<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).&nbsp; 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.&nbsp; Of course this only accounts for the returned point being &quot;slightly&quot; farther away from the input point than the actual closest point.&nbsp; A simple test would be to compare the results with vtkPointLocator.&nbsp; <br>
<br>If you&#39;re still seeing problems with it, please send me your code along with any input files so that I can look at what&#39;s going on.&nbsp; <br><br>Andy <br></div><div><br>&nbsp;</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: &quot;Mengda Wu&quot; &lt;<a href="mailto:wumengda@gmail.com">wumengda@gmail.com</a>&gt;<br>
Subject: [vtkusers] vtkKdTreePointLocator sometimes gives wrong answer<br>
To: <a href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a><br>
Message-ID:<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;<a href="mailto:e56638dd0811062147g5692303esdf69f295cd63b80e@mail.gmail.com">e56638dd0811062147g5692303esdf69f295cd63b80e@mail.gmail.com</a>&gt;<br>
Content-Type: text/plain; charset=&quot;iso-8859-1&quot;<br>
<br>
Hi all,<br>
<br>
 &nbsp; 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>
 &nbsp;vtkKdTreePointLocator &nbsp;*kdt = vtkKdTreePointLocator::New();<br>
 &nbsp;kdt-&gt;SetDataSet( a_polydata );<br>
<br>
 &nbsp;vtkIdType id= kdt-&gt;FindClosestPoint(given_point_coordinate);<br>
 &nbsp;a_polydat-&gt;GetPoint(id, nearest_point_coordinate);<br>
<br>
 &nbsp;But I found &quot;nearest_point_coordinate&quot; is not always the right answer.<br>
Sometimes, the result is<br>
very far from the right answer. Am I missing something? Shouldn&#39;t the<br>
returned variable &quot;id&quot;<br>
be always the index of the nearest point?<br>
<br>
Thanks,<br>
Mengda<br>
</blockquote></div><br>