Skip to content

Commit 5acb326

Browse files
committed
Add basic support for Data<Eigen::MatrixXF> in data
1 parent 9b244d4 commit 5acb326

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Plugin/src/SofaPython3/PythonFactory.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ using sofa::core::objectmodel::Event;
4545

4646
#include <sofa/defaulttype/DataTypeInfo.h>
4747

48+
#include <pybind11/eigen.h>
49+
4850
SOFAPYTHON3_BIND_ATTRIBUTE_ERROR()
4951

5052
/// Makes an alias for the pybind11 namespace to increase readability.
@@ -196,6 +198,10 @@ py::object PythonFactory::valueToPython_ro(sofa::core::objectmodel::BaseData* da
196198
a.attr("flags").attr("writeable") = false;
197199
return std::move(a);
198200
}
201+
if(auto p = dynamic_cast<sofa::core::objectmodel::Data<Eigen::MatrixXf>*>(data)){
202+
const auto matrice = p->getValue();
203+
return py::cast(matrice);
204+
}
199205

200206
/// If this is not the case we return the converted datas (copy)
201207
return convertToPython(data);

0 commit comments

Comments
 (0)