2297: Update line graph neighborhood & window piters.

* mln/core/internal/line_graph_vicinity_piter.hh (mln::internal::line_graph_vicinity_piter_<P, S, E>): Inherit from internal::site_relative_iterator_base. (line_graph_vicinity_piter_<P, S, E>::line_graph_vicinity_piter_): New default ctor. Adjust other ctors. (mln::internal::line_graph_vicinity_piter_<P, S, E>::super_) (mln::internal::line_graph_vicinity_piter_<P, S, E>::psite) (mln::internal::line_graph_vicinity_piter_<P, S, E>::point) (mln::internal::line_graph_vicinity_piter_<P, S, E>::coord): Remove typedefs. (mln::internal::line_graph_vicinity_piter_<P, S, E>::to_point) (mln::internal::line_graph_vicinity_piter_<P, S, E>::to_psite) (mln::internal::line_graph_vicinity_piter_<P, S, E>::operator psite) (mln::internal::line_graph_vicinity_piter_<P, S, E>::p_ref) (mln::internal::line_graph_vicinity_piter_<P, S, E>::plg) (mln::internal::line_graph_vicinity_piter_<P, S, E>::p_hook_) (mln::internal::line_graph_vicinity_piter_<P, S, E>::operator[]): Remove methods. (mln::internal::line_graph_vicinity_piter_<P, S, E>::p_ref_) (mln::internal::line_graph_vicinity_piter_<P, S, E>::saved_p_ref_) (mln::internal::line_graph_vicinity_piter_<P, S, E>::psite_) (mln::internal::line_graph_vicinity_piter_<P, S, E>::p_): Remove attributes. * mln/core/image/line_graph_neighborhood_piter.hh * mln/core/image/line_graph_window_piter.hh (mln::line_graph_neighborhood_fwd_piter<P, N>::psite) (mln::line_graph_neighborhood_bkd_piter<P, N>::psite) (mln::line_graph_window_fwd_piter<P, W>::psite) (mln::line_graph_window_bkd_piter<P, W>::psite): New typdefs. (mln::line_graph_neighborhood_fwd_piter<P, N>) (mln::line_graph_neighborhood_bkd_piter<P, N>) (mln::line_graph_window_fwd_piter<P, W>) (mln::line_graph_window_bkd_piter<P, W>): New default ctors. Adjust other ctors to the new interface of mln::line_graph_vicinity_piter_. (mln::line_graph_neighborhood_fwd_piter<P, N>::is_valid_) (mln::line_graph_neighborhood_bkd_piter<P, N>::is_valid_) (mln::line_graph_window_fwd_piter<P, W>::is_valid_) (mln::line_graph_window_bkd_piter<P, W>::is_valid_): Adjust to the new interface of mln::line_graph_vicinity_piter_. (mln::line_graph_neighborhood_fwd_piter<P, N>::start) (mln::line_graph_neighborhood_bkd_piter<P, N>::start) (mln::line_graph_window_fwd_piter<P, W>::start) (mln::line_graph_window_bkd_piter<P, W>::start) (mln::line_graph_neighborhood_fwd_piter<P, N>::next) (mln::line_graph_neighborhood_bkd_piter<P, N>::next) (mln::line_graph_window_fwd_piter<P, W>::next) (mln::line_graph_window_bkd_piter<P, W>::next): Likewise. Rename as... (mln::line_graph_neighborhood_fwd_piter<P, N>::do_start_) (mln::line_graph_neighborhood_bkd_piter<P, N>::do_start_) (mln::line_graph_window_fwd_piter<P, W>::do_start_) (mln::line_graph_window_bkd_piter<P, W>::do_start_) (mln::line_graph_neighborhood_fwd_piter<P, N>::do_next_) (mln::line_graph_neighborhood_bkd_piter<P, N>::do_next_) (mln::line_graph_window_fwd_piter<P, W>::do_next_) (mln::line_graph_window_bkd_piter<P, W>::do_next_): ...these. (mln::line_graph_neighborhood_fwd_piter<P, N>::compute_p_) (mln::line_graph_neighborhood_bkd_piter<P, N>::compute_p_) (mln::line_graph_window_fwd_piter<P, W>::compute_p_) (mln::line_graph_window_bkd_piter<P, W>::compute_p_): New methods. (mln::line_graph_neighborhood_fwd_piter<P, N>::site) (mln::line_graph_neighborhood_bkd_piter<P, N>::site): Remove typedefs. (mln::line_graph_neighborhood_fwd_piter<P, N>::update_) (mln::line_graph_neighborhood_bkd_piter<P, N>::update_) (mln::line_graph_window_fwd_piter<P, W>::update_) (mln::line_graph_window_bkd_piter<P, W>::update_) (mln::line_graph_neighborhood_fwd_piter<P, N>::to_site) (mln::line_graph_neighborhood_bkd_piter<P, N>::to_site) (mln::line_graph_neighborhood_fwd_piter<P, N>::operator site) (mln::line_graph_neighborhood_bkd_piter<P, N>::operator site) (mln::line_graph_neighborhood_fwd_piter<P, N>::target_) (mln::line_graph_neighborhood_bkd_piter<P, N>::target_) (mln::line_graph_neighborhood_fwd_piter<P, N>::change_target) (mln::line_graph_neighborhood_bkd_piter<P, N>::change_target): Remove methods. (mln::line_graph_neighborhood_fwd_piter<P, N>::nbh_) (mln::line_graph_neighborhood_bkd_piter<P, N>::nbh_) (mln::line_graph_neighborhood_fwd_piter<P, N>::site_) (mln::line_graph_neighborhood_bkd_piter<P, N>::site_): --- milena/ChangeLog | 94 ++++++++ .../core/image/line_graph_neighborhood_piter.hh | 235 ++++---------------- milena/mln/core/image/line_graph_window_piter.hh | 140 +++++------- .../mln/core/internal/line_graph_vicinity_piter.hh | 119 ++--------- 4 files changed, 213 insertions(+), 375 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index f41074f..eaec49e 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,99 @@ 2008-09-17 Roland Levillain <roland@lrde.epita.fr> + Update line graph neighborhood & window piters. + + * mln/core/internal/line_graph_vicinity_piter.hh + (mln::internal::line_graph_vicinity_piter_<P, S, E>): + Inherit from internal::site_relative_iterator_base. + (line_graph_vicinity_piter_<P, S, E>::line_graph_vicinity_piter_): + New default ctor. + Adjust other ctors. + (mln::internal::line_graph_vicinity_piter_<P, S, E>::super_) + (mln::internal::line_graph_vicinity_piter_<P, S, E>::psite) + (mln::internal::line_graph_vicinity_piter_<P, S, E>::point) + (mln::internal::line_graph_vicinity_piter_<P, S, E>::coord): + Remove typedefs. + (mln::internal::line_graph_vicinity_piter_<P, S, E>::to_point) + (mln::internal::line_graph_vicinity_piter_<P, S, E>::to_psite) + (mln::internal::line_graph_vicinity_piter_<P, S, E>::operator psite) + (mln::internal::line_graph_vicinity_piter_<P, S, E>::p_ref) + (mln::internal::line_graph_vicinity_piter_<P, S, E>::plg) + (mln::internal::line_graph_vicinity_piter_<P, S, E>::p_hook_) + (mln::internal::line_graph_vicinity_piter_<P, S, E>::operator[]): + Remove methods. + (mln::internal::line_graph_vicinity_piter_<P, S, E>::p_ref_) + (mln::internal::line_graph_vicinity_piter_<P, S, E>::saved_p_ref_) + (mln::internal::line_graph_vicinity_piter_<P, S, E>::psite_) + (mln::internal::line_graph_vicinity_piter_<P, S, E>::p_): + Remove attributes. + + * mln/core/image/line_graph_neighborhood_piter.hh + * mln/core/image/line_graph_window_piter.hh + (mln::line_graph_neighborhood_fwd_piter<P, N>::psite) + (mln::line_graph_neighborhood_bkd_piter<P, N>::psite) + (mln::line_graph_window_fwd_piter<P, W>::psite) + (mln::line_graph_window_bkd_piter<P, W>::psite): + New typdefs. + (mln::line_graph_neighborhood_fwd_piter<P, N>) + (mln::line_graph_neighborhood_bkd_piter<P, N>) + (mln::line_graph_window_fwd_piter<P, W>) + (mln::line_graph_window_bkd_piter<P, W>): + New default ctors. + Adjust other ctors to the new interface of + mln::line_graph_vicinity_piter_. + (mln::line_graph_neighborhood_fwd_piter<P, N>::is_valid_) + (mln::line_graph_neighborhood_bkd_piter<P, N>::is_valid_) + (mln::line_graph_window_fwd_piter<P, W>::is_valid_) + (mln::line_graph_window_bkd_piter<P, W>::is_valid_): + Adjust to the new interface of mln::line_graph_vicinity_piter_. + (mln::line_graph_neighborhood_fwd_piter<P, N>::start) + (mln::line_graph_neighborhood_bkd_piter<P, N>::start) + (mln::line_graph_window_fwd_piter<P, W>::start) + (mln::line_graph_window_bkd_piter<P, W>::start) + (mln::line_graph_neighborhood_fwd_piter<P, N>::next) + (mln::line_graph_neighborhood_bkd_piter<P, N>::next) + (mln::line_graph_window_fwd_piter<P, W>::next) + (mln::line_graph_window_bkd_piter<P, W>::next): + Likewise. + Rename as... + (mln::line_graph_neighborhood_fwd_piter<P, N>::do_start_) + (mln::line_graph_neighborhood_bkd_piter<P, N>::do_start_) + (mln::line_graph_window_fwd_piter<P, W>::do_start_) + (mln::line_graph_window_bkd_piter<P, W>::do_start_) + (mln::line_graph_neighborhood_fwd_piter<P, N>::do_next_) + (mln::line_graph_neighborhood_bkd_piter<P, N>::do_next_) + (mln::line_graph_window_fwd_piter<P, W>::do_next_) + (mln::line_graph_window_bkd_piter<P, W>::do_next_): + ...these. + (mln::line_graph_neighborhood_fwd_piter<P, N>::compute_p_) + (mln::line_graph_neighborhood_bkd_piter<P, N>::compute_p_) + (mln::line_graph_window_fwd_piter<P, W>::compute_p_) + (mln::line_graph_window_bkd_piter<P, W>::compute_p_): + New methods. + (mln::line_graph_neighborhood_fwd_piter<P, N>::site) + (mln::line_graph_neighborhood_bkd_piter<P, N>::site): + Remove typedefs. + (mln::line_graph_neighborhood_fwd_piter<P, N>::update_) + (mln::line_graph_neighborhood_bkd_piter<P, N>::update_) + (mln::line_graph_window_fwd_piter<P, W>::update_) + (mln::line_graph_window_bkd_piter<P, W>::update_) + (mln::line_graph_neighborhood_fwd_piter<P, N>::to_site) + (mln::line_graph_neighborhood_bkd_piter<P, N>::to_site) + (mln::line_graph_neighborhood_fwd_piter<P, N>::operator site) + (mln::line_graph_neighborhood_bkd_piter<P, N>::operator site) + (mln::line_graph_neighborhood_fwd_piter<P, N>::target_) + (mln::line_graph_neighborhood_bkd_piter<P, N>::target_) + (mln::line_graph_neighborhood_fwd_piter<P, N>::change_target) + (mln::line_graph_neighborhood_bkd_piter<P, N>::change_target): + Remove methods. + (mln::line_graph_neighborhood_fwd_piter<P, N>::nbh_) + (mln::line_graph_neighborhood_bkd_piter<P, N>::nbh_) + (mln::line_graph_neighborhood_fwd_piter<P, N>::site_) + (mln::line_graph_neighborhood_bkd_piter<P, N>::site_): + Remove attributes. + +2008-09-17 Roland Levillain <roland@lrde.epita.fr> + Update line graph elementary neighborhood and window. * mln/core/image/line_graph_elt_neighborhood.hh, diff --git a/milena/mln/core/image/line_graph_neighborhood_piter.hh b/milena/mln/core/image/line_graph_neighborhood_piter.hh index 69ad4db..c795783 100644 --- a/milena/mln/core/image/line_graph_neighborhood_piter.hh +++ b/milena/mln/core/image/line_graph_neighborhood_piter.hh @@ -54,8 +54,13 @@ namespace mln typedef internal::line_graph_vicinity_piter_<P, N, self_> super_; public: + /// The Point_Site type. + typedef mln_psite(N) psite; + + public: /// Construction. /// \{ + line_graph_neighborhood_fwd_piter(); template <typename Pref> line_graph_neighborhood_fwd_piter(const Neighborhood<N>& nbh, const Pref& p_ref); @@ -67,36 +72,17 @@ namespace mln bool is_valid_() const; /// Invalidate the iterator. void invalidate_(); - /// Start an iteration. - void start_(); + /// 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_(); - /// Conversions. - /// \{ - /// The corresponding site type. - typedef P site; - // FIXME: Dummy. - site site_; - // FIXME: Dummy. - const site& to_site() const; - // FIXME: Dummy. - operator site() const; + /// Compute the current psite. + psite compute_p_() const; /// \} - /// Give the target neighborhood address. - const N*& target_(); - /// Change the target neighborhood. - void change_target(const N& nbh); - private: - /// The neighborhood. - const N* nbh_; - /// An iterator on the set of adjacent edges. typename super_::sites_t::const_iterator i_; }; @@ -116,8 +102,13 @@ namespace mln typedef internal::line_graph_vicinity_piter_<P, N, self_> super_; public: + /// The Point_Site type. + typedef mln_psite(N) psite; + + public: /// Construction. /// \{ + line_graph_neighborhood_bkd_piter(); template <typename Pref> line_graph_neighborhood_bkd_piter(const Neighborhood<N>& nbh, const Pref& p_ref); @@ -129,36 +120,17 @@ namespace mln bool is_valid_() const; /// Invalidate the iterator. void invalidate_(); - /// Start an iteration. - void start_(); + /// 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_(); - /// Conversions. - /// \{ - /// The corresponding site type. - typedef P site; - // FIXME: Dummy. - site site_; - // FIXME: Dummy. - const site& to_site() const; - // FIXME: Dummy. - operator site() const; + /// Compute the current psite. + psite compute_p_() const; /// \} - /// Give the target neighborhood address. - const N*& target_(); - /// Change the target neighborhood. - void change_target(const N& nbh); - private: - /// The neighborhood. - const N* nbh_; - /// An iterator on the set of adjacent edges. typename super_::sites_t::const_reverse_iterator i_; }; @@ -172,15 +144,19 @@ namespace mln `------------------------------------------*/ template <typename P, typename N> + inline + line_graph_neighborhood_fwd_piter<P, N>::line_graph_neighborhood_fwd_piter() + { + } + + template <typename P, typename N> template <typename Pref> inline line_graph_neighborhood_fwd_piter<P, N>::line_graph_neighborhood_fwd_piter(const Neighborhood<N>& nbh, const Pref& p_ref) - : super_(p_ref), - nbh_(&exact(nbh)) + : super_(p_ref) { - // Invalidate i_. - this->invalidate(); + this->change_target(exact(nbh)); } template <typename P, typename N> @@ -188,14 +164,7 @@ namespace mln bool line_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> @@ -209,96 +178,47 @@ namespace mln template <typename P, typename N> inline void - line_graph_neighborhood_fwd_piter<P, N>::start_() + line_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 (this->is_valid()) - update_(); } template <typename P, typename N> inline void - line_graph_neighborhood_fwd_piter<P, N>::next_() + line_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 (this->is_valid()) - update_(); } template <typename P, typename N> inline - void - line_graph_neighborhood_fwd_piter<P, N>::update_() + mln_psite(N) + line_graph_neighborhood_fwd_piter<P, N>::compute_p_() const { - // Update psite_. - this->psite_ = line_graph_psite<P>(this->plg(), *i_); + return line_graph_psite<P>(this->center().site_set(), *i_); } - template <typename P, typename N> - inline - const P& - line_graph_neighborhood_fwd_piter<P, N>::to_site() const - { - // FIXME: Dummy. - abort(); - return site_; - } - - template <typename P, typename N> - inline - line_graph_neighborhood_fwd_piter<P, N>::operator P() const - { - // FIXME: Dummy. - abort(); - return site_; - } - - - template <typename P, typename N> - inline - const N*& - line_graph_neighborhood_fwd_piter<P, N>::target_() - { - return nbh_; - } + /*------------------------------------------. + | line_graph_neighborhood_bkd_piter<P, N>. | + `------------------------------------------*/ template <typename P, typename N> inline - void line_graph_neighborhood_fwd_piter<P, N>::change_target(const N& nbh) + line_graph_neighborhood_bkd_piter<P, N>::line_graph_neighborhood_bkd_piter() { - nbh_ = &nbh; - this->invalidate(); } - - - /*------------------------------------------. - | line_graph_neighborhood_bkd_piter<P, N>. | - `------------------------------------------*/ - template <typename P, typename N> template <typename Pref> inline line_graph_neighborhood_bkd_piter<P, N>::line_graph_neighborhood_bkd_piter(const Neighborhood<N>& nbh, const Pref& p_ref) - : super_(p_ref), - nbh_(&exact(nbh)) + : super_(p_ref) { - // Invalidate i_. - this->invalidate(); + this->change_target(exact(nbh)); } template <typename P, typename N> @@ -306,14 +226,7 @@ namespace mln bool line_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> @@ -327,78 +240,26 @@ namespace mln template <typename P, typename N> inline void - line_graph_neighborhood_bkd_piter<P, N>::start_() + line_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 (this->is_valid()) - update_(); } template <typename P, typename N> inline void - line_graph_neighborhood_bkd_piter<P, N>::next_() + line_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 (this->is_valid()) - update_(); - } - - template <typename P, typename N> - inline - void - line_graph_neighborhood_bkd_piter<P, N>::update_() - { - // Update psite_. - this->psite_ = line_graph_psite<P>(this->plg(), *i_); - } - - - template <typename P, typename N> - inline - const P& - line_graph_neighborhood_bkd_piter<P, N>::to_site() const - { - // FIXME: Dummy. - abort(); - return site_; - } - - template <typename P, typename N> - inline - line_graph_neighborhood_bkd_piter<P, N>::operator P() const - { - // FIXME: Dummy. - abort(); - return site_; - } - - - template <typename P, typename N> - inline - const N*& - line_graph_neighborhood_bkd_piter<P, N>::target_() - { - return nbh_; } template <typename P, typename N> inline - void line_graph_neighborhood_bkd_piter<P, N>::change_target(const N& nbh) + mln_psite(N) + line_graph_neighborhood_bkd_piter<P, N>::compute_p_() const { - nbh_ = &nbh; - this->invalidate(); + return line_graph_psite<P>(this->center().site_set(), *i_); } # endif // ! MLN_INCLUDE_ONLY diff --git a/milena/mln/core/image/line_graph_window_piter.hh b/milena/mln/core/image/line_graph_window_piter.hh index 2460f9a..085346c 100644 --- a/milena/mln/core/image/line_graph_window_piter.hh +++ b/milena/mln/core/image/line_graph_window_piter.hh @@ -54,11 +54,16 @@ namespace mln typedef internal::line_graph_vicinity_piter_<P, W, self_> super_; public: + /// The Point_Site type. + typedef mln_psite(W) psite; + + public: /// Construction. /// \{ + line_graph_window_fwd_piter(); template <typename Pref> line_graph_window_fwd_piter(const Window<W>& win, - const Point_Site<Pref>& p_ref); + const Pref& p_ref); /// \} /// Manipulation. @@ -67,19 +72,17 @@ namespace mln bool is_valid_() const; /// Invalidate the iterator. void invalidate_(); - /// Start an iteration. - void start_(); + /// 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 edges. typename super_::sites_t::const_iterator i_; }; @@ -98,11 +101,16 @@ namespace mln typedef internal::line_graph_vicinity_piter_<P, W, self_> super_; public: + /// The Point_Site type. + typedef mln_psite(W) psite; + + public: /// Construction. /// \{ + line_graph_window_bkd_piter(); template <typename Pref> line_graph_window_bkd_piter(const Window<W>& win, - const Point_Site<Pref>& p_ref); + const Pref& p_ref); /// \} /// Manipulation. @@ -111,19 +119,17 @@ namespace mln bool is_valid_() const; /// Invalidate the iterator. void invalidate_(); - /// Start an iteration. - void start_(); + /// 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 edges. typename super_::sites_t::const_reverse_iterator i_; }; @@ -137,15 +143,19 @@ namespace mln `------------------------------------*/ template <typename P, typename W> + inline + line_graph_window_fwd_piter<P, W>::line_graph_window_fwd_piter() + { + } + + template <typename P, typename W> template <typename Pref> inline line_graph_window_fwd_piter<P, W>::line_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_. - this->invalidate(); + this->change_target(exact(win)); } template <typename P, typename W> @@ -153,13 +163,7 @@ namespace mln bool line_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> @@ -173,41 +177,26 @@ namespace mln template <typename P, typename W> inline void - line_graph_window_fwd_piter<P, W>::start_() + line_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 (this->is_valid()) - update_(); } template <typename P, typename W> inline void - line_graph_window_fwd_piter<P, W>::next_() + line_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 (this->is_valid()) - update_(); } template <typename P, typename W> inline - void - line_graph_window_fwd_piter<P, W>::update_() + mln_psite(W) + line_graph_window_fwd_piter<P, W>::compute_p_() const { - // Update psite_. - this->psite_ = line_graph_psite<P>(this->plg(), *i_); + return line_graph_psite<P>(this->center().site_set(), *i_); } @@ -216,15 +205,19 @@ namespace mln `------------------------------------*/ template <typename P, typename W> + inline + line_graph_window_bkd_piter<P, W>::line_graph_window_bkd_piter() + { + } + + template <typename P, typename W> template <typename Pref> inline line_graph_window_bkd_piter<P, W>::line_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_. - this->invalidate(); + this->change_target(exact(win)); } template <typename P, typename W> @@ -232,13 +225,7 @@ namespace mln bool line_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> @@ -252,41 +239,26 @@ namespace mln template <typename P, typename W> inline void - line_graph_window_bkd_piter<P, W>::start_() + line_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 (this->is_valid()) - update_(); } template <typename P, typename W> inline void - line_graph_window_bkd_piter<P, W>::next_() + line_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 (this->is_valid()) - update_(); } template <typename P, typename W> inline - void - line_graph_window_bkd_piter<P, W>::update_() + mln_psite(W) + line_graph_window_bkd_piter<P, W>::compute_p_() const { - // Update psite_. - this->psite_ = line_graph_psite<P>(this->plg(), *i_); + return line_graph_psite<P>(this->center().site_set(), *i_); } # endif // ! MLN_INCLUDE_ONLY diff --git a/milena/mln/core/internal/line_graph_vicinity_piter.hh b/milena/mln/core/internal/line_graph_vicinity_piter.hh index 5a2f699..ffb7616 100644 --- a/milena/mln/core/internal/line_graph_vicinity_piter.hh +++ b/milena/mln/core/internal/line_graph_vicinity_piter.hh @@ -39,7 +39,7 @@ # include <set> -# include <mln/core/concept/site_iterator.hh> +# include <mln/core/internal/site_relative_iterator_base.hh> # include <mln/core/site_set/p_line_graph.hh> # include <mln/core/image/line_graph_psite.hh> @@ -49,25 +49,22 @@ namespace mln template <typename P> class p_line_graph; template <typename P> class line_graph_psite; + // FIXME: Consider renaming line_graph_vicinity_piter_ as + // line_graph_relative_piter_. + namespace internal { /// \brief Base for iterator on a line graph vicinity. template <typename P, typename S, typename E> class line_graph_vicinity_piter_ - /* FIXME: We should update the interface of this class and inherit - from internal::site_relative_iterator_base< S, E > instead. */ - : public internal::site_iterator_base< S, E > + : public internal::site_relative_iterator_base< S, E > { typedef line_graph_vicinity_piter_<P, S, E> self_; - typedef Site_Iterator< self_ > super_; public: enum { dim = P::dim }; - typedef line_graph_psite<P> psite; - typedef P point; - typedef mln_coord(point) coord; // FIXME: Dummy typedef. typedef void dpoint; // FIXME: Dummy typedef. @@ -77,115 +74,46 @@ namespace mln typedef std::set<util::edge_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_line_graph corresponding to this piter. - const p_line_graph<P>& plg() const; /// Return the set of sites (adjacent edge ids). sites_t& sites(); - /* FIXME: Get rid of this as soon as this class inherits from - internal::site_relative_iterator_base< S, E >. */ - const psite& p_hook_() const; - - /// Read-only access to the \a i-th coordinate. - coord operator[](unsigned i) const; - /// \} - protected: /// Construction. /// \{ + line_graph_vicinity_piter_(); template <typename Pref> line_graph_vicinity_piter_(const Pref& p_ref); /// \} protected: - /// The ``central'' psite of the vicinity. - 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. - /* FIXME: Dummy value. To be removed as soon as the conversion - from psite to point is no longer mandatory. */ - 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 a mln::line_graph_vicinity_piter_<P, S, E>. template <typename P, typename S, typename E> inline std::ostream& - operator<<(std::ostream& ostr, const line_graph_vicinity_piter_<P, S, E>& p); + operator<<(std::ostream& ostr, + const line_graph_vicinity_piter_<P, S, E>& p); # ifndef MLN_INCLUDE_ONLY template <typename P, typename S, typename E> - template <typename Pref> - inline - line_graph_vicinity_piter_<P, S, E>::line_graph_vicinity_piter_(const Pref& p_ref) - : p_ref_(exact(p_ref)), - // Initialize psite_ to a dummy value. - psite_() - { - } - - template <typename P, typename S, typename E> - inline - const P& - line_graph_vicinity_piter_<P, S, E>::to_point() const - { - return p_; - } - - template <typename P, typename S, typename E> - inline - const line_graph_psite<P>& - line_graph_vicinity_piter_<P, S, E>::to_psite() const - { - return psite_; - } - - template <typename P, typename S, typename E> inline - line_graph_vicinity_piter_<P, S, E>::operator line_graph_psite<P> () const + line_graph_vicinity_piter_<P, S, E>::line_graph_vicinity_piter_() { - mln_precondition(exact(*this).is_valid()); - return psite_; - } - - template <typename P, typename S, typename E> - inline - const line_graph_psite<P>& - line_graph_vicinity_piter_<P, S, E>::p_ref() const - { - return p_ref_; } template <typename P, typename S, typename E> + template <typename Pref> inline - const p_line_graph<P>& - line_graph_vicinity_piter_<P, S, E>::plg() const + line_graph_vicinity_piter_<P, S, E>::line_graph_vicinity_piter_(const Pref& p_ref) { - return p_ref_.plg(); + center_at(p_ref); } template <typename P, typename S, typename E> @@ -196,30 +124,13 @@ namespace mln return sites_; } - template <typename P, typename S, typename E> - inline - const line_graph_psite<P>& - line_graph_vicinity_piter_<P, S, E>::p_hook_() const - { - return psite_; - } - - template <typename P, typename S, typename E> - inline - mln_coord(P) - line_graph_vicinity_piter_<P, S, E>::operator[](unsigned i) const - { - assert(i < dim); - return p_[i]; - } - template <typename P, typename S, typename E> inline std::ostream& operator<<(std::ostream& ostr, const line_graph_vicinity_piter_<P, S, E>& p) { - return ostr << p.to_psite(); + return ostr << p.unproxy_(); } # endif // ! MLN_INCLUDE_ONLY -- 1.6.0.1
participants (1)
-
Roland Levillain