[vtkusers] Number of points in a KdTree?
Bill Lorensen
bill.lorensen at gmail.com
Mon Oct 26 16:34:49 EDT 2009
I think the problem is that there is not a dataset associated with the
kdtree if you build it from points.
If you build it from a dataset, there will probably be a dataset.
Just a guess...
On Mon, Oct 26, 2009 at 3:17 PM, David Doria <daviddoria+vtk at gmail.com> wrote:
> 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
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
More information about the vtkusers
mailing list