* 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
* mln/core/image/complex_lower_neighborhood.hh,
* mln/core/image/complex_higher_neighborhood.hh:
Update the documentation.
---
milena/ChangeLog | 8 ++++++++
.../mln/core/image/complex_higher_neighborhood.hh | 10 ++++++----
.../mln/core/image/complex_lower_neighborhood.hh | 10 ++++++----
3 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 1fe4229..e07f8bc 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,13 @@
2008-10-03 Roland Levillain <roland(a)lrde.epita.fr>
+ Overhaul neighborhoods of adjacent lower- and higher-dimension faces.
+
+ * mln/core/image/complex_lower_neighborhood.hh,
+ * mln/core/image/complex_higher_neighborhood.hh:
+ Update the documentation.
+
+2008-10-03 Roland Levillain <roland(a)lrde.epita.fr>
+
Overhaul piters on complex neighborhood.
* mln/core/image/complex_neighborhood_piter.hh
diff --git a/milena/mln/core/image/complex_higher_neighborhood.hh b/milena/mln/core/image/complex_higher_neighborhood.hh
index 2b52c5b..3b56d68 100644
--- a/milena/mln/core/image/complex_higher_neighborhood.hh
+++ b/milena/mln/core/image/complex_higher_neighborhood.hh
@@ -43,7 +43,7 @@
namespace mln
{
- // Fwd decls.
+ // Forward declarations.
template <typename I, typename P, typename N>
class complex_neighborhood_fwd_piter;
template <typename I, typename P, typename N>
@@ -58,10 +58,12 @@ namespace mln
{
typedef complex_higher_neighborhood<D, P> self_;
- // FIXME: The associated complex iterators.
public:
+ /// The associated complex iterators.
+ /// \{
typedef topo::adj_higher_face_fwd_iter<D> complex_fwd_iter;
typedef topo::adj_higher_face_bkd_iter<D> complex_bkd_iter;
+ /// \}
public:
/// Associated types.
@@ -71,12 +73,12 @@ namespace mln
/// The type of site corresponding to the neighborhood.
typedef mln_site(psite) site;
- /// \brief Point_Iterator type to browse the psites of the neighborhood
+ /// \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 Point_Iterator type to browse the psites of the neighborhood
+ /// \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;
diff --git a/milena/mln/core/image/complex_lower_neighborhood.hh b/milena/mln/core/image/complex_lower_neighborhood.hh
index 7eb8fc4..6c21acc 100644
--- a/milena/mln/core/image/complex_lower_neighborhood.hh
+++ b/milena/mln/core/image/complex_lower_neighborhood.hh
@@ -43,7 +43,7 @@
namespace mln
{
- // Fwd decls.
+ // Forward declarations.
template <typename I, typename P, typename N>
class complex_neighborhood_fwd_piter;
template <typename I, typename P, typename N>
@@ -58,10 +58,12 @@ namespace mln
{
typedef complex_lower_neighborhood<D, P> self_;
- // FIXME: The associated complex iterators.
public:
+ /// The associated complex iterators.
+ /// \{
typedef topo::adj_lower_face_fwd_iter<D> complex_fwd_iter;
typedef topo::adj_lower_face_bkd_iter<D> complex_bkd_iter;
+ /// \}
public:
/// Associated types.
@@ -71,12 +73,12 @@ namespace mln
/// The type of site corresponding to the neighborhood.
typedef mln_site(psite) site;
- /// \brief Point_Iterator type to browse the psites of the neighborhood
+ /// \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 Point_Iterator type to browse the psites of the neighborhood
+ /// \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;
--
1.6.0.1
* mln/topo/internal/complex_set_iterator_base.hh: Update
documentation and headers.
Don't include header `limits'.
Include header `iosfwd'.
---
milena/ChangeLog | 9 +++++++++
.../mln/topo/internal/complex_set_iterator_base.hh | 3 ++-
2 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 5a11379..e84ab00 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,12 @@
+2008-10-03 Roland Levillain <roland(a)lrde.epita.fr>
+
+ Overhaul mln::topo::internal::complex_set_iterator_base.
+
+ * mln/topo/internal/complex_set_iterator_base.hh: Update
+ documentation and headers.
+ Don't include header `limits'.
+ Include header `iosfwd'.
+
2008-10-02 Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Start to integrate registration in Milena.
diff --git a/milena/mln/topo/internal/complex_set_iterator_base.hh b/milena/mln/topo/internal/complex_set_iterator_base.hh
index 7e76b76..51f67c1 100644
--- a/milena/mln/topo/internal/complex_set_iterator_base.hh
+++ b/milena/mln/topo/internal/complex_set_iterator_base.hh
@@ -32,7 +32,7 @@
/// \brief Definition of an implementation (factoring) class for
/// iterators on faces of a complex.
-# include <limits>
+# include <iosfwd>
# include <mln/metal/equal.hh>
@@ -61,6 +61,7 @@ namespace mln
typedef complex_set_iterator_base<F, E> self_;
public:
+ /// The type of the iterated faces.
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>?
--
1.6.0.1