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
4 changes: 2 additions & 2 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Download SOFA nightly build
run: |
curl --output sofa.zip -L \
https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries-v20.12/lastSuccessfulBuild/CI_SCOPE=binaries_minimal/artifact/MacOS/*zip*/MacOS.zip
https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries/lastSuccessfulBuild/CI_SCOPE=binaries_minimal/artifact/MacOS/*zip*/MacOS.zip

- name: Install SOFA nightly build
run: |
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:
- name: Download SOFA nightly build
run: |
curl --output sofa.zip -L \
https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries-v20.12/lastSuccessfulBuild/CI_SCOPE=binaries_minimal/artifact/MacOS/*zip*/MacOS.zip
https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries/lastSuccessfulBuild/CI_SCOPE=binaries_minimal/artifact/MacOS/*zip*/MacOS.zip

- name: Install SOFA nightly build
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: Download SOFA nightly build
run: |
curl --output sofa.zip -L \
https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries-v20.12/lastSuccessfulBuild/CI_SCOPE=binaries_minimal/artifact/Linux/*zip*/Linux.zip
https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries/lastSuccessfulBuild/CI_SCOPE=binaries_minimal/artifact/Linux/*zip*/Linux.zip

- name: Install SOFA nightly build
run: |
Expand Down Expand Up @@ -123,7 +123,7 @@ jobs:
- name: Download SOFA nightly build
run: |
curl --output sofa.zip -L \
https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries-v20.12/lastSuccessfulBuild/CI_SCOPE=binaries_minimal/artifact/Linux/*zip*/Linux.zip
https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries/lastSuccessfulBuild/CI_SCOPE=binaries_minimal/artifact/Linux/*zip*/Linux.zip

- name: Install SOFA nightly build
run: |
Expand Down
2 changes: 1 addition & 1 deletion Plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ endif(SP3_BUILD_TEST)

find_package(pybind11 CONFIG REQUIRED)
find_package(SofaFramework REQUIRED)
find_package(SofaSimulation REQUIRED)
find_package(SofaSimulationGraph REQUIRED)

add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES})
add_library(SofaPython3::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
Expand Down
2 changes: 1 addition & 1 deletion Plugin/PluginConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

find_package(pybind11 CONFIG REQUIRED)
find_package(SofaFramework REQUIRED)
find_package(SofaSimulation REQUIRED)
find_package(SofaSimulationGraph REQUIRED)

# If we are importing this config file and the target is not yet there this is indicating that
# target is an imported one. So we include it
Expand Down
2 changes: 1 addition & 1 deletion Plugin/src/SofaPython3/PythonEnvironment.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include <vector>
#include <string>

#include <sofa/helper/logging/FileInfo.h>

/// Fixes compile errors:
/// removing all slots macros is necessary if embedded in a Qt project
Expand Down
4 changes: 3 additions & 1 deletion Plugin/src/SofaPython3/SceneLoaderPY3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ using sofa::simulation::graph::DAGNode;
#include <pybind11/embed.h>
namespace py = pybind11;

using namespace sofa::core::objectmodel;
#include <sofa/helper/system/SetDirectory.h>
using sofa::helper::system::SetDirectory;

using namespace sofa::core::objectmodel;

MSG_REGISTER_CLASS(sofapython3::SceneLoaderPY3, "SofaPython3::SceneLoader")

PYBIND11_DECLARE_HOLDER_TYPE(Base, sofa::core::sptr<Base>, true)
Expand Down
8 changes: 6 additions & 2 deletions bindings/BindingsConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ find_package(SofaDeformable REQUIRED)
# Required by the bindings Sofa.Components, Sofa.Core, Sofa.Helper, Sofa.Simulation, Sofa.Types, SofaGui
find_package(SofaFramework REQUIRED)

# Required by the bindings Sofa.Core, Sofa.Simulation, SofaRuntime
find_package(SofaSimulation REQUIRED)
# Required by the bindings Sofa.Simulation, SofaRuntime
find_package(SofaSimulationGraph REQUIRED)

# Required by the bindings SofaRuntime
find_package(SofaSimulationCommon REQUIRED)

# Required by the bindings SofaGui
find_package(Sofa.GL QUIET)
find_package(SofaGui REQUIRED)

# Required by the bindings Sofa.Core
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
// Imports for getCategories
#include <sofa/core/objectmodel/ContextObject.h>
#include <sofa/core/visual/VisualModel.h>
#include <sofa/core/BaseMapping.h>
#include <sofa/core/BehaviorModel.h>
#include <sofa/core/CollisionModel.h>
#include <sofa/core/behavior/BaseMechanicalState.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <sofa/core/behavior/MechanicalState.h>
#include <sofa/core/behavior/ForceField.h>
#include <sofa/core/MechanicalParams.h>
#include <sofa/core/behavior/MultiMatrixAccessor.h>

#include <SofaPython3/PythonEnvironment.h>
using sofapython3::PythonEnvironment;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <SofaPython3/Sofa/Core/Binding_PythonScriptEvent.h>
#include <SofaPython3/PythonFactory.h>
#include <sofa/core/objectmodel/Event.h>
#include <sofa/simulation/Node.h>

/// Makes an alias for the pybind11 namespace to increase readability.
namespace py { using namespace pybind11; }
Expand All @@ -30,7 +31,7 @@ using namespace pybind11::literals;

SOFA_EVENT_CPP(PythonScriptEvent)

PythonScriptEvent::PythonScriptEvent(sofa::simulation::Node::SPtr sender, const char* eventName, py::object userData)
PythonScriptEvent::PythonScriptEvent(sofa::core::sptr<sofa::simulation::Node> sender, const char* eventName, py::object userData)
: sofa::core::objectmodel::ScriptEvent(sender,eventName)
, m_userData(userData){}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <pybind11/pybind11.h>
#include <sofa/core/objectmodel/ScriptEvent.h>
#include <sofa/simulation/Node.h>

#include <SofaPython3/config.h>

Expand All @@ -32,7 +33,7 @@ class PythonScriptEvent : public sofa::core::objectmodel::ScriptEvent
{
SOFA_EVENT_H(PythonScriptEvent)
public:
PythonScriptEvent(sofa::simulation::Node::SPtr sender, const char* eventName, pybind11::object userData=pybind11::none());
PythonScriptEvent(sofa::core::sptr<sofa::simulation::Node> sender, const char* eventName, pybind11::object userData=pybind11::none());
~PythonScriptEvent() override;
pybind11::object getUserData() const { return m_userData; }
inline static const char* GetClassName() { return "PythonScriptEvent"; }
Expand Down
1 change: 0 additions & 1 deletion bindings/Sofa/src/SofaPython3/Sofa/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ if (NOT TARGET SofaPython3::Plugin)
endif()

find_package(SofaFramework REQUIRED)
find_package(SofaSimulation REQUIRED)
find_package(SofaBaseCollision REQUIRED)
find_package(SofaBaseVisual REQUIRED)
find_package(SofaBaseUtils REQUIRED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if (NOT TARGET SofaPython3::Plugin)
endif()

find_package(SofaFramework REQUIRED)
find_package(SofaSimulation REQUIRED)
find_package(SofaSimulationGraph REQUIRED)

SP3_add_python_module(
TARGET ${PROJECT_NAME}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
#include <pybind11/pybind11.h>

#include <sofa/simulation/Simulation.h>
#include <sofa/simulation/Node.h>
using sofa::simulation::Simulation;

#include <SofaSimulationGraph/DAGSimulation.h>
using sofa::simulation::graph::DAGSimulation;

#include <sofa/simulation/Node.h>
using sofa::simulation::Node;
using namespace pybind11::literals;

Expand Down
2 changes: 1 addition & 1 deletion bindings/SofaGui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ SP3_add_python_module(
DESTINATION Sofa
SOURCES ${SOURCE_FILES}
HEADERS ${HEADER_FILES}
DEPENDS SofaCore SofaGuiCommon SofaGuiMain SofaPython3::Plugin SofaPython3::Bindings.Sofa.Core
DEPENDS SofaCore SofaGuiCommon SofaGui SofaPython3::Plugin SofaPython3::Bindings.Sofa.Core
)
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <SofaPython3/SofaGui/Binding_GUIManager.h>
#include <sofa/gui/GUIManager.h>
#include <sofa/gui/BaseGUI.h>
#include <sofa/simulation/Node.h>

/// Makes an alias for the pybind11 namespace to increase readability.
namespace py { using namespace pybind11; }
Expand Down
4 changes: 2 additions & 2 deletions bindings/SofaGui/src/SofaPython3/SofaGui/Module_SofaGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include <pybind11/pybind11.h>

#include <sofa/gui/Main.h>
#include <SofaGui/initSofaGui.h>
#include <sofa/core/init.h>

#include "Binding_BaseGui.h"
Expand Down Expand Up @@ -57,7 +57,7 @@ PYBIND11_MODULE(Gui, m) {

// This is needed to make sure the GuiMain library (libSofaGuiMain.so) is correctly
// linked since the GUIs are statically created during the load of the library.
sofa::gui::initMain();
sofa::gui::initSofaGui();
sofa::core::init();

moduleAddBaseGui(m);
Expand Down
3 changes: 2 additions & 1 deletion bindings/SofaRuntime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ set(HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/src/SofaPython3/SofaRuntime/Timer/Submodule_Timer_doc.h
)

find_package(SofaSimulation REQUIRED)
find_package(SofaSimulationGraph REQUIRED)
find_package(SofaSimulationCommon REQUIRED)

SP3_add_python_package(
SOURCE_DIRECTORY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
******************************************************************************/

#include <sofa/helper/AdvancedTimer.h>
#include <stack>
using sofa::helper::AdvancedTimer;

#include "Submodule_Timer.h"
#include "Submodule_Timer_doc.h"

#include <stack>

namespace sofapython3
{
Expand Down
14 changes: 12 additions & 2 deletions bindings/SofaTypes/src/SofaPython3/SofaTypes/Binding_Vec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "Binding_Vec.h"
#include <functional>
#include <pybind11/operators.h>
#include <sstream>
using sofa::type::Vec;

#define BINDING_VEC_MAKE_NAME(N, T) \
std::string(std::string("Vec") + std::to_string(N) + typeid(T).name())
Expand Down Expand Up @@ -188,7 +190,7 @@ py::class_<Vec<N,T>> addVec(py::module &m)
p.def("normalized", &VecClass::normalized);
p.def("sum", &VecClass::sum);
p.def("dot", [](const VecClass &self, const VecClass &b) {
return sofa::defaulttype::dot(self, b);
return sofa::type::dot(self, b);
});


Expand Down Expand Up @@ -217,7 +219,15 @@ T addCross(T p)
{
p.def("cross", [](typename T::type& a, typename T::type& b)
{
return sofa::defaulttype::cross(a,b);
if constexpr (T::type::spatial_dimensions == 2 || T::type::spatial_dimensions == 3)
{
return sofa::type::cross(a, b);
}
else
{
// can only call cross with vec2 or vec3
return T();
}
});
return p;
}
Expand Down
11 changes: 7 additions & 4 deletions bindings/SofaTypes/src/SofaPython3/SofaTypes/Binding_Vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@
namespace py = pybind11;
using namespace pybind11::literals;

#include <sofa/defaulttype/Vec.h>
using sofa::defaulttype::Vec;
#include <sofa/type/Vec.h>
namespace sofa::type {
template <unsigned int N, class T>
class Vec;
}

namespace pyVec {
template <sofa::Size N, class T>
std::string __str__(const Vec<N, T> &self, bool repr = false);
template <unsigned int N, class T>
std::string __str__(const sofa::type::Vec<N, T> &self, bool repr = false);
} // namespace pyVec

void moduleAddVec(py::module &m);