From b59ea208040610a64b59e33d768f89114eaf4955 Mon Sep 17 00:00:00 2001 From: Marcus Boyd Date: Sat, 24 Oct 2020 15:07:22 +1030 Subject: [PATCH] More consistent handling of BoundaryBox tolerance --- cadquery/occ_impl/geom.py | 4 +++- cadquery/occ_impl/shapes.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cadquery/occ_impl/geom.py b/cadquery/occ_impl/geom.py index e3c335a8b..6a857d231 100644 --- a/cadquery/occ_impl/geom.py +++ b/cadquery/occ_impl/geom.py @@ -764,7 +764,7 @@ def __init__(self, bb: Bnd_Box) -> None: def add( self, obj: Union[Tuple[float, float, float], Vector, "BoundBox"], - tol: float = 1e-8, + tol: Optional[float] = None, ) -> "BoundBox": """Returns a modified (expanded) bounding box @@ -777,6 +777,8 @@ def add( This bounding box is not changed. """ + tol = TOL if tol is None else tol # tol = TOL (by default) + tmp = Bnd_Box() tmp.SetGap(tol) tmp.Add(self.wrapped) diff --git a/cadquery/occ_impl/shapes.py b/cadquery/occ_impl/shapes.py index ec4b32110..258dd47c8 100644 --- a/cadquery/occ_impl/shapes.py +++ b/cadquery/occ_impl/shapes.py @@ -488,8 +488,8 @@ def Center(self) -> Vector: return Shape.centerOfMass(self) - def CenterOfBoundBox(self, tolerance: float = 0.1) -> Vector: - return self.BoundingBox().center + def CenterOfBoundBox(self, tolerance: Optional[float] = None) -> Vector: + return self.BoundingBox(tolerance=tolerance).center @staticmethod def CombinedCenter(objects: Iterable["Shape"]) -> Vector: