<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<TITLE>Nachricht</TITLE>
<META content="MSHTML 6.00.6000.16525" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2><SPAN class=750124010-17082007>Hi vtk
users,</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=750124010-17082007></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=750124010-17082007>I think i stumbled
upon a bug in vtkPointLocator in method
GetOverlappingBuckets.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=750124010-17082007>The following
example does not work properly:</SPAN></FONT></DIV><FONT face=Arial size=2>
<DIV><BR>------------------------------<BR># vtk DataFile Version 3.0<BR>vtk
output<BR>ASCII<BR>DATASET POLYDATA<BR>POINTS 6 float<BR>0.000992855
-8.43769e-19 0.0038<BR>0.000992855
0
0<BR>0
0 0
<BR>0 -8.43769e-19
0.0038<BR>0.000992855 -1.68754e-18
0.0076<BR>0
-1.68754e-18 0.0076 </DIV>
<DIV> </DIV>
<DIV>POLYGONS 2 10<BR>4 0 1 2 3 <BR>4 4 0 3 5 </DIV>
<DIV> </DIV>
<DIV>CELL_DATA 2<BR>POINT_DATA 6<BR>------------------------------</DIV>
<DIV> </DIV>
<DIV>from vtk import *<BR>reader =
vtkPolyDataReader()<BR>reader.SetFileName('grid.vtk')<BR>reader.Update()<BR>locator
= vtkPointLocator()<BR>locator.SetDataSet(reader.GetOutput())<BR>x = (0, 0,
0.0076)<BR>ptId = locator.FindClosestPoint(x)<BR>print "IN : ", x<BR>print "OUT:
", reader.GetOutput().GetPoint(ptId)</DIV>
<DIV> </DIV>
<DIV>------------------------------</FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=750124010-17082007></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=750124010-17082007>The correct result
should be (0, -1.68754e-18, 0.0076), instead FindClosestPoint returns (0,
-8.43769e-19, 0.0038).</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=750124010-17082007></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=750124010-17082007>The problematic line
in vtkPointLocator.cxx in method GetOverlappingBuckets is:
</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=750124010-17082007></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=750124010-17082007>maxLevel[i] = (int)
((double) (((x[i]+dist) - this->Bounds[2*i]) /
<BR> (this->Bounds[2*i+1] -
this->Bounds[2*i])) * this->Divisions[i]);<BR></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=750124010-17082007>Casting a very large
(positive) double to int results in MIN_INT (negative).<BR>This occurs when
the bounding box in one direction is very small, e.g.
1e-18.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=750124010-17082007></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=750124010-17082007>Possible solution:
</DIV></SPAN></FONT>
<DIV><FONT face=Arial size=2><SPAN class=750124010-17082007>Replace above line
with:</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=750124010-17082007></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=750124010-17082007>double
xx;</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=750124010-17082007>xx = ((double)
(((x[i]+dist) - this->Bounds[2*i]) /
<BR> (this->Bounds[2*i+1] -
this->Bounds[2*i])) * this->Divisions[i]);<BR>if (xx > VTK_INT_MAX)
maxLevel[i] = VTK_INT_MAX;<BR>else maxLevel[i] = (int) xx;</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=750124010-17082007></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=750124010-17082007>Could someone with
access to CVS check this or niftier
solution in?</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=750124010-17082007></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=750124010-17082007></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=750124010-17082007>Regards,
</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=750124010-17082007>Reinhold
Niesner</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=750124010-17082007></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=750124010-17082007></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=750124010-17082007></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=750124010-17082007></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=750124010-17082007></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=750124010-17082007></SPAN></FONT> </DIV></BODY></HTML>