|
6 | 6 | import rhinoscriptsyntax as rs # type: ignore |
7 | 7 |
|
8 | 8 | import compas_rhino.objects |
| 9 | +from compas.datastructures import Mesh |
9 | 10 | from compas.geometry import Brep |
10 | 11 | from compas.geometry import BrepError |
11 | 12 | from compas.geometry import BrepFilletError |
@@ -61,6 +62,13 @@ def _import_brep_from_file(filepath): |
61 | 62 | return RhinoBrep.from_native(geometry) |
62 | 63 |
|
63 | 64 |
|
| 65 | +def _join_meshes(meshes): |
| 66 | + result = Mesh() |
| 67 | + for mesh in meshes: |
| 68 | + result.join(mesh) |
| 69 | + return result |
| 70 | + |
| 71 | + |
64 | 72 | class RhinoBrep(Brep): |
65 | 73 | """Rhino Brep backend class. |
66 | 74 |
|
@@ -862,6 +870,26 @@ def to_meshes(self, u=16, v=16): |
862 | 870 | meshes = [mesh_to_compas(m) for m in rg_meshes] |
863 | 871 | return meshes |
864 | 872 |
|
| 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 | + |
865 | 893 | def to_step(self, filepath): |
866 | 894 | if not filepath.endswith(".step"): |
867 | 895 | raise ValueError("Attempted to export STEP but file ends with {} extension".format(filepath.split(".")[-1])) |
|
0 commit comments