]>
Commit | Line | Data |
---|---|---|
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 | ||
92f5a8d4 TL |
7 | // This file was modified by Oracle on 2015, 2016, 2018. |
8 | // Modifications copyright (c) 2015-2018, 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 | |
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 | { | |
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 | |
67 | >::apply(*it, mbr, strategy.get_element_envelope_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 | |
75 | >::apply(mbr, *it, strategy.get_element_expand_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 | { |
92f5a8d4 | 83 | return apply(Strategy::begin(range), Strategy::end(range), mbr, strategy); |
7c673cae FG |
84 | } |
85 | }; | |
86 | ||
87 | ||
88 | // implementation for multi-ranges | |
89 | template <typename EnvelopePolicy> | |
90 | struct envelope_multi_range | |
91 | { | |
b32b8144 FG |
92 | template <typename MultiRange, typename Box, typename Strategy> |
93 | static inline void apply(MultiRange const& multirange, | |
94 | Box& mbr, | |
95 | Strategy const& strategy) | |
7c673cae | 96 | { |
92f5a8d4 | 97 | apply(boost::begin(multirange), boost::end(multirange), mbr, strategy); |
7c673cae | 98 | } |
7c673cae | 99 | |
92f5a8d4 TL |
100 | template <typename Iter, typename Box, typename Strategy> |
101 | static inline void apply(Iter it, | |
102 | Iter last, | |
b32b8144 FG |
103 | Box& mbr, |
104 | Strategy const& strategy) | |
7c673cae | 105 | { |
92f5a8d4 TL |
106 | typename Strategy::template multi_state<Box> state; |
107 | for (; it != last; ++it) | |
7c673cae FG |
108 | { |
109 | if (! geometry::is_empty(*it)) | |
110 | { | |
92f5a8d4 TL |
111 | Box helper_mbr; |
112 | EnvelopePolicy::apply(*it, helper_mbr, strategy); | |
113 | state.apply(helper_mbr); | |
7c673cae FG |
114 | } |
115 | } | |
92f5a8d4 | 116 | state.result(mbr); |
7c673cae FG |
117 | } |
118 | }; | |
119 | ||
120 | ||
121 | }} // namespace detail::envelope | |
122 | #endif // DOXYGEN_NO_DETAIL | |
123 | ||
124 | ||
125 | }} // namespace boost::geometry | |
126 | ||
127 | #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_RANGE_HPP |