]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/include/boost/geometry/algorithms/detail/for_each_range.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / include / boost / geometry / algorithms / detail / for_each_range.hpp
CommitLineData
7c673cae
FG
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_ALGORITHMS_DETAIL_FOR_EACH_RANGE_HPP
15#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_FOR_EACH_RANGE_HPP
16
17
18#include <boost/mpl/assert.hpp>
19#include <boost/concept/requires.hpp>
20#include <boost/range.hpp>
21#include <boost/type_traits/is_const.hpp>
22#include <boost/type_traits/remove_const.hpp>
23
24#include <boost/geometry/core/tag.hpp>
25#include <boost/geometry/core/tag_cast.hpp>
26#include <boost/geometry/core/tags.hpp>
27
28#include <boost/geometry/util/add_const_if_c.hpp>
29#include <boost/geometry/views/box_view.hpp>
30
31
32namespace boost { namespace geometry
33{
34
35
36#ifndef DOXYGEN_NO_DETAIL
37namespace detail { namespace for_each
38{
39
40
41template <typename Range, typename Actor>
42struct fe_range_range
43{
44 static inline void apply(Range & range, Actor & actor)
45 {
46 actor.apply(range);
47 }
48};
49
50
51template <typename Polygon, typename Actor>
52struct fe_range_polygon
53{
54 static inline void apply(Polygon & polygon, Actor & actor)
55 {
56 actor.apply(exterior_ring(polygon));
57
58 // TODO: If some flag says true, also do the inner rings.
59 // for convex hull, it's not necessary
60 }
61};
62
63template <typename Box, typename Actor>
64struct fe_range_box
65{
66 static inline void apply(Box & box, Actor & actor)
67 {
68 actor.apply(box_view<typename boost::remove_const<Box>::type>(box));
69 }
70};
71
72template <typename Multi, typename Actor, typename SinglePolicy>
73struct fe_range_multi
74{
75 static inline void apply(Multi & multi, Actor & actor)
76 {
77 for ( typename boost::range_iterator<Multi>::type
78 it = boost::begin(multi); it != boost::end(multi); ++it)
79 {
80 SinglePolicy::apply(*it, actor);
81 }
82 }
83};
84
85}} // namespace detail::for_each
86#endif // DOXYGEN_NO_DETAIL
87
88
89#ifndef DOXYGEN_NO_DISPATCH
90namespace dispatch
91{
92
93
94template
95<
96 typename Geometry,
97 typename Actor,
98 typename Tag = typename tag<Geometry>::type
99>
100struct for_each_range
101{
102 BOOST_MPL_ASSERT_MSG
103 (
104 false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
105 , (types<Geometry>)
106 );
107};
108
109
110template <typename Linestring, typename Actor>
111struct for_each_range<Linestring, Actor, linestring_tag>
112 : detail::for_each::fe_range_range<Linestring, Actor>
113{};
114
115
116template <typename Ring, typename Actor>
117struct for_each_range<Ring, Actor, ring_tag>
118 : detail::for_each::fe_range_range<Ring, Actor>
119{};
120
121
122template <typename Polygon, typename Actor>
123struct for_each_range<Polygon, Actor, polygon_tag>
124 : detail::for_each::fe_range_polygon<Polygon, Actor>
125{};
126
127
128template <typename Box, typename Actor>
129struct for_each_range<Box, Actor, box_tag>
130 : detail::for_each::fe_range_box<Box, Actor>
131{};
132
133
134template <typename MultiPoint, typename Actor>
135struct for_each_range<MultiPoint, Actor, multi_point_tag>
136 : detail::for_each::fe_range_range<MultiPoint, Actor>
137{};
138
139
140template <typename Geometry, typename Actor>
141struct for_each_range<Geometry, Actor, multi_linestring_tag>
142 : detail::for_each::fe_range_multi
143 <
144 Geometry,
145 Actor,
146 detail::for_each::fe_range_range
147 <
148 typename add_const_if_c
149 <
150 boost::is_const<Geometry>::value,
151 typename boost::range_value<Geometry>::type
152 >::type,
153 Actor
154 >
155 >
156{};
157
158
159template <typename Geometry, typename Actor>
160struct for_each_range<Geometry, Actor, multi_polygon_tag>
161 : detail::for_each::fe_range_multi
162 <
163 Geometry,
164 Actor,
165 detail::for_each::fe_range_polygon
166 <
167 typename add_const_if_c
168 <
169 boost::is_const<Geometry>::value,
170 typename boost::range_value<Geometry>::type
171 >::type,
172 Actor
173 >
174 >
175{};
176
177
178} // namespace dispatch
179#endif // DOXYGEN_NO_DISPATCH
180
181namespace detail
182{
183
184template <typename Geometry, typename Actor>
185inline void for_each_range(Geometry const& geometry, Actor & actor)
186{
187 dispatch::for_each_range
188 <
189 Geometry const,
190 Actor
191 >::apply(geometry, actor);
192}
193
194
195}
196
197
198}} // namespace boost::geometry
199
200
201#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_FOR_EACH_RANGE_HPP