[vtkusers] Number of points in a KdTree?
David Doria
daviddoria+vtk at gmail.com
Fri Oct 30 13:26:05 EDT 2009
On Mon, Oct 26, 2009 at 4:53 PM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
> The purpose of BuildLocatorFromPoints is described in the header. I
> suspect that if you use this method, you cannot get the information
> that you want.
>
> // For the purpose of removing duplicate points quickly from large
> // data sets, or for finding nearby points, we added another mode for
> // building the locator. BuildLocatorFromPoints will build a k-d tree
> // from one or more vtkPoints objects. This can be followed by
> // BuildMapForDuplicatePoints which returns a mapping from the original
> // ids to a subset of the ids that is unique within a supplied
> // tolerance, or you can use FindPoint and FindClosestPoint to
> // locate points in the original set that the tree was built from.
>
> On Mon, Oct 26, 2009 at 4:40 PM, David Doria <daviddoria+vtk at gmail.com> wrote:
>> On Mon, Oct 26, 2009 at 4:34 PM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
>>> 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...
Trying to build the tree from a dataset:
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;
vtkSmartPointer<vtkPolyData> Polydata = vtkSmartPointer<vtkPolyData>::New();
Polydata->SetPoints(Points);
//Create the tree
vtkSmartPointer<vtkKdTree> KDTree = vtkSmartPointer<vtkKdTree>::New();
KDTree->AddDataSet(Polydata);
KDTree->BuildLocator();
vtkstd::cout << "Number of points in tree: " <<
KDTree->GetDataSets()->GetNextDataSet()->GetNumberOfPoints() <<
vtkstd::endl;
I get an error "No cells to subdivide". Does that mean I have to
create vertices for my points before calling BuildLocator()?
Thanks,
David
More information about the vtkusers
mailing list