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
00027 #ifndef MLN_DATA_FILL_WITH_VALUE_HH
00028 # define MLN_DATA_FILL_WITH_VALUE_HH
00029
00038
00039 # include <cstdlib>
00040
00041 # include <mln/core/concept/image.hh>
00042
00043
00044
00045
00046 # include <mln/data/fill_with_value.spe.hh>
00047
00048
00049 namespace mln
00050 {
00051
00052 namespace data
00053 {
00054
00063 template <typename I, typename V>
00064 void fill_with_value(Image<I>& ima, const V& val);
00066
00067
00068
00069 # ifndef MLN_INCLUDE_ONLY
00070
00071 namespace internal
00072 {
00073
00074 template <typename I, typename V>
00075 inline
00076 void fill_with_value_tests(Image<I>& ima, const V&)
00077 {
00078 mlc_converts_to(mln_exact(V), mln_value(I))::check();
00079 mln_precondition(exact(ima).is_valid());
00080
00081
00082 (void) ima;
00083 }
00084
00085 }
00086
00087
00088 namespace impl
00089 {
00090
00091 namespace generic
00092 {
00093
00101
00102 template <typename I, typename V>
00103 void fill_with_value(Image<I>& ima_, const V& val)
00104 {
00105 trace::entering("data::impl::generic::fill_with_value");
00106
00107 I& ima = exact(ima_);
00108
00109 internal::fill_with_value_tests(ima, val);
00110 mlc_is(mln_trait_image_pw_io(I),
00111 trait::image::pw_io::read_write)::check();
00112
00113 mln_value(I) v = static_cast<mln_value(I)>(exact(val));
00114 mln_piter(I) p(ima.domain());
00115 for_all(p)
00116 ima(p) = v;
00117
00118 trace::exiting("data::impl::generic::fill_with_value");
00119 }
00120
00121 }
00122
00123 }
00124
00125
00126
00127
00128 template <typename I, typename V>
00129 inline
00130 void fill_with_value(Image<I>& ima, const V& val)
00131 {
00132 trace::entering("data::fill_with_value");
00133
00134 internal::fill_with_value_tests(ima, val);
00135 internal::fill_with_value_dispatch(ima, val);
00136
00137 trace::exiting("data::fill_with_value");
00138 }
00139
00140
00141 # endif // ! MLN_INCLUDE_ONLY
00142
00143 }
00144
00145 }
00146
00147
00148 #endif // ! MLN_DATA_FILL_WITH_VALUE_HH