From 4cad6e3d678f8e7b3dc22ba9e20b9f11c806c42e Mon Sep 17 00:00:00 2001 From: james <81617086+je-cook@users.noreply.github.com> Date: Mon, 18 Nov 2024 07:34:50 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Patch=20for=20tolerance=20of=20f?= =?UTF-8?q?aces?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bluemira/codes/_freecadapi.py | 13 +++++++------ bluemira/geometry/face.py | 3 +++ bluemira/geometry/wire.py | 4 ++++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/bluemira/codes/_freecadapi.py b/bluemira/codes/_freecadapi.py index 98feae19ac..854ca958d4 100644 --- a/bluemira/codes/_freecadapi.py +++ b/bluemira/codes/_freecadapi.py @@ -660,7 +660,7 @@ def offset_wire( ]) raise FreeCADError(msg) from None - fix_wire(wire) + fix_shape(wire) if not wire.isClosed() and not open_wire: raise FreeCADError("offset failed to close wire") return wire @@ -1537,6 +1537,7 @@ def import_cad( if len(objs) > 0: return [(scale_shape(obj.copy(), scale), lab) for obj, lab in objs] bluemira_warn("No objects found in import") + if filetype not in CADFileType.unitless_formats(): return [(scale_shape(obj.copy(), scale), lab) for obj, lab in objs] return objs @@ -2331,22 +2332,22 @@ def _make_shapes_coaxis(shapes): # ====================================================================================== -def fix_wire( - wire: apiWire, precision: float = EPS_FREECAD, min_length: float = MINIMUM_LENGTH +def fix_shape( + shape: apiShape, precision: float = EPS_FREECAD, min_length: float = MINIMUM_LENGTH ): """ - Fix a wire by removing any small edges and joining the remaining edges. + Fix a shape by removing any small edges and joining the remaining edges. Parameters ---------- - wire: + shape: Wire to fix precision: General precision with which to work min_length: Minimum edge length """ - wire.fix(precision, min_length, min_length) + shape.fix(precision, min_length, min_length) # ====================================================================================== diff --git a/bluemira/geometry/face.py b/bluemira/geometry/face.py index 17b16c38ab..c32affb036 100644 --- a/bluemira/geometry/face.py +++ b/bluemira/geometry/face.py @@ -124,6 +124,9 @@ def _create_face(self, *, check_reverse: bool = True): else: raise DisjointedFaceError("Any or more than one face has been created.") + if not cadapi.is_valid(face): + cadapi.fix_shape(face) + if check_reverse: return self._check_reverse(face) return face diff --git a/bluemira/geometry/wire.py b/bluemira/geometry/wire.py index 96ebf15541..93ee7e5e44 100644 --- a/bluemira/geometry/wire.py +++ b/bluemira/geometry/wire.py @@ -83,6 +83,10 @@ def _create_shape(self) -> cadapi.apiWire: def _create_wire(self, *, check_reverse: bool = True): wire = cadapi.apiWire(self._get_wires()) + + if not cadapi.is_valid(wire): + cadapi.fix_shape(wire) + if check_reverse: return self._check_reverse(wire) return wire