
https://svn.lrde.epita.fr/svn/oln/trunk/olena Index: ChangeLog from Roland Levillain <roland@lrde.epita.fr> Add oln::level::fill(). * oln/level/fill.hh: New. * oln/Makefile.am (nobase_oln_HEADERS): Add level/fill.hh. * tests/fill.cc: New test. * tests/Makefile.am (AM_CXXFLAGS): Rename as... (CXXFLAGS): ...this. (check_PROGRAMS): Add fill. (fill_SOURCES): New. oln/Makefile.am | 2 + oln/level/fill.hh | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/Makefile.am | 16 +++++++-- tests/fill.cc | 46 +++++++++++++++++++++++++++ 4 files changed, 150 insertions(+), 3 deletions(-) Index: tests/Makefile.am --- tests/Makefile.am (revision 584) +++ tests/Makefile.am (working copy) @@ -3,12 +3,14 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/olena -I$(top_srcdir)/extended \ -I$(top_srcdir)/static -I$(top_srcdir)/metalic + # FIXME: Add # -# AM_CXXFLAGS = $(CXXFLAGS_STRICT) -ggdb +# AM_CXXFLAGS = $(CXXFLAGS_STRICT) $(CXXFLAGS_DEBUG) # # when oln.m4 is available in the distribution. -AM_CXXFLAGS = -O0 -ggdb +# Meanwhile, alter CXXFLAGS to turn off any optimization. +CXXFLAGS = -O0 -ggdb check_PROGRAMS = \ @@ -18,14 +20,22 @@ \ identity_morpher \ add_neighborhood_morpher \ - morphers + morphers \ + \ + fill +# Images and auxiliary structures. grid_SOURCES = grid.cc image_entry_SOURCES = image_entry.cc npoints_SOURCES = npoints.cc + # Morphers. identity_morpher_SOURCES = identity_morpher.cc add_neighborhood_morpher_SOURCES = add_neighborhood_morpher.cc morphers_SOURCES = morphers.cc +# Algorithms. +fill_SOURCES = fill.cc + + TESTS = $(check_PROGRAMS) Index: tests/fill.cc --- tests/fill.cc (revision 0) +++ tests/fill.cc (revision 0) @@ -0,0 +1,46 @@ +// Copyright (C) 2006 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. + +/// Test oln::level::fill. + +#include <cassert> +// FIXME: We should not include oln/basics2d.hh, but +// oln/core/2d/image2d.hh (and oln/core/2d/neigh2d.hh ?). +#include <oln/basics2d.hh> +#include <oln/level/fill.hh> + + +int +main() +{ + typedef oln::image2d<int> image_t; + image_t ima(3, 3); + oln::level::fill(ima, 51); + oln_type_of_(image_t, piter) p(ima.topo()); + for_all(p) + assert(ima(p) == 51); +} Index: oln/level/fill.hh --- oln/level/fill.hh (revision 0) +++ oln/level/fill.hh (revision 0) @@ -0,0 +1,89 @@ +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 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 OLN_LEVEL_FILL_HH +# define OLN_LEVEL_FILL_HH + +# include <mlc/assert.hh> +# include <mlc/is_a.hh> + +# include <oln/core/abstract/image.hh> +# include <oln/core/automatic/image_being_mutable.hh> + + +namespace oln +{ + + namespace ERROR + { + struct FIRST_ARGUMENT_OF_oln_level_fill_IS_NOT_MUTABLE; + } + + namespace level + { + + /// Fwd decl. + template <typename I> + void fill(abstract::image<I>& input, const oln_type_of(I, value)& val); + + + namespace impl + { + + /// Generic version. + template <typename I> + void fill(abstract::image_being_mutable<I>& input, + const oln_type_of(I, value)& val) + { + oln_type_of(I, piter) p(input.topo()); + for_all(p) + input(p) = val; + } + + } // end of namespace oln::level::fill + + + /// Facade. + template <typename I> + void fill(abstract::image<I>& input, const oln_type_of(I, value)& val) + { + // Precondition. + mlc::assert_< + mlc_is_a(I, abstract::image_being_mutable), + ERROR::FIRST_ARGUMENT_OF_oln_level_fill_IS_NOT_MUTABLE + >::check(); + + impl::fill(input.exact(), val); + } + + } // end of namespace oln::level + +} // end of namespace oln + + +#endif // ! OLN_LEVEL_FILL_HH Index: oln/Makefile.am --- oln/Makefile.am (revision 584) +++ oln/Makefile.am (working copy) @@ -112,6 +112,8 @@ \ debug/print.hh \ \ + level/fill.hh \ + \ morpher/internal/image_extension.hh \ \ morpher/add_neighborhood.hh \