
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena ChangeLog: 2008-02-13 Michel Pellegrin <pellegrin@lrde.epita.fr> Commit of personnal work in my sandbox. * sandbox/pellegrin/Makefile: New. * sandbox/pellegrin/first_test.cc: New. * sandbox/pellegrin/set/Makefile: New. * sandbox/pellegrin/set/multi_set.hh: New. * sandbox/pellegrin/set/test_set.cc: New. * sandbox/pellegrin/set/uni_set.hh: New. * sandbox/pellegrin/set: New. --- Makefile | 26 ++++++++ first_test.cc | 40 ++++++++++++ set/Makefile | 26 ++++++++ set/multi_set.hh | 176 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ set/test_set.cc | 47 ++++++++++++++ set/uni_set.hh | 176 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 491 insertions(+) Index: trunk/milena/sandbox/pellegrin/first_test.cc =================================================================== --- trunk/milena/sandbox/pellegrin/first_test.cc (revision 0) +++ trunk/milena/sandbox/pellegrin/first_test.cc (revision 1721) @@ -0,0 +1,40 @@ +// Copyright (C) 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. + +/*! \file sandbox/pellegrin/first_test.cc + * + * \brief My first test. + */ + +#include <mln/core/image2d.hh> + + +int main () +{ + mln::image2d<int> I; +} + Index: trunk/milena/sandbox/pellegrin/set/multi_set.hh =================================================================== --- trunk/milena/sandbox/pellegrin/set/multi_set.hh (revision 0) +++ trunk/milena/sandbox/pellegrin/set/multi_set.hh (revision 1721) @@ -0,0 +1,176 @@ +// Copyright (C) 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 __MULTI_SET_HH__ +# define __MULTI_SET_HH__ + +/*! \file sandbox/pellegrin/set/multi_set.hh + * + * \brief Definition of a point multi-set class. + */ + +# include <mln/core/internal/point_set_base.hh> +# include <mln/core/internal/set_of.hh> + + +namespace mln +{ + + /*! \brief Point set class. + * + * This is a mathematical multi-set of points. The + * parameter \p P shall be a Point type. + * + * \todo All. + */ + template <typename P> + class multi_set : public internal::point_set_base_< P, p_set<P> >, + private internal::set_of_<P> + { + typedef internal::set_of_<P> super_; + + public: + /// Forward Point_Iterator associated type. + typedef multi_set_fwd_piter_<P> fwd_piter; + /// Backward Point_Iterator associated type. + typedef multi_set_bkd_piter_<P> bkd_piter; + + /// Constructor. + multi_set(); + + /// Test is \p p belongs to this point set. + bool has(const P& p) const; + + /// Return the corresponding std::vector of points. + using super_::vect; + + /// Give the number of points. + std::size_t npoints() const; + + /// Insert a point \p p. + multi_set<P>& insert(const P& p); + + // FIXME : doesn't compile + // /// Remove a point \p p. + // p_set<P>& remove(P& p); + + /// Return the \p i-th point. + const P& operator[](unsigned i) const; + + /// Clear this set. + void clear(); + + /// Give the exact bounding box. + const box_<mln_point(P)>& bbox() const; + + protected: + + accu::bbox<P> bb_; + // FIXME: Add invariant bb_.is_valid() <=> npoints() != 0 + }; + + +# ifndef MLN_INCLUDE_ONLY + + template <typename P> + inline + multi_set<P>::multi_set() + { + } + + template <typename P> + inline + bool + multi_set<P>::has(const P& p) const + { + return this->super_::has(p); + } + + template <typename P> + inline + std::size_t + multi_set<P>::npoints() const + { + return this->super_::nelements(); + } + + template <typename P> + inline + multi_set<P>& + multi_set<P>::insert(const P& p) + { + this->super_::insert(p); + bb_.take(p); + return *this; + } + + + // FIXME : finish it. + // template <typename P> + // p_set<P>& + // p_set<P>::remove(P& p) + // { + // this->super_::remove(p); + // // FIXME: need to rebuild bb_ ? + // //bb_.untake(p); + // return *this; + // } + + template <typename P> + inline + const P& + multi_set<P>::operator[](unsigned i) const + { + mln_precondition(i < npoints()); + return this->super_::element(i); + } + + template <typename P> + inline + void + multi_set<P>::clear() + { + this->super_::clear(); + bb_.init(); + } + + template <typename P> + inline + const box_<mln_point(P)>& + multi_set<P>::bbox() const + { + mln_precondition(npoints() != 0); + return bb_.to_result(); + } + +# endif // ! MLN_INCLUDE_ONLY + +} // end of namespace mln + + +#endif // ! __MULTI_SET_HH__ Index: trunk/milena/sandbox/pellegrin/set/uni_set.hh =================================================================== --- trunk/milena/sandbox/pellegrin/set/uni_set.hh (revision 0) +++ trunk/milena/sandbox/pellegrin/set/uni_set.hh (revision 1721) @@ -0,0 +1,176 @@ +// Copyright (C) 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 __UNI_SET_HH__ +# define __UNI_SET_HH__ + +/*! \file sandbox/pellegrin/set/uni_set.hh + * + * \brief Definition of a point uni-set class. + */ + +# include <mln/core/internal/point_set_base.hh> +# include <mln/core/internal/set_of.hh> + + +namespace mln +{ + + /*! \brief Point set class. + * + * This is a mathematical uni-set of points (not a multi-set). The + * parameter \p P shall be a Point type. + * + * \todo All. + */ + template <typename P> + class uni_set : public internal::point_set_base_< P, p_set<P> >, + private internal::set_of_<P> + { + typedef internal::set_of_<P> super_; + + public: + /// Forward Point_Iterator associated type. + typedef uni_set_fwd_piter_<P> fwd_piter; + /// Backward Point_Iterator associated type. + typedef uni_set_bkd_piter_<P> bkd_piter; + + /// Constructor. + uni_set(); + + /// Test is \p p belongs to this point set. + bool has(const P& p) const; + + /// Return the corresponding std::vector of points. + using super_::vect; + + /// Give the number of points. + std::size_t npoints() const; + + /// Insert a point \p p. + uni_set<P>& insert(const P& p); + + // FIXME : doesn't compile + // /// Remove a point \p p. + // p_set<P>& remove(P& p); + + /// Return the \p i-th point. + const P& operator[](unsigned i) const; + + /// Clear this set. + void clear(); + + /// Give the exact bounding box. + const box_<mln_point(P)>& bbox() const; + + protected: + + accu::bbox<P> bb_; + // FIXME: Add invariant bb_.is_valid() <=> npoints() != 0 + }; + + +# ifndef MLN_INCLUDE_ONLY + + template <typename P> + inline + uni_set<P>::uni_set() + { + } + + template <typename P> + inline + bool + uni_set<P>::has(const P& p) const + { + return this->super_::has(p); + } + + template <typename P> + inline + std::size_t + uni_set<P>::npoints() const + { + return this->super_::nelements(); + } + + template <typename P> + inline + uni_set<P>& + uni_set<P>::insert(const P& p) + { + this->super_::insert(p); + bb_.take(p); + return *this; + } + + + // FIXME : finish it. + // template <typename P> + // p_set<P>& + // p_set<P>::remove(P& p) + // { + // this->super_::remove(p); + // // FIXME: need to rebuild bb_ ? + // //bb_.untake(p); + // return *this; + // } + + template <typename P> + inline + const P& + uni_set<P>::operator[](unsigned i) const + { + mln_precondition(i < npoints()); + return this->super_::element(i); + } + + template <typename P> + inline + void + uni_set<P>::clear() + { + this->super_::clear(); + bb_.init(); + } + + template <typename P> + inline + const box_<mln_point(P)>& + uni_set<P>::bbox() const + { + mln_precondition(npoints() != 0); + return bb_.to_result(); + } + +# endif // ! MLN_INCLUDE_ONLY + +} // end of namespace mln + + +#endif // ! __UNI_SET_HH__ Index: trunk/milena/sandbox/pellegrin/set/Makefile =================================================================== --- trunk/milena/sandbox/pellegrin/set/Makefile (revision 0) +++ trunk/milena/sandbox/pellegrin/set/Makefile (revision 1721) @@ -0,0 +1,26 @@ +All_warnings = -ansi -pedantic -Wabi -Wctor-dtor-privacy -Wnon-virtual-dtor \ + -Wreorder -Weffc++ -Wno-deprecated -Wstrict-null-sentinel \ + -Wno-non-template-friend -Wold-style-cast -Woverloaded-virtual \ + -Wno-pmf-conversions -Wsign-promo -fsyntax-only-pedantic-errors \ + -w -Wextra -Wall -Waddress -Waggregate-return -Wno-attributes \ + -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment -Wconversion \ + -Wno-deprecated-declarations -Wdisabled-optimization -Wno-div-by-zero \ + -Wno-endif-labels -Werror -Wfatal-errors -Wfloat-equal -Wformat \ + -Wformat=2 -Wno-format-extra-args -Wformat-nonliteral \ + -Wformat-security -Wformat-y2k -Wimplicit -Wimport -Wno-import \ + -Winit-self -Winline -Wno-invalid-offsetof -Winvalid-pch \ + -Wlarger-than-1 -Wunsafe-loop-optimizations -Wlong-long \ + -Wmissing-braces -Wmissing-field-initializers \ + -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn \ + -Wno-multichar -Wno-overflow -Woverlength-strings -Wpacked -Wpadded \ + -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type \ + -Wsequence-point -Wshadow -Wsign-compare -Wstack-protector \ + -Wstrict-aliasing -Wstrict-overflow -Wswitch -Wswitch-default \ + -Wswitch-enum -Wsystem-headers -Wtrigraphs -Wundef -Wuninitialized \ + -Wunknown-pragmas -Wno-pragmas -Wunreachable-code -Wunused \ + -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value \ + -Wunused-variable -Wvariadic-macros -Wvolatile-register-var \ + -Wwrite-strings \ + +all: + g++-4.2 -ansi -pedantic -I../.. first_test.cc -o first_test Index: trunk/milena/sandbox/pellegrin/set/test_set.cc =================================================================== --- trunk/milena/sandbox/pellegrin/set/test_set.cc (revision 0) +++ trunk/milena/sandbox/pellegrin/set/test_set.cc (revision 1721) @@ -0,0 +1,47 @@ +// Copyright (C) 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. + +/*! \file sandbox/pellegrin/set/test_set.cc + * + * \brief test my work on set. + */ + +#include <mln/core/image2d.hh> +#include "uni_set.hh" +#include "multi_set.hh" + + +int main () +{ + mln::image2d<value::int_u8> I = io::pgm::load ("../img/lena.pgm"); + mln::image2d<value::int_u8>::fwd_piter p (I.domain ()); + + for_all (p) + { + } +} + Index: trunk/milena/sandbox/pellegrin/Makefile =================================================================== --- trunk/milena/sandbox/pellegrin/Makefile (revision 0) +++ trunk/milena/sandbox/pellegrin/Makefile (revision 1721) @@ -0,0 +1,26 @@ +All_warnings = -ansi -pedantic -Wabi -Wctor-dtor-privacy -Wnon-virtual-dtor \ + -Wreorder -Weffc++ -Wno-deprecated -Wstrict-null-sentinel \ + -Wno-non-template-friend -Wold-style-cast -Woverloaded-virtual \ + -Wno-pmf-conversions -Wsign-promo -fsyntax-only-pedantic-errors \ + -w -Wextra -Wall -Waddress -Waggregate-return -Wno-attributes \ + -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment -Wconversion \ + -Wno-deprecated-declarations -Wdisabled-optimization -Wno-div-by-zero \ + -Wno-endif-labels -Werror -Wfatal-errors -Wfloat-equal -Wformat \ + -Wformat=2 -Wno-format-extra-args -Wformat-nonliteral \ + -Wformat-security -Wformat-y2k -Wimplicit -Wimport -Wno-import \ + -Winit-self -Winline -Wno-invalid-offsetof -Winvalid-pch \ + -Wlarger-than-1 -Wunsafe-loop-optimizations -Wlong-long \ + -Wmissing-braces -Wmissing-field-initializers \ + -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn \ + -Wno-multichar -Wno-overflow -Woverlength-strings -Wpacked -Wpadded \ + -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type \ + -Wsequence-point -Wshadow -Wsign-compare -Wstack-protector \ + -Wstrict-aliasing -Wstrict-overflow -Wswitch -Wswitch-default \ + -Wswitch-enum -Wsystem-headers -Wtrigraphs -Wundef -Wuninitialized \ + -Wunknown-pragmas -Wno-pragmas -Wunreachable-code -Wunused \ + -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value \ + -Wunused-variable -Wvariadic-macros -Wvolatile-register-var \ + -Wwrite-strings \ + +all: + g++-4.2 -ansi -pedantic -I../.. first_test.cc -o first_test