------------------------------------------------------------------------------
| 1238 | |
| 1239 | //------------------------------------------------------------------------------ |
| 1240 | int vtkKdTree::DivideRegion(vtkKdNode* kd, float* c1, int* ids, int level) |
| 1241 | { |
| 1242 | int ok = this->DivideTest(kd->GetNumberOfPoints(), level); |
| 1243 | |
| 1244 | if (!ok) |
| 1245 | { |
| 1246 | return 0; |
| 1247 | } |
| 1248 | |
| 1249 | int maxdim = this->SelectCutDirection(kd); |
| 1250 | |
| 1251 | kd->SetDim(maxdim); |
| 1252 | |
| 1253 | int dim1 = maxdim; // best cut direction |
| 1254 | int dim2 = -1; // other valid cut directions |
| 1255 | int dim3 = -1; |
| 1256 | |
| 1257 | int otherDirections = this->ValidDirections ^ (1 << maxdim); |
| 1258 | |
| 1259 | if (otherDirections) |
| 1260 | { |
| 1261 | int x = otherDirections & (1 << vtkKdTree::XDIM); |
| 1262 | int y = otherDirections & (1 << vtkKdTree::YDIM); |
| 1263 | int z = otherDirections & (1 << vtkKdTree::ZDIM); |
| 1264 | |
| 1265 | if (x) |
| 1266 | { |
| 1267 | dim2 = vtkKdTree::XDIM; |
| 1268 | |
| 1269 | if (y) |
| 1270 | { |
| 1271 | dim3 = vtkKdTree::YDIM; |
| 1272 | } |
| 1273 | else if (z) |
| 1274 | { |
| 1275 | dim3 = vtkKdTree::ZDIM; |
| 1276 | } |
| 1277 | } |
| 1278 | else if (y) |
| 1279 | { |
| 1280 | dim2 = vtkKdTree::YDIM; |
| 1281 | |
| 1282 | if (z) |
| 1283 | { |
| 1284 | dim3 = vtkKdTree::ZDIM; |
| 1285 | } |
| 1286 | } |
| 1287 | else if (z) |
| 1288 | { |
| 1289 | dim2 = vtkKdTree::ZDIM; |
| 1290 | } |
| 1291 | } |
| 1292 | |
| 1293 | this->DoMedianFind(kd, c1, ids, dim1, dim2, dim3); |
| 1294 | |
| 1295 | if (kd->GetLeft() == nullptr) |
| 1296 | { |
| 1297 | return 0; // unable to divide region further |
no test coverage detected