<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:14pt"><DIV>Hello All;</DIV>
<DIV>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.</DIV>
<DIV> </DIV>
<DIV>I want to convert Itk mesh to vtk poly data.</DIV>
<DIV>vtkPolyData* ITKMeshToVtkPolyData( MeshType::Pointer <B style="COLOR: black; BACKGROUND-COLOR: #a0ffff">mesh</B> )<BR>{<BR> //Creat a new vtkPolyData<BR> vtkPolyData* newPolyData = vtkPolyData::New();<BR><BR> //Creat vtkPoints for insertion into newPolyData<BR> vtkPoints *points = vtkPoints::New();<BR> std::cout<<"Points = "<<<B style="COLOR: black; BACKGROUND-COLOR: #a0ffff">mesh</B>->GetNumberOfPoints()<<std::endl;<BR><BR> //Copy all points into the vtkPolyData structure<BR> <FONT color=#ff0000>PointIterator pntIterator = <B style="COLOR: black; BACKGROUND-COLOR: #a0ffff">mesh</B>->GetPoints()->Begin(); // it says PointIterator is Undefining <BR> PointIterator pntItEnd = <B style="COLOR: black; BACKGROUND-COLOR: #a0ffff">mesh</B>->GetPoints()->End();<BR></FONT> for (int i = 0; pntIterator != pntItEnd; ++i, ++pntIterator)<BR> {<BR> <FONT
color=#ff0000>ItkPoint pnt = pntIterator.Value(); // also here it says ItkPoint is undefining ,<FONT size=5>How can I define them??<BR></FONT></FONT> points->InsertPoint(i, pnt[0], pnt[1], pnt[2]);<BR>// std::cout<<i<<"-th point: ";<BR>// std::cout<<pnt[0]<<std::endl;<BR>// std::cout<<" "<<pntIterator.Value()<<std::endl;<BR>// ++pntIterator;<BR> }<BR> newPolyData->SetPoints(points);<BR> points->Delete();<BR><BR> //Copy all cells into the vtkPolyData structure<BR> //Creat vtkCellArray into which the cells are copied<BR> vtkCellArray* triangle = vtkCellArray::New();<BR> CellIterator cellIt = <B style="COLOR: black;
BACKGROUND-COLOR: #a0ffff">mesh</B>->GetCells()->Begin();<BR> CellIterator cellItEnd = <B style="COLOR: black; BACKGROUND-COLOR: #a0ffff">mesh</B>->GetCells()->End();<BR> for (int it = 0; cellIt != cellItEnd; ++it, ++cellIt)<BR> {<BR> CellType * cellptr = cellIt.Value();<BR> // LineType * line = dynamic_cast<LineType *>( cellptr );<BR> // std::cout << line->GetNumberOfPoints() << std::endl;<BR> // std::cout << cellptr->GetNumberOfPoints() << std::endl;<BR> PointIdIterator pntIdIter = cellptr->PointIdsBegin();<BR> PointIdIterator pntIdEnd = cellptr->PointIdsEnd();<BR> vtkIdList* pts = vtkIdList::New();<BR> for (; pntIdIter != pntIdEnd; ++pntIdIter)<BR>
{<BR> pts->InsertNextId( *pntIdIter );<BR> // std::cout<<" "<<tempCell[it1]<<std::endl;<BR> }<BR> triangle->InsertNextCell(pts);<BR> }<BR> newPolyData->SetPolys(triangle);<BR> triangle->Delete();<BR><BR> // return the vtkUnstructuredGrid<BR> return newPolyData;<BR>}<BR></DIV>
<DIV> </DIV>
<DIV>Thank you </DIV>
<DIV>Tony</DIV></div><br>
<hr size=1>Don't pick lemons.<br>
See all the <a href="http://autos.yahoo.com/new_cars.html;_ylc=X3oDMTE0OGRsc3F2BF9TAzk3MTA3MDc2BHNlYwNtYWlsdGFncwRzbGsDbmV3Y2Fycw--">new 2007 cars</a> at <a href="http://autos.yahoo.com/new_cars.html;_ylc=X3oDMTE0OGRsc3F2BF9TAzk3MTA3MDc2BHNlYwNtYWlsdGFncwRzbGsDbmV3Y2Fycw--">Yahoo! Autos.</a></body></html>