Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE) 00002 // 00003 // This file is part of Olena. 00004 // 00005 // Olena is free software: you can redistribute it and/or modify it under 00006 // the terms of the GNU General Public License as published by the Free 00007 // Software Foundation, version 2 of the License. 00008 // 00009 // Olena is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Olena. If not, see <http://www.gnu.org/licenses/>. 00016 // 00017 // As a special exception, you may use this file as part of a free 00018 // software project without restriction. Specifically, if other files 00019 // instantiate templates or use macros or inline functions from this 00020 // file, or you compile this file and link it with other files to produce 00021 // an executable, this file does not by itself cause the resulting 00022 // executable to be covered by the GNU General Public License. This 00023 // exception does not however invalidate any other reasons why the 00024 // executable file might be covered by the GNU General Public License. 00025 00026 #ifndef MLN_TOPO_ATTIC_FACES_ITER_HH 00027 # define MLN_TOPO_ATTIC_FACES_ITER_HH 00028 00032 00033 # include <mln/topo/internal/complex_set_iterator_base.hh> 00034 # include <mln/topo/n_face.hh> 00035 00036 namespace mln 00037 { 00038 00039 namespace topo 00040 { 00041 00042 /*------------------------------. 00043 | topo::faces_fwd_iter_<N, D>. | 00044 `------------------------------*/ 00045 00050 template <unsigned N, unsigned D> 00051 class faces_fwd_iter_ 00052 : public internal::complex_set_iterator_base< n_face<N, D>, 00053 faces_fwd_iter_<N, D> > 00054 { 00055 public: 00057 typedef n_face<N, D> face; 00058 00059 private: 00060 typedef faces_fwd_iter_<N, D> self_; 00061 typedef internal::complex_set_iterator_base< face, self_ > super_; 00062 00063 public: 00064 using super_::is_valid; 00065 using super_::invalidate; 00066 00067 public: 00070 faces_fwd_iter_(); 00071 // FIXME: See comment in internal::complex_set_iterator_base's 00072 // default ctor. 00073 faces_fwd_iter_(complex<D>& c); 00075 00079 void start(); 00081 void next_(); 00083 00084 private: 00085 using super_::face_; 00086 }; 00087 00088 00089 /*------------------------------. 00090 | topo::faces_bkd_iter_<N, D>. | 00091 `------------------------------*/ 00092 00097 template <unsigned N, unsigned D> 00098 class faces_bkd_iter_ 00099 : public internal::complex_set_iterator_base< n_face<N, D>, 00100 faces_bkd_iter_<N, D> > 00101 { 00102 public: 00104 typedef n_face<N, D> face; 00105 00106 private: 00107 typedef faces_bkd_iter_<N, D> self_; 00108 typedef internal::complex_set_iterator_base< face, self_ > super_; 00109 00110 public: 00111 using super_::is_valid; 00112 using super_::invalidate; 00113 00114 public: 00117 faces_bkd_iter_(); 00118 // FIXME: See comment in internal::complex_set_iterator_base's 00119 // default ctor. 00120 faces_bkd_iter_(complex<D>& c); 00122 00126 void start(); 00128 void next_(); 00130 00131 private: 00132 using super_::face_; 00133 }; 00134 00135 00136 00137 # ifndef MLN_INCLUDE_ONLY 00138 00139 /*------------------------------. 00140 | topo::faces_fwd_iter_<N, D>. | 00141 `------------------------------*/ 00142 00143 template <unsigned N, unsigned D> 00144 inline 00145 faces_fwd_iter_<N, D>::faces_fwd_iter_() 00146 : super_() 00147 { 00148 // Ensure N is compatible with D. 00149 metal::bool_< N <= D >::check(); 00150 mln_postcondition(!is_valid()); 00151 } 00152 00153 template <unsigned N, unsigned D> 00154 inline 00155 faces_fwd_iter_<N, D>::faces_fwd_iter_(complex<D>& c) 00156 : super_(c) 00157 { 00158 // Ensure N is compatible with D. 00159 metal::bool_< N <= D >::check(); 00160 mln_postcondition(!is_valid()); 00161 } 00162 00163 template <unsigned N, unsigned D> 00164 inline 00165 void 00166 faces_fwd_iter_<N, D>::start() 00167 { 00168 face_.set_face_id(0u); 00169 } 00170 00171 template <unsigned N, unsigned D> 00172 inline 00173 void 00174 faces_fwd_iter_<N, D>::next_() 00175 { 00176 if (is_valid()) 00177 { 00178 unsigned face_id = face_.face_id(); 00179 if (face_id + 1 < face_.cplx().template nfaces_of_static_dim<N>()) 00180 /* FIXME: Provide accessor n_face::n() returning 00181 a mutable reference? This way, we could just write 00182 00183 ++face_.face_id(); 00184 00185 instead of the following. */ 00186 face_.set_face_id(face_id + 1); 00187 else 00188 invalidate(); 00189 } 00190 } 00191 00192 00193 /*------------------------------. 00194 | topo::faces_bkd_iter_<N, D>. | 00195 `------------------------------*/ 00196 00197 template <unsigned N, unsigned D> 00198 inline 00199 faces_bkd_iter_<N, D>::faces_bkd_iter_() 00200 : super_() 00201 { 00202 // Ensure N is compatible with D. 00203 metal::bool_< N <= D >::check(); 00204 mln_postcondition(!is_valid()); 00205 } 00206 00207 template <unsigned N, unsigned D> 00208 inline 00209 faces_bkd_iter_<N, D>::faces_bkd_iter_(complex<D>& c) 00210 : super_(c) 00211 { 00212 // Ensure N is compatible with D. 00213 metal::bool_< N <= D >::check(); 00214 mln_postcondition(!is_valid()); 00215 } 00216 00217 template <unsigned N, unsigned D> 00218 inline 00219 void 00220 faces_bkd_iter_<N, D>::start() 00221 { 00222 face_.set_face_id(face_.cplx().template nfaces_of_static_dim<N>() - 1); 00223 } 00224 00225 template <unsigned N, unsigned D> 00226 inline 00227 void 00228 faces_bkd_iter_<N, D>::next_() 00229 { 00230 if (is_valid()) 00231 { 00232 unsigned face_id = face_.face_id(); 00233 if (face_id > 0) 00234 /* FIXME: Provide accessor n_face::n() returning 00235 a mutable reference? This way, we could just write 00236 00237 ++face_.face_id(); 00238 00239 instead of the following. */ 00240 face_.set_face_id(face_id - 1); 00241 else 00242 invalidate(); 00243 } 00244 } 00245 00246 # endif // ! MLN_INCLUDE_ONLY 00247 00248 } // end of namespace mln::topo 00249 00250 } // end of namespace mln 00251 00252 #endif // ! MLN_TOPO_ATTIC_FACES_ITER_HH