Skip to content

Commit 5b19781

Browse files
committed
fix: solve some visualization errors + homogenize parameters offscreen-->off_screen
1 parent f0f9b02 commit 5b19781

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

wakis/gridFIT3D.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,8 @@ def _assign_colors(self):
583583
for key in self.stl_solids:
584584
mat = self.stl_materials[key]
585585
if type(mat) is str:
586-
self.stl_colors[key] = mat
586+
_color = material_colors.get(mat, material_colors['other'])
587+
self.stl_colors[key] = _color
587588
elif len(mat) == 2:
588589
if mat[0] is np.inf: #eps_r
589590
self.stl_colors[key] = material_colors['pec']
@@ -615,7 +616,7 @@ def _add_logo_widget(self, pl):
615616

616617
def plot_solids(self, bounding_box=False, show_grid=False, anti_aliasing=None,
617618
opacity=1.0, specular=0.5, smooth_shading=False,
618-
offscreen=False, **kwargs):
619+
off_screen=False, **kwargs):
619620
"""
620621
Generates a 3D visualization of the imported STL geometries using PyVista.
621622
@@ -678,15 +679,15 @@ def plot_solids(self, bounding_box=False, show_grid=False, anti_aliasing=None,
678679
if show_grid:
679680
pl.add_mesh(self.grid, style='wireframe', color='grey', opacity=0.3, name='grid')
680681

681-
if offscreen:
682+
if off_screen:
682683
pl.export_html('grid_plot_solids.html')
683684
else:
684685
pl.show()
685686

686687
def plot_stl_mask(self, stl_solid, cmap='viridis', bounding_box=True, show_grid=True,
687688
add_stl='all', stl_opacity=0., stl_colors=None,
688689
xmax=None, ymax=None, zmax=None,
689-
anti_aliasing='ssaa', smooth_shading=False, offscreen=False):
690+
anti_aliasing='ssaa', smooth_shading=False, off_screen=False):
690691

691692
"""
692693
Interactive 3D visualization of the structured grid mask and imported STL geometries.
@@ -728,8 +729,8 @@ def plot_stl_mask(self, stl_solid, cmap='viridis', bounding_box=True, show_grid=
728729
maximum domain extent.
729730
anti_aliasing : {'ssaa', 'fxaa', None}, default 'ssaa'
730731
Anti-aliasing mode passed to `pl.enable_anti_aliasing`.
731-
offscreen : bool, default False
732-
If True, render offscreen and export the scene to
732+
off_screen : bool, default False
733+
If True, render off-screen and export the scene to
733734
``grid_stl_mask_<stl_solid>.html``. If False, open an interactive window.
734735
735736
Notes
@@ -848,13 +849,13 @@ def update_clip(val, axis="x"):
848849
pl.add_mesh(pv.Box(bounds=(self.xmin, self.xmax, self.ymin, self.ymax, self.zmin, self.zmax)),
849850
style="wireframe", color="black", line_width=2, name="domain_box")
850851

851-
if offscreen:
852+
if off_screen:
852853
pl.export_html(f'grid_stl_mask_{stl_solid}.html')
853854
else:
854855
pl.show()
855856

856857
def inspect(self, add_stl=None, stl_opacity=0.5, stl_colors=None,
857-
anti_aliasing='ssaa', smooth_shading=True, offscreen=False):
858+
anti_aliasing='ssaa', smooth_shading=True, off_screen=False):
858859

859860
'''3D plot using pyvista to visualize
860861
the structured grid and
@@ -927,7 +928,7 @@ def clip(widget):
927928
pl.enable_3_lights()
928929
pl.enable_anti_aliasing(anti_aliasing)
929930

930-
if offscreen:
931+
if off_screen:
931932
pl.export_html('grid_inspect.html')
932933
else:
933934
pl.show()

wakis/plotting.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ def inspect(self, wake=None, window_size=None, off_screen=False,
826826
print('[!] plot3D is not supported when `use_mpi=True`')
827827
return
828828
if wake is not None:
829-
self.solver.wake = wake
829+
self.wake = wake
830830

831831
# Initialize plotter
832832
pl = pv.Plotter(window_size=window_size)
@@ -905,7 +905,7 @@ def master_cb(v):
905905
for i, name in enumerate(solid_state):
906906
y = cy - (i + 2) * dy
907907
_color_on = self.stl_colors.get(name, color_on)
908-
if _color_on == 'white' or _color_on == [1.0, 1.0, 1.0]:
908+
if str(_color_on) == 'white' or list(_color_on) == [1.0, 1.0, 1.0]:
909909
_color_on = 'gray'
910910
btn = pl.add_checkbox_button_widget(make_cb(name), value=False,
911911
color_on=_color_on,
@@ -926,9 +926,9 @@ def master_cb(v):
926926
direction=(0, 0, 1), height=z_height, radius=radius)
927927

928928
beam_actor = pl.add_mesh(beam, color="orange", name="beam", opacity=1.0)
929-
beam_actor.SetVisibility(False)
929+
beam_actor.SetVisibility(True)
930930
path_actor = pl.add_mesh(path, color="blue", name="integration_path", opacity=1.0)
931-
path_actor.SetVisibility(False)
931+
path_actor.SetVisibility(True)
932932

933933
bx = int(w - box - 200 * ui)
934934
to = box + pad
@@ -938,12 +938,12 @@ def beam_cb(v):
938938
def path_cb(v):
939939
path_actor.SetVisibility(bool(v))
940940

941-
pl.add_checkbox_button_widget(path_cb, value=False,
941+
pl.add_checkbox_button_widget(path_cb, value=True,
942942
color_off=color_off, color_on="blue",
943943
position=(bx, cy + dy), size=box)
944944
pl.add_text("Integration path", position=(bx + to, cy + dy), font_size=font)
945945

946-
pl.add_checkbox_button_widget(beam_cb, value=False,
946+
pl.add_checkbox_button_widget(beam_cb, value=True,
947947
color_off=color_off, color_on="orange",
948948
position=(bx, cy), size=box)
949949
pl.add_text("Beam", position=(bx + to, cy), font_size=font)

0 commit comments

Comments
 (0)