Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- 9625 discussions
* milena/mln/topo/face.hh
(mln::topo::face_data<N, D>)
(mln::topo::n_face<N, D>)
(mln::topo::n_faces_set<N, D>):
Move...
* milena/mln/topo/face_data.hh,
* milena/mln/topo/n_face.hh,
* milena/mln/topo/n_faces_set.hh:
...here (new files).
* milena/mln/topo/complex.hh,
* milena/mln/topo/complex_faces_iter.hh,
* milena/mln/topo/complex_iter.hh,
* milena/mln/topo/faces_iter.hh:
Adjust.
* milena/tests/topo/complex.cc: Update documentation.
---
milena/ChangeLog | 20 ++
milena/mln/topo/complex.hh | 16 +-
milena/mln/topo/complex_faces_iter.hh | 1 +
milena/mln/topo/complex_iter.hh | 1 +
milena/mln/topo/face.hh | 442 +--------------------------------
milena/mln/topo/face_data.hh | 158 ++++++++++++
milena/mln/topo/faces_iter.hh | 1 +
milena/mln/topo/n_face.hh | 285 +++++++++++++++++++++
milena/mln/topo/n_faces_set.hh | 138 ++++++++++
milena/tests/topo/complex.cc | 17 +-
10 files changed, 629 insertions(+), 450 deletions(-)
create mode 100644 milena/mln/topo/face_data.hh
create mode 100644 milena/mln/topo/n_face.hh
create mode 100644 milena/mln/topo/n_faces_set.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 5a41910..9bd58d5 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,25 @@
2008-09-26 Roland Levillain <roland(a)lrde.epita.fr>
+ Split mln/topo/face.hh.
+
+ * milena/mln/topo/face.hh
+ (mln::topo::face_data<N, D>)
+ (mln::topo::n_face<N, D>)
+ (mln::topo::n_faces_set<N, D>):
+ Move...
+ * milena/mln/topo/face_data.hh,
+ * milena/mln/topo/n_face.hh,
+ * milena/mln/topo/n_faces_set.hh:
+ ...here (new files).
+ * milena/mln/topo/complex.hh,
+ * milena/mln/topo/complex_faces_iter.hh,
+ * milena/mln/topo/complex_iter.hh,
+ * milena/mln/topo/faces_iter.hh:
+ Adjust.
+ * milena/tests/topo/complex.cc: Update documentation.
+
+2008-09-26 Roland Levillain <roland(a)lrde.epita.fr>
+
Rename mln::topo::faces_set as mln::topo::n_faces_set.
* mln/topo/face.hh (mln::topo::faces_set<N, D>): Rename as...
diff --git a/milena/mln/topo/complex.hh b/milena/mln/topo/complex.hh
index 3ed8923..bef3ca9 100644
--- a/milena/mln/topo/complex.hh
+++ b/milena/mln/topo/complex.hh
@@ -43,7 +43,10 @@
# include <mln/util/tracked_ptr.hh>
+# include <mln/topo/face_data.hh>
# include <mln/topo/face.hh>
+# include <mln/topo/n_face.hh>
+# include <mln/topo/n_faces_set.hh>
# include <mln/topo/complex_iter.hh>
# include <mln/topo/faces_iter.hh>
@@ -56,7 +59,14 @@ namespace mln
namespace topo
{
- // Forward declarations.
+ // Forward declarations (external).
+ template <unsigned N, unsigned D> class n_faces_set;
+ template <unsigned D> class complex_fwd_iter_;
+ template <unsigned D> class complex_bkd_iter_;
+ template <unsigned N, unsigned D> class faces_fwd_iter_;
+ template <unsigned N, unsigned D> class faces_bkd_iter_;
+
+ // Forward declarations (internal).
namespace internal
{
template <unsigned D>
@@ -65,10 +75,6 @@ namespace mln
template <unsigned N, unsigned D>
struct faces_set_mixin;
}
- template <unsigned D> class complex_fwd_iter_;
- template <unsigned D> class complex_bkd_iter_;
- template <unsigned N, unsigned D> class faces_fwd_iter_;
- template <unsigned N, unsigned D> class faces_bkd_iter_;
/*----------.
diff --git a/milena/mln/topo/complex_faces_iter.hh b/milena/mln/topo/complex_faces_iter.hh
index 990d8d4..95d7901 100644
--- a/milena/mln/topo/complex_faces_iter.hh
+++ b/milena/mln/topo/complex_faces_iter.hh
@@ -33,6 +33,7 @@
/// of a complex.
# include <mln/topo/internal/complex_iter_base.hh>
+# include <mln/topo/face.hh>
/* FIXME: Should we drop N from the signature of these iterators?
I.e., have N be dynamic? Or better: provide other iterators where
diff --git a/milena/mln/topo/complex_iter.hh b/milena/mln/topo/complex_iter.hh
index a752892..32bbb1f 100644
--- a/milena/mln/topo/complex_iter.hh
+++ b/milena/mln/topo/complex_iter.hh
@@ -32,6 +32,7 @@
/// \brief Definition of forward and backward iterators on complexes.
# include <mln/topo/internal/complex_iter_base.hh>
+# include <mln/topo/face.hh>
// FIXME: Factor a bit more? (Using complex_iter_base_.)
diff --git a/milena/mln/topo/face.hh b/milena/mln/topo/face.hh
index e15c66a..136271c 100644
--- a/milena/mln/topo/face.hh
+++ b/milena/mln/topo/face.hh
@@ -33,236 +33,19 @@
#include <limits>
-#include <vector>
-
#include <mln/core/contract.hh>
-/* FIXME: Suggestions:
-
- Split `face', `face_handle' and `any_face_handle' code into several
- files.
-
- `face_data' is somehow an implementation detail: it should be
- hidden, either by moving it to mln/topo/complex.cc or into its own
- file in mln/topo/internal.
-
- And what about `n_faces_set'? Should we move it to its own file as
- well? */
-
namespace mln
{
namespace topo
{
- // Forward declarations (external).
+ // Forward declarations.
template <unsigned D> class complex;
- namespace internal
- {
- template <unsigned N, unsigned D> struct lower_dim_faces_set_mixin;
- template <unsigned N, unsigned D> struct higher_dim_faces_set_mixin;
- }
-
- // Forward declarations (internal).
template <unsigned N, unsigned D> class n_face;
- namespace internal
- {
- template <unsigned N, unsigned D> class lower_dim_faces_data_mixin;
- template <unsigned N, unsigned D> class higher_dim_faces_data_mixin;
- }
-
-
- /*------------.
- | Face data. |
- `------------*/
-
- /// Data (adjacent faces) associated to a \p N-face of a \p D-complex.
template <unsigned N, unsigned D> class face_data;
-
-
- // Specialization for the faces of highest dimension (\p D).
- template <unsigned D>
- class face_data<D, D> : public internal::lower_dim_faces_data_mixin<D, D>
- {
- };
-
- // Specialization for the faces of intermediate dimension (greater
- // than 0, lower than \p D).
- template <unsigned N, unsigned D>
- class face_data : public internal::lower_dim_faces_data_mixin<N, D>,
- public internal::higher_dim_faces_data_mixin<N, D>
- {
- };
-
- // Specialization for the faces of lowest dimension (0).
- template <unsigned D>
- class face_data<0u, D> : public internal::higher_dim_faces_data_mixin<0u, D>
- {
- };
-
- // Specialization for the case of a 0-complex.
- template <>
- class face_data<0u, 0u>
- {
- };
-
-
- namespace internal
- {
-
- /// Factored implementation of faces.
- /// \{
- template <unsigned N, unsigned D>
- class lower_dim_faces_data_mixin
- {
- public:
- void connect_lower_dim_face (const n_face<N - 1, D>& f);
- private:
- friend class mln::topo::internal::lower_dim_faces_set_mixin<N, D>;
- std::vector< n_face<N - 1, D> > lower_dim_faces_;
- };
-
- template <unsigned N, unsigned D>
- class higher_dim_faces_data_mixin
- {
- public:
- void connect_higher_dim_face(const n_face<N + 1, D>& f);
- private:
- friend class mln::topo::internal::higher_dim_faces_set_mixin<N, D>;
- std::vector< n_face<N + 1, D> > higher_dim_faces_;
- };
- /// \}
-
- } // end of namespace mln::topo::internal
-
-
-
- /*---------.
- | n-Face. |
- `---------*/
-
- /// \brief \p N-face handle in a complex.
- ///
- /// Contrary to an mln::topo::face, the dimension of an
- /// mln::topo::n_face is fixed.
- template <unsigned N, unsigned D>
- struct n_face
- {
- // The type of the complex this handle points to.
- typedef complex<D> complex_type;
-
- /// Build a non-initialized face handle.
- n_face();
- /// Build a face handle from \a complex and \a face_id.
- n_face(complex<D>& complex, unsigned face_id);
-
- /// Copy and assignment.
- /// \{
- n_face(const n_face<N, D>& rhs);
- n_face<N, D>& operator=(const n_face<N, D>& rhs);
- /// \}
-
- /// Is this handle valid?
- bool is_valid() const;
- /// Invalidate this handle.
- void invalidate();
-
- /// Accessors.
- /// \{
- /// Return the complex the face belongs to.
- complex<D>& cplx() const;
- /// Return the id of the face.
- // FIXME: Rename as `id'?
- unsigned face_id() const;
-
- /// Set the complex the face belongs to.
- void set_cplx(complex<D>& cplx);
- /// Return the dimension of the face.
- // FIXME: Rename as `dim'?
- unsigned n() const;
- /// Set the id of the face.
- void set_face_id(unsigned face_id);
-
- /// Return the mln::topo::face_data pointed by this handle.
- face_data<N, D>& face_data() const;
- /// \}
-
- private:
- /// \brief The complex the face belongs to.
- ///
- /// A const mln::topo::n_face can be used to modify a complex.
- mutable complex<D>* cplx_;
- /// \brief The id of the face.
- // FIXME: Rename as `id_'?
- unsigned face_id_;
- };
-
-
- /// Create a handle for \p N-face of a \p D-complex.
- template <unsigned N, unsigned D>
- n_face<N, D>
- make_n_face(const complex<D>& c, unsigned face_id);
-
-
- /// Comparison of two instances of mln::topo::n_face.
- /// \{
- /// \brief Is \a lhs equal to \a rhs?
- ///
- /// \pre Arguments \a lhs and \a rhs must belong to the same
- /// mln::topo::complex.
- template <unsigned N, unsigned D>
- bool
- operator==(const n_face<N, D>& lhs, const n_face<N, D>& rhs);
-
- /// \brief Is \a lhs ``less'' than \a rhs?
- ///
- /// This comparison is required by algorithms sorting face handles.
- ///
- /// \pre Arguments \a lhs and \a rhs must belong to the same
- /// mln::topo::complex.
- template <unsigned N, unsigned D>
- bool
- operator< (const n_face<N, D>& lhs, const n_face<N, D>& rhs);
- /// \}
-
-
- /*----------------------.
- | Set of face handles. |
- `----------------------*/
-
- /// \brief Set of face handles of dimension \p N.
- template <unsigned N, unsigned D>
- class n_faces_set
- {
- public:
- void add(const n_face<N, D>& f);
-
- /// \brief Accessors.
- ///
- /// Return the set of handles.
- /// \{
- const std::vector< n_face<N, D> >& faces() const;
- /// \}
-
- private:
- friend class complex<D>;
-
- // FIXME: Rename this as `handles_'?
- std::vector< n_face<N, D> > faces_;
- };
-
-
- /// Construction helpers for mln::topo::n_faces_set.
- /// \{
- template <unsigned N, unsigned D>
- n_faces_set<N, D>
- operator+(const n_face<N, D>& f1, const n_face<N, D>& f2);
-
- template <unsigned N, unsigned D>
- n_faces_set<N, D>
- operator+(const n_faces_set<N, D>& fs, const n_face<N, D>& f);
- /// \}
-
+
/*-------.
| Face. |
@@ -287,6 +70,7 @@ namespace mln
template <unsigned N>
face(const n_face<N, D>& f);
+ // FIXME: Probably useless.
/// Copy and assignment.
/// \{
face(const face<D>& rhs);
@@ -361,222 +145,6 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
- /*--------.
- | Faces. |
- `--------*/
-
- namespace internal
- {
- template <unsigned N, unsigned D>
- inline
- void
- lower_dim_faces_data_mixin<N, D>::connect_lower_dim_face(const n_face<N - 1, D>& f)
- {
- lower_dim_faces_.push_back(f);
- }
-
- template <unsigned N, unsigned D>
- inline
- void
- higher_dim_faces_data_mixin<N, D>::connect_higher_dim_face(const n_face<N + 1, D>& f)
- {
- higher_dim_faces_.push_back(f);
- }
-
- } // end of namespace mln::topo::internal
-
-
- /*--------------.
- | Face handle. |
- `--------------*/
-
- template <unsigned N, unsigned D>
- inline
- n_face<N, D>::n_face()
- : cplx_(0), face_id_(std::numeric_limits<unsigned>::max())
- {
- // Ensure N is compatible with D.
- metal::bool_< N <= D >::check();
- }
-
- template <unsigned N, unsigned D>
- inline
- n_face<N, D>::n_face(complex<D>& c, unsigned face_id)
- : cplx_(&c), face_id_(face_id)
- {
- // Ensure N is compatible with D.
- metal::bool_< N <= D >::check();
- }
-
- template <unsigned N, unsigned D>
- inline
- n_face<N, D>::n_face(const n_face<N, D>& rhs)
- : cplx_(rhs.cplx_), face_id_(rhs.face_id_)
- {
- // Ensure N is compatible with D.
- metal::bool_< N <= D >::check();
- }
-
- template <unsigned N, unsigned D>
- inline
- n_face<N, D>&
- n_face<N, D>::operator=(const n_face<N, D>& rhs)
- {
- if (&rhs != this)
- {
- cplx_ = rhs.cplx_;
- face_id_ = rhs.face_id_;
- }
- return *this;
- }
-
- template <unsigned N, unsigned D>
- inline
- bool
- n_face<N, D>::is_valid() const
- {
- return cplx_ != 0 && face_id_ < cplx_->template nfaces<N>();
- }
-
- template <unsigned N, unsigned D>
- inline
- void
- n_face<N, D>::invalidate()
- {
- set_face_id(std::numeric_limits<unsigned>::max());
- }
-
- template <unsigned N, unsigned D>
- inline
- complex<D>&
- n_face<N, D>::cplx() const
- {
- mln_precondition(cplx_);
- return *cplx_;
- }
-
- template <unsigned N, unsigned D>
- inline
- unsigned
- n_face<N, D>::n() const
- {
- return N;
- }
-
- template <unsigned N, unsigned D>
- inline
- unsigned
- n_face<N, D>::face_id() const
- {
- return face_id_;
- }
-
- template <unsigned N, unsigned D>
- inline
- void
- n_face<N, D>::set_cplx(complex<D>& cplx)
- {
- cplx_ = &cplx;
- }
-
- template <unsigned N, unsigned D>
- inline
- void
- n_face<N, D>::set_face_id(unsigned face_id)
- {
- face_id_ = face_id;
- }
-
- template <unsigned N, unsigned D>
- inline
- face_data<N, D>&
- n_face<N, D>::face_data() const
- {
- mln_precondition(is_valid());
- return cplx_->template face_data_<N>(face_id_);
- }
-
-
- template <unsigned N, unsigned D>
- inline
- n_face<N, D>
- make_n_face(const complex<D>& c, unsigned face_id)
- {
- return n_face<N, D>(&c, face_id);
- }
-
-
- template <unsigned N, unsigned D>
- inline
- bool
- operator==(const n_face<N, D>& lhs, const n_face<N, D>& rhs)
- {
- // Ensure LHS and RHS belong to the same complex.
- mln_precondition(&lhs.face.cplx() == &rhs.face.cplx());
- return lhs.face().id() == rhs.face().id();
- }
-
- template <unsigned N, unsigned D>
- inline
- bool
- operator< (const n_face<N, D>& lhs, const n_face<N, D>& rhs)
- {
- // Ensure LHS and RHS belong to the same complex.
- mln_precondition(&lhs.face.cplx() == &rhs.face.cplx());
- return lhs.face().id() < rhs.face().id();
- }
-
-
- /*---------------.
- | Set of faces. |
- `---------------*/
-
- template <unsigned N, unsigned D>
- inline
- void
- n_faces_set<N, D>::add(const n_face<N, D>& f)
- {
- // Check consistency.
- if (!faces_.empty())
- mln_precondition(&faces_.front().cplx() == &f.cplx());
- faces_.push_back(f);
- }
-
- template <unsigned N, unsigned D>
- inline
- const std::vector< n_face<N, D> >&
- n_faces_set<N, D>::faces() const
- {
- return faces_;
- }
-
-
- template <unsigned N, unsigned D>
- inline
- n_faces_set<N, D>
- operator+(const n_face<N, D>& f1, const n_face<N, D>& f2)
- {
- n_faces_set<N, D> fs;
- fs.add(f1);
- fs.add(f2);
- return fs;
- }
-
- template <unsigned N, unsigned D>
- inline
- n_faces_set<N, D>
- operator+(const n_faces_set<N, D>& fs, const n_face<N, D>& f)
- {
- n_faces_set<N, D> fs2(fs);
- fs2.add(f);
- return fs2;
- }
-
-
- /*----------------------.
- | ``Any-face'' handle. |
- `----------------------*/
-
template <unsigned D>
inline
face<D>::face()
@@ -588,8 +156,7 @@ namespace mln
template <unsigned D>
inline
- face<D>::face(complex<D>& c, unsigned n,
- unsigned face_id)
+ face<D>::face(complex<D>& c, unsigned n, unsigned face_id)
: cplx_(&c), n_(n), face_id_(face_id)
{
// Ensure N is compatible with D.
@@ -718,7 +285,6 @@ namespace mln
lhs.face().id() == rhs.face().id();
}
-
template <unsigned D>
inline
bool
diff --git a/milena/mln/topo/face_data.hh b/milena/mln/topo/face_data.hh
new file mode 100644
index 0000000..7c94ddd
--- /dev/null
+++ b/milena/mln/topo/face_data.hh
@@ -0,0 +1,158 @@
+// 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_FACE_DATA_HH
+# define MLN_TOPO_FACE_DATA_HH
+
+/// \file mln/topo/face_data.hh
+/// \brief Data associated to the faces of a complex.
+///
+/// These data are actually lists of adjacent faces (of lower and
+/// higher dimensions).
+
+# include <vector>
+
+# include <mln/topo/n_face.hh>
+
+
+namespace mln
+{
+
+ namespace topo
+ {
+
+ // Forward declarations (external).
+ template <unsigned D> class complex;
+ namespace internal
+ {
+ template <unsigned N, unsigned D> struct lower_dim_faces_set_mixin;
+ template <unsigned N, unsigned D> struct higher_dim_faces_set_mixin;
+ }
+
+ // Forward declarations (internal).
+ template <unsigned N, unsigned D> class n_face;
+ namespace internal
+ {
+ template <unsigned N, unsigned D> class lower_dim_faces_data_mixin;
+ template <unsigned N, unsigned D> class higher_dim_faces_data_mixin;
+ }
+
+
+ /*------------.
+ | Face data. |
+ `------------*/
+
+ /// Data (adjacent faces) associated to a \p N-face of a \p D-complex.
+ template <unsigned N, unsigned D> class face_data;
+
+
+ // Specialization for the faces of highest dimension (\p D).
+ template <unsigned D>
+ class face_data<D, D> : public internal::lower_dim_faces_data_mixin<D, D>
+ {
+ };
+
+ // Specialization for the faces of intermediate dimension (greater
+ // than 0, lower than \p D).
+ template <unsigned N, unsigned D>
+ class face_data : public internal::lower_dim_faces_data_mixin<N, D>,
+ public internal::higher_dim_faces_data_mixin<N, D>
+ {
+ };
+
+ // Specialization for the faces of lowest dimension (0).
+ template <unsigned D>
+ class face_data<0u, D> : public internal::higher_dim_faces_data_mixin<0u, D>
+ {
+ };
+
+ // Specialization for the case of a 0-complex.
+ template <>
+ class face_data<0u, 0u>
+ {
+ };
+
+
+ namespace internal
+ {
+
+ /// Factored implementation of faces.
+ /// \{
+ template <unsigned N, unsigned D>
+ class lower_dim_faces_data_mixin
+ {
+ public:
+ void connect_lower_dim_face (const n_face<N - 1, D>& f);
+ private:
+ friend class mln::topo::internal::lower_dim_faces_set_mixin<N, D>;
+ std::vector< n_face<N - 1, D> > lower_dim_faces_;
+ };
+
+ template <unsigned N, unsigned D>
+ class higher_dim_faces_data_mixin
+ {
+ public:
+ void connect_higher_dim_face(const n_face<N + 1, D>& f);
+ private:
+ friend class mln::topo::internal::higher_dim_faces_set_mixin<N, D>;
+ std::vector< n_face<N + 1, D> > higher_dim_faces_;
+ };
+ /// \}
+
+ } // end of namespace mln::topo::internal
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace internal
+ {
+ template <unsigned N, unsigned D>
+ inline
+ void
+ lower_dim_faces_data_mixin<N, D>::connect_lower_dim_face(const n_face<N - 1, D>& f)
+ {
+ lower_dim_faces_.push_back(f);
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ void
+ higher_dim_faces_data_mixin<N, D>::connect_higher_dim_face(const n_face<N + 1, D>& f)
+ {
+ higher_dim_faces_.push_back(f);
+ }
+
+ } // end of namespace mln::topo::internal
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::topo
+
+} // end of namespace mln
+
+#endif // ! MLN_TOPO_FACE_DATA_HH
diff --git a/milena/mln/topo/faces_iter.hh b/milena/mln/topo/faces_iter.hh
index 1ad756b..509ed9c 100644
--- a/milena/mln/topo/faces_iter.hh
+++ b/milena/mln/topo/faces_iter.hh
@@ -33,6 +33,7 @@
/// of a complex.
# include <mln/topo/internal/complex_iter_base.hh>
+# include <mln/topo/n_face.hh>
namespace mln
{
diff --git a/milena/mln/topo/n_face.hh b/milena/mln/topo/n_face.hh
new file mode 100644
index 0000000..afeb4ab
--- /dev/null
+++ b/milena/mln/topo/n_face.hh
@@ -0,0 +1,285 @@
+// 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_N_FACE_HH
+# define MLN_TOPO_N_FACE_HH
+
+/// \file mln/topo/n_face.hh
+/// \brief n-face of a complex.
+
+#include <limits>
+
+#include <mln/core/contract.hh>
+
+
+namespace mln
+{
+
+ namespace topo
+ {
+
+ // Forward declaration.
+ template <unsigned D> class complex;
+ template <unsigned N, unsigned D> class face_data;
+
+
+ /*---------.
+ | n-Face. |
+ `---------*/
+
+ /// \brief \p N-face handle in a complex.
+ ///
+ /// Contrary to an mln::topo::face, the dimension of an
+ /// mln::topo::n_face is fixed.
+ template <unsigned N, unsigned D>
+ struct n_face
+ {
+ // The type of the complex this handle points to.
+ typedef complex<D> complex_type;
+
+ /// Build a non-initialized face handle.
+ n_face();
+ /// Build a face handle from \a complex and \a face_id.
+ n_face(complex<D>& complex, unsigned face_id);
+
+ // FIXME: Probably useless.
+ /// Copy and assignment.
+ /// \{
+ n_face(const n_face<N, D>& rhs);
+ n_face<N, D>& operator=(const n_face<N, D>& rhs);
+ /// \}
+
+ /// Is this handle valid?
+ bool is_valid() const;
+ /// Invalidate this handle.
+ void invalidate();
+
+ /// Accessors.
+ /// \{
+ /// Return the complex the face belongs to.
+ complex<D>& cplx() const;
+ /// Return the id of the face.
+ // FIXME: Rename as `id'?
+ unsigned face_id() const;
+
+ /// Set the complex the face belongs to.
+ void set_cplx(complex<D>& cplx);
+ /// Return the dimension of the face.
+ // FIXME: Rename as `dim'?
+ unsigned n() const;
+ /// Set the id of the face.
+ void set_face_id(unsigned face_id);
+
+ /// Return the mln::topo::face_data pointed by this handle.
+ face_data<N, D>& face_data() const;
+ /// \}
+
+ private:
+ /// \brief The complex the face belongs to.
+ ///
+ /// A const mln::topo::n_face can be used to modify a complex.
+ mutable complex<D>* cplx_;
+ /// \brief The id of the face.
+ // FIXME: Rename as `id_'?
+ unsigned face_id_;
+ };
+
+
+ /// Create a handle for \p N-face of a \p D-complex.
+ template <unsigned N, unsigned D>
+ n_face<N, D>
+ make_n_face(const complex<D>& c, unsigned face_id);
+
+
+ /// Comparison of two instances of mln::topo::n_face.
+ /// \{
+ /// \brief Is \a lhs equal to \a rhs?
+ ///
+ /// \pre Arguments \a lhs and \a rhs must belong to the same
+ /// mln::topo::complex.
+ template <unsigned N, unsigned D>
+ bool
+ operator==(const n_face<N, D>& lhs, const n_face<N, D>& rhs);
+
+ /// \brief Is \a lhs ``less'' than \a rhs?
+ ///
+ /// This comparison is required by algorithms sorting face handles.
+ ///
+ /// \pre Arguments \a lhs and \a rhs must belong to the same
+ /// mln::topo::complex.
+ template <unsigned N, unsigned D>
+ bool
+ operator< (const n_face<N, D>& lhs, const n_face<N, D>& rhs);
+ /// \}
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <unsigned N, unsigned D>
+ inline
+ n_face<N, D>::n_face()
+ : cplx_(0), face_id_(std::numeric_limits<unsigned>::max())
+ {
+ // Ensure N is compatible with D.
+ metal::bool_< N <= D >::check();
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ n_face<N, D>::n_face(complex<D>& c, unsigned face_id)
+ : cplx_(&c), face_id_(face_id)
+ {
+ // Ensure N is compatible with D.
+ metal::bool_< N <= D >::check();
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ n_face<N, D>::n_face(const n_face<N, D>& rhs)
+ : cplx_(rhs.cplx_), face_id_(rhs.face_id_)
+ {
+ // Ensure N is compatible with D.
+ metal::bool_< N <= D >::check();
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ n_face<N, D>&
+ n_face<N, D>::operator=(const n_face<N, D>& rhs)
+ {
+ if (&rhs != this)
+ {
+ cplx_ = rhs.cplx_;
+ face_id_ = rhs.face_id_;
+ }
+ return *this;
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ bool
+ n_face<N, D>::is_valid() const
+ {
+ return cplx_ != 0 && face_id_ < cplx_->template nfaces<N>();
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ void
+ n_face<N, D>::invalidate()
+ {
+ set_face_id(std::numeric_limits<unsigned>::max());
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ complex<D>&
+ n_face<N, D>::cplx() const
+ {
+ mln_precondition(cplx_);
+ return *cplx_;
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ unsigned
+ n_face<N, D>::n() const
+ {
+ return N;
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ unsigned
+ n_face<N, D>::face_id() const
+ {
+ return face_id_;
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ void
+ n_face<N, D>::set_cplx(complex<D>& cplx)
+ {
+ cplx_ = &cplx;
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ void
+ n_face<N, D>::set_face_id(unsigned face_id)
+ {
+ face_id_ = face_id;
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ face_data<N, D>&
+ n_face<N, D>::face_data() const
+ {
+ mln_precondition(is_valid());
+ return cplx_->template face_data_<N>(face_id_);
+ }
+
+
+ template <unsigned N, unsigned D>
+ inline
+ n_face<N, D>
+ make_n_face(const complex<D>& c, unsigned face_id)
+ {
+ return n_face<N, D>(&c, face_id);
+ }
+
+
+ template <unsigned N, unsigned D>
+ inline
+ bool
+ operator==(const n_face<N, D>& lhs, const n_face<N, D>& rhs)
+ {
+ // Ensure LHS and RHS belong to the same complex.
+ mln_precondition(&lhs.face.cplx() == &rhs.face.cplx());
+ return lhs.face().id() == rhs.face().id();
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ bool
+ operator< (const n_face<N, D>& lhs, const n_face<N, D>& rhs)
+ {
+ // Ensure LHS and RHS belong to the same complex.
+ mln_precondition(&lhs.face.cplx() == &rhs.face.cplx());
+ return lhs.face().id() < rhs.face().id();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::topo
+
+} // end of namespace mln
+
+#endif // ! MLN_TOPO_N_FACE_HH
diff --git a/milena/mln/topo/n_faces_set.hh b/milena/mln/topo/n_faces_set.hh
new file mode 100644
index 0000000..65f56d9
--- /dev/null
+++ b/milena/mln/topo/n_faces_set.hh
@@ -0,0 +1,138 @@
+// 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_N_FACES_SET_HH
+# define MLN_TOPO_N_FACES_SET_HH
+
+/// \file mln/topo/n_face_set.hh
+/// \brief Set of n-face of a complex.
+
+#include <vector>
+
+#include <mln/core/contract.hh>
+#include <mln/topo/n_face.hh>
+
+
+namespace mln
+{
+
+ namespace topo
+ {
+
+ // Forward declaration.
+ template <unsigned D> class complex;
+
+
+ /*------------------------.
+ | Set of n-face handles. |
+ `------------------------*/
+
+ /// \brief Set of face handles of dimension \p N.
+ template <unsigned N, unsigned D>
+ class n_faces_set
+ {
+ public:
+ void add(const n_face<N, D>& f);
+
+ /// \brief Accessors.
+ ///
+ /// Return the set of handles.
+ /// \{
+ const std::vector< n_face<N, D> >& faces() const;
+ /// \}
+
+ private:
+ friend class complex<D>;
+
+ // FIXME: Rename this as `handles_'?
+ std::vector< n_face<N, D> > faces_;
+ };
+
+
+ /// Construction helpers for mln::topo::n_faces_set.
+ /// \{
+ template <unsigned N, unsigned D>
+ n_faces_set<N, D>
+ operator+(const n_face<N, D>& f1, const n_face<N, D>& f2);
+
+ template <unsigned N, unsigned D>
+ n_faces_set<N, D>
+ operator+(const n_faces_set<N, D>& fs, const n_face<N, D>& f);
+ /// \}
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <unsigned N, unsigned D>
+ inline
+ void
+ n_faces_set<N, D>::add(const n_face<N, D>& f)
+ {
+ // Check consistency.
+ if (!faces_.empty())
+ mln_precondition(&faces_.front().cplx() == &f.cplx());
+ faces_.push_back(f);
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ const std::vector< n_face<N, D> >&
+ n_faces_set<N, D>::faces() const
+ {
+ return faces_;
+ }
+
+
+ template <unsigned N, unsigned D>
+ inline
+ n_faces_set<N, D>
+ operator+(const n_face<N, D>& f1, const n_face<N, D>& f2)
+ {
+ n_faces_set<N, D> fs;
+ fs.add(f1);
+ fs.add(f2);
+ return fs;
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ n_faces_set<N, D>
+ operator+(const n_faces_set<N, D>& fs, const n_face<N, D>& f)
+ {
+ n_faces_set<N, D> fs2(fs);
+ fs2.add(f);
+ return fs2;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::topo
+
+} // end of namespace mln
+
+#endif // ! MLN_TOPO_N_FACES_SET_HH
diff --git a/milena/tests/topo/complex.cc b/milena/tests/topo/complex.cc
index ebe734a..6b8c17e 100644
--- a/milena/tests/topo/complex.cc
+++ b/milena/tests/topo/complex.cc
@@ -189,15 +189,15 @@ int main()
But first, we need to clarify (existing) names.
-----------------------------------------------------------------
- Current/old name New name Definition
+ Current name New name Definition
-----------------------------------------------------------------
complex<D> (n/a) General complex
-
- face<N, D> face_data<N, D> Face data
- face_handle<N, D> n_face<N, D> (Static) n-face handle
- faces_set<N, D> n_faces_set<N, D> Set of face handles
- any_face_handle<D> face<D> Dynamic face handle
-
+
+ face_data<N, D> (n/a) Face data
+ n_face<N, D> (n/a) (Static) n-face handle
+ n_faces_set<N, D> (n/a) Set of face handles
+ face<D> (n/a) Dynamic face handle
+
complex_fwd_iter_<D>(c) face_fwd_iter<D>(c) | Iterators on all
complex_bkd_iter_<D>(c) face_bkd_iter<D>(c) | faces of c
@@ -209,6 +209,9 @@ int main()
(Note: get rid of trailing underscores, even for entities in
mln::internal::.)
+ And likewise for image-related entities!
+
+
Next, write these:
-----------------------------------------------------------------
--
1.6.0.1
1
0
26 Sep '08
* mln/topo/face.hh (mln::topo::faces_set<N, D>): Rename as...
(mln::topo::n_faces_set<N, D>): ...this.
Adjust.
* mln/topo/complex.hh: Adjust.
---
milena/ChangeLog | 9 +++++++++
milena/mln/topo/complex.hh | 10 +++++-----
milena/mln/topo/face.hh | 30 ++++++++++++++----------------
3 files changed, 28 insertions(+), 21 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index ded9680..5a41910 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,14 @@
2008-09-26 Roland Levillain <roland(a)lrde.epita.fr>
+ Rename mln::topo::faces_set as mln::topo::n_faces_set.
+
+ * mln/topo/face.hh (mln::topo::faces_set<N, D>): Rename as...
+ (mln::topo::n_faces_set<N, D>): ...this.
+ Adjust.
+ * mln/topo/complex.hh: Adjust.
+
+2008-09-26 Roland Levillain <roland(a)lrde.epita.fr>
+
Rename mln::topo::any_face_handle as mln::topo::face.
* mln/topo/face.hh (mln::topo::any_face_handle<D>): Rename as...
diff --git a/milena/mln/topo/complex.hh b/milena/mln/topo/complex.hh
index de6fb90..3ed8923 100644
--- a/milena/mln/topo/complex.hh
+++ b/milena/mln/topo/complex.hh
@@ -105,7 +105,7 @@ namespace mln
/// \param adjacent_faces The (\p N-1)-faces adjacent to the new
/// \p N-face.
template <unsigned N>
- n_face<N + 1, D> add_face(const faces_set<N, D>& adjacent_faces);
+ n_face<N + 1, D> add_face(const n_faces_set<N, D>& adjacent_faces);
/// \}
/// \brief Static manipulators.
@@ -128,8 +128,8 @@ namespace mln
/// \brief Return the number of \a n-faces.
///
/// Warning, this function has a complexity linear in term of N,
- /// since each faces_set is checked (the present implementation
- /// does not provide a direct access to faces_set through a
+ /// since each n_faces_set is checked (the present implementation
+ /// does not provide a direct access to n_faces_set through a
/// dynamic value of the dimension).
std::size_t nfaces(unsigned n) const;
/// \}
@@ -171,7 +171,7 @@ namespace mln
/* FIXME: Replace F and ACCU by a Milena accumulator? */
/** \brief Apply a kind of static fold left operator to the
- implicit list of faces_set using a functor \a f and a value \a
+ implicit list of n_faces_set using a functor \a f and a value \a
accu.
Argument \a is called an "accumulator", but with a slightly
@@ -420,7 +420,7 @@ namespace mln
template <unsigned D>
template <unsigned N>
n_face<N + 1, D>
- complex<D>::add_face(const faces_set<N, D>& adjacent_faces)
+ complex<D>::add_face(const n_faces_set<N, D>& adjacent_faces)
{
typedef typename std::vector< n_face<N, D> >::const_iterator iter_t;
diff --git a/milena/mln/topo/face.hh b/milena/mln/topo/face.hh
index 85c2fef..e15c66a 100644
--- a/milena/mln/topo/face.hh
+++ b/milena/mln/topo/face.hh
@@ -39,8 +39,6 @@
/* FIXME: Suggestions:
- Rename faces_set as n_faces_set.
-
Split `face', `face_handle' and `any_face_handle' code into several
files.
@@ -48,8 +46,8 @@
hidden, either by moving it to mln/topo/complex.cc or into its own
file in mln/topo/internal.
- (And what about `faces_set'? Should we move it to its own file as
- well?) */
+ And what about `n_faces_set'? Should we move it to its own file as
+ well? */
namespace mln
{
@@ -234,7 +232,7 @@ namespace mln
/// \brief Set of face handles of dimension \p N.
template <unsigned N, unsigned D>
- class faces_set
+ class n_faces_set
{
public:
void add(const n_face<N, D>& f);
@@ -254,15 +252,15 @@ namespace mln
};
- /// Construction helpers for mln::topo::faces_set.
+ /// Construction helpers for mln::topo::n_faces_set.
/// \{
template <unsigned N, unsigned D>
- faces_set<N, D>
+ n_faces_set<N, D>
operator+(const n_face<N, D>& f1, const n_face<N, D>& f2);
template <unsigned N, unsigned D>
- faces_set<N, D>
- operator+(const faces_set<N, D>& fs, const n_face<N, D>& f);
+ n_faces_set<N, D>
+ operator+(const n_faces_set<N, D>& fs, const n_face<N, D>& f);
/// \}
@@ -536,7 +534,7 @@ namespace mln
template <unsigned N, unsigned D>
inline
void
- faces_set<N, D>::add(const n_face<N, D>& f)
+ n_faces_set<N, D>::add(const n_face<N, D>& f)
{
// Check consistency.
if (!faces_.empty())
@@ -547,7 +545,7 @@ namespace mln
template <unsigned N, unsigned D>
inline
const std::vector< n_face<N, D> >&
- faces_set<N, D>::faces() const
+ n_faces_set<N, D>::faces() const
{
return faces_;
}
@@ -555,10 +553,10 @@ namespace mln
template <unsigned N, unsigned D>
inline
- faces_set<N, D>
+ n_faces_set<N, D>
operator+(const n_face<N, D>& f1, const n_face<N, D>& f2)
{
- faces_set<N, D> fs;
+ n_faces_set<N, D> fs;
fs.add(f1);
fs.add(f2);
return fs;
@@ -566,10 +564,10 @@ namespace mln
template <unsigned N, unsigned D>
inline
- faces_set<N, D>
- operator+(const faces_set<N, D>& fs, const n_face<N, D>& f)
+ n_faces_set<N, D>
+ operator+(const n_faces_set<N, D>& fs, const n_face<N, D>& f)
{
- faces_set<N, D> fs2(fs);
+ n_faces_set<N, D> fs2(fs);
fs2.add(f);
return fs2;
}
--
1.6.0.1
1
0
26 Sep '08
* mln/topo/face.hh (mln::topo::any_face_handle<D>): Rename as...
(mln::topo::face<D>): ...this.
Adjust.
* mln/topo/complex.hh,
* mln/topo/complex_iter.hh,
* mln/topo/complex_faces_iter.hh,
* tests/topo/complex.cc:
Adjust.
* mln/core/site_set/p_complex.hh: Update documentation.
* mln/core/site_set/complex_psite.hh,
* tests/core/image/complex_image.cc:
Adjust.
---
milena/ChangeLog | 18 ++++++
milena/mln/core/site_set/complex_psite.hh | 10 ++--
milena/mln/core/site_set/p_complex.hh | 15 +++---
milena/mln/topo/complex.hh | 2 +-
milena/mln/topo/complex_faces_iter.hh | 12 ++--
milena/mln/topo/complex_iter.hh | 12 ++--
milena/mln/topo/face.hh | 81 +++++++++++++++--------------
milena/tests/core/image/complex_image.cc | 2 +-
milena/tests/topo/complex.cc | 6 +-
9 files changed, 89 insertions(+), 69 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index dfdd15b..ded9680 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,23 @@
2008-09-26 Roland Levillain <roland(a)lrde.epita.fr>
+ Rename mln::topo::any_face_handle as mln::topo::face.
+
+ * mln/topo/face.hh (mln::topo::any_face_handle<D>): Rename as...
+ (mln::topo::face<D>): ...this.
+ Adjust.
+ * mln/topo/complex.hh,
+ * mln/topo/complex_iter.hh,
+ * mln/topo/complex_faces_iter.hh,
+ * tests/topo/complex.cc:
+ Adjust.
+
+ * mln/core/site_set/p_complex.hh: Update documentation.
+ * mln/core/site_set/complex_psite.hh,
+ * tests/core/image/complex_image.cc:
+ Adjust.
+
+2008-09-26 Roland Levillain <roland(a)lrde.epita.fr>
+
Rename mln::topo::face_handle as mln::topo::n_face.
* mln/topo/face.hh (mln::topo::face_handle<N, D>): Rename as...
diff --git a/milena/mln/core/site_set/complex_psite.hh b/milena/mln/core/site_set/complex_psite.hh
index 71dd84e..02ab19e 100644
--- a/milena/mln/core/site_set/complex_psite.hh
+++ b/milena/mln/core/site_set/complex_psite.hh
@@ -73,7 +73,7 @@ namespace mln
complex_psite();
/// \pre pc.cplx() == face.cplx().
complex_psite(const p_complex<D, P>& pc,
- const topo::any_face_handle<D>& face);
+ const topo::face<D>& face);
complex_psite(const p_complex<D, P>& pc, unsigned n, unsigned face_id);
/// \}
@@ -107,7 +107,7 @@ namespace mln
/// Face handle manipulators.
/// \{
/// Return the face handle of this point site.
- topo::any_face_handle<D> face() const;
+ topo::face<D> face() const;
/// Return the dimension of the face of this psite.
unsigned n() const;
@@ -142,7 +142,7 @@ namespace mln
/// The mln::p_faces this point site belongs to.
const target* pc_;
/// The handle of the face this psite is pointing towards.
- topo::any_face_handle<D> face_;
+ topo::face<D> face_;
/// \}
};
@@ -209,7 +209,7 @@ namespace mln
template <unsigned D, typename P>
inline
complex_psite<D, P>::complex_psite(const p_complex<D, P>& pc,
- const topo::any_face_handle<D>& face)
+ const topo::face<D>& face)
: pc_(&pc),
face_(face)
{
@@ -289,7 +289,7 @@ namespace mln
template <unsigned D, typename P>
inline
- topo::any_face_handle<D>
+ topo::face<D>
complex_psite<D, P>::face() const
{
return face_;
diff --git a/milena/mln/core/site_set/p_complex.hh b/milena/mln/core/site_set/p_complex.hh
index 206cd34..a747b69 100644
--- a/milena/mln/core/site_set/p_complex.hh
+++ b/milena/mln/core/site_set/p_complex.hh
@@ -167,18 +167,17 @@ namespace mln
private:
/// The complex on which this pset is built.
/* FIXME: Get rid of this `mutable' qualifier. This is needed for
- compatiblity reasons with any_face_handle (see
- p_complex_piter).
+ compatiblity reasons with topo::face (see p_complex_piter).
We should either
- - have an additional version of any_face_handle holding a
- const (not mutable) complex;
+ - have an additional version of topo::face holding a const (not
+ mutable) complex;
- - have face_handle and any_face_handle do not hold a reference
- on a complex, leading to a design of complexes similar to
- graphs, where vertex and edge handles (named `id's) are not
- tied to a specific graph. */
+ - have face_handle and topo::face do not hold a reference on a
+ complex, leading to a design of complexes similar to graphs,
+ where vertex and edge handles (named `id's) are not tied to a
+ specific graph. */
mutable topo::complex<D> cplx_;
};
diff --git a/milena/mln/topo/complex.hh b/milena/mln/topo/complex.hh
index 021e788..de6fb90 100644
--- a/milena/mln/topo/complex.hh
+++ b/milena/mln/topo/complex.hh
@@ -153,7 +153,7 @@ namespace mln
/// Accessors.
/// \{
template <unsigned N, unsigned D_> friend class n_face;
- template <unsigned D_> friend class any_face_handle;
+ template <unsigned D_> friend class face;
template <unsigned N>
face_data<N, D>& face_data_(unsigned face_id);
diff --git a/milena/mln/topo/complex_faces_iter.hh b/milena/mln/topo/complex_faces_iter.hh
index 05713da..990d8d4 100644
--- a/milena/mln/topo/complex_faces_iter.hh
+++ b/milena/mln/topo/complex_faces_iter.hh
@@ -55,12 +55,12 @@ namespace mln
/// \arg \p D The dimension of the complex this iterator belongs to.
template <unsigned N, unsigned D>
class complex_faces_fwd_iter_
- : public internal::complex_iter_base_< any_face_handle<D>,
+ : public internal::complex_iter_base_< face<D>,
complex_faces_fwd_iter_<N, D> >
{
public:
/// Type of associated face.
- typedef any_face_handle<D> face;
+ typedef face<D> face;
private:
typedef complex_faces_fwd_iter_<N, D> self_;
@@ -101,12 +101,12 @@ namespace mln
/// \arg \p D The dimension of the complex this iterator belongs to.
template <unsigned N, unsigned D>
class complex_faces_bkd_iter_
- : public internal::complex_iter_base_< any_face_handle<D>,
+ : public internal::complex_iter_base_< face<D>,
complex_faces_bkd_iter_<N, D> >
{
public:
/// Type of associated face.
- typedef any_face_handle<D> face;
+ typedef face<D> face;
private:
typedef complex_faces_bkd_iter_<N, D> self_;
@@ -183,7 +183,7 @@ namespace mln
{
unsigned face_id = face_.face_id();
if (face_id + 1 < face_.cplx().template nfaces<N>())
- /* FIXME: Provide accessor any_face_handle::face_id()
+ /* FIXME: Provide accessor face::face_id()
returning a mutable reference? This way, we could just
write
@@ -242,7 +242,7 @@ namespace mln
{
unsigned face_id = face_.face_id();
if (face_id > 0)
- /* FIXME: Provide accessor any_face_handle::face_id()
+ /* FIXME: Provide accessor face::face_id()
returning a mutable reference? This way, we could just
write
diff --git a/milena/mln/topo/complex_iter.hh b/milena/mln/topo/complex_iter.hh
index b30ca00..a752892 100644
--- a/milena/mln/topo/complex_iter.hh
+++ b/milena/mln/topo/complex_iter.hh
@@ -55,12 +55,12 @@ namespace mln
/// \arg \p D The dimension of the complex this iterator belongs to.
template <unsigned D>
class complex_fwd_iter_
- : public internal::complex_iter_base_< any_face_handle<D>,
+ : public internal::complex_iter_base_< face<D>,
complex_fwd_iter_<D> >
{
public:
/// Type of associated face.
- typedef any_face_handle<D> face;
+ typedef face<D> face;
private:
typedef complex_fwd_iter_<D> self_;
@@ -100,12 +100,12 @@ namespace mln
/// \arg \p D The dimension of the complex this iterator belongs to.
template <unsigned D>
class complex_bkd_iter_
- : public internal::complex_iter_base_< any_face_handle<D>,
+ : public internal::complex_iter_base_< face<D>,
complex_bkd_iter_<D> >
{
public:
/// Type of associated face.
- typedef any_face_handle<D> face;
+ typedef face<D> face;
private:
typedef complex_bkd_iter_<D> self_;
@@ -179,7 +179,7 @@ namespace mln
unsigned face_id = face_.face_id();
if (face_id + 1 < face_.cplx().nfaces(n))
- /* FIXME: Provide accessor any_face_handle::face_id() returning
+ /* FIXME: Provide accessor face::face_id() returning
a mutable reference? This way, we could just write
++face_.face_id();
@@ -243,7 +243,7 @@ namespace mln
unsigned face_id = face_.face_id();
if (face_id > 0)
- /* FIXME: Provide accessor any_face_handle::face_id() returning
+ /* FIXME: Provide accessor face::face_id() returning
a mutable reference? This way, we could just write
++face_.face_id();
diff --git a/milena/mln/topo/face.hh b/milena/mln/topo/face.hh
index 4aab366..85c2fef 100644
--- a/milena/mln/topo/face.hh
+++ b/milena/mln/topo/face.hh
@@ -39,13 +39,10 @@
/* FIXME: Suggestions:
- - rename `face' as `face_data', and move it into complex.hh or its
- own file;
- - rename `face_handle' as `face', and move it to its own file;
- - rename `any_face_handle' as `any_face', and move it to its own file.
+ Rename faces_set as n_faces_set.
- Anyway, whatever the decision, splitting `face', `face_handle' and
- `any_face_handle' seems to be sound.
+ Split `face', `face_handle' and `any_face_handle' code into several
+ files.
`face_data' is somehow an implementation detail: it should be
hidden, either by moving it to mln/topo/complex.cc or into its own
@@ -146,7 +143,10 @@ namespace mln
| n-Face. |
`---------*/
- // \p N-face handle in a complex.
+ /// \brief \p N-face handle in a complex.
+ ///
+ /// Contrary to an mln::topo::face, the dimension of an
+ /// mln::topo::n_face is fixed.
template <unsigned N, unsigned D>
struct n_face
{
@@ -266,30 +266,33 @@ namespace mln
/// \}
- /*----------------------.
- | ``Any-face'' handle. |
- `----------------------*/
+ /*-------.
+ | Face. |
+ `-------*/
- // Face handle in a complex, where the dimension is dynamic.
+ /// \brief Face handle in a complex; the face dimension is dynamic.
+ ///
+ /// Contrary to an mln::topo::n_face, the dimension of an
+ /// mln::topo::face is not fixed.
template <unsigned D>
- struct any_face_handle
+ struct face
{
// The type of the complex this handle points to.
typedef complex<D> complex_type;
/// Build a non-initialized face handle.
- any_face_handle();
+ face();
/// Build a face handle from \a complex and \a face_id.
- any_face_handle(complex<D>& complex, unsigned n, unsigned face_id);
+ face(complex<D>& complex, unsigned n, unsigned face_id);
- /// Build a face handle from a face_handle.
+ /// Build a face handle from an mln::topo::n_face.
template <unsigned N>
- any_face_handle(const n_face<N, D>& f);
+ face(const n_face<N, D>& f);
/// Copy and assignment.
/// \{
- any_face_handle(const any_face_handle<D>& rhs);
- any_face_handle<D>& operator=(const any_face_handle<D>& rhs);
+ face(const face<D>& rhs);
+ face<D>& operator=(const face<D>& rhs);
/// \}
/// Is this handle valid?
@@ -323,7 +326,7 @@ namespace mln
private:
/// \brief The complex the face belongs to.
///
- /// A const any_face_handle can be used to modify a complex.
+ /// A const face can be used to modify a complex.
mutable complex<D>* cplx_;
/// The dimension of the face.
// FIXME: Rename as `dim_'?
@@ -334,7 +337,7 @@ namespace mln
};
- /// Comparison of two instances of mln::topo::any_face_handle.
+ /// Comparison of two instances of mln::topo::face.
/// \{
/// \brief Is \a lhs equal to \a rhs?
///
@@ -342,7 +345,7 @@ namespace mln
/// mln::topo::complex.
template <unsigned D>
bool
- operator==(const any_face_handle<D>& lhs, const any_face_handle<D>& rhs);
+ operator==(const face<D>& lhs, const face<D>& rhs);
/// \brief Is \a lhs ``less'' than \a rhs?
///
@@ -353,7 +356,7 @@ namespace mln
/// \pre Arguments \a lhs and \a rhs must have the same dimension.
template <unsigned D>
bool
- operator< (const any_face_handle<D>& lhs, const any_face_handle<D>& rhs);
+ operator< (const face<D>& lhs, const face<D>& rhs);
/// \}
@@ -578,7 +581,7 @@ namespace mln
template <unsigned D>
inline
- any_face_handle<D>::any_face_handle()
+ face<D>::face()
: cplx_(0),
n_(std::numeric_limits<unsigned>::max()),
face_id_(std::numeric_limits<unsigned>::max())
@@ -587,7 +590,7 @@ namespace mln
template <unsigned D>
inline
- any_face_handle<D>::any_face_handle(complex<D>& c, unsigned n,
+ face<D>::face(complex<D>& c, unsigned n,
unsigned face_id)
: cplx_(&c), n_(n), face_id_(face_id)
{
@@ -598,7 +601,7 @@ namespace mln
template <unsigned D>
template <unsigned N>
inline
- any_face_handle<D>::any_face_handle(const n_face<N, D>& f)
+ face<D>::face(const n_face<N, D>& f)
: cplx_(&f.cplx()), n_(N), face_id_(f.face_id())
{
// Ensure N is compatible with D.
@@ -608,15 +611,15 @@ namespace mln
template <unsigned D>
inline
- any_face_handle<D>::any_face_handle(const any_face_handle<D>& rhs)
+ face<D>::face(const face<D>& rhs)
: cplx_(rhs.cplx_), n_(rhs.n_), face_id_(rhs.face_id_)
{
}
template <unsigned D>
inline
- any_face_handle<D>&
- any_face_handle<D>::operator=(const any_face_handle<D>& rhs)
+ face<D>&
+ face<D>::operator=(const face<D>& rhs)
{
if (&rhs != this)
{
@@ -630,7 +633,7 @@ namespace mln
template <unsigned D>
inline
bool
- any_face_handle<D>::is_valid() const
+ face<D>::is_valid() const
{
return cplx_ != 0 && n_ <= D && face_id_ < cplx_->nfaces(n_);
}
@@ -638,7 +641,7 @@ namespace mln
template <unsigned D>
inline
void
- any_face_handle<D>::invalidate()
+ face<D>::invalidate()
{
set_n(std::numeric_limits<unsigned>::max());
set_face_id(std::numeric_limits<unsigned>::max());
@@ -647,7 +650,7 @@ namespace mln
template <unsigned D>
inline
complex<D>&
- any_face_handle<D>::cplx() const
+ face<D>::cplx() const
{
mln_precondition(cplx_);
return *cplx_;
@@ -656,7 +659,7 @@ namespace mln
template <unsigned D>
inline
unsigned
- any_face_handle<D>::n() const
+ face<D>::n() const
{
return n_;
}
@@ -664,7 +667,7 @@ namespace mln
template <unsigned D>
inline
unsigned
- any_face_handle<D>::face_id() const
+ face<D>::face_id() const
{
return face_id_;
}
@@ -672,7 +675,7 @@ namespace mln
template <unsigned D>
inline
void
- any_face_handle<D>::set_cplx(complex<D>& cplx)
+ face<D>::set_cplx(complex<D>& cplx)
{
cplx_ = &cplx;
}
@@ -680,7 +683,7 @@ namespace mln
template <unsigned D>
inline
void
- any_face_handle<D>::set_n(unsigned n)
+ face<D>::set_n(unsigned n)
{
n_ = n;
}
@@ -688,7 +691,7 @@ namespace mln
template <unsigned D>
inline
void
- any_face_handle<D>::set_face_id(unsigned face_id)
+ face<D>::set_face_id(unsigned face_id)
{
face_id_ = face_id;
}
@@ -697,7 +700,7 @@ namespace mln
template <unsigned N>
inline
face_data<N, D>&
- any_face_handle<D>::face_data() const
+ face<D>::face_data() const
{
mln_precondition(n_ == N);
mln_precondition(is_valid());
@@ -708,7 +711,7 @@ namespace mln
template <unsigned D>
inline
bool
- operator==(const any_face_handle<D>& lhs, const any_face_handle<D>& rhs)
+ operator==(const face<D>& lhs, const face<D>& rhs)
{
// Ensure LHS and RHS belong to the same complex.
mln_precondition(&lhs.face.cplx() == &rhs.face.cplx());
@@ -721,7 +724,7 @@ namespace mln
template <unsigned D>
inline
bool
- operator< (const any_face_handle<D>& lhs, const any_face_handle<D>& rhs)
+ operator< (const face<D>& lhs, const face<D>& rhs)
{
// Ensure LHS and RHS belong to the same complex.
mln_precondition(&lhs.face.cplx() == &rhs.face.cplx());
diff --git a/milena/tests/core/image/complex_image.cc b/milena/tests/core/image/complex_image.cc
index b8e4c8a..148041d 100644
--- a/milena/tests/core/image/complex_image.cc
+++ b/milena/tests/core/image/complex_image.cc
@@ -91,7 +91,7 @@ int main()
// A pset.
p_complex<D, point2d> pc(c);
- topo::any_face_handle<D> af(e0);
+ topo::face<D> af(e0);
// An associated psite.
complex_psite<D, point2d> cs(pc, af);
diff --git a/milena/tests/topo/complex.cc b/milena/tests/topo/complex.cc
index e10721f..ebe734a 100644
--- a/milena/tests/topo/complex.cc
+++ b/milena/tests/topo/complex.cc
@@ -110,7 +110,7 @@ int main()
const topo::face_data<1, D>& face1 = e0.face_data();
// Any-face handle.
- topo::any_face_handle<D> af(e0);
+ topo::face<D> af(e0);
// Get the face data from (``dynamic'') face handle AF.
const topo::face_data<1, D>& face2 = af.face_data<1>();
@@ -150,7 +150,7 @@ int main()
test_faces_iter<2>(c);
/* Using complex_faces_{fwd,bkd}_iter_<N, D>, which are proxies to
- any_face_handles<N>. */
+ faces<N>. */
test_complex_faces_iter<0>(c);
test_complex_faces_iter<1>(c);
test_complex_faces_iter<2>(c);
@@ -278,7 +278,7 @@ int main()
faces_fwd_iter_<N, D> Iterators on N-faces, N being
faces_fwd_iter_<N, D> static, acting as proxies of
- any_face_handle<N, D>'s.
+ face<D>'s.
-----------------------------------------------------------------
*/
}
--
1.6.0.1
1
0
* mln/topo/face.hh (mln::topo::face_handle<N, D>): Rename as...
(mln::topo::n_face<N, D>): ...this.
Adjust.
* mln/topo/complex.hh,
* mln/topo/faces_iter.hh,
* tests/topo/complex.cc:
Adjust.
* mln/core/faces_psite.hh,
* tests/core/image/complex_image.cc:
Likewise.
---
milena/ChangeLog | 16 +++++
milena/mln/core/faces_psite.hh | 10 ++--
milena/mln/topo/complex.hh | 28 ++++----
milena/mln/topo/face.hh | 102 +++++++++++++++---------------
milena/mln/topo/faces_iter.hh | 12 ++--
milena/tests/core/image/complex_image.cc | 22 +++---
milena/tests/topo/complex.cc | 28 ++++----
7 files changed, 117 insertions(+), 101 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index fb69e22..dfdd15b 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,21 @@
2008-09-26 Roland Levillain <roland(a)lrde.epita.fr>
+ Rename mln::topo::face_handle as mln::topo::n_face.
+
+ * mln/topo/face.hh (mln::topo::face_handle<N, D>): Rename as...
+ (mln::topo::n_face<N, D>): ...this.
+ Adjust.
+ * mln/topo/complex.hh,
+ * mln/topo/faces_iter.hh,
+ * tests/topo/complex.cc:
+ Adjust.
+
+ * mln/core/faces_psite.hh,
+ * tests/core/image/complex_image.cc:
+ Likewise.
+
+2008-09-26 Roland Levillain <roland(a)lrde.epita.fr>
+
Rename mln::topo::face as mln::topo::face_data.
* mln/topo/face.hh (mln::topo::face<N, D>): Rename as...
diff --git a/milena/mln/core/faces_psite.hh b/milena/mln/core/faces_psite.hh
index dd213b6..0e4d635 100644
--- a/milena/mln/core/faces_psite.hh
+++ b/milena/mln/core/faces_psite.hh
@@ -66,7 +66,7 @@ namespace mln
/// \{
faces_psite();
/// \pre pf.cplx() == face.cplx().
- faces_psite(const p_faces<N, D, P>& pf, const topo::face_handle<N, D>& face);
+ faces_psite(const p_faces<N, D, P>& pf, const topo::n_face<N, D>& face);
faces_psite(const p_faces<N, D, P>& pf, unsigned face_id);
/// \}
@@ -100,7 +100,7 @@ namespace mln
/// Face handle manipulators.
/// \{
/// Return the face handle of this point site.
- topo::face_handle<N, D> face() const;
+ topo::n_face<N, D> face() const;
/// Return the dimension of the face of this psite.
unsigned n() const;
@@ -134,7 +134,7 @@ namespace mln
/// The mln::p_faces this point site belongs to.
const target* pf_;
/// The handle of the face this psite is pointing towards.
- topo::face_handle<N, D> face_;
+ topo::n_face<N, D> face_;
/// \}
};
@@ -199,7 +199,7 @@ namespace mln
template <unsigned N, unsigned D, typename P>
inline
faces_psite<N, D, P>::faces_psite(const p_faces<N, D, P>& pf,
- const topo::face_handle<N, D>& face)
+ const topo::n_face<N, D>& face)
: pf_(&pf),
face_(face)
{
@@ -285,7 +285,7 @@ namespace mln
template <unsigned N, unsigned D, typename P>
inline
- topo::face_handle<N, D>
+ topo::n_face<N, D>
faces_psite<N, D, P>::face() const
{
return face_;
diff --git a/milena/mln/topo/complex.hh b/milena/mln/topo/complex.hh
index 52c43a9..021e788 100644
--- a/milena/mln/topo/complex.hh
+++ b/milena/mln/topo/complex.hh
@@ -98,14 +98,14 @@ namespace mln
complex();
/// \brief Add a 0-face to the complex.
- face_handle<0u, D> add_face();
+ n_face<0u, D> add_face();
/// \brief Add a \p (N+1)-face to the complex (with \p N >= 0).
///
/// \param adjacent_faces The (\p N-1)-faces adjacent to the new
/// \p N-face.
template <unsigned N>
- face_handle<N + 1, D> add_face(const faces_set<N, D>& adjacent_faces);
+ n_face<N + 1, D> add_face(const faces_set<N, D>& adjacent_faces);
/// \}
/// \brief Static manipulators.
@@ -152,7 +152,7 @@ namespace mln
/// Accessors.
/// \{
- template <unsigned N, unsigned D_> friend class face_handle;
+ template <unsigned N, unsigned D_> friend class n_face;
template <unsigned D_> friend class any_face_handle;
template <unsigned N>
@@ -195,8 +195,8 @@ namespace mln
///
/// \pre \p N must be lower or equal to \p D.
template <unsigned N>
- void connect_(const face_handle<N, D>& f1,
- const face_handle<N + 1, D>& f2);
+ void connect_(const n_face<N, D>& f1,
+ const n_face<N + 1, D>& f2);
};
@@ -406,7 +406,7 @@ namespace mln
}
template <unsigned D>
- face_handle<0u, D>
+ n_face<0u, D>
complex<D>::add_face()
{
/* FIXME: This is not thread-proof (these two lines should
@@ -414,15 +414,15 @@ namespace mln
data_->internal::faces_set_mixin<0u, D>::faces_.push_back(face_data<0u, D>());
unsigned id = nfaces<0u>() - 1;
- return face_handle<0u, D>(*this, id);
+ return n_face<0u, D>(*this, id);
}
template <unsigned D>
template <unsigned N>
- face_handle<N + 1, D>
+ n_face<N + 1, D>
complex<D>::add_face(const faces_set<N, D>& adjacent_faces)
{
- typedef typename std::vector< face_handle<N, D> >::const_iterator iter_t;
+ typedef typename std::vector< n_face<N, D> >::const_iterator iter_t;
// Ensure ADJACENT_FACES are already part of the complex.
if (!HAS_NDEBUG)
@@ -439,7 +439,7 @@ namespace mln
data_->internal::faces_set_mixin<N + 1, D>::faces_.push_back(f);
unsigned id = nfaces<N + 1>() - 1;
- face_handle<N + 1, D> fh(*this, id);
+ n_face<N + 1, D> fh(*this, id);
// Connect F and its ADJACENT_FACES.
for (iter_t a = adjacent_faces.faces().begin();
a != adjacent_faces.faces().end(); ++a)
@@ -551,8 +551,8 @@ namespace mln
template <unsigned D>
template <unsigned N>
void
- complex<D>::connect_(const face_handle<N, D>& f1,
- const face_handle<N + 1, D>& f2)
+ complex<D>::connect_(const n_face<N, D>& f1,
+ const n_face<N + 1, D>& f2)
{
// Ensure N is compatible with D.
metal::bool_< N <= D >::check();
@@ -703,7 +703,7 @@ namespace mln
lower_dim_faces_set_mixin<N, D>::print(std::ostream& ostr,
const face_data<N, D>& f) const
{
- for (typename std::vector< face_handle<N - 1, D> >::const_iterator l =
+ for (typename std::vector< n_face<N - 1, D> >::const_iterator l =
f.lower_dim_faces_.begin(); l != f.lower_dim_faces_.end(); ++l)
ostr << l->face_id() << " ";
}
@@ -713,7 +713,7 @@ namespace mln
higher_dim_faces_set_mixin<N, D>::print(std::ostream& ostr,
const face_data<N, D>& f) const
{
- for (typename std::vector< face_handle<N + 1, D> >::const_iterator h =
+ for (typename std::vector< n_face<N + 1, D> >::const_iterator h =
f.higher_dim_faces_.begin(); h != f.higher_dim_faces_.end(); ++h)
ostr << h->face_id() << " ";
}
diff --git a/milena/mln/topo/face.hh b/milena/mln/topo/face.hh
index 689f7e6..4aab366 100644
--- a/milena/mln/topo/face.hh
+++ b/milena/mln/topo/face.hh
@@ -69,7 +69,7 @@ namespace mln
}
// Forward declarations (internal).
- template <unsigned N, unsigned D> class face_handle;
+ template <unsigned N, unsigned D> class n_face;
namespace internal
{
template <unsigned N, unsigned D> class lower_dim_faces_data_mixin;
@@ -121,20 +121,20 @@ namespace mln
class lower_dim_faces_data_mixin
{
public:
- void connect_lower_dim_face (const face_handle<N - 1, D>& f);
+ void connect_lower_dim_face (const n_face<N - 1, D>& f);
private:
friend class mln::topo::internal::lower_dim_faces_set_mixin<N, D>;
- std::vector< face_handle<N - 1, D> > lower_dim_faces_;
+ std::vector< n_face<N - 1, D> > lower_dim_faces_;
};
template <unsigned N, unsigned D>
class higher_dim_faces_data_mixin
{
public:
- void connect_higher_dim_face(const face_handle<N + 1, D>& f);
+ void connect_higher_dim_face(const n_face<N + 1, D>& f);
private:
friend class mln::topo::internal::higher_dim_faces_set_mixin<N, D>;
- std::vector< face_handle<N + 1, D> > higher_dim_faces_;
+ std::vector< n_face<N + 1, D> > higher_dim_faces_;
};
/// \}
@@ -142,26 +142,26 @@ namespace mln
- /*--------------.
- | Face handle. |
- `--------------*/
+ /*---------.
+ | n-Face. |
+ `---------*/
- // Face handle in a complex.
+ // \p N-face handle in a complex.
template <unsigned N, unsigned D>
- struct face_handle
+ struct n_face
{
// The type of the complex this handle points to.
typedef complex<D> complex_type;
/// Build a non-initialized face handle.
- face_handle();
+ n_face();
/// Build a face handle from \a complex and \a face_id.
- face_handle(complex<D>& complex, unsigned face_id);
+ n_face(complex<D>& complex, unsigned face_id);
/// Copy and assignment.
/// \{
- face_handle(const face_handle<N, D>& rhs);
- face_handle<N, D>& operator=(const face_handle<N, D>& rhs);
+ n_face(const n_face<N, D>& rhs);
+ n_face<N, D>& operator=(const n_face<N, D>& rhs);
/// \}
/// Is this handle valid?
@@ -192,7 +192,7 @@ namespace mln
private:
/// \brief The complex the face belongs to.
///
- /// A const face_handle can be used to modify a complex.
+ /// A const mln::topo::n_face can be used to modify a complex.
mutable complex<D>* cplx_;
/// \brief The id of the face.
// FIXME: Rename as `id_'?
@@ -202,11 +202,11 @@ namespace mln
/// Create a handle for \p N-face of a \p D-complex.
template <unsigned N, unsigned D>
- face_handle<N, D>
- make_face_handle(const complex<D>& c, unsigned face_id);
+ n_face<N, D>
+ make_n_face(const complex<D>& c, unsigned face_id);
- /// Comparison of two instances of mln::topo::face_handle.
+ /// Comparison of two instances of mln::topo::n_face.
/// \{
/// \brief Is \a lhs equal to \a rhs?
///
@@ -214,7 +214,7 @@ namespace mln
/// mln::topo::complex.
template <unsigned N, unsigned D>
bool
- operator==(const face_handle<N, D>& lhs, const face_handle<N, D>& rhs);
+ operator==(const n_face<N, D>& lhs, const n_face<N, D>& rhs);
/// \brief Is \a lhs ``less'' than \a rhs?
///
@@ -224,7 +224,7 @@ namespace mln
/// mln::topo::complex.
template <unsigned N, unsigned D>
bool
- operator< (const face_handle<N, D>& lhs, const face_handle<N, D>& rhs);
+ operator< (const n_face<N, D>& lhs, const n_face<N, D>& rhs);
/// \}
@@ -237,20 +237,20 @@ namespace mln
class faces_set
{
public:
- void add(const face_handle<N, D>& f);
+ void add(const n_face<N, D>& f);
/// \brief Accessors.
///
/// Return the set of handles.
/// \{
- const std::vector< face_handle<N, D> >& faces() const;
+ const std::vector< n_face<N, D> >& faces() const;
/// \}
private:
friend class complex<D>;
// FIXME: Rename this as `handles_'?
- std::vector< face_handle<N, D> > faces_;
+ std::vector< n_face<N, D> > faces_;
};
@@ -258,11 +258,11 @@ namespace mln
/// \{
template <unsigned N, unsigned D>
faces_set<N, D>
- operator+(const face_handle<N, D>& f1, const face_handle<N, D>& f2);
+ operator+(const n_face<N, D>& f1, const n_face<N, D>& f2);
template <unsigned N, unsigned D>
faces_set<N, D>
- operator+(const faces_set<N, D>& fs, const face_handle<N, D>& f);
+ operator+(const faces_set<N, D>& fs, const n_face<N, D>& f);
/// \}
@@ -284,7 +284,7 @@ namespace mln
/// Build a face handle from a face_handle.
template <unsigned N>
- any_face_handle(const face_handle<N, D>& f);
+ any_face_handle(const n_face<N, D>& f);
/// Copy and assignment.
/// \{
@@ -369,7 +369,7 @@ namespace mln
template <unsigned N, unsigned D>
inline
void
- lower_dim_faces_data_mixin<N, D>::connect_lower_dim_face(const face_handle<N - 1, D>& f)
+ lower_dim_faces_data_mixin<N, D>::connect_lower_dim_face(const n_face<N - 1, D>& f)
{
lower_dim_faces_.push_back(f);
}
@@ -377,7 +377,7 @@ namespace mln
template <unsigned N, unsigned D>
inline
void
- higher_dim_faces_data_mixin<N, D>::connect_higher_dim_face(const face_handle<N + 1, D>& f)
+ higher_dim_faces_data_mixin<N, D>::connect_higher_dim_face(const n_face<N + 1, D>& f)
{
higher_dim_faces_.push_back(f);
}
@@ -391,7 +391,7 @@ namespace mln
template <unsigned N, unsigned D>
inline
- face_handle<N, D>::face_handle()
+ n_face<N, D>::n_face()
: cplx_(0), face_id_(std::numeric_limits<unsigned>::max())
{
// Ensure N is compatible with D.
@@ -400,7 +400,7 @@ namespace mln
template <unsigned N, unsigned D>
inline
- face_handle<N, D>::face_handle(complex<D>& c, unsigned face_id)
+ n_face<N, D>::n_face(complex<D>& c, unsigned face_id)
: cplx_(&c), face_id_(face_id)
{
// Ensure N is compatible with D.
@@ -409,7 +409,7 @@ namespace mln
template <unsigned N, unsigned D>
inline
- face_handle<N, D>::face_handle(const face_handle<N, D>& rhs)
+ n_face<N, D>::n_face(const n_face<N, D>& rhs)
: cplx_(rhs.cplx_), face_id_(rhs.face_id_)
{
// Ensure N is compatible with D.
@@ -418,8 +418,8 @@ namespace mln
template <unsigned N, unsigned D>
inline
- face_handle<N, D>&
- face_handle<N, D>::operator=(const face_handle<N, D>& rhs)
+ n_face<N, D>&
+ n_face<N, D>::operator=(const n_face<N, D>& rhs)
{
if (&rhs != this)
{
@@ -432,7 +432,7 @@ namespace mln
template <unsigned N, unsigned D>
inline
bool
- face_handle<N, D>::is_valid() const
+ n_face<N, D>::is_valid() const
{
return cplx_ != 0 && face_id_ < cplx_->template nfaces<N>();
}
@@ -440,7 +440,7 @@ namespace mln
template <unsigned N, unsigned D>
inline
void
- face_handle<N, D>::invalidate()
+ n_face<N, D>::invalidate()
{
set_face_id(std::numeric_limits<unsigned>::max());
}
@@ -448,7 +448,7 @@ namespace mln
template <unsigned N, unsigned D>
inline
complex<D>&
- face_handle<N, D>::cplx() const
+ n_face<N, D>::cplx() const
{
mln_precondition(cplx_);
return *cplx_;
@@ -457,7 +457,7 @@ namespace mln
template <unsigned N, unsigned D>
inline
unsigned
- face_handle<N, D>::n() const
+ n_face<N, D>::n() const
{
return N;
}
@@ -465,7 +465,7 @@ namespace mln
template <unsigned N, unsigned D>
inline
unsigned
- face_handle<N, D>::face_id() const
+ n_face<N, D>::face_id() const
{
return face_id_;
}
@@ -473,7 +473,7 @@ namespace mln
template <unsigned N, unsigned D>
inline
void
- face_handle<N, D>::set_cplx(complex<D>& cplx)
+ n_face<N, D>::set_cplx(complex<D>& cplx)
{
cplx_ = &cplx;
}
@@ -481,7 +481,7 @@ namespace mln
template <unsigned N, unsigned D>
inline
void
- face_handle<N, D>::set_face_id(unsigned face_id)
+ n_face<N, D>::set_face_id(unsigned face_id)
{
face_id_ = face_id;
}
@@ -489,7 +489,7 @@ namespace mln
template <unsigned N, unsigned D>
inline
face_data<N, D>&
- face_handle<N, D>::face_data() const
+ n_face<N, D>::face_data() const
{
mln_precondition(is_valid());
return cplx_->template face_data_<N>(face_id_);
@@ -498,17 +498,17 @@ namespace mln
template <unsigned N, unsigned D>
inline
- face_handle<N, D>
- make_face_handle(const complex<D>& c, unsigned face_id)
+ n_face<N, D>
+ make_n_face(const complex<D>& c, unsigned face_id)
{
- return face_handle<N, D>(&c, face_id);
+ return n_face<N, D>(&c, face_id);
}
template <unsigned N, unsigned D>
inline
bool
- operator==(const face_handle<N, D>& lhs, const face_handle<N, D>& rhs)
+ operator==(const n_face<N, D>& lhs, const n_face<N, D>& rhs)
{
// Ensure LHS and RHS belong to the same complex.
mln_precondition(&lhs.face.cplx() == &rhs.face.cplx());
@@ -518,7 +518,7 @@ namespace mln
template <unsigned N, unsigned D>
inline
bool
- operator< (const face_handle<N, D>& lhs, const face_handle<N, D>& rhs)
+ operator< (const n_face<N, D>& lhs, const n_face<N, D>& rhs)
{
// Ensure LHS and RHS belong to the same complex.
mln_precondition(&lhs.face.cplx() == &rhs.face.cplx());
@@ -533,7 +533,7 @@ namespace mln
template <unsigned N, unsigned D>
inline
void
- faces_set<N, D>::add(const face_handle<N, D>& f)
+ faces_set<N, D>::add(const n_face<N, D>& f)
{
// Check consistency.
if (!faces_.empty())
@@ -543,7 +543,7 @@ namespace mln
template <unsigned N, unsigned D>
inline
- const std::vector< face_handle<N, D> >&
+ const std::vector< n_face<N, D> >&
faces_set<N, D>::faces() const
{
return faces_;
@@ -553,7 +553,7 @@ namespace mln
template <unsigned N, unsigned D>
inline
faces_set<N, D>
- operator+(const face_handle<N, D>& f1, const face_handle<N, D>& f2)
+ operator+(const n_face<N, D>& f1, const n_face<N, D>& f2)
{
faces_set<N, D> fs;
fs.add(f1);
@@ -564,7 +564,7 @@ namespace mln
template <unsigned N, unsigned D>
inline
faces_set<N, D>
- operator+(const faces_set<N, D>& fs, const face_handle<N, D>& f)
+ operator+(const faces_set<N, D>& fs, const n_face<N, D>& f)
{
faces_set<N, D> fs2(fs);
fs2.add(f);
@@ -598,7 +598,7 @@ namespace mln
template <unsigned D>
template <unsigned N>
inline
- any_face_handle<D>::any_face_handle(const face_handle<N, D>& f)
+ any_face_handle<D>::any_face_handle(const n_face<N, D>& f)
: cplx_(&f.cplx()), n_(N), face_id_(f.face_id())
{
// Ensure N is compatible with D.
diff --git a/milena/mln/topo/faces_iter.hh b/milena/mln/topo/faces_iter.hh
index 8f444c7..1ad756b 100644
--- a/milena/mln/topo/faces_iter.hh
+++ b/milena/mln/topo/faces_iter.hh
@@ -50,12 +50,12 @@ namespace mln
/// \arg \p D The dimension of the complex this iterator belongs to.
template <unsigned N, unsigned D>
class faces_fwd_iter_
- : public internal::complex_iter_base_< face_handle<N, D>,
+ : public internal::complex_iter_base_< n_face<N, D>,
faces_fwd_iter_<N, D> >
{
public:
/// Type of associated face.
- typedef face_handle<N, D> face;
+ typedef n_face<N, D> face;
private:
typedef faces_fwd_iter_<N, D> self_;
@@ -96,12 +96,12 @@ namespace mln
/// \arg \p D The dimension of the complex this iterator belongs to.
template <unsigned N, unsigned D>
class faces_bkd_iter_
- : public internal::complex_iter_base_< face_handle<N, D>,
+ : public internal::complex_iter_base_< n_face<N, D>,
faces_bkd_iter_<N, D> >
{
public:
/// Type of associated face.
- typedef face_handle<N, D> face;
+ typedef n_face<N, D> face;
private:
typedef faces_bkd_iter_<N, D> self_;
@@ -176,7 +176,7 @@ namespace mln
{
unsigned face_id = face_.face_id();
if (face_id + 1 < face_.cplx().template nfaces<N>())
- /* FIXME: Provide accessor face_handle::n() returning
+ /* FIXME: Provide accessor n_face::n() returning
a mutable reference? This way, we could just write
++face_.face_id();
@@ -230,7 +230,7 @@ namespace mln
{
unsigned face_id = face_.face_id();
if (face_id > 0)
- /* FIXME: Provide accessor face_handle::n() returning
+ /* FIXME: Provide accessor n_face::n() returning
a mutable reference? This way, we could just write
++face_.face_id();
diff --git a/milena/tests/core/image/complex_image.cc b/milena/tests/core/image/complex_image.cc
index 3b40fba..b8e4c8a 100644
--- a/milena/tests/core/image/complex_image.cc
+++ b/milena/tests/core/image/complex_image.cc
@@ -68,21 +68,21 @@ int main()
topo::complex<D> c;
// 0-faces (points).
- topo::face_handle<0, D> v0 = c.add_face();
- topo::face_handle<0, D> v1 = c.add_face();
- topo::face_handle<0, D> v2 = c.add_face();
- topo::face_handle<0, D> v3 = c.add_face();
+ topo::n_face<0, D> v0 = c.add_face();
+ topo::n_face<0, D> v1 = c.add_face();
+ topo::n_face<0, D> v2 = c.add_face();
+ topo::n_face<0, D> v3 = c.add_face();
// 1-faces (segments).
- topo::face_handle<1, D> e0 = c.add_face(v0 + v1);
- topo::face_handle<1, D> e1 = c.add_face(v0 + v2);
- topo::face_handle<1, D> e2 = c.add_face(v1 + v2);
- topo::face_handle<1, D> e3 = c.add_face(v0 + v3);
- topo::face_handle<1, D> e4 = c.add_face(v2 + v3);
+ topo::n_face<1, D> e0 = c.add_face(v0 + v1);
+ topo::n_face<1, D> e1 = c.add_face(v0 + v2);
+ topo::n_face<1, D> e2 = c.add_face(v1 + v2);
+ topo::n_face<1, D> e3 = c.add_face(v0 + v3);
+ topo::n_face<1, D> e4 = c.add_face(v2 + v3);
// 2-faces (triangles).
- topo::face_handle<2, D> t0 = c.add_face(e0 + e1 + e2);
- topo::face_handle<2, D> t1 = c.add_face(e1 + e3 + e4);
+ topo::n_face<2, D> t0 = c.add_face(e0 + e1 + e2);
+ topo::n_face<2, D> t1 = c.add_face(e1 + e3 + e4);
/*---------------------.
diff --git a/milena/tests/topo/complex.cc b/milena/tests/topo/complex.cc
index 43143c5..e10721f 100644
--- a/milena/tests/topo/complex.cc
+++ b/milena/tests/topo/complex.cc
@@ -69,21 +69,21 @@ int main()
topo::complex<D> c;
// 0-faces (points).
- topo::face_handle<0, D> v0 = c.add_face();
- topo::face_handle<0, D> v1 = c.add_face();
- topo::face_handle<0, D> v2 = c.add_face();
- topo::face_handle<0, D> v3 = c.add_face();
+ topo::n_face<0, D> v0 = c.add_face();
+ topo::n_face<0, D> v1 = c.add_face();
+ topo::n_face<0, D> v2 = c.add_face();
+ topo::n_face<0, D> v3 = c.add_face();
// 1-faces (segments).
- topo::face_handle<1, D> e0 = c.add_face(v0 + v1);
- topo::face_handle<1, D> e1 = c.add_face(v0 + v2);
- topo::face_handle<1, D> e2 = c.add_face(v1 + v2);
- topo::face_handle<1, D> e3 = c.add_face(v0 + v3);
- topo::face_handle<1, D> e4 = c.add_face(v2 + v3);
+ topo::n_face<1, D> e0 = c.add_face(v0 + v1);
+ topo::n_face<1, D> e1 = c.add_face(v0 + v2);
+ topo::n_face<1, D> e2 = c.add_face(v1 + v2);
+ topo::n_face<1, D> e3 = c.add_face(v0 + v3);
+ topo::n_face<1, D> e4 = c.add_face(v2 + v3);
// 2-faces (triangles).
- topo::face_handle<2, D> t0 = c.add_face(e0 + e1 + e2);
- topo::face_handle<2, D> t1 = c.add_face(e1 + e3 + e4);
+ topo::n_face<2, D> t0 = c.add_face(e0 + e1 + e2);
+ topo::n_face<2, D> t1 = c.add_face(e1 + e3 + e4);
std::cout << c << std::endl;
@@ -144,7 +144,7 @@ int main()
but I'm not sure. */
/* Using faces_{fwd,bkd}_iter_<N, D>, which are proxies to
- face_handles<N, D>. */
+ n_faces<N, D>. */
test_faces_iter<0>(c);
test_faces_iter<1>(c);
test_faces_iter<2>(c);
@@ -189,7 +189,7 @@ int main()
But first, we need to clarify (existing) names.
-----------------------------------------------------------------
- Current name New name Definition
+ Current/old name New name Definition
-----------------------------------------------------------------
complex<D> (n/a) General complex
@@ -274,7 +274,7 @@ int main()
-----------------------------------------------------------------
complex_faces_fwd_iter_<N, D> Iterators on N-faces, N being
complex_faces_fwd_iter_<N, D> static, acting as proxies of
- face_handle<N, D>'s.
+ n_face<N, D>'s.
faces_fwd_iter_<N, D> Iterators on N-faces, N being
faces_fwd_iter_<N, D> static, acting as proxies of
--
1.6.0.1
1
0
* mln/topo/face.hh (mln::topo::face<N, D>): Rename as...
(mln::topo::face_data<N, D>): ...this.
(mln::topo::internal::lower_dim_faces_mixin<N, D>)
(mln::topo::internal::higher_dim_faces_mixin<N, D>):
Rename as...
(mln::topo::internal::lower_dim_faces_data_mixin<N, D>)
(mln::topo::internal::higher_dim_faces_data_mixin<N, D>):
...these.
(mln::topo::face_handle<N, D>::to_face)
(mln::topo::any_face_handle<D>::to_face):
Rename accessors as...
(mln::topo::face_handle<N, D>::face_data)
(mln::topo::any_face_handle<D>::face_data):
...these.
Adjust.
* mln/topo/complex.hh: Adjust.
* tests/topo/complex.cc: Likewise.
---
milena/ChangeLog | 22 +++++++++++++
milena/mln/topo/complex.hh | 36 ++++++++++----------
milena/mln/topo/face.hh | 72 ++++++++++++++++++++++-------------------
milena/tests/topo/complex.cc | 4 +-
4 files changed, 81 insertions(+), 53 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index ce8c7c6..fb69e22 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,27 @@
2008-09-26 Roland Levillain <roland(a)lrde.epita.fr>
+ Rename mln::topo::face as mln::topo::face_data.
+
+ * mln/topo/face.hh (mln::topo::face<N, D>): Rename as...
+ (mln::topo::face_data<N, D>): ...this.
+ (mln::topo::internal::lower_dim_faces_mixin<N, D>)
+ (mln::topo::internal::higher_dim_faces_mixin<N, D>):
+ Rename as...
+ (mln::topo::internal::lower_dim_faces_data_mixin<N, D>)
+ (mln::topo::internal::higher_dim_faces_data_mixin<N, D>):
+ ...these.
+ (mln::topo::face_handle<N, D>::to_face)
+ (mln::topo::any_face_handle<D>::to_face):
+ Rename accessors as...
+ (mln::topo::face_handle<N, D>::face_data)
+ (mln::topo::any_face_handle<D>::face_data):
+ ...these.
+ Adjust.
+ * mln/topo/complex.hh: Adjust.
+ * tests/topo/complex.cc: Likewise.
+
+2008-09-26 Roland Levillain <roland(a)lrde.epita.fr>
+
* tests/topo/complex.cc: Add more to-do and proto-documentation.
2008-09-26 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
diff --git a/milena/mln/topo/complex.hh b/milena/mln/topo/complex.hh
index ae69dee..52c43a9 100644
--- a/milena/mln/topo/complex.hh
+++ b/milena/mln/topo/complex.hh
@@ -156,10 +156,10 @@ namespace mln
template <unsigned D_> friend class any_face_handle;
template <unsigned N>
- face<N, D>& face_(unsigned face_id);
+ face_data<N, D>& face_data_(unsigned face_id);
template <unsigned N>
- const face<N, D>& face_(unsigned face_id) const;
+ const face_data<N, D>& face_data_(unsigned face_id) const;
/// \}
/// Functional meta-manipulators.
@@ -258,7 +258,7 @@ namespace mln
struct faces_set_mixin<D, D> : public faces_set_mixin<D - 1, D>,
public lower_dim_faces_set_mixin<D, D>
{
- std::vector< face<D, D> > faces_;
+ std::vector< face_data<D, D> > faces_;
/// Pretty-printing.
/// \{
@@ -287,7 +287,7 @@ namespace mln
public lower_dim_faces_set_mixin<N, D>,
public higher_dim_faces_set_mixin<N, D>
{
- std::vector< face<N, D> > faces_;
+ std::vector< face_data<N, D> > faces_;
/// Pretty-printing.
/// \{
@@ -316,7 +316,7 @@ namespace mln
template <unsigned D>
struct faces_set_mixin<0u, D> : public higher_dim_faces_set_mixin<0u, D>
{
- std::vector< face<0u, D> > faces_;
+ std::vector< face_data<0u, D> > faces_;
/// Pretty-printing.
/// \{
@@ -343,7 +343,7 @@ namespace mln
template <>
struct faces_set_mixin<0u, 0u>
{
- std::vector< face<0u, 0u> > faces_;
+ std::vector< face_data<0u, 0u> > faces_;
/// Pretty-printing.
/// \{
@@ -378,13 +378,13 @@ namespace mln
template <unsigned N, unsigned D>
struct lower_dim_faces_set_mixin
{
- void print(std::ostream& ostr, const face<N, D>& f) const;
+ void print(std::ostream& ostr, const face_data<N, D>& f) const;
};
template <unsigned N, unsigned D>
struct higher_dim_faces_set_mixin
{
- void print(std::ostream& ostr, const face<N, D>& f) const;
+ void print(std::ostream& ostr, const face_data<N, D>& f) const;
};
/// \}
@@ -411,7 +411,7 @@ namespace mln
{
/* FIXME: This is not thread-proof (these two lines should
form an atomic section). */
- data_->internal::faces_set_mixin<0u, D>::faces_.push_back(face<0u, D>());
+ data_->internal::faces_set_mixin<0u, D>::faces_.push_back(face_data<0u, D>());
unsigned id = nfaces<0u>() - 1;
return face_handle<0u, D>(*this, id);
@@ -433,7 +433,7 @@ namespace mln
mln_precondition(a->is_valid());
}
- face<N + 1, D> f;
+ face_data<N + 1, D> f;
/* FIXME: This is not thread-proof (these two lines should
form an atomic section). */
data_->internal::faces_set_mixin<N + 1, D>::faces_.push_back(f);
@@ -534,16 +534,16 @@ namespace mln
template <unsigned D>
template <unsigned N>
- face<N, D>&
- complex<D>::face_(unsigned face_id)
+ face_data<N, D>&
+ complex<D>::face_data_(unsigned face_id)
{
return data_->internal::faces_set_mixin<N, D>::faces_[face_id];
}
template <unsigned D>
template <unsigned N>
- const face<N, D>&
- complex<D>::face_(unsigned face_id) const
+ const face_data<N, D>&
+ complex<D>::face_data_(unsigned face_id) const
{
return data_->internal::faces_set_mixin<N, D>::faces_[face_id];
}
@@ -557,8 +557,8 @@ namespace mln
// Ensure N is compatible with D.
metal::bool_< N <= D >::check();
- f1.to_face().connect_higher_dim_face(f2);
- f2.to_face().connect_lower_dim_face(f1);
+ f1.face_data().connect_higher_dim_face(f2);
+ f2.face_data().connect_lower_dim_face(f1);
}
@@ -701,7 +701,7 @@ namespace mln
template <unsigned N, unsigned D>
void
lower_dim_faces_set_mixin<N, D>::print(std::ostream& ostr,
- const face<N, D>& f) const
+ const face_data<N, D>& f) const
{
for (typename std::vector< face_handle<N - 1, D> >::const_iterator l =
f.lower_dim_faces_.begin(); l != f.lower_dim_faces_.end(); ++l)
@@ -711,7 +711,7 @@ namespace mln
template <unsigned N, unsigned D>
void
higher_dim_faces_set_mixin<N, D>::print(std::ostream& ostr,
- const face<N, D>& f) const
+ const face_data<N, D>& f) const
{
for (typename std::vector< face_handle<N + 1, D> >::const_iterator h =
f.higher_dim_faces_.begin(); h != f.higher_dim_faces_.end(); ++h)
diff --git a/milena/mln/topo/face.hh b/milena/mln/topo/face.hh
index 11f22b2..689f7e6 100644
--- a/milena/mln/topo/face.hh
+++ b/milena/mln/topo/face.hh
@@ -47,6 +47,10 @@
Anyway, whatever the decision, splitting `face', `face_handle' and
`any_face_handle' seems to be sound.
+ `face_data' is somehow an implementation detail: it should be
+ hidden, either by moving it to mln/topo/complex.cc or into its own
+ file in mln/topo/internal.
+
(And what about `faces_set'? Should we move it to its own file as
well?) */
@@ -68,42 +72,42 @@ namespace mln
template <unsigned N, unsigned D> class face_handle;
namespace internal
{
- template <unsigned N, unsigned D> class lower_dim_faces_mixin;
- template <unsigned N, unsigned D> class higher_dim_faces_mixin;
+ template <unsigned N, unsigned D> class lower_dim_faces_data_mixin;
+ template <unsigned N, unsigned D> class higher_dim_faces_data_mixin;
}
- /*-------.
- | Face. |
- `-------*/
+ /*------------.
+ | Face data. |
+ `------------*/
- /// \p N-face of a \p D-complex.
- template <unsigned N, unsigned D> class face;
+ /// Data (adjacent faces) associated to a \p N-face of a \p D-complex.
+ template <unsigned N, unsigned D> class face_data;
// Specialization for the faces of highest dimension (\p D).
template <unsigned D>
- class face<D, D> : public internal::lower_dim_faces_mixin<D, D>
+ class face_data<D, D> : public internal::lower_dim_faces_data_mixin<D, D>
{
};
// Specialization for the faces of intermediate dimension (greater
// than 0, lower than \p D).
template <unsigned N, unsigned D>
- class face : public internal::lower_dim_faces_mixin<N, D>,
- public internal::higher_dim_faces_mixin<N, D>
+ class face_data : public internal::lower_dim_faces_data_mixin<N, D>,
+ public internal::higher_dim_faces_data_mixin<N, D>
{
};
// Specialization for the faces of lowest dimension (0).
template <unsigned D>
- class face<0u, D> : public internal::higher_dim_faces_mixin<0u, D>
+ class face_data<0u, D> : public internal::higher_dim_faces_data_mixin<0u, D>
{
};
// Specialization for the case of a 0-complex.
template <>
- class face<0u, 0u>
+ class face_data<0u, 0u>
{
};
@@ -114,7 +118,7 @@ namespace mln
/// Factored implementation of faces.
/// \{
template <unsigned N, unsigned D>
- class lower_dim_faces_mixin
+ class lower_dim_faces_data_mixin
{
public:
void connect_lower_dim_face (const face_handle<N - 1, D>& f);
@@ -124,7 +128,7 @@ namespace mln
};
template <unsigned N, unsigned D>
- class higher_dim_faces_mixin
+ class higher_dim_faces_data_mixin
{
public:
void connect_higher_dim_face(const face_handle<N + 1, D>& f);
@@ -181,8 +185,8 @@ namespace mln
/// Set the id of the face.
void set_face_id(unsigned face_id);
- /// Return the mln::face pointed by this handle.
- face<N, D>& to_face() const;
+ /// Return the mln::topo::face_data pointed by this handle.
+ face_data<N, D>& face_data() const;
/// \}
private:
@@ -202,12 +206,12 @@ namespace mln
make_face_handle(const complex<D>& c, unsigned face_id);
- /// Comparison of two instances of mln::face_handle.
+ /// Comparison of two instances of mln::topo::face_handle.
/// \{
/// \brief Is \a lhs equal to \a rhs?
///
/// \pre Arguments \a lhs and \a rhs must belong to the same
- /// mln::complex.
+ /// mln::topo::complex.
template <unsigned N, unsigned D>
bool
operator==(const face_handle<N, D>& lhs, const face_handle<N, D>& rhs);
@@ -217,7 +221,7 @@ namespace mln
/// This comparison is required by algorithms sorting face handles.
///
/// \pre Arguments \a lhs and \a rhs must belong to the same
- /// mln::complex.
+ /// mln::topo::complex.
template <unsigned N, unsigned D>
bool
operator< (const face_handle<N, D>& lhs, const face_handle<N, D>& rhs);
@@ -250,7 +254,7 @@ namespace mln
};
- /// Construction helpers for mln::faces_set.
+ /// Construction helpers for mln::topo::faces_set.
/// \{
template <unsigned N, unsigned D>
faces_set<N, D>
@@ -311,9 +315,9 @@ namespace mln
/// Set the id of the face.
void set_face_id(unsigned face_id);
- /// Return the mln::face pointed by this handle.
+ /// Return the mln::topo::face_data pointed by this handle.
template <unsigned N>
- face<N, D>& to_face() const;
+ face_data<N, D>& face_data() const;
/// \}
private:
@@ -330,12 +334,12 @@ namespace mln
};
- /// Comparison of two instances of mln::any_face_handle.
+ /// Comparison of two instances of mln::topo::any_face_handle.
/// \{
/// \brief Is \a lhs equal to \a rhs?
///
/// \pre Arguments \a lhs and \a rhs must belong to the same
- /// mln::complex.
+ /// mln::topo::complex.
template <unsigned D>
bool
operator==(const any_face_handle<D>& lhs, const any_face_handle<D>& rhs);
@@ -345,7 +349,7 @@ namespace mln
/// This comparison is required by algorithms sorting face handles.
///
/// \pre Arguments \a lhs and \a rhs must belong to the same
- /// mln::complex.
+ /// mln::topo::complex.
/// \pre Arguments \a lhs and \a rhs must have the same dimension.
template <unsigned D>
bool
@@ -365,7 +369,7 @@ namespace mln
template <unsigned N, unsigned D>
inline
void
- lower_dim_faces_mixin<N, D>::connect_lower_dim_face(const face_handle<N - 1, D>& f)
+ lower_dim_faces_data_mixin<N, D>::connect_lower_dim_face(const face_handle<N - 1, D>& f)
{
lower_dim_faces_.push_back(f);
}
@@ -373,7 +377,7 @@ namespace mln
template <unsigned N, unsigned D>
inline
void
- higher_dim_faces_mixin<N, D>::connect_higher_dim_face(const face_handle<N + 1, D>& f)
+ higher_dim_faces_data_mixin<N, D>::connect_higher_dim_face(const face_handle<N + 1, D>& f)
{
higher_dim_faces_.push_back(f);
}
@@ -484,11 +488,11 @@ namespace mln
template <unsigned N, unsigned D>
inline
- face<N, D>&
- face_handle<N, D>::to_face() const
+ face_data<N, D>&
+ face_handle<N, D>::face_data() const
{
mln_precondition(is_valid());
- return cplx_->template face_<N>(face_id_);
+ return cplx_->template face_data_<N>(face_id_);
}
@@ -500,6 +504,7 @@ namespace mln
return face_handle<N, D>(&c, face_id);
}
+
template <unsigned N, unsigned D>
inline
bool
@@ -691,12 +696,12 @@ namespace mln
template <unsigned D>
template <unsigned N>
inline
- face<N, D>&
- any_face_handle<D>::to_face() const
+ face_data<N, D>&
+ any_face_handle<D>::face_data() const
{
mln_precondition(n_ == N);
mln_precondition(is_valid());
- return cplx_->template face_<N>(face_id_);
+ return cplx_->template face_data_<N>(face_id_);
}
@@ -712,6 +717,7 @@ namespace mln
lhs.face().id() == rhs.face().id();
}
+
template <unsigned D>
inline
bool
diff --git a/milena/tests/topo/complex.cc b/milena/tests/topo/complex.cc
index b9051dc..43143c5 100644
--- a/milena/tests/topo/complex.cc
+++ b/milena/tests/topo/complex.cc
@@ -107,12 +107,12 @@ int main()
`-------------------*/
// Get the face data from (``static'') face handle E0.
- const topo::face<1, D>& face1 = e0.to_face();
+ const topo::face_data<1, D>& face1 = e0.face_data();
// Any-face handle.
topo::any_face_handle<D> af(e0);
// Get the face data from (``dynamic'') face handle AF.
- const topo::face<1, D>& face2 = af.to_face<1>();
+ const topo::face_data<1, D>& face2 = af.face_data<1>();
mln_assertion(&face1 == &face2);
--
1.6.0.1
1
0
2411: * tests/topo/complex.cc: Add more to-do and proto-documentation.
by Roland Levillain 26 Sep '08
by Roland Levillain 26 Sep '08
26 Sep '08
---
milena/ChangeLog | 4 +
milena/tests/topo/complex.cc | 125 +++++++++++++++++++++++++++++++++++++++++-
2 files changed, 127 insertions(+), 2 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 6af1c1c..ce8c7c6 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,7 @@
+2008-09-26 Roland Levillain <roland(a)lrde.epita.fr>
+
+ * tests/topo/complex.cc: Add more to-do and proto-documentation.
+
2008-09-26 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Clean erosion and dilation a bit.
diff --git a/milena/tests/topo/complex.cc b/milena/tests/topo/complex.cc
index 08be130..b9051dc 100644
--- a/milena/tests/topo/complex.cc
+++ b/milena/tests/topo/complex.cc
@@ -155,11 +155,132 @@ int main()
test_complex_faces_iter<1>(c);
test_complex_faces_iter<2>(c);
+ /*------------------------------.
+ | Iterators on adjacent faces. |
+ `------------------------------*/
- /* FIXME: Exercice more iterators (see
+ /* FIXME: Write and exercise more iterators (see
milena/tests/core/complex_image.cc) and ticket #162
(https://trac.lrde.org/olena/ticket/162) */
- // ...
+
+ /* Iterate on the the set of (n-1)-faces adjacent to AF.
+
+ Note: this can be solved with iterators where the dimension can
+ be either static or dynamic.
+
+ 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.
+
+ Likewise, our iterators on n-faces (both faces_piter and
+ complex_faces_piter) use a static `n'. We should also have
+ n-faces iterators where n could be dynamic.
+
+ But first, we need to clarify (existing) names.
+
+ -----------------------------------------------------------------
+ Current name New name Definition
+ -----------------------------------------------------------------
+ complex<D> (n/a) General complex
+
+ face<N, D> face_data<N, D> Face data
+ face_handle<N, D> n_face<N, D> (Static) n-face handle
+ faces_set<N, D> n_faces_set<N, D> Set of face handles
+ any_face_handle<D> face<D> Dynamic face handle
+
+ complex_fwd_iter_<D>(c) face_fwd_iter<D>(c) | Iterators on all
+ complex_bkd_iter_<D>(c) face_bkd_iter<D>(c) | faces of c
+
+ complex_iter_base_<F, E> complex_iter_base<F, E>
+ | Factoring base
+ | class.
+ -----------------------------------------------------------------
+
+ (Note: get rid of trailing underscores, even for entities in
+ mln::internal::.)
+
+ Next, write these:
+
+ -----------------------------------------------------------------
+ Name Definition
+ -----------------------------------------------------------------
+ n_faces_fwd_iter<D>(c) | Iterators on n-faces,
+ n_faces_bkd_iter<D>(c) | n being dynamic
+
+ adj_lower_faces_fwd_iter<D>(c, f) | Iterators on the adjacent
+ adj_lower_faces_bkd_iter<D>(c, f) | (lower) (n-1)-faces of the
+ | n-face f of the complex c,
+ | n being dynamic
+
+ adj_higher_faces_fwd_iter<D>(c, f) | Iterators on the adjacent
+ adj_higher_faces_bkd_iter<D>(c, f) | (higher) (n+1)-faces of the
+ | n-face f of the complex c,
+ | n being dynamic
+
+ adj_lower_dim_connected_n_faces_fwd_iter<D>(c, f)
+ adj_lower_dim_connected_n_faces_bkd_iter<D>(c, f)
+ (FIXME: These names are admittedly too long.)
+ | Iterators on the the set of
+ | n-faces sharing an adjacent
+ | (n-1)-face with f, n being
+ | dynamic
+
+ adj_higher_dim_connected_n_faces_fwd_iter<D>(c, f)
+ adj_higher_dim_connected_n_faces_bkd_iter<D>(c, f)
+ (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
+ | all m-faces adjacent to p,
+ | where m is in [0, n-1];
+ | this set is name « f-hat »
+
+ cell_boundary_fwd_iter<D>(c, f) | Likewise, but excluding p;
+ cell_boundary_bkd_iter<D>(c, f) | this set is named « p-hat* »
+ -----------------------------------------------------------------
+
+ We could also have generic iterators based on predicated, and
+ even use them to provide first (non efficient) implementations of
+ the iterators from the previous list.
+
+ -----------------------------------------------------------------
+ Name Definition
+ -----------------------------------------------------------------
+ generic_face_fwd_iter<D>(c, pred) | Generic face iterators on c
+ generic_face_bkd_iter<D>(c, pred) | using predicate pred to
+ | define the iterated subset.
+ -----------------------------------------------------------------
+
+ I'm unsure about the following existing iterators; should we keep
+ them? What are they good for, except testing our code?
+
+ -----------------------------------------------------------------
+ Current name Definition
+ -----------------------------------------------------------------
+ complex_faces_fwd_iter_<N, D> Iterators on N-faces, N being
+ complex_faces_fwd_iter_<N, D> static, acting as proxies of
+ face_handle<N, D>'s.
+
+ faces_fwd_iter_<N, D> Iterators on N-faces, N being
+ faces_fwd_iter_<N, D> static, acting as proxies of
+ any_face_handle<N, D>'s.
+ -----------------------------------------------------------------
+ */
}
--
1.6.0.1
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Clean erosion and dilation a bit.
* doc/examples/tuto_one.cc: Cleanup.
(argv): New argument for chosing neighborhood.
* mln/border/resize.hh (todo): New.
* mln/morpho/erosion.spe.hh,
* mln/morpho/erosion.hh,
* mln/morpho/dilation.hh,
* mln/morpho/dilation_fast.hh: Use extension fill.
Anticipate border adjust.
* mln/extension/all.hh: New.
* mln/morpho/includes.hh: Update.
doc/examples/tuto_one.cc | 107 +++++++++++++++++++++++++-------------------
mln/border/resize.hh | 3 +
mln/extension/all.hh | 51 ++++++++++++++++++++
mln/morpho/dilation.hh | 12 ++++
mln/morpho/dilation_fast.hh | 6 +-
mln/morpho/erosion.hh | 13 ++++-
mln/morpho/erosion.spe.hh | 23 +++++++--
mln/morpho/includes.hh | 3 -
8 files changed, 160 insertions(+), 58 deletions(-)
Index: doc/examples/tuto_one.cc
--- doc/examples/tuto_one.cc (revision 2409)
+++ doc/examples/tuto_one.cc (working copy)
@@ -3,41 +3,35 @@
# include <mln/value/int_u8.hh>
# include <mln/value/rgb8.hh>
+# include <mln/io/pgm/load.hh>
+# include <mln/io/ppm/save.hh>
+
# include <mln/core/var.hh>
# include <mln/core/image/image2d.hh>
# include <mln/core/alias/neighb2d.hh>
-# include <mln/core/alias/window2d.hh>
-
-# include <mln/convert/to_p_set.hh>
-# include <mln/convert/to_image.hh>
-# include <mln/debug/println.hh>
-
# include <mln/make/double_neighb2d.hh>
-# include <mln/io/pgm/load.hh>
-# include <mln/io/pgm/save.hh>
-# include <mln/io/pbm/save.hh>
-# include <mln/io/ppm/save.hh>
-
# include <mln/level/transform.hh>
# include <mln/literal/black.hh>
-# include <mln/pw/all.hh>
+# include <mln/debug/println.hh>
# include <mln/morpho/closing_area.hh>
# include <mln/morpho/gradient.hh>
# include <mln/morpho/meyer_wst.hh>
+using namespace mln;
+using value::int_u8;
-struct colorize : mln::Function_v2v< colorize >
+struct colorize : Function_v2v< colorize >
{
- typedef mln::value::rgb8 result;
+ typedef value::rgb8 result;
colorize(unsigned max)
: lut(max + 1)
{
- lut[0] = mln::literal::black;
+ lut[0] = literal::black;
for (unsigned i = 1; i <= max; ++i)
lut[i] = result(100 + std::rand() % 150,
100 + std::rand() % 150,
@@ -51,7 +45,7 @@
};
- bool is_chess(const mln::point2d& p)
+bool is_chess(const point2d& p)
{
return p.col() % 2 == p.row() % 2;
}
@@ -59,23 +53,67 @@
void usage(char* argv[])
{
- std::cerr << "usage: " << argv[0] << " input.pgm lambda output.ppm" << std::endl;
+ std::cerr << "usage: " << argv[0] << " input.pgm nbh lambda output.ppm" << std::endl;
+ std::cerr << " nbh in {4, 6, 8}; lambda >= 0" << std::endl;
abort();
}
+template <typename I, typename N>
+void do_it(const I& ima,
+ const N& nbh,
+ int lambda,
+ const std::string& filename)
+{
+ I grad = morpho::gradient(ima, nbh.win());
+
+ I clo;
+ if (lambda > 1)
+ clo = morpho::closing_area(grad, nbh, lambda);
+ else
+ clo = grad;
+
+ unsigned l;
+ mln_ch_value(I, unsigned) wst = morpho::meyer_wst(clo, nbh, l);
+
+ debug::println(labeling::regional_minima(clo, nbh, l));
+ debug::println(wst);
+
+ io::ppm::save(level::transform(wst, colorize(l)), filename);
+}
+
+
int main(int argc, char* argv[])
{
- using namespace mln;
- using value::int_u8;
+ if (argc != 5)
+ usage(argv);
+ image2d<int_u8> ima;
+
+ io::pgm::load(ima, argv[1]);
+
+ int nbh_ = atoi(argv[2]);
+ if (! (nbh_ == 4 || nbh_ == 6 || nbh_ == 8))
+ usage(argv);
- if (argc != 4)
+ int lambda = atoi(argv[3]);
+ if (lambda < 0)
usage(argv);
- image2d<int_u8> lena;
- io::pgm::load(lena, argv[1]);
+ std::string filename(argv[4]);
+ if (nbh_ == 4)
+ {
+ mln_VAR(nbh, c4());
+ do_it(ima, nbh, lambda, filename);
+ }
+ else if (nbh_ == 8)
+ {
+ mln_VAR(nbh, c8());
+ do_it(ima, nbh, lambda, filename);
+ }
+ else if (nbh_ == 6)
+ {
bool vert[] = { 1, 1, 0,
1, 0, 1,
0, 1, 1 };
@@ -85,29 +123,6 @@
1, 1, 0 };
mln_VAR( nbh, make::double_neighb2d(is_chess, vert, hori) );
-// mln_VAR(nbh, c4());
-// mln_VAR(nbh, c8());
-
- image2d<int_u8> clo, grad = morpho::gradient(lena, nbh.win());
- // io::pgm::save(grad, "tmp_grad.pgm");
-
- int lambda = atoi(argv[2]);
- if (lambda > 1)
- {
- clo = morpho::closing_area(grad, nbh, lambda);
- io::pgm::save(clo, "tmp_clo.pgm");
+ do_it(ima, nbh, lambda, filename);
}
- else
- clo = grad;
-
- unsigned l;
- image2d<unsigned> wst = morpho::meyer_wst(clo, nbh, l);
-
- std::cout << "l = " << l << std::endl;
- debug::println(wst);
-
- io::ppm::save(level::transform(wst, colorize(l)), argv[3]);
-
-// io::pbm::save((pw::value(wst) == pw::cst(0)) | lena.domain(),
-// argv[3]);
}
Index: mln/border/resize.hh
--- mln/border/resize.hh (revision 2409)
+++ mln/border/resize.hh (working copy)
@@ -34,6 +34,9 @@
* image.
*
* \todo Use level::fill!!!
+ *
+ * \todo Test with a primary image with no notion of border; I guess
+ * it does not work.
*/
# include <mln/core/concept/image.hh>
Index: mln/morpho/erosion.spe.hh
--- mln/morpho/erosion.spe.hh (revision 2409)
+++ mln/morpho/erosion.spe.hh (working copy)
@@ -45,7 +45,10 @@
*
* \brief Specialization for mln::morpho::erosion.
*
+ * \todo Warning: we should also have the "arbitrary" versions working
+ * on sets (not only on functions!)
*
+ * \todo Activate the FIXMEs (border::adjust).
*/
# ifndef MLN_INCLUDE_ONLY
@@ -91,9 +94,11 @@
const I& input = exact(input_);
const W& win = exact(win_);
+ // FIXME: border::adjust(input, win.delta());
+ extension::fill(input, mln_max(mln_value(I)));
+
O output;
initialize(output, input);
- extension::fill(input, mln_max(mln_value(I)));
mln_pixter(const I) p(input);
mln_pixter(O) o(output);
@@ -122,9 +127,11 @@
const I& input = exact(input_);
const W& win = exact(win_);
+ // FIXME: border::adjust(input, win.delta());
+ extension::fill(input, true);
+
O output;
initialize(output, input);
- extension::fill(input, true);
mln_pixter(const I) p(input);
mln_pixter(O) p_out(output);
@@ -152,11 +159,13 @@
typedef mln_concrete(I) O;
const I& input = exact(input_);
const W& win = exact(win_);
- O output;
+ // FIXME: border::adjust(input, win.delta());
extension::fill(input, true);
+ O output;
output = clone(input);
+
mln_piter(I) p(input.domain());
mln_qiter(W) q(win, p);
for_all(p)
@@ -181,11 +190,13 @@
typedef mln_concrete(I) O;
const I& input = exact(input_);
const W& win = exact(win_);
- O output;
+ // FIXME: border::adjust(input, win.delta());
extension::fill(input, true);
+ O output;
output = clone(input);
+
mln_pixter(const I) p(input);
mln_qixter(const I, W) q(p, win);
mln_pixter(O) p_out(output);
@@ -280,6 +291,8 @@
void init()
{
+ // FIXME: border::adjust(input, win.delta());
+ extension::fill(input, mln_max(mln_value(I)));
initialize(output, input);
min.init();
p = input.domain().pmin() + up;
@@ -375,6 +388,8 @@
void init()
{
+ // FIXME: border::adjust(input, win.delta());
+ extension::fill(input, mln_max(mln_value(I)));
initialize(output, input);
min.init();
p = input.domain().pmin() + up;
Index: mln/morpho/erosion.hh
--- mln/morpho/erosion.hh (revision 2409)
+++ mln/morpho/erosion.hh (working copy)
@@ -30,6 +30,8 @@
/// \file mln/morpho/erosion.hh
/// \brief Morphological erosion.
+///
+/// \todo Activate the FIXMEs (border::adjust).
# include <mln/morpho/includes.hh>
@@ -70,16 +72,20 @@
const I& input = exact(input_);
const W& win = exact(win_);
+ // FIXME: border::adjust(input, win.delta());
+ extension::fill(input, mln_max(mln_value(I)));
+
mln_concrete(I) output;
initialize(output, input);
accu::min_<mln_value(I)> min;
+
mln_piter(I) p(input.domain());
mln_qiter(W) q(win, p);
for_all(p)
{
min.init();
- for_all(q) if (input.domain().has(q))
+ for_all(q) if (input.has(q))
min.take(input(q));
output(p) = min;
}
@@ -100,6 +106,9 @@
const I& input = exact(input_);
const W& win = exact(win_);
+ // FIXME: border::adjust(input, win.delta());
+ extension::fill(input, true);
+
mln_concrete(I) output;
initialize(output, input);
@@ -107,7 +116,7 @@
mln_qiter(W) q(win, p);
for_all(p)
{
- for_all(q) if (input.domain().has(q))
+ for_all(q) if (input.has(q))
if (input(q) == false)
break;
output(p) = ! q.is_valid();
Index: mln/morpho/dilation.hh
--- mln/morpho/dilation.hh (revision 2409)
+++ mln/morpho/dilation.hh (working copy)
@@ -30,6 +30,8 @@
/// \file mln/morpho/dilation.hh
/// \brief Morphological dilation.
+///
+/// \todo Activate the FIXMEs (border::adjust).
# include <mln/morpho/includes.hh>
@@ -92,6 +94,9 @@
const W& win = exact(win_);
O& output = exact(output_);
+ // FIXME: border::adjust(input, win.delta());
+ extension::fill(input, mln_min(mln_value(I)));
+
accu::max_<mln_value(I)> max;
mln_piter(I) p(input.domain());
@@ -99,7 +104,7 @@
for_all(p)
{
max.init();
- for_all(q) if (input.domain().has(q))
+ for_all(q) if (input.has(q))
max.take(input(q));
output(p) = max.to_result();
}
@@ -116,13 +121,16 @@
const W& win = exact(win_);
O& output = exact(output_);
+ // FIXME: border::adjust(input, win.delta());
+ extension::fill(input, false);
+
level::fill(output, input);
mln_piter(I) p(input.domain());
mln_qiter(W) q(win, p);
for_all(p)
if (!input(p))
- for_all(q) if (input.domain().has(q))
+ for_all(q) if (input.has(q))
if (input(q))
{
output(p) = true;
Index: mln/morpho/includes.hh
--- mln/morpho/includes.hh (revision 2409)
+++ mln/morpho/includes.hh (working copy)
@@ -55,8 +55,7 @@
# include <mln/test/positive.hh>
-// # include <mln/border/all.hh>
-# include <mln/extension/fill.hh>
+# include <mln/extension/all.hh>
# include <mln/geom/sym.hh>
# include <mln/set/inter.hh>
Index: mln/morpho/dilation_fast.hh
--- mln/morpho/dilation_fast.hh (revision 2409)
+++ mln/morpho/dilation_fast.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -30,7 +30,7 @@
/*! \file mln/morpho/dilation_fast.hh
*
- * \brief Ero filtering of an image.
+ * \brief Dilation filtering of an image with arbitrary s.e.
*
* \todo Add fastest versions.
*/
@@ -124,6 +124,8 @@
inline
void init()
{
+ // FIXME: border::adjust(input, win.delta());
+ extension::fill(input, mln_min(mln_value(I)));
max.init();
mln_qiter(W) q(win, p);
for_all(q) if (input.has(q))
Index: mln/extension/all.hh
--- mln/extension/all.hh (revision 0)
+++ mln/extension/all.hh (revision 0)
@@ -0,0 +1,51 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// 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_EXTENSION_ALL_HH
+# define MLN_EXTENSION_ALL_HH
+
+/*! \file mln/pw/all.hh
+ *
+ * \brief File that includes all extension materials.
+ *
+ * \todo Also include "extension images" + "extended"?
+ */
+
+
+namespace mln
+{
+
+ /// Namespace of extension tools.
+ namespace extension {}
+
+} // end of namespace mln
+
+
+# include <mln/extension/fill.hh>
+
+
+#endif // ! MLN_EXTENSION_ALL_HH
1
0
cleanup-2008 2409: Revamp extension fill and fix dependant morpho operators.
by Thierry Geraud 25 Sep '08
by Thierry Geraud 25 Sep '08
25 Sep '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Revamp extension fill and fix dependant morpho operators.
* tests/core/routine/extend.cc: New.
* tests/core/routine/Makefile.am: Update.
* sandbox/geraud/cs2d/dbl_neighb.cc: Rename as...
* doc/examples/tuto_one.cc: ...this.
Update.
* mln/core/image/extension_ima.hh (change_extension): New.
* mln/core/routine/extend.hh (todo): New.
* mln/core/internal/image_morpher.hh (unmorph_): New.
* mln/border/fill.hh: Revamp.
* mln/morpho/closing_area.hh (closing_area): New up-to-date sig.
* mln/morpho/erosion.spe.hh: Update.
De-activate some parts because of multiple windows.
(FIXME): New couple.
* mln/morpho/erosion.hh (has): Replace by...
(domain.has): ...this.
* mln/morpho/dilation.hh: Likewise.
* mln/morpho/meyer_wst.hh: Likewise.
* mln/canvas/morpho/algebraic_union_find.hh: Likewise.
* mln/canvas/labeling.hh: Likewise.
* mln/morpho/includes.hh: New include.
* mln/extension/fill.hh: Revamp.
doc/examples/tuto_one.cc | 33 +++----
mln/border/fill.hh | 105 ++++++++++++++++++----
mln/canvas/labeling.hh | 4
mln/canvas/morpho/algebraic_union_find.hh | 2
mln/core/image/extension_ima.hh | 13 ++
mln/core/internal/image_morpher.hh | 15 +++
mln/core/routine/extend.hh | 1
mln/extension/fill.hh | 140 +++++++++++++++++++++++-------
mln/morpho/closing_area.hh | 14 +++
mln/morpho/dilation.hh | 4
mln/morpho/erosion.hh | 4
mln/morpho/erosion.spe.hh | 59 +++++++-----
mln/morpho/includes.hh | 2
mln/morpho/meyer_wst.hh | 6 -
tests/core/routine/Makefile.am | 2
tests/core/routine/extend.cc | 72 +++++++++++++++
16 files changed, 374 insertions(+), 102 deletions(-)
Index: tests/core/routine/Makefile.am
--- tests/core/routine/Makefile.am (revision 2408)
+++ tests/core/routine/Makefile.am (working copy)
@@ -5,10 +5,12 @@
check_PROGRAMS = \
clone \
exact \
+ extend \
initialize
clone_SOURCES = clone.cc
exact_SOURCES = exact.cc
+extend_SOURCES = extend.cc
initialize_SOURCES = initialize.cc
TESTS = $(check_PROGRAMS)
Index: tests/core/routine/extend.cc
--- tests/core/routine/extend.cc (revision 0)
+++ tests/core/routine/extend.cc (revision 0)
@@ -0,0 +1,72 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// 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.
+
+/*! \file tests/core/routine/extend.cc
+ *
+ * \brief Tests on mln::extend.
+ */
+
+#include <mln/core/var.hh>
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/sub_image.hh>
+
+#include <mln/core/image/extended.hh>
+#include <mln/core/routine/extend.hh>
+
+#include <mln/debug/iota.hh>
+#include <mln/debug/println.hh>
+
+#include <mln/extension/fill.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ image2d<int> ima(3, 3, 1);
+ debug::iota(ima);
+
+ box2d bb = ima.domain().to_larger(1);
+ box2d BB = ima.domain().to_larger(2);
+
+ debug::println(ima);
+ debug::println(extended_to(ima, bb));
+
+ mln_VAR(ima_, extend(ima | make::box2d(2,2), 7));
+ debug::println(ima_);
+
+ debug::println(extended_to(ima_, BB));
+
+ extension::fill(ima_, 8);
+
+ debug::println(ima_);
+ debug::println(extended_to(ima_, BB));
+
+ debug::println(ima_);
+}
Index: doc/examples/tuto_one.cc
--- doc/examples/tuto_one.cc (revision 2406)
+++ doc/examples/tuto_one.cc (working copy)
@@ -3,6 +3,7 @@
# include <mln/value/int_u8.hh>
# include <mln/value/rgb8.hh>
+# include <mln/core/var.hh>
# include <mln/core/image/image2d.hh>
# include <mln/core/alias/neighb2d.hh>
# include <mln/core/alias/window2d.hh>
@@ -11,7 +12,7 @@
# include <mln/convert/to_image.hh>
# include <mln/debug/println.hh>
-# include "dbl_neighb.hh"
+# include <mln/make/double_neighb2d.hh>
# include <mln/io/pgm/load.hh>
# include <mln/io/pgm/save.hh>
@@ -29,14 +30,6 @@
-struct is_chess_t
-{
- bool operator()(const mln::point2d& p) const
- {
- return p.col() % 2 == p.row() % 2;
- }
-};
-
struct colorize : mln::Function_v2v< colorize >
{
@@ -58,6 +51,12 @@
};
+ bool is_chess(const mln::point2d& p)
+ {
+ return p.col() % 2 == p.row() % 2;
+ }
+
+
void usage(char* argv[])
{
std::cerr << "usage: " << argv[0] << " input.pgm lambda output.ppm" << std::endl;
@@ -70,6 +69,7 @@
using namespace mln;
using value::int_u8;
+
if (argc != 4)
usage(argv);
@@ -84,26 +84,27 @@
1, 0, 1,
1, 1, 0 };
- dbl_neighb_<dpoint2d, is_chess_t> nbh;
- nbh
- .when_true (make::neighb2d(vert))
- .when_false(make::neighb2d(hori));
+ mln_VAR( nbh, make::double_neighb2d(is_chess, vert, hori) );
+// mln_VAR(nbh, c4());
+// mln_VAR(nbh, c8());
- image2d<int_u8> clo, grad = morpho::gradient(lena, nbh);
- // io::pgm::save(grad, "grad.pgm");
+ image2d<int_u8> clo, grad = morpho::gradient(lena, nbh.win());
+ // io::pgm::save(grad, "tmp_grad.pgm");
int lambda = atoi(argv[2]);
if (lambda > 1)
{
clo = morpho::closing_area(grad, nbh, lambda);
- // io::pgm::save(clo, "clo.pgm");
+ io::pgm::save(clo, "tmp_clo.pgm");
}
else
clo = grad;
unsigned l;
image2d<unsigned> wst = morpho::meyer_wst(clo, nbh, l);
+
std::cout << "l = " << l << std::endl;
+ debug::println(wst);
io::ppm::save(level::transform(wst, colorize(l)), argv[3]);
Index: mln/core/image/extension_ima.hh
--- mln/core/image/extension_ima.hh (revision 2408)
+++ mln/core/image/extension_ima.hh (working copy)
@@ -39,6 +39,7 @@
*/
# include <mln/core/internal/image_identity.hh>
+# include <mln/level/fill_with_value.hh>
@@ -142,6 +143,9 @@
/// Mutable access to the extension domain (image). This domain
/// can be modified if J a read-write image type.
J& extension();
+
+ /// Change the value in the extension domain (image).
+ void change_extension(const mln_value(I)& v);
};
@@ -266,6 +270,15 @@
return this->data_->ext_;
}
+ template <typename I, typename J>
+ inline
+ void
+ extension_ima<I, J>::change_extension(const mln_value(I)& v)
+ {
+ mlc_equal(mln_trait_image_value_io(J),
+ trait::image::value_io::read_write)::check();
+ level::fill_with_value(v);
+ }
// init_
Index: mln/core/routine/extend.hh
--- mln/core/routine/extend.hh (revision 2408)
+++ mln/core/routine/extend.hh (working copy)
@@ -35,6 +35,7 @@
*
* \todo Use the 'instant' mechanism.
* \todo Deal with ambiguities.
+ * \todo Check that there is no extension yet (except "extendable").
*/
# include <mln/core/image/extension_ima.hh>
Index: mln/core/internal/image_morpher.hh
--- mln/core/internal/image_morpher.hh (revision 2408)
+++ mln/core/internal/image_morpher.hh (working copy)
@@ -61,6 +61,11 @@
/// Return the delegatee_ pointer (non-const version); default code.
I* delegatee_();
+
+ /// Give the morphed image.
+ I& unmorph_();
+
+
/* \brief Test if this image has been initialized; default impl.
*
* This default impl is stronger than the one inherited from
@@ -130,6 +135,16 @@
template <typename I, typename T, typename S, typename E>
inline
+ I&
+ image_morpher<I, T, S, E>::unmorph_()
+ {
+ I* ptr = delegatee_();
+ mln_assertion(ptr != 0);
+ return *ptr;
+ }
+
+ template <typename I, typename T, typename S, typename E>
+ inline
image_morpher<I, T, S, E>::operator I() const
{
mln_precondition(exact(this)->has_data());
Index: mln/border/fill.hh
--- mln/border/fill.hh (revision 2408)
+++ mln/border/fill.hh (working copy)
@@ -58,16 +58,34 @@
template <typename I>
void fill(const Image<I>& ima, const mln_value(I)& v);
+
# ifndef MLN_INCLUDE_ONLY
+
+ namespace internal
+ {
+
+ template <typename I>
+ inline
+ void fill_tests(const Image<I>& ima, const mln_value(I)& v)
+ {
+ mln_precondition(exact(ima).has_data());
+ }
+
+ } // end of namespace mln::border::internal
+
+
namespace impl
{
template <typename I>
inline
- void fill_size_1_(const I& ima, const mln_value(I)& v)
+ void fill_size_1(const Image<I>& ima_, const mln_value(I)& v)
{
- trace::entering("border::impl::fill_size_1_");
+ trace::entering("border::impl::fill_size_1");
+
+ const I& ima = exact(ima_);
+ internal::fill_tests(ima, v);
typedef mln_psite(I) P;
typedef mln_psite(I) P;
@@ -88,14 +106,18 @@
*(const int*)(&v),
ima.nelements () - st);
- trace::exiting("border::impl::fill_size_1_");
+ trace::exiting("border::impl::fill_size_1");
}
+
template <typename I>
inline
- void fill_size_n_(const I& ima, const mln_value(I)& v)
+ void fill_size_n(const I& ima_, const mln_value(I)& v)
{
- trace::entering("border::impl::fill_size_n_");
+ trace::entering("border::impl::fill_size_n");
+
+ const I& ima = exact(ima_);
+ internal::fill_tests(ima, v);
typedef mln_psite(I) P;
mln_box_runstart_piter(I) pl(ima.domain());
@@ -112,34 +134,81 @@
for (std::size_t i = st; i < ima.nelements (); ++i)
const_cast<I&>(ima).element(i) = v;
- trace::exiting("border::impl::fill_size_n_");
+ trace::exiting("border::impl::fill_size_n");
+ }
+
+
+ } // end of namespace mln::border::impl
+
+
+ namespace internal
+ {
+
+ // Dispatch.
+
+ template <typename I>
+ inline
+ void fill_dispatch(const Image<I>& ima, const mln_value(I)& v);
+
+ template <typename I>
+ inline
+ void fill_dispatch(mln::trait::image::category::primary,
+ mln::trait::image::speed::fastest,
+ I& ima, const mln_value(I)& v)
+ {
+ if (sizeof(mln_value(I)) == 1)
+ impl::fill_size_1(ima, v);
+ else
+ impl::fill_size_n(ima, v);
+ }
+
+ template <typename I>
+ inline
+ void fill_dispatch(mln::trait::image::category::primary,
+ mln::trait::image::speed::any,
+ I& ima, const mln_value(I)& v)
+ {
+ // No border so no-op.
}
+ template <typename I>
+ inline
+ void fill_dispatch(mln::trait::image::category::morpher,
+ mln::trait::image::speed::any,
+ I& ima, const mln_value(I)& v)
+ {
+ fill_dispatch(ima.unmorph_(), v);
}
+ template <typename I>
+ inline
+ void fill_dispatch(const Image<I>& ima_, const mln_value(I)& v)
+ {
+ I& ima = const_cast<I&>(exact(ima_));
+ fill_dispatch(mln_trait_image_category(I)(),
+ mln_trait_image_speed(I)(),
+ ima, v);
+ }
+
+ } // end of namespace mln::border::internal
+
+
+
// Facade.
template <typename I>
inline
- void fill(const Image<I>& ima_, const mln_value(I)& v)
+ void fill(const Image<I>& ima, const mln_value(I)& v)
{
trace::entering("border::fill");
- typedef mln_psite(I) P;
- const I& ima = exact(ima_);
-
- mlc_is(mln_trait_image_speed(I), trait::image::speed::fastest)::check();
- mln_precondition(ima.has_data());
- if (!ima.border ())
- return;
- if (sizeof(mln_value(I)) == 1)
- impl::fill_size_1_(ima, v);
- else
- impl::fill_size_n_(ima, v);
+ internal::fill_tests(ima, v);
+ internal::fill_dispatch(ima, v);
trace::exiting("border::fill");
}
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::border
Index: mln/morpho/closing_area.hh
--- mln/morpho/closing_area.hh (revision 2408)
+++ mln/morpho/closing_area.hh (working copy)
@@ -48,6 +48,10 @@
void closing_area(const Image<I>& input, const Neighborhood<N>& nbh,
std::size_t lambda, Image<O>& output);
+ template <typename I, typename N>
+ mln_concrete(I) closing_area(const Image<I>& input, const Neighborhood<N>& nbh,
+ std::size_t lambda);
+
# ifndef MLN_INCLUDE_ONLY
@@ -62,6 +66,16 @@
closing_attribute< accu::count_<pix_t> >(input, nbh, lambda, output);
}
+ template <typename I, typename N>
+ mln_concrete(I) closing_area(const Image<I>& input, const Neighborhood<N>& nbh,
+ std::size_t lambda)
+ {
+ mln_concrete(I) output;
+ initialize(output, input);
+ closing_area(input, nbh, lambda, output);
+ return output;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::morpho
Index: mln/morpho/erosion.spe.hh
--- mln/morpho/erosion.spe.hh (revision 2408)
+++ mln/morpho/erosion.spe.hh (working copy)
@@ -93,7 +93,7 @@
O output;
initialize(output, input);
-// border::fill(input, mln_max(mln_value(I)));
+ extension::fill(input, mln_max(mln_value(I)));
mln_pixter(const I) p(input);
mln_pixter(O) o(output);
@@ -124,7 +124,7 @@
O output;
initialize(output, input);
-// border::fill(input, true);
+ extension::fill(input, true);
mln_pixter(const I) p(input);
mln_pixter(O) p_out(output);
@@ -154,7 +154,7 @@
const W& win = exact(win_);
O output;
-// border::fill(input, true);
+ extension::fill(input, true);
output = clone(input);
mln_piter(I) p(input.domain());
@@ -183,7 +183,7 @@
const W& win = exact(win_);
O output;
-// border::fill(input, true);
+ extension::fill(input, true);
output = clone(input);
mln_pixter(const I) p(input);
@@ -439,26 +439,29 @@
// dispatch for the generic version
- template <typename I, typename W>
- mln_concrete(I)
- erosion_dispatch_for_generic(trait::image::kind::logic, // On sets.
- trait::image::speed::fastest,
- const I& input, const W& win)
- {
- if (win.is_centered())
- return impl::erosion_on_set_centered_fastest(input, win);
- else
- return impl::erosion_on_set_fastest(input, win);
- }
+ // FIXME: De-activate because when the window is multiple, the access
+ // win.dp(i), used in dpoints_pixter, is impossible.
- template <typename I, typename W>
- mln_concrete(I)
- erosion_dispatch_for_generic(trait::image::kind::any, // On functions.
- trait::image::speed::fastest,
- const I& input, const W& win)
- {
- return impl::erosion_on_function_fastest(input, win);
- }
+// template <typename I, typename W>
+// mln_concrete(I)
+// erosion_dispatch_for_generic(trait::image::kind::logic, // On sets.
+// trait::image::speed::fastest,
+// const I& input, const W& win)
+// {
+// if (win.is_centered())
+// return impl::erosion_on_set_centered_fastest(input, win);
+// else
+// return impl::erosion_on_set_fastest(input, win);
+// }
+
+// template <typename I, typename W>
+// mln_concrete(I)
+// erosion_dispatch_for_generic(trait::image::kind::any, // On functions.
+// trait::image::speed::fastest,
+// const I& input, const W& win)
+// {
+// return impl::erosion_on_function_fastest(input, win);
+// }
template <typename I, typename W>
mln_concrete(I)
@@ -543,9 +546,13 @@
mln_concrete(I)
erosion_dispatch_wrt_win(const I& input, const W& win)
{
- if (erosion_chooses_arbitrary(input, win))
- return erosion_dispatch_for_arbitrary(input, win);
- else
+ // FIXME: De-activate because, when win is multiple,
+ // geom::shift does not work. We have to introduce
+ // props from windows, then re-write geom::shift.
+
+// if (erosion_chooses_arbitrary(input, win))
+// return erosion_dispatch_for_arbitrary(input, win);
+// else
return erosion_dispatch_for_generic(input, win);
}
Index: mln/morpho/erosion.hh
--- mln/morpho/erosion.hh (revision 2408)
+++ mln/morpho/erosion.hh (working copy)
@@ -79,7 +79,7 @@
for_all(p)
{
min.init();
- for_all(q) if (input.has(q))
+ for_all(q) if (input.domain().has(q))
min.take(input(q));
output(p) = min;
}
@@ -107,7 +107,7 @@
mln_qiter(W) q(win, p);
for_all(p)
{
- for_all(q) if (input.has(q))
+ for_all(q) if (input.domain().has(q))
if (input(q) == false)
break;
output(p) = ! q.is_valid();
Index: mln/morpho/dilation.hh
--- mln/morpho/dilation.hh (revision 2408)
+++ mln/morpho/dilation.hh (working copy)
@@ -99,7 +99,7 @@
for_all(p)
{
max.init();
- for_all(q) if (input.has(q))
+ for_all(q) if (input.domain().has(q))
max.take(input(q));
output(p) = max.to_result();
}
@@ -122,7 +122,7 @@
mln_qiter(W) q(win, p);
for_all(p)
if (!input(p))
- for_all(q) if (input.has(q))
+ for_all(q) if (input.domain().has(q))
if (input(q))
{
output(p) = true;
Index: mln/morpho/includes.hh
--- mln/morpho/includes.hh (revision 2408)
+++ mln/morpho/includes.hh (working copy)
@@ -54,7 +54,9 @@
# include <mln/level/fill.hh>
# include <mln/test/positive.hh>
+
// # include <mln/border/all.hh>
+# include <mln/extension/fill.hh>
# include <mln/geom/sym.hh>
# include <mln/set/inter.hh>
Index: mln/morpho/meyer_wst.hh
--- mln/morpho/meyer_wst.hh (revision 2408)
+++ mln/morpho/meyer_wst.hh (working copy)
@@ -138,7 +138,7 @@
for_all (p)
if (output(p) == unmarked)
for_all(n)
- if (output.has(n) && output(n) != unmarked)
+ if (output.domain().has(n) && output(n) != unmarked)
{
queue.push(p);
break;
@@ -157,7 +157,7 @@
bool single_adjacent_marker_p = true;
mln_niter(N) n(nbh, p);
for_all(n)
- if (output.has(n) && output(n) != unmarked)
+ if (output.domain().has(n) && output(n) != unmarked)
{
if (adjacent_marker == unmarked)
{
@@ -179,7 +179,7 @@
{
output(p) = adjacent_marker;
for_all(n)
- if (output.has(n) && output(n) == unmarked)
+ if (output.domain().has(n) && output(n) == unmarked)
queue.push(n);
}
}
Index: mln/canvas/morpho/algebraic_union_find.hh
--- mln/canvas/morpho/algebraic_union_find.hh (revision 2408)
+++ mln/canvas/morpho/algebraic_union_find.hh (working copy)
@@ -92,7 +92,7 @@
{
make_set(p);
for_all(n)
- if (f.input.has(n) && deja_vu(n))
+ if (f.input.domain().has(n) && deja_vu(n))
do_union(n, p);
deja_vu(p) = true;
}
Index: mln/canvas/labeling.hh
--- mln/canvas/labeling.hh (revision 2408)
+++ mln/canvas/labeling.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -173,7 +173,7 @@
{
make_set(p);
for_all(n)
- if (f.input.has(n) && deja_vu(n))
+ if (f.input.domain().has(n) && deja_vu(n))
{
if (f.equiv(n, p))
do_union(n, p);
Index: mln/extension/fill.hh
--- mln/extension/fill.hh (revision 2408)
+++ mln/extension/fill.hh (working copy)
@@ -25,7 +25,6 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-
#ifndef MLN_CORE_EXTENSION_FILL_HH
# define MLN_CORE_EXTENSION_FILL_HH
@@ -33,6 +32,9 @@
*
* \brief Define function that fills domain extension.
*
+ *
+ * \todo Test the compatibility between val and mln_value(I) because,
+ * while unmorphing, this type can change...
*/
# include <mln/core/concept/image.hh>
@@ -40,6 +42,7 @@
# include <mln/border/fill.hh>
# include <mln/level/fill_with_value.hh>
+
namespace mln
{
@@ -50,63 +53,136 @@
* single value \p v.
*
* \param[in,out] ima The image whose domain extension is to be filled.
- * \param[in] v The value to assign.
+ * \param[in] val The value to assign.
*
* \pre \p ima has to be initialized.
*
* \todo Optimize with memset if possible.
*/
template <typename I>
- void fill(const Image<I>& ima, const mln_value(I)& v);
+ void fill(const Image<I>& ima, const mln_value(I)& val);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
- namespace impl
+ namespace internal
{
+
+ // Do it.
+
+ template <typename I>
+ void do_fill(I& ima, const mln_value(I)& val); // Entry point.
+
template <typename I>
- void fill_fixed_extension(const Image<I>& ima, const mln_value(I)& v);
+ void do_fill(mln::trait::image::ext_domain::some,
+ mln::trait::image::ext_value::single,
+ mln::trait::image::ext_domain::none,
+ I& ima, const mln_value(I)& val)
+ {
+ ima.change_extension(val);
}
-# ifndef MLN_INCLUDE_ONLY
+ template <typename I>
+ void do_fill(mln::trait::image::ext_domain::some,
+ mln::trait::image::ext_value::multiple,
+ mln::trait::image::ext_domain::none,
+ I& ima, const mln_value(I)& val)
+ {
+ border::fill(ima, val);
+ ima.change_extension(val);
+ }
template <typename I>
- void fill(const Image<I>& ima, const mln_value(I)& v)
+ void do_fill(mln::trait::image::ext_domain::some,
+ mln::trait::image::ext_value::any,
+ mln::trait::image::ext_domain::some,
+ I& ima, const mln_value(I)& val)
{
- // Case of ext_io::read_only.
- if (mlc_equal(mln_trait_image_ext_io(I),
- mln::trait::image::ext_io::read_only)::value == true)
- return; // No-op.
+ mln::extension::fill(ima.unmorph_(), val);
+ }
- // Case of ext_domain::none.
- if (mlc_equal(mln_trait_image_ext_domain(I),
- mln::trait::image::ext_domain::none)::value == true)
- return; // No-op.
+ template <typename I>
+ void do_fill(mln::trait::image::ext_domain::none,
+ mln::trait::image::ext_value::any,
+ mln::trait::image::ext_domain::any,
+ I& ima, const mln_value(I)& val)
+ {
+ // Oops...
+ }
+
+ template <typename I>
+ void do_fill(I& ima, const mln_value(I)& val)
+ {
+ typedef typename I::delegatee D;
+ do_fill(mln_trait_image_ext_domain(I)(),
+ mln_trait_image_ext_value(I)(),
+ mln_trait_image_ext_domain(D)(),
+ ima, val);
+ }
- // Case of ext_domain::extendable.
- if (mlc_equal(mln_trait_image_ext_domain(I),
- mln::trait::image::ext_domain::extendable)::value == true)
- return mln::border::fill(ima, v);
- // Case of ext_domain::fixed.
- if (mlc_equal(mln_trait_image_ext_domain(I),
- mln::trait::image::ext_domain::fixed)::value == true)
+ // Dispatch.
- // Case of ext_value::single.
- if (mlc_equal(mln_trait_image_ext_value(I),
- mln::trait::image::ext_value::single)::value == true)
- return impl::fill_fixed_extension(const_cast<I&>(exact(ima)), v);
- else
- return mln::level::fill_with_value(const_cast<I&>(exact(ima)), v);
+ template <typename I>
+ void fill_dispatch(mln::trait::image::ext_domain::none,
+ mln::trait::image::ext_io::any,
+ I& ima, const mln_value(I)& val)
+ {
+ // No-op cause no extension domain, no border.
+ }
+ template <typename I>
+ void fill_dispatch(mln::trait::image::ext_domain::some,
+ mln::trait::image::ext_io::read_only,
+ I& ima, const mln_value(I)& val)
+ {
+ // No-op for the extension domain, yet:
+ border::fill(ima, val);
+ }
+
+ template <typename I>
+ void fill_dispatch(mln::trait::image::ext_domain::extendable,
+ mln::trait::image::ext_io::read_write,
+ I& ima, const mln_value(I)& val)
+ {
+ // Just fill the border.
+ border::fill(ima, val);
}
- namespace impl
+ template <typename I>
+ void fill_dispatch(mln::trait::image::ext_domain::some,
+ mln::trait::image::ext_io::read_write,
+ I& ima, const mln_value(I)& val)
{
+ do_fill(ima, val);
+ }
+
template <typename I>
- void fill_fixed_extension(Image<I>& ima_, const mln_value(I)& v)
+ void fill_dispatch(const Image<I>& ima_, const mln_value(I)& val)
{
- I& ima = exact(ima_);
- ima.extension() = v;
+ I& ima = const_cast<I&>(exact(ima_));
+ fill_dispatch(mln_trait_image_ext_domain(I)(),
+ mln_trait_image_ext_io(I)(),
+ ima, val);
}
+
+ } // end of namespace mln::extension::internal
+
+
+ // Facade.
+
+ template <typename I>
+ void fill(const Image<I>& ima, const mln_value(I)& val)
+ {
+ trace::entering("extension::fill");
+
+ mln_precondition(exact(ima).has_data());
+ internal::fill_dispatch(ima, val);
+
+ trace::exiting("extension::fill");
}
# endif // ! MLN_INCLUDE_ONLY
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Fix interpolated and tr_image.
* mln/core/image/tr_image.hh (operator()): Fix. Fix trait.
* mln/convert/from_to.hh (from_to): Move (vec -> rgb)...
* mln/value/rgb.hh: ...here.
convert/from_to.hh | 15 ---------------
core/image/tr_image.hh | 10 +++++-----
value/rgb.hh | 21 +++++++++++++++++++++
3 files changed, 26 insertions(+), 20 deletions(-)
Index: mln/core/image/tr_image.hh
--- mln/core/image/tr_image.hh (revision 2407)
+++ mln/core/image/tr_image.hh (working copy)
@@ -73,6 +73,7 @@
{
// ...these changes.
typedef trait::image::value_io::read_only value_io;
+ typedef mln_internal_trait_image_speed_from(I) speed; // Un-fastest.
};
} // end of namespace mln::trait
@@ -97,10 +98,10 @@
typedef mln_value(I) value;
/// Return type of read-write access.
- typedef mln_lvalue(I) lvalue; // FIXME: Depends on lvalue presence in I.
+ typedef mln_value(I) lvalue; // FIXME: Depends on lvalue presence in I.
/// Return type of read-only access.
- typedef mln_rvalue(I) rvalue;
+ typedef mln_value(I) rvalue;
/// Skeleton.
typedef tr_image< S, tag::image_<I>, T> skeleton;
@@ -130,10 +131,10 @@
/// Read-only access of pixel value at point site \p p.
/// Mutable access is only OK for reading (not writing).
- using super_::operator();
+ //using super_::operator();
- mln_value(I) operator()(const psite& p);
mln_value(I) operator()(const psite& p) const;
+ mln_value(I) operator()(const psite& p);
void set_tr(T& tr);
};
@@ -205,7 +206,6 @@
mln_value(I)
tr_image<S,I,T>::operator()(const psite& p) const
{
- std::cout << "yay" << std::endl;
algebra::vec<I::psite::dim, float> v = p;
return this->data_->ima_(this->data_->tr_.inv()(v));
}
Index: mln/value/rgb.hh
--- mln/value/rgb.hh (revision 2407)
+++ mln/value/rgb.hh (working copy)
@@ -283,6 +283,7 @@
operator/(const rgb<n>& lhs, const mln::value::scalar_<S>& s);
/// \}
+
# ifndef MLN_INCLUDE_ONLY
/*---------------.
@@ -496,6 +497,26 @@
} // end of namespace mln::value
+
+ namespace convert
+ {
+
+ // algebra::vec -> rgb.
+ template <typename T, unsigned m>
+ inline
+ void
+ from_to(const algebra::vec<3,T>& from, value::rgb<m>& to_)
+ {
+ value::rgb<m>& to = exact(to_);
+ algebra::vec<3, unsigned> tmp;
+ for (unsigned i = 0; i < 3; ++i)
+ tmp[i] = static_cast<unsigned>(from[i]); // FIXME: Use from_to instead of cast.
+
+ to = value::rgb<m>(tmp);
+ }
+
+ } // end of namespace mln::convert
+
} // end of namespace mln
Index: mln/convert/from_to.hh
--- mln/convert/from_to.hh (revision 2407)
+++ mln/convert/from_to.hh (working copy)
@@ -42,7 +42,6 @@
# include <mln/core/concept/object.hh>
# include <mln/core/concept/gpoint.hh>
# include <mln/value/concept/all.hh>
-# include <mln/value/rgb.hh>
# include <mln/convert/impl/all.hh>
@@ -115,20 +114,6 @@
to[i] = static_cast< typename P::coord >(from[i]);
}
- // algebra::vec -> rgb.
- template <typename T, unsigned m>
- inline
- void
- from_to(const algebra::vec<3,T>& from, value::rgb<m>& to_)
- {
- value::rgb<m>& to = exact(to_);
- algebra::vec<3, unsigned> tmp;
- for (unsigned i = 0; i < 3; ++i)
- tmp[i] = static_cast<unsigned>(from[i]);
-
- to = value::rgb<m>(tmp);
- }
-
// Value -> Value
template <typename F, typename T>
inline
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Sandbox: Update test.
* jardonnet/virtual/access.cc: Update test.
access.cc | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
Index: jardonnet/virtual/access.cc
--- jardonnet/virtual/access.cc (revision 2406)
+++ jardonnet/virtual/access.cc (working copy)
@@ -72,7 +72,8 @@
// adjust border
border::adjust(input, 100);
- //border::fill(input, literal::black);
+ border::fill(input, literal::red);
+ // See extension_fill
interpolated< image2d< value::rgb<8> >, interpolation::bilinear>
interp(input);
@@ -89,7 +90,7 @@
//border::adjust(interp, 20);
//test1<interpolation::bilinear>(input, output, compose(r,t));
- //test2(interp, output, compose(r,t));
- test3(tr_ima, output);
+ test2(interp, output, compose(r,t));
+ //test3(tr_ima, output);
mln::io::ppm::save(output,"./out.ppm");
}
1
0