diff --git a/include/boost/geometry/algorithms/detail/overlay/traversal_switch_detector.hpp b/include/boost/geometry/algorithms/detail/overlay/traversal_switch_detector.hpp index 189de14eb..f081da68a 100644 --- a/include/boost/geometry/algorithms/detail/overlay/traversal_switch_detector.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/traversal_switch_detector.hpp @@ -119,33 +119,6 @@ struct traversal_switch_detector { } - bool inspect_difference(set_type& turn_id_difference, - set_type const& turn_ids, - set_type const& other_turn_ids) const - { - // TODO: consider if std::set_difference can be used in the final version - int const turn_count = turn_ids.size(); - int const other_turn_count = other_turn_ids.size(); - - // First quick check on size (TODO: implement multiple-multiple connections) - if (turn_count - other_turn_count > 1) - { - return false; - } - - // Check if all turns are also present in the connection. - // The difference is returned - for (set_iterator it = turn_ids.begin(); it != turn_ids.end(); ++it) - { - signed_size_type const& id = *it; - if (other_turn_ids.count(id) == 0) - { - turn_id_difference.insert(id); - } - } - return true; - } - bool one_connection_to_another_region(region_properties const& region) const { // For example: @@ -227,9 +200,7 @@ struct traversal_switch_detector bool has_only_isolated_children(region_properties const& region) const { bool first_with_turn = true; - bool first_with_multiple = true; signed_size_type first_turn_id = 0; - signed_size_type first_multiple_region_id = 0; for (typename connection_map::const_iterator it = region.connected_region_counts.begin(); it != region.connected_region_counts.end(); ++it) @@ -246,43 +217,12 @@ struct traversal_switch_detector region_properties const& connected_region = mit->second; - bool const multiple = connected_region.isolated == isolation_multiple; - if (cprop.count != 1) { - if (! multiple) - { - return false; - } - - // It connects multiple times to an isolated region. - // This is allowed as long as it happens only once - if (first_with_multiple) - { - first_multiple_region_id = connected_region.region_id; - first_with_multiple = false; - } - else if (first_multiple_region_id != connected_region.region_id) - { - return false; - } - - // Turns in region should be either present in the connection, - // of form part of the connection with the other region - set_type diff; - if (! inspect_difference(diff, region.unique_turn_ids, - connected_region.unique_turn_ids)) - { - return false; - } - if (diff.size() > 1) - { - // For now: - return false; - } + return false; } - if (connected_region.isolated != isolation_yes && ! multiple) + if (connected_region.isolated != isolation_yes) { signed_size_type const unique_turn_id = *cprop.unique_turn_ids.begin(); if (first_with_turn) @@ -296,6 +236,7 @@ struct traversal_switch_detector } } } + // If there is only one connection (with a 'parent'), and all other // connections are itself isolated, it is isolated return true; diff --git a/test/algorithms/overlay/multi_overlay_cases.hpp b/test/algorithms/overlay/multi_overlay_cases.hpp index 532c1ccba..db3eb40d4 100644 --- a/test/algorithms/overlay/multi_overlay_cases.hpp +++ b/test/algorithms/overlay/multi_overlay_cases.hpp @@ -1236,6 +1236,12 @@ static std::string case_recursive_boxes_80[2] = "MULTIPOLYGON(((1 1,1 2,2 1,1 1)),((3 2,3 3,4 3,3 2)))" }; +static std::string case_recursive_boxes_81[2] = +{ + "MULTIPOLYGON(((3 4,2 4,2 5,3 4)),((3 3,2 3,2 4,3 3)),((3 3,3 4,4 5,5 4,5 3,3 3),(4 4,3.5 3.5,4 3,4 4)),((2 1,2 0,1 0,1 1,0 1,1 2,3 2,4 3,4 1,2 1)))", + "MULTIPOLYGON(((2 4,2 2,1 2,0 1,0 3,1 3,1 4,2 4)),((2 4,2 5,3 4,2 4)),((3 4,5 4,5 3,3 3,3 4)),((1 4,0 4,0 5,1 5,1 4)),((2 1,2 0,0 0,0 1,2 1)),((4 2,5 2,4 1,3 1,4 2)),((4 1,5 1,4 0,4 1)))" +}; + static std::string pie_21_7_21_0_3[2] = { "MULTIPOLYGON(((2500 2500,2500 3875,2855 3828,3187 3690,3472 3472,3690 3187,3828 2855,3875 2500,3828 2144,3690 1812,3472 1527,3187 1309,2855 1171,2499 1125,2144 1171,1812 1309,1527 1527,1309 1812,1171 2144,1125 2499,1171 2855,1309 3187,2500 2500)))", diff --git a/test/algorithms/set_operations/intersection/intersection_multi.cpp b/test/algorithms/set_operations/intersection/intersection_multi.cpp index f982cbca9..aa63d85fc 100644 --- a/test/algorithms/set_operations/intersection/intersection_multi.cpp +++ b/test/algorithms/set_operations/intersection/intersection_multi.cpp @@ -168,7 +168,7 @@ void test_areal() // TODO: isolated region with multiple connection should be handled // differently - TEST_INTERSECTION_IGNORE(case_141_multi, 2, -1, 74.5); + TEST_INTERSECTION_IGNORE(case_141_multi, 3, -1, 74.5); #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS TEST_INTERSECTION(case_recursive_boxes_1, 10, 97, 47.0); @@ -355,6 +355,7 @@ void test_areal() TEST_INTERSECTION(case_recursive_boxes_78, 9, -1, 8.0); TEST_INTERSECTION(case_recursive_boxes_79, 5, -1, 9.0); TEST_INTERSECTION(case_recursive_boxes_80, 1, -1, 0.25); + TEST_INTERSECTION(case_recursive_boxes_81, 5, -1, 3.75); test_one("ggl_list_20120915_h2_a", ggl_list_20120915_h2[0], ggl_list_20120915_h2[1],