Hi David,<br><br>I was checking out the broken vtkKdTree example at <a href="http://www.vtk.org/Wiki/VTK/Examples/Broken/vtkKdTree_BuildLocator_ClosestPoint">http://www.vtk.org/Wiki/VTK/Examples/Broken/vtkKdTree_BuildLocator_ClosestPoint</a> and it seems that the BuildLocator() method was more intended for use as an ordering of cells by centroid so that they can be order by a viewing direction.  I&#39;m not sure what was intended for this example but it shouldn&#39;t be used as an example of a point locator.  In any case, below is something you may want to put on the wiki.  I&#39;ll leave it up to you to decide how it should go in.<br>
<br>Andy<br><br>=========================<br><br>The BuildLocator() method in vtkKdTree can be used to order cells from a viewing direction.  The vtkKdTree region Ids are returned<br>from the ViewOrderAllRegions() method sorted from front to back in the specified direction.<br>
<br>==ClosestPoint.cxx==<br>&lt;source lang=&quot;cpp&quot;&gt;<br>#include &lt;vtkSmartPointer.h&gt;<br>#include &lt;vtkSphereSource.h&gt;<br>#include &lt;vtkIntArray.h&gt;<br>#include &lt;vtkKdTree.h&gt;<br><br>int main(int argc, char *argv[])<br>
{<br>  // Create a polydata source<br>  vtkSmartPointer&lt;vtkSphereSource&gt; sphere =<br>      vtkSmartPointer&lt;vtkSphereSource&gt;::New();<br>  sphere-&gt;SetThetaResolution(30);<br>  sphere-&gt;SetPhiResolution(40);<br>
<br>  //Create the tree<br>  vtkSmartPointer&lt;vtkKdTree&gt; kDTree =<br>      vtkSmartPointer&lt;vtkKdTree&gt;::New();<br>  //kDTree-&gt;SetNumberOfRegionsOrMore(3);<br>  kDTree-&gt;AddDataSet(sphere-&gt;GetOutput());<br>
  kDTree-&gt;BuildLocator();<br><br>  // Order the cells based on a viewing direction<br>  double direction[3] = {2, 1, 0};<br>  vtkSmartPointer&lt;vtkIntArray&gt; cellOrder =<br>    vtkSmartPointer&lt;vtkIntArray&gt;::New();<br>
  kDTree-&gt;ViewOrderAllRegionsInDirection(direction, cellOrder);<br>  cout &lt;&lt; &quot;Order of vtkKdTree regions is:\n&quot;;<br>  for(vtkIdType i=0;i&lt;cellOrder-&gt;GetNumberOfTuples()*cellOrder-&gt;GetNumberOfComponents();i++)<br>
    {<br>    cout &lt;&lt; cellOrder-&gt;GetValue(i) &lt;&lt; endl;<br>    }<br><br>  return EXIT_SUCCESS;<br>}<br><br><br>&lt;/source&gt;<br><br>==CMakeLists.txt==<br>&lt;source lang=&quot;cmake&quot;&gt;<br>cmake_minimum_required(VERSION 2.6)<br>
<br>PROJECT(KDTree)<br><br>FIND_PACKAGE(VTK REQUIRED)<br>INCLUDE(${VTK_USE_FILE})<br><br>ADD_EXECUTABLE(ClosestPoint ClosestPoint.cxx)<br>TARGET_LINK_LIBRARIES(ClosestPoint vtkHybrid)<br><br>&lt;/source&gt;<br><br>