2444: Add iterators on lower- and higher-dimension adjacent faces.

* mln/topo/internal/complex_relative_iterator_base.hh: New file. * mln/topo/adj_lower_face_iter.hh, * mln/topo/adj_higher_face_iter.hh: New files. Include them... * mln/topo/complex.hh: ...here. * tests/topo/complex.cc (main): Exercise these iterators. --- milena/ChangeLog | 13 + milena/mln/topo/adj_higher_face_iter.hh | 185 +++++++++ milena/mln/topo/adj_lower_face_iter.hh | 185 +++++++++ milena/mln/topo/complex.hh | 4 + .../internal/complex_relative_iterator_base.hh | 436 ++++++++++++++++++++ milena/tests/topo/complex.cc | 49 ++- 6 files changed, 852 insertions(+), 20 deletions(-) create mode 100644 milena/mln/topo/adj_higher_face_iter.hh create mode 100644 milena/mln/topo/adj_lower_face_iter.hh create mode 100644 milena/mln/topo/internal/complex_relative_iterator_base.hh diff --git a/milena/ChangeLog b/milena/ChangeLog index 0f28467..040d817 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,18 @@ 2008-09-30 Roland Levillain <roland@lrde.epita.fr> + Add iterators on lower- and higher-dimension adjacent faces. + + * mln/topo/internal/complex_relative_iterator_base.hh: + New file. + * mln/topo/adj_lower_face_iter.hh, + * mln/topo/adj_higher_face_iter.hh: + New files. + Include them... + * mln/topo/complex.hh: ...here. + * tests/topo/complex.cc (main): Exercise these iterators. + +2008-09-30 Roland Levillain <roland@lrde.epita.fr> + Print the address of complexes with their face handles. * mln/topo/face.hh (operator<<(std::ostream&, const face<D>&)) diff --git a/milena/mln/topo/adj_higher_face_iter.hh b/milena/mln/topo/adj_higher_face_iter.hh new file mode 100644 index 0000000..5301c05 --- /dev/null +++ b/milena/mln/topo/adj_higher_face_iter.hh @@ -0,0 +1,185 @@ +// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef MLN_TOPO_ADJ_HIGHER_FACE_ITER_HH +# define MLN_TOPO_ADJ_HIGHER_FACE_ITER_HH + +/// \file mln/topo/adj_higher_face_iter.hh +/// \brief Definition of forward and backward iterators on the +/// adjacent (n+1)-faces of a (reference) n-face in a complex. + +# include <mln/topo/internal/complex_relative_iterator_base.hh> +# include <mln/topo/face.hh> + + +namespace mln +{ + + namespace topo + { + + // Forward declaration. + template <unsigned D> class complex; + + + /*------------------------------------. + | topo::adj_higher_face_fwd_iter<D>. | + `------------------------------------*/ + + /// \brief Forward iterator on all the faces of an mln::complex<D>. + /// + /// \arg \p D The dimension of the complex this iterator belongs to. + template <unsigned D> + class adj_higher_face_fwd_iter + : public internal::forward_complex_relative_iterator_base< face<D>, + adj_higher_face_fwd_iter<D> > + { + private: + typedef adj_higher_face_fwd_iter<D> self_; + typedef internal::forward_complex_relative_iterator_base< face<D>, + self_ > super_; + + public: + using super_::is_valid; + using super_::invalidate; + + public: + /// Construction and assignment. + /// \{ + adj_higher_face_fwd_iter(); + template <typename Fref> + adj_higher_face_fwd_iter(const Fref& f_ref); + /// \} + + /// Compute the set of faces adjacent to the reference face. + void update_adj_faces_(); + }; + + + /*------------------------------------. + | topo::adj_higher_face_bkd_iter<D>. | + `------------------------------------*/ + + /// \brief Backward iterator on all the faces of an mln::complex<D>. + /// + /// \arg \p D The dimension of the complex this iterator belongs to. + template <unsigned D> + class adj_higher_face_bkd_iter + : public internal::backward_complex_relative_iterator_base< face<D>, + adj_higher_face_bkd_iter<D> > + { + private: + typedef adj_higher_face_bkd_iter<D> self_; + typedef internal::backward_complex_relative_iterator_base< face<D>, + self_ > super_; + + public: + using super_::is_valid; + using super_::invalidate; + + public: + /// Construction and assignment. + /// \{ + adj_higher_face_bkd_iter(); + template <typename Fref> + adj_higher_face_bkd_iter(const Fref& f_ref); + /// \} + + /// Compute the set of faces adjacent to the reference face. + void update_adj_faces_(); + }; + + + +# ifndef MLN_INCLUDE_ONLY + + /*------------------------------------. + | topo::adj_higher_face_fwd_iter<D>. | + `------------------------------------*/ + + template <unsigned D> + inline + adj_higher_face_fwd_iter<D>::adj_higher_face_fwd_iter() + { + } + + template <unsigned D> + template <typename Fref> + inline + adj_higher_face_fwd_iter<D>::adj_higher_face_fwd_iter(const Fref& f_ref) + { + center_at(f_ref); + // FIXME: Move this to the super class? + invalidate(); + } + + template <unsigned D> + inline + void + adj_higher_face_fwd_iter<D>::update_adj_faces_() + { + mln_precondition(this->c_); + this->adj_faces_ = this->c_->higher_dim_adj_faces(); + } + + + /*------------------------------------. + | topo::adj_higher_face_bkd_iter<D>. | + `------------------------------------*/ + + template <unsigned D> + inline + adj_higher_face_bkd_iter<D>::adj_higher_face_bkd_iter() + { + } + + template <unsigned D> + template <typename Fref> + inline + adj_higher_face_bkd_iter<D>::adj_higher_face_bkd_iter(const Fref& f_ref) + { + center_at(f_ref); + // FIXME: Move this to the super class? + invalidate(); + } + + template <unsigned D> + inline + void + adj_higher_face_bkd_iter<D>::update_adj_faces_() + { + mln_precondition(this->c_); + this->adj_faces_ = this->c_->higher_dim_adj_faces(); + } + +# endif // ! MLN_INCLUDE_ONLY + + } // end of namespace mln::topo + +} // end of namespace mln + +#endif // ! MLN_TOPO_ADJ_HIGHER_FACE_ITER_HH diff --git a/milena/mln/topo/adj_lower_face_iter.hh b/milena/mln/topo/adj_lower_face_iter.hh new file mode 100644 index 0000000..498357b --- /dev/null +++ b/milena/mln/topo/adj_lower_face_iter.hh @@ -0,0 +1,185 @@ +// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef MLN_TOPO_ADJ_LOWER_FACE_ITER_HH +# define MLN_TOPO_ADJ_LOWER_FACE_ITER_HH + +/// \file mln/topo/adj_lower_face_iter.hh +/// \brief Definition of forward and backward iterators on the +/// adjacent (n-1)-faces of a (reference) n-face in a complex. + +# include <mln/topo/internal/complex_relative_iterator_base.hh> +# include <mln/topo/face.hh> + + +namespace mln +{ + + namespace topo + { + + // Forward declaration. + template <unsigned D> class complex; + + + /*-----------------------------------. + | topo::adj_lower_face_fwd_iter<D>. | + `-----------------------------------*/ + + /// \brief Forward iterator on all the faces of an mln::complex<D>. + /// + /// \arg \p D The dimension of the complex this iterator belongs to. + template <unsigned D> + class adj_lower_face_fwd_iter + : public internal::forward_complex_relative_iterator_base< face<D>, + adj_lower_face_fwd_iter<D> > + { + private: + typedef adj_lower_face_fwd_iter<D> self_; + typedef internal::forward_complex_relative_iterator_base< face<D>, + self_ > super_; + + public: + using super_::is_valid; + using super_::invalidate; + + public: + /// Construction and assignment. + /// \{ + adj_lower_face_fwd_iter(); + template <typename Fref> + adj_lower_face_fwd_iter(const Fref& f_ref); + /// \} + + /// Compute the set of faces adjacent to the reference face. + void update_adj_faces_(); + }; + + + /*-----------------------------------. + | topo::adj_lower_face_bkd_iter<D>. | + `-----------------------------------*/ + + /// \brief Backward iterator on all the faces of an mln::complex<D>. + /// + /// \arg \p D The dimension of the complex this iterator belongs to. + template <unsigned D> + class adj_lower_face_bkd_iter + : public internal::backward_complex_relative_iterator_base< face<D>, + adj_lower_face_bkd_iter<D> > + { + private: + typedef adj_lower_face_bkd_iter<D> self_; + typedef internal::backward_complex_relative_iterator_base< face<D>, + self_ > super_; + + public: + using super_::is_valid; + using super_::invalidate; + + public: + /// Construction and assignment. + /// \{ + adj_lower_face_bkd_iter(); + template <typename Fref> + adj_lower_face_bkd_iter(const Fref& f_ref); + /// \} + + /// Compute the set of faces adjacent to the reference face. + void update_adj_faces_(); + }; + + + +# ifndef MLN_INCLUDE_ONLY + + /*-----------------------------------. + | topo::adj_lower_face_fwd_iter<D>. | + `-----------------------------------*/ + + template <unsigned D> + inline + adj_lower_face_fwd_iter<D>::adj_lower_face_fwd_iter() + { + } + + template <unsigned D> + template <typename Fref> + inline + adj_lower_face_fwd_iter<D>::adj_lower_face_fwd_iter(const Fref& f_ref) + { + center_at(f_ref); + // FIXME: Move this to the super class? + invalidate(); + } + + template <unsigned D> + inline + void + adj_lower_face_fwd_iter<D>::update_adj_faces_() + { + mln_precondition(this->c_); + this->adj_faces_ = this->c_->lower_dim_adj_faces(); + } + + + /*-----------------------------------. + | topo::adj_lower_face_bkd_iter<D>. | + `-----------------------------------*/ + + template <unsigned D> + inline + adj_lower_face_bkd_iter<D>::adj_lower_face_bkd_iter() + { + } + + template <unsigned D> + template <typename Fref> + inline + adj_lower_face_bkd_iter<D>::adj_lower_face_bkd_iter(const Fref& f_ref) + { + center_at(f_ref); + // FIXME: Move this to the super class? + invalidate(); + } + + template <unsigned D> + inline + void + adj_lower_face_bkd_iter<D>::update_adj_faces_() + { + mln_precondition(this->c_); + this->adj_faces_ = this->c_->lower_dim_adj_faces(); + } + +# endif // ! MLN_INCLUDE_ONLY + + } // end of namespace mln::topo + +} // end of namespace mln + +#endif // ! MLN_TOPO_ADJ_LOWER_FACE_ITER_HH diff --git a/milena/mln/topo/complex.hh b/milena/mln/topo/complex.hh index 643285c..c053879 100644 --- a/milena/mln/topo/complex.hh +++ b/milena/mln/topo/complex.hh @@ -56,6 +56,10 @@ # include <mln/topo/faces_iter.hh> # endif +# include <mln/topo/adj_lower_face_iter.hh> +# include <mln/topo/adj_higher_face_iter.hh> + + namespace mln { diff --git a/milena/mln/topo/internal/complex_relative_iterator_base.hh b/milena/mln/topo/internal/complex_relative_iterator_base.hh new file mode 100644 index 0000000..599727a --- /dev/null +++ b/milena/mln/topo/internal/complex_relative_iterator_base.hh @@ -0,0 +1,436 @@ +// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef MLN_TOPO_INTERNAL_COMPLEX_RELATIVE_ITERATOR_BASE_HH +# define MLN_TOPO_INTERNAL_COMPLEX_RELATIVE_ITERATOR_BASE_HH + +/** \file mln/topo/internal/complex_relative_iterator_base.hh + \brief Definition of an implementation (factoring) class for + iterators on mln::complex. + + The hierarchy of classes in this file is as follows + + \verbatim + + complex_relative_iterator_base<F, E> + ^ + | + ,--------------+--------------. + | | + forward_complex_relative_iterator_base<F, E> | + | + backward_complex_relative_iterator_base<F, E> + + \endverbatim +*/ + +# include <limits> + +# include <mln/metal/equal.hh> + +# include <mln/core/concept/iterator.hh> +# include <mln/topo/complex.hh> + +/* FIXME: By moving iterator `i_' into + internal::complex_relative_iterator_base, we'll be able to factor + more methods (do_next_, update_f); this requires the type of this + iterator be passed as an extra parameter to + internal::complex_relative_iterator_base. */ + + +namespace mln +{ + + namespace topo + { + + namespace internal + { + + /*-------------------------------------------------------. + | topo::internal::complex_relative_iterator_base<F, E>. | + `-------------------------------------------------------*/ + + /// \brief Factoring class for relative iterators on mln::complex. + /// + /// \arg \p F The type of the face handle. + /// \arg \p E The type exact type of the iterator. + template <typename F, typename E> + class complex_relative_iterator_base : public Iterator<E> + { + typedef complex_relative_iterator_base<F, E> self_; + + public: + typedef F face; + // FIXME: Maybe we could just get the dimension D of the face's + // complex, an define complex_type as mln::complex<D>? + typedef typename F::complex_type complex_type; + + /// Construction and assignment. + /// \{ + /* FIXME: Keep this non-const? See a (big) comment about this in + milena/tests/complex_image.cc. */ + complex_relative_iterator_base(); + /// \} + + /// Manipulation. + /// \{ + /// Change the center face. + void center_at(const F& c); + + /// Start an iteration. + void start(); + /// Go to the next point. + void next_(); + /// \} + + /// Conversion and accessors. + /// \{ + /// Reference to the corresponding face handle. + const face& to_face () const; + /// Convert the iterator into an face handle. + operator face() const; + /// \} + + protected: + /// A pointer to the center face around which this iterator + /// moves. + const face* c_; + + // The type of the set of vicinity sites (adjacent face handles). + typedef std::vector<face> adj_faces_t; + /// The set of faces adjacent to the reference face. + adj_faces_t adj_faces_; + + /// The face handle this iterator is pointing to. + face f_; + }; + + + /* FIXME: This hand-made delegation is painful. We should rely on + the general mechanism provided by Point_Site. But then again, we + need to refine/adjust the interface of Point_Site w.r.t. the + mandatory conversions to points. */ + template <typename F, typename E> + inline + std::ostream& + operator<<(std::ostream& ostr, const complex_relative_iterator_base<F, E>& p); + + + /*---------------------------------------------------------------. + | topo::internal::forward_complex_relative_iterator_base<F, E>. | + `---------------------------------------------------------------*/ + + /// \brief Factoring class for forward relative iterators on + /// mln::complex. + /// + /// \arg \p F The type of the face handle. + /// \arg \p E The type exact type of the iterator. + template <typename F, typename E> + class forward_complex_relative_iterator_base + : public complex_relative_iterator_base<F, E> + { + typedef forward_complex_relative_iterator_base<F, E> self_; + typedef complex_relative_iterator_base<F, E> super_; + + public: + typedef F face; + // FIXME: Maybe we could just get the dimension D of the face's + // complex, an define complex_type as mln::complex<D>? + typedef typename F::complex_type complex_type; + + public: + /// Construction and assignment. + /// \{ + /* FIXME: Keep this non-const? See a (big) comment about this in + milena/tests/complex_image.cc. */ + forward_complex_relative_iterator_base(); + /// \} + + public: + /// Manipulation + /// \{ + /// Test if the iterator is valid. + bool is_valid() const; + /// Invalidate the iterator. + void invalidate(); + + /// Start an iteration. + void do_start_(); + /// Go to the next point. + void do_next_(); + + /// Update the target face. + void update_f_(); + /// \} + + protected: + /// An iterator on the set of adjacent edges. + typename super_::adj_faces_t::const_iterator i_; + }; + + + /*----------------------------------------------------------------. + | topo::internal::backward_complex_relative_iterator_base<F, E>. | + `----------------------------------------------------------------*/ + + /// \brief Factoring class for backward relative iterators on + /// mln::complex. + /// + /// \arg \p F The type of the face handle. + /// \arg \p E The type exact type of the iterator. + template <typename F, typename E> + class backward_complex_relative_iterator_base + : public complex_relative_iterator_base<F, E> + { + typedef backward_complex_relative_iterator_base<F, E> self_; + typedef complex_relative_iterator_base<F, E> super_; + + public: + typedef F face; + // FIXME: Maybe we could just get the dimension D of the face's + // complex, an define complex_type as mln::complex<D>? + typedef typename F::complex_type complex_type; + + public: + /// Construction and assignment. + /// \{ + /* FIXME: Keep this non-const? See a (big) comment about this in + milena/tests/complex_image.cc. */ + backward_complex_relative_iterator_base(); + /// \} + + public: + /// Manipulation + /// \{ + /// Test if the iterator is valid. + bool is_valid() const; + /// Invalidate the iterator. + void invalidate(); + + /// Start an iteration. + void do_start_(); + /// Go to the next point. + void do_next_(); + + /// Update the target face. + void update_f_(); + /// \} + + protected: + /// An iterator on the set of adjacent edges. + typename super_::adj_faces_t::const_reverse_iterator i_; + }; + + + +# ifndef MLN_INCLUDE_ONLY + + /*-------------------------------------------------------. + | topo::internal::complex_relative_iterator_base<F, E>. | + `-------------------------------------------------------*/ + + template <typename F, typename E> + inline + complex_relative_iterator_base<F, E>::complex_relative_iterator_base() + : c_(0) + { + // Ensure F and E are compatible. + mlc_equal(F, typename E::face)::check(); + // Check for required methods in E. + void (E::*m)() = & E::update_adj_faces_; + m = 0; + } + + template <typename F, typename E> + inline + void + complex_relative_iterator_base<F, E>::center_at(const F& c) + { + c_ = &c; + exact(this)->invalidate(); + } + + template <typename F, typename E> + inline + void + complex_relative_iterator_base<F, E>::start() + { + exact(this)->do_start_(); + if (exact(this)->is_valid()) + exact(this)->update_f_(); + } + + template <typename F, typename E> + inline + void + complex_relative_iterator_base<F, E>::next_() + { + exact(this)->do_next_(); + if (exact(this)->is_valid()) + exact(this)->update_f_(); + } + + template <typename F, typename E> + inline + const F& + complex_relative_iterator_base<F, E>::to_face() const + { + return f_; + } + + template <typename F, typename E> + inline + complex_relative_iterator_base<F, E>::operator F() const + { + mln_precondition(exact(this)->is_valid()); + return f_; + } + + + template <typename F, typename E> + inline + std::ostream& + operator<<(std::ostream& ostr, + const complex_relative_iterator_base<F, E>& p) + { + return ostr << F(p); + } + + + /*---------------------------------------------------------------. + | topo::internal::forward_complex_relative_iterator_base<F, E>. | + `---------------------------------------------------------------*/ + + template <typename F, typename E> + inline + forward_complex_relative_iterator_base<F, E>::forward_complex_relative_iterator_base() + { + } + + template <typename F, typename E> + inline + bool + forward_complex_relative_iterator_base<F, E>::is_valid() const + { + return i_ != this->adj_faces_.end(); + } + + template <typename F, typename E> + inline + void + forward_complex_relative_iterator_base<F, E>::invalidate() + { + i_ = this->adj_faces_.end(); + } + + template <typename F, typename E> + inline + void + forward_complex_relative_iterator_base<F, E>::do_start_() + { + exact(this)->update_adj_faces_(); + i_ = this->adj_faces_.begin(); + } + + template <typename F, typename E> + inline + void + forward_complex_relative_iterator_base<F, E>::do_next_() + { + ++i_; + } + + template <typename F, typename E> + inline + void + forward_complex_relative_iterator_base<F, E>::update_f_() + { + this->f_ = *i_; + } + + + /*----------------------------------------------------------------. + | topo::internal::backward_complex_relative_iterator_base<F, E>. | + `----------------------------------------------------------------*/ + + template <typename F, typename E> + inline + backward_complex_relative_iterator_base<F, E>::backward_complex_relative_iterator_base() + { + } + + template <typename F, typename E> + inline + bool + backward_complex_relative_iterator_base<F, E>::is_valid() const + { + return i_ != this->adj_faces_.rend(); + } + + template <typename F, typename E> + inline + void + backward_complex_relative_iterator_base<F, E>::invalidate() + { + i_ = this->adj_faces_.rend(); + } + + template <typename F, typename E> + inline + void + backward_complex_relative_iterator_base<F, E>::do_start_() + { + exact(this)->update_adj_faces_(); + i_ = this->adj_faces_.rbegin(); + } + + template <typename F, typename E> + inline + void + backward_complex_relative_iterator_base<F, E>::do_next_() + { + ++i_; + } + + template <typename F, typename E> + inline + void + backward_complex_relative_iterator_base<F, E>::update_f_() + { + this->f_ = *i_; + } + +# endif // ! MLN_INCLUDE_ONLY + + } // end of namespace mln::topo::internal + + } // end of namespace mln::topo + +} // end of namespace mln + +#endif // ! MLN_TOPO_INTERNAL_COMPLEX_RELATIVE_ITERATOR_BASE_HH diff --git a/milena/tests/topo/complex.cc b/milena/tests/topo/complex.cc index 349921c..f079734 100644 --- a/milena/tests/topo/complex.cc +++ b/milena/tests/topo/complex.cc @@ -207,7 +207,8 @@ int main() milena/tests/core/complex_image.cc) and ticket #162 (https://trac.lrde.org/olena/ticket/162) */ - /* Iterate on the the set of (n-1)-faces adjacent to AF. + /* Iterate on the the set of (n-1)- and (n+1)-faces adjacent to the + faces of C. Note: this can be solved with iterators where the dimension can be either static or dynamic. @@ -224,13 +225,31 @@ int main() (Note: we might want to get rid of the name `citer', and use `fiter' everywhere.). - A static version might be useful (and more efficient) too. + A static version might be useful (and more efficient) too. */ + + topo::adj_lower_face_fwd_iter<D> fwd_alf(fwd_f); + topo::adj_lower_face_bkd_iter<D> bkd_alf(fwd_f); + for_all(fwd_f) + { + std::cout << "Lower-dimension faces adjacent to " << fwd_f << ": " + << std::endl; + for_all_2(fwd_alf, bkd_alf) + std::cout << " " << fwd_alf << '\t' << bkd_alf << std::endl; + } + std::cout << std::endl; - Likewise, our iterators on n-faces (both faces_piter and - complex_faces_piter) use a static `n'. We should also have - n-faces iterators where n could be dynamic. + topo::adj_higher_face_fwd_iter<D> fwd_ahf(fwd_f); + topo::adj_higher_face_bkd_iter<D> bkd_ahf(fwd_f); + for_all(fwd_f) + { + std::cout << "Higher-dimension faces adjacent to " << fwd_f << ": " + << std::endl; + for_all_2(fwd_ahf, bkd_ahf) + std::cout << " " << fwd_ahf << '\t' << bkd_ahf << std::endl; + } + std::cout << std::endl; - But first, we need to clarify (existing) names. The one listed + /* But first, we need to clarify (existing) names. The one listed in https://trac.lrde.org/olena/wiki/Olena/ComplexBasedImages are OK. @@ -239,26 +258,16 @@ int main() ----------------------------------------------------------------- Name Definition ----------------------------------------------------------------- - adj_lower_faces_fwd_iter<D>(c, f) | Iterators on the adjacent - adj_lower_faces_bkd_iter<D>(c, f) | (lower) (n-1)-faces of the - | n-face f of the complex c, - | n being dynamic - - adj_higher_faces_fwd_iter<D>(c, f) | Iterators on the adjacent - adj_higher_faces_bkd_iter<D>(c, f) | (higher) (n+1)-faces of the - | n-face f of the complex c, - | n being dynamic - - adj_lower_dim_connected_n_faces_fwd_iter<D>(c, f) - adj_lower_dim_connected_n_faces_bkd_iter<D>(c, f) + adj_lower_dim_connected_n_face_fwd_iter<D>(c, f) + adj_lower_dim_connected_n_face_bkd_iter<D>(c, f) (FIXME: These names are admittedly too long.) | Iterators on the the set of | n-faces sharing an adjacent | (n-1)-face with f, n being | dynamic - adj_higher_dim_connected_n_faces_fwd_iter<D>(c, f) - adj_higher_dim_connected_n_faces_bkd_iter<D>(c, f) + adj_higher_dim_connected_n_face_fwd_iter<D>(c, f) + adj_higher_dim_connected_n_face_bkd_iter<D>(c, f) (FIXME: These names are admittedly too long.) | Iterators on the the set of | n-faces sharing an adjacent -- 1.6.0.1
participants (1)
-
Roland Levillain