<!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>&nbsp;</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&nbsp; 
0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
0<BR>0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0 
<BR>0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -8.43769e-19 
0.0038<BR>0.000992855 -1.68754e-18 
0.0076<BR>0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
-1.68754e-18 0.0076 </DIV>
<DIV>&nbsp;</DIV>
<DIV>POLYGONS 2 10<BR>4 0 1 2 3 <BR>4 4 0 3 5 </DIV>
<DIV>&nbsp;</DIV>
<DIV>CELL_DATA 2<BR>POINT_DATA 6<BR>------------------------------</DIV>
<DIV>&nbsp;</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>&nbsp;</DIV>
<DIV>------------------------------</FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=750124010-17082007></SPAN></FONT>&nbsp;</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>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN class=750124010-17082007>The problematic line 
in vtkPointLocator.cxx in&nbsp;method GetOverlappingBuckets is: 
</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=750124010-17082007></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN class=750124010-17082007>maxLevel[i] = (int) 
((double) (((x[i]+dist) - this-&gt;Bounds[2*i]) / 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (this-&gt;Bounds[2*i+1] - 
this-&gt;Bounds[2*i])) * this-&gt;Divisions[i]);<BR></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=750124010-17082007>Casting a very large 
(positive) double to int&nbsp;results in MIN_INT (negative).<BR>This occurs when 
the bounding box in one direction is very small,&nbsp;e.g. 
1e-18.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=750124010-17082007></SPAN></FONT>&nbsp;</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>&nbsp;</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-&gt;Bounds[2*i]) / 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (this-&gt;Bounds[2*i+1] - 
this-&gt;Bounds[2*i])) * this-&gt;Divisions[i]);<BR>if (xx &gt; 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>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN class=750124010-17082007>Could someone with 
access to&nbsp;CVS&nbsp;check this or niftier 
solution&nbsp;in?</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=750124010-17082007></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=750124010-17082007></SPAN></FONT>&nbsp;</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>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=750124010-17082007></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=750124010-17082007></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=750124010-17082007></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=750124010-17082007></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=750124010-17082007></SPAN></FONT>&nbsp;</DIV></BODY></HTML>