Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- 9625 discussions
02 Oct '08
URL: https://svn.lrde.epita.fr/svn/scool/branches/scool-ng
ChangeLog:
2008-10-02 Maxime van Noppen <yabo(a)lrde.epita.fr>
Start work on where clauses : handle inheritance
* Declaration.str: Handle where clauses for simple classes
* (ie non-template).
* Class.str: Handle the inheritance relationship taking care of using
* the correct 'Exact' parameter depending on the class being 'final'
* or not.
Class.str | 45 +++++++++++++++++++++++++++++++++++++++++++++
Declaration.str | 10 +++++++---
2 files changed, 52 insertions(+), 3 deletions(-)
Index: branches/scool-ng/src/scoolt/Class.str
===================================================================
--- branches/scool-ng/src/scoolt/Class.str (revision 104)
+++ branches/scool-ng/src/scoolt/Class.str (revision 105)
@@ -48,3 +48,48 @@
cqualif -> [(CxxType("typename"), "Exact")]
where
<?Some("abstract") <+ ?None()> cqualif
+
+ AddExactParameter(| cqualif, cxx_idf):
+ SimpleType(type) -> StaticFunctionCall(Identifier(type), Parameters([params]))
+ where
+ <ExactParameter(| cqualif, cxx_idf)> [] => params
+
+ ExactParameter(| cqualif, cxx_idf):
+ _ -> Identifier(idf)
+ where
+ <? Some("final")> cqualif
+ ; <? CxxId(idf)> cxx_idf
+ // FIXME : I only have the cxx_idf and rather want the scl_idf to build my SFC
+
+ ExactParameter(| cqualif, cxx_idf):
+ _ -> Identifier("Exact")
+ where
+ <? None()> cqualif
+
+ CheckDaughter(| scl_idf):
+ daughter -> 42 // The result isn't used
+ where
+ <?Identifier(idf)> scl_idf
+ ; <eq> (daughter, idf)
+
+ CheckDaughter(| scl_idf):
+ daughter -> <say(<concat-strings> [ "Error: class name \"", daughter, "\" doest not match with \"", idf, "\"" ]); fail>
+ where
+ <?Identifier(idf)> scl_idf
+
+ // FIXME: allow other inheritances than the public one
+ InheritanceToCxx(| cqualif, cxx_idf):
+ mother -> ("public", cxx_mother)
+ where
+ <AddExactParameter(| cqualif, cxx_idf)> mother => cxx_mother
+
+ // Handle where clauses
+
+ ClassWhereClauseToCxx(|cqualif, idf, body):
+ Inherits(daughter, mother) -> CxxClassDecl(cxx_params, cxx_idf, cxx_mother, cxx_body)
+ where
+ <CheckDaughter(| idf)> daughter // Check if we are the daughter
+ ; <AddExactType(| cqualif)> [] => cxx_params
+ ; <IdentifierToCxx> idf => cxx_idf
+ ; <InheritanceToCxx(| cqualif, cxx_idf)> mother => cxx_mother
+ ; <ClassBodyToCxx> body => cxx_body
Index: branches/scool-ng/src/scoolt/Declaration.str
===================================================================
--- branches/scool-ng/src/scoolt/Declaration.str (revision 104)
+++ branches/scool-ng/src/scoolt/Declaration.str (revision 105)
@@ -60,14 +60,18 @@
////////////////////////////////////////////////////////////////////////////////
- // Class //
+ // Classes //
////////////////////////////////////////////////////////////////////////////////
DeclarationToCxx:
- ClassDefinition(cqualif, idf, wclause, ClassBlock(body)) -> CxxClassDecl(cxx_params, cxx_idf, [], cxx_body)
+ ClassDefinition(cqualif, idf, None(), ClassBlock(body)) -> CxxClassDecl(cxx_params, cxx_idf, [], cxx_body)
where
<AddExactType(|cqualif)> [] => cxx_params
; <IdentifierToCxx> idf => cxx_idf
- ; <?None> wclause
; <ClassBodyToCxx> body => cxx_body
+ DeclarationToCxx:
+ ClassDefinition(cqualif, idf, Some(ClassWhereClause([wclause])), ClassBlock(body)) -> cxx_code
+ where
+ <ClassWhereClauseToCxx(|cqualif, idf, body)> wclause => cxx_code
+
--
\__/ \__/
(00) Maxime `yabo` van Noppen (00)
___) \ Epita 2009 / (___
(_____/ \_____)
1
0
URL: https://svn.lrde.epita.fr/svn/scool/branches/scool-ng
ChangeLog:
2008-10-02 Maxime van Noppen <yabo(a)lrde.epita.fr>
Add tests on classes
* class/scool_ast/inheritance_001.aterm,
* class/scool_ast/inheritance_002.aterm: Update regarding grammar
* changes.
* class/scool_ast/inheritance_004.aterm: New.
* class/scool_src/inheritance_004.scl: New.
scool_ast/inheritance_001.aterm | 2 +-
scool_ast/inheritance_002.aterm | 2 +-
scool_ast/inheritance_004.aterm | 1 +
scool_src/inheritance_004.scl | 3 +++
4 files changed, 6 insertions(+), 2 deletions(-)
Index: branches/scool-ng/tests/class/scool_ast/inheritance_001.aterm
===================================================================
--- branches/scool-ng/tests/class/scool_ast/inheritance_001.aterm (revision 103)
+++ branches/scool-ng/tests/class/scool_ast/inheritance_001.aterm (revision 104)
@@ -1 +1 @@
-Program([ClassDefinition(None,Identifier("Bar"),None,ClassBlock([])),ClassDefinition(None,Identifier("Foo"),Some(ClassWhereClause([Inherits("Foo","Bar")])),ClassBlock([]))])
+Program([ClassDefinition(None,Identifier("Bar"),None,ClassBlock([])),ClassDefinition(None,Identifier("Foo"),Some(ClassWhereClause([Inherits("Foo",SimpleType("Bar"))])),ClassBlock([]))])
Index: branches/scool-ng/tests/class/scool_ast/inheritance_002.aterm
===================================================================
--- branches/scool-ng/tests/class/scool_ast/inheritance_002.aterm (revision 103)
+++ branches/scool-ng/tests/class/scool_ast/inheritance_002.aterm (revision 104)
@@ -1 +1 @@
-Program([ClassDefinition(None,Identifier("Animal"),None,ClassBlock([])),ClassDefinition(None,Identifier("Mammal"),Some(ClassWhereClause([Inherits("Mammal","Animal")])),ClassBlock([])),ClassDefinition(Some("final"),Identifier("Monkey"),Some(ClassWhereClause([Inherits("Monkey","Mammal")])),ClassBlock([]))])
+Program([ClassDefinition(None,Identifier("Animal"),None,ClassBlock([])),ClassDefinition(None,Identifier("Mammal"),Some(ClassWhereClause([Inherits("Mammal",SimpleType("Animal"))])),ClassBlock([])),ClassDefinition(Some("final"),Identifier("Monkey"),Some(ClassWhereClause([Inherits("Monkey",SimpleType("Mammal"))])),ClassBlock([]))])
Index: branches/scool-ng/tests/class/scool_ast/inheritance_004.aterm
===================================================================
--- branches/scool-ng/tests/class/scool_ast/inheritance_004.aterm (revision 0)
+++ branches/scool-ng/tests/class/scool_ast/inheritance_004.aterm (revision 104)
@@ -0,0 +1 @@
+Program([ClassDefinition(None,Identifier("Cat"),Some(ClassWhereClause([Inherits("Cat",StaticFunctionCall(Identifier("Foo"),Parameters([Integer("42")])))])),ClassBlock([]))])
Index: branches/scool-ng/tests/class/scool_src/inheritance_004.scl
===================================================================
--- branches/scool-ng/tests/class/scool_src/inheritance_004.scl (revision 0)
+++ branches/scool-ng/tests/class/scool_src/inheritance_004.scl (revision 104)
@@ -0,0 +1,3 @@
+Cat : class where Cat -> Foo[42] =
+{
+}
--
\__/ \__/
(00) Maxime `yabo` van Noppen (00)
___) \ Epita 2009 / (___
(_____/ \_____)
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Add nearest neighbor interpolation.
* mln/fun/x2x/interpol/nneighbor.hh: Add this interpolation.
* mln/fun/x2x/interpol/bilinear.hh: Fix include.
* mln/fun/x2x/interpol/linear.hh: Fix include.
* mln/fun/x2x/interpol/test.cc: Remove.
bilinear.hh | 2 +
linear.hh | 2 +
nneighbor.hh | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 103 insertions(+)
Index: mln/fun/x2x/interpol/bilinear.hh
--- mln/fun/x2x/interpol/bilinear.hh (revision 2472)
+++ mln/fun/x2x/interpol/bilinear.hh (working copy)
@@ -31,6 +31,8 @@
# include <mln/core/image/image2d.hh>
# include <mln/core/concept/function.hh>
# include <mln/fun/internal/selector.hh>
+# include <mln/convert/to.hh>
+# include <mln/algebra/vec.hh>
/*! \file mln/fun/x2x/interpol/bilinear.hh
*
Index: mln/fun/x2x/interpol/linear.hh
--- mln/fun/x2x/interpol/linear.hh (revision 2472)
+++ mln/fun/x2x/interpol/linear.hh (working copy)
@@ -36,6 +36,8 @@
# include <mln/core/image/image1d.hh>
# include <mln/core/concept/function.hh>
# include <mln/fun/internal/selector.hh>
+# include <mln/convert/to.hh>
+# include <mln/algebra/vec.hh>
namespace mln
{
Index: mln/fun/x2x/interpol/nneighbor.hh
--- mln/fun/x2x/interpol/nneighbor.hh (revision 0)
+++ mln/fun/x2x/interpol/nneighbor.hh (revision 0)
@@ -0,0 +1,99 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_X2X_INTERPOL_NNEIGHBOR_HH
+# define MLN_FUN_X2X_INTERPOL_NNEIGHBOR_HH
+
+# include <mln/core/concept/function.hh>
+# include <mln/fun/internal/selector.hh>
+# include <mln/algebra/vec.hh>
+# include <mln/convert/to.hh>
+
+/*! \file mln/fun/x2x/interpol/nneighbor.hh
+ *
+ * \brief Define a nneighbor interpolation of values from an underlying image
+ */
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace x2x
+ {
+
+ namespace interpol
+ {
+
+ template < typename I >
+ struct nneighbor
+ : public fun::internal::selector_<const algebra::vec<3,float>,
+ // 3,float is a dummy parameter (real is n,T)
+ mln_value(I), nneighbor<I> >::ret
+ {
+ typedef mln_value(I) result;
+
+ nneighbor(const I& ima);
+
+ template < unsigned n, typename T >
+ mln_value(I)
+ operator()(const algebra::vec<n,T>& x) const;
+
+ const I& ima;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template < typename I >
+ nneighbor<I>::nneighbor(const I& ima) : ima(ima)
+ {
+ }
+
+ template < typename I >
+ template < unsigned n, typename T >
+ mln_value(I)
+ nneighbor<I>::operator()(const algebra::vec<n,T>& x) const
+ {
+ mln_psite(I) p = convert::to<mln_psite(I)>(x);
+ return ima(p);
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::x2x::interpol
+
+ } // end of namespace mln::fun::x2x
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_X2X_INTERPOL_NNEIGHBOR_HH
1
0
cleanup-2008 2472: Several fixes and updates on windows and morphology.
by Thierry Geraud 02 Oct '08
by Thierry Geraud 02 Oct '08
02 Oct '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Several fixes and updates on windows and morphology.
* mln/core/concept/window.hh (regular, has): New checks.
Layout.
* mln/convert/to_window.hh (to_window): Update version for
neighborhoods.
Cut useless dependencies to line_graph stuff.
* mln/set/inter.hh (inter): Remove window version.
* mln/win/shift.hh: Copy to...
* mln/win/inter.hh: ...this new file.
(shift): Model...
(operator&&): ...this new operator.
Update.
* mln/win/multiple.hh (FIXME): Fix.
(change_target): New.
Use it.
* mln/win/diff.hh (operator-): Move to mln namespace to
disambiguate calls.
(check): New checks.
* mln/morpho/thin_fit.hh,
* mln/morpho/thinning.hh,
* mln/morpho/hit_or_miss.hh,
* mln/morpho/thickening.hh,
* mln/morpho/thick_miss.hh: Factor test routines.
Use them.
(set::inter): Replace by operator && on windows.
* mln/morpho/dilation.hh (convert::to_window): Update to .win().
* mln/morpho/includes.hh (to_window): Remove include; obsolete.
(set/inter): Update to win/inter.
convert/to_window.hh | 53 +--------------------------
core/concept/window.hh | 14 ++++++-
morpho/dilation.hh | 2 -
morpho/hit_or_miss.hh | 55 ++++++++++++++++++++++------
morpho/includes.hh | 3 -
morpho/thick_miss.hh | 4 +-
morpho/thickening.hh | 37 ++++++++++++++++---
morpho/thin_fit.hh | 35 +++++++++++++++---
morpho/thinning.hh | 38 +++++++++++++++++--
set/inter.hh | 30 ---------------
win/diff.hh | 6 ---
win/inter.hh | 95 +++++++++++++++++++++++++++++--------------------
win/multiple.hh | 16 +++++++-
13 files changed, 232 insertions(+), 156 deletions(-)
Index: mln/core/concept/window.hh
--- mln/core/concept/window.hh (revision 2471)
+++ mln/core/concept/window.hh (working copy)
@@ -143,6 +143,10 @@
{
static void run_extra()
{
+ // Associated type.
+ typedef mln_regular(E) regular;
+
+ // Methods.
bool (E::*m1)() const = &E::is_centered;
m1 = 0;
bool (E::*m2)() const = &E::is_symmetric;
@@ -152,21 +156,27 @@
unsigned (E::*m4)() const = &E::delta;
m4 = 0;
}
+
static void run(mln::trait::window::definition::unique)
{
typedef mln_dpsite(E) D;
- const D& (E::*m)(unsigned) const = &E::dp;
- m = 0;
+ const D& (E::*m1)(unsigned) const = &E::dp;
+ m1 = 0;
+ bool (E::*m2)(const D&) const = &E::has;
+ m2 = 0;
run_extra();
}
+
static void run(mln::trait::window::definition::n_ary)
{
run_extra();
}
+
static void run(mln::trait::window::definition::varying)
{
/* No requirement. */
}
+
static void run()
{
run(mln_trait_window_definition(E)());
Index: mln/convert/to_window.hh
--- mln/convert/to_window.hh (revision 2471)
+++ mln/convert/to_window.hh (working copy)
@@ -42,34 +42,16 @@
# include <mln/pw/cst.hh>
# include <mln/metal/is_a.hh>
-# include <mln/core/image/line_graph_elt_neighborhood.hh>
-# include <mln/core/image/line_graph_elt_window.hh>
-
namespace mln
{
namespace convert
{
- // Return type trait of neighborhood-to-window conversions.
-
- /* FIXME: This trait should probably be moved elsewhere. And/or
- it could encapsulate the conversion function, too. */
-
- // Default case.
- template <typename N>
- struct nbh_to_win_trait
- { typedef window<mln_dpsite(N)> ret; };
-
- // Case of line_graph_elt_neighborhood<P>.
- template <typename P>
- struct nbh_to_win_trait< line_graph_elt_neighborhood<P> >
- { typedef line_graph_elt_window<P> ret; };
-
/// Convert a neighborhood \p nbh into a window.
template <typename N>
- typename nbh_to_win_trait<N>::ret to_window(const Neighborhood<N>& nbh);
+ mln_window(N) to_window(const Neighborhood<N>& nbh);
/// Convert a binary image \p ima into a window.
template <typename I>
@@ -90,40 +72,11 @@
| Neighborhood-to-window conversions. |
`-------------------------------------*/
- namespace impl
- {
-
- template <typename N>
- inline
- window<mln_dpsite(N)> to_window(const N& nbh_)
- {
- const N& nbh = exact(nbh_);
- typedef mln_dpsite(N) D;
- typedef mln_psite(D) P;
- window<D> win;
- mln_niter(N) n(nbh, P::origin);
- for_all(n)
- win.insert(n - P::origin);
- return win;
- }
-
- template <typename P>
- inline
- line_graph_elt_window<P>
- to_window(const line_graph_elt_neighborhood<P>& /* nbh_ */ )
- {
- return line_graph_elt_window<P>();
- }
-
- } // end of namepace mln::convert::impl
-
-
- // Facade.
template <typename N>
inline
- typename nbh_to_win_trait<N>::ret to_window(const Neighborhood<N>& nbh)
+ mln_window(N) to_window(const Neighborhood<N>& nbh)
{
- return impl::to_window(exact(nbh));
+ return exact(nbh).win();
}
/*------------------------------.
Index: mln/set/inter.hh
--- mln/set/inter.hh (revision 2471)
+++ mln/set/inter.hh (working copy)
@@ -31,11 +31,10 @@
/*! \file mln/set/inter.hh
*
* \brief Several routines to compute the intersection between a
- * couple of sets.
+ * couple of site sets.
*/
# include <mln/convert/to_std_set.hh>
-# include <mln/convert/to_window.hh>
# include <mln/convert/to_p_set.hh>
# include <mln/metal/equal.hh>
@@ -47,14 +46,6 @@
namespace set
{
- /*! \brief Intersection between a couple of windows.
- *
- * \relates mln::Window
- */
- template <typename Wl, typename Wr>
- window<mln_dpsite(Wl)>
- inter(const Window<Wl>& lhs, const Window<Wr>& rhs);
-
/*! \brief Intersection between a couple of point sets.
*
* \relates mln::Site_Set
@@ -67,25 +58,6 @@
template <typename Wl, typename Wr>
inline
- window<mln_dpsite(Wl)>
- inter(const Window<Wl>& lhs, const Window<Wr>& rhs)
- {
- trace::entering("set::inter");
- mln::metal::equal<mln_dpsite(Wl), mln_dpsite(Wr)>::check();
- typedef mln_dpsite(Wl) D;
- std::set<D>
- sl = convert::to_std_set(lhs),
- sr = convert::to_std_set(rhs),
- s;
- std::set_intersection(sl.begin(), sl.end(),
- sr.begin(), sr.end(),
- std::inserter(s, s.begin()));
- trace::exiting("set::inter");
- return convert::to_window(s);
- }
-
- template <typename Wl, typename Wr>
- inline
p_set<mln_psite(Wl)>
inter(const Site_Set<Wl>& lhs, const Site_Set<Wr>& rhs)
{
Index: mln/win/inter.hh
--- mln/win/inter.hh (revision 2469)
+++ mln/win/inter.hh (working copy)
@@ -25,12 +25,12 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WIN_SHIFT_HH
-# define MLN_WIN_SHIFT_HH
+#ifndef MLN_WIN_INTER_HH
+# define MLN_WIN_INTER_HH
-/*! \file mln/win/shift.hh
+/*! \file mln/win/inter.hh
*
- * \brief Define a function which shifts a window with a delta-point.
+ * \brief Define a function which inters a window with a delta-point.
*/
# include <mln/core/window.hh>
@@ -40,76 +40,95 @@
namespace mln
{
- namespace win
- {
-
- /// Shift a window \p win with a delta-point \p dp.
- template <typename W>
- mln_regular(W)
- shift(const Window<W>& win, const mln_dpsite(W)& dp);
+ /// Inter a window \p win with a delta-point \p dp.
+ template <typename W1, typename W2>
+ mln_regular(W1)
+ operator && (const Window<W1>& win1, const Window<W2>& win2);
# ifndef MLN_INCLUDE_ONLY
+ namespace win
+ {
+
namespace impl
{
- template <typename W>
+ template <typename W1, typename W2>
inline
- mln_regular(W)
- shift_(trait::window::definition::unique,
- const W& win, const mln_dpsite(W)& dp)
+ mln_regular(W1)
+ inter(trait::window::definition::unique,
+ const W1& win1, const W2& win2)
{
- mlc_is(mln_trait_window_size(W),
+ mlc_is(mln_trait_window_size(W1),
+ trait::window::size::fixed)::check();
+ mlc_is(mln_trait_window_size(W2),
trait::window::size::fixed)::check();
- mln_regular(W) tmp;
- unsigned n = win.size();
+
+ mln_regular(W1) tmp;
+ unsigned n = win1.size();
for (unsigned i = 0; i < n; ++i)
- tmp.insert(win.dp(i) + dp);
+ if (win2.has(win1.dp(i)))
+ tmp.insert(win1.dp(i));
return tmp;
}
- template <typename W>
+ template <typename W1, typename W2>
inline
- mln_regular(W)
- shift_(trait::window::definition::multiple,
- const W& win, const mln_dpsite(W)& dp)
+ mln_regular(W1)
+ inter(trait::window::definition::multiple,
+ const W1& win1, const W2& win2)
{
- mln_regular(W) tmp(win.function());
- const unsigned nw = win.nwindows();
+ mln_precondition(win1.nwindows() == win2.nwindows());
+ // FIXME: What about "win1.function() not equal win2.function()"!
+
+ mln_regular(W1) tmp(win1.function());
+ const unsigned nw = win1.nwindows();
for (unsigned w = 0; w < nw; ++w)
- tmp.set_window(w, win::shift(win.window(w), dp));
+ tmp.set_window(w, win1.window(w) && win2.window(w));
return tmp;
}
} // end of namespace mln::win::impl
+ } // end of namespace mln::win
+
// Facade.
- template <typename W>
+ template <typename W1, typename W2>
inline
- mln_regular(W)
- shift(const Window<W>& win, const mln_dpsite(W)& dp)
+ mln_regular(W1)
+ operator && (const Window<W1>& win1, const Window<W2>& win2)
{
- trace::entering("win::shift");
+ trace::entering("win::inter");
- mlc_is(mln_trait_window_support(W),
+ // Compatibility checks.
+ mlc_equal(mln_regular(W1), mln_regular(W2))::check();
+ mlc_converts_to(mln_dpsite(W1), mln_dpsite(W2))::check();
+
+ // Support checks.
+ mlc_is(mln_trait_window_support(W1),
+ trait::window::support::regular)::check();
+ mlc_is(mln_trait_window_support(W2),
trait::window::support::regular)::check();
- mlc_is_not(mln_trait_window_definition(W),
+
+ // Definition checks.
+ mlc_equal(mln_trait_window_definition(W1),
+ mln_trait_window_definition(W2))::check();
+
+ mlc_is_not(mln_trait_window_definition(W1),
trait::window::definition::varying)::check();
- mln_regular(W) tmp = impl::shift_(mln_trait_window_definition(W)(),
- exact(win), dp);
+ mln_regular(W1) tmp = win::impl::inter(mln_trait_window_definition(W1)(),
+ exact(win1), exact(win2));
- trace::exiting("win::shift");
+ trace::exiting("win::inter");
return tmp;
}
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::win
-
} // end of namespace mln
-#endif // ! MLN_WIN_SHIFT_HH
+#endif // ! MLN_WIN_INTER_HH
Index: mln/win/multiple.hh
--- mln/win/multiple.hh (revision 2471)
+++ mln/win/multiple.hh (working copy)
@@ -126,6 +126,8 @@
: public internal::site_relative_iterator_base< multiple<W,F>,
multiple_qiter<W,F> >
{
+ typedef multiple_qiter<W,F> self_;
+ typedef internal::site_relative_iterator_base< multiple<W,F>, self_ > super_;
public:
multiple_qiter();
@@ -133,6 +135,8 @@
template <typename P>
multiple_qiter(const multiple<W,F>& w, const P& c);
+ void change_target(const multiple<W,F>& w); // Overridden to initialize size_.
+
/// Test the iterator validity.
bool is_valid_() const;
@@ -317,8 +321,16 @@
this->center_at(c);
// We have to first change the center so that 'invalidate' can
// work when changing the target.
- this->change_target(w);
- size_ = w.size(); // FIXME: In a local change_target!
+ change_target(w);
+ }
+
+ template <typename W, typename F>
+ inline
+ void
+ multiple_qiter<W,F>::change_target(const multiple<W,F>& w)
+ {
+ this->super_::change_target(w);
+ size_ = w.size();
}
template <typename W, typename F>
Index: mln/win/diff.hh
--- mln/win/diff.hh (revision 2471)
+++ mln/win/diff.hh (working copy)
@@ -41,14 +41,12 @@
namespace mln
{
- namespace win
- {
-
/// Set difference between a couple of windows \p win1 and \p win2.
template <typename W1, typename W2>
mln_regular(W1)
operator-(const Window<W1>& win1, const Window<W2>& win2);
+
/// Set difference between a couple of neighborhoods \p nbh1 and \p nbh2.
template <typename N1, typename N2>
neighb<mln_deduce(N1, window, regular)>
@@ -96,8 +94,6 @@
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::win
-
} // end of namespace mln
Index: mln/morpho/thin_fit.hh
--- mln/morpho/thin_fit.hh (revision 2471)
+++ mln/morpho/thin_fit.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -55,6 +55,34 @@
# ifndef MLN_INCLUDE_ONLY
+ namespace internal
+ {
+
+ template <typename I, typename Wfg, typename Wbg>
+ inline
+ void
+ thin_fit_tests(const Image<I>& input_,
+ const Window<Wfg>& win_fg_,
+ const Window<Wbg>& win_bg_)
+ {
+ const I& input = exact(input_);
+ const Wfg& win_fg = exact(win_fg_);
+ const Wbg& win_bg = exact(win_bg_);
+
+ // Tests.
+ mln_precondition(input.has_data());
+ mln_precondition(win_fg.is_centered());
+ mln_precondition((win_fg && win_bg).is_empty());
+
+ // Avoid warnings.
+ (void) input_;
+ (void) win_fg_;
+ (void) win_bg_;
+ }
+
+ } // end of namespace mln::morpho::internal
+
+
template <typename I, typename Wfg, typename Wbg>
inline
mln_concrete(I)
@@ -62,9 +90,8 @@
const Window<Wfg>& win_fg, const Window<Wbg>& win_bg)
{
trace::entering("morpho::thin_fit");
- mln_precondition(exact(input).has_data());
- mln_precondition(exact(win_fg).is_centered());
- mln_precondition(set::inter(exact(win_fg), exact(win_bg)).is_empty());
+
+ internal::thin_fit_tests(input, win_fg, win_bg);
mln_concrete(I)
output = morpho::minus( input,
Index: mln/morpho/thinning.hh
--- mln/morpho/thinning.hh (revision 2471)
+++ mln/morpho/thinning.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -58,6 +58,35 @@
# ifndef MLN_INCLUDE_ONLY
+ namespace internal
+ {
+
+ template <typename I, typename Wfg, typename Wbg>
+ inline
+ void
+ thinning_tests(const Image<I>& input_,
+ const Window<Wfg>& win_fg_,
+ const Window<Wbg>& win_bg_)
+ {
+ const I& input = exact(input_);
+ const Wfg& win_fg = exact(win_fg_);
+ const Wbg& win_bg = exact(win_bg_);
+
+ // Tests.
+ mln_precondition(input.has_data());
+ mln_precondition(win_bg.is_centered());
+ mln_precondition(! win_bg.is_empty());
+ mln_precondition((win_fg && win_bg).is_empty());
+
+ // Avoid warnings.
+ (void) input_;
+ (void) win_fg_;
+ (void) win_bg_;
+ }
+
+ } // end of namespace mln::morpho::internal
+
+
template <typename I, typename Wfg, typename Wbg>
inline
mln_concrete(I)
@@ -65,10 +94,9 @@
const Window<Wfg>& win_fg, const Window<Wbg>& win_bg)
{
trace::entering("morpho::thinning");
- mln_precondition(exact(input).has_data());
- mln_precondition(exact(win_fg).is_centered());
- mln_precondition(! exact(win_bg).is_empty());
- mln_precondition(set::inter(exact(win_fg), exact(win_bg)).is_empty());
+
+
+ internal::thinning_tests(input, win_fg, win_bg);
mln_concrete(I) output = morpho::minus( input,
hit_or_miss(input, win_fg, win_bg) );
Index: mln/morpho/hit_or_miss.hh
--- mln/morpho/hit_or_miss.hh (revision 2471)
+++ mln/morpho/hit_or_miss.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -105,6 +105,35 @@
# ifndef MLN_INCLUDE_ONLY
+
+ namespace internal
+ {
+
+ template <typename I, typename Wh, typename Wm>
+ inline
+ void
+ hit_or_miss_tests(const Image<I>& input_,
+ const Window<Wh>& win_hit_,
+ const Window<Wm>& win_miss_)
+ {
+ const I& input = exact(input_);
+ const Wh& win_hit = exact(win_hit_);
+ const Wm& win_miss = exact(win_miss_);
+
+ // Tests.
+ mln_precondition(input.has_data());
+ mln_precondition(win_hit.is_centered());
+ mln_precondition((win_hit && win_miss).is_empty());
+
+ // Avoid warnings.
+ (void) input_;
+ (void) win_hit_;
+ (void) win_miss_;
+ }
+
+ } // end of namespace mln::morpho::internal
+
+
namespace impl
{
@@ -113,11 +142,15 @@
template <typename I, typename Wh, typename Wm>
inline
- void hit_or_miss_preconditions_(const Image<I>& input,
- const Window<Wh>& win_hit, const Window<Wm>& win_miss)
- {
- mln_precondition(exact(input).has_data());
- mln_precondition(set::inter(exact(win_hit), exact(win_miss)).is_empty());
+ void hit_or_miss_preconditions_(const Image<I>& input_,
+ const Window<Wh>& win_hit_,
+ const Window<Wm>& win_miss_)
+ {
+ const I& input = exact(input_);
+ const Wh& win_hit = exact(win_hit_);
+ const Wm& win_miss = exact(win_miss_);
+ mln_precondition(input.has_data());
+ mln_precondition((win_hit && win_miss).is_empty());
}
@@ -203,7 +236,7 @@
const Window<Wh>& win_hit, const Window<Wm>& win_miss)
{
trace::entering("morpho::hit_or_miss");
- impl::hit_or_miss_preconditions_(input, win_hit, win_miss);
+ internal::hit_or_miss_tests(input, win_hit, win_miss);
mln_concrete(I) output = impl::hit_or_miss_(mln_trait_image_kind(I)(),
exact(input),
@@ -221,7 +254,7 @@
const Window<Wh>& win_hit, const Window<Wm>& win_miss)
{
trace::entering("morpho::hit_or_miss_opening");
- impl::hit_or_miss_preconditions_(input, win_hit, win_miss);
+ internal::hit_or_miss_tests(input, win_hit, win_miss);
mln_concrete(I) output = dilation( hit_or_miss(input, win_hit, win_miss),
win::sym(win_hit) );
@@ -238,7 +271,7 @@
const Window<Wh>& win_hit, const Window<Wm>& win_miss)
{
trace::entering("morpho::hit_or_miss_background_opening");
- impl::hit_or_miss_preconditions_(input, win_hit, win_miss);
+ internal::hit_or_miss_tests(input, win_hit, win_miss);
mln_concrete(I) output = hit_or_miss_opening(complementation(input), win_miss, win_hit);
@@ -256,7 +289,7 @@
const Window<Wh>& win_hit, const Window<Wm>& win_miss)
{
trace::entering("morpho::hit_or_miss_closing");
- impl::hit_or_miss_preconditions_(input, win_hit, win_miss);
+ internal::hit_or_miss_tests(input, win_hit, win_miss);
mln_concrete(I) output = complementation( hit_or_miss_opening( complementation(input),
win_hit, win_miss ) );
@@ -274,7 +307,7 @@
const Window<Wh>& win_hit, const Window<Wm>& win_miss)
{
trace::entering("morpho::hit_or_miss_background_closing");
- impl::hit_or_miss_preconditions_(input, win_hit, win_miss);
+ internal::hit_or_miss_tests(input, win_hit, win_miss);
mln_concrete(I) output = hit_or_miss_closing(input, win_miss, win_hit);
Index: mln/morpho/thickening.hh
--- mln/morpho/thickening.hh (revision 2471)
+++ mln/morpho/thickening.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -55,6 +55,35 @@
# ifndef MLN_INCLUDE_ONLY
+ namespace internal
+ {
+
+ template <typename I, typename Wfg, typename Wbg>
+ inline
+ void
+ thickening_tests(const Image<I>& input_,
+ const Window<Wfg>& win_fg_,
+ const Window<Wbg>& win_bg_)
+ {
+ const I& input = exact(input_);
+ const Wfg& win_fg = exact(win_fg_);
+ const Wbg& win_bg = exact(win_bg_);
+
+ // Tests.
+ mln_precondition(input.has_data());
+ mln_precondition(win_bg.is_centered());
+ mln_precondition(! win_fg.is_empty());
+ mln_precondition((win_fg && win_bg).is_empty());
+
+ // Avoid warnings.
+ (void) input_;
+ (void) win_fg_;
+ (void) win_bg_;
+ }
+
+ } // end of namespace mln::morpho::internal
+
+
template <typename I, typename Wfg, typename Wbg>
inline
mln_concrete(I)
@@ -62,10 +91,8 @@
const Window<Wfg>& win_fg, const Window<Wbg>& win_bg)
{
trace::entering("morpho::thickening");
- mln_precondition(exact(input).has_data());
- mln_precondition(exact(win_bg).is_centered());
- mln_precondition(! exact(win_fg).is_empty());
- mln_precondition(set::inter(exact(win_fg), exact(win_bg)).is_empty());
+
+ internal::thickening_tests(input, win_fg, win_bg);
mln_concrete(I) output = morpho::plus( input,
hit_or_miss(input, win_fg, win_bg) );
Index: mln/morpho/thick_miss.hh
--- mln/morpho/thick_miss.hh (revision 2471)
+++ mln/morpho/thick_miss.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -64,7 +64,7 @@
trace::entering("morpho::thick_miss");
// FIXME: Fix the following line (win_miss ??)
// mln_precondition(exact(win_miss).is_centered());
- mln_precondition(set::inter(exact(win_fg), exact(win_bg)).is_empty());
+ mln_precondition((exact(win_fg) && exact(win_bg)).is_empty());
mln_concrete(I)
output = morpho::plus( input,
Index: mln/morpho/dilation.hh
--- mln/morpho/dilation.hh (revision 2471)
+++ mln/morpho/dilation.hh (working copy)
@@ -257,7 +257,7 @@
here. This means the conversion should be smart enough to
produce a working window, even in the case of a non
dpoint-set-based neighborhood. */
- dilation_wrt_win(input, convert::to_window(nbh), output);
+ dilation_wrt_win(input, nbh.win(), output);
}
#endif
Index: mln/morpho/includes.hh
--- mln/morpho/includes.hh (revision 2471)
+++ mln/morpho/includes.hh (working copy)
@@ -60,7 +60,7 @@
# include <mln/win/sym.hh>
# include <mln/win/shift.hh>
# include <mln/win/diff.hh>
-# include <mln/set/inter.hh>
+# include <mln/win/inter.hh>
# include <mln/morpho/dilation.hh>
# include <mln/morpho/erosion.hh>
@@ -70,6 +70,5 @@
# include <mln/morpho/minus.hh>
# include <mln/morpho/plus.hh>
-# include <mln/convert/to_window.hh>
#endif // ! MLN_MORPHO_INCLUDES_HH
1
0
02 Oct '08
* mln/topo/internal/complex_iter_base.hh: Rename as...
* mln/topo/internal/complex_set_iterator_base.hh: ...this.
(mln::internal::complex_iter_base<F, E>): Rename as...
(mln::internal::complex_set_iternal_base<F, E>): ...this.
* mln/topo/face_iter.hh,
* mln/topo/n_face_iter.hh,
* mln/topo/static_n_face_iter.hh,
* mln/topo/attic/faces_iter.hh:
Adjust derived classes.
---
milena/ChangeLog | 14 +++++++
milena/mln/topo/attic/faces_iter.hh | 20 +++++----
milena/mln/topo/face_iter.hh | 18 +++++----
.../internal/complex_relative_iterator_base.hh | 3 +
...x_iter_base.hh => complex_set_iterator_base.hh} | 42 +++++++++----------
milena/mln/topo/n_face_iter.hh | 20 ++++++----
milena/mln/topo/static_n_face_iter.hh | 20 +++++----
7 files changed, 81 insertions(+), 56 deletions(-)
rename milena/mln/topo/internal/{complex_iter_base.hh => complex_set_iterator_base.hh} (76%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 6c59174..226bbf5 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,17 @@
+2008-10-02 Roland Levillain <roland(a)lrde.epita.fr>
+
+ Rename complex_iter_base as complex_set_iterator_base.
+
+ * mln/topo/internal/complex_iter_base.hh: Rename as...
+ * mln/topo/internal/complex_set_iterator_base.hh: ...this.
+ (mln::internal::complex_iter_base<F, E>): Rename as...
+ (mln::internal::complex_set_iternal_base<F, E>): ...this.
+ * mln/topo/face_iter.hh,
+ * mln/topo/n_face_iter.hh,
+ * mln/topo/static_n_face_iter.hh,
+ * mln/topo/attic/faces_iter.hh:
+ Adjust derived classes.
+
2008-10-01 Nicolas Ballas <ballas(a)lrde.epita.fr>
Update documentation, add an operator to the sign value class.
diff --git a/milena/mln/topo/attic/faces_iter.hh b/milena/mln/topo/attic/faces_iter.hh
index 9497a14..5306835 100644
--- a/milena/mln/topo/attic/faces_iter.hh
+++ b/milena/mln/topo/attic/faces_iter.hh
@@ -32,7 +32,7 @@
/// \brief Definition of forward and backward iterators on the n-faces
/// of a complex.
-# include <mln/topo/internal/complex_iter_base.hh>
+# include <mln/topo/internal/complex_set_iterator_base.hh>
# include <mln/topo/n_face.hh>
namespace mln
@@ -51,8 +51,8 @@ namespace mln
/// \arg \p D The dimension of the complex this iterator belongs to.
template <unsigned N, unsigned D>
class faces_fwd_iter_
- : public internal::complex_iter_base< n_face<N, D>,
- faces_fwd_iter_<N, D> >
+ : public internal::complex_set_iterator_base< n_face<N, D>,
+ faces_fwd_iter_<N, D> >
{
public:
/// Type of associated face.
@@ -60,7 +60,7 @@ namespace mln
private:
typedef faces_fwd_iter_<N, D> self_;
- typedef internal::complex_iter_base< face, self_ > super_;
+ typedef internal::complex_set_iterator_base< face, self_ > super_;
public:
using super_::is_valid;
@@ -70,7 +70,8 @@ namespace mln
/// Construction and assignment.
/// \{
faces_fwd_iter_();
- // FIXME: See comment in internal::complex_iter_base's default ctor
+ // FIXME: See comment in internal::complex_set_iterator_base's
+ // default ctor.
faces_fwd_iter_(complex<D>& c);
/// \}
@@ -97,8 +98,8 @@ namespace mln
/// \arg \p D The dimension of the complex this iterator belongs to.
template <unsigned N, unsigned D>
class faces_bkd_iter_
- : public internal::complex_iter_base< n_face<N, D>,
- faces_bkd_iter_<N, D> >
+ : public internal::complex_set_iterator_base< n_face<N, D>,
+ faces_bkd_iter_<N, D> >
{
public:
/// Type of associated face.
@@ -106,7 +107,7 @@ namespace mln
private:
typedef faces_bkd_iter_<N, D> self_;
- typedef internal::complex_iter_base< face, self_ > super_;
+ typedef internal::complex_set_iterator_base< face, self_ > super_;
public:
using super_::is_valid;
@@ -116,7 +117,8 @@ namespace mln
/// Construction and assignment.
/// \{
faces_bkd_iter_();
- // FIXME: See comment in internal::complex_iter_base's default ctor
+ // FIXME: See comment in internal::complex_set_iterator_base's
+ // default ctor.
faces_bkd_iter_(complex<D>& c);
/// \}
diff --git a/milena/mln/topo/face_iter.hh b/milena/mln/topo/face_iter.hh
index a564831..b34bfbd 100644
--- a/milena/mln/topo/face_iter.hh
+++ b/milena/mln/topo/face_iter.hh
@@ -32,10 +32,10 @@
/// \brief Definition of forward and backward iterators on all the
/// faces of a complex.
-# include <mln/topo/internal/complex_iter_base.hh>
+# include <mln/topo/internal/complex_set_iterator_base.hh>
# include <mln/topo/face.hh>
-// FIXME: Factor a bit more? (Using complex_iter_base.)
+// FIXME: Factor a bit more? (Using complex_set_iterator_base.)
namespace mln
@@ -57,11 +57,11 @@ namespace mln
/// \arg \p D The dimension of the complex this iterator belongs to.
template <unsigned D>
class face_fwd_iter
- : public internal::complex_iter_base< face<D>, face_fwd_iter<D> >
+ : public internal::complex_set_iterator_base< face<D>, face_fwd_iter<D> >
{
private:
typedef face_fwd_iter<D> self_;
- typedef internal::complex_iter_base< face<D>, self_ > super_;
+ typedef internal::complex_set_iterator_base< face<D>, self_ > super_;
public:
using super_::is_valid;
@@ -71,7 +71,8 @@ namespace mln
/// Construction and assignment.
/// \{
face_fwd_iter();
- // FIXME: See comment in internal::complex_iter_base's default ctor
+ // FIXME: See comment in internal::complex_set_iterator_base's
+ // default ctor.
face_fwd_iter(complex<D>& c);
/// \}
@@ -97,11 +98,11 @@ namespace mln
/// \arg \p D The dimension of the complex this iterator belongs to.
template <unsigned D>
class face_bkd_iter
- : public internal::complex_iter_base< face<D>, face_bkd_iter<D> >
+ : public internal::complex_set_iterator_base< face<D>, face_bkd_iter<D> >
{
private:
typedef face_bkd_iter<D> self_;
- typedef internal::complex_iter_base< face<D>, self_ > super_;
+ typedef internal::complex_set_iterator_base< face<D>, self_ > super_;
public:
using super_::is_valid;
@@ -111,7 +112,8 @@ namespace mln
/// Construction and assignment.
/// \{
face_bkd_iter();
- // FIXME: See comment in internal::complex_iter_base's default ctor
+ // FIXME: See comment in internal::complex_set_iterator_base's
+ // default ctor.
face_bkd_iter(complex<D>& c);
/// \}
diff --git a/milena/mln/topo/internal/complex_relative_iterator_base.hh b/milena/mln/topo/internal/complex_relative_iterator_base.hh
index 43a38ae..8fe8c2e 100644
--- a/milena/mln/topo/internal/complex_relative_iterator_base.hh
+++ b/milena/mln/topo/internal/complex_relative_iterator_base.hh
@@ -55,6 +55,9 @@
# include <mln/core/concept/iterator.hh>
# include <mln/topo/complex.hh>
+/* FIXME: Introduce a common factoring class for this class and for
+ complex_relative_iterator_base? */
+
/* FIXME: By moving iterator `i_' into
internal::complex_relative_iterator_base, we'll be able to factor
more methods (do_next_, update_f); this requires the type of this
diff --git a/milena/mln/topo/internal/complex_iter_base.hh b/milena/mln/topo/internal/complex_set_iterator_base.hh
similarity index 76%
rename from milena/mln/topo/internal/complex_iter_base.hh
rename to milena/mln/topo/internal/complex_set_iterator_base.hh
index 06ffca2..7e76b76 100644
--- a/milena/mln/topo/internal/complex_iter_base.hh
+++ b/milena/mln/topo/internal/complex_set_iterator_base.hh
@@ -25,12 +25,12 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_TOPO_INTERNAL_COMPLEX_ITER_BASE_HH
-# define MLN_TOPO_INTERNAL_COMPLEX_ITER_BASE_HH
+#ifndef MLN_TOPO_INTERNAL_COMPLEX_SET_ITERATOR_BASE_HH
+# define MLN_TOPO_INTERNAL_COMPLEX_SET_ITERATOR_BASE_HH
-/// \file mln/topo/internal/complex_iter_base.hh
+/// \file mln/topo/internal/complex_set_iterator_base.hh
/// \brief Definition of an implementation (factoring) class for
-/// iterators on mln::complex.
+/// iterators on faces of a complex.
# include <limits>
@@ -39,10 +39,8 @@
# include <mln/core/concept/iterator.hh>
# include <mln/topo/complex.hh>
-// FIXME: Rename as something else?
-// - complex_iterator_base?
-// - complex_set_iterator_base?
-// - faces_set_iterator_base?
+/* FIXME: Introduce a common factoring class for this class and for
+ complex_relative_iterator_base? */
namespace mln
@@ -58,9 +56,9 @@ namespace mln
/// \arg \p F The type of the face handle.
/// \arg \p E The type exact type of the iterator.
template <typename F, typename E>
- class complex_iter_base : public Iterator<E>
+ class complex_set_iterator_base : public Iterator<E>
{
- typedef complex_iter_base<F, E> self_;
+ typedef complex_set_iterator_base<F, E> self_;
public:
typedef F face;
@@ -72,8 +70,8 @@ namespace mln
/// \{
/* FIXME: Keep this non-const? See a (big) comment about this in
milena/tests/complex_image.cc. */
- complex_iter_base();
- complex_iter_base(complex_type& c);
+ complex_set_iterator_base();
+ complex_set_iterator_base(complex_type& c);
/// \}
/// Manipulation.
@@ -100,11 +98,11 @@ namespace mln
};
- /// Print an mln::topo::internal::complex_iter_base.
+ /// Print an mln::topo::internal::complex_set_iterator_base.
template <typename F, typename E>
inline
std::ostream&
- operator<<(std::ostream& ostr, const complex_iter_base<F, E>& p);
+ operator<<(std::ostream& ostr, const complex_set_iterator_base<F, E>& p);
@@ -112,7 +110,7 @@ namespace mln
template <typename F, typename E>
inline
- complex_iter_base<F, E>::complex_iter_base()
+ complex_set_iterator_base<F, E>::complex_set_iterator_base()
{
// Ensure F and E are compatible.
mlc_equal(F, typename E::face)::check();
@@ -122,7 +120,7 @@ namespace mln
template <typename F, typename E>
inline
- complex_iter_base<F, E>::complex_iter_base(complex_type& c)
+ complex_set_iterator_base<F, E>::complex_set_iterator_base(complex_type& c)
{
// Ensure F and E are compatible.
mlc_equal(F, typename E::face)::check();
@@ -135,7 +133,7 @@ namespace mln
template <typename F, typename E>
inline
void
- complex_iter_base<F, E>::set_cplx(complex_type& c)
+ complex_set_iterator_base<F, E>::set_cplx(complex_type& c)
{
f_.set_cplx(c);
// Invalidate f_.
@@ -145,7 +143,7 @@ namespace mln
template <typename F, typename E>
inline
bool
- complex_iter_base<F, E>::is_valid() const
+ complex_set_iterator_base<F, E>::is_valid() const
{
return f_.is_valid();
}
@@ -153,14 +151,14 @@ namespace mln
template <typename F, typename E>
inline
void
- complex_iter_base<F, E>::invalidate()
+ complex_set_iterator_base<F, E>::invalidate()
{
f_.invalidate();
}
template <typename F, typename E>
inline
- complex_iter_base<F, E>::operator const F&() const
+ complex_set_iterator_base<F, E>::operator const F&() const
{
return f_;
}
@@ -169,7 +167,7 @@ namespace mln
template <typename F, typename E>
inline
std::ostream&
- operator<<(std::ostream& ostr, const complex_iter_base<F, E>& p)
+ operator<<(std::ostream& ostr, const complex_set_iterator_base<F, E>& p)
{
return ostr << F(p);
}
@@ -182,4 +180,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_TOPO_INTERNAL_COMPLEX_ITER_BASE_HH
+#endif // ! MLN_TOPO_INTERNAL_COMPLEX_SET_ITERATOR_BASE_HH
diff --git a/milena/mln/topo/n_face_iter.hh b/milena/mln/topo/n_face_iter.hh
index 2a499c2..eaf9ef9 100644
--- a/milena/mln/topo/n_face_iter.hh
+++ b/milena/mln/topo/n_face_iter.hh
@@ -32,10 +32,10 @@
/// \brief Definition of forward and backward iterators on all the
/// \a n-faces of a complex, \a n being a dynamic value.
-# include <mln/topo/internal/complex_iter_base.hh>
+# include <mln/topo/internal/complex_set_iterator_base.hh>
# include <mln/topo/face.hh>
-// FIXME: Factor a bit more? (Using complex_iter_base.)
+// FIXME: Factor a bit more? (Using complex_set_iterator_base.)
// FIXME: Rename the old commplex_faces_{fwd,bkd}_iter as
// static_n_face_{fwd,bkd}_iter.
@@ -60,11 +60,12 @@ namespace mln
/// \arg \p D The dimension of the complex this iterator belongs to.
template <unsigned D>
class n_face_fwd_iter
- : public internal::complex_iter_base< face<D>, n_face_fwd_iter<D> >
+ : public internal::complex_set_iterator_base< face<D>,
+ n_face_fwd_iter<D> >
{
private:
typedef n_face_fwd_iter<D> self_;
- typedef internal::complex_iter_base< face<D>, self_ > super_;
+ typedef internal::complex_set_iterator_base< face<D>, self_ > super_;
public:
using super_::is_valid;
@@ -74,7 +75,8 @@ namespace mln
/// Construction and assignment.
/// \{
n_face_fwd_iter();
- // FIXME: See comment in internal::complex_iter_base's default ctor
+ // FIXME: See comment in internal::complex_set_iterator_base's
+ // default ctor.
n_face_fwd_iter(complex<D>& c, unsigned n);
/// \}
@@ -108,11 +110,12 @@ namespace mln
/// \arg \p D The dimension of the complex this iterator belongs to.
template <unsigned D>
class n_face_bkd_iter
- : public internal::complex_iter_base< face<D>, n_face_bkd_iter<D> >
+ : public internal::complex_set_iterator_base< face<D>,
+ n_face_bkd_iter<D> >
{
private:
typedef n_face_bkd_iter<D> self_;
- typedef internal::complex_iter_base< face<D>, self_ > super_;
+ typedef internal::complex_set_iterator_base< face<D>, self_ > super_;
public:
using super_::is_valid;
@@ -122,7 +125,8 @@ namespace mln
/// Construction and assignment.
/// \{
n_face_bkd_iter();
- // FIXME: See comment in internal::complex_iter_base's default ctor
+ // FIXME: See comment in internal::complex_set_iterator_base's
+ // default ctor.
n_face_bkd_iter(complex<D>& c, unsigned n);
/// \}
diff --git a/milena/mln/topo/static_n_face_iter.hh b/milena/mln/topo/static_n_face_iter.hh
index f29c4e4..3868e01 100644
--- a/milena/mln/topo/static_n_face_iter.hh
+++ b/milena/mln/topo/static_n_face_iter.hh
@@ -32,7 +32,7 @@
/// \brief Definition of forward and backward iterators on all the
/// \p N-faces of a complex, \p N being a static value.
-# include <mln/topo/internal/complex_iter_base.hh>
+# include <mln/topo/internal/complex_set_iterator_base.hh>
# include <mln/topo/face.hh>
@@ -53,12 +53,12 @@ namespace mln
/// \arg \p D The dimension of the complex this iterator belongs to.
template <unsigned N, unsigned D>
class static_n_face_fwd_iter
- : public internal::complex_iter_base< face<D>,
- static_n_face_fwd_iter<N, D> >
+ : public internal::complex_set_iterator_base< face<D>,
+ static_n_face_fwd_iter<N, D> >
{
private:
typedef static_n_face_fwd_iter<N, D> self_;
- typedef internal::complex_iter_base< face<D>, self_ > super_;
+ typedef internal::complex_set_iterator_base< face<D>, self_ > super_;
public:
using super_::is_valid;
@@ -68,7 +68,8 @@ namespace mln
/// Construction and assignment.
/// \{
static_n_face_fwd_iter();
- // FIXME: See comment in internal::complex_iter_base's default ctor
+ // FIXME: See comment in internal::complex_set_iterator_base's
+ // default ctor.
static_n_face_fwd_iter(complex<D>& c);
/// \}
@@ -96,12 +97,12 @@ namespace mln
/// \arg \p D The dimension of the complex this iterator belongs to.
template <unsigned N, unsigned D>
class static_n_face_bkd_iter
- : public internal::complex_iter_base< face<D>,
- static_n_face_bkd_iter<N, D> >
+ : public internal::complex_set_iterator_base< face<D>,
+ static_n_face_bkd_iter<N, D> >
{
private:
typedef static_n_face_bkd_iter<N, D> self_;
- typedef internal::complex_iter_base< face<D>, self_ > super_;
+ typedef internal::complex_set_iterator_base< face<D>, self_ > super_;
public:
using super_::is_valid;
@@ -111,7 +112,8 @@ namespace mln
/// Construction and assignment.
/// \{
static_n_face_bkd_iter();
- // FIXME: See comment in internal::complex_iter_base's default ctor
+ // FIXME: See comment in internal::complex_set_iterator_base's
+ // default ctor.
static_n_face_bkd_iter(complex<D>& c);
/// \}
--
1.6.0.1
1
0
---
milena/ChangeLog | 38 +++++++++++++++++++-------------------
1 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index d13bb69..6c59174 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -258,7 +258,7 @@
Fixes on median.
* mln/level/median.hh: Add initialisation of p :
- p = input.domain().pmin() + up;
+ p = input.domain().pmin() + up;
* tests/level/median_.cc: Some tests.
2008-09-30 Roland Levillain <roland(a)lrde.epita.fr>
@@ -279,7 +279,7 @@
Print the address of complexes with their face handles.
* mln/topo/face.hh (operator<<(std::ostream&, const face<D>&))
- * mln/topo/n_face.hh (operator<<(std::ostream&, const n_face<N, D>&)):
+ * mln/topo/n_face.hh (operator<<(std::ostream&, const n_face<N, D>&)):
Do it.
2008-09-30 Roland Levillain <roland(a)lrde.epita.fr>
@@ -384,7 +384,7 @@
* mln/core/internal/p_complex_piter_base.hh
(mln::internal::p_complex_piter_base_<I, S, P, E>::iter_):
Set to protected.
- * mln/core/site_set/p_n_faces_piter.hh): New file.
+ * mln/core/site_set/p_n_faces_piter.hh: New file.
Include it...
* mln/core/site_set/p_complex.hh: ...here.
* tests/core/image/complex_image.cc: Exercise iterators on
@@ -892,7 +892,7 @@
Simplify mln::internal::complex_iter_base_.
- * mln/core/internal/complex_iter_base.hh:
+ * mln/core/internal/complex_iter_base.hh:
(mln::internal::complex_iter_base_<F, E>::complex_iter_base_):
Remove copy ctor.
(mln::internal::complex_iter_base_<F, E>::operator=):
@@ -1162,7 +1162,7 @@
2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
Update tests exercising graph image.
-
+
* tests/core/image/graph_image.cc: Update.
Move the morpho-related part...
* tests/morpho/graph_image_morpho.cc: ...here (new test).
@@ -1481,7 +1481,7 @@
(mln::p_graph<P>::piter):
New typedefs.
(mln::p_graph<P>::bbox): Remove method.
- (mln::p_graph<P>::bb_): Remove attribute.
+ (mln::p_graph<P>::bb_): Remove attribute.
(mln::p_graph<P>::p_graph): Adjust ctor.
(mln::p_graph<P>::has): Update.
(mln::p_graph<P>::to_graph): Update accessors.
@@ -1551,7 +1551,7 @@
(mln::p_complex_piter_base_<D, P>::p_): Get it from the super
class.
(mln::p_complex_piter_base_<D, P>::psite): Remove attribute.
- * mln/core/site_set/p_complex_piter.hh:
+ * mln/core/site_set/p_complex_piter.hh:
(mln::p_complex_fwd_piter_<D, P>::p_complex_fwd_piter_)
(mln::p_complex_bkd_piter_<D, P>::p_complex_bkd_piter_):
New default ctors.
@@ -1563,7 +1563,7 @@
(mln::p_complex_fwd_piter_<D, P>::operator=(const self_&))
(mln::p_complex_bkd_piter_<D, P>::operator=(const self_&)):
Remove.
-
+
2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
Update site on mln::p_faces.
@@ -1716,7 +1716,7 @@
Complete the overhaul of line graph images.
- * mln/core/image/line_graph_image.hh:
+ * mln/core/image/line_graph_image.hh:
(mln::line_graph_image<P, V>): Fix access to members.
(mln::line_graph_image<P, V>::super_): Remove typedef.
* mln/core/site_set/p_line_graph.hh: Update documentation.
@@ -1761,11 +1761,11 @@
* mln/canvas/browsing/snake_vert.hh: New, snake vert browsing
canvas. This canvas browse all the point of an image 'input' like
this :
- 1 4 5
- || /\ ||
- || || ||
- \/ || \/
- 2 3 6
+ 1 4 5
+ || /\ ||
+ || || ||
+ \/ || \/
+ 2 3 6
* tests/canvas/browsing/Makefile.am: Add snake_vert test.
* tests/canvas/browsing/snake_vert.cc: New. The test.
@@ -2438,7 +2438,7 @@
Inherit from internal::site_iterator_base< S, E >.
Adjust.
(mln::line_graph_vicinity_piter_<P, S, E>::p_hook_): New method.
-
+
* mln/core/image/line_graph_elt_neighborhood.hh
(mln::line_graph_elt_neighborhood<P>::point): Rename typedef as...
(mln::line_graph_elt_neighborhood<P>::site): ...this.
@@ -2781,7 +2781,7 @@
Have iterators on mln::complex export their dimension.
* mln/core/complex_iter.hh
- (mln::complex_fwd_iter<D>::complex_dim):
+ (mln::complex_fwd_iter<D>::complex_dim):
(mln::complex_bkd_iter<D>::complex_dim):
New constants.
@@ -2968,7 +2968,7 @@
* milena/mln/core/alias/point2d_h.hh,
* milena/tests/algebra/h_vec.cc,
* milena/tests/core/alias/point2d.cc,
- * milena/tests/core/alias/point1d.cc: Use def::coord instead of int.
+ * milena/tests/core/alias/point1d.cc: Use def::coord instead of int.
* milena/tests/set/diff.cc,
* milena/tests/core/site_set/p_image2d.cc: Update.
@@ -3191,7 +3191,7 @@
* mln/core/site_set/p_graph.hh,
* mln/core/image/obased_rle_image.hh,
* mln/core/image/t_image.hh,
- * mln/core/concept/doc/image.hh,
+ * mln/core/concept/doc/image.hh,
* mln/core/line_piter.hh,
* mln/core/alias/box2d_h.hh
(box_): Update to...
@@ -3412,7 +3412,7 @@
2008-09-11 Roland Levillain <roland(a)lrde.epita.fr>
Add default constructors to complexes on iterators.
-
+
* mln/core/complex_iter.hh
(mln::complex_fwd_iter_<D>::complex_fwd_iter_)
(mln::complex_bkd_iter_<D>::complex_bkd_iter_):
--
1.6.0.1
1
0
cleanup-2008 2469: Sandbox: Registration: Start to use milena transformations.
by Ugo Jardonnet 01 Oct '08
by Ugo Jardonnet 01 Oct '08
01 Oct '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Sandbox: Registration: Start to use milena transformations.
* jardonnet/test/registration.cc: Add use of milena trasformation.
* jardonnet/registration/quat7.hh: Replace quat7 by a generic T.
* jardonnet/registration/registration.hh: Replace quat7 by a generic T..
Start working on .hxx creation using perl:
* jardonnet/perl/hxx.pl: Script.
* jardonnet/perl/test,
* jardonnet/perl/test/ops.hh,
* jardonnet/perl/test/c.hh,
* jardonnet/perl/test/i2v,
* jardonnet/perl/test/i2v/all.hh,
* jardonnet/perl/test/i2v/all_to.hh,
* jardonnet/perl/test/i2v/array.hh,
* jardonnet/perl/test/x2x,
* jardonnet/perl/test/x2x/all.hh,
* jardonnet/perl/test/x2x/geom,
* jardonnet/perl/test/x2x/geom/composed.hh,
* jardonnet/perl/test/x2x/geom/translation.hh,
* jardonnet/perl/test/x2x/geom/rotation.hh,
* jardonnet/perl/test/x2x/interpol,
* jardonnet/perl/test/x2x/interpol/bilinear.hh,
* jardonnet/perl/test/x2x/interpol/test.cc,
* jardonnet/perl/test/x2x/interpol/linear.hh,
* jardonnet/perl/test/p2b,
* jardonnet/perl/test/p2b/chess.hh,
* jardonnet/perl/test/p2b/all.hh,
* jardonnet/perl/test/p2b/has.hh,
* jardonnet/perl/test/vv2v,
* jardonnet/perl/test/vv2v/min.hh,
* jardonnet/perl/test/vv2v/max.hh,
* jardonnet/perl/test/all.hh,
* jardonnet/perl/test/p2v,
* jardonnet/perl/test/p2v/elifs.hh,
* jardonnet/perl/test/p2v/ternary.hh,
* jardonnet/perl/test/p2v/all.hh,
* jardonnet/perl/test/p2v/iota.hh,
* jardonnet/perl/test/cast.hh,
* jardonnet/perl/test/v2b,
* jardonnet/perl/test/v2b/threshold.hh,
* jardonnet/perl/test/internal,
* jardonnet/perl/test/internal/x2x_linear_impl.hh,
* jardonnet/perl/test/internal/selector.hh,
* jardonnet/perl/test/v2v,
* jardonnet/perl/test/v2v/abs.hh,
* jardonnet/perl/test/v2v/enc.hh,
* jardonnet/perl/test/v2v/saturate.hh,
* jardonnet/perl/test/v2v/all.hh,
* jardonnet/perl/test/v2v/inc.hh,
* jardonnet/perl/test/v2v/linear.hh,
* jardonnet/perl/test/v2v/cast.hh,
* jardonnet/perl/test/v2v/norm.hh,
* jardonnet/perl/test/v2v/dec.hh,
* jardonnet/perl/test/v2v/id.hh,
* jardonnet/perl/test/v2v/rgb_to_hsi.hh: Add test files.
perl/hxx.pl | 27 +++
perl/test/all.hh | 63 +++++++
perl/test/c.hh | 140 ++++++++++++++++
perl/test/cast.hh | 85 ++++++++++
perl/test/i2v/all.hh | 56 ++++++
perl/test/i2v/all_to.hh | 108 ++++++++++++
perl/test/i2v/array.hh | 147 +++++++++++++++++
perl/test/internal/selector.hh | 200 +++++++++++++++++++++++
perl/test/internal/x2x_linear_impl.hh | 102 ++++++++++++
perl/test/ops.hh | 199 +++++++++++++++++++++++
perl/test/p2b/all.hh | 56 ++++++
perl/test/p2b/chess.hh | 78 +++++++++
perl/test/p2b/has.hh | 137 ++++++++++++++++
perl/test/p2v/all.hh | 58 ++++++
perl/test/p2v/elifs.hh | 85 ++++++++++
perl/test/p2v/iota.hh | 106 ++++++++++++
perl/test/p2v/ternary.hh | 120 ++++++++++++++
perl/test/v2b/threshold.hh | 90 ++++++++++
perl/test/v2v/abs.hh | 78 +++++++++
perl/test/v2v/all.hh | 61 +++++++
perl/test/v2v/cast.hh | 81 +++++++++
perl/test/v2v/dec.hh | 78 +++++++++
perl/test/v2v/enc.hh | 77 +++++++++
perl/test/v2v/id.hh | 78 +++++++++
perl/test/v2v/inc.hh | 78 +++++++++
perl/test/v2v/linear.hh | 94 +++++++++++
perl/test/v2v/norm.hh | 130 +++++++++++++++
perl/test/v2v/rgb_to_hsi.hh | 143 +++++++++++++++++
perl/test/v2v/saturate.hh | 129 +++++++++++++++
perl/test/vv2v/max.hh | 77 +++++++++
perl/test/vv2v/min.hh | 77 +++++++++
perl/test/x2x/all.hh | 66 +++++++
perl/test/x2x/geom/composed.hh | 285 ++++++++++++++++++++++++++++++++++
perl/test/x2x/geom/rotation.hh | 243 ++++++++++++++++++++++++++++
perl/test/x2x/geom/translation.hh | 152 ++++++++++++++++++
perl/test/x2x/interpol/bilinear.hh | 139 ++++++++++++++++
perl/test/x2x/interpol/linear.hh | 124 ++++++++++++++
perl/test/x2x/interpol/test.cc | 14 +
registration/quat7.hh | 3
registration/registration.hh | 16 +
test/registration.cc | 73 ++------
41 files changed, 4088 insertions(+), 65 deletions(-)
Index: jardonnet/test/registration.cc
--- jardonnet/test/registration.cc (revision 2468)
+++ jardonnet/test/registration.cc (working copy)
@@ -12,6 +12,8 @@
#include <sandbox/jardonnet/registration/final_qk.hh>
#include <mln/geom/bbox.hh>
+#include <mln/fun/x2x/all.hh>
+
void usage(char *argv[])
{
std::cout << "usage : " << argv[0]
@@ -26,83 +28,42 @@
// usage
float q = std::atof(argv[3]);
int e = std::atoi(argv[4]);
- if (argc != 5)
- usage(argv);
- if (q < 1 or e < 1)
- usage(argv);
+ if ((argc != 5) || (q < 1 or e < 1)) usage(argv);
using namespace mln;
typedef image2d< bool > image2db;
+
+ //declare image
image2db img1;
image2db img2;
+
//load images
io::pbm::load(img1, argv[1]);
io::pbm::load(img2, argv[2]);
- //build p_arrays.
+
+ //build p_arrays
p_array<mln_psite_(image2db)> c = convert::to< p_array<point2d> >(img1);
p_array<mln_psite_(image2db)> x = convert::to< p_array<point2d> >(img2);
+
//working box
const box<point2d> working_box =
enlarge(bigger(geom::bbox(c), geom::bbox(x)), 100);
- //Make a lazy_image map via function closest_point
- closest_point<mln_psite_(image2db)> fun(x, working_box);
-
- // * Use real lazy image
- lazy_image<image2d<bool>, closest_point<mln_psite_(image2db)>, box2d > map(fun, fun.domain());
- quat7<2> qk ;//= registration::icp(c, map, q, e, x);
-
-#ifndef NDEBUG
- std::cout << "closest_point(Ck[i]) = " << fun.i << std::endl;
- std::cout << "Pts processed = " << registration::pts << std::endl;
-#endif
-
- qk.apply_on(c, c, c.nsites());
-
- float stddev, mean;
- registration::mean_stddev(c, map, mean, stddev);
-
-#ifndef NDEBUG
- std::cout << "mean : " << mean << std::endl;
- std::cout << "stddev : " << stddev << std::endl;
-#endif
- std::vector<float> length(c.nsites());
- for (size_t i = 0; i < c.nsites(); i++)
- length[i] = norm::l2( convert::to< algebra::vec<2,float> >(c[i] - map(c[i])));
-
-
- // final transform
- quat7<2> fqk = registration::final_qk2(c, map, 2*stddev);
- fqk.apply_on(c, c, c.nsites());
-
-
- //init output image
- image2d<value::rgb8> output(convert::to_box2d(working_box), 0);
- level::fill(output, literal::white);
-
-
- //print x
- for (unsigned i = 0; i < x.nsites(); i++)
- {
- //Xk points
- point2d px(x[i][0], x[i][1]);
- if (output.has(px))
- output(px) = literal::black;
- }
+ //make a lazy_image map via function closest_point
+ closest_point<mln_psite_(image2db)> fun(x, working_box);
+ lazy_image<image2d<bool>, closest_point<mln_psite_(image2db)>, box2d >
+ map(fun, fun.domain());
- for (unsigned i = 0; i < c.nsites(); i++)
- {
- //Ck points
- point2d p(c[i][0], c[i][1]);
- if (output.has(p))
- output(p) = literal::green;
- }
+ //do registration
+ using namespace fun::x2x::geom;
+ composed<rotation<2u, float>, translation<2u, float> > rigid_tr =
+ registration::icp(c, map, q, e, x);
io::ppm::save(output, "registred.ppm");
Index: jardonnet/perl/test/ops.hh
--- jardonnet/perl/test/ops.hh (revision 0)
+++ jardonnet/perl/test/ops.hh (revision 0)
@@ -0,0 +1,199 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_OPS_HH
+# define MLN_FUN_OPS_HH
+
+/*! \file mln/fun/ops.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/fun/internal/selector.hh>
+# include <mln/trait/all.hh>
+
+
+
+# define mln_decl_binary_expr_(In, Out, Name, Symbol) \
+ \
+ namespace fun \
+ { \
+ \
+ template <typename L, typename R> \
+ struct Name##_##Out##_expr_ \
+ : public Function_##Out < Name##_##Out##_expr_<L,R> > \
+ { \
+ typedef typename mln::trait::op:: Name < mln_result(L), \
+ mln_result(R) >::ret result; \
+ \
+ Name##_##Out##_expr_() \
+ { \
+ } \
+ \
+ Name##_##Out##_expr_(const L& l, const R& r) \
+ : l_(l), r_(r) \
+ { \
+ } \
+ \
+ template <typename P> \
+ result operator()(const P& p) const \
+ { \
+ return l_(p) Symbol r_(p); \
+ } \
+ \
+ protected: \
+ L l_; \
+ R r_; \
+ }; \
+ \
+ } \
+ \
+ namespace trait \
+ { \
+ \
+ template <typename L, typename R> \
+ struct set_binary_< op::Name, \
+ Function_##In, L, \
+ Function_##In, R > \
+ { \
+ typedef fun::Name##_##Out##_expr_<L,R> ret; \
+ }; \
+ } \
+ \
+ template <typename L, typename R> \
+ fun::Name##_##Out##_expr_<L,R> \
+ operator Symbol (const Function_##In<L>& lhs, const Function_##In<R>& rhs) \
+ { \
+ fun::Name##_##Out##_expr_<L,R> tmp(exact(lhs), exact(rhs)); \
+ return tmp; \
+ } \
+ \
+ struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_u_m_n
+
+
+# define mln_decl_unary_expr_(In, Out, Name, Symbol) \
+ \
+ namespace fun \
+ { \
+ \
+ template <typename F> \
+ struct Name##_##Out##_expr_ \
+ : public Function_##Out< Name##_##Out##_expr_<F> > \
+ { \
+ typedef typename mln::trait::op:: Name < mln_result(F) >::ret result; \
+ \
+ Name##_##Out##_expr_() \
+ { \
+ } \
+ \
+ Name##_##Out##_expr_(const F& f) \
+ : f_(f) \
+ { \
+ } \
+ \
+ template <typename P> \
+ result operator()(const P& p) const \
+ { \
+ return Symbol f_(p); \
+ } \
+ \
+ protected: \
+ F f_; \
+ }; \
+ \
+ } \
+ \
+ namespace trait \
+ { \
+ template <typename F> \
+ struct set_unary_< op::Name, \
+ Function_##In, F > \
+ { \
+ typedef fun::Name##_##Out##_expr_<F> ret; \
+ }; \
+ } \
+ \
+ template <typename F> \
+ fun::Name##_##Out##_expr_<F> \
+ operator Symbol (const Function_##In<F>& f) \
+ { \
+ fun::Name##_##Out##_expr_<F> tmp(exact(f)); \
+ return tmp; \
+ } \
+ \
+ struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_u_m_n
+
+
+
+namespace mln
+{
+ // -> p2v
+
+ mln_decl_binary_expr_(p2v, p2b, eq, ==);
+ mln_decl_binary_expr_(p2v, p2b, neq, !=);
+
+ mln_decl_binary_expr_(p2v, p2b, less, <);
+ mln_decl_binary_expr_(p2v, p2b, leq , <=);
+ mln_decl_binary_expr_(p2v, p2b, geq, >=);
+ mln_decl_binary_expr_(p2v, p2b, greater, >);
+
+ mln_decl_binary_expr_(p2b, p2b, and_, &&);
+ mln_decl_binary_expr_(p2b, p2b, or_, ||);
+ mln_decl_binary_expr_(p2b, p2b, xor_, ^);
+
+ mln_decl_unary_expr_(p2b, p2b, not_, !);
+
+ mln_decl_binary_expr_(p2v, p2v, plus, +);
+ mln_decl_binary_expr_(p2v, p2v, minus, -);
+ mln_decl_binary_expr_(p2v, p2v, times, *);
+ mln_decl_binary_expr_(p2v, p2v, div, /);
+ mln_decl_binary_expr_(p2v, p2v, mod, %);
+
+ mln_decl_unary_expr_(p2v, p2v, uplus, +);
+ mln_decl_unary_expr_(p2v, p2v, uminus, -);
+
+ // -> v2b
+
+ mln_decl_binary_expr_(v2v, v2b, eq, ==);
+ mln_decl_binary_expr_(v2v, v2b, neq, !=);
+
+ mln_decl_binary_expr_(v2v, v2b, less, <);
+ mln_decl_binary_expr_(v2v, v2b, leq, <=);
+ mln_decl_binary_expr_(v2v, v2b, geq, >=);
+ mln_decl_binary_expr_(v2v, v2b, greater, >);
+
+ mln_decl_binary_expr_(v2b, v2b, and_, &&);
+ mln_decl_binary_expr_(v2b, v2b, or_, ||);
+ mln_decl_binary_expr_(v2b, v2b, xor_, ^);
+
+ mln_decl_unary_expr_(v2b, v2b, not_, !);
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_OPS_HH
Index: jardonnet/perl/test/c.hh
--- jardonnet/perl/test/c.hh (revision 0)
+++ jardonnet/perl/test/c.hh (revision 0)
@@ -0,0 +1,140 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_C_HH
+# define MLN_FUN_C_HH
+
+/*! \file mln/fun/c.hh
+ *
+ * \brief Encapsulate a plain (C language-like) pointer to function
+ * into a functor.
+ */
+
+# include <mln/fun/internal/selector.hh>
+# include <mln/metal/unqualif.hh>
+
+
+namespace mln
+{
+
+ /// Concept-like.
+ template <typename E>
+ struct C_Function;
+
+
+ /// Category declaration for a unary C function.
+ template <typename R, typename A>
+ struct category< R (*)(A) >
+ {
+ typedef C_Function<void> ret;
+ };
+
+
+
+ // Forward declaration.
+ namespace fun { template <typename F> struct C; }
+
+
+
+ namespace trait
+ {
+
+ template <template <class> class Op,
+ typename R, typename A>
+ struct set_unary_< Op, C_Function, R (*)(A) >
+ {
+ typedef Op< fun::C<R (*)(A)> > Op_;
+ typedef typename Op_::ret ret;
+ };
+
+ template <template <class, class> class Op,
+ typename O,
+ typename R, typename A>
+ struct set_binary_< Op,
+ Object, O,
+ C_Function, R (*)(A) >
+ {
+ typedef Op< O, fun::C<R (*)(A)> > Op_;
+ typedef typename Op_::ret ret;
+ };
+
+ } // end of namespace trait
+
+
+
+ namespace fun
+ {
+
+ template <typename F> struct C;
+
+
+ // FIXME: Doc!
+ template <typename R, typename A>
+ struct C< R (*)(A) >
+ :
+ fun::internal::selector_< R, A, C<R(*)(A)> >::ret
+ {
+ C();
+ C(R (*f)(A));
+ typedef R result;
+ R operator()(const mlc_unqualif(A)& a) const;
+ protected:
+ R (*f_)(A);
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename R, typename A>
+ inline
+ C<R(*)(A)>::C()
+ {
+ }
+
+ template <typename R, typename A>
+ inline
+ C<R(*)(A)>::C(R (*f)(A))
+ : f_(f)
+ {
+ }
+
+ template <typename R, typename A>
+ inline
+ R
+ C<R(*)(A)>::operator()(const mlc_unqualif(A)& a) const
+ {
+ return f_(a);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_P2B_C_HH
Index: jardonnet/perl/test/i2v/all.hh
--- jardonnet/perl/test/i2v/all.hh (revision 0)
+++ jardonnet/perl/test/i2v/all.hh (revision 0)
@@ -0,0 +1,56 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_I2V_ALL_HH
+# define MLN_FUN_I2V_ALL_HH
+
+/*! \file mln/fun/i2v/all.hh
+ *
+ * \brief File that includes all functions from index to value.
+ */
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ /// Namespace of functions from index to value.
+ namespace i2v
+ {
+ }
+ }
+
+}
+
+
+# include <mln/fun/i2v/all_to.hh>
+
+
+
+#endif // ! MLN_FUN_I2V_ALL_HH
Index: jardonnet/perl/test/i2v/all_to.hh
--- jardonnet/perl/test/i2v/all_to.hh (revision 0)
+++ jardonnet/perl/test/i2v/all_to.hh (revision 0)
@@ -0,0 +1,108 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_I2V_ALL_TO_HH
+# define MLN_FUN_I2V_ALL_TO_HH
+
+/*! \file mln/fun/i2v/all_to.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace i2v
+ {
+
+ template <typename T>
+ struct all_to : public Function_i2v< all_to<T> >
+ {
+ typedef T result;
+ all_to(T t);
+ template <typename U>
+ T operator()(const U&) const;
+ private:
+ T t_;
+ };
+
+ } // end of namespace mln::fun::i2v
+
+ } // end of namespace mln::fun
+
+ template <typename T>
+ fun::i2v::all_to<T> all_to(T t);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace fun
+ {
+
+ namespace i2v
+ {
+
+ template <typename T>
+ inline
+ all_to<T>::all_to(T t)
+ : t_(t)
+ {
+ }
+
+ template <typename T>
+ template <typename U>
+ inline
+ T
+ all_to<T>::operator()(const U&) const
+ {
+ return t_;
+ }
+
+ } // end of namespace mln::fun::i2v
+
+ } // end of namespace mln::fun
+
+ template <typename T>
+ inline
+ fun::i2v::all_to<T> all_to(T t)
+ {
+ fun::i2v::all_to<T> tmp(t);
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_I2V_ALL_TO_HH
Index: jardonnet/perl/test/i2v/array.hh
--- jardonnet/perl/test/i2v/array.hh (revision 0)
+++ jardonnet/perl/test/i2v/array.hh (revision 0)
@@ -0,0 +1,147 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_I2V_ARRAY_HH
+# define MLN_FUN_I2V_ARRAY_HH
+
+/*! \file mln/fun/i2v/array.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <vector>
+# include <algorithm>
+# include <mln/core/concept/function.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace i2v
+ {
+
+ template <typename T>
+ class array : public Function_i2v< array<T> >
+ {
+ public:
+
+ typedef T result;
+
+ array();
+ array(unsigned n);
+
+ void resize(unsigned n);
+ unsigned size() const;
+
+ T operator()(unsigned i) const;
+ T& operator()(unsigned i);
+
+ private:
+ std::vector<T> v_;
+ };
+
+ } // end of namespace mln::fun::i2v
+
+ } // end of namespace mln::fun
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace fun
+ {
+
+ namespace i2v
+ {
+
+ template <typename T>
+ inline
+ array<T>::array()
+ {
+ }
+
+ template <typename T>
+ inline
+ array<T>::array(unsigned n)
+ {
+ resize(n);
+ }
+
+ template <typename T>
+ inline
+ void
+ array<T>::resize(unsigned n)
+ {
+ v_.resize(n);
+ }
+
+ template <typename T>
+ inline
+ unsigned
+ array<T>::size() const
+ {
+ return v_.size();
+ }
+
+ template <typename T>
+ inline
+ T
+ array<T>::operator()(unsigned i) const
+ {
+ mln_precondition(i < v_.size());
+ return v_[i];
+ }
+
+ template <typename T>
+ inline
+ T&
+ array<T>::operator()(unsigned i)
+ {
+ mln_precondition(i < v_.size());
+ return v_[i];
+ }
+
+ } // end of namespace mln::fun::i2v
+
+ } // end of namespace mln::fun
+
+ template <typename T>
+ inline
+ fun::i2v::array<T> array(T t)
+ {
+ fun::i2v::array<T> tmp(t);
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_I2V_ARRAY_HH
Index: jardonnet/perl/test/x2x/all.hh
--- jardonnet/perl/test/x2x/all.hh (revision 0)
+++ jardonnet/perl/test/x2x/all.hh (revision 0)
@@ -0,0 +1,66 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_X2X_ALL_HH
+# define MLN_FUN_X2X_ALL_HH
+
+/*! \file mln/fun/x2x/all.hh
+ *
+ * \brief File that includes all functions from vector to vector.
+ */
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ /// Namespace of functions from vector to vector.
+ namespace x2x
+ {
+
+ /// Internal namespace of functions form vector to vector.
+ namespace internal
+ {
+ }
+ }
+ }
+
+}
+
+
+# include <mln/fun/x2x/geom/composed.hh>
+# include <mln/fun/x2x/geom/rotation.hh>
+# include <mln/fun/x2x/geom/translation.hh>
+
+# include <mln/fun/x2x/interpol/linear.hh>
+# include <mln/fun/x2x/interpol/bilinear.hh>
+
+
+
+#endif // ! MLN_FUN_X2X_ALL_HH
Index: jardonnet/perl/test/x2x/geom/composed.hh
--- jardonnet/perl/test/x2x/geom/composed.hh (revision 0)
+++ jardonnet/perl/test/x2x/geom/composed.hh (revision 0)
@@ -0,0 +1,285 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_X2X_GEOM_COMPOSED_HH
+# define MLN_FUN_X2X_GEOM_COMPOSED_HH
+
+/*! \file mln/fun/x2x/composed.hh
+ *
+ * \brief Definition of a composed transformation.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/fun/internal/x2x_linear_impl.hh>
+# include <mln/algebra/vec.hh>
+# include <mln/metal/is.hh>
+# include <mln/metal/bexpr.hh>
+# include <mln/algebra/h_mat.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace x2x
+ {
+
+ namespace geom
+ {
+
+ // Fwd decl.
+ template <typename F, typename G>
+ struct composed;
+
+ namespace internal
+ {
+ template <typename F, typename G, typename E, bool is_bij>
+ struct helper_composed_;
+
+
+ /// Helper for describing a bijective composition.
+ template <typename F, typename G, typename E>
+ struct helper_composed_< F, G, E, true>
+ : public fun::internal::x2x_linear_impl_<mln_result(F), E >,
+ public Bijection_x2x<E>
+ {
+ typedef fun::internal::x2x_linear_impl_<typename F::result, E > super_;
+
+ using super_::dim;
+
+ /// Constructor without argument.
+ helper_composed_();
+ /// Constructor with the two transformation to be composed.
+ helper_composed_(const F& f, const G& g);
+
+ using super_::operator();
+
+ /// Set the new first transformation.
+ void set_first(const F& f);
+ /// Set the new second transformation.
+ void set_second(const G& g);
+
+ /// Type of the inverse function.
+ typedef composed<mln_invert(G),mln_invert(F)> invert;
+ /// Return the inverse function.
+ invert inv() const;
+
+ protected:
+
+ F f_;
+ G g_;
+ };
+
+ /// Helper for describing a non bijective composition.
+ template <typename F, typename G, typename E>
+ struct helper_composed_< F, G, E, false>
+ : public fun::internal::x2x_linear_impl_<mln_result(F), E >,
+ public Function_x2x<E>
+ {
+ typedef fun::internal::x2x_linear_impl_<typename F::result, E > super_;
+
+ using super_::dim;
+
+ /// Constructor without argument.
+ helper_composed_();
+ /// Constructor with the two transformation to be composed.
+ helper_composed_(const F& f, const G& g);
+
+ using super_::operator();
+
+ /// Set the new first transformation.
+ void set_first(const F& f);
+ /// Set the new second transformation.
+ void set_second(const G& g);
+
+ protected:
+
+ F f_;
+ G g_;
+ };
+
+ } // end of namespace mln::fun::x2x::geom::internal
+
+
+ /*! \brief Represent a composition of two transformations.
+ *
+ */
+ template <typename F, typename G>
+ struct composed
+ : public internal::helper_composed_<F, G, composed<F,G>,
+ mlc_is(F, Bijection_x2x<F>)::value &&
+ mlc_is(G, Bijection_x2x<G>)::value>,
+ private metal::and_< metal::bool_<(F::dim == G::dim)>,
+ metal::is<mln_argument(F), mln_result(G)>
+ >::check_t
+ {
+ /// Constructor without argument.
+ composed() {}
+
+ /// Constructor with the two transformation to be composed.
+ composed(const F& f, const G& g)
+ : internal::helper_composed_<F, G, composed<F,G>,
+ mlc_is(F, Bijection_x2x<F>)::value &&
+ mlc_is(G, Bijection_x2x<G>)::value>(f, g)
+ {
+ }
+ };
+
+ } // end of namespace mln::fun::x2x::geom
+
+ } // end of namespace mln::fun::x2x
+
+ } // end of namespace mln::fun
+
+
+ /*! \brief Do a composition of two transformations
+ *
+ * \param[in] f The first transformation.
+ * \param[in] g The second transformation.
+ *
+ * \return The composed transformation fog.
+ */
+ template <typename F, typename G>
+ fun::x2x::geom::composed<F,G> compose(F f, G g);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace fun
+ {
+
+ namespace x2x
+ {
+
+ namespace geom
+ {
+
+ namespace internal
+ {
+
+ // Implementation of the bijective version.
+
+ template <typename F, typename G, typename E>
+ inline
+ helper_composed_<F,G,E,true>::helper_composed_()
+ {
+ }
+
+ template <typename F, typename G, typename E>
+ inline
+ helper_composed_<F,G,E,true>::helper_composed_(const F& f, const G& g)
+ :f_(f),
+ g_(g)
+ {
+ this->m_ = f_.mat() * g_.mat();
+ }
+
+ template <typename F, typename G, typename E>
+ inline
+ typename helper_composed_<F,G,E,true>::invert
+ helper_composed_<F,G,E,true>::inv() const
+ {
+ return compose(g_.inv(), f_.inv());
+ }
+
+ template <typename F, typename G, typename E>
+ inline
+ void
+ helper_composed_<F,G,E,true>::set_first(const F& f)
+ {
+ this->f_ = f;
+ this->m_ = this->f_.mat() * this->g_.mat();
+ }
+
+ template <typename F, typename G, typename E>
+ inline
+ void
+ helper_composed_<F,G,E,true>::set_second(const G& g)
+ {
+ this->g_ = g;
+ this->m_ = this->f_.mat() * this->g_.mat();
+ }
+
+ // Implementation of the non bijective version.
+ template <typename F, typename G, typename E>
+ inline
+ helper_composed_<F,G,E,false>::helper_composed_()
+ {
+ }
+
+ template <typename F, typename G, typename E>
+ inline
+ helper_composed_<F,G,E,false>::helper_composed_(const F& f, const G& g)
+ :f_(f),
+ g_(g)
+ {
+ this->m_ = f_.mat() * g_.mat();
+ }
+
+ template <typename F, typename G, typename E>
+ inline
+ void
+ helper_composed_<F,G,E,false>::set_first(const F& f)
+ {
+ this->f_ = f;
+ this->m_ = this->f_.mat() * this->g_.mat();
+ }
+
+ template <typename F, typename G, typename E>
+ inline
+ void
+ helper_composed_<F,G,E,false>::set_second(const G& g)
+ {
+ this->g_ = g;
+ this->m_ = this->f_.mat() * this->g_.mat();
+ }
+
+ } // end of namespace mln::fun::x2x::geom::internal
+
+ } // end of namespace mln::fun::x2x::geom
+
+ } // end of namespace mln::fun::x2x
+
+ } // end of namespace mln::fun
+
+ template <typename F, typename G>
+ inline
+ fun::x2x::geom::composed<F,G> compose(F f, G g)
+ {
+ trace::entering("fun::x2x::compose");
+ fun::x2x::geom::composed<F,G> comp(f, g);
+ trace::exiting("fun::x2x::compose");
+ return comp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_X2X_GEOM_COMPOSED_HH
Index: jardonnet/perl/test/x2x/geom/translation.hh
--- jardonnet/perl/test/x2x/geom/translation.hh (revision 0)
+++ jardonnet/perl/test/x2x/geom/translation.hh (revision 0)
@@ -0,0 +1,152 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_X2X_TRANSLATION_HH
+# define MLN_FUN_X2X_TRANSLATION_HH
+
+/*! \file mln/fun/x2x/translation.hh
+ *
+ * \brief Define a translation function.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/fun/internal/x2x_linear_impl.hh>
+# include <mln/algebra/vec.hh>
+# include <mln/algebra/h_mat.hh>
+# include <mln/fun/i2v/all.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace x2x
+ {
+
+ namespace geom
+ {
+
+ /*! \brief Represent a translation function.
+ *
+ */
+ template <unsigned n, typename C>
+ struct translation
+ : fun::internal::x2x_linear_impl_< algebra::vec<n,C>, translation<n,C> >
+ , public Bijection_x2x< translation<n,C> >
+ {
+ typedef fun::internal::x2x_linear_impl_< algebra::vec<n,C>, translation<n,C> > super_;
+
+ /// Type of the inverse function.
+ typedef translation<n,C> invert;
+ /// Return the inverse function.
+ invert inv() const;
+
+ /// Constructor without argument.
+ translation();
+ /// Constructor with the translation vector.
+ translation(const algebra::vec<n,C>& t);
+
+ using super_::operator();
+ /// Perform the translation of the given vector
+ algebra::vec<n,C> operator()(const algebra::vec<n,C>& v) const;
+
+ /// Set a net translation vector.
+ void set_t(const algebra::vec<n,C>& t);
+
+ protected:
+ void update();
+
+ algebra::vec<n,C> t_;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <unsigned n, typename C>
+ inline
+ translation<n,C>::translation()
+ {
+ }
+
+ template <unsigned n, typename C>
+ inline
+ translation<n,C>::translation(const algebra::vec<n,C>& t)
+ :t_(t)
+ {
+ this->update();
+ }
+
+ template <unsigned n, typename C>
+ inline
+ algebra::vec<n,C>
+ translation<n,C>::operator()(const algebra::vec<n,C>& v) const
+ {
+ return v + t_;
+ }
+
+ template <unsigned n, typename C>
+ inline
+ translation<n,C>
+ translation<n,C>::inv() const
+ {
+ typename translation::invert res(-t_);
+
+ return res;
+ }
+
+ template <unsigned n, typename C>
+ inline
+ void
+ translation<n,C>::set_t(const algebra::vec<n,C>& t)
+ {
+ this->t_ = t;
+ this->update();
+ }
+
+ template <unsigned n, typename C>
+ inline
+ void
+ translation<n,C>::update()
+ {
+ this->m_ = algebra::h_mat<n,C>::Id;
+ for (unsigned i = 0; i < n; ++i)
+ this->m_(i,n) = this->t_[i];
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::x2x::geom
+
+ } // end of namespace mln::fun::x2x
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_X2X_TRANSLATION_HH
Index: jardonnet/perl/test/x2x/geom/rotation.hh
--- jardonnet/perl/test/x2x/geom/rotation.hh (revision 0)
+++ jardonnet/perl/test/x2x/geom/rotation.hh (revision 0)
@@ -0,0 +1,243 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_X2X_ROTATION_HH
+# define MLN_FUN_X2X_ROTATION_HH
+
+/*! \file mln/fun/x2x/rotation.hh
+ *
+ * \brief Define a rotation function.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/fun/internal/x2x_linear_impl.hh>
+# include <mln/algebra/vec.hh>
+# include <mln/algebra/mat.hh>
+# include <cmath>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace x2x
+ {
+
+ namespace geom
+ {
+
+ namespace internal
+ {
+ template < unsigned n, typename C >
+ algebra::h_mat<n, C>
+ get_rot_h_mat(const float alpha_, const algebra::vec<3,C>& axis_)
+ {
+ assert(!"get_h_mat : n not implemented");
+ }
+
+ template <typename C >
+ algebra::h_mat<3, C>
+ get_rot_h_mat(const float alpha_, const algebra::vec<3,C>& axis_)
+ {
+ algebra::h_mat<3, C> m_;
+
+ const float cos_a = cos(alpha_);
+ const float sin_a = sin(alpha_);
+ const float u = axis_[0];
+ const float v = axis_[1];
+ const float w = axis_[2];
+ const float u2 = u * u;
+ const float v2 = v * v;
+ const float w2 = w * w;
+ const float uvw2 = u2 + v2 + w2;
+
+ m_(0,0) = (u2 + (v2 + w2) * cos_a) / uvw2;
+ m_(0,1) = (u*v * (1 - cos_a) - u * std::sqrt(uvw2) * sin_a) / uvw2;
+ m_(0,2) = (u*w * (1 - cos_a) + v * std::sqrt(uvw2) * sin_a) / uvw2;
+ m_(0,3) = 0;
+
+ m_(1,0) = (u*v * (1 - cos_a) + w * std::sqrt(uvw2) * sin_a) / uvw2;
+ m_(1,1) = (v2 + (u2 + w2) * cos_a) / uvw2;
+ m_(1,2) = (v*w * (1 - cos_a) - u * std::sqrt(uvw2) * sin_a) / uvw2;
+ m_(1,3) = 0;
+
+ m_(2,0) = (u*w * (1 - cos_a) - v * std::sqrt(uvw2) * sin_a) / uvw2;
+ m_(2,1) = (v*w * (1 - cos_a) + u * std::sqrt(uvw2) * sin_a) / uvw2;
+ m_(2,1) = (u2 + (u2 + v2) * cos_a) / uvw2;
+ m_(2,3) = 0;
+
+ m_(2,0) = 0;
+ m_(2,1) = 0;
+ m_(2,1) = 0;
+ m_(2,3) = 1;
+
+ return m_;
+ }
+
+ template <typename C >
+ algebra::h_mat<2, C>
+ get_rot_h_mat(const float alpha_, const algebra::vec<2,C>&)
+ {
+ algebra::h_mat<2, C> m_;
+
+ const float cos_a = cos(alpha_);
+ const float sin_a = sin(alpha_);
+
+ m_(0,0) = cos_a; m_(0,1) = -sin_a; m_(0,2) = 0;
+
+ m_(1,0) = sin_a; m_(1,1) = cos_a; m_(1,2) = 0;
+
+ m_(2,0) = 0; m_(2,1) = 0; m_(2,2) = 1;
+
+ return m_;
+ }
+ }
+
+
+ /*! \brief Represent a rotation function.
+ *
+ */
+ template <unsigned n, typename C>
+ struct rotation
+ : fun::internal::x2x_linear_impl_< algebra::vec<n,C>, rotation<n,C> >
+ , public Bijection_x2x< rotation<n,C> >
+ {
+ typedef fun::internal::x2x_linear_impl_< algebra::vec<n,C>, rotation<n,C> > super_;
+
+ /// Type of the inverse function.
+ typedef rotation<n,C> invert;
+ /// Return the invere function.
+ invert inv() const;
+
+ /// Constructor without argument.
+ rotation();
+ /// Constructor with grade alpha and a facultative direction (rotation axis).
+ rotation(float alpha, const algebra::vec<n,float>& axis);
+
+ using super_::operator();
+ /// Perform the rotation of the given vector.
+ algebra::vec<n,C> operator()(const algebra::vec<n,C>& v) const;
+
+ /// Set a new grade alpha.
+ void set_alpha(float alpha);
+ /// Set a new rotation axis.
+ void set_dir(unsigned dir);
+
+ protected:
+ void update();
+
+ float alpha_;
+ algebra::vec <n,float> axis_;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <unsigned n, typename C>
+ inline
+ rotation<n,C>::rotation()
+ {
+ }
+
+ template <unsigned n, typename C>
+ inline
+ rotation<n,C>::rotation(float alpha, const algebra::vec<n,float>& axis)
+ :alpha_(alpha),
+ axis_(axis)
+ {
+ this->m_ = algebra::h_mat<n,C>::Id;
+ update();
+ }
+
+ template <unsigned n, typename C>
+ inline
+ algebra::vec<n,C>
+ rotation<n,C>::operator()(const algebra::vec<n,C>& v) const
+ {
+ algebra::mat<n+1,1,C> hmg;
+ algebra::mat<n+1,1,C> tmp;
+ algebra::vec<n,C> res;
+
+ for (unsigned i = 0; i < n; ++i)
+ hmg(i,0) = v[i];
+ hmg(n,0) = 1;
+ tmp = this->m_ * hmg;
+ mln_assertion(tmp(n,0) == 1);
+ for (unsigned i = 0; i < n; ++i)
+ res[i] = tmp(i,0);
+ return res;
+ }
+
+ template <unsigned n, typename C>
+ inline
+ rotation<n,C>
+ rotation<n,C>::inv() const
+ {
+ typename rotation::invert res(-alpha_, axis_);
+ return res;
+ }
+
+ template <unsigned n, typename C>
+ inline
+ void
+ rotation<n,C>::set_alpha(float alpha)
+ {
+ alpha_ = alpha;
+ update();
+ }
+
+ template <unsigned n, typename C>
+ inline
+ void
+ rotation<n,C>::set_dir(unsigned dir)
+ {
+ update();
+ }
+
+ // Homogenous matrix for a rotation of a point (x,y,z)
+ // about the vector (u,v,w) by the angle alpha
+ template <unsigned n, typename C>
+ inline
+ void
+ rotation<n,C>::update()
+ {
+ this->m_ = internal::get_rot_h_mat(alpha_, axis_);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::x2x::geom
+
+ } // end of namespace mln::fun::x2x
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_X2X_ROTATION_HH
Index: jardonnet/perl/test/x2x/interpol/bilinear.hh
--- jardonnet/perl/test/x2x/interpol/bilinear.hh (revision 0)
+++ jardonnet/perl/test/x2x/interpol/bilinear.hh (revision 0)
@@ -0,0 +1,139 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_X2X_INTERPOL_BILINEAR_HH
+# define MLN_FUN_X2X_INTERPOL_BILINEAR_HH
+
+# include <mln/core/image/image2d.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/fun/internal/selector.hh>
+
+/*! \file mln/fun/x2x/interpol/bilinear.hh
+ *
+ * \brief Define a bilinear interpolation of values from an underlying image
+ */
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace x2x
+ {
+
+ namespace interpol
+ {
+
+
+ /*! \brief Represent a bilinear interolation of values from an underlying image
+ *
+ */
+ template < typename I >
+ struct bilinear
+ : public fun::internal::selector_<const algebra::vec<3,float>,
+ // 3,float is a dummy parameter (real is n,T)
+ mln_value(I), bilinear<I> >::ret
+ {
+ typedef mln_value(I) result;
+
+ bilinear(const I& ima);
+
+ template <unsigned n, typename T>
+ mln_value(I)
+ operator()(const algebra::vec<n,T>& v) const;
+
+ const I& ima;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ bilinear<I>::bilinear(const I& ima) : ima(ima)
+ {
+ mlc_bool(I::psite::dim == 2)::check();
+ }
+
+ template <typename I>
+ template <unsigned n, typename T>
+ mln_value(I)
+ bilinear<I>::operator()(const algebra::vec<n,T>& v) const
+ {
+ typedef mln_sum(mln_value(I)) vsum;
+
+ // q12----r2----q22
+ // | | |
+ // | x |
+ // | | |
+ // q11----r1----q21
+
+ // looking for img(P(x,y))
+ double x = v[0];
+ double y = v[1];
+
+ double x1 = std::floor(v[0]);
+ double x2 = std::floor(v[0]) + 1;
+ double y1 = std::floor(v[1]);
+ double y2 = std::floor(v[1]) + 1;
+
+ //if (not ima.has(point2d(x1, y1))) return mln_value(I)();
+ vsum q11 = ima(point2d(x1, y1));
+ vsum q12 = ima(point2d(x1, y2));
+ vsum q21 = ima(point2d(x2, y1));
+ vsum q22 = ima(point2d(x2, y2));
+
+ double x2_x1 = x2 - x1;
+ double y2_y1 = y2 - y1;
+
+ // linear interpolation #1
+ vsum img_r1 = q11 * (x2 - x) / (x2_x1) +
+ q21 * (x - x1) / (x2_x1);
+
+ // linear interpolation #2
+ vsum img_r2 = q12 * (x2 - x) / (x2_x1) + q22 * (x - x1) / (x2_x1);
+
+ // interpolating in y direction
+ vsum res = (img_r1 * (y2 - y) / (y2_y1)
+ + img_r2 * (y - y1) / (y2_y1));
+
+ return convert::to<mln_value(I)>(res);
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::x2x::interpol
+
+ } // end of namespace mln::fun::x2x
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_X2X_INTERPOL_BILINEAR_HH
Index: jardonnet/perl/test/x2x/interpol/test.cc
--- jardonnet/perl/test/x2x/interpol/test.cc (revision 0)
+++ jardonnet/perl/test/x2x/interpol/test.cc (revision 0)
@@ -0,0 +1,14 @@
+#include "bilinear.hh"
+#include "linear.hh"
+
+int main()
+{
+ typedef mln::image2d<int> I;
+ typedef mln::image1d<int> II;
+
+ I ima2d;
+ II ima1d;
+
+ mln::fun::x2x::interpol::bilinear<I> interp(ima2d);
+ mln::fun::x2x::interpol::linear<II> interp3(ima1d);
+}
Index: jardonnet/perl/test/x2x/interpol/linear.hh
--- jardonnet/perl/test/x2x/interpol/linear.hh (revision 0)
+++ jardonnet/perl/test/x2x/interpol/linear.hh (revision 0)
@@ -0,0 +1,124 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_X2X_INTERPOL_LINEAR_HH
+# define MLN_FUN_X2X_INTERPOL_LINEAR_HH
+
+/*! \file mln/fun/x2x/interpol/linear.hh
+ *
+ * \brief Define a linear interpolation of values from an underlying image
+ */
+
+# include <mln/core/image/image1d.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/fun/internal/selector.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace x2x
+ {
+
+ namespace interpol
+ {
+
+
+ /*! \brief Represent a linear interolation of values from an underlying image
+ *
+ */
+ template < typename I >
+ struct linear
+ : public fun::internal::selector_<const algebra::vec<1,float>,
+ // float is a dummy parameter (real is C)
+ mln_value(I), linear<I> >::ret
+ {
+ typedef mln_value(I) result;
+
+ /// Constructor with the underlying image
+ linear(const I& ima);
+
+ /// Return the interpolated value in the underlying image
+ /// at the given 'point' v.
+ template <typename C>
+ mln_value(I)
+ operator()(const algebra::vec<1,C>& v) const;
+
+ /// Underlying image
+ const I& ima;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ linear<I>::linear(const I& ima) : ima(ima)
+ {
+ mlc_bool(I::psite::dim == 1)::check();
+ }
+
+ template <typename I>
+ template <typename C>
+ mln_value(I)
+ linear<I>::operator()(const algebra::vec<1,C>& v) const
+ {
+ typedef mln_sum(mln_value(I)) vsum;
+
+ // looking for img(x);
+ double x = v[0];
+
+ // p1
+ double xa = mln_point(I)::coord(v[0]);
+ vsum ya = ima(point1d(xa));
+
+ // x makes sens in img
+ if (x == xa)
+ return ima(xa);
+
+ // p2
+ double xb = mln_point(I)::coord(v[0] + 1);
+ vsum yb = ima(point1d(xb));
+
+ // Taylor-young
+ return convert::to<mln_value(I)>
+ (ya + (x - xa) * (yb - ya) / (xb - xa));
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::x2x::interpol
+
+ } // end of namespace mln::fun::x2x
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_X2X_INTERPOL_HH
Index: jardonnet/perl/test/p2b/chess.hh
--- jardonnet/perl/test/p2b/chess.hh (revision 0)
+++ jardonnet/perl/test/p2b/chess.hh (revision 0)
@@ -0,0 +1,78 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_P2B_CHESS_HH
+# define MLN_FUN_P2B_CHESS_HH
+
+/*! \file mln/fun/p2b/chess.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/core/alias/point2d.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace p2b
+ {
+
+ // FIXME: Doc!
+
+ struct chess_t : public Function_p2b< chess_t >
+ {
+ typedef bool result;
+ bool operator()(const point2d& p) const;
+ }
+
+ chess;
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ inline
+ bool
+ chess_t::operator()(const point2d& p) const
+ {
+ return (p.row() + p.col()) % 2 == 0;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::p2b
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_P2B_CHESS_HH
Index: jardonnet/perl/test/p2b/all.hh
--- jardonnet/perl/test/p2b/all.hh (revision 0)
+++ jardonnet/perl/test/p2b/all.hh (revision 0)
@@ -0,0 +1,56 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_P2B_ALL_HH
+# define MLN_FUN_P2B_ALL_HH
+
+/*! \file mln/fun/p2b/all.hh
+ *
+ * \brief File that includes all functions from point to boolean.
+ */
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ /// Namespace of functions from point to boolean.
+ namespace p2b
+ {
+ }
+ }
+
+}
+
+
+# include <mln/fun/p2b/chess.hh>
+
+
+
+#endif // ! MLN_FUN_P2B_ALL_HH
Index: jardonnet/perl/test/p2b/has.hh
--- jardonnet/perl/test/p2b/has.hh (revision 0)
+++ jardonnet/perl/test/p2b/has.hh (revision 0)
@@ -0,0 +1,137 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_P2B_HAS_HH
+# define MLN_FUN_P2B_HAS_HH
+
+/*! \file mln/fun/p2b/has.hh
+ *
+ * \brief Function "psite-> bool" that maps the call "ima.has(p)".
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/metal/const.hh>
+# include <mln/metal/unconst.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace p2b
+ {
+
+ // FIXME: Doc!
+
+ template <typename I>
+ struct has
+
+ : public Function_p2b< has<I> >,
+ private mlc_is_a(I, Image)::check_t
+ {
+ /// Result associated type.
+ typedef bool result;
+
+ /// Apply the function on the psite \p p.
+ bool operator()(const mln_psite(I)& p) const;
+
+
+ /// Constructor without argument.
+ has();
+
+ /// Constructor from an image \p ima.
+ has(mlc_const(I)& ima);
+
+
+ /// Copy constructor.
+ has(const has<I>& rhs);
+
+ /// Assignment operator.
+ has<I>& operator=(const has<I>& rhs);
+
+ private:
+ mlc_const(I) ima_;
+ typedef Function_p2b< has<I> > super_;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ inline
+ bool
+ has<I>::operator()(const mln_psite(I)& p) const
+ {
+ return ima_.has(p);
+ }
+
+ template <typename I>
+ inline
+ has<I>::has()
+ : ima_()
+ {
+ }
+
+ template <typename I>
+ inline
+ has<I>::has(mlc_const(I)& ima)
+ : ima_(ima)
+ {
+ }
+
+ template <typename I>
+ inline
+ has<I>::has(const has<I>& rhs)
+ : Function_v2v< has<I> >(), // Please g++.
+ super_(),
+ ima_(rhs.ima_)
+ {
+ }
+
+ template <typename I>
+ inline
+ has<I>&
+ has<I>::operator=(const has<I>& rhs)
+ {
+ if (&rhs == this)
+ return *this;
+ const_cast<mlc_unconst(I)&>(this->ima_) = rhs.ima_;
+ return *this;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::p2b
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_P2B_HAS_HH
Index: jardonnet/perl/test/vv2v/min.hh
--- jardonnet/perl/test/vv2v/min.hh (revision 0)
+++ jardonnet/perl/test/vv2v/min.hh (revision 0)
@@ -0,0 +1,77 @@
+// 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_FUN_VV2V_MIN_HH
+# define MLN_FUN_VV2V_MIN_HH
+
+/// \file mln/fun/vv2v/min.hh
+/// \brief computing the minimum of two values using a functor.
+
+# include <mln/core/concept/function.hh>
+# include <mln/math/min.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace vv2v
+ {
+
+ // FIXME: Doc.
+
+ /// \brief A functor computing the minimum of two values.
+ template <typename V>
+ struct min : public Function_vv2v< min<V> >
+ {
+ typedef V result;
+ V operator()(const V& v1, const V& v2) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V>
+ inline
+ V
+ min<V>::operator()(const V& v1, const V& v2) const
+ {
+ return mln::math::min(v1, v2);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::vv2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_VV2V_MIN_HH
Index: jardonnet/perl/test/vv2v/max.hh
--- jardonnet/perl/test/vv2v/max.hh (revision 0)
+++ jardonnet/perl/test/vv2v/max.hh (revision 0)
@@ -0,0 +1,77 @@
+// 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_FUN_VV2V_MAX_HH
+# define MLN_FUN_VV2V_MAX_HH
+
+/// \file mln/fun/vv2v/max.hh
+/// \brief Computing the maximum of two values using a functor.
+
+# include <mln/core/concept/function.hh>
+# include <mln/math/max.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace vv2v
+ {
+
+ // FIXME: Doc.
+
+ /// \brief A functor computing the maximum of two values.
+ template <typename V>
+ struct max : public Function_vv2v< max<V> >
+ {
+ typedef V result;
+ V operator()(const V& v1, const V& v2) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V>
+ inline
+ V
+ max<V>::operator()(const V& v1, const V& v2) const
+ {
+ return mln::math::max(v1, v2);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::vv2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_VV2V_MAX_HH
Index: jardonnet/perl/test/all.hh
--- jardonnet/perl/test/all.hh (revision 0)
+++ jardonnet/perl/test/all.hh (revision 0)
@@ -0,0 +1,63 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_ALL_HH
+# define MLN_FUN_ALL_HH
+
+/*! \file mln/fun/all.hh
+ *
+ * \brief File that includes all fun-related routines.
+ */
+
+
+namespace mln
+{
+
+ /// Namespace of image processing routines related to functions.
+ namespace fun
+ {
+
+ /// Internal namespace of functions.
+ namespace internal
+ {
+ }
+ }
+
+}
+
+
+# include <mln/fun/c.hh>
+# include <mln/fun/ops.hh>
+# include <mln/fun/i2v/all.hh>
+# include <mln/fun/p2b/all.hh>
+# include <mln/fun/p2v/all.hh>
+# include <mln/fun/v2v/all.hh>
+# include <mln/fun/x2x/all.hh>
+
+
+
+#endif // ! MLN_FUN_ALL_HH
Index: jardonnet/perl/test/p2v/elifs.hh
--- jardonnet/perl/test/p2v/elifs.hh (revision 0)
+++ jardonnet/perl/test/p2v/elifs.hh (revision 0)
@@ -0,0 +1,85 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_P2V_ELIFS_HH
+# define MLN_FUN_P2V_ELIFS_HH
+
+/*! \file mln/fun/p2v/elifs.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/fun/p2v/ternary.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace p2v
+ {
+
+ template <typename T1, typename N1,
+ typename T2, typename N2,
+ typename O>
+ ternary_<T1, N1,
+ ternary_<T2, N2, O> >
+ elifs(const Function_p2b<T1>& f_if_1, const Function_p2v<N1>& f_then_1,
+ const Function_p2b<T2>& f_if_2, const Function_p2v<N2>& f_then_2,
+ const Function_p2v<O>& f_otherwise);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T1, typename N1,
+ typename T2, typename N2,
+ typename O>
+ inline
+ ternary_<T1, N1,
+ ternary_<T2, N2, O> >
+ elifs(const Function_p2b<T1>& f_if_1, const Function_p2v<N1>& f_then_1,
+ const Function_p2b<T2>& f_if_2, const Function_p2v<N2>& f_then_2,
+ const Function_p2v<O>& f_otherwise)
+ {
+ typedef ternary_<T2, N2, O> T2_N2_O;
+ T2_N2_O f_otherwise_1(f_if_2, f_then_2, f_otherwise);
+ ternary_<T1, N1, T2_N2_O> tmp(f_if_1, f_then_1, f_otherwise_1);
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::p2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_P2V_ELIFS_HH
Index: jardonnet/perl/test/p2v/ternary.hh
--- jardonnet/perl/test/p2v/ternary.hh (revision 0)
+++ jardonnet/perl/test/p2v/ternary.hh (revision 0)
@@ -0,0 +1,120 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_P2V_TERNARY_HH
+# define MLN_FUN_P2V_TERNARY_HH
+
+/*! \file mln/fun/p2v/ternary.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/fun/internal/selector.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace p2v
+ {
+
+ template <typename P, typename T, typename F>
+ struct ternary_
+ : fun::internal::selector_p2_<mln_result(T), ternary_<P,T,F> >::ret
+ {
+ typedef mln_result(T) result;
+
+ ternary_(const Function_p2b<P>& f_pred,
+ const Function_p2v<T>& f_true,
+ const Function_p2v<F>& f_false);
+
+ template <typename Pt>
+ result operator()(const Pt& p) const;
+
+ protected:
+ const P f_pred_;
+ const T f_true_;
+ const F f_false_;
+ };
+
+
+ template <typename P, typename T, typename F>
+ ternary_<P, T, F>
+ ternary(const Function_p2b<P>& f_pred,
+ const Function_p2v<T>& f_true,
+ const Function_p2v<F>& f_false);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P, typename T, typename F>
+ inline
+ ternary_<P,T,F>::ternary_(const Function_p2b<P>& f_pred,
+ const Function_p2v<T>& f_true,
+ const Function_p2v<F>& f_false)
+ : f_pred_(exact(f_pred)),
+ f_true_(exact(f_true)),
+ f_false_(exact(f_false))
+ {
+ }
+
+ template <typename P, typename T, typename F>
+ template <typename Pt>
+ inline
+ mln_result(T)
+ ternary_<P,T,F>::operator()(const Pt& p) const
+ {
+ return f_pred_(p) ? f_true_(p) : f_false_(p);
+ }
+
+
+ template <typename P, typename T, typename F>
+ inline
+ ternary_<P, T, F>
+ ternary(const Function_p2b<P>& f_pred,
+ const Function_p2v<T>& f_true,
+ const Function_p2v<F>& f_false)
+ {
+ ternary_<P, T, F> tmp(exact(f_pred),
+ exact(f_true),
+ exact(f_false));
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::p2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_P2V_TERNARY_HH
Index: jardonnet/perl/test/p2v/all.hh
--- jardonnet/perl/test/p2v/all.hh (revision 0)
+++ jardonnet/perl/test/p2v/all.hh (revision 0)
@@ -0,0 +1,58 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_P2V_ALL_HH
+# define MLN_FUN_P2V_ALL_HH
+
+/*! \file mln/fun/p2v/all.hh
+ *
+ * \brief File that includes all functions from point to value.
+ */
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ /// Namespace of functions from point to value.
+ namespace p2v
+ {
+ }
+ }
+
+}
+
+
+# include <mln/fun/p2v/elifs.hh>
+# include <mln/fun/p2v/iota.hh>
+# include <mln/fun/p2v/ternary.hh>
+
+
+
+#endif // ! MLN_FUN_P2V_ALL_HH
Index: jardonnet/perl/test/p2v/iota.hh
--- jardonnet/perl/test/p2v/iota.hh (revision 0)
+++ jardonnet/perl/test/p2v/iota.hh (revision 0)
@@ -0,0 +1,106 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_P2V_IOTA_HH
+# define MLN_FUN_P2V_IOTA_HH
+
+/*! \file mln/fun/p2v/iota.hh
+ *
+ * \brief Iota function.
+ */
+
+# include <mln/core/concept/function.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace p2v
+ {
+
+ struct iota_t : public Function_p2v< iota_t >
+ {
+ typedef unsigned result;
+
+ iota_t();
+
+ template <typename P>
+ unsigned operator()(const P&) const;
+
+ unsigned value() const;
+ void reset() const;
+
+ protected:
+ mutable unsigned i_;
+ }
+
+ iota;
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ inline
+ iota_t::iota_t()
+ {
+ reset();
+ }
+
+ template <typename P>
+ inline
+ unsigned
+ iota_t::operator()(const P&) const
+ {
+ return ++i_;
+ }
+
+ inline
+ unsigned
+ iota_t::value() const
+ {
+ return i_;
+ }
+
+ inline
+ void
+ iota_t::reset() const
+ {
+ i_ = 0;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::p2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_P2V_IOTA_HH
Index: jardonnet/perl/test/cast.hh
--- jardonnet/perl/test/cast.hh (revision 0)
+++ jardonnet/perl/test/cast.hh (revision 0)
@@ -0,0 +1,85 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_CAST_HH
+# define MLN_FUN_CAST_HH
+
+/*! \file mln/fun/cast.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ // FIXME: Doc!
+ template <typename V, typename F>
+ struct cast_p2v_expr_ : public Function_p2v< cast_p2v_expr_<V,F> >
+ {
+ typedef V result;
+
+ cast_p2v_expr_(const F& f)
+ : f_(f)
+ {}
+
+ template <typename P>
+ V operator()(const P& p) const
+ {
+ return static_cast<V>(f_(p)); // FIXME: value::cast?
+ }
+
+ protected:
+ const F f_;
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V, typename F>
+ inline
+ cast_p2v_expr_<V, F>
+ cast(const Function_p2v<F>& f)
+ {
+ cast_p2v_expr_<V, F> tmp(exact(f));
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_CAST_HH
Index: jardonnet/perl/test/v2b/threshold.hh
--- jardonnet/perl/test/v2b/threshold.hh (revision 0)
+++ jardonnet/perl/test/v2b/threshold.hh (revision 0)
@@ -0,0 +1,90 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_V2B_THRESHOLD_HH
+# define MLN_FUN_V2B_THRESHOLD_HH
+
+/*! \file mln/fun/v2b/threshold.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2b
+ {
+
+ /*!
+ *\brief Threshold function.
+ * f(v) = (v >= threshold).
+ *
+ */
+ template <typename V>
+ struct threshold : public Function_v2b< threshold<V> >
+ {
+ typedef bool result;
+ bool operator()(const V& v) const;
+
+ threshold(const V& a);
+ V a;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V>
+ inline
+ threshold<V>::threshold(const V& a)
+ : a(a)
+ {
+ }
+
+ template <typename V>
+ inline
+ bool
+ threshold<V>::operator()(const V& v) const
+ {
+ return (v >= a);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2b
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_V2B_THRESHOLD_HH
Index: jardonnet/perl/test/internal/x2x_linear_impl.hh
--- jardonnet/perl/test/internal/x2x_linear_impl.hh (revision 0)
+++ jardonnet/perl/test/internal/x2x_linear_impl.hh (revision 0)
@@ -0,0 +1,102 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_INTERNAL_X2X_LINEAR_IMPL_HH
+# define MLN_FUN_INTERNAL_X2X_LINEAR_IMPL_HH
+
+/*! \file mln/fun/internal/x2x_linear_impl.hh
+ *
+ * \brief Implementation class for every linear Function_x2x.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/algebra/h_mat.hh>
+# include <mln/algebra/h_vec.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace internal
+ {
+
+ template <typename V, typename E>
+ struct x2x_linear_impl_
+ {
+ static const unsigned dim = V::dim; // To please g++ when comparing dim in metal bexpr.
+
+ typedef V argument;
+ typedef V result;
+ typedef typename V::coord coord;
+ typedef algebra::h_mat<dim, coord> matrix;
+
+ V operator()(const V& x) const
+ {
+ algebra::h_vec<dim, coord> tmp = m_ * x.to_h_vec();
+ return tmp.to_vec();
+ }
+
+ const matrix& mat() const;
+
+ protected:
+ x2x_linear_impl_();
+
+ matrix m_;
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V, typename E>
+ inline
+ x2x_linear_impl_<V,E>::x2x_linear_impl_()
+ {
+ }
+
+
+ template <typename V, typename E>
+ inline
+ const typename x2x_linear_impl_<V,E>::matrix&
+ x2x_linear_impl_<V,E>::mat() const
+ {
+ return m_;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::internal
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_INTERNAL_X2X_LINEAR_IMPL_HH
Index: jardonnet/perl/test/internal/selector.hh
--- jardonnet/perl/test/internal/selector.hh (revision 0)
+++ jardonnet/perl/test/internal/selector.hh (revision 0)
@@ -0,0 +1,200 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_INTERNAL_SELECTOR_HH
+# define MLN_FUN_INTERNAL_SELECTOR_HH
+
+/*! \file mln/fun/internal/selector.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/core/concept/site.hh>
+# include <mln/core/concept/pseudo_site.hh>
+# include <mln/metal/unqualif.hh>
+# include <mln/metal/if.hh>
+# include <mln/metal/is_a.hh>
+# include <mln/algebra/vec.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace internal
+ {
+
+ // Function_v2v
+ // |
+ // + ---------------------- Function_v2b
+ // | |
+ // + -- Function_i2v |
+ // | |
+ // + -- Function_x2x |
+ // | |
+ // + -- Function_p2v |
+ // | |
+ // + -- Function_p2b -- +
+ // |
+ // + -- Function_p2p
+
+ enum
+ {
+ b_,
+ i_,
+ p_,
+ v_,
+ x_
+ };
+
+ template <int arg, int res, typename E> struct helper_selector_;
+
+ // b2* => v2v type, except for v2b
+ template <typename E>
+ struct helper_selector_< b_, b_, E > { typedef Function_v2b<E> ret; };
+ template <typename E>
+ struct helper_selector_< b_, i_, E > { typedef Function_v2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< b_, p_, E > { typedef Function_v2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< b_, v_, E > { typedef Function_v2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< b_, x_, E > { typedef Function_v2v<E> ret; };
+
+ // i2* => i2v type
+ template <typename E>
+ struct helper_selector_< i_, b_, E > { typedef Function_i2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< i_, i_, E > { typedef Function_i2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< i_, p_, E > { typedef Function_i2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< i_, v_, E > { typedef Function_i2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< i_, x_, E > { typedef Function_i2v<E> ret; };
+
+ // p2*
+ template <typename E>
+ struct helper_selector_< p_, b_, E > { typedef Function_p2b<E> ret; };
+ template <typename E>
+ struct helper_selector_< p_, i_, E > { typedef Function_p2v<E> ret; }; // no p2i type => p2v
+ template <typename E>
+ struct helper_selector_< p_, p_, E > { typedef Function_p2p<E> ret; };
+ template <typename E>
+ struct helper_selector_< p_, v_, E > { typedef Function_p2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< p_, x_, E > { typedef Function_p2v<E> ret; };
+
+ // v2* => v2v type, except for v2b
+ template <typename E>
+ struct helper_selector_< v_, b_, E > { typedef Function_v2b<E> ret; };
+ template <typename E>
+ struct helper_selector_< v_, i_, E > { typedef Function_v2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< v_, p_, E > { typedef Function_v2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< v_, v_, E > { typedef Function_v2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< v_, x_, E > { typedef Function_v2v<E> ret; };
+
+ // x2* => v2v type
+ template <typename E>
+ struct helper_selector_< x_, b_, E > { typedef Function_v2b<E> ret; };
+ template <typename E>
+ struct helper_selector_< x_, i_, E > { typedef Function_v2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< x_, p_, E > { typedef Function_v2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< x_, v_, E > { typedef Function_v2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< x_, x_, E > { typedef Function_v2v<E> ret; };
+
+ // tag_
+
+ template <typename T> struct tag_;
+
+ template <>
+ struct tag_< bool >
+ {
+ enum { value = b_ };
+ };
+
+ template <>
+ struct tag_< unsigned >
+ {
+ enum { value = i_ };
+ };
+
+ template <unsigned n, typename T>
+ struct tag_< algebra::vec<n,T> >
+ {
+ enum { value = x_ };
+ };
+
+ template <typename T>
+ struct tag_
+ {
+ enum { value = (mlc_is_a(T, Site)::value || mlc_is_a(T, Pseudo_Site)::value)
+ ? p_
+ : v_ };
+ };
+
+
+ template <typename R_, typename A_, typename E>
+ struct selector_
+ {
+ typedef mlc_unqualif(R_) R;
+ typedef mlc_unqualif(A_) A;
+ enum { arg = tag_<A>::value,
+ res = tag_<R>::value };
+ typedef typename helper_selector_<arg, res, E>::ret ret;
+ private:
+ selector_();
+ };
+
+
+ template <typename R_, typename E>
+ struct selector_p2_
+ {
+ typedef mlc_unqualif(R_) R;
+ enum { res = tag_<R>::value };
+ typedef typename helper_selector_<p_, res, E>::ret ret;
+ private:
+ selector_p2_();
+ };
+
+ } // end of namespace mln::fun::internal
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_INTERNAL_SELECTOR_HH
Index: jardonnet/perl/test/v2v/abs.hh
--- jardonnet/perl/test/v2v/abs.hh (revision 0)
+++ jardonnet/perl/test/v2v/abs.hh (revision 0)
@@ -0,0 +1,78 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_V2V_ABS_HH
+# define MLN_FUN_V2V_ABS_HH
+
+/*! \file mln/fun/v2v/abs.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/math/abs.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ // FIXME: Doc!
+
+ template <typename V>
+ struct abs : public Function_v2v< abs<V> >
+ {
+ typedef V result;
+ V operator()(const V& v) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V>
+ inline
+ V
+ abs<V>::operator()(const V& v) const
+ {
+ return mln::math::abs(v);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_V2V_ABS_HH
Index: jardonnet/perl/test/v2v/enc.hh
--- jardonnet/perl/test/v2v/enc.hh (revision 0)
+++ jardonnet/perl/test/v2v/enc.hh (revision 0)
@@ -0,0 +1,77 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_V2V_ENC_HH
+# define MLN_FUN_V2V_ENC_HH
+
+/*! \file mln/fun/v2v/enc.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ // FIXME: Doc!
+
+ template <typename V>
+ struct enc : public Function_v2v< enc<V> >
+ {
+ typedef typename V::enc result;
+ result operator()(const V& v) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V>
+ inline
+ typename V::enc
+ enc<V>::operator()(const V& v) const
+ {
+ return v.to_enc();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_V2V_ENC_HH
Index: jardonnet/perl/test/v2v/saturate.hh
--- jardonnet/perl/test/v2v/saturate.hh (revision 0)
+++ jardonnet/perl/test/v2v/saturate.hh (revision 0)
@@ -0,0 +1,129 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_V2V_SATURATE_HH
+# define MLN_FUN_V2V_SATURATE_HH
+
+/*! \file mln/fun/v2v/saturate.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/metal/converts_to.hh>
+# include <mln/trait/value_.hh>
+# include <mln/value/cast.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ // FIXME: Doc!
+
+ template <typename V>
+ struct saturate : public Function_v2v< saturate<V> >
+ {
+ saturate();
+ saturate(const V& min, const V& max);
+
+ typedef V result;
+
+ template <typename W>
+ V operator()(const W& w) const;
+
+ protected:
+ V min_, max_;
+ mutable bool needs_update_;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V>
+ inline
+ saturate<V>::saturate()
+ : min_(mln_min(V)),
+ max_(mln_max(V))
+ {
+ needs_update_ = true;
+ }
+
+ template <typename V>
+ inline
+ saturate<V>::saturate(const V& min, const V& max)
+ : min_(min),
+ max_(max)
+ {
+ mln_precondition(max > min);
+ needs_update_ = true;
+ }
+
+ template <typename V>
+ template <typename W>
+ inline
+ V
+ saturate<V>::operator()(const W& w) const
+ {
+ // FIXME: Check that W is a larger type than V; otherwise
+ // alt code.
+
+ static W min_W, max_W;
+ if (needs_update_)
+ {
+ min_W = mln::value::cast<W>(min_);
+ max_W = mln::value::cast<W>(max_);
+ needs_update_ = false;
+ }
+
+ // FIXME: Below we need something more powerful that mlc_converts_to
+ // for instance, with W=int_s<10u> and V=int_u<8u>, it does not
+ // works cause the cast is not obvious...
+ // mlc_converts_to(W, V)::check();
+
+ if (w < min_W)
+ return min_;
+ if (w > max_W)
+ return max_;
+ return mln::value::cast<W>(w);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_V2V_SATURATE_HH
Index: jardonnet/perl/test/v2v/all.hh
--- jardonnet/perl/test/v2v/all.hh (revision 0)
+++ jardonnet/perl/test/v2v/all.hh (revision 0)
@@ -0,0 +1,61 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_V2V_ALL_HH
+# define MLN_FUN_V2V_ALL_HH
+
+/*! \file mln/fun/v2v/all.hh
+ *
+ * \brief File that includes all functions from value to value.
+ */
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ /// Namespace of functions from value to value.
+ namespace v2v
+ {
+ }
+ }
+
+}
+
+
+# include <mln/fun/v2v/abs.hh>
+# include <mln/fun/v2v/cast.hh>
+# include <mln/fun/v2v/enc.hh>
+# include <mln/fun/v2v/id.hh>
+# include <mln/fun/v2v/linear.hh>
+# include <mln/fun/v2v/saturate.hh>
+
+
+
+#endif // ! MLN_FUN_V2V_ALL_HH
Index: jardonnet/perl/test/v2v/inc.hh
--- jardonnet/perl/test/v2v/inc.hh (revision 0)
+++ jardonnet/perl/test/v2v/inc.hh (revision 0)
@@ -0,0 +1,78 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_V2V_INC_HH
+# define MLN_FUN_V2V_INC_HH
+
+/*! \file mln/fun/v2v/inc.hh
+ *
+ * \brief Incrementation function.
+ */
+
+# include <mln/fun/internal/selector.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ // FIXME: Doc!
+
+ template <typename T>
+ struct inc
+ : fun::internal::selector_<T, T, inc<T> >::ret
+ {
+ typedef T result;
+ T operator()(const T& t) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ inline
+ T
+ inc<T>::operator()(const T& t) const
+ {
+ return t + 1;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_V2V_INC_HH
Index: jardonnet/perl/test/v2v/linear.hh
--- jardonnet/perl/test/v2v/linear.hh (revision 0)
+++ jardonnet/perl/test/v2v/linear.hh (revision 0)
@@ -0,0 +1,94 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_V2V_LINEAR_HH
+# define MLN_FUN_V2V_LINEAR_HH
+
+/*! \file mln/fun/v2v/linear.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ /*!
+ *\brief Linear function.
+ * f(v) = a * v + b.
+ * \c V is the type of input values; \c T is the type used to
+ * compute the result; \c R is the result type.
+ *
+ * By defaut, \c T is \c V and \c R is \c T.
+ */
+ template <typename V, typename T = V, typename R = T>
+ struct linear : public Function_v2v< linear<V,T,R> >
+ {
+ typedef R result;
+ R operator()(const V& v) const;
+
+ linear(T a, T b);
+ T a, b;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V, typename T, typename R>
+ inline
+ linear<V,T,R>::linear(T a, T b)
+ : a(a),
+ b(b)
+ {
+ }
+
+ template <typename V, typename T, typename R>
+ inline
+ R
+ linear<V,T,R>::operator()(const V& v) const
+ {
+ return R(a * T(v) + b);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_V2V_LINEAR_HH
Index: jardonnet/perl/test/v2v/cast.hh
--- jardonnet/perl/test/v2v/cast.hh (revision 0)
+++ jardonnet/perl/test/v2v/cast.hh (revision 0)
@@ -0,0 +1,81 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_V2V_CAST_HH
+# define MLN_FUN_V2V_CAST_HH
+
+/*! \file mln/fun/v2v/cast.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/value/cast.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ // FIXME: Doc!
+
+ template <typename V>
+ struct cast : public Function_v2v< cast<V> >
+ {
+ typedef V result;
+
+ template <typename W>
+ V operator()(const W& w) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V>
+ template <typename W>
+ inline
+ V
+ cast<V>::operator()(const W& w) const
+ {
+ return mln::value::cast<V>(w);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_V2V_CAST_HH
Index: jardonnet/perl/test/v2v/norm.hh
--- jardonnet/perl/test/v2v/norm.hh (revision 0)
+++ jardonnet/perl/test/v2v/norm.hh (revision 0)
@@ -0,0 +1,130 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_V2V_NORM_HH
+# define MLN_FUN_V2V_NORM_HH
+
+/*! \file mln/fun/v2v/norm.hh
+ *
+ * \brief Norm functors.
+ *
+ * \see mln/norm/.
+ */
+
+// FIXME: Move to mln/fun/x2v/?
+
+# include <mln/core/concept/function.hh>
+# include <mln/trait/value_.hh>
+
+# include <mln/norm/all.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ /*! \brief L1-norm.
+ *
+ * \c V is the type of input values; \c R is the result type.
+ *
+ * \see mln::norm::l1.
+ */
+ template <typename V, typename R>
+ struct l1_norm : public Function_v2v< l1_norm<V, R> >
+ {
+ typedef R result;
+ R operator()(const V& v) const;
+ };
+
+ /*! \brief L2-norm.
+ *
+ * \c V is the type of input values; \c R is the result type.
+ *
+ * \see mln::norm::l2.
+ */
+ template <typename V, typename R>
+ struct l2_norm : public Function_v2v< l2_norm<V, R> >
+ {
+ typedef R result;
+ R operator()(const V& v) const;
+ };
+
+ /*! \brief L-infty norm.
+ *
+ * \c V is the type of input values; \c R is the result type.
+ *
+ * \see mln::norm::linfty.
+ */
+ template <typename V, typename R>
+ struct linfty_norm : public Function_v2v< linfty_norm<V, R> >
+ {
+ typedef R result;
+ R operator()(const V& v) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V, typename R>
+ inline
+ R
+ l1_norm<V, R>::operator()(const V& v) const
+ {
+ return mln::norm::l1 (v);
+ }
+
+ template <typename V, typename R>
+ inline
+ R
+ l2_norm<V, R>::operator()(const V& v) const
+ {
+ return mln::norm::l2 (v);
+ }
+
+ template <typename V, typename R>
+ inline
+ R
+ linfty_norm<V, R>::operator()(const V& v) const
+ {
+ return mln::norm::linfty (v);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_V2V_NORM_HH
Index: jardonnet/perl/test/v2v/dec.hh
--- jardonnet/perl/test/v2v/dec.hh (revision 0)
+++ jardonnet/perl/test/v2v/dec.hh (revision 0)
@@ -0,0 +1,78 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_V2V_DEC_HH
+# define MLN_FUN_V2V_DEC_HH
+
+/*! \file mln/fun/v2v/dec.hh
+ *
+ * \brief Decrementation function.
+ */
+
+# include <mln/fun/internal/selector.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ // FIXME: Doc!
+
+ template <typename T>
+ struct dec
+ : fun::internal::selector_<T, T, dec<T> >::ret
+ {
+ typedef T result;
+ T operator()(const T& t) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ inline
+ T
+ dec<T>::operator()(const T& t) const
+ {
+ return t - 1;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_V2V_DEC_HH
Index: jardonnet/perl/test/v2v/id.hh
--- jardonnet/perl/test/v2v/id.hh (revision 0)
+++ jardonnet/perl/test/v2v/id.hh (revision 0)
@@ -0,0 +1,78 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_V2V_ID_HH
+# define MLN_FUN_V2V_ID_HH
+
+/*! \file mln/fun/v2v/id.hh
+ *
+ * \brief Identity function.
+ */
+
+# include <mln/fun/internal/selector.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ // FIXME: Doc!
+
+ template <typename T>
+ struct id
+ : fun::internal::selector_<T, T, id<T> >::ret
+ {
+ typedef T result;
+ T operator()(const T& t) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ inline
+ T
+ id<T>::operator()(const T& t) const
+ {
+ return t;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_V2V_ID_HH
Index: jardonnet/perl/test/v2v/rgb_to_hsi.hh
--- jardonnet/perl/test/v2v/rgb_to_hsi.hh (revision 0)
+++ jardonnet/perl/test/v2v/rgb_to_hsi.hh (revision 0)
@@ -0,0 +1,143 @@
+// 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.
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_V2V_RGB_TO_HSI_HH
+# define MLN_FUN_V2V_RGB_TO_HSI_HH
+
+#include <cmath>
+
+#include <mln/value/rgb8.hh>
+#include <mln/math/round.hh>
+
+#include <mln/value/hsi.hh>
+
+
+// FIXME: Split interface and implementation.
+
+namespace mln
+{
+
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ template <typename T_hsi>
+ struct f_rgb_to_hsi_ : public Function_v2v< f_rgb_to_hsi_<T_hsi> >
+ {
+ typedef T_hsi result;
+
+ template <typename T_rgb>
+ T_hsi operator()(const T_rgb& rgb) const
+ {
+ // Locals.
+ static const double sqrt3_3 = std::sqrt(3) / 3;
+ static const double inv_sqrt6 = 1 / std::sqrt(6);
+ static const double inv_sqrt2 = 1 / std::sqrt(2);
+
+ T_hsi hsi;
+
+ double alpha = inv_sqrt2 * rgb.green() - inv_sqrt2 * rgb.blue();
+ double beta =
+ 2 * inv_sqrt6 * rgb.red() -
+ inv_sqrt6 * rgb.green() -
+ inv_sqrt6 * rgb.blue();
+
+
+ hsi.hue() = atan2(beta, alpha) / 3.1415 * 180.0;
+ if (hsi.hue() < 0)
+ hsi.hue() = hsi.hue() + 360.0;
+ mln_invariant(hsi.hue() >= 0);
+ hsi.sat() = std::sqrt(alpha * alpha + beta * beta);
+ hsi.inty() =
+ sqrt3_3 * rgb.red() +
+ sqrt3_3 * rgb.green() +
+ sqrt3_3 * rgb.blue();
+
+ return hsi;
+ }
+ };
+
+ typedef f_rgb_to_hsi_<value::hsi_f> f_rgb_to_hsi_f_t;
+
+ // FIXME: Warning: global object.
+ f_rgb_to_hsi_f_t f_rgb_to_hsi_f;
+
+
+ template <typename T_rgb>
+ struct f_hsi_to_rgb_ : public Function_v2v< f_hsi_to_rgb_<T_rgb> >
+ {
+ typedef T_rgb result;
+
+ template <typename T_hsi>
+ T_rgb operator()(const T_hsi& hsi) const
+ {
+ typedef typename T_rgb::red_t red_t;
+ typedef typename T_rgb::green_t green_t;
+ typedef typename T_rgb::blue_t blue_t;
+
+ static math::round<red_t> to_r;
+ static math::round<green_t> to_g;
+ static math::round<blue_t> to_b;
+
+ static const float
+ sqrt3_3 = std::sqrt(3) / 3,
+ inv_sqrt6 = 1 / std::sqrt(6),
+ inv_sqrt2 = 1 / std::sqrt(2);
+
+ float
+ h = hsi.hue() / 180.0 * 3.1415,
+ alpha = hsi.sat() * std::cos(h),
+ beta = hsi.sat() * std::sin(h);
+
+
+ red_t r = to_r(sqrt3_3 * hsi.inty() + 2 * inv_sqrt6 * beta);
+ green_t g =
+ to_g(sqrt3_3 * hsi.inty() + inv_sqrt2 * alpha - inv_sqrt6 * beta);
+ blue_t b =
+ to_b(sqrt3_3 * hsi.inty() - inv_sqrt2 * alpha - inv_sqrt6 * beta);
+
+ T_rgb rgb(r, g, b);
+
+ return rgb;
+ }
+ };
+
+ typedef f_hsi_to_rgb_<value::rgb8> f_hsi_to_rgb_3x8_t;
+
+ // FIXME: Warning: global object.
+ f_hsi_to_rgb_3x8_t f_hsi_to_rgb_3x8;
+
+ } // end of namespace fun::v2v
+
+ } // end of namespace fun
+
+} // end of namespace mln
+
+#endif // ! MLN_FUN_V2V_RGB_TO_HSI_HH
Index: jardonnet/perl/hxx.pl
--- jardonnet/perl/hxx.pl (revision 0)
+++ jardonnet/perl/hxx.pl (revision 0)
@@ -0,0 +1,27 @@
+#!/usr/bin/env perl
+
+# while (<>) {
+# print if /\# ifndef MLN_INCLUDE_ONLY/ .. /\# endif \/\/ ! MLN_INCLUDE_ONLY/
+# }
+# perl -0777 -ne 'print "$1\n" while /ifndef MLN_INCLUDE_ONLY(.*?)# endif/gs'
+
+sub process($)
+{
+ $file = shift;
+
+ open(IN, '<', $file) or die "Failed to open `$file' for reading: $!";
+ $_ = join('', <IN>);
+ close(IN) or die "Failed to close `$file': $!";
+
+ print if /\# ifndef MLN_INCLUDE_ONLY/ .. /\# endif \/\/ ! MLN_INCLUDE_ONLY/;
+
+ #open(OUT, '>', $file) or die "Failed to open `$file' for writing: $!";
+ #print OUT;
+ #close(OUT) or die "Failed to close `$file': $!";
+}
+
+my @input_files = @ARGV; #parse_options();
+foreach my $file (@input_files)
+{
+ process $file;
+}
Property changes on: jardonnet/perl/hxx.pl
___________________________________________________________________
Name: svn:executable
+ *
Index: jardonnet/registration/quat7.hh
--- jardonnet/registration/quat7.hh (revision 2468)
+++ jardonnet/registration/quat7.hh (working copy)
@@ -179,9 +179,6 @@
algebra::quat qR(literal::zero);
qR = jacobi(Qk);
- //std::cout << qR << std::endl;
- //qR = power_it(Qk);
- //std::cout << qR << std::endl;
// qT
const algebra::vec<P::dim,float> qT = mu_Xk - rotate(qR, mu_C);
Index: jardonnet/registration/registration.hh
--- jardonnet/registration/registration.hh (revision 2468)
+++ jardonnet/registration/registration.hh (working copy)
@@ -61,13 +61,10 @@
namespace registration
{
-#ifndef NDEBUG
- static unsigned pts = 0;
-#endif
+
+ using namespace fun::x2x::geom;
/*! Registration FIXME : doxy
- *
- *
*/
template <typename I, typename J>
inline
@@ -75,11 +72,14 @@
registration(const Image<I>& cloud,
const Image<J>& surface);
+
# ifndef MLN_INCLUDE_ONLY
+
namespace impl
{
+
template <typename P, typename M, typename T>
inline
void
@@ -133,11 +133,12 @@
} // end of namespace mln::registration::impl
+
// FIXME: Separate icp.hh registration.hh multiscale_registration.hh
// FIXME: Make it works in 3d *AND* 2d
template <typename P, typename M>
inline
- quat7<P::dim> // what is it suposed to return tr(rot()), rot(tr()) or something else ...
+ composed< rotation<P::dim, float>, translation<P::dim, float> >
registration(p_array<P>& cloud,
const M& map,
const p_array<P>& x)
@@ -158,10 +159,13 @@
return qk;
}
+
# endif // ! MLN_INCLUDE_ONLY
+
} // end of namespace mln::registration
+
} // end of namespace mln
1
0
01 Oct '08
Roland Levillain wrote:
> Roland Levillain a écrit :
> ...
>
> La synchronisation est faite (cf. révisions 2316 à 2335) :
très très cool :-)
> ...
> Alexandre, est-ce que tu veux récupérer ce patch et le réintégrer dans
> cleanup-2008 ou bien est-ce que la version actuelle dans cleanup-2008
> est OK ?
j'ai pas vu passer de réponse...
> P.S. : Rappel : on n'enregistre plus dans trunk/ désormais ! :)
3
3
cleanup-2008 2467: Update documentation, add an operator to the sign value class.
by Nicolas Ballas 01 Oct '08
by Nicolas Ballas 01 Oct '08
01 Oct '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
Update documentation, add an operator to the sign value class.
* tests/value/sign.cc: Update.
* doc/technical/designs/properties/values.txt: Update.
* mln/value/sign.hh: Add an operator.
doc/technical/designs/properties/values.txt | 22 +++++++++++++---------
mln/value/sign.hh | 14 ++++++++++----
tests/value/sign.cc | 14 +++++++++++---
3 files changed, 34 insertions(+), 16 deletions(-)
Index: tests/value/sign.cc
--- tests/value/sign.cc (revision 2467)
+++ tests/value/sign.cc (working copy)
@@ -32,6 +32,7 @@
#include <cassert>
#include <mln/value/sign.hh>
+#include <mln/value/set.hh>
int main()
@@ -44,8 +45,15 @@
s = -1;
s = 0;
s = 1;
- assert(sign::zero == 0);
- assert(sign::one == 1);
- assert(s != 3);
+ assert(sign::zero == (sign) 0);
+ assert(sign::one == (sign) 1);
+ assert(s != (sign) -1);
+ }
+
+ {
+ value::set<sign> set;
+ mln_viter_(value::set<sign>) v(set);
+ for_all(v)
+ std::cout << v << std::endl;
}
}
Index: doc/technical/designs/properties/values.txt
--- doc/technical/designs/properties/values.txt (revision 2467)
+++ doc/technical/designs/properties/values.txt (working copy)
@@ -23,7 +23,7 @@
- direct: Images store all their values in memory, we can take a reference
of the values.
-- semi-direct: Images store partially their value in memory, we can't take
+- semi_direct: Images store partially their value in memory, we can't take
a reference on them. For instance, images that compute a value at the first
access and store it in a buffer to speed up the next access, are semi-direct.
@@ -96,7 +96,7 @@
=> image.buffer() -> return the start adress of the ima buffer
value_storage == piece_wise
- // runs iterator?
+ => image.pieces() -> return all the pieces composing the image.
** value_browsing:/any/
|
@@ -112,11 +112,12 @@
value_browsing == value_wise
=> ima.values_taken() -> return the current values taken by
ima
+ => ima.sites(v) -> return the sites associated to the
+ value v
+// FIXME these method depend on value_taken more than ima
=> ima.change_value(oldVal, newVal) -> change the value oldVal to newVal
=> ima.apply(f) -> apply f (a function v2v) to all the
values
- => ima.sites(v) -> return the sites associated to the
- value v
value_browsing == cell_wise
=> ima.values_cell() -> return the cells composing the image
@@ -132,7 +133,7 @@
+ -- read_write
=> Definition:
- Indicates the io permission for the site access.
+ Indicates the io permissions for the site access.
It replaces the property value_access.
- read_only: We can only read the image values.
@@ -161,10 +162,13 @@
*** value_storage == piece_wise
// MemCopy on the runs?
-for (ungsigned i = 0; i < ima.nruns(); ++i)
- //FIXME
-**** Method related:
- nruns ???
+mln_miter(I::miter) mit(image.pieces())
+for_all(miter)
+ for (unsigned i = 0; i < miter.size(); ++i)
+ *miter.buffer[i] = v;
+**** Method/Type related
+ -> I::miter
+ -> ima.pieces
*** value_browsing == value_wise
// direct access to the value
Index: mln/value/sign.hh
--- mln/value/sign.hh (revision 2467)
+++ mln/value/sign.hh (working copy)
@@ -32,7 +32,6 @@
*
* \brief Definition of the mln::value::sign class.
*/
-
# include <mln/value/internal/integer.hh>
# include <mln/trait/value_.hh>
# include <mln/literal/zero.hh>
@@ -85,7 +84,6 @@
sign& operator=(int i);
-
/// Zero value.
static const sign zero;
@@ -108,7 +106,8 @@
std::ostream& operator<<(std::ostream& ostr, const sign& i);
/// Comparaison operator
- bool operator==(sign lhs, sign rhs);
+ bool operator==(const sign& lhs, const sign& rhs);
+ bool operator<(const sign& lhs, const sign& rhs);
# ifndef MLN_INCLUDE_ONLY
@@ -187,7 +186,13 @@
}
inline
- bool operator==(sign lhs, sign rhs)
+ bool operator==(const sign& lhs, const sign& rhs)
+ {
+ return lhs.val_() == rhs.val_();
+ }
+
+ inline
+ bool operator<(const sign& lhs, const sign& rhs)
{
return lhs.val_() == rhs.val_();
}
@@ -220,6 +225,7 @@
typedef int sum;
};
+
} // end of namespace trait
1
0
URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
ChangeLog:
2008-10-01 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Add bench for median.
* doc/benchmark/median/median_bench.cc: New.
* doc/benchmark/median: New.
---
median_bench.cc | 175 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 175 insertions(+)
Index: branches/cleanup-2008/milena/doc/benchmark/median/median_bench.cc
===================================================================
--- branches/cleanup-2008/milena/doc/benchmark/median/median_bench.cc (revision 0)
+++ branches/cleanup-2008/milena/doc/benchmark/median/median_bench.cc (revision 2467)
@@ -0,0 +1,175 @@
+// 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.
+
+#include <stdio.h>
+#include <time.h>
+
+#include <mln/core/image/image2d.hh>
+#include <mln/win/all.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/debug/iota.hh>
+#include <mln/debug/println.hh>
+
+#include <mln/level/approx/median.hh>
+#include <mln/level/fast_median.hh>
+#include <mln/level/median.hh>
+
+#include <mln/core/dpoints_pixter.hh>
+#include <mln/core/pixel.hh>
+
+#include "tests/data.hh"
+
+using namespace mln;
+using value::int_u8;
+
+class timer
+{
+public:
+ void start()
+ {
+ start_ = clock();
+ }
+
+ void stop()
+ {
+ end_ = clock();
+ len = float(end_ - start_) / CLOCKS_PER_SEC;
+ }
+
+ float lenght()
+ {
+ return len;
+ }
+
+private:
+ clock_t start_;
+ clock_t end_;
+ float len;
+};
+
+
+std::ostream& operator<<(std::ostream& ostr, timer t)
+{
+ return ostr << t.lenght() << "s";
+}
+
+template <typename I, typename W, typename O>
+void tests(const Image<I>& input, const Window<W>& win,
+ Image<O>& output)
+{
+ timer chrono;
+
+ chrono.start();
+ level::fast_median(input, win, output);
+ chrono.stop();
+ std::cout << "Fast median : " << chrono << std::endl;
+
+ chrono.start();
+ level::median(input, win, output);
+ chrono.stop();
+ std::cout << "Median : " << chrono << std::endl;
+
+ chrono.start();
+ level::approx::median(input, exact(win), output);
+ chrono.stop();
+ std::cout << "Approx median : " << chrono << std::endl;
+
+}
+
+int main()
+{
+ {
+ std::cout << "-----------------------" << std::endl;
+ std::cout << "-----With rectangle 21x21" << std::endl;
+ std::cout << "-----------------------" << std::endl;
+
+ win::rectangle2d rect(21, 21);
+ border::thickness = 50;
+
+ image2d<int_u8> lena;
+ io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+ image2d<int_u8> out(lena.domain());
+
+ tests(lena, rect, out);
+ io::pgm::save(out, "out.pgm");
+
+ }
+
+ {
+ std::cout << "-----------------------" << std::endl;
+ std::cout << "-----With octogone 13" << std::endl;
+ std::cout << "-----------------------" << std::endl;
+
+ win::octagon2d oct(13);
+ border::thickness = 50;
+
+ image2d<int_u8> lena;
+ io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+ image2d<int_u8> out(lena.domain());
+
+ tests(lena, oct, out);
+ io::pgm::save(out, "out_oct.pgm");
+ }
+
+
+ {
+ std::cout << "-----------------------" << std::endl;
+ std::cout << "-----With disk2d 10" << std::endl;
+ std::cout << "-----------------------" << std::endl;
+
+ win::disk2d win(10);
+ border::thickness = 50;
+
+ image2d<int_u8> lena;
+ io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+ image2d<int_u8> out(lena.domain());
+
+ tests(lena, win, out);
+ io::pgm::save(out, "out_oct.pgm");
+ }
+
+// {
+// std::cout << "-----------------------" << std::endl;
+// std::cout << "-----With hline 10" << std::endl;
+// std::cout << "-----------------------" << std::endl;
+
+// win::hline2d win(10);
+// border::thickness = 50;
+
+// image2d<int_u8> lena;
+// io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+// image2d<int_u8> out(lena.domain());
+
+// tests(lena, win, out);
+// io::pgm::save(out, "out_oct.pgm");
+// }
+
+}
1
0