]> git.proxmox.com Git - ceph.git/blob - 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
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
7 // This file was modified by Oracle on 2015-2020.
8 // Modifications copyright (c) 2015-2020, Oracle and/or its affiliates.
9
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
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
27 #include <boost/range/begin.hpp>
28 #include <boost/range/end.hpp>
29
30 #include <boost/geometry/algorithms/is_empty.hpp>
31
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>
36
37 #include <boost/geometry/core/coordinate_dimension.hpp>
38
39 namespace boost { namespace geometry
40 {
41
42 #ifndef DOXYGEN_NO_DETAIL
43 namespace detail { namespace envelope
44 {
45
46
47 // implementation for simple ranges
48 struct envelope_range
49 {
50 template <typename Iterator, typename Box, typename Strategy>
51 static inline void apply(Iterator it,
52 Iterator last,
53 Box& mbr,
54 Strategy const& strategy)
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
61 if (it != last)
62 {
63 // initialize box with first element in range
64 dispatch::envelope
65 <
66 value_type
67 >::apply(*it, mbr, strategy);
68
69 // consider now the remaining elements in the range (if any)
70 for (++it; it != last; ++it)
71 {
72 dispatch::expand
73 <
74 Box, value_type
75 >::apply(mbr, *it, strategy);
76 }
77 }
78 }
79
80 template <typename Range, typename Box, typename Strategy>
81 static inline void apply(Range const& range, Box& mbr, Strategy const& strategy)
82 {
83 using strategy_t = decltype(strategy.envelope(range, mbr));
84 return apply(strategy_t::begin(range), strategy_t::end(range),
85 mbr, strategy);
86 }
87 };
88
89
90 // implementation for multi-ranges
91 template <typename EnvelopePolicy>
92 struct envelope_multi_range
93 {
94 template <typename MultiRange, typename Box, typename Strategy>
95 static inline void apply(MultiRange const& multirange,
96 Box& mbr,
97 Strategy const& strategy)
98 {
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);
103 }
104
105 private:
106 template <typename State, typename Iter, typename Box, typename Strategy>
107 static inline void apply(Iter it,
108 Iter last,
109 Box& mbr,
110 Strategy const& strategy)
111 {
112 State state;
113 for (; it != last; ++it)
114 {
115 if (! geometry::is_empty(*it))
116 {
117 Box helper_mbr;
118 EnvelopePolicy::apply(*it, helper_mbr, strategy);
119 state.apply(helper_mbr);
120 }
121 }
122 state.result(mbr);
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