[vtkusers] Number of points in a KdTree?

David Doria daviddoria+vtk at gmail.com
Mon Oct 26 15:17:45 EDT 2009


On Mon, Oct 26, 2009 at 2:58 PM, Paul Edwards <paul.m.edwards at gmail.com> wrote:
> The original data should be returned with vtkKdTree::GetDataSets()
>
> Regards,
> Paul

That's what I thought... Here's what I tried:

	vtkSmartPointer<vtkPoints> Points = vtkSmartPointer<vtkPoints>::New();
  Points->InsertNextPoint(0.0, 0.0, 0.0);
  Points->InsertNextPoint(1.0, 0.0, 0.0);
  Points->InsertNextPoint(0.0, 1.0, 0.0);

	//get the number of points the file contains
	vtkIdType NumPoints = Points->GetNumberOfPoints();
  vtkstd::cout << "There are " << NumPoints << " points." << vtkstd::endl;
	
	//Create the tree
  vtkSmartPointer<vtkKdTree> KDTree = vtkSmartPointer<vtkKdTree>::New();
	KDTree->BuildLocatorFromPoints(Points);
	
  vtkstd::cout << "Number of points in tree: " <<
KDTree->GetDataSets()->GetNextDataSet()->GetNumberOfPoints() <<
vtkstd::endl;
  //vtkstd::cout << "Number of points in tree: " <<
KDTree->GetDataSet(0)->GetNumberOfPoints() << vtkstd::endl;
	

It segfaults on either of those last two lines which are supposed to
output the number of points.

Thoughts?

Thanks,

David



More information about the vtkusers mailing list