|
|
|
@ -65,9 +65,21 @@ class Positionable(metaclass=ABCMeta):
|
|
|
|
|
def get_bounds(self) -> Optional[NDArray[numpy.float64]]:
|
|
|
|
|
"""
|
|
|
|
|
Returns `[[x_min, y_min], [x_max, y_max]]` which specify a minimal bounding box for the entity.
|
|
|
|
|
Returns `None` for an empty entity.
|
|
|
|
|
"""
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def get_bounds_nonempty(self) -> NDArray[numpy.float64]:
|
|
|
|
|
"""
|
|
|
|
|
Returns `[[x_min, y_min], [x_max, y_max]]` which specify a minimal bounding box for the entity.
|
|
|
|
|
Asserts that the entity is non-empty (i.e., `get_bounds()` does not return None).
|
|
|
|
|
|
|
|
|
|
This is handy for destructuring like `xy_min, xy_max = entity.get_bounds_nonempty()`
|
|
|
|
|
"""
|
|
|
|
|
bounds = self.get_bounds()
|
|
|
|
|
assert(bounds is not None)
|
|
|
|
|
return bounds
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PositionableImpl(Positionable, metaclass=ABCMeta):
|
|
|
|
|
"""
|
|
|
|
|