mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-11 13:34:10 +00:00
[traverse] enhance validity by checking touching (uu or combined turns creating a touch)
in clusters.
This commit is contained in:
parent
5178c4e241
commit
df9a97dea8
@ -354,7 +354,7 @@ struct traversal
|
||||
|
||||
inline bool select_from_cluster(signed_size_type& turn_index,
|
||||
int& op_index, signed_size_type start_turn_index,
|
||||
sbs_type const& sbs, bool allow_pass_rank) const
|
||||
sbs_type const& sbs, bool is_touching) const
|
||||
{
|
||||
bool const is_union = OperationType == operation_union;
|
||||
bool const is_intersection = OperationType == operation_intersection;
|
||||
@ -380,7 +380,7 @@ struct traversal
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! allow_pass_rank && ranked_op.visited.finalized())
|
||||
if (! is_touching && ranked_op.visited.finalized())
|
||||
{
|
||||
// Skip this one, go to next
|
||||
min_rank = ranked_point.main_rank;
|
||||
@ -419,7 +419,7 @@ struct traversal
|
||||
result = true;
|
||||
selected_rank = ranked_point.main_rank;
|
||||
}
|
||||
else if (! allow_pass_rank)
|
||||
else if (! is_touching)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
@ -429,7 +429,8 @@ struct traversal
|
||||
}
|
||||
|
||||
inline bool select_turn_from_cluster(signed_size_type& turn_index,
|
||||
int& op_index, signed_size_type start_turn_index,
|
||||
int& op_index, bool& is_touching,
|
||||
signed_size_type start_turn_index,
|
||||
segment_identifier const& previous_seg_id) const
|
||||
{
|
||||
bool const is_union = OperationType == operation_union;
|
||||
@ -517,14 +518,14 @@ struct traversal
|
||||
}
|
||||
}
|
||||
|
||||
bool allow = false;
|
||||
if (open_count > 1)
|
||||
is_touching = open_count > 1;
|
||||
if (is_touching)
|
||||
{
|
||||
sbs.reverse();
|
||||
allow = true;
|
||||
}
|
||||
|
||||
return select_from_cluster(turn_index, op_index, start_turn_index, sbs, allow);
|
||||
return select_from_cluster(turn_index, op_index, start_turn_index, sbs,
|
||||
is_touching);
|
||||
}
|
||||
|
||||
inline void change_index_for_self_turn(signed_size_type& to_vertex_index,
|
||||
@ -624,6 +625,7 @@ struct traversal
|
||||
bool select_turn(signed_size_type start_turn_index,
|
||||
signed_size_type& turn_index,
|
||||
int& op_index,
|
||||
bool& is_touching,
|
||||
int previous_op_index,
|
||||
signed_size_type previous_turn_index,
|
||||
segment_identifier const& previous_seg_id,
|
||||
@ -631,7 +633,7 @@ struct traversal
|
||||
{
|
||||
if (m_turns[turn_index].cluster_id >= 0)
|
||||
{
|
||||
if (! select_turn_from_cluster(turn_index, op_index,
|
||||
if (! select_turn_from_cluster(turn_index, op_index, is_touching,
|
||||
start_turn_index, previous_seg_id))
|
||||
{
|
||||
return false;
|
||||
|
@ -119,7 +119,9 @@ struct traversal_ring_creator
|
||||
m_visitor.visit_traverse(m_turns, previous_turn, previous_op, "Start");
|
||||
}
|
||||
|
||||
bool is_touching = false;
|
||||
if (! m_trav.select_turn(start_turn_index, turn_index, op_index,
|
||||
is_touching,
|
||||
previous_op_index, previous_turn_index, previous_seg_id,
|
||||
is_start))
|
||||
{
|
||||
|
@ -66,6 +66,7 @@ struct traversal_switch_detector
|
||||
int start_op_index,
|
||||
signed_size_type& turn_index,
|
||||
int& op_index,
|
||||
bool& is_touching,
|
||||
bool is_start)
|
||||
{
|
||||
int const previous_op_index = op_index;
|
||||
@ -99,6 +100,7 @@ struct traversal_switch_detector
|
||||
}
|
||||
|
||||
if (! m_trav.select_turn(start_turn_index, turn_index, op_index,
|
||||
is_touching,
|
||||
previous_op_index, previous_turn_index, previous_seg_id,
|
||||
is_start))
|
||||
{
|
||||
@ -137,9 +139,10 @@ struct traversal_switch_detector
|
||||
signed_size_type current_turn_index = start_turn_index;
|
||||
int current_op_index = start_op_index;
|
||||
|
||||
bool is_touching = false;
|
||||
traverse_error_type error = travel_to_next_turn(start_turn_index,
|
||||
start_op_index,
|
||||
current_turn_index, current_op_index,
|
||||
current_turn_index, current_op_index, is_touching,
|
||||
true);
|
||||
|
||||
if (error != traverse_error_none)
|
||||
@ -152,7 +155,7 @@ struct traversal_switch_detector
|
||||
// SWITCH
|
||||
{
|
||||
turn_type const& turn = m_turns[current_turn_index];
|
||||
if (turn.both(operation_union))
|
||||
if (is_touching || turn.both(operation_union))
|
||||
{
|
||||
#if defined(BOOST_GEOMETRY_DEBUG_TRAVERSAL_SWITCH_DETECTOR)
|
||||
std::cout << "FOUND OTHER UU TURN RIGHT AFTER START "
|
||||
@ -186,7 +189,7 @@ struct traversal_switch_detector
|
||||
|
||||
// Below three reasons to stop.
|
||||
error = travel_to_next_turn(start_turn_index, start_op_index,
|
||||
current_turn_index, current_op_index,
|
||||
current_turn_index, current_op_index, is_touching,
|
||||
false);
|
||||
|
||||
if (error != traverse_error_none)
|
||||
@ -197,7 +200,7 @@ struct traversal_switch_detector
|
||||
// SWITCH
|
||||
{
|
||||
turn_type const& turn = m_turns[current_turn_index];
|
||||
if (turn.both(operation_union))
|
||||
if (is_touching || turn.both(operation_union))
|
||||
{
|
||||
if (current_turn_index == start_turn_index)
|
||||
{
|
||||
|
@ -511,7 +511,7 @@ void test_specific()
|
||||
ticket_11676[0], ticket_11676[1],
|
||||
1, 18, 2537992.5,
|
||||
2, 11, 294963.5,
|
||||
1, -1, 2537992.5 + 294963.5,
|
||||
2, -1, 2537992.5 + 294963.5,
|
||||
settings);
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ void test_areal()
|
||||
case_recursive_boxes_3[0], case_recursive_boxes_3[1],
|
||||
24, -1, 21.5,
|
||||
25, -1, 22.5,
|
||||
36, -1, 44.0);
|
||||
37, -1, 44.0);
|
||||
|
||||
// 4, input is not valid
|
||||
|
||||
@ -202,7 +202,7 @@ void test_areal()
|
||||
case_recursive_boxes_6[0], case_recursive_boxes_6[1],
|
||||
6, -1, 3.5,
|
||||
3, -1, 1.5,
|
||||
7, -1, 5.0);
|
||||
8, -1, 5.0);
|
||||
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_7",
|
||||
case_recursive_boxes_7[0], case_recursive_boxes_7[1],
|
||||
@ -220,7 +220,7 @@ void test_areal()
|
||||
case_recursive_boxes_9[0], case_recursive_boxes_9[1],
|
||||
3, -1, 1.5,
|
||||
4, -1, 2.5,
|
||||
5, -1, 4.0);
|
||||
6, -1, 4.0);
|
||||
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_10",
|
||||
case_recursive_boxes_10[0], case_recursive_boxes_10[1],
|
||||
|
@ -147,8 +147,7 @@ void test_areal()
|
||||
2, 0, 16, 48);
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_113_multi",
|
||||
case_113_multi[0], case_113_multi[1],
|
||||
1, 0, 13, 162.5,
|
||||
ignore_validity);
|
||||
2, 0, 13, 162.5);
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_114_multi",
|
||||
case_114_multi[0], case_114_multi[1],
|
||||
1, 1, 13, 187.5);
|
||||
@ -185,7 +184,7 @@ void test_areal()
|
||||
1, 0, 14, 100.0); // Area from SQL Server
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_3",
|
||||
case_recursive_boxes_3[0], case_recursive_boxes_3[1],
|
||||
16, 0, 159, 56.5,
|
||||
17, 0, 159, 56.5,
|
||||
ignore_validity); // Area from SQL Server
|
||||
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_4",
|
||||
@ -223,19 +222,16 @@ void test_areal()
|
||||
1, 0, -1, 8.0);
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_12",
|
||||
case_recursive_boxes_12[0], case_recursive_boxes_12[1],
|
||||
5, 0, -1, 6.0,
|
||||
ignore_validity);
|
||||
6, 0, -1, 6.0);
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_13",
|
||||
case_recursive_boxes_13[0], case_recursive_boxes_13[1],
|
||||
3, 0, -1, 10.25);
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_14",
|
||||
case_recursive_boxes_14[0], case_recursive_boxes_14[1],
|
||||
4, 0, -1, 4.5,
|
||||
ignore_validity);
|
||||
5, 0, -1, 4.5);
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_15",
|
||||
case_recursive_boxes_15[0], case_recursive_boxes_15[1],
|
||||
2, 0, -1, 6.0,
|
||||
ignore_validity);
|
||||
3, 0, -1, 6.0);
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_16",
|
||||
case_recursive_boxes_16[0], case_recursive_boxes_16[1],
|
||||
1, 1, -1, 22.0,
|
||||
|
Loading…
x
Reference in New Issue
Block a user