00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
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 
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         
00073         
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     } 
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       } 
00116 
00117     } 
00118 
00119 
00120     
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   } 
00136 
00137 } 
00138 
00139 
00140 #endif // ! MLN_DATA_FILL_WITH_IMAGE_HH