[cluster] move open_count to cluster_info itself to avoid calculating

it multiple times. Rename assign_startable... to gather_cluster_properties
This commit is contained in:
Barend Gehrels
2016-04-27 14:27:39 +02:00
parent 258183d7aa
commit 378e266bc3
4 changed files with 12 additions and 10 deletions

View File

@@ -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)
{}
};

View File

@@ -328,7 +328,7 @@ inline void enrich_intersection_points(Turns& turns,
if (has_colocations)
{
detail::overlay::assign_startable_in_clusters<Reverse1, Reverse2>(
detail::overlay::gather_cluster_properties<Reverse1, Reverse2>(
clusters, turns, for_operation, geometry1, geometry2);
}

View File

@@ -15,6 +15,7 @@
#include <vector>
#include <boost/range.hpp>
#include <boost/geometry/algorithms/detail/overlay/cluster_info.hpp>
#include <boost/geometry/algorithms/detail/overlay/overlay_type.hpp>
#include <boost/geometry/algorithms/detail/overlay/sort_by_side.hpp>
#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
@@ -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<signed_size_type> const& ids = mit->second.turn_indices;
cluster_info& cinfo = mit->second;
std::set<signed_size_type> 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);
}
}

View File

@@ -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();