olena-2.0-550-gb14fad4 Make template parameter name more consistant with naming conventions.

* mln/core/image/image1d.hh, * mln/core/image/image2d.hh, * mln/core/image/image3d.hh: Here. --- milena/ChangeLog | 9 ++ milena/mln/core/image/image1d.hh | 278 ++++++++++++++++++------------------ milena/mln/core/image/image2d.hh | 290 +++++++++++++++++++------------------- milena/mln/core/image/image3d.hh | 290 +++++++++++++++++++------------------- 4 files changed, 438 insertions(+), 429 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index edf3a65..e081229 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,12 @@ +2013-04-19 Guillaume Lazzara <z@lrde.epita.fr> + + Make template parameter name more consistant with naming + conventions. + + * mln/core/image/image1d.hh, + * mln/core/image/image2d.hh, + * mln/core/image/image3d.hh: Here. + 2013-04-17 Guillaume Lazzara <z@lrde.epita.fr> * doc/mln/convert.dox: Fix from_to_ module name. diff --git a/milena/mln/core/image/image1d.hh b/milena/mln/core/image/image1d.hh index 0cac67d..aaa1ec2 100644 --- a/milena/mln/core/image/image1d.hh +++ b/milena/mln/core/image/image1d.hh @@ -52,7 +52,7 @@ namespace mln { // Forward declaration. - template <typename T> struct image1d; + template <typename V> struct image1d; namespace internal @@ -60,16 +60,16 @@ namespace mln /*! \internal - \brief Data structure for \c mln::image1d<T>. + \brief Data structure for \c mln::image1d<V>. */ - template <typename T> - struct data< image1d<T> > + template <typename V> + struct data< image1d<V> > { data(const box1d& b, unsigned bdr); ~data(); - T* buffer_; - T* array_; + V* buffer_; + V* array_; box1d b_; // theoretical box unsigned bdr_; @@ -78,7 +78,7 @@ namespace mln void update_vb_(); void allocate_(); void deallocate_(); - void swap_ (data< image1d<T> >& other_); + void swap_ (data< image1d<V> >& other_); void reallocate_(unsigned new_border); }; @@ -89,8 +89,8 @@ namespace mln namespace trait { - template <typename T> - struct image_< image1d<T> > : default_image_< T, image1d<T> > + template <typename V> + struct image_< image1d<V> > : default_image_< V, image1d<V> > { // misc typedef trait::image::category::primary category; @@ -122,7 +122,7 @@ namespace mln // Forward declaration. - template <typename T> struct image1d; + template <typename V> struct image1d; /// Basic 1D image class. @@ -133,23 +133,23 @@ namespace mln /// /// \ingroup modimageconcrete // - template <typename T> + template <typename V> struct image1d : - public internal::image_primary< T, box1d, image1d<T> > + public internal::image_primary< V, box1d, image1d<V> > { - typedef internal::image_primary< T, mln::box1d, image1d<T> > super_; + typedef internal::image_primary< V, mln::box1d, image1d<V> > super_; /// Value associated type. - typedef T value; + typedef V value; /// Return type of read-only access. - typedef const T& rvalue; + typedef const V& rvalue; /// Return type of read-write access. - typedef T& lvalue; + typedef V& lvalue; /// Skeleton. - typedef image1d< tag::value_<T> > skeleton; + typedef image1d< tag::value_<V> > skeleton; /// Constructor without argument. @@ -185,10 +185,10 @@ namespace mln unsigned border() const; /// Read-only access to the image value located at point \p p. - const T& operator()(const point1d& p) const; + const V& operator()(const point1d& p) const; /// Read-write access to the image value located at point \p p. - T& operator()(const point1d& p); + V& operator()(const point1d& p); // Specific methods: @@ -197,10 +197,10 @@ namespace mln /// \cond INTERNAL_API /// Read-only access to the image value located at (\p offset). - const T& at_(def::coord offset) const; + const V& at_(def::coord offset) const; /// Read-write access to the image value located at (\p offset). - T& at_(def::coord offset); + V& at_(def::coord offset); /// Give the number of offsets. unsigned ninds() const; @@ -220,18 +220,18 @@ namespace mln point1d point_at_offset(unsigned i) const; /// Give a hook to the value buffer. - const T* buffer() const; + const V* buffer() const; /// Give a hook to the value buffer. - T* buffer(); + V* buffer(); /// Read-only access to the \p i-th image value (including the /// border). - const T& element(unsigned i) const; + const V& element(unsigned i) const; /// Read-write access to the \p i-th image value (including the /// border). - T& element(unsigned i); + V& element(unsigned i); /// Give the number of cells (points including border ones). unsigned nelements() const; @@ -244,22 +244,22 @@ namespace mln }; - template <typename T, typename J> - void init_(tag::image_t, mln::image1d<T>& target, const J& model); + template <typename V, typename J> + void init_(tag::image_t, mln::image1d<V>& target, const J& model); # ifndef MLN_INCLUDE_ONLY // init_ - template <typename T> + template <typename V> inline - void init_(tag::border_t, unsigned& b, const image1d<T>& model) + void init_(tag::border_t, unsigned& b, const image1d<V>& model) { b = model.border(); } - template <typename T, typename J> + template <typename V, typename J> inline - void init_(tag::image_t, image1d<T>& target, const J& model) + void init_(tag::image_t, image1d<V>& target, const J& model) { box1d b; init_(tag::bbox, b, model); @@ -268,14 +268,14 @@ namespace mln target.init_(b, bdr); } - // internal::data< image1d<T> > + // internal::data< image1d<V> > namespace internal { - template <typename T> + template <typename V> inline - data< image1d<T> >::data(const box1d& b, unsigned bdr) + data< image1d<V> >::data(const box1d& b, unsigned bdr) : buffer_(0), array_ (0), b_ (b), @@ -284,17 +284,17 @@ namespace mln allocate_(); } - template <typename T> + template <typename V> inline - data< image1d<T> >::~data() + data< image1d<V> >::~data() { deallocate_(); } - template <typename T> + template <typename V> inline void - data< image1d<T> >::update_vb_() + data< image1d<V> >::update_vb_() { dpoint1d dp(all_to(bdr_)); @@ -302,23 +302,23 @@ namespace mln vb_.pmax() = b_.pmax() + dp; } - template <typename T> + template <typename V> inline void - data< image1d<T> >::allocate_() + data< image1d<V> >::allocate_() { update_vb_(); unsigned ni = vb_.len(0); - buffer_ = new T[ni]; + buffer_ = new V[ni]; array_ = buffer_ - vb_.pmin().ind(); mln_postcondition(vb_.len(0) == b_.len(0) + 2 * bdr_); } - template <typename T> + template <typename V> inline void - data< image1d<T> >::deallocate_() + data< image1d<V> >::deallocate_() { if (buffer_) { @@ -328,212 +328,212 @@ namespace mln } - template <typename T> + template <typename V> inline void - data< image1d<T> >::swap_(data< image1d<T> >& other_) + data< image1d<V> >::swap_(data< image1d<V> >& other_) { - data< image1d<T> > self_ = *this; + data< image1d<V> > self_ = *this; *this = other_; other_ = self_; } - template <typename T> + template <typename V> inline void - data< image1d<T> >::reallocate_(unsigned new_border) + data< image1d<V> >::reallocate_(unsigned new_border) { - data< image1d<T> >& tmp = *(new data< image1d<T> >(this->b_, new_border)); + data< image1d<V> >& tmp = *(new data< image1d<V> >(this->b_, new_border)); this->swap_(tmp); } } // end of namespace mln::internal - // image1d<T> + // image1d<V> - template <typename T> + template <typename V> inline - image1d<T>::image1d() + image1d<V>::image1d() { } - template <typename T> + template <typename V> inline - image1d<T>::image1d(const box1d& b, unsigned bdr) + image1d<V>::image1d(const box1d& b, unsigned bdr) { init_(b, bdr); } - template <typename T> + template <typename V> inline - image1d<T>::image1d(unsigned ninds, unsigned bdr) + image1d<V>::image1d(unsigned ninds, unsigned bdr) { mln_precondition(ninds != 0); init_(make::box1d(ninds), bdr); } - template <typename T> + template <typename V> inline void - image1d<T>::init_(const box1d& b, unsigned bdr) + image1d<V>::init_(const box1d& b, unsigned bdr) { mln_precondition(! this->is_valid()); - this->data_ = new internal::data< image1d<T> >(b, bdr); + this->data_ = new internal::data< image1d<V> >(b, bdr); } - template <typename T> + template <typename V> inline const box1d& - image1d<T>::domain() const + image1d<V>::domain() const { mln_precondition(this->is_valid()); return this->data_->b_; } - template <typename T> + template <typename V> inline const box1d& - image1d<T>::bbox() const + image1d<V>::bbox() const { mln_precondition(this->is_valid()); return this->data_->b_; } - template <typename T> + template <typename V> inline const box1d& - image1d<T>::vbbox() const + image1d<V>::vbbox() const { mln_precondition(this->is_valid()); return this->data_->vb_; } - template <typename T> + template <typename V> inline unsigned - image1d<T>::border() const + image1d<V>::border() const { mln_precondition(this->is_valid()); return this->data_->bdr_; } - template <typename T> + template <typename V> inline unsigned - image1d<T>::nelements() const + image1d<V>::nelements() const { mln_precondition(this->is_valid()); return this->data_->vb_.nsites(); } - template <typename T> + template <typename V> inline bool - image1d<T>::has(const point1d& p) const + image1d<V>::has(const point1d& p) const { mln_precondition(this->is_valid()); return this->data_->vb_.has(p); } - template <typename T> + template <typename V> inline - const T& - image1d<T>::operator()(const point1d& p) const + const V& + image1d<V>::operator()(const point1d& p) const { mln_precondition(this->has(p)); return this->data_->array_[p.ind()]; } - template <typename T> + template <typename V> inline - T& - image1d<T>::operator()(const point1d& p) + V& + image1d<V>::operator()(const point1d& p) { mln_precondition(this->has(p)); return this->data_->array_[p.ind()]; } - template <typename T> + template <typename V> inline - const T& - image1d<T>::at_(def::coord offset) const + const V& + image1d<V>::at_(def::coord offset) const { mln_precondition(this->has(point1d(offset))); return this->data_->array_[offset]; } - template <typename T> + template <typename V> inline unsigned - image1d<T>::ninds() const + image1d<V>::ninds() const { mln_precondition(this->is_valid()); return this->data_->b_.len(0); } - template <typename T> + template <typename V> inline - T& - image1d<T>::at_(def::coord offset) + V& + image1d<V>::at_(def::coord offset) { mln_precondition(this->has(point1d(offset))); return this->data_->array_[offset]; } - template <typename T> + template <typename V> inline - const T& - image1d<T>::element(unsigned i) const + const V& + image1d<V>::element(unsigned i) const { mln_precondition(i < nelements()); return this->data_->buffer_[i]; } - template <typename T> + template <typename V> inline - T& - image1d<T>::element(unsigned i) + V& + image1d<V>::element(unsigned i) { mln_precondition(i < nelements()); return this->data_->buffer_[i]; } - template <typename T> + template <typename V> inline - const T* - image1d<T>::buffer() const + const V* + image1d<V>::buffer() const { mln_precondition(this->is_valid()); return this->data_->buffer_; } - template <typename T> + template <typename V> inline - T* - image1d<T>::buffer() + V* + image1d<V>::buffer() { mln_precondition(this->is_valid()); return this->data_->buffer_; } - template <typename T> + template <typename V> inline int - image1d<T>::delta_offset(const dpoint1d& dp) const + image1d<V>::delta_offset(const dpoint1d& dp) const { mln_precondition(this->is_valid()); int o = dp[0]; return o; } - template <typename T> + template <typename V> inline point1d - image1d<T>::point_at_offset(unsigned i) const + image1d<V>::point_at_offset(unsigned i) const { mln_precondition(i < nelements()); def::coord ind = static_cast<def::coord>(i + this->data_->vb_.min_ind()); @@ -542,10 +542,10 @@ namespace mln return p; } - template <typename T> + template <typename V> inline void - image1d<T>::resize_(unsigned new_border) + image1d<V>::resize_(unsigned new_border) { this->data_->reallocate_(new_border); } @@ -571,80 +571,80 @@ namespace mln // pixter - template <typename T> - struct fwd_pixter< image1d<T> > + template <typename V> + struct fwd_pixter< image1d<V> > { - typedef fwd_pixter1d< image1d<T> > ret; + typedef fwd_pixter1d< image1d<V> > ret; }; - template <typename T> - struct fwd_pixter< const image1d<T> > + template <typename V> + struct fwd_pixter< const image1d<V> > { - typedef fwd_pixter1d< const image1d<T> > ret; + typedef fwd_pixter1d< const image1d<V> > ret; }; - template <typename T> - struct bkd_pixter< image1d<T> > + template <typename V> + struct bkd_pixter< image1d<V> > { - typedef bkd_pixter1d< image1d<T> > ret; + typedef bkd_pixter1d< image1d<V> > ret; }; - template <typename T> - struct bkd_pixter< const image1d<T> > + template <typename V> + struct bkd_pixter< const image1d<V> > { - typedef bkd_pixter1d< const image1d<T> > ret; + typedef bkd_pixter1d< const image1d<V> > ret; }; // qixter - template <typename T, typename W> - struct fwd_qixter< image1d<T>, W > + template <typename V, typename W> + struct fwd_qixter< image1d<V>, W > { - typedef dpoints_fwd_pixter< image1d<T> > ret; + typedef dpoints_fwd_pixter< image1d<V> > ret; }; - template <typename T, typename W> - struct fwd_qixter< const image1d<T>, W > + template <typename V, typename W> + struct fwd_qixter< const image1d<V>, W > { - typedef dpoints_fwd_pixter< const image1d<T> > ret; + typedef dpoints_fwd_pixter< const image1d<V> > ret; }; - template <typename T, typename W> - struct bkd_qixter< image1d<T>, W > + template <typename V, typename W> + struct bkd_qixter< image1d<V>, W > { - typedef dpoints_bkd_pixter< image1d<T> > ret; + typedef dpoints_bkd_pixter< image1d<V> > ret; }; - template <typename T, typename W> - struct bkd_qixter< const image1d<T>, W > + template <typename V, typename W> + struct bkd_qixter< const image1d<V>, W > { - typedef dpoints_bkd_pixter< const image1d<T> > ret; + typedef dpoints_bkd_pixter< const image1d<V> > ret; }; // nixter - template <typename T, typename W> - struct fwd_nixter< image1d<T>, W > + template <typename V, typename W> + struct fwd_nixter< image1d<V>, W > { - typedef dpoints_fwd_pixter< image1d<T> > ret; + typedef dpoints_fwd_pixter< image1d<V> > ret; }; - template <typename T, typename W> - struct fwd_nixter< const image1d<T>, W > + template <typename V, typename W> + struct fwd_nixter< const image1d<V>, W > { - typedef dpoints_fwd_pixter< const image1d<T> > ret; + typedef dpoints_fwd_pixter< const image1d<V> > ret; }; - template <typename T, typename W> - struct bkd_nixter< image1d<T>, W > + template <typename V, typename W> + struct bkd_nixter< image1d<V>, W > { - typedef dpoints_bkd_pixter< image1d<T> > ret; + typedef dpoints_bkd_pixter< image1d<V> > ret; }; - template <typename T, typename W> - struct bkd_nixter< const image1d<T>, W > + template <typename V, typename W> + struct bkd_nixter< const image1d<V>, W > { - typedef dpoints_bkd_pixter< const image1d<T> > ret; + typedef dpoints_bkd_pixter< const image1d<V> > ret; }; } // end of namespace mln::trait diff --git a/milena/mln/core/image/image2d.hh b/milena/mln/core/image/image2d.hh index 7ef0102..830057d 100644 --- a/milena/mln/core/image/image2d.hh +++ b/milena/mln/core/image/image2d.hh @@ -56,23 +56,23 @@ namespace mln { // Forward declaration. - template <typename T> class image2d; + template <typename V> class image2d; namespace internal { /*! - \brief Data structure for \c mln::image2d<T>. + \brief Data structure for \c mln::image2d<V>. */ - template <typename T> - struct data< image2d<T> > + template <typename V> + struct data< image2d<V> > { data(const box2d& b, unsigned bdr); ~data(); - T* buffer_; - T** array_; + V* buffer_; + V** array_; box2d b_; // theoretical box unsigned bdr_; @@ -81,7 +81,7 @@ namespace mln void update_vb_(); void allocate_(); void deallocate_(); - void swap_(data< image2d<T> >& other_); + void swap_(data< image2d<V> >& other_); void reallocate_(unsigned new_border); }; @@ -90,8 +90,8 @@ namespace mln namespace trait { - template <typename T> - struct image_< image2d<T> > : default_image_< T, image2d<T> > + template <typename V> + struct image_< image2d<V> > : default_image_< V, image2d<V> > { // misc typedef trait::image::category::primary category; @@ -130,24 +130,24 @@ namespace mln /// /// \ingroup modimageconcrete // - template <typename T> - class image2d : public internal::image_primary< T, mln::box2d, image2d<T> > + template <typename V> + class image2d : public internal::image_primary< V, mln::box2d, image2d<V> > { - typedef internal::image_primary< T, mln::box2d, image2d<T> > super_; + typedef internal::image_primary< V, mln::box2d, image2d<V> > super_; public: /// Value associated type. - typedef T value; + typedef V value; /// Return type of read-only access. - typedef const T& rvalue; + typedef const V& rvalue; /// Return type of read-write access. - typedef T& lvalue; + typedef V& lvalue; /// Skeleton. - typedef image2d< tag::value_<T> > skeleton; + typedef image2d< tag::value_<V> > skeleton; /// Constructor without argument. @@ -181,14 +181,14 @@ namespace mln const box2d& vbbox() const; /// Read-only access to the image value located at point \p p. - const T& operator()(const point2d& p) const; + const V& operator()(const point2d& p) const; /// Read-write access to the image value located at point \p p. - T& operator()(const point2d& p); + V& operator()(const point2d& p); template <typename P> - T& alt(const P& p) + V& alt(const P& p) { typedef def::coord coord_t; mln_precondition(this->has(p)); @@ -212,9 +212,9 @@ namespace mln /// \cond INTERNAL_API /// Read-only access to the image value located at (\p row, \p col). - const T& at_(mln::def::coord row, mln::def::coord col) const; + const V& at_(mln::def::coord row, mln::def::coord col) const; /// Read-write access to the image value located at (\p row, \p col). - T& at_(mln::def::coord row, mln::def::coord col); + V& at_(mln::def::coord row, mln::def::coord col); /// \endcond @@ -238,10 +238,10 @@ namespace mln unsigned nelements() const; /// Read-only access to the image value located at offset \p i. - const T& element(unsigned i) const; + const V& element(unsigned i) const; /// Read-write access to the image value located at offset \p i. - T& element(unsigned i); + V& element(unsigned i); /// Give the delta-offset corresponding to the delta-point \p dp. int delta_offset(const dpoint2d& dp) const; @@ -250,10 +250,10 @@ namespace mln point2d point_at_offset(unsigned i) const; /// Give a hook to the value buffer. - const T* buffer() const; + const V* buffer() const; /// Give a hook to the value buffer. - T* buffer(); + V* buffer(); /// \cond INTERNAL_API @@ -268,11 +268,11 @@ namespace mln /// \cond INTERNAL_API - template <typename T> - void init_(tag::border_t, unsigned& bdr, const image2d<T>& model); + template <typename V> + void init_(tag::border_t, unsigned& bdr, const image2d<V>& model); - template <typename T, typename J> - void init_(tag::image_t, mln::image2d<T>& target, const J& model); + template <typename V, typename J> + void init_(tag::image_t, mln::image2d<V>& target, const J& model); /// \endcond @@ -281,16 +281,16 @@ namespace mln // init_ - template <typename T> + template <typename V> inline - void init_(tag::border_t, unsigned& bdr, const image2d<T>& model) + void init_(tag::border_t, unsigned& bdr, const image2d<V>& model) { bdr = model.border(); } - template <typename T, typename J> + template <typename V, typename J> inline - void init_(tag::image_t, image2d<T>& target, const J& model) + void init_(tag::image_t, image2d<V>& target, const J& model) { box2d b; init_(tag::bbox, b, model); @@ -300,13 +300,13 @@ namespace mln } - // internal::data< image2d<T> > + // internal::data< image2d<V> > namespace internal { - template <typename T> + template <typename V> inline - data< image2d<T> >::data(const box2d& b, unsigned bdr) + data< image2d<V> >::data(const box2d& b, unsigned bdr) : buffer_(0), array_ (0), b_ (b), @@ -315,34 +315,34 @@ namespace mln allocate_(); } - template <typename T> + template <typename V> inline - data< image2d<T> >::~data() + data< image2d<V> >::~data() { deallocate_(); } - template <typename T> + template <typename V> inline void - data< image2d<T> >::update_vb_() + data< image2d<V> >::update_vb_() { vb_.pmin() = b_.pmin() - dpoint2d(all_to(bdr_)); vb_.pmax() = b_.pmax() + dpoint2d(all_to(bdr_)); } - template <typename T> + template <typename V> inline void - data< image2d<T> >::allocate_() + data< image2d<V> >::allocate_() { update_vb_(); unsigned nr = vb_.len(0), nc = vb_.len(1); - buffer_ = new T[nr * nc]; - array_ = new T*[nr]; - T* buf = buffer_ - vb_.pmin().col(); + buffer_ = new V[nr * nc]; + array_ = new V*[nr]; + V* buf = buffer_ - vb_.pmin().col(); for (unsigned i = 0; i < nr; ++i) { array_[i] = buf; @@ -353,10 +353,10 @@ namespace mln mln_postcondition(vb_.len(1) == b_.len(1) + 2 * bdr_); } - template <typename T> + template <typename V> inline void - data< image2d<T> >::deallocate_() + data< image2d<V> >::deallocate_() { if (buffer_) { @@ -371,22 +371,22 @@ namespace mln } } - template <typename T> + template <typename V> inline void - data< image2d<T> >::swap_(data< image2d<T> >& other_) + data< image2d<V> >::swap_(data< image2d<V> >& other_) { - data< image2d<T> > self_ = *this; + data< image2d<V> > self_ = *this; *this = other_; other_ = self_; } - template <typename T> + template <typename V> inline void - data< image2d<T> >::reallocate_(unsigned new_border) + data< image2d<V> >::reallocate_(unsigned new_border) { - data< image2d<T> >& tmp = *(new data< image2d<T> >(this->b_, new_border)); + data< image2d<V> >& tmp = *(new data< image2d<V> >(this->b_, new_border)); this->swap_(tmp); } @@ -394,86 +394,86 @@ namespace mln } // end of namespace mln::internal - // image2d<T> + // image2d<V> - template <typename T> + template <typename V> inline - image2d<T>::image2d() + image2d<V>::image2d() { } - template <typename T> + template <typename V> inline - image2d<T>::image2d(int nrows, int ncols, unsigned bdr) + image2d<V>::image2d(int nrows, int ncols, unsigned bdr) { init_(make::box2d(nrows, ncols), bdr); } - template <typename T> + template <typename V> inline - image2d<T>::image2d(const box2d& b, unsigned bdr) + image2d<V>::image2d(const box2d& b, unsigned bdr) { init_(b, bdr); } - template <typename T> + template <typename V> inline void - image2d<T>::init_(const box2d& b, unsigned bdr) + image2d<V>::init_(const box2d& b, unsigned bdr) { mln_precondition(! this->is_valid()); - this->data_ = new internal::data< image2d<T> >(b, bdr); + this->data_ = new internal::data< image2d<V> >(b, bdr); } - template <typename T> + template <typename V> inline const box2d& - image2d<T>::domain() const + image2d<V>::domain() const { mln_precondition(this->is_valid()); return this->data_->b_; } - template <typename T> + template <typename V> inline const box2d& - image2d<T>::bbox() const + image2d<V>::bbox() const { mln_precondition(this->is_valid()); return this->data_->b_; } - template <typename T> + template <typename V> inline const box2d& - image2d<T>::vbbox() const + image2d<V>::vbbox() const { mln_precondition(this->is_valid()); return this->data_->vb_; } - template <typename T> + template <typename V> inline bool - image2d<T>::has(const point2d& p) const + image2d<V>::has(const point2d& p) const { mln_precondition(this->is_valid()); return this->data_->vb_.has(p); } - template <typename T> + template <typename V> inline - const T& - image2d<T>::operator()(const point2d& p) const + const V& + image2d<V>::operator()(const point2d& p) const { mln_precondition(this->has(p)); return this->data_->array_[p.row()][p.col()]; } - template <typename T> + template <typename V> inline - T& - image2d<T>::operator()(const point2d& p) + V& + image2d<V>::operator()(const point2d& p) { mln_precondition(this->has(p)); return this->data_->array_[p.row()][p.col()]; @@ -482,37 +482,37 @@ namespace mln // Specific methods: - template <typename T> + template <typename V> inline - const T& - image2d<T>::at_(mln::def::coord row, mln::def::coord col) const + const V& + image2d<V>::at_(mln::def::coord row, mln::def::coord col) const { mln_precondition(this->has(point2d(row, col))); return this->data_->array_[row][col]; } - template <typename T> + template <typename V> inline - T& - image2d<T>::at_(mln::def::coord row, mln::def::coord col) + V& + image2d<V>::at_(mln::def::coord row, mln::def::coord col) { mln_precondition(this->has(point2d(row, col))); return this->data_->array_[row][col]; } - template <typename T> + template <typename V> inline unsigned - image2d<T>::nrows() const + image2d<V>::nrows() const { mln_precondition(this->is_valid()); return this->data_->b_.len(0); } - template <typename T> + template <typename V> inline unsigned - image2d<T>::ncols() const + image2d<V>::ncols() const { mln_precondition(this->is_valid()); return this->data_->b_.len(1); @@ -521,74 +521,74 @@ namespace mln // As a fastest image: - template <typename T> + template <typename V> inline unsigned - image2d<T>::border() const + image2d<V>::border() const { mln_precondition(this->is_valid()); return this->data_->bdr_; } - template <typename T> + template <typename V> inline unsigned - image2d<T>::nelements() const + image2d<V>::nelements() const { mln_precondition(this->is_valid()); return this->data_->vb_.nsites(); } - template <typename T> + template <typename V> inline - const T& - image2d<T>::element(unsigned i) const + const V& + image2d<V>::element(unsigned i) const { mln_precondition(i < nelements()); return *(this->data_->buffer_ + i); } - template <typename T> + template <typename V> inline - T& - image2d<T>::element(unsigned i) + V& + image2d<V>::element(unsigned i) { mln_precondition(i < nelements()); return *(this->data_->buffer_ + i); } - template <typename T> + template <typename V> inline - const T* - image2d<T>::buffer() const + const V* + image2d<V>::buffer() const { mln_precondition(this->is_valid()); return this->data_->buffer_; } - template <typename T> + template <typename V> inline - T* - image2d<T>::buffer() + V* + image2d<V>::buffer() { mln_precondition(this->is_valid()); return this->data_->buffer_; } - template <typename T> + template <typename V> inline int - image2d<T>::delta_offset(const dpoint2d& dp) const + image2d<V>::delta_offset(const dpoint2d& dp) const { mln_precondition(this->is_valid()); int o = dp[0] * this->data_->vb_.len(1) + dp[1]; return o; } - template <typename T> + template <typename V> inline point2d - image2d<T>::point_at_offset(unsigned i) const + image2d<V>::point_at_offset(unsigned i) const { mln_precondition(i < nelements()); def::coord @@ -601,10 +601,10 @@ namespace mln // Extra. - template <typename T> + template <typename V> inline void - image2d<T>::resize_(unsigned new_border) + image2d<V>::resize_(unsigned new_border) { mln_precondition(this->is_valid()); this->data_->reallocate_(new_border); @@ -630,80 +630,80 @@ namespace mln // pixter - template <typename T> - struct fwd_pixter< image2d<T> > + template <typename V> + struct fwd_pixter< image2d<V> > { - typedef fwd_pixter2d< image2d<T> > ret; + typedef fwd_pixter2d< image2d<V> > ret; }; - template <typename T> - struct fwd_pixter< const image2d<T> > + template <typename V> + struct fwd_pixter< const image2d<V> > { - typedef fwd_pixter2d< const image2d<T> > ret; + typedef fwd_pixter2d< const image2d<V> > ret; }; - template <typename T> - struct bkd_pixter< image2d<T> > + template <typename V> + struct bkd_pixter< image2d<V> > { - typedef bkd_pixter2d< image2d<T> > ret; + typedef bkd_pixter2d< image2d<V> > ret; }; - template <typename T> - struct bkd_pixter< const image2d<T> > + template <typename V> + struct bkd_pixter< const image2d<V> > { - typedef bkd_pixter2d< const image2d<T> > ret; + typedef bkd_pixter2d< const image2d<V> > ret; }; // qixter - template <typename T, typename W> - struct fwd_qixter< image2d<T>, W > + template <typename V, typename W> + struct fwd_qixter< image2d<V>, W > { - typedef dpoints_fwd_pixter< image2d<T> > ret; + typedef dpoints_fwd_pixter< image2d<V> > ret; }; - template <typename T, typename W> - struct fwd_qixter< const image2d<T>, W > + template <typename V, typename W> + struct fwd_qixter< const image2d<V>, W > { - typedef dpoints_fwd_pixter< const image2d<T> > ret; + typedef dpoints_fwd_pixter< const image2d<V> > ret; }; - template <typename T, typename W> - struct bkd_qixter< image2d<T>, W > + template <typename V, typename W> + struct bkd_qixter< image2d<V>, W > { - typedef dpoints_bkd_pixter< image2d<T> > ret; + typedef dpoints_bkd_pixter< image2d<V> > ret; }; - template <typename T, typename W> - struct bkd_qixter< const image2d<T>, W > + template <typename V, typename W> + struct bkd_qixter< const image2d<V>, W > { - typedef dpoints_bkd_pixter< const image2d<T> > ret; + typedef dpoints_bkd_pixter< const image2d<V> > ret; }; // nixter - template <typename T, typename N> - struct fwd_nixter< image2d<T>, N > + template <typename V, typename N> + struct fwd_nixter< image2d<V>, N > { - typedef dpoints_fwd_pixter< image2d<T> > ret; + typedef dpoints_fwd_pixter< image2d<V> > ret; }; - template <typename T, typename N> - struct fwd_nixter< const image2d<T>, N > + template <typename V, typename N> + struct fwd_nixter< const image2d<V>, N > { - typedef dpoints_fwd_pixter< const image2d<T> > ret; + typedef dpoints_fwd_pixter< const image2d<V> > ret; }; - template <typename T, typename N> - struct bkd_nixter< image2d<T>, N > + template <typename V, typename N> + struct bkd_nixter< image2d<V>, N > { - typedef dpoints_bkd_pixter< image2d<T> > ret; + typedef dpoints_bkd_pixter< image2d<V> > ret; }; - template <typename T, typename N> - struct bkd_nixter< const image2d<T>, N > + template <typename V, typename N> + struct bkd_nixter< const image2d<V>, N > { - typedef dpoints_bkd_pixter< const image2d<T> > ret; + typedef dpoints_bkd_pixter< const image2d<V> > ret; }; } // end of namespace mln::trait diff --git a/milena/mln/core/image/image3d.hh b/milena/mln/core/image/image3d.hh index 20831c5..d4e14ee 100644 --- a/milena/mln/core/image/image3d.hh +++ b/milena/mln/core/image/image3d.hh @@ -51,7 +51,7 @@ namespace mln { // Forward declaration. - template <typename T> struct image3d; + template <typename V> struct image3d; @@ -60,16 +60,16 @@ namespace mln /*! \internal - \brief Data structure for \c mln::image3d<T>. + \brief Data structure for \c mln::image3d<V>. */ - template <typename T> - struct data< image3d<T> > + template <typename V> + struct data< image3d<V> > { data(const box3d& b, unsigned bdr); ~data(); - T* buffer_; - T*** array_; + V* buffer_; + V*** array_; box3d b_; // theoretical box unsigned bdr_; @@ -78,7 +78,7 @@ namespace mln void update_vb_(); void allocate_(); void deallocate_(); - void swap_ (data< image3d<T> >& other_); + void swap_ (data< image3d<V> >& other_); void reallocate_(unsigned new_border); }; @@ -89,8 +89,8 @@ namespace mln namespace trait { - template <typename T> - struct image_< image3d<T> > : default_image_< T, image3d<T> > + template <typename V> + struct image_< image3d<V> > : default_image_< V, image3d<V> > { // misc typedef trait::image::category::primary category; @@ -129,8 +129,8 @@ namespace mln /// /// \ingroup modimageconcrete // - template <typename T> - struct image3d : public internal::image_primary< T, box3d, image3d<T> > + template <typename V> + struct image3d : public internal::image_primary< V, box3d, image3d<V> > { // Warning: just to make effective types appear in Doxygen: typedef box3d pset; @@ -144,20 +144,20 @@ namespace mln /// Super type - typedef internal::image_primary< T, box3d, image3d<T> > super_; + typedef internal::image_primary< V, box3d, image3d<V> > super_; /// Value associated type. - typedef T value; + typedef V value; /// Return type of read-only access. - typedef const T& rvalue; + typedef const V& rvalue; /// Return type of read-write access. - typedef T& lvalue; + typedef V& lvalue; /// Skeleton. - typedef image3d< tag::value_<T> > skeleton; + typedef image3d< tag::value_<V> > skeleton; /// Constructor without argument. image3d(); @@ -196,26 +196,26 @@ namespace mln unsigned nelements() const; /// Read-only access to the image value located at point \p p. - const T& operator()(const point3d& p) const; + const V& operator()(const point3d& p) const; /// Read-write access to the image value located at point \p p. - T& operator()(const point3d& p); + V& operator()(const point3d& p); /// Read-only access to the image value located at offset \p i. - const T& element(unsigned i) const; + const V& element(unsigned i) const; /// Read-write access to the image value located at offset \p i. - T& element(unsigned i); + V& element(unsigned i); /// \cond INTERNAL_API /// Read-only access to the image value located at (\p sli, \p /// row, \p col). - const T& at_(def::coord sli, def::coord row, def::coord col) const; + const V& at_(def::coord sli, def::coord row, def::coord col) const; /// Read-write access to the image value located at (\p sli, \p /// row, \p col). - T& at_(def::coord sli, def::coord row, def::coord col); + V& at_(def::coord sli, def::coord row, def::coord col); /// \endcond @@ -238,10 +238,10 @@ namespace mln point3d point_at_offset(unsigned o) const; /// Give a hook to the value buffer. - const T* buffer() const; + const V* buffer() const; /// Give a hook to the value buffer. - T* buffer(); + V* buffer(); /// \cond INTERNAL_API @@ -256,8 +256,8 @@ namespace mln }; - template <typename T, typename J> - void init_(tag::image_t, mln::image3d<T>& target, const J& model); + template <typename V, typename J> + void init_(tag::image_t, mln::image3d<V>& target, const J& model); @@ -265,16 +265,16 @@ namespace mln // init_ - template <typename T> + template <typename V> inline - void init_(tag::border_t, unsigned& b, const image3d<T>& model) + void init_(tag::border_t, unsigned& b, const image3d<V>& model) { b = model.border(); } - template <typename T, typename J> + template <typename V, typename J> inline - void init_(tag::image_t, image3d<T>& target, const J& model) + void init_(tag::image_t, image3d<V>& target, const J& model) { box3d b; init_(tag::bbox, b, model); @@ -284,14 +284,14 @@ namespace mln } - // internal::data< image3d<T> > + // internal::data< image3d<V> > namespace internal { - template <typename T> + template <typename V> inline - data< image3d<T> >::data(const box3d& b, unsigned bdr) + data< image3d<V> >::data(const box3d& b, unsigned bdr) : buffer_(0), array_ (0), b_ (b), @@ -300,38 +300,38 @@ namespace mln allocate_(); } - template <typename T> + template <typename V> inline - data< image3d<T> >::~data() + data< image3d<V> >::~data() { deallocate_(); } - template <typename T> + template <typename V> inline void - data< image3d<T> >::update_vb_() + data< image3d<V> >::update_vb_() { vb_.pmin() = b_.pmin() - dpoint3d(all_to(bdr_)); vb_.pmax() = b_.pmax() + dpoint3d(all_to(bdr_)); } - template <typename T> + template <typename V> inline void - data< image3d<T> >::allocate_() + data< image3d<V> >::allocate_() { update_vb_(); unsigned ns = vb_.len(0), nr = vb_.len(1), nc = vb_.len(2); - buffer_ = new T[nr * nc * ns]; - array_ = new T**[ns]; - T* buf = buffer_ - vb_.pmin().col(); + buffer_ = new V[nr * nc * ns]; + array_ = new V**[ns]; + V* buf = buffer_ - vb_.pmin().col(); for (unsigned i = 0; i < ns; ++i) { - T** tmp = new T*[nr]; + V** tmp = new V*[nr]; array_[i] = tmp; for (unsigned j = 0; j < nr; ++j) { @@ -344,10 +344,10 @@ namespace mln mln_postcondition(vb_.len(0) == b_.len(0) + 2 * bdr_); } - template <typename T> + template <typename V> inline void - data< image3d<T> >::deallocate_() + data< image3d<V> >::deallocate_() { if (buffer_) { @@ -371,216 +371,216 @@ namespace mln } } - template <typename T> + template <typename V> inline void - data< image3d<T> >::swap_(data< image3d<T> >& other_) + data< image3d<V> >::swap_(data< image3d<V> >& other_) { - data< image3d<T> > self_ = *this; + data< image3d<V> > self_ = *this; *this = other_; other_ = self_; } - template <typename T> + template <typename V> inline void - data< image3d<T> >::reallocate_(unsigned new_border) + data< image3d<V> >::reallocate_(unsigned new_border) { - data< image3d<T> >& tmp = *(new data< image3d<T> >(this->b_, new_border)); + data< image3d<V> >& tmp = *(new data< image3d<V> >(this->b_, new_border)); this->swap_(tmp); } } // end of namespace mln::internal - // image3d<T> + // image3d<V> - template <typename T> + template <typename V> inline - image3d<T>::image3d() + image3d<V>::image3d() { } - template <typename T> + template <typename V> inline - image3d<T>::image3d(const box3d& b, unsigned bdr) + image3d<V>::image3d(const box3d& b, unsigned bdr) { init_(b, bdr); } - template <typename T> + template <typename V> inline - image3d<T>::image3d(int nslis, int nrows, int ncols, unsigned bdr) + image3d<V>::image3d(int nslis, int nrows, int ncols, unsigned bdr) { init_(make::box3d(nslis, nrows, ncols), bdr); } - template <typename T> + template <typename V> inline void - image3d<T>::init_(const box3d& b, unsigned bdr) + image3d<V>::init_(const box3d& b, unsigned bdr) { mln_precondition(! this->is_valid()); - this->data_ = new internal::data< image3d<T> >(b, bdr); + this->data_ = new internal::data< image3d<V> >(b, bdr); } - template <typename T> + template <typename V> inline const box3d& - image3d<T>::domain() const + image3d<V>::domain() const { mln_precondition(this->is_valid()); return data_->b_; } - template <typename T> + template <typename V> inline const box3d& - image3d<T>::bbox() const + image3d<V>::bbox() const { mln_precondition(this->is_valid()); return data_->b_; } - template <typename T> + template <typename V> inline const box3d& - image3d<T>::vbbox() const + image3d<V>::vbbox() const { mln_precondition(this->is_valid()); return data_->vb_; } - template <typename T> + template <typename V> inline unsigned - image3d<T>::border() const + image3d<V>::border() const { mln_precondition(this->is_valid()); return data_->bdr_; } - template <typename T> + template <typename V> inline unsigned - image3d<T>::nelements() const + image3d<V>::nelements() const { mln_precondition(this->is_valid()); return data_->vb_.nsites(); } - template <typename T> + template <typename V> inline bool - image3d<T>::has(const point3d& p) const + image3d<V>::has(const point3d& p) const { mln_precondition(this->is_valid()); return data_->vb_.has(p); } - template <typename T> + template <typename V> inline - const T& - image3d<T>::operator()(const point3d& p) const + const V& + image3d<V>::operator()(const point3d& p) const { mln_precondition(this->has(p)); return data_->array_[p.sli()][p.row()][p.col()]; } - template <typename T> + template <typename V> inline - T& - image3d<T>::operator()(const point3d& p) + V& + image3d<V>::operator()(const point3d& p) { mln_precondition(this->has(p)); return data_->array_[p.sli()][p.row()][p.col()]; } - template <typename T> + template <typename V> inline - const T& - image3d<T>::element(unsigned i) const + const V& + image3d<V>::element(unsigned i) const { mln_precondition(i < nelements()); return *(data_->buffer_ + i); } - template <typename T> + template <typename V> inline - T& - image3d<T>::element(unsigned i) + V& + image3d<V>::element(unsigned i) { mln_precondition(i < nelements()); return *(data_->buffer_ + i); } - template <typename T> + template <typename V> inline - const T& - image3d<T>::at_(def::coord sli, def::coord row, def::coord col) const + const V& + image3d<V>::at_(def::coord sli, def::coord row, def::coord col) const { mln_precondition(this->has(point3d(sli, row, col))); return data_->array_[sli][row][col]; } - template <typename T> + template <typename V> inline - T& - image3d<T>::at_(def::coord sli, def::coord row, def::coord col) + V& + image3d<V>::at_(def::coord sli, def::coord row, def::coord col) { mln_precondition(this->has(point3d(sli, row, col))); return data_->array_[sli][row][col]; } - template <typename T> + template <typename V> inline unsigned - image3d<T>::nslis() const + image3d<V>::nslis() const { mln_precondition(this->is_valid()); return this->data_->b_.len(0); } - template <typename T> + template <typename V> inline unsigned - image3d<T>::nrows() const + image3d<V>::nrows() const { mln_precondition(this->is_valid()); return this->data_->b_.len(1); } - template <typename T> + template <typename V> inline unsigned - image3d<T>::ncols() const + image3d<V>::ncols() const { mln_precondition(this->is_valid()); return this->data_->b_.len(2); } - template <typename T> + template <typename V> inline - const T* - image3d<T>::buffer() const + const V* + image3d<V>::buffer() const { mln_precondition(this->is_valid()); return data_->buffer_; } - template <typename T> + template <typename V> inline - T* - image3d<T>::buffer() + V* + image3d<V>::buffer() { mln_precondition(this->is_valid()); return data_->buffer_; } - template <typename T> + template <typename V> inline int - image3d<T>::delta_offset(const dpoint3d& dp) const + image3d<V>::delta_offset(const dpoint3d& dp) const { mln_precondition(this->is_valid()); int o = (dp[0] * this->data_->vb_.len(1) @@ -588,10 +588,10 @@ namespace mln return o; } - template <typename T> + template <typename V> inline point3d - image3d<T>::point_at_offset(unsigned o) const + image3d<V>::point_at_offset(unsigned o) const { mln_precondition(o < nelements()); def::coord @@ -603,10 +603,10 @@ namespace mln return p; } - template <typename T> + template <typename V> inline void - image3d<T>::resize_(unsigned new_border) + image3d<V>::resize_(unsigned new_border) { this->data_->reallocate_(new_border); } @@ -631,80 +631,80 @@ namespace mln // pixter - template <typename T> - struct fwd_pixter< image3d<T> > + template <typename V> + struct fwd_pixter< image3d<V> > { - typedef fwd_pixter3d< image3d<T> > ret; + typedef fwd_pixter3d< image3d<V> > ret; }; - template <typename T> - struct fwd_pixter< const image3d<T> > + template <typename V> + struct fwd_pixter< const image3d<V> > { - typedef fwd_pixter3d< const image3d<T> > ret; + typedef fwd_pixter3d< const image3d<V> > ret; }; - template <typename T> - struct bkd_pixter< image3d<T> > + template <typename V> + struct bkd_pixter< image3d<V> > { - typedef bkd_pixter3d< image3d<T> > ret; + typedef bkd_pixter3d< image3d<V> > ret; }; - template <typename T> - struct bkd_pixter< const image3d<T> > + template <typename V> + struct bkd_pixter< const image3d<V> > { - typedef bkd_pixter3d< const image3d<T> > ret; + typedef bkd_pixter3d< const image3d<V> > ret; }; // qixter - template <typename T, typename W> - struct fwd_qixter< image3d<T>, W > + template <typename V, typename W> + struct fwd_qixter< image3d<V>, W > { - typedef dpoints_fwd_pixter< image3d<T> > ret; + typedef dpoints_fwd_pixter< image3d<V> > ret; }; - template <typename T, typename W> - struct fwd_qixter< const image3d<T>, W > + template <typename V, typename W> + struct fwd_qixter< const image3d<V>, W > { - typedef dpoints_fwd_pixter< const image3d<T> > ret; + typedef dpoints_fwd_pixter< const image3d<V> > ret; }; - template <typename T, typename W> - struct bkd_qixter< image3d<T>, W > + template <typename V, typename W> + struct bkd_qixter< image3d<V>, W > { - typedef dpoints_bkd_pixter< image3d<T> > ret; + typedef dpoints_bkd_pixter< image3d<V> > ret; }; - template <typename T, typename W> - struct bkd_qixter< const image3d<T>, W > + template <typename V, typename W> + struct bkd_qixter< const image3d<V>, W > { - typedef dpoints_bkd_pixter< const image3d<T> > ret; + typedef dpoints_bkd_pixter< const image3d<V> > ret; }; // nixter - template <typename T, typename W> - struct fwd_nixter< image3d<T>, W > + template <typename V, typename W> + struct fwd_nixter< image3d<V>, W > { - typedef dpoints_fwd_pixter< image3d<T> > ret; + typedef dpoints_fwd_pixter< image3d<V> > ret; }; - template <typename T, typename W> - struct fwd_nixter< const image3d<T>, W > + template <typename V, typename W> + struct fwd_nixter< const image3d<V>, W > { - typedef dpoints_fwd_pixter< const image3d<T> > ret; + typedef dpoints_fwd_pixter< const image3d<V> > ret; }; - template <typename T, typename W> - struct bkd_nixter< image3d<T>, W > + template <typename V, typename W> + struct bkd_nixter< image3d<V>, W > { - typedef dpoints_bkd_pixter< image3d<T> > ret; + typedef dpoints_bkd_pixter< image3d<V> > ret; }; - template <typename T, typename W> - struct bkd_nixter< const image3d<T>, W > + template <typename V, typename W> + struct bkd_nixter< const image3d<V>, W > { - typedef dpoints_bkd_pixter< const image3d<T> > ret; + typedef dpoints_bkd_pixter< const image3d<V> > ret; }; } // end of namespace mln::trait -- 1.7.2.5
participants (1)
-
Guillaume Lazzara