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

Method BuildLocatorInternal

Common/DataModel/vtkStaticCellLocator.cxx:1470–1548  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1468
1469//------------------------------------------------------------------------------
1470void vtkStaticCellLocator::BuildLocatorInternal()
1471{
1472 vtkDebugMacro(<< "Building static cell locator");
1473 vtkIdType numCells;
1474 if (!this->DataSet || (numCells = this->DataSet->GetNumberOfCells()) < 1)
1475 {
1476 vtkErrorMacro(<< "No cells to build");
1477 return;
1478 }
1479
1480 // Prepare
1481 this->FreeSearchStructure();
1482
1483 // The bounding box can be slow
1484 int i, ndivs[3];
1485 const double* bounds = this->DataSet->GetBounds();
1486 vtkIdType numBins = static_cast<vtkIdType>(
1487 static_cast<double>(numCells) / static_cast<double>(this->NumberOfCellsPerNode));
1488 numBins = (numBins > this->MaxNumberOfBuckets ? this->MaxNumberOfBuckets : numBins);
1489
1490 vtkBoundingBox bbox(bounds);
1491 if (this->Automatic)
1492 {
1493 bbox.ComputeDivisions(numBins, this->Bounds, ndivs);
1494 }
1495 else
1496 {
1497 bbox.Inflate(); // make sure non-zero volume
1498 bbox.GetBounds(this->Bounds);
1499 for (i = 0; i < 3; i++)
1500 {
1501 ndivs[i] = (this->Divisions[i] < 1 ? 1 : this->Divisions[i]);
1502 }
1503 }
1504
1505 this->Divisions[0] = ndivs[0];
1506 this->Divisions[1] = ndivs[1];
1507 this->Divisions[2] = ndivs[2];
1508 numBins = static_cast<vtkIdType>(ndivs[0]) * static_cast<vtkIdType>(ndivs[1]) *
1509 static_cast<vtkIdType>(ndivs[2]);
1510
1511 // Compute bin/bucket widths
1512 for (i = 0; i < 3; i++)
1513 {
1514 this->H[i] = (this->Bounds[2 * i + 1] - this->Bounds[2 * i]) / this->Divisions[i];
1515 }
1516
1517 // Actually do the hard work of creating the locator. Clear out old stuff.
1518 delete this->Binner;
1519 delete this->Processor;
1520 this->Binner = new vtkCellBinner(this, numCells, numBins);
1521 vtkSMPTools::For(0, numCells, *(this->Binner));
1522
1523 // Create sorted cell fragments tuples of (cellId,binId). Depending
1524 // on problem size, different types are used.
1525 vtkIdType numFragments = this->Binner->NumFragments;
1526 if (numFragments >= VTK_INT_MAX)
1527 {

Callers 2

BuildLocatorMethod · 0.95
ForceBuildLocatorMethod · 0.95

Calls 8

FreeSearchStructureMethod · 0.95
ComputeDivisionsMethod · 0.80
SortFunction · 0.70
ForFunction · 0.50
GetNumberOfCellsMethod · 0.45
GetBoundsMethod · 0.45
InflateMethod · 0.45
ModifiedMethod · 0.45

Tested by

no test coverage detected