* milena/mln/topo/n_faces_set.hh
(mln::topo::n_faces_set::faces_type): New typedef.
Use it as type of...
(mln::topo::n_faces_set::faces_): ...this member.
(mln::topo::n_faces_set::faces)
(mln::topo::n_faces_set::add):
Adjust methods.
(operator+(const algebraic_n_face<N,D>&, const
algebraic_n_face<N,D>&))
(operator+(const n_face<N,D>&, const algebraic_n_face<N,D>&))
(operator+(const algebraic_n_face<N,D>&, const n_face<N,D>&))
(operator+(const n_faces_set<N,D>&, const algebraic_n_face<N,D>))
(operator-(const algebraic_n_face<N,D>&, const
algebraic_n_face<N,D>&))
(operator-(const n_face<N,D>&, const algebraic_n_face<N,D>&))
(operator-(const algebraic_n_face<N,D>&, const n_face<N,D>&))
(operator-(const n_face<N,D>&, const n_face<N,D>&))
(operator-(const n_faces_set<N,D>&, const algebraic_n_face<N,D>))
(operator-(const n_faces_set<N,D>&, const n_face<N,D>))
(operator-=(n_faces_set<N,D>&, const algebraic_n_face<N, D>&))
New operators.
(operator+=(n_faces_set<N,D>&, const n_face<N, D>&)):
Turn into...
(operator+=(n_faces_set<N,D>&, const algebraic_n_face<N, D>&)):
...this.
* tests/topo/complex.cc: Adjust test.
---
milena/ChangeLog | 29 +++++
milena/mln/topo/n_faces_set.hh | 229 +++++++++++++++++++++++++++++++++++++---
milena/tests/topo/complex.cc | 18 ++--
3 files changed, 251 insertions(+), 25 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 6076a89..5395ca0 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,34 @@
2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+ Convert n-faces set to algebraic faces.
+
+ * milena/mln/topo/n_faces_set.hh
+ (mln::topo::n_faces_set::faces_type): New typedef.
+ Use it as type of...
+ (mln::topo::n_faces_set::faces_): ...this member.
+ (mln::topo::n_faces_set::faces)
+ (mln::topo::n_faces_set::add):
+ Adjust methods.
+ (operator+(const algebraic_n_face<N,D>&, const
algebraic_n_face<N,D>&))
+ (operator+(const n_face<N,D>&, const algebraic_n_face<N,D>&))
+ (operator+(const algebraic_n_face<N,D>&, const n_face<N,D>&))
+ (operator+(const n_faces_set<N,D>&, const algebraic_n_face<N,D>))
+ (operator-(const algebraic_n_face<N,D>&, const
algebraic_n_face<N,D>&))
+ (operator-(const n_face<N,D>&, const algebraic_n_face<N,D>&))
+ (operator-(const algebraic_n_face<N,D>&, const n_face<N,D>&))
+ (operator-(const n_face<N,D>&, const n_face<N,D>&))
+ (operator-(const n_faces_set<N,D>&, const algebraic_n_face<N,D>))
+ (operator-(const n_faces_set<N,D>&, const n_face<N,D>))
+ (operator-=(n_faces_set<N,D>&, const algebraic_n_face<N, D>&))
+ New operators.
+ (operator+=(n_faces_set<N,D>&, const n_face<N, D>&)):
+ Turn into...
+ (operator+=(n_faces_set<N,D>&, const algebraic_n_face<N, D>&)):
+ ...this.
+ * tests/topo/complex.cc: Adjust test.
+
+2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+
Adjust (non algebraic) faces.
* mln/topo/face.hh
diff --git a/milena/mln/topo/n_faces_set.hh b/milena/mln/topo/n_faces_set.hh
index cf11eef..cafd410 100644
--- a/milena/mln/topo/n_faces_set.hh
+++ b/milena/mln/topo/n_faces_set.hh
@@ -34,7 +34,9 @@
#include <vector>
#include <mln/core/contract.hh>
-#include <mln/topo/n_face.hh>
+#include <mln/topo/algebraic_n_face.hh>
+
+// FIXME: Rename as algebraic_n_faces_set?
namespace mln
@@ -47,17 +49,17 @@ namespace mln
template <unsigned D> class complex;
- /*------------------------.
- | Set of n-face handles. |
- `------------------------*/
+ /*------------------------------------.
+ | Set of (algebraic) n-face handles. |
+ `------------------------------------*/
/// \brief Set of face handles of dimension \p N.
template <unsigned N, unsigned D>
class n_faces_set
{
public:
- /// \brief Append face \a f to the set.
- void add(const n_face<N, D>& f);
+ /// \brief Append an algebraic face \a f to the set.
+ void add(const algebraic_n_face<N, D>& f);
/// \brief Reserve \a n cells in the set.
///
@@ -66,44 +68,109 @@ namespace mln
/// efficiency purpose, and its use is completely optional.
void reserve(size_t n);
+ /// The type of the set of face handles.
+ typedef std::vector< algebraic_n_face<N, D> > faces_type;
+
/// \brief Accessors.
///
/// Return the set of handles.
/// \{
- const std::vector< n_face<N, D> >& faces() const;
+ const faces_type& faces() const;
/// \}
private:
friend class complex<D>;
- // FIXME: Rename this as `handles_'?
- std::vector< n_face<N, D> > faces_;
+ /// The set of face handles.
+ faces_type faces_;
};
- /// Construction helpers for mln::topo::n_faces_set.
+ /*-----------------------.
+ | Construction helpers. |
+ `-----------------------*/
+
+ /* FIXME: We can probably reduce the number of operators, given
+ the fact that ``a - b'' is equivalent to ``a + (-b)''. */
+
+ /// Addition.
/// \{
template <unsigned N, unsigned D>
n_faces_set<N, D>
+ operator+(const algebraic_n_face<N, D>& f1,
+ const algebraic_n_face<N, D>& f2);
+
+ template <unsigned N, unsigned D>
+ n_faces_set<N, D>
+ operator+(const algebraic_n_face<N, D>& f1, const n_face<N, D>&
f2);
+
+ template <unsigned N, unsigned D>
+ n_faces_set<N, D>
+ operator+(const n_face<N, D>& f1, const algebraic_n_face<N, D>&
f2);
+
+ 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 algebraic_n_face<N,
D>& f);
+
template <unsigned N, unsigned D>
n_faces_set<N, D>
operator+(const n_faces_set<N, D>& fs, const n_face<N, D>& f);
template <unsigned N, unsigned D>
n_faces_set<N, D>&
- operator+=(n_faces_set<N, D>& fs, const n_face<N, D>& f);
+ operator+=(n_faces_set<N, D>& fs, const algebraic_n_face<N, D>&
f);
+ /// \}
+
+ /// Subtraction.
+ /// \{
+ template <unsigned N, unsigned D>
+ n_faces_set<N, D>
+ operator-(const algebraic_n_face<N, D>& f1,
+ const algebraic_n_face<N, D>& f2);
+
+ template <unsigned N, unsigned D>
+ n_faces_set<N, D>
+ operator-(const algebraic_n_face<N, D>& f1, const n_face<N, D>&
f2);
+
+ template <unsigned N, unsigned D>
+ n_faces_set<N, D>
+ operator-(const n_face<N, D>& f1, const algebraic_n_face<N, D>&
f2);
+
+ 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 algebraic_n_face<N,
D>& f);
+
+ template <unsigned N, unsigned D>
+ n_faces_set<N, D>
+ operator-(const n_faces_set<N, D>& fs, const n_face<N, D>& f);
+
+ template <unsigned N, unsigned D>
+ n_faces_set<N, D>&
+ operator-=(n_faces_set<N, D>& fs, const algebraic_n_face<N, D>&
f);
/// \}
# ifndef MLN_INCLUDE_ONLY
+ /*------------------------------------.
+ | Set of (algebraic) n-face handles. |
+ `------------------------------------*/
+
template <unsigned N, unsigned D>
inline
void
- n_faces_set<N, D>::add(const n_face<N, D>& f)
+ n_faces_set<N, D>::add(const algebraic_n_face<N, D>& f)
{
// Check consistency.
if (!faces_.empty())
@@ -121,17 +188,25 @@ namespace mln
template <unsigned N, unsigned D>
inline
- const std::vector< n_face<N, D> >&
+ const std::vector< algebraic_n_face<N, D> >&
n_faces_set<N, D>::faces() const
{
return faces_;
}
+ /*-----------------------.
+ | Construction helpers. |
+ `-----------------------*/
+
+ // ---------- //
+ // Addition. //
+ // ---------- //
template <unsigned N, unsigned D>
inline
n_faces_set<N, D>
- operator+(const n_face<N, D>& f1, const n_face<N, D>& f2)
+ operator+(const algebraic_n_face<N, D>& f1,
+ const algebraic_n_face<N, D>& f2)
{
n_faces_set<N, D> fs;
fs.add(f1);
@@ -142,7 +217,41 @@ namespace mln
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)
+ operator+(const algebraic_n_face<N, D>& f1, const n_face<N, D>&
f2)
+ {
+ n_faces_set<N, D> fs;
+ fs.add(f1);
+ fs.add(make_algebraic_n_face(f2, true));
+ return fs;
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ n_faces_set<N, D>
+ operator+(const n_face<N, D>& f1, const algebraic_n_face<N, D>&
f2)
+ {
+ n_faces_set<N, D> fs;
+ fs.add(make_algebraic_n_face(f1, true));
+ fs.add(f2);
+ return fs;
+ }
+
+ 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(make_algebraic_n_face(f1, true));
+ fs.add(make_algebraic_n_face(f2, true));
+ return fs;
+ }
+
+
+ template <unsigned N, unsigned D>
+ inline
+ n_faces_set<N, D>
+ operator+(const n_faces_set<N, D>& fs, const algebraic_n_face<N,
D>& f)
{
n_faces_set<N, D> fs2(fs);
fs2.add(f);
@@ -150,13 +259,101 @@ namespace mln
}
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(make_algebraic_n_face(f, true));
+ return fs2;
+ }
+
+ template <unsigned N, unsigned D>
n_faces_set<N, D>&
- operator+=(n_faces_set<N, D>& fs, const n_face<N, D>& f)
+ operator+=(n_faces_set<N, D>& fs, const algebraic_n_face<N, D>&
f)
{
fs.add(f);
return fs;
}
+ // ------------- //
+ // Subtraction. //
+ // ------------- //
+
+ template <unsigned N, unsigned D>
+ inline
+ n_faces_set<N, D>
+ operator-(const algebraic_n_face<N, D>& f1,
+ const algebraic_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 algebraic_n_face<N, D>& f1, const n_face<N, D>&
f2)
+ {
+ n_faces_set<N, D> fs;
+ fs.add(f1);
+ fs.add(make_algebraic_n_face(f2, false));
+ return fs;
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ n_faces_set<N, D>
+ operator-(const n_face<N, D>& f1, const algebraic_n_face<N, D>&
f2)
+ {
+ n_faces_set<N, D> fs;
+ fs.add(make_algebraic_n_face(f1, true));
+ fs.add(-f2);
+ return fs;
+ }
+
+ 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(make_algebraic_n_face(f1, true));
+ fs.add(make_algebraic_n_face(f2, false));
+ return fs;
+ }
+
+
+ template <unsigned N, unsigned D>
+ inline
+ n_faces_set<N, D>
+ operator-(const n_faces_set<N, D>& fs, const algebraic_n_face<N,
D>& f)
+ {
+ n_faces_set<N, D> fs2(fs);
+ fs2.add(-f);
+ return fs2;
+ }
+
+ 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(make_algebraic_n_face(f, false));
+ return fs2;
+ }
+
+ template <unsigned N, unsigned D>
+ n_faces_set<N, D>&
+ operator-=(n_faces_set<N, D>& fs, const algebraic_n_face<N, D>&
f)
+ {
+ fs.add(-f);
+ return fs;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::topo
diff --git a/milena/tests/topo/complex.cc b/milena/tests/topo/complex.cc
index 7d5d354..3f87de7 100644
--- a/milena/tests/topo/complex.cc
+++ b/milena/tests/topo/complex.cc
@@ -85,15 +85,15 @@ int main()
topo::n_face<0, D> v3 = c.add_face();
// 1-faces (segments).
- 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);
+ topo::n_face<1, D> e0 = c.add_face(-v1 + v0);
+ topo::n_face<1, D> e1 = c.add_face(-v0 + v2);
+ topo::n_face<1, D> e2 = c.add_face(-v2 + v1);
+ topo::n_face<1, D> e3 = c.add_face(-v0 + v3);
+ topo::n_face<1, D> e4 = c.add_face(-v3 + v2);
// 2-faces (triangles).
- topo::n_face<2, D> t0 = c.add_face(e0 + e1 + e2);
- topo::n_face<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;
@@ -133,7 +133,7 @@ int main()
`-----------------*/
// Adjacent lower-dimension faces of AF.
- std::vector< topo::face<D> > af_lower_dim_adj_faces =
+ std::vector< topo::algebraic_face<D> > af_lower_dim_adj_faces =
af.lower_dim_adj_faces();
std::cout << "lower-dimension faces adjacent to " << af <<
":" << std::endl;
std::copy (af_lower_dim_adj_faces.begin(), af_lower_dim_adj_faces.end(),
@@ -141,7 +141,7 @@ int main()
std::cout << std::endl;
// Adjacent higher-dimension faces of AF.
- std::vector< topo::face<D> > af_higher_dim_adj_faces =
+ std::vector< topo::algebraic_face<D> > af_higher_dim_adj_faces =
af.higher_dim_adj_faces();
std::cout << "higher-dimension faces adjacent to " << af <<
":" << std::endl;
std::copy (af_higher_dim_adj_faces.begin(), af_higher_dim_adj_faces.end(),
--
1.5.6.5