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_CORE_ROUTINE_EXTEND_HH
00028 # define MLN_CORE_ROUTINE_EXTEND_HH
00029
00037
00038 # include <mln/core/image/dmorph/extension_ima.hh>
00039 # include <mln/core/image/dmorph/extension_fun.hh>
00040 # include <mln/core/image/dmorph/extension_val.hh>
00041
00042 # include <mln/trait/undef.hh>
00043
00044
00045 # define mln_extension_type(I,J) \
00046 typename mln::internal::extension_type<I,J>::result;
00047
00048 # define mln_extension_type_(I,J) \
00049 mln::internal::extension_type<I,J>::result;
00050
00051
00052 namespace mln
00053 {
00054
00055 namespace internal
00056 {
00057
00058 template <typename I, typename J, typename B1, typename B2>
00059 struct extension_type_selector
00060 {
00061 typedef mln::trait::undef result;
00062 };
00063
00064
00065 template <typename I, typename J>
00066 struct extension_type_selector<I,J,
00067 metal::bool_<false>, metal::bool_<false> >
00068 : mlc_converts_to(J, mln_value(I))::check_t
00069 {
00070 typedef extension_val<I> result;
00071 };
00072
00073
00074 template <typename I, typename J>
00075 struct extension_type_selector<I,J,
00076 metal::bool_<false>, metal::bool_<true> >
00077 {
00078 typedef extension_fun<I, J> result;
00079 };
00080
00081
00082 template <typename I, typename J>
00083 struct extension_type_selector<I,J,
00084 metal::bool_<true>, metal::bool_<false> >
00085 {
00086 typedef extension_ima<I, J> result;
00087 };
00088
00089
00090 template <typename I, typename J>
00091 struct extension_type
00092 : extension_type_selector<I, J,
00093 typename mlc_is_a(J,Image)::eval,
00094 typename mlc_is_a(J,Function)::eval>
00095 {
00096 };
00097
00098
00099 }
00100
00101
00103
00104 template <typename I, typename F>
00105 extension_fun<const I, F>
00106 extend(const Image<I>& ima, const Function_v2v<F>& fun);
00107
00108 template <typename I, typename F>
00109 extension_fun<I, F>
00110 extend(Image<I>& ima, const Function_v2v<F>& fun);
00111
00112
00114
00115 template <typename I, typename J>
00116 extension_ima<const I, const J>
00117 extend(const Image<I>& ima, const Image<J>& ext);
00118
00119
00121
00122 template <typename I>
00123 extension_val<const I>
00124 extend(const Image<I>& ima, const mln_value(I)& val);
00125
00126 template <typename I>
00127 extension_val<I>
00128 extend(Image<I>& ima, const mln_value(I)& val);
00129
00130
00131
00132 # ifndef MLN_INCLUDE_ONLY
00133
00134
00135
00136
00137 template <typename I, typename F>
00138 inline
00139 extension_fun<const I, F>
00140 extend(const Image<I>& ima, const Function_v2v<F>& fun)
00141 {
00142 mlc_converts_to(mln_result(F), mln_value(I))::check();
00143 extension_fun<const I, F> tmp(exact(ima), exact(fun));
00144 return tmp;
00145 }
00146
00147 template <typename I, typename F>
00148 inline
00149 extension_fun<I, F>
00150 extend(Image<I>& ima, const Function_v2v<F>& fun)
00151 {
00152 mlc_converts_to(mln_result(F), mln_value(I))::check();
00153 extension_fun<I, F> tmp(exact(ima), exact(fun));
00154 return tmp;
00155 }
00156
00157
00158
00159
00160 template <typename I, typename J>
00161 extension_ima<const I, const J>
00162 extend(const Image<I>& ima, const Image<J>& ext)
00163 {
00164 mlc_converts_to(mln_value(J), mln_value(I))::check();
00165 extension_ima<const I, const J> tmp(exact(ima), exact(ext));
00166 return tmp;
00167 }
00168
00169
00170
00171
00172 template <typename I>
00173 inline
00174 extension_val<const I>
00175 extend(const Image<I>& ima, const mln_value(I)& val)
00176 {
00177 extension_val<const I> tmp(exact(ima), val);
00178 return tmp;
00179 }
00180
00181 template <typename I>
00182 inline
00183 extension_val<I>
00184 extend(Image<I>& ima, const mln_value(I)& val)
00185 {
00186 extension_val<I> tmp(exact(ima), val);
00187 return tmp;
00188 }
00189
00190
00191 # endif // ! MLN_INCLUDE_ONLY
00192
00193 }
00194
00195
00196 #endif // ! MLN_CORE_ROUTINE_EXTEND_HH