MCPcopy Create free account
hub / github.com/Kitware/VTK / BuildLocatorInternal

Method BuildLocatorInternal

Common/DataModel/vtkOctreePointLocator.cxx:303–426  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

301
302//------------------------------------------------------------------------------
303void vtkOctreePointLocator::BuildLocatorInternal()
304{
305 if (!this->DataSet || this->DataSet->GetNumberOfPoints() == 0)
306 {
307 vtkErrorMacro("No data set");
308 return;
309 }
310
311 int numPoints = this->GetDataSet()->GetNumberOfPoints();
312
313 if (numPoints >= VTK_INT_MAX)
314 {
315 // When point IDs are stored in an "int" instead of a vtkIdType,
316 // performance doubles. So we store point IDs in an "int" during
317 // the calculation. This will need to be rewritten if true 64 bit
318 // IDs are required.
319
320 vtkErrorMacro("Intentional 64 bit error - time to rewrite code.");
321 return;
322 }
323
324 vtkDebugMacro(<< "Creating octree");
325 this->FreeSearchStructure();
326
327 // Fix bounds - (1) push out a little if flat
328 // (2) pull back the x, y and z lower bounds a little bit so that
329 // points are clearly "inside" the spatial region. Point p is
330 // "inside" region r = [r1, r2] if r1 < p <= r2.
331
332 double bounds[6], diff[3];
333
334 this->GetDataSet()->GetBounds(bounds);
335
336 this->MaxWidth = 0.0;
337 int i;
338 for (i = 0; i < 3; i++)
339 {
340 diff[i] = bounds[2 * i + 1] - bounds[2 * i];
341 this->MaxWidth = static_cast<float>((diff[i] > this->MaxWidth) ? diff[i] : this->MaxWidth);
342 }
343
344 if (this->CreateCubicOctants)
345 {
346 // make the bounding box have equal length sides so that all octants
347 // will also have equal length sides
348 for (i = 0; i < 3; i++)
349 {
350 if (diff[i] != this->MaxWidth)
351 {
352 double delta = this->MaxWidth - diff[i];
353 bounds[2 * i] -= .5 * delta;
354 bounds[2 * i + 1] += .5 * delta;
355 diff[i] = this->MaxWidth;
356 }
357 }
358 }
359
360 this->FudgeFactor = this->MaxWidth * 10e-6;

Callers 2

BuildLocatorMethod · 0.95
ForceBuildLocatorMethod · 0.95

Calls 13

FreeSearchStructureMethod · 0.95
DivideRegionMethod · 0.95
BuildLeafNodeListMethod · 0.95
NewFunction · 0.50
GetNumberOfPointsMethod · 0.45
GetDataSetMethod · 0.45
GetBoundsMethod · 0.45
SetBoundsMethod · 0.45
SetNumberOfPointsMethod · 0.45
SetDataBoundsMethod · 0.45
GetPointMethod · 0.45

Tested by

no test coverage detected