$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
faces_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_ATTIC_FACES_ITER_HH
28 # define MLN_TOPO_ATTIC_FACES_ITER_HH
29 
33 
34 # include <mln/topo/internal/complex_set_iterator_base.hh>
35 # include <mln/topo/n_face.hh>
36 
37 namespace mln
38 {
39 
40  namespace topo
41  {
42 
43  /*------------------------------.
44  | topo::faces_fwd_iter_<N, D>. |
45  `------------------------------*/
46 
54  template <unsigned N, unsigned D>
56  : public internal::complex_set_iterator_base< n_face<N, D>,
57  faces_fwd_iter_<N, D> >
58  {
59  public:
61  typedef n_face<N, D> face;
62 
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_::face_;
90  };
91 
92 
93  /*------------------------------.
94  | topo::faces_bkd_iter_<N, D>. |
95  `------------------------------*/
96 
104  template <unsigned N, unsigned D>
106  : public internal::complex_set_iterator_base< n_face<N, D>,
107  faces_bkd_iter_<N, D> >
108  {
109  public:
112 
113  private:
116 
117  public:
118  using super_::is_valid;
119  using super_::invalidate;
120 
121  public:
124  faces_bkd_iter_();
125  // FIXME: See comment in internal::complex_set_iterator_base's
126  // default ctor.
129 
133  void start();
135  void next_();
137 
138  private:
139  using super_::face_;
140  };
141 
142 
143 
144 # ifndef MLN_INCLUDE_ONLY
145 
146  /*------------------------------.
147  | topo::faces_fwd_iter_<N, D>. |
148  `------------------------------*/
149 
150  template <unsigned N, unsigned D>
151  inline
153  : super_()
154  {
155  // Ensure N is compatible with D.
156  metal::bool_< N <= D >::check();
157  mln_postcondition(!is_valid());
158  }
159 
160  template <unsigned N, unsigned D>
161  inline
163  : super_(c)
164  {
165  // Ensure N is compatible with D.
166  metal::bool_< N <= D >::check();
167  mln_postcondition(!is_valid());
168  }
169 
170  template <unsigned N, unsigned D>
171  inline
172  void
174  {
175  face_.set_face_id(0u);
176  }
177 
178  template <unsigned N, unsigned D>
179  inline
180  void
182  {
183  if (is_valid())
184  {
185  unsigned face_id = face_.face_id();
186  if (face_id + 1 < face_.cplx().template nfaces_of_static_dim<N>())
187  /* FIXME: Provide accessor n_face::n() returning
188  a mutable reference? This way, we could just write
189 
190  ++face_.face_id();
191 
192  instead of the following. */
193  face_.set_face_id(face_id + 1);
194  else
195  invalidate();
196  }
197  }
198 
199 
200  /*------------------------------.
201  | topo::faces_bkd_iter_<N, D>. |
202  `------------------------------*/
203 
204  template <unsigned N, unsigned D>
205  inline
207  : super_()
208  {
209  // Ensure N is compatible with D.
210  metal::bool_< N <= D >::check();
211  mln_postcondition(!is_valid());
212  }
213 
214  template <unsigned N, unsigned D>
215  inline
217  : super_(c)
218  {
219  // Ensure N is compatible with D.
220  metal::bool_< N <= D >::check();
221  mln_postcondition(!is_valid());
222  }
223 
224  template <unsigned N, unsigned D>
225  inline
226  void
228  {
229  face_.set_face_id(face_.cplx().template nfaces_of_static_dim<N>() - 1);
230  }
231 
232  template <unsigned N, unsigned D>
233  inline
234  void
236  {
237  if (is_valid())
238  {
239  unsigned face_id = face_.face_id();
240  if (face_id > 0)
241  /* FIXME: Provide accessor n_face::n() returning
242  a mutable reference? This way, we could just write
243 
244  ++face_.face_id();
245 
246  instead of the following. */
247  face_.set_face_id(face_id - 1);
248  else
249  invalidate();
250  }
251  }
252 
253 # endif // ! MLN_INCLUDE_ONLY
254 
255  } // end of namespace mln::topo
256 
257 } // end of namespace mln
258 
259 #endif // ! MLN_TOPO_ATTIC_FACES_ITER_HH