| 488 | } |
| 489 | } |
| 490 | ShapeRange ShapeRange::intersect(const ShapeRange& other) const { |
| 491 | |
| 492 | // These routines will throw if it's invalid (i.e. max < min) |
| 493 | ShapeRange out; |
| 494 | if (_minimum <= other.minimum()) |
| 495 | out.setLower(other.minimum()); |
| 496 | else { |
| 497 | out.setLower(_minimum); |
| 498 | } |
| 499 | |
| 500 | if (_maximum >= other.maximum()) |
| 501 | out.setUpper(other.maximum()); |
| 502 | else { |
| 503 | out.setUpper(_maximum); |
| 504 | } |
| 505 | |
| 506 | if (_minimum > _maximum || _minimum.isUnbound()) { |
| 507 | std::stringstream ss; |
| 508 | ss << "Invalid intersection between " << *this << " and " << other; |
| 509 | throw std::runtime_error(ss.str()); |
| 510 | } |
| 511 | |
| 512 | return out; |
| 513 | |
| 514 | } |
| 515 | |
| 516 | ShapeRange ShapeRange::unify(const ShapeRange& other) const { |
| 517 | ShapeRange out; |