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_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 
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       
00072       
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 
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       
00119       
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 
00141 
00142 
00143     template <unsigned N, unsigned D>
00144     inline
00145     faces_fwd_iter_<N, D>::faces_fwd_iter_()
00146       : super_()
00147     {
00148       
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       
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             
00181 
00182 
00183 
00184 
00185 
00186             face_.set_face_id(face_id + 1);
00187           else
00188             invalidate();
00189         }
00190     }
00191 
00192 
00193     
00194 
00195 
00196 
00197     template <unsigned N, unsigned D>
00198     inline
00199     faces_bkd_iter_<N, D>::faces_bkd_iter_()
00200       : super_()
00201     {
00202       
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       
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             
00235 
00236 
00237 
00238 
00239 
00240             face_.set_face_id(face_id - 1);
00241           else
00242             invalidate();
00243         }
00244     }
00245 
00246 # endif // ! MLN_INCLUDE_ONLY
00247 
00248   } 
00249 
00250 } 
00251 
00252 #endif // ! MLN_TOPO_ATTIC_FACES_ITER_HH