Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- 9625 discussions
* mln/core/image/graph_window_piter.hh
(mln::graph_window_fwd_piter<P, W>)
(mln::graph_window_bkd_piter<P, W>):
Adjust to the new interface of internal::graph_vicinity_piter_.
(mln::graph_window_fwd_piter<P, W>::super_)
(mln::graph_window_bkd_piter<P, W>::super_):
Adjust.
(mln::graph_window_fwd_piter<P, W>::psite)
(mln::graph_window_bkd_piter<P, W>::psite):
New typedefs.
(mln::graph_window_fwd_piter<P, W>::graph_window_fwd_piter)
(mln::graph_window_bkd_piter<P, W>::graph_window_bkd_piter):
New default ctors.
(graph_window_fwd_piter(const Window<W>&, const Point_Site<Pref>&))
(graph_window_bkd_piter(const Window<W>&, const Point_Site<Pref>&)):
Turn ctors into...
(graph_window_fwd_piter(const Window<W>&, const Pref&))
(graph_window_bkd_piter(const Window<W>&, const Pref&)):
...these.
Adjust.
(mln::graph_window_fwd_piter<P, W>::is_valid)
(mln::graph_window_fwd_piter<P, W>::invalidate)
(mln::graph_window_fwd_piter<P, W>::start)
(mln::graph_window_fwd_piter<P, W>::next_)
(mln::graph_window_bkd_piter<P, W>::is_valid)
(mln::graph_window_bkd_piter<P, W>::invalidate)
(mln::graph_window_bkd_piter<P, W>::start)
(mln::graph_window_bkd_piter<P, W>::next_):
Catch up with the new interface of
internal::graph_vicinity_piter_.
Rename as...
(mln::graph_window_fwd_piter<P, W>::is_valid_)
(mln::graph_window_fwd_piter<P, W>::invalidate_)
(mln::graph_window_fwd_piter<P, W>::do_start_)
(mln::graph_window_fwd_piter<P, W>::do_next_)
(mln::graph_window_bkd_piter<P, W>::is_valid_)
(mln::graph_window_bkd_piter<P, W>::invalidate_)
(mln::graph_window_bkd_piter<P, W>::do_start_)
(mln::graph_window_bkd_piter<P, W>::do_next_):
...these.
(mln::graph_window_fwd_piter<P, W>::compute_sites_)
(mln::graph_window_bkd_piter<P, W>::compute_sites_):
New methods.
(mln::graph_window_fwd_piter<P, W>::win_)
(mln::graph_window_bkd_piter<P, W>::win_):
Remove attributes.
---
milena/ChangeLog | 51 ++++++++
milena/mln/core/image/graph_window_piter.hh | 164 +++++++++++----------------
2 files changed, 119 insertions(+), 96 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index e450700..5ef0f52 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,56 @@
2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+ Update graph window piters.
+
+ * mln/core/image/graph_window_piter.hh
+ (mln::graph_window_fwd_piter<P, W>)
+ (mln::graph_window_bkd_piter<P, W>):
+ Adjust to the new interface of internal::graph_vicinity_piter_.
+ (mln::graph_window_fwd_piter<P, W>::super_)
+ (mln::graph_window_bkd_piter<P, W>::super_):
+ Adjust.
+ (mln::graph_window_fwd_piter<P, W>::psite)
+ (mln::graph_window_bkd_piter<P, W>::psite):
+ New typedefs.
+ (mln::graph_window_fwd_piter<P, W>::graph_window_fwd_piter)
+ (mln::graph_window_bkd_piter<P, W>::graph_window_bkd_piter):
+ New default ctors.
+ (graph_window_fwd_piter(const Window<W>&, const Point_Site<Pref>&))
+ (graph_window_bkd_piter(const Window<W>&, const Point_Site<Pref>&)):
+ Turn ctors into...
+ (graph_window_fwd_piter(const Window<W>&, const Pref&))
+ (graph_window_bkd_piter(const Window<W>&, const Pref&)):
+ ...these.
+ Adjust.
+ (mln::graph_window_fwd_piter<P, W>::is_valid)
+ (mln::graph_window_fwd_piter<P, W>::invalidate)
+ (mln::graph_window_fwd_piter<P, W>::start)
+ (mln::graph_window_fwd_piter<P, W>::next_)
+ (mln::graph_window_bkd_piter<P, W>::is_valid)
+ (mln::graph_window_bkd_piter<P, W>::invalidate)
+ (mln::graph_window_bkd_piter<P, W>::start)
+ (mln::graph_window_bkd_piter<P, W>::next_):
+ Catch up with the new interface of
+ internal::graph_vicinity_piter_.
+ Rename as...
+ (mln::graph_window_fwd_piter<P, W>::is_valid_)
+ (mln::graph_window_fwd_piter<P, W>::invalidate_)
+ (mln::graph_window_fwd_piter<P, W>::do_start_)
+ (mln::graph_window_fwd_piter<P, W>::do_next_)
+ (mln::graph_window_bkd_piter<P, W>::is_valid_)
+ (mln::graph_window_bkd_piter<P, W>::invalidate_)
+ (mln::graph_window_bkd_piter<P, W>::do_start_)
+ (mln::graph_window_bkd_piter<P, W>::do_next_):
+ ...these.
+ (mln::graph_window_fwd_piter<P, W>::compute_sites_)
+ (mln::graph_window_bkd_piter<P, W>::compute_sites_):
+ New methods.
+ (mln::graph_window_fwd_piter<P, W>::win_)
+ (mln::graph_window_bkd_piter<P, W>::win_):
+ Remove attributes.
+
+2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+
Update relative iterators on graph image vicinity.
* mln/core/internal/graph_vicinity_piter.hh
diff --git a/milena/mln/core/image/graph_window_piter.hh b/milena/mln/core/image/graph_window_piter.hh
index e38484a..d9191ee 100644
--- a/milena/mln/core/image/graph_window_piter.hh
+++ b/milena/mln/core/image/graph_window_piter.hh
@@ -47,37 +47,40 @@ namespace mln
/// \brief Forward iterator on graph window.
template <typename P, typename W>
class graph_window_fwd_piter :
- public internal::graph_vicinity_piter_< P, graph_window_fwd_piter<P, W> >
+ public internal::graph_vicinity_piter_< P, W, graph_window_fwd_piter<P, W> >
{
typedef graph_window_fwd_piter<P, W> self_;
- typedef internal::graph_vicinity_piter_<P, self_> super_;
+ typedef internal::graph_vicinity_piter_<P, W, self_> super_;
+
+ public:
+ /// The Point_Site type.
+ typedef mln_psite(W) psite;
public:
/// Construction.
/// \{
+ graph_window_fwd_piter();
template <typename Pref>
- graph_window_fwd_piter(const Window<W>& win, const Point_Site<Pref>& p_ref);
+ graph_window_fwd_piter(const Window<W>& win, const Pref& p_ref);
/// \}
/// Manipulation.
/// \{
/// Test if the iterator is valid.
- bool is_valid() const;
+ bool is_valid_() const;
/// Invalidate the iterator.
- void invalidate();
- /// Start an iteration.
- void start();
+ void invalidate_();
+ /// Start an iteration.
+ void do_start_();
/// Go to the next point.
- void next_();
- /// Update the internal data of the iterator.
- void update_();
+ void do_next_();
+
+ /// Compute the current psite.
+ psite compute_p_() const;
/// \}
private:
- /// The window.
- const W& win_;
-
/// An iterator on the set of adjacent vertices.
typename super_::sites_t::const_iterator i_;
};
@@ -90,37 +93,40 @@ namespace mln
/// \brief Backward iterator on graph window.
template <typename P, typename W>
class graph_window_bkd_piter :
- public internal::graph_vicinity_piter_< P, graph_window_bkd_piter<P, W> >
+ public internal::graph_vicinity_piter_< P, W, graph_window_bkd_piter<P, W> >
{
typedef graph_window_bkd_piter<P, W> self_;
- typedef internal::graph_vicinity_piter_<P, self_> super_;
+ typedef internal::graph_vicinity_piter_<P, W, self_> super_;
+
+ public:
+ /// The Point_Site type.
+ typedef mln_psite(W) psite;
public:
/// Construction.
/// \{
+ graph_window_bkd_piter();
template <typename Pref>
- graph_window_bkd_piter(const Window<W>& win, const Point_Site<Pref>& p_ref);
+ graph_window_bkd_piter(const Window<W>& win, const Pref& p_ref);
/// \}
/// Manipulation.
/// \{
/// Test if the iterator is valid.
- bool is_valid() const;
+ bool is_valid_() const;
/// Invalidate the iterator.
- void invalidate();
- /// Start an iteration.
- void start();
+ void invalidate_();
+ /// Start an iteration.
+ void do_start_();
/// Go to the next point.
- void next_();
- /// Update the internal data of the iterator.
- void update_();
+ void do_next_();
+
+ /// Compute the current psite.
+ psite compute_p_() const;
/// \}
private:
- /// The window.
- const W& win_;
-
/// An iterator on the set of adjacent vertices.
typename super_::sites_t::const_reverse_iterator i_;
};
@@ -134,35 +140,33 @@ namespace mln
`-------------------------------*/
template <typename P, typename W>
+ inline
+ graph_window_fwd_piter<P, W>::graph_window_fwd_piter()
+ {
+ }
+
+ template <typename P, typename W>
template <typename Pref>
inline
graph_window_fwd_piter<P, W>::graph_window_fwd_piter(const Window<W>& win,
- const Point_Site<Pref>& p_ref)
- : super_(p_ref),
- win_(exact(win))
+ const Pref& p_ref)
+ : super_(p_ref)
{
- // Invalidate i_.
- invalidate();
+ this->change_target(exact(win));
}
template <typename P, typename W>
inline
bool
- graph_window_fwd_piter<P, W>::is_valid() const
+ graph_window_fwd_piter<P, W>::is_valid_() const
{
- return
- // The reference point must be valid...
- this->p_ref_.is_valid()
- // ...and must not have changed since the window has been computed...
- && this->p_ref_ == this->saved_p_ref_
- // ...and the iterator i_ must point a valid value.
- && i_ != this->sites_.end();
+ return i_ != this->sites_.end();
}
template <typename P, typename W>
inline
void
- graph_window_fwd_piter<P, W>::invalidate()
+ graph_window_fwd_piter<P, W>::invalidate_()
{
i_ = this->sites_.end();
}
@@ -170,41 +174,26 @@ namespace mln
template <typename P, typename W>
inline
void
- graph_window_fwd_piter<P, W>::start()
+ graph_window_fwd_piter<P, W>::do_start_()
{
- mln_precondition(this->p_ref_.is_valid());
- // Update the sites, if needed.
- if (!this->saved_p_ref_.is_valid() || this->p_ref_ != this->saved_p_ref_)
- {
- this->saved_p_ref_ = this->p_ref_;
- win_.compute_sites_(*this);
- }
+ this->site_set().compute_sites_(*this);
i_ = this->sites_.begin();
- // FIXME: We might move the is_valid condition within update_.
- if (is_valid())
- update_();
}
template <typename P, typename W>
inline
void
- graph_window_fwd_piter<P, W>::next_()
+ graph_window_fwd_piter<P, W>::do_next_()
{
- // Ensure the p_ref_ has not changed.
- mln_precondition(this->p_ref_ == this->saved_p_ref_);
++i_;
- // FIXME: We might move the is_valid condition within update_.
- if (is_valid())
- update_();
}
template <typename P, typename W>
inline
- void
- graph_window_fwd_piter<P, W>::update_()
+ mln_psite(W)
+ graph_window_fwd_piter<P, W>::compute_p_() const
{
- // Update psite_.
- this->psite_ = graph_psite<P>(this->pg(), *i_);
+ return graph_psite<P>(this->center().site_set(), *i_);
}
@@ -213,35 +202,33 @@ namespace mln
`-------------------------------*/
template <typename P, typename W>
+ inline
+ graph_window_bkd_piter<P, W>::graph_window_bkd_piter()
+ {
+ }
+
+ template <typename P, typename W>
template <typename Pref>
inline
graph_window_bkd_piter<P, W>::graph_window_bkd_piter(const Window<W>& win,
- const Point_Site<Pref>& p_ref)
- : super_(p_ref),
- win_(exact(win))
+ const Pref& p_ref)
+ : super_(p_ref)
{
- // Invalidate i_.
- invalidate();
+ this->change_target(exact(win));
}
template <typename P, typename W>
inline
bool
- graph_window_bkd_piter<P, W>::is_valid() const
+ graph_window_bkd_piter<P, W>::is_valid_() const
{
- return
- // The reference point must be valid...
- this->p_ref_.is_valid()
- // ...and must not have changed since the window has been computed...
- && this->p_ref_ == this->saved_p_ref_
- // ...and the iterator i_ must point a valid value.
- && i_ != this->sites_.rend();
+ return i_ != this->sites_.rend();
}
template <typename P, typename W>
inline
void
- graph_window_bkd_piter<P, W>::invalidate()
+ graph_window_bkd_piter<P, W>::invalidate_()
{
i_ = this->sites_.rend();
}
@@ -249,41 +236,26 @@ namespace mln
template <typename P, typename W>
inline
void
- graph_window_bkd_piter<P, W>::start()
+ graph_window_bkd_piter<P, W>::do_start_()
{
- mln_precondition(this->p_ref_.is_valid());
- // Update the sites, if needed.
- if (!this->saved_p_ref_.is_valid() || this->p_ref_ != this->saved_p_ref_)
- {
- this->saved_p_ref_ = this->p_ref_;
- win_.compute_sites_(*this);
- }
+ this->site_set().compute_sites_(*this);
i_ = this->sites_.rbegin();
- // FIXME: We might move the is_valid condition within update_.
- if (is_valid())
- update_();
}
template <typename P, typename W>
inline
void
- graph_window_bkd_piter<P, W>::next_()
+ graph_window_bkd_piter<P, W>::do_next_()
{
- // Ensure the p_ref_ has not changed.
- mln_precondition(this->p_ref_ == this->saved_p_ref_);
++i_;
- // FIXME: We might move the is_valid condition within update_.
- if (is_valid())
- update_();
}
template <typename P, typename W>
inline
- void
- graph_window_bkd_piter<P, W>::update_()
+ mln_psite(W)
+ graph_window_bkd_piter<P, W>::compute_p_() const
{
- // Update psite_.
- this->psite_ = graph_psite<P>(this->pg(), *i_);
+ return graph_psite<P>(this->center().site_set(), *i_);
}
# endif // ! MLN_INCLUDE_ONLY
--
1.5.6.5
1
0
* mln/core/internal/graph_vicinity_piter.hh
(mln::internal::graph_vicinity_piter_<P, S, E>): Take and
additional parameter S.
Inherit from internal::site_relative_iterator_base.
Adjust.
(graph_vicinity_piter_<P, S, E>::graph_vicinity_piter_):
New default ctor.
Adjust other ctor.
(mln::internal::graph_vicinity_piter_<P, S, E>::self_)
(mln::internal::graph_vicinity_piter_<P, S, E>::super_)
(mln::internal::graph_vicinity_piter_<P, S, E>::psite)
(mln::internal::graph_vicinity_piter_<P, S, E>::point)
(mln::internal::graph_vicinity_piter_<P, S, E>::coord):
Remove typedefs.
(mln::internal::graph_vicinity_piter_<P, S, E>::to_point)
(mln::internal::graph_vicinity_piter_<P, S, E>::to_psite)
(mln::internal::graph_vicinity_piter_<P, S, E>::operator psite)
(mln::internal::graph_vicinity_piter_<P, S, E>::p_ref)
(mln::internal::graph_vicinity_piter_<P, S, E>::pg)
(mln::internal::graph_vicinity_piter_<P, S, E>::operator[]):
Remove methods.
(mln::internal::graph_vicinity_piter_<P, S, E>::p_ref_)
(mln::internal::graph_vicinity_piter_<P, S, E>::saved_p_ref_)
(mln::internal::graph_vicinity_piter_<P, S, E>::psite_)
(mln::internal::graph_vicinity_piter_<P, S, E>::p_):
Remove attributes.
(operator<<(std::ostream&, const graph_vicinity_piter_<P, E>&_)):
Adjust, turn into...
(operator<<(std::ostream&, const graph_vicinity_piter_<P, S, E>&_)):
...this.
Adjust.
---
milena/ChangeLog | 36 ++++++
milena/mln/core/internal/graph_vicinity_piter.hh | 144 +++++-----------------
2 files changed, 65 insertions(+), 115 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index ee2ec1b..e450700 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,41 @@
2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+ Update relative iterators on graph image vicinity.
+
+ * mln/core/internal/graph_vicinity_piter.hh
+ (mln::internal::graph_vicinity_piter_<P, S, E>): Take and
+ additional parameter S.
+ Inherit from internal::site_relative_iterator_base.
+ Adjust.
+ (graph_vicinity_piter_<P, S, E>::graph_vicinity_piter_):
+ New default ctor.
+ Adjust other ctor.
+ (mln::internal::graph_vicinity_piter_<P, S, E>::self_)
+ (mln::internal::graph_vicinity_piter_<P, S, E>::super_)
+ (mln::internal::graph_vicinity_piter_<P, S, E>::psite)
+ (mln::internal::graph_vicinity_piter_<P, S, E>::point)
+ (mln::internal::graph_vicinity_piter_<P, S, E>::coord):
+ Remove typedefs.
+ (mln::internal::graph_vicinity_piter_<P, S, E>::to_point)
+ (mln::internal::graph_vicinity_piter_<P, S, E>::to_psite)
+ (mln::internal::graph_vicinity_piter_<P, S, E>::operator psite)
+ (mln::internal::graph_vicinity_piter_<P, S, E>::p_ref)
+ (mln::internal::graph_vicinity_piter_<P, S, E>::pg)
+ (mln::internal::graph_vicinity_piter_<P, S, E>::operator[]):
+ Remove methods.
+ (mln::internal::graph_vicinity_piter_<P, S, E>::p_ref_)
+ (mln::internal::graph_vicinity_piter_<P, S, E>::saved_p_ref_)
+ (mln::internal::graph_vicinity_piter_<P, S, E>::psite_)
+ (mln::internal::graph_vicinity_piter_<P, S, E>::p_):
+ Remove attributes.
+ (operator<<(std::ostream&, const graph_vicinity_piter_<P, E>&_)):
+ Adjust, turn into...
+ (operator<<(std::ostream&, const graph_vicinity_piter_<P, S, E>&_)):
+ ...this.
+ Adjust.
+
+2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+
Update iterators on mln::p_graph.
* mln/core/site_set/p_graph_piter.hh
diff --git a/milena/mln/core/internal/graph_vicinity_piter.hh b/milena/mln/core/internal/graph_vicinity_piter.hh
index 4a53616..b51ab97 100644
--- a/milena/mln/core/internal/graph_vicinity_piter.hh
+++ b/milena/mln/core/internal/graph_vicinity_piter.hh
@@ -32,46 +32,43 @@
/// \brief Factored implementation for point iterators on a graph windows
/// and graph neighborhoods, called "vicinities".
+# include <set>
+
+# include <mln/core/internal/site_relative_iterator_base.hh>
+# include <mln/core/site_set/p_graph.hh>
+# include <mln/core/image/graph_psite.hh>
+
/* FIXME: Factor those classes:
- mln::internal::graph_vicinity_piter.hh
- mln::internal::line_graph_vicinity_piter.hh */
-# include <mln/core/concept/site_iterator.hh>
-# include <mln/core/site_set/p_graph.hh>
-# include <mln/core/image/graph_psite.hh>
-
/* FIXME: Due to the poor interface of mln::p_graph and
mln::util::graph, we show to much implementation details here.
Enrich their interfaces to avoid that. */
+
namespace mln
{
// Fwd decls.
template <typename P> class p_graph;
template <typename P> class graph_psite;
+ // FIXME: Consider renaming graph_vicinity_piter_ as
+ // graph_relative_piter_.
- /*----------------------------------------.
- | internal::graph_vicinity_piter_<P, E>. |
- `----------------------------------------*/
namespace internal
{
/// \brief Base for iterator on a graph vicinity.
- template <typename P, typename E>
- class graph_vicinity_piter_ : public Site_Iterator< E >
+ template <typename P, typename S, typename E>
+ class graph_vicinity_piter_
+ : public internal::site_relative_iterator_base< S, E >
{
- typedef graph_vicinity_piter_<P, E> self_;
- typedef Site_Iterator< self_ > super_;
-
public:
enum { dim = P::dim };
- typedef graph_psite<P> psite;
- typedef P point;
- typedef mln_coord(P) coord;
// FIXME: Dummy typedef.
typedef void dpoint;
// FIXME: Dummy value.
@@ -81,145 +78,62 @@ namespace mln
typedef std::set<util::vertex_id> sites_t;
public:
- /// Conversion and accessors.
- /// \{
- /// Reference to the corresponding point.
- const point& to_point() const;
- /// Reference to the corresponding point site.
- const psite& to_psite() const;
- /// Convert the iterator into a line graph psite.
- operator psite() const;
-
- /// Return the reference psite.
- const psite& p_ref() const;
- /// Return the mln::p_graph corresponding to this piter.
- const p_graph<P>& pg() const;
/// Return the set of sites (adjacent vertex ids).
sites_t& sites();
- /// Read-only access to the \a i-th coordinate.
- coord operator[](unsigned i) const;
- /// \}
-
protected:
/// Construction.
/// \{
+ graph_vicinity_piter_();
template <typename Pref>
- graph_vicinity_piter_(const Point_Site<Pref>& p_ref);
- /// \}
-
- /// Internals, used by the vicinity.
- /// \{
- public:
- /// An internal iterator on the set of vertices of the underlying graph.
- util::vertex_id id_;
+ graph_vicinity_piter_(const Pref& p_ref);
/// \}
protected:
- /// The ``central'' psite of the vicinity (for instance, the
- /// center of the neighborhood, in the case of a neighborhood
- /// piter).
- const psite& p_ref_;
-
- /// The last reference psite whose ajacent psites have been computed.
- psite saved_p_ref_;
/// The set of edge ids adjacent to the reference psite.
sites_t sites_;
-
- /// The psite corresponding to this iterator.
- psite psite_;
- /// The point corresponding to this iterator.
- point p_;
};
- /* 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 <typename P, typename E>
+
+ /// Print an mln::line_graph_vicinity_piter_<P, S, E>.
+ template <typename P, typename S, typename E>
inline
std::ostream&
- operator<<(std::ostream& ostr, const graph_vicinity_piter_<P, E>& p);
+ operator<<(std::ostream& ostr, const graph_vicinity_piter_<P, S, E>& p);
# ifndef MLN_INCLUDE_ONLY
- template <typename P, typename E>
- template <typename Pref>
+ template <typename P, typename S, typename E>
inline
- graph_vicinity_piter_<P, E>::graph_vicinity_piter_(const Point_Site<Pref>& p_ref)
- : p_ref_(exact(p_ref).to_psite()),
- // Initialize psite_ to a dummy value.
- psite_(),
- p_()
+ graph_vicinity_piter_<P, S, E>::graph_vicinity_piter_()
{
}
- template <typename P, typename E>
- inline
- const P&
- graph_vicinity_piter_<P, E>::to_point() const
- {
- return p_;
- }
-
- template <typename P, typename E>
- inline
- const graph_psite<P>&
- graph_vicinity_piter_<P, E>::to_psite() const
- {
- return psite_;
- }
-
- template <typename P, typename E>
- inline
- graph_vicinity_piter_<P, E>::operator graph_psite<P>() const
- {
- mln_precondition(exact(*this).is_valid());
- return psite_;
- }
-
- template <typename P, typename E>
- inline
- const graph_psite<P>&
- graph_vicinity_piter_<P, E>::p_ref() const
- {
- return p_ref_;
- }
-
- template <typename P, typename E>
+ template <typename P, typename S, typename E>
+ template <typename Pref>
inline
- const p_graph<P>&
- graph_vicinity_piter_<P, E>::pg() const
+ graph_vicinity_piter_<P, S, E>::graph_vicinity_piter_(const Pref& p_ref)
{
- return p_ref_.pg();
+ center_at(p_ref);
}
- template <typename P, typename E>
+ template <typename P, typename S, typename E>
inline
std::set<util::vertex_id>&
- graph_vicinity_piter_<P, E>::sites()
+ graph_vicinity_piter_<P, S, E>::sites()
{
return sites_;
}
- template <typename P, typename E>
- inline
- mln_coord(P)
- graph_vicinity_piter_<P, E>::operator[](unsigned i) const
- {
- assert(i < dim);
- return p_[i];
- }
-
- template <typename P, typename E>
+ template <typename P, typename S, typename E>
inline
std::ostream&
- operator<<(std::ostream& ostr, const graph_vicinity_piter_<P, E>& p)
+ operator<<(std::ostream& ostr, const graph_vicinity_piter_<P, S, E>& p)
{
- return ostr << p.to_psite();
+ return ostr << p.unproxy_();
}
# endif // ! MLN_INCLUDE_ONLY
--
1.5.6.5
1
0
* mln/core/site_set/p_graph_piter.hh
(mln::p_graph_fwd_piter<P>)
(mln::p_graph_bkd_piter<P>):
Inherit from internal::site_set_iterator_base.
(mln::p_graph_fwd_piter<P>::super_)
(mln::p_graph_bkd_piter<P>::super_):
Adjust.
(mln::p_graph_fwd_piter<P>::dim)
(mln::p_graph_bkd_piter<P>::dim):
Remove enums.
(mln::p_graph_fwd_piter<P>::psite)
(mln::p_graph_fwd_piter<P>::point)
(mln::p_graph_fwd_piter<P>::coord)
(mln::p_graph_bkd_piter<P>::psite)
(mln::p_graph_bkd_piter<P>::point)
(mln::p_graph_bkd_piter<P>::coord):
Remove typedefs.
(mln::p_graph_fwd_piter<P>::p_graph_fwd_piter)
(mln::p_graph_bkd_piter<P>::p_graph_bkd_piter):
New default ctors.
(mln::p_graph_fwd_piter<P>::p_graph_fwd_piter(const p_graph<P>& pg))
(mln::p_graph_bkd_piter<P>::p_graph_bkd_piter(const p_graph<P>& pg)):
Ajust ctors.
(mln::p_graph_fwd_piter<P>::p_graph_fwd_piter(const self_&))
(mln::p_graph_bkd_piter<P>::p_graph_bkd_piter(const self_&))
(mln::p_graph_fwd_piter<P>::operator=(const self_&))
(mln::p_graph_bkd_piter<P>::operator=(const self_&)):
Remove.
(mln::p_graph_fwd_piter<P>::next_)
(mln::p_graph_bkd_piter<P>::next_):
Catch up with the new interface of graph_psite.
(mln::p_graph_fwd_piter<P>::is_valid)
(mln::p_graph_fwd_piter<P>::invalidate)
(mln::p_graph_fwd_piter<P>::start)
(mln::p_graph_bkd_piter<P>::is_valid)
(mln::p_graph_bkd_piter<P>::invalidate)
(mln::p_graph_bkd_piter<P>::start):
Likewise.
Rename as...
(mln::p_graph_fwd_piter<P>::is_valid_)
(mln::p_graph_fwd_piter<P>::invalidate_)
(mln::p_graph_fwd_piter<P>::start_):
(mln::p_graph_bkd_piter<P>::is_valid_)
(mln::p_graph_bkd_piter<P>::invalidate_)
(mln::p_graph_bkd_piter<P>::start_):
...these.
(mln::p_graph_fwd_piter<P>::to_point)
(mln::p_graph_fwd_piter<P>::to_psite)
(mln::p_graph_fwd_piter<P>::operator psite)
(mln::p_graph_fwd_piter<P>::operator[])
(mln::p_graph_bkd_piter<P>::to_point)
(mln::p_graph_bkd_piter<P>::to_psite)
(mln::p_graph_bkd_piter<P>::operator psite)
(mln::p_graph_bkd_piter<P>::operator[]):
Remove.
(mln::p_graph_fwd_piter<P>::pg_)
(mln::p_graph_fwd_piter<P>::id_)
(mln::p_graph_fwd_piter<P>::psite_)
(mln::p_graph_bkd_piter<P>::pg_)
(mln::p_graph_bkd_piter<P>::id_)
(mln::p_graph_bkd_piter<P>::psite_):
Remove attributes
(mln::p_graph_fwd_piter<P>::p_)
(mln::p_graph_bkd_piter<P>::p_):
Remove.
Use the one from the super class.
---
milena/ChangeLog | 71 ++++++
milena/mln/core/site_set/p_graph_piter.hh | 349 +++++------------------------
2 files changed, 127 insertions(+), 293 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 323a1fe..ee2ec1b 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,76 @@
2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+ Update iterators on mln::p_graph.
+
+ * mln/core/site_set/p_graph_piter.hh
+ (mln::p_graph_fwd_piter<P>)
+ (mln::p_graph_bkd_piter<P>):
+ Inherit from internal::site_set_iterator_base.
+ (mln::p_graph_fwd_piter<P>::super_)
+ (mln::p_graph_bkd_piter<P>::super_):
+ Adjust.
+ (mln::p_graph_fwd_piter<P>::dim)
+ (mln::p_graph_bkd_piter<P>::dim):
+ Remove enums.
+ (mln::p_graph_fwd_piter<P>::psite)
+ (mln::p_graph_fwd_piter<P>::point)
+ (mln::p_graph_fwd_piter<P>::coord)
+ (mln::p_graph_bkd_piter<P>::psite)
+ (mln::p_graph_bkd_piter<P>::point)
+ (mln::p_graph_bkd_piter<P>::coord):
+ Remove typedefs.
+ (mln::p_graph_fwd_piter<P>::p_graph_fwd_piter)
+ (mln::p_graph_bkd_piter<P>::p_graph_bkd_piter):
+ New default ctors.
+ (mln::p_graph_fwd_piter<P>::p_graph_fwd_piter(const p_graph<P>& pg))
+ (mln::p_graph_bkd_piter<P>::p_graph_bkd_piter(const p_graph<P>& pg)):
+ Ajust ctors.
+ (mln::p_graph_fwd_piter<P>::p_graph_fwd_piter(const self_&))
+ (mln::p_graph_bkd_piter<P>::p_graph_bkd_piter(const self_&))
+ (mln::p_graph_fwd_piter<P>::operator=(const self_&))
+ (mln::p_graph_bkd_piter<P>::operator=(const self_&)):
+ Remove.
+ (mln::p_graph_fwd_piter<P>::next_)
+ (mln::p_graph_bkd_piter<P>::next_):
+ Catch up with the new interface of graph_psite.
+ (mln::p_graph_fwd_piter<P>::is_valid)
+ (mln::p_graph_fwd_piter<P>::invalidate)
+ (mln::p_graph_fwd_piter<P>::start)
+ (mln::p_graph_bkd_piter<P>::is_valid)
+ (mln::p_graph_bkd_piter<P>::invalidate)
+ (mln::p_graph_bkd_piter<P>::start):
+ Likewise.
+ Rename as...
+ (mln::p_graph_fwd_piter<P>::is_valid_)
+ (mln::p_graph_fwd_piter<P>::invalidate_)
+ (mln::p_graph_fwd_piter<P>::start_):
+ (mln::p_graph_bkd_piter<P>::is_valid_)
+ (mln::p_graph_bkd_piter<P>::invalidate_)
+ (mln::p_graph_bkd_piter<P>::start_):
+ ...these.
+ (mln::p_graph_fwd_piter<P>::to_point)
+ (mln::p_graph_fwd_piter<P>::to_psite)
+ (mln::p_graph_fwd_piter<P>::operator psite)
+ (mln::p_graph_fwd_piter<P>::operator[])
+ (mln::p_graph_bkd_piter<P>::to_point)
+ (mln::p_graph_bkd_piter<P>::to_psite)
+ (mln::p_graph_bkd_piter<P>::operator psite)
+ (mln::p_graph_bkd_piter<P>::operator[]):
+ Remove.
+ (mln::p_graph_fwd_piter<P>::pg_)
+ (mln::p_graph_fwd_piter<P>::id_)
+ (mln::p_graph_fwd_piter<P>::psite_)
+ (mln::p_graph_bkd_piter<P>::pg_)
+ (mln::p_graph_bkd_piter<P>::id_)
+ (mln::p_graph_bkd_piter<P>::psite_):
+ Remove attributes
+ (mln::p_graph_fwd_piter<P>::p_)
+ (mln::p_graph_bkd_piter<P>::p_):
+ Remove.
+ Use the one from the super class.
+
+2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+
Update site of mln::p_graph.
* mln/core/image/graph_psite.hh (mln::graph_psite<P>): Inherit
diff --git a/milena/mln/core/site_set/p_graph_piter.hh b/milena/mln/core/site_set/p_graph_piter.hh
index 56419d9..7ef1859 100644
--- a/milena/mln/core/site_set/p_graph_piter.hh
+++ b/milena/mln/core/site_set/p_graph_piter.hh
@@ -28,12 +28,16 @@
#ifndef MLN_CORE_SITE_SET_P_GRAPH_PITER_HH
# define MLN_CORE_SITE_SET_P_GRAPH_PITER_HH
-# include <mln/core/internal/site_iterator_base.hh>
+/// \file mln/core/site_set/p_graph_piter.hh
+/// \brief Definition of point iterator on graph-based point set.
+
+# include <mln/core/internal/site_set_iterator_base.hh>
# include <mln/core/site_set/p_graph.hh>
# include <mln/core/image/graph_psite.hh>
-/// \file mln/core/site_set/p_graph_piter.hh
-/// \brief Definition of point iterator on graph-based point set.
+/* FIXME: Iterators on p_graph and p_line_graph share common code.
+ Factor as much as possible. */
+
namespace mln
{
@@ -41,6 +45,7 @@ namespace mln
template <typename P> class p_graph;
template <typename P> class graph_psite;
+
/*------------------------.
| p_graph_fwd_piter_<P>. |
`------------------------*/
@@ -48,69 +53,39 @@ namespace mln
/// \brief Forward iterator on point sites of a mln::p_graph<P>.
template <typename P>
class p_graph_fwd_piter_
- : public internal::site_iterator_base< P, p_graph_fwd_piter_<P> >
+ : public internal::site_set_iterator_base< p_graph<P>,
+ p_graph_fwd_piter_<P> >
{
typedef p_graph_fwd_piter_<P> self_;
- typedef internal::site_iterator_base< P, self_ > super_;
+ typedef internal::site_set_iterator_base< p_graph<P>, self_ > super_;
public:
- // Make definitions from super class available.
- enum { dim = super_::dim };
-
- typedef graph_psite<P> psite;
- typedef P point;
- typedef mln_coord(point) coord;
-
/// Construction and assignment.
/// \{
+ p_graph_fwd_piter_();
p_graph_fwd_piter_(const p_graph<P>& pg);
- p_graph_fwd_piter_(const self_& rhs);
- self_& operator= (const self_& rhs);
/// \}
/// Manipulation.
/// \{
/// Test if the iterator is valid.
- bool is_valid() const;
+ bool is_valid_() const;
/// Invalidate the iterator.
- void invalidate();
- /// Start an iteration.
- void start();
+ void invalidate_();
+ /// Start an iteration.
+ void start_();
/// Go to the next point.
void next_();
- /// Update the internal data of the iterator.
- void update_();
- /// \}
-
- /// Conversion and accessors.
- /// \{
- /// Reference to the corresponding point.
- const point& to_point () const;
- /// Reference to the corresponding point site.
- const psite& to_psite () const;
- /// Convert the iterator into a graph psite.
- operator psite() const;
-
- /// Read-only access to the \p i-th coordinate.
- mln_coord(P) operator[](unsigned i) const;
/// \}
private:
- /// The p_graph this point site belongs to.
- const p_graph<P>* pg_;
- /// The id of the vertex this psite is pointing towards.
- unsigned id_;
/// The psite corresponding to this iterator.
- psite psite_;
- /// The point corresponding to this iterator.
- point p_;
+ using super_::p_;
};
- /* 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. */
+
+ /// Print an mln::p_graph_fwd_piter_<P>.
template <typename P>
inline
std::ostream&
@@ -124,76 +99,46 @@ namespace mln
/// \brief Backward iterator on point sites of a mln::p_graph<P>.
template <typename P>
class p_graph_bkd_piter_
- : public internal::site_iterator_base< P, p_graph_bkd_piter_<P> >
+ : public internal::site_set_iterator_base< p_graph<P>,
+ p_graph_bkd_piter_<P> >
{
typedef p_graph_bkd_piter_<P> self_;
- typedef internal::site_iterator_base< P, self_ > super_;
+ typedef internal::site_set_iterator_base< p_graph<P>, self_ > super_;
public:
- // Make definitions from super class available.
- enum { dim = super_::dim };
-
- typedef graph_psite<P> psite;
- typedef P point;
- typedef mln_coord(point) coord;
-
/// Construction and assignment.
/// \{
+ p_graph_bkd_piter_();
p_graph_bkd_piter_(const p_graph<P>& pg);
- p_graph_bkd_piter_(const self_& rhs);
- self_& operator= (const self_& rhs);
/// \}
/// Manipulation.
/// \{
/// Test if the iterator is valid.
- bool is_valid() const;
+ bool is_valid_() const;
/// Invalidate the iterator.
- void invalidate();
- /// Start an iteration.
- void start();
+ void invalidate_();
+ /// Start an iteration.
+ void start_();
/// Go to the next point.
void next_();
- /// Update the internal data of the iterator.
- void update_();
- /// \}
-
- /// Conversion and accessors.
- /// \{
- /// Reference to the corresponding point.
- const point& to_point () const;
- /// Reference to the corresponding point site.
- const psite& to_psite () const;
- /// Convert the iterator into a graph psite.
- operator psite() const;
-
- /// Read-only access to the \p i-th coordinate.
- coord operator[](unsigned i) const;
/// \}
private:
- /// The p_graph this point site belongs to.
- const p_graph<P>* pg_;
- /// The id of the vertex this psite is pointing towards.
- unsigned id_;
/// The psite corresponding to this iterator.
- psite psite_;
- /// The point corresponding to this iterator.
- point p_;
+ using super_::p_;
};
- /* 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. */
+ /// Print an mln::p_graph_bkd_piter_<P>.
template <typename P>
inline
std::ostream&
operator<<(std::ostream& ostr, const p_graph_bkd_piter_<P>& p);
+
# ifndef MLN_INCLUDE_ONLY
/*------------------------.
@@ -202,71 +147,41 @@ namespace mln
template <typename P>
inline
- p_graph_fwd_piter_<P>::p_graph_fwd_piter_(const p_graph<P>& pg)
- : pg_(&pg),
- // Initialize psite_ to a dummy value.
- psite_(pg, -1)
- {
- // Invalidate id_.
- invalidate();
- }
-
- template <typename P>
- inline
- p_graph_fwd_piter_<P>::p_graph_fwd_piter_(const p_graph_fwd_piter_<P>& rhs)
- : pg_(rhs.pg_),
- id_(rhs.id_),
- psite_(rhs.psite_),
- p_(rhs.p_)
- {
- }
-
- template <typename P>
- inline
- p_graph_fwd_piter_<P>&
- p_graph_fwd_piter_<P>::operator=(const p_graph_fwd_piter_<P>& rhs)
+ p_graph_fwd_piter_<P>::p_graph_fwd_piter_()
{
- if (&rhs == this)
- return *this;
- pg_ = rhs.pg_;
- id_ = rhs.id_;
- psite_ = rhs.psite_;
- p_ = rhs.p_;
- return *this;
+ mln_postcondition(!this->is_valid());
}
template <typename P>
inline
- mln_coord(P)
- p_graph_fwd_piter_<P>::operator[](unsigned i) const
+ p_graph_fwd_piter_<P>::p_graph_fwd_piter_(const p_graph<P>& pg)
{
- return p_[i];
+ this->change_target(pg);
+ mln_postcondition(!this->is_valid());
}
template <typename P>
inline
bool
- p_graph_fwd_piter_<P>::is_valid() const
+ p_graph_fwd_piter_<P>::is_valid_() const
{
- return pg_ && id_ < pg_->nvertices();
+ return p_.is_valid();
}
template <typename P>
inline
void
- p_graph_fwd_piter_<P>::invalidate()
+ p_graph_fwd_piter_<P>::invalidate_()
{
- id_ = -1;
+ p_.invalidate();
}
template <typename P>
inline
void
- p_graph_fwd_piter_<P>::start()
+ p_graph_fwd_piter_<P>::start_()
{
- id_ = 0;
- if (is_valid())
- update_();
+ p_.change_vertex_id(0);
}
template <typename P>
@@ -274,66 +189,7 @@ namespace mln
void
p_graph_fwd_piter_<P>::next_()
{
- ++id_;
- if (is_valid())
- update_();
- }
-
- template <typename P>
- inline
- void
- p_graph_fwd_piter_<P>::update_()
- {
- // Update psite_.
- psite_ = graph_psite<P>(*pg_, id_);
- // Update p_.
- p_ = pg_->point_from_id(id_);
- }
-
- template <typename P>
- inline
- const P&
- p_graph_fwd_piter_<P>::to_point() const
- {
- /* We don't check whether the iterator is valid before returning
- the value using
-
- mln_precondition(is_valid());
-
- since this method may be called *before* the iterator is
- actually initialized. This is the case for instance when this
- point iterator (say, P) is used to initialize another iterator
- on window or neighborhood (say, Q); most of the time, for_all()
- is responsible for the initialization of P, but it takes place
- *after* the creation of Q. */
- return p_;
- }
-
- template <typename P>
- inline
- const graph_psite<P>&
- p_graph_fwd_piter_<P>::to_psite() const
- {
- /* We don't check whether the iterator is valid before returning
- the value using
-
- mln_precondition(is_valid());
-
- since this method may be called *before* the iterator is
- actually initialized. This is the case for instance when this
- point iterator (say, P) is used to initialize another iterator
- on window or neighborhood (say, Q); most of the time, for_all()
- is responsible for the initialization of P, but it takes place
- *after* the creation of Q. */
- return psite_;
- }
-
- template <typename P>
- inline
- p_graph_fwd_piter_<P>::operator graph_psite<P>() const
- {
- mln_precondition(is_valid());
- return psite_;
+ p_.inc_vertex_id();
}
@@ -342,9 +198,7 @@ namespace mln
std::ostream&
operator<<(std::ostream& ostr, const p_graph_fwd_piter_<P>& p)
{
- // FIXME: We should use p.to_psite() here, but as it lacks the
- // precondition the conversion operator has, we use the latter.
- return ostr << static_cast< graph_psite<P> >(p);
+ return ostr << p.unproxy_();
}
@@ -354,71 +208,41 @@ namespace mln
template <typename P>
inline
- p_graph_bkd_piter_<P>::p_graph_bkd_piter_(const p_graph<P>& pg)
- : pg_(&pg),
- // Initialize psite_ to a dummy value.
- psite_(pg, -1)
- {
- // Invalidate id_.
- invalidate();
- }
-
- template <typename P>
- inline
- p_graph_bkd_piter_<P>::p_graph_bkd_piter_(const p_graph_bkd_piter_<P>& rhs)
- : pg_(rhs.pg_),
- id_(rhs.id_),
- psite_(rhs.psite_),
- p_(rhs.p_)
- {
- }
-
- template <typename P>
- inline
- p_graph_bkd_piter_<P>&
- p_graph_bkd_piter_<P>::operator=(const p_graph_bkd_piter_<P>& rhs)
+ p_graph_bkd_piter_<P>::p_graph_bkd_piter_()
{
- if (&rhs == this)
- return *this;
- pg_ = rhs.pg_;
- id_ = rhs.id_;
- psite_ = rhs.psite_;
- p_ = rhs.p_;
- return *this;
+ mln_postcondition(!this->is_valid());
}
template <typename P>
inline
- mln_coord(P)
- p_graph_bkd_piter_<P>::operator[](unsigned i) const
+ p_graph_bkd_piter_<P>::p_graph_bkd_piter_(const p_graph<P>& pg)
{
- return p_[i];
+ this->change_target(pg);
+ mln_postcondition(!this->is_valid());
}
template <typename P>
inline
bool
- p_graph_bkd_piter_<P>::is_valid() const
+ p_graph_bkd_piter_<P>::is_valid_() const
{
- return pg_ && id_ < pg_->nvertices();
+ return p_.is_valid();
}
template <typename P>
inline
void
- p_graph_bkd_piter_<P>::invalidate()
+ p_graph_bkd_piter_<P>::invalidate_()
{
- id_ = -1;
+ p_.invalidate();
}
template <typename P>
inline
void
- p_graph_bkd_piter_<P>::start()
+ p_graph_bkd_piter_<P>::start_()
{
- id_ = pg_->nvertices() - 1;
- if (is_valid())
- update_();
+ p_.change_vertex_id(this->site_set().nvertices() - 1);
}
template <typename P>
@@ -426,66 +250,7 @@ namespace mln
void
p_graph_bkd_piter_<P>::next_()
{
- --id_;
- if (is_valid())
- update_();
- }
-
- template <typename P>
- inline
- void
- p_graph_bkd_piter_<P>::update_()
- {
- // Update psite_.
- psite_ = graph_psite<P>(*pg_, id_);
- // Update p_.
- p_ = pg_->point_from_id(id_);
- }
-
- template <typename P>
- inline
- const P&
- p_graph_bkd_piter_<P>::to_point() const
- {
- /* We don't check whether the iterator is valid before returning
- the value using
-
- mln_precondition(is_valid());
-
- since this method may be called *before* the iterator is
- actually initialized. This is the case for instance when this
- point iterator (say, P) is used to initialize another iterator
- on window or neighborhood (say, Q); most of the time, for_all()
- is responsible for the initialization of P, but it takes place
- *after* the creation of Q. */
- return p_;
- }
-
- template <typename P>
- inline
- const graph_psite<P>&
- p_graph_bkd_piter_<P>::to_psite() const
- {
- /* We don't check whether the iterator is valid before returning
- the value using
-
- mln_precondition(is_valid());
-
- since this method may be called *before* the iterator is
- actually initialized. This is the case for instance when this
- point iterator (say, P) is used to initialize another iterator
- on window or neighborhood (say, Q); most of the time, for_all()
- is responsible for the initialization of P, but it takes place
- *after* the creation of Q. */
- return psite_;
- }
-
- template <typename P>
- inline
- p_graph_bkd_piter_<P>::operator graph_psite<P>() const
- {
- mln_precondition(is_valid());
- return psite_;
+ p_.dec_vertex_id();
}
@@ -494,9 +259,7 @@ namespace mln
std::ostream&
operator<<(std::ostream& ostr, const p_graph_bkd_piter_<P>& p)
{
- // FIXME: We should use p.to_psite() here, but as it lacks the
- // precondition the conversion operator has, we use the latter.
- return ostr << static_cast< graph_psite<P> >(p);
+ return ostr << p.unproxy_();
}
# endif // ! MLN_INCLUDE_ONLY
--
1.5.6.5
1
0
* mln/core/image/graph_psite.hh (mln::graph_psite<P>): Inherit
from internal::pseudo_site_base_.
(mln::graph_psite<P>::super_)
(mln::graph_psite<P>::mesh)
(mln::graph_psite<P>::point)
(mln::graph_psite<P>::dpoint)
(mln::graph_psite<P>::coord):
Remove typedefs.
(mln::graph_psite<P>::dim): Remove enum.
(mln::graph_psite<P>::target): New typedef.
(mln::graph_psite<P>::graph_psite(const self_&))
(mln::graph_psite<P>::operator=(const self_&)):
Remove.
(mln::graph_psite<P>::to_psite)
(mln::graph_psite<P>::to_point)
(mln::graph_psite<P>::operator[]):
Remove methods.
(mln::graph_psite<P>::graph_psite)
(mln::graph_psite<P>::graph_psite(const p_graph<P>&, util::vertex_id)):
Update ctors.
(mln::graph_psite<P>::is_valid):
Update.
(mln::graph_psite<P>::invalidate)
(mln::graph_psite<P>::update_)
(mln::graph_psite<P>::site_set)
(mln::graph_psite<P>::target_)
(mln::graph_psite<P>::change_target)
(mln::graph_psite<P>::subj_):
New methods.
(mln::graph_psite<P>::id): Rename accessor as...
(mln::graph_psite<P>::vertex_id): ...this.
(mln::graph_psite<P>::change_vertex_id)
(mln::graph_psite<P>::inc_vertex_id)
(mln::graph_psite<P>::dec_vertex_id):
New methods.
(mln::graph_psite<P>::p_): New attribute.
(operator!=(const graph_psite<P>&, const graph_psite<P>&))
(operator<<(std::ostream&, const graph_psite<P>&)):
New operators.
(operator==(const graph_psite<P>&, const graph_psite<P>&))
(operator< (const graph_psite<P>&, const graph_psite<P>&)):
Update operators.
---
milena/ChangeLog | 47 +++++++
milena/mln/core/image/graph_psite.hh | 227 ++++++++++++++++++++++++---------
2 files changed, 212 insertions(+), 62 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 746a34a..323a1fe 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,52 @@
2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+ Update site of mln::p_graph.
+
+ * mln/core/image/graph_psite.hh (mln::graph_psite<P>): Inherit
+ from internal::pseudo_site_base_.
+ (mln::graph_psite<P>::super_)
+ (mln::graph_psite<P>::mesh)
+ (mln::graph_psite<P>::point)
+ (mln::graph_psite<P>::dpoint)
+ (mln::graph_psite<P>::coord):
+ Remove typedefs.
+ (mln::graph_psite<P>::dim): Remove enum.
+ (mln::graph_psite<P>::target): New typedef.
+ (mln::graph_psite<P>::graph_psite(const self_&))
+ (mln::graph_psite<P>::operator=(const self_&)):
+ Remove.
+ (mln::graph_psite<P>::to_psite)
+ (mln::graph_psite<P>::to_point)
+ (mln::graph_psite<P>::operator[]):
+ Remove methods.
+ (mln::graph_psite<P>::graph_psite)
+ (mln::graph_psite<P>::graph_psite(const p_graph<P>&, util::vertex_id)):
+ Update ctors.
+ (mln::graph_psite<P>::is_valid):
+ Update.
+ (mln::graph_psite<P>::invalidate)
+ (mln::graph_psite<P>::update_)
+ (mln::graph_psite<P>::site_set)
+ (mln::graph_psite<P>::target_)
+ (mln::graph_psite<P>::change_target)
+ (mln::graph_psite<P>::subj_):
+ New methods.
+ (mln::graph_psite<P>::id): Rename accessor as...
+ (mln::graph_psite<P>::vertex_id): ...this.
+ (mln::graph_psite<P>::change_vertex_id)
+ (mln::graph_psite<P>::inc_vertex_id)
+ (mln::graph_psite<P>::dec_vertex_id):
+ New methods.
+ (mln::graph_psite<P>::p_): New attribute.
+ (operator!=(const graph_psite<P>&, const graph_psite<P>&))
+ (operator<<(std::ostream&, const graph_psite<P>&)):
+ New operators.
+ (operator==(const graph_psite<P>&, const graph_psite<P>&))
+ (operator< (const graph_psite<P>&, const graph_psite<P>&)):
+ Update operators.
+
+2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+
Update site set mln::p_graph.
* mln/core/site_set/p_graph.hh
diff --git a/milena/mln/core/image/graph_psite.hh b/milena/mln/core/image/graph_psite.hh
index ef0fedb..0a70497 100644
--- a/milena/mln/core/image/graph_psite.hh
+++ b/milena/mln/core/image/graph_psite.hh
@@ -29,64 +29,102 @@
# define MLN_CORE_IMAGE_GRAPH_PSITE_HH
/// \file mln/core/image/graph_psite.hh
-/// \brief Definition of a graph-based point site.
+/// \brief Definition of a graph-based psite.
-# include <mln/core/concept/point_site.hh>
+# include <mln/core/internal/pseudo_site_base.hh>
# include <mln/core/site_set/p_graph.hh>
+/* FIXME: This class shares a lot with line_graph_psite. Factor as
+ much as possible. */
+
+// FIXME: Rename graph_psite as p_graph_psite, and move this
+// to core/site_set.
+
namespace mln
{
// Forward declaration.
template <typename P> class p_graph;
+ template <typename P> class graph_psite;
/// \brief Point site associated to a mln::graph_image.
+ ///
+ /// \arg \p P The type of the site.
template <typename P>
- class graph_psite : public Point_Site< graph_psite<P> >
+ class graph_psite
+ : public internal::pseudo_site_base_< const P&, graph_psite<P> >
{
typedef graph_psite<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_graph<P> target;
/// Construction and assignment.
/// \{
graph_psite();
graph_psite(const p_graph<P>& pg_, util::vertex_id id);
- graph_psite(const self_& rhs);
- self_& operator= (const self_& rhs);
/// \}
- /// Access to psite.
- const self_& to_psite() const;
+ /// Psite manipulators.
+ /// \{
+ /// Is this psite valid?
+ bool is_valid() const;
+ /// Invalidate this psite.
+ void invalidate();
+ /// \}
- /// Access to point.
+ /// Site set manipulators.
/// \{
- const point& to_point() const;
- coord operator[](unsigned id) const;
+ /// \brief Get the site set (shortcut for *target()).
+ /// \pre Member plg_ is non null.
+ 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);
/// \}
- /// Return the p_graph this point site belongs to.
- const p_graph<P>& pg() const;
+ /// Proxy manipulators.
+ /// \{
+ /// Return the site corresponding to this psite.
+ const P& subj_();
+ /// \}
+
+ /// Vertex id manipulators.
+ //// \{
/// Return the vertex id of this point site.
- util::vertex_id id() const;
+ util::vertex_id vertex_id() const;
+ /// Set the vertex id of this point site.
+ void change_vertex_id(const util::vertex_id& id);
+ /// Increment the vertex id of this point site.
+ void inc_vertex_id();
+ /// Increment the vertex id of this point site.
+ void dec_vertex_id();
+ /// \}
- /// 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_;
+ /// \}
private:
+ /// Graph-related members.
+ /// \{
/// The p_graph this point site belongs to.
- const p_graph<P>* pg_;
+ const target* pg_;
/// The id of the vertex this psite is pointing towards.
util::vertex_id id_;
+ /// \}
};
@@ -103,6 +141,14 @@ namespace mln
bool
operator==(const graph_psite<P>& lhs, const graph_psite<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_graph.
+ template <typename P>
+ bool
+ operator!=(const graph_psite<P>& lhs, const graph_psite<P>& rhs);
+
/// \brief Is \a lhs ``less'' than \a rhs?
///
/// This comparison is required by algorithms sorting psites.
@@ -115,97 +161,134 @@ namespace mln
/// \}
+ template <typename P>
+ inline
+ std::ostream&
+ operator<<(std::ostream& ostr, const graph_psite<P>& p);
+
+
# ifndef MLN_INCLUDE_ONLY
template <typename P>
inline
graph_psite<P>::graph_psite()
- // Dummy initializations.
- : super_(),
- pg_(0),
- id_(-1)
+ : pg_(0)
{
}
template <typename P>
inline
graph_psite<P>::graph_psite(const p_graph<P>& g, util::vertex_id id)
- : super_(),
- pg_(&g),
+ // FIXME: Use change_target instead.
+ : pg_(&g),
id_(id)
{
+ update_();
}
template <typename P>
inline
- graph_psite<P>::graph_psite(const graph_psite<P>& rhs)
- : super_(rhs),
- pg_(rhs.pg_),
- id_(rhs.id_)
+ bool
+ graph_psite<P>::is_valid() const
{
+ /* FIXME: Instead of `plg_->gr_->nvertices()', we should have
+ something like `run_->has_edge_id(id_)' (see the implementation of
+ p_run_psite. */
+ return pg_ && id_ < pg_->gr_->nvertices();
}
template <typename P>
inline
- graph_psite<P>&
- graph_psite<P>::operator= (const graph_psite<P>& rhs)
+ void
+ graph_psite<P>::invalidate()
{
- if (&rhs == this)
- return *this;
- pg_ = rhs.pg_;
- id_ = rhs.id_;
- return *this;
+ /* FIXME: Instead of `plg_->gr_->nvertices()', we should have
+ something like `run_->has_edge_id(id_)' (see the implementation of
+ p_run_psite. */
+ id_ = pg_->gr_->nvertices();
}
template <typename P>
inline
- bool
- graph_psite<P>::is_valid() const
+ const p_graph<P>&
+ graph_psite<P>::site_set() const
{
- return pg_ && id_ < pg_->gr_->nvertices();
+ mln_precondition(target_());
+ return *target_();
}
template <typename P>
inline
- const graph_psite<P>&
- graph_psite<P>::to_psite() const
+ const p_graph<P>*
+ graph_psite<P>::target_() const
{
- return *this;
+ return pg_;
}
template <typename P>
inline
+ void
+ graph_psite<P>::change_target(const p_graph<P>& new_target)
+ {
+ pg_ = &new_target;
+ invalidate();
+ }
+
+ // FIXME: Write or extend a test to exercise this method.
+ template <typename P>
+ inline
const P&
- graph_psite<P>::to_point() const
+ graph_psite<P>::subj_()
{
- return pg().point_from_id(id_);
+ return p_;
}
template <typename P>
inline
- mln_coord(P)
- graph_psite<P>::operator[](unsigned i) const
+ util::vertex_id
+ graph_psite<P>::vertex_id() const
{
- mln_assertion(is_valid());
- return to_point()[i];
+ return id_;
}
template <typename P>
inline
- const p_graph<P>&
- graph_psite<P>::pg() const
+ void
+ graph_psite<P>::change_vertex_id(const util::vertex_id& id)
{
- mln_assertion(pg_);
- return *pg_;
+ id_ = id;
+ if (is_valid())
+ update_();
}
template <typename P>
inline
- util::vertex_id
- graph_psite<P>::id() const
+ void
+ graph_psite<P>::inc_vertex_id()
{
- return id_;
+ ++id_.to_equiv();
+ if (is_valid())
+ update_();
+ }
+
+ template <typename P>
+ inline
+ void
+ graph_psite<P>::dec_vertex_id()
+ {
+ --id_.to_equiv();
+ if (is_valid())
+ update_();
+ }
+
+ template <typename P>
+ inline
+ void
+ graph_psite<P>::update_()
+ {
+ mln_precondition(is_valid());
+ p_ = site_set().point_from_id(id_);
}
@@ -217,19 +300,39 @@ namespace mln
bool
operator==(const graph_psite<P>& lhs, const graph_psite<P>& rhs)
{
- mln_assertion(&lhs.pg() == &rhs.pg());
- return lhs.id() == rhs.id();
+ mln_assertion(lhs.target_() == rhs.target_());
+ return lhs.vertex_id() == rhs.vertex_id();
+ }
+
+ template <typename P>
+ bool
+ operator!=(const graph_psite<P>& lhs, const graph_psite<P>& rhs)
+ {
+ mln_assertion(lhs.target_() == rhs.target_());
+ return lhs.vertex_id() != rhs.vertex_id();
}
template <typename P>
bool
operator< (const graph_psite<P>& lhs, const graph_psite<P>& rhs)
{
- mln_assertion(&lhs.pg() == &rhs.pg());
- return lhs.id() < rhs.id();
+ mln_assertion(lhs.target_() == rhs.target_());
+ return lhs.vertex_id() < rhs.vertex_id();
}
+ /*------------------.
+ | Pretty-printing. |
+ `------------------*/
+
+ template <typename P>
+ inline
+ std::ostream&
+ operator<<(std::ostream& ostr, const graph_psite<P>& p)
+ {
+ return ostr << p.unproxy_();
+ }
+
# endif // ! MLN_INCLUDE_ONLY
--
1.5.6.5
1
0
* mln/core/site_set/p_graph.hh
(mln::trait::site_set_< p_graph<P> >): New properties.
(mln::p_graph<P>): Inherit from internal::site_set_base_.
(mln::p_graph<P>::self_
(mln::p_graph<P>::super_)
(mln::p_graph<P>::element)
(mln::p_graph<P>::piter):
New typedefs.
(mln::p_graph<P>::bbox): Remove method.
(mln::p_graph<P>::bb_): Remove attribute.
(mln::p_graph<P>::p_graph): Adjust ctor.
(mln::p_graph<P>::has): Update.
(mln::p_graph<P>::to_graph): Update accessors.
Rename them as...
(mln::p_graph<P>::gr): ...these.
(mln::p_graph<P>::nsites): Change return type of this method to
unsigned.
(mln::p_graph<P>::is_valid)
(mln::p_graph<P>::memory_size):
New methods.
---
milena/ChangeLog | 25 ++++++
milena/mln/core/site_set/p_graph.hh | 158 ++++++++++++++++++++++++-----------
2 files changed, 134 insertions(+), 49 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index ba324e4..746a34a 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_graph.
+
+ * mln/core/site_set/p_graph.hh
+ (mln::trait::site_set_< p_graph<P> >): New properties.
+ (mln::p_graph<P>): Inherit from internal::site_set_base_.
+ (mln::p_graph<P>::self_
+ (mln::p_graph<P>::super_)
+ (mln::p_graph<P>::element)
+ (mln::p_graph<P>::piter):
+ New typedefs.
+ (mln::p_graph<P>::bbox): Remove method.
+ (mln::p_graph<P>::bb_): Remove attribute.
+ (mln::p_graph<P>::p_graph): Adjust ctor.
+ (mln::p_graph<P>::has): Update.
+ (mln::p_graph<P>::to_graph): Update accessors.
+ Rename them as...
+ (mln::p_graph<P>::gr): ...these.
+ (mln::p_graph<P>::nsites): Change return type of this method to
+ unsigned.
+ (mln::p_graph<P>::is_valid)
+ (mln::p_graph<P>::memory_size):
+ New methods.
+
+2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+
Update complex-based image.
* mln/core/complex_iter.hh: More documentation.
diff --git a/milena/mln/core/site_set/p_graph.hh b/milena/mln/core/site_set/p_graph.hh
index d7de799..073b91f 100644
--- a/milena/mln/core/site_set/p_graph.hh
+++ b/milena/mln/core/site_set/p_graph.hh
@@ -28,26 +28,49 @@
#ifndef MLN_CORE_SITE_SET_P_GRAPH_HH
# define MLN_CORE_SITE_SET_P_GRAPH_HH
-# include <mln/core/concept/point_site.hh>
+/// \file mln/core/site_set/p_graph.hh
+/// \brief Definition of a point set based on a graph.
+
# include <mln/core/internal/site_set_base.hh>
-# include <mln/accu/bbox.hh>
-# include <mln/util/tracked_ptr.hh>
# include <mln/util/graph.hh>
+# include <mln/util/tracked_ptr.hh>
# include <mln/core/image/graph_psite.hh>
# include <mln/core/site_set/p_graph_piter.hh>
+/* FIXME: This class shares a lot with p_line_graph. Factor as much
+ as possible. */
+
+/* FIXME: We should move the `adjacent'/`adjacent_or_equal' methods
+ out of this class (into iterators on *graph*). */
+
namespace mln
{
- /* FIXME: Contray to, e.g., p_array, the sole parameter P of p_graph
- is expected to be a point, not a psite!! We should have a
- uniform scheme for point site sets. */
+ // Forward declaration.
+ template <typename P> struct p_graph;
+
+ namespace trait
+ {
+ template <typename P>
+ struct site_set_< p_graph<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
+
template <typename P>
struct p_graph
- : public internal::site_set_base_< graph_psite<P>, p_graph<P> >
+ : public internal::site_set_base_< P, p_graph<P> >
{
+ typedef p_graph<P> self_;
+ typedef internal::site_set_base_< P, self_ > super_;
+
typedef util::graph<P> graph;
/// \brief Construct a graph psite set from a graph of points.
@@ -56,8 +79,12 @@ namespace mln
///
/// \a gr is \em copied internally, so that the graph psite set is
/// still valid after the initial graph has been removed.
- p_graph (const graph& gr);
+ p_graph(const graph& gr);
+ /// Associated types.
+ /// \{
+ /// Element associated type.
+ typedef mln_site(super_) element;
/// Point_Site associated type.
typedef graph_psite<P> psite;
@@ -67,27 +94,48 @@ namespace mln
/// Backward Site_Iterator associated type.
typedef p_graph_bkd_piter_<P> bkd_piter;
+ /// Site_Iterator associated type.
+ typedef fwd_piter piter;
+ /// \}
+
/// \brief Return The number of points (sites) of the set, i.e.,
/// the number of \em vertices.
///
/// Required by the mln::Point_Set concept.
- std::size_t nsites() const;
+ /* FIXME: Return type should be std::size_t (see
+ mln/core/concept/site_set.hh). */
+ unsigned nsites() const;
/// Return The number of vertices in the graph.
std::size_t nvertices() const;
/// 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;
+ /// Does this site set has \a p?
bool has(const psite& p) const;
+ // FIXME: Dummy.
+ std::size_t memory_size() const;
+
+ /// Accessors.
+ /// \{
+ /// Return the graph associated to this site set (const version)
+ const graph& gr() const;
+ /// Return the graph associated to this site set (mutable version).
+ graph& gr();
+ /// \}
+
+ /// \brief Graph-related services
+ ///
+ /// \todo Move them into iterators on graphs.
+ /// \{
/// Return the graph point (FIXME site?) from an index
const P& point_from_id(const util::vertex_id& id) const;
P& point_from_id(const util::vertex_id& id);
-
/// Return the point contained in the first vertex adjacent
// to the edge id \a e.
const P& vertex1(const util::edge_id& e) const;
@@ -95,6 +143,9 @@ namespace mln
/// to the edge id \a e.
const P& vertex2(const util::edge_id& e) const;
+ // 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.
@@ -111,21 +162,11 @@ namespace mln
const util::vertex_id& rhs) const;
/// \}
- /// Return the graph associated to the p_graph domain.
- // FIXME: Rename as something else (graph() ?).
- const graph& to_graph() const;
- graph& to_graph();
-
+ /// \}
- // FIXME: Should be private.
public:
+ // FIXME: Should be private.
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? */
- private:
- box<P> bb_;
};
@@ -137,6 +178,10 @@ namespace mln
bool
operator==(const p_graph<P>& lhs, const p_graph<P>& rhs);
+
+ /* FIXME: Extend the `ord' mechanism instead of this ill-defined
+ pseudo-order. */
+
/// \brief Inclusion of a mln::p_graph in another one.
///
/// This inclusion relation is very strict for the moment, since our
@@ -159,15 +204,11 @@ namespace mln
// Create a deep, managed copy of GR.
: gr_ (new util::graph<P>(gr))
{
- accu::bbox<P> a;
- for (unsigned i = 0; i < nsites(); ++i)
- a.take(gr_->vertex_data(i));
- bb_ = a.to_result();
}
template <typename P>
inline
- std::size_t
+ unsigned
p_graph<P>::nsites() const
{
return nvertices();
@@ -191,10 +232,11 @@ namespace mln
template <typename P>
inline
- const box<P>&
- p_graph<P>::bbox() const
+ bool
+ p_graph<P>::is_valid() const
{
- return bb_;
+ // FIXME: Might be too low-level, again.
+ return gr_.ptr_;
}
template <typename P>
@@ -202,11 +244,39 @@ namespace mln
bool
p_graph<P>::has(const psite& p) const
{
+ mln_precondition(is_valid());
return
// Check whether P is compatible with this psite set.
- (&p.pg() == this) &&
- // Check that the vertex id of P belongs to the range of valid vertex ids.
- (p.id() < gr_->nvertices());
+ (p.target_() == this) &&
+ // Check that the vertex id of P belongs to the range of valid
+ // vertex ids.
+ (p.is_valid());
+ }
+
+ template <typename P>
+ inline
+ std::size_t
+ p_graph<P>::memory_size() const
+ {
+ // FIXME: Dummy; implement (see other site sets).
+ abort();
+ return 0;
+ }
+
+ template <typename P>
+ const typename p_graph<P>::graph&
+ p_graph<P>::gr() const
+ {
+ mln_precondition(is_valid());
+ return *gr_.ptr;
+ }
+
+ template <typename P>
+ typename p_graph<P>::graph&
+ p_graph<P>::gr()
+ {
+ mln_precondition(is_valid());
+ return *gr_.ptr;
}
template <typename P>
@@ -301,25 +371,15 @@ namespace mln
return adjacent(lhs, rhs);
}
- template <typename P>
- const typename p_graph<P>::graph&
- p_graph<P>::to_graph() const
- {
- return this->gr_;
- }
-
- template <typename P>
- typename p_graph<P>::graph&
- p_graph<P>::to_graph()
- {
- return this->gr_;
- }
-
template <typename P>
bool
operator==(const p_graph<P>& lhs, const p_graph<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.gr_.ptr_ == rhs.gr_.ptr_;
}
--
1.5.6.5
1
0
* mln/core/complex_iter.hh: More documentation.
* mln/core/image/complex_image.hh
(mln::internal::data< complex_image<D, P, V> >):
Update properties.
(mln::complex_image<D, P, V>): Fix access to members.
(mln::complex_image<D, P, V>::super_): Remove typedef.
* tests/core/image/complex_image.: Catch up with the current
interfaces of mln::complex_psite and mln::faces_psite.
* tests/core/image/Makefile.am (check_PROGRAMS): Re-enable
complex_image.
(complex_image_SOURCES): Re-enable.
---
milena/ChangeLog | 16 +++++++++++
milena/mln/core/complex_iter.hh | 9 ++++++
milena/mln/core/image/complex_image.hh | 42 +++++++++++++++++------------
milena/tests/core/image/Makefile.am | 4 +-
milena/tests/core/image/complex_image.cc | 8 +++---
5 files changed, 56 insertions(+), 23 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index ee684ea..ba324e4 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,21 @@
2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+ Update complex-based image.
+
+ * mln/core/complex_iter.hh: More documentation.
+ * mln/core/image/complex_image.hh
+ (mln::internal::data< complex_image<D, P, V> >):
+ Update properties.
+ (mln::complex_image<D, P, V>): Fix access to members.
+ (mln::complex_image<D, P, V>::super_): Remove typedef.
+ * tests/core/image/complex_image.: Catch up with the current
+ interfaces of mln::complex_psite and mln::faces_psite.
+ * tests/core/image/Makefile.am (check_PROGRAMS): Re-enable
+ complex_image.
+ (complex_image_SOURCES): Re-enable.
+
+2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+
Update iterators on p_complex.
* mln/core/internal/p_complex_piter_base.hh
diff --git a/milena/mln/core/complex_iter.hh b/milena/mln/core/complex_iter.hh
index ba2731e..1e60fe0 100644
--- a/milena/mln/core/complex_iter.hh
+++ b/milena/mln/core/complex_iter.hh
@@ -33,6 +33,9 @@
# include <mln/core/internal/complex_iter_base.hh>
+// FIXME: Factor a bit more? (Using complex_iter_base_.)
+
+
namespace mln
{
@@ -52,7 +55,10 @@ namespace mln
complex_fwd_iter_<D> >
{
public:
+ /// Type of associated face.
typedef any_face_handle<D> face;
+ // FIXME: Rename as dim?
+ /// Dimension of the complex.
static const unsigned complex_dim = D;
private:
@@ -103,7 +109,10 @@ namespace mln
complex_bkd_iter_<D> >
{
public:
+ /// Type of associated face.
typedef any_face_handle<D> face;
+ // FIXME: Rename as dim?
+ /// Dimension of the complex.
static const unsigned complex_dim = D;
private:
diff --git a/milena/mln/core/image/complex_image.hh b/milena/mln/core/image/complex_image.hh
index 3923454..6dbc522 100644
--- a/milena/mln/core/image/complex_image.hh
+++ b/milena/mln/core/image/complex_image.hh
@@ -50,8 +50,8 @@
namespace mln
{
- // Fwd decl.
- template <unsigned D, typename P, typename V> struct complex_image;
+ // Forward declaration.
+ template <unsigned D, typename P, typename V> class complex_image;
namespace internal
{
@@ -80,16 +80,25 @@ namespace mln
typedef trait::image::category::primary category;
// FIXME: Is that right?
- typedef trait::image::access::random access;
- typedef typename trait::image::space_from_point<P>::ret space;
- typedef trait::image::size::regular size;
- typedef trait::image::support::irregular support;
-
- typedef trait::image::border::none border;
- typedef trait::image::data::stored data;
- typedef trait::image::io::read_write io;
+ typedef trait::image::speed::fast speed;
+ typedef trait::image::size::regular size;
+
+ // Value.
+ typedef trait::image::value_access::direct value_access;
// FIXME: Is that right?
- typedef trait::image::speed::fast speed;
+ typedef trait::image::value_storage::one_block value_storage;
+ typedef trait::image::value_browsing::site_wise_only value_browsing;
+ typedef trait::image::value_io::read_write value_io;
+
+ // Site / domain.
+ typedef trait::image::localization::space localization;
+ // FIXME: Likewise.
+ typedef typename trait::image::space_from_point<P>::ret dimension;
+
+ // Extended domain.
+ typedef trait::image::ext_domain::none ext_domain;
+ typedef trait::image::ext_value::irrelevant ext_value;
+ typedef trait::image::ext_io::irrelevant ext_io;
};
} // end of namespace mln::trait
@@ -99,13 +108,11 @@ namespace mln
///
/// Values are stored on the vertices of the graph.
template <unsigned D, typename P, typename V>
- struct complex_image :
- public internal::image_primary_< V, p_complex<D, P>, complex_image<D,P,V> >
+ class complex_image
+ : public internal::image_primary< V, p_complex<D, P>,
+ complex_image<D, P, V> >
{
- /// Super type.
- typedef mln::internal::image_base_< p_complex<D, P>,
- complex_image<D, P, V> > super_;
-
+ public:
/// Value associated type.
typedef V value;
@@ -123,6 +130,7 @@ namespace mln
/// Skeleton.
typedef complex_image< D, tag::psite_<P>, tag::value_<V> > skeleton;
+ public:
/// Constructors.
/// \{
complex_image();
diff --git a/milena/tests/core/image/Makefile.am b/milena/tests/core/image/Makefile.am
index 5c7e6ac..583cbba 100644
--- a/milena/tests/core/image/Makefile.am
+++ b/milena/tests/core/image/Makefile.am
@@ -5,7 +5,7 @@ include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
## bgraph_image \
cast_image \
-## complex_image \
+ complex_image \
decorated_image \
flat_image \
## hexa \
@@ -33,7 +33,7 @@ check_PROGRAMS = \
##bgraph_image_SOURCES = bgraph_image.cc
cast_image_SOURCES = cast_image.cc
-##complex_image_SOURCES = complex_image.cc
+complex_image_SOURCES = complex_image.cc
decorated_image_SOURCES = decorated_image.cc
##graph_image_SOURCES = graph_image.cc
##graph_image_wst_SOURCES = graph_image_wst.cc
diff --git a/milena/tests/core/image/complex_image.cc b/milena/tests/core/image/complex_image.cc
index 44a62f0..7711f38 100644
--- a/milena/tests/core/image/complex_image.cc
+++ b/milena/tests/core/image/complex_image.cc
@@ -146,7 +146,7 @@ int main()
face_handle<1, D> e0_(pc.cplx(), 0);
any_face_handle<D> af(e0_);
// An associated psite.
- complex_psite<D, point2d> cs(af);
+ complex_psite<D, point2d> cs(pc, af);
/*--------------------.
@@ -161,9 +161,9 @@ int main()
p_faces<2, D, point2d> pf2(c);
// Some psites on faces.
- faces_psite<0, D, point2d> fs0(v0);
- faces_psite<1, D, point2d> fs1(e0);
- faces_psite<2, D, point2d> fs2(t0);
+ faces_psite<0, D, point2d> fs0(pf0, v0);
+ faces_psite<1, D, point2d> fs1(pf1, e0);
+ faces_psite<2, D, point2d> fs2(pf2, t0);
/*----------------------.
--
1.6.0.1
1
0
* mln/core/internal/p_complex_piter_base.hh
(mln::p_complex_piter_base_<D, P>): Inherit
from internal::site_set_iterator_base.
(mln::p_complex_piter_base_<D, P>::super_): Update typedef.
(mln::p_complex_piter_base_<D, P>::complex_dim): New constant.
(mln::p_complex_piter_base_<D, P>::pset)
(mln::p_complex_piter_base_<D, P>::psite):
Remove typedefs.
(mln::p_complex_piter_base_<D, P>::p_complex_piter_base_):
New default ctor.
(mln::p_complex_piter_base_<D, P>::p_complex_piter_base_(const self&)):
Remove copy ctor.
(mln::p_complex_piter_base_<D, P>::p_complex_piter_base_):
Update other ctor.
(mln::p_complex_piter_base_<D, P>::operator=(const self&)):
Remove operator.
(mln::p_complex_piter_base_<D, P>::next_)
(mln::p_complex_piter_base_<D, P>::update_):
Update methods.
(mln::p_complex_piter_base_<D, P>::is_valid)
(mln::p_complex_piter_base_<D, P>::invalidate)
(mln::p_complex_piter_base_<D, P>::start):
Likewise.
Rename as...
(mln::p_complex_piter_base_<D, P>::is_valid_)
(mln::p_complex_piter_base_<D, P>::invalidate_)
(mln::p_complex_piter_base_<D, P>::start_):
...these.
(mln::p_complex_piter_base_<D, P>::to_point)
(mln::p_complex_piter_base_<D, P>::to_psite)
(mln::p_complex_piter_base_<D, P>::operator psite)
(mln::p_complex_piter_base_<D, P>::operator[]):
Remove methods.
(operator<<(std::ostream&, const p_complex_piter_base_<I, P, E>&)):
Update.
(mln::p_complex_piter_base_<D, P>::p_): Get it from the super
class.
(mln::p_complex_piter_base_<D, P>::psite): Remove attribute.
* mln/core/site_set/p_complex_piter.hh:
(mln::p_complex_fwd_piter_<D, P>::p_complex_fwd_piter_)
(mln::p_complex_bkd_piter_<D, P>::p_complex_bkd_piter_):
New default ctors.
(mln::p_complex_fwd_piter_<D, P>::p_complex_fwd_piter_)
(mln::p_complex_bkd_piter_<D, P>::p_complex_bkd_piter_):
Adjust other ctor.
(mln::p_complex_fwd_piter_<D, P>::p_complex_fwd_piter_(const self_&))
(mln::p_complex_bkd_piter_<D, P>::p_complex_bkd_piter_(const self_&))
(mln::p_complex_fwd_piter_<D, P>::operator=(const self_&))
(mln::p_complex_bkd_piter_<D, P>::operator=(const self_&)):
Remove.
---
milena/ChangeLog | 55 +++++++
milena/mln/core/internal/p_complex_piter_base.hh | 173 +++++-----------------
milena/mln/core/site_set/p_complex_piter.hh | 44 +-----
3 files changed, 103 insertions(+), 169 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 583ddc0..ee684ea 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,60 @@
2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+ Update iterators on p_complex.
+
+ * mln/core/internal/p_complex_piter_base.hh
+ (mln::p_complex_piter_base_<D, P>): Inherit
+ from internal::site_set_iterator_base.
+ (mln::p_complex_piter_base_<D, P>::super_): Update typedef.
+ (mln::p_complex_piter_base_<D, P>::complex_dim): New constant.
+ (mln::p_complex_piter_base_<D, P>::pset)
+ (mln::p_complex_piter_base_<D, P>::psite):
+ Remove typedefs.
+ (mln::p_complex_piter_base_<D, P>::p_complex_piter_base_):
+ New default ctor.
+ (mln::p_complex_piter_base_<D, P>::p_complex_piter_base_(const self&)):
+ Remove copy ctor.
+ (mln::p_complex_piter_base_<D, P>::p_complex_piter_base_):
+ Update other ctor.
+ (mln::p_complex_piter_base_<D, P>::operator=(const self&)):
+ Remove operator.
+ (mln::p_complex_piter_base_<D, P>::next_)
+ (mln::p_complex_piter_base_<D, P>::update_):
+ Update methods.
+ (mln::p_complex_piter_base_<D, P>::is_valid)
+ (mln::p_complex_piter_base_<D, P>::invalidate)
+ (mln::p_complex_piter_base_<D, P>::start):
+ Likewise.
+ Rename as...
+ (mln::p_complex_piter_base_<D, P>::is_valid_)
+ (mln::p_complex_piter_base_<D, P>::invalidate_)
+ (mln::p_complex_piter_base_<D, P>::start_):
+ ...these.
+ (mln::p_complex_piter_base_<D, P>::to_point)
+ (mln::p_complex_piter_base_<D, P>::to_psite)
+ (mln::p_complex_piter_base_<D, P>::operator psite)
+ (mln::p_complex_piter_base_<D, P>::operator[]):
+ Remove methods.
+ (operator<<(std::ostream&, const p_complex_piter_base_<I, P, E>&)):
+ Update.
+ (mln::p_complex_piter_base_<D, P>::p_): Get it from the super
+ class.
+ (mln::p_complex_piter_base_<D, P>::psite): Remove attribute.
+ * mln/core/site_set/p_complex_piter.hh:
+ (mln::p_complex_fwd_piter_<D, P>::p_complex_fwd_piter_)
+ (mln::p_complex_bkd_piter_<D, P>::p_complex_bkd_piter_):
+ New default ctors.
+ (mln::p_complex_fwd_piter_<D, P>::p_complex_fwd_piter_)
+ (mln::p_complex_bkd_piter_<D, P>::p_complex_bkd_piter_):
+ Adjust other ctor.
+ (mln::p_complex_fwd_piter_<D, P>::p_complex_fwd_piter_(const self_&))
+ (mln::p_complex_bkd_piter_<D, P>::p_complex_bkd_piter_(const self_&))
+ (mln::p_complex_fwd_piter_<D, P>::operator=(const self_&))
+ (mln::p_complex_bkd_piter_<D, P>::operator=(const self_&)):
+ Remove.
+
+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
diff --git a/milena/mln/core/internal/p_complex_piter_base.hh b/milena/mln/core/internal/p_complex_piter_base.hh
index a9d5f6d..c9787c1 100644
--- a/milena/mln/core/internal/p_complex_piter_base.hh
+++ b/milena/mln/core/internal/p_complex_piter_base.hh
@@ -32,16 +32,14 @@
/// \brief Definition of an implementation (factoring) class for
/// iterators on mln::p_complex.
-# include <limits>
-
-# include <mln/core/internal/point_iterator_base.hh>
-# include <mln/core/p_complex.hh>
+# include <mln/core/internal/site_set_iterator_base.hh>
+# include <mln/core/site_set/p_complex.hh>
# include <mln/core/complex_psite.hh>
# include <mln/core/complex_iter.hh>
+
namespace mln
{
- /* FIXME: Get rid of P? */
// Forward declarations.
template <unsigned D, typename P> class p_complex;
@@ -57,75 +55,58 @@ namespace mln
/// \brief Factoring class for iterators on mln::p_complex.
///
/// \arg \p I The type of the underlying complex iterator.
- /// \arg \p P The associated point type.
+ /// \arg \p P The associated site type.
/// \arg \p E The type exact type of the iterator.
template <typename I, typename P, typename E>
- class p_complex_piter_base_ : public point_iterator_base_< P, E >
+ class p_complex_piter_base_
+ : public internal::site_set_iterator_base< p_complex<I::complex_dim, P>,
+ p_complex_piter_base_<I, P, E> >
{
+ static const unsigned D = I::complex_dim;
+
typedef p_complex_piter_base_<I, P, E> self_;
- typedef point_iterator_base_< P, E > super_;
+ typedef internal::site_set_iterator_base< p_complex<D, P>,
+ self_ > super_;
/// The type of the underlying complex iterator.
typedef I iter;
public:
- typedef p_complex<iter::complex_dim, P> pset;
- typedef complex_psite<iter::complex_dim, P> psite;
- typedef P point;
- typedef mln_coord(point) coord;
-
/// Construction and assignment.
/// \{
- p_complex_piter_base_(const pset& pc);
- p_complex_piter_base_(const self_& rhs);
- self_& operator= (const self_& rhs);
+ p_complex_piter_base_();
+ p_complex_piter_base_(const p_complex<D, P>& pc);
/// \}
/// Manipulation.
/// \{
+ public:
/// Test if the iterator is valid.
- bool is_valid() const;
+ bool is_valid_() const;
/// Invalidate the iterator.
- void invalidate();
- /// Start an iteration.
- void start();
+ void invalidate_();
+ /// Start an iteration.
+ void start_();
/// Go to the next point.
void next_();
- /// Update the internal data of the iterator.
+
+ private:
+ /// Update the psite.
void update_();
/// \}
- /// Conversion and accessors.
- /// \{
- /// Reference to the corresponding point.
- // FIXME: Don't use this method (dummy value).
- const point& to_point () const;
- /// Reference to the corresponding point site.
- const psite& to_psite () const;
- /// Convert the iterator into a line graph psite.
- operator psite() const;
-
- /// Read-only access to the \a i-th coordinate.
- // FIXME: Don't use this operator (dummy value).
- coord operator[](unsigned i) const;
- /// \}
+ protected:
+ /// The psite corresponding to this iterator.
+ using super_::p_;
private:
/// The underlying complex iterator.
iter iter_;
- /// The psite corresponding to this iterator.
- psite psite_;
- /// \brief The point associated to this psite.
- // FIXME: Actually, this is a dummy value!
- point p_;
};
- /* 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. */
+ /// Print an mln::p_complex_piter_base_<I, P, E>.
template <typename I, typename P, typename E>
inline
std::ostream&
@@ -133,7 +114,6 @@ namespace mln
-
# ifndef MLN_INCLUDE_ONLY
/*---------------------------------.
@@ -142,50 +122,24 @@ namespace mln
template <typename I, typename P, typename E>
inline
- p_complex_piter_base_<I, P, E>::p_complex_piter_base_(const pset& pc)
- // Initialize psite_ and p_ a dummy values.
- : psite_(),
- p_()
- {
- iter_.set_cplx(pc.cplx());
- mln_postcondition(!is_valid());
- }
-
- template <typename I, typename P, typename E>
- inline
- p_complex_piter_base_<I, P, E>::p_complex_piter_base_(const p_complex_piter_base_<I, P, E>& rhs)
- : iter_(rhs.iter_),
- psite_(rhs.psite_),
- // Dummy value.
- p_()
- {
- }
-
- template <typename I, typename P, typename E>
- inline
- p_complex_piter_base_<I, P, E>&
- p_complex_piter_base_<I, P, E>::operator=(const p_complex_piter_base_<I, P, E>& rhs)
+ p_complex_piter_base_<I, P, E>::p_complex_piter_base_()
{
- if (&rhs == this)
- return *this;
- iter_ = rhs.iter_;
- psite_ = rhs.psite_;
- return *this;
+ mln_postcondition(!this->is_valid());
}
template <typename I, typename P, typename E>
inline
- mln_coord(P)
- p_complex_piter_base_<I, P, E>::operator[](unsigned i) const
+ p_complex_piter_base_<I, P, E>::p_complex_piter_base_(const p_complex<D, P>& pc)
{
- // Dummy value.
- return p_[i];
+ this->change_target(pc);
+ iter_.set_cplx(pc.cplx());
+ mln_postcondition(!this->is_valid());
}
template <typename I, typename P, typename E>
inline
bool
- p_complex_piter_base_<I, P, E>::is_valid() const
+ p_complex_piter_base_<I, P, E>::is_valid_() const
{
return iter_.is_valid();
}
@@ -193,7 +147,7 @@ namespace mln
template <typename I, typename P, typename E>
inline
void
- p_complex_piter_base_<I, P, E>::invalidate()
+ p_complex_piter_base_<I, P, E>::invalidate_()
{
iter_.invalidate();
}
@@ -201,10 +155,11 @@ namespace mln
template <typename I, typename P, typename E>
inline
void
- p_complex_piter_base_<I, P, E>::start()
+ p_complex_piter_base_<I, P, E>::start_()
{
iter_.start();
- update_();
+ if (this->is_valid())
+ update_();
}
template <typename I, typename P, typename E>
@@ -213,7 +168,7 @@ namespace mln
p_complex_piter_base_<I, P, E>::next_()
{
iter_.next_();
- if (is_valid())
+ if (this->is_valid())
update_();
}
@@ -222,44 +177,9 @@ namespace mln
void
p_complex_piter_base_<I, P, E>::update_()
{
+ mln_precondition(this->is_valid());
// Update psite_.
- psite_ = psite(iter_);
- }
-
- template <typename I, typename P, typename E>
- inline
- const P&
- p_complex_piter_base_<I, P, E>::to_point() const
- {
- // Dummy value.
- return p_;
- }
-
- template <typename I, typename P, typename E>
- inline
- const typename p_complex_piter_base_<I, P, E>::psite&
- p_complex_piter_base_<I, P, E>::to_psite() const
- {
- /* We don't check whether the iterator is valid before returning
- the value using
-
- mln_precondition(is_valid());
-
- since this method may be called *before* the iterator is
- actually initialized. This is the case for instance when this
- point iterator (say, P) is used to initialize another iterator
- on window or neighborhood (say, Q); most of the time, for_all()
- is responsible for the initialization of P, but it takes place
- *after* the creation of Q. */
- return psite_;
- }
-
- template <typename I, typename P, typename E>
- inline
- p_complex_piter_base_<I, P, E>::operator psite() const
- {
- mln_precondition(is_valid());
- return psite_;
+ p_ = complex_psite<D, P>(exact(this)->site_set(), iter_);
}
@@ -268,20 +188,7 @@ namespace mln
std::ostream&
operator<<(std::ostream& ostr, const p_complex_piter_base_<I, P, E>& p)
{
- /* FIXME: We should use p.to_psite() here, but as it lacks the
- precondition the conversion operator has, so we use the latter.
-
- We should
- - rename `to_psite' as `to_psite_';
- - write a new `to_psite' routine checking the validity of the
- iterator;
- - have the conversion operator to psite use this new `to_psite'
- routine;
- - adjust former clients of `to_psite'
-
- This is a general remark that applies to all point/psite
- iterators of Milena. */
- return ostr << static_cast< mln_psite(E) >(p);
+ return ostr << p.unproxy_();
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/site_set/p_complex_piter.hh b/milena/mln/core/site_set/p_complex_piter.hh
index 817306e..7cde5bf 100644
--- a/milena/mln/core/site_set/p_complex_piter.hh
+++ b/milena/mln/core/site_set/p_complex_piter.hh
@@ -35,8 +35,6 @@
namespace mln
{
- /* FIXME: Get rid of P? */
-
/*-----------------------------.
| p_complex_fwd_piter_<D, P>. |
@@ -56,9 +54,8 @@ namespace mln
public:
/// Construction and assignment.
/// \{
+ p_complex_fwd_piter_();
p_complex_fwd_piter_(const p_complex<D, P>& pc);
- p_complex_fwd_piter_(const self_& rhs);
- self_& operator= (const self_& rhs);
/// \}
};
@@ -81,9 +78,8 @@ namespace mln
public:
/// Construction and assignment.
/// \{
+ p_complex_bkd_piter_();
p_complex_bkd_piter_(const p_complex<D, P>& pc);
- p_complex_bkd_piter_(const self_& rhs);
- self_& operator= (const self_& rhs);
/// \}
};
@@ -97,27 +93,15 @@ namespace mln
template <unsigned D, typename P>
inline
- p_complex_fwd_piter_<D, P>::p_complex_fwd_piter_(const p_complex<D, P>& pc)
- : super_(pc)
- {
- }
-
- template <unsigned D, typename P>
- inline
- p_complex_fwd_piter_<D, P>::p_complex_fwd_piter_(const p_complex_fwd_piter_<D, P>& rhs)
- : super_(rhs)
+ p_complex_fwd_piter_<D, P>::p_complex_fwd_piter_()
{
}
template <unsigned D, typename P>
inline
- p_complex_fwd_piter_<D, P>&
- p_complex_fwd_piter_<D, P>::operator=(const p_complex_fwd_piter_<D, P>& rhs)
+ p_complex_fwd_piter_<D, P>::p_complex_fwd_piter_(const p_complex<D, P>& pc)
+ : super_(pc)
{
- if (&rhs == this)
- return *this;
- super_::operator=(rhs);
- return *this;
}
@@ -127,27 +111,15 @@ namespace mln
template <unsigned D, typename P>
inline
- p_complex_bkd_piter_<D, P>::p_complex_bkd_piter_(const p_complex<D, P>& pc)
- : super_(pc)
+ p_complex_bkd_piter_<D, P>::p_complex_bkd_piter_()
{
}
template <unsigned D, typename P>
inline
- p_complex_bkd_piter_<D, P>::p_complex_bkd_piter_(const p_complex_bkd_piter_<D, P>& rhs)
- : super_(rhs)
- {
- }
-
- template <unsigned D, typename P>
- inline
- p_complex_bkd_piter_<D, P>&
- p_complex_bkd_piter_<D, P>::operator=(const p_complex_bkd_piter_<D, P>& rhs)
+ p_complex_bkd_piter_<D, P>::p_complex_bkd_piter_(const p_complex<D, P>& pc)
+ : super_(pc)
{
- if (&rhs == this)
- return *this;
- super_::operator=(rhs);
- return *this;
}
# endif // ! MLN_INCLUDE_ONLY
--
1.6.0.1
1
0
* 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