
* mln/accu/count_adjacent_vertices.hh: add missing is_valid(). * mln/canvas/labeling.hh: cleanup. * mln/labeling/relabel.hh, * mln/convert/from_to.hh: reorder declarations. * mln/linear/gaussian.hh, * mln/core/site_set/p_vaccess.hh, * mln/core/alias/complex_geometry.hh: add missing includes. * mln/registration/registration.hh, * mln/pw/cst.hh, * mln/pw/value.hh, * mln/geom/ninds.hh, * mln/fun/p2b/chess.hh, * mln/core/image/complex_neighborhood_piter.hh * mln/core/dpsites_piter.hh: update comments. * mln/win/multiple_size.hh, * mln/core/image/complex_window_piter.hh: add center_at_(). * mln/core/image/image_if.hh: move init_() implementation between MLN_INCLUDE_ONLY guards. * mln/core/internal/graph_psite_base.hh: be sure to not return a temporary object. The psite holds a site. * mln/core/routine/duplicate.hh: rename guards. * mln/fun/i2v/array.hh * mln/fun/internal/array_base.hh * mln/fun/l2l/relabel.hh: make array and relabel inherit from the proper function concept. The mutable result must be typedef-ed again in that classes. * mln/morpho/opening_area_on_vertices.hh: fix wrong prototype. * mln/registration/get_rot.hh: get rid of warnings. * mln/util/ord_pair.hh: add default constructor. * mln/util/site_pair.hh: add accessors. * tests/unit_test/Makefile.am, * tests/unit_test/mln_geom_resize.cc: update unit tests. * headers.mk: remove geom/resize.hh from distribution. --- milena/ChangeLog | 55 +++++++- milena/headers.mk | 1 - milena/mln/accu/count_adjacent_vertices.hh | 11 ++ milena/mln/canvas/labeling.hh | 8 +- milena/mln/convert/from_to.hh | 31 ++-- milena/mln/core/alias/complex_geometry.hh | 1 + milena/mln/core/dpsites_piter.hh | 2 +- .../mln/core/image/complex_neighborhood_piter.hh | 2 +- milena/mln/core/image/complex_window_piter.hh | 22 +-- milena/mln/core/image/image_if.hh | 38 +++--- milena/mln/core/internal/graph_psite_base.hh | 158 +++++++++++++++++++- milena/mln/core/routine/duplicate.hh | 31 ++-- milena/mln/core/site_set/p_vaccess.hh | 11 +- milena/mln/fun/i2v/array.hh | 9 +- milena/mln/fun/internal/array_base.hh | 53 ++++---- milena/mln/fun/l2l/relabel.hh | 9 +- milena/mln/fun/p2b/chess.hh | 10 +- milena/mln/geom/ninds.hh | 10 +- milena/mln/labeling/relabel.hh | 33 ++-- milena/mln/linear/gaussian.hh | 6 +- milena/mln/morpho/opening_area_on_vertices.hh | 2 +- milena/mln/pw/cst.hh | 8 +- milena/mln/pw/value.hh | 27 ++-- milena/mln/registration/get_rot.hh | 5 + milena/mln/registration/registration.hh | 10 +- milena/mln/util/ord_pair.hh | 18 ++- milena/mln/util/site_pair.hh | 107 ++++++++++++- milena/mln/win/multiple_size.hh | 14 ++- milena/tests/unit_test/Makefile.am | 2 - milena/tests/unit_test/mln_geom_resize.cc | 11 -- 30 files changed, 508 insertions(+), 197 deletions(-) delete mode 100644 milena/tests/unit_test/mln_geom_resize.cc diff --git a/milena/ChangeLog b/milena/ChangeLog index f5bebd3..4d6d70f 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,4 +1,57 @@ -2008-12-30 Guillaume Lazzara <z@lrde.epita.fr> +2008-12-31 Guillaume Lazzara <z@lrde.epita.fr> + + Various small fixes. + + * mln/accu/count_adjacent_vertices.hh: add missing is_valid(). + + * mln/canvas/labeling.hh: cleanup. + + * mln/labeling/relabel.hh, + * mln/convert/from_to.hh: reorder declarations. + + * mln/linear/gaussian.hh, + * mln/core/site_set/p_vaccess.hh, + * mln/core/alias/complex_geometry.hh: add missing includes. + + * mln/registration/registration.hh, + * mln/pw/cst.hh, + * mln/pw/value.hh, + * mln/geom/ninds.hh, + * mln/fun/p2b/chess.hh, + * mln/core/image/complex_neighborhood_piter.hh + * mln/core/dpsites_piter.hh: update comments. + + * mln/win/multiple_size.hh, + * mln/core/image/complex_window_piter.hh: add center_at_(). + + * mln/core/image/image_if.hh: move init_() implementation between + MLN_INCLUDE_ONLY guards. + + * mln/core/internal/graph_psite_base.hh: be sure to not return a + temporary object. The psite holds a site. + + * mln/core/routine/duplicate.hh: rename guards. + + * mln/fun/i2v/array.hh + * mln/fun/internal/array_base.hh + * mln/fun/l2l/relabel.hh: make array and relabel inherit from the + proper function concept. The mutable result must be typedef-ed again + in that classes. + + * mln/morpho/opening_area_on_vertices.hh: fix wrong prototype. + + * mln/registration/get_rot.hh: get rid of warnings. + + * mln/util/ord_pair.hh: add default constructor. + + * mln/util/site_pair.hh: add accessors. + + * tests/unit_test/Makefile.am, + * tests/unit_test/mln_geom_resize.cc: update unit tests. + + * mln/accu/count_adjacent_vertices.hh: add missing is_valid(). + +2008-12-31 Guillaume Lazzara <z@lrde.epita.fr> Rename mln_sum_x to mln_sum_product. diff --git a/milena/headers.mk b/milena/headers.mk index faea509..8cd49e1 100644 --- a/milena/headers.mk +++ b/milena/headers.mk @@ -21,7 +21,6 @@ mln/geom/size3d.hh \ mln/geom/ninds.hh \ mln/geom/nslis.hh \ mln/geom/delta.hh \ -mln/geom/resize.hh \ mln/geom/nsites.hh \ mln/geom/min_col.hh \ mln/geom/complex_geometry.hh \ diff --git a/milena/mln/accu/count_adjacent_vertices.hh b/milena/mln/accu/count_adjacent_vertices.hh index 382e509..9d1f7b3 100644 --- a/milena/mln/accu/count_adjacent_vertices.hh +++ b/milena/mln/accu/count_adjacent_vertices.hh @@ -76,6 +76,9 @@ namespace mln /// Get the value of the accumulator. unsigned to_result() const; + /// Return whether this accu can return a result. + bool is_valid() const; + protected: /// Update the value of the counter. void update_ (); @@ -168,6 +171,14 @@ namespace mln count__ = vertices_.size(); } + template <typename F, typename S> + inline + bool + count_adjacent_vertices<F,S>::is_valid() const + { + return true; + } + # endif // ! MLN_INCLUDE_ONLY } // end of namespace mln::accu diff --git a/milena/mln/canvas/labeling.hh b/milena/mln/canvas/labeling.hh index 6702ee0..fb539f7 100644 --- a/milena/mln/canvas/labeling.hh +++ b/milena/mln/canvas/labeling.hh @@ -196,7 +196,7 @@ namespace mln trace::exiting("canvas::impl::generic::labeling"); return output; } - + } // end of namespace mln::canvas::impl::generic } // end of namespace mln::canvas::impl @@ -385,12 +385,12 @@ namespace mln F& functor, L& nlabels) { trace::entering("canvas::labeling"); - + internal::labeling_tests(input, nbh, functor, nlabels); - + mln_ch_value(I, L) output; output = internal::labeling_dispatch(input, nbh, functor, nlabels); - + trace::exiting("canvas::labeling"); return output; } diff --git a/milena/mln/convert/from_to.hh b/milena/mln/convert/from_to.hh index 8e3510a..e86e73a 100644 --- a/milena/mln/convert/from_to.hh +++ b/milena/mln/convert/from_to.hh @@ -67,22 +67,6 @@ namespace mln namespace internal { - - // Default dispatch if the two arguments are objects. - - // Object -> Object - template <typename F, typename T> - inline - void - from_to_dispatch(const Object<F>& from, Object<T>& to) - { - typedef mlc_converts_to(F, T) F_converts_to_T; - internal::from_to_dispatch(F_converts_to_T(), - exact(from), exact(to)); - } - - - // Dispatch to specific implementation. // Image -> Site_Set. @@ -133,6 +117,21 @@ namespace mln + // Default dispatch if the two arguments are objects. + + // Object -> Object + template <typename F, typename T> + inline + void + from_to_dispatch(const Object<F>& from, Object<T>& to) + { + typedef mlc_converts_to(F, T) F_converts_to_T; + internal::from_to_dispatch(F_converts_to_T(), + exact(from), exact(to)); + } + + + // Dispatch entry points. // Check whether arguments are an object or not. diff --git a/milena/mln/core/alias/complex_geometry.hh b/milena/mln/core/alias/complex_geometry.hh index 44fa899..2ba0362 100644 --- a/milena/mln/core/alias/complex_geometry.hh +++ b/milena/mln/core/alias/complex_geometry.hh @@ -33,6 +33,7 @@ /// Definition of mln::geom::complex_geometry aliases. # include <mln/geom/complex_geometry.hh> +# include <mln/core/alias/point2d.hh> # include <mln/core/alias/point3df.hh> diff --git a/milena/mln/core/dpsites_piter.hh b/milena/mln/core/dpsites_piter.hh index 6895cba..91709d7 100644 --- a/milena/mln/core/dpsites_piter.hh +++ b/milena/mln/core/dpsites_piter.hh @@ -120,7 +120,7 @@ namespace mln /// Go to the next point. void do_next_(); - /// Set the reference psite. + /// Do some work while setting the reference site. template <typename Pref> void center_at_(const Pref&); diff --git a/milena/mln/core/image/complex_neighborhood_piter.hh b/milena/mln/core/image/complex_neighborhood_piter.hh index f69455c..f57588b 100644 --- a/milena/mln/core/image/complex_neighborhood_piter.hh +++ b/milena/mln/core/image/complex_neighborhood_piter.hh @@ -153,7 +153,7 @@ namespace mln /// Go to the next site. void do_next_(); - /// Set the reference psite. + /// Do some work while setting the reference site. template <typename Pref> void center_at_(const Pref&); diff --git a/milena/mln/core/image/complex_window_piter.hh b/milena/mln/core/image/complex_window_piter.hh index 4a77fbc..72952d5 100644 --- a/milena/mln/core/image/complex_window_piter.hh +++ b/milena/mln/core/image/complex_window_piter.hh @@ -86,12 +86,10 @@ namespace mln /// Go to the next site. void do_next_(); - /// Set the reference psite. - /* FIXME: Careful, this method overrides the (non virtual) method - internal::site_relative_iterator_base<S, E>::center_at. See - FIXME above. */ + /// Do some work while setting the reference site. template <typename Pref> - void center_at(const Pref& c); + void center_at_(const Pref& c); + /// Compute the current psite. psite compute_p_() const; /// \} @@ -154,12 +152,10 @@ namespace mln /// Go to the next site. void do_next_(); - /// Set the reference psite. - /* FIXME: Careful, this method overrides the (non virtual) method - internal::site_relative_iterator_base<S, E>::center_at. See - FIXME above. */ + /// Do some work while setting the reference site. template <typename Pref> - void center_at(const Pref& c); + void center_at_(const Pref& c); + /// Compute the current psite. psite compute_p_() const; /// \} @@ -243,9 +239,8 @@ namespace mln template <typename Pref> inline void - complex_window_fwd_piter<I, G, W>::center_at(const Pref& c) + complex_window_fwd_piter<I, G, W>::center_at_(const Pref&) { - super_::center_at(c); iter_.center_at(this->center().face()); } @@ -341,9 +336,8 @@ namespace mln template <typename Pref> inline void - complex_window_bkd_piter<I, G, W>::center_at(const Pref& c) + complex_window_bkd_piter<I, G, W>::center_at_(const Pref& c) { - super_::center_at(c); iter_.center_at(this->center().face()); } diff --git a/milena/mln/core/image/image_if.hh b/milena/mln/core/image/image_if.hh index 168a7bc..ce07f35 100644 --- a/milena/mln/core/image/image_if.hh +++ b/milena/mln/core/image/image_if.hh @@ -115,26 +115,6 @@ namespace mln operator image_if<const I, F>() const; }; - - // init_. - - template <typename I, typename F> - void init_(tag::function_t, F& f, const image_if<I,F>& model) - { - f = model.domain().predicate(); - } - - template <typename I, typename F, typename J> - void init_(tag::image_t, image_if<I,F>& target, const J& model) - { - I ima; - init_(tag::image, ima, exact(model)); - F f; - init_(tag::function, f, exact(model)); - target.init_(ima, f); - } - - // Operators. // Image | Function_p2b. @@ -165,6 +145,24 @@ namespace mln # ifndef MLN_INCLUDE_ONLY + // init_. + + template <typename I, typename F> + void init_(tag::function_t, F& f, const image_if<I,F>& model) + { + f = model.domain().predicate(); + } + + template <typename I, typename F, typename J> + void init_(tag::image_t, image_if<I,F>& target, const J& model) + { + I ima; + init_(tag::image, ima, exact(model)); + F f; + init_(tag::function, f, exact(model)); + target.init_(ima, f); + } + // internal::data< image_if<I,F> > namespace internal diff --git a/milena/mln/core/internal/graph_psite_base.hh b/milena/mln/core/internal/graph_psite_base.hh index cbff5f0..d0df650 100644 --- a/milena/mln/core/internal/graph_psite_base.hh +++ b/milena/mln/core/internal/graph_psite_base.hh @@ -100,7 +100,7 @@ namespace mln const typename S::graph_element& element() const; /// Return the underlying element. - const typename S::graph_element& hook_elt_() const; + const typename S::graph_element& p_hook_() const; protected: @@ -118,6 +118,7 @@ namespace mln /// \} const S* s_; + mln_site(S) site_; typename S::graph_element elt_; }; @@ -155,6 +156,39 @@ namespace mln /// \} + /// \{ + /// subject_impl specialization (Proxy) + template <typename S, typename P, typename E> + struct subject_impl< const graph_psite_base<S,P>&, E > + { + const S* target_() const; + const S& site_set() const; + const typename S::graph_t& graph() const; + unsigned id() const; + bool is_valid() const; + operator unsigned() const; + operator const typename S::graph_element&() const; + const typename S::graph_element& element() const; + const typename S::graph_element& p_hook_() const; + + private: + const E& exact_() const; + }; + + template <typename S, typename P, typename E> + struct subject_impl< graph_psite_base<S,P>&, E > : + subject_impl< const graph_psite_base<S,P>&, E > + { + void change_target(const S& new_target); + void update_id(unsigned elt_id); + void invalidate(); + + private: + E& exact_(); + }; + /// \} + + # ifndef MLN_INCLUDE_ONLY @@ -195,7 +229,9 @@ namespace mln void graph_psite_base<S,E>::update_id(unsigned id) { + mln_precondition(s_ != 0); elt_.update_id(id); + site_ = s_->function()(elt_.id()); } template <typename S, typename E> @@ -254,8 +290,12 @@ namespace mln const mln_site(S)& graph_psite_base<S,E>::subj_() { - mln_precondition(s_ != 0); - return s_->function()(elt_.id()); + /*FIXME: we may like to enable the following precondition, however, we + ** can't do that since neighb_*_niters update the psite target after having + ** taken the adress of the subject. + */ + // mln_precondition(is_valid()); + return site_; } template <typename S, typename E> @@ -270,7 +310,7 @@ namespace mln inline graph_psite_base<S,E>::operator const typename S::graph_element&() const { - mln_precondition(is_valid()); + //mln_precondition(is_valid()); return elt_; } @@ -279,20 +319,23 @@ namespace mln const typename S::graph_element& graph_psite_base<S,E>::element() const { - mln_precondition(is_valid()); + /*FIXME: we may like to enable the following precondition, however, we + ** can't do that since neighb_*_niters update the psite target after having + ** taken the adress of the subject. + */ + // mln_precondition(is_valid()); return elt_; } template <typename S, typename E> inline const typename S::graph_element& - graph_psite_base<S,E>::hook_elt_() const + graph_psite_base<S,E>::p_hook_() const { return elt_; } - - /*--------------. + /*--------------. | Comparisons. | `--------------*/ @@ -320,6 +363,105 @@ namespace mln return lhs.id() < rhs.id(); } + + template <typename S, typename P, typename E> + inline + const E& + subject_impl< const graph_psite_base<S,P>&, E >::exact_() const + { + return internal::force_exact<const E>(*this); + } + + template <typename S, typename P, typename E> + inline + const S* + subject_impl< const graph_psite_base<S,P>&, E >::target_() const + { + return exact_().get_subject().target(); + } + + template <typename S, typename P, typename E> + inline + const S& + subject_impl< const graph_psite_base<S,P>&, E >::site_set() const + { + return exact_().get_subject().site_set(); + } + + + template <typename S, typename P, typename E> + inline + const typename S::graph_t& + subject_impl< const graph_psite_base<S,P>&, E >::graph() const + { + return exact_().get_subject().graph(); + } + + template <typename S, typename P, typename E> + inline + unsigned + subject_impl< const graph_psite_base<S,P>&, E >::id() const + { + return exact_().get_subject().id(); + }; + + template <typename S, typename P, typename E> + inline + bool + subject_impl< const graph_psite_base<S,P>&, E >::is_valid() const + { + return exact_().get_subject().is_valid(); + } + + template <typename S, typename P, typename E> + inline + const typename S::graph_element& + subject_impl< const graph_psite_base<S,P>&, E >::element() const + { + return exact_().get_subject().element(); + } + + template <typename S, typename P, typename E> + inline + const typename S::graph_element& + subject_impl< const graph_psite_base<S,P>&, E >::p_hook_() const + { + return exact_().get_subject().p_hook_(); + } + + + template <typename S, typename P, typename E> + inline + E& + subject_impl< graph_psite_base<S,P>&, E >::exact_() + { + return internal::force_exact<E>(*this); + } + + template <typename S, typename P, typename E> + inline + void + subject_impl< graph_psite_base<S,P>&, E >::change_target(const S& new_target) + { + exact_().get_subject().change_target(new_target); + } + + template <typename S, typename P, typename E> + inline + void + subject_impl< graph_psite_base<S,P>&, E >::update_id(unsigned id) + { + exact_().get_subject().update_id(id); + }; + + template <typename S, typename P, typename E> + inline + void + subject_impl< graph_psite_base<S,P>&, E >::invalidate() + { + exact_().get_subject().invalidate(); + } + # endif // ! MLN_INCLUDE_ONLY } // end of namespace internal diff --git a/milena/mln/core/routine/duplicate.hh b/milena/mln/core/routine/duplicate.hh index cd1982f..579cf1e 100644 --- a/milena/mln/core/routine/duplicate.hh +++ b/milena/mln/core/routine/duplicate.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -25,13 +26,12 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef MLN_CORE_ROUTINE_CLONE_HH -# define MLN_CORE_ROUTINE_CLONE_HH +#ifndef MLN_CORE_ROUTINE_DUPLICATE_HH +# define MLN_CORE_ROUTINE_DUPLICATE_HH -/*! \file mln/core/routine/duplicate.hh - * - * \brief Clone an image, that is, get an effective copy. - */ +/// \file mln/core/routine/duplicate.hh +/// +/// Clone an image, that is, get an effective copy. # include <mln/core/concept/image.hh> # include <mln/core/routine/init.hh> @@ -41,14 +41,13 @@ namespace mln { - /*! \brief Clone the image \p model with the values of the image \p - * data. - * - * \param[in] model The image to be duplicateed. - * \result The duplicate. - * - * \pre model.has_data - */ + /// Duplicate the image \p model with the values of the image \p + /// data. + /// + /// \param[in] model The image to be duplicated. + /// \result The duplicate. + /// + /// \pre model.has_data template <typename I> mln_concrete(I) duplicate(const Image<I>& model); @@ -75,4 +74,4 @@ namespace mln } // end of namespace mln -#endif // ! MLN_CORE_ROUTINE_CLONE_HH +#endif // ! MLN_CORE_ROUTINE_DUPLICATE_HH diff --git a/milena/mln/core/site_set/p_vaccess.hh b/milena/mln/core/site_set/p_vaccess.hh index 44e1f38..25b8e5c 100644 --- a/milena/mln/core/site_set/p_vaccess.hh +++ b/milena/mln/core/site_set/p_vaccess.hh @@ -34,6 +34,7 @@ /// \todo Fix the FIXMEs. # include <utility> +# include <mln/core/concept/site_set.hh> # include <mln/core/site_set/p_double.hh> # include <mln/core/internal/site_set_base.hh> # include <mln/core/internal/pseudo_site_base.hh> @@ -41,7 +42,6 @@ # include <mln/value/set.hh> - namespace mln { @@ -66,8 +66,7 @@ namespace mln - /*! \brief FIXME - */ + /// FIXME template <typename V, typename S> class p_vaccess : public internal::site_set_base_< mln_site(S), p_vaccess<V,S> >, @@ -111,14 +110,14 @@ namespace mln /// site set. bool has(const V& v, const mln_psite(S)& p) const; - /// Test if this site set is valid. + /// Test if this site set is valid. bool is_valid() const; /// Element associated type. typedef mln_element(S) element; - /// Insertion element associated type. + /// Insertion element associated type. typedef std::pair<V, element> i_element; /// Insert a pair \p v_e (value v, element e). @@ -145,7 +144,7 @@ namespace mln // Required by p_double-related classes. const mln::value::set<V>& set_1_() const; const S& set_2_(const V& v) const; - + protected: mln::value::set<V> vs_; diff --git a/milena/mln/fun/i2v/array.hh b/milena/mln/fun/i2v/array.hh index f9ce0d1..6b6754a 100644 --- a/milena/mln/fun/i2v/array.hh +++ b/milena/mln/fun/i2v/array.hh @@ -37,6 +37,7 @@ # include <vector> # include <algorithm> +# include <mln/core/concept/function.hh> # include <mln/fun/internal/array_base.hh> # include <mln/util/array.hh> @@ -88,12 +89,16 @@ namespace mln { template <typename T> - class array : public internal::array_base< T, array<T> > + class array : public Function_i2v< array<T> >, + public internal::array_base<T> { - typedef internal::array_base< T, array<T> > super_base_; + typedef internal::array_base<T> super_base_; public: + /// Mutable result type. The function results can be modified. + typedef typename super_base_::mutable_result mutable_result; + /// Constructors /// \{ diff --git a/milena/mln/fun/internal/array_base.hh b/milena/mln/fun/internal/array_base.hh index 3782ca4..e26ab91 100644 --- a/milena/mln/fun/internal/array_base.hh +++ b/milena/mln/fun/internal/array_base.hh @@ -34,7 +34,6 @@ # include <vector> # include <algorithm> -# include <mln/core/concept/function.hh> # include <mln/util/array.hh> # include <mln/tag/init.hh> @@ -48,8 +47,8 @@ namespace mln namespace internal { - template <typename T, typename E> - class array_base : public Function_i2v< E > + template <typename T> + class array_base { public: @@ -114,88 +113,88 @@ namespace mln namespace internal { - template <typename T, typename E> + template <typename T> inline - array_base<T,E>::array_base() + array_base<T>::array_base() { } - template <typename T, typename E> + template <typename T> inline - array_base<T,E>::array_base(unsigned n) + array_base<T>::array_base(unsigned n) : v_(n) { } - template <typename T, typename E> + template <typename T> inline - array_base<T,E>::array_base(unsigned n, const T& val) + array_base<T>::array_base(unsigned n, const T& val) : v_(n, val) { } - template <typename T, typename E> + template <typename T> inline - array_base<T,E>::array_base(const util::array<T>& from) + array_base<T>::array_base(const util::array<T>& from) : v_(from.std_vector()) { } - template <typename T, typename E> + template <typename T> inline - array_base<T,E>::array_base(const std::vector<T>& from) + array_base<T>::array_base(const std::vector<T>& from) : v_(from) { } - template <typename T, typename E> + template <typename T> inline void - array_base<T,E>::resize(unsigned n) + array_base<T>::resize(unsigned n) { v_.resize(n); } - template <typename T, typename E> + template <typename T> inline void - array_base<T,E>::resize(unsigned n, const T& val) + array_base<T>::resize(unsigned n, const T& val) { v_.resize(n, val); } - template <typename T, typename E> + template <typename T> inline unsigned - array_base<T,E>::size() const + array_base<T>::size() const { return v_.size(); } - template <typename T, typename E> + template <typename T> inline - typename array_base<T,E>::result - array_base<T,E>::operator()(unsigned i) const + typename array_base<T>::result + array_base<T>::operator()(unsigned i) const { mln_precondition(i < v_.size()); return v_[i]; } - template <typename T, typename E> + template <typename T> inline - typename array_base<T,E>::mutable_result - array_base<T,E>::operator()(unsigned i) + typename array_base<T>::mutable_result + array_base<T>::operator()(unsigned i) { mln_precondition(i < v_.size()); return v_[i]; } - template <typename T, typename E> + template <typename T> inline void - array_base<T,E>::init_(unsigned n) + array_base<T>::init_(unsigned n) { v_.resize(n); } diff --git a/milena/mln/fun/l2l/relabel.hh b/milena/mln/fun/l2l/relabel.hh index 0950e01..16da5b4 100644 --- a/milena/mln/fun/l2l/relabel.hh +++ b/milena/mln/fun/l2l/relabel.hh @@ -35,6 +35,7 @@ # include <vector> # include <algorithm> +# include <mln/core/concept/function.hh> # include <mln/fun/internal/array_base.hh> # include <mln/util/array.hh> # include <mln/metal/converts_to.hh> @@ -89,12 +90,16 @@ namespace mln { template <typename L> - class relabel : public internal::array_base< L, relabel<L> > + class relabel : public Function_l2l< relabel<L> >, + public internal::array_base<L> { - typedef internal::array_base< L, relabel<L> > super_base_; + typedef internal::array_base<L> super_base_; public: + /// Mutable result type. The function results can be modified. + typedef typename super_base_::mutable_result mutable_result; + /// Constructors /// \{ diff --git a/milena/mln/fun/p2b/chess.hh b/milena/mln/fun/p2b/chess.hh index 2f73cf9..a4c18a4 100644 --- a/milena/mln/fun/p2b/chess.hh +++ b/milena/mln/fun/p2b/chess.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -28,10 +29,9 @@ #ifndef MLN_FUN_P2B_CHESS_HH # define MLN_FUN_P2B_CHESS_HH -/*! \file mln/fun/p2b/chess.hh - * - * \brief FIXME. - */ +/// \file mln/fun/p2b/chess.hh +/// +/// FIXME. # include <mln/core/concept/function.hh> # include <mln/core/alias/point2d.hh> diff --git a/milena/mln/geom/ninds.hh b/milena/mln/geom/ninds.hh index 9ab0d1a..12fd520 100644 --- a/milena/mln/geom/ninds.hh +++ b/milena/mln/geom/ninds.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -28,10 +29,9 @@ #ifndef MLN_GEOM_NINDS_HH # define MLN_GEOM_NINDS_HH -/*! \file mln/geom/ninds.hh - * - * \brief Give the number of inds of an image. - */ +/// \file mln/geom/ninds.hh +/// +/// Give the number of inds of an image. # include <mln/geom/min_ind.hh> # include <mln/geom/max_ind.hh> diff --git a/milena/mln/labeling/relabel.hh b/milena/mln/labeling/relabel.hh index 551da6d..660e25b 100644 --- a/milena/mln/labeling/relabel.hh +++ b/milena/mln/labeling/relabel.hh @@ -148,15 +148,13 @@ namespace mln relabel(const Image<I>& label, const mln_value(I)& nlabels, mln_value(I)& new_nlabels, - const Function_l2b<F>& fl2b) + const Function_l2l<F>& fl2l) { trace::entering("labeling::relabel"); - internal::relabel_tests(label, nlabels, new_nlabels, fl2b); + internal::relabel_tests(label, nlabels, new_nlabels, fl2l); - typedef fun::l2l::relabel<mln_value(I)> fl2l_t; - fl2l_t fl2l = make::relabelfun(fl2b, nlabels, new_nlabels); - mln_concrete(I) output = labeling::relabel(label, nlabels, new_nlabels, fl2l); + mln_concrete(I) output = level::transform(label, fl2l); trace::exiting("labeling::relabel"); return output; @@ -170,13 +168,15 @@ namespace mln relabel(const Image<I>& label, const mln_value(I)& nlabels, mln_value(I)& new_nlabels, - const Function_l2l<F>& fl2l) + const Function_l2b<F>& fl2b) { trace::entering("labeling::relabel"); - internal::relabel_tests(label, nlabels, new_nlabels, fl2l); + internal::relabel_tests(label, nlabels, new_nlabels, fl2b); - mln_concrete(I) output = level::transform(label, fl2l); + typedef fun::l2l::relabel<mln_value(I)> fl2l_t; + fl2l_t fl2l = make::relabelfun(fl2b, nlabels, new_nlabels); + mln_concrete(I) output = labeling::relabel(label, nlabels, new_nlabels, fl2l); trace::exiting("labeling::relabel"); return output; @@ -189,15 +189,13 @@ namespace mln void relabel_inplace(Image<I>& label, mln_value(I)& nlabels, - const Function_l2b<F>& fl2b) + const Function_l2l<F>& fl2l) { trace::entering("labeling::relabel_inplace"); - internal::relabel_inplace_tests(label, nlabels, fl2b); + internal::relabel_inplace_tests(label, nlabels, fl2l); - typedef fun::l2l::relabel<mln_value(I)> fl2l_t; - fl2l_t fl2l = make::relabelfun(fl2b, nlabels, nlabels); - relabel_inplace(label, nlabels, fl2l); + level::transform_inplace(label, fl2l); trace::exiting("labeling::relabel_inplace"); } @@ -209,18 +207,19 @@ namespace mln void relabel_inplace(Image<I>& label, mln_value(I)& nlabels, - const Function_l2l<F>& fl2l) + const Function_l2b<F>& fl2b) { trace::entering("labeling::relabel_inplace"); - internal::relabel_inplace_tests(label, nlabels, fl2l); + internal::relabel_inplace_tests(label, nlabels, fl2b); - level::transform_inplace(label, fl2l); + typedef fun::l2l::relabel<mln_value(I)> fl2l_t; + fl2l_t fl2l = make::relabelfun(fl2b, nlabels, nlabels); + labeling::relabel_inplace(label, nlabels, fl2l); trace::exiting("labeling::relabel_inplace"); } - # endif // ! MLN_INCLUDE_ONLY } // end of namespace mln::labeling diff --git a/milena/mln/linear/gaussian.hh b/milena/mln/linear/gaussian.hh index d550123..4b5be0c 100644 --- a/milena/mln/linear/gaussian.hh +++ b/milena/mln/linear/gaussian.hh @@ -41,9 +41,13 @@ # include <mln/core/concept/image.hh> # include <mln/core/alias/point2d.hh> +# include <mln/core/alias/dpoint1d.hh> +# include <mln/core/alias/dpoint3d.hh> # include <mln/extension/adjust_fill.hh> # include <mln/geom/ncols.hh> # include <mln/geom/nrows.hh> +# include <mln/geom/ninds.hh> +# include <mln/geom/nslis.hh> # include <mln/data/paste.hh> # include <mln/level/stretch.hh> # include <mln/algebra/vec.hh> @@ -449,7 +453,7 @@ namespace mln static_cast<def::coord>(k)), point3d(static_cast<def::coord>(i), static_cast<def::coord>(geom::nrows(img) - 1 + - img.border()), + img.border()), static_cast<def::coord>(k)), geom::nrows(img) + 2 * img.border(), diff --git a/milena/mln/morpho/opening_area_on_vertices.hh b/milena/mln/morpho/opening_area_on_vertices.hh index 80c6053..a1d3b72 100644 --- a/milena/mln/morpho/opening_area_on_vertices.hh +++ b/milena/mln/morpho/opening_area_on_vertices.hh @@ -52,7 +52,7 @@ namespace mln template <typename P2V, typename G, typename V2P, typename N> pw::image<P2V, p_edges<G, V2P> > opening_area_on_vertices(const pw::image<P2V, p_edges<G, V2P> >& input, - const Neighborhood<N>& nbh); + const Neighborhood<N>& nbh, unsigned lambda); # ifndef MLN_INCLUDE_ONLY diff --git a/milena/mln/pw/cst.hh b/milena/mln/pw/cst.hh index e9e01f9..bc344ad 100644 --- a/milena/mln/pw/cst.hh +++ b/milena/mln/pw/cst.hh @@ -1,4 +1,5 @@ // Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -28,10 +29,9 @@ #ifndef MLN_PW_CST_HH # define MLN_PW_CST_HH -/*! \file mln/pw/cst.hh - * - * \brief FIXME. - */ +/// \file mln/pw/cst.hh +/// +/// FIXME. # include <mln/fun/internal/selector.hh> diff --git a/milena/mln/pw/value.hh b/milena/mln/pw/value.hh index 5dacaad..c237653 100644 --- a/milena/mln/pw/value.hh +++ b/milena/mln/pw/value.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -28,10 +29,9 @@ #ifndef MLN_PW_VALUE_HH # define MLN_PW_VALUE_HH -/*! \file mln/pw/value.hh - * - * \brief FIXME. - */ +/// \file mln/pw/value.hh +/// +/// FIXME. # include <mln/fun/internal/selector.hh> # include <mln/core/concept/image.hh> @@ -52,10 +52,12 @@ namespace mln : fun::internal::selector_p2_< mln_value(I), value_<I> >::ret { typedef mln_value(I) result; + + value_(); value_(const I& ima); + mln_rvalue(I) operator()(const mln_psite(I)& p) const; - value_(); // A function should have a ctor without arg so that "initialize" can work. protected: const I* ima_; }; @@ -63,7 +65,7 @@ namespace mln // FIXME: Doc! - + template <typename I> value_<I> value(const Image<I>& ima); @@ -75,15 +77,15 @@ namespace mln template <typename I> inline - value_<I>::value_(const I& ima) - : ima_(&ima) + value_<I>::value_() + : ima_(0) { } template <typename I> inline - value_<I>::value_() - : ima_(0) + value_<I>::value_(const I& ima) + : ima_(&ima) { } @@ -97,8 +99,9 @@ namespace mln return (*ima_)(p); } + // pw::value(ima) - + template <typename I> inline value_<I> diff --git a/milena/mln/registration/get_rot.hh b/milena/mln/registration/get_rot.hh index 6742abc..b258937 100644 --- a/milena/mln/registration/get_rot.hh +++ b/milena/mln/registration/get_rot.hh @@ -61,6 +61,11 @@ namespace mln const M& map, const algebra::vec<2u,float>& mu_xk) { + (void) c; + (void) mu_c; + (void) ck; + (void) map; + (void) mu_xk; //FIXME: Write 2d version of rotation computation betwenn two p_array return fun::x2x::rotation<2u, float>(); } diff --git a/milena/mln/registration/registration.hh b/milena/mln/registration/registration.hh index 41a531d..81925ed 100644 --- a/milena/mln/registration/registration.hh +++ b/milena/mln/registration/registration.hh @@ -28,10 +28,9 @@ #ifndef MLN_REGISTRATION_REGISTRATION_HH # define MLN_REGISTRATION_REGISTRATION_HH -/*! \file mln/registration/registration.hh - * - * \brief image registration - */ +/// \file mln/registration/registration.hh +/// +/// image registration # include <mln/registration/icp.hh> # include <mln/fun/x2x/all.hh> @@ -47,8 +46,7 @@ namespace mln using namespace mln::fun::x2x; - /*! Register an image \p cloud over the image \p surface. - */ + /// Register an image \p cloud over the image \p surface. template <typename I, typename J> inline composed< rotation<I::psite::dim, float>, translation<I::psite::dim, float> > diff --git a/milena/mln/util/ord_pair.hh b/milena/mln/util/ord_pair.hh index 79fef46..9802fab 100644 --- a/milena/mln/util/ord_pair.hh +++ b/milena/mln/util/ord_pair.hh @@ -30,7 +30,8 @@ # define MLN_UTIL_ORD_PAIR_HH /// \file mln/util/ord_pair.hh -/// \brief Definition of an ordered pair. +/// +/// Definition of an ordered pair. # include <mln/core/concept/object.hh> # include <mln/util/ord.hh> @@ -44,13 +45,14 @@ namespace mln // FIXME: Rename as ord_pair. - /// \brief Ordered pair structure s.a. this->first <= this->second; + /// Ordered pair structure s.a. this->first <= this->second; /// ordered pairs are partially ordered using lexicographical /// ordering. template <typename T> struct ord_pair : public mln::Object< ord_pair<T> > { public: + ord_pair(); ord_pair(const T& val1, const T& val2); public: @@ -66,21 +68,21 @@ namespace mln T& second(); /// \} - /// \brief Replace the first member of the pair by \a val, while + /// Replace the first member of the pair by \a val, while /// keeping the relative order. /// /// \post \a first_ <= \a second_ (with <= being the /// mln::util::ord_weak relationship). void change_first(const T& val); - /// \brief Replace the second member of the pair by \a val, + /// Replace the second member of the pair by \a val, /// while keeping the relative order. /// /// \post \a first_ <= \a second_ (with <= being the /// mln::util::ord_weak relationship). void change_second(const T& val); - /// \brief Replace both members of the pair by \a val, while + /// Replace both members of the pair by \a val, while /// keeping the relative order. /// /// \post \a first_ <= \a second_ (with <= being the @@ -128,6 +130,12 @@ namespace mln template <typename T> inline + ord_pair<T>::ord_pair() + { + } + + template <typename T> + inline ord_pair<T>::ord_pair(const T& val1, const T& val2) { change_both(val1, val2); diff --git a/milena/mln/util/site_pair.hh b/milena/mln/util/site_pair.hh index b9a5611..9bb3162 100644 --- a/milena/mln/util/site_pair.hh +++ b/milena/mln/util/site_pair.hh @@ -28,10 +28,12 @@ #ifndef MLN_UTIL_SITE_PAIR_HH # define MLN_UTIL_SITE_PAIR_HH +# include <mln/core/concept/proxy.hh> # include <mln/util/ord_pair.hh> /// \file mln/util/site_pair.hh -/// \brief Definition of a site pair type. +/// +/// Definition of a site pair type. namespace mln { @@ -44,8 +46,9 @@ namespace mln Hence this small workaround. Use ord_pair directly as soon as image_base is refurbished. */ template <typename P> - struct site_pair : public mln::Object< site_pair<P> > + class site_pair : public mln::Object< site_pair<P> > { + public: /* FIXME: We should not need to define this typedef (see. mln::internal::image_base's site `coord' typedef). */ typedef mln_coord(P) coord; @@ -53,6 +56,15 @@ namespace mln site_pair(); site_pair(const P& first, const P& second); + /// Return the first site. + const P& first() const; + /// Return the second site. + const P& second() const; + + /// Return the underlying pair. + const util::ord_pair<P>& pair() const; + + private: util::ord_pair<P> pair_; }; @@ -71,17 +83,43 @@ namespace mln template <typename P> bool operator< (const site_pair<P>& lhs, const site_pair<P>& rhs); + } // end of namespace mln::util + + + namespace internal + { + + /// \{ + /// subject_impl specialization (Proxy) + + template <typename P, typename E> + struct subject_impl< const util::site_pair<P>, E > + { + const P& first() const; + const P& second() const; + const util::ord_pair<P>& pair() const; + + private: + const E& exact_() const; + }; + + /// \} + + } // end of namespace mln::internal + # ifndef MLN_INCLUDE_ONLY + namespace util + { + /*---------------. | Construction. | `---------------*/ template <typename P> site_pair<P>::site_pair() - : pair_(P(), P()) { } @@ -91,6 +129,30 @@ namespace mln { } + template <typename P> + inline + const P& + site_pair<P>::first() const + { + return pair_.first(); + } + + template <typename P> + inline + const P& + site_pair<P>::second() const + { + return pair_.second(); + } + + template <typename P> + inline + const util::ord_pair<P>& + site_pair<P>::pair() const + { + return pair_; + } + /*-------------. | Comparison. | `-------------*/ @@ -100,7 +162,7 @@ namespace mln bool operator==(const site_pair<P>& lhs, const site_pair<P>& rhs) { - return lhs.pair_ == rhs.pair_; + return lhs.pair() == rhs.pair(); } template <typename P> @@ -108,7 +170,7 @@ namespace mln bool operator< (const site_pair<P>& lhs, const site_pair<P>& rhs) { - return lhs.pair_ < rhs.pair_; + return lhs.pair() < rhs.pair(); } template <typename P> @@ -116,13 +178,42 @@ namespace mln bool operator<=(const site_pair<P>& lhs, const site_pair<P>& rhs) { - return lhs.pair_ <= rhs.pair_; + return lhs.pair() <= rhs.pair(); } -# endif // ! MLN_INCLUDE_ONLY - } // end of mln::util + namespace internal + { + + template <typename P, typename E> + inline + const E& + subject_impl< const util::site_pair<P>, E >::exact_() const + { + return internal::force_exact<const E>(*this); + } + + template <typename P, typename E> + inline + const P& + subject_impl< const util::site_pair<P>, E >::first() const + { + return exact_().get_subject().first(); + } + + template <typename P, typename E> + inline + const P& + subject_impl< const util::site_pair<P>, E >::second() const + { + return exact_().get_subject().second(); + } + + } // end of namespace mln::internal + +# endif // ! MLN_INCLUDE_ONLY + } // end of mln diff --git a/milena/mln/win/multiple_size.hh b/milena/mln/win/multiple_size.hh index beede96..86ccaed 100644 --- a/milena/mln/win/multiple_size.hh +++ b/milena/mln/win/multiple_size.hh @@ -130,7 +130,7 @@ namespace mln template <unsigned n, typename W, typename F> - class multiple_size_qiter + class multiple_size_qiter : public internal::site_relative_iterator_base< multiple_size<n,W,F>, multiple_size_qiter<n,W,F> > { @@ -155,6 +155,10 @@ namespace mln /// Go to the next point. void do_next_(); + /// Do some work while setting the reference site. + template <typename Pref> + void center_at_(const Pref&); + /// Compute the current psite. mln_psite(W) compute_p_() const; @@ -349,6 +353,14 @@ namespace mln } template <unsigned n, typename W, typename F> + template <typename Pref> + inline + void + multiple_size_qiter<n,W,F>::center_at_(const Pref&) + { + } + + template <unsigned n, typename W, typename F> inline mln_psite(W) multiple_size_qiter<n,W,F>::compute_p_() const diff --git a/milena/tests/unit_test/Makefile.am b/milena/tests/unit_test/Makefile.am index 2f3426e..91e56f5 100644 --- a/milena/tests/unit_test/Makefile.am +++ b/milena/tests/unit_test/Makefile.am @@ -21,7 +21,6 @@ mln_geom_size3d \ mln_geom_ninds \ mln_geom_nslis \ mln_geom_delta \ -mln_geom_resize \ mln_geom_nsites \ mln_geom_min_col \ mln_geom_complex_geometry \ @@ -1028,7 +1027,6 @@ mln_geom_size3d_SOURCES = mln_geom_size3d.cc mln_geom_ninds_SOURCES = mln_geom_ninds.cc mln_geom_nslis_SOURCES = mln_geom_nslis.cc mln_geom_delta_SOURCES = mln_geom_delta.cc -mln_geom_resize_SOURCES = mln_geom_resize.cc mln_geom_nsites_SOURCES = mln_geom_nsites.cc mln_geom_min_col_SOURCES = mln_geom_min_col.cc mln_geom_complex_geometry_SOURCES = mln_geom_complex_geometry.cc diff --git a/milena/tests/unit_test/mln_geom_resize.cc b/milena/tests/unit_test/mln_geom_resize.cc deleted file mode 100644 index c1bac73..0000000 --- a/milena/tests/unit_test/mln_geom_resize.cc +++ /dev/null @@ -1,11 +0,0 @@ -// Unit test for mln/geom/resize.hh. -// Generated by ./build_unit_test.sh, do not modify. - -// Include the file twice, so we detect missing inclusion guards. -#include <mln/geom/resize.hh> -#include <mln/geom/resize.hh> - -int main() -{ - // Nothing. -} -- 1.5.6.5