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
April 2009
- 11 participants
- 187 discussions
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-04-28 Etienne FOLIO <folio(a)lrde.epita.fr>
Circular value type.
* folio/mln/value/circular.hh: New type.
* folio/test/value/circular.cc: New tests.
---
mln/value/circular.hh | 268 +++++++++++++++++++++++++++++++++++++++++++++++++
test/value/circular.cc | 48 ++++++++
2 files changed, 316 insertions(+)
Index: trunk/milena/sandbox/folio/test/value/circular.cc
===================================================================
--- trunk/milena/sandbox/folio/test/value/circular.cc (revision 0)
+++ trunk/milena/sandbox/folio/test/value/circular.cc (revision 3721)
@@ -0,0 +1,48 @@
+
+#include <mln/value/float01.hh>
+
+#include "../../mln/value/circular.hh"
+
+
+int main()
+{
+ using namespace mln;
+ using namespace mln::value;
+
+ circular<12, 0, 360> inter(21);
+ std::cout << "21: " << inter << " " << float(inter) << std::endl;
+ inter = 0;
+ std::cout << "0: " << inter << std::endl;
+ inter = 42;
+ std::cout << "42: " << inter << std::endl;
+ inter = 359;
+ std::cout << "359: " << inter << std::endl;
+ inter = 359.5;
+ std::cout << "359.5: " << inter << std::endl;
+ inter = 360;
+ std::cout << "360: " << inter << std::endl;
+ inter = 360.5;
+ std::cout << "360.5: " << inter << std::endl;
+ inter = 361;
+ std::cout << "361: " << inter << std::endl;
+ inter = 372;
+ std::cout << "372: " << inter << std::endl;
+ inter = 972;
+ std::cout << "972: " << inter << std::endl;
+ inter = -0.2;
+ std::cout << "-0.2: " << inter << std::endl;
+ inter = -1;
+ std::cout << "-1: " << inter << std::endl;
+ inter = -1;
+ std::cout << "-1: " << inter << std::endl;
+ inter = -359;
+ std::cout << "-359: " << inter << std::endl;
+ inter = -359.5;
+ std::cout << "-359.5: " << inter << std::endl;
+ inter = -360;
+ std::cout << "-360: " << inter << std::endl;
+ inter = -360.5;
+ std::cout << "-360.5: " << inter << std::endl;
+ inter = -361;
+ std::cout << "-361: " << inter << std::endl;
+}
Index: trunk/milena/sandbox/folio/mln/value/circular.hh
===================================================================
--- trunk/milena/sandbox/folio/mln/value/circular.hh (revision 0)
+++ trunk/milena/sandbox/folio/mln/value/circular.hh (revision 3721)
@@ -0,0 +1,268 @@
+// Copyright (C) 2006, 2007, 2008 EPITA Research and Development
+// Laboratory (LRDE)
+//
+// 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_CIRCULAR_HH
+# define MLN_VALUE_CIRCULAR_HH
+
+/*! \file mln/value/circular.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <iostream>
+# include <math.h>
+# include <mln/core/contract.hh>
+# include <mln/metal/math/pow.hh>
+# include <mln/metal/bexpr.hh>
+
+# include <mln/value/int_u.hh>
+# include <mln/value/concept/floating.hh>
+# include <mln/value/internal/convert.hh>
+# include <mln/trait/value_.hh>
+
+
+
+namespace mln
+{
+
+ // Fwd decls.
+ namespace value {
+ template <unsigned n, int inf, int sup> struct circular;
+ }
+
+
+ namespace trait
+ {
+
+ template <unsigned n, int inf, int sup>
+ struct value_< mln::value::circular<n, inf, sup> >
+ {
+ enum constants_ {
+ dim = 1,
+ nbits = n,
+ card = mln_value_card_from_(nbits)
+ };
+
+ typedef trait::value::nature::floating nature;
+ typedef trait::value::kind::data kind;
+ typedef mln_value_quant_from_(card) quant;
+
+ static float min() { return 0.f; }
+ static float max() { return 1.f; }
+ static float epsilon() { return 0.f; }
+
+ typedef float comp;
+
+ typedef float sum;
+ };
+
+ } // end of namespace trait
+
+
+ namespace value
+ {
+
+ /// General class for the interval [0,1] of |R made discrete (quantized with n bits).
+ template <unsigned n, int inf, int sup>
+ struct circular
+
+ : public Floating< circular<n, inf, sup> >,
+
+ public internal::value_like_< float, // Equivalent. // FIXME: Why not circular?
+ mln_enc(int_u<n>), // Encoding.
+ float, // Interoperation.
+ circular<n, inf, sup> > // Exact.
+ {
+ /// Constructor without argument.
+ circular();
+
+ /// Constructor from a float.
+ circular(float val);
+
+ /// Assigment from a float.
+ circular<n, inf, sup>& operator=(float val);
+
+ /// Access to std type.
+ float value() const;
+
+ /// Set value to the \p val th position in the quantized interval.
+ void set_ind(unsigned long val);
+
+ /// Conversion to a float.
+ operator float() const;
+
+ private:
+ typedef mln_enc(int_u<n>) enc_;
+
+ float
+ circle(const float i) const;
+
+ float float01encode(const float i) const;
+ float float01decode(const float i) const;
+
+ };
+
+
+ namespace internal
+ {
+
+ template <unsigned n, int inf, int sup>
+ struct convert_< circular<n, inf, sup> >
+ {
+ static circular<n, inf, sup> value_at_index(unsigned i)
+ {
+ circular<n, inf, sup> tmp;
+ tmp.set_ind(i);
+ return tmp;
+ }
+
+ static unsigned index_of_value(const circular<n, inf, sup>& v)
+ {
+ return v.to_enc();
+ }
+ };
+ }
+
+
+ /// Op<<.
+ template <unsigned n, int inf, int sup>
+ std::ostream& operator<<(std::ostream& ostr, const circular<n, inf, sup>& f);
+
+ template <unsigned n, int inf, int sup, unsigned m, int inf2, int sup2>
+ bool approx_equal(const circular<n, inf, sup>& lhs, const circular<m, inf2, sup2>& rhs);
+
+ template <unsigned n, int inf, int sup>
+ bool approx_equal(const circular<n, inf, sup>& lhs, const float f);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // Circular<n, inf, sup>.
+
+ template <unsigned n, int inf, int sup>
+ inline
+ circular<n, inf, sup>::circular()
+ {
+ }
+
+ template <unsigned n, int inf, int sup>
+ inline
+ float
+ circular<n, inf, sup>::float01encode(const float i) const
+ {
+ return circle((i - inf) / (sup - inf));
+ }
+
+ template <unsigned n, int inf, int sup>
+ inline
+ float
+ circular<n, inf, sup>::float01decode(const float i) const
+ {
+ return i * (sup - inf) + inf;
+ }
+
+ template <unsigned n, int inf, int sup>
+ inline
+ circular<n, inf, sup>::circular(float val)
+ {
+ this->v_ = static_cast<enc_>(float01encode(val) * (float(mln_max(enc_)) - 1.f)); // FIXME
+ }
+
+ template <unsigned n, int inf, int sup>
+ inline
+ float
+ circular<n, inf, sup>::circle(const float i) const
+ {
+ return (int(floor(i)) - inf) % (sup - inf) + inf + (i - floor(i));
+ }
+
+ template <unsigned n, int inf, int sup>
+ inline
+ float
+ circular<n, inf, sup>::value() const
+ {
+ return float(float01decode(this->v_)) / (float(mln_max(enc_)) - 1.f); // FIXME
+ }
+
+ template <unsigned n, int inf, int sup>
+ inline
+ void
+ circular<n, inf, sup>::set_ind(unsigned long val)
+ {
+ this->v_ = static_cast<enc_>(val);
+ }
+
+ template <unsigned n, int inf, int sup>
+ inline
+ circular<n, inf, sup>&
+ circular<n, inf, sup>::operator=(float val)
+ {
+ this->v_ = static_cast<enc_>(float01encode(val) * (float(mln_max(enc_)) - 1.f)); // FIXME
+ return *this;
+ }
+
+ template <unsigned n, int inf, int sup>
+ inline
+ circular<n, inf, sup>::operator float() const
+ {
+ return float(float01decode(this->v_)) / (float(mln_max(enc_)) - 1.f);
+ }
+
+
+ // Operators.
+
+ template <unsigned n, int inf, int sup>
+ inline
+ std::ostream& operator<<(std::ostream& ostr, const circular<n, inf, sup>& f)
+ {
+ return ostr << f.value();
+ }
+
+ // template <unsigned n, int inf, int sup, unsigned m, int inf2, int sup2>
+ // inline
+ // bool approx_equal(const circular<n, inf, sup>& lhs, const circular<m, inf2, sup2>& rhs)
+ // {
+ // return circular<n, inf, sup>(lhs) == circular<>(rhs);
+ // }
+
+ template <unsigned n, int inf, int sup>
+ inline
+ bool approx_equal(const circular<n, inf, sup>& lhs, float f)
+ {
+ return circular<n, inf, sup>(lhs) == circular<n, inf, sup>(f);
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::value
+
+} // end of namespace mln
+
+#endif // ! MLN_VALUE_CIRCULAR_HH
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-04-28 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Add world/ directory for inter_pixel images.
* mln/arith/all.hh: Update.
* mln/arith/div.hh: New div operator.
* mln/arith/div.spe.hh: New div operator.
* mln/io/magick/save.hh: Update.
* mln/io/plot/save.hh: Update.
* mln/world/inter_pixel/full.hh: Convert standard image
to inter_pixel image.
* mln/world/inter_pixel/neighb2d.hh: Define standard
inter_pixel neighborhood.
---
arith/all.hh | 1
arith/div.hh | 289 ++++++++++++++++++++++++++++++++++++++++++
arith/div.spe.hh | 121 +++++++++++++++++
io/magick/save.hh | 2
io/plot/save.hh | 4
world/inter_pixel/full.hh | 77 +++++++++++
world/inter_pixel/neighb2d.hh | 83 ++++++++++++
7 files changed, 574 insertions(+), 3 deletions(-)
Index: trunk/milena/mln/world/inter_pixel/full.hh
===================================================================
--- trunk/milena/mln/world/inter_pixel/full.hh (revision 0)
+++ trunk/milena/mln/world/inter_pixel/full.hh (revision 3720)
@@ -0,0 +1,77 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// 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_WORLD_INTER_PIXEL_FULL_HH
+# define MLN_WORLD_INTER_PIXEL_FULL_HH
+
+/// \file mln/world/inter_pixel/full.hh
+///
+/// FIXME: insert comment.
+
+# include <mln/core/image/image2d.hh>
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace inter_pixel
+ {
+
+ template <typename T>
+ image2d<T>
+ image2full(const image2d<T>& input)
+ {
+ image2d<T> output(2 * input.nrows() - 1,
+ 2 * input.ncols() - 1);
+ for (int row = 0; row < input.nrows(); ++row)
+ for (int col = 0; col < input.ncols(); ++col)
+ opt::at(output, 2 * row, 2 * col) = opt::at(input, row, col);
+ return output;
+ }
+
+ template <typename T>
+ image2d<T>
+ full2image(const image2d<T>& input)
+ {
+ image2d<T> output((input.nrows() + 1) / 2,
+ (input.ncols() + 1) / 2);
+ for (int row = 0; row < input.nrows(); row += 2)
+ for (int col = 0; col < input.ncols(); col += 2)
+ opt::at(output, row / 2, col / 2) =
+ opt::at(input, row, col);
+ return output;
+ }
+
+ } // end of namespace mln::world::inter_pixel
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_INTER_PIXEL_FULL
Index: trunk/milena/mln/world/inter_pixel/neighb2d.hh
===================================================================
--- trunk/milena/mln/world/inter_pixel/neighb2d.hh (revision 0)
+++ trunk/milena/mln/world/inter_pixel/neighb2d.hh (revision 3720)
@@ -0,0 +1,83 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// 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_WORLD_INTER_PIXEL_NEIGHB2D_HH
+# define MLN_WORLD_INTER_PIXEL_NEIGHB2D_HH
+
+/// \file mln/world/inter_pixel/neighb2d.hh
+///
+/// FIXME: insert comment.
+
+# include <mln/core/alias/neighb2d.hh>
+# include <mln/make/double_neighb2d.hh>
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace inter_pixel
+ {
+
+ typedef neighb< win::multiple<window2d, bool(*)(const point2d&)> > dbl_neighb2d;
+
+ const dbl_neighb2d& e2c()
+ {
+ static bool e2c_h[] = { 0, 1, 0,
+ 0, 0, 0,
+ 0, 1, 0 };
+ static bool e2c_v[] = { 0, 0, 0,
+ 1, 0, 1,
+ 0, 0, 0 };
+ static dbl_neighb2d nbh = make::double_neighb2d(is_row_odd, e2c_h, e2c_v);
+ return nbh;
+ }
+
+ const dbl_neighb2d& e2e()
+ {
+ static bool e2e_h[] = { 0, 0, 1, 0, 0,
+ 0, 1, 0, 1, 0,
+ 0, 0, 0, 0, 0,
+ 0, 1, 0, 1, 0,
+ 0, 0, 1, 0, 0 };
+ static bool e2e_v[] = { 0, 0, 0, 0, 0,
+ 0, 1, 0, 1, 0,
+ 1, 0, 0, 0, 1,
+ 0, 1, 0, 1, 0,
+ 0, 0, 0, 0, 0 };
+ static dbl_neighb2d nbh = make::double_neighb2d(is_row_odd, e2e_h, e2e_v);
+ return nbh;
+ }
+
+ } // end of namespace mln::world::inter_pixel
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_INTER_PIXEL_NEIGHB2D
Index: trunk/milena/mln/arith/div.hh
===================================================================
--- trunk/milena/mln/arith/div.hh (revision 0)
+++ trunk/milena/mln/arith/div.hh (revision 3720)
@@ -0,0 +1,289 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// 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_ARITH_DIV_HH
+# define MLN_ARITH_DIV_HH
+
+/// \file mln/arith/div.hh
+///
+/// Point-wise division between images.
+///
+/// \todo Speedup; some versions are not optimal.
+
+# include <mln/arith/includes.hh>
+
+// Specializations are in:
+# include <mln/arith/div.spe.hh>
+
+
+namespace mln
+{
+
+
+ namespace trait
+ {
+
+ template <typename L, typename R>
+ struct set_binary_< op::div, Image, L, Image, R >
+ {
+ typedef mln_trait_op_div(mln_value(L), mln_value(R)) value;
+ typedef mln_ch_value(L, value) ret;
+ };
+
+ template <typename I, typename S>
+ struct set_binary_< op::div, Image, I, mln::value::Scalar, S >
+ {
+ typedef mln_trait_op_div(mln_value(I), S) value;
+ typedef mln_ch_value(I, value) ret;
+ };
+
+ } // end of namespace mln::trait
+
+
+
+ template <typename L, typename R>
+ mln_trait_op_div(L,R)
+ operator/(const Image<L>& lhs, const Image<R>& rhs);
+
+ template <typename L, typename R>
+ L&
+ operator/=(Image<L>& lhs, const Image<R>& rhs);
+
+
+ template <typename I, typename S>
+ mln_trait_op_div(I,S)
+ operator/(const Image<I>& ima, const value::Scalar<S>& s);
+
+ template <typename I, typename S>
+ I&
+ operator/=(Image<I>& ima, const value::Scalar<S>& s);
+
+
+
+ namespace arith
+ {
+
+ /// Point-wise division of images \p lhs and \p rhs.
+ /*!
+ * \param[in] lhs First operand image.
+ * \param[in] rhs Second operand image.
+ * \param[out] output The result image.
+ *
+ * \pre \p output.domain == \p lhs.domain == \p rhs.domain
+ */
+ template <typename L, typename R, typename O>
+ void div(const Image<L>& lhs, const Image<R>& rhs, Image<O>& output);
+
+
+ /// Point-wise division of the value \p val to image \p input.
+ /*!
+ * \param[in] input The image.
+ * \param[in] val The value.
+ * \param[out] output The result image.
+ *
+ * \pre \p output.domain == \p input.domain
+ */
+ template <typename I, typename V, typename O>
+ void div_cst(const Image<I>& input, const V& val, Image<O>& output);
+
+
+ /// Point-wise division of image \p rhs in image \p lhs.
+ /*!
+ * \param[in] lhs First operand image (subject to division).
+ * \param[in,out] rhs Second operand image (to div \p lhs).
+ *
+ * This addition performs: \n
+ * for all p of rhs.domain \n
+ * lhs(p) /= rhs(p)
+ *
+ * \pre \p rhs.domain <= \p lhs.domain
+ */
+ template <typename L, typename R>
+ void div_inplace(Image<L>& lhs, const Image<R>& rhs);
+
+
+ } // end of namespace mln::arith
+
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename L, typename R>
+ inline
+ mln_trait_op_div(L,R)
+ operator/(const Image<L>& lhs, const Image<R>& rhs)
+ {
+ mln_precondition(exact(rhs).domain() == exact(lhs).domain());
+ mln_trait_op_div(L,R) tmp;
+ initialize(tmp, lhs);
+ arith::div(lhs, rhs, tmp);
+ return tmp;
+ }
+
+ template <typename L, typename R>
+ inline
+ L&
+ operator/=(Image<L>& lhs, const Image<R>& rhs)
+ {
+ mln_precondition(exact(rhs).domain() == exact(lhs).domain());
+ arith::div_inplace(lhs, rhs);
+ return exact(lhs);
+ }
+
+
+ template <typename I, typename S>
+ inline
+ mln_trait_op_div(I,S)
+ operator/(const Image<I>& ima, const value::Scalar<S>& s)
+ {
+ mln_precondition(exact(ima).is_valid());
+ mln_precondition(s != 0);
+ mln_trait_op_div(I,S) tmp;
+ initialize(tmp, ima);
+ arith::div_cst(ima, exact(s), tmp);
+ return tmp;
+ }
+
+ template <typename I, typename S>
+ inline
+ I&
+ operator/=(Image<I>& ima, const value::Scalar<S>& s)
+ {
+ mln_precondition(exact(ima).is_valid());
+ arith::div_cst(ima, exact(s), ima);
+ return exact(ima);
+ }
+
+
+
+ namespace arith
+ {
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+
+ template <typename L, typename R, typename O>
+ inline
+ void div_(const L& lhs, const R& rhs, O& output)
+ {
+ trace::entering("arith::impl::generic::div_");
+
+ mln_piter(L) p(lhs.domain());
+ for_all(p)
+ output(p) = lhs(p) / rhs(p);
+
+ trace::exiting("arith::impl::generic::div_");
+ }
+
+ template <typename L, typename R>
+ inline
+ void div_inplace_(L& lhs, const R& rhs)
+ {
+ trace::entering("arith::impl::generic::div_inplace_");
+
+ mln_piter(R) p(rhs.domain());
+ for_all(p)
+ lhs(p) /= rhs(p);
+
+ trace::exiting("arith::impl::generic::div_inplace_");
+ }
+
+ } // end of namespace mln::arith::impl::generic
+
+ } // end of namespace mln::arith::impl
+
+
+ // Facades.
+
+ template <typename L, typename R, typename O>
+ inline
+ void div(const Image<L>& lhs, const Image<R>& rhs, Image<O>& output)
+ {
+ trace::entering("arith::div");
+
+ mln_precondition(exact(rhs).domain() == exact(lhs).domain());
+ mln_precondition(exact(output).domain() == exact(lhs).domain());
+ impl::div_(mln_trait_image_speed(L)(), exact(lhs),
+ mln_trait_image_speed(R)(), exact(rhs),
+ mln_trait_image_speed(O)(), exact(output));
+
+ trace::exiting("arith::div");
+ }
+
+ template <typename I, typename V, typename O>
+ inline
+ void div_cst(const Image<I>& input, const V& val, Image<O>& output)
+ {
+ trace::entering("arith::div_cst");
+
+ mln_precondition(exact(output).domain() == exact(input).domain());
+ div(input, pw::cst(val) | exact(input).domain(), output);
+ // Calls the previous version.
+
+ trace::exiting("arith::div_cst");
+ }
+
+ template <typename L, typename R>
+ inline
+ void div_inplace(Image<L>& lhs, const Image<R>& rhs)
+ {
+ trace::entering("arith::div_inplace");
+
+ mln_precondition(exact(rhs).domain() <= exact(lhs).domain());
+ impl::div_inplace_(mln_trait_image_speed(L)(), exact(lhs),
+ mln_trait_image_speed(R)(), exact(rhs));
+
+ trace::exiting("arith::div_inplace");
+ }
+
+ template <typename I, typename V>
+ inline
+ void div_cst_inplace(Image<I>& input, const V& val)
+ {
+ trace::entering("arith::div_cst_inplace");
+
+ mln_precondition(exact(input).is_valid());
+ div_inplace(input, pw::cst(val) | exact(input).domain());
+ // Calls the previous version.
+
+ trace::exiting("arith::div_cst_inplace");
+ }
+
+ } // end of namespace mln::arith
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_ARITH_DIV_HH
Index: trunk/milena/mln/arith/all.hh
===================================================================
--- trunk/milena/mln/arith/all.hh (revision 3719)
+++ trunk/milena/mln/arith/all.hh (revision 3720)
@@ -55,6 +55,7 @@
}
# include <mln/arith/diff_abs.hh>
+# include <mln/arith/div.hh>
# include <mln/arith/min.hh>
# include <mln/arith/minus.hh>
# include <mln/arith/plus.hh>
Index: trunk/milena/mln/arith/div.spe.hh
===================================================================
--- trunk/milena/mln/arith/div.spe.hh (revision 0)
+++ trunk/milena/mln/arith/div.spe.hh (revision 3720)
@@ -0,0 +1,121 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// 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_ARITH_DIV_SPE_HH
+# define MLN_ARITH_DIV_SPE_HH
+
+/// \file mln/arith/div.spe.hh
+///
+/// Specializations for mln::arith::div.
+
+# ifndef MLN_ARITH_DIV_HH
+# error "Forbidden inclusion of *.spe.hh"
+# endif // ! MLN_ARITH_DIV_HH
+
+# include <mln/arith/includes.hh>
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+namespace mln
+{
+
+ namespace arith
+ {
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+ template <typename L, typename R, typename O>
+ void div_(const L& lhs, const R& rhs, O& output);
+
+ template <typename L, typename R>
+ void div_inplace_(L& lhs, const R& rhs);
+
+ }
+
+ template <typename L, typename R, typename O>
+ inline
+ void div_(trait::image::speed::any, const L& lhs,
+ trait::image::speed::any, const R& rhs,
+ trait::image::speed::any, O& output)
+ {
+ generic::div_(lhs, rhs, output);
+ }
+
+ template <typename L, typename R, typename O>
+ inline
+ void div_(trait::image::speed::fastest, const L& lhs,
+ trait::image::speed::fastest, const R& rhs,
+ trait::image::speed::fastest, O& output)
+ {
+ trace::entering("arith::impl::div_");
+
+ mln_pixter(const L) lp(lhs);
+ mln_pixter(const R) rp(rhs);
+ mln_pixter(O) op(output);
+ for_all_3(lp, rp, op)
+ op.val() = lp.val() / rp.val();
+
+ trace::exiting("arith::impl::div_");
+ }
+
+ template <typename L, typename R>
+ inline
+ void div_inplace_(trait::image::speed::any, L& lhs,
+ trait::image::speed::any, const R& rhs)
+ {
+ generic::div_inplace_(lhs, rhs);
+ }
+
+ template <typename L, typename R>
+ inline
+ void div_inplace_(trait::image::speed::fastest, L& lhs,
+ trait::image::speed::fastest, const R& rhs)
+ {
+ trace::entering("arith::impl::div_inplace_");
+
+ mln_pixter(L) lp(lhs);
+ mln_pixter(const R) rp(rhs);
+ for_all_2(rp, lp)
+ lp.val() /= rp.val();
+
+ trace::exiting("arith::impl::div_inplace_");
+ }
+
+ } // end of namespace mln::arith::impl
+
+ } // end of namespace mln::arith
+
+} // end of namespace mln
+
+# endif // ! MLN_INCLUDE_ONLY
+
+#endif // ! MLN_ARITH_DIV_SPE_HH
Index: trunk/milena/mln/io/magick/save.hh
===================================================================
--- trunk/milena/mln/io/magick/save.hh (revision 3719)
+++ trunk/milena/mln/io/magick/save.hh (revision 3720)
@@ -102,7 +102,7 @@
mln::metal::equal<mln_value(I), value::rgb8>::value))
{
std::cerr << "error: trying to save an unsupported format" << std::endl;
- std::cerr << "formats supported: binary, 8bits grayscale (int_u8), 8bits truecolor (rgb8)" << std::endl;
+ std::cerr << "supported formats: binary, 8bits grayscale (int_u8), 8bits truecolor (rgb8)" << std::endl;
abort();
}
Index: trunk/milena/mln/io/plot/save.hh
===================================================================
--- trunk/milena/mln/io/plot/save.hh (revision 3719)
+++ trunk/milena/mln/io/plot/save.hh (revision 3720)
@@ -87,7 +87,7 @@
trace::entering("mln::io::plot::save");
std::ofstream file_out(filename.c_str());
- for (int i = 0; i < ima.ninds(); ++i)
+ for (unsigned i = 0; i < ima.ninds(); ++i)
file_out << start_value + i << ", " << ima.at_(i) << std::endl;
trace::exiting("mln::io::plot::save");
@@ -101,7 +101,7 @@
trace::entering("mln::io::plot::save");
std::ofstream file_out(filename.c_str());
- for (int i = 0; i < arr.nelements(); ++i)
+ for (unsigned i = 0; i < arr.nelements(); ++i)
file_out << start_value + i << ", " << arr[i] << std::endl;
trace::exiting("mln::io::plot::save");
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-04-28 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Convert Matlab images to Milena images.
* fabien/igr/mat2mln/mat2mln.cc: Convert matlab ascii format
to mln format.
* fabien/igr/mat2mln/raw2mlndata.cc: Deprecated.
* fabien/igr/seg_fixed.cc: Update.
---
TODO | 59 --------------------------------------------
igr/mat2mln/mat2mln.cc | 60 +++++++++++++++++++++++++++++++++++++++++++++
igr/mat2mln/raw2mlndata.cc | 9 +++++-
igr/seg_fixed.cc | 42 +++++++++++++++----------------
4 files changed, 89 insertions(+), 81 deletions(-)
Index: trunk/milena/sandbox/fabien/igr/seg_fixed.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/seg_fixed.cc (revision 3718)
+++ trunk/milena/sandbox/fabien/igr/seg_fixed.cc (revision 3719)
@@ -13,6 +13,7 @@
#include <mln/accu/sum.hh>
#include <mln/data/fill.hh>
+#include <mln/debug/quiet.hh>
#include <mln/convert/from_to.hh>
#include <mln/level/compute.hh>
#include <mln/util/array.hh>
@@ -27,20 +28,20 @@
point2d
get_edge_location(point2d p, point2d n)
{
- point2d res(p);
+ point2d res;
- res.to_vec()[0] *= 2;
- res.to_vec()[1] *= 2;
+ res[0] = p[0] * 2;
+ res[1] = p[1] * 2;
- if (n.to_vec()[0] > p.to_vec()[0])
- ++(res.to_vec()[0]);
- if (n.to_vec()[0] < p.to_vec()[0])
- --(res.to_vec()[0]);
-
- if (n.to_vec()[1] > p.to_vec()[1])
- ++(res.to_vec()[1]);
- if (n.to_vec()[1] < p.to_vec()[1])
- --(res.to_vec()[1]);
+ if (n[0] > p[0])
+ ++(res[0]);
+ if (n[0] < p[0])
+ --(res[0]);
+
+ if (n[1] > p[1])
+ ++(res[1]);
+ if (n[1] < p[1])
+ --(res[1]);
return res;
}
@@ -55,12 +56,13 @@
{
float res = 0.f;
+ if (!ima_sum.bbox().has(n))
+ return res;
+
for (unsigned i = 0; i < ima_arr(p).nelements(); ++i)
res += std::min(ima_arr(p)[i], ima_arr(n)[i]);
res /= std::max(ima_sum(p), ima_sum(n));
- std::cout << "dist = " << res << std::endl;
-
return res;
}
@@ -83,23 +85,22 @@
image2d<float>
dist_on_edges(image2d<util::array<I> > ima_arr)
{
- image2d<float> edges(2 * ima_arr.nrows(), 2 * ima_arr.ncols());
+ box2d b = ima_arr.bbox();
+ image2d<float> edges(make::box2d(2 * b.pmin()[0], 2 * b.pmin()[1],
+ 2 * b.pmax()[0], 2 * b.pmax()[1]));
data::fill(edges, -1.f);
image2d<float> ima_sum;
initialize(ima_sum, ima_arr);
compute_sum_arrays(ima_sum, ima_arr);
- std::cout << "can i has a loop?" << std::endl;
mln_piter(image2d<util::array<I> >) p(ima_arr.domain());
+ mln_niter(neighb2d) n(c4(), p);
for_all(p)
{
- std::cout << "for_all(p)" << std::endl;
- mln_niter(neighb2d) n(c4(), p);
for_all(n)
{
- std::cout << "for_all(n)" << std::endl;
point2d location = get_edge_location(p, n);
- std::cout << "location = " << p << " && edge = " << edges(location) << std::endl;
+ //std::cout << "p: " << p << " | n: " << n << " | e: " << location << std::endl;
if (edges(location) == -1.f)
edges(location) = compute_dist(ima_arr, ima_sum, p, n);
}
@@ -135,7 +136,6 @@
ima_arr(p).append(tmp_slice(p));
}
- std::cout << "ho hai _o/" << std::endl;
image2d<float> edges = dist_on_edges(ima_arr);
return 0;
Index: trunk/milena/sandbox/fabien/igr/mat2mln/raw2mlndata.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/mat2mln/raw2mlndata.cc (revision 3718)
+++ trunk/milena/sandbox/fabien/igr/mat2mln/raw2mlndata.cc (revision 3719)
@@ -27,6 +27,7 @@
unsigned int size = 0;
unsigned int offset = 0;
+
// Top level miMATRIX.
offset += 4;
input.seekg(offset);
@@ -64,11 +65,13 @@
delete name;
offset += 8 - size % 8;
+
std::cout << "----" << std::endl;
// FIXME: Decode data.
offset = 128;
+
// Data miMATRIX.
offset += 4;
input.seekg(offset);
@@ -103,10 +106,11 @@
input.seekg(offset);
input.read((char*) &nslis, sizeof (unsigned int));
offset += sizeof (unsigned int);
+ offset += sizeof (unsigned int); // Padding.
std::cout << "ncols: " << ncols << "; nrows: " << nrows << "; nslis: " << nslis << std::endl;
// Data buffer.
- typedef int V;
+ typedef double V;
int data_size = ncols * nrows * nslis;
V* data_buffer = new V[data_size];
input.seekg(offset);
@@ -119,7 +123,8 @@
// Debug.
image2d<V> ima_debug;
ima_debug = duplicate(slice(ima, 50));
- io::pgm::save(level::stretch(value::int_u8(), ima_debug), "debug.pgm");
+ //io::pgm::save(level::stretch(value::int_u8(), ima_debug), "debug.pgm");
+ io::pgm::save(ima_debug, "debug.pgm");
return 0;
}
Index: trunk/milena/sandbox/fabien/igr/mat2mln/mat2mln.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/mat2mln/mat2mln.cc (revision 0)
+++ trunk/milena/sandbox/fabien/igr/mat2mln/mat2mln.cc (revision 3719)
@@ -0,0 +1,60 @@
+#include <iostream>
+#include <fstream>
+
+#include <mln/core/image/image3d.hh>
+#include <mln/io/dump/save.hh>
+
+#include <mln/core/image/image2d.hh>
+#include <mln/debug/slices_2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/level/stretch.hh>
+
+using namespace mln;
+using value::int_u8;
+
+#define MAX_SLI 750
+#define MAX_ROW 375
+#define MAX_COL 80
+
+
+
+int main(int argc, char* argv[])
+{
+ if (argc != 3)
+ {
+ std::cout << "Usage: " << argv[0] << " cube.in dump.out" << std::endl;
+ return 1;
+ }
+
+ image3d<unsigned int> ima(MAX_SLI, MAX_ROW, MAX_COL);
+
+ std::ifstream file_in(argv[1]);
+ unsigned int val;
+ unsigned int col = 0;
+ unsigned int row = 0;
+ unsigned int sli = 0;
+
+ while (file_in >> val)
+ {
+ ima.at_(sli, row, col) = val;
+ ++row;
+ if (row % MAX_ROW == 0)
+ {
+ row = 0;
+ ++sli;
+ if (sli % MAX_SLI == 0)
+ {
+ sli = 0;
+ ++col;
+ }
+ }
+ }
+
+ io::dump::save(ima, argv[2]);
+
+ image2d<int_u8> ima_flat = debug::slices_2d(level::stretch(int_u8(), ima), 1.f, 0);
+ io::pgm::save(ima_flat, "debug.pgm");
+
+ return 0;
+}
Index: trunk/milena/sandbox/fabien/TODO
===================================================================
--- trunk/milena/sandbox/fabien/TODO (revision 3718)
+++ trunk/milena/sandbox/fabien/TODO (revision 3719)
@@ -7,62 +7,5 @@
||----w |
|| ||
-[X] Create binaries
-[X] Create scripts shell
-[X] Generate color images for regions
-[X] Generate histograms (normal, bg, obj, p_bg, p_obj)
-[ ] Test processing chain on US
-[X] Create README file for special images
-[X] Implement watershed
-[X] Create tool for dicom mask
-[X] Check conversion for mask (everything except int_u12(0))
-[ ] Extract ROI (projection or fill holes)
-[ ] Create routine for region colors
-[X] Create dicom2dump (2d, 3d, int_u8, int_u12)
-[ ] After threshold, take biggest object and then erode, dilate
-[ ] Fix n_max
-[ ] Create routine for binary images (keep n big bg & m big objects)
-[X] US: projection of internal gradient
-[X] Create 3D US morpho with 2D stack
-[ ] Create macro for_all_slice
-[X] Batch process watershed with 2D, 3D and any combination of parameters
-[X] Cut into small tools
-[X] Test 3D workflow on 2D images
-[X] Create colorized colors for graph
-[X] Diff with %
-[X] Find biggest dark regions (threshold value or median accu - median / 2 - )
- [X] Learn regions value
- [X] Threshold
- [X] 3D
- [X] Print nb bg regions // nb fg objets
-[ ] Profile for performance
-[X] ImageMagick support
-[ ] Integrate external libraries (GDCM, IM)
-[X] Send result images to lrde account
-[X] Translate Matlab code
-[X] Subsample binary images
-[X] Fast projected histogram
-[ ] Triple histogram
-[X] Create plot for each kind of point with each method
-[ ] Fix mean slices values
-[X] Compatibility Windows
-[X] Fix spatial smooth
-[X] Crop volume 52
-[X] Plot all labels (3, 4 labels for tumeur)
-[X] Prepare data for IGR
- [X] crop->norm->tmax
- [X] crop->norm->space_smooth->tmax
-
- (comparo normalisé)
- 1)brut
- 2)time_smooth
- 3)space_smooth
- 4)current_label_smooth (lambda faible, pas de ligne watershed)
-
- [X] plot label
- [X] gif animés labels
-
- [X] fausses couleurs watershed
- [X] images moyennes
+[ ] Create values between pixels
[ ] Watershed between pixels
-[ ] Mat2Mln
1
0
28 Apr '09
* mln/io/pnm/load.hh: Use the value equivalent type to read
data correctly.
---
milena/ChangeLog | 7 ++++++
milena/mln/io/pnm/load.hh | 53 +++++++++++++++++++++++++++++++++++++++++---
2 files changed, 56 insertions(+), 4 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index efc8740..28a4127 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,12 @@
2009-04-28 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Fix ambiguities while loading PGM images into label values.
+
+ * mln/io/pnm/load.hh: Use the value equivalent type to read
+ data correctly.
+
+2009-04-28 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
Small fixes (again).
* headers.mk: update distributed file list.
diff --git a/milena/mln/io/pnm/load.hh b/milena/mln/io/pnm/load.hh
index a5d591e..be37c51 100644
--- a/milena/mln/io/pnm/load.hh
+++ b/milena/mln/io/pnm/load.hh
@@ -47,6 +47,8 @@
# include <mln/io/pnm/max_component.hh>
# include <mln/io/pnm/macros.hh>
+# include <mln/metal/is_a.hh>
+
namespace mln
{
@@ -59,6 +61,35 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
+ template <typename I>
+ void load_ascii_value(std::ifstream& file, I& ima);
+
+ template <typename I>
+ void load_ascii_builtin(std::ifstream& file, I& ima);
+
+
+ namespace internal
+ {
+
+ template <typename I>
+ inline
+ void
+ load_ascii_dispatch(std::ifstream& file, I& ima, const metal::bool_<true>&)
+ {
+ load_ascii_value(file, ima);
+ }
+
+ template <typename I>
+ inline
+ void
+ load_ascii_dispatch(std::ifstream& file, I& ima, const metal::bool_<false>&)
+ {
+ load_ascii_builtin(file, ima);
+ }
+
+ } // end of namespace mln::io::pnm::internal
+
+
// Read a Milena rgb value (sizeof(int_u8) != 1).
template <unsigned int n>
inline
@@ -130,10 +161,24 @@ namespace mln
file.read((char*)(&ima(p)), len);
}
- /// load_ascii.
+ /// load_ascii for Milena value types.
+ template <typename I>
+ inline
+ void load_ascii_value(std::ifstream& file, I& ima)
+ {
+ mln_equiv(mln_value_(I)) c;
+ mln_fwd_piter(I) p(ima.domain());
+ for_all(p)
+ {
+ file >> c;
+ ima(p) = c;
+ }
+ }
+
+ /// load_ascii for builtin value types.
template <typename I>
inline
- void load_ascii(std::ifstream& file, I& ima)
+ void load_ascii_builtin(std::ifstream& file, I& ima)
{
mln_fwd_piter(I) p(ima.domain());
for_all(p)
@@ -190,7 +235,7 @@ namespace mln
load_raw_2d(file, ima);
else
if (type == (type_ - 3))
- pnm::load_ascii(file, ima);
+ pnm::internal::load_ascii_dispatch(file, ima, mlc_is_a(V, mln::Value)());
trace::exiting("mln::io::pnm::load");
@@ -242,7 +287,7 @@ namespace mln
load_raw_2d(file, ima);
else
if (type == (type_ - 3))
- pnm::load_ascii(file, ima);
+ pnm::internal::load_ascii_dispatch(file, ima, mlc_is_a(mln_value(I), mln::Value)());
trace::exiting("mln::io::pnm::load");
}
--
1.5.6.5
1
0
* headers.mk: update distributed file list.
* mln/accu/inf.hh,
* mln/accu/sup.hh: add a missing typename.
* mln/canvas/browsing/depth_first_search.hh: call id() on vertex
elements.
* mln/core/concept/object_id.hh: add a missing operator==.
* mln/fun/math/inf.hh,
* mln/fun/math/sup.hh: add a missing new line at end of file and fix
copyright.
* mln/trait/next/solve_proxy.hh: add a missing forward declaration.
* mln/util/vertex.hh,
* mln/util/internal/id2element.hh: add a missing include.
* tests/core/image/line_graph_image.cc: use make::vertex_image.
* tests/make/dummy_p_edges.cc,
* tests/make/dummy_p_vertices.cc,
* tests/util/line_graph.cc: call index() instead of id().
* tests/unit_test/unit-tests.mk: update list of unit tests.
---
milena/ChangeLog | 31 ++++++++
milena/headers.mk | 30 ++++++++
milena/mln/accu/inf.hh | 4 +-
milena/mln/accu/sup.hh | 4 +-
milena/mln/canvas/browsing/depth_first_search.hh | 9 ++-
milena/mln/core/concept/object_id.hh | 84 ++++------------------
milena/mln/fun/math/inf.hh | 5 +-
milena/mln/fun/math/sup.hh | 5 +-
milena/mln/trait/next/solve_proxy.hh | 13 +++-
milena/mln/util/internal/id2element.hh | 1 +
milena/mln/util/vertex.hh | 1 +
milena/tests/core/image/line_graph_image.cc | 3 +-
milena/tests/make/dummy_p_edges.cc | 5 +-
milena/tests/make/dummy_p_vertices.cc | 2 +-
milena/tests/unit_test/unit-tests.mk | 60 +++++++++++++++
milena/tests/util/line_graph.cc | 4 +-
16 files changed, 172 insertions(+), 89 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 1a416bd..efc8740 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,34 @@
+2009-04-28 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Small fixes (again).
+
+ * headers.mk: update distributed file list.
+
+ * mln/accu/inf.hh,
+ * mln/accu/sup.hh: add a missing typename.
+
+ * mln/canvas/browsing/depth_first_search.hh: call id() on vertex
+ elements.
+
+ * mln/core/concept/object_id.hh: add a missing operator==.
+
+ * mln/fun/math/inf.hh,
+ * mln/fun/math/sup.hh: add a missing new line at end of file and fix
+ copyright.
+
+ * mln/trait/next/solve_proxy.hh: add a missing forward declaration.
+
+ * mln/util/vertex.hh,
+ * mln/util/internal/id2element.hh: add a missing include.
+
+ * tests/core/image/line_graph_image.cc: use make::vertex_image.
+
+ * tests/make/dummy_p_edges.cc,
+ * tests/make/dummy_p_vertices.cc,
+ * tests/util/line_graph.cc: call index() instead of id().
+
+ * tests/unit_test/unit-tests.mk: update list of unit tests.
+
2009-04-27 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
Small fixes.
diff --git a/milena/headers.mk b/milena/headers.mk
index 5eaf7f7..733a334 100644
--- a/milena/headers.mk
+++ b/milena/headers.mk
@@ -145,6 +145,7 @@ mln/make/cell.hh \
mln/make/image.hh \
mln/make/influence_zone_adjacency_graph.hh \
mln/make/vec.hh \
+mln/make/edge_image.hh \
mln/make/all.hh \
mln/make/dual_neighb.hh \
mln/make/attachment.hh \
@@ -204,9 +205,11 @@ mln/fun/p2b/essential.hh \
mln/fun/p2p/all.hh \
mln/fun/p2p/translation.hh \
mln/fun/p2p/mirror.hh \
+mln/fun/accu_result.hh \
mln/fun/x2p/closest_point.hh \
mln/fun/x2p/all.hh \
mln/fun/x2p/essential.hh \
+mln/fun/binary.hh \
mln/fun/ops.hh \
mln/fun/c.hh \
mln/fun/vv2v/max.hh \
@@ -224,6 +227,8 @@ mln/fun/internal/x2x_linear_impl.hh \
mln/fun/internal/ch_function_value_impl.hh \
mln/fun/internal/resolve.hh \
mln/fun/internal/selector.hh \
+mln/fun/spe/binary.hh \
+mln/fun/spe/unary.hh \
mln/fun/v2w_w2v/norm.hh \
mln/fun/p2v/ternary.hh \
mln/fun/p2v/iota.hh \
@@ -231,6 +236,12 @@ mln/fun/p2v/elifs.hh \
mln/fun/p2v/all.hh \
mln/fun/p2v/essential.hh \
mln/fun/all.hh \
+mln/fun/param.hh \
+mln/fun/math/norm.hh \
+mln/fun/math/abs.hh \
+mln/fun/math/sup.hh \
+mln/fun/math/cos.hh \
+mln/fun/math/inf.hh \
mln/fun/v2b/lnot.hh \
mln/fun/v2b/all.hh \
mln/fun/v2b/threshold.hh \
@@ -252,6 +263,7 @@ mln/fun/v2v/projection.hh \
mln/fun/v2v/convert.hh \
mln/fun/v2v/essential.hh \
mln/fun/v2w2v/cos.hh \
+mln/fun/unary.hh \
mln/fun/vv2b/implies.hh \
mln/fun/vv2b/le.hh \
mln/fun/vv2b/gt.hh \
@@ -259,6 +271,7 @@ mln/fun/vv2b/ge.hh \
mln/fun/vv2b/lt.hh \
mln/fun/vv2b/eq.hh \
mln/fun/cast.hh \
+mln/fun/composition.hh \
mln/fun/i2v/all.hh \
mln/fun/i2v/array.hh \
mln/fun/i2v/all_to.hh \
@@ -271,6 +284,12 @@ mln/fun/x2x/all.hh \
mln/fun/x2x/translation.hh \
mln/fun/x2x/rotation.hh \
mln/fun/x2x/essential.hh \
+mln/fun/component/red.hh \
+mln/fun/component/green.hh \
+mln/fun/component/comp.hh \
+mln/fun/component/blue.hh \
+mln/fun/component/rgb.hh \
+mln/fun/compose.hh \
mln/fun/meta/red.hh \
mln/fun/meta/hue.hh \
mln/fun/meta/lum.hh \
@@ -283,6 +302,7 @@ mln/fun/meta/sat.hh \
mln/fun/meta/first.hh \
mln/fun/meta/to_enc.hh \
mln/fun/meta/essential.hh \
+mln/fun/from_accu.hh \
mln/fun/x2v/trilinear.hh \
mln/fun/x2v/linear.hh \
mln/fun/x2v/bilinear.hh \
@@ -410,6 +430,7 @@ mln/accu/land_basic.hh \
mln/accu/p.hh \
mln/accu/transform.hh \
mln/accu/median_alt.hh \
+mln/accu/sup.hh \
mln/accu/volume.hh \
mln/accu/sum.hh \
mln/accu/label_used.hh \
@@ -417,6 +438,7 @@ mln/accu/height.hh \
mln/accu/land.hh \
mln/accu/take.hh \
mln/accu/histo.hh \
+mln/accu/inf.hh \
mln/accu/pair.hh \
mln/accu/count_labels.hh \
mln/accu/count_adjacent_vertices.hh \
@@ -517,10 +539,15 @@ mln/trait/window/props.hh \
mln/trait/window/print.hh \
mln/trait/accumulator/props.hh \
mln/trait/accumulator/print.hh \
+mln/trait/next/solve_binary.hh \
+mln/trait/next/solve.hh \
+mln/trait/next/solve_unary.hh \
+mln/trait/next/solve_proxy.hh \
mln/trait/ch_function_value.hh \
mln/trait/ch_value.hh \
mln/trait/solve.hh \
mln/trait/solve_unary.hh \
+mln/trait/fun.hh \
mln/trait/op/postdec.hh \
mln/trait/op/mod.hh \
mln/trait/op/lor.hh \
@@ -948,6 +975,7 @@ mln/core/concept/doc/point_iterator.hh \
mln/core/concept/pseudo_site.hh \
mln/core/concept/image.hh \
mln/core/concept/value_set.hh \
+mln/core/concept/meta_function.hh \
mln/core/concept/proxy.hh \
mln/core/concept/site.hh \
mln/core/concept/weighted_window.hh \
@@ -1005,8 +1033,10 @@ mln/core/image/cast_image.hh \
mln/core/image/rle_encode.hh \
mln/core/image/complex_window_piter.hh \
mln/core/image/tr_image.hh \
+mln/core/image/thrubin_morpher.hh \
mln/core/image/sub_image.hh \
mln/core/image/rle_image.hh \
+mln/core/image/thru_morpher.hh \
mln/core/image/mono_rle_encode.hh \
mln/core/image/bgraph_psite.hh \
mln/core/image/sparse_image.hh \
diff --git a/milena/mln/accu/inf.hh b/milena/mln/accu/inf.hh
index a17ee29..d44b1b5 100644
--- a/milena/mln/accu/inf.hh
+++ b/milena/mln/accu/inf.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2009 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of the Olena Library. This library is free
@@ -75,7 +75,7 @@ namespace mln
protected:
T t_;
- mln::fun::inf::with<T, T>::ret fun_;
+ typename mln::fun::inf::with<T, T>::ret fun_;
};
diff --git a/milena/mln/accu/sup.hh b/milena/mln/accu/sup.hh
index f7759d2..a07c3e7 100644
--- a/milena/mln/accu/sup.hh
+++ b/milena/mln/accu/sup.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2009 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of the Olena Library. This library is free
@@ -75,7 +75,7 @@ namespace mln
protected:
T t_;
- mln::fun::sup::with<T, T>::ret fun_;
+ typename mln::fun::sup::with<T, T>::ret fun_;
};
diff --git a/milena/mln/canvas/browsing/depth_first_search.hh b/milena/mln/canvas/browsing/depth_first_search.hh
index 818e44b..48a8554 100644
--- a/milena/mln/canvas/browsing/depth_first_search.hh
+++ b/milena/mln/canvas/browsing/depth_first_search.hh
@@ -81,18 +81,25 @@ namespace mln
namespace browsing
{
+ /// Depth-limited search algorithm for graph.
+ /// Browse over all vertices for each component.
struct depth_first_search_t : public Browsing< depth_first_search_t >
{
template <typename G, typename F>
void operator()(const Graph<G>&, F& f) const;
};
+
extern const depth_first_search_t depth_first_search;
+
+
# ifndef MLN_INCLUDE_ONLY
const depth_first_search_t depth_first_search;
+
+
template <typename G, typename F>
inline
void
@@ -115,7 +122,7 @@ namespace mln
while (!queue.empty())
{
util::vertex<G> current_v = g.vertex(queue.front());
- f.process_vertex(current_v); // <--- process_vertex
+ f.process_vertex(current_v.id()); // <--- process_vertex
queue.pop();
for (unsigned nv = 0; nv < current_v.nmax_nbh_vertices(); ++nv)
if (f.to_be_queued(current_v.ith_nbh_vertex(nv))) // <--- to_be_queued
diff --git a/milena/mln/core/concept/object_id.hh b/milena/mln/core/concept/object_id.hh
index 5bf5547..770098e 100644
--- a/milena/mln/core/concept/object_id.hh
+++ b/milena/mln/core/concept/object_id.hh
@@ -98,19 +98,10 @@ namespace mln
template <typename Tag, typename V>
bool
operator==(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs);
-//
-// template <typename Tag, typename V>
-// bool
-// operator<(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs);
-//
-// template <typename Tag, typename V>
-// bool
-// operator<(const object_id<Tag,V>& lhs,
-// const typename object_id<Tag,V>::V& rhs);
-//
-// template <typename Tag, typename V>
-// std::ostream&
-// operator<<(std::ostream& ostr, const object_id<Tag,V>& id);
+
+ template <typename Tag, typename V, typename V2>
+ bool
+ operator==(const object_id<Tag,V>& lhs, const Value<V2>& rhs);
# ifndef MLN_INCLUDE_ONLY
@@ -202,15 +193,8 @@ namespace mln
}
-// template <typename Tag, typename V>
-// inline
-// std::ostream&
-// operator<<(std::ostream& ostr, const object_id<Tag,V>& id)
-// {
-// return ostr << id.value();
-// }
-//
-//
+
+
template <typename Tag, typename V>
inline
bool
@@ -218,56 +202,14 @@ namespace mln
{
return lhs.value() == rhs.value();
}
-//
-// template <typename Tag, typename V>
-// inline
-// bool
-// operator<(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs)
-// {
-// return lhs.value() < rhs.value();
-// }
-//
-// template <typename Tag, typename V>
-// inline
-// bool
-// operator<(const object_id<Tag,V>& lhs, const V& rhs)
-// {
-// return lhs.value() < rhs;
-// }
-//
-// template <typename Tag, typename V>
-// inline
-// bool
-// operator<=(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs)
-// {
-// return lhs.value() <= rhs.value();
-// }
-//
-// template <typename Tag, typename V>
-// inline
-// bool
-// operator<=(const object_id<Tag,V>& lhs, const V& rhs)
-// {
-// return lhs.value() <= rhs;
-// }
-
-// template <typename Tag, typename V>
-// inline
-// object_id<Tag,V>
-// operator+(const object_id<Tag,V>& lhs, const V& rhs)
-// {
-// return lhs.value() + rhs;
-// }
-//
-// template <typename Tag, typename V>
-// inline
-// object_id<Tag,V>
-// operator+(const object_id<Tag,V>& lhs, const size_t& rhs)
-// {
-// return lhs.value() + rhs;
-// }
-
+ template <typename Tag, typename V, typename V2>
+ inline
+ bool
+ operator==(const object_id<Tag,V>& lhs, const Value<V2>& rhs)
+ {
+ return lhs.value() == exact(rhs).to_equiv();
+ }
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/fun/math/inf.hh b/milena/mln/fun/math/inf.hh
index 56a4a12..2c80d84 100644
--- a/milena/mln/fun/math/inf.hh
+++ b/milena/mln/fun/math/inf.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -66,4 +66,5 @@ namespace mln
}
-#endif /* ! MLN_FUN_MATH_INF_HH */
\ No newline at end of file
+#endif /* ! MLN_FUN_MATH_INF_HH */
+
diff --git a/milena/mln/fun/math/sup.hh b/milena/mln/fun/math/sup.hh
index ed00aa8..cd94dc1 100644
--- a/milena/mln/fun/math/sup.hh
+++ b/milena/mln/fun/math/sup.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -66,4 +66,5 @@ namespace mln
}
-#endif /* ! MLN_FUN_MATH_SUP_HH */
\ No newline at end of file
+#endif /* ! MLN_FUN_MATH_SUP_HH */
+
diff --git a/milena/mln/trait/next/solve_proxy.hh b/milena/mln/trait/next/solve_proxy.hh
index 168d305..a46cf1b 100644
--- a/milena/mln/trait/next/solve_proxy.hh
+++ b/milena/mln/trait/next/solve_proxy.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -51,6 +51,13 @@ namespace mln
namespace next
{
+ // Forward declaration
+ // Needed by mln_trait_nbinary.
+ template < typename Name, typename L_, typename R_ >
+ struct solve_binary;
+
+
+
// Unary ops.
template < typename Op, typename P >
@@ -67,8 +74,8 @@ namespace mln
{
typedef mln::internal::helper_unprox_binop<L, R> helper;
typedef mln_trait_nbinary(Op,
- typename helper::L_ret,
- typename helper::R_ret) ret;
+ typename helper::L_ret,
+ typename helper::R_ret) ret;
};
template < typename Op, typename P, typename O >
diff --git a/milena/mln/util/internal/id2element.hh b/milena/mln/util/internal/id2element.hh
index d574dc3..48550da 100644
--- a/milena/mln/util/internal/id2element.hh
+++ b/milena/mln/util/internal/id2element.hh
@@ -34,6 +34,7 @@
/// Function constructing a element from an id.
#include <mln/core/concept/graph.hh>
+#include <mln/core/concept/function.hh>
namespace mln
{
diff --git a/milena/mln/util/vertex.hh b/milena/mln/util/vertex.hh
index 4b43ef3..8c931df 100644
--- a/milena/mln/util/vertex.hh
+++ b/milena/mln/util/vertex.hh
@@ -33,6 +33,7 @@
# include <mln/util/graph_ids.hh>
# include <mln/util/internal/vertex_impl.hh>
# include <mln/core/concept/proxy.hh>
+# include <mln/core/concept/site.hh>
/// \file mln/util/vertex.hh
///
diff --git a/milena/tests/core/image/line_graph_image.cc b/milena/tests/core/image/line_graph_image.cc
index 2c11e73..9a67fda 100644
--- a/milena/tests/core/image/line_graph_image.cc
+++ b/milena/tests/core/image/line_graph_image.cc
@@ -42,6 +42,7 @@
#include <mln/pw/all.hh>
#include <mln/fun/i2v/array.hh>
#include <mln/util/graph.hh>
+#include <mln/make/vertex_image.hh>
/* The graph and its corresponding line graph are as follows:
@@ -113,7 +114,7 @@ int main()
// Create line graph image.
typedef vertex_image<point2d,unsigned> ima_t;
- ima_t ima(g, sites, iota);
+ ima_t ima = make::vertex_image(g, sites, iota);
/*------------.
| Iterators. |
diff --git a/milena/tests/make/dummy_p_edges.cc b/milena/tests/make/dummy_p_edges.cc
index b04e6d4..5fb56e8 100644
--- a/milena/tests/make/dummy_p_edges.cc
+++ b/milena/tests/make/dummy_p_edges.cc
@@ -52,13 +52,14 @@ int main()
g.add_edge(4,2);
{
- typedef p_edges<G, pw::cst_<int> > pe_t;
+ typedef p_edges<G> pe_t;
pe_t pe = make::dummy_p_edges(g);
+ unsigned i = 0;
mln_assertion(pe.nsites() == 4);
mln_piter_(pe_t) p(pe);
for_all(p)
- mln_assertion(p == 0);
+ mln_assertion(p.id() == i++);
}
{
diff --git a/milena/tests/make/dummy_p_vertices.cc b/milena/tests/make/dummy_p_vertices.cc
index 344d72c..c97e805 100644
--- a/milena/tests/make/dummy_p_vertices.cc
+++ b/milena/tests/make/dummy_p_vertices.cc
@@ -52,7 +52,7 @@ int main()
g.add_edge(4,2);
{
- typedef p_vertices<G, pw::cst_<int> > pe_t;
+ typedef p_vertices<G> pe_t;
pe_t pe = make::dummy_p_vertices(g);
mln_assertion(pe.nsites() == 5);
diff --git a/milena/tests/unit_test/unit-tests.mk b/milena/tests/unit_test/unit-tests.mk
index 46fbff2..844b37f 100644
--- a/milena/tests/unit_test/unit-tests.mk
+++ b/milena/tests/unit_test/unit-tests.mk
@@ -140,6 +140,7 @@ mln_make_cell \
mln_make_image \
mln_make_influence_zone_adjacency_graph \
mln_make_vec \
+mln_make_edge_image \
mln_make_all \
mln_make_dual_neighb \
mln_make_attachment \
@@ -199,9 +200,11 @@ mln_fun_p2b_essential \
mln_fun_p2p_all \
mln_fun_p2p_translation \
mln_fun_p2p_mirror \
+mln_fun_accu_result \
mln_fun_x2p_closest_point \
mln_fun_x2p_all \
mln_fun_x2p_essential \
+mln_fun_binary \
mln_fun_ops \
mln_fun_c \
mln_fun_vv2v_max \
@@ -219,6 +222,8 @@ mln_fun_internal_x2x_linear_impl \
mln_fun_internal_ch_function_value_impl \
mln_fun_internal_resolve \
mln_fun_internal_selector \
+mln_fun_spe_binary \
+mln_fun_spe_unary \
mln_fun_v2w_w2v_norm \
mln_fun_p2v_ternary \
mln_fun_p2v_iota \
@@ -226,6 +231,12 @@ mln_fun_p2v_elifs \
mln_fun_p2v_all \
mln_fun_p2v_essential \
mln_fun_all \
+mln_fun_param \
+mln_fun_math_norm \
+mln_fun_math_abs \
+mln_fun_math_sup \
+mln_fun_math_cos \
+mln_fun_math_inf \
mln_fun_v2b_lnot \
mln_fun_v2b_all \
mln_fun_v2b_threshold \
@@ -247,6 +258,7 @@ mln_fun_v2v_projection \
mln_fun_v2v_convert \
mln_fun_v2v_essential \
mln_fun_v2w2v_cos \
+mln_fun_unary \
mln_fun_vv2b_implies \
mln_fun_vv2b_le \
mln_fun_vv2b_gt \
@@ -254,6 +266,7 @@ mln_fun_vv2b_ge \
mln_fun_vv2b_lt \
mln_fun_vv2b_eq \
mln_fun_cast \
+mln_fun_composition \
mln_fun_i2v_all \
mln_fun_i2v_array \
mln_fun_i2v_all_to \
@@ -266,6 +279,12 @@ mln_fun_x2x_all \
mln_fun_x2x_translation \
mln_fun_x2x_rotation \
mln_fun_x2x_essential \
+mln_fun_component_red \
+mln_fun_component_green \
+mln_fun_component_comp \
+mln_fun_component_blue \
+mln_fun_component_rgb \
+mln_fun_compose \
mln_fun_meta_red \
mln_fun_meta_hue \
mln_fun_meta_lum \
@@ -278,6 +297,7 @@ mln_fun_meta_sat \
mln_fun_meta_first \
mln_fun_meta_to_enc \
mln_fun_meta_essential \
+mln_fun_from_accu \
mln_fun_x2v_trilinear \
mln_fun_x2v_linear \
mln_fun_x2v_bilinear \
@@ -405,6 +425,7 @@ mln_accu_land_basic \
mln_accu_p \
mln_accu_transform \
mln_accu_median_alt \
+mln_accu_sup \
mln_accu_volume \
mln_accu_sum \
mln_accu_label_used \
@@ -412,6 +433,7 @@ mln_accu_height \
mln_accu_land \
mln_accu_take \
mln_accu_histo \
+mln_accu_inf \
mln_accu_pair \
mln_accu_count_labels \
mln_accu_count_adjacent_vertices \
@@ -510,10 +532,15 @@ mln_trait_window_props \
mln_trait_window_print \
mln_trait_accumulator_props \
mln_trait_accumulator_print \
+mln_trait_next_solve_binary \
+mln_trait_next_solve \
+mln_trait_next_solve_unary \
+mln_trait_next_solve_proxy \
mln_trait_ch_function_value \
mln_trait_ch_value \
mln_trait_solve \
mln_trait_solve_unary \
+mln_trait_fun \
mln_trait_op_postdec \
mln_trait_op_mod \
mln_trait_op_lor \
@@ -923,6 +950,7 @@ mln_core_concept_iterator \
mln_core_concept_pseudo_site \
mln_core_concept_image \
mln_core_concept_value_set \
+mln_core_concept_meta_function \
mln_core_concept_proxy \
mln_core_concept_site \
mln_core_concept_weighted_window \
@@ -980,8 +1008,10 @@ mln_core_image_cast_image \
mln_core_image_rle_encode \
mln_core_image_complex_window_piter \
mln_core_image_tr_image \
+mln_core_image_thrubin_morpher \
mln_core_image_sub_image \
mln_core_image_rle_image \
+mln_core_image_thru_morpher \
mln_core_image_mono_rle_encode \
mln_core_image_bgraph_psite \
mln_core_image_sparse_image \
@@ -1295,6 +1325,7 @@ mln_make_cell_SOURCES = mln_make_cell.cc
mln_make_image_SOURCES = mln_make_image.cc
mln_make_influence_zone_adjacency_graph_SOURCES = mln_make_influence_zone_adjacency_graph.cc
mln_make_vec_SOURCES = mln_make_vec.cc
+mln_make_edge_image_SOURCES = mln_make_edge_image.cc
mln_make_all_SOURCES = mln_make_all.cc
mln_make_dual_neighb_SOURCES = mln_make_dual_neighb.cc
mln_make_attachment_SOURCES = mln_make_attachment.cc
@@ -1354,9 +1385,11 @@ mln_fun_p2b_essential_SOURCES = mln_fun_p2b_essential.cc
mln_fun_p2p_all_SOURCES = mln_fun_p2p_all.cc
mln_fun_p2p_translation_SOURCES = mln_fun_p2p_translation.cc
mln_fun_p2p_mirror_SOURCES = mln_fun_p2p_mirror.cc
+mln_fun_accu_result_SOURCES = mln_fun_accu_result.cc
mln_fun_x2p_closest_point_SOURCES = mln_fun_x2p_closest_point.cc
mln_fun_x2p_all_SOURCES = mln_fun_x2p_all.cc
mln_fun_x2p_essential_SOURCES = mln_fun_x2p_essential.cc
+mln_fun_binary_SOURCES = mln_fun_binary.cc
mln_fun_ops_SOURCES = mln_fun_ops.cc
mln_fun_c_SOURCES = mln_fun_c.cc
mln_fun_vv2v_max_SOURCES = mln_fun_vv2v_max.cc
@@ -1374,6 +1407,8 @@ mln_fun_internal_x2x_linear_impl_SOURCES = mln_fun_internal_x2x_linear_impl.cc
mln_fun_internal_ch_function_value_impl_SOURCES = mln_fun_internal_ch_function_value_impl.cc
mln_fun_internal_resolve_SOURCES = mln_fun_internal_resolve.cc
mln_fun_internal_selector_SOURCES = mln_fun_internal_selector.cc
+mln_fun_spe_binary_SOURCES = mln_fun_spe_binary.cc
+mln_fun_spe_unary_SOURCES = mln_fun_spe_unary.cc
mln_fun_v2w_w2v_norm_SOURCES = mln_fun_v2w_w2v_norm.cc
mln_fun_p2v_ternary_SOURCES = mln_fun_p2v_ternary.cc
mln_fun_p2v_iota_SOURCES = mln_fun_p2v_iota.cc
@@ -1381,6 +1416,12 @@ mln_fun_p2v_elifs_SOURCES = mln_fun_p2v_elifs.cc
mln_fun_p2v_all_SOURCES = mln_fun_p2v_all.cc
mln_fun_p2v_essential_SOURCES = mln_fun_p2v_essential.cc
mln_fun_all_SOURCES = mln_fun_all.cc
+mln_fun_param_SOURCES = mln_fun_param.cc
+mln_fun_math_norm_SOURCES = mln_fun_math_norm.cc
+mln_fun_math_abs_SOURCES = mln_fun_math_abs.cc
+mln_fun_math_sup_SOURCES = mln_fun_math_sup.cc
+mln_fun_math_cos_SOURCES = mln_fun_math_cos.cc
+mln_fun_math_inf_SOURCES = mln_fun_math_inf.cc
mln_fun_v2b_lnot_SOURCES = mln_fun_v2b_lnot.cc
mln_fun_v2b_all_SOURCES = mln_fun_v2b_all.cc
mln_fun_v2b_threshold_SOURCES = mln_fun_v2b_threshold.cc
@@ -1402,6 +1443,7 @@ mln_fun_v2v_projection_SOURCES = mln_fun_v2v_projection.cc
mln_fun_v2v_convert_SOURCES = mln_fun_v2v_convert.cc
mln_fun_v2v_essential_SOURCES = mln_fun_v2v_essential.cc
mln_fun_v2w2v_cos_SOURCES = mln_fun_v2w2v_cos.cc
+mln_fun_unary_SOURCES = mln_fun_unary.cc
mln_fun_vv2b_implies_SOURCES = mln_fun_vv2b_implies.cc
mln_fun_vv2b_le_SOURCES = mln_fun_vv2b_le.cc
mln_fun_vv2b_gt_SOURCES = mln_fun_vv2b_gt.cc
@@ -1409,6 +1451,7 @@ mln_fun_vv2b_ge_SOURCES = mln_fun_vv2b_ge.cc
mln_fun_vv2b_lt_SOURCES = mln_fun_vv2b_lt.cc
mln_fun_vv2b_eq_SOURCES = mln_fun_vv2b_eq.cc
mln_fun_cast_SOURCES = mln_fun_cast.cc
+mln_fun_composition_SOURCES = mln_fun_composition.cc
mln_fun_i2v_all_SOURCES = mln_fun_i2v_all.cc
mln_fun_i2v_array_SOURCES = mln_fun_i2v_array.cc
mln_fun_i2v_all_to_SOURCES = mln_fun_i2v_all_to.cc
@@ -1421,6 +1464,12 @@ mln_fun_x2x_all_SOURCES = mln_fun_x2x_all.cc
mln_fun_x2x_translation_SOURCES = mln_fun_x2x_translation.cc
mln_fun_x2x_rotation_SOURCES = mln_fun_x2x_rotation.cc
mln_fun_x2x_essential_SOURCES = mln_fun_x2x_essential.cc
+mln_fun_component_red_SOURCES = mln_fun_component_red.cc
+mln_fun_component_green_SOURCES = mln_fun_component_green.cc
+mln_fun_component_comp_SOURCES = mln_fun_component_comp.cc
+mln_fun_component_blue_SOURCES = mln_fun_component_blue.cc
+mln_fun_component_rgb_SOURCES = mln_fun_component_rgb.cc
+mln_fun_compose_SOURCES = mln_fun_compose.cc
mln_fun_meta_red_SOURCES = mln_fun_meta_red.cc
mln_fun_meta_hue_SOURCES = mln_fun_meta_hue.cc
mln_fun_meta_lum_SOURCES = mln_fun_meta_lum.cc
@@ -1433,6 +1482,7 @@ mln_fun_meta_sat_SOURCES = mln_fun_meta_sat.cc
mln_fun_meta_first_SOURCES = mln_fun_meta_first.cc
mln_fun_meta_to_enc_SOURCES = mln_fun_meta_to_enc.cc
mln_fun_meta_essential_SOURCES = mln_fun_meta_essential.cc
+mln_fun_from_accu_SOURCES = mln_fun_from_accu.cc
mln_fun_x2v_trilinear_SOURCES = mln_fun_x2v_trilinear.cc
mln_fun_x2v_linear_SOURCES = mln_fun_x2v_linear.cc
mln_fun_x2v_bilinear_SOURCES = mln_fun_x2v_bilinear.cc
@@ -1560,6 +1610,7 @@ mln_accu_land_basic_SOURCES = mln_accu_land_basic.cc
mln_accu_p_SOURCES = mln_accu_p.cc
mln_accu_transform_SOURCES = mln_accu_transform.cc
mln_accu_median_alt_SOURCES = mln_accu_median_alt.cc
+mln_accu_sup_SOURCES = mln_accu_sup.cc
mln_accu_volume_SOURCES = mln_accu_volume.cc
mln_accu_sum_SOURCES = mln_accu_sum.cc
mln_accu_label_used_SOURCES = mln_accu_label_used.cc
@@ -1567,6 +1618,7 @@ mln_accu_height_SOURCES = mln_accu_height.cc
mln_accu_land_SOURCES = mln_accu_land.cc
mln_accu_take_SOURCES = mln_accu_take.cc
mln_accu_histo_SOURCES = mln_accu_histo.cc
+mln_accu_inf_SOURCES = mln_accu_inf.cc
mln_accu_pair_SOURCES = mln_accu_pair.cc
mln_accu_count_labels_SOURCES = mln_accu_count_labels.cc
mln_accu_count_adjacent_vertices_SOURCES = mln_accu_count_adjacent_vertices.cc
@@ -1665,10 +1717,15 @@ mln_trait_window_props_SOURCES = mln_trait_window_props.cc
mln_trait_window_print_SOURCES = mln_trait_window_print.cc
mln_trait_accumulator_props_SOURCES = mln_trait_accumulator_props.cc
mln_trait_accumulator_print_SOURCES = mln_trait_accumulator_print.cc
+mln_trait_next_solve_binary_SOURCES = mln_trait_next_solve_binary.cc
+mln_trait_next_solve_SOURCES = mln_trait_next_solve.cc
+mln_trait_next_solve_unary_SOURCES = mln_trait_next_solve_unary.cc
+mln_trait_next_solve_proxy_SOURCES = mln_trait_next_solve_proxy.cc
mln_trait_ch_function_value_SOURCES = mln_trait_ch_function_value.cc
mln_trait_ch_value_SOURCES = mln_trait_ch_value.cc
mln_trait_solve_SOURCES = mln_trait_solve.cc
mln_trait_solve_unary_SOURCES = mln_trait_solve_unary.cc
+mln_trait_fun_SOURCES = mln_trait_fun.cc
mln_trait_op_postdec_SOURCES = mln_trait_op_postdec.cc
mln_trait_op_mod_SOURCES = mln_trait_op_mod.cc
mln_trait_op_lor_SOURCES = mln_trait_op_lor.cc
@@ -2078,6 +2135,7 @@ mln_core_concept_iterator_SOURCES = mln_core_concept_iterator.cc
mln_core_concept_pseudo_site_SOURCES = mln_core_concept_pseudo_site.cc
mln_core_concept_image_SOURCES = mln_core_concept_image.cc
mln_core_concept_value_set_SOURCES = mln_core_concept_value_set.cc
+mln_core_concept_meta_function_SOURCES = mln_core_concept_meta_function.cc
mln_core_concept_proxy_SOURCES = mln_core_concept_proxy.cc
mln_core_concept_site_SOURCES = mln_core_concept_site.cc
mln_core_concept_weighted_window_SOURCES = mln_core_concept_weighted_window.cc
@@ -2135,8 +2193,10 @@ mln_core_image_cast_image_SOURCES = mln_core_image_cast_image.cc
mln_core_image_rle_encode_SOURCES = mln_core_image_rle_encode.cc
mln_core_image_complex_window_piter_SOURCES = mln_core_image_complex_window_piter.cc
mln_core_image_tr_image_SOURCES = mln_core_image_tr_image.cc
+mln_core_image_thrubin_morpher_SOURCES = mln_core_image_thrubin_morpher.cc
mln_core_image_sub_image_SOURCES = mln_core_image_sub_image.cc
mln_core_image_rle_image_SOURCES = mln_core_image_rle_image.cc
+mln_core_image_thru_morpher_SOURCES = mln_core_image_thru_morpher.cc
mln_core_image_mono_rle_encode_SOURCES = mln_core_image_mono_rle_encode.cc
mln_core_image_bgraph_psite_SOURCES = mln_core_image_bgraph_psite.cc
mln_core_image_sparse_image_SOURCES = mln_core_image_sparse_image.cc
diff --git a/milena/tests/util/line_graph.cc b/milena/tests/util/line_graph.cc
index 811a695..3370a5c 100644
--- a/milena/tests/util/line_graph.cc
+++ b/milena/tests/util/line_graph.cc
@@ -94,7 +94,7 @@ int main()
{
unsigned i = 0;
for_all(n)
- mln_assertion(i++ == n.id());
+ mln_assertion(i++ == n.index());
mln_assertion(i != 0);
}
}
@@ -107,7 +107,7 @@ int main()
{
unsigned i = v.nmax_nbh_edges();
for_all(e)
- mln_assertion(--i == e.id());
+ mln_assertion(--i == e.index());
mln_assertion((v.nmax_nbh_edges() == 0 && i == 0) || i != v.nmax_nbh_edges());
}
}
--
1.5.6.5
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk
ChangeLog:
2009-04-27 Frederic Bour <bour(a)lrde.epita.fr>
Merge new fun implementation to main milena directory.
* milena/mln/accu/inf.hh: New.
* milena/mln/accu/sup.hh: New.
* milena/mln/core/concept/meta_function.hh: New.
* milena/mln/core/image/thru_morpher.hh: New.
* milena/mln/core/image/thrubin_morpher.hh: New.
* milena/mln/fun/accu_result.hh: New.
* milena/mln/fun/binary.hh: New.
* milena/mln/fun/component/blue.hh: New.
* milena/mln/fun/component/comp.hh: New.
* milena/mln/fun/component/green.hh: New.
* milena/mln/fun/component/red.hh: New.
* milena/mln/fun/component/rgb.hh: New.
* milena/mln/fun/component: New.
* milena/mln/fun/compose.hh: New.
* milena/mln/fun/composition.hh: New.
* milena/mln/fun/from_accu.hh: New.
* milena/mln/fun/math/abs.hh: New.
* milena/mln/fun/math/cos.hh: New.
* milena/mln/fun/math/inf.hh: New.
* milena/mln/fun/math/norm.hh: New.
* milena/mln/fun/math/sup.hh: New.
* milena/mln/fun/math: New.
* milena/mln/fun/param.hh: New.
* milena/mln/fun/spe/binary.hh: New.
* milena/mln/fun/spe/unary.hh: New.
* milena/mln/fun/spe: New.
* milena/mln/fun/unary.hh: New.
* milena/mln/trait/fun.hh: New.
* milena/mln/trait/next/solve.hh: New.
* milena/mln/trait/next/solve_binary.hh: New.
* milena/mln/trait/next/solve_proxy.hh: New.
* milena/mln/trait/next/solve_unary.hh: New.
* milena/mln/trait/next: New.
* milena/sandbox/fred/mln/accu/inf.hh: Remove.
* milena/sandbox/fred/mln/accu/sup.hh: Remove.
* milena/sandbox/fred/mln/core/concept/meta_function.hh: Remove.
* milena/sandbox/fred/mln/core/image/thru_morpher.hh: Remove.
* milena/sandbox/fred/mln/core/image/thrubin_morpher.hh: Remove.
* milena/sandbox/fred/mln/fun/accu_result.hh: Remove.
* milena/sandbox/fred/mln/fun/binary.hh: Remove.
* milena/sandbox/fred/mln/fun/component/blue.hh: Remove.
* milena/sandbox/fred/mln/fun/component/comp.hh: Remove.
* milena/sandbox/fred/mln/fun/component/green.hh: Remove.
* milena/sandbox/fred/mln/fun/component/red.hh: Remove.
* milena/sandbox/fred/mln/fun/component/rgb.hh: Remove.
* milena/sandbox/fred/mln/fun/compose.hh: Remove.
* milena/sandbox/fred/mln/fun/composition.hh: Remove.
* milena/sandbox/fred/mln/fun/from_accu.hh: Remove.
* milena/sandbox/fred/mln/fun/math/abs.hh: Remove.
* milena/sandbox/fred/mln/fun/math/cos.hh: Remove.
* milena/sandbox/fred/mln/fun/math/inf.hh: Remove.
* milena/sandbox/fred/mln/fun/math/norm.hh: Remove.
* milena/sandbox/fred/mln/fun/math/sup.hh: Remove.
* milena/sandbox/fred/mln/fun/param.hh: Remove.
* milena/sandbox/fred/mln/fun/spe/binary.hh: Remove.
* milena/sandbox/fred/mln/fun/spe/unary.hh: Remove.
* milena/sandbox/fred/mln/fun/unary.hh: Remove.
* milena/sandbox/fred/mln/trait/fun.hh: Remove.
* milena/sandbox/fred/mln/trait/next/solve.hh: Remove.
* milena/sandbox/fred/mln/trait/next/solve_binary.hh: Remove.
* milena/sandbox/fred/mln/trait/next/solve_proxy.hh: Remove.
* milena/sandbox/fred/mln/trait/next/solve_unary.hh: Remove.
---
trunk/milena/mln/accu/inf.hh | 166 +++++++++++++
trunk/milena/mln/accu/sup.hh | 166 +++++++++++++
trunk/milena/mln/core/concept/meta_function.hh | 203 ++++++++++++++++
trunk/milena/mln/core/image/thru_morpher.hh | 306 +++++++++++++++++++++++++
trunk/milena/mln/core/image/thrubin_morpher.hh | 279 ++++++++++++++++++++++
trunk/milena/mln/fun/accu_result.hh | 69 +++++
trunk/milena/mln/fun/binary.hh | 94 +++++++
trunk/milena/mln/fun/component/blue.hh | 84 ++++++
trunk/milena/mln/fun/component/comp.hh | 174 ++++++++++++++
trunk/milena/mln/fun/component/green.hh | 84 ++++++
trunk/milena/mln/fun/component/red.hh | 84 ++++++
trunk/milena/mln/fun/component/rgb.hh | 40 +++
trunk/milena/mln/fun/compose.hh | 117 +++++++++
trunk/milena/mln/fun/composition.hh | 223 ++++++++++++++++++
trunk/milena/mln/fun/from_accu.hh | 95 +++++++
trunk/milena/mln/fun/math/abs.hh | 69 +++++
trunk/milena/mln/fun/math/cos.hh | 91 +++++++
trunk/milena/mln/fun/math/inf.hh | 69 +++++
trunk/milena/mln/fun/math/norm.hh | 119 +++++++++
trunk/milena/mln/fun/math/sup.hh | 69 +++++
trunk/milena/mln/fun/param.hh | 88 +++++++
trunk/milena/mln/fun/spe/binary.hh | 136 +++++++++++
trunk/milena/mln/fun/spe/unary.hh | 302 ++++++++++++++++++++++++
trunk/milena/mln/fun/unary.hh | 169 +++++++++++++
trunk/milena/mln/trait/fun.hh | 253 ++++++++++++++++++++
trunk/milena/mln/trait/next/solve.hh | 152 ++++++++++++
trunk/milena/mln/trait/next/solve_binary.hh | 302 ++++++++++++++++++++++++
trunk/milena/mln/trait/next/solve_proxy.hh | 95 +++++++
trunk/milena/mln/trait/next/solve_unary.hh | 171 +++++++++++++
29 files changed, 4269 insertions(+)
Index: trunk/milena/mln/trait/fun.hh
===================================================================
--- trunk/milena/mln/trait/fun.hh (revision 0)
+++ trunk/milena/mln/trait/fun.hh (revision 3716)
@@ -0,0 +1,253 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// 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 F PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_TRAIT_FUN_HH
+# define MLN_TRAIT_FUN_HH
+
+# include <mln/metal/bexpr.hh>
+# include <mln/metal/if.hh>
+# include <mln/fun/param.hh>
+# include <mln/trait/next/solve.hh>
+
+# define mln_trait_fun_is_assignable(Fun) typename mln::trait::fun::is_assignable< Fun >::ret
+# define mln_trait_fun_is_assignable_(Fun) mln::trait::fun::is_assignable< Fun >::ret
+# define mln_trait_fun_is_assignable__1comma(A, B) typename mln::trait::fun::is_assignable< A, B >::ret
+# define mln_trait_fun_is_assignable__1comma_(A, B) mln::trait::fun::is_assignable< A, B >::ret
+
+# define mln_trait_fun_is_parametrable(Fun) typename mln::trait::fun::is_parametrable< Fun >::ret
+# define mln_trait_fun_is_parametrable_(Fun) mln::trait::fun::is_parametrable< Fun >::ret
+
+# define mln_trait_fun_lvalue(Fun) typename mln::trait::fun::get_lvalue< Fun >::ret
+# define mln_trait_fun_param(Fun) typename mln::trait::fun::get_param< Fun >::ret
+# define mln_trait_fun_storage(Fun) typename mln::trait::fun::get_storage< Fun >::ret
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+ namespace fun
+ {
+
+ namespace internal
+ {
+
+ namespace introspect
+ {
+
+ template <typename T>
+ struct except_void_t
+ {
+ typedef void ret;
+ };
+
+ template <>
+ struct except_void_t<void>;
+
+ // Lvalue solver
+
+ template <typename T, typename V>
+ struct has_lvalue_t
+ {
+ typedef metal::false_ ret;
+ typedef void type;
+ };
+
+ template <typename T>
+ struct has_lvalue_t<T, typename except_void_t<typename T::lvalue>::ret>
+ {
+ typedef metal::true_ ret;
+ typedef typename T::lvalue type;
+ };
+
+ // Parameter solver
+ template <typename T, typename V>
+ struct param_solver;
+
+ template <typename T, typename V>
+ struct param_flag_solver
+ {
+ typedef typename mln::fun::parameter<T> ret;
+ };
+
+ template <typename T>
+ struct param_flag_solver<T, typename except_void_t<typename mln::fun::parameter<typename T::flag>::param>::ret>
+ {
+ typedef mln::fun::parameter<typename T::flag> ret;
+ };
+
+ template <typename T, typename V>
+ struct param_def_solver
+ {
+ typedef typename param_flag_solver<T, V>::ret ret;
+ };
+
+ template <typename T>
+ struct param_def_solver<T, typename except_void_t<typename mln::fun::parameter<typename T::def>::param>::ret>
+ {
+ typedef mln::fun::parameter<typename T::def> ret;
+ };
+
+ template <typename T, typename V>
+ struct param_solver : param_def_solver<T, V>
+ {
+ };
+
+ template <typename T>
+ struct param_solver<T, typename except_void_t<typename T::param>::ret>
+ {
+ typedef T ret;
+ };
+
+ template <typename T, typename V>
+ struct has_param_t
+ {
+ typedef metal::false_ ret;
+ typedef void type;
+ };
+
+ template <typename T>
+ struct has_param_t<T, typename except_void_t<typename param_solver<T,void>::ret::param>::ret>
+ {
+ typedef metal::true_ ret;
+ typedef typename param_solver<T,void>::ret::param type;
+ };
+
+ template <typename T, typename V>
+ struct storage_solver;
+
+ template <typename T, typename V>
+ struct storage_flag_solver
+ {
+ typedef typename mln::fun::parameter<T> ret;
+ };
+
+ template <typename T>
+ struct storage_flag_solver<T, typename except_void_t<typename mln::fun::parameter<typename T::flag>::storage>::ret>
+ {
+ typedef mln::fun::parameter<typename T::flag> ret;
+ };
+
+ template <typename T, typename V>
+ struct storage_def_solver
+ {
+ typedef typename storage_flag_solver<T, V>::ret ret;
+ };
+
+ template <typename T>
+ struct storage_def_solver<T, typename except_void_t<typename mln::fun::parameter<typename T::def>::storage>::ret>
+ {
+ typedef mln::fun::parameter<typename T::def> ret;
+ };
+
+ template <typename T, typename V>
+ struct storage_solver : storage_def_solver<T, V>
+ {
+ };
+
+ template <typename T>
+ struct storage_solver<T, typename except_void_t<typename T::storage>::ret>
+ {
+ typedef T ret;
+ };
+
+ template <typename T, typename V>
+ struct has_storage_t
+ {
+ typedef has_param_t<T, V> has_param;
+
+ typedef metal::false_ ret;
+ typedef typename has_param::type type;
+
+ template <typename U>
+ static inline
+ const U& compute(const U& t)
+ {
+ return t;
+ }
+
+ };
+
+ template <typename T>
+ struct has_storage_t<T, typename except_void_t<typename param_solver<T,void>::ret::storage>::ret>
+ {
+ typedef metal::true_ ret;
+ typedef typename param_solver<T,void>::ret def;
+
+ typedef typename def::storage type;
+
+ template <typename U>
+ static inline
+ type compute(const U& p)
+ {
+ return def::compute(p);
+ };
+
+ };
+
+ } // end of namespace mln::trait::fun::internal::introspect
+
+ } // end of namespace mln::trait::fun::internal
+
+ template <typename F>
+ struct is_assignable
+ {
+ typedef typename internal::introspect::has_lvalue_t<F, void>::ret ret;
+ };
+
+ template <typename F>
+ struct is_parametrable
+ {
+ typedef typename internal::introspect::has_param_t<F, void>::ret ret;
+ };
+
+ template <typename F>
+ struct get_lvalue
+ {
+ typedef typename internal::introspect::has_lvalue_t<F, void>::type ret;
+ };
+
+ template <typename F>
+ struct get_param
+ {
+ typedef typename internal::introspect::has_param_t<F, void>::type ret;
+ };
+
+ template <typename F>
+ struct get_storage
+ {
+ typedef typename internal::introspect::has_storage_t<F, void>::type ret;
+ };
+
+ } // end of namespace mln::trait::fun
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif // ! MLN_TRAIT_FUN_HH
Index: trunk/milena/mln/trait/next/solve_unary.hh
===================================================================
--- trunk/milena/mln/trait/next/solve_unary.hh (revision 0)
+++ trunk/milena/mln/trait/next/solve_unary.hh (revision 3716)
@@ -0,0 +1,171 @@
+// Copyright (C) 2006, 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_TRAIT_NEXT_SOLVE_UNARY_HH
+# define MLN_TRAIT_NEXT_SOLVE_UNARY_HH
+
+/*!
+ * \file mln/trait/next/solve_unary.hh
+ *
+ * \brief FIXME
+ *
+ *
+ */
+
+# include <mln/core/category.hh>
+# include <mln/core/routine/exact.hh>
+# include <mln/metal/equal.hh>
+# include <mln/metal/if.hh>
+# include <mln/metal/ret.hh>
+# include <mln/trait/next/solve.hh>
+
+
+// FIXME: Just for the record (use it...)
+
+# ifndef MLN_DEBUG_TRAITS
+# endif // ! MLN_DEBUG_TRAITS
+
+
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ namespace internal
+ {
+
+
+ template < typename Name,
+ typename Category,
+ typename T >
+ struct trait_set_unary_;
+
+ template < typename Name,
+ template <class> class Category, typename _,
+ typename T >
+ struct trait_set_unary_< Name, Category<_>, T >
+ {
+ typedef typename mln::trait::next::set_unary_<Name, Category, T>::ret ret;
+ };
+
+
+ // Fwd decls.
+ template < typename Name,
+ typename Category, typename T >
+ struct get_unary_;
+
+
+ template < typename user_ret, /* != not_found and != undefined */
+ typename Name,
+ typename Category, typename T >
+ struct helper_get_unary_
+ {
+ typedef user_ret ret; // The user has defined 'ret' so we return it.
+ };
+
+
+ template < typename Name,
+ typename Category, typename T >
+ struct helper_get_unary_< /* user_ret == */ not_found,
+ Name, Category, T >
+ {
+ typedef not_found ret; // End of search due to a blocker; 'ret' is not found.
+ };
+
+
+ template < typename Name,
+ typename Category, typename T >
+ struct helper_get_unary_< /* user_ret == */ undefined,
+ Name, Category, T >
+ {
+ typedef typename mln::internal::super_category_< Category, T >::ret Super_Category;
+ typedef typename get_unary_<Name, Super_Category, T>::ret ret; // No user ret definition => Recursion.
+ };
+
+
+ template < typename Name,
+ typename Category, typename T >
+ struct get_unary_
+ {
+ typedef typename trait_set_unary_<Name, Category, T>::ret user_ret; // First get 'user_ret'
+ typedef helper_get_unary_<user_ret, Name, Category, T> helper; // Set the helper to make a decision.
+ typedef mlc_ret(helper) ret; // Return.
+ };
+
+
+ template < typename precise_ret,
+ typename Name,
+ typename Category, typename T >
+ struct helper_choose_unary_wrt_ /* precise_ret != undefined */
+ {
+ typedef precise_ret ret; // -> A precise ret has been defined so it is it.
+ };
+
+ template < typename Name,
+ typename Category, typename T >
+ struct helper_choose_unary_wrt_< /* precise_ret == */ undefined,
+ Name, Category, T >
+ {
+ typedef typename get_unary_<Name, Category, T>::ret ret; // -> Go up into the category inheritance
+ // to fetch a ret from 'set_unary_'s.
+ };
+
+ template < typename Name,
+ typename Category, typename T >
+ struct helper_solve_unary_
+ {
+ typedef typename set_precise_unary_<Name, T>::ret precise_ret;
+ typedef helper_choose_unary_wrt_< precise_ret, /* undefined or not (?) */
+ Name, Category, T> helper;
+ typedef mlc_ret(helper) ret;
+ };
+
+ } // end of namespace mln::trait::next::internal
+
+
+ template < typename Name,
+ typename T_ >
+ struct solve_unary
+ {
+ typedef mln_exact(T_) T;
+ typedef typename mln::category<T>::ret Category;
+ typedef internal::helper_solve_unary_< Name, Category, T > meta_code;
+ typedef typename meta_code::ret ret;
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+
+#endif // ! MLN_TRAIT_NEXT_SOLVE_UNARY_HH
Index: trunk/milena/mln/trait/next/solve.hh
===================================================================
--- trunk/milena/mln/trait/next/solve.hh (revision 0)
+++ trunk/milena/mln/trait/next/solve.hh (revision 3716)
@@ -0,0 +1,152 @@
+// Copyright (C) 2006, 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_TRAIT_NEXT_SOLVE_HH
+# define MLN_TRAIT_NEXT_SOLVE_HH
+
+/*!
+ * \file mln/trait/next/solve.hh
+ *
+ * \brief FIXME
+ *
+ *
+ */
+
+# include <mln/core/category.hh>
+# include <mln/metal/equal.hh>
+# include <mln/metal/if.hh>
+# include <mln/metal/ret.hh>
+# include <mln/trait/solve.hh>
+
+
+// FIXME: Just for the record (use it...)
+
+# ifndef MLN_DEBUG_TRAITS
+# endif // ! MLN_DEBUG_TRAITS
+
+
+# define mln_trait_nunary(Name, T) typename mln::trait::next::solve_unary< Name, T >::ret
+# define mln_trait_nunary_(Name, T) mln::trait::next::solve_unary< Name, T >::ret
+
+# define mln_trait_nbinary(Name, T1, T2) typename mln::trait::next::solve_binary< Name, T1, T2 >::ret
+# define mln_trait_nbinary_(Name, T1, T2) mln::trait::next::solve_binary< Name, T1, T2 >::ret
+
+
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ // Unary case.
+
+
+ template < typename Name,
+ typename T >
+ struct set_precise_unary_
+ {
+ typedef undefined ret;
+ };
+
+
+ template < typename Name,
+ template <class> class Category_T, typename T >
+ struct set_unary_
+ {
+ typedef undefined ret;
+ };
+
+ template < typename Name,
+ typename T >
+ struct set_unary_< Name, Unknown, T > // Blocker; top of inheritance.
+ {
+ typedef not_found ret;
+ };
+
+
+
+
+ // Binary case.
+
+
+ template < typename Name,
+ typename L,
+ typename R >
+ struct set_precise_binary_
+ {
+ typedef undefined ret;
+ };
+
+
+ template < typename Name,
+ template <class> class Category_L, typename L,
+ template <class> class Category_R, typename R >
+ struct set_binary_
+ {
+ typedef undefined ret;
+ };
+
+ template < typename Name,
+ typename L,
+ template <class> class Category_R, typename R >
+ struct set_binary_< Name, Unknown, L, Category_R, R > // Left blocker.
+ {
+ typedef not_found ret;
+ };
+
+ template < typename Name,
+ template <class> class Category_L, typename L,
+ typename R >
+ struct set_binary_< Name, Category_L, L, Unknown, R > // Right blocker.
+ {
+ typedef not_found ret;
+ };
+
+ template < typename Name,
+ typename L,
+ typename R >
+ struct set_binary_< Name, Unknown, L, Unknown, R > // Blocker.
+ {
+ typedef not_found ret;
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+
+# include <mln/trait/next/solve_unary.hh>
+# include <mln/trait/next/solve_binary.hh>
+# include <mln/trait/next/solve_proxy.hh>
+
+#endif // ! MLN_TRAIT_NEXT_SOLVE_HH
Index: trunk/milena/mln/trait/next/solve_proxy.hh
===================================================================
--- trunk/milena/mln/trait/next/solve_proxy.hh (revision 0)
+++ trunk/milena/mln/trait/next/solve_proxy.hh (revision 3716)
@@ -0,0 +1,95 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_CONCEPT_PROXY_HH
+# define MLN_CORE_CONCEPT_PROXY_HH
+
+/*! \file mln/core/concept/proxy.hh
+ *
+ * \brief Definition of the concept of mln::Proxy.
+ *
+ * \todo preinc and predec are not tested; post-like ops are not handled.
+ *
+ * \todo add "op=(T)" when possible, so add a constness property.
+ * \todo add "opT()const" when possible.
+ */
+
+# include <mln/core/concept/object.hh>
+# include <mln/core/concept/proxy.hh>
+# include <mln/core/concept/proxy.hxx>
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ // Unary ops.
+
+ template < typename Op, typename P >
+ struct set_unary_< Op, mln::Proxy, P >
+ {
+ typedef mlc_unqualif(mln_q_subject(P)) S;
+ typedef mln_trait_nunary(Op, S) ret;
+ };
+
+ // Binary ops.
+
+ template < typename Op, typename L, typename R >
+ struct set_binary_< Op, mln::Proxy, L, mln::Proxy, R >
+ {
+ typedef mln::internal::helper_unprox_binop<L, R> helper;
+ typedef mln_trait_nbinary(Op,
+ typename helper::L_ret,
+ typename helper::R_ret) ret;
+ };
+
+ template < typename Op, typename P, typename O >
+ struct set_binary_< Op, mln::Proxy, P, mln::Object, O >
+ {
+ typedef mlc_unqualif(mln_q_subject(P)) S;
+ typedef mln_trait_nbinary(Op, S, O) ret;
+ };
+
+ template < typename Op, typename O, typename P >
+ struct set_binary_< Op, mln::Object, O, mln::Proxy, P >
+ {
+ typedef mlc_unqualif(mln_q_subject(P)) S;
+ typedef mln_trait_nbinary(Op, O, S) ret;
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_CONCEPT_PROXY_HH
Index: trunk/milena/mln/trait/next/solve_binary.hh
===================================================================
--- trunk/milena/mln/trait/next/solve_binary.hh (revision 0)
+++ trunk/milena/mln/trait/next/solve_binary.hh (revision 3716)
@@ -0,0 +1,302 @@
+// Copyright (C) 2006, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+#ifndef MLN_TRAIT_NEXT_SOLVE_BINARY_HH
+# define MLN_TRAIT_NEXT_SOLVE_BINARY_HH
+
+/// \file mln/trait/next/solve_binary.hh
+///
+/// FIXME
+
+# include <mln/core/category.hh>
+# include <mln/core/routine/exact.hh>
+# include <mln/metal/equal.hh>
+# include <mln/metal/if.hh>
+# include <mln/metal/ret.hh>
+# include <mln/trait/next/solve.hh>
+
+
+// FIXME: Just for the record (use it...)
+
+# ifndef MLN_DEBUG_TRAITS
+# endif // ! MLN_DEBUG_TRAITS
+
+
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ namespace internal
+ {
+
+
+ template < typename Name,
+ typename Category_L, typename L,
+ typename Category_R, typename R >
+ struct trait_set_binary_;
+
+ template < typename Name,
+ template <class> class Category_L, typename _l, typename L,
+ template <class> class Category_R, typename _r, typename R >
+ struct trait_set_binary_< Name,
+ Category_L<_l>, L,
+ Category_R<_r>, R >
+ {
+ typedef typename mln::trait::next::set_binary_<Name,
+ Category_L, L,
+ Category_R, R>::ret ret;
+ };
+
+
+ // triplet_ret_
+
+ template < unsigned i_L_, unsigned i_R_, typename ret_ >
+ struct triplet_
+ {
+ typedef ret_ ret;
+ };
+
+
+ // merge_triplets_
+
+ template < typename L_trp, typename R_trp >
+ struct merge_triplets_;
+
+ template < unsigned L_i_L, unsigned L_i_R, typename L_ret,
+ unsigned R_i_L, unsigned R_i_R, typename R_ret >
+ struct merge_triplets_< triplet_<L_i_L, L_i_R, L_ret>,
+ triplet_<R_i_L, R_i_R, R_ret> >
+ {
+ typedef metal::bool_<(L_i_L <= R_i_L && L_i_R <= R_i_R)> take_L;
+ typedef metal::bool_<(R_i_L <= L_i_L && R_i_R <= L_i_R)> take_R;
+ typedef metal::or_<take_L, take_R> ok;
+ typedef typename metal::if_< metal::and_<ok, take_L>,
+ triplet_<L_i_L, L_i_R, L_ret>,
+ typename metal::if_< metal::and_<ok, take_R>,
+ triplet_<R_i_L, R_i_R, R_ret>,
+ triplet_<0,0, not_found> >::ret >::ret ret;
+ };
+
+ template < unsigned i_L, unsigned i_R, typename LR_ret >
+ struct merge_triplets_< triplet_<i_L, i_R, LR_ret>,
+ triplet_<i_L, i_R, LR_ret> >
+ {
+ typedef triplet_<i_L, i_R, LR_ret> ret;
+ };
+
+
+ template < unsigned L_i_L, unsigned L_i_R, unsigned L_i_max,
+ unsigned R_i_L, unsigned R_i_R, unsigned R_i_max >
+ // L_i_max and R_i_max differ
+ struct helper_merge_triplets_same_ret_
+ {
+ // The winning couple between L_* and R_* is the one which
+ // maximum index is the smallest; for instance, with:
+ // left branch giving L_i_L = 5 and L_i_R = 1 so L_i_max = 5
+ // right branch giving L_i_L = 3 and L_i_R = 4 so R_i_max = 4
+ // the right branch wins.
+ enum { i_L = (L_i_max < R_i_max ? L_i_L : R_i_L),
+ i_R = (L_i_max < R_i_max ? L_i_R : R_i_R) };
+ };
+
+ template < unsigned L_i_L, unsigned L_i_R, unsigned i_max,
+ unsigned R_i_L, unsigned R_i_R >
+ // L_i_max is equal to R_i_max
+ struct helper_merge_triplets_same_ret_< L_i_L, L_i_R, i_max,
+ R_i_L, R_i_R, i_max >
+ {
+ // The winning couple is the one with the minimum index.
+ enum { L_i_min = (L_i_L < L_i_R ? L_i_L : L_i_R),
+ R_i_min = (R_i_L < R_i_R ? R_i_L : R_i_R),
+ i_L = (L_i_min < R_i_min ? L_i_L : R_i_L),
+ i_R = (L_i_min < R_i_min ? L_i_R : R_i_R) };
+ };
+
+
+ template < unsigned L_i_L, unsigned L_i_R, typename LR_ret,
+ unsigned R_i_L, unsigned R_i_R >
+ struct merge_triplets_< triplet_<L_i_L, L_i_R, LR_ret>,
+ triplet_<R_i_L, R_i_R, LR_ret> >
+ {
+ typedef helper_merge_triplets_same_ret_< L_i_L, L_i_R, (L_i_L > L_i_R ? L_i_L : L_i_R),
+ R_i_L, R_i_R, (R_i_L > R_i_R ? R_i_L : R_i_R) > helper;
+ typedef triplet_<helper::i_L, helper::i_R, LR_ret> ret;
+ };
+
+ template < unsigned L_i_L, unsigned L_i_R, typename L_ret >
+ struct merge_triplets_< triplet_<L_i_L, L_i_R, L_ret>,
+ triplet_< 0, 0, not_found> >
+ {
+ typedef triplet_<L_i_L, L_i_R, L_ret> ret;
+ };
+
+ template < unsigned R_i_L, unsigned R_i_R, typename R_ret >
+ struct merge_triplets_< triplet_< 0, 0, not_found>,
+ triplet_<R_i_L, R_i_R, R_ret> >
+ {
+ typedef triplet_<R_i_L, R_i_R, R_ret> ret;
+ };
+
+ template <> // To disambiguate.
+ struct merge_triplets_< triplet_<0, 0, not_found>,
+ triplet_<0, 0, not_found> >
+ {
+ typedef triplet_<0u,0u, not_found> ret;
+ };
+
+
+
+ // Fwd decl.
+ template < typename Name,
+ unsigned i_L, typename Category_L, typename L,
+ unsigned i_R, typename Category_R, typename R >
+ struct get_binary_;
+
+
+ template < typename user_ret, /* != not_found and != undefined */
+ typename Name,
+ unsigned i_L, typename Category_L, typename L,
+ unsigned i_R, typename Category_R, typename R >
+ struct helper_get_binary_
+ {
+ typedef triplet_< i_L, i_R, user_ret > ret; // The user has defined 'ret' so we return it.
+ };
+
+ template < typename Name,
+ unsigned i_L, typename Category_L, typename L,
+ unsigned i_R, typename Category_R, typename R >
+ struct helper_get_binary_< /* user_ret == */ not_found,
+ Name, i_L, Category_L, L, i_R, Category_R, R >
+ {
+ typedef triplet_< 0, 0, not_found > ret; // End of search due to a blocker; 'ret' is not found.
+ };
+
+
+ template < typename Name,
+ unsigned i_L, typename Category_L, typename L,
+ unsigned i_R, typename Category_R, typename R >
+ struct helper_get_binary_< /* user_ret == */ undefined,
+ Name, i_L,Category_L, L, i_R,Category_R, R >
+ {
+ // No user definition for 'ret' so treillis construction in a static recursive way.
+
+ // FIXME: We *do* need to handle this search with a priority!
+ // FIXME: for a result can be found in both branches...
+
+ typedef typename mln::internal::super_category_< Category_L, L >::ret Super_Category_L;
+ typedef typename mln::internal::super_category_< Category_R, R >::ret Super_Category_R;
+
+ typedef get_binary_< Name,
+ i_L + 1, Super_Category_L, L,
+ i_R, Category_R, R > L_branch;
+ typedef mlc_ret(L_branch) L_trp;
+
+ typedef get_binary_< Name,
+ i_L, Category_L, L,
+ i_R + 1, Super_Category_R, R > R_branch;
+ typedef mlc_ret(R_branch) R_trp;
+
+ typedef typename merge_triplets_< L_trp, R_trp >::ret ret;
+ };
+
+
+ template < typename Name,
+ unsigned i_L, typename Category_L, typename L,
+ unsigned i_R, typename Category_R, typename R >
+ struct get_binary_
+ {
+ typedef typename trait_set_binary_<Name, Category_L,L,
+ Category_R,R>::ret user_ret; // First get 'user_ret'
+ typedef helper_get_binary_<user_ret, Name, i_L,Category_L,L,
+ i_R,Category_R,R> helper; // Set the helper to make a decision.
+ typedef mlc_ret(helper) ret; // Return a triplet.
+ };
+
+
+ template < typename precise_ret,
+ typename Name,
+ typename Category_L, typename L,
+ typename Category_R, typename R >
+ struct helper_choose_binary_wrt_ /* precise_ret != undefined */
+ {
+ typedef precise_ret ret; // -> A precise ret has been defined so it is it.
+ };
+
+ template < typename Name,
+ typename Category_L, typename L,
+ typename Category_R, typename R >
+ struct helper_choose_binary_wrt_< /* precise_ret == */ undefined,
+ Name, Category_L, L, Category_R, R >
+ {
+ typedef typename get_binary_< Name,
+ 0, Category_L, L,
+ 0, Category_R, R >::ret triplet; // Browse upwards the category inheritance
+ typedef mlc_ret(triplet) ret; // to fetch ret from 'get_binary_'s.
+ };
+
+
+ template < typename Name,
+ typename Category_L, typename L,
+ typename Category_R, typename R >
+ struct helper_solve_binary_
+ {
+ typedef typename set_precise_binary_<Name, L, R>::ret precise_ret; /* undefined or not (?) */
+ typedef helper_choose_binary_wrt_<precise_ret, Name, Category_L,L, Category_R,R> helper;
+ typedef mlc_ret(helper) ret;
+ };
+
+ } // end of namespace mln::trait::internal
+
+
+ // FIXME: Postfix solve_binary with a '-'(?)
+ template < typename Name,
+ typename L_,
+ typename R_ >
+ struct solve_binary
+ {
+ typedef mln_exact(L_) L;
+ typedef mln_exact(R_) R;
+ typedef typename mln::category<L>::ret Category_L;
+ typedef typename mln::category<R>::ret Category_R;
+ typedef internal::helper_solve_binary_< Name, Category_L, L, Category_R, R > meta_code;
+ typedef typename meta_code::ret ret;
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+
+#endif // ! MLN_TRAIT_NEXT_SOLVE_BINARY_HH
Index: trunk/milena/mln/core/image/thru_morpher.hh
===================================================================
--- trunk/milena/mln/core/image/thru_morpher.hh (revision 0)
+++ trunk/milena/mln/core/image/thru_morpher.hh (revision 3716)
@@ -0,0 +1,306 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_IMAGE_THRU_MORPHER_HH
+# define MLN_CORE_IMAGE_THRU_MORPHER_HH
+
+# include <mln/core/internal/image_value_morpher.hh>
+# include <mln/core/concept/meta_function.hh>
+# include <mln/metal/bexpr.hh>
+# include <mln/trait/fun.hh>
+
+///
+/// \file mln/core/image/thru_morpher.hh
+///
+/// \brief Definition of a morpher that morph image values through a function.
+///
+/// \todo Debug constness of thru_image
+
+namespace mln
+{
+
+ // Forward declaration.
+ template <typename I, typename F> struct thru_image;
+
+ namespace internal
+ {
+ template <typename I, typename F> struct thru_image_write;
+ template <typename I, typename F> struct thru_image_read;
+
+ /// Find correct implementation
+ template <typename I, typename F>
+ struct thru_find_impl
+ {
+ typedef thru_image_write<I, F> write;
+ typedef thru_image_read<I, F> read;
+ typedef mlc_if(mlc_and(typename trait::fun::is_assignable<F>::ret,
+ mlc_and(mlc_not(mlc_is_const(I)),
+ mlc_equal(mln_trait_image_pw_io(I),
+ trait::image::pw_io::read_write))),
+ write, read) ret;
+ };
+
+ /// Data structure for \c mln::thru_image<I>.
+ template <typename I, typename F>
+ struct data< thru_image<I, F> >
+ {
+ data(I& ima, const F& f);
+
+ I ima_;
+ F f_;
+ };
+
+ } // end of namespace mln::internal
+
+
+ namespace trait
+ {
+
+ template <typename I, typename F>
+ struct image_< thru_image<I, F> > : image_< typename mln::internal::thru_find_impl<I, F>::ret > // Same as I except...
+ {
+ // ...these changes.
+ typedef trait::image::category::value_morpher category;
+ typedef mln_internal_trait_image_speed_from(I) speed; // Un-fastest.
+ typedef trait::image::value_access::computed value_access;
+ };
+
+ template <typename I, typename F>
+ struct image_< mln::internal::thru_image_write<I, F> > : image_< I > // Same as I except...
+ {
+ typedef trait::image::vw_io::read_write vw_io;
+ };
+
+ template <typename I, typename F>
+ struct image_< mln::internal::thru_image_read<I, F> > : image_< I > // Same as I except...
+ {
+ typedef trait::image::vw_io::read vw_io;
+ };
+
+ } // end of namespace mln::trait
+
+
+
+ // FIXME: Doc!
+
+ namespace internal
+ {
+
+ template <typename I, typename F>
+ class thru_image_read : public internal::image_value_morpher< I, typename F::result, thru_image<I,F> >
+ {
+ public:
+
+ /// Skeleton.
+ typedef thru_image<tag::image_<I>, F> skeleton;
+
+ /// Point_Site associated type.
+ typedef mln_psite(I) psite;
+
+ /// Value associated type.
+ typedef typename F::result value;
+
+ /// Return type of read-only access.
+ typedef typename F::result rvalue;
+
+ rvalue operator()(const mln_psite(I)& p) const;
+
+ };
+
+ // Inheritance from read ?!
+ template <typename I, typename F>
+ class thru_image_write : public thru_image_read<I,F>
+ {
+ public:
+
+ /// Type returned by the read-write pixel value operator.
+// typedef typename F::template lresult<typename F::argument>::ret lvalue;
+ typedef typename F::lresult lvalue;
+
+ using thru_image_read<I,F>::operator();
+ lvalue operator()(const mln_psite(I)& p);
+
+ };
+ }
+
+ template <typename I, typename F>
+ class thru_image : public internal::thru_find_impl<I, F>::ret
+ {
+ public:
+
+ thru_image();
+ thru_image(I& ima);
+ thru_image(I& ima, const F& f);
+
+ void init_(I& ima, const F& f);
+
+ /// Const promotion via conversion.
+ operator thru_image<const I, F>() const;
+ };
+
+ template <typename I, typename F>
+ thru_image<I, F> thru(const mln::Function<F>& f,
+ Image<I>& ima);
+
+ template <typename I, typename F>
+ const thru_image<const I, F> thru(const mln::Function<F>& f,
+ const Image<I>& ima);
+
+ template <typename I, typename M>
+ thru_image<I, mln_fun_with(M, mln_value(I))>
+ thru(const mln::Meta_Function<M>& f, Image<I>& ima);
+
+ template <typename I, typename M>
+ const thru_image<const I, mln_fun_with(M, mln_value(I))>
+ thru(const mln::Meta_Function<M>& f, const Image<I>& ima);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // internal::data< thru_image<I,S> >
+
+ namespace internal
+ {
+
+ template <typename I, typename F>
+ inline
+ data< thru_image<I, F> >::data(I& ima, const F& f)
+ : ima_(ima),
+ f_(f)
+ {
+ }
+
+ } // end of namespace mln::internal
+
+ // thru_image<I>
+
+ template <typename I, typename F>
+ inline
+ thru_image<I, F>::thru_image()
+ {
+ }
+
+ template <typename I, typename F>
+ inline
+ thru_image<I, F>::thru_image(I& ima, const F& f)
+ {
+ mln_precondition(ima.is_valid());
+ init_(ima, f);
+ }
+
+ template <typename I, typename F>
+ inline
+ thru_image<I, F>::thru_image(I& ima)
+ {
+ mln_precondition(ima.is_valid());
+ init_(ima, mln_value(I)());
+ }
+
+ template <typename I, typename F>
+ inline
+ void
+ thru_image<I, F>::init_(I& ima, const F& f)
+ {
+ mln_precondition(! this->is_valid());
+ mln_precondition(ima.is_valid());
+ this->data_ = new internal::data< thru_image<I, F> >(ima, f);
+ }
+
+ template <typename I, typename F>
+ inline
+ thru_image<I, F>::operator thru_image<const I, F>() const
+ {
+ thru_image<const I, F> tmp(this->data_->ima_, this->data_->f_);
+ return tmp;
+ }
+
+ namespace internal
+ {
+
+ template <typename I, typename F>
+ inline
+ typename thru_image_read<I, F>::rvalue
+ thru_image_read<I, F>::operator()(const mln_psite(I)& p) const
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->f_(this->data_->ima_(p));
+ }
+
+ template <typename I, typename F>
+ inline
+ typename thru_image_write<I, F>::lvalue
+ thru_image_write<I, F>::operator()(const mln_psite(I)& p)
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->f_(this->data_->ima_(p));
+ }
+
+ }
+
+ // thru
+ template <typename I, typename F>
+ thru_image<I, F> thru(const mln::Function<F>& f,
+ Image<I>& ima)
+ {
+ thru_image<I, F> tmp(exact(ima), exact(f));
+ return tmp;
+ }
+
+ template <typename I, typename F>
+ thru_image<const I, F> thru(const mln::Function<F>& f,
+ const Image<I>& ima)
+ {
+ thru_image<const I, F> tmp(exact(ima), exact(f));
+ return tmp;
+ }
+
+ template <typename I, typename M>
+ thru_image<I, mln_fun_with(M, mln_value(I))>
+ thru(const mln::Meta_Function<M>& f, Image<I>& ima)
+ {
+ typedef mln_fun_with(M, mln_value(I)) F;
+ thru_image<I, F> tmp(exact(ima), F());
+
+ return tmp;
+ }
+
+ template <typename I, typename M>
+ thru_image<const I, mln_fun_with(M, mln_value(I))>
+ thru(const mln::Meta_Function<M>& f, const Image<I>& ima)
+ {
+ typedef mln_fun_with(M, mln_value(I)) F;
+ thru_image<const I, F> tmp(exact(ima), F());
+
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_IMAGE_THRU_MORPHER_HH
Index: trunk/milena/mln/core/image/thrubin_morpher.hh
===================================================================
--- trunk/milena/mln/core/image/thrubin_morpher.hh (revision 0)
+++ trunk/milena/mln/core/image/thrubin_morpher.hh (revision 3716)
@@ -0,0 +1,279 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_IMAGE_THRUBIN_MORPHER_HH
+# define MLN_CORE_IMAGE_THRUBIN_MORPHER_HH
+
+# include <mln/core/internal/image_value_morpher.hh>
+# include <mln/core/concept/meta_function.hh>
+# include <mln/metal/bexpr.hh>
+# include <mln/trait/fun.hh>
+
+///
+/// \file mln/core/image/thrubin_morpher.hh
+///
+/// \brief Definition of a morpher that morph values from two images through a binary function.
+///
+
+namespace mln
+{
+
+ // Forward declaration.
+ template <typename I, typename F> struct thrubin_image;
+
+ namespace internal
+ {
+ /// Data structure for \c mln::thrubin_image<I>.
+ template <typename I1, typename I2, typename F>
+ struct data< thrubin_image<I1, I2, F> >
+ {
+ data(I1& ima1, I2& ima2, const F& f);
+
+ I1 ima1_;
+ I2 ima2_;
+ F f_;
+ };
+
+ } // end of namespace mln::internal
+
+
+ namespace trait
+ {
+
+ template <typename I1, typename I2, typename F>
+ struct image_< thrubin_image<I1, I2, F> > : image_< typename mln::internal::thrubin_find_impl<I1, , F>::ret > // Same as I except...
+ {
+ // ...these changes.
+ typedef trait::image::category::value_morpher category;
+ typedef mln_internal_trait_image_speed_from(I) speed; // Un-fastest.
+ typedef trait::image::value_access::computed value_access;
+ typedef trait::image::vw_io::read vw_io;
+ };
+
+ } // end of namespace mln::trait
+
+
+
+ // FIXME: Doc!
+
+ namespace internal
+ {
+
+ template <typename I, typename F>
+ class thrubin_image_read : public internal::image_value_morpher< I, typename F::result, thrubin_image<I,F> >
+ {
+ public:
+
+ /// Skeleton.
+ typedef thrubin_image<tag::image_<I>, F> skeleton;
+
+ /// Point_Site associated type.
+ typedef mln_psite(I) psite;
+
+ /// Value associated type.
+ typedef typename F::result value;
+
+ /// Return type of read-only access.
+ typedef typename F::result rvalue;
+
+ rvalue operator()(const mln_psite(I)& p) const;
+
+ };
+
+ // Inheritance from read ?!
+ template <typename I, typename F>
+ class thrubin_image_write : public thrubin_image_read<I,F>
+ {
+ public:
+
+ /// Type returned by the read-write pixel value operator.
+// typedef typename F::template lresult<typename F::argument>::ret lvalue;
+ typedef typename F::lresult lvalue;
+
+ using thrubin_image_read<I,F>::operator();
+ lvalue operator()(const mln_psite(I)& p);
+
+ };
+ }
+
+ template <typename I, typename F>
+ class thrubin_image : public internal::thrubin_find_impl<I, F>::ret
+ {
+ public:
+
+ thrubin_image();
+ thrubin_image(I& ima);
+ thrubin_image(I& ima, const F& f);
+
+ void init_(I& ima, const F& f);
+
+ /// Const promotion via conversion.
+ operator thrubin_image<const I, F>() const;
+ };
+
+ template <typename I, typename F>
+ thrubin_image<I, F> thrubin(const mln::Function<F>& f,
+ Image<I>& ima);
+
+ template <typename I, typename F>
+ const thrubin_image<const I, F> thrubin(const mln::Function<F>& f,
+ const Image<I>& ima);
+
+ template <typename I, typename M>
+ thrubin_image<I, mln_fun_with(M, mln_value(I))>
+ thrubin(const mln::Meta_Function<M>& f, Image<I>& ima);
+
+ template <typename I, typename M>
+ const thrubin_image<const I, mln_fun_with(M, mln_value(I))>
+ thrubin(const mln::Meta_Function<M>& f, const Image<I>& ima);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // internal::data< thrubin_image<I,S> >
+
+ namespace internal
+ {
+
+ template <typename I, typename F>
+ inline
+ data< thrubin_image<I, F> >::data(I& ima, const F& f)
+ : ima_(ima),
+ f_(f)
+ {
+ }
+
+ } // end of namespace mln::internal
+
+ // thrubin_image<I>
+
+ template <typename I, typename F>
+ inline
+ thrubin_image<I, F>::thrubin_image()
+ {
+ }
+
+ template <typename I, typename F>
+ inline
+ thrubin_image<I, F>::thrubin_image(I& ima, const F& f)
+ {
+ mln_precondition(ima.is_valid());
+ init_(ima, f);
+ }
+
+ template <typename I, typename F>
+ inline
+ thrubin_image<I, F>::thrubin_image(I& ima)
+ {
+ mln_precondition(ima.is_valid());
+ init_(ima, mln_value(I)());
+ }
+
+ template <typename I, typename F>
+ inline
+ void
+ thrubin_image<I, F>::init_(I& ima, const F& f)
+ {
+ mln_precondition(! this->is_valid());
+ mln_precondition(ima.is_valid());
+ this->data_ = new internal::data< thrubin_image<I, F> >(ima, f);
+ }
+
+ template <typename I, typename F>
+ inline
+ thrubin_image<I, F>::operator thrubin_image<const I, F>() const
+ {
+ thrubin_image<const I, F> tmp(this->data_->ima_, this->data_->f_);
+ return tmp;
+ }
+
+ namespace internal
+ {
+
+ template <typename I, typename F>
+ inline
+ typename thrubin_image_read<I, F>::rvalue
+ thrubin_image_read<I, F>::operator()(const mln_psite(I)& p) const
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->f_(this->data_->ima_(p));
+ }
+
+ template <typename I, typename F>
+ inline
+ typename thrubin_image_write<I, F>::lvalue
+ thrubin_image_write<I, F>::operator()(const mln_psite(I)& p)
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->f_(this->data_->ima_(p));
+ }
+
+ }
+
+ // thrubin
+ template <typename I, typename F>
+ thrubin_image<I, F> thrubin(const mln::Function<F>& f,
+ Image<I>& ima)
+ {
+ thrubin_image<I, F> tmp(exact(ima), exact(f));
+ return tmp;
+ }
+
+ template <typename I, typename F>
+ thrubin_image<const I, F> thrubin(const mln::Function<F>& f,
+ const Image<I>& ima)
+ {
+ thrubin_image<const I, F> tmp(exact(ima), exact(f));
+ return tmp;
+ }
+
+ template <typename I, typename M>
+ thrubin_image<I, mln_fun_with(M, mln_value(I))>
+ thrubin(const mln::Meta_Function<M>& f, Image<I>& ima)
+ {
+ typedef mln_fun_with(M, mln_value(I)) F;
+ thrubin_image<I, F> tmp(exact(ima), F());
+
+ return tmp;
+ }
+
+ template <typename I, typename M>
+ thrubin_image<const I, mln_fun_with(M, mln_value(I))>
+ thrubin(const mln::Meta_Function<M>& f, const Image<I>& ima)
+ {
+ typedef mln_fun_with(M, mln_value(I)) F;
+ thrubin_image<const I, F> tmp(exact(ima), F());
+
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_IMAGE_THRUBIN_MORPHER_HH
Index: trunk/milena/mln/core/concept/meta_function.hh
===================================================================
--- trunk/milena/mln/core/concept/meta_function.hh (revision 0)
+++ trunk/milena/mln/core/concept/meta_function.hh (revision 3716)
@@ -0,0 +1,203 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// 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 F PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_CONCEPT_META_FUNCTION_HH
+# define MLN_CORE_CONCEPT_META_FUNCTION_HH
+
+/// \file mln/core/concept/meta_function.hh
+///
+/// Definition of the concept of mln::Meta_Function.
+
+# include <mln/core/concept/object.hh>
+# include <mln/core/concept/function.hh>
+
+
+# define mln_fun_with(F, T) \
+typename F::template with< T >::ret
+
+# define mln_fun_with_(F, T) \
+F::with< T >::ret
+
+
+# define mln_fun_result(F, T) \
+typename F::template with< T >::ret::result
+
+
+# define mln_fun_result_(F, T) \
+F::with< T >::ret::result
+
+
+
+namespace mln
+{
+
+ // Fwd decl.
+ template <typename E> struct Meta_Function;
+ template <typename E> struct Meta_Function_v2v;
+ template <typename E> struct Meta_Function_vv2v;
+
+ // Meta_Function category flag type.
+ template <>
+ struct Meta_Function<void>
+ {
+ typedef Object<void> super;
+ };
+
+
+ /*! \brief Base class for implementation of meta functions.
+ *
+ * The parameter \a E is the exact type.
+ *
+ * \see mln::doc::Meta_Function for a complete documentation of
+ * this class contents.
+ */
+ template <typename E>
+ struct Meta_Function : public Object<E>
+ {
+ typedef Meta_Function<void> category;
+ protected:
+ Meta_Function();
+ };
+
+ /*----------------------.
+ | Unary meta function. |
+ `----------------------*/
+
+ template <>
+ struct Meta_Function_v2v<void> { typedef Meta_Function<void> super; };
+
+ /// Base class for implementation of function-objects from
+ /// value to value.
+ ///
+ /// The parameter \a E is the exact type.
+ ///
+ template <typename E>
+ struct Meta_Function_v2v : public Meta_Function<E>
+ {
+ typedef Meta_Function_v2v<void> category;
+
+ protected:
+ Meta_Function_v2v();
+ Meta_Function_v2v(const Meta_Function_v2v&);
+ };
+
+ /*-----------------------.
+ | Binary meta function. |
+ `-----------------------*/
+
+ template <>
+ struct Meta_Function_vv2v<void> { typedef Meta_Function<void> super; };
+
+ /// Base class for implementation of function-objects from
+ /// value to value.
+ ///
+ /// The parameter \a E is the exact type.
+ ///
+ template <typename E>
+ struct Meta_Function_vv2v : public Meta_Function<E>
+ {
+ typedef Meta_Function_vv2v<void> category;
+
+ protected:
+ Meta_Function_vv2v();
+ Meta_Function_vv2v(const Meta_Function_vv2v&);
+ };
+
+ namespace fun
+ {
+
+ // To be specialized when some state (attributes) have to be transfered
+ // from the meta-function to the function.
+ // Warning: the first argument has to be an object with the exact type.
+ template <typename M, typename T>
+ mln_fun_with(M, T)
+ unmeta(const M&, T);
+
+ template <typename M, typename T>
+ void
+ unmeta(const Meta_Function<M>&, T); // Safety.
+
+ } // end of namespace mln::fun
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename E>
+ inline
+ Meta_Function<E>::Meta_Function()
+ {
+ // FIXME: Check "with" on E.
+ }
+
+ template <typename E>
+ inline
+ Meta_Function_v2v<E>::Meta_Function_v2v()
+ {
+ }
+
+ template <typename E>
+ inline
+ Meta_Function_v2v<E>::Meta_Function_v2v(const Meta_Function_v2v<E>& rhs)
+ : Meta_Function<E>(rhs)
+ {
+ }
+
+ template <typename E>
+ inline
+ Meta_Function_vv2v<E>::Meta_Function_vv2v()
+ {
+ }
+
+ template <typename E>
+ inline
+ Meta_Function_vv2v<E>::Meta_Function_vv2v(const Meta_Function_vv2v<E>& rhs)
+ : Meta_Function<E>(rhs)
+ {
+ }
+
+ namespace fun
+ {
+
+ template <typename M, typename T>
+ inline
+ mln_fun_with(M, T)
+ unmeta(const M&, T)
+ {
+ mlc_is_a(M, Meta_Function)::check();
+ mln_fun_with(M, T) a;
+ return a;
+ }
+
+ } // end of namespace mln::fun
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_CONCEPT_META_FUNCTION_HH
Index: trunk/milena/mln/accu/inf.hh
===================================================================
--- trunk/milena/mln/accu/inf.hh (revision 0)
+++ trunk/milena/mln/accu/inf.hh (revision 3716)
@@ -0,0 +1,166 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// 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_ACCU_INF_HH
+# define MLN_ACCU_INF_HH
+
+/// \file mln/accu/inf.hh
+///
+/// Define an accumulator that computes a inf.
+
+# include <mln/accu/internal/base.hh>
+# include <mln/core/concept/meta_accumulator.hh>
+# include <mln/trait/value_.hh>
+# include <mln/util/pix.hh>
+# include <mln/fun/math/inf.hh>
+
+namespace mln
+{
+
+ namespace accu
+ {
+
+
+ /// Generic inf accumulator class.
+ /*!
+ * The parameter \c T is the type of values.
+ */
+ template <typename T>
+ struct inf : public mln::accu::internal::base< const T&, inf<T> >
+ {
+ typedef T argument;
+
+ inf();
+
+ /// Manipulators.
+ /// \{
+ void init();
+ void take_as_init(const argument& t);
+ void take(const argument& t);
+ void take(const inf<T>& other);
+ /// \}
+
+ /// Get the value of the accumulator.
+ const T& to_result() const;
+
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
+ protected:
+
+ T t_;
+ mln::fun::inf::with<T, T>::ret fun_;
+ };
+
+
+ template <typename I> struct inf< util::pix<I> >;
+
+
+
+ namespace meta
+ {
+
+ /// Meta accumulator for inf.
+
+ struct inf : public Meta_Accumulator< inf >
+ {
+ template <typename T>
+ struct with
+ {
+ typedef accu::inf<T> ret;
+ };
+ };
+
+ } // end of namespace mln::accu::meta
+
+
+
+ # ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ inline
+ inf<T>::inf()
+ {
+ init();
+ }
+
+ template <typename T>
+ inline
+ void
+ inf<T>::init()
+ {
+ t_ = mln_max(T);
+ }
+
+ template <typename T>
+ inline
+ void inf<T>::take_as_init(const argument& t)
+ {
+ t_ = t;
+ }
+
+ template <typename T>
+ inline
+ void inf<T>::take(const argument& t)
+ {
+ this->t_ = this->fun_(t_, t);
+ }
+
+ template <typename T>
+ inline
+ void
+ inf<T>::take(const inf<T>& other)
+ {
+ this->t_ = this->fun_(t_, other.t_);
+ }
+
+ template <typename T>
+ inline
+ const T&
+ inf<T>::to_result() const
+ {
+ return t_;
+ }
+
+ template <typename T>
+ inline
+ bool
+ inf<T>::is_valid() const
+ {
+ return true;
+ }
+
+ # endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::accu
+
+} // end of namespace mln
+
+
+#endif // ! MLN_ACCU_INF_HH
Index: trunk/milena/mln/accu/sup.hh
===================================================================
--- trunk/milena/mln/accu/sup.hh (revision 0)
+++ trunk/milena/mln/accu/sup.hh (revision 3716)
@@ -0,0 +1,166 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// 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_ACCU_SUP_HH
+# define MLN_ACCU_SUP_HH
+
+/// \file mln/accu/sup.hh
+///
+/// Define an accumulator that computes a sup.
+
+# include <mln/accu/internal/base.hh>
+# include <mln/core/concept/meta_accumulator.hh>
+# include <mln/trait/value_.hh>
+# include <mln/util/pix.hh>
+# include <mln/fun/math/sup.hh>
+
+namespace mln
+{
+
+ namespace accu
+ {
+
+
+ /// Generic sup accumulator class.
+ /*!
+ * The parameter \c T is the type of values.
+ */
+ template <typename T>
+ struct sup : public mln::accu::internal::base< const T&, sup<T> >
+ {
+ typedef T argument;
+
+ sup();
+
+ /// Manipulators.
+ /// \{
+ void init();
+ void take_as_init(const argument& t);
+ void take(const argument& t);
+ void take(const sup<T>& other);
+ /// \}
+
+ /// Get the value of the accumulator.
+ const T& to_result() const;
+
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
+ protected:
+
+ T t_;
+ mln::fun::sup::with<T, T>::ret fun_;
+ };
+
+
+ template <typename I> struct sup< util::pix<I> >;
+
+
+
+ namespace meta
+ {
+
+ /// Meta accumulator for sup.
+
+ struct sup : public Meta_Accumulator< sup >
+ {
+ template <typename T>
+ struct with
+ {
+ typedef accu::sup<T> ret;
+ };
+ };
+
+ } // end of namespace mln::accu::meta
+
+
+
+ # ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ inline
+ sup<T>::sup()
+ {
+ init();
+ }
+
+ template <typename T>
+ inline
+ void
+ sup<T>::init()
+ {
+ t_ = mln_min(T);
+ }
+
+ template <typename T>
+ inline
+ void sup<T>::take_as_init(const argument& t)
+ {
+ t_ = t;
+ }
+
+ template <typename T>
+ inline
+ void sup<T>::take(const argument& t)
+ {
+ this->t_ = this->fun_(t_, t);
+ }
+
+ template <typename T>
+ inline
+ void
+ sup<T>::take(const sup<T>& other)
+ {
+ this->t_ = this->fun_(t_, other.t_);
+ }
+
+ template <typename T>
+ inline
+ const T&
+ sup<T>::to_result() const
+ {
+ return t_;
+ }
+
+ template <typename T>
+ inline
+ bool
+ sup<T>::is_valid() const
+ {
+ return true;
+ }
+
+ # endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::accu
+
+} // end of namespace mln
+
+
+#endif // ! MLN_ACCU_SUP_HH
Index: trunk/milena/mln/fun/binary.hh
===================================================================
--- trunk/milena/mln/fun/binary.hh (revision 0)
+++ trunk/milena/mln/fun/binary.hh (revision 3716)
@@ -0,0 +1,94 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// 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 F 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_FUN_BINARY_HH
+# define MLN_FUN_BINARY_HH
+
+# include <mln/core/concept/meta_function.hh>
+# include <mln/fun/spe/binary.hh>
+# include <mln/trait/next/solve.hh>
+# include <mln/trait/fun.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ template <typename F>
+ struct binary : mln::Meta_Function_vv2v< binary<F> >
+ {
+ typedef F flag;
+ typedef mln_trait_fun_storage(flag) storage;
+
+ template <typename T1, typename T2>
+ struct with
+ {
+ typedef spe::binary<F, T1, T2> ret;
+ };
+
+ template <typename T1, typename T2>
+ typename with<T1, T2>::ret::result operator()(const T1& a, const T2& b) const
+ {
+ return typename with<T1, T2>::ret(storage_)(a, b);
+ }
+
+ template <typename U>
+ void init(const U& value)
+ {
+ storage_ = mln::trait::fun::internal::introspect::has_storage_t<flag, void>::compute(value);
+ };
+
+ binary()
+ {
+ }
+
+ template <typename U>
+ binary(const U& param)
+ {
+ this->init(param);
+ }
+
+ stored<storage>& storage_get()
+ {
+ return storage_;
+ }
+
+ const stored<storage>& storage_get() const
+ {
+ return storage_;
+ }
+
+ protected:
+ stored<storage> storage_;
+ };
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+#endif /* ! MLN_FUN_BINARY_HH */
Index: trunk/milena/mln/fun/spe/binary.hh
===================================================================
--- trunk/milena/mln/fun/spe/binary.hh (revision 0)
+++ trunk/milena/mln/fun/spe/binary.hh (revision 3716)
@@ -0,0 +1,136 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// 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 F 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_FUN_SPE_BINARY_HH
+# define MLN_FUN_SPE_BINARY_HH
+
+# include <mln/core/concept/function.hh>
+# include <mln/trait/next/solve.hh>
+# include <mln/trait/fun.hh>
+
+/// \todo Implements parameter support
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace spe
+ {
+
+ // Forward declaration
+ template <typename Fun, typename T1, typename T2>
+ struct binary;
+
+ namespace impl
+ {
+
+ template <bool has_param, typename Fun, typename T1, typename T2>
+ struct binary_impl;
+
+ template <typename Fun, typename T1, typename T2>
+ struct binary_impl<false, Fun, T1, T2>
+ : mln::Function_v2v< binary<Fun, T1, T2> >
+ {
+ typedef Fun flag;
+ typedef mln_trait_nbinary(flag, T1, T2) def;
+
+ typedef typename def::argument1 argument1;
+ typedef typename def::argument2 argument2;
+ typedef typename def::result result;
+
+ result operator () (const argument1& a, const argument2& b) const
+ {
+ return def::read(a, b);
+ }
+
+
+ template <typename U>
+ void init(const U& value)
+ {
+ }
+
+ };
+
+ template <typename Fun, typename T1, typename T2>
+ struct binary_impl<true, Fun, T1, T2>
+ : mln::Function_v2v< binary<Fun, T1, T2> >
+ {
+ typedef Fun flag;
+ typedef mln_trait_nbinary(flag, T1, T2) def;
+
+ typedef typename def::argument1 argument1;
+ typedef typename def::argument2 argument2;
+ typedef typename def::result result;
+
+ typedef mln_trait_fun_param(def) param;
+ typedef mln_trait_fun_storage(def) storage;
+
+ result operator () (const argument1& a, const argument2& b) const
+ {
+ return def::read(storage_, a, b);
+ }
+
+ template <typename U>
+ void init(const U& value)
+ {
+ storage_ = mln::trait::fun::internal::introspect::has_storage_t<def, void>::compute(value);
+ }
+
+ protected:
+ mln::fun::stored<storage> storage_;
+ };
+
+ } // end of namespace mln::fun::spe::impl
+
+ template <typename Fun, typename T1, typename T2>
+ struct binary
+ : impl::binary_impl<mln_trait_fun_is_parametrable_(Fun)::value, Fun, T1, T2>
+ {
+ typedef impl::binary_impl<mln_trait_fun_is_parametrable_(Fun)::value, Fun, T1, T2> super;
+
+ binary()
+ {
+ }
+
+ template <typename U>
+ binary(const U& param)
+ {
+ this->super::init(param);
+ }
+
+ using super::operator();
+ };
+
+ } // end of namespace mln::fun::spe
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+#endif /* ! MLN_FUN_SPE_BINARY_HH */
Index: trunk/milena/mln/fun/spe/unary.hh
===================================================================
--- trunk/milena/mln/fun/spe/unary.hh (revision 0)
+++ trunk/milena/mln/fun/spe/unary.hh (revision 3716)
@@ -0,0 +1,302 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// 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 F 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_FUN_SPE_UNARY_HH
+# define MLN_FUN_SPE_UNARY_HH
+
+# include <mln/core/concept/function.hh>
+# include <mln/trait/next/solve.hh>
+# include <mln/trait/fun.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace spe
+ {
+
+ // Wrapper for bijective functions
+ template <typename Fun, typename T>
+ struct lwrapper
+ {
+ typedef typename Fun::result result;
+ typedef typename Fun::argument argument;
+ typedef typename Fun::lvalue lvalue;
+ typedef lwrapper lresult;
+
+ lwrapper(const Fun& f, T& x)
+ : x_(&x), f_(&f)
+ {
+ }
+
+ result to_result() const
+ {
+ return (*f_)(*const_cast<const T*>(x_));
+ };
+
+ operator result() const
+ {
+ return to_result();
+ };
+
+ const result& operator = (const result& r) const
+ {
+ argument x(*x_);
+ f_->set(x, r);
+ *x_ = x;
+
+ return r;
+ }
+
+ private:
+ T *x_;
+ const Fun *f_;
+ };
+
+ template <typename Fun>
+ struct lwrapper<Fun, typename Fun::argument>
+ {
+ typedef typename Fun::result result;
+ typedef typename Fun::argument argument;
+ typedef typename Fun::lvalue lvalue;
+ typedef lwrapper lresult;
+
+ lwrapper(const Fun& f, argument& x)
+ : x_(&x), f_(&f)
+ {
+ }
+
+ result to_result() const
+ {
+ return (*f_)(*const_cast<const argument*>(x_));
+ };
+
+ operator result() const
+ {
+ return to_result();
+ };
+
+ const result& operator = (const result& r) const
+ {
+ f_->set(*x_, r);
+
+ return r;
+ }
+
+ private:
+ argument *x_;
+ const Fun *f_;
+ };
+
+ template <typename Fun, typename Any, typename T>
+ struct lwrapper<Fun, lwrapper<Any, T> >
+ {
+ typedef typename Fun::result result;
+ typedef typename Fun::argument argument;
+ typedef typename Fun::lvalue lvalue;
+ typedef lwrapper lresult;
+
+ lwrapper(const Fun& f, const lwrapper<Any, T>& m)
+ : m_(m), f_(&f)
+ {
+ }
+
+ result to_result() const
+ {
+ return (*f_)(m_.to_result());
+ };
+
+ operator result() const
+ {
+ return to_result();
+ };
+
+ const result& operator = (const result& r) const
+ {
+ argument m(m_);
+ f_->set(m, r);
+ m_ = m;
+
+ return r;
+ }
+
+ private:
+ const lwrapper<Any, T> m_;
+ const Fun *f_;
+ };
+
+ template <typename Fun, typename T>
+ struct unary;
+
+ namespace impl
+ {
+
+ template <bool param, bool set, typename Fun, typename T>
+ struct unary_impl;
+
+ template <typename Fun, typename T>
+ struct unary_impl<false, false, Fun, T> : Function_v2v< unary<Fun, T> >
+ {
+ typedef Fun flag;
+ typedef mln_trait_nunary(Fun, T) def;
+
+ typedef typename def::argument argument;
+ typedef typename def::result result;
+
+ result operator () (const argument& value) const
+ {
+ return def::read(value);
+ }
+
+ template <typename U>
+ void init(const U& value)
+ {
+ };
+
+ };
+
+ template <typename Fun, typename T>
+ struct unary_impl<false, true, Fun, T> : unary_impl<false, false, Fun, T>
+ {
+ typedef unary_impl<false, false, Fun, T> super;
+ typedef typename super::def::lvalue lvalue;
+
+ template <typename U>
+ struct lresult_with
+ {
+ typedef mln::fun::spe::lwrapper< unary<Fun, T>, U> ret;
+ };
+
+ typedef typename lresult_with<typename super::argument>::ret lresult;
+
+ void set(lvalue l, const typename super::result& r) const
+ {
+ super::def::write(l, r);
+ }
+
+ using super::operator ();
+
+ lresult operator () (typename super::argument& value) const
+ {
+ return lresult(this, value);
+ }
+ };
+
+ template <typename Fun, typename T>
+ struct unary_impl<true, false, Fun, T> : Function_v2v< unary<Fun, T> >
+ {
+ typedef Fun flag;
+ typedef mln_trait_nunary(Fun, T) def;
+
+ typedef typename def::argument argument;
+ typedef typename def::result result;
+
+ typedef mln_trait_fun_param(unary_impl) param;
+ typedef mln_trait_fun_storage(unary_impl) storage;
+
+ result operator () (const argument& value) const
+ {
+ return def::read(this->storage_, value);
+ }
+
+ template <typename U>
+ void init(const U& value)
+ {
+ storage_ = mln::trait::fun::internal::introspect::has_storage_t<def, void>::compute(value);
+ };
+
+ protected:
+ storage storage_;
+ };
+
+ template <typename Fun, typename T>
+ struct unary_impl<true, true, Fun, T> : unary_impl<true, false, Fun, T>
+ {
+ typedef unary_impl<true, false, Fun, T> super;
+ typedef typename super::def::lvalue lvalue;
+
+ template <typename U>
+ struct lresult_with
+ {
+ typedef mln::fun::spe::lwrapper< unary<Fun, T>, U> ret;
+ };
+
+ typedef typename lresult_with<typename super::argument>::ret lresult;
+
+ void set(lvalue l, const typename super::result& r) const
+ {
+ super::def::write(this->storage_, l, r);
+ }
+
+ using super::operator ();
+
+ lresult operator () (typename super::argument& value) const
+ {
+ return lresult(exact(*this), value);
+ }
+ };
+
+ } // end of namespace mln::fun::spe::impl
+
+ template <typename Fun, typename T>
+ struct unary
+ : impl::unary_impl<mlc_or(mln_trait_fun_is_parametrable(mln_trait_nunary(Fun, T)), mln_trait_fun_is_parametrable(Fun))::value,
+ mln_trait_fun_is_assignable_(mln_trait_nunary(Fun, T))::value, Fun, T>
+ {
+ typedef mln_trait_nunary(Fun, T) def;
+ typedef impl::unary_impl<mlc_or(mln_trait_fun_is_parametrable(def), mln_trait_fun_is_parametrable(Fun))::value,
+ mln_trait_fun_is_assignable_(def)::value,
+ Fun,
+ T>
+ super;
+
+ unary() {}
+
+ template <typename U>
+ unary(const U& param)
+ {
+ this->init(param);
+ }
+
+ using super::operator();
+ };
+
+ } // end of namespace mln::fun::spe
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+template <typename F, typename T>
+std::ostream& operator << (std::ostream& o, const mln::fun::spe::lwrapper<F, T>& m)
+{
+ return o << m.to_result();
+}
+
+#endif /* ! UNARY_HH */
Index: trunk/milena/mln/fun/math/cos.hh
===================================================================
--- trunk/milena/mln/fun/math/cos.hh (revision 0)
+++ trunk/milena/mln/fun/math/cos.hh (revision 3716)
@@ -0,0 +1,91 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// 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 F 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_FUN_MATH_COS_HH
+# define MLN_FUN_MATH_COS_HH
+
+# include <mln/fun/unary.hh>
+# include <mln/value/builtin/floatings.hh>
+# include <mln/value/builtin/integers.hh>
+# include <mln/math/acos.hh>
+# include <mln/math/cos.hh>
+
+namespace mln
+{
+
+ // Cosinus, bijective
+ namespace fun
+ {
+ struct cos : unary<cos> {};
+ }
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <typename T>
+ struct set_unary_<mln::fun::cos, mln::value::Floating, T>
+ {
+ typedef set_unary_ ret;
+ typedef T result;
+ typedef T argument;
+ typedef T& lvalue;
+
+ static result read(const argument& x)
+ {
+ return math::cos(x);
+ }
+
+ static void write(lvalue l, const result& x)
+ {
+ l = math::acos(x);
+ }
+ };
+
+ template <typename T>
+ struct set_unary_<mln::fun::cos, mln::value::Integer, T>
+ {
+ typedef set_unary_ ret;
+ typedef double result;
+ typedef T argument;
+
+ static result read(const argument& x)
+ {
+ return math::cos((result)x);
+ }
+
+ };
+
+ }
+
+ }
+
+}
+
+#endif /* ! MLN_FUN_MATH_COS_HH */
\ No newline at end of file
Index: trunk/milena/mln/fun/math/abs.hh
===================================================================
--- trunk/milena/mln/fun/math/abs.hh (revision 0)
+++ trunk/milena/mln/fun/math/abs.hh (revision 3716)
@@ -0,0 +1,69 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// 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 F 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_FUN_MATH_ABS_HH
+# define MLN_FUN_MATH_ABS_HH
+
+# include <mln/fun/unary.hh>
+# include <mln/value/concept/scalar.hh>
+# include <mln/math/abs.hh>
+
+namespace mln
+{
+
+ // Absolute value, pure
+ namespace fun
+ {
+ struct abs : unary<abs> {};
+ }
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <typename T>
+ struct set_unary_<mln::fun::abs, mln::value::Scalar, T>
+ {
+ typedef set_unary_ ret;
+ typedef T result;
+ typedef T argument;
+
+ static result read(const argument& x)
+ {
+ return math::abs(x);
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif /* ! MLN_FUN_MATH_ABS_HH */
\ No newline at end of file
Index: trunk/milena/mln/fun/math/sup.hh
===================================================================
--- trunk/milena/mln/fun/math/sup.hh (revision 0)
+++ trunk/milena/mln/fun/math/sup.hh (revision 3716)
@@ -0,0 +1,69 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// 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 F 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_FUN_MATH_SUP_HH
+# define MLN_FUN_MATH_SUP_HH
+
+# include <mln/fun/binary.hh>
+# include <mln/math/max.hh>
+
+namespace mln
+{
+
+ // Cosinus, bijective
+ namespace fun
+ {
+ struct sup : binary<sup> {};
+ }
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <typename T>
+ struct set_binary_<mln::fun::sup, mln::Object, T, mln::Object, T>
+ {
+ typedef set_binary_ ret;
+ typedef T result;
+ typedef T argument1;
+ typedef T argument2;
+
+ static result read(const argument1& a, const argument1& b)
+ {
+ return math::max(a, b);
+ }
+ };
+
+ }
+
+ }
+
+}
+
+#endif /* ! MLN_FUN_MATH_SUP_HH */
\ No newline at end of file
Index: trunk/milena/mln/fun/math/norm.hh
===================================================================
--- trunk/milena/mln/fun/math/norm.hh (revision 0)
+++ trunk/milena/mln/fun/math/norm.hh (revision 3716)
@@ -0,0 +1,119 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// 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 F 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_FUN_MATH_NORM_HH
+# define MLN_FUN_MATH_NORM_HH
+
+# include <mln/fun/unary.hh>
+# include <mln/norm/all.hh>
+
+namespace mln
+{
+
+ // Common norm functions, reversible
+ namespace fun
+ {
+ namespace norm
+ {
+ struct l1 : unary<l1> {};
+
+ struct l2 : unary<l2> {};
+
+ struct linfty : unary<linfty> {};
+ }
+ }
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <unsigned n, typename T>
+ struct set_precise_unary_<mln::fun::norm::l1, mln::algebra::vec<n, T> >
+ {
+ typedef set_precise_unary_ ret;
+ typedef mln::algebra::vec<n, T> argument;
+ typedef argument& lvalue;
+ typedef mln_sum_product(argument,argument) result;
+
+ static result read(const argument& x)
+ {
+ return mln::norm::l1(x);
+ }
+
+ static void write(lvalue l, const result& x)
+ {
+ l = l / read(l) * x;
+ }
+ };
+
+ template <unsigned n, typename T>
+ struct set_precise_unary_<mln::fun::norm::l2, mln::algebra::vec<n, T> >
+ {
+ typedef set_precise_unary_ ret;
+ typedef mln::algebra::vec<n, T> argument;
+ typedef argument& lvalue;
+ typedef mln_sum_product(argument,argument) result;
+
+ static result read(const argument& x)
+ {
+ return mln::norm::l2(x);
+ }
+
+ static void write(lvalue l, const result& x)
+ {
+ l = l / read(l) * x;
+ }
+ };
+
+ template <unsigned n, typename T>
+ struct set_precise_unary_<mln::fun::norm::linfty, mln::algebra::vec<n, T> >
+ {
+ typedef set_precise_unary_ ret;
+ typedef mln::algebra::vec<n, T> argument;
+ typedef argument& lvalue;
+ typedef mln_sum_product(argument,argument) result;
+
+ static result read(const argument& x)
+ {
+ return mln::norm::linfty(x);
+ }
+
+ static void write(lvalue l, const result& x)
+ {
+ l = l / read(l) * x;
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif /* ! NORM_HH */
\ No newline at end of file
Index: trunk/milena/mln/fun/math/inf.hh
===================================================================
--- trunk/milena/mln/fun/math/inf.hh (revision 0)
+++ trunk/milena/mln/fun/math/inf.hh (revision 3716)
@@ -0,0 +1,69 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// 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 F 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_FUN_MATH_INF_HH
+# define MLN_FUN_MATH_INF_HH
+
+# include <mln/fun/binary.hh>
+# include <mln/math/min.hh>
+
+namespace mln
+{
+
+ // Cosinus, bijective
+ namespace fun
+ {
+ struct inf : binary<inf> {};
+ }
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <typename T>
+ struct set_binary_<mln::fun::inf, mln::Object, T, mln::Object, T>
+ {
+ typedef set_binary_ ret;
+ typedef T result;
+ typedef T argument1;
+ typedef T argument2;
+
+ static result read(const argument1& a, const argument1& b)
+ {
+ return math::min(a, b);
+ }
+ };
+
+ }
+
+ }
+
+}
+
+#endif /* ! MLN_FUN_MATH_INF_HH */
\ No newline at end of file
Index: trunk/milena/mln/fun/unary.hh
===================================================================
--- trunk/milena/mln/fun/unary.hh (revision 0)
+++ trunk/milena/mln/fun/unary.hh (revision 3716)
@@ -0,0 +1,169 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// 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 F 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_FUN_UNARY_HH
+# define MLN_FUN_UNARY_HH
+
+# include <mln/core/concept/meta_function.hh>
+# include <mln/fun/spe/unary.hh>
+# include <mln/trait/next/solve.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ // Forward declarations, for composition with unary::operator()(Fun)
+ struct compose;
+
+ namespace internal
+ {
+
+ template <typename U>
+ struct unary_with {};
+
+ }
+
+ template <typename F>
+ struct unary: mln::Meta_Function_v2v< F >
+ {
+ typedef F flag;
+ typedef mln_trait_fun_param(flag) param;
+ typedef mln_trait_fun_storage(flag) storage;
+
+ template <typename T>
+ struct with {
+ typedef mln_trait_nunary(internal::unary_with<F>, T) def;
+ typedef typename def::ret ret;
+ };
+
+ template <typename T>
+ typename with<T>::ret::result operator()(const T& v) const
+ {
+ return with<T>::def::call(exact(*this), v);
+ }
+
+ template <typename T>
+ typename with<T>::ret::template lresult_with<T>::ret operator()(T& v) const
+ {
+ return typename with<T>::ret(storage_get())(v);
+ }
+
+ template <typename T, typename R>
+ void set(T& v, const R& r) const
+ {
+ typename with<T>::ret(storage_).set(v, r);
+ }
+
+ template <typename U>
+ void init(const U& value)
+ {
+ storage_ = mln::trait::fun::internal::introspect::has_storage_t<flag, void>::compute(value);
+ };
+
+ unary()
+ {
+ }
+
+ template <typename U>
+ unary(const U& param)
+ {
+ this->init(param);
+ }
+
+ stored<storage>& storage_get()
+ {
+ return storage_;
+ }
+
+ const stored<storage>& storage_get() const
+ {
+ return storage_;
+ }
+
+ protected:
+ stored<storage> storage_;
+ };
+
+ } // end of namespace mln::fun
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ // Any type
+ template <typename F, typename T>
+ struct set_unary_< mln::fun::internal::unary_with<F>, mln::Object, T>
+ {
+ struct ret_t
+ {
+ typedef mln::fun::spe::unary<F, T> ret;
+
+ static typename ret::result call(const F& f, const T& v)
+ {
+ return ret(f.storage_get())(v);
+ }
+ };
+
+ typedef ret_t ret;
+ };
+
+ // Meta Function
+ template <typename F, typename G>
+ struct set_unary_< mln::fun::internal::unary_with<F>, mln::Meta_Function, G>
+ {
+ // FIXME: Workaround for cyclic references (unary -> unary_with -> compose -> unary)
+ template <typename T>
+ struct identity
+ {
+ typedef T ret;
+ };
+
+ struct ret_t
+ {
+ typedef typename identity<mln::fun::compose>::ret::template with<F, G>::ret ret;
+
+ static typename ret::result call(const F& f, const G& g)
+ {
+ return ret()(f, g);
+ }
+
+ };
+
+ typedef ret_t ret;
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif /* ! MLN_FUN_UNARY_HH */
Index: trunk/milena/mln/fun/from_accu.hh
===================================================================
--- trunk/milena/mln/fun/from_accu.hh (revision 0)
+++ trunk/milena/mln/fun/from_accu.hh (revision 3716)
@@ -0,0 +1,95 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// 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 F 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_FUN_FROM_ACCU_HH
+# define MLN_FUN_FROM_ACCU_HH
+
+# include <mln/fun/unary.hh>
+# include <mln/core/concept/accumulator.hh>
+# include <mln/math/acos.hh>
+# include <mln/math/cos.hh>
+
+namespace mln
+{
+
+ // from_accu: wrap an accumulator into a function
+ namespace fun
+ {
+ template <typename A>
+ struct from_accu : unary_param<from_accu<A>, A*>
+ {
+ from_accu() : unary_param<from_accu<A>, A*>() {};
+ from_accu(A* a) : unary_param<from_accu<A>, A*>(a) {};
+ };
+ }
+
+ namespace trait
+ {
+
+ namespace next
+ {
+ template <typename A, typename T>
+ struct set_unary_<mln::fun::from_accu<A>, mln::Object, T>
+ {
+ typedef set_unary_ ret;
+ typedef typename A::result result;
+ typedef typename A::argument argument;
+ typedef A* param;
+
+ set_unary_()
+ {
+ }
+
+ set_unary_(const param& accu)
+ : accu_(accu)
+ {
+ }
+
+ result read(const argument& x) const
+ {
+ mln_precondition(accu_ != 0);
+
+ accu_->take(x);
+ return accu_->to_result ();
+ }
+
+ void init(const param& accu)
+ {
+ accu_ = accu;
+ }
+
+ protected:
+ A* accu_;
+ };
+
+ }
+
+ }
+
+}
+
+#endif /* ! MLN_FUN_FROM_ACCU_HH */
\ No newline at end of file
Index: trunk/milena/mln/fun/param.hh
===================================================================
--- trunk/milena/mln/fun/param.hh (revision 0)
+++ trunk/milena/mln/fun/param.hh (revision 3716)
@@ -0,0 +1,88 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// 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 F 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_FUN_PARAM_HH
+# define MLN_FUN_PARAM_HH
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ template <typename T>
+ struct stored
+ {
+ typedef T value;
+
+ const T& to_value() const
+ {
+ return t_;
+ }
+
+ T& to_value()
+ {
+ return t_;
+ }
+
+ operator const T& () const
+ {
+ return to_value();
+ }
+
+ operator T& ()
+ {
+ return to_value();
+ }
+
+ stored& operator = (const T& t)
+ {
+ t_ = t;
+ return *this;
+ }
+
+ protected:
+ T t_;
+ };
+
+ template <>
+ struct stored<void>
+ {
+ };
+
+ template <typename F>
+ struct parameter
+ {
+ typedef void param;
+ typedef void storage;
+ };
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+#endif /* ! MLN_FUN_PARAM_HH */
Index: trunk/milena/mln/fun/composition.hh
===================================================================
--- trunk/milena/mln/fun/composition.hh (revision 0)
+++ trunk/milena/mln/fun/composition.hh (revision 3716)
@@ -0,0 +1,223 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// 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 F 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_FUN_COMPOSITION_HH
+# define MLN_FUN_COMPOSITION_HH
+
+# include <mln/fun/unary.hh>
+# include <mln/fun/binary.hh>
+# include <mln/fun/param.hh>
+
+namespace mln
+{
+ // Composition
+ namespace fun
+ {
+
+ namespace internal
+ {
+
+ // Compositions may take this has initialization parameter
+ template <typename F, typename G>
+ struct composition_param
+ {
+ composition_param(const F& f, const G& g) : f_(f), g_(g) {}
+ composition_param() {}
+
+ F f_;
+ G g_;
+ };
+
+ // Composition types...
+ template <template <class> class CatF, typename F,
+ template <class> class CatG, typename G>
+ struct composition;
+
+ } // end of namespace mln::fun::internal
+
+ template <template <class> class CatF, typename F,
+ template <class> class CatG, typename G>
+ struct parameter< internal::composition<CatF, F, CatG, G> >
+ {
+ typedef internal::composition_param<F, G> param;
+ };
+
+ namespace internal
+ {
+
+ // Meta
+ template <typename F, typename G>
+ struct composition<mln::Meta_Function_v2v, F, mln::Meta_Function_v2v, G>
+ : mln::fun::unary< composition<mln::Meta_Function_v2v, F, mln::Meta_Function_v2v, G> >
+ {
+ typedef mln::fun::unary< composition<mln::Meta_Function_v2v, F, mln::Meta_Function_v2v, G> > super;
+
+ composition() {};
+ composition(const composition_param<F, G>& p) : super(p) {};
+
+ typedef composition exact_type;
+ };
+
+ template <typename F, typename G>
+ struct composition<mln::Meta_Function_v2v, F, mln::Meta_Function_vv2v, G>
+ : mln::fun::binary< composition<mln::Meta_Function_v2v, F, mln::Meta_Function_vv2v, G> >
+ {
+ typedef mln::fun::binary< composition<mln::Meta_Function_v2v, F, mln::Meta_Function_vv2v, G> > super;
+
+ composition() {};
+ composition(const composition_param<F, G>& p) : super(p) {};
+
+ typedef composition exact_type;
+ };
+
+ // Concrete
+ template <typename F, typename G>
+ struct composition<mln::Meta_Function_v2v, F, mln::Function_v2v, G>
+ {
+ typedef mln::fun::spe::unary< composition<mln::Meta_Function_v2v, F, mln::Function_vv2v, G>, typename G::argument> exact_type;
+ };
+
+ template <typename F, typename G>
+ struct composition<mln::Meta_Function_v2v, F, mln::Function_vv2v, G>
+ {
+ typedef mln::fun::spe::binary< composition<mln::Meta_Function_v2v, F, mln::Function_vv2v, G>,
+ typename G::argument1, typename G::argument2> exact_type;
+ };
+
+ // Unary compositions implementation inherit from composition_unary_impl...
+ template <bool has_lvalue, typename F, typename F_spe, typename G, typename G_spe>
+ struct composition_unary_impl_helper;
+
+ template <typename F, typename F_spe, typename G, typename G_spe>
+ struct composition_unary_impl_helper<false, F, F_spe, G, G_spe>
+ {
+ typedef typename G_spe::argument argument;
+ typedef typename F_spe::result result;
+ typedef composition_param<F, G> param;
+
+ static result read(const param& p, const argument& x)
+ {
+ return p.f_(p.g_(x));
+ }
+ };
+
+ template <typename F, typename F_spe, typename G, typename G_spe>
+ struct composition_unary_impl_helper<true, F, F_spe, G, G_spe>
+ : composition_unary_impl_helper<false, F, F_spe, G, G_spe>
+ {
+ typedef composition_unary_impl_helper<false, F, F_spe, G, G_spe> super;
+ typedef typename G_spe::lvalue lvalue;
+
+ composition_unary_impl_helper() {}
+ composition_unary_impl_helper(const typename super::param& p) : super(p) {}
+
+ static void write(const typename super::param& p, lvalue l, const typename super::result& x)
+ {
+ typename G_spe::result r(p.g_(l));
+
+ p.f_.set(r, x);
+ p.g_.set(l, r);
+ }
+ };
+
+ template <typename F, typename F_spe, typename G, typename G_spe>
+ struct composition_unary_impl
+ : composition_unary_impl_helper<mln_trait_fun_is_assignable_(G_spe)::value, F, F_spe, G, G_spe>
+ {
+ typedef composition_unary_impl_helper<mln_trait_fun_is_assignable_(G_spe)::value, F, F_spe, G, G_spe> super;
+
+ composition_unary_impl() {}
+ composition_unary_impl(const typename super::param& p) : super(p) {}
+ };
+
+ template <typename F, typename F_spe, typename G, typename G_spe>
+ struct composition_binary_impl
+ {
+ typedef typename G_spe::argument1 argument1;
+ typedef typename G_spe::argument2 argument2;
+ typedef typename F_spe::result result;
+ typedef composition_param<F, G> param;
+
+ static result read(const param& p, const argument1& a, const argument2& b)
+ {
+ return p.f_(p.g_(a, b));
+ }
+ };
+
+ } // end of namespace mln::fun::internal
+
+ } // end of namespace mln::fun
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <typename F, typename G, typename T>
+ struct set_precise_unary_<mln::fun::internal::composition<mln::Meta_Function_v2v, F, mln::Meta_Function_v2v, G>, T>
+ {
+ typedef typename G::template with<T>::ret G_fun;
+ typedef typename F::template with<typename G_fun::result>::ret F_fun;
+
+ typedef mln::fun::internal::composition_unary_impl<F, F_fun, G, G_fun> ret;
+ };
+
+ template <typename F, typename G, typename T1, typename T2>
+ struct set_precise_binary_<mln::fun::internal::composition<mln::Meta_Function_v2v, F, mln::Meta_Function_vv2v, G>, T1, T2>
+ {
+ typedef typename G::template with<T1, T2>::ret G_fun;
+ typedef typename F::template with<typename G_fun::result>::ret F_fun;
+
+ typedef mln::fun::internal::composition_binary_impl<F, F_fun, G, G_fun> ret;
+ };
+
+ template <typename F, typename G>
+ struct set_precise_unary_<mln::fun::internal::composition<mln::Meta_Function_v2v, F, mln::Function_v2v, G>,
+ typename G::argument>
+ {
+ typedef typename F::template with<typename G::result>::ret F_fun;
+
+ typedef mln::fun::internal::composition_unary_impl<F, F_fun, G, G> ret;
+ };
+
+ template <typename F, typename G>
+ struct set_precise_binary_<mln::fun::internal::composition<mln::Meta_Function_v2v, F, mln::Meta_Function_vv2v, G>,
+ typename G::argument1, typename G::argument2>
+ {
+ typedef typename F::template with<typename G::result>::ret F_fun;
+
+ typedef mln::fun::internal::composition_binary_impl<F, F_fun, G, G> ret;
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif /* ! MLN_FUN_COMPOSITION_HH */
Index: trunk/milena/mln/fun/component/blue.hh
===================================================================
--- trunk/milena/mln/fun/component/blue.hh (revision 0)
+++ trunk/milena/mln/fun/component/blue.hh (revision 3716)
@@ -0,0 +1,84 @@
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can blueistribute 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 coveblue by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be coveblue by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_COMPONENT_BLUE_HH
+# define MLN_FUN_COMPONENT_BLUE_HH
+
+/// \file mln/fun/component/blue.hh
+///
+/// Meta function to retrieve/modify the blue component.
+
+# include <mln/fun/unary.hh>
+# include <mln/value/rgb.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ struct blue : unary<blue> {};
+
+ } // end of namespace mln::fun
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <unsigned n>
+ struct set_precise_unary_<mln::fun::blue, mln::value::rgb<n> >
+ {
+ typedef set_precise_unary_ ret;
+ typedef mln::value::rgb<n> argument;
+ typedef typename argument::blue_t result;
+ typedef argument& lvalue;
+
+ static result read(const argument& x)
+ {
+ return x.blue();
+ }
+
+ static void write(lvalue l, const result& r)
+ {
+ l.blue() = r;
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // MLN_FUN_COMPONENT_BLUE_HH
Index: trunk/milena/mln/fun/component/red.hh
===================================================================
--- trunk/milena/mln/fun/component/red.hh (revision 0)
+++ trunk/milena/mln/fun/component/red.hh (revision 3716)
@@ -0,0 +1,84 @@
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
+//
+// 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_FUN_COMPONENT_RED_HH
+# define MLN_FUN_COMPONENT_RED_HH
+
+/// \file mln/fun/component/red.hh
+///
+/// Meta function to retrieve/modify the red component.
+
+# include <mln/fun/unary.hh>
+# include <mln/value/rgb.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ struct red : unary<red> {};
+
+ } // end of namespace mln::fun
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <unsigned n>
+ struct set_precise_unary_<mln::fun::red, mln::value::rgb<n> >
+ {
+ typedef set_precise_unary_ ret;
+ typedef mln::value::rgb<n> argument;
+ typedef typename argument::red_t result;
+ typedef argument& lvalue;
+
+ static result read(const argument& x)
+ {
+ return x.red();
+ }
+
+ static void write(lvalue l, const result& r)
+ {
+ l.red() = r;
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // MLN_FUN_COMPONENT_RED_HH
Index: trunk/milena/mln/fun/component/rgb.hh
===================================================================
--- trunk/milena/mln/fun/component/rgb.hh (revision 0)
+++ trunk/milena/mln/fun/component/rgb.hh (revision 3716)
@@ -0,0 +1,40 @@
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
+//
+// 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_FUN_COMPONENT_RGB_HH
+# define MLN_FUN_COMPONENT_RGB_HH
+
+/// \file mln/fun/component/red.hh
+///
+/// Meta functions to retrieve/modify rgb components.
+
+# include <mln/fun/component/red.hh>
+# include <mln/fun/component/green.hh>
+# include <mln/fun/component/blue.hh>
+
+#endif // MLN_FUN_COMPONENT_RGB_HH
Index: trunk/milena/mln/fun/component/comp.hh
===================================================================
--- trunk/milena/mln/fun/component/comp.hh (revision 0)
+++ trunk/milena/mln/fun/component/comp.hh (revision 3716)
@@ -0,0 +1,174 @@
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
+//
+// 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_FUN_COMPONENT_COMP_HH
+# define MLN_FUN_COMPONENT_COMP_HH
+
+/// \file mln/fun/component/comp.hh
+///
+/// Meta function to retrieve/modify a component.
+
+# include <mln/fun/unary.hh>
+# include <mln/fun/binary.hh>
+# include <mln/fun/param.hh>
+# include <mln/trait/next/solve.hh>
+# include <mln/value/rgb.hh>
+# include <mln/value/int_u.hh>
+# include <mln/algebra/vec.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ struct comp : binary<comp> {};
+
+ struct pcomp;
+
+ template <>
+ struct parameter<pcomp>
+ {
+ typedef unsigned param;
+ };
+
+ struct pcomp : unary<pcomp>
+ {
+ pcomp() : unary<pcomp>(0) {};
+ pcomp(unsigned i = 0) : unary<pcomp>(i) {};
+ };
+
+ struct comp_count : unary<comp_count> {};
+
+ } // end of namespace mln::fun
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <typename E, typename T>
+ struct set_binary_<mln::fun::comp, mln::value::Integer, E, mln::Object, T>
+ {
+ typedef set_binary_ ret;
+ typedef E argument1;
+ typedef T argument2;
+ typedef mln_trait_nunary(mln::fun::pcomp, T) pcomp_t;
+ typedef mln_result(pcomp_t) result;
+
+ static result read(const argument1& i, const argument2& v)
+ {
+ pcomp_t c;
+ return c.read(i, v);
+ }
+ };
+
+ template <unsigned n>
+ struct set_precise_unary_<mln::fun::comp_count, mln::value::rgb<n> >
+ {
+ typedef set_precise_unary_ ret;
+
+ typedef mln::value::rgb<n> argument;
+ typedef unsigned result;
+ typedef argument& lvalue;
+
+ static result read(const argument&)
+ {
+ return n;
+ }
+ };
+
+ template <unsigned n, typename T>
+ struct set_precise_unary_<mln::fun::comp_count, mln::algebra::vec<n,T> >
+ {
+ typedef set_precise_unary_ ret;
+
+ typedef mln::algebra::vec<n,T> argument;
+ typedef unsigned result;
+ typedef argument& lvalue;
+
+ static result read(const argument&)
+ {
+ return n;
+ }
+ };
+
+ template <unsigned n>
+ struct set_precise_unary_<mln::fun::pcomp, mln::value::rgb<n> >
+ {
+ typedef set_precise_unary_ ret;
+// typedef mln::fun::pcomp flag;
+
+ typedef mln::value::rgb<n> argument;
+ typedef mln::value::int_u<n> result;
+ typedef argument& lvalue;
+
+ static result read(unsigned p_i, const argument& v)
+ {
+ return v.comp(p_i);
+ }
+
+ static void write(unsigned p_i, lvalue l, const result& x)
+ {
+ l.comp(p_i) = x;
+ }
+ };
+
+ template <unsigned n, typename T>
+ struct set_precise_unary_<mln::fun::pcomp, mln::algebra::vec<n,T> >
+ {
+ typedef set_precise_unary_ ret;
+ typedef mln::fun::pcomp flag;
+
+ typedef mln::algebra::vec<n,T> argument;
+ typedef T result;
+ typedef argument& lvalue;
+
+ static result read(unsigned p_i, const argument& v)
+ {
+ return v[p_i];
+ }
+
+ static void write(unsigned p_i, lvalue l, const result& x)
+ {
+ l[p_i] = x;
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // MLN_FUN_COMPONENT_COMP_HH
Index: trunk/milena/mln/fun/component/green.hh
===================================================================
--- trunk/milena/mln/fun/component/green.hh (revision 0)
+++ trunk/milena/mln/fun/component/green.hh (revision 3716)
@@ -0,0 +1,84 @@
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can greenistribute 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 covegreen by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covegreen by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_COMPONENT_GREEN_HH
+# define MLN_FUN_COMPONENT_GREEN_HH
+
+/// \file mln/fun/component/green.hh
+///
+/// Meta function to retrieve/modify the green component.
+
+# include <mln/fun/unary.hh>
+# include <mln/value/rgb.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ struct green : unary<green> {};
+
+ } // end of namespace mln::fun
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <unsigned n>
+ struct set_precise_unary_<mln::fun::green, mln::value::rgb<n> >
+ {
+ typedef set_precise_unary_ ret;
+ typedef mln::value::rgb<n> argument;
+ typedef typename argument::green_t result;
+ typedef argument& lvalue;
+
+ static result read(const argument& x)
+ {
+ return x.green();
+ }
+
+ static void write(lvalue l, const result& r)
+ {
+ l.green() = r;
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // MLN_FUN_COMPONENT_GREEN_HH
Index: trunk/milena/mln/fun/compose.hh
===================================================================
--- trunk/milena/mln/fun/compose.hh (revision 0)
+++ trunk/milena/mln/fun/compose.hh (revision 3716)
@@ -0,0 +1,117 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// 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 F 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_FUN_COMPOSE_HH
+# define MLN_FUN_COMPOSE_HH
+
+# include <mln/fun/binary.hh>
+# include <mln/fun/composition.hh>
+# include <mln/fun/param.hh>
+
+namespace mln
+{
+ // Composition
+ namespace fun
+ {
+ struct compose : binary<compose> {};
+
+ namespace internal
+ {
+
+ template <template <class> class CatF, typename F, template <class> class CatG, typename G>
+ struct compose_helper;
+
+ }
+
+ template <template <class> class CatF, typename F,
+ template <class> class CatG, typename G>
+ struct parameter< internal::compose_helper<CatF, F, CatG, G> >
+ {
+ typedef typename internal::composition<CatF, F, CatG, G>::exact_type result;
+ typedef typename result::param param;
+ };
+
+ namespace internal
+ {
+
+ template <template <class> class CatF, typename F, template <class> class CatG, typename G>
+ struct compose_helper
+ {
+ typedef F argument1;
+ typedef G argument2;
+
+ typedef typename composition<CatF, F, CatG, G>::exact_type result;
+ typedef mln_trait_fun_param(result) param;
+
+ static result read(const F& f, const G& g)
+ {
+ return result(param(f, g));
+ }
+ };
+
+ } // end of namespace mln::fun::internal
+
+ } // end of namespace mln::fun
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ // All kinds of supported compositions (meta : unary) with (meta or not : unary or binary)
+ template <typename F, typename G>
+ struct set_binary_< mln::fun::compose, mln::Meta_Function_v2v, F, mln::Meta_Function_v2v, G>
+ {
+ typedef mln::fun::internal::compose_helper<mln::Meta_Function_v2v, F, mln::Meta_Function_v2v, G> ret;
+ };
+
+ template <typename F, typename G>
+ struct set_binary_< mln::fun::compose, mln::Meta_Function_v2v, F, mln::Meta_Function_vv2v, G>
+ {
+ typedef mln::fun::internal::compose_helper<mln::Meta_Function_v2v, F, mln::Meta_Function_vv2v, G> ret;
+ };
+
+ template <typename F, typename G>
+ struct set_binary_< mln::fun::compose, mln::Meta_Function_v2v, F, mln::Function_v2v, G>
+ {
+ typedef mln::fun::internal::compose_helper<mln::Meta_Function_v2v, F, mln::Function_v2v, G> ret;
+ };
+
+ template <typename F, typename G>
+ struct set_binary_< mln::fun::compose, mln::Meta_Function_v2v, F, mln::Function_vv2v, G>
+ {
+ typedef mln::fun::internal::compose_helper<mln::Meta_Function_v2v, F, mln::Function_vv2v, G> ret;
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif /* ! MLN_FUN_COMPOSE_HH */
Index: trunk/milena/mln/fun/accu_result.hh
===================================================================
--- trunk/milena/mln/fun/accu_result.hh (revision 0)
+++ trunk/milena/mln/fun/accu_result.hh (revision 3716)
@@ -0,0 +1,69 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// 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 F 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_FUN_ACCU_RESULT_HH
+# define MLN_FUN_ACCU_RESULT_HH
+
+# include <mln/fun/unary.hh>
+# include <mln/core/concept/accumulator.hh>
+# include <mln/math/acos.hh>
+# include <mln/math/cos.hh>
+
+namespace mln
+{
+
+ // accu_result: return result of given accumulator.
+ namespace fun
+ {
+ struct accu_result : unary<accu_result> {};
+ }
+
+ namespace trait
+ {
+
+ namespace next
+ {
+ template <typename E>
+ struct set_unary_<mln::fun::accu_result, mln::Accumulator, E>
+ {
+ typedef set_unary_ ret;
+ typedef typename E::result result;
+ typedef mln::Accumulator<E> argument;
+
+ static result read(const argument& x)
+ {
+ return exact(x).to_result();
+ }
+ };
+
+ }
+
+ }
+
+}
+
+#endif /* ! MLN_FUN_ACCU_RESULT_HH */
\ No newline at end of file
Index: trunk/milena/sandbox/fred/mln/trait/fun.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/trait/next/solve_unary.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/trait/next/solve.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/trait/next/solve_proxy.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/trait/next/solve_binary.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/core/image/thrubin_morpher.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/core/image/thru_morpher.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/core/concept/meta_function.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/composition.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/binary.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/compose.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/accu_result.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/from_accu.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/unary.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/param.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/component/blue.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/component/red.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/component/rgb.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/component/comp.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/component/green.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/spe/binary.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/spe/unary.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/math/cos.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/math/abs.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/math/sup.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/math/norm.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/math/inf.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/accu/sup.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/accu/inf.hh (deleted)
===================================================================
1
0
27 Apr '09
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-04-27 Frederic Bour <bour(a)lrde.epita.fr>
Add functions working on components, add proxy support for new.
* fred/mln/core/image/thrubin_morpher.hh: New.
* fred/mln/fun/component/blue.hh: New.
* fred/mln/fun/component/comp.hh: New.
* fred/mln/fun/component/green.hh: New.
* fred/mln/fun/component/red.hh: New.
* fred/mln/fun/component/rgb.hh: New.
* fred/mln/fun/component: New.
* fred/mln/fun/spe/unary.hh: Debug parameter handling.
* fred/mln/trait/fun.hh: Debug parameter handling.
* fred/mln/trait/next/solve.hh: Add proxy support.
* fred/mln/trait/next/solve_proxy.hh: New.
* fred/tests/cos.cc: Add/remove tests.
* fred/tests/fun.cc: Add/remove tests.
---
mln/core/image/thrubin_morpher.hh | 279 ++++++++++++++++++++++++++++++++++++++
mln/fun/component/blue.hh | 84 +++++++++++
mln/fun/component/comp.hh | 174 +++++++++++++++++++++++
mln/fun/component/green.hh | 84 +++++++++++
mln/fun/component/red.hh | 84 +++++++++++
mln/fun/component/rgb.hh | 40 +++++
mln/fun/spe/unary.hh | 8 -
mln/trait/fun.hh | 49 +++++-
mln/trait/next/solve.hh | 2
mln/trait/next/solve_proxy.hh | 95 ++++++++++++
tests/cos.cc | 1
tests/fun.cc | 33 ++--
12 files changed, 910 insertions(+), 23 deletions(-)
Index: trunk/milena/sandbox/fred/tests/cos.cc
===================================================================
--- trunk/milena/sandbox/fred/tests/cos.cc (revision 3714)
+++ trunk/milena/sandbox/fred/tests/cos.cc (revision 3715)
@@ -11,6 +11,7 @@
mln::fun::compose compose;
double x;
+
dbg_print(cos(compose)(cos,cos)(x) = 0.857553);
dbg_print(x);
dbg_print(cos(compose)(cos,cos)(0.));
Index: trunk/milena/sandbox/fred/tests/fun.cc
===================================================================
--- trunk/milena/sandbox/fred/tests/fun.cc (revision 3714)
+++ trunk/milena/sandbox/fred/tests/fun.cc (revision 3715)
@@ -3,8 +3,9 @@
#include <mln/fun/math/cos.hh>
#include <mln/fun/math/norm.hh>
// #include <mln/fun/math/inc.hh>
-// #include <mln/fun/math/red.hh>
-
+#include <mln/fun/component/red.hh>
+#include <mln/fun/component/comp.hh>
+#include <mln/value/rgb8.hh>
#include <iostream>
#define dbg_print(val) std::cout << #val << "\n\t -> \t" << (val) << std::endl
@@ -13,7 +14,9 @@
mln::fun::abs abs;
mln::fun::cos cos;
// mln::fun::inc inc;
-// mln::fun::red red;
+ mln::fun::red red;
+ mln::fun::comp comp;
+ mln::fun::pcomp comp1(1);
mln::fun::norm::l1 l1;
mln::fun::norm::l2 l2;
@@ -41,9 +44,9 @@
dbg_print(cos(0.));
dbg_print(cos(mln::math::acos(0.5)));
-// // RED
-// mln_invariant(red(mln::value::rgb8(8,13,21)) == 8);
-// dbg_print(red(mln::value::rgb8(8,13,21)));
+ // RED
+ mln_invariant(red(mln::value::rgb8(8,13,21)) == 8);
+ dbg_print(red(mln::value::rgb8(8,13,21)));
// NORM
mln::algebra::vec<3, double> v;
@@ -77,13 +80,17 @@
}
// RED
-// {
-// mln::value::rgb8 rgb(8,13,21);
-// dbg_print(rgb);
-// dbg_print(red(rgb) = 0);
-// // FIXME: Doesn't compile! mln_invariant(red(rgb) == 0);
-// dbg_print(rgb);
-// }
+ {
+ mln::value::rgb8 rgb(8,13,21);
+ dbg_print(rgb);
+ dbg_print(red(rgb) = 0);
+ mln_invariant(red(rgb) == 0);
+ dbg_print(rgb);
+ dbg_print(comp(0, rgb));
+ dbg_print(comp(1, rgb));
+ dbg_print(comp(2, rgb));
+ comp1(rgb) = 2;
+ }
// NORM
{
Index: trunk/milena/sandbox/fred/mln/trait/fun.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/trait/fun.hh (revision 3714)
+++ trunk/milena/sandbox/fred/mln/trait/fun.hh (revision 3715)
@@ -96,20 +96,21 @@
};
template <typename T>
- struct param_flag_solver<T, typename except_void_t<typename T::flag>::ret>
+ struct param_flag_solver<T, typename except_void_t<typename mln::fun::parameter<typename T::flag>::param>::ret>
{
- typedef typename param_solver<typename T::flag, void>::ret ret;
+ typedef mln::fun::parameter<typename T::flag> ret;
};
template <typename T, typename V>
- struct param_def_solver : param_flag_solver<T, V>
+ struct param_def_solver
{
+ typedef typename param_flag_solver<T, V>::ret ret;
};
template <typename T>
- struct param_def_solver<T, typename except_void_t<typename T::def>::ret>
+ struct param_def_solver<T, typename except_void_t<typename mln::fun::parameter<typename T::def>::param>::ret>
{
- typedef typename param_solver<typename T::def, void>::ret ret;
+ typedef mln::fun::parameter<typename T::def> ret;
};
template <typename T, typename V>
@@ -138,6 +139,44 @@
};
template <typename T, typename V>
+ struct storage_solver;
+
+ template <typename T, typename V>
+ struct storage_flag_solver
+ {
+ typedef typename mln::fun::parameter<T> ret;
+ };
+
+ template <typename T>
+ struct storage_flag_solver<T, typename except_void_t<typename mln::fun::parameter<typename T::flag>::storage>::ret>
+ {
+ typedef mln::fun::parameter<typename T::flag> ret;
+ };
+
+ template <typename T, typename V>
+ struct storage_def_solver
+ {
+ typedef typename storage_flag_solver<T, V>::ret ret;
+ };
+
+ template <typename T>
+ struct storage_def_solver<T, typename except_void_t<typename mln::fun::parameter<typename T::def>::storage>::ret>
+ {
+ typedef mln::fun::parameter<typename T::def> ret;
+ };
+
+ template <typename T, typename V>
+ struct storage_solver : storage_def_solver<T, V>
+ {
+ };
+
+ template <typename T>
+ struct storage_solver<T, typename except_void_t<typename T::storage>::ret>
+ {
+ typedef T ret;
+ };
+
+ template <typename T, typename V>
struct has_storage_t
{
typedef has_param_t<T, V> has_param;
Index: trunk/milena/sandbox/fred/mln/trait/next/solve.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/trait/next/solve.hh (revision 3714)
+++ trunk/milena/sandbox/fred/mln/trait/next/solve.hh (revision 3715)
@@ -147,6 +147,6 @@
# include <mln/trait/next/solve_unary.hh>
# include <mln/trait/next/solve_binary.hh>
-
+# include <mln/trait/next/solve_proxy.hh>
#endif // ! MLN_TRAIT_NEXT_SOLVE_HH
Index: trunk/milena/sandbox/fred/mln/trait/next/solve_proxy.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/trait/next/solve_proxy.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/trait/next/solve_proxy.hh (revision 3715)
@@ -0,0 +1,95 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_CONCEPT_PROXY_HH
+# define MLN_CORE_CONCEPT_PROXY_HH
+
+/*! \file mln/core/concept/proxy.hh
+ *
+ * \brief Definition of the concept of mln::Proxy.
+ *
+ * \todo preinc and predec are not tested; post-like ops are not handled.
+ *
+ * \todo add "op=(T)" when possible, so add a constness property.
+ * \todo add "opT()const" when possible.
+ */
+
+# include <mln/core/concept/object.hh>
+# include <mln/core/concept/proxy.hh>
+# include <mln/core/concept/proxy.hxx>
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ // Unary ops.
+
+ template < typename Op, typename P >
+ struct set_unary_< Op, mln::Proxy, P >
+ {
+ typedef mlc_unqualif(mln_q_subject(P)) S;
+ typedef mln_trait_nunary(Op, S) ret;
+ };
+
+ // Binary ops.
+
+ template < typename Op, typename L, typename R >
+ struct set_binary_< Op, mln::Proxy, L, mln::Proxy, R >
+ {
+ typedef mln::internal::helper_unprox_binop<L, R> helper;
+ typedef mln_trait_nbinary(Op,
+ typename helper::L_ret,
+ typename helper::R_ret) ret;
+ };
+
+ template < typename Op, typename P, typename O >
+ struct set_binary_< Op, mln::Proxy, P, mln::Object, O >
+ {
+ typedef mlc_unqualif(mln_q_subject(P)) S;
+ typedef mln_trait_nbinary(Op, S, O) ret;
+ };
+
+ template < typename Op, typename O, typename P >
+ struct set_binary_< Op, mln::Object, O, mln::Proxy, P >
+ {
+ typedef mlc_unqualif(mln_q_subject(P)) S;
+ typedef mln_trait_nbinary(Op, O, S) ret;
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_CONCEPT_PROXY_HH
Index: trunk/milena/sandbox/fred/mln/core/image/thrubin_morpher.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/core/image/thrubin_morpher.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/core/image/thrubin_morpher.hh (revision 3715)
@@ -0,0 +1,279 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_IMAGE_THRUBIN_MORPHER_HH
+# define MLN_CORE_IMAGE_THRUBIN_MORPHER_HH
+
+# include <mln/core/internal/image_value_morpher.hh>
+# include <mln/core/concept/meta_function.hh>
+# include <mln/metal/bexpr.hh>
+# include <mln/trait/fun.hh>
+
+///
+/// \file mln/core/image/thrubin_morpher.hh
+///
+/// \brief Definition of a morpher that morph values from two images through a binary function.
+///
+
+namespace mln
+{
+
+ // Forward declaration.
+ template <typename I, typename F> struct thrubin_image;
+
+ namespace internal
+ {
+ /// Data structure for \c mln::thrubin_image<I>.
+ template <typename I1, typename I2, typename F>
+ struct data< thrubin_image<I1, I2, F> >
+ {
+ data(I1& ima1, I2& ima2, const F& f);
+
+ I1 ima1_;
+ I2 ima2_;
+ F f_;
+ };
+
+ } // end of namespace mln::internal
+
+
+ namespace trait
+ {
+
+ template <typename I1, typename I2, typename F>
+ struct image_< thrubin_image<I1, I2, F> > : image_< typename mln::internal::thrubin_find_impl<I1, , F>::ret > // Same as I except...
+ {
+ // ...these changes.
+ typedef trait::image::category::value_morpher category;
+ typedef mln_internal_trait_image_speed_from(I) speed; // Un-fastest.
+ typedef trait::image::value_access::computed value_access;
+ typedef trait::image::vw_io::read vw_io;
+ };
+
+ } // end of namespace mln::trait
+
+
+
+ // FIXME: Doc!
+
+ namespace internal
+ {
+
+ template <typename I, typename F>
+ class thrubin_image_read : public internal::image_value_morpher< I, typename F::result, thrubin_image<I,F> >
+ {
+ public:
+
+ /// Skeleton.
+ typedef thrubin_image<tag::image_<I>, F> skeleton;
+
+ /// Point_Site associated type.
+ typedef mln_psite(I) psite;
+
+ /// Value associated type.
+ typedef typename F::result value;
+
+ /// Return type of read-only access.
+ typedef typename F::result rvalue;
+
+ rvalue operator()(const mln_psite(I)& p) const;
+
+ };
+
+ // Inheritance from read ?!
+ template <typename I, typename F>
+ class thrubin_image_write : public thrubin_image_read<I,F>
+ {
+ public:
+
+ /// Type returned by the read-write pixel value operator.
+// typedef typename F::template lresult<typename F::argument>::ret lvalue;
+ typedef typename F::lresult lvalue;
+
+ using thrubin_image_read<I,F>::operator();
+ lvalue operator()(const mln_psite(I)& p);
+
+ };
+ }
+
+ template <typename I, typename F>
+ class thrubin_image : public internal::thrubin_find_impl<I, F>::ret
+ {
+ public:
+
+ thrubin_image();
+ thrubin_image(I& ima);
+ thrubin_image(I& ima, const F& f);
+
+ void init_(I& ima, const F& f);
+
+ /// Const promotion via conversion.
+ operator thrubin_image<const I, F>() const;
+ };
+
+ template <typename I, typename F>
+ thrubin_image<I, F> thrubin(const mln::Function<F>& f,
+ Image<I>& ima);
+
+ template <typename I, typename F>
+ const thrubin_image<const I, F> thrubin(const mln::Function<F>& f,
+ const Image<I>& ima);
+
+ template <typename I, typename M>
+ thrubin_image<I, mln_fun_with(M, mln_value(I))>
+ thrubin(const mln::Meta_Function<M>& f, Image<I>& ima);
+
+ template <typename I, typename M>
+ const thrubin_image<const I, mln_fun_with(M, mln_value(I))>
+ thrubin(const mln::Meta_Function<M>& f, const Image<I>& ima);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // internal::data< thrubin_image<I,S> >
+
+ namespace internal
+ {
+
+ template <typename I, typename F>
+ inline
+ data< thrubin_image<I, F> >::data(I& ima, const F& f)
+ : ima_(ima),
+ f_(f)
+ {
+ }
+
+ } // end of namespace mln::internal
+
+ // thrubin_image<I>
+
+ template <typename I, typename F>
+ inline
+ thrubin_image<I, F>::thrubin_image()
+ {
+ }
+
+ template <typename I, typename F>
+ inline
+ thrubin_image<I, F>::thrubin_image(I& ima, const F& f)
+ {
+ mln_precondition(ima.is_valid());
+ init_(ima, f);
+ }
+
+ template <typename I, typename F>
+ inline
+ thrubin_image<I, F>::thrubin_image(I& ima)
+ {
+ mln_precondition(ima.is_valid());
+ init_(ima, mln_value(I)());
+ }
+
+ template <typename I, typename F>
+ inline
+ void
+ thrubin_image<I, F>::init_(I& ima, const F& f)
+ {
+ mln_precondition(! this->is_valid());
+ mln_precondition(ima.is_valid());
+ this->data_ = new internal::data< thrubin_image<I, F> >(ima, f);
+ }
+
+ template <typename I, typename F>
+ inline
+ thrubin_image<I, F>::operator thrubin_image<const I, F>() const
+ {
+ thrubin_image<const I, F> tmp(this->data_->ima_, this->data_->f_);
+ return tmp;
+ }
+
+ namespace internal
+ {
+
+ template <typename I, typename F>
+ inline
+ typename thrubin_image_read<I, F>::rvalue
+ thrubin_image_read<I, F>::operator()(const mln_psite(I)& p) const
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->f_(this->data_->ima_(p));
+ }
+
+ template <typename I, typename F>
+ inline
+ typename thrubin_image_write<I, F>::lvalue
+ thrubin_image_write<I, F>::operator()(const mln_psite(I)& p)
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->f_(this->data_->ima_(p));
+ }
+
+ }
+
+ // thrubin
+ template <typename I, typename F>
+ thrubin_image<I, F> thrubin(const mln::Function<F>& f,
+ Image<I>& ima)
+ {
+ thrubin_image<I, F> tmp(exact(ima), exact(f));
+ return tmp;
+ }
+
+ template <typename I, typename F>
+ thrubin_image<const I, F> thrubin(const mln::Function<F>& f,
+ const Image<I>& ima)
+ {
+ thrubin_image<const I, F> tmp(exact(ima), exact(f));
+ return tmp;
+ }
+
+ template <typename I, typename M>
+ thrubin_image<I, mln_fun_with(M, mln_value(I))>
+ thrubin(const mln::Meta_Function<M>& f, Image<I>& ima)
+ {
+ typedef mln_fun_with(M, mln_value(I)) F;
+ thrubin_image<I, F> tmp(exact(ima), F());
+
+ return tmp;
+ }
+
+ template <typename I, typename M>
+ thrubin_image<const I, mln_fun_with(M, mln_value(I))>
+ thrubin(const mln::Meta_Function<M>& f, const Image<I>& ima)
+ {
+ typedef mln_fun_with(M, mln_value(I)) F;
+ thrubin_image<const I, F> tmp(exact(ima), F());
+
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_IMAGE_THRUBIN_MORPHER_HH
Index: trunk/milena/sandbox/fred/mln/fun/component/blue.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/component/blue.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/component/blue.hh (revision 3715)
@@ -0,0 +1,84 @@
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can blueistribute 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 coveblue by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be coveblue by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_COMPONENT_BLUE_HH
+# define MLN_FUN_COMPONENT_BLUE_HH
+
+/// \file mln/fun/component/blue.hh
+///
+/// Meta function to retrieve/modify the blue component.
+
+# include <mln/fun/unary.hh>
+# include <mln/value/rgb.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ struct blue : unary<blue> {};
+
+ } // end of namespace mln::fun
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <unsigned n>
+ struct set_precise_unary_<mln::fun::blue, mln::value::rgb<n> >
+ {
+ typedef set_precise_unary_ ret;
+ typedef mln::value::rgb<n> argument;
+ typedef typename argument::blue_t result;
+ typedef argument& lvalue;
+
+ static result read(const argument& x)
+ {
+ return x.blue();
+ }
+
+ static void write(lvalue l, const result& r)
+ {
+ l.blue() = r;
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // MLN_FUN_COMPONENT_BLUE_HH
Index: trunk/milena/sandbox/fred/mln/fun/component/red.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/component/red.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/component/red.hh (revision 3715)
@@ -0,0 +1,84 @@
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
+//
+// 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_FUN_COMPONENT_RED_HH
+# define MLN_FUN_COMPONENT_RED_HH
+
+/// \file mln/fun/component/red.hh
+///
+/// Meta function to retrieve/modify the red component.
+
+# include <mln/fun/unary.hh>
+# include <mln/value/rgb.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ struct red : unary<red> {};
+
+ } // end of namespace mln::fun
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <unsigned n>
+ struct set_precise_unary_<mln::fun::red, mln::value::rgb<n> >
+ {
+ typedef set_precise_unary_ ret;
+ typedef mln::value::rgb<n> argument;
+ typedef typename argument::red_t result;
+ typedef argument& lvalue;
+
+ static result read(const argument& x)
+ {
+ return x.red();
+ }
+
+ static void write(lvalue l, const result& r)
+ {
+ l.red() = r;
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // MLN_FUN_COMPONENT_RED_HH
Index: trunk/milena/sandbox/fred/mln/fun/component/rgb.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/component/rgb.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/component/rgb.hh (revision 3715)
@@ -0,0 +1,40 @@
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
+//
+// 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_FUN_COMPONENT_RGB_HH
+# define MLN_FUN_COMPONENT_RGB_HH
+
+/// \file mln/fun/component/red.hh
+///
+/// Meta functions to retrieve/modify rgb components.
+
+# include <mln/fun/component/red.hh>
+# include <mln/fun/component/green.hh>
+# include <mln/fun/component/blue.hh>
+
+#endif // MLN_FUN_COMPONENT_RGB_HH
Index: trunk/milena/sandbox/fred/mln/fun/component/comp.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/component/comp.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/component/comp.hh (revision 3715)
@@ -0,0 +1,174 @@
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
+//
+// 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_FUN_COMPONENT_COMP_HH
+# define MLN_FUN_COMPONENT_COMP_HH
+
+/// \file mln/fun/component/comp.hh
+///
+/// Meta function to retrieve/modify a component.
+
+# include <mln/fun/unary.hh>
+# include <mln/fun/binary.hh>
+# include <mln/fun/param.hh>
+# include <mln/trait/next/solve.hh>
+# include <mln/value/rgb.hh>
+# include <mln/value/int_u.hh>
+# include <mln/algebra/vec.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ struct comp : binary<comp> {};
+
+ struct pcomp;
+
+ template <>
+ struct parameter<pcomp>
+ {
+ typedef unsigned param;
+ };
+
+ struct pcomp : unary<pcomp>
+ {
+ pcomp() : unary<pcomp>(0) {};
+ pcomp(unsigned i = 0) : unary<pcomp>(i) {};
+ };
+
+ struct comp_count : unary<comp_count> {};
+
+ } // end of namespace mln::fun
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <typename E, typename T>
+ struct set_binary_<mln::fun::comp, mln::value::Integer, E, mln::Object, T>
+ {
+ typedef set_binary_ ret;
+ typedef E argument1;
+ typedef T argument2;
+ typedef mln_trait_nunary(mln::fun::pcomp, T) pcomp_t;
+ typedef mln_result(pcomp_t) result;
+
+ static result read(const argument1& i, const argument2& v)
+ {
+ pcomp_t c;
+ return c.read(i, v);
+ }
+ };
+
+ template <unsigned n>
+ struct set_precise_unary_<mln::fun::comp_count, mln::value::rgb<n> >
+ {
+ typedef set_precise_unary_ ret;
+
+ typedef mln::value::rgb<n> argument;
+ typedef unsigned result;
+ typedef argument& lvalue;
+
+ static result read(const argument&)
+ {
+ return n;
+ }
+ };
+
+ template <unsigned n, typename T>
+ struct set_precise_unary_<mln::fun::comp_count, mln::algebra::vec<n,T> >
+ {
+ typedef set_precise_unary_ ret;
+
+ typedef mln::algebra::vec<n,T> argument;
+ typedef unsigned result;
+ typedef argument& lvalue;
+
+ static result read(const argument&)
+ {
+ return n;
+ }
+ };
+
+ template <unsigned n>
+ struct set_precise_unary_<mln::fun::pcomp, mln::value::rgb<n> >
+ {
+ typedef set_precise_unary_ ret;
+// typedef mln::fun::pcomp flag;
+
+ typedef mln::value::rgb<n> argument;
+ typedef mln::value::int_u<n> result;
+ typedef argument& lvalue;
+
+ static result read(unsigned p_i, const argument& v)
+ {
+ return v.comp(p_i);
+ }
+
+ static void write(unsigned p_i, lvalue l, const result& x)
+ {
+ l.comp(p_i) = x;
+ }
+ };
+
+ template <unsigned n, typename T>
+ struct set_precise_unary_<mln::fun::pcomp, mln::algebra::vec<n,T> >
+ {
+ typedef set_precise_unary_ ret;
+ typedef mln::fun::pcomp flag;
+
+ typedef mln::algebra::vec<n,T> argument;
+ typedef T result;
+ typedef argument& lvalue;
+
+ static result read(unsigned p_i, const argument& v)
+ {
+ return v[p_i];
+ }
+
+ static void write(unsigned p_i, lvalue l, const result& x)
+ {
+ l[p_i] = x;
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // MLN_FUN_COMPONENT_COMP_HH
Index: trunk/milena/sandbox/fred/mln/fun/component/green.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/component/green.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/component/green.hh (revision 3715)
@@ -0,0 +1,84 @@
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can greenistribute 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 covegreen by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covegreen by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_COMPONENT_GREEN_HH
+# define MLN_FUN_COMPONENT_GREEN_HH
+
+/// \file mln/fun/component/green.hh
+///
+/// Meta function to retrieve/modify the green component.
+
+# include <mln/fun/unary.hh>
+# include <mln/value/rgb.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ struct green : unary<green> {};
+
+ } // end of namespace mln::fun
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <unsigned n>
+ struct set_precise_unary_<mln::fun::green, mln::value::rgb<n> >
+ {
+ typedef set_precise_unary_ ret;
+ typedef mln::value::rgb<n> argument;
+ typedef typename argument::green_t result;
+ typedef argument& lvalue;
+
+ static result read(const argument& x)
+ {
+ return x.green();
+ }
+
+ static void write(lvalue l, const result& r)
+ {
+ l.green() = r;
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // MLN_FUN_COMPONENT_GREEN_HH
Index: trunk/milena/sandbox/fred/mln/fun/spe/unary.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/spe/unary.hh (revision 3714)
+++ trunk/milena/sandbox/fred/mln/fun/spe/unary.hh (revision 3715)
@@ -217,8 +217,8 @@
typedef typename def::argument argument;
typedef typename def::result result;
- typedef mln_trait_fun_param(def) param;
- typedef mln_trait_fun_storage(def) storage;
+ typedef mln_trait_fun_param(unary_impl) param;
+ typedef mln_trait_fun_storage(unary_impl) storage;
result operator () (const argument& value) const
{
@@ -266,11 +266,11 @@
template <typename Fun, typename T>
struct unary
- : impl::unary_impl<mln_trait_fun_is_parametrable_(mln_trait_nunary(Fun, T))::value,
+ : impl::unary_impl<mlc_or(mln_trait_fun_is_parametrable(mln_trait_nunary(Fun, T)), mln_trait_fun_is_parametrable(Fun))::value,
mln_trait_fun_is_assignable_(mln_trait_nunary(Fun, T))::value, Fun, T>
{
typedef mln_trait_nunary(Fun, T) def;
- typedef impl::unary_impl<mln_trait_fun_is_parametrable_(def)::value,
+ typedef impl::unary_impl<mlc_or(mln_trait_fun_is_parametrable(def), mln_trait_fun_is_parametrable(Fun))::value,
mln_trait_fun_is_assignable_(def)::value,
Fun,
T>
1
0
* mln/util/array.hh,
* mln/io/pgm/save.hh: remove a wrong precondition.
* mln/labeling/compute.hh: do not call next() anymore.
* mln/linear/gaussian_directional_2d.hh: avoid a warning.
* tests/core/image/safe_image.cc: remove invalid code.
* tests/level/transform.cc: update invalid code. No implicit
conversion allowed from morphers to concrete images.
* tests/make/Makefile.am: remove duplicate test entry.
* tests/unit_test/unit-tests.mk: update unit test list.
* tools/area_flooding.cc: use edge_image and vertex_image.
---
milena/ChangeLog | 22 ++++++++++++++++
milena/mln/labeling/compute.hh | 6 ++--
milena/mln/linear/gaussian_directional_2d.hh | 1 +
milena/mln/util/array.hh | 2 -
milena/tests/core/image/safe_image.cc | 15 ++++-------
milena/tests/level/transform.cc | 19 ++++++--------
milena/tests/make/Makefile.am | 1 -
milena/tests/unit_test/unit-tests.mk | 34 +++++++++++++++++++++----
milena/tools/area_flooding.cc | 11 ++++----
9 files changed, 72 insertions(+), 39 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 54be57c..1a416bd 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,27 @@
2009-04-27 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Small fixes.
+
+ * mln/util/array.hh,
+ * mln/io/pgm/save.hh: remove a wrong precondition.
+
+ * mln/labeling/compute.hh: do not call next() anymore.
+
+ * mln/linear/gaussian_directional_2d.hh: avoid a warning.
+
+ * tests/core/image/safe_image.cc: remove invalid code.
+
+ * tests/level/transform.cc: update invalid code. No implicit
+ conversion allowed from morphers to concrete images.
+
+ * tests/make/Makefile.am: remove duplicate test entry.
+
+ * tests/unit_test/unit-tests.mk: update unit test list.
+
+ * tools/area_flooding.cc: use edge_image and vertex_image.
+
+2009-04-27 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
Revamp graph images.
* headers.mk: update distributed file list.
diff --git a/milena/mln/labeling/compute.hh b/milena/mln/labeling/compute.hh
index 9bf6394..7099069 100644
--- a/milena/mln/labeling/compute.hh
+++ b/milena/mln/labeling/compute.hh
@@ -175,7 +175,7 @@ namespace mln
const A& a = exact(a_);
const L& label = exact(label_);
- util::array<A> accus(nlabels.next(), a);
+ util::array<A> accus(static_cast<unsigned>(nlabels) + 1, a);
mln_piter(L) p(label.domain());
for_all(p)
@@ -204,7 +204,7 @@ namespace mln
const I& input = exact(input_);
const L& label = exact(label_);
- util::array<A> accus(nlabels.next(), a);
+ util::array<A> accus(static_cast<unsigned>(nlabels) + 1, a);
mln_piter(I) p(input.domain());
for_all(p)
@@ -302,7 +302,7 @@ namespace mln
typedef util::array<mln_result(A)> R;
R res = internal::compute_dispatch(a, label, nlabels);
- mln_postcondition(res.nelements() == nlabels.next());
+ mln_postcondition(res.nelements() == static_cast<unsigned>(nlabels) + 1);
trace::exiting("labeling::compute");
return res;
diff --git a/milena/mln/linear/gaussian_directional_2d.hh b/milena/mln/linear/gaussian_directional_2d.hh
index 18b350c..eeb93d2 100644
--- a/milena/mln/linear/gaussian_directional_2d.hh
+++ b/milena/mln/linear/gaussian_directional_2d.hh
@@ -405,6 +405,7 @@ namespace mln
// Non causal part
+ (void) bdr;
// extension::fill(ima, bdr);
unsigned
diff --git a/milena/mln/util/array.hh b/milena/mln/util/array.hh
index 5d1fed5..f48d242 100644
--- a/milena/mln/util/array.hh
+++ b/milena/mln/util/array.hh
@@ -374,8 +374,6 @@ namespace mln
void
from_to_(const util::array<T1>& from, util::array<T2>& to)
{
- mlc_converts_to(T1,T2)::check();
-
to.reserve(from.nelements());
for (unsigned i = 0; i < from.nelements(); ++i)
diff --git a/milena/tests/core/image/safe_image.cc b/milena/tests/core/image/safe_image.cc
index 2fff120..8a74d0d 100644
--- a/milena/tests/core/image/safe_image.cc
+++ b/milena/tests/core/image/safe_image.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2009 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
@@ -25,10 +25,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/core/image/safe_image.cc
- *
- * \brief Tests on mln::safe_image.
- */
+/// \file tests/core/image/safe_image.cc
+///
+/// Tests on mln::safe_image.
#include <mln/core/image/image2d.hh>
#include <mln/core/image/safe.hh>
@@ -49,13 +48,9 @@ int main()
ima_(in) = 51;
mln_assertion(ima_(in) == 51);
-
+
ima_(out) = 0;
mln_assertion(ima_(out) == 7);
-
- // test "image_adaptor_<..>::operator I() const"
- I ima2 = ima_;
- const I ima3 = ima_;
}
{
diff --git a/milena/tests/level/transform.cc b/milena/tests/level/transform.cc
index e771b01..179aea8 100644
--- a/milena/tests/level/transform.cc
+++ b/milena/tests/level/transform.cc
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -126,7 +126,7 @@ int main()
{
const pw::image<fun::p2v::iota, box2d> ima(fun::p2v::iota(),
make::box2d(2,2, 5,5));
- image2d<short unsigned int> out(8, 8);
+ image2d<unsigned short> out(8, 8);
data::fill(out, (short unsigned int)0);
out = level::transform(ima, mysqrt());
@@ -151,12 +151,11 @@ int main()
typedef image_if<I, fun::p2b::chess> II;
I ima(size, size);
- I out(size, size);
II ima_if = ima | fun::p2b::chess();
data::fill_with_value(ima, 0);
debug::iota(ima);
- out = level::transform(ima_if, mysqrt());
+ II out = level::transform(ima_if, mysqrt());
II::piter p(ima_if.domain());
for_all(p)
@@ -187,14 +186,13 @@ int main()
{
typedef image2d<int> I;
typedef sub_image< image2d<int>, box2d > II;
- typedef image2d<unsigned short> III;
+ typedef sub_image< image2d<unsigned short>, box2d > III;
I ima(size, size);
II sub_ima(ima, make::box2d(4,4, 10,10));
- III out(size, size);
data::fill(ima, 51);
- out = level::transform(sub_ima, mysqrt());
+ III out = level::transform(sub_ima, mysqrt());
II::piter p(sub_ima.domain());
for_all(p)
@@ -205,14 +203,13 @@ int main()
{
typedef image2d<int> I;
typedef extension_val< image2d<int> > II;
- typedef image2d<unsigned short> III;
+ typedef extension_val< image2d<unsigned short> > III;
I ima(size, size);
II extend_ima(ima, 5);
- III out(size, size);
data::fill(ima, 51);
- out = level::transform(extend_ima, mysqrt());
+ III out = level::transform(extend_ima, mysqrt());
II::piter p(extend_ima.domain());
for_all(p)
diff --git a/milena/tests/make/Makefile.am b/milena/tests/make/Makefile.am
index f83f95c..d9e391c 100644
--- a/milena/tests/make/Makefile.am
+++ b/milena/tests/make/Makefile.am
@@ -18,7 +18,6 @@ check_PROGRAMS = \
w_window \
w_window_directional
-dual_neighb_SOURCES = dual_neighb.c
dual_neighb_SOURCES = dual_neighb.cc
dummy_p_edges_SOURCES = dummy_p_edges.cc
dummy_p_vertices_SOURCES = dummy_p_vertices.cc
diff --git a/milena/tests/unit_test/unit-tests.mk b/milena/tests/unit_test/unit-tests.mk
index 15c6fcd..46fbff2 100644
--- a/milena/tests/unit_test/unit-tests.mk
+++ b/milena/tests/unit_test/unit-tests.mk
@@ -81,6 +81,7 @@ mln_util_internal_vertex_impl \
mln_util_internal_edge_impl \
mln_util_internal_graph_base \
mln_util_internal_boost_graph \
+mln_util_internal_id2element \
mln_util_internal_graph_nbh_iter_base \
mln_util_internal_boost_graph_property \
mln_util_ord_pair \
@@ -108,6 +109,7 @@ mln_util_pix \
mln_util_tree_fast \
mln_util_site_pair \
mln_util_nil \
+mln_util_graph_ids \
mln_util_eat \
mln_util_essential \
mln_data_memset_ \
@@ -130,13 +132,13 @@ mln_trace_resume \
mln_trace_quiet \
mln_trace_stop \
mln_trace_essential \
-mln_make_graph \
mln_make_double_neighb2d \
mln_make_image3d \
mln_make_dpoint2d_h \
mln_make_w_window \
mln_make_cell \
mln_make_image \
+mln_make_influence_zone_adjacency_graph \
mln_make_vec \
mln_make_all \
mln_make_dual_neighb \
@@ -148,11 +150,15 @@ mln_make_w_window2d_int \
mln_make_box1d \
mln_make_voronoi \
mln_make_box2d \
+mln_make_p_edges_with_mass_centers \
mln_make_h_mat \
+mln_make_p_vertices_with_mass_centers \
+mln_make_vertex_image \
mln_make_w_window2d \
mln_make_box3d \
mln_make_detachment \
mln_make_region_adjacency_graph \
+mln_make_dummy_p_vertices \
mln_make_relabelfun \
mln_make_pixel \
mln_make_pix \
@@ -161,6 +167,7 @@ mln_make_w_window1d \
mln_make_image2d \
mln_make_w_window_directional \
mln_make_rag_and_labeled_wsl \
+mln_make_dummy_p_edges \
mln_make_w_window3d_int \
mln_make_essential \
mln_make_w_window1d_int \
@@ -208,7 +215,6 @@ mln_fun_vv2v_diff_abs \
mln_fun_vv2v_land \
mln_fun_vv2v_min \
mln_fun_vv2v_essential \
-mln_fun_internal_array_base \
mln_fun_internal_x2x_linear_impl \
mln_fun_internal_ch_function_value_impl \
mln_fun_internal_resolve \
@@ -252,7 +258,6 @@ mln_fun_i2v_all \
mln_fun_i2v_array \
mln_fun_i2v_all_to \
mln_fun_i2v_essential \
-mln_fun_l2l_relabel \
mln_fun_l2l_all \
mln_fun_l2l_wrap \
mln_fun_l2l_essential \
@@ -938,6 +943,7 @@ mln_core_concept_window \
mln_core_concept_value \
mln_core_concept_accumulator \
mln_core_concept_site_set \
+mln_core_concept_object_id \
mln_core_concept_object \
mln_core_concept_meta_fun \
mln_core_concept_delta_point_site \
@@ -1017,6 +1023,7 @@ mln_labeling_foreground \
mln_labeling_regional_maxima \
mln_labeling_wrap \
mln_labeling_compute \
+mln_labeling_pack \
mln_labeling_regional_minima \
mln_labeling_essential \
mln_labeling_fill_holes \
@@ -1107,6 +1114,7 @@ mln_debug_println_with_border \
mln_debug_colorize \
mln_debug_slices_2d \
mln_debug_draw_graph \
+mln_debug_filename \
mln_debug_put_word \
mln_debug_histo \
mln_debug_quiet \
@@ -1118,6 +1126,9 @@ mln_estim_all \
mln_estim_sum \
mln_estim_mean \
mln_estim_essential \
+mln_graph_attribute_representative \
+mln_graph_attribute_card \
+mln_graph_compute \
mln_set_uni \
mln_set_unique \
mln_set_inter \
@@ -1225,6 +1236,7 @@ mln_util_internal_vertex_impl_SOURCES = mln_util_internal_vertex_impl.cc
mln_util_internal_edge_impl_SOURCES = mln_util_internal_edge_impl.cc
mln_util_internal_graph_base_SOURCES = mln_util_internal_graph_base.cc
mln_util_internal_boost_graph_SOURCES = mln_util_internal_boost_graph.cc
+mln_util_internal_id2element_SOURCES = mln_util_internal_id2element.cc
mln_util_internal_graph_nbh_iter_base_SOURCES = mln_util_internal_graph_nbh_iter_base.cc
mln_util_internal_boost_graph_property_SOURCES = mln_util_internal_boost_graph_property.cc
mln_util_ord_pair_SOURCES = mln_util_ord_pair.cc
@@ -1252,6 +1264,7 @@ mln_util_pix_SOURCES = mln_util_pix.cc
mln_util_tree_fast_SOURCES = mln_util_tree_fast.cc
mln_util_site_pair_SOURCES = mln_util_site_pair.cc
mln_util_nil_SOURCES = mln_util_nil.cc
+mln_util_graph_ids_SOURCES = mln_util_graph_ids.cc
mln_util_eat_SOURCES = mln_util_eat.cc
mln_util_essential_SOURCES = mln_util_essential.cc
mln_data_memset__SOURCES = mln_data_memset_.cc
@@ -1274,13 +1287,13 @@ mln_trace_resume_SOURCES = mln_trace_resume.cc
mln_trace_quiet_SOURCES = mln_trace_quiet.cc
mln_trace_stop_SOURCES = mln_trace_stop.cc
mln_trace_essential_SOURCES = mln_trace_essential.cc
-mln_make_graph_SOURCES = mln_make_graph.cc
mln_make_double_neighb2d_SOURCES = mln_make_double_neighb2d.cc
mln_make_image3d_SOURCES = mln_make_image3d.cc
mln_make_dpoint2d_h_SOURCES = mln_make_dpoint2d_h.cc
mln_make_w_window_SOURCES = mln_make_w_window.cc
mln_make_cell_SOURCES = mln_make_cell.cc
mln_make_image_SOURCES = mln_make_image.cc
+mln_make_influence_zone_adjacency_graph_SOURCES = mln_make_influence_zone_adjacency_graph.cc
mln_make_vec_SOURCES = mln_make_vec.cc
mln_make_all_SOURCES = mln_make_all.cc
mln_make_dual_neighb_SOURCES = mln_make_dual_neighb.cc
@@ -1292,11 +1305,15 @@ mln_make_w_window2d_int_SOURCES = mln_make_w_window2d_int.cc
mln_make_box1d_SOURCES = mln_make_box1d.cc
mln_make_voronoi_SOURCES = mln_make_voronoi.cc
mln_make_box2d_SOURCES = mln_make_box2d.cc
+mln_make_p_edges_with_mass_centers_SOURCES = mln_make_p_edges_with_mass_centers.cc
mln_make_h_mat_SOURCES = mln_make_h_mat.cc
+mln_make_p_vertices_with_mass_centers_SOURCES = mln_make_p_vertices_with_mass_centers.cc
+mln_make_vertex_image_SOURCES = mln_make_vertex_image.cc
mln_make_w_window2d_SOURCES = mln_make_w_window2d.cc
mln_make_box3d_SOURCES = mln_make_box3d.cc
mln_make_detachment_SOURCES = mln_make_detachment.cc
mln_make_region_adjacency_graph_SOURCES = mln_make_region_adjacency_graph.cc
+mln_make_dummy_p_vertices_SOURCES = mln_make_dummy_p_vertices.cc
mln_make_relabelfun_SOURCES = mln_make_relabelfun.cc
mln_make_pixel_SOURCES = mln_make_pixel.cc
mln_make_pix_SOURCES = mln_make_pix.cc
@@ -1305,6 +1322,7 @@ mln_make_w_window1d_SOURCES = mln_make_w_window1d.cc
mln_make_image2d_SOURCES = mln_make_image2d.cc
mln_make_w_window_directional_SOURCES = mln_make_w_window_directional.cc
mln_make_rag_and_labeled_wsl_SOURCES = mln_make_rag_and_labeled_wsl.cc
+mln_make_dummy_p_edges_SOURCES = mln_make_dummy_p_edges.cc
mln_make_w_window3d_int_SOURCES = mln_make_w_window3d_int.cc
mln_make_essential_SOURCES = mln_make_essential.cc
mln_make_w_window1d_int_SOURCES = mln_make_w_window1d_int.cc
@@ -1352,7 +1370,6 @@ mln_fun_vv2v_diff_abs_SOURCES = mln_fun_vv2v_diff_abs.cc
mln_fun_vv2v_land_SOURCES = mln_fun_vv2v_land.cc
mln_fun_vv2v_min_SOURCES = mln_fun_vv2v_min.cc
mln_fun_vv2v_essential_SOURCES = mln_fun_vv2v_essential.cc
-mln_fun_internal_array_base_SOURCES = mln_fun_internal_array_base.cc
mln_fun_internal_x2x_linear_impl_SOURCES = mln_fun_internal_x2x_linear_impl.cc
mln_fun_internal_ch_function_value_impl_SOURCES = mln_fun_internal_ch_function_value_impl.cc
mln_fun_internal_resolve_SOURCES = mln_fun_internal_resolve.cc
@@ -1396,7 +1413,6 @@ mln_fun_i2v_all_SOURCES = mln_fun_i2v_all.cc
mln_fun_i2v_array_SOURCES = mln_fun_i2v_array.cc
mln_fun_i2v_all_to_SOURCES = mln_fun_i2v_all_to.cc
mln_fun_i2v_essential_SOURCES = mln_fun_i2v_essential.cc
-mln_fun_l2l_relabel_SOURCES = mln_fun_l2l_relabel.cc
mln_fun_l2l_all_SOURCES = mln_fun_l2l_all.cc
mln_fun_l2l_wrap_SOURCES = mln_fun_l2l_wrap.cc
mln_fun_l2l_essential_SOURCES = mln_fun_l2l_essential.cc
@@ -2082,6 +2098,7 @@ mln_core_concept_window_SOURCES = mln_core_concept_window.cc
mln_core_concept_value_SOURCES = mln_core_concept_value.cc
mln_core_concept_accumulator_SOURCES = mln_core_concept_accumulator.cc
mln_core_concept_site_set_SOURCES = mln_core_concept_site_set.cc
+mln_core_concept_object_id_SOURCES = mln_core_concept_object_id.cc
mln_core_concept_object_SOURCES = mln_core_concept_object.cc
mln_core_concept_meta_fun_SOURCES = mln_core_concept_meta_fun.cc
mln_core_concept_delta_point_site_SOURCES = mln_core_concept_delta_point_site.cc
@@ -2161,6 +2178,7 @@ mln_labeling_foreground_SOURCES = mln_labeling_foreground.cc
mln_labeling_regional_maxima_SOURCES = mln_labeling_regional_maxima.cc
mln_labeling_wrap_SOURCES = mln_labeling_wrap.cc
mln_labeling_compute_SOURCES = mln_labeling_compute.cc
+mln_labeling_pack_SOURCES = mln_labeling_pack.cc
mln_labeling_regional_minima_SOURCES = mln_labeling_regional_minima.cc
mln_labeling_essential_SOURCES = mln_labeling_essential.cc
mln_labeling_fill_holes_SOURCES = mln_labeling_fill_holes.cc
@@ -2251,6 +2269,7 @@ mln_debug_println_with_border_SOURCES = mln_debug_println_with_border.cc
mln_debug_colorize_SOURCES = mln_debug_colorize.cc
mln_debug_slices_2d_SOURCES = mln_debug_slices_2d.cc
mln_debug_draw_graph_SOURCES = mln_debug_draw_graph.cc
+mln_debug_filename_SOURCES = mln_debug_filename.cc
mln_debug_put_word_SOURCES = mln_debug_put_word.cc
mln_debug_histo_SOURCES = mln_debug_histo.cc
mln_debug_quiet_SOURCES = mln_debug_quiet.cc
@@ -2262,6 +2281,9 @@ mln_estim_all_SOURCES = mln_estim_all.cc
mln_estim_sum_SOURCES = mln_estim_sum.cc
mln_estim_mean_SOURCES = mln_estim_mean.cc
mln_estim_essential_SOURCES = mln_estim_essential.cc
+mln_graph_attribute_representative_SOURCES = mln_graph_attribute_representative.cc
+mln_graph_attribute_card_SOURCES = mln_graph_attribute_card.cc
+mln_graph_compute_SOURCES = mln_graph_compute.cc
mln_set_uni_SOURCES = mln_set_uni.cc
mln_set_unique_SOURCES = mln_set_unique.cc
mln_set_inter_SOURCES = mln_set_inter.cc
diff --git a/milena/tools/area_flooding.cc b/milena/tools/area_flooding.cc
index 742ec94..55813c6 100644
--- a/milena/tools/area_flooding.cc
+++ b/milena/tools/area_flooding.cc
@@ -57,7 +57,6 @@
#include <mln/core/routine/duplicate.hh>
#include <mln/core/image/image2d.hh>
-#include <mln/core/image/line_graph_elt_neighborhood.hh>
#include <mln/core/var.hh>
#include <mln/morpho/line_gradient.hh>
@@ -102,12 +101,13 @@ int main(int argc, char* argv[])
`----------------*/
// Type of the function mapping graph edges and image sites.
- typedef fun::i2v::array<util::site_pair<point2d> > fedge_site_t;
+ typedef util::site_pair<point2d> P;
+ typedef fun::i2v::array<P> fedge_site_t;
// Line graph image.
typedef fun::i2v::array<val_t> fval_t;
fval_t values;
- typedef pw::image<fval_t, p_edges<util::graph,fedge_site_t> > lg_ima_t;
+ typedef edge_image<P,val_t> lg_ima_t;
lg_ima_t lg_ima = morpho::line_gradient(input);
/*-----------.
@@ -117,7 +117,7 @@ int main(int argc, char* argv[])
/* FIXME: I'm not sure this is the way it should be done. Anyway,
we should implement this as a canvas. */
- typedef line_graph_elt_neighborhood<util::graph, lg_ima_t::pset::fun_t> nbh_t;
+ typedef lg_ima_t::nbh_t nbh_t;
nbh_t nbh;
unsigned area = 0;
@@ -146,8 +146,7 @@ int main(int argc, char* argv[])
// Perform a Watershed Transform.
typedef int_u16 wst_val_t;
wst_val_t nbasins;
- typedef pw::image<fun::i2v::array<wst_val_t>,
- p_edges<util::graph,fedge_site_t> > wshed_t;
+ typedef edge_image<P,wst_val_t> wshed_t;
wshed_t wshed = morpho::meyer_wst(result, nbh, nbasins);
std::cout << "nbasins = " << nbasins << std::endl;
--
1.5.6.5
1
0
* icdar/2009/dibco/binarization.cc,
* icdar/2009/dibco/svg.1.binarization.cc,
* icdar/2009/dibco/svg.2.binarization.cc,
* icdar/2009/dibco/svg.3.binarization.cc,
* lazzara/igr/irm/wst_rag_hsl.cc: use vertex_image and edge_image
types.
---
milena/sandbox/ChangeLog | 11 +++
milena/sandbox/icdar/2009/dibco/binarization.cc | 19 +++--
.../sandbox/icdar/2009/dibco/svg.1.binarization.cc | 14 ++--
.../sandbox/icdar/2009/dibco/svg.2.binarization.cc | 7 +-
.../sandbox/icdar/2009/dibco/svg.3.binarization.cc | 40 +++++-----
milena/sandbox/lazzara/igr/irm/wst_rag_hsl.cc | 79 ++++++++-----------
6 files changed, 87 insertions(+), 83 deletions(-)
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index fba221d..2501564 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,3 +1,14 @@
+2009-04-27 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Update the use of graph image in sandbox.
+
+ * icdar/2009/dibco/binarization.cc,
+ * icdar/2009/dibco/svg.1.binarization.cc,
+ * icdar/2009/dibco/svg.2.binarization.cc,
+ * icdar/2009/dibco/svg.3.binarization.cc,
+ * lazzara/igr/irm/wst_rag_hsl.cc: use vertex_image and edge_image
+ types.
+
2009-04-25 Alex Hamelin <hamelin(a)lrde.epita.fr>
End of vector method, proved to be useless.
diff --git a/milena/sandbox/icdar/2009/dibco/binarization.cc b/milena/sandbox/icdar/2009/dibco/binarization.cc
index c9fadbc..14f4495 100644
--- a/milena/sandbox/icdar/2009/dibco/binarization.cc
+++ b/milena/sandbox/icdar/2009/dibco/binarization.cc
@@ -7,6 +7,8 @@
#include <mln/core/alias/neighb2d.hh>
#include <mln/make/double_neighb2d.hh>
+#include <mln/core/image/vertex_image.hh>
+
#include <mln/pw/all.hh>
#include <mln/core/image/image_if.hh>
#include <mln/core/site_set/p_queue.hh>
@@ -17,7 +19,7 @@
#include <mln/core/site_set/p_edges.hh>
#include <mln/core/site_set/p_vertices.hh>
-#include <mln/core/image/graph_elt_neighborhood.hh>
+#include <mln/make/p_vertices_with_mass_centers.hh>
#include <mln/io/essential.hh>
#include <mln/value/int_u8.hh>
@@ -500,11 +502,12 @@ namespace mln
L& nlabels)
{
trace::entering("labeling__quasi_regional_minima");
-
+
+ (void) nlabels;
const I& input = exact(input_);
const N& nbh = exact(nbh_);
mln_precondition(input.is_valid());
-
+
typedef mln_psite(I) P;
p_array<P> s = level::sort_psites_increasing(input);
@@ -694,8 +697,6 @@ int main(int argc, char *argv[])
// ----------------------------- R A G --------------------------------
- util::graph& gr = rag_data.first();
-
fun::i2v::array<int_u8> f_med;
convert::from_to(basin_med, f_med);
@@ -707,12 +708,12 @@ int main(int argc, char *argv[])
}
p_vertices<util::graph, fun::i2v::array<point2d> >
- pv = make::common_pvertices(ws, nbasins, rag_data.first());
-
- mln_VAR( med, f_med | pv );
+ pv = make::p_vertices_with_mass_centers(ws, nbasins, rag_data.first());
+ typedef vertex_image<point2d, int_u8> med_t;
+ med_t med(pv, f_med);
- typedef graph_elt_neighborhood<util::graph, F> N;
+ typedef med_t::nbh_t N;
N nbh;
threshold = 25; // FIXME
diff --git a/milena/sandbox/icdar/2009/dibco/svg.1.binarization.cc b/milena/sandbox/icdar/2009/dibco/svg.1.binarization.cc
index 2111a08..119c64b 100644
--- a/milena/sandbox/icdar/2009/dibco/svg.1.binarization.cc
+++ b/milena/sandbox/icdar/2009/dibco/svg.1.binarization.cc
@@ -12,9 +12,10 @@
#include <mln/data/fill.hh>
+#include <mln/core/image/edge_image.hh>
+#include <mln/core/image/vertex_image.hh>
#include <mln/core/site_set/p_edges.hh>
#include <mln/core/site_set/p_vertices.hh>
-#include <mln/core/image/graph_elt_neighborhood.hh>
#include <mln/io/essential.hh>
#include <mln/value/int_u8.hh>
@@ -103,7 +104,7 @@ namespace mln
}
template <typename FVV, typename G, typename V2P, typename E2P, typename FVE>
- pw::image<fun::i2v::array<mln_result(FVE)>,p_edges<G,E2P> >
+ edge_image<mln_result(FVE),mln_result(E2P)>
edge_image(const pw::image<FVV,p_vertices<G,V2P> >& vertex_image,
const p_edges<G,E2P>& pe,
const Function_vv2v<FVE>& edge_value_)
@@ -118,8 +119,8 @@ namespace mln
edge_values_t edge_values(pe.nsites());
// image on graph edges
- typedef pw::image<edge_values_t, p_edges<G,E2P> > ima_e_t;
- ima_e_t ima_e = (edge_values | pe);
+ typedef mln::edge_image<mln_result(FVE),mln_result(E2P)> ima_e_t;
+ ima_e_t ima_e(pe, edge_values);
mln_piter(ima_e_t) e(ima_e.domain());
for_all(e)
@@ -365,7 +366,8 @@ int main(int argc, char *argv[])
p_vertices<util::graph, fun::i2v::array<point2d> >
pv = make::common_pvertices(wst, nbasins, rag_data.first());
- mln_VAR( med, f_med | pv );
+ typedef vertex_image<point2d, int_u8> med_t;
+ med_t med(pv, f_med);
int_u8
object = 255,
@@ -376,7 +378,7 @@ int main(int argc, char *argv[])
initialize(out, med);
data::fill(out, unknown);
- typedef graph_elt_neighborhood<util::graph, F> N;
+ typedef med_t::nbh_t N;
N nbh;
// Initialization.
diff --git a/milena/sandbox/icdar/2009/dibco/svg.2.binarization.cc b/milena/sandbox/icdar/2009/dibco/svg.2.binarization.cc
index d50c428..20a0505 100644
--- a/milena/sandbox/icdar/2009/dibco/svg.2.binarization.cc
+++ b/milena/sandbox/icdar/2009/dibco/svg.2.binarization.cc
@@ -15,9 +15,9 @@
#include <mln/core/routine/duplicate.hh>
#include <mln/data/fill.hh>
+#include <mln/core/image/vertex_image.hh>
#include <mln/core/site_set/p_edges.hh>
#include <mln/core/site_set/p_vertices.hh>
-#include <mln/core/image/graph_elt_neighborhood.hh>
#include <mln/io/essential.hh>
#include <mln/value/int_u8.hh>
@@ -630,7 +630,8 @@ int main(int argc, char *argv[])
p_vertices<util::graph, fun::i2v::array<point2d> >
pv = make::common_pvertices(ws, nbasins, rag_data.first());
- mln_VAR( med, f_med | pv );
+ typedef vertex_image<point2d, int_u8> med_t;
+ med_t med(pv, f_med);
int_u8
object = 255,
@@ -641,7 +642,7 @@ int main(int argc, char *argv[])
initialize(out, med);
data::fill(out, unknown);
- typedef graph_elt_neighborhood<util::graph, F> N;
+ typedef med_t::nbh_t N;
N nbh;
// Initialization.
diff --git a/milena/sandbox/icdar/2009/dibco/svg.3.binarization.cc b/milena/sandbox/icdar/2009/dibco/svg.3.binarization.cc
index 8af311f..86214c6 100644
--- a/milena/sandbox/icdar/2009/dibco/svg.3.binarization.cc
+++ b/milena/sandbox/icdar/2009/dibco/svg.3.binarization.cc
@@ -7,6 +7,9 @@
#include <mln/core/alias/neighb2d.hh>
#include <mln/make/double_neighb2d.hh>
+#include <mln/core/image/vertex_image.hh>
+#include <mln/core/image/edge_image.hh>
+
#include <mln/pw/all.hh>
#include <mln/core/image/image_if.hh>
#include <mln/core/site_set/p_queue.hh>
@@ -17,7 +20,6 @@
#include <mln/core/site_set/p_edges.hh>
#include <mln/core/site_set/p_vertices.hh>
-#include <mln/core/image/graph_elt_neighborhood.hh>
#include <mln/io/essential.hh>
#include <mln/value/int_u8.hh>
@@ -113,10 +115,10 @@ namespace mln
}
template <typename FVV, typename G, typename V2P, typename E2P, typename FVE>
- pw::image<fun::i2v::array<mln_result(FVE)>,p_edges<G,E2P> >
- edge_image(const pw::image<FVV,p_vertices<G,V2P> >& vertex_image,
- const p_edges<G,E2P>& pe,
- const Function_vv2v<FVE>& edge_value_)
+ edge_image<mln_result(E2P), mln_result(FVE), G>
+ edgeimage(const pw::image<FVV,p_vertices<G,V2P> >& vertex_image,
+ const p_edges<G,E2P>& pe,
+ const Function_vv2v<FVE>& edge_value_)
{
trace::entering("edge_image");
@@ -128,8 +130,8 @@ namespace mln
edge_values_t edge_values(pe.nsites());
// image on graph edges
- typedef pw::image<edge_values_t, p_edges<G,E2P> > ima_e_t;
- ima_e_t ima_e = (edge_values | pe);
+ typedef edge_image<mln_result(E2P), mln_result(FVE), G> ima_e_t;
+ ima_e_t ima_e(pe, edge_values);
mln_piter(ima_e_t) e(ima_e.domain());
for_all(e)
@@ -165,12 +167,12 @@ namespace mln
template <typename A, typename G, typename F, typename I, typename W>
- pw::image<fun::i2v::array<mln_value(I)>, p_vertices<G,F> >
- vertex_image(const Accumulator<A>& accu,
- const p_vertices<G,F>& pv,
- const Image<I>& input_,
- const Image<W>& wst_,
- const mln_value(W)& nbasins)
+ vertex_image<mln_result(F), mln_value(I), G>
+ verteximage(const Accumulator<A>& accu,
+ const p_vertices<G,F>& pv,
+ const Image<I>& input_,
+ const Image<W>& wst_,
+ const mln_value(W)& nbasins)
{
trace::entering("vertex_image");
@@ -185,9 +187,8 @@ namespace mln
convert::from_to(labeling::compute(accu, input, wst, nbasins),
vertex_values);
- pw::image<fun::i2v::array<mln_value(I)>,
- p_vertices<util::graph, fun::i2v::array<mln_site(I)> > >
- ima_vertex = vertex_values | pv;
+ vertex_image<mln_result(F), mln_value(I), G>
+ ima_vertex(pv, vertex_values);
trace::exiting("vertex_image");
return ima_vertex;
@@ -730,12 +731,13 @@ int main(int argc, char *argv[])
}
p_vertices<util::graph, fun::i2v::array<point2d> >
- pv = make::common_pvertices(ws, nbasins, rag_data.first());
+ pv = make::common_pvertices(ws, nbasins, gr);
- mln_VAR( med, f_med | pv );
+ typedef vertex_image<point2d,int_u8,util::graph> med_t;
+ med_t med(pv, f_med);
- typedef graph_elt_neighborhood<util::graph, F> N;
+ typedef med_t::nbh_t N;
N nbh;
threshold = 25; // FIXME
diff --git a/milena/sandbox/lazzara/igr/irm/wst_rag_hsl.cc b/milena/sandbox/lazzara/igr/irm/wst_rag_hsl.cc
index 48cca5a..f08ca70 100644
--- a/milena/sandbox/lazzara/igr/irm/wst_rag_hsl.cc
+++ b/milena/sandbox/lazzara/igr/irm/wst_rag_hsl.cc
@@ -1,14 +1,13 @@
#include <mln/essential/2d.hh>
+#include <mln/core/image/edge_image.hh>
+
#include <mln/core/alias/dpoint2d.hh>
#include <mln/core/alias/vec3d.hh>
-#include <mln/core/image/line_graph_elt_neighborhood.hh>
#include <mln/accu/center.hh>
#include <mln/accu/compute.hh>
-#include <mln/canvas/morpho/algebraic_union_find.hh>
-
#include <mln/debug/draw_graph.hh>
#include <mln/draw/box.hh>
@@ -34,6 +33,9 @@
#include <mln/value/hsl.hh>
#include <mln/make/region_adjacency_graph.hh>
+#include <mln/make/edge_image.hh>
+#include <mln/make/vertex_image.hh>
+#include <mln/make/p_vertices_with_mass_centers.hh>
// Given a color image and a wshed image, computes the component graph.
@@ -58,45 +60,39 @@ namespace mln
};
- value::int_u8 dist(const value::rgb8& c1, const value::rgb8& c2)
+ struct dist : Function_vv2v<dist>
{
- unsigned d = 0;
- d += (math::diff_abs(c1.red(), c2.red()) + 2) / 3;
- d += (math::diff_abs(c1.green(), c2.green()) + 2) / 3;
- d += (math::diff_abs(c1.blue(), c2.blue()) + 2) / 3;
- if (d > 255)
- d = 255;
- return d;
- }
+ typedef value::int_u8 result;
+
+ value::int_u8 operator()(const value::rgb8& c1, const value::rgb8& c2) const
+ {
+ unsigned d = 0;
+ d += (math::diff_abs(c1.red(), c2.red()) + 2) / 3;
+ d += (math::diff_abs(c1.green(), c2.green()) + 2) / 3;
+ d += (math::diff_abs(c1.blue(), c2.blue()) + 2) / 3;
+ if (d > 255u)
+ d = 255;
+ return d;
+ }
+
+ };
// ima_v, image on graph vertices; value = mean color per vertex (watershed basin)
template <typename I>
inline
- pw::image<fun::i2v::array<value::int_u8>,
- p_edges<util::graph, fun::i2v::array<mln_site(I)> > >
+ edge_image<mln_site(I),value::int_u8>
make_edge_graph_image(const I& ima_v, const util::graph& g)
{
// edge sites.
typedef fun::i2v::array<mln_site(I)> edge_site_t;
edge_site_t edge_site(g.e_nmax(), literal::origin);
- typedef p_edges<util::graph, edge_site_t > pe_t;
- pe_t pe(g, edge_site);
-
- // edge values
- typedef fun::i2v::array<value::int_u8> edge_values_t;
- edge_values_t edge_values(g.e_nmax());
// image on graph edges
- typedef pw::image<edge_values_t, pe_t> ima_e_t;
- ima_e_t ima_e = (edge_values | pe);
-
- mln_piter(ima_e_t) e(ima_e.domain());
- for_all(e) // in ima_e
- ima_e(e) = dist(ima_v.function()(e.element().v1()),
- ima_v.function()(e.element().v2()));
+ typedef edge_image<mln_site(I),value::int_u8> ima_e_t;
+ ima_e_t ima_e = make::edge_image(ima_v, edge_site, dist());
return ima_e;
}
@@ -123,30 +119,21 @@ namespace mln
}
template <typename I, typename J>
- pw::image<fun::i2v::array<mln_value(I)>,
- p_vertices<util::graph, fun::i2v::array<mln_site(I)> > >
+ vertex_image<mln_site(I), mln_value(I)>
make_vertex_graph_image(const util::graph& g, const I&input,
- const J& w, const mln_value(J)& nbasins)
+ const J& w, const mln_value(J)& nbasins)
{
- typedef util::array<mln_site(I)> vertex_sites_t;
- vertex_sites_t site_values;
- convert::from_to(labeling::compute(accu::center<mln_site(I)>(), w, nbasins),
- site_values);
-
- typedef fun::i2v::array<mln_site(J)> f_sites_t;
- f_sites_t sites;
- convert::from_to(site_values, sites);
-
- // p_vertices
- typedef p_vertices<util::graph, f_sites_t> S;
- S pv(g, sites);
-
+ /// Sites
+ typedef fun::i2v::array<mln_site(J)> vertex_sites_t;
+ typedef p_vertices<util::graph, vertex_sites_t> S;
+ S pv = make::p_vertices_with_mass_centers(w, nbasins, g);
+ /// Values
typedef fun::i2v::array<mln_value(I)> vertex_values_t;
vertex_values_t vertex_values;
convert::from_to(mean_color_values(input, w, nbasins), vertex_values);
- mln_VAR(ima_v, (vertex_values | pv));
+ vertex_image<mln_site(I), mln_value(I)> ima_v(pv, vertex_values);
return ima_v;
}
@@ -260,7 +247,7 @@ int main(int argc, char *argv[])
unsigned nbasins2;
fun::i2v::array<label_16> f;
{
- util::graph g = make::graph(vol, c4(), nbasins);
+ util::graph g = make::region_adjacency_graph(vol, c4(), nbasins);
mln_VAR(ima_v, make_vertex_graph_image(g, input, vol, nbasins));
mln_VAR(ima_e, make_edge_graph_image(ima_v, g));
@@ -302,7 +289,7 @@ int main(int argc, char *argv[])
// debug::println(vol);
vol2 = level::transform(vol, f);
// debug::println(vol2);
- util::graph g2 = make::graph(vol2, c4(), nbasins2);
+ util::graph g2 = make::region_adjacency_graph(vol2, c4(), nbasins2);
// Compute values distance on the HSL Image.
mln_VAR(ima_v2, make_vertex_graph_image(g2, input, vol2, nbasins2));
--
1.5.6.5
1
0
* headers.mk: update distributed file list.
* mln/make/dummy_p_edges.hh,
* mln/make/dummy_p_vertices.hh,
* mln/util/line_graph.hh,
* mln/util/internal/graph_base.hh,
* mln/util/internal/graph_iter.hh,
* mln/util/internal/graph_iter_base.hh,
* mln/util/internal/graph_nbh_iter.hh,
* mln/util/internal/graph_nbh_iter_base.hh,
* mln/util/graph.hh,
* mln/morpho/attribute/count_adjacent_vertices.hh,
* mln/core/concept/graph.hh: update member signatures with vertex and
edge ids.
* mln/core/site_set/p_graph_piter.hh,
* mln/core/internal/graph_psite_base.hh,
* mln/core/internal/neighb_niter_impl.hh,
* mln/core/internal/graph_psite_base.hh,
* mln/core/image/graph_window_piter.hh: comment a conversion
operators. Cause ambiguities with iterators/proxies.
* mln/core/image/vertex_image.hh,
* mln/core/image/edge_image.hh: add new members.
* mln/core/internal/site_iterator_base.hh: add a 'target' typedef.
* mln/core/site_set/p_edges.hh,
* mln/core/site_set/p_vertices.hh: add new constructors.
* mln/make/rag_and_labeled_wsl.hh: update doc.
* mln/util/graph_ids.hh,
* mln/util/edge.hh,
* mln/util/vertex.hh: introduce vertex and edge id types.
* mln/util/internal/id2element.hh: function mapping ids to graph
elements.
* mln/make/p_edges_with_mass_centers.hh: fix guards.
* tests/make/dummy_p_vertices.cc,
* tests/morpho/graph_image_morpho.cc,
* tests/morpho/graph_image_wst.cc,
* tests/morpho/line_graph_image_morpho.cc,
* tests/morpho/line_graph_image_wst.cc,
* tests/util/graph.cc,
* tests/util/line_graph.cc: update tests according the new
routines/constructors/types.
* mln/core/concept/object_id.hh: new concept for object ids.
---
milena/ChangeLog | 56 ++++
milena/headers.mk | 17 +-
milena/mln/core/concept/graph.hh | 40 ++--
milena/mln/core/concept/object_id.hh | 278 ++++++++++++++++++++
milena/mln/core/image/edge_image.hh | 75 ++++--
milena/mln/core/image/graph_window_piter.hh | 20 +-
milena/mln/core/image/vertex_image.hh | 127 ++++++---
milena/mln/core/internal/graph_psite_base.hh | 4 +-
milena/mln/core/internal/neighb_niter_impl.hh | 8 +-
milena/mln/core/internal/site_iterator_base.hh | 3 +
milena/mln/core/site_set/p_edges.hh | 22 ++-
milena/mln/core/site_set/p_graph_piter.hh | 87 ++++++-
milena/mln/core/site_set/p_vertices.hh | 21 ++-
milena/mln/make/dummy_p_edges.hh | 6 +-
milena/mln/make/dummy_p_vertices.hh | 6 +-
milena/mln/make/edge_image.hh | 164 ++++++++++++
milena/mln/make/p_edges_with_mass_centers.hh | 6 +-
milena/mln/make/rag_and_labeled_wsl.hh | 52 ++--
milena/mln/make/vertex_image.hh | 28 ++
.../morpho/attribute/count_adjacent_vertices.hh | 3 +-
milena/mln/util/edge.hh | 128 ++++++----
milena/mln/util/graph.hh | 123 ++++-----
.../dummy_p_vertices.cc => mln/util/graph_ids.hh} | 61 ++---
milena/mln/util/internal/graph_base.hh | 15 +-
milena/mln/util/internal/graph_iter.hh | 32 ++--
milena/mln/util/internal/graph_iter_base.hh | 26 ++-
milena/mln/util/internal/graph_nbh_iter.hh | 2 +-
milena/mln/util/internal/graph_nbh_iter_base.hh | 31 ++-
milena/mln/util/internal/id2element.hh | 100 +++++++
milena/mln/util/line_graph.hh | 92 ++++---
milena/mln/util/vertex.hh | 109 +++++---
milena/tests/make/dummy_p_vertices.cc | 4 +-
milena/tests/morpho/graph_image_morpho.cc | 5 +-
milena/tests/morpho/graph_image_wst.cc | 5 +-
milena/tests/morpho/line_graph_image_morpho.cc | 5 +-
milena/tests/morpho/line_graph_image_wst.cc | 5 +-
milena/tests/util/graph.cc | 12 +-
milena/tests/util/line_graph.cc | 12 +-
38 files changed, 1346 insertions(+), 444 deletions(-)
create mode 100644 milena/mln/core/concept/object_id.hh
create mode 100644 milena/mln/make/edge_image.hh
copy milena/{tests/make/dummy_p_vertices.cc => mln/util/graph_ids.hh} (54%)
create mode 100644 milena/mln/util/internal/id2element.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 10a5cc4..54be57c 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,61 @@
2009-04-27 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Revamp graph images.
+
+ * headers.mk: update distributed file list.
+
+ * mln/make/dummy_p_edges.hh,
+ * mln/make/dummy_p_vertices.hh,
+ * mln/util/line_graph.hh,
+ * mln/util/internal/graph_base.hh,
+ * mln/util/internal/graph_iter.hh,
+ * mln/util/internal/graph_iter_base.hh,
+ * mln/util/internal/graph_nbh_iter.hh,
+ * mln/util/internal/graph_nbh_iter_base.hh,
+ * mln/util/graph.hh,
+ * mln/morpho/attribute/count_adjacent_vertices.hh,
+ * mln/core/concept/graph.hh: update member signatures with vertex and
+ edge ids.
+
+ * mln/core/site_set/p_graph_piter.hh,
+ * mln/core/internal/graph_psite_base.hh,
+ * mln/core/internal/neighb_niter_impl.hh,
+ * mln/core/internal/graph_psite_base.hh,
+ * mln/core/image/graph_window_piter.hh: comment a conversion
+ operators. Cause ambiguities with iterators/proxies.
+
+ * mln/core/image/vertex_image.hh,
+ * mln/core/image/edge_image.hh: add new members.
+
+ * mln/core/internal/site_iterator_base.hh: add a 'target' typedef.
+
+ * mln/core/site_set/p_edges.hh,
+ * mln/core/site_set/p_vertices.hh: add new constructors.
+
+ * mln/make/rag_and_labeled_wsl.hh: update doc.
+
+ * mln/util/graph_ids.hh,
+ * mln/util/edge.hh,
+ * mln/util/vertex.hh: introduce vertex and edge id types.
+
+ * mln/util/internal/id2element.hh: function mapping ids to graph
+ elements.
+
+ * mln/make/p_edges_with_mass_centers.hh: fix guards.
+
+ * tests/make/dummy_p_vertices.cc,
+ * tests/morpho/graph_image_morpho.cc,
+ * tests/morpho/graph_image_wst.cc,
+ * tests/morpho/line_graph_image_morpho.cc,
+ * tests/morpho/line_graph_image_wst.cc,
+ * tests/util/graph.cc,
+ * tests/util/line_graph.cc: update tests according the new
+ routines/constructors/types.
+
+ * mln/core/concept/object_id.hh: new concept for object ids.
+
+2009-04-27 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
Fix documentation distributed files.
* doc/examples/examples.mk,
diff --git a/milena/headers.mk b/milena/headers.mk
index 590621d..5eaf7f7 100644
--- a/milena/headers.mk
+++ b/milena/headers.mk
@@ -83,6 +83,7 @@ mln/util/internal/vertex_impl.hh \
mln/util/internal/edge_impl.hh \
mln/util/internal/graph_base.hh \
mln/util/internal/boost_graph.hh \
+mln/util/internal/id2element.hh \
mln/util/internal/graph_nbh_iter_base.hh \
mln/util/internal/boost_graph_property.hh \
mln/util/ord_pair.hh \
@@ -110,6 +111,7 @@ mln/util/pix.hh \
mln/util/tree_fast.hh \
mln/util/site_pair.hh \
mln/util/nil.hh \
+mln/util/graph_ids.hh \
mln/util/eat.hh \
mln/util/essential.hh \
mln/data/memset_.hh \
@@ -135,13 +137,13 @@ mln/trace/resume.hh \
mln/trace/quiet.hh \
mln/trace/stop.hh \
mln/trace/essential.hh \
-mln/make/graph.hh \
mln/make/double_neighb2d.hh \
mln/make/image3d.hh \
mln/make/dpoint2d_h.hh \
mln/make/w_window.hh \
mln/make/cell.hh \
mln/make/image.hh \
+mln/make/influence_zone_adjacency_graph.hh \
mln/make/vec.hh \
mln/make/all.hh \
mln/make/dual_neighb.hh \
@@ -153,11 +155,15 @@ mln/make/w_window2d_int.hh \
mln/make/box1d.hh \
mln/make/voronoi.hh \
mln/make/box2d.hh \
+mln/make/p_edges_with_mass_centers.hh \
mln/make/h_mat.hh \
+mln/make/p_vertices_with_mass_centers.hh \
+mln/make/vertex_image.hh \
mln/make/w_window2d.hh \
mln/make/box3d.hh \
mln/make/detachment.hh \
mln/make/region_adjacency_graph.hh \
+mln/make/dummy_p_vertices.hh \
mln/make/relabelfun.hh \
mln/make/pixel.hh \
mln/make/pix.hh \
@@ -166,6 +172,7 @@ mln/make/w_window1d.hh \
mln/make/image2d.hh \
mln/make/w_window_directional.hh \
mln/make/rag_and_labeled_wsl.hh \
+mln/make/dummy_p_edges.hh \
mln/make/w_window3d_int.hh \
mln/make/essential.hh \
mln/make/w_window1d_int.hh \
@@ -213,7 +220,6 @@ mln/fun/vv2v/diff_abs.hh \
mln/fun/vv2v/land.hh \
mln/fun/vv2v/min.hh \
mln/fun/vv2v/essential.hh \
-mln/fun/internal/array_base.hh \
mln/fun/internal/x2x_linear_impl.hh \
mln/fun/internal/ch_function_value_impl.hh \
mln/fun/internal/resolve.hh \
@@ -257,7 +263,6 @@ mln/fun/i2v/all.hh \
mln/fun/i2v/array.hh \
mln/fun/i2v/all_to.hh \
mln/fun/i2v/essential.hh \
-mln/fun/l2l/relabel.hh \
mln/fun/l2l/all.hh \
mln/fun/l2l/wrap.hh \
mln/fun/l2l/essential.hh \
@@ -963,6 +968,7 @@ mln/core/concept/window.hh \
mln/core/concept/value.hh \
mln/core/concept/accumulator.hh \
mln/core/concept/site_set.hh \
+mln/core/concept/object_id.hh \
mln/core/concept/object.hh \
mln/core/concept/meta_fun.hh \
mln/core/concept/delta_point_site.hh \
@@ -1043,6 +1049,7 @@ mln/labeling/foreground.hh \
mln/labeling/regional_maxima.hh \
mln/labeling/wrap.hh \
mln/labeling/compute.hh \
+mln/labeling/pack.hh \
mln/labeling/regional_minima.hh \
mln/labeling/essential.hh \
mln/labeling/fill_holes.hh \
@@ -1138,6 +1145,7 @@ mln/debug/println.spe.hh \
mln/debug/colorize.hh \
mln/debug/slices_2d.hh \
mln/debug/draw_graph.hh \
+mln/debug/filename.hh \
mln/debug/put_word.hh \
mln/debug/histo.hh \
mln/debug/quiet.hh \
@@ -1151,6 +1159,9 @@ mln/estim/all.hh \
mln/estim/sum.hh \
mln/estim/mean.hh \
mln/estim/essential.hh \
+mln/graph/attribute/representative.hh \
+mln/graph/attribute/card.hh \
+mln/graph/compute.hh \
mln/set/uni.hh \
mln/set/unique.hh \
mln/set/inter.hh \
diff --git a/milena/mln/core/concept/graph.hh b/milena/mln/core/concept/graph.hh
index fa07e78..4d43569 100644
--- a/milena/mln/core/concept/graph.hh
+++ b/milena/mln/core/concept/graph.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -33,6 +34,7 @@
/// Definition of the concept of mln::Graph.
# include <mln/core/concept/object.hh>
+# include <mln/util/graph_ids.hh>
namespace mln
{
@@ -81,21 +83,21 @@ namespace mln
void invalidate();
/*
// Vertex and edges oriented.
- unsigned v_other(unsigned id_e, unsigned id_v) const;
+ util::vertex_id_t v_other(const util::edge_id_t& id_e, const util::vertex_id_t& id_v) const;
// Vertex oriented.
size_t v_nmax() const;
- bool has_v(unsigned id_v) const;
- size_t v_nmax_nbh_edges(unsigned id_v) const;
- unsigned v_ith_nbh_edge(unsigned id_v, unsigned i) const;
+ bool has(unsigned id_v) const;
+ size_t v_nmax_nbh_edges(const util::vertex_id_t& id_v) const;
+ util::edge_id_t v_ith_nbh_edge(const util::vertex_id_t& id_v, unsigned i) const;
// Edge oriented.
size_t e_nmax() const;
- bool has_e(unsigned id_e) const;
- unsigned v1(unsigned id_e) const;
- unsigned v2(unsigned id_e) const;
- size_t e_nmax_nbh_edges(unsigned id_e) const;
- unsigned e_ith_nbh_edge(unsigned id_e, unsigned i) const;
+ bool has_e(const util::edge_id_t& id_e) const;
+ util::vertex_id_t v1(const util::edge_id_t& id_e) const;
+ util::vertex_id_t v2(const util::edge_id_t& id_e) const;
+ size_t e_nmax_nbh_edges(const util::edge_id_t& id_e) const;
+ util::edge_id_t e_ith_nbh_edge(const util::edge_id_t& id_e, unsigned i) const;
*/
@@ -120,27 +122,27 @@ namespace mln
// Check methods
const void* (E::*m1)() const = & E::id;
m1 = 0;
- unsigned (E::*m2)(unsigned id_e, unsigned id_v) const = & E::v_other;
+ util::vertex_id_t (E::*m2)(const util::edge_id_t& id_e, const util::vertex_id_t& id_v) const = & E::v_other;
m2 = 0;
size_t (E::*m4)() const = & E::v_nmax;
m4 = 0;
- bool (E::*m5)(unsigned id_v) const = & E::has_v;
+ bool (E::*m5)(const util::vertex_id_t& id_v) const = & E::has_v;
m5 = 0;
- size_t (E::*m6)(unsigned id_v) const = & E::v_nmax_nbh_edges;
+ size_t (E::*m6)(const util::vertex_id_t& id_v) const = & E::v_nmax_nbh_edges;
m6 = 0;
- unsigned (E::*m7)(unsigned id_v, unsigned i) const = & E::v_ith_nbh_edge;
+ util::edge_id_t (E::*m7)(const util::vertex_id_t& id_v, unsigned i) const = & E::v_ith_nbh_edge;
m7 = 0;
size_t (E::*m8)() const = & E::e_nmax;
m8 = 0;
- bool (E::*m9)(unsigned id_e) const = & E::has_e;
+ bool (E::*m9)(const util::edge_id_t& id_e) const = & E::has_e;
m9 = 0;
- unsigned (E::*m10)(unsigned id_e) const = & E::v1;
+ util::vertex_id_t (E::*m10)(const util::edge_id_t& id_e) const = & E::v1;
m10 = 0;
- unsigned (E::*m11)(unsigned id_e) const = & E::v2;
+ util::vertex_id_t (E::*m11)(const util::edge_id_t& id_e) const = & E::v2;
m11 = 0;
- size_t (E::*m12)(unsigned id_e) const = & E::e_nmax_nbh_edges;
+ size_t (E::*m12)(const util::edge_id_t& id_e) const = & E::e_nmax_nbh_edges;
m12 = 0;
- unsigned (E::*m13)(unsigned id_e, unsigned i) const = & E::e_ith_nbh_edge;
+ util::edge_id_t (E::*m13)(const util::edge_id_t& id_e, unsigned i) const = & E::e_ith_nbh_edge;
m13 = 0;
//FIXME: enable this test. Currently does not work because this is
diff --git a/milena/mln/core/concept/object_id.hh b/milena/mln/core/concept/object_id.hh
new file mode 100644
index 0000000..5bf5547
--- /dev/null
+++ b/milena/mln/core/concept/object_id.hh
@@ -0,0 +1,278 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// 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.
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+
+#ifndef MLN_CORE_CONCEPT_OBJECT_ID_HH
+# define MLN_CORE_CONCEPT_OBJECT_ID_HH
+
+/// \file mln/util/internal/element_id.hh
+///
+/// Base class of an object id.
+
+
+# include <mln/core/concept/object.hh>
+# include <mln/value/concept/integer.hh>
+# include <mln/metal/abort.hh>
+
+namespace mln
+{
+
+
+ /// Object category.
+ template <typename E>
+ struct Object_Id;
+
+ template <>
+ struct Object_Id<void>
+ {
+ };
+
+
+
+ /// Base class of an object id.
+ /// \tparam Tag the tag type
+ /// \tparam Equiv the equivalent value.
+ template <typename Tag, typename V>
+ class object_id : public value::Integer< object_id<Tag, V> >
+ {
+ public:
+ /// The underlying type id.
+ typedef V value_t;
+ typedef unsigned equiv;
+ typedef V enc;
+
+ /// Constructors
+ /// @{
+ object_id();
+
+ template <typename V2>
+ object_id(const V2& id);
+
+ template <typename Tag2, typename V2>
+ object_id(const object_id<Tag2,V2>& other);
+ /// @}
+
+ template <typename V2>
+ object_id<Tag,V>& operator=(const V2& e);
+
+ const V& value() const;
+ V& value();
+
+ operator unsigned() const;
+
+ bool is_valid() const;
+ void invalidate();
+
+ unsigned to_equiv() const;
+
+ protected:
+ V id_;
+ };
+
+
+ template <typename Tag, typename V>
+ bool
+ operator==(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs);
+//
+// template <typename Tag, typename V>
+// bool
+// operator<(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs);
+//
+// template <typename Tag, typename V>
+// bool
+// operator<(const object_id<Tag,V>& lhs,
+// const typename object_id<Tag,V>::V& rhs);
+//
+// template <typename Tag, typename V>
+// std::ostream&
+// operator<<(std::ostream& ostr, const object_id<Tag,V>& id);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename Tag, typename V>
+ inline
+ object_id<Tag,V>::object_id()
+ : id_(mln_max(V))
+ {
+ }
+
+ template <typename Tag, typename V>
+ template <typename V2>
+ inline
+ object_id<Tag,V>::object_id(const V2& id)
+ : id_(id)
+ {
+ mlc_converts_to(V2,V)::check();
+ }
+
+ template <typename Tag, typename V>
+ template <typename Tag2, typename V2>
+ inline
+ object_id<Tag,V>::object_id(const object_id<Tag2,V2>& id)
+ {
+ typedef object_id<Tag2,V2> id_t;
+ mlc_abort(id_t)::check();
+ }
+
+ template <typename Tag, typename V>
+ template <typename V2>
+ inline
+ object_id<Tag,V>&
+ object_id<Tag,V>::operator=(const V2& v)
+ {
+ mlc_converts_to(V2,V)::check();
+
+ id_ = v;
+ return *this;
+ }
+
+ template <typename Tag, typename V>
+ inline
+ V&
+ object_id<Tag,V>::value()
+ {
+ return id_;
+ }
+
+ template <typename Tag, typename V>
+ inline
+ const V&
+ object_id<Tag,V>::value() const
+ {
+ return id_;
+ }
+
+ template <typename Tag, typename V>
+ inline
+ object_id<Tag,V>::operator unsigned() const
+ {
+ return id_;
+ }
+
+
+ template <typename Tag, typename V>
+ inline
+ bool
+ object_id<Tag,V>::is_valid() const
+ {
+ return id_ != mln_max(V);
+ }
+
+ template <typename Tag, typename V>
+ inline
+ void
+ object_id<Tag,V>::invalidate()
+ {
+ id_ = mln_max(V);
+ }
+
+ template <typename Tag, typename V>
+ inline
+ unsigned
+ object_id<Tag,V>::to_equiv() const
+ {
+ return id_;
+ }
+
+
+// template <typename Tag, typename V>
+// inline
+// std::ostream&
+// operator<<(std::ostream& ostr, const object_id<Tag,V>& id)
+// {
+// return ostr << id.value();
+// }
+//
+//
+ template <typename Tag, typename V>
+ inline
+ bool
+ operator==(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs)
+ {
+ return lhs.value() == rhs.value();
+ }
+//
+// template <typename Tag, typename V>
+// inline
+// bool
+// operator<(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs)
+// {
+// return lhs.value() < rhs.value();
+// }
+//
+// template <typename Tag, typename V>
+// inline
+// bool
+// operator<(const object_id<Tag,V>& lhs, const V& rhs)
+// {
+// return lhs.value() < rhs;
+// }
+//
+// template <typename Tag, typename V>
+// inline
+// bool
+// operator<=(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs)
+// {
+// return lhs.value() <= rhs.value();
+// }
+//
+// template <typename Tag, typename V>
+// inline
+// bool
+// operator<=(const object_id<Tag,V>& lhs, const V& rhs)
+// {
+// return lhs.value() <= rhs;
+// }
+
+// template <typename Tag, typename V>
+// inline
+// object_id<Tag,V>
+// operator+(const object_id<Tag,V>& lhs, const V& rhs)
+// {
+// return lhs.value() + rhs;
+// }
+//
+// template <typename Tag, typename V>
+// inline
+// object_id<Tag,V>
+// operator+(const object_id<Tag,V>& lhs, const size_t& rhs)
+// {
+// return lhs.value() + rhs;
+// }
+
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+} // end of namespace mln
+
+#endif // ! MLN_CORE_CONCEPT_OBJECT_ID_HH
+
diff --git a/milena/mln/core/image/edge_image.hh b/milena/mln/core/image/edge_image.hh
index 68e7227..9dcbc2a 100644
--- a/milena/mln/core/image/edge_image.hh
+++ b/milena/mln/core/image/edge_image.hh
@@ -73,11 +73,13 @@ namespace mln
template <typename P, typename V, typename G>
struct data< mln::edge_image<P,V,G> >
{
+ typedef typename edge_image<P,V,G>::site_function_t site_function_t;
+
data(const fun::i2v::array<V>& edge_values,
- const p_edges<G,fun::i2v::array<P> >& pv);
+ const p_edges<G,site_function_t>& pe);
fun::i2v::array<V> f_;
- p_edges<G,fun::i2v::array<P> > pset_;
+ p_edges<G,site_function_t> pset_;
};
} // end of namespace mln::internal
@@ -90,19 +92,41 @@ namespace mln
template <typename V, typename G, typename P>
edge_image<P,V,G>
operator | (const fun::i2v::array<V>& edge_values,
- const p_edges<G,fun::i2v::array<P> >& pv);
+ const p_edges<G,fun::i2v::array<P> >& pe);
+
+
+ // Vertex_image_fsite_selector
+
+ namespace internal
+ {
+
+ template <typename P, typename G>
+ struct efsite_selector
+ {
+ typedef fun::i2v::array<P> site_function_t;
+ };
+ template <typename G>
+ struct efsite_selector<void,G>
+ {
+ typedef util::internal::id2element< G,util::edge<G> > site_function_t;
+ };
+
+
+ } // end of namespace mln::internal
+
+
template <typename P, typename V, typename G = util::graph>
class edge_image
: public pw::internal::image_base<fun::i2v::array<V>,
- p_edges<G, fun::i2v::array<P> >,
+ p_edges<G, typename internal::efsite_selector<P,G>::site_function_t >,
edge_image<P,V,G> >
{
typedef pw::internal::image_base<fun::i2v::array<V>,
- p_edges<G, fun::i2v::array<P> >,
+ p_edges<G, typename internal::efsite_selector<P,G>::site_function_t >,
edge_image<P,V,G> > super_;
public:
@@ -112,7 +136,8 @@ namespace mln
tag::graph_<G> > skeleton;
/// Function mapping graph elements to sites.
- typedef fun::i2v::array<P> site_function_t;
+ typedef typename internal::efsite_selector<P,G>::site_function_t
+ site_function_t;
/// Window type
typedef graph_elt_window<G,p_edges<G,site_function_t> > win_t;
@@ -122,12 +147,12 @@ namespace mln
/// Constructors.
/// @{
edge_image();
-
+ edge_image(const p_edges<G, site_function_t>& pe);
edge_image(const Graph<G>& g,
- const Function_i2v< fun::i2v::array<P> >& edge_sites,
+ const Function_i2v< site_function_t >& edge_sites,
const Function_i2v< fun::i2v::array<V> >& edge_values);
- edge_image(const p_edges<G,fun::i2v::array<P> >& pe,
+ edge_image(const p_edges<G, site_function_t >& pe,
const Function_i2v< fun::i2v::array<V> >& edge_values);
template <typename FP, typename FV>
@@ -136,7 +161,7 @@ namespace mln
const Function_i2v<FV>& edge_values);
template <typename FV>
- edge_image(const p_edges<G,fun::i2v::array<P> >& pv,
+ edge_image(const p_edges<G,site_function_t>& pe,
const Function_i2v<FV>& edge_values);
/// @}
@@ -164,9 +189,9 @@ namespace mln
inline
edge_image<P,V,G>
operator | (const fun::i2v::array<V>& edge_values,
- const p_edges<G,fun::i2v::array<P> >& pv)
+ const p_edges<G,fun::i2v::array<P> >& pe)
{
- edge_image<P,V,G> tmp(edge_values, pv);
+ edge_image<P,V,G> tmp(edge_values, pe);
return tmp;
}
@@ -180,7 +205,7 @@ namespace mln
template <typename P, typename V, typename G>
inline
data< mln::edge_image<P,V,G> >::data(const fun::i2v::array<V>& f,
- const p_edges<G,fun::i2v::array<P> >& ps)
+ const p_edges<G,site_function_t>& ps)
: f_(exact(f)),
pset_(ps)
{
@@ -200,20 +225,28 @@ namespace mln
template <typename P, typename V, typename G>
inline
+ edge_image<P,V,G>::edge_image(const p_edges<G,site_function_t>& pe)
+ : super_(fun::i2v::array<V>(pe.nsites()), pe)
+ {
+ }
+
+
+ template <typename P, typename V, typename G>
+ inline
edge_image<P,V,G>::edge_image(const Graph<G>& g,
- const Function_i2v< fun::i2v::array<P> >& edge_sites,
+ const Function_i2v< site_function_t >& edge_sites,
const Function_i2v< fun::i2v::array<V> >& edge_values)
: super_(exact(edge_values),
- p_edges<G,fun::i2v::array<P> >(g, exact(edge_sites)))
+ p_edges<G,site_function_t>(g, exact(edge_sites)))
{
}
template <typename P, typename V, typename G>
inline
- edge_image<P,V,G>::edge_image(const p_edges<G,fun::i2v::array<P> >& pv,
+ edge_image<P,V,G>::edge_image(const p_edges<G,site_function_t>& pe,
const Function_i2v< fun::i2v::array<V> >& edge_values)
- : super_(exact(edge_values), pv)
+ : super_(exact(edge_values), pe)
{
}
@@ -225,9 +258,8 @@ namespace mln
const Function_i2v<FP>& edge_sites,
const Function_i2v<FV>& edge_values)
: super_(convert::to<fun::i2v::array<V> >(exact(edge_values)),
- p_edges<G,fun::i2v::array<P> >(g, exact(edge_sites)))
+ p_edges<G,site_function_t>(g, exact(edge_sites)))
{
- mlc_converts_to(FV,fun::i2v::array<V>)::check();
mlc_equal(mln_result(FP),P)::check();
mlc_equal(mln_result(FV),V)::check();
}
@@ -237,11 +269,10 @@ namespace mln
template <typename P, typename V, typename G>
template <typename FV>
inline
- edge_image<P,V,G>::edge_image(const p_edges<G,fun::i2v::array<P> >& pv,
+ edge_image<P,V,G>::edge_image(const p_edges<G,site_function_t>& pe,
const Function_i2v<FV>& edge_values)
- : super_(convert::to<fun::i2v::array<V> >(exact(edge_values)), pv)
+ : super_(convert::to<fun::i2v::array<V> >(exact(edge_values)), pe)
{
- mlc_converts_to(FV,fun::i2v::array<V>)::check();
mlc_equal(mln_result(FV),V)::check();
}
diff --git a/milena/mln/core/image/graph_window_piter.hh b/milena/mln/core/image/graph_window_piter.hh
index 0bd341e..320599d 100644
--- a/milena/mln/core/image/graph_window_piter.hh
+++ b/milena/mln/core/image/graph_window_piter.hh
@@ -91,10 +91,10 @@ namespace mln
/// Compute the current psite.
mln_psite(W) compute_p_() const;
- /// Convert towards the graph element id.
- operator unsigned() const;
-
/// Return the graph element id.
+ /// FIXME: we do not want to have this member since there is an
+ /// automatic conversion to the graph element.
+ /// C++ does not seem to use this conversion operator.
unsigned id() const;
/// \}
@@ -189,13 +189,13 @@ namespace mln
return iter_;
}
- template <typename S, typename W, typename I>
- inline
- graph_window_piter<S, W, I>::operator unsigned() const
- {
- return iter_.id();
- }
-
+// template <typename S, typename W, typename I>
+// inline
+// graph_window_piter<S, W, I>::operator unsigned() const
+// {
+// return iter_.id();
+// }
+//
template <typename S, typename W, typename I>
inline
unsigned
diff --git a/milena/mln/core/image/vertex_image.hh b/milena/mln/core/image/vertex_image.hh
index 09aa15b..6f92753 100644
--- a/milena/mln/core/image/vertex_image.hh
+++ b/milena/mln/core/image/vertex_image.hh
@@ -40,6 +40,9 @@
# include <mln/pw/internal/image_base.hh>
# include <mln/fun/i2v/array.hh>
+# include <mln/util/internal/id2element.hh>
+
+
namespace mln
{
@@ -72,11 +75,14 @@ namespace mln
template <typename P, typename V, typename G>
struct data< mln::vertex_image<P,V,G> >
{
+ typedef typename vertex_image<P,V,G>::site_function_t site_function_t;
+
+ template <typename F>
data(const fun::i2v::array<V>& vertex_values,
- const p_vertices<G,fun::i2v::array<P> >& pv);
+ const p_vertices<G,F>& pv);
fun::i2v::array<V> f_;
- p_vertices<G,fun::i2v::array<P> > pset_;
+ p_vertices<G,site_function_t> pset_;
};
} // end of namespace mln::internal
@@ -91,25 +97,54 @@ namespace mln
const p_vertices<G,fun::i2v::array<P> >& pv);
+ // Vertex_image_fsite_selector
+
+ namespace internal
+ {
+
+ template <typename P, typename G>
+ struct vfsite_selector
+ {
+ typedef fun::i2v::array<P> site_function_t;
+ };
+
+
+
+ template <typename G>
+ struct vfsite_selector<void,G>
+ {
+ typedef util::internal::id2element< G,util::vertex<G> > site_function_t;
+ };
+
+
+ } // end of namespace mln::internal
+
+
+
template <typename P, typename V, typename G = util::graph>
class vertex_image
: public pw::internal::image_base<fun::i2v::array<V>,
- p_vertices<G, fun::i2v::array<P> >,
+ p_vertices<G, typename internal::vfsite_selector<P,G>::site_function_t >,
vertex_image<P,V,G> >
{
typedef pw::internal::image_base<fun::i2v::array<V>,
- p_vertices<G, fun::i2v::array<P> >,
+ p_vertices<G, typename internal::vfsite_selector<P,G>::site_function_t >,
vertex_image<P,V,G> > super_;
public:
+ typedef typename super_::rvalue rvalue;
+ typedef typename super_::lvalue lvalue;
+
+ /// Function mapping graph elements to sites.
+ typedef typename internal::vfsite_selector<P,G>::site_function_t
+ site_function_t;
+
+
/// Skeleton type.
typedef vertex_image< tag::psite_<P>,
tag::value_<V>,
tag::graph_<G> > skeleton;
- /// Function mapping graph elements to sites.
- typedef fun::i2v::array<P> site_function_t;
-
/// Window type
typedef graph_elt_window<G,p_vertices<G,site_function_t> > win_t;
/// Neighborhood type.
@@ -118,23 +153,24 @@ namespace mln
/// Constructors.
/// @{
vertex_image();
- vertex_image(const Graph<G>& g,
- const Function_i2v< fun::i2v::array<P> >& vertex_sites,
- const Function_i2v< fun::i2v::array<V> >& vertex_values);
-
- vertex_image(const p_vertices<G,fun::i2v::array<P> >& pv,
+ vertex_image(const p_vertices<G, site_function_t>& pv);
+ vertex_image(const p_vertices<G, site_function_t>& pv,
const Function_i2v< fun::i2v::array<V> >& vertex_values);
-
- template <typename FP, typename FV>
- vertex_image(const Graph<G>& g,
- const Function_i2v<FP>& vertex_sites,
- const Function_i2v<FV>& vertex_values);
-
template <typename FV>
- vertex_image(const p_vertices<G,fun::i2v::array<P> >& pv,
+ vertex_image(const p_vertices<G, site_function_t>& pv,
const Function_i2v<FV>& vertex_values);
/// @}
+ using super_::operator();
+
+ /// Value accessors/operators overloads.
+ /// @{
+// rvalue operator()(const util::vertex<G>& v) const;
+// lvalue operator()(const util::vertex<G>& v);
+ rvalue operator()(unsigned v_id) const;
+ lvalue operator()(unsigned v_id);
+ /// @}
+
};
template <typename P, typename V, typename G, typename J>
@@ -159,7 +195,7 @@ namespace mln
inline
vertex_image<P,V,G>
operator | (const fun::i2v::array<V>& vertex_values,
- const p_vertices<G,fun::i2v::array<P> >& pv)
+ const p_vertices<G, fun::i2v::array<P> >& pv)
{
vertex_image<P,V,G> tmp(vertex_values, pv);
return tmp;
@@ -173,9 +209,10 @@ namespace mln
{
template <typename P, typename V, typename G>
+ template <typename F>
inline
data< mln::vertex_image<P,V,G> >::data(const fun::i2v::array<V>& f,
- const p_vertices<G,fun::i2v::array<P> >& ps)
+ const p_vertices<G,F>& ps)
: f_(f),
pset_(ps)
{
@@ -196,18 +233,15 @@ namespace mln
template <typename P, typename V, typename G>
inline
- vertex_image<P,V,G>::vertex_image(const Graph<G>& g,
- const Function_i2v< fun::i2v::array<P> >& vertex_sites,
- const Function_i2v< fun::i2v::array<V> >& vertex_values)
- : super_(exact(vertex_values),
- p_vertices<G,fun::i2v::array<P> >(g, exact(vertex_sites)))
+ vertex_image<P,V,G>::vertex_image(const p_vertices<G,site_function_t>& pv)
+ : super_(fun::i2v::array<V>(pv.nsites()), pv)
{
}
template <typename P, typename V, typename G>
inline
- vertex_image<P,V,G>::vertex_image(const p_vertices<G,fun::i2v::array<P> >& pv,
+ vertex_image<P,V,G>::vertex_image(const p_vertices<G,site_function_t>& pv,
const Function_i2v< fun::i2v::array<V> >& vertex_values)
: super_(exact(vertex_values), pv)
{
@@ -215,32 +249,43 @@ namespace mln
template <typename P, typename V, typename G>
- template <typename FP, typename FV>
+ template <typename FV>
inline
- vertex_image<P,V,G>::vertex_image(const Graph<G>& g,
- const Function_i2v<FP>& vertex_sites,
+ vertex_image<P,V,G>::vertex_image(const p_vertices<G,site_function_t>& pv,
const Function_i2v<FV>& vertex_values)
- : super_(convert::to<fun::i2v::array<V> >(exact(vertex_values)),
- p_vertices<G,fun::i2v::array<P> >(g, vertex_sites))
+ : super_(convert::to<fun::i2v::array<V> >(exact(vertex_values)), pv)
{
- mlc_converts_to(FV,fun::i2v::array<V>)::check();
- mlc_equal(mln_result(FP),P)::check();
mlc_equal(mln_result(FV),V)::check();
}
+// template <typename P, typename V, typename G>
+// typename vertex_image<P,V,G>::rvalue
+// vertex_image<P,V,G>::operator()(const util::vertex<G>& v) const
+// {
+// return this->data_->f_(v.id());
+// }
+//
+// template <typename P, typename V, typename G>
+// typename vertex_image<P,V,G>::lvalue
+// vertex_image<P,V,G>::operator()(const util::vertex<G>& v)
+// {
+// return this->data_->f_(v.id());
+// }
template <typename P, typename V, typename G>
- template <typename FV>
- inline
- vertex_image<P,V,G>::vertex_image(const p_vertices<G,fun::i2v::array<P> >& pv,
- const Function_i2v<FV>& vertex_values)
- : super_(convert::to<fun::i2v::array<V> >(exact(vertex_values)), pv)
+ typename vertex_image<P,V,G>::rvalue
+ vertex_image<P,V,G>::operator()(unsigned v_id) const
{
- mlc_converts_to(FV,fun::i2v::array<V>)::check();
- mlc_equal(mln_result(FV),V)::check();
+ return this->data_->f_(v_id);
}
+ template <typename P, typename V, typename G>
+ typename vertex_image<P,V,G>::lvalue
+ vertex_image<P,V,G>::operator()(unsigned v_id)
+ {
+ return this->data_->f_(v_id);
+ }
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/internal/graph_psite_base.hh b/milena/mln/core/internal/graph_psite_base.hh
index 3767fd2..d02df00 100644
--- a/milena/mln/core/internal/graph_psite_base.hh
+++ b/milena/mln/core/internal/graph_psite_base.hh
@@ -162,8 +162,8 @@ namespace mln
const typename S::graph_t& graph() const;
unsigned id() const;
bool is_valid() const;
- operator unsigned() const;
- operator const typename S::graph_element&() const;
+// operator unsigned() const;
+// operator const typename S::graph_element&() const;
const typename S::graph_element& element() const;
const typename S::graph_element& p_hook_() const;
diff --git a/milena/mln/core/internal/neighb_niter_impl.hh b/milena/mln/core/internal/neighb_niter_impl.hh
index c17ae1d..9079af6 100644
--- a/milena/mln/core/internal/neighb_niter_impl.hh
+++ b/milena/mln/core/internal/neighb_niter_impl.hh
@@ -72,10 +72,10 @@ namespace mln
return internal::force_exact<E>(*this).compute_p_().id();
}
- operator unsigned() const
- {
- return internal::force_exact<E>(*this).compute_p_().id();
- }
+// operator unsigned() const
+// {
+// return internal::force_exact<E>(*this).compute_p_().id();
+// }
};
diff --git a/milena/mln/core/internal/site_iterator_base.hh b/milena/mln/core/internal/site_iterator_base.hh
index 793eee0..893a9b2 100644
--- a/milena/mln/core/internal/site_iterator_base.hh
+++ b/milena/mln/core/internal/site_iterator_base.hh
@@ -59,6 +59,9 @@ namespace mln
struct site_iterator_base : Site_Iterator<E>,
proxy_impl< const mln_psite(S)&, E>
{
+ /// The associated target type.
+ typedef S target;
+
/// The associated site type (as a Site_Proxy).
typedef mln_site(S) site;
diff --git a/milena/mln/core/site_set/p_edges.hh b/milena/mln/core/site_set/p_edges.hh
index ad07474..06af1d3 100644
--- a/milena/mln/core/site_set/p_edges.hh
+++ b/milena/mln/core/site_set/p_edges.hh
@@ -39,6 +39,9 @@
# include <mln/core/site_set/p_graph_piter.hh>
# include <mln/core/site_set/p_edges_psite.hh>
# include <mln/util/graph.hh>
+# include <mln/util/internal/id2element.hh>
+
+# include <mln/metal/equal.hh>
namespace mln
@@ -62,7 +65,7 @@ namespace mln
} // end of namespace mln::trait
- template <typename G, typename F>
+ template <typename G, typename F = util::internal::id2element<G,util::edge<G> > >
class p_edges
: public internal::site_set_base_< mln_result(F), p_edges<G, F> >
{
@@ -92,6 +95,11 @@ namespace mln
/// Construct a graph edge psite set from a graph and a function.
///
/// \param gr The graph upon which the graph edge psite set is built.
+ p_edges(const Graph<G>& gr);
+
+ /// Construct a graph edge psite set from a graph and a function.
+ ///
+ /// \param gr The graph upon which the graph edge psite set is built.
/// \param f the function mapping edges and sites.
p_edges(const Graph<G>& gr, const Function<F>& f);
@@ -197,6 +205,18 @@ namespace mln
template <typename G, typename F>
inline
+ p_edges<G, F>::p_edges(const Graph<G>& g)
+ {
+ typedef util::internal::id2element<G,util::edge<G> > F_REF;
+ mlc_equal(F, F_REF)::check();
+
+ mln_precondition(exact(g).is_valid());
+ g_ = exact(g);
+ f_ = util::internal::id2element< G, util::edge<G> >(g);
+ }
+
+ template <typename G, typename F>
+ inline
p_edges<G, F>::p_edges(const Graph<G>& g, const Function<F>& f)
{
mln_precondition(exact(g).is_valid());
diff --git a/milena/mln/core/site_set/p_graph_piter.hh b/milena/mln/core/site_set/p_graph_piter.hh
index 5642446..dba2b52 100644
--- a/milena/mln/core/site_set/p_graph_piter.hh
+++ b/milena/mln/core/site_set/p_graph_piter.hh
@@ -44,6 +44,7 @@ namespace mln
template <typename S, typename I> class graph_psite;
+
/*------------------------.
| p_graph_piter<S,I>. |
`------------------------*/
@@ -88,9 +89,6 @@ namespace mln
/// Return the underlying graph element iterator.
const iter& hook_elt_() const;
- /// Convert towards the graph element id.
- operator unsigned() const;
-
/// Return the graph element id.
unsigned id() const;
@@ -109,6 +107,33 @@ namespace mln
};
+ namespace internal
+ {
+
+ /// \{
+ /// subject_impl specialization (Proxy)
+ template <typename S, typename I, typename E>
+ struct subject_impl< const p_graph_piter<S,I>&, E >
+ {
+ const typename S::graph_t& graph() const;
+ unsigned id() const;
+
+ private:
+ const E& exact_() const;
+ };
+
+ template <typename S, typename I, typename E>
+ struct subject_impl< p_graph_piter<S,I>&, E >
+ : subject_impl< const p_graph_piter<S,I>&, E >
+ {
+ mln_q_subject(I) element();
+
+ private:
+ E& exact_();
+ };
+ /// \}
+
+ } // end of namespace mln::internal
# ifndef MLN_INCLUDE_ONLY
@@ -195,13 +220,6 @@ namespace mln
template <typename S, typename I>
inline
- p_graph_piter<S,I>::operator unsigned() const
- {
- return iter_.id();
- }
-
- template <typename S, typename I>
- inline
unsigned
p_graph_piter<S,I>::id() const
{
@@ -218,6 +236,55 @@ namespace mln
p_.update_id(iter_.id());
}
+
+
+ namespace internal
+ {
+
+ /// Subject_impl
+
+ template <typename S, typename I, typename E>
+ inline
+ const E&
+ subject_impl< const p_graph_piter<S,I>&, E >::exact_() const
+ {
+ return internal::force_exact<const E>(*this);
+ }
+
+ template <typename S, typename I, typename E>
+ inline
+ const typename S::graph_t&
+ subject_impl< const p_graph_piter<S,I>&, E >::graph() const
+ {
+ return exact_().get_subject().graph();
+ }
+
+ template <typename S, typename I, typename E>
+ inline
+ unsigned
+ subject_impl< const p_graph_piter<S,I>&, E >::id() const
+ {
+ return exact_().get_subject().id();
+ };
+
+ template <typename S, typename I, typename E>
+ inline
+ E&
+ subject_impl< p_graph_piter<S,I>&, E >::exact_()
+ {
+ return internal::force_exact<E>(*this);
+ }
+
+ template <typename S, typename I, typename E>
+ inline
+ mln_q_subject(I)
+ subject_impl< p_graph_piter<S,I>&, E >::element()
+ {
+ return exact_().get_subject().element();
+ }
+
+ } // end of namespace mln::internal
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
diff --git a/milena/mln/core/site_set/p_vertices.hh b/milena/mln/core/site_set/p_vertices.hh
index b20d19b..f158626 100644
--- a/milena/mln/core/site_set/p_vertices.hh
+++ b/milena/mln/core/site_set/p_vertices.hh
@@ -38,6 +38,7 @@
# include <mln/core/site_set/p_graph_piter.hh>
# include <mln/core/site_set/p_vertices_psite.hh>
# include <mln/util/graph.hh>
+# include <mln/util/internal/id2element.hh>
@@ -64,8 +65,7 @@ namespace mln
} // end of namespace mln::trait
-
- template <typename G, typename F>
+ template <typename G, typename F = util::internal::id2element<G,util::vertex<G> > >
class p_vertices
: public internal::site_set_base_< mln_result(F), p_vertices<G,F> >
{
@@ -94,6 +94,11 @@ namespace mln
/// Construct a graph psite set from a graph of points.
/// \param gr The graph upon which the graph psite set is built.
+ /// The identity function is used.
+ p_vertices(const Graph<G>& gr);
+
+ /// Construct a graph psite set from a graph of points.
+ /// \param gr The graph upon which the graph psite set is built.
/// \param f the function which maps a vertex to a site.
p_vertices(const Graph<G>& gr, const Function<F>& f);
@@ -214,6 +219,18 @@ namespace mln
template <typename G, typename F>
inline
+ p_vertices<G,F>::p_vertices(const Graph<G>& g)
+ {
+ typedef util::internal::id2element<G,util::vertex<G> > F_REF;
+ mlc_equal(F, F_REF)::check();
+
+ mln_precondition(exact(g).is_valid());
+ g_ = exact(g);
+ f_ = util::internal::id2element< G, util::vertex<G> >(g);
+ }
+
+ template <typename G, typename F>
+ inline
p_vertices<G,F>::p_vertices(const Graph<G>& g, const Function<F>& f)
{
mln_precondition(exact(g).is_valid());
diff --git a/milena/mln/make/dummy_p_edges.hh b/milena/mln/make/dummy_p_edges.hh
index 927d0d8..7c17aec 100644
--- a/milena/mln/make/dummy_p_edges.hh
+++ b/milena/mln/make/dummy_p_edges.hh
@@ -67,7 +67,7 @@ namespace mln
/// \return A p_edges.
//
template <typename G>
- p_edges< G, pw::cst_<int> >
+ p_edges<G>
dummy_p_edges(const Graph<G>& g);
@@ -91,10 +91,10 @@ namespace mln
template <typename G>
- p_edges< G, pw::cst_<int> >
+ p_edges<G>
dummy_p_edges(const Graph<G>& g)
{
- return dummy_p_edges(g, 0);
+ return p_edges<G>(g);
}
diff --git a/milena/mln/make/dummy_p_vertices.hh b/milena/mln/make/dummy_p_vertices.hh
index 910d02e..c9c643d 100644
--- a/milena/mln/make/dummy_p_vertices.hh
+++ b/milena/mln/make/dummy_p_vertices.hh
@@ -67,7 +67,7 @@ namespace mln
/// \return A p_vertices.
//
template <typename G>
- p_vertices< G, pw::cst_<int> >
+ p_vertices<G>
dummy_p_vertices(const Graph<G>& g);
@@ -91,10 +91,10 @@ namespace mln
template <typename G>
- p_vertices< G, pw::cst_<int> >
+ p_vertices<G>
dummy_p_vertices(const Graph<G>& g)
{
- return dummy_p_vertices(g, 0);
+ return p_vertices<G>(g);
}
diff --git a/milena/mln/make/edge_image.hh b/milena/mln/make/edge_image.hh
new file mode 100644
index 0000000..7ca6980
--- /dev/null
+++ b/milena/mln/make/edge_image.hh
@@ -0,0 +1,164 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_MAKE_EDGE_IMAGE_HH
+# define MLN_MAKE_EDGE_IMAGE_HH
+
+/// \file mln/make/edge_image.hh
+///
+/// Routine to create a edge image.
+
+# include <mln/core/image/edge_image.hh>
+# include <mln/core/image/vertex_image.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/util/internal/id2element.hh>
+
+
+namespace mln
+{
+
+ namespace make
+ {
+
+
+ /// Construct an edge image.
+ ///
+ /// \param[in] g A graph
+ /// \param[in] fv A function mapping edge ids to values.
+ ///
+ /// \return an edge image.
+ //
+ template <typename V, typename G>
+ mln::edge_image<void,V,G>
+ edge_image(const Graph<G>& g, const fun::i2v::array<V>& fv);
+
+
+ /// Construct an edge image.
+ ///
+ /// \param[in] g A graph
+ /// \param[in] fp A function mapping edge ids to sites.
+ /// \param[in] fv A function mapping edge ids to values.
+ ///
+ /// \return an edge image.
+ //
+ template <typename FP, typename FV, typename G>
+ mln::edge_image<mln_result(FP),mln_result(FV),G>
+ edge_image(const Graph<G>& g_,
+ const Function_i2v<FP>& fp,
+ const Function_i2v<FV>& fv);
+
+
+ /// Construct an edge image.
+ ///
+ /// \param[in] v_ima_ A vertex image.
+ /// \param[in] fp A function mapping edge ids to sites.
+ /// \param[in] fv A function mapping two vertex ids to a value.
+ /// The result is associated to the corresponding edge.
+ ///
+ /// \return an edge image.
+ //
+ template <typename P, typename V, typename FP, typename FV, typename G>
+ mln::edge_image<mln_result(FP),mln_result(FV),G>
+ edge_image(const vertex_image<P,V,G>& v_ima_,
+ const Function_v2v<FP>& fp_,
+ const Function_vv2v<FV>& fv_);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename V, typename G>
+ mln::edge_image<void,V,G>
+ edge_image(const Graph<G>& g, const fun::i2v::array<V>& fv)
+ {
+ trace::entering("make::edge_image");
+ mln_precondition(exact(g).is_valid());
+
+ p_vertices<G> pv(g);
+ mln::edge_image<void,V,G> ima(pv, fv);
+
+ trace::exiting("make::edge_image");
+ return ima;
+ }
+
+
+ template <typename FP, typename FV, typename G>
+ mln::edge_image<mln_result(FP),mln_result(FV),G>
+ edge_image(const Graph<G>& g_,
+ const Function_i2v<FP>& fp,
+ const Function_i2v<FV>& fv)
+ {
+ trace::entering("make::edge_image");
+ const G& g = exact(g_);
+ mln_precondition(g.is_valid());
+
+ p_vertices<G,FP> pv(g,fp);
+ mln::edge_image<mln_result(FP),mln_result(FV),G> ima(pv, fv);
+
+ trace::exiting("make::edge_image");
+ return ima;
+ }
+
+
+ template <typename P, typename V, typename FP, typename FV, typename G>
+ mln::edge_image<mln_result(FP),mln_result(FV),G>
+ edge_image(const vertex_image<P,V,G>& v_ima_,
+ const Function_v2v<FP>& fp_,
+ const Function_vv2v<FV>& fv_)
+ {
+ trace::entering("make::edge_image");
+
+ const FP& fp = exact(fp_);
+ const FV& fv = exact(fv_);
+ const vertex_image<P,V,G>& v_ima = exact(v_ima_);
+ mln_precondition(v_ima.is_valid());
+
+ fun::i2v::array<mln_result(FV)> tmp_fv(v_ima.domain().graph().e_nmax());
+
+ p_edges<G,FP> pe(v_ima.domain().graph(), fp);
+
+ typedef mln::edge_image<mln_result(FP),mln_result(FV),G> edge_ima_t;
+ edge_ima_t ima_e(pe, tmp_fv);
+
+ mln_piter(edge_ima_t) e(ima_e.domain());
+ for_all(e)
+ ima_e(e) = fv(v_ima(e.element().v1()), v_ima(e.element().v2()));
+
+ trace::exiting("make::edge_image");
+ return ima_e;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace mln::make
+
+} // end of namespace mln
+
+# endif // ! MLN_MAKE_EDGE_IMAGE_HH
diff --git a/milena/mln/make/p_edges_with_mass_centers.hh b/milena/mln/make/p_edges_with_mass_centers.hh
index 06a2376..8a1db50 100644
--- a/milena/mln/make/p_edges_with_mass_centers.hh
+++ b/milena/mln/make/p_edges_with_mass_centers.hh
@@ -25,8 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_MAKE_P_VERTICES_WITH_MASS_CENTERS_HH
-# define MLN_MAKE_P_VERTICES_WITH_MASS_CENTERS_HH
+#ifndef MLN_MAKE_P_EDGES_WITH_MASS_CENTERS_HH
+# define MLN_MAKE_P_EDGES_WITH_MASS_CENTERS_HH
/// \file mln/make/p_edges_with_mass_centers.hh
///
@@ -118,4 +118,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_MAKE_P_VERTICES_WITH_MASS_CENTERS_HH
+#endif // ! MLN_MAKE_P_EDGES_WITH_MASS_CENTERS_HH
diff --git a/milena/mln/make/rag_and_labeled_wsl.hh b/milena/mln/make/rag_and_labeled_wsl.hh
index 1ad3705..774c78a 100644
--- a/milena/mln/make/rag_and_labeled_wsl.hh
+++ b/milena/mln/make/rag_and_labeled_wsl.hh
@@ -64,33 +64,31 @@ namespace mln
/// \return A couple. First element is the graph, second element is an
/// image with a labeled watershed line.
/*!
- **
- ** \verbatim
- **
- ** |-----------------| |-----------------|
- ** | 1 1 1 0 2 2 0 3 | | . . . 1 . . 2 . |
- ** | 1 1 0 2 2 2 0 3 | | . . 1 . . . 2 . |
- ** | 1 0 4 0 2 0 3 3 | ----> | . 1 . 3 . 4 . . |
- ** | 0 4 4 4 0 5 0 3 | | 1 . . . 5 . 6 . |
- ** |-----------------| |-----------------|
- **
- ** Watershed image Labeled watershed line
- ** (watershed line labeled with 0)
- **
- **
- ** |
- ** |
- ** |
- ** v
- **
- ** 1 -- 2 - 3
- ** \ / /
- ** 4 -- 5
- **
- ** Region Adjacency graph (RAG)
- **
- ** \endverbatim
- **
+ \verbatim
+
+ |-----------------| |-----------------|
+ | 1 1 1 0 2 2 0 3 | | . . . 1 . . 2 . |
+ | 1 1 0 2 2 2 0 3 | | . . 1 . . . 2 . |
+ | 1 0 4 0 2 0 3 3 | ----> | . 1 . 3 . 4 . . |
+ | 0 4 4 4 0 5 0 3 | | 1 . . . 5 . 6 . |
+ |-----------------| |-----------------|
+
+ Watershed image Labeled watershed line
+ (watershed line labeled with 0)
+
+
+ |
+ |
+ |
+ v
+
+ 1 -- 2 - 3
+ \ / /
+ 4 -- 5
+
+ Region Adjacency graph (RAG)
+
+ \endverbatim
*/
template <typename I, typename N>
util::couple<util::graph,mln_concrete(I)>
diff --git a/milena/mln/make/vertex_image.hh b/milena/mln/make/vertex_image.hh
index c5db7ea..dc7e28f 100644
--- a/milena/mln/make/vertex_image.hh
+++ b/milena/mln/make/vertex_image.hh
@@ -44,6 +44,34 @@ namespace mln
{
+ /// Construct a vertex image
+ ///
+ /// \param[in] g A graph.
+ /// \param[in] fv A function mapping vertex ids to values.
+ ///
+ /// \return A vertex image.
+ //
+ template <typename V, typename G>
+ mln::vertex_image<void,V,G>
+ vertex_image(const Graph<G>& g, const fun::i2v::array<V>& fv);
+
+
+ /// Construct a vertex image
+ ///
+ /// \param[in] g_ A graph.
+ /// \param[in] fp A function mapping vertex ids to sites.
+ /// \param[in] fv A function mapping vertex ids to values.
+ ///
+ /// \return A vertex image.
+ //
+ template <typename FP, typename FV, typename G>
+ mln::vertex_image<mln_result(FP),mln_result(FV),G>
+ vertex_image(const Graph<G>& g_,
+ const Function_i2v<FP>& fp,
+ const Function_i2v<FV>& fv);
+
+
+
# ifndef MLN_INCLUDE_ONLY
template <typename V, typename G>
diff --git a/milena/mln/morpho/attribute/count_adjacent_vertices.hh b/milena/mln/morpho/attribute/count_adjacent_vertices.hh
index 49e08b3..bc4ae3c 100644
--- a/milena/mln/morpho/attribute/count_adjacent_vertices.hh
+++ b/milena/mln/morpho/attribute/count_adjacent_vertices.hh
@@ -40,6 +40,7 @@
# include <mln/accu/internal/base.hh>
# include <mln/pw/image.hh>
# include <mln/util/pix.hh>
+# include <mln/util/graph_ids.hh>
namespace mln
{
@@ -114,7 +115,7 @@ namespace mln
/// The value of the counter.
unsigned count__;
/// The set of adjacent vertices.
- std::set<unsigned> vertices_;
+ std::set<util::vertex_id_t> vertices_;
};
diff --git a/milena/mln/util/edge.hh b/milena/mln/util/edge.hh
index 9d9c3fc..0c759db 100644
--- a/milena/mln/util/edge.hh
+++ b/milena/mln/util/edge.hh
@@ -34,24 +34,49 @@
/// Definition of a graph edge.
# include <iostream>
+# include <mln/util/graph_ids.hh>
# include <mln/util/internal/edge_impl.hh>
# include <mln/core/concept/proxy.hh>
+# include <mln/core/concept/site.hh>
namespace mln
{
- namespace util
+ // Forward declaration.
+ namespace util { template<typename G> class edge; }
+
+
+
+ /// edge category flag type.
+ template <typename E>
+ struct Edge
{
+ };
+
+ template <>
+ struct Edge<void>
+ {
+ typedef Site<void> super;
+ };
+
+
- /*-------.
- | Edge. |
- `-------*/
+ namespace util
+ {
/// Edge of a graph \p G.
template <typename G>
class edge : public internal::edge_impl_<G>
{
public:
+ /// Object category.
+ typedef Edge<void> category;
+
+ /// The underlying type used to store edge ids.
+ typedef typename edge_id_t::value_t id_value_t;
+
+ /// The edge type id.
+ typedef edge_id_t id_t;
/// Graph associated type.
typedef G graph_t;
@@ -60,7 +85,8 @@ namespace mln
/// \{
edge();
explicit edge(const G& g);
- edge(const G& g, unsigned id);
+ edge(const G& g, id_value_t id);
+ edge(const G& g, const edge_id_t& id);
/// \}
@@ -72,13 +98,13 @@ namespace mln
void invalidate();
/// Return the edge id.
- unsigned id() const;
+ edge_id_t id() const;
/// Set id_ with \p id;
- void update_id(unsigned id);
+ void update_id(const edge_id_t& id);
/// Conversion to the edge id.
- operator unsigned() const;
+ operator edge_id_t() const;
/// Return a reference to the graph holding this edge.
const G& graph() const;
@@ -91,28 +117,29 @@ namespace mln
/// Vertex and edges oriented.
/// \{
/// Return the vertex id of this edge which is different from \p id_v.
- unsigned v_other(unsigned id_v) const;
+ vertex_id_t
+ v_other(const vertex_id_t& id_v) const;
/// \}
/// Edge oriented.
/// \{
/// Return the lowest vertex id adjacent to this edge.
- unsigned v1() const;
+ vertex_id_t v1() const;
/// Return the highest vertex id adjacent to this edge.
- unsigned v2() const;
+ vertex_id_t v2() const;
/// Return the number max of adjacent edges.
size_t nmax_nbh_edges() const;
/// Return the \p i th adjacent edge.
- unsigned ith_nbh_edge(unsigned i) const;
+ edge_id_t ith_nbh_edge(unsigned i) const;
/// \}
private:
G g_;
- unsigned id_;
+ edge_id_t id_;
};
@@ -141,14 +168,18 @@ namespace mln
template <typename G, typename E>
struct subject_impl< const util::edge<G>, E >
{
- unsigned id() const;
+ util::edge_id_t id() const;
const G& graph() const;
- unsigned v_other(unsigned id_v) const;
- bool is_valid() const;
- unsigned v1() const;
- unsigned v2() const;
+
+ util::vertex_id_t
+ v_other(const util::vertex_id_t& id_v) const;
+
+ util::vertex_id_t v1() const;
+
+ util::vertex_id_t v2() const;
+
size_t nmax_nbh_edges() const;
- unsigned ith_nbh_edge(unsigned i) const;
+ util::edge_id_t ith_nbh_edge(unsigned i) const;
private:
@@ -159,7 +190,7 @@ namespace mln
struct subject_impl< util::edge<G>, E > :
subject_impl< const util::edge<G>, E >
{
- void update_id(unsigned id);
+ void update_id(const util::edge_id_t& id);
void change_graph(const mlc_const(G)& g);
void invalidate();
@@ -199,7 +230,15 @@ namespace mln
template <typename G>
inline
- edge<G>::edge(const G& g, unsigned id)
+ edge<G>::edge(const G& g, id_value_t id)
+ : g_(g), id_(id)
+ {
+ mln_precondition(g_.is_valid() && g.has_e(id));
+ }
+
+ template <typename G>
+ inline
+ edge<G>::edge(const G& g, const edge_id_t& id)
: g_(g), id_(id)
{
mln_precondition(g_.is_valid() && g.has_e(id));
@@ -207,7 +246,7 @@ namespace mln
template <typename G>
inline
- unsigned
+ edge_id_t
edge<G>::id() const
{
return id_;
@@ -216,14 +255,14 @@ namespace mln
template <typename G>
inline
void
- edge<G>::update_id(unsigned id)
+ edge<G>::update_id(const edge_id_t& id)
{
id_ = id;
}
template <typename G>
inline
- edge<G>::operator unsigned() const
+ edge<G>::operator edge_id_t() const
{
return id_;
}
@@ -249,7 +288,7 @@ namespace mln
bool
edge<G>::is_valid() const
{
- return g_.is_valid() && g_.has_e(id_);
+ return g_.is_valid() && id_.is_valid() && g_.has_e(id_);
}
template <typename G>
@@ -257,14 +296,15 @@ namespace mln
void
edge<G>::invalidate()
{
- id_ = mln_max(unsigned);
+ //id_ = mln_max(unsigned);
+ id_.invalidate();
}
template <typename G>
inline
- unsigned
- edge<G>::v_other(unsigned id_v) const
+ vertex_id_t
+ edge<G>::v_other(const vertex_id_t& id_v) const
{
mln_precondition(v1() == id_v || v2() == id_v);
return g_.v_other(id_, id_v);
@@ -272,7 +312,7 @@ namespace mln
template <typename G>
inline
- unsigned
+ vertex_id_t
edge<G>::v1() const
{
mln_precondition(g_.has_e(id_));
@@ -281,7 +321,7 @@ namespace mln
template <typename G>
inline
- unsigned
+ vertex_id_t
edge<G>::v2() const
{
mln_precondition(g_.has_e(id_));
@@ -299,7 +339,7 @@ namespace mln
template <typename G>
inline
- unsigned
+ edge_id_t
edge<G>::ith_nbh_edge(unsigned i) const
{
mln_precondition(g_.has_e(id_));
@@ -351,7 +391,7 @@ namespace mln
template <typename G, typename E>
inline
- unsigned
+ util::edge_id_t
subject_impl< const util::edge<G>, E >::id() const
{
return exact_().get_subject().id();
@@ -367,23 +407,15 @@ namespace mln
template <typename G, typename E>
inline
- unsigned
- subject_impl< const util::edge<G>, E >::v_other(unsigned id_v) const
+ util::vertex_id_t
+ subject_impl< const util::edge<G>, E >::v_other(const util::vertex_id_t& id_v) const
{
return exact_().get_subject().v_other(id_v);
}
template <typename G, typename E>
inline
- bool
- subject_impl< const util::edge<G>, E >::is_valid() const
- {
- return exact_().get_subject().is_valid();
- }
-
- template <typename G, typename E>
- inline
- unsigned
+ util::vertex_id_t
subject_impl< const util::edge<G>, E >::v1() const
{
return exact_().get_subject().v1();
@@ -391,7 +423,7 @@ namespace mln
template <typename G, typename E>
inline
- unsigned
+ util::vertex_id_t
subject_impl< const util::edge<G>, E >::v2() const
{
return exact_().get_subject().v2();
@@ -407,7 +439,7 @@ namespace mln
template <typename G, typename E>
inline
- unsigned
+ util::edge_id_t
subject_impl< const util::edge<G>, E >::ith_nbh_edge(unsigned i) const
{
return exact_().get_subject().ith_nbh_edge(i);
@@ -415,13 +447,13 @@ namespace mln
/*----------------------------------`
- | subject_impl< util::edge<G> |
- \----------------------------------*/
+ | subject_impl< util::edge<G> |
+ \----------------------------------*/
template <typename G, typename E>
inline
void
- subject_impl< util::edge<G>, E >::update_id(unsigned id)
+ subject_impl< util::edge<G>, E >::update_id(const util::edge_id_t& id)
{
return exact_().get_subject().update_id(id);
}
diff --git a/milena/mln/util/graph.hh b/milena/mln/util/graph.hh
index c93e0f9..0614b61 100644
--- a/milena/mln/util/graph.hh
+++ b/milena/mln/util/graph.hh
@@ -36,17 +36,15 @@
# include <mln/util/internal/graph_base.hh>
# include <mln/util/internal/graph_iter.hh>
# include <mln/util/internal/graph_nbh_iter.hh>
+# include <mln/util/vertex.hh>
+# include <mln/util/edge.hh>
# include <mln/util/ord_pair.hh>
-
namespace mln
{
- namespace util
- {
- /// Forward declaration.
- class graph;
- }
+ /// Forward declaration.
+ namespace util { class graph; }
namespace internal
@@ -57,9 +55,9 @@ namespace mln
struct data<util::graph>
{
typedef util::graph G;
- typedef std::vector<std::vector<unsigned> > vertices_t;
- typedef std::vector<util::ord_pair<unsigned> > edges_t;
- typedef std::set<util::ord_pair<unsigned> > edges_set_t;
+ typedef std::vector<std::vector<util::edge_id_t> > vertices_t;
+ typedef std::vector<util::ord_pair<util::vertex_id_t> > edges_t;
+ typedef std::set<util::ord_pair<util::vertex_id_t> > edges_set_t;
data();
/// Constructor.
@@ -159,34 +157,34 @@ namespace mln
/// Add \p n vertices to the graph.
///
/// \return A range of vertex ids.
- std::pair<unsigned, unsigned> add_vertices(unsigned n);
+ std::pair<vertex_id_t, vertex_id_t> add_vertices(unsigned n);
/// Return the vertex whose id is \a v.
/// \{
- vertex_t vertex(unsigned id_v) const;
+ vertex_t vertex(vertex_id_t id_v) const;
/// \}
/// Return the number of vertices in the graph.
size_t v_nmax() const;
/// Check whether a vertex id \p id_v exists in the graph.
- bool has_v(unsigned id_v) const;
- /// Check whether an edge \p v exists in the graph.
- template <typename G>
- bool has_v(const util::vertex<G>& v) const;
+ bool has_v(const vertex_id_t& id_v) const;
/// Return the number of adjacent edges of vertex \p id_v.
- size_t v_nmax_nbh_edges(unsigned id_v) const;
+ size_t v_nmax_nbh_edges(const vertex_id_t& id_v) const;
/// Returns the \p i th edge adjacent to the vertex \p id_v.
- unsigned v_ith_nbh_edge(unsigned id_v, unsigned i) const;
+ edge_id_t
+ v_ith_nbh_edge(const vertex_id_t& id_v,
+ unsigned i) const;
/// Return the number of adjacent vertices of vertex \p id_v.
- size_t v_nmax_nbh_vertices(unsigned id_v) const;
+ size_t v_nmax_nbh_vertices(const vertex_id_t& id_v) const;
/// Returns the \p i th vertex adjacent to the vertex \p id_v.
- unsigned v_ith_nbh_vertex(unsigned id_v, unsigned i) const;
+ vertex_id_t v_ith_nbh_vertex(const vertex_id_t& id_v,
+ unsigned i) const;
/// \}
@@ -197,36 +195,33 @@ namespace mln
///
/// \return The id of the new edge if it does not exist yet;
/// otherwise, return <tt>mln_max(unsigned)</tt>.
- unsigned add_edge(unsigned id_v1, unsigned id_v2);
+ edge_id_t add_edge(const vertex_id_t& id_v1, const vertex_id_t& id_v2);
/// Return the edge whose id is \a e.
- edge_t edge(unsigned e) const;
+ edge_t edge(const edge_id_t& e) const;
/// Return the list of all edges.
- const std::vector<util::ord_pair<unsigned> >& edges() const;
+ const std::vector<util::ord_pair<vertex_id_t> >& edges() const;
/// Return the number of edges in the graph.
size_t e_nmax() const;
/// Return whether \p id_e is in the graph.
- bool has_e(unsigned id_e) const;
- /// Return whether \p e is in the graph.
- template <typename G>
- bool has_e(const util::edge<G>& e) const;
+ bool has_e(const edge_id_t& id_e) const;
/// Return the first vertex associated to the edge \p id_e.
- unsigned v1(unsigned id_e) const;
+ vertex_id_t v1(const edge_id_t& id_e) const;
/// Return the second vertex associated to edge \p id_e
- unsigned v2(unsigned id_e) const;
+ vertex_id_t v2(const edge_id_t& id_e) const;
/// Return the number max of adjacent edge, given an edge \p id_e.
- size_t e_nmax_nbh_edges(unsigned id_e) const;
+ size_t e_nmax_nbh_edges(const edge_id_t& id_e) const;
/// Return the \p i th edge adjacent to the edge \p id_e.
- unsigned e_ith_nbh_edge(unsigned id_e, unsigned i) const;
+ edge_id_t e_ith_nbh_edge(const edge_id_t& id_e, unsigned i) const;
/// Return whether this graph is a subgraph
/// Return true if g and *this have the same graph_id.
@@ -303,7 +298,7 @@ namespace mln
}
inline
- std::pair<unsigned, unsigned>
+ std::pair<vertex_id_t, vertex_id_t>
graph::add_vertices(unsigned n)
{
/* FIXME: This is not thread-proof (these two lines should
@@ -316,7 +311,7 @@ namespace mln
inline
graph::vertex_t
- graph::vertex(unsigned id_v) const
+ graph::vertex(vertex_id_t id_v) const
{
mln_assertion(has_v(id_v));
return vertex_t(*this, id_v);
@@ -332,54 +327,46 @@ namespace mln
inline
bool
- graph::has_v(unsigned id_v) const
+ graph::has_v(const vertex_id_t& id_v) const
{
return id_v < data_->vertices_.size();
}
- template <typename G>
- inline
- bool
- graph::has_v(const util::vertex<G>& v) const
- {
- return v.graph().is_subgraph_of(*this) && has_v(v.id());
- }
-
inline
size_t
- graph::v_nmax_nbh_edges(unsigned id_v) const
+ graph::v_nmax_nbh_edges(const vertex_id_t& id_v) const
{
mln_precondition(has_v(id_v));
return data_->vertices_[id_v].size();
}
inline
- unsigned
- graph::v_ith_nbh_edge(unsigned id_v, unsigned i) const
+ edge_id_t
+ graph::v_ith_nbh_edge(const vertex_id_t& id_v, unsigned i) const
{
mln_precondition(has_v(id_v));
if (i >= v_nmax_nbh_edges(id_v))
- return v_nmax();
+ return edge_id_t();
return data_->vertices_[id_v][i];
}
inline
size_t
- graph::v_nmax_nbh_vertices(unsigned id_v) const
+ graph::v_nmax_nbh_vertices(const vertex_id_t& id_v) const
{
mln_precondition(has_v(id_v));
return v_nmax_nbh_edges(id_v);
}
inline
- unsigned
- graph::v_ith_nbh_vertex(unsigned id_v, unsigned i) const
+ vertex_id_t
+ graph::v_ith_nbh_vertex(const vertex_id_t& id_v, unsigned i) const
{
mln_precondition(has_v(id_v));
- unsigned id_e = v_ith_nbh_edge(id_v, i);
+ edge_id_t id_e = v_ith_nbh_edge(id_v, i);
return v_other(id_e, id_v);
- }
+ }
/*--------------.
@@ -387,8 +374,8 @@ namespace mln
`---------------*/
inline
- unsigned
- graph::add_edge(unsigned id_v1, unsigned id_v2)
+ edge_id_t
+ graph::add_edge(const vertex_id_t& id_v1, const vertex_id_t& id_v2)
{
//FIXME: to be removed! We should not check that, except in without NDEBUG.
// Does this edge already exist in the graph?
@@ -397,7 +384,7 @@ namespace mln
if (data_->edges_set_.find(edge) != data_->edges_set_.end ())
{
// Return the erroneous value.
- return mln_max(unsigned);
+ return edge_id_t();
}
else
{
@@ -406,7 +393,7 @@ namespace mln
/* FIXME: This is not thread-proof (these two lines should
form an atomic section). */
data_->edges_.push_back(edge);
- unsigned id = data_->edges_.size() - 1;
+ edge_id_t id = data_->edges_.size() - 1;
// Update the set of edges.
# ifndef NDEBUG
@@ -424,7 +411,7 @@ namespace mln
}
inline
- const std::vector<util::ord_pair<unsigned> >&
+ const std::vector<util::ord_pair<vertex_id_t> >&
graph::edges() const
{
return this->data_->edges_;
@@ -432,7 +419,7 @@ namespace mln
inline
graph::edge_t
- graph::edge(unsigned e) const
+ graph::edge(const edge_id_t& e) const
{
mln_assertion(e < e_nmax());
return edge_t(*this, e);
@@ -447,30 +434,22 @@ namespace mln
inline
bool
- graph::has_e(unsigned id_e) const
+ graph::has_e(const edge_id_t& id_e) const
{
return id_e < data_->edges_.size();
}
- template <typename G>
- inline
- bool
- graph::has_e(const util::edge<G>& e) const
- {
- return e.graph().is_subgraph_of(*this) && has_e(e.id());
- }
-
inline
- unsigned
- graph::v1(unsigned id_e) const
+ vertex_id_t
+ graph::v1(const edge_id_t& id_e) const
{
mln_precondition(has_e(id_e));
return data_->edges_[id_e].first();
}
inline
- unsigned
- graph::v2(unsigned id_e) const
+ vertex_id_t
+ graph::v2(const edge_id_t& id_e) const
{
mln_precondition(has_e(id_e));
return data_->edges_[id_e].second();
@@ -478,15 +457,15 @@ namespace mln
inline
size_t
- graph::e_nmax_nbh_edges(unsigned id_e) const
+ graph::e_nmax_nbh_edges(const edge_id_t& id_e) const
{
mln_precondition(has_e(id_e));
return v_nmax_nbh_edges(v1(id_e)) + v_nmax_nbh_edges(v2(id_e));
}
inline
- unsigned
- graph::e_ith_nbh_edge(unsigned id_e, unsigned i) const
+ edge_id_t
+ graph::e_ith_nbh_edge(const edge_id_t& id_e, unsigned i) const
{
mln_precondition(has_e(id_e));
if (i >= e_nmax_nbh_edges(id_e))
diff --git a/milena/tests/make/dummy_p_vertices.cc b/milena/mln/util/graph_ids.hh
similarity index 54%
copy from milena/tests/make/dummy_p_vertices.cc
copy to milena/mln/util/graph_ids.hh
index 6cfa2b8..df3e981 100644
--- a/milena/tests/make/dummy_p_vertices.cc
+++ b/milena/mln/util/graph_ids.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -21,55 +22,41 @@
// 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
+// License.
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file tests/make/dummy_p_vertices.cc
+#ifndef MLN_UTIL_GRAPH_IDS_HH
+# define MLN_UTIL_GRAPH_IDS_HH
+
+/// \file mln/util/graph_ids.hh
///
-/// Tests on mln::make::dummy_p_vertices.
+/// Definition of graph element ids.
+# include <mln/core/concept/object_id.hh>
-#include <mln/core/image/image2d.hh>
-#include <mln/core/site_set/p_array.hh>
-#include <mln/util/graph.hh>
+namespace mln
+{
-#include <mln/value/label_8.hh>
+ namespace util
+ {
-#include <mln/make/dummy_p_vertices.hh>
+ /// Object id vertex tag
+ struct vertex_tag;
-int main()
-{
- using namespace mln;
+ /// Vertex id type.
+ typedef object_id<vertex_tag, unsigned> vertex_id_t;
- typedef util::graph G;
- G g;
- g.add_vertices(5);
- g.add_edge(1,2);
- g.add_edge(1,3);
- g.add_edge(4,3);
- g.add_edge(4,2);
+ // Edge tag for object_id.
+ struct edge_tag;
- {
- typedef p_vertices<G, pw::cst_<int> > pe_t;
- pe_t pe = make::dummy_p_vertices(g);
-
- mln_assertion(pe.nsites() == 4);
- mln_piter_(pe_t) p(pe);
- for_all(p)
- mln_assertion(p == 0);
- }
+ // Edge id type.
+ typedef object_id<edge_tag, unsigned> edge_id_t;
- {
- typedef p_vertices<G, pw::cst_<point2d> > pe_t;
- pe_t pe = make::dummy_p_vertices(g, point2d::plus_infty());
+ } // end of namespace mln::util
- mln_assertion(pe.nsites() == 4);
- mln_piter_(pe_t) p(pe);
- for_all(p)
- mln_assertion(p == point2d::plus_infty());
- }
+} // end of namespace mln
-}
+#endif // ! MLN_UTIL_GRAPH_IDS_HH
diff --git a/milena/mln/util/internal/graph_base.hh b/milena/mln/util/internal/graph_base.hh
index f011324..7724087 100644
--- a/milena/mln/util/internal/graph_base.hh
+++ b/milena/mln/util/internal/graph_base.hh
@@ -70,13 +70,14 @@ namespace mln
protected:
/// The type of a vertex.
typedef util::vertex<E> vertex_t;
- /// Internal vertex data type
- typedef std::vector<unsigned> vertex_data_t;
-
/// The type of an edge.
typedef util::edge<E> edge_t;
+
+ /// Internal vertex data type
+ typedef std::vector<edge_id_t> vertex_data_t;
+
/// Internal edge data type.
- typedef ord_pair<unsigned> edge_data_t;
+ typedef ord_pair<vertex_id_t> edge_data_t;
public:
/// Misc. methods
@@ -102,7 +103,7 @@ namespace mln
/// Vertex and edge oriented methods.
/// \{
/// Returns the other adjacent vertex id of a given edge id \p id_e.
- unsigned v_other(unsigned id_e, unsigned id_v) const;
+ vertex_id_t v_other(const edge_id_t& id_e, const vertex_id_t& id_v) const;
/// \}
// FIXME: We might want to externalize this in routine of
@@ -169,8 +170,8 @@ namespace mln
template<typename E>
inline
- unsigned
- graph_base<E>::v_other(unsigned id_e, unsigned id_v) const
+ vertex_id_t
+ graph_base<E>::v_other(const edge_id_t& id_e, const vertex_id_t& id_v) const
{
const E *g = exact(this);
mln_precondition(g->has_e(id_e));
diff --git a/milena/mln/util/internal/graph_iter.hh b/milena/mln/util/internal/graph_iter.hh
index 6da2e3c..7cfdcfd 100644
--- a/milena/mln/util/internal/graph_iter.hh
+++ b/milena/mln/util/internal/graph_iter.hh
@@ -62,11 +62,11 @@ namespace mln
protected:
/// Returns the id of the first element.
/// Called in start();
- unsigned start_id_() const;
+ util::vertex_id_t start_id_() const;
/// Returns the next element id.
/// Called in next();
- unsigned next_id_() const;
+ util::vertex_id_t next_id_() const;
friend class graph_iter_base<G, util::vertex<G>, vertex_fwd_iterator<G> >;
};
@@ -90,11 +90,11 @@ namespace mln
protected:
/// Returns the id of the first element.
/// Called in start();
- unsigned start_id_() const;
+ util::vertex_id_t start_id_() const;
/// Returns the next element id.
/// Called in next();
- unsigned next_id_() const;
+ util::vertex_id_t next_id_() const;
friend class graph_iter_base<G, util::vertex<G>, vertex_bkd_iterator<G> >;
};
@@ -118,11 +118,11 @@ namespace mln
protected:
/// Returns the id of the first element.
/// Called in start();
- unsigned start_id_() const;
+ util::edge_id_t start_id_() const;
/// Returns the next element id.
/// Called in next();
- unsigned next_id_() const;
+ util::edge_id_t next_id_() const;
friend class graph_iter_base<G, util::edge<G>, edge_fwd_iterator<G> >;
};
@@ -146,11 +146,11 @@ namespace mln
protected:
/// Returns the id of the first element.
/// Called in start();
- unsigned start_id_() const;
+ util::edge_id_t start_id_() const;
/// Returns the next element id.
/// Called in next();
- unsigned next_id_() const;
+ util::edge_id_t next_id_() const;
friend class graph_iter_base<G, util::edge<G>, edge_bkd_iterator<G> >;
};
@@ -180,7 +180,7 @@ namespace mln
template <typename G>
inline
- unsigned
+ util::vertex_id_t
vertex_fwd_iterator<G>::start_id_() const
{
return 0;
@@ -188,7 +188,7 @@ namespace mln
template <typename G>
inline
- unsigned
+ util::vertex_id_t
vertex_fwd_iterator<G>::next_id_() const
{
return this->p_.id() + 1;
@@ -215,7 +215,7 @@ namespace mln
template <typename G>
inline
- unsigned
+ util::vertex_id_t
vertex_bkd_iterator<G>::start_id_() const
{
return this->p_.graph().v_nmax() - 1;
@@ -223,7 +223,7 @@ namespace mln
template <typename G>
inline
- unsigned
+ util::vertex_id_t
vertex_bkd_iterator<G>::next_id_() const
{
return this->p_.id() - 1;
@@ -250,7 +250,7 @@ namespace mln
template <typename G>
inline
- unsigned
+ util::edge_id_t
edge_fwd_iterator<G>::start_id_() const
{
return 0;
@@ -258,7 +258,7 @@ namespace mln
template <typename G>
inline
- unsigned
+ util::edge_id_t
edge_fwd_iterator<G>::next_id_() const
{
return this->p_.id() + 1;
@@ -285,7 +285,7 @@ namespace mln
template <typename G>
inline
- unsigned
+ util::edge_id_t
edge_bkd_iterator<G>::start_id_() const
{
return this->p_.graph().e_nmax() - 1;
@@ -293,7 +293,7 @@ namespace mln
template <typename G>
inline
- unsigned
+ util::edge_id_t
edge_bkd_iterator<G>::next_id_() const
{
return this->p_.id() - 1;
diff --git a/milena/mln/util/internal/graph_iter_base.hh b/milena/mln/util/internal/graph_iter_base.hh
index 10cbe64..b8b9fb9 100644
--- a/milena/mln/util/internal/graph_iter_base.hh
+++ b/milena/mln/util/internal/graph_iter_base.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -64,11 +65,15 @@ namespace mln
/// Go to the next value.
void next();
- /// Return current index
- unsigned index() const;
+ /// Return the element id.
+ typename Elt::id_t id() const;
/// Conversion operator. Returns the element id.
- operator unsigned() const;
+ operator typename Elt::id_t() const;
+
+ /// Conversion operator. Returns the element id.
+ /// FIXME: May cause ambiguities.
+ operator typename Elt::id_value_t() const;
/// Conversion operator. Returns the graph element.
operator const Elt&() const;
@@ -134,15 +139,22 @@ namespace mln
template <typename G, typename Elt, typename E>
inline
- unsigned
- graph_iter_base<G, Elt, E>::index() const
+ typename Elt::id_t
+ graph_iter_base<G, Elt, E>::id() const
+ {
+ return p_.id();
+ }
+
+ template <typename G, typename Elt, typename E>
+ inline
+ graph_iter_base<G, Elt, E>::operator typename Elt::id_t() const
{
return p_.id();
}
template <typename G, typename Elt, typename E>
inline
- graph_iter_base<G, Elt, E>::operator unsigned() const
+ graph_iter_base<G, Elt, E>::operator typename Elt::id_value_t() const
{
return p_.id();
}
diff --git a/milena/mln/util/internal/graph_nbh_iter.hh b/milena/mln/util/internal/graph_nbh_iter.hh
index b99de7b..9d7d245 100644
--- a/milena/mln/util/internal/graph_nbh_iter.hh
+++ b/milena/mln/util/internal/graph_nbh_iter.hh
@@ -538,7 +538,7 @@ namespace mln
// since it is computed thanks to the edge neighboors of its
// two vertices.
// We do not want the current edge to be part of its neighbors.
- unsigned e_id = this->c_->ith_nbh_edge(this->i_);
+ util::edge_id_t e_id = this->c_->ith_nbh_edge(this->i_);
while (e_id == this->c_->id())
{
this->i_ = next_id_();
diff --git a/milena/mln/util/internal/graph_nbh_iter_base.hh b/milena/mln/util/internal/graph_nbh_iter_base.hh
index 2654055..3e8e958 100644
--- a/milena/mln/util/internal/graph_nbh_iter_base.hh
+++ b/milena/mln/util/internal/graph_nbh_iter_base.hh
@@ -63,11 +63,19 @@ namespace mln
/// Go to the next value.
void next();
- /// Return current index
+ /// Return current index.
+ /// (The current element is the i-th neighbor)
unsigned index() const;
- /// Conversion operator. Returns the element ID.
- operator unsigned() const;
+ /// Returns the element ID.
+ typename Elt::id_t id() const;
+
+ /// Conversion operator. Returns the element id.
+ operator typename Elt::id_t() const;
+
+ /// Conversion operator. Returns the element id.
+ /// FIXME: May cause ambiguities.
+ operator typename Elt::id_value_t() const;
/// The psite around which this iterator moves.
const C& center() const;
@@ -173,7 +181,22 @@ namespace mln
template <typename G, typename C, typename Elt, typename E>
inline
- nbh_iterator_base<G,C,Elt,E>::operator unsigned() const
+ typename Elt::id_t
+ nbh_iterator_base<G,C,Elt,E>::id() const
+ {
+ return elt_.id();
+ }
+
+ template <typename G, typename C, typename Elt, typename E>
+ inline
+ nbh_iterator_base<G,C,Elt,E>::operator typename Elt::id_t() const
+ {
+ return elt_.id();
+ }
+
+ template <typename G, typename C, typename Elt, typename E>
+ inline
+ nbh_iterator_base<G,C,Elt,E>::operator typename Elt::id_value_t() const
{
return elt_.id();
}
diff --git a/milena/mln/util/internal/id2element.hh b/milena/mln/util/internal/id2element.hh
new file mode 100644
index 0000000..d574dc3
--- /dev/null
+++ b/milena/mln/util/internal/id2element.hh
@@ -0,0 +1,100 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// 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.
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_UTIL_INTERNAL_ID2VERTEX_HH
+# define MLN_UTIL_INTERNAL_ID2VERTEX_HH
+
+/// \file mln/util/id2element.hh
+///
+/// Function constructing a element from an id.
+
+#include <mln/core/concept/graph.hh>
+
+namespace mln
+{
+
+ namespace util
+ {
+
+ namespace internal
+ {
+
+ template <typename G, typename Elt>
+ struct id2element : Function_i2v< id2element<G,Elt> >
+ {
+ typedef Elt result;
+
+ id2element();
+ id2element(const Graph<G>& g);
+ Elt operator()(unsigned id) const;
+
+ G g_;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename G, typename Elt>
+ inline
+ id2element<G,Elt>::id2element()
+ {
+ }
+
+ template <typename G, typename Elt>
+ inline
+ id2element<G,Elt>::id2element(const Graph<G>& g)
+ : g_(exact(g))
+ {
+ }
+
+ template <typename G, typename Elt>
+ inline
+ Elt
+ id2element<G,Elt>::operator()(unsigned id) const
+ {
+ mln_assertion(g_.is_valid());
+ mln_assertion(g_.has(Elt(g_,id)));
+ /// FIXME: cannot check whether the graph has
+ /// its element since we must call the proper member according
+ /// to the element type (has_v or has_e)!
+ return Elt(g_, id);
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace mln::util::internal
+
+ } // end of namespace mln::util
+
+} // end of namespace mln
+
+
+# endif // ! MLN_UTIL_INTERNAL_ID2VERTEX_HH
+
diff --git a/milena/mln/util/line_graph.hh b/milena/mln/util/line_graph.hh
index ae49cbc..8ecf7b2 100644
--- a/milena/mln/util/line_graph.hh
+++ b/milena/mln/util/line_graph.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of the Olena Library. This library is free
@@ -30,6 +30,7 @@
# define MLN_UTIL_LINE_GRAPH_HH
/// \file mln/util/line_graph.hh
+///
/// Definitions of undirected graphs.
# include <mln/util/internal/graph_base.hh>
@@ -55,9 +56,9 @@ namespace mln
template <typename G>
struct data< util::line_graph<G> >
{
-
- typedef std::vector<std::vector<unsigned> > vertices_t;
- typedef std::vector<util::ord_pair<unsigned> > edges_t;
+ typedef util::line_graph<G> lg_t;
+ typedef std::vector<std::vector<util::edge_id_t> > vertices_t;
+ typedef std::vector<util::ord_pair<util::vertex_id_t> > edges_t;
data();
data(const G& g);
@@ -153,30 +154,30 @@ namespace mln
/// \{
/// Return the vertex whose id is \a v.
/// \{
- vertex_t vertex(unsigned id_v) const;
+ vertex_t vertex(const vertex_id_t& id_v) const;
/// \}
/// Return the number of vertices in the graph.
size_t v_nmax() const;
/// Check whether a vertex id \p id_v exists in the graph.
- bool has_v(unsigned id_v) const;
+ bool has_v(const vertex_id_t& id_v) const;
/// Check whether an edge \p v exists in the graph.
template <typename G2>
- bool has_v(const util::vertex<G2>& v) const;
+ bool has(const util::vertex<G2>& v) const;
/// Return the number of adjacent edges of vertex \p id_v.
- size_t v_nmax_nbh_edges(unsigned id_v) const;
+ size_t v_nmax_nbh_edges(const vertex_id_t& id_v) const;
/// Returns the \p i th edge adjacent to the vertex \p id_v.
- unsigned v_ith_nbh_edge(unsigned id_v, unsigned i) const;
+ edge_id_t v_ith_nbh_edge(const vertex_id_t& id_v, unsigned i) const;
/// Return the number of adjacent vertices of vertex \p id_v.
- size_t v_nmax_nbh_vertices(unsigned id_v) const;
+ size_t v_nmax_nbh_vertices(const vertex_id_t& id_v) const;
/// Returns the \p i th vertex adjacent to the vertex \p id_v.
- unsigned v_ith_nbh_vertex(unsigned id_v, unsigned i) const;
+ vertex_id_t v_ith_nbh_vertex(const vertex_id_t& id_v, unsigned i) const;
/// \}
@@ -185,29 +186,30 @@ namespace mln
/// Edge oriented.
/// \{
/// Return the edge whose id is \a e.
- edge_t edge(unsigned e) const;
+ edge_t edge(const edge_id_t& e) const;
/// Return the number of edges in the graph.
size_t e_nmax() const;
/// Return whether \p id_e is in the graph.
- bool has_e(unsigned id_e) const;
+ bool has_e(const util::edge_id_t& id_e) const;
+
/// Return whether \p e is in the graph.
template <typename G2>
- bool has_e(const util::edge<G2>& e) const;
+ bool has(const util::edge<G2>& e) const;
/// Return the first vertex associated to the edge \p id_e.
- unsigned v1(unsigned id_e) const;
+ vertex_id_t v1(const edge_id_t& id_e) const;
/// Return the second vertex associated to edge \p id_e
- unsigned v2(unsigned id_e) const;
+ vertex_id_t v2(const edge_id_t& id_e) const;
/// Return the number max of adjacent edge, given an edge \p id_e.
- size_t e_nmax_nbh_edges(unsigned id_e) const;
+ size_t e_nmax_nbh_edges(const edge_id_t& id_e) const;
/// Return the \p i th edge adjacent to the edge \p id_e.
- unsigned e_ith_nbh_edge(unsigned id_e, unsigned i) const;
+ edge_id_t e_ith_nbh_edge(const edge_id_t& id_e, unsigned i) const;
/// Return whether this graph is a subgraph
/// Return true if g and *this have the same graph_id.
@@ -251,23 +253,29 @@ namespace mln
g_ = g;
// Initialize vertices and edges.
- std::set<util::ord_pair<unsigned> > edges_set;
+ //FIXME: use an adjacency matrix!!
+ std::set<util::ord_pair<util::vertex_id_t> > edges_set;
+
vertices_.resize(g.e_nmax());
mln_edge_iter(G) e(g);
mln_edge_nbh_edge_iter(G) ne(e);
for_all(e)
+ {
+ util::vertex_id_t v1(e.id().value());
for_all(ne)
{
- util::ord_pair<unsigned> edge(e, ne);
+ util::vertex_id_t v2(ne.id().value());
+ util::ord_pair<util::vertex_id_t> edge(v1, v2);
if (edges_set.find(edge) == edges_set.end())
{
- vertices_[e].push_back(edges_.size());
- vertices_[ne].push_back(edges_.size());
+ vertices_[v1].push_back(edges_.size());
+ vertices_[v2].push_back(edges_.size());
edges_set.insert(edge);
edges_.push_back(edge);
}
}
+ }
}
template <typename G>
@@ -302,7 +310,7 @@ namespace mln
template <typename G>
inline
typename line_graph<G>::vertex_t
- line_graph<G>::vertex(unsigned id_v) const
+ line_graph<G>::vertex(const vertex_id_t& id_v) const
{
mln_assertion(has_v(id_v));
return vertex_t(*this, id_v);
@@ -320,16 +328,16 @@ namespace mln
template <typename G>
inline
bool
- line_graph<G>::has_v(unsigned id_v) const
+ line_graph<G>::has_v(const vertex_id_t& id_v) const
{
- return data_->g_.has_e(id_v);
+ return data_->g_.has_v(id_v);
}
template <typename G>
template <typename G2>
inline
bool
- line_graph<G>::has_v(const util::vertex<G2>& v) const
+ line_graph<G>::has(const util::vertex<G2>& v) const
{
//FIXME: not sure...
return v.graph().is_subgraph_of(*this) && has_v(v.id());
@@ -338,7 +346,7 @@ namespace mln
template <typename G>
inline
size_t
- line_graph<G>::v_nmax_nbh_edges(unsigned id_v) const
+ line_graph<G>::v_nmax_nbh_edges(const vertex_id_t& id_v) const
{
mln_precondition(has_v(id_v));
return data_->vertices_[id_v].size();
@@ -346,8 +354,8 @@ namespace mln
template <typename G>
inline
- unsigned
- line_graph<G>::v_ith_nbh_edge(unsigned id_v, unsigned i) const
+ edge_id_t
+ line_graph<G>::v_ith_nbh_edge(const vertex_id_t& id_v, unsigned i) const
{
mln_precondition(has_v(id_v));
if (i >= v_nmax_nbh_edges(id_v))
@@ -358,7 +366,7 @@ namespace mln
template <typename G>
inline
size_t
- line_graph<G>::v_nmax_nbh_vertices(unsigned id_v) const
+ line_graph<G>::v_nmax_nbh_vertices(const vertex_id_t& id_v) const
{
mln_precondition(has_v(id_v));
return v_nmax_nbh_edges(id_v);
@@ -366,8 +374,8 @@ namespace mln
template <typename G>
inline
- unsigned
- line_graph<G>::v_ith_nbh_vertex(unsigned id_v, unsigned i) const
+ vertex_id_t
+ line_graph<G>::v_ith_nbh_vertex(const vertex_id_t& id_v, unsigned i) const
{
mln_precondition(has_v(id_v));
@@ -383,7 +391,7 @@ namespace mln
template <typename G>
inline
typename line_graph<G>::edge_t
- line_graph<G>::edge(unsigned e) const
+ line_graph<G>::edge(const edge_id_t& e) const
{
mln_assertion(e < e_nmax());
return edge_t(*this, e);
@@ -400,7 +408,7 @@ namespace mln
template <typename G>
inline
bool
- line_graph<G>::has_e(unsigned id_e) const
+ line_graph<G>::has_e(const edge_id_t& id_e) const
{
return id_e < data_->edges_.size();
}
@@ -409,15 +417,15 @@ namespace mln
template <typename G2>
inline
bool
- line_graph<G>::has_e(const util::edge<G2>& e) const
+ line_graph<G>::has(const util::edge<G2>& e) const
{
return e.graph().is_subgraph_of(*this) && has_e(e.id());
}
template <typename G>
inline
- unsigned
- line_graph<G>::v1(unsigned id_e) const
+ vertex_id_t
+ line_graph<G>::v1(const edge_id_t& id_e) const
{
mln_precondition(has_e(id_e));
return data_->edges_[id_e].first();
@@ -425,8 +433,8 @@ namespace mln
template <typename G>
inline
- unsigned
- line_graph<G>::v2(unsigned id_e) const
+ vertex_id_t
+ line_graph<G>::v2(const edge_id_t& id_e) const
{
mln_precondition(has_e(id_e));
return data_->edges_[id_e].second();
@@ -435,7 +443,7 @@ namespace mln
template <typename G>
inline
size_t
- line_graph<G>::e_nmax_nbh_edges(unsigned id_e) const
+ line_graph<G>::e_nmax_nbh_edges(const edge_id_t& id_e) const
{
mln_precondition(has_e(id_e));
return v_nmax_nbh_edges(v1(id_e)) + v_nmax_nbh_edges(v2(id_e));
@@ -443,8 +451,8 @@ namespace mln
template <typename G>
inline
- unsigned
- line_graph<G>::e_ith_nbh_edge(unsigned id_e, unsigned i) const
+ edge_id_t
+ line_graph<G>::e_ith_nbh_edge(const edge_id_t& id_e, unsigned i) const
{
mln_precondition(has_e(id_e));
if (i >= e_nmax_nbh_edges(id_e))
diff --git a/milena/mln/util/vertex.hh b/milena/mln/util/vertex.hh
index 9b55f9b..4b43ef3 100644
--- a/milena/mln/util/vertex.hh
+++ b/milena/mln/util/vertex.hh
@@ -30,6 +30,7 @@
# define MLN_UTIL_VERTEX_HH
# include <iostream>
+# include <mln/util/graph_ids.hh>
# include <mln/util/internal/vertex_impl.hh>
# include <mln/core/concept/proxy.hh>
@@ -42,15 +43,42 @@
namespace mln
{
+ // Forward declaration.
+ namespace util { template<typename G> class vertex; }
+
+ /// Vertex category flag type.
+ template <typename E>
+ struct Vertex
+ {
+ };
+
+ template <>
+ struct Vertex<void>
+ {
+ typedef Site<void> super;
+ };
+
+
+
namespace util
{
/// Vertex of a graph \p G.
template<typename G>
- class vertex : public internal::vertex_impl_<G>
+ class vertex
+ : public Site< vertex<G> >,
+ public internal::vertex_impl_<G>
{
public:
+ /// Object category.
+ typedef Vertex<void> Category;
+
+ /// The underlying type used to store vertex ids.
+ typedef typename vertex_id_t::value_t id_value_t;
+
+ /// The vertex type id.
+ typedef vertex_id_t id_t;
/// Graph associated type.
typedef G graph_t;
@@ -59,7 +87,8 @@ namespace mln
/// \{
vertex();
explicit vertex(const G& g);
- vertex(const G& g, unsigned id);
+ vertex(const G& g, const id_value_t& id);
+ vertex(const G& g, const vertex_id_t& id);
/// \}
/// Check whether the vertex is still part of the graph.
@@ -67,10 +96,11 @@ namespace mln
/// Invalidate that vertex.
void invalidate();
- unsigned other(unsigned id_e) const;
+ /// Returns the other vertex located on edge \p id_e.
+ vertex_id_t other(const edge_id_t& id_e) const;
/// Returns the ith edge starting from this vertex.
- unsigned ith_nbh_edge(unsigned i) const;
+ edge_id_t ith_nbh_edge(unsigned i) const;
/// Returns the number max of edges starting from this vertex.
/// If g_ is a sub graph of another graph, nmax will be retrived from
@@ -78,7 +108,7 @@ namespace mln
unsigned nmax_nbh_edges() const;
/// Returns the ith vertex adjacent to this vertex.
- unsigned ith_nbh_vertex(unsigned i) const;
+ vertex_id_t ith_nbh_vertex(unsigned i) const;
/// Returns the number max of vertices adjacent to this vertex.
unsigned nmax_nbh_vertices() const;
@@ -87,20 +117,21 @@ namespace mln
void change_graph(const G& g);
/// Update the vertex id.
- void update_id(unsigned id);
+ void update_id(const vertex_id_t& id);
/// Returns the graph pointer this vertex belongs to.
const G& graph() const;
/// Returns the vertex id.
- unsigned id() const;
+ const vertex_id_t& id() const;
/// Conversion to the vertex id.
- operator unsigned() const;
+ /// FIXME: May cause ambiguities... :(
+ operator vertex_id_t() const;
protected:
G g_;
- unsigned id_;
+ vertex_id_t id_;
};
@@ -135,14 +166,18 @@ namespace mln
template <typename G, typename E>
struct subject_impl< const util::vertex<G>, E >
{
- bool is_valid() const;
+// Can't be provided since there is an ambiguity with the iterator's
+// member.
+//
+// bool is_valid() const;
+
const G& graph() const;
- unsigned id() const;
+ const util::vertex_id_t& id() const;
- unsigned other(unsigned id_e) const;
- unsigned ith_nbh_edge(unsigned i) const;
+ util::vertex_id_t other(const util::edge_id_t& id_e) const;
+ util::edge_id_t ith_nbh_edge(unsigned i) const;
unsigned nmax_nbh_edges() const;
- unsigned ith_nbh_vertex(unsigned i) const;
+ util::vertex_id_t ith_nbh_vertex(unsigned i) const;
unsigned nmax_nbh_vertices() const;
private:
@@ -155,7 +190,7 @@ namespace mln
{
void invalidate();
void change_graph(const G& g);
- void update_id(unsigned id);
+ void update_id(const util::vertex_id_t& id);
private:
E& exact_();
@@ -195,7 +230,15 @@ namespace mln
template<typename G>
inline
- vertex<G>::vertex(const G& g, unsigned id)
+ vertex<G>::vertex(const G& g, const id_value_t& id)
+ : g_(g), id_(id)
+ {
+ mln_assertion(is_valid());
+ }
+
+ template<typename G>
+ inline
+ vertex<G>::vertex(const G& g, const vertex_id_t& id)
: g_(g), id_(id)
{
mln_assertion(is_valid());
@@ -219,8 +262,8 @@ namespace mln
template<typename G>
inline
- unsigned
- vertex<G>::other(unsigned id_e) const
+ vertex_id_t
+ vertex<G>::other(const edge_id_t& id_e) const
{
mln_precondition(g_.has_v(id_));
mln_precondition(g_.has_e(id_e));
@@ -230,7 +273,7 @@ namespace mln
template<typename G>
inline
- unsigned
+ edge_id_t
vertex<G>::ith_nbh_edge(unsigned i) const
{
mln_precondition(g_.has_v(id_));
@@ -248,7 +291,7 @@ namespace mln
template<typename G>
inline
- unsigned
+ vertex_id_t
vertex<G>::ith_nbh_vertex(unsigned i) const
{
mln_precondition(g_.has_v(id_));
@@ -275,7 +318,7 @@ namespace mln
template<typename G>
inline
void
- vertex<G>::update_id(unsigned id)
+ vertex<G>::update_id(const vertex_id_t& id)
{
id_ = id;
}
@@ -290,7 +333,7 @@ namespace mln
template<typename G>
inline
- unsigned
+ const vertex_id_t&
vertex<G>::id() const
{
return id_;
@@ -298,7 +341,7 @@ namespace mln
template<typename G>
inline
- vertex<G>::operator unsigned() const
+ vertex<G>::operator vertex_id_t() const
{
return id_;
}
@@ -344,14 +387,6 @@ namespace mln
template <typename G, typename E>
inline
- bool
- subject_impl< const util::vertex<G>, E >::is_valid() const
- {
- return exact_().get_subject().is_valid();
- }
-
- template <typename G, typename E>
- inline
const G&
subject_impl< const util::vertex<G>, E >::graph() const
{
@@ -360,7 +395,7 @@ namespace mln
template <typename G, typename E>
inline
- unsigned
+ const util::vertex_id_t&
subject_impl< const util::vertex<G>, E >::id() const
{
return exact_().get_subject().id();
@@ -370,15 +405,15 @@ namespace mln
template <typename G, typename E>
inline
- unsigned
- subject_impl< const util::vertex<G>, E >::other(unsigned id_e) const
+ util::vertex_id_t
+ subject_impl< const util::vertex<G>, E >::other(const util::edge_id_t& id_e) const
{
return exact_().get_subject().other(id_e);
}
template <typename G, typename E>
inline
- unsigned
+ util::edge_id_t
subject_impl< const util::vertex<G>, E >::ith_nbh_edge(unsigned i) const
{
return exact_().get_subject().ith_nbh_edge(i);
@@ -394,7 +429,7 @@ namespace mln
template <typename G, typename E>
inline
- unsigned
+ util::vertex_id_t
subject_impl< const util::vertex<G>, E >::ith_nbh_vertex(unsigned i) const
{
return exact_().get_subject().ith_nbh_vertex(i);
@@ -435,7 +470,7 @@ namespace mln
template <typename G, typename E>
inline
void
- subject_impl< util::vertex<G>, E >::update_id(unsigned id)
+ subject_impl< util::vertex<G>, E >::update_id(const util::vertex_id_t& id)
{
exact_().get_subject().update_id(id);
};
diff --git a/milena/tests/make/dummy_p_vertices.cc b/milena/tests/make/dummy_p_vertices.cc
index 6cfa2b8..344d72c 100644
--- a/milena/tests/make/dummy_p_vertices.cc
+++ b/milena/tests/make/dummy_p_vertices.cc
@@ -55,7 +55,7 @@ int main()
typedef p_vertices<G, pw::cst_<int> > pe_t;
pe_t pe = make::dummy_p_vertices(g);
- mln_assertion(pe.nsites() == 4);
+ mln_assertion(pe.nsites() == 5);
mln_piter_(pe_t) p(pe);
for_all(p)
mln_assertion(p == 0);
@@ -65,7 +65,7 @@ int main()
typedef p_vertices<G, pw::cst_<point2d> > pe_t;
pe_t pe = make::dummy_p_vertices(g, point2d::plus_infty());
- mln_assertion(pe.nsites() == 4);
+ mln_assertion(pe.nsites() == 5);
mln_piter_(pe_t) p(pe);
for_all(p)
mln_assertion(p == point2d::plus_infty());
diff --git a/milena/tests/morpho/graph_image_morpho.cc b/milena/tests/morpho/graph_image_morpho.cc
index 35b3045..5f42933 100644
--- a/milena/tests/morpho/graph_image_morpho.cc
+++ b/milena/tests/morpho/graph_image_morpho.cc
@@ -42,6 +42,7 @@
#include <mln/core/var.hh>
#include <mln/fun/i2v/array.hh>
#include <mln/util/graph.hh>
+#include <mln/make/vertex_image.hh>
#include <mln/debug/draw_graph.hh>
#include <mln/debug/iota.hh>
@@ -102,8 +103,8 @@ int main()
for (unsigned i = 0; i < iota.size(); ++i)
iota(i) = 10 + i;
- typedef vertex_image<point2d,unsigned,util::graph> ima_t;
- ima_t ima(g, sites, iota);
+ typedef vertex_image<point2d, unsigned, util::graph> ima_t;
+ ima_t ima = make::vertex_image(g, sites, iota);
/*-------------------------------------.
| Image representation/visualization. |
diff --git a/milena/tests/morpho/graph_image_wst.cc b/milena/tests/morpho/graph_image_wst.cc
index 7eb1c24..c3d0fc6 100644
--- a/milena/tests/morpho/graph_image_wst.cc
+++ b/milena/tests/morpho/graph_image_wst.cc
@@ -38,6 +38,7 @@
#include <mln/core/var.hh>
#include <mln/fun/i2v/array.hh>
#include <mln/util/graph.hh>
+#include <mln/make/vertex_image.hh>
#include <mln/morpho/meyer_wst.hh>
@@ -95,8 +96,8 @@ int main()
for (unsigned i = 0; i < iota.size(); ++i)
iota(i) = 10 + i;
- typedef vertex_image<point2d,unsigned,util::graph> ima_t;
- ima_t ima(g,sites,iota);
+ typedef vertex_image<point2d, unsigned, util::graph> ima_t;
+ ima_t ima = make::vertex_image(g, sites, iota);
/*------.
| WST. |
diff --git a/milena/tests/morpho/line_graph_image_morpho.cc b/milena/tests/morpho/line_graph_image_morpho.cc
index 3a5becb..adee818 100644
--- a/milena/tests/morpho/line_graph_image_morpho.cc
+++ b/milena/tests/morpho/line_graph_image_morpho.cc
@@ -38,6 +38,7 @@
#include <mln/util/line_graph.hh>
#include <mln/util/graph.hh>
#include <mln/util/site_pair.hh>
+#include <mln/make/vertex_image.hh>
#include <mln/morpho/erosion.hh>
#include <mln/morpho/dilation.hh>
@@ -103,8 +104,8 @@ int main()
for (unsigned i = 0; i < iota.size(); ++i)
iota(i) = 10 + i;
- typedef vertex_image<P,unsigned,util::line_graph<util::graph> > ima_t;
- ima_t ima(lg, sites, iota);
+ typedef vertex_image< P, unsigned, util::line_graph<util::graph> > ima_t;
+ ima_t ima = make::vertex_image(lg, sites, iota);
/*-------------------------------.
diff --git a/milena/tests/morpho/line_graph_image_wst.cc b/milena/tests/morpho/line_graph_image_wst.cc
index afc39ba..67af966 100644
--- a/milena/tests/morpho/line_graph_image_wst.cc
+++ b/milena/tests/morpho/line_graph_image_wst.cc
@@ -39,6 +39,7 @@
#include <mln/util/graph.hh>
#include <mln/util/line_graph.hh>
#include <mln/util/site_pair.hh>
+#include <mln/make/vertex_image.hh>
#include <mln/morpho/watershed/flooding.hh>
@@ -105,7 +106,7 @@ int main()
sites(9) = P(point2d(1,2), point2d(1,3)); // Site associated to vertex 6.
// Edge values.
- typedef fun::i2v::array<int> edge_values_t;
+ typedef fun::i2v::array<unsigned> edge_values_t;
edge_values_t edge_values(10);
static const unsigned values[] = { 0, 10, 5, 2, 4, 6, 0, 3, 5, 2 };
@@ -113,7 +114,7 @@ int main()
edge_values(i) = values[i];
typedef vertex_image< P, unsigned, util::line_graph<util::graph> > ima_t;
- ima_t ima(lg, sites, edge_values);
+ ima_t ima = make::vertex_image(lg, sites, edge_values);
/*------------.
diff --git a/milena/tests/util/graph.cc b/milena/tests/util/graph.cc
index d832023..7e3910e 100644
--- a/milena/tests/util/graph.cc
+++ b/milena/tests/util/graph.cc
@@ -53,26 +53,26 @@ int main ()
unsigned i = 0;
mln_vertex_fwd_iter_(util::graph) v(g);
for_all(v)
- mln_assertion(i++ == v.index());
+ mln_assertion(i++ == v.id());
mln_assertion(i != 0);
i = 0;
mln_edge_fwd_iter_(util::graph) e(g);
for_all(e)
- mln_assertion(i++ == e.index());
+ mln_assertion(i++ == e.id());
mln_assertion(i != 0);
}
{
unsigned i = g.v_nmax() - 1;
mln_vertex_bkd_iter_(util::graph) v(g);
for_all(v)
- mln_assertion(i-- == v.index());
+ mln_assertion(i-- == v.id());
mln_assertion(i != g.v_nmax() - 1);
i = g.e_nmax() - 1;
mln_edge_bkd_iter_(util::graph) e(g);
for_all(e)
- mln_assertion(i-- == e.index());
+ mln_assertion(i-- == e.id());
mln_assertion(i != g.e_nmax() - 1);
}
@@ -84,7 +84,7 @@ int main ()
{
unsigned i = 0;
for_all(n)
- mln_assertion(i++ == n.index());
+ mln_assertion(i++ == n.id());
mln_assertion(i != 0);
}
}
@@ -95,7 +95,7 @@ int main ()
{
unsigned i = v.nmax_nbh_edges();
for_all(e)
- mln_assertion(--i == e.index());
+ mln_assertion(--i == e.id());
mln_assertion((v.nmax_nbh_edges() == 0 && i == 0) || i != v.nmax_nbh_edges());
}
}
diff --git a/milena/tests/util/line_graph.cc b/milena/tests/util/line_graph.cc
index 1a65dee..811a695 100644
--- a/milena/tests/util/line_graph.cc
+++ b/milena/tests/util/line_graph.cc
@@ -61,13 +61,13 @@ int main()
unsigned i = 0;
mln_vertex_fwd_iter_(LG) v(lg);
for_all(v)
- mln_assertion(i++ == v.index());
+ mln_assertion(i++ == v.id());
mln_assertion(i != 0);
i = 0;
mln_edge_fwd_iter_(LG) e(lg);
for_all(e)
- mln_assertion(i++ == e.index());
+ mln_assertion(i++ == e.id());
mln_assertion(i != 0);
}
@@ -76,13 +76,13 @@ int main()
unsigned i = lg.v_nmax() - 1;
mln_vertex_bkd_iter_(LG) v(lg);
for_all(v)
- mln_assertion(i-- == v.index());
+ mln_assertion(i-- == v.id());
mln_assertion(i != lg.v_nmax() - 1);
i = lg.e_nmax() - 1;
mln_edge_bkd_iter_(LG) e(lg);
for_all(e)
- mln_assertion(i-- == e.index());
+ mln_assertion(i-- == e.id());
mln_assertion(i != lg.e_nmax() - 1);
}
@@ -94,7 +94,7 @@ int main()
{
unsigned i = 0;
for_all(n)
- mln_assertion(i++ == n.index());
+ mln_assertion(i++ == n.id());
mln_assertion(i != 0);
}
}
@@ -107,7 +107,7 @@ int main()
{
unsigned i = v.nmax_nbh_edges();
for_all(e)
- mln_assertion(--i == e.index());
+ mln_assertion(--i == e.id());
mln_assertion((v.nmax_nbh_edges() == 0 && i == 0) || i != v.nmax_nbh_edges());
}
}
--
1.5.6.5
1
0