]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/algorithms/detail/buffer/buffer_policies.hpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / boost / geometry / algorithms / detail / buffer / buffer_policies.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2012-2014 Barend Gehrels, Amsterdam, the Netherlands.
4
5 // This file was modified by Oracle on 2017.
6 // Modifications copyright (c) 2017, 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_BUFFER_POLICIES_HPP
14 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_BUFFER_POLICIES_HPP
15
16 #if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
17 # define BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION
18 #endif
19
20 #include <cstddef>
21
22 #include <boost/range.hpp>
23
24 #include <boost/geometry/core/coordinate_type.hpp>
25 #include <boost/geometry/core/point_type.hpp>
26
27 #include <boost/geometry/algorithms/covered_by.hpp>
28 #include <boost/geometry/algorithms/detail/overlay/backtrack_check_si.hpp>
29 #include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
30
31 #include <boost/geometry/strategies/buffer.hpp>
32
33
34 namespace boost { namespace geometry
35 {
36
37
38 #ifndef DOXYGEN_NO_DETAIL
39 namespace detail { namespace buffer
40 {
41
42
43 enum intersection_location_type
44 {
45 location_ok, inside_buffer, location_discard
46 };
47
48 class backtrack_for_buffer
49 {
50 public :
51 typedef detail::overlay::backtrack_state state_type;
52
53 template
54 <
55 typename Operation,
56 typename Rings,
57 typename Turns,
58 typename Geometry,
59 typename Strategy,
60 typename RobustPolicy,
61 typename Visitor
62 >
63 static inline void apply(std::size_t size_at_start,
64 Rings& rings, typename boost::range_value<Rings>::type& ring,
65 Turns& turns,
66 typename boost::range_value<Turns>::type const& /*turn*/,
67 Operation& operation,
68 detail::overlay::traverse_error_type /*traverse_error*/,
69 Geometry const& ,
70 Geometry const& ,
71 Strategy const& ,
72 RobustPolicy const& ,
73 state_type& state,
74 Visitor& /*visitor*/
75 )
76 {
77 #if defined(BOOST_GEOMETRY_COUNT_BACKTRACK_WARNINGS)
78 extern int g_backtrack_warning_count;
79 g_backtrack_warning_count++;
80 #endif
81 //std::cout << "!";
82 //std::cout << "WARNING " << traverse_error_string(traverse_error) << std::endl;
83
84 state.m_good = false;
85
86 // Make bad output clean
87 rings.resize(size_at_start);
88 ring.clear();
89
90 // Reject this as a starting point
91 operation.visited.set_rejected();
92
93 // And clear all visit info
94 clear_visit_info(turns);
95 }
96 };
97
98 struct buffer_overlay_visitor
99 {
100 public :
101 void print(char const* /*header*/)
102 {
103 }
104
105 template <typename Turns>
106 void print(char const* /*header*/, Turns const& /*turns*/, int /*turn_index*/)
107 {
108 }
109
110 template <typename Turns>
111 void print(char const* /*header*/, Turns const& /*turns*/, int /*turn_index*/, int /*op_index*/)
112 {
113 }
114
115 template <typename Turns>
116 void visit_turns(int , Turns const& ) {}
117
118 template <typename Clusters, typename Turns>
119 void visit_clusters(Clusters const& , Turns const& ) {}
120
121 template <typename Turns, typename Turn, typename Operation>
122 void visit_traverse(Turns const& /*turns*/, Turn const& /*turn*/, Operation const& /*op*/, const char* /*header*/)
123 {
124 }
125
126 template <typename Turns, typename Turn, typename Operation>
127 void visit_traverse_reject(Turns const& , Turn const& , Operation const& ,
128 detail::overlay::traverse_error_type )
129 {}
130
131 template <typename Rings>
132 void visit_generated_rings(Rings const& )
133 {}
134 };
135
136
137 // Should follow traversal-turn-concept (enrichment, visit structure)
138 // and adds index in piece vector to find it back
139 template <typename Point, typename SegmentRatio>
140 struct buffer_turn_operation
141 : public detail::overlay::traversal_turn_operation<Point, SegmentRatio>
142 {
143 signed_size_type piece_index;
144 signed_size_type index_in_robust_ring;
145
146 inline buffer_turn_operation()
147 : piece_index(-1)
148 , index_in_robust_ring(-1)
149 {}
150 };
151
152 // Version for buffer including type of location, is_opposite, and helper variables
153 template <typename Point, typename RobustPoint, typename SegmentRatio>
154 struct buffer_turn_info
155 : public detail::overlay::turn_info
156 <
157 Point,
158 SegmentRatio,
159 buffer_turn_operation<Point, SegmentRatio>
160 >
161 {
162 typedef Point point_type;
163 typedef RobustPoint robust_point_type;
164
165 std::size_t turn_index; // TODO: this might go if partition can operate on non-const input
166
167 RobustPoint robust_point;
168 #if defined(BOOST_GEOMETRY_BUFFER_ENLARGED_CLUSTERS)
169 // Will (most probably) be removed later
170 RobustPoint mapped_robust_point; // alas... we still need to adapt our points, offsetting them 1 integer to be co-located with neighbours
171 #endif
172
173
174 inline RobustPoint const& get_robust_point() const
175 {
176 #if defined(BOOST_GEOMETRY_BUFFER_ENLARGED_CLUSTERS)
177 return mapped_robust_point;
178 #endif
179 return robust_point;
180 }
181
182 intersection_location_type location;
183
184 #if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION)
185 robust_point_type rob_pi, rob_pj, rob_qi, rob_qj;
186 #endif
187
188 std::size_t count_within;
189
190 bool within_original;
191 std::size_t count_on_original_boundary;
192 signed_size_type count_in_original; // increased by +1 for in ext.ring, -1 for int.ring
193
194 std::size_t count_on_offsetted;
195 std::size_t count_on_helper;
196 #if ! defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION)
197 std::size_t count_within_near_offsetted;
198 #endif
199
200 bool remove_on_multi;
201
202 // Obsolete:
203 std::size_t count_on_occupied;
204 std::size_t count_on_multi;
205
206 inline buffer_turn_info()
207 : turn_index(0)
208 , location(location_ok)
209 , count_within(0)
210 , within_original(false)
211 , count_on_original_boundary(0)
212 , count_in_original(0)
213 , count_on_offsetted(0)
214 , count_on_helper(0)
215 #if ! defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION)
216 , count_within_near_offsetted(0)
217 #endif
218 , remove_on_multi(false)
219 , count_on_occupied(0)
220 , count_on_multi(0)
221 {}
222 };
223
224 struct buffer_operation_less
225 {
226 template <typename Turn>
227 inline bool operator()(Turn const& left, Turn const& right) const
228 {
229 segment_identifier const& sl = left.seg_id;
230 segment_identifier const& sr = right.seg_id;
231
232 // Sort them descending
233 return sl == sr
234 ? left.fraction < right.fraction
235 : sl < sr;
236 }
237 };
238
239 }} // namespace detail::buffer
240 #endif // DOXYGEN_NO_DETAIL
241
242
243 }} // namespace boost::geometry
244
245 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_BUFFER_POLICIES_HPP