// Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. // This file was modified by Oracle on 2020. // Modifications copyright (c) 2020, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_FOR_EACH_RANGE_HPP #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_FOR_EACH_RANGE_HPP #include #include #include #include #include #include #include #include #include #include #include #include #include namespace boost { namespace geometry { #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace for_each { template struct fe_range_point { template static inline bool apply(Point& point, Functor&& f) { Point* ptr = boost::addressof(point); return f(std::pair(ptr, ptr + 1)); } }; template struct fe_range_segment { template static inline bool apply(Segment& segment, Functor&& f) { return f(segment_view::type>(segment)); } }; template struct fe_range_range { template static inline bool apply(Range& range, Functor&& f) { return f(range); } }; template struct fe_range_polygon { template static inline bool apply(Polygon& polygon, Functor&& f) { return f(exterior_ring(polygon)); // TODO: If some flag says true, also do the inner rings. // for convex hull, it's not necessary } }; template struct fe_range_box { template static inline bool apply(Box& box, Functor&& f) { return f(box_view::type>(box)); } }; template struct fe_range_multi { template static inline bool apply(Multi& multi, Functor&& f) { auto const end = boost::end(multi); for (auto it = boost::begin(multi); it != end; ++it) { if (! SinglePolicy::apply(*it, f)) { return false; } } return true; } }; }} // namespace detail::for_each #endif // DOXYGEN_NO_DETAIL #ifndef DOXYGEN_NO_DISPATCH namespace dispatch { template < typename Geometry, typename Tag = typename tag::type > struct for_each_range { BOOST_GEOMETRY_STATIC_ASSERT_FALSE( "Not or not yet implemented for this Geometry type.", Geometry, Tag); }; template struct for_each_range : detail::for_each::fe_range_point {}; template struct for_each_range : detail::for_each::fe_range_segment {}; template struct for_each_range : detail::for_each::fe_range_range {}; template struct for_each_range : detail::for_each::fe_range_range {}; template struct for_each_range : detail::for_each::fe_range_polygon {}; template struct for_each_range : detail::for_each::fe_range_box {}; template struct for_each_range : detail::for_each::fe_range_range {}; template struct for_each_range : detail::for_each::fe_range_multi < Geometry, detail::for_each::fe_range_range < util::transcribe_const_t < Geometry, typename boost::range_value::type > > > {}; template struct for_each_range : detail::for_each::fe_range_multi < Geometry, detail::for_each::fe_range_polygon < util::transcribe_const_t < Geometry, typename boost::range_value::type > > > {}; } // namespace dispatch #endif // DOXYGEN_NO_DISPATCH namespace detail { // Currently for Polygons p is checked only for exterior ring // Should this function be renamed? template inline bool all_ranges_of(Geometry const& geometry, UnaryPredicate p) { return dispatch::for_each_range::apply(geometry, p); } // Currently for Polygons p is checked only for exterior ring // Should this function be renamed? template inline bool any_range_of(Geometry const& geometry, UnaryPredicate p) { return ! dispatch::for_each_range::apply(geometry, [&](auto&& range) { return ! p(range); }); } // Currently for Polygons p is checked only for exterior ring // Should this function be renamed? template inline bool none_range_of(Geometry const& geometry, UnaryPredicate p) { return dispatch::for_each_range::apply(geometry, [&](auto&& range) { return ! p(range); }); } // Currently for Polygons f is called only for exterior ring // Should this function be renamed? template inline Functor for_each_range(Geometry const& geometry, Functor f) { dispatch::for_each_range::apply(geometry, [&](auto&& range) { f(range); // TODO: Implement separate function? return true; }); return f; } } }} // namespace boost::geometry #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_FOR_EACH_RANGE_HPP