Skip to content

Commit e1e7af1

Browse files
committed
Merge branch 'main' into mesh-strip-split
2 parents a58a1fa + 8618b98 commit e1e7af1

34 files changed

+2353
-1228
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515

1616
### Changed
1717

18+
* Fixed bug in combination of `compas_rhino.artists.MeshArtist.draw_mesh` and `compas_rhino.utilities.drawing.draw_mesh`.
1819
* Fixed bug in continuous loops in `compas.datastructures.Halfedge.edge_loop`.
1920
* Fixed bug in continuous strips in `compas.datastructures.Halfedge.edge_strip`.
2021
* Changed abstract method `compas.artists.MeshArtist.draw_mesh` to implemented method in `compas_plotters.artists.MeshArtist.draw_mesh`.
@@ -32,6 +33,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3233
* Added pluggables for `compas.geometry.NurbsSurface.__new__`, `compas.geometry.NurbsSurface.from_parameters`, `compas.geometry.NurbsSurface.from_points`, `compas.geometry.NurbsSurface.from_fill`, `compas.geometry.NurbsSurface.from_step`.
3334
* Added missing implementations for abstract clear methods of `compas_rhino.artists.volmeshartist`.
3435

36+
* Added `compas_rhino.geometry.RhinoBox`, `compas_rhino.geometry.RhinoCircle`, `compas_rhino.geometry.RhinoCone`, `compas_rhino.geometry.RhinoCurve`, `compas_rhino.geometry.RhinoCylinder`, `compas_rhino.geometry.RhinoEllipse`, `compas_rhino.geometry.RhinoLine`, `compas_rhino.geometry.RhinoMesh`, `compas_rhino.geometry.RhinoPlane`, `compas_rhino.geometry.RhinoPoint`, `compas_rhino.geometry.RhinoPolyline`, `compas_rhino.geometry.RhinoSphere`, `compas_rhino.geometry.RhinoSurface`, `compas_rhino.geometry.RhinoVector` as wrappers for working with Rhino geometry through geometry conversions or coercion of doc objects.
37+
* Added `compas_rhino.conversions` from COMPAS geometry to Rhino geometry and vice versa, for primitives, shapes, curves, surfaces, meshes.
38+
* Added `compas_rhino.coercion` from Rhino doc objects to Rhino geometry compatible with COMPAS geometry.
39+
3540
### Changed
3641

3742
* Fixed bug in directions of `compas.datastructures.Mesh.from_meshgrid`.
@@ -143,6 +148,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
143148
* Added general plotter for geometry objects and data structures based on the artist registration mechanism.
144149
* Added support for multimesh files to OBJ reader/writer.
145150
* Added support for attaching and detaching meshes in `compas.robots.RobotModelArtist` and drawing them.
151+
* Added `compas.geometry.NurbsCurve`.
152+
* Added `compas.geometry.NurbsSurface`.
153+
* Added `compas_rhino.conversions`.
154+
* Added `compas_rhino.geometry.RhinoBox`.
155+
* Added `compas_rhino.geometry.RhinoCone`.
156+
* Added `compas_rhino.geometry.RhinoCylinder`.
157+
* Added `compas_rhino.geometry.RhinoPolyline`.
158+
* Added `compas_rhino.geometry.RhinoSphere`.
146159
* Added `meshes` method to artists of `compas.robots.RobotModel`.
147160
* Added `FrameArtist` class to `compas_blender`.
148161

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
.. automodule:: compas_rhino.conversions

docs/conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
import sphinx_compas_theme
1515
from sphinx.ext.napoleon.docstring import NumpyDocstring
1616

17-
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../src'))
18-
1917
# patches
2018

2119
current_m2r2_setup = m2r2.setup
@@ -331,7 +329,9 @@ def linkcode_resolve(domain, info):
331329

332330
# extlinks
333331

334-
extlinks = {}
332+
extlinks = {
333+
"rhino": ("https://developer.rhino3d.com/api/RhinoCommon/html/T_%s.htm", "%s")
334+
}
335335

336336
# -- Options for HTML output ----------------------------------------------
337337

docs/tutorial/curves-and-surfs.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
***********************
2+
Curves and Surfaces
3+
***********************

src/compas_rhino/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
1111
compas_rhino.artists
1212
compas_rhino.conduits
13+
compas_rhino.conversions
1314
compas_rhino.forms
1415
compas_rhino.geometry
1516
compas_rhino.objects

src/compas_rhino/artists/meshartist.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
from functools import partial
66

77
from compas.utilities import color_to_colordict
8-
from compas.utilities import pairwise
98
from compas.geometry import add_vectors
109
from compas.geometry import scale_vector
11-
from compas.geometry import centroid_polygon
1210
from compas.geometry import centroid_points
1311

1412
import compas_rhino
@@ -174,21 +172,9 @@ def draw_mesh(self, color=None, disjoint=False):
174172
vertex_xyz = self.vertex_xyz
175173
vertices = [vertex_xyz[vertex] for vertex in self.mesh.vertices()]
176174
faces = [[vertex_index[vertex] for vertex in self.mesh.face_vertices(face)] for face in self.mesh.faces()]
177-
new_faces = []
178-
for face in faces:
179-
f = len(face)
180-
if f == 3:
181-
new_faces.append(face + face[-1:])
182-
elif f == 4:
183-
new_faces.append(face)
184-
elif f > 4:
185-
centroid = len(vertices)
186-
vertices.append(centroid_polygon([vertices[index] for index in face]))
187-
for a, b in pairwise(face + face[0:1]):
188-
new_faces.append([centroid, a, b, b])
189175
layer = self.layer
190176
name = "{}.mesh".format(self.mesh.name)
191-
guid = compas_rhino.draw_mesh(vertices, new_faces, layer=layer, name=name, color=color, disjoint=disjoint)
177+
guid = compas_rhino.draw_mesh(vertices, faces, layer=layer, name=name, color=color, disjoint=disjoint)
192178
return [guid]
193179

194180
def draw_vertices(self, vertices=None, color=None):
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
"""
2+
********************************************************************************
3+
conversions
4+
********************************************************************************
5+
6+
.. currentmodule:: compas_rhino.conversions
7+
8+
.. rst-class:: lead
9+
10+
Conversions between Rhino geometry objects (:mod:`Rhino.Geometry`) and COMPAS geometry objects (:mod:`compas.geometry`).
11+
12+
Exceptions
13+
==========
14+
15+
.. autosummary::
16+
:toctree: generated/
17+
:nosignatures:
18+
19+
ConversionError
20+
21+
22+
Primitives
23+
==========
24+
25+
.. autosummary::
26+
:toctree: generated/
27+
:nosignatures:
28+
29+
point_to_rhino
30+
vector_to_rhino
31+
line_to_rhino
32+
plane_to_rhino
33+
frame_to_rhino
34+
circle_to_rhino
35+
ellipse_to_rhino
36+
polyline_to_rhino
37+
polygon_to_rhino
38+
point_to_compas
39+
vector_to_compas
40+
line_to_compas
41+
plane_to_compas
42+
plane_to_compas_frame
43+
circle_to_compas
44+
ellipse_to_compas
45+
polyline_to_compas
46+
polygon_to_compas
47+
48+
49+
Shapes
50+
======
51+
52+
.. autosummary::
53+
:toctree: generated/
54+
:nosignatures:
55+
56+
box_to_rhino
57+
sphere_to_rhino
58+
cone_to_rhino
59+
cylinder_to_rhino
60+
box_to_compas
61+
sphere_to_compas
62+
cone_to_compas
63+
cylinder_to_compas
64+
65+
66+
Curves
67+
======
68+
69+
.. autosummary::
70+
:toctree: generated/
71+
:nosignatures:
72+
73+
line_to_rhino_curve
74+
circle_to_rhino_curve
75+
ellipse_to_rhino_curve
76+
curve_to_compas_line
77+
curve_to_compas_circle
78+
curve_to_compas_ellipse
79+
curve_to_compas_polyline
80+
81+
82+
Surfaces
83+
========
84+
85+
.. autosummary::
86+
:toctree: generated/
87+
:nosignatures:
88+
89+
90+
"""
91+
from __future__ import absolute_import
92+
93+
from .exceptions import ConversionError
94+
95+
from .primitives import (
96+
point_to_rhino,
97+
vector_to_rhino,
98+
line_to_rhino,
99+
plane_to_rhino,
100+
frame_to_rhino,
101+
circle_to_rhino,
102+
ellipse_to_rhino,
103+
polyline_to_rhino,
104+
polygon_to_rhino,
105+
106+
point_to_compas,
107+
vector_to_compas,
108+
line_to_compas,
109+
plane_to_compas,
110+
plane_to_compas_frame,
111+
circle_to_compas,
112+
ellipse_to_compas,
113+
polyline_to_compas,
114+
polygon_to_compas
115+
)
116+
from .shapes import (
117+
box_to_rhino,
118+
sphere_to_rhino,
119+
cone_to_rhino,
120+
cylinder_to_rhino,
121+
122+
box_to_compas,
123+
sphere_to_compas,
124+
cone_to_compas,
125+
cylinder_to_compas,
126+
)
127+
from .curves import (
128+
line_to_rhino_curve,
129+
circle_to_rhino_curve,
130+
ellipse_to_rhino_curve,
131+
132+
curve_to_compas_circle,
133+
curve_to_compas_ellipse,
134+
curve_to_compas_line,
135+
curve_to_compas_polyline
136+
)
137+
138+
# geometry to geometry conversions
139+
# Rhino object to geometry conversions
140+
141+
__all__ = [
142+
'ConversionError',
143+
144+
'point_to_rhino',
145+
'vector_to_rhino',
146+
'line_to_rhino',
147+
'plane_to_rhino',
148+
'frame_to_rhino',
149+
'circle_to_rhino',
150+
'ellipse_to_rhino',
151+
'polyline_to_rhino',
152+
'polygon_to_rhino',
153+
154+
'point_to_compas',
155+
'vector_to_compas',
156+
'line_to_compas',
157+
'plane_to_compas',
158+
'plane_to_compas_frame',
159+
'circle_to_compas',
160+
'ellipse_to_compas',
161+
'polyline_to_compas',
162+
'polygon_to_compas',
163+
164+
'box_to_rhino',
165+
'sphere_to_rhino',
166+
'cone_to_rhino',
167+
'cylinder_to_rhino',
168+
169+
'box_to_compas',
170+
'sphere_to_compas',
171+
'cone_to_compas',
172+
'cylinder_to_compas',
173+
174+
'line_to_rhino_curve',
175+
'circle_to_rhino_curve',
176+
'ellipse_to_rhino_curve',
177+
178+
'curve_to_compas_circle',
179+
'curve_to_compas_ellipse',
180+
'curve_to_compas_line',
181+
'curve_to_compas_polyline',
182+
]

0 commit comments

Comments
 (0)