]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/geometry/algorithms/detail/envelope/range.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / geometry / algorithms / detail / envelope / range.hpp
CommitLineData
7c673cae
FG
1// Boost.Geometry (aka GGL, Generic Geometry Library)
2
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.
6
20effc67
TL
7// This file was modified by Oracle on 2015-2020.
8// Modifications copyright (c) 2015-2020, Oracle and/or its affiliates.
7c673cae 9
b32b8144 10// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
7c673cae 11// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
92f5a8d4 12// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
7c673cae
FG
13
14// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
15// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
16
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)
20
21#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_RANGE_HPP
22#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_RANGE_HPP
23
24#include <iterator>
25#include <vector>
26
92f5a8d4
TL
27#include <boost/range/begin.hpp>
28#include <boost/range/end.hpp>
7c673cae
FG
29
30#include <boost/geometry/algorithms/is_empty.hpp>
31
32#include <boost/geometry/algorithms/detail/envelope/initialize.hpp>
7c673cae
FG
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>
36
92f5a8d4 37#include <boost/geometry/core/coordinate_dimension.hpp>
7c673cae
FG
38
39namespace boost { namespace geometry
40{
41
42#ifndef DOXYGEN_NO_DETAIL
43namespace detail { namespace envelope
44{
45
46
47// implementation for simple ranges
48struct envelope_range
49{
b32b8144 50 template <typename Iterator, typename Box, typename Strategy>
92f5a8d4 51 static inline void apply(Iterator it,
b32b8144
FG
52 Iterator last,
53 Box& mbr,
54 Strategy const& strategy)
7c673cae
FG
55 {
56 typedef typename std::iterator_traits<Iterator>::value_type value_type;
57
58 // initialize MBR
59 initialize<Box, 0, dimension<Box>::value>::apply(mbr);
60
7c673cae
FG
61 if (it != last)
62 {
63 // initialize box with first element in range
92f5a8d4
TL
64 dispatch::envelope
65 <
66 value_type
20effc67 67 >::apply(*it, mbr, strategy);
7c673cae
FG
68
69 // consider now the remaining elements in the range (if any)
70 for (++it; it != last; ++it)
71 {
92f5a8d4
TL
72 dispatch::expand
73 <
74 Box, value_type
20effc67 75 >::apply(mbr, *it, strategy);
7c673cae
FG
76 }
77 }
78 }
79
b32b8144
FG
80 template <typename Range, typename Box, typename Strategy>
81 static inline void apply(Range const& range, Box& mbr, Strategy const& strategy)
7c673cae 82 {
20effc67
TL
83 using strategy_t = decltype(strategy.envelope(range, mbr));
84 return apply(strategy_t::begin(range), strategy_t::end(range),
85 mbr, strategy);
7c673cae
FG
86 }
87};
88
89
90// implementation for multi-ranges
91template <typename EnvelopePolicy>
92struct envelope_multi_range
93{
b32b8144
FG
94 template <typename MultiRange, typename Box, typename Strategy>
95 static inline void apply(MultiRange const& multirange,
96 Box& mbr,
97 Strategy const& strategy)
7c673cae 98 {
20effc67
TL
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);
7c673cae 103 }
7c673cae 104
20effc67
TL
105private:
106 template <typename State, typename Iter, typename Box, typename Strategy>
92f5a8d4
TL
107 static inline void apply(Iter it,
108 Iter last,
b32b8144
FG
109 Box& mbr,
110 Strategy const& strategy)
7c673cae 111 {
20effc67 112 State state;
92f5a8d4 113 for (; it != last; ++it)
7c673cae
FG
114 {
115 if (! geometry::is_empty(*it))
116 {
92f5a8d4
TL
117 Box helper_mbr;
118 EnvelopePolicy::apply(*it, helper_mbr, strategy);
119 state.apply(helper_mbr);
7c673cae
FG
120 }
121 }
92f5a8d4 122 state.result(mbr);
7c673cae
FG
123 }
124};
125
126
127}} // namespace detail::envelope
128#endif // DOXYGEN_NO_DETAIL
129
130
131}} // namespace boost::geometry
132
133#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_RANGE_HPP