|
25 | 25 | #include <stdexcept>
|
26 | 26 |
|
27 | 27 | #include <SMESH_Gen.hxx>
|
| 28 | +#include <SMESH_Group.hxx> |
28 | 29 | #include <SMESH_Mesh.hxx>
|
| 30 | +#include <SMESHDS_Group.hxx> |
| 31 | +#include <SMDSAbs_ElementType.hxx> |
| 32 | +#include <SMDS_MeshElement.hxx> |
29 | 33 | #include <SMDS_VolumeTool.hxx>
|
30 | 34 |
|
31 | 35 | #include <TopoDS_Shape.hxx>
|
@@ -898,6 +902,57 @@ PyObject* FemMeshPy::getElementNodes(PyObject *args)
|
898 | 902 | }
|
899 | 903 | }
|
900 | 904 |
|
| 905 | +PyObject* FemMeshPy::getGroupName(PyObject *args) |
| 906 | +{ |
| 907 | + int id; |
| 908 | + if (!PyArg_ParseTuple(args, "i", &id)) |
| 909 | + return 0; |
| 910 | + |
| 911 | + return PyString_FromString(getFemMeshPtr()->getSMesh()->GetGroup(id)->GetName()); |
| 912 | +} |
| 913 | + |
| 914 | +PyObject* FemMeshPy::getGroupElementType(PyObject *args) |
| 915 | +{ |
| 916 | + int id; |
| 917 | + if (!PyArg_ParseTuple(args, "i", &id)) |
| 918 | + return 0; |
| 919 | + |
| 920 | + SMDSAbs_ElementType aElementType = getFemMeshPtr()->getSMesh()->GetGroup(id)->GetGroupDS()->GetType(); |
| 921 | + const char* typeString = ""; |
| 922 | + switch(aElementType) { |
| 923 | + case SMDSAbs_All : typeString = "All"; break; |
| 924 | + case SMDSAbs_Node : typeString = "Node"; break; |
| 925 | + case SMDSAbs_Edge : typeString = "Edge"; break; |
| 926 | + case SMDSAbs_Face : typeString = "Face"; break; |
| 927 | + case SMDSAbs_Volume : typeString = "Volume"; break; |
| 928 | + case SMDSAbs_0DElement : typeString = "0DElement"; break; |
| 929 | + case SMDSAbs_Ball : typeString = "Ball"; break; |
| 930 | + case SMDSAbs_NbElementTypes : typeString = "NbElementTypes"; break; |
| 931 | + } |
| 932 | + return PyString_FromString(typeString); |
| 933 | +} |
| 934 | + |
| 935 | +PyObject* FemMeshPy::getGroupElements(PyObject *args) |
| 936 | +{ |
| 937 | + int id; |
| 938 | + if (!PyArg_ParseTuple(args, "i", &id)) |
| 939 | + return 0; |
| 940 | + |
| 941 | + std::set<int> ids; |
| 942 | + SMDS_ElemIteratorPtr aElemIter = getFemMeshPtr()->getSMesh()->GetGroup(id)->GetGroupDS()->GetElements(); |
| 943 | + while (aElemIter->more()) { |
| 944 | + const SMDS_MeshElement* aElement = aElemIter->next(); |
| 945 | + ids.insert(aElement->GetID()); |
| 946 | + } |
| 947 | + |
| 948 | + Py::Tuple tuple(ids.size()); |
| 949 | + int index = 0; |
| 950 | + for (std::set<int>::iterator it = ids.begin(); it != ids.end(); ++it) { |
| 951 | + tuple.setItem(index++, Py::Int(*it)); |
| 952 | + } |
| 953 | + |
| 954 | + return Py::new_reference_to(tuple); |
| 955 | +} |
901 | 956 |
|
902 | 957 | // ===== Atributes ============================================================
|
903 | 958 |
|
|
0 commit comments