From 378e266bc3d484aa653e65cd7a03bd26ddc74181 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 27 Apr 2016 14:27:39 +0200 Subject: [PATCH] [cluster] move open_count to cluster_info itself to avoid calculating it multiple times. Rename assign_startable... to gather_cluster_properties --- .../geometry/algorithms/detail/overlay/cluster_info.hpp | 4 ++++ .../detail/overlay/enrich_intersection_points.hpp | 2 +- .../algorithms/detail/overlay/handle_colocations.hpp | 7 +++++-- .../geometry/algorithms/detail/overlay/traversal.hpp | 9 ++------- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/overlay/cluster_info.hpp b/include/boost/geometry/algorithms/detail/overlay/cluster_info.hpp index 4e757e7d1..5b460919f 100644 --- a/include/boost/geometry/algorithms/detail/overlay/cluster_info.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/cluster_info.hpp @@ -28,8 +28,12 @@ struct cluster_info bool switch_source; // For clusters with a touch, conform turn_info uu + //! Number of open spaces (e.g. 2 for touch) + std::size_t open_count; + inline cluster_info() : switch_source(false) + , open_count(0) {} }; diff --git a/include/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp b/include/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp index c79c9cf50..021a07e74 100644 --- a/include/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp @@ -328,7 +328,7 @@ inline void enrich_intersection_points(Turns& turns, if (has_colocations) { - detail::overlay::assign_startable_in_clusters( + detail::overlay::gather_cluster_properties( clusters, turns, for_operation, geometry1, geometry2); } diff --git a/include/boost/geometry/algorithms/detail/overlay/handle_colocations.hpp b/include/boost/geometry/algorithms/detail/overlay/handle_colocations.hpp index b16260b0b..242f0de00 100644 --- a/include/boost/geometry/algorithms/detail/overlay/handle_colocations.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/handle_colocations.hpp @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -498,7 +499,7 @@ template typename Geometry1, typename Geometry2 > -inline void assign_startable_in_clusters(Clusters& clusters, Turns& turns, +inline void gather_cluster_properties(Clusters& clusters, Turns& turns, operation_type for_operation, Geometry1 const& geometry1, Geometry2 const& geometry2) { @@ -516,7 +517,8 @@ inline void assign_startable_in_clusters(Clusters& clusters, Turns& turns, for (typename Clusters::iterator mit = clusters.begin(); mit != clusters.end(); ++mit) { - std::set const& ids = mit->second.turn_indices; + cluster_info& cinfo = mit->second; + std::set const& ids = cinfo.turn_indices; if (ids.empty()) { continue; @@ -570,6 +572,7 @@ inline void assign_startable_in_clusters(Clusters& clusters, Turns& turns, } } + cinfo.open_count = sbs.open_count(turns); } } diff --git a/include/boost/geometry/algorithms/detail/overlay/traversal.hpp b/include/boost/geometry/algorithms/detail/overlay/traversal.hpp index 51f014cd9..00d31c370 100644 --- a/include/boost/geometry/algorithms/detail/overlay/traversal.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/traversal.hpp @@ -493,13 +493,8 @@ struct traversal sbs.apply(turn.point); - std::size_t open_count = 0; - if (is_union) // && ! cinfo.switch_source) - { - open_count = sbs.open_count(m_turns); - } - - is_touching = open_count > 1; + // TODO: use also cinfo.switch_source + is_touching = is_union && cinfo.open_count > 1; if (is_touching) { sbs.reverse();