$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
point3d.hh
1 // Copyright (C) 2007, 2008, 2009, 2012, 2013 EPITA Research and
2 // Development Laboratory (LRDE)
3 //
4 // This file is part of Olena.
5 //
6 // Olena is free software: you can redistribute it and/or modify it under
7 // the terms of the GNU General Public License as published by the Free
8 // Software Foundation, version 2 of the License.
9 //
10 // Olena is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // As a special exception, you may use this file as part of a free
19 // software project without restriction. Specifically, if other files
20 // instantiate templates or use macros or inline functions from this
21 // file, or you compile this file and link it with other files to produce
22 // an executable, this file does not by itself cause the resulting
23 // executable to be covered by the GNU General Public License. This
24 // exception does not however invalidate any other reasons why the
25 // executable file might be covered by the GNU General Public License.
26 
27 #ifndef MLN_CORE_ALIAS_POINT3D_HH
28 # define MLN_CORE_ALIAS_POINT3D_HH
29 
34 
35 # include <mln/core/def/coord.hh>
36 # include <mln/core/def/coordf.hh>
37 # include <mln/core/point.hh>
38 // For site_const_impl and site_mutable_impl:
39 # include <mln/core/concept/site_proxy.hh>
40 # include <mln/core/internal/force_exact.hh>
41 
42 namespace mln
43 {
44 
52 
53  typedef point<grid::cube, def::coord> point3d;
55 
56 
64 
65  typedef point<grid::cube, def::coordf> point3df;
66 
68 
69  namespace internal
70  {
71 
72  // Specialization.
73 
75  template <typename C, typename E>
76  struct subject_impl< const point<grid::cube, C>, E >
77  : subject_point_impl< point<grid::cube, C>, E >
78  {
79  typedef C coord;
80  enum { dim = 3 };
81 
82  typedef const C& row_t;
83  const C& row() const;
84 
85  typedef const C& col_t;
86  const C& col() const;
87 
88  typedef const C& sli_t;
89  const C& sli() const;
90 
91  const C& operator[](unsigned i) const;
92  const C& last_coord() const;
93  private:
94  const E& exact_() const;
95  };
96 
97 
98  // Specialization for point<M,C>.
99 
101  template <typename C, typename E>
102  struct subject_impl< point<grid::cube, C>, E > :
103  subject_impl< const point<grid::cube, C>, E >
104  {
105  private:
106  typedef subject_impl< const point<grid::cube, C>, E > super_;
107  E& exact_();
108  public:
109 
110  using super_::row;
111  C& row();
112 
113  using super_::col;
114  C& col();
115 
116  using super_::sli;
117  C& sli();
118 
119  using super_::operator[];
120  C& operator[](unsigned i);
121  };
122 
123 
124 
125 # ifndef MLN_INCLUDE_ONLY
126 
127  // subject_impl
128 
129  template <typename C, typename E>
130  inline
131  const C&
133  {
134  return exact_().get_subject().row();
135  }
136 
137  template <typename C, typename E>
138  inline
139  const C&
141  {
142  return exact_().get_subject().col();
143  }
144 
145  template <typename C, typename E>
146  inline
147  const C&
149  {
150  return exact_().get_subject().sli();
151  }
152 
153  template <typename C, typename E>
154  inline
155  const C&
156  subject_impl< const point<grid::cube, C>, E >::operator[](unsigned i) const
157  {
158  mln_precondition(i < 3);
159  return exact_().get_subject()[i];
160  }
161 
162  template <typename C, typename E>
163  inline
164  const C&
165  subject_impl< const point<grid::cube, C>, E >::last_coord() const
166  {
167  return this->col();
168  }
169 
170  template <typename C, typename E>
171  inline
172  const E&
173  subject_impl< const point<grid::cube, C>, E >::exact_() const
174  {
175  return internal::force_exact<const E>(*this);
176  }
177 
178  // subject_impl
179 
180  template <typename C, typename E>
181  inline
182  C&
184  {
185  return exact_().get_subject().row();
186  }
187 
188  template <typename C, typename E>
189  inline
190  C&
192  {
193  return exact_().get_subject().col();
194  }
195 
196  template <typename C, typename E>
197  inline
198  C&
200  {
201  return exact_().get_subject().sli();
202  }
203 
204  template <typename C, typename E>
205  inline
206  C&
207  subject_impl< point<grid::cube, C>, E >::operator[](unsigned i)
208  {
209  mln_precondition(i < 3);
210  return exact_().get_subject()[i];
211  }
212 
213  template <typename C, typename E>
214  inline
215  E&
217  {
218  return internal::force_exact<E>(*this);
219  }
220 
221 # endif // ! MLN_INCLUDE_ONLY
222 
223  } // end of namespace mln::internal
224 
225 
226 } // end of namespace mln
227 
228 
229 # include <mln/core/alias/dpoint3d.hh>
230 
231 
232 #endif // ! MLN_CORE_ALIAS_POINT3D_HH