diff --git a/bindings/Modules/src/SofaPython3/SofaDeformable/Binding_CorotationalFEMForceField.cpp b/bindings/Modules/src/SofaPython3/SofaDeformable/Binding_CorotationalFEMForceField.cpp
new file mode 100644
index 00000000..d83287ce
--- /dev/null
+++ b/bindings/Modules/src/SofaPython3/SofaDeformable/Binding_CorotationalFEMForceField.cpp
@@ -0,0 +1,74 @@
+/******************************************************************************
+* SofaPython3 plugin *
+* (c) 2021 CNRS, University of Lille, INRIA *
+* *
+* This program is free software; you can redistribute it and/or modify it *
+* under the terms of the GNU Lesser General Public License as published by *
+* the Free Software Foundation; either version 2.1 of the License, or (at *
+* your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, but WITHOUT *
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
+* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
+* for more details. *
+* *
+* You should have received a copy of the GNU Lesser General Public License *
+* along with this program. If not, see . *
+*******************************************************************************
+* Contact information: contact@sofa-framework.org *
+******************************************************************************/
+#include
+
+#include
+
+#include
+#include
+
+#include
+#include
+
+#include
+#include
+
+namespace sofapython3
+{
+namespace py = pybind11;
+
+template
+void bindCorotationalFEMForceField(py::module& m, const std::string& elementName)
+{
+ using ForceField = sofa::component::solidmechanics::fem::elastic::CorotationalFEMForceField;
+
+ const std::string pyclassName = std::string("CorotationalFEMForceField") + DataTypes::Name() + elementName;
+ py::class_, py_shared_ptr> f(
+ m, pyclassName.c_str(), py::multiple_inheritance());
+
+ f.def("getElementRotations", [](const ForceField& self)
+ {
+ constexpr py::ssize_t dim = DataTypes::spatial_dimensions;
+ const auto& rotations = self.getElementRotations();
+ py::array_t result({static_cast(rotations.size()), dim, dim});
+ SReal* out = result.mutable_data();
+ for (const auto& rotation : rotations)
+ out = std::copy_n(rotation.ptr(), dim * dim, out);
+ return result;
+ }, "Rotation of every element, as last computed: shape (nb_elements, spatial_dimension, spatial_dimension).");
+
+ PythonFactory::registerType([](sofa::core::objectmodel::Base* object)
+ {
+ return py::cast(dynamic_cast(object));
+ });
+}
+
+void moduleAddCorotationalFEMForceField(py::module& m)
+{
+ using namespace sofa::defaulttype;
+ using namespace sofa::geometry;
+
+ bindCorotationalFEMForceField(m, "Triangle");
+ bindCorotationalFEMForceField(m, "Quad");
+ bindCorotationalFEMForceField(m, "Tetrahedron");
+ bindCorotationalFEMForceField(m, "Hexahedron");
+}
+
+} // namespace sofapython3
diff --git a/bindings/Modules/src/SofaPython3/SofaDeformable/Binding_CorotationalFEMForceField.h b/bindings/Modules/src/SofaPython3/SofaDeformable/Binding_CorotationalFEMForceField.h
new file mode 100644
index 00000000..c34c5834
--- /dev/null
+++ b/bindings/Modules/src/SofaPython3/SofaDeformable/Binding_CorotationalFEMForceField.h
@@ -0,0 +1,27 @@
+/******************************************************************************
+* SofaPython3 plugin *
+* (c) 2021 CNRS, University of Lille, INRIA *
+* *
+* This program is free software; you can redistribute it and/or modify it *
+* under the terms of the GNU Lesser General Public License as published by *
+* the Free Software Foundation; either version 2.1 of the License, or (at *
+* your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, but WITHOUT *
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
+* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
+* for more details. *
+* *
+* You should have received a copy of the GNU Lesser General Public License *
+* along with this program. If not, see . *
+*******************************************************************************
+* Contact information: contact@sofa-framework.org *
+******************************************************************************/
+#pragma once
+
+#include
+
+namespace sofapython3
+{
+void moduleAddCorotationalFEMForceField(pybind11::module& m);
+}
diff --git a/bindings/Modules/src/SofaPython3/SofaDeformable/CMakeLists.txt b/bindings/Modules/src/SofaPython3/SofaDeformable/CMakeLists.txt
index c884ff1a..edc2a3c9 100644
--- a/bindings/Modules/src/SofaPython3/SofaDeformable/CMakeLists.txt
+++ b/bindings/Modules/src/SofaPython3/SofaDeformable/CMakeLists.txt
@@ -2,6 +2,7 @@ project(Bindings.Modules.SofaDeformable)
set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/Binding_CauchyStress.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/Binding_CorotationalFEMForceField.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Binding_LameParameters.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Binding_LinearSpring.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Binding_SpringForceField.cpp
@@ -10,6 +11,7 @@ set(SOURCE_FILES
set(HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/Binding_CauchyStress.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/Binding_CorotationalFEMForceField.h
${CMAKE_CURRENT_SOURCE_DIR}/Binding_LameParameters.h
${CMAKE_CURRENT_SOURCE_DIR}/Binding_LinearSpring.h
${CMAKE_CURRENT_SOURCE_DIR}/Binding_LinearSpring_doc.h
diff --git a/bindings/Modules/src/SofaPython3/SofaDeformable/Module_SofaDeformable.cpp b/bindings/Modules/src/SofaPython3/SofaDeformable/Module_SofaDeformable.cpp
index 09b58d72..13b47f2b 100644
--- a/bindings/Modules/src/SofaPython3/SofaDeformable/Module_SofaDeformable.cpp
+++ b/bindings/Modules/src/SofaPython3/SofaDeformable/Module_SofaDeformable.cpp
@@ -23,6 +23,7 @@
#include
#include
#include
+#include
namespace py { using namespace pybind11; }
@@ -38,6 +39,7 @@ PYBIND11_MODULE(SofaDeformable, m)
moduleAddSpringForceField(m);
moduleAddLameParameters(m);
moduleAddCauchyStress(m);
+ moduleAddCorotationalFEMForceField(m);
}
} // namespace sofapython3