5
5
6
6
import numpy as np
7
7
import pyvista as pv
8
- from pyvista .plotting . plotting import Plotter
8
+ from pyvista .plotting import Plotter
9
9
import vtk
10
10
11
11
import ansys .dyna .core .pre as pre
@@ -172,7 +172,7 @@ class Graphics(object):
172
172
Whether to use the Trame visualizer. The default is ``False``.
173
173
"""
174
174
175
- def __init__ (self , model : pre .Model , use_trame : bool = False ):
175
+ def __init__ (self , model : pre .Model , use_trame : bool = False , view_position : str = "xy" ):
176
176
"""Initialize graphics."""
177
177
self ._model = model
178
178
self ._display_data = {}
@@ -199,6 +199,7 @@ def __init__(self, model: pre.Model, use_trame: bool = False):
199
199
self ._viewLeftBt : vtk .vtkButtonWidget = None
200
200
self ._sphinx_build = defaults .get_sphinx_build ()
201
201
self ._use_trame = use_trame
202
+ self ._view_position = view_position
202
203
self ._init_velocity_data = []
203
204
self ._bdy_spc = []
204
205
self ._actor_init_velocity = None
@@ -631,12 +632,17 @@ def __draw_parts(self, parts: List = [], update: bool = False, spline: bool = Fa
631
632
def _show_selector (self ):
632
633
"""Chooses between using Trame or Python visualizer."""
633
634
if self ._use_trame : # pragma: no cover
635
+ pv .set_jupyter_backend ("server" )
634
636
visualizer = TrameVisualizer ()
635
637
visualizer .set_scene (self ._plotter )
636
638
visualizer .show ()
637
639
else :
638
- self ._plotter .camera_position = "xy"
639
- self ._plotter .show ()
640
+ if self ._view_position in ["xy" , "xz" , "yx" , "yz" , "zx" , "zy" ]:
641
+ pos = self ._view_position
642
+ else :
643
+ pos = "xy"
644
+ self ._plotter .camera_position = pos
645
+ self ._plotter .show (jupyter_backend = "static" )
640
646
641
647
def __update_bt_icons (self ):
642
648
"""Update the icons on display."""
@@ -835,7 +841,7 @@ def add_to_plotter(self, plotter: Plotter):
835
841
if self ._type is DisplayMeshType .FACE :
836
842
surf = pv .PolyData (self ._vertices , self ._facet_list )
837
843
fcolor = np .array (self .get_face_color ())
838
- colors = np .tile (fcolor , (surf .n_faces , 1 ))
844
+ colors = np .tile (fcolor , (surf .n_cells , 1 ))
839
845
surf ["colors" ] = colors
840
846
surf .disp_mesh = self
841
847
self ._poly_data = surf
@@ -847,7 +853,7 @@ def add_to_plotter(self, plotter: Plotter):
847
853
elif self ._type is DisplayMeshType .BEAM :
848
854
surf = pv .PolyData (self ._vertices , lines = self ._facet_list )
849
855
fcolor = np .array (self .get_face_color ())
850
- colors = np .tile (fcolor , (surf .n_faces , 1 ))
856
+ colors = np .tile (fcolor , (surf .n_cells , 1 ))
851
857
surf ["colors" ] = colors
852
858
surf .disp_mesh = self
853
859
self ._poly_data = surf
@@ -861,7 +867,7 @@ def add_to_plotter(self, plotter: Plotter):
861
867
):
862
868
surf = self ._mesh
863
869
fcolor = np .array (self .get_face_color ())
864
- colors = np .tile (fcolor , (surf .n_faces , 1 ))
870
+ colors = np .tile (fcolor , (surf .n_cells , 1 ))
865
871
surf ["colors" ] = colors
866
872
surf .disp_mesh = self
867
873
self ._poly_data = surf
@@ -968,5 +974,5 @@ def set_color_by_type(self, type: ColorByType):
968
974
if self ._type == DisplayMeshType .FACE :
969
975
if self ._poly_data != None :
970
976
fcolor = np .array (self .get_face_color ())
971
- colors = np .tile (fcolor , (self ._poly_data .n_faces , 1 ))
977
+ colors = np .tile (fcolor , (self ._poly_data .n_cells , 1 ))
972
978
self ._poly_data ["colors" ] = colors
0 commit comments