https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Improve handling of faces (of complexes) of lowest and highest
dimensions.
* mln/core/face.hh (mln::face<D, D>, mln::face<0u, 0u>): New.
* mln/core/complex.hh
(mln::internal::faces_set_mixin<D, D>)
(mln::internal::faces_set_mixin<0u, 0u>): New.
(mln::internal::faces_set_mixin<0u, D>::print): Aesthetic change.
complex.hh | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++------
face.hh | 29 +++++++++++++++++++++-
2 files changed, 101 insertions(+), 8 deletions(-)
Index: mln/core/complex.hh
--- mln/core/complex.hh (revision 2116)
+++ mln/core/complex.hh (working copy)
@@ -121,8 +121,6 @@
| Faces of a complex. |
`---------------------*/
- // FIXME: Move these declarations after � Complex �.
-
/// The sets of n-faces of a complex are recursively aggregated as
/// mixins.
namespace internal
@@ -159,6 +157,32 @@
void print_rec_asc(std::ostream& ostr) const;
/// \}
};
+
+ template <unsigned D>
+ struct faces_set_mixin<D, D> : faces_set_mixin<D - 1, D>
+ {
+ std::vector< face<D, D> > faces_;
+
+ /// Pretty-printing.
+ /// \{
+ /// Print the faces of dimension \p D.
+ void print(std::ostream& ostr) const;
+ void print_rec_asc(std::ostream& ostr) const;
+ /// \}
+ };
+
+ template <>
+ struct faces_set_mixin<0u, 0u>
+ {
+ std::vector< face<0u, 0u> > faces_;
+
+ /// Pretty-printing.
+ /// \{
+ /// Print the faces of dimension \p D.
+ void print(std::ostream& ostr) const;
+ void print_rec_asc(std::ostream& ostr) const;
+ /// \}
+ };
/// \}
} // end of namespace mln::internal
@@ -279,7 +303,21 @@
template <unsigned D>
void
- faces_set_mixin<0, D>::print_rec_asc(std::ostream& ostr) const
+ faces_set_mixin<0u, D>::print_rec_asc(std::ostream& ostr) const
+ {
+ print(ostr);
+ }
+
+ template <unsigned D>
+ void
+ faces_set_mixin<D, D>::print_rec_asc(std::ostream& ostr) const
+ {
+ faces_set_mixin<D - 1, D>::print_rec_asc(ostr);
+ print(ostr);
+ }
+
+ void
+ faces_set_mixin<0u, 0u>::print_rec_asc(std::ostream& ostr) const
{
print(ostr);
}
@@ -316,13 +354,13 @@
faces_set_mixin<0u, D>::print(std::ostream& ostr) const
{
// FIXME: Much could be factored with the previous routine.
- const unsigned N = 0;
+ const unsigned N = 0u;
ostr << "Faces of dimension " << N
<< " and their ajacent faces of dimension "
<< N + 1 << std::endl;
for (unsigned f = 0; f < faces_.size(); ++f)
{
- ostr << " " << f << " dim " << N + 1
<< ": { ";
+ ostr << " " << f << ": dim " << N + 1
<< ": { ";
for (typename std::vector< face_handle<N + 1, D> >::const_iterator h =
faces_[f].higher_dim_faces_.begin();
h != faces_[f].higher_dim_faces_.end();
@@ -333,9 +371,37 @@
}
}
+ template <unsigned D>
+ void
+ faces_set_mixin<D, D>::print(std::ostream& ostr) const
+ {
+ // FIXME: Much could be factored with the previous routines.
+ const unsigned N = D;
+ ostr << "Faces of dimension " << N
+ << " and their ajacent faces of dimension "
+ << N - 1 << std::endl;
+ for (unsigned f = 0; f < faces_.size(); ++f)
+ {
+ ostr << " " << f << ": dim " << N - 1
<< ": { ";
+ for (typename std::vector< face_handle<N - 1, D> >::const_iterator l =
+ faces_[f].lower_dim_faces_.begin();
+ l != faces_[f].lower_dim_faces_.end();
+ ++l)
+ ostr << l->face_id_ << " ";
+ ostr << "}";
+ ostr << std::endl;
+ }
+ }
- // FIXME: Handle faces_set_mixin<D, D>::print.
-
+ void
+ faces_set_mixin<0u, 0u>::print(std::ostream& ostr) const
+ {
+ // FIXME: Much could be factored with the previous routines.
+ const unsigned N = 0u;
+ ostr << "Faces of dimension " << N << std::endl;
+ for (unsigned f = 0; f < faces_.size(); ++f)
+ ostr << " " << f << std::endl;
+ }
} // end of namespace mln::internal
Index: mln/core/face.hh
--- mln/core/face.hh (revision 2116)
+++ mln/core/face.hh (working copy)
@@ -74,6 +74,7 @@
std::vector< face_handle<N - 1, D> > lower_dim_faces_;
};
+ // Specialization for the faces of lowest dimension (0).
template <unsigned D>
class face<0u, D>
{
@@ -88,7 +89,26 @@
std::vector< face_handle<1u, D> > higher_dim_faces_;
};
- // FIXME: Handle face<0u, 0u>.
+ // Specialization for the faces of highest dimension (D).
+ template <unsigned D>
+ class face<D, D>
+ {
+ public:
+ void connect_lower_dim_face(const face_handle<1u, D>& f);
+
+ private:
+ friend class mln::internal::faces_set_mixin<D, D>;
+
+ // FIXME: Provide accessors instead of using `friend; if there are
+ // clients other than mln::internal::faces_set_mixin<0, D>.
+ std::vector< face_handle<1u, D> > lower_dim_faces_;
+ };
+
+ // Specialization for the case of a 0-complex.
+ template <>
+ class face<0u, 0u>
+ {
+ };
/*--------------.
@@ -234,6 +254,13 @@
higher_dim_faces_.push_back(f);
}
+ template <unsigned D>
+ void
+ face<D, D>::connect_lower_dim_face(const face_handle<1u, D>& f)
+ {
+ lower_dim_faces_.push_back(f);
+ }
+
/*---------------.
| Set of faces. |