]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/algorithms/detail/buffer/buffer_policies.hpp
update source to Ceph Pacific 16.2.2
[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, 2018.
6 // Modifications copyright (c) 2017-2018, 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 #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/traversal_info.hpp>
26 #include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
27
28 #include <boost/geometry/strategies/buffer.hpp>
29
30
31 namespace boost { namespace geometry
32 {
33
34
35 #ifndef DOXYGEN_NO_DETAIL
36 namespace detail { namespace buffer
37 {
38
39
40 enum intersection_location_type
41 {
42 location_ok, inside_buffer, location_discard
43 };
44
45 class backtrack_for_buffer
46 {
47 public :
48 typedef detail::overlay::backtrack_state state_type;
49
50 template
51 <
52 typename Operation,
53 typename Rings,
54 typename Turns,
55 typename Geometry,
56 typename Strategy,
57 typename RobustPolicy,
58 typename Visitor
59 >
60 static inline void apply(std::size_t size_at_start,
61 Rings& rings, typename boost::range_value<Rings>::type& ring,
62 Turns& turns,
63 typename boost::range_value<Turns>::type const& /*turn*/,
64 Operation& operation,
65 detail::overlay::traverse_error_type /*traverse_error*/,
66 Geometry const& ,
67 Geometry const& ,
68 Strategy const& ,
69 RobustPolicy const& ,
70 state_type& state,
71 Visitor& /*visitor*/
72 )
73 {
74 #if defined(BOOST_GEOMETRY_COUNT_BACKTRACK_WARNINGS)
75 extern int g_backtrack_warning_count;
76 g_backtrack_warning_count++;
77 #endif
78 //std::cout << "!";
79 //std::cout << "WARNING " << traverse_error_string(traverse_error) << std::endl;
80
81 state.m_good = false;
82
83 // Make bad output clean
84 rings.resize(size_at_start);
85 ring.clear();
86
87 // Reject this as a starting point
88 operation.visited.set_rejected();
89
90 // And clear all visit info
91 clear_visit_info(turns);
92 }
93 };
94
95 struct buffer_overlay_visitor
96 {
97 public :
98 void print(char const* /*header*/)
99 {
100 }
101
102 template <typename Turns>
103 void print(char const* /*header*/, Turns const& /*turns*/, int /*turn_index*/)
104 {
105 }
106
107 template <typename Turns>
108 void print(char const* /*header*/, Turns const& /*turns*/, int /*turn_index*/, int /*op_index*/)
109 {
110 }
111
112 template <typename Turns>
113 void visit_turns(int , Turns const& ) {}
114
115 template <typename Clusters, typename Turns>
116 void visit_clusters(Clusters const& , Turns const& ) {}
117
118 template <typename Turns, typename Turn, typename Operation>
119 void visit_traverse(Turns const& /*turns*/, Turn const& /*turn*/, Operation const& /*op*/, const char* /*header*/)
120 {
121 }
122
123 template <typename Turns, typename Turn, typename Operation>
124 void visit_traverse_reject(Turns const& , Turn const& , Operation const& ,
125 detail::overlay::traverse_error_type )
126 {}
127
128 template <typename Rings>
129 void visit_generated_rings(Rings const& )
130 {}
131 };
132
133
134 // Should follow traversal-turn-concept (enrichment, visit structure)
135 // and adds index in piece vector to find it back
136 template <typename Point, typename SegmentRatio>
137 struct buffer_turn_operation
138 : public detail::overlay::traversal_turn_operation<Point, SegmentRatio>
139 {
140 signed_size_type piece_index;
141 signed_size_type index_in_robust_ring;
142
143 inline buffer_turn_operation()
144 : piece_index(-1)
145 , index_in_robust_ring(-1)
146 {}
147 };
148
149 // Version for buffer including type of location, is_opposite, and helper variables
150 template <typename Point, typename RobustPoint, typename SegmentRatio>
151 struct buffer_turn_info
152 : public detail::overlay::turn_info
153 <
154 Point,
155 SegmentRatio,
156 buffer_turn_operation<Point, SegmentRatio>
157 >
158 {
159 typedef Point point_type;
160 typedef RobustPoint robust_point_type;
161
162 std::size_t turn_index; // TODO: this might go if partition can operate on non-const input
163
164 RobustPoint robust_point;
165
166 inline RobustPoint const& get_robust_point() const
167 {
168 return robust_point;
169 }
170
171 intersection_location_type location;
172
173 robust_point_type rob_pi, rob_pj, rob_qi, rob_qj;
174
175 std::size_t count_within;
176
177 bool within_original;
178 signed_size_type count_in_original; // increased by +1 for in ext.ring, -1 for int.ring
179
180 std::size_t count_on_offsetted;
181 std::size_t count_on_helper;
182 std::size_t count_within_near_offsetted;
183
184 inline buffer_turn_info()
185 : turn_index(0)
186 , location(location_ok)
187 , count_within(0)
188 , within_original(false)
189 , count_in_original(0)
190 , count_on_offsetted(0)
191 , count_on_helper(0)
192 , count_within_near_offsetted(0)
193 {}
194 };
195
196 struct buffer_operation_less
197 {
198 template <typename Turn>
199 inline bool operator()(Turn const& left, Turn const& right) const
200 {
201 segment_identifier const& sl = left.seg_id;
202 segment_identifier const& sr = right.seg_id;
203
204 // Sort them descending
205 return sl == sr
206 ? left.fraction < right.fraction
207 : sl < sr;
208 }
209 };
210
211 }} // namespace detail::buffer
212 #endif // DOXYGEN_NO_DETAIL
213
214
215 }} // namespace boost::geometry
216
217 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_BUFFER_POLICIES_HPP