https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Roland Levillain <roland(a)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 \
2006-09-27 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add oln debug print and a "classical" image abstraction.
* oln/debug/print.hh: New.
* oln/core/abstract/image/hybrid/classical.hh: New.
* oln/core/abstract/image/hierarchies.hh
(image_hybrid_hierarchy_wrt_classical): New.
(include): Update.
* oln/Makefile.am (nobase_oln_HEADERS): Update.
Index: oln/debug/print.hh
===================================================================
--- oln/debug/print.hh (revision 0)
+++ oln/debug/print.hh (revision 0)
@@ -0,0 +1,96 @@
+// 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.
+
+#ifndef OLN_DEBUG_PRINT_HH
+# define OLN_DEBUG_PRINT_HH
+
+# include <iostream>
+# include <oln/core/abstract/image.hh>
+
+
+namespace oln
+{
+
+
+ namespace debug
+ {
+
+ /// Fwd decl.
+ template <typename I>
+ void print(const abstract::image<I>& input, std::ostream& ostr);
+
+
+ namespace impl
+ {
+
+ /// Generic version.
+ template <typename I>
+ void print(const abstract::image<I>& input, std::ostream& ostr)
+ {
+ oln_type_of(I, fwd_piter) p(input.topo());
+ for_all(p)
+ ostr << p.to_point() << ':' << ima(p) << ' ';
+ }
+
+
+ /// Version for classical 2D images.
+ template <typename I>
+ void print(const abstract::classical_2d_image<I>& input,
+ std::ostream& ostr)
+ {
+ for (int row = input.pmin().row(); row <= input.pmax().row(); ++row)
+ {
+ for (int col = input.pmin().col(); col <= input.pmax().col(); ++col)
+ {
+ point2d p(row, col);
+ if (input.has(p))
+ ostr << input(p);
+ else
+ ostr << '-';
+ ostr << ' ';
+ }
+ ostr << std::endl;
+ }
+ }
+
+ } // end of namespace oln::debug::impl
+
+
+ /// Facade.
+ template <typename I>
+ void print(const abstract::image<I>& input, std::ostream& ostr)
+ {
+ impl::print(input.exact(), ostr);
+ }
+
+
+ } // end of namespace oln::debug
+
+} // end of namespace oln
+
+
+#endif // ! OLN_DEBUG_PRINT_HH
Index: oln/core/abstract/image/hybrid/classical.hh
===================================================================
--- oln/core/abstract/image/hybrid/classical.hh (revision 0)
+++ oln/core/abstract/image/hybrid/classical.hh (revision 0)
@@ -0,0 +1,95 @@
+// Copyright (C) 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_CORE_ABSTRACT_IMAGE_HYBRID_CLASSICAL_HH
+# define OLN_CORE_ABSTRACT_IMAGE_HYBRID_CLASSICAL_HH
+
+# include <oln/core/abstract/image.hh>
+
+# include <oln/core/abstract/image/dimension/2d.hh>
+# include <oln/core/abstract/image/bbox/hierarchy.hh>
+# include <oln/core/abstract/image/accessibility/hierarchy.hh>
+
+
+namespace oln
+{
+
+ namespace abstract
+ {
+
+ template <typename E>
+ struct classical_image
+ : public virtual abstract::image_having_bbox<E>,
+ public virtual abstract::image_being_random_accessible<E>
+ {
+ protected:
+ classical_image()
+ {}
+ };
+
+ template <typename E>
+ struct classical_2d_image
+ : public virtual abstract::classical_image<E>,
+ public virtual abstract::image2d<E>
+ {
+ protected:
+ classical_2d_image()
+ {}
+ };
+
+ } // end of namespace oln::abstract
+
+
+ /// 2-D case.
+ template <typename E>
+ struct case_< image_hybrid_hierarchy_wrt_classical, E, 1 > :
+ where_< mlc::and_list_< mlc::eq_< oln_type_of(E, grid), oln::grid2d >,
+ mlc::eq_< oln_deduce_type_of(E, topo, is_random_accessible), mlc::true_ >,
+ mlc::neq_< oln_deduce_type_of(E, topo, bbox), mlc::not_found >
+ >
+ >
+ {
+ typedef abstract::classical_2d_image<E> ret;
+ };
+
+
+ /// General case.
+ template <typename E>
+ struct case_< image_hybrid_hierarchy_wrt_classical, E, 2 > :
+ where_< mlc::and_< mlc::eq_< oln_deduce_type_of(E, topo, is_random_accessible), mlc::true_ >,
+ mlc::neq_< oln_deduce_type_of(E, topo, bbox), mlc::not_found >
+ >
+ >
+ {
+ typedef abstract::classical_image<E> ret;
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_ABSTRACT_IMAGE_HYBRID_CLASSICAL_HH
Index: oln/core/abstract/image/hierarchies.hh
===================================================================
--- oln/core/abstract/image/hierarchies.hh (revision 581)
+++ oln/core/abstract/image/hierarchies.hh (working copy)
@@ -41,33 +41,38 @@
typedef hierarchy<abstract::image, 5> image_hierarchy_wrt_accessibility;
typedef hierarchy<abstract::image, 6> image_hierarchy_wrt_mutability;
+ typedef hierarchy<abstract::image, 7> image_hybrid_hierarchy_wrt_classical;
+
// FIXME: To be continued.
#if 0
- typedef hierarchy<abstract::image, 7> image_hierarchy_wrt_value;
- typedef hierarchy<abstract::image, 8> image_hierarchy_wrt_data_retrieval;
+ typedef hierarchy<abstract::image, 8> image_hierarchy_wrt_value;
+ typedef hierarchy<abstract::image, 9> image_hierarchy_wrt_data_retrieval;
// ...
#endif
} // end of namespace oln
-// Hierarchy 1: topology w.r.t. dimension.
+// Hierarchy 1: image w.r.t. dimension.
# include <oln/core/abstract/image/dimension/hierarchy.hh>
-// Hierarchy 2: topology w.r.t. type of data.
+// Hierarchy 2: image w.r.t. type of data.
# include <oln/core/abstract/image/type/hierarchy.hh>
-// Hierarchy 3: topology w.r.t. neighborhood.
+// Hierarchy 3: image w.r.t. neighborhood.
# include <oln/core/abstract/image/neighborhood/hierarchy.hh>
-// Hierarchy 4: topology w.r.t. bounding box.
+// Hierarchy 4: image w.r.t. bounding box.
# include <oln/core/abstract/image/bbox/hierarchy.hh>
-// Hierarchy 5: topology w.r.t. accessibility.
+// Hierarchy 5: image w.r.t. accessibility.
# include <oln/core/abstract/image/accessibility/hierarchy.hh>
-// // // Hierarchy 6: topology w.r.t. data mutability.
+// Hierarchy 6: image w.r.t. data mutability.
# include <oln/core/abstract/image/mutability/hierarchy.hh>
+// Hybrid hierarchy 7: image w.r.t. classical features.
+# include <oln/core/abstract/image/hybrid/classical.hh>
+
#endif // ! OLN_CORE_ABSTRACT_IMAGE_HIERARCHIES_HH
Index: oln/Makefile.am
===================================================================
--- oln/Makefile.am (revision 581)
+++ oln/Makefile.am (working copy)
@@ -41,6 +41,7 @@
core/abstract/image/dimension/3d.hh \
core/abstract/image/dimension/hierarchy.hh \
core/abstract/image/hierarchies.hh \
+ core/abstract/image/hybrid/classical.hh \
core/abstract/image/mutability/hierarchy.hh \
core/abstract/image/neighborhood/hierarchy.hh \
core/abstract/image/type/binary.hh \
@@ -94,6 +95,8 @@
core/typedefs.hh \
core/type.hh \
\
+ debug/print.hh \
+ \
morpher/internal/image_extension.hh \
\
morpher/add_neighborhood.hh \