fix compilation with old, and future gcc

This commit is contained in:
Gael Guennebaud 2009-03-10 11:55:50 +00:00
parent 3e4307d8a8
commit 14691d6836
4 changed files with 98 additions and 104 deletions

View File

@ -634,7 +634,8 @@ template<typename Derived> class MatrixBase
NestByValue<StartMinusOne> > HNormalizedReturnType;
const HNormalizedReturnType hnormalized() const;
const Homogeneous<Derived,MatrixBase<Derived>::ColsAtCompileTime==1?Vertical:Horizontal> homogeneous() const;
typedef Homogeneous<Derived,MatrixBase<Derived>::ColsAtCompileTime==1?Vertical:Horizontal> HomogeneousReturnType;
const HomogeneousReturnType homogeneous() const;
/////////// Sparse module ///////////

View File

@ -136,7 +136,7 @@ template<typename MatrixType,int Direction> class Homogeneous
* \sa class Homogeneous
*/
template<typename Derived>
inline const Homogeneous<Derived,MatrixBase<Derived>::ColsAtCompileTime==1?Vertical:Horizontal>
inline const typename MatrixBase<Derived>::HomogeneousReturnType
MatrixBase<Derived>::homogeneous() const
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);

View File

@ -49,6 +49,14 @@ struct ei_transform_left_product_impl;
template<typename Lhs,typename Rhs> struct ei_transform_transform_product_impl;
template< typename Other,
int Mode,
int Dim,
int HDim,
int OtherRows=Other::RowsAtCompileTime,
int OtherCols=Other::ColsAtCompileTime>
struct ei_transform_construct_from_matrix;
/** \geometry_module \ingroup Geometry_Module
*
* \class Transform
@ -205,75 +213,20 @@ public:
inline Transform& operator=(const Transform& other)
{ m_matrix = other.m_matrix; return *this; }
template<typename OtherDerived, bool IsCompact, int _Rows, int _Cols>
struct construct_from_matrix;
template<typename OtherDerived> struct construct_from_matrix<OtherDerived, false, Dim, Dim>
{
static inline void run(Transform *transform, const MatrixBase<OtherDerived>& other)
{
transform->linear() = other;
transform->translation().setZero();
transform->makeAffine();
}
};
template<typename OtherDerived> struct construct_from_matrix<OtherDerived, true, Dim, Dim>
{
static inline void run(Transform *transform, const MatrixBase<OtherDerived>& other)
{
transform->linear() = other;
transform->translation().setZero();
}
};
template<typename OtherDerived> struct construct_from_matrix<OtherDerived, false, Dim, HDim>
{
static inline void run(Transform *transform, const MatrixBase<OtherDerived>& other)
{
transform->affine() = other;
transform->makeAffine();
}
};
template<typename OtherDerived> struct construct_from_matrix<OtherDerived, true, Dim, HDim>
{
static inline void run(Transform *transform, const MatrixBase<OtherDerived>& other)
{ transform->affine() = other; }
};
template<typename OtherDerived> struct construct_from_matrix<OtherDerived, false, HDim, HDim>
{
static inline void run(Transform *transform, const MatrixBase<OtherDerived>& other)
{ transform->matrix() = other; }
};
template<typename OtherDerived> struct construct_from_matrix<OtherDerived, true, HDim, HDim>
{
static inline void run(Transform *transform, const MatrixBase<OtherDerived>& other)
{ transform->matrix() = other.template block<Dim,HDim>(0,0); }
};
typedef ei_transform_take_affine_part<Transform> take_affine_part;
/** Constructs and initializes a transformation from a Dim^2 or a (Dim+1)^2 matrix. */
template<typename OtherDerived>
inline explicit Transform(const MatrixBase<OtherDerived>& other)
{
construct_from_matrix<OtherDerived,
int(Mode)==int(AffineCompact),
int(OtherDerived::RowsAtCompileTime),
int(OtherDerived::ColsAtCompileTime)>::run(this, other);
ei_transform_construct_from_matrix<OtherDerived,Mode,Dim,HDim>::run(this, other.derived());
}
/** Set \c *this from a Dim^2 or (Dim+1)^2 matrix. */
template<typename OtherDerived>
inline Transform& operator=(const MatrixBase<OtherDerived>& other)
{
construct_from_matrix<OtherDerived,
int(Mode)==int(AffineCompact),
int(OtherDerived::RowsAtCompileTime),
int(OtherDerived::ColsAtCompileTime)>::run(this, other);
ei_transform_construct_from_matrix<OtherDerived,Mode,Dim,HDim>::run(this, other.derived());
return *this;
}
@ -282,10 +235,7 @@ public:
{
ei_assert(OtherMode!=Projective && "You cannot directly assign a projective transform to an affine one.");
typedef typename Transform<Scalar,Dim,OtherMode>::MatrixType OtherMatrixType;
construct_from_matrix<OtherMatrixType,
int(Mode)==int(AffineCompact),
int(OtherMatrixType::RowsAtCompileTime),
int(OtherMatrixType::ColsAtCompileTime)>::run(this, other.matrix());
ei_transform_construct_from_matrix<OtherMatrixType,Mode,Dim,HDim>::run(this, other.matrix());
}
template<typename OtherDerived,typename OtherEvalType>
@ -958,6 +908,10 @@ Transform<Scalar,Dim,Mode>::inverse(TransformTraits hint) const
}
}
/*****************************************************
*** Specializations of take affine part ***
*****************************************************/
template<typename TransformType> struct ei_transform_take_affine_part {
typedef typename TransformType::MatrixType MatrixType;
typedef typename TransformType::AffinePart AffinePart;
@ -974,6 +928,45 @@ struct ei_transform_take_affine_part<Transform<Scalar,Dim,AffineCompact> > {
static inline const MatrixType& run(const MatrixType& m) { return m; }
};
/*****************************************************
*** Specializations of construct from matix ***
*****************************************************/
template<typename Other, int Mode, int Dim, int HDim>
struct ei_transform_construct_from_matrix<Other, Mode,Dim,HDim, Dim,Dim>
{
static inline void run(Transform<typename ei_traits<Other>::Scalar,Dim,Mode> *transform, const Other& other)
{
transform->linear() = other;
transform->translation().setZero();
transform->makeAffine();
}
};
template<typename Other, int Mode, int Dim, int HDim>
struct ei_transform_construct_from_matrix<Other, Mode,Dim,HDim, Dim,HDim>
{
static inline void run(Transform<typename ei_traits<Other>::Scalar,Dim,Mode> *transform, const Other& other)
{
transform->affine() = other;
transform->makeAffine();
}
};
template<typename Other, int Mode, int Dim, int HDim>
struct ei_transform_construct_from_matrix<Other, Mode,Dim,HDim, HDim,HDim>
{
static inline void run(Transform<typename ei_traits<Other>::Scalar,Dim,Mode> *transform, const Other& other)
{ transform->matrix() = other; }
};
template<typename Other, int Dim, int HDim>
struct ei_transform_construct_from_matrix<Other, AffineCompact,Dim,HDim, HDim,HDim>
{
static inline void run(Transform<typename ei_traits<Other>::Scalar,Dim,AffineCompact> *transform, const Other& other)
{ transform->matrix() = other.template block<Dim,HDim>(0,0); }
};
/*****************************************************
*** Specializations of operator* with a MatrixBase ***
*****************************************************/