• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2005-2007 Adobe Systems Incorporated
3 //
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
7 //
8 #ifndef BOOST_GIL_CONCEPTS_POINT_HPP
9 #define BOOST_GIL_CONCEPTS_POINT_HPP
10 
11 #include <boost/gil/concepts/basic.hpp>
12 #include <boost/gil/concepts/concept_check.hpp>
13 
14 #include <cstddef>
15 
16 #if defined(BOOST_CLANG)
17 #pragma clang diagnostic push
18 #pragma clang diagnostic ignored "-Wunknown-pragmas"
19 #pragma clang diagnostic ignored "-Wunused-local-typedefs"
20 #endif
21 
22 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
23 #pragma GCC diagnostic push
24 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
25 #endif
26 
27 namespace boost { namespace gil {
28 
29 // Forward declarations
30 template <typename T>
31 class point;
32 
33 template <std::size_t K, typename T>
34 T const& axis_value(point<T> const& p);
35 
36 template <std::size_t K, typename T>
37 T& axis_value(point<T>& p);
38 
39 /// \brief N-dimensional point concept
40 /// \code
41 /// concept PointNDConcept<typename T> : Regular<T>
42 /// {
43 ///     // the type of a coordinate along each axis
44 ///     template <size_t K>
45 ///     struct axis; where Metafunction<axis>;
46 ///
47 ///     const size_t num_dimensions;
48 ///
49 ///     // accessor/modifier of the value of each axis.
50 ///
51 ///     template <size_t K>
52 ///     typename axis<K>::type const& T::axis_value() const;
53 ///
54 ///     template <size_t K>
55 ///     typename axis<K>::type& T::axis_value();
56 /// };
57 /// \endcode
58 /// \ingroup PointConcept
59 ///
60 template <typename P>
61 struct PointNDConcept
62 {
constraintsboost::gil::PointNDConcept63     void constraints()
64     {
65         gil_function_requires<Regular<P>>();
66 
67         using value_type = typename P::value_type;
68         ignore_unused_variable_warning(value_type{});
69 
70         static const std::size_t N = P::num_dimensions;
71         ignore_unused_variable_warning(N);
72         using FT = typename P::template axis<0>::coord_t;
73         using LT = typename P::template axis<N - 1>::coord_t;
74         FT ft = gil::axis_value<0>(point);
75         axis_value<0>(point) = ft;
76         LT lt = axis_value<N - 1>(point);
77         axis_value<N - 1>(point) = lt;
78 
79         //value_type v=point[0];
80         //ignore_unused_variable_warning(v);
81     }
82     P point;
83 };
84 
85 /// \brief 2-dimensional point concept
86 /// \code
87 /// concept Point2DConcept<typename T> : PointNDConcept<T>
88 /// {
89 ///     where num_dimensions == 2;
90 ///     where SameType<axis<0>::type, axis<1>::type>;
91 ///
92 ///     typename value_type = axis<0>::type;
93 ///
94 ///     value_type const& operator[](T const&, size_t i);
95 ///     value_type& operator[](T&, size_t i);
96 ///
97 ///     value_type x,y;
98 /// };
99 /// \endcode
100 /// \ingroup PointConcept
101 ///
102 template <typename P>
103 struct Point2DConcept
104 {
constraintsboost::gil::Point2DConcept105     void constraints()
106     {
107         gil_function_requires<PointNDConcept<P>>();
108         static_assert(P::num_dimensions == 2, "");
109         point.x = point.y;
110         point[0] = point[1];
111     }
112     P point;
113 };
114 
115 }} // namespace boost::gil
116 
117 #if defined(BOOST_CLANG)
118 #pragma clang diagnostic pop
119 #endif
120 
121 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
122 #pragma GCC diagnostic pop
123 #endif
124 
125 #endif
126