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