From d6201ef57308e2b785c8b14ab4fc6f61588e143e Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Thu, 6 Nov 2014 11:02:39 +0100 Subject: [PATCH] [overlay] refactor counting turns This prepares next phase where we handle uu separately --- .../algorithms/detail/overlay/overlay.hpp | 43 +++++++++---------- .../detail/overlay/select_rings.hpp | 4 +- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/overlay/overlay.hpp b/include/boost/geometry/algorithms/detail/overlay/overlay.hpp index 88ac4deb3..e32600b17 100644 --- a/include/boost/geometry/algorithms/detail/overlay/overlay.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/overlay.hpp @@ -57,16 +57,6 @@ namespace boost { namespace geometry namespace detail { namespace overlay { -// Skip for assemble process -template -inline bool skip(TurnInfo const& turn_info) -{ - return (turn_info.discarded || turn_info.both(operation_union)) - && ! turn_info.any_blocked() - && ! turn_info.both(operation_intersection) - ; -} - template inline void count_turns(CountMap& count_map, TurnPoints const& turn_points) @@ -79,20 +69,29 @@ inline void count_turns(CountMap& count_map, TurnPoints const& turn_points) it != boost::end(turn_points); ++it) { - if (! skip(*it)) + typename boost::range_value::type const& turn_info = *it; + bool both_uu = turn_info.both(operation_union); + bool skip = (turn_info.discarded || both_uu) + && ! turn_info.any_blocked() + && ! turn_info.both(operation_intersection) + ; + + for (typename boost::range_iterator::type + op_it = boost::begin(turn_info.operations); + op_it != boost::end(turn_info.operations); + ++op_it) { - for (typename boost::range_iterator::type - op_it = boost::begin(it->operations); - op_it != boost::end(it->operations); - ++op_it) + ring_identifier ring_id + ( + op_it->seg_id.source_index, + op_it->seg_id.multi_index, + op_it->seg_id.ring_index + ); + + if (! skip) { - ring_identifier ring_id - ( - op_it->seg_id.source_index, - op_it->seg_id.multi_index, - op_it->seg_id.ring_index - ); - count_map[ring_id]++; + // We set it to 1, will be changed on next commit + count_map[ring_id] = 1; } } } diff --git a/include/boost/geometry/algorithms/detail/overlay/select_rings.hpp b/include/boost/geometry/algorithms/detail/overlay/select_rings.hpp index 04a7a64bd..311bfc1cf 100644 --- a/include/boost/geometry/algorithms/detail/overlay/select_rings.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/select_rings.hpp @@ -232,8 +232,8 @@ inline void update_ring_selection(Geometry1 const& geometry1, it != boost::end(all_ring_properties); ++it) { - bool has_turns = turn_count_map.find(it->first) != turn_count_map.end(); - if (! has_turns) + typename TurnCountMap::const_iterator tcit = turn_count_map.find(it->first); + if (tcit == turn_count_map.end()) { ring_identifier const id = it->first; typename RingPropertyMap::mapped_type properties = it->second; // Copy by value