<div class="gmail_quote"><div>Yes, FindClosestPoint should return a point that has no other points in the data set that are closer (there could be multiple points that are this same distance away though). Note that the returned point calculation is also susceptible to round-off error since the points in vtkKdTree are stored as floats instead of the native data set format. Of course this only accounts for the returned point being "slightly" farther away from the input point than the actual closest point. A simple test would be to compare the results with vtkPointLocator. <br>
<br>If you're still seeing problems with it, please send me your code along with any input files so that I can look at what's going on. <br><br>Andy <br></div><div><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Message: 12<br>
Date: Thu, 6 Nov 2008 21:47:54 -0800<br>
From: "Mengda Wu" <<a href="mailto:wumengda@gmail.com">wumengda@gmail.com</a>><br>
Subject: [vtkusers] vtkKdTreePointLocator sometimes gives wrong answer<br>
To: <a href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a><br>
Message-ID:<br>
<<a href="mailto:e56638dd0811062147g5692303esdf69f295cd63b80e@mail.gmail.com">e56638dd0811062147g5692303esdf69f295cd63b80e@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="iso-8859-1"<br>
<br>
Hi all,<br>
<br>
I am trying to use vtkKdTreePointLocator to find the nearest point in a<br>
Polydata to a given point.<br>
The code I am using is as follows:<br>
<br>
vtkKdTreePointLocator *kdt = vtkKdTreePointLocator::New();<br>
kdt->SetDataSet( a_polydata );<br>
<br>
vtkIdType id= kdt->FindClosestPoint(given_point_coordinate);<br>
a_polydat->GetPoint(id, nearest_point_coordinate);<br>
<br>
But I found "nearest_point_coordinate" is not always the right answer.<br>
Sometimes, the result is<br>
very far from the right answer. Am I missing something? Shouldn't the<br>
returned variable "id"<br>
be always the index of the nearest point?<br>
<br>
Thanks,<br>
Mengda<br>
</blockquote></div><br>