
* mln/topo/attic/complex_faces_iter.hh: Rename as... * mln/topo/static_n_face_iter.hh: ...this. (mln::topo::complex_faces_fwd_iter_<N, D>) (mln::topo::complex_faces_bkd_iter_<N, D>): Rename as... (static_n_face_fwd_iter) (static_n_face_bkd_iter): ...these. Adjust file layout. * mln/topo/complex.hh: Include mln/topo/static_n_face_iter.hh. * tests/topo/complex.cc (test_complex_faces_iter): Rename as... (test_static_n_face_iter): ...this. Adjust to static_n_face_fwd_iter and static_n_face_bkd_iter. (main): Exercise static_n_face_fwd_iter and static_n_face_bkd_iter. (test_faces_iter): Really disable this funcion. --- milena/ChangeLog | 21 +++++ milena/mln/topo/complex.hh | 2 +- ...complex_faces_iter.hh => static_n_face_iter.hh} | 86 ++++++++++---------- milena/tests/topo/complex.cc | 54 +++++++------ 4 files changed, 94 insertions(+), 69 deletions(-) rename milena/mln/topo/{attic/complex_faces_iter.hh => static_n_face_iter.hh} (72%) diff --git a/milena/ChangeLog b/milena/ChangeLog index d469c21..4d9412b 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,26 @@ 2008-09-26 Roland Levillain <roland@lrde.epita.fr> + Revive iterators on n-faces (with a statically known `n'). + + * mln/topo/attic/complex_faces_iter.hh: Rename as... + * mln/topo/static_n_face_iter.hh: ...this. + (mln::topo::complex_faces_fwd_iter_<N, D>) + (mln::topo::complex_faces_bkd_iter_<N, D>): + Rename as... + (static_n_face_fwd_iter) + (static_n_face_bkd_iter): + ...these. + Adjust file layout. + * mln/topo/complex.hh: Include mln/topo/static_n_face_iter.hh. + * tests/topo/complex.cc (test_complex_faces_iter): Rename as... + (test_static_n_face_iter): ...this. + Adjust to static_n_face_fwd_iter and static_n_face_bkd_iter. + (main): Exercise static_n_face_fwd_iter and + static_n_face_bkd_iter. + (test_faces_iter): Really disable this funcion. + +2008-09-26 Roland Levillain <roland@lrde.epita.fr> + Adjust paths of included files in the attic. * mln/core/site_set/attic/p_complex_faces_piter.hh, diff --git a/milena/mln/topo/complex.hh b/milena/mln/topo/complex.hh index e49f513..61ce84b 100644 --- a/milena/mln/topo/complex.hh +++ b/milena/mln/topo/complex.hh @@ -49,10 +49,10 @@ # include <mln/topo/n_faces_set.hh> # include <mln/topo/face_iter.hh> +# include <mln/topo/static_n_face_iter.hh> // FIXME: Disabled (moved to the attic). # if 0 # include <mln/topo/faces_iter.hh> -# include <mln/topo/complex_faces_iter.hh> # endif namespace mln diff --git a/milena/mln/topo/attic/complex_faces_iter.hh b/milena/mln/topo/static_n_face_iter.hh similarity index 72% rename from milena/mln/topo/attic/complex_faces_iter.hh rename to milena/mln/topo/static_n_face_iter.hh index c0d278c..2146310 100644 --- a/milena/mln/topo/attic/complex_faces_iter.hh +++ b/milena/mln/topo/static_n_face_iter.hh @@ -25,20 +25,16 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef MLN_TOPO_COMPLEX_FACES_ITER_HH -# define MLN_TOPO_COMPLEX_FACES_ITER_HH +#ifndef MLN_TOPO_STATIC_N_FACE_ITER_HH +# define MLN_TOPO_STATIC_N_FACE_ITER_HH -/// \file mln/topo/complex_faces_iter.hh -/// \brief Definition of forward and backward iterators on the n-faces -/// of a complex. +/// \file mln/topo/static_n_face_iter.hh +/// \brief Definition of forward and backward iterators on all the +/// \p N-faces of a complex, \p N being a static value. # include <mln/topo/internal/complex_iter_base.hh> # include <mln/topo/face.hh> -/* FIXME: Should we drop N from the signature of these iterators? - I.e., have N be dynamic? Or better: provide other iterators where - N is dynamic? */ - namespace mln { @@ -46,25 +42,26 @@ namespace mln namespace topo { - /*--------------------------------------. - | topo::complex_faces_fwd_iter_<N, D>. | - `--------------------------------------*/ + /*-------------------------------------. + | topo::static_n_face_fwd_iter<N, D>. | + `-------------------------------------*/ - /// \brief Forward iterator on all the faces of a mln::complex<D>. + /// \brief Forward iterator on all the \p N-faces of a + /// mln::complex<D>. /// /// \arg \p N The dimension of the face associated to this iterator. /// \arg \p D The dimension of the complex this iterator belongs to. template <unsigned N, unsigned D> - class complex_faces_fwd_iter_ + class static_n_face_fwd_iter : public internal::complex_iter_base< face<D>, - complex_faces_fwd_iter_<N, D> > + static_n_face_fwd_iter<N, D> > { public: /// Type of associated face. typedef face<D> face; private: - typedef complex_faces_fwd_iter_<N, D> self_; + typedef static_n_face_fwd_iter<N, D> self_; typedef internal::complex_iter_base< face, self_ > super_; public: @@ -74,9 +71,9 @@ namespace mln public: /// Construction and assignment. /// \{ - complex_faces_fwd_iter_(); + static_n_face_fwd_iter(); // FIXME: See comment in internal::complex_iter_base's default ctor - complex_faces_fwd_iter_(complex<D>& c); + static_n_face_fwd_iter(complex<D>& c); /// \} /// Manipulation. @@ -92,25 +89,26 @@ namespace mln }; - /*--------------------------------------. - | topo::complex_faces_bkd_iter_<N, D>. | - `--------------------------------------*/ + /*-------------------------------------. + | topo::static_n_face_bkd_iter<N, D>. | + `-------------------------------------*/ - /// \brief Backward iterator on all the faces of a mln::complex<D>. + /// \brief Backward iterator on all the \p N-faces of a + /// mln::complex<D>. /// /// \arg \p N The dimension of the face associated to this iterator. /// \arg \p D The dimension of the complex this iterator belongs to. template <unsigned N, unsigned D> - class complex_faces_bkd_iter_ + class static_n_face_bkd_iter : public internal::complex_iter_base< face<D>, - complex_faces_bkd_iter_<N, D> > + static_n_face_bkd_iter<N, D> > { public: /// Type of associated face. typedef face<D> face; private: - typedef complex_faces_bkd_iter_<N, D> self_; + typedef static_n_face_bkd_iter<N, D> self_; typedef internal::complex_iter_base< face, self_ > super_; public: @@ -120,9 +118,9 @@ namespace mln public: /// Construction and assignment. /// \{ - complex_faces_bkd_iter_(); + static_n_face_bkd_iter(); // FIXME: See comment in internal::complex_iter_base's default ctor - complex_faces_bkd_iter_(complex<D>& c); + static_n_face_bkd_iter(complex<D>& c); /// \} /// Manipulation. @@ -141,13 +139,13 @@ namespace mln # ifndef MLN_INCLUDE_ONLY - /*--------------------------------------. - | topo::complex_faces_fwd_iter_<N, D>. | - `--------------------------------------*/ + /*-------------------------------------. + | topo::static_n_face_fwd_iter<N, D>. | + `-------------------------------------*/ template <unsigned N, unsigned D> inline - complex_faces_fwd_iter_<N, D>::complex_faces_fwd_iter_() + static_n_face_fwd_iter<N, D>::static_n_face_fwd_iter() : super_() { // Ensure N is compatible with D. @@ -158,7 +156,7 @@ namespace mln template <unsigned N, unsigned D> inline - complex_faces_fwd_iter_<N, D>::complex_faces_fwd_iter_(complex<D>& c) + static_n_face_fwd_iter<N, D>::static_n_face_fwd_iter(complex<D>& c) : super_(c) { // Ensure N is compatible with D. @@ -170,7 +168,7 @@ namespace mln template <unsigned N, unsigned D> inline void - complex_faces_fwd_iter_<N, D>::start() + static_n_face_fwd_iter<N, D>::start() { face_.set_face_id(0u); } @@ -178,12 +176,14 @@ namespace mln template <unsigned N, unsigned D> inline void - complex_faces_fwd_iter_<N, D>::next_() + static_n_face_fwd_iter<N, D>::next_() { if (is_valid()) { unsigned face_id = face_.face_id(); - if (face_id + 1 < face_.cplx().template nfaces<N>()) + // The number of faces of dimension N in cplx_. + unsigned nn_faces = face_.cplx().template nfaces<N>(); + if (face_id + 1 < nn_faces) /* FIXME: Provide accessor face::face_id() returning a mutable reference? This way, we could just write @@ -200,13 +200,13 @@ namespace mln } - /*--------------------------------------. - | topo::complex_faces_bkd_iter_<N, D>. | - `--------------------------------------*/ + /*-------------------------------------. + | topo::static_n_face_bkd_iter<N, D>. | + `-------------------------------------*/ template <unsigned N, unsigned D> inline - complex_faces_bkd_iter_<N, D>::complex_faces_bkd_iter_() + static_n_face_bkd_iter<N, D>::static_n_face_bkd_iter() : super_() { // Ensure N is compatible with D. @@ -217,7 +217,7 @@ namespace mln template <unsigned N, unsigned D> inline - complex_faces_bkd_iter_<N, D>::complex_faces_bkd_iter_(complex<D>& c) + static_n_face_bkd_iter<N, D>::static_n_face_bkd_iter(complex<D>& c) : super_(c) { // Ensure N is compatible with D. @@ -229,7 +229,7 @@ namespace mln template <unsigned N, unsigned D> inline void - complex_faces_bkd_iter_<N, D>::start() + static_n_face_bkd_iter<N, D>::start() { face_.set_face_id(face_.cplx().template nfaces<N>() - 1); } @@ -237,7 +237,7 @@ namespace mln template <unsigned N, unsigned D> inline void - complex_faces_bkd_iter_<N, D>::next_() + static_n_face_bkd_iter<N, D>::next_() { if (is_valid()) { @@ -264,4 +264,4 @@ namespace mln } // end of namespace mln -#endif // ! MLN_TOPO_COMPLEX_FACES_ITER_HH +#endif // ! MLN_TOPO_STATIC_N_FACE_ITER_HH diff --git a/milena/tests/topo/complex.cc b/milena/tests/topo/complex.cc index 3319813..4d220e7 100644 --- a/milena/tests/topo/complex.cc +++ b/milena/tests/topo/complex.cc @@ -35,9 +35,14 @@ using namespace mln; -// Forward declaration. -template <unsigned N, unsigned D> void test_faces_iter(topo::complex<D>& c); -template <unsigned N, unsigned D> void test_complex_faces_iter(topo::complex<D>& c); +// Forward declarations. +template <unsigned N, unsigned D> +void test_static_n_face_iter(topo::complex<D>& c); +// FIXME: Disabled (moved to the attic). +#if 0 +template <unsigned N, unsigned D> +void test_faces_iter(topo::complex<D>& c); +#endif int main() @@ -143,6 +148,11 @@ int main() actual complex processing since they are not really flexible --- but I'm not sure. */ + // Static version. + test_static_n_face_iter<0>(c); + test_static_n_face_iter<1>(c); + test_static_n_face_iter<2>(c); + // FIXME: Disabled (moved to the attic). # if 0 /* Using faces_{fwd,bkd}_iter_<N, D>, which are proxies to @@ -150,12 +160,6 @@ int main() test_faces_iter<0>(c); test_faces_iter<1>(c); test_faces_iter<2>(c); - - /* Using complex_faces_{fwd,bkd}_iter_<N, D>, which are proxies to - faces<N>. */ - test_complex_faces_iter<0>(c); - test_complex_faces_iter<1>(c); - test_complex_faces_iter<2>(c); #endif /*------------------------------. @@ -293,6 +297,22 @@ int main() } +template <unsigned N, unsigned D> +void +test_static_n_face_iter(topo::complex<D>& c) +{ + std::cout << "test_static_n_face_iter<" << N << ", " << D << ">:" + << std::endl; + /* FIXME: Provide sugar. Maybe redefined mln_fwd_fiter and + mln_bkd_fiter so that they expand as complex_faces_iters (instead + of faces_iters). */ + topo::static_n_face_fwd_iter<N, D> fwd_ncf(c); + topo::static_n_face_bkd_iter<N, D> bkd_ncf(c); + for_all_2(fwd_ncf, bkd_ncf) + std::cout << fwd_ncf << ' ' << bkd_ncf << std::endl; + std::cout << std::endl; +} + // FIXME: Disabled (moved to the attic). # if 0 template <unsigned N, unsigned D> @@ -307,20 +327,4 @@ test_faces_iter(topo::complex<D>& c) std::cout << fwd_nf << ' ' << bkd_nf << std::endl; std::cout << std::endl; } - -template <unsigned N, unsigned D> -void -test_complex_faces_iter(topo::complex<D>& c) -{ - std::cout << "test_complex_faces_iter<" << N << ", " << D << ">:" - << std::endl; - /* FIXME: Provide sugar. Maybe redefined mln_fwd_fiter and - mln_bkd_fiter so that they expand as complex_faces_iters (instead - of faces_iters). */ - topo::complex_faces_fwd_iter_<N, D> fwd_ncf(c); - topo::complex_faces_bkd_iter_<N, D> bkd_ncf(c); - for_all_2(fwd_ncf, bkd_ncf) - std::cout << fwd_ncf << ' ' << bkd_ncf << std::endl; - std::cout << std::endl; -} #endif -- 1.6.0.1