[Insight-users] Error: it says Undefining object , please have
a look
Thomas Lambertz
thomas at hexerei-software.de
Thu Feb 1 08:17:28 EST 2007
Hi Tony,
you may have a look into Chapter 11 of the itkSoftwareGuide - its about
using iterators.
Seemes you missed your type declartions - something like
typedefitk::Image<float,3>ImageType;
typedefitk::ImageRegionConstIterator<ImageType>ConstIteratorType;
typedefitk::ImageRegionIterator<ImageType>IteratorType;
(keep in mind that this is for itkImage and not itkMesh)
Hth,
Tom
tony hakki wrote:
> Hello All;
> I converted vtk polydata to itk mesh. Now I would like to convert that
> mesh to the vtk poly data for testing if first converting right. To
> convert mesh to vtk poly data I would like to use the following code
> ,bur unfortunately it gives an error ,I have also indicated that line
> with red below.
>
> I want to convert Itk mesh to vtk poly data.
> vtkPolyData* ITKMeshToVtkPolyData( MeshType::Pointer *mesh* )
> {
> //Creat a new vtkPolyData
> vtkPolyData* newPolyData = vtkPolyData::New();
>
> //Creat vtkPoints for insertion into newPolyData
> vtkPoints *points = vtkPoints::New();
> std::cout<<"Points = "<<*mesh*->GetNumberOfPoints()<<std::endl;
>
> //Copy all points into the vtkPolyData structure
> PointIterator pntIterator = *mesh*->GetPoints()->Begin(); // it says
> PointIterator is Undefining
> PointIterator pntItEnd = *mesh*->GetPoints()->End();
> for (int i = 0; pntIterator != pntItEnd; ++i, ++pntIterator)
> {
> ItkPoint pnt = pntIterator.Value(); // also here it says
> ItkPoint is undefining ,How can I define them??
> points->InsertPoint(i, pnt[0], pnt[1], pnt[2]);
> // std::cout<<i<<"-th point: ";
> // std::cout<<pnt[0]<<std::endl;
> // std::cout<<" "<<pntIterator.Value()<<std::endl;
> // ++pntIterator;
> }
> newPolyData->SetPoints(points);
> points->Delete();
>
> //Copy all cells into the vtkPolyData structure
> //Creat vtkCellArray into which the cells are copied
> vtkCellArray* triangle = vtkCellArray::New();
> CellIterator cellIt = *mesh*->GetCells()->Begin();
> CellIterator cellItEnd = *mesh*->GetCells()->End();
> for (int it = 0; cellIt != cellItEnd; ++it, ++cellIt)
> {
> CellType * cellptr = cellIt.Value();
> // LineType * line = dynamic_cast<LineType *>( cellptr );
> // std::cout << line->GetNumberOfPoints() << std::endl;
> // std::cout << cellptr->GetNumberOfPoints() << std::endl;
> PointIdIterator pntIdIter = cellptr->PointIdsBegin();
> PointIdIterator pntIdEnd = cellptr->PointIdsEnd();
> vtkIdList* pts = vtkIdList::New();
> for (; pntIdIter != pntIdEnd; ++pntIdIter)
> {
> pts->InsertNextId( *pntIdIter );
> // std::cout<<" "<<tempCell[it1]<<std::endl;
> }
> triangle->InsertNextCell(pts);
> }
> newPolyData->SetPolys(triangle);
> triangle->Delete();
>
> // return the vtkUnstructuredGrid
> return newPolyData;
> }
>
> Thank you
> Tony
>
> ------------------------------------------------------------------------
> Don't pick lemons.
> See all the new 2007 cars
> <http://autos.yahoo.com/new_cars.html;_ylc=X3oDMTE0OGRsc3F2BF9TAzk3MTA3MDc2BHNlYwNtYWlsdGFncwRzbGsDbmV3Y2Fycw-->
> at Yahoo! Autos.
> <http://autos.yahoo.com/new_cars.html;_ylc=X3oDMTE0OGRsc3F2BF9TAzk3MTA3MDc2BHNlYwNtYWlsdGFncwRzbGsDbmV3Y2Fycw-->
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
More information about the Insight-users
mailing list