Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import unittest
import Sofa.Core
import Sofa.Components
from Sofa import SofaConstraintSolver

class Test(unittest.TestCase):
Expand Down
1 change: 0 additions & 1 deletion bindings/Modules/tests/SofaLinearSolver/matrix_access.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import unittest
import Sofa.Core
import Sofa.Components
from Sofa import SofaLinearSolver

class Test(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion bindings/Sofa/Bindings.SofaConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ find_package(SofaPython3 QUIET REQUIRED COMPONENTS Plugin)
# Required by Bindings.Sofa.Helper, Bindings.Sofa.Types
find_package(Sofa.Core QUIET REQUIRED)

# Required by Bindings.Sofa.Core, Bindings.Sofa.Components
# Required by Bindings.Sofa.Core
find_package(Sofa.Simulation.Core QUIET REQUIRED)

# Required by Bindings.Sofa.Core
Expand Down
1 change: 0 additions & 1 deletion bindings/Sofa/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
project(Bindings.Sofa)

set(SOFABINDINGS_MODULE_LIST
Components
Core
Helper
Simulation
Expand Down
1 change: 0 additions & 1 deletion bindings/Sofa/package/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@
import Sofa.Core
import Sofa.Simulation
import Sofa.Types
import Sofa.Components
import SofaTypes

from .prefab import *
Expand Down
21 changes: 0 additions & 21 deletions bindings/Sofa/src/SofaPython3/Sofa/Components/CMakeLists.txt

This file was deleted.

142 changes: 0 additions & 142 deletions bindings/Sofa/src/SofaPython3/Sofa/Components/Submodule_Components.cpp

This file was deleted.

This file was deleted.

5 changes: 5 additions & 0 deletions bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ using sofa::helper::WriteOnlyAccessor;

#include <SofaPython3/PythonFactory.h>

#include <SofaPython3/Sofa/Core/Binding_BaseData.h>
#include <SofaPython3/Sofa/Core/Binding_BaseLink.h>
#include <SofaPython3/Sofa/Core/Binding_LinkPath.h>
#include <SofaPython3/Sofa/Core/Binding_Base.h>
#include <SofaPython3/Sofa/Core/Binding_Base_doc.h>
Expand Down Expand Up @@ -449,6 +451,9 @@ py::object BindingBase::setDataValues(Base& self, py::kwargs kwargs)

void moduleAddBase(py::module &m)
{
moduleForwardAddBaseData(m);
moduleForwardAddBaseLink(m);

py::class_<Base, py_shared_ptr<Base>> base(m, "Base", py::dynamic_attr(), doc::base::BaseClass);
/// set & get the name as string. The alternative is to access the data field using
/// obj.name.value = "aName"
Expand Down
16 changes: 15 additions & 1 deletion bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_BaseData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,24 @@ std::string getValueTypeString(BaseData* data)
return data->getValueTypeInfo()->name();
}

auto getPythonClassForBaseData(py::module& m)
{
/// Register the BaseData binding into the pybind11 system.
static py::class_<BaseData, std::unique_ptr<sofa::core::objectmodel::BaseData, pybind11::nodelete>> data(m, "Data", sofapython3::doc::baseData::BaseDataClass);
return data;
}

void moduleForwardAddBaseData(py::module& m)
{
getPythonClassForBaseData(m);
}

void moduleAddBaseData(py::module& m)
{
/// Register the BaseData binding into the pybind11 system.
py::class_<BaseData, std::unique_ptr<sofa::core::objectmodel::BaseData, pybind11::nodelete>> data(m, "Data", sofapython3::doc::baseData::BaseDataClass);
//py::class_<BaseData, std::unique_ptr<sofa::core::objectmodel::BaseData, pybind11::nodelete>> data(m, "Data", sofapython3::doc::baseData::BaseDataClass);

auto data =getPythonClassForBaseData(m);
data.def("getName", [](BaseData& b){ return b.getName(); }, sofapython3::doc::baseData::getName);
data.def("setName", [](BaseData& b, const std::string& s){ b.setName(s); }, sofapython3::doc::baseData::setName);
data.def("getCounter", [](BaseData& self) { return self.getCounter(); }, sofapython3::doc::baseData::getCounter);
Expand Down
1 change: 1 addition & 0 deletions bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_BaseData.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

namespace sofapython3 {

void moduleForwardAddBaseData(pybind11::module& m);
void moduleAddBaseData(pybind11::module& m);

} /// sofapython3
14 changes: 13 additions & 1 deletion bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_BaseLink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,21 @@ void __setattr__(py::object self, const std::string& s, py::object value)
}
}

auto getPythonClassForBaseLink(py::module& m)
{
/// Register the BaseData binding into the pybind11 system.
static py::class_<BaseLink> link(m, "Link", sofapython3::doc::baseLink::baseLinkClass);
return link;
}

void moduleForwardAddBaseLink(py::module& m)
{
getPythonClassForBaseLink(m);
}

void moduleAddBaseLink(py::module& m)
{
py::class_<BaseLink> link(m, "Link", sofapython3::doc::baseLink::baseLinkClass);
auto link = getPythonClassForBaseLink(m);
link.def("getName", &BaseLink::getName, sofapython3::doc::baseLink::getName);
link.def("setName", &BaseLink::setName, sofapython3::doc::baseLink::setName);
link.def("isMultiLink", &BaseLink::isMultiLink, sofapython3::doc::baseLink::isMultiLink);
Expand Down
1 change: 1 addition & 0 deletions bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_BaseLink.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

namespace sofapython3 {

void moduleForwardAddBaseLink(pybind11::module& m);
void moduleAddBaseLink(pybind11::module& m);

} /// sofapython3
2 changes: 0 additions & 2 deletions bindings/Sofa/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ set(SOURCE_FILES
)

set(PYTHON_FILES
${CMAKE_CURRENT_SOURCE_DIR}/Components/Components.py
${CMAKE_CURRENT_SOURCE_DIR}/Core/Base.py
${CMAKE_CURRENT_SOURCE_DIR}/Core/BaseData.py
${CMAKE_CURRENT_SOURCE_DIR}/Core/BaseLink.py
Expand Down Expand Up @@ -51,7 +50,6 @@ sofa_auto_set_target_rpath(
add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME})

set(DIR_BINDING_LIST
Components
Core
Helper
Simulation
Expand Down
13 changes: 0 additions & 13 deletions bindings/Sofa/tests/Components/Components.py

This file was deleted.

1 change: 0 additions & 1 deletion bindings/Sofa/tests/PythonModule_Sofa_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ static struct PythonModule_Sofa_tests : public PythonTestExtractor
addTestDirectory(executable_directory+"/Bindings.Sofa.Tests.d/Helper", "Sofa_Helper_");
addTestDirectory(executable_directory+"/Bindings.Sofa.Tests.d/Simulation", "Sofa_Simulation_");
addTestDirectory(executable_directory+"/Bindings.Sofa.Tests.d/Types", "Sofa_Types_");
addTestDirectory(executable_directory+"/Bindings.Sofa.Tests.d/Components", "Sofa_Components_");
}
} python_tests;

Expand Down