diff --git a/adze/util.py b/adze/util.py index d7af74f..247840d 100644 --- a/adze/util.py +++ b/adze/util.py @@ -310,6 +310,14 @@ def check_poly(poly: poly_t, check_connectivity: bool = True) -> None: raise AdzeError('Vertex graph is not 3-vertex-connected') +def get_aabb(poly: poly_t) -> tuple[NDArray, NDArray]: + """ + Get the axis-aligned bounding box of a polyhedron. + """ + if poly['vertices'].shape[0] == 0: + return numpy.zeros(3), numpy.zeros(3) + return poly['vertices'].min(axis=0), poly['vertices'].max(axis=0) + def plot_brep(brep: Sequence[dict[str, NDArray]]) -> None: """ Plot a boundary representation