Skip to content

Commit a3ab8fb

Browse files
committed
added missing properties to RhinoBrep
1 parent 8496686 commit a3ab8fb

File tree

2 files changed

+123
-0
lines changed

2 files changed

+123
-0
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
* Added `compas.geometry.angle_vectors_projected`.
1616
* Added `compas.geometry.Brep.from_curves`.
1717
* Added `compas_rhino.geometry.RhinoBrep.from_curves`.
18+
* Added missing property `centroid` in `compas_rhino.geometry.RhinoBrep`.
19+
* Added missing property `curves` in `compas_rhino.geometry.RhinoBrep`.
20+
* Added missing property `is_closed` in `compas_rhino.geometry.RhinoBrep`.
21+
* Added missing property `is_compound` in `compas_rhino.geometry.RhinoBrep`.
22+
* Added missing property `is_compoundsolid` in `compas_rhino.geometry.RhinoBrep`.
23+
* Added missing property `is_orientable` in `compas_rhino.geometry.RhinoBrep`.
24+
* Added missing property `is_surface` in `compas_rhino.geometry.RhinoBrep`.
25+
* Added missing property `is_valid` in `compas_rhino.geometry.RhinoBrep`.
26+
* Added missing property `orientation` in `compas_rhino.geometry.RhinoBrep`.
27+
* Added missing property `surfaces` in `compas_rhino.geometry.RhinoBrep`.
1828

1929
### Changed
2030

src/compas_rhino/geometry/brep/brep.py

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
from compas_rhino.conversions import sphere_to_rhino
2828
from compas_rhino.conversions import transformation_to_rhino
2929
from compas_rhino.conversions import vector_to_rhino
30+
from compas_rhino.geometry import RhinoNurbsCurve
31+
from compas_rhino.geometry import RhinoNurbsSurface
3032

3133
from .builder import _RhinoBrepBuilder
3234
from .edge import RhinoBrepEdge
@@ -62,6 +64,36 @@ class RhinoBrep(Brep):
6264
The calculated area of this brep.
6365
volume : float, read-only
6466
The calculated volume of this brep.
67+
centroid : :class:`compas.geometry.Point`, read-only
68+
The calculated centroid of this brep.
69+
curves : list[:class:`compas_rhino.geometry.RhinoNurbsCurve`], read-only
70+
The list of curves which comprise this brep.
71+
is_closed : bool, read-only
72+
True if this brep is closed, False otherwise.
73+
is_compound : bool, read-only
74+
True if this brep is compound, False otherwise.
75+
is_compoundsolid : bool, read-only
76+
True if this brep is compound solid, False otherwise.
77+
is_convex : bool, read-only
78+
True if this brep is convex, False otherwise.
79+
is_infinite : bool, read-only
80+
True if this brep is infinite, False otherwise.
81+
is_orientable : bool, read-only
82+
True if this brep is orientable, False otherwise.
83+
is_shell : bool, read-only
84+
True if this brep is a shell, False otherwise.
85+
is_surface : bool, read-only
86+
True if this brep is a surface, False otherwise.
87+
is_valid : bool, read-only
88+
True if this brep is valid, False otherwise.
89+
orientation : literal(:class:`~compas.geometry.BrepOrientation`), read-only
90+
The orientation of this brep. One of: FORWARD, REVERSED, INTERNAL, EXTERNAL.
91+
shells : list[:class:`compas_rhino.geometry.RhinoBrep`], read-only
92+
The list of shells which comprise this brep.
93+
solids : list[:class:`compas_rhino.geometry.RhinoBrep`], read-only
94+
The list of solids which comprise this brep.
95+
surfaces : list[:class:`compas_rhino.geometry.RhinoNurbsSurface`], read-only
96+
The list of surfaces which comprise this brep.
6597
6698
"""
6799

@@ -183,6 +215,87 @@ def volume(self):
183215
if self._brep:
184216
return self._brep.GetVolume()
185217

218+
@property
219+
def centroid(self):
220+
assert self._brep
221+
centroid = Rhino.Geometry.AreaMassProperties.Compute(self._brep).Centroid
222+
return Point(*centroid)
223+
224+
@property
225+
def curves(self):
226+
assert self._brep
227+
return [RhinoNurbsCurve.from_native(c.ToNurbsCurve()) for c in self._brep.Curves3D]
228+
229+
@property
230+
def is_closed(self):
231+
assert self._brep
232+
return self._brep.IsSolid
233+
234+
@property
235+
def is_compound(self):
236+
# TODO: clarify. according to the internets compound brep is actually a container for several breps, not sure that's possible with a Rhino Brep.
237+
return False
238+
239+
@property
240+
def is_compoundsolid(self):
241+
# TODO: see above
242+
return False
243+
244+
@property
245+
def is_convex(self):
246+
raise NotImplementedError("Convexity check is not implemented for Rhino Breps.")
247+
248+
@property
249+
def is_infinite(self):
250+
pass
251+
252+
@property
253+
def is_orientable(self):
254+
assert self._brep
255+
return self._brep.SolidOrientation in (Rhino.Geometry.BrepSolidOrientation.Inward, Rhino.Geometry.BrepSolidOrientation.Outward)
256+
257+
@property
258+
def is_shell(self):
259+
# not sure how to get this one
260+
raise NotImplementedError
261+
262+
@property
263+
def is_surface(self):
264+
assert self._brep
265+
return self._brep.IsSurface
266+
267+
@property
268+
def is_valid(self):
269+
assert self._brep
270+
return self.IsValid
271+
272+
@property
273+
def orientation(self):
274+
assert self._brep
275+
# TODO: align this with compas.geometry.BrepOrientation
276+
return self._brep.SolidOrientation
277+
278+
@property
279+
def shells(self):
280+
# TODO: can create shell from brep but have to specify which faces to eliminate in order to hollow out the brep, doesn't seem like the intention.
281+
# TODO: is this about traversing a compound brep?
282+
raise NotImplementedError("Shells are not implemented for Rhino Breps.")
283+
284+
@property
285+
def solids(self):
286+
# TODO: same as above
287+
raise NotImplementedError("Solids are not implemented for Rhino Breps.")
288+
289+
@property
290+
def surfaces(self):
291+
assert self._brep
292+
return [[RhinoNurbsSurface.from_native(s.ToNurbsSurface()) for s in self._brep.Surfaces]]
293+
294+
@property
295+
def type(self):
296+
# TODO: seems like an OCC specific thinh, rename to occ_type and remove from interface?
297+
raise NotImplementedError("Type is not implemented for Rhino Breps.")
298+
186299
# ==============================================================================
187300
# Constructors
188301
# ==============================================================================

0 commit comments

Comments
 (0)