LRE
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
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
List overview
Download
Olena-patches
April 2006
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
olena-patches@lrde.epita.fr
3 participants
35 discussions
Start a n
N
ew thread
460: mlc/Makefile.am (nobase_mlc_HEADERS): Add missing files.
by Roland Levillain
https://svn.lrde.epita.fr/svn/oln/trunk/metalic
Index: ChangeLog from Roland Levillain <roland(a)lrde.epita.fr> * mlc/Makefile.am (nobase_mlc_HEADERS): Add missing files. Remove type.hh. Makefile.am | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) Index: mlc/Makefile.am --- mlc/Makefile.am (revision 459) +++ mlc/Makefile.am (working copy) @@ -2,23 +2,33 @@ mlcdir = $(includedir)/mlc nobase_mlc_HEADERS = \ + abort.hh \ any.hh \ + assert.hh \ + bexpr.hh \ bool.hh \ case.hh \ + char.hh \ cmp.hh \ comma.hh \ + contract.hh \ elt.hh \ flags.hh \ if.hh \ implies.hh \ + int.hh \ is_a.hh \ logic.hh \ pair.hh \ ret.hh \ + switch.hh \ to_string.hh \ - type.hh \ typedef.hh \ uint.hh \ valist.hh \ value.hh \ - wrap.hh + values.hh \ + wrap.hh \ + \ + abstract/bexpr.hh \ + abstract/type.hh
18 years, 8 months
1
0
0
0
459: xtd/Makefile.am (nobase_xtd_HEADERS): Add missing files.
by Roland Levillain
https://svn.lrde.epita.fr/svn/oln/trunk/extended
Index: ChangeLog from Roland Levillain <roland(a)lrde.epita.fr> * xtd/Makefile.am (nobase_xtd_HEADERS): Add missing files. Makefile.am | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) Index: xtd/Makefile.am --- xtd/Makefile.am (revision 458) +++ xtd/Makefile.am (working copy) @@ -3,4 +3,57 @@ xtddir = $(includedir)/xtd # FIXME: To be filled. -#nobase_xtd_HEADERS = +nobase_xtd_HEADERS = \ + arg.hh \ + args.hh \ + bind.hh \ + cast.hh \ + cfun.hh \ + literal.hh \ + math.hh \ + mexpr.hh \ + mfun.hh \ + optraits.hh \ + res.hh \ + traits.hh \ + \ + abstract/fun.hh \ + abstract/fun_expr.hh \ + abstract/fun_nary_expr.hh \ + abstract/meta_fun.hh \ + abstract/meta_nary_fun.hh \ + abstract/nary_fun.hh \ + abstract/open_fun.hh \ + abstract/open_nary_fun.hh \ + abstract/plain_fun.hh \ + abstract/plain_nary_fun.hh \ + \ + builtin/traits.hh \ + \ + internal/mlc.hh \ + internal/opmacros.hh \ + \ + math/abs.hh \ + math/acos.hh \ + math/arith.hh \ + math/asin.hh \ + math/atan.hh \ + math/atan2.hh \ + math/ceil.hh \ + math/cmp.hh \ + math/constraints.hh \ + math/cos.hh \ + math/cosh.hh \ + math/exp.hh \ + math/floor.hh \ + math/id.hh \ + math/includes.hh \ + math/log.hh \ + math/log10.hh \ + math/logic.hh \ + math/pow.hh \ + math/sin.hh \ + math/sinh.hh \ + math/sqrt.hh \ + math/tan.hh \ + math/tanh.hh
18 years, 8 months
1
0
0
0
458: Start the Olena subproject.
by Roland Levillain
https://svn.lrde.epita.fr/svn/oln/trunk
Index: ChangeLog from Roland Levillain <roland(a)lrde.epita.fr> Start the Olena subproject. * Makefile.am (SUBDIRS): Add olena. * olena/Makefile.am, olena/oln/Makefile.am, * olena/tests/Makefile.am: New files. * configure.ac: Configure them. * TODO: Update. Makefile.am | 2 +- TODO | 26 ++++++++------------------ configure.ac | 1 + olena/Makefile.am | 3 +++ 4 files changed, 13 insertions(+), 19 deletions(-) Index: TODO --- TODO (revision 457) +++ TODO (working copy) @@ -1,27 +1,17 @@ See also the TODO in oln-proto-1.0 and oln-proto-stl-style -* Metalic -** Modules -Split Metalic into several modules: +* Release process +This is to be done later, before the release of the whole project or +of one or some of its components. + +** Tests output +The tests should print nothing on the stantard output, nor on the +standard error. - mlc : core Metalic tools - stc : static inheritance - xtd : meta-functions and operator traits (for built-in types) - dyn : static-dynamic bridge (work of Damien Thivolle and Nicolas - Pouillard) - -** Static inheritance - -*** mlc/properties -- Roland - - -* Olena - - -* Integre Local Variables: mode: outline +ispell-local-dictionary: "american" End: Index: configure.ac --- configure.ac (revision 457) +++ configure.ac (working copy) @@ -62,6 +62,7 @@ extended/xtd/Makefile static/Makefile static/stc/Makefile + olena/Makefile ]) # Checks for library functions. Index: Makefile.am --- Makefile.am (revision 457) +++ Makefile.am (working copy) @@ -1,3 +1,3 @@ ## Process this file through Automake to produce Makefile.in -*- Makefile -*- -SUBDIRS = build-aux metalic extended static +SUBDIRS = build-aux metalic extended static olena Index: olena/Makefile.am --- olena/Makefile.am (revision 0) +++ olena/Makefile.am (revision 0) @@ -0,0 +1,3 @@ +## Process this file through Automake to create Makefile.in -*- Makefile -*- + +SUBDIRS =
18 years, 8 months
1
0
0
0
457: Fix some icpc remarks and update operator traits.
by Thierry Geraud
https://svn.lrde.epita.fr/svn/oln/trunk/extended
Index: ChangeLog from Thierry Geraud <theo(a)lrde.epita.fr> Fix some icpc remarks and update operator traits. * xtd/res.hh (macros): Add spaces to fix pb with icpc preproc. * xtd/args.hh (xtd_nargs): Likewise. * xtd/math/abs.hh (internal::int_): Handwrite code. * xtd/math/pow.hh: Cosmetics. * xtd/math/arith.hh: Add comments. * xtd/literal.hh (argument): Remove reference so that temporaries are copied. * xtd/abstract/fun_nary_expr.hh: Likewise. * xtd/bind.hh: Likewise. * xtd/abstract/any.hh: Remove cause obsolete. * xtd/abstract/fun.hh: Add doc. (abstract::fun_): Disable imperative operators. * xtd/abstract/plain_fun.hh: Add doc. * xtd/optraits.hh: Rewrite. * xtd/traits.hh: New. * xtd/builtin/traits.hh: Replace dummy code by effective one. * xtd/internal/opmacros.hh: Rewrite. * xtd/internal/mlc.hh: Add include. * tests: Add ignore rule for '.deps'. * tests/cfun.cc: Fix icpc remark. * tests/abs.cc: New. * tests/optraits.cc: New. * tests/Makefile.am: Update. * tests/bi_traits: New directory to test builtin op traits. * tests/bi_traits/bool.cc: New. * tests/bi_traits/char.cc: New. * tests/bi_traits/sint.cc: New. * tests/bi_traits/uint.cc: New. * tests/bi_traits/schar.cc: New. * tests/bi_traits/slong.cc: New. * tests/bi_traits/uchar.cc: New. * tests/bi_traits/sshort.cc: New. * tests/bi_traits/ulong.cc: New. * tests/bi_traits/ushort.cc: New. * tests/bi_traits/float.cc: New. * tests/bi_traits/ldouble.cc: New. * tests/bi_traits/double.cc: New. tests/Makefile.am | 10 + tests/abs.cc | 13 ++ tests/bi_traits/bool.cc | 48 ++++++++ tests/bi_traits/char.cc | 48 ++++++++ tests/bi_traits/double.cc | 48 ++++++++ tests/bi_traits/float.cc | 48 ++++++++ tests/bi_traits/ldouble.cc | 48 ++++++++ tests/bi_traits/schar.cc | 48 ++++++++ tests/bi_traits/sint.cc | 48 ++++++++ tests/bi_traits/slong.cc | 48 ++++++++ tests/bi_traits/sshort.cc | 48 ++++++++ tests/bi_traits/uchar.cc | 48 ++++++++ tests/bi_traits/uint.cc | 48 ++++++++ tests/bi_traits/ulong.cc | 48 ++++++++ tests/bi_traits/ushort.cc | 48 ++++++++ tests/cfun.cc | 4 tests/optraits.cc | 33 ++++++ xtd/abstract/fun.hh | 42 +++++++ xtd/abstract/fun_nary_expr.hh | 10 - xtd/abstract/plain_fun.hh | 32 +++++ xtd/bind.hh | 10 - xtd/builtin/traits.hh | 194 ++++++++++++++++++++++------------- xtd/internal/mlc.hh | 1 xtd/internal/opmacros.hh | 87 ++++++++++++--- xtd/literal.hh | 8 - xtd/math/abs.hh | 10 - xtd/math/arith.hh | 1 xtd/math/pow.hh | 1 xtd/optraits.hh | 229 +++++++++++++++++++++++++++--------------- xtd/traits.hh | 74 +++++++++++++ 30 files changed, 1186 insertions(+), 197 deletions(-) Index: xtd/res.hh Index: xtd/math/abs.hh --- xtd/math/abs.hh (revision 456) +++ xtd/math/abs.hh (working copy) @@ -56,12 +56,12 @@ namespace internal { - int abs_(int i) { return std::abs(i); } - long int abs_(long int i) { return std::abs(i); } + int abs_(int x) { return x < 0 ? -x : x; } + long int abs_(long int x) { return x < 0 ? -x : x; } - float abs_(float i) { return std::fabs(i); } - double abs_(double i) { return std::fabs(i); } - long double abs_(long double i) { return std::fabs(i); } + float abs_(float x) { return std::abs(x); } + double abs_(double x) { return std::abs(x); } + long double abs_(long double x) { return std::abs(x); } } // end of namespace xtd::internal Index: xtd/math/pow.hh --- xtd/math/pow.hh (revision 456) +++ xtd/math/pow.hh (working copy) @@ -102,6 +102,7 @@ const pow_type pow; + } // end of namespace xtd Index: xtd/math/arith.hh --- xtd/math/arith.hh (revision 456) +++ xtd/math/arith.hh (working copy) @@ -39,6 +39,7 @@ xtd_internal_decl_binary_operator( mult, * ); xtd_internal_decl_binary_operator( div, / ); xtd_internal_decl_binary_operator( mod, % ); +// xtd_internal_decl_binary_operator( pow, ^ ); // Cf. xtd/math/pow.hh xtd_internal_decl_unary_operator( uminus, - ); Index: xtd/args.hh Index: xtd/literal.hh --- xtd/literal.hh (revision 456) +++ xtd/literal.hh (working copy) @@ -68,7 +68,7 @@ { const T value; - plain_literal_(const T& value) + plain_literal_(T value) : value(value) {} @@ -106,7 +106,7 @@ { const T value; - meta_literal_(const T& value) + meta_literal_(T value) : value(value) {} @@ -150,7 +150,7 @@ { const T value; - literal_expr_(const T& value) : + literal_expr_(T value) : value(value) {} @@ -165,7 +165,7 @@ // FIXME: doc template <typename T> - literal_expr_<T> lit(const T& value) + literal_expr_<T> lit(T value) { literal_expr_<T> tmp(value); return tmp; Index: xtd/optraits.hh --- xtd/optraits.hh (revision 456) +++ xtd/optraits.hh (working copy) @@ -28,141 +28,210 @@ #ifndef EXTENDED_OPTRAITS_HH # define EXTENDED_OPTRAITS_HH -# include <mlc/flags.hh> +# include <xtd/traits.hh> +# include <xtd/builtin/traits.hh> -// logic +namespace xtd +{ -# define xtd_land(L, R) typename xtd::land_trait_<L, R>::ret -# define xtd_lor(L, R) typename xtd::lor_trait_<L, R>::ret -# define xtd_lxor(L, R) typename xtd::lxor_trait_<L, R>::ret -# define xtd_lnot(T) typename xtd::lnot_trait_<T>::ret + /// \{ + /// Tags to designate operators. + namespace abstract + { + struct oper + {}; -// cmp + struct op_tag + {}; -# define xtd_eq(L, R) typename xtd::eq_trait_<L, R>::ret -# define xtd_neq(L, R) typename xtd::neq_trait_<L, R>::ret -# define xtd_less(L, R) typename xtd::less_trait_<L, R>::ret -# define xtd_leq(L, R) typename xtd::leq_trait_<L, R>::ret -# define xtd_greater(L, R) typename xtd::greater_trait_<L, R>::ret -# define xtd_geq(L, R) typename xtd::geq_trait_<L, R>::ret + } // end of namespace xtd::abstract -// arith -# define xtd_plus(L, R) typename xtd::plus_trait_<L, R>::ret -# define xtd_minus(L, R) typename xtd::minus_trait_<L, R>::ret -# define xtd_mult(L, R) typename xtd::mult_trait_<L, R>::ret -# define xtd_div(L, R) typename xtd::div_trait_<L, R>::ret -# define xtd_mod(L, R) typename xtd::mod_trait_<L, R>::ret + template <typename opname> + struct op_ -# define xtd_uminus(T) typename xtd::uminus_trait_<T>::ret + : public abstract::oper, + private mlc::assert_< mlc_is_a(opname, abstract::op_tag), + xtd::ERROR::FIXME > + { + }; -// FIXME: xtd_plus(L, R) should be xtd::INTERNAL::plus_trait_< L, R >::ret -// FIXME: which checks that the trait *is* defined + // logic + struct land : public abstract::op_tag {}; + struct lor : public abstract::op_tag {}; + struct lxor : public abstract::op_tag {}; + struct lnot : public abstract::op_tag {}; + + typedef op_<land> op_land; + typedef op_<lor > op_lor; + typedef op_<lxor> op_lxor; + typedef op_<lnot> op_lnot; -namespace xtd -{ + // cmp - // logic + struct eq : public abstract::op_tag {}; + struct neq : public abstract::op_tag {}; + struct less : public abstract::op_tag {}; + struct leq : public abstract::op_tag {}; + struct greater : public abstract::op_tag {}; + struct geq : public abstract::op_tag {}; + + typedef op_<eq > op_eq; + typedef op_<neq > op_neq; + typedef op_<less > op_less; + typedef op_<leq > op_leq; + typedef op_<greater> op_greater; + typedef op_<geq > op_geq; - template <typename L, typename R> - struct land_trait_ : public mlc::undefined - { - }; + // arith - template <typename L, typename R> - struct lor_trait_ : public mlc::undefined - { - }; + struct plus : public abstract::op_tag {}; + struct minus : public abstract::op_tag {}; + struct mult : public abstract::op_tag {}; + struct div : public abstract::op_tag {}; + struct mod : public abstract::op_tag {}; + struct uminus : public abstract::op_tag {}; - template <typename L, typename R> - struct lxor_trait_ : public mlc::undefined - { - }; + typedef op_<plus > op_plus; + typedef op_<minus > op_minus; + typedef op_<mult > op_mult; + typedef op_<div > op_div; + typedef op_<mod > op_mod; + typedef op_<uminus> op_uminus; - template <typename T> - struct lnot_trait_ : public mlc::undefined - { - }; + /// \} - // cmp - template <typename L, typename R> - struct eq_trait_ : public mlc::undefined - { - }; - template <typename L, typename R> - struct neq_trait_ : public mlc::undefined - { - }; - template <typename L, typename R> - struct less_trait_ : public mlc::undefined + template < typename name, + typename data > + struct default_case_ < op_<name>, data > { + typedef mlc::undefined ret; }; - template <typename L, typename R> - struct leq_trait_ : public mlc::undefined - { - }; - template <typename L, typename R> - struct greater_trait_ : public mlc::undefined + template <typename name, + typename T> + struct case_ < op_<name>, T, + 1 > : public mlc::where_< mlc_is_builtin(T) >, + + private mlc::assert_< mlc_is_not_a(T, mlc::pair_), + xtd::ERROR::FIXME > { + typedef T ret; // FIXME: fake!!! }; - template <typename L, typename R> - struct geq_trait_ : public mlc::undefined + + template <typename name, + typename L, typename R> + struct case_ < op_<name>, mlc::pair_<L, R>, + 1 > : public mlc::where_< mlc::and_<mlc_is_builtin(L), mlc_is_builtin(R)> > { + struct protected_ { + typedef typename xtd::switch_< internal::UAC, mlc::pair_<L, R> >::ret ret; + }; }; - // arith - template <typename L, typename R> - struct plus_trait_ : public mlc::undefined + namespace internal { - }; - template <typename L, typename R> - struct minus_trait_ : public mlc::undefined - { - }; - template <typename L, typename R> - struct mult_trait_ : public mlc::undefined // FIXME: or "times"? - { - }; + template < typename name, + typename L, typename R > + struct get_trait_ < op_<name>, L, R > - template <typename L, typename R> - struct div_trait_ : public mlc::undefined - { - }; + : private mlc::assert_< mlc::implies_< mlc::is_defined_< xtd::set_trait_<op_<name>, L, R> >, + mlc::ret_found_in_< xtd::set_trait_<op_<name>, L, R> > >, + xtd::ERROR::FIXME >, - template <typename L, typename R> - struct mod_trait_ : public mlc::undefined + private mlc::assert_< mlc::implies_< mlc::is_undefined_< xtd::set_trait_<op_<name>, L, R> >, + mlc::neq_< typename get_case_< op_<name>, mlc::pair_<L, R> >::ret, + mlc::none > >, + xtd::ERROR::FIXME > { + typedef xtd::set_trait_< op_<name>, L, R > user_trait; + typedef mlc_ret(user_trait) user_ret; + + typedef typename get_case_< op_<name>, mlc::pair_<L, R> >::ret case_t; + typedef mlc_ret(case_t) case_ret; + + typedef typename mlc::if_< mlc_is_found(user_ret), user_ret, case_ret >::ret ret; }; - template <typename T> - struct uminus_trait_ : public mlc::undefined + + template < typename name, + typename T > + struct get_trait_ < op_<name>, T > + + : private mlc::assert_< mlc::implies_< mlc::is_defined_< xtd::set_trait_<op_<name>, T> >, + mlc::ret_found_in_< xtd::set_trait_<op_<name>, T> > >, + xtd::ERROR::FIXME > { + typedef xtd::set_trait_< op_<name>, T > user_trait; + typedef mlc_ret(user_trait) user_ret; + + typedef typename get_case_< op_<name>, T >::ret case_t; + typedef mlc_ret(case_t) case_ret; + + typedef typename mlc::if_< mlc_is_found(user_ret), user_ret, case_ret >::ret ret; }; + } // end of namespace xtd::internal + } // end of namespace xtd +// logic + +# define xtd_op_land_trait(L, R) typename xtd::internal::get_trait_<xtd::op_land, L, R>::ret +# define xtd_op_lor_trait(L, R) typename xtd::internal::get_trait_<xtd::op_lor, L, R>::ret +# define xtd_op_lxor_trait(L, R) typename xtd::internal::get_trait_<xtd::op_lxor, L, R>::ret + +# define xtd_op_lnot_trait(T) typename xtd::internal::get_trait_<xtd::op_lnot, T>::ret + + +// cmp + +# define xtd_op_eq_trait(L, R) typename xtd::internal::get_trait_<xtd::op_eq, L, R>::ret +# define xtd_op_neq_trait(L, R) typename xtd::internal::get_trait_<xtd::op_neq, L, R>::ret +# define xtd_op_less_trait(L, R) typename xtd::internal::get_trait_<xtd::op_less, L, R>::ret +# define xtd_op_leq_trait(L, R) typename xtd::internal::get_trait_<xtd::op_leq, L, R>::ret +# define xtd_op_greater_trait(L, R) typename xtd::internal::get_trait_<xtd::op_greater, L, R>::ret +# define xtd_op_geq_trait(L, R) typename xtd::internal::get_trait_<xtd::op_geq, L, R>::ret + + +// arith + +# define xtd_op_plus_trait(L, R) typename xtd::internal::get_trait_<xtd::op_plus, L, R>::ret +# define xtd_op_plus_trait_(L, R) xtd::internal::get_trait_<xtd::op_plus, L, R>::ret +# define xtd_op_minus_trait(L, R) typename xtd::internal::get_trait_<xtd::op_minus, L, R>::ret +# define xtd_op_minus_trait_(L, R) xtd::internal::get_trait_<xtd::op_minus, L, R>::ret +# define xtd_op_mult_trait(L, R) typename xtd::internal::get_trait_<xtd::op_mult, L, R>::ret +# define xtd_op_mult_trait_(L, R) xtd::internal::get_trait_<xtd::op_mult, L, R>::ret +# define xtd_op_div_trait(L, R) typename xtd::internal::get_trait_<xtd::op_div, L, R>::ret +# define xtd_op_div_trait_(L, R) xtd::internal::get_trait_<xtd::op_div, L, R>::ret +# define xtd_op_mod_trait(L, R) typename xtd::internal::get_trait_<xtd::op_mod, L, R>::ret +# define xtd_op_mod_trait_(L, R) xtd::internal::get_trait_<xtd::op_mod, L, R>::ret + +# define xtd_op_uminus_trait(T) typename xtd::internal::get_trait_<xtd::op_uminus, T>::ret + + + #endif // ! EXTENDED_OPTRAITS_HH Index: xtd/abstract/fun.hh --- xtd/abstract/fun.hh (revision 456) +++ xtd/abstract/fun.hh (working copy) @@ -37,10 +37,18 @@ namespace abstract { - /*! \class xtd::abstract::fun_ + /*! \class xtd::abstract::fun_<E> ** - ** Abstract base class for xtd functions. Parameter E is the - ** exact type of the function. + ** Abstract base class for xtd functions. These functions are + ** pure (non imperative); they can be plain, meta, or expr. + ** Parameter E is the exact type of the function. + ** + ** \note 1) This base class is useful to check if a type is the + ** one of an xtd function. 2) As an xtd function is pure, all + ** imperative operators are disabled. + ** + ** \see xtd::abstract::plain_fun_<E>, xtd::abstract::meta_fun_<E>, + ** xtd::abstract::fun_expr_<E> */ template <typename E> @@ -48,12 +56,40 @@ { public: + /// Static dispatch of this towards its exact type. const E& exact() const { return *(const E*)(const void*)(this); } + /// \{ + /// Imperative operators are disabled. + template <typename T> void operator %= (const T&) const; + template <typename T> void operator &= (const T&) const; + template <typename T> void operator *= (const T&) const; + template <typename T> void operator += (const T&) const; + template <typename T> void operator -= (const T&) const; + template <typename T> void operator /= (const T&) const; + template <typename T> void operator ^= (const T&) const; + template <typename T> void operator |= (const T&) const; + template <typename T> void operator = (const T&); + void operator ++ () const; + void operator -- () const; + void operator ++ (int) const; + void operator -- (int) const; + /// \} + + /// \{ + /// Operators "*(x)" and "(x)->" are disabled. + void operator * () const; + void operator -> () const; + /// \} + + /// Conversion operator is disabled. + template <typename T> operator T () const; + protected: + /// Ctor is protected so that this class seems abstract. fun_() {} }; Index: xtd/abstract/plain_fun.hh --- xtd/abstract/plain_fun.hh (revision 456) +++ xtd/abstract/plain_fun.hh (working copy) @@ -31,8 +31,9 @@ # include <xtd/abstract/fun.hh> -// macro - +/** \def xtd_res(F) + ** \brief Macro to get the result type of a plain function of type F. + */ # define xtd_res(F) typename xtd::typedef_::res_type::from_<xtd::fun_traits_<F> >::ret @@ -50,6 +51,12 @@ } // end of namespace xtd::ERROR + /*! \class xtd::fun_traits_<F> + ** + ** Traits class for a plain function of type F. This class should + ** be specialized to provide (thru typedefs) the result type and + ** the argument types. + */ template <typename F> struct fun_traits_ : public mlc::undefined @@ -63,10 +70,27 @@ namespace abstract { - /*! \class xtd::abstract::plain_fun_ + /*! \class xtd::abstract::plain_fun_<E> ** ** Abstract base class for plain functions. Parameter E is the ** exact type of the function. + ** + ** A plain function is a function object knowing the types of its + ** input (and consequently of its output). For instance, + ** xtd::cos_f is an instance of xtd::cos_<float>. This function + ** explicitly takes a float (and thus returns a float); so it is a + ** plain function. + ** + ** A plain function of type F should define the type of its + ** result. For that the traits class associated with this + ** function type, fun_traits_<F>, should be specialized and + ** contain a typedef res_type. The result type is then accessible + ** thru the macro xtd_res(F) where F is the type of the plain + ** function. + ** + ** An xtd plain function is an xtd function. + ** + ** \see xtd::fun_traits_<F>, xtd_res(F) */ template <typename E> @@ -80,6 +104,8 @@ public fun_<E> { + public: + protected: plain_fun_(){ // FIXME: unsigned is parameter so mlc_is_a does not work Index: xtd/abstract/fun_nary_expr.hh --- xtd/abstract/fun_nary_expr.hh (revision 456) +++ xtd/abstract/fun_nary_expr.hh (working copy) @@ -170,11 +170,11 @@ template <typename T> m2expr_< E, literal_expr_<T>, arg_<2> > - bind_1(const T& value) const; + bind_1(T value) const; template <typename T> m2expr_< E, arg_<1>, literal_expr_<T> > - bind_2(const T& value) const; + bind_2(T value) const; protected: fun_nary_expr_() {} @@ -207,15 +207,15 @@ template <typename T> m3expr_< E, literal_expr_<T>, arg_<2>, arg_<3> > - bind_1(const T& value) const; + bind_1(T value) const; template <typename T> m3expr_< E, arg_<1>, literal_expr_<T>, arg_<3> > - bind_2(const T& value) const; + bind_2(T value) const; template <typename T> m3expr_< E, arg_<1>, arg_<2>, literal_expr_<T> > - bind_3(const T& value) const; + bind_3(T value) const; protected: fun_nary_expr_() {} Index: xtd/traits.hh --- xtd/traits.hh (revision 0) +++ xtd/traits.hh (revision 0) @@ -0,0 +1,74 @@ +// Copyright (C) 2002, 2005, 2006 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 59 Temple Place - Suite 330, 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 EXTENDED_TRAITS_HH +# define EXTENDED_TRAITS_HH + +# include <xtd/internal/mlc.hh> + + +namespace xtd +{ + + namespace ERROR + { + struct FIXME; + + } // end of namespace xtd::ERROR + + + + template < typename subject, + typename T1, + typename T2 = mlc::none > + struct set_trait_ : public mlc::undefined + { + }; + + + + namespace internal + { + + template < typename subject, + typename T1, + typename T2 = mlc::none > + struct get_trait_ + + : private mlc::assert_< mlc::is_defined_< xtd::set_trait_<subject, T1, T2> >, + xtd::ERROR::FIXME > + { + }; + + } // end of namespace xtd::internal + + +} // end of namespace xtd + + + +#endif // ! EXTENDED_TRAITS_HH Index: xtd/builtin/traits.hh --- xtd/builtin/traits.hh (revision 456) +++ xtd/builtin/traits.hh (working copy) @@ -28,95 +28,149 @@ #ifndef EXTENDED_BUILTIN_TRAITS_HH # define EXTENDED_BUILTIN_TRAITS_HH -# include <xtd/optraits.hh> +# include <xtd/traits.hh> -// FIXME: this is dummy and incomplete code! +# define xtd_intprom(Type) typename xtd::internal::intprom_<Type>::ret -# define xtd_internal_DUMMY_builtin_arith_traits(OperatorName) \ - \ - template <typename T> \ - struct OperatorName##_trait_ < T, T > \ - { \ - typedef T ret; \ - }; \ - \ - template <> struct OperatorName##_trait_ < float, int > { typedef float ret; }; \ - template <> struct OperatorName##_trait_ < int, float > { typedef float ret; }; \ - template <> struct OperatorName##_trait_ < double, int > { typedef double ret; }; \ - template <> struct OperatorName##_trait_ < int, double > { typedef double ret; }; \ - template <> struct OperatorName##_trait_ < double, float > { typedef double ret; }; \ - template <> struct OperatorName##_trait_ < float, double > { typedef double ret; }; \ - \ - template <> struct OperatorName##_trait_ < long double, int > { typedef long double ret; }; \ - template <> struct OperatorName##_trait_ < int, long double > { typedef long double ret; }; \ - template <> struct OperatorName##_trait_ < long double, float > { typedef long double ret; }; \ - template <> struct OperatorName##_trait_ < float, long double > { typedef long double ret; }; \ - template <> struct OperatorName##_trait_ < long double, double > { typedef long double ret; }; \ - template <> struct OperatorName##_trait_ < double, long double > { typedef long double ret; }; \ - \ - struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n - - -# define xtd_internal_DUMMY_builtin_logic_traits(OperatorName) \ - \ - template <> \ - struct OperatorName##_trait_ < bool, bool > \ - { \ - typedef bool ret; \ - }; \ - \ - struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n - - -# define xtd_internal_DUMMY_builtin_cmp_traits(OperatorName) \ - \ - template <typename T> \ - struct OperatorName##_trait_ < T, T > \ - { \ - typedef bool ret; \ - }; \ - \ - struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n +namespace xtd +{ + + // built-in traits and usual arithmetic conversions + namespace internal + { + // see page 90 of ISO-IEC_14882.2003.pdf -namespace xtd + + struct UAC; // for "usual arithmetic conversions" + + // Integral promotion such as defined in FIXME: std. + + template <class T> + struct intprom_ { + typedef T ret; + }; - // logic + // FIXME: approx? - xtd_internal_DUMMY_builtin_logic_traits( land ); - xtd_internal_DUMMY_builtin_logic_traits( lor ); - xtd_internal_DUMMY_builtin_logic_traits( lxor ); + template <> struct intprom_ <char> { typedef int ret; }; + template <> struct intprom_ <signed char> { typedef int ret; }; + template <> struct intprom_ <unsigned char> { typedef int ret; }; + template <> struct intprom_ <unsigned short int> { typedef int ret; }; - template <> struct lnot_trait_< bool > { typedef bool ret; }; + template <> struct intprom_ <bool> { typedef int ret; }; // FIXME: right? - // cmp + } // end of namespace mlc::internal - xtd_internal_DUMMY_builtin_cmp_traits( eq ); - xtd_internal_DUMMY_builtin_cmp_traits( neq ); - xtd_internal_DUMMY_builtin_cmp_traits( less ); - xtd_internal_DUMMY_builtin_cmp_traits( leq ); - xtd_internal_DUMMY_builtin_cmp_traits( greater ); - xtd_internal_DUMMY_builtin_cmp_traits( geq ); + // 1) Prevent bool to be involved in arithmetics. + template <typename L, typename R> + struct case_ < internal::UAC, mlc::pair_<L, R>, + 1 > + : public mlc::where_< mlc::or_< mlc::eq_<L, bool>, + mlc::eq_<R, bool> > > + { + typedef mlc::undefined ret; + }; - // arith + // 2) If either operand is of type long double, the other shall be + // 2) converted to long double. + template <typename L, typename R> + struct case_ < internal::UAC, mlc::pair_<L, R>, + 2 > + : public mlc::where_< mlc::or_< mlc::eq_<L, long double>, + mlc::eq_<R, long double> > > + { + typedef long double ret; + }; - xtd_internal_DUMMY_builtin_arith_traits( plus ); - xtd_internal_DUMMY_builtin_arith_traits( minus ); - xtd_internal_DUMMY_builtin_arith_traits( mult ); - xtd_internal_DUMMY_builtin_arith_traits( div ); - xtd_internal_DUMMY_builtin_arith_traits( mod ); + // 3) Otherwise, if either operand is double, the other shall be + // 3) converted to double. + template <typename L, typename R> + struct case_ < internal::UAC, mlc::pair_<L, R>, + 3 > + : public mlc::where_< mlc::or_< mlc::eq_<L, double>, + mlc::eq_<R, double> > > + { + typedef double ret; + }; - template <> struct uminus_trait_< int > { typedef int ret; }; - template <> struct uminus_trait_< float > { typedef float ret; }; - template <> struct uminus_trait_< double > { typedef double ret; }; - template <> struct uminus_trait_< long double > { typedef long double ret; }; + // 4) Otherwise, if either operand is float, the other shall be + // 4) converted to float. + template <typename L, typename R> + struct case_ < internal::UAC, mlc::pair_<L, R>, + 4 > + : public mlc::where_< mlc::or_< mlc::eq_<L, float>, + mlc::eq_<R, float> > > + { + typedef float ret; + }; + + // 5) If either operand is unsigned long the other shall be + // 5) converted to unsigned long. + template <typename L, typename R> + struct case_ < internal::UAC, mlc::pair_<L, R>, + 5 > + : public mlc::where_< mlc::or_< mlc::eq_<L, unsigned long>, + mlc::eq_<R, unsigned long> > > + { + typedef unsigned long ret; + }; + + // 6) Otherwise, if one operand is a long int and the other unsigned + // 6) int, then if a long int can represent all the values of an + // 6) unsigned int, the unsigned int shall be converted to a long + // 6) int; otherwise both operands shall be converted to unsigned + // 6) long int. + template <typename L, typename R> + struct case_ < internal::UAC, mlc::pair_<L, R>, + 6 > + : public mlc::where_< mlc::or_< mlc::and_< mlc::eq_<xtd_intprom(L), long int>, + mlc::eq_<xtd_intprom(R), unsigned int> >, + mlc::and_< mlc::eq_<xtd_intprom(R), long int>, + mlc::eq_<xtd_intprom(L), unsigned int> > > > + { + typedef long int ret; // FIXME: approx... + }; + + // 7) Otherwise, if either operand is long, the other shall be + // 7) converted to long. + template <typename L, typename R> + struct case_ < internal::UAC, mlc::pair_<L, R>, + 7 > + : public mlc::where_< mlc::or_< mlc::eq_<xtd_intprom(L), long>, + mlc::eq_<xtd_intprom(R), long> > > + { + typedef long ret; + }; + + // 8) Otherwise, if either operand is unsigned, the other shall be + // 8) converted to unsigned. + template <typename L, typename R> + struct case_ < internal::UAC, mlc::pair_<L, R>, + 8 > + : public mlc::where_< mlc::or_< mlc::eq_<xtd_intprom(L), unsigned>, + mlc::eq_<xtd_intprom(R), unsigned> > > + { + typedef unsigned ret; + }; + + + // 0) Note: otherwise, the only remaining case is that both operands + // 0) are int. + template <typename L, typename R> + struct default_case_ < internal::UAC, mlc::pair_<L, R> > + { + // FIXME: test that: + // mlc::or_<mlc::eq_<xtd_intprom(L), int>, mlc::eq_<xtd_intprom(R), int> > + typedef int ret; + }; } // end of namespace xtd Index: xtd/bind.hh --- xtd/bind.hh (revision 456) +++ xtd/bind.hh (working copy) @@ -46,7 +46,7 @@ template <typename E> template <typename T> m2expr_< E, literal_expr_<T>, arg_<2> > - fun_nary_expr_< 2, E >::bind_1(const T& value) const + fun_nary_expr_< 2, E >::bind_1(T value) const { typedef m2expr_< E, literal_expr_<T>, arg_<2> > ret; ret tmp(this->exact(), lit(value), arg_<2>()); @@ -56,7 +56,7 @@ template <typename E> template <typename T> m2expr_< E, arg_<1>, literal_expr_<T> > - fun_nary_expr_< 2, E >::bind_2(const T& value) const + fun_nary_expr_< 2, E >::bind_2(T value) const { typedef m2expr_< E, arg_<1>, literal_expr_<T> > ret; ret tmp(this->exact(), arg_<1>(), lit(value)); @@ -69,7 +69,7 @@ template <typename E> template <typename T> m3expr_< E, literal_expr_<T>, arg_<2>, arg_<3> > - fun_nary_expr_< 3, E >::bind_1(const T& value) const + fun_nary_expr_< 3, E >::bind_1(T value) const { typedef m3expr_< E, literal_expr_<T>, arg_<2>, arg_<3> > ret; ret tmp(this->exact(), lit(value), arg_<2>(), arg_<3>()); @@ -79,7 +79,7 @@ template <typename E> template <typename T> m3expr_< E, arg_<1>, literal_expr_<T>, arg_<3> > - fun_nary_expr_< 3, E >::bind_2(const T& value) const + fun_nary_expr_< 3, E >::bind_2(T value) const { typedef m3expr_< E, arg_<1>, literal_expr_<T>, arg_<3> > ret; ret tmp(this->exact(), arg_<1>(), lit(value), arg_<3>()); @@ -89,7 +89,7 @@ template <typename E> template <typename T> m3expr_< E, arg_<1>, arg_<2>, literal_expr_<T> > - fun_nary_expr_< 3, E >::bind_3(const T& value) const + fun_nary_expr_< 3, E >::bind_3(T value) const { typedef m3expr_< E, arg_<1>, arg_<2>, literal_expr_<T> > ret; ret tmp(this->exact(), arg_<1>(), arg_<2>(), lit(value)); Index: xtd/internal/opmacros.hh --- xtd/internal/opmacros.hh (revision 456) +++ xtd/internal/opmacros.hh (working copy) @@ -28,6 +28,7 @@ #ifndef EXTENDED_INTERNAL_OPMACROS_HH # define EXTENDED_INTERNAL_OPMACROS_HH +# include <mlc/if.hh> # include <xtd/math/includes.hh> # include <xtd/abstract/fun_expr.hh> @@ -49,7 +50,7 @@ struct fun_traits_< plain_##OperatorName##_<T> > \ { \ typedef T arg_type; \ - typedef xtd_##OperatorName(T) res_type; \ + typedef xtd_op_##OperatorName##_trait(T) res_type; \ }; \ \ \ @@ -71,6 +72,16 @@ \ \ template <typename Expr> \ + struct case_ < op_##OperatorName, Expr, \ + 2 > : public mlc::where_< mlc_is_a(Expr, xtd::abstract::fun_expr_) > \ + { \ + struct protected_ { \ + typedef xtd::m1expr_<xtd::OperatorName##_type, Expr> ret; \ + }; \ + }; \ + \ + \ + template <typename Expr> \ xtd::m1expr_<xtd::OperatorName##_type, Expr> \ operator OperatorSymbol (const xtd::abstract::fun_expr_<Expr>& expr) \ { \ @@ -79,16 +90,41 @@ } \ \ \ - struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n \ + struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n -// FIXME: does not specialize any template arguments -// template <typename Expr> -// struct OperatorName##_trait_ < Expr > -// { -// typedef xtd::m1expr_<xtd::OperatorName##_type, Expr> ret; -// }; + + +# define xtd_internal_decl_binop_w_lit(OperatorName, OperatorSymbol, Builtin) \ + \ + \ + template <typename Rexpr> \ + xtd::m2expr_<xtd::OperatorName##_type, xtd::literal_expr_<Builtin>, Rexpr> \ + operator OperatorSymbol (Builtin value, \ + const xtd::abstract::fun_expr_<Rexpr>& rexpr) \ + { \ + typedef xtd::literal_expr_<Builtin> Lexpr; \ + Lexpr lexpr(value); \ + xtd::m2expr_<xtd::OperatorName##_type, Lexpr, Rexpr> tmp(lexpr, rexpr); \ + return tmp; \ + } \ + \ + \ + template <typename Lexpr> \ + xtd::m2expr_<xtd::OperatorName##_type, Lexpr, xtd::literal_expr_<Builtin> > \ + operator OperatorSymbol (const xtd::abstract::fun_expr_<Lexpr>& lexpr, \ + Builtin value) \ + { \ + typedef xtd::literal_expr_<Builtin> Rexpr; \ + Rexpr rexpr(value); \ + xtd::m2expr_<xtd::OperatorName##_type, Lexpr, Rexpr> tmp(lexpr, rexpr); \ + return tmp; \ + } \ + \ + \ + struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n + @@ -103,7 +139,7 @@ { \ typedef T1 arg1_type; \ typedef T2 arg2_type; \ - typedef xtd_##OperatorName(T1, T2) res_type; \ + typedef xtd_op_##OperatorName##_trait(T1, T2) res_type; \ }; \ \ \ @@ -124,6 +160,25 @@ const OperatorName##_type OperatorName; \ \ \ + template <typename L, typename R> \ + struct case_ < op_##OperatorName, mlc::pair_<L, R>, \ + 2 > : public mlc::where_< mlc::or_< mlc_is_a(L, xtd::abstract::fun_expr_), \ + mlc_is_a(R, xtd::abstract::fun_expr_) > > \ + { \ + struct protected_ { \ + typedef typename mlc::if_< mlc_is_a(L, xtd::abstract::fun_expr_), \ + L, \ + xtd::literal_expr_<L> >::ret Lexpr; \ + \ + typedef typename mlc::if_< mlc_is_a(R, xtd::abstract::fun_expr_), \ + R, \ + xtd::literal_expr_<R> >::ret Rexpr; \ + \ + typedef xtd::m2expr_<xtd::OperatorName##_type, Lexpr, Rexpr> ret; \ + }; \ + }; \ + \ + \ template <typename Lexpr, typename Rexpr> \ xtd::m2expr_<xtd::OperatorName##_type, Lexpr, Rexpr> \ operator OperatorSymbol (const xtd::abstract::fun_expr_<Lexpr>& lexpr, \ @@ -134,16 +189,14 @@ } \ \ \ - struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n \ - + xtd_internal_decl_binop_w_lit(OperatorName, OperatorSymbol, int); \ + xtd_internal_decl_binop_w_lit(OperatorName, OperatorSymbol, float); \ + xtd_internal_decl_binop_w_lit(OperatorName, OperatorSymbol, double); \ + \ + \ + struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n -// FIXME: does not specialize any template arguments -// template <typename Lexpr, typename Rexpr> -// struct OperatorName##_trait_ < Lexpr, Rexpr > -// { -// typedef xtd::m2expr_<xtd::OperatorName##_type, Lexpr, Rexpr> ret; -// }; #endif // ! EXTENDED_INTERNAL_OPMACROS_HH Index: xtd/internal/mlc.hh --- xtd/internal/mlc.hh (revision 456) +++ xtd/internal/mlc.hh (working copy) @@ -37,6 +37,7 @@ # include <mlc/assert.hh> # include <mlc/is_a.hh> # include <mlc/logic.hh> +# include <mlc/implies.hh> # include <mlc/cmp.hh> # include <mlc/if.hh> Index: tests/cfun.cc --- tests/cfun.cc (revision 456) +++ tests/cfun.cc (working copy) @@ -7,12 +7,12 @@ namespace my { - float foo() + static float foo() { return 5.1f; } - float bar(int i) + static float bar(int i) { return float(i) * 3.f; } Index: tests/bi_traits/bool.cc --- tests/bi_traits/bool.cc (revision 0) +++ tests/bi_traits/bool.cc (revision 0) @@ -0,0 +1,48 @@ +#include <iostream> +#include <typeinfo> + +#include <mlc/assert.hh> +#include <mlc/cmp.hh> + +#include <xtd/optraits.hh> + + +# define check_op_trait(OpName, OpSymb, T1, T2) \ +mlc::assert_< mlc::eq_< typeof(T1() OpSymb T2()), xtd_op_##OpName##_trait_(T1, T2) > >::check() + +# define check_trait(T1, T2) \ +check_op_trait(plus, +, T1, T2); \ +check_op_trait(minus, -, T1, T2); \ +check_op_trait(mult, *, T1, T2) + +// check_op_trait(mod, %, T1, T2); + + + +int main() +{ + typedef long double ldouble; + typedef unsigned char uchar; + typedef signed char schar; + typedef unsigned short ushort; + typedef signed short sshort; + typedef unsigned int uint; + typedef signed int sint; + typedef unsigned long ulong; + typedef signed long slong; + +// check_trait(bool, bool); +// check_trait(bool, char); +// check_trait(bool, float); +// check_trait(bool, double); +// check_trait(bool, ldouble); + check_trait(bool, uchar); + check_trait(bool, schar); + check_trait(bool, ushort); + check_trait(bool, sshort); +// check_trait(bool, uint); + check_trait(bool, sint); +// check_trait(bool, ulong); +// check_trait(bool, slong); + +} Index: tests/bi_traits/char.cc --- tests/bi_traits/char.cc (revision 0) +++ tests/bi_traits/char.cc (revision 0) @@ -0,0 +1,48 @@ +#include <iostream> +#include <typeinfo> + +#include <mlc/assert.hh> +#include <mlc/cmp.hh> + +#include <xtd/optraits.hh> + + +# define check_op_trait(OpName, OpSymb, T1, T2) \ +mlc::assert_< mlc::eq_< typeof(T1() OpSymb T2()), xtd_op_##OpName##_trait_(T1, T2) > >::check() + +# define check_trait(T1, T2) \ +check_op_trait(plus, +, T1, T2); \ +check_op_trait(minus, -, T1, T2); \ +check_op_trait(mult, *, T1, T2) + +// check_op_trait(mod, %, T1, T2); + + + +int main() +{ + typedef long double ldouble; + typedef unsigned char uchar; + typedef signed char schar; + typedef unsigned short ushort; + typedef signed short sshort; + typedef unsigned int uint; + typedef signed int sint; + typedef unsigned long ulong; + typedef signed long slong; + + check_trait(char, bool); + check_trait(char, char); + check_trait(char, float); + check_trait(char, double); + check_trait(char, ldouble); + check_trait(char, uchar); + check_trait(char, schar); + check_trait(char, ushort); + check_trait(char, sshort); + check_trait(char, uint); + check_trait(char, sint); + check_trait(char, ulong); + check_trait(char, slong); + +} Index: tests/bi_traits/sint.cc --- tests/bi_traits/sint.cc (revision 0) +++ tests/bi_traits/sint.cc (revision 0) @@ -0,0 +1,48 @@ +#include <iostream> +#include <typeinfo> + +#include <mlc/assert.hh> +#include <mlc/cmp.hh> + +#include <xtd/optraits.hh> + + +# define check_op_trait(OpName, OpSymb, T1, T2) \ +mlc::assert_< mlc::eq_< typeof(T1() OpSymb T2()), xtd_op_##OpName##_trait_(T1, T2) > >::check() + +# define check_trait(T1, T2) \ +check_op_trait(plus, +, T1, T2); \ +check_op_trait(minus, -, T1, T2); \ +check_op_trait(mult, *, T1, T2) + +// check_op_trait(mod, %, T1, T2); + + + +int main() +{ + typedef long double ldouble; + typedef unsigned char uchar; + typedef signed char schar; + typedef unsigned short ushort; + typedef signed short sshort; + typedef unsigned int uint; + typedef signed int sint; + typedef unsigned long ulong; + typedef signed long slong; + + check_trait(sint, bool); + check_trait(sint, char); + check_trait(sint, float); + check_trait(sint, double); + check_trait(sint, ldouble); + check_trait(sint, uchar); + check_trait(sint, schar); + check_trait(sint, ushort); + check_trait(sint, sshort); + check_trait(sint, uint); + check_trait(sint, sint); + check_trait(sint, ulong); + check_trait(sint, slong); + +} Index: tests/bi_traits/uint.cc --- tests/bi_traits/uint.cc (revision 0) +++ tests/bi_traits/uint.cc (revision 0) @@ -0,0 +1,48 @@ +#include <iostream> +#include <typeinfo> + +#include <mlc/assert.hh> +#include <mlc/cmp.hh> + +#include <xtd/optraits.hh> + + +# define check_op_trait(OpName, OpSymb, T1, T2) \ +mlc::assert_< mlc::eq_< typeof(T1() OpSymb T2()), xtd_op_##OpName##_trait_(T1, T2) > >::check() + +# define check_trait(T1, T2) \ +check_op_trait(plus, +, T1, T2); \ +check_op_trait(minus, -, T1, T2); \ +check_op_trait(mult, *, T1, T2) + +// check_op_trait(mod, %, T1, T2); + + + +int main() +{ + typedef long double ldouble; + typedef unsigned char uchar; + typedef signed char schar; + typedef unsigned short ushort; + typedef signed short sshort; + typedef unsigned int uint; + typedef signed int sint; + typedef unsigned long ulong; + typedef signed long slong; + + check_trait(uint, bool); + check_trait(uint, char); + check_trait(uint, float); + check_trait(uint, double); + check_trait(uint, ldouble); + check_trait(uint, uchar); + check_trait(uint, schar); + check_trait(uint, ushort); + check_trait(uint, sshort); + check_trait(uint, uint); + check_trait(uint, sint); + check_trait(uint, ulong); + check_trait(uint, slong); + +} Index: tests/bi_traits/schar.cc --- tests/bi_traits/schar.cc (revision 0) +++ tests/bi_traits/schar.cc (revision 0) @@ -0,0 +1,48 @@ +#include <iostream> +#include <typeinfo> + +#include <mlc/assert.hh> +#include <mlc/cmp.hh> + +#include <xtd/optraits.hh> + + +# define check_op_trait(OpName, OpSymb, T1, T2) \ +mlc::assert_< mlc::eq_< typeof(T1() OpSymb T2()), xtd_op_##OpName##_trait_(T1, T2) > >::check() + +# define check_trait(T1, T2) \ +check_op_trait(plus, +, T1, T2); \ +check_op_trait(minus, -, T1, T2); \ +check_op_trait(mult, *, T1, T2) + +// check_op_trait(mod, %, T1, T2); + + + +int main() +{ + typedef long double ldouble; + typedef unsigned char uchar; + typedef signed char schar; + typedef unsigned short ushort; + typedef signed short sshort; + typedef unsigned int uint; + typedef signed int sint; + typedef unsigned long ulong; + typedef signed long slong; + + check_trait(schar, bool); + check_trait(schar, char); + check_trait(schar, float); + check_trait(schar, double); + check_trait(schar, ldouble); + check_trait(schar, uchar); + check_trait(schar, schar); + check_trait(schar, ushort); + check_trait(schar, sshort); + check_trait(schar, uint); + check_trait(schar, sint); + check_trait(schar, ulong); + check_trait(schar, slong); + +} Index: tests/bi_traits/slong.cc --- tests/bi_traits/slong.cc (revision 0) +++ tests/bi_traits/slong.cc (revision 0) @@ -0,0 +1,48 @@ +#include <iostream> +#include <typeinfo> + +#include <mlc/assert.hh> +#include <mlc/cmp.hh> + +#include <xtd/optraits.hh> + + +# define check_op_trait(OpName, OpSymb, T1, T2) \ +mlc::assert_< mlc::eq_< typeof(T1() OpSymb T2()), xtd_op_##OpName##_trait_(T1, T2) > >::check() + +# define check_trait(T1, T2) \ +check_op_trait(plus, +, T1, T2); \ +check_op_trait(minus, -, T1, T2); \ +check_op_trait(mult, *, T1, T2) + +// check_op_trait(mod, %, T1, T2); + + + +int main() +{ + typedef long double ldouble; + typedef unsigned char uchar; + typedef signed char schar; + typedef unsigned short ushort; + typedef signed short sshort; + typedef unsigned int uint; + typedef signed int sint; + typedef unsigned long ulong; + typedef signed long slong; + + check_trait(slong, bool); + check_trait(slong, char); + check_trait(slong, float); + check_trait(slong, double); + check_trait(slong, ldouble); + check_trait(slong, uchar); + check_trait(slong, schar); + check_trait(slong, ushort); + check_trait(slong, sshort); + check_trait(slong, uint); + check_trait(slong, sint); + check_trait(slong, ulong); + check_trait(slong, slong); + +} Index: tests/bi_traits/uchar.cc --- tests/bi_traits/uchar.cc (revision 0) +++ tests/bi_traits/uchar.cc (revision 0) @@ -0,0 +1,48 @@ +#include <iostream> +#include <typeinfo> + +#include <mlc/assert.hh> +#include <mlc/cmp.hh> + +#include <xtd/optraits.hh> + + +# define check_op_trait(OpName, OpSymb, T1, T2) \ +mlc::assert_< mlc::eq_< typeof(T1() OpSymb T2()), xtd_op_##OpName##_trait_(T1, T2) > >::check() + +# define check_trait(T1, T2) \ +check_op_trait(plus, +, T1, T2); \ +check_op_trait(minus, -, T1, T2); \ +check_op_trait(mult, *, T1, T2) + +// check_op_trait(mod, %, T1, T2); + + + +int main() +{ + typedef long double ldouble; + typedef unsigned char uchar; + typedef signed char schar; + typedef unsigned short ushort; + typedef signed short sshort; + typedef unsigned int uint; + typedef signed int sint; + typedef unsigned long ulong; + typedef signed long slong; + + check_trait(uchar, bool); + check_trait(uchar, char); + check_trait(uchar, float); + check_trait(uchar, double); + check_trait(uchar, ldouble); + check_trait(uchar, uchar); + check_trait(uchar, schar); + check_trait(uchar, ushort); + check_trait(uchar, sshort); + check_trait(uchar, uint); + check_trait(uchar, sint); + check_trait(uchar, ulong); + check_trait(uchar, slong); + +} Index: tests/bi_traits/sshort.cc --- tests/bi_traits/sshort.cc (revision 0) +++ tests/bi_traits/sshort.cc (revision 0) @@ -0,0 +1,48 @@ +#include <iostream> +#include <typeinfo> + +#include <mlc/assert.hh> +#include <mlc/cmp.hh> + +#include <xtd/optraits.hh> + + +# define check_op_trait(OpName, OpSymb, T1, T2) \ +mlc::assert_< mlc::eq_< typeof(T1() OpSymb T2()), xtd_op_##OpName##_trait_(T1, T2) > >::check() + +# define check_trait(T1, T2) \ +check_op_trait(plus, +, T1, T2); \ +check_op_trait(minus, -, T1, T2); \ +check_op_trait(mult, *, T1, T2) + +// check_op_trait(mod, %, T1, T2); + + + +int main() +{ + typedef long double ldouble; + typedef unsigned char uchar; + typedef signed char schar; + typedef unsigned short ushort; + typedef signed short sshort; + typedef unsigned int uint; + typedef signed int sint; + typedef unsigned long ulong; + typedef signed long slong; + + check_trait(sshort, bool); + check_trait(sshort, char); + check_trait(sshort, float); + check_trait(sshort, double); + check_trait(sshort, ldouble); + check_trait(sshort, uchar); + check_trait(sshort, schar); + check_trait(sshort, ushort); + check_trait(sshort, sshort); + check_trait(sshort, uint); + check_trait(sshort, sint); + check_trait(sshort, ulong); + check_trait(sshort, slong); + +} Index: tests/bi_traits/ulong.cc --- tests/bi_traits/ulong.cc (revision 0) +++ tests/bi_traits/ulong.cc (revision 0) @@ -0,0 +1,48 @@ +#include <iostream> +#include <typeinfo> + +#include <mlc/assert.hh> +#include <mlc/cmp.hh> + +#include <xtd/optraits.hh> + + +# define check_op_trait(OpName, OpSymb, T1, T2) \ +mlc::assert_< mlc::eq_< typeof(T1() OpSymb T2()), xtd_op_##OpName##_trait_(T1, T2) > >::check() + +# define check_trait(T1, T2) \ +check_op_trait(plus, +, T1, T2); \ +check_op_trait(minus, -, T1, T2); \ +check_op_trait(mult, *, T1, T2) + +// check_op_trait(mod, %, T1, T2); + + + +int main() +{ + typedef long double ldouble; + typedef unsigned char uchar; + typedef signed char schar; + typedef unsigned short ushort; + typedef signed short sshort; + typedef unsigned int uint; + typedef signed int sint; + typedef unsigned long ulong; + typedef signed long slong; + + check_trait(ulong, bool); + check_trait(ulong, char); + check_trait(ulong, float); + check_trait(ulong, double); + check_trait(ulong, ldouble); + check_trait(ulong, uchar); + check_trait(ulong, schar); + check_trait(ulong, ushort); + check_trait(ulong, sshort); + check_trait(ulong, uint); + check_trait(ulong, sint); + check_trait(ulong, ulong); + check_trait(ulong, slong); + +} Index: tests/bi_traits/ushort.cc --- tests/bi_traits/ushort.cc (revision 0) +++ tests/bi_traits/ushort.cc (revision 0) @@ -0,0 +1,48 @@ +#include <iostream> +#include <typeinfo> + +#include <mlc/assert.hh> +#include <mlc/cmp.hh> + +#include <xtd/optraits.hh> + + +# define check_op_trait(OpName, OpSymb, T1, T2) \ +mlc::assert_< mlc::eq_< typeof(T1() OpSymb T2()), xtd_op_##OpName##_trait_(T1, T2) > >::check() + +# define check_trait(T1, T2) \ +check_op_trait(plus, +, T1, T2); \ +check_op_trait(minus, -, T1, T2); \ +check_op_trait(mult, *, T1, T2) + +// check_op_trait(mod, %, T1, T2); + + + +int main() +{ + typedef long double ldouble; + typedef unsigned char uchar; + typedef signed char schar; + typedef unsigned short ushort; + typedef signed short sshort; + typedef unsigned int uint; + typedef signed int sint; + typedef unsigned long ulong; + typedef signed long slong; + + check_trait(ushort, bool); + check_trait(ushort, char); + check_trait(ushort, float); + check_trait(ushort, double); + check_trait(ushort, ldouble); + check_trait(ushort, uchar); + check_trait(ushort, schar); + check_trait(ushort, ushort); + check_trait(ushort, sshort); + check_trait(ushort, uint); + check_trait(ushort, sint); + check_trait(ushort, ulong); + check_trait(ushort, slong); + +} Index: tests/bi_traits/float.cc --- tests/bi_traits/float.cc (revision 0) +++ tests/bi_traits/float.cc (revision 0) @@ -0,0 +1,48 @@ +#include <iostream> +#include <typeinfo> + +#include <mlc/assert.hh> +#include <mlc/cmp.hh> + +#include <xtd/optraits.hh> + + +# define check_op_trait(OpName, OpSymb, T1, T2) \ +mlc::assert_< mlc::eq_< typeof(T1() OpSymb T2()), xtd_op_##OpName##_trait_(T1, T2) > >::check() + +# define check_trait(T1, T2) \ +check_op_trait(plus, +, T1, T2); \ +check_op_trait(minus, -, T1, T2); \ +check_op_trait(mult, *, T1, T2) + +// check_op_trait(mod, %, T1, T2); + + + +int main() +{ + typedef long double ldouble; + typedef unsigned char uchar; + typedef signed char schar; + typedef unsigned short ushort; + typedef signed short sshort; + typedef unsigned int uint; + typedef signed int sint; + typedef unsigned long ulong; + typedef signed long slong; + +// check_trait(float, bool); + check_trait(float, char); + check_trait(float, float); + check_trait(float, double); + check_trait(float, ldouble); + check_trait(float, uchar); + check_trait(float, schar); + check_trait(float, ushort); + check_trait(float, sshort); + check_trait(float, uint); + check_trait(float, sint); + check_trait(float, ulong); + check_trait(float, slong); + +} Index: tests/bi_traits/ldouble.cc --- tests/bi_traits/ldouble.cc (revision 0) +++ tests/bi_traits/ldouble.cc (revision 0) @@ -0,0 +1,48 @@ +#include <iostream> +#include <typeinfo> + +#include <mlc/assert.hh> +#include <mlc/cmp.hh> + +#include <xtd/optraits.hh> + + +# define check_op_trait(OpName, OpSymb, T1, T2) \ +mlc::assert_< mlc::eq_< typeof(T1() OpSymb T2()), xtd_op_##OpName##_trait_(T1, T2) > >::check() + +# define check_trait(T1, T2) \ +check_op_trait(plus, +, T1, T2); \ +check_op_trait(minus, -, T1, T2); \ +check_op_trait(mult, *, T1, T2) + +// check_op_trait(mod, %, T1, T2); + + + +int main() +{ + typedef long double ldouble; + typedef unsigned char uchar; + typedef signed char schar; + typedef unsigned short ushort; + typedef signed short sshort; + typedef unsigned int uint; + typedef signed int sint; + typedef unsigned long ulong; + typedef signed long slong; + +// check_trait(ldouble, bool); + check_trait(ldouble, char); + check_trait(ldouble, float); + check_trait(ldouble, double); + check_trait(ldouble, ldouble); + check_trait(ldouble, uchar); + check_trait(ldouble, schar); + check_trait(ldouble, ushort); + check_trait(ldouble, sshort); + check_trait(ldouble, uint); + check_trait(ldouble, sint); + check_trait(ldouble, ulong); + check_trait(ldouble, slong); + +} Index: tests/bi_traits/double.cc --- tests/bi_traits/double.cc (revision 0) +++ tests/bi_traits/double.cc (revision 0) @@ -0,0 +1,48 @@ +#include <iostream> +#include <typeinfo> + +#include <mlc/assert.hh> +#include <mlc/cmp.hh> + +#include <xtd/optraits.hh> + + +# define check_op_trait(OpName, OpSymb, T1, T2) \ +mlc::assert_< mlc::eq_< typeof(T1() OpSymb T2()), xtd_op_##OpName##_trait_(T1, T2) > >::check() + +# define check_trait(T1, T2) \ +check_op_trait(plus, +, T1, T2); \ +check_op_trait(minus, -, T1, T2); \ +check_op_trait(mult, *, T1, T2) + +// check_op_trait(mod, %, T1, T2); + + + +int main() +{ + typedef long double ldouble; + typedef unsigned char uchar; + typedef signed char schar; + typedef unsigned short ushort; + typedef signed short sshort; + typedef unsigned int uint; + typedef signed int sint; + typedef unsigned long ulong; + typedef signed long slong; + +// check_trait(double, bool); + check_trait(double, char); + check_trait(double, float); + check_trait(double, double); + check_trait(double, ldouble); + check_trait(double, uchar); + check_trait(double, schar); + check_trait(double, ushort); + check_trait(double, sshort); + check_trait(double, uint); + check_trait(double, sint); + check_trait(double, ulong); + check_trait(double, slong); + +} Index: tests/Makefile.am --- tests/Makefile.am (revision 456) +++ tests/Makefile.am (working copy) @@ -8,20 +8,24 @@ # when oln.m4 is available in the distribution. check_PROGRAMS = \ - id \ + abs \ bind \ cast \ cfun \ cos \ + id \ lit \ - math + math \ + optraits -id_SOURCES = id.cc +abs_SOURCES = abs.cc bind_SOURCES = bind.cc cast_SOURCES = cast.cc cfun_SOURCES = cfun.cc cos_SOURCES = cos.cc +id_SOURCES = id.cc lit_SOURCES = lit.cc math_SOURCES = math.cc +optraits_SOURCES = optraits.cc TESTS = $(check_PROGRAMS) Index: tests/abs.cc --- tests/abs.cc (revision 0) +++ tests/abs.cc (revision 0) @@ -0,0 +1,13 @@ +#include <iostream> +#include <xtd/math/abs.hh> + +int main() +{ + long l = -3; + long ll = xtd::abs(l); + std::cout << ll << std::endl; + + long i = -3; + long ii = xtd::abs(i); + std::cout << ii << std::endl; +} Index: tests/optraits.cc --- tests/optraits.cc (revision 0) +++ tests/optraits.cc (revision 0) @@ -0,0 +1,33 @@ +#include <iostream> +#include <xtd/optraits.hh> +#include <xtd/math.hh> + + +template <typename T> +static void foo() +{ + xtd_op_plus_trait(int, char) tmp; +} + + +template <typename E1, typename E2> +static +void test_plus(const xtd::abstract::fun_expr_<E1>& expr1, + const xtd::abstract::fun_expr_<E2>& expr2) +{ + const xtd_op_plus_trait(E1, E2)& tmp = expr1 + expr2; + std::cout << tmp(1.) << std::endl; +} + + +int main() +{ + using xtd::cos; + using xtd::sin; + using xtd::_1; + + typeof(1+2u) tmp; +// 2 * cos(_1); + + test_plus(2 * cos(_1), sin(_1)); +}
18 years, 8 months
1
0
0
0
proto-1.0 456: Add sample for real time segmentation.
by Nicolas Widynski
https://svn/svn/oln/prototypes/proto-1.0/olena
Index: ChangeLog from Nicolas Widynski <nicolas.widynski(a)lrde.epita.fr> Add sample for real time segmentation. * oln/appli/snakes/snakes.cc: New. Real time segmentation using snakes and watersnakes. snakes.cc | 227 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 227 insertions(+) Index: oln/appli/snakes/snakes.cc --- oln/appli/snakes/snakes.cc (revision 0) +++ oln/appli/snakes/snakes.cc (revision 0) @@ -0,0 +1,227 @@ +#include <oln/basics2d.hh> +#include <ntg/all.hh> +#include <oln/morpho/watersnakes.hh> +#include <oln/level/fill.hh> +#include <oln/appli/snakes/snakes.hh> + +#define my_abs(u) ((u) > 0 ? (u) : (-(u))) + +using ntg::int_u8; + +template <typename T> +void aff_points(const oln::image2d<T>& input, + const std::vector<oln::point2d>& v, + oln::image2d<T>& out) +{ + oln_iter_type(oln::image2d<T>) p(input); + oln::image2d<bool> mask(input.size()); + + for_all(p) + mask[p] = false; + + std::vector<oln::point2d>::const_iterator it = v.begin(); + for (; it != v.end(); it++) + mask[*it] = true; + + for_all(p) + { + if (mask[p] == true) + out[p] = 255; + else + out[p] = input[p]; + } +} + +template <typename T> +void aff_droites(const oln::image2d<T>& input, + const std::vector<oln::point2d>& v, + oln::image2d<T>& out) +{ + oln_iter_type(oln::image2d<T>) p(input); + oln::image2d<bool> mask(input.size()); + + for_all(p) + mask[p] = false; + + std::vector<oln::point2d>::const_iterator it = v.begin(); + for (; it + 1!= v.end(); it++) + { + std::vector<oln::point2d> vec = oln::snakes::impl::draw_line_(*it, *(it+1)); + std::vector<oln::point2d>::const_iterator it2 = vec.begin(); + + for (; it2 != vec.end(); it2++) + mask[*it2] = true; + } + + for_all(p) + { + if (mask[p] == true) + out[p] = 255; + else + out[p] = input[p]; + } +} + + + +bool nearly_equal(int x1, int x2, int y1, int y2) +{ + return (my_abs(x1 - x2) < 5 and my_abs(y1 - y2) < 5); +} + +template <typename T> +std::vector<oln::point2d> tri_vec(const oln::image2d<T>& ima, + const std::vector<oln::point2d>& v) +{ + std::vector<oln::point2d> res; + std::vector<oln::point2d>::const_iterator it; + std::vector<oln::point2d>::iterator it2; + + int ex_1_x = -100; + int ex_1_y = -100; + int ex_2_x = 0; + int ex_2_y = 0; + int save_x = -1; + int save_y = -1; + + + for (int i = 0; i < 2; i++) + { + double min = 100000000; + + for (it = v.begin(); it != v.end(); it++) + { + if (i and nearly_equal((*it).row(), ex_1_x, (*it).col(), ex_1_y)) + continue; + + double tmp1 = oln::snakes::impl::euclidian_distance((*it).row(), 0, 0, 0); + double tmp2 = oln::snakes::impl::euclidian_distance((*it).row(), ima.nrows(), 0, 0); + double tmp3 = oln::snakes::impl::euclidian_distance(0, 0, (*it).col(), 0); + double tmp4 = oln::snakes::impl::euclidian_distance(0, 0, (*it).col(), ima.ncols()); + + double tmp_min; + + if (tmp1 <= tmp2 and tmp1 <= tmp3 and tmp1 <= tmp4) + tmp_min = tmp1; + if (tmp2 <= tmp1 and tmp2 <= tmp3 and tmp2 <= tmp4) + tmp_min = tmp2; + if (tmp3 <= tmp1 and tmp3 <= tmp2 and tmp3 <= tmp4) + tmp_min = tmp3; + if (tmp4 <= tmp1 and tmp4 <= tmp2 and tmp4 <= tmp3) + tmp_min = tmp4; + + if (tmp_min < min) + { + min = tmp_min; + save_x = (*it).row(); + save_y = (*it).col(); + } + } + if (not i) + { + ex_1_x = save_x; + ex_1_y = save_y; + } + else + { + ex_2_x = save_x; + ex_2_y = save_y; + } + } + + res.push_back(oln::point2d(ex_1_x, ex_1_y)); + + std::vector<oln::point2d> tmp; + for (it = v.begin(); it != v.end(); it++) + if (((*it).row() != ex_1_x or (*it).col() != ex_1_y) and + ((*it).row() != ex_2_x or (*it).col() != ex_2_y)) + tmp.push_back(*it); + + + bool stop = false; + + int tmp_x = ex_1_x; + int tmp_y = ex_1_y; + + while (stop == false) + { + if (tmp.size() > 1) + { + double min = 10000000; + oln::point2d p; + std::vector<oln::point2d>::iterator p_ref; + for (it2 = tmp.begin(); it2 != tmp.end(); it2++) + { + double tmp_d = oln::snakes::impl::euclidian_distance((*it2).row(), tmp_x, (*it2).col(), tmp_y); + if (tmp_d < min) + { + min = tmp_d; + p = *it2; + p_ref = it2; + } + } + res.push_back(p); + tmp.erase(p_ref); + tmp_x = p.row(); + tmp_y = p.col(); + } + else + { + res.push_back(oln::point2d(tmp.front().row(), tmp.front().col())); + stop = true; + } + } + + res.push_back(oln::point2d(ex_2_x, ex_2_y)); + return res; +} + + +int main(int argc, char **argv) +{ + using namespace oln; + + if (argc < 10) + { + std::cout << "Usage : ./cmd force_type(0: grad, 1: variance) fen nb_gen lamda dmax snake_type(0:ferme, 1:ouvert) max_pts image_bool images(1+) " << std::endl; + exit(1); + } + + std::vector<oln::point2d> v; + unsigned max_pts = (unsigned)atoi(argv[7]); + + oln::image2d<ntg::bin> mask = load(argv[8]); + oln::image2d<int_u8> input1 = load(argv[9]); + + v = morpho::watersnakes(input1, mask, win_c8p(), 5); + + v = tri_vec(input1, v); + + if (max_pts) + v = oln::snakes::impl::redispatch(v, max_pts); + + for (int i = 9; i < argc; i++) + { + std::cout << i - 8 << " / " << argc - 9 << std::endl; + + oln::image2d<int_u8> input; + input = load(argv[i]); + oln::image2d<int_u8> out(input.size()); + unsigned nb_gen = 0; + + if (i == 9) + nb_gen = (unsigned)atoi(argv[3]); + else + nb_gen = 1; + + v = oln::snakes::snakes(input, v, (force_type)(atoi(argv[1])), (unsigned)atoi(argv[2]), nb_gen, max_pts, atof(argv[4]), (unsigned)atoi(argv[5]), (snake_type)atoi(argv[6])); + + aff_droites(input, v, out); + // aff_points(input, v, out); + + char t[30]; + sprintf(t, "snakes_%d.pgm", i - 8); + + save(out, t); + } +}
18 years, 8 months
1
0
0
0
proto-1.0 455: Update snake force.
by Nicolas Widynski
https://svn/svn/oln/prototypes/proto-1.0/olena
Index: ChangeLog from Nicolas Widynski <nicolas.widynski(a)lrde.epita.fr> Update snake force. * oln/appli/snakes/snakes.hh: 2 external forces to be chosen : gradient and variance. Energy of non agglutination. snakes.hh | 247 ++++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 155 insertions(+), 92 deletions(-) Index: oln/appli/snakes/snakes.hh --- oln/appli/snakes/snakes.hh (revision 454) +++ oln/appli/snakes/snakes.hh (working copy) @@ -36,6 +36,8 @@ # include <vector> #define sqr(u) ((u)*(u)) +typedef enum SNAKE_TYPE { FERME = 0, OUVERT = 1 } snake_type; +typedef enum FORCE_TYPE { GRADIENT = 0, VARIANCE = 1 } force_type; const float PI = 3.14159265; @@ -48,12 +50,12 @@ inline float euclidian_distance(int x1, int x2, int y1, int y2) // sqr { - return sqr(x1 - x2) + sqr(y1 - y2); + return (sqr(x1 - x2) + sqr(y1 - y2)); } template <typename T> - void verify_integrity_(const image2d<T>& grad, + void verify_integrity_(const image2d<T>& force, int &x1, int &x2, int &y1, @@ -63,19 +65,19 @@ x1 = 0; if (x2 < 0) x2 = 0; - if (x1 > grad.nrows()) - x1 = grad.nrows() - 1; - if (x2 > grad.nrows()) - x2 = grad.nrows() - 1; + if (x1 > force.nrows()) + x1 = force.nrows() - 1; + if (x2 > force.nrows()) + x2 = force.nrows() - 1; if (y1 < 0) y1 = 0; if (y2 < 0) y2 = 0; - if (y1 > grad.ncols()) - y1 = grad.ncols() - 1; - if (y2 > grad.ncols()) - y2 = grad.ncols() - 1; + if (y1 > force.ncols()) + y1 = force.ncols() - 1; + if (y2 > force.ncols()) + y2 = force.ncols() - 1; } @@ -154,9 +156,8 @@ - template <typename T> - std::vector<point2d> compute_normal_points_(const image2d<T>& grad, + std::vector<point2d> compute_normal_points_(const image2d<T>& force, const point2d& p1, const point2d& p2, const point2d& p3, @@ -208,12 +209,13 @@ y2 = p2.col(); } - verify_integrity_(grad, x1, x2, y1, y2); + verify_integrity_(force, x1, x2, y1, y2); return draw_line_(point2d(x1, y1), point2d(x2, y2)); } + // we can compute the second derivative. float angle_force(const point2d& p1, const point2d& p2, const point2d& p3) { // al kashi float b = euclidian_distance(p1.row(), p2.row(), p1.col(), p2.col()); @@ -221,49 +223,99 @@ float a = euclidian_distance(p1.row(), p3.row(), p1.col(), p3.col()); float angle = acos((b + c - a) / (2 * sqrt(b) * sqrt(c))); // rad angle = (angle * 180) / PI; //deg - return angle; + return sqr(180 - angle) / sqr(180); + } + + template <typename T> + double variance(const image2d<T>& input, + const point2d& p, + unsigned int fen) + { + double moy = 0; + double res = 0; + + for (int i = p.row() - fen / 2; i < p.row() + fen / 2; i++) + for (int j = p.col() - fen / 2; j < p.col() + fen / 2; j++) + { + point2d p(i, j); + if (input.hold(p)) + moy += input[p]; } + moy /= sqr(fen); + for (int i = p.row() - fen / 2; i < p.row() + fen / 2; i++) + for (int j = p.col() - fen / 2; j < p.col() + fen / 2; j++) + { + point2d p(i, j); + if (input.hold(p)) + res += sqr(input[p] - moy); + } + + return res / sqr(fen); + } template <typename T> - std::vector<point2d> gen_snakes_(const image2d<T>& grad, + std::vector<point2d> gen_snakes_(const image2d<T>& force, const std::vector<point2d>& v, + force_type f, unsigned int fen, float lambda, unsigned int dmax, - unsigned int type) + snake_type type) { std::vector<point2d>::const_iterator it = v.begin(); std::vector<point2d> res; - if (type) - res.push_back(v[0]); - - for (; (it + 2) != v.end(); it++) + for (; it != v.end(); it++) { point2d p1 = *it; - point2d p2 = *(it + 1); - point2d p3 = *(it + 2); - std::vector<point2d> v_normal = compute_normal_points_(grad, p1, p2, p3, dmax); + point2d p2 = *it; + point2d p3 = *it; + + if (type) + { + if (it != v.begin()) + p1 = *(it - 1); + if (it + 1 != v.end()) + p3 = *(it + 1); + } + else + { + if (it == v.begin()) + continue; + if (it + 1 == v.end()) + continue; + p1 = *(it - 1); + p3 = *(it + 1); + } + + std::vector<point2d> v_normal = compute_normal_points_(force, p1, p2, p3, dmax); std::vector<point2d>::const_iterator it2 = v_normal.begin(); - float max = -1; - point2d n_pt(0,0); + float max = -1000000000; + point2d n_pt(-1,-1); for (; it2 != v_normal.end(); it2++) { - float force = grad[*it2]; - if (max < force) + float v_force = 0; + + if (f == GRADIENT) + v_force = (float)(force[*it2]) / 255 - angle_force(p1, *it2, p3) * lambda; + else + v_force = variance(force, *it2, fen) / 128 - angle_force(p1, *it2, p3) * lambda; + + if (max < v_force) { - max = force; + max = v_force; n_pt = *it2; } } + if (n_pt.row() != -1) res.push_back(n_pt); } - if (type == 0) + if (type == FERME) { res.push_back(res[0]); res.push_back(res[1]); @@ -271,78 +323,49 @@ else res.push_back(*(v.end() - 1)); - if (lambda != 0) - { - bool conv = false; + return res; + } - while (conv == false) - { - conv = true; - float max = 0; - std::vector<point2d>::iterator it3 = res.begin(); - std::vector<point2d>::iterator p_s; - point2d n_pt(0,0); - for (; (it3 + 2) != res.end(); it3++) + template <typename T> + void init_view(const image2d<T>& input, + const std::vector<point2d>& v) { - point2d p1 = *it3; - point2d p2 = *(it3 + 1); - point2d p3 = *(it3 + 2); + oln_iter_type(image2d<T>) p(input); + image2d<ntg::int_u8> out(input.size()); + image2d<bool> mask(input.size()); - std::vector<point2d> v_normal = compute_normal_points_(grad, p1, p2, p3, dmax); - std::vector<point2d>::const_iterator it2 = v_normal.begin(); - - float angle_ref = angle_force(p1, p2, p3); - float force_ref = grad[p2] - (180 - angle_ref) * lambda; - - for (; it2 != v_normal.end(); it2++) - { - float angle = angle_force(p1, *it2, p3); - float force = grad[*it2] - (180 - angle) * lambda; + for_all(p) + mask[p] = false; - if (p2.col() != (*it2).col() and p2.row() != (*it2).row() and force - force_ref > max) - { - max = force - force_ref; - p_s = it3 + 1; - n_pt = *it2; - } - } - } + std::vector<point2d>::const_iterator it = v.begin(); + for (; it != v.end(); it++) + mask[*it] = true; - if (max > 0) - { - conv = false; - if (type == 0) + for_all(p) { - if (p_s == (res.begin() + 1)) // 2nd - { - (*(res.end() - 1)).col() = n_pt.col(); - (*(res.end() - 1)).row() = n_pt.row(); - } + if (mask[p] == true) + out[p] = 255; else - if (p_s == (res.end() - 2)) // last - { - (*(res.begin())).col() = n_pt.col(); - (*(res.begin())).row() = n_pt.row(); - } - } - (*p_s).col() = n_pt.col(); - (*p_s).row() = n_pt.row(); - } - } + out[p] = input[p]; } - return res; + save(out, "init.pgm"); } + std::vector<point2d> regen_snaxels(std::vector<point2d>& v, - int type) + snake_type type, + unsigned max_pts) { std::vector<point2d> res; std::vector<point2d> tmp; std::vector<point2d>::iterator it = v.begin(); std::vector<point2d>::iterator it2; + if (2 * v.size() > max_pts) + return v; + for (it = v.begin(); (it + 1) != v.end(); it++) { std::vector<point2d> tmp2 = draw_line_(*it, *(it+1)); @@ -357,7 +380,7 @@ if ((cpt % (tmp.size() / nb_pts)) == 0) res.push_back(*it2); - if (type == 0) + if (type == FERME) { res.push_back(res[0]); res.push_back(res[1]); @@ -369,6 +392,32 @@ } + std::vector<point2d> redispatch(const std::vector<point2d>& v, + int nb_snaxels) + { + std::vector<point2d> res; + std::vector<point2d> tmp; + std::vector<point2d>::const_iterator it = v.begin(); + int cpt = 0; + + for (; it + 1 != v.end(); it++) + { + std::vector<point2d> vec = draw_line_(*it, *(it+1)); + std::vector<point2d>::const_iterator it2 = vec.begin(); + + for (; it2 != vec.end(); it2++) + tmp.push_back(*it2); + } + + for (it = tmp.begin(); it != tmp.end(); it++, cpt++) + if ((cpt % (int)(roundf(((float)(tmp.size()) / nb_snaxels)))) == 0) + res.push_back(*it); + + res.push_back(*(v.end() - 1)); + return res; + } + + template <typename T> void clean_ima(image2d<T>& ima) { @@ -390,34 +439,46 @@ std::vector<point2d> snakes_(const image2d<T>& input, const std::vector<point2d>& v_init, + force_type f, unsigned int fen, unsigned int nb_gen, + unsigned int max_pts, float lambda, unsigned int dmax, - unsigned int type) + snake_type type) { - image2d<T> grad = morpho::gradient_morpho(input, win_c4p()); - clean_ima(grad); + image2d<T> force(input.size()); + + if (f == GRADIENT) + force = morpho::gradient_morpho(input, win_c4p()); + else + { + oln_iter_type(image2d<T>) p(input); + for_all(p) + force[p] = input[p]; + } + + clean_ima(force); std::vector<point2d> res; std::vector<point2d>::const_iterator it = v_init.begin(); for (it = v_init.begin(); it != v_init.end(); it++) res.push_back(*it); - if (type == 0) + if (type == FERME) { res.push_back(res[0]); res.push_back(res[1]); } int i = 0; - while (i < nb_gen) { - res = gen_snakes_(grad, res, fen, lambda, dmax, type); + res = gen_snakes_(force, res, f, fen, lambda, dmax, type); + res = redispatch(res, max_pts); i++; if (i < nb_gen) - res = regen_snaxels(res, type); + res = regen_snaxels(res, type, max_pts); } return res; @@ -430,13 +491,15 @@ std::vector<point2d> snakes(const image2d<T>& input, const std::vector<point2d>& v_init, + force_type f, unsigned int fen, unsigned int nb_gen, + unsigned int max_pts, float lambda, unsigned int dmax, - unsigned int type) // 0 : ferme, 1 : ouvert + snake_type type = OUVERT) { - return impl::snakes_(input, v_init, fen, nb_gen, lambda, dmax, type); + return impl::snakes_(input, v_init, f, fen, nb_gen, max_pts, lambda, dmax, type); } } // end of namespace oln::appli
18 years, 8 months
1
0
0
0
proto-1.0 454: Update Watersnakes.
by Nicolas Widynski
https://svn/svn/oln/prototypes/proto-1.0/olena
Index: ChangeLog from Nicolas Widynski <nicolas.widynski(a)lrde.epita.fr> Update Watersnakes. * oln/morpho/watersnakes.hh: Little modifications. watersnakes.hh | 59 ++++++++++++++++++++++++++------------------------------- 1 file changed, 27 insertions(+), 32 deletions(-) Index: oln/morpho/watersnakes.hh --- oln/morpho/watersnakes.hh (revision 453) +++ oln/morpho/watersnakes.hh (working copy) @@ -46,7 +46,7 @@ const float INFTY = 1000000000000.f; -# define WSHED 255 +# define WSHED -2 # define MASK_VALUE -1 typedef enum version_t { TARJAN = 0, NORMAL = 1 } version; @@ -76,6 +76,7 @@ LS[p] = LS[p] > (float)(input[p] - input[n]) ? LS[p] : (float)(input[p] - input[n]); } } + return LS; } @@ -189,7 +190,6 @@ template <typename T> bool is_a_boundary_point(const image2d<int>& label, - const window2d& ng, const T& p, unsigned& label_b) { @@ -207,20 +207,18 @@ template <typename T> bool snake_iteration(image2d<T>& label, - const window2d& ng, const image2d<float *>& dist, - unsigned nb_compo, int b) { float dist_min = INFTY; point2d p_replace; - unsigned label_replace; + unsigned label_replace = 0; oln_iter_type(image2d<T>) p(label); for_all(p) { unsigned label_b; - if (is_a_boundary_point(label, ng, p, label_b)) + if (is_a_boundary_point(label, p, label_b)) { float tmp = - dist[p][label[p] - 1] + compute_perimeter(label, p, label[p], b) + dist[p][label_b - 1] - compute_perimeter(label, p, label_b, b); @@ -261,18 +259,15 @@ if (marqueur[p] == false) { dist[p][label[p] - 1] = input[p]; - for (int i = 0; i < nb_compo; i++) - if (i != label[p] - 1) + for (unsigned i = 0; i < nb_compo; i++) + if ((int)i != label[p] - 1) dist[p][i] = INFTY; } else - { - for (int i = 0; i < nb_compo; i++) + for (unsigned i = 0; i < nb_compo; i++) dist[p][i] = INFTY; } - } - int i = 0; bool stop = false; @@ -290,7 +285,7 @@ float grad = local_grad(input, LS, p, n); float tmp = chamfer_distance(p, n) * grad; - for (int k = 0; k < nb_compo; k++) + for (unsigned k = 0; k < nb_compo; k++) if (dist[p][k] + tmp < dist[n][k]) { dist[n][k] = dist[p][k] + tmp; @@ -311,7 +306,7 @@ float grad = local_grad(input, LS, p2, n); float tmp = chamfer_distance(p2, n) * grad; - for (int k = 0; k < nb_compo; k++) + for (unsigned k = 0; k < nb_compo; k++) if (dist[p2][k] + tmp < dist[n][k]) { dist[n][k] = dist[p2][k] + tmp; @@ -404,7 +399,6 @@ image2d<int> output(input.size()); level::fill(output, MASK_VALUE); - unsigned tmp; oln_iter_type(image2d<T>) p(input); for_all (p) @@ -415,7 +409,7 @@ } template<typename T, typename T2> - image2d<T> + std::vector<point2d> watershed_line(const image2d<T>& input, const image2d<T>& orig, const image2d<T2>& marqueur, @@ -423,17 +417,14 @@ int b, version v) { - image2d<T> res(input.size()); + image2d<int> final(input.size()); image2d<int> label; image2d<T2> mark(input.size()); oln_iter_type(image2d<T>) p(input); image2d<bool> is_wshed_line(input.size()); - float dist; - float tmp; + std::vector<point2d> res; unsigned nb_compo = 0; - int i = 0; - for_all(p) mark[p] = marqueur[p]; @@ -450,8 +441,8 @@ op_type op(marqueur, input, ng); recon = op.output; } - image2d<float> LS = lower_slope(recon, ng); + label = init_watershed_(recon, mark, ng, nb_compo); image2d<float*> topo = topographic_distance(recon, LS, mark, label, ng, nb_compo); @@ -460,8 +451,7 @@ { unsigned mini_label = 1; float mini_topo = topo[p][0]; - int h = 1; - for (; h < nb_compo; h++) + for (unsigned h = 1; h < nb_compo; h++) if (mini_topo > topo[p][h]) { mini_topo = topo[p][h]; @@ -469,28 +459,33 @@ } label[p] = mini_label; } - while (snake_iteration(label, ng, topo, nb_compo, b)) + + while (snake_iteration(label, topo, b)) ; - level::fill(res, 0); + level::fill(final, 0); for_all(p) { oln_neighb_type(window2d) q(win_c4p(), p); for_all (q) if (input.hold(q)) - if (label[p] != label[q] and res[q] != WSHED) - res[p] = WSHED; - if (res[p] == 0) - res[p] = orig[p]; + if (label[p] != label[q] and final[q] != WSHED) + final[p] = WSHED; + if (final[p] == 0) + final[p] = orig[p]; } + for_all(p) + if (final[p] == WSHED) + res.push_back(p); + return res; } template<typename T, typename T2> - image2d<T> + std::vector<point2d> watersnakes_(const image2d<T>& input, const image2d<T2>& marqueur, const window2d& ng, @@ -508,7 +503,7 @@ template<typename T, typename T2> - image2d<T> + std::vector<point2d> watersnakes(const image2d<T>& input, const image2d<T2>& marqueur, const window2d& ng,
18 years, 8 months
1
0
0
0
453: Fix some warnings with icpc; add is_built_in_.
by Thierry Geraud
https://svn.lrde.epita.fr/svn/oln/trunk/metalic
Index: ChangeLog from Thierry Geraud <theo(a)lrde.epita.fr> Fix some warnings with icpc; add is_built_in_. * tests (svn:ignore): Add '.deps'. * tests/case.cc: Fix warning with icpc. * tests/gcase.cc: New file. * mlc/abstract: New directory. * mlc/type.hh: Rename as... * mlc/abstract/type.hh: ...this. * mlc/bexpr.hh (abstract::bexpr): Move to... * mlc/abstract/bexpr.hh: ...this new file. * mlc/flags.hh: Update include. * mlc/value.hh: Update include. * mlc/ret.hh: Add separators in macros to fix error with icpc. * mlc/assert.hh: Add dtor to fix warning with icpc. * mlc/case.hh (internal::a_get_case): New flag. (get_case_): New class; it differs from case_ in remaining silent when no case matches. * mlc/cmp.hh (is_builtin_): New class with its specializations. mlc/abstract/bexpr.hh | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++ mlc/abstract/type.hh | 10 +++---- mlc/assert.hh | 1 mlc/bexpr.hh | 32 ++++++------------------ mlc/case.hh | 27 ++++++++++++++++++++ mlc/cmp.hh | 44 +++++++++++++++++++++++++++++++++ mlc/flags.hh | 2 - mlc/value.hh | 2 - tests/case.cc | 4 +-- tests/gcase.cc | 38 +++++++++++++++++++++++++++++ 10 files changed, 192 insertions(+), 33 deletions(-) Index: tests/case.cc --- tests/case.cc (revision 452) +++ tests/case.cc (working copy) @@ -52,9 +52,9 @@ template <class T> -void print() +static void print() { - int tmp; + T tmp; } Index: tests/gcase.cc --- tests/gcase.cc (revision 0) +++ tests/gcase.cc (revision 0) @@ -0,0 +1,38 @@ +#include <mlc/is_a.hh> +#include <mlc/case.hh> + + +struct test; + + +mlc_case_equipment_for_namespace(client); + + +namespace client +{ + + template <class T> + struct case_ <test, T, 1> : public mlc::where_< mlc_is_a(T, short) > + { + }; + + template <class T> + struct case_ <test, T, 2> : public mlc::where_< mlc_is_a(T, int) > + { + }; + +} // end of namespace client + + +template <class T> +void print() +{ + int tmp; +} + + + +int main() +{ + print< client::get_case_<test, char>::ret >(); +} Index: mlc/ret.hh Index: mlc/flags.hh --- mlc/flags.hh (revision 452) +++ mlc/flags.hh (working copy) @@ -28,7 +28,7 @@ #ifndef METALIC_FLAGS_HH # define METALIC_FLAGS_HH -# include <mlc/type.hh> +# include <mlc/abstract/type.hh> namespace mlc { Index: mlc/assert.hh --- mlc/assert.hh (revision 452) +++ mlc/assert.hh (working copy) @@ -156,6 +156,7 @@ { public: static void check() {} + virtual ~assert_() {} protected: assert_() {} }; Index: mlc/case.hh --- mlc/case.hh (revision 452) +++ mlc/case.hh (working copy) @@ -64,6 +64,7 @@ namespace internal { + struct a_get_case; struct a_simple_case; struct a_switch_case; @@ -203,6 +204,22 @@ struct handle_default_case_; \ \ \ + template <typename context, typename data> \ + struct handle_default_case_ < mlc::internal::a_get_case, context, data > \ + \ + : private mlc::assert_< mlc::implies_< mlc::is_defined_< NAMESPACE::default_case_<context, data> >, \ + mlc_is_not_a(mlc_comma_1(NAMESPACE::default_case_<context, data>), \ + mlc::where_) >, \ + mlc::ERROR::A_default_case_STATEMENT_SHOULD_NOT_DERIVE_FROM_mlc_where_ > \ + { \ + typedef NAMESPACE::default_case_<context, data> case_t; \ + typedef typename protected_in_<case_t>::the protected_case_t; \ + \ + typedef typename mlc::if_< mlc::is_found_<protected_case_t>, \ + protected_case_t, \ + case_t >::ret ret; \ + }; \ + \ \ template <typename context, typename data> \ struct handle_default_case_ < mlc::internal::a_simple_case, context, data > \ @@ -261,7 +278,8 @@ mlc::where_) >, \ mlc::ERROR::A_case_STATEMENT_SHOULD_DERIVE_FROM_mlc_where_ >, \ \ - private mlc::assert_< mlc::is_defined_< NAMESPACE::default_case_<context, data> >, \ + private mlc::assert_< mlc::implies_< mlc::neq_< use, mlc::internal::a_get_case >, \ + mlc::is_defined_< NAMESPACE::default_case_<context, data> > >, \ mlc::WARNING::NO_default_case_STATEMENT_HAS_BEEN_DEFINED > \ \ { \ @@ -380,6 +398,13 @@ \ \ template <typename context, typename data> \ + struct get_case_ \ + { \ + typedef typename NAMESPACE::internal::select_case_<mlc::internal::a_get_case, context, data>::ret ret; \ + }; \ + \ + \ + template <typename context, typename data> \ struct case_ <context, data, mlc::internal::unknown_case_id> \ \ : private mlc::assert_< mlc::neq_< mlc_comma_2(typename NAMESPACE::internal::select_case_<mlc::internal::a_simple_case, \ Index: mlc/cmp.hh --- mlc/cmp.hh (revision 452) +++ mlc/cmp.hh (working copy) @@ -50,12 +50,16 @@ # define mlc_is_found(T) mlc::is_found_<T> # define mlc_is_not_found(T) mlc::is_not_found_<T> +// FIXME: or (?) mlc_is_not_defined below # define mlc_is_undefined(T) mlc::is_undefined_<T> # define mlc_is_defined(T) mlc::is_defined_<T> # define mlc_is_ok(T) mlc::is_ok_<T> # define mlc_is_not_ok(T) mlc::is_not_ok_<T> +# define mlc_is_builtin(T) mlc::is_builtin_<T> +# define mlc_is_not_builtin(T) mlc::is_not_builtin_<T> + /// \} @@ -162,6 +166,46 @@ /// \} + + /// Check whether a type is a builtin type. + /// \{ + + template <typename T> + struct is_builtin_ : public bexpr_<false> + { + }; + + template <typename T> struct is_builtin_ < const T > : public is_builtin_< T >::bexpr {}; + template <typename T> struct is_builtin_ < T* > : public is_builtin_< T >::bexpr {}; + template <typename T> struct is_builtin_ < T[] > : public is_builtin_< T >::bexpr {}; + template <typename T, + unsigned n> struct is_builtin_ < T[n] > : public is_builtin_< T >::bexpr {}; + + template <> struct is_builtin_ < void > : public bexpr_<true> {}; // FIXME: ? + template <> struct is_builtin_ < bool > : public bexpr_<true> {}; + template <> struct is_builtin_ < char > : public bexpr_<true> {}; + + template <> struct is_builtin_ < float > : public bexpr_<true> {}; + template <> struct is_builtin_ < double > : public bexpr_<true> {}; + template <> struct is_builtin_ < long double > : public bexpr_<true> {}; + + template <> struct is_builtin_ < unsigned char > : public bexpr_<true> {}; + template <> struct is_builtin_ < signed char > : public bexpr_<true> {}; + template <> struct is_builtin_ < unsigned short > : public bexpr_<true> {}; + template <> struct is_builtin_ < signed short > : public bexpr_<true> {}; + template <> struct is_builtin_ < unsigned int > : public bexpr_<true> {}; + template <> struct is_builtin_ < signed int > : public bexpr_<true> {}; + template <> struct is_builtin_ < unsigned long > : public bexpr_<true> {}; + template <> struct is_builtin_ < signed long > : public bexpr_<true> {}; + + template <typename T> + struct is_not_builtin_ : public not_< is_builtin_<T> >::bexpr + { + }; + + /// \} + + } // end of namespace mlc Index: mlc/bexpr.hh --- mlc/bexpr.hh (revision 452) +++ mlc/bexpr.hh (working copy) @@ -28,7 +28,7 @@ #ifndef METALIC_BEXPR_HH # define METALIC_BEXPR_HH -# include <mlc/type.hh> +# include <mlc/abstract/bexpr.hh> # include <mlc/flags.hh> @@ -46,28 +46,6 @@ - namespace abstract { - - /*! \class mlc::abstract::bexpr - ** - ** Abstract base class for mlc Boolean expression types. - ** - ** When you define a new class for a Boolean expression type, you - ** should not directly derive from this class from fom its - ** subclass: bexpr_<b>. - ** - ** \see bexpr_<b> - */ - - struct bexpr : public type - { - // typedef void eval; - }; - - } // end of namespace mlc::abstract - - - /*! \class mlc::bexpr_<b> ** ** Base class for any class of mlc Boolean expression types. @@ -109,6 +87,10 @@ // FIXME: doc typedef bexpr_<true> bexpr; + + protected: + /// Ctor is protected to prevent instantiations. + bexpr_() {} }; @@ -128,6 +110,10 @@ typedef mlc::false_ eval; typedef bexpr_<false> bexpr; + + protected: + /// Ctor is protected to prevent instantiations. + bexpr_() {} }; Index: mlc/abstract/type.hh --- mlc/abstract/type.hh (revision 0) +++ mlc/abstract/type.hh (working copy) @@ -25,8 +25,8 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef METALIC_TYPE_HH -# define METALIC_TYPE_HH +#ifndef METALIC_ABSTRACT_TYPE_HH +# define METALIC_ABSTRACT_TYPE_HH namespace mlc { @@ -48,8 +48,8 @@ struct type { - private: - /// Ctor is private to prevent instantiations. + protected: + /// Ctor is protected to prevent instantiations. type() {} }; @@ -58,4 +58,4 @@ } // end of namespace mlc -#endif // ! METALIC_TYPE_HH +#endif // ! METALIC_ABSTRACT_TYPE_HH Index: mlc/abstract/bexpr.hh --- mlc/abstract/bexpr.hh (revision 0) +++ mlc/abstract/bexpr.hh (revision 0) @@ -0,0 +1,65 @@ +// Copyright (C) 2006 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 59 Temple Place - Suite 330, 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 METALIC_ABSTRACT_BEXPR_HH +# define METALIC_ABSTRACT_BEXPR_HH + +# include <mlc/abstract/type.hh> +# include <mlc/flags.hh> + + + +namespace mlc +{ + + namespace abstract + { + + /*! \class mlc::abstract::bexpr + ** + ** Abstract base class for mlc Boolean expression types. + ** + ** When you define a new class for a Boolean expression type, you + ** should not directly derive from this class from fom its + ** subclass: bexpr_<b>. + ** + ** \see bexpr_<b> + */ + + struct bexpr : public mlc::abstract::type + { + // typedef void eval; + }; + + + } // end of namespace mlc::abstract + +} // end of namespace mlc + + + +#endif // ! METALIC_ABSTRACT_BEXPR_HH Index: mlc/value.hh --- mlc/value.hh (revision 452) +++ mlc/value.hh (working copy) @@ -28,7 +28,7 @@ #ifndef METALIC_VALUE_HH # define METALIC_VALUE_HH -# include <mlc/type.hh> +# include <mlc/abstract/type.hh> // # include <mlc/assert.hh> // # include <mlc/is_a.hh>
18 years, 8 months
1
0
0
0
proto-1.0 452: Update for opened and closed snakes.
by Nicolas Widynski
https://svn/svn/oln/prototypes/proto-1.0/olena
Index: ChangeLog from Nicolas Widynski <nicolas.widynski(a)lrde.epita.fr> Update for opened and closed snakes. * oln/appli/snakes/snakes.hh: Update for opened and closed snakes. snakes.hh | 58 ++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 12 deletions(-) Index: oln/appli/snakes/snakes.hh --- oln/appli/snakes/snakes.hh (revision 451) +++ oln/appli/snakes/snakes.hh (working copy) @@ -51,6 +51,7 @@ return sqr(x1 - x2) + sqr(y1 - y2); } + template <typename T> void verify_integrity_(const image2d<T>& grad, int &x1, @@ -206,6 +207,7 @@ x2 = p2.row() + dmax; y2 = p2.col(); } + verify_integrity_(grad, x1, x2, y1, y2); return draw_line_(point2d(x1, y1), point2d(x2, y2)); @@ -229,11 +231,15 @@ const std::vector<point2d>& v, unsigned int fen, float lambda, - unsigned int dmax) + unsigned int dmax, + unsigned int type) { std::vector<point2d>::const_iterator it = v.begin(); std::vector<point2d> res; + if (type) + res.push_back(v[0]); + for (; (it + 2) != v.end(); it++) { point2d p1 = *it; @@ -257,9 +263,13 @@ res.push_back(n_pt); } + if (type == 0) + { res.push_back(res[0]); res.push_back(res[1]); - + } + else + res.push_back(*(v.end() - 1)); if (lambda != 0) { @@ -272,6 +282,7 @@ std::vector<point2d>::iterator it3 = res.begin(); std::vector<point2d>::iterator p_s; point2d n_pt(0,0); + for (; (it3 + 2) != res.end(); it3++) { point2d p1 = *it3; @@ -282,7 +293,6 @@ std::vector<point2d>::const_iterator it2 = v_normal.begin(); float angle_ref = angle_force(p1, p2, p3); - float force_ref = grad[p2] - (180 - angle_ref) * lambda; for (; it2 != v_normal.end(); it2++) @@ -302,6 +312,8 @@ if (max > 0) { conv = false; + if (type == 0) + { if (p_s == (res.begin() + 1)) // 2nd { (*(res.end() - 1)).col() = n_pt.col(); @@ -313,6 +325,7 @@ (*(res.begin())).col() = n_pt.col(); (*(res.begin())).row() = n_pt.row(); } + } (*p_s).col() = n_pt.col(); (*p_s).row() = n_pt.row(); } @@ -322,8 +335,8 @@ return res; } - - std::vector<point2d> regen_snaxels(std::vector<point2d>& v) + std::vector<point2d> regen_snaxels(std::vector<point2d>& v, + int type) { std::vector<point2d> res; std::vector<point2d> tmp; @@ -338,15 +351,24 @@ } int nb_pts = v.size() * 2; - int cpt = 1; + int cpt = 0; for (it2 = tmp.begin(); it2 != tmp.end(); it2++, cpt++) if ((cpt % (tmp.size() / nb_pts)) == 0) res.push_back(*it2); + if (type == 0) + { + res.push_back(res[0]); + res.push_back(res[1]); + } + else + res.push_back(*(v.end() - 1)); + return res; } + template <typename T> void clean_ima(image2d<T>& ima) { @@ -367,25 +389,35 @@ template <typename T> std::vector<point2d> snakes_(const image2d<T>& input, + const std::vector<point2d>& v_init, unsigned int fen, unsigned int nb_gen, float lambda, - unsigned int dmax) + unsigned int dmax, + unsigned int type) { image2d<T> grad = morpho::gradient_morpho(input, win_c4p()); clean_ima(grad); std::vector<point2d> res; + std::vector<point2d>::const_iterator it = v_init.begin(); + for (it = v_init.begin(); it != v_init.end(); it++) + res.push_back(*it); - // build init points + 2 (close snake) + if (type == 0) + { + res.push_back(res[0]); + res.push_back(res[1]); + } int i = 0; + while (i < nb_gen) { - res = gen_snakes_(grad, res, fen, lambda, dmax); + res = gen_snakes_(grad, res, fen, lambda, dmax, type); i++; if (i < nb_gen) - res = regen_snaxels(res); + res = regen_snaxels(res, type); } return res; @@ -397,12 +429,14 @@ template <typename T> std::vector<point2d> snakes(const image2d<T>& input, + const std::vector<point2d>& v_init, unsigned int fen, unsigned int nb_gen, float lambda, - unsigned int dmax) + unsigned int dmax, + unsigned int type) // 0 : ferme, 1 : ouvert { - return impl::snakes_(input, fen, nb_gen, lambda, dmax); + return impl::snakes_(input, v_init, fen, nb_gen, lambda, dmax, type); } } // end of namespace oln::appli
18 years, 8 months
1
0
0
0
proto-1.0 451: Add a closed snake algorithm.
by Nicolas Widynski
https://svn/svn/oln/prototypes/proto-1.0/olena
Index: ChangeLog from Nicolas Widynski <nicolas.widynski(a)lrde.epita.fr> Add a closed snake algorithm. * oln/appli/snakes: New. Directory. * oln/appli/snakes/snakes.hh: New. Snake algorithm. 2 forces : gradient and snake perimeter. snakes.hh | 413 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 413 insertions(+) Index: oln/appli/snakes/snakes.hh --- oln/appli/snakes/snakes.hh (revision 0) +++ oln/appli/snakes/snakes.hh (revision 0) @@ -0,0 +1,413 @@ +// Copyright (C) 2001-2006 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 59 Temple Place - Suite 330, 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 OLENA_SNAKES_HH +# define OLENA_SNAKES_HH + +# include <mlc/is_a.hh> +# include <oln/basics2d.hh> +# include <ntg/all.hh> +# include <oln/morpho/gradient_morpho.hh> +# include <ntg/int.hh> +# include <vector> + +#define sqr(u) ((u)*(u)) +const float PI = 3.14159265; + + +namespace oln { + + namespace snakes { + + namespace impl { + + inline + float euclidian_distance(int x1, int x2, int y1, int y2) // sqr + { + return sqr(x1 - x2) + sqr(y1 - y2); + } + + template <typename T> + void verify_integrity_(const image2d<T>& grad, + int &x1, + int &x2, + int &y1, + int &y2) + { + if (x1 < 0) + x1 = 0; + if (x2 < 0) + x2 = 0; + if (x1 > grad.nrows()) + x1 = grad.nrows() - 1; + if (x2 > grad.nrows()) + x2 = grad.nrows() - 1; + + if (y1 < 0) + y1 = 0; + if (y2 < 0) + y2 = 0; + if (y1 > grad.ncols()) + y1 = grad.ncols() - 1; + if (y2 > grad.ncols()) + y2 = grad.ncols() - 1; + } + + + std::vector<point2d> draw_line_(const point2d& p, + const point2d& q) + { + std::vector<point2d> res; + + point2d p_cur = p; + if (q.col() == p.col()) // cas vertical + { + int sens = q.row() > p.row() ? 1 : -1; + while (p_cur != q) + { + double pc_p = euclidian_distance(p_cur.row(), p.row(), p_cur.col(), p.col()); + double pc_q = euclidian_distance(p_cur.row(), q.row(), p_cur.col(), q.col()); + double p_q = euclidian_distance(p.row(), q.row(), p.col(), q.col()); + + res.push_back(p_cur); + p_cur.row() = p_cur.row() + sens; + } + } + else + { + if (q.row() == p.row()) // cas horizontal + { + int sens = q.col() > p.col() ? 1 : -1; + while (p_cur != q) + { + double pc_p = euclidian_distance(p_cur.row(), p.row(), p_cur.col(), p.col()); + double pc_q = euclidian_distance(p_cur.row(), q.row(), p_cur.col(), q.col()); + double p_q = euclidian_distance(p.row(), q.row(), p.col(), q.col()); + + res.push_back(p_cur); + p_cur.col() = p_cur.col() + sens; + } + } + else // cas diagonal + { + long decalage = 0; + + long nom = q.row() - p.row(); + long denom = q.col() - p.col(); + int signe = (nom * denom) > 0 ? 1 : -1; + nom = nom * signe; + denom = denom * signe; + + int vsens = q.row() > p.row() ? 1 : -1; + int hsens = q.col() > p.col() ? 1 : -1; + + int deboule = 0; + + while (p_cur != q) + { + double pc_p = euclidian_distance(p_cur.row(), p.row(), p_cur.col(), p.col()); + double pc_q = euclidian_distance(p_cur.row(), q.row(), p_cur.col(), q.col()); + double p_q = euclidian_distance(p.row(), q.row(), p.col(), q.col()); + + res.push_back(p_cur); + + if (abs(decalage) >= abs(denom)) + { + p_cur.row() = p_cur.row() + vsens; + decalage -= vsens * denom; + } + else + { + p_cur.col() = p_cur.col() + hsens; + decalage += nom * hsens; + } + } + } + } + return res; + } + + + + + template <typename T> + std::vector<point2d> compute_normal_points_(const image2d<T>& grad, + const point2d& p1, + const point2d& p2, + const point2d& p3, + unsigned int dmax) + { + float x_c = p2.row(); + float y_c = p2.col(); + float a_p1_p3 = (p1.col() - p3.col()) != 0 ? (float)(((float)(p1.row() - p3.row())) / (p1.col() - p3.col())) : 0; + float a = -a_p1_p3; + float b = p2.col() - a * p2.row(); // use of - slope of p1 et p3 + + int x1 = 0; + int y1 = 0; + int x2 = 0; + int y2 = 0; + + if (a != 0) + { + float A = 1 + sqr(a); + float B = -2 * (x_c + a * y_c - a * b); + float C = sqr(x_c) + sqr((b - y_c)) - sqr(dmax); + + float delta = sqr(B) - (4 * A * C); + + if (delta > 0) + { + x1 = (int)(roundf((-B + sqrt(delta)) / (2 * A))); + x2 = (int)(roundf((-B - sqrt(delta)) / (2 * A))); + + if (x1 == x2) + { + float tmp1 = roundf((-B + sqrt(delta)) / (2 * A)); + float tmp2 = roundf((-B - sqrt(delta)) / (2 * A)); + if (tmp1 > tmp2) + x1++; + else + x2++; + } + + y1 = (int)(a * x1 + b); + y2 = (int)(a * x2 + b); + } + } + else + { + x1 = p2.row() - dmax; + y1 = p2.col(); + x2 = p2.row() + dmax; + y2 = p2.col(); + } + verify_integrity_(grad, x1, x2, y1, y2); + + return draw_line_(point2d(x1, y1), point2d(x2, y2)); + } + + + float angle_force(const point2d& p1, const point2d& p2, const point2d& p3) + { // al kashi + float b = euclidian_distance(p1.row(), p2.row(), p1.col(), p2.col()); + float c = euclidian_distance(p3.row(), p2.row(), p3.col(), p2.col()); + float a = euclidian_distance(p1.row(), p3.row(), p1.col(), p3.col()); + float angle = acos((b + c - a) / (2 * sqrt(b) * sqrt(c))); // rad + angle = (angle * 180) / PI; //deg + return angle; + } + + + + template <typename T> + std::vector<point2d> gen_snakes_(const image2d<T>& grad, + const std::vector<point2d>& v, + unsigned int fen, + float lambda, + unsigned int dmax) + { + std::vector<point2d>::const_iterator it = v.begin(); + std::vector<point2d> res; + + for (; (it + 2) != v.end(); it++) + { + point2d p1 = *it; + point2d p2 = *(it + 1); + point2d p3 = *(it + 2); + std::vector<point2d> v_normal = compute_normal_points_(grad, p1, p2, p3, dmax); + std::vector<point2d>::const_iterator it2 = v_normal.begin(); + + float max = -1; + point2d n_pt(0,0); + + for (; it2 != v_normal.end(); it2++) + { + float force = grad[*it2]; + if (max < force) + { + max = force; + n_pt = *it2; + } + } + res.push_back(n_pt); + } + + res.push_back(res[0]); + res.push_back(res[1]); + + + if (lambda != 0) + { + bool conv = false; + + while (conv == false) + { + conv = true; + float max = 0; + std::vector<point2d>::iterator it3 = res.begin(); + std::vector<point2d>::iterator p_s; + point2d n_pt(0,0); + for (; (it3 + 2) != res.end(); it3++) + { + point2d p1 = *it3; + point2d p2 = *(it3 + 1); + point2d p3 = *(it3 + 2); + + std::vector<point2d> v_normal = compute_normal_points_(grad, p1, p2, p3, dmax); + std::vector<point2d>::const_iterator it2 = v_normal.begin(); + + float angle_ref = angle_force(p1, p2, p3); + + float force_ref = grad[p2] - (180 - angle_ref) * lambda; + + for (; it2 != v_normal.end(); it2++) + { + float angle = angle_force(p1, *it2, p3); + float force = grad[*it2] - (180 - angle) * lambda; + + if (p2.col() != (*it2).col() and p2.row() != (*it2).row() and force - force_ref > max) + { + max = force - force_ref; + p_s = it3 + 1; + n_pt = *it2; + } + } + } + + if (max > 0) + { + conv = false; + if (p_s == (res.begin() + 1)) // 2nd + { + (*(res.end() - 1)).col() = n_pt.col(); + (*(res.end() - 1)).row() = n_pt.row(); + } + else + if (p_s == (res.end() - 2)) // last + { + (*(res.begin())).col() = n_pt.col(); + (*(res.begin())).row() = n_pt.row(); + } + (*p_s).col() = n_pt.col(); + (*p_s).row() = n_pt.row(); + } + } + } + + return res; + } + + + std::vector<point2d> regen_snaxels(std::vector<point2d>& v) + { + std::vector<point2d> res; + std::vector<point2d> tmp; + std::vector<point2d>::iterator it = v.begin(); + std::vector<point2d>::iterator it2; + + for (it = v.begin(); (it + 1) != v.end(); it++) + { + std::vector<point2d> tmp2 = draw_line_(*it, *(it+1)); + for (it2 = tmp2.begin(); it2 != tmp2.end(); it2++) + tmp.push_back(*it2); + } + + int nb_pts = v.size() * 2; + int cpt = 1; + + for (it2 = tmp.begin(); it2 != tmp.end(); it2++, cpt++) + if ((cpt % (tmp.size() / nb_pts)) == 0) + res.push_back(*it2); + + return res; + } + + template <typename T> + void clean_ima(image2d<T>& ima) + { + for (int j = 0; j < ima.size().ncols(); j++) + { + ima(-1, j) = ima(0, j); + ima(ima.size().nrows(), j) = ima(ima.size().nrows() - 1, j); + } + + for (int j = 0; j < ima.size().nrows(); j++) + { + ima(j, -1) = ima(j, 0); + ima(j, ima.size().ncols()) = ima(j, ima.size().ncols() - 1); + } + } + + + template <typename T> + std::vector<point2d> + snakes_(const image2d<T>& input, + unsigned int fen, + unsigned int nb_gen, + float lambda, + unsigned int dmax) + { + image2d<T> grad = morpho::gradient_morpho(input, win_c4p()); + clean_ima(grad); + + std::vector<point2d> res; + + // build init points + 2 (close snake) + + int i = 0; + while (i < nb_gen) + { + res = gen_snakes_(grad, res, fen, lambda, dmax); + i++; + if (i < nb_gen) + res = regen_snaxels(res); + } + + return res; + } + + + } // end of namespace oln::impl::snakes + + template <typename T> + std::vector<point2d> + snakes(const image2d<T>& input, + unsigned int fen, + unsigned int nb_gen, + float lambda, + unsigned int dmax) + { + return impl::snakes_(input, fen, nb_gen, lambda, dmax); + } + + } // end of namespace oln::appli + +} // end of namespace oln + + +#endif // ! OLENA_SNAKES_HH
18 years, 8 months
1
0
0
0
← Newer
1
2
3
4
Older →
Jump to page:
1
2
3
4
Results per page:
10
25
50
100
200