<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7652.24">
<TITLE>RE: [vtkusers] vtkKdTree BuildLocatorFromPoints trouble</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=2>Upon further investigation into my problem, I noticed that vtkMarchingContourFilter and vtkMarchingCubes each have a &quot;GetLocator&quot; vtkPointLocator.&nbsp; I tried them instead of using the vtkKdTree locator, and they seem to indicate that the Id of the closest point to any point is -1.&nbsp; Also, when I try to get a point from the marching filter by using GetPoint(any integer), my program stops.&nbsp; Any ideas as to what I could be doing wrong to get no point Ids from vtkMarchingCubes, as well as no points when supplying Ids.&nbsp; Below is how I used vtkMarchingCubes with a structured points reader.<BR>
<BR>
&nbsp;&nbsp;&nbsp; vtkMarchingCubes * contour = vtkMarchingCubes::New();<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; contour-&gt;AddInputConnection( reader1-&gt;GetOutputPort() );<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; contour-&gt;SetValue(1,120);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; contour-&gt;GenerateValues(2,500.0,600);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; contour-&gt;ComputeNormalsOn();<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; contour-&gt;ComputeGradientsOn();<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; contour-&gt;ComputeScalarsOn();<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkIdType axe;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkPointLocator *below = vtkPointLocator::New();<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; axe=below-&gt;FindClosestPoint(458.4098, 446.6154, 441.8497);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cout &lt;&lt; contour-&gt;GetOutput()-&gt;GetPoint(axe) &lt;&lt; endl;<BR>
The last line is as far as it gets.<BR>
<BR>
Original Message:<BR>
I am having some trouble with vtkKdTree.&nbsp; I read data in as structured points, turn it into a surface with vtkMarchingContourFilter, and would like to find the nearest point of this surface to a specified point in space.&nbsp; To do this, do I need to get the point data from the contour filter and use BuildLocatorFromPoints, or would I just set the contour filter output as the data set and use BuildLocator; I ask because the manual pages online suggest that vtkIdType vtkKdTree::FindClosestPoint requires the locator be from BuildLocatorFromPoints.&nbsp; If this is the case, should the following work (or better phrased, why doesn't it)?<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkKdTree * example = vtkKdTree::New();<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; example-&gt;BuildLocatorFromPoints(contour-&gt;GetOutput()-&gt;GetPoints());</FONT>
</P>

</BODY>
</HTML>