Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 2009, 2011 EPITA Research and Development Laboratory 00002 // (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_IMAGE_GRAPH_ELT_WINDOW_IF_HH 00028 # define MLN_CORE_IMAGE_GRAPH_ELT_WINDOW_IF_HH 00029 00035 00036 # include <mln/core/concept/window.hh> 00037 # include <mln/core/internal/neighborhood_base.hh> 00038 # include <mln/core/internal/graph_window_base.hh> 00039 # include <mln/core/internal/is_masked_impl_selector.hh> 00040 # include <mln/core/image/graph_window_if_piter.hh> 00041 00042 00043 namespace mln 00044 { 00045 00047 template <typename G, typename S, typename I> class graph_elt_window_if; 00048 template <typename G, typename F> class p_edges; 00049 template <typename G, typename F> class p_vertices; 00050 00051 00052 namespace internal 00053 { 00054 00055 template <typename G, typename S, typename I, typename E> 00056 struct neighborhood_impl<graph_elt_window_if<G,S,I>,E> 00057 : public neighborhood_extra_impl<graph_elt_window_if<G,S,I>,E> 00058 { 00059 }; 00060 00061 00064 template <typename G, typename S> 00065 struct graph_window_if_iter_dispatch; 00066 00067 template <typename G, typename F> 00068 struct graph_window_if_iter_dispatch<G, p_edges<G,F> > 00069 { 00070 typedef mln_edge_nbh_edge_fwd_iter(G) nbh_fwd_iter_; 00071 typedef mln_edge_nbh_edge_bkd_iter(G) nbh_bkd_iter_; 00072 }; 00073 00074 template <typename G, typename F> 00075 struct graph_window_if_iter_dispatch<G, p_vertices<G,F> > 00076 { 00077 typedef mln_vertex_nbh_vertex_fwd_iter(G) nbh_fwd_iter_; 00078 typedef mln_vertex_nbh_vertex_bkd_iter(G) nbh_bkd_iter_; 00079 }; 00080 00081 00082 } // end of namespace mln::internal 00083 00084 00085 namespace trait 00086 { 00087 00088 template <typename G, typename S, typename I> 00089 struct window_< mln::graph_elt_window_if<G,S,I> > 00090 { 00091 typedef trait::window::size::unknown size; 00092 typedef trait::window::support::irregular support; 00093 typedef trait::window::definition::varying definition; 00094 }; 00095 00096 } // end of namespace mln::trait 00097 00098 00105 template <typename G, typename S, typename I> 00106 class graph_elt_window_if 00107 : public graph_window_base<mln_result(S::fun_t), 00108 graph_elt_window_if<G,S,I> >, 00109 public internal::graph_window_if_iter_dispatch<G,S>, 00110 private mlc_is(mln_value(I), bool)::check_t 00111 { 00112 typedef graph_elt_window_if<G,S,I> self_; 00113 typedef internal::graph_window_if_iter_dispatch<G,S> super_; 00114 00115 typedef typename super_::nbh_fwd_iter_ nbh_fwd_iter_; 00116 typedef typename super_::nbh_bkd_iter_ nbh_bkd_iter_; 00117 00118 public: 00120 typedef I mask_t; 00121 00125 graph_elt_window_if(); 00126 00130 graph_elt_window_if(const Image<I>& mask); 00132 00135 00137 typedef S target; 00138 00140 typedef mln_psite(target) psite; 00141 00144 typedef graph_window_if_piter<target,self_,nbh_fwd_iter_> fwd_qiter; 00145 00148 typedef graph_window_if_piter<target,self_,nbh_bkd_iter_> bkd_qiter; 00149 00151 typedef fwd_qiter qiter; 00153 00155 const I& mask() const; 00156 00158 void change_mask(const Image<I>& mask); 00159 00161 bool is_valid() const; 00162 00163 private: 00164 // FIXME: Should be const! 00165 I mask_; 00166 }; 00167 00168 00169 00170 # ifndef MLN_INCLUDE_ONLY 00171 00172 00173 template <typename G, typename S, typename I> 00174 inline 00175 graph_elt_window_if<G,S,I>::graph_elt_window_if() 00176 { 00177 } 00178 00179 00180 template <typename G, typename S, typename I> 00181 inline 00182 graph_elt_window_if<G,S,I>::graph_elt_window_if(const Image<I>& mask) 00183 : mask_(exact(mask)) 00184 { 00185 } 00186 00187 00188 template <typename G, typename S, typename I> 00189 inline 00190 const I& 00191 graph_elt_window_if<G,S,I>::mask() const 00192 { 00193 return mask_; 00194 } 00195 00196 00197 template <typename G, typename S, typename I> 00198 inline 00199 void 00200 graph_elt_window_if<G,S,I>::change_mask(const Image<I>& mask) 00201 { 00202 mln_precondition(exact(mask).is_valid()); 00203 mask_ = exact(mask); 00204 } 00205 00206 template <typename G, typename S, typename I> 00207 inline 00208 bool 00209 graph_elt_window_if<G,S,I>::is_valid() const 00210 { 00211 return mask_.is_valid(); 00212 } 00213 00214 00215 # endif // ! MLN_INCLUDE_ONLY 00216 00217 00218 } // end of namespace mln 00219 00220 00221 #endif // ! MLN_CORE_IMAGE_GRAPH_ELT_WINDOW_IF_HH