Sorry to be a stick in the mud... why not just write your own function to replace that for loop and other setup code?<br>
<br>
  vtkSmartPointer<vtkIdList> neighbors = MyGetPointInRadius(kdTree, pointID, eRadius);<br><br>
Pat<br><br><div class="gmail_quote">On Fri, Aug 20, 2010 at 3:16 PM, David Doria <span dir="ltr"><<a href="mailto:daviddoria%2Bvtk@gmail.com">daviddoria+vtk@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
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:<div>



<br></div><div><div>    double queryPoint[3];</div><div>    input->GetPoint(pointID, queryPoint);</div><div><br></div><div>    //find all the points around the query point</div><div>    vtkSmartPointer<vtkIdList> neighbors =</div>



<div>      vtkSmartPointer<vtkIdList>::New();</div><div>    kdTree->FindPointsWithinRadius(eRadius, queryPoint, neighbors);</div><div><br></div><div>    // Do something with the neighbors</div><div>    for(vtkIdType n = 0; n < neighbors->GetNumberOfIds(); n++)</div>



<div>      {</div><div>      if(neighbors->GetId(n) == pointID) //we have found exactly the same point we queried for!</div><div>        {</div><div>        continue;</div><div>        }</div><div><br></div><div>I would like to propose adding a function to query by a pointID already in the tree. </div>



<div><br></div><div><div>  // Description:</div><div>  // Find all points within a specified radius R of point n.</div><div>  // The result does not include point n.</div><div>  virtual void FindPointsWithinRadius(double R, const vtkIdType n,</div>



<div>                                      vtkIdList *result);</div></div><div><br></div><div><div><div>void vtkKdTreePointLocator::FindPointsWithinRadius(double R, const vtkIdType n,</div><div>                                      vtkIdList *result)</div>


<div>{</div><div>  double queryPoint[3];</div><div>  vtkPointSet::SafeDownCast(this->GetDataSet())->GetPoint(n, queryPoint);</div><div>  this->BuildLocator();</div><div>  this->KdTree->FindPointsWithinRadius(R, queryPoint, result);</div>


<div>  result->DeleteId(n);</div><div>}</div></div></div><div><br></div><div>I have also added a test for both the new and old method.</div><div><br></div><div>I have created a branch here:</div><div>repo: git@github.com:daviddoria/daviddoria-vtk.git</div>


<div>branch: VTK-KdTree</div><div><br></div><div>Any comments?</div><div><br></div>Thanks,<br><br>David<br>
</div>
<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtk-developers" target="_blank">http://www.vtk.org/mailman/listinfo/vtk-developers</a><br>
<br>
<br></blockquote></div><br>