Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- 9625 discussions
09 Oct '07
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Move op-related traits into trait::op:: to be consistent.
* mln/trait/op_plus.hh,
* mln/trait/op_minus.hh,
* mln/trait/op_uminus.hh,
* mln/trait/op_times.hh: Rename as...
* mln/trait/op/times.hh,
* mln/trait/op/plus.hh,
* mln/trait/op/minus.hh,
* mln/trait/op/uminus.hh: ...those.
(op_): Rename as...
(op::): ...those.
* mln/trait/op/all.hh: New.
* mln/trait/all.hh: Update; include op/all.hh.
* tests/trait_op_uminus.cc,
* tests/trait_super.cc,
* tests/trait_op_plus.cc,
* mln/core/ops.hh,
* mln/metal/mat.hh,
* mln/metal/vec.hh,
* mln/arith/plus.hh,
* mln/pw/all.hh: Update.
mln/arith/plus.hh | 2 -
mln/core/ops.hh | 6 +----
mln/metal/mat.hh | 10 ++++-----
mln/metal/vec.hh | 8 +++----
mln/pw/all.hh | 3 --
mln/trait/all.hh | 11 +++-------
mln/trait/op/all.hh | 50 +++++++++++++++++++++++++++++++++++++++++++++++
mln/trait/op/minus.hh | 14 ++++++++-----
mln/trait/op/plus.hh | 14 ++++++++-----
mln/trait/op/times.hh | 14 ++++++++-----
mln/trait/op/uminus.hh | 15 +++++++++-----
tests/trait_op_plus.cc | 10 ++++-----
tests/trait_op_uminus.cc | 10 ++++-----
tests/trait_super.cc | 4 +--
14 files changed, 116 insertions(+), 55 deletions(-)
Index: tests/trait_op_uminus.cc
--- tests/trait_op_uminus.cc (revision 1275)
+++ tests/trait_op_uminus.cc (working copy)
@@ -27,10 +27,10 @@
/*! \file tests/trait_op_uminus.cc
*
- * \brief Tests on mln::trait::op_uminus.
+ * \brief Tests on mln::trait::op::uminus.
*/
-#include <mln/trait/op_uminus.hh>
+#include <mln/trait/op/uminus.hh>
#include <mln/core/concept/object.hh>
@@ -79,19 +79,19 @@
{
// template <>
-// struct set_precise_unary_< op_uminus, test >
+// struct set_precise_unary_< op::uminus, test >
// {
// typedef bool ret;
// };
// template <typename T>
-// struct set_unary_< op_uminus, Sub_Concept, T >
+// struct set_unary_< op::uminus, Sub_Concept, T >
// {
// typedef int ret;
// };
// template <typename T>
-// struct set_unary_< op_uminus, Top_Concept, T >
+// struct set_unary_< op::uminus, Top_Concept, T >
// {
// typedef float ret;
// };
Index: tests/trait_super.cc
--- tests/trait_super.cc (revision 1275)
+++ tests/trait_super.cc (working copy)
@@ -30,7 +30,7 @@
* \brief Tests on mln::trait::solve.
*/
-#include <mln/trait/op_uminus.hh>
+#include <mln/trait/op/uminus.hh>
#include <mln/core/concept/object.hh>
#include <mln/value/int_u8.hh>
@@ -127,7 +127,7 @@
{
template <typename T>
- struct set_unary_< op_uminus, my::Integer, T >
+ struct set_unary_< op::uminus, my::Integer, T >
{
typedef bool ret;
};
Index: tests/trait_op_plus.cc
--- tests/trait_op_plus.cc (revision 1275)
+++ tests/trait_op_plus.cc (working copy)
@@ -27,12 +27,12 @@
/*! \file tests/trait_op_plus.cc
*
- * \brief Tests on mln::trait::op_plus.
+ * \brief Tests on mln::trait::op::plus.
*/
#include <mln/core/concept/image.hh>
#include <mln/value/concept/all.hh>
-#include <mln/trait/op_plus.hh>
+#include <mln/trait/op/plus.hh>
namespace mln
@@ -52,7 +52,7 @@
// int + float -> float
template <>
- struct set_precise_binary_< op_plus, int, float >
+ struct set_precise_binary_< op::plus, int, float >
{
typedef float ret;
};
@@ -61,7 +61,7 @@
// Image I + Image J -> bool (demo type!)
template <typename I, typename J>
- struct set_binary_< op_plus, Image, I, Image, J >
+ struct set_binary_< op::plus, Image, I, Image, J >
{
typedef bool ret;
};
@@ -69,7 +69,7 @@
// precise definition: my_image2d<T> + my_image2d<U> -> my_image2d<V> ('&' is to avoid compiling an empty class)
template <typename T, typename U>
- struct set_precise_binary_< op_plus, my_image2d<T>, my_image2d<U> >
+ struct set_precise_binary_< op::plus, my_image2d<T>, my_image2d<U> >
{
typedef mln_trait_op_plus(T, U) V;
typedef my_image2d<V>& ret;
Index: mln/trait/all.hh
--- mln/trait/all.hh (revision 1275)
+++ mln/trait/all.hh (working copy)
@@ -32,24 +32,21 @@
namespace mln
{
- // FIXME: Doc!
+ /// Namespace where traits are defined.
namespace trait
{}
} // end of namespace mln
+// meta-program to solve a trait call
# include <mln/trait/solve.hh>
// promote
# include <mln/trait/promote.hh>
-// arith
-# include <mln/trait/op_plus.hh>
-# include <mln/trait/op_times.hh>
-# include <mln/trait/op_minus.hh>
-# include <mln/trait/op_uminus.hh>
-
+// ops
+# include <mln/trait/op/all.hh>
#endif // ! MLN_TRAIT_ALL_HH
Index: mln/trait/op/times.hh
--- mln/trait/op/times.hh (revision 1275)
+++ mln/trait/op/times.hh (working copy)
@@ -31,8 +31,8 @@
# include <mln/trait/promote.hh>
-# define mln_trait_op_times(L, R) typename mln::trait::op_times< L , R >::ret
-# define mln_trait_op_times_(L, R) mln::trait::op_times< L , R >::ret
+# define mln_trait_op_times(L, R) typename mln::trait::op::times< L , R >::ret
+# define mln_trait_op_times_(L, R) mln::trait::op::times< L , R >::ret
@@ -42,16 +42,20 @@
namespace trait
{
+ namespace op
+ {
template <typename L, typename R>
- struct op_times : public solve_binary<op_times, L, R>
+ struct times : public solve_binary<times, L, R>
{
};
+ } // end of namespace mln::trait::op
+
- /// Default definition of op_times is given by the promote trait.
+ /// Default definition of op::times is given by the promote trait.
template <typename L, typename R>
- struct set_binary_< op_times, Object, L, Object, R >
+ struct set_binary_< op::times, Object, L, Object, R >
:
public promote< L, R >
{
Index: mln/trait/op/plus.hh
--- mln/trait/op/plus.hh (revision 1275)
+++ mln/trait/op/plus.hh (working copy)
@@ -31,8 +31,8 @@
# include <mln/trait/promote.hh>
-# define mln_trait_op_plus(L, R) typename mln::trait::op_plus< L , R >::ret
-# define mln_trait_op_plus_(L, R) mln::trait::op_plus< L , R >::ret
+# define mln_trait_op_plus(L, R) typename mln::trait::op::plus< L , R >::ret
+# define mln_trait_op_plus_(L, R) mln::trait::op::plus< L , R >::ret
@@ -42,16 +42,20 @@
namespace trait
{
+ namespace op
+ {
template <typename L, typename R>
- struct op_plus : public solve_binary<op_plus, L, R>
+ struct plus : public solve_binary<plus, L, R>
{
};
+ } // end of namespace mln::trait::op
+
- /// Default definition of op_plus is given by the promote trait.
+ /// Default definition of op::plus is given by the promote trait.
template < typename L, typename R >
- struct set_binary_< op_plus, Object, L, Object, R >
+ struct set_binary_< op::plus, Object, L, Object, R >
:
public promote< L, R >
{
Index: mln/trait/op/all.hh
--- mln/trait/op/all.hh (revision 0)
+++ mln/trait/op/all.hh (revision 0)
@@ -0,0 +1,50 @@
+// 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 MLN_TRAIT_OP_ALL_HH
+# define MLN_TRAIT_OP_ALL_HH
+
+
+namespace mln
+{
+
+ namespace trait
+ {
+ /// Namespace of traits related to operators.
+ namespace op {}
+ }
+
+} // end of namespace mln
+
+
+# include <mln/trait/op/plus.hh>
+# include <mln/trait/op/times.hh>
+# include <mln/trait/op/minus.hh>
+# include <mln/trait/op/uminus.hh>
+
+
+#endif // ! MLN_TRAIT_OP_ALL_HH
Index: mln/trait/op/minus.hh
--- mln/trait/op/minus.hh (revision 1275)
+++ mln/trait/op/minus.hh (working copy)
@@ -31,8 +31,8 @@
# include <mln/trait/promote.hh>
-# define mln_trait_op_minus(L, R) typename mln::trait::op_minus< L , R >::ret
-# define mln_trait_op_minus_(L, R) mln::trait::op_minus< L , R >::ret
+# define mln_trait_op_minus(L, R) typename mln::trait::op::minus< L , R >::ret
+# define mln_trait_op_minus_(L, R) mln::trait::op::minus< L , R >::ret
@@ -42,16 +42,20 @@
namespace trait
{
+ namespace op
+ {
template <typename L, typename R>
- struct op_minus : public solve_binary<op_minus, L, R>
+ struct minus : public solve_binary<minus, L, R>
{
};
+ } // end of namespace mln::trait::op
+
- /// Default definition of op_minus is given by the promote trait.
+ /// Default definition of op::minus is given by the promote trait.
template <typename L, typename R>
- struct set_binary_< op_minus, Object, L, Object, R >
+ struct set_binary_< op::minus, Object, L, Object, R >
:
public promote< L, R >
{
Index: mln/trait/op/uminus.hh
--- mln/trait/op/uminus.hh (revision 1275)
+++ mln/trait/op/uminus.hh (working copy)
@@ -31,8 +31,8 @@
# include <mln/trait/solve.hh>
-# define mln_trait_op_uminus(T) typename mln::trait::op_uminus< T >::ret
-# define mln_trait_op_uminus_(T) mln::trait::op_uminus< T >::ret
+# define mln_trait_op_uminus(T) typename mln::trait::op::uminus< T >::ret
+# define mln_trait_op_uminus_(T) mln::trait::op::uminus< T >::ret
@@ -46,15 +46,20 @@
namespace trait
{
+ namespace op
+ {
+
template <typename T>
- struct op_uminus : public solve_unary<op_uminus, T>
+ struct uminus : public solve_unary<uminus, T>
{
};
+ } // end of namespace mln::trait::op
+
- /// Default definition of op_uminus is the input type itself.
+ /// Default definition of op::uminus is the input type itself.
template <typename T>
- struct set_unary_< op_uminus, Object, T >
+ struct set_unary_< op::uminus, Object, T >
{
typedef T ret;
};
Index: mln/core/ops.hh
--- mln/core/ops.hh (revision 1275)
+++ mln/core/ops.hh (working copy)
@@ -35,9 +35,7 @@
# include <mln/core/concept/object.hh>
# include <mln/core/exact.hh>
# include <mln/value/builtin.hh>
-
-# include <mln/trait/op_plus.hh>
-# include <mln/trait/op_times.hh>
+# include <mln/trait/op/all.hh>
namespace mln
@@ -120,7 +118,7 @@
// namespace trait {
// template < typename L, typename R >
-// struct set_binary_< op_plus, Built_In, L, Object, R >
+// struct set_binary_< op::plus, Built_In, L, Object, R >
// {
// typedef mln_trait_op_plus(R, L)
// };
Index: mln/metal/mat.hh
--- mln/metal/mat.hh (revision 1275)
+++ mln/metal/mat.hh (working copy)
@@ -99,7 +99,7 @@
template <unsigned n, unsigned m, typename T,
typename U>
- struct set_precise_binary_<op_plus, metal::mat<n, m, T>, metal::mat<n, m, U> >
+ struct set_precise_binary_<op::plus, metal::mat<n, m, T>, metal::mat<n, m, U> >
{
typedef metal::mat<n, m, mln_trait_op_plus(T, U)> ret;
};
@@ -110,7 +110,7 @@
template <unsigned n, unsigned m, typename T,
typename U>
- struct set_precise_binary_<op_minus, metal::mat<n, m, T>, metal::mat<n, m, U> >
+ struct set_precise_binary_<op::minus, metal::mat<n, m, T>, metal::mat<n, m, U> >
{
typedef metal::mat<n, m, mln_trait_op_minus(T, U)> ret;
};
@@ -118,7 +118,7 @@
// - mat
template <unsigned n, unsigned m, typename T>
- struct set_precise_unary_<op_uminus, metal::mat<n, m, T> >
+ struct set_precise_unary_<op::uminus, metal::mat<n, m, T> >
{
typedef metal::mat<n, m, mln_trait_op_uminus(T)> ret;
};
@@ -127,7 +127,7 @@
template <unsigned n, unsigned o, typename T,
unsigned m, typename U>
- struct set_precise_binary_<op_times, metal::mat<n,o,T>, metal::mat<o,m,U> >
+ struct set_precise_binary_<op::times, metal::mat<n,o,T>, metal::mat<o,m,U> >
{
typedef metal::mat< n, m, mln_trait_op_times(T,U) > ret;
};
@@ -136,7 +136,7 @@
template <unsigned n, unsigned m, typename T,
typename S>
- struct set_precise_binary_<op_times, metal::mat<n,m,T>, S >
+ struct set_precise_binary_<op::times, metal::mat<n,m,T>, S >
{
typedef metal::mat< n, m, mln_trait_op_times(T,S) > ret;
};
Index: mln/metal/vec.hh
--- mln/metal/vec.hh (revision 1275)
+++ mln/metal/vec.hh (working copy)
@@ -187,7 +187,7 @@
// vec + vec
template <unsigned n, typename T, typename U>
- struct set_precise_binary_<op_plus, metal::vec<n, T>, metal::vec<n, U> >
+ struct set_precise_binary_<op::plus, metal::vec<n, T>, metal::vec<n, U> >
{
typedef metal::vec<n, mln_trait_op_plus(T, U)> ret;
};
@@ -197,7 +197,7 @@
// vec - vec
template <unsigned n, typename T, typename U>
- struct set_precise_binary_<op_minus, metal::vec<n, T>, metal::vec<n, U> >
+ struct set_precise_binary_<op::minus, metal::vec<n, T>, metal::vec<n, U> >
{
typedef metal::vec<n, mln_trait_op_minus(T, U)> ret;
};
@@ -205,7 +205,7 @@
// - vec
template <unsigned n, typename T>
- struct set_precise_unary_<op_uminus, metal::vec<n, T> >
+ struct set_precise_unary_<op::uminus, metal::vec<n, T> >
{
typedef metal::vec<n, mln_trait_op_uminus(T)> ret;
};
@@ -213,7 +213,7 @@
// vec * s
template <unsigned n, typename T, typename S>
- struct set_precise_binary_<op_times, metal::vec<n, T>, S >
+ struct set_precise_binary_<op::times, metal::vec<n, T>, S >
{
typedef metal::vec<n, mln_trait_op_times(T, S)> ret;
};
Index: mln/arith/plus.hh
--- mln/arith/plus.hh (revision 1275)
+++ mln/arith/plus.hh (working copy)
@@ -39,7 +39,7 @@
# include <mln/pw/cst.hh>
# include <mln/pw/image.hh>
-# include <mln/trait/op_plus.hh>
+# include <mln/trait/op/plus.hh>
namespace mln
Index: mln/pw/all.hh
--- mln/pw/all.hh (revision 1275)
+++ mln/pw/all.hh (working copy)
@@ -37,8 +37,7 @@
namespace mln
{
- /*! Namespace of "point-wise" expression tools.
- */
+ /// Namespace of "point-wise" expression tools.
namespace pw {}
} // end of namespace mln
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Clean some operators on object and value types.
* tests/value_interop.cc (int_u<n>): Augment.
Deactivate some parts of code because they contain too few
tests to be relevant; they have to be augmented!
* tests/value_int_u8.cc: Augment.
* tests/hexa.cc: Fix; make it compile.
* mln/core/ops.hh (++, --): New operator default impls.
* mln/core/concept/value.hh (++, --): Move to...
* mln/value/concept/scalar.hh: ...here.
Those ops are only relevant for scalars.
* mln/value/int_s.hh,
* mln/value/int_u.hh (+=, -=): Move to...
* mln/value/concept/integer.hh: ...here.
Their definition is more general than just for int_*.
mln/core/concept/value.hh | 22 --------
mln/core/ops.hh | 32 ++++++++++++
mln/value/concept/integer.hh | 2
mln/value/concept/scalar.hh | 77 +++++++++++++++++++++++++++++
mln/value/int_s.hh | 26 ---------
mln/value/int_u.hh | 26 ---------
tests/hexa.cc | 7 +-
tests/value_int_u8.cc | 78 ++++++++++++++++++++++++++---
tests/value_interop.cc | 114 +++++++++++++++++++++++--------------------
9 files changed, 246 insertions(+), 138 deletions(-)
Index: tests/value_interop.cc
--- tests/value_interop.cc (revision 1274)
+++ tests/value_interop.cc (working copy)
@@ -39,66 +39,76 @@
{
using namespace mln;
using value::int_u8;
- using value::int_s8;
using value::int_u16;
using value::float01_8;
- {
- // Operations on int_u<n>
- int_u8 i = 128;
- int_u16 j = 42;
- int_s8 k = 42;
- float01_8 x;
-
- (j = j + i) = i + j;
- assert(j = (128 + 42));
-
- (k = j - i) = i - j;
- assert(k = (-42));
-
- j = 2;
- (j = j * i) = i * j;
- assert(j = (2 * 128));
-
- (x = (j / i) / ((j / i) + 0.1))
- = (i / j) / ((i / j) + 0.1);
-
-// std::cout << i + i << std::endl;
-// float01_8 f = i / 200.5;
-// std::cout << x << std::endl;
- }
+ // Tests on int_u<n> alone.
{
- // Operations on int_u<n> and int / float
- int_u16 j = 42;
- int_s8 k = 42;
- float x;
-
- // int
- (k = j - 123) = 123 - j;
- (j = j + 123) = 123 + j;
- (j = j * 4) = 4 * j;
-
- (j = j / 4) = 4 / j;
-
- // float
- x = (j / 4.5 * 3.4 + 3.5 - 5.6) / 0.0234;
+ int_u8 i;
+ i = 51;
+ i *= 2;
}
+ using value::int_s8;
- {
- // Operations on int_u<n> and float01_8
- int_u16 j = 42;
- float01_8 x = 0.456;
-
- x = x / j;
- assert(x < 0 && x < 1);
-
- x = x * j;
- assert(x < 0 && x < 1);
- x = x * j;
- assert(x < 0 && x < 1);
+// {
+// // Operations on int_u<n>
+// int_u8 i = 128;
+// int_u16 j = 42;
+// int_s8 k = 42;
+// float01_8 x;
+
+// (j = j + i) = i + j;
+// mln_assertion(j = (128 + 42));
+
+// (k = j - i) = i - j;
+// mln_assertion(k = (-42));
+
+// j = 2;
+// (j = j * i) = i * j;
+// mln_assertion(j = (2 * 128));
+
+// (x = (j / i) / ((j / i) + 0.1))
+// = (i / j) / ((i / j) + 0.1);
+
+// // std::cout << i + i << std::endl;
+// // float01_8 f = i / 200.5;
+// // std::cout << x << std::endl;
+// }
+
+// {
+// // Operations on int_u<n> and int / float
+// int_u16 j = 42;
+// int_s8 k = 42;
+// float x;
+
+// // int
+// (k = j - 123) = 123 - j;
+// (j = j + 123) = 123 + j;
+// (j = j * 4) = 4 * j;
+
+// (j = j / 4) = 4 / j;
+
+// // float
+// x = (j / 4.5 * 3.4 + 3.5 - 5.6) / 0.0234;
+// }
+
+
+// {
+// // Operations on int_u<n> and float01_8
+// int_u16 j = 42;
+// float01_8 x = 0.456;
+
+// x = x / j;
+// mln_assertion(x < 0 && x < 1);
+
+// x = x * j;
+// mln_assertion(x < 0 && x < 1);
+
+// x = x * j;
+// mln_assertion(x < 0 && x < 1);
+// }
}
-}
Index: tests/value_int_u8.cc
--- tests/value_int_u8.cc (revision 1274)
+++ tests/value_int_u8.cc (working copy)
@@ -40,14 +40,76 @@
using value::int_u8;
using value::float01_8;
- std::cout << sizeof(float01_8) << std::endl;
- {
- int_u8 i = 3;
- i = 2;
- mln_assertion(i = 2);
- mln_assertion(i != 3);
+ int_u8 i = 3, j;
- mln_assertion(-i = -2);
- mln_assertion(-3 * i = -6);
+ {
+// int k = 1;
+// i *= k;
+ i *= i;
+ mln_assertion(i = 9);
}
+
+// // Assignment.
+// {
+// i = 51;
+// mln_assertion(i = 51);
+
+// i = 51u;
+// mln_assertion(i = 51);
+
+// signed char c = 51;
+// i = c;
+// mln_assertion(i = 51);
+
+// j = i;
+// mln_assertion(j = 51);
+
+// // Error at run-time as expected :-)
+// // i = 256;
+// // i = -1;
+// // i = 255, ++i;
+// }
+
+// // Multiplication.
+// {
+// i *= 2;
+// int k; k *= i;
+
+// unsigned char c = 0;
+// i *= c;
+// mln_assertion(i = 0);
+
+// // Error at run-time as expected :-)
+// // i = 128;
+// // i *= 2;
+// }
+
+
+// {
+// i = 3;
+// mln_assertion(3.0f = i);
+// mln_assertion(i != 2.99f);
+// }
+
+// {
+// int j;
+// j = -i;
+// j = +i;
+// }
+
+// {
+// i = 0;
+// i += 1;
+// }
+
+ // mln_assertion(i = 2);
+ // mln_assertion(i != 3);
+
+ // mln_assertion(-i = -2);
+ // mln_assertion(-3 * i = -6);
+
+ // mln_assertion(j != i);
+ // mln_assertion(j != 0);
+ // mln_assertion(0 != j);
+
}
Index: tests/hexa.cc
--- tests/hexa.cc (revision 1274)
+++ tests/hexa.cc (working copy)
@@ -40,7 +40,7 @@
int main()
{
using namespace mln;
- using typename value::int_u8;
+ using value::int_u8;
typedef image2d_b<int_u8> I;
@@ -51,10 +51,9 @@
// FIXME : to put into debug::println
- box_<point2d>::fwd_piter p(ima.box());
-
+ I::fwd_piter p(ima.domain());
for_all(p)
{
- p
+ ;
}
}
Index: mln/core/ops.hh
--- mln/core/ops.hh (revision 1274)
+++ mln/core/ops.hh (working copy)
@@ -97,6 +97,22 @@
bool operator<=(const Object<O1>& lhs, const Object<O2>& rhs);
+ /* \brief Default definition of the post-incrementation operator.
+ *
+ * It relies on the definition of the pre-incrementation operator.
+ */
+ template <typename O>
+ O operator++(Object<O>& rhs, int);
+
+
+ /* \brief Default definition of the post-decrementation operator.
+ *
+ * It relies on the definition of the pre-decrementation operator.
+ */
+ template <typename O>
+ O operator--(Object<O>& rhs, int);
+
+
// Operator +.
// FIXME HERE
@@ -165,6 +181,22 @@
# ifndef MLN_INCLUDE_ONLY
+ template <typename O>
+ O operator++(Object<O>& rhs, int)
+ {
+ O tmp(exact(rhs)); // Copy.
+ ++exact(rhs); // Pre-inc.
+ return tmp;
+ }
+
+ template <typename O>
+ O operator--(Object<O>& rhs, int)
+ {
+ O tmp(exact(rhs)); // Copy.
+ --exact(rhs); // Pre-dec.
+ return tmp;
+ }
+
template <typename O1, typename O2>
bool operator!=(const Object<O1>& lhs, const Object<O2>& rhs)
{
Index: mln/core/concept/value.hh
--- mln/core/concept/value.hh (revision 1274)
+++ mln/core/concept/value.hh (working copy)
@@ -65,12 +65,6 @@
typedef equiv; // equivalent type
*/
- /// Pre-incrementation.
- E& operator++();
-
- /// Pre-decrementation.
- E& operator--();
-
protected:
Value();
};
@@ -86,22 +80,6 @@
typedef mln_equiv(E) equiv;
}
- template <typename E>
- E&
- Value<E>::operator++()
- {
- exact(this)->operator+=(E::one);
- return exact(*this);
- }
-
- template <typename E>
- E&
- Value<E>::operator--()
- {
- exact(this)->operator-=(E::one);
- return exact(*this);
- }
-
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
Index: mln/value/int_s.hh
--- mln/value/int_s.hh (revision 1274)
+++ mln/value/int_s.hh (working copy)
@@ -124,12 +124,6 @@
/// Unit value.
static const int_s<n> one;
-
- /// Self addition.
- int_s<n>& operator+=(int i);
-
- /// Self subtraction.
- int_s<n>& operator-=(int i);
};
@@ -208,26 +202,6 @@
}
template <unsigned n>
- int_s<n>&
- int_s<n>::operator+=(int i)
- {
- mln_precondition(long(this->v_) + i >= mln_min(int_s<n>));
- mln_precondition(long(this->v_) + i <= mln_max(int_s<n>));
- this->v_ += i;
- return *this;
- }
-
- template <unsigned n>
- int_s<n>&
- int_s<n>::operator-=(int i)
- {
- mln_precondition(long(this->v_) - i >= mln_min(int_s<n>));
- mln_precondition(long(this->v_) - i <= mln_max(int_s<n>));
- this->v_ -= i;
- return *this;
- }
-
- template <unsigned n>
const int_s<n> int_s<n>::zero = 0;
template <unsigned n>
Index: mln/value/int_u.hh
--- mln/value/int_u.hh (revision 1274)
+++ mln/value/int_u.hh (working copy)
@@ -131,12 +131,6 @@
/// Unit value.
static const int_u<n> one;
-
- /// Self addition.
- int_u<n>& operator+=(int i);
-
- /// Self subtraction.
- int_u<n>& operator-=(int i);
};
@@ -204,26 +198,6 @@
}
template <unsigned n>
- int_u<n>&
- int_u<n>::operator+=(int i)
- {
- mln_precondition(long(this->v_) + i >= 0);
- mln_precondition(long(this->v_) + i <= mln_max(enc_));
- this->v_ += i;
- return *this;
- }
-
- template <unsigned n>
- int_u<n>&
- int_u<n>::operator-=(int i)
- {
- mln_precondition(long(this->v_) - i >= 0);
- mln_precondition(long(this->v_) - i <= mln_max(enc_));
- this->v_ -= i;
- return *this;
- }
-
- template <unsigned n>
const int_u<n> int_u<n>::zero = 0;
template <unsigned n>
Index: mln/value/concept/scalar.hh
--- mln/value/concept/scalar.hh (revision 1274)
+++ mln/value/concept/scalar.hh (working copy)
@@ -71,6 +71,83 @@
} // end of namespace mln::value
+
+
+ /// Pre-incrementation.
+ template <typename S>
+ S& operator++(value::Scalar<S>& rhs);
+
+
+ /// Pre-decrementation.
+ template <typename S>
+ S& operator--(value::Scalar<S>& rhs);
+
+
+
+ template <typename S>
+ S& operator*=(value::Scalar<S>& lhs, typename S::interop i);
+
+ template <typename S>
+ S& operator/=(value::Scalar<S>& lhs, typename S::interop i);
+
+ template <typename S>
+ S& operator+=(value::Scalar<S>& lhs, typename S::interop i);
+
+ template <typename S>
+ S& operator-=(value::Scalar<S>& lhs, typename S::interop i);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename S>
+ S& operator++(value::Scalar<S>& rhs)
+ {
+ exact(rhs) += 1; // FIXME: literal::one?
+ return exact(rhs);
+ }
+
+ template <typename S>
+ S& operator--(value::Scalar<S>& rhs)
+ {
+ exact(rhs) -= 1; // FIXME: literal::one?
+ return exact(rhs);
+ }
+
+ template <typename S>
+ S& operator*=(value::Scalar<S>& lhs_, typename S::interop i)
+ {
+ S& lhs = exact(lhs_);
+ lhs = lhs * i;
+ return lhs;
+ }
+
+ template <typename S>
+ S& operator/=(value::Scalar<S>& lhs_, typename S::interop i)
+ {
+ S& lhs = exact(lhs_);
+ lhs = lhs / i;
+ return lhs;
+ }
+
+ template <typename S>
+ S& operator+=(value::Scalar<S>& lhs_, typename S::interop i)
+ {
+ S& lhs = exact(lhs_);
+ lhs = lhs + i;
+ return lhs;
+ }
+
+ template <typename S>
+ S& operator-=(value::Scalar<S>& lhs_, typename S::interop i)
+ {
+ S& lhs = exact(lhs_);
+ lhs = lhs - i;
+ return lhs;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
} // end of namespace mln
Index: mln/value/concept/integer.hh
--- mln/value/concept/integer.hh (revision 1274)
+++ mln/value/concept/integer.hh (working copy)
@@ -45,11 +45,13 @@
template <typename E> struct Integer;
}
+
namespace trait
{
// FIXME
} // end of namespace mln::trait
+
namespace value
{
1
0
Re: [Olena-patches] milena r1273: Update on hexa images, create value_interop test
by Thierry GERAUD 09 Oct '07
by Thierry GERAUD 09 Oct '07
09 Oct '07
Matthieu Garrigues wrote:
> URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
>
> ChangeLog:
> 2007-10-08 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
>
> Update on hexa images, create value_interop test.
> * mln/core/hexa.hh,
> * tests/hexa.cc: Update.
> ...
tegucigalpa% g++-4.1 -I.. hexa.cc
hexa.cc: In function 'int main()':
hexa.cc:54: error: 'struct main()::I' has no member named 'box'
hexa.cc:59: error: expected `;' before '}' token
A test can fail to compile but *not* for such a reason!
1
0
08 Oct '07
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-08 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Refactoring erosion with dispatch mecanism and tracing.
* mln/morpho/erosion.hh: Add fastest image version.
* mln/morpho/erosion.spe.hh: New.
* mln/morpho/includes.hh: Includes min_h and max_h.
---
erosion.hh | 108 +++-----------------
erosion.spe.hh | 294 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
includes.hh | 2
3 files changed, 313 insertions(+), 91 deletions(-)
Index: trunk/milena/mln/morpho/erosion.spe.hh
===================================================================
--- trunk/milena/mln/morpho/erosion.spe.hh (revision 0)
+++ trunk/milena/mln/morpho/erosion.spe.hh (revision 1274)
@@ -0,0 +1,294 @@
+// 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 MLN_MORPHO_EROSION_SPE_HH
+# define MLN_MORPHO_EROSION_SPE_HH
+
+/*! \file mln/morpho/erosion.spe.hh
+ *
+ * \brief Specialization for mln::morpho::erosion.
+ */
+
+# ifndef MLN_INCLUDE_ONLY
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ // Fwd decl.
+ template <typename I, typename W, typename O>
+ void erosion(const Image<I>& input, const Window<W>& win, Image<O>& output);
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+ // Fwd decl.
+ template <typename I, typename W, typename O, typename A>
+ void erosion_on_function(const I& input, const W& win, O& output, A& min);
+
+ // Fwd decl.
+ template <typename I, typename W, typename O>
+ void erosion_on_set(const I& input, const W& win, O& output);
+ }
+
+
+ template <typename I, typename W, typename O, typename A>
+ void erosion_on_function_fast(const I& input, const W& win, O& output, A& min)
+ {
+ trace::entering("morpho::impl::erosion_on_function_fast");
+ border::fill(input, mln_max(mln_value(I)));
+
+ mln_pixter(const I) p(input);
+ mln_pixter(O) p_out(output);
+ mln_qixter(const I, W) q(p, win);
+ for_all_2(p, p_out)
+ {
+ min.init();
+ for_all(q)
+ min.take(q.val());
+ p_out.val() = min.to_result();
+ }
+ trace::exiting("morpho::impl::erosion_on_function_fast");
+ }
+
+ template <typename I, typename W, typename O>
+ void erosion_on_set_fast(const I& input, const W& win, O& output)
+ {
+ trace::entering("morpho::impl::erosion_on_set_fast");
+ level::fill(output, input);
+ border::fill(input, true);
+
+ mln_pixter(const I) p(input);
+ mln_pixter(O) p_out(output);
+ mln_qixter(const I, W) q(p, win);
+ for_all_2(p, p_out)
+ if (p.val())
+ for_all(q)
+ if (! q.val())
+ {
+ p_out.val() = false;
+ break;
+ }
+ trace::exiting("morpho::impl::erosion_on_set_fast");
+ }
+
+
+ // Stage 5: dispatch w.r.t. fast property
+ // |
+ // V
+
+ template <typename I, typename W, typename O>
+ void erosion_set_wrt_fast(trait::image::speed::any, const I& input,
+ const W& win, O& output)
+ {
+ trace::entering("morpho::impl::erosion_set_wrt_fast");
+ generic::erosion_on_set(input, win, output);
+ trace::exiting("morpho::impl::erosion_set_wrt_fast");
+ }
+
+ template <typename I, typename W, typename O>
+ void erosion_set_wrt_fast(trait::image::speed::fastest, const I& input,
+ const W& win, O& output)
+ {
+ trace::entering("morpho::impl::erosion_set_wrt_fast");
+ impl::erosion_on_set_fast(input, win, output);
+ trace::exiting("morpho::impl::erosion_set_wrt_fast");
+ }
+
+ template <typename I, typename W, typename O, typename A>
+ void erosion_fun_wrt_fast(trait::image::speed::any, const I& input,
+ const W& win, O& output, A& min)
+ {
+ trace::entering("morpho::impl::erosion_fun_wrt_fast");
+ generic::erosion_on_function(input, win, output, min);
+ trace::exiting("morpho::impl::erosion_fun_wrt_fast");
+ }
+
+ template <typename I, typename W, typename O, typename A>
+ void erosion_fun_wrt_fast(trait::image::speed::fastest, const I& input,
+ const W& win, O& output, A& min)
+ {
+ trace::entering("morpho::impl::erosion_fun_wrt_fast");
+ impl::erosion_on_function_fast(input, win, output, min);
+ trace::exiting("morpho::impl::erosion_fun_wrt_fast");
+ }
+
+ // ^
+ // |
+ // end of stage 5 (dispatch w.r.t. fast property)
+
+ // Stage 4: dispatch w.r.t. data quantification
+ // |
+ // V
+
+ template <typename I, typename W, typename O>
+ void erosion_wrt_data(trait::image::quant::high, const I& input,
+ const W& win, O& output)
+ {
+ trace::entering("morpho::impl::erosion_wrt_data");
+ accu::min_<mln_value(I)> min;
+ impl::erosion_fun_wrt_fast(mln_trait_image_speed(I)(), input,
+ win, output, min);
+ trace::exiting("morpho::impl::erosion_wrt_data");
+ }
+
+ template <typename I, typename W, typename O>
+ void erosion_wrt_data(trait::image::quant::low, const I& input,
+ const W& win, O& output)
+ {
+ trace::entering("morpho::impl::erosion_wrt_data");
+ accu::min_h<mln_vset(I)> min;
+ impl::erosion_fun_wrt_fast(mln_trait_image_speed(I)(), input,
+ win, output, min);
+ trace::exiting("morpho::impl::erosion_wrt_data");
+ }
+
+ // ^
+ // |
+ // end of stage 4 (dispatch w.r.t. the data quantification)
+
+ // Stage 3: dispatch w.r.t. the value type
+ // |
+ // V
+
+ template <typename I, typename W, typename O>
+ void erosion_wrt_value(const I& input, const W& win, O& output)
+ {
+ trace::entering("morpho::impl::erosion_wrt_value");
+
+ if (mlc_is(mln_trait_image_kind(I), trait::image::kind::logic)::value)
+ impl::erosion_set_wrt_fast(mln_trait_image_speed(I)(), input,
+ win, output);
+ // |
+ // `--> call stage 5: dispatch w.r.t. fast property
+ else
+ impl::erosion_wrt_data(mln_trait_image_quant(I)(), input,
+ win, output);
+ // |
+ // `--> call stage 4: dispatch w.r.t. the data quantification
+ trace::exiting("morpho::impl::erosion_wrt_value");
+ }
+
+ // ^
+ // |
+ // end of stage 3 (dispatch w.r.t. the value type)
+
+
+
+ // Stage 2: dispatch w.r.t. the window morphology
+ // |
+ // V
+
+ template <typename I, typename W, typename O>
+ void erosion_wrt_mor(const I& input, const W& win, O& output)
+ {
+ trace::entering("morpho::impl::erosion_wrt_mor");
+ // FIXME : Choose the right algorithm between :
+ impl::erosion_wrt_value(input, win, output);
+ // and :
+ // impl::erosion_incr_wrt_value(input, win, output);
+ trace::exiting("morpho::impl::erosion_wrt_mor");
+ }
+
+ // ^
+ // |
+ // end of stage 2 (dispatch w.r.t. the window morphology)
+
+
+
+ // Stage 1: dispatch w.r.t. the window type.
+ // |
+ // V
+
+ template <typename I, typename W, typename O>
+ void erosion_wrt_win(const Image<I>& input_, const W& win_, Image<O>& output_)
+ {
+ trace::entering("morpho::impl::erosion_wrt_win");
+ const I& input = exact(input_);
+ const W& win = exact(win_);
+ O& output = exact(output_);
+
+ impl::erosion_wrt_mor(input, win, output);
+ // |
+ // `--> call stage 2: dispatch w.r.t. the data quantification
+ trace::exiting("morpho::impl::erosion_wrt_win");
+ }
+
+# ifdef MLN_CORE_WIN_RECTANGLE2D_HH
+
+ template <typename I, typename O>
+ void erosion_wrt_win(const Image<I>& input, const win::rectangle2d& win, Image<O>& output)
+ {
+ O temp(exact(output).domain());
+ morpho::erosion(input, win::hline2d(win.width()), temp);
+ morpho::erosion(temp, win::vline2d(win.height()), output);
+ }
+
+# endif // MLN_CORE_WIN_RECTANGLE2D_HH
+
+
+# ifdef MLN_CORE_WIN_OCTAGON2D_HH
+# ifdef MLN_CORE_WIN_DIAG2D_HH
+# ifdef MLN_CORE_WIN_BACKDIAG2D_HH
+
+ template <typename I, typename O>
+ void erosion_wrt_win(const Image<I>& input, const win::octagon2d& win, Image<O>& output)
+ {
+ const unsigned len = win.length() / 3 + 1;
+
+ O temp1(exact(output).domain());
+ O temp2(exact(output).domain());
+ morpho::erosion(input, win::hline2d(len), temp1);
+ morpho::erosion(temp1, win::vline2d(len), temp2);
+ morpho::erosion(temp2, win::diag2d(len), temp1);
+ morpho::erosion(temp1, win::backdiag2d(len), output);
+ }
+
+# endif // MLN_CORE_WIN_BACKDIAG2D_HH
+# endif // MLN_CORE_WIN_DIAG2D_HH
+# endif // MLN_CORE_WIN_OCTAGON2D_HH
+
+ // ^
+ // |
+ // end of stage 1 (dispatch w.r.t. the window type)
+
+
+
+ } // end of namespace mln::morpho::impl
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+#endif // ! MLN_MORPHO_EROSION_SPE_HH
Index: trunk/milena/mln/morpho/includes.hh
===================================================================
--- trunk/milena/mln/morpho/includes.hh (revision 1273)
+++ trunk/milena/mln/morpho/includes.hh (revision 1274)
@@ -40,6 +40,8 @@
# include <mln/accu/min.hh>
# include <mln/accu/max.hh>
+# include <mln/accu/min_h.hh>
+# include <mln/accu/max_h.hh>
# include <mln/level/compare.hh>
# include <mln/level/fill.hh>
Index: trunk/milena/mln/morpho/erosion.hh
===================================================================
--- trunk/milena/mln/morpho/erosion.hh (revision 1273)
+++ trunk/milena/mln/morpho/erosion.hh (revision 1274)
@@ -36,6 +36,9 @@
# include <mln/morpho/includes.hh>
+// Specializations are in:
+# include <mln/morpho/erosion.spe.hh>
+
namespace mln
{
@@ -57,17 +60,15 @@
namespace impl
{
- // On function.
- template <typename I, typename W, typename O>
- void erosion_on_function(const Image<I>& input_, const Window<W>& win_, Image<O>& output_)
+ namespace generic
{
- const I& input = exact(input_);
- const W& win = exact(win_);
- O& output = exact(output_);
-
- accu::min_<mln_value(I)> min;
+ // On function.
+ template <typename I, typename W, typename O, typename A>
+ void erosion_on_function(const I& input, const W& win, O& output, A& min)
+ {
+ trace::entering("morpho::impl::generic::erosion_on_function");
mln_piter(I) p(input.domain());
mln_qiter(W) q(win, p);
for_all(p)
@@ -77,18 +78,15 @@
min.take(input(q));
output(p) = min.to_result();
}
+ trace::exiting("morpho::impl::generic::erosion_on_function");
}
-
// On set.
template <typename I, typename W, typename O>
- void erosion_on_set(const Image<I>& input_, const Window<W>& win_, Image<O>& output_)
+ void erosion_on_set(const I& input, const W& win, O& output)
{
- const I& input = exact(input_);
- const W& win = exact(win_);
- O& output = exact(output_);
-
+ trace::entering("morpho::impl::generic::erosion_on_set");
level::fill(output, input);
mln_piter(I) p(input.domain());
@@ -101,94 +99,21 @@
output(p) = false;
break;
}
+ trace::exiting("morpho::impl::generic::erosion_on_set");
}
-
-
- // ...
-
-
-
- // FIXME: Stage 3: dispatch w.r.t. fast property
-
-
- // Stage 2: dispatch w.r.t. the value kind.
-
- template <typename I, typename W, typename O>
- void erosion_wrt_value(trait::image::kind::logic, // binary => morphology on sets
- const Image<I>& input, const Window<W>& win, Image<O>& output)
- {
- return impl::erosion_on_set(exact(input), exact(win), output);
- }
-
- template <typename K, typename I, typename W, typename O>
- void erosion_wrt_value(K, // otherwise => morphology on functions
- const Image<I>& input, const Window<W>& win, Image<O>& output)
- {
- return impl::erosion_on_function(exact(input), exact(win), output);
- }
-
-
-
- // Stage 1: dispatch w.r.t. the window type.
- // |
- // V
-
- template <typename I, typename W, typename O>
- void erosion_wrt_win(const Image<I>& input, const Window<W>& win, Image<O>& output)
- {
- erosion_wrt_value(mln_trait_image_kind(I)(), exact(input), exact(win), output);
- // |
- // --> call stage 2: dispatch w.r.t. the value kind
- }
-
-# ifdef MLN_CORE_WIN_RECTANGLE2D_HH
-
- template <typename I, typename O>
- void erosion_wrt_win(const Image<I>& input, const win::rectangle2d& win, Image<O>& output)
- {
- O temp(exact(output).domain());
- morpho::erosion(input, win::hline2d(win.width()), temp);
- morpho::erosion(temp, win::vline2d(win.height()), output);
- }
-
-# endif // MLN_CORE_WIN_RECTANGLE2D_HH
-
-
-# ifdef MLN_CORE_WIN_OCTAGON2D_HH
-# ifdef MLN_CORE_WIN_DIAG2D_HH
-# ifdef MLN_CORE_WIN_BACKDIAG2D_HH
-
- template <typename I, typename O>
- void erosion_wrt_win(const Image<I>& input, const win::octagon2d& win, Image<O>& output)
- {
- const unsigned len = win.length() / 3 + 1;
-
- O temp1(exact(output).domain());
- O temp2(exact(output).domain());
- morpho::erosion(input, win::hline2d(len), temp1);
- morpho::erosion(temp1, win::vline2d(len), temp2);
- morpho::erosion(temp2, win::diag2d(len), temp1);
- morpho::erosion(temp1, win::backdiag2d(len), output);
- }
-
-# endif // MLN_CORE_WIN_BACKDIAG2D_HH
-# endif // MLN_CORE_WIN_DIAG2D_HH
-# endif // MLN_CORE_WIN_OCTAGON2D_HH
-
- // ^
- // |
- // end of stage1 (dispatch w.r.t. the window type)
-
+ } // end of namespace mln::morpho::impl::generic
} // end of namespace mln::morpho::impl
+
// Facade.
template <typename I, typename W, typename O>
void erosion(const Image<I>& input, const Window<W>& win, Image<O>& output)
{
+ trace::entering("morpho::erosion");
mln_precondition(exact(output).domain() == exact(input).domain());
mln_precondition(! exact(win).is_empty());
@@ -196,6 +121,7 @@
if (exact(win).is_centered())
mln_postcondition(output <= input);
+ trace::exiting("morpho::erosion");
}
# endif // ! MLN_INCLUDE_ONLY
1
0
08 Oct '07
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-08 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Update on hexa images, create value_interop test.
* mln/core/hexa.hh,
* tests/hexa.cc: Update.
* tests/value_int_u.cc: Remove.
* tests/value_interop.cc: New.
---
mln/core/hexa.hh | 17 +++++++-
tests/hexa.cc | 13 ++++++
tests/value_interop.cc | 104 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 133 insertions(+), 1 deletion(-)
Index: trunk/milena/tests/value_int_u.cc (deleted)
===================================================================
Index: trunk/milena/tests/value_interop.cc
===================================================================
--- trunk/milena/tests/value_interop.cc (revision 0)
+++ trunk/milena/tests/value_interop.cc (revision 1273)
@@ -0,0 +1,104 @@
+// 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 tests/value_interop.cc
+ *
+ * \brief Tests interoperability on mln::value::*.
+ */
+
+#include <mln/value/int_u8.hh>
+#include <mln/value/int_s8.hh>
+#include <mln/value/int_u16.hh>
+#include <mln/value/float01_8.hh>
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+ using value::int_s8;
+ using value::int_u16;
+ using value::float01_8;
+
+ {
+ // Operations on int_u<n>
+ int_u8 i = 128;
+ int_u16 j = 42;
+ int_s8 k = 42;
+ float01_8 x;
+
+ (j = j + i) = i + j;
+ assert(j == (128 + 42));
+
+ (k = j - i) = i - j;
+ assert(k == (-42));
+
+ j = 2;
+ (j = j * i) = i * j;
+ assert(j == (2 * 128));
+
+ (x = (j / i) / ((j / i) + 0.1))
+ = (i / j) / ((i / j) + 0.1);
+
+// std::cout << i + i << std::endl;
+// float01_8 f = i / 200.5;
+// std::cout << x << std::endl;
+ }
+
+ {
+ // Operations on int_u<n> and int / float
+ int_u16 j = 42;
+ int_s8 k = 42;
+ float x;
+
+ // int
+ (k = j - 123) = 123 - j;
+ (j = j + 123) = 123 + j;
+ (j = j * 4) = 4 * j;
+
+ (j = j / 4) = 4 / j;
+
+ // float
+ x = (j / 4.5 * 3.4 + 3.5 - 5.6) / 0.0234;
+ }
+
+
+ {
+ // Operations on int_u<n> and float01_8
+ int_u16 j = 42;
+ float01_8 x = 0.456;
+
+ x = x / j;
+ assert(x < 0 && x < 1);
+
+ x = x * j;
+ assert(x < 0 && x < 1);
+
+ x = x * j;
+ assert(x < 0 && x < 1);
+
+ }
+}
Index: trunk/milena/tests/hexa.cc
===================================================================
--- trunk/milena/tests/hexa.cc (revision 1272)
+++ trunk/milena/tests/hexa.cc (revision 1273)
@@ -34,6 +34,8 @@
#include <mln/core/hexa.hh>
#include <mln/value/int_u8.hh>
+#include <mln/trait/image/print.hh>
+
int main()
{
@@ -44,4 +46,15 @@
I ima(3,3);
hexa< I > h(ima);
+
+ trait::image::print(h, std::cout);
+
+
+ // FIXME : to put into debug::println
+ box_<point2d>::fwd_piter p(ima.box());
+
+ for_all(p)
+ {
+ p
+ }
}
Index: trunk/milena/mln/core/hexa.hh
===================================================================
--- trunk/milena/mln/core/hexa.hh (revision 1272)
+++ trunk/milena/mln/core/hexa.hh (revision 1273)
@@ -73,7 +73,7 @@
typedef trait::image::category::domain_morpher category;
- typedef trait::image::border::none border; // no more accessible border
+ typedef mln_trait_image_border(I) border; // have a border only if I does.
typedef mln_trait_image_io_from_(I) io; // un-write when I const
@@ -90,6 +90,21 @@
*
* The parameter \c I is the type of the base image. This image class
* which handles hexagonal grid.
+ *
+ * Ex :
+ * -------------------
+ * XX| | | | | | |XX
+ * ---------------------
+ * XX| | | | | | |XX
+ * ---------------------
+ * XX| | | | | | |XX
+ * ---------------------
+ * XX| | | | | | |XX
+ * ---------------------
+ * XX| | | | | | |XX
+ * -------------------
+ *
+ *
*/
template <typename I>
struct hexa : public internal::image_domain_morpher_< I, mln_pset(I), hexa<I> >
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Clean-up value types.
* tests/value_float01_bis.cc: New.
* tests/value_float01_f.cc: Layout.
* tests/value_float01.hh: Remove.
* tests/value_float01.cc: Use mln_assertion.
* tests/value_int_u8.cc: Check size of float01_8.
* mln/accu/median.hh (init): Fix.
* mln/value/internal/value_like.hh (V): Rename as...
(C): ...this.
(V, N): New parameters.
(operator): Remove auto conversion; too risky.
(to_interop): New.
* mln/value/graylevel.hh,
* mln/value/float01_.hh,
* mln/value/int_s.hh,
* mln/value/int_u.hh,
* mln/value/int_u_sat.hh,
* mln/value/float01.hh,
* mln/value/float01_f.hh: Update.
mln/accu/median.hh | 3 -
mln/value/float01.hh | 63 ++++++++++++++----------
mln/value/float01_.hh | 100 ++++++++++++---------------------------
mln/value/float01_f.hh | 42 +++++++---------
mln/value/graylevel.hh | 63 ++++++++----------------
mln/value/int_s.hh | 39 ++++++++-------
mln/value/int_u.hh | 37 +++++++++-----
mln/value/int_u_sat.hh | 44 +++++++++--------
mln/value/internal/value_like.hh | 73 +++++++++++++---------------
tests/value_float01.cc | 2
tests/value_float01_f.cc | 5 -
tests/value_int_u8.cc | 1
12 files changed, 222 insertions(+), 250 deletions(-)
Index: tests/value_float01_f.cc
--- tests/value_float01_f.cc (revision 1271)
+++ tests/value_float01_f.cc (working copy)
@@ -30,10 +30,9 @@
int main()
{
- using typename mln::value::float01_f;
- float01_f x = 0.5;
+ using mln::value::float01_f;
+ float01_f x = 0.5;
std::cout << x + 21.25 << std::endl;
-
x = x + 34;
}
Index: tests/value_float01.cc
--- tests/value_float01.cc (revision 1271)
+++ tests/value_float01.cc (working copy)
@@ -137,7 +137,7 @@
io::pgm::save(lena, "out.pgm");
io::pgm::save(ref, "ref.pgm");
- assert(lena = ref);
+ mln_assertion(lena = ref);
//debug::println(out);
}
Index: tests/value_int_u8.cc
--- tests/value_int_u8.cc (revision 1271)
+++ tests/value_int_u8.cc (working copy)
@@ -40,6 +40,7 @@
using value::int_u8;
using value::float01_8;
+ std::cout << sizeof(float01_8) << std::endl;
{
int_u8 i = 3;
i = 2;
Index: mln/accu/median.hh
--- mln/accu/median.hh (revision 1271)
+++ mln/accu/median.hh (working copy)
@@ -217,7 +217,8 @@
h_.init();
sum_minus_ = 0;
sum_plus_ = 0;
- i_ = (mln_max(argument) - mln_min(argument)) / 2;
+ i_ = (s_.index_of(mln_max(argument))
+ - s_.index_of(mln_min(argument))) / 2;
t_ = s_[i_];
valid_ = true;
}
Index: mln/value/graylevel.hh
--- mln/value/graylevel.hh (revision 1271)
+++ mln/value/graylevel.hh (working copy)
@@ -34,9 +34,7 @@
# include <mln/metal/math.hh>
# include <mln/metal/bexpr.hh>
-# include <mln/value/internal/value_like.hh>
-# include <mln/value/concept/integer.hh>
-# include <mln/value/internal/encoding.hh>
+# include <mln/value/int_u.hh>
# include <mln/value/gray.hh>
# include <mln/value/props.hh>
@@ -53,36 +51,25 @@
/// General gray-level class on n bits.
template <unsigned n>
- class graylevel
- : public Integer< graylevel<n> >,
- public internal::value_like_< typename internal::encoding_unsigned_<n>::ret,
- graylevel<n> >
- {
- protected:
- typedef internal::value_like_< typename internal::encoding_unsigned_<n>::ret,
- graylevel<n> > like;
-
- public:
-
- /// Encoding associated type.
- typedef typename like::enc enc;
-
+ struct graylevel
+ :
+ public Integer< graylevel<n> >,
+
+ public internal::value_like_< int_u<n>, // Equivalent.
+ mln_enc(int_u<n>), // Encoding.
+ gray, // Interoperation.
+ graylevel<n> > // Exact.
+ {
/// Ctor.
graylevel();
/// Ctor.
- explicit graylevel(const int val);
+ explicit graylevel(int val);
/// Access to std type.
- enc value() const;
-
- /// Op<.
- bool operator<(const graylevel<n>& rhs) const;
+ mln_enc(int_u<n>) value() const;
- graylevel<n>& operator=(const int val);
-
- protected:
- enc val_;
+ graylevel<n>& operator=(int val);
};
@@ -132,37 +119,31 @@
}
template <unsigned n>
- graylevel<n>::graylevel(const int val)
- : val_(val)
+ graylevel<n>::graylevel(int val)
{
mln_precondition(val >= 0);
- mln_precondition(unsigned(val) <= mln_max(enc));
+ mln_precondition(unsigned(val) <= mln_max(mln_enc(int_u<n>)));
+ this->v_ = val;
}
template <unsigned n>
- typename graylevel<n>::enc
+ mln_enc(int_u<n>)
graylevel<n>::value() const
{
- return val_;
+ return this->v_;
}
template <unsigned n>
graylevel<n>&
- graylevel<n>::operator=(const int val)
+ graylevel<n>::operator=(int val)
{
mln_precondition(val >= 0);
- mln_precondition(unsigned(val) <= mln_max(enc));
- this->val_ = val;
+ mln_precondition(unsigned(val) <= mln_max(mln_enc(int_u<n>)));
+ this->v_ = val;
return *this;
}
template <unsigned n>
- bool graylevel<n>::operator<(const graylevel<n>& rhs) const
- {
- return val_ < rhs.val_;
- }
-
- template <unsigned n>
std::ostream& operator<<(std::ostream& ostr, const graylevel<n>& g)
{
return ostr << g.value();
@@ -174,7 +155,7 @@
return gray(lhs) = gray(rhs);
}
-# endif
+# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::value
Index: mln/value/float01_.hh
--- mln/value/float01_.hh (revision 1271)
+++ mln/value/float01_.hh (working copy)
@@ -32,12 +32,14 @@
# include <mln/core/contract.hh>
# include <mln/metal/math.hh>
# include <mln/metal/bexpr.hh>
-# include <mln/value/internal/value_like.hh>
+
+# include <mln/value/int_u.hh>
# include <mln/value/concept/floating.hh>
-# include <mln/value/internal/encoding.hh>
# include <mln/value/float01.hh>
# include <mln/value/props.hh>
+
+
namespace mln
{
@@ -50,44 +52,29 @@
/// General float01-level class on n bits.
template <unsigned n>
- class float01_
- : public Floating< float01_<n> >,
- public internal::value_like_< float,
- float01_<n> >
- {
- public:
+ struct float01_
- /// Encoding associated type.
- typedef typename internal::encoding_unsigned_<n>::ret enc;
+ : public Floating< float01_<n> >,
+ public internal::value_like_< int_u<n>, // Equivalent. // FIXME: Why not float01?
+ mln_enc(int_u<n>), // Encoding.
+ float, // Interoperation.
+ float01_<n> > // Exact.
+ {
/// Ctor.
float01_();
/// Ctor.
- float01_(const float val);
+ float01_(float val);
/// Access to std type.
float value() const;
void set_ind(unsigned long val);
- enc value_ind() const;
-
- /// Op encoding_t.
operator float() const;
- /// Op float01.
- operator float01() const;
-
- /// Op<.
- bool operator<(const float01_<n>& rhs) const;
-
- float01_<n>& operator=(const float val);
- /// Op=.
- // bool operator=(const float01_<n>& rhs) const;
-
- protected:
- enc val_;
+ float01_<n>& operator=(float val);
};
@@ -106,7 +93,7 @@
static std::size_t index_of_value(const float01_<n>& v)
{
- return v.value_ind();
+ return v.to_enc();
}
};
}
@@ -115,8 +102,8 @@
struct props< float01_<n> >
{
static const std::size_t card_ = metal::pow<2, n>::value;
- static const int min() { return 0; }
- static const int max() { return 1; }
+ static const float min() { return 0.f; }
+ static const float max() { return 1.f; }
static const unsigned nbits = n;
typedef trait::value::kind::data kind;
typedef float sum;
@@ -126,96 +113,71 @@
/// Op<<.
template <unsigned n>
- std::ostream& operator<<(std::ostream& ostr, const float01_<n>& g);
+ std::ostream& operator<<(std::ostream& ostr, const float01_<n>& f);
template <unsigned n, unsigned m>
bool approx_equal(const float01_<n>& lhs, const float01_<m>& rhs);
template <unsigned n>
- bool operator=(const float01_<n>& lhs, const float01_<n>& rhs);
-
- template <unsigned n>
bool approx_equal(const float01_<n>& lhs, const float f);
+
+
# ifndef MLN_INCLUDE_ONLY
// Float01_<n>.
template <unsigned n>
float01_<n>::float01_()
- : val_(0)
{
}
template <unsigned n>
- float01_<n>::float01_(const float val)
- : val_( int(val * (mln_card_(float01_<n>) - 1)) )
+ float01_<n>::float01_(float val)
{
mln_precondition(val >= 0);
mln_precondition(val <= 1);
+ this->v_ = int(val * (mln_card_(float01_<n>) - 1)); // FIXME
}
template <unsigned n>
float
float01_<n>::value() const
{
- return (float(val_) / (mln_card_(float01_<n>) - 1));
+ return float(this->v_) / (mln_card_(float01_<n>) - 1); // FIXME
}
template <unsigned n>
void
float01_<n>::set_ind(unsigned long val)
{
- val_ = val;
- }
-
- template <unsigned n>
- typename float01_<n>::enc
- float01_<n>::value_ind() const
- {
- return (val_);
+ this->v_ = val;
}
template <unsigned n>
float01_<n>&
- float01_<n>::operator=(const float val)
+ float01_<n>::operator=(float val)
{
mln_precondition(val >= 0);
mln_precondition(val <= 1);
- this->val_ = long(val * (mln_card_(float01_<n>) - 1));
+ this->v_ = int(val * (mln_card_(float01_<n>) - 1)); // FIXME
return *this;
}
template <unsigned n>
- float01_<n>::operator float01() const
- {
- float01 tmp(n, val_);
- return tmp;
- }
-
- template <unsigned n>
float01_<n>::operator float() const
{
- return float(val_) / (mln_card_(float01_<n>) - 1);
+ return float(this->v_) / (mln_card_(float01_<n>) - 1);
}
- template <unsigned n>
- bool float01_<n>::operator<(const float01_<n>& rhs) const
- {
- return val_ < rhs.val_;
- }
- template <unsigned n>
- std::ostream& operator<<(std::ostream& ostr, const float01_<n>& g)
- {
- return ostr << g.value();
- }
+ // Operators.
template <unsigned n>
- bool operator=(const float01_<n>& lhs, const float01_<n>& rhs)
+ std::ostream& operator<<(std::ostream& ostr, const float01_<n>& f)
{
- return lhs.value_ind() = rhs.value_ind();
+ return ostr << f.value();
}
template <unsigned n, unsigned m>
@@ -225,13 +187,13 @@
}
template <unsigned n>
- bool approx_equal(const float01_<n>& lhs, const float f)
+ bool approx_equal(const float01_<n>& lhs, float f)
{
return float01(lhs) = float01_<n>(f);
}
-# endif
+# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::value
Index: mln/value/int_s.hh
--- mln/value/int_s.hh (revision 1271)
+++ mln/value/int_s.hh (working copy)
@@ -96,25 +96,23 @@
*/
template <unsigned n>
struct int_s
- : public Integer< int_s<n> >,
- public internal::value_like_< typename internal::encoding_signed_<n>::ret,
- int_s<n> >
- {
- protected:
- typedef internal::value_like_< typename internal::encoding_signed_<n>::ret,
- int_s<n> > super;
-
- public:
-
- /// Encoding associated type.
- typedef typename super::enc enc;
+ :
+ public Integer< int_s<n> >,
+ public internal::value_like_< int, // Equivalent.
+ typename internal::encoding_signed_<n>::ret, // Enc.
+ int, // Interoperation.
+ int_s<n> > // Exact.
+ {
/// Constructor without argument.
int_s();
/// Constructor from an integer.
int_s(int i);
+ /// Conversion to an integer.
+ operator int() const;
+
/// Assignment from an integer.
int_s<n>& operator=(int i);
@@ -166,6 +164,7 @@
std::ostream& operator<<(std::ostream& ostr, const int_s<n>& i);
+
# ifndef MLN_INCLUDE_ONLY
template <unsigned n>
@@ -174,13 +173,19 @@
}
template <unsigned n>
+ int_s<n>::operator int() const
+ {
+ return this->v_;
+ }
+
+ template <unsigned n>
int_s<n>::int_s(int i)
{
static const int max = metal::pow<2, n-1>::value - 1;
static const int min = - max;
mln_precondition(i >= min);
mln_precondition(i <= max);
- this->v_ = enc(i);
+ this->v_ = i;
}
template <unsigned n>
@@ -206,8 +211,8 @@
int_s<n>&
int_s<n>::operator+=(int i)
{
- mln_precondition(long(this->v_) + i >= mln_min(enc));
- mln_precondition(long(this->v_) + i <= mln_max(enc));
+ mln_precondition(long(this->v_) + i >= mln_min(int_s<n>));
+ mln_precondition(long(this->v_) + i <= mln_max(int_s<n>));
this->v_ += i;
return *this;
}
@@ -216,8 +221,8 @@
int_s<n>&
int_s<n>::operator-=(int i)
{
- mln_precondition(long(this->v_) - i >= mln_min(enc));
- mln_precondition(long(this->v_) - i <= mln_max(enc));
+ mln_precondition(long(this->v_) - i >= mln_min(int_s<n>));
+ mln_precondition(long(this->v_) - i <= mln_max(int_s<n>));
this->v_ -= i;
return *this;
}
Index: mln/value/internal/value_like.hh
--- mln/value/internal/value_like.hh (revision 1271)
+++ mln/value/internal/value_like.hh (working copy)
@@ -36,6 +36,7 @@
*/
# include <mln/core/concept/value.hh>
+# include <mln/core/internal/force_exact.hh>
namespace mln
@@ -55,29 +56,32 @@
* Parameters are \c V the equivalent value type and \c E the
* exact value type.
*/
- template <typename V, typename E>
+ template < typename V, // Equivalent.
+ typename C, // Encoding.
+ typename N, // Interoperation.
+ typename E >
struct value_like_ // FIXME :Remove -> : public Value<E>
{
- /// Encoding associated type.
- typedef V enc;
-
/// Equivalent associated type.
typedef V equiv;
- /// Convertion towards equivalent type.
- operator V() const;
+ /// Encoding associated type.
+ typedef C enc;
+
+ /// Interoperation associated type.
+ typedef N interop;
/// Explicit convertion towards equivalent type.
V to_equiv() const;
/// Explicit convertion towards encoding type.
- V to_enc() const;
+ C to_enc() const;
- /// Assignment from equivalent type.
- E& operator=(const V& v);
+ /// Explicit convertion towards interoperation type.
+ N to_interop() const;
protected:
- enc v_; /// The actual value.
+ enc v_; /// The encoding value.
};
@@ -86,8 +90,8 @@
*
* \relates value_like_
*/
- template <typename V, typename E>
- bool operator=(const value_like_<V,E>& lhs, const value_like_<V,E>& rhs);
+ template <typename V, typename C, typename N, typename E>
+ bool operator=(const value_like_<V,C,N,E>& lhs, const value_like_<V,C,N,E>& rhs);
/*! \brief General definition of the "less than" operator
@@ -95,52 +99,45 @@
*
* \relates value_like_
*/
- template <typename V, typename E>
- bool operator<(const value_like_<V,E>& lhs, const value_like_<V,E>& rhs);
+ template <typename V, typename C, typename N, typename E>
+ bool operator<(const value_like_<V,C,N,E>& lhs, const value_like_<V,C,N,E>& rhs);
# ifndef MLN_INCLUDE_ONLY
- template <typename V, typename E>
- value_like_<V, E>::operator V() const
- {
- return v_;
- }
-
- template <typename V, typename E>
+ template <typename V, typename C, typename N, typename E>
V
- value_like_<V, E>::to_equiv() const
+ value_like_<V,C,N,E>::to_equiv() const
{
return v_;
}
- template <typename V, typename E>
- V
- value_like_<V, E>::to_enc() const
+ template <typename V, typename C, typename N, typename E>
+ C
+ value_like_<V,C,N,E>::to_enc() const
{
return v_;
}
- template <typename V, typename E>
- E&
- value_like_<V, E>::operator=(const V& v)
+ template <typename V, typename C, typename N, typename E>
+ N
+ value_like_<V,C,N,E>::to_interop() const
{
- v_ = v;
- return exact(*this);
+ return mln::internal::force_exact<E>(*this).operator N();
}
- template <typename V, typename E>
- bool operator=(const value_like_<V, E>& lhs,
- const value_like_<V, E>& rhs)
+ template <typename V, typename C, typename N, typename E>
+ bool operator=(const value_like_<V,C,N,E>& lhs,
+ const value_like_<V,C,N,E>& rhs)
{
- return V(lhs) = V(rhs);
+ return lhs.to_interop() = rhs.to_interop();
}
- template <typename V, typename E>
- bool operator<(const value_like_<V, E>& lhs,
- const value_like_<V, E>& rhs)
+ template <typename V, typename C, typename N, typename E>
+ bool operator<(const value_like_<V,C,N,E>& lhs,
+ const value_like_<V,C,N,E>& rhs)
{
- return V(lhs) < V(rhs);
+ return lhs.to_interop() < rhs.to_interop();
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/value/int_u.hh
--- mln/value/int_u.hh (revision 1271)
+++ mln/value/int_u.hh (working copy)
@@ -100,25 +100,29 @@
*/
template <unsigned n>
struct int_u
- : public Integer< int_u<n> >,
- public internal::value_like_< typename internal::encoding_unsigned_<n>::ret,
- int_u<n> >
+ :
+ public Integer< int_u<n> >,
+
+ public internal::value_like_< unsigned, // Equivalent.
+ typename internal::encoding_unsigned_<n>::ret, // Enc.
+ int, // Interoperation.
+ int_u<n> > // Exact.
{
protected:
- typedef internal::value_like_< typename internal::encoding_unsigned_<n>::ret,
- int_u<n> > super;
+ /// Encoding associated type.
+ typedef typename internal::encoding_unsigned_<n>::ret enc_;
public:
- /// Encoding associated type.
- typedef typename super::enc enc;
-
/// Constructor without argument.
int_u();
/// Constructor from an integer.
int_u(int i);
+ /// Conversion to an integer.
+ operator int() const;
+
/// Assignment from an integer.
int_u<n>& operator=(int i);
@@ -136,6 +140,7 @@
};
+
// Safety.
template <> struct int_u<0>;
template <> struct int_u<1>;
@@ -178,8 +183,14 @@
int_u<n>::int_u(int i)
{
mln_precondition(i >= 0);
- mln_precondition(unsigned(i) <= mln_max(enc));
- this->v_ = enc(i);
+ mln_precondition(unsigned(i) <= mln_max(enc_));
+ this->v_ = enc_(i);
+ }
+
+ template <unsigned n>
+ int_u<n>::operator int() const
+ {
+ return this->v_;
}
template <unsigned n>
@@ -187,7 +198,7 @@
int_u<n>::operator=(int i)
{
mln_precondition(i >= 0);
- mln_precondition(unsigned(i) <= mln_max(enc));
+ mln_precondition(unsigned(i) <= mln_max(enc_));
this->v_ = i;
return *this;
}
@@ -197,7 +208,7 @@
int_u<n>::operator+=(int i)
{
mln_precondition(long(this->v_) + i >= 0);
- mln_precondition(long(this->v_) + i <= mln_max(enc));
+ mln_precondition(long(this->v_) + i <= mln_max(enc_));
this->v_ += i;
return *this;
}
@@ -207,7 +218,7 @@
int_u<n>::operator-=(int i)
{
mln_precondition(long(this->v_) - i >= 0);
- mln_precondition(long(this->v_) - i <= mln_max(enc));
+ mln_precondition(long(this->v_) - i <= mln_max(enc_));
this->v_ -= i;
return *this;
}
Index: mln/value/int_u_sat.hh
--- mln/value/int_u_sat.hh (revision 1271)
+++ mln/value/int_u_sat.hh (working copy)
@@ -55,25 +55,23 @@
*/
template <unsigned n>
struct int_u_sat
- : public Integer< int_u_sat<n> >,
- public internal::value_like_< typename internal::encoding_unsigned_<n>::ret,
- int_u_sat<n> >
- {
- protected:
- typedef internal::value_like_< typename internal::encoding_unsigned_<n>::ret,
- int_u_sat<n> > like;
-
- public:
-
- /// Encoding associated type.
- typedef typename like::enc enc;
+ :
+ public Integer< int_u_sat<n> >,
+ public internal::value_like_< int_u<n>, // Equivalent.
+ mln_enc(int_u<n>), // Encoding.
+ int, // Interoperation.
+ int_u_sat<n> > // Exact.
+ {
/// Constructor without argument.
int_u_sat();
/// Constructor from an integer.
int_u_sat(int i);
+ /// Conversion to an integer.
+ operator int() const;
+
/// Assignment from an integer.
int_u_sat<n>& operator=(int i);
@@ -133,11 +131,17 @@
int_u_sat<n>::int_u_sat(int i)
{
if (i < 0)
- this->v_ = enc(0);
- else if (i > mln_max(enc))
- this->v_ = mln_max(enc);
+ this->v_ = 0;
+ else if (i > mln_max(int_u_sat<n>))
+ this->v_ = mln_max(int_u_sat<n>);
else
- this->v_ = enc(i);
+ this->v_ = i;
+ }
+
+ template <unsigned n>
+ int_u_sat<n>::operator int() const
+ {
+ return this->v_;
}
template <unsigned n>
@@ -145,11 +149,11 @@
int_u_sat<n>::operator=(int i)
{
if (i < 0)
- this->v_ = enc(0);
- else if (i > mln_max(enc))
- this->v_ = mln_max(enc);
+ this->v_ = 0;
+ else if (i > mln_max(int_u_sat<n>))
+ this->v_ = mln_max(int_u_sat<n>);
else
- this->v_ = enc(i);
+ this->v_ = i;
return *this;
}
Index: mln/value/float01.hh
--- mln/value/float01.hh (revision 1271)
+++ mln/value/float01.hh (working copy)
@@ -29,6 +29,7 @@
# define MLN_VALUE_FLOAT01_HH
# include <iostream>
+# include <utility>
# include <mln/core/concept/value.hh>
# include <mln/value/float01_.hh>
@@ -38,21 +39,23 @@
namespace mln
{
- // Fwd decls.
namespace value
{
- template <unsigned N> class float01_;
+
+ // Fwd decl.
+ template <unsigned n> class float01_;
class float01;
+
/// General float01_ class where n bits is not know at compile-time.
/// This class is used for exchange between float01_ types purpose.
- class float01 : public Value<float01>
+ class float01 : public Floating<float01>
{
public:
/// Encoding associated type.
- typedef float enc;
+ typedef std::pair<unsigned, unsigned long> enc;
/// Equivalent associated type.
typedef float equiv;
@@ -61,8 +64,8 @@
float01();
/// Ctor.
- template <unsigned N>
- float01(const float01_<N>& val);
+ template <unsigned n>
+ float01(const float01_<n>& val);
/// Ctor.
float01(unsigned nbits, float val);
@@ -73,12 +76,13 @@
unsigned nbits() const;
- void set_nbits(unsigned nbits);
+ float01& set_nbits(unsigned nbits);
+ const float01 to_nbits(unsigned nbits) const;
- float01 to_nbits(unsigned nbits) const;
+ operator float() const;
- template <unsigned N>
- operator float01_<N>() const;
+// template <unsigned n>
+// operator float01_<n>() const;
protected:
unsigned nbits_;
@@ -91,6 +95,7 @@
bool operator<(const float01& lhs, const float01& rhs);
+
# ifndef MLN_INCLUDE_ONLY
namespace internal
@@ -123,17 +128,18 @@
} // end of mln::value::internal
+
// Float01.
float01::float01()
- : nbits_(0)
+ : nbits_(0) // FIXME: Cost at run-time...
{
}
template <unsigned n>
float01::float01(const float01_<n>& g)
: nbits_(n),
- val_(g.value_ind())
+ val_(g.to_enc())
{
}
@@ -160,14 +166,13 @@
return nbits_;
}
-
-
- void float01::set_nbits(unsigned nbits)
+ float01&
+ float01::set_nbits(unsigned nbits)
{
mln_precondition(nbits != 0);
mln_invariant(nbits_ != 0);
if (nbits = nbits_)
- return;
+ return *this;
if (nbits > nbits_)
{
val_ *= internal::two_pow_n_minus_1(nbits);
@@ -178,10 +183,11 @@
val_ /= internal::two_pow_(nbits_ - nbits);
}
nbits_ = nbits;
+ return *this;
}
-
- float01 float01::to_nbits(unsigned nbits) const
+ const float01
+ float01::to_nbits(unsigned nbits) const
{
mln_precondition(nbits != 0);
mln_invariant(nbits_ != 0);
@@ -190,18 +196,25 @@
return tmp;
}
-
- template <unsigned n>
- float01::operator float01_<n>() const
+ float01::operator float() const
{
mln_precondition(nbits_ != 0);
- float01_<n> tmp;
- tmp.set_ind(internal::convert<n>(nbits_, val_));
- mln_assertion(tmp.value() < internal::two_pow_(n));
+ float tmp = float(val_) / internal::two_pow_n_minus_1(nbits_);
return tmp;
}
- // operators
+// template <unsigned n>
+// float01::operator float01_<n>() const
+// {
+// mln_precondition(nbits_ != 0);
+// float01_<n> tmp;
+// tmp.set_ind(internal::convert<n>(nbits_, val_));
+// mln_assertion(tmp.value() < internal::two_pow_(n));
+// return tmp;
+// }
+
+
+ // Operators.
std::ostream& operator<<(std::ostream& ostr, const float01& g)
{
Index: mln/value/float01_f.hh
--- mln/value/float01_f.hh (revision 1271)
+++ mln/value/float01_f.hh (working copy)
@@ -40,22 +40,24 @@
{
/// Fwd decl.
- class float01;
+ struct float01;
/// General float01-level class on n bits.
- class float01_f
- : public Floating< float01_f >,
- public internal::value_like_< float,
- float01_f >
+ struct float01_f
+ :
+ public Floating< float01_f >,
+
+ public internal::value_like_< float, // Equivalent.
+ float, // Encoding.
+ float, // Interoperation.
+ float01_f > // Exact.
{
- public:
-
/// Ctor.
float01_f();
/// Ctor.
- float01_f(const float val);
+ float01_f(float val);
/// Access to std type.
float value() const;
@@ -64,13 +66,9 @@
operator float() const;
float01_f& operator=(const float val);
- /// Op=.
- // bool operator=(const float01_f& rhs) const;
-
- protected:
- float val_;
};
+
template <>
struct props< float01_f >
{
@@ -83,47 +81,47 @@
typedef float interop;
};
+
# ifndef MLN_INCLUDE_ONLY
// Float01_F.
float01_f::float01_f()
- : val_(0)
{
}
- float01_f::float01_f(const float val)
- : val_(val)
+ float01_f::float01_f(float val)
{
mln_precondition(val >= 0);
mln_precondition(val <= 1);
+ this->v_ = val;
}
float
float01_f::value() const
{
- return (val_);
+ return this->v_;
}
float01_f&
- float01_f::operator=(const float val)
+ float01_f::operator=(float val)
{
mln_precondition(val >= 0);
mln_precondition(val <= 1);
- this->val_ = val;
+ this->v_ = val;
return *this;
}
float01_f::operator float() const
{
- return val_;
+ return this->v_;
}
-# endif
-
+# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::value
} // end of namespace mln
+
#endif // ! MLN_CORE_VALUE_FLOAT01_F_HH
1
0
milena r1271: Move color_sub from sandbox into color_pretty in a new folder : display
by Guillaume Duhamel 08 Oct '07
by Guillaume Duhamel 08 Oct '07
08 Oct '07
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-08 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Move color_sub from sandbox into color_pretty in a new folder : display.
* display/color_pretty.hh: New.
* display: New folder for display.
---
color_pretty.hh | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 97 insertions(+)
Index: trunk/milena/mln/display/color_pretty.hh
===================================================================
--- trunk/milena/mln/display/color_pretty.hh (revision 0)
+++ trunk/milena/mln/display/color_pretty.hh (revision 1271)
@@ -0,0 +1,97 @@
+// 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 MLN_DISPLAY_COLOR_PRETTY_HH
+# define MLN_DISPLAY_COLOR_PRETTY_HH
+
+/*! \file mln/display/color_pretty.hh
+ *
+ * \brief Create a pretty image, which display its content
+ * with red value for non-defined point site.
+ */
+
+# include <mln/trait/image_from_mesh.hh>
+# include <mln/core/image_if_value.hh>
+# include <mln/core/image2d_b.hh>
+# include <mln/value/rgb8.hh>
+# include <mln/level/fill.hh>
+# include <mln/level/paste.hh>
+
+
+namespace mln
+{
+
+ namespace display
+ {
+
+ template <typename I>
+ typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret
+ color_pretty(const Image<I>& input_);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ template <typename I>
+ typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret
+ color_pretty(const Image<I>& input_)
+ {
+ const I& input = exact (input_);
+
+ image2d_b<value::rgb8> output(input.domain().bbox());
+ level::fill(output, value::rgb8(255, 0, 0));
+
+// /// FIXME by :
+// level::paste(input, output);
+ {
+ mln_piter(I) p(input.domain());
+
+ for_all(p)
+ output(p) = value::rgb8(input(p));
+ }
+ return output;
+ }
+
+ } // end of namespace mln::display::impl
+
+ /// Facade.
+ template <typename I>
+ typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret
+ color_pretty(const Image<I>& input_)
+ {
+ return impl::color_pretty(input_);
+ }
+
+# endif // !MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::display
+
+} // end of namespace mln
+
+
+#endif // ! MLN_DISPLAY_COLOR_PRETTY_HH
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-08 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add test for color pretty.
* color_pretty.cc: New test for color pretty.
Update
* chamfer.cc: Update.
---
color_pretty.cc | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)
Index: trunk/milena/tests/chamfer.cc
===================================================================
Index: trunk/milena/tests/color_pretty.cc
===================================================================
--- trunk/milena/tests/color_pretty.cc (revision 0)
+++ trunk/milena/tests/color_pretty.cc (revision 1270)
@@ -0,0 +1,71 @@
+// 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 tests/sub_image.cc
+ *
+ * \brief Tests on mln::sub_image.
+ */
+
+# include <mln/core/image2d_b.hh>
+# include <mln/io/pbm/load.hh>
+# include <mln/make/win_chamfer.hh>
+# include <mln/geom/chamfer.hh>
+# include <mln/value/rgb8.hh>
+# include <mln/core/sub_image.hh>
+# include <mln/core/image_if_value.hh>
+# include <mln/core/inplace.hh>
+# include <mln/core/w_window2d_int.hh>
+# include <mln/display/color_pretty.hh>
+# include <mln/io/ppm/save.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ unsigned max = 51;
+
+
+ image2d_b<bool> input = io::pbm::load("../img/toto.pbm");
+
+ // Create a weighted windows :
+ // 0 2 0
+ // 2 p 2
+ // 0 2 0
+ const w_window2d_int& w_win = win_chamfer::mk_chamfer_3x3_int<2, 0> ();
+
+ // Call chamfer for a distance image.
+ image2d_b<unsigned> tmp = geom::chamfer(input, w_win, max);
+
+ // Call color_pretty for sub_image.
+ image2d_b<value::rgb8> out = display::color_pretty(inplace (tmp | 4));
+
+ // Save output image from color in out.ppm.
+ io::ppm::save(out, "out.ppm");
+
+ std::cout << "out.ppm generate" << std::endl;
+}
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-08 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Add hexa images.
* mln/core/box2d_h.hh: New.
* mln/core/dpoint2d_h.hh: New.
* mln/core/hexa.hh: New.
* mln/core/point2d_h.hh: New.
* mln/make/box2d_h.hh: New.
* mln/make/dpoint2d_h.hh: New.
* mln/make/point2d_h.hh: New.
* tests/hexa.cc: New, Fixme : write more tests.
---
mln/core/box2d_h.hh | 58 ++++++++++++
mln/core/dpoint2d_h.hh | 68 ++++++++++++++
mln/core/hexa.hh | 230 +++++++++++++++++++++++++++++++++++++++++++++++++
mln/core/point2d_h.hh | 56 +++++++++++
mln/make/box2d_h.hh | 101 +++++++++++++++++++++
mln/make/dpoint2d_h.hh | 72 +++++++++++++++
mln/make/point2d_h.hh | 72 +++++++++++++++
tests/hexa.cc | 47 ++++++++++
8 files changed, 704 insertions(+)
Index: trunk/milena/tests/hexa.cc
===================================================================
--- trunk/milena/tests/hexa.cc (revision 0)
+++ trunk/milena/tests/hexa.cc (revision 1269)
@@ -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 tests/hexa.cc
+ *
+ * \brief Tests on mln::hexa
+ */
+
+#include <mln/core/image2d_b.hh>
+#include <mln/core/hexa.hh>
+
+#include <mln/value/int_u8.hh>
+
+int main()
+{
+ using namespace mln;
+ using typename value::int_u8;
+
+ typedef image2d_b<int_u8> I;
+
+ I ima(3,3);
+ hexa< I > h(ima);
+}
Index: trunk/milena/mln/core/hexa.hh
===================================================================
--- trunk/milena/mln/core/hexa.hh (revision 0)
+++ trunk/milena/mln/core/hexa.hh (revision 1269)
@@ -0,0 +1,230 @@
+// 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 MLN_CORE_HEXA_HH
+# define MLN_CORE_HEXA_HH
+
+
+/*! \file mln/core/hexa.hh
+ *
+ * \brief Definition of the mln::hexa class.
+ */
+
+# include <mln/core/internal/image_domain_morpher.hh>
+# include <mln/core/point2d_h.hh>
+
+
+namespace mln
+{
+ // Fwd decl.
+ template <typename I> class hexa;
+
+
+ namespace internal
+ {
+
+ template <typename I>
+ struct data_< hexa<I> >
+ {
+ data_(I& ima);
+
+ I ima_;
+ };
+
+ } // end of namespace mln::internal
+
+
+ namespace trait
+ {
+
+ template <typename I>
+ struct image_< hexa<I> > : default_image_morpher_< I, mln_value(I),
+ hexa<I> >
+ {
+ // private:
+ // typedef mln_trait_image_data(I) I_data_;
+ // typedef mlc_equal(I_data_, trait::data::linear) I_data_are_linear_;
+ // public:
+
+ typedef trait::image::category::domain_morpher category;
+
+ typedef trait::image::border::none border; // no more accessible border
+
+ typedef mln_trait_image_io_from_(I) io; // un-write when I const
+
+ typedef mln_trait_image_data_from_(I) data;
+ // typedef mlc_if( I_data_are_linear_,
+ // trait::data::stored, // if linear then just stored
+ // I_data_ ) data; // otherwise like I
+ };
+
+ } // end of namespace mln::trait
+
+
+ /*! \brief hexagonal image class.
+ *
+ * The parameter \c I is the type of the base image. This image class
+ * which handles hexagonal grid.
+ */
+ template <typename I>
+ struct hexa : public internal::image_domain_morpher_< I, mln_pset(I), hexa<I> >
+ {
+ /// Skeleton.
+ typedef hexa< tag::image_<I> > skeleton;
+
+ /// Value associated type.
+ typedef mln_value(I) value;
+
+ /// Lvalue associated type.
+ typedef mln_value(I) lvalue;
+
+ /// Return type of read-only access.
+ typedef mln_rvalue(I) rvalue;
+
+ /// Point site type
+ typedef point2d_h psite;
+
+ /// Constructor without argument.
+ hexa();
+
+ /// Constructor with an base image.
+ hexa(I& ima);
+
+ /// Initialization.
+ void init_(I& ima);
+
+ /// Give the definition domain.
+ const mln_pset(I)& domain() const;
+
+ /// Test if \p p belongs to the image domain.
+ bool has(const psite& p) const;
+ bool owns_(const psite& p) const;
+
+ /// Read-only access of pixel value at hexa point site \p p.
+ rvalue operator()(const point2d_h& p) const;
+
+ /// Read-write access of pixel value at hexa point site \p p.
+ value operator()(const point2d_h& p);
+ };
+
+ template <typename I, typename J>
+ void init_(tag::image_t, hexa<I>& target, const J& model);
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // init_
+
+ template <typename I, typename J>
+ void init_(tag::image_t, hexa<I>& target, const J& model)
+ {
+ I ima;
+ init_(tag::image, ima, model);
+ target.init_(ima);
+ }
+
+
+
+ // internal::data_< hexa<I> >
+
+ namespace internal
+ {
+
+ template <typename I>
+ data_< hexa<I> >::data_(I& ima)
+ : ima_(ima)
+ {
+ }
+
+ } // end of namespace mln::internal
+
+
+ template <typename I>
+ void
+ hexa<I>::init_(I& ima)
+ {
+ mln_precondition(! this->has_data());
+ this->data_ = new internal::data_< hexa<I> >(ima);
+ }
+
+
+
+ template <typename I>
+ hexa<I>::hexa()
+ {
+ }
+
+
+ template <typename I>
+ hexa<I>::hexa(I& ima)
+ {
+ this->init_(ima);
+ }
+
+ template <typename I>
+ typename hexa<I>::rvalue
+ hexa<I>::operator()(const point2d_h& p) const
+ {
+ return this->data_->ima_(make::point2d(p[0] / 2, p[1] / 2));
+ }
+
+ template <typename I>
+ typename hexa<I>::value
+ hexa<I>::operator()(const point2d_h& p)
+ {
+ return this->data_->ima_(make::point2d(p[0] / 2, p[1] / 2));
+ }
+
+ template <typename I>
+ const mln_pset(I)&
+ hexa<I>::domain() const
+ {
+ return this->data_->ima_.domain();
+ }
+
+ template <typename I>
+ bool
+ hexa<I>::has(const psite& p) const
+ {
+ return this->data_->ima_.has(make::point2d(p[0] / 2, p[1] / 2));
+ }
+
+
+ template <typename I>
+ bool
+ hexa<I>::owns_(const psite& p) const
+ {
+ return this->has(p);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_HEXA_HH
Index: trunk/milena/mln/core/dpoint2d_h.hh
===================================================================
--- trunk/milena/mln/core/dpoint2d_h.hh (revision 0)
+++ trunk/milena/mln/core/dpoint2d_h.hh (revision 1269)
@@ -0,0 +1,68 @@
+// 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 MLN_CORE_DPOINT2D_H_HH
+# define MLN_CORE_DPOINT2D_H_HH
+
+/*! \file mln/core/dpoint2d_h.hh
+ *
+ * \brief Definition of the mln::dpoint2d_h alias and of its
+ * construction routine.
+ */
+
+# include <mln/core/dpoint.hh>
+
+
+namespace mln
+{
+
+ /*! \brief Type alias for a delta-point defined on the 2D square
+ * grid with integer coordinates.
+ */
+ typedef dpoint_<grid::hexa, int> dpoint2d_h;
+
+
+} // end of namespace mln
+
+
+# include <mln/make/dpoint2d_h.hh>
+# include <mln/core/point2d_h.hh>
+
+
+namespace mln
+{
+
+ // FIXME: Doc!
+ const dpoint2d_h up_h = make::dpoint2d_h( -1, 0 );
+ const dpoint2d_h down_h = make::dpoint2d_h( +1, 0 );
+ const dpoint2d_h left_h = make::dpoint2d_h( 0, -1 );
+ const dpoint2d_h right_h = make::dpoint2d_h( 0, +1 );
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_DPOINT2D_H_HH
Index: trunk/milena/mln/core/box2d_h.hh
===================================================================
--- trunk/milena/mln/core/box2d_h.hh (revision 0)
+++ trunk/milena/mln/core/box2d_h.hh (revision 1269)
@@ -0,0 +1,58 @@
+// 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 MLN_CORE_BOX2D_HH
+# define MLN_CORE_BOX2D_HH
+
+/*! \file mln/core/box2d.hh
+ *
+ * \brief Definition of the mln::box2d alias and of construction
+ * routines.
+ */
+
+# include <mln/core/box.hh>
+# include <mln/core/point2d_h.hh>
+
+
+namespace mln
+{
+
+ /*! \brief Type alias for a box defined on the 2D square grid with
+ * integer coordinates.
+ *
+ * \see mln::win::rectangle2d.
+ */
+ typedef box_<point2d_h> box2d_h;
+
+
+} // end of namespace mln
+
+
+# include <mln/make/box2d_h.hh>
+
+
+#endif // ! MLN_CORE_BOX2D_HH
Index: trunk/milena/mln/core/point2d_h.hh
===================================================================
--- trunk/milena/mln/core/point2d_h.hh (revision 0)
+++ trunk/milena/mln/core/point2d_h.hh (revision 1269)
@@ -0,0 +1,56 @@
+// 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 MLN_CORE_POINT2D_H_HH
+# define MLN_CORE_POINT2D_H_HH
+
+/*! \file mln/core/point2d_h.hh
+ *
+ * \brief Definition of the mln::point2d_h alias and of its construction
+ * routine.
+ */
+
+# include <mln/core/point.hh>
+
+
+namespace mln
+{
+
+ /*! \brief Type alias for a point defined on the 2D square grid with
+ * integer coordinates.
+ */
+ typedef point_<grid::hexa, int> point2d_h;
+
+
+} // end of namespace mln
+
+
+# include <mln/make/point2d_h.hh>
+# include <mln/core/dpoint2d_h.hh>
+
+
+#endif // ! MLN_CORE_POINT2D_H_HH
Index: trunk/milena/mln/make/box2d_h.hh
===================================================================
--- trunk/milena/mln/make/box2d_h.hh (revision 0)
+++ trunk/milena/mln/make/box2d_h.hh (revision 1269)
@@ -0,0 +1,101 @@
+// 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 MLN_MAKE_BOX2D_H_HH
+# define MLN_MAKE_BOX2D_H_HH
+
+/*! \file mln/make/box2d_h.hh
+ *
+ * \brief Routines to construct an mln::box2d_h.
+ */
+
+# include <mln/core/box2d_h.hh>
+# include <mln/make/point2d_h.hh>
+
+
+namespace mln
+{
+
+ namespace make
+ {
+
+ /*! \brief Create an mln::box2d_h.
+ *
+ * \param[in] nrows Number of rows.
+ * \param[in] ncols Number of columns.
+ *
+ * \pre \p nrows != 0 and \p ncols != 0.
+ *
+ * \return A 2D_H box.
+ */
+ mln::box2d_h box2d_h(unsigned nrows, unsigned ncols);
+
+
+ /*! \brief Create an mln::box2d_h.
+ *
+ * \overload
+ *
+ * \param[in] min_row Index of the top most row.
+ * \param[in] min_col Index of the left most column.
+ * \param[in] max_row Index of the botton most row.
+ * \param[in] max_col Index of the right most column.
+ *
+ * \pre \p max_row >= \p min_row and \p max_col >= \p min_col.
+ *
+ * \return A 2D_H box.
+ */
+ mln::box2d_h box2d_h(int min_row, int min_col,
+ int max_row, int max_col);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ mln::box2d_h box2d_h(unsigned nrows, unsigned ncols)
+ {
+ mln_precondition(nrows != 0 && ncols != 0);
+ mln::box2d_h tmp(make::point2d_h(0, 0),
+ make::point2d_h(nrows - 1, ncols - 1));
+ return tmp;
+ }
+
+ mln::box2d_h box2d_h(int min_row, int min_col,
+ int max_row, int max_col)
+ {
+ mln_precondition(max_row >= min_row && max_col >= min_col);
+ mln::box2d_h tmp(make::point2d_h(min_row, min_col),
+ make::point2d_h(max_row, max_col));
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::make
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MAKE_BOX2D_H_HH
Index: trunk/milena/mln/make/point2d_h.hh
===================================================================
--- trunk/milena/mln/make/point2d_h.hh (revision 0)
+++ trunk/milena/mln/make/point2d_h.hh (revision 1269)
@@ -0,0 +1,72 @@
+// 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 MLN_MAKE_POINT2D_H_HH
+# define MLN_MAKE_POINT2D_H_HH
+
+/*! \file mln/make/point2d_h.hh
+ *
+ * \brief Routine to construct an mln::point2d_h.
+ */
+
+# include <mln/core/point2d_h.hh>
+
+
+namespace mln
+{
+
+ namespace make
+ {
+
+ /*! \brief Create an mln::point2d_h.
+ *
+ * \param[in] row Row coordinate.
+ * \param[in] col Column coordinate.
+ *
+ * \return A 2D point.
+ */
+ mln::point2d_h point2d_h(int row, int col);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ mln::point2d_h point2d_h(int row, int col)
+ {
+ mln::point2d_h tmp;
+ tmp[0] = row;
+ tmp[1] = col;
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::make
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MAKE_POINT2D_H_HH
Index: trunk/milena/mln/make/dpoint2d_h.hh
===================================================================
--- trunk/milena/mln/make/dpoint2d_h.hh (revision 0)
+++ trunk/milena/mln/make/dpoint2d_h.hh (revision 1269)
@@ -0,0 +1,72 @@
+// 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 MLN_MAKE_DPOINT2D_H_HH
+# define MLN_MAKE_DPOINT2D_H_HH
+
+/*! \file mln/make/dpoint2d_h.hh
+ *
+ * \brief Routine to construct an mln::dpoint2d_h.
+ */
+
+# include <mln/core/dpoint2d_h.hh>
+
+
+namespace mln
+{
+
+ namespace make
+ {
+
+ /*! \brief Create an mln::dpoint2d_h.
+ *
+ * \param[in] row Row coordinate.
+ * \param[in] col Column coordinate.
+ *
+ * \return A 2D dpoint.
+ */
+ mln::dpoint2d_h dpoint2d_h(int row, int col);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ mln::dpoint2d_h dpoint2d_h(int row, int col)
+ {
+ mln::dpoint2d_h tmp;
+ tmp[0] = row;
+ tmp[1] = col;
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::make
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MAKE_DPOINT2D_H_HH
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix value concepts and related file inclusions.
* tests/value_scalar.cc: New.
* tests/value_gray.cc: Rename as...
* tests/value_graylevel.cc: ...this.
(assert): Change to...
(mln_assertion): ...this!
* tests/trait_op_plus.cc,
* mln/metal/mat.hh,
* mln/metal/vec.hh: Include value concepts.
* mln/trait/image/print.hh: (print). New overload.
* mln/trait/op: New directory; to be populated.
* mln/core/ops.hh: Remove dead code.
* mln/value/graylevel.hh: Layout.
* mln/value/scalar.hh: New.
* mln/value/builtin.hh: Replace includes by decls.
* mln/value/concept/symbolic.hh,
* mln/value/concept/floating.hh,
* mln/value/concept/integer.hh,
* mln/value/concept/structured.hh,
* mln/value/concept/scalar.hh,
* mln/value/concept/vectorial.hh: Fix.
* mln/value/concept/all.hh: New.
mln/core/ops.hh | 13 +++
mln/metal/mat.hh | 1
mln/metal/vec.hh | 1
mln/trait/image/print.hh | 9 ++
mln/value/builtin.hh | 14 +--
mln/value/concept/all.hh | 43 +++++++++++
mln/value/concept/floating.hh | 21 +++--
mln/value/concept/integer.hh | 22 ++++--
mln/value/concept/scalar.hh | 18 +++--
mln/value/concept/structured.hh | 23 ++++--
mln/value/concept/symbolic.hh | 21 ++++-
mln/value/concept/vectorial.hh | 21 ++++-
mln/value/graylevel.hh | 3
mln/value/scalar.hh | 144 ++++++++++++++++++++++++++++++++++++++++
tests/trait_op_plus.cc | 1
tests/value_graylevel.cc | 16 +++-
tests/value_scalar.cc | 51 ++++++++++++++
17 files changed, 372 insertions(+), 50 deletions(-)
Index: tests/value_scalar.cc
--- tests/value_scalar.cc (revision 0)
+++ tests/value_scalar.cc (revision 0)
@@ -0,0 +1,51 @@
+// 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 tests/value_scalar.cc
+ *
+ * \brief Tests on mln::value::scalar.
+ */
+
+#include <iostream>
+#include <mln/value/scalar.hh>
+
+
+template <typename T>
+void foo(const T& t)
+{
+ std::cout << mln::value::scalar(t) << std::endl;
+}
+
+
+int main()
+{
+ using namespace mln;
+
+ int i = 51;
+ foo(i);
+ foo( value::scalar(i) );
+}
Index: tests/trait_op_plus.cc
--- tests/trait_op_plus.cc (revision 1267)
+++ tests/trait_op_plus.cc (working copy)
@@ -31,6 +31,7 @@
*/
#include <mln/core/concept/image.hh>
+#include <mln/value/concept/all.hh>
#include <mln/trait/op_plus.hh>
Index: tests/value_graylevel.cc
--- tests/value_graylevel.cc (revision 1264)
+++ tests/value_graylevel.cc (working copy)
@@ -25,22 +25,30 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
+/*! \file tests/value_graylevel.cc
+ *
+ * \brief Tests on mln::value::graylevel.
+ */
+
#include <mln/value/graylevel.hh>
+
int main()
{
using namespace mln::value;
gl8 a = white;
gl16 b = white;
- assert((a = b) = true);
+ mln_assertion(a = b);
+
gl8 c = (a + b) / 2;
- assert(c = white);
+ mln_assertion(c = white);
+
c = a;
- assert(c = white);
+ mln_assertion(c = white);
c = (a * 2) / 2;
- assert(c = white);
+ mln_assertion(c = white);
c = c / 6;
}
Index: mln/trait/image/print.hh
--- mln/trait/image/print.hh (revision 1267)
+++ mln/trait/image/print.hh (working copy)
@@ -55,6 +55,9 @@
template <typename I>
void print(std::ostream& ostr);
+ template <typename I>
+ void print(const Image<I>& ima, std::ostream& ostr);
+
# ifndef MLN_INCLUDE_ONLY
@@ -78,6 +81,12 @@
<< typename the::speed() .name() << " }" << std::endl;
}
+ template <typename I>
+ void print(const Image<I>&, std::ostream& ostr)
+ {
+ print<I>(ostr);
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::trait::image
Index: mln/core/ops.hh
--- mln/core/ops.hh (revision 1267)
+++ mln/core/ops.hh (working copy)
@@ -99,6 +99,18 @@
// Operator +.
+ // FIXME HERE
+
+// namespace trait {
+
+// template < typename L, typename R >
+// struct set_binary_< op_plus, Built_In, L, Object, R >
+// {
+// typedef mln_trait_op_plus(R, L)
+// };
+
+// }
+
// FIXME: Doc!
template <typename O>
mln_trait_op_plus(O, int)
@@ -123,6 +135,7 @@
return exact(rhs) + lhs;
}
+
// Operator *.
// FIXME: Doc!
Index: mln/metal/mat.hh
--- mln/metal/mat.hh (revision 1267)
+++ mln/metal/mat.hh (working copy)
@@ -34,6 +34,7 @@
# include <mln/core/contract.hh>
# include <mln/trait/all.hh>
# include <mln/value/props.hh>
+# include <mln/value/concept/all.hh>
// FIXME: Document.
Index: mln/metal/vec.hh
--- mln/metal/vec.hh (revision 1267)
+++ mln/metal/vec.hh (working copy)
@@ -36,6 +36,7 @@
# include <mln/value/props.hh>
# include <mln/fun/i2v/all.hh>
# include <mln/literal/zero.hh>
+# include <mln/value/concept/all.hh>
// FIXME: Document.
Index: mln/value/graylevel.hh
--- mln/value/graylevel.hh (revision 1267)
+++ mln/value/graylevel.hh (working copy)
@@ -29,15 +29,18 @@
# define MLN_CORE_VALUE_GRAYLEVEL_HH
# include <iostream>
+
# include <mln/core/contract.hh>
# include <mln/metal/math.hh>
# include <mln/metal/bexpr.hh>
+
# include <mln/value/internal/value_like.hh>
# include <mln/value/concept/integer.hh>
# include <mln/value/internal/encoding.hh>
# include <mln/value/gray.hh>
# include <mln/value/props.hh>
+
namespace mln
{
Index: mln/value/scalar.hh
--- mln/value/scalar.hh (revision 0)
+++ mln/value/scalar.hh (revision 0)
@@ -0,0 +1,144 @@
+// Copyright (C) 2006, 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 MLN_VALUE_SCALAR_HH
+# define MLN_VALUE_SCALAR_HH
+
+# include <mln/value/concept/scalar.hh>
+# include <mln/metal/is_a.hh>
+# include <mln/metal/if.hh>
+
+
+
+namespace mln
+{
+
+ namespace value
+ {
+
+ template <typename T>
+ class scalar_ : public Scalar< scalar_<T> >
+ {
+ public:
+
+ /// Encoding associated type.
+ typedef T enc; // FIXME
+
+ /// Equivalent associated type.
+ typedef T equiv; // FIXME
+
+
+ /// Ctor.
+ scalar_();
+
+ /// Ctor.
+ scalar_(const T& val);
+
+ /// Conversion.
+ operator T() const;
+
+ protected:
+ T val_; // FIXME: const&?
+ };
+
+
+ template <typename T>
+ class scalar_< scalar_<T> >; // Safety.
+
+
+
+ template <typename T>
+ std::ostream& operator<<(std::ostream& ostr, const scalar_<T>& s);
+
+
+
+ namespace internal
+ {
+
+ template <typename T>
+ struct helper_scalar_
+ {
+ typedef mlc_is_a(T, Scalar) is_scalar_;
+ typedef mlc_if(is_scalar_, T, scalar_<T>) ret;
+ };
+
+ } // end of namespace mln::value::internal
+
+
+ // Routine.
+ template <typename T>
+ typename internal::helper_scalar_<T>::ret
+ scalar(const T& s); // FIXME: if T already is a scalar_...
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // scalar_<T>.
+
+ template <typename T>
+ scalar_<T>::scalar_()
+ {
+ }
+
+ template <typename T>
+ scalar_<T>::scalar_(const T& val)
+ : val_(val)
+ {
+ }
+
+ template <typename T>
+ scalar_<T>::operator T() const
+ {
+ return val_;
+ }
+
+ // Operator.
+
+ template <typename T>
+ std::ostream& operator<<(std::ostream& ostr, const scalar_<T>& s)
+ {
+ return ostr << T(s);
+ }
+
+ // Routine.
+
+ template <typename T>
+ typename internal::helper_scalar_<T>::ret
+ scalar(const T& s)
+ {
+ return s;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::value
+
+} // end of namespace mln
+
+
+#endif // ! MLN_VALUE_SCALAR_HH
Index: mln/value/builtin.hh
--- mln/value/builtin.hh (revision 1267)
+++ mln/value/builtin.hh (working copy)
@@ -32,16 +32,19 @@
* \brief Some definitions about builtins.
*/
-# include <mln/value/concept/symbolic.hh>
-# include <mln/value/concept/integer.hh>
-# include <mln/value/concept/floating.hh>
+# include <mln/core/category.hh>
+
namespace mln
{
// Fwd decl.
template <typename E> struct Value;
-
+ namespace value {
+ template <typename E> struct Symbolic;
+ template <typename E> struct Integer;
+ template <typename E> struct Floating;
+ }
// The case of built-in types.
@@ -68,7 +71,4 @@
} // end of namespace mln
-# include <mln/core/concept/value.hh>
-
-
#endif // ! MLN_VALUE_BUILTIN_HH
Index: mln/value/concept/symbolic.hh
--- mln/value/concept/symbolic.hh (revision 1267)
+++ mln/value/concept/symbolic.hh (working copy)
@@ -25,19 +25,26 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_VALUE_CONCEPT_VALUE_SYMBOLIC_HH
-# define MLN_VALUE_CONCEPT_VALUE_SYMBOLIC_HH
+#ifndef MLN_VALUE_CONCEPT_SYMBOLIC_HH
+# define MLN_VALUE_CONCEPT_SYMBOLIC_HH
-/*! \file mln/value/symbolic.hh
+/*! \file mln/value/concept/symbolic.hh
*
* \brief Define a generic class for symbolic values.
*/
+# include <mln/core/concept/value.hh>
+
+
namespace mln
{
- // Fwd decl.
+ // Fwd decls.
template <typename E> struct Value;
+ namespace value
+ {
+ template <typename E> struct Symbolic;
+ }
namespace trait
{
@@ -68,6 +75,8 @@
} // end of namespace mln
-# include <mln/core/concept/value.hh>
-#endif // ! MLN_VALUE_CONCEPT_VALUE_SYMBOLIC_HH
+# include <mln/value/concept/all.hh>
+
+
+#endif // ! MLN_VALUE_CONCEPT_SYMBOLIC_HH
Index: mln/value/concept/floating.hh
--- mln/value/concept/floating.hh (revision 1267)
+++ mln/value/concept/floating.hh (working copy)
@@ -25,19 +25,26 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_VALUE_CONCEPT_VALUE_FLOATING_HH
-# define MLN_VALUE_CONCEPT_VALUE_FLOATING_HH
+#ifndef MLN_VALUE_CONCEPT_FLOATING_HH
+# define MLN_VALUE_CONCEPT_FLOATING_HH
-/*! \file mln/value/floating.hh
+/*! \file mln/value/concept/floating.hh
*
* \brief Define a generic class for float values.
*/
# include <mln/value/concept/scalar.hh>
+
namespace mln
{
+ // Fwd decl.
+ namespace value
+ {
+ template <typename E> struct Floating;
+ }
+
namespace trait
{
// FIXME
@@ -46,9 +53,6 @@
namespace value
{
- // Fwd decl.
- template <typename E> struct Floating;
-
// Category flag type.
template <>
struct Floating<void>
@@ -66,4 +70,7 @@
} // end of namespace mln
-#endif // ! MLN_VALUE_CONCEPT_VALUE_FLOATING_HH
+# include <mln/value/concept/all.hh>
+
+
+#endif // ! MLN_VALUE_CONCEPT_FLOATING_HH
Index: mln/value/concept/structured.hh
--- mln/value/concept/structured.hh (revision 1267)
+++ mln/value/concept/structured.hh (working copy)
@@ -25,29 +25,36 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_VALUE_CONCEPT_VALUE_STRUCTURED_HH
-# define MLN_VALUE_CONCEPT_VALUE_STRUCTURED_HH
+#ifndef MLN_VALUE_CONCEPT_STRUCTURED_HH
+# define MLN_VALUE_CONCEPT_STRUCTURED_HH
-/*! \file mln/value/structured.hh
+/*! \file mln/value/concept/structured.hh
*
* \brief Define a generic class for structured values.
*/
+# include <mln/core/concept/value.hh>
+
+
namespace mln
{
// Fwd decl.
- template <typename E> struct Value;
+ namespace value
+ {
+ template <typename E> struct Structured;
+ }
+
namespace trait
{
// FIXME
} // end of namespace mln::trait
+
namespace value
{
-
// Fwd decl.
template <typename E> struct Structured;
@@ -67,6 +74,8 @@
} // end of namespace mln
-# include <mln/core/concept/value.hh>
-#endif // ! MLN_VALUE_CONCEPT_VALUE_STRUCTURED_HH
+# include <mln/value/concept/all.hh>
+
+
+#endif // ! MLN_VALUE_CONCEPT_STRUCTURED_HH
Index: mln/value/concept/scalar.hh
--- mln/value/concept/scalar.hh (revision 1267)
+++ mln/value/concept/scalar.hh (working copy)
@@ -25,19 +25,26 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_VALUE_CONCEPT_VALUE_SCALAR_HH
-# define MLN_VALUE_CONCEPT_VALUE_SCALAR_HH
+#ifndef MLN_VALUE_CONCEPT_SCALAR_HH
+# define MLN_VALUE_CONCEPT_SCALAR_HH
-/*! \file mln/value/scalar.hh
+/*! \file mln/value/concept/scalar.hh
*
* \brief Define a generic class for scalar values.
*/
+# include <mln/core/concept/value.hh>
+
+
namespace mln
{
- // Fwd decl.
+ // Fwd decls.
template <typename E> struct Value;
+ namespace value
+ {
+ template <typename E> struct Scalar;
+ }
namespace trait
{
@@ -66,6 +73,5 @@
} // end of namespace mln
-# include <mln/core/concept/value.hh>
-#endif // ! MLN_VALUE_CONCEPT_VALUE_SCALAR_HH
+#endif // ! MLN_VALUE_CONCEPT_SCALAR_HH
Index: mln/value/concept/vectorial.hh
--- mln/value/concept/vectorial.hh (revision 1267)
+++ mln/value/concept/vectorial.hh (working copy)
@@ -25,19 +25,25 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_VALUE_CONCEPT_VALUE_VECTORIEL_HH
-# define MLN_VALUE_CONCEPT_VALUE_VECTORIEL_HH
+#ifndef MLN_VALUE_CONCEPT_VECTORIAL_HH
+# define MLN_VALUE_CONCEPT_VECTORIAL_HH
-/*! \file mln/value/vectorial.hh
+/*! \file mln/value/concept/vectorial.hh
*
* \brief Define a generic class for vectorial values.
*/
+# include <mln/core/concept/value.hh>
+
+
namespace mln
{
// Fwd decl.
- template <typename E> struct Value;
+ namespace value
+ {
+ template <typename E> struct Vectorial;
+ }
namespace trait
{
@@ -46,6 +52,7 @@
} // end of namespace mln::trait
+
namespace value
{
@@ -68,6 +75,8 @@
} // end of namespace mln
-# include <mln/core/concept/value.hh>
-#endif // ! MLN_VALUE_CONCEPT_VALUE_VECTORIEL_HH
+# include <mln/value/concept/all.hh>
+
+
+#endif // ! MLN_VALUE_CONCEPT_VECTORIAL_HH
Index: mln/value/concept/all.hh
--- mln/value/concept/all.hh (revision 0)
+++ mln/value/concept/all.hh (revision 0)
@@ -0,0 +1,43 @@
+// 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 MLN_VALUE_CONCEPT_ALL_HH
+# define MLN_VALUE_CONCEPT_ALL_HH
+
+/*! \file mln/value/concept/all.hh
+ *
+ * \brief FIXME
+ */
+
+# include <mln/value/concept/integer.hh>
+# include <mln/value/concept/floating.hh>
+# include <mln/value/concept/vectorial.hh>
+# include <mln/value/concept/structured.hh>
+# include <mln/value/concept/symbolic.hh>
+
+
+#endif // ! MLN_VALUE_CONCEPT_ALL_HH
Index: mln/value/concept/integer.hh
--- mln/value/concept/integer.hh (revision 1267)
+++ mln/value/concept/integer.hh (working copy)
@@ -25,18 +25,26 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_VALUE_CONCEPT_VALUE_INTEGER_HH
-# define MLN_VALUE_CONCEPT_VALUE_INTEGER_HH
+#ifndef MLN_VALUE_CONCEPT_INTEGER_HH
+# define MLN_VALUE_CONCEPT_INTEGER_HH
-/*! \file mln/value/integer.hh
+/*! \file mln/value/concept/integer.hh
*
* \brief Define a generic class for integer values.
*/
# include <mln/value/concept/scalar.hh>
+
namespace mln
{
+
+ // Fwd decl.
+ namespace value
+ {
+ template <typename E> struct Integer;
+ }
+
namespace trait
{
// FIXME
@@ -45,9 +53,6 @@
namespace value
{
- // Fwd decl.
- template <typename E> struct Integer;
-
// Category flag type.
template <>
struct Integer<void>
@@ -65,4 +70,7 @@
} // end of namespace mln
-#endif // ! MLN_VALUE_CONCEPT_VALUE_INTEGER_HH
+# include <mln/value/concept/all.hh>
+
+
+#endif // ! MLN_VALUE_CONCEPT_INTEGER_HH
1
0