LRE
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
April
March
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
List overview
Download
Olena-patches
January 2005
----- 2025 -----
April 2025
March 2025
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
olena-patches@lrde.epita.fr
5 participants
28 discussions
Start a n
N
ew thread
proto-1.0 19: Change point iterators.
by Thierry GERAUD
Index: ChangeLog =================================================================== --- ChangeLog (revision 18) +++ ChangeLog (working copy) @@ -1,3 +1,15 @@ +2005-01-24 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr> + + * oln/core/props.hh: Move image defaults into abstract/image.hh. + * oln/core/macros.hh: Add piter related macros. + * oln/core/abstract/image.hh: Add image defaults and piter typedefs. + * oln/core/abstract/iter.hh: Move to piter.hh. + * oln/core/abstract/piter.hh: Change interface. + * oln/core/2d/image2d.hh: Add piter typedefs in props. + * oln/core/2d/iter2d.hh: Move to fwd_piter2d.hh. + * oln/core/2d/fwd_piter2d.hh: Conform to new interface. + * oln/core/cats.hh: Add cat::piter. + 2005-01-21 Simon Odou <simon(a)lrde.epita.fr> * tests/core/tests/readonly_image: New. Index: oln/core/props.hh =================================================================== --- oln/core/props.hh (revision 18) +++ oln/core/props.hh (working copy) @@ -29,32 +29,6 @@ struct default_props; - // FIXME: doc - template <> - struct default_props < cat::image > - { - typedef mlc::undefined_type delegated_type; - - typedef mlc::undefined_type size_type; - typedef mlc::undefined_type point_type; - typedef mlc::undefined_type value_type; - - typedef mlc::undefined_type value_storage_type; - typedef mlc::undefined_type value_container_type; - - // FIXME: etc. - - template <typename T> - struct ch_value_type - { - typedef mlc::undefined_type ret; - }; - - protected: - default_props() {} - }; - - /*! \class props<E> ** ** Declaration of the trait class for properties. Index: oln/core/macros.hh =================================================================== --- oln/core/macros.hh (revision 18) +++ oln/core/macros.hh (working copy) @@ -33,6 +33,9 @@ # define oln_value_storage_type(T) typename oln::props<oln_category_type(T),T>::value_storage_type # define oln_value_container_type(T) typename oln::props<oln_category_type(T),T>::value_container_type +# define oln_piter_type(T) typename oln::props<oln_category_type(T),T>::piter_type +# define oln_fwd_piter_type(T) typename oln::props<oln_category_type(T),T>::fwd_piter_type + // binary macros # define oln_ch_value_type(I,V) typename oln::props<oln_category_type(I),I>::ch_value_type<V>::ret Index: oln/core/abstract/image.hh =================================================================== --- oln/core/abstract/image.hh (revision 18) +++ oln/core/abstract/image.hh (working copy) @@ -2,9 +2,12 @@ # define OLENA_CORE_ABSTRACT_IMAGE_HH # include <oln/core/abstract/internal/image_impl.hh> +# include <oln/core/cats.hh> +# include <oln/core/props.hh> # include <oln/core/macros.hh> # include <oln/core/value_box.hh> + /*! \namespace oln ** \brief oln namespace. */ @@ -12,6 +15,36 @@ + // FIXME: doc + template <> + struct default_props < cat::image > + { + typedef mlc::undefined_type delegated_type; + + typedef mlc::undefined_type size_type; + typedef mlc::undefined_type point_type; + typedef mlc::undefined_type value_type; + + typedef mlc::undefined_type piter_type; + typedef mlc::undefined_type fwd_piter_type; + + typedef mlc::undefined_type value_storage_type; + typedef mlc::undefined_type value_container_type; + + // FIXME: etc. + + template <typename T> + struct ch_value_type + { + typedef mlc::undefined_type ret; + }; + + protected: + default_props() {} + }; + + + /*! \namespace oln::abstract ** \brief oln::abstract namespace. */ Index: oln/core/abstract/iter.hh =================================================================== --- oln/core/abstract/iter.hh (revision 18) +++ oln/core/abstract/iter.hh (working copy) @@ -1,72 +0,0 @@ -#ifndef PROTO_OLN_CORE_ABSTRACT_ITER_HH -# define PROTO_OLN_CORE_ABSTRACT_ITER_HH - -# include <mlc/any.hh> - -# include <oln/core/abstract/point.hh> -# include <oln/core/abstract/size.hh> - -namespace oln { - - namespace abstract { - - template <typename E> - struct iter : mlc::any__best_memory<E> - { - - void - operator++() - { - this->exact().next_impl(); - } - - void - begin() - { - this->exact().begin_impl(); - } - - bool - end() - { - return this->exact().end_impl(); - } - - - template <typename P> - bool - operator!=(const point<P> &p) const - { - return this->exact().noteq_impl(p.exact()); - } - - template <typename P> - bool - operator==(const point<P> &p) const - { - return this->exact().eq_impl(p.exact()); - } - - template <typename P> - operator point<P>() const - { - return this->exact().to_point(); - } - - template <typename S> - void operator() (const size<S> &s) - { - this->exact().op_par_impl(s.exact()); - } - - protected: - - iter() - {} - - }; - } -} - - -#endif // ndef PROTO_OLN_CORE_ABSTRACT_ITER_HH Index: oln/core/abstract/piter.hh =================================================================== --- oln/core/abstract/piter.hh (revision 18) +++ oln/core/abstract/piter.hh (working copy) @@ -1,72 +1,79 @@ -#ifndef PROTO_OLN_CORE_ABSTRACT_ITER_HH -# define PROTO_OLN_CORE_ABSTRACT_ITER_HH +#ifndef PROTO_OLN_CORE_ABSTRACT_PITER_HH +# define PROTO_OLN_CORE_ABSTRACT_PITER_HH # include <mlc/any.hh> +# include <mlc/types.hh> +# include <mlc/contract.hh> # include <oln/core/abstract/point.hh> -# include <oln/core/abstract/size.hh> +# include <oln/core/cats.hh> +# include <oln/core/props.hh> + namespace oln { + + template <> + struct default_props < cat::piter > + { + typedef mlc::undefined_type point_type; + typedef mlc::undefined_type size_type; + }; + + namespace abstract { template <typename E> - struct iter : mlc::any__best_memory<E> + struct piter : public mlc::any__best_memory<E> { - - void - operator++() + + void start() { - this->exact().next_impl(); + this->exact().impl_start(); } - void - begin() + void next() { - this->exact().begin_impl(); + precondition(this->is_ok()); + this->exact().impl_next(); } - bool - end() + bool is_ok() const { - return this->exact().end_impl(); + return this->exact().impl_is_ok(); } - - template <typename P> - bool - operator!=(const point<P> &p) const + operator point_type() const { - return this->exact().noteq_impl(p.exact()); + precondition(this->is_ok()); + return this->p_; } - template <typename P> - bool - operator==(const point<P> &p) const + void invalidate() { - return this->exact().eq_impl(p.exact()); + this->exact().impl_invalidate(); + postcondition(not this->is_ok()); } - template <typename P> - operator point<P>() const - { - return this->exact().to_point(); - } + protected: - template <typename S> - void operator() (const size<S> &s) + typedef piter<E> self_type; + typedef oln_point_type(self_type) point_type; + typedef oln_size_type(self_type) size_type; + + piter(const size_type& s) : + s_(s), + p_() { - this->exact().op_par_impl(s.exact()); + this->invalidate(); } - protected: + const size_type s_; + point_type p_; - iter() - {} - }; } } -#endif // ndef PROTO_OLN_CORE_ABSTRACT_ITER_HH +#endif // ndef PROTO_OLN_CORE_ABSTRACT_PITER_HH Index: oln/core/2d/image2d.hh =================================================================== --- oln/core/2d/image2d.hh (revision 18) +++ oln/core/2d/image2d.hh (working copy) @@ -37,6 +37,9 @@ typedef point2d point_type; typedef T value_type; + typedef fwd_piter2d piter_type; + typedef fwd_piter2d fwd_piter_type; + // please note that value_storage_type means data_type // since image2d is an image_with_data typedef mlc_encoding_type(T) value_storage_type; Index: oln/core/2d/iter2d.hh =================================================================== --- oln/core/2d/iter2d.hh (revision 18) +++ oln/core/2d/iter2d.hh (working copy) @@ -1,98 +0,0 @@ -#ifndef PROTO_OLN_CORE_2D_ITER2D_HH -# define PROTO_OLN_CORE_2D_ITER2D_HH - -# include <mlc/contract.hh> - -# include <oln/core/abstract/iter.hh> -# include <oln/core/2d/point2d.hh> -# include <oln/core/2d/size2d.hh> -# include <oln/core/props.hh> - - -namespace oln { - - struct iter2d; - - struct iter2d : abstract::iter<iter2d> - { - - typedef abstract::iter<iter2d> super_type; - - friend class abstract::iter<iter2d>; - - iter2d() : super_type(), nrows_(0), ncols_(0) - {} - - iter2d(const size2d& size) : - super_type(), - nrows_(size.nrows()), - ncols_(size.ncols()) - {} - - - protected: - - coord_t nrows_; - coord_t ncols_; - point2d p_; - - point2d - to_point() const - { - precondition(!end_impl()); - invariant(this->p_.row() >= 0 && - (this->p_.row() < nrows_ || this->p_.row() == nrows_) && - this->p_.col() >= 0 && - this->p_.col() < ncols_); - return this->p_; - } - - - void op_par_impl(const size2d& size) - { - ncols_ = size.ncols(); - nrows_ = size.nrows(); - } - - void - next_impl() - { - this->p_.col()++; - if (this->p_.col() != this->ncols_) - return; - this->p_.col() = 0; - this->p_.row()++; - } - - void - begin_impl() - { - this->p_.row() = 0; - this->p_.col() = 0; - } - - bool - end_impl() const - { - return this->p_.row() == this->nrows_; - } - - - bool - noteq_impl(const point2d &p) const - { - return p_ != p.exact(); - } - - bool - eq_impl(const point2d &p) const - { - return p_ == p.exact(); - } - - - }; -} - - -#endif // ndef PROTO_OLN_CORE_2D_ITER2D_HH Index: oln/core/2d/fwd_piter2d.hh =================================================================== --- oln/core/2d/fwd_piter2d.hh (revision 18) +++ oln/core/2d/fwd_piter2d.hh (working copy) @@ -1,5 +1,5 @@ -#ifndef PROTO_OLN_CORE_2D_ITER2D_HH -# define PROTO_OLN_CORE_2D_ITER2D_HH +#ifndef PROTO_OLN_CORE_2D_FWD_ITER2D_HH +# define PROTO_OLN_CORE_2D_FWD_ITER2D_HH # include <mlc/contract.hh> @@ -11,88 +11,55 @@ namespace oln { - struct iter2d; + struct fwd_iter2d; - struct iter2d : abstract::iter<iter2d> + template <> + struct props < cat::piter, fwd_iter2d > { + typedef point2d point_type; + typedef size2d size_type; + }; - typedef abstract::iter<iter2d> super_type; + struct fwd_iter2d : public abstract::piter<fwd_iter2d> + { - friend class abstract::iter<iter2d>; + typedef abstract::iter<fwd_iter2d> super_type; - iter2d() : super_type(), nrows_(0), ncols_(0) - {} + friend class abstract::iter<fwd_iter2d>; - iter2d(const size2d& size) : - super_type(), - nrows_(size.nrows()), - ncols_(size.ncols()) - {} - - - protected: - - coord_t nrows_; - coord_t ncols_; - point2d p_; - - point2d - to_point() const + fwd_iter2d(const size2d& size) : + super_type(size) { - precondition(!end_impl()); - invariant(this->p_.row() >= 0 && - (this->p_.row() < nrows_ || this->p_.row() == nrows_) && - this->p_.col() >= 0 && - this->p_.col() < ncols_); - return this->p_; } - - void op_par_impl(const size2d& size) + void impl_start() { - ncols_ = size.ncols(); - nrows_ = size.nrows(); - } - - void - next_impl() - { - this->p_.col()++; - if (this->p_.col() != this->ncols_) - return; - this->p_.col() = 0; - this->p_.row()++; - } - - void - begin_impl() - { this->p_.row() = 0; this->p_.col() = 0; } - bool - end_impl() const + bool impl_is_ok() const { - return this->p_.row() == this->nrows_; + return this->p_.row() < this->s_.nrows(); } - - bool - noteq_impl(const point2d &p) const + void impl_next() const { - return p_ != p.exact(); + ++this->p_.col(); + if (this->p_.col() != this->s_.ncols()) + return; + this->p_.col() = 0; + ++this->p_.row(); } - bool - eq_impl(const point2d &p) const + void impl_invalidate() { - return p_ == p.exact(); + this->p_.row() = this->s_.nrows(); + this->p_.col() = this->s_.ncols(); } - }; } -#endif // ndef PROTO_OLN_CORE_2D_ITER2D_HH +#endif // ndef PROTO_OLN_CORE_2D_FWD_ITER2D_HH Index: oln/core/cats.hh =================================================================== --- oln/core/cats.hh (revision 18) +++ oln/core/cats.hh (working copy) @@ -35,9 +35,10 @@ namespace cat { struct image; + struct data_storage; + struct piter; struct point; struct size; - struct data_storage; // FIXME:... } // end of namespace oln::cat
20 years, 2 months
1
0
0
0
proto-1.0 18: Add mlc_encoding_type_ macro
by Simon Odou
Index: ChangeLog from Simon Odou <simon(a)lrde.epita.fr> * mlc/traits.hh: Add `mlc_encoding_type_' macro. traits.hh | 1 + 1 files changed, 1 insertion(+) Index: mlc/traits.hh --- mlc/traits.hh (revision 17) +++ mlc/traits.hh (working copy) @@ -14,6 +14,7 @@ # define mlc_encoding_type(T) typename mlc::traits<T>::encoding_type +# define mlc_encoding_type_(T) mlc::traits<T>::encoding_type
20 years, 2 months
1
0
0
0
proto-1.0 17: Add tests for readonly and readwrite images
by Simon Odou
Index: ChangeLog from Simon Odou <simon(a)lrde.epita.fr> * tests/core/tests/readonly_image: New. * tests/core/tests/readwrite_image: New. readonly_image | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ readwrite_image | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) Index: tests/core/tests/readonly_image --- tests/core/tests/readonly_image (revision 0) +++ tests/core/tests/readonly_image (revision 0) @@ -0,0 +1,60 @@ +#include <iostream> + +#include <ntg/real/int_u8.hh> +#include <oln/basics2d.hh> + +#include "check.hh" +#include "data.hh" + +namespace oln { + + struct dummy_image; + + template <> + struct category_type< dummy_image > { typedef cat::image ret; }; + + template <> + struct props <cat::image, dummy_image> : + public default_props < cat::image > + { + typedef size2d size_type; + typedef point2d point_type; + typedef ntg::int_u8 value_type; + + typedef mlc_encoding_type_(value_type) value_storage_type; + typedef array2d<value_storage_type> value_container_type; + + typedef tag::readonly constness_tag; + typedef tag::dimension2 dimension_tag; + typedef mlc::no_type delegated_type; + }; + + struct dummy_image : public abstract::image_with_data< dummy_image > + { + + typedef abstract::image_with_data< dummy_image > super_type; + + dummy_image() + { + this->exact_ptr = this; + } + + dummy_image(coord_t nrows, coord_t ncols) : + super_type(size2d(nrows, ncols)) + { + this->exact_ptr = this; + } + + }; + +} // end of namespace test + + + +bool check() +{ + oln::dummy_image ima(3, 3); + // COMPFAIL + ima[oln::point2d(0,0)] = 42; + return false; +} Index: tests/core/tests/readwrite_image --- tests/core/tests/readwrite_image (revision 0) +++ tests/core/tests/readwrite_image (revision 0) @@ -0,0 +1,60 @@ +#include <iostream> + +#include <ntg/real/int_u8.hh> +#include <oln/basics2d.hh> + +#include "check.hh" +#include "data.hh" + +namespace oln { + + struct dummy_image; + + template <> + struct category_type< dummy_image > { typedef cat::image ret; }; + + template <> + struct props <cat::image, dummy_image> : + public default_props < cat::image > + { + typedef size2d size_type; + typedef point2d point_type; + typedef ntg::int_u8 value_type; + + typedef mlc_encoding_type_(value_type) value_storage_type; + typedef array2d<value_storage_type> value_container_type; + + typedef tag::readwrite constness_tag; + typedef tag::dimension2 dimension_tag; + typedef mlc::no_type delegated_type; + }; + + struct dummy_image : public abstract::image_with_data< dummy_image > + { + + typedef abstract::image_with_data< dummy_image > super_type; + + dummy_image() + { + this->exact_ptr = this; + } + + dummy_image(coord_t nrows, coord_t ncols) : + super_type(size2d(nrows, ncols)) + { + this->exact_ptr = this; + } + + }; + +} // end of namespace test + + + +bool check() +{ + oln::dummy_image ima(3, 3); + ima[oln::point2d(0,0)] = 42; + std::cout << ima[oln::point2d(0,0)].value() << std::endl; + return false; +}
20 years, 2 months
1
0
0
0
proto-1.0 16: Abstract hierarchy for image with dimension (and update pseudo algorithms to use these abstractions)
by Simon Odou
Index: ChangeLog from Simon Odou <simon(a)lrde.epita.fr> * oln/core/tags.hh: The abstract entry point is a big switch which must now inherits an image dimension. * oln/fancy/print.hh: Use abstraction for image with dimension (image_with_dim in Olena). * oln/fancy/iota.hh: Likewise. * oln/makefile.src: Add image_dimension.hh. * oln/core/abstract/image_dimension.hh: New. * oln/core/1d/image1d.hh: Add a property for dimension. * oln/core/2d/image2d.hh: Likewise. * oln/core/3d/image3d.hh: Likewise. core/1d/image1d.hh | 1 core/2d/image2d.hh | 1 core/3d/image3d.hh | 1 core/abstract/image_dimension.hh | 58 +++++++++++++++++++++++++++++++++++++++ core/tags.hh | 22 ++++++++++++-- fancy/iota.hh | 12 ++++---- fancy/print.hh | 32 ++++++++++----------- makefile.src | 1 8 files changed, 103 insertions(+), 25 deletions(-) Index: oln/fancy/print.hh --- oln/fancy/print.hh (revision 15) +++ oln/fancy/print.hh (working copy) @@ -22,13 +22,12 @@ namespace impl { - template <typename T> - void print(const image1d<T>& input, std::ostream& ostr); - template <typename T> - void print(const image2d<T>& input, std::ostream& ostr); - template <typename T> - void print(const image3d<T>& input, std::ostream& ostr); - // FIXME: it should be abstract::image2d<I>... + template <typename E> + void print(const abstract::image1d<E>& input, std::ostream& ostr); + template <typename E> + void print(const abstract::image2d<E>& input, std::ostream& ostr); + template <typename E> + void print(const abstract::image3d<E>& input, std::ostream& ostr); } // end of namespace impl @@ -73,31 +72,31 @@ } - template <typename T> - void print(const image1d<T>& input, std::ostream& ostr) + template <typename E> + void print(const abstract::image1d<E>& input, std::ostream& ostr) { // FIXME: lacks cleaning for (coord_t index = 0; index < input.size().nindices(); ++index) { - ostr << internal::pp<T>(input[point1d(index)]) << ' '; + ostr << internal::pp<oln_value_type(E)>(input[point1d(index)]) << ' '; } ostr << std::endl; } - template <typename T> - void print(const image2d<T>& input, std::ostream& ostr) + template <typename E> + void print(const abstract::image2d<E>& input, std::ostream& ostr) { // FIXME: lacks cleaning for (coord_t row = 0; row < input.size().nrows(); ++row) { for (coord_t col = 0; col < input.size().ncols(); ++col) - ostr << internal::pp<T>(input[point2d(row,col)]) << ' '; + ostr << internal::pp<oln_value_type(E)>(input[point2d(row,col)]) << ' '; ostr << std::endl; } } - template <typename T> - void print(const image3d<T>& input, std::ostream& ostr) + template <typename E> + void print(const abstract::image3d<E>& input, std::ostream& ostr) { // FIXME: lacks cleaning for (coord_t slice = 0; slice < input.size().nslices(); ++slice) @@ -105,7 +104,8 @@ for (coord_t row = 0; row < input.size().nrows(); ++row) { for (coord_t col = 0; col < input.size().ncols(); ++col) - ostr << internal::pp<T>(input[point3d(slice,row,col)]) << ' '; + ostr << internal::pp<oln_value_type(E)>(input[point3d(slice,row,col)]) + << ' '; ostr << ", "; } ostr << std::endl; Index: oln/fancy/iota.hh --- oln/fancy/iota.hh (revision 15) +++ oln/fancy/iota.hh (working copy) @@ -12,11 +12,11 @@ namespace impl { template <typename T> - void iota(image1d<T>& inout); // FIXME: abstract::image1d<I>... + void iota(abstract::image1d<T>& inout); template <typename T> - void iota(image2d<T>& inout); // FIXME: abstract::image2d<I>... + void iota(abstract::image2d<T>& inout); template <typename T> - void iota(image3d<T>& inout); // FIXME: abstract::image2d<I>... + void iota(abstract::image3d<T>& inout); } // end of namespace impl @@ -39,7 +39,7 @@ // iterators and we just want to test. template <typename T> - void iota(image2d<T>& inout) + void iota(abstract::image2d<T>& inout) { unsigned counter = 0; // FIXME: lacks cleaning @@ -49,7 +49,7 @@ } template <typename T> - void iota(image1d<T>& inout) + void iota(abstract::image1d<T>& inout) { unsigned counter = 0; // FIXME: lacks cleaning @@ -58,7 +58,7 @@ } template <typename T> - void iota(image3d<T>& inout) + void iota(abstract::image3d<T>& inout) { unsigned counter = 0; // FIXME: lacks cleaning Index: oln/makefile.src --- oln/makefile.src (revision 15) +++ oln/makefile.src (working copy) @@ -26,6 +26,7 @@ core/abstract/data_storage.hh \ core/abstract/image.hh \ core/abstract/image_constness.hh \ + core/abstract/image_dimension.hh \ core/abstract/image_with_data.hh \ core/abstract/images.hh \ core/abstract/internal/image_impl.hh \ Index: oln/core/abstract/image_dimension.hh --- oln/core/abstract/image_dimension.hh (revision 0) +++ oln/core/abstract/image_dimension.hh (revision 0) @@ -0,0 +1,58 @@ +#ifndef OLENA_CORE_ABSTRACT_IMAGE_DIMENSION_HH +# define OLENA_CORE_ABSTRACT_IMAGE_DIMENSION_HH + +# include <oln/core/abstract/image.hh> + +/*! \namespace oln +** \brief oln namespace. +*/ +namespace oln { + + /*! \namespace oln::abstract + ** \brief oln::abstract namespace. + */ + namespace abstract { + + /*! \class abstract::image2d<E> + ** + ** Class of 1d images. + */ + + + template <typename E> + struct image1d : public virtual image<E> + { + protected: + + /*! \brief Constructor (protected, empty). + */ + image1d() {} + }; + + template <typename E> + struct image2d : public virtual image<E> + { + protected: + + /*! \brief Constructor (protected, empty). + */ + image2d() {} + }; + + template <typename E> + struct image3d : public virtual image<E> + { + protected: + + /*! \brief Constructor (protected, empty). + */ + image3d() {} + }; + + + } // end of namespace oln::abstract + +} // end of namespace oln + + +#endif // ! OLENA_CORE_ABSTRACT_IMAGE_DIMENSION_HH Index: oln/core/1d/image1d.hh --- oln/core/1d/image1d.hh (revision 15) +++ oln/core/1d/image1d.hh (working copy) @@ -47,6 +47,7 @@ // tags typedef tag::readwrite constness_tag; + typedef tag::dimension1 dimension_tag; // functions Index: oln/core/2d/image2d.hh --- oln/core/2d/image2d.hh (revision 15) +++ oln/core/2d/image2d.hh (working copy) @@ -48,6 +48,7 @@ // tags typedef tag::readwrite constness_tag; + typedef tag::dimension2 dimension_tag; // functions Index: oln/core/3d/image3d.hh --- oln/core/3d/image3d.hh (revision 15) +++ oln/core/3d/image3d.hh (working copy) @@ -48,6 +48,7 @@ // tags typedef tag::readwrite constness_tag; + typedef tag::dimension3 dimension_tag; // functions Index: oln/core/tags.hh --- oln/core/tags.hh (revision 15) +++ oln/core/tags.hh (working copy) @@ -2,6 +2,7 @@ # define OLENA_CORE_TAGS_HH # include <oln/core/abstract/image_constness.hh> +# include <oln/core/abstract/image_dimension.hh> #define oln_tag_decl(TAG) \ \ @@ -60,6 +61,10 @@ oln_tag_decl_case( constness, readonly, abstract::readonly_image ) oln_tag_decl_case( constness, readwrite, abstract::readwrite_image ) + oln_tag_decl ( dimension ); + oln_tag_decl_case( dimension, dimension1, abstract::image1d) + oln_tag_decl_case( dimension, dimension2, abstract::image2d) + oln_tag_decl_case( dimension, dimension3, abstract::image3d) namespace internal { @@ -70,8 +75,17 @@ // test if ret derives from constness_tag }; + template <typename E> + struct retrieve < tag::dimension, E > + { + typedef typename props<cat::image,E>::dimension_tag ret; // FIXME: ok? + // test if ret derives from constness_tag + }; + + template <typename TAG, typename E> - struct image_switch : public image_case< typename retrieve<TAG,E>::ret, E> + struct image_switch : + public image_case< typename retrieve<TAG,E>::ret, E> { protected: image_switch() {} @@ -86,8 +100,10 @@ namespace abstract { template <typename E> - struct image_entry : public tag::internal::image_switch < tag::constness, E > - // ... + struct image_entry : + public tag::internal::image_switch < tag::constness, E >, + public tag::internal::image_switch < tag::dimension, E > + // ... { protected: image_entry() {}
20 years, 2 months
1
0
0
0
proto-1.0 10: Add Point1d and Point3d
by Simon Odou
Index: ChangeLog from Simon Odou <simon(a)lrde.epita.fr> * oln/basics1d.hh: New. * oln/core/1d/point1d.hh: New. * oln/core/3d: New. * oln/core/3d/point3d.hh: New. * oln/basics3d.hh: New. ChangeLog | 8 +++++ oln/basics1d.hh | 9 ++++++ oln/basics3d.hh | 9 ++++++ oln/core/1d/point1d.hh | 58 +++++++++++++++++++++++++++++++++++++++ oln/core/3d/point3d.hh | 72 +++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 156 insertions(+) Index: ChangeLog --- ChangeLog (revision 9) +++ ChangeLog (working copy) @@ -1,3 +1,11 @@ +2005-01-21 Simon Odou <simon(a)lrde.epita.fr> + + * oln/basics1d.hh: New. + * oln/core/1d/point1d.hh: New. + * oln/core/3d: New. + * oln/core/3d/point3d.hh: New. + * oln/basics3d.hh: New. + 2005-01-21 Damien Thivolle <damien(a)lrde.epita.fr> * oln/makefile.src: Update file dependencies. Index: oln/basics1d.hh --- oln/basics1d.hh (revision 0) +++ oln/basics1d.hh (revision 0) @@ -0,0 +1,9 @@ +#ifndef OLENA_BASICS1D_HH +# define OLENA_BASICS1D_HH + + +# include <oln/basics.hh> + +# include <oln/core/1d/point1d.hh> + +#endif // ! OLENA_BASICS1D_HH Index: oln/core/1d/point1d.hh --- oln/core/1d/point1d.hh (revision 0) +++ oln/core/1d/point1d.hh (revision 0) @@ -0,0 +1,58 @@ +#ifndef OLENA_CORE_1D_POINT1D_HH +# define OLENA_CORE_1D_POINT1D_HH + +# include <ostream> + +# include <oln/core/abstract/point.hh> +# include <oln/core/coord.hh> + +namespace oln { + + struct point1d : public abstract::point< point1d > + { + point1d() : + index_(0) + { + } + + point1d(coord_t index_) : + index_(index_) + { + } + + point1d(const point1d& rhs) : + index_(rhs.index_) + { + } + + point1d& operator=(const point1d& rhs) + { + if (&rhs == this) + return *this; + this->index_ = rhs.index_; + return *this; + } + + bool impl_eq(const point1d& rhs) const + { + return this->index_ == rhs.index_; + } + + const coord_t index() const { return index_; } + + coord_t& index() { return index_; } + + protected: + coord_t index_; + }; + +} // end of namespace oln + + +std::ostream& operator<<(std::ostream& ostr, const oln::point1d& p) +{ + return ostr << '(' << p.index() << ')'; +} + + +#endif // ! OLENA_CORE_1D_POINT1D_HH Index: oln/core/3d/point3d.hh --- oln/core/3d/point3d.hh (revision 0) +++ oln/core/3d/point3d.hh (revision 0) @@ -0,0 +1,72 @@ +#ifndef OLENA_CORE_3D_POINT3D_HH +# define OLENA_CORE_3D_POINT3D_HH + +# include <ostream> + +# include <oln/core/abstract/point.hh> +# include <oln/core/coord.hh> + +namespace oln { + + struct point3d : public abstract::point< point3d > + { + point3d() : + slice_(0), + row_(0), + col_(0) + { + } + + point3d(coord_t slice_, coord_t row_, coord_t col_) : + slice_(slice_), + row_(row_), + col_(col_) + { + } + + point3d(const point3d& rhs) : + slice_(slice_), + row_(rhs.row_), + col_(rhs.col_) + { + } + + point3d& operator=(const point3d& rhs) + { + if (&rhs == this) + return *this; + this->slice_ = rhs.slice_; + this->row_ = rhs.row_; + this->col_ = rhs.col_; + return *this; + } + + bool impl_eq(const point3d& rhs) const + { + return this->slice_ == rhs.slice_ and + this->row_ == rhs.row_ and + this->col_ == rhs.col_; + } + + const coord_t slice() const { return slice_; } + const coord_t row() const { return row_; } + const coord_t col() const { return col_; } + + coord_t& slice() { return slice_; } + coord_t& row() { return row_; } + coord_t& col() { return col_; } + + protected: + coord_t slice_, row_, col_; + }; + +} // end of namespace oln + + +std::ostream& operator<<(std::ostream& ostr, const oln::point3d& p) +{ + return ostr << '(' << p.slice() << ',' << p.row() << ',' << p.col() << ')'; +} + + +#endif // ! OLENA_CORE_3D_POINT3D_HH Index: oln/basics3d.hh --- oln/basics3d.hh (revision 0) +++ oln/basics3d.hh (revision 0) @@ -0,0 +1,9 @@ +#ifndef OLENA_BASICS3D_HH +# define OLENA_BASICS3D_HH + + +# include <oln/basics.hh> + +# include <oln/core/3d/point3d.hh> + +#endif // ! OLENA_BASICS3D_HH
20 years, 2 months
2
6
0
0
proto-1.0 15: Fix missing files in makefile.src
by Simon Odou
Index: ChangeLog from Simon Odou <simon(a)lrde.epita.fr> * oln/makefile.src: Fix missing files. makefile.src | 12 ++++++++++++ 1 files changed, 12 insertions(+) Index: oln/makefile.src --- oln/makefile.src (revision 14) +++ oln/makefile.src (working copy) @@ -4,13 +4,25 @@ ## OLN_DEP = \ + basics.hh \ + basics1d.hh \ + basics2d.hh \ + basics3d.hh \ config/pconf.hh \ config/system.hh \ + core/1d/array1d.hh \ + core/1d/image1d.hh \ + core/1d/point1d.hh \ + core/1d/size1d.hh \ core/2d/array2d.hh \ core/2d/image2d.hh \ core/2d/iter2d.hh \ core/2d/point2d.hh \ core/2d/size2d.hh \ + core/3d/array3d.hh \ + core/3d/image3d.hh \ + core/3d/point3d.hh \ + core/3d/size3d.hh \ core/abstract/data_storage.hh \ core/abstract/image.hh \ core/abstract/image_constness.hh \
20 years, 2 months
1
0
0
0
proto-1.0 14: Add Image3d with test
by Simon Odou
Index: ChangeLog from Simon Odou <simon(a)lrde.epita.fr> * tests/core/tests/image3d: New. * oln/fancy/print.hh: Add print for image3d. * oln/fancy/iota.hh: Add iota for image3d. * oln/core/2d/image2d.hh: Fix a 80 columns line. * oln/core/3d/array3d.hh: Fix a missing variable. * oln/core/3d/image3d.hh: New. * oln/core/3d/point3d.hh: Fix a missing "rhs". * oln/basics3d.hh: Add image3d include. oln/basics3d.hh | 1 oln/core/2d/image2d.hh | 3 - oln/core/3d/array3d.hh | 4 - oln/core/3d/image3d.hh | 102 +++++++++++++++++++++++++++++++++++++++++++++++ oln/core/3d/point3d.hh | 2 oln/fancy/iota.hh | 16 ++++++- oln/fancy/print.hh | 28 +++++++++++- tests/core/tests/image3d | 40 ++++++++++++++++++ 8 files changed, 187 insertions(+), 9 deletions(-) Index: tests/core/tests/image3d --- tests/core/tests/image3d (revision 0) +++ tests/core/tests/image3d (revision 0) @@ -0,0 +1,40 @@ + +#include <iostream> + +#include <ntg/real/int_u8.hh> +#include <oln/basics3d.hh> + +#include <oln/fancy/iota.hh> +#include <oln/fancy/print.hh> + +#include "check.hh" +#include "data.hh" + + + +template <typename I> +void foo(oln::abstract::image<I>& input, const oln_point_type(I)& p) +{ + // FIXME: dummy code below +// struct dummy {}; +// oln_typeof(I,value) tmp = (dummy*)0; + input[p] = 7; +} + + +bool check() +{ + oln::point3d p(0,0,0); + + typedef oln::image3d<ntg::int_u8> image_type; + image_type ima(3, 3, 3); + oln::fancy::iota(ima); + oln::fancy::println(ima); + + image_type ima2; + ima2 = ima; + + foo(ima, p); + oln::fancy::println(ima2); + return false; +} Index: oln/fancy/print.hh --- oln/fancy/print.hh (revision 13) +++ oln/fancy/print.hh (working copy) @@ -10,6 +10,7 @@ # include <oln/core/1d/image1d.hh> # include <oln/core/2d/image2d.hh> +# include <oln/core/3d/image3d.hh> namespace oln { @@ -25,6 +26,8 @@ void print(const image1d<T>& input, std::ostream& ostr); template <typename T> void print(const image2d<T>& input, std::ostream& ostr); + template <typename T> + void print(const image3d<T>& input, std::ostream& ostr); // FIXME: it should be abstract::image2d<I>... } // end of namespace impl @@ -71,6 +74,17 @@ } template <typename T> + void print(const image1d<T>& input, std::ostream& ostr) + { + // FIXME: lacks cleaning + for (coord_t index = 0; index < input.size().nindices(); ++index) + { + ostr << internal::pp<T>(input[point1d(index)]) << ' '; + } + ostr << std::endl; + } + + template <typename T> void print(const image2d<T>& input, std::ostream& ostr) { // FIXME: lacks cleaning @@ -83,15 +97,21 @@ } template <typename T> - void print(const image1d<T>& input, std::ostream& ostr) + void print(const image3d<T>& input, std::ostream& ostr) { // FIXME: lacks cleaning - for (coord_t index = 0; index < input.size().nindices(); ++index) + for (coord_t slice = 0; slice < input.size().nslices(); ++slice) + { + for (coord_t row = 0; row < input.size().nrows(); ++row) { - ostr << internal::pp<T>(input[point1d(index)]) << ' '; + for (coord_t col = 0; col < input.size().ncols(); ++col) + ostr << internal::pp<T>(input[point3d(slice,row,col)]) << ' '; + ostr << ", "; } - ostr << std::endl; + ostr << std::endl; + } } + } // end of namespace impl Index: oln/fancy/iota.hh --- oln/fancy/iota.hh (revision 13) +++ oln/fancy/iota.hh (working copy) @@ -1,8 +1,9 @@ #ifndef OLENA_FANCY_IOTA_HH # define OLENA_FANCY_IOTA_HH +# include <oln/core/1d/image1d.hh> # include <oln/core/2d/image2d.hh> -# include <oln/core/1d/image1d.hh> +# include <oln/core/3d/image3d.hh> namespace oln { @@ -14,6 +15,8 @@ void iota(image1d<T>& inout); // FIXME: abstract::image1d<I>... template <typename T> void iota(image2d<T>& inout); // FIXME: abstract::image2d<I>... + template <typename T> + void iota(image3d<T>& inout); // FIXME: abstract::image2d<I>... } // end of namespace impl @@ -54,6 +57,17 @@ inout[point1d(index)] = ++counter; } + template <typename T> + void iota(image3d<T>& inout) + { + unsigned counter = 0; + // FIXME: lacks cleaning + for (coord_t slice = 0; slice < inout.size().nslices(); ++slice) + for (coord_t row = 0; row < inout.size().nrows(); ++row) + for (coord_t col = 0; col < inout.size().ncols(); ++col) + inout[point3d(slice,row,col)] = ++counter; + } + } // end of namespace impl Index: oln/core/2d/image2d.hh --- oln/core/2d/image2d.hh (revision 13) +++ oln/core/2d/image2d.hh (working copy) @@ -16,7 +16,8 @@ template <typename T> class image2d; // category decl - template <typename T> struct category_type< image2d<T> > { typedef cat::image ret; }; + template <typename T> + struct category_type< image2d<T> > { typedef cat::image ret; }; /*! \class props< abstract::image, image2d<T> > Index: oln/core/3d/array3d.hh --- oln/core/3d/array3d.hh (revision 13) +++ oln/core/3d/array3d.hh (working copy) @@ -114,7 +114,7 @@ for (size_t slice = 0; slice < nslices_eff; ++slice) { T** a2 = array2_ + slice * nrows_eff; - array[slice] = a2 + size_.border(); + array_[slice] = a2 + size_.border(); for (size_t row = 0; row < nrows_eff; ++row) { a2[row] = buf; @@ -179,8 +179,8 @@ private: T* buffer_; + T*** array_; T** array2_; - T*** array_; size3d size_; void invariant_() const Index: oln/core/3d/image3d.hh --- oln/core/3d/image3d.hh (revision 0) +++ oln/core/3d/image3d.hh (revision 0) @@ -0,0 +1,102 @@ +#ifndef OLENA_CORE_IMAGE3D_HH +# define OLENA_CORE_IMAGE3D_HH + +# include <mlc/traits.hh> + +# include <oln/core/abstract/image_with_data.hh> +# include <oln/core/3d/array3d.hh> + +/*! \namespace oln +** \brief oln namespace. +*/ +namespace oln { + + + // fwd decl + template <typename T> class image3d; + + // category decl + template <typename T> + struct category_type< image3d<T> > { typedef cat::image ret; }; + + + /*! \class props< abstract::image, image3d<T> > + ** + ** Properties of common 3D images. Specialization of props<abstraction,type>. + ** Parameter T is the type of pixel values. + ** + ** \see image3d<T>, props<category,type> + */ + + template <typename T> + struct props < cat::image, image3d<T> > : public default_props < cat::image > + { + typedef mlc::no_type delegated_type; + + typedef size3d size_type; + typedef point3d point_type; + typedef T value_type; + + // please note that value_storage_type means data_type + // since image3d is an image_with_data + typedef mlc_encoding_type(T) value_storage_type; + + // please note that value_container_type means + // data_container_type (or value_storage_container_type) + // FIXME: find a better name... + typedef array3d<value_storage_type> value_container_type; + + // tags + typedef tag::readwrite constness_tag; + + // functions + + template <typename U> + struct ch_value_type + { + typedef image3d<U> ret; + }; + + }; + + + + /*! \class image3d<T> + ** + ** Common class for 3D images. Pixels values are stored in memory. + ** FIXME: give details about other properties (border, etc.) + ** + ** Parameter T is the type of pixel values. + */ + + template <typename T> + class image3d : public abstract::image_with_data< image3d<T> > + { + public: + + typedef abstract::image_with_data< image3d<T> > super_type; + + image3d() + { + this->exact_ptr = this; + } + + image3d(coord_t nslices, coord_t nrows, coord_t ncols) : + super_type(size3d(nslices, nrows, ncols)) + { + this->exact_ptr = this; + } + + image3d(image3d& rhs) : + super_type(rhs) + { + this->exact_ptr = this; + } + + }; + + +} // end of namespace oln + + +#endif // ! OLENA_CORE_IMAGE3D_HH Index: oln/core/3d/point3d.hh --- oln/core/3d/point3d.hh (revision 13) +++ oln/core/3d/point3d.hh (working copy) @@ -25,7 +25,7 @@ } point3d(const point3d& rhs) : - slice_(slice_), + slice_(rhs.slice_), row_(rhs.row_), col_(rhs.col_) { Index: oln/basics3d.hh --- oln/basics3d.hh (revision 13) +++ oln/basics3d.hh (working copy) @@ -6,5 +6,6 @@ # include <oln/core/3d/size3d.hh> # include <oln/core/3d/point3d.hh> +# include <oln/core/3d/image3d.hh> #endif // ! OLENA_BASICS3D_HH
20 years, 2 months
1
0
0
0
proto-1.0 13: Add Image1d with test
by Simon Odou
Index: ChangeLog from Simon Odou <simon(a)lrde.epita.fr> * tests/core/tests/image1d: New. * oln/fancy/print.hh: Add print for image1d. * oln/fancy/iota.hh: Add iota for image1d. * oln/basics1d.hh: Add image1d include. * oln/core/2d/image2d.hh: Move the has_data method to... * oln/core/abstract/image_with_data.hh: here. * oln/core/1d/image1d.hh: New. * oln/core/1d/size1d.hh: Fix a forgotten initialization in constructor. ChangeLog | 15 ----- oln/basics1d.hh | 1 oln/core/1d/image1d.hh | 101 +++++++++++++++++++++++++++++++++++ oln/core/1d/size1d.hh | 3 - oln/core/2d/image2d.hh | 5 - oln/core/abstract/image_with_data.hh | 10 +++ oln/fancy/iota.hh | 21 ++++++- oln/fancy/print.hh | 14 ++++ tests/core/tests/image1d | 40 +++++++++++++ 9 files changed, 186 insertions(+), 24 deletions(-) Index: tests/core/tests/image1d --- tests/core/tests/image1d (revision 0) +++ tests/core/tests/image1d (revision 0) @@ -0,0 +1,40 @@ + +#include <iostream> + +#include <ntg/real/int_u8.hh> +#include <oln/basics1d.hh> + +#include <oln/fancy/iota.hh> +#include <oln/fancy/print.hh> + +#include "check.hh" +#include "data.hh" + + + +template <typename I> +void foo(oln::abstract::image<I>& input, const oln_point_type(I)& p) +{ + // FIXME: dummy code below +// struct dummy {}; +// oln_typeof(I,value) tmp = (dummy*)0; + input[p] = 7; +} + + +bool check() +{ + oln::point1d p(0); + + typedef oln::image1d<ntg::int_u8> image_type; + image_type ima(3); + oln::fancy::iota(ima); + oln::fancy::println(ima); + + image_type ima2; + ima2 = ima; + + foo(ima, p); + oln::fancy::println(ima2); + return false; +} Index: oln/fancy/print.hh --- oln/fancy/print.hh (revision 12) +++ oln/fancy/print.hh (working copy) @@ -8,6 +8,7 @@ # include <ntg/real/int_u8.hh> // FIXME: no coupling like that! +# include <oln/core/1d/image1d.hh> # include <oln/core/2d/image2d.hh> namespace oln { @@ -21,6 +22,8 @@ namespace impl { template <typename T> + void print(const image1d<T>& input, std::ostream& ostr); + template <typename T> void print(const image2d<T>& input, std::ostream& ostr); // FIXME: it should be abstract::image2d<I>... @@ -79,6 +82,17 @@ } } + template <typename T> + void print(const image1d<T>& input, std::ostream& ostr) + { + // FIXME: lacks cleaning + for (coord_t index = 0; index < input.size().nindices(); ++index) + { + ostr << internal::pp<T>(input[point1d(index)]) << ' '; + } + ostr << std::endl; + } + } // end of namespace impl Index: oln/fancy/iota.hh --- oln/fancy/iota.hh (revision 12) +++ oln/fancy/iota.hh (working copy) @@ -2,6 +2,7 @@ # define OLENA_FANCY_IOTA_HH # include <oln/core/2d/image2d.hh> +# include <oln/core/1d/image1d.hh> namespace oln { @@ -9,7 +10,10 @@ namespace impl { - template <typename T> void iota(image2d<T>& inout); // FIXME: abstract::image2d<I>... + template <typename T> + void iota(image1d<T>& inout); // FIXME: abstract::image1d<I>... + template <typename T> + void iota(image2d<T>& inout); // FIXME: abstract::image2d<I>... } // end of namespace impl @@ -28,15 +32,28 @@ namespace impl { + // FIXME: must be generic, of course ! But for now, we have not yet + // iterators and we just want to test. + template <typename T> void iota(image2d<T>& inout) { unsigned counter = 0; - for (coord_t row = 0; row < inout.size().nrows(); ++row) // FIXME: lacks cleaning + // FIXME: lacks cleaning + for (coord_t row = 0; row < inout.size().nrows(); ++row) for (coord_t col = 0; col < inout.size().ncols(); ++col) inout[point2d(row,col)] = ++counter; } + template <typename T> + void iota(image1d<T>& inout) + { + unsigned counter = 0; + // FIXME: lacks cleaning + for (coord_t index = 0; index < inout.size().nindices(); ++index) + inout[point1d(index)] = ++counter; + } + } // end of namespace impl Index: oln/basics1d.hh --- oln/basics1d.hh (revision 12) +++ oln/basics1d.hh (working copy) @@ -6,5 +6,6 @@ # include <oln/core/1d/size1d.hh> # include <oln/core/1d/point1d.hh> +# include <oln/core/1d/image1d.hh> #endif // ! OLENA_BASICS1D_HH Index: oln/core/abstract/image_with_data.hh --- oln/core/abstract/image_with_data.hh (revision 12) +++ oln/core/abstract/image_with_data.hh (working copy) @@ -97,6 +97,14 @@ return this->data_->set(p, v); } + /*! \brief True if the image contains data. + */ + bool has_data() const + { + return data_ != 0; + } + + protected: /*! \brief Constructor (protected) with no memory allocation for @@ -107,6 +115,7 @@ data_ = 0; } + /*! \brief Constructor (protected) with memory allocation for ** data. */ @@ -123,7 +132,6 @@ this->data_ = rhs.data_; } - /*! \brief Data storage. */ mlc::tracked_ptr<oln_value_container_type(E)> data_; Index: oln/core/1d/image1d.hh --- oln/core/1d/image1d.hh (revision 0) +++ oln/core/1d/image1d.hh (revision 0) @@ -0,0 +1,101 @@ +#ifndef OLENA_CORE_IMAGE1D_HH +# define OLENA_CORE_IMAGE1D_HH + +# include <mlc/traits.hh> + +# include <oln/core/abstract/image_with_data.hh> +# include <oln/core/1d/array1d.hh> + +/*! \namespace oln +** \brief oln namespace. +*/ +namespace oln { + + + // fwd decl + template <typename T> class image1d; + + // category decl + template <typename T> struct category_type< image1d<T> > { typedef cat::image ret; }; + + + /*! \class props< abstract::image, image1d<T> > + ** + ** Properties of common 1D images. Specialization of props<abstraction,type>. + ** Parameter T is the type of pixel values. + ** + ** \see image1d<T>, props<category,type> + */ + + template <typename T> + struct props < cat::image, image1d<T> > : public default_props < cat::image > + { + typedef mlc::no_type delegated_type; + + typedef size1d size_type; + typedef point1d point_type; + typedef T value_type; + + // please note that value_storage_type means data_type + // since image1d is an image_with_data + typedef mlc_encoding_type(T) value_storage_type; + + // please note that value_container_type means + // data_container_type (or value_storage_container_type) + // FIXME: find a better name... + typedef array1d<value_storage_type> value_container_type; + + // tags + typedef tag::readwrite constness_tag; + + // functions + + template <typename U> + struct ch_value_type + { + typedef image1d<U> ret; + }; + + }; + + + + /*! \class image1d<T> + ** + ** Common class for 1D images. Pixels values are stored in memory. + ** FIXME: give details about other properties (border, etc.) + ** + ** Parameter T is the type of pixel values. + */ + + template <typename T> + class image1d : public abstract::image_with_data< image1d<T> > + { + public: + + typedef abstract::image_with_data< image1d<T> > super_type; + + image1d() + { + this->exact_ptr = this; + } + + image1d(coord_t nindices) : + super_type(size1d(nindices)) + { + this->exact_ptr = this; + } + + image1d(image1d& rhs) : + super_type(rhs) + { + this->exact_ptr = this; + } + + }; + + +} // end of namespace oln + + +#endif // ! OLENA_CORE_IMAGE1D_HH Index: oln/core/1d/size1d.hh --- oln/core/1d/size1d.hh (revision 12) +++ oln/core/1d/size1d.hh (working copy) @@ -12,7 +12,8 @@ struct size1d : public abstract::size< size1d > { size1d() : - nindices_(0) + nindices_(0), + border_(0) {} size1d(coord_t nindices_) : Index: oln/core/2d/image2d.hh --- oln/core/2d/image2d.hh (revision 12) +++ oln/core/2d/image2d.hh (working copy) @@ -109,11 +109,6 @@ // FIXME: idem with abstract::image2d<E> (?) - bool has_data() const // FIXME: should be defined in abstract::something_image... - { - return this->data_ != 0; - } - };
20 years, 2 months
1
0
0
0
proto-1.0 12: Add Array1d and Array3d
by Simon Odou
Index: ChangeLog from Simon Odou <simon(a)lrde.epita.fr> * oln/core/1d/array1d.hh: New. * oln/core/2d/array2d.hh: Fix a missing destructor. * oln/core/3d/array3d.hh: New. 1d/array1d.hh | 156 +++++++++++++++++++++++++++++++++++++++++++ 2d/array2d.hh | 8 +- 3d/array3d.hh | 208 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 371 insertions(+), 1 deletion(-) Index: oln/core/1d/array1d.hh --- oln/core/1d/array1d.hh (revision 0) +++ oln/core/1d/array1d.hh (revision 0) @@ -0,0 +1,156 @@ +#ifndef OLENA_CORE_1D_ARRAY1D_HH +# define OLENA_CORE_1D_ARRAY1D_HH + + +# include <oln/core/abstract/data_storage.hh> +# include <oln/core/1d/size1d.hh> +# include <oln/core/1d/point1d.hh> + +namespace oln { + + + template <typename T> struct array1d; + template <typename T> + struct category_type< array1d<T> > { typedef cat::data_storage ret; }; + + + template <typename T> + struct props < cat::data_storage, array1d<T> > // FIXME: add inheritance + { + typedef size1d size_type; + typedef point1d point_type; + typedef T data_type; + }; + + + template <typename T> + class array1d : public abstract::data_storage< array1d<T> > + { + + public: + + array1d() : + buffer_(0), + size_() + { + this->exact_ptr = this; + invariant_(); + } + + // w/o impl + array1d(const array1d&); + void operator=(const array1d&); + + + array1d(const size1d& s) : + buffer_(0), + size_() + { + this->exact_ptr = this; + this->resize(s); + } + + ~array1d() + { + this->impl_clear_data(); + } + + bool impl_has_data() const + { + invariant_(); + return buffer_ != 0; + } + + void impl_clear_data() + { + invariant_(); + if (this->has_data()) + { + // buffer + delete[] buffer_; + buffer_ = 0; + // size + size_ = size1d(); + } + invariant_(); + } + + const size1d& size() const + { + return size_; + } + + void impl_resize(const size1d& s) + { + precondition(s.nindices() > 0 and + s.border() >= 0); + invariant_(); + this->clear_data(); + size_ = s; + size_t nelts_eff = size_.nindices() + 2 * size_.border(); + buffer_ = new T[nelts_eff]; + invariant_(); + } + + unsigned long impl_npoints() const + { + return size_.npoints(); + } + + bool impl_hold(const point1d& p) const + { + return + p.index() >= 0 and + p.index() < size_.nindices(); + } + + bool impl_hold_large(const point1d& p) const + { + return + p.index() >= - size_.border() and + p.index() < size_.nindices() + size_.border(); + } + + const T impl_get(const point1d& p) const + { + invariant_(); + return buffer_[p.index()]; + } + + void impl_set(const point1d& p, const T& v) + { + invariant_(); + buffer_[p.index()] = v; + } + + void impl_set_data(const T& v) + { + invariant_(); + const size_t len = size_.nindices() + 2 * size_.border(); + T* p = buffer_; + for (size_t i = 0; i < len; ++i) + *p++ = v; + } + + private: + + T* buffer_; + size1d size_; + + void invariant_() const + { + invariant((buffer_ != 0 and + size_.nindices() > 0 and + size_.border() >= 0) + or + (buffer_ == 0 and + size_.nindices() == 0 and + size_.border() == 0)); + } + + }; + +} // end of namespace oln + + +#endif // ! OLENA_CORE_1D_ARRAY1D_HH Index: oln/core/2d/array2d.hh --- oln/core/2d/array2d.hh (revision 11) +++ oln/core/2d/array2d.hh (working copy) @@ -10,7 +10,8 @@ template <typename T> struct array2d; - template <typename T> struct category_type< array2d<T> > { typedef cat::data_storage ret; }; + template <typename T> + struct category_type< array2d<T> > { typedef cat::data_storage ret; }; template <typename T> @@ -51,6 +52,11 @@ this->resize(s); } + ~array2d() + { + this->impl_clear_data(); + } + bool impl_has_data() const { invariant_(); Index: oln/core/3d/array3d.hh --- oln/core/3d/array3d.hh (revision 0) +++ oln/core/3d/array3d.hh (revision 0) @@ -0,0 +1,208 @@ +#ifndef OLENA_CORE_3D_ARRAY3D_HH +# define OLENA_CORE_3D_ARRAY3D_HH + + +# include <oln/core/abstract/data_storage.hh> +# include <oln/core/3d/size3d.hh> +# include <oln/core/3d/point3d.hh> + +namespace oln { + + + template <typename T> struct array3d; + template <typename T> + struct category_type< array3d<T> > { typedef cat::data_storage ret; }; + + + template <typename T> + struct props < cat::data_storage, array3d<T> > // FIXME: add inheritance + { + typedef size3d size_type; + typedef point3d point_type; + typedef T data_type; + }; + + + template <typename T> + class array3d : public abstract::data_storage< array3d<T> > + { + + public: + + array3d() : + buffer_(0), + array_(0), + array2_(0), + size_() + { + this->exact_ptr = this; + invariant_(); + } + + // w/o impl + array3d(const array3d&); + void operator=(const array3d&); + + + array3d(const size3d& s) : + buffer_(0), + array_(0), + array2_(0), + size_() + { + this->exact_ptr = this; + this->resize(s); + } + + ~array3d() + { + this->impl_clear_data(); + } + + bool impl_has_data() const + { + invariant_(); + return buffer_ != 0; + } + + void impl_clear_data() + { + invariant_(); + if (this->has_data()) + { + // buffer + delete[] buffer_; + buffer_ = 0; + // array2 + delete[] array2_; + array2_ = 0; + // array + array_ -= size_.border(); + delete[] array_; + array_ = 0; + // size + size_ = size3d(); + } + invariant_(); + } + + const size3d& size() const + { + return size_; + } + + void impl_resize(const size3d& s) + { + precondition(s.nslices() > 0 and + s.nrows() > 0 and + s.ncols() > 0 and + s.border() >= 0); + invariant_(); + this->clear_data(); + size_ = s; + + size_t nslices_eff = size_.nslices() + 2 * size_.border(); + size_t nrows_eff = size_.nrows() + 2 * size_.border(); + size_t ncols_eff = size_.ncols() + 2 * size_.border(); + size_t nelts_eff = nslices_eff * nrows_eff * ncols_eff; + + buffer_ = new T[nelts_eff]; + array_ = new T**[nslices_eff]; + array2_ = new T*[nslices_eff * nrows_eff]; + + T* buf = buffer_ + size_.border(); + for (size_t slice = 0; slice < nslices_eff; ++slice) + { + T** a2 = array2_ + slice * nrows_eff; + array[slice] = a2 + size_.border(); + for (size_t row = 0; row < nrows_eff; ++row) + { + a2[row] = buf; + buf += ncols_eff; + } + } + array_ += size_.border(); + invariant_(); + } + + unsigned long impl_npoints() const + { + return size_.npoints(); + } + + bool impl_hold(const point3d& p) const + { + return + p.slice() >= 0 and + p.slice() < size_.nslices() and + p.row() >= 0 and + p.row() < size_.nrows() and + p.col() >= 0 and + p.col() < size_.ncols(); + } + + bool impl_hold_large(const point3d& p) const + { + return + p.slice() >= - size_.border() and + p.slice() < size_.nslices() + size_.border() and + p.row() >= - size_.border() and + p.row() < size_.nrows() + size_.border() and + p.col() >= - size_.border() and + p.col() < size_.ncols() + size_.border(); + } + + const T impl_get(const point3d& p) const + { + invariant_(); + return array_[p.slice()][p.row()][p.col()]; + } + + void impl_set(const point3d& p, const T& v) + { + invariant_(); + array_[p.slice()][p.row()][p.col()] = v; + } + + void impl_set_data(const T& v) + { + invariant_(); + const size_t nslices_eff = size_.nslices() + 2 * size_.border(); + const size_t nrows_eff = size_.nrows() + 2 * size_.border(); + const size_t ncols_eff = size_.ncols() + 2 * size_.border(); + const size_t len = nslices_eff * nrows_eff * ncols_eff; + T* p = buffer_; + for (size_t i = 0; i < len; ++i) + *p++ = v; + } + + private: + + T* buffer_; + T** array2_; + T*** array_; + size3d size_; + + void invariant_() const + { + invariant((buffer_ != 0 and + array_ != 0 and + size_.nslices() > 0 and + size_.nrows() > 0 and + size_.ncols() > 0 and + size_.border() >= 0) + or + (buffer_ == 0 and + array_ == 0 and + size_.nslices() == 0 and + size_.nrows() == 0 and + size_.ncols() == 0 and + size_.border() == 0)); + } + + }; + +} // end of namespace oln + + +#endif // ! OLENA_CORE_3D_ARRAY3D_HH
20 years, 2 months
2
1
0
0
proto-1.0 11: Add Size1d and Size3d
by Simon Odou
Index: ChangeLog from Simon Odou <simon(a)lrde.epita.fr> * oln/basics1d.hh: Add size1d include. * oln/core/1d/size1d.hh: New. * oln/core/2d/size2d.hh: Fix a missing "this". * oln/core/3d/size3d.hh: New. * oln/basics3d.hh: Add size3d include. ChangeLog | 7 ++++ oln/basics1d.hh | 1 oln/basics3d.hh | 1 oln/core/1d/size1d.hh | 67 ++++++++++++++++++++++++++++++++++++++ oln/core/2d/size2d.hh | 3 + oln/core/3d/size3d.hh | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 164 insertions(+), 1 deletion(-) Index: ChangeLog --- ChangeLog (revision 10) +++ ChangeLog (working copy) @@ -1,5 +1,12 @@ 2005-01-21 Simon Odou <simon(a)lrde.epita.fr> + * oln/basics1d.hh: Add size1d include. + * oln/core/1d/size1d.hh: New. + * oln/core/3d/size3d.hh: New. + * oln/basics3d.hh: Add size3d include. + +2005-01-21 Simon Odou <simon(a)lrde.epita.fr> + * oln/basics1d.hh: New. * oln/core/1d/point1d.hh: New. * oln/core/3d: New. Index: oln/basics1d.hh --- oln/basics1d.hh (revision 10) +++ oln/basics1d.hh (working copy) @@ -4,6 +4,7 @@ # include <oln/basics.hh> +# include <oln/core/1d/size1d.hh> # include <oln/core/1d/point1d.hh> #endif // ! OLENA_BASICS1D_HH Index: oln/core/1d/size1d.hh --- oln/core/1d/size1d.hh (revision 0) +++ oln/core/1d/size1d.hh (revision 0) @@ -0,0 +1,67 @@ +#ifndef OLENA_CORE_1D_SIZE1D_HH +# define OLENA_CORE_1D_SIZE1D_HH + +# include <ostream> + +# include <oln/core/abstract/size.hh> +# include <oln/core/coord.hh> + +namespace oln { + + + struct size1d : public abstract::size< size1d > + { + size1d() : + nindices_(0) + {} + + size1d(coord_t nindices_) : + nindices_(nindices_), + border_(2) // FIXME: 2! + {} + + size1d(coord_t nindices_, coord_t border_) : + nindices_(nindices_), + border_(border_) + {} + + size1d(const size1d& rhs) : + nindices_(rhs.nindices_), + border_(rhs.border_) + {} + + void operator=(const size1d& rhs) + { + this->nindices_ = rhs.nindices_; + this->border_ = rhs.border_; + } + + unsigned long impl_npoints() const + { + return (unsigned long)nindices_; + } + + bool impl_eq(const size1d& rhs) const + { + return this->nindices_ == rhs.nindices_; + } + + const coord_t nindices() const { return nindices_; } + const coord_t border() const { return border_; } + + protected: + coord_t nindices_, border_; + }; + + +} // end of namespace oln + + +std::ostream& operator<<(std::ostream& ostr, const oln::size1d& s) +{ + return ostr << "(nindices=" << s.nindices() + << ", border=" << s.border() << ")"; +} + + +#endif // ! OLENA_CORE_1D_SIZE1D_HH Index: oln/core/2d/size2d.hh --- oln/core/2d/size2d.hh (revision 10) +++ oln/core/2d/size2d.hh (working copy) @@ -49,7 +49,8 @@ bool impl_eq(const size2d& rhs) const { - return nrows_ == rhs.nrows_ and ncols_ == rhs.ncols_; + return this->nrows_ == rhs.nrows_ and + this->ncols_ == rhs.ncols_; } const coord_t nrows() const { return nrows_; } Index: oln/core/3d/size3d.hh --- oln/core/3d/size3d.hh (revision 0) +++ oln/core/3d/size3d.hh (revision 0) @@ -0,0 +1,86 @@ +#ifndef OLENA_CORE_3D_SIZE3D_HH +# define OLENA_CORE_3D_SIZE3D_HH + +# include <ostream> + +# include <oln/core/abstract/size.hh> +# include <oln/core/coord.hh> + +namespace oln { + + + struct size3d : public abstract::size< size3d > + { + size3d() : + nslices_(0), + nrows_(0), + ncols_(0), + border_(0) + {} + + size3d(coord_t nslices_, coord_t nrows_, coord_t ncols_) : + nslices_(nslices_), + nrows_(nrows_), + ncols_(ncols_), + border_(2) // FIXME: 2! + {} + + size3d(coord_t nslices_, coord_t nrows_, coord_t ncols_, coord_t border_) : + nslices_(nslices_), + nrows_(nrows_), + ncols_(ncols_), + border_(border_) + {} + + size3d(const size3d& rhs) : + nslices_(rhs.nslices_), + nrows_(rhs.nrows_), + ncols_(rhs.ncols_), + border_(rhs.border_) + {} + + void operator=(const size3d& rhs) + { + this->nslices_ = rhs.nslices_; + this->nrows_ = rhs.nrows_; + this->ncols_ = rhs.ncols_; + this->border_ = rhs.border_; + } + + unsigned long impl_npoints() const + { + return (unsigned long)nslices_ * + (unsigned long)nslices_ * + (unsigned long)ncols_; + } + + bool impl_eq(const size3d& rhs) const + { + return this->nslices_ == rhs.nslices_ and + this->nrows_ == rhs.nrows_ and + this->ncols_ == rhs.ncols_; + } + + const coord_t nslices() const { return nslices_; } + const coord_t nrows() const { return nrows_; } + const coord_t ncols() const { return ncols_; } + const coord_t border() const { return border_; } + + protected: + coord_t nslices_, nrows_, ncols_, border_; + }; + + +} // end of namespace oln + + +std::ostream& operator<<(std::ostream& ostr, const oln::size3d& s) +{ + return ostr << "(nslices=" << s.nslices() + << ", nrows=" << s.nrows() + << ", ncols=" << s.ncols() + << ", border=" << s.border() << ")"; +} + + +#endif // ! OLENA_CORE_3D_SIZE3D_HH Index: oln/basics3d.hh --- oln/basics3d.hh (revision 10) +++ oln/basics3d.hh (working copy) @@ -4,6 +4,7 @@ # include <oln/basics.hh> +# include <oln/core/3d/size3d.hh> # include <oln/core/3d/point3d.hh> #endif // ! OLENA_BASICS3D_HH
20 years, 2 months
2
1
0
0
← Newer
1
2
3
Older →
Jump to page:
1
2
3
Results per page:
10
25
50
100
200