From d018b3f8fbd44531311133f0415cdce03e726fd1 Mon Sep 17 00:00:00 2001 From: marioalexis Date: Wed, 29 Oct 2025 00:38:41 -0300 Subject: [PATCH] Fem: Add method to rename mesh group --- src/Mod/Fem/App/FemMesh.cpp | 8 ++++++++ src/Mod/Fem/App/FemMesh.h | 2 ++ src/Mod/Fem/App/FemMesh.pyi | 8 ++++++++ src/Mod/Fem/App/FemMeshPyImp.cpp | 12 ++++++++++++ 4 files changed, 30 insertions(+) diff --git a/src/Mod/Fem/App/FemMesh.cpp b/src/Mod/Fem/App/FemMesh.cpp index 52e0ed8fa0..4a493c0d04 100644 --- a/src/Mod/Fem/App/FemMesh.cpp +++ b/src/Mod/Fem/App/FemMesh.cpp @@ -2705,3 +2705,11 @@ bool FemMesh::removeGroup(int GroupId) { return this->getSMesh()->RemoveGroup(GroupId); } + +void FemMesh::renameGroup(int id, const std::string& name) +{ + SMESH_Group* grp = this->getSMesh()->GetGroup(id); + if (grp) { + grp->SetName(name.c_str()); + } +} diff --git a/src/Mod/Fem/App/FemMesh.h b/src/Mod/Fem/App/FemMesh.h index af79553857..3edc6a1a17 100644 --- a/src/Mod/Fem/App/FemMesh.h +++ b/src/Mod/Fem/App/FemMesh.h @@ -180,6 +180,8 @@ public: void addGroupElements(int, const std::set&); /// Remove group (Name due to similarity to SMESH basis functions) bool removeGroup(int); + /// Rename group + void renameGroup(int id, const std::string& name); //@} diff --git a/src/Mod/Fem/App/FemMesh.pyi b/src/Mod/Fem/App/FemMesh.pyi index 04f2fa8f3b..c48dec78c6 100644 --- a/src/Mod/Fem/App/FemMesh.pyi +++ b/src/Mod/Fem/App/FemMesh.pyi @@ -239,6 +239,14 @@ class FemMesh(ComplexGeoData): Returns boolean.""" ... + @constmethod + def renameGroup(self) -> Any: + """Rename a group with a given group ID + renameGroup(id, name) + groupid: int + name: string""" + ... + @constmethod def getElementType(self) -> Any: """Return the element type of a given ID""" diff --git a/src/Mod/Fem/App/FemMeshPyImp.cpp b/src/Mod/Fem/App/FemMeshPyImp.cpp index c4450193b4..bfb923ebc7 100644 --- a/src/Mod/Fem/App/FemMeshPyImp.cpp +++ b/src/Mod/Fem/App/FemMeshPyImp.cpp @@ -1718,6 +1718,18 @@ PyObject* FemMeshPy::removeGroup(PyObject* args) const return PyBool_FromLong((long)(getFemMeshPtr()->removeGroup(theId))); } +PyObject* FemMeshPy::renameGroup(PyObject* args) const +{ + int id; + const char* name; + if (!PyArg_ParseTuple(args, "is", &id, &name)) { + return nullptr; + } + + getFemMeshPtr()->renameGroup(id, name); + + Py_Return; +} PyObject* FemMeshPy::getElementType(PyObject* args) const {