Skip to content

Commit d03d83d

Browse files
committed
added partial implementation of Brep.to_viewmesh()
1 parent 639222e commit d03d83d

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3737
* Added implementation for `Brep.from_pipe` in `compas_rhino.geometry.RhinoBrep`.
3838
* Added implementation for `Brep.from_iges` in `compas_rhino.geometry.RhinoBrep`.
3939
* Added implementation for `Brep.to_step` in `compas_rhino.geometry.RhinoBrep`.
40+
* Added implementation for `Brep.to_viewmesh()` in `compas_rhino.geometry.RhinoBrep`.
4041

4142
### Changed
4243

src/compas_rhino/geometry/brep/brep.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import rhinoscriptsyntax as rs # type: ignore
77

88
import compas_rhino.objects
9+
from compas.datastructures import Mesh
910
from compas.geometry import Brep
1011
from compas.geometry import BrepError
1112
from compas.geometry import BrepFilletError
@@ -61,6 +62,13 @@ def _import_brep_from_file(filepath):
6162
return RhinoBrep.from_native(geometry)
6263

6364

65+
def _join_meshes(meshes):
66+
result = Mesh()
67+
for mesh in meshes:
68+
result.join(mesh)
69+
return result
70+
71+
6472
class RhinoBrep(Brep):
6573
"""Rhino Brep backend class.
6674
@@ -862,6 +870,26 @@ def to_meshes(self, u=16, v=16):
862870
meshes = [mesh_to_compas(m) for m in rg_meshes]
863871
return meshes
864872

873+
def to_viewmesh(self, linear_deflection: float = 0.001):
874+
"""
875+
Convert the Brep to a single view mesh.
876+
877+
Note
878+
----
879+
Edges as polylines is not currently implemented for RhinoBrep. Therefore, an empty list will be returned.
880+
881+
Parameters
882+
----------
883+
linear_deflection : float, optional
884+
The maximum linear deflection between the geometry and its discrete representation.
885+
886+
Returns
887+
-------
888+
tuple[:class:`compas.datastructures.Mesh`, list[:class:`compas.geometry.Polyline`]]
889+
890+
"""
891+
return _join_meshes(self.to_meshes()), []
892+
865893
def to_step(self, filepath):
866894
if not filepath.endswith(".step"):
867895
raise ValueError("Attempted to export STEP but file ends with {} extension".format(filepath.split(".")[-1]))

0 commit comments

Comments
 (0)