Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 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_MAKE_EDGE_IMAGE_HH 00027 # define MLN_MAKE_EDGE_IMAGE_HH 00028 00032 00033 # include <mln/core/image/edge_image.hh> 00034 # include <mln/core/image/vertex_image.hh> 00035 # include <mln/core/concept/function.hh> 00036 # include <mln/util/internal/id2element.hh> 00037 # include <mln/data/fill.hh> 00038 00039 00040 namespace mln 00041 { 00042 00043 namespace make 00044 { 00045 00046 00053 // 00054 template <typename V, typename G> 00055 mln::edge_image<void,V,G> 00056 edge_image(const Graph<G>& g, const fun::i2v::array<V>& fv); 00057 00064 // 00065 template <typename FV, typename G> 00066 mln::edge_image<void, mln_result(FV), G> 00067 edge_image(const Graph<G>& g, const Function_v2v<FV>& fv); 00068 00069 00077 // 00078 template <typename FP, typename FV, typename G> 00079 mln::edge_image<mln_result(FP),mln_result(FV),G> 00080 edge_image(const Graph<G>& g_, 00081 const Function_v2v<FP>& fp, 00082 const Function_v2v<FV>& fv); 00083 00084 00085 00094 // 00095 template <typename P, typename V, typename G, typename FP, typename FV> 00096 mln::edge_image<mln_result(FP),mln_result(FV),G> 00097 edge_image(const mln::vertex_image<P,V,G>& v_ima_, 00098 const p_edges<G,FP> pe, 00099 const Function_vv2v<FV>& fv_); 00100 00101 00102 00111 // 00112 template <typename P, typename V, typename G, typename FV> 00113 mln::edge_image<void,mln_result(FV),G> 00114 edge_image(const mln::vertex_image<P,V,G>& v_ima_, 00115 const Function_vv2v<FV>& fv_); 00116 00117 00127 // 00128 template <typename P, typename V, typename G, typename F> 00129 mln::edge_image<void,bool,G> 00130 edge_image(const mln::vertex_image<P,V,G>& v_ima_, 00131 const Function_v2b<F>& fv_); 00132 00133 00134 # ifndef MLN_INCLUDE_ONLY 00135 00136 00137 00138 template <typename V, typename G> 00139 inline 00140 mln::edge_image<void,V,G> 00141 edge_image(const Graph<G>& g, const fun::i2v::array<V>& fv) 00142 { 00143 trace::entering("make::edge_image"); 00144 mln_precondition(exact(g).is_valid()); 00145 00146 p_edges<G> pe(g); 00147 mln::edge_image<void,V,G> ima(pe, fv); 00148 00149 trace::exiting("make::edge_image"); 00150 return ima; 00151 } 00152 00153 template <typename FV, typename G> 00154 mln::edge_image<void,mln_result(FV),G> 00155 edge_image(const Graph<G>& g_, 00156 const Function_v2v<FV>& fv) 00157 { 00158 trace::entering("make::edge_image"); 00159 const G& g = exact(g_); 00160 const FV& f = exact(fv); 00161 mln_precondition(g.is_valid()); 00162 00163 p_edges<G> pe(g); 00164 typedef mln::edge_image<void,mln_result(FV),G> ima_t; 00165 ima_t ima(pe); 00166 00167 mln_piter(ima_t) e(ima.domain()); 00168 for_all(e) 00169 ima(e) = f(e.id()); 00170 00171 trace::exiting("make::edge_image"); 00172 return ima; 00173 } 00174 00175 00176 template <typename FP, typename FV, typename G> 00177 inline 00178 mln::edge_image<mln_result(FP),mln_result(FV),G> 00179 edge_image(const Graph<G>& g_, 00180 const Function_v2v<FP>& fp, 00181 const Function_v2v<FV>& fv) 00182 { 00183 trace::entering("make::edge_image"); 00184 const G& g = exact(g_); 00185 mln_precondition(g.is_valid()); 00186 00187 p_edges<G,FP> pe(g,fp); 00188 mln::edge_image<mln_result(FP),mln_result(FV),G> ima(pe, fv); 00189 00190 trace::exiting("make::edge_image"); 00191 return ima; 00192 } 00193 00194 00195 00196 template <typename P, typename V, typename G, typename FP, typename FV> 00197 inline 00198 mln::edge_image<mln_result(FP),mln_result(FV),G> 00199 edge_image(const mln::vertex_image<P,V,G>& v_ima_, 00200 const p_edges<G,FP> pe, 00201 const Function_vv2v<FV>& fv_) 00202 { 00203 trace::entering("make::edge_image"); 00204 00205 const FV& fv = exact(fv_); 00206 const mln::vertex_image<P,V,G>& v_ima = exact(v_ima_); 00207 mln_precondition(v_ima.is_valid()); 00208 00209 typedef mln::edge_image<mln_result(FP),mln_result(FV),G> edge_ima_t; 00210 edge_ima_t ima_e(pe); 00211 00212 mln_piter(edge_ima_t) e(ima_e.domain()); 00213 for_all(e) 00214 ima_e(e) = fv(e.element().v1(), e.element().v2()); 00215 00216 trace::exiting("make::edge_image"); 00217 return ima_e; 00218 } 00219 00220 00221 00222 template <typename P, typename V, typename G, typename FV> 00223 inline 00224 mln::edge_image<void,mln_result(FV),G> 00225 edge_image(const mln::vertex_image<P,V,G>& v_ima_, 00226 const Function_vv2v<FV>& fv_) 00227 { 00228 trace::entering("make::edge_image"); 00229 00230 const FV& fv = exact(fv_); 00231 const mln::vertex_image<P,V,G>& v_ima = exact(v_ima_); 00232 mln_precondition(v_ima.is_valid()); 00233 00234 p_edges<G> pe(v_ima.domain().graph()); 00235 typedef mln::edge_image<void,mln_result(FV),G> edge_ima_t; 00236 edge_ima_t ima_e(pe); 00237 00238 mln_piter(edge_ima_t) e(ima_e.domain()); 00239 for_all(e) 00240 ima_e(e) = fv(v_ima(e.element().v1()), v_ima(e.element().v2())); 00241 00242 trace::exiting("make::edge_image"); 00243 return ima_e; 00244 } 00245 00246 00247 template <typename P, typename V, typename G, typename F> 00248 inline 00249 mln::edge_image<void,bool,G> 00250 edge_image(const mln::vertex_image<P,V,G>& v_ima_, 00251 const Function_v2b<F>& fv_) 00252 { 00253 trace::entering("make::edge_image"); 00254 00255 const F& fv = exact(fv_); 00256 typedef mln::vertex_image<P,V,G> v_ima_t; 00257 const v_ima_t& v_ima = exact(v_ima_); 00258 mln_precondition(v_ima.is_valid()); 00259 00260 p_edges<G> pe(v_ima.domain().graph()); 00261 typedef mln::edge_image<void,bool,G> edge_ima_t; 00262 edge_ima_t ima_e(pe); 00263 data::fill(ima_e, true); 00264 00265 mln_piter(v_ima_t) p(v_ima.domain()); 00266 for_all(p) 00267 if (!fv(v_ima(p))) 00268 { 00269 typename v_ima_t::edge_win_t win; 00270 mln_qiter(v_ima_t::edge_win_t) q(win, p); 00271 for_all(q) 00272 ima_e(q) = false; 00273 } 00274 00275 trace::exiting("make::edge_image"); 00276 return ima_e; 00277 } 00278 00279 00280 00281 # endif // ! MLN_INCLUDE_ONLY 00282 00283 00284 } // end of namespace mln::make 00285 00286 } // end of namespace mln 00287 00288 #endif // ! MLN_MAKE_EDGE_IMAGE_HH