[Insight-users] Error: it says Undefining object , please have a look

Sylvain Jaume sylvain.jaume at kitware.com
Thu Feb 1 17:15:40 EST 2007


Hi Thomas and Tony,

If you're reading and writing triangle meshes,
you could use itkVTKPolyDataReader.h and itkVTKPolyDataWriter.h
in Insight/Code/Review/.

Sylvain

Thomas Lambertz wrote:
> Hi Tony,
> 
> i havent worked with meshes - so i cannot give you some detailed code.
> 
> You may have a look into the code embedded in 
> http://www.itk.org/pipermail/insight-users/2004-March/007501.html
> 
> It seemes to work with iterators on meshes.
> 
> Hth,
> Tom
> 
> 
> 
> tony hakki wrote:
>> Could you please suggest me an example to convert itk mesh to  vtk 
>> polydata,I haven't accomplished such a easy application yet,And I am 
>> really angry with mymeslf,please help me
>>
>>
>>  
>> ----- Original Message ----
>> From: Thomas Lambertz <thomas at hexerei-software.de>
>> To: insight-users at itk.org
>> Sent: Thursday, February 1, 2007 2:17:28 PM
>> Subject: Re: [Insight-users] Error: it says Undefining object , please 
>> have a look
>>
>> 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
>> > 
>> _______________________________________________
>> Insight-users mailing list
>> Insight-users at itk.org
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>>
>> ------------------------------------------------------------------------
>> Don't be flakey. Get Yahoo! Mail for Mobile 
>> <http://us.rd.yahoo.com/evt=43909/*http://mobile.yahoo.com/mail> and
>> always stay connected 
>> <http://us.rd.yahoo.com/evt=43909/*http://mobile.yahoo.com/mail> to 
>> friends.
> 
> _______________________________________________
> 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