Chris@16
|
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
|
Chris@16
|
2
|
Chris@16
|
3 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
|
Chris@16
|
4 // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
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_CONCEPTS_CHECK_HPP
|
Chris@16
|
16 #define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_CHECK_HPP
|
Chris@16
|
17
|
Chris@16
|
18
|
Chris@16
|
19 #include <boost/concept_check.hpp>
|
Chris@16
|
20 #include <boost/concept/requires.hpp>
|
Chris@16
|
21 #include <boost/type_traits/is_const.hpp>
|
Chris@101
|
22 #include <boost/variant/variant_fwd.hpp>
|
Chris@16
|
23
|
Chris@16
|
24 #include <boost/geometry/core/tag.hpp>
|
Chris@101
|
25 #include <boost/geometry/core/tags.hpp>
|
Chris@16
|
26
|
Chris@16
|
27 #include <boost/geometry/geometries/concepts/box_concept.hpp>
|
Chris@16
|
28 #include <boost/geometry/geometries/concepts/linestring_concept.hpp>
|
Chris@101
|
29 #include <boost/geometry/geometries/concepts/multi_point_concept.hpp>
|
Chris@101
|
30 #include <boost/geometry/geometries/concepts/multi_linestring_concept.hpp>
|
Chris@101
|
31 #include <boost/geometry/geometries/concepts/multi_polygon_concept.hpp>
|
Chris@16
|
32 #include <boost/geometry/geometries/concepts/point_concept.hpp>
|
Chris@16
|
33 #include <boost/geometry/geometries/concepts/polygon_concept.hpp>
|
Chris@16
|
34 #include <boost/geometry/geometries/concepts/ring_concept.hpp>
|
Chris@16
|
35 #include <boost/geometry/geometries/concepts/segment_concept.hpp>
|
Chris@16
|
36
|
Chris@16
|
37 #include <boost/geometry/algorithms/not_implemented.hpp>
|
Chris@16
|
38
|
Chris@16
|
39 namespace boost { namespace geometry
|
Chris@16
|
40 {
|
Chris@16
|
41
|
Chris@16
|
42
|
Chris@16
|
43 #ifndef DOXYGEN_NO_DETAIL
|
Chris@16
|
44 namespace detail { namespace concept_check
|
Chris@16
|
45 {
|
Chris@16
|
46
|
Chris@16
|
47 template <typename Concept>
|
Chris@16
|
48 class check
|
Chris@16
|
49 {
|
Chris@16
|
50 BOOST_CONCEPT_ASSERT((Concept ));
|
Chris@16
|
51 };
|
Chris@16
|
52
|
Chris@16
|
53 }} // namespace detail::concept_check
|
Chris@16
|
54 #endif // DOXYGEN_NO_DETAIL
|
Chris@16
|
55
|
Chris@16
|
56
|
Chris@16
|
57
|
Chris@16
|
58 #ifndef DOXYGEN_NO_DISPATCH
|
Chris@16
|
59 namespace dispatch
|
Chris@16
|
60 {
|
Chris@16
|
61
|
Chris@101
|
62 template
|
Chris@16
|
63 <
|
Chris@16
|
64 typename Geometry,
|
Chris@16
|
65 typename GeometryTag = typename geometry::tag<Geometry>::type,
|
Chris@16
|
66 bool IsConst = boost::is_const<Geometry>::type::value
|
Chris@16
|
67 >
|
Chris@16
|
68 struct check : not_implemented<GeometryTag>
|
Chris@16
|
69 {};
|
Chris@16
|
70
|
Chris@16
|
71
|
Chris@16
|
72 template <typename Geometry>
|
Chris@16
|
73 struct check<Geometry, point_tag, true>
|
Chris@16
|
74 : detail::concept_check::check<concept::ConstPoint<Geometry> >
|
Chris@16
|
75 {};
|
Chris@16
|
76
|
Chris@16
|
77
|
Chris@16
|
78 template <typename Geometry>
|
Chris@16
|
79 struct check<Geometry, point_tag, false>
|
Chris@16
|
80 : detail::concept_check::check<concept::Point<Geometry> >
|
Chris@16
|
81 {};
|
Chris@16
|
82
|
Chris@16
|
83
|
Chris@16
|
84 template <typename Geometry>
|
Chris@16
|
85 struct check<Geometry, linestring_tag, true>
|
Chris@16
|
86 : detail::concept_check::check<concept::ConstLinestring<Geometry> >
|
Chris@16
|
87 {};
|
Chris@16
|
88
|
Chris@16
|
89
|
Chris@16
|
90 template <typename Geometry>
|
Chris@16
|
91 struct check<Geometry, linestring_tag, false>
|
Chris@16
|
92 : detail::concept_check::check<concept::Linestring<Geometry> >
|
Chris@16
|
93 {};
|
Chris@16
|
94
|
Chris@16
|
95
|
Chris@16
|
96 template <typename Geometry>
|
Chris@16
|
97 struct check<Geometry, ring_tag, true>
|
Chris@16
|
98 : detail::concept_check::check<concept::ConstRing<Geometry> >
|
Chris@16
|
99 {};
|
Chris@16
|
100
|
Chris@16
|
101
|
Chris@16
|
102 template <typename Geometry>
|
Chris@16
|
103 struct check<Geometry, ring_tag, false>
|
Chris@16
|
104 : detail::concept_check::check<concept::Ring<Geometry> >
|
Chris@16
|
105 {};
|
Chris@16
|
106
|
Chris@16
|
107 template <typename Geometry>
|
Chris@16
|
108 struct check<Geometry, polygon_tag, true>
|
Chris@16
|
109 : detail::concept_check::check<concept::ConstPolygon<Geometry> >
|
Chris@16
|
110 {};
|
Chris@16
|
111
|
Chris@16
|
112
|
Chris@16
|
113 template <typename Geometry>
|
Chris@16
|
114 struct check<Geometry, polygon_tag, false>
|
Chris@16
|
115 : detail::concept_check::check<concept::Polygon<Geometry> >
|
Chris@16
|
116 {};
|
Chris@16
|
117
|
Chris@16
|
118
|
Chris@16
|
119 template <typename Geometry>
|
Chris@16
|
120 struct check<Geometry, box_tag, true>
|
Chris@16
|
121 : detail::concept_check::check<concept::ConstBox<Geometry> >
|
Chris@16
|
122 {};
|
Chris@16
|
123
|
Chris@16
|
124
|
Chris@16
|
125 template <typename Geometry>
|
Chris@16
|
126 struct check<Geometry, box_tag, false>
|
Chris@16
|
127 : detail::concept_check::check<concept::Box<Geometry> >
|
Chris@16
|
128 {};
|
Chris@16
|
129
|
Chris@16
|
130
|
Chris@16
|
131 template <typename Geometry>
|
Chris@16
|
132 struct check<Geometry, segment_tag, true>
|
Chris@16
|
133 : detail::concept_check::check<concept::ConstSegment<Geometry> >
|
Chris@16
|
134 {};
|
Chris@16
|
135
|
Chris@16
|
136
|
Chris@16
|
137 template <typename Geometry>
|
Chris@16
|
138 struct check<Geometry, segment_tag, false>
|
Chris@16
|
139 : detail::concept_check::check<concept::Segment<Geometry> >
|
Chris@16
|
140 {};
|
Chris@16
|
141
|
Chris@16
|
142
|
Chris@101
|
143 template <typename Geometry>
|
Chris@101
|
144 struct check<Geometry, multi_point_tag, true>
|
Chris@101
|
145 : detail::concept_check::check<concept::ConstMultiPoint<Geometry> >
|
Chris@101
|
146 {};
|
Chris@101
|
147
|
Chris@101
|
148
|
Chris@101
|
149 template <typename Geometry>
|
Chris@101
|
150 struct check<Geometry, multi_point_tag, false>
|
Chris@101
|
151 : detail::concept_check::check<concept::MultiPoint<Geometry> >
|
Chris@101
|
152 {};
|
Chris@101
|
153
|
Chris@101
|
154
|
Chris@101
|
155 template <typename Geometry>
|
Chris@101
|
156 struct check<Geometry, multi_linestring_tag, true>
|
Chris@101
|
157 : detail::concept_check::check<concept::ConstMultiLinestring<Geometry> >
|
Chris@101
|
158 {};
|
Chris@101
|
159
|
Chris@101
|
160
|
Chris@101
|
161 template <typename Geometry>
|
Chris@101
|
162 struct check<Geometry, multi_linestring_tag, false>
|
Chris@101
|
163 : detail::concept_check::check<concept::MultiLinestring<Geometry> >
|
Chris@101
|
164 {};
|
Chris@101
|
165
|
Chris@101
|
166
|
Chris@101
|
167 template <typename Geometry>
|
Chris@101
|
168 struct check<Geometry, multi_polygon_tag, true>
|
Chris@101
|
169 : detail::concept_check::check<concept::ConstMultiPolygon<Geometry> >
|
Chris@101
|
170 {};
|
Chris@101
|
171
|
Chris@101
|
172
|
Chris@101
|
173 template <typename Geometry>
|
Chris@101
|
174 struct check<Geometry, multi_polygon_tag, false>
|
Chris@101
|
175 : detail::concept_check::check<concept::MultiPolygon<Geometry> >
|
Chris@101
|
176 {};
|
Chris@101
|
177
|
Chris@101
|
178
|
Chris@16
|
179 } // namespace dispatch
|
Chris@16
|
180 #endif
|
Chris@16
|
181
|
Chris@16
|
182
|
Chris@16
|
183
|
Chris@16
|
184
|
Chris@16
|
185 namespace concept
|
Chris@16
|
186 {
|
Chris@16
|
187
|
Chris@16
|
188
|
Chris@16
|
189 #ifndef DOXYGEN_NO_DETAIL
|
Chris@16
|
190 namespace detail
|
Chris@16
|
191 {
|
Chris@16
|
192
|
Chris@16
|
193
|
Chris@16
|
194 template <typename Geometry>
|
Chris@16
|
195 struct checker : dispatch::check<Geometry>
|
Chris@16
|
196 {};
|
Chris@16
|
197
|
Chris@16
|
198 template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
|
Chris@16
|
199 struct checker<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
|
Chris@16
|
200 {};
|
Chris@16
|
201
|
Chris@16
|
202 template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
|
Chris@16
|
203 struct checker<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const>
|
Chris@16
|
204 {};
|
Chris@16
|
205
|
Chris@16
|
206
|
Chris@16
|
207 }
|
Chris@16
|
208 #endif // DOXYGEN_NO_DETAIL
|
Chris@16
|
209
|
Chris@16
|
210
|
Chris@16
|
211 /*!
|
Chris@16
|
212 \brief Checks, in compile-time, the concept of any geometry
|
Chris@16
|
213 \ingroup concepts
|
Chris@16
|
214 */
|
Chris@16
|
215 template <typename Geometry>
|
Chris@16
|
216 inline void check()
|
Chris@16
|
217 {
|
Chris@16
|
218 detail::checker<Geometry> c;
|
Chris@16
|
219 boost::ignore_unused_variable_warning(c);
|
Chris@16
|
220 }
|
Chris@16
|
221
|
Chris@16
|
222
|
Chris@16
|
223 /*!
|
Chris@16
|
224 \brief Checks, in compile-time, the concept of two geometries, and if they
|
Chris@16
|
225 have equal dimensions
|
Chris@16
|
226 \ingroup concepts
|
Chris@16
|
227 */
|
Chris@16
|
228 template <typename Geometry1, typename Geometry2>
|
Chris@16
|
229 inline void check_concepts_and_equal_dimensions()
|
Chris@16
|
230 {
|
Chris@16
|
231 check<Geometry1>();
|
Chris@16
|
232 check<Geometry2>();
|
Chris@16
|
233 assert_dimension_equal<Geometry1, Geometry2>();
|
Chris@16
|
234 }
|
Chris@16
|
235
|
Chris@16
|
236
|
Chris@16
|
237 } // namespace concept
|
Chris@16
|
238
|
Chris@16
|
239
|
Chris@16
|
240 }} // namespace boost::geometry
|
Chris@16
|
241
|
Chris@16
|
242
|
Chris@16
|
243 #endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_CHECK_HPP
|