• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

edge_image.hh

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 
00038 
00039 namespace mln
00040 {
00041 
00042   namespace make
00043   {
00044 
00045 
00052     //
00053     template <typename V, typename G>
00054     mln::edge_image<void,V,G>
00055     edge_image(const Graph<G>& g, const fun::i2v::array<V>& fv);
00056 
00057 
00058 
00066     //
00067     template <typename FP, typename FV, typename G>
00068     mln::edge_image<mln_result(FP),mln_result(FV),G>
00069     edge_image(const Graph<G>& g_,
00070                const Function_v2v<FP>& fp,
00071                const Function_v2v<FV>& fv);
00072 
00073 
00074 
00083     //
00084     template <typename P, typename V, typename G, typename FP, typename FV>
00085     mln::edge_image<mln_result(FP),mln_result(FV),G>
00086     edge_image(const mln::vertex_image<P,V,G>& v_ima_,
00087                const p_edges<G,FP> pe,
00088                const Function_vv2v<FV>& fv_);
00089 
00090 
00091 
00100     //
00101     template <typename P, typename V, typename G, typename FV>
00102     mln::edge_image<void,mln_result(FV),G>
00103     edge_image(const mln::vertex_image<P,V,G>& v_ima_,
00104                const Function_vv2v<FV>& fv_);
00105 
00106 
00107 # ifndef MLN_INCLUDE_ONLY
00108 
00109 
00110 
00111     template <typename V, typename G>
00112     mln::edge_image<void,V,G>
00113     edge_image(const Graph<G>& g, const fun::i2v::array<V>& fv)
00114     {
00115       trace::entering("make::edge_image");
00116       mln_precondition(exact(g).is_valid());
00117 
00118       p_vertices<G> pv(g);
00119       mln::edge_image<void,V,G> ima(pv, fv);
00120 
00121       trace::exiting("make::edge_image");
00122       return ima;
00123     }
00124 
00125 
00126 
00127     template <typename FP, typename FV, typename G>
00128     mln::edge_image<mln_result(FP),mln_result(FV),G>
00129     edge_image(const Graph<G>& g_,
00130                const Function_v2v<FP>& fp,
00131                const Function_v2v<FV>& fv)
00132     {
00133       trace::entering("make::edge_image");
00134       const G& g = exact(g_);
00135       mln_precondition(g.is_valid());
00136 
00137       p_vertices<G,FP> pv(g,fp);
00138       mln::edge_image<mln_result(FP),mln_result(FV),G> ima(pv, fv);
00139 
00140       trace::exiting("make::edge_image");
00141       return ima;
00142     }
00143 
00144 
00145 
00146     template <typename P, typename V, typename G, typename FP, typename FV>
00147     mln::edge_image<mln_result(FP),mln_result(FV),G>
00148     edge_image(const mln::vertex_image<P,V,G>& v_ima_,
00149                const p_edges<G,FP> pe,
00150                const Function_vv2v<FV>& fv_)
00151     {
00152       trace::entering("make::edge_image");
00153 
00154       const FV& fv = exact(fv_);
00155       const mln::vertex_image<P,V,G>& v_ima = exact(v_ima_);
00156       mln_precondition(v_ima.is_valid());
00157 
00158       typedef mln::edge_image<mln_result(FP),mln_result(FV),G> edge_ima_t;
00159       edge_ima_t ima_e(pe);
00160 
00161       mln_piter(edge_ima_t) e(ima_e.domain());
00162       for_all(e)
00163         ima_e(e) = fv(e.element().v1(), e.element().v2());
00164 
00165       trace::exiting("make::edge_image");
00166       return ima_e;
00167     }
00168 
00169 
00170 
00171     template <typename P, typename V, typename G, typename FV>
00172     mln::edge_image<void,mln_result(FV),G>
00173     edge_image(const mln::vertex_image<P,V,G>& v_ima_,
00174                const Function_vv2v<FV>& fv_)
00175     {
00176       trace::entering("make::edge_image");
00177 
00178       const FV& fv = exact(fv_);
00179       const mln::vertex_image<P,V,G>& v_ima = exact(v_ima_);
00180       mln_precondition(v_ima.is_valid());
00181 
00182       p_edges<G> pe(v_ima.domain().graph());
00183       typedef mln::edge_image<void,mln_result(FV),G> edge_ima_t;
00184       edge_ima_t ima_e(pe);
00185 
00186       mln_piter(edge_ima_t) e(ima_e.domain());
00187       for_all(e)
00188         ima_e(e) = fv(v_ima(e.element().v1()), v_ima(e.element().v2()));
00189 
00190       trace::exiting("make::edge_image");
00191       return ima_e;
00192     }
00193 
00194 
00195 
00196 # endif // ! MLN_INCLUDE_ONLY
00197 
00198 
00199   } // end of namespace mln::make
00200 
00201 } // end of namespace mln
00202 
00203 #endif // ! MLN_MAKE_EDGE_IMAGE_HH

Generated on Thu Sep 8 2011 18:31:47 for Milena (Olena) by  doxygen 1.7.1