------------------------------------------------------------------------------
| 373 | |
| 374 | //------------------------------------------------------------------------------ |
| 375 | void vtkHyperTreeGridPlaneCutter::RecursivelyProcessTreePrimal( |
| 376 | vtkHyperTreeGridNonOrientedGeometryCursor* cursor) |
| 377 | { |
| 378 | // If cursor is at a masked cell stop recursion |
| 379 | vtkIdType inId = cursor->GetGlobalNodeIndex(); |
| 380 | if (this->InMask && this->InMask->GetValue(inId)) |
| 381 | { |
| 382 | return; |
| 383 | } |
| 384 | |
| 385 | // Retrieve cursor geometry |
| 386 | double* origin = cursor->GetOrigin(); |
| 387 | double* size = cursor->GetSize(); |
| 388 | |
| 389 | // Initialize cell coordinates |
| 390 | double cellCoords[8][3]; |
| 391 | for (int i = 0; i < 8; ++i) |
| 392 | { |
| 393 | cellCoords[i][0] = (i & 1) ? origin[0] + size[0] : origin[0]; |
| 394 | // Checking if the plane is equal to the boundary of a cell. |
| 395 | // If it is, we need to shift it a tiny bit. |
| 396 | // Check is done on all axis. |
| 397 | // NOTE: we set cellCoords to std::sqrt(VTK_DBL_MIN) if the plane passes by the origin |
| 398 | // because distance computation, needed later, requires squaring those values. |
| 399 | // Since VTK_DBL_MIN is the smallest normal double value, VTK_DBL_MIN*VTK_DBL_MIN == 0, |
| 400 | // and sqrt(VTK_DBL_MIN)*std::sqrt(VTK_DBL_MIN) == VTK_DBL_MIN, which is what we want |
| 401 | if (this->IsPlaneOrthogonalToXAxis()) |
| 402 | { |
| 403 | if (cellCoords[i][0] == this->Plane[3]) |
| 404 | { |
| 405 | cellCoords[i][0] += std::abs(cellCoords[i][0]) > std::sqrt(VTK_DBL_MIN) |
| 406 | ? VTK_DBL_EPSILON * std::abs(cellCoords[i][0]) |
| 407 | : std::sqrt(VTK_DBL_MIN); |
| 408 | } |
| 409 | } |
| 410 | cellCoords[i][1] = (i & 2) ? origin[1] + size[1] : origin[1]; |
| 411 | if (this->IsPlaneOrthogonalToYAxis()) |
| 412 | { |
| 413 | if (cellCoords[i][1] == this->Plane[3]) |
| 414 | { |
| 415 | cellCoords[i][1] += std::abs(cellCoords[i][1]) > std::sqrt(VTK_DBL_MIN) |
| 416 | ? VTK_DBL_EPSILON * std::abs(cellCoords[i][1]) |
| 417 | : std::sqrt(VTK_DBL_MIN); |
| 418 | } |
| 419 | } |
| 420 | cellCoords[i][2] = (i & 4) ? origin[2] + size[2] : origin[2]; |
| 421 | if (this->IsPlaneOrthogonalToZAxis()) |
| 422 | { |
| 423 | if (cellCoords[i][2] == this->Plane[3]) |
| 424 | { |
| 425 | cellCoords[i][2] += std::abs(cellCoords[i][2]) > std::sqrt(VTK_DBL_MIN) |
| 426 | ? VTK_DBL_EPSILON * std::abs(cellCoords[i][2]) |
| 427 | : std::sqrt(VTK_DBL_MIN); |
| 428 | } |
| 429 | } |
| 430 | } |
| 431 | |
| 432 | // Check cell-plane intersection |
no test coverage detected