Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
at.hh
1 // Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
2 //
3 // This file is part of Olena.
4 //
5 // Olena is free software: you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free
7 // Software Foundation, version 2 of the License.
8 //
9 // Olena is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // As a special exception, you may use this file as part of a free
18 // software project without restriction. Specifically, if other files
19 // instantiate templates or use macros or inline functions from this
20 // file, or you compile this file and link it with other files to produce
21 // an executable, this file does not by itself cause the resulting
22 // executable to be covered by the GNU General Public License. This
23 // exception does not however invalidate any other reasons why the
24 // executable file might be covered by the GNU General Public License.
25 
26 #ifndef MLN_OPT_AT_HH
27 # define MLN_OPT_AT_HH
28 
32 
33 # include <mln/core/concept/image.hh>
34 # include <mln/trait/images.hh>
35 # include <mln/trace/all.hh>
36 
37 # include <mln/core/alias/point1d.hh>
38 # include <mln/core/alias/point2d.hh>
39 # include <mln/core/alias/point3d.hh>
40 
41 namespace mln
42 {
43 
44  namespace opt
45  {
46 
49  template <typename I>
50  mln_rvalue(I) at(const Image<I>& ima, def::coord ind);
51 
53  template <typename I>
54  mln_lvalue(I) at(Image<I>& ima, def::coord ind);
55 
56 
59  template <typename I>
60  mln_rvalue(I) at(const Image<I>& ima, def::coord row, def::coord col);
61 
63  template <typename I>
64  mln_lvalue(I) at(Image<I>& ima, def::coord row, def::coord col);
65 
69  template <typename I>
70  mln_rvalue(I) at(const Image<I>& ima,
71  def::coord sli, def::coord row, def::coord col);
72 
73 
74 
77  template <typename I>
78  mln_lvalue(I) at(Image<I>& ima,
79  def::coord sli, def::coord row, def::coord col);
80 
81 
82 # ifndef MLN_INCLUDE_ONLY
83 
84 
86  namespace impl
87  {
88 
89  template <typename I>
90  inline
91  mln_rvalue(I) at_1d_impl(trait::image::category::domain_morpher,
92  const Image<I>& ima, def::coord ind)
93  {
94  point1d p(ind);
95  return exact(ima)(p);
96  }
97 
98  template <typename I>
99  inline
100  mln_rvalue(I) at_1d_impl(trait::image::category::morpher,
101  const Image<I>& ima, def::coord ind)
102  {
103  // FIXME: what about morpher that modify the image value?
104  // (through a function for instance)
105  return at(*exact(ima).delegatee_(), ind);
106  }
107 
108  template <typename I>
109  inline
110  mln_rvalue(I) at_1d_impl(trait::image::category::primary,
111  const Image<I>& ima, def::coord ind)
112  {
113  return exact(ima).at_(ind);
114  }
115 
116 
117  template <typename I>
118  inline
119  mln_lvalue(I) at_1d_impl(trait::image::category::domain_morpher,
120  Image<I>& ima, def::coord ind)
121  {
122  mlc_is(mln_trait_image_pw_io(I),
123  trait::image::pw_io::read_write)::check();
124 
125  point1d p(ind);
126  return exact(ima)(p);
127  }
128 
129  template <typename I>
130  inline
131  mln_lvalue(I) at_1d_impl(trait::image::category::morpher,
132  Image<I>& ima, def::coord ind)
133  {
134  // FIXME: what about morpher that modify the image value?
135  // (through a function for instance)
136  return at(*exact(ima).delegatee_(), ind);
137  }
138 
139  template <typename I>
140  inline
141  mln_lvalue(I) at_1d_impl(trait::image::category::primary,
142  Image<I>& ima, def::coord ind)
143  {
144  return exact(ima).at_(ind);
145  }
146 
147  } // end of namespace mln::opt::impl
148 
149  template <typename I>
150  inline
151  mln_rvalue(I) at(const Image<I>& ima, def::coord ind)
152  {
153  mlc_is(mln_trait_image_dimension(I),
154  trait::image::dimension::one_d)::check();
155 
156  return impl::at_1d_impl(mln_trait_image_category(I)(), ima, ind);
157  }
158 
159  template <typename I>
160  mln_lvalue(I) at(Image<I>& ima, def::coord ind)
161  {
162  mlc_is(mln_trait_image_dimension(I),
163  trait::image::dimension::one_d)::check();
164 
165  return impl::at_1d_impl(mln_trait_image_category(I)(), ima, ind);
166  }
167 
168 
169 
171  namespace impl
172  {
173 
174  template <typename I>
175  inline
176  mln_rvalue(I) at_2d_impl(trait::image::category::domain_morpher,
177  const Image<I>& ima, def::coord row, def::coord col)
178  {
179  point2d p(row, col);
180  return exact(ima)(p);
181  }
182 
183  template <typename I>
184  inline
185  mln_rvalue(I) at_2d_impl(trait::image::category::morpher,
186  const Image<I>& ima, def::coord row, def::coord col)
187  {
188  // FIXME: what about morpher that modify the image value?
189  // (through a function for instance)
190  return at(*exact(ima).delegatee_(), row, col);
191  }
192 
193  template <typename I>
194  inline
195  mln_rvalue(I) at_2d_impl(trait::image::category::primary,
196  const Image<I>& ima, def::coord row, def::coord col)
197  {
198  return exact(ima).at_(row, col);
199  }
200 
201 
202  template <typename I>
203  inline
204  mln_lvalue(I) at_2d_impl(trait::image::category::domain_morpher,
205  Image<I>& ima, def::coord row, def::coord col)
206  {
207  mlc_is(mln_trait_image_pw_io(I),
208  trait::image::pw_io::read_write)::check();
209 
210  point2d p(row, col);
211  return exact(ima)(p);
212  }
213 
214  template <typename I>
215  inline
216  mln_lvalue(I) at_2d_impl(trait::image::category::morpher,
217  Image<I>& ima, def::coord row, def::coord col)
218  {
219  // FIXME: what about morpher that modify the image value?
220  // (through a function for instance)
221  return at(*exact(ima).delegatee_(), row, col);
222  }
223 
224  template <typename I>
225  inline
226  mln_lvalue(I) at_2d_impl(trait::image::category::primary,
227  Image<I>& ima, def::coord row, def::coord col)
228  {
229  return exact(ima).at_(row, col);
230  }
231 
232  } // end of namespace mln::opt::impl
233 
234  template <typename I>
235  inline
236  mln_rvalue(I) at(const Image<I>& ima, def::coord row, def::coord col)
237  {
238  mlc_is(mln_trait_image_dimension(I),
239  trait::image::dimension::two_d)::check();
240 
241  return impl::at_2d_impl(mln_trait_image_category(I)(), ima, row, col);
242  }
243 
244  template <typename I>
245  mln_lvalue(I) at(Image<I>& ima, def::coord row, def::coord col)
246  {
247  mlc_is(mln_trait_image_dimension(I),
248  trait::image::dimension::two_d)::check();
249 
250  return impl::at_2d_impl(mln_trait_image_category(I)(), ima, row, col);
251  }
252 
253 
255  namespace impl
256  {
257 
258  template <typename I>
259  inline
260  mln_rvalue(I) at_3d_impl(trait::image::category::domain_morpher,
261  const Image<I>& ima, def::coord sli, def::coord row, def::coord col)
262  {
263  point3d p(sli, row, col);
264  return exact(ima)(p);
265  }
266 
267  template <typename I>
268  inline
269  mln_rvalue(I) at_3d_impl(trait::image::category::morpher,
270  const Image<I>& ima, def::coord sli, def::coord row, def::coord col)
271  {
272  // FIXME: what about morpher that modify the image value?
273  // (through a function for instance)
274  return at(*exact(ima).delegatee_(), sli, row, col);
275  }
276 
277  template <typename I>
278  inline
279  mln_rvalue(I) at_3d_impl(trait::image::category::primary,
280  const Image<I>& ima, def::coord sli, def::coord row, def::coord col)
281  {
282  return exact(ima).at_(sli, row, col);
283  }
284 
285 
286  template <typename I>
287  inline
288  mln_lvalue(I) at_3d_impl(trait::image::category::domain_morpher,
289  Image<I>& ima, def::coord sli, def::coord row, def::coord col)
290  {
291  mlc_is(mln_trait_image_pw_io(I),
292  trait::image::pw_io::read_write)::check();
293 
294  point3d p(sli, row, col);
295  return exact(ima)(p);
296  }
297 
298  template <typename I>
299  inline
300  mln_lvalue(I) at_3d_impl(trait::image::category::morpher,
301  Image<I>& ima, def::coord sli, def::coord row, def::coord col)
302  {
303  // FIXME: what about morpher that modify the image value?
304  // (through a function for instance)
305  return at(*exact(ima).delegatee_(), sli, row, col);
306  }
307 
308  template <typename I>
309  inline
310  mln_lvalue(I) at_3d_impl(trait::image::category::primary,
311  Image<I>& ima, def::coord sli, def::coord row, def::coord col)
312  {
313  return exact(ima).at_(sli, row, col);
314  }
315 
316  } // end of namespace mln::opt::impl
317 
318  template <typename I>
319  inline
320  mln_rvalue(I) at(const Image<I>& ima, def::coord sli, def::coord row, def::coord col)
321  {
322  mlc_is(mln_trait_image_dimension(I),
323  trait::image::dimension::three_d)::check();
324 
325  return impl::at_3d_impl(mln_trait_image_category(I)(),
326  ima, sli, row, col);
327  }
328 
329  template <typename I>
330  mln_lvalue(I) at(Image<I>& ima, def::coord sli, def::coord row, def::coord col)
331  {
332  mlc_is(mln_trait_image_dimension(I),
333  trait::image::dimension::three_d)::check();
334 
335  return impl::at_3d_impl(mln_trait_image_category(I)(),
336  ima, sli, row, col);
337  }
338 
339 # endif // ! MLN_INCLUDE_ONLY
340 
341  } // end of namespace mln::opt
342 
343 } // end of namespace mln
344 
345 
346 #endif // ! MLN_OPT_AT_HH