[Insight-users] Re: [vtkusers] itkmeshtovtkpolydata

Bill Lorensen bill.lorensen at gmail.com
Thu Feb 22 07:52:01 EST 2007


The statement should read:
itk::Point pnt = pntIterator.Value();


On 2/22/07, tony hakki <tony2007vtk at yahoo.com> wrote:
>
>  Hello dear ITK and VTK users;
>
> First I converted vtk polydata to itk mesh format. After some processing I
> want to reconvert itk mesh to vtk polydata format. TO implement that I found
> an code through the internet. It seems good,But one line it gives an error,I
> couldn't understand reason of that. Could any one help me on that problem.
> It will be really appreciated help for me.
> Here is the code and I indicated the line which gives error
>
>  *//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
> typedef MeshType::PointsContainer::ConstIterator  PointIterator;
>   PointIterator pntIterator = mesh->GetPoints()->Begin();
>   PointIterator pntItEnd = mesh->GetPoints()->End();
>   for (int i = 0; pntIterator != pntItEnd; ++i, ++pntIterator)
>     {
>     ItkPoint pnt = pntIterator.Value();  //Here it says *ItkPoint* is
> undeclared identifier ,how  should I define that
>     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();
>
>
>
> ------------------------------
> TV dinner still cooling?
> Check out "Tonight's Picks"<http://us.rd.yahoo.com/evt=49979/*http://tv.yahoo.com/>on Yahoo! TV.
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070222/83087217/attachment.htm


More information about the Insight-users mailing list