Skip to content

Commit ca2be7c

Browse files
authored
Add bindings for prism and pyramid topology functions (#578)
1 parent 346d298 commit ca2be7c

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_BaseMeshTopology.cpp

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ void moduleAddBaseMeshTopology(py::module& m) {
6565
c.def("getNbTriangles", &BaseMeshTopology::getNbTriangles);
6666
c.def("getNbTetrahedra", &BaseMeshTopology::getNbTetrahedra);
6767
c.def("getNbHexahedra", &BaseMeshTopology::getNbHexahedra);
68+
c.def("getNbPrisms", &BaseMeshTopology::getNbPrisms);
69+
c.def("getNbPyramids", &BaseMeshTopology::getNbPyramids);
6870
c.def("getNbQuads", &BaseMeshTopology::getNbQuads);
6971
c.def("getNbTetras", &BaseMeshTopology::getNbTetras);
7072

7173
c.def("getEdge",
72-
[] (BaseMeshTopology &self, const sofa::Index & index) -> std::array<sofa::Index, 2> {
74+
[] (BaseMeshTopology &self, const sofa::Index & index) -> std::array<sofa::Index, sofa::geometry::Edge::NumberOfNodes> {
7375
const auto & e = self.getEdge(index);
7476
return {{e[0], e[1]}};
7577
},
@@ -78,7 +80,7 @@ void moduleAddBaseMeshTopology(py::module& m) {
7880
);
7981

8082
c.def("getTriangle",
81-
[] (BaseMeshTopology &self, const sofa::Index & index) -> std::array<sofa::Index, 3> {
83+
[] (BaseMeshTopology &self, const sofa::Index & index) -> std::array<sofa::Index, sofa::geometry::Triangle::NumberOfNodes> {
8284
const auto & t = self.getTriangle(index);
8385
return {{t[0], t[1], t[2]}};
8486
},
@@ -87,7 +89,7 @@ void moduleAddBaseMeshTopology(py::module& m) {
8789
);
8890

8991
c.def("getQuad",
90-
[] (BaseMeshTopology &self, const sofa::Index & index) -> std::array<sofa::Index, 4> {
92+
[] (BaseMeshTopology &self, const sofa::Index & index) -> std::array<sofa::Index, sofa::geometry::Quad::NumberOfNodes> {
9193
const auto & q = self.getQuad(index);
9294
return {{q[0], q[1], q[2], q[3]}};
9395
},
@@ -96,7 +98,7 @@ void moduleAddBaseMeshTopology(py::module& m) {
9698
);
9799

98100
c.def("getTetrahedron",
99-
[] (BaseMeshTopology & self, const sofa::Index & index) -> std::array<sofa::Index, 4> {
101+
[] (BaseMeshTopology & self, const sofa::Index & index) -> std::array<sofa::Index, sofa::geometry::Tetrahedron::NumberOfNodes> {
100102
const auto & n = self.getTetrahedron(index);
101103
return {{n[0], n[1], n[2], n[3]}};
102104
},
@@ -105,14 +107,32 @@ void moduleAddBaseMeshTopology(py::module& m) {
105107
);
106108

107109
c.def("getHexahedron",
108-
[] (BaseMeshTopology & self, const sofa::Index & index) -> std::array<sofa::Index, 8> {
110+
[] (BaseMeshTopology & self, const sofa::Index & index) -> std::array<sofa::Index, sofa::geometry::Hexahedron::NumberOfNodes> {
109111
const auto & n = self.getHexahedron(index);
110112
return {{n[0], n[1], n[2], n[3], n[4], n[5], n[6], n[7]}};
111113
},
112114
py::arg("index"),
113115
"Returns the vertices of Hexahedron at index."
114116
);
115117

118+
c.def("getPrism",
119+
[] (BaseMeshTopology & self, const sofa::Index & index) -> std::array<sofa::Index, sofa::geometry::Prism::NumberOfNodes> {
120+
const auto & n = self.getPrism(index);
121+
return {{n[0], n[1], n[2], n[3], n[4], n[5]}};
122+
},
123+
py::arg("index"),
124+
"Returns the vertices of Prism at index."
125+
);
126+
127+
c.def("getPyramid",
128+
[] (BaseMeshTopology & self, const sofa::Index & index) -> std::array<sofa::Index, sofa::geometry::Pyramid::NumberOfNodes> {
129+
const auto & n = self.getPyramid(index);
130+
return {{n[0], n[1], n[2], n[3], n[4]}};
131+
},
132+
py::arg("index"),
133+
"Returns the vertices of Pyramid at index."
134+
);
135+
116136
c.def("getLocalEdgesInTetrahedron",
117137
[] (const BaseMeshTopology & self, const sofa::Index & index) -> std::array<sofa::Index, 2> {
118138
const auto & e = self.getLocalEdgesInTetrahedron(index);

0 commit comments

Comments
 (0)