diff --git a/include/eigenpy/details.hpp b/include/eigenpy/details.hpp index 58ed6ad064ebcd0e55ad55bae0dc989022d65d4d..f431c91ddbb66cc272572d675607998ba95bdd16 100644 --- a/include/eigenpy/details.hpp +++ b/include/eigenpy/details.hpp @@ -49,6 +49,20 @@ namespace boost { namespace python { namespace detail { std::size_t, value = sizeof(MatType)); }; + template<class MatType> + struct referent_size<Eigen::PlainObjectBase<MatType>&> + { + BOOST_STATIC_CONSTANT( + std::size_t, value = sizeof(MatType)); + }; + + template<class MatType> + struct referent_size<Eigen::PlainObjectBase<MatType> > + { + BOOST_STATIC_CONSTANT( + std::size_t, value = sizeof(MatType)); + }; + }}} namespace eigenpy diff --git a/include/eigenpy/eigen-from-python.hpp b/include/eigenpy/eigen-from-python.hpp index 83beda216ff335ae42e7ab291d725d8dbf578c9c..1a55bcbaba45bdba843a86a979c41bf5f046fb3c 100644 --- a/include/eigenpy/eigen-from-python.hpp +++ b/include/eigenpy/eigen-from-python.hpp @@ -173,6 +173,14 @@ namespace boost { namespace python { namespace converter { EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(Derived const &) }; + /// \brief Template specialization of rvalue_from_python_data + template<typename Derived> + struct rvalue_from_python_data<Eigen::PlainObjectBase<Derived> const &> + : rvalue_from_python_data_eigen<Derived const &> + { + EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(Derived const &) + }; + template<typename MatType, int Options, typename Stride> struct rvalue_from_python_data<Eigen::Ref<MatType,Options,Stride> &> : rvalue_from_python_storage<Eigen::Ref<MatType,Options,Stride> &> @@ -425,6 +433,10 @@ namespace eigenpy typedef Eigen::EigenBase<MatType> EigenBase; EigenFromPy<EigenBase>::registration(); + // Add conversion to Eigen::PlainObjectBase<MatType> + typedef Eigen::PlainObjectBase<MatType> PlainObjectBase; + EigenFromPy<PlainObjectBase>::registration(); + #if EIGEN_VERSION_AT_LEAST(3,2,0) // Add conversion to Eigen::Ref<MatType> typedef Eigen::Ref<MatType> RefType; @@ -464,6 +476,20 @@ namespace eigenpy &EigenFromPy::construct,bp::type_id<Base>()); } }; + + template<typename MatType> + struct EigenFromPy< Eigen::PlainObjectBase<MatType> > : EigenFromPy<MatType> + { + typedef EigenFromPy<MatType> EigenFromPyDerived; + typedef Eigen::PlainObjectBase<MatType> Base; + + static void registration() + { + bp::converter::registry::push_back + (reinterpret_cast<void *(*)(_object *)>(&EigenFromPy::convertible), + &EigenFromPy::construct,bp::type_id<Base>()); + } + }; #if EIGEN_VERSION_AT_LEAST(3,2,0)