------------------------------------------------------------------------------
| 434 | |
| 435 | //------------------------------------------------------------------------------ |
| 436 | std::vector<vtkBoundingBox> vtkNativePartitioningStrategy::ExpandCuts( |
| 437 | const std::vector<vtkBoundingBox>& cuts, const vtkBoundingBox& bounds) |
| 438 | { |
| 439 | vtkBoundingBox cutsBounds; |
| 440 | for (const auto& bbox : cuts) |
| 441 | { |
| 442 | cutsBounds.AddBox(bbox); |
| 443 | } |
| 444 | |
| 445 | if (!bounds.IsValid() || !cutsBounds.IsValid() || cutsBounds.Contains(bounds)) |
| 446 | { |
| 447 | // nothing to do. |
| 448 | return cuts; |
| 449 | } |
| 450 | |
| 451 | std::vector<vtkBoundingBox> result = cuts; |
| 452 | for (auto& bbox : result) |
| 453 | { |
| 454 | if (!bbox.IsValid()) |
| 455 | { |
| 456 | continue; |
| 457 | } |
| 458 | |
| 459 | double bds[6]; |
| 460 | bbox.GetBounds(bds); |
| 461 | for (int face = 0; face < 6; ++face) |
| 462 | { |
| 463 | if (bds[face] == cutsBounds.GetBound(face)) |
| 464 | { |
| 465 | bds[face] = (face % 2 == 0) ? std::min(bds[face], bounds.GetBound(face)) |
| 466 | : std::max(bds[face], bounds.GetBound(face)); |
| 467 | } |
| 468 | } |
| 469 | bbox.SetBounds(bds); |
| 470 | assert(bbox.IsValid()); // input valid implies output is valid too. |
| 471 | } |
| 472 | |
| 473 | return result; |
| 474 | } |
| 475 | |
| 476 | VTK_ABI_NAMESPACE_END |