[vtkusers] vtkKdTreePointLocator sometimes gives wrong answer

Mengda Wu wumengda at gmail.com
Fri Nov 7 00:47:54 EST 2008

Hi all,

   I am trying to use vtkKdTreePointLocator to find the nearest point in a
Polydata to a given point.
The code I am using is as follows:

  vtkKdTreePointLocator  *kdt = vtkKdTreePointLocator::New();
  kdt->SetDataSet( a_polydata );

  vtkIdType id= kdt->FindClosestPoint(given_point_coordinate);
  a_polydat->GetPoint(id, nearest_point_coordinate);

  But I found "nearest_point_coordinate" is not always the right answer.
Sometimes, the result is
very far from the right answer. Am I missing something? Shouldn't the
returned variable "id"
be always the index of the nearest point?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081106/0ca52b6a/attachment.htm>

More information about the vtkusers mailing list