<!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 "GetLocator" vtkPointLocator. 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. Also, when I try to get a point from the marching filter by using GetPoint(any integer), my program stops. 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. Below is how I used vtkMarchingCubes with a structured points reader.<BR>
<BR>
vtkMarchingCubes * contour = vtkMarchingCubes::New();<BR>
contour->AddInputConnection( reader1->GetOutputPort() );<BR>
contour->SetValue(1,120);<BR>
contour->GenerateValues(2,500.0,600);<BR>
contour->ComputeNormalsOn();<BR>
contour->ComputeGradientsOn();<BR>
contour->ComputeScalarsOn();<BR>
<BR>
vtkIdType axe;<BR>
vtkPointLocator *below = vtkPointLocator::New();<BR>
axe=below->FindClosestPoint(458.4098, 446.6154, 441.8497);<BR>
cout << contour->GetOutput()->GetPoint(axe) << endl;<BR>
The last line is as far as it gets.<BR>
<BR>
Original Message:<BR>
I am having some trouble with vtkKdTree. 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. 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. If this is the case, should the following work (or better phrased, why doesn't it)?<BR>
vtkKdTree * example = vtkKdTree::New();<BR>
example->BuildLocatorFromPoints(contour->GetOutput()->GetPoints());</FONT>
</P>
</BODY>
</HTML>