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

Method BuildLocatorInternal

Common/DataModel/vtkStaticPointLocator2D.cxx:1644–1721  ·  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

1642// The result is directly addressable and of uniform subdivision.
1643//
1644void vtkStaticPointLocator2D::BuildLocatorInternal()
1645{
1646 int ndivs[3];
1647 int i;
1648 vtkIdType numPts;
1649
1650 vtkDebugMacro(<< "Hashing points...");
1651 this->Level = 1; // only single lowest level - from superclass
1652
1653 if (!this->DataSet || (numPts = this->DataSet->GetNumberOfPoints()) < 1)
1654 {
1655 vtkErrorMacro(<< "No points to locate");
1656 return;
1657 }
1658
1659 // Make sure the appropriate data is available
1660 //
1661 if (this->Buckets)
1662 {
1663 this->FreeSearchStructure();
1664 }
1665
1666 // Size the root bucket. Initialize bucket data structure, compute
1667 // level and divisions. The GetBounds() method below can be very slow;
1668 // hopefully it is cached or otherwise accelerated.
1669 //
1670 const double* bounds = this->DataSet->GetBounds();
1671 vtkIdType numBuckets = static_cast<vtkIdType>(
1672 static_cast<double>(numPts) / static_cast<double>(this->NumberOfPointsPerBucket));
1673 numBuckets = (numBuckets > this->MaxNumberOfBuckets ? this->MaxNumberOfBuckets : numBuckets);
1674
1675 vtkBoundingBox bbox(bounds);
1676 if (this->Automatic)
1677 {
1678 bbox.ComputeDivisions(numBuckets, this->Bounds, ndivs);
1679 }
1680 else
1681 {
1682 bbox.Inflate(); // make sure non-zero volume
1683 bbox.GetBounds(this->Bounds);
1684 for (i = 0; i < 2; i++)
1685 {
1686 ndivs[i] = (this->Divisions[i] < 1 ? 1 : this->Divisions[i]);
1687 }
1688 }
1689
1690 this->Divisions[0] = ndivs[0];
1691 this->Divisions[1] = ndivs[1];
1692 this->NumberOfBuckets = numBuckets =
1693 static_cast<vtkIdType>(ndivs[0]) * static_cast<vtkIdType>(ndivs[1]);
1694
1695 // Compute width of bucket in three directions
1696 //
1697 for (i = 0; i < 2; i++)
1698 {
1699 this->H[i] = (this->Bounds[2 * i + 1] - this->Bounds[2 * i]) / static_cast<double>(ndivs[i]);
1700 }
1701

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