Unverified Commit 24e1044e authored by Justin Carpentier's avatar Justin Carpentier Committed by GitHub
Browse files

Merge pull request #136 from jcarpent/devel

Improve conversion
parents b20044cd 46756995
......@@ -22,6 +22,7 @@ namespace eigenpy
struct call< Eigen::AngleAxis<Scalar> >
{
typedef Eigen::AngleAxis<Scalar> AngleAxis;
static inline void expose()
{
AngleAxisVisitor<AngleAxis>::expose();
......@@ -46,6 +47,7 @@ namespace eigenpy
typedef typename AngleAxis::Matrix3 Matrix3;
typedef typename Eigen::Quaternion<Scalar,0> Quaternion;
typedef Eigen::RotationBase<AngleAxis,3> RotationBase;
public:
......@@ -136,6 +138,9 @@ namespace eigenpy
"AngleAxis representation of a rotation.\n\n",
bp::no_init)
.def(AngleAxisVisitor<AngleAxis>());
// Cast to Eigen::RotationBase and vice-versa
bp::implicitly_convertible<AngleAxis,RotationBase>();
}
};
......
......@@ -515,34 +515,8 @@ namespace eigenpy
}
};
template<typename MatType>
struct EigenFromPy< Eigen::MatrixBase<MatType> >
{
typedef EigenFromPy<MatType> EigenFromPyDerived;
typedef Eigen::MatrixBase<MatType> Base;
/// \brief Determine if pyObj can be converted into a MatType object
static void* convertible(PyArrayObject* pyObj)
{
return EigenFromPyDerived::convertible(pyObj);
}
/// \brief Allocate memory and copy pyObj in the new storage
static void construct(PyObject* pyObj,
bp::converter::rvalue_from_python_stage1_data* memory)
{
EigenFromPyDerived::construct(pyObj,memory);
}
static void registration()
{
bp::converter::registry::push_back
(reinterpret_cast<void *(*)(_object *)>(&EigenFromPy::convertible),
&EigenFromPy::construct,bp::type_id<Base>());
}
};
template<typename MatType,typename EigenEquivalentType>
EIGENPY_DEPRECATED
void enableEigenPySpecific()
{
enableEigenPySpecific<MatType>();
......@@ -557,7 +531,8 @@ namespace eigenpy
// Add also conversion to Eigen::MatrixBase<MatType>
typedef Eigen::MatrixBase<MatType> MatTypeBase;
EigenFromPy<MatTypeBase>::registration();
bp::implicitly_convertible<MatType,MatTypeBase>();
bp::implicitly_convertible<MatTypeBase,MatType>();
}
};
......@@ -585,7 +560,6 @@ namespace eigenpy
bp::to_python_converter<MatType,EigenToPy<MatType> >();
EigenFromPyConverter<MatType>::registration();
}
} // namespace eigenpy
......
......@@ -263,9 +263,11 @@ namespace eigenpy
"'q*v' (rotating 'v' by 'q'), "
"'q==q', 'q!=q', 'q[0..3]'.",
bp::no_init)
.def(QuaternionVisitor<Quaternion>())
;
.def(QuaternionVisitor<Quaternion>());
// Cast to Eigen::QuaternionBase and vice-versa
bp::implicitly_convertible<Quaternion,QuaternionBase >();
bp::implicitly_convertible<QuaternionBase,Quaternion >();
}
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment