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 #ifndef MLN_CORE_IMAGE_GRAPH_ELT_WINDOW_IF_HH
00027 # define MLN_CORE_IMAGE_GRAPH_ELT_WINDOW_IF_HH
00028
00034
00035 # include <mln/core/concept/window.hh>
00036 # include <mln/core/internal/neighborhood_base.hh>
00037 # include <mln/core/internal/graph_window_base.hh>
00038 # include <mln/core/internal/is_masked_impl_selector.hh>
00039 # include <mln/core/image/graph_window_if_piter.hh>
00040
00041
00042 namespace mln
00043 {
00044
00046 template <typename G, typename S, typename I> class graph_elt_window_if;
00047 template <typename G, typename F> struct p_edges;
00048 template <typename G, typename F> struct p_vertices;
00049
00050
00051 namespace internal
00052 {
00053
00054 template <typename G, typename S, typename I, typename E>
00055 struct neighborhood_impl<graph_elt_window_if<G,S,I>,E>
00056 : public neighborhood_extra_impl<graph_elt_window_if<G,S,I>,E>
00057 {
00058 };
00059
00060
00063 template <typename G, typename S>
00064 struct graph_window_if_iter_dispatch;
00065
00066 template <typename G, typename F>
00067 struct graph_window_if_iter_dispatch<G, p_edges<G,F> >
00068 {
00069 typedef mln_edge_nbh_edge_fwd_iter(G) nbh_fwd_iter_;
00070 typedef mln_edge_nbh_edge_bkd_iter(G) nbh_bkd_iter_;
00071 };
00072
00073 template <typename G, typename F>
00074 struct graph_window_if_iter_dispatch<G, p_vertices<G,F> >
00075 {
00076 typedef mln_vertex_nbh_vertex_fwd_iter(G) nbh_fwd_iter_;
00077 typedef mln_vertex_nbh_vertex_bkd_iter(G) nbh_bkd_iter_;
00078 };
00079
00080
00081 }
00082
00083
00084 namespace trait
00085 {
00086
00087 template <typename G, typename S, typename I>
00088 struct window_< mln::graph_elt_window_if<G,S,I> >
00089 {
00090 typedef trait::window::size::unknown size;
00091 typedef trait::window::support::irregular support;
00092 typedef trait::window::definition::varying definition;
00093 };
00094
00095 }
00096
00097
00104 template <typename G, typename S, typename I>
00105 class graph_elt_window_if
00106 : public graph_window_base<mln_result(S::fun_t),
00107 graph_elt_window_if<G,S,I> >,
00108 public internal::graph_window_if_iter_dispatch<G,S>,
00109 private mlc_is(mln_value(I), bool)::check_t
00110 {
00111 typedef graph_elt_window_if<G,S,I> self_;
00112 typedef internal::graph_window_if_iter_dispatch<G,S> super_;
00113
00114 typedef typename super_::nbh_fwd_iter_ nbh_fwd_iter_;
00115 typedef typename super_::nbh_bkd_iter_ nbh_bkd_iter_;
00116
00117 public:
00119 typedef I mask_t;
00120
00124 graph_elt_window_if();
00125
00129 graph_elt_window_if(const Image<I>& mask);
00131
00134
00136 typedef S target;
00137
00139 typedef mln_psite(target) psite;
00140
00143 typedef graph_window_if_piter<target,self_,nbh_fwd_iter_> fwd_qiter;
00144
00147 typedef graph_window_if_piter<target,self_,nbh_bkd_iter_> bkd_qiter;
00148
00150 typedef fwd_qiter qiter;
00152
00154 const I& mask() const;
00155
00157 void change_mask(const Image<I>& mask);
00158
00160 bool is_valid() const;
00161
00162 private:
00163
00164 I mask_;
00165 };
00166
00167
00168
00169 # ifndef MLN_INCLUDE_ONLY
00170
00171
00172 template <typename G, typename S, typename I>
00173 inline
00174 graph_elt_window_if<G,S,I>::graph_elt_window_if()
00175 {
00176 }
00177
00178
00179 template <typename G, typename S, typename I>
00180 inline
00181 graph_elt_window_if<G,S,I>::graph_elt_window_if(const Image<I>& mask)
00182 : mask_(exact(mask))
00183 {
00184 }
00185
00186
00187 template <typename G, typename S, typename I>
00188 inline
00189 const I&
00190 graph_elt_window_if<G,S,I>::mask() const
00191 {
00192 return mask_;
00193 }
00194
00195
00196 template <typename G, typename S, typename I>
00197 inline
00198 void
00199 graph_elt_window_if<G,S,I>::change_mask(const Image<I>& mask)
00200 {
00201 mln_precondition(exact(mask).is_valid());
00202 mask_ = exact(mask);
00203 }
00204
00205 template <typename G, typename S, typename I>
00206 inline
00207 bool
00208 graph_elt_window_if<G,S,I>::is_valid() const
00209 {
00210 return mask_.is_valid();
00211 }
00212
00213
00214 # endif // ! MLN_INCLUDE_ONLY
00215
00216
00217 }
00218
00219
00220 #endif // ! MLN_CORE_IMAGE_GRAPH_ELT_WINDOW_IF_HH