* tests/core/image/complex_image.cc: Here.
---
milena/ChangeLog | 6 ++++
milena/tests/core/image/complex_image.cc | 40 ++++++++++++++++++++++++------
2 files changed, 38 insertions(+), 8 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 54dde45..0c47245 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,11 @@
2008-10-03 Roland Levillain <roland(a)lrde.epita.fr>
+ Exercise neighborhood and piters on lower+higher-dim. adjacent faces.
+
+ * tests/core/image/complex_image.cc: Here.
+
+2008-10-03 Roland Levillain <roland(a)lrde.epita.fr>
+
Add neighborhood of both lower- and higher-dimension adjacent faces.
* mln/core/image/complex_lower_higher_neighborhood.hh: New.
diff --git a/milena/tests/core/image/complex_image.cc b/milena/tests/core/image/complex_image.cc
index 76f55db..d30ccc4 100644
--- a/milena/tests/core/image/complex_image.cc
+++ b/milena/tests/core/image/complex_image.cc
@@ -39,8 +39,13 @@
// FIXME: Include these elsewhere? (In complex_image.hh?)
#include <mln/core/image/complex_lower_neighborhood.hh>
#include <mln/core/image/complex_higher_neighborhood.hh>
+#include <mln/core/image/complex_lower_higher_neighborhood.hh>
#include <mln/core/image/complex_neighborhood_piter.hh>
+/* FIXME: Split this test (and maybe factor common parts, like the
+ construction of the complex), since it exercises too many features
+ in a single file. */
+
int main()
{
@@ -201,7 +206,8 @@ int main()
// Iterators on windows and neighborhoods. //
// ---------------------------------------- //
- // FIXME: Factor: these two test cases only differ by their neighborhood.
+ // FIXME: Factor: these three test cases only differ by their
+ // neighborhoods.
// Iterate on the lower-dimension faces of each face.
{
@@ -245,17 +251,35 @@ int main()
std::cout << std::endl;
}
- /* FIXME: Implement windows (and neighborhoods) and corresponding
- iterators for complex-based images.
+ // Iterate on the lower- and higher-dimension faces of each face.
+ {
+ typedef complex_lower_higher_neighborhood<D, P> nbh_t;
+ nbh_t nbh;
+ mln_fwd_niter_(nbh_t) fn(nbh, fp);
+ mln_bkd_niter_(nbh_t) bn(nbh, fp);
+ for_all(fp)
+ {
+ std::cout << "Lower- and higer-dimension faces adjacent to " << fp
+ << std::endl;
+ for_all_2(fn, bn)
+ {
+ mln_assertion((fn.center() ==
+ static_cast<const complex_psite<D, P>&>(fp)));
+ mln_assertion((bn.center() ==
+ static_cast<const complex_psite<D, P>&>(fp)));
+ std::cout << " " << fn << '\t' << bn << std::endl;
+ }
+ }
+ std::cout << std::endl;
+ }
+
+
+ /* FIXME: Implement other neighborhoods (and windows) and
+ corresponding iterators for complex-based images.
For a given (fixed) dimension N and a psite P on a N-face,
implement windows returning
- - the set of (N-1)-faces adjacent to P (using p_faces and
- faces_psite?);
- - the set of (N+1)-faces adjacent to P (using p_faces and
- faces_psite?);
-
- the set of N-faces sharing a (N-1)-face with P;
- the set of N-faces sharing a (N-1)-face or (N-2)-face (by
transitivity) with P (is it useful?);
--
1.6.0.1
* mln/core/image/complex_lower_higher_neighborhood.hh: New.
---
milena/ChangeLog | 6 +
.../image/complex_lower_higher_neighborhood.hh | 121 ++++++++++++++++++++
2 files changed, 127 insertions(+), 0 deletions(-)
create mode 100644 milena/mln/core/image/complex_lower_higher_neighborhood.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 57729ee..54dde45 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,11 @@
2008-10-03 Roland Levillain <roland(a)lrde.epita.fr>
+ Add neighborhood of both lower- and higher-dimension adjacent faces.
+
+ * mln/core/image/complex_lower_higher_neighborhood.hh: New.
+
+2008-10-03 Roland Levillain <roland(a)lrde.epita.fr>
+
Exercise iterators lower+higher-dimension adjacent faces.
* tests/topo/complex.cc: Here.
diff --git a/milena/mln/core/image/complex_lower_higher_neighborhood.hh b/milena/mln/core/image/complex_lower_higher_neighborhood.hh
new file mode 100644
index 0000000..3780709
--- /dev/null
+++ b/milena/mln/core/image/complex_lower_higher_neighborhood.hh
@@ -0,0 +1,121 @@
+// 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. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_COMPLEX_LOWER_HIGHER_NEIGHBORHOOD_HH
+# define MLN_CORE_COMPLEX_LOWER_HIGHER_NEIGHBORHOOD_HH
+
+/// \file mln/core/complex_lower_higher_neighborhood.hh
+/// \brief A neighborhood centered on a n-face of complex returning its
+/// adjacent (n-1)-faces and (n+1)-faces.
+
+# include <mln/core/concept/neighborhood.hh>
+
+# include <mln/core/site_set/complex_psite.hh>
+
+# include <mln/topo/adj_lower_higher_face_iter.hh>
+
+/* FIXME: Factor with complex_lower_neighborhood and
+ complex_higher_neighborhood (e.g., using an
+ internal::complex_neighborhood_base common base class). */
+
+
+namespace mln
+{
+ // Forward declarations.
+ template <typename I, typename P, typename N>
+ class complex_neighborhood_fwd_piter;
+ template <typename I, typename P, typename N>
+ class complex_neighborhood_bkd_piter;
+
+
+ /// \brief Neighborhood centered on a n-face of complex returning its
+ /// adjacent (n-1)-faces.
+ template <unsigned D, typename P>
+ class complex_lower_higher_neighborhood
+ : public Neighborhood< complex_lower_higher_neighborhood<D, P> >
+ {
+ typedef complex_lower_higher_neighborhood<D, P> self_;
+
+ public:
+ /// The associated complex iterators.
+ /// \{
+ typedef topo::adj_lower_higher_face_fwd_iter<D> complex_fwd_iter;
+ typedef topo::adj_lower_higher_face_bkd_iter<D> complex_bkd_iter;
+ /// \}
+
+ public:
+ /// Associated types.
+ /// \{
+ /// The type of psite corresponding to the neighborhood.
+ typedef complex_psite<D, P> psite;
+ /// The type of site corresponding to the neighborhood.
+ typedef mln_site(psite) site;
+
+ /// \brief Site_Iterator type to browse the psites of the neighborhood
+ /// w.r.t. the ordering of vertices.
+ typedef
+ complex_neighborhood_fwd_piter<complex_fwd_iter, P, self_> fwd_niter;
+
+ /// \brief Site_Iterator type to browse the psites of the neighborhood
+ /// w.r.t. the reverse ordering of vertices.
+ typedef
+ complex_neighborhood_bkd_piter<complex_bkd_iter, P, self_> bkd_niter;
+
+ /// The default niter type.
+ typedef fwd_niter niter;
+ /// \}
+
+ /// Conversions.
+ /// \{
+ /// The window type corresponding to this neighborhood.
+ // FIXME: Dummy.
+ typedef self_ window;
+ /// Create a window corresponding to this neighborhood.
+ const window& win() const;
+ /// \}
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // FIXME: Dummy.
+ template <unsigned D, typename P>
+ inline
+ // FIXME: Change (dummy) type.
+ const typename complex_lower_higher_neighborhood<D, P>::window&
+ complex_lower_higher_neighborhood<D, P>::win() const
+ {
+ // FIXME: Dummy.
+ return *this;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // ! MLN_CORE_COMPLEX_LOWER_HIGHER_NEIGHBORHOOD_HH
--
1.6.0.1
* tests/topo/complex.cc: Here.
---
milena/ChangeLog | 6 ++++++
milena/tests/topo/complex.cc | 41 +++++++++++++++++++++++++----------------
2 files changed, 31 insertions(+), 16 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 4ebc231..57729ee 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,11 @@
2008-10-03 Roland Levillain <roland(a)lrde.epita.fr>
+ Exercise iterators lower+higher-dimension adjacent faces.
+
+ * tests/topo/complex.cc: Here.
+
+2008-10-03 Roland Levillain <roland(a)lrde.epita.fr>
+
Add iterators on both lower- and higher-dimension adjacent faces.
* mln/topo/adj_lower_higher_face_iter.hh: New.
diff --git a/milena/tests/topo/complex.cc b/milena/tests/topo/complex.cc
index f079734..9e559de 100644
--- a/milena/tests/topo/complex.cc
+++ b/milena/tests/topo/complex.cc
@@ -36,6 +36,9 @@
using namespace mln;
+/* FIXME: Split this test (and maybe factor common parts, like the
+ construction of the complex), since it exercises too many features
+ in a single file. */
// Forward declarations.
template <unsigned N, unsigned D>
@@ -207,26 +210,18 @@ 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)- and (n+1)-faces adjacent to the
- faces of C.
+ /* Iterate on the the set of (n-1)- and/or (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.
+ be either static or dynamic. For the moment, our iterators are
+ dynamic w.r.t. the dimensions of the faces (both the reference
+ face and the iterated ones).
- Let's start with a dynamic one, as it would allow us to
- write something like this:
-
- mln_fwd_citer_(topo::complex<D>) f(c);
- mln_fwd_lower_nciter(topo::complex<D>) n(c);
- for_all(c)
- for_all(n)
- // ...
-
- (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. */
+ Static versions might be useful, and more efficient too, when
+ flexibility is not needed. */
+ // Iterate on the the set of (n-1)-faces adjacent to the faces of C.
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)
@@ -238,6 +233,7 @@ int main()
}
std::cout << std::endl;
+ // Iterate on the the set of (n+1)-faces adjacent to the faces of C.
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)
@@ -249,6 +245,19 @@ int main()
}
std::cout << std::endl;
+ // Iterate on the the set of (n+1)-faces *and* (n+1)-faces adjacent
+ // to the faces of C.
+ topo::adj_lower_higher_face_fwd_iter<D> fwd_alhf(fwd_f);
+ topo::adj_lower_higher_face_bkd_iter<D> bkd_alhf(fwd_f);
+ for_all(fwd_f)
+ {
+ std::cout << "Lower- and higher-dimension faces adjacent to " << fwd_f
+ << ": " << std::endl;
+ for_all_2(fwd_alhf, bkd_alhf)
+ std::cout << " " << fwd_alhf << '\t' << bkd_alhf << std::endl;
+ }
+ std::cout << std::endl;
+
/* But first, we need to clarify (existing) names. The one listed
in https://trac.lrde.org/olena/wiki/Olena/ComplexBasedImages
are OK.
--
1.6.0.1
* mln/topo/adj_lower_higher_face_iter.hh: New.
Include this header...
* mln/topo/complex.hh: ...here.
---
milena/ChangeLog | 8 ++
milena/mln/topo/adj_lower_higher_face_iter.hh | 161 +++++++++++++++++++++++++
milena/mln/topo/complex.hh | 1 +
3 files changed, 170 insertions(+), 0 deletions(-)
create mode 100644 milena/mln/topo/adj_lower_higher_face_iter.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 755c13d..4ebc231 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,13 @@
2008-10-03 Roland Levillain <roland(a)lrde.epita.fr>
+ Add iterators on both lower- and higher-dimension adjacent faces.
+
+ * mln/topo/adj_lower_higher_face_iter.hh: New.
+ Include this header...
+ * mln/topo/complex.hh: ...here.
+
+2008-10-03 Roland Levillain <roland(a)lrde.epita.fr>
+
Add a meta iterator sequencing two complex relative iterators.
* mln/topo/internal/complex_relative_iterator_sequence.hh: New.
diff --git a/milena/mln/topo/adj_lower_higher_face_iter.hh b/milena/mln/topo/adj_lower_higher_face_iter.hh
new file mode 100644
index 0000000..e28b64a
--- /dev/null
+++ b/milena/mln/topo/adj_lower_higher_face_iter.hh
@@ -0,0 +1,161 @@
+// 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_HIGHER_FACE_ITER_HH
+# define MLN_TOPO_ADJ_LOWER_HIGHER_FACE_ITER_HH
+
+/// \file mln/topo/adj_lower_higher_face_iter.hh
+/// \brief Definition of forward and backward iterators on all the
+/// adjacent (n-1)-faces and (n+1)-faces of a (reference) n-face in a
+/// complex.
+
+# include <mln/topo/internal/complex_relative_iterator_sequence.hh>
+# include <mln/topo/adj_lower_face_iter.hh>
+# include <mln/topo/adj_higher_face_iter.hh>
+
+# include <mln/topo/face.hh>
+
+
+namespace mln
+{
+
+ namespace topo
+ {
+
+ // Forward declaration.
+ template <unsigned D> class complex;
+
+
+ /*------------------------------------------.
+ | topo::adj_lower_higher_face_fwd_iter<D>. |
+ `------------------------------------------*/
+
+ /// \brief Forward iterator on all the adjacent (n-1)-faces and
+ /// (n+1)-faces of the n-face of an mln::complex<D>.
+ ///
+ /// \arg \p D The dimension of the complex this iterator belongs to.
+ template <unsigned D>
+ class adj_lower_higher_face_fwd_iter
+ : public internal::complex_relative_iterator_sequence<adj_lower_face_fwd_iter<D>,
+ adj_higher_face_fwd_iter<D>,
+ adj_lower_higher_face_fwd_iter<D> >
+ {
+ typedef adj_lower_higher_face_fwd_iter<D> self_;
+ typedef adj_lower_face_fwd_iter<D> iter1_;
+ typedef adj_higher_face_fwd_iter<D> iter2_;
+ typedef internal::complex_relative_iterator_sequence< iter1_,
+ iter2_,
+ self_ > super_;
+
+ public:
+ /// Construction.
+ /// \{
+ adj_lower_higher_face_fwd_iter();
+ template <typename Fref>
+ adj_lower_higher_face_fwd_iter(const Fref& f_ref);
+ /// \}
+ };
+
+
+ /*------------------------------------------.
+ | topo::adj_lower_higher_face_bkd_iter<D>. |
+ `------------------------------------------*/
+
+ /// \brief Forward iterator on all the adjacent (n-1)-faces and
+ /// (n+1)-faces of the n-face of an mln::complex<D>.
+ ///
+ /// \arg \p D The dimension of the complex this iterator belongs to.
+ template <unsigned D>
+ class adj_lower_higher_face_bkd_iter
+ : public internal::complex_relative_iterator_sequence<adj_higher_face_bkd_iter<D>,
+ adj_lower_face_bkd_iter<D>,
+ adj_lower_higher_face_bkd_iter<D> >
+ {
+ typedef adj_lower_higher_face_bkd_iter<D> self_;
+ typedef adj_higher_face_bkd_iter<D> iter1_;
+ typedef adj_lower_face_bkd_iter<D> iter2_;
+ typedef internal::complex_relative_iterator_sequence< iter1_,
+ iter2_,
+ self_ > super_;
+
+ public:
+ /// Construction.
+ /// \{
+ adj_lower_higher_face_bkd_iter();
+ template <typename Fref>
+ adj_lower_higher_face_bkd_iter(const Fref& f_ref);
+ /// \}
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ /*------------------------------------------.
+ | topo::adj_lower_higher_face_fwd_iter<D>. |
+ `------------------------------------------*/
+
+ template <unsigned D>
+ inline
+ adj_lower_higher_face_fwd_iter<D>::adj_lower_higher_face_fwd_iter()
+ {
+ }
+
+ template <unsigned D>
+ template <typename Fref>
+ inline
+ adj_lower_higher_face_fwd_iter<D>::adj_lower_higher_face_fwd_iter(const Fref& f_ref)
+ : super_(f_ref)
+ {
+ }
+
+
+ /*------------------------------------------.
+ | topo::adj_lower_higher_face_bkd_iter<D>. |
+ `------------------------------------------*/
+
+ template <unsigned D>
+ inline
+ adj_lower_higher_face_bkd_iter<D>::adj_lower_higher_face_bkd_iter()
+ {
+ }
+
+ template <unsigned D>
+ template <typename Fref>
+ inline
+ adj_lower_higher_face_bkd_iter<D>::adj_lower_higher_face_bkd_iter(const Fref& f_ref)
+ : super_(f_ref)
+ {
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::topo
+
+} // end of namespace mln
+
+#endif // ! MLN_TOPO_ADJ_LOWER_HIGHER_FACE_ITER_HH
diff --git a/milena/mln/topo/complex.hh b/milena/mln/topo/complex.hh
index c053879..1291ca7 100644
--- a/milena/mln/topo/complex.hh
+++ b/milena/mln/topo/complex.hh
@@ -58,6 +58,7 @@
# include <mln/topo/adj_lower_face_iter.hh>
# include <mln/topo/adj_higher_face_iter.hh>
+# include <mln/topo/adj_lower_higher_face_iter.hh>
namespace mln
--
1.6.0.1
* mln/topo/internal/complex_relative_iterator_sequence.hh: New.
---
milena/ChangeLog | 6 +
.../internal/complex_relative_iterator_sequence.hh | 235 ++++++++++++++++++++
2 files changed, 241 insertions(+), 0 deletions(-)
create mode 100644 milena/mln/topo/internal/complex_relative_iterator_sequence.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index be4dc71..755c13d 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,11 @@
2008-10-03 Roland Levillain <roland(a)lrde.epita.fr>
+ Add a meta iterator sequencing two complex relative iterators.
+
+ * mln/topo/internal/complex_relative_iterator_sequence.hh: New.
+
+2008-10-03 Roland Levillain <roland(a)lrde.epita.fr>
+
* mln/core/macros.hh (mln_face, mln_face_): New macros.
2008-10-03 Roland Levillain <roland(a)lrde.epita.fr>
diff --git a/milena/mln/topo/internal/complex_relative_iterator_sequence.hh b/milena/mln/topo/internal/complex_relative_iterator_sequence.hh
new file mode 100644
index 0000000..6725bc0
--- /dev/null
+++ b/milena/mln/topo/internal/complex_relative_iterator_sequence.hh
@@ -0,0 +1,235 @@
+// 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_SEQUENCE_HH
+# define MLN_TOPO_INTERNAL_COMPLEX_RELATIVE_ITERATOR_SEQUENCE_HH
+
+/// \file mln/topo/internal/complex_relative_iterator_sequence.hh
+/// \brief Definition of a meta complex relative iterator using two
+/// complex relative iterators sequentially.
+
+# include <iosfwd>
+
+# include <mln/metal/equal.hh>
+
+# include <mln/core/concept/iterator.hh>
+# include <mln/topo/complex.hh>
+
+
+namespace mln
+{
+
+ namespace topo
+ {
+
+ namespace internal
+ {
+ /// \brief A meta relative iterator on the faces of a complex
+ /// using two complex relative iterators sequentially.
+ ///
+ /// The first relative iterator is used, and when it becomes
+ /// invalid, the second one is used.
+ ///
+ /// \arg \p I1 The type of the first relative iterator.
+ /// \arg \p I2 The type of the second relative iterator.
+ /// \arg \p E The type exact type of the iterator.
+ template <typename I1, typename I2, typename E>
+ class complex_relative_iterator_sequence : public Iterator<E>
+ {
+ typedef complex_relative_iterator_sequence<I1, I2, E> self_;
+
+ public:
+ /// The type of the iterated faces.
+ typedef mln_face(I1) face;
+
+ /// Construction and assignment.
+ /// \{
+ complex_relative_iterator_sequence();
+ template <typename Fref>
+ complex_relative_iterator_sequence(const Fref& f_ref);
+ /// \}
+
+ /// Manipulation.
+ /// \{
+ /// Change the center face.
+ void center_at(const face& c);
+
+ /// Test if the iterator is valid.
+ bool is_valid() const;
+ /// Invalidate the iterator.
+ void invalidate();
+
+ /// Start an iteration.
+ void start();
+ /// Go to the next point.
+ void next_();
+ /// \}
+
+ /// Conversion.
+ /// \{
+ /// Return a reference to the corresponding face handle.
+ operator const face&() const;
+ /// \}
+
+ protected:
+ /// Update the target face.
+ void update_();
+
+ protected:
+ /// The first complex relative iterator.
+ I1 iter1_;
+ /// The second complex relative iterator.
+ I2 iter2_;
+
+ /// The face handle this iterator is pointing to.
+ face f_;
+ };
+
+
+ /// Print an mln::topo::internal::complex_relative_iterator_sequence.
+ template <typename I1, typename I2, typename E>
+ inline
+ std::ostream&
+ operator<<(std::ostream& ostr,
+ const complex_relative_iterator_sequence<I1, I2, E>& p);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I1, typename I2, typename E>
+ inline
+ complex_relative_iterator_sequence<I1, I2, E>::complex_relative_iterator_sequence()
+ {
+ // Ensure I1 and I2 are compatible.
+ mlc_equal(mln_face(I1), mln_face(I2))::check();
+
+ invalidate();
+ }
+
+ template <typename I1, typename I2, typename E>
+ template <typename Fref>
+ inline
+ complex_relative_iterator_sequence<I1, I2, E>::complex_relative_iterator_sequence(const Fref& f_ref)
+ {
+ // Ensure I1 and I2 are compatible.
+ mlc_equal(mln_face(I1), mln_face(I2))::check();
+
+ center_at(f_ref);
+ }
+
+ template <typename I1, typename I2, typename E>
+ inline
+ void
+ complex_relative_iterator_sequence<I1, I2, E>::center_at(const mln_face(I1)& c)
+ {
+ iter1_.center_at(c);
+ iter2_.center_at(c);
+ invalidate();
+ }
+
+ template <typename I1, typename I2, typename E>
+ inline
+ bool
+ complex_relative_iterator_sequence<I1, I2, E>::is_valid() const
+ {
+ return iter1_.is_valid() || iter2_.is_valid();
+ }
+
+ template <typename I1, typename I2, typename E>
+ inline
+ void
+ complex_relative_iterator_sequence<I1, I2, E>::invalidate()
+ {
+ iter1_.invalidate();
+ iter2_.invalidate();
+ }
+
+ template <typename I1, typename I2, typename E>
+ inline
+ void
+ complex_relative_iterator_sequence<I1, I2, E>::start()
+ {
+ iter1_.start();
+ iter2_.start();
+ if (is_valid())
+ update_();
+ }
+
+ template <typename I1, typename I2, typename E>
+ inline
+ void
+ complex_relative_iterator_sequence<I1, I2, E>::next_()
+ {
+ /* Iterator<E>::next() ensures that either iter1_ or iter2_
+ (or both) are valid before executing this method. */
+ if (iter1_.is_valid())
+ iter1_.next();
+ else
+ iter2_.next();
+ if (is_valid())
+ update_();
+ }
+
+ template <typename I1, typename I2, typename E>
+ inline
+ void
+ complex_relative_iterator_sequence<I1, I2, E>::update_()
+ {
+ mln_precondition(is_valid());
+ if (iter1_.is_valid())
+ f_ = iter1_;
+ else
+ f_ = iter2_;
+ }
+
+ template <typename I1, typename I2, typename E>
+ inline
+ complex_relative_iterator_sequence<I1, I2, E>::operator const mln_face(I1)&() const
+ {
+ return f_;
+ }
+
+
+ template <typename I1, typename I2, typename E>
+ inline
+ std::ostream&
+ operator<<(std::ostream& ostr,
+ const complex_relative_iterator_sequence<I1, I2, E>& p)
+ {
+ return ostr << mln_face(I1)(p);
+ }
+
+# 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_SEQUENCE_HH
--
1.6.0.1