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

fill_with_image.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_DATA_FILL_WITH_IMAGE_HH
00027 # define MLN_DATA_FILL_WITH_IMAGE_HH
00028 
00034 
00035 # include <mln/core/concept/image.hh>
00036 
00037 
00038 // Specializations are in:
00039 # include <mln/data/fill_with_image.spe.hh>
00040 
00041 
00042 namespace mln
00043 {
00044 
00045   namespace data
00046   {
00047 
00058     template <typename I, typename J>
00059     void fill_with_image(Image<I>& ima, const Image<J>& data);
00060 
00061 
00062 
00063 # ifndef MLN_INCLUDE_ONLY
00064 
00065     namespace internal
00066     {
00067 
00068       template <typename I, typename J>
00069       inline
00070       void fill_with_image_tests(Image<I>& ima, const Image<J>& data)
00071       {
00072         // Avoid a warning about an undefined variable when NDEBUG
00073         // is not defined.
00074         (void)ima;
00075         (void)data;
00076 
00077         mlc_is(mln_trait_image_pw_io(I),
00078                mln::trait::image::pw_io::read_write)::check();
00079         mlc_converts_to(mln_value(J), mln_value(I))::check();
00080         mln_precondition(exact(ima).is_valid());
00081         mln_precondition(exact(data).is_valid());
00082         mln_precondition(exact(ima).domain() <= exact(data).domain());
00083       }
00084 
00085     } // end of namespace mln::data::internal
00086 
00087 
00088     namespace impl
00089     {
00090 
00091       namespace generic
00092       {
00093 
00098         //
00099         template <typename I, typename J>
00100         void fill_with_image(Image<I>& ima_, const Image<J>& data_)
00101         {
00102           trace::entering("data::impl::generic::fill_with_image");
00103           I& ima = exact(ima_);
00104           const J& data = exact(data_);
00105 
00106           data::internal::fill_with_image_tests(ima, data);
00107 
00108           mln_piter(I) p(ima.domain());
00109           for_all(p)
00110             ima(p) = static_cast<mln_value(I)>(data(p));
00111 
00112           trace::exiting("data::impl::generic::fill_with_image");
00113         }
00114 
00115       } // end if namespace mln::data::impl::generic
00116 
00117     } // end of namespace mln::data::impl
00118 
00119 
00120     // Facade.
00121 
00122     template <typename I, typename J>
00123     inline
00124     void fill_with_image(Image<I>& ima, const Image<J>& data)
00125     {
00126       trace::entering("data::fill_with_image");
00127 
00128       internal::fill_with_image_(ima, data);
00129 
00130       trace::exiting("data::fill_with_image");
00131     }
00132 
00133 # endif // ! MLN_INCLUDE_ONLY
00134 
00135   } // end of namespace mln::data
00136 
00137 } // end of namespace mln
00138 
00139 
00140 #endif // ! MLN_DATA_FILL_WITH_IMAGE_HH

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