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

Method BuildLocatorInternal

Common/DataModel/vtkStaticPointLocator.cxx:1628–1707  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Method to form subdivision of space based on the points provided and subject to the constraints of levels and NumberOfPointsPerBucket. The result is directly addressable and of uniform subdivision.

Source from the content-addressed store, hash-verified

1626// The result is directly addressable and of uniform subdivision.
1627//
1628void vtkStaticPointLocator::BuildLocatorInternal()
1629{
1630 int ndivs[3];
1631 int i;
1632 vtkIdType numPts;
1633
1634 vtkDebugMacro(<< "Hashing points...");
1635 this->Level = 1; // only single lowest level - from superclass
1636
1637 if (!this->DataSet || (numPts = this->DataSet->GetNumberOfPoints()) < 1)
1638 {
1639 vtkErrorMacro(<< "No points to locate");
1640 return;
1641 }
1642
1643 // Make sure the appropriate data is available
1644 this->FreeSearchStructure();
1645
1646 // Size the root bucket. Initialize bucket data structure, compute
1647 // level and divisions. The GetBounds() method below can be very slow;
1648 // hopefully it is cached or otherwise accelerated.
1649 //
1650 const double* bounds = this->DataSet->GetBounds();
1651 vtkIdType numBuckets = static_cast<vtkIdType>(
1652 static_cast<double>(numPts) / static_cast<double>(this->NumberOfPointsPerBucket));
1653 numBuckets = (numBuckets > this->MaxNumberOfBuckets ? this->MaxNumberOfBuckets : numBuckets);
1654
1655 vtkBoundingBox bbox(bounds);
1656 // If bounds padding is specified, inflate it
1657 if (this->Padding > 0.)
1658 {
1659 bbox.Inflate(this->Padding);
1660 }
1661
1662 if (this->Automatic)
1663 {
1664 bbox.ComputeDivisions(numBuckets, this->Bounds, ndivs);
1665 }
1666 else
1667 {
1668 bbox.Inflate(); // make sure non-zero volume
1669 bbox.GetBounds(this->Bounds);
1670 for (i = 0; i < 3; i++)
1671 {
1672 ndivs[i] = (this->Divisions[i] < 1 ? 1 : this->Divisions[i]);
1673 }
1674 }
1675
1676 this->Divisions[0] = ndivs[0];
1677 this->Divisions[1] = ndivs[1];
1678 this->Divisions[2] = ndivs[2];
1679
1680 this->NumberOfBuckets = numBuckets = static_cast<vtkIdType>(ndivs[0]) *
1681 static_cast<vtkIdType>(ndivs[1]) * static_cast<vtkIdType>(ndivs[2]);
1682
1683 // Compute width of bucket in three directions
1684 for (i = 0; i < 3; i++)
1685 {

Callers 2

BuildLocatorMethod · 0.95
ForceBuildLocatorMethod · 0.95

Calls 7

FreeSearchStructureMethod · 0.95
ComputeDivisionsMethod · 0.80
GetNumberOfPointsMethod · 0.45
GetBoundsMethod · 0.45
InflateMethod · 0.45
BuildLocatorMethod · 0.45
ModifiedMethod · 0.45

Tested by

no test coverage detected