diff --git a/CMakeLists.txt b/CMakeLists.txt index de9b4152f..3c93264f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,7 +66,7 @@ option(GTSAM_WITH_EIGEN_MKL_OPENMP "Eigen, when using Intel MKL, will also option(GTSAM_THROW_CHEIRALITY_EXCEPTION "Throw exception when a triangulated point is behind a camera" ON) option(GTSAM_BUILD_PYTHON "Enable/Disable building & installation of Python module" OFF) option(GTSAM_ALLOW_DEPRECATED_SINCE_V4 "Allow use of methods/functions deprecated in GTSAM 4" ON) -option(GTSAM_USE_VECTOR3_POINTS "Simply typdef Point3 to eigen::Vector3d" OFF) +option(GTSAM_TYPEDEF_POINTS_TO_VECTORS "Typdef Point2 and Point3 to Eigen::Vector equivalents" OFF) option(GTSAM_SUPPORT_NESTED_DISSECTION "Support Metis-based nested dissection" ON) option(GTSAM_TANGENT_PREINTEGRATION "Use new ImuFactor with integration on tangent space" ON) @@ -91,8 +91,8 @@ if(GTSAM_BUILD_PYTHON AND GTSAM_ALLOW_DEPRECATED_SINCE_V4) message(FATAL_ERROR "GTSAM_BUILD_PYTHON and GTSAM_ALLOW_DEPRECATED_SINCE_V4 are both enabled. The python module cannot be compiled with deprecated functions turned on. Turn one of the two options off.") endif() -if(GTSAM_INSTALL_MATLAB_TOOLBOX AND GTSAM_USE_VECTOR3_POINTS) - message(FATAL_ERROR "GTSAM_INSTALL_MATLAB_TOOLBOX and GTSAM_USE_VECTOR3_POINTS are both enabled. For now, the MATLAB toolbox cannot deal with this yet. Please turn one of the two options off.") +if(GTSAM_INSTALL_MATLAB_TOOLBOX AND GTSAM_TYPEDEF_POINTS_TO_VECTORS) + message(FATAL_ERROR "GTSAM_INSTALL_MATLAB_TOOLBOX and GTSAM_TYPEDEF_POINTS_TO_VECTORS are both enabled. For now, the MATLAB toolbox cannot deal with this yet. Please turn one of the two options off.") endif() # Flags for choosing default packaging tools @@ -491,7 +491,7 @@ print_config_flag(${GTSAM_ENABLE_CONSISTENCY_CHECKS} "Runtime consistency chec print_config_flag(${GTSAM_ROT3_EXPMAP} "Rot3 retract is full ExpMap ") print_config_flag(${GTSAM_POSE3_EXPMAP} "Pose3 retract is full ExpMap ") print_config_flag(${GTSAM_ALLOW_DEPRECATED_SINCE_V4} "Deprecated in GTSAM 4 allowed ") -print_config_flag(${GTSAM_USE_VECTOR3_POINTS} "Point3 is typedef to Vector3 ") +print_config_flag(${GTSAM_TYPEDEF_POINTS_TO_VECTORS} "Point3 is typedef to Vector3 ") print_config_flag(${GTSAM_SUPPORT_NESTED_DISSECTION} "Metis-based Nested Dissection ") print_config_flag(${GTSAM_TANGENT_PREINTEGRATION} "Use tangent-space preintegration") diff --git a/gtsam/geometry/Point2.h b/gtsam/geometry/Point2.h index bd9bc9c58..790a91c5f 100644 --- a/gtsam/geometry/Point2.h +++ b/gtsam/geometry/Point2.h @@ -22,6 +22,14 @@ namespace gtsam { +#ifdef GTSAM_TYPEDEF_POINTS_TO_VECTORS + + /// As of GTSAM 4, in order to make GTSAM more lean, + /// it is now possible to just typedef Point2 to Vector2 + typedef Vector2 Point2; + +#else + /** * A 2D point * Complies with the Testable Concept @@ -172,6 +180,12 @@ private: /// @} }; +template<> +struct traits : public internal::VectorSpace { +}; + +#endif // GTSAM_TYPEDEF_POINTS_TO_VECTORS + // Convenience typedef typedef std::pair Point2Pair; std::ostream &operator<<(std::ostream &os, const gtsam::Point2Pair &p); @@ -184,9 +198,5 @@ inline Point2 operator*(double s, const Point2& p) { return p * s; } -template<> -struct traits : public internal::VectorSpace { -}; - } // \ namespace gtsam diff --git a/gtsam/geometry/Point3.cpp b/gtsam/geometry/Point3.cpp index df0f78283..99136e31d 100644 --- a/gtsam/geometry/Point3.cpp +++ b/gtsam/geometry/Point3.cpp @@ -21,7 +21,7 @@ using namespace std; namespace gtsam { -#ifndef GTSAM_USE_VECTOR3_POINTS +#ifndef GTSAM_TYPEDEF_POINTS_TO_VECTORS bool Point3::equals(const Point3 &q, double tol) const { return (fabs(x() - q.x()) < tol && fabs(y() - q.y()) < tol && fabs(z() - q.z()) < tol); diff --git a/gtsam/geometry/Point3.h b/gtsam/geometry/Point3.h index f0ffb76fe..31ce985c0 100644 --- a/gtsam/geometry/Point3.h +++ b/gtsam/geometry/Point3.h @@ -29,7 +29,7 @@ namespace gtsam { -#ifdef GTSAM_USE_VECTOR3_POINTS +#ifdef GTSAM_TYPEDEF_POINTS_TO_VECTORS /// As of GTSAM 4, in order to make GTSAM more lean, /// it is now possible to just typedef Point3 to Vector3 @@ -153,7 +153,7 @@ struct traits : public internal::VectorSpace {}; template<> struct traits : public internal::VectorSpace {}; -#endif +#endif // GTSAM_TYPEDEF_POINTS_TO_VECTORS // Convenience typedef typedef std::pair Point3Pair; diff --git a/gtsam/geometry/tests/testPoint3.cpp b/gtsam/geometry/tests/testPoint3.cpp index 60fff30cc..405f52521 100644 --- a/gtsam/geometry/tests/testPoint3.cpp +++ b/gtsam/geometry/tests/testPoint3.cpp @@ -154,7 +154,7 @@ TEST( Point3, cross2) { } /* ************************************************************************* */ -#ifndef GTSAM_USE_VECTOR3_POINTS +#ifndef GTSAM_TYPEDEF_POINTS_TO_VECTORS TEST( Point3, stream) { Point3 p(1, 2, -3); std::ostringstream os; diff --git a/python/handwritten/geometry/Point3.cpp b/python/handwritten/geometry/Point3.cpp index de5c8e556..24bd92a05 100644 --- a/python/handwritten/geometry/Point3.cpp +++ b/python/handwritten/geometry/Point3.cpp @@ -44,7 +44,7 @@ class_("Point3") .def("norm", &Point3::norm, norm_overloads(args("OptionalJacobian<1,3>"))) .def("normalized", &Point3::normalized) .def("print", &Point3::print, print_overloads(args("s"))) -#ifndef GTSAM_USE_VECTOR3_POINTS +#ifndef GTSAM_TYPEDEF_POINTS_TO_VECTORS .def("vector", &Point3::vector, return_value_policy()) .def("x", &Point3::x) .def("y", &Point3::y)