1 // Boost.Geometry (aka GGL, Generic Geometry Library) 2 3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. 4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. 5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. 6 7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library 8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. 9 10 // Use, modification and distribution is subject to the Boost Software License, 11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 12 // http://www.boost.org/LICENSE_1_0.txt) 13 14 #ifndef BOOST_GEOMETRY_GEOMETRIES_REGISTER_POINT_HPP 15 #define BOOST_GEOMETRY_GEOMETRIES_REGISTER_POINT_HPP 16 17 18 #include <cstddef> 19 20 #ifndef DOXYGEN_NO_SPECIALIZATIONS 21 22 // Starting point, specialize basic traits necessary to register a point 23 #define BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_TRAITS(Point, Dim, CoordinateType, CoordinateSystem) \ 24 template<> struct tag<Point> { typedef point_tag type; }; \ 25 template<> struct dimension<Point> : boost::mpl::int_<Dim> {}; \ 26 template<> struct coordinate_type<Point> { typedef CoordinateType type; }; \ 27 template<> struct coordinate_system<Point> { typedef CoordinateSystem type; }; 28 29 // Specialize access class per dimension 30 #define BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS(Point, Dim, CoordinateType, Get, Set) \ 31 template<> struct access<Point, Dim> \ 32 { \ 33 static inline CoordinateType get(Point const& p) { return p. Get; } \ 34 static inline void set(Point& p, CoordinateType const& value) { p. Set = value; } \ 35 }; 36 37 // Const version 38 #define BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_CONST(Point, Dim, CoordinateType, Get) \ 39 template<> struct access<Point, Dim> \ 40 { \ 41 static inline CoordinateType get(Point const& p) { return p. Get; } \ 42 }; 43 44 45 // Getter/setter version 46 #define BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_GET_SET(Point, Dim, CoordinateType, Get, Set) \ 47 template<> struct access<Point, Dim> \ 48 { \ 49 static inline CoordinateType get(Point const& p) \ 50 { return p. Get (); } \ 51 static inline void set(Point& p, CoordinateType const& value) \ 52 { p. Set ( value ); } \ 53 }; 54 55 #endif // DOXYGEN_NO_SPECIALIZATIONS 56 57 58 /*! 59 \brief \brief_macro{2D point type} 60 \ingroup register 61 \details \details_macro{BOOST_GEOMETRY_REGISTER_POINT_2D, two-dimensional point type} 62 \param Point \param_macro_type{Point} 63 \param CoordinateType \param_macro_coortype{point} 64 \param CoordinateSystem \param_macro_coorsystem 65 \param Field0 \param_macro_member{\macro_x} 66 \param Field1 \param_macro_member{\macro_y} 67 68 \qbk{[include reference/geometries/register/point.qbk]} 69 */ 70 #define BOOST_GEOMETRY_REGISTER_POINT_2D(Point, CoordinateType, CoordinateSystem, Field0, Field1) \ 71 namespace boost { namespace geometry { namespace traits { \ 72 BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_TRAITS(Point, 2, CoordinateType, CoordinateSystem) \ 73 BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS(Point, 0, CoordinateType, Field0, Field0) \ 74 BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS(Point, 1, CoordinateType, Field1, Field1) \ 75 }}} 76 77 /*! 78 \brief \brief_macro{3D point type} 79 \ingroup register 80 \details \details_macro{BOOST_GEOMETRY_REGISTER_POINT_3D, three-dimensional point type} 81 \param Point \param_macro_type{Point} 82 \param CoordinateType \param_macro_coortype{point} 83 \param CoordinateSystem \param_macro_coorsystem 84 \param Field0 \param_macro_member{\macro_x} 85 \param Field1 \param_macro_member{\macro_y} 86 \param Field2 \param_macro_member{\macro_z} 87 */ 88 #define BOOST_GEOMETRY_REGISTER_POINT_3D(Point, CoordinateType, CoordinateSystem, Field0, Field1, Field2) \ 89 namespace boost { namespace geometry { namespace traits { \ 90 BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_TRAITS(Point, 3, CoordinateType, CoordinateSystem) \ 91 BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS(Point, 0, CoordinateType, Field0, Field0) \ 92 BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS(Point, 1, CoordinateType, Field1, Field1) \ 93 BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS(Point, 2, CoordinateType, Field2, Field2) \ 94 }}} 95 96 /*! 97 \brief \brief_macro{2D point type} \brief_macro_const 98 \ingroup register 99 \details \details_macro{BOOST_GEOMETRY_REGISTER_POINT_2D_CONST, two-dimensional point type}. \details_macro_const 100 \param Point \param_macro_type{Point} 101 \param CoordinateType \param_macro_coortype{point} 102 \param CoordinateSystem \param_macro_coorsystem 103 \param Field0 \param_macro_member{\macro_x} 104 \param Field1 \param_macro_member{\macro_y} 105 */ 106 #define BOOST_GEOMETRY_REGISTER_POINT_2D_CONST(Point, CoordinateType, CoordinateSystem, Field0, Field1) \ 107 namespace boost { namespace geometry { namespace traits { \ 108 BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_TRAITS(Point, 2, CoordinateType, CoordinateSystem) \ 109 BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_CONST(Point, 0, CoordinateType, Field0) \ 110 BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_CONST(Point, 1, CoordinateType, Field1) \ 111 }}} 112 113 /*! 114 \brief \brief_macro{3D point type} \brief_macro_const 115 \ingroup register 116 \details \details_macro{BOOST_GEOMETRY_REGISTER_POINT_3D_CONST, three-dimensional point type}. \details_macro_const 117 \param Point \param_macro_type{Point} 118 \param CoordinateType \param_macro_coortype{point} 119 \param CoordinateSystem \param_macro_coorsystem 120 \param Field0 \param_macro_member{\macro_x} 121 \param Field1 \param_macro_member{\macro_y} 122 \param Field2 \param_macro_member{\macro_z} 123 */ 124 #define BOOST_GEOMETRY_REGISTER_POINT_3D_CONST(Point, CoordinateType, CoordinateSystem, Field0, Field1, Field2) \ 125 namespace boost { namespace geometry { namespace traits { \ 126 BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_TRAITS(Point, 3, CoordinateType, CoordinateSystem) \ 127 BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_CONST(Point, 0, CoordinateType, Field0) \ 128 BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_CONST(Point, 1, CoordinateType, Field1) \ 129 BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_CONST(Point, 2, CoordinateType, Field2) \ 130 }}} 131 132 /*! 133 \brief \brief_macro{2D point type} \brief_macro_getset 134 \ingroup register 135 \details \details_macro{BOOST_GEOMETRY_REGISTER_POINT_2D_GET_SET, two-dimensional point type}. \details_macro_getset 136 \param Point \param_macro_type{Point} 137 \param CoordinateType \param_macro_coortype{point} 138 \param CoordinateSystem \param_macro_coorsystem 139 \param Get0 \param_macro_getset{get, \macro_x} 140 \param Get1 \param_macro_getset{get, \macro_y} 141 \param Set0 \param_macro_getset{set, \macro_x} 142 \param Set1 \param_macro_getset{set, \macro_y} 143 */ 144 #define BOOST_GEOMETRY_REGISTER_POINT_2D_GET_SET(Point, CoordinateType, CoordinateSystem, Get0, Get1, Set0, Set1) \ 145 namespace boost { namespace geometry { namespace traits { \ 146 BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_TRAITS(Point, 2, CoordinateType, CoordinateSystem) \ 147 BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_GET_SET(Point, 0, CoordinateType, Get0, Set0) \ 148 BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_GET_SET(Point, 1, CoordinateType, Get1, Set1) \ 149 }}} 150 151 /*! 152 \brief \brief_macro{3D point type} \brief_macro_getset 153 \ingroup register 154 \details \details_macro{BOOST_GEOMETRY_REGISTER_POINT_3D_GET_SET, three-dimensional point type}. \details_macro_getset 155 \param Point \param_macro_type{Point} 156 \param CoordinateType \param_macro_coortype{point} 157 \param CoordinateSystem \param_macro_coorsystem 158 \param Get0 \param_macro_getset{get, \macro_x} 159 \param Get1 \param_macro_getset{get, \macro_y} 160 \param Get2 \param_macro_getset{get, \macro_z} 161 \param Set0 \param_macro_getset{set, \macro_x} 162 \param Set1 \param_macro_getset{set, \macro_y} 163 \param Set2 \param_macro_getset{set, \macro_z} 164 */ 165 #define BOOST_GEOMETRY_REGISTER_POINT_3D_GET_SET(Point, CoordinateType, CoordinateSystem, Get0, Get1, Get2, Set0, Set1, Set2) \ 166 namespace boost { namespace geometry { namespace traits { \ 167 BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_TRAITS(Point, 3, CoordinateType, CoordinateSystem) \ 168 BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_GET_SET(Point, 0, CoordinateType, Get0, Set0) \ 169 BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_GET_SET(Point, 1, CoordinateType, Get1, Set1) \ 170 BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_GET_SET(Point, 2, CoordinateType, Get2, Set2) \ 171 }}} 172 173 #endif // BOOST_GEOMETRY_GEOMETRIES_REGISTER_POINT_HPP 174