From 02e5fc46fa05b2bb7b65e8ca2060a5d7633baee5 Mon Sep 17 00:00:00 2001 From: Chen Kasirer Date: Fri, 6 Jan 2023 13:43:41 +0100 Subject: [PATCH 1/5] removed undocumented plane flip --- src/compas_rhino/geometry/brep/brep.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/compas_rhino/geometry/brep/brep.py b/src/compas_rhino/geometry/brep/brep.py index 11a042e39bc7..5766a7c78cca 100644 --- a/src/compas_rhino/geometry/brep/brep.py +++ b/src/compas_rhino/geometry/brep/brep.py @@ -219,7 +219,7 @@ def trim(self, trimming_plane, tolerance=TOLERANCE): Parameters ---------- trimming_plane : :class:`~compas.geometry.Frame` or :class:`~compas.geometry.Plane` - The frame or plane to use when trimming. + The frame or plane to use when trimming. The discarded bit is in the direction of the frame's normal. tolerance : float The precision to use for the trimming operation. @@ -232,7 +232,6 @@ def trim(self, trimming_plane, tolerance=TOLERANCE): if isinstance(trimming_plane, Plane): trimming_plane = Frame.from_plane(trimming_plane) rhino_frame = frame_to_rhino(trimming_plane) - rhino_frame.Flip() results = self._brep.Trim(rhino_frame, tolerance) if not results: raise BrepTrimmingError("Trim operation ended with no result") From 8f416a31e6ef3951eb69560f67e157bf9aefceb5 Mon Sep 17 00:00:00 2001 From: Chen Kasirer Date: Sat, 7 Jan 2023 11:33:10 +0100 Subject: [PATCH 2/5] brep native copy --- src/compas_rhino/geometry/brep/brep.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/compas_rhino/geometry/brep/brep.py b/src/compas_rhino/geometry/brep/brep.py index 5766a7c78cca..741c3c1cfa96 100644 --- a/src/compas_rhino/geometry/brep/brep.py +++ b/src/compas_rhino/geometry/brep/brep.py @@ -65,6 +65,9 @@ def __init__(self, brep=None): super(RhinoBrep, self).__init__() self._brep = brep or Rhino.Geometry.Brep() + def __deepcopy__(self, *args, **kwargs): + return self.copy() + # ============================================================================== # Data # ============================================================================== @@ -88,6 +91,16 @@ def data(self, data): RhinoBrepFace.from_data(f_data, builder) self._brep = builder.result + def copy(self, cls=None): + """Creates a copy of this Brep using the native Rhino.Geometry.Brep copying mechanism. + + Returns + ------- + :class:`~compas_rhino.geometry.RhinoBrep` + + """ + return RhinoBrep.from_native(self._brep.DuplicateBrep()) + # ============================================================================== # Properties # ============================================================================== From 8854aab6041a17f72154934359deaf9037d27798 Mon Sep 17 00:00:00 2001 From: Chen Kasirer Date: Sat, 7 Jan 2023 11:39:11 +0100 Subject: [PATCH 3/5] updated changelog. formatting. --- CHANGELOG.md | 1 + src/compas_rhino/geometry/brep/brep.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04606419e5a8..f0940c02dbe9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed * Updated workflows to v2. +* Changed deepcopy of `RhinoBrep` to use the native `Rhino.Geometry` mechanism. ### Removed diff --git a/src/compas_rhino/geometry/brep/brep.py b/src/compas_rhino/geometry/brep/brep.py index 741c3c1cfa96..240f63451360 100644 --- a/src/compas_rhino/geometry/brep/brep.py +++ b/src/compas_rhino/geometry/brep/brep.py @@ -93,11 +93,11 @@ def data(self, data): def copy(self, cls=None): """Creates a copy of this Brep using the native Rhino.Geometry.Brep copying mechanism. - + Returns ------- :class:`~compas_rhino.geometry.RhinoBrep` - + """ return RhinoBrep.from_native(self._brep.DuplicateBrep()) From 5c4a2ff0bbc6745bc3a2abe453b6637f066b4c6b Mon Sep 17 00:00:00 2001 From: Chen Kasirer Date: Wed, 11 Jan 2023 13:55:33 +0100 Subject: [PATCH 4/5] added comment --- src/compas_rhino/geometry/brep/brep.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compas_rhino/geometry/brep/brep.py b/src/compas_rhino/geometry/brep/brep.py index 240f63451360..f03676f07f87 100644 --- a/src/compas_rhino/geometry/brep/brep.py +++ b/src/compas_rhino/geometry/brep/brep.py @@ -92,13 +92,14 @@ def data(self, data): self._brep = builder.result def copy(self, cls=None): - """Creates a copy of this Brep using the native Rhino.Geometry.Brep copying mechanism. + """Creates a deep-copy of this Brep using the native Rhino.Geometry.Brep copying mechanism. Returns ------- :class:`~compas_rhino.geometry.RhinoBrep` """ + # Avoid reconstruction when just copying. for sake of efficiency and stability return RhinoBrep.from_native(self._brep.DuplicateBrep()) # ============================================================================== From 7d0d81e70ab3455f10812cb96128e30b95bfd70a Mon Sep 17 00:00:00 2001 From: Chen Kasirer Date: Wed, 11 Jan 2023 14:05:07 +0100 Subject: [PATCH 5/5] updated change log --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0940c02dbe9..6229fd504c1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Updated workflows to v2. * Changed deepcopy of `RhinoBrep` to use the native `Rhino.Geometry` mechanism. +* The normal of the cutting plane is no longer flipped in `compas_rhino.geometry.RhinoBrep`. ### Removed