• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

at.hh

00001 // Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
00002 //
00003 // This file is part of Olena.
00004 //
00005 // Olena is free software: you can redistribute it and/or modify it under
00006 // the terms of the GNU General Public License as published by the Free
00007 // Software Foundation, version 2 of the License.
00008 //
00009 // Olena is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Olena.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 // As a special exception, you may use this file as part of a free
00018 // software project without restriction.  Specifically, if other files
00019 // instantiate templates or use macros or inline functions from this
00020 // file, or you compile this file and link it with other files to produce
00021 // an executable, this file does not by itself cause the resulting
00022 // executable to be covered by the GNU General Public License.  This
00023 // exception does not however invalidate any other reasons why the
00024 // executable file might be covered by the GNU General Public License.
00025 
00026 #ifndef MLN_OPT_AT_HH
00027 # define MLN_OPT_AT_HH
00028 
00032 
00033 # include <mln/core/concept/image.hh>
00034 # include <mln/trait/images.hh>
00035 # include <mln/trace/all.hh>
00036 
00037 # include <mln/core/alias/point1d.hh>
00038 # include <mln/core/alias/point2d.hh>
00039 # include <mln/core/alias/point3d.hh>
00040 
00041 namespace mln
00042 {
00043 
00044   namespace opt
00045   {
00046 
00049     template <typename I>
00050     mln_rvalue(I) at(const Image<I>& ima, def::coord ind);
00051 
00053     template <typename I>
00054     mln_lvalue(I) at(Image<I>& ima, def::coord ind);
00055 
00056 
00059     template <typename I>
00060     mln_rvalue(I) at(const Image<I>& ima, def::coord row, def::coord col);
00061 
00063     template <typename I>
00064     mln_lvalue(I) at(Image<I>& ima, def::coord row, def::coord col);
00065 
00069     template <typename I>
00070     mln_rvalue(I) at(const Image<I>& ima,
00071                      def::coord sli, def::coord row, def::coord col);
00072 
00073 
00074 
00077     template <typename I>
00078     mln_lvalue(I) at(Image<I>& ima,
00079                      def::coord sli, def::coord row, def::coord col);
00080 
00081 
00082 # ifndef MLN_INCLUDE_ONLY
00083 
00084 
00086     namespace impl
00087     {
00088 
00089       template <typename I>
00090       inline
00091       mln_rvalue(I) at_1d_impl(trait::image::category::domain_morpher,
00092                                const Image<I>& ima, def::coord ind)
00093       {
00094         point1d p(ind);
00095         return exact(ima)(p);
00096       }
00097 
00098       template <typename I>
00099       inline
00100       mln_rvalue(I) at_1d_impl(trait::image::category::morpher,
00101                                const Image<I>& ima, def::coord ind)
00102       {
00103         // FIXME: what about morpher that modify the image value?
00104         // (through a function for instance)
00105         return at(*exact(ima).delegatee_(), ind);
00106       }
00107 
00108       template <typename I>
00109       inline
00110       mln_rvalue(I) at_1d_impl(trait::image::category::primary,
00111                                const Image<I>& ima, def::coord ind)
00112       {
00113         return exact(ima).at_(ind);
00114       }
00115 
00116 
00117       template <typename I>
00118       inline
00119       mln_lvalue(I) at_1d_impl(trait::image::category::domain_morpher,
00120                                Image<I>& ima, def::coord ind)
00121       {
00122         mlc_is(mln_trait_image_pw_io(I),
00123                trait::image::pw_io::read_write)::check();
00124 
00125         point1d p(ind);
00126         return exact(ima)(p);
00127       }
00128 
00129       template <typename I>
00130       inline
00131       mln_lvalue(I) at_1d_impl(trait::image::category::morpher,
00132                                Image<I>& ima, def::coord ind)
00133       {
00134         // FIXME: what about morpher that modify the image value?
00135         // (through a function for instance)
00136         return at(*exact(ima).delegatee_(), ind);
00137       }
00138 
00139       template <typename I>
00140       inline
00141       mln_lvalue(I) at_1d_impl(trait::image::category::primary,
00142                                Image<I>& ima, def::coord ind)
00143       {
00144         return exact(ima).at_(ind);
00145       }
00146 
00147     } // end of namespace mln::opt::impl
00148 
00149     template <typename I>
00150     inline
00151     mln_rvalue(I) at(const Image<I>& ima, def::coord ind)
00152     {
00153       mlc_is(mln_trait_image_dimension(I),
00154              trait::image::dimension::one_d)::check();
00155 
00156       return impl::at_1d_impl(mln_trait_image_category(I)(), ima, ind);
00157     }
00158 
00159     template <typename I>
00160     mln_lvalue(I) at(Image<I>& ima, def::coord ind)
00161     {
00162       mlc_is(mln_trait_image_dimension(I),
00163              trait::image::dimension::one_d)::check();
00164 
00165       return impl::at_1d_impl(mln_trait_image_category(I)(), ima, ind);
00166     }
00167 
00168 
00169 
00171     namespace impl
00172     {
00173 
00174       template <typename I>
00175       inline
00176       mln_rvalue(I) at_2d_impl(trait::image::category::domain_morpher,
00177                                const Image<I>& ima, def::coord row, def::coord col)
00178       {
00179         point2d p(row, col);
00180         return exact(ima)(p);
00181       }
00182 
00183       template <typename I>
00184       inline
00185       mln_rvalue(I) at_2d_impl(trait::image::category::morpher,
00186                                const Image<I>& ima, def::coord row, def::coord col)
00187       {
00188         // FIXME: what about morpher that modify the image value?
00189         // (through a function for instance)
00190         return at(*exact(ima).delegatee_(), row, col);
00191       }
00192 
00193       template <typename I>
00194       inline
00195       mln_rvalue(I) at_2d_impl(trait::image::category::primary,
00196                                const Image<I>& ima, def::coord row, def::coord col)
00197       {
00198         return exact(ima).at_(row, col);
00199       }
00200 
00201 
00202       template <typename I>
00203       inline
00204       mln_lvalue(I) at_2d_impl(trait::image::category::domain_morpher,
00205                                Image<I>& ima, def::coord row, def::coord col)
00206       {
00207         mlc_is(mln_trait_image_pw_io(I),
00208                trait::image::pw_io::read_write)::check();
00209 
00210         point2d p(row, col);
00211         return exact(ima)(p);
00212       }
00213 
00214       template <typename I>
00215       inline
00216       mln_lvalue(I) at_2d_impl(trait::image::category::morpher,
00217                                Image<I>& ima, def::coord row, def::coord col)
00218       {
00219         // FIXME: what about morpher that modify the image value?
00220         // (through a function for instance)
00221         return at(*exact(ima).delegatee_(), row, col);
00222       }
00223 
00224       template <typename I>
00225       inline
00226       mln_lvalue(I) at_2d_impl(trait::image::category::primary,
00227                                Image<I>& ima, def::coord row, def::coord col)
00228       {
00229         return exact(ima).at_(row, col);
00230       }
00231 
00232     } // end of namespace mln::opt::impl
00233 
00234     template <typename I>
00235     inline
00236     mln_rvalue(I) at(const Image<I>& ima, def::coord row, def::coord col)
00237     {
00238       mlc_is(mln_trait_image_dimension(I),
00239              trait::image::dimension::two_d)::check();
00240 
00241       return impl::at_2d_impl(mln_trait_image_category(I)(), ima, row, col);
00242     }
00243 
00244     template <typename I>
00245     mln_lvalue(I) at(Image<I>& ima, def::coord row, def::coord col)
00246     {
00247       mlc_is(mln_trait_image_dimension(I),
00248              trait::image::dimension::two_d)::check();
00249 
00250       return impl::at_2d_impl(mln_trait_image_category(I)(), ima, row, col);
00251     }
00252 
00253 
00255     namespace impl
00256     {
00257 
00258       template <typename I>
00259       inline
00260       mln_rvalue(I) at_3d_impl(trait::image::category::domain_morpher,
00261                                const Image<I>& ima, def::coord sli, def::coord row, def::coord col)
00262       {
00263         point3d p(sli, row, col);
00264         return exact(ima)(p);
00265       }
00266 
00267       template <typename I>
00268       inline
00269       mln_rvalue(I) at_3d_impl(trait::image::category::morpher,
00270                                const Image<I>& ima, def::coord sli, def::coord row, def::coord col)
00271       {
00272         // FIXME: what about morpher that modify the image value?
00273         // (through a function for instance)
00274         return at(*exact(ima).delegatee_(), sli, row, col);
00275       }
00276 
00277       template <typename I>
00278       inline
00279       mln_rvalue(I) at_3d_impl(trait::image::category::primary,
00280                                const Image<I>& ima, def::coord sli, def::coord row, def::coord col)
00281       {
00282         return exact(ima).at_(sli, row, col);
00283       }
00284 
00285 
00286       template <typename I>
00287       inline
00288       mln_lvalue(I) at_3d_impl(trait::image::category::domain_morpher,
00289                                Image<I>& ima, def::coord sli, def::coord row, def::coord col)
00290       {
00291         mlc_is(mln_trait_image_pw_io(I),
00292                trait::image::pw_io::read_write)::check();
00293 
00294         point3d p(sli, row, col);
00295         return exact(ima)(p);
00296       }
00297 
00298       template <typename I>
00299       inline
00300       mln_lvalue(I) at_3d_impl(trait::image::category::morpher,
00301                                Image<I>& ima, def::coord sli, def::coord row, def::coord col)
00302       {
00303         // FIXME: what about morpher that modify the image value?
00304         // (through a function for instance)
00305         return at(*exact(ima).delegatee_(), sli, row, col);
00306       }
00307 
00308       template <typename I>
00309       inline
00310       mln_lvalue(I) at_3d_impl(trait::image::category::primary,
00311                                Image<I>& ima, def::coord sli, def::coord row, def::coord col)
00312       {
00313         return exact(ima).at_(sli, row, col);
00314       }
00315 
00316     } // end of namespace mln::opt::impl
00317 
00318     template <typename I>
00319     inline
00320     mln_rvalue(I) at(const Image<I>& ima, def::coord sli, def::coord row, def::coord col)
00321     {
00322       mlc_is(mln_trait_image_dimension(I),
00323              trait::image::dimension::three_d)::check();
00324 
00325       return impl::at_3d_impl(mln_trait_image_category(I)(),
00326                               ima, sli, row, col);
00327     }
00328 
00329     template <typename I>
00330     mln_lvalue(I) at(Image<I>& ima, def::coord sli, def::coord row, def::coord col)
00331     {
00332       mlc_is(mln_trait_image_dimension(I),
00333              trait::image::dimension::three_d)::check();
00334 
00335       return impl::at_3d_impl(mln_trait_image_category(I)(),
00336                               ima, sli, row, col);
00337     }
00338 
00339 # endif // ! MLN_INCLUDE_ONLY
00340 
00341   } // end of namespace mln::opt
00342 
00343 } // end of namespace mln
00344 
00345 
00346 #endif // ! MLN_OPT_AT_HH

Generated on Tue Oct 4 2011 15:23:25 for Milena (Olena) by  doxygen 1.7.1