From 6fbaad34ea52299170040d439d17c1618d5bb11f Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Tue, 27 Aug 2024 17:49:03 +0200 Subject: [PATCH] Fix/node-numbering (#3297) * 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> --- doc/changelog.d/3297.fixed.md | 1 + src/ansys/mapdl/core/mapdl_extended.py | 1 + src/ansys/mapdl/core/plotting/visualizer.py | 14 +++++--------- tests/test_plotting.py | 17 +++++++++++++++++ 4 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 doc/changelog.d/3297.fixed.md diff --git a/doc/changelog.d/3297.fixed.md b/doc/changelog.d/3297.fixed.md new file mode 100644 index 0000000000..ae99b97904 --- /dev/null +++ b/doc/changelog.d/3297.fixed.md @@ -0,0 +1 @@ +Fix/node-numbering \ No newline at end of file diff --git a/src/ansys/mapdl/core/mapdl_extended.py b/src/ansys/mapdl/core/mapdl_extended.py index a1a785727a..908ccdebae 100644 --- a/src/ansys/mapdl/core/mapdl_extended.py +++ b/src/ansys/mapdl/core/mapdl_extended.py @@ -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: diff --git a/src/ansys/mapdl/core/plotting/visualizer.py b/src/ansys/mapdl/core/plotting/visualizer.py index 1ff21832c7..a513c50800 100644 --- a/src/ansys/mapdl/core/plotting/visualizer.py +++ b/src/ansys/mapdl/core/plotting/visualizer.py @@ -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, @@ -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, diff --git a/tests/test_plotting.py b/tests/test_plotting.py index 1871a0eb64..d35ae176fa 100644 --- a/tests/test_plotting.py +++ b/tests/test_plotting.py @@ -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 + )