diff --git a/Eigen/src/Geometry/AlignedBox.h b/Eigen/src/Geometry/AlignedBox.h index b51deb3f3..f01746f77 100644 --- a/Eigen/src/Geometry/AlignedBox.h +++ b/Eigen/src/Geometry/AlignedBox.h @@ -349,4 +349,38 @@ inline Scalar AlignedBox::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 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 diff --git a/test/geo_alignedbox.cpp b/test/geo_alignedbox.cpp index 738ca3150..724133725 100644 --- a/test/geo_alignedbox.cpp +++ b/test/geo_alignedbox.cpp @@ -113,7 +113,7 @@ void specificTest1() Vector2f m; m << -1.0f, -2.0f; Vector2f M; M << 1.0f, 5.0f; - typedef AlignedBox 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 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()) ); - CALL_SUBTEST_2( alignedboxCastTests(AlignedBox()) ); + CALL_SUBTEST_1( alignedbox(AlignedBox2f()) ); + CALL_SUBTEST_2( alignedboxCastTests(AlignedBox2f()) ); - CALL_SUBTEST_3( alignedbox(AlignedBox()) ); - CALL_SUBTEST_4( alignedboxCastTests(AlignedBox()) ); + CALL_SUBTEST_3( alignedbox(AlignedBox3f()) ); + CALL_SUBTEST_4( alignedboxCastTests(AlignedBox3f()) ); - CALL_SUBTEST_5( alignedbox(AlignedBox()) ); - CALL_SUBTEST_6( alignedboxCastTests(AlignedBox()) ); + CALL_SUBTEST_5( alignedbox(AlignedBox4d()) ); + CALL_SUBTEST_6( alignedboxCastTests(AlignedBox4d()) ); - CALL_SUBTEST_7( alignedbox(AlignedBox()) ); - CALL_SUBTEST_8( alignedboxCastTests(AlignedBox()) ); + CALL_SUBTEST_7( alignedbox(AlignedBox1d()) ); + CALL_SUBTEST_8( alignedboxCastTests(AlignedBox1d()) ); - CALL_SUBTEST_9( alignedbox(AlignedBox()) ); - CALL_SUBTEST_10( alignedbox(AlignedBox()) ); - CALL_SUBTEST_11( alignedbox(AlignedBox()) ); + CALL_SUBTEST_9( alignedbox(AlignedBox1i()) ); + CALL_SUBTEST_10( alignedbox(AlignedBox2i()) ); + CALL_SUBTEST_11( alignedbox(AlignedBox3i()) ); } CALL_SUBTEST_12( specificTest1() ); CALL_SUBTEST_13( specificTest2() );