|
27 | 27 | from compas_rhino.conversions import sphere_to_rhino |
28 | 28 | from compas_rhino.conversions import transformation_to_rhino |
29 | 29 | from compas_rhino.conversions import vector_to_rhino |
| 30 | +from compas_rhino.geometry import RhinoNurbsCurve |
| 31 | +from compas_rhino.geometry import RhinoNurbsSurface |
30 | 32 |
|
31 | 33 | from .builder import _RhinoBrepBuilder |
32 | 34 | from .edge import RhinoBrepEdge |
@@ -62,6 +64,36 @@ class RhinoBrep(Brep): |
62 | 64 | The calculated area of this brep. |
63 | 65 | volume : float, read-only |
64 | 66 | 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. |
65 | 97 |
|
66 | 98 | """ |
67 | 99 |
|
@@ -183,6 +215,87 @@ def volume(self): |
183 | 215 | if self._brep: |
184 | 216 | return self._brep.GetVolume() |
185 | 217 |
|
| 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 | + |
186 | 299 | # ============================================================================== |
187 | 300 | # Constructors |
188 | 301 | # ============================================================================== |
|
0 commit comments