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

Method FindCellsWithinBounds

Common/DataModel/vtkCellLocator.cxx:1127–1177  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1125
1126//------------------------------------------------------------------------------
1127void vtkCellLocator::FindCellsWithinBounds(double* bbox, vtkIdList* cells)
1128{
1129 this->BuildLocator();
1130 if (this->Tree == nullptr)
1131 {
1132 return;
1133 }
1134 if (!cells)
1135 {
1136 return;
1137 }
1138 cells->Reset();
1139
1140 // Get the locator locations for the two extreme corners of the bounding box
1141 double p1[3], p2[3];
1142 p1[0] = bbox[0];
1143 p1[1] = bbox[2];
1144 p1[2] = bbox[4];
1145 p2[0] = bbox[1];
1146 p2[1] = bbox[3];
1147 p2[2] = bbox[5];
1148 int ijk[2][3];
1149
1150 // Find bucket the points are in
1151 this->GetBucketIndices(p1, ijk[0]);
1152 this->GetBucketIndices(p2, ijk[1]);
1153
1154 // Now loop over block to load in ids
1155 int leafStart = this->NumberOfOctants -
1156 this->NumberOfDivisions * this->NumberOfDivisions * this->NumberOfDivisions;
1157 vtkIdList* cellIds;
1158 vtkIdType idx;
1159 int i, j, k;
1160 for (k = ijk[0][2]; k <= ijk[1][2]; k++)
1161 {
1162 for (j = ijk[0][1]; j <= ijk[1][1]; j++)
1163 {
1164 for (i = ijk[0][0]; i <= ijk[1][0]; i++)
1165 {
1166 if ((cellIds = this->Tree[leafStart + i + j * this->NumberOfDivisions +
1167 k * this->NumberOfDivisions * this->NumberOfDivisions]) != nullptr)
1168 {
1169 for (idx = 0; idx < cellIds->GetNumberOfIds(); idx++)
1170 {
1171 cells->InsertUniqueId(cellIds->GetId(idx));
1172 }
1173 }
1174 }
1175 }
1176 }
1177}
1178
1179//------------------------------------------------------------------------------
1180struct IntersectionInfo

Callers 1

Calls 6

BuildLocatorMethod · 0.95
GetBucketIndicesMethod · 0.95
InsertUniqueIdMethod · 0.80
ResetMethod · 0.45
GetNumberOfIdsMethod · 0.45
GetIdMethod · 0.45

Tested by 1