2005-04-08 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* oln/core/pw/logic.hh: New file.
* oln/core/abstract/image_valuedness.hh: New file.
* oln/core/abstract/image_vectorialness.hh: Remove.
* oln/core/abstract/image_typeness.hh: New file.
* oln/arith/logic.hh: New file.
* oln/core/pw/image.hh (image_vectorialness_type): Remove.
(for_all_p): Update.
* oln/core/pw/macros.hh (oln_pw_cmp_operator): New macro.
(oln_pw_cmp_operators): New macro.
* oln/core/pw/abstract/function.hh (operator!): New method.
* oln/core/pw/all.hh (oln/core/pw/logic.hh): New include.
* oln/core/pw/minus.hh: Cosmetic change.
* oln/core/pw/cmp.hh: Derive from pw::abstract::binary_function.
* oln/core/pw/logic.hh: New file.
* oln/core/properties.hh (image_typeness_type): New target.
(image_valuedness_type): Likewise.
(dummy_type): New target for temporary dummy tests.
* oln/core/abstract/image_constness.hh: Fix include.
* oln/core/abstract/image_neighbness.hh: Likewise.
* oln/core/abstract/image.hh (image_vectorialness_type): Remove.
* oln/core/abstract/image_operator.hh (abstract::image_operator):
New props and set_type_of for temporary dummy tests.
* oln/core/abstract/entry.hh (typeness::inheritance_switch): New
inheritance.
(valuedness::inheritance_switch): Likewise.
* oln/core/abstract/images.hh: Update.
* oln/core/abstract/image_with_data.hh: Cosmetic change.
* oln/core/1d/image1d.hh (image_vectorialness_type): Remove.
* oln/core/2d/image2d.hh: Likewise.
* oln/core/3d/image3d.hh: Likewise.
* oln/makefile.src: Update.
* oln/morpho/stat.hh (min, max): Change sig.
* oln/morpho/erosion.hh (morpho::impl::generic_erosion): Add
code for temporary dummy tests.
* oln/arith/ops.hh (operator+): Add erroneous overloading.
Index: oln/core/pw/image.hh
===================================================================
--- oln/core/pw/image.hh (revision 125)
+++ oln/core/pw/image.hh (working copy)
@@ -31,6 +31,7 @@
# include <mlc/any.hh>
# include <mlc/cmp.hh>
# include <oln/core/box.hh>
+# include <oln/core/abstract/image_typeness.hh>
# include <oln/core/abstract/entry.hh>
# include <oln/core/pw/abstract/function.hh>
@@ -130,7 +131,6 @@
// FIXME: AWFUL we do not know if it is 2d...
typedef is_a<abstract::image2d> image_dimension_type;
- typedef vectorialness_from_valuetype(value_type) image_vectorialness_type;
typedef fwd_piter2d piter_type;
typedef fwd_piter2d fwd_piter_type;
@@ -199,7 +199,7 @@
};
- /// Routine
+ /// Routine for_all_p.
template <typename F>
image_from_pw<F> for_all_p(const pw::abstract::function<F>& fun)
@@ -209,6 +209,16 @@
}
+ // FIXME: below, produce an error instead of correcting the client code (?)
+
+ /// Specialization of for_all_p (so that "for_all_p(p_value(ima)) == ima").
+
+ template <typename I>
+ const I& for_all_p(const pw::image<I>& pv)
+ {
+ return pv.ima.unbox();
+ }
+
/// Specialization of p_value (so that "p_value(for_all_p(fun)) == fun").
template <typename F>
@@ -220,13 +230,13 @@
+
+
/// Routine check.
- // FIXME: this should be an algorithm (pred = binary_image)
template <typename I>
- bool check(const abstract::image<I>& pred)
+ bool check(const abstract::binary_image<I>& pred)
{
- // FIXME: input should be binary
oln_type_of(I, fwd_piter) p(pred.size());
for_all (p)
if (! pred[p])
@@ -234,8 +244,6 @@
return true;
}
-
-
namespace pw {
/// Routine oln::pw::check.
@@ -243,13 +251,33 @@
template <typename F>
bool check(const pw::abstract::function<F>& pred)
{
- mlc::eq< oln_pw_value_type(F), bool >::ensure();
+ mlc::eq< oln_typeness_of(oln_pw_value_type(F)), typeness::binary_tag
>::ensure();
return oln::check(for_all_p(pred));
}
} // end of namespace oln::pw
+
+
+ /// Specialization of for_all_p that gives a compile-time error.
+
+ template <typename I>
+ void for_all_p(const abstract::image<I>&)
+ {
+ struct OLENA_ERROR__arg_of__for_all_p__should_not_be_an_image();
+ }
+
+ /// Specialization of for_all_p that gives a compile-time error.
+
+ template <typename P>
+ void for_all_p(const abstract::point<P>&)
+ {
+ struct OLENA_ERROR__arg_of__for_all_p__should_not_be_a_point();
+ }
+
+
+
} // end of namespace oln
Index: oln/core/pw/macros.hh
===================================================================
--- oln/core/pw/macros.hh (revision 125)
+++ oln/core/pw/macros.hh (working copy)
@@ -35,18 +35,18 @@
# define oln_pw_size_type(F) typename oln::pw::traits<F>::size_type
-// FIXME: rename
+// FIXME: rename?
# define oln_pw_operator(NAME, SYMBOL, TYPE) \
template <typename L> \
oln::pw::NAME<L, oln::pw::literal<TYPE> > \
operator SYMBOL (const oln::pw::abstract::function<L>& lhs, \
- TYPE value) \
+ const TYPE& value) \
{ \
return lhs SYMBOL oln::pw::literal<TYPE>(value); \
} \
template <typename R> \
oln::pw::NAME<oln::pw::literal<TYPE>, R> \
-operator SYMBOL (TYPE value, \
+operator SYMBOL (const TYPE& value, \
const oln::pw::abstract::function<R>& rhs) \
{ \
return oln::pw::literal<TYPE>(value) SYMBOL rhs; \
@@ -54,4 +54,32 @@
+// FIXME: rename?
+# define oln_pw_cmp_operator(NAME, SYMBOL, TYPE) \
+template <typename L> \
+oln::pw::cmp<L, oln::pw::literal<TYPE>, oln::pw::internal::NAME> \
+operator SYMBOL (const oln::pw::abstract::function<L>& lhs, \
+ const TYPE& value) \
+{ \
+ return lhs SYMBOL oln::pw::literal<TYPE>(value); \
+} \
+template <typename R> \
+oln::pw::cmp<oln::pw::literal<TYPE>, R, oln::pw::internal::NAME> \
+operator SYMBOL (const TYPE& value, \
+ const oln::pw::abstract::function<R>& rhs) \
+{ \
+ return oln::pw::literal<TYPE>(value) SYMBOL rhs; \
+}
+
+
+// FIXME: rename?
+# define oln_pw_cmp_operators(TYPE) \
+oln_pw_cmp_operator(eq, ==, TYPE) \
+oln_pw_cmp_operator(neq, !=, TYPE) \
+oln_pw_cmp_operator(geq, >=, TYPE) \
+oln_pw_cmp_operator(leq, <=, TYPE) \
+oln_pw_cmp_operator(g, >, TYPE) \
+oln_pw_cmp_operator(l, <, TYPE)
+
+
#endif // ! OLENA_CORE_PW_MACROS_HH
Index: oln/core/pw/abstract/function.hh
===================================================================
--- oln/core/pw/abstract/function.hh (revision 125)
+++ oln/core/pw/abstract/function.hh (working copy)
@@ -47,9 +47,9 @@
}
template <typename L, typename R> struct minus;
template <typename T> struct literal;
+ template <typename F> struct not_;
-
template <typename E>
struct traits < abstract::function<E> >
{
@@ -87,7 +87,8 @@
return this->exact().impl_hold_large(p);
}
- minus< literal<value_type>, E> operator-() const;
+ minus<literal<value_type>, E> operator-() const;
+ not_<E> operator!() const;
protected:
function() {}
Index: oln/core/pw/all.hh
===================================================================
--- oln/core/pw/all.hh (revision 125)
+++ oln/core/pw/all.hh (working copy)
@@ -34,13 +34,14 @@
# include <oln/core/pw/literal.hh>
# include <oln/core/pw/cmp.hh>
+# include <oln/core/pw/logic.hh>
# include <oln/core/pw/plus.hh>
# include <oln/core/pw/minus.hh>
# include <oln/core/pw/times.hh>
# include <oln/core/pw/div.hh>
-// FIXME: not xor mod...
+// FIXME: xor mod...
#endif // ! OLENA_CORE_PW_ALL_HH
Index: oln/core/pw/minus.hh
===================================================================
--- oln/core/pw/minus.hh (revision 125)
+++ oln/core/pw/minus.hh (working copy)
@@ -77,12 +77,12 @@
};
- // FIXME: uncomment?
+ // impl of abstract::function<E>::operator-()
namespace abstract {
template <typename E>
- minus< literal<oln_pw_value_type(E)>, E>
+ minus<literal<oln_pw_value_type(E)>, E>
function<E>::operator-() const
{
typedef literal<oln_pw_value_type(E)> lit_type;
@@ -91,7 +91,7 @@
return tmp;
}
- }
+ } // end of namespace oln::pw::abstract
} // end of namespace oln::pw
Index: oln/core/pw/logic.hh
===================================================================
--- oln/core/pw/logic.hh (revision 0)
+++ oln/core/pw/logic.hh (revision 0)
@@ -0,0 +1,172 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_PW_LOGIC_HH
+# define OLENA_CORE_PW_LOGIC_HH
+
+# include <oln/core/abstract/image_typeness.hh>
+# include <oln/core/pw/abstract/function.hh>
+
+
+namespace oln {
+
+
+ namespace pw { // means "point-wise"
+
+
+ // FIXME: move somewhere else
+ namespace internal
+ {
+ struct not_ {
+ template <typename T>
+ bool operator()(const T& rhs) const {
+ return !rhs;
+ }
+ };
+ struct and_ {
+ template <typename L, typename R>
+ bool operator()(const L& lhs, const R& rhs) const {
+ return lhs && rhs;
+ }
+ };
+ struct nand_ {
+ template <typename L, typename R>
+ bool operator()(const L& lhs, const R& rhs) const {
+ return !(lhs && rhs);
+ }
+ };
+ struct or_ {
+ template <typename L, typename R>
+ bool operator()(const L& lhs, const R& rhs) const {
+ return lhs || rhs;
+ }
+ };
+ struct nor_ {
+ template <typename L, typename R>
+ bool operator()(const L& lhs, const R& rhs) const {
+ return !(lhs || rhs);
+ }
+ };
+ struct xor_ {
+ template <typename L, typename R>
+ bool operator()(const L& lhs, const R& rhs) const {
+ return (lhs && !rhs) || (!lhs && rhs);
+ }
+ };
+ struct xnor_ {
+ template <typename L, typename R>
+ bool operator()(const L& lhs, const R& rhs) const {
+ return (lhs && rhs) || (!lhs && !rhs);
+ }
+ };
+ } // end of oln::pw::internal
+
+
+
+ // fwd decl
+ template <typename R> struct not_;
+
+ template <typename R>
+ struct traits < not_<R> >
+ {
+ typedef oln_pw_point_type(R) point_type;
+ typedef oln_pw_size_type(R) size_type;
+ typedef bool value_type;
+ };
+
+ template <typename R>
+ struct not_ : public abstract::function < not_<R> >
+ {
+ typedef not_<R> self_type;
+
+ typedef oln_pw_point_type(self_type) point_type;
+ typedef oln_pw_value_type(self_type) value_type;
+ typedef oln_pw_size_type(self_type) size_type;
+
+ R right;
+
+ not_(const abstract::function<R>& right) :
+ right(right.exact())
+ {
+ }
+
+ const bool impl_get(const point_type& p) const
+ {
+ return ! this->right(p);
+ }
+
+ const size_type& impl_size() const
+ {
+ return this->right.size();
+ }
+
+ bool impl_hold(const point_type& p) const
+ {
+ return this->right.hold(p);
+ }
+
+ bool impl_hold_large(const point_type& p) const
+ {
+ return this->right.hold_large(p);
+ }
+
+ };
+
+
+ // impl of abstract::function<E>::operator!()
+
+ namespace abstract {
+
+ template <typename E>
+ not_<E>
+ function<E>::operator!() const
+ {
+ mlc::eq< oln_typeness_of(oln_pw_value_type(E)), typeness::binary_tag >::ensure();
+ not_<E> tmp(this->exact());
+ return tmp;
+ }
+
+ } // end of namespace oln::pw::abstract
+
+
+ } // end of namespace oln::pw
+
+
+} // end of namespace oln
+
+
+
+/// Ops on pwf
+
+oln_pw_decl_cmp_op(and_, &&)
+oln_pw_decl_cmp_op(or_, ||)
+
+oln_pw_cmp_operator(and_, &&, bool)
+oln_pw_cmp_operator(or_, ||, bool)
+
+
+#endif // ! OLENA_CORE_PW_LOGIC_HH
Index: oln/core/pw/cmp.hh
===================================================================
--- oln/core/pw/cmp.hh (revision 125)
+++ oln/core/pw/cmp.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef OLENA_CORE_PW_CMP_HH
# define OLENA_CORE_PW_CMP_HH
-# include <oln/core/pw/abstract/function.hh>
+# include <oln/core/pw/abstract/binary_function.hh>
namespace oln {
@@ -76,59 +76,46 @@
return lhs < rhs;
}
};
- }
+ } // end of oln::pw::internal
+
// fwd decl
template <typename L, typename R, typename C> struct cmp;
template <typename L, typename R, typename C>
struct traits < cmp<L, R, C> >
{
- typedef oln_pw_point_type(L) point_type;
+ typedef abstract::binary_function<L, R, cmp<L, R, C> > super_type;
+ typedef typename traits<super_type>::point_type point_type;
+ typedef typename traits<super_type>::size_type size_type;
typedef bool value_type;
- typedef oln_pw_size_type(L) size_type;
};
+
template <typename L, typename R, typename C>
- struct cmp : public abstract::function < cmp<L, R, C> >
+ struct cmp : public abstract::binary_function < L, R, cmp<L, R, C> >
{
typedef cmp<L, R, C> self_type;
typedef oln_pw_point_type(self_type) point_type;
typedef oln_pw_size_type(self_type) size_type;
+ typedef oln_pw_value_type(self_type) value_type;
- L left;
- R right;
+ typedef abstract::binary_function < L, R, self_type > super_type;
cmp(const abstract::function<L>& left,
const abstract::function<R>& right) :
- left(left.exact()),
- right(right.exact())
+ super_type(left, right)
{
}
- const size_type& impl_size() const
- {
- return this->left.size();
- }
-
const bool impl_get(const point_type& p) const
{
static const C cmpfun = C();
return cmpfun(this->left(p), this->right(p));
}
- bool impl_hold(const point_type& p) const
- {
- return this->left.hold(p);
- }
-
- bool impl_hold_large(const point_type& p) const
- {
- return this->left.hold_large(p);
- }
-
};
} // end of namespace oln::pw
@@ -138,68 +125,30 @@
-/// Op+ on pwf
+/// Ops on pwf
-template <typename L, typename R>
-oln::pw::cmp<L, R, oln::pw::internal::eq>
-operator == (const oln::pw::abstract::function<L>& lhs,
- const oln::pw::abstract::function<R>& rhs)
-{
- precondition(lhs.size() == rhs.size());
- oln::pw::cmp<L, R, oln::pw::internal::eq> tmp(lhs, rhs);
- return tmp;
+# define oln_pw_decl_cmp_op(NAME, SYMBOL) \
+template <typename L, typename R> \
+oln::pw::cmp<L, R, oln::pw::internal::NAME> \
+operator SYMBOL (const oln::pw::abstract::function<L>& lhs, \
+ const oln::pw::abstract::function<R>& rhs) \
+{ \
+ precondition(lhs.size() == rhs.size()); \
+ oln::pw::cmp<L, R, oln::pw::internal::NAME> tmp(lhs, rhs); \
+ return tmp; \
}
-template <typename L, typename R>
-oln::pw::cmp<L, R, oln::pw::internal::neq>
-operator != (const oln::pw::abstract::function<L>& lhs,
- const oln::pw::abstract::function<R>& rhs)
-{
- precondition(lhs.size() == rhs.size());
- oln::pw::cmp<L, R, oln::pw::internal::neq> tmp(lhs, rhs);
- return tmp;
-}
+oln_pw_decl_cmp_op(eq, ==)
+oln_pw_decl_cmp_op(neq, !=)
+oln_pw_decl_cmp_op(geq, >=)
+oln_pw_decl_cmp_op(leq, <=)
+oln_pw_decl_cmp_op(g, >)
+oln_pw_decl_cmp_op(l, <)
-template <typename L, typename R>
-oln::pw::cmp<L, R, oln::pw::internal::geq>
-operator >= (const oln::pw::abstract::function<L>& lhs,
- const oln::pw::abstract::function<R>& rhs)
-{
- precondition(lhs.size() == rhs.size());
- oln::pw::cmp<L, R, oln::pw::internal::geq> tmp(lhs, rhs);
- return tmp;
-}
+oln_pw_cmp_operators(int)
+oln_pw_cmp_operators(float)
+oln_pw_cmp_operators(double)
-template <typename L, typename R>
-oln::pw::cmp<L, R, oln::pw::internal::leq>
-operator <= (const oln::pw::abstract::function<L>& lhs,
- const oln::pw::abstract::function<R>& rhs)
-{
- precondition(lhs.size() == rhs.size());
- oln::pw::cmp<L, R, oln::pw::internal::leq> tmp(lhs, rhs);
- return tmp;
-}
-template <typename L, typename R>
-oln::pw::cmp<L, R, oln::pw::internal::g>
-operator > (const oln::pw::abstract::function<L>& lhs,
- const oln::pw::abstract::function<R>& rhs)
-{
- precondition(lhs.size() == rhs.size());
- oln::pw::cmp<L, R, oln::pw::internal::g> tmp(lhs, rhs);
- return tmp;
-}
-template <typename L, typename R>
-oln::pw::cmp<L, R, oln::pw::internal::l>
-operator < (const oln::pw::abstract::function<L>& lhs,
- const oln::pw::abstract::function<R>& rhs)
-{
- precondition(lhs.size() == rhs.size());
- oln::pw::cmp<L, R, oln::pw::internal::l> tmp(lhs, rhs);
- return tmp;
-}
-
-
-
#endif // ! OLENA_CORE_PW_CMP_HH
Index: oln/core/properties.hh
===================================================================
--- oln/core/properties.hh (revision 125)
+++ oln/core/properties.hh (working copy)
@@ -75,8 +75,11 @@
struct image_neighbness_type;
struct image_constness_type;
struct image_dimension_type;
- struct image_vectorialness_type;
+ struct image_typeness_type;
+ struct image_valuedness_type;
// FIXME: ...
+
+ struct dummy_type; // FIXME: remove (test purpose!)
}
mlc_equip_namespace_for_properties();
Index: oln/core/abstract/image_constness.hh
===================================================================
--- oln/core/abstract/image_constness.hh (revision 125)
+++ oln/core/abstract/image_constness.hh (working copy)
@@ -28,7 +28,6 @@
#ifndef OLENA_CORE_ABSTRACT_IMAGE_CONSTNESS_HH
# define OLENA_CORE_ABSTRACT_IMAGE_CONSTNESS_HH
-# include <oln/core/abstract/internal/image_impl.hh>
# include <oln/core/abstract/image.hh>
/*! \namespace oln
Index: oln/core/abstract/image.hh
===================================================================
--- oln/core/abstract/image.hh (revision 125)
+++ oln/core/abstract/image.hh (working copy)
@@ -77,7 +77,6 @@
mlc_decl_prop_with_default(category::image, image_neighbness_type,
is_a<abstract::image_without_nbh>);
mlc_decl_prop_with_default(category::image, image_constness_type,
is_a<abstract::readonly_image>);
mlc_decl_prop(category::image, image_dimension_type);
- mlc_decl_prop(category::image, image_vectorialness_type);
//...
@@ -97,7 +96,6 @@
<< " image_constness_type = " <<
typeid(image_constness_type).name()
<< " image_dimension_type = " <<
typeid(image_dimension_type).name()
- << " image_vectorialness_type = " <<
typeid(image_vectorialness_type).name()
<< " image_neighbness_type = " <<
typeid(image_neighbness_type).name()
<< " }" << std::endl;
@@ -119,7 +117,6 @@
mlc_register_prop(category::image, image_constness_type);
mlc_register_prop(category::image, image_dimension_type);
- mlc_register_prop(category::image, image_vectorialness_type);
mlc_register_prop(category::image, image_neighbness_type);
Index: oln/core/abstract/image_vectorialness.hh
===================================================================
--- oln/core/abstract/image_vectorialness.hh (revision 125)
+++ oln/core/abstract/image_vectorialness.hh (working copy)
@@ -1,125 +0,0 @@
-// Copyright (C) 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_ABSTRACT_IMAGE_VECTORIALNESS_HH
-# define OLENA_CORE_ABSTRACT_IMAGE_VECTORIALNESS_HH
-
-# include <mlc/switch.hh>
-# include <ntg/basics.hh>
-# include <oln/core/abstract/image.hh>
-
-
-/*! \namespace oln
-** \brief oln namespace.
-*/
-namespace oln {
-
- /*! \namespace oln::abstract
- ** \brief oln::abstract namespace.
- */
- namespace abstract {
-
- template <typename E>
- struct data_type_image : public virtual image<E>
- {
- protected:
- data_type_image() {}
- };
-
- template <typename E>
- struct vectorial_image : public data_type_image<E>
- {
- protected:
- vectorial_image() {}
- };
-
- template <typename E>
- struct non_vectorial_image : public data_type_image<E>
- {
- protected:
- non_vectorial_image() {}
- };
-
- template <typename E>
- struct decimal_image : public non_vectorial_image<E>
- {
- protected:
- decimal_image() {}
- };
-
- template <typename E>
- struct integer_image : public non_vectorial_image<E>
- {
- protected:
- integer_image() {}
- };
-
- template <typename E>
- struct binary_image : public non_vectorial_image<E>
- {
- protected:
- binary_image() {}
- };
-
-
- } // end of namespace oln::abstract
-
- template <typename T>
- struct vectorialness_from_valuetype
- {
- typedef typename mlc::bool_switch_<
-
- mlc::bool_case_<ntg_is_a(T, ntg::binary)::val,
- is_a<abstract::binary_image>,
-
- mlc::bool_case_<ntg_is_a(T, ntg::integer)::val,
- is_a<abstract::integer_image>,
-
- mlc::bool_case_<ntg_is_a(T, ntg::decimal)::val,
- is_a<abstract::decimal_image>,
-
- mlc::bool_case_<ntg_is_a(T, ntg::vectorial)::val,
- is_a<abstract::vectorial_image>,
-
- mlc::bool_case_<ntg_is_a(T, ntg::non_vectorial)::val,
- is_a<abstract::non_vectorial_image>,
-
- mlc::bool_case_<true,
- is_a<abstract::data_type_image> >
-
- > > > > > >::ret ret;
- };
-
- #define vectorialness_from_valuetype(T) \
- typename vectorialness_from_valuetype< T >::ret
- #define vectorialness_from_valuetype_(T) \
- vectorialness_from_valuetype< T >::ret
-
-} // end of namespace oln
-
-
-#endif // ! OLENA_CORE_ABSTRACT_IMAGE_VECTORIALNESS_HH
Index: oln/core/abstract/image_neighbness.hh
===================================================================
--- oln/core/abstract/image_neighbness.hh (revision 125)
+++ oln/core/abstract/image_neighbness.hh (working copy)
@@ -28,10 +28,6 @@
#ifndef OLENA_CORE_ABSTRACT_IMAGE_NEIGHBNESS_HH
# define OLENA_CORE_ABSTRACT_IMAGE_NEIGHBNESS_HH
-# include <mlc/bool.hh>
-
-# include <ntg/basics.hh>
-
# include <oln/core/abstract/image.hh>
/*! \namespace oln
Index: oln/core/abstract/image_operator.hh
===================================================================
--- oln/core/abstract/image_operator.hh (revision 125)
+++ oln/core/abstract/image_operator.hh (working copy)
@@ -56,6 +56,22 @@
struct set_super_type< abstract::image_binary_operator<O, I1, I2, E> > {
typedef abstract::image_operator<O, E> ret; };
+ // FIXME: an extension of props; remove (test purpose!)
+ template <typename O, typename E>
+ struct set_props < category::image, abstract::image_operator<O, E> > :
public props_of<category::image>
+ {
+ typedef float dummy_type;
+ };
+ template <typename O, typename E>
+ struct set_type_of < category::image,
+ abstract::image_operator<O, E>,
+ target::dummy_type >
+ {
+ typedef double ret;
+ };
+ // end of FIXME: remove (test purpose!)
+
+
namespace abstract {
Index: oln/core/abstract/entry.hh
===================================================================
--- oln/core/abstract/entry.hh (revision 125)
+++ oln/core/abstract/entry.hh (working copy)
@@ -28,13 +28,9 @@
#ifndef OLENA_CORE_ABSTRACT_ENTRY_HH
# define OLENA_CORE_ABSTRACT_ENTRY_HH
-# include <oln/core/abstract/image_constness.hh>
-# include <oln/core/abstract/image_dimension.hh>
-# include <oln/core/abstract/image_vectorialness.hh>
-# include <oln/core/abstract/image_neighbness.hh>
+# include <oln/core/abstract/images.hh>
-// FIXME: this file should move to oln/core/abstract/
namespace oln {
@@ -52,28 +48,17 @@
typedef category::image ret;
};
-
-
namespace abstract {
-// namespace internal {
-
-// template < typename isa, typename E >
-// struct inherits
-// {
-// typedef typename isa::template instantiated_with<E>::ret ret;
-// };
-
-// }
-
template <typename E>
struct image_entry :
// intrusive:
public oln_type_of_(E, image_constness) ::template
instantiated_with<E>::ret,
public oln_type_of_(E, image_dimension) ::template
instantiated_with<E>::ret,
public oln_type_of_(E, image_neighbness) ::template
instantiated_with<E>::ret,
- public oln_type_of_(E, image_vectorialness) ::template
instantiated_with<E>::ret
- // ...
+ // ...
+ public typeness::inheritance_switch<E>,
+ public valuedness::inheritance_switch<E>
{
protected:
image_entry() {}
Index: oln/core/abstract/images.hh
===================================================================
--- oln/core/abstract/images.hh (revision 125)
+++ oln/core/abstract/images.hh (working copy)
@@ -29,11 +29,19 @@
# define OLENA_CORE_ABSTRACT_IMAGES_HH
-# include <oln/core/abstract/internal/image_impl.hh>
+# include <oln/core/abstract/image.hh>
-
-# include <oln/core/abstract/image.hh>
+// hierarchies:
# include <oln/core/abstract/image_constness.hh>
+# include <oln/core/abstract/image_dimension.hh>
+# include <oln/core/abstract/image_neighbness.hh>
+# include <oln/core/abstract/image_typeness.hh>
+# include <oln/core/abstract/image_valuedness.hh>
+// hierarchy entry
+# include <oln/core/abstract/entry.hh>
+
+
+
#endif // ! OLENA_CORE_ABSTRACT_IMAGES_HH
Index: oln/core/abstract/image_with_data.hh
===================================================================
--- oln/core/abstract/image_with_data.hh (revision 125)
+++ oln/core/abstract/image_with_data.hh (working copy)
@@ -30,7 +30,6 @@
# include <mlc/tracked_ptr.hh>
-
# include <oln/core/abstract/entry.hh>
Index: oln/core/abstract/image_valuedness.hh
===================================================================
--- oln/core/abstract/image_valuedness.hh (revision 0)
+++ oln/core/abstract/image_valuedness.hh (revision 0)
@@ -0,0 +1,253 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_ABSTRACT_IMAGE_VALUEDNESS_HH
+# define OLENA_CORE_ABSTRACT_IMAGE_VALUEDNESS_HH
+
+# include <ntg/decls.hh>
+# include <oln/core/abstract/image.hh>
+
+
+// image
+//
+// ^
+// |
+// -------------------------------------------------------------------------
+// | | | | |
+//
+// scalar_valued_image vector_valued_image label_valued_image data_valued_image ...
+
+
+
+
+// fwd decls
+namespace oln {
+ namespace abstract {
+ template <typename E> struct scalar_valued_image;
+ template <typename E> struct vector_valued_image;
+ template <typename E> struct label_valued_image;
+ template <typename E> struct data_valued_image;
+ }
+}
+namespace std {
+ template <class T, class A> class vector;
+ template <class T> class complex;
+}
+
+
+
+
+/*! \namespace oln
+** \brief oln namespace.
+*/
+namespace oln {
+
+
+ /*! \namespace oln::valuedness
+ ** \brief oln::valuedness namespace.
+ */
+ namespace valuedness {
+
+ enum {
+ scalar_tag = 1,
+ vector_tag = 2,
+ label_tag = 3,
+ data_tag = 4
+ };
+
+
+ template <typename T>
+ struct of
+ {
+ protected:
+
+ static T* makeT();
+ template <int tag> struct tag_is { char c[tag]; };
+
+ // scalar
+
+ template <typename E>
+ static tag_is<scalar_tag> selector(ntg::float_value<E>*);
+ template <typename E>
+ static tag_is<scalar_tag> selector(ntg::int_value<E>*);
+
+ static tag_is<scalar_tag> selector( signed int*);
+ static tag_is<scalar_tag> selector(unsigned int*);
+ static tag_is<scalar_tag> selector( signed char*);
+ static tag_is<scalar_tag> selector(unsigned char*);
+ static tag_is<scalar_tag> selector( signed short*);
+ static tag_is<scalar_tag> selector(unsigned short*);
+ static tag_is<scalar_tag> selector( signed long*);
+ static tag_is<scalar_tag> selector(unsigned long*);
+ static tag_is<scalar_tag> selector(float*);
+ static tag_is<scalar_tag> selector(double*);
+
+ // vector
+
+ template <unsigned n, typename V>
+ static tag_is<vector_tag> selector(V (*)[n]);
+ template <class V, class A>
+ static tag_is<vector_tag> selector(std::vector<V,A>*);
+ template <typename E>
+ static tag_is<vector_tag> selector(ntg::vect_value<E>*);
+ template <class V>
+ static tag_is<vector_tag> selector(std::complex<V>*);
+ template <ntg::cplx_representation R, class V>
+ static tag_is<vector_tag> selector(ntg::cplx<R,V>*);
+
+ // label
+
+ template <typename E>
+ static tag_is<label_tag> selector(ntg::enum_value<E>*);
+ static tag_is<label_tag> selector(bool*);
+ static tag_is<label_tag> selector(ntg::bin*);
+ template <class b>
+ static tag_is<label_tag> selector(ntg::int_u<1,b>*);
+ template <class b>
+ static tag_is<label_tag> selector(ntg::int_s<1,b>*);
+
+ // data
+
+ static tag_is<data_tag> selector(...); // default
+
+ public:
+
+ enum { val = sizeof(selector(makeT())) };
+ };
+
+
+ // specializations:
+
+ template <class T, class interval>
+ struct of < ntg::cycle<T, interval> >
+ {
+ enum { val = of<T>::val };
+ };
+
+ template <class T, class interval, class behavior>
+ struct of < ntg::range<T, interval, behavior> >
+ {
+ enum { val = of<T>::val };
+ };
+
+
+ // inheritance mechanism:
+
+ template <unsigned tag, typename E>
+ struct inheritance_case;
+
+ template <typename E> struct inheritance_case <scalar_tag, E> : public
abstract::scalar_valued_image<E> {};
+ template <typename E> struct inheritance_case <vector_tag, E> : public
abstract::vector_valued_image<E> {};
+ template <typename E> struct inheritance_case <label_tag, E> : public
abstract::label_valued_image<E> {};
+ template <typename E> struct inheritance_case <data_tag, E> : public
abstract::data_valued_image<E> {};
+
+ template <typename E>
+ struct inheritance_switch : public inheritance_case < of< oln_type_of(E, value)
>::val, E >
+ {
+ };
+
+
+ } // end of namespace oln::valuedness
+
+
+
+
+ /*! \namespace oln::abstract
+ ** \brief oln::abstract namespace.
+ */
+ namespace abstract {
+
+
+ /*! \class abstract::scalar_image<E>
+ **
+ ** Class of images containing scalar values.
+ */
+
+ template <typename E>
+ struct scalar_valued_image : public virtual image<E>
+ {
+ protected:
+ /// Constructor (protected, empty).
+ scalar_valued_image() {}
+ };
+
+
+
+ /*! \class abstract::vector_valued_image<E>
+ **
+ ** Class of images containing vectorial values.
+ */
+
+ template <typename E>
+ struct vector_valued_image : public virtual image<E>
+ {
+ protected:
+ /// Constructor (protected, empty).
+ vector_valued_image() {}
+ };
+
+
+
+ /*! \class abstract::label_valued_image<E>
+ **
+ ** Class of images containing label values.
+ */
+
+ template <typename E>
+ struct label_valued_image : public virtual image<E>
+ {
+ protected:
+ /// Constructor (protected, empty).
+ label_valued_image() {}
+ };
+
+
+
+ /*! \class abstract::data_valued_image<E>
+ **
+ ** Class of images containing values that cannot be qualified of scalars,
+ ** vectors, or labels.
+ */
+
+ template <typename E>
+ struct data_valued_image : public virtual image<E>
+ {
+ protected:
+ /// Constructor (protected, empty).
+ data_valued_image() {}
+ };
+
+
+
+ } // end of namespace oln::abstract
+
+
+} // end of namespace oln
+
+
+
+#endif // ! OLENA_CORE_ABSTRACT_IMAGE_VALUEDNESS_HH
Index: oln/core/abstract/image_typeness.hh
===================================================================
--- oln/core/abstract/image_typeness.hh (revision 0)
+++ oln/core/abstract/image_typeness.hh (revision 0)
@@ -0,0 +1,258 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_ABSTRACT_IMAGE_TYPENESS_HH
+# define OLENA_CORE_ABSTRACT_IMAGE_TYPENESS_HH
+
+# include <ntg/decls.hh>
+# include <oln/core/abstract/image.hh>
+
+
+// image
+//
+// ^
+// |
+// -------------------------------------------------
+// | | | | |
+//
+// greylevel_image color_image label_image data_image ...
+//
+// ^
+// |
+//
+// binary_image
+
+
+
+// fwd decls
+namespace oln {
+ namespace abstract {
+ template <typename E> struct greylevel_image;
+ template <typename E> struct color_image;
+ template <typename E> struct label_image;
+ template <typename E> struct binary_image;
+ template <typename E> struct data_image;
+ }
+}
+
+
+/// Macro.
+# define oln_typeness_of(T) typename typeness::tag_< typeness::of<T>::val
>::ret
+
+
+
+/*! \namespace oln
+** \brief oln namespace.
+*/
+namespace oln {
+
+
+ /*! \namespace oln::typeness
+ ** \brief oln::typeness namespace.
+ */
+ namespace typeness {
+
+ enum {
+ _greylevel_tag = 1,
+ _color_tag = 2,
+ _label_tag = 3,
+ _binary_tag = 4,
+ _data_tag = 5
+ };
+
+ struct greylevel_tag;
+ struct color_tag;
+ struct label_tag;
+ struct binary_tag;
+ struct data_tag;
+
+ template <int tag> struct tag_;
+ template <> struct tag_ <_greylevel_tag> { typedef greylevel_tag ret; };
+ template <> struct tag_ <_color_tag> { typedef color_tag ret; };
+ template <> struct tag_ <_label_tag> { typedef label_tag ret; };
+ template <> struct tag_ <_binary_tag> { typedef binary_tag ret; };
+ template <> struct tag_ <_data_tag> { typedef data_tag ret; };
+
+ template <typename T>
+ struct of
+ {
+ protected:
+
+ static T* makeT();
+ template <int tag> struct tag_is { char c[tag]; };
+
+ template <typename E>
+ static tag_is<_color_tag> selector(ntg::color_value<E>*);
+
+ template <typename E>
+ static tag_is<_label_tag> selector(ntg::enum_value<E>*);
+
+ static tag_is<_binary_tag> selector(bool*);
+ static tag_is<_binary_tag> selector(ntg::bin*);
+ template <class b>
+ static tag_is<_binary_tag> selector(ntg::int_u<1,b>*);
+ template <class b>
+ static tag_is<_binary_tag> selector(ntg::int_s<1,b>*);
+
+ static tag_is<_data_tag> selector(...); // default
+
+ public:
+
+ enum { val = sizeof(selector(makeT())) };
+ };
+
+
+ // specializations:
+
+ template <class T, class interval>
+ struct of < ntg::cycle<T, interval> >
+ {
+ enum { val = of<T>::val };
+ };
+
+ template <class T, class interval, class behavior>
+ struct of < ntg::range<T, interval, behavior> >
+ {
+ enum { val = of<T>::val };
+ };
+
+
+ // inheritance mechanism:
+
+ template <typename tag, typename E>
+ struct inheritance_case;
+
+ template <typename E> struct inheritance_case <greylevel_tag, E> : public
abstract::greylevel_image<E> {};
+ template <typename E> struct inheritance_case <color_tag, E> : public
abstract::color_image<E> {};
+ template <typename E> struct inheritance_case <label_tag, E> : public
abstract::label_image<E> {};
+ template <typename E> struct inheritance_case <binary_tag, E> : public
abstract::binary_image<E> {};
+ template <typename E> struct inheritance_case <data_tag, E> : public
abstract::data_image<E> {};
+
+ template <typename E>
+ struct inheritance_switch : public inheritance_case < typename tag_<
of<oln_type_of(E, value)>::val >::ret, E >
+ {
+ };
+
+
+ } // end of namespace oln::typeness
+
+
+
+
+ /*! \namespace oln::abstract
+ ** \brief oln::abstract namespace.
+ */
+ namespace abstract {
+
+
+ /*! \class abstract::greylevel_image<E>
+ **
+ ** Class of greylevel images. An image that contains values whose
+ ** type is 'int' or 'unsigned char', or 'ntg::int_u<8>'
(...) is
+ ** NOT a greylevel image. FIXME: say more.
+ */
+
+ template <typename E>
+ struct greylevel_image : public virtual image<E>
+ {
+ protected:
+ /// Constructor (protected, empty).
+ greylevel_image() {}
+ };
+
+
+
+ /*! \class abstract::color_image<E>
+ **
+ ** Class of color images.
+ */
+
+ template <typename E>
+ struct color_image : public virtual image<E>
+ {
+ protected:
+ /// Constructor (protected, empty).
+ color_image() {}
+ };
+
+
+
+ /*! \class abstract::label_image<E>
+ **
+ ** Class of images whose data are labels. Such images do not
+ ** support arithmetics.
+ */
+
+ template <typename E>
+ struct label_image : public virtual image<E>
+ {
+ protected:
+ /// Constructor (protected, empty).
+ label_image() {}
+ };
+
+
+
+ /*! \class abstract::binary_image<E>
+ **
+ ** Class of images whose data are Boolean values. Such images are
+ ** abstract::label_image.
+ */
+
+ template <typename E>
+ struct binary_image : public label_image<E>
+ {
+ protected:
+ /// Constructor (protected, empty).
+ binary_image() {}
+ };
+
+
+
+ /*! \class abstract::data_image<E>
+ **
+ ** Class of images whose data cannot be qualified of greylevels,
+ ** colors, or labels.
+ */
+
+ template <typename E>
+ struct data_image : public virtual image<E>
+ {
+ protected:
+ /// Constructor (protected, empty).
+ data_image() {}
+ };
+
+
+
+ } // end of namespace oln::abstract
+
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_ABSTRACT_IMAGE_TYPENESS_HH
Index: oln/core/1d/image1d.hh
===================================================================
--- oln/core/1d/image1d.hh (revision 125)
+++ oln/core/1d/image1d.hh (working copy)
@@ -31,9 +31,8 @@
# include <mlc/traits.hh>
# include <oln/core/abstract/image_with_data.hh>
-# include <oln/core/abstract/image_vectorialness.hh>
+# include <oln/core/abstract/image_like_.hh>
# include <oln/core/1d/array1d.hh>
-# include <oln/core/1d/fwd_piter1d.hh>
@@ -44,7 +43,8 @@
- // fwd decl
+ // fwd decls
+ struct fwd_piter1d;
template <typename T> class image1d;
// category
@@ -65,7 +65,6 @@
// intrusive property:
typedef is_a<abstract::image1d> image_dimension_type;
// FIXME: should be generalized
- typedef vectorialness_from_valuetype(T) image_vectorialness_type;
typedef mlc::no_type delegated_type;
Index: oln/core/2d/image2d.hh
===================================================================
--- oln/core/2d/image2d.hh (revision 125)
+++ oln/core/2d/image2d.hh (working copy)
@@ -30,12 +30,9 @@
# include <mlc/traits.hh>
-# include <oln/core/abstract/image_like_.hh>
# include <oln/core/abstract/image_with_data.hh>
-# include <oln/core/abstract/image_vectorialness.hh>
+# include <oln/core/abstract/image_like_.hh>
# include <oln/core/2d/array2d.hh>
-# include <oln/core/2d/fwd_piter2d.hh>
-# include <oln/core/2d/bkd_piter2d.hh>
/*! \namespace oln
@@ -53,7 +50,9 @@
- // fwd decl
+ // fwd decls
+ struct fwd_piter2d;
+ struct bkd_piter2d;
template <typename T> class image2d;
// category
@@ -74,7 +73,6 @@
// intrusive property:
typedef is_a<abstract::image2d> image_dimension_type;
// FIXME: should be generalized
- typedef vectorialness_from_valuetype(T) image_vectorialness_type;
typedef mlc::no_type delegated_type;
Index: oln/core/3d/image3d.hh
===================================================================
--- oln/core/3d/image3d.hh (revision 125)
+++ oln/core/3d/image3d.hh (working copy)
@@ -31,10 +31,10 @@
# include <mlc/traits.hh>
# include <oln/core/abstract/image_with_data.hh>
-# include <oln/core/abstract/image_vectorialness.hh>
+# include <oln/core/abstract/image_like_.hh>
# include <oln/core/3d/array3d.hh>
-# include <oln/core/3d/fwd_piter3d.hh>
+
/*! \namespace oln
** \brief oln namespace.
*/
@@ -42,7 +42,8 @@
- // fwd decl
+ // fwd decls
+ struct fwd_piter3d;
template <typename T> class image3d;
// category
@@ -63,7 +64,6 @@
// intrusive property:
typedef is_a<abstract::image3d> image_dimension_type;
// FIXME: should be generalized
- typedef vectorialness_from_valuetype(T) image_vectorialness_type;
typedef mlc::no_type delegated_type;
Index: oln/makefile.src
===================================================================
--- oln/makefile.src (revision 125)
+++ oln/makefile.src (working copy)
@@ -47,7 +47,8 @@
core/abstract/image_dimension.hh \
core/abstract/image_like_.hh \
core/abstract/image_operator.hh \
- core/abstract/image_vectorialness.hh \
+ core/abstract/image_typeness.hh \
+ core/abstract/image_valuedness.hh \
core/abstract/image_with_data.hh \
core/abstract/images.hh \
core/abstract/internal/image_impl.hh \
Index: oln/morpho/stat.hh
===================================================================
--- oln/morpho/stat.hh (revision 125)
+++ oln/morpho/stat.hh (working copy)
@@ -154,7 +154,7 @@
*/
template<class I, class E>
oln_type_of(I, value)
- max(const abstract::non_vectorial_image<I>& input,
+ max(const abstract::image<I>& input,
const oln_type_of(I, point)& p,
const abstract::struct_elt<E>& se)
{
@@ -176,7 +176,7 @@
*/
template<class I, class E>
oln_type_of(I, value)
- min(const abstract::non_vectorial_image<I>& input,
+ min(const abstract::image<I>& input,
const oln_type_of(I, point)& p,
// const mlc_exact_type(I)::iter_type& p,
const abstract::struct_elt<E>& se)
Index: oln/morpho/erosion.hh
===================================================================
--- oln/morpho/erosion.hh (revision 125)
+++ oln/morpho/erosion.hh (working copy)
@@ -120,8 +120,35 @@
};
+
+ // FIXME: remove (test purpose!)
+ // fwd decl
namespace morpho {
+ namespace impl {
+ template <typename I, typename S> struct generic_erosion;
+ }
+ }
+ // category
+ template <typename I, typename S>
+ struct set_category< morpho::impl::generic_erosion<I,S> > { typedef
category::image ret; };
+ // super_type
+ template <typename I, typename S>
+ struct set_super_type< morpho::impl::generic_erosion<I,S> >
+ {
+ typedef morpho::erosion_ret<I,S> ret;
+ };
+ template <typename I, typename S>
+ struct set_type_of< category::image, morpho::impl::generic_erosion<I,S>,
target::dummy_type >
+ {
+ typedef S ret;
+ };
+ // end of FIXME: remove (test purpose!)
+
+
+
+ namespace morpho {
+
/// Erosion return.
template <typename I, typename E>
@@ -142,6 +169,7 @@
};
+
namespace impl {
/// Erosion generic implementation.
Index: oln/arith/ops.hh
===================================================================
--- oln/arith/ops.hh (revision 125)
+++ oln/arith/ops.hh (working copy)
@@ -29,6 +29,7 @@
# define OLENA_ARITH_OPS_HH
# include <oln/core/abstract/image.hh>
+# include <oln/core/abstract/image_typeness.hh>
# include <oln/core/pw/all.hh>
@@ -130,4 +131,19 @@
+template <typename I, typename F>
+void operator + (const oln::abstract::image<I>&,
+ const oln::pw::abstract::function<F>&)
+{
+ struct OLENA_ERROR__args_are_not_compatible();
+}
+template <typename F, typename I>
+void operator + (const oln::pw::abstract::function<F>&,
+ const oln::abstract::image<I>&)
+{
+ struct OLENA_ERROR__args_are_not_compatible();
+}
+// FIXME: to be continued...
+
+
#endif // ! OLENA_ARITH_OPS_HH
Index: oln/arith/logic.hh
===================================================================
--- oln/arith/logic.hh (revision 0)
+++ oln/arith/logic.hh (revision 0)
@@ -0,0 +1,71 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, 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 OLENA_LOGIC_OPS_HH
+# define OLENA_LOGIC_OPS_HH
+
+# include <oln/core/abstract/image.hh>
+# include <oln/core/abstract/image_typeness.hh>
+# include <oln/core/pw/all.hh>
+
+
+/// Operator 'and' between 2 binary images.
+
+template <typename L, typename R>
+oln::image_from_pw< oln::pw::cmp< oln::pw::image<L>,
+ oln::pw::image<R>, oln::pw::internal::and_ > >
+operator && (const oln::abstract::binary_image<L>& lhs,
+ const oln::abstract::binary_image<R>& rhs)
+{
+ return oln::for_all_p(oln::p_value(lhs) && oln::p_value(rhs));
+}
+
+
+/// Operator 'or' between 2 binary images.
+
+template <typename L, typename R>
+oln::image_from_pw< oln::pw::cmp< oln::pw::image<L>,
+ oln::pw::image<R>, oln::pw::internal::or_ > >
+operator || (const oln::abstract::binary_image<L>& lhs,
+ const oln::abstract::binary_image<R>& rhs)
+{
+ return oln::for_all_p(oln::p_value(lhs) || oln::p_value(rhs));
+}
+
+
+/// Unary operator 'not' on a binary image.
+
+template <typename I>
+oln::image_from_pw< oln::pw::not_< oln::pw::image<I> > >
+operator ! (const oln::abstract::binary_image<I>& rhs)
+{
+ return oln::for_all_p(!oln::p_value(rhs));
+}
+
+
+
+#endif // ! OLENA_LOGIC_OPS_HH