]>
Commit | Line | Data |
---|---|---|
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-2021. | |
8 | // Modifications copyright (c) 2015-2021, 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 | #include <boost/geometry/algorithms/detail/dummy_geometries.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> | |
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 Range, typename Box, typename Strategies> | |
51 | static inline void apply(Range const& range, Box& mbr, Strategies const& strategies) | |
52 | { | |
53 | strategies.envelope(range, mbr).apply(range, mbr); | |
54 | } | |
55 | }; | |
56 | ||
57 | ||
58 | // implementation for multi-ranges | |
59 | template <typename EnvelopePolicy> | |
60 | struct envelope_multi_range | |
61 | { | |
62 | template <typename MultiRange, typename Box, typename Strategies> | |
63 | static inline void apply(MultiRange const& multirange, | |
64 | Box& mbr, | |
65 | Strategies const& strategies) | |
66 | { | |
67 | using strategy_t = decltype(strategies.envelope(multirange, mbr)); | |
68 | apply<strategy_t>(multirange, mbr, strategies); | |
69 | } | |
70 | ||
71 | template <typename Strategy, typename MultiRange, typename Box, typename Strategies> | |
72 | static inline void apply(MultiRange const& multirange, | |
73 | Box& mbr, | |
74 | Strategies const& strategies) | |
75 | { | |
76 | typename Strategy::template state<Box> state; | |
77 | auto const end = boost::end(multirange); | |
78 | for (auto it = boost::begin(multirange); it != end; ++it) | |
79 | { | |
80 | if (! geometry::is_empty(*it)) | |
81 | { | |
82 | Box helper_mbr; | |
83 | EnvelopePolicy::apply(*it, helper_mbr, strategies); | |
84 | Strategy::apply(state, helper_mbr); | |
85 | } | |
86 | } | |
87 | Strategy::result(state, mbr); | |
88 | } | |
89 | }; | |
90 | ||
91 | ||
92 | }} // namespace detail::envelope | |
93 | #endif // DOXYGEN_NO_DETAIL | |
94 | ||
95 | ||
96 | }} // namespace boost::geometry | |
97 | ||
98 | #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_RANGE_HPP |