fix bug #190: directly pass Transform Options to Matrix, allowing to use RowMajor. Fix issues in Transform with non-default Options.

This commit is contained in:
Benoit Jacob 2011-02-22 08:14:38 -05:00
parent 659c97ee49
commit 39d3bc2394
2 changed files with 14 additions and 8 deletions

View File

@ -89,7 +89,8 @@ template<typename TransformType> struct transform_take_affine_part;
* - AffineCompact: the transformation is stored as a (Dim)x(Dim+1) matrix. * - AffineCompact: the transformation is stored as a (Dim)x(Dim+1) matrix.
* - Projective: the transformation is stored as a (Dim+1)^2 matrix * - Projective: the transformation is stored as a (Dim+1)^2 matrix
* without any assumption. * without any assumption.
* \tparam _Options can be \b AutoAlign or \b DontAlign. Default is \b AutoAlign * \tparam _Options has the same meaning as in class Matrix. It allows to specify DontAlign and/or RowMajor.
* These Options are passed directly to the underlying matrix type.
* *
* The homography is internally represented and stored by a matrix which * The homography is internally represented and stored by a matrix which
* is available through the matrix() method. To understand the behavior of * is available through the matrix() method. To understand the behavior of
@ -198,11 +199,11 @@ public:
typedef _Scalar Scalar; typedef _Scalar Scalar;
typedef DenseIndex Index; typedef DenseIndex Index;
/** type of the matrix used to represent the transformation */ /** type of the matrix used to represent the transformation */
typedef Matrix<Scalar,Rows,HDim,Options&DontAlign> MatrixType; typedef Matrix<Scalar,Rows,HDim,Options> MatrixType;
/** constified MatrixType */ /** constified MatrixType */
typedef const MatrixType ConstMatrixType; typedef const MatrixType ConstMatrixType;
/** type of the matrix used to represent the linear part of the transformation */ /** type of the matrix used to represent the linear part of the transformation */
typedef Matrix<Scalar,Dim,Dim> LinearMatrixType; typedef Matrix<Scalar,Dim,Dim,Options> LinearMatrixType;
/** type of read/write reference to the linear part of the transformation */ /** type of read/write reference to the linear part of the transformation */
typedef Block<MatrixType,Dim,Dim> LinearPart; typedef Block<MatrixType,Dim,Dim> LinearPart;
/** type of read reference to the linear part of the transformation */ /** type of read reference to the linear part of the transformation */
@ -607,7 +608,6 @@ protected:
#ifndef EIGEN_PARSED_BY_DOXYGEN #ifndef EIGEN_PARSED_BY_DOXYGEN
EIGEN_STRONG_INLINE static void check_template_params() EIGEN_STRONG_INLINE static void check_template_params()
{ {
EIGEN_STATIC_ASSERT((Options & (DontAlign)) == Options, INVALID_MATRIX_TEMPLATE_PARAMETERS)
} }
#endif #endif
@ -1139,9 +1139,9 @@ template<typename TransformType> struct transform_take_affine_part {
{ return m.template block<TransformType::Dim,TransformType::HDim>(0,0); } { return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }
}; };
template<typename Scalar, int Dim> template<typename Scalar, int Dim, int Options>
struct transform_take_affine_part<Transform<Scalar,Dim,AffineCompact> > { struct transform_take_affine_part<Transform<Scalar,Dim,AffineCompact, Options> > {
typedef typename Transform<Scalar,Dim,AffineCompact>::MatrixType MatrixType; typedef typename Transform<Scalar,Dim,AffineCompact,Options>::MatrixType MatrixType;
static inline MatrixType& run(MatrixType& m) { return m; } static inline MatrixType& run(MatrixType& m) { return m; }
static inline const MatrixType& run(const MatrixType& m) { return m; } static inline const MatrixType& run(const MatrixType& m) { return m; }
}; };
@ -1181,7 +1181,7 @@ struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, HDim,HDim>
template<typename Other, int Options, int Dim, int HDim> template<typename Other, int Options, int Dim, int HDim>
struct transform_construct_from_matrix<Other, AffineCompact,Options,Dim,HDim, HDim,HDim> struct transform_construct_from_matrix<Other, AffineCompact,Options,Dim,HDim, HDim,HDim>
{ {
static inline void run(Transform<typename Other::Scalar,Dim,AffineCompact> *transform, const Other& other) static inline void run(Transform<typename Other::Scalar,Dim,AffineCompact,Options> *transform, const Other& other)
{ transform->matrix() = other.template block<Dim,HDim>(0,0); } { transform->matrix() = other.template block<Dim,HDim>(0,0); }
}; };

View File

@ -459,5 +459,11 @@ void test_geo_transformations()
CALL_SUBTEST_3(( transformations<double,Projective,AutoAlign>() )); CALL_SUBTEST_3(( transformations<double,Projective,AutoAlign>() ));
CALL_SUBTEST_3(( transformations<double,Projective,DontAlign>() )); CALL_SUBTEST_3(( transformations<double,Projective,DontAlign>() ));
CALL_SUBTEST_3(( transform_alignment<double>() )); CALL_SUBTEST_3(( transform_alignment<double>() ));
CALL_SUBTEST_4(( transformations<double,Affine,RowMajor|AutoAlign>() ));
CALL_SUBTEST_4(( transformations<double,AffineCompact,RowMajor|AutoAlign>() ));
CALL_SUBTEST_5(( transformations<double,Projective,RowMajor|AutoAlign>() ));
CALL_SUBTEST_5(( transformations<double,Projective,RowMajor|DontAlign>() ));
} }
} }