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
cleanup-2008 2205: Add the sign value type (subset of the int value type).
by Nicolas Ballas 09 Sep '08
by Nicolas Ballas 09 Sep '08
09 Sep '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
Add the sign value type (subset of the int value type).
* tests/core/image/flat_image.cc: Update the test.
* tests/value/sign.cc: New test.
* tests/value/Makefile.am: Add the new test in the Makefile.
* mln/value/sign.hh: New sign value type.
* mln/value/super_value.hh: Update the super_value trait.
* mln/make/box2d.hh: Fix a conversion warning.
mln/make/box2d.hh | 4
mln/value/sign.hh | 229 +++++++++++++++++++++++++++++++++++++++++
mln/value/super_value.hh | 16 ++
tests/core/image/flat_image.cc | 9 +
tests/value/Makefile.am | 2
tests/value/sign.cc | 51 +++++++++
6 files changed, 302 insertions(+), 9 deletions(-)
Index: tests/core/image/flat_image.cc
--- tests/core/image/flat_image.cc (revision 2204)
+++ tests/core/image/flat_image.cc (working copy)
@@ -32,18 +32,21 @@
#include <mln/core/image/flat_image.hh>
#include <mln/core/alias/box2d.hh>
+#include <mln/value/sign.hh>
int main()
{
- {
using namespace mln;
+ {
flat_image<short, box2d> test;
-
std::cout << test.values_eligible() << std::endl;
std::cout << test.values_space() << std::endl;
- // flat_image<short, box2d>::t_eligible_value_set::fwd_viter viter(test.values_eligible());
+ }
+ {
+ flat_image<value::sign, box2d> test;
+ std::cout << test.values_eligible() << std::endl;
}
}
Index: tests/value/sign.cc
--- tests/value/sign.cc (revision 0)
+++ tests/value/sign.cc (revision 0)
@@ -0,0 +1,51 @@
+// Copyright (C) 2008 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/sign.cc
+ *
+ * \brief Tests on mln::value::sign.
+ */
+
+#include <cassert>
+#include <mln/value/sign.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using value::sign;
+
+ {
+ sign s;
+ s = -1;
+ s = 0;
+ s = 1;
+ assert(sign::zero == 0);
+ assert(sign::one == 1);
+ assert(s != 3);
+ }
+}
Index: tests/value/Makefile.am
--- tests/value/Makefile.am (revision 2204)
+++ tests/value/Makefile.am (working copy)
@@ -27,6 +27,7 @@
rgb8 \
scalar \
set \
+ sign \
stack
# FIXME: Enable when make check_full works.
@@ -51,6 +52,7 @@
rgb8_SOURCES = rgb8.cc
scalar_SOURCES = scalar.cc
set_SOURCES = set.cc
+sign_SOURCES = sign.cc
stack_SOURCES = stack.cc
# FIXME: Enable when make check_full works.
Index: mln/value/sign.hh
--- mln/value/sign.hh (revision 0)
+++ mln/value/sign.hh (revision 0)
@@ -0,0 +1,229 @@
+// Copyright (C) 2008 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_SIGN_HH
+# define MLN_VALUE_SIGN_HH
+
+/*! \file mln/value/sign.hh
+ *
+ * \brief Definition of the mln::value::sign class.
+ */
+
+# include <mln/value/internal/integer.hh>
+# include <mln/trait/value_.hh>
+# include <mln/literal/zero.hh>
+# include <mln/literal/one.hh>
+# include <mln/debug/format.hh>
+
+namespace mln
+{
+ namespace value
+ {
+
+
+ /*!
+ ** \brief The sign class represents the value type
+ ** composed by the set (-1, 0, 1)
+ ** sign value type is a subset of the int value type.
+ */
+ class sign : public internal::Integer<sign>
+ {
+ public:
+ /// FIXME is these typedefs correct?
+
+ /// Define the encoding type
+ typedef int enc;
+
+ /// Define the equivalent type
+ typedef int equiv;
+
+
+ /// Constructor without argument.
+ sign();
+
+ /// Constructor from an integer.
+ sign(int i);
+
+ /// \{ Constructors/assignments with literals.
+ sign(const mln::literal::zero_t&);
+ sign& operator=(const mln::literal::zero_t&);
+ sign(const mln::literal::one_t&);
+ sign& operator=(const mln::literal::one_t&);
+ /// \}
+
+ /// Conversion to an integer.
+ operator int() const;
+
+ /// Return the value associated to the sign object
+ int val_() const;
+
+ /// Assignment from an integer.
+ sign& operator=(int i);
+
+
+
+ /// Zero value.
+ static const sign zero;
+
+ /// Unit value.
+ static const sign one;
+
+ protected:
+
+ /// The value
+ int v_;
+ };
+
+ /*! \brief Print an signed integer \p i into the output stream \p ostr.
+ *
+ * \param[in,out] ostr An output stream.
+ * \param[in] i An sign value
+ *
+ * \return The modified output stream \p ostr.
+ */
+ std::ostream& operator<<(std::ostream& ostr, const sign& i);
+
+ /// Comparaison operator
+ bool operator==(sign lhs, sign rhs);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ inline
+ sign::sign()
+ {
+ }
+
+ inline
+ sign::operator int() const
+ {
+ return this->v_;
+ }
+
+ inline
+ int
+ sign::val_() const
+ {
+ return this->v_;
+ }
+
+ inline
+ sign::sign(int i)
+ {
+ mln_precondition(i >= -1);
+ mln_precondition(i <= 1);
+ this->v_ = i;
+ }
+
+ inline
+ sign&
+ sign::operator=(int i)
+ {
+ mln_precondition(i >= -1);
+ mln_precondition(i <= 1);
+ this->v_ = i;
+ return *this;
+ }
+
+ inline
+ sign::sign(const mln::literal::zero_t&)
+ {
+ this->v_ = 0;
+ }
+
+ inline
+ sign&
+ sign::operator=(const mln::literal::zero_t&)
+ {
+ this->v_ = 0;
+ return *this;
+ }
+
+ inline
+ sign::sign(const mln::literal::one_t&)
+ {
+ this->v_ = 1;
+ }
+
+ inline
+ sign&
+ sign::operator=(const mln::literal::one_t&)
+ {
+ this->v_ = 1;
+ return *this;
+ }
+
+ const sign sign::zero = 0;
+
+ const sign sign::one = 1;
+
+ inline
+ std::ostream& operator<<(std::ostream& ostr, const sign& i)
+ {
+ return ostr << debug::format(i.val_());
+ }
+
+ inline
+ bool operator==(sign lhs, sign rhs)
+ {
+ return lhs.val_() == rhs.val_();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace value
+
+
+ namespace trait
+ {
+
+ template <>
+ struct value_<mln::value::sign>
+ {
+
+ enum {
+ nbits = 2,
+ card = 3
+ };
+
+ typedef trait::value::nature::integer nature;
+ typedef trait::value::kind::gray kind;
+ typedef trait::value::quant::low quant;
+
+ static mln::value::sign min() { return -1; }
+ static mln::value::sign max() { return 1; }
+ static mln::value::sign epsilon() { return 0; }
+
+ typedef int sum;
+ };
+
+ } // end of namespace trait
+
+
+} // end of namespace mln
+
+
+#endif // ! MLN_VALUE_SIGN_HH
Index: mln/value/super_value.hh
--- mln/value/super_value.hh (revision 2204)
+++ mln/value/super_value.hh (working copy)
@@ -33,6 +33,8 @@
* \brief Definition of the mln::super_value trait.
*/
+# include <mln/value/sign.hh>
+
namespace mln
{
@@ -49,11 +51,17 @@
typedef T ret;
};
- /// Specialization
- ///
+ /// Specializations:
+
+ /// Sign type is a subset of the short value type.
+ template <>
+ struct super_value<sign>
+ {
+ typedef int ret;
+ };
- }
+ } // end of namespace value
-}
+} // end of namespace mln
#endif // !MLN_VALUE_SUPER_VALUE_HH
Index: mln/make/box2d.hh
--- mln/make/box2d.hh (revision 2204)
+++ mln/make/box2d.hh (working copy)
@@ -79,8 +79,8 @@
{
mln_precondition(nrows != 0 && ncols != 0);
mln::box2d tmp(make::point2d(0, 0),
- make::point2d(nrows - 1,
- ncols - 1));
+ make::point2d(def::coord (nrows - 1),
+ def::coord (ncols - 1)));
return tmp;
}
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Update fun::rotation.
* mln/fun/x2x/rotation.hh: Code 3d rotation about a vector x.
rotation.hh | 50 +++++++++++++++++++++++++++++++++++---------------
1 file changed, 35 insertions(+), 15 deletions(-)
Index: mln/fun/x2x/rotation.hh
--- mln/fun/x2x/rotation.hh (revision 2203)
+++ mln/fun/x2x/rotation.hh (working copy)
@@ -66,7 +66,7 @@
/// Constructor without argument.
rotation();
/// Constructor with grade alpha and a facultative direction (rotation axis).
- rotation(float alpha, unsigned dir = 2);
+ rotation(float alpha, algebra::vec<n,float>& axis);
using super_::operator();
/// Perform the rotation of the given vector.
@@ -81,7 +81,7 @@
void update();
float alpha_;
- unsigned dir_;
+ algebra::vec <n,float> axis_;
};
@@ -95,9 +95,9 @@
template <unsigned n, typename C>
inline
- rotation<n,C>::rotation(float alpha, unsigned dir)
+ rotation<n,C>::rotation(float alpha, algebra::vec<n,float>& axis)
:alpha_(alpha),
- dir_(dir)
+ axis_(axis)
{
mln_precondition(dir == 2 || n == 3);
this->m_ = algebra::h_mat<n,C>::Id;
@@ -128,7 +128,7 @@
rotation<n,C>
rotation<n,C>::inv() const
{
- typename rotation::invert res(-alpha_, dir_);
+ typename rotation::invert res(-alpha_, axis_);
return res;
}
@@ -151,24 +151,44 @@
update();
}
+ // Homogenous matrix for a rotation of a point (x,y,z)
+ // about the vector (u,v,w) by the angle alpha
template <unsigned n, typename C>
inline
void
rotation<n,C>::update()
{
+ assert(n == 3); // debug
const float cos_a = cos(alpha_);
const float sin_a = sin(alpha_);
- const algebra::vec<4,float> vec = make::vec(cos_a, -sin_a, sin_a, cos_a);
+ const float u = axis_[0];
+ const float v = axis_[1];
+ const float w = axis_[2];
+ const float u2 = u * u;
+ const float v2 = v * v;
+ const float w2 = w * w;
+ const float uvw2 = u2 + v2 + w2;
+
+ this->m_(0,0) = (u2 + (v2 + w2) * cos_a) / uvw2;
+ this->m_(0,1) = (u*v * (1 - cos_a) - u * math::sqrt(uvw2) * sin_a) / uvw2;
+ this->m_(0,2) = (u*w * (1 - cos_a) + v * math::sqrt(uvw2) * sin_a) / uvw2;
+ this->m_(0,3) = 0;
+
+ this->m_(1,0) = (u*v * (1 - cos_a) + w * math::sqrt(uvw2) * sin_a) / uvw2;
+ this->m_(1,1) = (v2 + (u2 + w2) * cos_a) / uvw2;
+ this->m_(1,2) = (v*w * (1 - cos_a) - u * math::sqrt(uvw2) * sin_a) / uvw2;
+ this->m_(1,3) = 0;
+
+ this->m_(2,0) = (u*w * (1 - cos_a) - v * math::sqrt(uvw2) * sin_a) / uvw2;
+ this->m_(2,1) = (v*w * (1 - cos_a) + u * math::sqrt(uvw2) * sin_a) / uvw2;
+ this->m_(2,1) = (u2 + (u2 + v2) * cos_a) / uvw2;
+ this->m_(2,3) = 0;
+
+ this->m_(2,0) = 0;
+ this->m_(2,1) = 0;
+ this->m_(2,1) = 0;
+ this->m_(2,3) = 1;
- unsigned k = 0;
- for (unsigned i = 0; i < n; ++i)
- for (unsigned j = 0; j < n; ++j)
- {
- if (j != this->dir_ && i != this->dir_)
- this->m_(i, j) = vec[k++];
- else
- this->m_(i, j) = (i == j);
- }
}
# endif // ! MLN_INCLUDE_ONLY
1
0
09 Sep '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Upgrade image1d + minor fixes ( _ removing ).
* mln/core/dpoints_piter.hh: Remove underscore to site_iterator_base_.
* mln/core/image/image1d.hh: Upgrade following image2d.
* mln/core/macros.hh: Temporarily uncomment mln_(d)point.
* mln/core/w_window.hh: Include dpoints_piter.hh.
* mln/core/line_piter.hh: Remove underscore to site_iterator_base_.
* mln/core/alias/dpoint1d.hh: Remove underscore to dpoint_.
* mln/core/alias/box1d.hh: Remove underscore to box_.
* mln/core/alias/point1d.hh: Cosmetic change.
alias/box1d.hh | 2 -
alias/dpoint1d.hh | 2 -
alias/point1d.hh | 2 -
dpoints_piter.hh | 4 +-
image/image1d.hh | 82 ++++++++++++++++++++++++++++++++----------------------
line_piter.hh | 4 +-
macros.hh | 20 ++++++-------
w_window.hh | 2 -
8 files changed, 67 insertions(+), 51 deletions(-)
Index: mln/core/dpoints_piter.hh
--- mln/core/dpoints_piter.hh (revision 2202)
+++ mln/core/dpoints_piter.hh (working copy)
@@ -48,7 +48,7 @@
* The parameter \c D is the type of delta-points.
*/
template <typename D>
- class dpoints_fwd_piter : public internal::site_iterator_base_< mln_point(D), dpoints_fwd_piter<D> >
+ class dpoints_fwd_piter : public internal::site_iterator_base< mln_point(D), dpoints_fwd_piter<D> >
{
public:
@@ -106,7 +106,7 @@
* The parameter \c D is the type of delta-points.
*/
template <typename D>
- class dpoints_bkd_piter : public internal::site_iterator_base_< mln_point(D), dpoints_bkd_piter<D> >
+ class dpoints_bkd_piter : public internal::site_iterator_base< mln_point(D), dpoints_bkd_piter<D> >
{
public:
Index: mln/core/image/image1d.hh
--- mln/core/image/image1d.hh (revision 2202)
+++ mln/core/image/image1d.hh (working copy)
@@ -88,17 +88,25 @@
template <typename T>
struct image_< image1d<T> > : default_image_< T, image1d<T> >
{
+ // misc
typedef trait::image::category::primary category;
-
- typedef trait::image::access::random access;
- typedef trait::image::space::one_d space;
+ typedef trait::image::speed::fastest speed;
typedef trait::image::size::regular size;
- typedef trait::image::support::aligned support;
- typedef trait::image::border::stored border;
- typedef trait::image::data::raw data;
- typedef trait::image::io::read_write io;
- typedef trait::image::speed::fastest speed;
+ // value
+ typedef trait::image::value_access::direct value_access;
+ typedef trait::image::value_storage::one_block value_storage;
+ typedef trait::image::value_browsing::site_wise_only value_browsing;
+ typedef trait::image::value_io::read_write value_io;
+
+ // site / domain
+ typedef trait::image::localization::basic_grid localization;
+ typedef trait::image::dimension::one_d dimension;
+
+ // extended domain
+ typedef trait::image::ext_domain::extendable ext_domain;
+ typedef trait::image::ext_value::multiple ext_value;
+ typedef trait::image::ext_io::read_write ext_io;
};
} // end of namespace mln::trait
@@ -115,16 +123,10 @@
struct image1d :
public internal::image_primary< T, box1d, image1d<T> >
{
- // Warning: just to make effective types appear in Doxygen:
- typedef box1d pset;
- typedef point1d psite;
- typedef point1d point;
- typedef dpoint1d dpoint;
- typedef mln_fwd_piter(box1d) fwd_piter;
- typedef mln_bkd_piter(box1d) bkd_piter;
- typedef line_piter_<point> line_piter;
- // End of warning.
+ typedef internal::image_primary< T, mln::box1d, image1d<T> > super_;
+ /// Coordinate associated type.
+ typedef int coord;
/// Value associated type.
typedef T value;
@@ -161,6 +163,9 @@
/// Give the definition domain.
const box1d& domain() const;
+ /// Give the bounding box domain.
+ const box1d& bbox() const;
+
/// Give the border thickness.
unsigned border() const;
@@ -188,6 +193,9 @@
/// Fast Image method
+ // Give the index of a point.
+ using super_::index_of_point;
+
/// Give the offset corresponding to the delta-point \p dp.
int offset(const dpoint1d& dp) const;
@@ -201,7 +209,6 @@
T* buffer();
-
/// Resize image border with new_border.
void resize_(unsigned new_border);
@@ -351,7 +358,16 @@
image1d<T>::domain() const
{
mln_precondition(this->has_data());
- return this->data_->b_;
+ return this->data->b_;
+ }
+
+ template <typename T>
+ inline
+ const box1d&
+ image1d<T>::bbox() const
+ {
+ mln_precondition(this->has_data());
+ return this->data->b_;
}
template <typename T>
@@ -360,7 +376,7 @@
image1d<T>::border() const
{
mln_precondition(this->has_data());
- return this->data_->bdr_;
+ return this->data->bdr_;
}
template <typename T>
@@ -369,7 +385,7 @@
image1d<T>::ncells() const
{
mln_precondition(this->has_data());
- return this->data_->vb_.npoints();
+ return this->data->vb_.npoints();
}
template <typename T>
@@ -378,7 +394,7 @@
image1d<T>::has(const point1d& p) const
{
mln_precondition(this->has_data());
- return this->data_->vb_.has(p);
+ return this->data->vb_.has(p);
}
template <typename T>
@@ -387,7 +403,7 @@
image1d<T>::operator()(const point1d& p) const
{
mln_precondition(this->has(p));
- return this->data_->array_[p.ind()];
+ return this->data->array_[p.ind()];
}
template <typename T>
@@ -396,7 +412,7 @@
image1d<T>::operator()(const point1d& p)
{
mln_precondition(this->has(p));
- return this->data_->array_[p.ind()];
+ return this->data->array_[p.ind()];
}
template <typename T>
@@ -405,7 +421,7 @@
image1d<T>::operator[](unsigned o) const
{
mln_precondition(o < ncells());
- return *(this->data_->buffer_ + o);
+ return *(this->data->buffer_ + o);
}
template <typename T>
@@ -414,7 +430,7 @@
image1d<T>::operator[](unsigned o)
{
mln_precondition(o < ncells());
- return *(this->data_->buffer_ + o);
+ return *(this->data->buffer_ + o);
}
template <typename T>
@@ -423,7 +439,7 @@
image1d<T>::at(int ind) const
{
mln_precondition(this->has(make::point1d(ind)));
- return this->data_->array_[ind];
+ return this->data->array_[ind];
}
template <typename T>
@@ -432,7 +448,7 @@
image1d<T>::at(int ind)
{
mln_precondition(this->has(make::point1d(ind)));
- return this->data_->array_[ind];
+ return this->data->array_[ind];
}
template <typename T>
@@ -441,7 +457,7 @@
image1d<T>::buffer() const
{
mln_precondition(this->has_data());
- return this->data_->buffer_;
+ return this->data->buffer_;
}
template <typename T>
@@ -450,7 +466,7 @@
image1d<T>::buffer()
{
mln_precondition(this->has_data());
- return this->data_->buffer_;
+ return this->data->buffer_;
}
template <typename T>
@@ -469,8 +485,8 @@
image1d<T>::point_at_offset(unsigned o) const
{
mln_precondition(o < ncells());
- point1d p = make::point1d(o + this->data_->vb_.min_ind());
- mln_postcondition(& this->operator()(p) == this->data_->buffer_ + o);
+ point1d p = make::point1d(o + this->data->vb_.min_ind());
+ mln_postcondition(& this->operator()(p) == this->data->buffer_ + o);
return p;
}
@@ -479,7 +495,7 @@
void
image1d<T>::resize_(unsigned new_border)
{
- this->data_->reallocate_(new_border);
+ this->data->reallocate_(new_border);
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/macros.hh
--- mln/core/macros.hh (revision 2202)
+++ mln/core/macros.hh (working copy)
@@ -104,11 +104,11 @@
# define mln_delta_(T) T::delta
/// \}
-// /// Shortcuts to access the dpoint type associated to T.
-// /// \{
-// # define mln_dpoint(T) typename T::dpoint
-// # define mln_dpoint_(T) T::dpoint
-// /// \}
+/// Shortcuts to access the dpoint type associated to T.
+/// \{
+# define mln_dpoint(T) typename T::dpoint
+# define mln_dpoint_(T) T::dpoint
+/// \}
/// Shortcuts to access the dpsite type associated to T.
/// \{
@@ -253,11 +253,11 @@
# define mln_psite_(T) T::psite
/// \}
-// /// Shortcuts to access the point type associated to T.
-// /// \{
-// # define mln_point(T) typename T::point
-// # define mln_point_(T) T::point
-// /// \}
+/// Shortcuts to access the point type associated to T.
+/// \{
+# define mln_point(T) typename T::point
+# define mln_point_(T) T::point
+/// \}
// q
Index: mln/core/w_window.hh
--- mln/core/w_window.hh (revision 2202)
+++ mln/core/w_window.hh (working copy)
@@ -37,7 +37,7 @@
# include <mln/core/window.hh>
# include <mln/core/concept/weighted_window.hh>
-
+# include <mln/core/dpoints_piter.hh>
namespace mln
{
Index: mln/core/line_piter.hh
--- mln/core/line_piter.hh (revision 2202)
+++ mln/core/line_piter.hh (working copy)
@@ -47,10 +47,10 @@
*/
template <typename P>
class line_piter_ :
- public internal::site_iterator_base_< P, line_piter_<P> >
+ public internal::site_iterator_base< P, line_piter_<P> >
{
typedef line_piter_<P> self_;
- typedef internal::site_iterator_base_< P, self_ > super_;
+ typedef internal::site_iterator_base< P, self_ > super_;
public:
// Make definitions from super class available.
Index: mln/core/alias/dpoint1d.hh
--- mln/core/alias/dpoint1d.hh (revision 2202)
+++ mln/core/alias/dpoint1d.hh (working copy)
@@ -44,7 +44,7 @@
/*! \brief Type alias for a delta-point defined on the 1D square
* grid with integer coordinates.
*/
- typedef dpoint_<mln::grid::tick, int> dpoint1d;
+ typedef dpoint<mln::grid::tick, int> dpoint1d;
} // end of namespace mln
Index: mln/core/alias/box1d.hh
--- mln/core/alias/box1d.hh (revision 2202)
+++ mln/core/alias/box1d.hh (working copy)
@@ -46,7 +46,7 @@
*
* \see mln::win::rectangle1d.
*/
- typedef box_<point1d> box1d;
+ typedef box<point1d> box1d;
} // end of namespace mln
Index: mln/core/alias/point1d.hh
--- mln/core/alias/point1d.hh (revision 2202)
+++ mln/core/alias/point1d.hh (working copy)
@@ -43,7 +43,7 @@
/*! \brief Type alias for a point defined on the 1D square grid with
* integer coordinates.
*/
- typedef point<mln::grid::tick, def::coord> point1d;
+ typedef point<grid::tick, def::coord> point1d;
} // end of namespace mln
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Sandbox: Sync access.hh/.cc with trunk.
* jardonnet/virtual/access.hh: Sync with trunk.
* jardonnet/virtual/access.cc: Sync with trunk.
access.cc | 4 +--
access.hh | 66 +++++++++++++++++++++++++++++++++++++++++++-------------------
2 files changed, 48 insertions(+), 22 deletions(-)
Index: jardonnet/virtual/access.hh
--- jardonnet/virtual/access.hh (revision 2201)
+++ jardonnet/virtual/access.hh (working copy)
@@ -1,10 +1,12 @@
#ifndef _ACCESS_HH
# define _ACCESS_HH
-# include <mln/core/image1d.hh>
-# include <mln/core/image2d.hh>
+# include <mln/core/image/image1d.hh>
+# include <mln/core/image/image2d.hh>
# include <mln/metal/is.hh>
# include <mln/core/concept/function.hh>
+# include <mln/fun/internal/selector.hh>
+# include <mln/convert/to.hh>
namespace mln
{
@@ -14,37 +16,48 @@
template < typename I >
struct nearest_neighbor
- : public Function_x2x< nearest_neighbor<I> >
+ : public fun::internal::selector_<const algebra::vec<3,float>,
+ // 3,float is a dummy parameter (real is n,T)
+ mln_value(I), nearest_neighbor<I> >::ret
{
typedef mln_value(I) result;
- template < typename V >
+ nearest_neighbor(const I& ima) : ima(ima) {}
+
+ template < unsigned n, typename T >
mln_value(I)
- operator()(const I& img, const V& v) const
+ operator()(const I& img, const algebra::vec<n,T>& x) const
{
- mln_point(I) p = algebra::to_point<mln_point(I)>(v);
+ mln_psite(I) p = convert::to<mln_psite(I)>(x);
return img(p);
}
+ const I& ima;
};
template < typename I >
struct linear
- : public Function_x2x< linear<I> >
+ : public fun::internal::selector_<const algebra::vec<1,float>,
+ // float is a dummy parameter (real is C)
+ mln_value(I), linear<I> >::ret
{
typedef mln_value(I) result;
+ linear(const I& ima) : ima(ima) {}
+
template <typename C>
mln_value(I)
operator()(const I& img,
const algebra::vec<1,C>& v) const
{
+ typedef mln_sum(mln_value(I)) vsum;
+
// looking for img(x);
double x = v[0];
// p1
double xa = mln_point(I)::coord(v[0]);
- double ya = img(point1d(xa));
+ vsum ya = img(point1d(xa));
// x makes sens in img
if (x == xa)
@@ -52,23 +65,32 @@
// p2
double xb = mln_point(I)::coord(v[0] + 1);
- double yb = img(point1d(xb));
+ vsum yb = img(point1d(xb));
// Taylor-young
- return ya + (x - xa) * (yb - ya) / (xb - xa);
+ return convert::to<mln_value(I)>
+ (ya + (x - xa) * (yb - ya) / (xb - xa));
}
+
+ const I& ima;
};
template < typename I >
struct bilinear
- : public Function_x2x< bilinear<I> >
+ : public fun::internal::selector_<const algebra::vec<3,float>,
+ // 3,float is a dummy parameter (real is n,T)
+ mln_value(I), linear<I> >::ret
{
typedef mln_value(I) result;
- template <typename V>
+ bilinear(const I& ima) : ima(ima) {}
+
+ template <unsigned n, typename T>
mln_value(I)
- operator()(const I& img, const V& v) const
+ operator()(const I& img, const algebra::vec<n,T>& v) const
{
+ typedef mln_sum(mln_value(I)) vsum;
+
// q12----r2----q22
// | | |
// | x |
@@ -90,17 +112,20 @@
point2d q22 = point2d(x2, y2);
// linear interpolation #1
- mln_value(I) img_r1 = img(q11) * (x2 - x) / (x2 - x1) +
+ vsum img_r1 = img(q11) * (x2 - x) / (x2 - x1) +
img(q21) * (x - x1) / (x2 - x1);
// linear interpolation #2
- mln_value(I) img_r2 = img(q12) * (x2 - x) / (x2 - x1) +
+ vsum img_r2 = img(q12) * (x2 - x) / (x2 - x1) +
img(q22) * (x - x1) / (x2 - x1);
// interpolating in y direction
- return img_r1 * (y2 - y) / (y2 -y1)
- + img_r2 * (y - y1) /(y2 - y1);
+ return convert::to<mln_value(I)>
+ (img_r1 * (y2 - y) / (y2 -y1)
+ + img_r2 * (y - y1) /(y2 - y1));
}
+
+ const I& ima;
};
}
@@ -109,11 +134,12 @@
template <typename I, typename T, typename F>
mln_value(I)
- access(const I& img, const mln_point(I)& p,
+ access(const I& img, const point2d& p,
const T& trans, const F& interp)
{
- mlc_is(typename T::invert, Bijection_x2x<typename T::invert>)::check();
- mlc_is(F, Function_x2x<F>)::check();
+ mlc_is(typename T::invert,
+ Bijection_x2x<typename T::invert>)::check();
+ mlc_is(F, Function<F>)::check();
return interp(img, (trans.inv())(p));
}
Index: jardonnet/virtual/access.cc
--- jardonnet/virtual/access.cc (revision 2201)
+++ jardonnet/virtual/access.cc (working copy)
@@ -1,7 +1,7 @@
#include <iostream>
#include "access.hh"
-#include <mln/core/image2d.hh>
+#include <mln/core/image/image2d.hh>
#include <mln/fun/x2x/all.hh>
#include <mln/debug/iota.hh>
#include <mln/algebra/vec.hh>
@@ -13,7 +13,7 @@
point2d p(5,5);
algebra::vec<2,float> v = make::vec(3,4);
fun::x2x::translation<2,float> t(v);
- interpolation::nearest_neighbor< image2d<int> > nn;
+ interpolation::nearest_neighbor< image2d<int> > nn(img);
debug::iota(img);
1
0
Un dessin vaut mieux que mille mots. :-)
Tant qu'on dépend de Subversion, il faut qu'on essaie de maintenir ce
fichier. Il aurait été encore mieux d'aller renseigner les méta-
données SVN des différentes révisions (peut-être n'est-il d'ailleurs
pas trop tard, mais je n'en sais rien) pour en déduire ce schéma, mais
bon, le mieux est l'ennemi du bien.
Dans tous les cas, je pense qu'il faut qu'on se parle avant de décidé
d'un merge (dans un sens ou dans l'autre). Et une fois que branche
cleanup-2008 aura été complètement réintégrée dans trunk, je pense
qu'il faudra la détruire, puis utiliser des branches Git dans les
dépôt perso, qui offrent moins de risques.
Index: README.branches
===================================================================
--- README.branches (revision 2200)
+++ README.branches (revision 2201)
@@ -7,8 +7,40 @@
Should be merged back, then closed, as soon as all cleanup changes
have been applied.
** History
-Forked from the trunk (r1939) by revision 1940 on 2008-05-09.
+- Forked from the trunk (r1939) by revision 1940 on 2008-05-09.
+- Sync'd (merge) trunk (r1940:2162) into cleanup-2008 by revision 2163
+ on 2008-09-02.
+- Sync'd (merge) trunk (r2163:2188) into cleanup-2008 by revision 2189
+ on 2008-09-05.
+rev. branches
+
+ |
+1939 o.
+ | \
+1940 . `o create branches/cleanup-2008
+ . |
+ ... . .
+ | .
+2162 o. .
+ | \ |
+2163 . `o merge trunk (r1940:2162) -> branches/cleanup-2008
+ . |
+ ... . .
+ | .
+2188 o. .
+ | \ |
+2189 | `o merge trunk (r2163:2188) -> branches/cleanup-2008
+ | |
+ ... | |
+ | |
+ v |
+ trunk |
+ |
+ v
+ branches/cleanup-2008
+
+
* olena-ng
** Status: OPEN
** Object: Olena NG (Next Generation), based on the SCOOP 2 paradigm
1
0
Re: [Olena-patches] cleanup-2008 6fd64da: Merge last changes from trunk to cleanup
by Guillaume Lazzara 09 Sep '08
by Guillaume Lazzara 09 Sep '08
09 Sep '08
Roland Levillain wrote:
> Oh by the way, did you use a specific tool to format and send this patch
> to olena-patches (svn-wrapper maybe)?
>
Yes, I used svn-wrapper. It has git support.
--
Guillaume Lazzara
1
0
09 Sep '08
URL: https://svn.lrde.epita.fr/svn/oln
Git branch: cleanup (HEAD: 9517158)
ChangeLog:
2008-09-05 Guillaume Lazzara <z(a)lrde.epita.fr>
Merge last changes from trunk to cleanup.
* milena/ChangeLog: .
* milena/mln/fun/x2x/rotation.hh: .
* milena/mln/fun/x2x/translation.hh: .
* milena/mln/metal/all.hh: .
* milena/mln/metal/array.hh: New.
* milena/mln/metal/array1d.hh: New.
* milena/mln/metal/array2d.hh: New.
* milena/mln/metal/array3d.hh: New.
* milena/sandbox/ChangeLog: .
* milena/sandbox/geraud/fllt/fllt.svg.7.hh: .
* milena/sandbox/jardonnet/array/Makefile: New.
* milena/sandbox/jardonnet/array/array.cc: .
* milena/sandbox/jardonnet/array/array.hh: .
* milena/sandbox/jardonnet/array/old/1d.hh: .
* milena/sandbox/jardonnet/registration/tools.hh: .
* milena/sandbox/jardonnet/test/icp.cc: .
* milena/sandbox/jardonnet/virtual/Makefile: New.
* milena/sandbox/jardonnet/virtual/access.cc: New.
* milena/sandbox/jardonnet/virtual/access.hh: New.
* milena/sandbox/nivault/plugin-gimp/autogen.sh: .
* milena/sandbox/nivault/plugin-gimp/configure.ac: .
* milena/sandbox/nivault/plugin-gimp/src/main.cc: .
---
ChangeLog | 26 ++
milena/ChangeLog | 18 ++
milena/mln/fun/x2x/rotation.hh | 2 +-
milena/mln/fun/x2x/translation.hh | 6 +-
milena/mln/metal/all.hh | 5 +
milena/mln/metal/array.hh | 117 +++++++++
milena/mln/metal/array1d.hh | 298 ++++++++++++++++++++++
milena/mln/metal/array2d.hh | 309 ++++++++++++++++++++++
milena/mln/metal/array3d.hh | 310 +++++++++++++++++++++++
milena/sandbox/ChangeLog | 41 +++
milena/sandbox/geraud/fllt/fllt.svg.7.hh | 96 ++++++-
milena/sandbox/jardonnet/array/Makefile | 2 +
milena/sandbox/jardonnet/array/array.cc | 12 +-
milena/sandbox/jardonnet/array/array.hh | 121 +++++++++-
milena/sandbox/jardonnet/array/old/1d.hh | 4 +-
milena/sandbox/jardonnet/registration/tools.hh | 54 +---
milena/sandbox/jardonnet/test/icp.cc | 1 +
milena/sandbox/jardonnet/virtual/Makefile | 2 +
milena/sandbox/jardonnet/virtual/access.cc | 36 +++
milena/sandbox/jardonnet/virtual/access.hh | 126 +++++++++
milena/sandbox/nivault/plugin-gimp/autogen.sh | 2 +-
milena/sandbox/nivault/plugin-gimp/configure.ac | 3 +-
milena/sandbox/nivault/plugin-gimp/src/main.cc | 2 +-
23 files changed, 1529 insertions(+), 64 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 335521e..c39c773 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2008-09-05 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Merge last changes from trunk to cleanup.
+ * milena/ChangeLog: .
+ * milena/mln/fun/x2x/rotation.hh: .
+ * milena/mln/fun/x2x/translation.hh: .
+ * milena/mln/metal/all.hh: .
+ * milena/mln/metal/array.hh: New.
+ * milena/mln/metal/array1d.hh: New.
+ * milena/mln/metal/array2d.hh: New.
+ * milena/mln/metal/array3d.hh: New.
+ * milena/sandbox/ChangeLog: .
+ * milena/sandbox/geraud/fllt/fllt.svg.7.hh: .
+ * milena/sandbox/jardonnet/array/Makefile: New.
+ * milena/sandbox/jardonnet/array/array.cc: .
+ * milena/sandbox/jardonnet/array/array.hh: .
+ * milena/sandbox/jardonnet/array/old/1d.hh: .
+ * milena/sandbox/jardonnet/registration/tools.hh: .
+ * milena/sandbox/jardonnet/test/icp.cc: .
+ * milena/sandbox/jardonnet/virtual/Makefile: New.
+ * milena/sandbox/jardonnet/virtual/access.cc: New.
+ * milena/sandbox/jardonnet/virtual/access.hh: New.
+ * milena/sandbox/nivault/plugin-gimp/autogen.sh: .
+ * milena/sandbox/nivault/plugin-gimp/configure.ac: .
+ * milena/sandbox/nivault/plugin-gimp/src/main.cc: .
+
2008-09-05 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Augment tutorial example for Z.
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 10983ef..479dea2 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,21 @@
+2008-09-05 Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
+
+ Minor fix : Translation Rotation.
+
+ * mln/fun/x2x/translation.hh,
+ * mln/fun/x2x/rotation.hh: Fix wrong namespaces.
+ * sandbox/jardonnet/virtual/access.hh: Fix concept check.
+
+2008-09-03 Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
+
+ Add metal::array (1d,2d,3d).
+
+ * mln/metal/all.hh: Update.
+ * mln/metal/array.hh: Generic.
+ * mln/metal/array1d.hh: Container 1d.
+ * mln/metal/array2d.hh: Container 2d.
+ * mln/metal/array3d.hh: Container 3d.
+
2008-09-04 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add a tutorial example for Z.
diff --git a/milena/mln/fun/x2x/rotation.hh b/milena/mln/fun/x2x/rotation.hh
index 3fb3ef5..af1a0ca 100644
--- a/milena/mln/fun/x2x/rotation.hh
+++ b/milena/mln/fun/x2x/rotation.hh
@@ -53,7 +53,7 @@ namespace mln
*/
template <unsigned n, typename C>
struct rotation
- : internal::x2x_linear_impl_< algebra::vec<n,C>, rotation<n,C> >
+ : fun::internal::x2x_linear_impl_< algebra::vec<n,C>, rotation<n,C> >
, public Bijection_x2x< rotation<n,C> >
{
typedef fun::internal::x2x_linear_impl_< algebra::vec<n,C>, rotation<n,C> > super_;
diff --git a/milena/mln/fun/x2x/translation.hh b/milena/mln/fun/x2x/translation.hh
index 86713bf..f2075e0 100644
--- a/milena/mln/fun/x2x/translation.hh
+++ b/milena/mln/fun/x2x/translation.hh
@@ -53,10 +53,8 @@ namespace mln
*/
template <unsigned n, typename C>
struct translation
-
- : internal::x2x_linear_impl_< algebra::vec<n,C>, translation<n,C> >
- ,
- public Bijection_x2x< translation<n,C> >
+ : fun::internal::x2x_linear_impl_< algebra::vec<n,C>, translation<n,C> >
+ , public Bijection_x2x< translation<n,C> >
{
typedef fun::internal::x2x_linear_impl_< algebra::vec<n,C>, translation<n,C> > super_;
diff --git a/milena/mln/metal/all.hh b/milena/mln/metal/all.hh
index 511083f..e006e45 100644
--- a/milena/mln/metal/all.hh
+++ b/milena/mln/metal/all.hh
@@ -80,6 +80,11 @@ namespace mln
# include <mln/metal/math/all.hh>
+# include <mln/metal/array.hh>
+# include <mln/metal/array1d.hh>
+# include <mln/metal/array2d.hh>
+# include <mln/metal/array3d.hh>
+
// FIXME: Remove the following includes below!
# include <mln/metal/same_coord.hh>
# include <mln/metal/same_point.hh>
diff --git a/milena/mln/metal/array.hh b/milena/mln/metal/array.hh
new file mode 100644
index 0000000..1e2bb60
--- /dev/null
+++ b/milena/mln/metal/array.hh
@@ -0,0 +1,117 @@
+// Copyright (C) 2008 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_METAL_ARRAY_HH
+# define MLN_METAL_ARRAY_HH
+
+# include <mln/metal/array1d.hh>
+# include <mln/metal/array2d.hh>
+# include <mln/metal/array3d.hh>
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ // a1
+
+ template<unsigned i, class T, unsigned n> inline
+ T get_at(const array1d<T, n>& arr)
+ {
+ return arr.template get_at_<i>();
+ }
+
+ template<unsigned i, class T, unsigned n> inline
+ T get(const array1d<T, n>& arr)
+ {
+ return arr.template get_<i>();
+ }
+
+ // a2
+
+ template<unsigned row, unsigned col, class T,
+ unsigned r, unsigned c> inline
+ T get_at(const array2d<T, r, c>& arr)
+ {
+ return arr.template get_at_<row, col>();
+ }
+
+ template<unsigned row, unsigned col, class T,
+ unsigned r, unsigned c> inline
+ T get(const array2d<T, r, c>& arr)
+ {
+ return arr.template get_<row, col>();
+ }
+
+ // a3
+
+ template<unsigned sli, unsigned row, unsigned col,
+ class T, unsigned s, unsigned r, unsigned c> inline
+ T get_at(const array3d<T, s, r, c>& arr)
+ {
+ return arr.template get_at_<sli, row, col>();
+ }
+
+ template<unsigned sli, unsigned row, unsigned col,
+ class T, unsigned s, unsigned r, unsigned c> inline
+ T get_(const array3d<T, s, r, c>& arr)
+ {
+ return arr.template get_<sli, row, col>();
+ }
+
+ // print
+
+ template<typename T, unsigned n>
+ std::ostream& operator<<(std::ostream& ostr, const array1d<T, n>& rhs)
+ {
+ for (unsigned i = 0; i < n; ++i)
+ ostr << rhs[i] << " ";
+ ostr << std::endl;
+
+ return ostr;
+ }
+
+ template<typename T, unsigned r, unsigned c>
+ std::ostream& operator<<(std::ostream& ostr, const array2d<T, r, c>& rhs)
+ {
+ for (unsigned i = 0; i < r; ++i)
+ {
+ for (unsigned j = 0; j < c; ++j)
+ ostr << rhs(i,j) << '\t';
+ ostr << '\n';
+ }
+ ostr << std::endl;
+
+ return ostr;
+ }
+
+ }
+
+}
+
+#endif /* MLN_METAL_ARRAY_HH */
diff --git a/milena/mln/metal/array1d.hh b/milena/mln/metal/array1d.hh
new file mode 100644
index 0000000..7f441d8
--- /dev/null
+++ b/milena/mln/metal/array1d.hh
@@ -0,0 +1,298 @@
+// Copyright (C) 2008 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_METAL_ARRAY1D_HH
+# define MLN_METAL_ARRAY1D_HH
+
+# include <mln/core/concept/object.hh>
+
+# include <mln/trait/all.hh>
+# include <mln/trait/value_.hh>
+
+# include <mln/value/ops.hh>
+
+namespace mln
+{
+
+ // Fwd decls.
+ namespace metal {
+ template <typename T, unsigned Size> struct array1d;
+ }
+
+ namespace trait
+ {
+
+ template <typename T, unsigned Size>
+ struct value_< mln::metal::array1d<T,Size> >
+ {
+ typedef trait::value::nature::vectorial nature;
+ typedef trait::value::kind::data kind;
+
+ enum {
+ nbits = Size * mln_nbits(T),
+ card = Size * mln_card(T)
+ };
+ typedef mln_value_quant_from_(card) quant;
+
+ typedef metal::array1d<mln_sum(T),Size> sum;
+ };
+
+ } // end of namespace mln::trait
+
+
+ namespace metal
+ {
+
+ template <typename T, unsigned Size>
+ struct array1d : public Object< array1d<T,Size> >
+ {
+
+ //
+ // Constructors
+ //
+
+ array1d();
+ array1d(T* ptr);
+
+ // Copy
+
+ array1d(const array1d<T, Size>& rhs);
+ array1d<T, Size>& operator=(const array1d<T, Size>& rhs);
+
+ // Operators
+
+ template <class U>
+ array1d<T, Size> operator*(U w);
+
+ template <class U>
+ array1d<mln_trait_op_div(T,U), Size>
+ operator/(U w);
+
+ template <typename U>
+ array1d<mln_trait_op_plus(T,U), Size>
+ operator+(const array1d<U, Size>& rhs) const;
+ array1d<T, Size>& operator+=(const array1d<T, Size>& rhs);
+
+ template <typename U>
+ array1d<mln_trait_op_minus(T,U), Size>
+ operator-(const array1d<U, Size>& rhs) const;
+ array1d<T, Size>&
+ operator-=(const array1d<T, Size>& rhs);
+
+
+ // dynamic accessors:
+
+ T operator[](unsigned i) const {
+ mln_precondition(i < Size);
+ return buffer_[i];
+ }
+ T& operator[](unsigned i) {
+ mln_precondition(i < Size);
+ return buffer_[i];
+ }
+
+ // static accessor
+
+ template<unsigned i>
+ T get() const {
+ return buffer_[i];
+ }
+ template<unsigned i>
+ T& get() {
+ return buffer_[i];
+ }
+
+ enum { length = Size };
+ protected:
+
+ T buffer_[Size];
+ };
+
+ }
+
+ namespace trait
+ {
+
+ // For unary traits.
+
+ template < template <class> class Name,
+ unsigned n, typename T >
+ struct set_precise_unary_< Name, metal::array1d<T, n> >
+ {
+ typedef mln_trait_unary(Name, T) V;
+ typedef metal::array1d<V, n> ret;
+ };
+
+ // For binary traits.
+
+ template < template <class, class> class Name,
+ unsigned n, typename T,
+ typename U >
+ struct set_precise_binary_< Name,
+ metal::array1d<T, n>, metal::array1d<U, n> >
+ {
+ typedef mln_trait_binary(Name, T, U) V;
+ typedef metal::array1d<V, n> ret;
+ };
+
+ template < unsigned n, typename T,
+ typename U >
+ struct set_precise_binary_< op::times,
+ metal::array1d<T, n>, metal::array1d<U, n> >
+ {
+ typedef mln_sum_x(T,U) ret;
+ };
+
+ template < template <class, class> class Name,
+ unsigned n, typename T,
+ typename S >
+ struct set_precise_binary_< Name,
+ metal::array1d<T, n>, mln::value::scalar_<S> >
+ {
+ typedef mln_trait_binary(Name, T, S) V;
+ typedef metal::array1d<V, n> ret;
+ };
+
+ template < template<class, class> class Name,
+ unsigned n, typename T,
+ typename S >
+ struct set_binary_< Name,
+ mln::Object, metal::array1d<T, n>,
+ mln::value::Scalar, S >
+ {
+ typedef mln_trait_binary(Name, T, S) V;
+ typedef metal::array1d<T, n> ret;
+ };
+
+ } // end of namespace mln::trait
+
+
+ namespace metal
+ {
+
+ //
+ // Constructors
+ //
+
+ template <typename T, unsigned Size>
+ array1d<T,Size>::array1d()
+ {
+ }
+
+ template <typename T, unsigned Size>
+ array1d<T,Size>::array1d(T* ptr)
+ {
+ for (unsigned i = 0; i < Size; ++i)
+ buffer_[i] = *ptr++;
+ }
+
+ // Copy
+
+ template <typename T, unsigned Size>
+ array1d<T,Size>::array1d(const array1d<T, Size>& rhs)
+ {
+ for (unsigned i = 0; i < Size; ++i)
+ buffer_[i] = rhs[i];
+ }
+ template <typename T, unsigned Size>
+ array1d<T, Size>&
+ array1d<T,Size>::operator=(const array1d<T, Size>& rhs)
+ {
+ for (unsigned i = 0; i < Size; ++i)
+ buffer_[i] = rhs[i];
+ return *this;
+ }
+
+ // Operators
+
+ template <typename T, unsigned Size>
+ template <class U>
+ array1d<T, Size>
+ array1d<T,Size>::operator*(U w)
+ {
+ //fixme mln_trait_op_mult<int,U>
+ array1d<T, Size> tmp;
+ for (unsigned i = 0; i < Size; ++i)
+ tmp[i] = this->buffer_[i] * w;
+ return tmp;
+ }
+
+ template <typename T, unsigned Size>
+ template <class U>
+ array1d<mln_trait_op_div(T,U), Size>
+ array1d<T,Size>::operator/(U w)
+ {
+ array1d<T, Size> tmp;
+ for (unsigned i = 0; i < Size; ++i)
+ tmp[i] = this->buffer_[i] / w;
+ return tmp;
+ }
+
+ template <typename T, unsigned Size>
+ template <typename U>
+ array1d<mln_trait_op_plus(T,U), Size>
+ array1d<T,Size>::operator+(const array1d<U, Size>& rhs) const
+ {
+ array1d<T, Size> tmp;
+ for (unsigned i = 0; i < Size; ++i)
+ tmp[i] = this->buffer_[i] + rhs.buffer_[i];
+ return tmp;
+ }
+ template <typename T, unsigned Size>
+ array1d<T, Size>&
+ array1d<T,Size>::operator+=(const array1d<T, Size>& rhs)
+ {
+ for (unsigned i = 0; i < Size; ++i)
+ this->buffer_[i] += rhs.buffer_[i];
+ return *this;
+ }
+
+ template <typename T, unsigned Size>
+ template <typename U>
+ array1d<mln_trait_op_minus(T,U), Size>
+ array1d<T,Size>::operator-(const array1d<U, Size>& rhs) const
+ {
+ array1d<T, Size> tmp;
+ for (unsigned i = 0; i < Size; ++i)
+ tmp[i] = this->buffer_[i] - rhs.buffer_[i];
+ return tmp;
+ }
+ template <typename T, unsigned Size>
+ array1d<T, Size>&
+ array1d<T,Size>::operator-=(const array1d<T, Size>& rhs)
+ {
+ for (unsigned i = 0; i < Size; ++i)
+ this->buffer_[i] -= rhs.buffer_[i];
+ return *this;
+ }
+
+ } // end of namespace metal
+
+} // end of namespace mln
+
+#endif /* MLN_METAL_ARRAY1D_HH */
+
diff --git a/milena/mln/metal/array2d.hh b/milena/mln/metal/array2d.hh
new file mode 100644
index 0000000..4f3992a
--- /dev/null
+++ b/milena/mln/metal/array2d.hh
@@ -0,0 +1,309 @@
+// Copyright (C) 2008 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_METAL_ARRAY2D_HH
+# define MLN_METAL_ARRAY2D_HH
+
+# include <mln/core/concept/object.hh>
+
+# include <mln/trait/all.hh>
+# include <mln/trait/value_.hh>
+
+# include <mln/value/ops.hh>
+
+namespace mln
+{
+
+ // Fwd decls.
+ namespace metal {
+ template <typename T, unsigned r, unsigned c> struct array2d;
+ }
+
+ namespace trait
+ {
+
+ template <typename T, unsigned r, unsigned c>
+ struct value_< mln::metal::array2d<T, r, c> >
+ {
+ typedef trait::value::nature::vectorial nature;
+ typedef trait::value::kind::data kind;
+
+ enum {
+ nbits = r * c * mln_nbits(T),
+ card = r * c * mln_card(T)
+ };
+ typedef mln_value_quant_from_(card) quant;
+
+ typedef metal::array2d<mln_sum(T),r, c> sum;
+ };
+
+ } // end of namespace mln::trait
+
+
+ namespace metal
+ {
+
+ template <typename T, unsigned r, unsigned c>
+ struct array2d : public Object< array2d<T, r, c> >
+ {
+
+ //
+ // Constructors
+ //
+
+ array2d();
+ array2d(T* ptr);
+
+ // Copy
+
+ array2d(const array2d<T, r, c>& rhs);
+
+ array2d<T, r, c>& operator=(const array2d<T, r, c>& rhs);
+
+ // Operators
+
+ template <class U>
+ array2d<T, r, c> operator*(U w);
+
+ template <class U>
+ array2d<mln_trait_op_div(T,U), r, c>
+ operator/(U w);
+
+ template <typename U>
+ array2d<mln_trait_op_plus(T,U), r, c>
+ operator+(const array2d<U, r, c>& rhs) const;
+ array2d<T, r, c>& operator+=(const array2d<T, r, c>& rhs);
+
+ template <typename U>
+ array2d<mln_trait_op_minus(T,U), r, c>
+ operator-(const array2d<U, r, c>& rhs) const;
+ array2d<T, r, c>&
+ operator-=(const array2d<T, r, c>& rhs);
+
+ // dynamic accessors:
+
+ T operator()(unsigned row, unsigned col) const {
+ mln_precondition(row < r * c);
+ return buffer_[col * r + row];
+ }
+ T& operator()(unsigned row, unsigned col) {
+ mln_precondition(row < r * c);
+ return buffer_[col * r + row];
+ }
+
+ // static accessor
+
+ template<unsigned row, unsigned col>
+ T get() const {
+ return buffer_[col * r + row];
+ }
+ template<unsigned row, unsigned col>
+ T& get() {
+ return buffer_[col * r + row];
+ }
+
+ template<unsigned row, unsigned col>
+ T get_at() const {
+ mln_precondition(col * r + row < r *c);
+ return buffer_[col * r + row];
+ }
+ template<unsigned row, unsigned col>
+ T& get_at() {
+ mln_precondition(col * r + row < r *c);
+ return buffer_[col * r + row];
+ }
+
+ enum { length = r * c };
+ protected:
+
+ T buffer_[r * c];
+ };
+
+ }
+
+ namespace trait
+ {
+
+ // For unary traits.
+
+ template < template <class> class Name,
+ unsigned r, unsigned c, typename T >
+ struct set_precise_unary_< Name, metal::array2d<T, r, c> >
+ {
+ typedef mln_trait_unary(Name, T) V;
+ typedef metal::array2d<V, r, c> ret;
+ };
+
+ // For binary traits.
+
+ template < template <class, class> class Name,
+ unsigned r, unsigned c, typename T,
+ typename U >
+ struct set_precise_binary_< Name,
+ metal::array2d<T, r, c>, metal::array2d<U, r, c> >
+ {
+ typedef mln_trait_binary(Name, T, U) V;
+ typedef metal::array2d<V, r, c> ret;
+ };
+
+ template < unsigned r, unsigned c, typename T,
+ typename U >
+ struct set_precise_binary_< op::times,
+ metal::array2d<T, r, c>, metal::array2d<U, r, c> >
+ {
+ typedef mln_sum_x(T,U) ret;
+ };
+
+ template < template <class, class> class Name,
+ unsigned r, unsigned c, typename T,
+ typename S >
+ struct set_precise_binary_< Name,
+ metal::array2d<T, r, c>, mln::value::scalar_<S> >
+ {
+ typedef mln_trait_binary(Name, T, S) V;
+ typedef metal::array2d<V, r, c> ret;
+ };
+
+ template < template<class, class> class Name,
+ unsigned r, unsigned c, typename T,
+ typename S >
+ struct set_binary_< Name,
+ mln::Object, metal::array2d<T, r, c>,
+ mln::value::Scalar, S >
+ {
+ typedef mln_trait_binary(Name, T, S) V;
+ typedef metal::array2d<T, r, c> ret;
+ };
+
+ } // end of namespace mln::trait
+
+
+ namespace metal
+ {
+
+ //
+ // Constructors
+ //
+
+ template <typename T, unsigned r, unsigned c>
+ array2d<T, r, c>::array2d()
+ {
+ }
+
+ template <typename T, unsigned r, unsigned c>
+ array2d<T, r, c>::array2d(T* ptr)
+ {
+ for (unsigned i = 0; i < r * c; ++i)
+ buffer_[i] = *ptr++;
+ }
+
+ // Copy
+
+ template <typename T, unsigned r, unsigned c>
+ array2d<T, r, c>::array2d(const array2d<T, r, c>& rhs)
+ {
+ for (unsigned i = 0; i < r * c; ++i)
+ buffer_[i] = rhs[i];
+ }
+ template <typename T, unsigned r, unsigned c>
+ array2d<T, r, c>&
+ array2d<T, r, c>::operator=(const array2d<T, r, c>& rhs)
+ {
+ for (unsigned i = 0; i < r * c; ++i)
+ buffer_[i] = rhs[i];
+ return *this;
+ }
+
+ // Operators
+
+ template <typename T, unsigned r, unsigned c>
+ template <class U>
+ array2d<T, r, c>
+ array2d<T, r, c>::operator*(U w)
+ {
+ //fixme mln_trait_op_mult<int,U>
+ array2d<T, r, c> tmp;
+ for (unsigned i = 0; i < r * c; ++i)
+ tmp[i] = this->buffer_[i] * w;
+ return tmp;
+ }
+
+ template <typename T, unsigned r, unsigned c>
+ template <class U>
+ array2d<mln_trait_op_div(T,U), r, c>
+ array2d<T,r, c>::operator/(U w)
+ {
+ array2d<T, r, c> tmp;
+ for (unsigned i = 0; i < r * c; ++i)
+ tmp[i] = this->buffer_[i] / w;
+ return tmp;
+ }
+
+ template <typename T, unsigned r, unsigned c>
+ template <typename U>
+ array2d<mln_trait_op_plus(T,U), r, c>
+ array2d<T,r, c>::operator+(const array2d<U, r, c>& rhs) const
+ {
+ array2d<T, r, c> tmp;
+ for (unsigned i = 0; i < r * c; ++i)
+ tmp[i] = this->buffer_[i] + rhs.buffer_[i];
+ return tmp;
+ }
+ template <typename T, unsigned r, unsigned c>
+ array2d<T, r, c>&
+ array2d<T, r, c>::operator+=(const array2d<T, r, c>& rhs)
+ {
+ for (unsigned i = 0; i < r * c; ++i)
+ this->buffer_[i] += rhs.buffer_[i];
+ return *this;
+ }
+
+ template <typename T, unsigned r, unsigned c>
+ template <typename U>
+ array2d<mln_trait_op_minus(T,U), r, c>
+ array2d<T,r, c>::operator-(const array2d<U, r, c>& rhs) const
+ {
+ array2d<T, r, c> tmp;
+ for (unsigned i = 0; i < r * c; ++i)
+ tmp[i] = this->buffer_[i] - rhs.buffer_[i];
+ return tmp;
+ }
+ template <typename T, unsigned r, unsigned c>
+ array2d<T, r, c>&
+ array2d<T, r, c>::operator-=(const array2d<T, r, c>& rhs)
+ {
+ for (unsigned i = 0; i < r * c; ++i)
+ this->buffer_[i] -= rhs.buffer_[i];
+ return *this;
+ }
+
+ } // end of namespace metal
+
+} // end of namespace mln
+
+#endif /* MLN_METAL_ARRAY2D_HH */
+
diff --git a/milena/mln/metal/array3d.hh b/milena/mln/metal/array3d.hh
new file mode 100644
index 0000000..574d2a6
--- /dev/null
+++ b/milena/mln/metal/array3d.hh
@@ -0,0 +1,310 @@
+// Copyright (C) 2008 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_METAL_ARRAY3D_HH
+# define MLN_METAL_ARRAY3D_HH
+
+# include <mln/core/concept/object.hh>
+
+# include <mln/trait/all.hh>
+# include <mln/trait/value_.hh>
+
+# include <mln/value/ops.hh>
+
+namespace mln
+{
+
+ // Fwd decls.
+ namespace metal {
+ template <typename T, unsigned s, unsigned r, unsigned c> struct array3d;
+ }
+
+ namespace trait
+ {
+
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ struct value_< mln::metal::array3d<T,s, r, c> >
+ {
+ typedef trait::value::nature::vectorial nature;
+ typedef trait::value::kind::data kind;
+
+ enum {
+ nbits = s * r * c * mln_nbits(T),
+ card = s * r * c * mln_card(T)
+ };
+ typedef mln_value_quant_from_(card) quant;
+
+ typedef metal::array3d<mln_sum(T), s, r, c> sum;
+ };
+
+ } // end of namespace mln::trait
+
+
+ namespace metal
+ {
+
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ struct array3d : public Object< array3d<T, s, r, c> >
+ {
+
+ //
+ // Constructors
+ //
+
+ array3d();
+ array3d(T* ptr);
+
+ // Copy
+
+ array3d(const array3d<T, s, r, c>& rhs);
+ array3d<T, s, r, c>& operator=(const array3d<T, s, r, c>& rhs);
+
+ // Operators
+
+ template <class U>
+ array3d<T, s, r, c> operator*(U w);
+
+ template <class U>
+ array3d<mln_trait_op_div(T,U), s, r, c>
+ operator/(U w);
+
+ template <typename U>
+ array3d<mln_trait_op_plus(T,U), s, r, c>
+ operator+(const array3d<U, s, r, c>& rhs) const;
+ array3d<T, s, r, c>& operator+=(const array3d<T, s, r, c>& rhs);
+
+ template <typename U>
+ array3d<mln_trait_op_minus(T,U), s, r, c>
+ operator-(const array3d<U, s, r, c>& rhs) const;
+ array3d<T, s, r, c>&
+ operator-=(const array3d<T, s, r, c>& rhs);
+
+
+ // dynamic accessors:
+
+ T operator[](unsigned i) const {
+ mln_precondition(i < s * r * c);
+ return buffer_[i];
+ }
+ T& operator[](unsigned i) {
+ mln_precondition(i < s * r * c);
+ return buffer_[i];
+ }
+
+ // static accessor
+
+ template <unsigned sli, unsigned row, unsigned col>
+ T get() const {
+ return buffer_[sli * (row * col) + col * r + row];
+ }
+ template <unsigned sli, unsigned row, unsigned col>
+ T& get() {
+ return buffer_[sli * (row * col) + col * r + row];
+ }
+
+
+ template <unsigned sli, unsigned row, unsigned col>
+ T get_at() const {
+ mln_precondition(sli * (row * col) + col * r + row < s * r * c );
+ return buffer_[sli * (row * col) + col * r + row];
+ }
+ template <unsigned sli, unsigned row, unsigned col>
+ T& get_at() {
+ mln_precondition(sli * (row * col) + col * r + row < s * r * c );
+ return buffer_[sli * (row * col) + col * r + row];
+ }
+
+ enum { length = s * r * c };
+ protected:
+
+ T buffer_[s * r * c];
+ };
+
+ }
+
+ namespace trait
+ {
+
+ // For unary traits.
+
+ template < template <class> class Name,
+ unsigned s, unsigned r, unsigned c, typename T >
+ struct set_precise_unary_< Name, metal::array3d<T, s, r, c> >
+ {
+ typedef mln_trait_unary(Name, T) V;
+ typedef metal::array3d<V, s, r, c> ret;
+ };
+
+ // For binary traits.
+
+ template < template <class, class> class Name,
+ unsigned s, unsigned r, unsigned c, typename T,
+ typename U >
+ struct set_precise_binary_< Name,
+ metal::array3d<T, s, r, c>, metal::array3d<U, s, r, c> >
+ {
+ typedef mln_trait_binary(Name, T, U) V;
+ typedef metal::array3d<V, s, r, c> ret;
+ };
+
+ template < unsigned s, unsigned r, unsigned c, typename T,
+ typename U >
+ struct set_precise_binary_< op::times,
+ metal::array3d<T, s, r, c>, metal::array3d<U, s, r, c> >
+ {
+ typedef mln_sum_x(T,U) ret;
+ };
+
+ template < template <class, class> class Name,
+ unsigned s, unsigned r, unsigned c, typename T,
+ typename S >
+ struct set_precise_binary_< Name,
+ metal::array3d<T, s, r, c>, mln::value::scalar_<S> >
+ {
+ typedef mln_trait_binary(Name, T, S) V;
+ typedef metal::array3d<V, s, r, c> ret;
+ };
+
+ template < template<class, class> class Name,
+ unsigned s, unsigned r, unsigned c, typename T,
+ typename S >
+ struct set_binary_< Name,
+ mln::Object, metal::array3d<T, s, r, c>,
+ mln::value::Scalar, S >
+ {
+ typedef mln_trait_binary(Name, T, S) V;
+ typedef metal::array3d<T, s, r, c> ret;
+ };
+
+ } // end of namespace mln::trait
+
+
+ namespace metal
+ {
+
+ //
+ // Constructors
+ //
+
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ array3d<T,s, r, c>::array3d()
+ {
+ }
+
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ array3d<T,s, r, c>::array3d(T* ptr)
+ {
+ for (unsigned i = 0; i < s * r * c; ++i)
+ buffer_[i] = *ptr++;
+ }
+
+ // Copy
+
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ array3d<T,s, r, c>::array3d(const array3d<T, s, r, c>& rhs)
+ {
+ for (unsigned i = 0; i < s * r * c; ++i)
+ buffer_[i] = rhs[i];
+ }
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ array3d<T, s, r, c>&
+ array3d<T,s, r, c>::operator=(const array3d<T, s, r, c>& rhs)
+ {
+ for (unsigned i = 0; i < s * r * c; ++i)
+ buffer_[i] = rhs[i];
+ return *this;
+ }
+
+ // Operators
+
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ template <class U>
+ array3d<T, s, r, c>
+ array3d<T,s, r, c>::operator*(U w)
+ {
+ //fixme mln_trait_op_mult<int,U>
+ array3d<T, s, r, c> tmp;
+ for (unsigned i = 0; i < s * r * c; ++i)
+ tmp[i] = this->buffer_[i] * w;
+ return tmp;
+ }
+
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ template <class U>
+ array3d<mln_trait_op_div(T,U), s, r, c>
+ array3d<T,s, r, c>::operator/(U w)
+ {
+ array3d<T, s, r, c> tmp;
+ for (unsigned i = 0; i < s * r * c; ++i)
+ tmp[i] = this->buffer_[i] / w;
+ return tmp;
+ }
+
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ template <typename U>
+ array3d<mln_trait_op_plus(T,U), s, r, c>
+ array3d<T,s, r, c>::operator+(const array3d<U, s, r, c>& rhs) const
+ {
+ array3d<T, s, r, c> tmp;
+ for (unsigned i = 0; i < s * r * c; ++i)
+ tmp[i] = this->buffer_[i] + rhs.buffer_[i];
+ return tmp;
+ }
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ array3d<T, s, r, c>&
+ array3d<T,s, r, c>::operator+=(const array3d<T, s, r, c>& rhs)
+ {
+ for (unsigned i = 0; i < s * r * c; ++i)
+ this->buffer_[i] += rhs.buffer_[i];
+ return *this;
+ }
+
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ template <typename U>
+ array3d<mln_trait_op_minus(T,U), s, r, c>
+ array3d<T,s, r, c>::operator-(const array3d<U, s, r, c>& rhs) const
+ {
+ array3d<T, s, r, c> tmp;
+ for (unsigned i = 0; i < s * r * c; ++i)
+ tmp[i] = this->buffer_[i] - rhs.buffer_[i];
+ return tmp;
+ }
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ array3d<T, s, r, c>&
+ array3d<T,s, r, c>::operator-=(const array3d<T, s, r, c>& rhs)
+ {
+ for (unsigned i = 0; i < s * r * c; ++i)
+ this->buffer_[i] -= rhs.buffer_[i];
+ return *this;
+ }
+
+ } // end of namespace metal
+
+} // end of namespace mln
+
+#endif /* MLN_METAL_ARRAY3D_HH */
+
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 64366fc..9043427 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,3 +1,44 @@
+2008-09-05 Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
+
+ Sandbox: virtual transform, Add concept check.
+
+ * jardonnet/virtual/access.hh: Add concept check.
+ * jardonnet/virtual/access.cc: Update in consequence.
+
+2008-09-05 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
+
+ Fixes to install the gimp plugin.
+ * nivault/plugin-gimp/autogen.sh: s/main.c/main.cc
+ * nivault/plugin-gimp/configure.ac: move install dir to home to
+ install it without administrator rights (dirty)
+ * nivault/plugin-gimp/src/main.cc: Change place in the gimp menu.
+
+2008-09-04 Ugo Jardonnet <jardonnet(a)lrde.epita.fr>
+
+ Start working on image virtual transformation.
+
+ * jardonnet/virtual: New.
+ * jardonnet/virtual/access.hh (access): Virtual access to image.
+ It also contains image interpolation routines.
+ * jardonnet/virtual/access.cc: Test file.
+ * jardonnet/virtual/Makefile: New.
+
+2008-09-02 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
+
+ * geraud/fllt/fllt.svg.7.hh: Add comments to the working version of
+ FLLT.
+
+2008-09-01 Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
+
+ Sandbox: Update metal::array.
+
+ * jardonnet/array/array.cc: Update Test.
+ * jardonnet/array/array.hh: Add stc/dyn getters.
+ * jardonnet/array/Makefile: New.
+
+ * jardonnet/test/icp.cc: .
+ * jardonnet/registration/tools.hh: .
+
2008-06-19 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add kruskal algorithm in a sample morphological chain.
diff --git a/milena/sandbox/geraud/fllt/fllt.svg.7.hh b/milena/sandbox/geraud/fllt/fllt.svg.7.hh
index c2a2df3..105e4e6 100644
--- a/milena/sandbox/geraud/fllt/fllt.svg.7.hh
+++ b/milena/sandbox/geraud/fllt/fllt.svg.7.hh
@@ -331,9 +331,6 @@ namespace mln
++label;
- // if (holes.size() == 2)
- // std::cout << holes[0] << holes[1] << std::endl;
- // std::cout << " <<<<<<<exiting blob." << std::endl;
}
template <typename P, typename V>
@@ -393,7 +390,8 @@ namespace mln
}
}
- // LOWER LEVEL SET : region = c4, border = c8
+ // LOWER LEVEL SET information to compute the max tree.
+ // -> region = c4, border = c8
template <typename V>
struct lower
{
@@ -421,7 +419,8 @@ namespace mln
};
- // UPPER LEVEL SET : region = c8, border = c4
+ // UPPER LEVEL SET information to compute the max tree.
+ // -> region = c8, border = c4
template <typename V>
struct upper
{
@@ -445,6 +444,14 @@ namespace mln
static const neighb2d& reg_nbh() { return c8(); }
};
+ /*! Fast computation of a min/max tree.
+ *
+ * \param[in] input_ An input image.
+ * \param[out] smallest_shapes We stock in this image, for each point, a pointer
+ * to the smallest shape containing it.
+ * \return The min/max tree built.
+ *
+ */
template <typename I, typename Set>
fllt_tree(mln_point(I), mln_value(I))&
level_set(const Image<I>& input_,
@@ -560,7 +567,7 @@ namespace mln
deja_vu(x) = in_N;
}
}
- // gN = min u(x) for all x in N
+ // gN <- min u(x) for all x in N
update_gN(N, gN, Set());
// FIXME: update the number of CC of the border of R
@@ -609,7 +616,6 @@ namespace mln
// c)
else
{
- // FIXME: IDEA: this change might be performed while R is constructed(?)
n_step_4c++;
mln_piter(I) r(N_box);
for_all(r)
@@ -627,6 +633,15 @@ namespace mln
return *new tree_type(current_cc);
}
+ /*! Get the hole of a shape which contains a given point.
+ *
+ * \param[in] node a shape.
+ * \param[in] p a point.
+ * \param[in] other_reg The map which associate a point with its smallest shape
+ * of the oposite tree.
+ * \return true if A is included in B.
+ *
+ */
// F is the set in which we get the node.
template <typename P, typename V, typename F>
fllt_node(P, V)*
@@ -636,6 +651,7 @@ namespace mln
{
fllt_node(P, V)* s = other_reg(p);
mln_assertion(s);
+ // Go up the tree.
while (s->parent() && F::compare(s->parent()->elt().value, node.elt().value))
{
mln_assertion(s);
@@ -649,6 +665,14 @@ namespace mln
return s;
}
+ /*! Test the inclusion of two shapes of the same tree
+ *
+ * \param[in] A a shape.
+ * \param[in] B a shape.
+ * \return true if A is included in B.
+ *
+ * \pre The shapes have to come from the same tree.
+ */
template <typename P, typename V>
bool shape_is_included(fllt_node(P, V)* A,
fllt_node(P, V)* B)
@@ -656,6 +680,17 @@ namespace mln
return A->parent() == B || A == B;
}
+ /*! Associated the points of the holes of the min/max tree's shapes.
+ *
+ * \param[in] lower_tree The min tree.
+ * \param[in] upper_tree The max tree.
+ * \param[in] low_reg The map which associate a point with its smallest shape
+ * of the min tree.
+ * \param[in] upp_reg The map which associate a point with its smallest shape
+ * of the max tree.
+ * \return The merged tree.
+ *
+ */
template <typename P, typename V>
void find_all_holes(fllt_tree(P, V)& lower_tree,
fllt_tree(P, V)& upper_tree,
@@ -665,6 +700,7 @@ namespace mln
typedef p_array<P> arr_t;
typedef fllt_node(P, V) node_type;
+ // Get the holes of the min tree
{
fllt_branch_iter_ind(P, V) node_(lower_tree.main_branch());
for_all(node_)
@@ -676,6 +712,7 @@ namespace mln
}
}
+ // Get the holes of the max tree
{
fllt_branch_iter_ind(P, V) node_(upper_tree.main_branch());
for_all(node_)
@@ -688,6 +725,17 @@ namespace mln
}
}
+ /*! Merge the Min and the max tree.
+ *
+ * \param[in] lower_tree The min tree.
+ * \param[in] upper_tree The max tree.
+ * \param[in] low_reg The map which associate a point with its smallest shape
+ * of the min tree.
+ * \param[in] upp_reg The map which associate a point with its smallest shape
+ * of the max tree.
+ * \return The merged tree.
+ *
+ */
template <typename I>
fllt_tree(mln_point(I), mln_value(I))
merge_trees(fllt_tree(mln_point(I), mln_value(I))& lower_tree,
@@ -706,17 +754,24 @@ namespace mln
typedef p_array<P> arr_t;
+ // Here, a hole of a shape of the max or min tree is represented
+ // by a point belonging to this hole. We need to associate each of
+ // these points with its shape in the oposite tree.
find_all_holes(lower_tree, upper_tree, low_reg, upp_reg);
std::vector<node_type*> to_fill;
fllt_branch_iter_ind(P, V) node_(lower_tree.main_branch());
+ // Browse the shapes of the min_tree, in order to put as child of
+ // min tree's shapes the shapes of the max tree corresponding to
+ // their holes.
for_all(node_)
{
node_type& node = *node_;
+ // If the node was not in the min tree at the begining, we ignore it.
if (node.elt().set_id != lower<V>::id)
continue;
- // std::cout << "Fill " << &node << std::endl;
+ // Browse the holes of the shape.
typename std::vector<fllt_node(P, V)*>::iterator hole_;
for (hole_ = node.elt().hole_shapes.begin();
hole_ != node.elt().hole_shapes.end();
@@ -724,6 +779,7 @@ namespace mln
{
fllt_node(P, V)* hole = *hole_;
+ // Check if hole_ is contained by a hole of the children of node.
bool child_has_bigger_hole = false;
typename fllt_node(P, V)::children_t::iterator it;
for (it = node.children().begin(); it != node.children().end() && !child_has_bigger_hole; it++)
@@ -735,8 +791,6 @@ namespace mln
child_hole_++)
{
fllt_node(P, V)* child_hole = *child_hole_;
- // std::cout << "hole : " << hole << " " << hole->elt().points << " " << std::endl;
- // std::cout << "child hole : " << child_hole << " " << child_hole->elt().points << std::endl;
if (shape_is_included(hole, child_hole))
{
child_has_bigger_hole = true;
@@ -744,6 +798,9 @@ namespace mln
}
} // end of browsing child's holes.
} // end of browsing childs.
+
+ // If no, move the shape of the max tree previously associated to this hole.
+ // as child of node.
if (!child_has_bigger_hole)
{
// // std::cout << "move " << hole << " as child of " << &node << std::endl;
@@ -754,6 +811,12 @@ namespace mln
node.elt().holes.clear();
} // end of browsing lower_tree.
+ // At this step, we have filled all the holes of the min
+ // tree. But, by filling these holes, we introduced somes holes of
+ // the max tree in the result tree. We need to fill them.
+
+ // Thus, we browse the shapes of the max tree previously merged in
+ // the min tree, in order to check their holes.
for(typename std::vector<node_type*>::iterator node_ = to_fill.begin();
node_ != to_fill.end();
node_++)
@@ -767,6 +830,7 @@ namespace mln
if (node.elt().set_id != upper<V>::id)
continue;
+ // Check if hole_ is contained by a hole of the children of node.
typename std::vector<fllt_node(P, V)*>::iterator hole_;
for (hole_ = node.elt().hole_shapes.begin();
hole_ != node.elt().hole_shapes.end();
@@ -785,7 +849,6 @@ namespace mln
child_hole_++)
{
fllt_node(P, V)* child_hole = *child_hole_;
- //if (hole->elt().points <= child_hole->elt().points)
if (shape_is_included(hole, child_hole))
{
child_has_bigger_hole = true;
@@ -794,6 +857,8 @@ namespace mln
} // end of browsing child's holes.
} // end of browsing childs.
+ // If no, move the shape of the max tree previously associated to this hole.
+ // as child of node.
if (!child_has_bigger_hole)
node.add_child(hole);
@@ -806,6 +871,12 @@ namespace mln
return lower_tree;
}
+ /*! This function compute the fllt tree of an image.
+ *
+ * \param[in] input_ An input image.
+ * \return The computed tree.
+ *
+ */
template <typename I>
fllt_tree(mln_point(I), mln_value(I))
fllt(const Image<I>& input_)
@@ -820,12 +891,15 @@ namespace mln
image2d<fllt_node(P, V)*> low_reg(input.domain());
image2d<fllt_node(P, V)*> upp_reg(input.domain());
+ // Compute the Min tree.
std::cout << "1/ Compute the lower level set.----------------------------------------" << std::endl;
lower_tree = level_set<I, lower<V> >(input, low_reg);
+ // Compute the Max tree.
std::cout << "2/ Compute the upper level set.----------------------------------------" << std::endl;
upper_tree = level_set<I, upper<V> >(input, upp_reg);
+ // Merge the two trees.
std::cout << "3/ Merge.---------------------------------------------------------------" << std::endl;
fllt_tree(P, V) result_tree = merge_trees(lower_tree, upper_tree, low_reg, upp_reg, input);
diff --git a/milena/sandbox/jardonnet/array/Makefile b/milena/sandbox/jardonnet/array/Makefile
new file mode 100644
index 0000000..07c5494
--- /dev/null
+++ b/milena/sandbox/jardonnet/array/Makefile
@@ -0,0 +1,2 @@
+all:
+ g++ array.cc -I../../..
\ No newline at end of file
diff --git a/milena/sandbox/jardonnet/array/array.cc b/milena/sandbox/jardonnet/array/array.cc
index 1eb1447..d01897a 100644
--- a/milena/sandbox/jardonnet/array/array.cc
+++ b/milena/sandbox/jardonnet/array/array.cc
@@ -1,6 +1,6 @@
#include <iostream>
-#include <mln/metal/array.hh>
+#include "array.hh"
int main(int, char **)
{
@@ -9,4 +9,14 @@ int main(int, char **)
mln::metal::array1d<int, 5> c;
c = a + b;
+
+ a.get<0>() = 0;
+ a.get<1>() = 1;
+ a.get<2>() = 2;
+ a.get<3>() = 3;
+
+ for (int i = 0 ; i < a.length; i++)
+ std::cout << a[i] << " ";
+
+ std::cout << std::endl;
}
diff --git a/milena/sandbox/jardonnet/array/array.hh b/milena/sandbox/jardonnet/array/array.hh
index 57b798d..0934856 100644
--- a/milena/sandbox/jardonnet/array/array.hh
+++ b/milena/sandbox/jardonnet/array/array.hh
@@ -28,16 +28,47 @@
#ifndef MLN_METAL_ARRAY1D_HH
# define MLN_METAL_ARRAY1D_HH
+# include <mln/core/concept/object.hh>
+
# include <mln/trait/all.hh>
+# include <mln/trait/value_.hh>
+
+# include <mln/value/ops.hh>
namespace mln
{
+ // Fwd decls.
+ namespace metal {
+ template <typename T, unsigned Size> struct array1d;
+ }
+
+ namespace trait
+ {
+
+ template <typename T, unsigned Size>
+ struct value_< mln::metal::array1d<T,Size> >
+ {
+ typedef trait::value::nature::vectorial nature;
+ typedef trait::value::kind::data kind;
+
+ enum {
+ nbits = Size * mln_nbits(T),
+ card = Size * mln_card(T)
+ };
+ typedef mln_value_quant_from_(card) quant;
+
+ typedef metal::array1d<mln_sum(T),Size> sum;
+ };
+
+ } // end of namespace mln::trait
+
+
namespace metal
{
template <typename T, unsigned Size>
- struct array1d
+ struct array1d : public Object< array1d<T,Size> >
{
//
@@ -72,11 +103,99 @@ namespace mln
array1d<T, Size>&
operator-=(const array1d<T, Size>& rhs);
+
+ // dynamic accessors:
+
+ T operator[](unsigned i) const
+ {
+ mln_precondition(i < Size);
+ return buffer_[i];
+ }
+ T& operator[](unsigned i)
+ {
+ mln_precondition(i < Size);
+ return buffer_[i];
+ }
+
+ // static accessor
+
+ template<unsigned i>
+ T get() const {
+ return *(buffer_ + i);
+ }
+ template<unsigned i>
+ T& get() {
+ return *(buffer_ + i);
+ }
+
+ enum { length = Size };
protected:
T buffer_[Size];
};
+ }
+
+ namespace trait
+ {
+
+ // For unary traits.
+
+ template < template <class> class Name,
+ unsigned n, typename T >
+ struct set_precise_unary_< Name, metal::array1d<T, n> >
+ {
+ typedef mln_trait_unary(Name, T) V;
+ typedef metal::array1d<V, n> ret;
+ };
+
+ // For binary traits.
+
+ template < template <class, class> class Name,
+ unsigned n, typename T,
+ typename U >
+ struct set_precise_binary_< Name,
+ metal::array1d<T, n>, metal::array1d<U, n> >
+ {
+ typedef mln_trait_binary(Name, T, U) V;
+ typedef metal::array1d<V, n> ret;
+ };
+
+ template < unsigned n, typename T,
+ typename U >
+ struct set_precise_binary_< op::times,
+ metal::array1d<T, n>, metal::array1d<U, n> >
+ {
+ typedef mln_sum_x(T,U) ret;
+ };
+
+ template < template <class, class> class Name,
+ unsigned n, typename T,
+ typename S >
+ struct set_precise_binary_< Name,
+ metal::array1d<T, n>, mln::value::scalar_<S> >
+ {
+ typedef mln_trait_binary(Name, T, S) V;
+ typedef metal::array1d<V, n> ret;
+ };
+
+ template < template<class, class> class Name,
+ unsigned n, typename T,
+ typename S >
+ struct set_binary_< Name,
+ mln::Object, metal::array1d<T, n>,
+ mln::value::Scalar, S >
+ {
+ typedef mln_trait_binary(Name, T, S) V;
+ typedef metal::array1d<T, n> ret;
+ };
+
+ } // end of namespace mln::trait
+
+
+ namespace metal
+ {
+
//
// Constructors
//
diff --git a/milena/sandbox/jardonnet/array/old/1d.hh b/milena/sandbox/jardonnet/array/old/1d.hh
index c161e79..0da9f1a 100644
--- a/milena/sandbox/jardonnet/array/old/1d.hh
+++ b/milena/sandbox/jardonnet/array/old/1d.hh
@@ -236,9 +236,7 @@ namespace mlc
template<int i>
T get_() const {
- lesseq<-Info_::center, i>::ensure();
- lesseq<i, Info_::card - Info_::center - 1>::ensure();
- return *(buffer_ + Info_::center + i);
+ return *(buffer_ + i);
}
protected:
diff --git a/milena/sandbox/jardonnet/registration/tools.hh b/milena/sandbox/jardonnet/registration/tools.hh
index 99ee7de..624af17 100644
--- a/milena/sandbox/jardonnet/registration/tools.hh
+++ b/milena/sandbox/jardonnet/registration/tools.hh
@@ -193,23 +193,23 @@ namespace mln
namespace convert
{
- // to_p_array
- template <typename I>
- inline
- p_array<mln_psite(I)>
- to_p_array(const Image<I>& img_)
- {
- const I& img = exact(img_);
+// // to_p_array
+// template <typename I>
+// inline
+// p_array<mln_psite(I)>
+// to_p_array(const Image<I>& img_)
+// {
+// const I& img = exact(img_);
- p_array<mln_psite(I)> a;
+// p_array<mln_psite(I)> a;
- mln_piter(I) p(img.domain());
- for_all(p)
- if (img(p))
- a.append(p);
+// mln_piter(I) p(img.domain());
+// for_all(p)
+// if (img(p))
+// a.append(p);
- return a;
- }
+// return a;
+// }
template < typename P >
@@ -316,32 +316,6 @@ namespace mln
} // end of namespace convert
- namespace algebra
- {
-
- // transpose
- template<unsigned n, unsigned m, typename T>
- mat<m,n,T>
- trans(const mat<n,m,T>& matrice)
- {
- mat<m,n,T> tmp;
- for (unsigned i = 0; i < n; ++i)
- for (unsigned j = 0; j < m; ++j)
- tmp(j,i) = matrice(i,j);
- return tmp;
- }
-
- // trace
- template<unsigned n, typename T> inline
- float tr(const mat<n,n,T>& m)
- {
- float f = 0.f;
- for (unsigned i = 0; i < n; ++i)
- f += m(i,i);
- return f;
- }
-
- } // end of namespace algebra
} // end of namespace mln
diff --git a/milena/sandbox/jardonnet/test/icp.cc b/milena/sandbox/jardonnet/test/icp.cc
index bf7eebc..70b4f88 100644
--- a/milena/sandbox/jardonnet/test/icp.cc
+++ b/milena/sandbox/jardonnet/test/icp.cc
@@ -3,6 +3,7 @@
#include <mln/io/pbm/load.hh>
#include <mln/io/pbm/save.hh>
#include <mln/io/ppm/save.hh>
+#include <mln/convert/to_p_array.hh>
#include <mln/norm/l2.hh>
#include <sandbox/jardonnet/registration/icp.hh>
diff --git a/milena/sandbox/jardonnet/virtual/Makefile b/milena/sandbox/jardonnet/virtual/Makefile
new file mode 100644
index 0000000..f2fd44f
--- /dev/null
+++ b/milena/sandbox/jardonnet/virtual/Makefile
@@ -0,0 +1,2 @@
+all:
+ g++ access.cc -I../../..
\ No newline at end of file
diff --git a/milena/sandbox/jardonnet/virtual/access.cc b/milena/sandbox/jardonnet/virtual/access.cc
new file mode 100644
index 0000000..620ab74
--- /dev/null
+++ b/milena/sandbox/jardonnet/virtual/access.cc
@@ -0,0 +1,36 @@
+
+#include <iostream>
+#include "access.hh"
+#include <mln/core/image2d.hh>
+#include <mln/fun/x2x/all.hh>
+#include <mln/debug/iota.hh>
+#include <mln/algebra/vec.hh>
+
+int main()
+{
+ using namespace mln;
+ image2d<int> img(50,50);
+ point2d p(5,5);
+ algebra::vec<2,float> v = make::vec(3,4);
+ fun::x2x::translation<2,float> t(v);
+ interpolation::nearest_neighbor< image2d<int> > nn;
+
+ debug::iota(img);
+
+ for (int i = 0; i < 50; i++)
+ {
+ for (int j = 0; j < 50; j++)
+ std::cout << img(point2d(i,j));
+ std::cout << std::endl;
+ }
+
+ std::cout << std::endl;
+
+ for (int i = 3; i < 53; i++)
+ {
+ for (int j = 4; j < 54; j++)
+ std::cout <<
+ mln::access::access(img, point2d(i,j), t, nn);
+ std::cout << std::endl;
+ }
+}
diff --git a/milena/sandbox/jardonnet/virtual/access.hh b/milena/sandbox/jardonnet/virtual/access.hh
new file mode 100644
index 0000000..d5684e7
--- /dev/null
+++ b/milena/sandbox/jardonnet/virtual/access.hh
@@ -0,0 +1,126 @@
+#ifndef _ACCESS_HH
+# define _ACCESS_HH
+
+# include <mln/core/image1d.hh>
+# include <mln/core/image2d.hh>
+# include <mln/metal/is.hh>
+# include <mln/core/concept/function.hh>
+
+namespace mln
+{
+
+ namespace interpolation
+ {
+
+ template < typename I >
+ struct nearest_neighbor
+ : public Function_x2x< nearest_neighbor<I> >
+ {
+ typedef mln_value(I) result;
+
+ template < typename V >
+ mln_value(I)
+ operator()(const I& img, const V& v) const
+ {
+ mln_point(I) p = algebra::to_point<mln_point(I)>(v);
+ return img(p);
+ }
+
+ };
+
+ template < typename I >
+ struct linear
+ : public Function_x2x< linear<I> >
+ {
+ typedef mln_value(I) result;
+
+ template <typename C>
+ mln_value(I)
+ operator()(const I& img,
+ const algebra::vec<1,C>& v) const
+ {
+ // looking for img(x);
+ double x = v[0];
+
+ // p1
+ double xa = mln_point(I)::coord(v[0]);
+ double ya = img(point1d(xa));
+
+ // x makes sens in img
+ if (x == xa)
+ return img(xa);
+
+ // p2
+ double xb = mln_point(I)::coord(v[0] + 1);
+ double yb = img(point1d(xb));
+
+ // Taylor-young
+ return ya + (x - xa) * (yb - ya) / (xb - xa);
+ }
+ };
+
+ template < typename I >
+ struct bilinear
+ : public Function_x2x< bilinear<I> >
+ {
+ typedef mln_value(I) result;
+
+ template <typename V>
+ mln_value(I)
+ operator()(const I& img, const V& v) const
+ {
+ // q12----r2----q22
+ // | | |
+ // | x |
+ // | | |
+ // q11----r1----q21
+
+ // looking for img(P(x,y))
+ double x = v[0];
+ double y = v[1];
+
+ double x1 = mln_point(I)::coord(v[0]);
+ double x2 = mln_point(I)::coord(v[0]+ 1);
+ double y1 = mln_point(I)::coord(v[1]);
+ double y2 = mln_point(I)::coord(v[1]+ 1);
+
+ point2d q11 = point2d(x1, y1);
+ point2d q12 = point2d(x1, y2);
+ point2d q21 = point2d(x2, y1);
+ point2d q22 = point2d(x2, y2);
+
+ // linear interpolation #1
+ mln_value(I) img_r1 = img(q11) * (x2 - x) / (x2 - x1) +
+ img(q21) * (x - x1) / (x2 - x1);
+
+ // linear interpolation #2
+ mln_value(I) img_r2 = img(q12) * (x2 - x) / (x2 - x1) +
+ img(q22) * (x - x1) / (x2 - x1);
+
+ // interpolating in y direction
+ return img_r1 * (y2 - y) / (y2 -y1)
+ + img_r2 * (y - y1) /(y2 - y1);
+ }
+ };
+ }
+
+ namespace access
+ {
+
+ template <typename I, typename T, typename F>
+ mln_value(I)
+ access(const I& img, const mln_point(I)& p,
+ const T& trans, const F& interp)
+ {
+ mlc_is(typename T::invert, Bijection_x2x<typename T::invert>)::check();
+ mlc_is(F, Function_x2x<F>)::check();
+
+ return interp(img, (trans.inv())(p));
+ }
+
+ }
+
+}
+
+#endif /* _ACCESS_HH */
+
diff --git a/milena/sandbox/nivault/plugin-gimp/autogen.sh b/milena/sandbox/nivault/plugin-gimp/autogen.sh
index 67c0744..2a28f72 100755
--- a/milena/sandbox/nivault/plugin-gimp/autogen.sh
+++ b/milena/sandbox/nivault/plugin-gimp/autogen.sh
@@ -10,7 +10,7 @@
PROJECT="GIMP Plug-In Template"
TEST_TYPE=-f
-FILE=src/main.c
+FILE=src/main.cc
AUTOCONF_REQUIRED_VERSION=2.54
AUTOMAKE_REQUIRED_VERSION=1.6
diff --git a/milena/sandbox/nivault/plugin-gimp/configure.ac b/milena/sandbox/nivault/plugin-gimp/configure.ac
index a91ecdf..85a24d2 100644
--- a/milena/sandbox/nivault/plugin-gimp/configure.ac
+++ b/milena/sandbox/nivault/plugin-gimp/configure.ac
@@ -59,7 +59,8 @@ PKG_CHECK_MODULES(GIMP,
AC_SUBST(GIMP_CFLAGS)
AC_SUBST(GIMP_LIBS)
-GIMP_LIBDIR=`$PKG_CONFIG --variable=gimplibdir gimp-2.0`
+#GIMP_LIBDIR=`$PKG_CONFIG --variable=gimplibdir gimp-2.0`
+GIMP_LIBDIR=`echo ~/.gimp-2.4`
AC_SUBST(GIMP_LIBDIR)
diff --git a/milena/sandbox/nivault/plugin-gimp/src/main.cc b/milena/sandbox/nivault/plugin-gimp/src/main.cc
index d9f38ea..aa49d7f 100644
--- a/milena/sandbox/nivault/plugin-gimp/src/main.cc
+++ b/milena/sandbox/nivault/plugin-gimp/src/main.cc
@@ -84,7 +84,7 @@ query (void)
G_N_ELEMENTS (args), 0,
args, NULL);
- gimp_plugin_menu_register (PROCEDURE_NAME, "<Image>/Tools/");
+ gimp_plugin_menu_register (PROCEDURE_NAME, "<Image>/Filters/Milena");
}
static void
2
2
From: Matthieu Garrigues <garrigues(a)lrde.epita.fr>
To: olena-patches(a)lrde.epita.fr
Subject: milena r2200: Rename data_ as data
URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
ChangeLog:
2008-09-08 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Rename data_ as data.
* mln/core/image/bgraph_image.hh: .
* mln/core/image/cast_image.hh: .
* mln/core/image/complex_image.hh: .
* mln/core/image/decorated_image.hh: .
* mln/core/image/fi_adaptor.hh: .
* mln/core/image/graph_image.hh: .
* mln/core/image/hexa.hh: .
* mln/core/image/image1d.hh: .
* mln/core/image/image3d.hh: .
* mln/core/image/interpolated.hh: .
* mln/core/image/lazy_image.hh: .
* mln/core/image/line_graph_image.hh: .
* mln/core/image/mono_obased_rle_image.hh: .
* mln/core/image/mono_rle_image.hh: .
* mln/core/image/rle_image.hh: .
* mln/core/image/t_image.hh: .
* mln/core/image/tr_image.hh: .
* mln/core/image/translate_image.hh: .
* mln/core/image/value_enc_image.hh: .
* mln/core/internal/image_if_base.hh: .
* mln/neighb/image.hh: .
* mln/value/stack.hh: .
---
core/image/bgraph_image.hh | 8 ++++----
core/image/cast_image.hh | 12 ++++++------
core/image/complex_image.hh | 8 ++++----
core/image/decorated_image.hh | 10 +++++-----
core/image/fi_adaptor.hh | 24 ++++++++++++------------
core/image/graph_image.hh | 8 ++++----
core/image/hexa.hh | 10 +++++-----
core/image/image1d.hh | 30 +++++++++++++++---------------
core/image/image3d.hh | 30 +++++++++++++++---------------
core/image/interpolated.hh | 10 +++++-----
core/image/lazy_image.hh | 10 +++++-----
core/image/line_graph_image.hh | 8 ++++----
core/image/mono_obased_rle_image.hh | 14 +++++++-------
core/image/mono_rle_image.hh | 14 +++++++-------
core/image/rle_image.hh | 16 ++++++++--------
core/image/t_image.hh | 10 +++++-----
core/image/tr_image.hh | 10 +++++-----
core/image/translate_image.hh | 10 +++++-----
core/image/value_enc_image.hh | 12 ++++++------
core/internal/image_if_base.hh | 10 +++++-----
neighb/image.hh | 10 +++++-----
value/stack.hh | 10 +++++-----
22 files changed, 142 insertions(+), 142 deletions(-)
Index: branches/cleanup-2008/milena/mln/core/image/lazy_image.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/image/lazy_image.hh (revision
2199)
+++ branches/cleanup-2008/milena/mln/core/image/lazy_image.hh (revision
2200)
@@ -51,9 +51,9 @@
/// \internal Data structure for \c mln::lazy_image<I>.
template <typename I, typename F, typename B>
- struct data_< lazy_image<I,F,B> >
+ struct data< lazy_image<I,F,B> >
{
- data_(const F& fun_, const B& box);
+ data(const F& fun_, const B& box);
mutable mln_ch_value(I,mln_result(F)) ima_;
mutable mln_ch_value(I,bool) is_known;
@@ -144,11 +144,11 @@
namespace internal
{
- // internal::data_< lazy_image<I,S> >
+ // internal::data< lazy_image<I,S> >
template <typename I, typename F, typename B>
inline
- data_< lazy_image<I,F,B> >::data_(const F& fun, const B& box)
+ data< lazy_image<I,F,B> >::data(const F& fun, const B& box)
: ima_(box), is_known(box), fun(fun), bb_(box)
{
}
@@ -159,7 +159,7 @@
inline
lazy_image<I,F,B>::lazy_image(const F& fun, const B& box)
{
- this->data_ = new internal::data_< lazy_image<I,F,B> >(fun, box);
+ this->data_ = new internal::data< lazy_image<I,F,B> >(fun, box);
}
template <typename I, typename F, typename B>
Index: branches/cleanup-2008/milena/mln/core/image/cast_image.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/image/cast_image.hh (revision
2199)
+++ branches/cleanup-2008/milena/mln/core/image/cast_image.hh (revision
2200)
@@ -52,9 +52,9 @@
{
/// \internal Data structure for \c mln::cast_image_<T,I>.
template <typename T, typename I>
- struct data_< cast_image_<T,I> >
+ struct data< cast_image_<T,I> >
{
- data_(const I& ima);
+ data(const I& ima);
const I& ima_;
};
@@ -68,7 +68,7 @@
template <typename T, typename I>
struct image_< cast_image_<T,I> > : default_image_morpher< I, T,
cast_image_<T,I> >
{
- typedef trait::image::io::read_only io;
+ typedef trait::image::value_io::read_only value_io;
};
} // end of namespace mln::trait
@@ -123,14 +123,14 @@
# ifndef MLN_INCLUDE_ONLY
- // internal::data_< cast_image_<T,I> >
+ // internal::data< cast_image_<T,I> >
namespace internal
{
template <typename T, typename I>
inline
- data_< cast_image_<T,I> >::data_(const I& ima)
+ data< cast_image_<T,I> >::data(const I& ima)
: ima_(ima)
{
}
@@ -145,7 +145,7 @@
cast_image_<T,I>::cast_image_(const Image<I>& ima)
{
mln_precondition(exact(ima).has_data());
- this->data_ = new internal::data_< cast_image_<T,I> >(exact(ima));
+ this->data_ = new internal::data< cast_image_<T,I> >(exact(ima));
}
template <typename T, typename I>
Index: branches/cleanup-2008/milena/mln/core/image/decorated_image.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/image/decorated_image.hh
(revision 2199)
+++ branches/cleanup-2008/milena/mln/core/image/decorated_image.hh
(revision 2200)
@@ -65,9 +65,9 @@
/// \internal Data structure for \c mln::decorated_image<I,D>.
template <typename I, typename D>
- struct data_< decorated_image<I,D> >
+ struct data< decorated_image<I,D> >
{
- data_(I& ima, const D& deco);
+ data(I& ima, const D& deco);
I ima_;
D deco_;
@@ -143,10 +143,10 @@
namespace internal
{
- /// \internal internal::data_< decorated_image<I,S> >
+ /// \internal internal::data< decorated_image<I,S> >
template <typename I, typename D>
inline
- data_< decorated_image<I,D> >::data_(I& ima, const D& deco)
+ data< decorated_image<I,D> >::data(I& ima, const D& deco)
: ima_(ima),
deco_(deco)
{
@@ -166,7 +166,7 @@
inline
decorated_image<I,D>::decorated_image(I& ima, const D& deco)
{
- this->data_ = new internal::data_< decorated_image<I,D> >(ima, deco);
+ this->data_ = new internal::data< decorated_image<I,D> >(ima, deco);
}
template <typename I, typename D>
Index: branches/cleanup-2008/milena/mln/core/image/translate_image.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/image/translate_image.hh
(revision 2199)
+++ branches/cleanup-2008/milena/mln/core/image/translate_image.hh
(revision 2200)
@@ -51,9 +51,9 @@
/// \internal Data structure for \c mln::translate_image<I>.
template <typename I>
- struct data_< translate_image<I> >
+ struct data< translate_image<I> >
{
- data_(I& ima, const mln_dpsite(I) dp);
+ data(I& ima, const mln_dpsite(I) dp);
I ima_;
@@ -137,11 +137,11 @@
namespace internal
{
- // internal::data_< translate_image<I,S> >
+ // internal::data< translate_image<I,S> >
template <typename I>
inline
- data_< translate_image<I> >::data_(I& ima, const mln_dpsite(I) dp)
+ data< translate_image<I> >::data(I& ima, const mln_dpsite(I) dp)
: ima_ (ima),
dp_ (dp)
{
@@ -162,7 +162,7 @@
translate_image<I>::translate_image(I& ima, const mln_dpsite(I) dp)
{
mln_precondition(ima.has_data());
- this->data_ = new internal::data_< translate_image<I> >(ima, dp);
+ this->data_ = new internal::data< translate_image<I> >(ima, dp);
}
template <typename I>
Index: branches/cleanup-2008/milena/mln/core/image/graph_image.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/image/graph_image.hh (revision
2199)
+++ branches/cleanup-2008/milena/mln/core/image/graph_image.hh (revision
2200)
@@ -51,9 +51,9 @@
/// \internal Data structure for \c mln::graph_image<P,V>.
template <typename P, typename V>
- struct data_< graph_image<P, V> >
+ struct data< graph_image<P, V> >
{
- data_(const p_graph<P>& pg, const std::vector<V>& val);
+ data(const p_graph<P>& pg, const std::vector<V>& val);
std::vector<V> val_;
const p_graph<P> pg_;
@@ -179,7 +179,7 @@
{
template <typename P, typename V>
inline
- data_< graph_image<P, V> >::data_(const p_graph<P>& pg,
+ data< graph_image<P, V> >::data(const p_graph<P>& pg,
const std::vector<V>& val)
: val_ (val),
pg_ (pg)
@@ -220,7 +220,7 @@
graph_image<P, V>::init_(const p_graph<P>& pg, const std::vector<V>&
val)
{
mln_precondition(! this->has_data());
- this->data_ = new internal::data_< graph_image<P, V> > (pg, val);
+ this->data_ = new internal::data< graph_image<P, V> > (pg, val);
}
/*---------------.
Index: branches/cleanup-2008/milena/mln/core/image/value_enc_image.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/image/value_enc_image.hh
(revision 2199)
+++ branches/cleanup-2008/milena/mln/core/image/value_enc_image.hh
(revision 2200)
@@ -54,9 +54,9 @@
/// \internal Data structure for \c mln::value_enc_image<P,T>.
template <typename P, typename T>
- struct data_< value_enc_image<P, T> >
+ struct data< value_enc_image<P, T> >
{
- data_();
+ data();
/// Image values.
std::vector<T> values_;
@@ -146,11 +146,11 @@
namespace internal
{
- // internal::data_< value_enc_image<P, T> >
+ // internal::data< value_enc_image<P, T> >
template <typename P, typename T>
inline
- data_< value_enc_image<P,T> >::data_()
+ data< value_enc_image<P,T> >::data()
{
}
@@ -161,7 +161,7 @@
inline
value_enc_image<P, T>::value_enc_image()
{
- this->data_ = new internal::data_< value_enc_image<P,T> >();
+ this->data_ = new internal::data< value_enc_image<P,T> >();
}
template <typename P, typename T>
@@ -178,7 +178,7 @@
value_enc_image<P, T>::insert(const p_runs_<P>& ps, T value)
{
if (!this->has_data())
- this->data_ = new internal::data_< value_enc_image<P,T> >();
+ this->data_ = new internal::data< value_enc_image<P,T> >();
this->data_->domain_.insert(ps);
this->data_->values_.push_back(value);
Index: branches/cleanup-2008/milena/mln/core/image/line_graph_image.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/image/line_graph_image.hh
(revision 2199)
+++ branches/cleanup-2008/milena/mln/core/image/line_graph_image.hh
(revision 2200)
@@ -65,9 +65,9 @@
/// \internal Data structure for \c mln::line_graph_image<P,V>.
template <typename P, typename V>
- struct data_< line_graph_image<P, V> >
+ struct data< line_graph_image<P, V> >
{
- data_(const p_line_graph<P>& plg,
+ data(const p_line_graph<P>& plg,
const std::vector<V>& vertex_val, const std::vector<V>& edge_val);
std::vector<V> vertex_val_;
@@ -205,7 +205,7 @@
{
template <typename P, typename V>
inline
- data_< line_graph_image<P, V> >::data_(const p_line_graph<P>& plg,
+ data< line_graph_image<P, V> >::data(const p_line_graph<P>& plg,
const std::vector<V>& vertex_val,
const std::vector<V>& edge_val)
: vertex_val_(vertex_val),
@@ -253,7 +253,7 @@
{
mln_precondition(! this->has_data());
this->data_ =
- new internal::data_< line_graph_image<P, V> >(plg, vertex_val,
edge_val);
+ new internal::data< line_graph_image<P, V> >(plg, vertex_val,
edge_val);
}
/*---------------.
Index: branches/cleanup-2008/milena/mln/core/image/rle_image.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/image/rle_image.hh (revision 2199)
+++ branches/cleanup-2008/milena/mln/core/image/rle_image.hh (revision 2200)
@@ -51,9 +51,9 @@
/// \internal Data structure for \c mln::rle_image<P,T>.
template <typename P, typename T>
- struct data_< rle_image<P,T> >
+ struct data< rle_image<P,T> >
{
- data_();
+ data();
/// Image values.
std::vector<T> values_;
@@ -141,18 +141,18 @@
namespace internal
{
- // internal::data_< rle_image<I,S> >
+ // internal::data< rle_image<I,S> >
template <typename P, typename T>
inline
- data_< rle_image<P,T> >::data_()
+ data< rle_image<P,T> >::data()
{
}
template <typename P, typename T>
inline
unsigned
- data_< rle_image<P,T> >::size_mem() const
+ data< rle_image<P,T> >::size_mem() const
{
return sizeof(T) * values_.size() + domain_.size_mem();
}
@@ -160,7 +160,7 @@
template <typename P, typename T>
inline
void
- data_< rle_image<P,T> >::finalize()
+ data< rle_image<P,T> >::finalize()
{
domain_.finalize();
}
@@ -171,7 +171,7 @@
inline
rle_image<P, T>::rle_image()
{
- this->data_ = new internal::data_< rle_image<P,T> >();
+ this->data_ = new internal::data< rle_image<P,T> >();
}
template <typename P, typename T>
@@ -188,7 +188,7 @@
rle_image<P, T>::insert(const p_run<P>& pr, T value)
{
if (!this->has_data())
- this->data_ = new internal::data_< rle_image<P,T> >();
+ this->data_ = new internal::data< rle_image<P,T> >();
mln_assertion(this->data_->values_.size() == 0 ||
pr.first() > this->data_->domain_[this->data_->domain_.nruns() -
1].first());
this->data_->domain_.insert(pr);
Index: branches/cleanup-2008/milena/mln/core/image/hexa.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/image/hexa.hh (revision 2199)
+++ branches/cleanup-2008/milena/mln/core/image/hexa.hh (revision 2200)
@@ -52,9 +52,9 @@
{
/// \internal Data structure for \c mln::hexa<I>.
template <typename I>
- struct data_< hexa<I> >
+ struct data< hexa<I> >
{
- data_(I& ima, box2d_h b);
+ data(I& ima, box2d_h b);
I ima_;
mln::box2d_h b_;
@@ -185,14 +185,14 @@
- // internal::data_< hexa<I> >
+ // internal::data< hexa<I> >
namespace internal
{
template <typename I>
inline
- data_< hexa<I> >::data_(I& ima, box2d_h b)
+ data< hexa<I> >::data(I& ima, box2d_h b)
: ima_(ima),
b_(b)
{
@@ -210,7 +210,7 @@
box2d b_in = ima.bbox();
box2d_h b = make::box2d_h(b_in.pmin()[0] * 2, b_in.pmin()[1],
b_in.pmax()[0] * 2, (b_in.pmax()[1] + 1) * 2 - 1);
- this->data_ = new internal::data_< hexa<I> >(ima, b);
+ this->data_ = new internal::data< hexa<I> >(ima, b);
}
Index: branches/cleanup-2008/milena/mln/core/image/tr_image.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/image/tr_image.hh (revision 2199)
+++ branches/cleanup-2008/milena/mln/core/image/tr_image.hh (revision 2200)
@@ -53,9 +53,9 @@
/// \internal Data structure for \c mln::tr_image<T,I>.
template <typename T, typename I>
- struct data_< tr_image<T,I> >
+ struct data< tr_image<T,I> >
{
- data_(I& ima, T& tr);
+ data(I& ima, T& tr);
I ima_;
T tr_;
@@ -133,11 +133,11 @@
namespace internal
{
- // internal::data_< tr_image<I,S> >
+ // internal::data< tr_image<I,S> >
template <typename T, typename I>
inline
- data_< tr_image<T,I> >::data_(I& ima, T& tr)
+ data< tr_image<T,I> >::data(I& ima, T& tr)
: ima_(ima),
tr_(tr)
{
@@ -150,7 +150,7 @@
tr_image<T,I>::tr_image(I& ima, T& tr)
{
mln_precondition(ima.has_data());
- this->data_ = new internal::data_< tr_image<T,I> >(ima, tr);
+ this->data_ = new internal::data< tr_image<T,I> >(ima, tr);
}
template <typename T, typename I>
Index: branches/cleanup-2008/milena/mln/core/image/mono_obased_rle_image.hh
===================================================================
---
branches/cleanup-2008/milena/mln/core/image/mono_obased_rle_image.hh
(revision 2199)
+++
branches/cleanup-2008/milena/mln/core/image/mono_obased_rle_image.hh
(revision 2200)
@@ -53,9 +53,9 @@
/// \internal Data structure for \c mln::mono_obased_rle_image<P,T>.
template <typename P, typename T>
- struct data_< mono_obased_rle_image<P,T> >
+ struct data< mono_obased_rle_image<P,T> >
{
- data_(const std::set<T>& values);
+ data(const std::set<T>& values);
/// Objects.
std::vector< mono_rle_image<P, T> > ima_;
@@ -149,11 +149,11 @@
namespace internal
{
- // internal::data_< mono_obased_rle_image<P,T> >
+ // internal::data< mono_obased_rle_image<P,T> >
template <typename P, typename T>
inline
- data_< mono_obased_rle_image<P,T> >::data_(const std::set<T>& values)
+ data< mono_obased_rle_image<P,T> >::data(const std::set<T>& values)
: ima_(values.begin(), values.end())
{
}
@@ -161,7 +161,7 @@
template <typename P, typename T>
inline
unsigned
- data_< mono_obased_rle_image<P,T> >::size_mem() const
+ data< mono_obased_rle_image<P,T> >::size_mem() const
{
return domain_.size_mem() * 2 + sizeof(T) * (values_.size() +
ima_.size());
}
@@ -169,7 +169,7 @@
template <typename P, typename T>
inline
void
- data_< mono_obased_rle_image<P,T> >::finalize()
+ data< mono_obased_rle_image<P,T> >::finalize()
{
domain_.finalize();
for (typename std::vector< mono_rle_image<P, T> >::iterator it =
ima_.begin();
@@ -183,7 +183,7 @@
inline
mono_obased_rle_image<P, T>::mono_obased_rle_image(const
std::set<T>& values)
{
- this->data_ = new internal::data_< mono_obased_rle_image<P,T>
>(values);
+ this->data_ = new internal::data< mono_obased_rle_image<P,T> >(values);
}
template <typename P, typename T>
Index: branches/cleanup-2008/milena/mln/core/image/interpolated.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/image/interpolated.hh
(revision 2199)
+++ branches/cleanup-2008/milena/mln/core/image/interpolated.hh
(revision 2200)
@@ -51,9 +51,9 @@
/// \internal Data structure for \c mln::interpolated<I>.
template <typename I>
- struct data_< interpolated<I> >
+ struct data< interpolated<I> >
{
- data_(I& ima);
+ data(I& ima);
I ima_;
};
@@ -117,11 +117,11 @@
namespace internal
{
- // internal::data_< interpolated<I,S> >
+ // internal::data< interpolated<I,S> >
template <typename I>
inline
- data_< interpolated<I> >::data_(I& ima)
+ data< interpolated<I> >::data(I& ima)
: ima_(ima)
{
}
@@ -133,7 +133,7 @@
interpolated<I>::interpolated(I& ima)
{
mln_precondition(ima.has_data());
- this->data_ = new internal::data_< interpolated<I> >(ima);
+ this->data_ = new internal::data< interpolated<I> >(ima);
}
template <typename I>
Index: branches/cleanup-2008/milena/mln/core/image/bgraph_image.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/image/bgraph_image.hh
(revision 2199)
+++ branches/cleanup-2008/milena/mln/core/image/bgraph_image.hh
(revision 2200)
@@ -51,12 +51,12 @@
/// \internal Data structure for \c mln::bgraph_image<P,V>.
template <typename P, typename V>
- struct data_< bgraph_image<P, V> >
+ struct data< bgraph_image<P, V> >
{
/// Data stores a **copy** of the pset g.
/// But, the pset g and the data_ copy will shared the same
/// underlaying graph.
- data_(const p_bgraph<P>& g, const std::vector<V>& val);
+ data(const p_bgraph<P>& g, const std::vector<V>& val);
p_bgraph<P> pg_;
@@ -179,7 +179,7 @@
{
template <typename P, typename V>
inline
- data_< bgraph_image<P, V> >::data_(const p_bgraph<P>& g,
+ data< bgraph_image<P, V> >::data(const p_bgraph<P>& g,
const std::vector<V>& val)
: pg_ (g),
val_ (val)
@@ -218,7 +218,7 @@
void
bgraph_image<P, V>::init_(const p_bgraph<P>& g, const
std::vector<V>& val)
{
- this->data_ = new internal::data_< bgraph_image<P, V> > (g, val);
+ this->data_ = new internal::data< bgraph_image<P, V> > (g, val);
}
/*---------------.
Index: branches/cleanup-2008/milena/mln/core/image/t_image.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/image/t_image.hh (revision 2199)
+++ branches/cleanup-2008/milena/mln/core/image/t_image.hh (revision 2200)
@@ -48,7 +48,7 @@
/// \internal Data structure for \c mln::t_image<I>.
template <typename I>
- struct data_< t_image<I> >
+ struct data< t_image<I> >
{
/// \brief Build the data object held by a t_image.
///
@@ -56,7 +56,7 @@
/// \param dim1 The first dimension to be swapped.
/// \param dim2 The second dimension to be swapped.
/// \param box The bounding box (domain) of the morphed image.
- data_(I& ima, unsigned dim1, unsigned dim2,
+ data(I& ima, unsigned dim1, unsigned dim2,
mln::box_<mln_psite(I)>& box);
/// Underlying image.
@@ -162,11 +162,11 @@
namespace internal
{
- // internal::data_< t_image<I,S> >
+ // internal::data< t_image<I,S> >
template <typename I>
inline
- data_< t_image<I> >::data_(I& ima,
+ data< t_image<I> >::data(I& ima,
unsigned dim1, unsigned dim2,
mln::box_<mln_psite(I)>& box)
: ima_(ima),
@@ -190,7 +190,7 @@
// yet at this point.
box_<mln_psite(I)> box(exchange_coords_(ima.bbox().pmin(), dim1,
dim2),
exchange_coords_(ima.bbox().pmax(), dim1, dim2));
- this->data_ = new internal::data_< t_image<I> >(ima, dim1, dim2, box);
+ this->data_ = new internal::data< t_image<I> >(ima, dim1, dim2, box);
}
template <typename I>
Index: branches/cleanup-2008/milena/mln/core/image/image1d.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/image/image1d.hh (revision 2199)
+++ branches/cleanup-2008/milena/mln/core/image/image1d.hh (revision 2200)
@@ -59,10 +59,10 @@
/// \internal Data structure for \c mln::image1d<T>.
template <typename T>
- struct data_< image1d<T> >
+ struct data< image1d<T> >
{
- data_(const box1d& b, unsigned bdr);
- ~data_();
+ data(const box1d& b, unsigned bdr);
+ ~data();
T* buffer_;
T* array_;
@@ -74,7 +74,7 @@
void update_vb_();
void allocate_();
void deallocate_();
- void swap_ (data_< image1d<T> >& other_);
+ void swap_ (data< image1d<T> >& other_);
void reallocate_(unsigned new_border);
};
@@ -231,14 +231,14 @@
target.init_(b, bdr);
}
- // \internal internal::data_< image1d<T> >
+ // \internal internal::data< image1d<T> >
namespace internal
{
template <typename T>
inline
- data_< image1d<T> >::data_(const box1d& b, unsigned bdr)
+ data< image1d<T> >::data(const box1d& b, unsigned bdr)
: buffer_(0),
array_ (0),
b_ (b),
@@ -249,7 +249,7 @@
template <typename T>
inline
- data_< image1d<T> >::~data_()
+ data< image1d<T> >::~data()
{
deallocate_();
}
@@ -257,7 +257,7 @@
template <typename T>
inline
void
- data_< image1d<T> >::update_vb_()
+ data< image1d<T> >::update_vb_()
{
vb_.pmin() = b_.pmin() - dpoint1d(all_to(bdr_));
vb_.pmax() = b_.pmax() + dpoint1d(all_to(bdr_));
@@ -266,7 +266,7 @@
template <typename T>
inline
void
- data_< image1d<T> >::allocate_()
+ data< image1d<T> >::allocate_()
{
update_vb_();
unsigned
@@ -279,7 +279,7 @@
template <typename T>
inline
void
- data_< image1d<T> >::deallocate_()
+ data< image1d<T> >::deallocate_()
{
if (buffer_)
{
@@ -292,10 +292,10 @@
template <typename T>
inline
void
- data_< image1d<T> >::swap_(data_< image1d<T> >& other_)
+ data< image1d<T> >::swap_(data< image1d<T> >& other_)
{
- data_< image1d<T> > self_ = *this;
+ data< image1d<T> > self_ = *this;
*this = other_;
other_ = self_;
@@ -304,9 +304,9 @@
template <typename T>
inline
void
- data_< image1d<T> >::reallocate_(unsigned new_border)
+ data< image1d<T> >::reallocate_(unsigned new_border)
{
- data_< image1d<T> >& tmp = *(new data_< image1d<T> >(this->b_,
new_border));
+ data< image1d<T> >& tmp = *(new data< image1d<T> >(this->b_,
new_border));
this->swap_(tmp);
}
@@ -342,7 +342,7 @@
image1d<T>::init_(const box1d& b, unsigned bdr)
{
mln_precondition(! this->has_data());
- this->data_ = new internal::data_< image1d<T> >(b, bdr);
+ this->data_ = new internal::data< image1d<T> >(b, bdr);
}
template <typename T>
Index: branches/cleanup-2008/milena/mln/core/image/fi_adaptor.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/image/fi_adaptor.hh (revision
2199)
+++ branches/cleanup-2008/milena/mln/core/image/fi_adaptor.hh (revision
2200)
@@ -64,13 +64,13 @@
{
/// \internal Data structure for \c mln::fi_adaptor<I>.
template <typename I>
- struct data_< fi_adaptor<I> >
+ struct data< fi_adaptor<I> >
{
/// Constructor.
- data_();
+ data();
/// Destructor.
- ~data_();
+ ~data();
/// Adaptee image
fipImage fi_ima_;
@@ -91,7 +91,7 @@
void deallocate_();
/// Swap data between images.
- void swap_(data_< fi_adaptor<I> >& other_);
+ void swap_(data< fi_adaptor<I> >& other_);
};
} // end of namespace mln::internal
@@ -220,24 +220,24 @@
};
- // internal::data_< fi_adaptor<I> >
+ // internal::data< fi_adaptor<I> >
namespace internal
{
template <typename I>
- data_< fi_adaptor<I> >::data_()
+ data< fi_adaptor<I> >::data()
{
}
template <typename I>
- data_< fi_adaptor<I> >::~data_()
+ data< fi_adaptor<I> >::~data()
{
deallocate_();
}
template <typename I>
void
- data_< fi_adaptor<I> >::sync_with_adaptee_()
+ data< fi_adaptor<I> >::sync_with_adaptee_()
{
mln_precondition(fi_ima_.isValid());
// FIXME: doesnt work for rgb:
@@ -262,7 +262,7 @@
template <typename I>
void
- data_< fi_adaptor<I> >::deallocate_()
+ data< fi_adaptor<I> >::deallocate_()
{
if (array_)
{
@@ -273,9 +273,9 @@
template <typename I>
void
- data_< fi_adaptor<I> >::swap_(data_< fi_adaptor<I> >& other_)
+ data< fi_adaptor<I> >::swap_(data< fi_adaptor<I> >& other_)
{
- data_< fi_adaptor<I> > self_ = *this;
+ data< fi_adaptor<I> > self_ = *this;
*this = other_;
other_ = self_;
}
@@ -294,7 +294,7 @@
void
fi_adaptor<I>::init_()
{
- this->data_ = new internal::data_< fi_adaptor<I> >();
+ this->data_ = new internal::data< fi_adaptor<I> >();
}
template <typename I>
Index: branches/cleanup-2008/milena/mln/core/image/image3d.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/image/image3d.hh (revision 2199)
+++ branches/cleanup-2008/milena/mln/core/image/image3d.hh (revision 2200)
@@ -60,10 +60,10 @@
/// \internal Data structure for \c mln::image3d<T>.
template <typename T>
- struct data_< image3d<T> >
+ struct data< image3d<T> >
{
- data_(const box3d& b, unsigned bdr);
- ~data_();
+ data(const box3d& b, unsigned bdr);
+ ~data();
T* buffer_;
T*** array_;
@@ -75,7 +75,7 @@
void update_vb_();
void allocate_();
void deallocate_();
- void swap_ (data_< image3d<T> >& other_);
+ void swap_ (data< image3d<T> >& other_);
void reallocate_(unsigned new_border);
};
@@ -241,14 +241,14 @@
}
- // internal::data_< image3d<T> >
+ // internal::data< image3d<T> >
namespace internal
{
template <typename T>
inline
- data_< image3d<T> >::data_(const box3d& b, unsigned bdr)
+ data< image3d<T> >::data(const box3d& b, unsigned bdr)
: buffer_(0),
array_ (0),
b_ (b),
@@ -259,7 +259,7 @@
template <typename T>
inline
- data_< image3d<T> >::~data_()
+ data< image3d<T> >::~data()
{
deallocate_();
}
@@ -267,7 +267,7 @@
template <typename T>
inline
void
- data_< image3d<T> >::update_vb_()
+ data< image3d<T> >::update_vb_()
{
vb_.pmin() = b_.pmin() - dpoint3d(all_to(bdr_));
vb_.pmax() = b_.pmax() + dpoint3d(all_to(bdr_));
@@ -276,7 +276,7 @@
template <typename T>
inline
void
- data_< image3d<T> >::allocate_()
+ data< image3d<T> >::allocate_()
{
update_vb_();
unsigned
@@ -304,7 +304,7 @@
template <typename T>
inline
void
- data_< image3d<T> >::deallocate_()
+ data< image3d<T> >::deallocate_()
{
if (buffer_)
{
@@ -331,9 +331,9 @@
template <typename T>
inline
void
- data_< image3d<T> >::swap_(data_< image3d<T> >& other_)
+ data< image3d<T> >::swap_(data< image3d<T> >& other_)
{
- data_< image3d<T> > self_ = *this;
+ data< image3d<T> > self_ = *this;
*this = other_;
other_ = self_;
}
@@ -341,9 +341,9 @@
template <typename T>
inline
void
- data_< image3d<T> >::reallocate_(unsigned new_border)
+ data< image3d<T> >::reallocate_(unsigned new_border)
{
- data_< image3d<T> >& tmp = *(new data_< image3d<T> >(this->b_,
new_border));
+ data< image3d<T> >& tmp = *(new data< image3d<T> >(this->b_,
new_border));
this->swap_(tmp);
}
@@ -378,7 +378,7 @@
image3d<T>::init_(const box3d& b, unsigned bdr)
{
mln_precondition(! this->has_data());
- this->data_ = new internal::data_< image3d<T> >(b, bdr);
+ this->data_ = new internal::data< image3d<T> >(b, bdr);
}
template <typename T>
Index: branches/cleanup-2008/milena/mln/core/image/complex_image.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/image/complex_image.hh
(revision 2199)
+++ branches/cleanup-2008/milena/mln/core/image/complex_image.hh
(revision 2200)
@@ -58,9 +58,9 @@
/// \internal Data structure for \c mln::complex_image<P,V>.
template <unsigned D, typename P, typename V>
- struct data_< complex_image<D, P, V> >
+ struct data< complex_image<D, P, V> >
{
- data_(const p_complex<D, P>& pc,
+ data(const p_complex<D, P>& pc,
const metal::vec< D + 1, std::vector<V> >& values);
metal::vec< D + 1, std::vector<V> > values_;
@@ -184,7 +184,7 @@
{
template <unsigned D, typename P, typename V>
inline
- data_< complex_image<D, P, V> >::data_(const p_complex<D, P>& pc,
+ data< complex_image<D, P, V> >::data(const p_complex<D, P>& pc,
const metal::vec< D + 1,
std::vector<V> >& values)
: values_(values),
@@ -238,7 +238,7 @@
{
mln_precondition(! this->has_data());
this->data_ =
- new internal::data_< complex_image<D, P, V> >(pc, values);
+ new internal::data< complex_image<D, P, V> >(pc, values);
}
/*---------------.
Index: branches/cleanup-2008/milena/mln/core/image/mono_rle_image.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/image/mono_rle_image.hh
(revision 2199)
+++ branches/cleanup-2008/milena/mln/core/image/mono_rle_image.hh
(revision 2200)
@@ -51,9 +51,9 @@
/// \internal Data structure for \c mln::mono_rle_image<P,T>.
template <typename P, typename T>
- struct data_< mono_rle_image<P,T> >
+ struct data< mono_rle_image<P,T> >
{
- data_(const T& val);
+ data(const T& val);
/// Image value.
T value_;
@@ -145,11 +145,11 @@
namespace internal
{
- // internal::data_< mono_rle_image<I,S> >
+ // internal::data< mono_rle_image<I,S> >
template <typename P, typename T>
inline
- data_< mono_rle_image<P,T> >::data_(const T& val)
+ data< mono_rle_image<P,T> >::data(const T& val)
: value_(val)
{
}
@@ -157,7 +157,7 @@
template <typename P, typename T>
inline
unsigned
- data_< mono_rle_image<P,T> >::size_mem() const
+ data< mono_rle_image<P,T> >::size_mem() const
{
return sizeof(T) + domain_.size_mem();
}
@@ -165,7 +165,7 @@
template <typename P, typename T>
inline
void
- data_< mono_rle_image<P,T> >::finalize()
+ data< mono_rle_image<P,T> >::finalize()
{
domain_.finalize();
}
@@ -176,7 +176,7 @@
inline
mono_rle_image<P, T>::mono_rle_image(const T& val)
{
- this->data_ = new internal::data_< mono_rle_image<P,T> >(val);
+ this->data_ = new internal::data< mono_rle_image<P,T> >(val);
}
template <typename P, typename T>
Index: branches/cleanup-2008/milena/mln/core/internal/image_if_base.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/internal/image_if_base.hh
(revision 2199)
+++ branches/cleanup-2008/milena/mln/core/internal/image_if_base.hh
(revision 2200)
@@ -52,9 +52,9 @@
// \internal data_.
template <typename I, typename F, typename E>
- struct data_< image_if_base_<I,F,E> >
+ struct data< image_if_base_<I,F,E> >
{
- data_(I& ima, const F& f);
+ data(I& ima, const F& f);
I ima_;
p_if<mln_pset(I), F> pset_;
@@ -141,11 +141,11 @@
// target.init_(ima, f);
// }
- // \internal internal::data_< image_if_base_<I,S> >
+ // \internal internal::data< image_if_base_<I,S> >
template <typename I, typename F, typename E>
inline
- data_< image_if_base_<I,F,E> >::data_(I& ima, const F& f)
+ data< image_if_base_<I,F,E> >::data(I& ima, const F& f)
: ima_(ima),
pset_(ima.domain() | f)
{
@@ -181,7 +181,7 @@
image_if_base_<I,F,E>::init_(I& ima, const F& f)
{
mln_precondition(! this->has_data());
- this->data_ = new internal::data_<E>(ima, f);
+ this->data_ = new internal::data<E>(ima, f);
}
template <typename I, typename F, typename E>
Index: branches/cleanup-2008/milena/mln/neighb/image.hh
===================================================================
--- branches/cleanup-2008/milena/mln/neighb/image.hh (revision 2199)
+++ branches/cleanup-2008/milena/mln/neighb/image.hh (revision 2200)
@@ -54,9 +54,9 @@
/// \internal Data structure for mln::neighb::image
template <typename I, typename N>
- struct data_< mln::neighb::image<I, N> >
+ struct data< mln::neighb::image<I, N> >
{
- data_(I& ima, const N& nbh);
+ data(I& ima, const N& nbh);
I ima_;
N nbh_;
@@ -169,14 +169,14 @@
}
/*-----------------------------------------.
- | internal::data_< neighb::image_<T,I> >. |
+ | internal::data< neighb::image_<T,I> >. |
`-----------------------------------------*/
namespace internal
{
template <typename I, typename N>
inline
- data_< neighb::image<I, N> >::data_(I& ima, const N& nbh)
+ data< neighb::image<I, N> >::data(I& ima, const N& nbh)
: ima_(ima),
nbh_(nbh)
{
@@ -210,7 +210,7 @@
{
mln_precondition(! this->has_data());
this->data_ =
- new mln::internal::data_< mln::neighb::image<I, N> >(exact(ima),
+ new mln::internal::data< mln::neighb::image<I, N> >(exact(ima),
exact(nbh));
}
Index: branches/cleanup-2008/milena/mln/value/stack.hh
===================================================================
--- branches/cleanup-2008/milena/mln/value/stack.hh (revision 2199)
+++ branches/cleanup-2008/milena/mln/value/stack.hh (revision 2200)
@@ -54,10 +54,10 @@
*
*/
template <unsigned n, typename I>
- struct data_< value::stack_image<n, I> >
+ struct data< value::stack_image<n, I> >
{
public:
- data_(const algebra::vec<n,I>& imas);
+ data(const algebra::vec<n,I>& imas);
algebra::vec<n,I> imas_;
I& ima_;
};
@@ -214,11 +214,11 @@
namespace internal
{
- // internal::data_< cast_image_<T,I> >
+ // internal::data< cast_image_<T,I> >
template <unsigned n, typename I>
inline
- data_< value::stack_image<n,I> >::data_(const algebra::vec<n,I>& imas)
+ data< value::stack_image<n,I> >::data(const algebra::vec<n,I>& imas)
: imas_(imas),
ima_(imas_[0])
{
@@ -241,7 +241,7 @@
inline
stack_image<n,I>::stack_image(const algebra::vec<n,I>& imas)
{
- this->data_ = new mln::internal::data_< stack_image<n, I> >(imas);
+ this->data_ = new mln::internal::data< stack_image<n, I> >(imas);
for (unsigned i = 0; i < n; ++i)
{
mln_precondition(imas[i].has_data());
1
0
08 Sep '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add initialization for extension morphers.
* mln/core/image/extension_fun.hh,
* mln/core/image/extension_ima.hh,
* mln/core/image/extension_val.hh,
(init): Rename this method as...
(init_): ...this.
(init_): New procedure overloads.
* doc/tutorial/examples/image_if.cc: Augment.
* mln/trait/ch_value.hh: New overload.
* mln/core/image/extension_fun.hh (FIXME): Fix.
Augment doc.
(extension): New method.
* mln/core/image/extension_ima.hh (skeleton): Fix.
Now the extension is a particular tag so we cannot mix up
image and extension.
* mln/core/image/extension_val.hh: .
(extension_value, change_extension_value): Rename as...
(extension, change_extension): ...these.
* mln/core/internal/image_morpher.hh (FIXME): Fix.
Add static check.
* mln/core/concept/image.hh: Layout.
(check_init): New material.
(Image): Check the presence of the init_ method.
* mln/tag/init.hh: Layout.
(extension_t, extension): New tag type and object.
* mln/tag/skeleton.hh (ext_): New tag.
* mln/fun/p2b/has.hh: New check.
doc/tutorial/examples/image_if.cc | 13 ++++++++-
mln/core/concept/image.hh | 34 +++++++++++++++++++++++
mln/core/image/extension_fun.hh | 53 +++++++++++++++++++++++++++++++++----
mln/core/image/extension_ima.hh | 46 ++++++++++++++++++++++++++++----
mln/core/image/extension_val.hh | 43 ++++++++++++++++++++++++------
mln/core/internal/image_morpher.hh | 4 +-
mln/fun/p2b/has.hh | 5 ++-
mln/tag/init.hh | 4 ++
mln/tag/skeleton.hh | 9 +++---
mln/trait/ch_value.hh | 7 ++++
10 files changed, 190 insertions(+), 28 deletions(-)
Index: doc/tutorial/examples/image_if.cc
--- doc/tutorial/examples/image_if.cc (revision 2196)
+++ doc/tutorial/examples/image_if.cc (working copy)
@@ -51,6 +51,13 @@
}
}
+template <typename I>
+void algo(const I& input)
+{
+ using namespace mln;
+ mln_ch_value(I, float) output;
+ initialize(output, input);
+}
@@ -58,6 +65,8 @@
{
using namespace mln;
+ trace::quiet = false;
+
typedef image2d<unsigned> I;
I ima(3, 3, 1);
// FIXME: border::fill(ima, 0);
@@ -75,8 +84,10 @@
ch_target(mln_fwd_piter_(S)(), ima_.domain());
// mln_VAR(ima_e, extend(ima_, pw::value(ima)));
- // mln_VAR(ima_e, extend(ima_, 0));
+ // mln_VAR(ima_e, extend(ima_, 8));
mln_VAR(ima_e, extend(ima_, ima));
debug::println(ima_e);
browse(ima_e, c4());
+
+ algo(ima_e);
}
Index: mln/trait/ch_value.hh
--- mln/trait/ch_value.hh (revision 2196)
+++ mln/trait/ch_value.hh (working copy)
@@ -105,6 +105,13 @@
typedef M< mln_ch_value(I1, V), mln_ch_value(I2, V) > ret;
};
+ template < template <class, class> class M, typename I, typename E,
+ typename V >
+ struct ch_value_< M< tag::image_<I>, tag::ext_<E> >, V >
+ {
+ typedef M< mln_ch_value(I, V), E > ret;
+ };
+
// For mln::value::stack_image<n,I>.
template < template <unsigned, class> class M, unsigned n, typename I,
typename V >
Index: mln/core/image/extension_fun.hh
--- mln/core/image/extension_fun.hh (revision 2196)
+++ mln/core/image/extension_fun.hh (working copy)
@@ -89,6 +89,7 @@
template <typename I, typename F>
class extension_fun :
+
public internal::image_identity< I, mln_pset(I), extension_fun<I, F> >,
private mlc_converts_to(mln_result(F), mln_value(I))::check_t
{
@@ -96,7 +97,6 @@
/// Skeleton.
typedef extension_fun< tag::image_<I>, tag::function_<F> > skeleton;
- // FIXME: OK when ch_value?
/// Return type of read-only access.
@@ -111,10 +111,11 @@
/// Deferred initialization from an image \p ima and a function \p
/// fun.
- void init(I& ima, const F& fun);
+ void init_(I& ima, const F& fun);
- /// Test if \p p is valid. It returns always true.
+ /// Test if \p p is valid. It returns always true, assuming that
+ /// the function is valid for any \p p.
// Tech note: the 'template' allows for multiple input.
template <typename P>
bool has(const P& p) const;
@@ -125,9 +126,22 @@
/// Read-write access to the image value located at site \p p.
mln_morpher_lvalue(I) operator()(const mln_psite(I)& p);
+
+
+ /// Give the extension function.
+ const F& extension() const;
};
+ // init_
+
+ template <typename I, typename F, typename J>
+ void init_(tag::image_t, extension_fun<I,F>& target, const J& model);
+
+ template <typename F, typename I>
+ void init_(tag::extension_t, F& target, const extension_fun<I,F>& model);
+
+
# ifndef MLN_INCLUDE_ONLY
@@ -147,6 +161,7 @@
} // end of namespace mln::internal
+
// extension_fun<I, F>
template <typename I, typename F>
@@ -159,13 +174,13 @@
inline
extension_fun<I, F>::extension_fun(I& ima, const F& fun)
{
- init(ima, fun);
+ init_(ima, fun);
}
template <typename I, typename F>
inline
void
- extension_fun<I, F>::init(I& ima, const F& fun)
+ extension_fun<I, F>::init_(I& ima, const F& fun)
{
this->data_ = new internal::data< extension_fun<I, F> >(ima, fun);
}
@@ -213,6 +228,34 @@
}
}
+ template <typename I, typename F>
+ inline
+ const F&
+ extension_fun<I, F>::extension() const
+ {
+ mln_precondition(this->has_data());
+ return this->data_->fun_;
+ }
+
+
+ // init_
+
+ template <typename I, typename F, typename J>
+ void init_(tag::image_t, extension_fun<I,F>& target, const J& model)
+ {
+ I ima;
+ init_(tag::image, ima, model);
+ F fun;
+ init_(tag::extension, fun, model);
+ target.init_(ima, fun);
+ }
+
+ template <typename F, typename I>
+ void init_(tag::extension_t, F& target, const extension_fun<I,F>& model)
+ {
+ target = model.extension();
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
Index: mln/core/image/extension_ima.hh
--- mln/core/image/extension_ima.hh (revision 2196)
+++ mln/core/image/extension_ima.hh (working copy)
@@ -96,8 +96,7 @@
public:
/// Skeleton.
- typedef extension_ima< tag::image_<I>, tag::image_<J> > skeleton;
- // FIXME: OK when ch_value?
+ typedef extension_ima< tag::image_<I>, tag::ext_<J> > skeleton;
/// Return type of read-only access.
@@ -112,7 +111,7 @@
/// Deferred initialization from an image \p ima and a function \p
/// ext.
- void init(I& ima, J& ext);
+ void init_(I& ima, J& ext);
/// Test if \p p is valid.
@@ -137,6 +136,18 @@
};
+ // init_
+
+ template <typename I, typename J, typename M>
+ void init_(tag::image_t, extension_ima<I,J>& target, const M& model);
+
+ template <typename J, typename I>
+ void init_(tag::extension_t, J& target, const extension_ima<I,J>& model);
+
+ template <typename J, typename I>
+ void init_(tag::extension_t, J& target, const extension_ima<I,const J>& model);
+
+
# ifndef MLN_INCLUDE_ONLY
@@ -168,13 +179,13 @@
inline
extension_ima<I, J>::extension_ima(I& ima, J& ext)
{
- init(ima, ext);
+ init_(ima, ext);
}
template <typename I, typename J>
inline
void
- extension_ima<I, J>::init(I& ima, J& ext)
+ extension_ima<I, J>::init_(I& ima, J& ext)
{
this->data_ = new internal::data< extension_ima<I, J> >(ima, ext);
}
@@ -246,6 +257,31 @@
return this->data_->ext_;
}
+
+ // init_
+
+ template <typename I, typename J, typename M>
+ void init_(tag::image_t, extension_ima<I,J>& target, const M& model)
+ {
+ I ima;
+ init_(tag::image, ima, model);
+ J ext;
+ init_(tag::extension, ext, model);
+ target.init_(ima, ext);
+ }
+
+ template <typename J, typename I>
+ void init_(tag::extension_t, J& target, const extension_ima<I,J>& model)
+ {
+ target = model.extension();
+ }
+
+ template <typename J, typename I>
+ void init_(tag::extension_t, J& target, const extension_ima<I,const J>& model)
+ {
+ target = model.extension();
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
Index: mln/core/image/extension_val.hh
--- mln/core/image/extension_val.hh (revision 2196)
+++ mln/core/image/extension_val.hh (working copy)
@@ -94,7 +94,6 @@
/// Skeleton.
typedef extension_val< tag::image_<I> > skeleton;
- // FIXME: OK when ch_value?
/// Return type of read-only access.
@@ -109,7 +108,7 @@
/// Deferred initialization from an image \p ima and a value \p
/// val.
- void init(I& ima, const mln_value(I)& val);
+ void init_(I& ima, const mln_value(I)& val);
/// Test if \p p is valid. It returns always true.
@@ -126,13 +125,21 @@
/// Read-only access to the value of the extension domain.
- const mln_value(I)& extension_value() const;
+ const mln_value(I)& extension() const;
/// Change the value of the extension domain.
- void change_extension_value(const mln_value(I)& val);
+ void change_extension(const mln_value(I)& val);
};
+ // init_
+
+ template <typename I, typename J>
+ void init_(tag::image_t, extension_val<I>& target, const J& model);
+
+ template <typename V, typename I>
+ void init_(tag::extension_t, V& target, const extension_val<I>& model);
+
# ifndef MLN_INCLUDE_ONLY
@@ -164,13 +171,13 @@
inline
extension_val<I>::extension_val(I& ima, const mln_value(I)& val)
{
- init(ima, val);
+ init_(ima, val);
}
template <typename I>
inline
void
- extension_val<I>::init(I& ima, const mln_value(I)& val)
+ extension_val<I>::init_(I& ima, const mln_value(I)& val)
{
this->data_ = new internal::data< extension_val<I> >(ima, val);
}
@@ -218,7 +225,7 @@
template <typename I>
inline
const mln_value(I)&
- extension_val<I>::extension_value() const
+ extension_val<I>::extension() const
{
mln_precondition(this->has_data());
return this->data_->val_;
@@ -227,12 +234,32 @@
template <typename I>
inline
void
- extension_val<I>::change_extension_value(const mln_value(I)& val)
+ extension_val<I>::change_extension(const mln_value(I)& val)
{
mln_precondition(this->has_data());
this->data_->val_ = val;
}
+
+ // init_
+
+ template <typename I, typename J>
+ void init_(tag::image_t, extension_val<I>& target, const J& model)
+ {
+ I ima;
+ init_(tag::image, ima, model);
+ mln_value(I) val;
+ init_(tag::extension, val, model);
+ target.init_(ima, val);
+ }
+
+ template <typename V, typename I>
+ void init_(tag::extension_t, V& target, const extension_val<I>& model)
+ {
+ mlc_converts_to(mln_value(I), V)::check();
+ target = model.extension();
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
Index: mln/core/internal/image_morpher.hh
--- mln/core/internal/image_morpher.hh (revision 2196)
+++ mln/core/internal/image_morpher.hh (working copy)
@@ -167,8 +167,8 @@
inline
void init_(Subject s, T& target, const Image<J>& model_)
{
- // FIXME: Precondition.
- // FIXME: Properly check that J is an internal::image_morpher.
+ mlc_is(mln_trait_image_category(J),
+ trait::image::category::morpher)::check();
const J& model = exact(model_);
init_(s, target, * model.delegatee_());
}
Index: mln/core/concept/image.hh
--- mln/core/concept/image.hh (revision 2196)
+++ mln/core/concept/image.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 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
@@ -114,6 +114,7 @@
namespace internal
{
+
template <typename values_browsing_trait, typename E>
struct image_values_interface_check
{
@@ -132,8 +133,35 @@
m = 0;
}
};
+
+
+ // check_init
+
+ template < typename E,
+ typename A >
+ int check_init(void (E::*)(A))
+ {
+ return 0;
+ }
+
+ template < typename E,
+ typename A1, typename A2 >
+ int check_init(void (E::*)(A1, A2))
+ {
+ return 0;
}
+ template < typename E,
+ typename A1, typename A2, typename A3 >
+ int check_init(void (E::*)(A1, A2, A3))
+ {
+ return 0;
+ }
+
+ } // end of namespace mln::internal
+
+
+
template <typename E>
inline
Image<E>::Image()
@@ -187,6 +215,10 @@
typedef typename E::skeleton skeleton;
+ // Check E::init_ presence. Since its signature varies from an
+ // image type to another, that is the only thing we can ensure.
+ internal::check_init(& E::init_);
+
/// Optional interface:
internal::image_values_interface_check<mln_trait_image_value_browsing(E),
E>::run();
Index: mln/tag/init.hh
--- mln/tag/init.hh (revision 2196)
+++ mln/tag/init.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 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
@@ -44,6 +44,7 @@
struct domain_t {};
struct bbox_t {};
struct border_t {};
+ struct extension_t {};
struct function_t {};
// FIXME: Make these proper globals (issue #43).
@@ -51,6 +52,7 @@
static const domain_t domain = domain_t();
static const bbox_t bbox = bbox_t();
static const border_t border = border_t();
+ static const extension_t extension = extension_t();
static const function_t function = function_t();
} // end of namespace mln::tag
Index: mln/tag/skeleton.hh
--- mln/tag/skeleton.hh (revision 2196)
+++ mln/tag/skeleton.hh (working copy)
@@ -42,13 +42,14 @@
{
// With param.
- template <typename I> struct image_ { typedef I param; };
- template <typename V> struct value_ { typedef V param; };
- template <typename P> struct psite_ { typedef P param; };
- template <typename S> struct pset_ { typedef S param; };
template <typename D> struct data_ { typedef D param; };
+ template <typename E> struct ext_ { typedef E param; };
template <typename F> struct function_ { typedef F param; };
+ template <typename I> struct image_ { typedef I param; };
template <typename N> struct neighb_ { typedef N param; };
+ template <typename P> struct psite_ { typedef P param; };
+ template <typename S> struct pset_ { typedef S param; };
+ template <typename V> struct value_ { typedef V param; };
// With value.
template <unsigned u> struct unsigned_ { enum { value = u }; };
Index: mln/fun/p2b/has.hh
--- mln/fun/p2b/has.hh (revision 2196)
+++ mln/fun/p2b/has.hh (working copy)
@@ -50,7 +50,10 @@
// FIXME: Doc!
template <typename I>
- struct has : public Function_p2b< has<I> >
+ struct has
+
+ : public Function_p2b< has<I> >,
+ private mlc_is_a(I, Image)::check_t
{
/// Result associated type.
typedef bool result;
1
0
08 Sep '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
Add the values_space method to image base.
* tests/core/image/flat_image.cc: update test
* mln/core/image/cast_image.hh,
* mln/core/image/decorated_image.hh,
* mln/core/image/obased_rle_image.hh,
* mln/core/image/value_enc_image.hh,
* mln/core/image/graph_image.hh,
* mln/core/image/line_graph_image.hh,
* mln/core/image/rle_image.hh,
* mln/core/image/tr_image.hh,
* mln/core/image/flat_image.hh,
* mln/core/image/mono_obased_rle_image.hh,
* mln/core/image/interpolated.hh,
* mln/core/image/sparse_image.hh,
* mln/core/image/bgraph_image.hh,
* mln/core/image/t_image.hh,
* mln/core/image/image1d.hh,
* mln/core/image/image2d.hh,
* mln/core/image/fi_adaptor.hh,
* mln/core/image/image3d.hh,
* mln/core/image/complex_image.hh,
* mln/core/image/mono_rle_image.hh: delete the values method.
* mln/core/macros.hh: update (mln_vset returns now t_eligible_values).
* mln/core/internal/image_base.hh: add the values_space method.
* mln/core/internal/image_identity.hh,
* mln/core/internal/image_domain_morpher.hh: update.
* mln/core/internal/image_value_morpher.hh: fix compile bug.
* mln/core/concept/image.hh: add interface check.
* mln/value/super_value.hh: New trait that return the super value type.
mln/core/concept/image.hh | 16 +++++---
mln/core/image/bgraph_image.hh | 14 -------
mln/core/image/cast_image.hh | 15 -------
mln/core/image/complex_image.hh | 13 ------
mln/core/image/decorated_image.hh | 4 --
mln/core/image/fi_adaptor.hh | 14 -------
mln/core/image/flat_image.hh | 19 ---------
mln/core/image/graph_image.hh | 13 ------
mln/core/image/image1d.hh | 15 -------
mln/core/image/image2d.hh | 15 -------
mln/core/image/image3d.hh | 16 --------
mln/core/image/interpolated.hh | 16 --------
mln/core/image/line_graph_image.hh | 13 ------
mln/core/image/mono_obased_rle_image.hh | 12 ------
mln/core/image/mono_rle_image.hh | 12 ------
mln/core/image/obased_rle_image.hh | 12 ------
mln/core/image/rle_image.hh | 12 ------
mln/core/image/sparse_image.hh | 18 ---------
mln/core/image/t_image.hh | 16 --------
mln/core/image/tr_image.hh | 4 --
mln/core/image/value_enc_image.hh | 12 ------
mln/core/internal/image_base.hh | 24 ++++++++++--
mln/core/internal/image_domain_morpher.hh | 19 ---------
mln/core/internal/image_identity.hh | 16 --------
mln/core/internal/image_value_morpher.hh | 12 +++---
mln/core/macros.hh | 4 +-
mln/value/super_value.hh | 59 ++++++++++++++++++++++++++++++
tests/core/image/flat_image.cc | 1
28 files changed, 99 insertions(+), 317 deletions(-)
Index: tests/core/image/flat_image.cc
--- tests/core/image/flat_image.cc (revision 2195)
+++ tests/core/image/flat_image.cc (working copy)
@@ -42,6 +42,7 @@
flat_image<short, box2d> test;
std::cout << test.values_eligible() << std::endl;
+ std::cout << test.values_space() << std::endl;
// flat_image<short, box2d>::t_eligible_value_set::fwd_viter viter(test.values_eligible());
}
Index: mln/core/image/cast_image.hh
--- mln/core/image/cast_image.hh (revision 2195)
+++ mln/core/image/cast_image.hh (working copy)
@@ -92,10 +92,6 @@
/// Return type of read-write access.
typedef T lvalue;
- /// Value set associated type.
- typedef mln::value::set<T> vset;
-
-
/// Skeleton.
typedef cast_image_< tag::value_<T>, tag::image_<I> > skeleton;
@@ -109,9 +105,6 @@
/// Mutable access is only OK for reading (not writing).
T operator()(const mln_psite(I)& p);
-
- /// Give the set of values of the image.
- const vset& values() const;
};
@@ -172,14 +165,6 @@
return mln::value::cast<T>( this->data_->ima_(p) );
}
- template <typename T, typename I>
- inline
- const mln::value::set<T>&
- cast_image_<T,I>::values() const
- {
- return vset::the();
- }
-
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
Index: mln/core/image/decorated_image.hh
--- mln/core/image/decorated_image.hh (revision 2195)
+++ mln/core/image/decorated_image.hh (working copy)
@@ -104,10 +104,6 @@
/// Dtor
~decorated_image();
-
- /// Value_Set associated type.
- typedef mln_vset(I) vset;
-
/// Skeleton.
typedef decorated_image< tag::image_<I>, tag::data_<D> > skeleton;
Index: mln/core/image/obased_rle_image.hh
--- mln/core/image/obased_rle_image.hh (revision 2195)
+++ mln/core/image/obased_rle_image.hh (working copy)
@@ -119,7 +119,6 @@
typedef T& lvalue;
typedef const T rvalue;
typedef runs_psite<P> psite;
- typedef mln::value::set<T> vset;
typedef p_runs_<P> pset;
@@ -141,9 +140,6 @@
/// Test if this image has been initialized.
bool has_data() const;
- /// Give the set of values of the image.
- const vset& values() const;
-
/// Give the definition domain.
const pset& domain() const;
@@ -210,14 +206,6 @@
template <typename P, typename T>
inline
- const typename obased_rle_image<P, T>::vset&
- obased_rle_image<P, T>::values() const
- {
- return vset::the();
- }
-
- template <typename P, typename T>
- inline
void
obased_rle_image<P, T>::insert(const p_run<P>& pr, T value)
{
Index: mln/core/image/value_enc_image.hh
--- mln/core/image/value_enc_image.hh (revision 2195)
+++ mln/core/image/value_enc_image.hh (working copy)
@@ -108,7 +108,6 @@
typedef T value;
typedef T& lvalue;
typedef const T rvalue;
- typedef typename std::vector<T> vset;
/// Domain related typedefs
typedef pset_array_psite< runs_psite<P> > psite;
@@ -137,9 +136,6 @@
/// Test if this image has been initialized.
bool has_data() const;
- /// Give the set of values of the image.
- const vset& values() const;
-
/// Give the definition domain.
const pset& domain() const;
};
@@ -178,14 +174,6 @@
template <typename P, typename T>
inline
- const typename value_enc_image<P, T>::vset&
- value_enc_image<P, T>::values() const
- {
- return this->data_->values_;
- }
-
- template <typename P, typename T>
- inline
void
value_enc_image<P, T>::insert(const p_runs_<P>& ps, T value)
{
Index: mln/core/image/graph_image.hh
--- mln/core/image/graph_image.hh (revision 2195)
+++ mln/core/image/graph_image.hh (working copy)
@@ -111,9 +111,6 @@
/// Return type of read-only access.
typedef typename std::vector<V>::const_reference rvalue;
- /// Value set associated type.
- typedef mln::value::set<value> vset;
-
/// Skeleton.
typedef graph_image< tag::psite_<P>, tag::value_<V> > skeleton;
@@ -137,8 +134,6 @@
/// \{
/// Return the domain of psites od the image.
const p_graph<P>& domain() const;
- /// Return the domain of values of the image.
- const vset& values() const;
/// Return the array of values associated to the vertices.
const std::vector<V>& vertex_values() const;
@@ -254,14 +249,6 @@
template <typename P, typename V>
inline
- const mln::value::set<V> &
- graph_image<P, V>::values() const
- {
- return vset::the();
- }
-
- template <typename P, typename V>
- inline
const std::vector<V>&
graph_image<P, V>::vertex_values() const
{
Index: mln/core/image/line_graph_image.hh
--- mln/core/image/line_graph_image.hh (revision 2195)
+++ mln/core/image/line_graph_image.hh (working copy)
@@ -128,9 +128,6 @@
/// Return type of read-only access.
typedef typename std::vector<V>::const_reference rvalue;
- /// Value set associated type.
- typedef mln::value::set<value> vset;
-
/// Skeleton.
typedef line_graph_image< tag::psite_<P>, tag::value_<V> > skeleton;
@@ -158,8 +155,6 @@
/// \{
/// Return the domain of psites od the image.
const p_line_graph<P>& domain() const;
- /// Return the domain of values of the image.
- const vset& values() const;
/// Return the array of values associated to the edges.
const std::vector<V>& edge_values() const;
@@ -287,14 +282,6 @@
template <typename P, typename V>
inline
- const mln::value::set<V> &
- line_graph_image<P, V>::values() const
- {
- return vset::the();
- }
-
- template <typename P, typename V>
- inline
const std::vector<V>&
line_graph_image<P, V>::edge_values() const
{
Index: mln/core/image/rle_image.hh
--- mln/core/image/rle_image.hh (revision 2195)
+++ mln/core/image/rle_image.hh (working copy)
@@ -109,7 +109,6 @@
typedef T& lvalue;
typedef const T rvalue;
typedef runs_psite<P> psite;
- typedef mln::value::set<T> vset;
typedef p_runs_<P> pset;
@@ -131,9 +130,6 @@
/// Test if this image has been initialized.
bool has_data() const;
- /// Give the set of values of the image.
- const vset& values() const;
-
/// Give the definition domain.
const pset& domain() const;
@@ -188,14 +184,6 @@
template <typename P, typename T>
inline
- const typename rle_image<P, T>::vset&
- rle_image<P, T>::values() const
- {
- return vset::the();
- }
-
- template <typename P, typename T>
- inline
void
rle_image<P, T>::insert(const p_run<P>& pr, T value)
{
Index: mln/core/image/tr_image.hh
--- mln/core/image/tr_image.hh (revision 2195)
+++ mln/core/image/tr_image.hh (working copy)
@@ -88,10 +88,6 @@
/// Return type of read-only access.
typedef mln_rvalue(I) rvalue;
- /// Value set associated type.
- typedef mln::value::set<value> vset;
-
-
/// Skeleton.
typedef tr_image< T, tag::image_<I> > skeleton;
Index: mln/core/image/flat_image.hh
--- mln/core/image/flat_image.hh (revision 2195)
+++ mln/core/image/flat_image.hh (working copy)
@@ -138,17 +138,6 @@
const T& operator()(const mln_psite(S)& p);
- // FIXME: Weird...
-
- /// Value_Set associated type.
- typedef mln::value::set<T> vset;
-
- /// Give the set of values of the image.
- const mln::value::set<T>& values() const;
-
- // end of FIXME
-
-
/// Change the image value.
void change_value(const T& old_val, const T& new_val);
};
@@ -251,14 +240,6 @@
template <typename T, typename S>
inline
- const mln::value::set<T>&
- flat_image<T,S>::values() const
- {
- return vset::the();
- }
-
- template <typename T, typename S>
- inline
void
flat_image<T,S>::change_value(const T& old_val, const T& new_val)
{
Index: mln/core/image/mono_obased_rle_image.hh
--- mln/core/image/mono_obased_rle_image.hh (revision 2195)
+++ mln/core/image/mono_obased_rle_image.hh (working copy)
@@ -114,7 +114,6 @@
typedef T& lvalue;
typedef const T rvalue;
typedef runs_psite<P> psite;
- typedef mln::value::set<T> vset;
typedef p_runs_<P> pset;
@@ -136,9 +135,6 @@
/// Test if this image has been initialized.
bool has_data() const;
- /// Give the set of values of the image.
- const vset& values() const;
-
/// Give the definition domain.
const pset& domain() const;
@@ -200,14 +196,6 @@
template <typename P, typename T>
inline
- const typename mono_obased_rle_image<P, T>::vset&
- mono_obased_rle_image<P, T>::values() const
- {
- return vset::the();
- }
-
- template <typename P, typename T>
- inline
void
mono_obased_rle_image<P, T>::insert(const p_run<P>& pr, T value)
{
Index: mln/core/image/interpolated.hh
--- mln/core/image/interpolated.hh (revision 2195)
+++ mln/core/image/interpolated.hh (working copy)
@@ -83,10 +83,6 @@
/// Return type of read-only access.
typedef mln_rvalue(I) rvalue;
- /// Value set associated type.
- typedef mln::value::set<value> vset;
-
-
/// Skeleton.
typedef interpolated< tag::image_<I> > skeleton;
@@ -112,8 +108,6 @@
mln_value(I) operator()(const mln::algebra::vec<I::point::dim, float>& v) const;
- /// Give the set of values of the image.
- const vset& values() const;
};
@@ -178,16 +172,6 @@
return this->data_->ima_(p);
}
- // FIXME : Should we remove this method? (and inherit it from
- // identity morpher)
- template <typename I>
- inline
- const mln::value::set<mln_value(I) >&
- interpolated<I>::values() const
- {
- return vset::the();
- }
-
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
Index: mln/core/image/sparse_image.hh
--- mln/core/image/sparse_image.hh (revision 2195)
+++ mln/core/image/sparse_image.hh (working copy)
@@ -122,11 +122,6 @@
/// Return type of read-write access.
typedef T& lvalue;
-
- /// Value_Set associated type.
- typedef mln::value::set<T> vset;
-
-
/// Skeleton.
typedef sparse_image< tag::psite_<P>, tag::value_<T> > skeleton;
@@ -153,11 +148,6 @@
/// Read-write access to the image value located at point \p p.
lvalue operator()(const psite& p);
-
- /// Give the set of values of the image.
- const vset& values() const;
-
-
/// Give the definition domain.
const p_set_of< p_run<P> >& domain() const;
};
@@ -200,14 +190,6 @@
template <typename P, typename T>
inline
- const typename sparse_image<P,T>::vset&
- sparse_image<P,T>::values() const
- {
- return vset::the();
- }
-
- template <typename P, typename T>
- inline
void
sparse_image<P,T>::insert(const p_run<P>& r, const std::vector<T>& vals)
{
Index: mln/core/image/bgraph_image.hh
--- mln/core/image/bgraph_image.hh (revision 2195)
+++ mln/core/image/bgraph_image.hh (working copy)
@@ -114,10 +114,6 @@
/// Return type of read-only access.
typedef typename std::vector<V>::const_reference rvalue;
- /// Value set associated type.
- typedef mln::value::set<value> vset;
-
-
/// Skeleton.
typedef bgraph_image< tag::psite_<P>, tag::value_<V> > skeleton;
@@ -141,8 +137,6 @@
/// \{
/// Return the domain of psites od the image.
const p_bgraph<P>& domain() const;
- /// Return the domain of values of the image.
- const vset& values() const;
/// Return the array of values associated to the nodes.
const std::vector<V>& node_values() const;
@@ -253,14 +247,6 @@
template <typename P, typename V>
inline
- const mln::value::set<V> &
- bgraph_image<P, V>::values() const
- {
- return vset::the();
- }
-
- template <typename P, typename V>
- inline
const std::vector<V>&
bgraph_image<P, V>::node_values() const
{
Index: mln/core/image/t_image.hh
--- mln/core/image/t_image.hh (revision 2195)
+++ mln/core/image/t_image.hh (working copy)
@@ -100,10 +100,6 @@
/// Return type of read-only access.
typedef mln_rvalue(I) rvalue;
- /// Value set associated type.
- typedef mln::value::set<value> vset;
-
-
/// Skeleton.
typedef t_image< tag::image_<I> > skeleton;
@@ -138,8 +134,6 @@
/// Read-write access of pixel value at point site \p p.
mln_morpher_lvalue(I) operator()(const mln_psite(I)& p);
- /// Give the set of values of the image.
- const vset& values() const;
protected:
/// Exchange components \a dim1_ and \a dim2_ of point \a p.
@@ -266,16 +260,6 @@
template <typename I>
inline
- const typename t_image<I>::vset&
- t_image<I>::values() const
- {
- mln_precondition(this->delegatee_() != 0);
- return this->delegatee_()->values();
- }
-
-
- template <typename I>
- inline
t_image<I>
swap_coords(Image<I>& ima, unsigned dim1, unsigned dim2)
{
Index: mln/core/image/image1d.hh
--- mln/core/image/image1d.hh (revision 2195)
+++ mln/core/image/image1d.hh (working copy)
@@ -140,10 +140,6 @@
typedef image1d< tag::value_<T> > skeleton;
- /// Value_Set associated type.
- typedef mln::value::set<T> vset;
-
-
/// Constructor without argument.
image1d();
@@ -162,9 +158,6 @@
/// Test if \p p is valid.
bool has(const point1d& p) const;
- /// Give the set of values of the image.
- const vset& values() const;
-
/// Give the definition domain.
const box1d& domain() const;
@@ -354,14 +347,6 @@
template <typename T>
inline
- const typename image1d<T>::vset&
- image1d<T>::values() const
- {
- return vset::the();
- }
-
- template <typename T>
- inline
const box1d&
image1d<T>::domain() const
{
Index: mln/core/image/image2d.hh
--- mln/core/image/image2d.hh (revision 2195)
+++ mln/core/image/image2d.hh (working copy)
@@ -146,10 +146,6 @@
typedef image2d< tag::value_<T> > skeleton;
- /// Value_Set associated type.
- typedef mln::value::set<T> vset;
-
-
/// Constructor without argument.
image2d();
@@ -169,9 +165,6 @@
/// Test if \p p is valid.
bool has(const point2d& p) const;
- /// Give the set of values of the image.
- const vset& values() const;
-
/// Give the definition domain.
const box2d& domain() const;
@@ -418,14 +411,6 @@
template <typename T>
inline
- const typename image2d<T>::vset&
- image2d<T>::values() const
- {
- return vset::the();
- }
-
- template <typename T>
- inline
const box2d&
image2d<T>::domain() const
{
Index: mln/core/image/fi_adaptor.hh
--- mln/core/image/fi_adaptor.hh (revision 2195)
+++ mln/core/image/fi_adaptor.hh (working copy)
@@ -157,10 +157,6 @@
/// Skeleton.
typedef fi_adaptor< tag::value_<T> > skeleton;
- /// Value_Set associated type.
- typedef mln::value::set<T> vset;
-
-
/// Constructor without argument.
fi_adaptor();
@@ -170,9 +166,6 @@
/// Initialize an empty image.
void init_();
- /// Give the set of values of the image.
- const vset& values() const;
-
/// Give the definition domain.
const box2d& domain() const;
@@ -305,13 +298,6 @@
}
template <typename I>
- const typename fi_adaptor<I>::vset&
- fi_adaptor<I>::values() const
- {
- return vset::the();
- }
-
- template <typename I>
const box2d&
fi_adaptor<I>::domain() const
{
Index: mln/core/image/image3d.hh
--- mln/core/image/image3d.hh (revision 2195)
+++ mln/core/image/image3d.hh (working copy)
@@ -142,11 +142,6 @@
/// Skeleton.
typedef image3d< tag::value_<T> > skeleton;
-
- /// Value_Set associated type.
- typedef mln::value::set<T> vset;
-
-
/// Constructor without argument.
image3d();
@@ -166,9 +161,6 @@
/// Test if \p p is valid.
bool has(const point3d& p) const;
- /// Give the set of values of the image.
- const vset& values() const;
-
/// Give the definition domain.
const box3d& domain() const;
@@ -391,14 +383,6 @@
template <typename T>
inline
- const typename image3d<T>::vset&
- image3d<T>::values() const
- {
- return vset::the();
- }
-
- template <typename T>
- inline
const box3d&
image3d<T>::domain() const
{
Index: mln/core/image/complex_image.hh
--- mln/core/image/complex_image.hh (revision 2195)
+++ mln/core/image/complex_image.hh (working copy)
@@ -120,9 +120,6 @@
/// Return type of read-only access.
typedef typename std::vector<V>::const_reference rvalue;
- /// Value set associated type.
- typedef mln::value::set<value> vset;
-
/// Skeleton.
typedef complex_image< D, tag::psite_<P>, tag::value_<V> > skeleton;
@@ -148,8 +145,6 @@
/// \{
/// Return the domain of psites od the image.
const p_complex<D, P>& domain() const;
- /// Return the domain of values of the image.
- const vset& values() const;
/// Return the array of values associated to the faces.
const metal::vec<D + 1, std::vector<V> >& face_values() const;
@@ -270,14 +265,6 @@
template <unsigned D, typename P, typename V>
inline
- const mln::value::set<V> &
- complex_image<D, P, V>::values() const
- {
- return vset::the();
- }
-
- template <unsigned D, typename P, typename V>
- inline
const metal::vec< D + 1, std::vector<V> >&
complex_image<D, P, V>::face_values() const
{
Index: mln/core/image/mono_rle_image.hh
--- mln/core/image/mono_rle_image.hh (revision 2195)
+++ mln/core/image/mono_rle_image.hh (working copy)
@@ -110,7 +110,6 @@
typedef T& lvalue;
typedef const T rvalue;
typedef runs_psite<P> psite;
- typedef mln::value::set<T> vset;
typedef p_runs_<P> pset;
@@ -135,9 +134,6 @@
/// Give the uniq value of the image.
rvalue get_value() const;
- /// Give the set of values of the image.
- const vset& values() const;
-
/// Give the definition domain.
const pset& domain() const;
@@ -193,14 +189,6 @@
template <typename P, typename T>
inline
- const typename mono_rle_image<P, T>::vset&
- mono_rle_image<P, T>::values() const
- {
- return vset::the();
- }
-
- template <typename P, typename T>
- inline
void
mono_rle_image<P, T>::insert(const p_run<P>& pr)
{
Index: mln/core/macros.hh
--- mln/core/macros.hh (revision 2195)
+++ mln/core/macros.hh (working copy)
@@ -353,8 +353,8 @@
/// Shortcuts to access the type of value set (vset) associated to T.
/// \{
-# define mln_vset(T) typename T::vset
-# define mln_vset_(T) T::vset
+# define mln_vset(T) typename T::t_eligible_value_set
+# define mln_vset_(T) T::t_eligible_value_set
/// \}
/// Shortcuts to access the viter type associated to T.
Index: mln/core/internal/image_base.hh
--- mln/core/internal/image_base.hh (revision 2195)
+++ mln/core/internal/image_base.hh (working copy)
@@ -41,6 +41,7 @@
# include <mln/core/internal/morpher_lvalue.hh>
# include <mln/util/tracked_ptr.hh>
# include <mln/value/set.hh>
+# include <mln/value/super_value.hh>
// image_base
// ^
@@ -85,10 +86,17 @@
typedef T value;
/// Eligible-value-set associated type.
- typedef mln::value::set<T> t_eligible_value_set;
+ typedef mln::value::set<T> t_eligible_values_set;
// Return the set of the image eligigle values
- const t_eligible_value_set& values_eligible() const;
+ const t_eligible_values_set& values_eligible() const;
+
+ /// Value space associated type.
+ typedef mln::value::set<
+ typename mln::value::super_value<T>::ret > t_values_space;
+
+ /// Return the value space of the image.
+ const t_values_space& values_space() const;
/// Site_Set associated type.
@@ -222,10 +230,18 @@
template <typename T, typename S, typename E>
inline
- const typename image_base<T, S, E>::t_eligible_value_set&
+ const typename image_base<T, S, E>::t_eligible_values_set&
image_base<T, S, E>::values_eligible() const
{
- return t_eligible_value_set::the();
+ return t_eligible_values_set::the();
+ }
+
+ template <typename T, typename S, typename E>
+ inline
+ const typename image_base<T, S, E>::t_values_space&
+ image_base<T, S, E>::values_space() const
+ {
+ return t_values_space::the();
}
template <typename T, typename S, typename E>
Index: mln/core/internal/image_identity.hh
--- mln/core/internal/image_identity.hh (revision 2195)
+++ mln/core/internal/image_identity.hh (working copy)
@@ -133,9 +133,6 @@
{
public:
- /// Value_Set associated type.
- typedef mln_vset(I) vset;
-
/// Value associated type.
typedef mln_value(I) value;
@@ -145,10 +142,6 @@
/// Return type of read-write access.
typedef mln_morpher_lvalue(I) lvalue;
-
- /// Give the set of values.
- const vset& values() const;
-
/// Read-only access of pixel value at point site \p p.
rvalue operator()(const mln_psite(S)& p) const;
@@ -177,15 +170,6 @@
template <typename I, typename S, typename E>
inline
- const mln_vset(I)&
- image_identity<I, S, E>::values() const
- {
- mln_precondition(this->delegatee_() != 0);
- return this->delegatee_()->values();
- }
-
- template <typename I, typename S, typename E>
- inline
mln_rvalue(I)
image_identity<I, S, E>::operator()(const mln_psite(S)& p) const
{
Index: mln/core/internal/image_domain_morpher.hh
--- mln/core/internal/image_domain_morpher.hh (revision 2195)
+++ mln/core/internal/image_domain_morpher.hh (working copy)
@@ -55,16 +55,6 @@
{
public:
- /// Value_Set associated type.
- typedef mln_vset(I) vset;
-
- /// Give the set of values.
- const vset& values() const;
-
-
- /// Value associated type.
- typedef mln_value(I) value;
-
/// Return type of read-only access.
typedef mln_rvalue(I) rvalue;
@@ -95,15 +85,6 @@
template <typename I, typename S, typename E>
inline
- const mln_vset(I)&
- image_domain_morpher<I,S,E>::values() const
- {
- mln_precondition(this->delegatee_() != 0);
- return this->delegatee_()->values();
- }
-
- template <typename I, typename S, typename E>
- inline
mln_rvalue(I)
image_domain_morpher<I,S,E>::operator()(const mln_psite(S)& p) const
{
Index: mln/core/internal/image_value_morpher.hh
--- mln/core/internal/image_value_morpher.hh (revision 2195)
+++ mln/core/internal/image_value_morpher.hh (working copy)
@@ -65,25 +65,25 @@
# ifndef MLN_INCLUDE_ONLY
- template <typename I, typename E>
+ template <typename I, typename T, typename E>
inline
- image_value_morpher<I,E>::image_value_morpher()
+ image_value_morpher<I,T,E>::image_value_morpher()
{
}
- template <typename I, typename E>
+ template <typename I, typename T, typename E>
inline
const mln_pset(I)&
- image_value_morpher<I,E>::domain() const
+ image_value_morpher<I,T,E>::domain() const
{
mln_precondition(this->delegatee_() != 0);
return this->delegatee_()->domain();
}
- template <typename I, typename E>
+ template <typename I, typename T, typename E>
inline
bool
- image_value_morpher<I,E>::has(const mln_psite(I)& p) const
+ image_value_morpher<I,T,E>::has(const mln_psite(I)& p) const
{
mln_precondition(this->delegatee_() != 0);
return this->delegatee_()->has(p);
Index: mln/core/concept/image.hh
--- mln/core/concept/image.hh (revision 2195)
+++ mln/core/concept/image.hh (working copy)
@@ -162,11 +162,14 @@
typedef mln_value(E) value;
typedef mln_rvalue(E) rvalue;
typedef mln_lvalue(E) lvalue;
- typedef typename E::t_eligible_value_set t_eligible_value_set;
+ typedef typename E::t_eligible_values_set t_eligible_values_set;
+ typedef typename E::t_values_space t_values_space;
- typedef mln_vset(E) vset;
- const vset& (E::*m5)() const = & E::values;
- m5 = 0;
+
+ // FIXME Doc
+ //typedef mln_vset(E) vset;
+ //const vset& (E::*m5)() const = & E::values;
+ //m5 = 0;
rvalue (E::*m6)(const psite& p) const = & E::operator();
m6 = 0;
@@ -176,9 +179,12 @@
const pset& (E::*m8)() const = & E::domain;
m8 = 0;
- const t_eligible_value_set& (E::*m9)() const = & E::values_eligible;
+ const t_eligible_values_set& (E::*m9)() const = & E::values_eligible;
m9 = 0;
+ const t_values_space& (E::*m10)() const = & E::values_space;
+ m10 = 0;
+
typedef typename E::skeleton skeleton;
/// Optional interface:
Index: mln/value/super_value.hh
--- mln/value/super_value.hh (revision 0)
+++ mln/value/super_value.hh (revision 0)
@@ -0,0 +1,59 @@
+// Copyright (C) 2008 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_SUPER_VALUE_HH
+# define MLN_VALUE_SUPER_VALUE_HH
+
+/*! \file mln/value/super_value.hh
+ *
+ * \brief Definition of the mln::super_value trait.
+ */
+
+namespace mln
+{
+
+ namespace value
+ {
+
+ /*
+ * \brief Return the super value type associated to the parameter \p T
+ * By default, the super value type of the parameter \p T, is T itself.
+ */
+ template <typename T>
+ struct super_value
+ {
+ typedef T ret;
+ };
+
+ /// Specialization
+ ///
+
+ }
+
+}
+
+#endif // !MLN_VALUE_SUPER_VALUE_HH
1
0