[vtkusers] what changes the coordinates?
Petru Pau
ppau at risc.uni-linz.ac.at
Tue Aug 24 04:24:51 EDT 2004
I can give you a practical example. The two attached poly data files contain
two faces each: a quadrilateral and a triangle. The points in
testPolydata07.vtk
have integer coordinates, and those from testPolydata08.vtk were obtained
by multiplying each point with 3/25.
The coordinates of the points in the vtkPolyData created by reading these
files differ from those on files by more than 10^(-8). Due to this fact the
volume of the tetrahedron is of order 10^(-9). The following code snippet
allows you to see this, if you run it in debug mode and insert a
breakpoint at
the last sentence:
vtkPolyDataReader* reader = vtkPolyDataReader::New();
polyData = vtkPolyData::New();
reader->SetFileName("testPolydata08.vtk");
vtkPolyData* readData = reader->GetOutput();
readData->Update();
vtkCell* cell = readData->GetCell(0);
bool planar = true;
if (cell->GetCellType()==VTK_QUAD)
{
vtkPoints *cellPoints = cell->GetPoints();
double vertices[4][3];
for (int i=0; i<4; i++)
{
double *aVert = cellPoints->GetPoint(i);
memcpy(vertices[i], aVert, 3*sizeof(double));
}
double vol = vtkTetra::ComputeVolume(vertices[0], vertices[1],
vertices[2], vertices[3]);
if (abs(vol)>1.0e-10)
{
planar = false;
}
}
Of course, I am not urging you to try this out.
My theory is that reading is done in float, and the vtkPolyData arithmetic
is in double; when storing the read points to the vtkPolyData points,
the latter
are not initialized with 0 and some residual non-zero digits of small order
are preserved.
For some real-life examples, the errors are even bigger (10^(-6)); you
can imagine
the influence of these errors to precision-sensible computations...
For the moment, I see no way to eliminate this effect.
Petru
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040824/164583a4/attachment.htm>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: testPolydata07.vtk
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040824/164583a4/attachment.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: testPolydata08.vtk
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040824/164583a4/attachment.asc>
More information about the vtkusers
mailing list