@@ -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
@@ -636,7 +637,11 @@ def _show_selector(self):
636
637
visualizer .set_scene (self ._plotter )
637
638
visualizer .show ()
638
639
else :
639
- self ._plotter .camera_position = "xy"
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
640
645
self ._plotter .show (jupyter_backend = "static" )
641
646
642
647
def __update_bt_icons (self ):
@@ -836,7 +841,7 @@ def add_to_plotter(self, plotter: Plotter):
836
841
if self ._type is DisplayMeshType .FACE :
837
842
surf = pv .PolyData (self ._vertices , self ._facet_list )
838
843
fcolor = np .array (self .get_face_color ())
839
- colors = np .tile (fcolor , (surf .n_faces , 1 ))
844
+ colors = np .tile (fcolor , (surf .n_cells , 1 ))
840
845
surf ["colors" ] = colors
841
846
surf .disp_mesh = self
842
847
self ._poly_data = surf
@@ -848,7 +853,7 @@ def add_to_plotter(self, plotter: Plotter):
848
853
elif self ._type is DisplayMeshType .BEAM :
849
854
surf = pv .PolyData (self ._vertices , lines = self ._facet_list )
850
855
fcolor = np .array (self .get_face_color ())
851
- colors = np .tile (fcolor , (surf .n_faces , 1 ))
856
+ colors = np .tile (fcolor , (surf .n_cells , 1 ))
852
857
surf ["colors" ] = colors
853
858
surf .disp_mesh = self
854
859
self ._poly_data = surf
@@ -862,7 +867,7 @@ def add_to_plotter(self, plotter: Plotter):
862
867
):
863
868
surf = self ._mesh
864
869
fcolor = np .array (self .get_face_color ())
865
- colors = np .tile (fcolor , (surf .n_faces , 1 ))
870
+ colors = np .tile (fcolor , (surf .n_cells , 1 ))
866
871
surf ["colors" ] = colors
867
872
surf .disp_mesh = self
868
873
self ._poly_data = surf
@@ -969,5 +974,5 @@ def set_color_by_type(self, type: ColorByType):
969
974
if self ._type == DisplayMeshType .FACE :
970
975
if self ._poly_data != None :
971
976
fcolor = np .array (self .get_face_color ())
972
- colors = np .tile (fcolor , (self ._poly_data .n_faces , 1 ))
977
+ colors = np .tile (fcolor , (self ._poly_data .n_cells , 1 ))
973
978
self ._poly_data ["colors" ] = colors
0 commit comments