[vtkusers] Using vtkPointLocator with vtkPoints

Moreland, Kenneth kmorel at sandia.gov
Thu Jul 20 10:20:45 EDT 2006

I have a collection of points that I wish to use a vtkPointLocator to
find points in a point cloud within the radius of some location.  Since
I don't have a data set to start with, I have been using
InitPointInsertion and InsertNextPoint to create the locator.  Below is
some code that exercises that functionality.

  vtkPointLocator *locator = vtkPointLocator::New();

  double bounds[6];
  bounds[0] = bounds[2] = bounds[4] = 0.0;
  bounds[1] = bounds[3] = bounds[5] = 1.0;

  vtkPoints *points = vtkPoints::New();
  locator->InitPointInsertion(points, bounds, NUM_POINTS);

  for (vtkIdType i = 0; i < NUM_POINTS; i++)
    double point[3];
    point[0] = vtkMath::Random();
    point[1] = vtkMath::Random();
    point[2] = vtkMath::Random();

  vtkIdList *ids = vtkIdList::New();
  double point[3];
  point[0] = point[1] = point[2] = 0.5;
  locator->FindPointsWithinRadius(0.25, point, ids);

Everything seems to work fine until I get to the locator->BuildLocator()
call.  When this happens I get the following error:

ERROR: In C:\kmorel\src\ParaView\VTK\Filtering\vtkPointLocator.cxx, line
vtkPointLocator (09FC83C8): No points to subdivide

I thought that the process of calling InitPointInsertion and
InsertNextPoint perhaps was supposed to take the place of BuildLocator,
so I tried commenting that out.  I got the same error message because
FindPointsWithinRadius internally calls BuildLocator.  I also get a seg
fault within FindPointsWithinRadius because it tries to access the
DataSet ivar for the vtkPointLocator, which of course is still NULL.  Is
this a bug, or am I doing something wrong?


   ****      Kenneth Moreland
    ***      Sandia National Laboratories
*** *** ***  email: kmorel at sandia.gov
**  ***  **  phone: (505) 844-8919
    ***      fax:   (505) 845-0833

More information about the vtkusers mailing list