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
* mln/io/off/load.hh (mln::io::off:load): Ensure the end of the
file is reached.
---
milena/ChangeLog | 7 +++++++
milena/mln/io/off/load.hh | 11 +++++++++++
2 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 4d2c9e9..2c8f00d 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,12 @@
2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+ Improve mln::io::off:load.
+
+ * mln/io/off/load.hh (mln::io::off:load): Ensure the end of the
+ file is reached.
+
+2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+
Adjust I/O routines to algebraic faces.
* mln/io/off/load.hh (mln::io::off::load): Adjust.
diff --git a/milena/mln/io/off/load.hh b/milena/mln/io/off/load.hh
index 38e6b6e..60c534b 100644
--- a/milena/mln/io/off/load.hh
+++ b/milena/mln/io/off/load.hh
@@ -264,6 +264,17 @@ namespace mln
// Image.
ima.init_(pc, values);
+ /*--------------.
+ | End of file. |
+ `--------------*/
+
+ istr >> internal::eat_comment;
+ if (!istr.eof())
+ {
+ std::cerr << me << ": `" << filename
+ << "': end of file not reached" << std::endl;
+ std::exit(1);
+ }
istr.close();
}
--
1.5.6.5
1
0
* mln/io/off/load.hh (mln::io::off::load): Adjust.
---
milena/ChangeLog | 6 ++++++
milena/mln/io/off/load.hh | 6 ++++--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index e32143d..4d2c9e9 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,11 @@
2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+ Adjust I/O routines to algebraic faces.
+
+ * mln/io/off/load.hh (mln::io::off::load): Adjust.
+
+2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+
Convert iterators on complexes to algebraic faces.
* mln/topo/internal/complex_relative_iterator_base.hh
diff --git a/milena/mln/io/off/load.hh b/milena/mln/io/off/load.hh
index 6cdf3d5..38e6b6e 100644
--- a/milena/mln/io/off/load.hh
+++ b/milena/mln/io/off/load.hh
@@ -220,14 +220,16 @@ namespace mln
topo::n_face<0, D> vertex(c, vertex_id);
topo::n_face<0, D> next_vertex(c, next_vertex_id);
// The current edge.
- topo::n_face<1, D> edge;
+ topo::algebraic_n_face<1, D> edge;
// If the edge has been constructed yet, create it;
// otherwise, retrieve its id from the complex.
if (!complex_edges[vertex_id][next_vertex_id])
{
complex_edges[vertex_id][next_vertex_id] = true;
complex_edges[next_vertex_id][vertex_id] = true;
- edge = c.add_face(vertex + next_vertex);
+ edge =
+ make_algebraic_n_face(c.add_face(vertex - next_vertex),
+ true);
}
else
{
--
1.5.6.5
1
0
* mln/topo/internal/complex_relative_iterator_base.hh
(topo::internal::complex_relative_iterator_base)
(topo::internal::forward_complex_relative_iterator_base)
(topo::internal::backward_complex_relative_iterator_base):
Add a template parameter C, for the type of the center face, which
might be different from F, the type of the iterated faces.
(topo::internal::complex_relative_iterator_base::center_type):
New typedef.
Use it as type of...
(topo::internal::complex_relative_iterator_base::c_):
...this member.
(topo::internal::complex_relative_iterator_base::center_at):
Adjust.
* mln/topo/internal/complex_iterator_base.hh:
Adjust documentation.
* mln/topo/adj_lower_face_iter.hh,
* mln/topo/adj_higher_face_iter.hh,
* mln/topo/adj_lower_dim_connected_n_face_iter.hh,
* mln/topo/adj_higher_dim_connected_n_face_iter.hh,
* mln/topo/center_only_iter.hh,
* mln/topo/internal/complex_relative_iterator_sequence:
Adjust.
Pass algebraic_face<D> as parameter F to super class, and face<D>
as as parameter C.
* mln/topo/adj_m_face_iter.hh: Likewise.
(adj_m_face_iterator<D>::update_adj_faces__): Have the
algorithm take the sign (orientation) of the face into account.
* mln/topo/adj_lower_higher_face_iter.hh: Remove a useless header
inclusion.
---
milena/ChangeLog | 34 +++++
.../topo/adj_higher_dim_connected_n_face_iter.hh | 18 ++-
milena/mln/topo/adj_higher_face_iter.hh | 6 +-
.../topo/adj_lower_dim_connected_n_face_iter.hh | 14 ++-
milena/mln/topo/adj_lower_face_iter.hh | 6 +-
milena/mln/topo/adj_lower_higher_face_iter.hh | 2 -
milena/mln/topo/adj_m_face_iter.hh | 49 +++++--
milena/mln/topo/center_only_iter.hh | 4 +-
milena/mln/topo/internal/complex_iterator_base.hh | 2 +-
.../internal/complex_relative_iterator_base.hh | 150 ++++++++++----------
.../internal/complex_relative_iterator_sequence.hh | 6 +-
11 files changed, 187 insertions(+), 104 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index e7adf55..e32143d 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,39 @@
2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+ Convert iterators on complexes to algebraic faces.
+
+ * mln/topo/internal/complex_relative_iterator_base.hh
+ (topo::internal::complex_relative_iterator_base)
+ (topo::internal::forward_complex_relative_iterator_base)
+ (topo::internal::backward_complex_relative_iterator_base):
+ Add a template parameter C, for the type of the center face, which
+ might be different from F, the type of the iterated faces.
+ (topo::internal::complex_relative_iterator_base::center_type):
+ New typedef.
+ Use it as type of...
+ (topo::internal::complex_relative_iterator_base::c_):
+ ...this member.
+ (topo::internal::complex_relative_iterator_base::center_at):
+ Adjust.
+ * mln/topo/internal/complex_iterator_base.hh:
+ Adjust documentation.
+ * mln/topo/adj_lower_face_iter.hh,
+ * mln/topo/adj_higher_face_iter.hh,
+ * mln/topo/adj_lower_dim_connected_n_face_iter.hh,
+ * mln/topo/adj_higher_dim_connected_n_face_iter.hh,
+ * mln/topo/center_only_iter.hh,
+ * mln/topo/internal/complex_relative_iterator_sequence:
+ Adjust.
+ Pass algebraic_face<D> as parameter F to super class, and face<D>
+ as as parameter C.
+ * mln/topo/adj_m_face_iter.hh: Likewise.
+ (adj_m_face_iterator<D>::update_adj_faces__): Have the
+ algorithm take the sign (orientation) of the face into account.
+ * mln/topo/adj_lower_higher_face_iter.hh: Remove a useless header
+ inclusion.
+
+2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+
Convert mln::topo::complex to algebraic faces.
* mln/topo/complex.hh
diff --git a/milena/mln/topo/adj_higher_dim_connected_n_face_iter.hh b/milena/mln/topo/adj_higher_dim_connected_n_face_iter.hh
index be619cb..921575e 100644
--- a/milena/mln/topo/adj_higher_dim_connected_n_face_iter.hh
+++ b/milena/mln/topo/adj_higher_dim_connected_n_face_iter.hh
@@ -37,7 +37,7 @@
# include <set>
# include <mln/topo/internal/complex_relative_iterator_base.hh>
-# include <mln/topo/face.hh>
+# include <mln/topo/algebraic_face.hh>
namespace mln
@@ -65,12 +65,14 @@ namespace mln
template <unsigned D>
class adj_higher_dim_connected_n_face_fwd_iter
: public internal::forward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
adj_higher_dim_connected_n_face_fwd_iter<D> >,
- private internal::adj_higher_dim_connected_n_face_iterator<D>
+ private internal::adj_higher_dim_connected_n_face_iterator<D>
{
private:
typedef adj_higher_dim_connected_n_face_fwd_iter<D> self_;
typedef internal::forward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
self_ > super_;
public:
@@ -100,12 +102,14 @@ namespace mln
template <unsigned D>
class adj_higher_dim_connected_n_face_bkd_iter
: public internal::backward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
adj_higher_dim_connected_n_face_bkd_iter<D> >,
- private internal::adj_higher_dim_connected_n_face_iterator<D>
+ private internal::adj_higher_dim_connected_n_face_iterator<D>
{
private:
typedef adj_higher_dim_connected_n_face_bkd_iter<D> self_;
typedef internal::backward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
self_ > super_;
public:
@@ -138,7 +142,7 @@ namespace mln
/// The actual implementation of the computation of the set of
/// faces adjacent to the reference face.
void update_adj_faces__(const face<D>& center,
- std::vector< face<D> >& adj_faces);
+ std::vector< algebraic_face<D> >& adj_faces);
};
} // end of namespace mln::topo::internal
@@ -225,7 +229,7 @@ namespace mln
inline
void
adj_higher_dim_connected_n_face_iterator<D>::update_adj_faces__(const face<D>& center,
- std::vector< face<D> >& adj_faces)
+ std::vector< algebraic_face<D> >& adj_faces)
{
// Reset the result container.
adj_faces.clear();
@@ -235,8 +239,8 @@ namespace mln
added to the pool of adjacent faces. We use an std::set
because the lookup is cheaper (O(log(n)) vs O(n) for a
vector, where n is the size of the containers. */
- std::set< face<D> > faces_set;
- typedef std::vector< face<D> > faces_t;
+ std::set< algebraic_face<D> > faces_set;
+ typedef std::vector< algebraic_face<D> > faces_t;
// The set of (n+1)-faces adjacent to CENTER.
faces_t shared_higher_faces = center.higher_dim_adj_faces();
diff --git a/milena/mln/topo/adj_higher_face_iter.hh b/milena/mln/topo/adj_higher_face_iter.hh
index cfea904..e51d678 100644
--- a/milena/mln/topo/adj_higher_face_iter.hh
+++ b/milena/mln/topo/adj_higher_face_iter.hh
@@ -33,7 +33,7 @@
/// adjacent (n+1)-faces of a (reference) n-face in a complex.
# include <mln/topo/internal/complex_relative_iterator_base.hh>
-# include <mln/topo/face.hh>
+# include <mln/topo/algebraic_face.hh>
namespace mln
@@ -57,10 +57,12 @@ namespace mln
template <unsigned D>
class adj_higher_face_fwd_iter
: public internal::forward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
adj_higher_face_fwd_iter<D> >
{
typedef adj_higher_face_fwd_iter<D> self_;
typedef internal::forward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
self_ > super_;
public:
@@ -87,10 +89,12 @@ namespace mln
template <unsigned D>
class adj_higher_face_bkd_iter
: public internal::backward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
adj_higher_face_bkd_iter<D> >
{
typedef adj_higher_face_bkd_iter<D> self_;
typedef internal::backward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
self_ > super_;
public:
diff --git a/milena/mln/topo/adj_lower_dim_connected_n_face_iter.hh b/milena/mln/topo/adj_lower_dim_connected_n_face_iter.hh
index 181d439..9d35482 100644
--- a/milena/mln/topo/adj_lower_dim_connected_n_face_iter.hh
+++ b/milena/mln/topo/adj_lower_dim_connected_n_face_iter.hh
@@ -37,7 +37,7 @@
# include <set>
# include <mln/topo/internal/complex_relative_iterator_base.hh>
-# include <mln/topo/face.hh>
+# include <mln/topo/algebraic_face.hh>
namespace mln
@@ -65,12 +65,14 @@ namespace mln
template <unsigned D>
class adj_lower_dim_connected_n_face_fwd_iter
: public internal::forward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
adj_lower_dim_connected_n_face_fwd_iter<D> >,
private internal::adj_lower_dim_connected_n_face_iterator<D>
{
private:
typedef adj_lower_dim_connected_n_face_fwd_iter<D> self_;
typedef internal::forward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
self_ > super_;
public:
@@ -100,12 +102,14 @@ namespace mln
template <unsigned D>
class adj_lower_dim_connected_n_face_bkd_iter
: public internal::backward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
adj_lower_dim_connected_n_face_bkd_iter<D> >,
private internal::adj_lower_dim_connected_n_face_iterator<D>
{
private:
typedef adj_lower_dim_connected_n_face_bkd_iter<D> self_;
typedef internal::backward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
self_ > super_;
public:
@@ -138,7 +142,7 @@ namespace mln
/// The actual implementation of the computation of the set of
/// faces adjacent to the reference face.
void update_adj_faces__(const face<D>& center,
- std::vector< face<D> >& adj_faces);
+ std::vector< algebraic_face<D> >& adj_faces);
};
} // end of namespace mln::topo::internal
@@ -225,7 +229,7 @@ namespace mln
inline
void
adj_lower_dim_connected_n_face_iterator<D>::update_adj_faces__(const face<D>& center,
- std::vector< face<D> >& adj_faces)
+ std::vector< algebraic_face<D> >& adj_faces)
{
// Reset the result container.
adj_faces.clear();
@@ -235,8 +239,8 @@ namespace mln
added to the pool of adjacent faces. We use an std::set
because the lookup is cheaper (O(log(n)) vs O(n) for a
vector, where n is the size of the containers. */
- std::set< face<D> > faces_set;
- typedef std::vector< face<D> > faces_t;
+ std::set< algebraic_face<D> > faces_set;
+ typedef std::vector< algebraic_face<D> > faces_t;
// The set of (n-1)-faces adjacent to CENTER.
faces_t shared_lower_faces = center.lower_dim_adj_faces();
diff --git a/milena/mln/topo/adj_lower_face_iter.hh b/milena/mln/topo/adj_lower_face_iter.hh
index e8f5f3f..88cc8f2 100644
--- a/milena/mln/topo/adj_lower_face_iter.hh
+++ b/milena/mln/topo/adj_lower_face_iter.hh
@@ -33,7 +33,7 @@
/// adjacent (n-1)-faces of a (reference) n-face in a complex.
# include <mln/topo/internal/complex_relative_iterator_base.hh>
-# include <mln/topo/face.hh>
+# include <mln/topo/algebraic_face.hh>
namespace mln
@@ -57,11 +57,13 @@ namespace mln
template <unsigned D>
class adj_lower_face_fwd_iter
: public internal::forward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
adj_lower_face_fwd_iter<D> >
{
private:
typedef adj_lower_face_fwd_iter<D> self_;
typedef internal::forward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
self_ > super_;
public:
@@ -88,11 +90,13 @@ namespace mln
template <unsigned D>
class adj_lower_face_bkd_iter
: public internal::backward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
adj_lower_face_bkd_iter<D> >
{
private:
typedef adj_lower_face_bkd_iter<D> self_;
typedef internal::backward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
self_ > super_;
public:
diff --git a/milena/mln/topo/adj_lower_higher_face_iter.hh b/milena/mln/topo/adj_lower_higher_face_iter.hh
index e28b64a..dcd11c2 100644
--- a/milena/mln/topo/adj_lower_higher_face_iter.hh
+++ b/milena/mln/topo/adj_lower_higher_face_iter.hh
@@ -37,8 +37,6 @@
# include <mln/topo/adj_lower_face_iter.hh>
# include <mln/topo/adj_higher_face_iter.hh>
-# include <mln/topo/face.hh>
-
namespace mln
{
diff --git a/milena/mln/topo/adj_m_face_iter.hh b/milena/mln/topo/adj_m_face_iter.hh
index f54a341..d9ed9e5 100644
--- a/milena/mln/topo/adj_m_face_iter.hh
+++ b/milena/mln/topo/adj_m_face_iter.hh
@@ -70,12 +70,14 @@ namespace mln
template <unsigned D>
class adj_m_face_fwd_iter
: public internal::forward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
adj_m_face_fwd_iter<D> >,
public internal::adj_m_face_iterator<D>
{
private:
typedef adj_m_face_fwd_iter<D> self_;
typedef internal::forward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
self_ > super_;
typedef internal::adj_m_face_iterator<D> impl_;
@@ -115,12 +117,14 @@ namespace mln
template <unsigned D>
class adj_m_face_bkd_iter
: public internal::backward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
adj_m_face_bkd_iter<D> >,
public internal::adj_m_face_iterator<D>
{
private:
typedef adj_m_face_bkd_iter<D> self_;
typedef internal::backward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
self_ > super_;
typedef internal::adj_m_face_iterator<D> impl_;
@@ -168,7 +172,7 @@ namespace mln
/// The actual implementation of the computation of the set of
/// faces adjacent to the reference face.
void update_adj_faces__(const face<D>& center,
- std::vector< face<D> >& adj_faces);
+ std::vector< algebraic_face<D> >& adj_faces);
/// The dimension of the iterated faces.
unsigned m_;
@@ -278,22 +282,23 @@ namespace mln
inline
void
adj_m_face_iterator<D>::update_adj_faces__(const face<D>& center,
- std::vector< face<D> >& adj_faces)
+ std::vector< algebraic_face<D> >& adj_faces)
{
adj_faces.clear();
if (center.n() == m_)
return;
- typedef std::vector < topo::face<D> > faces_t;
- typedef std::set < topo::face<D> > faces_set_t;
+ typedef std::vector < topo::algebraic_face<D> > faces_t;
+ typedef std::set < topo::algebraic_face<D> > faces_set_t;
/* FIXME: p_faces is redundant; we could use adj_faces
directly. */
/* The adjacent p-faces being built; initialized with CENTER,
and filled with q-faces at each step, until q reaches
m_. */
- faces_t p_faces(1, center);
+ faces_t p_faces(1,
+ make_algebraic_face(center, true));
// The set of faces being built.
/* FIXME: This pattern is recurring in Milena---using an
std::set (or any fast associative container) to improve
@@ -314,14 +319,34 @@ namespace mln
faces_t q_faces = g->n() < m_ ?
g->higher_dim_adj_faces() :
g->lower_dim_adj_faces();
- // Don't insert a face twice.
- for (typename faces_t::const_iterator h = q_faces.begin();
+ /* Traverse the higher- or lower-dimension adjacent
+ faces of G in the natural order if G's sign is
+ positive, or in the reverse order if G's sign is
+ negative. */
+ /* FIXME: Factor; the code if the two branches is the
+ same, except for the iteration order. */
+ if (g->sign())
+ {
+ for (typename faces_t::const_iterator h = q_faces.begin();
h != q_faces.end(); ++h)
- if (work_faces_set.find(*h) == work_faces_set.end())
- {
- work_faces.push_back(*h);
- work_faces_set.insert(*h);
- }
+ // Don't insert a face twice.
+ if (work_faces_set.find(*h) == work_faces_set.end())
+ {
+ work_faces.push_back(*h);
+ work_faces_set.insert(*h);
+ }
+ }
+ else
+ {
+ for (typename faces_t::const_reverse_iterator h =
+ q_faces.rbegin(); h != q_faces.rend(); ++h)
+ // Don't insert a face twice.
+ if (work_faces_set.find(*h) == work_faces_set.end())
+ {
+ work_faces.push_back(*h);
+ work_faces_set.insert(*h);
+ }
+ }
}
work_faces.swap(p_faces);
work_faces.clear();
diff --git a/milena/mln/topo/center_only_iter.hh b/milena/mln/topo/center_only_iter.hh
index d55ffca..c2d2a6e 100644
--- a/milena/mln/topo/center_only_iter.hh
+++ b/milena/mln/topo/center_only_iter.hh
@@ -74,11 +74,13 @@ namespace mln
template <unsigned D>
class center_only_iter
: public internal::forward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
center_only_iter<D> >
{
private:
typedef center_only_iter<D> self_;
typedef internal::forward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
self_ > super_;
public:
@@ -122,7 +124,7 @@ namespace mln
{
mln_precondition(this->c_);
this->adj_faces_.clear();
- this->adj_faces_.push_back(*this->c_);
+ this->adj_faces_.push_back(make_algebraic_face(*this->c_, true));
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/topo/internal/complex_iterator_base.hh b/milena/mln/topo/internal/complex_iterator_base.hh
index 015ad7d..ceb86f3 100644
--- a/milena/mln/topo/internal/complex_iterator_base.hh
+++ b/milena/mln/topo/internal/complex_iterator_base.hh
@@ -50,7 +50,7 @@
|
,--------------+--------------.
| |
- complex_set_iterator_base<F, E> complex_relative_iterator_base<F, E>
+ complex_set_iterator_base<F, E> complex_relative_iterator_base<C, F, E>
\endverbatim
*/
diff --git a/milena/mln/topo/internal/complex_relative_iterator_base.hh b/milena/mln/topo/internal/complex_relative_iterator_base.hh
index 630f0f0..4925952 100644
--- a/milena/mln/topo/internal/complex_relative_iterator_base.hh
+++ b/milena/mln/topo/internal/complex_relative_iterator_base.hh
@@ -36,14 +36,14 @@
\verbatim
- complex_relative_iterator_base<F, E>
+ complex_relative_iterator_base<C, F, E>
^
|
,--------------+--------------.
| |
- forward_complex_relative_iterator_base<F, E> |
+ forward_complex_relative_iterator_base<C, F, E> |
|
- backward_complex_relative_iterator_base<F, E>
+ backward_complex_relative_iterator_base<C, F, E>
\endverbatim
*/
@@ -68,20 +68,24 @@ namespace mln
namespace internal
{
- /*-------------------------------------------------------.
- | topo::internal::complex_relative_iterator_base<F, E>. |
- `-------------------------------------------------------*/
+ /*----------------------------------------------------------.
+ | topo::internal::complex_relative_iterator_base<C, F, E>. |
+ `----------------------------------------------------------*/
/// \brief Factoring class for relative iterators on mln::complex.
///
+ /// \arg \p C The type of the center face handle.
/// \arg \p F The type of the face handle.
/// \arg \p E The type exact type of the iterator.
- template <typename F, typename E>
- class complex_relative_iterator_base : public complex_iterator_base<F, E>
+ template <typename C, typename F, typename E>
+ class complex_relative_iterator_base :
+ public complex_iterator_base<F, E>
{
- typedef complex_relative_iterator_base<F, E> self_;
+ typedef complex_relative_iterator_base<C, F, E> self_;
public:
+ /// The type of the center face.
+ typedef C center_type;
/// The type of the iterated faces.
typedef F face_type;
@@ -95,7 +99,7 @@ namespace mln
/// Manipulation.
/// \{
/// Change the center face.
- void center_at(const F& c);
+ void center_at(const center_type& c);
/// Start an iteration.
void start();
@@ -106,7 +110,7 @@ namespace mln
protected:
/// A pointer to the center face around which this iterator
/// moves.
- const face_type* c_;
+ const center_type* c_;
// The type of the set of vicinity sites (adjacent face handles).
typedef std::vector<face_type> adj_faces_t;
@@ -116,21 +120,22 @@ namespace mln
- /*---------------------------------------------------------------.
- | topo::internal::forward_complex_relative_iterator_base<F, E>. |
- `---------------------------------------------------------------*/
+ /*------------------------------------------------------------------.
+ | topo::internal::forward_complex_relative_iterator_base<C, F, E>. |
+ `------------------------------------------------------------------*/
/// \brief Factoring class for forward relative iterators on
/// mln::complex.
///
+ /// \arg \p C The type of the center face handle.
/// \arg \p F The type of the face handle.
/// \arg \p E The type exact type of the iterator.
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
class forward_complex_relative_iterator_base
- : public complex_relative_iterator_base<F, E>
+ : public complex_relative_iterator_base<C, F, E>
{
- typedef forward_complex_relative_iterator_base<F, E> self_;
- typedef complex_relative_iterator_base<F, E> super_;
+ typedef forward_complex_relative_iterator_base<C, F, E> self_;
+ typedef complex_relative_iterator_base<C, F, E> super_;
public:
typedef F face_type;
@@ -166,21 +171,22 @@ namespace mln
};
- /*----------------------------------------------------------------.
- | topo::internal::backward_complex_relative_iterator_base<F, E>. |
- `----------------------------------------------------------------*/
+ /*-------------------------------------------------------------------.
+ | topo::internal::backward_complex_relative_iterator_base<C, F, E>. |
+ `-------------------------------------------------------------------*/
/// \brief Factoring class for backward relative iterators on
/// mln::complex.
///
+ /// \arg \p C The type of the center face handle.
/// \arg \p F The type of the face handle.
/// \arg \p E The type exact type of the iterator.
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
class backward_complex_relative_iterator_base
- : public complex_relative_iterator_base<F, E>
+ : public complex_relative_iterator_base<C, F, E>
{
- typedef backward_complex_relative_iterator_base<F, E> self_;
- typedef complex_relative_iterator_base<F, E> super_;
+ typedef backward_complex_relative_iterator_base<C, F, E> self_;
+ typedef complex_relative_iterator_base<C, F, E> super_;
public:
typedef F face_type;
@@ -219,13 +225,13 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
- /*-------------------------------------------------------.
- | topo::internal::complex_relative_iterator_base<F, E>. |
- `-------------------------------------------------------*/
+ /*----------------------------------------------------------.
+ | topo::internal::complex_relative_iterator_base<C, F, E>. |
+ `----------------------------------------------------------*/
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
- complex_relative_iterator_base<F, E>::complex_relative_iterator_base()
+ complex_relative_iterator_base<C, F, E>::complex_relative_iterator_base()
: c_(0)
{
// Check for required methods in E.
@@ -235,10 +241,10 @@ namespace mln
exact(this)->invalidate();
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
template <typename Fref>
inline
- complex_relative_iterator_base<F, E>::complex_relative_iterator_base(const Fref& f_ref)
+ complex_relative_iterator_base<C, F, E>::complex_relative_iterator_base(const Fref& f_ref)
{
// Check for required methods in E.
void (E::*m)() = & E::update_adj_faces_;
@@ -247,29 +253,29 @@ namespace mln
center_at(f_ref);
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
void
- complex_relative_iterator_base<F, E>::center_at(const F& c)
+ complex_relative_iterator_base<C, F, E>::center_at(const C& c)
{
c_ = &c;
exact(this)->invalidate();
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
void
- complex_relative_iterator_base<F, E>::start()
+ complex_relative_iterator_base<C, F, E>::start()
{
exact(this)->do_start_();
if (exact(this)->is_valid())
exact(this)->update_f_();
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
void
- complex_relative_iterator_base<F, E>::next_()
+ complex_relative_iterator_base<C, F, E>::next_()
{
exact(this)->do_next_();
if (exact(this)->is_valid())
@@ -278,122 +284,122 @@ namespace mln
- /*---------------------------------------------------------------.
- | topo::internal::forward_complex_relative_iterator_base<F, E>. |
- `---------------------------------------------------------------*/
+ /*------------------------------------------------------------------.
+ | topo::internal::forward_complex_relative_iterator_base<C, F, E>. |
+ `------------------------------------------------------------------*/
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
- forward_complex_relative_iterator_base<F, E>::forward_complex_relative_iterator_base()
+ forward_complex_relative_iterator_base<C, F, E>::forward_complex_relative_iterator_base()
{
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
template <typename Fref>
inline
- forward_complex_relative_iterator_base<F, E>::forward_complex_relative_iterator_base(const Fref& f_ref)
+ forward_complex_relative_iterator_base<C, F, E>::forward_complex_relative_iterator_base(const Fref& f_ref)
: super_(f_ref)
{
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
bool
- forward_complex_relative_iterator_base<F, E>::is_valid() const
+ forward_complex_relative_iterator_base<C, F, E>::is_valid() const
{
return i_ != this->adj_faces_.end();
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
void
- forward_complex_relative_iterator_base<F, E>::invalidate()
+ forward_complex_relative_iterator_base<C, F, E>::invalidate()
{
i_ = this->adj_faces_.end();
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
void
- forward_complex_relative_iterator_base<F, E>::do_start_()
+ forward_complex_relative_iterator_base<C, F, E>::do_start_()
{
exact(this)->update_adj_faces_();
i_ = this->adj_faces_.begin();
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
void
- forward_complex_relative_iterator_base<F, E>::do_next_()
+ forward_complex_relative_iterator_base<C, F, E>::do_next_()
{
++i_;
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
void
- forward_complex_relative_iterator_base<F, E>::update_f_()
+ forward_complex_relative_iterator_base<C, F, E>::update_f_()
{
mln_precondition(is_valid());
this->f_ = *i_;
}
- /*----------------------------------------------------------------.
- | topo::internal::backward_complex_relative_iterator_base<F, E>. |
- `----------------------------------------------------------------*/
+ /*-------------------------------------------------------------------.
+ | topo::internal::backward_complex_relative_iterator_base<C, F, E>. |
+ `-------------------------------------------------------------------*/
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
- backward_complex_relative_iterator_base<F, E>::backward_complex_relative_iterator_base()
+ backward_complex_relative_iterator_base<C, F, E>::backward_complex_relative_iterator_base()
{
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
template <typename Fref>
inline
- backward_complex_relative_iterator_base<F, E>::backward_complex_relative_iterator_base(const Fref& f_ref)
+ backward_complex_relative_iterator_base<C, F, E>::backward_complex_relative_iterator_base(const Fref& f_ref)
: super_(f_ref)
{
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
bool
- backward_complex_relative_iterator_base<F, E>::is_valid() const
+ backward_complex_relative_iterator_base<C, F, E>::is_valid() const
{
return i_ != this->adj_faces_.rend();
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
void
- backward_complex_relative_iterator_base<F, E>::invalidate()
+ backward_complex_relative_iterator_base<C, F, E>::invalidate()
{
i_ = this->adj_faces_.rend();
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
void
- backward_complex_relative_iterator_base<F, E>::do_start_()
+ backward_complex_relative_iterator_base<C, F, E>::do_start_()
{
exact(this)->update_adj_faces_();
i_ = this->adj_faces_.rbegin();
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
void
- backward_complex_relative_iterator_base<F, E>::do_next_()
+ backward_complex_relative_iterator_base<C, F, E>::do_next_()
{
++i_;
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
void
- backward_complex_relative_iterator_base<F, E>::update_f_()
+ backward_complex_relative_iterator_base<C, F, E>::update_f_()
{
mln_precondition(is_valid());
this->f_ = *i_;
diff --git a/milena/mln/topo/internal/complex_relative_iterator_sequence.hh b/milena/mln/topo/internal/complex_relative_iterator_sequence.hh
index d0756f4..57b4843 100644
--- a/milena/mln/topo/internal/complex_relative_iterator_sequence.hh
+++ b/milena/mln/topo/internal/complex_relative_iterator_sequence.hh
@@ -63,6 +63,8 @@ namespace mln
typedef complex_relative_iterator_sequence<I1, I2, E> self_;
public:
+ /// The type of the center face.
+ typedef typename I1::center_type center_type;
/// The type of the iterated faces.
typedef typename I1::face_type face_type;
@@ -76,7 +78,7 @@ namespace mln
/// Manipulation.
/// \{
/// Change the center face.
- void center_at(const face& c);
+ void center_at(const center_type& c);
/// Test if the iterator is valid.
bool is_valid() const;
@@ -145,7 +147,7 @@ namespace mln
template <typename I1, typename I2, typename E>
inline
void
- complex_relative_iterator_sequence<I1, I2, E>::center_at(const face& c)
+ complex_relative_iterator_sequence<I1, I2, E>::center_at(const center_type& c)
{
iter1_.center_at(c);
iter2_.center_at(c);
--
1.5.6.5
1
0
* mln/topo/complex.hh
(connect_(const n_face<N, D>&, const n_face<N + 1, D>&)):
Turn method into...
(connect_(const algebraic_n_face<N, D>&, const n_face<N + 1, D>&)):
...this.
(complex<D>::add_face): Adjust.
(internal::lower_dim_faces_set_mixin<N, D>::print)
(higher_dim_faces_set_mixin<N, D>::print):
Adjust.
* mln/topo/face_data.hh: Adjust friends.
(internal::lower_dim_faces_data_mixin<N, D>::lower_dim_faces_type)
(internal::higher_dim_faces_data_mixin<N, D>::higher_dim_faces_type):
New typedefs.
Use them as types of...
(internal::lower_dim_faces_data_mixin<N, D>::lower_dim_faces_)
(internal::higher_dim_faces_data_mixin<N, D>::higher_dim_faces_):
...these members.
(internal::lower_dim_faces_data_mixin<N, D>::connect_lower_dim_face)
(internal::higher_dim_faces_data_mixin<N, D>::connect_higher_dim_face):
Convert to algebraic n-faces.
---
milena/ChangeLog | 25 +++++++++++++++++++++++++
milena/mln/topo/complex.hh | 31 +++++++++++++++++++++----------
milena/mln/topo/face_data.hh | 24 +++++++++++++++---------
3 files changed, 61 insertions(+), 19 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 5395ca0..e7adf55 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,30 @@
2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+ Convert mln::topo::complex to algebraic faces.
+
+ * mln/topo/complex.hh
+ (connect_(const n_face<N, D>&, const n_face<N + 1, D>&)):
+ Turn method into...
+ (connect_(const algebraic_n_face<N, D>&, const n_face<N + 1, D>&)):
+ ...this.
+ (complex<D>::add_face): Adjust.
+ (internal::lower_dim_faces_set_mixin<N, D>::print)
+ (higher_dim_faces_set_mixin<N, D>::print):
+ Adjust.
+ * mln/topo/face_data.hh: Adjust friends.
+ (internal::lower_dim_faces_data_mixin<N, D>::lower_dim_faces_type)
+ (internal::higher_dim_faces_data_mixin<N, D>::higher_dim_faces_type):
+ New typedefs.
+ Use them as types of...
+ (internal::lower_dim_faces_data_mixin<N, D>::lower_dim_faces_)
+ (internal::higher_dim_faces_data_mixin<N, D>::higher_dim_faces_):
+ ...these members.
+ (internal::lower_dim_faces_data_mixin<N, D>::connect_lower_dim_face)
+ (internal::higher_dim_faces_data_mixin<N, D>::connect_higher_dim_face):
+ Convert to algebraic n-faces.
+
+2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+
Convert n-faces set to algebraic faces.
* milena/mln/topo/n_faces_set.hh
diff --git a/milena/mln/topo/complex.hh b/milena/mln/topo/complex.hh
index e6330e2..00a2bb2 100644
--- a/milena/mln/topo/complex.hh
+++ b/milena/mln/topo/complex.hh
@@ -44,8 +44,8 @@
# 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/algebraic_face.hh>
+# include <mln/topo/algebraic_n_face.hh>
# include <mln/topo/n_faces_set.hh>
# include <mln/topo/complex_iterators.hh>
@@ -204,14 +204,15 @@ namespace mln
apply_if_dim_matches_(unsigned n, const UnaryFunction& f) const;
/// \}
- /// \brief connect two faces.
+ /// \brief Connect two algebraic faces.
///
- /// \param f1 A face of dimension \p N
+ /// \param f1 An algebraic face of dimension \p N
/// \param f2 A face of dimension \p N + 1
///
/// \pre \p N must be lower or equal to \p D.
template <unsigned N>
- void connect_(const n_face<N, D>& f1, const n_face<N + 1, D>& f2);
+ void connect_(const algebraic_n_face<N, D>& f1,
+ const n_face<N + 1, D>& f2);
};
@@ -494,7 +495,8 @@ namespace mln
n_face<N + 1, D>
complex<D>::add_face(const n_faces_set<N, D>& adjacent_faces)
{
- typedef typename std::vector< n_face<N, D> >::const_iterator iter_t;
+ typedef typename std::vector< algebraic_n_face<N, D> >::const_iterator
+ iter_t;
// Ensure ADJACENT_FACES are already part of the complex.
if (!HAS_NDEBUG)
@@ -515,6 +517,10 @@ namespace mln
// Connect F and its ADJACENT_FACES.
for (iter_t a = adjacent_faces.faces().begin();
a != adjacent_faces.faces().end(); ++a)
+ /* Connect
+ - algebraic n-face *A,
+ - and an (n+1)-algebraic face based on FH and having the
+ sign of *A. */
connect_(*a, fh);
return fh;
}
@@ -629,12 +635,17 @@ namespace mln
template <unsigned N>
inline
void
- complex<D>::connect_(const n_face<N, D>& f1, const n_face<N + 1, D>& f2)
+ complex<D>::connect_(const algebraic_n_face<N, D>& f1,
+ const n_face<N + 1, D>& f2)
{
// Ensure N is compatible with D.
metal::bool_< N <= D >::check();
- f1.data().connect_higher_dim_face(f2);
+ /* Connect
+ - F1, an algebraic n-face,
+ - and AF2, an algebraic (n+1)-face based on F2 and having the
+ sign of F1. */
+ f1.data().connect_higher_dim_face(make_algebraic_n_face(f2, f1.sign()));
f2.data().connect_lower_dim_face(f1);
}
@@ -801,7 +812,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< n_face<N - 1, D> >::const_iterator l =
+ for (typename std::vector< algebraic_n_face<N - 1, D> >::const_iterator l =
f.lower_dim_faces_.begin(); l != f.lower_dim_faces_.end(); ++l)
ostr << l->face_id() << " ";
}
@@ -812,7 +823,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< n_face<N + 1, D> >::const_iterator h =
+ for (typename std::vector< algebraic_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_data.hh b/milena/mln/topo/face_data.hh
index 27e78cd..1cee9e1 100644
--- a/milena/mln/topo/face_data.hh
+++ b/milena/mln/topo/face_data.hh
@@ -36,7 +36,7 @@
# include <vector>
-# include <mln/topo/n_face.hh>
+# include <mln/topo/algebraic_n_face.hh>
namespace mln
@@ -110,31 +110,37 @@ namespace mln
template <unsigned N, unsigned D>
class lower_dim_faces_data_mixin
{
+ typedef std::vector< algebraic_n_face<N - 1, D> > lower_dim_faces_type;
+
public:
- void connect_lower_dim_face (const n_face<N - 1, D>& f);
+ void connect_lower_dim_face(const algebraic_n_face<N - 1, D>& f);
+
private:
friend class mln::topo::internal::lower_dim_faces_set_mixin<N, D>;
friend class mln::topo::internal::lower_dim_adj_faces_if_dim_matches_<N, D>;
- friend std::vector< n_face<N - 1, D> >
+ friend lower_dim_faces_type
mln::topo::n_face<N, D>::lower_dim_adj_faces() const;
// FIXME: Rename as lower_dim_adj_faces_ (as well as related members).
- std::vector< n_face<N - 1, D> > lower_dim_faces_;
+ lower_dim_faces_type lower_dim_faces_;
};
template <unsigned N, unsigned D>
class higher_dim_faces_data_mixin
{
+ typedef std::vector< algebraic_n_face<N + 1, D> > higher_dim_faces_type;
+
public:
- void connect_higher_dim_face(const n_face<N + 1, D>& f);
+ void connect_higher_dim_face(const algebraic_n_face<N + 1, D>& f);
+
private:
friend class mln::topo::internal::higher_dim_faces_set_mixin<N, D>;
friend class mln::topo::internal::higher_dim_adj_faces_if_dim_matches_<N, D>;
- friend std::vector< n_face<N + 1, D> >
+ friend higher_dim_faces_type
mln::topo::n_face<N, D>::higher_dim_adj_faces() const;
// FIXME: Rename as higher_dim_adj_faces_ (as well as related members).
- std::vector< n_face<N + 1, D> > higher_dim_faces_;
+ higher_dim_faces_type higher_dim_faces_;
};
/// \}
@@ -149,7 +155,7 @@ namespace mln
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_data_mixin<N, D>::connect_lower_dim_face(const algebraic_n_face<N - 1, D>& f)
{
lower_dim_faces_.push_back(f);
}
@@ -157,7 +163,7 @@ namespace mln
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_data_mixin<N, D>::connect_higher_dim_face(const algebraic_n_face<N + 1, D>& f)
{
higher_dim_faces_.push_back(f);
}
--
1.5.6.5
1
0
* 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
1
0
* mln/topo/face.hh
(mln::topo::face<D>::lower_dim_adj_faces)
(mln::topo::face<D>::higher_dim_adj_faces):
Return algebraic faces.
(mln::topo::internal::lower_dim_adj_faces_if_dim_matches_<N, D>)
(mln::topo::internal::higher_dim_adj_faces_if_dim_matches_<N, D>):
Split the interface from the implementation, and move the
latter...
* mln/topo/algebraic_face.hh: ...here.
Update w.r.t. algebraic faces.
---
milena/ChangeLog | 15 +++++
milena/mln/topo/algebraic_face.hh | 94 +++++++++++++++++++++++++++++++++
milena/mln/topo/face.hh | 103 ++++++++++---------------------------
3 files changed, 137 insertions(+), 75 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 334b083..6076a89 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,20 @@
2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+ Adjust (non algebraic) faces.
+
+ * mln/topo/face.hh
+ (mln::topo::face<D>::lower_dim_adj_faces)
+ (mln::topo::face<D>::higher_dim_adj_faces):
+ Return algebraic faces.
+ (mln::topo::internal::lower_dim_adj_faces_if_dim_matches_<N, D>)
+ (mln::topo::internal::higher_dim_adj_faces_if_dim_matches_<N, D>):
+ Split the interface from the implementation, and move the
+ latter...
+ * mln/topo/algebraic_face.hh: ...here.
+ Update w.r.t. algebraic faces.
+
+2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+
Adjust (non algebraic) n-faces.
* mln/topo/n_face.hh
diff --git a/milena/mln/topo/algebraic_face.hh b/milena/mln/topo/algebraic_face.hh
index 79f9116..1c666ac 100644
--- a/milena/mln/topo/algebraic_face.hh
+++ b/milena/mln/topo/algebraic_face.hh
@@ -276,6 +276,100 @@ namespace mln
<< ", id = " << f.face_id() << ", sign = " << f.sign()<< ')';
}
+
+ /*-----------------------------------------------.
+ | Helpers for face<D>::lower_dim_adj_faces() and |
+ | face<D>::higher_dim_adj_faces(). |
+ `-----------------------------------------------*/
+
+ /* FIXME: This is way too complicated; should disappear when the
+ implementation of complexes is simplified (see
+ https://trac.lrde.org/olena/ticket/168) */
+
+ namespace internal
+ {
+
+ template <unsigned N, unsigned D>
+ std::vector< algebraic_face<D> >
+ lower_dim_adj_faces_if_dim_matches_<N, D>::operator()(const face<D>& face)
+ {
+ metal::bool_< (N <= D) >::check();
+ metal::bool_< (N > 1) >::check();
+
+ if (face.n() == N)
+ {
+ face_data<N, D>& data = face.template data<N>();
+ std::vector< algebraic_n_face<N - 1, D> > lower_dim_faces =
+ data.lower_dim_faces_;
+ std::vector< topo::algebraic_face<D> > result;
+ for (typename std::vector< algebraic_n_face<N - 1, D> >::const_iterator f =
+ lower_dim_faces.begin(); f != lower_dim_faces.end(); ++f)
+ result.push_back(*f);
+ return result;
+ }
+ else
+ return internal::lower_dim_adj_faces_if_dim_matches_<N - 1, D>()(face);
+ }
+
+ template <unsigned D>
+ std::vector< algebraic_face<D> >
+ lower_dim_adj_faces_if_dim_matches_<1, D>::operator()(const face<D>& face)
+ {
+ /// If we reached this function, then the dimension of FACE
+ /// has to be 1.
+ mln_precondition(face.n() == 1);
+ face_data<1, D>& data = face.template data<1>();
+ std::vector< algebraic_n_face<0, D> > lower_dim_faces =
+ data.lower_dim_faces_;
+ std::vector< topo::algebraic_face<D> > result;
+ for (typename std::vector< algebraic_n_face<0, D> >::const_iterator f =
+ lower_dim_faces.begin(); f != lower_dim_faces.end(); ++f)
+ result.push_back(*f);
+ return result;
+ }
+
+ template <unsigned N, unsigned D>
+ std::vector< algebraic_face<D> >
+ higher_dim_adj_faces_if_dim_matches_<N, D>::operator()(const face<D>& face)
+ {
+ metal::bool_< (N < D) >::check();
+
+ if (face.n() == N)
+ {
+ face_data<N, D>& data = face.template data<N>();
+ std::vector< algebraic_n_face<N + 1, D> > higher_dim_faces =
+ data.higher_dim_faces_;
+ std::vector< topo::algebraic_face<D> > result;
+ for (typename std::vector< algebraic_n_face<N + 1, D> >::const_iterator f =
+ higher_dim_faces.begin(); f != higher_dim_faces.end(); ++f)
+ result.push_back(*f);
+ return result;
+ }
+ else
+ return
+ internal::higher_dim_adj_faces_if_dim_matches_<N - 1, D>()(face);
+ }
+
+ template <unsigned D>
+ std::vector< algebraic_face<D> >
+ higher_dim_adj_faces_if_dim_matches_<0, D>::operator()(const face<D>& face)
+ {
+ /// If we reached this function, then the dimension of face
+ /// has to be D - 1.
+ mln_precondition(face.n() == 0);
+ face_data<0, D>& data = face.template data<0>();
+ std::vector< algebraic_n_face<1, D> > higher_dim_faces =
+ data.higher_dim_faces_;
+ std::vector< topo::algebraic_face<D> > result;
+ for (typename std::vector< algebraic_n_face<1, D> >::const_iterator f =
+ higher_dim_faces.begin(); f != higher_dim_faces.end(); ++f)
+ result.push_back(*f);
+ return result;
+ }
+
+ } // end of namespace mln::topo::internal
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::topo
diff --git a/milena/mln/topo/face.hh b/milena/mln/topo/face.hh
index 371cf21..4ace2ab 100644
--- a/milena/mln/topo/face.hh
+++ b/milena/mln/topo/face.hh
@@ -47,7 +47,8 @@ namespace mln
template <unsigned D> class complex;
template <unsigned N, unsigned D> class n_face;
template <unsigned N, unsigned D> class face_data;
-
+ template <unsigned N> class algebraic_face;
+
/*-------.
| Face. |
@@ -60,6 +61,7 @@ namespace mln
template <unsigned D>
struct face
{
+ public:
// The type of the complex this handle points to.
typedef complex<D> complex_type;
@@ -111,9 +113,9 @@ namespace mln
// FIXME: To be overhauled.
/// Return an array of face handles pointing to adjacent (n-1)-faces.
- std::vector< face<D> > lower_dim_adj_faces() const;
+ std::vector< algebraic_face<D> > lower_dim_adj_faces() const;
/// Return an array of face handles pointing to adjacent (n+1)-faces.
- std::vector< face<D> > higher_dim_adj_faces() const;
+ std::vector< algebraic_face<D> > higher_dim_adj_faces() const;
/// \}
private:
@@ -195,7 +197,6 @@ namespace mln
{
// Ensure N is compatible with D.
metal::bool_< N <= D >::check();
-
}
template <unsigned D>
@@ -307,98 +308,50 @@ namespace mln
}
- // FIXME: This is way too complicated.
+ /*-----------------------------------------------.
+ | Helpers for face<D>::lower_dim_adj_faces() and |
+ | face<D>::higher_dim_adj_faces(). |
+ `-----------------------------------------------*/
+
+ /* FIXME: This is way too complicated; should disappear when the
+ implementation of complexes is simplified (see
+ https://trac.lrde.org/olena/ticket/168) */
+
+ // Implementation is in mln/topo/algebraic_face.hh.
+
namespace internal
{
+
template <unsigned N, unsigned D>
struct lower_dim_adj_faces_if_dim_matches_
{
- std::vector< face<D> > operator()(const face<D>& face)
- {
- metal::bool_< (N <= D) >::check();
- metal::bool_< (N > 1) >::check();
-
- if (face.n() == N)
- {
- face_data<N, D>& data = face.template data<N>();
- std::vector< n_face<N - 1, D> > lower_dim_faces =
- data.lower_dim_faces_;
- std::vector< topo::face<D> > result;
- for (typename std::vector< n_face<N - 1, D> >::const_iterator f =
- lower_dim_faces.begin(); f != lower_dim_faces.end(); ++f)
- result.push_back(*f);
- return result;
- }
- else
- return internal::lower_dim_adj_faces_if_dim_matches_<N - 1, D>()(face);
- }
+ std::vector< algebraic_face<D> > operator()(const face<D>& face);
};
template <unsigned D>
struct lower_dim_adj_faces_if_dim_matches_<1, D>
{
- std::vector< face<D> > operator()(const face<D>& face)
- {
- /// If we reached this function, then the dimension of FACE
- /// has to be 1.
- mln_precondition(face.n() == 1);
- face_data<1, D>& data = face.template data<1>();
- std::vector< n_face<0, D> > lower_dim_faces = data.lower_dim_faces_;
- std::vector< topo::face<D> > result;
- for (typename std::vector< n_face<0, D> >::const_iterator f =
- lower_dim_faces.begin(); f != lower_dim_faces.end(); ++f)
- result.push_back(*f);
- return result;
- }
+ std::vector< algebraic_face<D> > operator()(const face<D>& face);
};
template <unsigned N, unsigned D>
struct higher_dim_adj_faces_if_dim_matches_
{
- std::vector< face<D> > operator()(const face<D>& face)
- {
- metal::bool_< (N < D) >::check();
-
- if (face.n() == N)
- {
- face_data<N, D>& data = face.template data<N>();
- std::vector< n_face<N + 1, D> > higher_dim_faces =
- data.higher_dim_faces_;
- std::vector< topo::face<D> > result;
- for (typename std::vector< n_face<N + 1, D> >::const_iterator f =
- higher_dim_faces.begin(); f != higher_dim_faces.end(); ++f)
- result.push_back(*f);
- return result;
- }
- else
- return
- internal::higher_dim_adj_faces_if_dim_matches_<N - 1, D>()(face);
- }
+ std::vector< algebraic_face<D> > operator()(const face<D>& face);
};
template <unsigned D>
struct higher_dim_adj_faces_if_dim_matches_<0, D>
{
- std::vector< face<D> > operator()(const face<D>& face)
- {
- /// If we reached this function, then the dimension of face
- /// has to be D - 1.
- mln_precondition(face.n() == 0);
- face_data<0, D>& data = face.template data<0>();
- std::vector< n_face<1, D> > higher_dim_faces =
- data.higher_dim_faces_;
- std::vector< topo::face<D> > result;
- for (typename std::vector< n_face<1, D> >::const_iterator f =
- higher_dim_faces.begin(); f != higher_dim_faces.end(); ++f)
- result.push_back(*f);
- return result;
- }
+ std::vector< algebraic_face<D> > operator()(const face<D>& face);
};
- }
+
+ } // end of namespace mln::topo::internal
+
template <unsigned D>
inline
- std::vector< face<D> >
+ std::vector< algebraic_face<D> >
face<D>::lower_dim_adj_faces() const
{
// FIXME: Warning: might prevent any attempt to build a complex<0>.
@@ -406,12 +359,12 @@ namespace mln
return n_ > 0 ?
internal::lower_dim_adj_faces_if_dim_matches_<D, D>()(*this) :
- std::vector< face<D> >();
+ std::vector< algebraic_face<D> >();
}
template <unsigned D>
inline
- std::vector< face<D> >
+ std::vector< algebraic_face<D> >
face<D>::higher_dim_adj_faces() const
{
// FIXME: Warning: might prevent any attempt to build a complex<0>.
@@ -419,7 +372,7 @@ namespace mln
return n_ < D ?
internal::higher_dim_adj_faces_if_dim_matches_<D - 1, D>()(*this) :
- std::vector< face<D> >();
+ std::vector< algebraic_face<D> >();
}
--
1.5.6.5
1
0
* 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
1
0
23 Oct '08
* mln/topo/algebraic_face.hh: New.
---
milena/ChangeLog | 6 +
milena/mln/topo/algebraic_face.hh | 285 +++++++++++++++++++++++++++++++++++++
2 files changed, 291 insertions(+), 0 deletions(-)
create mode 100644 milena/mln/topo/algebraic_face.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 57d15fd..8f68af8 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,11 @@
2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+ Add an algebraic (oriented) face handle (descriptor).
+
+ * mln/topo/algebraic_face.hh: New.
+
+2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+
Add an algebraic (oriented) n-face handle (descriptor).
* mln/topo/algebraic_n_face.hh: New.
diff --git a/milena/mln/topo/algebraic_face.hh b/milena/mln/topo/algebraic_face.hh
new file mode 100644
index 0000000..79f9116
--- /dev/null
+++ b/milena/mln/topo/algebraic_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_ALGEBRAIC_FACE_HH
+# define MLN_TOPO_ALGEBRAIC_FACE_HH
+
+/// \file mln/topo/algebraic_face.hh
+/// \brief Algebraic face of a complex.
+
+#include <mln/topo/face.hh>
+
+
+namespace mln
+{
+
+ namespace topo
+ {
+
+ // Forward declarations.
+ template <unsigned D> class complex;
+ template <unsigned N, unsigned D> class n_face;
+ template <unsigned N, unsigned D> class face_data;
+
+
+ /*-------.
+ | Face. |
+ `-------*/
+
+ /// \brief Algebraic face handle in a complex; the face dimension
+ /// is dynamic.
+ ///
+ /// Contrary to an mln::topo::algebraic_n_face, the dimension of an
+ /// mln::topo::algebraic_face is not fixed.
+ template <unsigned D>
+ struct algebraic_face : public face<D>
+ {
+ typedef face<D> super_;
+
+ public:
+ // The type of the complex this handle points to.
+ typedef complex<D> complex_type;
+
+ /// Build a non-initialized algebraic face handle.
+ algebraic_face();
+ /// Build an algebraic face handle from \a complex and \a face_id.
+ algebraic_face(complex<D>& complex, unsigned n, unsigned face_id,
+ bool sign);
+ /// Build an algebraic face handle from an mln::face.
+ algebraic_face(const face<D>& f, bool sign);
+
+ /// Build a face handle from an mln::topo::algebraic_n_face.
+ template <unsigned N>
+ algebraic_face(const algebraic_n_face<N, D>& f);
+
+ /// Accessors.
+ /// \{
+ /// Return the sign of this face.
+ bool sign() const;
+ /// Set the sign of this face.
+ void set_sign(bool sign);
+ /// \}
+
+ private:
+ /// The sign of this algebraic face.
+ bool sign_;
+ };
+
+
+ /// Create an algebraic face handle of a \p D-complex.
+ template <unsigned D>
+ algebraic_face<D>
+ make_algebraic_face(const face<D>& f, bool sign);
+
+
+ /// Inversion operators.
+ /// \{
+ template <unsigned D>
+ algebraic_face<D>
+ operator-(const face<D>& f);
+
+ template <unsigned D>
+ algebraic_face<D>
+ operator-(const algebraic_face<D>& f);
+ /// \}
+
+
+ /// Comparison of two instances of mln::topo::algebraic_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 D>
+ bool operator==(const algebraic_face<D>& lhs,
+ const algebraic_face<D>& rhs);
+
+ /// \brief Is \a lhs different from \a rhs?
+ ///
+ /// \pre Arguments \a lhs and \a rhs must belong to the same
+ /// mln::topo::complex.
+ template <unsigned D>
+ bool operator!=(const algebraic_face<D>& lhs,
+ const algebraic_face<D>& rhs);
+
+ /// \brief Is \a lhs ``less'' than \a rhs?
+ ///
+ /// This comparison is required by algorithms sorting algebraic
+ /// face handles.
+ ///
+ /// \pre Arguments \a lhs and \a rhs must belong to the same
+ /// mln::topo::complex.
+ /// \pre Arguments \a lhs and \a rhs must have the same dimension.
+ template <unsigned D>
+ bool operator< (const algebraic_face<D>& lhs,
+ const algebraic_face<D>& rhs);
+
+ /// \}
+
+
+ /// Print an mln::topo::algebraic_face.
+ template <unsigned D>
+ std::ostream&
+ operator<<(std::ostream& ostr, const algebraic_face<D>& f);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <unsigned D>
+ inline
+ algebraic_face<D>::algebraic_face()
+ : super_(), sign_(true)
+ {
+ }
+
+ template <unsigned D>
+ inline
+ algebraic_face<D>::algebraic_face(complex<D>& c, unsigned n,
+ unsigned face_id, bool sign)
+ : super_(c, n, face_id), sign_(sign)
+ {
+ // Ensure N is compatible with D.
+ mln_precondition(n <= D);
+ }
+
+ template <unsigned D>
+ inline
+ algebraic_face<D>::algebraic_face(const face<D>& f, bool sign)
+ : super_(f), sign_(sign)
+ {
+ // Ensure N is compatible with D.
+ mln_precondition(f.n() <= D);
+ }
+
+ template <unsigned D>
+ template <unsigned N>
+ inline
+ algebraic_face<D>::algebraic_face(const algebraic_n_face<N, D>& f)
+ : super_(f), sign_(f.sign())
+ {
+ // Ensure N is compatible with D.
+ metal::bool_< N <= D >::check();
+ }
+
+
+ template <unsigned D>
+ inline
+ bool
+ algebraic_face<D>::sign() const
+ {
+ return sign_;
+ }
+
+ template <unsigned D>
+ inline
+ void
+ algebraic_face<D>::set_sign(bool sign)
+ {
+ sign_ = sign;
+ }
+
+
+ template <unsigned D>
+ algebraic_face<D>
+ make_algebraic_face(const face<D>& f, bool sign)
+ {
+ return algebraic_face<D>(f, sign);
+ }
+
+
+ template <unsigned D>
+ algebraic_face<D>
+ operator-(const face<D>& f)
+ {
+ return algebraic_face<D>(f, false);
+ }
+
+ template <unsigned D>
+ algebraic_face<D>
+ operator-(const algebraic_face<D>& f)
+ {
+ algebraic_face<D> f2(f);
+ f2.set_sign(!f.sign());
+ return f2;
+ }
+
+
+ template <unsigned D>
+ inline
+ bool
+ operator==(const algebraic_face<D>& lhs, const algebraic_face<D>& rhs)
+ {
+ // Ensure LHS and RHS belong to the same complex.
+ mln_precondition(lhs.cplx() == rhs.cplx());
+ return
+ lhs.n() == rhs.n() &&
+ lhs.face_id() == rhs.face_id() &&
+ lhs.sign() == rhs.sign();
+ }
+
+ template <unsigned D>
+ inline
+ bool
+ operator!=(const algebraic_face<D>& lhs, const algebraic_face<D>& rhs)
+ {
+ // Ensure LHS and RHS belong to the same complex.
+ mln_precondition(lhs.cplx() == rhs.cplx());
+ return !(lhs == rhs);
+ }
+
+ template <unsigned D>
+ inline
+ bool
+ operator< (const algebraic_face<D>& lhs, const algebraic_face<D>& rhs)
+ {
+ // Ensure LHS and RHS belong to the same complex.
+ mln_precondition(lhs.cplx() == rhs.cplx());
+ // Ensure LHS and RHS have the same dimension.
+ mln_precondition(lhs.n() == rhs.n());
+ return lhs.face_id() < rhs.face_id();
+ }
+
+
+ template <unsigned D>
+ inline
+ std::ostream&
+ operator<<(std::ostream& ostr, const algebraic_face<D>& f)
+ {
+ return
+ ostr << "(cplx = " << f.cplx().addr() << ", dim = " << f.n()
+ << ", id = " << f.face_id() << ", sign = " << f.sign()<< ')';
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::topo
+
+} // end of namespace mln
+
+#endif // ! MLN_TOPO_FACE_HH
--
1.5.6.5
1
0
23 Oct '08
* mln/topo/algebraic_n_face.hh: New.
---
milena/ChangeLog | 6 +
milena/mln/topo/algebraic_n_face.hh | 262 +++++++++++++++++++++++++++++++++++
2 files changed, 268 insertions(+), 0 deletions(-)
create mode 100644 milena/mln/topo/algebraic_n_face.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 6bf9126..57d15fd 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,11 @@
2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+ Add an algebraic (oriented) n-face handle (descriptor).
+
+ * mln/topo/algebraic_n_face.hh: New.
+
+2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+
Fix a bug in OFF file saving.
* mln/io/off/save.hh
diff --git a/milena/mln/topo/algebraic_n_face.hh b/milena/mln/topo/algebraic_n_face.hh
new file mode 100644
index 0000000..fbfccf4
--- /dev/null
+++ b/milena/mln/topo/algebraic_n_face.hh
@@ -0,0 +1,262 @@
+// 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_ALGEBRAIC_N_FACE_HH
+# define MLN_TOPO_ALGEBRAIC_N_FACE_HH
+
+/// \file mln/topo/algebraic_n_face.hh
+/// \brief Algebraic n-face of a complex.
+
+#include <mln/topo/n_face.hh>
+
+
+namespace mln
+{
+
+ namespace topo
+ {
+
+ /*-------------------.
+ | Algebraic n-Face. |
+ `-------------------*/
+
+ /// \brief Algebraic \p N-face handle in a complex.
+ ///
+ /// Contrary to an mln::topo::algebraic_face, the dimension of an
+ /// mln::topo::algebraic_n_face is fixed.
+ template <unsigned N, unsigned D>
+ class algebraic_n_face : public n_face<N, D>
+ {
+ typedef n_face<N, D> super_;
+
+ public:
+ /// Build a non-initialized algebraic face handle.
+ algebraic_n_face();
+ /// Build an algebraic face handle from \a complex and \a face_id.
+ algebraic_n_face(complex<D>& complex, unsigned face_id, bool sign);
+ /// Build an algebraic face handle from an mln::n_face.
+ algebraic_n_face(const n_face<N, D>& f, bool sign);
+
+ /// Accessors.
+ /// \{
+ /// Return the sign of this face.
+ bool sign() const;
+ /// Set the sign of this face.
+ void set_sign(bool sign);
+ /// \}
+
+ private:
+ bool sign_;
+ };
+
+
+ /// Create an algebraic \p N-face handle of a \p D-complex.
+ template <unsigned N, unsigned D>
+ algebraic_n_face<N, D>
+ make_algebraic_n_face(const n_face<N, D>& f, bool sign);
+
+
+ /// Inversion operators.
+ /// \{
+ template <unsigned N, unsigned D>
+ algebraic_n_face<N, D>
+ operator-(const n_face<N, D>& f);
+
+ template <unsigned N, unsigned D>
+ algebraic_n_face<N, D>
+ operator-(const algebraic_n_face<N, D>& f);
+ /// \}
+
+
+ /// Comparison of two instances of mln::topo::algebraic_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 algebraic_n_face<N, D>& lhs,
+ const algebraic_n_face<N, D>& rhs);
+
+ /// \brief Is \a lhs different from \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 algebraic_n_face<N, D>& lhs,
+ const algebraic_n_face<N, D>& rhs);
+
+ /// \brief Is \a lhs ``less'' than \a rhs?
+ ///
+ /// This comparison is required by algorithms sorting algebraic
+ /// 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 algebraic_n_face<N, D>& lhs,
+ const algebraic_n_face<N, D>& rhs);
+
+ /// \}
+
+
+ /// Print an mln::topo::algebraic_n_face.
+ template <unsigned N, unsigned D>
+ std::ostream&
+ operator<<(std::ostream& ostr, const algebraic_n_face<N, D>& f);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <unsigned N, unsigned D>
+ inline
+ algebraic_n_face<N, D>::algebraic_n_face()
+ : super_(), sign_(true)
+ {
+ // Ensure N is compatible with D.
+ metal::bool_< N <= D >::check();
+ mln_postcondition(!this->is_valid());
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ algebraic_n_face<N, D>::algebraic_n_face(complex<D>& c, unsigned face_id,
+ bool sign)
+ : super_(c, face_id), sign_(sign)
+ {
+ // Ensure N is compatible with D.
+ metal::bool_< N <= D >::check();
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ algebraic_n_face<N, D>::algebraic_n_face(const n_face<N, D>& f, bool sign)
+ : super_(f), sign_(sign)
+ {
+ // Ensure N is compatible with D.
+ metal::bool_< N <= D >::check();
+ }
+
+
+ template <unsigned N, unsigned D>
+ inline
+ bool
+ algebraic_n_face<N, D>::sign() const
+ {
+ return sign_;
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ void
+ algebraic_n_face<N, D>::set_sign(bool sign)
+ {
+ sign_ = sign;
+ }
+
+
+ template <unsigned N, unsigned D>
+ algebraic_n_face<N, D>
+ make_algebraic_n_face(const n_face<N, D>& f, bool sign)
+ {
+ return algebraic_n_face<N, D>(f, sign);
+ }
+
+
+ template <unsigned N, unsigned D>
+ algebraic_n_face<N, D>
+ operator-(const n_face<N, D>& f)
+ {
+ return algebraic_n_face<N, D>(f, false);
+ }
+
+ template <unsigned N, unsigned D>
+ algebraic_n_face<N, D>
+ operator-(const algebraic_n_face<N, D>& f)
+ {
+ algebraic_n_face<N, D> f2(f);
+ f2.set_sign(!f.sign());
+ return f2;
+ }
+
+
+ template <unsigned N, unsigned D>
+ inline
+ bool
+ operator==(const algebraic_n_face<N, D>& lhs,
+ const algebraic_n_face<N, D>& rhs)
+ {
+ // Ensure LHS and RHS belong to the same complex.
+ mln_precondition(lhs.cplx() == rhs.cplx());
+ return lhs.face_id() == rhs.face_id() && lhs.sign() == rhs.sign();
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ bool
+ operator!=(const algebraic_n_face<N, D>& lhs,
+ const algebraic_n_face<N, D>& rhs)
+ {
+ // Ensure LHS and RHS belong to the same complex.
+ mln_precondition(lhs.cplx() == rhs.cplx());
+ return !(lhs == rhs);
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ bool
+ operator< (const algebraic_n_face<N, D>& lhs,
+ const algebraic_n_face<N, D>& rhs)
+ {
+ // Ensure LHS and RHS belong to the same complex.
+ mln_precondition(lhs.cplx() == rhs.cplx());
+ return lhs.face_id() < rhs.face_id();
+ }
+
+
+ template <unsigned N, unsigned D>
+ inline
+ std::ostream&
+ operator<<(std::ostream& ostr, const algebraic_n_face<N, D>& f)
+ {
+ return
+ ostr << "(cplx = " << f.cplx().addr() << ", dim = " << f.n()
+ << ", id = " << f.face_id() << ", sign = " << f.sign()<< ')';
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::topo
+
+} // end of namespace mln
+
+#endif // ! MLN_TOPO_ALGEBRAIC_N_FACE_HH
--
1.5.6.5
1
0
* mln/io/off/save.hh
(save(const bin_2complex_image3df&, const std::string&)):
Swap the positions of the number of edges and number of faces in
the written file.
---
milena/ChangeLog | 9 +++++++++
milena/mln/io/off/save.hh | 4 ++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index f6299c9..6bf9126 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,14 @@
2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+ Fix a bug in OFF file saving.
+
+ * mln/io/off/save.hh
+ (save(const bin_2complex_image3df&, const std::string&)):
+ Swap the positions of the number of edges and number of faces in
+ the written file.
+
+2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+
Remove seldom used macros mln_face and mln_face_.
* mln/core/macros.hh (mln_face, mln_face_): Remove macros.
diff --git a/milena/mln/io/off/save.hh b/milena/mln/io/off/save.hh
index eba2aeb..dce42fd 100644
--- a/milena/mln/io/off/save.hh
+++ b/milena/mln/io/off/save.hh
@@ -113,8 +113,8 @@ namespace mln
ima.nfaces<0>().
*/
ostr << ima.domain().cplx().nfaces<0>() << ' '
- << ima.domain().cplx().nfaces<1>() << ' '
- << ima.domain().cplx().nfaces<2>() << std::endl;
+ << ima.domain().cplx().nfaces<2>() << ' '
+ << ima.domain().cplx().nfaces<1>() << std::endl;
/*-------.
| Data. |
--
1.5.6.5
1
0