[vtkusers] vtkKdTree BuildLocatorFromPoints trouble

jtaclas at bidmc.harvard.edu jtaclas at bidmc.harvard.edu
Fri Oct 26 11:44:31 EDT 2007


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.

    vtkMarchingCubes * contour = vtkMarchingCubes::New();
	contour->AddInputConnection( reader1->GetOutputPort() );
	contour->SetValue(1,120);
        contour->GenerateValues(2,500.0,600);
	contour->ComputeNormalsOn();
	contour->ComputeGradientsOn();
	contour->ComputeScalarsOn();

	vtkIdType axe;
	vtkPointLocator *below = vtkPointLocator::New();
	axe=below->FindClosestPoint(458.4098, 446.6154, 441.8497);
	cout << contour->GetOutput()->GetPoint(axe) << endl;
The last line is as far as it gets.

Original Message:
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)?
        vtkKdTree * example = vtkKdTree::New();
        example->BuildLocatorFromPoints(contour->GetOutput()->GetPoints());
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20071026/7157f537/attachment.htm>


More information about the vtkusers mailing list