[Insight-users] platform dependent code in vtkPolyDataToitkMesh.cxx
Georgi.Diakov at i-med.ac.at
Georgi.Diakov at i-med.ac.at
Thu Jun 19 04:19:16 EDT 2008
Dear Insight Users,
it seems that a line in the very handy and often used filter
"vtkPolyDataToitkMesh" makes it platform dependent, which may cause
unpredictable errors on some platforms. That line is:
t->SetPointIds( (unsigned long*)cellPoints );
This line sets the vertex indeces for the triangles in the mesh by
copying the cell point ids from the polydata. t is from
TriangleCellType. cellPoints is from vtkIdType, which is an integer and
is declared in a platform independent manner in vtkIdType.h. The cast
to unsigned long* type is platform dependent, which may lead to changed
triangle vertex ids in the mesh. I experienced this under Fedora Linux
on Pentium 4, where the mesh was distorted, something like drawing
random lines between its points. I solved the problem by declaring a
new variable of the type unsigned long* by:
unsigned long* meshids = new unsigned long[3];
and asigning the id values manually at each iteration:
meshids[0] = cellPoint[0]; and so on to [2].
Then:
t->SetPointIds(meshids);
This is probably not the most elegant way to modify the filter. I would
suggest defining a platform independent id type for itk, similarly to
vtkIdType.
Best regards,
Georgi
More information about the Insight-users
mailing list