<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<title></title>
</head>
<body>
I can give you a practical example. The two attached poly data files contain<br>
two faces each: a quadrilateral and a triangle. The points in testPolydata07.vtk<br>
have integer coordinates, and those from testPolydata08.vtk were obtained<br>
by multiplying each point with 3/25. <br>
<br>
The coordinates of the points in the vtkPolyData created by reading these<br>
files differ from those on files by more than 10^(-8). Due to this fact the<br>
volume of the tetrahedron is of order 10^(-9). The following code snippet<br>
allows you to see this, if you run it in debug mode and insert a breakpoint
at <br>
the last sentence:<br>
<br>
<i> vtkPolyDataReader* reader = vtkPolyDataReader::New();<br>
polyData = vtkPolyData::New();<br>
<br>
reader->SetFileName("testPolydata08.vtk");<br>
vtkPolyData* readData = reader->GetOutput();<br>
readData->Update();<br>
<br>
vtkCell* cell = readData->GetCell(0);<br>
bool planar = true;<br>
if (cell->GetCellType()==VTK_QUAD)<br>
{<br>
vtkPoints *cellPoints = cell->GetPoints();<br>
double vertices[4][3];<br>
for (int i=0; i<4; i++)<br>
{<br>
double *aVert = cellPoints->GetPoint(i);<br>
memcpy(vertices[i], aVert, 3*sizeof(double));<br>
}<br>
double vol = vtkTetra::ComputeVolume(vertices[0], vertices[1], vertices[2],
vertices[3]);<br>
if (abs(vol)>1.0e-10)<br>
{<br>
planar = false;<br>
}<br>
}</i><br>
<br>
Of course, I am not urging you to try this out.<br>
<br>
My theory is that reading is done in float, and the vtkPolyData arithmetic<br>
is in double; when storing the read points to the vtkPolyData points, the
latter<br>
are not initialized with 0 and some residual non-zero digits of small order
<br>
are preserved.<br>
<br>
For some real-life examples, the errors are even bigger (10^(-6)); you can
imagine<br>
the influence of these errors to precision-sensible computations... <br>
<br>
For the moment, I see no way to eliminate this effect.<br>
<br>
Petru<br>
</body>
</html>