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