Skip to content

Commit 7174ab6

Browse files
committed
[Bindings] Add BaseState bindings
Signed-off-by: Jean-Nicolas Brunet <[email protected]>
1 parent 8d83a97 commit 7174ab6

File tree

4 files changed

+77
-0
lines changed

4 files changed

+77
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/******************************************************************************
2+
* SofaPython3 plugin *
3+
* (c) 2021 CNRS, University of Lille, INRIA *
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_BaseState.h>
22+
#include <SofaPython3/Sofa/Core/Binding_Base.h>
23+
#include <sofa/core/BaseState.h>
24+
25+
#include <SofaPython3/PythonFactory.h>
26+
27+
namespace py { using namespace pybind11; }
28+
29+
namespace sofapython3 {
30+
31+
void moduleAddBaseState(py::module& m) {
32+
using namespace sofa::core;
33+
py::class_<BaseState, sofa::core::objectmodel::BaseObject, py_shared_ptr<BaseState>> (m, "BaseState")
34+
.def("getSize", &BaseState::getSize)
35+
.def("resize", &BaseState::getSize)
36+
;
37+
38+
/// register the BaseState binding in the downcasting subsystem
39+
PythonFactory::registerType<BaseState>([](sofa::core::objectmodel::Base* object)
40+
{
41+
return py::cast(dynamic_cast<BaseState*>(object));
42+
});
43+
}
44+
45+
} // namespace sofapython3
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/******************************************************************************
2+
* SofaPython3 plugin *
3+
* (c) 2021 CNRS, University of Lille, INRIA *
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+
#include <pybind11/pybind11.h>
23+
24+
namespace sofapython3 {
25+
26+
void moduleAddBaseState(pybind11::module &m);
27+
28+
} /// namespace sofapython3

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ set(HEADER_FILES
1010
${CMAKE_CURRENT_SOURCE_DIR}/Binding_BaseObject_doc.h
1111
${CMAKE_CURRENT_SOURCE_DIR}/Binding_BaseCamera.h
1212
${CMAKE_CURRENT_SOURCE_DIR}/Binding_BaseContext.h
13+
${CMAKE_CURRENT_SOURCE_DIR}/Binding_BaseState.h
1314
${CMAKE_CURRENT_SOURCE_DIR}/Binding_ContactListener.h
1415
${CMAKE_CURRENT_SOURCE_DIR}/Binding_ContactListener_doc.h
1516
${CMAKE_CURRENT_SOURCE_DIR}/Binding_Context.h
@@ -49,6 +50,7 @@ set(SOURCE_FILES
4950
${CMAKE_CURRENT_SOURCE_DIR}/Binding_BaseObject.cpp
5051
${CMAKE_CURRENT_SOURCE_DIR}/Binding_BaseCamera.cpp
5152
${CMAKE_CURRENT_SOURCE_DIR}/Binding_BaseContext.cpp
53+
${CMAKE_CURRENT_SOURCE_DIR}/Binding_BaseState.cpp
5254
${CMAKE_CURRENT_SOURCE_DIR}/Binding_ContactListener.cpp
5355
${CMAKE_CURRENT_SOURCE_DIR}/Binding_Context.cpp
5456
${CMAKE_CURRENT_SOURCE_DIR}/Binding_Controller.cpp

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ using sofa::helper::logging::Message;
2828
#include <SofaPython3/Sofa/Core/Binding_DataDict.h>
2929
#include <SofaPython3/Sofa/Core/Binding_BaseData.h>
3030
#include <SofaPython3/Sofa/Core/Binding_BaseCamera.h>
31+
#include <SofaPython3/Sofa/Core/Binding_BaseState.h>
3132
#include <SofaPython3/Sofa/Core/Binding_ForceField.h>
3233
#include <SofaPython3/Sofa/Core/Binding_ContactListener.h>
3334
#include <SofaPython3/Sofa/Core/Binding_Context.h>
@@ -126,6 +127,7 @@ PYBIND11_MODULE(Core, core)
126127
moduleAddDataVectorString(core);
127128
moduleAddBaseObject(core);
128129
moduleAddBaseCamera(core);
130+
moduleAddBaseState(core);
129131
moduleAddContactListener(core);
130132
moduleAddContext(core);
131133
moduleAddController(core);

0 commit comments

Comments
 (0)