]>
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 | // Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France. | |
7 | ||
8 | // This file was modified by Oracle on 2015. | |
9 | // Modifications copyright (c) 2015, Oracle and/or its affiliates. | |
10 | ||
11 | // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle | |
12 | ||
13 | // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library | |
14 | // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. | |
15 | ||
16 | // Distributed under the Boost Software License, Version 1.0. | |
17 | // (See accompanying file LICENSE_1_0.txt or copy at | |
18 | // http://www.boost.org/LICENSE_1_0.txt) | |
19 | ||
20 | #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_INDEXED_HPP | |
21 | #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_INDEXED_HPP | |
22 | ||
23 | #include <cstddef> | |
24 | ||
25 | #include <boost/geometry/core/access.hpp> | |
26 | #include <boost/geometry/core/tags.hpp> | |
27 | ||
28 | #include <boost/geometry/util/select_coordinate_type.hpp> | |
29 | ||
30 | #include <boost/geometry/strategies/compare.hpp> | |
31 | #include <boost/geometry/policies/compare.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 | typename StrategyLess, typename StrategyGreater, | |
47 | std::size_t Index, | |
48 | std::size_t Dimension, std::size_t DimensionCount | |
49 | > | |
50 | struct indexed_loop | |
51 | { | |
52 | template <typename Box, typename Geometry> | |
53 | static inline void apply(Box& box, Geometry const& source) | |
54 | { | |
55 | typedef typename strategy::compare::detail::select_strategy | |
56 | < | |
57 | StrategyLess, 1, Box, Dimension | |
58 | >::type less_type; | |
59 | ||
60 | typedef typename strategy::compare::detail::select_strategy | |
61 | < | |
62 | StrategyGreater, -1, Box, Dimension | |
63 | >::type greater_type; | |
64 | ||
65 | typedef typename select_coordinate_type | |
66 | < | |
67 | Box, | |
68 | Geometry | |
69 | >::type coordinate_type; | |
70 | ||
71 | less_type less; | |
72 | greater_type greater; | |
73 | ||
74 | coordinate_type const coord = get<Index, Dimension>(source); | |
75 | ||
76 | if (less(coord, get<min_corner, Dimension>(box))) | |
77 | { | |
78 | set<min_corner, Dimension>(box, coord); | |
79 | } | |
80 | ||
81 | if (greater(coord, get<max_corner, Dimension>(box))) | |
82 | { | |
83 | set<max_corner, Dimension>(box, coord); | |
84 | } | |
85 | ||
86 | indexed_loop | |
87 | < | |
88 | StrategyLess, StrategyGreater, | |
89 | Index, Dimension + 1, DimensionCount | |
90 | >::apply(box, source); | |
91 | } | |
92 | }; | |
93 | ||
94 | ||
95 | template | |
96 | < | |
97 | typename StrategyLess, typename StrategyGreater, | |
98 | std::size_t Index, std::size_t DimensionCount | |
99 | > | |
100 | struct indexed_loop | |
101 | < | |
102 | StrategyLess, StrategyGreater, | |
103 | Index, DimensionCount, DimensionCount | |
104 | > | |
105 | { | |
106 | template <typename Box, typename Geometry> | |
107 | static inline void apply(Box&, Geometry const&) {} | |
108 | }; | |
109 | ||
110 | ||
111 | ||
112 | // Changes a box such that the other box is also contained by the box | |
113 | template | |
114 | < | |
115 | std::size_t Dimension, std::size_t DimensionCount, | |
116 | typename StrategyLess, typename StrategyGreater | |
117 | > | |
118 | struct expand_indexed | |
119 | { | |
120 | template <typename Box, typename Geometry> | |
121 | static inline void apply(Box& box, Geometry const& geometry) | |
122 | { | |
123 | indexed_loop | |
124 | < | |
125 | StrategyLess, StrategyGreater, | |
126 | 0, Dimension, DimensionCount | |
127 | >::apply(box, geometry); | |
128 | ||
129 | indexed_loop | |
130 | < | |
131 | StrategyLess, StrategyGreater, | |
132 | 1, Dimension, DimensionCount | |
133 | >::apply(box, geometry); | |
134 | } | |
135 | }; | |
136 | ||
137 | ||
138 | }} // namespace detail::expand | |
139 | #endif // DOXYGEN_NO_DETAIL | |
140 | ||
141 | ||
142 | }} // namespace boost::geometry | |
143 | ||
144 | #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_INDEXED_HPP |