-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboost_difference.patch
236 lines (229 loc) · 7.6 KB
/
boost_difference.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
diff -ruN /usr/include/boost/geometry/algorithms/detail/difference_box_box.hpp boost/geometry/algorithms/detail/difference_box_box.hpp
--- /usr/include/boost/geometry/algorithms/detail/difference_box_box.hpp 1970-01-01 01:00:00.000000000 +0100
+++ boost/geometry/algorithms/detail/difference_box_box.hpp 2018-03-21 20:37:14.638250585 +0100
@@ -0,0 +1,152 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DIFFERENCE_BOX_BOX_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DIFFERENCE_BOX_BOX_HPP
+#include <algorithm>
+#include <boost/foreach.hpp>
+#include <boost/geometry/util/range.hpp>
+#include <boost/geometry/algorithms/is_valid.hpp>
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace difference
+{
+
+template
+<
+ typename OutBox,
+ int corner,
+ size_t dim,
+ size_t end,
+ size_t i
+>
+struct set_for_each {
+ typedef typename traits::point_type<OutBox>::type PointOut;
+ typedef typename traits::coordinate_type<PointOut>::type CoordinatesOut;
+ static inline void impl(
+ OutBox arr[2 * dim],
+ const CoordinatesOut &val)
+ {
+ set<corner, dim>(arr[i], val);
+ set_for_each<OutBox, corner, dim, end, i + 1>::impl(arr, val);
+ }
+ };
+
+template
+<
+ typename OutBox,
+ int corner,
+ size_t dim,
+ size_t end
+>
+struct set_for_each<OutBox, corner, dim, end, end> {
+ typedef typename traits::point_type<OutBox>::type PointOut;
+ typedef typename traits::coordinate_type<PointOut>::type CoordinatesOut;
+ static inline void impl(
+ OutBox arr[2*dim],
+ const CoordinatesOut &val) { }
+};
+
+template
+<
+ typename Box1,
+ typename Box2,
+ typename OutBox,
+ int coord_dim,
+ int dim
+>
+struct box_diff_rec {
+ static inline void
+ impl(const Box1 &minuend, const Box2 &subtrahend,
+ OutBox (&candidates)[2*dim]) {
+ typedef typename traits::point_type<Box1>::type Point1;
+ typedef typename traits::point_type<Box2>::type Point2;
+ typedef typename traits::coordinate_type<Point1>::type Coordinates1;
+ typedef typename traits::coordinate_type<Point2>::type Coordinates2;
+ const Coordinates1 minuend_min = get<min_corner, coord_dim>(minuend);
+ const Coordinates1 minuend_max = get<max_corner, coord_dim>(minuend);
+ const Coordinates2 subtrahend_min = get<min_corner, coord_dim>(subtrahend);
+ const Coordinates2 subtrahend_max = get<max_corner, coord_dim>(subtrahend);
+
+ set_for_each<OutBox, min_corner, coord_dim, 2 * coord_dim, 0>::impl(candidates, minuend_min);
+ set_for_each<OutBox, max_corner, coord_dim, 2 * coord_dim, 0>::impl(candidates, minuend_max);
+ set<min_corner, coord_dim>(candidates[2 * coord_dim], minuend_min);
+ set<max_corner, coord_dim>(candidates[2 * coord_dim], subtrahend_min);
+ set<min_corner, coord_dim>(candidates[2 * coord_dim+1], subtrahend_max);
+ set<max_corner, coord_dim>(candidates[2 * coord_dim+1], minuend_max);
+ set_for_each<OutBox, min_corner, coord_dim, 2 * dim, 2 * (coord_dim + 1)>::impl(candidates,
+ std::max(subtrahend_min, minuend_min));
+ set_for_each<OutBox, max_corner, coord_dim, 2 * dim, 2 * (coord_dim + 1)>::impl(candidates,
+ std::min(subtrahend_max, minuend_max));
+ box_diff_rec<Box1, Box2, OutBox, coord_dim + 1,dim>::impl(minuend, subtrahend, candidates);
+ }
+};
+
+template <
+ typename Box1,
+ typename Box2,
+ typename OutBox,
+ int dim
+>
+struct box_diff_rec<Box1, Box2, OutBox, dim, dim>
+ {
+ static inline void
+ impl(const Box1 &minuend, const Box2 &subtrahend,
+ OutBox (&candidates)[2 * dim])
+ {
+ }
+ };
+
+template
+<
+ typename Box1,
+ typename Box2,
+ typename BoxCollection
+>
+struct difference_box_box {
+ typedef typename BoxCollection::value_type OutBox;
+ typedef typename traits::point_type<Box1>::type Point1;
+ typedef typename traits::point_type<Box2>::type Point2;
+ typedef typename traits::point_type<OutBox>::type PointOut;
+ typedef typename traits::coordinate_type<Point1>::type Coordinates1;
+ typedef typename traits::coordinate_type<Point2>::type Coordinates2;
+ static const std::size_t dim = dimension<PointOut>::type::value;
+
+
+
+ static inline void apply(Box1 const& minuend,
+ Box2 const& subtrahend,
+ BoxCollection& output_collection)
+ {
+ range::back_insert_iterator<BoxCollection> out(output_collection);
+ if (boost::geometry::disjoint(minuend, subtrahend))
+ {
+ OutBox m;
+ boost::geometry::transform(minuend, m);
+ out=m;
+ }
+ else
+ {
+ OutBox candidates[2 * dim];
+ box_diff_rec<Box1, Box2, OutBox, 0, dim>::impl(minuend, subtrahend, candidates);
+ BOOST_FOREACH(OutBox& candidate, candidates)
+ {
+ if (boost::geometry::is_valid(candidate))
+ *out++ = candidate;
+ }
+ }
+ }
+};
+
+}} // namespace detail::difference
+#endif // DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DIFFERENCE_BOX_BOX_HPP
diff -ruN /usr/include/boost/geometry/algorithms/difference.hpp boost/geometry/algorithms/difference.hpp
--- /usr/include/boost/geometry/algorithms/difference.hpp 2017-12-27 10:37:04.000000000 +0100
+++ boost/geometry/algorithms/difference.hpp 2018-03-21 20:36:49.325502589 +0100
@@ -20,9 +20,11 @@
#include <boost/variant/variant_fwd.hpp>
#include <boost/geometry/algorithms/detail/overlay/intersection_insert.hpp>
+#include <boost/geometry/algorithms/detail/difference_box_box.hpp>
#include <boost/geometry/policies/robustness/get_rescale_policy.hpp>
#include <boost/geometry/strategies/default_strategy.hpp>
#include <boost/geometry/util/range.hpp>
+#include <boost/geometry/core/tags.hpp>
namespace boost { namespace geometry
@@ -369,6 +371,43 @@
}
+template
+<
+ typename GeometryTag1,
+ typename GeometryTag2,
+ typename CollectionTag,
+ typename Geometry1,
+ typename Geometry2,
+ typename Collection
+>
+struct difference_box_or_poly {
+ static inline void apply(Geometry1 const& geometry1,
+ Geometry2 const& geometry2,
+ Collection& output_collection)
+ {
+ resolve_variant::difference
+ <
+ Geometry1,
+ Geometry2
+ >::apply(geometry1, geometry2, output_collection, default_strategy());
+ }
+};
+
+template
+<
+ typename Box1,
+ typename Box2,
+ typename Collection
+>
+struct difference_box_or_poly<box_tag, box_tag, box_tag, Box1, Box2, Collection> {
+ static inline void apply(Box1 const& geometry1,
+ Box2 const& geometry2,
+ Collection& output_collection)
+ {
+ detail::difference::difference_box_box<Box1, Box2, Collection>::apply(geometry1, geometry2, output_collection);
+ }
+};
+
/*!
\brief_calc2{difference}
\ingroup difference
@@ -392,11 +431,16 @@
Geometry2 const& geometry2,
Collection& output_collection)
{
- resolve_variant::difference
+
+ difference_box_or_poly
<
- Geometry1,
- Geometry2
- >::apply(geometry1, geometry2, output_collection, default_strategy());
+ typename tag<Geometry1>::type,
+ typename tag<Geometry2>::type,
+ typename tag<typename Collection::value_type>::type,
+ Geometry1,
+ Geometry2,
+ Collection
+ >::apply(geometry1, geometry2, output_collection);
}