From 7fee72257d09441452dcdc8cd788cb7e1568fa22 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 6 Apr 2016 10:17:31 +0200 Subject: [PATCH] [traverse] split condition to cc / non cc --- .../algorithms/detail/overlay/traverse.hpp | 67 ++++++++++--------- 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/overlay/traverse.hpp b/include/boost/geometry/algorithms/detail/overlay/traverse.hpp index e5845ffe9..b5bf6e18d 100644 --- a/include/boost/geometry/algorithms/detail/overlay/traverse.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/traverse.hpp @@ -252,46 +252,49 @@ struct traversal return true; } - signed_size_type const next_turn_index = get_next_turn_index(op); - - // In some cases there are two alternatives. - // For "ii", take the other one (alternate) - // UNLESS the other one is already visited - // For "uu", take the same one (see above); - // For "cc", take either one, but if there is a starting one, - // take that one. If next is dead end, skip that one. - if ( (op.operation == operation_continue - && traverse_possible(next_turn_index) - && ! result) - || (op.operation == OperationType - && ! op.visited.finished() - && (! result - || select_source(turn_index, op.seg_id, seg_id) - ) - ) - ) + if (op.operation == operation_continue) { - if (op.operation == operation_continue) + // For "cc", take either one, but if there is a starting one, + // take that one. If next is dead end, skip that one. + + signed_size_type const next_turn_index = get_next_turn_index(op); + + if (! result && traverse_possible(next_turn_index)) { max_remaining_distance = op.remaining_distance; + selected_op_index = i; + debug_traverse(turn, op, " Candidate"); + result = true; + } + + if (result) + { + if (next_turn_index == start_turn_index) + { + selected_op_index = i; + debug_traverse(turn, op, " Candidate override (start)"); + } + else if (op.remaining_distance > max_remaining_distance) + { + max_remaining_distance = op.remaining_distance; + selected_op_index = i; + debug_traverse(turn, op, " Candidate override (remaining)"); + } } - selected_op_index = i; - debug_traverse(turn, op, " Candidate"); - result = true; } - - if (op.operation == operation_continue && result) + else { - if (next_turn_index == start_turn_index) + // For "ii", take the other one (alternate) + // UNLESS the other one is already visited + // For "uu", take the same one (see above); + if (op.operation == OperationType + && ! op.visited.finished() + && (! result || select_source(turn_index, op.seg_id, seg_id)) + ) { selected_op_index = i; - debug_traverse(turn, op, " Candidate override (start)"); - } - else if (op.remaining_distance > max_remaining_distance) - { - max_remaining_distance = op.remaining_distance; - selected_op_index = i; - debug_traverse(turn, op, " Candidate override (remaining)"); + debug_traverse(turn, op, " Candidate"); + result = true; } } }