mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-01 20:42:10 +00:00
[traverse] move counting open spaces to sort_by_side structure
This commit is contained in:
@@ -330,6 +330,35 @@ struct side_sorter
|
||||
}
|
||||
}
|
||||
|
||||
//! Check how many open spaces there are
|
||||
template <typename Turns>
|
||||
std::size_t open_count(Turns const& turns) const
|
||||
{
|
||||
typedef typename boost::range_value<Turns>::type turn_type;
|
||||
typedef typename turn_type::turn_operation_type turn_operation_type;
|
||||
|
||||
std::size_t result = 0;
|
||||
std::size_t last_rank = 0;
|
||||
for (std::size_t i = 0; i < m_ranked_points.size(); i++)
|
||||
{
|
||||
rp const& ranked_point = m_ranked_points[i];
|
||||
|
||||
if (ranked_point.main_rank > last_rank
|
||||
&& ranked_point.index == sort_by_side::index_to)
|
||||
{
|
||||
turn_type const& ranked_turn = turns[ranked_point.turn_index];
|
||||
turn_operation_type const& ranked_op = ranked_turn.operations[ranked_point.op_index];
|
||||
if (ranked_op.enriched.count_left == 0
|
||||
&& ranked_op.enriched.count_right > 0)
|
||||
{
|
||||
result++;
|
||||
last_rank = ranked_point.main_rank;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//protected :
|
||||
|
||||
typedef std::vector<rp> container_type;
|
||||
|
||||
@@ -493,30 +493,10 @@ struct traversal
|
||||
|
||||
sbs.apply(turn.point);
|
||||
|
||||
int open_count = 0;
|
||||
std::size_t open_count = 0;
|
||||
if (is_union) // && ! cinfo.switch_source)
|
||||
{
|
||||
// Check how many open spaces there are.
|
||||
// TODO: might be moved to sbs itself, though it also uses turns
|
||||
|
||||
std::size_t last_rank = 0;
|
||||
for (std::size_t i = 0; i < sbs.m_ranked_points.size(); i++)
|
||||
{
|
||||
typename sbs_type::rp const& ranked_point = sbs.m_ranked_points[i];
|
||||
|
||||
if (ranked_point.main_rank > last_rank
|
||||
&& ranked_point.index == sort_by_side::index_to)
|
||||
{
|
||||
turn_type const& ranked_turn = m_turns[ranked_point.turn_index];
|
||||
turn_operation_type const& ranked_op = ranked_turn.operations[ranked_point.op_index];
|
||||
if (ranked_op.enriched.count_left == 0
|
||||
&& ranked_op.enriched.count_right > 0)
|
||||
{
|
||||
open_count++;
|
||||
last_rank = ranked_point.main_rank;
|
||||
}
|
||||
}
|
||||
}
|
||||
open_count = sbs.open_count(m_turns);
|
||||
}
|
||||
|
||||
is_touching = open_count > 1;
|
||||
|
||||
Reference in New Issue
Block a user