Skip to content

Commit a81a50f

Browse files
psomers3psomers3
andauthored
[bindings] Started Topology and BaseMeshTopology bindings (#114)
Co-authored-by: psomers3 <[email protected]>
1 parent 4def6d8 commit a81a50f

File tree

7 files changed

+153
-2
lines changed

7 files changed

+153
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <SofaPython3/Sofa/Core/Binding_BaseContext.h>
2323
#include <SofaPython3/PythonFactory.h>
2424
#include <sofa/core/BaseState.h>
25+
#include <sofa/core/objectmodel/BaseObject.h>
2526
#include <sofa/core/behavior/BaseMechanicalState.h>
2627
#include <sofa/core/topology/Topology.h>
2728
#include <sofa/core/topology/BaseMeshTopology.h>
@@ -55,8 +56,8 @@ void moduleAddBaseContext(py::module& m) {
5556
c.def("getState", &BaseContext::getState, "Mechanical Degrees-of-Freedom");
5657
c.def("getMechanicalState", &BaseContext::getMechanicalState, "Mechanical Degrees-of-Freedom");
5758
c.def("getTopology", &BaseContext::getTopology, "Topology");
58-
c.def("getMeshTopology", &BaseContext::getMeshTopology, "Mesh Topology (unified interface for both static and dynamic topologies)");
59-
c.def("getMeshTopologyLink", &BaseContext::getMeshTopologyLink, "Mesh Topology (unified interface for both static and dynamic topologies)");
59+
c.def("getMeshTopology", &BaseContext::getMeshTopology, py::arg("SearchDirection") = BaseContext::SearchDirection::SearchUp, "Mesh Topology (unified interface for both static and dynamic topologies)");
60+
c.def("getMeshTopologyLink", &BaseContext::getMeshTopologyLink, py::arg("SearchDirection") = BaseContext::SearchDirection::SearchUp, "Mesh Topology (unified interface for both static and dynamic topologies)");
6061
c.def("getMass", &BaseContext::getMass, "Mass");
6162

6263
c.def("__str__", [](const BaseContext & context) {std::ostringstream s; s << context; return s.str();}, "Get a string representation of the context.");
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/******************************************************************************
2+
* SOFA, Simulation Open-Framework Architecture *
3+
* (c) 2021 INRIA, USTL, UJF, CNRS, MGH *
4+
* *
5+
* This program is free software; you can redistribute it and/or modify it *
6+
* under the terms of the GNU Lesser General Public License as published by *
7+
* the Free Software Foundation; either version 2.1 of the License, or (at *
8+
* your option) any later version. *
9+
* *
10+
* This program is distributed in the hope that it will be useful, but WITHOUT *
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
12+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
13+
* for more details. *
14+
* *
15+
* You should have received a copy of the GNU Lesser General Public License *
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
17+
*******************************************************************************
18+
* Contact information: [email protected] *
19+
******************************************************************************/
20+
21+
#include <SofaPython3/Sofa/Core/Binding_Base.h>
22+
#include <SofaPython3/Sofa/Core/Binding_BaseContext.h>
23+
#include <SofaPython3/PythonFactory.h>
24+
#include <sofa/core/BaseState.h>
25+
#include <sofa/core/objectmodel/BaseObject.h>
26+
#include <sofa/core/behavior/BaseMechanicalState.h>
27+
#include <sofa/core/topology/Topology.h>
28+
#include <sofa/core/topology/BaseMeshTopology.h>
29+
30+
31+
namespace py { using namespace pybind11; }
32+
33+
using namespace sofa::core::objectmodel;
34+
using namespace sofa::core::topology;
35+
36+
namespace sofapython3 {
37+
38+
void moduleAddBaseMeshTopology(py::module& m) {
39+
py::class_<BaseMeshTopology, Base, py_shared_ptr<BaseMeshTopology>> c (m, "BaseMeshTopology");
40+
}
41+
42+
} // namespace sofapython3
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/******************************************************************************
2+
* SOFA, Simulation Open-Framework Architecture *
3+
* (c) 2021 INRIA, USTL, UJF, CNRS, MGH *
4+
* *
5+
* This program is free software; you can redistribute it and/or modify it *
6+
* under the terms of the GNU Lesser General Public License as published by *
7+
* the Free Software Foundation; either version 2.1 of the License, or (at *
8+
* your option) any later version. *
9+
* *
10+
* This program is distributed in the hope that it will be useful, but WITHOUT *
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
12+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
13+
* for more details. *
14+
* *
15+
* You should have received a copy of the GNU Lesser General Public License *
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
17+
*******************************************************************************
18+
* Contact information: [email protected] *
19+
******************************************************************************/
20+
21+
#pragma once
22+
23+
#include <pybind11/pybind11.h>
24+
25+
namespace sofapython3 {
26+
27+
void moduleAddBaseMeshTopology(pybind11::module &m);
28+
29+
} // namespace sofapython3
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/******************************************************************************
2+
* SOFA, Simulation Open-Framework Architecture *
3+
* (c) 2021 INRIA, USTL, UJF, CNRS, MGH *
4+
* *
5+
* This program is free software; you can redistribute it and/or modify it *
6+
* under the terms of the GNU Lesser General Public License as published by *
7+
* the Free Software Foundation; either version 2.1 of the License, or (at *
8+
* your option) any later version. *
9+
* *
10+
* This program is distributed in the hope that it will be useful, but WITHOUT *
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
12+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
13+
* for more details. *
14+
* *
15+
* You should have received a copy of the GNU Lesser General Public License *
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
17+
*******************************************************************************
18+
* Contact information: [email protected] *
19+
******************************************************************************/
20+
21+
#include <SofaPython3/Sofa/Core/Binding_Base.h>
22+
#include <SofaPython3/Sofa/Core/Binding_BaseContext.h>
23+
#include <SofaPython3/PythonFactory.h>
24+
#include <sofa/core/BaseState.h>
25+
#include <sofa/core/objectmodel/BaseObject.h>
26+
#include <sofa/core/behavior/BaseMechanicalState.h>
27+
#include <sofa/core/topology/Topology.h>
28+
#include <sofa/core/topology/BaseMeshTopology.h>
29+
30+
31+
namespace py { using namespace pybind11; }
32+
33+
using namespace sofa::core::objectmodel;
34+
using namespace sofa::core::topology;
35+
36+
namespace sofapython3 {
37+
38+
void moduleAddTopology(py::module& m) {
39+
py::class_<Topology, Base, py_shared_ptr<Topology>> c (m, "Topology");
40+
}
41+
42+
} // namespace sofapython3
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/******************************************************************************
2+
* SOFA, Simulation Open-Framework Architecture *
3+
* (c) 2021 INRIA, USTL, UJF, CNRS, MGH *
4+
* *
5+
* This program is free software; you can redistribute it and/or modify it *
6+
* under the terms of the GNU Lesser General Public License as published by *
7+
* the Free Software Foundation; either version 2.1 of the License, or (at *
8+
* your option) any later version. *
9+
* *
10+
* This program is distributed in the hope that it will be useful, but WITHOUT *
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
12+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
13+
* for more details. *
14+
* *
15+
* You should have received a copy of the GNU Lesser General Public License *
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
17+
*******************************************************************************
18+
* Contact information: [email protected] *
19+
******************************************************************************/
20+
21+
#pragma once
22+
23+
#include <pybind11/pybind11.h>
24+
25+
namespace sofapython3 {
26+
27+
void moduleAddTopology(pybind11::module &m);
28+
29+
} // namespace sofapython3

bindings/Sofa/src/SofaPython3/Sofa/Core/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ set(HEADER_FILES
3838
${CMAKE_CURRENT_SOURCE_DIR}/Binding_BaseLink_doc.h
3939
${CMAKE_CURRENT_SOURCE_DIR}/Binding_BaseData_doc.h
4040
${CMAKE_CURRENT_SOURCE_DIR}/Binding_BaseCamera_doc.h
41+
${CMAKE_CURRENT_SOURCE_DIR}/Binding_Topology.h
42+
${CMAKE_CURRENT_SOURCE_DIR}/Binding_BaseMeshTopology.h
4143
)
4244

4345
set(SOURCE_FILES
@@ -63,6 +65,8 @@ set(SOURCE_FILES
6365
${CMAKE_CURRENT_SOURCE_DIR}/Submodule_Core.cpp
6466
${CMAKE_CURRENT_SOURCE_DIR}/Binding_PythonScriptEvent.cpp
6567
${CMAKE_CURRENT_SOURCE_DIR}/Binding_BaseLink.cpp
68+
${CMAKE_CURRENT_SOURCE_DIR}/Binding_Topology.cpp
69+
${CMAKE_CURRENT_SOURCE_DIR}/Binding_BaseMeshTopology.cpp
6670
)
6771

6872
if (NOT TARGET SofaPython3::Plugin)

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ using sofa::helper::logging::Message;
3939
#include <SofaPython3/Sofa/Core/Binding_Prefab.h>
4040
#include <SofaPython3/Sofa/Core/Binding_BaseLink.h>
4141
#include <SofaPython3/Sofa/Core/Binding_PythonScriptEvent.h>
42+
#include <SofaPython3/Sofa/Core/Binding_Topology.h>
43+
#include <SofaPython3/Sofa/Core/Binding_BaseMeshTopology.h>
4244

4345
#include <SofaPython3/Sofa/Core/Data/Binding_DataString.h>
4446
#include <SofaPython3/Sofa/Core/Data/Binding_DataLink.h>
@@ -134,6 +136,8 @@ PYBIND11_MODULE(Core, core)
134136
moduleAddNodeIterator(core);
135137
moduleAddPrefab(core);
136138
moduleAddBaseLink(core);
139+
moduleAddTopology(core);
140+
moduleAddBaseMeshTopology(core);
137141
}
138142

139143
} ///namespace sofapython3

0 commit comments

Comments
 (0)