]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | ||
3 | // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. | |
4 | // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands. | |
5 | // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. | |
6 | ||
20effc67 TL |
7 | // This file was modified by Oracle on 2020. |
8 | // Modifications copyright (c) 2020, Oracle and/or its affiliates. | |
9 | // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle | |
10 | ||
7c673cae FG |
11 | // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library |
12 | // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. | |
13 | ||
14 | // Use, modification and distribution is subject to the Boost Software License, | |
15 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
16 | // http://www.boost.org/LICENSE_1_0.txt) | |
17 | ||
18 | #ifndef BOOST_GEOMETRY_CORE_COORDINATE_DIMENSION_HPP | |
19 | #define BOOST_GEOMETRY_CORE_COORDINATE_DIMENSION_HPP | |
20 | ||
21 | ||
22 | #include <cstddef> | |
23 | ||
7c673cae | 24 | #include <boost/geometry/core/point_type.hpp> |
20effc67 TL |
25 | #include <boost/geometry/core/static_assert.hpp> |
26 | #include <boost/geometry/util/type_traits_std.hpp> | |
7c673cae FG |
27 | |
28 | namespace boost { namespace geometry | |
29 | { | |
30 | ||
31 | namespace traits | |
32 | { | |
33 | ||
34 | /*! | |
35 | \brief Traits class indicating the number of dimensions of a point | |
36 | \par Geometries: | |
37 | - point | |
38 | \par Specializations should provide: | |
20effc67 | 39 | - value (e.g. derived from std::integral_constant<std::size_t, D>) |
7c673cae FG |
40 | \ingroup traits |
41 | */ | |
42 | template <typename Point, typename Enable = void> | |
43 | struct dimension | |
44 | { | |
20effc67 TL |
45 | BOOST_GEOMETRY_STATIC_ASSERT_FALSE( |
46 | "Not implemented for this Point type.", | |
47 | Point); | |
7c673cae FG |
48 | }; |
49 | ||
50 | } // namespace traits | |
51 | ||
52 | #ifndef DOXYGEN_NO_DISPATCH | |
53 | namespace core_dispatch | |
54 | { | |
55 | ||
56 | // Base class derive from its own specialization of point-tag | |
57 | template <typename T, typename G> | |
20effc67 TL |
58 | struct dimension |
59 | : dimension<point_tag, typename point_type<T, G>::type>::type | |
60 | {}; | |
7c673cae FG |
61 | |
62 | template <typename P> | |
63 | struct dimension<point_tag, P> | |
20effc67 TL |
64 | : std::integral_constant |
65 | < | |
66 | std::size_t, | |
67 | traits::dimension<util::remove_cptrref_t<P>>::value | |
68 | > | |
7c673cae | 69 | { |
20effc67 TL |
70 | BOOST_GEOMETRY_STATIC_ASSERT( |
71 | (traits::dimension<util::remove_cptrref_t<P>>::value > 0), | |
72 | "Dimension has to be greater than 0.", | |
73 | traits::dimension<util::remove_cptrref_t<P>> | |
7c673cae FG |
74 | ); |
75 | }; | |
76 | ||
77 | } // namespace core_dispatch | |
78 | #endif | |
79 | ||
80 | /*! | |
81 | \brief \brief_meta{value, number of coordinates (the number of axes of any geometry), \meta_point_type} | |
82 | \tparam Geometry \tparam_geometry | |
83 | \ingroup core | |
84 | ||
85 | \qbk{[include reference/core/coordinate_dimension.qbk]} | |
86 | */ | |
87 | template <typename Geometry> | |
88 | struct dimension | |
89 | : core_dispatch::dimension | |
90 | < | |
91 | typename tag<Geometry>::type, | |
20effc67 | 92 | typename util::remove_cptrref<Geometry>::type |
7c673cae FG |
93 | > |
94 | {}; | |
95 | ||
96 | /*! | |
97 | \brief assert_dimension, enables compile-time checking if coordinate dimensions are as expected | |
98 | \ingroup utility | |
99 | */ | |
20effc67 TL |
100 | template <typename Geometry, std::size_t Dimensions> |
101 | constexpr inline void assert_dimension() | |
7c673cae | 102 | { |
20effc67 | 103 | BOOST_STATIC_ASSERT(( dimension<Geometry>::value == Dimensions )); |
7c673cae FG |
104 | } |
105 | ||
106 | /*! | |
107 | \brief assert_dimension, enables compile-time checking if coordinate dimensions are as expected | |
108 | \ingroup utility | |
109 | */ | |
20effc67 TL |
110 | template <typename Geometry, std::size_t Dimensions> |
111 | constexpr inline void assert_dimension_less_equal() | |
7c673cae | 112 | { |
20effc67 | 113 | BOOST_STATIC_ASSERT(( dimension<Geometry>::value <= Dimensions )); |
7c673cae FG |
114 | } |
115 | ||
20effc67 TL |
116 | template <typename Geometry, std::size_t Dimensions> |
117 | constexpr inline void assert_dimension_greater_equal() | |
7c673cae | 118 | { |
20effc67 | 119 | BOOST_STATIC_ASSERT(( dimension<Geometry>::value >= Dimensions )); |
7c673cae FG |
120 | } |
121 | ||
122 | /*! | |
123 | \brief assert_dimension_equal, enables compile-time checking if coordinate dimensions of two geometries are equal | |
124 | \ingroup utility | |
125 | */ | |
126 | template <typename G1, typename G2> | |
20effc67 | 127 | constexpr inline void assert_dimension_equal() |
7c673cae | 128 | { |
20effc67 | 129 | BOOST_STATIC_ASSERT(( dimension<G1>::value == dimension<G2>::value )); |
7c673cae FG |
130 | } |
131 | ||
132 | }} // namespace boost::geometry | |
133 | ||
134 | #endif // BOOST_GEOMETRY_CORE_COORDINATE_DIMENSION_HPP |