]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | ||
3 | // Copyright (c) 2014 Barend Gehrels, Amsterdam, the Netherlands. | |
4 | // Copyright (c) 2014 Bruno Lalande, Paris, France. | |
5 | // Copyright (c) 2014 Mateusz Loskot, London, UK. | |
6 | // Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland. | |
7 | ||
8 | // Use, modification and distribution is subject to the Boost Software License, | |
9 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
10 | // http://www.boost.org/LICENSE_1_0.txt) | |
11 | ||
12 | #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_GET_MAX_SIZE_HPP | |
13 | #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_GET_MAX_SIZE_HPP | |
14 | ||
15 | ||
16 | #include <cstddef> | |
17 | ||
18 | #include <boost/geometry/core/access.hpp> | |
19 | #include <boost/geometry/util/math.hpp> | |
20 | ||
21 | namespace boost { namespace geometry | |
22 | { | |
23 | ||
24 | #ifndef DOXYGEN_NO_DETAIL | |
25 | namespace detail | |
26 | { | |
27 | ||
28 | template <typename Box, std::size_t Dimension> | |
29 | struct get_max_size_box | |
30 | { | |
31 | static inline typename coordinate_type<Box>::type apply(Box const& box) | |
32 | { | |
33 | typename coordinate_type<Box>::type s | |
34 | = geometry::math::abs(geometry::get<1, Dimension>(box) - geometry::get<0, Dimension>(box)); | |
35 | ||
36 | return (std::max)(s, get_max_size_box<Box, Dimension - 1>::apply(box)); | |
37 | } | |
38 | }; | |
39 | ||
40 | template <typename Box> | |
41 | struct get_max_size_box<Box, 0> | |
42 | { | |
43 | static inline typename coordinate_type<Box>::type apply(Box const& box) | |
44 | { | |
45 | return geometry::math::abs(geometry::get<1, 0>(box) - geometry::get<0, 0>(box)); | |
46 | } | |
47 | }; | |
48 | ||
49 | // This might be implemented later on for other geometries too. | |
50 | // Not dispatched yet. | |
51 | template <typename Box> | |
52 | inline typename coordinate_type<Box>::type get_max_size(Box const& box) | |
53 | { | |
54 | return get_max_size_box<Box, dimension<Box>::value - 1>::apply(box); | |
55 | } | |
56 | ||
57 | } // namespace detail | |
58 | #endif // DOXYGEN_NO_DETAIL | |
59 | ||
60 | ||
61 | }} // namespace boost::geometry | |
62 | ||
63 | ||
64 | #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_GET_MAX_SIZE_HPP |