A BoundingBox for an object or set of objects. Wraps the OCP one
| 865 | |
| 866 | |
| 867 | class BoundBox(object): |
| 868 | """A BoundingBox for an object or set of objects. Wraps the OCP one""" |
| 869 | |
| 870 | wrapped: Bnd_Box |
| 871 | |
| 872 | xmin: float |
| 873 | xmax: float |
| 874 | xlen: float |
| 875 | |
| 876 | ymin: float |
| 877 | ymax: float |
| 878 | ylen: float |
| 879 | |
| 880 | zmin: float |
| 881 | zmax: float |
| 882 | zlen: float |
| 883 | |
| 884 | center: Vector |
| 885 | DiagonalLength: float |
| 886 | |
| 887 | def __init__(self, bb: Bnd_Box) -> None: |
| 888 | self.wrapped = bb |
| 889 | XMin, YMin, ZMin, XMax, YMax, ZMax = bb.Get() |
| 890 | |
| 891 | self.xmin = XMin |
| 892 | self.xmax = XMax |
| 893 | self.xlen = XMax - XMin |
| 894 | self.ymin = YMin |
| 895 | self.ymax = YMax |
| 896 | self.ylen = YMax - YMin |
| 897 | self.zmin = ZMin |
| 898 | self.zmax = ZMax |
| 899 | self.zlen = ZMax - ZMin |
| 900 | |
| 901 | self.center = Vector((XMax + XMin) / 2, (YMax + YMin) / 2, (ZMax + ZMin) / 2) |
| 902 | |
| 903 | self.DiagonalLength = self.wrapped.SquareExtent() ** 0.5 |
| 904 | |
| 905 | def add( |
| 906 | self, |
| 907 | obj: Union[Tuple[float, float, float], Vector, "BoundBox"], |
| 908 | tol: Optional[float] = None, |
| 909 | ) -> "BoundBox": |
| 910 | """Returns a modified (expanded) bounding box |
| 911 | |
| 912 | obj can be one of several things: |
| 913 | 1. a 3-tuple corresponding to x,y, and z amounts to add |
| 914 | 2. a vector, containing the x,y,z values to add |
| 915 | 3. another bounding box, where a new box will be created that |
| 916 | encloses both. |
| 917 | |
| 918 | This bounding box is not changed. |
| 919 | """ |
| 920 | |
| 921 | tol = TOL if tol is None else tol # tol = TOL (by default) |
| 922 | |
| 923 | tmp = Bnd_Box() |
| 924 | tmp.SetGap(tol) |