
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena Index: ChangeLog from Thierry Geraud <thierry.geraud@lrde.epita.fr> Update the design of windows. Propagate box renaming. * mln/core/site_set/p_bgraph.hh, * mln/core/site_set/p_complex.hh, * mln/core/site_set/p_line_graph.hh, * mln/core/site_set/p_faces.hh, * mln/core/site_set/p_graph.hh, * mln/core/image/obased_rle_image.hh, * mln/core/image/t_image.hh, * mln/core/concept/doc/image.hh, * mln/core/line_piter.hh, * mln/core/alias/box2d_h.hh (box_): Update to... (box): ...its new name. Use site-related names instead of point-related names. * mln/core/w_window.hh, * mln/core/clock_neighb.hh, * mln/core/internal/image_base.hh, * mln/core/concept/doc/weighted_window.hh, * mln/core/concept/doc/dpoint.hh, * mln/core/concept/doc/neighborhood.hh, * mln/core/concept/doc/point_site.hh: Fix doc. * mln/make/w_window.hh, * mln/convert/to_upper_window.hh, * mln/convert/to_image.hh, * mln/convert/to_std_set.hh, * mln/convert/to_p_set.hh, * mln/geom/shift.hh: Fix code. Update the design of windows. * mln/core/point.hh (site, psite): New; this is a temp hack. * mln/core/internal/dpoints_base.hh: Revamp. (set_of): Remove; use instead... (util::set): ...this and prefer delegation to... (win_): ...this new attribute. (insert): New protected method; no more inherited. * mln/win/vline2d.hh, * mln/win/hline2d.hh, * mln/win/cube3d.hh, * mln/win/segment1d.hh, * mln/win/line.hh, * mln/win/rectangle2d.hh, * mln/win/diag2d.hh, * mln/win/backdiag2d.hh, * mln/win/cuboid3d.hh, * mln/win/octagon2d.hh, * mln/win/disk2d.hh: Update. Misc. * mln/core/site_set/p_array.hh: Fix missing include. * mln/core/concept/window.hh (operator==): New. * mln/core/grids.hh (coord): New include. * mln/geom/bbox.hh: New overload for windows. * mln/geom/sym.hh: Fix; the 'sym' method returns void. convert/to_image.hh | 10 ++-- convert/to_p_set.hh | 8 +-- convert/to_std_set.hh | 12 ++--- convert/to_upper_window.hh | 6 +- core/alias/box2d_h.hh | 2 core/clock_neighb.hh | 4 - core/concept/doc/dpoint.hh | 4 - core/concept/doc/image.hh | 6 +- core/concept/doc/neighborhood.hh | 4 - core/concept/doc/point_site.hh | 4 - core/concept/doc/weighted_window.hh | 4 - core/concept/window.hh | 8 +++ core/grids.hh | 3 - core/image/obased_rle_image.hh | 6 +- core/image/t_image.hh | 12 ++--- core/internal/dpoints_base.hh | 83 ++++++++++++++++++++++++------------ core/internal/image_base.hh | 2 core/line_piter.hh | 6 +- core/point.hh | 5 ++ core/site_set/p_array.hh | 1 core/site_set/p_bgraph.hh | 6 +- core/site_set/p_complex.hh | 6 +- core/site_set/p_faces.hh | 6 +- core/site_set/p_graph.hh | 6 +- core/site_set/p_line_graph.hh | 6 +- core/w_window.hh | 4 - core/window.hh | 2 geom/bbox.hh | 23 +++++++++ geom/shift.hh | 12 ++--- geom/sym.hh | 8 ++- make/w_window.hh | 6 +- win/backdiag2d.hh | 27 +---------- win/cube3d.hh | 27 +---------- win/cuboid3d.hh | 25 ---------- win/diag2d.hh | 27 +---------- win/disk2d.hh | 27 +---------- win/hline2d.hh | 4 - win/line.hh | 29 ++---------- win/octagon2d.hh | 27 +---------- win/rectangle2d.hh | 28 +++--------- win/segment1d.hh | 4 - win/vline2d.hh | 4 - 42 files changed, 211 insertions(+), 293 deletions(-) Index: mln/core/site_set/p_bgraph.hh --- mln/core/site_set/p_bgraph.hh (revision 2228) +++ mln/core/site_set/p_bgraph.hh (working copy) @@ -84,7 +84,7 @@ std::size_t nlines() const; /// Give the exact bounding box. - const box_<P>& bbox() const; + const box<P>& bbox() const; bool has(const psite& p) const; @@ -106,7 +106,7 @@ private: graph* gr_; - box_<P> bb_; + box<P> bb_; }; # ifndef MLN_INCLUDE_ONLY @@ -146,7 +146,7 @@ template<typename P> inline - const box_<P>& + const box<P>& p_bgraph<P>::bbox() const { return bb_; Index: mln/core/site_set/p_complex.hh --- mln/core/site_set/p_complex.hh (revision 2228) +++ mln/core/site_set/p_complex.hh (working copy) @@ -103,7 +103,7 @@ complex<D>& cplx(); /// Give the exact bounding box. - const box_<P>& bbox() const; + const box<P>& bbox() const; /// \} private: @@ -125,7 +125,7 @@ are not tied to a specific graph. */ mutable util::tracked_ptr< complex<D> > cplx_; // FIXME: Remove as soon as bbox become optional. - box_<P> bb_; + box<P> bb_; }; @@ -212,7 +212,7 @@ template <unsigned D, typename P> inline - const box_<P>& + const box<P>& p_complex<D, P>::bbox() const { // FIXME: Dummy value. Index: mln/core/site_set/p_line_graph.hh --- mln/core/site_set/p_line_graph.hh (revision 2228) +++ mln/core/site_set/p_line_graph.hh (working copy) @@ -87,7 +87,7 @@ std::size_t nedges() const; /// Give the exact bounding box. - const box_<P>& bbox() const; + const box<P>& bbox() const; bool has(const psite& p) const; @@ -113,7 +113,7 @@ /* 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? */ - box_<P> bb_; + box<P> bb_; }; @@ -178,7 +178,7 @@ template <typename P> inline - const box_<P>& + const box<P>& p_line_graph<P>::bbox() const { return bb_; Index: mln/core/site_set/p_array.hh --- mln/core/site_set/p_array.hh (revision 2228) +++ mln/core/site_set/p_array.hh (working copy) @@ -41,6 +41,7 @@ # include <vector> # include <mln/core/internal/site_set_base.hh> +# include <mln/core/internal/site_set_iterator_base.hh> # include <mln/core/internal/pseudo_site_base.hh> # include <mln/util/index.hh> Index: mln/core/site_set/p_faces.hh --- mln/core/site_set/p_faces.hh (revision 2228) +++ mln/core/site_set/p_faces.hh (working copy) @@ -85,7 +85,7 @@ std::size_t nfaces() const; /// Give the exact bounding box. - const box_<P>& bbox() const; + const box<P>& bbox() const; bool has(const psite& p) const; @@ -96,7 +96,7 @@ /// 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_; + box<P> bb_; }; @@ -158,7 +158,7 @@ template <unsigned N, unsigned D, typename P> inline - const box_<P>& + const box<P>& p_faces<N, D, P>::bbox() const { // FIXME: Dummy value. Index: mln/core/site_set/p_graph.hh --- mln/core/site_set/p_graph.hh (revision 2228) +++ mln/core/site_set/p_graph.hh (working copy) @@ -79,7 +79,7 @@ std::size_t nedges() const; /// Give the exact bounding box. - const box_<P>& bbox() const; + const box<P>& bbox() const; bool has(const psite& p) const; @@ -125,7 +125,7 @@ named bbox(). Now the question is: should each image type have a bounding box? */ private: - box_<P> bb_; + box<P> bb_; }; @@ -191,7 +191,7 @@ template <typename P> inline - const box_<P>& + const box<P>& p_graph<P>::bbox() const { return bb_; Index: mln/core/image/obased_rle_image.hh --- mln/core/image/obased_rle_image.hh (revision 2228) +++ mln/core/image/obased_rle_image.hh (working copy) @@ -147,7 +147,7 @@ const std::vector<unsigned>& object(unsigned i) const; /// Give the bounding box of the i-th object. - const box_<P>& bbox_of_run(unsigned i) const; + const box<P>& bbox_of_run(unsigned i) const; }; @@ -175,7 +175,7 @@ data_< obased_rle_image<P,T> >::size_mem() const { return domain_.size_mem() + bbox_.size() - * (sizeof(T) + sizeof(box_<P>) + sizeof(std::vector<unsigned>)) + * (sizeof(T) + sizeof(box<P>) + sizeof(std::vector<unsigned>)) + (sizeof(unsigned) + sizeof(T)) * domain_.nruns(); } @@ -261,7 +261,7 @@ template <typename P, typename T> inline - const box_<P>& + const box<P>& obased_rle_image<P, T>::bbox_of_run(unsigned i) const { mln_assertion(i < this->data_->bbox_.size()); Index: mln/core/image/t_image.hh --- mln/core/image/t_image.hh (revision 2228) +++ mln/core/image/t_image.hh (working copy) @@ -57,7 +57,7 @@ /// \param dim2 The second dimension to be swapped. /// \param box The bounding box (domain) of the morphed image. data(I& ima, unsigned dim1, unsigned dim2, - mln::box_<mln_psite(I)>& box); + mln::box<mln_psite(I)>& box); /// Underlying image. I ima_; @@ -67,7 +67,7 @@ unsigned dim2_; /// \} /// The bounding box of the morphed image. - mln::box_<mln_psite(I)> box_; + mln::box<mln_psite(I)> box_; }; } // end of namespace mln::internal @@ -126,7 +126,7 @@ bool has(const mln_psite(I)& p) const; /// Give the definition domain. - const box_<mln_psite(I)>& domain() const; + const box<mln_psite(I)>& domain() const; /// Read-only access of pixel value at point site \p p. mln_rvalue(I) operator()(const mln_psite(I)& p) const; @@ -168,7 +168,7 @@ inline data< t_image<I> >::data(I& ima, unsigned dim1, unsigned dim2, - mln::box_<mln_psite(I)>& box) + mln::box<mln_psite(I)>& box) : ima_(ima), dim1_(dim1), dim2_(dim2), box_(box) @@ -188,7 +188,7 @@ // We don't use mln::t_image::transpose here, since one its // prerequisite is that data_ is initialized, which is not done // yet at this point. - box_<mln_psite(I)> box(exchange_coords_(ima.bbox().pmin(), dim1, dim2), + box<mln_psite(I)> box(exchange_coords_(ima.bbox().pmin(), dim1, dim2), exchange_coords_(ima.bbox().pmax(), dim1, dim2)); this->data_ = new internal::data< t_image<I> >(ima, dim1, dim2, box); } @@ -233,7 +233,7 @@ template <typename I> inline - const box_<mln_psite(I)>& + const box<mln_psite(I)>& t_image<I>::domain() const { mln_precondition(this->has_data()); Index: mln/core/point.hh --- mln/core/point.hh (revision 2228) +++ mln/core/point.hh (working copy) @@ -85,6 +85,11 @@ struct point : public Gpoint< point<G,C> >, public internal::mutable_coord_impl_< G::dim, C, point<G,C> > { + // FIXME: Temporary hack. + typedef point site; + typedef point psite; + + /*! \var dim * \brief Dimension of the space. * \invariant dim > 0 Index: mln/core/w_window.hh --- mln/core/w_window.hh (revision 2228) +++ mln/core/w_window.hh (working copy) @@ -56,10 +56,10 @@ template <typename D, typename W> struct w_window : public Weighted_Window< w_window<D,W> > { - /// Point associated type. + /// Site associated type. typedef mln_point(D) point; - /// Dpoint associated type. + /// Dpsite associated type. typedef D dpoint; /// Weight associated type. Index: mln/core/window.hh --- mln/core/window.hh (revision 2228) +++ mln/core/window.hh (working copy) @@ -38,6 +38,8 @@ * \todo Code other comparisons (< and <=). * * \todo Add static checks in insert methods. + * + * \todo Rename dps_hook_ as util_set_. */ # include <mln/core/internal/window_base.hh> Index: mln/core/clock_neighb.hh --- mln/core/clock_neighb.hh (revision 2228) +++ mln/core/clock_neighb.hh (working copy) @@ -54,10 +54,10 @@ template <typename D> struct clock_neighb_ : public Neighborhood< clock_neighb_ <D> > { - /// Dpoint associated type. + /// Dpsite associated type. typedef D dpoint; - /// Point associated type. + /// Site associated type. typedef mln_point(D) point; /*! \brief Site_Iterator type to browse the points of a generic Index: mln/core/internal/image_base.hh --- mln/core/internal/image_base.hh (revision 2228) +++ mln/core/internal/image_base.hh (working copy) @@ -105,7 +105,7 @@ /// Point_Site associated type. typedef mln_psite(S) psite; - /// Point associated type. + /// Site associated type. typedef mln_site(S) site; Index: mln/core/internal/dpoints_base.hh --- mln/core/internal/dpoints_base.hh (revision 2228) +++ mln/core/internal/dpoints_base.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -31,11 +31,15 @@ /*! \file mln/core/internal/dpoints_base.hh * * \brief Definition of a base class for classes based on a set of dpoints. + * + * \todo Rename as dpsites_impl. + * + * \todo Remove the .vect() method. */ -# include <mln/core/internal/set_of.hh> -# include <mln/fun/i2v/all_to.hh> -# include <mln/norm/linfty.hh> +# include <mln/core/window.hh> +# include <mln/core/dpsites_piter.hh> + namespace mln @@ -48,16 +52,28 @@ * */ template <typename D, typename E> - class dpoints_base_ : protected internal::set_of_<D> + class dpoints_base_ { - typedef internal::set_of_<D> super_; public: - /// Point associated type. - typedef mln_point(D) point; + /// Dpsite associated type. + typedef D dpsite; + + /// Psite associated type. + typedef mln_psite(D) psite; + + /// Site associated type. + typedef mln_site(D) site; + + + /// Forward site iterator associated type. + typedef dpsites_fwd_piter<E> fwd_qiter; - /// Dpoint associated type. - typedef D dpoint; + /// Backward site iterator associated type. + typedef dpsites_fwd_piter<E> bkd_qiter; + + /// Site iterator associated type. + typedef fwd_qiter qiter; /*! \brief Test if the window is centered. @@ -87,8 +103,16 @@ // Give the vector of delta-points. const std::vector<D>& vect() const; + // Give the vector of delta-points. + const std::vector<D>& std_vector() const; + protected: + dpoints_base_(); + + void insert(const D& d); + + mln::window<D> win_; }; @@ -105,30 +129,21 @@ inline bool dpoints_base_<D,E>::is_centered() const { - static const D origin = all_to(0); - return this->super_::has(origin); + return win_.is_centered(); } template <typename D, typename E> inline bool dpoints_base_<D,E>::is_empty() const { - return this->super_::is_empty(); + return win_.is_empty(); } template <typename D, typename E> inline unsigned dpoints_base_<D,E>::delta() const { - unsigned d = 0; - const unsigned n = ndpoints(); - for (unsigned i = 0; i < n; ++i) - { - unsigned dd = norm::linfty(dp(i).to_vec()); - if (dd > d) - d = dd; - } - return d; + return win_.delta(); } template <typename D, typename E> @@ -136,7 +151,7 @@ unsigned dpoints_base_<D,E>::ndpoints() const { - return this->super_::nelements(); + return win_.size(); } template <typename D, typename E> @@ -145,7 +160,15 @@ dpoints_base_<D,E>::dp(unsigned i) const { mln_precondition(i < ndpoints()); - return this->element(i); + return win_.dp(i); + } + + template <typename D, typename E> + inline + const std::vector<D>& + dpoints_base_<D,E>::std_vector() const + { + return win_.std_vector(); } template <typename D, typename E> @@ -153,7 +176,7 @@ const std::vector<D>& dpoints_base_<D,E>::vect() const { - return this->super_::vect(); + return std_vector(); } template <typename D, typename E> @@ -161,7 +184,15 @@ bool dpoints_base_<D,E>::has(const D& dp) const { - return this->super_::has(dp); + return win_.dps_hook_().has(dp); + } + + template <typename D, typename E> + inline + void + dpoints_base_<D,E>::insert(const D& d) + { + win_.insert(d); } # endif // ! MLN_INCLUDE_ONLY Index: mln/core/line_piter.hh --- mln/core/line_piter.hh (revision 2228) +++ mln/core/line_piter.hh (working copy) @@ -60,7 +60,7 @@ * * \param[in] b A box. */ - line_piter_(const box_<P>& b); + line_piter_(const box<P>& b); /// Conversion to point. operator P() const; @@ -84,7 +84,7 @@ void next_(); private: - const box_<P>& b_; + const box<P>& b_; P p_; bool is_valid_; }; @@ -97,7 +97,7 @@ template <typename P> inline - line_piter_<P>::line_piter_(const box_<P>& b) + line_piter_<P>::line_piter_(const box<P>& b) : b_(b) { invalidate(); Index: mln/core/alias/box2d_h.hh --- mln/core/alias/box2d_h.hh (revision 2228) +++ mln/core/alias/box2d_h.hh (working copy) @@ -46,7 +46,7 @@ * */ - typedef box_<point2d_h> box2d_h; + typedef box<point2d_h> box2d_h; } // end of namespace mln Index: mln/core/concept/window.hh --- mln/core/concept/window.hh (revision 2228) +++ mln/core/concept/window.hh (working copy) @@ -30,6 +30,8 @@ /*! \file mln/core/concept/window.hh * \brief Definition of the concept of mln::Window. + * + * \todo Operator== should test if the cmp is possible. */ # include <mln/core/concept/object.hh> @@ -76,6 +78,12 @@ }; + template <typename Wl, typename Wr> + bool operator==(const Window<Wl>& lhs, const Window<Wr>& rhs) + { + return exact(lhs).std_vector() == exact(rhs).std_vector(); + } + # ifndef MLN_INCLUDE_ONLY Index: mln/core/concept/doc/image.hh --- mln/core/concept/doc/image.hh (revision 2228) +++ mln/core/concept/doc/image.hh (working copy) @@ -121,7 +121,7 @@ */ typedef void pset; - /*! \brief Point associated type. + /*! \brief Site associated type. * \invariant This type has to derive from mln::Point. */ typedef void point; @@ -136,7 +136,7 @@ */ typedef void coord; - /*! \brief Dpoint associated type. + /*! \brief Dpsite associated type. * \invariant This type has to derive from mln::Dpoint. */ typedef void dpoint; @@ -172,7 +172,7 @@ * * \return A bounding box of the image domain. */ - const box_<point>& bbox() const; + const box<point>& bbox() const; /*! \brief Give the number of points of the image domain. */ Index: mln/core/concept/doc/weighted_window.hh --- mln/core/concept/doc/weighted_window.hh (revision 2228) +++ mln/core/concept/doc/weighted_window.hh (working copy) @@ -56,10 +56,10 @@ */ typedef void bkd_qiter; - /// Point associated type. + /// Site associated type. typedef void point; - /// Dpoint associated type. + /// Dpsite associated type. typedef void dpoint; /// Weight associated type. Index: mln/core/concept/doc/dpoint.hh --- mln/core/concept/doc/dpoint.hh (revision 2228) +++ mln/core/concept/doc/dpoint.hh (working copy) @@ -47,12 +47,12 @@ */ enum { dim }; - /*! \brief Point associated type. + /*! \brief Site associated type. * \invariant This type has to derive from mln::Point. */ typedef void point; - /*! \brief Dpoint associated type. + /*! \brief Dpsite associated type. * \invariant This type has to derive from mln::Dpoint. */ typedef void dpoint; Index: mln/core/concept/doc/neighborhood.hh --- mln/core/concept/doc/neighborhood.hh (revision 2228) +++ mln/core/concept/doc/neighborhood.hh (working copy) @@ -57,10 +57,10 @@ */ typedef void bkd_niter; - /// Dpoint associated type. + /// Dpsite associated type. typedef void dpoint; - /// Point associated type. + /// Site associated type. typedef void point; }; Index: mln/core/concept/doc/point_site.hh --- mln/core/concept/doc/point_site.hh (revision 2228) +++ mln/core/concept/doc/point_site.hh (working copy) @@ -54,12 +54,12 @@ */ typedef void mesh; - /*! \brief Point associated type. + /*! \brief Site associated type. * \invariant This type has to derive from mln::Point. */ typedef void point; - /*! \brief Dpoint associated type. + /*! \brief Dpsite associated type. * \invariant This type has to derive from mln::Dpoint. */ typedef void dpoint; Index: mln/core/grids.hh --- mln/core/grids.hh (revision 2228) +++ mln/core/grids.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -34,6 +34,7 @@ */ # include <mln/core/concept/regular_grid.hh> +# include <mln/core/def/coord.hh> # include <mln/metal/bool.hh> Index: mln/make/w_window.hh --- mln/make/w_window.hh (revision 2228) +++ mln/make/w_window.hh (working copy) @@ -53,7 +53,7 @@ * \return A weighted window. */ template <typename W, typename F> - mln::w_window<mln_dpoint(W), mln_result(F)> + mln::w_window<mln_dpsite(W), mln_result(F)> w_window(const Window<W>& win, const Function_p2v<F>& wei); @@ -61,13 +61,13 @@ template <typename W, typename F> inline - mln::w_window<mln_dpoint(W), mln_result(F)> + mln::w_window<mln_dpsite(W), mln_result(F)> w_window(const Window<W>& win_, const Function_p2v<F>& wei_) { const W& win = exact(win_); const F& wei = exact(wei_); mln_precondition(! win.is_empty()); - typedef mln_dpoint(W) D; + typedef mln_dpsite(W) D; typedef mln_point(D) P; mln::w_window<D, mln_result(F)> w_win; mln_qiter(W) q(win, P::origin); Index: mln/convert/to_upper_window.hh --- mln/convert/to_upper_window.hh (revision 2228) +++ mln/convert/to_upper_window.hh (working copy) @@ -46,7 +46,7 @@ /// Convert a window \p nbh into an upper window. template <typename W> - window<mln_dpoint(W)> to_upper_window(const Window<W>& win); + window<mln_dpsite(W)> to_upper_window(const Window<W>& win); /// Convert a neighborhood \p nbh into an upper window. template <typename N> @@ -66,10 +66,10 @@ depth in milena/core/concepts/README. */ template <typename W> inline - window<mln_dpoint(W)> to_upper_window(const Window<W>& win_) + window<mln_dpsite(W)> to_upper_window(const Window<W>& win_) { const W& input_win = exact(win_); - typedef mln_dpoint(W) D; + typedef mln_dpsite(W) D; typedef mln_point(D) P; window<D> win; mln_qiter(W) q(input_win, P::origin); Index: mln/convert/to_image.hh --- mln/convert/to_image.hh (revision 2228) +++ mln/convert/to_image.hh (working copy) @@ -31,6 +31,8 @@ /*! \file mln/convert/to_image.hh * * \brief Conversions to mln::Image. + * + * \todo Remove. Use from_to instead... */ # include <mln/core/image/image1d.hh> @@ -150,8 +152,8 @@ const W& win = exact(win_); mln_precondition(! win.is_empty()); - typedef mln_point(W) P; - box_<P> b = geom::bbox(win); + typedef mln_site(W) P; + box<P> b = geom::bbox(win); mln_image_from(W, bool) ima(b); level::fill(ima, false); mln_qiter(W) q(win, P::origin); @@ -174,8 +176,8 @@ const W& w_win = exact(w_win_); mln_precondition(! w_win.is_empty()); - typedef mln_point(W) P; - box_<P> b = geom::bbox(w_win); + typedef mln_site(W) P; + box<P> b = geom::bbox(w_win); mln_image_from(W, mln_weight(W)) ima(b); // Fill the image with zeros, as (weighted) windows are not // necessarily box-shaped (there might be holes corresponding to Index: mln/convert/to_std_set.hh --- mln/convert/to_std_set.hh (revision 2228) +++ mln/convert/to_std_set.hh (working copy) @@ -48,19 +48,19 @@ /// Convert a window \p win into a std::set of delta-points. template <typename W> - std::set<mln_dpoint(W)> to_std_set(const Window<W>& win); + std::set<mln_dpsite(W)> to_std_set(const Window<W>& win); /// Convert a point set \p pset into a std::set of points. template <typename W> - std::set<mln_point(W)> to_std_set(const Site_Set<W>& setp); + std::set<mln_site(W)> to_std_set(const Site_Set<W>& setp); # ifndef MLN_INCLUDE_ONLY template <typename W> inline - std::set<mln_dpoint(W)> to_std_set(const Window<W>& win) + std::set<mln_dpsite(W)> to_std_set(const Window<W>& win) { - typedef mln_dpoint(W) D; + typedef mln_dpsite(W) D; typedef mln_point(D) P; std::set<D> s; mln_qiter(W) q(exact(win), P::origin); @@ -71,9 +71,9 @@ template <typename W> inline - std::set<mln_point(W)> to_std_set(const Site_Set<W>& setp) + std::set<mln_site(W)> to_std_set(const Site_Set<W>& setp) { - typedef mln_point(W) P; + typedef mln_site(W) P; std::set<P> s; mln_piter(W) p(exact(setp)); for_all(p) Index: mln/convert/to_p_set.hh --- mln/convert/to_p_set.hh (revision 2228) +++ mln/convert/to_p_set.hh (working copy) @@ -61,7 +61,7 @@ /// Convert a Window \p win into a point set. template <typename W> - p_set<mln_point(W)> to_p_set(const Window<W>& win); + p_set<mln_site(W)> to_p_set(const Window<W>& win); /// Convert an std::set \p s of points into a point set. template <typename P> @@ -110,10 +110,10 @@ template <typename W> inline - p_set<mln_point(W)> to_p_set(const Window<W>& win) + p_set<mln_site(W)> to_p_set(const Window<W>& win) { - typedef mln_dpoint(W) D; - typedef mln_point(W) P; + typedef mln_dpsite(W) D; + typedef mln_site(W) P; p_set<P> pset; mln_qiter(W) q(exact(win), P::origin); for_all(q) Index: mln/geom/bbox.hh --- mln/geom/bbox.hh (revision 2228) +++ mln/geom/bbox.hh (working copy) @@ -37,9 +37,15 @@ * "set::nsites(Site_Set)"... * * \todo Add a static check "domain is ok for bbox (like grid)". + * + * \todo Add the weighted_window case. */ # include <mln/core/concept/box.hh> +# include <mln/core/concept/image.hh> +# include <mln/core/concept/window.hh> +# include <mln/literal/zero.hh> +# include <mln/accu/bbox.hh> namespace mln @@ -58,6 +64,12 @@ box<mln_site(I)> bbox(const Image<I>& ima); + /// Compute the precise bounding box of a window \p win. + template <typename W> + box<mln_site(W)> bbox(const Window<W>& win); + + + # ifndef MLN_INCLUDE_ONLY namespace impl @@ -123,6 +135,17 @@ return geom::bbox(ima.domain()); } + template <typename W> + box<mln_site(W)> bbox(const Window<W>& win) + { + typedef mln_site(W) P; + accu::bbox<P> b; + mln_qiter(W) q(exact(win), literal::origin); + for_all(q) + b.take(q); + return b; + } + # endif // ! MLN_INCLUDE_ONLY } // end of namespace mln::geom Index: mln/geom/sym.hh --- mln/geom/sym.hh (revision 2228) +++ mln/geom/sym.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -62,7 +62,8 @@ W sym(const Window<W>& win) { W tmp = exact(win); - return tmp.sym(); + tmp.sym(); + return tmp; } template <typename W> @@ -70,7 +71,8 @@ W sym(const Weighted_Window<W>& w_win) { W tmp = exact(w_win); - return tmp.sym(); + tmp.sym(); + return tmp; } # endif // ! MLN_INCLUDE_ONLY Index: mln/geom/shift.hh --- mln/geom/shift.hh (revision 2228) +++ mln/geom/shift.hh (working copy) @@ -46,19 +46,19 @@ /// Shift a window \p win with a delta-point \p dp. template <typename W> - window<mln_dpoint(W)> - shift(const Window<W>& win, const mln_dpoint(W)& dp); + window<mln_dpsite(W)> + shift(const Window<W>& win, const mln_dpsite(W)& dp); # ifndef MLN_INCLUDE_ONLY template <typename W> inline - window<mln_dpoint(W)> - shift(const Window<W>& win, const mln_dpoint(W)& dp) + window<mln_dpsite(W)> + shift(const Window<W>& win, const mln_dpsite(W)& dp) { - typedef mln_point(W) P; - window<mln_dpoint(W)> tmp; + typedef mln_site(W) P; + window<mln_dpsite(W)> tmp; mln_qiter(W) q(win, P::origin); for_all(q) tmp.insert(convert::to(q) + dp); Index: mln/win/vline2d.hh --- mln/win/vline2d.hh (revision 2228) +++ mln/win/vline2d.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -54,7 +54,7 @@ * o \n * is defined with length = 3. */ - typedef line<grid::square, 0, int> vline2d; + typedef line<grid::square, 0, def::coord> vline2d; } // end of namespace mln::win Index: mln/win/hline2d.hh --- mln/win/hline2d.hh (revision 2228) +++ mln/win/hline2d.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -52,7 +52,7 @@ * o o x o o \n * is defined with length = 5. */ - typedef line<grid::square, 1, int> hline2d; + typedef line<grid::square, 1, def::coord> hline2d; } // end of namespace mln::win Index: mln/win/cube3d.hh --- mln/win/cube3d.hh (revision 2228) +++ mln/win/cube3d.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -33,10 +33,9 @@ * \brief Definition of the mln::win::cube3d window. */ -# include <mln/core/concept/window.hh> +# include <mln/core/internal/window_base.hh> # include <mln/core/internal/dpoints_base.hh> # include <mln/core/alias/dpoint3d.hh> -# include <mln/core/dpoints_piter.hh> namespace mln @@ -64,29 +63,9 @@ * o o o \n * is defined with length = 3. */ - struct cube3d : public Window< cube3d >, + struct cube3d : public internal::window_base< dpoint3d, cube3d >, public internal::dpoints_base_< dpoint3d, cube3d > { - /// Point associated type. - typedef point3d point; - - /// Dpoint associated type. - typedef dpoint3d dpoint; - - /*! \brief Site_Iterator type to browse a cube such as: "for each row - * (increasing), for each column (increasing)." - */ - typedef dpoints_fwd_piter<dpoint3d> fwd_qiter; - - /*! \brief Site_Iterator type to browse a cube such as: "for each row - * (decreasing), for each column (decreasing)." - */ - typedef dpoints_bkd_piter<dpoint3d> bkd_qiter; - - /*! \brief Same as fwd_qiter. - */ - typedef fwd_qiter qiter; - /*! \brief Constructor. * * \param[in] length Length, thus height, of the cube3d. Index: mln/win/segment1d.hh --- mln/win/segment1d.hh (revision 2228) +++ mln/win/segment1d.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -52,7 +52,7 @@ * o x o \n * is defined with length = 3. */ - typedef line<grid::tick, 0, int> segment1d; + typedef line<grid::tick, 0, def::coord> segment1d; } // end of namespace mln::win Index: mln/win/line.hh --- mln/win/line.hh (revision 2228) +++ mln/win/line.hh (working copy) @@ -33,10 +33,9 @@ * \brief Definition of the mln::win::line window. */ -# include <mln/core/concept/window.hh> +# include <mln/core/internal/window_base.hh> # include <mln/core/internal/dpoints_base.hh> # include <mln/core/dpoint.hh> -# include <mln/core/dpoints_piter.hh> namespace mln @@ -57,27 +56,9 @@ * \see mln::win::hline2d for an exemple of his use. */ template <typename M, unsigned i, typename C> - struct line : public Window< line<M,i,C> >, - public internal::dpoints_base_<dpoint<M, C>, point<M, C> > + struct line : public internal::window_base< dpoint<M, C>, line<M,i,C> >, + public internal::dpoints_base_< dpoint<M, C>, line<M,i,C> > { - /// Point associated type. - typedef point<M, int> point; - - /// Psite associated type. - typedef point psite; - - /// Dpoint associated type. - typedef dpoint<M, int> dpoint; - - /// Site_Iterator type to browse a line forward - typedef dpoints_fwd_piter<dpoint> fwd_qiter; - - /// Site_Iterator type to browse a line backward - typedef dpoints_bkd_piter<dpoint> bkd_qiter; - - /// Same as fwd_qiter - typedef fwd_qiter qiter; - /*! \brief Constructor. * * \param[in] length Length of the line. @@ -140,11 +121,11 @@ { metal::bool_< i < M::dim >::check(); mln_precondition(length % 2 == 1); + dpoint<M,C> n; + n.set_all(0); const int dc = length / 2; for (int c = - dc; c <= dc; ++c) { - dpoint n; - n.set_all(0); n[i] = c; this->insert(n); } Index: mln/win/rectangle2d.hh --- mln/win/rectangle2d.hh (revision 2228) +++ mln/win/rectangle2d.hh (working copy) @@ -35,7 +35,9 @@ * \todo Reactivate includes at EOF. */ -# include <mln/core/alias/window2d.hh> +# include <mln/core/internal/window_base.hh> +# include <mln/core/internal/dpoints_base.hh> +# include <mln/core/alias/dpoint2d.hh> namespace mln @@ -55,22 +57,9 @@ * o o o o o \n * is defined with height = 3 and width = 5. */ - struct rectangle2d : public internal::window_base< dpoint2d, rectangle2d > + struct rectangle2d : public internal::window_base< dpoint2d, rectangle2d >, + public internal::dpoints_base_< dpoint2d, rectangle2d > { - - /*! \brief Site_Iterator type to browse a rectangle such as: "for each row - * (increasing), for each column (increasing)." - */ - typedef dpsites_fwd_piter<rectangle2d> fwd_qiter; - - /*! \brief Site_Iterator type to browse a rectangle such as: "for each row - * (decreasing), for each column (decreasing)." - */ - typedef dpsites_fwd_piter<rectangle2d> bkd_qiter; - - typedef fwd_qiter qiter; - - /*! \brief Constructor. * * \param[in] height Height of the rectangle2d. @@ -117,7 +106,6 @@ protected: unsigned height_, width_; - window2d win_; }; @@ -146,7 +134,7 @@ const int drow = height / 2, dcol = width / 2; for (int row = - drow; row <= drow; ++row) for (int col = - dcol; col <= dcol; ++col) - win_.insert(row, col); + this->insert(dpoint2d(row, col)); } inline @@ -215,8 +203,8 @@ // When rectangle2d is involved, one surely also wants: -// # include <mln/win/hline2d.hh> -// # include <mln/win/vline2d.hh> +# include <mln/win/hline2d.hh> +# include <mln/win/vline2d.hh> #endif // ! MLN_WIN_RECTANGLE2D_HH Index: mln/win/diag2d.hh --- mln/win/diag2d.hh (revision 2228) +++ mln/win/diag2d.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -33,10 +33,9 @@ * \brief Definition of the mln::win::diag2d window. */ -# include <mln/core/concept/window.hh> +# include <mln/core/internal/window_base.hh> # include <mln/core/internal/dpoints_base.hh> # include <mln/core/alias/dpoint2d.hh> -# include <mln/core/dpoints_piter.hh> namespace mln @@ -58,29 +57,9 @@ * o \n * is defined with length = 5. */ - struct diag2d : public Window< diag2d >, + struct diag2d : public internal::window_base< dpoint2d, diag2d >, public internal::dpoints_base_< dpoint2d, diag2d > { - /// Point associated type. - typedef point2d point; - - /// Dpoint associated type. - typedef dpoint2d dpoint; - - /*! \brief Site_Iterator type to browse a hline such as: "for each row - * (increasing), for each column (increasing)." - */ - typedef dpoints_fwd_piter<dpoint2d> fwd_qiter; - - /*! \brief Site_Iterator type to browse a hline such as: "for each row - * (decreasing), for each column (decreasing)." - */ - typedef dpoints_bkd_piter<dpoint2d> bkd_qiter; - - /*! \brief Same as fwd_qiter. - */ - typedef fwd_qiter qiter; - /*! \brief Constructor. * * \param[in] length Length, thus width, of the diagonal line. Index: mln/win/backdiag2d.hh --- mln/win/backdiag2d.hh (revision 2228) +++ mln/win/backdiag2d.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -33,10 +33,9 @@ * \brief Definition of the mln::win::backdiag2d window. */ -# include <mln/core/concept/window.hh> +# include <mln/core/internal/window_base.hh> # include <mln/core/internal/dpoints_base.hh> # include <mln/core/alias/dpoint2d.hh> -# include <mln/core/dpoints_piter.hh> namespace mln @@ -58,29 +57,9 @@ * o \n * is defined with length = 5. */ - struct backdiag2d : public Window< backdiag2d >, + struct backdiag2d : public internal::window_base< dpoint2d, backdiag2d >, public internal::dpoints_base_< dpoint2d, backdiag2d > { - /// Point associated type. - typedef point2d point; - - /// Dpoint associated type. - typedef dpoint2d dpoint; - - /*! \brief Site_Iterator type to browse a hline such as: "for each row - * (increasing), for each column (increasing)." - */ - typedef dpoints_fwd_piter<dpoint2d> fwd_qiter; - - /*! \brief Site_Iterator type to browse a hline such as: "for each row - * (decreasing), for each column (decreasing)." - */ - typedef dpoints_bkd_piter<dpoint2d> bkd_qiter; - - /*! \brief Same as fwd_qiter. - */ - typedef fwd_qiter qiter; - /*! \brief Constructor. * * \param[in] length Length, thus width, of the diagonal line. Index: mln/win/cuboid3d.hh --- mln/win/cuboid3d.hh (revision 2228) +++ mln/win/cuboid3d.hh (working copy) @@ -31,10 +31,9 @@ /// \file mln/win/cuboid3d.hh /// \brief Definition of the mln::win::cuboid3d window. -# include <mln/core/concept/window.hh> +# include <mln/core/internal/window_base.hh> # include <mln/core/internal/dpoints_base.hh> # include <mln/core/alias/dpoint3d.hh> -# include <mln/core/dpoints_piter.hh> namespace mln @@ -74,29 +73,9 @@ Reference: http://en.wikipedia.org/wiki/Cuboid */ - struct cuboid3d : public Window< cuboid3d >, + struct cuboid3d : public internal::window_base< dpoint3d, cuboid3d >, public internal::dpoints_base_< dpoint3d, cuboid3d > { - /// Point Site associated type. - typedef point3d psite; - - /// Point associated type. - typedef point3d point; - - /// Dpoint associated type. - typedef dpoint3d dpoint; - - /// \brief Site_Iterator type to browse a cuboid such as: "for - /// each slice (increasing), for each row (increasing), for each - /// column (increasing)." - typedef dpoints_fwd_piter<dpoint3d> fwd_qiter; - - /// \brief Site_Iterator type to browse a cuboid such as: "for - /// each slice (decreasing), for each row (decreasing), for each - /// column (decreasing)." - typedef dpoints_bkd_piter<dpoint3d> bkd_qiter; - - /// \brief Constructor. /// /// \param[in] depth The depth of the cuboid3d. Index: mln/win/octagon2d.hh --- mln/win/octagon2d.hh (revision 2228) +++ mln/win/octagon2d.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -33,10 +33,9 @@ * \brief Definition of the mln::win::octagon2d window. */ -# include <mln/core/concept/window.hh> +# include <mln/core/internal/window_base.hh> # include <mln/core/internal/dpoints_base.hh> # include <mln/core/alias/dpoint2d.hh> -# include <mln/core/dpoints_piter.hh> namespace mln @@ -62,29 +61,9 @@ * o o o \n * is defined with L = 7 (l = 1). */ - struct octagon2d : public Window< octagon2d >, + struct octagon2d : public internal::window_base< dpoint2d, octagon2d >, public internal::dpoints_base_< dpoint2d, octagon2d > { - /// Point associated type. - typedef point2d point; - - /// Dpoint associated type. - typedef dpoint2d dpoint; - - /*! \brief Site_Iterator type to browse a hline such as: "for each row - * (increasing), for each column (increasing)." - */ - typedef dpoints_fwd_piter<dpoint2d> fwd_qiter; - - /*! \brief Site_Iterator type to browse a hline such as: "for each row - * (decreasing), for each column (decreasing)." - */ - typedef dpoints_bkd_piter<dpoint2d> bkd_qiter; - - /*! \brief Same as fwd_qiter. - */ - typedef fwd_qiter qiter; - /*! \brief Constructor. * * \param[in] length Length, of the octagon. Index: mln/win/disk2d.hh --- mln/win/disk2d.hh (revision 2228) +++ mln/win/disk2d.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -33,10 +33,9 @@ * \brief Definition of the mln::win::disk2d window. */ -# include <mln/core/concept/window.hh> +# include <mln/core/internal/window_base.hh> # include <mln/core/internal/dpoints_base.hh> # include <mln/core/alias/dpoint2d.hh> -# include <mln/core/dpoints_piter.hh> namespace mln @@ -50,29 +49,9 @@ * An disk2d is centered and symmetric. * */ - struct disk2d : public Window< disk2d >, + struct disk2d : public internal::window_base< dpoint2d, disk2d >, public internal::dpoints_base_< dpoint2d, disk2d > { - /// Point associated type. - typedef point2d point; - - /// Dpoint associated type. - typedef dpoint2d dpoint; - - /*! \brief Site_Iterator type to browse a hline such as: "for each row - * (increasing), for each column (increasing)." - */ - typedef dpoints_fwd_piter<dpoint2d> fwd_qiter; - - /*! \brief Site_Iterator type to browse a hline such as: "for each row - * (decreasing), for each column (decreasing)." - */ - typedef dpoints_bkd_piter<dpoint2d> bkd_qiter; - - /*! \brief Same as fwd_qiter. - */ - typedef fwd_qiter qiter; - /*! \brief Constructor. * * \param[in] length Length, thus diameter.