Skip to content

Commit 0b8d693

Browse files
committed
Improve offset handling
1 parent a20b1ea commit 0b8d693

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

SiberneticReplay.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626
plotter = None
27-
offset_ = 0
27+
offset3d_ = (0, 0, 0)
2828
slider = None
2929

3030
show_boundary = False
@@ -59,12 +59,19 @@ def add_sibernetic_model(
5959
position_file="Sibernetic/position_buffer.txt",
6060
report_file=None,
6161
swap_y_z=False,
62-
offset=0,
62+
offset3d=(0, 0, 0),
6363
include_boundary=False,
6464
):
65-
global all_points, all_point_types, last_meshes, plotter, offset_, slider, show_boundary
66-
67-
offset_ = offset
65+
global \
66+
all_points, \
67+
all_point_types, \
68+
last_meshes, \
69+
plotter, \
70+
offset3d_, \
71+
slider, \
72+
show_boundary
73+
74+
offset3d_ = offset3d
6875
plotter = pl
6976
show_boundary = include_boundary
7077

@@ -226,7 +233,7 @@ def play_animation(play):
226233
def create_mesh(step):
227234
step_count = step
228235
value = step_count
229-
global all_points, last_meshes, plotter, offset_, replaying, show_boundary
236+
global all_points, last_meshes, plotter, offset3d_, replaying, show_boundary
230237

231238
index = int(value)
232239
if index >= len(all_points):
@@ -257,7 +264,7 @@ def create_mesh(step):
257264
continue
258265
if type_ not in last_meshes:
259266
last_meshes[type_] = pv.PolyData(curr_points)
260-
last_meshes[type_].translate((0, 0, 0), inplace=True)
267+
last_meshes[type_].translate(offset3d_, inplace=True)
261268

262269
# last_actor =
263270
plotter.add_mesh(
@@ -269,7 +276,9 @@ def create_mesh(step):
269276
else:
270277
if not is_boundary:
271278
last_meshes[type_].points = curr_points
272-
last_meshes[type_].translate((offset_, 0, 0), inplace=True)
279+
last_meshes[type_].translate(
280+
(offset3d_[0], offset3d_[1], offset3d_[2]), inplace=True
281+
)
273282
else:
274283
print("Boundary points not translated")
275284

load.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
spacing = 50
1313

14-
add_sibernetic_model(plotter, swap_y_z=True, offset=spacing)
14+
add_sibernetic_model(plotter, swap_y_z=True, offset3d=(spacing, -50, -100))
1515
add_neuroml_model(
1616
plotter, "NeuroML2/c302_D_Full.net.nml", somas_only=False
1717
) # at 0...

0 commit comments

Comments
 (0)