Ejemplo n.º 1
0
    def add_shape(self, shape):
        """
        Add shape to the bounding box.

        :param afem.topology.entities.Shape shape: The shape.

        :return: None.
        """
        BRepBndLib.Add_(shape.object, self, True)
Ejemplo n.º 2
0
 def get_bounding_box(self, shape=None):
     shape = shape or self.shape
     if not shape:
         return BBox()
     bbox = Bnd_Box()
     BRepBndLib.Add_(shape, bbox)
     pmin, pmax = bbox.CornerMin(), bbox.CornerMax()
     return BBox(*(pmin.X(), pmin.Y(), pmin.Z(), pmax.X(), pmax.Y(),
                   pmax.Z()))
Ejemplo n.º 3
0
    def get_bounding_box(self, shapes):
        """ Compute the bounding box for the given list of shapes. Return values
        are in 3d coordinate space.

        Parameters
        ----------
        shapes: List
            A list of TopoDS_Shape to compute a bbox for

        Returns
        -------
        bbox: Tuple
            A tuple of (xmin, ymin, zmin, xmax, ymax, zmax).

        """
        bbox = Bnd_Box()
        for shape in shapes:
            BRepBndLib.Add_(shape, bbox)
        try:
            pmin = bbox.CornerMin()
            pmax = bbox.CornerMax()
        except RuntimeError:
            return (0, 0, 0, 0, 0, 0)
        return (pmin.X(), pmin.Y(), pmin.Z(), pmax.X(), pmax.Y(), pmax.Z())