Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e9b047a
fix(plotting): Test plotting changes
AlejandroFernandezLuces Jan 24, 2025
4ab8104
chore: adding changelog file 3702.fixed.md [dependabot-skip]
pyansys-ci-bot Jan 24, 2025
3ee7447
fix(plotting): Small bug
AlejandroFernandezLuces Jan 24, 2025
89ad28b
Merge branch 'fix/plotter-issues' of https://github.com/pyansys/pymap…
AlejandroFernandezLuces Jan 24, 2025
eaf9101
fix: Bug caused tests failure
AlejandroFernandezLuces Jan 24, 2025
34459bf
Merge branch 'main' into fix/plotter-issues
AlejandroFernandezLuces Jan 24, 2025
5c52f92
fix: Add warning
AlejandroFernandezLuces Jan 27, 2025
2503336
Merge branch 'fix/plotter-issues' of https://github.com/pyansys/pymap…
AlejandroFernandezLuces Jan 27, 2025
4753b7a
Merge branch 'main' into fix/plotter-issues
AlejandroFernandezLuces Jan 27, 2025
cbe4330
chore: adding changelog file 3702.fixed.md [dependabot-skip]
pyansys-ci-bot Jan 27, 2025
dd79733
Merge branch 'main' into fix/plotter-issues
clatapie Jan 29, 2025
867794d
Merge branch 'main' into fix/plotter-issues
clatapie Feb 13, 2025
3139191
Merge branch 'main' into fix/plotter-issues
germa89 Feb 17, 2025
7b0084a
Merge branch 'main' into fix/plotter-issues
germa89 Feb 26, 2025
64207f2
Merge branch 'main' into fix/plotter-issues
germa89 Mar 7, 2025
04315ab
Merge branch 'main' into fix/plotter-issues
clatapie Mar 13, 2025
1e828f5
Merge branch 'main' into fix/plotter-issues
AlejandroFernandezLuces Mar 14, 2025
f40f571
test: Add mesh testing
AlejandroFernandezLuces Mar 14, 2025
9065839
test: Add docstring to test
AlejandroFernandezLuces Mar 14, 2025
eb48840
fix: PyVista lazy import
AlejandroFernandezLuces Mar 14, 2025
6718ab3
Merge branch 'main' into fix/plotter-issues
AlejandroFernandezLuces Mar 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.d/3702.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix(plotting): Test plotting changes
65 changes: 40 additions & 25 deletions src/ansys/mapdl/core/plotting/visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

"""Module for the MapdlPlotter class."""
from collections import OrderedDict
from typing import Any, Iterable, Optional, Union
from typing import Any, Dict, Iterable, Optional, Union

from ansys.tools.visualization_interface import Plotter
from ansys.tools.visualization_interface.backends.pyvista import PyVistaBackendInterface
Expand Down Expand Up @@ -280,9 +280,9 @@

def add_mesh(
self,
meshes,
points,
labels,
meshes: Union[pv.PolyData, Dict[str, Any]] = [],
points=[],
labels=[],
*,
cpos=None,
show_bounds=False,
Expand Down Expand Up @@ -331,6 +331,9 @@
plotter_kwargs : dict, optional
Extra kwargs, by default {}
"""
if not meshes and not points and not labels:
return

if theme is None:
theme = MapdlTheme()

Expand Down Expand Up @@ -378,31 +381,43 @@
**(add_points_kwargs or {}),
)

if isinstance(meshes, pv.PolyData):
meshes = [meshes]

Check warning on line 385 in src/ansys/mapdl/core/plotting/visualizer.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/mapdl/core/plotting/visualizer.py#L385

Added line #L385 was not covered by tests
for mesh in meshes:
scalars: Optional[NDArray[Any]] = mesh.get("scalars")

if (
"scalars" in mesh
and scalars.ndim == 2
and (scalars.shape[1] == 3 or scalars.shape[1] == 4)
):
# for the case we are using scalars for plotting
rgb = True
rgb = False
if isinstance(mesh, Dict):
scalars: Optional[NDArray[Any]] = mesh.get("scalars")

if (
"scalars" in mesh
and scalars.ndim == 2
and (scalars.shape[1] == 3 or scalars.shape[1] == 4)
):
# for the case we are using scalars for plotting
rgb = True

Check warning on line 397 in src/ansys/mapdl/core/plotting/visualizer.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/mapdl/core/plotting/visualizer.py#L397

Added line #L397 was not covered by tests

# To avoid index error.
mesh_ = mesh["mesh"]
if not isinstance(mesh_, list):
mesh_ = [mesh_]
else:
rgb = False

# To avoid index error.
mesh_ = mesh["mesh"]
if not isinstance(mesh_, list):
mesh_ = [mesh_]

scalars = None
mesh_ = meshes

Check warning on line 405 in src/ansys/mapdl/core/plotting/visualizer.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/mapdl/core/plotting/visualizer.py#L404-L405

Added lines #L404 - L405 were not covered by tests
for each_mesh in mesh_:
self.scene.add_mesh(
each_mesh,
scalars=scalars,
scalar_bar_args=scalar_bar_args,
color=mesh.get("color", color),
style=mesh.get("style", style),
color=(
mesh.get("color", color)
if isinstance(mesh, Dict) and "color" in mesh
else color
),
style=(
mesh.get("style", style)
if isinstance(mesh, Dict) and "style" in mesh
else style
),
show_edges=show_edges,
edge_color=edge_color,
smooth_shading=smooth_shading,
Expand Down Expand Up @@ -651,9 +666,9 @@

def plot(
self,
meshes,
points,
labels,
meshes: Union[pv.PolyData, Dict[str, Any]] = [],
points=[],
labels=[],
*,
title="",
cpos=None,
Expand Down
Loading