1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
5 // Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
7 // This file was modified by Oracle on 2015-2020.
8 // Modifications copyright (c) 2015-2020, Oracle and/or its affiliates.
10 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
11 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
12 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
14 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
15 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
17 // Distributed under the Boost Software License, Version 1.0.
18 // (See accompanying file LICENSE_1_0.txt or copy at
19 // http://www.boost.org/LICENSE_1_0.txt)
21 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_RANGE_HPP
22 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_RANGE_HPP
27 #include <boost/range/begin.hpp>
28 #include <boost/range/end.hpp>
30 #include <boost/geometry/algorithms/is_empty.hpp>
32 #include <boost/geometry/algorithms/detail/envelope/initialize.hpp>
33 #include <boost/geometry/algorithms/detail/expand/box.hpp>
34 #include <boost/geometry/algorithms/detail/expand/point.hpp>
35 #include <boost/geometry/algorithms/detail/expand/segment.hpp>
37 #include <boost/geometry/core/coordinate_dimension.hpp>
39 namespace boost { namespace geometry
42 #ifndef DOXYGEN_NO_DETAIL
43 namespace detail { namespace envelope
47 // implementation for simple ranges
50 template <typename Iterator, typename Box, typename Strategy>
51 static inline void apply(Iterator it,
54 Strategy const& strategy)
56 typedef typename std::iterator_traits<Iterator>::value_type value_type;
59 initialize<Box, 0, dimension<Box>::value>::apply(mbr);
63 // initialize box with first element in range
67 >::apply(*it, mbr, strategy);
69 // consider now the remaining elements in the range (if any)
70 for (++it; it != last; ++it)
75 >::apply(mbr, *it, strategy);
80 template <typename Range, typename Box, typename Strategy>
81 static inline void apply(Range const& range, Box& mbr, Strategy const& strategy)
83 using strategy_t = decltype(strategy.envelope(range, mbr));
84 return apply(strategy_t::begin(range), strategy_t::end(range),
90 // implementation for multi-ranges
91 template <typename EnvelopePolicy>
92 struct envelope_multi_range
94 template <typename MultiRange, typename Box, typename Strategy>
95 static inline void apply(MultiRange const& multirange,
97 Strategy const& strategy)
99 using range_t = typename boost::range_value<MultiRange>::type;
100 using strategy_t = decltype(strategy.envelope(std::declval<range_t>(), mbr));
101 using state_t = typename strategy_t::template multi_state<Box>;
102 apply<state_t>(boost::begin(multirange), boost::end(multirange), mbr, strategy);
106 template <typename State, typename Iter, typename Box, typename Strategy>
107 static inline void apply(Iter it,
110 Strategy const& strategy)
113 for (; it != last; ++it)
115 if (! geometry::is_empty(*it))
118 EnvelopePolicy::apply(*it, helper_mbr, strategy);
119 state.apply(helper_mbr);
127 }} // namespace detail::envelope
128 #endif // DOXYGEN_NO_DETAIL
131 }} // namespace boost::geometry
133 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_RANGE_HPP