def aabb(self, precision=0.0, optimal=False): """Compute the axis aligned bounding box of the surface. Parameters ---------- precision : float, optional optimal : bool, optional Returns ------- :class:`~compas.geometry.Box` """ box = Bnd_Box() if optimal: add = BndLib_AddSurface_AddOptimal else: add = BndLib_AddSurface_Add add(GeomAdaptor_Surface(self.occ_surface), precision, box) return Box.from_diagonal( (Point.from_occ(box.CornerMin()), Point.from_occ(box.CornerMax())))
from compas.datastructures import Mesh from compas.geometry import Point, Box from compas.geometry import Translation, Scale from compas_view2 import app box = Box.from_diagonal([(0.0, 0.0, 0.0), (1.0, 1.0, 1.0)]) mesh = Mesh.from_shape(box) trimesh = Mesh.from_polyhedron(4) tribox = Box.from_bounding_box(trimesh.bounding_box()) S = tribox.width / box.width trimesh.transform(Scale.from_factors([S, S, S])) trimesh.transform( Translation.from_vector(Point(0.5, 0.5, 0.5) - Point(0, 0, 0))) tri = mesh.subdivide(k=3, scheme='tri') quad = mesh.subdivide(k=3, scheme='quad') corner = mesh.subdivide(k=3, scheme='corner') ck = mesh.subdivide(k=3, scheme='catmullclark') doosabin = mesh.subdivide(k=3, scheme='doosabin') frames = mesh.subdivide(offset=0.2, scheme='frames') loop = trimesh.subdivide(k=3, scheme='loop') corner.transform(Translation.from_vector([1.2 * 1, 0.0, 0.0])) loop.transform(Translation.from_vector([1.2 * 2, 0.0, 0.0])) quad.transform(Translation.from_vector([1.2 * 3, 0.0, 0.0])) ck.transform(Translation.from_vector([1.2 * 4, 0.0, 0.0])) doosabin.transform(Translation.from_vector([1.2 * 5, 0.0, 0.0])) frames.transform(Translation.from_vector([1.2 * 6, 0.0, 0.0]))