[vtkusers] vtkPointLocator

Nikita Kojekine AKA Kitya Karlson karlson at stu.mech.titech.ac.jp
Mon Apr 23 01:15:20 EDT 2001


Hello!
I have posted it once, but I got no replays. Still the problem
with vtkPointLocator persists. Maybe it is a bug?

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