Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 2008, 2009, 2010 EPITA Research and Development 00002 // Laboratory (LRDE) 00003 // 00004 // This file is part of Olena. 00005 // 00006 // Olena is free software: you can redistribute it and/or modify it under 00007 // the terms of the GNU General Public License as published by the Free 00008 // Software Foundation, version 2 of the License. 00009 // 00010 // Olena is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Olena. If not, see <http://www.gnu.org/licenses/>. 00017 // 00018 // As a special exception, you may use this file as part of a free 00019 // software project without restriction. Specifically, if other files 00020 // instantiate templates or use macros or inline functions from this 00021 // file, or you compile this file and link it with other files to produce 00022 // an executable, this file does not by itself cause the resulting 00023 // executable to be covered by the GNU General Public License. This 00024 // exception does not however invalidate any other reasons why the 00025 // executable file might be covered by the GNU General Public License. 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 } // end of namespace mln::internal 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 // With a function. 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 // With an image. 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 // With a value. 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 } // end of namespace mln 00194 00195 00196 #endif // ! MLN_CORE_ROUTINE_EXTEND_HH