Commit aa20bad5 authored by Roland Levillain's avatar Roland Levillain
Browse files

Overhaul mln::topo::internal::complex_iter_base.

	* mln/topo/internal/complex_iter_base.hh
	(mln::topo::internal::complex_iter_base<F, E>::to_face): Remove.
	(operator<<(std::ostream&, const complex_iter_base<F, E>&)):
	Remove outdated FIXME.
	(mln::topo::internal::complex_iter_base<F, E>::face_): Rename as...
	(mln::topo::internal::complex_iter_base<F, E>::f_): ...this.
	Adjust.
	* mln/topo/face_iter.hh,
	* mln/topo/n_face_iter.hh,
	* mln/topo/static_n_face_iter.hh:
	Adjust as well.

git-svn-id: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008@2442 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent af4aa593
2008-09-30 Roland Levillain <roland@lrde.epita.fr>
Overhaul mln::topo::internal::complex_iter_base.
* mln/topo/internal/complex_iter_base.hh
(mln::topo::internal::complex_iter_base<F, E>::to_face): Remove.
(operator<<(std::ostream&, const complex_iter_base<F, E>&)):
Remove outdated FIXME.
(mln::topo::internal::complex_iter_base<F, E>::face_): Rename as...
(mln::topo::internal::complex_iter_base<F, E>::f_): ...this.
Adjust.
* mln/topo/face_iter.hh,
* mln/topo/n_face_iter.hh,
* mln/topo/static_n_face_iter.hh:
Adjust as well.
2008-09-30 Roland Levillain <roland@lrde.epita.fr>
 
Improve accesses to adjacent faces to mln::topo::face<D>.
......
......@@ -84,7 +84,7 @@ namespace mln
/// \}
private:
using super_::face_;
using super_::f_;
};
......@@ -124,7 +124,7 @@ namespace mln
/// \}
private:
using super_::face_;
using super_::f_;
};
......@@ -156,8 +156,8 @@ namespace mln
void
face_fwd_iter<D>::start()
{
face_.set_n(0u);
face_.set_face_id(0u);
f_.set_n(0u);
f_.set_face_id(0u);
}
template <unsigned D>
......@@ -167,27 +167,27 @@ namespace mln
{
if (is_valid())
{
unsigned n = face_.n();
unsigned face_id = face_.face_id();
unsigned n = f_.n();
unsigned face_id = f_.face_id();
if (face_id + 1 < face_.cplx().nfaces(n))
if (face_id + 1 < f_.cplx().nfaces(n))
/* FIXME: Provide accessor face::face_id() returning
a mutable reference? This way, we could just write
++face_.face_id();
++f_.face_id();
instead of the following.
Or add {inc,add}_face_id() services. */
face_.set_face_id(face_id + 1);
f_.set_face_id(face_id + 1);
else
// Start to iterate on the faces of the next dimension if
// possible.
if (n <= D)
{
// FIXME: Same remark as above.
face_.set_n(n + 1);
face_.set_face_id(0u);
f_.set_n(n + 1);
f_.set_face_id(0u);
}
else
invalidate();
......@@ -220,8 +220,8 @@ namespace mln
void
face_bkd_iter<D>::start()
{
face_.set_n(D);
face_.set_face_id(face_.cplx().template nfaces<D>() - 1);
f_.set_n(D);
f_.set_face_id(f_.cplx().template nfaces<D>() - 1);
}
template <unsigned D>
......@@ -231,27 +231,27 @@ namespace mln
{
if (is_valid())
{
unsigned n = face_.n();
unsigned face_id = face_.face_id();
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
++face_.face_id();
++f_.face_id();
instead of the following.
Or add {inc,add}_face_id() services. */
face_.set_face_id(face_id - 1);
f_.set_face_id(face_id - 1);
else
// Start to iterate on the faces of the previous dimension
// if it exists.
if (n > 0)
{
// FIXME: Same remark as above.
face_.set_n(n - 1);
face_.set_face_id(face_.cplx().nfaces(n - 1) - 1);
f_.set_n(n - 1);
f_.set_face_id(f_.cplx().nfaces(n - 1) - 1);
}
else
invalidate();
......
......@@ -39,6 +39,11 @@
# include <mln/core/concept/iterator.hh>
# include <mln/topo/complex.hh>
// FIXME: Rename as something else?
// - complex_iterator_base?
// - complex_set_iterator_base?
// - faces_set_iterator_base?
namespace mln
{
......@@ -83,17 +88,15 @@ namespace mln
void invalidate();
/// \}
/// Conversion and accessors.
/// Conversion.
/// \{
/// Reference to the corresponding face handle.
const face& to_face () const;
/// Convert the iterator into an face handle.
operator face() const;
/// Return a reference to the corresponding face handle.
operator const face&() const;
/// \}
protected:
/// The face handle this iterator is pointing to.
face face_;
face f_;
};
......@@ -124,8 +127,8 @@ namespace mln
// Ensure F and E are compatible.
mlc_equal(F, typename E::face)::check();
face_.set_cplx(c);
// Invalidate face_.
f_.set_cplx(c);
// Invalidate f_.
invalidate();
}
......@@ -134,8 +137,8 @@ namespace mln
void
complex_iter_base<F, E>::set_cplx(complex_type& c)
{
face_.set_cplx(c);
// Invalidate face_.
f_.set_cplx(c);
// Invalidate f_.
invalidate();
}
......@@ -144,7 +147,7 @@ namespace mln
bool
complex_iter_base<F, E>::is_valid() const
{
return face_.is_valid();
return f_.is_valid();
}
template <typename F, typename E>
......@@ -152,23 +155,14 @@ namespace mln
void
complex_iter_base<F, E>::invalidate()
{
face_.invalidate();
}
template <typename F, typename E>
inline
const F&
complex_iter_base<F, E>::to_face() const
{
return face_;
f_.invalidate();
}
template <typename F, typename E>
inline
complex_iter_base<F, E>::operator F() const
complex_iter_base<F, E>::operator const F&() const
{
mln_precondition(is_valid());
return face_;
return f_;
}
......@@ -177,21 +171,7 @@ namespace mln
std::ostream&
operator<<(std::ostream& ostr, const complex_iter_base<F, E>& p)
{
/* FIXME: We should use p.to_face() here, but as it lacks the
precondition the conversion operator has, so we use the latter.
We should
- rename `to_face' as `to_face_';
- write a new `to_face' routine checking the validity of the
iterator;
- have the conversion operator to face use this new `to_face'
routine;
- adjust former clients of `to_face'
This is a general remark that applies to all iterators of
Milena. */
F f = p;
return ostr << f;
return ostr << F(p);
}
# endif // ! MLN_INCLUDE_ONLY
......
......@@ -95,7 +95,7 @@ namespace mln
/// \}
private:
using super_::face_;
using super_::f_;
};
......@@ -143,7 +143,7 @@ namespace mln
/// \}
private:
using super_::face_;
using super_::f_;
};
......@@ -177,7 +177,7 @@ namespace mln
void
n_face_fwd_iter<D>::start()
{
face_.set_face_id(0u);
f_.set_face_id(0u);
}
template <unsigned D>
......@@ -187,19 +187,19 @@ namespace mln
{
if (is_valid())
{
unsigned face_id = face_.face_id();
unsigned face_id = f_.face_id();
// The number of faces of dimension N in cplx_.
unsigned nn_faces = face_.cplx().nfaces(n());
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
++face_.face_id();
++f_.face_id();
instead of the following.
Or add {inc,add}_face_id() services. */
face_.set_face_id(face_id + 1);
f_.set_face_id(face_id + 1);
else
invalidate();
}
......@@ -210,7 +210,7 @@ namespace mln
unsigned
n_face_fwd_iter<D>::n() const
{
return face_.n();
return f_.n();
}
template <unsigned D>
......@@ -219,7 +219,7 @@ namespace mln
n_face_fwd_iter<D>::set_n(unsigned n)
{
mln_precondition(n <= D);
face_.set_n(n);
f_.set_n(n);
}
......@@ -250,8 +250,8 @@ namespace mln
void
n_face_bkd_iter<D>::start()
{
face_.set_n(n());
face_.set_face_id(face_.cplx().nfaces(n()) - 1);
f_.set_n(n());
f_.set_face_id(f_.cplx().nfaces(n()) - 1);
}
template <unsigned D>
......@@ -261,17 +261,17 @@ namespace mln
{
if (is_valid())
{
unsigned face_id = face_.face_id();
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
++face_.face_id();
++f_.face_id();
instead of the following.
Or add {inc,add}_face_id() services. */
face_.set_face_id(face_id - 1);
f_.set_face_id(face_id - 1);
else
invalidate();
}
......@@ -282,7 +282,7 @@ namespace mln
unsigned
n_face_bkd_iter<D>::n() const
{
return face_.n();
return f_.n();
}
template <unsigned D>
......@@ -291,7 +291,7 @@ namespace mln
n_face_bkd_iter<D>::set_n(unsigned n)
{
mln_precondition(n <= D);
face_.set_n(n);
f_.set_n(n);
}
# endif // ! MLN_INCLUDE_ONLY
......
......@@ -81,7 +81,7 @@ namespace mln
/// \}
private:
using super_::face_;
using super_::f_;
};
......@@ -124,7 +124,7 @@ namespace mln
/// \}
private:
using super_::face_;
using super_::f_;
};
......@@ -142,7 +142,7 @@ namespace mln
{
// Ensure N is compatible with D.
metal::bool_< N <= D >::check();
face_.set_n(N);
f_.set_n(N);
mln_postcondition(!is_valid());
}
......@@ -153,7 +153,7 @@ namespace mln
{
// Ensure N is compatible with D.
metal::bool_< N <= D >::check();
face_.set_n(N);
f_.set_n(N);
mln_postcondition(!is_valid());
}
......@@ -162,7 +162,7 @@ namespace mln
void
static_n_face_fwd_iter<N, D>::start()
{
face_.set_face_id(0u);
f_.set_face_id(0u);
}
template <unsigned N, unsigned D>
......@@ -172,20 +172,20 @@ namespace mln
{
if (is_valid())
{
unsigned face_id = face_.face_id();
unsigned face_id = f_.face_id();
// The number of faces of dimension N in cplx_.
unsigned nn_faces = face_.cplx().template nfaces<N>();
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
++face_.face_id();
++f_.face_id();
instead of the following.
Or add {inc,add}_face_id() services. */
face_.set_face_id(face_id + 1);
f_.set_face_id(face_id + 1);
else
invalidate();
}
......@@ -203,7 +203,7 @@ namespace mln
{
// Ensure N is compatible with D.
metal::bool_< N <= D >::check();
face_.set_n(N);
f_.set_n(N);
mln_postcondition(!is_valid());
}
......@@ -214,7 +214,7 @@ namespace mln
{
// Ensure N is compatible with D.
metal::bool_< N <= D >::check();
face_.set_n(N);
f_.set_n(N);
mln_postcondition(!is_valid());
}
......@@ -223,7 +223,7 @@ namespace mln
void
static_n_face_bkd_iter<N, D>::start()
{
face_.set_face_id(face_.cplx().template nfaces<N>() - 1);
f_.set_face_id(f_.cplx().template nfaces<N>() - 1);
}
template <unsigned N, unsigned D>
......@@ -233,18 +233,18 @@ namespace mln
{
if (is_valid())
{
unsigned face_id = face_.face_id();
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
++face_.face_id();
++f_.face_id();
instead of the following.
Or add {inc,add}_face_id() services. */
face_.set_face_id(face_id - 1);
f_.set_face_id(face_id - 1);
else
invalidate();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment