Skip to content

Commit

Permalink
Fix/node-numbering (#3297)
Browse files Browse the repository at this point in the history
* tests: add test

* tests: testing

* fix: removing everything that handled the duplicated points. It is not needed anymore.

* chore: adding changelog file 3297.fixed.md

---------

Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com>
  • Loading branch information
germa89 and pyansys-ci-bot authored Aug 27, 2024
1 parent 0c0f679 commit 6fbaad3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
1 change: 1 addition & 0 deletions doc/changelog.d/3297.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix/node-numbering
1 change: 1 addition & 0 deletions src/ansys/mapdl/core/mapdl_extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,7 @@ def eplot(self, show_node_numbering=False, vtk=None, **kwargs):

pl = kwargs.get("plotter", None)
pl = MapdlPlotter().switch_scene(pl)
pl.mapdl = self

kwargs.setdefault("title", "MAPDL Element Plot")
if not self._mesh.n_elem:
Expand Down
14 changes: 5 additions & 9 deletions src/ansys/mapdl/core/plotting/visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from numpy.typing import NDArray

from ansys.mapdl.core import _HAS_PYVISTA
from ansys.mapdl.core.misc import get_bounding_box, unique_rows
from ansys.mapdl.core.misc import get_bounding_box
from ansys.mapdl.core.plotting.consts import (
ALLOWED_TARGETS,
BC_D,
Expand Down Expand Up @@ -424,16 +424,12 @@ def add_mesh(
)

for label in labels:
# verify points are not duplicates
points = np.atleast_2d(np.array(label["points"]))
_, idx, idx2 = unique_rows(points)
points = points[idx2][idx] # Getting back the initial order.
# Pyvista does not support plotting two labels with the same point.
# It does handle that case by keeping only the first label.

# Converting python order (0 based)
labels_ = np.array(label["labels"] - 1)[idx]
self.add_labels(
points,
labels_,
label["points"],
label["labels"],
show_points=False,
shadow=False,
font_size=font_size,
Expand Down
17 changes: 17 additions & 0 deletions tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -1109,3 +1109,20 @@ def test_node_numbering_order(mapdl, cleared):
# There is no way to retrieve labels from the plotter object. So we cannot
# test it.
pl.show()


def test_lplot_line(mapdl, cleared):
mapdl.prep7()

# Create keypoints 3 keypoints
mapdl.k(1, 0, 0, 0)
mapdl.k(2, 1, 0, 0)
mapdl.k(3, 1, 1, 0)

# Create line connecting keypoints 1 and 2
mapdl.l(1, 2)

# Plot the geometry
mapdl.lplot(
show_line_numbering=False, show_keypoint_numbering=True, color_lines=True
)

0 comments on commit 6fbaad3

Please sign in to comment.