Skip to content

Commit 962842b

Browse files
committed
Merge branch 'master' of https://github.com/compas-dev/compas
2 parents ce28416 + ac0dcc3 commit 962842b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2755
-2492
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ temp/**
119119
src/.build/**
120120

121121
data/bunny
122+
data/models
123+
data/ctralie
122124
*.ply
123125
*.tar.gz
124126

src/compas_blender/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@
33
compas_blender
44
********************************************************************************
55
6-
.. currentmodule:: compas_blender
6+
.. module:: compas_blender
77
88
.. toctree::
99
:maxdepth: 1
1010
1111
compas_blender.artists
12+
compas_blender.conduits
1213
compas_blender.forms
1314
compas_blender.geometry
1415
compas_blender.helpers
16+
compas_blender.inspectors
17+
compas_blender.modifiers
18+
compas_blender.selectors
1519
compas_blender.ui
1620
compas_blender.utilities
1721
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
12
"""
23
********************************************************************************
34
compas_blender.artists
45
********************************************************************************
56
67
.. currentmodule:: compas_blender.artists
78
8-
99
Artists for visualising (painting) COMPAS data structures in Blender.
1010
1111
@@ -17,14 +17,15 @@
1717
VolMeshArtist
1818
1919
"""
20-
from __future__ import absolute_import
2120

21+
from .artist import *
2222
from .meshartist import *
2323
from .networkartist import *
2424
from .volmeshartist import *
2525

26-
from . import meshartist
27-
from . import networkartist
28-
from . import volmeshartist
26+
from .artist import __all__ as a
27+
from .meshartist import __all__ as b
28+
from .networkartist import __all__ as c
29+
from .volmeshartist import __all__ as d
2930

30-
__all__ = meshartist.__all__ + networkartist.__all__ + volmeshartist.__all__
31+
__all__ = a + b + c + d
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
2+
from __future__ import absolute_import
3+
from __future__ import division
4+
from __future__ import print_function
5+
6+
try:
7+
import bpy
8+
except ImportError:
9+
pass
10+
11+
12+
__all__ = [
13+
'Artist',
14+
]
15+
16+
17+
class Artist(object):
18+
19+
__module__ = "compas_blender.artists"
20+
21+
def __init__(self, layer=None):
22+
23+
self.layer = layer
24+
self.defaults = {
25+
'color.point': [255, 255, 255],
26+
'color.line': [0, 0, 0],
27+
'color.polygon': [210, 210, 210],
28+
}
29+
self.vertex_objects = []
30+
self.edge_objects = []
31+
self.face_objects = []
32+
33+
34+
def redraw(self, timeout=None):
35+
36+
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
37+
38+
39+
def clear_layer(self):
40+
41+
raise NotImplementedError
42+
43+
44+
def save(self, path, width=1920, height=1080, scale=1,
45+
draw_grid=False, draw_world_axes=False, draw_cplane_axes=False, background=False):
46+
47+
raise NotImplementedError
48+
49+
50+
def draw_points(self, points, layer=None, clear_layer=False, redraw=False):
51+
52+
raise NotImplementedError
53+
54+
55+
def draw_lines(self, lines, layer=None, clear_layer=False, redraw=False):
56+
57+
raise NotImplementedError
58+
59+
60+
def draw_polygons(self, polygons, layer=None, clear_layer=False, redraw=False):
61+
62+
raise NotImplementedError
63+
64+
65+
# ==============================================================================
66+
# Main
67+
# ==============================================================================
68+
69+
if __name__ == "__main__":
70+
71+
pass
Lines changed: 83 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,83 @@
1-
import time
2-
3-
try:
4-
import bpy
5-
except ImportError:
6-
pass
7-
8-
from compas_blender.utilities import clear_layer
9-
from compas_blender.artists.mixins import VertexArtist
10-
from compas_blender.artists.mixins import EdgeArtist
11-
from compas_blender.artists.mixins import FaceArtist
12-
13-
14-
__author__ = ['Andrew Liew <[email protected]>']
15-
__copyright__ = 'Copyright 2017, Block Research Group - ETH Zurich'
16-
__license__ = 'MIT License'
17-
__email__ = '[email protected]'
18-
19-
20-
__all__ = ['MeshArtist']
21-
22-
23-
class MeshArtist(FaceArtist, EdgeArtist, VertexArtist):
24-
""""""
25-
26-
def __init__(self, mesh, layer=0):
27-
self.datastructure = mesh
28-
self.layer = layer
29-
self.defaults = {
30-
'color.vertex': [1, 0, 0],
31-
'color.face': [1, 1, 1],
32-
'color.edge': [0, 0, 1]}
33-
34-
def redraw(self, timeout=None):
35-
"""Redraw the Blender view."""
36-
if timeout:
37-
time.sleep(timeout)
38-
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
39-
40-
def clear_layer(self):
41-
clear_layer(layer=self.layer)
42-
43-
def clear(self):
44-
self.clear_vertices()
45-
self.clear_faces()
46-
self.clear_edges()
47-
48-
49-
# ==============================================================================
50-
# Main
51-
# ==============================================================================
52-
53-
if __name__ == "__main__":
54-
55-
from compas_blender.utilities import get_objects
56-
57-
from compas_blender.helpers import mesh_from_bmesh
58-
59-
mesh = mesh_from_bmesh(bmesh=get_objects(layer=0)[0])
60-
61-
meshartist = MeshArtist(mesh=mesh, layer=1)
62-
63-
meshartist.clear_layer()
64-
65-
meshartist.draw_vertices()
66-
meshartist.draw_vertexlabels()
67-
meshartist.clear_vertices(keys=[4])
68-
meshartist.clear_vertexlabels(keys=[6])
69-
70-
meshartist.draw_edges()
71-
meshartist.draw_edgelabels()
72-
meshartist.clear_edges(keys=[(0, 4)])
73-
meshartist.clear_edgelabels(keys=[(5, 4)])
74-
75-
meshartist.draw_faces()
76-
meshartist.draw_facelabels()
77-
meshartist.clear_faces(keys=[2, 3])
78-
meshartist.clear_facelabels(keys=[5])
1+
2+
from __future__ import absolute_import
3+
from __future__ import division
4+
from __future__ import print_function
5+
6+
from compas_blender.artists import Artist
7+
from compas_blender.artists.mixins import VertexArtist
8+
from compas_blender.artists.mixins import EdgeArtist
9+
from compas_blender.artists.mixins import FaceArtist
10+
11+
12+
__all__ = [
13+
'MeshArtist',
14+
]
15+
16+
17+
class MeshArtist(FaceArtist, EdgeArtist, VertexArtist, Artist):
18+
19+
__module__ = "compas_blender.artists"
20+
21+
def __init__(self, mesh, layer=None):
22+
super(MeshArtist, self).__init__(layer=layer)
23+
24+
self.mesh = mesh
25+
self.defaults.update({
26+
'color.vertex': [255, 255, 255],
27+
'color.edge': [0, 0, 0],
28+
'color.face': [110, 110, 110],
29+
})
30+
31+
32+
@property
33+
def mesh(self):
34+
35+
return self.datastructure
36+
37+
38+
@mesh.setter
39+
def mesh(self, mesh):
40+
41+
self.datastructure = mesh
42+
43+
44+
def draw(self):
45+
46+
raise NotImplementedError
47+
48+
49+
def clear(self):
50+
51+
self.clear_vertices()
52+
self.clear_faces()
53+
self.clear_edges()
54+
55+
56+
# ==============================================================================
57+
# Main
58+
# ==============================================================================
59+
60+
if __name__ == "__main__":
61+
62+
import compas
63+
64+
from compas.datastructures import Mesh
65+
66+
67+
mesh = Mesh.from_obj(compas.get('quadmesh.obj'))
68+
69+
artist = MeshArtist(mesh)
70+
71+
# artist.clear()
72+
73+
artist.draw_vertices(radius=0.01)
74+
artist.draw_vertexlabels()
75+
# artist.clear_vertexlabels()
76+
77+
# artist.draw_edges(width=0.01)
78+
# artist.draw_edgelabels()
79+
# artist.clear_edgelabels()
80+
81+
# artist.draw_faces()
82+
# artist.draw_facelabels()
83+
# artist.clear_facelabels()
Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
from .vertexartist import *
2-
from .edgeartist import *
3-
from .faceartist import *
4-
from .pathartist import *
5-
6-
from .vertexartist import __all__ as a
7-
from .edgeartist import __all__ as b
8-
from .faceartist import __all__ as c
9-
from .pathartist import __all__ as d
10-
11-
__all__ = a + b + d
1+
2+
from .vertexartist import *
3+
from .edgeartist import *
4+
from .faceartist import *
5+
6+
from .vertexartist import __all__ as a
7+
from .edgeartist import __all__ as b
8+
from .faceartist import __all__ as c
9+
10+
__all__ = a + b + c

0 commit comments

Comments
 (0)