From 72c40daa8243f787df8513c9d719f3c6bbb0a5c3 Mon Sep 17 00:00:00 2001 From: Damien Marchal Date: Mon, 14 Jul 2025 17:06:32 +0200 Subject: [PATCH 1/2] Propagates the removale of DAGNode and DAGSimulation --- Plugin/src/SofaPython3/Prefab.h | 8 ++++---- Plugin/src/SofaPython3/SceneLoaderPY3.cpp | 3 --- bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Node.cpp | 6 +++--- .../SofaPython3/Sofa/Simulation/Submodule_Simulation.cpp | 3 --- .../src/SofaPython3/SofaRuntime/Module_SofaRuntime.cpp | 3 +-- 5 files changed, 8 insertions(+), 15 deletions(-) diff --git a/Plugin/src/SofaPython3/Prefab.h b/Plugin/src/SofaPython3/Prefab.h index 0b212d0e3..e5e4912a0 100644 --- a/Plugin/src/SofaPython3/Prefab.h +++ b/Plugin/src/SofaPython3/Prefab.h @@ -19,7 +19,7 @@ ******************************************************************************/ #pragma once -#include +#include #include #include @@ -28,17 +28,17 @@ namespace sofa::core::objectmodel { -class SOFAPYTHON3_API BasePrefab : public sofa::simulation::graph::DAGNode +class SOFAPYTHON3_API BasePrefab : public sofa::simulation::Node { public: - SOFA_CLASS(BasePrefab, sofa::simulation::graph::DAGNode); + SOFA_CLASS(BasePrefab, sofa::simulation::Node); }; } // namespace sofa::core::objectmodel namespace sofapython3 { -using sofa::simulation::graph::DAGNode; +using sofa::simulation::Node; using sofa::core::objectmodel::BasePrefab; using sofa::core::objectmodel::DataCallback; diff --git a/Plugin/src/SofaPython3/SceneLoaderPY3.cpp b/Plugin/src/SofaPython3/SceneLoaderPY3.cpp index a5a851094..9185e1593 100644 --- a/Plugin/src/SofaPython3/SceneLoaderPY3.cpp +++ b/Plugin/src/SofaPython3/SceneLoaderPY3.cpp @@ -22,9 +22,6 @@ #include #include -#include -using sofa::simulation::graph::DAGNode; - #include #include #include diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Node.cpp b/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Node.cpp index 5cc88588a..6c029ec93 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Node.cpp +++ b/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Node.cpp @@ -164,12 +164,12 @@ std::string getLinkPath(Node* node){ } py_shared_ptr __init__noname() { - auto dag_node = sofa::core::objectmodel::New("unnamed"); + auto dag_node = sofa::core::objectmodel::New("unnamed"); return std::move(dag_node); } py_shared_ptr __init__(const std::string& name) { - auto dag_node = sofa::core::objectmodel::New(name); + auto dag_node = sofa::core::objectmodel::New(name); return std::move(dag_node); } @@ -629,7 +629,7 @@ void moduleAddNode(py::module &m) { sofa::core::objectmodel::Context, py_shared_ptr> p(m, "Node", sofapython3::doc::sofa::core::Node::Class); - PythonFactory::registerType( + PythonFactory::registerType( [](sofa::core::objectmodel::Base* object) { return py::cast(dynamic_cast(object->toBaseNode())); diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Simulation/Submodule_Simulation.cpp b/bindings/Sofa/src/SofaPython3/Sofa/Simulation/Submodule_Simulation.cpp index 384362f3a..cf81ad049 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Simulation/Submodule_Simulation.cpp +++ b/bindings/Sofa/src/SofaPython3/Sofa/Simulation/Submodule_Simulation.cpp @@ -26,9 +26,6 @@ #include "SofaPython3/DataHelper.h" using sofa::simulation::Simulation; -#include -using sofa::simulation::graph::DAGSimulation; - #include using sofa::simulation::Node; using namespace pybind11::literals; diff --git a/bindings/SofaRuntime/src/SofaPython3/SofaRuntime/Module_SofaRuntime.cpp b/bindings/SofaRuntime/src/SofaPython3/SofaRuntime/Module_SofaRuntime.cpp index db70b8745..23c366bac 100644 --- a/bindings/SofaRuntime/src/SofaPython3/SofaRuntime/Module_SofaRuntime.cpp +++ b/bindings/SofaRuntime/src/SofaPython3/SofaRuntime/Module_SofaRuntime.cpp @@ -22,8 +22,7 @@ #include namespace py = pybind11; -#include -using sofa::simulation::graph::DAGSimulation ; +#include using sofa::simulation::Simulation; #include From 84b6767a8f4ad8f3542804e05f37c8b928857a7e Mon Sep 17 00:00:00 2001 From: Damien Marchal Date: Sat, 6 Sep 2025 08:14:14 +0200 Subject: [PATCH 2/2] Fix constructor build issue. --- Plugin/src/SofaPython3/PythonFactory.cpp | 2 +- .../SofaPython3/Sofa/Core/Binding_Base.cpp | 1 - .../SofaPython3/Sofa/Core/Binding_Node.cpp | 30 +++++++++---------- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/Plugin/src/SofaPython3/PythonFactory.cpp b/Plugin/src/SofaPython3/PythonFactory.cpp index b421ec495..3a9c678b4 100644 --- a/Plugin/src/SofaPython3/PythonFactory.cpp +++ b/Plugin/src/SofaPython3/PythonFactory.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include "sofa/simulation/AnimateBeginEvent.h" using sofa::simulation::AnimateBeginEvent; diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Base.cpp b/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Base.cpp index 81365ecff..e71150634 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Base.cpp +++ b/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Base.cpp @@ -133,7 +133,6 @@ bool BindingBase::SetLink(BaseLink* link, py::object value) return true; } - void BindingBase::SetAttr(py::object self, const std::string& s, py::object value) { Base* self_d = py::cast(self); diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Node.cpp b/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Node.cpp index 99cecf11f..df26021d6 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Node.cpp +++ b/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Node.cpp @@ -37,7 +37,7 @@ using sofa::helper::logging::Message; #include using sofa::helper::getClosestMatch; -#include +#include using sofa::core::ExecParams; #include @@ -163,22 +163,20 @@ std::string getLinkPath(Node* node){ return ("@"+node->getPathName()).c_str(); } -py_shared_ptr __init__noname() { - auto dag_node = sofa::core::objectmodel::New("unnamed"); - return std::move(dag_node); +py_shared_ptr __init_noname__() { + auto node = sofa::core::objectmodel::New("unnamed"); + return std::move(node); } -py_shared_ptr __init__(const std::string& name) { - auto dag_node = sofa::core::objectmodel::New(name); - return std::move(dag_node); +py_shared_ptr __init_named__(const std::string& name) { + auto node = sofa::core::objectmodel::New(name); + return std::move(node); } -py_shared_ptr __init__(const std::string& name, const py::kwargs& kwargs) { - auto dag_node = sofa::core::objectmodel::New(name); - - setDataFromKwargs(dag_node.get(), kwargs); - - return std::move(dag_node); +py_shared_ptr __init_kwarged__(const std::string& name, const py::kwargs& kwargs) { + auto node = sofa::core::objectmodel::New(name); + setDataFromKwargs(node.get(), kwargs); + return std::move(node); } /// Method: init (beware this is not the python __init__, this is sofa's init()) @@ -687,9 +685,9 @@ void moduleAddNode(py::module &m) { return py::cast(dynamic_cast(object->toBaseNode())); }); - p.def(py::init(&__init__noname), sofapython3::doc::sofa::core::Node::init); - p.def(py::init(&__init__no_kwargs__), sofapython3::doc::sofa::core::Node::init1Arg, py::arg("name")); - p.def(py::init(&__init__), sofapython3::doc::sofa::core::Node::init1Arg); + p.def(py::init(&__init_noname__), sofapython3::doc::sofa::core::Node::init); + p.def(py::init(&__init_named__), sofapython3::doc::sofa::core::Node::init1Arg, py::arg("name")); + p.def(py::init(&__init_kwarged__), sofapython3::doc::sofa::core::Node::init1Arg, py::arg("name")); p.def("init", &init, sofapython3::doc::sofa::core::Node::initSofa ); p.def("add", &addKwargs, sofapython3::doc::sofa::core::Node::addKwargs); p.def("addObject", &addObjectKwargs, sofapython3::doc::sofa::core::Node::addObjectKwargs);