mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-11 13:34:10 +00:00
[traversal] handle non clustered ii turns using sort-by-side
This commit is contained in:
parent
a801bf621e
commit
3c58f15105
@ -572,6 +572,32 @@ struct traversal
|
||||
return result;
|
||||
}
|
||||
|
||||
inline bool analyze_ii_intersection(signed_size_type& turn_index, int& op_index,
|
||||
turn_type const& current_turn,
|
||||
segment_identifier const& previous_seg_id)
|
||||
{
|
||||
sbs_type sbs;
|
||||
|
||||
// Add this turn to the sort-by-side sorter
|
||||
bool has_origin = false;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
turn_operation_type const& op = current_turn.operations[i];
|
||||
bool const is_origin = op.seg_id.source_index
|
||||
== previous_seg_id.source_index;
|
||||
has_origin = has_origin || is_origin;
|
||||
sbs.add(op, turn_index, i, m_geometry1, m_geometry2, is_origin);
|
||||
}
|
||||
|
||||
if (! has_origin)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
sbs.apply(current_turn.point);
|
||||
return analyze_cluster_intersection(turn_index, op_index, sbs);
|
||||
}
|
||||
|
||||
inline void change_index_for_self_turn(signed_size_type& to_vertex_index,
|
||||
turn_type const& start_turn,
|
||||
turn_operation_type const& start_op,
|
||||
@ -665,7 +691,7 @@ struct traversal
|
||||
return true;
|
||||
}
|
||||
|
||||
bool select_turn(signed_size_type start_turn_index,
|
||||
bool select_turn(signed_size_type start_turn_index, int start_op_index,
|
||||
signed_size_type& turn_index,
|
||||
int& op_index,
|
||||
bool& is_touching,
|
||||
@ -674,7 +700,29 @@ struct traversal
|
||||
segment_identifier const& previous_seg_id,
|
||||
bool is_start)
|
||||
{
|
||||
if (m_turns[turn_index].cluster_id >= 0)
|
||||
turn_type const& current_turn = m_turns[turn_index];
|
||||
|
||||
if (target_operation == operation_intersection
|
||||
&& current_turn.both(operation_intersection)
|
||||
&& turn_index == start_turn_index)
|
||||
{
|
||||
// Intersection can always be finished if returning at ii
|
||||
op_index = start_op_index;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (current_turn.cluster_id < 0
|
||||
&& target_operation == operation_intersection
|
||||
&& current_turn.both(operation_intersection))
|
||||
{
|
||||
if (analyze_ii_intersection(turn_index, op_index, current_turn,
|
||||
previous_seg_id))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (current_turn.cluster_id >= 0)
|
||||
{
|
||||
if (! select_turn_from_cluster(turn_index, op_index, is_touching,
|
||||
start_turn_index, previous_seg_id, is_start))
|
||||
@ -689,8 +737,6 @@ struct traversal
|
||||
}
|
||||
else
|
||||
{
|
||||
turn_type const& current_turn = m_turns[turn_index];
|
||||
|
||||
op_index = starting_operation_index(current_turn);
|
||||
if (op_index == -1)
|
||||
{
|
||||
|
@ -121,7 +121,8 @@ struct traversal_ring_creator
|
||||
}
|
||||
|
||||
bool is_touching = false;
|
||||
if (! m_trav.select_turn(start_turn_index, turn_index, op_index,
|
||||
if (! m_trav.select_turn(start_turn_index, start_op_index,
|
||||
turn_index, op_index,
|
||||
is_touching,
|
||||
previous_op_index, previous_turn_index, previous_seg_id,
|
||||
is_start))
|
||||
|
@ -449,7 +449,7 @@ void test_all()
|
||||
TEST_INTERSECTION(case_101_multi, 4.75, 4, 0);
|
||||
|
||||
TEST_INTERSECTION(case_recursive_boxes_11, 1.0, 2, 0);
|
||||
TEST_INTERSECTION(case_recursive_boxes_30, 6.0, 3, 0);
|
||||
TEST_INTERSECTION(case_recursive_boxes_30, 6.0, 4, 0);
|
||||
|
||||
TEST_UNION(case_recursive_boxes_4, 96.75, 1, 2);
|
||||
TEST_INTERSECTION_WITH(case_58_multi, 6, 2, 13.25, 1, 1);
|
||||
|
@ -415,7 +415,7 @@ void test_all()
|
||||
test_one<polygon, polygon, polygon>("ticket_9563",
|
||||
ticket_9563[0], ticket_9563[1],
|
||||
0, 0, 0,
|
||||
1, 20, 20.096189, ignore_validity);
|
||||
6, 24, 20.096189);
|
||||
#endif
|
||||
|
||||
test_one<polygon, polygon, polygon>("ticket_10108_a",
|
||||
@ -527,8 +527,7 @@ void test_all()
|
||||
mysql_21965285[0], mysql_21965285[1],
|
||||
1, 2, -1, 92.0,
|
||||
1, 1, -1, 14.0,
|
||||
1, 2, -1, 92.0 + 14.0,
|
||||
ignore_validity);
|
||||
1, 2, -1, 92.0 + 14.0);
|
||||
|
||||
test_one<polygon, polygon, polygon>("mysql_23023665_1",
|
||||
mysql_23023665_1[0], mysql_23023665_1[1],
|
||||
|
@ -334,8 +334,7 @@ void test_areal()
|
||||
|
||||
test_one<Polygon, Polygon, Polygon>("case_101",
|
||||
case_101[0], case_101[1],
|
||||
0, -1, 6.25,
|
||||
ignore_validity);
|
||||
0, -1, 6.25);
|
||||
test_one<Polygon, Polygon, Polygon>("case_102",
|
||||
case_102[0], case_102[1],
|
||||
0, -1, 3.1875);
|
||||
|
@ -158,7 +158,7 @@ void test_areal()
|
||||
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_4",
|
||||
case_recursive_boxes_4[0], case_recursive_boxes_4[1],
|
||||
7, 179, 67.0, // Area from SQL Server
|
||||
8, 179, 67.0, // Area from SQL Server
|
||||
ignore_validity);
|
||||
|
||||
// Fixed by replacing handle_tangencies in less_by_segment_ratio sort order
|
||||
@ -240,8 +240,7 @@ void test_areal()
|
||||
5, 0, 3.75);
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_30",
|
||||
case_recursive_boxes_30[0], case_recursive_boxes_30[1],
|
||||
3, 0, 6.0,
|
||||
ignore_validity);
|
||||
4, 0, 6.0);
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_31",
|
||||
case_recursive_boxes_31[0], case_recursive_boxes_31[1],
|
||||
2, 0, 2.5);
|
||||
|
Loading…
x
Reference in New Issue
Block a user