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 15 #ifndef BOOST_GEOMETRY_GEOMETRIES_REGISTER_BOX_HPP 16 #define BOOST_GEOMETRY_GEOMETRIES_REGISTER_BOX_HPP 17 18 19 #ifndef DOXYGEN_NO_SPECIALIZATIONS 20 21 22 #define BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_ACCESS(Box, Point, MinCorner, MaxCorner) \ 23 template <size_t D> \ 24 struct indexed_access<Box, min_corner, D> \ 25 { \ 26 typedef typename coordinate_type<Point>::type ct; \ 27 static inline ct get(Box const& b) \ 28 { return geometry::get<D>(b. MinCorner); } \ 29 static inline void set(Box& b, ct const& value) \ 30 { geometry::set<D>(b. MinCorner, value); } \ 31 }; \ 32 template <size_t D> \ 33 struct indexed_access<Box, max_corner, D> \ 34 { \ 35 typedef typename coordinate_type<Point>::type ct; \ 36 static inline ct get(Box const& b) \ 37 { return geometry::get<D>(b. MaxCorner); } \ 38 static inline void set(Box& b, ct const& value) \ 39 { geometry::set<D>(b. MaxCorner, value); } \ 40 }; 41 42 43 #define BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_ACCESS_TEMPLATED(Box, MinCorner, MaxCorner) \ 44 template <typename P, size_t D> \ 45 struct indexed_access<Box<P>, min_corner, D> \ 46 { \ 47 typedef typename coordinate_type<P>::type ct; \ 48 static inline ct get(Box<P> const& b) \ 49 { return geometry::get<D>(b. MinCorner); } \ 50 static inline void set(Box<P>& b, ct const& value) \ 51 { geometry::set<D>(b. MinCorner, value); } \ 52 }; \ 53 template <typename P, size_t D> \ 54 struct indexed_access<Box<P>, max_corner, D> \ 55 { \ 56 typedef typename coordinate_type<P>::type ct; \ 57 static inline ct get(Box<P> const& b) \ 58 { return geometry::get<D>(b. MaxCorner); } \ 59 static inline void set(Box<P>& b, ct const& value) \ 60 { geometry::set<D>(b. MaxCorner, value); } \ 61 }; 62 63 64 #define BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_ACCESS_4VALUES(Box, Point, Left, Bottom, Right, Top) \ 65 template <> struct indexed_access<Box, min_corner, 0> \ 66 { \ 67 typedef coordinate_type<Point>::type ct; \ 68 static inline ct get(Box const& b) { return b. Left; } \ 69 static inline void set(Box& b, ct const& value) { b. Left = value; } \ 70 }; \ 71 template <> struct indexed_access<Box, min_corner, 1> \ 72 { \ 73 typedef coordinate_type<Point>::type ct; \ 74 static inline ct get(Box const& b) { return b. Bottom; } \ 75 static inline void set(Box& b, ct const& value) { b. Bottom = value; } \ 76 }; \ 77 template <> struct indexed_access<Box, max_corner, 0> \ 78 { \ 79 typedef coordinate_type<Point>::type ct; \ 80 static inline ct get(Box const& b) { return b. Right; } \ 81 static inline void set(Box& b, ct const& value) { b. Right = value; } \ 82 }; \ 83 template <> struct indexed_access<Box, max_corner, 1> \ 84 { \ 85 typedef coordinate_type<Point>::type ct; \ 86 static inline ct get(Box const& b) { return b. Top; } \ 87 static inline void set(Box& b, ct const& value) { b. Top = value; } \ 88 }; 89 90 91 92 93 #define BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_TRAITS(Box, PointType) \ 94 template<> struct tag<Box > { typedef box_tag type; }; \ 95 template<> struct point_type<Box > { typedef PointType type; }; 96 97 #define BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_TRAITS_TEMPLATED(Box) \ 98 template<typename P> struct tag<Box<P> > { typedef box_tag type; }; \ 99 template<typename P> struct point_type<Box<P> > { typedef P type; }; 100 101 #endif // DOXYGEN_NO_SPECIALIZATIONS 102 103 104 105 /*! 106 \brief \brief_macro{box} 107 \ingroup register 108 \details \details_macro{BOOST_GEOMETRY_REGISTER_BOX, box} The 109 box may contain template parameters, which must be specified then. 110 \param Box \param_macro_type{Box} 111 \param Point Point type on which box is based. Might be two or three-dimensional 112 \param MinCorner minimum corner (should be public member or method) 113 \param MaxCorner maximum corner (should be public member or method) 114 115 \qbk{ 116 [heading Example] 117 [register_box] 118 [register_box_output] 119 } 120 */ 121 #define BOOST_GEOMETRY_REGISTER_BOX(Box, Point, MinCorner, MaxCorner) \ 122 namespace boost { namespace geometry { namespace traits { \ 123 BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_TRAITS(Box, Point) \ 124 BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_ACCESS(Box, Point, MinCorner, MaxCorner) \ 125 }}} 126 127 128 /*! 129 \brief \brief_macro{box} 130 \ingroup register 131 \details \details_macro{BOOST_GEOMETRY_REGISTER_BOX_TEMPLATED, box} 132 \details_macro_templated{box, point} 133 \param Box \param_macro_type{Box} 134 \param MinCorner minimum corner (should be public member or method) 135 \param MaxCorner maximum corner (should be public member or method) 136 137 \qbk{ 138 [heading Example] 139 [register_box_templated] 140 [register_box_templated_output] 141 } 142 */ 143 #define BOOST_GEOMETRY_REGISTER_BOX_TEMPLATED(Box, MinCorner, MaxCorner) \ 144 namespace boost { namespace geometry { namespace traits { \ 145 BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_TRAITS_TEMPLATED(Box) \ 146 BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_ACCESS_TEMPLATED(Box, MinCorner, MaxCorner) \ 147 }}} 148 149 /*! 150 \brief \brief_macro{box} 151 \ingroup register 152 \details \details_macro{BOOST_GEOMETRY_REGISTER_BOX_2D_4VALUES, box} 153 \param Box \param_macro_type{Box} 154 \param Point Point type reported as point_type by box. Must be two dimensional. 155 Note that these box tyeps do not contain points, but they must have a 156 related point_type 157 \param Left Left side (must be public member or method) 158 \param Bottom Bottom side (must be public member or method) 159 \param Right Right side (must be public member or method) 160 \param Top Top side (must be public member or method) 161 162 \qbk{ 163 [heading Example] 164 [register_box_2d_4values] 165 [register_box_2d_4values_output] 166 } 167 */ 168 #define BOOST_GEOMETRY_REGISTER_BOX_2D_4VALUES(Box, Point, Left, Bottom, Right, Top) \ 169 namespace boost { namespace geometry { namespace traits { \ 170 BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_TRAITS(Box, Point) \ 171 BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_ACCESS_4VALUES(Box, Point, Left, Bottom, Right, Top) \ 172 }}} 173 174 175 176 // CONST versions are for boxes probably not that common. Postponed. 177 178 179 #endif // BOOST_GEOMETRY_GEOMETRIES_REGISTER_BOX_HPP 180