cleanup-2008 2464: Some completion work on window and neighborhood.

https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena Index: ChangeLog from Thierry Geraud <thierry.geraud@lrde.epita.fr> Some completion work on window and neighborhood. * mln/core/neighb.hh (dp): New. (operator<<): Move to... * mln/core/concept/neighborhood.hh: ...here. Generalize it. * mln/core/concept/window.hh (todo): Done. * mln/win/multiple.hh (delta, sym): New methods. core/concept/neighborhood.hh | 17 +++++++++++++++++ core/concept/window.hh | 4 +--- core/neighb.hh | 31 ++++++++++++++++++++++++------- win/multiple.hh | 31 +++++++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 10 deletions(-) Index: mln/core/neighb.hh --- mln/core/neighb.hh (revision 2463) +++ mln/core/neighb.hh (working copy) @@ -97,6 +97,12 @@ /// center and a neighboring point. unsigned delta() const; + /// Give the maximum coordinate gap between the neighborhood + /// center and a neighboring point. + const mln_dpsite(W)& dp(unsigned i) const; + + // end of Optional methods. + /// \internal Hook to the window. W& hook_win_(); @@ -106,13 +112,6 @@ }; - template <typename W> - inline - std::ostream& operator<<(std::ostream&ostr, const neighb<W>& nbh) - { - return ostr << nbh.win(); - } - namespace convert { @@ -242,6 +241,8 @@ unsigned neighb<W>::size() const { + mlc_is(mln_trait_window_size(W), + trait::window::size::fixed)::check(); return win_.size(); } @@ -250,11 +251,27 @@ unsigned neighb<W>::delta() const { + mlc_is(mln_trait_window_support(W), + trait::window::support::regular)::check(); + mlc_is_not(mln_trait_window_definition(W), + trait::window::definition::varying)::check(); return win_.delta(); } template <typename W> inline + const mln_dpsite(W)& + neighb<W>::dp(unsigned i) const + { + mlc_is(mln_trait_window_support(W), + trait::window::support::regular)::check(); + mlc_is(mln_trait_window_definition(W), + trait::window::definition::unique)::check(); + return win_.dp(i); + } + + template <typename W> + inline W& neighb<W>::hook_win_() { Index: mln/core/concept/neighborhood.hh --- mln/core/concept/neighborhood.hh (revision 2463) +++ mln/core/concept/neighborhood.hh (working copy) @@ -78,6 +78,13 @@ + + template <typename N> + std::ostream& + operator<<(std::ostream&ostr, const Neighborhood<N>& nbh); + + + # ifndef MLN_INCLUDE_ONLY template <typename E> @@ -100,6 +107,16 @@ # endif } + + + template <typename N> + inline + std::ostream& + operator<<(std::ostream&ostr, const Neighborhood<N>& nbh) + { + return ostr << exact(nbh).win(); + } + # endif // ! MLN_INCLUDE_ONLY } // end of namespace mln Index: mln/core/concept/window.hh --- mln/core/concept/window.hh (revision 2463) +++ mln/core/concept/window.hh (working copy) @@ -32,8 +32,6 @@ * \brief Definition of the concept of mln::Window. * * \todo Operator== should test if the cmp is possible. - * - * \todo Activate run_extra() below. */ # include <mln/core/concept/object.hh> @@ -163,7 +161,7 @@ } static void run(mln::trait::window::definition::n_ary) { - // run_extra(); + run_extra(); } static void run(mln::trait::window::definition::varying) { Index: mln/win/multiple.hh --- mln/win/multiple.hh (revision 2463) +++ mln/win/multiple.hh (working copy) @@ -110,6 +110,10 @@ bool is_symmetric() const; + void sym(); + + unsigned delta() const; + private: util::array<W> win_; @@ -250,6 +254,33 @@ return true; } + + template <typename W, typename F> + inline + void + multiple<W,F>::sym() + { + mln_precondition(win_.nelements() >= 1); + for (unsigned i = 0; i < win_.nelements(); ++i) + win_[i].sym(); + } + + template <typename W, typename F> + inline + unsigned + multiple<W,F>::delta() const + { + mln_precondition(win_.nelements() >= 1); + unsigned d = win_[0].delta(); + for (unsigned i = 1; i < win_.nelements(); ++i) + { + unsigned d_i = win_[i].delta(); + if (d_i > d) + d = d_i; + } + return d; + } + // template <typename W, typename F> // inline // unsigned
participants (1)
-
Thierry Geraud