]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/algorithms/detail/buffer/buffered_ring.hpp
update ceph source to reef 18.1.2
[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 concepts
87 {
88
89 template <typename Geometry>
90 struct concept_type<Geometry, geometry::detail::buffer::buffered_ring_collection_tag>
91 {
92 struct dummy {};
93 using type = dummy;
94 };
95
96 }
97
98
99 #endif // DOXYGEN_NO_DETAIL
100
101
102
103 // Register the types
104 namespace traits
105 {
106
107
108 template <typename Ring>
109 struct tag<geometry::detail::buffer::buffered_ring<Ring> >
110 {
111 typedef ring_tag type;
112 };
113
114
115 template <typename Ring>
116 struct point_order<geometry::detail::buffer::buffered_ring<Ring> >
117 {
118 static const order_selector value = geometry::point_order<Ring>::value;
119 };
120
121
122 template <typename Ring>
123 struct closure<geometry::detail::buffer::buffered_ring<Ring> >
124 {
125 static const closure_selector value = geometry::closure<Ring>::value;
126 };
127
128
129 template <typename Ring>
130 struct point_type<geometry::detail::buffer::buffered_ring_collection<Ring> >
131 {
132 typedef typename geometry::point_type<Ring>::type type;
133 };
134
135 template <typename Ring>
136 struct tag<geometry::detail::buffer::buffered_ring_collection<Ring> >
137 {
138 typedef geometry::detail::buffer::buffered_ring_collection_tag type;
139 };
140
141
142 } // namespace traits
143
144
145
146
147 namespace core_dispatch
148 {
149
150 template <typename Ring>
151 struct ring_type
152 <
153 detail::buffer::buffered_ring_collection_tag,
154 detail::buffer::buffered_ring_collection<Ring>
155 >
156 {
157 typedef Ring type;
158 };
159
160
161 // There is a specific tag, so this specialization cannot be placed in traits
162 template <typename Ring>
163 struct point_order<detail::buffer::buffered_ring_collection_tag,
164 geometry::detail::buffer::buffered_ring_collection
165 <
166 geometry::detail::buffer::buffered_ring<Ring>
167 > >
168 {
169 static const order_selector value
170 = core_dispatch::point_order<ring_tag, Ring>::value;
171 };
172
173
174 }
175
176
177 template <>
178 struct single_tag_of<detail::buffer::buffered_ring_collection_tag>
179 {
180 typedef ring_tag type;
181 };
182
183
184 namespace dispatch
185 {
186
187 template
188 <
189 typename MultiRing,
190 bool Reverse,
191 typename SegmentIdentifier,
192 typename PointOut
193 >
194 struct copy_segment_point
195 <
196 detail::buffer::buffered_ring_collection_tag,
197 MultiRing,
198 Reverse,
199 SegmentIdentifier,
200 PointOut
201 >
202 : detail::copy_segments::copy_segment_point_multi
203 <
204 MultiRing,
205 SegmentIdentifier,
206 PointOut,
207 detail::copy_segments::copy_segment_point_range
208 <
209 typename boost::range_value<MultiRing>::type,
210 Reverse,
211 SegmentIdentifier,
212 PointOut
213 >
214 >
215 {};
216
217
218 template<bool Reverse>
219 struct copy_segments
220 <
221 detail::buffer::buffered_ring_collection_tag,
222 Reverse
223 >
224 : detail::copy_segments::copy_segments_multi
225 <
226 detail::copy_segments::copy_segments_ring<Reverse>
227 >
228 {};
229
230 template <typename Point, typename MultiGeometry>
231 struct within
232 <
233 Point,
234 MultiGeometry,
235 point_tag,
236 detail::buffer::buffered_ring_collection_tag
237 >
238 {
239 template <typename Strategy>
240 static inline bool apply(Point const& point,
241 MultiGeometry const& multi, Strategy const& strategy)
242 {
243 return detail::within::point_in_geometry(point, multi, strategy) == 1;
244 }
245 };
246
247
248 template <typename Geometry>
249 struct is_empty<Geometry, detail::buffer::buffered_ring_collection_tag>
250 : detail::is_empty::multi_is_empty<detail::is_empty::range_is_empty>
251 {};
252
253
254 template <typename Geometry>
255 struct envelope<Geometry, detail::buffer::buffered_ring_collection_tag>
256 : detail::envelope::envelope_multi_range
257 <
258 detail::envelope::envelope_range
259 >
260 {};
261
262
263 } // namespace dispatch
264
265 namespace detail { namespace overlay
266 {
267
268 template<>
269 struct get_ring<detail::buffer::buffered_ring_collection_tag>
270 {
271 template<typename MultiGeometry>
272 static inline typename ring_type<MultiGeometry>::type const& apply(
273 ring_identifier const& id,
274 MultiGeometry const& multi_ring)
275 {
276 BOOST_GEOMETRY_ASSERT
277 (
278 id.multi_index >= 0
279 && id.multi_index < int(boost::size(multi_ring))
280 );
281 return get_ring<ring_tag>::apply(id, multi_ring[id.multi_index]);
282 }
283 };
284
285 }}
286
287
288 }} // namespace boost::geometry
289
290 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_BUFFERED_RING