diff --git a/CHANGELOG.md b/CHANGELOG.md index 04606419e5a8..6229fd504c1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ 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. +* The normal of the cutting plane is no longer flipped in `compas_rhino.geometry.RhinoBrep`. ### Removed diff --git a/src/compas_rhino/geometry/brep/brep.py b/src/compas_rhino/geometry/brep/brep.py index 11a042e39bc7..f03676f07f87 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,17 @@ def data(self, data): RhinoBrepFace.from_data(f_data, builder) self._brep = builder.result + def copy(self, cls=None): + """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()) + # ============================================================================== # Properties # ============================================================================== @@ -219,7 +233,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 +246,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")