* mln/topo/complex.hh: Move iterator-related header inclusions...
* mln/topo/complex_iterators.hh: ...here (new file).
---
milena/ChangeLog | 7 +++++
milena/mln/topo/complex.hh | 14 +---------
milena/mln/topo/complex_iterators.hh | 50 ++++++++++++++++++++++++++++++++++
3 files changed, 58 insertions(+), 13 deletions(-)
create mode 100644 milena/mln/topo/complex_iterators.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index ee844c1..d466a7a 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,12 @@
2008-10-05 Roland Levillain <roland(a)lrde.epita.fr>
+ Introduce a header for iterators on complexes.
+
+ * mln/topo/complex.hh: Move iterator-related header inclusions...
+ * mln/topo/complex_iterators.hh: ...here (new file).
+
+2008-10-05 Roland Levillain <roland(a)lrde.epita.fr>
+
Add relative iterators on faces sharing lower/higher-dimension faces.
* mln/topo/adj_lower_dim_connected_n_face_iter.hh,
diff --git a/milena/mln/topo/complex.hh b/milena/mln/topo/complex.hh
index 06c714e..d3d2e18 100644
--- a/milena/mln/topo/complex.hh
+++ b/milena/mln/topo/complex.hh
@@ -48,19 +48,7 @@
# include <mln/topo/n_face.hh>
# include <mln/topo/n_faces_set.hh>
-# include <mln/topo/face_iter.hh>
-# include <mln/topo/n_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>
-# endif
-
-# 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>
-# include <mln/topo/adj_lower_dim_connected_n_face_iter.hh>
-# include <mln/topo/adj_higher_dim_connected_n_face_iter.hh>
+# include <mln/topo/complex_iterators.hh>
namespace mln
diff --git a/milena/mln/topo/complex_iterators.hh b/milena/mln/topo/complex_iterators.hh
new file mode 100644
index 0000000..170e19c
--- /dev/null
+++ b/milena/mln/topo/complex_iterators.hh
@@ -0,0 +1,50 @@
+// 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_COMPLEX_ITERATORS_HH
+# define MLN_TOPO_COMPLEX_ITERATORS_HH
+
+/// \file mln/core/topo/complex_iterators.hh
+/// \brief Iterators on complexes.
+///
+/// This file includes all iterators on faces.
+
+# include <mln/topo/face_iter.hh>
+# include <mln/topo/n_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>
+# endif
+
+# 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>
+# include <mln/topo/adj_lower_dim_connected_n_face_iter.hh>
+# include <mln/topo/adj_higher_dim_connected_n_face_iter.hh>
+
+#endif // ! MLN_TOPO_COMPLEX_ITERATORS_HH
--
1.6.0.1
* mln/topo/adj_lower_dim_connected_n_face_iter.hh,
* mln/topo/adj_higher_dim_connected_n_face_iter.hh:
New.
Include these headers...
* mln/topo/complex.hh: ...here.
* tests/topo/complex.cc: Exercise these iterators.
---
milena/ChangeLog | 11 +
.../topo/adj_higher_dim_connected_n_face_iter.hh | 270 ++++++++++++++++++++
.../topo/adj_lower_dim_connected_n_face_iter.hh | 270 ++++++++++++++++++++
milena/mln/topo/complex.hh | 2 +
milena/tests/topo/complex.cc | 66 +++--
5 files changed, 595 insertions(+), 24 deletions(-)
create mode 100644 milena/mln/topo/adj_higher_dim_connected_n_face_iter.hh
create mode 100644 milena/mln/topo/adj_lower_dim_connected_n_face_iter.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 583c73e..ee844c1 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,16 @@
2008-10-05 Roland Levillain <roland(a)lrde.epita.fr>
+ Add relative iterators on faces sharing lower/higher-dimension faces.
+
+ * mln/topo/adj_lower_dim_connected_n_face_iter.hh,
+ * mln/topo/adj_higher_dim_connected_n_face_iter.hh:
+ New.
+ Include these headers...
+ * mln/topo/complex.hh: ...here.
+ * tests/topo/complex.cc: Exercise these iterators.
+
+2008-10-05 Roland Levillain <roland(a)lrde.epita.fr>
+
Add operator!= on face handles.
* mln/topo/face.hh
diff --git a/milena/mln/topo/adj_higher_dim_connected_n_face_iter.hh b/milena/mln/topo/adj_higher_dim_connected_n_face_iter.hh
new file mode 100644
index 0000000..ad6dbe9
--- /dev/null
+++ b/milena/mln/topo/adj_higher_dim_connected_n_face_iter.hh
@@ -0,0 +1,270 @@
+// 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_DIM_CONNECTED_N_FACE_ITER_HH
+# define MLN_TOPO_ADJ_HIGHER_DIM_CONNECTED_N_FACE_ITER_HH
+
+/// \file mln/topo/adj_higher_dim_connected_n_face_iter.hh
+
+/// \brief Definition of forward and backward iterators on all the
+/// n-faces sharing an adjacent (n+1)-face with a (reference) n-face
+/// in a complex.
+
+# include <set>
+
+# include <mln/topo/internal/complex_relative_iterator_base.hh>
+# include <mln/topo/face.hh>
+
+
+namespace mln
+{
+
+ namespace topo
+ {
+
+ // Forward declarations.
+ template <unsigned D> class complex;
+ namespace internal
+ {
+ template <unsigned D> class adj_higher_dim_connected_n_face_iterator;
+ }
+
+
+ /*---------------------------------------------------.
+ | topo::adj_higher_dim_connected_n_face_fwd_iter<D>. |
+ `---------------------------------------------------*/
+
+ /// \brief Forward iterator on all the n-faces sharing an adjacent
+ /// (n+1)-face with a (reference) n-face of an mln::complex<D>.
+ ///
+ /// \arg \p D The dimension of the complex this iterator belongs to.
+ template <unsigned D>
+ class adj_higher_dim_connected_n_face_fwd_iter
+ : public internal::forward_complex_relative_iterator_base< face<D>,
+ adj_higher_dim_connected_n_face_fwd_iter<D> >,
+ private internal::adj_higher_dim_connected_n_face_iterator<D>
+ {
+ private:
+ typedef adj_higher_dim_connected_n_face_fwd_iter<D> self_;
+ typedef internal::forward_complex_relative_iterator_base< face<D>,
+ self_ > super_;
+
+ public:
+ /// Construction.
+ /// \{
+ adj_higher_dim_connected_n_face_fwd_iter();
+ template <typename Fref>
+ adj_higher_dim_connected_n_face_fwd_iter(const Fref& f_ref);
+ /// \}
+
+ /// Compute the set of faces adjacent to the reference face.
+ void update_adj_faces_();
+ };
+
+
+ /*---------------------------------------------------.
+ | topo::adj_higher_dim_connected_n_face_bkd_iter<D>. |
+ `---------------------------------------------------*/
+
+ /// \brief Backward iterator on all the n-faces sharing an adjacent
+ /// (n+1)-face with a (reference) n-face of an mln::complex<D>.
+ ///
+ /// \arg \p D The dimension of the complex this iterator belongs to.
+ template <unsigned D>
+ class adj_higher_dim_connected_n_face_bkd_iter
+ : public internal::backward_complex_relative_iterator_base< face<D>,
+ adj_higher_dim_connected_n_face_bkd_iter<D> >,
+ private internal::adj_higher_dim_connected_n_face_iterator<D>
+ {
+ private:
+ typedef adj_higher_dim_connected_n_face_bkd_iter<D> self_;
+ typedef internal::backward_complex_relative_iterator_base< face<D>,
+ self_ > super_;
+
+ public:
+ /// Construction.
+ /// \{
+ adj_higher_dim_connected_n_face_bkd_iter();
+ template <typename Fref>
+ adj_higher_dim_connected_n_face_bkd_iter(const Fref& f_ref);
+ /// \}
+
+ /// \brief Compute the set of faces adjacent to the reference face.
+ ///
+ /// The computation is delegated to
+ /// mln::topo::internal::adj_higher_dim_connected_n_face_iterator.
+ void update_adj_faces_();
+ };
+
+
+ /*-------------------------------------------------------------.
+ | topo::internal::adj_higher_dim_connected_n_face_iterator<D>. |
+ `-------------------------------------------------------------*/
+
+ namespace internal
+ {
+
+ template <unsigned D>
+ class adj_higher_dim_connected_n_face_iterator
+ {
+ protected:
+ /// The actual implementation of the computation of the set of
+ /// faces adjacent to the reference face.
+ void update_adj_faces__(const face<D>& center,
+ std::vector< face<D> >& adj_faces);
+ };
+
+ } // end of namespace mln::topo::internal
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ /*---------------------------------------------------.
+ | topo::adj_higher_dim_connected_n_face_fwd_iter<D>. |
+ `---------------------------------------------------*/
+
+ template <unsigned D>
+ inline
+ adj_higher_dim_connected_n_face_fwd_iter<D>::adj_higher_dim_connected_n_face_fwd_iter()
+ {
+ }
+
+ template <unsigned D>
+ template <typename Fref>
+ inline
+ adj_higher_dim_connected_n_face_fwd_iter<D>::adj_higher_dim_connected_n_face_fwd_iter(const Fref& f_ref)
+ : super_(f_ref)
+ {
+ }
+
+ /* FIXME: Most of this code is shared by
+ adj_higher_dim_connected_n_face_{fwd,bkd}_iter<D> and
+ adj_higher_dim_connected_n_face_{fwd,bkd}_iter<D>). Find a way
+ to factor this, maybe through a common (implementation) base
+ class. */
+ template <unsigned D>
+ inline
+ void
+ adj_higher_dim_connected_n_face_fwd_iter<D>::update_adj_faces_()
+ {
+ mln_precondition(this->c_);
+ // Delegate computation to base class.
+ this->update_adj_faces__(*this->c_, this->adj_faces_);
+ }
+
+
+ /*---------------------------------------------------.
+ | topo::adj_higher_dim_connected_n_face_bkd_iter<D>. |
+ `---------------------------------------------------*/
+
+ template <unsigned D>
+ inline
+ adj_higher_dim_connected_n_face_bkd_iter<D>::adj_higher_dim_connected_n_face_bkd_iter()
+ {
+ }
+
+ template <unsigned D>
+ template <typename Fref>
+ inline
+ adj_higher_dim_connected_n_face_bkd_iter<D>::adj_higher_dim_connected_n_face_bkd_iter(const Fref& f_ref)
+ : super_(f_ref)
+ {
+ }
+
+ template <unsigned D>
+ inline
+ void
+ adj_higher_dim_connected_n_face_bkd_iter<D>::update_adj_faces_()
+ {
+ mln_precondition(this->c_);
+ // Delegate computation to base class.
+ this->update_adj_faces__(*this->c_, this->adj_faces_);
+ }
+
+
+ /*-------------------------------------------------------------.
+ | topo::internal::adj_higher_dim_connected_n_face_iterator<D>. |
+ `-------------------------------------------------------------*/
+
+ namespace internal
+ {
+
+ /* FIXME: Factor
+ topo::internal::adj_lower_dim_connected_n_face_iterator<D> and
+ topo::internal::adj_higher_dim_connected_n_face_iterator<D>. */
+
+ template <unsigned D>
+ inline
+ void
+ adj_higher_dim_connected_n_face_iterator<D>::update_adj_faces__(const face<D>& center,
+ std::vector< face<D> >& adj_faces)
+ {
+ // Reset the result container.
+ adj_faces.clear();
+
+ /* A set of faces containing the same values as ADJ_FACES, used
+ to quickly check whether a candidate face has already been
+ added to the pool of adjacent faces. We use an std::set
+ because the lookup is cheaper (O(log(n)) vs O(n) for a
+ vector, where n is the size of the containers. */
+ std::set< face<D> > faces_set;
+ typedef std::vector< face<D> > faces_t;
+
+ // The set of (n+1)-faces adjacent to CENTER.
+ faces_t shared_higher_faces = center.higher_dim_adj_faces();
+ for (typename faces_t::const_iterator slf = shared_higher_faces.begin();
+ slf != shared_higher_faces.end(); ++slf)
+ {
+ /* The n-faces sharing an adjacent (n+1)-face with CENTER.
+ Note that this set contains CENTER itself. */
+ faces_t adj_n_faces = slf->lower_dim_adj_faces();
+ for (typename faces_t::const_iterator af = adj_n_faces.begin();
+ af != adj_n_faces.end(); ++af)
+ {
+ /* Ensure that 1. we are not adding CENTER to the result;
+ and 2. that we are not adding an already added
+ processed face. */
+ if (*af != center &&
+ faces_set.find(*af) == faces_set.end())
+ {
+ adj_faces.push_back(*af);
+ faces_set.insert(*af);
+ }
+ }
+ }
+ }
+
+ } // end of namespace mln::topo::internal
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::topo
+
+} // end of namespace mln
+
+#endif // ! MLN_TOPO_ADJ_HIGHER_DIM_CONNECTED_N_FACE_ITER_HH
diff --git a/milena/mln/topo/adj_lower_dim_connected_n_face_iter.hh b/milena/mln/topo/adj_lower_dim_connected_n_face_iter.hh
new file mode 100644
index 0000000..7a11009
--- /dev/null
+++ b/milena/mln/topo/adj_lower_dim_connected_n_face_iter.hh
@@ -0,0 +1,270 @@
+// 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_DIM_CONNECTED_N_FACE_ITER_HH
+# define MLN_TOPO_ADJ_LOWER_DIM_CONNECTED_N_FACE_ITER_HH
+
+/// \file mln/topo/adj_lower_dim_connected_n_face_iter.hh
+
+/// \brief Definition of forward and backward iterators on all the
+/// n-faces sharing an adjacent (n-1)-face with a (reference) n-face
+/// in a complex.
+
+# include <set>
+
+# include <mln/topo/internal/complex_relative_iterator_base.hh>
+# include <mln/topo/face.hh>
+
+
+namespace mln
+{
+
+ namespace topo
+ {
+
+ // Forward declarations.
+ template <unsigned D> class complex;
+ namespace internal
+ {
+ template <unsigned D> class adj_lower_dim_connected_n_face_iterator;
+ }
+
+
+ /*---------------------------------------------------.
+ | topo::adj_lower_dim_connected_n_face_fwd_iter<D>. |
+ `---------------------------------------------------*/
+
+ /// \brief Forward iterator on all the n-faces sharing an adjacent
+ /// (n-1)-face with a (reference) 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_dim_connected_n_face_fwd_iter
+ : public internal::forward_complex_relative_iterator_base< face<D>,
+ adj_lower_dim_connected_n_face_fwd_iter<D> >,
+ private internal::adj_lower_dim_connected_n_face_iterator<D>
+ {
+ private:
+ typedef adj_lower_dim_connected_n_face_fwd_iter<D> self_;
+ typedef internal::forward_complex_relative_iterator_base< face<D>,
+ self_ > super_;
+
+ public:
+ /// Construction.
+ /// \{
+ adj_lower_dim_connected_n_face_fwd_iter();
+ template <typename Fref>
+ adj_lower_dim_connected_n_face_fwd_iter(const Fref& f_ref);
+ /// \}
+
+ /// Compute the set of faces adjacent to the reference face.
+ void update_adj_faces_();
+ };
+
+
+ /*---------------------------------------------------.
+ | topo::adj_lower_dim_connected_n_face_bkd_iter<D>. |
+ `---------------------------------------------------*/
+
+ /// \brief Backward iterator on all the n-faces sharing an adjacent
+ /// (n-1)-face with a (reference) 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_dim_connected_n_face_bkd_iter
+ : public internal::backward_complex_relative_iterator_base< face<D>,
+ adj_lower_dim_connected_n_face_bkd_iter<D> >,
+ private internal::adj_lower_dim_connected_n_face_iterator<D>
+ {
+ private:
+ typedef adj_lower_dim_connected_n_face_bkd_iter<D> self_;
+ typedef internal::backward_complex_relative_iterator_base< face<D>,
+ self_ > super_;
+
+ public:
+ /// Construction.
+ /// \{
+ adj_lower_dim_connected_n_face_bkd_iter();
+ template <typename Fref>
+ adj_lower_dim_connected_n_face_bkd_iter(const Fref& f_ref);
+ /// \}
+
+ /// \brief Compute the set of faces adjacent to the reference face.
+ ///
+ /// The computation is delegated to
+ /// mln::topo::internal::adj_lower_dim_connected_n_face_iterator.
+ void update_adj_faces_();
+ };
+
+
+ /*-------------------------------------------------------------.
+ | topo::internal::adj_lower_dim_connected_n_face_iterator<D>. |
+ `-------------------------------------------------------------*/
+
+ namespace internal
+ {
+
+ template <unsigned D>
+ class adj_lower_dim_connected_n_face_iterator
+ {
+ protected:
+ /// The actual implementation of the computation of the set of
+ /// faces adjacent to the reference face.
+ void update_adj_faces__(const face<D>& center,
+ std::vector< face<D> >& adj_faces);
+ };
+
+ } // end of namespace mln::topo::internal
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ /*---------------------------------------------------.
+ | topo::adj_lower_dim_connected_n_face_fwd_iter<D>. |
+ `---------------------------------------------------*/
+
+ template <unsigned D>
+ inline
+ adj_lower_dim_connected_n_face_fwd_iter<D>::adj_lower_dim_connected_n_face_fwd_iter()
+ {
+ }
+
+ template <unsigned D>
+ template <typename Fref>
+ inline
+ adj_lower_dim_connected_n_face_fwd_iter<D>::adj_lower_dim_connected_n_face_fwd_iter(const Fref& f_ref)
+ : super_(f_ref)
+ {
+ }
+
+ /* FIXME: Most of this code is shared by
+ adj_lower_dim_connected_n_face_{fwd,bkd}_iter<D> and
+ adj_higher_dim_connected_n_face_{fwd,bkd}_iter<D>). Find a way
+ to factor this, maybe through a common (implementation) base
+ class. */
+ template <unsigned D>
+ inline
+ void
+ adj_lower_dim_connected_n_face_fwd_iter<D>::update_adj_faces_()
+ {
+ mln_precondition(this->c_);
+ // Delegate computation to base class.
+ this->update_adj_faces__(*this->c_, this->adj_faces_);
+ }
+
+
+ /*---------------------------------------------------.
+ | topo::adj_lower_dim_connected_n_face_bkd_iter<D>. |
+ `---------------------------------------------------*/
+
+ template <unsigned D>
+ inline
+ adj_lower_dim_connected_n_face_bkd_iter<D>::adj_lower_dim_connected_n_face_bkd_iter()
+ {
+ }
+
+ template <unsigned D>
+ template <typename Fref>
+ inline
+ adj_lower_dim_connected_n_face_bkd_iter<D>::adj_lower_dim_connected_n_face_bkd_iter(const Fref& f_ref)
+ : super_(f_ref)
+ {
+ }
+
+ template <unsigned D>
+ inline
+ void
+ adj_lower_dim_connected_n_face_bkd_iter<D>::update_adj_faces_()
+ {
+ mln_precondition(this->c_);
+ // Delegate computation to base class.
+ this->update_adj_faces__(*this->c_, this->adj_faces_);
+ }
+
+
+ /*-------------------------------------------------------------.
+ | topo::internal::adj_lower_dim_connected_n_face_iterator<D>. |
+ `-------------------------------------------------------------*/
+
+ namespace internal
+ {
+
+ /* FIXME: Factor
+ topo::internal::adj_lower_dim_connected_n_face_iterator<D> and
+ topo::internal::adj_higher_dim_connected_n_face_iterator<D>. */
+
+ template <unsigned D>
+ inline
+ void
+ adj_lower_dim_connected_n_face_iterator<D>::update_adj_faces__(const face<D>& center,
+ std::vector< face<D> >& adj_faces)
+ {
+ // Reset the result container.
+ adj_faces.clear();
+
+ /* A set of faces containing the same values as ADJ_FACES, used
+ to quickly check whether a candidate face has already been
+ added to the pool of adjacent faces. We use an std::set
+ because the lookup is cheaper (O(log(n)) vs O(n) for a
+ vector, where n is the size of the containers. */
+ std::set< face<D> > faces_set;
+ typedef std::vector< face<D> > faces_t;
+
+ // The set of (n-1)-faces adjacent to CENTER.
+ faces_t shared_lower_faces = center.lower_dim_adj_faces();
+ for (typename faces_t::const_iterator slf = shared_lower_faces.begin();
+ slf != shared_lower_faces.end(); ++slf)
+ {
+ /* The n-faces sharing an adjacent (n-1)-face with CENTER.
+ Note that this set contains CENTER itself. */
+ faces_t adj_n_faces = slf->higher_dim_adj_faces();
+ for (typename faces_t::const_iterator af = adj_n_faces.begin();
+ af != adj_n_faces.end(); ++af)
+ {
+ /* Ensure that 1. we are not adding CENTER to the result;
+ and 2. that we are not adding an already added
+ processed face. */
+ if (*af != center &&
+ faces_set.find(*af) == faces_set.end())
+ {
+ adj_faces.push_back(*af);
+ faces_set.insert(*af);
+ }
+ }
+ }
+ }
+
+ } // end of namespace mln::topo::internal
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::topo
+
+} // end of namespace mln
+
+#endif // ! MLN_TOPO_ADJ_LOWER_DIM_CONNECTED_N_FACE_ITER_HH
diff --git a/milena/mln/topo/complex.hh b/milena/mln/topo/complex.hh
index 1291ca7..06c714e 100644
--- a/milena/mln/topo/complex.hh
+++ b/milena/mln/topo/complex.hh
@@ -59,6 +59,8 @@
# 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>
+# include <mln/topo/adj_lower_dim_connected_n_face_iter.hh>
+# include <mln/topo/adj_higher_dim_connected_n_face_iter.hh>
namespace mln
diff --git a/milena/tests/topo/complex.cc b/milena/tests/topo/complex.cc
index 92d0398..249b743 100644
--- a/milena/tests/topo/complex.cc
+++ b/milena/tests/topo/complex.cc
@@ -211,10 +211,12 @@ 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/or (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
+ /* Note: this can be solved with iterators where the dimension can
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).
@@ -259,31 +261,44 @@ int main()
}
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.
- Next, write these:
+ // ------------------------------------------------------- //
+ // Iterators on the the set of n-faces sharing an adjacent //
+ // (n-1)-face or (n+1)-face with f, n being dynamic. //
+ // ------------------------------------------------------- //
+
+ // For each face F of C, iterate on the the set of n-faces sharing
+ // adjacent (n-1)-faces with F.
+ topo::adj_lower_dim_connected_n_face_fwd_iter<D> fwd_aldcf(fwd_f);
+ topo::adj_lower_dim_connected_n_face_bkd_iter<D> bkd_aldcf(fwd_f);
+ for_all(fwd_f)
+ {
+ std::cout << "Lower-dim-connected faces adjacent to " << fwd_f
+ << ": " << std::endl;
+ for_all_2(fwd_aldcf, bkd_aldcf)
+ std::cout << " " << fwd_aldcf << '\t' << bkd_aldcf << std::endl;
+ }
+ std::cout << std::endl;
+
+ // For each face F of C, iterate on the the set of n-faces sharing
+ // adjacent (n+1)-faces with F.
+ topo::adj_higher_dim_connected_n_face_fwd_iter<D> fwd_ahdcf(fwd_f);
+ topo::adj_higher_dim_connected_n_face_bkd_iter<D> bkd_ahdcf(fwd_f);
+ for_all(fwd_f)
+ {
+ std::cout << "Higher-dim-connected faces adjacent to " << fwd_f
+ << ": " << std::endl;
+ for_all_2(fwd_ahdcf, bkd_ahdcf)
+ std::cout << " " << fwd_ahdcf << '\t' << bkd_ahdcf << std::endl;
+ }
+ std::cout << std::endl;
+
+
+ /* Next, write these:
-----------------------------------------------------------------
Name Definition
-----------------------------------------------------------------
- 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_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
- | (n+1)-face with f, n being
- | dynamic
-
cell_fwd_iter<D>(c, f) | Iterators on the set of the
cell_bkd_iter<D>(c, f) | faces in the « cell »
| including p, i.e. the set of
@@ -324,7 +339,9 @@ int main()
faces_fwd_iter_<N, D> static, acting as proxies of
face<D>'s.
-----------------------------------------------------------------
- */
+
+ See also https://trac.lrde.org/olena/wiki/Olena/ComplexBasedImages */
+
/*------------------.
| Other iterators. |
@@ -333,6 +350,7 @@ int main()
// For each face, iterate on itself. (This iterator is not
// interesting as-is, but is useful when combined with others,
// e.g. in topo::centered_iter_adapter).
+ std::cout << "Center-only iterator:" << std::endl;
topo::center_only_iter<D> center(fwd_f);
for_all(fwd_f)
for_all(center)
--
1.6.0.1
* mln/core/image/complex_lower_higher_neighborhood.hh: New.
* tests/morpho/complex_image_morpho.cc: Exercise this window.
---
milena/ChangeLog | 7 +
.../core/image/complex_lower_higher_window_p.hh | 147 ++++++++++++++++++++
milena/tests/morpho/complex_image_morpho.cc | 2 +
3 files changed, 156 insertions(+), 0 deletions(-)
create mode 100644 milena/mln/core/image/complex_lower_higher_window_p.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 4f36848..c2b1c36 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,12 @@
2008-10-05 Roland Levillain <roland(a)lrde.epita.fr>
+ Add a centered window of lower/higher-dim. adjacent complex faces.
+
+ * mln/core/image/complex_lower_higher_neighborhood.hh: New.
+ * tests/morpho/complex_image_morpho.cc: Exercise this window.
+
+2008-10-05 Roland Levillain <roland(a)lrde.epita.fr>
+
Add a centered window of higher-dimension adjacent complex faces.
* mln/core/image/complex_higher_window_p.hh: New.
diff --git a/milena/mln/core/image/complex_lower_higher_window_p.hh b/milena/mln/core/image/complex_lower_higher_window_p.hh
new file mode 100644
index 0000000..a3260df
--- /dev/null
+++ b/milena/mln/core/image/complex_lower_higher_window_p.hh
@@ -0,0 +1,147 @@
+// 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_IMAGE_COMPLEX_LOWER_HIGHER_WINDOW_P_HH
+# define MLN_CORE_IMAGE_COMPLEX_LOWER_HIGHER_WINDOW_P_HH
+
+/// \file mln/core/complex_lower_higher_window_p.hh
+/// \brief Definition of a window centered on a n-face of complex
+/// returning its adjacent (n-1)-faces and (n+1)-faces as well as the
+/// center n-face.
+
+# include <mln/core/concept/window.hh>
+
+# include <mln/core/site_set/complex_psite.hh>
+
+# include <mln/topo/centered_iter_adapter.hh>
+# include <mln/topo/adj_lower_higher_face_iter.hh>
+
+
+namespace mln
+{
+ // Forward declarations.
+ template <unsigned D, typename P> class complex_lower_higher_window_p;
+ template <typename I, typename P, typename W> class complex_window_fwd_piter;
+ template <typename I, typename P, typename W> class complex_window_bkd_piter;
+
+
+ namespace trait
+ {
+
+ template <unsigned D, typename P>
+ struct window_< mln::complex_lower_higher_window_p<D,P> >
+ {
+ typedef trait::window::size::unknown size;
+ typedef trait::window::support::irregular support;
+ typedef trait::window::definition::varying definition;
+ };
+
+ } // end of namespace mln::trait
+
+
+ /// \brief Window centered on a n-face of complex returning its
+ /// adjacent (n-1)-faces as well as the center n-face.
+ template <unsigned D, typename P>
+ class complex_lower_higher_window_p
+ : public Window< complex_lower_higher_window_p<D, P> >
+ {
+ typedef complex_lower_higher_window_p<D, P> self_;
+ /// The complex iterators on the <em>adjacent</em> faces only
+ /// (without the center point).
+ /// \{
+ typedef topo::adj_lower_higher_face_fwd_iter<D> adj_fwd_iter_;
+ typedef topo::adj_lower_higher_face_bkd_iter<D> adj_bkd_iter_;
+ /// \}
+
+ public:
+ /// The associated complex iterators.
+ /// \{
+ typedef topo::centered_fwd_iter_adapter<D, adj_fwd_iter_> complex_fwd_iter;
+ typedef topo::centered_bkd_iter_adapter<D, adj_bkd_iter_> complex_bkd_iter;
+ /// \}
+
+ public:
+ /// Associated types.
+ /// \{
+ /// The type of psite corresponding to the window.
+ typedef complex_psite<D, P> psite;
+ /// The type of site corresponding to the window.
+ typedef mln_site(psite) site;
+
+ // FIXME: This is a dummy value.
+ typedef void dpsite;
+
+ /// \brief Site_Iterator type to browse the psites of the window
+ /// w.r.t. the ordering of vertices.
+ typedef
+ complex_window_fwd_piter<complex_fwd_iter, P, self_> fwd_qiter;
+
+ /// \brief Site_Iterator type to browse the psites of the window
+ /// w.r.t. the reverse ordering of vertices.
+ typedef
+ complex_window_bkd_piter<complex_bkd_iter, P, self_> bkd_qiter;
+
+ /// The default qiter type.
+ typedef fwd_qiter qiter;
+ /// \}
+
+ public:
+ /// Services.
+ /// \{
+ /* FIXME: mln::morpho::dilation requires these method from models
+ of concept Window, but Window does not list them in its
+ requirements. Who's guilty: morpho::dilation or Window? */
+ /// Is this window empty? (Always returns \c false).
+ bool is_empty() const;
+ /// Is this window centered? (Always returns \c true).
+ bool is_centered() const;
+ /// \}
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <unsigned D, typename P>
+ bool
+ complex_lower_higher_window_p<D, P>::is_empty() const
+ {
+ return false;
+ }
+
+ template <unsigned D, typename P>
+ bool
+ complex_lower_higher_window_p<D, P>::is_centered() const
+ {
+ return true;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // ! MLN_CORE_IMAGE_COMPLEX_LOWER_HIGHER_WINDOW_P_HH
diff --git a/milena/tests/morpho/complex_image_morpho.cc b/milena/tests/morpho/complex_image_morpho.cc
index c950b2c..1d01c17 100644
--- a/milena/tests/morpho/complex_image_morpho.cc
+++ b/milena/tests/morpho/complex_image_morpho.cc
@@ -39,6 +39,7 @@
// FIXME: Include these elsewhere? (In complex_image.hh?)
#include <mln/core/image/complex_lower_window_p.hh>
#include <mln/core/image/complex_higher_window_p.hh>
+#include <mln/core/image/complex_lower_higher_window_p.hh>
#include <mln/core/image/complex_window_piter.hh>
#include <mln/debug/iota.hh>
@@ -149,6 +150,7 @@ int main()
test_morpho(ima, complex_lower_window_p<D, P>());
test_morpho(ima, complex_higher_window_p<D, P>());
+ test_morpho(ima, complex_lower_higher_window_p<D, P>());
/* FIXME: Exercise elementary erosion/dilation (with neighborhoods)
when available. */
--
1.6.0.1
* mln/core/image/complex_higher_window_p.hh: New.
* tests/morpho/complex_image_morpho.cc: Exercise this window.
---
milena/ChangeLog | 7 +
milena/mln/core/image/complex_higher_window_p.hh | 146 ++++++++++++++++++++++
milena/tests/morpho/complex_image_morpho.cc | 2 +
3 files changed, 155 insertions(+), 0 deletions(-)
create mode 100644 milena/mln/core/image/complex_higher_window_p.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index b36b7d2..4f36848 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,12 @@
2008-10-05 Roland Levillain <roland(a)lrde.epita.fr>
+ Add a centered window of higher-dimension adjacent complex faces.
+
+ * mln/core/image/complex_higher_window_p.hh: New.
+ * tests/morpho/complex_image_morpho.cc: Exercise this window.
+
+2008-10-05 Roland Levillain <roland(a)lrde.epita.fr>
+
Revamp test complex_image_morpho.
* tests/morpho/complex_image_morpho.cc: Clean up whitespaces.
diff --git a/milena/mln/core/image/complex_higher_window_p.hh b/milena/mln/core/image/complex_higher_window_p.hh
new file mode 100644
index 0000000..8e68544
--- /dev/null
+++ b/milena/mln/core/image/complex_higher_window_p.hh
@@ -0,0 +1,146 @@
+// 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_IMAGE_COMPLEX_HIGHER_WINDOW_P_HH
+# define MLN_CORE_IMAGE_COMPLEX_HIGHER_WINDOW_P_HH
+
+/// \file mln/core/complex_higher_window_p.hh
+/// \brief Definition of a window centered on a n-face of complex
+/// returning its adjacent (n+1)-faces as well as the center n-face.
+
+# include <mln/core/concept/window.hh>
+
+# include <mln/core/site_set/complex_psite.hh>
+
+# include <mln/topo/centered_iter_adapter.hh>
+# include <mln/topo/adj_higher_face_iter.hh>
+
+
+namespace mln
+{
+ // Forward declarations.
+ template <unsigned D, typename P> class complex_higher_window_p;
+ template <typename I, typename P, typename W> class complex_window_fwd_piter;
+ template <typename I, typename P, typename W> class complex_window_bkd_piter;
+
+
+ namespace trait
+ {
+
+ template <unsigned D, typename P>
+ struct window_< mln::complex_higher_window_p<D,P> >
+ {
+ typedef trait::window::size::unknown size;
+ typedef trait::window::support::irregular support;
+ typedef trait::window::definition::varying definition;
+ };
+
+ } // end of namespace mln::trait
+
+
+ /// \brief Window centered on a n-face of complex returning its
+ /// adjacent (n+1)-faces as well as the center n-face.
+ template <unsigned D, typename P>
+ class complex_higher_window_p
+ : public Window< complex_higher_window_p<D, P> >
+ {
+ typedef complex_higher_window_p<D, P> self_;
+ /// The complex iterators on the <em>adjacent</em> faces only
+ /// (without the center point).
+ /// \{
+ typedef topo::adj_higher_face_fwd_iter<D> adj_fwd_iter_;
+ typedef topo::adj_higher_face_bkd_iter<D> adj_bkd_iter_;
+ /// \}
+
+ public:
+ /// The associated complex iterators.
+ /// \{
+ typedef topo::centered_fwd_iter_adapter<D, adj_fwd_iter_> complex_fwd_iter;
+ typedef topo::centered_bkd_iter_adapter<D, adj_bkd_iter_> complex_bkd_iter;
+ /// \}
+
+ public:
+ /// Associated types.
+ /// \{
+ /// The type of psite corresponding to the window.
+ typedef complex_psite<D, P> psite;
+ /// The type of site corresponding to the window.
+ typedef mln_site(psite) site;
+
+ // FIXME: This is a dummy value.
+ typedef void dpsite;
+
+ /// \brief Site_Iterator type to browse the psites of the window
+ /// w.r.t. the ordering of vertices.
+ typedef
+ complex_window_fwd_piter<complex_fwd_iter, P, self_> fwd_qiter;
+
+ /// \brief Site_Iterator type to browse the psites of the window
+ /// w.r.t. the reverse ordering of vertices.
+ typedef
+ complex_window_bkd_piter<complex_bkd_iter, P, self_> bkd_qiter;
+
+ /// The default qiter type.
+ typedef fwd_qiter qiter;
+ /// \}
+
+ public:
+ /// Services.
+ /// \{
+ /* FIXME: mln::morpho::dilation requires these method from models
+ of concept Window, but Window does not list them in its
+ requirements. Who's guilty: morpho::dilation or Window? */
+ /// Is this window empty? (Always returns \c false).
+ bool is_empty() const;
+ /// Is this window centered? (Always returns \c true).
+ bool is_centered() const;
+ /// \}
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <unsigned D, typename P>
+ bool
+ complex_higher_window_p<D, P>::is_empty() const
+ {
+ return false;
+ }
+
+ template <unsigned D, typename P>
+ bool
+ complex_higher_window_p<D, P>::is_centered() const
+ {
+ return true;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // ! MLN_CORE_IMAGE_COMPLEX_HIGHER_WINDOW_P_HH
diff --git a/milena/tests/morpho/complex_image_morpho.cc b/milena/tests/morpho/complex_image_morpho.cc
index 98da610..c950b2c 100644
--- a/milena/tests/morpho/complex_image_morpho.cc
+++ b/milena/tests/morpho/complex_image_morpho.cc
@@ -38,6 +38,7 @@
// FIXME: Include these elsewhere? (In complex_image.hh?)
#include <mln/core/image/complex_lower_window_p.hh>
+#include <mln/core/image/complex_higher_window_p.hh>
#include <mln/core/image/complex_window_piter.hh>
#include <mln/debug/iota.hh>
@@ -147,6 +148,7 @@ int main()
`---------------------------------------------------*/
test_morpho(ima, complex_lower_window_p<D, P>());
+ test_morpho(ima, complex_higher_window_p<D, P>());
/* FIXME: Exercise elementary erosion/dilation (with neighborhoods)
when available. */
--
1.6.0.1
* mln/core/image/complex_lower_window_p.hh: New.
---
milena/ChangeLog | 6 +
milena/mln/core/image/complex_lower_window_p.hh | 146 +++++++++++++++++++++++
2 files changed, 152 insertions(+), 0 deletions(-)
create mode 100644 milena/mln/core/image/complex_lower_window_p.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 60b6c1e..f5e4b5e 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,11 @@
2008-10-04 Roland Levillain <roland(a)lrde.epita.fr>
+ Add a centered window of lower-dimension adjacent complex faces.
+
+ * mln/core/image/complex_lower_window_p.hh: New.
+
+2008-10-04 Roland Levillain <roland(a)lrde.epita.fr>
+
Add generic site iterators on complex windows.
* mln/core/image/complex_window_piter.hh: New.
diff --git a/milena/mln/core/image/complex_lower_window_p.hh b/milena/mln/core/image/complex_lower_window_p.hh
new file mode 100644
index 0000000..d346d4a
--- /dev/null
+++ b/milena/mln/core/image/complex_lower_window_p.hh
@@ -0,0 +1,146 @@
+// 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_IMAGE_COMPLEX_LOWER_WINDOW_P_HH
+# define MLN_CORE_IMAGE_COMPLEX_LOWER_WINDOW_P_HH
+
+/// \file mln/core/complex_lower_window_p.hh
+/// \brief Definition of a window centered on a n-face of complex
+/// returning its adjacent (n-1)-faces as well as the center n-face.
+
+# include <mln/core/concept/window.hh>
+
+# include <mln/core/site_set/complex_psite.hh>
+
+# include <mln/topo/centered_iter_adapter.hh>
+# include <mln/topo/adj_lower_face_iter.hh>
+
+
+namespace mln
+{
+ // Forward declarations.
+ template <unsigned D, typename P> class complex_lower_window_p;
+ template <typename I, typename P, typename W> class complex_window_fwd_piter;
+ template <typename I, typename P, typename W> class complex_window_bkd_piter;
+
+
+ namespace trait
+ {
+
+ template <unsigned D, typename P>
+ struct window_< mln::complex_lower_window_p<D,P> >
+ {
+ typedef trait::window::size::unknown size;
+ typedef trait::window::support::irregular support;
+ typedef trait::window::definition::varying definition;
+ };
+
+ } // end of namespace mln::trait
+
+
+ /// \brief Window centered on a n-face of complex returning its
+ /// adjacent (n-1)-faces as well as the center n-face.
+ template <unsigned D, typename P>
+ class complex_lower_window_p
+ : public Window< complex_lower_window_p<D, P> >
+ {
+ typedef complex_lower_window_p<D, P> self_;
+ /// The complex iterators on the <em>adjacent</em> faces only
+ /// (without the center point).
+ /// \{
+ typedef topo::adj_lower_face_fwd_iter<D> adj_fwd_iter_;
+ typedef topo::adj_lower_face_bkd_iter<D> adj_bkd_iter_;
+ /// \}
+
+ public:
+ /// The associated complex iterators.
+ /// \{
+ typedef topo::centered_fwd_iter_adapter<D, adj_fwd_iter_> complex_fwd_iter;
+ typedef topo::centered_bkd_iter_adapter<D, adj_bkd_iter_> complex_bkd_iter;
+ /// \}
+
+ public:
+ /// Associated types.
+ /// \{
+ /// The type of psite corresponding to the window.
+ typedef complex_psite<D, P> psite;
+ /// The type of site corresponding to the window.
+ typedef mln_site(psite) site;
+
+ // FIXME: This is a dummy value.
+ typedef void dpsite;
+
+ /// \brief Site_Iterator type to browse the psites of the window
+ /// w.r.t. the ordering of vertices.
+ typedef
+ complex_window_fwd_piter<complex_fwd_iter, P, self_> fwd_qiter;
+
+ /// \brief Site_Iterator type to browse the psites of the window
+ /// w.r.t. the reverse ordering of vertices.
+ typedef
+ complex_window_bkd_piter<complex_bkd_iter, P, self_> bkd_qiter;
+
+ /// The default qiter type.
+ typedef fwd_qiter qiter;
+ /// \}
+
+ public:
+ /// Services.
+ /// \{
+ /* FIXME: mln::morpho::dilation requires these method from models
+ of concept Window, but Window does not list them in its
+ requirements. Who's guilty: morpho::dilation or Window? */
+ /// Is this window empty? (Always returns \c false).
+ bool is_empty() const;
+ /// Is this window centered? (Always returns \c true).
+ bool is_centered() const;
+ /// \}
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <unsigned D, typename P>
+ bool
+ complex_lower_window_p<D, P>::is_empty() const
+ {
+ return false;
+ }
+
+ template <unsigned D, typename P>
+ bool
+ complex_lower_window_p<D, P>::is_centered() const
+ {
+ return true;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // ! MLN_CORE_IMAGE_COMPLEX_LOWER_WINDOW_P_HH
--
1.6.0.1
* mln/topo/centered_iter_adapter.hh: New.
---
milena/ChangeLog | 6 +
milena/mln/topo/centered_iter_adapter.hh | 161 ++++++++++++++++++++++++++++++
2 files changed, 167 insertions(+), 0 deletions(-)
create mode 100644 milena/mln/topo/centered_iter_adapter.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 5375a7d..c86e12a 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,11 @@
2008-10-04 Roland Levillain <roland(a)lrde.epita.fr>
+ Add a complex relative iterator adapter adding the center/ref. face.
+
+ * mln/topo/centered_iter_adapter.hh: New.
+
+2008-10-04 Roland Levillain <roland(a)lrde.epita.fr>
+
Add a complex relative iterator iterating on its center only.
* mln/topo/center_only_iter.hh: New.
diff --git a/milena/mln/topo/centered_iter_adapter.hh b/milena/mln/topo/centered_iter_adapter.hh
new file mode 100644
index 0000000..b9cb399
--- /dev/null
+++ b/milena/mln/topo/centered_iter_adapter.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_CENTERED_ITER_ADAPTER_HH
+# define MLN_TOPO_CENTERED_ITER_ADAPTER_HH
+
+/// \file mln/topo/centered_iter_adapter.hh
+/// \brief Complex relative iterator adapters adding the central
+/// (reference) point to the set of iterated faces.
+
+# include <mln/topo/internal/complex_relative_iterator_sequence.hh>
+# include <mln/topo/center_only_iter.hh>
+
+# include <mln/topo/face.hh>
+
+
+namespace mln
+{
+
+ namespace topo
+ {
+
+ /*----------------------------------------.
+ | topo::centered_fwd_iter_adapter<D, I>. |
+ `----------------------------------------*/
+
+ // FIXME: We should deduce D from I.
+
+ /// \brief Backward complex relative iterator adapters adding the
+ /// central (reference) point to the set of iterated faces.
+ ///
+ /// \arg \p D The dimension of the complex this iterator belongs to.
+ /// \arg \p I The adapated complex relative iterator.
+ template <unsigned D, typename I>
+ class centered_fwd_iter_adapter
+ : public internal::complex_relative_iterator_sequence< center_only_iter<D>,
+ I,
+ centered_fwd_iter_adapter<D, I> >
+ {
+ typedef centered_fwd_iter_adapter<D, I> self_;
+ typedef center_only_iter<D> iter1_;
+ typedef I iter2_;
+ typedef internal::complex_relative_iterator_sequence< iter1_,
+ iter2_,
+ self_ > super_;
+
+ public:
+ /// Construction.
+ /// \{
+ centered_fwd_iter_adapter();
+ template <typename Fref>
+ centered_fwd_iter_adapter(const Fref& f_ref);
+ /// \}
+ };
+
+
+ /*----------------------------------------.
+ | topo::centered_bkd_iter_adapter<D, I>. |
+ `----------------------------------------*/
+
+ // FIXME: We should deduce D from I.
+
+ /// \brief Forward complex relative iterator adapters adding the
+ /// central (reference) point to the set of iterated faces.
+ ///
+ /// \arg \p D The dimension of the complex this iterator belongs to.
+ /// \arg \p I The adapated complex relative iterator.
+ template <unsigned D, typename I>
+ class centered_bkd_iter_adapter
+ : public internal::complex_relative_iterator_sequence< I,
+ center_only_iter<D>,
+ centered_bkd_iter_adapter<D, I> >
+ {
+ typedef centered_bkd_iter_adapter<D, I> self_;
+ typedef I iter1_;
+ typedef center_only_iter<D> iter2_;
+ typedef internal::complex_relative_iterator_sequence< iter1_,
+ iter2_,
+ self_ > super_;
+
+ public:
+ /// Construction.
+ /// \{
+ centered_bkd_iter_adapter();
+ template <typename Fref>
+ centered_bkd_iter_adapter(const Fref& f_ref);
+ /// \}
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ /*----------------------------------------.
+ | topo::centered_fwd_iter_adapter<D, I>. |
+ `----------------------------------------*/
+
+ template <unsigned D, typename I>
+ inline
+ centered_fwd_iter_adapter<D, I>::centered_fwd_iter_adapter()
+ {
+ }
+
+ template <unsigned D, typename I>
+ template <typename Fref>
+ inline
+ centered_fwd_iter_adapter<D, I>::centered_fwd_iter_adapter(const Fref& f_ref)
+ : super_(f_ref)
+ {
+ }
+
+
+ /*----------------------------------------.
+ | topo::centered_bkd_iter_adapter<D, I>. |
+ `----------------------------------------*/
+
+ template <unsigned D, typename I>
+ inline
+ centered_bkd_iter_adapter<D, I>::centered_bkd_iter_adapter()
+ {
+ }
+
+ template <unsigned D, typename I>
+ template <typename Fref>
+ inline
+ centered_bkd_iter_adapter<D, I>::centered_bkd_iter_adapter(const Fref& f_ref)
+ : super_(f_ref)
+ {
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::topo
+
+} // end of namespace mln
+
+#endif // ! MLN_TOPO_CENTERED_ITER_ADAPTER_HH
--
1.6.0.1