Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 15 additions & 2 deletions src/compas_rhino/geometry/brep/brep.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
# ==============================================================================
Expand All @@ -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
# ==============================================================================
Expand Down Expand Up @@ -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.
Expand All @@ -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")
Expand Down