
https://svn.lrde.epita.fr/svn/oln/trunk/olena Index: ChangeLog from Roland Levillain <roland@lrde.epita.fr> Fix fwd_viter_lut and rgb8. * oln/value/color/rgb.hh (rgb_<T>::operator==): Make it const. * oln/core/gen/fwd_viter_lut.hh (operator rvalue_type, print): Fix these methods. * tests/morphers/with_lut.cc: Test oln::fwd_viter_lut. oln/core/gen/fwd_viter_lut.hh | 11 ++++++----- oln/value/color/rgb.hh | 4 ++-- tests/morphers/with_lut.cc | 30 ++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 7 deletions(-) Index: tests/morphers/with_lut.cc --- tests/morphers/with_lut.cc (revision 699) +++ tests/morphers/with_lut.cc (working copy) @@ -27,6 +27,8 @@ /// Test the look-up table morpher. +#include <list> + #include <oln/basics2d.hh> #include <oln/morpher/with_lut.hh> #include <oln/value/color/rgb.hh> @@ -144,6 +146,34 @@ assert(ima_with_lut(p) == red); assert(ima_with_lut.at(1, 2) == red); + + // Check fwd_viter_lut. + oln_type_of_(image_with_lut_t, fwd_viter) fv(ima_with_lut.lut()); + std::list<rgb8> fwd_values; + std::cout << "values of lut (fwd) =" << std::endl; + for_all (fv) + { + // Push the values to the *back* of the list. + fwd_values.push_back(fv); + std::cout << " " << fv << std::endl; + } + +// FIXME: To be enabled later. + +// // Check bkd_viter_lut. +// oln_type_of_(image_with_lut_t, bkd_viter) bv(ima_with_lut.lut()); +// std::list<rgb8> bkd_values; +// std::cout << "values of lut (bkd) =" << std::endl; +// for_all (bv) +// { +// // Push the values to the *front* of the list. +// bkd_values.push_front(bv); +// std::cout << " " << bv << std::endl; +// } +// // Compare the two lists. +// assert (fwd_values == bkd_values); + + // FIXME: To be enabled later, when oln::level::fill is specialized // for abstract::mutable_image_being_value_wise_random_accessible. #if 0 Index: oln/core/gen/fwd_viter_lut.hh --- oln/core/gen/fwd_viter_lut.hh (revision 699) +++ oln/core/gen/fwd_viter_lut.hh (working copy) @@ -117,14 +117,14 @@ fwd_viter_lut<Lut>::operator typename fwd_viter_lut<Lut>::rvalue_type() const { precondition(this->is_valid()); - return this->i_->second; + return this->i_->first; } template <typename Lut> void fwd_viter_lut<Lut>::print(std::ostream& ostr) const { precondition(this->is_valid()); - ostr << "fwd_viter_lut<Lut> { value = " << this->i_->second << " }"; + ostr << "fwd_viter_lut<Lut> { value = " << this->i_->first << " }"; } @@ -177,6 +177,7 @@ { typedef mutable_fwd_viter_lut<Lut> self_t; typedef stc_get_super(self_t) super_t; + typedef oln_type_of(self_t, lut_iter) lut_iter_t; typedef typename Lut::orig_value_type orig_value_t; typedef typename Lut::new_value_type new_value_t; @@ -237,7 +238,7 @@ mutable_fwd_viter_lut<Lut>::operator typename mutable_fwd_viter_lut<Lut>::lvalue_type() { precondition(this->is_valid()); - return this->i_->second; + return this->i_->first; } template <typename Lut> @@ -250,7 +251,7 @@ new_value_t cur_new_val = this->i_->first; // Shortcuts. - typedef typename Lut::iterator new_iter_t; + typedef lut_iter_t new_iter_t; typedef std::pair<new_iter_t, new_iter_t> new_iter_range_t; // Current ``original'' value(s) associated to the next ``new'' value RHS. @@ -282,7 +283,7 @@ { precondition(this->is_valid()); ostr - << "mutable_fwd_viter_lut<Lut> { value = " << this->i_->second << " }"; + << "mutable_fwd_viter_lut<Lut> { value = " << this->i_->first << " }"; } Index: oln/value/color/rgb.hh --- oln/value/color/rgb.hh (revision 699) +++ oln/value/color/rgb.hh (working copy) @@ -65,7 +65,7 @@ /// Op==. template <typename U> - bool operator==(const rgb_<U>& rhs); + bool operator==(const rgb_<U>& rhs) const; T red() const; T& red(); @@ -129,7 +129,7 @@ template <typename T> template <typename U> - bool rgb_<T>::operator==(const rgb_<U>& rhs) + bool rgb_<T>::operator==(const rgb_<U>& rhs) const { return val_[0] == rhs.red() and