diff --git a/bindings/SofaExporter/CMakeLists.txt b/bindings/SofaExporter/CMakeLists.txt
index e933c2cd..59d9e9cb 100644
--- a/bindings/SofaExporter/CMakeLists.txt
+++ b/bindings/SofaExporter/CMakeLists.txt
@@ -3,10 +3,13 @@ project(Bindings.SofaExporter)
set(HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/src/SofaExporter/Binding_STLExporter.h
${CMAKE_CURRENT_SOURCE_DIR}/src/SofaExporter/Binding_STLExporter_doc.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/SofaExporter/Binding_OBJExporter.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/SofaExporter/Binding_OBJExporter_doc.h
)
set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/src/SofaExporter/Binding_STLExporter.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/SofaExporter/Binding_OBJExporter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/SofaExporter/Module_SofaExporter.cpp
)
diff --git a/bindings/SofaExporter/src/SofaExporter/Binding_OBJExporter.cpp b/bindings/SofaExporter/src/SofaExporter/Binding_OBJExporter.cpp
new file mode 100644
index 00000000..4ad1002a
--- /dev/null
+++ b/bindings/SofaExporter/src/SofaExporter/Binding_OBJExporter.cpp
@@ -0,0 +1,47 @@
+/******************************************************************************
+* 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
+
+using sofa::component::exporter::OBJExporter;
+
+namespace py { using namespace pybind11; }
+
+namespace sofapython3 {
+
+void moduleAddOBJExporter(py::module &m)
+{
+ PythonFactory::registerType([](sofa::core::objectmodel::Base* object)
+ {
+ return py::cast(dynamic_cast(object));
+ });
+
+ py::class_> p(m, "OBJExporter");
+
+ p.def("write", &OBJExporter::write, sofapython3::doc::SofaExporter::OBJExporter::write::docstring);
+}
+
+} // namespace sofapython3
diff --git a/bindings/SofaExporter/src/SofaExporter/Binding_OBJExporter.h b/bindings/SofaExporter/src/SofaExporter/Binding_OBJExporter.h
new file mode 100644
index 00000000..6fd95768
--- /dev/null
+++ b/bindings/SofaExporter/src/SofaExporter/Binding_OBJExporter.h
@@ -0,0 +1,29 @@
+/******************************************************************************
+* 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 moduleAddOBJExporter(pybind11::module &m);
+
+} /// namespace sofapython3
diff --git a/bindings/SofaExporter/src/SofaExporter/Binding_OBJExporter_doc.h b/bindings/SofaExporter/src/SofaExporter/Binding_OBJExporter_doc.h
new file mode 100644
index 00000000..092ccae9
--- /dev/null
+++ b/bindings/SofaExporter/src/SofaExporter/Binding_OBJExporter_doc.h
@@ -0,0 +1,50 @@
+/******************************************************************************
+* 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
+
+namespace sofapython3::doc::SofaExporter::OBJExporter::write {
+
+static auto docstring =
+ R"(
+ Exports an OBJ file
+ ---------------------------------------
+
+ Will export a binary or ascii file depending on the binary flag of OBJExporter
+ Will auto-number the exported files
+
+ Example of use:
+ .. code-block:: python
+
+ import Sofa
+ import SofaExporter
+
+ # Create a new node
+ n = Sofa.Core.Node("root"")
+
+ # Add STLExporter
+ n.addObject("OBJExporter", name="exporter", ...)
+
+ # writes down the stl file
+ n.exporter.write()
+
+ )";
+
+}
diff --git a/bindings/SofaExporter/src/SofaExporter/Module_SofaExporter.cpp b/bindings/SofaExporter/src/SofaExporter/Module_SofaExporter.cpp
index 6bba79c2..297f85aa 100644
--- a/bindings/SofaExporter/src/SofaExporter/Module_SofaExporter.cpp
+++ b/bindings/SofaExporter/src/SofaExporter/Module_SofaExporter.cpp
@@ -22,6 +22,7 @@
namespace py = pybind11;
#include
+#include
namespace sofapython3
{
@@ -43,12 +44,14 @@ PYBIND11_MODULE(SofaExporter, m) {
:toctree: _autosummary/_autosummary
SofaExporter.STLExporter
+ SofaExporter.OBJExporter
)doc";
py::module::import("Sofa.Core");
moduleAddSTLExporter(m);
+ moduleAddOBJExporter(m);
}
} // namespace sofapython3