------------------------------------------------------------------------------ Method to form subdivision of space based on the cells provided and subject to the constraints of levels and NumberOfCellsPerNode. The result is directly addressable and of uniform subdivision.
| 708 | // subject to the constraints of levels and NumberOfCellsPerNode. |
| 709 | // The result is directly addressable and of uniform subdivision. |
| 710 | void vtkCellLocator::BuildLocatorInternal() |
| 711 | { |
| 712 | double cellBounds[6], *cellBoundsPtr; |
| 713 | cellBoundsPtr = cellBounds; |
| 714 | vtkIdType numCells; |
| 715 | int ndivs, product; |
| 716 | int i, j, k, ijkMin[3], ijkMax[3]; |
| 717 | vtkIdType cellId, idx; |
| 718 | int parentOffset; |
| 719 | int numCellsPerBucket = this->NumberOfCellsPerNode; |
| 720 | int prod, numOctants; |
| 721 | double hTol[3]; |
| 722 | |
| 723 | vtkDebugMacro(<< "Subdividing octree..."); |
| 724 | |
| 725 | if (!this->DataSet || (numCells = this->DataSet->GetNumberOfCells()) < 1) |
| 726 | { |
| 727 | vtkErrorMacro(<< "No cells to subdivide"); |
| 728 | return; |
| 729 | } |
| 730 | this->DataSet->ComputeBounds(); |
| 731 | |
| 732 | // Make sure the appropriate data is available |
| 733 | this->FreeSearchStructure(); |
| 734 | |
| 735 | // Size the root cell. Initialize cell data structure, compute |
| 736 | // level and divisions. |
| 737 | const double* bounds = this->DataSet->GetBounds(); |
| 738 | vtkBoundingBox bbox(bounds); |
| 739 | bbox.Inflate(); |
| 740 | bbox.GetBounds(this->Bounds); |
| 741 | |
| 742 | if (this->Automatic) |
| 743 | { |
| 744 | this->Level = static_cast<int>( |
| 745 | std::ceil(std::log(static_cast<double>(numCells) / numCellsPerBucket) / (std::log(8.0)))); |
| 746 | } |
| 747 | this->Level = (this->Level > this->MaxLevel ? this->MaxLevel : this->Level); |
| 748 | |
| 749 | // compute number of octants and number of divisions |
| 750 | for (ndivs = 1, prod = 1, numOctants = 1, i = 0; i < this->Level; i++) |
| 751 | { |
| 752 | ndivs *= 2; |
| 753 | prod *= 8; |
| 754 | numOctants += prod; |
| 755 | } |
| 756 | this->NumberOfDivisions = ndivs; |
| 757 | this->NumberOfOctants = numOctants; |
| 758 | |
| 759 | this->TreeSharedPtr = |
| 760 | std::make_shared<std::vector<vtkSmartPointer<vtkIdList>>>(numOctants, nullptr); |
| 761 | this->Tree = TreeSharedPtr->data(); |
| 762 | |
| 763 | this->ComputeCellBounds(); |
| 764 | |
| 765 | // Compute width of leaf octant in three directions |
| 766 | for (i = 0; i < 3; i++) |
| 767 | { |
no test coverage detected