]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/include/boost/geometry/algorithms/detail/expand_by_epsilon.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / include / boost / geometry / algorithms / detail / expand_by_epsilon.hpp
CommitLineData
7c673cae
FG
1// Boost.Geometry
2
3// Copyright (c) 2015, Oracle and/or its affiliates.
4
5// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
6
7// Distributed under the Boost Software License, Version 1.0.
8// (See accompanying file LICENSE_1_0.txt or copy at
9// http://www.boost.org/LICENSE_1_0.txt)
10
11#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_EXPAND_BY_EPSILON_HPP
12#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_EXPAND_BY_EPSILON_HPP
13
14#include <cstddef>
15#include <algorithm>
16
17#include <boost/type_traits/is_floating_point.hpp>
18
19#include <boost/geometry/core/access.hpp>
20#include <boost/geometry/core/coordinate_dimension.hpp>
21#include <boost/geometry/core/coordinate_type.hpp>
22
23#include <boost/geometry/util/math.hpp>
24
25#include <boost/geometry/views/detail/indexed_point_view.hpp>
26
27namespace boost { namespace geometry
28{
29
30#ifndef DOXYGEN_NO_DETAIL
31namespace detail { namespace expand
32{
33
34template
35<
36 typename Point,
37 template <typename> class PlusOrMinus,
38 std::size_t I = 0,
39 std::size_t D = dimension<Point>::value,
40 bool Enable = boost::is_floating_point
41 <
42 typename coordinate_type<Point>::type
43 >::value
44>
45struct corner_by_epsilon
46{
47 static inline void apply(Point & point)
48 {
49 typedef typename coordinate_type<Point>::type coord_type;
50 coord_type const coord = get<I>(point);
51 coord_type const eps = math::scaled_epsilon(coord);
52
53 set<I>(point, PlusOrMinus<coord_type>()(coord, eps));
54
55 corner_by_epsilon<Point, PlusOrMinus, I+1>::apply(point);
56 }
57};
58
59template
60<
61 typename Point,
62 template <typename> class PlusOrMinus,
63 std::size_t I,
64 std::size_t D
65>
66struct corner_by_epsilon<Point, PlusOrMinus, I, D, false>
67{
68 static inline void apply(Point const&) {}
69};
70
71template
72<
73 typename Point,
74 template <typename> class PlusOrMinus,
75 std::size_t D,
76 bool Enable
77>
78struct corner_by_epsilon<Point, PlusOrMinus, D, D, Enable>
79{
80 static inline void apply(Point const&) {}
81};
82
83template
84<
85 typename Point,
86 template <typename> class PlusOrMinus,
87 std::size_t D
88>
89struct corner_by_epsilon<Point, PlusOrMinus, D, D, false>
90{
91 static inline void apply(Point const&) {}
92};
93
94} // namespace expand
95
96template <typename Box>
97inline void expand_by_epsilon(Box & box)
98{
99 typedef detail::indexed_point_view<Box, min_corner> min_type;
100 min_type min_point(box);
101 expand::corner_by_epsilon<min_type, std::minus>::apply(min_point);
102
103 typedef detail::indexed_point_view<Box, max_corner> max_type;
104 max_type max_point(box);
105 expand::corner_by_epsilon<max_type, std::plus>::apply(max_point);
106}
107
108} // namespace detail
109#endif // DOXYGEN_NO_DETAIL
110
111}} // namespace boost::geometry
112
113#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_EXPAND_BY_EPSILON_HPP