diff options
Diffstat (limited to 'boost/geometry/algorithms/detail/overlay/handle_self_turns.hpp')
-rw-r--r-- | boost/geometry/algorithms/detail/overlay/handle_self_turns.hpp | 55 |
1 files changed, 18 insertions, 37 deletions
diff --git a/boost/geometry/algorithms/detail/overlay/handle_self_turns.hpp b/boost/geometry/algorithms/detail/overlay/handle_self_turns.hpp index aec43548d4..435a80c272 100644 --- a/boost/geometry/algorithms/detail/overlay/handle_self_turns.hpp +++ b/boost/geometry/algorithms/detail/overlay/handle_self_turns.hpp @@ -1,10 +1,10 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2017 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2017-2023 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2019-2020. -// Modifications copyright (c) 2019-2020 Oracle and/or its affiliates. +// This file was modified by Oracle on 2019-2022. +// Modifications copyright (c) 2019-2022 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -19,11 +19,11 @@ #include <boost/range/end.hpp> #include <boost/range/value_type.hpp> +#include <boost/geometry/algorithms/detail/covered_by/implementation.hpp> #include <boost/geometry/algorithms/detail/overlay/cluster_info.hpp> #include <boost/geometry/algorithms/detail/overlay/is_self_turn.hpp> #include <boost/geometry/algorithms/detail/overlay/overlay_type.hpp> -#include <boost/geometry/algorithms/covered_by.hpp> -#include <boost/geometry/algorithms/within.hpp> +#include <boost/geometry/algorithms/detail/within/implementation.hpp> namespace boost { namespace geometry { @@ -106,15 +106,8 @@ struct discard_closed_turns<overlay_union, operation_union> Geometry0 const& geometry0, Geometry1 const& geometry1, Strategy const& strategy) { - typedef typename boost::range_value<Turns>::type turn_type; - - for (typename boost::range_iterator<Turns>::type - it = boost::begin(turns); - it != boost::end(turns); - ++it) + for (auto& turn : turns) { - turn_type& turn = *it; - if (! turn.discarded && is_self_turn<overlay_union>(turn) && check_within<overlay_union>::apply(turn, geometry0, @@ -137,18 +130,16 @@ private : bool is_self_cluster(signed_size_type cluster_id, const Turns& turns, Clusters const& clusters) { - typename Clusters::const_iterator cit = clusters.find(cluster_id); + auto cit = clusters.find(cluster_id); if (cit == clusters.end()) { return false; } cluster_info const& cinfo = cit->second; - for (std::set<signed_size_type>::const_iterator it - = cinfo.turn_indices.begin(); - it != cinfo.turn_indices.end(); ++it) + for (auto index : cinfo.turn_indices) { - if (! is_self_turn<OverlayType>(turns[*it])) + if (! is_self_turn<OverlayType>(turns[index])) { return false; } @@ -164,28 +155,25 @@ private : Geometry0 const& geometry0, Geometry1 const& geometry1, Strategy const& strategy) { - for (typename Clusters::const_iterator cit = clusters.begin(); - cit != clusters.end(); ++cit) + for (auto const& pair : clusters) { - signed_size_type const cluster_id = cit->first; + signed_size_type const cluster_id = pair.first; + cluster_info const& cinfo = pair.second; // If there are only self-turns in the cluster, the cluster should // be located within the other geometry, for intersection - if (! cit->second.turn_indices.empty() + if (! cinfo.turn_indices.empty() && is_self_cluster(cluster_id, turns, clusters)) { - cluster_info const& cinfo = cit->second; - signed_size_type const index = *cinfo.turn_indices.begin(); - if (! check_within<OverlayType>::apply(turns[index], + signed_size_type const first_index = *cinfo.turn_indices.begin(); + if (! check_within<OverlayType>::apply(turns[first_index], geometry0, geometry1, strategy)) { // Discard all turns in cluster - for (std::set<signed_size_type>::const_iterator sit - = cinfo.turn_indices.begin(); - sit != cinfo.turn_indices.end(); ++sit) + for (auto index : cinfo.turn_indices) { - turns[*sit].discarded = true; + turns[index].discarded = true; } } } @@ -203,15 +191,8 @@ public : { discard_clusters(turns, clusters, geometry0, geometry1, strategy); - typedef typename boost::range_value<Turns>::type turn_type; - - for (typename boost::range_iterator<Turns>::type - it = boost::begin(turns); - it != boost::end(turns); - ++it) + for (auto& turn : turns) { - turn_type& turn = *it; - // It is a ii self-turn // Check if it is within the other geometry if (! turn.discarded |