$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
static_n_face_iter.hh
1 // Copyright (C) 2008, 2009, 2012 EPITA Research and Development
2 // Laboratory (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_TOPO_STATIC_N_FACE_ITER_HH
28 # define MLN_TOPO_STATIC_N_FACE_ITER_HH
29 
34 
35 # include <mln/topo/internal/complex_set_iterator_base.hh>
36 # include <mln/topo/face.hh>
37 
38 
39 namespace mln
40 {
41 
42  namespace topo
43  {
44 
45  /*-------------------------------------.
46  | topo::static_n_face_fwd_iter<N, D>. |
47  `-------------------------------------*/
48 
57  template <unsigned N, unsigned D>
59  : public internal::complex_set_iterator_base< topo::face<D>,
60  static_n_face_fwd_iter<N, D> >
61  {
62  // Tech note: we use topo::face to help g++-2.95.
63  private:
66 
67  public:
68  using super_::is_valid;
69  using super_::invalidate;
70 
71  public:
75  // FIXME: See comment in internal::complex_set_iterator_base's
76  // default ctor.
79 
83  void start();
85  void next_();
87 
88  private:
89  using super_::f_;
90  };
91 
92 
93  /*-------------------------------------.
94  | topo::static_n_face_bkd_iter<N, D>. |
95  `-------------------------------------*/
96 
105  template <unsigned N, unsigned D>
107  : public internal::complex_set_iterator_base< topo::face<D>,
108  static_n_face_bkd_iter<N, D> >
109  {
110  // Tech note: we use topo::face to help g++-2.95.
111  private:
114 
115  public:
116  using super_::is_valid;
117  using super_::invalidate;
118 
119  public:
123  // FIXME: See comment in internal::complex_set_iterator_base's
124  // default ctor.
127 
131  void start();
133  void next_();
135 
136  private:
137  using super_::f_;
138  };
139 
140 
141 
142 # ifndef MLN_INCLUDE_ONLY
143 
144  /*-------------------------------------.
145  | topo::static_n_face_fwd_iter<N, D>. |
146  `-------------------------------------*/
147 
148  template <unsigned N, unsigned D>
149  inline
151  : super_()
152  {
153  // Ensure N is compatible with D.
154  metal::bool_< N <= D >::check();
155  f_.set_n(N);
156  mln_postcondition(!is_valid());
157  }
158 
159  template <unsigned N, unsigned D>
160  inline
162  : super_(c)
163  {
164  // Ensure N is compatible with D.
165  metal::bool_< N <= D >::check();
166  f_.set_n(N);
167  mln_postcondition(!is_valid());
168  }
169 
170  template <unsigned N, unsigned D>
171  inline
172  void
174  {
175  f_.set_face_id(0u);
176  }
177 
178  template <unsigned N, unsigned D>
179  inline
180  void
182  {
183  if (is_valid())
184  {
185  if (f_.face_id() + 1 < f_.cplx().template nfaces_of_static_dim<N>())
186  f_.inc_face_id();
187  else
188  invalidate();
189  }
190  }
191 
192 
193  /*-------------------------------------.
194  | topo::static_n_face_bkd_iter<N, D>. |
195  `-------------------------------------*/
196 
197  template <unsigned N, unsigned D>
198  inline
200  : super_()
201  {
202  // Ensure N is compatible with D.
203  metal::bool_< N <= D >::check();
204  f_.set_n(N);
205  mln_postcondition(!is_valid());
206  }
207 
208  template <unsigned N, unsigned D>
209  inline
211  : super_(c)
212  {
213  // Ensure N is compatible with D.
214  metal::bool_< N <= D >::check();
215  f_.set_n(N);
216  mln_postcondition(!is_valid());
217  }
218 
219  template <unsigned N, unsigned D>
220  inline
221  void
223  {
224  f_.set_face_id(f_.cplx().template nfaces_of_static_dim<N>() - 1);
225  }
226 
227  template <unsigned N, unsigned D>
228  inline
229  void
231  {
232  if (is_valid())
233  {
234  if (f_.face_id() > 0)
235  f_.dec_face_id();
236  else
237  invalidate();
238  }
239  }
240 
241 # endif // ! MLN_INCLUDE_ONLY
242 
243  } // end of namespace mln::topo
244 
245 } // end of namespace mln
246 
247 #endif // ! MLN_TOPO_STATIC_N_FACE_ITER_HH