Skip to content

Commit 41f680d

Browse files
authored
Merge pull request #1005 from compas-dev/datastructure-artist-fixes
General fixes related to data structure artists
2 parents 96ecee2 + 15d5fd4 commit 41f680d

File tree

14 files changed

+756
-233
lines changed

14 files changed

+756
-233
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
* Added `compas.datastructures.VolMesh.from_meshgrid`.
1919
* Added `vertices_where`, `vertices_where_predicate`, `edges_where`, `edges_where_predicate` to `compas.datastructures.HalfFace`.
2020
* Added `faces_where`, `faces_where_predicate`, `cells_where`, `cells_where_predicate` to `compas.datastructures.HalfFace`.
21+
* Added `VolMeshArtist` to registered Blender artists.
2122
* Added `3.1` to supported versions for Blender installer.
2223

2324
### Changed
@@ -38,6 +39,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3839
* Changed `planarity` to optional requirement on all platforms.
3940
* Changed `numba` to optional requirement on all platforms.
4041
* Changed raw github content path for `compas.get`.
42+
* Fixed `compas_blender.artists.VolMeshArtist.draw` and `compas_blender.artists.VolMeshArtist.draw_cells`.
43+
* Fixed `compas_ghpython.artists.VolMeshArtist.draw` and `compas_ghpython.artists.VolMeshArtist.draw_cells`.
44+
* Fixed `compas_rhino.artists.VolMeshArtist.draw` and `compas_rhino.artists.VolMeshArtist.draw_cells`.
4145

4246
### Removed
4347

src/compas/artists/meshartist.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@ class MeshArtist(Artist):
1616
----------
1717
mesh : :class:`~compas.datastructures.Mesh`
1818
A COMPAS mesh.
19+
vertices : list[int], optional
20+
Selection of vertices to draw.
21+
edges : list[tuple[int, int]], optional
22+
Selection of edges to draw.
23+
faces : list[int], optional
24+
Selection of faces to draw.
25+
vertexcolor : tuple[float, float, float] | dict[int, tuple[float, float, float]], optional
26+
Color of the vertices.
27+
Default color is :attr:`MeshArtists.default_vertexcolor`.
28+
edgecolor : tuple[float, float, float] | dict[tuple[int, int], tuple[float, float, float]], optional
29+
Color of the edges.
30+
Default color is :attr:`MeshArtists.default_edgecolor`.
31+
facecolor : tuple[float, float, float] | dict[int, tuple[float, float, float]], optional
32+
Color of the faces.
33+
Default color is :attr:`MeshArtists.default_facecolor`.
1934
2035
Attributes
2136
----------
@@ -90,7 +105,15 @@ class MeshArtist(Artist):
90105
default_vertexsize = 5
91106
default_edgewidth = 1.0
92107

93-
def __init__(self, mesh, **kwargs):
108+
def __init__(self,
109+
mesh,
110+
vertices=None,
111+
edges=None,
112+
faces=None,
113+
vertexcolor=None,
114+
edgecolor=None,
115+
facecolor=None,
116+
**kwargs):
94117
super(MeshArtist, self).__init__()
95118

96119
self._default_vertexcolor = None
@@ -123,6 +146,13 @@ def __init__(self, mesh, **kwargs):
123146

124147
self.mesh = mesh
125148

149+
self.vertices = vertices
150+
self.edges = edges
151+
self.faces = faces
152+
self.vertex_color = vertexcolor
153+
self.edge_color = edgecolor
154+
self.face_color = facecolor
155+
126156
@property
127157
def mesh(self):
128158
return self._mesh

src/compas/artists/networkartist.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ class NetworkArtist(Artist):
1616
----------
1717
network : :class:`~compas.datastructures.Network`
1818
A COMPAS network.
19+
nodes : list[hashable], optional
20+
A list of node identifiers.
21+
Default is None, in which case all nodes are drawn.
22+
edges : list[tuple[hashable, hashable]], optional
23+
A list of edge keys (as uv pairs) identifying which edges to draw.
24+
The default is None, in which case all edges are drawn.
25+
nodecolor : :class:`~compas.colors.Color` | dict[hashable, :class:`~compas.colors.Color`], optional
26+
The color specification for the nodes.
27+
edgecolor : :class:`~compas.colors.Color` | dict[tuple[hashable, hashable]], :class:`~compas.colors.Color`], optional
28+
The color specification for the edges.
1929
2030
Attributes
2131
----------
@@ -69,7 +79,13 @@ class NetworkArtist(Artist):
6979
default_nodesize = 5
7080
default_edgewidth = 1.0
7181

72-
def __init__(self, network, **kwargs):
82+
def __init__(self,
83+
network,
84+
nodes=None,
85+
edges=None,
86+
nodecolor=None,
87+
edgecolor=None,
88+
**kwargs):
7389
super(NetworkArtist, self).__init__()
7490

7591
self._default_nodecolor = None
@@ -83,6 +99,7 @@ def __init__(self, network, **kwargs):
8399
self._edge_color = None
84100
self._node_text = None
85101
self._edge_text = None
102+
self._edge_width = None
86103

87104
self._nodecollection = None
88105
self._edgecollection = None
@@ -91,6 +108,11 @@ def __init__(self, network, **kwargs):
91108

92109
self.network = network
93110

111+
self.nodes = nodes
112+
self.edges = edges
113+
self.node_color = nodecolor
114+
self.edge_color = edgecolor
115+
94116
@property
95117
def network(self):
96118
return self._network

src/compas/artists/volmeshartist.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,17 @@ class VolMeshArtist(Artist):
8282
face_color = ColorDict()
8383
cell_color = ColorDict()
8484

85-
def __init__(self, volmesh, **kwargs):
85+
def __init__(self,
86+
volmesh,
87+
vertices=None,
88+
edges=None,
89+
faces=None,
90+
cells=None,
91+
vertexcolor=None,
92+
edgecolor=None,
93+
facecolor=None,
94+
cellcolor=None,
95+
**kwargs):
8696
super(VolMeshArtist, self).__init__()
8797

8898
self._default_vertexcolor = None
@@ -105,8 +115,28 @@ def __init__(self, volmesh, **kwargs):
105115
self._face_text = None
106116
self._cell_text = None
107117

118+
self._vertexcollection = None
119+
self._edgecollection = None
120+
self._facecollection = None
121+
self._cellcollection = None
122+
self._vertexnormalcollection = None
123+
self._facenormalcollection = None
124+
self._vertexlabelcollection = None
125+
self._edgelabelcollection = None
126+
self._facelabelcollection = None
127+
self._celllabelcollection = None
128+
108129
self.volmesh = volmesh
109130

131+
self.vertices = vertices
132+
self.edges = edges
133+
self.faces = faces
134+
self.cells = cells
135+
self.vertex_color = vertexcolor
136+
self.edge_color = edgecolor
137+
self.face_color = facecolor
138+
self.cell_color = cellcolor
139+
110140
@property
111141
def volmesh(self):
112142
return self._volmesh

src/compas_blender/artists/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
from compas.geometry import Vector
109109
from compas.datastructures import Mesh
110110
from compas.datastructures import Network
111+
from compas.datastructures import VolMesh
111112
from compas.robots import RobotModel
112113

113114
from .artist import BlenderArtist
@@ -130,6 +131,7 @@
130131
from .surfaceartist import SurfaceArtist
131132
from .torusartist import TorusArtist
132133
from .vectorartist import VectorArtist
134+
from .volmeshartist import VolMeshArtist
133135

134136

135137
@plugin(category='drawing-utils', pluggable_name='clear', requires=['bpy'])
@@ -164,6 +166,7 @@ def register_artists():
164166
Artist.register(Surface, SurfaceArtist, context='Blender')
165167
Artist.register(Torus, TorusArtist, context='Blender')
166168
Artist.register(Vector, VectorArtist, context='Blender')
169+
Artist.register(VolMesh, VolMeshArtist, context='Blender')
167170
print('Blender Artists registered.')
168171

169172

@@ -188,4 +191,5 @@ def register_artists():
188191
'SurfaceArtist',
189192
'TorusArtist',
190193
'VectorArtist',
194+
'VolMeshArtist',
191195
]

src/compas_blender/artists/meshartist.py

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,6 @@ class MeshArtist(BlenderArtist, MeshArtist):
2727
A COMPAS mesh.
2828
collection : str | :blender:`bpy.types.Collection`
2929
The Blender scene collection the object(s) created by this artist belong to.
30-
vertices : list[int], optional
31-
A list of vertex identifiers.
32-
Default is None, in which case all vertices are drawn.
33-
edges : list[tuple[int, int]], optional
34-
A list of edge keys (as uv pairs) identifying which edges to draw.
35-
The default is None, in which case all edges are drawn.
36-
faces : list[int], optional
37-
A list of face identifiers.
38-
The default is None, in which case all faces are drawn.
39-
vertexcolor : :class:`~compas.colors.Color` | dict[int, :class:`~compas.colors.Color`], optional
40-
The color specification for the vertices.
41-
edgecolor : :class:`~compas.colors.Color` | dict[tuple[int, int], :class:`~compas.colors.Color`], optional
42-
The color specification for the edges.
43-
facecolor : :class:`~compas.colors.Color` | dict[int, :class:`~compas.colors.Color`], optional
44-
The color specification for the faces.
45-
show_mesh : bool, optional
46-
If True, draw the mesh.
47-
show_vertices : bool, optional
48-
If True, draw the individual vertices.
49-
show_edges : bool, optional
50-
If True, draw the individual edges.
51-
show_faces : bool, optional
52-
If True, draw the individual faces.
5330
5431
Attributes
5532
----------
@@ -97,31 +74,10 @@ class MeshArtist(BlenderArtist, MeshArtist):
9774
def __init__(self,
9875
mesh: Mesh,
9976
collection: Optional[Union[str, bpy.types.Collection]] = None,
100-
vertices: Optional[List[int]] = None,
101-
edges: Optional[List[int]] = None,
102-
faces: Optional[List[int]] = None,
103-
vertexcolor: Optional[Color] = None,
104-
edgecolor: Optional[Color] = None,
105-
facecolor: Optional[Color] = None,
106-
show_mesh: bool = False,
107-
show_vertices: bool = True,
108-
show_edges: bool = True,
109-
show_faces: bool = True,
11077
**kwargs: Any):
11178

11279
super().__init__(mesh=mesh, collection=collection or mesh.name, **kwargs)
11380

114-
self.vertices = vertices
115-
self.edges = edges
116-
self.faces = faces
117-
self.vertex_color = vertexcolor
118-
self.edge_color = edgecolor
119-
self.face_color = facecolor
120-
self.show_mesh = show_mesh
121-
self.show_vertices = show_vertices
122-
self.show_edges = show_edges
123-
self.show_faces = show_faces
124-
12581
@property
12682
def vertexcollection(self) -> bpy.types.Collection:
12783
if not self._vertexcollection:

src/compas_blender/artists/networkartist.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,6 @@ class NetworkArtist(BlenderArtist, NetworkArtist):
2828
A COMPAS network.
2929
collection : str | :blender:`bpy.types.Collection`
3030
The name of the collection the object belongs to.
31-
nodes : list[hashable], optional
32-
A list of node identifiers.
33-
Default is None, in which case all nodes are drawn.
34-
edges : list[tuple[hashable, hashable]], optional
35-
A list of edge keys (as uv pairs) identifying which edges to draw.
36-
The default is None, in which case all edges are drawn.
37-
nodecolor : :class:`~compas.colors.Color` | dict[hashable, :class:`~compas.colors.Color`], optional
38-
The color specification for the nodes.
39-
edgecolor : :class:`~compas.colors.Color` | dict[tuple[hashable, hashable]], :class:`~compas.colors.Color`], optional
40-
The color specification for the edges.
41-
show_nodes : bool, optional
42-
If True, draw the nodes of the network.
43-
show_edges : bool, optional
44-
If True, draw the edges of the network.
4531
4632
Attributes
4733
----------
@@ -87,23 +73,10 @@ class NetworkArtist(BlenderArtist, NetworkArtist):
8773
def __init__(self,
8874
network: Network,
8975
collection: Optional[Union[str, bpy.types.Collection]] = None,
90-
nodes: Optional[List[int]] = None,
91-
edges: Optional[List[int]] = None,
92-
nodecolor: Color = None,
93-
edgecolor: Color = None,
94-
show_nodes: bool = True,
95-
show_edges: bool = True,
9676
**kwargs: Any):
9777

9878
super().__init__(network=network, collection=collection or network.name, **kwargs)
9979

100-
self.nodes = nodes
101-
self.edges = edges
102-
self.node_color = nodecolor
103-
self.edge_color = edgecolor
104-
self.show_nodes = show_nodes
105-
self.show_edges = show_edges
106-
10780
@property
10881
def nodecollection(self) -> bpy.types.Collection:
10982
if not self._nodecollection:

0 commit comments

Comments
 (0)