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 \