[Geometry/AlignedBox] New typedefs, like for Core/Matrix

Includes 1-4 and dynamic sized boxes for int, float and double type.
Also changes the tests to use these typedefs.
This commit is contained in:
Dennis Schridde 2011-11-09 22:12:28 +01:00
parent 8fbbbe7521
commit db36e4204f
2 changed files with 47 additions and 13 deletions

View File

@ -349,4 +349,38 @@ inline Scalar AlignedBox<Scalar,AmbientDim>::squaredExteriorDistance(const Align
return dist2;
}
/** \defgroup alignedboxtypedefs Global aligned box typedefs
*
* \ingroup Geometry_Module
*
* Eigen defines several typedef shortcuts for most common aligned box types.
*
* The general patterns are the following:
*
* \c AlignedBoxSizeType where \c Size can be \c 1, \c 2,\c 3,\c 4 for fixed size boxes or \c X for dynamic size,
* and where \c Type can be \c i for integer, \c f for float, \c d for double.
*
* For example, \c AlignedBox3d is a fixed-size 3x3 aligned box type of doubles, and \c AlignedBoxXf is a dynamic-size aligned box of floats.
*
* \sa class AlignedBox
*/
#define EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix) \
/** \ingroup alignedboxtypedefs */ \
typedef AlignedBox<Type, Size> AlignedBox##SizeSuffix##TypeSuffix;
#define EIGEN_MAKE_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \
EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 1, 1) \
EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 2, 2) \
EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 3, 3) \
EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 4, 4) \
EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Dynamic, X)
EIGEN_MAKE_TYPEDEFS_ALL_SIZES(int, i)
EIGEN_MAKE_TYPEDEFS_ALL_SIZES(float, f)
EIGEN_MAKE_TYPEDEFS_ALL_SIZES(double, d)
#undef EIGEN_MAKE_TYPEDEFS_ALL_SIZES
#undef EIGEN_MAKE_TYPEDEFS
#endif // EIGEN_ALIGNEDBOX_H

View File

@ -113,7 +113,7 @@ void specificTest1()
Vector2f m; m << -1.0f, -2.0f;
Vector2f M; M << 1.0f, 5.0f;
typedef AlignedBox<float,2> BoxType;
typedef AlignedBox2f BoxType;
BoxType box( m, M );
Vector2f sides = M-m;
@ -140,7 +140,7 @@ void specificTest2()
Vector3i m; m << -1, -2, 0;
Vector3i M; M << 1, 5, 3;
typedef AlignedBox<int,3> BoxType;
typedef AlignedBox3i BoxType;
BoxType box( m, M );
Vector3i sides = M-m;
@ -165,21 +165,21 @@ void test_geo_alignedbox()
{
for(int i = 0; i < g_repeat; i++)
{
CALL_SUBTEST_1( alignedbox(AlignedBox<float,2>()) );
CALL_SUBTEST_2( alignedboxCastTests(AlignedBox<float,2>()) );
CALL_SUBTEST_1( alignedbox(AlignedBox2f()) );
CALL_SUBTEST_2( alignedboxCastTests(AlignedBox2f()) );
CALL_SUBTEST_3( alignedbox(AlignedBox<float,3>()) );
CALL_SUBTEST_4( alignedboxCastTests(AlignedBox<float,3>()) );
CALL_SUBTEST_3( alignedbox(AlignedBox3f()) );
CALL_SUBTEST_4( alignedboxCastTests(AlignedBox3f()) );
CALL_SUBTEST_5( alignedbox(AlignedBox<double,4>()) );
CALL_SUBTEST_6( alignedboxCastTests(AlignedBox<double,4>()) );
CALL_SUBTEST_5( alignedbox(AlignedBox4d()) );
CALL_SUBTEST_6( alignedboxCastTests(AlignedBox4d()) );
CALL_SUBTEST_7( alignedbox(AlignedBox<double,1>()) );
CALL_SUBTEST_8( alignedboxCastTests(AlignedBox<double,1>()) );
CALL_SUBTEST_7( alignedbox(AlignedBox1d()) );
CALL_SUBTEST_8( alignedboxCastTests(AlignedBox1d()) );
CALL_SUBTEST_9( alignedbox(AlignedBox<int,1>()) );
CALL_SUBTEST_10( alignedbox(AlignedBox<int,2>()) );
CALL_SUBTEST_11( alignedbox(AlignedBox<int,3>()) );
CALL_SUBTEST_9( alignedbox(AlignedBox1i()) );
CALL_SUBTEST_10( alignedbox(AlignedBox2i()) );
CALL_SUBTEST_11( alignedbox(AlignedBox3i()) );
}
CALL_SUBTEST_12( specificTest1() );
CALL_SUBTEST_13( specificTest2() );