$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
graph_elt_window_if.hh
1 // Copyright (C) 2009, 2011 EPITA Research and Development Laboratory
2 // (LRDE)
3 //
4 // This file is part of Olena.
5 //
6 // Olena is free software: you can redistribute it and/or modify it under
7 // the terms of the GNU General Public License as published by the Free
8 // Software Foundation, version 2 of the License.
9 //
10 // Olena is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // As a special exception, you may use this file as part of a free
19 // software project without restriction. Specifically, if other files
20 // instantiate templates or use macros or inline functions from this
21 // file, or you compile this file and link it with other files to produce
22 // an executable, this file does not by itself cause the resulting
23 // executable to be covered by the GNU General Public License. This
24 // exception does not however invalidate any other reasons why the
25 // executable file might be covered by the GNU General Public License.
26 
27 #ifndef MLN_CORE_IMAGE_GRAPH_ELT_WINDOW_IF_HH
28 # define MLN_CORE_IMAGE_GRAPH_ELT_WINDOW_IF_HH
29 
35 
36 # include <mln/core/concept/window.hh>
37 # include <mln/core/internal/neighborhood_base.hh>
38 # include <mln/core/internal/graph_window_base.hh>
39 # include <mln/core/internal/is_masked_impl_selector.hh>
40 # include <mln/core/image/graph_window_if_piter.hh>
41 
42 
43 namespace mln
44 {
45 
47  template <typename G, typename S, typename I> class graph_elt_window_if;
48  template <typename G, typename F> class p_edges;
49  template <typename G, typename F> class p_vertices;
50 
51 
52  namespace internal
53  {
54 
55  template <typename G, typename S, typename I, typename E>
57  : public neighborhood_extra_impl<graph_elt_window_if<G,S,I>,E>
58  {
59  };
60 
61 
64  template <typename G, typename S>
66 
67  template <typename G, typename F>
69  {
70  typedef mln_edge_nbh_edge_fwd_iter(G) nbh_fwd_iter_;
71  typedef mln_edge_nbh_edge_bkd_iter(G) nbh_bkd_iter_;
72  };
73 
74  template <typename G, typename F>
76  {
77  typedef mln_vertex_nbh_vertex_fwd_iter(G) nbh_fwd_iter_;
78  typedef mln_vertex_nbh_vertex_bkd_iter(G) nbh_bkd_iter_;
79  };
80 
81 
82  } // end of namespace mln::internal
83 
84 
85  namespace trait
86  {
87 
88  template <typename G, typename S, typename I>
89  struct window_< mln::graph_elt_window_if<G,S,I> >
90  {
91  typedef trait::window::size::unknown size;
92  typedef trait::window::support::irregular support;
93  typedef trait::window::definition::varying definition;
94  };
95 
96  } // end of namespace mln::trait
97 
98 
105  template <typename G, typename S, typename I>
107  : public graph_window_base<mln_result(S::fun_t),
108  graph_elt_window_if<G,S,I> >,
109  public internal::graph_window_if_iter_dispatch<G,S>,
110  private mlc_is(mln_value(I), bool)::check_t
111  {
113  typedef internal::graph_window_if_iter_dispatch<G,S> super_;
114 
115  typedef typename super_::nbh_fwd_iter_ nbh_fwd_iter_;
116  typedef typename super_::nbh_bkd_iter_ nbh_bkd_iter_;
117 
118  public:
120  typedef I mask_t;
121 
124 
127 
132 
134 
137 
139  typedef S target;
140 
142  typedef mln_psite(target) psite;
143 
146  typedef graph_window_if_piter<target,self_,nbh_fwd_iter_> fwd_qiter;
147 
150  typedef graph_window_if_piter<target,self_,nbh_bkd_iter_> bkd_qiter;
151 
153  typedef fwd_qiter qiter;
155 
157  const I& mask() const;
158 
160  void change_mask(const Image<I>& mask);
161 
163  bool is_valid() const;
164 
165  private:
166  // FIXME: Should be const!
167  I mask_;
168  };
169 
170 
171 
172 # ifndef MLN_INCLUDE_ONLY
173 
174 
175  template <typename G, typename S, typename I>
176  inline
178  {
179  }
180 
181 
182  template <typename G, typename S, typename I>
183  inline
185  : mask_(exact(mask))
186  {
187  }
188 
189 
190  template <typename G, typename S, typename I>
191  inline
192  const I&
194  {
195  return mask_;
196  }
197 
198 
199  template <typename G, typename S, typename I>
200  inline
201  void
202  graph_elt_window_if<G,S,I>::change_mask(const Image<I>& mask)
203  {
204  mln_precondition(exact(mask).is_valid());
205  mask_ = exact(mask);
206  }
207 
208  template <typename G, typename S, typename I>
209  inline
210  bool
212  {
213  return mask_.is_valid();
214  }
215 
216 
217 # endif // ! MLN_INCLUDE_ONLY
218 
219 
220 } // end of namespace mln
221 
222 
223 #endif // ! MLN_CORE_IMAGE_GRAPH_ELT_WINDOW_IF_HH