|
1 | 1 | import pyvista as pv |
2 | | - |
3 | 2 | import sys |
4 | 3 |
|
5 | | - |
6 | | -''' |
7 | | -
|
8 | | -points = [] |
9 | | -
|
10 | | -types = [] |
11 | | -
|
12 | | -file = "pressure_buffer.txt" |
13 | | -file = "position_buffer.txt" |
14 | | -if len(sys.argv) == 2: |
15 | | - file = sys.argv[1] |
16 | | -
|
17 | | -colours = {1.1: "lightblue", 2.1: "green", 2.2: "turquoise", 3: "#eeeeee"} |
18 | | -colours = {1.1: "blue", 2.2: "turquoise"} |
19 | | -
|
20 | | -line_count = 0 |
21 | | -pcount = 0 |
22 | | -
|
23 | | -all_points = [] |
24 | | -all_point_types = [] |
25 | | -
|
26 | | -time_count = 0 |
27 | | -
|
28 | | -logStep = None |
29 | | -
|
30 | | -include_boundary = False |
31 | | -
|
32 | | -for line in open(file): |
33 | | - ws = line.split() |
34 | | - # print(ws) |
35 | | - if line_count == 6: |
36 | | - numOfElasticP = int(ws[0]) |
37 | | - if line_count == 7: |
38 | | - numOfLiquidP = int(ws[0]) |
39 | | - if line_count == 8: |
40 | | - numOfBoundaryP = int(ws[0]) |
41 | | - if line_count == 9: |
42 | | - timeStep = float(ws[0]) |
43 | | - if line_count == 10: |
44 | | - logStep = int(ws[0]) |
45 | | -
|
46 | | - if len(ws) == 4: |
47 | | - type = float(ws[3]) |
48 | | -
|
49 | | - if not (type == 3 and not include_boundary): |
50 | | - points.append([float(ws[0]), float(ws[1]), float(ws[2])]) |
51 | | - types.append(type) |
52 | | -
|
53 | | - if logStep is not None: |
54 | | - pcount += 1 |
55 | | -
|
56 | | - if pcount == numOfBoundaryP + numOfElasticP + numOfLiquidP: |
57 | | - print( |
58 | | - "End of one batch of %i added, %i total points at line %i, time: %i" |
59 | | - % (len(points), pcount, line_count, time_count) |
60 | | - ) |
61 | | - all_points.append(points) |
62 | | - all_point_types.append(types) |
63 | | -
|
64 | | - points = [] |
65 | | - types = [] |
66 | | - pcount = 0 |
67 | | - numOfBoundaryP = 0 |
68 | | -
|
69 | | - time_count += 1 |
70 | | -
|
71 | | - line_count += 1 |
72 | | -
|
73 | | -# all_points_np = np.array(all_points) |
74 | | -
|
75 | | -print( |
76 | | - "Loaded positions with %i elastic, %i liquid and %i boundary points (%i total), %i lines" |
77 | | - % ( |
78 | | - numOfElasticP, |
79 | | - numOfLiquidP, |
80 | | - numOfBoundaryP, |
81 | | - numOfElasticP + numOfLiquidP + numOfBoundaryP, |
82 | | - line_count, |
83 | | - ) |
84 | | -) |
85 | | -
|
86 | | -print("Num of time points found: %i" % len(all_points)) |
87 | | -
|
88 | | -pl.set_background("lightgrey") |
89 | | -
|
90 | | -last_mesh = None |
91 | | -
|
92 | | -
|
93 | | -import time |
94 | | -
|
95 | | -def create_mesh(step): |
96 | | - step_count = step |
97 | | - value = step_count |
98 | | - global last_mesh |
99 | | - index = int(value) |
100 | | -
|
101 | | - print("Changing to time point: %s (%s) " % (index, value)) |
102 | | - curr_points = all_points[index] |
103 | | - curr_types = all_point_types[index] |
104 | | - if last_mesh is None: |
105 | | - last_mesh = pv.PolyData(curr_points) |
106 | | - last_mesh["types"] = curr_types |
107 | | - last_mesh.translate((0, -1000, 0), inplace=True) |
108 | | - print(last_mesh) |
109 | | -
|
110 | | - # last_actor = |
111 | | - pl.add_mesh( |
112 | | - last_mesh, |
113 | | - render_points_as_spheres=True, |
114 | | - cmap=[c for c in colours.values()], |
115 | | - point_size=3, |
116 | | - ) |
117 | | - else: |
118 | | - last_mesh.points = curr_points |
119 | | - last_mesh.translate((0, -00, -100), inplace=True) |
120 | | -
|
121 | | - pl.render() |
122 | | -
|
123 | | - time.sleep(0.1) |
124 | | -
|
125 | | - return |
126 | | -
|
127 | | -
|
128 | | -create_mesh(0) |
129 | | -
|
130 | | -max_time = len(all_points) - 1 |
131 | | -pl.add_slider_widget(create_mesh, rng=[0, max_time], value=max_time, title="Time point") |
132 | | -pl.add_timer_event(max_steps=5, duration=2, callback=create_mesh) |
133 | | -
|
134 | | -
|
135 | | -mesh = pv.read("bwm.obj") |
136 | | -mesh.scale(20, inplace=True) |
137 | | -mesh.translate((-40, 0, 0), inplace=True) |
138 | | -
|
139 | | -pl.add_mesh(mesh, smooth_shading=True, color="green") |
140 | | -
|
141 | | -mesh2 = pv.read("neurons.obj") |
142 | | -mesh2.scale(20, inplace=True) |
143 | | -mesh2.translate((-80, 0, 0), inplace=True) |
144 | | -
|
145 | | -pl.add_mesh(mesh2, smooth_shading=True, color="orange") |
146 | | -""" |
147 | | -conn = mesh2.connectivity('all') |
148 | | -print(conn) |
149 | | -# Format scalar bar text for integer values. |
150 | | -scalar_bar_args = dict( |
151 | | - fmt='%.f', |
152 | | -) |
153 | | -
|
154 | | -cpos = [(10.5, 12.2, 18.3), (0.0, 0.0, 0.0), (0.0, 1.0, 0.0)] |
155 | | -
|
156 | | -conn.plot( |
157 | | - categories=True, |
158 | | - cmap='jet', |
159 | | - scalar_bar_args=scalar_bar_args, |
160 | | - cpos=cpos, |
161 | | -)""" |
162 | | -
|
163 | | -''' |
164 | | - |
| 4 | +from virtualworm import add_virtualworm_muscles |
| 5 | +from virtualworm import add_virtualworm_neurons |
| 6 | +from neuromlmodel import add_neuroml_model |
| 7 | +from siberneticmodel import add_sibernetic_model |
165 | 8 |
|
166 | 9 | if __name__ == "__main__": |
167 | | - pl = pv.Plotter() |
| 10 | + plotter = pv.Plotter() |
168 | 11 |
|
169 | | - from virtualworm import add_virtualworm_muscles |
170 | | - from neuromlmodel import add_neuroml_model |
171 | | - from siberneticmodel import add_sibernetic_model |
| 12 | + add_virtualworm_muscles(plotter) |
| 13 | + add_virtualworm_neurons(plotter) |
| 14 | + add_neuroml_model(plotter, "NeuroML2/c302_D_Full.net.nml", somas_only=False) |
| 15 | + add_sibernetic_model(plotter) |
172 | 16 |
|
173 | | - add_virtualworm_muscles(pl) |
174 | | - add_neuroml_model(pl, somas_only=True) |
175 | | - add_sibernetic_model(pl) |
| 17 | + plotter.set_background("white") |
| 18 | + plotter.set_viewup([0, 10, 0]) |
176 | 19 |
|
177 | | - pl.set_background("white") |
178 | | - pl.add_axes() |
| 20 | + plotter.add_axes() |
| 21 | + plotter.remove_scalar_bar("RegionId") |
| 22 | + plotter.remove_scalar_bar("types") |
179 | 23 |
|
180 | 24 | if "-nogui" not in sys.argv: |
181 | | - pl.show() |
| 25 | + plotter.show() |
0 commit comments