URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-03-13 Etienne FOLIO <folio(a)lrde.epita.fr>
Add dimendions and components types in values' traits.
Everything in the title, same for each file.
* mln/trait/value_.hh: .
* mln/value/float01.hh: .
* mln/value/float01_.hh: .
* mln/value/float01_f.hh: .
* mln/value/graylevel.hh: .
* mln/value/graylevel_f.hh: .
* mln/value/hsl.hh: .
* mln/value/int_s.hh: .
* mln/value/int_u.hh: .
* mln/value/int_u_sat.hh: .
* mln/value/label.hh: .
* mln/value/rgb.hh: .
* mln/value/sign.hh: .
---
trait/value_.hh | 8 ++++++++
value/float01.hh | 1 -
value/float01_.hh | 3 +++
value/float01_f.hh | 3 +++
value/graylevel.hh | 3 +++
value/graylevel_f.hh | 3 +++
value/hsl.hh | 5 +++++
value/int_s.hh | 3 +++
value/int_u.hh | 3 +++
value/int_u_sat.hh | 10 ++++++++--
value/label.hh | 2 ++
value/rgb.hh | 12 ++++++++----
value/sign.hh | 9 ++++-----
13 files changed, 53 insertions(+), 12 deletions(-)
Index: trunk/milena/mln/trait/value_.hh
===================================================================
--- trunk/milena/mln/trait/value_.hh (revision 3528)
+++ trunk/milena/mln/trait/value_.hh (revision 3529)
@@ -107,6 +107,7 @@
/*
* enum {
+ * dim = ?
* nbits = ?,
* card = ?
* };
@@ -124,6 +125,7 @@
struct default_value_ : undefined_value_
{
enum {
+ dim = 0,
nbits = 0,
card = 0
};
@@ -131,6 +133,12 @@
typedef trait::value::nature::unknown nature;
typedef trait::value::kind::data kind;
typedef trait::value::quant::high quant;
+
+ /*
+ * typedef ? comp_0;
+ * typedef ? comp_1;
+ * ...
+ */
};
Index: trunk/milena/mln/value/hsl.hh
===================================================================
--- trunk/milena/mln/value/hsl.hh (revision 3528)
+++ trunk/milena/mln/value/hsl.hh (revision 3529)
@@ -130,6 +130,7 @@
struct value_< mln::value::hsl_<H,S,L> >
{
enum {
+ dim = 3,
nbits = (sizeof (H) + sizeof (S) + sizeof (L)) * 8,
card = mln_value_card_from_(nbits)
};
@@ -138,6 +139,10 @@
typedef trait::value::kind::color kind;
typedef mln_value_quant_from_(card) quant;
+ typedef H comp_0;
+ typedef S comp_1;
+ typedef L comp_2;
+
// typedef algebra::vec<3, float> sum;
typedef mln::value::hsl_<H,S,L> sum;
};
Index: trunk/milena/mln/value/graylevel.hh
===================================================================
--- trunk/milena/mln/value/graylevel.hh (revision 3528)
+++ trunk/milena/mln/value/graylevel.hh (revision 3529)
@@ -162,6 +162,7 @@
public:
enum {
+ dim = 1,
nbits = n,
card = mln_value_card_from_(n)
};
@@ -174,6 +175,8 @@
static const self_ max() { return card - 1; }
static const self_ epsilon() { return 0; }
+ typedef mln::value::int_u<n> comp;
+
typedef float sum;
};
Index: trunk/milena/mln/value/graylevel_f.hh
===================================================================
--- trunk/milena/mln/value/graylevel_f.hh (revision 3528)
+++ trunk/milena/mln/value/graylevel_f.hh (revision 3529)
@@ -168,6 +168,7 @@
public:
enum {
+ dim = 1,
nbits = mln_nbits(equiv_),
card = 0
};
@@ -180,6 +181,8 @@
static const equiv_ max() { return 1; }
static const equiv_ epsilon() { return mln_epsilon(equiv_); }
+ typedef float comp;
+
typedef float sum;
};
Index: trunk/milena/mln/value/sign.hh
===================================================================
--- trunk/milena/mln/value/sign.hh (revision 3528)
+++ trunk/milena/mln/value/sign.hh (revision 3529)
@@ -40,10 +40,9 @@
namespace mln
{
+
namespace value
{
-
-
/*!
** \brief The sign class represents the value type
** composed by the set (-1, 0, 1)
@@ -201,7 +200,6 @@
} // end of namespace value
-
namespace trait
{
@@ -210,6 +208,7 @@
{
enum {
+ dim = 1,
nbits = 2,
card = 3
};
@@ -222,13 +221,13 @@
static mln::value::sign max() { return 1; }
static mln::value::sign epsilon() { return 0; }
+ typedef int comp;
+
typedef int sum;
};
-
} // end of namespace trait
-
} // end of namespace mln
Index: trunk/milena/mln/value/float01_.hh
===================================================================
--- trunk/milena/mln/value/float01_.hh (revision 3528)
+++ trunk/milena/mln/value/float01_.hh (revision 3529)
@@ -64,6 +64,7 @@
struct value_< mln::value::float01_<n> >
{
enum constants_ {
+ dim = 1,
nbits = n,
card = mln_value_card_from_(nbits)
};
@@ -76,6 +77,8 @@
static float max() { return 1.f; }
static float epsilon() { return 0.f; }
+ typedef float comp;
+
typedef float sum;
};
Index: trunk/milena/mln/value/int_s.hh
===================================================================
--- trunk/milena/mln/value/int_s.hh (revision 3528)
+++ trunk/milena/mln/value/int_s.hh (revision 3529)
@@ -76,6 +76,7 @@
public:
enum constants_ {
+ dim = 1,
nbits = n,
card = mln_value_card_from_(n) - 1
};
@@ -88,6 +89,8 @@
static const self_ min() { return - max(); }
static const self_ epsilon() { return 0; }
+ typedef mln::value::int_s<n> comp;
+
typedef float sum;
static const char* name()
Index: trunk/milena/mln/value/int_u.hh
===================================================================
--- trunk/milena/mln/value/int_u.hh (revision 3528)
+++ trunk/milena/mln/value/int_u.hh (revision 3529)
@@ -82,6 +82,7 @@
public:
enum constants_ {
+ dim = 1,
nbits = n,
card = mln_value_card_from_(n)
};
@@ -94,6 +95,8 @@
static const self_ max() { return mlc_pow_int(2, n) - 1; }
static const self_ epsilon() { return 0; }
+ typedef unsigned comp;
+
typedef float sum;
static const char* name()
Index: trunk/milena/mln/value/int_u_sat.hh
===================================================================
--- trunk/milena/mln/value/int_u_sat.hh (revision 3528)
+++ trunk/milena/mln/value/int_u_sat.hh (revision 3529)
@@ -58,17 +58,23 @@
template <unsigned n>
struct value_< mln::value::int_u_sat<n> >
{
+ enum {
+ dim = 1,
+ card = metal::math::pow_int<2, n>::value,
+ nbits = n;
+ };
+
// FIXME: Overhaul these traits (see other value traits).
- static const std::size_t card = metal::math::pow_int<2, n>::value;
static const mln::value::int_u_sat<n> min() { return 0; }
static const mln::value::int_u_sat<n> max() { return card - 1; }
- static const unsigned nbits = n;
typedef trait::value::nature::integer nature;
typedef trait::value::kind::data kind;
// FIXME: Is that right?
typedef mln_value_quant_from_(card) quant;
+ typedef unsigned comp;
+
typedef float sum;
};
Index: trunk/milena/mln/value/float01.hh
===================================================================
--- trunk/milena/mln/value/float01.hh (revision 3528)
+++ trunk/milena/mln/value/float01.hh (revision 3529)
@@ -40,7 +40,6 @@
# include <mln/value/concept/floating.hh>
# include <mln/trait/value_.hh>
# include <mln/trait/all.hh> // FIXME!
-# include <mln/trait/value_.hh>
Index: trunk/milena/mln/value/rgb.hh
===================================================================
--- trunk/milena/mln/value/rgb.hh (revision 3528)
+++ trunk/milena/mln/value/rgb.hh (revision 3529)
@@ -105,9 +105,7 @@
// Forward declaration.
namespace value
{
- template <unsigned n> struct rgb;
template <typename H, typename S, typename L> class hsl_;
- template <unsigned n> struct int_u;
}
@@ -208,7 +206,8 @@
struct value_< mln::value::rgb<n> >
{
enum {
- nbits = 3 * n,
+ dim = 3,
+ nbits = dim * n,
card = mln_value_card_from_(nbits)
};
@@ -216,7 +215,9 @@
typedef trait::value::kind::color kind;
typedef mln_value_quant_from_(card) quant;
- typedef algebra::vec<3, float> sum;
+ typedef mln::value::int_u<n> comp;
+
+ typedef algebra::vec<dim, float> sum;
static const char* name()
{
@@ -260,6 +261,9 @@
int_u<n> blue() const { return this->v_[2]; }
int_u<n>& blue() { return this->v_[2]; }
+
+ int_u<n> comp(unsigned k) const { return this->v_[k]; }
+ int_u<n>& comp(unsigned k) { return this->v_[k]; }
/// \}
/// Constructor without argument.
Index: trunk/milena/mln/value/float01_f.hh
===================================================================
--- trunk/milena/mln/value/float01_f.hh (revision 3528)
+++ trunk/milena/mln/value/float01_f.hh (revision 3529)
@@ -62,6 +62,7 @@
typedef trait::value::quant::high quant;
enum {
+ dim = 1,
nbits = 8 * sizeof(float),
card = 0
};
@@ -70,6 +71,8 @@
static float max() { return 1; }
static float epsilon() { return mln_epsilon(float); }
+ typedef float comp;
+
typedef float sum;
};
Index: trunk/milena/mln/value/label.hh
===================================================================
--- trunk/milena/mln/value/label.hh (revision 3528)
+++ trunk/milena/mln/value/label.hh (revision 3529)
@@ -68,6 +68,7 @@
public:
enum {
+ dim = 1,
nbits = n,
card = mln_value_card_from_(n)
};
@@ -85,6 +86,7 @@
return s.c_str();
}
+ typedef unsigned comp;
};
} // end of namespace trait