Skip to content

Commit 5a688ac

Browse files
authored
Merge pull request #1110 from compas-dev/brep_copy
Brep copy
2 parents 735a3e8 + 7d0d81e commit 5a688ac

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
### Changed
1717

1818
* Updated workflows to v2.
19+
* Changed deepcopy of `RhinoBrep` to use the native `Rhino.Geometry` mechanism.
20+
* The normal of the cutting plane is no longer flipped in `compas_rhino.geometry.RhinoBrep`.
1921

2022
### Removed
2123

src/compas_rhino/geometry/brep/brep.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ def __init__(self, brep=None):
6565
super(RhinoBrep, self).__init__()
6666
self._brep = brep or Rhino.Geometry.Brep()
6767

68+
def __deepcopy__(self, *args, **kwargs):
69+
return self.copy()
70+
6871
# ==============================================================================
6972
# Data
7073
# ==============================================================================
@@ -88,6 +91,17 @@ def data(self, data):
8891
RhinoBrepFace.from_data(f_data, builder)
8992
self._brep = builder.result
9093

94+
def copy(self, cls=None):
95+
"""Creates a deep-copy of this Brep using the native Rhino.Geometry.Brep copying mechanism.
96+
97+
Returns
98+
-------
99+
:class:`~compas_rhino.geometry.RhinoBrep`
100+
101+
"""
102+
# Avoid reconstruction when just copying. for sake of efficiency and stability
103+
return RhinoBrep.from_native(self._brep.DuplicateBrep())
104+
91105
# ==============================================================================
92106
# Properties
93107
# ==============================================================================
@@ -219,7 +233,7 @@ def trim(self, trimming_plane, tolerance=TOLERANCE):
219233
Parameters
220234
----------
221235
trimming_plane : :class:`~compas.geometry.Frame` or :class:`~compas.geometry.Plane`
222-
The frame or plane to use when trimming.
236+
The frame or plane to use when trimming. The discarded bit is in the direction of the frame's normal.
223237
224238
tolerance : float
225239
The precision to use for the trimming operation.
@@ -232,7 +246,6 @@ def trim(self, trimming_plane, tolerance=TOLERANCE):
232246
if isinstance(trimming_plane, Plane):
233247
trimming_plane = Frame.from_plane(trimming_plane)
234248
rhino_frame = frame_to_rhino(trimming_plane)
235-
rhino_frame.Flip()
236249
results = self._brep.Trim(rhino_frame, tolerance)
237250
if not results:
238251
raise BrepTrimmingError("Trim operation ended with no result")

0 commit comments

Comments
 (0)