From fa6d0ce2ee1e4d63ba99e2f7965701b0ec73eee0 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 6 Dec 2017 11:23:27 +0100 Subject: [PATCH] [traverse] replace switch_source by inspecting region ids locally --- .../algorithms/detail/overlay/traversal.hpp | 28 +++++++++++-------- .../overlay/traversal_switch_detector.hpp | 23 --------------- .../algorithms/detail/overlay/turn_info.hpp | 2 -- .../extensions/algorithms/dissolve.hpp | 1 - 4 files changed, 17 insertions(+), 37 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/overlay/traversal.hpp b/include/boost/geometry/algorithms/detail/overlay/traversal.hpp index fe1a7adee..2d8f46e24 100644 --- a/include/boost/geometry/algorithms/detail/overlay/traversal.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/traversal.hpp @@ -236,7 +236,23 @@ struct traversal segment_identifier const& current, segment_identifier const& previous) const { - return turn.switch_source + turn_operation_type const& op0 = turn.operations[0]; + turn_operation_type const& op1 = turn.operations[1]; + + bool const switch_source = op0.enriched.region_id != -1 + && op0.enriched.region_id == op1.enriched.region_id; + +#if defined(BOOST_GEOMETRY_DEBUG_TRAVERSAL_SWITCH_DETECTOR) + if (switch_source) + { + std::cout << "Switch source at " << &turn << std::endl; + } + else + { + std::cout << "DON'T SWITCH SOURCES at " << &turn << std::endl; + } +#endif + return switch_source ? current.*Member != previous.*Member : current.*Member == previous.*Member; } @@ -247,16 +263,6 @@ struct traversal { // For uu/ii, only switch sources if indicated -#if defined(BOOST_GEOMETRY_DEBUG_TRAVERSAL_SWITCH_DETECTOR) - if (turn.switch_source) - { - std::cout << "Switch source at " << turn_index << std::endl; - } - else - { - std::cout << "DON'T SWITCH SOURCES at " << turn_index << std::endl; - } -#endif if (OverlayType == overlay_buffer || OverlayType == overlay_dissolve_union) { diff --git a/include/boost/geometry/algorithms/detail/overlay/traversal_switch_detector.hpp b/include/boost/geometry/algorithms/detail/overlay/traversal_switch_detector.hpp index 13edb4b90..b4a3edee4 100644 --- a/include/boost/geometry/algorithms/detail/overlay/traversal_switch_detector.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/traversal_switch_detector.hpp @@ -611,29 +611,6 @@ struct traversal_switch_detector } } - // Iterate through all uu/ii turns (non-clustered) - for (std::size_t turn_index = 0; turn_index < m_turns.size(); ++turn_index) - { - turn_type& turn = m_turns[turn_index]; - - if (turn.discarded - || turn.blocked() - || turn.is_clustered() - || ! (turn.both(operation_union) || turn.both(operation_intersection))) - { - // Skip discarded, blocked, non-uu/ii and clustered turns - continue; - } - - - signed_size_type const region0 = get_region_id(turn.operations[0]); - signed_size_type const region1 = get_region_id(turn.operations[1]); - - // Switch sources for same region - turn.switch_source = region0 == region1; - } - - #if defined(BOOST_GEOMETRY_DEBUG_TRAVERSAL_SWITCH_DETECTOR) std::cout << "SWITCH END ITERATION" << std::endl; diff --git a/include/boost/geometry/algorithms/detail/overlay/turn_info.hpp b/include/boost/geometry/algorithms/detail/overlay/turn_info.hpp index 3ed75cf09..545b5e902 100644 --- a/include/boost/geometry/algorithms/detail/overlay/turn_info.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/turn_info.hpp @@ -94,7 +94,6 @@ struct turn_info bool discarded; bool has_colocated_both; // Colocated with a uu turn (for union) or ii (other) - bool switch_source; // For u/u turns which can either switch or not Container operations; @@ -104,7 +103,6 @@ struct turn_info , cluster_id(-1) , discarded(false) , has_colocated_both(false) - , switch_source(false) {} inline bool both(operation_type type) const diff --git a/include/boost/geometry/extensions/algorithms/dissolve.hpp b/include/boost/geometry/extensions/algorithms/dissolve.hpp index c9d4a8aaa..0c7ecee0c 100644 --- a/include/boost/geometry/extensions/algorithms/dissolve.hpp +++ b/include/boost/geometry/extensions/algorithms/dissolve.hpp @@ -127,7 +127,6 @@ struct dissolve_ring_or_polygon turn.discarded = false; turn.cluster_id = -1; turn.has_colocated_both = false; - turn.switch_source = false; turn.touch_only = false; }