Skip to content

Commit fa6d0ce

Browse files
committed
[traverse] replace switch_source by inspecting region ids locally
1 parent d096cc8 commit fa6d0ce

File tree

4 files changed

+17
-37
lines changed

4 files changed

+17
-37
lines changed

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

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,23 @@ struct traversal
236236
segment_identifier const& current,
237237
segment_identifier const& previous) const
238238
{
239-
return turn.switch_source
239+
turn_operation_type const& op0 = turn.operations[0];
240+
turn_operation_type const& op1 = turn.operations[1];
241+
242+
bool const switch_source = op0.enriched.region_id != -1
243+
&& op0.enriched.region_id == op1.enriched.region_id;
244+
245+
#if defined(BOOST_GEOMETRY_DEBUG_TRAVERSAL_SWITCH_DETECTOR)
246+
if (switch_source)
247+
{
248+
std::cout << "Switch source at " << &turn << std::endl;
249+
}
250+
else
251+
{
252+
std::cout << "DON'T SWITCH SOURCES at " << &turn << std::endl;
253+
}
254+
#endif
255+
return switch_source
240256
? current.*Member != previous.*Member
241257
: current.*Member == previous.*Member;
242258
}
@@ -247,16 +263,6 @@ struct traversal
247263
{
248264
// For uu/ii, only switch sources if indicated
249265

250-
#if defined(BOOST_GEOMETRY_DEBUG_TRAVERSAL_SWITCH_DETECTOR)
251-
if (turn.switch_source)
252-
{
253-
std::cout << "Switch source at " << turn_index << std::endl;
254-
}
255-
else
256-
{
257-
std::cout << "DON'T SWITCH SOURCES at " << turn_index << std::endl;
258-
}
259-
#endif
260266
if (OverlayType == overlay_buffer
261267
|| OverlayType == overlay_dissolve_union)
262268
{

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

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -611,29 +611,6 @@ struct traversal_switch_detector
611611
}
612612
}
613613

614-
// Iterate through all uu/ii turns (non-clustered)
615-
for (std::size_t turn_index = 0; turn_index < m_turns.size(); ++turn_index)
616-
{
617-
turn_type& turn = m_turns[turn_index];
618-
619-
if (turn.discarded
620-
|| turn.blocked()
621-
|| turn.is_clustered()
622-
|| ! (turn.both(operation_union) || turn.both(operation_intersection)))
623-
{
624-
// Skip discarded, blocked, non-uu/ii and clustered turns
625-
continue;
626-
}
627-
628-
629-
signed_size_type const region0 = get_region_id(turn.operations[0]);
630-
signed_size_type const region1 = get_region_id(turn.operations[1]);
631-
632-
// Switch sources for same region
633-
turn.switch_source = region0 == region1;
634-
}
635-
636-
637614
#if defined(BOOST_GEOMETRY_DEBUG_TRAVERSAL_SWITCH_DETECTOR)
638615
std::cout << "SWITCH END ITERATION" << std::endl;
639616

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ struct turn_info
9494
bool discarded;
9595

9696
bool has_colocated_both; // Colocated with a uu turn (for union) or ii (other)
97-
bool switch_source; // For u/u turns which can either switch or not
9897

9998
Container operations;
10099

@@ -104,7 +103,6 @@ struct turn_info
104103
, cluster_id(-1)
105104
, discarded(false)
106105
, has_colocated_both(false)
107-
, switch_source(false)
108106
{}
109107

110108
inline bool both(operation_type type) const

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ struct dissolve_ring_or_polygon
127127
turn.discarded = false;
128128
turn.cluster_id = -1;
129129
turn.has_colocated_both = false;
130-
turn.switch_source = false;
131130
turn.touch_only = false;
132131
}
133132

0 commit comments

Comments
 (0)