* mln/core/image/graph_neighborhood_piter.hh
(mln::graph_neighborhood_fwd_piter<P, N>)
(mln::graph_neighborhood_bkd_piter<P, N>):
Adjust to the new interface of internal::graph_vicinity_piter_.
(mln::graph_neighborhood_fwd_piter<P, N>::super_)
(mln::graph_neighborhood_bkd_piter<P, N>::super_):
Adjust.
(mln::graph_neighborhood_fwd_piter<P, N>::psite)
(mln::graph_neighborhood_bkd_piter<P, N>::psite):
New typedefs.
(mln::graph_neighborhood_fwd_piter<P, N>::graph_neighborhood_fwd_piter)
(mln::graph_neighborhood_bkd_piter<P, N>::graph_neighborhood_bkd_piter):
New default ctors.
(graph_neighborhood_fwd_piter(const Neighborhood<N>&, const
Point_Site<Pref>&))
(graph_neighborhood_bkd_piter(const Neighborhood<N>&, const
Point_Site<Pref>&)):
Turn ctors into...
(graph_neighborhood_fwd_piter(const Neighborhood<N>&, const Pref&))
(graph_neighborhood_bkd_piter(const Neighborhood<N>&, const Pref&)):
...these.
Adjust.
(mln::graph_neighborhood_fwd_piter<P, N>::is_valid)
(mln::graph_neighborhood_fwd_piter<P, N>::invalidate)
(mln::graph_neighborhood_fwd_piter<P, N>::start)
(mln::graph_neighborhood_fwd_piter<P, N>::next_)
(mln::graph_neighborhood_bkd_piter<P, N>::is_valid)
(mln::graph_neighborhood_bkd_piter<P, N>::invalidate)
(mln::graph_neighborhood_bkd_piter<P, N>::start)
(mln::graph_neighborhood_bkd_piter<P, N>::next_):
Catch up with the new interface of
internal::graph_vicinity_piter_.
Rename as...
(mln::graph_neighborhood_fwd_piter<P, N>::is_valid_)
(mln::graph_neighborhood_fwd_piter<P, N>::invalidate_)
(mln::graph_neighborhood_fwd_piter<P, N>::do_start_)
(mln::graph_neighborhood_fwd_piter<P, N>::do_next_)
(mln::graph_neighborhood_bkd_piter<P, N>::is_valid_)
(mln::graph_neighborhood_bkd_piter<P, N>::invalidate_)
(mln::graph_neighborhood_bkd_piter<P, N>::do_start_)
(mln::graph_neighborhood_bkd_piter<P, N>::do_next_):
...these.
(mln::graph_neighborhood_fwd_piter<P, N>::compute_sites_)
(mln::graph_neighborhood_bkd_piter<P, N>::compute_sites_):
New methods.
(mln::graph_neighborhood_fwd_piter<P, N>::nbh_)
(mln::graph_neighborhood_bkd_piter<P, N>::nbh_):
Remove attributes.
---
milena/ChangeLog | 51 +++++++
milena/mln/core/image/graph_neighborhood_piter.hh | 166 +++++++++------------
2 files changed, 119 insertions(+), 98 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 5ef0f52..a2e7ce6 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,56 @@
2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+ Update graph neighborhood piters.
+
+ * mln/core/image/graph_neighborhood_piter.hh
+ (mln::graph_neighborhood_fwd_piter<P, N>)
+ (mln::graph_neighborhood_bkd_piter<P, N>):
+ Adjust to the new interface of internal::graph_vicinity_piter_.
+ (mln::graph_neighborhood_fwd_piter<P, N>::super_)
+ (mln::graph_neighborhood_bkd_piter<P, N>::super_):
+ Adjust.
+ (mln::graph_neighborhood_fwd_piter<P, N>::psite)
+ (mln::graph_neighborhood_bkd_piter<P, N>::psite):
+ New typedefs.
+ (mln::graph_neighborhood_fwd_piter<P, N>::graph_neighborhood_fwd_piter)
+ (mln::graph_neighborhood_bkd_piter<P, N>::graph_neighborhood_bkd_piter):
+ New default ctors.
+ (graph_neighborhood_fwd_piter(const Neighborhood<N>&, const
Point_Site<Pref>&))
+ (graph_neighborhood_bkd_piter(const Neighborhood<N>&, const
Point_Site<Pref>&)):
+ Turn ctors into...
+ (graph_neighborhood_fwd_piter(const Neighborhood<N>&, const Pref&))
+ (graph_neighborhood_bkd_piter(const Neighborhood<N>&, const Pref&)):
+ ...these.
+ Adjust.
+ (mln::graph_neighborhood_fwd_piter<P, N>::is_valid)
+ (mln::graph_neighborhood_fwd_piter<P, N>::invalidate)
+ (mln::graph_neighborhood_fwd_piter<P, N>::start)
+ (mln::graph_neighborhood_fwd_piter<P, N>::next_)
+ (mln::graph_neighborhood_bkd_piter<P, N>::is_valid)
+ (mln::graph_neighborhood_bkd_piter<P, N>::invalidate)
+ (mln::graph_neighborhood_bkd_piter<P, N>::start)
+ (mln::graph_neighborhood_bkd_piter<P, N>::next_):
+ Catch up with the new interface of
+ internal::graph_vicinity_piter_.
+ Rename as...
+ (mln::graph_neighborhood_fwd_piter<P, N>::is_valid_)
+ (mln::graph_neighborhood_fwd_piter<P, N>::invalidate_)
+ (mln::graph_neighborhood_fwd_piter<P, N>::do_start_)
+ (mln::graph_neighborhood_fwd_piter<P, N>::do_next_)
+ (mln::graph_neighborhood_bkd_piter<P, N>::is_valid_)
+ (mln::graph_neighborhood_bkd_piter<P, N>::invalidate_)
+ (mln::graph_neighborhood_bkd_piter<P, N>::do_start_)
+ (mln::graph_neighborhood_bkd_piter<P, N>::do_next_):
+ ...these.
+ (mln::graph_neighborhood_fwd_piter<P, N>::compute_sites_)
+ (mln::graph_neighborhood_bkd_piter<P, N>::compute_sites_):
+ New methods.
+ (mln::graph_neighborhood_fwd_piter<P, N>::nbh_)
+ (mln::graph_neighborhood_bkd_piter<P, N>::nbh_):
+ Remove attributes.
+
+2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+
Update graph window piters.
* mln/core/image/graph_window_piter.hh
diff --git a/milena/mln/core/image/graph_neighborhood_piter.hh
b/milena/mln/core/image/graph_neighborhood_piter.hh
index b83099a..a39128f 100644
--- a/milena/mln/core/image/graph_neighborhood_piter.hh
+++ b/milena/mln/core/image/graph_neighborhood_piter.hh
@@ -46,39 +46,42 @@ namespace mln
template <typename P, typename N>
class graph_neighborhood_fwd_piter :
- public internal::graph_vicinity_piter_< P,
+ public internal::graph_vicinity_piter_< P, N,
graph_neighborhood_fwd_piter<P, N> >
{
typedef graph_neighborhood_fwd_piter<P, N> self_;
- typedef internal::graph_vicinity_piter_<P, self_> super_;
+ typedef internal::graph_vicinity_piter_<P, N, self_> super_;
+
+ public:
+ /// The Point_Site type.
+ typedef mln_psite(N) psite;
public:
/// Construction.
/// \{
+ graph_neighborhood_fwd_piter();
template <typename Pref>
graph_neighborhood_fwd_piter(const Neighborhood<N>& nbh,
- const Point_Site<Pref>& p_ref);
+ 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 neighborhood.
- const N& nbh_;
-
/// An iterator on the set of adjacent edges.
typename super_::sites_t::const_iterator i_;
};
@@ -90,39 +93,41 @@ namespace mln
template <typename P, typename N>
class graph_neighborhood_bkd_piter :
- public internal::graph_vicinity_piter_< P,
+ public internal::graph_vicinity_piter_< P, N,
graph_neighborhood_bkd_piter<P, N> >
{
typedef graph_neighborhood_bkd_piter<P, N> self_;
- typedef internal::graph_vicinity_piter_<P, self_> super_;
+ typedef internal::graph_vicinity_piter_<P, N, self_> super_;
+
+ /// The Point_Site type.
+ typedef mln_psite(N) psite;
public:
/// Construction.
/// \{
+ graph_neighborhood_bkd_piter();
template <typename Pref>
graph_neighborhood_bkd_piter(const Neighborhood<N>& nbh,
- const Point_Site<Pref>& p_ref);
+ 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 neighborhood.
- const N& nbh_;
-
/// An iterator on the set of adjacent edges.
typename super_::sites_t::const_reverse_iterator i_;
};
@@ -136,36 +141,33 @@ namespace mln
`-------------------------------------*/
template <typename P, typename N>
+ inline
+ graph_neighborhood_fwd_piter<P, N>::graph_neighborhood_fwd_piter()
+ {
+ }
+
+ template <typename P, typename N>
template <typename Pref>
inline
graph_neighborhood_fwd_piter<P, N>::graph_neighborhood_fwd_piter(const
Neighborhood<N>& nbh,
- const Point_Site<Pref>& p_ref)
- : super_(p_ref),
- nbh_(exact(nbh))
+ const Pref& p_ref)
+ : super_(p_ref)
{
- // Invalidate i_.
- invalidate();
+ this->change_target(exact(nbh));
}
template <typename P, typename N>
inline
bool
- graph_neighborhood_fwd_piter<P, N>::is_valid() const
+ graph_neighborhood_fwd_piter<P, N>::is_valid_() const
{
- return
- // The reference point must be valid...
- this->p_ref_.is_valid()
- // ...and must not have changed since the neighborhood 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 N>
inline
void
- graph_neighborhood_fwd_piter<P, N>::invalidate()
+ graph_neighborhood_fwd_piter<P, N>::invalidate_()
{
i_ = this->sites_.end();
}
@@ -173,41 +175,26 @@ namespace mln
template <typename P, typename N>
inline
void
- graph_neighborhood_fwd_piter<P, N>::start()
+ graph_neighborhood_fwd_piter<P, N>::do_start_()
{
- mln_precondition(this->p_ref_.is_valid());
- // Update the neighbors, if needed.
- if (!this->saved_p_ref_.is_valid() || this->p_ref_ != this->saved_p_ref_)
- {
- this->saved_p_ref_ = this->p_ref_;
- nbh_.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 N>
inline
void
- graph_neighborhood_fwd_piter<P, N>::next_()
+ graph_neighborhood_fwd_piter<P, N>::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 N>
inline
- void
- graph_neighborhood_fwd_piter<P, N>::update_()
+ mln_psite(N)
+ graph_neighborhood_fwd_piter<P, N>::compute_p_() const
{
- // Update psite_.
- this->psite_ = graph_psite<P>(this->pg(), *i_);
+ return graph_psite<P>(this->center().site_set(), *i_);
}
@@ -216,36 +203,33 @@ namespace mln
`-------------------------------------*/
template <typename P, typename N>
+ inline
+ graph_neighborhood_bkd_piter<P, N>::graph_neighborhood_bkd_piter()
+ {
+ }
+
+ template <typename P, typename N>
template <typename Pref>
inline
graph_neighborhood_bkd_piter<P, N>::graph_neighborhood_bkd_piter(const
Neighborhood<N>& nbh,
- const Point_Site<Pref>& p_ref)
- : super_(p_ref),
- nbh_(exact(nbh))
+ const Pref& p_ref)
+ : super_(p_ref)
{
- // Invalidate i_.
- invalidate();
+ this->change_target(exact(nbh));
}
template <typename P, typename N>
inline
bool
- graph_neighborhood_bkd_piter<P, N>::is_valid() const
+ graph_neighborhood_bkd_piter<P, N>::is_valid_() const
{
- return
- // The reference point must be valid...
- this->p_ref_.is_valid()
- // ...and must not have changed since the neighborhood 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 N>
inline
void
- graph_neighborhood_bkd_piter<P, N>::invalidate()
+ graph_neighborhood_bkd_piter<P, N>::invalidate_()
{
i_ = this->sites_.rend();
}
@@ -253,43 +237,29 @@ namespace mln
template <typename P, typename N>
inline
void
- graph_neighborhood_bkd_piter<P, N>::start()
+ graph_neighborhood_bkd_piter<P, N>::do_start_()
{
- mln_precondition(this->p_ref_.is_valid());
- // Update the neighbors, if needed.
- if (!this->saved_p_ref_.is_valid() || this->p_ref_ != this->saved_p_ref_)
- {
- this->saved_p_ref_ = this->p_ref_;
- nbh_.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 N>
inline
void
- graph_neighborhood_bkd_piter<P, N>::next_()
+ graph_neighborhood_bkd_piter<P, N>::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 N>
inline
- void
- graph_neighborhood_bkd_piter<P, N>::update_()
+ mln_psite(N)
+ graph_neighborhood_bkd_piter<P, N>::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
} // end of namespace mln
--
1.5.6.5