]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/algorithms/detail/expand/indexed.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / geometry / algorithms / detail / expand / indexed.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 // Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France.
7
8 // This file was modified by Oracle on 2015, 2016, 2017.
9 // Modifications copyright (c) 2015-2017, Oracle and/or its affiliates.
10
11 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
12 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
13 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
14
15 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
16 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
17
18 // Distributed under the Boost Software License, Version 1.0.
19 // (See accompanying file LICENSE_1_0.txt or copy at
20 // http://www.boost.org/LICENSE_1_0.txt)
21
22 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_INDEXED_HPP
23 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_INDEXED_HPP
24
25 #include <cstddef>
26 #include <functional>
27
28 #include <boost/geometry/core/access.hpp>
29 #include <boost/geometry/core/tags.hpp>
30
31 #include <boost/geometry/util/select_coordinate_type.hpp>
32
33 #include <boost/geometry/algorithms/dispatch/expand.hpp>
34
35
36 namespace boost { namespace geometry
37 {
38
39 #ifndef DOXYGEN_NO_DETAIL
40 namespace detail { namespace expand
41 {
42
43
44 template
45 <
46 std::size_t Index,
47 std::size_t Dimension, std::size_t DimensionCount
48 >
49 struct indexed_loop
50 {
51 template <typename Box, typename Geometry, typename Strategy>
52 static inline void apply(Box& box, Geometry const& source, Strategy const& strategy)
53 {
54 typedef typename select_coordinate_type
55 <
56 Box,
57 Geometry
58 >::type coordinate_type;
59
60 coordinate_type const coord = get<Index, Dimension>(source);
61
62 std::less<coordinate_type> less;
63 std::greater<coordinate_type> greater;
64
65 if (less(coord, get<min_corner, Dimension>(box)))
66 {
67 set<min_corner, Dimension>(box, coord);
68 }
69
70 if (greater(coord, get<max_corner, Dimension>(box)))
71 {
72 set<max_corner, Dimension>(box, coord);
73 }
74
75 indexed_loop
76 <
77 Index, Dimension + 1, DimensionCount
78 >::apply(box, source, strategy);
79 }
80 };
81
82
83 template <std::size_t Index, std::size_t DimensionCount>
84 struct indexed_loop
85 <
86 Index, DimensionCount, DimensionCount
87 >
88 {
89 template <typename Box, typename Geometry, typename Strategy>
90 static inline void apply(Box&, Geometry const&, Strategy const&) {}
91 };
92
93
94
95 // Changes a box such that the other box is also contained by the box
96 template <std::size_t Dimension, std::size_t DimensionCount>
97 struct expand_indexed
98 {
99 template <typename Box, typename Geometry, typename Strategy>
100 static inline void apply(Box& box,
101 Geometry const& geometry,
102 Strategy const& strategy)
103 {
104 indexed_loop
105 <
106 0, Dimension, DimensionCount
107 >::apply(box, geometry, strategy);
108
109 indexed_loop
110 <
111 1, Dimension, DimensionCount
112 >::apply(box, geometry, strategy);
113 }
114 };
115
116
117 }} // namespace detail::expand
118 #endif // DOXYGEN_NO_DETAIL
119
120
121 }} // namespace boost::geometry
122
123 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_INDEXED_HPP