diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_BaseObject.cpp b/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_BaseComponent.cpp similarity index 65% rename from bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_BaseObject.cpp rename to bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_BaseComponent.cpp index 6740de72b..a211d32fc 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_BaseObject.cpp +++ b/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_BaseComponent.cpp @@ -19,8 +19,8 @@ ******************************************************************************/ #include -#include -#include +#include +#include #include #include @@ -61,11 +61,11 @@ namespace py { using namespace pybind11; } using sofa::core::objectmodel::BaseData; using sofa::core::objectmodel::Base; -using sofa::core::objectmodel::BaseObject; +using sofa::core::objectmodel::BaseComponent; namespace sofapython3 { -py::object getItem(const BaseObject& self, const std::string& path) +py::object getItem(const BaseComponent& self, const std::string& path) { if (path.empty()) return py::cast(self); @@ -79,19 +79,19 @@ py::object getItem(const BaseObject& self, const std::string& path) throw py::value_error("Invalid syntax"); // should never get there } -std::string getLinkPath(const BaseObject *self) +std::string getLinkPath(const BaseComponent *self) { return std::string("@")+self->getPathName(); } -void computeBBox(BaseObject *self) +void computeBBox(BaseComponent *self) { self->computeBBox(sofa::core::execparams::defaultInstance(), false); } -py::list getSlaves(BaseObject &self) +py::list getSlaves(BaseComponent &self) { - const BaseObject::VecSlaves& slaves = self.getSlaves(); + const BaseComponent::VecSlaves& slaves = self.getSlaves(); py::list slaveList; for (auto slave : slaves){ slaveList.append(py::cast(slave)); @@ -99,7 +99,7 @@ py::list getSlaves(BaseObject &self) return slaveList; } -py::object getContext(const BaseObject &self) +py::object getContext(const BaseComponent &self) { const sofa::core::objectmodel::BaseContext* context = self.getContext(); if (context){ @@ -108,16 +108,16 @@ py::object getContext(const BaseObject &self) return py::none(); } -py::object getMaster(const BaseObject &self) +py::object getMaster(const BaseComponent &self) { - const BaseObject* master = self.getMaster(); + const BaseComponent* master = self.getMaster(); if (master){ return py::cast(master); } return py::none(); } -py::object getTarget(BaseObject *self) +py::object getTarget(BaseComponent *self) { if (!self) return py::none(); @@ -133,7 +133,7 @@ py::object getTarget(BaseObject *self) return py::none() ; } -py::object getCategories(BaseObject *self) +py::object getCategories(BaseComponent *self) { std::vector categories; const sofa::core::objectmodel::BaseClass* c=self->getClass(); @@ -142,12 +142,12 @@ py::object getCategories(BaseObject *self) return std::move(l); } -std::string getAsACreateObjectParameter(BaseObject *self) +std::string getAsACreateObjectParameter(BaseComponent *self) { return getLinkPath(self); } -void setSrc(BaseObject &self, char *valueString, BaseObject *loader) +void setSrc(BaseComponent &self, char *valueString, BaseComponent *loader) { self.setSrc(valueString,loader); } @@ -166,7 +166,7 @@ void setSrc(BaseObject &self, char *valueString, BaseObject *loader) /// In the example above, node1 and node2 can be inferred as being nodes without performing any checks. /// object1 can be a node or an object, but cannot be a datafield nor a link /// value can be a node or an object (if object1 is a node), or must be a data (if object1 is an object) -py::object __getitem__(BaseObject &self, std::string s) +py::object __getitem__(BaseComponent &self, std::string s) { if (s[0] == '.') s.erase(s.begin()); @@ -189,49 +189,49 @@ py::object __getitem__(BaseObject &self, std::string s) return getItem(self, s); } -auto getBaseObjectBinding(py::module& m) +auto getBaseComponentBinding(py::module& m) { - /// Register the BaseObject binding into the pybind11 typing system - static py::class_>p(m, "Object", sofapython3::doc::baseObject::Class); + /// Register the BaseComponent binding into the pybind11 typing system + static py::class_>p(m, "Object", sofapython3::doc::BaseComponent::Class); return p; } -void moduleForwardAddBaseObject(py::module& m) +void moduleForwardAddBaseComponent(py::module& m) { - getBaseObjectBinding(m); + getBaseComponentBinding(m); } -void moduleAddBaseObject(py::module& m) +void moduleAddBaseComponent(py::module& m) { - auto p = getBaseObjectBinding(m); + auto p = getBaseComponentBinding(m); - /// Register the BaseObject binding into the downcasting subsystem - PythonFactory::registerType( + /// Register the BaseComponent binding into the downcasting subsystem + PythonFactory::registerType( [](sofa::core::objectmodel::Base* object) { - return py::cast(py_shared_ptr(object->toBaseObject())); + return py::cast(py_shared_ptr(object->toBaseComponent())); }); - p.def("init", &BaseObject::init, sofapython3::doc::baseObject::init); - p.def("reinit", &BaseObject::reinit, sofapython3::doc::baseObject::reinit); - p.def("getPathName", &BaseObject::getPathName, sofapython3::doc::baseObject::getPathName); - p.def("getLinkPath", [](const BaseObject &self){ return std::string("@") + self.getPathName(); }, sofapython3::doc::baseObject::getLink); - p.def("getSlaves", getSlaves, sofapython3::doc::baseObject::getSlaves); - p.def("getContext", getContext, sofapython3::doc::baseObject::getContext); - p.def("getMaster", getMaster, sofapython3::doc::baseObject::getMaster); - p.def("addSlave", &BaseObject::addSlave, sofapython3::doc::baseObject::addSlave); - p.def("storeResetState", &BaseObject::storeResetState, sofapython3::doc::baseObject::storeResetState); - p.def("reset", &BaseObject::reset, sofapython3::doc::baseObject::reset); - p.def("getTarget", getTarget, sofapython3::doc::baseObject::getTarget); - p.def("getCategories", getCategories, sofapython3::doc::baseObject::getCategories); - p.def("bwdInit", &BaseObject::bwdInit, sofapython3::doc::baseObject::bwdInit); - p.def("cleanup", &BaseObject::cleanup, sofapython3::doc::baseObject::cleanup); - p.def("computeBBox", &computeBBox, sofapython3::doc::baseObject::computeBBox); - p.def("getLinkPath", &getLinkPath, sofapython3::doc::baseObject::getLinkPath); - p.def("getAsACreateObjectParameter", getAsACreateObjectParameter, sofapython3::doc::baseObject::getAsACreateObjectParameter); - p.def("setSrc", setSrc, sofapython3::doc::baseObject::setSrc); - p.def("computeBBox", &BaseObject::computeBBox, sofapython3::doc::baseObject::computeBBox); - p.def("__getitem__", __getitem__, sofapython3::doc::baseObject::__getitem__); + p.def("init", &BaseComponent::init, sofapython3::doc::BaseComponent::init); + p.def("reinit", &BaseComponent::reinit, sofapython3::doc::BaseComponent::reinit); + p.def("getPathName", &BaseComponent::getPathName, sofapython3::doc::BaseComponent::getPathName); + p.def("getLinkPath", [](const BaseComponent &self){ return std::string("@") + self.getPathName(); }, sofapython3::doc::BaseComponent::getLink); + p.def("getSlaves", getSlaves, sofapython3::doc::BaseComponent::getSlaves); + p.def("getContext", getContext, sofapython3::doc::BaseComponent::getContext); + p.def("getMaster", getMaster, sofapython3::doc::BaseComponent::getMaster); + p.def("addSlave", &BaseComponent::addSlave, sofapython3::doc::BaseComponent::addSlave); + p.def("storeResetState", &BaseComponent::storeResetState, sofapython3::doc::BaseComponent::storeResetState); + p.def("reset", &BaseComponent::reset, sofapython3::doc::BaseComponent::reset); + p.def("getTarget", getTarget, sofapython3::doc::BaseComponent::getTarget); + p.def("getCategories", getCategories, sofapython3::doc::BaseComponent::getCategories); + p.def("bwdInit", &BaseComponent::bwdInit, sofapython3::doc::BaseComponent::bwdInit); + p.def("cleanup", &BaseComponent::cleanup, sofapython3::doc::BaseComponent::cleanup); + p.def("computeBBox", &computeBBox, sofapython3::doc::BaseComponent::computeBBox); + p.def("getLinkPath", &getLinkPath, sofapython3::doc::BaseComponent::getLinkPath); + p.def("getAsACreateObjectParameter", getAsACreateObjectParameter, sofapython3::doc::BaseComponent::getAsACreateObjectParameter); + p.def("setSrc", setSrc, sofapython3::doc::BaseComponent::setSrc); + p.def("computeBBox", &BaseComponent::computeBBox, sofapython3::doc::BaseComponent::computeBBox); + p.def("__getitem__", __getitem__, sofapython3::doc::BaseComponent::__getitem__); } } /// namespace sofapython3 diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_BaseObject.h b/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_BaseComponent.h similarity index 88% rename from bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_BaseObject.h rename to bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_BaseComponent.h index 3908e6044..9a2a3627f 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_BaseObject.h +++ b/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_BaseComponent.h @@ -26,10 +26,10 @@ namespace sofapython3 { -pybind11::object getItem(const sofa::core::objectmodel::BaseObject & self, const std::string& path); +pybind11::object getItem(const sofa::core::objectmodel::BaseComponent & self, const std::string& path); -void moduleForwardAddBaseObject(pybind11::module &m); -void moduleAddBaseObject(pybind11::module &m); +void moduleForwardAddBaseComponent(pybind11::module &m); +void moduleAddBaseComponent(pybind11::module &m); } /// namespace sofapython diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_BaseObject_doc.h b/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_BaseComponent_doc.h similarity index 87% rename from bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_BaseObject_doc.h rename to bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_BaseComponent_doc.h index b1dd790ba..404ebd5f0 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_BaseObject_doc.h +++ b/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_BaseComponent_doc.h @@ -20,7 +20,7 @@ #pragma once -namespace sofapython3::doc::baseObject +namespace sofapython3::doc::BaseComponent { static auto Class = R"( @@ -61,41 +61,41 @@ static auto reinit = )"; static auto getPathName = R"( - Return the full path name of this baseObject + Return the full path name of this BaseComponent :rtype: string )"; static auto getLink = R"( - Return the link of the baseObject - :param self: the baseObject itself - :type self: baseObject + Return the link of the BaseComponent + :param self: the BaseComponent itself + :type self: BaseComponent :rtype: string )"; static auto getSlaves = R"( - Return the slaves of the baseObject. + Return the slaves of the BaseComponent. :rtype: list )"; static auto getContext = R"( - Return the conext of the baseObject. + Return the conext of the BaseComponent. :rtype: BaseContext )"; static auto getMaster = R"( - Return the master of the baseObject. - :rtype: BaseObject + Return the master of the BaseComponent. + :rtype: BaseComponent )"; static auto addSlave = R"( - Add a slave to the master BaseObject. + Add a slave to the master BaseComponent. :param slave: the slave to be added. - :type slave: BaseObject + :type slave: BaseComponent )"; static auto storeResetState = @@ -111,13 +111,13 @@ static auto reset = static auto getName = R"( - Accessor to the baseObject name. + Accessor to the BaseComponent name. :rtype: string )"; static auto getTarget = R"( - Return the target (plugin) that contains the current baseObject. + Return the target (plugin) that contains the current BaseComponent. :rtype: string )"; @@ -151,13 +151,13 @@ static auto computeBBox = static auto getLinkPath = R"( - Return the full path name of this baseObject with an extra prefix '@' + Return the full path name of this BaseComponent with an extra prefix '@' :rtype: string )"; static auto getAsACreateObjectParameter = R"( - Return the full path name of this baseObject with an extra prefix '@' + Return the full path name of this BaseComponent with an extra prefix '@' :rtype: string )"; diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Node.cpp b/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Node.cpp index a290c1b58..85d0de2bf 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Node.cpp +++ b/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Node.cpp @@ -25,6 +25,9 @@ #include #include +#include +using sofa::core::objectmodel::BaseComponent; + #include using sofa::core::objectmodel::BaseData; @@ -44,7 +47,7 @@ using sofa::core::ExecParams; using sofapython3::LinkPath; #include -#include +#include #include #include @@ -138,7 +141,7 @@ py::object getItem(Node& self, std::list& path) if (path.empty()) return py::cast(self); Node* child = self.getChild(path.front()); - BaseObject* obj = self.getObject(path.front()); + BaseComponent* obj = self.getObject(path.front()); BaseData* data = self.findData(path.front()); if (child) { @@ -182,25 +185,25 @@ py_shared_ptr __init_kwarged__(const std::string& name, const py::kwargs& /// Method: init (beware this is not the python __init__, this is sofa's init()) void init(Node& self) { self.init(sofa::core::execparams::defaultInstance()); } -py::object addObject(Node& self, BaseObject * object) +py::object addObject(Node& self, BaseComponent * object) { try { if (self.addObject(object)) return PythonFactory::toPython(object); } catch (...) { - throw py::type_error("Trying to add an object that isn't derived from sofa::core::objectmodel::BaseObject."); + throw py::type_error("Trying to add an object that isn't derived from sofa::core::objectmodel::BaseComponent."); } return py::none(); } -void removeObject(Node& self, BaseObject* object) +void removeObject(Node& self, BaseComponent* object) { self.removeObject(object); } py::object hasObject(Node &n, const std::string &name) { - BaseObject *object = n.getObject(name); + BaseComponent *object = n.getObject(name); if (object) return py::cast(true); return py::cast(false); @@ -216,7 +219,7 @@ py::object getObject(Node &n, const std::string &name, const py::kwargs& kwargs) << PythonEnvironment::getPythonCallingPointString() ; } - BaseObject *object = n.getObject(name); + BaseComponent *object = n.getObject(name); if (object) return PythonFactory::toPython(object); return py::none(); @@ -344,9 +347,9 @@ py::object addObjectKwargs(Node* self, const std::string& type, const py::kwargs /// Implement the addObject function. py::object addKwargs(Node* self, const py::object& callable, const py::kwargs& kwargs) { - if(py::isinstance(callable)) + if(py::isinstance(callable)) { - BaseObject* obj = py::cast(callable); + BaseComponent* obj = py::cast(callable); self->addObject(obj); return py::cast(obj); } @@ -375,7 +378,7 @@ py::object addKwargs(Node* self, const py::object& callable, const py::kwargs& k Base* base = py::cast(c); if(!py::isinstance(c)) { - throw py::value_error("add: the function passed as first argument can only return a Sofa.BaseObject or Sofa.Node object"); + throw py::value_error("add: the function passed as first argument can only return a Sofa.BaseComponent or Sofa.Node object"); } // Set the creation point @@ -516,7 +519,7 @@ py::object __getattr__(py::object pyself, const std::string& name) { Node* selfnode = py::cast(pyself); /// Search in the object lists - BaseObject *object = selfnode->getObject(name); + BaseComponent *object = selfnode->getObject(name); if (object) return PythonFactory::toPython(object); diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Core/CMakeLists.txt b/bindings/Sofa/src/SofaPython3/Sofa/Core/CMakeLists.txt index 8de180d46..5b096833b 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Core/CMakeLists.txt +++ b/bindings/Sofa/src/SofaPython3/Sofa/Core/CMakeLists.txt @@ -8,8 +8,8 @@ set(HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/Binding_DataDict.h ${CMAKE_CURRENT_SOURCE_DIR}/Binding_DataDict_doc.h ${CMAKE_CURRENT_SOURCE_DIR}/Binding_BaseData.h - ${CMAKE_CURRENT_SOURCE_DIR}/Binding_BaseObject.h - ${CMAKE_CURRENT_SOURCE_DIR}/Binding_BaseObject_doc.h + ${CMAKE_CURRENT_SOURCE_DIR}/Binding_BaseComponent.h + ${CMAKE_CURRENT_SOURCE_DIR}/Binding_BaseComponent_doc.h ${CMAKE_CURRENT_SOURCE_DIR}/Binding_BaseCamera.h ${CMAKE_CURRENT_SOURCE_DIR}/Binding_BaseContext.h ${CMAKE_CURRENT_SOURCE_DIR}/Binding_ContactListener.h @@ -63,7 +63,7 @@ set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/Binding_BaseData.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Binding_DataDict.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Binding_DrawTool.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Binding_BaseObject.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Binding_BaseComponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Binding_BaseCamera.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Binding_BaseContext.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Binding_ContactListener.cpp diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Core/Submodule_Core.cpp b/bindings/Sofa/src/SofaPython3/Sofa/Core/Submodule_Core.cpp index f56b278ea..23d0c89ab 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Core/Submodule_Core.cpp +++ b/bindings/Sofa/src/SofaPython3/Sofa/Core/Submodule_Core.cpp @@ -25,7 +25,7 @@ using sofa::helper::logging::Message; #include #include #include -#include +#include #include #include #include @@ -114,7 +114,7 @@ PYBIND11_MODULE(Core, core) /// more details in: https://github.com/sofa-framework/SofaPython3/pull/457 moduleForwardAddBaseClass(core); moduleForwardAddBase(core); - moduleForwardAddBaseObject(core); + moduleForwardAddBaseComponent(core); moduleForwardAddBaseData(core); moduleForwardAddBaseLink(core); moduleForwardAddTopology(core); @@ -138,7 +138,7 @@ PYBIND11_MODULE(Core, core) moduleAddDataLink(core); moduleAddDataVectorString(core); moduleAddDrawTool(core); - moduleAddBaseObject(core); + moduleAddBaseComponent(core); moduleAddBaseCamera(core); moduleAddContactListener(core); moduleAddContext(core); diff --git a/bindings/SofaExporter/src/SofaExporter/Binding_STLExporter.cpp b/bindings/SofaExporter/src/SofaExporter/Binding_STLExporter.cpp index 32f0f51d6..5cfba4e9c 100644 --- a/bindings/SofaExporter/src/SofaExporter/Binding_STLExporter.cpp +++ b/bindings/SofaExporter/src/SofaExporter/Binding_STLExporter.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include using sofa::component::io::mesh::STLExporter; @@ -41,7 +41,7 @@ void moduleAddSTLExporter(py::module &m) return py::cast(dynamic_cast(object)); }); - py::class_> p(m, "STLExporter", sofapython3::doc::SofaExporter::STLExporter::docstring); + py::class_> p(m, "STLExporter", sofapython3::doc::SofaExporter::STLExporter::docstring); p.def("write", &STLExporter::write); } diff --git a/bindings/SofaExporter/src/SofaExporter/Binding_VisualModelOBJExporter.cpp b/bindings/SofaExporter/src/SofaExporter/Binding_VisualModelOBJExporter.cpp index b9dcdfaea..3a9b4af8e 100644 --- a/bindings/SofaExporter/src/SofaExporter/Binding_VisualModelOBJExporter.cpp +++ b/bindings/SofaExporter/src/SofaExporter/Binding_VisualModelOBJExporter.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include using sofa::component::io::mesh::VisualModelOBJExporter; @@ -39,7 +39,7 @@ void moduleAddVisualModelOBJExporter(py::module &m) return py::cast(dynamic_cast(object)); }); - py::class_> p(m, "VisualModelOBJExporter", sofapython3::doc::SofaExporter::VisualModelOBJExporter::docstring); + py::class_> p(m, "VisualModelOBJExporter", sofapython3::doc::SofaExporter::VisualModelOBJExporter::docstring); p.def("write", &VisualModelOBJExporter::write); }