Skip to content

Commit 2c651d3

Browse files
committed
clean warning of drawing model
1 parent 3a1ea53 commit 2c651d3

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ classifiers = [
2828
dependencies = ["ansys-dpf-core>=0.7.2",
2929
"ansys-api-dyna==0.3.6",
3030
"ansys-platform-instancemanagement~=1.0",
31-
"pyvista[jupyter]==0.42.3",
31+
"pyvista==0.43.4",
3232
]
3333

3434
[project.optional-dependencies]

src/ansys/dyna/core/pre/graphics/graphics.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class Graphics(object):
172172
Whether to use the Trame visualizer. The default is ``False``.
173173
"""
174174

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"):
176176
"""Initialize graphics."""
177177
self._model = model
178178
self._display_data = {}
@@ -199,6 +199,7 @@ def __init__(self, model: pre.Model, use_trame: bool = False):
199199
self._viewLeftBt: vtk.vtkButtonWidget = None
200200
self._sphinx_build = defaults.get_sphinx_build()
201201
self._use_trame = use_trame
202+
self._view_position = view_position
202203
self._init_velocity_data = []
203204
self._bdy_spc = []
204205
self._actor_init_velocity = None
@@ -636,7 +637,11 @@ def _show_selector(self):
636637
visualizer.set_scene(self._plotter)
637638
visualizer.show()
638639
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
640645
self._plotter.show(jupyter_backend="static")
641646

642647
def __update_bt_icons(self):
@@ -836,7 +841,7 @@ def add_to_plotter(self, plotter: Plotter):
836841
if self._type is DisplayMeshType.FACE:
837842
surf = pv.PolyData(self._vertices, self._facet_list)
838843
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))
840845
surf["colors"] = colors
841846
surf.disp_mesh = self
842847
self._poly_data = surf
@@ -848,7 +853,7 @@ def add_to_plotter(self, plotter: Plotter):
848853
elif self._type is DisplayMeshType.BEAM:
849854
surf = pv.PolyData(self._vertices, lines=self._facet_list)
850855
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))
852857
surf["colors"] = colors
853858
surf.disp_mesh = self
854859
self._poly_data = surf
@@ -862,7 +867,7 @@ def add_to_plotter(self, plotter: Plotter):
862867
):
863868
surf = self._mesh
864869
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))
866871
surf["colors"] = colors
867872
surf.disp_mesh = self
868873
self._poly_data = surf
@@ -969,5 +974,5 @@ def set_color_by_type(self, type: ColorByType):
969974
if self._type == DisplayMeshType.FACE:
970975
if self._poly_data != None:
971976
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))
973978
self._poly_data["colors"] = colors

0 commit comments

Comments
 (0)