* mln/topo/n_face.hh
(mln::topo::n_face<D>::lower_dim_adj_faces)
(mln::topo::n_face<D>::higher_dim_adj_faces):
Return algebraic n-faces.
(mln::topo::make_n_face): Remove useless helper.
(mln::topo::edge(const n_face<0, D>&, const n_face<0, D>&)):
Have this helper return an algebraic 1-face, and move it...
* milena/mln/topo/face.hh: ...here.
---
milena/ChangeLog | 13 ++++++
milena/mln/topo/algebraic_n_face.hh | 53 +++++++++++++++++++++++
milena/mln/topo/n_face.hh | 78 +++-------------------------------
3 files changed, 73 insertions(+), 71 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 8f68af8..334b083 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,18 @@
2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+ Adjust (non algebraic) n-faces.
+
+ * mln/topo/n_face.hh
+ (mln::topo::n_face<D>::lower_dim_adj_faces)
+ (mln::topo::n_face<D>::higher_dim_adj_faces):
+ Return algebraic n-faces.
+ (mln::topo::make_n_face): Remove useless helper.
+ (mln::topo::edge(const n_face<0, D>&, const n_face<0, D>&)):
+ Have this helper return an algebraic 1-face, and move it...
+ * milena/mln/topo/face.hh: ...here.
+
+2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+
Add an algebraic (oriented) face handle (descriptor).
* mln/topo/algebraic_face.hh: New.
diff --git a/milena/mln/topo/algebraic_n_face.hh b/milena/mln/topo/algebraic_n_face.hh
index fbfccf4..9228963 100644
--- a/milena/mln/topo/algebraic_n_face.hh
+++ b/milena/mln/topo/algebraic_n_face.hh
@@ -134,6 +134,32 @@ namespace mln
operator<<(std::ostream& ostr, const algebraic_n_face<N, D>& f);
+ /// \brief Helpers
+ /// \{
+
+ /** \brief Return the algebraic 1-face (edge) linking the 0-faces
+ (vertices) \a f1 and \a f2. If there is no 1-face between \a
+ f1 and \a f2, return an invalid 1-face.
+
+ \pre \a f1 and \a f2 must belong to the same complex.
+
+ Note: this routine assumes the complex is not degenerated, i.e,
+ \li it does not check that \a f1 and \a f2 are the only
+ 0-faces adjacent to an hypothetical 1-face; it just checks
+ that \a f1 and \a f2 <em>share</em> a common 1-face;
+
+ \li if there are several ajacent 1-faces shared by \a f1 and
+ \a f2 (if the complex is ill-formed), there is no
+ guarantee on the returned 1-face (the current
+ implementation return the first 1-face found, but client
+ code should not rely on this implementation-defined
+ behavior). */
+ template <unsigned D>
+ algebraic_n_face<1, D>
+ edge(const n_face<0, D>& f1, const n_face<0, D>& f2);
+ /// \}
+
+
# ifndef MLN_INCLUDE_ONLY
@@ -253,6 +279,33 @@ namespace mln
<< ", id = " << f.face_id() << ", sign = "
<< f.sign()<< ')';
}
+ /*----------.
+ | Helpers. |
+ `----------*/
+
+ template <unsigned D>
+ algebraic_n_face<1, D>
+ edge(const n_face<0, D>& f1, const n_face<0, D>& f2)
+ {
+ typedef std::vector< algebraic_n_face<0, D> > n0_faces_t;
+ typedef std::vector< algebraic_n_face<1, D> > n1_faces_t;
+
+ n1_faces_t f1_adj_edges = f1.higher_dim_adj_faces();
+ for (typename n1_faces_t::const_iterator e = f1_adj_edges.begin();
+ e != f1_adj_edges.end(); ++e)
+ {
+ n0_faces_t e_adj_vertices = e->lower_dim_adj_faces();
+ for (typename n0_faces_t::const_iterator w = e_adj_vertices.begin();
+ w != e_adj_vertices.end(); ++w)
+ if (*w == f2)
+ // E is the edge linking F1 and F2.
+ return *e;
+ }
+
+ // If no shared edge was found, retun an empty (invalid) 1-face.
+ return algebraic_n_face<1, D>();
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::topo
diff --git a/milena/mln/topo/n_face.hh b/milena/mln/topo/n_face.hh
index 68a9512..2f8a7e0 100644
--- a/milena/mln/topo/n_face.hh
+++ b/milena/mln/topo/n_face.hh
@@ -46,6 +46,7 @@ namespace mln
// Forward declaration.
template <unsigned D> class complex;
template <unsigned N, unsigned D> class face_data;
+ template <unsigned N, unsigned D> class algebraic_n_face;
/*---------.
@@ -57,8 +58,9 @@ namespace mln
/// Contrary to an mln::topo::face, the dimension of an
/// mln::topo::n_face is fixed.
template <unsigned N, unsigned D>
- struct n_face
+ class n_face
{
+ public:
// The type of the complex this handle points to.
typedef complex<D> complex_type;
@@ -98,9 +100,9 @@ namespace mln
/* FIXME: We should not provide lower_dim_adj_faces() when N ==
0 nor higher_dim_adj_faces() when N == D. */
/// \Return an array of face handles pointing to adjacent (n-1)-faces.
- std::vector< n_face<N - 1, D> > lower_dim_adj_faces() const;
+ std::vector< algebraic_n_face<N - 1, D> > lower_dim_adj_faces() const;
/// Return an array of face handles pointing to adjacent (n+1)-faces.
- std::vector< n_face<N + 1, D> > higher_dim_adj_faces() const;
+ std::vector< algebraic_n_face<N + 1, D> > higher_dim_adj_faces()
const;
/// \}
private:
@@ -114,12 +116,6 @@ namespace mln
};
- /// 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.
/// \{
@@ -155,31 +151,6 @@ namespace mln
operator<<(std::ostream& ostr, const n_face<N, D>& f);
- /// \brief Helpers
- /// \{
-
- /** \brief Return the 1-face (edge) linking the 0-faces (vertices)
- \a f1 and \a f2. If there is no 1-face between \a f1 and \a
- f2, return an invalid 1-face.
-
- \pre \a f1 and \a f2 must belong to the same complex.
-
- Note: this routine assumes the complex is not degenerated, i.e,
- \li it does not check that \a f1 and \a f2 are the only
- 0-faces adjacent to an hypothetical 1-face; it just checks
- that \a f1 and \a f2 <em>share</em> a common 1-face;
-
- \li if there are several ajacent 1-faces shared by \a f1 and
- \a f2 (if the complex is ill-formed), there is no
- guarantee on the returned 1-face (the current
- implementation return the first 1-face found, but client
- code should not rely on this implementation-defined
- behavior). */
- template <unsigned D>
- n_face<1, D> edge(const n_face<0, D>& f1, const n_face<0,
D>& f2);
- /// \}
-
-
# ifndef MLN_INCLUDE_ONLY
@@ -285,7 +256,7 @@ namespace mln
template <unsigned N, unsigned D>
inline
- std::vector< n_face<N - 1, D> >
+ std::vector< algebraic_n_face<N - 1, D> >
n_face<N, D>::lower_dim_adj_faces() const
{
mln_precondition(N > 0);
@@ -295,7 +266,7 @@ namespace mln
template <unsigned N, unsigned D>
inline
- std::vector< n_face<N + 1, D> >
+ std::vector< algebraic_n_face<N + 1, D> >
n_face<N, D>::higher_dim_adj_faces() const
{
mln_precondition(N <= D);
@@ -306,15 +277,6 @@ namespace mln
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)
{
@@ -353,32 +315,6 @@ namespace mln
<< ", id = " << f.face_id() << ')';
}
- /*----------.
- | Helpers. |
- `----------*/
-
- template <unsigned D>
- n_face<1, D> edge(const n_face<0, D>& f1, const n_face<0,
D>& f2)
- {
- typedef std::vector< n_face<0, D> > n0_faces_t;
- typedef std::vector< n_face<1, D> > n1_faces_t;
-
- n1_faces_t f1_adj_edges = f1.higher_dim_adj_faces();
- for (typename n1_faces_t::const_iterator e = f1_adj_edges.begin();
- e != f1_adj_edges.end(); ++e)
- {
- n0_faces_t e_adj_vertices = e->lower_dim_adj_faces();
- for (typename n0_faces_t::const_iterator w = e_adj_vertices.begin();
- w != e_adj_vertices.end(); ++w)
- if (*w == f2)
- // E is the edge linking F1 and F2.
- return *e;
- }
-
- // If no shared edge was found, retun an empty (invalid) 1-face.
- return n_face<1, D>();
- }
-
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::topo
--
1.5.6.5