* milena/mln/core/site_set/p_complex_faces_piter.hh,
* milena/mln/core/site_set/p_faces_piter.hh,
* milena/mln/topo/complex_faces_iter.hh,
* milena/mln/topo/faces_iter.hh:
Move...
* milena/mln/core/site_set/attic/p_complex_faces_piter.hh,
* milena/mln/core/site_set/attic/p_faces_piter.hh,
* milena/mln/topo/attic/complex_faces_iter.hh,
* milena/mln/topo/attic/faces_iter.hh:
...here.
Disable these iterators...
* milena/mln/core/site_set/p_complex.hh,
* milena/mln/core/site_set/p_faces.hh,
* milena/mln/topo/complex.hh,
* milena/tests/core/image/complex_image.cc,
* milena/tests/topo/complex.cc:
...in those files.
---
milena/ChangeLog | 22 ++++++++++++++++++++
.../site_set/{ => attic}/p_complex_faces_piter.hh | 0
.../mln/core/site_set/{ => attic}/p_faces_piter.hh | 0
milena/mln/core/site_set/p_complex.hh | 9 ++++++-
milena/mln/core/site_set/p_faces.hh | 6 ++++-
milena/mln/topo/{ => attic}/complex_faces_iter.hh | 0
milena/mln/topo/{ => attic}/faces_iter.hh | 0
milena/mln/topo/complex.hh | 14 ++++++++++--
milena/tests/core/image/complex_image.cc | 8 ++----
milena/tests/topo/complex.cc | 13 ++++++++++-
10 files changed, 59 insertions(+), 13 deletions(-)
rename milena/mln/core/site_set/{ => attic}/p_complex_faces_piter.hh (100%)
rename milena/mln/core/site_set/{ => attic}/p_faces_piter.hh (100%)
rename milena/mln/topo/{ => attic}/complex_faces_iter.hh (100%)
rename milena/mln/topo/{ => attic}/faces_iter.hh (100%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 9bd58d5..d105628 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,27 @@
2008-09-26 Roland Levillain <roland(a)lrde.epita.fr>
+ Disable old iterators on n-faces (with n statically known).
+
+ * milena/mln/core/site_set/p_complex_faces_piter.hh,
+ * milena/mln/core/site_set/p_faces_piter.hh,
+ * milena/mln/topo/complex_faces_iter.hh,
+ * milena/mln/topo/faces_iter.hh:
+ Move...
+ * milena/mln/core/site_set/attic/p_complex_faces_piter.hh,
+ * milena/mln/core/site_set/attic/p_faces_piter.hh,
+ * milena/mln/topo/attic/complex_faces_iter.hh,
+ * milena/mln/topo/attic/faces_iter.hh:
+ ...here.
+ Disable these iterators...
+ * milena/mln/core/site_set/p_complex.hh,
+ * milena/mln/core/site_set/p_faces.hh,
+ * milena/mln/topo/complex.hh,
+ * milena/tests/core/image/complex_image.cc,
+ * milena/tests/topo/complex.cc:
+ ...in those files.
+
+2008-09-26 Roland Levillain <roland(a)lrde.epita.fr>
+
Split mln/topo/face.hh.
* milena/mln/topo/face.hh
diff --git a/milena/mln/core/site_set/p_complex_faces_piter.hh b/milena/mln/core/site_set/attic/p_complex_faces_piter.hh
similarity index 100%
rename from milena/mln/core/site_set/p_complex_faces_piter.hh
rename to milena/mln/core/site_set/attic/p_complex_faces_piter.hh
diff --git a/milena/mln/core/site_set/p_faces_piter.hh b/milena/mln/core/site_set/attic/p_faces_piter.hh
similarity index 100%
rename from milena/mln/core/site_set/p_faces_piter.hh
rename to milena/mln/core/site_set/attic/p_faces_piter.hh
diff --git a/milena/mln/core/site_set/p_complex.hh b/milena/mln/core/site_set/p_complex.hh
index a747b69..06fc8b2 100644
--- a/milena/mln/core/site_set/p_complex.hh
+++ b/milena/mln/core/site_set/p_complex.hh
@@ -37,7 +37,10 @@
# include <mln/core/site_set/complex_psite.hh>
# include <mln/core/site_set/p_complex_piter.hh>
-# include <mln/core/site_set/p_complex_faces_piter.hh>
+// FIXME: Disabled (moved to the attic).
+# if 0
+# include <mln/core/site_set/p_complex_faces_piter.hh>
+# endif
namespace mln
@@ -49,11 +52,13 @@ namespace mln
template <unsigned D, typename P> class p_complex_fwd_piter_;
template <unsigned D, typename P> class p_complex_bkd_piter_;
+// FIXME: Disabled (moved to the attic).
+# if 0
template <unsigned N, unsigned D, typename P>
class p_complex_faces_fwd_piter_;
template <unsigned N, unsigned D, typename P>
class p_complex_faces_bkd_piter_;
-
+# endif
namespace trait
{
diff --git a/milena/mln/core/site_set/p_faces.hh b/milena/mln/core/site_set/p_faces.hh
index b17f85a..6df4ded 100644
--- a/milena/mln/core/site_set/p_faces.hh
+++ b/milena/mln/core/site_set/p_faces.hh
@@ -37,7 +37,11 @@
# include <mln/topo/complex.hh>
# include <mln/core/faces_psite.hh>
-# include <mln/core/site_set/p_faces_piter.hh>
+
+// FIXME: Disabled (moved to the attic).
+# if 0
+# include <mln/core/site_set/p_faces_piter.hh>
+# endif
# include <mln/core/site_set/p_complex.hh>
diff --git a/milena/mln/topo/complex_faces_iter.hh b/milena/mln/topo/attic/complex_faces_iter.hh
similarity index 100%
rename from milena/mln/topo/complex_faces_iter.hh
rename to milena/mln/topo/attic/complex_faces_iter.hh
diff --git a/milena/mln/topo/faces_iter.hh b/milena/mln/topo/attic/faces_iter.hh
similarity index 100%
rename from milena/mln/topo/faces_iter.hh
rename to milena/mln/topo/attic/faces_iter.hh
diff --git a/milena/mln/topo/complex.hh b/milena/mln/topo/complex.hh
index bef3ca9..2ce88fd 100644
--- a/milena/mln/topo/complex.hh
+++ b/milena/mln/topo/complex.hh
@@ -49,9 +49,11 @@
# include <mln/topo/n_faces_set.hh>
# include <mln/topo/complex_iter.hh>
-# include <mln/topo/faces_iter.hh>
-# include <mln/topo/complex_faces_iter.hh>
-
+// FIXME: Disabled (moved to the attic).
+# if 0
+# include <mln/topo/faces_iter.hh>
+# include <mln/topo/complex_faces_iter.hh>
+# endif
namespace mln
{
@@ -63,8 +65,11 @@ namespace mln
template <unsigned N, unsigned D> class n_faces_set;
template <unsigned D> class complex_fwd_iter_;
template <unsigned D> class complex_bkd_iter_;
+// FIXME: Disabled (moved to the attic).
+# if 0
template <unsigned N, unsigned D> class faces_fwd_iter_;
template <unsigned N, unsigned D> class faces_bkd_iter_;
+#endif
// Forward declarations (internal).
namespace internal
@@ -91,12 +96,15 @@ namespace mln
/// Backward mln::Iterator type iterating on all faces.
typedef complex_bkd_iter_<D> bkd_citer;
+// FIXME: Disabled (moved to the attic).
+# if 0
/// Forward mln::Iterator type iterating on \p N-faces.
template <unsigned N>
struct fwd_fiter { typedef faces_fwd_iter_<N, D> ret; };
/// Backward mln::Iterator type iterating on \p N-faces.
template <unsigned N>
struct bkd_fiter { typedef faces_bkd_iter_<N, D> ret; };
+#endif
/// Complex construction.
/// \{
diff --git a/milena/tests/core/image/complex_image.cc b/milena/tests/core/image/complex_image.cc
index 148041d..47233cb 100644
--- a/milena/tests/core/image/complex_image.cc
+++ b/milena/tests/core/image/complex_image.cc
@@ -164,15 +164,13 @@ int main()
// Iterators on n-faces (with n fixed in [0, D]). //
// ----------------------------------------------- //
- // We need to instantiate a (non temporary) object on the stack, so
- // that it can be referenced later by face_psites held by iterators
- // (as for windows and neighborhoods).
-
+// FIXME: Disabled (moved to the attic).
+# if 0
// FIXME: Sugar the name of the iterator.
p_complex_faces_fwd_piter_<0, D, point2d> f0p(ima.domain());
for_all(f0p)
std::cout << "ima(" << f0p << ") = " << ima(f0p) << std::endl;
-
+#endif
/* FIXME: Implement other psite iterators, for instance:
diff --git a/milena/tests/topo/complex.cc b/milena/tests/topo/complex.cc
index 6b8c17e..eeaeb14 100644
--- a/milena/tests/topo/complex.cc
+++ b/milena/tests/topo/complex.cc
@@ -143,6 +143,8 @@ int main()
actual complex processing since they are not really flexible ---
but I'm not sure. */
+// FIXME: Disabled (moved to the attic).
+# if 0
/* Using faces_{fwd,bkd}_iter_<N, D>, which are proxies to
n_faces<N, D>. */
test_faces_iter<0>(c);
@@ -154,6 +156,7 @@ int main()
test_complex_faces_iter<0>(c);
test_complex_faces_iter<1>(c);
test_complex_faces_iter<2>(c);
+#endif
/*------------------------------.
| Iterators on adjacent faces. |
@@ -269,8 +272,11 @@ int main()
| 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?
+
+ I'm unsure about the old iterators on n-faces (with a static n)
+ moved to the attic; should we keep them? What are they good for,
+ except testing our code? At least, we should find better names
+ for them, as we might confuse them with new iterators.
-----------------------------------------------------------------
Current name Definition
@@ -287,6 +293,8 @@ int main()
}
+// FIXME: Disabled (moved to the attic).
+# if 0
template <unsigned N, unsigned D>
void
test_faces_iter(topo::complex<D>& c)
@@ -315,3 +323,4 @@ test_complex_faces_iter(topo::complex<D>& c)
std::cout << fwd_ncf << ' ' << bkd_ncf << std::endl;
std::cout << std::endl;
}
+#endif
--
1.6.0.1
* 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
* 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
---
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