
Index: ChangeLog from Nicolas Ballas <ballas@lrde.epita.fr> Fix bug on sparse image. * oln/core/encode/sparse_encode.hh: New. * oln/core/sparse/sparse_image.hh: sparse_image class working now encode/sparse_encode.hh | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ sparse/sparse_image.hh | 8 +++--- 2 files changed, 62 insertions(+), 4 deletions(-) Index: oln/core/encode/sparse_encode.hh --- oln/core/encode/sparse_encode.hh (revision 0) +++ oln/core/encode/sparse_encode.hh (revision 0) @@ -0,0 +1,58 @@ +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 EPITA +// Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef SPARSE_ENCODE_HH_ +# define SPARSE_ENCODE_HH_ + +# include <oln/core/concept/image.hh> + +# include <oln/core/sparse/sparse_image.hh> + +namespace oln +{ + + /*! + ** encode a generic image to a sparse image format + ** + ** @param input an Image + ** + ** @return a sparse image + */ + template <typename I> + sparse_image<typename I::point, typename I::value> + sparse_encode(const Image<I> input) + { + sparse_image<typename I::point, typename I::value> output; + typename I::piter p (input.points()); + // typename I::coord len = 1; + typename I::point rstart; /*!< range pointstart */ + typename I::value rvalue; /*!< range value */ + } +} + +#endif /* !SPARSE_ENCODE_HH_ */ Index: oln/core/sparse/sparse_image.hh --- oln/core/sparse/sparse_image.hh (revision 878) +++ oln/core/sparse/sparse_image.hh (working copy) @@ -133,9 +133,9 @@ typename sparse_image<P, T>::rvalue sparse_image<P, T>::impl_read(const sparse_image<P, T>::psite& ps) const { - typename std::map<point, value>::const_iterator irun; + typename std::map<point, std::vector<value> >::const_iterator irun; - irun = this->data_->second.find(ps.start_); + irun.operator= (this->data_->second.find(ps.start_)); assert(irun != this->data_->second.end() && ps.index_ < this->data_->first.range_len_(ps.start_)); return irun->second[ps.index_]; } @@ -144,9 +144,9 @@ typename sparse_image<P, T>::lvalue sparse_image<P, T>::impl_read_write(const sparse_image<P, T>::psite& ps) { - typename std::map<point, value>::const_iterator irun; + typename std::map<point, std::vector<value> >::iterator irun; - irun = this->data_->second.find(ps.start_); + irun.operator= (this->data_->second.find(ps.start_)); assert(irun != this->data_->second.end() && ps.index_ < this->data_->first.range_len_(ps.start_)); return irun->second[ps.index_]; }