]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/algorithms/detail/buffer/buffered_ring.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / geometry / algorithms / detail / buffer / buffered_ring.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2012-2015 Barend Gehrels, Amsterdam, the Netherlands.
4
5 // This file was modified by Oracle on 2020.
6 // Modifications copyright (c) 2020 Oracle and/or its affiliates.
7 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
8
9 // Use, modification and distribution is subject to the Boost Software License,
10 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
11 // http://www.boost.org/LICENSE_1_0.txt)
12
13 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_BUFFERED_RING
14 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_BUFFERED_RING
15
16
17 #include <cstddef>
18
19 #include <boost/range/size.hpp>
20 #include <boost/range/value_type.hpp>
21
22 #include <boost/geometry/core/assert.hpp>
23 #include <boost/geometry/core/coordinate_type.hpp>
24 #include <boost/geometry/core/closure.hpp>
25 #include <boost/geometry/core/point_order.hpp>
26 #include <boost/geometry/core/point_type.hpp>
27
28 #include <boost/geometry/strategies/buffer.hpp>
29
30 #include <boost/geometry/algorithms/within.hpp>
31
32 #include <boost/geometry/algorithms/detail/overlay/copy_segments.hpp>
33 #include <boost/geometry/algorithms/detail/overlay/copy_segment_point.hpp>
34 #include <boost/geometry/algorithms/detail/overlay/enrichment_info.hpp>
35 #include <boost/geometry/algorithms/detail/overlay/get_ring.hpp>
36 #include <boost/geometry/algorithms/detail/overlay/traversal_info.hpp>
37 #include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
38
39
40 namespace boost { namespace geometry
41 {
42
43 #ifndef DOXYGEN_NO_DETAIL
44 namespace detail { namespace buffer
45 {
46
47 struct buffered_ring_collection_tag : polygonal_tag, multi_tag
48 {};
49
50
51 template <typename Ring>
52 struct buffered_ring : public Ring
53 {
54 bool has_concave;
55 bool has_accepted_intersections;
56 bool has_discarded_intersections;
57 bool is_untouched_outside_original;
58
59 inline buffered_ring()
60 : has_concave(false)
61 , has_accepted_intersections(false)
62 , has_discarded_intersections(false)
63 , is_untouched_outside_original(false)
64 {}
65
66 inline bool discarded() const
67 {
68 return has_discarded_intersections && ! has_accepted_intersections;
69 }
70 inline bool has_intersections() const
71 {
72 return has_discarded_intersections || has_accepted_intersections;
73 }
74 };
75
76 // This is a collection now special for overlay (needs vector of rings)
77 template <typename Ring>
78 struct buffered_ring_collection : public std::vector<Ring>
79 {
80 };
81
82 }} // namespace detail::buffer
83
84
85 // Turn off concept checking (for now)
86 namespace dispatch
87 {
88 template <typename Geometry, bool IsConst>
89 struct check<Geometry, detail::buffer::buffered_ring_collection_tag, IsConst>
90 {
91 };
92
93 }
94
95
96 #endif // DOXYGEN_NO_DETAIL
97
98
99
100 // Register the types
101 namespace traits
102 {
103
104
105 template <typename Ring>
106 struct tag<geometry::detail::buffer::buffered_ring<Ring> >
107 {
108 typedef ring_tag type;
109 };
110
111
112 template <typename Ring>
113 struct point_order<geometry::detail::buffer::buffered_ring<Ring> >
114 {
115 static const order_selector value = geometry::point_order<Ring>::value;
116 };
117
118
119 template <typename Ring>
120 struct closure<geometry::detail::buffer::buffered_ring<Ring> >
121 {
122 static const closure_selector value = geometry::closure<Ring>::value;
123 };
124
125
126 template <typename Ring>
127 struct point_type<geometry::detail::buffer::buffered_ring_collection<Ring> >
128 {
129 typedef typename geometry::point_type<Ring>::type type;
130 };
131
132 template <typename Ring>
133 struct tag<geometry::detail::buffer::buffered_ring_collection<Ring> >
134 {
135 typedef geometry::detail::buffer::buffered_ring_collection_tag type;
136 };
137
138
139 } // namespace traits
140
141
142
143
144 namespace core_dispatch
145 {
146
147 template <typename Ring>
148 struct ring_type
149 <
150 detail::buffer::buffered_ring_collection_tag,
151 detail::buffer::buffered_ring_collection<Ring>
152 >
153 {
154 typedef Ring type;
155 };
156
157
158 // There is a specific tag, so this specialization cannot be placed in traits
159 template <typename Ring>
160 struct point_order<detail::buffer::buffered_ring_collection_tag,
161 geometry::detail::buffer::buffered_ring_collection
162 <
163 geometry::detail::buffer::buffered_ring<Ring>
164 > >
165 {
166 static const order_selector value
167 = core_dispatch::point_order<ring_tag, Ring>::value;
168 };
169
170
171 }
172
173
174 template <>
175 struct single_tag_of<detail::buffer::buffered_ring_collection_tag>
176 {
177 typedef ring_tag type;
178 };
179
180
181 namespace dispatch
182 {
183
184 template
185 <
186 typename MultiRing,
187 bool Reverse,
188 typename SegmentIdentifier,
189 typename PointOut
190 >
191 struct copy_segment_point
192 <
193 detail::buffer::buffered_ring_collection_tag,
194 MultiRing,
195 Reverse,
196 SegmentIdentifier,
197 PointOut
198 >
199 : detail::copy_segments::copy_segment_point_multi
200 <
201 MultiRing,
202 SegmentIdentifier,
203 PointOut,
204 detail::copy_segments::copy_segment_point_range
205 <
206 typename boost::range_value<MultiRing>::type,
207 Reverse,
208 SegmentIdentifier,
209 PointOut
210 >
211 >
212 {};
213
214
215 template<bool Reverse>
216 struct copy_segments
217 <
218 detail::buffer::buffered_ring_collection_tag,
219 Reverse
220 >
221 : detail::copy_segments::copy_segments_multi
222 <
223 detail::copy_segments::copy_segments_ring<Reverse>
224 >
225 {};
226
227 template <typename Point, typename MultiGeometry>
228 struct within
229 <
230 Point,
231 MultiGeometry,
232 point_tag,
233 detail::buffer::buffered_ring_collection_tag
234 >
235 {
236 template <typename Strategy>
237 static inline bool apply(Point const& point,
238 MultiGeometry const& multi, Strategy const& strategy)
239 {
240 return detail::within::point_in_geometry(point, multi, strategy) == 1;
241 }
242 };
243
244
245 template <typename Geometry>
246 struct is_empty<Geometry, detail::buffer::buffered_ring_collection_tag>
247 : detail::is_empty::multi_is_empty<detail::is_empty::range_is_empty>
248 {};
249
250
251 template <typename Geometry>
252 struct envelope<Geometry, detail::buffer::buffered_ring_collection_tag>
253 : detail::envelope::envelope_multi_range
254 <
255 detail::envelope::envelope_range
256 >
257 {};
258
259
260 } // namespace dispatch
261
262 namespace detail { namespace overlay
263 {
264
265 template<>
266 struct get_ring<detail::buffer::buffered_ring_collection_tag>
267 {
268 template<typename MultiGeometry>
269 static inline typename ring_type<MultiGeometry>::type const& apply(
270 ring_identifier const& id,
271 MultiGeometry const& multi_ring)
272 {
273 BOOST_GEOMETRY_ASSERT
274 (
275 id.multi_index >= 0
276 && id.multi_index < int(boost::size(multi_ring))
277 );
278 return get_ring<ring_tag>::apply(id, multi_ring[id.multi_index]);
279 }
280 };
281
282 }}
283
284
285 }} // namespace boost::geometry
286
287 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_BUFFERED_RING