* mln/topo/face_iter.hh
(mln::topo::face_fwd_iter<D>::next_)
(mln::topo::face_bkd_iter<D>::next_)
* mln/topo/n_face_iter.hh
(mln::topo::n_face_fwd_iter<D>::next_)
(mln::topo::n_face_bkd_iter<D>::next_)
* mln/topo/static_n_face_iter.hh
(mln::topo::static_n_face_fwd_iter<N, D>::next_)
(mln::topo::static_n_face_bkd_iter<N, D>::next_):
Here.
---
milena/ChangeLog | 15 +++++++++++
milena/mln/topo/face_iter.hh | 42 +++++++-------------------------
milena/mln/topo/n_face_iter.hh | 28 +++------------------
milena/mln/topo/static_n_face_iter.hh | 30 +++--------------------
4 files changed, 32 insertions(+), 83 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index d647d7e..18b410e 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,20 @@
2008-10-06 Roland Levillain <roland(a)lrde.epita.fr>
+ Simplify face iterators using the new accessors of face handles.
+
+ * mln/topo/face_iter.hh
+ (mln::topo::face_fwd_iter<D>::next_)
+ (mln::topo::face_bkd_iter<D>::next_)
+ * mln/topo/n_face_iter.hh
+ (mln::topo::n_face_fwd_iter<D>::next_)
+ (mln::topo::n_face_bkd_iter<D>::next_)
+ * mln/topo/static_n_face_iter.hh
+ (mln::topo::static_n_face_fwd_iter<N, D>::next_)
+ (mln::topo::static_n_face_bkd_iter<N, D>::next_):
+ Here.
+
+2008-10-06 Roland Levillain <roland(a)lrde.epita.fr>
+
Add extra accessors for topo::face<D> and topo::n_face<N, D>.
* mln/topo/face.hh
diff --git a/milena/mln/topo/face_iter.hh b/milena/mln/topo/face_iter.hh
index b34bfbd..2c0df92 100644
--- a/milena/mln/topo/face_iter.hh
+++ b/milena/mln/topo/face_iter.hh
@@ -169,26 +169,14 @@ namespace mln
{
if (is_valid())
{
- unsigned n = f_.n();
- unsigned face_id = f_.face_id();
-
- if (face_id + 1 < f_.cplx().nfaces(n))
- /* FIXME: Provide accessor face::face_id() returning
- a mutable reference? This way, we could just write
-
- ++f_.face_id();
-
- instead of the following.
-
- Or add {inc,add}_face_id() services. */
- f_.set_face_id(face_id + 1);
+ if (f_.face_id() + 1 < f_.cplx().nfaces(f_.n()))
+ f_.inc_face_id();
else
// Start to iterate on the faces of the next dimension if
// possible.
- if (n <= D)
+ if (f_.n() <= D)
{
- // FIXME: Same remark as above.
- f_.set_n(n + 1);
+ f_.inc_n();
f_.set_face_id(0u);
}
else
@@ -233,27 +221,15 @@ namespace mln
{
if (is_valid())
{
- unsigned n = f_.n();
- unsigned face_id = f_.face_id();
-
- if (face_id > 0)
- /* FIXME: Provide accessor face::face_id() returning
- a mutable reference? This way, we could just write
-
- ++f_.face_id();
-
- instead of the following.
-
- Or add {inc,add}_face_id() services. */
- f_.set_face_id(face_id - 1);
+ if (f_.face_id() > 0)
+ f_.dec_face_id();
else
// Start to iterate on the faces of the previous dimension
// if it exists.
- if (n > 0)
+ if (f_.n() > 0)
{
- // FIXME: Same remark as above.
- f_.set_n(n - 1);
- f_.set_face_id(f_.cplx().nfaces(n - 1) - 1);
+ f_.dec_n();
+ f_.set_face_id(f_.cplx().nfaces(f_.n()) - 1);
}
else
invalidate();
diff --git a/milena/mln/topo/n_face_iter.hh b/milena/mln/topo/n_face_iter.hh
index eaf9ef9..4b658bb 100644
--- a/milena/mln/topo/n_face_iter.hh
+++ b/milena/mln/topo/n_face_iter.hh
@@ -191,19 +191,8 @@ namespace mln
{
if (is_valid())
{
- unsigned face_id = f_.face_id();
- // The number of faces of dimension N in cplx_.
- unsigned nn_faces = f_.cplx().nfaces(n());
- if (face_id + 1 < nn_faces)
- /* FIXME: Provide accessor face::face_id() returning
- a mutable reference? This way, we could just write
-
- ++f_.face_id();
-
- instead of the following.
-
- Or add {inc,add}_face_id() services. */
- f_.set_face_id(face_id + 1);
+ if (f_.face_id() + 1 < f_.cplx().nfaces(n()))
+ f_.inc_face_id();
else
invalidate();
}
@@ -265,17 +254,8 @@ namespace mln
{
if (is_valid())
{
- unsigned face_id = f_.face_id();
- if (face_id > 0)
- /* FIXME: Provide accessor face::face_id() returning
- a mutable reference? This way, we could just write
-
- ++f_.face_id();
-
- instead of the following.
-
- Or add {inc,add}_face_id() services. */
- f_.set_face_id(face_id - 1);
+ if (f_.face_id() > 0)
+ f_.dec_face_id();
else
invalidate();
}
diff --git a/milena/mln/topo/static_n_face_iter.hh
b/milena/mln/topo/static_n_face_iter.hh
index 3868e01..db184ba 100644
--- a/milena/mln/topo/static_n_face_iter.hh
+++ b/milena/mln/topo/static_n_face_iter.hh
@@ -174,20 +174,8 @@ namespace mln
{
if (is_valid())
{
- unsigned face_id = f_.face_id();
- // The number of faces of dimension N in cplx_.
- unsigned nn_faces = f_.cplx().template nfaces<N>();
- if (face_id + 1 < nn_faces)
- /* FIXME: Provide accessor face::face_id()
- returning a mutable reference? This way, we could just
- write
-
- ++f_.face_id();
-
- instead of the following.
-
- Or add {inc,add}_face_id() services. */
- f_.set_face_id(face_id + 1);
+ if (f_.face_id() + 1 < f_.cplx().template nfaces<N>())
+ f_.inc_face_id();
else
invalidate();
}
@@ -235,18 +223,8 @@ namespace mln
{
if (is_valid())
{
- unsigned face_id = f_.face_id();
- if (face_id > 0)
- /* FIXME: Provide accessor face::face_id()
- returning a mutable reference? This way, we could just
- write
-
- ++f_.face_id();
-
- instead of the following.
-
- Or add {inc,add}_face_id() services. */
- f_.set_face_id(face_id - 1);
+ if (f_.face_id() > 0)
+ f_.dec_face_id();
else
invalidate();
}
--
1.5.6.5
Show replies by date