Skip to content

Commit b0588db

Browse files
committed
capsule and box as disjoint mesh
1 parent ce4a93f commit b0588db

File tree

2 files changed

+18
-38
lines changed

2 files changed

+18
-38
lines changed

src/compas_rhino/artists/boxartist.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ def draw(self, color=None):
3636
"""
3737
color = color or self.color
3838
vertices = [list(vertex) for vertex in self.shape.vertices]
39-
polygons = [{'points': [vertices[index] for index in face]} for face in self.shape.faces]
40-
guids = compas_rhino.draw_faces(polygons, clear=False, redraw=False)
41-
guid = compas_rhino.rs.JoinMeshes(guids, delete_input=True)
42-
compas_rhino.rs.ObjectLayer(guid, self.layer)
43-
compas_rhino.rs.ObjectName(guid, self.shape.name)
44-
compas_rhino.rs.ObjectColor(guid, color)
39+
faces = self.shape.faces
40+
guid = compas_rhino.draw_mesh(vertices,
41+
faces,
42+
layer=self.layer,
43+
name=self.shape.name,
44+
color=color,
45+
disjoint=True)
4546
return [guid]

src/compas_rhino/artists/capsuleartist.py

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from __future__ import absolute_import
33
from __future__ import division
44

5-
from compas.utilities import pairwise
65
import compas_rhino
76
from compas.artists import ShapeArtist
87
from .artist import RhinoArtist
@@ -22,54 +21,34 @@ class CapsuleArtist(RhinoArtist, ShapeArtist):
2221
def __init__(self, capsule, layer=None, **kwargs):
2322
super(CapsuleArtist, self).__init__(shape=capsule, layer=layer, **kwargs)
2423

25-
def draw(self, u=None, v=None, show_vertices=False, show_edges=False, show_faces=True, join_faces=True):
24+
def draw(self, color=None, u=None, v=None):
2625
"""Draw the capsule associated with the artist.
2726
2827
Parameters
2928
----------
29+
color : tuple of float, optional
30+
The RGB color of the capsule.
3031
u : int, optional
3132
Number of faces in the "u" direction.
3233
Default is ``~CapsuleArtist.u``.
3334
v : int, optional
3435
Number of faces in the "v" direction.
3536
Default is ``~CapsuleArtist.v``.
36-
show_vertices : bool, optional
37-
Default is ``False``.
38-
show_edges : bool, optional
39-
Default is ``False``.
40-
show_faces : bool, optional
41-
Default is ``True``.
42-
join_faces : bool, optional
43-
Default is ``True``.
4437
4538
Returns
4639
-------
4740
list
4841
The GUIDs of the objects created in Rhino.
4942
"""
43+
color = color or self.color
5044
u = u or self.u
5145
v = v or self.v
5246
vertices, faces = self.shape.to_vertices_and_faces(u=u, v=v)
5347
vertices = [list(vertex) for vertex in vertices]
54-
guids = []
55-
if show_vertices:
56-
points = [{'pos': point, 'color': self.color} for point in vertices]
57-
guids += compas_rhino.draw_points(points, layer=self.layer, clear=False, redraw=False)
58-
if show_edges:
59-
lines = []
60-
seen = set()
61-
for face in faces:
62-
for u, v in pairwise(face + face[:1]):
63-
if (u, v) not in seen:
64-
seen.add((u, v))
65-
seen.add((v, u))
66-
lines.append({'start': vertices[u], 'end': vertices[v], 'color': self.color})
67-
guids += compas_rhino.draw_lines(lines, layer=self.layer, clear=False, redraw=False)
68-
if show_faces:
69-
if join_faces:
70-
guid = compas_rhino.draw_mesh(vertices, faces, layer=self.layer, name=self.shape.name, color=self.color, disjoint=True)
71-
guids.append(guid)
72-
else:
73-
polygons = [{'points': [vertices[index] for index in face], 'color': self.color} for face in faces]
74-
guids += compas_rhino.draw_faces(polygons, layer=self.layer, clear=False, redraw=False)
75-
return guids
48+
guid = compas_rhino.draw_mesh(vertices,
49+
faces,
50+
layer=self.layer,
51+
name=self.shape.name,
52+
color=color,
53+
disjoint=True)
54+
return [guid]

0 commit comments

Comments
 (0)