[vtk-developers] KdTree FindPointsWithinRadius

pat marion pat.marion at kitware.com
Fri Aug 20 15:32:01 EDT 2010


Sorry to be a stick in the mud... why not just write your own function to
replace that for loop and other setup code?

  vtkSmartPointer<vtkIdList> neighbors = MyGetPointInRadius(kdTree, pointID,
eRadius);

Pat

On Fri, Aug 20, 2010 at 3:16 PM, David Doria
<daviddoria+vtk at gmail.com<daviddoria%2Bvtk at gmail.com>
> wrote:

> An operation that I perform extremely frequently is to build a tree on a
> set of points and then query for all neighbors within a radius of a point
> that is in the tree. Currently the procedure is to get the coordinates of
> the point, then query the tree, then remember to ignore the point that was
> the query point:
>
>     double queryPoint[3];
>     input->GetPoint(pointID, queryPoint);
>
>     //find all the points around the query point
>     vtkSmartPointer<vtkIdList> neighbors =
>       vtkSmartPointer<vtkIdList>::New();
>     kdTree->FindPointsWithinRadius(eRadius, queryPoint, neighbors);
>
>     // Do something with the neighbors
>     for(vtkIdType n = 0; n < neighbors->GetNumberOfIds(); n++)
>       {
>       if(neighbors->GetId(n) == pointID) //we have found exactly the same
> point we queried for!
>         {
>         continue;
>         }
>
> I would like to propose adding a function to query by a pointID already in
> the tree.
>
>   // Description:
>   // Find all points within a specified radius R of point n.
>   // The result does not include point n.
>   virtual void FindPointsWithinRadius(double R, const vtkIdType n,
>                                       vtkIdList *result);
>
> void vtkKdTreePointLocator::FindPointsWithinRadius(double R, const
> vtkIdType n,
>                                       vtkIdList *result)
> {
>   double queryPoint[3];
>   vtkPointSet::SafeDownCast(this->GetDataSet())->GetPoint(n, queryPoint);
>   this->BuildLocator();
>   this->KdTree->FindPointsWithinRadius(R, queryPoint, result);
>   result->DeleteId(n);
> }
>
> I have also added a test for both the new and old method.
>
> I have created a branch here:
> repo: git at github.com:daviddoria/daviddoria-vtk.git
> branch: VTK-KdTree
>
> Any comments?
>
> Thanks,
>
> David
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20100820/bce6cc1c/attachment.html>


More information about the vtk-developers mailing list