[vtkusers] vtkKdTreePointLocator sometimes gives wrong answer

Andy Bauer andy.bauer at kitware.com
Fri Nov 7 16:03:06 EST 2008


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.

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.

Andy



>
> Message: 12
> Date: Thu, 6 Nov 2008 21:47:54 -0800
> From: "Mengda Wu" <wumengda at gmail.com>
> Subject: [vtkusers] vtkKdTreePointLocator sometimes gives wrong answer
> To: vtkusers at vtk.org
> Message-ID:
>        <e56638dd0811062147g5692303esdf69f295cd63b80e at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> 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?
>
> Thanks,
> Mengda
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081107/d41f595e/attachment.htm>


More information about the vtkusers mailing list