[Insight-users] itkmeshtovtkpolydata
tony hakki
tony2007vtk at yahoo.com
Thu Feb 22 05:12:47 EST 2007
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();
____________________________________________________________________________________
Food fight? Enjoy some healthy debate
in the Yahoo! Answers Food & Drink Q&A.
http://answers.yahoo.com/dir/?link=list&sid=396545367
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070222/055fbd22/attachment.htm
More information about the Insight-users
mailing list