[vtkusers] Bug in vtkKdTreePointLocator for distant points

Christophe Van Dijck christophe_vandijck at hotmail.com
Fri Nov 4 08:38:43 EDT 2016


Hi,

I discovered a possible bug in the vtkKdTreePointLocator for distant points. I included a small example in python. For compatibility reasons, I'm still at commit 2d7055f19972012e8120281d50604d5bfd2a9be2 so it might be already solved...


It only occurs when the point is further than double the distance of the maxDist of the target dataset (in the example > 2*10+5) and if there are significant number of points so that multiple regions exist.


Regards,

Christophe


Code:


import vtk

# Setup point coordinates
source = vtk.vtkSphereSource()
source.SetCenter(0,0,0)
source.SetRadius(5.0)
source.SetThetaResolution(120)
source.SetPhiResolution(70)
source.Update()

polydata = vtk.vtkPolyData()
polydata.DeepCopy(source.GetOutput())

# Create the tree
kDTree = vtk.vtkKdTreePointLocator()
kDTree.SetDataSet(polydata)
kDTree.BuildLocator()

testPoint = [0.0, 0.0, 25.] # all points up to [0., 0., 24.9999...] give [0., 0., 5.] as closest point

print("Test point: ", ', '.join([str(x) for x in testPoint]))

# Find the closest points to TestPoint
iD = kDTree.FindClosestPoint(testPoint)
print("\nThe closest point is point %d" % iD)

#Get the coordinates of the closest point
closestPoint = [0.0, 0.0, 0.0]
kDTree.GetDataSet().GetPoint(iD, closestPoint)
print("Coordinates: %f, %f, %f" % (closestPoint[0], closestPoint[1], closestPoint[2])) # Should be [0., 0., 5.] but returns  [-2.452237, -1.985783, -3.878556]



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161104/5e2775b4/attachment-0001.html>


More information about the vtkusers mailing list