[vtkusers] question about using Locators

Kitya Karlson karlson at stu.mech.titech.ac.jp
Wed Apr 11 21:24:12 EDT 2001


Hello!
I have a set of 3D points and my main object is to quickly locate
closest within
given radius r points to given point.
I know, that effective representation of such algorithm requires the use

of octtree or something like this. But vtkCellLocator, wich, as i read
in
the doc, uses octtree cannot give closest points within radius, but only

closest one point to another. So I tried to use vtkPointLocator instead.

  I try to use it like this:

  vtkPoints* PointArray = vtkPoints::New();
  FILE* fd = fopen(filename, "r");
  if (fd == NULL)
   throw("Cannot open input file!");
  char buf[81];
  float x1;
  float y1;
  float z1;
  float P[3];
  while (1)
  {
   if (fgets(buf, 80, fd) == NULL) break;
   if (sscanf(buf, "%f %f %f", &x1, &y1, &z1) == 3)
   {
    P[0]=x1;
    P[1]=y1n;
    P[2]=z1;
    PointArray->InsertNextPoint(P);
    point_num++;
   }
  }
  fclose(fd);
  float zzz[3];
  int i;
  vtkPointLocator *tree = vtkPointLocator::New();
  tree->Initialize();
  tree->InitPointInsertion(PointArray,PointArray->GetBounds());
  int pt;
  for (i=0;i<point_num;i++) {
   tree->InsertNextPoint(PointArray->GetPoint(i));
  }
 tree->BuildLocator();

and when I try to use BuildLocator() here I get an error message
"No data to subdivide!"
What is the meaning?
How should I use it?







More information about the vtkusers mailing list