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
September 2008
- 12 participants
- 359 discussions
* mln/core/faces_psite.hh (mln::faces_psite<N, D, P>): Inherit
from internal::pseudo_site_base_.
(mln::faces_psite<N, D, P>::self_)
(mln::faces_psite<N, D, P>::super_):
(mln::faces_psite<N, D, P>::mesh):
(mln::faces_psite<N, D, P>::point):
(mln::faces_psite<N, D, P>::dpoint):
(mln::faces_psite<N, D, P>::coord):
Remove typdefs.
(mln::faces_psite<N, D, P>::dim):
Remove enum.
(mln::faces_psite<N, D, P>::target): New typedef.
(mln::faces_psite<N, D, P>::faces_psite(const self_&)):
Remove ctor.
(mln::faces_psite<N, D, P>::operator=(const self_&))
(mln::faces_psite<N, D, P>::to_site)
(mln::faces_psite<N, D, P>::to_point)
(mln::faces_psite<N, D, P>::operator[]):
Remove methods.
(mln::faces_psite<N, D, P>::faces_psite(const any_face_handle<D>&)):
Add an extra argument pc to pass the target mln::p_complex.
(faces_psite(const p_complex<N, D, P>, unsigned, unsigned)):
New ctor.
(mln::faces_psite<N, D, P>::invalidate)
(mln::faces_psite<N, D, P>::target_)
(mln::faces_psite<N, D, P>::change_target)
(mln::faces_psite<N, D, P>::subj_)
(mln::faces_psite<N, D, P>::update_):
New method.
(mln::faces_psite<N, D, P>::cplx): Rename as...
(mln::faces_psite<N, D, P>::site_set): ...this.
Adjust clients.
(mln::faces_psite<N, D, P>::p_): Change type of attribute to P.
(mln::faces_psite<N, D, P>::pc_): New attribute.
(operator!=(const faces_psite<N, D, P>&, const faces_psite<N, D, P>&)):
New operator.
(operator<<(std::ostream& ostr, const faces_psite<N, D, P>& p))
(mln::faces_psite<N, D, P>::faces_psite):
Adjust all ctors.
(mln::faces_psite<N, D, P>::is_valid)
(mln::faces_psite<N, D, P>::site_set):
Adjust methods.
(mln::faces_psite<N, D, P>::n)
(mln::faces_psite<N, D, P>::face_id):
New accessors.
---
milena/ChangeLog | 50 ++++++++
milena/mln/core/faces_psite.hh | 248 ++++++++++++++++++++++++++++++----------
2 files changed, 235 insertions(+), 63 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 87164b6..583ddc0 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,55 @@
2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+ Update site on mln::p_faces.
+
+ * mln/core/faces_psite.hh (mln::faces_psite<N, D, P>): Inherit
+ from internal::pseudo_site_base_.
+ (mln::faces_psite<N, D, P>::self_)
+ (mln::faces_psite<N, D, P>::super_):
+ (mln::faces_psite<N, D, P>::mesh):
+ (mln::faces_psite<N, D, P>::point):
+ (mln::faces_psite<N, D, P>::dpoint):
+ (mln::faces_psite<N, D, P>::coord):
+ Remove typdefs.
+ (mln::faces_psite<N, D, P>::dim):
+ Remove enum.
+ (mln::faces_psite<N, D, P>::target): New typedef.
+ (mln::faces_psite<N, D, P>::faces_psite(const self_&)):
+ Remove ctor.
+ (mln::faces_psite<N, D, P>::operator=(const self_&))
+ (mln::faces_psite<N, D, P>::to_site)
+ (mln::faces_psite<N, D, P>::to_point)
+ (mln::faces_psite<N, D, P>::operator[]):
+ Remove methods.
+ (mln::faces_psite<N, D, P>::faces_psite(const any_face_handle<D>&)):
+ Add an extra argument pc to pass the target mln::p_complex.
+ (faces_psite(const p_complex<N, D, P>, unsigned, unsigned)):
+ New ctor.
+ (mln::faces_psite<N, D, P>::invalidate)
+ (mln::faces_psite<N, D, P>::target_)
+ (mln::faces_psite<N, D, P>::change_target)
+ (mln::faces_psite<N, D, P>::subj_)
+ (mln::faces_psite<N, D, P>::update_):
+ New method.
+ (mln::faces_psite<N, D, P>::cplx): Rename as...
+ (mln::faces_psite<N, D, P>::site_set): ...this.
+ Adjust clients.
+ (mln::faces_psite<N, D, P>::p_): Change type of attribute to P.
+ (mln::faces_psite<N, D, P>::pc_): New attribute.
+ (operator!=(const faces_psite<N, D, P>&, const faces_psite<N, D, P>&)):
+ New operator.
+ (operator<<(std::ostream& ostr, const faces_psite<N, D, P>& p))
+ (mln::faces_psite<N, D, P>::faces_psite):
+ Adjust all ctors.
+ (mln::faces_psite<N, D, P>::is_valid)
+ (mln::faces_psite<N, D, P>::site_set):
+ Adjust methods.
+ (mln::faces_psite<N, D, P>::n)
+ (mln::faces_psite<N, D, P>::face_id):
+ New accessors.
+
+2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+
Update site on mln::p_complex.
* mln/core/complex_psite.hh (mln::complex_psite<D, P>): Inherit
diff --git a/milena/mln/core/faces_psite.hh b/milena/mln/core/faces_psite.hh
index ac8b5ed..102394b 100644
--- a/milena/mln/core/faces_psite.hh
+++ b/milena/mln/core/faces_psite.hh
@@ -32,15 +32,20 @@
/// \brief Definition of a point site based on the n-faces of a
/// complex.
-# include <mln/core/concept/point_site.hh>
+# include <mln/core/internal/pseudo_site_base.hh>
# include <mln/core/complex.hh>
+// FIXME: Factor complex_psite and faces_psite?
+
+// FIXME: Rename faces_psite as p_faces_psite, and move this file to
+// core/site_set.
namespace mln
{
- /* FIXME: Currently, P and N are free variables; we might want to
- relate them, e.g., have P::dim == N. Or even get rid of P. */
+ // Forward declaration.
+ template <unsigned N, unsigned D, typename P> class p_faces;
+
/// \brief Point site associated to a mln::p_faces.
///
@@ -48,50 +53,89 @@ namespace mln
/// \arg \p D The dimension of the complex this psite belongs to.
/// \arg \p P The type of point associated to this psite.
template <unsigned N, unsigned D, typename P>
- class faces_psite : public Point_Site< faces_psite<N, D, P> >
+ class faces_psite
+ : public internal::pseudo_site_base_< const P&,
+ faces_psite<N, D, P> >
{
- typedef faces_psite<N, D, P> self_;
- typedef Point_Site<self_> super_;
-
public:
- typedef mln_mesh(P) mesh;
- enum { dim = P::dim };
- typedef P point;
- typedef mln_dpoint(P) dpoint;
- typedef mln_coord(P) coord;
+ // This associated type is important to know that this particular
+ // pseudo site knows the site set it refers to.
+ typedef p_faces<N, D, P> target;
/// Construction and assignment.
/// \{
faces_psite();
- faces_psite(const face_handle<N, D>& face);
- faces_psite(const self_& rhs);
- self_& operator= (const self_& rhs);
+ /// \pre pf.cplx() == face.cplx().
+ faces_psite(const p_faces<N, D, P>& pf, const face_handle<N, D>& face);
+ faces_psite(const p_faces<N, D, P>& pf, unsigned face_id);
+ /// \}
+
+ /// Psite manipulators.
+ /// \{
+ /// Is this psite valid?
+ bool is_valid() const;
+ /// Invalidate this psite.
+ void invalidate();
/// \}
- /// Access to psite.
- const self_& to_psite() const;
+ /// Site set manipulators.
+ /// \{
+ /// \brief Return the p_faces this site is built on.
+ /// (shortcut for *target()).
+ /// \pre Member face_ is valid.
+ const target& site_set() const;
+
+ /// Get a pointer to the target site_set.
+ const target* target_() const;
+ /// Set the target site_set.
+ void change_target(const target& new_target);
+ /// \}
- /* FIXME: Should be removed as soon as ``point sets'' become
- ``site sets''. */
- /// Access to point.
+ /// Proxy manipulators.
/// \{
- const point& to_point() const;
- coord operator[](unsigned face) const;
+ /// Return the site corresponding to this psite.
+ const P& subj_();
/// \}
+ /// Face handle manipulators.
+ /// \{
/// Return the face handle of this point site.
face_handle<N, D> face() const;
- /// Return the complex on which this site is built.
- const complex<D>& cplx() const;
- /// Is this psite valid?
- bool is_valid() const;
+ /// Return the dimension of the face of this psite.
+ unsigned n() const;
+ /// Return the id of the face of this psite.
+ unsigned face_id() const;
+ /// \}
+
+ private:
+ /// Site-related members.
+ /// \{
+ /// Update the site corresponding to this psite.
+ void update_();
+ // The site corresponding to this psite.
+ P p_;
+ /// \}
+
+ /* FIXME: Attributes pf_ and face_ share a common information: the
+ address of their complex.
+
+ This is both a loss of space and time (we must ensure
+ synchronization), but this design issue is not trivial: we
+ actually introduced the face handles to pack together the
+ location information (face_id) with the support (the complex),
+ to avoid what we did with graphs --- where location (edge id or
+ vertex id) is separated from the support (the graph).
+ Think about it, and adjust complex_psite as well. */
private:
+ /// Complex-related members.
+ /// \{
+ /// The mln::p_faces this point site belongs to.
+ const target* pf_;
/// The handle of the face this psite is pointing towards.
face_handle<N, D> face_;
- // FIXME: Actually, this is a dummy value!
- point p_;
+ /// \}
};
@@ -109,6 +153,16 @@ namespace mln
operator==(const faces_psite<N, D, P>& lhs,
const faces_psite<N, D, P>& rhs);
+
+ /// \brief Is \a lhs equal to \a rhs?
+ ///
+ /// \pre Arguments \a lhs and \a rhs must belong to the same
+ /// mln::complex.
+ template <unsigned N, unsigned D, typename P>
+ bool
+ operator!=(const faces_psite<N, D, P>& lhs,
+ const faces_psite<N, D, P>& rhs);
+
/// \brief Is \a lhs ``less'' than \a rhs?
///
/// This comparison is required by algorithms sorting psites.
@@ -122,83 +176,111 @@ namespace mln
/// \}
+ template <unsigned N, unsigned D, typename P>
+ inline
+ std::ostream&
+ operator<<(std::ostream& ostr, const faces_psite<N, D, P>& p);
+
+
# ifndef MLN_INCLUDE_ONLY
template <unsigned N, unsigned D, typename P>
inline
faces_psite<N, D, P>::faces_psite()
- : super_(),
- // Dummy initializations.
- face_(), p_()
+ : pf_(0)
{
// Ensure N is compatible with D.
metal::bool_< N <= D >::check();
+
+ invalidate();
}
template <unsigned N, unsigned D, typename P>
inline
- faces_psite<N, D, P>::faces_psite(const face_handle<N, D>& face)
- : super_(),
- face_(face), p_()
+ faces_psite<N, D, P>::faces_psite(const p_faces<N, D, P>& pf,
+ const face_handle<N, D>& face)
+ : pf_(&pf),
+ face_(face)
{
// Ensure N is compatible with D.
metal::bool_< N <= D >::check();
+ // Check arguments consistency.
+// mln_precondition(pf.cplx() == face.cplx());
+
+ update_();
}
template <unsigned N, unsigned D, typename P>
inline
- faces_psite<N, D, P>::faces_psite(const faces_psite<N, D, P>& rhs)
- : super_(rhs),
- face_(rhs.face_), p_()
+ faces_psite<N, D, P>::faces_psite(const p_faces<N, D, P>& pf,
+ unsigned face_id)
+ : pf_(&pf),
+ face_(pf.cplx(), face_id)
{
// Ensure N is compatible with D.
metal::bool_< N <= D >::check();
+
+ update_();
+ }
+
+ template <unsigned N, unsigned D, typename P>
+ inline
+ bool
+ faces_psite<N, D, P>::is_valid() const
+ {
+// mln_invariant(!pf_ || pf_.cplx() == face_.cplx());
+ return face_.is_valid();
}
template <unsigned N, unsigned D, typename P>
inline
- faces_psite<N, D, P>&
- faces_psite<N, D, P>::operator= (const faces_psite<N, D, P>& rhs)
+ void
+ faces_psite<N, D, P>::invalidate()
{
- if (&rhs == this)
- return *this;
- face_ = rhs.face_;
- return *this;
+ return face_.invalidate();
}
template <unsigned N, unsigned D, typename P>
inline
- bool
- faces_psite<N, D, P>::is_valid() const
+ const p_faces<N, D, P>&
+ faces_psite<N, D, P>::site_set() const
{
- return face_.is_valid();
+ mln_precondition(target_());
+ return *target_();
}
template <unsigned N, unsigned D, typename P>
inline
- const faces_psite<N, D, P>&
- faces_psite<N, D, P>::to_psite() const
+ const p_faces<N, D, P>*
+ faces_psite<N, D, P>::target_() const
{
- return *this;
+// mln_invariant(!pf_ || pf_.cplx() == face_.cplx());
+ return pf_;
}
template <unsigned N, unsigned D, typename P>
inline
- const P&
- faces_psite<N, D, P>::to_point() const
+ void
+ faces_psite<N, D, P>::change_target(const p_faces<N, D, P>& new_target)
{
- // FIXME: Dummy value.
- return p_;
+ // Update both pc_ and face_.
+ pf_ = &new_target;
+ face_.set_cplx(new_target.cplx());
+ invalidate();
}
+ // FIXME: Write or extend a test to exercise this method (when the
+ // handling of P is done, i.e., when update_ is complete).
template <unsigned N, unsigned D, typename P>
inline
- mln_coord(P)
- faces_psite<N, D, P>::operator[](unsigned i) const
+ const P&
+ faces_psite<N, D, P>::subj_()
{
- mln_precondition(is_valid());
- return to_point()[i];
+ // FIXME: Member p_ is not updated correctly yet; do not use this
+ // method for now.
+ abort();
+ return p_;
}
template <unsigned N, unsigned D, typename P>
@@ -211,12 +293,31 @@ namespace mln
template <unsigned N, unsigned D, typename P>
inline
- const complex<D>&
- faces_psite<N, D, P>::cplx() const
+ unsigned
+ faces_psite<N, D, P>::n() const
+ {
+ return face_.n();
+ }
+
+ template <unsigned N, unsigned D, typename P>
+ inline
+ unsigned
+ faces_psite<N, D, P>::face_id() const
+ {
+ return face_.face_id();
+ }
+
+ template <unsigned N, unsigned D, typename P>
+ inline
+ void
+ faces_psite<N, D, P>::update_()
{
- return face_.cplx();
+ mln_precondition(is_valid());
+// mln_invariant(!pf_ || pf_.cplx() == face_.cplx());
+ // FIXME: Implement (update p_).
}
+
/*--------------.
| Comparisons. |
`--------------*/
@@ -226,21 +327,42 @@ namespace mln
operator==(const faces_psite<N, D, P>& lhs,
const faces_psite<N, D, P>& rhs)
{
- mln_precondition(&lhs.cplx() == &rhs.cplx());
+ mln_precondition(&lhs.site_set() == &rhs.site_set());
return lhs.face() == rhs.face();
}
template <unsigned N, unsigned D, typename P>
bool
+ operator!=(const faces_psite<N, D, P>& lhs,
+ const faces_psite<N, D, P>& rhs)
+ {
+ mln_precondition(&lhs.site_set() == &rhs.site_set());
+ return lhs.face() != rhs.face();
+ }
+
+ template <unsigned N, unsigned D, typename P>
+ bool
operator< (const faces_psite<N, D, P>& lhs,
const faces_psite<N, D, P>& rhs)
{
- mln_precondition(&lhs.cplx() == &rhs.cplx());
+ mln_precondition(&lhs.site_set() == &rhs.site_set());
return lhs.face() < rhs.face();
}
-# endif // ! MLN_INCLUDE_ONLY
+ /*------------------.
+ | Pretty-printing. |
+ `------------------*/
+
+ template <unsigned N, unsigned D, typename P>
+ inline
+ std::ostream&
+ operator<<(std::ostream& ostr, const faces_psite<N, D, P>& p)
+ {
+ return ostr << "(dim = " << p.n() << ", id = " << p.face_id() << ')';
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
} // end of mln
--
1.6.0.1
1
0
* mln/core/complex_psite.hh (mln::complex_psite<D, P>): Inherit
from internal::pseudo_site_base_.
(mln::complex_psite<D, P>::self_)
(mln::complex_psite<D, P>::super_):
(mln::complex_psite<D, P>::mesh):
(mln::complex_psite<D, P>::point):
(mln::complex_psite<D, P>::dpoint):
(mln::complex_psite<D, P>::coord):
Remove typdefs.
(mln::complex_psite<D, P>::dim):
Remove enum.
(mln::complex_psite<D, P>::target): New typedef.
(mln::complex_psite<D, P>::complex_psite(const self_&)):
Remove ctor.
(mln::complex_psite<D, P>::operator=(const self_&))
(mln::complex_psite<D, P>::to_site)
(mln::complex_psite<D, P>::to_point)
(mln::complex_psite<D, P>::operator[]):
Remove methods.
(mln::complex_psite<D, P>::complex_psite(const any_face_handle<D>&)):
Add an extra argument pc to pass the target mln::p_complex.
(complex_psite(const p_complex<D, P>, unsigned, unsigned)):
New ctor.
(mln::complex_psite<D, P>::invalidate)
(mln::complex_psite<D, P>::target_)
(mln::complex_psite<D, P>::change_target)
(mln::complex_psite<D, P>::subj_)
(mln::complex_psite<D, P>::update_):
New method.
(mln::complex_psite<D, P>::cplx): Rename as...
(mln::complex_psite<D, P>::site_set): ...this.
Adjust clients.
(mln::complex_psite<D, P>::p_): Change type of attribute to P.
(mln::complex_psite<D, P>::pc_): New attribute.
(operator!=(const complex_psite<D, P>&, const complex_psite<D, P>&)):
New operator.
(mln::complex_psite<D, P>::complex_psite):
Adjust all ctors.
(mln::complex_psite<D, P>::is_valid)
(mln::complex_psite<D, P>::site_set):
Adjust methods.
---
milena/ChangeLog | 46 ++++++++
milena/mln/core/complex_psite.hh | 232 ++++++++++++++++++++++++++------------
2 files changed, 206 insertions(+), 72 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 8778cd6..87164b6 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,51 @@
2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+ Update site on mln::p_complex.
+
+ * mln/core/complex_psite.hh (mln::complex_psite<D, P>): Inherit
+ from internal::pseudo_site_base_.
+ (mln::complex_psite<D, P>::self_)
+ (mln::complex_psite<D, P>::super_):
+ (mln::complex_psite<D, P>::mesh):
+ (mln::complex_psite<D, P>::point):
+ (mln::complex_psite<D, P>::dpoint):
+ (mln::complex_psite<D, P>::coord):
+ Remove typdefs.
+ (mln::complex_psite<D, P>::dim):
+ Remove enum.
+ (mln::complex_psite<D, P>::target): New typedef.
+ (mln::complex_psite<D, P>::complex_psite(const self_&)):
+ Remove ctor.
+ (mln::complex_psite<D, P>::operator=(const self_&))
+ (mln::complex_psite<D, P>::to_site)
+ (mln::complex_psite<D, P>::to_point)
+ (mln::complex_psite<D, P>::operator[]):
+ Remove methods.
+ (mln::complex_psite<D, P>::complex_psite(const any_face_handle<D>&)):
+ Add an extra argument pc to pass the target mln::p_complex.
+ (complex_psite(const p_complex<D, P>, unsigned, unsigned)):
+ New ctor.
+ (mln::complex_psite<D, P>::invalidate)
+ (mln::complex_psite<D, P>::target_)
+ (mln::complex_psite<D, P>::change_target)
+ (mln::complex_psite<D, P>::subj_)
+ (mln::complex_psite<D, P>::update_):
+ New method.
+ (mln::complex_psite<D, P>::cplx): Rename as...
+ (mln::complex_psite<D, P>::site_set): ...this.
+ Adjust clients.
+ (mln::complex_psite<D, P>::p_): Change type of attribute to P.
+ (mln::complex_psite<D, P>::pc_): New attribute.
+ (operator!=(const complex_psite<D, P>&, const complex_psite<D, P>&)):
+ New operator.
+ (mln::complex_psite<D, P>::complex_psite):
+ Adjust all ctors.
+ (mln::complex_psite<D, P>::is_valid)
+ (mln::complex_psite<D, P>::site_set):
+ Adjust methods.
+
+2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+
Update site set mln::p_faces
* mln/core/site_set/p_faces.hh
diff --git a/milena/mln/core/complex_psite.hh b/milena/mln/core/complex_psite.hh
index d7ace6b..2a9a0e7 100644
--- a/milena/mln/core/complex_psite.hh
+++ b/milena/mln/core/complex_psite.hh
@@ -31,57 +31,82 @@
/// \file mln/core/complex_psite.hh
/// \brief Definition of a complex-based point site.
-# include <mln/core/concept/point_site.hh>
+# include <mln/core/internal/pseudo_site_base.hh>
# include <mln/core/complex.hh>
+// FIXME: There's a circular dependency issue between complex_psite
+// and p_complex (likewise for faces_psite and p_faces): they have to
+// know their interfaces one another. I have disabled some
+// preconditions and invariants to have the code compile, but we must
+// find a real solution.
+
+// FIXME: Factor complex_psite and faces_psite?
+
+// FIXME: Rename complex_psite as p_complex_psite, and move this file to
+// core/site_set.
+
namespace mln
{
- /* FIXME: Get rid of P? */
+ // Forward declaration.
+ template <unsigned D, typename P> class p_complex;
+
/// \brief Point site associated to a mln::p_complex.
///
/// \arg \p D The dimension of the complex this psite belongs to.
/// \arg \p P The type of point associated to this psite.
template <unsigned D, typename P>
- class complex_psite : public Point_Site< complex_psite<D, P> >
+ class complex_psite
+ : public internal::pseudo_site_base_< const P&,
+ complex_psite<D, P> >
{
- typedef complex_psite<D, P> self_;
- typedef Point_Site<self_> super_;
-
public:
- typedef mln_mesh(P) mesh;
- enum { dim = P::dim };
- typedef P point;
- typedef mln_dpoint(P) dpoint;
- typedef mln_coord(P) coord;
+ // This associated type is important to know that this particular
+ // pseudo site knows the site set it refers to.
+ typedef p_complex<D, P> target;
+ // FIXME: Document.
/// Construction and assignment.
/// \{
complex_psite();
- complex_psite(const any_face_handle<D>& face);
- complex_psite(const self_& rhs);
- self_& operator= (const self_& rhs);
+ /// \pre pc.cplx() == face.cplx().
+ complex_psite(const p_complex<D, P>& pc, const any_face_handle<D>& face);
+ complex_psite(const p_complex<D, P>& pc, unsigned n, unsigned face_id);
/// \}
- /// Access to psite.
- const self_& to_psite() const;
+ /// Psite manipulators.
+ /// \{
+ /// Is this psite valid?
+ bool is_valid() const;
+ /// Invalidate this psite.
+ void invalidate();
+ /// \}
+
+ /// Site set manipulators.
+ /// \{
+ /// \brief Return the mln::p_complex this site is built on.
+ /// (shortcut for *target()).
+ /// \pre Member face_ is valid.
+ const target& site_set() const;
+
+ /// Get a pointer to the target site_set.
+ const target* target_() const;
+ /// Set the target site_set.
+ void change_target(const target& new_target);
+ /// \}
- /* FIXME: Should be removed as soon as ``point sets'' become
- ``site sets''. */
- /// Access to point.
+ /// Proxy manipulators.
/// \{
- const point& to_point() const;
- coord operator[](unsigned face) const;
+ /// Return the site corresponding to this psite.
+ const P& subj_();
/// \}
- /// Accessors
+ /// Face handle manipulators.
/// \{
/// Return the face handle of this point site.
any_face_handle<D> face() const;
- /// Return the complex on which this site is built.
- const complex<D>& cplx() const;
/// Return the dimension of the face of this psite.
unsigned n() const;
@@ -89,14 +114,35 @@ namespace mln
unsigned face_id() const;
/// \}
- /// Is this psite valid?
- bool is_valid() const;
+ private:
+ /// Site-related members.
+ /// \{
+ /// Update the site corresponding to this psite.
+ void update_();
+ // The site corresponding to this psite.
+ P p_;
+ /// \}
+
+ /* FIXME: Attributes pc_ and face_ share a common information: the
+ address of their complex.
+
+ This is both a loss of space and time (we must ensure
+ synchronization), but this design issue is not trivial: we
+ actually introduced (any-)face handles to pack together the
+ location information (n, face_id) with the support (the
+ complex), to avoid what we did with graphs --- where location
+ (edge id or vertex id) is separated from the support (the
+ graph).
+ Think about it, and adjust faces_psite as well. */
private:
+ /// Complex-related members.
+ /// \{
+ /// The mln::p_faces this point site belongs to.
+ const target* pc_;
/// The handle of the face this psite is pointing towards.
any_face_handle<D> face_;
- // FIXME: Actually, this is a dummy value!
- point p_;
+ /// \}
};
@@ -108,18 +154,33 @@ namespace mln
/// \brief Is \a lhs equal to \a rhs?
///
/// \pre Arguments \a lhs and \a rhs must belong to the same
- /// mln::complex.
+ /// mln::p_complex.
+ /* FIXME: We probably want to relax this precondition: p_complex
+ equality is too strong; prefer complex equality. */
template <unsigned D, typename P>
bool
operator==(const complex_psite<D, P>& lhs,
const complex_psite<D, P>& rhs);
+ /// \brief Is \a lhs not equal to \a rhs?
+ ///
+ /// \pre Arguments \a lhs and \a rhs must belong to the same
+ /// mln::p_complex.
+ /* FIXME: We probably want to relax this precondition: p_complex
+ equality is too strong; prefer complex equality. */
+ template <unsigned D, typename P>
+ bool
+ operator!=(const complex_psite<D, P>& lhs,
+ const complex_psite<D, P>& rhs);
+
/// \brief Is \a lhs ``less'' than \a rhs?
///
/// This comparison is required by algorithms sorting psites.
///
/// \pre Arguments \a lhs and \a rhs must belong to the same
- /// mln::complex.
+ /// mln::p_complex.
+ /* FIXME: We probably want to relax this precondition: p_complex
+ equality is too strong; prefer complex equality. */
template <unsigned D, typename P>
bool
operator< (const complex_psite<D, P>& lhs,
@@ -127,10 +188,6 @@ namespace mln
/// \}
- /* FIXME: This hand-made delegation is painful. We should rely on
- the general mechanism provided by Point_Site. But then again, we
- need to refine/adjust the interface of Point_Site w.r.t. the
- mandatory conversions to points. */
template <unsigned D, typename P>
inline
std::ostream&
@@ -143,87 +200,98 @@ namespace mln
template <unsigned D, typename P>
inline
complex_psite<D, P>::complex_psite()
- : super_(),
- // Dummy initializations.
- face_(), p_()
+ : pc_(0)
{
+ invalidate();
}
template <unsigned D, typename P>
inline
- complex_psite<D, P>::complex_psite(const any_face_handle<D>& face)
- : super_(),
- face_(face), p_()
+ complex_psite<D, P>::complex_psite(const p_complex<D, P>& pc,
+ const any_face_handle<D>& face)
+ : pc_(&pc),
+ face_(face)
{
+ // Check arguments consistency.
+// mln_precondition(pc.cplx() == face.cplx());
+ update_();
}
template <unsigned D, typename P>
inline
- complex_psite<D, P>::complex_psite(const complex_psite<D, P>& rhs)
- : super_(rhs),
- face_(rhs.face_), p_()
+ complex_psite<D, P>::complex_psite(const p_complex<D, P>& pc,
+ unsigned n, unsigned face_id)
+ : pc_(&pc),
+ face_(pc.cplx(), n, face_id)
{
+ update_();
}
template <unsigned D, typename P>
inline
- complex_psite<D, P>&
- complex_psite<D, P>::operator= (const complex_psite<D, P>& rhs)
+ bool
+ complex_psite<D, P>::is_valid() const
{
- if (&rhs == this)
- return *this;
- face_ = rhs.face_;
- return *this;
+// mln_invariant(!pc_ || pc_.cplx() == face_.cplx());
+ return face_.is_valid();
}
template <unsigned D, typename P>
inline
- bool
- complex_psite<D, P>::is_valid() const
+ void
+ complex_psite<D, P>::invalidate()
{
- return face_.is_valid();
+ return face_.invalidate();
}
template <unsigned D, typename P>
inline
- const complex_psite<D, P>&
- complex_psite<D, P>::to_psite() const
+ const p_complex<D, P>&
+ complex_psite<D, P>::site_set() const
{
- return *this;
+ mln_precondition(target_());
+ return *target_();
}
template <unsigned D, typename P>
inline
- const P&
- complex_psite<D, P>::to_point() const
+ const p_complex<D, P>*
+ complex_psite<D, P>::target_() const
{
- // FIXME: Dummy value.
- return p_;
+// mln_invariant(!pc_ || pc_.cplx() == face_.cplx());
+ return pc_;
}
template <unsigned D, typename P>
inline
- mln_coord(P)
- complex_psite<D, P>::operator[](unsigned i) const
+ void
+ complex_psite<D, P>::change_target(const p_complex<D, P>& new_target)
{
- mln_precondition(is_valid());
- return to_point()[i];
+ // Update both pc_ and face_.
+ pc_ = &new_target;
+ face_.set_cplx(new_target.cplx());
+ invalidate();
}
+ // FIXME: Write or extend a test to exercise this method (when the
+ // handling of P is done, i.e., when update_ is complete).
template <unsigned D, typename P>
inline
- any_face_handle<D>
- complex_psite<D, P>::face() const
+ const P&
+ complex_psite<D, P>::subj_()
{
- return face_;
+ // FIXME: Member p_ is not updated correctly yet; do not use this
+ // method for now.
+ abort();
+ return p_;
}
template <unsigned D, typename P>
inline
- const complex<D>&
- complex_psite<D, P>::cplx() const
+ any_face_handle<D>
+ complex_psite<D, P>::face() const
{
- return face_.cplx();
+ return face_;
}
template <unsigned D, typename P>
@@ -242,6 +310,17 @@ namespace mln
return face_.face_id();
}
+ template <unsigned D, typename P>
+ inline
+ void
+ complex_psite<D, P>::update_()
+ {
+ mln_precondition(is_valid());
+// mln_invariant(!pc_ || pc_.cplx() == face_.cplx());
+ // FIXME: Implement (update p_).
+ }
+
+
/*--------------.
| Comparisons. |
`--------------*/
@@ -251,19 +330,29 @@ namespace mln
operator==(const complex_psite<D, P>& lhs,
const complex_psite<D, P>& rhs)
{
- mln_precondition(&lhs.cplx() == &rhs.cplx());
+ mln_precondition(&lhs.site_set() == &rhs.site_set());
return lhs.face() == rhs.face();
}
template <unsigned D, typename P>
bool
+ operator!=(const complex_psite<D, P>& lhs,
+ const complex_psite<D, P>& rhs)
+ {
+ mln_precondition(&lhs.site_set() == &rhs.site_set());
+ return lhs.face() != rhs.face();
+ }
+
+ template <unsigned D, typename P>
+ bool
operator< (const complex_psite<D, P>& lhs,
const complex_psite<D, P>& rhs)
{
- mln_precondition(&lhs.cplx() == &rhs.cplx());
+ mln_precondition(&lhs.site_set() == &rhs.site_set());
return lhs.face() < rhs.face();
}
+
/*------------------.
| Pretty-printing. |
`------------------*/
@@ -278,7 +367,6 @@ namespace mln
# endif // ! MLN_INCLUDE_ONLY
-
} // end of mln
#endif // MLN_CORE_COMPLEX_PSITE_HH
--
1.6.0.1
1
0
* mln/core/site_set/p_faces.hh
(mln::internal::site_set_< p_faces<N, D, P> >): New properties.
(mln::internal::site_set_< p_faces<N, D, P> >::self_)
(mln::internal::site_set_< p_faces<N, D, P> >::super_)
(mln::internal::site_set_< p_faces<N, D, P> >::element_)
(mln::internal::site_set_< p_faces<N, D, P> >::piter):
New typedefs.
(mln::p_faces<N, D, P>::nsites): Change the return type of this
method to unsigned.
(mln::p_faces<N, D, P>::is_valid)
(mln::p_faces<N, D, P>::memory_size):
New methods.
(mln::p_faces<N, D, P>::bbox): Remove method.
(mln::p_faces<N, D, P>::bb_): Remove attribute.
(mln::p_faces<N, D, P>::p_faces)
(mln::p_faces<N, D, P>::has)
(mln::p_faces<N, D, P>::cplx() const):
Update methods.
(mln::p_faces<N, D, P>::cplx()):
New (mutable) accessor.
(operator==(const mln::p_faces<N,D,P>&, const mln::p_faces<N,D,P>&)):
New operator.
---
milena/ChangeLog | 27 +++++++
milena/mln/core/site_set/p_faces.hh | 131 ++++++++++++++++++++++++++--------
2 files changed, 127 insertions(+), 31 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 02ae1c6..8778cd6 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,32 @@
2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+ Update site set mln::p_faces
+
+ * mln/core/site_set/p_faces.hh
+ (mln::internal::site_set_< p_faces<N, D, P> >): New properties.
+ (mln::internal::site_set_< p_faces<N, D, P> >::self_)
+ (mln::internal::site_set_< p_faces<N, D, P> >::super_)
+ (mln::internal::site_set_< p_faces<N, D, P> >::element_)
+ (mln::internal::site_set_< p_faces<N, D, P> >::piter):
+ New typedefs.
+ (mln::p_faces<N, D, P>::nsites): Change the return type of this
+ method to unsigned.
+ (mln::p_faces<N, D, P>::is_valid)
+ (mln::p_faces<N, D, P>::memory_size):
+ New methods.
+ (mln::p_faces<N, D, P>::bbox): Remove method.
+ (mln::p_faces<N, D, P>::bb_): Remove attribute.
+ (mln::p_faces<N, D, P>::p_faces)
+ (mln::p_faces<N, D, P>::has)
+ (mln::p_faces<N, D, P>::cplx() const):
+ Update methods.
+ (mln::p_faces<N, D, P>::cplx()):
+ New (mutable) accessor.
+ (operator==(const mln::p_faces<N,D,P>&, const mln::p_faces<N,D,P>&)):
+ New operator.
+
+2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+
Update site set mln::p_complex.
* mln/core/site_set/p_complex.hh (mln::p_complex<D, P>): Inherit
diff --git a/milena/mln/core/site_set/p_faces.hh b/milena/mln/core/site_set/p_faces.hh
index f204471..025023d 100644
--- a/milena/mln/core/site_set/p_faces.hh
+++ b/milena/mln/core/site_set/p_faces.hh
@@ -44,14 +44,28 @@
namespace mln
{
- /* FIXME: For compatibility reasons with mln::Point_Set, a point
- type \P is attached to this complex-based pset (but it is not
- used actually). We should either:
+ // Forward declarations.
+ template <unsigned N, unsigned D, typename P> class p_faces;
+ // FIXME: Enable when available.
+#if 0
+ template <unsigned N, unsigned D, typename P> class p_faces_fwd_piter_;
+ template <unsigned N, unsigned D, typename P> class p_faces_bkd_piter_;
+#endif
+
+
+ namespace trait
+ {
+ template <unsigned N, unsigned D, typename P>
+ struct site_set_< p_faces<N, D, P> >
+ {
+ typedef trait::site_set::nsites::known nsites;
+ // FIXME: Depends on P!
+ typedef trait::site_set::bbox::unknown bbox;
+ typedef trait::site_set::contents::fixed contents;
+ typedef trait::site_set::arity::unique arity;
+ };
+ } // end of namespace mln::trait
- - use it, and make it mandatory (good solution for the moment);
- - use it, and make it optional (better solution, but implies
- changes in mln::Point_Set;
- - remove it (easy and bad solution). */
/// A complex psite set based on a the \N-faces of a complex of
/// dimension \p D (a \p D-complex).
@@ -60,6 +74,9 @@ namespace mln
: public internal::site_set_base_< faces_psite<N, D, P>,
p_faces<N, D, P> >
{
+ typedef p_faces<N, D, P> self_;
+ typedef internal::site_set_base_< faces_psite<N, D, P>, self_ > super_;
+
/// \brief Construct a complex psite set from a complex.
///
/// \param gr The complex upon which the complex psite set is built.
@@ -68,35 +85,71 @@ namespace mln
/// still valid after the initial complex has been removed.
p_faces (const complex<D>& cplx);
+ /// Associated types.
+ /// \{
+ /// Element associated type.
+ typedef mln_site(super_) element;
+
/// Point_Site associated type.
typedef faces_psite<N, D, P> psite;
// FIXME: Fake.
+ /// Forward Site_Iterator associated type.
typedef void fwd_piter;
+
+ // FIXME: Fake.
+ /// Backward Site_Iterator associated type.
typedef void bkd_piter;
- /// \brief Return The number of points (sites) of the set, i.e., the
- /// number of \em faces.
+ /// Site_Iterator associated type.
+ typedef fwd_piter piter;
+ /// \}
+
+ /// \brief Return The number of sites of the set, i.e., the number
+ /// of \em faces.
///
- /// Required by the mln::Point_Set concept.
- std::size_t nsites() const;
+ /// (Required by the mln::Site_Set concept, since the property
+ /// trait::site_set::nsites::known of this site set is set to
+ /// `known'.)
+ /* FIXME: Return type should be std::size_t (see
+ mln/core/concept/site_set.hh). */
+ unsigned nsites() const;
/// Return The number of faces in the complex.
std::size_t nfaces() const;
- /// Give the exact bounding box.
- const box<P>& bbox() const;
+ // FIXME: Add nfaces(unsigned) routines? Yes, if this can
+ // simplify (and lighten) the implementation of piters, psites,
+ // etc.
+
+ /// Is this site set valid?
+ bool is_valid() const;
bool has(const psite& p) const;
- /// Return the complex associated to the p_faces domain.
- const complex<D>& cplx() const;
+ // FIXME: Dummy.
+ std::size_t memory_size() const;
+
+ /// Accessors.
+ /// \{
+ /// Return the complex associated to the p_faces domain (const
+ /// version).
+ /* FIXME: Move back the const qualifier on this return type (see
+ comment below on cplx_). */
+ complex<D>& cplx() const;
+ /// Return the complex associated to the p_faces domain (mutable
+ /// version).
+ complex<D>& cplx();
+ /// \}
private:
/// The complex on which this pset is built.
util::tracked_ptr< complex<D> > cplx_;
- // FIXME: Remove as soon as bbox become optional.
- box<P> bb_;
+
+ template <unsigned D_, unsigned N_, typename P_>
+ friend
+ bool operator==(const p_faces<D_, N_, P_>& lhs,
+ const p_faces<D_, N_, P_>& rhs);
};
@@ -132,17 +185,11 @@ namespace mln
{
// Ensure N is compatible with D.
metal::bool_< N <= D >::check();
-
- // FIXME: Dummy initialization.
- accu::bbox<P> a;
- for (unsigned i = 0; i < nsites(); ++i)
- a.take(P());
- bb_ = a.to_result();
}
template <unsigned N, unsigned D, typename P>
inline
- std::size_t
+ unsigned
p_faces<N, D, P>::nsites() const
{
return nfaces();
@@ -158,11 +205,11 @@ namespace mln
template <unsigned N, unsigned D, typename P>
inline
- const box<P>&
- p_faces<N, D, P>::bbox() const
+ bool
+ p_faces<N, D, P>::is_valid() const
{
- // FIXME: Dummy value.
- return bb_;
+ // FIXME: Might be too low-level, again.
+ return (cplx_.ptr_);
}
template <unsigned N, unsigned D, typename P>
@@ -170,22 +217,44 @@ namespace mln
bool
p_faces<N, D, P>::has(const psite& p) const
{
+ mln_precondition(is_valid());
return
// Check whether P's complex is compatible with this pset's complex.
- &p.cplx() == &cplx() &&
+ (p.site_set() == *this) &&
// Check whether the complex has the face associated to P.
- p.face().is_valid();
+ (p.is_valid());
}
+ template <unsigned N, unsigned D, typename P>
+ inline
+ std::size_t
+ p_faces<N, D, P>::memory_size() const
+ {
+ // FIXME: Dummy; implement (see other site sets).
+ abort();
+ return 0;
+ }
template <unsigned N, unsigned D, typename P>
- const complex<D>&
+ complex<D>&
p_faces<N, D, P>::cplx() const
{
mln_precondition(cplx_);
return *cplx_.ptr_;
}
+ template <unsigned N, unsigned D, typename P>
+ complex<D>&
+ p_faces<N, D, P>::cplx()
+ {
+ mln_precondition(cplx_);
+ return *cplx_.ptr_;
+ }
+
+
+ /*--------------.
+ | Comparisons. |
+ `--------------*/
template <unsigned N, unsigned D, typename P>
bool
--
1.6.0.1
1
0
* mln/core/site_set/p_complex.hh (mln::p_complex<D, P>): Inherit
from internal::site_set_base_.
(mln::p_complex<D, P>::self_)
(mln::p_complex<D, P>::super_)
(mln::p_complex<D, P>::element_)
(mln::p_complex<D, P>::piter):
New typedefs.
(mln::p_complex<D, P>::nsites): Change the return type of this
method to unsigned.
(mln::p_complex<D, P>::is_valid)
(mln::p_complex<D, P>::memory_size):
New methods.
(mln::p_complex<D, P>::bbox): Remove method.
(mln::p_complex<D, P>::bb_): Remove attribute.
(mln::p_complex<D, P>::p_complex)
(mln::p_complex<D, P>::has)
(mln::p_complex<D, P>::cplx):
Update methods.
(operator==(const mln::p_complex<D, P>&, const mln::p_complex<D, P>&)):
New operator.
---
milena/ChangeLog | 25 ++++++
milena/mln/core/site_set/p_complex.hh | 151 ++++++++++++++++++++++++---------
2 files changed, 134 insertions(+), 42 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 1636331..02ae1c6 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,30 @@
2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+ Update site set mln::p_complex.
+
+ * mln/core/site_set/p_complex.hh (mln::p_complex<D, P>): Inherit
+ from internal::site_set_base_.
+ (mln::p_complex<D, P>::self_)
+ (mln::p_complex<D, P>::super_)
+ (mln::p_complex<D, P>::element_)
+ (mln::p_complex<D, P>::piter):
+ New typedefs.
+ (mln::p_complex<D, P>::nsites): Change the return type of this
+ method to unsigned.
+ (mln::p_complex<D, P>::is_valid)
+ (mln::p_complex<D, P>::memory_size):
+ New methods.
+ (mln::p_complex<D, P>::bbox): Remove method.
+ (mln::p_complex<D, P>::bb_): Remove attribute.
+ (mln::p_complex<D, P>::p_complex)
+ (mln::p_complex<D, P>::has)
+ (mln::p_complex<D, P>::cplx):
+ Update methods.
+ (operator==(const mln::p_complex<D, P>&, const mln::p_complex<D, P>&)):
+ New operator.
+
+2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+
Complete the overhaul of line graph images.
* mln/core/image/line_graph_image.hh:
diff --git a/milena/mln/core/site_set/p_complex.hh b/milena/mln/core/site_set/p_complex.hh
index 840ae40..6065df4 100644
--- a/milena/mln/core/site_set/p_complex.hh
+++ b/milena/mln/core/site_set/p_complex.hh
@@ -33,7 +33,6 @@
# include <mln/core/internal/site_set_base.hh>
-# include <mln/accu/bbox.hh>
# include <mln/util/tracked_ptr.hh>
# include <mln/core/complex.hh>
@@ -49,24 +48,53 @@ namespace mln
template <unsigned D, typename P> class p_complex_bkd_piter_;
- // FIXME: Rename as p_faces?
+ namespace trait
+ {
+ template <unsigned D, typename P>
+ struct site_set_< p_complex<D, P> >
+ {
+ typedef trait::site_set::nsites::known nsites;
+ // FIXME: Depends on P!
+ typedef trait::site_set::bbox::unknown bbox;
+ typedef trait::site_set::contents::fixed contents;
+ typedef trait::site_set::arity::unique arity;
+ };
+ } // end of namespace mln::trait
+
+
+ /* FIXME: We should decide was P represents:
+
+ - a unique site type for all faces of all dimensions?
+ (Acceptable for a first implementation -- the one currently
+ chosen.)
+
+ - the site type associated to 0-faces only (site types of n-faces
+ with n > 1 will be deduced from this one)?
+ (Better, but not really flexible.)
- /* FIXME: For compatibility reasons with mln::Point_Set, a point
- type \P is attached to this complex-based pset (but it is not
- used actually). We should either:
+ - a type list of the site types associated faces of each
+ dimensions, e.g.
- - use it, and make it mandatory (good solution for the moment);
- - use it, and make it optional (better solution, but implies
- changes in mln::Point_Set;
- - remove it (easy and bad solution). */
+ mln_type_list(point2d,
+ mln_type_list(site_pair<point2d>,
+ mln_type_list(site_set<point2d>, // or site_triplet<point2d>
+ mln_empty_list)))
+
+ for a 2-complex?
+ (The best solution so far, but requires more work.) */
+
+ /* FIXME: Aggregate site data (location). */
/// A complex psite set based on a the \N-faces of a complex of
/// dimension \p D (a \p D-complex).
template <unsigned D, typename P>
- struct p_complex
- : public internal::site_set_base_< complex_psite<D, P>,
- p_complex<D, P> >
+ class p_complex
+ : public internal::site_set_base_< complex_psite<D, P>, p_complex<D, P> >
{
+ typedef p_complex<D, P> self_;
+ typedef internal::site_set_base_< complex_psite<D, P>, self_ > super_;
+
+ public:
/// \brief Construct a complex psite set from a complex.
///
/// \param gr The complex upon which the complex psite set is built.
@@ -75,27 +103,50 @@ namespace mln
/// still valid after the initial complex has been removed.
p_complex (const complex<D>& cplx);
+ /// Associated types.
+ /// \{
+ /// Element associated type.
+ typedef mln_site(super_) element;
+
/// Point_Site associated type.
typedef complex_psite<D, P> psite;
- /// Forward Point_Iterator associated type.
+ /// Forward Site_Iterator associated type.
typedef p_complex_fwd_piter_<D, P> fwd_piter;
- /// Backward Point_Iterator associated type.
+
+ /// Backward Site_Iterator associated type.
typedef p_complex_bkd_piter_<D, P> bkd_piter;
- /// \brief Return The number of points (sites) of the set, i.e., the
- /// number of \em faces.
+ /// Site_Iterator associated type.
+ typedef fwd_piter piter;
+ /// \}
+
+ /// \brief Return The number of sites of the set, i.e., the number
+ /// of \em faces.
///
- /// Required by the mln::Point_Set concept.
- std::size_t nsites() const;
+ /// (Required by the mln::Site_Set concept, since the property
+ /// trait::site_set::nsites::known of this site set is set to
+ /// `known'.)
+ /* FIXME: Return type should be std::size_t (see
+ mln/core/concept/site_set.hh). */
+ unsigned nsites() const;
/// Return The number of faces in the complex.
std::size_t nfaces() const;
- // FIXME: Add nfaces(unsigned) routines?
+ // FIXME: Add nfaces(unsigned) routines? Yes, if this can
+ // simplify (and lighten) the implementation of piters, psites,
+ // etc.
+ /// Is this site set valid?
+ bool is_valid() const;
+
+ /// Does this site set has \a p?
bool has(const psite& p) const;
+ // FIXME: Dummy.
+ std::size_t memory_size() const;
+
/// Accessors.
/// \{
/// Return the complex associated to the p_complex domain (const
@@ -106,9 +157,6 @@ namespace mln
/// Return the complex associated to the p_complex domain (mutable
/// version).
complex<D>& cplx();
-
- /// Give the exact bounding box.
- const box<P>& bbox() const;
/// \}
private:
@@ -129,8 +177,13 @@ namespace mln
similar to graphs, where vertex and edge handles (named `id's)
are not tied to a specific graph. */
mutable util::tracked_ptr< complex<D> > cplx_;
- // FIXME: Remove as soon as bbox become optional.
- box<P> bb_;
+
+ // FIXME: Remove as soon as the tracked_ptr is move into the
+ // complex itself.
+ template <unsigned D_, typename P_>
+ friend
+ bool operator==(const p_complex<D_, P_>& lhs,
+ const p_complex<D_, P_>& rhs);
};
@@ -164,16 +217,11 @@ namespace mln
// Create a deep, managed copy of CPLX.
: cplx_(new complex<D>(cplx))
{
- // FIXME: Dummy initialization.
- accu::bbox<P> a;
- for (unsigned i = 0; i < nsites(); ++i)
- a.take(P());
- bb_ = a.to_result();
}
template <unsigned D, typename P>
inline
- std::size_t
+ unsigned
p_complex<D, P>::nsites() const
{
return nfaces();
@@ -190,20 +238,40 @@ namespace mln
template <unsigned D, typename P>
inline
bool
+ p_complex<D, P>::is_valid() const
+ {
+ // FIXME: Might be too low-level, again.
+ return (cplx_.ptr_);
+ }
+
+ template <unsigned D, typename P>
+ inline
+ bool
p_complex<D, P>::has(const psite& p) const
{
+ mln_precondition(is_valid());
return
// Check whether P's complex is compatible with this pset's complex.
- &p.cplx() == &cplx() &&
+ (p.site_set() == *this) &&
// Check whether the complex has the face associated to P.
- p.face().is_valid();
+ (p.is_valid());
+ }
+
+ template <unsigned D, typename P>
+ inline
+ std::size_t
+ p_complex<D, P>::memory_size() const
+ {
+ // FIXME: Dummy; implement (see other site sets).
+ abort();
+ return 0;
}
template <unsigned D, typename P>
complex<D>&
p_complex<D, P>::cplx() const
{
- mln_precondition(cplx_);
+ mln_precondition(is_valid());
return *cplx_.ptr_;
}
@@ -211,24 +279,23 @@ namespace mln
complex<D>&
p_complex<D, P>::cplx()
{
- mln_precondition(cplx_);
+ mln_precondition(is_valid());
return *cplx_.ptr_;
}
- template <unsigned D, typename P>
- inline
- const box<P>&
- p_complex<D, P>::bbox() const
- {
- // FIXME: Dummy value.
- return bb_;
- }
+ /*--------------.
+ | Comparisons. |
+ `--------------*/
template <unsigned D, typename P>
bool
operator==(const p_complex<D, P>& lhs, const p_complex<D, P>& rhs)
{
+ /* FIXME: We should not rely on pointer equality here, as graph
+ will soon become shells using (shared) tracked pointers to
+ actual data. So, delegate the equality test to the graphs
+ themselves. */
return lhs.cplx_.ptr_ == rhs.cplx_.ptr_;
}
--
1.6.0.1
1
0
* mln/core/image/line_graph_image.hh:
(mln::line_graph_image<P, V>): Fix access to members.
(mln::line_graph_image<P, V>::super_): Remove typedef.
* mln/core/site_set/p_line_graph.hh: Update documentation.
(mln::p_line_graph<P>::gr() const)
(mln::p_line_graph<P>::gr()):
New accessors.
(mln::p_line_graph<P>::bbox): Remove method.
(mln::p_line_graph<P>::bb_): Remove attributes.
(mln::p_line_graph<P>::p_line_graph<P>): Ajust ctor.
(mln::p_line_graph<P>::has): Ensure the site set is valid.
(mln::p_line_graph<P>::memory_size): Temporarily prevent the
method from being executed.
* mln/core/image/line_graph_psite.hh: Aesthetic changes.
(mln::line_graph_psite<P>::super_): Remove typedef.
(mln::line_graph_psite<P>::line_graph_psite): Invalidate the psite
in the default ctor.
(mln::line_graph_psite<P>::site_set): Use target_() instead of
manipulating plg_ directly.
* mln/core/site_set/p_line_graph_piter.hh: Update documentation.
(p_line_graph_fwd_piter_<P>::p_line_graph_fwd_piter_)
(p_line_graph_bkd_piter_<P>::p_line_graph_bkd_piter_):
Add postconditions.
---
milena/ChangeLog | 28 ++++++++
milena/mln/core/image/line_graph_image.hh | 20 +++---
milena/mln/core/image/line_graph_psite.hh | 80 +++++++++++------------
milena/mln/core/site_set/p_line_graph.hh | 84 ++++++++++++++----------
milena/mln/core/site_set/p_line_graph_piter.hh | 15 +++-
5 files changed, 136 insertions(+), 91 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 4fffc21..1636331 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,31 @@
+2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+
+ Complete the overhaul of line graph images.
+
+ * mln/core/image/line_graph_image.hh:
+ (mln::line_graph_image<P, V>): Fix access to members.
+ (mln::line_graph_image<P, V>::super_): Remove typedef.
+ * mln/core/site_set/p_line_graph.hh: Update documentation.
+ (mln::p_line_graph<P>::gr() const)
+ (mln::p_line_graph<P>::gr()):
+ New accessors.
+ (mln::p_line_graph<P>::bbox): Remove method.
+ (mln::p_line_graph<P>::bb_): Remove attributes.
+ (mln::p_line_graph<P>::p_line_graph<P>): Ajust ctor.
+ (mln::p_line_graph<P>::has): Ensure the site set is valid.
+ (mln::p_line_graph<P>::memory_size): Temporarily prevent the
+ method from being executed.
+ * mln/core/image/line_graph_psite.hh: Aesthetic changes.
+ (mln::line_graph_psite<P>::super_): Remove typedef.
+ (mln::line_graph_psite<P>::line_graph_psite): Invalidate the psite
+ in the default ctor.
+ (mln::line_graph_psite<P>::site_set): Use target_() instead of
+ manipulating plg_ directly.
+ * mln/core/site_set/p_line_graph_piter.hh: Update documentation.
+ (p_line_graph_fwd_piter_<P>::p_line_graph_fwd_piter_)
+ (p_line_graph_bkd_piter_<P>::p_line_graph_bkd_piter_):
+ Add postconditions.
+
2008-09-22 Nicolas Ballas <ballas(a)lrde.epita.fr>
Update median"".
diff --git a/milena/mln/core/image/line_graph_image.hh b/milena/mln/core/image/line_graph_image.hh
index b06b6c9..6b9b7ba 100644
--- a/milena/mln/core/image/line_graph_image.hh
+++ b/milena/mln/core/image/line_graph_image.hh
@@ -31,6 +31,8 @@
/// \file mln/core/image/line_graph_image.hh
/// \brief Definition of a line graph-based image.
+# include <vector>
+
# include <mln/trait/images.hh>
# include <mln/core/internal/image_primary.hh>
@@ -38,7 +40,6 @@
# include <mln/core/site_set/p_line_graph.hh>
# include <mln/core/image/line_graph_psite.hh>
# include <mln/value/set.hh>
-# include <vector>
/* FIXME: This class shares a lot with graph_image. Factor as much as
possible. */
@@ -57,7 +58,7 @@
namespace mln
{
- // Fwd decl.
+ // Forward declaration.
template <typename P, typename V> struct line_graph_image;
namespace internal
@@ -104,11 +105,9 @@ namespace mln
// FIXME: Likewise.
typedef typename trait::image::space_from_point<P>::ret dimension;
- // extended domain
+ // Extended domain
typedef trait::image::ext_domain::none ext_domain;
- // FIXME: Is that right?
typedef trait::image::ext_value::irrelevant ext_value;
- // FIXME: Is that right?
typedef trait::image::ext_io::irrelevant ext_io;
};
@@ -119,13 +118,11 @@ namespace mln
///
/// Values are stored on the edges of the graph.
template <typename P, typename V>
- struct line_graph_image :
- public internal::image_primary<V, p_line_graph<P>, line_graph_image<P, V> >
+ class line_graph_image
+ : public internal::image_primary< V, p_line_graph<P>,
+ line_graph_image<P, V> >
{
- /// Super type.
- typedef mln::internal::image_base< V, p_line_graph<P>,
- line_graph_image<P, V> > super_;
-
+ public:
/// Value associated type.
typedef V value;
@@ -143,6 +140,7 @@ namespace mln
/// Skeleton.
typedef line_graph_image< tag::psite_<P>, tag::value_<V> > skeleton;
+ public:
/// Constructors.
/// \{
line_graph_image();
diff --git a/milena/mln/core/image/line_graph_psite.hh b/milena/mln/core/image/line_graph_psite.hh
index 6e66436..869a5cf 100644
--- a/milena/mln/core/image/line_graph_psite.hh
+++ b/milena/mln/core/image/line_graph_psite.hh
@@ -39,6 +39,9 @@
/* FIXME: This class shares a lot with graph_psite. Factor as much as
possible. */
+// FIXME: Rename line_graph_psite as p_line_graph_psite, and move this
+// to core/site_set.
+
namespace mln
{
@@ -47,8 +50,6 @@ namespace mln
template <typename P> class p_line_graph;
template <typename P> class line_graph_psite;
- // FIXME: Rename as line_graph_psite as p_line_graph_psite.
-
/// \brief Point site associated to a mln::line_graph_image.
///
/// \arg \p P The type of the site.
@@ -58,7 +59,6 @@ namespace mln
line_graph_psite<P> >
{
typedef line_graph_psite<P> self_;
- typedef internal::pseudo_site_base_< P, self_ > super_;
public:
// This associated type is important to know that this particular
@@ -191,12 +191,14 @@ namespace mln
line_graph_psite<P>::line_graph_psite()
: plg_(0)
{
+ invalidate();
}
template <typename P>
inline
line_graph_psite<P>::line_graph_psite(const p_line_graph<P>& plg,
util::edge_id id)
+ // FIXME: Use change_target instead.
: plg_(&plg),
id_(id)
{
@@ -205,11 +207,33 @@ namespace mln
template <typename P>
inline
+ bool
+ line_graph_psite<P>::is_valid() const
+ {
+ /* FIXME: Instead of `plg_->gr_->nedges()', we should have
+ something like `run_->has_edge_id(id_)' (see the implementation of
+ p_run_psite. */
+ return plg_ && id_ < plg_->gr_->nedges();
+ }
+
+ template <typename P>
+ inline
+ void
+ line_graph_psite<P>::invalidate()
+ {
+ /* FIXME: Instead of `plg_->gr_->nedges()', we should have
+ something like `run_->has_edge_id(id_)' (see the implementation of
+ p_run_psite. */
+ id_ = plg_->gr_->nedges();
+ }
+
+ template <typename P>
+ inline
const p_line_graph<P>&
line_graph_psite<P>::site_set() const
{
- mln_precondition(plg_);
- return *plg_;
+ mln_precondition(target_());
+ return *target_();
}
template <typename P>
@@ -225,45 +249,19 @@ namespace mln
void
line_graph_psite<P>::change_target(const p_line_graph<P>& new_target)
{
- plg_ = & new_target;
+ plg_ = &new_target;
invalidate();
}
+ // FIXME: Write or extend a test to exercise this method.
template <typename P>
inline
const site_pair<P>&
line_graph_psite<P>::subj_()
{
- // FIXME: p_ is not properly updated yet; we shouldn't call this
- // method yet.
- abort();
return p_;
}
-
- template <typename P>
- inline
- bool
- line_graph_psite<P>::is_valid() const
- {
- /* FIXME: Instead of `plg_->gr_->nedges()', we should have
- something like `run_->has_edge_id(id_)' (see the implementation of
- p_run_psite. */
- return plg_ && id_ < plg_->gr_->nedges();
- }
-
- template <typename P>
- inline
- void
- line_graph_psite<P>::invalidate()
- {
- /* FIXME: Instead of `plg_->gr_->nedges()', we should have
- something like `run_->has_edge_id(id_)' (see the implementation of
- p_run_psite. */
- id_ = plg_->gr_->nedges();
- }
-
-
template <typename P>
inline
util::edge_id
@@ -307,7 +305,7 @@ namespace mln
P
line_graph_psite<P>::first() const
{
- mln_assertion(is_valid());
+ mln_precondition(is_valid());
// FIXME: Too low-level.
return plg_->gr_->vertex_data(first_id());
}
@@ -317,7 +315,7 @@ namespace mln
P
line_graph_psite<P>::second() const
{
- mln_assertion(is_valid());
+ mln_precondition(is_valid());
// FIXME: Too low-level.
return plg_->gr_->vertex_data(second_id());
}
@@ -327,7 +325,7 @@ namespace mln
util::vertex_id
line_graph_psite<P>::first_id() const
{
- mln_assertion(is_valid());
+ mln_precondition(is_valid());
// FIXME: Too low-level.
return plg_->gr_->edge(id_).v1();
}
@@ -337,7 +335,7 @@ namespace mln
util::vertex_id
line_graph_psite<P>::second_id() const
{
- mln_assertion(is_valid());
+ mln_precondition(is_valid());
// FIXME: Too low-level.
return plg_->gr_->edge(id_).v2();
}
@@ -348,7 +346,7 @@ namespace mln
void
line_graph_psite<P>::update_()
{
- mln_assertion(is_valid());
+ mln_precondition(is_valid());
p_.pair_.change_both(first(), second());
}
@@ -361,7 +359,7 @@ namespace mln
bool
operator==(const line_graph_psite<P>& lhs, const line_graph_psite<P>& rhs)
{
- mln_assertion(lhs.target_() == rhs.target_());
+ mln_precondition(lhs.target_() == rhs.target_());
return lhs.edge_id() == rhs.edge_id();
}
@@ -369,7 +367,7 @@ namespace mln
bool
operator!=(const line_graph_psite<P>& lhs, const line_graph_psite<P>& rhs)
{
- mln_assertion(lhs.target_() == rhs.target_());
+ mln_precondition(lhs.target_() == rhs.target_());
return lhs.edge_id() != rhs.edge_id();
}
@@ -377,7 +375,7 @@ namespace mln
bool
operator< (const line_graph_psite<P>& lhs, const line_graph_psite<P>& rhs)
{
- mln_assertion(lhs.target_() == rhs.target_());
+ mln_precondition(lhs.target_() == rhs.target_());
return lhs.edge_id() < rhs.edge_id();
}
diff --git a/milena/mln/core/site_set/p_line_graph.hh b/milena/mln/core/site_set/p_line_graph.hh
index 548b9e2..96b2c93 100644
--- a/milena/mln/core/site_set/p_line_graph.hh
+++ b/milena/mln/core/site_set/p_line_graph.hh
@@ -28,24 +28,23 @@
#ifndef MLN_CORE_SITE_SET_P_LINE_GRAPH_HH
# define MLN_CORE_SITE_SET_P_LINE_GRAPH_HH
-# include <mln/util/site_pair.hh>
+/// \file mln/core/site_set/p_line_graph.hh
+/// \brief Definition of a point set based on line graph.
# include <mln/core/concept/point_site.hh>
# include <mln/core/internal/site_set_base.hh>
-# include <mln/accu/bbox.hh>
# include <mln/util/graph.hh>
# include <mln/util/tracked_ptr.hh>
+# include <mln/util/site_pair.hh>
# include <mln/core/image/line_graph_psite.hh>
# include <mln/core/site_set/p_line_graph_piter.hh>
/* FIXME: This class shares a lot with p_graph. Factor as much as
possible. */
-// FIXME: We should move the `adjacent_or_equal method' from
-// iterators into this class.
+/* FIXME: We should move the `adjacent_or_equal method' from iterators
+ into this class. */
-/// \file mln/core/site_set/p_line_graph.hh
-/// \brief Definition of a point set based on line graph.
namespace mln
{
@@ -53,6 +52,7 @@ namespace mln
// Forward declaration.
template<typename P> struct p_line_graph;
+
namespace trait
{
template <typename P>
@@ -66,9 +66,6 @@ namespace mln
};
} // end of namespace mln::trait
- /* FIXME: Contray to, e.g., p_array, the sole parameter P of
- p_line_graph is expected to be a point, not a psite!! We should
- have a uniform scheme for point site sets. */
template<typename P>
struct p_line_graph
@@ -101,15 +98,16 @@ namespace mln
/// Backward Site_Iterator associated type.
typedef p_line_graph_bkd_piter_<P> bkd_piter;
- /// Forward Site_Iterator associated type.
+ /// Site_Iterator associated type.
typedef fwd_piter piter;
/// \}
- /// \brief Return The number of points (sites) of the set, i.e.,
- /// the number of \em edges, since this is a point set based on a
- /// line graph.
+ /// \brief Return The number of sites of the set, i.e., the number
+ /// of \em edges.
///
- /// Required by the mln::Point_Set concept.
+ /// (Required by the mln::Site_Set concept, since the property
+ /// trait::site_set::nsites::known of this site set is set to
+ /// `known'.)
/* FIXME: Return type should be std::size_t (see
mln/core/concept/site_set.hh). */
unsigned nsites() const;
@@ -119,9 +117,6 @@ namespace mln
/// Return The number of edges in the graph.
std::size_t nedges() const;
- /// Give the exact bounding box.
- const box<P>& bbox() const;
-
/// Is this site set valid?
bool is_valid() const;
@@ -131,6 +126,19 @@ namespace mln
// FIXME: Dummy.
std::size_t memory_size() const;
+ /// Accessors.
+ /// \{
+ /// Return the graph associated to the p_graph domain (const
+ /// version)
+ const graph& gr() const;
+ /// Return the graph associated to the p_graph domain (mutable
+ /// version).
+ graph& gr();
+ /// \}
+
+ // FIXME: These would probably be no longer needed as soon as
+ // iterators on graphs are available.
+
/// Adjacency tests.
/// \{
/// Return true if the psites \a lhs and \a rhs are adjacent.
@@ -148,12 +156,8 @@ namespace mln
/// \}
// FIXME: Should be private.
+ /// The graph on which the pset is built.
util::tracked_ptr<graph> gr_;
- // FIXME: (Roland) Is it really useful/needed?
- /* 2007-12-19: It seems so, since graph_image must implement a
- method named bbox(). Now the question is: should each image
- type have a bounding box? */
- box<P> bb_;
};
@@ -182,6 +186,7 @@ namespace mln
operator<=(const p_line_graph<P>& lhs, const p_line_graph<P>& rhs);
+
# ifndef MLN_INCLUDE_ONLY
template <typename P>
@@ -190,10 +195,6 @@ namespace mln
// Create a deep, managed copy of GR.
: gr_ (new util::graph<P>(gr))
{
- accu::bbox<P> a;
- for (unsigned i = 0; i < nvertices(); ++i)
- a.take(gr_->vertex_data(i));
- bb_ = a.to_result();
}
template <typename P>
@@ -222,14 +223,6 @@ namespace mln
template <typename P>
inline
- const box<P>&
- p_line_graph<P>::bbox() const
- {
- return bb_;
- }
-
- template <typename P>
- inline
bool
p_line_graph<P>::is_valid() const
{
@@ -242,6 +235,7 @@ namespace mln
bool
p_line_graph<P>::has(const psite& p) const
{
+ mln_precondition(is_valid());
return
// Check whether P is compatible with this psite set.
(p.target_() == this) &&
@@ -254,10 +248,26 @@ namespace mln
std::size_t
p_line_graph<P>::memory_size() const
{
- // FIXME: Dummy
+ // FIXME: Dummy; implement (see other site sets).
+ abort();
return 0;
}
+ template <typename P>
+ const util::graph<P>&
+ p_graph<P>::gr() const
+ {
+ mln_precondition(is_valid());
+ return *gr_.ptr_;
+ }
+
+ template <typename P>
+ util::graph<P>&
+ p_graph<P>::gr()
+ {
+ mln_precondition(is_valid());
+ return *gr_.ptr_;
+ }
template <typename P>
inline
@@ -322,6 +332,10 @@ namespace mln
}
+ /*--------------.
+ | Comparisons. |
+ `--------------*/
+
template <typename P>
bool
operator==(const p_line_graph<P>& lhs, const p_line_graph<P>& rhs)
diff --git a/milena/mln/core/site_set/p_line_graph_piter.hh b/milena/mln/core/site_set/p_line_graph_piter.hh
index 4971075..90b8e3c 100644
--- a/milena/mln/core/site_set/p_line_graph_piter.hh
+++ b/milena/mln/core/site_set/p_line_graph_piter.hh
@@ -28,16 +28,18 @@
#ifndef MLN_CORE_SITE_SET_P_LINE_GRAPH_PITER_HH
# define MLN_CORE_SITE_SET_P_LINE_GRAPH_PITER_HH
+/// \file mln/core/site_set/p_line_graph_piter.hh
+/// \brief Definition of point iterators on line graph-based site set.
+
# include <mln/core/internal/site_iterator_base.hh>
# include <mln/core/site_set/p_line_graph.hh>
# include <mln/core/image/line_graph_psite.hh>
-/// \file mln/core/site_set/p_line_graph_piter.hh
-/// \brief Definition of point iterator on line graph-based point set.
namespace mln
{
- // Fwd decls.
+
+ // Forward declarations.
template <typename P> class p_line_graph;
template <typename P> class line_graph_psite;
@@ -121,11 +123,12 @@ namespace mln
/// \}
protected:
+ /// The psite corresponding to this iterator.
using super_::p_;
};
- /// Print a mln::p_line_graph_bkd_piter_<P>.
+ /// Print an mln::p_line_graph_bkd_piter_<P>.
template <typename P>
inline
std::ostream&
@@ -142,6 +145,7 @@ namespace mln
inline
p_line_graph_fwd_piter_<P>::p_line_graph_fwd_piter_()
{
+ mln_postcondition(!is_valid());
}
template <typename P>
@@ -149,6 +153,7 @@ namespace mln
p_line_graph_fwd_piter_<P>::p_line_graph_fwd_piter_(const p_line_graph<P>& plg)
{
this->change_target(plg);
+ mln_postcondition(!is_valid());
}
template <typename P>
@@ -201,6 +206,7 @@ namespace mln
inline
p_line_graph_bkd_piter_<P>::p_line_graph_bkd_piter_()
{
+ mln_postcondition(!is_valid());
}
template <typename P>
@@ -208,6 +214,7 @@ namespace mln
p_line_graph_bkd_piter_<P>::p_line_graph_bkd_piter_(const p_line_graph<P>& plg)
{
this->change_target(plg);
+ mln_postcondition(!is_valid());
}
template <typename P>
--
1.6.0.1
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
Update median"".
* tests/level/median_.cc: New.
* mln/level/median.hh: .
* mln/win/rectangle2d.hh: .
mln/level/median.hh | 15 ++++++------
mln/win/rectangle2d.hh | 9 ++++---
tests/level/median_.cc | 59 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 73 insertions(+), 10 deletions(-)
Index: tests/level/median_.cc
--- tests/level/median_.cc (revision 0)
+++ tests/level/median_.cc (revision 0)
@@ -0,0 +1,59 @@
+// Copyright (C) 2007, 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. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/level/median.cc
+ *
+ * \brief Test on mln::level::median.
+ */
+
+#include <mln/core/image/image2d.hh>
+#include <mln/win/rectangle2d.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/level/median.hh>
+
+#include "tests/data.hh"
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ win::rectangle2d rect(5, 5);
+ border::thickness = 6;
+
+ image2d<int_u8> lena;
+ io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+ image2d<int_u8> out(lena.domain());
+
+ level::impl::median_(lena, rect, out);
+ io::pgm::save(out, "out.pgm");
+}
Index: mln/level/median.hh
--- mln/level/median.hh (revision 2346)
+++ mln/level/median.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -98,7 +98,7 @@
struct median_t
{
typedef mln_psite(I) P;
- typedef mln_dpsite(I) D;
+ typedef mln_dpsite(P) D;
// i/o
@@ -108,10 +108,10 @@
// aux data
- accu::median_h<mln_vset(I)> med;
+ accu::median_h<mln_value(I)> med;
P p;
window<D> win_fp, win_fm, win_bp, win_bm, win_dp, win_dm;
- mln_qiter(W) q_fp, q_fm, q_bp, q_bm, q_dp, q_dm;
+ mln_qiter(window<D>) q_fp, q_fm, q_bp, q_bm, q_dp, q_dm;
// ctor
@@ -123,7 +123,7 @@
win(exact(win_)),
output(exact(output_)),
// aux data
- med(input.values_eligible()),
+ med(),
p(),
win_fp(set::diff(win, geom::shift(win, left))),
win_fm(set::diff(geom::shift(win, left), win)),
@@ -196,7 +196,7 @@
// aux data
mln_psite(I) p;
- accu::median_h<mln_vset(I)> med;
+ accu::median_h<mln_value(I)> med;
// ctor
inline
@@ -304,7 +304,8 @@
trace::entering("level::median_dir");
mlc_is(mln_trait_image_value_io(O), trait::image::value_io::read_write)::check();
- mlc_is(mln_trait_image_support(I), trait::image::support::aligned)::check();
+ mlc_is(mln_trait_image_localization(I),
+ trait::image::localization::basic_grid)::check();
mlc_converts_to(mln_value(I), mln_value(O))::check();
mln_precondition(exact(output).domain() == exact(input).domain());
Index: mln/win/rectangle2d.hh
--- mln/win/rectangle2d.hh (revision 2346)
+++ mln/win/rectangle2d.hh (working copy)
@@ -38,6 +38,7 @@
# include <mln/core/internal/window_base.hh>
# include <mln/core/internal/dpoints_base.hh>
# include <mln/core/alias/dpoint2d.hh>
+# include <mln/core/def/coord.hh>
namespace mln
@@ -131,9 +132,11 @@
width_(width)
{
mln_precondition(height % 2 == 1 && width % 2 == 1);
- const int drow = height / 2, dcol = width / 2;
- for (int row = - drow; row <= drow; ++row)
- for (int col = - dcol; col <= dcol; ++col)
+ const def::coord drow = (def::coord) (height / 2);
+ const def::coord dcol = (def::coord) (width / 2);
+
+ for (def::coord row = (def::coord) -drow; row <= drow; ++row)
+ for (def::coord col = (def::coord) -dcol; col <= dcol; ++col)
this->insert(dpoint2d(row, col));
}
1
0
URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
ChangeLog:
2008-09-22 Guillaume Lazzara <z(a)lrde.epita.fr>
Update tutorial.
* tutorial.tex: Add sections about values and differences between
sites and psites.
---
tutorial.tex | 175 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 169 insertions(+), 6 deletions(-)
Index: branches/cleanup-2008/milena/doc/tutorial/tutorial.tex
===================================================================
--- branches/cleanup-2008/milena/doc/tutorial/tutorial.tex (revision 2345)
+++ branches/cleanup-2008/milena/doc/tutorial/tutorial.tex (revision 2346)
@@ -186,10 +186,10 @@
An image is composed both of:
\begin{itemize}
\item A function $$
-f : \left\{
+ima : \left\{
\begin{array}{lll}
Site &\rightarrow & Value \\
- p & \mapsto & v
+ p & \mapsto & ima(p)
\end{array}
\right.
$$
@@ -212,8 +212,31 @@
ici, site <=> Point2d
-[sample code]
+\section{About value, rvalue and lvalue}
+Image types provide a method to access values, namely "operator() const".
+Yet, its signature is NOT "value operator()(const site\& p) const"
+but "rvalue operator()(const psite\& p) const"
+
+For instance, with I being image2d$<$int\_u8$>$, we have :
+
+ I::value == int\_u8 but I::rvalue == const int\_u8\&
+
+so copying the value when the call "f(p)" returns is avoided.
+In that case, it is a low-level implementation issue that makes rvalue
+be different from value. In some other cases, the difference can be
+more fundamental. For instance, a proxy is returned so that some extra
+code is performed if this value is eventually read.
+
+Likewise, lvalue is also used as return type for methods such as "operator()".
+The difference is that lvalue allows the data to be modified.
+
+With I being image2d$<$int\_u8$>$, we have :
+
+ I::value == int\_u8 but I::lvalue == int\_u8\&
+
+
+\section{Sample code}
In order to create a 2D image, you have two possibilites:
\begin{lstlisting}[frame=single]
// which builds an empty image;
@@ -333,13 +356,14 @@
\end{itemize}
+
\subsection{Interface}
\begin{tabular}{|l|l|l|l|p{4cm}|}
\hline
Return Type & Name & Arguments & Const & Comments \\ \hline
-site\_set & domain & - & X - & \\ \hline
+I::pvset & domain & - & X - & \\ \hline
const Value\& & operator() & const point\& p & X & Used for reading. \\ \hline
Value\& & operator() & const point\& p & - & Used for writing. \\ \hline
const P\& & at & unsigned x,
@@ -349,7 +373,7 @@
bool & has & const Point\& p & X & \\ \hline
bool & has\_data & - & X & Returns true if the domain is defined. \\ \hline
site\_id & id & - & X & Return the Id of the underlying shared data. \\ \hline
-FIXME & destination & - & X & Value set of all the possible site values in this
+I::vset & destination & - & X & Value set of all the possible site values in this
Image. \\ \hline
site\_set & bbox & - & - & Returns the bounding box of the domain. \\ \hline
site\_set & bbox\_large & - & - & Returns the bouding box of the domain and the
@@ -368,9 +392,143 @@
+
+\chapter{Sites and psites}
+
+\section{Need for site}
+
+As we have seen before, an image is defined on a grid. It has associated
+data and a site set which defines the domain of the image on that grid.
+Usually, we need to access a value by its coordinates. With default images it
+can be done easily, at no cost.
+
+Example with an image2d:
+
+\begin{lstlisting}[frame=single]
+ c 0 1 2 3
+ r
+ +-+-+-+-+
+ 0 | |x| | |
+ +-+-+-+-+
+ 1 | | | | |
+ +-+-+-+-+
+\end{lstlisting}
+
+The site x is the point (0, 1). The image values are stored in a
+multi-dimensional array. The point coordinates can be used directly. The site
+(0, 1) \textbf{is} the point (0, 1) and the data is stored at row 0 and column
+1.
+
+Here we have:
+
+ I::site == I::psite == point2d
+
+where, roughly, point2d = \{ row, column \}.
+
+\section{Need for psite}
+
+Sometimes, accessing a value in constant-time complexity, O(1), is not
+possible with a site object.
+
+Let's have a small example. Define a function returning a value for a given
+point:
+
+\begin{lstlisting}[frame=single]
+ unsigned my_values(const point2d& p)
+ {
+ if (p.row() == 0)
+ return 8;
+ return 9;
+ }
+\end{lstlisting}
+So, for each point having (0, x) as coordinate, this function will return 8,
+otherwise it will be 9.
+
+Then, define a p\_array with few point2d:
+
+\begin{lstlisting}[frame=single]
+ p_array<point2d> arr;
+ arr.append(point2d(3, 6));
+ arr.append(point2d(3, 7));
+ arr.append(point2d(3, 8));
+ arr.append(point2d(4, 8));
+ arr.append(point2d(4, 9));
+\end{lstlisting}
+
+Now, create a point-wise image from this function and this p\_array:
+\begin{lstlisting}[frame=single]
+ mln_VAR(ima, my_values | arr);
+\end{lstlisting}
+
+Ima is actually that image:
+\begin{lstlisting}[frame=single]
+ c 6 7 8 9
+ r
+ +-+-+-+
+ 3 | |x| |
+ +-+-+-+-+
+ 4 | | |
+ +-+-+
+\end{lstlisting}
+
+However, in memory, since it is based on a p\_array, values are stored in a
+vector.
+
+The site x is the point (3, 7). The image values are stored in a
+vector where the index is the offset of the cell from the beginning of the
+vector. The site x thus corresponds to the cell 1.
+
+
+\begin{lstlisting}[frame=single]
+arr[] = 0 1 2 3 4
+ +-+-+-+-+-+
+ | |x| | | |
+ +-+-+-+-+-+
+\end{lstlisting}
+
+Obviously, from the site coordinates, we cannot access the associated data in
+constant-time. That's why we need a different mechanism in order to access
+this data: the psites.
+
+Here we have:
+
+ I::site == point2d but I::psite == pseudo\_site$<$point2d$>$
+
+where, roughly, pseudo\_site$<$point2d$>$ = \{ i\_in\_p\_array, p\_array\_ptr
+\}.
+
+Psites contains all the needed information to access the values in
+constant-time.
+
+\section{From psite to site}
+
+In the last example there was an image of type I such as I::site != I::psite.
+In that case, an object of type I::psite is actually convertible towards an
+object of type I::site. Furthermore, a psite shall behave as if it was a
+site.
+
+Design note: it seems impossible to offer through the interface of
+some psite what is expected from its corresponding site. For instance, when a
+site has a given feature, say a method "m", then this
+method has to appear in the psite interface. However, thanks to
+inheritance, we fetch an interface and an implementation that delegates
+to the site.
+
+For instance, in the last example, I::psite has a method ::row() because
+I::site, point2d, provides such a method.
+
+How it works: a psite inherits from internal::site\_impl$<$site$>$ which is
+specialized for every site type; for instance, internal::site\_impl$<$point2d$>$
+owns the method "coord row() const" which is defined as
+"return exact(this)->to\_site().row()"
+
+
\chapter{Iterators}
Each container object in Olena like site sets or images have iterators.
+The iteration mechanism for images is directly derived from the mechanism
+for site set.
+
There are usually three kinds:
\begin{itemize}
\item \textbf{fwd\_iter}, depends on the container,
@@ -378,6 +536,10 @@
\item \textbf{iter}, usually the same as fwd\_iter. It is guaranteed to
iterate all over the elements.
\end{itemize}
+Every iterable object have these three kinds of iterator. There are all
+bidirectional containers.
+Whatever the iterator used, the basic iterator has the only property of
+browsing every site once.
The iterator type name depends on the data pointed by it: \\
@@ -700,6 +862,7 @@
}
\end{lstlisting}
+
\chapter{Graphes and images}
\section{Description}
Olena enables the possibility of using graphes with images.
@@ -875,6 +1038,6 @@
}
\end{lstlisting}
-//FIXME talk about p_vertices and p_edges.
+//FIXME talk about p\_vertices and p\_edges.
\end{document}
\ No newline at end of file
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Update test on extension fill.
* milena/tests/extension/fill.cc (println_with_border): Remove.
Use 'extended' instead.
* milena/mln/core/image/extended.hh: Fix missing arg name.
mln/core/image/extended.hh | 2 +-
tests/extension/fill.cc | 17 ++++++++++++-----
2 files changed, 13 insertions(+), 6 deletions(-)
Index: milena/tests/extension/fill.cc
--- milena/tests/extension/fill.cc (revision 2344)
+++ milena/tests/extension/fill.cc (working copy)
@@ -31,9 +31,12 @@
*/
#include <mln/core/image/image2d.hh>
+#include <mln/core/image/extended.hh>
#include <mln/extension/fill.hh>
-#include <mln/value/int_u8.hh>
-#include <mln/debug/println_with_border.hh>
+
+#include <mln/level/fill.hh>
+#include <mln/debug/println.hh>
+
int main()
{
@@ -41,8 +44,12 @@
const unsigned border = 2;
- image2d<value::int_u8> ima(3, 3, border);
- extension::fill(ima, 42);
+ image2d<unsigned> ima(3, 3, border);
+
+ level::fill(ima, 0);
+ extension::fill(ima, 9);
- debug::println_with_border(ima);
+ box2d b = ima.bbox();
+ b.enlarge(border);
+ debug::println(extended_to(ima, b));
}
Index: milena/mln/core/image/extended.hh
--- milena/mln/core/image/extended.hh (revision 2344)
+++ milena/mln/core/image/extended.hh (working copy)
@@ -104,7 +104,7 @@
extended();
/// Constructor.
- extended(I& ima, const box<mln_site(I)>& );
+ extended(I& ima, const box<mln_site(I)>& b);
/// Initialization.
void init_(I& ima, const box<mln_site(I)>& b);
1
0
URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
ChangeLog:
2008-09-22 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Add snake_vert browsing canvas.
* mln/canvas/browsing/snake_vert.hh: New, snake vert browsing
canvas. This canvas browse all the point of an image 'input' like
this :
1 4 5
|| /\ ||
|| || ||
\/ || \/
2 3 6
* tests/canvas/browsing/Makefile.am: Add snake_vert test.
* tests/canvas/browsing/snake_vert.cc: New. The test.
* mln/canvas/browsing/snake_fwd.hh: Desactivate check
of dimension.
---
mln/canvas/browsing/snake_fwd.hh | 8 +
mln/canvas/browsing/snake_vert.hh | 166 ++++++++++++++++++++++++++++++++++++
tests/canvas/browsing/Makefile.am | 2
tests/canvas/browsing/snake_vert.cc | 96 ++++++++++++++++++++
4 files changed, 269 insertions(+), 3 deletions(-)
Index: branches/cleanup-2008/milena/tests/canvas/browsing/snake_vert.cc
===================================================================
--- branches/cleanup-2008/milena/tests/canvas/browsing/snake_vert.cc (revision 0)
+++ branches/cleanup-2008/milena/tests/canvas/browsing/snake_vert.cc (revision 2344)
@@ -0,0 +1,96 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/canvas/browsing/snake_vert.cc
+ *
+ * \brief Tests on mln::canvas::browsing::snake_vert.
+ */
+
+#include <mln/core/image/image2d.hh>
+#include <mln/canvas/browsing/snake_vert.hh>
+#include <mln/fun/p2v/iota.hh>
+#include <mln/debug/println.hh>
+
+// FIXME: Move code below into mln/canvas/browsing/iota.hh.
+
+
+template <typename I, typename F>
+struct assign_browsing_functor
+{
+ enum { dim = I::site::dim };
+
+
+ I input;
+ F f;
+
+ assign_browsing_functor(I& input, F f = F())
+ : input(input),
+ f(f)
+ {}
+
+ mln_psite(I) p;
+
+ void init() {}
+ void final() {}
+ void next()
+ {
+ input(p) = f(p);
+// mln_assertion(input(p) - 1 == p[0] * input.domain().ncols()
+// + ( (p[0] % 2) ? input.domain().ncols() - 1 - p[1] : p[1]));
+ }
+ void fwd() { next(); }
+ void up() { next(); }
+ void down() { next(); }
+};
+
+namespace mln
+{
+
+ template <typename I, typename F, typename B>
+ void my_test(Image<I>& ima_,
+ const Function_p2v<F>& f_,
+ const Browsing<B>& browse_)
+ {
+ I& ima = exact(ima_);
+ const F& f = exact(f_);
+ const B& browse = exact(browse_);
+
+ assign_browsing_functor<I, F> fun(ima, f);
+ browse(fun);
+ }
+
+}
+
+
+int main()
+{
+ using namespace mln;
+ image2d<unsigned> ima2(2, 7);
+
+ my_test(ima2, fun::p2v::iota, canvas::browsing::snake_vert);
+ debug::println(ima2);
+}
Index: branches/cleanup-2008/milena/tests/canvas/browsing/Makefile.am
===================================================================
--- branches/cleanup-2008/milena/tests/canvas/browsing/Makefile.am (revision 2343)
+++ branches/cleanup-2008/milena/tests/canvas/browsing/Makefile.am (revision 2344)
@@ -5,11 +5,13 @@
check_PROGRAMS = \
fwd \
snake_fwd \
+ snake_vert \
directional \
dir_struct_elt_incr_update
fwd_SOURCES = fwd.cc
snake_fwd_SOURCES = snake_fwd.cc
+snake_vert_SOURCES = snake_vert.cc
directional_SOURCES = directional.cc
dir_struct_elt_incr_update_SOURCES = dir_struct_elt_incr_update.cc
Index: branches/cleanup-2008/milena/mln/canvas/browsing/snake_fwd.hh
===================================================================
--- branches/cleanup-2008/milena/mln/canvas/browsing/snake_fwd.hh (revision 2343)
+++ branches/cleanup-2008/milena/mln/canvas/browsing/snake_fwd.hh (revision 2344)
@@ -101,7 +101,9 @@
void
snake_fwd_t::operator()(F& f) const
{
- // FIXME: Check the dimension (2D) or generalize.
+ // Fixme: check the dimension of the input
+// mlc_equal(mln_trait_image_dimension(I)(),
+// trait::image::dimension::two_d)::check();
trace::entering("canvas::browsing::snake_fwd");
mln_precondition(f.input.has_data());
int
@@ -141,9 +143,9 @@
while (col > min_col)
{
--col;
- trace::entering("canvas::browsing::snake_fwd");
+ trace::entering("canvas::browsing::snake_fwd::bkd");
f.bkd();
- trace::exiting("canvas::browsing::snake_fwd");
+ trace::exiting("canvas::browsing::snake_fwd::bkd");
}
// change browsing
Index: branches/cleanup-2008/milena/mln/canvas/browsing/snake_vert.hh
===================================================================
--- branches/cleanup-2008/milena/mln/canvas/browsing/snake_vert.hh (revision 0)
+++ branches/cleanup-2008/milena/mln/canvas/browsing/snake_vert.hh (revision 2344)
@@ -0,0 +1,166 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CANVAS_BROWSING_SNAKE_VERT_HH
+# define MLN_CANVAS_BROWSING_SNAKE_VERT_HH
+
+/*! \file mln/canvas/browsing/snake_vert.hh
+ *
+ * \brief Browsing in a snake-way, forward.
+ */
+
+# include <mln/core/concept/browsing.hh>
+# include <mln/geom/size2d.hh>
+
+
+namespace mln
+{
+
+ namespace canvas
+ {
+
+ namespace browsing
+ {
+
+ /*!
+ * \brief Browsing in a snake-way, forward.
+ *
+ * This canvas browse all the point of an image 'input' like
+ * this :
+ *
+ * | /\ |
+ * | | |
+ * \/ | \/
+ *
+ * The fonctor should provide (In addition to 'input') four
+ * methods :
+ *
+ * - init() : Will be called at the beginning.
+ * - down() : Will be called after each moving down.
+ * - up() : Will ba called after each moving up.
+ * - fwd() : Will be called after each moving right. (will
+ * also be called once at the first point).
+ *
+ * This methods should acces to the current working point 'p'
+ * also provided by the functor.
+ *
+ * Warning: This canvas works only on 2D.
+ *
+ * F shall feature: \n
+ * { \n
+ * --- as attributes: \n
+ * input; \n
+ * p; \n
+ * --- as methods: \n
+ * void init(); \n
+ * void down(); \n
+ * void up(); \n
+ * void fwd(); \n
+ * } \n
+ *
+ */
+
+ struct snake_vert_t : public Browsing< snake_vert_t >
+ {
+ template <typename F>
+ void operator()(F& f) const;
+ }
+
+ snake_vert;
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename F>
+ inline
+ void
+ snake_vert_t::operator()(F& f) const
+ {
+ // Fixme: check the dimension of the input
+// mlc_equal(mln_trait_image_dimension(I)(),
+// trait::image::dimension::two_d)::check();
+ trace::entering("canvas::browsing::snake_vert");
+ mln_precondition(f.input.has_data());
+ int
+ min_row = geom::min_row(f.input), max_row = geom::max_row(f.input),
+ min_col = geom::min_col(f.input), max_col = geom::max_col(f.input);
+
+ // p
+ f.p = f.input.bbox().pmin();
+ def::coord& row = f.p.row();
+ def::coord& col = f.p.col();
+
+ // initialization
+ trace::entering("canvas::browsing::snake_vert::init");
+ f.init();
+ trace::exiting("canvas::browsing::snake_vert::init");
+
+ bool down = true;
+ for (col = min_col; col <= max_col; ++col)
+ // FIXME: Add "if (f.input.has(p))"?
+ {
+ // go fwd
+ trace::entering("canvas::browsing::snake_vert::init");
+ f.fwd();
+ trace::exiting("canvas::browsing::snake_vert::init");
+
+ if (down)
+ // browse col down.
+ while (row < max_row)
+ {
+ ++row;
+ trace::entering("canvas::browsing::snake_vert::down");
+ f.down();
+ trace::exiting("canvas::browsing::snake_vert::down");
+ }
+ else
+ // browse col up.
+ while (row > min_row)
+ {
+ --row;
+ trace::entering("canvas::browsing::snake_vert::up");
+ f.up();
+ trace::exiting("canvas::browsing::snake_vert::up");
+ }
+
+ // change browsing
+ down = ! down;
+ }
+ trace::exiting("canvas::browsing::snake_vert");
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::canvas::browsing
+
+ } // end of namespace mln::canvas
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CANVAS_BROWSING_SNAKE_VERT_HH
1
0
URL: https://svn.lrde.epita.fr/svn/scool/branches/scool-ng
ChangeLog:
2008-09-19 Maxime van Noppen <yabo(a)lrde.epita.fr>
Use CxxId in the pretty-printer
* pp-cxx/CxxExp.str,
* pp-cxx/CxxType.str: Use CxxId instead of a string litteral.
CxxExp.str | 10 ++++++----
CxxType.str | 2 +-
2 files changed, 7 insertions(+), 5 deletions(-)
Index: branches/scool-ng/src/pp-cxx/CxxExp.str
===================================================================
--- branches/scool-ng/src/pp-cxx/CxxExp.str (revision 91)
+++ branches/scool-ng/src/pp-cxx/CxxExp.str (revision 92)
@@ -26,14 +26,11 @@
CxxAssign(idf, exp) -> <concat-strings> [idf, " = ", <CxxExpToStr> exp]
CxxExpToStr:
- CxxFunCall([], idf, args) -> <concat-strings> [ idf, "(", <CxxArgListToStr> args, ")" ]
+ CxxFunCall([], CxxId(idf), args) -> <concat-strings> [ idf, "(", <CxxArgListToStr> args, ")" ]
CxxExpToStr:
CxxProgram(exp) -> exp
- CxxExpToAbox:
- CxxAdressOf(idf) -> H hs=0 [ "&" ~<CxxIdToAbox> idf ]
-
CxxExpToStr:
x -> x
where <is-string> x
@@ -41,6 +38,11 @@
CxxExpToStr:
CxxId(idf) -> idf
+
+
+ CxxExpToAbox:
+ CxxAdressOf(idf) -> H hs=0 [ "&" ~<CxxIdToAbox> idf ]
+
CxxExpToAbox:
x -> S(<CxxExpToStr> x)
Index: branches/scool-ng/src/pp-cxx/CxxType.str
===================================================================
--- branches/scool-ng/src/pp-cxx/CxxType.str (revision 91)
+++ branches/scool-ng/src/pp-cxx/CxxType.str (revision 92)
@@ -23,7 +23,7 @@
Typename -> S("typename")
CxxTypeToAbox:
- CxxFunCall([], idf, args) -> H hs=0 [ ~<CxxIdToAbox>idf "(" H hs=1 [ ~*<CxxListToAbox(CxxTypeToAbox <+ CxxExpToAbox|",")>args ] ")"]
+ CxxFunCall([], CxxId(idf), args) -> H hs=0 [ ~<CxxIdToAbox>idf "(" H hs=1 [ ~*<CxxListToAbox(CxxTypeToAbox <+ CxxExpToAbox|",")>args ] ")"]
CxxTypeToAbox:
CxxScope(idf1, idf2) -> H hs=0 [ ~<CxxTypeToAbox> idf1 "::" ~<CxxIdToAbox> idf2 ]
--
\__/ \__/
(00) Maxime `yabo` van Noppen (00)
___) \ Epita 2009 / (___
(_____/ \_____)
1
0