
Index: olena/ChangeLog from Damien Thivolle <damien@lrde.epita.fr> * olena/oln/core/abstract/dpoint.hh: Add comments. * olena/oln/core/abstract/image_size.hh: Add comments. * olena/oln/core/abstract/point.hh: Add comments. * olena/oln/core/abstract/image.hh: Add comments. * olena/oln/core/abstract/image_with_dim.hh: Add comments. * olena/oln/core/abstract/image_with_impl.hh: Add comments. * olena/oln/core/abstract/image_with_type.hh: Add comments. * olena/oln/core/abstract/image_with_type_with_dim.hh: Add comments. * olena/oln/core/abstract/behavior.hh: Add comments. Index: olena/oln/core/abstract/dpoint.hh --- olena/oln/core/abstract/dpoint.hh Fri, 23 Jan 2004 16:23:03 +0100 astrid (oln/d/28_dpoint.hh 1.18 640) +++ olena/oln/core/abstract/dpoint.hh Thu, 11 Mar 2004 16:55:50 +0100 thivol_d (oln/d/28_dpoint.hh 1.18 640) @@ -1,4 +1,4 @@ -// Copyright (C) 2001, 2002, 2003 EPITA Research and Development Laboratory +// Copyright (C) 2001, 2002, 2003, 2004 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 @@ -35,16 +35,22 @@ namespace oln { + namespace abstract { template<class Exact> struct dpoint; // fwd_decl template<class Exact> - struct point; + struct point; // fwd_decl } // end of abstract template<class Exact> - struct dpoint_traits; + struct dpoint_traits; // fwd_decl + + /*! \class dpoint_traits<abstract::dpoint<Exact> > + ** + ** The specialized version for abstract::dpoint<Exact>. + */ template<class Exact> struct dpoint_traits<abstract::dpoint<Exact> > @@ -52,7 +58,15 @@ }; + namespace abstract { + + /*! \class dpoint + ** + ** The abstract dpoint class from whom derives + ** all the others dpoint classes. + */ + template<class Exact> struct dpoint : public mlc_hierarchy::any<Exact> { @@ -62,54 +76,93 @@ enum { dim = dpoint_traits<exact_type>::dim }; typedef typename dpoint_traits<exact_type>::point_type point_type; + /*! \brief Construct a dpoint with the same coordinates + ** a the point \a p. + */ + explicit dpoint(const abstract::point<point_type>& p) { for (unsigned i = 0; i < dim; ++i) nth(i) = p.exact().nth(i); } + /// Return the dth coordinate of the current dpoint. + coord nth(const unsigned d) const { return coord_[d]; } + /// Return a reference to the dth coordinate of the current dpoint. coord& nth(const unsigned d) { return coord_[d]; } + /*! \brief Return a dpoint whose coordinates are the opposite + ** of the current dpoint coordinates. + */ + exact_type operator-() const { return this->exact().minus(); } + /*! \brief Add a dpoint \a dp to the current dpoint. + ** + ** \return A reference to the current dpoint plus \a dp. + */ + exact_type& operator+=(const self_type& dp) { return this->exact().plus_assign_dp(dp.exact()); } + /*! \brief Subtract a dpoint \a dp from the current dpoint. + ** + ** \return A reference to the current point minus \a dp. + */ + exact_type& operator-=(const self_type& dp) { return this->exact().minus_assign_dp(dp.exact()); } + /*! \brief Add a dpoint \a dp to the current dpoint. + ** + ** \return The value of the current point plus \a dp. + */ + exact_type operator+(const self_type& dp) const { return this->exact().plus_dp(dp.exact()); } + /*! \brief Subtract a dpoint \a dp from the current dpoint. + ** + ** \return The value of the current point minus \a dp. + */ + exact_type operator-(const self_type& dp) const { return this->exact().minus_dp(dp.exact()); } + /*! \brief Test if two dpoints have the same coordinates. + ** + ** \arg dp A dpoint. + ** + ** \return True if \a dp and the current point have the same + ** coordinate, false otherwise. + */ + bool operator==(const self_type& dp) const { @@ -119,6 +172,14 @@ return true; } + /*! \brief Test if two dpoints do not have the same coordinates. + ** + ** \arg dp A dpoint. + ** + ** \return False if \a dp and the current point have the same + ** coordinate, true otherwise. + */ + bool operator!=(const self_type& dp) const { @@ -128,6 +189,12 @@ return false; } + /*! \brief Test if all the dpoint coordinates are set to zero. + ** + ** \return True if all the coordinates of the current dpoint + ** are set to zero. + */ + bool is_centered(void) const { @@ -137,6 +204,8 @@ return true; } + /// Return the norm of the current dpoint. + ntg::float_d norm2(void) const { @@ -147,6 +216,8 @@ return sqrt(norm); } + /// Return the square of the norm of the current dpoint. + ntg::float_d sqr_norm2(void) const { @@ -176,11 +247,30 @@ } // end of abstract + /*! \namespace oln::internal + ** \brief internal namespace. + */ + + namespace internal { + + /*! \class default_less< abstract::dpoint<Exact> > + ** + ** The specialized version for < abstract::dpoint<Exact> >. + */ + + template<class Exact> struct default_less< abstract::dpoint<Exact> > { + + /*! \brief Test if the coordinates of a dpoint l + ** are not greater than the coordinates of a dpoint r. + ** + ** \return True if the coordinates of l are not greater + ** than the coordinates of r. + */ bool operator()(const abstract::dpoint<Exact>& l, const abstract::dpoint<Exact>& r) const { Index: olena/oln/core/abstract/image_size.hh --- olena/oln/core/abstract/image_size.hh Thu, 07 Aug 2003 02:08:21 +0200 david (oln/c/41_image_size 1.10 640) +++ olena/oln/core/abstract/image_size.hh Thu, 11 Mar 2004 16:55:46 +0100 thivol_d (oln/c/41_image_size 1.10 640) @@ -1,4 +1,4 @@ -// Copyright (C) 2001, 2002, 2003 EPITA Research and Development Laboratory +// Copyright (C) 2001, 2002, 2003, 2004 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,10 +34,14 @@ # include <ntg/utils/debug.hh> # include <sstream> + + namespace oln { namespace abstract { + + template<class Exact> struct image_size; // fwd_decl @@ -46,13 +50,28 @@ template<class Exact> struct image_size_traits; + /*! \class image_size_traits<abstract::image_size<Exact> > + ** + ** A class specialized for each image type + ** which gives the dimension of the template + ** parameter. + */ + template<class Exact> struct image_size_traits<abstract::image_size<Exact> > { }; + namespace abstract { + + /*! \class image_size + ** + ** The class that defines the image size + ** according to its dimension. + */ + template<class Exact> struct image_size : public mlc_hierarchy::any< Exact > { @@ -61,6 +80,10 @@ enum { dim = image_size_traits<Exact>::dim }; + /*! \brief Return the number of coordinates + ** in the nth section of the image. + */ + coord nth(unsigned n) const { @@ -68,6 +91,11 @@ return coord_[n]; } + /*! \brief Return a reference to the number of coordinates + ** in the nth section of the image. + */ + + coord& nth(unsigned n) { @@ -75,18 +103,27 @@ return coord_[n]; } + /// Return the value border width of the current image. coord border() const { return border_; } + /// Return a reference to the border width of the current image. + coord& border() { return border_; } + /*! \brief Test if two images + ** have compatible size. + ** + ** \return True if the two images have compatible size, false otherwise. + */ + template< class S > bool operator==(const image_size<S>& size) const @@ -97,6 +134,11 @@ return true; } + /*! \brief Test if two images do not have compatible size + ** + ** \return False if the two images have compatible size, true otherwise. + */ + template< class S > bool operator!=(const image_size<S>& size) const @@ -108,6 +150,7 @@ } + static std::string name() { @@ -117,13 +160,25 @@ protected: + image_size() {} + /*! border_ represents the width of the image border + ** such a mecanism allow algorithm to perform operation + ** on the points at the edge of the image as if they were + ** normally surrounded by points + */ + coord border_; private: + + /*! \brief An array that contains the number + ** of coordinates for each dimension. + */ + coord coord_[dim]; }; Index: olena/oln/core/abstract/point.hh --- olena/oln/core/abstract/point.hh Thu, 07 Aug 2003 02:08:21 +0200 david (oln/c/33_point.hh 1.15 640) +++ olena/oln/core/abstract/point.hh Thu, 11 Mar 2004 16:55:53 +0100 thivol_d (oln/c/33_point.hh 1.15 640) @@ -1,4 +1,4 @@ -// Copyright (C) 2001, 2002, 2003 EPITA Research and Development Laboratory +// Copyright (C) 2001, 2002, 2003, 2004 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 @@ -35,19 +35,23 @@ # include <iostream> # include <sstream> - namespace oln { namespace abstract { template<class Exact> - struct point; + struct point; // fwd declaration template<class Exact> - struct dpoint; + struct dpoint; // fwd declaration } // end of abstract template<class Exact> - struct point_traits; + struct point_traits; // fwd declaration + + /*! \class point_traits<abstract::point<Exact> > + ** + ** The specialized implementation for abstract::point. + */ template<class Exact> struct point_traits<abstract::point<Exact> > @@ -56,6 +60,13 @@ }; namespace abstract { + + /*! \class point + ** + ** The abstract class from whom derives all the others + ** point classes. + */ + template<class Exact> struct point : public mlc_hierarchy::any<Exact> { @@ -65,56 +76,97 @@ typedef point<Exact> self_type; typedef Exact exact_type; typedef typename point_traits<Exact>::dpoint_type dpoint_type; + enum { dim = point_traits<Exact>::dim }; + /// Return the current point casted in exact_type. + const exact_type& point_ref() const { return this->exact(); } + /// Give the value of the nth coordinate of the point. + coord nth(const unsigned dim) const { return coord_[dim]; } + /// Return a reference to the nth coordinate of the point. + coord& nth(const unsigned dim) { return coord_[dim]; } + /*! \brief Add a delta point \a dp to the current point + ** + ** \return The current point plus \a dp. + */ + exact_type& operator+=(const abstract::dpoint<dpoint_type>& dp) { return this->exact().plus_assign_dp(dp.exact()); } + /*! \brief Subtract a delta point \a dp from the current point. + ** + ** \return The current point minus \a dp. + */ + + exact_type& operator-=(const abstract::dpoint<dpoint_type>& dp) { return this->exact().minus_assign_dp(dp.exact()); } + /*! \brief Subtract a point \a p from the current point. + ** + ** \return A reference to this current point minus \a p. + */ + dpoint_type operator-(const self_type& p) const { return this->exact().minus_p(p.exact()); } + + /*! \brief Give the result of the addition of + ** a delta point \a dp and the current point + ** + ** \return The result of the addition of \a dp and the current point. + */ + exact_type operator+(const abstract::dpoint<dpoint_type>& dp) const { return this->exact().plus_dp(dp.exact()); } + /*! \brief Give the result of the subtraction of + ** a delta point \a dp and the current point. + ** + ** \return The result of the subtraction of \a dp and the current point. + */ + + exact_type operator-(const abstract::dpoint<dpoint_type>& dp) const { return this->exact().minus_dp(dp.exact()); } + /*! \brief Return a point whose coordinates are + ** the opposite of the current point coordinates + */ + exact_type operator-() const { @@ -122,6 +174,12 @@ } + /*! \brief Test if \a p and the current point have the same coordinates + ** + ** \return True if \a p and the current point have the same coordinates, + ** false otherwise. + */ + bool operator==(const self_type& p) const { @@ -131,6 +189,14 @@ return true; } + + /*! \brief Test if \a p and the current point do + ** not have the same coordinates. + ** + ** \return False if \a p and the current point have + ** the same coordinates, true otherwise. + */ + bool operator!=(const self_type& p) const { @@ -153,17 +219,40 @@ private: + /*! \brief The coordinates of the point are stored + ** in this array. + */ + coord coord_[dim]; }; } // end of abstract + namespace internal { + + /*! \class default_less< abstract::point<Exact> > + ** + ** The specialized version for abstract::point. + */ + template<class Exact> struct default_less< abstract::point<Exact> > { + + /*! \brief Test if the coordinates of a point l + ** are not greater than the coordinates of a point r. + ** + ** \arg l A point. + ** + ** \arg r Another point. + ** + ** \return True if the coordinates of l are not greater + ** than the coordinates of r. + */ + bool operator()(const abstract::point<Exact>& l, const abstract::point<Exact>& r) const { Index: olena/oln/core/abstract/image.hh --- olena/oln/core/abstract/image.hh Wed, 11 Feb 2004 11:51:35 +0100 van-vl_n (oln/t/25_image.hh 1.20 640) +++ olena/oln/core/abstract/image.hh Thu, 11 Mar 2004 17:01:49 +0100 thivol_d (oln/t/25_image.hh 1.20 640) @@ -34,7 +34,10 @@ # include <oln/core/abstract/point.hh> # include <oln/core/abstract/iter.hh> + namespace oln { + + namespace abstract { // fwd_decl @@ -49,55 +52,119 @@ template<class Ima> struct image_traits; + /*! \class image_traits + ** + ** A helping structure to find the + ** exact_type of a given class. + */ + template <class Exact> struct image_traits<abstract::image<Exact> > { typedef Exact exact_type; }; + + namespace abstract { + /*! \class image + ** + ** The image class whom derives all + ** other image classes. + */ + template <class Exact> class image : public mlc_hierarchy::any_with_diamond<Exact> { public: typedef typename image_traits<Exact>::point_type point_type; + /*!< Prefer the macro oln_point_type(I) to retrieve the point_type + ** of an image. + ** + ** \see point + */ typedef typename image_traits<Exact>::dpoint_type dpoint_type; + /*!< Prefer the macro oln_dpoint_type(I) to retrieve the dpoint_type + ** of an image. + ** + ** \see dpoint + */ typedef typename image_traits<Exact>::iter_type iter_type; + /*!< Prefer the macro oln_iter_type(I) to retrieve the iter_type + ** of an image + ** + ** \see iter + */ typedef typename image_traits<Exact>::fwd_iter_type fwd_iter_type; + /*!< Forward iterator type. */ typedef typename image_traits<Exact>::bkd_iter_type bkd_iter_type; + /*!< Backward iterator type. */ typedef typename image_traits<Exact>::value_type value_type; + /*!< Prefer the macro oln_value_type(I) to retrieve the value_type + ** of an image. + */ typedef typename image_traits<Exact>::size_type size_type; + /*!< Indicate how the image size is handled. + ** + ** \see image_size + */ typedef typename image_traits<Exact>::impl_type impl_type; + /*!< Underlying implementation. */ typedef image<Exact> self_type; typedef Exact exact_type; enum { dim = image_traits<Exact>::dim }; + + /*! \brief Return a reference to the value stored + ** at \a p in the current image. + */ + const value_type& operator[](const abstract::point<point_type>& p) const { return this->exact().at(p.exact()); } + /*! \brief Return the value stored stored at \a p + ** in the current image. + */ + value_type& operator[](const abstract::point<point_type>& p) { return this->exact().at(p.exact()); } + /*! \brief Indicate if the image can be processed. + ** + ** \return True if the image can be processed, false otherwise. + */ + bool has_impl() const { return this->exact().impl() != 0; } + /*! \brief Clone the image, all the points are + ** duplicated. + ** + ** \return A real copy of the current image. + */ + exact_type clone() const { return this->exact().clone_(); } + /*! \brief Test if the point \a p belong to the image. + ** + ** \return True if p belong to the image, false otherwise. + */ + bool hold(const abstract::point<point_type>& p) const { @@ -105,6 +172,8 @@ return this->exact().impl()->hold(p.exact()); } + /// Return a reference to the image size. + const size_type& size() const { @@ -112,18 +181,32 @@ return this->exact().impl()->size(); } + /// Return the value of the border width. + coord border() const { return size().border(); } + /*! \brief Return the total number of points + ** in the current image. + */ + + size_t npoints() const { return this->exact().npoints_(); } + /*! \brief Perform a shallow copy from \rhs to + ** the current image, the points are not duplicated + ** but shared between the two images. + ** + ** \see image::clone() + */ + exact_type& operator=(self_type rhs) { @@ -140,6 +223,17 @@ // borders + + /*! \brief Set the width of the border to perform + ** operations on the image sides. + ** + ** \arg new_border The new value of the border width. + ** + ** \arg copy_border Its default value is false. + ** + ** \see image_size::border_ + */ + void border_set_width(coord new_border, bool copy_border = false) const { @@ -151,6 +245,17 @@ const_cast<impl_type *>(this->exact().impl())->border_reallocate_and_copy(new_border, copy_border); } + /*! \brief Adapt the border if min_border is + ** less or equal to the current border + ** value. + ** + ** \arg min_border The new value of the border width. + ** + ** \arg copy_border Its default value is false. + ** + ** \see image_size::border_ + */ + void border_adapt_width(coord min_border, bool copy_border = false) const @@ -162,6 +267,14 @@ this->exact().border_set_width(min_border, copy_border); } + /*! \brief The border points will have the same + ** value as the nearer real point of the image. + ** + ** \arg min_border The new value of the border width. + ** + ** \see image_size::border_ + */ + void border_adapt_copy(coord min_border) const { @@ -169,6 +282,13 @@ const_cast<impl_type *>(this->exact().impl())->border_replicate(); } + /*! \brief The border points value are set according + ** to the value of the points on the image sides. + ** + ** \arg min_border The new value of the border width. + ** + ** \see image_size::border_ + */ void border_adapt_mirror(coord min_border) const @@ -177,6 +297,16 @@ const_cast<impl_type *>(this->exact().impl())->border_mirror(); } + /*! \brief The border points value will be equal to + ** the \a val parameters. + ** + ** \arg min_border The new value of the border width. + ** + ** \arg val The new value of the border points. + ** + ** \see image_size::border_ + */ + void border_adapt_assign(coord min_border, value_type val) const { @@ -185,6 +315,7 @@ } protected: + image() {} Index: olena/oln/core/abstract/image_with_dim.hh --- olena/oln/core/abstract/image_with_dim.hh Thu, 07 Aug 2003 02:08:21 +0200 david (oln/t/26_image_with 1.18 640) +++ olena/oln/core/abstract/image_with_dim.hh Thu, 11 Mar 2004 16:55:46 +0100 thivol_d (oln/t/26_image_with 1.18 640) @@ -1,4 +1,4 @@ -// Copyright (C) 2001, 2003 EPITA Research and Development Laboratory +// Copyright (C) 2001, 2003, 2004 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 @@ -40,6 +40,8 @@ # include <cstdlib> + + namespace oln { // fwd decl @@ -66,59 +68,129 @@ } // end of namespace abstract + + /*! \class image_traits<abstract::image_with_dim<1, Exact> > + ** + ** The specialized version for 1d image. + */ + template <class Exact> struct image_traits<abstract::image_with_dim<1, Exact> > : public image_traits<abstract::image<Exact> > { + enum {dim = 1}; + /*!< Image1d dimension = 1. */ typedef point1d point_type; + /*!< Image1d point_type is point1d. */ typedef dpoint1d dpoint_type; + /*!< Image1d dpoint_type is dpoint1d. */ typedef fwd_iter1d<mlc::final> iter_type; + /*!< Image1d iter_type is fwd_iter1d<mlc::final>. */ typedef fwd_iter1d<mlc::final> fwd_iter_type; + /*!< Image1d fwd_iter_type is fwd_iter1d<mlc::final>. */ typedef bkd_iter1d<mlc::final> bkd_iter_type; + /*!< Image1d bkd_iter_type is bkd_iter1d<mlc::final>. */ typedef image1d_size size_type; + /*!< Image1d size_type is image1d_size. */ }; + + /*! \class image_traits<abstract::image_with_dim<2, Exact> > + ** + ** The specialized version for 2d image. + ** + */ + template <class Exact> struct image_traits<abstract::image_with_dim<2, Exact> > : public image_traits<abstract::image<Exact> > { enum {dim = 2}; + /*!< Imaged2 dimension = 2. */ typedef point2d point_type; + /*!< Imaged2 point_type is point2d. */ typedef dpoint2d dpoint_type; + /*!< Image2d dpoint_type is dpoint2d. */ typedef fwd_iter2d<mlc::final> iter_type; + /*!< Image2d iter_type is fwd_iter2d<mlc::final>. */ typedef fwd_iter2d<mlc::final> fwd_iter_type; + /*!< Image2d fwd_iter_type is fwd_iter2d<mlc::final>. */ typedef bkd_iter2d<mlc::final> bkd_iter_type; + /*!< Image2d bkd_iter_type is bkd_iter2d<mlc::final>. */ typedef image2d_size size_type; + /*!< Image2d size_type is image2d_size. */ }; + /*! \class image_traits<abstract::image_with_dim<3, Exact> > + ** + ** The specialized version for 3d image. + */ + template <class Exact> struct image_traits<abstract::image_with_dim<3, Exact> > : public image_traits<abstract::image<Exact> > { enum {dim = 3}; + /*!< Image3d dimension = 3. */ typedef point3d point_type; + /*!< Image3d point_type is point3d. */ typedef dpoint3d dpoint_type; + /*!< Image3d dpoint_type is dpoint3d. */ typedef fwd_iter3d<mlc::final> iter_type; + /*!< Image3d iter_type is fwd_iter3d<mlc::final>. */ typedef fwd_iter3d<mlc::final> fwd_iter_type; + /*!< Image3d fwd_iter_type is fwd_iter3d<mlc::final>. */ typedef bkd_iter3d<mlc::final> bkd_iter_type; + /*!< Image3d bkd_iter_type is bkd_iter3d<mlc::final>. */ typedef image3d_size size_type; + /*!< Image3d size_type is image3d_size. */ }; + namespace abstract { - // one-dimensional specialization + + /*! \class image_with_dim<1, Exact>: virtual public image<Exact> + ** + ** The specialized version for image1d. + */ + template <class Exact> class image_with_dim<1, Exact>: virtual public image<Exact> { public: typedef typename image_traits<Exact>::point_type point_type; + /*!< Prefer the macro oln_point_type(I) to retrieve the point_type + ** of an image. + ** + ** \see oln::point1d + */ typedef typename image_traits<Exact>::point_type dpoint_type; + /*!< Prefer the macro oln_dpoint_type(I) to retrieve the dpoint_type + ** of an image. + ** + ** \see oln::dpoint1d + */ typedef typename image_traits<Exact>::iter_type iter_type; + /*!< Prefer the macro oln_iter_type(I) to retrieve the iter_type + ** of an image. + ** + ** \see iter1d + */ typedef typename image_traits<Exact>::fwd_iter_type fwd_iter_type; + /*!< Forward iterator type. */ typedef typename image_traits<Exact>::bkd_iter_type bkd_iter_type; + /*!< Backward iterator type. */ typedef typename image_traits<Exact>::value_type value_type; + /*!< Prefer the macro oln_value_type(I) to retrieve the value_type + ** of an image. + */ typedef typename image_traits<Exact>::size_type size_type; + /*!< Indicate how the image size is handled. + ** + ** \see oln::image1d_size + */ typedef image<Exact> super_type; typedef image_with_dim<1, Exact> self_type; @@ -126,18 +198,29 @@ friend class image<exact_type>; + + /// Return the number of columns in the current image. + coord ncols() const { return this->size().ncols(); } + /*! \brief Return the value stored at \a col coordinate + ** in the current image. + */ + const value_type operator()(coord col) const { return this->exact()[point_type(col)]; } + /*! \brief Return a reference to the value stored + ** at \a col coordinate in the current image. + */ + value_type& operator()(coord col) { @@ -146,12 +229,26 @@ using super_type::hold; + /*! \brief Test if a point belongs to the current image. + ** + ** \arg col Column coordinate of the point. + ** + ** \return True if the point belongs to the image, false otherwise. + */ + bool hold(coord col) const { return hold(point_type(col)); } + /*! \brief Perform a shallow copy from \a rhs to + ** the current image, the points are not duplicated + ** but shared between the two images + ** + ** \see image::clone() + */ + exact_type& operator=(self_type rhs) { @@ -169,6 +266,7 @@ protected: + /// Return the total number of points in the current image. size_t npoints_() const { @@ -180,43 +278,88 @@ }; // end of one-dimensional specialization - // bi-dimensional specialization + + + /*! \class image_with_dim<2, Exact>: virtual public image<Exact> + ** + ** The specialized version for image2d. + */ + + template <class Exact> class image_with_dim<2, Exact>: virtual public image<Exact> { public: + typedef typename image_traits<Exact>::point_type point_type; - typedef typename image_traits<Exact>::dpoint_type dpoint_type; + /*!< Prefer the macro oln_point_type(I) to retrieve the point_type + ** of an image. + ** + ** \see oln::point2d + */ + typedef typename image_traits<Exact>::point_type dpoint_type; + /*!< Prefer the macro oln_dpoint_type(I) to retrieve the dpoint_type + ** of an image. + ** + ** \see oln::dpoint2d + */ typedef typename image_traits<Exact>::iter_type iter_type; + /*!< Prefer the macro oln_iter_type(I) to retrieve the iter_type + ** of an image. + ** + ** \see iter2d + */ typedef typename image_traits<Exact>::fwd_iter_type fwd_iter_type; + /*!< Forward iterator type. */ typedef typename image_traits<Exact>::bkd_iter_type bkd_iter_type; + /*!< Backward iterator type. */ typedef typename image_traits<Exact>::value_type value_type; + /*!< Prefer the macro oln_value_type(I) to retrieve the value_type + ** of an image. + */ typedef typename image_traits<Exact>::size_type size_type; + /*!< Indicate how the image size is handled. + ** + ** \see oln::image2d_size + */ + typedef image<Exact> super_type; typedef image_with_dim<2, Exact> self_type; typedef Exact exact_type; - typedef image<Exact> super_type; friend class image<exact_type>; + + /// Return the number of rows in the current image. coord nrows() const { return this->size().nrows(); } + + /// Return the number of columns in the current image. + coord ncols() const { return this->size().ncols(); } + /*! \brief Return the value stored at \a row, \a col + ** coordinates on the current image. + */ + const value_type operator()(coord row, coord col) const { return this->exact()[point_type(row, col)]; } + /*! \brief Return a reference to the value stored + ** at \a row, \a col coordinates on the current image. + */ + value_type& operator()(coord row, coord col) { @@ -225,12 +368,29 @@ using super_type::hold; + /*! \brief Test if a point belongs to the current image. + ** + ** \arg row Row coordinate of the point. + ** + ** \arg col Column coordinate of the point. + ** + ** \return True if the point belongs to the image, false otherwise. + */ + bool hold(coord row, coord col) const { return hold(point_type(row, col)); } + /*! \brief Perform a shallow copy from \a rhs + ** to the current image, the points are not + ** duplicated but shared between the two + ** image. + ** + ** \see image::clone() + */ + exact_type& operator=(self_type rhs) { @@ -248,6 +408,9 @@ protected: + + /// Return the total number of points in the current image. + size_t npoints_() const { @@ -259,49 +422,97 @@ }; // end of bi-dimensional specialization - // tri-dimensional specialization + + /*! \class image_with_dim<3, Exact>: virtual public image<Exact> + ** + ** The specialized version for image3d. + */ + template <class Exact> class image_with_dim<3, Exact>: virtual public image<Exact> { public: typedef typename image_traits<Exact>::point_type point_type; + /*!< Prefer the macro oln_point_type(I) to retrieve the point_type + ** of an image. + ** + ** \see oln::point3d + */ typedef typename image_traits<Exact>::point_type dpoint_type; + /*!< Prefer the macro oln_dpoint_type(I) to retrieve the dpoint_type + ** of an image. + ** + ** \see oln::dpoint3d + */ typedef typename image_traits<Exact>::iter_type iter_type; + /*!< Prefer the macro oln_iter_type(I) to retrieve the iter_type + ** of an image. + ** + ** \see iter3d + */ typedef typename image_traits<Exact>::fwd_iter_type fwd_iter_type; + /*!< Forward iterator type. */ typedef typename image_traits<Exact>::bkd_iter_type bkd_iter_type; + /*!< Backward iterator type. */ typedef typename image_traits<Exact>::value_type value_type; + /*!< Prefer the macro oln_value_type(I) to retrieve the value_type + ** of an image. + */ typedef typename image_traits<Exact>::size_type size_type; - typedef image<Exact> super_type; + /*!< Indicate how the image size is handled. + ** + ** \see oln::image3d_size + */ + typedef image<Exact> super_type; typedef image_with_dim<3, Exact> self_type; typedef Exact exact_type; friend class image<exact_type>; + + + /// Return the number of slices in the current image. + coord nslices() const { return this->size().nslices(); } + + /// Return the number of rows in the current image. + coord nrows() const { return this->size().nrows(); } + /// Return the number of columns in the image. + */ + coord ncols() const { return this->size().ncols(); } + /*! \brief Return the value stored at \a slice, \a row + ** and \a col coordinates on the current image. + */ + const value_type operator()(coord slice, coord row, coord col) const { return this->exact()[point_type(slice, row, col)]; } + /*! \brief Return a reference to the value stored + ** at \a slice, \a row and \a col coordinates on + ** the current image. + */ + value_type& operator()(coord slice, coord row, coord col) { @@ -310,12 +521,31 @@ using super_type::hold; + /*! \brief Test if a point belongs to the current image. + ** + ** \arg slice Slice coordinate of the point. + ** + ** \arg row Row coordinate of the point. + ** + ** \arg col Column coordinate of the point. + ** + ** \return True if the point belongs to the image, false otherwise. + */ + bool hold(coord slice, coord row, coord col) const { return hold(point_type(slice, row, col)); } + /*! \brief Perform a shallow copy from \a rhs + ** to the current image, the points are not + ** duplicated but shared between the two + ** image. + ** + ** \see image::clone() + */ + exact_type& operator=(self_type rhs) { @@ -333,12 +563,17 @@ protected: + + + /// Return the total number of points in the current image. + size_t npoints_() const { return size_t(nslices()) * size_t(nrows()) * size_t(ncols()); } + image_with_dim() : super_type() {} @@ -349,6 +584,7 @@ } // end of namespace oln +/// Print all the values contained in the image on an output stream. template<class Exact> inline std::ostream& @@ -362,6 +598,9 @@ return o; } + +/// Print all the values contained in the image on an output stream. + template<class Exact> inline std::ostream& operator<<(std::ostream& o, const oln::abstract::image_with_dim<2, Exact>& ima) @@ -382,6 +621,8 @@ return o; } +/// Print all the values contained in the image on an output stream. + template<class Exact> inline std::ostream& operator<<(std::ostream& o, const oln::abstract::image_with_dim<3, Exact>& ima) Index: olena/oln/core/abstract/image_with_impl.hh --- olena/oln/core/abstract/image_with_impl.hh Mon, 25 Aug 2003 11:47:33 +0200 burrus_n (oln/t/27_image_with 1.14.1.8 640) +++ olena/oln/core/abstract/image_with_impl.hh Thu, 11 Mar 2004 16:55:46 +0100 thivol_d (oln/t/27_image_with 1.14.1.8 640) @@ -1,4 +1,4 @@ -// Copyright (C) 2001, 2003 EPITA Research and Development Laboratory +// Copyright (C) 2001, 2003, 2004 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,6 +31,7 @@ # include <oln/core/abstract/image_with_type_with_dim.hh> # include <oln/core/impl/image_impl.hh> + namespace oln { namespace abstract { @@ -40,6 +41,13 @@ } // end of namespace abstract + /*! \class image_traits<abstract::image_with_impl<Impl, Exact> > + ** + ** The specialized version for image_with_impl, + ** give the impl_type of an image. + ** + */ + template<class Impl, class Exact> struct image_traits<abstract::image_with_impl<Impl, Exact> > : public image_traits<typename abstract::image_with_dim<image_id<Exact>::dim, Exact> >, @@ -48,30 +56,66 @@ typedef Impl impl_type; }; + + namespace abstract { + /*! \class image_with_impl + ** + ** This class contains all the implementation relative methods. + */ + template<class Impl, class Exact> class image_with_impl: public image_with_type_with_dim_switch<Exact>::ret { public: + typedef typename image_traits<Exact>::point_type point_type; + /*!< Prefer the macro oln_point_type(I) to retrieve the point_type + ** of an image. + ** + ** \see point + */ typedef typename image_traits<Exact>::iter_type iter_type; + /*!< Prefer the macro oln_iter_type(I) to retrieve the iter_type + ** of an image. + ** + ** \see iter + */ typedef typename image_traits<Exact>::fwd_iter_type fwd_iter_type; + /*!< Forward iterator type. */ typedef typename image_traits<Exact>::bkd_iter_type bkd_iter_type; + /*!< Backward iterator type. */ typedef typename image_traits<Exact>::value_type value_type; + /*!< Prefer the macro oln_value_type(I) to retrieve the value_type + ** of an image. + */ typedef typename image_traits<Exact>::size_type size_type; + /*!< Indicate how the image size is handled. + ** + ** \see image_size + */ typedef typename image_traits<Exact>::impl_type impl_type; + /*!< Underlying implementation. */ typedef image_with_impl<Impl, Exact> self_type; typedef Exact exact_type; typedef typename image_with_type_with_dim_switch<Exact>::ret super_type; - friend class image<exact_type>; friend class image_with_dim<image_id<Exact>::dim, exact_type>; friend class image_with_type<typename image_id<Exact>::value_type, Exact>; // shallow copy + + /*! /brief Construct a new image by performing + ** a shallow copy, the points will not be + ** duplicated but shared between \a rhs and the + ** current image. + ** + ** \see image::clone() + */ + image_with_impl(self_type& rhs) : super_type(rhs) { @@ -80,18 +124,29 @@ impl_->ref(); } + /*! \brief Perform a shallow copy from rhs to + ** the current image, the points will not be + ** duplicated but shared between the two images. + ** + ** \see image::clone() + */ + exact_type& operator=(self_type rhs) { return this->exact().assign(rhs.exact()); } + /// Return the core data of the image. + const impl_type* impl() const { return impl_; } + /// Return the core data of the image. + impl_type* impl() { @@ -107,6 +162,10 @@ + Exact::name() + ">"; } + /*! \brief Create a copy of the current image data, + ** at the \a output_data address. + */ + void clone_to(impl_type* output_data) const { @@ -114,6 +173,8 @@ impl()->clone_to(output_data); } + /// Free the image data. + void clear() { @@ -126,18 +187,44 @@ protected: + /*! \brief Return a reference to the value stored + ** at \a p in the current image. + ** + ** \warning This method must not be overloaded, + ** unlike operator[]. + ** + ** \see image::operator[]() + */ + const value_type& at(const point_type& p) const { return impl_->at(p); } + + /*! \brief Return the value stored at \a p in the + ** current image. + ** + ** \warning This method must not be overloaded, + ** unlike operator[]. + ** + ** \see image::operator[]() + */ + value_type& at(const point_type& p) { return impl_->at(p); } + /*! \brief Perform a shallow copy from \a rhs to + ** the current image, the points will not be + ** duplicated but shared between the two images. + ** + ** \see image::clone() + */ + exact_type& assign(exact_type rhs) // shallow assignment { @@ -156,9 +243,15 @@ clear(); } + /*! \brief Empty constructor for image_with_impl, + ** set \a impl_ to 0 + */ + image_with_impl() : impl_(0) {} + /// Assign \a impl to \a this->impl_. + image_with_impl(impl_type* impl) : super_type(), impl_(impl) @@ -168,7 +261,12 @@ private: + /*! \brief Implementation type of the image. + ** It can be an array, a std::vector, ... + */ + impl_type* impl_; + image_with_impl(const self_type& rhs); // w/o impl }; Index: olena/oln/core/abstract/image_with_type.hh --- olena/oln/core/abstract/image_with_type.hh Thu, 07 Aug 2003 02:08:21 +0200 david (oln/t/28_image_with 1.11 640) +++ olena/oln/core/abstract/image_with_type.hh Thu, 11 Mar 2004 16:55:46 +0100 thivol_d (oln/t/28_image_with 1.11 640) @@ -1,4 +1,4 @@ -// Copyright (C) 2001, 2003 EPITA Research and Development Laboratory +// Copyright (C) 2001, 2003, 2004 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 @@ -38,10 +38,19 @@ namespace abstract { template<class T, class Exact> - class image_with_type; + class image_with_type; //fwd declaration } // end of namespace abstract + + /*! \class image_traits<abstract::image_with_type<T, Exact> > + ** + ** The specialized version for image_with_type + ** + ** \warning This class may change, prefer the macro oln_value_type(I) + ** to retrieve the value_type of an image. + */ + template <class T, class Exact> struct image_traits<abstract::image_with_type<T, Exact> > : public image_traits<abstract::image<Exact> > @@ -49,17 +58,31 @@ typedef T value_type; }; + namespace abstract { + + /*! \class image_with_type + ** + ** The template parameter T gives the value_type of the image. + */ + template<class T, class Exact> class image_with_type: virtual public image<Exact> { public: - typedef image<Exact> super_type; + typedef image<Exact> super_type; /*!< The base class whom derives image_with_type. */ typedef image_with_type<T, Exact> self_type; typedef Exact exact_type; + /*! \brief Shallow copy from \a rhs to the current image, + ** the points will not be duplicated but shared between + ** the two images. + ** + ** \see image::clone() + */ + exact_type& operator=(self_type rhs) { Index: olena/oln/core/abstract/image_with_type_with_dim.hh --- olena/oln/core/abstract/image_with_type_with_dim.hh Sun, 02 Nov 2003 17:27:23 +0100 burrus_n (oln/v/11_image_with 1.4 600) +++ olena/oln/core/abstract/image_with_type_with_dim.hh Thu, 11 Mar 2004 16:55:46 +0100 thivol_d (oln/v/11_image_with 1.4 600) @@ -1,4 +1,4 @@ -// Copyright (C) 2003 EPITA Research and Development Laboratory +// Copyright (C) 2003, 2004 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,11 +34,13 @@ # include <oln/core/abstract/image_with_type.hh> # include <oln/core/abstract/image_with_dim.hh> +// oln_label_image_(Name, Super) // Define a type label image This macro create two classes, // Name<Exact> and Name##_with_dim<N, Exact>. Super is used to // determine the parent class of Name##_with_dim and is suffixed with // _with_dim. + # define oln_label_image_(Name, Super) \ template <class Exact> \ class Name \ @@ -87,21 +89,28 @@ << Exact::name() << ">"; \ return s.str(); \ } \ - } + }; namespace oln { namespace abstract { + // The label images here were defined because they appeared to be // quite handy. They are different than using image_with_type<T>, // because it handle categories of types, not only one. - + // // With each label image, another label_with_dim<Dim, Exact> class // is defined. - + // // Proxy towards image_with_type + /*! \class data_type_image + ** + ** This class is used as a proxy towards image_with_type. + ** \note This shouldn't be used. + */ + template <class Exact> struct data_type_image : virtual public image_with_type<typename image_id<Exact>::value_type, Exact> @@ -111,6 +120,14 @@ typedef data_type_image<Exact> self_type; typedef Exact exact_type; + /*! \brief Perform a shallow copy between \a rhs and the + ** current point, the points will not be duplicated but + ** shared between the two images. + ** + ** \see image::clone() + */ + + exact_type& operator=(self_type rhs) { @@ -126,6 +143,15 @@ } }; + /*! \class data_type_image_with_dim + ** + ** + ** This class when used in a function declaration, + ** force the function to only accept images with a + ** dimension equal to \a Dim. + */ + + template <unsigned Dim, class Exact> struct data_type_image_with_dim : virtual public data_type_image<Exact>, @@ -136,6 +162,13 @@ typedef data_type_image<Exact> self_type; typedef Exact exact_type; + /*! \brief Perform a shallow copy between \a rhs and the + ** current point, the points will not be duplicated but + ** shared between the two images. + ** + ** \see image::clone() + */ + exact_type& operator=(self_type rhs) { @@ -151,12 +184,90 @@ } }; + /*! This class, when used in a function declaration, + ** forces the function to only accept vectorial images. + */ + oln_label_image_(vectorial_image, data_type_image); + + /*! This class, when used in a function declaration, + ** forces the function to only accept vectorial images + ** with a dimension equal to 'Dim'. + */ + + + /*! \class non_vectorial_image + ** + ** This class, when used in a function declaration, + ** forces the function to only accept non vectorial images. + */ + oln_label_image_(non_vectorial_image, data_type_image); + + /*! \class non_vectorial_image_with_dim + ** + ** This class, when used in a function declaration, + ** forces the function to only accept non vectorial images. + ** with a dimension equal to 'Dim' + */ + + + /*! \class binary_image + ** + ** This class, when used in a function declaration, + ** forces the function to only accept binary images. + */ + oln_label_image_(binary_image, non_vectorial_image); + + /*! \class binary_image_with_dim + ** + ** This class, when used in a function declaration, + ** forces the function to only accept binary images + ** with a dimension equal to 'Dim'. + */ + + + /*! \class integer_image + ** + ** This class, when used in a function declaration, + ** forces the function to only accept integer images. + */ + oln_label_image_(integer_image, non_vectorial_image); + + /*! \class integer_image_with_dim + ** + ** This class, when used in a function declaration, + ** forces the function to only accept integer images + ** with a dimension of 'Dim'. + */ + + + /*! \class decimal_image + ** + ** This class, when used in a function declaration, + ** forces the function to only accept decimal images. + */ + oln_label_image_(decimal_image, non_vectorial_image); + /*! \class decimal_image_with_dim + ** + ** This class, when used in a function declaration, + ** forces the function to only accept decimal images + ** with a dimension of 'Dim'. + */ + + + + /*! \class image_with_type_with_dim_switch + ** + ** A metaswitch that return the right type of + ** an image regarding its dimension and + ** value_type. + */ + template<class Exact> struct image_with_type_with_dim_switch { @@ -164,6 +275,8 @@ typedef typename image_id<Exact>::value_type T; + + typedef typename mlc::bool_switch_< mlc::bool_case_<ntg_is_a(T, ntg::binary)::ret, @@ -184,7 +297,15 @@ mlc::bool_case_<true, data_type_image_with_dim<Dim, Exact> > - > > > > > >::ret ret; + > > > > > >::ret ret; /*!< Translated in pseudo code :\n + ** switch (T)\n + ** case ntg::binary : ret = binary_image_with_dim<Dim, Exact>\n + ** case ntg::integer : ret = integer_image_with_dim<Dim, Exact>\n + ** case ntg::decimal : ret = decimal_image_with_dim<Dim, Exact>\n + ** case ntg::vectorial : ret = vectorial_image_with_dim<Dim, Exact>\n + ** case ntg::non_vectorial : ret = non_vectorial_image_with_dim<Dim, Exact>\n + ** default : ret = data_type_image_with_dim<Dim, Exact>\n + */ }; } // end of namespace abstract Index: olena/oln/core/abstract/behavior.hh --- olena/oln/core/abstract/behavior.hh Tue, 24 Feb 2004 16:33:38 +0100 palma_g (oln/j/46_behavior.h 1.2 644) +++ olena/oln/core/abstract/behavior.hh Thu, 11 Mar 2004 16:56:00 +0100 thivol_d (oln/j/46_behavior.h 1.2 644) @@ -31,30 +31,29 @@ # include <oln/core/abstract/image.hh> # include <oln/core/coord.hh> -/*! \namespace oln -** \brief oln namespace -*/ + namespace oln { - /*! \namespace abstract - ** \brief abstract namespace - */ + + namespace abstract { /*! \class behavior - ** behavior hierarchy + ** Behavior hierarchy. ** - ** the aim of this one is to describe how an algorithm should work - ** on borders + ** The aim of this one is to describe how an algorithm should work + ** on borders. */ template <class Exact> class behavior: public mlc_hierarchy::any<Exact> { public: - typedef behavior<Exact> self_type; /*!< the self type*/ - typedef mlc_exact_vt_type(self_type, Exact) exact_type; /*!< the exact type*/ + typedef behavior<Exact> self_type; + /*!< The self type.*/ + typedef mlc_exact_vt_type(self_type, Exact) exact_type; + /*!< The exact type.*/ /*! - ** \brief Adapt the border of an image + ** \brief Adapt the border of an image. ** ** Adapt the border of an image regarding the kind of behavior wanted. */ @@ -67,7 +66,7 @@ /*! ** \brief CTor ** - ** Do nothing, used only by sub-classes + ** Do nothing, used only by sub-classes. */ behavior() {}; }; -- Damien Thivolle damien.thivolle@lrde.epita.fr