Skip to content

Commit 07f419e

Browse files
committed
refactor: removed unused functionality and minor changes preparing next pr
1 parent 82ef735 commit 07f419e

File tree

8 files changed

+120
-189
lines changed

8 files changed

+120
-189
lines changed

include/boost/geometry/algorithms/detail/buffer/buffer_policies.hpp

-34
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,6 @@ g_backtrack_warning_count++;
8787
struct buffer_overlay_visitor
8888
{
8989
public :
90-
void print(char const* /*header*/)
91-
{
92-
}
93-
94-
template <typename Turns>
95-
void print(char const* /*header*/, Turns const& /*turns*/, int /*turn_index*/)
96-
{
97-
}
98-
99-
template <typename Turns>
100-
void print(char const* /*header*/, Turns const& /*turns*/, int /*turn_index*/, int /*op_index*/)
101-
{
102-
}
103-
10490
template <typename Turns>
10591
void visit_turns(int , Turns const& ) {}
10692

@@ -170,26 +156,6 @@ struct buffer_turn_info
170156
{}
171157
};
172158

173-
struct buffer_less
174-
{
175-
template <typename Indexed>
176-
inline bool operator()(Indexed const& left, Indexed const& right) const
177-
{
178-
if (! (left.subject->seg_id == right.subject->seg_id))
179-
{
180-
return left.subject->seg_id < right.subject->seg_id;
181-
}
182-
183-
// Both left and right are located on the SAME segment.
184-
if (! (left.subject->fraction == right.subject->fraction))
185-
{
186-
return left.subject->fraction < right.subject->fraction;
187-
}
188-
189-
return left.turn_index < right.turn_index;
190-
}
191-
};
192-
193159
template <typename Strategy>
194160
struct piece_get_box
195161
{

include/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp

+45-102
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ inline void enrich_sort(Operations& operations,
104104

105105
// Assign travel-to-vertex/ip index for each turn.
106106
template <typename Operations, typename Turns>
107-
inline void enrich_assign(Operations& operations, Turns& turns,
108-
bool check_consecutive_turns)
107+
inline void enrich_assign(Operations& operations, Turns& turns)
109108
{
110109
for (auto const& item : util::enumerate(operations))
111110
{
@@ -131,34 +130,6 @@ inline void enrich_assign(Operations& operations, Turns& turns,
131130
return next_turn.operations[operations[next_index].operation_index];
132131
};
133132

134-
if (check_consecutive_turns
135-
&& indexed.turn_index == operations[next_index].turn_index
136-
&& op.seg_id == next_operation().seg_id)
137-
{
138-
// If the two operations on the same turn are ordered consecutively,
139-
// and they are on the same segment, then the turn where to travel to should
140-
// be considered one further. Therefore next is increased.
141-
//
142-
// It often happens in buffer, in these configurations:
143-
// +---->--+
144-
// | |
145-
// | +->-*---->
146-
// | | |
147-
// ^ +-<-+
148-
// If the next index is not corrected, the small rectangle
149-
// will be kept in the output.
150-
151-
// This is a normal situation and occurs, for example, in every concave bend.
152-
// In general it should always travel from turn to next turn.
153-
// Only in some circumstances traveling to the same turn is necessary, for example
154-
// if there is only one turn in the outer ring.
155-
//
156-
// (For dissolve this is not done, turn_index is often
157-
// the same for two consecutive operations - but the conditions are changed
158-
// and this should be verified again)
159-
next_index = advance(next_index);
160-
}
161-
162133
// Cluster behaviour: next should point after cluster, unless
163134
// their seg_ids are not the same
164135
// (For dissolve, this is still to be examined - TODO)
@@ -285,36 +256,50 @@ struct enriched_map_default_include_policy
285256
// Add all (non discarded) operations on this ring
286257
// Blocked operations or uu on clusters (for intersection)
287258
// should be included, to block potential paths in clusters
288-
template <typename Turns, typename MappedVector, typename IncludePolicy>
289-
inline void create_map(Turns const& turns, MappedVector& mapped_vector,
290-
IncludePolicy const& include_policy)
259+
template <typename Turns, typename IncludePolicy>
260+
inline auto create_map(Turns const& turns, IncludePolicy const& include_policy)
291261
{
262+
using turn_type = typename boost::range_value<Turns>::type;
263+
using indexed_turn_operation = detail::overlay::indexed_turn_operation
264+
<
265+
typename turn_type::turn_operation_type
266+
>;
267+
268+
std::map
269+
<
270+
ring_identifier,
271+
std::vector<indexed_turn_operation>
272+
> mapped_vector;
273+
292274
for (auto const& turn_item : util::enumerate(turns))
293275
{
294276
auto const& index = turn_item.index;
295277
auto const& turn = turn_item.value;
296-
if (! turn.discarded)
278+
if (turn.discarded)
297279
{
298-
for (auto const& op_item : util::enumerate(turn.operations))
280+
continue;
281+
}
282+
283+
for (auto const& op_item : util::enumerate(turn.operations))
284+
{
285+
auto const& op_index = op_item.index;
286+
auto const& op = op_item.value;
287+
if (include_policy.include(op.operation))
299288
{
300-
auto const& op_index = op_item.index;
301-
auto const& op = op_item.value;
302-
if (include_policy.include(op.operation))
303-
{
304-
ring_identifier const ring_id
305-
(
306-
op.seg_id.source_index,
307-
op.seg_id.multi_index,
308-
op.seg_id.ring_index
309-
);
310-
mapped_vector[ring_id].emplace_back
311-
(
312-
index, op_index, op, turn.operations[1 - op_index].seg_id
313-
);
314-
}
289+
ring_identifier const ring_id
290+
(
291+
op.seg_id.source_index,
292+
op.seg_id.multi_index,
293+
op.seg_id.ring_index
294+
);
295+
mapped_vector[ring_id].emplace_back
296+
(
297+
index, op_index, op, turn.operations[1 - op_index].seg_id
298+
);
315299
}
316300
}
317301
}
302+
return mapped_vector;
318303
}
319304

320305
template <typename Point1, typename Point2>
@@ -356,7 +341,6 @@ inline void calculate_remaining_distance(Turns& turns)
356341
}
357342
}
358343

359-
360344
}} // namespace detail::overlay
361345
#endif //DOXYGEN_NO_DETAIL
362346

@@ -398,51 +382,14 @@ inline void enrich_intersection_points(Turns& turns,
398382
? detail::overlay::operation_intersection
399383
: detail::overlay::operation_union;
400384
constexpr bool is_dissolve = OverlayType == overlay_dissolve;
401-
constexpr bool is_buffer = OverlayType == overlay_buffer;
402-
403-
using turn_type = typename boost::range_value<Turns>::type;
404-
using indexed_turn_operation = detail::overlay::indexed_turn_operation
405-
<
406-
typename turn_type::turn_operation_type
407-
> ;
408-
409-
using mapped_vector_type = std::map
410-
<
411-
ring_identifier,
412-
std::vector<indexed_turn_operation>
413-
>;
414385

415386
// Turns are often used by index (in clusters, next_index, etc)
416387
// and turns may therefore NOT be DELETED - they may only be flagged as discarded
417388

418-
bool has_cc = false;
419-
bool has_colocations = false;
420-
421-
if BOOST_GEOMETRY_CONSTEXPR (! is_buffer)
422-
{
423-
// Handle colocations, gathering clusters and (below) their properties.
424-
has_colocations = detail::overlay::handle_colocations
425-
<
426-
Reverse1, Reverse2, OverlayType, Geometry1, Geometry2
427-
>(turns, clusters);
428-
// Gather cluster properties (using even clusters with
429-
// discarded turns - for open turns)
430-
detail::overlay::gather_cluster_properties
431-
<
432-
Reverse1,
433-
Reverse2,
434-
OverlayType
435-
>(clusters, turns, target_operation,
436-
geometry1, geometry2, strategy);
437-
}
438-
else
439-
{
440-
// For buffer, this was already done before calling enrich_intersection_points.
441-
has_colocations = ! clusters.empty();
442-
}
443-
444389
discard_duplicate_turns(turns, geometry1, geometry2);
445390

391+
bool has_cc = false;
392+
446393
// Discard turns not part of target overlay
447394
for (auto& turn : turns)
448395
{
@@ -491,11 +438,15 @@ inline void enrich_intersection_points(Turns& turns,
491438
strategy);
492439
}
493440

441+
if (! clusters.empty())
442+
{
443+
detail::overlay::cleanup_clusters(turns, clusters);
444+
detail::overlay::colocate_clusters(clusters, turns);
445+
}
446+
494447
// Create a map of vectors of indexed operation-types to be able
495448
// to sort intersection points PER RING
496-
mapped_vector_type mapped_vector;
497-
498-
detail::overlay::create_map(turns, mapped_vector,
449+
auto mapped_vector = detail::overlay::create_map(turns,
499450
detail::overlay::enriched_map_default_include_policy());
500451

501452
for (auto& pair : mapped_vector)
@@ -506,14 +457,6 @@ inline void enrich_intersection_points(Turns& turns,
506457
strategy);
507458
}
508459

509-
if (has_colocations)
510-
{
511-
detail::overlay::cleanup_clusters(turns, clusters);
512-
detail::overlay::colocate_clusters(clusters, turns);
513-
}
514-
515-
// After cleaning up clusters assign the next turns
516-
517460
for (auto& pair : mapped_vector)
518461
{
519462
#ifdef BOOST_GEOMETRY_DEBUG_ENRICH
@@ -524,7 +467,7 @@ inline void enrich_intersection_points(Turns& turns,
524467
detail::overlay::enrich_adapt(pair.second, turns);
525468
}
526469

527-
detail::overlay::enrich_assign(pair.second, turns, ! is_dissolve);
470+
detail::overlay::enrich_assign(pair.second, turns);
528471
}
529472

530473
if (has_cc)

include/boost/geometry/algorithms/detail/overlay/handle_colocations.hpp

-17
Original file line numberDiff line numberDiff line change
@@ -364,23 +364,6 @@ inline bool handle_colocations(Turns& turns, Clusters& clusters)
364364
return true;
365365
}
366366

367-
368-
struct is_turn_index
369-
{
370-
is_turn_index(signed_size_type index)
371-
: m_index(index)
372-
{}
373-
374-
template <typename Indexed>
375-
inline bool operator()(Indexed const& indexed) const
376-
{
377-
// Indexed is a indexed_turn_operation<Operation>
378-
return indexed.turn_index == m_index;
379-
}
380-
381-
signed_size_type m_index;
382-
};
383-
384367
template
385368
<
386369
typename Sbs,

include/boost/geometry/algorithms/detail/overlay/less_by_segment_ratio.hpp

-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ struct indexed_turn_operation
4343

4444
std::size_t turn_index;
4545
std::size_t operation_index;
46-
bool skip;
4746
// use pointers to avoid copies, const& is not possible because of usage in vector
4847
segment_identifier const* other_seg_id; // segment id of other segment of intersection of two segments
4948
TurnOperation const* subject;
@@ -53,7 +52,6 @@ struct indexed_turn_operation
5352
segment_identifier const& oid)
5453
: turn_index(ti)
5554
, operation_index(oi)
56-
, skip(false)
5755
, other_seg_id(&oid)
5856
, subject(boost::addressof(sub))
5957
{}

include/boost/geometry/algorithms/detail/overlay/overlay.hpp

+17-8
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,6 @@ namespace detail { namespace overlay
6060
//! Default visitor for overlay, doing nothing
6161
struct overlay_null_visitor
6262
{
63-
void print(char const* ) {}
64-
65-
template <typename Turns>
66-
void print(char const* , Turns const& , int) {}
67-
68-
template <typename Turns>
69-
void print(char const* , Turns const& , int , int ) {}
70-
7163
template <typename Turns>
7264
void visit_turns(int , Turns const& ) {}
7365

@@ -271,6 +263,8 @@ struct overlay
271263
cluster_info
272264
>;
273265

266+
constexpr operation_type target_operation = operation_from_overlay<OverlayType>::value;
267+
274268
turn_container_type turns;
275269

276270
detail::get_turns::no_interrupt_policy policy;
@@ -303,6 +297,21 @@ struct overlay
303297
cluster_type clusters;
304298
std::map<ring_identifier, ring_turn_info> turn_info_per_ring;
305299

300+
// Handle colocations, gathering clusters and (below) their properties.
301+
detail::overlay::handle_colocations
302+
<
303+
Reverse1, Reverse2, OverlayType, Geometry1, Geometry2
304+
>(turns, clusters);
305+
306+
// Gather cluster properties (using even clusters with
307+
// discarded turns - for open turns)
308+
detail::overlay::gather_cluster_properties
309+
<
310+
Reverse1,
311+
Reverse2,
312+
OverlayType
313+
>(clusters, turns, target_operation, geometry1, geometry2, strategy);
314+
306315
geometry::enrich_intersection_points<Reverse1, Reverse2, OverlayType>(
307316
turns, clusters, geometry1, geometry2, strategy);
308317

include/boost/geometry/extensions/algorithms/dissolve.hpp

+17
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ struct dissolve_ring
173173
typename segment_ratio_type<point_type, RescalePolicy>::type
174174
>;
175175

176+
constexpr operation_type target_operation = operation_from_overlay<OverlayType>::value;
177+
176178
std::deque<turn_info> turns;
177179
detail::dissolve::no_interrupt_policy policy;
178180
detail::self_get_turn_points::self_turns
@@ -198,6 +200,21 @@ struct dissolve_ring
198200
std::map<signed_size_type, detail::overlay::cluster_info> clusters;
199201

200202
// Enrich/traverse the polygons
203+
// Handle colocations, gathering clusters and (below) their properties.
204+
detail::overlay::handle_colocations
205+
<
206+
Reverse1, Reverse2, OverlayType, Geometry1, Geometry2
207+
>(turns, clusters);
208+
209+
// Gather cluster properties (using even clusters with
210+
// discarded turns - for open turns)
211+
detail::overlay::gather_cluster_properties
212+
<
213+
Reverse1,
214+
Reverse2,
215+
OverlayType
216+
>(clusters, turns, target_operation, geometry1, geometry2, strategy);
217+
201218
enrich_intersection_points<Reverse, Reverse, overlay_dissolve>(turns,
202219
clusters, input_ring, input_ring, rescale_policy,
203220
strategy);

test/algorithms/overlay/sort_by_side.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ std::vector<std::size_t> apply_overlay(
159159

160160
cluster_type clusters;
161161

162+
// Handle colocations, gathering clusters and (below) their properties.
163+
bg::detail::overlay::handle_colocations
164+
<
165+
Reverse1, Reverse2, OverlayType, Geometry1, Geometry2
166+
>(turns, clusters);
167+
162168
bg::enrich_intersection_points<Reverse1, Reverse2, OverlayType>(turns,
163169
clusters, geometry1, geometry2, strategy);
164170

0 commit comments

Comments
 (0)