|
1 | 1 | # type: ignore |
2 | 2 |
|
3 | | -# import compas |
4 | | -from compas.datastructures import Mesh |
5 | | -from compas_view2.app import App |
6 | | -from compas.colors import Color |
7 | | -from compas.geometry import Circle |
8 | | -from compas_view2.objects import Text |
9 | | - |
10 | | -# mesh = Mesh.from_obj(compas.get("tubemesh.obj")) |
11 | | - |
12 | | -# viewer = App(width=1600, height=900) |
13 | | -# viewer.add(mesh) |
14 | | -# viewer.view.camera.position = [1, -6, 1.5] |
15 | | -# viewer.view.camera.look_at([1, 0, 1]) |
16 | | -# viewer.run() |
17 | | - |
18 | | -# mesh = Mesh.from_meshgrid(dx=9, nx=9) |
19 | | - |
20 | | -# viewer = App(viewport="top", width=1600, height=900) |
21 | | - |
22 | | -# viewer.add(mesh) |
23 | | -# for vertex in range(30, 40): |
24 | | -# color = (1.0, 0.0, 0.0) if mesh.is_vertex_on_boundary(vertex) else (0.0, 0.0, 0.0) |
25 | | -# viewer.add(mesh.vertex_point(vertex), pointsize=20, pointcolor=color) |
26 | | - |
27 | | -# viewer.view.camera.zoom_extents() |
28 | | -# viewer.view.camera.distance = 11 |
29 | | -# viewer.run() |
30 | | - |
31 | | -# mesh = Mesh.from_meshgrid(dx=9, nx=9) |
32 | | - |
33 | | -# viewer = App(viewport="top", width=1600, height=900) |
34 | | - |
35 | | -# red = Color.red() |
36 | | - |
37 | | -# viewer.add(mesh, facecolor=(0.95, 0.95, 0.95), linewidth=2) |
38 | | -# viewer.add( |
39 | | -# Circle.from_point_and_radius(mesh.vertex_point(23) + [0, 0, 0.1], 0.1).to_polygon(100), |
40 | | -# facecolor=(1.0, 1.0, 1.0), |
41 | | -# linecolor=(0.0, 0.0, 0.0), |
42 | | -# linewidth=2, |
43 | | -# ) |
44 | | - |
45 | | -# for i, nbr in enumerate(mesh.vertex_neighbors(23, True)): |
46 | | -# print(nbr) |
47 | | -# viewer.add( |
48 | | -# Circle.from_point_and_radius(mesh.vertex_point(nbr) + [0, 0, 0.1], 0.2).to_polygon(100), |
49 | | -# facecolor=red.lightened(50), |
50 | | -# linecolor=red, |
51 | | -# ) |
52 | | -# viewer.add( |
53 | | -# Text( |
54 | | -# str(i), |
55 | | -# mesh.vertex_point(nbr) + [0.09, -0.075, 0.1], |
56 | | -# height=50, |
57 | | -# ) |
58 | | -# ) |
59 | | - |
60 | | -# viewer.view.camera.zoom_extents() |
61 | | -# viewer.view.camera.distance = 11 |
62 | | -# viewer.run() |
| 3 | +from compas_viewer import Viewer |
63 | 4 |
|
64 | | -# mesh = Mesh.from_meshgrid(dx=9, nx=9) |
65 | | - |
66 | | -# viewer = App(viewport="top", width=1600, height=900) |
67 | | - |
68 | | -# red = Color.red() |
69 | | - |
70 | | -# viewer.add( |
71 | | -# Circle.from_point_and_radius(mesh.vertex_point(23) + [0, 0, 0.1], 0.1).to_polygon(100), |
72 | | -# facecolor=(1.0, 1.0, 1.0), |
73 | | -# linecolor=(0.0, 0.0, 0.0), |
74 | | -# linewidth=2, |
75 | | -# ) |
76 | | - |
77 | | -# facecolors = {face: (0.95, 0.95, 0.95) for face in mesh.faces()} |
78 | | -# for i, face in enumerate(mesh.vertex_faces(23)): |
79 | | -# print(face) |
80 | | -# viewer.add( |
81 | | -# Text( |
82 | | -# str(i), |
83 | | -# mesh.face_centroid(face) + [0.09, -0.075, 0.1], |
84 | | -# height=50, |
85 | | -# ) |
86 | | -# ) |
87 | | -# facecolors[face] = red.lightened(50) |
88 | | - |
89 | | -# viewer.add(mesh, facecolor=facecolors, linewidth=2) |
90 | | - |
91 | | -# viewer.view.camera.zoom_extents() |
92 | | -# viewer.view.camera.distance = 11 |
93 | | -# viewer.run() |
94 | | - |
95 | | -# mesh = Mesh.from_meshgrid(dx=9, nx=9) |
96 | | - |
97 | | -# viewer = App(viewport="top", width=1600, height=900) |
98 | | - |
99 | | -# red = Color.red() |
100 | | - |
101 | | -# viewer.add(mesh, facecolor=(0.95, 0.95, 0.95), linewidth=2) |
102 | | -# viewer.add(mesh.edge_line((20, 30)).translated([0, 0, 0.1]), linecolor=red, linewidth=10) |
103 | | - |
104 | | -# for edge in mesh.edge_strip((20, 30)): |
105 | | -# viewer.add(mesh.edge_line(edge).translated([0, 0, 0.1]), linewidth=10) |
106 | | - |
107 | | -# viewer.view.camera.zoom_extents() |
108 | | -# viewer.view.camera.distance = 11 |
109 | | -# viewer.run() |
| 5 | +from compas.colors import Color |
| 6 | +from compas.datastructures import Mesh |
110 | 7 |
|
111 | 8 | mesh = Mesh.from_meshgrid(dx=9, nx=9) |
112 | 9 |
|
113 | | -viewer = App(viewport="top", width=1600, height=900) |
| 10 | +viewer = Viewer(viewmode="top", width=1600, height=900) |
114 | 11 |
|
115 | 12 | red = Color.red() |
116 | 13 |
|
117 | | -viewer.add(mesh, facecolor=(0.95, 0.95, 0.95), linewidth=2) |
118 | | -viewer.add(mesh.edge_line((30, 31)).translated([0, 0, 0.1]), linecolor=red, linewidth=10) |
| 14 | +viewer.scene.add(mesh, facecolor=(0.95, 0.95, 0.95), lineswidth=2) |
| 15 | +viewer.scene.add(mesh.edge_line((30, 31)).translated([0, 0, 0.1]), linecolor=red, lineswidth=10) |
119 | 16 |
|
120 | 17 | for edge in mesh.edge_loop((30, 31)): |
121 | | - viewer.add(mesh.edge_line(edge).translated([0, 0, 0.1]), linewidth=10) |
| 18 | + viewer.scene.add(mesh.edge_line(edge).translated([0, 0, 0.1]), lineswidth=10) |
122 | 19 |
|
123 | | -viewer.view.camera.zoom_extents() |
124 | | -viewer.view.camera.distance = 11 |
125 | | -viewer.run() |
| 20 | +viewer.show() |
0 commit comments