1717*******************************************************************************
1818* Contact information: [email protected] * 1919******************************************************************************/
20+ #include < pybind11/stl.h>
2021
2122#include < SofaPython3/Sofa/Core/Binding_Base.h>
2223#include < SofaPython3/Sofa/Core/Binding_BaseContext.h>
@@ -37,6 +38,56 @@ namespace sofapython3 {
3738
3839void moduleAddBaseMeshTopology (py::module & m) {
3940 py::class_<BaseMeshTopology, Base, py_shared_ptr<BaseMeshTopology>> c (m, " BaseMeshTopology" );
41+
42+ // / register the ContactListener binding in the downcasting subsystem
43+ PythonFactory::registerType<BaseMeshTopology>([](sofa::core::objectmodel::Base* object)
44+ {
45+ return py::cast (dynamic_cast <BaseMeshTopology*>(object));
46+ });
47+
48+ c.def (" getNbPoints" , &BaseMeshTopology::getNbPoints);
49+ c.def (" getNbLines" , &BaseMeshTopology::getNbLines);
50+ c.def (" getNbEdges" , &BaseMeshTopology::getNbEdges);
51+ c.def (" getNbTriangles" , &BaseMeshTopology::getNbTriangles);
52+ c.def (" getNbTetrahedra" , &BaseMeshTopology::getNbTetrahedra);
53+ c.def (" getNbHexahedra" , &BaseMeshTopology::getNbHexahedra);
54+ c.def (" getNbQuads" , &BaseMeshTopology::getNbQuads);
55+ c.def (" getNbTetras" , &BaseMeshTopology::getNbTetras);
56+
57+ c.def (" getEdge" ,
58+ [] (BaseMeshTopology &self, const sofa::Index & index) -> std::array<sofa::Index, 2 > {
59+ const auto & e = self.getEdge (index);
60+ return {{e[0 ], e[1 ]}};
61+ },
62+ py::arg (" index" )
63+ );
64+
65+ c.def (" getLocalEdgesInTetrahedron" ,
66+ [] (const BaseMeshTopology & self, const sofa::Index & index) -> std::array<sofa::Index, 2 > {
67+ const auto & e = self.getLocalEdgesInTetrahedron (index);
68+ return {{e[0 ], e[1 ]}};
69+ },
70+ py::arg (" index" ),
71+ " Returns for each index (between 0 and 5) the two vertex indices that are adjacent to that edge."
72+ );
73+
74+ c.def (" getEdgesInTetrahedron" ,
75+ [] (BaseMeshTopology & self, const sofa::Index & index) -> std::array<sofa::Index, 6 > {
76+ const auto & e = self.getEdgesInTetrahedron (index);
77+ return {{e[0 ], e[1 ], e[2 ], e[3 ], e[4 ], e[5 ]}};
78+ },
79+ py::arg (" index" ),
80+ " Returns the set of edges adjacent to a given tetrahedron."
81+ );
82+
83+ c.def (" getTetrahedron" ,
84+ [] (BaseMeshTopology & self, const sofa::Index & index) -> std::array<sofa::Index, 4 > {
85+ const auto & n = self.getTetrahedron (index);
86+ return {{n[0 ], n[1 ], n[2 ], n[3 ]}};
87+ },
88+ py::arg (" index" ),
89+ " Returns the vertices of Tetrahedron at index."
90+ );
4091}
4192
4293} // namespace sofapython3
0 commit comments