22from __future__ import absolute_import
33from __future__ import division
44
5- from compas .utilities import pairwise
65import compas_rhino
76from compas .artists import ShapeArtist
87from .artist import RhinoArtist
@@ -22,54 +21,34 @@ class SphereArtist(RhinoArtist, ShapeArtist):
2221 def __init__ (self , sphere , layer = None , ** kwargs ):
2322 super (SphereArtist , self ).__init__ (shape = sphere , 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 sphere associated with the artist.
2726
2827 Parameters
2928 ----------
29+ color : tuple of float, optional
30+ The RGB color of the sphere.
3031 u : int, optional
3132 Number of faces in the "u" direction.
3233 Default is ``~SphereArtist.u``.
3334 v : int, optional
3435 Number of faces in the "v" direction.
3536 Default is ``~SphereArtist.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