Skip to content

Commit 1cdf4e5

Browse files
committed
implemented split operation in RhinoBrep
1 parent 41f874d commit 1cdf4e5

File tree

5 files changed

+42
-3
lines changed

5 files changed

+42
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
* Added `format` task using `black` formatter.
2121

2222
* Added a `test_intersection_circle_circle_xy` in the `test_intersections`
23+
* Added split operation to `compas_rhino.geometry.Brep`.
2324

2425
### Changed
2526
* Based all gltf data classes on `BaseGLTFDataClass`

docs/tutorial/brep.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,27 @@ Trimming a Brep in Grasshopper
110110
.. |pic2| image:: files/trimmed_box.png
111111
:width: 48%
112112

113+
Splitting a Brep in Grasshopper
114+
115+
.. code-block::
116+
117+
from compas.geometry import Brep, Box, Frame, Translation
118+
119+
brep = Brep.from_box(Box.from_width_height_depth(5,5,5))
120+
cutter = Brep.from_box(Box.from_width_height_depth(1, 6, 6))
121+
122+
a, b, c = brep.split(cutter)
123+
124+
world_xy = Frame.worldXY()
125+
translated_frame = Frame((0, 0, 1.), world_xy.xaxis, world_xy.yaxis)
126+
t = Translation.from_frame_to_frame(world_xy, translated_frame)
127+
a.transform(t)
128+
b.transform(t)
129+
130+
result = [x.native_brep for x in [a, b, c]]
131+
132+
.. image:: files/3_way_split.png
133+
:width: 50%
113134

114135
Implementing a new backend
115136
==========================
214 KB
Loading

src/compas/geometry/brep/brep.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -911,13 +911,13 @@ def slice(self, plane):
911911
912912
"""
913913

914-
def split(self, other):
914+
def split(self, cutter):
915915
"""Slice through the BRep with a plane.
916916
917917
Parameters
918918
----------
919-
other : :class:`~compas.geomtery.Brep`
920-
Another Brep.
919+
cutter : :class:`~compas.geomtery.Brep`
920+
Another Brep to use as a cutter.
921921
922922
Returns
923923
-------

src/compas_rhino/geometry/brep/brep.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,23 @@ def from_boolean_intersection(cls, breps_a, breps_b):
312312
)
313313
return [RhinoBrep.from_brep(brep) for brep in resulting_breps]
314314

315+
def split(self, cutter):
316+
"""Splits a Brep into pieces using a Brep as a cutter.
317+
318+
Parameters
319+
----------
320+
cutter : :class:`~compas_rhino.geometry.RhinoBrep`
321+
Another Brep to use as a cutter.
322+
323+
Returns
324+
-------
325+
list(:class:`~compas_rhino.geometry.RhinoBrep`)
326+
list of zero or more resulting Breps.
327+
328+
"""
329+
resulting_breps = self._brep.Split(cutter.native_brep, TOLERANCE)
330+
return [RhinoBrep.from_brep(brep) for brep in resulting_breps]
331+
315332
# ==============================================================================
316333
# Other Methods
317334
# ==============================================================================

0 commit comments

Comments
 (0)