Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
April 2005
- 8 participants
- 73 discussions
2005-04-29 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add some function objects.
* oln/funobj/abstract/binary.hh: New file.
* oln/funobj/abstract/unary.hh: Likewise.
* oln/funobj/meta.hh: Likewise.
* oln/funobj/arith.hh: Likewise.
* oln/funobj/logic.hh: Likewise.
* oln/funobj/cmp.hh: Likewise.
* oln/core/typedefs.hh: Update with new typedef decls.
Update of oln/core/pw/*
* oln/core/pw/binary_op.hh: New file.
* oln/core/pw/unary_op.hh: New file.
* oln/core/pw/times.hh,
* oln/core/pw/div.hh,
* oln/core/pw/plus.hh,
* oln/core/pw/minus.hh: Remove, replace by...
* oln/core/pw/arith.hh: ...this new file.
* oln/core/pw/image.hh (image_from_pw): Rename as...
(image_from_pwf): ...this.
(pw::image): Rename as...
(pw::value): ...this.
(p_value): Rename as...
(pw_value): ...this.
* oln/core/pw/image.hh: Move some parts into...
* oln/core/pw/value.hh: ...this new file.
* oln/core/pw/check.hh: ...and this new file.
* oln/core/pw/macros.hh: Update.
* oln/core/pw/abstract/function.hh (ensure): Add.
(operator-, operator!): Comment because not updated yet.
(~function): Use mlc_check_method_impl.
* oln/core/pw/abstract/unary_function.hh (input): Rename as...
(arg): ...this.
(T): Rename as...
(A): ...this.
* oln/core/pw/apply.hh: Update.
* oln/core/pw/literal.hh (p_lit): Rename as...
(p_literal): ...this.
* oln/core/pw/logic.hh: Update.
* oln/core/pw/cmp.hh: Likewise.
* oln/core/pw/all.hh: Likewise.
* oln/arith/ops.hh: Likewise.
* oln/arith/logic.hh: Likewise.
* oln/arith/cmp.hh: New file.
Fix morpho for geodesic_dilation to work.
* oln/morpho/elementary_dilation.hh: New file.
* oln/morpho/tags.hh (max_nbh, impl_max_nbh): New methods.
* oln/funobj/accum.hh (max_accumulator_init): New fun obj.
* oln/morpho/geodesic_dilation.hh
(operator<=): Remove thanks to oln/arith/cmp.hh.
* oln/morpho/geodesic_erosion.hh: Likewise.
* oln/morpho/stat.hh (local_max_nbh): New routine.
Index: oln/funobj/abstract/binary.hh
===================================================================
--- oln/funobj/abstract/binary.hh (revision 0)
+++ oln/funobj/abstract/binary.hh (revision 0)
@@ -0,0 +1,187 @@
+// Copyright (C) 2005 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_CORE_FUNOBJ_ABSTRACT_BINARY_HH
+# define OLENA_CORE_FUNOBJ_ABSTRACT_BINARY_HH
+
+# include <mlc/any.hh>
+# include <mlc/contract.hh>
+# include <mlc/types.hh>
+# include <ntg/all.hh>
+# include <oln/core/abstract/image.hh>
+
+
+// Macros.
+
+# define oln_fun2_type_of(Fun2Type, Alias) \
+mlc_type_of(oln, oln::category::fun2, Fun2Type, Alias)
+
+# define oln_fun2_type_2_of(Fun2Type,_2, Alias) \
+mlc_type_2_of(oln, oln::category::fun2, Fun2Type,_2, Alias)
+
+
+
+
+namespace oln
+{
+
+ namespace category
+ {
+ struct fun2;
+ }
+
+
+ template <>
+ struct set_default_props < category::fun2 >
+ {
+ typedef mlc::undefined_type res_type;
+ typedef mlc::undefined_type left_type;
+ typedef mlc::undefined_type right_type;
+ };
+
+
+ template <typename F>
+ struct get_props < category::fun2, F >
+ {
+ typedef oln_fun2_type_of(F, res) res_type;
+ typedef oln_fun2_type_of(F, left) left_type;
+ typedef oln_fun2_type_of(F, right) right_type;
+
+ static void echo(std::ostream& ostr)
+ {
+ ostr << "props_of( oln::category::fun1, " << mlc_to_string(F) << " ) =" << std::endl
+ << "{" << std::endl
+ << "\t res_type = " << mlc_to_string(res_type) << std::endl
+ << "\t left_type = " << mlc_to_string(left_type) << std::endl
+ << "\t right_type = " << mlc_to_string(right_type) << std::endl
+ << "}" << std::endl;
+ }
+
+ static void ensure()
+ {
+ mlc::is_ok< res_type >::ensure();
+ mlc::is_ok< left_type >::ensure();
+ mlc::is_ok< right_type >::ensure();
+ }
+ };
+
+
+
+ namespace f_
+ {
+
+
+ template <typename F, typename L, typename R>
+ struct binary_meta_result
+ {
+ typedef mlc::no_type ret;
+ };
+
+
+ namespace abstract {
+
+ // binary
+
+ template <typename E>
+ struct binary : public mlc::any<E>
+ {
+ typedef oln_fun2_type_of(E, res) res_type;
+ typedef oln_fun2_type_of(E, left) left_type;
+ typedef oln_fun2_type_of(E, right) right_type;
+
+ const res_type operator()(const left_type& left, const right_type& right) const
+ {
+ return this->exact().impl_binop(left, right);
+ }
+
+ protected:
+
+ binary()
+ {}
+
+ ~binary()
+ {
+ get_props<category::fun2, E>::ensure();
+ mlc_check_method_impl_2(E, const res_type, binop, const left_type&,
+ const right_type&, const);
+ }
+ };
+
+
+ // mbinary
+
+ template <typename E>
+ struct mbinary : public mlc::any<E>
+ {
+ template <typename L, typename R>
+ const typename binary_meta_result<E,L,R>::ret
+ operator()(const L& left, const R& right) const
+ {
+ return this->exact().impl_binop(left, right);
+ }
+
+ protected:
+
+ mbinary() {}
+ };
+
+
+ } // end of namespace oln::abstract
+
+
+
+
+ // fwd decl
+ template <template <typename, typename> class F> struct binary_meta;
+
+ // result
+ template <template <typename, typename> class F, typename L, typename R>
+ struct binary_meta_result < binary_meta<F>, L, R >
+ {
+ typedef oln_fun2_type_2_of(F<L,R>, res) ret;
+ };
+
+ // class
+ template <template <typename, typename> class F>
+ struct binary_meta : public abstract::mbinary< binary_meta<F> >
+ {
+ template <typename L, typename R>
+ const oln_fun2_type_2_of(F<L,R>, res)
+ impl_binop(const L& l, const R& r) const
+ {
+ static F<L,R> f;
+ return f(l, r);
+ }
+ };
+
+ } // end of namespace oln::f_
+
+} // end of namespace oln
+
+
+
+#endif // ! OLENA_CORE_FUNOBJ_ABSTRACT_BINARY_HH
Index: oln/funobj/abstract/unary.hh
===================================================================
--- oln/funobj/abstract/unary.hh (revision 0)
+++ oln/funobj/abstract/unary.hh (revision 0)
@@ -0,0 +1,169 @@
+// Copyright (C) 2005 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_CORE_FUNOBJ_ABSTRACT_UNARY_HH
+# define OLENA_CORE_FUNOBJ_ABSTRACT_UNARY_HH
+
+# include <mlc/any.hh>
+# include <mlc/contract.hh>
+# include <ntg/all.hh>
+# include <oln/core/abstract/image.hh>
+
+
+// Macros.
+
+# define oln_fun1_type_of(Fun1Type, Alias) \
+mlc_type_of(oln, oln::category::fun1, Fun1Type, Alias)
+
+
+namespace oln
+{
+
+ namespace category
+ {
+ struct fun1;
+ }
+
+
+ template <>
+ struct set_default_props < category::fun1 >
+ {
+ typedef mlc::undefined_type res_type;
+ typedef mlc::undefined_type arg_type;
+ };
+
+
+ template <typename F>
+ struct get_props < category::fun1, F >
+ {
+ typedef oln_fun1_type_of(F, res) res_type;
+ typedef oln_fun1_type_of(F, arg) arg_type;
+
+ static void echo(std::ostream& ostr)
+ {
+ ostr << "props_of( oln::category::fun1, " << mlc_to_string(F) << " ) =" << std::endl
+ << "{" << std::endl
+ << "\t res_type = " << mlc_to_string(res_type) << std::endl
+ << "\t arg_type = " << mlc_to_string(arg_type) << std::endl
+ << "}" << std::endl;
+ }
+
+ static void ensure()
+ {
+ mlc::is_ok< res_type >::ensure();
+ mlc::is_ok< arg_type >::ensure();
+ }
+ };
+
+
+ namespace f_
+ {
+
+ template <typename F, typename T>
+ struct unary_meta_result
+ {
+ typedef mlc::no_type ret;
+ };
+
+
+ namespace abstract {
+
+ // unary
+
+ template <typename E>
+ struct unary : public mlc::any<E>
+ {
+ typedef oln_fun1_type_of(E, res) res_type;
+ typedef oln_fun1_type_of(E, arg) arg_type;
+ const res_type operator()(const arg_type& arg) const
+ {
+ return this->exact().impl_unop(arg);
+ }
+ protected:
+ unary() {}
+ ~unary()
+ {
+ get_props<category::fun1, E>::ensure();
+ mlc_check_method_impl(E, const res_type, unop, const arg_type&, const);
+ }
+ };
+
+ // munary
+
+ template <typename E>
+ struct munary : public mlc::any<E>
+ {
+ template <typename T>
+ const typename unary_meta_result<E,T>::ret
+ operator()(const T& arg) const
+ {
+ return this->exact().impl_unop(arg);
+ }
+ protected:
+ munary() {}
+ };
+
+
+ } // end of namespace oln::abstract
+
+
+
+
+ /// Meta unary function that relies on a unary function.
+
+
+ // fwd decl
+ template <template <typename> class F> struct unary_meta;
+
+ // result
+ template <template <typename> class F, typename T>
+ struct unary_meta_result < unary_meta<F>, T >
+ {
+ typedef oln_fun1_type_of(F<T>, res) ret;
+ };
+
+ // class
+ template <template <typename> class F>
+ struct unary_meta : public abstract::munary< unary_meta<F> >
+ {
+ template <typename T>
+ const oln_fun1_type_of(F<T>, res)
+ impl_unop(const T& arg) const
+ {
+ static F<T> f;
+ return f(arg);
+ }
+ };
+
+
+ } // end of namespace oln::f_
+
+} // end of namespace oln
+
+
+
+#endif // ! OLENA_CORE_FUNOBJ_ABSTRACT_UNARY_HH
Index: oln/funobj/meta.hh
===================================================================
--- oln/funobj/meta.hh (revision 0)
+++ oln/funobj/meta.hh (revision 0)
@@ -0,0 +1,85 @@
+// Copyright (C) 2005 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_CORE_FUNOBJ_META_HH
+# define OLENA_CORE_FUNOBJ_META_HH
+
+# include <oln/funobj/abstract/unary.hh>
+# include <oln/funobj/abstract/binary.hh>
+
+
+namespace oln
+{
+
+ /// Plus.
+
+
+ // fwd decl
+ namespace f_ {
+ template <typename L, typename R> struct plus;
+ }
+
+ // super type
+ template <typename L, typename R>
+ struct set_super_type < f_::plus<L,R> > { typedef f_::abstract::binary< f_::plus<L,R> > ret; };
+
+ // props
+ template <typename L, typename R>
+ struct set_props < category::fun2, f_::plus<L,R> >
+ {
+ typedef ntg_return_type(plus, L, R) res_type;
+ typedef L left_type;
+ typedef R right_type;
+ };
+
+ namespace f_
+ {
+
+ // class
+ template <typename L, typename R>
+ struct plus : public oln_super2_of_(f_::plus<L,R>)
+ {
+ typedef plus<L,R> self_type;
+
+ const oln_fun2_type_of(self_type, res)
+ impl_binop(const L& left, const R& right) const
+ {
+ return left + right;
+ }
+ };
+
+ } // end of namespace oln::f_
+
+
+ static f_::binary_meta<f_::plus> f_plus;
+
+
+} // end of namespace oln
+
+
+
+#endif // ! OLENA_CORE_FUNOBJ_META_HH
Index: oln/funobj/arith.hh
===================================================================
--- oln/funobj/arith.hh (revision 0)
+++ oln/funobj/arith.hh (revision 0)
@@ -0,0 +1,143 @@
+// Copyright (C) 2005 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_CORE_FUNOBJ_ARITH_HH
+# define OLENA_CORE_FUNOBJ_ARITH_HH
+
+# include <oln/funobj/abstract/unary.hh>
+# include <oln/funobj/abstract/binary.hh>
+
+
+# define oln_decl_funobj_binary(OperatorName, OperatorSymbol) \
+ \
+ namespace f_ { \
+ template <typename L, typename R> struct OperatorName##_; \
+ } \
+ \
+ template <typename L, typename R> \
+ struct set_super_type < f_::OperatorName##_<L,R> > \
+ { \
+ typedef f_::abstract::binary< f_::OperatorName##_<L,R> > ret; \
+ }; \
+ \
+ template <typename L, typename R> \
+ struct set_props < category::fun2, f_::OperatorName##_<L,R> > \
+ { \
+ typedef ntg_return_type(OperatorName, L, R) res_type; \
+ typedef L left_type; \
+ typedef R right_type; \
+ }; \
+ \
+ namespace f_ \
+ { \
+ \
+ template <typename L, typename R> \
+ struct OperatorName##_ : public oln_super2_of_(f_::OperatorName##_<L,R>) \
+ { \
+ typedef OperatorName##_<L,R> self_type; \
+ \
+ const oln_fun2_type_of(self_type, res) \
+ impl_binop(const L& left, const R& right) const \
+ { \
+ return left OperatorSymbol right; \
+ } \
+ }; \
+ \
+ } \
+ \
+ typedef f_::binary_meta<f_::OperatorName##_> f_##OperatorName##_type; \
+ static f_##OperatorName##_type f_##OperatorName; \
+ \
+struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
+
+
+
+
+
+
+# define oln_decl_funobj_cmp(OperatorName, OperatorSymbol) \
+ \
+ namespace f_ { \
+ template <typename L, typename R> struct OperatorName##_; \
+ } \
+ \
+ template <typename L, typename R> \
+ struct set_super_type < f_::OperatorName##_<L,R> > \
+ { \
+ typedef f_::abstract::binary< f_::OperatorName##_<L,R> > ret; \
+ }; \
+ \
+ template <typename L, typename R> \
+ struct set_props < category::fun2, f_::OperatorName##_<L,R> > \
+ { \
+ typedef bool res_type; \
+ typedef L left_type; \
+ typedef R right_type; \
+ }; \
+ \
+ namespace f_ \
+ { \
+ \
+ template <typename L, typename R> \
+ struct OperatorName##_ : public oln_super2_of_(f_::OperatorName##_<L,R>) \
+ { \
+ typedef OperatorName##_<L,R> self_type; \
+ \
+ const oln_fun2_type_of(self_type, res) \
+ impl_binop(const L& left, const R& right) const \
+ { \
+ return left OperatorSymbol right; \
+ } \
+ }; \
+ \
+ } \
+ \
+ typedef f_::binary_meta<f_::OperatorName##_> f_##OperatorName##_type; \
+ static f_##OperatorName##_type f_##OperatorName; \
+ \
+struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
+
+
+
+namespace oln
+{
+
+ oln_decl_funobj_binary(plus, +);
+ oln_decl_funobj_binary(minus, -);
+ oln_decl_funobj_binary(times, *);
+ oln_decl_funobj_binary(div, /);
+ oln_decl_funobj_binary(mod, %);
+
+ // FIXME: min, max?
+ // FIXME: uminus?
+
+
+} // end of namespace oln
+
+
+
+#endif // ! OLENA_CORE_FUNOBJ_ARITH_HH
Index: oln/funobj/accum.hh
===================================================================
--- oln/funobj/accum.hh (revision 174)
+++ oln/funobj/accum.hh (working copy)
@@ -142,6 +142,35 @@
};
+ /// Max accumulator with initialization value.
+
+ template <class T>
+ struct max_accumulator_init
+ {
+
+ template <typename U>
+ max_accumulator_init(const U& init) :
+ acc_(init)
+ {}
+
+ void operator()(T t)
+ {
+ if (acc_ < t)
+ acc_ = t;
+ }
+
+ operator T() const
+ {
+ return acc_;
+ }
+
+ private:
+
+ T acc_;
+
+ };
+
+
} // end of namespace oln::funobj
} // end of namespace oln
Index: oln/funobj/logic.hh
===================================================================
--- oln/funobj/logic.hh (revision 0)
+++ oln/funobj/logic.hh (revision 0)
@@ -0,0 +1,97 @@
+// Copyright (C) 2005 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_CORE_FUNOBJ_LOGIC_HH
+# define OLENA_CORE_FUNOBJ_LOGIC_HH
+
+# include <oln/funobj/abstract/binary.hh>
+
+
+
+
+# define oln_decl_funobj_logic(OperatorName, OperatorBody) \
+ \
+ namespace f_ { \
+ template <typename L, typename R> struct OperatorName##_; \
+ } \
+ \
+ template <typename L, typename R> \
+ struct set_super_type < f_::OperatorName##_<L,R> > \
+ { \
+ typedef f_::abstract::binary< f_::OperatorName##_<L,R> > ret; \
+ }; \
+ \
+ template <typename L, typename R> \
+ struct set_props < category::fun2, f_::OperatorName##_<L,R> > \
+ { \
+ typedef bool res_type; \
+ typedef L left_type; \
+ typedef R right_type; \
+ }; \
+ \
+ namespace f_ \
+ { \
+ \
+ template <typename L, typename R> \
+ struct OperatorName##_ : public oln_super2_of_(f_::OperatorName##_<L,R>) \
+ { \
+ typedef OperatorName##_<L,R> self_type; \
+ \
+ const oln_fun2_type_of(self_type, res) \
+ impl_binop(const L& lhs, const R& rhs) const \
+ { \
+ return OperatorBody; \
+ } \
+ }; \
+ \
+ } \
+ \
+ typedef f_::binary_meta<f_::OperatorName##_> f_##OperatorName##_type; \
+ static f_##OperatorName##_type f_##OperatorName; \
+ \
+struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
+
+
+
+namespace oln
+{
+
+ oln_decl_funobj_logic( and, lhs && rhs);
+ oln_decl_funobj_logic(nand, !(lhs && rhs));
+ oln_decl_funobj_logic( or, lhs || rhs);
+ oln_decl_funobj_logic( nor, !(lhs || rhs));
+ oln_decl_funobj_logic( xor, (lhs && !rhs) || (!lhs && rhs));
+ oln_decl_funobj_logic(xnor, (lhs && rhs) || (!lhs && !rhs));
+
+ // FIXME: what about 'not'?!!!
+
+
+} // end of namespace oln
+
+
+
+#endif // ! OLENA_CORE_FUNOBJ_LOGIC_HH
Index: oln/funobj/cmp.hh
===================================================================
--- oln/funobj/cmp.hh (revision 0)
+++ oln/funobj/cmp.hh (revision 0)
@@ -0,0 +1,97 @@
+// Copyright (C) 2005 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_CORE_FUNOBJ_CMP_HH
+# define OLENA_CORE_FUNOBJ_CMP_HH
+
+# include <oln/funobj/abstract/binary.hh>
+
+
+
+
+# define oln_decl_funobj_cmp(OperatorName, OperatorSymbol) \
+ \
+ namespace f_ { \
+ template <typename L, typename R> struct OperatorName##_; \
+ } \
+ \
+ template <typename L, typename R> \
+ struct set_super_type < f_::OperatorName##_<L,R> > \
+ { \
+ typedef f_::abstract::binary< f_::OperatorName##_<L,R> > ret; \
+ }; \
+ \
+ template <typename L, typename R> \
+ struct set_props < category::fun2, f_::OperatorName##_<L,R> > \
+ { \
+ typedef bool res_type; \
+ typedef L left_type; \
+ typedef R right_type; \
+ }; \
+ \
+ namespace f_ \
+ { \
+ \
+ template <typename L, typename R> \
+ struct OperatorName##_ : public oln_super2_of_(f_::OperatorName##_<L,R>) \
+ { \
+ typedef OperatorName##_<L,R> self_type; \
+ \
+ const oln_fun2_type_of(self_type, res) \
+ impl_binop(const L& left, const R& right) const \
+ { \
+ return left OperatorSymbol right; \
+ } \
+ }; \
+ \
+ } \
+ \
+ typedef f_::binary_meta<f_::OperatorName##_> f_##OperatorName##_type; \
+ static f_##OperatorName##_type f_##OperatorName; \
+ \
+struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
+
+
+
+namespace oln
+{
+
+ oln_decl_funobj_cmp(eq, ==);
+ oln_decl_funobj_cmp(neq, !=);
+
+ oln_decl_funobj_cmp(less, <);
+ oln_decl_funobj_cmp(leq, <=);
+
+ oln_decl_funobj_cmp(greater, >);
+ oln_decl_funobj_cmp(geq, >=);
+
+
+} // end of namespace oln
+
+
+
+#endif // ! OLENA_CORE_FUNOBJ_CMP_HH
Index: oln/core/typedefs.hh
===================================================================
--- oln/core/typedefs.hh (revision 174)
+++ oln/core/typedefs.hh (working copy)
@@ -41,6 +41,13 @@
# define oln_super_of_(Type) \
oln::internal::get_super_type<Type>::ret
+# define oln_super2_of_(Type,_2) \
+oln::internal::get_super_type<Type,_2>::ret
+
+# define oln_super3_of_(Type,_2,_3) \
+oln::internal::get_super_type<Type,_2,_3>::ret
+
+
# define oln_super_of(Type) \
typename oln_super_of_(Type)
@@ -109,6 +116,14 @@
mlc_decl_typedef(coord_type);
+ // category::fun1 and 2
+
+ mlc_decl_typedef(res_type);
+ mlc_decl_typedef(arg_type);
+ mlc_decl_typedef(left_type);
+ mlc_decl_typedef(right_type);
+
+
} // end of namespace oln
Index: oln/core/pw/times.hh
===================================================================
--- oln/core/pw/times.hh (revision 174)
+++ oln/core/pw/times.hh (working copy)
@@ -1,107 +0,0 @@
-// Copyright (C) 2005 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_CORE_PW_TIMES_HH
-# define OLENA_CORE_PW_TIMES_HH
-
-# include <oln/core/pw/abstract/binary_function.hh>
-# include <oln/core/pw/literal.hh>
-# include <ntg/all.hh>
-# include <oln/core/pw/macros.hh>
-
-
-namespace oln {
-
- // fwd decl
- namespace pw {
- template <typename L, typename R> struct times;
- }
-
- // super type
- template <typename L, typename R>
- struct set_super_type < pw::times<L, R> > { typedef pw::abstract::binary_function<L, R, pw::times<L, R> > ret; };
-
- // props
- template <typename L, typename R>
- struct set_props < category::pw, pw::times<L, R> >
- {
- typedef ntg_return_type(times,
- oln_pw_type_of(L, value),
- oln_pw_type_of(R, value)) value_type;
- };
-
-
- namespace pw {
-
- template <typename L, typename R>
- struct times : public abstract::binary_function < L, R, times<L, R> >
- {
- typedef times<L, R> self_type;
-
- typedef oln_pw_type_of(self_type, point) point_type;
- typedef oln_pw_type_of(self_type, value) value_type;
- typedef oln_pw_type_of(self_type, size) size_type;
-
- typedef abstract::binary_function<L, R, self_type> super_type;
-
- times(const abstract::function<L>& left,
- const abstract::function<R>& right) :
- super_type(left, right)
- {
- }
-
- const value_type impl_get(const point_type& p) const
- {
- return this->left(p) * this->right(p);
- }
-
- };
-
-
- } // end of namespace oln::pw
-
-} // end of namespace oln
-
-
-
-/// Operator * on pwf
-
-template <typename L, typename R>
-oln::pw::times<L, R> operator * (const oln::pw::abstract::function<L>& lhs,
- const oln::pw::abstract::function<R>& rhs)
-{
- precondition(lhs.size() == rhs.size());
- oln::pw::times<L, R> tmp(lhs, rhs);
- return tmp;
-}
-
-oln_pw_operator(times, *, int)
-oln_pw_operator(times, *, float)
-oln_pw_operator(times, *, double)
-
-
-#endif // ! OLENA_CORE_PW_TIMES_HH
Index: oln/core/pw/binary_op.hh
===================================================================
--- oln/core/pw/binary_op.hh (revision 0)
+++ oln/core/pw/binary_op.hh (revision 0)
@@ -0,0 +1,94 @@
+// Copyright (C) 2005 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_CORE_PW_BINARY_OP_HH
+# define OLENA_CORE_PW_BINARY_OP_HH
+
+# include <mlc/is_a.hh>
+# include <oln/core/pw/abstract/binary_function.hh>
+# include <oln/funobj/abstract/binary.hh>
+
+
+namespace oln {
+
+
+ // fwd decl
+ namespace pw {
+ template <typename F, typename L, typename R> struct binary_op;
+ }
+
+ // super type
+ template <typename F, typename L, typename R>
+ struct set_super_type < pw::binary_op<F,L,R> > { typedef pw::abstract::binary_function< L, R, pw::binary_op<F,L,R> > ret; };
+
+ // props
+ template <typename F, typename L, typename R>
+ struct set_props < category::pw, pw::binary_op<F,L,R> >
+ {
+ typedef typename f_::binary_meta_result<F,L,R>::ret value_type;
+ };
+
+
+
+ namespace pw {
+
+
+ template <typename F, typename L, typename R>
+ struct binary_op : public abstract::binary_function< L, R, binary_op<F,L,R> >
+ {
+ typedef binary_op<F,L,R> self_type;
+ typedef abstract::binary_function<L,R,self_type> super_type;
+
+ F fun;
+
+ binary_op(const abstract::function<L>& left,
+ const abstract::function<R>& right) :
+ super_type(left, right),
+ fun()
+ {
+ mlc_is_a(F, f_::binary_meta)::ensure();
+ }
+
+ typedef oln_pw_type_of(self_type, point) point_type;
+ typedef oln_pw_type_of(self_type, value) value_type;
+
+ const value_type impl_get(const point_type& p) const
+ {
+ const value_type tmp = this->fun(this->left(p), this->right(p));
+ return tmp;
+ }
+
+ };
+
+
+ } // end of namespace oln::pw
+
+} // end of namespace oln
+
+
+
+#endif // ! OLENA_CORE_PW_BINARY_OP_HH
Index: oln/core/pw/image.hh
===================================================================
--- oln/core/pw/image.hh (revision 174)
+++ oln/core/pw/image.hh (working copy)
@@ -28,12 +28,9 @@
#ifndef OLENA_CORE_PW_IMAGE_HH
# define OLENA_CORE_PW_IMAGE_HH
-# include <mlc/any.hh>
-# include <mlc/cmp.hh>
-# include <oln/core/box.hh>
-# include <oln/core/abstract/image_typeness.hh>
# include <oln/core/abstract/image_entry.hh>
# include <oln/core/pw/abstract/function.hh>
+# include <oln/core/pw/value.hh>
// FIXME: remove
# include <oln/core/2d/grid2d.hh>
@@ -46,85 +43,15 @@
// fwd decl
- namespace pw {
- template <typename I> struct image;
- }
+ template <typename F> class image_from_pwf;
- // super type
- template <typename I>
- struct set_super_type < pw::image<I> > { typedef pw::abstract::function< pw::image<I> > ret; };
-
- // props
- template <typename I>
- struct set_props < category::pw, pw::image<I> >
- {
- typedef oln_type_of(I, point) point_type;
- typedef oln_type_of(I, value) value_type;
- typedef oln_type_of(I, size) size_type;
- };
-
-
- namespace pw { // means "point-wise"
-
- template <typename I>
- struct image : public abstract::function < image<I> >
- {
- oln::box<const I> ima;
-
- image(const oln::abstract::image<I>& ima) :
- ima(ima)
- {
- }
-
- typedef oln_type_of(I, point) point_type;
- typedef oln_type_of(I, value) value_type;
- typedef oln_type_of(I, size) size_type;
-
- const size_type& impl_size() const
- {
- return this->ima.size();
- }
-
- const value_type impl_get(const point_type& p) const
- {
- return this->ima.get(p);
- }
-
- bool impl_hold(const point_type& p) const
- {
- return this->ima.hold(p);
- }
-
- bool impl_hold_large(const point_type& p) const
- {
- return this->ima.hold_large(p);
- }
-
- };
-
- } // end of namespace oln::pw
-
-
- /// Routine that takes an image and outputs a "point value" object
-
- template <typename I>
- pw::image<I> p_value(const abstract::image<I>& ima)
- {
- pw::image<I> tmp(ima);
- return tmp;
- }
-
-
- // fwd decl
- template <typename F> class image_from_pw;
-
// super
template <typename F>
- struct set_super_type < image_from_pw<F> > { typedef abstract::image_entry< image_from_pw<F> > ret; };
+ struct set_super_type < image_from_pwf<F> > { typedef abstract::image_entry< image_from_pwf<F> > ret; };
// props
template <typename F>
- struct set_props < category::image, image_from_pw<F> >
+ struct set_props < category::image, image_from_pwf<F> >
{
typedef oln_pw_type_of(F, point) point_type;
typedef oln_pw_type_of(F, value) value_type;
@@ -143,22 +70,22 @@
};
- /// Class image_from_pw<F>.
+ /// Class image_from_pwf<F>.
template <typename F>
- struct image_from_pw : public abstract::image_entry< image_from_pw<F> >
+ struct image_from_pwf : public abstract::image_entry< image_from_pwf<F> >
{
- typedef image_from_pw<F> self_type;
+ typedef image_from_pwf<F> self_type;
F fun;
- image_from_pw(const pw::abstract::function<F>& fun) :
+ image_from_pwf(const pw::abstract::function<F>& fun) :
fun(fun.exact())
{
this->exact_ptr = this;
}
- image_from_pw(const self_type& rhs) :
+ image_from_pwf(const self_type& rhs) :
fun(rhs.fun)
{
this->exact_ptr = this;
@@ -200,85 +127,48 @@
};
+
/// Routine image_for_all_p.
template <typename F>
- image_from_pw<F> image_for_all_p(const pw::abstract::function<F>& fun)
+ image_from_pwf<F> image_for_all_p(const pw::abstract::function<F>& fun)
{
- image_from_pw<F> tmp(fun);
+ image_from_pwf<F> tmp(fun);
return tmp;
}
- // FIXME: below, produce an error instead of correcting the client code (?)
+ /// Specialization of image_for_all_p (so that "image_for_all_p(pw_value(ima)) == ima").
- /// Specialization of image_for_all_p (so that "image_for_all_p(p_value(ima)) == ima").
-
template <typename I>
- const I& image_for_all_p(const pw::image<I>& pv)
+ const I& image_for_all_p(const pw::value<I>& pwv)
{
- return pv.ima.unbox();
+ return pwv.ima.unbox();
}
- /// Specialization of p_value (so that "p_value(image_for_all_p(fun)) == fun").
- template <typename F>
- F p_value(const image_from_pw<F>& ima)
- {
- return ima.fun;
- }
+ /// Specializations of image_for_all_p to produce compile-time errors.
+ // FIXME: struct OLENA_ERROR__arg_of__image_for_all_p__should_be_a_point_wise_function();
+ template <typename I>
+ void image_for_all_p(const abstract::image<I>&)
+ {}
+ template <typename P>
+ void image_for_all_p(const abstract::point<P>&)
+ {}
+ /// Specialization of pw_value (so that "pw_value(image_for_all_p(fun)) == fun").
-
- /// Routine check.
-
- template <typename I>
- bool check(const abstract::binary_image<I>& pred)
+ template <typename F>
+ F pw_value(const image_from_pwf<F>& ima)
{
- oln_type_of(I, fwd_piter) p(pred.size());
- for_all_p (p)
- if (! pred[p])
- return false;
- return true;
+ F tmp = ima.fun;
+ return tmp;
}
- namespace pw {
- /// Routine oln::pw::check.
-
- template <typename F>
- bool check(const pw::abstract::function<F>& pred)
- {
- mlc::eq< oln_typeness_of(oln_pw_type_of(F, value)), typeness::binary_tag >::ensure();
- return oln::check(image_for_all_p(pred));
- }
-
- } // end of namespace oln::pw
-
-
-
- // FIXME: Does not work with g++-3.4.
- /// Specialization of image_for_all_p that gives a compile-time error.
-
-// template <typename I>
-// void image_for_all_p(const abstract::image<I>&)
-// {
-// struct OLENA_ERROR__arg_of__image_for_all_p__should_not_be_an_image();
-// }
-
-// /// Specialization of image_for_all_p that gives a compile-time error.
-
-// template <typename P>
-// void image_for_all_p(const abstract::point<P>&)
-// {
-// struct OLENA_ERROR__arg_of__image_for_all_p__should_not_be_a_point();
-// }
-
-
-
} // end of namespace oln
Index: oln/core/pw/div.hh
===================================================================
--- oln/core/pw/div.hh (revision 174)
+++ oln/core/pw/div.hh (working copy)
@@ -1,109 +0,0 @@
-// Copyright (C) 2005 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_CORE_PW_DIV_HH
-# define OLENA_CORE_PW_DIV_HH
-
-# include <oln/core/pw/abstract/binary_function.hh>
-# include <oln/core/pw/literal.hh>
-# include <ntg/all.hh>
-# include <oln/core/pw/macros.hh>
-
-
-namespace oln {
-
- // fwd decl
- namespace pw {
- template <typename L, typename R> struct div;
- }
-
- // super type
- template <typename L, typename R>
- struct set_super_type < pw::div<L, R> > { typedef pw::abstract::binary_function<L, R, pw::div<L, R> > ret; };
-
- // props
- template <typename L, typename R>
- struct set_props < category::pw, pw::div<L, R> >
- {
- typedef ntg_return_type(div,
- oln_pw_type_of(L, value),
- oln_pw_type_of(R, value)) value_type;
- };
-
-
- namespace pw {
-
- template <typename L, typename R>
- struct div : public abstract::binary_function < L, R, div<L, R> >
- {
- typedef div<L, R> self_type;
-
- typedef oln_pw_type_of(self_type, point) point_type;
- typedef oln_pw_type_of(self_type, value) value_type;
- typedef oln_pw_type_of(self_type, size) size_type;
-
- typedef abstract::binary_function<L, R, self_type> super_type;
-
- div(const abstract::function<L>& left,
- const abstract::function<R>& right) :
- super_type(left, right)
- {
- }
-
- const value_type impl_get(const point_type& p) const
- {
- precondition(this->right(p) != 0);
- return this->left(p) / this->right(p);
- }
-
- };
-
-
- } // end of namespace oln::pw
-
-} // end of namespace oln
-
-
-
-/// Operator / on pwf
-
-template <typename L, typename R>
-oln::pw::div<L, R> operator / (const oln::pw::abstract::function<L>& lhs,
- const oln::pw::abstract::function<R>& rhs)
-{
- precondition(lhs.size() == rhs.size());
- oln::pw::div<L, R> tmp(lhs, rhs);
- return tmp;
-}
-
-
-oln_pw_operator(div, /, int)
-oln_pw_operator(div, /, float)
-oln_pw_operator(div, /, double)
-
-
-#endif // ! OLENA_CORE_PW_DIV_HH
Index: oln/core/pw/plus.hh
===================================================================
--- oln/core/pw/plus.hh (revision 174)
+++ oln/core/pw/plus.hh (working copy)
@@ -1,107 +0,0 @@
-// Copyright (C) 2005 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_CORE_PW_PLUS_HH
-# define OLENA_CORE_PW_PLUS_HH
-
-# include <oln/core/pw/abstract/binary_function.hh>
-# include <oln/core/pw/literal.hh>
-# include <oln/core/pw/macros.hh>
-# include <ntg/all.hh>
-
-
-namespace oln {
-
- // fwd decl
- namespace pw {
- template <typename L, typename R> struct plus;
- }
-
- // super type
- template <typename L, typename R>
- struct set_super_type < pw::plus<L, R> > { typedef pw::abstract::binary_function<L, R, pw::plus<L, R> > ret; };
-
- // props
- template <typename L, typename R>
- struct set_props < category::pw, pw::plus<L, R> >
- {
- typedef ntg_return_type(plus,
- oln_pw_type_of(L, value),
- oln_pw_type_of(R, value)) value_type;
- };
-
-
- namespace pw {
-
- template <typename L, typename R>
- struct plus : public abstract::binary_function < L, R, plus<L, R> >
- {
- typedef plus<L, R> self_type;
-
- typedef oln_pw_type_of(self_type, point) point_type;
- typedef oln_pw_type_of(self_type, value) value_type;
- typedef oln_pw_type_of(self_type, size) size_type;
-
- typedef abstract::binary_function<L, R, self_type> super_type;
-
- plus(const abstract::function<L>& left,
- const abstract::function<R>& right) :
- super_type(left, right)
- {
- }
-
- const value_type impl_get(const point_type& p) const
- {
- return this->left(p) + this->right(p);
- }
-
- };
-
-
- } // end of namespace oln::pw
-
-} // end of namespace oln
-
-
-
-/// Operator + on pwf
-
-template <typename L, typename R>
-oln::pw::plus<L, R> operator + (const oln::pw::abstract::function<L>& lhs,
- const oln::pw::abstract::function<R>& rhs)
-{
- precondition(lhs.size() == rhs.size());
- oln::pw::plus<L, R> tmp(lhs, rhs);
- return tmp;
-}
-
-oln_pw_operator(plus, +, int)
-oln_pw_operator(plus, +, float)
-oln_pw_operator(plus, +, double)
-
-
-#endif // ! OLENA_CORE_PW_PLUS_HH
Index: oln/core/pw/macros.hh
===================================================================
--- oln/core/pw/macros.hh (revision 174)
+++ oln/core/pw/macros.hh (working copy)
@@ -28,53 +28,60 @@
#ifndef OLENA_CORE_PW_MACROS_HH
# define OLENA_CORE_PW_MACROS_HH
+# include <oln/core/pw/unary_op.hh>
+# include <oln/core/pw/binary_op.hh>
+# include <oln/core/pw/literal.hh>
-// FIXME: rename?
-# define oln_pw_operator(NAME, SYMBOL, TYPE) \
-template <typename L> \
-oln::pw::NAME<L, oln::pw::literal<TYPE> > \
-operator SYMBOL (const oln::pw::abstract::function<L>& lhs, \
- const TYPE& value) \
-{ \
- return lhs SYMBOL oln::pw::literal<TYPE>(value); \
-} \
-template <typename R> \
-oln::pw::NAME<oln::pw::literal<TYPE>, R> \
-operator SYMBOL (const TYPE& value, \
- const oln::pw::abstract::function<R>& rhs) \
-{ \
- return oln::pw::literal<TYPE>(value) SYMBOL rhs; \
-}
+# define oln_pw_decl_binary(OperatorName, OperatorSymbol) \
+ \
+template <typename L, typename R> \
+const oln::pw::binary_op< oln::f_##OperatorName##_type, \
+ L, R > \
+operator OperatorSymbol (const oln::pw::abstract::function<L>& lhs, \
+ const oln::pw::abstract::function<R>& rhs) \
+{ \
+ precondition(lhs.size() == rhs.size()); \
+ oln::pw::binary_op< oln::f_##OperatorName##_type, \
+ L, R > tmp(lhs, rhs); \
+ return tmp; \
+} \
+ \
+struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
-// FIXME: rename?
-# define oln_pw_cmp_operator(NAME, SYMBOL, TYPE) \
-template <typename L> \
-oln::pw::cmp<L, oln::pw::literal<TYPE>, oln::pw::internal::NAME> \
-operator SYMBOL (const oln::pw::abstract::function<L>& lhs, \
- const TYPE& value) \
-{ \
- return lhs SYMBOL oln::pw::literal<TYPE>(value); \
-} \
-template <typename R> \
-oln::pw::cmp<oln::pw::literal<TYPE>, R, oln::pw::internal::NAME> \
-operator SYMBOL (const TYPE& value, \
- const oln::pw::abstract::function<R>& rhs) \
-{ \
- return oln::pw::literal<TYPE>(value) SYMBOL rhs; \
-}
+# define oln_pw_decl_binary_with_lit(OperatorName, OperatorSymbol, LiteralType) \
+ \
+template <typename L> \
+const oln::pw::binary_op< oln::f_##OperatorName##_type, \
+ L, oln::pw::literal<LiteralType> > \
+operator OperatorSymbol (const oln::pw::abstract::function<L>& lhs, \
+ const LiteralType& rhs) \
+{ \
+ precondition(lhs.size() == rhs.size()); \
+ oln::pw::binary_op< oln::f_##OperatorName##_type, \
+ L, oln::pw::literal<LiteralType> > tmp(lhs, rhs); \
+ return tmp; \
+} \
+ \
+template <typename R> \
+const oln::pw::binary_op< oln::f_##OperatorName##_type, \
+ oln::pw::literal<LiteralType>, R > \
+operator OperatorSymbol (const LiteralType& lhs, \
+ const oln::pw::abstract::function<R>& rhs) \
+{ \
+ precondition(lhs.size() == rhs.size()); \
+ oln::pw::binary_op< oln::f_##OperatorName##_type, \
+ oln::pw::literal<LiteralType>, R > tmp(lhs, rhs); \
+ return tmp; \
+} \
+ \
+struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
-// FIXME: rename?
-# define oln_pw_cmp_operators(TYPE) \
-oln_pw_cmp_operator(eq, ==, TYPE) \
-oln_pw_cmp_operator(neq, !=, TYPE) \
-oln_pw_cmp_operator(geq, >=, TYPE) \
-oln_pw_cmp_operator(leq, <=, TYPE) \
-oln_pw_cmp_operator(g, >, TYPE) \
-oln_pw_cmp_operator(l, <, TYPE)
+
+
#endif // ! OLENA_CORE_PW_MACROS_HH
Index: oln/core/pw/apply.hh
===================================================================
--- oln/core/pw/apply.hh (revision 174)
+++ oln/core/pw/apply.hh (working copy)
@@ -78,15 +78,15 @@
F f_;
apply1(const mlc::abstract::unary_function<F>& f,
- const abstract::function<T>& input) :
- super_type(input),
+ const abstract::function<T>& arg) :
+ super_type(arg),
f_(f.exact())
{
}
const value_type impl_get(const point_type& p) const
{
- return f_(this->input(p));
+ return f_(this->arg(p));
}
};
Index: oln/core/pw/minus.hh
===================================================================
--- oln/core/pw/minus.hh (revision 174)
+++ oln/core/pw/minus.hh (working copy)
@@ -1,123 +0,0 @@
-// Copyright (C) 2005 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_CORE_PW_MINUS_HH
-# define OLENA_CORE_PW_MINUS_HH
-
-# include <oln/core/pw/abstract/binary_function.hh>
-# include <oln/core/pw/literal.hh>
-# include <ntg/all.hh>
-# include <oln/core/pw/macros.hh>
-
-
-namespace oln {
-
- // fwd decl
- namespace pw {
- template <typename L, typename R> struct minus;
- }
-
- // super type
- template <typename L, typename R>
- struct set_super_type < pw::minus<L, R> > { typedef pw::abstract::binary_function<L, R, pw::minus<L, R> > ret; };
-
- // props
- template <typename L, typename R>
- struct set_props < category::pw, pw::minus<L, R> >
- {
- typedef ntg_return_type(minus,
- oln_pw_type_of(L, value),
- oln_pw_type_of(R, value)) value_type;
- };
-
-
- namespace pw {
-
- template <typename L, typename R>
- struct minus : public abstract::binary_function < L, R, minus<L, R> >
- {
- typedef minus<L, R> self_type;
-
- typedef oln_pw_type_of(self_type, point) point_type;
- typedef oln_pw_type_of(self_type, value) value_type;
- typedef oln_pw_type_of(self_type, size) size_type;
-
- typedef abstract::binary_function<L, R, self_type > super_type;
-
- minus(const abstract::function<L>& left,
- const abstract::function<R>& right) :
- super_type(left, right)
- {
- }
-
- const value_type impl_get(const point_type& p) const
- {
- return this->left(p) - this->right(p);
- }
-
- };
-
-
- // impl of abstract::function<E>::operator-()
-
- namespace abstract {
-
- template <typename E>
- minus<literal<oln_pw_type_of(E, value)>, E>
- function<E>::operator-() const
- {
- typedef literal<oln_pw_type_of(E, value)> lit_type;
- static const lit_type lhs = 0;
- minus< lit_type, E> tmp(lhs, this->exact());
- return tmp;
- }
-
- } // end of namespace oln::pw::abstract
-
-
- } // end of namespace oln::pw
-
-} // end of namespace oln
-
-
-/// Operator - on pwf
-
-template <typename L, typename R>
-oln::pw::minus<L, R> operator - (const oln::pw::abstract::function<L>& lhs,
- const oln::pw::abstract::function<R>& rhs)
-{
- precondition(lhs.size() == rhs.size());
- oln::pw::minus<L, R> tmp(lhs, rhs);
- return tmp;
-}
-
-oln_pw_operator(minus, -, int)
-oln_pw_operator(minus, -, float)
-oln_pw_operator(minus, -, double)
-
-
-#endif // ! OLENA_CORE_PW_MINUS_HH
Index: oln/core/pw/unary_op.hh
===================================================================
--- oln/core/pw/unary_op.hh (revision 0)
+++ oln/core/pw/unary_op.hh (revision 0)
@@ -0,0 +1,91 @@
+// Copyright (C) 2005 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_CORE_PW_UNARY_OP_HH
+# define OLENA_CORE_PW_UNARY_OP_HH
+
+# include <mlc/is_a.hh>
+# include <oln/core/pw/abstract/unary_function.hh>
+# include <oln/funobj/abstract/unary.hh>
+
+
+
+namespace oln {
+
+
+ // fwd decl
+ namespace pw {
+ template <typename F, typename A> struct unary_op;
+ }
+
+ // super type
+ template <typename F, typename A>
+ struct set_super_type < pw::unary_op<F,A> > { typedef pw::abstract::unary_function< A, pw::unary_op<F,A> > ret; };
+
+ // props
+ template <typename F, typename A>
+ struct set_props < category::pw, pw::unary_op<F,A> >
+ {
+ typedef typename f_::unary_meta_result<F,A>::ret value_type;
+ };
+
+
+ namespace pw {
+
+ template <typename F, typename A>
+ struct unary_op : public abstract::unary_function< A, pw::unary_op<F,A> >
+ {
+ typedef unary_op<F,A> self_type;
+ typedef abstract::unary_function<A,self_type> super_type;
+
+ F fun;
+
+ unary_op(const abstract::function<A>& arg) :
+ super_type(arg),
+ fun()
+ {
+ mlc_is_a(F, f_::unary_meta)::ensure();
+ }
+
+ typedef oln_pw_type_of(self_type, point) point_type;
+ typedef oln_pw_type_of(self_type, value) value_type;
+
+ const value_type impl_get(const point_type& p) const
+ {
+ const value_type tmp = this->fun(this->arg(p));
+ return tmp;
+ }
+
+ };
+
+
+ } // end of namespace oln::pw
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_PW_UNARY_OP_HH
Index: oln/core/pw/literal.hh
===================================================================
--- oln/core/pw/literal.hh (revision 174)
+++ oln/core/pw/literal.hh (working copy)
@@ -96,13 +96,17 @@
/// Routine that takes a literal and outputs a "point-wise literal" object
template <typename T>
- pw::literal<T> p_lit(const T& value)
+ pw::literal<T> p_literal(const T& value)
{
pw::literal<T> tmp(value);
return tmp;
}
+ // FIXME: Specializations of p_literal to produce compile-time errors.
+ // ...
+
+
} // end of namespace oln
Index: oln/core/pw/logic.hh
===================================================================
--- oln/core/pw/logic.hh (revision 174)
+++ oln/core/pw/logic.hh (working copy)
@@ -28,157 +28,46 @@
#ifndef OLENA_CORE_PW_LOGIC_HH
# define OLENA_CORE_PW_LOGIC_HH
-# include <oln/core/abstract/image_typeness.hh>
-# include <oln/core/pw/abstract/function.hh>
-# include <oln/core/pw/cmp.hh>
+# include <oln/funobj/logic.hh>
+# include <oln/core/pw/macros.hh>
-namespace oln {
+oln_pw_decl_binary(and, and);
+oln_pw_decl_binary(or, or);
+oln_pw_decl_binary(xor, xor);
+// FIXME: not?
- namespace pw {
- // FIXME: move somewhere else
- namespace internal
- {
- struct not_ {
- template <typename T>
- bool operator()(const T& rhs) const {
- return !rhs;
- }
- };
- struct and_ {
- template <typename L, typename R>
- bool operator()(const L& lhs, const R& rhs) const {
- return lhs && rhs;
- }
- };
- struct nand_ {
- template <typename L, typename R>
- bool operator()(const L& lhs, const R& rhs) const {
- return !(lhs && rhs);
- }
- };
- struct or_ {
- template <typename L, typename R>
- bool operator()(const L& lhs, const R& rhs) const {
- return lhs || rhs;
- }
- };
- struct nor_ {
- template <typename L, typename R>
- bool operator()(const L& lhs, const R& rhs) const {
- return !(lhs || rhs);
- }
- };
- struct xor_ {
- template <typename L, typename R>
- bool operator()(const L& lhs, const R& rhs) const {
- return (lhs && !rhs) || (!lhs && rhs);
- }
- };
- struct xnor_ {
- template <typename L, typename R>
- bool operator()(const L& lhs, const R& rhs) const {
- return (lhs && rhs) || (!lhs && !rhs);
- }
- };
- } // end of oln::pw::internal
+# define oln_pw_decl_logic_lit(LiteralType) \
+ \
+oln_pw_decl_binary_with_lit(and, and, LiteralType); \
+oln_pw_decl_binary_with_lit(or, or, LiteralType); \
+oln_pw_decl_binary_with_lit(xor, xor, LiteralType); \
+ \
+struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
- } // end of namespace oln::pw
- // fwd decl
- namespace pw {
- template <typename R> struct not_;
- }
+namespace ntg {
+ struct bin;
+}
- // super type
- template <typename R>
- struct set_super_type < pw::not_<R> > { typedef pw::abstract::function < pw::not_<R> > ret; };
+oln_pw_decl_logic_lit(bool);
+oln_pw_decl_logic_lit(ntg::bin);
- // props
- template <typename R>
- struct set_props < category::pw, pw::not_<R> >
- {
- typedef oln_pw_type_of(R, point) point_type;
- typedef oln_pw_type_of(R, size) size_type;
- typedef bool value_type;
- };
- namespace pw
- {
- template <typename R>
- struct not_ : public abstract::function < not_<R> >
- {
- typedef not_<R> self_type;
+// template <typename E>
+// not_<E>
+// function<E>::operator!() const
+// {
+// mlc::eq< oln_typeness_of(oln_pw_type_of(E, value)), typeness::binary_tag >::ensure();
+// not_<E> tmp(this->exact());
+// return tmp;
+// }
- typedef oln_pw_type_of(R, point) point_type;
- typedef oln_pw_type_of(R, size) size_type;
- typedef oln_pw_type_of(R, value) value_type;
- R right;
- not_(const abstract::function<R>& right) :
- right(right.exact())
- {
- }
-
- const bool impl_get(const point_type& p) const
- {
- return ! this->right(p);
- }
-
- const size_type& impl_size() const
- {
- return this->right.size();
- }
-
- bool impl_hold(const point_type& p) const
- {
- return this->right.hold(p);
- }
-
- bool impl_hold_large(const point_type& p) const
- {
- return this->right.hold_large(p);
- }
-
- };
-
-
- // impl of abstract::function<E>::operator!()
-
- namespace abstract {
-
- template <typename E>
- not_<E>
- function<E>::operator!() const
- {
- mlc::eq< oln_typeness_of(oln_pw_type_of(E, value)), typeness::binary_tag >::ensure();
- not_<E> tmp(this->exact());
- return tmp;
- }
-
- } // end of namespace oln::pw::abstract
-
-
- } // end of namespace oln::pw
-
-
-} // end of namespace oln
-
-
-
-/// Ops on pwf
-
-oln_pw_decl_cmp_op(and_, &&)
-oln_pw_decl_cmp_op(or_, ||)
-
-oln_pw_cmp_operator(and_, &&, bool)
-oln_pw_cmp_operator(or_, ||, bool)
-
-
#endif // ! OLENA_CORE_PW_LOGIC_HH
Index: oln/core/pw/abstract/unary_function.hh
===================================================================
--- oln/core/pw/abstract/unary_function.hh (revision 174)
+++ oln/core/pw/abstract/unary_function.hh (working copy)
@@ -40,20 +40,20 @@
// fwd decl
namespace pw {
namespace abstract {
- template <typename T, typename E> struct unary_function;
+ template <typename A, typename E> struct unary_function;
}
}
// super type
- template <typename T, typename E>
- struct set_super_type < pw::abstract::unary_function<T, E> > { typedef pw::abstract::function<E> ret; };
+ template <typename A, typename E>
+ struct set_super_type < pw::abstract::unary_function<A, E> > { typedef pw::abstract::function<E> ret; };
// props
- template <typename T, typename E>
- struct set_props < category::pw, pw::abstract::unary_function<T, E> >
+ template <typename A, typename E>
+ struct set_props < category::pw, pw::abstract::unary_function<A, E> >
{
- typedef oln_pw_type_of(T, point) point_type;
- typedef oln_pw_type_of(T, size) size_type;
+ typedef oln_pw_type_of(A, point) point_type;
+ typedef oln_pw_type_of(A, size) size_type;
};
@@ -61,15 +61,15 @@
namespace abstract {
- template <typename T, typename E>
+ template <typename A, typename E>
struct unary_function : public function<E>
{
- typedef T input_type;
+ typedef A arg_type;
- T input;
+ A arg;
- unary_function(const abstract::function<T>& input) :
- input(input.exact())
+ unary_function(const abstract::function<A>& arg) :
+ arg(arg.exact())
{
}
@@ -78,17 +78,17 @@
const size_type& impl_size() const
{
- return input.size();
+ return arg.size();
}
bool impl_hold(const point_type& p) const
{
- return input.hold(p);
+ return arg.hold(p);
}
bool impl_hold_large(const point_type& p) const
{
- return input.hold_large(p);
+ return arg.hold_large(p);
}
protected:
Index: oln/core/pw/abstract/function.hh
===================================================================
--- oln/core/pw/abstract/function.hh (revision 174)
+++ oln/core/pw/abstract/function.hh (working copy)
@@ -71,6 +71,13 @@
<< "\t size_type = " << mlc_to_string(size_type) << std::endl
<< "}" << std::endl;
}
+
+ static void ensure()
+ {
+ mlc::is_ok< point_type >::ensure();
+ mlc::is_ok< value_type >::ensure();
+ mlc::is_ok< size_type >::ensure();
+ }
};
@@ -80,9 +87,10 @@
namespace abstract {
template <typename E> struct function;
}
- template <typename L, typename R> struct minus;
template <typename T> struct literal;
- template <typename F> struct not_;
+ // FIXME:...
+// template <typename L, typename R> struct minus;
+// template <typename F> struct not_;
namespace abstract {
@@ -114,34 +122,23 @@
return this->exact().impl_hold_large(p);
}
- minus<literal<value_type>, E> operator-() const;
- not_<E> operator!() const;
+ // FIXME:...
+// minus<literal<value_type>, E> operator-() const;
+// not_<E> operator!() const;
protected:
- function() {}
+ function()
+ {}
+
~function()
{
- { // impl_size
- typedef const size_type& (E::*meth)() const;
- meth adr = &E::impl_size;
- adr = 0;
- }
- { // impl_get
- typedef const value_type (E::*meth)(const point_type&) const;
- meth adr = &E::impl_get;
- adr = 0;
- }
- { // impl_hold
- typedef bool (E::*meth)(const point_type&) const;
- meth adr = &E::impl_hold;
- adr = 0;
- }
- { // impl_hold_large
- typedef bool (E::*meth)(const point_type&) const;
- meth adr = &E::impl_hold_large;
- adr = 0;
- }
+ get_props<category::pw, E>::ensure();
+
+ mlc_check_method_impl(E, const size_type&, size, , const);
+ mlc_check_method_impl(E, const value_type, get, const point_type&, const);
+ mlc_check_method_impl(E, bool, hold, const point_type&, const);
+ mlc_check_method_impl(E, bool, hold_large, const point_type&, const);
}
};
Index: oln/core/pw/arith.hh
===================================================================
--- oln/core/pw/arith.hh (revision 0)
+++ oln/core/pw/arith.hh (revision 0)
@@ -0,0 +1,60 @@
+// Copyright (C) 2005 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_CORE_PW_ARITH_HH
+# define OLENA_CORE_PW_ARITH_HH
+
+# include <oln/funobj/arith.hh>
+# include <oln/core/pw/macros.hh>
+
+
+oln_pw_decl_binary( plus, + );
+oln_pw_decl_binary( minus, - );
+oln_pw_decl_binary( times, * );
+oln_pw_decl_binary( div, / );
+oln_pw_decl_binary( mod, % );
+
+// FIXME: uminus?
+
+
+# define oln_pw_decl_arith_lit(LiteralType) \
+ \
+oln_pw_decl_binary_with_lit( plus, +, LiteralType); \
+oln_pw_decl_binary_with_lit( minus, -, LiteralType); \
+oln_pw_decl_binary_with_lit( times, +, LiteralType); \
+oln_pw_decl_binary_with_lit( div, /, LiteralType); \
+oln_pw_decl_binary_with_lit( mod, %, LiteralType); \
+ \
+struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
+
+
+oln_pw_decl_arith_lit(int);
+oln_pw_decl_arith_lit(float);
+oln_pw_decl_arith_lit(double);
+
+
+#endif // ! OLENA_CORE_PW_ARITH_HH
Index: oln/core/pw/all.hh
===================================================================
--- oln/core/pw/all.hh (revision 174)
+++ oln/core/pw/all.hh (working copy)
@@ -29,19 +29,17 @@
# define OLENA_CORE_PW_ALL_HH
-# include <oln/core/pw/abstract/function.hh>
+# include <oln/core/pw/value.hh>
# include <oln/core/pw/image.hh>
# include <oln/core/pw/literal.hh>
+// FIXME: # include <oln/core/pw/ternary.hh>
# include <oln/core/pw/cmp.hh>
+# include <oln/core/pw/arith.hh>
# include <oln/core/pw/logic.hh>
-# include <oln/core/pw/plus.hh>
-# include <oln/core/pw/minus.hh>
-# include <oln/core/pw/times.hh>
-# include <oln/core/pw/div.hh>
+# include <oln/core/pw/check.hh>
+# include <oln/core/pw/apply.hh>
-// FIXME: xor mod...
-
#endif // ! OLENA_CORE_PW_ALL_HH
Index: oln/core/pw/value.hh
===================================================================
--- oln/core/pw/value.hh (revision 0)
+++ oln/core/pw/value.hh (revision 0)
@@ -0,0 +1,123 @@
+// Copyright (C) 2005 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_CORE_PW_VALUE_HH
+# define OLENA_CORE_PW_VALUE_HH
+
+# include <oln/core/box.hh>
+# include <oln/core/abstract/point.hh>
+# include <oln/core/pw/abstract/function.hh>
+
+
+namespace oln {
+
+
+ // fwd decl
+ namespace pw {
+ template <typename I> struct value;
+ }
+
+ // super type
+ template <typename I>
+ struct set_super_type < pw::value<I> > { typedef pw::abstract::function< pw::value<I> > ret; };
+
+ // props
+ template <typename I>
+ struct set_props < category::pw, pw::value<I> >
+ {
+ typedef oln_type_of(I, point) point_type;
+ typedef oln_type_of(I, value) value_type;
+ typedef oln_type_of(I, size) size_type;
+ };
+
+
+ namespace pw { // means "point-wise"
+
+ template <typename I>
+ struct value : public abstract::function < value<I> >
+ {
+ oln::box<const I> ima;
+
+ value(const oln::abstract::image<I>& ima) :
+ ima(ima)
+ {
+ }
+
+ typedef oln_type_of(I, point) point_type;
+ typedef oln_type_of(I, value) value_type;
+ typedef oln_type_of(I, size) size_type;
+
+ const size_type& impl_size() const
+ {
+ return this->ima.size();
+ }
+
+ const value_type impl_get(const point_type& p) const
+ {
+ return this->ima.get(p);
+ }
+
+ bool impl_hold(const point_type& p) const
+ {
+ return this->ima.hold(p);
+ }
+
+ bool impl_hold_large(const point_type& p) const
+ {
+ return this->ima.hold_large(p);
+ }
+
+ };
+
+ } // end of namespace oln::pw
+
+
+ /// Routine that takes an image and outputs a "point value" object
+
+ template <typename I>
+ pw::value<I> pw_value(const abstract::image<I>& ima)
+ {
+ pw::value<I> tmp(ima);
+ return tmp;
+ }
+
+
+ /// Specializations of pw_value to produce compile-time errors.
+ // FIXME: struct OLENA_ERROR__arg_of__pw_value__should_be_a_image();
+
+ template <typename P>
+ void pw_value(const abstract::point<P>&)
+ {}
+
+ // FIXME: add abstract::piter, etc.
+
+
+} // end of namespace oln
+
+
+
+#endif // ! OLENA_CORE_PW_VALUE_HH
Index: oln/core/pw/check.hh
===================================================================
--- oln/core/pw/check.hh (revision 0)
+++ oln/core/pw/check.hh (revision 0)
@@ -0,0 +1,60 @@
+// Copyright (C) 2005 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_CORE_PW_CHECK_HH
+# define OLENA_CORE_PW_CHECK_HH
+
+# include <mlc/cmp.hh>
+# include <oln/core/abstract/image_typeness.hh>
+# include <oln/core/pw/image.hh>
+
+
+namespace oln {
+
+ namespace pw {
+
+
+ template <typename F>
+ bool check(const abstract::function<F>& pred)
+ {
+ mlc::eq< oln_typeness_of(oln_pw_type_of(F, value)), typeness::binary_tag >::ensure();
+ typedef image_from_pwf<F> I;
+ I ima(pred);
+ oln_type_of(I, fwd_piter) p(ima.size());
+ for_all_p (p)
+ if (not ima[p])
+ return false;
+ return true;
+ }
+
+
+ } // end of namespace oln::pw
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_PW_CHECK_HH
Index: oln/core/pw/cmp.hh
===================================================================
--- oln/core/pw/cmp.hh (revision 174)
+++ oln/core/pw/cmp.hh (working copy)
@@ -28,140 +28,35 @@
#ifndef OLENA_CORE_PW_CMP_HH
# define OLENA_CORE_PW_CMP_HH
-# include <oln/core/pw/abstract/binary_function.hh>
+# include <oln/funobj/cmp.hh>
# include <oln/core/pw/macros.hh>
-namespace oln {
+oln_pw_decl_binary( eq, == );
+oln_pw_decl_binary( neq, != );
+oln_pw_decl_binary( less, < );
+oln_pw_decl_binary( leq, <= );
+oln_pw_decl_binary( greater, > );
+oln_pw_decl_binary( geq, >= );
- namespace pw {
+# define oln_pw_decl_cmp_lit(LiteralType) \
+ \
+oln_pw_decl_binary_with_lit( eq, ==, LiteralType); \
+oln_pw_decl_binary_with_lit( neq, !=, LiteralType); \
+oln_pw_decl_binary_with_lit( less, < , LiteralType); \
+oln_pw_decl_binary_with_lit( leq, <=, LiteralType); \
+oln_pw_decl_binary_with_lit( greater, > , LiteralType); \
+oln_pw_decl_binary_with_lit( geq, >=, LiteralType); \
+ \
+struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
- // FIXME: move somewhere else
- namespace internal
- {
- struct eq {
- template <typename L, typename R>
- bool operator()(const L& lhs, const R& rhs) const {
- return lhs == rhs;
- }
- };
- struct neq {
- template <typename L, typename R>
- bool operator()(const L& lhs, const R& rhs) const {
- return lhs != rhs;
- }
- };
- struct geq {
- template <typename L, typename R>
- bool operator()(const L& lhs, const R& rhs) const {
- return lhs >= rhs;
- }
- };
- struct leq {
- template <typename L, typename R>
- bool operator()(const L& lhs, const R& rhs) const {
- return lhs <= rhs;
- }
- };
- struct g {
- template <typename L, typename R>
- bool operator()(const L& lhs, const R& rhs) const {
- return lhs > rhs;
- }
- };
- struct l {
- template <typename L, typename R>
- bool operator()(const L& lhs, const R& rhs) const {
- return lhs < rhs;
- }
- };
- } // end of oln::pw::internal
+oln_pw_decl_cmp_lit(int);
+oln_pw_decl_cmp_lit(float);
+oln_pw_decl_cmp_lit(double);
- } // end of namespace pw
-
- // fwd decl
- namespace pw {
- template <typename L, typename R, typename C> struct cmp;
- }
-
- // super type
- template <typename L, typename R, typename C>
- struct set_super_type < pw::cmp<L, R, C> > { typedef pw::abstract::binary_function<L, R, pw::cmp<L, R, C> > ret; };
-
- // props
- template <typename L, typename R, typename C>
- struct set_props < category::pw, pw::cmp<L, R, C> >
- {
- typedef bool value_type;
- };
-
-
-
-
- namespace pw
- {
-
- template <typename L, typename R, typename C>
- struct cmp : public abstract::binary_function < L, R, cmp<L, R, C> >
- {
- typedef cmp<L, R, C> self_type;
-
- typedef oln_pw_type_of(self_type, point) point_type;
- typedef oln_pw_type_of(self_type, value) value_type;
- typedef oln_pw_type_of(self_type, size) size_type;
-
- typedef abstract::binary_function<L, R, self_type> super_type;
-
- cmp(const abstract::function<L>& left,
- const abstract::function<R>& right) :
- super_type(left, right)
- {
- }
-
- const bool impl_get(const point_type& p) const
- {
- static const C cmpfun = C();
- return cmpfun(this->left(p), this->right(p));
- }
-
- };
-
- } // end of namespace oln::pw
-
-
-} // end of namespace oln
-
-
-
-/// Ops on pwf
-
-# define oln_pw_decl_cmp_op(NAME, SYMBOL) \
-template <typename L, typename R> \
-oln::pw::cmp<L, R, oln::pw::internal:: NAME > \
-operator SYMBOL (const oln::pw::abstract::function<L>& lhs, \
- const oln::pw::abstract::function<R>& rhs) \
-{ \
- precondition(lhs.size() == rhs.size()); \
- oln::pw::cmp<L, R, oln::pw::internal:: NAME > tmp(lhs, rhs); \
- return tmp; \
-}
-
-oln_pw_decl_cmp_op(eq, ==)
-oln_pw_decl_cmp_op(neq, !=)
-oln_pw_decl_cmp_op(geq, >=)
-oln_pw_decl_cmp_op(leq, <=)
-oln_pw_decl_cmp_op(g, >)
-oln_pw_decl_cmp_op(l, <)
-
-oln_pw_cmp_operators(int)
-oln_pw_cmp_operators(float)
-oln_pw_cmp_operators(double)
-
-
-
#endif // ! OLENA_CORE_PW_CMP_HH
Index: oln/morpho/elementary_dilation.hh
===================================================================
--- oln/morpho/elementary_dilation.hh (revision 0)
+++ oln/morpho/elementary_dilation.hh (revision 0)
@@ -0,0 +1,113 @@
+// Copyright (C) 2005 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_MORPHO_ELEMENTARY_DILATION_HH
+# define OLENA_MORPHO_ELEMENTARY_DILATION_HH
+
+# include <oln/utils/record.hh>
+# include <oln/core/gen/image_with_nbh.hh>
+# include <oln/morpho/tags.hh>
+
+
+namespace oln {
+
+ namespace morpho {
+
+
+
+ // Fwd decl of elementary dilation's facade.
+
+ template<typename K, typename I>
+ oln_type_of(I, concrete) elementary_dilation(const tag::kind<K>& kind,
+ const abstract::image_with_nbh<I>& input);
+
+ // Facade for classical elementary dilation.
+
+ template<typename I>
+ oln_type_of(I, concrete) elementary_dilation(const abstract::image_with_nbh<I>& input)
+ {
+ return elementary_dilation(tag::classical, input);
+ }
+
+
+
+ namespace impl {
+
+
+ // generic
+
+ template<typename K, typename I>
+ oln_type_of(I, concrete) elementary_dilation_(const tag::kind<K>& kind,
+ const abstract::image_with_nbh<I>& input)
+ {
+ entering("->generic");
+ registering(input, "input");
+
+ oln_type_of(I, concrete) output(input.size(), "output");
+
+ oln_type_of(I, piter) p(input.size());
+ for_all_p (p)
+ output[p] = kind.max_nbh(input, p);
+
+ exiting("->generic");
+ return output;
+ }
+
+
+ // add some other impls here...
+
+
+ } // end of namespace oln::morpho::impl
+
+
+
+
+ /// Generic elementary_dilation (facade).
+
+ template<typename K, typename I>
+ oln_type_of(I, concrete) elementary_dilation(const tag::kind<K>& kind,
+ const abstract::image_with_nbh<I>& input)
+ {
+ entering("morpho::elementary_dilation");
+ registering(input, "input");
+
+ oln_type_of(I, concrete) output("output");
+ output = impl::elementary_dilation_(kind, input.exact());
+
+ exiting("morpho::elementary_dilation");
+ return output;
+ }
+
+
+
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_MORPHO_ELEMENTARY_DILATION_HH
Index: oln/morpho/tags.hh
===================================================================
--- oln/morpho/tags.hh (revision 174)
+++ oln/morpho/tags.hh (working copy)
@@ -84,6 +84,15 @@
return this->exact().impl_min_nbh(input, p);
}
+ // max value in input of neighborhoods of p
+ template <typename I>
+ oln_type_of(I, value)
+ max_nbh(const abstract::image_with_nbh<I>& input,
+ const oln_type_of(I, point)& p) const
+ {
+ return this->exact().impl_max_nbh(input, p);
+ }
+
};
@@ -119,6 +128,15 @@
return morpho::local_min_nbh(input, p);
}
+ // max value in input of neighborhoods of p
+ template <typename I>
+ oln_type_of(I, value)
+ impl_max_nbh(const abstract::image_with_nbh<I>& input,
+ const oln_type_of(I, point)& p) const
+ {
+ return morpho::local_max_nbh(input, p);
+ }
+
};
const classical_type classical = classical_type();
Index: oln/morpho/geodesic_dilation.hh
===================================================================
--- oln/morpho/geodesic_dilation.hh (revision 174)
+++ oln/morpho/geodesic_dilation.hh (working copy)
@@ -32,22 +32,14 @@
# include <mlc/contract.hh>
# include <oln/utils/record.hh>
-# include <oln/core/pw/all.hh>
+# include <oln/arith/cmp.hh>
# include <oln/core/gen/image_with_nbh.hh> // FIXME: should be in core/abstract/ (?)
# include <oln/morpho/elementary_dilation.hh>
-// FIXME: such routines should be written somewhere else...
-template <typename L, typename R>
-bool operator <= (const oln::abstract::image<L>& lhs,
- const oln::abstract::image<R>& rhs)
-{
- return oln::pw::check(oln::p_value(lhs) <= oln::p_value(rhs));
-}
-
namespace oln {
namespace morpho {
Index: oln/morpho/stat.hh
===================================================================
--- oln/morpho/stat.hh (revision 174)
+++ oln/morpho/stat.hh (working copy)
@@ -58,7 +58,6 @@
return minval;
}
-
template <typename I>
oln_type_of(I, value) local_min_nbh(const abstract::image_with_nbh<I>& input,
const oln_type_of(I, point)& p)
@@ -110,7 +109,20 @@
return maxval;
}
+ template <typename I>
+ oln_type_of(I, value) local_max_nbh(const abstract::image_with_nbh<I>& input,
+ const oln_type_of(I, point)& p)
+ {
+ oln_type_of(I, niter) n(input);
+ funobj::max_accumulator_init<oln_type_of(I, value)> maxval(input[p]);
+
+ for_all_n_of_p (n, p)
+ if (input.hold(n))
+ maxval(input[n]);
+ return maxval;
+ }
+
/// Local max on a set.
template <typename I, typename W>
Index: oln/morpho/geodesic_erosion.hh
===================================================================
--- oln/morpho/geodesic_erosion.hh (revision 174)
+++ oln/morpho/geodesic_erosion.hh (working copy)
@@ -32,23 +32,13 @@
# include <mlc/contract.hh>
# include <oln/utils/record.hh>
-# include <oln/core/pw/all.hh>
+# include <oln/arith/cmp.hh>
# include <oln/core/gen/image_with_nbh.hh> // FIXME: should be in core/abstract/ (?)
# include <oln/morpho/elementary_erosion.hh>
-// FIXME: such routines should be written somewhere else...
-template <typename L, typename R>
-bool operator >= (const oln::abstract::image<L>& lhs,
- const oln::abstract::image<R>& rhs)
-{
- return oln::pw::check(oln::p_value(lhs) >= oln::p_value(rhs));
-}
-
-
-
namespace oln {
namespace morpho {
Index: oln/arith/ops.hh
===================================================================
--- oln/arith/ops.hh (revision 174)
+++ oln/arith/ops.hh (working copy)
@@ -29,108 +29,129 @@
# define OLENA_ARITH_OPS_HH
# include <oln/core/abstract/image.hh>
-# include <oln/core/abstract/image_typeness.hh>
-# include <oln/core/pw/all.hh>
+# include <oln/core/pw/image.hh>
+# include <oln/core/pw/value.hh>
+# include <oln/core/pw/arith.hh>
-/// Operator + between 2 images.
+/// Operator '+' between 2 images.
template <typename L, typename R>
-oln::image_from_pw< oln::pw::plus< oln::pw::image<L>,
- oln::pw::image<R> > >
+oln::image_from_pwf< oln::pw::binary_op< oln::f_plus_type,
+ oln::pw::value<L>,
+ oln::pw::value<R> > >
operator + (const oln::abstract::image<L>& lhs,
const oln::abstract::image<R>& rhs)
{
- return oln::image_for_all_p(oln::p_value(lhs) + oln::p_value(rhs));
+ return oln::image_for_all_p(oln::pw_value(lhs) + oln::pw_value(rhs));
}
-/// Operator - between 2 images.
+/// Operator '-' between 2 images.
template <typename L, typename R>
-oln::image_from_pw< oln::pw::minus< oln::pw::image<L>,
- oln::pw::image<R> > >
+oln::image_from_pwf< oln::pw::binary_op< oln::f_minus_type,
+ oln::pw::value<L>,
+ oln::pw::value<R> > >
operator - (const oln::abstract::image<L>& lhs,
const oln::abstract::image<R>& rhs)
{
- return oln::image_for_all_p(oln::p_value(lhs) - oln::p_value(rhs));
+ return oln::image_for_all_p(oln::pw_value(lhs) - oln::pw_value(rhs));
}
-/// Operator - (unary) on image.
+/// Operator '*' between 2 images.
-template <typename R>
-oln::image_from_pw< oln::pw::minus< oln::pw::literal< oln_pw_type_of(R, value) >,
- oln::pw::image<R> > >
-operator - (const oln::abstract::image<R>& rhs)
+template <typename L, typename R>
+oln::image_from_pwf< oln::pw::binary_op< oln::f_times_type,
+ oln::pw::value<L>,
+ oln::pw::value<R> > >
+operator * (const oln::abstract::image<L>& lhs,
+ const oln::abstract::image<R>& rhs)
{
- return oln::image_for_all_p( - oln::p_value(rhs));
+ return oln::image_for_all_p(oln::pw_value(lhs) * oln::pw_value(rhs));
}
-/// Operator * between 2 images.
+/// Operator '/' between 2 images.
template <typename L, typename R>
-oln::image_from_pw< oln::pw::times< oln::pw::image<L>,
- oln::pw::image<R> > >
-operator * (const oln::abstract::image<L>& lhs,
+oln::image_from_pwf< oln::pw::binary_op< oln::f_div_type,
+ oln::pw::value<L>,
+ oln::pw::value<R> > >
+operator / (const oln::abstract::image<L>& lhs,
const oln::abstract::image<R>& rhs)
{
- return oln::image_for_all_p(oln::p_value(lhs) * oln::p_value(rhs));
+ return oln::image_for_all_p(oln::pw_value(lhs) / oln::pw_value(rhs));
}
-/// Operator / between 2 images.
+/// Operator '%' between 2 images.
template <typename L, typename R>
-oln::image_from_pw< oln::pw::div< oln::pw::image<L>,
- oln::pw::image<R> > >
-operator / (const oln::abstract::image<L>& lhs,
+oln::image_from_pwf< oln::pw::binary_op< oln::f_mod_type,
+ oln::pw::value<L>,
+ oln::pw::value<R> > >
+operator % (const oln::abstract::image<L>& lhs,
const oln::abstract::image<R>& rhs)
{
- return oln::image_for_all_p(oln::p_value(lhs) / oln::p_value(rhs));
+ return oln::image_for_all_p(oln::pw_value(lhs) % oln::pw_value(rhs));
}
-# define oln_decl_binary_operator(NAME, SYMBOL, TYPE) \
-template <typename L> \
-oln::image_from_pw< oln::pw::NAME< oln::pw::image<L>, \
- oln::pw::literal<TYPE> > > \
-operator SYMBOL (const oln::abstract::image<L>& lhs, \
- TYPE value) \
-{ \
- return oln::image_for_all_p(oln::p_value(lhs) SYMBOL oln::p_lit(value)); \
-} \
-template <typename R> \
-oln::image_from_pw< oln::pw::NAME< oln::pw::literal<TYPE>, \
- oln::pw::image<R> > > \
-operator SYMBOL (TYPE value, \
- const oln::abstract::image<R>& rhs) \
-{ \
- return oln::image_for_all_p(oln::p_lit(value) SYMBOL oln::p_value(rhs)); \
-}
+// FIXME...
+// /// Operator - (unary) on image.
-oln_decl_binary_operator(plus, +, int)
-oln_decl_binary_operator(plus, +, float)
-oln_decl_binary_operator(plus, +, double)
+// template <typename R>
+// oln::image_from_pw< oln::pw::minus< oln::pw::literal< oln_pw_type_of(R, value) >,
+// oln::pw::image<R> > >
+// operator - (const oln::abstract::image<R>& rhs)
+// {
+// return oln::image_for_all_p( - oln::p_value(rhs));
+// }
-oln_decl_binary_operator(minus, -, int)
-oln_decl_binary_operator(minus, -, float)
-oln_decl_binary_operator(minus, -, double)
-oln_decl_binary_operator(times, *, int)
-oln_decl_binary_operator(times, *, float)
-oln_decl_binary_operator(times, *, double)
-oln_decl_binary_operator(div, /, int)
-oln_decl_binary_operator(div, /, float)
-oln_decl_binary_operator(div, /, double)
+// # define oln_decl_binary_operator(NAME, SYMBOL, TYPE) \
+// template <typename L> \
+// oln::image_from_pw< oln::pw::NAME< oln::pw::image<L>, \
+// oln::pw::literal<TYPE> > > \
+// operator SYMBOL (const oln::abstract::image<L>& lhs, \
+// TYPE value) \
+// { \
+// return oln::image_for_all_p(oln::p_value(lhs) SYMBOL oln::p_lit(value)); \
+// } \
+// template <typename R> \
+// oln::image_from_pw< oln::pw::NAME< oln::pw::literal<TYPE>, \
+// oln::pw::image<R> > > \
+// operator SYMBOL (TYPE value, \
+// const oln::abstract::image<R>& rhs) \
+// { \
+// return oln::image_for_all_p(oln::p_lit(value) SYMBOL oln::p_value(rhs)); \
+// }
+// oln_decl_binary_operator(plus, +, int)
+// oln_decl_binary_operator(plus, +, float)
+// oln_decl_binary_operator(plus, +, double)
+// oln_decl_binary_operator(minus, -, int)
+// oln_decl_binary_operator(minus, -, float)
+// oln_decl_binary_operator(minus, -, double)
+
+// oln_decl_binary_operator(times, *, int)
+// oln_decl_binary_operator(times, *, float)
+// oln_decl_binary_operator(times, *, double)
+
+// oln_decl_binary_operator(div, /, int)
+// oln_decl_binary_operator(div, /, float)
+// oln_decl_binary_operator(div, /, double)
+
+
+
// template <typename I, typename F>
// void operator + (const oln::abstract::image<I>&,
// const oln::pw::abstract::function<F>&)
Index: oln/arith/logic.hh
===================================================================
--- oln/arith/logic.hh (revision 174)
+++ oln/arith/logic.hh (working copy)
@@ -25,47 +25,64 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLENA_LOGIC_OPS_HH
-# define OLENA_LOGIC_OPS_HH
+#ifndef OLENA_ARITH_LOGIC_HH
+# define OLENA_ARITH_LOGIC_HH
# include <oln/core/abstract/image.hh>
-# include <oln/core/abstract/image_typeness.hh>
-# include <oln/core/pw/all.hh>
+# include <oln/core/pw/image.hh>
+# include <oln/core/pw/value.hh>
+# include <oln/core/pw/logic.hh>
/// Operator 'and' between 2 binary images.
template <typename L, typename R>
-oln::image_from_pw< oln::pw::cmp< oln::pw::image<L>,
- oln::pw::image<R>, oln::pw::internal::and_ > >
-operator && (const oln::abstract::binary_image<L>& lhs,
- const oln::abstract::binary_image<R>& rhs)
+const oln::image_from_pwf< oln::pw::binary_op< oln::f_and_type,
+ oln::pw::value<L>,
+ oln::pw::value<R> > >
+operator and (const oln::abstract::binary_image<L>& lhs,
+ const oln::abstract::binary_image<R>& rhs)
{
- return oln::image_for_all_p(oln::p_value(lhs) && oln::p_value(rhs));
+ return oln::image_for_all_p(oln::pw_value(lhs) and oln::pw_value(rhs));
}
/// Operator 'or' between 2 binary images.
template <typename L, typename R>
-oln::image_from_pw< oln::pw::cmp< oln::pw::image<L>,
- oln::pw::image<R>, oln::pw::internal::or_ > >
-operator || (const oln::abstract::binary_image<L>& lhs,
+const oln::image_from_pwf< oln::pw::binary_op< oln::f_or_type,
+ oln::pw::value<L>,
+ oln::pw::value<R> > >
+operator or (const oln::abstract::binary_image<L>& lhs,
const oln::abstract::binary_image<R>& rhs)
{
- return oln::image_for_all_p(oln::p_value(lhs) || oln::p_value(rhs));
+ return oln::image_for_all_p(oln::pw_value(lhs) or oln::pw_value(rhs));
}
-/// Unary operator 'not' on a binary image.
+/// Operator 'xor' between 2 binary images.
-template <typename I>
-oln::image_from_pw< oln::pw::not_< oln::pw::image<I> > >
-operator ! (const oln::abstract::binary_image<I>& rhs)
+template <typename L, typename R>
+const oln::image_from_pwf< oln::pw::binary_op< oln::f_xor_type,
+ oln::pw::value<L>,
+ oln::pw::value<R> > >
+operator xor (const oln::abstract::binary_image<L>& lhs,
+ const oln::abstract::binary_image<R>& rhs)
{
- return oln::image_for_all_p(!oln::p_value(rhs));
+ return oln::image_for_all_p(oln::pw_value(lhs) xor oln::pw_value(rhs));
}
+// FIXME...
+// /// Unary operator 'not' on a binary image.
-#endif // ! OLENA_LOGIC_OPS_HH
+// template <typename I>
+// oln::image_from_pw< oln::pw::not_< oln::pw::image<I> > >
+// operator ! (const oln::abstract::binary_image<I>& rhs)
+// {
+// return oln::image_for_all_p(!oln::p_value(rhs));
+// }
+
+
+
+#endif // ! OLENA_ARITH_LOGIC_HH
Index: oln/arith/cmp.hh
===================================================================
--- oln/arith/cmp.hh (revision 0)
+++ oln/arith/cmp.hh (revision 0)
@@ -0,0 +1,96 @@
+// Copyright (C) 2005 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_ARITH_CMP_HH
+# define OLENA_ARITH_CMP_HH
+
+# include <oln/core/abstract/image.hh>
+# include <oln/core/pw/cmp.hh>
+# include <oln/core/pw/check.hh>
+
+
+/// Operator '==' between 2 images.
+
+template <typename L, typename R>
+bool operator == (const oln::abstract::image<L>& lhs,
+ const oln::abstract::image<R>& rhs)
+{
+ return oln::pw::check(oln::pw_value(lhs) == oln::pw_value(rhs));
+}
+
+
+/// Operator '!=' between 2 images.
+
+template <typename L, typename R>
+bool operator != (const oln::abstract::image<L>& lhs,
+ const oln::abstract::image<R>& rhs)
+{
+ return oln::pw::check(oln::pw_value(lhs) != oln::pw_value(rhs));
+}
+
+
+/// Operator '<' between 2 images.
+
+template <typename L, typename R>
+bool operator < (const oln::abstract::image<L>& lhs,
+ const oln::abstract::image<R>& rhs)
+{
+ return oln::pw::check(oln::pw_value(lhs) < oln::pw_value(rhs));
+}
+
+
+/// Operator '<=' between 2 images.
+
+template <typename L, typename R>
+bool operator <= (const oln::abstract::image<L>& lhs,
+ const oln::abstract::image<R>& rhs)
+{
+ return oln::pw::check(oln::pw_value(lhs) <= oln::pw_value(rhs));
+}
+
+
+/// Operator '>' between 2 images.
+
+template <typename L, typename R>
+bool operator > (const oln::abstract::image<L>& lhs,
+ const oln::abstract::image<R>& rhs)
+{
+ return oln::pw::check(oln::pw_value(lhs) > oln::pw_value(rhs));
+}
+
+
+/// Operator '>=' between 2 images.
+
+template <typename L, typename R>
+bool operator >= (const oln::abstract::image<L>& lhs,
+ const oln::abstract::image<R>& rhs)
+{
+ return oln::pw::check(oln::pw_value(lhs) >= oln::pw_value(rhs));
+}
+
+
+#endif // ! OLENA_ARITH_CMP_HH
1
0
29 Apr '05
2005-04-29 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* mlc/properties.hh (mlc_type_2_of_, mlc_type_2_of): New macros
for types having a comma in their name.
* mlc/typedef.hh: Cosmetic.
* mlc/is_a.hh
(template_l_template_l_class_g_class_g_class_): New case.
(template_l_template_l_class_class_g_class_g_class_): New case.
Index: mlc/properties.hh
===================================================================
--- mlc/properties.hh (revision 174)
+++ mlc/properties.hh (working copy)
@@ -222,12 +222,20 @@
FromType, \
Namespace::internal::typedef_::Alias##_type>::ret
+# define mlc_type_2_of_(Namespace, Category, FromType,_2, Alias) \
+ Namespace::internal::f_get_type<Category, \
+ FromType,_2, \
+ Namespace::internal::typedef_::Alias##_type>::ret
+
# define mlc_type_of(Namespace, Category, FromType, Alias) \
typename mlc_type_of_(Namespace, Category, FromType, Alias)
+# define mlc_type_2_of(Namespace, Category, FromType,_2, Alias) \
+typename mlc_type_2_of_(Namespace, Category, FromType,_2, Alias)
+
// FIXME: TODO-list
//
// f_get_type lance d'une part f_rec_get_prop et d'autre part f_rec_get_type
Index: mlc/typedef.hh
===================================================================
--- mlc/typedef.hh (revision 174)
+++ mlc/typedef.hh (working copy)
@@ -119,7 +119,7 @@
/*! \macro mlc_typedef_of( FromType, TypedefName )
**
** FIXME
-** Sample use: mlc_typedef_of(vector_t, value_type)
+** Sample use: mlc_typedef_of(std::vector<int>, value_type)
*/
# define mlc_typedef_of_(FromType, TypedefName) \
\
Index: mlc/is_a.hh
===================================================================
--- mlc/is_a.hh (revision 174)
+++ mlc/is_a.hh (working copy)
@@ -67,8 +67,9 @@
enum {
class_ = 1,
template_l_class_g_class_ = 2,
- template_l_class_class_g_class_ = 3
- // template_l_unsigned_class_g_class_ = 4
+ template_l_class_class_g_class_ = 3,
+ template_l_template_l_class_g_class_g_class_ = 4,
+ template_l_template_l_class_class_g_class_g_class_ = 5
// ...
};
@@ -76,18 +77,21 @@
struct desc
{ char dummy[id]; };
- template<class T>
+ template < class T>
static desc< class_ > get();
- template<template<class> class T>
+ template < template < class > class T>
static desc< template_l_class_g_class_ > get();
- template<template<class,class> class T>
+ template< template < class,class > class T>
static desc< template_l_class_class_g_class_ > get();
- // template<template<unsigned,class> class T>
- // static desc < template_l_unsigned_class_g_class_ > get();
+ template< template < template < class > class > class T>
+ static desc< template_l_template_l_class_g_class_g_class_ > get();
+ template< template < template < class,class > class > class T>
+ static desc< template_l_template_l_class_class_g_class_g_class_ > get();
+
// ...
}
@@ -104,15 +108,14 @@
template<unsigned id>
struct is_a_;
- // _class_
+ // class_
-
template<>
struct is_a_< form::class_ >
{
typedef is_a_< form::class_ > self;
- template<class T, class U>
+ template<class T, class U>
struct helper
{
static yes_ check(U*);
@@ -120,7 +123,7 @@
static T* makeT();
};
- template<class T, class U>
+ template<class T, class U>
struct check
: public value<bool,( is_a__check_result_ )>
{
@@ -134,7 +137,7 @@
{
typedef is_a_< form::template_l_class_g_class_ > self;
- template<class T, template<class> class U>
+ template<class T, template < class > class U>
struct helper
{
template<class V>
@@ -143,21 +146,21 @@
static T* makeT();
};
- template<class T, template<class> class U>
+ template<class T, template < class > class U>
struct check
: public value<bool,( is_a__check_result_ )>
{
};
};
- // templatee_l_class_class_g_class_
+ // template_l_class_class_g_class_
template<>
struct is_a_< form::template_l_class_class_g_class_ >
{
typedef is_a_< form::template_l_class_class_g_class_ > self;
- template<class T, template<class,class> class U>
+ template<class T, template < class,class > class U>
struct helper
{
template<class V, class W>
@@ -166,12 +169,56 @@
static T* makeT();
};
- template<class T, template<class,class> class U>
+ template<class T, template < class,class > class U>
struct check
: public value<bool,( is_a__check_result_ )>
{};
};
+ // template_l_template_l_class_g_class_g_class_
+
+ template<>
+ struct is_a_< form::template_l_template_l_class_g_class_g_class_ >
+ {
+ typedef is_a_< form::template_l_template_l_class_g_class_g_class_ > self;
+
+ template<class T, template < template < class > class > class U>
+ struct helper
+ {
+ template<template<class> class V>
+ static yes_ check(U<V>*);
+ static no_ check(...);
+ static T* makeT();
+ };
+
+ template<class T, template < template < class > class > class U>
+ struct check
+ : public value<bool,( is_a__check_result_ )>
+ {};
+ };
+
+ // template_l_template_l_class_class_g_class_g_class_
+
+ template<>
+ struct is_a_< form::template_l_template_l_class_class_g_class_g_class_ >
+ {
+ typedef is_a_< form::template_l_template_l_class_class_g_class_g_class_ > self;
+
+ template<class T, template < template < class,class > class > class U>
+ struct helper
+ {
+ template<template<class,class> class V>
+ static yes_ check(U<V>*);
+ static no_ check(...);
+ static T* makeT();
+ };
+
+ template<class T, template < template < class,class > class > class U>
+ struct check
+ : public value<bool,( is_a__check_result_ )>
+ {};
+ };
+
} // end of internal
} // end of mlc
1
0
2005-04-28 Nicolas Widynski <widyns_n(a)ptaouchnok.lrde.epita.fr>
* oln/morpho/geodesic_dilation.hh: New type of implementation,
like geodesic_erosion.hh
+++ oln/morpho/geodesic_dilation.hh (revision 173)
@@ -0,0 +1,111 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 2005 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_MORPHO_GEODESIC_DILATION_HH
+# define OLENA_MORPHO_GEODESIC_DILATION_HH
+
+# include <mlc/cmp.hh>
+# include <mlc/contract.hh>
+
+# include <oln/utils/record.hh>
+# include <oln/core/pw/all.hh>
+# include <oln/core/gen/image_with_nbh.hh> // FIXME: should be in
core/abstract/ (?)
+# include <oln/morpho/elementary_dilation.hh>
+
+
+// FIXME: such routines should be written somewhere else...
+
+template <typename L, typename R>
+bool operator <= (const oln::abstract::image<L>& lhs,
+ const oln::abstract::image<R>& rhs)
+{
+ return oln::pw::check(oln::p_value(lhs) <= oln::p_value(rhs));
+}
+
+
+
+namespace oln {
+
+ namespace morpho {
+
+
+
+ /// Generic geodesic dilation.
+
+ template<typename K, typename I, typename II>
+ oln_type_of(I, concrete) geodesic_dilation(const tag::kind<K>& kind,
+ const
abstract::image_with_nbh<I>& marker,
+ const
abstract::image<II>& mask)
+ {
+ // FIXME: later, test the short code:
+ // FIXME: return max(elementary_dilation(kind, marker), mask)
+
+ // FIXME: and even later:
+ // FIXME: return elementary_dilation(kind, marker) _max_ mask
+
+ mlc::eq<oln_type_of(I, grid), oln_type_of(II, grid)>::ensure();
+
+ entering("morpho::geodesic_dilation");
+
+ registering(marker, "marker");
+ registering(mask, "mask");
+ precondition(marker.size() == mask.size()
+ and marker <= mask);
+
+ oln_type_of(I, concrete)
+ dil("dil"),
+ output(marker.size(), "output");
+
+ dil = elementary_dilation(kind, marker);
+
+ // FIXME: replace code below by a pw::max...
+ oln_type_of(I, fwd_piter) p(marker.size());
+ for_all_p (p)
+ output[p] = std::min(dil[p].value(), mask[p].value());
+
+ exiting("morpho::geodesic_dilation");
+ return output;
+ }
+
+
+ /// Generic classical geodesic dilation.
+
+ template<typename I, typename II>
+ oln_type_of(I, concrete) geodesic_dilation(const
abstract::image_with_nbh<I>& marker,
+ const
abstract::image<II>& mask)
+ {
+ return geodesic_dilation(tag::classical, marker, mask);
+ }
+
+
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+
+#endif // OLENA_MORPHO_GEODESIC_DILATION_HH
1
0
2005-04-27 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* oln/morpho/closing.hh: New-like file.
* oln/morpho/dilation.hh: Likewise.
* oln/morpho/elementary_erosion.hh: Likewise.
* oln/morpho/erosion.hh: Likewise.
* oln/morpho/geodesic_erosion.hh: Likewise.
* oln/morpho/opening.hh: Likewise.
* oln/morpho/stat.hh: Likewise.
* oln/morpho/tags.hh: Likewise.
Index: oln/morpho/closing.hh
===================================================================
--- oln/morpho/closing.hh (revision 0)
+++ oln/morpho/closing.hh (revision 0)
@@ -0,0 +1,103 @@
+// Copyright (C) 2001-2005 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_MORPHO_CLOSING_HH
+# define OLENA_MORPHO_CLOSING_HH
+
+# include <mlc/cmp.hh>
+# include <mlc/to_string.hh>
+
+# include <oln/morpho/erosion.hh>
+# include <oln/morpho/dilation.hh>
+
+
+namespace oln {
+
+ namespace morpho {
+
+
+
+ // fwd decl of facade
+
+ template<typename I, typename W>
+ oln_type_of(I, concrete) closing(const abstract::image<I>& input,
+ const abstract::window<W>& win);
+
+
+
+ namespace impl {
+
+
+
+ // generic
+
+ template<typename I, typename W>
+ oln_type_of(I, concrete) closing_(const abstract::image<I>& input,
+ const abstract::window<W>& win)
+ {
+ entering("generic");
+ oln_type_of(I, concrete) output;
+
+ output = dilation(erosion(input, win), -win);
+
+ exiting("generic");
+ return output;
+ }
+
+
+
+ } // end of namespace oln::morpho::impl
+
+
+
+
+ /// Generic closing (facade).
+
+ template<typename I, typename W>
+ oln_type_of(I, concrete) closing(const abstract::image<I>& input,
+ const abstract::window<W>& win)
+ {
+ mlc::eq<oln_type_of(I, grid), oln_wn_type_of(W, grid)>::ensure();
+
+ entering("morpho::closing");
+ oln_type_of(I, concrete) output;
+
+ output = impl::closing_(input.exact(), win.exact());
+
+ exiting("morpho::closing");
+ return output;
+ }
+
+
+
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_MORPHO_CLOSING_HH
Index: oln/morpho/tags.hh
===================================================================
--- oln/morpho/tags.hh (revision 0)
+++ oln/morpho/tags.hh (revision 0)
@@ -0,0 +1,152 @@
+// Copyright (C) 2005 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_MORPHO_TAGS_HH
+# define OLENA_MORPHO_TAGS_HH
+
+# include <mlc/any.hh>
+# include <mlc/cmp.hh>
+# include <oln/basics.hh>
+
+# include <oln/morpho/stat.hh> // FIXME: rename!!!
+
+
+
+namespace oln {
+
+ namespace morpho {
+
+
+ namespace tag
+ {
+
+ // Tags for selecting a given 'morphology' due to
+ // the couple of dual operations performed in erosion
+ // and dilation.
+
+
+ template <typename K>
+ struct kind : public mlc::any<K> // FIXME: name!
+ {
+
+ // min value in input on a window centered at p
+ template <typename I, typename W>
+ oln_type_of(I, value)
+ min(const abstract::image<I>& input,
+ const oln_type_of(I, point)& p,
+ const abstract::window<W>& win) const
+ {
+ mlc::eq<oln_type_of(I, grid), oln_wn_type_of(W, grid)>::ensure();
+ return this->exact().impl_min(input, p, win);
+ }
+
+ // max value in input on a window centered at p
+ template <typename I, typename W>
+ oln_type_of(I, value)
+ max(const abstract::image<I>& input,
+ const oln_type_of(I, point)& p,
+ const abstract::window<W>& win) const
+ {
+ mlc::eq<oln_type_of(I, grid), oln_wn_type_of(W, grid)>::ensure();
+ return this->exact().impl_max(input, p, win);
+ }
+
+ // min value in input of neighborhoods of p
+ template <typename I>
+ oln_type_of(I, value)
+ min_nbh(const abstract::image_with_nbh<I>& input,
+ const oln_type_of(I, point)& p) const
+ {
+ return this->exact().impl_min_nbh(input, p);
+ }
+
+ };
+
+
+
+ struct classical_type : public kind< classical_type >
+ {
+ // min value in input on a window centered at p
+ template <typename I, typename W>
+ oln_type_of(I, value)
+ impl_min(const abstract::image<I>& input,
+ const oln_type_of(I, point)& p,
+ const abstract::window<W>& win) const
+ {
+ return morpho::local_min(input, p, win);
+ }
+
+ // max value in input on a window centered at p
+ template <typename I, typename W>
+ oln_type_of(I, value)
+ impl_max(const abstract::image<I>& input,
+ const oln_type_of(I, point)& p,
+ const abstract::window<W>& win) const
+ {
+ return morpho::local_max(input, p, win);
+ }
+
+ // min value in input of neighborhoods of p
+ template <typename I>
+ oln_type_of(I, value)
+ impl_min_nbh(const abstract::image_with_nbh<I>& input,
+ const oln_type_of(I, point)& p) const
+ {
+ return morpho::local_min_nbh(input, p);
+ }
+
+ };
+
+ const classical_type classical = classical_type();
+
+
+ // Tags for approaches in reconstructions.
+
+ template <typename Op> struct oper {};
+
+ struct by_dilation_type : public oper< by_dilation_type > {};
+ struct by_erosion_type : public oper< by_erosion_type > {};
+
+
+ // Tags for common canvas.
+
+ template <typename A> struct algo {};
+
+ struct sequential_type : public algo< sequential_type > {};
+ struct hybrid_type : public algo< hybrid_type > {};
+ struct parallel_type : public algo< parallel_type > {};
+ struct unionfind_type : public algo< unionfind_type > {};
+
+ } // end of namespace oln::morpho::tag
+
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_MORPHO_EROSION_HH
Index: oln/morpho/opening.hh
===================================================================
--- oln/morpho/opening.hh (revision 0)
+++ oln/morpho/opening.hh (revision 0)
@@ -0,0 +1,118 @@
+// Copyright (C) 2001-2005 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_MORPHO_OPENING_HH
+# define OLENA_MORPHO_OPENING_HH
+
+# include <mlc/cmp.hh>
+# include <mlc/to_string.hh>
+
+# include <oln/morpho/erosion.hh>
+# include <oln/morpho/dilation.hh>
+
+
+namespace oln {
+
+ namespace morpho {
+
+
+
+ // Fwd decl of opening's facade.
+
+ template<typename K, typename I, typename W>
+ oln_type_of(I, concrete) opening(const tag::kind<K>& kind,
+ const abstract::image<I>& input,
+ const abstract::window<W>& win);
+
+ // Facade for classical opening.
+
+ template<typename I, typename W>
+ oln_type_of(I, concrete) opening(const abstract::image<I>& input,
+ const abstract::window<W>& win)
+ {
+ return opening(tag::classical, input, win);
+ }
+
+
+
+ namespace impl {
+
+
+ // generic
+
+ template<typename K, typename I, typename W>
+ oln_type_of(I, concrete) opening_(const tag::kind<K>& kind,
+ const abstract::image<I>& input,
+ const abstract::window<W>& win)
+ {
+ entering("->generic");
+ registering(input, "input");
+
+ oln_type_of(I, concrete) output("output");
+ output = dilation(kind, erosion(kind, input, win), -win);
+
+ exiting("->generic");
+ return output;
+ }
+
+
+ // add some other impls here...
+
+
+ } // end of namespace oln::morpho::impl
+
+
+
+
+ /// Generic opening (facade).
+
+ template<typename K, typename I, typename W>
+ oln_type_of(I, concrete) opening(const tag::kind<K>& kind,
+ const abstract::image<I>& input,
+ const abstract::window<W>& win)
+ {
+ mlc::eq<oln_type_of(I, grid), oln_wn_type_of(W, grid)>::ensure();
+
+ entering("morpho::opening");
+ registering(input, "input");
+
+ oln_type_of(I, concrete) output("output");
+ output = impl::opening_(kind, input.exact(), win.exact());
+
+ exiting("morpho::opening");
+ return output;
+ }
+
+
+
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_MORPHO_OPENING_HH
Index: oln/morpho/elementary_erosion.hh
===================================================================
--- oln/morpho/elementary_erosion.hh (revision 0)
+++ oln/morpho/elementary_erosion.hh (revision 0)
@@ -0,0 +1,113 @@
+// Copyright (C) 2005 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_MORPHO_ELEMENTARY_EROSION_HH
+# define OLENA_MORPHO_ELEMENTARY_EROSION_HH
+
+# include <oln/utils/record.hh>
+# include <oln/core/gen/image_with_nbh.hh>
+# include <oln/morpho/tags.hh>
+
+
+namespace oln {
+
+ namespace morpho {
+
+
+
+ // Fwd decl of elementary erosion's facade.
+
+ template<typename K, typename I>
+ oln_type_of(I, concrete) elementary_erosion(const tag::kind<K>& kind,
+ const abstract::image_with_nbh<I>& input);
+
+ // Facade for classical elementary erosion.
+
+ template<typename I>
+ oln_type_of(I, concrete) elementary_erosion(const abstract::image_with_nbh<I>& input)
+ {
+ return elementary_erosion(tag::classical, input);
+ }
+
+
+
+ namespace impl {
+
+
+ // generic
+
+ template<typename K, typename I>
+ oln_type_of(I, concrete) elementary_erosion_(const tag::kind<K>& kind,
+ const abstract::image_with_nbh<I>& input)
+ {
+ entering("->generic");
+ registering(input, "input");
+
+ oln_type_of(I, concrete) output(input.size(), "output");
+
+ oln_type_of(I, piter) p(input.size());
+ for_all_p (p)
+ output[p] = kind.min_nbh(input, p);
+
+ exiting("->generic");
+ return output;
+ }
+
+
+ // add some other impls here...
+
+
+ } // end of namespace oln::morpho::impl
+
+
+
+
+ /// Generic elementary_erosion (facade).
+
+ template<typename K, typename I>
+ oln_type_of(I, concrete) elementary_erosion(const tag::kind<K>& kind,
+ const abstract::image_with_nbh<I>& input)
+ {
+ entering("morpho::elementary_erosion");
+ registering(input, "input");
+
+ oln_type_of(I, concrete) output("output");
+ output = impl::elementary_erosion_(kind, input.exact());
+
+ exiting("morpho::elementary_erosion");
+ return output;
+ }
+
+
+
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_MORPHO_ELEMENTARY_EROSION_HH
Index: oln/morpho/dilation.hh
===================================================================
--- oln/morpho/dilation.hh (revision 0)
+++ oln/morpho/dilation.hh (revision 0)
@@ -0,0 +1,143 @@
+// Copyright (C) 2001-2005 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_MORPHO_DILATION_HH
+# define OLENA_MORPHO_DILATION_HH
+
+# include <mlc/cmp.hh>
+# include <mlc/to_string.hh>
+
+# include <oln/utils/record.hh>
+# include <oln/basics.hh>
+# include <oln/core/2d/window2d.hh>
+# include <oln/morpho/tags.hh>
+
+
+namespace oln {
+
+ namespace morpho {
+
+
+
+ // Fwd decl of dilation's facade.
+
+ template<typename K, typename I, typename W>
+ oln_type_of(I, concrete) dilation(const tag::kind<K>& kind,
+ const abstract::image<I>& input,
+ const abstract::window<W>& win);
+
+ // Facade for classical dilation.
+
+ template<typename I, typename W>
+ oln_type_of(I, concrete) dilation(const abstract::image<I>& input,
+ const abstract::window<W>& win)
+ {
+ return dilation(tag::classical, input, win);
+ }
+
+
+ namespace impl {
+
+ // generic
+
+ template<typename K, typename I, typename W>
+ oln_type_of(I, concrete) dilation_(const tag::kind<K>& kind,
+ const abstract::image<I>& input,
+ const abstract::window<W>& win)
+ {
+ entering("->generic");
+ registering(input, "input");
+
+ oln_type_of(I, concrete) output(input.size(), "output");
+
+ oln_type_of(I, fwd_piter) p(input.size());
+ for_all_p (p)
+ output[p] = kind.min(input, p, win);
+
+ exiting("->generic");
+ return output;
+ }
+
+
+
+ // win is a 2D rectangle
+
+ template<typename K, typename I>
+ oln_type_of(I, concrete) dilation_(const tag::kind<K>& kind,
+ const abstract::image2d<I>& input,
+ const win_rectangle2d& win)
+ {
+ entering("->(image2d,win_rectangle2d)");
+ registering(input, "input");
+
+ oln_type_of(I, concrete) temp("temp"), output("output");
+
+ win_hline2d hline(win.width); // FIXME: Cf. Soille, use L(i,dp)
+ win_vline2d vline(win.height);
+
+ temp = dilation(kind, input, hline);
+ output = dilation(kind, temp, vline);
+
+ exiting("->(image2d,win_rectangle2d)");
+ return output;
+ }
+
+
+ // add some other impls here...
+
+
+ } // end of namespace oln::morpho::impl
+
+
+
+
+ /// Generic dilation (facade).
+
+ template<typename K, typename I, typename W>
+ oln_type_of(I, concrete) dilation(const tag::kind<K>& kind,
+ const abstract::image<I>& input,
+ const abstract::window<W>& win)
+ {
+ mlc::eq<oln_type_of(I, grid), oln_wn_type_of(W, grid)>::ensure();
+ entering("morpho::dilation");
+
+ oln_type_of(I, concrete) output("output");
+ output = impl::dilation_(kind, input.exact(), win.exact());
+
+ exiting("morpho::dilation");
+ return output;
+ }
+
+
+
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_MORPHO_DILATION_HH
Index: oln/morpho/stat.hh
===================================================================
--- oln/morpho/stat.hh (revision 0)
+++ oln/morpho/stat.hh (revision 0)
@@ -0,0 +1,136 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 2005 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_MORPHO_STAT_HH
+# define OLENA_MORPHO_STAT_HH
+
+# include <mlc/cmp.hh>
+# include <ntg/bin.hh>
+# include <oln/basics.hh>
+# include <oln/funobj/accum.hh>
+
+
+namespace oln {
+
+ namespace morpho {
+
+
+ /// Local min on a function.
+
+ template <typename I, typename W>
+ oln_type_of(I, value) local_min(const abstract::image<I>& input,
+ const oln_type_of(I, point)& p,
+ const abstract::window<W>& win)
+ {
+ mlc::eq<oln_type_of(I, grid), oln_wn_type_of(W, grid)>::ensure();
+
+ oln_wn_type_of(W, fwd_iter) q(win);
+ funobj::min_accumulator<oln_type_of(I, value)> minval;
+
+ for_all_q_of_p (q, p)
+ if (input.hold(q))
+ minval(input[q]);
+
+ return minval;
+ }
+
+
+ template <typename I>
+ oln_type_of(I, value) local_min_nbh(const abstract::image_with_nbh<I>& input,
+ const oln_type_of(I, point)& p)
+ {
+ oln_type_of(I, niter) n(input);
+ funobj::min_accumulator_init<oln_type_of(I, value)> minval(input[p]);
+
+ for_all_n_of_p (n, p)
+ if (input.hold(n))
+ minval(input[n]);
+
+ return minval;
+ }
+
+
+ /// Local min on a set.
+
+ template <typename I, typename W>
+ bool local_min(const abstract::binary_image<I>& input,
+ const oln_type_of(I, point)& p,
+ const abstract::window<W>& win)
+ {
+ mlc::eq<oln_type_of(I, grid), oln_wn_type_of(W, grid)>::ensure();
+
+ oln_wn_type_of(W, fwd_iter) q(win);
+ for_all_q_of_p (q, p)
+ if (input.hold(q) and not input[q])
+ return false;
+ return true;
+ }
+
+
+ /// Local max on a function.
+
+ template <typename I, typename W>
+ oln_type_of(I, value) local_max(const abstract::image<I>& input,
+ const oln_type_of(I, point)& p,
+ const abstract::window<W>& win)
+ {
+ mlc::eq<oln_type_of(I, grid), oln_wn_type_of(W, grid)>::ensure();
+
+ oln_wn_type_of(W, fwd_iter) q(win);
+ funobj::max_accumulator<oln_type_of(I, value)> maxval;
+
+ for_all_q_of_p (q, p)
+ if (input.hold(q))
+ maxval(input[q]);
+
+ return maxval;
+ }
+
+
+ /// Local max on a set.
+
+ template <typename I, typename W>
+ bool local_max(const abstract::binary_image<I>& input,
+ const oln_type_of(I, point)& p,
+ const abstract::window<W>& win)
+ {
+ mlc::eq<oln_type_of(I, grid), oln_wn_type_of(W, grid)>::ensure();
+
+ oln_wn_type_of(W, fwd_iter) q(win);
+ for_all_q_of_p (q, p)
+ if (input.hold(q) and input[q])
+ return true;
+ return false;
+ }
+
+
+ } // end of namespace morpho
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_MORPHO_STAT_HH
Index: oln/morpho/erosion.hh
===================================================================
--- oln/morpho/erosion.hh (revision 0)
+++ oln/morpho/erosion.hh (revision 0)
@@ -0,0 +1,143 @@
+// Copyright (C) 2001-2005 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_MORPHO_EROSION_HH
+# define OLENA_MORPHO_EROSION_HH
+
+# include <mlc/cmp.hh>
+# include <mlc/to_string.hh>
+
+# include <oln/utils/record.hh>
+# include <oln/basics.hh>
+# include <oln/core/2d/window2d.hh>
+# include <oln/morpho/tags.hh>
+
+
+namespace oln {
+
+ namespace morpho {
+
+
+
+ // Fwd decl of erosion's facade.
+
+ template<typename K, typename I, typename W>
+ oln_type_of(I, concrete) erosion(const tag::kind<K>& kind,
+ const abstract::image<I>& input,
+ const abstract::window<W>& win);
+
+ // Facade for classical erosion.
+
+ template<typename I, typename W>
+ oln_type_of(I, concrete) erosion(const abstract::image<I>& input,
+ const abstract::window<W>& win)
+ {
+ return erosion(tag::classical, input, win);
+ }
+
+
+ namespace impl {
+
+ // generic
+
+ template<typename K, typename I, typename W>
+ oln_type_of(I, concrete) erosion_(const tag::kind<K>& kind,
+ const abstract::image<I>& input,
+ const abstract::window<W>& win)
+ {
+ entering("->generic");
+ registering(input, "input");
+
+ oln_type_of(I, concrete) output(input.size(), "output");
+
+ oln_type_of(I, fwd_piter) p(input.size());
+ for_all_p (p)
+ output[p] = kind.min(input, p, win);
+
+ exiting("->generic");
+ return output;
+ }
+
+
+
+ // win is a 2D rectangle
+
+ template<typename K, typename I>
+ oln_type_of(I, concrete) erosion_(const tag::kind<K>& kind,
+ const abstract::image2d<I>& input,
+ const win_rectangle2d& win)
+ {
+ entering("->(image2d,win_rectangle2d)");
+ registering(input, "input");
+
+ oln_type_of(I, concrete) temp("temp"), output("output");
+
+ win_hline2d hline(win.width); // FIXME: Cf. Soille, use L(i,dp)
+ win_vline2d vline(win.height);
+
+ temp = erosion(kind, input, hline);
+ output = erosion(kind, temp, vline);
+
+ exiting("->(image2d,win_rectangle2d)");
+ return output;
+ }
+
+
+ // add some other impls here...
+
+
+ } // end of namespace oln::morpho::impl
+
+
+
+
+ /// Generic erosion (facade).
+
+ template<typename K, typename I, typename W>
+ oln_type_of(I, concrete) erosion(const tag::kind<K>& kind,
+ const abstract::image<I>& input,
+ const abstract::window<W>& win)
+ {
+ mlc::eq<oln_type_of(I, grid), oln_wn_type_of(W, grid)>::ensure();
+ entering("morpho::erosion");
+
+ oln_type_of(I, concrete) output("output");
+ output = impl::erosion_(kind, input.exact(), win.exact());
+
+ exiting("morpho::erosion");
+ return output;
+ }
+
+
+
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_MORPHO_EROSION_HH
Index: oln/morpho/geodesic_erosion.hh
===================================================================
--- oln/morpho/geodesic_erosion.hh (revision 0)
+++ oln/morpho/geodesic_erosion.hh (revision 0)
@@ -0,0 +1,112 @@
+// Copyright (C) 2005 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_MORPHO_GEODESIC_EROSION_HH
+# define OLENA_MORPHO_GEODESIC_EROSION_HH
+
+# include <mlc/cmp.hh>
+# include <mlc/contract.hh>
+
+# include <oln/utils/record.hh>
+# include <oln/core/pw/all.hh>
+# include <oln/core/gen/image_with_nbh.hh> // FIXME: should be in core/abstract/ (?)
+# include <oln/morpho/elementary_erosion.hh>
+
+
+
+// FIXME: such routines should be written somewhere else...
+
+template <typename L, typename R>
+bool operator >= (const oln::abstract::image<L>& lhs,
+ const oln::abstract::image<R>& rhs)
+{
+ return oln::pw::check(oln::p_value(lhs) >= oln::p_value(rhs));
+}
+
+
+
+namespace oln {
+
+ namespace morpho {
+
+
+
+ /// Generic geodesic erosion.
+
+ template<typename K, typename I, typename II>
+ oln_type_of(I, concrete) geodesic_erosion(const tag::kind<K>& kind,
+ const abstract::image_with_nbh<I>& marker,
+ const abstract::image<II>& mask)
+ {
+ // FIXME: later, test the short code:
+ // FIXME: return max(elementary_erosion(kind, marker), mask)
+
+ // FIXME: and even later:
+ // FIXME: return elementary_erosion(kind, marker) _max_ mask
+
+ mlc::eq<oln_type_of(I, grid), oln_type_of(II, grid)>::ensure();
+
+ entering("morpho::geodesic_erosion");
+
+ registering(marker, "marker");
+ registering(mask, "mask");
+ precondition(marker.size() == mask.size()
+ and marker >= mask);
+
+ oln_type_of(I, concrete)
+ ero("ero"),
+ output(marker.size(), "output");
+
+ ero = elementary_erosion(kind, marker);
+
+ // FIXME: replace code below by a pw::max...
+ oln_type_of(I, fwd_piter) p(marker.size());
+ for_all_p (p)
+ output[p] = std::max(ero[p].value(), mask[p].value());
+
+ exiting("morpho::geodesic_erosion");
+ return output;
+ }
+
+
+ /// Generic classical geodesic erosion.
+
+ template<typename I, typename II>
+ oln_type_of(I, concrete) geodesic_erosion(const abstract::image_with_nbh<I>& marker,
+ const abstract::image<II>& mask)
+ {
+ return geodesic_erosion(tag::classical, marker, mask);
+ }
+
+
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_MORPHO_GEODESIC_EROSION_HH
1
0
2005-04-27 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Files in oln/morpho move to 'trash' since inheritance in
image operators will soon be no longer in use.
* oln/morpho/*.hh: Rename as...
* oln/morpho/*.trash: ...this.
* oln/morpho/*.inc: Rename as...
* oln/morpho/*.inctrash: ...this.
* oln/convert/nbh_to_se.hh: Remove cause meaningless.
The changes below are for safety purpose; we should ensure
that some (now commented) features are no more in use.
* oln/core/2d/image2d.hh (operator=(box)): Comment.
(operator=(image_like_): Comment.
(image2d(const image2d&)): Add decl to help compiler.
* oln/core/box.hh (operator I): New.
(operator=(box<II>): Comment.
(operator=(image_like_<I>)): Comment.
(operator=(image_like_<II>)): Comment.
(operator=(image<II>)): Comment.
* oln/utils/clone.hh: Update.
Index: oln/morpho/reconstruction.hh
===================================================================
--- oln/morpho/reconstruction.hh (revision 166)
+++ oln/morpho/reconstruction.hh (working copy)
@@ -1,227 +0,0 @@
-// Copyright (C) 2001, 2002, 2004, 2005 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 filek 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_MORPHO_RECONSTRUCTION_HH
-# define OLENA_MORPHO_RECONSTRUCTION_HH
-
-# include <queue>
-
-# include <mlc/cmp.hh>
-# include <mlc/contract.hh>
-
-# include <oln/convert/nbh_to_se.hh>
-
-# include <oln/core/abstract/image_operator.hh>
-# include <oln/core/abstract/neighborhood.hh>
-
-# include <oln/level/compare.hh>
-
-# include <oln/morpho/splitse.hh>
-# include <oln/morpho/stat.hh>
-
-# include <oln/utils/clone.hh>
-
-namespace oln {
-
-
- namespace tag {
-
- template <typename Op> struct oper {};
-
- struct by_dilation : public oper< by_dilation > {};
- struct by_erosion : public oper< by_erosion > {};
-
-
- template <typename A> struct algo {};
-
- struct sequential : public algo< sequential > {};
- struct hybrid : public algo< hybrid > {};
-
- } // end of namespace oln::morpho::tag
-
-
-
- namespace morpho {
- template <typename I1, typename I2> struct reconstruction_ret;
- } // end of namespace oln::morpho
-
- // super_type
-
- template <typename I1, typename I2>
- struct set_super_type< morpho::reconstruction_ret<I1, I2> >
- {
- typedef oln_type_of(I1, concrete) output_type;
-
- typedef morpho::reconstruction_ret<I1,I2> self_type;
- typedef abstract::image_binary_operator<output_type, I1, I2, self_type > ret;
- };
-
- namespace morpho {
-
- // Reconstruction as a 'classical' procedure returning an image (do not
- // use it; prefer morpho::reconstruction).
-
- namespace proc {
-
- // FIXME: ...
-
- } // end of namespace oln::morpho::proc
-
-
- template <typename I1, typename I2>
- struct reconstruction_ret :
- // FIXME: oln_super_of_
- public oln::internal::get_super_type< reconstruction_ret<I1,I2> >::ret
- {
- typedef reconstruction_ret<I1, I2> self_type;
- typedef typename oln::internal::get_super_type<self_type>::ret super_type;
-
- box<const I1> marker;
- box<const I2> mask;
-
- reconstruction_ret(const abstract::image_with_nbh<I1>& marker,
- const abstract::image<I2>& mask) :
- super_type(marker, mask),
- marker(marker),
- mask(mask)
- {
- }
-
- const oln_type_of(I1, neighb)& impl_nbh_get() const
- {
- return marker.nbh_get();
- }
-
- };
-
- } // end of namespace morpho
-
-} // end of namespace oln
-
-# include <oln/morpho/reconstruction_canvas.inc>
-
-namespace oln {
-
- namespace morpho {
-
- namespace impl {
-
- template<typename Op, typename A, typename I1, typename I2>
- struct generic_reconstruction;
-
- } // end of namespace impl
-
- } // end of namespace morpho
-
-} // end of namespace oln
-
-# include <oln/morpho/reconstruction_by_dilation.inc>
-# include <oln/morpho/reconstruction_by_erosion.inc>
-
-namespace oln {
-
- namespace morpho {
-
- namespace impl {
-
- // Generic implementation of reconstruction (routine).
-
- template<typename Op, typename A, typename I1, typename I2>
- reconstruction_ret<I1,I2>
- reconstruction(const abstract::image_with_nbh<I1>& marker,
- const abstract::image<I2>& mask)
- {
- generic_reconstruction<Op, A, I1, I2> tmp(marker, mask);
- tmp.run();
- return tmp;
- }
-
- } // end of namespace impl
-
- /// Generic reconstruction (facade).
-
- template<typename Op, typename I1, typename I2, typename A>
- reconstruction_ret<I1,I2>
- reconstruction(const tag::oper<Op>& oper_,
- const abstract::image_with_nbh<I1>& marker,
- const abstract::image<I2>& mask,
- const tag::algo<A>& algo_)
- {
- return impl::reconstruction<Op,A>(marker.exact(), mask.exact());
- }
-
- // by dilation
-
- template<typename I1, typename I2, typename A>
- reconstruction_ret<I1,I2>
- reconstruction_by_dilation(const abstract::image_with_nbh<I1>& marker,
- const abstract::image<I2>& mask,
- const tag::algo<A>& algo_)
- {
- mlc::eq<oln_type_of(I1, grid), oln_type_of(I2, grid)>::ensure();
- precondition(marker.size() == mask.size());
- return reconstruction(tag::by_dilation(), marker, mask, algo_);
- }
-
- template<typename I1, typename I2>
- reconstruction_ret<I1,I2>
- reconstruction_by_dilation(const abstract::image_with_nbh<I1>& marker,
- const abstract::image<I2>& mask)
- {
- mlc::eq<oln_type_of(I1, grid), oln_type_of(I2, grid)>::ensure();
- precondition(marker.size() == mask.size());
- return reconstruction(tag::by_dilation(), marker, mask, tag::hybrid());
- }
-
- // by erosion
-
- template<typename I1, typename I2, typename A>
- reconstruction_ret<I1,I2>
- reconstruction_by_erosion(const abstract::image_with_nbh<I1>& marker,
- const abstract::image<I2>& mask,
- const tag::algo<A>& algo_)
- {
- mlc::eq<oln_type_of(I1, grid), oln_type_of(I2, grid)>::ensure();
- precondition(marker.size() == mask.size());
- return reconstruction(tag::by_erosion(), marker, mask, algo_);
- }
-
- template<typename I1, typename I2>
- reconstruction_ret<I1,I2>
- reconstruction_by_erosion(const abstract::image_with_nbh<I1>& marker,
- const abstract::image<I2>& mask)
- {
- mlc::eq<oln_type_of(I1, grid), oln_type_of(I2, grid)>::ensure();
- precondition(marker.size() == mask.size());
- return reconstruction(tag::by_erosion(), marker, mask, tag::hybrid());
- }
-
- } // end of namespace oln::morpho
-
-} // end of namespace oln
-
-#endif // ! OLENA_MORPHO_RECONSTRUCTION_HH
Index: oln/morpho/reconstruction_by_erosion.inc
===================================================================
--- oln/morpho/reconstruction_by_erosion.inc (revision 166)
+++ oln/morpho/reconstruction_by_erosion.inc (working copy)
@@ -1,141 +0,0 @@
-// Copyright (C) 2005 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 filek 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.
-
-namespace oln {
-
- namespace morpho {
-
- namespace impl {
-
- // Sequential version
-
- template<typename I1, typename I2>
- struct generic_reconstruction <tag::by_erosion, tag::sequential, I1, I2>
- : public generic_reconstruction_canvas<I1, I2, tag::sequential,
- generic_reconstruction<tag::by_erosion, tag::sequential, I1, I2> >
- {
- typedef generic_reconstruction<tag::by_erosion,
- tag::sequential, I1,I2> self_type;
- typedef generic_reconstruction_canvas<I1, I2, tag::sequential,
- self_type> super_type;
-
- generic_reconstruction(const abstract::image_with_nbh<I1>& marker,
- const abstract::image<I2>& mask) :
- super_type(marker, mask)
- {
- }
-
-
- void impl_bkd_loop_body()
- {
- this->output[this->bkd_p] = ntg::max(morpho::min(this->output,
- this->bkd_p,
- this->win_minus),
- this->mask[this->bkd_p].value());
- }
-
- void impl_fwd_loop_body()
- {
- this->output[this->fwd_p] = ntg::max(morpho::min(this->output,
- this->fwd_p,
- this->win_plus),
- this->mask[this->fwd_p].value());
- }
-
- void impl_preconditions()
- {
- precondition(level::is_greater_or_equal(this->marker, this->mask));
- }
-
- };
-
- // Hybrid version
-
- template<typename I1, typename I2>
- struct generic_reconstruction <tag::by_erosion, tag::hybrid, I1, I2>
- : public generic_reconstruction_canvas<I1, I2, tag::hybrid,
- generic_reconstruction<tag::by_erosion, tag::hybrid, I1, I2> >
- {
- typedef generic_reconstruction<tag::by_erosion,
- tag::hybrid, I1,I2> self_type;
- typedef generic_reconstruction_canvas<I1, I2, tag::hybrid,
- self_type> super_type;
-
- generic_reconstruction(const abstract::image_with_nbh<I1>& marker,
- const abstract::image<I2>& mask) :
- super_type(marker, mask)
- {
- }
-
-
-
- void impl_bkd_loop_body()
- {
- this->output[this->bkd_p] = ntg::max(morpho::min(this->work,
- this->bkd_p,
- this->win_minus),
- this->mask[this->bkd_p].value());
- }
-
- void impl_fwd_loop_body()
- {
- this->output[this->fwd_p] = ntg::max(morpho::min(this->work,
- this->fwd_p,
- this->win_plus),
- this->mask[this->fwd_p].value());
- }
-
- void impl_fifo_loop_body()
- {
- if ((this->output[this->q] > this->output[this->p]) &&
- (this->mask[this->q] != this->output[this->q]))
- {
- this->output[this->q] = ntg::min(this->output[this->p].value(),
- this->mask[this->q].value());
- this->fifo.push(this->q);
- }
- }
-
- bool impl_exist_init()
- {
- return this->output.hold(this->q) &&
- (this->output[this->q] > this->output[this->bkd_p]) &&
- (this->output[this->q] > this->mask[this->q]);
- }
-
- void impl_preconditions()
- {
- precondition(level::is_greater_or_equal(this->marker, this->mask));
- }
-
- };
-
- }
-
- }
-
-}
Index: oln/morpho/splitse.hh
===================================================================
--- oln/morpho/splitse.hh (revision 166)
+++ oln/morpho/splitse.hh (working copy)
@@ -1,209 +0,0 @@
-// Copyright (C) 2001, 2002, 2004, 2005 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_MORPHO_SPLITSE_HH
-# define OLENA_MORPHO_SPLITSE_HH
-
-# include <oln/basics.hh>
-
-# include <oln/core/1d/size1d.hh>
-# include <oln/core/2d/size2d.hh>
-# include <oln/core/3d/size3d.hh>
-
-# include <oln/core/abstract/window.hh>
-# include <oln/core/abstract/window.hh>
-
-
-namespace oln {
- namespace morpho {
-
- template <class S>
- struct dim_traits
- {
- };
-
- template <>
- struct dim_traits<size1d>
- {
- enum {dim = 1};
- };
-
- template <>
- struct dim_traits<size2d>
- {
- enum {dim = 2};
- };
-
- template <>
- struct dim_traits<size3d>
- {
- enum {dim = 3};
- };
-
- /*!
- ** \brief Get a sub part of a window.
- **
- ** \param E Exact type of the window.
- **
- ** \arg win The window.
- **
- ** A point p take part of the new window if it exists
- ** a i that belongs to [[0..dim-1]] like p(i) < 0 and for all j
- ** that belongs to [[0..i-1]] p(j) = 0.
- **
- */
-
-
- template<class W>
- W
- get_plus_win_only(const W& win) // FIXME: abstract::window<W>& win)
- {
- W out;
- for (unsigned i = 0; i < win.card(); ++i)
- {
- const oln_wn_type_of(W, dpoint)& dp = win.get_dp()[i];
- unsigned n;
- for (n = 0; n < dim_traits<oln_wn_type_of(W, size)>::dim; ++n)
- if (dp.nth(n) < 0) {
- out.add(dp);
- break;
- } else if (dp.nth(n) > 0) {
- break;
- }
- }
- return out;
- }
-
- /*!
- ** \brief Get a sub part of a window.
- **
- ** \param W Exact type of the window.
- **
- ** \arg win The window.
- **
- ** A point p take part of the new window if it exists
- ** a i that belongs to [[0..dim-1]] like p(i) < 0 and for all j
- ** that belongs to [[0..i-1]] p(j) = 0 or if for all i that
- ** belongs to [[0..dim-1]] p(i) = 0.
- **
- */
- template<class W>
- W
- get_plus_win_p(const W& win) // abstract::window<W>& win)
- {
- W out;
- for (unsigned i = 0; i < win.card(); ++i)
- {
- const oln_wn_type_of(W, dpoint)& dp = win.get_dp()[i];
- unsigned n;
- for (n = 0; n < dim_traits<oln_wn_type_of(W, size)>::dim; ++n)
- if (dp.nth(n) < 0) {
- out.add(dp);
- break;
- } else if (dp.nth(n) > 0) {
- break;
- }
- // All p.nth(n) are 0.
- if (n == dim_traits<oln_wn_type_of(W, size)>::dim)
- out.add(dp);
- }
- return out;
- }
-
- /*!
- ** \brief Get a sub part of a window.
- **
- ** \param W Exact type of the window.
- **
- ** \arg win The window.
- **
- ** A point p take part of the new window if it exists
- ** a i that belongs to [[0..dim-1]] like p(i) > 0 and for all j
- ** that belongs to [[0..i-1]] p(j) = 0.
- **
- */
- template<class W>
- W
- get_minus_win_only(const W& win) // abstract::window<W>& win)
- {
- W out;
- for (unsigned i = 0; i < win.card(); ++i)
- {
- const oln_wn_type_of(W, dpoint)& dp = win.get_dp()[i];
- unsigned n;
- for (n = 0; n < dim_traits<oln_wn_type_of(W, size)>::dim; ++n)
- if (dp.nth(n) > 0) {
- out.add(dp);
- break;
- } else if (dp.nth(n) < 0) {
- break;
- }
- }
- return out;
- }
-
- /*!
- ** \brief Get a sub part of a window.
- **
- ** \param W Exact type of the window.
- **
- ** \arg win The window.
- **
- ** A point p take part of the new window if it exists
- ** a i that belongs to [[0..dim-1]] like p(i) > 0 and for all j
- ** that belongs to [[0..i-1]] p(j) = 0 or if for all i that
- ** belongs to [[0..dim-1]] p(i) = 0.
- **
- */
- template<class W>
- W
- get_minus_win_p(const W& win) // abstract::window<W>& win)
- {
- W out;
- for (unsigned i = 0; i < win.card(); ++i)
- {
- const oln_wn_type_of(W, dpoint)& dp = win.get_dp()[i];
- unsigned n;
- for (n = 0; n < dim_traits<oln_wn_type_of(W, size)>::dim; ++n)
- if (dp.nth(n) > 0) {
- out.add(dp);
- break;
- } else if (dp.nth(n) < 0) {
- break;
- }
- // All p.nth(n) are 0.
- if (n == dim_traits<oln_wn_type_of(W, size)>::dim)
- out.add(dp);
- }
- return out;
- }
-
- } // end of namespace oln::morpho
-
-} // end of namespace oln
-
-#endif // ! OLENA_MORPHO_SPLITSE_HH
Index: oln/morpho/cc_tarjan.hh
===================================================================
--- oln/morpho/cc_tarjan.hh (revision 166)
+++ oln/morpho/cc_tarjan.hh (working copy)
@@ -1,233 +0,0 @@
-// Copyright (C) 2005 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_CC_TARJAN_HH
-# define OLENA_CC_TARJAN_HH
-
-# include <vector>
-
-# include <oln/basics2d.hh>
-# include <oln/core/abstract/image_operator.hh>
-# include <oln/level/fill.hh>
-
-//
-// Based on "Ruminations on Tarjan's Union-Find algorithm and connected
-// operators" of Thierry Geraud.
-//
-
-
-namespace oln {
-
- // fwd decl
- namespace morpho {
- template <typename T, typename I, typename E> struct cc_tarjan_ret;
- }
-
- // FIXME: this macro is waiting for the mute.
- // (we may use a property to do it)
- #define tmp_mute(I, T) image2d< T >
-
- // category
- template <typename T, typename I, typename E>
- struct set_category< morpho::cc_tarjan_ret<T,I,E> >
- { typedef category::image ret; };
-
- // super_type
- template <typename T, typename I, typename E>
- struct set_super_type< morpho::cc_tarjan_ret<T,I,E> >
- {
- typedef abstract::image_unary_operator
- <tmp_mute(I, T), I, morpho::cc_tarjan_ret<T, I, E> >
- ret;
- };
-
-
- namespace morpho {
-
- template <typename T, typename I, typename E>
- struct cc_tarjan_ret
- : public abstract::image_unary_operator
- <tmp_mute(I, T), I, cc_tarjan_ret<T, I, E> >
- {
- typedef abstract::image_unary_operator
- <tmp_mute(I, T), I, cc_tarjan_ret<T, I, E> >
- super_type;
- typedef typename super_type::output_type output_type;
-
- const E ng;
-
- cc_tarjan_ret(const abstract::image<I>& input,
- const abstract::neighborhood<E>& ng) :
- super_type(input),
- ng(ng.exact())
- {
- }
-
- };
-
-
- namespace impl {
-
-
- namespace misc {
-
- // FIXME: This code should be generalized.
- // While iterating on image and then on a neighborhood, here we do
- // not want to see the neighborhood points ever seen.
- std::vector<dpoint2d> get_superior(const neighborhood2d& n)
- {
- std::vector<dpoint2d> output;
- for (unsigned i = 0; i < n.card(); ++i)
- {
- dpoint2d dp = n.dp(i);
- if (dp.row() < 0 || (dp.row() == 0 && dp.col() < 0))
- output.push_back(dp);
- }
- return output;
- }
-
- std::vector<dpoint2d> get_inferior(const neighborhood2d& n)
- {
- std::vector<dpoint2d> output;
- for (unsigned i = 0; i < n.card(); ++i)
- {
- dpoint2d dp = n.dp(i);
- if (dp.row() > 0 || (dp.row() == 0 && dp.col() > 0))
- output.push_back(dp);
- }
- return output;
- }
-
- } // end of misc namespace
-
-
- template <typename T, typename I, typename N>
- struct generic_cc_tarjan : public cc_tarjan_ret<T, I, N>
- {
- typedef cc_tarjan_ret<T, I, N> super_type;
- typedef typename super_type::output_type output_type;
-
- tmp_mute(I, oln_type_of(I, point)) parent;
- T ncomps;
-
- generic_cc_tarjan(const abstract::image<I>& input,
- const abstract::neighborhood<N>& ng) :
- super_type(input, ng),
- parent(input.size())
- {
- }
-
- void impl_run()
- {
- mlc::eq<oln_type_of(I, size), oln_type_of(N, size)>::ensure();
-
- output_type tmp(this->input.size()); // FIXME: trick
- this->output = tmp;
-
- first_pass();
- second_pass();
- }
-
- void first_pass()
- {
- std::vector<dpoint2d> neighb = misc::get_inferior(this->ng);
- oln_type_of(I, bkd_piter) p(this->input.size());
- for_all_p (p)
- if (this->input[p])
- {
- make_set(p);
- for (unsigned v = 0; v < neighb.size(); ++v)
- {
- oln_type_of(I, point) n = oln_type_of(I, point)(p) + neighb[v];
- if (this->input[n])
- do_union(n, p);
- }
- }
- }
-
- void second_pass()
- {
- oln_type_of(I, fwd_piter) p(this->input.size());
- level::fill(this->output, 0);
- ncomps = 0;
- for_all_p (p)
- if (this->input[p])
- {
- oln_type_of(I, point) q = parent[p];
- // FIXME: test if ncomps > T::max()
- this->output[p] = (q == p ? ++ncomps : this->output[q]);
- }
- }
-
- void make_set(const oln_type_of(I, point)& x)
- {
- parent[x] = x;
- }
-
- oln_type_of(I, point) find_root(const oln_type_of(I, point)& x)
- {
- if (parent[x] != x)
- {
- parent[x] = find_root(parent[x]);
- return parent[x];
- }
- return x;
- }
-
- void do_union(const oln_type_of(I, point)& n,
- const oln_type_of(I, point)& p)
- {
- oln_type_of(I, point) r = find_root(n);
- if (r != p)
- parent[r] = p;
- }
-
-
- };
-
- } // end of namespace oln::morpho::impl
-
-
- /// Connected component labelling via Tarjan Union-Find generic routine.
-
- // T is the component label type (usually unsigned).
- template<typename T, typename I, typename N>
- cc_tarjan_ret<T, I, N> cc_tarjan(const abstract::image<I>& input,
- const abstract::neighborhood<N>& ng)
- {
- impl::generic_cc_tarjan<T, I, N> tmp(input, ng);
- tmp.run();
- return tmp;
- }
-
-
- } // end of namespace oln::morpho
-
-} // end of namespace oln
-
-
-#endif // ! OLENA_CC_TARJAN_HH
Index: oln/morpho/reconstruction_canvas.inc
===================================================================
--- oln/morpho/reconstruction_canvas.inc (revision 166)
+++ oln/morpho/reconstruction_canvas.inc (working copy)
@@ -1,238 +0,0 @@
-// Copyright (C) 2005 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 filek 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.
-
-
-namespace oln {
-
- namespace morpho {
-
- namespace impl {
-
- template <typename I1, typename I2, typename A, typename E>
- struct generic_reconstruction_canvas;
-
- template <typename I1, typename I2, typename E>
- struct generic_reconstruction_canvas<I1, I2, tag::sequential, E> :
- public reconstruction_ret<I1, I2>
- {
- typedef reconstruction_ret<I1, I2> super_type;
- typedef oln_type_of(I1, neighb) nbh_type;
- typedef oln_type_of(I1, concrete) output_type;
-
- E& exact__()
- {
- return *(E*)(void*)(this);
- }
-
- void bkd_loop_body()
- {
- this->exact__().impl_bkd_loop_body();
- }
- void fwd_loop_body()
- {
- this->exact__().impl_fwd_loop_body();
- }
-
- void preconditions()
- {
- mlc::eq<oln_type_of(I1, grid), oln_type_of(I2, grid)>::ensure();
- precondition(this->marker.size() == this->mask.size());
- this->exact__().impl_preconditions();
- }
-
- void init()
- {
- // no call to impl_init here because this canvas can't be generalized yet.
- this->output = utils::clone(this->marker);
- this->work = utils::clone(this->marker);
-
- win_plus = get_plus_win_p(convert::nbh_to_cse(this->marker.nbh_get()));
- win_minus = get_minus_win_p(convert::nbh_to_cse(this->marker.nbh_get()));
- }
-
- bool is_stable()
- {
- // same explanation as above
- return level::is_equal(this->work, this->output);
- }
-
- void impl_run()
- {
- this->preconditions();
- this->init();
- for (;;)
- {
- for_all_p (fwd_p)
- this->fwd_loop_body();
- for_all_p (bkd_p)
- this->bkd_loop_body();
- if (this->is_stable())
- return;
- work = utils::clone(this->output);
- }
- }
-
- protected:
-
- generic_reconstruction_canvas(const abstract::image_with_nbh<I1>& marker,
- const abstract::image<I2>& mask) :
- super_type(marker, mask),
- bkd_p(marker.size()),
- fwd_p(marker.size())
- {
- }
-
-
- oln_type_of(I1, bkd_piter) bkd_p;
- oln_type_of(I1, fwd_piter) fwd_p;
-
- oln_nbh_type_of(nbh_type, window) win_plus;
- oln_nbh_type_of(nbh_type, window) win_minus;
-
- box<oln_type_of(I1, concrete)> work;
- };
-
- template <typename I1, typename I2, typename E>
- struct generic_reconstruction_canvas<I1, I2, tag::hybrid, E> :
- public reconstruction_ret<I1, I2>
- {
- typedef reconstruction_ret<I1, I2> super_type;
- typedef oln_type_of(I1, neighb) nbh_type;
- typedef oln_nbh_type_of(nbh_type, window) window_type;
- typedef oln_type_of(I1, concrete) output_type;
-
- E& exact__()
- {
- return *(E*)(void*)(this);
- }
-
-
- bool exist_init()
- {
- for (unsigned i = 0; i < win_minus.card(); ++i)
- {
- q = win_minus.get_dp()[i] + (oln_type_of(I1, point))bkd_p;
- if (this->exact__().impl_exist_init())
- return true;
- }
- return false;
- }
-
- void bkd_loop_body()
- {
- this->exact__().impl_bkd_loop_body();
- }
- void fwd_loop_body()
- {
- this->exact__().impl_fwd_loop_body();
- }
-
- void fifo_loop_body()
- {
- this->exact__().impl_fifo_loop_body();
- }
-
- void preconditions()
- {
- mlc::eq<oln_type_of(I1, grid), oln_type_of(I2, grid)>::ensure();
- precondition(this->marker.size() == this->mask.size());
- this->exact__().impl_preconditions();
- }
-
- void init()
- {
- output_type tmp(this->marker.size());
-
- this->output = tmp;
- this->work = utils::clone(this->marker);
-
- win_plus = get_plus_win_p(convert::nbh_to_cse(this->marker.nbh_get()));
- win_minus = get_minus_win_p(convert::nbh_to_cse(this->marker.nbh_get()));
- }
-
- void impl_run()
- {
- this->preconditions();
- this->init();
-
- for_all_p (fwd_p)
- this->fwd_loop_body();
-
- for_all_p (bkd_p)
- {
- bkd_loop_body();
- if (exist_init())
- fifo.push(bkd_p);
- }
- // Propagation Step
- while (!fifo.empty())
- {
- p = fifo.front();
- fifo.pop();
-
- window_type win = convert::nbh_to_se(this->marker.nbh_get());
- for (unsigned i = 0; i < win.card(); ++i)
- {
- q = win.get_dp()[i] + p;
-
- if (this->output.hold(q))
- fifo_loop_body();
- }
- }
- }
-
- protected:
-
- generic_reconstruction_canvas(const abstract::image_with_nbh<I1>& marker,
- const abstract::image<I2>& mask) :
- super_type(marker, mask),
- bkd_p(marker.size()),
- fwd_p(marker.size())
- {
- }
-
-
- oln_type_of(I1, bkd_piter) bkd_p;
- oln_type_of(I1, fwd_piter) fwd_p;
-
- oln_type_of(I1, point) p;
- oln_type_of(I1, point) q;
-
- window_type win_plus;
- window_type win_minus;
-
- box<oln_type_of(I1, concrete)> work;
-
- std::queue<oln_type_of(I1, point) > fifo;
-
- };
-
- } // end of namespace impl
-
- } // end of namespace morpho
-
-} // end of namespace oln
Index: oln/morpho/closing.hh
===================================================================
--- oln/morpho/closing.hh (revision 166)
+++ oln/morpho/closing.hh (working copy)
@@ -1,165 +0,0 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005 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_MORPHO_CLOSING_HH
-# define OLENA_MORPHO_CLOSING_HH
-
-# include <mlc/cmp.hh>
-# include <mlc/to_string.hh>
-
-# include <oln/core/abstract/image_operator.hh>
-
-# include <oln/morpho/dilation.hh>
-# include <oln/morpho/erosion.hh>
-# include <oln/core/2d/window2d.hh>
-
-
-namespace oln {
-
-
- // fwd decl
-
- namespace morpho {
- template <typename I> struct closing_ret;
- }
-
- // super_type
-
- template <typename I>
- struct set_super_type< morpho::closing_ret<I> >
- {
- typedef oln_type_of(I, concrete) output_type;
-
- typedef morpho::closing_ret<I> self_type;
- typedef abstract::image_unary_operator<output_type, I, self_type > ret;
- };
-
-
-
-
- namespace morpho {
-
-
-
- // Closing as a 'classical' procedure returning an image (do not
- // use it; prefer morpho::closing).
-
- namespace proc {
-
- template<typename I, typename W>
- oln_type_of(I, concrete) closing(const abstract::image<I>& input,
- const abstract::window<W>& win)
- {
- mlc::eq<oln_type_of(I, grid), oln_wn_type_of(W, grid)>::ensure();
- oln_type_of(I, concrete) output(input.size());
- output = morpho::erosion(morpho::dilation(input, win), win);
- return output;
- }
-
- } // end of namespace oln::morpho::proc
-
-
-
- /// Closing return type.
-
- template <typename I>
- struct closing_ret : public oln_super_of_(closing_ret<I>)
- {
- typedef oln_super_of(closing_ret<I>) super_type;
-
- closing_ret(const abstract::image<I>& input) :
- super_type(input)
- {
- }
-
- };
-
-
- // Various implementation.
-
- namespace impl {
-
-
- /// Generic implementation of closing (type).
-
- template <typename I, typename W>
- struct generic_closing : public closing_ret<I>
- {
- typedef closing_ret<I> super_type;
- // FIXME: typedef oln_type_of(super_type, output) output_type;
-
- const W& win;
-
- generic_closing(const abstract::image<I>& input,
- const abstract::window<W>& win) :
- super_type(input),
- win(win.exact())
- {
- }
-
- void impl_run()
- {
- oln_type_of(super_type, output) tmp(input.size());
- tmp = morpho::erosion(morpho::dilation(input, win), win);
- output = tmp;
- }
- };
-
- // Generic implementation of closing (routine).
-
- template<typename I, typename W>
- closing_ret<I> closing(const abstract::image<I>& input,
- const abstract::window<W>& win)
- {
- impl::generic_closing<I,W> tmp(input, win);
- tmp.run();
- return tmp;
- }
-
- // FIXME: Add specialized implementations.
-
- } // end of namespace oln::morpho::impl
-
-
- /// Generic closing (facade).
-
- template<typename I, typename W>
- closing_ret<I> closing(const abstract::image<I>& input,
- const abstract::window<W>& win)
- {
- mlc::eq<oln_type_of(I, grid), oln_wn_type_of(W, grid)>::ensure();
- return impl::closing(input.exact(), win.exact());
- }
-
-
- } // end of namespace oln::morpho
-
-
-} // end of namespace oln
-
-
-#endif // ! OLENA_MORPHO_CLOSING_HH
Index: oln/morpho/opening.hh
===================================================================
--- oln/morpho/opening.hh (revision 166)
+++ oln/morpho/opening.hh (working copy)
@@ -1,165 +0,0 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005 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_MORPHO_OPENING_HH
-# define OLENA_MORPHO_OPENING_HH
-
-# include <mlc/cmp.hh>
-# include <mlc/to_string.hh>
-
-# include <oln/core/abstract/image_operator.hh>
-
-# include <oln/morpho/dilation.hh>
-# include <oln/morpho/erosion.hh>
-# include <oln/core/2d/window2d.hh>
-
-
-namespace oln {
-
-
- // fwd decl
-
- namespace morpho {
- template <typename I> struct opening_ret;
- }
-
- // super_type
-
- template <typename I>
- struct set_super_type< morpho::opening_ret<I> >
- {
- typedef oln_type_of(I, concrete) output_type;
-
- typedef morpho::opening_ret<I> self_type;
- typedef abstract::image_unary_operator<output_type, I, self_type > ret;
- };
-
-
-
-
- namespace morpho {
-
-
-
- // Opening as a 'classical' procedure returning an image (do not
- // use it; prefer morpho::opening).
-
- namespace proc {
-
- template<typename I, typename W>
- oln_type_of(I, concrete) opening(const abstract::image<I>& input,
- const abstract::window<W>& win)
- {
- mlc::eq<oln_type_of(I, grid), oln_wn_type_of(W, grid)>::ensure();
- oln_type_of(I, concrete) output(input.size());
- output = morpho::dilation(morpho::erosion(input, win), win);
- return output;
- }
-
- } // end of namespace oln::morpho::proc
-
-
-
- /// Opening return type.
-
- template <typename I>
- struct opening_ret : public oln_super_of_(opening_ret<I>)
- {
- typedef oln_super_of(opening_ret<I>) super_type;
-
- opening_ret(const abstract::image<I>& input) :
- super_type(input)
- {
- }
-
- };
-
-
- // Various implementation.
-
- namespace impl {
-
-
- /// Generic implementation of opening (type).
-
- template <typename I, typename W>
- struct generic_opening : public opening_ret<I>
- {
- typedef opening_ret<I> super_type;
- // FIXME: typedef oln_type_of(super_type, output) output_type;
-
- const W& win;
-
- generic_opening(const abstract::image<I>& input,
- const abstract::window<W>& win) :
- super_type(input),
- win(win.exact())
- {
- }
-
- void impl_run()
- {
- oln_type_of(super_type, output) tmp(input.size());
- tmp = morpho::dilation(morpho::erosion(input, win), win);
- output = tmp;
- }
- };
-
- // Generic implementation of opening (routine).
-
- template<typename I, typename W>
- opening_ret<I> opening(const abstract::image<I>& input,
- const abstract::window<W>& win)
- {
- impl::generic_opening<I,W> tmp(input, win);
- tmp.run();
- return tmp;
- }
-
- // FIXME: Add specialized implementations.
-
- } // end of namespace oln::morpho::impl
-
-
- /// Generic opening (facade).
-
- template<typename I, typename W>
- opening_ret<I> opening(const abstract::image<I>& input,
- const abstract::window<W>& win)
- {
- mlc::eq<oln_type_of(I, grid), oln_wn_type_of(W, grid)>::ensure();
- return impl::opening(input.exact(), win.exact());
- }
-
-
- } // end of namespace oln::morpho
-
-
-} // end of namespace oln
-
-
-#endif // ! OLENA_MORPHO_OPENING_HH
Index: oln/morpho/dilation.hh
===================================================================
--- oln/morpho/dilation.hh (revision 166)
+++ oln/morpho/dilation.hh (working copy)
@@ -1,202 +0,0 @@
-// Copyright (C) 2001, 2002, 2004, 2005 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 filek 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_MORPHO_DILATION_HH
-# define OLENA_MORPHO_DILATION_HH
-
-# include <mlc/cmp.hh>
-
-# include <oln/core/abstract/image_operator.hh>
-# include <oln/morpho/stat.hh>
-
-
-namespace oln {
-
- namespace morpho {
-
-
-
- namespace proc {
-
- /// Dilation as a procedure (do not use it; prefer morpho::dilation).
-
- template<typename I, typename W>
- oln_type_of(I, concrete) dilation(const abstract::image<I>& input,
- const abstract::window<W>& win)
- {
- oln_type_of(I, concrete) output(input.size());
- oln_type_of(I, fwd_piter) p(input.size());
- for_all_p (p)
- output[p] = morpho::max(input, p, win);
- return output;
- }
-
- } // end of namespace oln::morpho::proc
-
-
-
- /*!
- ** \brief Processing dilation.
- **
- ** Compute the morphological dilation of input using win
- ** as structural element.\n
- **
- ** On grey-scale images, each point is replaced by the maximum value
- ** of its neighbors, as indicated by win. On binary images,
- ** a logical or is performed between neighbors.\n
- **
- ** The morpho::fast version of this function use a different
- ** algorithm: This algorithm is described in
- ** Implementation of morphological operations from:
- ** M. Van Droogenbroeck and H. Talbot.
- ** "Fast computation of morphological operations with arbitrary
- ** structuring elements". Pattern Recognition Letters,
- ** 17(14):1451-1460, 1996.\n
- **
- ** An histogram of the value of the neighborhood indicated by
- ** win is updated while iterating over all point of the
- ** image. Doing so is more efficient when the
- ** structural element is large.\n
- **
- ** \param I Exact type of the input image.
- ** \param E Exact type of the neighborhood.
- **
- ** \arg input The input image.
- ** \arg win Structuring element to use.
- **
- ** \code
- ** #include <oln/basics2d.hh>
- ** #include <oln/morpho/dilation.hh>
- ** #include <oln/level/compare.hh>
- ** #include <ntg/all.hh>
- ** int main()
- ** {
- ** typedef oln::image2d<ntg::bin> im_type;
- **
- ** im_type im1(oln::load(IMG_IN "object.pbm"));
- ** save(oln::morpho::dilation(im1, oln::win_c8p()),
- ** IMG_OUT "oln_morpho_dilation.pbm");
- ** }
- ** \endcode
- **
- ** \image html object_pbm.png
- ** \image latex object_pbm.png
- ** =>
- ** \image html oln_morpho_dilation.png
- ** \image latex oln_morpho_dilation.png
- */
-
- // fwd decl
- template <typename I, typename E> struct dilation_ret;
-
- }
-
- // category
- template <typename I, typename E>
- struct set_category< morpho::dilation_ret<I,E> > { typedef category::image ret; };
-
- // super_type
- template <typename I, typename E>
- struct set_super_type< morpho::dilation_ret<I,E> >
- {
- typedef abstract::image_unary_operator<oln_type_of(I, concrete), I, morpho::dilation_ret<I, E> > ret;
- };
-
-
-
- namespace morpho {
-
- /// Dilatation return.
-
- template <typename I, typename W>
- struct dilation_ret : public abstract::image_unary_operator<oln_type_of(I, concrete), I, dilation_ret<I,W> >
- {
- typedef abstract::image_unary_operator<oln_type_of(I, concrete), I, dilation_ret<I,W> > super_type;
- typedef typename super_type::output_type output_type;
-
- const W win;
-
- dilation_ret(const abstract::image<I>& input,
- const abstract::window<W>& win) :
- super_type(input.exact()),
- win(win.exact())
- {
- }
-
- };
-
-
- // Implementation:
-
- namespace impl {
-
- /// Dilation generic implementation.
-
- template <typename I, typename W>
- struct generic_dilation : public dilation_ret<I,W>
- {
- typedef dilation_ret<I,W> super_type;
- typedef typename super_type::output_type output_type;
-
- generic_dilation(const abstract::image<I>& input,
- const abstract::window<W>& win) :
- super_type(input, win)
- {
- }
-
- void impl_run()
- {
- mlc::eq<oln_type_of(I, size), oln_wn_type_of(W, size)>::ensure();
-
- output_type tmp(this->input.size()); // FIXME: trick
- this->output = tmp;
-
- oln_type_of(I, fwd_piter) p(this->input.size());
- for_all_p (p)
- this->output[p] = morpho::max(this->input, p, this->win);
- }
- };
-
- } // end of namespace oln::morpho::impl
-
-
- /// Dilation generic routine.
-
- template<typename I, typename W>
- dilation_ret<I,W> dilation(const abstract::image<I>& input,
- const abstract::window<W>& win)
- {
- impl::generic_dilation<I,W> tmp(input, win);
- tmp.run();
- return tmp;
- }
-
- } // end of morpho
-
-} // end of oln
-
-#endif // ! OLENA_MORPHO_DILATION_HH
Index: oln/morpho/geodesic_dilation.hh
===================================================================
--- oln/morpho/geodesic_dilation.hh (revision 166)
+++ oln/morpho/geodesic_dilation.hh (working copy)
@@ -1,141 +0,0 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005 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_MORPHO_GEODESIC_DILATION_HH
-# define OLENA_MORPHO_GEODESIC_DILATION_HH
-
-# include <mlc/cmp.hh>
-
-# include <oln/core/abstract/image_operator.hh>
-# include <oln/morpho/stat.hh>
-# include <oln/level/compare.hh>
-# include <oln/arith/min.hh>
-
-# include <oln/core/abstract/neighborhood.hh>
-# include <oln/morpho/dilation.hh>
-
-namespace oln {
-
- namespace morpho {
-
- // fwd declaration
- template <class I1, class I2> struct geodesic_dilation_ret;
-
- namespace proc {
-
- template<class I1, class I2>
- oln_type_of(I1, concrete)
- geodesic_dilation(const abstract::image_with_nbh<I1>& marker,
- const abstract::image<I2>& mask)
- {
- mlc::eq<oln_type_of(I1, size), oln_type_of(I2, size)>::ensure();
- precondition(marker.size() == mask.size());
- precondition(level::is_greater_or_equal(mask, marker));
- oln_type_of(I1, concrete) output(marker.size());
- // FIXME: Useless?
- // marker.border_adapt_copy(marker.nbh_get().delta());
- oln_type_of(I1, piter) p(marker.size());
- for_all_p (p)
- {
- oln_type_of(I1, value) a =
- morpho::max(marker, p, marker.nbh_get().get_win());
- oln_type_of(I2, value) b = mask[p];
- // Min.
- output[p] = a < b ? a : b;
- }
- return output;
- }
-
- } // end of namespace oln::morpho::proc
-
- } // end of namespace oln::morpho
-
-
-
- // super_type
- template <class I1, class I2>
- struct set_super_type< morpho::geodesic_dilation_ret<I1, I2> >
- {
- typedef abstract::image_binary_operator<oln_type_of(I1, concrete), I1, I2, morpho::geodesic_dilation_ret<I1, I2> > ret;
- };
-
-
- namespace morpho {
-
- template <class I1, class I2>
- struct geodesic_dilation_ret : public abstract::image_binary_operator<oln_type_of(I1, concrete), I1, I2, morpho::geodesic_dilation_ret<I1, I2> >
- {
- typedef abstract::image_binary_operator<oln_type_of(I1, concrete), I1, I2, geodesic_dilation_ret<I1, I2> > super_type;
-
- geodesic_dilation_ret(const abstract::image_with_nbh<I1>& marker,
- const abstract::image<I2>& mask) :
- super_type(marker, mask)
- {}
- };
-
-
- namespace safe {
-
- template <class I1, class I2>
- struct geodesic_dilation : public geodesic_dilation_ret<I1, I2>
- {
- typedef geodesic_dilation_ret<I1, I2> super_type;
-
- geodesic_dilation(const abstract::image_with_nbh<I1>& marker,
- const abstract::image<I2>& mask) :
- super_type(marker, mask)
- {}
-
- void impl_run()
- {
- mlc::eq<oln_type_of(I1, size), oln_type_of(I2, size)>::ensure();
- precondition((this->input1).size() == (this->input2).size());
- precondition(level::is_greater_or_equal(this->input2, this->input1));
- this->output =
- arith::min(dilation(this->input1.unbox(),
- this->input1.unbox().nbh_get().get_win()).output.unbox(),
- this->input2.unbox()).output;
- }
- };
-
- } // end of namespace oln::morpho::safe
-
- template<class I1, class I2>
- geodesic_dilation_ret<I1, I2>
- geodesic_dilation(const abstract::image_with_nbh<I1>& marker,
- const abstract::image<I2>& mask)
- {
- safe::geodesic_dilation<I1, I2> tmp(marker, mask);
- tmp.run();
- return tmp;
- }
-
- } // end of namespace oln::morpho
-
-} // end of namespace oln
-
-#endif // OLENA_MORPHO_GEODESIC_DILATION_HH
Index: oln/morpho/reconstruction_by_dilation.inc
===================================================================
--- oln/morpho/reconstruction_by_dilation.inc (revision 166)
+++ oln/morpho/reconstruction_by_dilation.inc (working copy)
@@ -1,142 +0,0 @@
-// Copyright (C) 2005 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 filek 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.
-
-namespace oln {
-
- namespace morpho {
-
- namespace impl {
-
- // Sequential version
-
- template<typename I1, typename I2>
- struct generic_reconstruction <tag::by_dilation, tag::sequential, I1, I2>
- : public generic_reconstruction_canvas<I1, I2, tag::sequential,
- generic_reconstruction<tag::by_dilation, tag::sequential, I1, I2> >
- {
- typedef generic_reconstruction<tag::by_dilation,
- tag::sequential, I1,I2> self_type;
- typedef generic_reconstruction_canvas<I1, I2, tag::sequential,
- self_type> super_type;
-
- generic_reconstruction(const abstract::image_with_nbh<I1>& marker,
- const abstract::image<I2>& mask) :
- super_type(marker, mask)
- {
- }
-
-
- void impl_bkd_loop_body()
- {
- this->output[this->bkd_p] = ntg::min(morpho::max(this->output,
- this->bkd_p,
- this->win_minus),
- this->mask[this->bkd_p].value());
- }
-
- void impl_fwd_loop_body()
- {
- this->output[this->fwd_p] = ntg::min(morpho::max(this->output,
- this->fwd_p,
- this->win_plus),
- this->mask[this->fwd_p].value());
- }
-
- void impl_preconditions()
- {
- precondition(level::is_greater_or_equal(this->mask, this->marker));
- }
-
- };
-
-
- // Hybrid version
-
- template<typename I1, typename I2>
- struct generic_reconstruction <tag::by_dilation, tag::hybrid, I1, I2>
- : public generic_reconstruction_canvas<I1, I2, tag::hybrid,
- generic_reconstruction<tag::by_dilation, tag::hybrid, I1, I2> >
- {
- typedef generic_reconstruction<tag::by_dilation,
- tag::hybrid, I1,I2> self_type;
- typedef generic_reconstruction_canvas<I1, I2, tag::hybrid,
- self_type> super_type;
-
- generic_reconstruction(const abstract::image_with_nbh<I1>& marker,
- const abstract::image<I2>& mask) :
- super_type(marker, mask)
- {
- }
-
-
-
- void impl_bkd_loop_body()
- {
- this->output[this->bkd_p] = ntg::min(morpho::max(this->work,
- this->bkd_p,
- this->win_minus),
- this->mask[this->bkd_p].value());
- }
-
- void impl_fwd_loop_body()
- {
- this->output[this->fwd_p] = ntg::min(morpho::max(this->work,
- this->fwd_p,
- this->win_plus),
- this->mask[this->fwd_p].value());
- }
-
- void impl_fifo_loop_body()
- {
- if ((this->output[this->q] < this->output[this->p]) &&
- (this->mask[this->q] != this->output[this->q]))
- {
- this->output[this->q] = ntg::min(this->output[this->p].value(),
- this->mask[this->q].value());
- this->fifo.push(this->q);
- }
- }
-
- bool impl_exist_init()
- {
- return this->output.hold(this->q) &&
- (this->output[this->q] < this->output[this->bkd_p]) &&
- (this->output[this->q] < this->mask[this->q]);
- }
-
- void impl_preconditions()
- {
- precondition(level::is_greater_or_equal(this->mask, this->marker));
- }
-
- };
-
- }
-
- }
-
-}
Index: oln/morpho/stat.hh
===================================================================
--- oln/morpho/stat.hh (revision 166)
+++ oln/morpho/stat.hh (working copy)
@@ -1,122 +0,0 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005 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_MORPHO_STAT_HH
-# define OLENA_MORPHO_STAT_HH
-
-# include <mlc/cmp.hh>
-# include <ntg/bin.hh>
-# include <oln/core/abstract/image_entry.hh>
-# include <oln/core/abstract/window.hh>
-# include <oln/funobj/accum.hh>
-
-
-namespace oln {
-
- namespace morpho {
-
-
- /// Local min on a function.
-
- template <typename I, typename W>
- oln_type_of(I, value) min(const abstract::image<I>& input,
- const oln_type_of(I, point)& p,
- const abstract::window<W>& win)
- {
- mlc::eq<oln_type_of(I, grid), oln_wn_type_of(W, grid)>::ensure();
-
- oln_wn_type_of(W, fwd_iter) q(win);
- funobj::min_accumulator<oln_type_of(I, value)> minval;
-
- for_all_q_of_p (q, p)
- if (input.hold(q))
- minval(input[q]);
-
- return minval;
- }
-
-
- /// Local min on a set.
-
- template <typename I, typename W>
- bool min(const abstract::binary_image<I>& input,
- const oln_type_of(I, point)& p,
- const abstract::window<W>& win)
- {
- mlc::eq<oln_type_of(I, grid), oln_wn_type_of(W, grid)>::ensure();
-
- oln_wn_type_of(W, fwd_iter) q(win);
- for_all_q_of_p (q, p)
- if (input.hold(q) and not input[q])
- return false;
- return true;
- }
-
-
- /// Local max on a function.
-
- template <typename I, typename W>
- oln_type_of(I, value) max(const abstract::image<I>& input,
- const oln_type_of(I, point)& p,
- const abstract::window<W>& win)
- {
- mlc::eq<oln_type_of(I, grid), oln_wn_type_of(W, grid)>::ensure();
-
- oln_wn_type_of(W, fwd_iter) q(win);
- funobj::max_accumulator<oln_type_of(I, value)> maxval;
-
- for_all_q_of_p (q, p)
- if (input.hold(q))
- maxval(input[q]);
-
- return maxval;
- }
-
-
- /// Local max on a set.
-
- template <typename I, typename W>
- bool max(const abstract::binary_image<I>& input,
- const oln_type_of(I, point)& p,
- const abstract::window<W>& win)
- {
- mlc::eq<oln_type_of(I, grid), oln_wn_type_of(W, grid)>::ensure();
-
- oln_wn_type_of(W, fwd_iter) q(win);
- for_all_q_of_p (q, p)
- if (input.hold(q) and input[q])
- return true;
- return false;
- }
-
-
- } // end of namespace morpho
-
-} // end of namespace oln
-
-
-#endif // ! OLENA_MORPHO_STAT_HH
Index: oln/morpho/erosion.hh
===================================================================
--- oln/morpho/erosion.hh (revision 166)
+++ oln/morpho/erosion.hh (working copy)
@@ -1,220 +0,0 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005 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_MORPHO_EROSION_HH
-# define OLENA_MORPHO_EROSION_HH
-
-# include <mlc/cmp.hh>
-# include <mlc/to_string.hh>
-
-# include <oln/core/abstract/image_operator.hh>
-# include <oln/morpho/stat.hh>
-
-# include <oln/core/2d/window2d.hh>
-
-
-namespace oln {
-
-
- // fwd decl
-
- namespace morpho {
- template <typename I> struct erosion_ret;
-
- template<typename I, typename W>
- erosion_ret<I> erosion(const abstract::image<I>& input,
- const abstract::window<W>& win);
- }
-
- // super_type
-
- template <typename I>
- struct set_super_type< morpho::erosion_ret<I> >
- {
- typedef oln_type_of(I, concrete) output_type;
-
- typedef morpho::erosion_ret<I> self_type;
- typedef abstract::image_unary_operator<output_type, I, self_type > ret;
- };
-
-
-
-
- namespace morpho {
-
-
-
- // Erosion as a 'classical' procedure returning an image (do not
- // use it; prefer morpho::erosion).
-
- namespace proc {
-
- template<typename I, typename W>
- oln_type_of(I, concrete) erosion(const abstract::image<I>& input,
- const abstract::window<W>& win)
- {
- mlc::eq<oln_type_of(I, grid), oln_wn_type_of(W, grid)>::ensure();
- oln_type_of(I, concrete) output(input.size());
- oln_type_of(I, fwd_piter) p(input.size());
- for_all_p (p)
- output[p] = morpho::min(input, p, win);
- return output;
- }
-
- } // end of namespace oln::morpho::proc
-
-
-
- /// Erosion return type.
-
- template <typename I>
- struct erosion_ret : public oln_super_of_(erosion_ret<I>)
- {
- typedef oln_super_of(erosion_ret<I>) super_type;
-
- erosion_ret(const abstract::image<I>& input) :
- super_type(input)
- {
- }
-
- };
-
-
- // Various implementation.
-
-
- namespace impl {
-
-
- /// Generic implementation of erosion (type).
-
- template <typename I, typename W>
- struct generic_erosion : public erosion_ret<I>
- {
- typedef erosion_ret<I> super_type;
- // FIXME: typedef oln_type_of(super_type, output) output_type;
-
- const W& win;
-
- generic_erosion(const abstract::image<I>& input,
- const abstract::window<W>& win) :
- super_type(input),
- win(win.exact())
- {
- }
-
- void impl_run()
- {
- oln_type_of(super_type, output) tmp(this->input.size()); // FIXME: trick
- this->output = tmp;
- // FIXME: output.resize(input.size);
-
- oln_type_of(I, fwd_piter) p(this->input.size());
- for_all_p (p)
- this->output[p] = morpho::min(this->input, p, this->win);
- }
- };
-
- // Generic implementation of erosion (routine).
-
- template<typename I, typename W>
- erosion_ret<I> erosion(const abstract::image<I>& input,
- const abstract::window<W>& win)
- {
- impl::generic_erosion<I,W> tmp(input, win);
- tmp.run();
- return tmp;
- }
-
-
-
-
- /// Rectangle2d implementation of erosion (type).
-
- template <typename I>
- struct rectangle2d_erosion : public erosion_ret<I>
- {
- typedef erosion_ret<I> super_type;
- // FIXME: typedef oln_type_of(super_type, output) output_type;
-
- const win_rectangle2d& win;
-
- rectangle2d_erosion(const abstract::image<I>& input,
- const win_rectangle2d& win) :
- super_type(input),
- win(win)
- {}
-
- void impl_run()
- {
- box<oln_type_of(super_type, output)> temp; // FIXME: box?
- // FIXME: output_type temp;
-
- win_hline2d hline(this->win.width);
- win_vline2d vline(this->win.height);
-
- temp = oln::morpho::erosion(this->input, hline);
- this->output = oln::morpho::erosion(temp, vline);
- }
- };
-
- // Rectangle2d implementation of erosion (routine).
-
- template<typename I>
- erosion_ret<I> erosion(const abstract::image<I>& input,
- const win_rectangle2d& win)
- {
- impl::rectangle2d_erosion<I> tmp(input, win);
- tmp.run();
- return tmp;
- }
-
-
-
-
- } // end of namespace oln::morpho::impl
-
-
-
- /// Generic erosion (facade).
-
- template<typename I, typename W>
- erosion_ret<I> erosion(const abstract::image<I>& input,
- const abstract::window<W>& win)
- {
- mlc::eq<oln_type_of(I, grid), oln_wn_type_of(W, grid)>::ensure();
- return impl::erosion(input.exact(), win.exact());
- }
-
-
- } // end of namespace oln::morpho
-
-
-} // end of namespace oln
-
-
-#endif // ! OLENA_MORPHO_EROSION_HH
Index: oln/morpho/hit_or_miss.hh
===================================================================
--- oln/morpho/hit_or_miss.hh (revision 166)
+++ oln/morpho/hit_or_miss.hh (working copy)
@@ -1,186 +0,0 @@
-// Copyright (C) 2001, 2003, 2004, 2005 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_MORPHO_HIT_OR_MISS_HH
-# define OLENA_MORPHO_HIT_OR_MISS_HH
-
-# include <oln/core/gen/image_with_nbh.hh>
-# include <oln/morpho/erosion.hh>
-# include <oln/morpho/dilation.hh>
-# include <oln/arith/min.hh>
-# include <oln/utils/invert.hh>
-
-namespace oln {
-
- namespace tag {
-
- // No tags yet
-
- } // end of namespace oln::morpho::tag
-
-
- namespace morpho {
- template <typename I, typename W1, typename W2> struct hit_or_miss_ret;
- } // end of namespace oln::morpho
-
- // super_type
-
- template <typename I, typename W1, typename W2>
- struct set_super_type< morpho::hit_or_miss_ret<I, W1, W2> >
- {
- typedef oln_type_of(I, concrete) output_type;
-
- typedef morpho::hit_or_miss_ret<I, W1, W2> self_type;
- typedef abstract::image_unary_operator<output_type, I, self_type > ret;
- };
-
- namespace morpho {
-
- // Reconstruction as a 'classical' procedure returning an image (do not
- // use it; prefer morpho::hit_or_miss).
-
- namespace proc {
-
- // FIXME: ...
-
- } // end of namespace oln::morpho::proc
-
-
- template <typename I, typename W1, typename W2>
- struct hit_or_miss_ret :
- // FIXME: oln_super_of_
- public oln::internal::get_super_type< hit_or_miss_ret<I, W1, W2> >::ret
- {
- typedef hit_or_miss_ret<I, W1, W2> self_type;
- typedef typename oln::internal::get_super_type<self_type>::ret super_type;
- const W1& win1;
- const W2& win2;
-
- hit_or_miss_ret(const abstract::image<I>& input,
- const abstract::regular_window<oln_type_of(I, grid), W1> win1,
- const abstract::regular_window<oln_type_of(I, grid), W2> win2) :
- super_type(input),
- win1(win1.exact()),
- win2(win2.exact())
- {
- }
-
- };
-
-
- namespace impl {
-
- template <typename I, typename W1, typename W2>
- struct generic_hit_or_miss : public hit_or_miss_ret<I, W1, W2>
- {
- typedef hit_or_miss_ret<I, W1, W2> super_type;
-
- generic_hit_or_miss(const abstract::image<I>& input,
- const abstract::regular_window<oln_type_of(I, grid), W1> win1,
- const abstract::regular_window<oln_type_of(I, grid), W2> win2) :
- super_type(input, win1, win2)
- {
- }
-
- void impl_run()
- {
- this->output = arith::min(erosion(this->input, this->win1),
- erosion(utils::invert(this->input),
- this->win2));
- }
- };
-
- template <typename I, typename W1, typename W2>
- hit_or_miss_ret<I, W1, W2>
- hit_or_miss(const abstract::image<I>& input,
- const abstract::regular_window<oln_type_of(I, grid), W1> win1,
- const abstract::regular_window<oln_type_of(I, grid), W2> win2)
- {
- generic_hit_or_miss<I, W1, W2> tmp(input, win1, win2);
- tmp.run();
- return tmp;
- }
-
- } //end of namespace impl
-
- template <typename I, typename W1, typename W2>
- hit_or_miss_ret<I, W1, W2>
- hit_or_miss(const abstract::image<I>& input,
- const abstract::regular_window<oln_type_of(I, grid), W1> win1,
- const abstract::regular_window<oln_type_of(I, grid), W2> win2)
- {
- // FIXME: win1 inter win2 must be empty
- return impl::hit_or_miss(input.exact(), win1.exact(), win2.exact());
- }
-
-
- template<class I, class W1, class W2>
- dilation_ret<hit_or_miss_ret<I, W1, W2>, W1>
- hit_or_miss_opening(const abstract::image<I>& input,
- const abstract::regular_window<oln_type_of(I, grid), W1> win1,
- const abstract::regular_window<oln_type_of(I, grid), W2> win2)
- {
- return dilation(hit_or_miss(input, win1, win2), -win1);
- }
-
- template<class I, class W1, class W2>
- dilation_ret<hit_or_miss_ret<I, W2, W1>, W2>
- hit_or_miss_opening_bg(const abstract::image<I>& input,
- const abstract::regular_window<oln_type_of(I, grid), W1> win1,
- const abstract::regular_window<oln_type_of(I, grid), W2> win2)
- {
- return hit_or_miss_opening(input, win2, win1);
- }
-
- template<class I, class W1, class W2>
- utils::image_inverted<dilation_ret<hit_or_miss_ret<utils::image_inverted<I>,
- W1, W2>, W1> > // !!!
- hit_or_miss_closing(const abstract::image<I>& input,
- const abstract::regular_window<oln_type_of(I, grid), W1> win1,
- const abstract::regular_window<oln_type_of(I, grid), W2> win2)
- {
- return utils::invert(hit_or_miss_opening(utils::invert(input),
- win1, win2));
- }
-
- template<class I, class W1, class W2>
- utils::image_inverted<dilation_ret<hit_or_miss_ret<utils::image_inverted<I>,
- W2, W1>, W2> > // !!!
- hit_or_miss_closing_bg(const abstract::image<I>& input,
- const abstract::regular_window<oln_type_of(I, grid), W1> win1,
- const abstract::regular_window<oln_type_of(I, grid), W2> win2)
- {
- return hit_or_miss_closing(input, win2, win1);
- }
-
-
-
- } // end of namespace morpho
-
-} // end of namespace oln
-
-#endif // ! OLENA_MORPHO_HIT_OR_MISS_HH
Index: oln/morpho/geodesic_erosion.hh
===================================================================
--- oln/morpho/geodesic_erosion.hh (revision 166)
+++ oln/morpho/geodesic_erosion.hh (working copy)
@@ -1,140 +0,0 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005 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_MORPHO_GEODESIC_EROSION_HH
-# define OLENA_MORPHO_GEODESIC_EROSION_HH
-
-# include <mlc/cmp.hh>
-
-# include <oln/core/abstract/image_operator.hh>
-# include <oln/morpho/stat.hh>
-# include <oln/level/compare.hh>
-# include <oln/arith/max.hh>
-
-# include <oln/core/abstract/neighborhood.hh>
-# include <oln/morpho/erosion.hh>
-
-namespace oln {
-
- namespace morpho {
-
- // fwd declaration
- template <class I1, class I2> struct geodesic_erosion_ret;
-
- namespace proc {
-
- template<class I1, class I2>
- oln_type_of(I1, concrete)
- geodesic_erosion(const abstract::image_with_nbh<I1>& marker,
- const abstract::image<I2>& mask)
- {
- mlc::eq<oln_type_of(I1, size), oln_type_of(I2, size)>::ensure();
- precondition(marker.size() == mask.size());
- precondition(level::is_greater_or_equal(marker, mask));
- oln_type_of(I1, concrete) output(marker.size());
- // FIXME: Useless?
- // marker.border_adapt_copy(marker.nbh_get().delta());
- oln_type_of(I1, piter) p(marker.size());
- for_all_p (p)
- {
- oln_type_of(I1, value) a =
- morpho::min(marker, p, marker.nbh_get().get_win());
- oln_type_of(I2, value) b = mask[p];
- // Max.
- output[p] = a > b ? a : b;
- }
- return output;
- }
-
- } // end of namespace oln::morpho::proc
-
- } // end of namespace oln::morpho
-
-
- // super_type
- template <class I1, class I2>
- struct set_super_type< morpho::geodesic_erosion_ret<I1, I2> >
- {
- typedef abstract::image_binary_operator<oln_type_of(I1, concrete), I1, I2, morpho::geodesic_erosion_ret<I1, I2> > ret;
- };
-
-
- namespace morpho {
-
- template <class I1, class I2>
- struct geodesic_erosion_ret : public abstract::image_binary_operator<oln_type_of(I1, concrete), I1, I2, morpho::geodesic_erosion_ret<I1, I2> >
- {
- typedef abstract::image_binary_operator<oln_type_of(I1, concrete), I1, I2, geodesic_erosion_ret<I1, I2> > super_type;
-
- geodesic_erosion_ret(const abstract::image_with_nbh<I1>& marker,
- const abstract::image<I2>& mask) :
- super_type(marker, mask)
- {}
- };
-
-
- namespace safe {
-
- template <class I1, class I2>
- struct geodesic_erosion : public geodesic_erosion_ret<I1, I2>
- {
- typedef geodesic_erosion_ret<I1, I2> super_type;
-
- geodesic_erosion(const abstract::image_with_nbh<I1>& marker,
- const abstract::image<I2>& mask) :
- super_type(marker, mask)
- {}
-
- void impl_run()
- {
- mlc::eq<oln_type_of(I1, size), oln_type_of(I2, size)>::ensure();
- precondition((this->input1).size() == (this->input2).size());
- precondition(level::is_greater_or_equal(this->input1, this->input2));
- this->output =
- arith::max(erosion(this->input1.unbox(),
- this->input1.unbox().nbh_get().get_win()).output.unbox(),
- this->input2.unbox()).output;
- }
- };
-
- } // end of namespace oln::morpho::safe
-
- template<class I1, class I2>
- geodesic_erosion_ret<I1, I2>
- geodesic_erosion(const abstract::image_with_nbh<I1>& marker,
- const abstract::image<I2>& mask)
- {
- safe::geodesic_erosion<I1, I2> tmp(marker, mask);
- tmp.run();
- return tmp;
- }
-
- } // end of namespace oln::morpho
-
-} // end of namespace oln
-
-#endif // OLENA_MORPHO_GEODESIC_EROSION_HH
1
0
2005-04-27 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Prepare naming and tracing features to come.
* oln/utils/record.hh: New file.
* oln/core/2d/image2d.hh (operator=io): Update to not call io.
* oln/core/abstract/image_constness.hh (set): Move method's body
to...
* oln/core/box.hh: ...here.
* oln/core/abstract/image.hh (impl_hold_large): Change call to
'impl_hold' to avoid counting a call to 'hold'.
(hold, get): Move method's body to...
* oln/core/box.hh: ...here.
* oln/core/abstract/data_storage.hh (record): New include.
(hold, get, set): Add call count.
(set_data): Comment cause unused.
* oln/core/abstract/image_with_data.hh (operator=): New
operator so that we will control the naming process to come.
* oln/core/abstract/image_by_delegation.hh
(operator=): Likewise.
* oln/core/2d/image2d.hh: New constructors with 'naming'.
* oln/core/gen/image_with_nbh.hh: Likewise.
(join): Add naming.
* oln/core/abstract/images.hh: Remove because error-prone
when included ---when 'watching' we need 'box' that depends
on image hierarchies so including this intermediate file
leads to partially defined class.
* oln/core/abstract/image_entry.hh: Update file inclusion.
* oln/basics.hh: Update.
* oln/utils/md5.hh: Likewise.
* oln/utils/clone.hh: Likewise.
* oln/basics.hh: Likewise.
* oln/morpho/stat.hh: Likewise.
* oln/morpho/erosion.hh: Likewise.
* oln/morpho/closing.hh: Likewise.
* oln/morpho/opening.hh: Likewise.
Index: oln/core/abstract/image_constness.hh
===================================================================
--- oln/core/abstract/image_constness.hh (revision 166)
+++ oln/core/abstract/image_constness.hh (working copy)
@@ -30,6 +30,18 @@
# include <oln/core/abstract/image.hh>
+
+// image
+//
+// ^
+// |
+// ---------------
+// | |
+//
+// readonly_image readwrite_image
+
+
+
/*! \namespace oln
** \brief oln namespace.
*/
@@ -100,10 +112,7 @@
** \see value_box, abstract::image<I>::operator[](point)
*/
- void set(const point_type& p, const value_type& v)
- {
- return this->exact().impl_set(p, v);
- }
+ void set(const point_type& p, const value_type& v); // impl is in image_entry.hh
// FIXME: NEW:
Index: oln/core/abstract/image.hh
===================================================================
--- oln/core/abstract/image.hh (revision 166)
+++ oln/core/abstract/image.hh (working copy)
@@ -247,11 +247,7 @@
** \see hold_large
*/
- bool hold(const point_type& p) const
- {
- precondition(this->npoints() != 0);
- return this->exact().impl_hold(p);
- }
+ bool hold(const point_type& p) const; // impl is in box.hh
/*! \brief Test if \a p is a proper point to access a value of
@@ -287,7 +283,9 @@
bool impl_hold_large(const point_type& p) const
{
- return this->hold(p);
+ // it relies on 'impl_hold' to avoid counting one call to
+ // 'hold' when the effective call is 'hold_large'
+ return this->exact().impl_hold(p);
}
@@ -371,10 +369,7 @@
** \see value_box, abstract::image<I>::operator[](point)
*/
- const value_type get(const point_type& p) const
- {
- return this->exact().impl_get(p);
- }
+ const value_type get(const point_type& p) const; // impl is in box.hh
// FIXME: patch!
Index: oln/core/abstract/data_storage.hh
===================================================================
--- oln/core/abstract/data_storage.hh (revision 166)
+++ oln/core/abstract/data_storage.hh (working copy)
@@ -31,6 +31,7 @@
# include <mlc/any.hh>
# include <mlc/to_string.hh>
# include <oln/core/typedefs.hh>
+# include <oln/utils/record.hh>
# define oln_ds_type_of(DataStorageType, Alias) \
@@ -133,6 +134,9 @@
{
if (! this->has_data())
return false;
+# ifdef OLNTRACE
+ inc_ncalls("data_hold", *this);
+# endif // ! OLNTRACE
return this->exact().impl_hold(p);
}
@@ -140,6 +144,9 @@
{
precondition(this->has_data());
precondition(this->hold_large(p));
+# ifdef OLNTRACE
+ inc_ncalls("data_get", *this);
+# endif // ! OLNTRACE
return this->exact().impl_get(p);
}
@@ -147,15 +154,21 @@
{
precondition(this->has_data());
precondition(this->hold_large(p));
+# ifdef OLNTRACE
+ inc_ncalls("data_set", *this);
+# endif // ! OLNTRACE
this->exact().impl_set(p, v);
}
- void set_data(const data_type& v)
- {
- precondition(this->has_data());
- this->exact().impl_set_data(v);
- }
+ // FIXME: commented below cause unused...
+// void set_data(const data_type& v)
+// {
+// precondition(this->has_data());
+// this->exact().impl_set_data(v);
+// }
+
+
// polymorphic method with default
bool hold_large(const point_type& p) const
Index: oln/core/abstract/image_entry.hh
===================================================================
--- oln/core/abstract/image_entry.hh (revision 166)
+++ oln/core/abstract/image_entry.hh (working copy)
@@ -28,7 +28,11 @@
#ifndef OLENA_CORE_ABSTRACT_IMAGE_ENTRY_HH
# define OLENA_CORE_ABSTRACT_IMAGE_ENTRY_HH
-# include <oln/core/abstract/images.hh>
+# include <oln/core/abstract/image_constness.hh>
+# include <oln/core/abstract/image_dimension.hh>
+# include <oln/core/abstract/image_neighbness.hh>
+# include <oln/core/abstract/image_typeness.hh>
+# include <oln/core/abstract/image_valuedness.hh>
Index: oln/core/abstract/images.hh
===================================================================
--- oln/core/abstract/images.hh (revision 166)
+++ oln/core/abstract/images.hh (working copy)
@@ -1,47 +0,0 @@
-// Copyright (C) 2005 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_CORE_ABSTRACT_IMAGES_HH
-# define OLENA_CORE_ABSTRACT_IMAGES_HH
-
-
-# include <oln/core/abstract/image.hh>
-
-// hierarchies:
-# include <oln/core/abstract/image_constness.hh>
-# include <oln/core/abstract/image_dimension.hh>
-# include <oln/core/abstract/image_neighbness.hh>
-# include <oln/core/abstract/image_typeness.hh>
-# include <oln/core/abstract/image_valuedness.hh>
-
-
-// hierarchy entry
-# include <oln/core/abstract/image_entry.hh>
-
-
-
-#endif // ! OLENA_CORE_ABSTRACT_IMAGES_HH
Index: oln/core/abstract/image_with_data.hh
===================================================================
--- oln/core/abstract/image_with_data.hh (revision 166)
+++ oln/core/abstract/image_with_data.hh (working copy)
@@ -31,6 +31,7 @@
# include <mlc/tracked_ptr.hh>
# include <oln/core/abstract/image_entry.hh>
+# include <oln/utils/record.hh>
/*! \namespace oln
@@ -201,6 +202,17 @@
this->data_ = rhs.data_;
}
+
+ /*! \brief Op= constructor (protected) with shallow data copy.
+ */
+ image_with_data& operator=(image_with_data& rhs)
+ {
+ // FIXME: handle naming here...
+ this->data_ = rhs.data_;
+ return *this;
+ }
+
+
/*! \brief Data storage.
*/
mlc::tracked_ptr<storage_type> data_;
Index: oln/core/abstract/image_by_delegation.hh
===================================================================
--- oln/core/abstract/image_by_delegation.hh (revision 166)
+++ oln/core/abstract/image_by_delegation.hh (working copy)
@@ -92,15 +92,24 @@
this->exact_ptr = (E*)(void*)(this);
}
+ image_by_delegation& operator=(const image_by_delegation& rhs)
+ {
+ // FIXME: handle naming here...
+ this->image_ = rhs.image_;
+ return *this;
+ }
+
box<I> image_;
public:
- I& image() { return this->image_.unbox(); }
+ I& image() const { return this->image_.unbox(); }
I& impl_delegate() { return this->image_.unbox(); }
const I& impl_delegate() const { return this->image_.unbox(); }
};
+
+
/// Const version of image_by_delegation
template <typename I, typename E>
@@ -125,6 +134,13 @@
this->exact_ptr = (E*)(void*)(this);
}
+ image_by_delegation& operator=(const image_by_delegation& rhs)
+ {
+ // FIXME: handle naming here...
+ this->image_ = rhs.image_;
+ return *this;
+ }
+
box<const I> image_;
public:
Index: oln/core/2d/image2d.hh
===================================================================
--- oln/core/2d/image2d.hh (revision 166)
+++ oln/core/2d/image2d.hh (working copy)
@@ -32,6 +32,7 @@
# include <oln/core/abstract/image_like_.hh>
# include <oln/core/2d/array2d.hh>
# include <oln/core/2d/niter2d.hh>
+# include <oln/utils/record.hh>
/*! \namespace oln
@@ -122,46 +123,85 @@
this->exact_ptr = this;
}
- image2d(const size2d& size) : super_type(size)
+ image2d(const std::string& name)
{
this->exact_ptr = this;
+ registering(*this, name);
}
+ image2d(const size2d& size) :
+ super_type(size)
+ {
+ this->exact_ptr = this;
+ }
+
+ image2d(const size2d& size,
+ const std::string& name) :
+ super_type(size)
+ {
+ this->exact_ptr = this;
+ registering(*this, name);
+ }
+
image2d(coord_t nrows, coord_t ncols, size_t border = 2) :
super_type(size2d(nrows, ncols, border))
{
this->exact_ptr = this;
}
+ image2d(coord_t nrows, coord_t ncols, size_t border,
+ const std::string& name) :
+ super_type(size2d(nrows, ncols, border))
+ {
+ this->exact_ptr = this;
+ registering(*this, name);
+ }
+
image2d(image2d& rhs) :
super_type(rhs)
{
this->exact_ptr = this;
}
- image2d& operator=(image2d& rhs)
+
+ image2d& operator=(image2d rhs)
{
- if (&rhs == this)
- return *this;
+ // FIXME: check that both objects are *really* different
super_type::operator=(rhs);
return *this;
};
- template <typename I, typename E>
- image2d& operator=(abstract::image_like_<I, E> rhs)
- {
- *this = rhs.real();
- return *this;
- }
+// image2d& operator=(box<image2d> rhs)
+// {
+// std::cout << "hop(box)" << std::endl;
+// if (&(rhs->unbox()) == this)
+// return *this;
+// super_type::operator=(rhs.unbox());
+// return *this;
+// };
+// template <typename I, typename E>
+// image2d& operator=(abstract::image_like_<I, E> rhs)
+// {
+// *this = rhs.real();
+// return *this;
+// }
+
image2d& operator=(const io::filename& rhs)
{
- io::do_read(*this, rhs);
+ // FIXME HERE: hack to avoid calling io
+// io::do_read(*this, rhs);
+ image2d tmp(4, 4);
+ *this = tmp;
return *this;
}
// FIXME: idem with abstract::image2d<E> (?)
+
+ // without impl
+ image2d(const image2d&);
+
};
Index: oln/core/box.hh
===================================================================
--- oln/core/box.hh (revision 166)
+++ oln/core/box.hh (working copy)
@@ -240,7 +240,63 @@
};
-}
+} // end of namespace oln
+
+# include <oln/utils/record.hh>
+
+
+
+namespace oln {
+
+ namespace abstract
+ {
+
+
+ /// Implementation of abstract::image<E>::hold(p).
+
+ template <typename E>
+ bool
+ image<E>::hold(const oln_type_of(E, point)& p) const
+ {
+# ifdef OLNTRACE
+ inc_ncalls("hold", *this);
+# endif // ! OLNTRACE
+ return this->exact().impl_hold(p);
+ }
+
+
+ /// Implementation of abstract::image<E>::get(p).
+
+ template <typename E>
+ const oln_type_of(E, value)
+ image<E>::get(const oln_type_of(E, point)& p) const
+ {
+# ifdef OLNTRACE
+ inc_ncalls("get", *this);
+# endif // ! OLNTRACE
+ return this->exact().impl_get(p);
+ }
+
+
+ /// Implementation of abstract::readwrite_image<E>::set(p, v).
+
+ template <typename E>
+ void
+ readwrite_image<E>::set(const oln_type_of(E, point)& p,
+ const oln_type_of(E, value)& v)
+ {
+# ifdef OLNTRACE
+ inc_ncalls("set", *this);
+# endif // ! OLNTRACE
+ return this->exact().impl_set(p, v);
+ }
+
+
+ } // end of namespace oln::abstract
+
+} // end of namespace oln
+
+
#endif // ! OLENA_CORE_BOX_HH
Index: oln/core/gen/image_with_nbh.hh
===================================================================
--- oln/core/gen/image_with_nbh.hh (revision 167)
+++ oln/core/gen/image_with_nbh.hh (working copy)
@@ -30,7 +30,9 @@
# include <oln/core/abstract/image_with_extension.hh>
# include <oln/core/abstract/neighborhood.hh>
+# include <oln/utils/record.hh>
+
namespace oln {
// fwd decl
@@ -51,6 +53,7 @@
typedef image_with_nbh< oln_type_of(I, concrete), N> concrete_type;
};
+
template <typename I, typename N>
struct image_with_nbh : public abstract::image_with_extension < I, image_with_nbh<I, N> >
{
@@ -76,13 +79,34 @@
{
}
+ image_with_nbh(const std::string& name)
+ {
+ registering(*this, name);
+ }
+
+ image_with_nbh(const oln_type_of(I, size)& size,
+ const std::string& name)
+ {
+ // FIXME: illegal hardware instruction when uncommented below!!!
+// I tmp(size, name);
+ // FIXME: other attemps below
+// registering(tmp, name, true);
+// tmp.set_name(name);
+
+ I tmp(size); // FIXME: hack
+ this->image_ = tmp;
+ registering(*this, name); //, true);
+ }
+
image_with_nbh(abstract::image<I>& image,
- const abstract::neighborhood<N>& nbh) :
+ const abstract::neighborhood<N>& nbh,
+ const std::string& name) :
super_type(image),
nbh_(nbh.exact())
{
+ registering(*this, name);
}
-
+
const N& impl_nbh_get() const
{
return nbh_;
@@ -98,10 +122,14 @@
template <typename I, typename N>
image_with_nbh<I, N>
- join(abstract::image<I>& image,
- const abstract::neighborhood<N>& nbh)
+ join(abstract::image<I>& image, const abstract::neighborhood<N>& nbh)
{
- image_with_nbh<I, N> tmp(image, nbh);
+ entering("join(image,nbh)");
+ registering(image, "image");
+
+ image_with_nbh<I, N> tmp(image, nbh, "tmp");
+
+ exiting("join(image,nbh)");
return tmp;
}
Index: oln/utils/md5.hh
===================================================================
--- oln/utils/md5.hh (revision 166)
+++ oln/utils/md5.hh (working copy)
@@ -31,7 +31,7 @@
# include <ntg/all.hh>
# include <vector>
-# include <oln/core/abstract/images.hh>
+# include <oln/core/abstract/image_entry.hh>
# include <oln/core/abstract/piter.hh>
# include <oln/utils/key.hh>
Index: oln/utils/record.hh
===================================================================
--- oln/utils/record.hh (revision 0)
+++ oln/utils/record.hh (revision 0)
@@ -0,0 +1,61 @@
+// Copyright (C) 2005 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_OLN_UTILS_RECORD_HH
+# define OLENA_OLN_UTILS_RECORD_HH
+
+# include <string>
+
+
+namespace oln
+{
+
+ void entering(const std::string& local_context_name)
+ {
+ }
+
+ void exiting(const std::string& local_context_name)
+ {
+ }
+
+ template <typename T>
+ void inc_ncalls(const std::string& code_name,
+ const T& obj)
+ {
+ }
+
+ template <typename T>
+ void registering(const T& obj,
+ const std::string& var_name)
+ {
+ }
+
+} // end of namespace oln
+
+
+
+#endif // ! OLENA_OLN_UTILS_RECORD_HH
Index: oln/utils/clone.hh
===================================================================
--- oln/utils/clone.hh (revision 166)
+++ oln/utils/clone.hh (working copy)
@@ -29,6 +29,7 @@
# define OLN_UTILS_CLONE_HH
# include <oln/basics.hh>
+# include <oln/core/abstract/image_operator.hh>
namespace oln {
Index: oln/basics.hh
===================================================================
--- oln/basics.hh (revision 166)
+++ oln/basics.hh (working copy)
@@ -25,8 +25,6 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-
-
#ifndef OLENA_BASICS_HH
# define OLENA_BASICS_HH
@@ -47,12 +45,15 @@
// ntg::
+// FIXME: include a fake ntg/decls.hh that should be in oln/
+
+
// oln::
-# include <oln/core/typedefs.hh>
-# include <oln/core/box.hh>
+# include <oln/core/coord.hh> // FIXME: why?
-# include <oln/core/coord.hh>
+# include <oln/core/abstract/image.hh>
+# include <oln/core/abstract/image_entry.hh>
# include <oln/core/abstract/size.hh>
# include <oln/core/abstract/point.hh>
@@ -60,9 +61,6 @@
# include <oln/core/abstract/window.hh>
# include <oln/core/abstract/neighborhood.hh>
-# include <oln/core/abstract/images.hh>
-# include <oln/core/abstract/image_operator.hh>
-
# include <oln/core/abstract/piter.hh>
# include <oln/core/abstract/qiter.hh>
# include <oln/core/abstract/niter.hh>
Index: oln/morpho/stat.hh
===================================================================
--- oln/morpho/stat.hh (revision 166)
+++ oln/morpho/stat.hh (working copy)
@@ -30,7 +30,7 @@
# include <mlc/cmp.hh>
# include <ntg/bin.hh>
-# include <oln/core/abstract/images.hh>
+# include <oln/core/abstract/image_entry.hh>
# include <oln/core/abstract/window.hh>
# include <oln/funobj/accum.hh>
Index: oln/morpho/erosion.hh
===================================================================
--- oln/morpho/erosion.hh (revision 166)
+++ oln/morpho/erosion.hh (working copy)
@@ -31,7 +31,6 @@
# include <mlc/cmp.hh>
# include <mlc/to_string.hh>
-# include <oln/core/abstract/images.hh>
# include <oln/core/abstract/image_operator.hh>
# include <oln/morpho/stat.hh>
Index: oln/morpho/closing.hh
===================================================================
--- oln/morpho/closing.hh (revision 166)
+++ oln/morpho/closing.hh (working copy)
@@ -31,7 +31,6 @@
# include <mlc/cmp.hh>
# include <mlc/to_string.hh>
-# include <oln/core/abstract/images.hh>
# include <oln/core/abstract/image_operator.hh>
# include <oln/morpho/dilation.hh>
Index: oln/morpho/opening.hh
===================================================================
--- oln/morpho/opening.hh (revision 166)
+++ oln/morpho/opening.hh (working copy)
@@ -31,7 +31,6 @@
# include <mlc/cmp.hh>
# include <mlc/to_string.hh>
-# include <oln/core/abstract/images.hh>
# include <oln/core/abstract/image_operator.hh>
# include <oln/morpho/dilation.hh>
1
0
2005-04-27 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Files related to io should be re-written so they are temporary
commented.
* oln/io/gz_stream.hh: Comment contents.
* oln/io/write_image_2d_pnm.hh: Likewise.
* oln/io/write_image.hh: Likewise.
* oln/io/read_image_2d_pnm.hh: Likewise.
* oln/io/read_image.hh: Likewise.
* oln/io/utils.hh: Likewise.
* tests/io/loadsave.hh: Update.
Index: tests/io/loadsave.hh
===================================================================
--- tests/io/loadsave.hh (revision 166)
+++ tests/io/loadsave.hh (working copy)
@@ -40,10 +40,11 @@
im1 = oln::io::read(name);
- oln::io::write(im1, savename);
+// oln::io::write(im1, savename);
- im2 = oln::io::read(savename);
+// im2 = oln::io::read(savename);
+ im2 = oln::io::read(name);
if (compare(im1, im2) == true)
std::cout << "OK" << std::endl;
Index: oln/io/gz_stream.hh
===================================================================
--- oln/io/gz_stream.hh (revision 166)
+++ oln/io/gz_stream.hh (working copy)
@@ -28,455 +28,455 @@
#ifndef OLN_IO_GZ_STREAM_HH
# define OLN_IO_GZ_STREAM_HH
-# include <oln/config/system.hh>
+// # include <oln/config/system.hh>
-#if defined HAVE_ZLIB && HAVE_ZLIB == 1
-# include <cassert>
-# include <fstream>
-# include <string>
-# include <zlib.h>
+// #if defined HAVE_ZLIB && HAVE_ZLIB == 1
+// # include <cassert>
+// # include <fstream>
+// # include <string>
+// # include <zlib.h>
-namespace oln {
+// namespace oln {
- namespace io {
+// namespace io {
- /// Functions for gz files
- namespace gz {
+// /// Functions for gz files
+// namespace gz {
- ///Performs operation on compressed files.
- class zfilebuf : public std::streambuf
- {
- public:
+// ///Performs operation on compressed files.
+// class zfilebuf : public std::streambuf
+// {
+// public:
- zfilebuf() : file(0), mode(0), own_file_descriptor(0)
- {
- inbuf = new char[lenbuf];
- outbuf = new char[lenbuf];
- setg(0, 0, 0);
- setp(outbuf, outbuf + lenbuf);
- }
+// zfilebuf() : file(0), mode(0), own_file_descriptor(0)
+// {
+// inbuf = new char[lenbuf];
+// outbuf = new char[lenbuf];
+// setg(0, 0, 0);
+// setp(outbuf, outbuf + lenbuf);
+// }
- virtual ~zfilebuf()
- {
- sync();
- delete[] inbuf;
- delete[] outbuf;
- if (own_file_descriptor)
- close();
- }
+// virtual ~zfilebuf()
+// {
+// sync();
+// delete[] inbuf;
+// delete[] outbuf;
+// if (own_file_descriptor)
+// close();
+// }
- /*! \brief Return a stream on the file \a name regarding
- ** the opening mode: \a io_mode.
- */
- zfilebuf*
- open(const char *name, int io_mode)
- {
- if (is_open())
- return 0;
+// /*! \brief Return a stream on the file \a name regarding
+// ** the opening mode: \a io_mode.
+// */
+// zfilebuf*
+// open(const char *name, int io_mode)
+// {
+// if (is_open())
+// return 0;
- char char_mode[10];
- char *p;
- memset(char_mode,'\0',10);
- p = char_mode;
+// char char_mode[10];
+// char *p;
+// memset(char_mode,'\0',10);
+// p = char_mode;
- if (io_mode & std::ios::in)
- {
- mode = std::ios::in;
- *p++ = 'r';
- }
- else
- if (io_mode & std::ios::app)
- {
- mode = std::ios::app;
- *p++ = 'a';
- }
- else
- {
- mode = std::ios::out;
- *p++ = 'w';
- }
- if (io_mode & std::ios::binary)
- {
- mode |= std::ios::binary;
- *p++ = 'b';
- }
+// if (io_mode & std::ios::in)
+// {
+// mode = std::ios::in;
+// *p++ = 'r';
+// }
+// else
+// if (io_mode & std::ios::app)
+// {
+// mode = std::ios::app;
+// *p++ = 'a';
+// }
+// else
+// {
+// mode = std::ios::out;
+// *p++ = 'w';
+// }
+// if (io_mode & std::ios::binary)
+// {
+// mode |= std::ios::binary;
+// *p++ = 'b';
+// }
- // Hard code the compression level
- if (io_mode & (std::ios::out|std::ios::app))
- *p++ = '9';
+// // Hard code the compression level
+// if (io_mode & (std::ios::out|std::ios::app))
+// *p++ = '9';
- if ((file = gzopen(name, char_mode)) == 0)
- return 0;
+// if ((file = gzopen(name, char_mode)) == 0)
+// return 0;
- name_ = name;
- own_file_descriptor = 1;
- return this;
- }
+// name_ = name;
+// own_file_descriptor = 1;
+// return this;
+// }
- /*! \brief Attach a stream on \a file_descriptor regarding
- ** the opening mode: \a io_mode.
- */
- zfilebuf*
- attach(int file_descriptor, int io_mode)
- {
- if (is_open())
- return 0;
+// /*! \brief Attach a stream on \a file_descriptor regarding
+// ** the opening mode: \a io_mode.
+// */
+// zfilebuf*
+// attach(int file_descriptor, int io_mode)
+// {
+// if (is_open())
+// return 0;
- char char_mode[10];
- char *p;
- memset(char_mode,'\0',10);
- p = char_mode;
+// char char_mode[10];
+// char *p;
+// memset(char_mode,'\0',10);
+// p = char_mode;
- if (io_mode & std::ios::in)
- {
- mode = std::ios::in;
- *p++ = 'r';
- }
- else
- if (io_mode & std::ios::app)
- {
- mode = std::ios::app;
- *p++ = 'a';
- }
- else
- {
- mode = std::ios::out;
- *p++ = 'w';
- }
+// if (io_mode & std::ios::in)
+// {
+// mode = std::ios::in;
+// *p++ = 'r';
+// }
+// else
+// if (io_mode & std::ios::app)
+// {
+// mode = std::ios::app;
+// *p++ = 'a';
+// }
+// else
+// {
+// mode = std::ios::out;
+// *p++ = 'w';
+// }
- if (io_mode & std::ios::binary)
- {
- mode |= std::ios::binary;
- *p++ = 'b';
- }
+// if (io_mode & std::ios::binary)
+// {
+// mode |= std::ios::binary;
+// *p++ = 'b';
+// }
- // Hard code the compression level
- if (io_mode & (std::ios::out|std::ios::app))
- *p++ = '9';
+// // Hard code the compression level
+// if (io_mode & (std::ios::out|std::ios::app))
+// *p++ = '9';
- if ((file = gzdopen(file_descriptor, char_mode)) == 0)
- return 0;
+// if ((file = gzdopen(file_descriptor, char_mode)) == 0)
+// return 0;
- own_file_descriptor = 0;
- return this;
- }
+// own_file_descriptor = 0;
+// return this;
+// }
- /// Close the stream.
- zfilebuf*
- close()
- {
- if (is_open())
- {
- sync();
- gzclose(file);
- file = 0;
- }
- return this;
- }
+// /// Close the stream.
+// zfilebuf*
+// close()
+// {
+// if (is_open())
+// {
+// sync();
+// gzclose(file);
+// file = 0;
+// }
+// return this;
+// }
- int
- setcompressionlevel(short comp_level)
- {
- return gzsetparams(file, comp_level, -2);
- }
+// int
+// setcompressionlevel(short comp_level)
+// {
+// return gzsetparams(file, comp_level, -2);
+// }
- int
- setcompressionstrategy(short comp_strategy)
- {
- return gzsetparams(file, -2, comp_strategy);
- }
+// int
+// setcompressionstrategy(short comp_strategy)
+// {
+// return gzsetparams(file, -2, comp_strategy);
+// }
- /// Return true if the stream is open, false otherwise.
- inline int
- is_open() const
- { return (file != 0); }
+// /// Return true if the stream is open, false otherwise.
+// inline int
+// is_open() const
+// { return (file != 0); }
- virtual std::streampos
- seekoff(std::streamoff off, std::ios::seekdir dir, int) // which)
- {
- return std::streampos(gzseek(file, off, dir));
- }
+// virtual std::streampos
+// seekoff(std::streamoff off, std::ios::seekdir dir, int) // which)
+// {
+// return std::streampos(gzseek(file, off, dir));
+// }
- /// Flush the buffer associated to the stream.
- virtual int
- sync()
- {
- if (!is_open())
- return EOF;
- return flushbuf();
- }
+// /// Flush the buffer associated to the stream.
+// virtual int
+// sync()
+// {
+// if (!is_open())
+// return EOF;
+// return flushbuf();
+// }
- protected:
+// protected:
- /*! \brief Return the next character in the stream.
- ** On failure, \a EOF is returned.
- */
- virtual int
- underflow()
- {
- // If the file hasn't been opened for reading, error.
- if (!is_open() || !(mode & std::ios::in))
- return EOF;
+// /*! \brief Return the next character in the stream.
+// ** On failure, \a EOF is returned.
+// */
+// virtual int
+// underflow()
+// {
+// // If the file hasn't been opened for reading, error.
+// if (!is_open() || !(mode & std::ios::in))
+// return EOF;
- if (in_avail())
- return (unsigned char) *gptr();
+// if (in_avail())
+// return (unsigned char) *gptr();
- if (flushbuf() == EOF)
- return EOF;
+// if (flushbuf() == EOF)
+// return EOF;
- // Attempt to fill the buffer.
- if (fillbuf() == EOF)
- return EOF;
+// // Attempt to fill the buffer.
+// if (fillbuf() == EOF)
+// return EOF;
- assert (eback());
+// assert (eback());
- return (unsigned char) *gptr();
- }
+// return (unsigned char) *gptr();
+// }
- /*! \brief Flush the output buffer associated to the stream
- ** then write \a c. On failure, \a EOF is returned.
- */
+// /*! \brief Flush the output buffer associated to the stream
+// ** then write \a c. On failure, \a EOF is returned.
+// */
- virtual int
- overflow(int c = EOF)
- {
- if (!is_open() || !(mode & std::ios::out))
- return EOF;
+// virtual int
+// overflow(int c = EOF)
+// {
+// if (!is_open() || !(mode & std::ios::out))
+// return EOF;
- assert (pbase());
+// assert (pbase());
- if (flushbuf() == EOF)
- return EOF;
+// if (flushbuf() == EOF)
+// return EOF;
- if (c != EOF)
- {
- *pptr() = c;
- pbump(1);
- }
- return 0;
- }
+// if (c != EOF)
+// {
+// *pptr() = c;
+// pbump(1);
+// }
+// return 0;
+// }
- private:
+// private:
- gzFile file;
- short mode;
- short own_file_descriptor;
- std::string name_;
- char *inbuf;
- char *outbuf;
- static const int lenbuf = 16 * 1024;
+// gzFile file;
+// short mode;
+// short own_file_descriptor;
+// std::string name_;
+// char *inbuf;
+// char *outbuf;
+// static const int lenbuf = 16 * 1024;
- /// Flush the output buffer
- int
- flushbuf()
- {
- int n = pptr() - outbuf;
+// /// Flush the output buffer
+// int
+// flushbuf()
+// {
+// int n = pptr() - outbuf;
- if (n == 0)
- return 0;
+// if (n == 0)
+// return 0;
- if (gzwrite(file, outbuf, n) < n)
- return EOF;
+// if (gzwrite(file, outbuf, n) < n)
+// return EOF;
- setp(outbuf, outbuf + lenbuf);
- return 0;
- }
- /// Fill the input buffer.
- int
- fillbuf()
- {
- int t = gzread(file, inbuf, lenbuf);
- if (t <= 0) return EOF;
- setg(inbuf, inbuf, inbuf + t);
- return t;
- }
+// setp(outbuf, outbuf + lenbuf);
+// return 0;
+// }
+// /// Fill the input buffer.
+// int
+// fillbuf()
+// {
+// int t = gzread(file, inbuf, lenbuf);
+// if (t <= 0) return EOF;
+// setg(inbuf, inbuf, inbuf + t);
+// return t;
+// }
- };
+// };
- ///Define an interface for compressed file stream manipulation.
- class zfilestream_common : virtual public std::ios
- {
- friend class zifstream;
- friend class zofstream;
- friend zofstream &setcompressionlevel(zofstream &, int);
- friend zofstream &setcompressionstrategy(zofstream &, int);
+// ///Define an interface for compressed file stream manipulation.
+// class zfilestream_common : virtual public std::ios
+// {
+// friend class zifstream;
+// friend class zofstream;
+// friend zofstream &setcompressionlevel(zofstream &, int);
+// friend zofstream &setcompressionstrategy(zofstream &, int);
- public:
- virtual ~zfilestream_common() {}
+// public:
+// virtual ~zfilestream_common() {}
- /*! \brief Open the stream on the file descriptor:
- ** \a fd regarding the opening mode.
- */
- void
- attach(int fd, int io_mode)
- {
- if (!buffer.attach(fd, io_mode))
- clear(std::ios::failbit | std::ios::badbit);
- else
- clear();
- }
+// /*! \brief Open the stream on the file descriptor:
+// ** \a fd regarding the opening mode.
+// */
+// void
+// attach(int fd, int io_mode)
+// {
+// if (!buffer.attach(fd, io_mode))
+// clear(std::ios::failbit | std::ios::badbit);
+// else
+// clear();
+// }
- /*! \brief Open the stream on the file named \a name
- ** regarding the opening mode.
- */
- void
- open(const char *name, int io_mode)
- {
- if (!buffer.open(name, io_mode))
- clear(std::ios::failbit | std::ios::badbit);
- else
- clear();
- }
+// /*! \brief Open the stream on the file named \a name
+// ** regarding the opening mode.
+// */
+// void
+// open(const char *name, int io_mode)
+// {
+// if (!buffer.open(name, io_mode))
+// clear(std::ios::failbit | std::ios::badbit);
+// else
+// clear();
+// }
- /// Close the current stream.
- void
- close()
- {
- if (!buffer.close())
- clear(std::ios::failbit | std::ios::badbit);
- }
+// /// Close the current stream.
+// void
+// close()
+// {
+// if (!buffer.close())
+// clear(std::ios::failbit | std::ios::badbit);
+// }
- bool
- is_open()
- {
- return buffer.is_open();
- }
+// bool
+// is_open()
+// {
+// return buffer.is_open();
+// }
- protected:
- /// Prevent instantiation.
- zfilestream_common() : std::ios(zfilestream_common::rdbuf())
- { }
+// protected:
+// /// Prevent instantiation.
+// zfilestream_common() : std::ios(zfilestream_common::rdbuf())
+// { }
- private:
- zfilebuf*
- rdbuf()
- {
- return &buffer;
- }
+// private:
+// zfilebuf*
+// rdbuf()
+// {
+// return &buffer;
+// }
- zfilebuf buffer;
- };
+// zfilebuf buffer;
+// };
- /// Read only zstream.
- class zifstream : public zfilestream_common, public std::istream
- {
- public:
+// /// Read only zstream.
+// class zifstream : public zfilestream_common, public std::istream
+// {
+// public:
- zifstream() : std::istream(zfilestream_common::rdbuf())
- {
- clear(std::ios::badbit);
- }
+// zifstream() : std::istream(zfilestream_common::rdbuf())
+// {
+// clear(std::ios::badbit);
+// }
- /// Open a read only stream on the file named \a name.
- zifstream(const char *name, int io_mode = std::ios::in) :
- std::istream(zfilestream_common::rdbuf())
- {
- zfilestream_common::open(name, io_mode);
- }
+// /// Open a read only stream on the file named \a name.
+// zifstream(const char *name, int io_mode = std::ios::in) :
+// std::istream(zfilestream_common::rdbuf())
+// {
+// zfilestream_common::open(name, io_mode);
+// }
- /// Open a read only stream on the file descriptor \a fd.
- zifstream(int fd, int io_mode = std::ios::in) :
- std::istream(zfilestream_common::rdbuf())
- {
- zfilestream_common::attach(fd, io_mode);
- }
+// /// Open a read only stream on the file descriptor \a fd.
+// zifstream(int fd, int io_mode = std::ios::in) :
+// std::istream(zfilestream_common::rdbuf())
+// {
+// zfilestream_common::attach(fd, io_mode);
+// }
- virtual ~zifstream() {}
- };
+// virtual ~zifstream() {}
+// };
- class zofstream : public zfilestream_common, public std::ostream {
+// class zofstream : public zfilestream_common, public std::ostream {
- public:
+// public:
- zofstream() : std::ostream(zfilestream_common::rdbuf())
- {
- clear(std::ios::badbit);
- }
+// zofstream() : std::ostream(zfilestream_common::rdbuf())
+// {
+// clear(std::ios::badbit);
+// }
- /// Open a write only stream on the file named \a name.
- zofstream(const char *name, int io_mode = std::ios::out) :
- std::ostream(zfilestream_common::rdbuf())
- {
- zfilestream_common::open(name, io_mode);
- }
+// /// Open a write only stream on the file named \a name.
+// zofstream(const char *name, int io_mode = std::ios::out) :
+// std::ostream(zfilestream_common::rdbuf())
+// {
+// zfilestream_common::open(name, io_mode);
+// }
- /// Open a write only stream on the file descriptor \a fd.
- zofstream(int fd, int io_mode = std::ios::out) :
- std::ostream(zfilestream_common::rdbuf())
- {
- zfilestream_common::attach(fd, io_mode);
- }
+// /// Open a write only stream on the file descriptor \a fd.
+// zofstream(int fd, int io_mode = std::ios::out) :
+// std::ostream(zfilestream_common::rdbuf())
+// {
+// zfilestream_common::attach(fd, io_mode);
+// }
- virtual ~zofstream() {}
+// virtual ~zofstream() {}
- };
+// };
- // Forward declaration.
- template <class T>
- class zomanip;
+// // Forward declaration.
+// template <class T>
+// class zomanip;
- /// Apply a function on \a s via the operator <<.
- template <class T>
- zofstream&
- operator<<(zofstream &s, const zomanip<T> &m) {
- return (*m.func)(s, m.val);
- }
+// /// Apply a function on \a s via the operator <<.
+// template <class T>
+// zofstream&
+// operator<<(zofstream &s, const zomanip<T> &m) {
+// return (*m.func)(s, m.val);
+// }
- /// Define a pair func / val to perform manipulation on zofstream.
- template<class T> class zomanip
- {
- friend zofstream &operator<< <T>(zofstream &, const zomanip<T> &);
- public:
- zomanip(zofstream &(*f)(zofstream &, T), T v) : func(f), val(v) { }
- private:
- zofstream &(*func)(zofstream &, T);
- T val;
- };
+// /// Define a pair func / val to perform manipulation on zofstream.
+// template<class T> class zomanip
+// {
+// friend zofstream &operator<< <T>(zofstream &, const zomanip<T> &);
+// public:
+// zomanip(zofstream &(*f)(zofstream &, T), T v) : func(f), val(v) { }
+// private:
+// zofstream &(*func)(zofstream &, T);
+// T val;
+// };
- /// Set the compression level of \a s to \a l.
- inline zofstream&
- setcompressionlevel(zofstream &s, int l) {
- (s.rdbuf())->setcompressionlevel(l);
- return s;
- }
+// /// Set the compression level of \a s to \a l.
+// inline zofstream&
+// setcompressionlevel(zofstream &s, int l) {
+// (s.rdbuf())->setcompressionlevel(l);
+// return s;
+// }
- /// Set the compression strategy of \a s to \a l.
- inline zofstream&
- setcompressionstrategy(zofstream &s, int l)
- {
- (s.rdbuf())->setcompressionstrategy(l);
- return s;
- }
+// /// Set the compression strategy of \a s to \a l.
+// inline zofstream&
+// setcompressionstrategy(zofstream &s, int l)
+// {
+// (s.rdbuf())->setcompressionstrategy(l);
+// return s;
+// }
- /// Specialized version for zomanip<int>
- inline zomanip<int>
- setcompressionlevel(int l)
- {
- return zomanip<int>(&setcompressionlevel,l);
- }
+// /// Specialized version for zomanip<int>
+// inline zomanip<int>
+// setcompressionlevel(int l)
+// {
+// return zomanip<int>(&setcompressionlevel,l);
+// }
- /// Specialized version for zomanip<int>
- inline zomanip<int>
- setcompressionstrategy(int l)
- {
- return zomanip<int>(&setcompressionstrategy,l);
- }
+// /// Specialized version for zomanip<int>
+// inline zomanip<int>
+// setcompressionstrategy(int l)
+// {
+// return zomanip<int>(&setcompressionstrategy,l);
+// }
- } // end of namespace gz
+// } // end of namespace gz
- } // end of namespace io
+// } // end of namespace io
-} // end of namespace oln
+// } // end of namespace oln
-# endif // ! HAVE_ZLIB
+// # endif // ! HAVE_ZLIB
#endif // ! OLN_IO_GZ_STREAM_HH
Index: oln/io/write_image_2d_pnm.hh
===================================================================
--- oln/io/write_image_2d_pnm.hh (revision 166)
+++ oln/io/write_image_2d_pnm.hh (working copy)
@@ -29,196 +29,196 @@
#ifndef OLN_IO_WRITE_IMAGE_2D_PNM_HH
# define OLN_IO_WRITE_IMAGE_2D_PNM_HH
-# include <iostream>
-# include <string>
+// # include <iostream>
+// # include <string>
-# include <mlc/box.hh>
+// # include <mlc/box.hh>
-# include <ntg/all.hh>
+// # include <ntg/all.hh>
-# include <oln/core/2d/image2d.hh>
+// # include <oln/core/2d/image2d.hh>
-// commented cause 'void_op' was removed
-//# include <oln/core/abstract/op.hh>
+// // commented cause 'void_op' was removed
+// //# include <oln/core/abstract/op.hh>
-# include <oln/io/utils.hh>
+// # include <oln/io/utils.hh>
-namespace oln {
+// namespace oln {
- namespace io {
+// namespace io {
- namespace impl {
+// namespace impl {
- template <typename I>
- struct write_image_2d_raw
- // commented below cause 'void_op' was removed
-// : public oln::abstract::void_op<write_image_2d_raw<I> >
- {
- typedef oln_type_of(I, value) value_type;
+// template <typename I>
+// struct write_image_2d_raw
+// // commented below cause 'void_op' was removed
+// // : public oln::abstract::void_op<write_image_2d_raw<I> >
+// {
+// typedef oln_type_of(I, value) value_type;
- const I& to_write_;
- std::ostream& ostr_;
- int bin_offset;
- char bin_v;
+// const I& to_write_;
+// std::ostream& ostr_;
+// int bin_offset;
+// char bin_v;
- write_image_2d_raw(const I& to_write, std::ostream& ostr):
- to_write_(to_write),
- ostr_(ostr)
- {
- bin_offset = 7;
- bin_v = 0;
- }
+// write_image_2d_raw(const I& to_write, std::ostream& ostr):
+// to_write_(to_write),
+// ostr_(ostr)
+// {
+// bin_offset = 7;
+// bin_v = 0;
+// }
- void run()
- {
- point2d p;
- value_type c;
+// void run()
+// {
+// point2d p;
+// value_type c;
- for (p.row() = 0; p.row() < to_write_.size().nrows(); ++p.row())
- {
- for (p.col() = 0; p.col() < to_write_.size().ncols(); ++p.col())
- // FIXME: SHOULD NOT BE .value() !!!
- write_value_type(to_write_[p].value());
- write_padding(c);
- }
- }
+// for (p.row() = 0; p.row() < to_write_.size().nrows(); ++p.row())
+// {
+// for (p.col() = 0; p.col() < to_write_.size().ncols(); ++p.col())
+// // FIXME: SHOULD NOT BE .value() !!!
+// write_value_type(to_write_[p].value());
+// write_padding(c);
+// }
+// }
- template <typename E>
- void write_padding(const ntg::value<E>&) {}
+// template <typename E>
+// void write_padding(const ntg::value<E>&) {}
- void write_padding(const ntg::bin&)
- {
- if (bin_offset != 7)
- {
- ostr_.write(&bin_v, 1);
- bin_offset = 7;
- bin_v = 0;
- }
- }
+// void write_padding(const ntg::bin&)
+// {
+// if (bin_offset != 7)
+// {
+// ostr_.write(&bin_v, 1);
+// bin_offset = 7;
+// bin_v = 0;
+// }
+// }
- //FIXME: Should work with builtin types.
+// //FIXME: Should work with builtin types.
- template <typename E>
- void write_value_type(const ntg::real_value<E> &c)
- {
- typedef oln_io_type(ntg_nbits(E)) v_type;
+// template <typename E>
+// void write_value_type(const ntg::real_value<E> &c)
+// {
+// typedef oln_io_type(ntg_nbits(E)) v_type;
- v_type v;
- v = ntg::cast::bound<E, v_type>(c.exact());
- ostr_.write((char*)&v, sizeof (v_type));
- }
+// v_type v;
+// v = ntg::cast::bound<E, v_type>(c.exact());
+// ostr_.write((char*)&v, sizeof (v_type));
+// }
- template <typename E>
- void write_value_type(const ntg::vect_value<E> &c)
- {
- for (unsigned i = 0; i < 3; i++)
- {
- typedef oln_io_type(ntg_nbits(ntg_comp_type(value_type))) v_type;
+// template <typename E>
+// void write_value_type(const ntg::vect_value<E> &c)
+// {
+// for (unsigned i = 0; i < 3; i++)
+// {
+// typedef oln_io_type(ntg_nbits(ntg_comp_type(value_type))) v_type;
- v_type v;
- v = c[i];
- ostr_.write((char*)&v, sizeof (v_type));
- }
- }
+// v_type v;
+// v = c[i];
+// ostr_.write((char*)&v, sizeof (v_type));
+// }
+// }
- void write_value_type(const ntg::bin &c)
- {
- if (bin_offset == -1)
- {
- ostr_.write(&bin_v, 1);
- bin_offset = 7;
- bin_v = 0;
- }
- if (c == value_type(1))
- bin_v |= 1 << bin_offset;
- bin_offset--;
- }
- };
+// void write_value_type(const ntg::bin &c)
+// {
+// if (bin_offset == -1)
+// {
+// ostr_.write(&bin_v, 1);
+// bin_offset = 7;
+// bin_v = 0;
+// }
+// if (c == value_type(1))
+// bin_v |= 1 << bin_offset;
+// bin_offset--;
+// }
+// };
- template <typename I, typename T>
- void write(const abstract::image2d<I>& to_write,
- const ntg::real_value<T>&,
- std::ostream& ostr,
- const std::string& ext)
- {
+// template <typename I, typename T>
+// void write(const abstract::image2d<I>& to_write,
+// const ntg::real_value<T>&,
+// std::ostream& ostr,
+// const std::string& ext)
+// {
- point2d p;
- size2d s = to_write.size();
+// point2d p;
+// size2d s = to_write.size();
- precondition(ntg_nbits(T) <= 16);
- if (ext == "pgm")
- if (internal::write_pnm_header(ostr, "P5",
- s.ncols(), s.nrows(),
- ntg_max_val(T)))
- {
- write_image_2d_raw<I> tmp(to_write.exact(), ostr);
- tmp.run();
- }
- else
- std::cerr << "error: unable to write file header" << std::endl;
- else
- std::cerr << "error: image data type (`integer') does not match"
- << " file extension (`" << ext << "')" << std::endl;
- }
+// precondition(ntg_nbits(T) <= 16);
+// if (ext == "pgm")
+// if (internal::write_pnm_header(ostr, "P5",
+// s.ncols(), s.nrows(),
+// ntg_max_val(T)))
+// {
+// write_image_2d_raw<I> tmp(to_write.exact(), ostr);
+// tmp.run();
+// }
+// else
+// std::cerr << "error: unable to write file header" << std::endl;
+// else
+// std::cerr << "error: image data type (`integer') does not match"
+// << " file extension (`" << ext << "')" << std::endl;
+// }
- template <typename I, typename T>
- void write(const abstract::image2d<I>& to_write,
- const ntg::color_value<T>&,
- std::ostream& ostr,
- const std::string& ext)
- {
+// template <typename I, typename T>
+// void write(const abstract::image2d<I>& to_write,
+// const ntg::color_value<T>&,
+// std::ostream& ostr,
+// const std::string& ext)
+// {
- point2d p;
- size2d s = to_write.size();
+// point2d p;
+// size2d s = to_write.size();
- precondition(ntg_nbits(ntg_comp_type(T)) <= 16);
- precondition(ntg_nb_comp(T) == 3);
- if (ext == "ppm")
- if (internal::write_pnm_header(ostr, "P6",
- s.ncols(), s.nrows(),
- ntg_max_val(ntg_comp_type(T))))
- {
- write_image_2d_raw<I> tmp(to_write.exact(), ostr);
- tmp.run();
- }
- else
- std::cerr << "error: unable to write header" << std::endl;
- else
- std::cerr << "error: image data type (`color') does not match"
- << " file extension (`" << ext << "')" << std::endl;
- }
+// precondition(ntg_nbits(ntg_comp_type(T)) <= 16);
+// precondition(ntg_nb_comp(T) == 3);
+// if (ext == "ppm")
+// if (internal::write_pnm_header(ostr, "P6",
+// s.ncols(), s.nrows(),
+// ntg_max_val(ntg_comp_type(T))))
+// {
+// write_image_2d_raw<I> tmp(to_write.exact(), ostr);
+// tmp.run();
+// }
+// else
+// std::cerr << "error: unable to write header" << std::endl;
+// else
+// std::cerr << "error: image data type (`color') does not match"
+// << " file extension (`" << ext << "')" << std::endl;
+// }
- template <typename I>
- void write(const abstract::image2d<I>& to_write,
- const ntg::bin&,
- std::ostream& ostr,
- const std::string& ext)
- {
- point2d p;
- size2d s = to_write.size();
+// template <typename I>
+// void write(const abstract::image2d<I>& to_write,
+// const ntg::bin&,
+// std::ostream& ostr,
+// const std::string& ext)
+// {
+// point2d p;
+// size2d s = to_write.size();
- if (ext == "pbm")
- if (internal::write_pnm_header(ostr, "P4",
- s.ncols(), s.nrows(),
- 1))
- {
- write_image_2d_raw<I> tmp(to_write.exact(), ostr);
- tmp.run();
- }
- else
- std::cerr << "error: unable to write header" << std::endl;
- else
- std::cerr << "error: image data type (`enum_value') does not match"
- << " file extension (`" << ext << "')" << std::endl;
- }
+// if (ext == "pbm")
+// if (internal::write_pnm_header(ostr, "P4",
+// s.ncols(), s.nrows(),
+// 1))
+// {
+// write_image_2d_raw<I> tmp(to_write.exact(), ostr);
+// tmp.run();
+// }
+// else
+// std::cerr << "error: unable to write header" << std::endl;
+// else
+// std::cerr << "error: image data type (`enum_value') does not match"
+// << " file extension (`" << ext << "')" << std::endl;
+// }
- }
+// }
- }
+// }
-}
+// }
Index: oln/io/read_image_2d_pnm.hh
===================================================================
--- oln/io/read_image_2d_pnm.hh (revision 166)
+++ oln/io/read_image_2d_pnm.hh (working copy)
@@ -28,160 +28,160 @@
#ifndef OLN_IO_READ_IMAGE_2D_PNM_HH
# define OLN_IO_READ_IMAGE_2D_PNM_HH
-# include <iostream>
-# include <string>
+// # include <iostream>
+// # include <string>
-# include <mlc/box.hh>
-# include <mlc/math.hh>
+// # include <mlc/box.hh>
+// # include <mlc/math.hh>
-# include <ntg/all.hh>
+// # include <ntg/all.hh>
-# include <oln/core/2d/image2d.hh>
+// # include <oln/core/2d/image2d.hh>
-# include <oln/core/abstract/image_operator.hh>
+// # include <oln/core/abstract/image_operator.hh>
-# include <oln/io/utils.hh>
+// # include <oln/io/utils.hh>
-namespace oln {
+// namespace oln {
- template <typename I>
- struct image2d;
+// template <typename I>
+// struct image2d;
- // fwd decl
- namespace io {
- namespace impl {
- template <typename I> struct read_image_2d_raw;
- }
- }
+// // fwd decl
+// namespace io {
+// namespace impl {
+// template <typename I> struct read_image_2d_raw;
+// }
+// }
- // super_type
- template <typename I>
- struct set_super_type < io::impl::read_image_2d_raw<I> >
- {
- typedef abstract::image_operator<I, io::impl::read_image_2d_raw<I> > ret;
- };
+// // super_type
+// template <typename I>
+// struct set_super_type < io::impl::read_image_2d_raw<I> >
+// {
+// typedef abstract::image_operator<I, io::impl::read_image_2d_raw<I> > ret;
+// };
- namespace io {
+// namespace io {
- namespace impl {
+// namespace impl {
- template <typename I>
- struct read_image_2d_raw :
- public oln::abstract::image_operator<I, read_image_2d_raw<I> >
- {
- typedef oln::abstract::image_operator<I, read_image_2d_raw<I> >
- super_type;
- typedef oln_type_of(I, value) value_type;
+// template <typename I>
+// struct read_image_2d_raw :
+// public oln::abstract::image_operator<I, read_image_2d_raw<I> >
+// {
+// typedef oln::abstract::image_operator<I, read_image_2d_raw<I> >
+// super_type;
+// typedef oln_type_of(I, value) value_type;
- std::istream& istr_;
- internal::pnm_info& info_;
- char v;
- int offset;
+// std::istream& istr_;
+// internal::pnm_info& info_;
+// char v;
+// int offset;
- read_image_2d_raw(std::istream &istr,
- internal::pnm_info &info) :
- super_type(),
- istr_(istr),
- info_(info),
- offset(-1)
- {
- }
+// read_image_2d_raw(std::istream &istr,
+// internal::pnm_info &info) :
+// super_type(),
+// istr_(istr),
+// info_(info),
+// offset(-1)
+// {
+// }
- template <typename E>
- void precond(ntg::real_value<E>& c)
- {
- precondition(ntg_max_val(value_type) <= info_.max_val);
- precondition(info_.type == "P5");
- }
+// template <typename E>
+// void precond(ntg::real_value<E>& c)
+// {
+// precondition(ntg_max_val(value_type) <= info_.max_val);
+// precondition(info_.type == "P5");
+// }
- template <typename E>
- void precond(ntg::vect_value<E>& c)
- {
- precondition(ntg_max_val(ntg_comp_type(value_type)) <=
- info_.max_val);
- precondition(info_.type == "P6");
- precondition(ntg_nb_comp(value_type) == 3);
- }
+// template <typename E>
+// void precond(ntg::vect_value<E>& c)
+// {
+// precondition(ntg_max_val(ntg_comp_type(value_type)) <=
+// info_.max_val);
+// precondition(info_.type == "P6");
+// precondition(ntg_nb_comp(value_type) == 3);
+// }
- void precond(ntg::bin& c)
- {
- precondition(info_.type == "P4");
- }
+// void precond(ntg::bin& c)
+// {
+// precondition(info_.type == "P4");
+// }
- void impl_run()
- {
- value_type c;
- point2d p;
- oln::image2d<value_type> tmp(info_.rows, info_.cols);
+// void impl_run()
+// {
+// value_type c;
+// point2d p;
+// oln::image2d<value_type> tmp(info_.rows, info_.cols);
- precond(c);
+// precond(c);
- for (p.row() = 0; p.row() < info_.rows && !istr_.eof(); ++p.row())
- {
- offset = -1;
- for (p.col() = 0; p.col() < info_.cols && !istr_.eof(); ++p.col())
- {
- read_value_type(c);
- tmp[p] = c;
- }
- }
- this->output = tmp;
- }
+// for (p.row() = 0; p.row() < info_.rows && !istr_.eof(); ++p.row())
+// {
+// offset = -1;
+// for (p.col() = 0; p.col() < info_.cols && !istr_.eof(); ++p.col())
+// {
+// read_value_type(c);
+// tmp[p] = c;
+// }
+// }
+// this->output = tmp;
+// }
- //FIXME: Should work with builtin types.
+// //FIXME: Should work with builtin types.
- template <typename E>
- void read_value_type(ntg::real_value<E> &c)
- {
- typedef oln_io_type(ntg_nbits(E)) v_type;
- v_type v;
- istr_.read((char*)&v, sizeof (v_type));
- c = ntg::cast::force<E, v_type>(v);
- }
+// template <typename E>
+// void read_value_type(ntg::real_value<E> &c)
+// {
+// typedef oln_io_type(ntg_nbits(E)) v_type;
+// v_type v;
+// istr_.read((char*)&v, sizeof (v_type));
+// c = ntg::cast::force<E, v_type>(v);
+// }
- template <typename E>
- void read_value_type(ntg::vect_value<E> &c)
- {
- for (unsigned i = 0; i < ntg_nb_comp(E); i++)
- {
- typedef oln_io_type(ntg_nbits(ntg_comp_type(E))) v_type;
- v_type v;
- istr_.read((char*)&v, sizeof (v_type));
- c[i] = ntg::cast::force<ntg_comp_type(E), v_type>(v);
- }
- }
+// template <typename E>
+// void read_value_type(ntg::vect_value<E> &c)
+// {
+// for (unsigned i = 0; i < ntg_nb_comp(E); i++)
+// {
+// typedef oln_io_type(ntg_nbits(ntg_comp_type(E))) v_type;
+// v_type v;
+// istr_.read((char*)&v, sizeof (v_type));
+// c[i] = ntg::cast::force<ntg_comp_type(E), v_type>(v);
+// }
+// }
- void read_value_type(ntg::bin &c)
- {
+// void read_value_type(ntg::bin &c)
+// {
- if (offset == -1)
- {
- istr_.read(&v, 1);
- offset = 7;
- }
- if ((int)(v & (1<<offset--)) == 0)
- c = 0;
- else
- c = 1;
- }
- };
+// if (offset == -1)
+// {
+// istr_.read(&v, 1);
+// offset = 7;
+// }
+// if ((int)(v & (1<<offset--)) == 0)
+// c = 0;
+// else
+// c = 1;
+// }
+// };
- template <typename I>
- read_image_2d_raw<I>
- read(std::istream& istr, internal::pnm_info info)
- {
- read_image_2d_raw<I> tmp(istr, info);
- tmp.run();
- return tmp;
- }
+// template <typename I>
+// read_image_2d_raw<I>
+// read(std::istream& istr, internal::pnm_info info)
+// {
+// read_image_2d_raw<I> tmp(istr, info);
+// tmp.run();
+// return tmp;
+// }
- }
+// }
- }
+// }
-}
+// }
#endif // ! OLN_IO_READ_IMAGE_2D_PNM_HH
Index: oln/io/write_image.hh
===================================================================
--- oln/io/write_image.hh (revision 166)
+++ oln/io/write_image.hh (working copy)
@@ -28,84 +28,84 @@
#ifndef OLN_IO_WRITE_IMAGE_HH
# define OLN_IO_WRITE_IMAGE_HH
-# include <string>
+// # include <string>
-# include <oln/io/gz_stream.hh>
-# include <oln/io/utils.hh>
-# include <oln/io/write_image_2d_pnm.hh>
+// # include <oln/io/gz_stream.hh>
+// # include <oln/io/utils.hh>
+// # include <oln/io/write_image_2d_pnm.hh>
-namespace oln {
+// namespace oln {
- namespace io {
+// namespace io {
- template <typename I>
- void do_write(const abstract::image<I>& ima,
- std::ostream& ostr,
- const std::string& ext)
- {
- typedef oln_type_of(I, value) value_type;
- value_type t;
+// template <typename I>
+// void do_write(const abstract::image<I>& ima,
+// std::ostream& ostr,
+// const std::string& ext)
+// {
+// typedef oln_type_of(I, value) value_type;
+// value_type t;
- impl::write(ima.exact(), t, ostr, ext);
- }
+// impl::write(ima.exact(), t, ostr, ext);
+// }
-#if defined HAVE_ZLIB && HAVE_ZLIB == 1
- template <typename I>
- void write_gz(const abstract::image<I>& ima, const std::string& name)
- {
- gz::zofstream zostr(name.c_str(), std::ios::out);
+// #if defined HAVE_ZLIB && HAVE_ZLIB == 1
+// template <typename I>
+// void write_gz(const abstract::image<I>& ima, const std::string& name)
+// {
+// gz::zofstream zostr(name.c_str(), std::ios::out);
- if (zostr.is_open() == false)
- std::cerr << "error: couldn't open " << name << std::endl;
- else
- {
- std::string ext;
+// if (zostr.is_open() == false)
+// std::cerr << "error: couldn't open " << name << std::endl;
+// else
+// {
+// std::string ext;
- ext = internal::utils::extension(name.substr(0, name.size() - 3));
- do_write(ima, zostr, ext);
- }
- zostr.close();
- }
+// ext = internal::utils::extension(name.substr(0, name.size() - 3));
+// do_write(ima, zostr, ext);
+// }
+// zostr.close();
+// }
-#endif // ! HAVE_ZLIB
+// #endif // ! HAVE_ZLIB
- template <typename I>
- void write_non_gz(const abstract::image<I>& ima,
- const std::string& name,
- const std::string& ext)
- {
- std::ofstream ostr;
+// template <typename I>
+// void write_non_gz(const abstract::image<I>& ima,
+// const std::string& name,
+// const std::string& ext)
+// {
+// std::ofstream ostr;
- ostr.open(name.c_str(), std::ifstream::out);
+// ostr.open(name.c_str(), std::ifstream::out);
- if (ostr.is_open() == false)
- std::cerr << "error: couldn't open " << name << std::endl;
- else
- do_write(ima, ostr, ext);
- ostr.close();
- }
+// if (ostr.is_open() == false)
+// std::cerr << "error: couldn't open " << name << std::endl;
+// else
+// do_write(ima, ostr, ext);
+// ostr.close();
+// }
- template <typename I>
- void write(const abstract::image<I>& ima, const std::string& name)
- {
- std::string ext;
- // FIXME: Unused?
- // oln_type_of(I, value) t;
+// template <typename I>
+// void write(const abstract::image<I>& ima, const std::string& name)
+// {
+// std::string ext;
+// // FIXME: Unused?
+// // oln_type_of(I, value) t;
- ext = internal::utils::extension(name);
+// ext = internal::utils::extension(name);
-#if defined HAVE_ZLIB && HAVE_ZLIB == 1
- if (ext == "gz")
- write_gz(ima, name);
- else
- write_non_gz(ima, name, ext);
-# else
- write_non_gz(ima, name, ext);
-#endif // ! HAVE_ZLIB
- }
+// #if defined HAVE_ZLIB && HAVE_ZLIB == 1
+// if (ext == "gz")
+// write_gz(ima, name);
+// else
+// write_non_gz(ima, name, ext);
+// # else
+// write_non_gz(ima, name, ext);
+// #endif // ! HAVE_ZLIB
+// }
- }
+// }
-}
+// }
#endif // ! OLN_IO_WRITE_IMAGE_HH
Index: oln/io/read_image.hh
===================================================================
--- oln/io/read_image.hh (revision 166)
+++ oln/io/read_image.hh (working copy)
@@ -63,99 +63,99 @@
}
- template <typename I>
- void read_dispatch_ext(abstract::image<I>& ima,
- std::istream& istr,
- const std::string& ext)
+// template <typename I>
+// void read_dispatch_ext(abstract::image<I>& ima,
+// std::istream& istr,
+// const std::string& ext)
- {
- if (ext == "pgm" || ext == "pbm" || ext == "ppm" ||
- ext == "pnm")
- {
- internal::pnm_info info;
+// {
+// if (ext == "pgm" || ext == "pbm" || ext == "ppm" ||
+// ext == "pnm")
+// {
+// internal::pnm_info info;
- if (internal::read_pnm_header(istr, info))
- if ((ext == "ppm" || ext == "pnm") && info.type == "P6")
- ima.exact() = impl::read<I>(istr, info);
- else if ((ext == "ppm" || ext == "pnm") && info.type == "P3")
- std::cerr << "error: read_image_2d_ppm_ascii not implemented"
- << std::endl;
- else if ((ext == "pbm" || ext == "pnm") && info.type == "P4")
- ima.exact() = impl::read<I>(istr, info);
- else if ((ext == "pbm" || ext == "pnm") && info.type == "P1")
- std::cerr << "error: read_image_2d_ppm_ascii not implemented"
- << std::endl;
- else if ((ext == "pgm" || ext == "pnm") && info.type == "P5")
- ima.exact() = impl::read<I>(istr, info);
- else if ((ext == "pgm" || ext == "pnm") && info.type == "P2")
- std::cerr << "error: read_image_2d_ppm_ascii not implemented"
- << std::endl;
- else
- std::cerr << "error: file header (`" << info.type
- << "') does not match file extension (`"
- << ext << "')" << std::endl;
- else
- std::cerr << "error: unable to get a valid header" << std::endl;
- }
- else
- std::cout << "no input method for '"
- << ext << "' file extension"
- << std::endl;
- }
+// if (internal::read_pnm_header(istr, info))
+// if ((ext == "ppm" || ext == "pnm") && info.type == "P6")
+// ima.exact() = impl::read<I>(istr, info);
+// else if ((ext == "ppm" || ext == "pnm") && info.type == "P3")
+// std::cerr << "error: read_image_2d_ppm_ascii not implemented"
+// << std::endl;
+// else if ((ext == "pbm" || ext == "pnm") && info.type == "P4")
+// ima.exact() = impl::read<I>(istr, info);
+// else if ((ext == "pbm" || ext == "pnm") && info.type == "P1")
+// std::cerr << "error: read_image_2d_ppm_ascii not implemented"
+// << std::endl;
+// else if ((ext == "pgm" || ext == "pnm") && info.type == "P5")
+// ima.exact() = impl::read<I>(istr, info);
+// else if ((ext == "pgm" || ext == "pnm") && info.type == "P2")
+// std::cerr << "error: read_image_2d_ppm_ascii not implemented"
+// << std::endl;
+// else
+// std::cerr << "error: file header (`" << info.type
+// << "') does not match file extension (`"
+// << ext << "')" << std::endl;
+// else
+// std::cerr << "error: unable to get a valid header" << std::endl;
+// }
+// else
+// std::cout << "no input method for '"
+// << ext << "' file extension"
+// << std::endl;
+// }
-#if defined HAVE_ZLIB && HAVE_ZLIB == 1
- template <typename I>
- void do_read_gz(abstract::image<I>& ima, const std::string& name)
- {
- gz::zifstream zistr(name.c_str(), std::ios::in);
+// #if defined HAVE_ZLIB && HAVE_ZLIB == 1
+// template <typename I>
+// void do_read_gz(abstract::image<I>& ima, const std::string& name)
+// {
+// gz::zifstream zistr(name.c_str(), std::ios::in);
- if (zistr.is_open() == false)
- std::cerr << "error: couldn't open " << name << std::endl;
- else
- {
- std::string ext;
+// if (zistr.is_open() == false)
+// std::cerr << "error: couldn't open " << name << std::endl;
+// else
+// {
+// std::string ext;
- ext = internal::utils::extension(name.substr(0, name.size() - 3));
- read_dispatch_ext(ima, zistr, ext);
- }
- zistr.close();
- }
+// ext = internal::utils::extension(name.substr(0, name.size() - 3));
+// read_dispatch_ext(ima, zistr, ext);
+// }
+// zistr.close();
+// }
-#endif // ! HAVE_ZLIB
+// #endif // ! HAVE_ZLIB
- template <typename I>
- void do_read_non_gz(abstract::image<I>& ima,
- const std::string& name,
- const std::string& ext)
- {
- std::ifstream istr;
+// template <typename I>
+// void do_read_non_gz(abstract::image<I>& ima,
+// const std::string& name,
+// const std::string& ext)
+// {
+// std::ifstream istr;
- istr.open(name.c_str(), std::ifstream::in);
+// istr.open(name.c_str(), std::ifstream::in);
- if (istr.is_open() == false)
- std::cerr << "error: couldn't open " << name << std::endl;
- else
- read_dispatch_ext(ima, istr, ext);
- istr.close();
- }
+// if (istr.is_open() == false)
+// std::cerr << "error: couldn't open " << name << std::endl;
+// else
+// read_dispatch_ext(ima, istr, ext);
+// istr.close();
+// }
- template <typename I>
- void do_read(abstract::image<I>& ima, const filename& name)
- {
- std::string ext;
+// template <typename I>
+// void do_read(abstract::image<I>& ima, const filename& name)
+// {
+// std::string ext;
- ext = internal::utils::extension(name.get());
+// ext = internal::utils::extension(name.get());
-#if defined HAVE_ZLIB && HAVE_ZLIB == 1
+// #if defined HAVE_ZLIB && HAVE_ZLIB == 1
- if (ext == "gz")
- do_read_gz(ima, name.get());
- else
- do_read_non_gz(ima, name.get(), ext);
-#else
- do_read_non_gz(ima, name.get(), ext);
-#endif // ! HAVE_ZLIB
- }
+// if (ext == "gz")
+// do_read_gz(ima, name.get());
+// else
+// do_read_non_gz(ima, name.get(), ext);
+// #else
+// do_read_non_gz(ima, name.get(), ext);
+// #endif // ! HAVE_ZLIB
+// }
}
Index: oln/io/utils.hh
===================================================================
--- oln/io/utils.hh (revision 166)
+++ oln/io/utils.hh (working copy)
@@ -28,153 +28,153 @@
#ifndef OLENA_IO_UTILS_HH
# define OLENA_IO_UTILS_HH
-# include <oln/config/system.hh>
+// # include <oln/config/system.hh>
-# include <iostream>
-# include <fstream>
-# include <string>
+// # include <iostream>
+// # include <fstream>
+// # include <string>
-namespace oln {
+// namespace oln {
- namespace io {
+// namespace io {
- namespace internal {
+// namespace internal {
- /*!
- ** \brief Utils for io (get extension of a file).
- */
- struct utils
- {
+// /*!
+// ** \brief Utils for io (get extension of a file).
+// */
+// struct utils
+// {
- /*!
- ** \brief Return the extension of a filename.
- ** \arg name The filename.
- ** \return The extension (lower case).
- */
- static std::string
- extension(const std::string& name)
- {
- std::string ext;
- int pos = name.rfind('.');
- if (pos > 0)
- {
- ext.assign(name, pos + 1, name.size() - pos);
- for (std::string::iterator i = ext.begin(); i != ext.end(); ++i)
- *i = tolower(*i);
- }
- return ext;
- }
+// /*!
+// ** \brief Return the extension of a filename.
+// ** \arg name The filename.
+// ** \return The extension (lower case).
+// */
+// static std::string
+// extension(const std::string& name)
+// {
+// std::string ext;
+// int pos = name.rfind('.');
+// if (pos > 0)
+// {
+// ext.assign(name, pos + 1, name.size() - pos);
+// for (std::string::iterator i = ext.begin(); i != ext.end(); ++i)
+// *i = tolower(*i);
+// }
+// return ext;
+// }
- };
+// };
- struct pnm_info
- {
- int max_val;
- int rows;
- int cols;
- std::string type;
- };
+// struct pnm_info
+// {
+// int max_val;
+// int rows;
+// int cols;
+// std::string type;
+// };
- bool read_pnm_header(std::istream& istr,
- internal::pnm_info& info)
- {
- std::getline(istr, info.type);
+// bool read_pnm_header(std::istream& istr,
+// internal::pnm_info& info)
+// {
+// std::getline(istr, info.type);
- info.max_val = 1;
+// info.max_val = 1;
- // skip comments
- while (istr.peek() == '#')
- {
- std::string line;
- std::getline(istr, line);
- }
+// // skip comments
+// while (istr.peek() == '#')
+// {
+// std::string line;
+// std::getline(istr, line);
+// }
- // read size
- istr >> info.cols;
- // skip comments
- while (istr.peek() == '#')
- {
- std::string line;
- std::getline(istr, line);
- }
+// // read size
+// istr >> info.cols;
+// // skip comments
+// while (istr.peek() == '#')
+// {
+// std::string line;
+// std::getline(istr, line);
+// }
- istr >> info.rows;
- // skip comments
- while (istr.peek() == '#')
- {
- std::string line;
- std::getline(istr, line);
- }
+// istr >> info.rows;
+// // skip comments
+// while (istr.peek() == '#')
+// {
+// std::string line;
+// std::getline(istr, line);
+// }
- if (info.cols <= 0 || info.rows <= 0) return false;
+// if (info.cols <= 0 || info.rows <= 0) return false;
- // skip comments
- while (istr.peek() == '#')
- {
- std::string line;
- std::getline(istr, line);
- }
+// // skip comments
+// while (istr.peek() == '#')
+// {
+// std::string line;
+// std::getline(istr, line);
+// }
- // FIXME: it can be either '\n', 'whitespace', ..., not only '\n'!
- if (istr.get() != '\n') return false;
- // extract or skip maxvalue
- if (info.type != "P1" && info.type != "P4")
- {
- istr >> info.max_val;
- if (info.max_val > 65535 ||
- istr.get() != '\n' ||
- info.max_val <= 0)
- return false;
- }
- return true;
- }
+// // FIXME: it can be either '\n', 'whitespace', ..., not only '\n'!
+// if (istr.get() != '\n') return false;
+// // extract or skip maxvalue
+// if (info.type != "P1" && info.type != "P4")
+// {
+// istr >> info.max_val;
+// if (info.max_val > 65535 ||
+// istr.get() != '\n' ||
+// info.max_val <= 0)
+// return false;
+// }
+// return true;
+// }
- bool write_pnm_header(std::ostream& ostr,
- const std::string& type,
- int ncols,
- int nrows,
- int max_val)
- {
- if (max_val > 65535)
- return false;
+// bool write_pnm_header(std::ostream& ostr,
+// const std::string& type,
+// int ncols,
+// int nrows,
+// int max_val)
+// {
+// if (max_val > 65535)
+// return false;
- ostr << type << std::endl
- << "# Olena 1.0" << std::endl
- << ncols << " " << nrows << std::endl;
- if (type != "P1" && type != "P4")
- ostr << max_val << std::endl;
- return true;
- }
+// ostr << type << std::endl
+// << "# Olena 1.0" << std::endl
+// << ncols << " " << nrows << std::endl;
+// if (type != "P1" && type != "P4")
+// ostr << max_val << std::endl;
+// return true;
+// }
- template <bool b>
- struct pnm_io_helper_bool
- {
- typedef unsigned char type;
- };
+// template <bool b>
+// struct pnm_io_helper_bool
+// {
+// typedef unsigned char type;
+// };
- template <>
- struct pnm_io_helper_bool<false>
- {
- typedef unsigned short type;
- };
+// template <>
+// struct pnm_io_helper_bool<false>
+// {
+// typedef unsigned short type;
+// };
- template <unsigned N>
- struct pnm_io_helper
- {
- typedef typename pnm_io_helper_bool<N <= 8>::type type;
- };
+// template <unsigned N>
+// struct pnm_io_helper
+// {
+// typedef typename pnm_io_helper_bool<N <= 8>::type type;
+// };
- } // end of namespace internal
+// } // end of namespace internal
- } // end of namespace io
+// } // end of namespace io
-} // end of namespace oln
+// } // end of namespace oln
-# define oln_io_type(N) typename oln::io::internal::pnm_io_helper<N>::type
-# define oln_io_type_(N) oln::io::internal::pnm_io_helper<N>::type
+// # define oln_io_type(N) typename oln::io::internal::pnm_io_helper<N>::type
+// # define oln_io_type_(N) oln::io::internal::pnm_io_helper<N>::type
#endif // ! OLENA_IO_UTILS_HH
1
0
2005-04-27 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* oln/funobj/accum.hh (min_accumulator_init): New class.
* oln/core/abstract/niter.hh (for_all_n_of_p): Fix bug.
(set_type<image,I,niter_type>): New type deduction.
(set_type<image,I,fwd_niter_type>): Likewise.
(set_type<image,I,bkd_niter_type>): Likewise.
* oln/core/abstract/neighborhood.hh
(iter, fwd_iter, bkd_iter): New properties.
* oln/core/gen/regular_neighborhood.hh: Update.
* oln/core/abstract/window.hh (operator-): New.
* oln/core/pw/image.hh (grid_type): New property.
(concrete_type): Likewise.
Index: oln/convert/nbh_to_se.hh
===================================================================
--- oln/convert/nbh_to_se.hh (revision 166)
+++ oln/convert/nbh_to_se.hh (working copy)
@@ -1,82 +0,0 @@
-// Copyright (C) 2002, 2004, 2005 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_CONVERT_NBH_TO_SE_HH
-# define OLENA_CONVERT_NBH_TO_SE_HH
-
-# include <oln/core/abstract/neighborhood.hh>
-# include <oln/core/2d/dpoint2d.hh>
-
-
-namespace oln {
- namespace convert {
- /*! Convert a neighborhood to a window.
- **
- ** \see nbh_to_cse
- */
- template<class N>
- oln_nbh_type_of(N, window)
- nbh_to_se(const N& nbh) // FIXME: UGLY oln::abstract::neighborhood<N>& nbh)
- {
- oln_nbh_type_of(N, window) output;
-
- for (unsigned i = 0; i < nbh.card(); i++)
- output.add(nbh.dp(i));
- return output;
- }
-
- void dpoint_zero(dpoint2d& dp)
- {
- dp.row() = 0;
- dp.col() = 0;
- }
-
- /*! Convert a neighborhood to a window and add the center.
- **
- ** \see nbh_to_cs
- */
- template<class N>
- oln_nbh_type_of(N, window)
- nbh_to_cse(const N& nbh) // FIXME: UGLY oln::abstract::neighborhood<N>& nbh)
- {
- oln_nbh_type_of(N, window) output;
-
- for (unsigned i = 0; i < nbh.card(); i++)
- output.add(nbh.dp(i));
-
- oln_nbh_type_of(N, dpoint) zero;
- dpoint_zero(zero);
- output.add(zero);
- return output;
- }
-
-
- } // convert
-} // oln
-
-
-#endif // OLENA_CONVERT_NBH_TO_SE_HH
Index: oln/funobj/accum.hh
===================================================================
--- oln/funobj/accum.hh (revision 166)
+++ oln/funobj/accum.hh (working copy)
@@ -55,7 +55,7 @@
acc_ = t;
return;
}
- if (t > acc_)
+ if (acc_ < t)
acc_ = t;
}
@@ -73,6 +73,10 @@
};
+ // FIXME: ... Max accumulator with initialization value.
+
+
+
/// Min accumulator.
template <class T>
@@ -109,6 +113,35 @@
};
+ /// Min accumulator with initialization value.
+
+ template <class T>
+ struct min_accumulator_init
+ {
+
+ template <typename U>
+ min_accumulator_init(const U& init) :
+ acc_(init)
+ {}
+
+ void operator()(T t)
+ {
+ if (t < acc_)
+ acc_ = t;
+ }
+
+ operator T() const
+ {
+ return acc_;
+ }
+
+ private:
+
+ T acc_;
+
+ };
+
+
} // end of namespace oln::funobj
} // end of namespace oln
Index: oln/core/abstract/niter.hh
===================================================================
--- oln/core/abstract/niter.hh (revision 166)
+++ oln/core/abstract/niter.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005 EPITA Research and Development Laboratory
+// Copyright (C) 2001-2005 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
@@ -29,14 +29,14 @@
# define OLENA_CORE_ABSTRACT_NITER_HH
# include <mlc/contract.hh>
-# include <oln/core/typedefs.hh>
+# include <oln/core/abstract/image.hh>
# include <oln/core/abstract/iter.hh>
# include <oln/core/abstract/point.hh>
# include <oln/core/abstract/neighborhood.hh>
# define for_all_n_of_p(n, p) \
- for(n.ensure_is_niter(), n.center_at(p), n.start(); n.is_valid(); n.next())
+ for(n.ensure_is_niter(), n.start_at_p(p); n.is_valid(); n.next())
# define for_all_remaining_n(n) \
for(n.ensure_is_niter(); n.is_valid(); n.next())
@@ -146,6 +146,32 @@
} // end of namespace oln::abstract
+
+
+ // From image type to niters.
+
+ template <typename I>
+ struct set_type < category::image, I, internal::typedef_::niter_type >
+ {
+ typedef oln_type_of(I, neighb) neighb_t;
+ typedef oln_nbh_type_of(neighb_t, iter) ret;
+ };
+
+ template <typename I>
+ struct set_type < category::image, I, internal::typedef_::fwd_niter_type >
+ {
+ typedef oln_type_of(I, neighb) neighb_t;
+ typedef oln_nbh_type_of(neighb_t, fwd_iter) ret;
+ };
+
+ template <typename I>
+ struct set_type < category::image, I, internal::typedef_::bkd_niter_type >
+ {
+ typedef oln_type_of(I, neighb) neighb_t;
+ typedef oln_nbh_type_of(neighb_t, bkd_iter) ret;
+ };
+
+
} // end of namespace oln
Index: oln/core/abstract/neighborhood.hh
===================================================================
--- oln/core/abstract/neighborhood.hh (revision 166)
+++ oln/core/abstract/neighborhood.hh (working copy)
@@ -50,6 +50,10 @@
typedef mlc::undefined_type dpoint_type;
typedef mlc::undefined_type size_type;
typedef mlc::undefined_type window_type;
+
+ typedef mlc::undefined_type iter_type;
+ typedef mlc::undefined_type fwd_iter_type;
+ typedef mlc::undefined_type bkd_iter_type;
};
@@ -61,14 +65,20 @@
typedef oln_nbh_type_of(N, dpoint) dpoint_type;
typedef oln_nbh_type_of(N, size) size_type;
typedef oln_nbh_type_of(N, window) window_type;
+ typedef oln_nbh_type_of(N, iter) iter_type;
+ typedef oln_nbh_type_of(N, fwd_iter) fwd_iter_type;
+ typedef oln_nbh_type_of(N, bkd_iter) bkd_iter_type;
static void echo(std::ostream& ostr)
{
ostr << "props_of( oln::category::neighborhood, " << mlc_to_string(N) << " ) =" << std::endl
<< "{" << std::endl
- << "\t dpoint_type = " << mlc_to_string(dpoint_type) << std::endl
- << "\t size_type = " << mlc_to_string(size_type) << std::endl
- << "\t window_type = " << mlc_to_string(window_type) << std::endl
+ << "\t dpoint_type = " << mlc_to_string(dpoint_type) << std::endl
+ << "\t size_type = " << mlc_to_string(size_type) << std::endl
+ << "\t window_type = " << mlc_to_string(window_type) << std::endl
+ << "\t iter_type = " << mlc_to_string(iter_type) << std::endl
+ << "\t fwd_iter_type = " << mlc_to_string(fwd_iter_type) << std::endl
+ << "\t bkd_iter_type = " << mlc_to_string(bkd_iter_type) << std::endl
<< "}" << std::endl;
}
@@ -77,6 +87,9 @@
mlc::is_ok< dpoint_type >::ensure();
mlc::is_ok< size_type >::ensure();
mlc::is_ok< window_type >::ensure();
+ mlc::is_ok< iter_type >::ensure();
+ mlc::is_ok< fwd_iter_type >::ensure();
+ mlc::is_ok< bkd_iter_type >::ensure();
}
};
Index: oln/core/abstract/window.hh
===================================================================
--- oln/core/abstract/window.hh (revision 166)
+++ oln/core/abstract/window.hh (working copy)
@@ -28,6 +28,7 @@
#ifndef OLENA_CORE_ABSTRACT_WINDOW_HH
# define OLENA_CORE_ABSTRACT_WINDOW_HH
+# include <mlc/contract.hh>
# include <oln/core/typedefs.hh>
@@ -96,6 +97,13 @@
template<class W>
struct window : public mlc::any<W>
{
+ public:
+
+ const W operator-() const
+ {
+ return this->exact().impl_op_minus();
+ }
+
protected:
window()
@@ -104,6 +112,7 @@
~window()
{
get_props<category::window, W>::ensure();
+ mlc_check_method_impl(W, const W, op_minus, , const);
}
};
Index: oln/core/pw/image.hh
===================================================================
--- oln/core/pw/image.hh (revision 166)
+++ oln/core/pw/image.hh (working copy)
@@ -36,6 +36,8 @@
# include <oln/core/pw/abstract/function.hh>
// FIXME: remove
+# include <oln/core/2d/grid2d.hh>
+# include <oln/core/2d/image2d.hh>
# include <oln/core/2d/fwd_piter2d.hh>
# include <oln/core/2d/bkd_piter2d.hh>
@@ -130,12 +132,14 @@
typedef mlc::no_type delegated_type;
- // FIXME: AWFUL we do not know if it is 2d...
+ // FIXME: EXTREMELY AWFUL!!! we do not know if it is 2d...
typedef is_a<abstract::image2d> image_dimension_type;
+ typedef grid2d grid_type;
typedef fwd_piter2d piter_type;
typedef fwd_piter2d fwd_piter_type;
typedef bkd_piter2d bkd_piter_type;
+ typedef image2d<value_type> concrete_type;
};
Index: oln/core/gen/regular_neighborhood.hh
===================================================================
--- oln/core/gen/regular_neighborhood.hh (revision 166)
+++ oln/core/gen/regular_neighborhood.hh (working copy)
@@ -36,6 +36,8 @@
// fwd decl
template <typename G> class regular_neighborhood;
+ template <typename G> class regular_fwd_niter;
+ template <typename G> class regular_bkd_niter;
// super_type
template <typename G> struct set_super_type< regular_neighborhood<G> > { typedef abstract::neighborhood< regular_neighborhood<G> > ret; };
@@ -61,6 +63,11 @@
typedef oln_grd_type_of(G, dpoint) dpoint_type;
typedef oln_grd_type_of(G, size) size_type;
typedef typename internal::to_window<G>::ret window_type;
+
+ typedef regular_fwd_niter<G> iter_type;
+ typedef regular_fwd_niter<G> fwd_iter_type;
+ typedef regular_bkd_niter<G> bkd_iter_type;
+
};
1
0
2005-04-27 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* mlc/contract.hh (mlc_check_method_impl): Fix bug.
(mlc_check_method_impl_2): Likewise.
Index: mlc/contract.hh
===================================================================
--- mlc/contract.hh (revision 165)
+++ mlc/contract.hh (working copy)
@@ -40,21 +40,22 @@
# define postcondition(expr) assert(expr)
+
# define mlc_check_method_impl(WHERE, RETURN, NAME, ARG, CONST) \
{ \
typedef RETURN (WHERE::*meth)(ARG) CONST; \
- meth adr = &E::impl_##NAME; \
+ meth adr = &WHERE::impl_##NAME; \
adr = 0; \
} \
struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
-# define mlc_check_method_impl_2(WHERE, RETURN, NAME, ARG1, ARG2, CONST) \
-{ \
- typedef RETURN (WHERE::*meth)(ARG1, ARG2) CONST; \
- meth adr = &E::impl_##NAME; \
- adr = 0; \
-} \
+# define mlc_check_method_impl_2(WHERE, RETURN, NAME, ARG1, ARG2, CONST) \
+{ \
+ typedef RETURN (WHERE::*meth)(ARG1, ARG2) CONST; \
+ meth adr = &WHERE::impl_##NAME; \
+ adr = 0; \
+} \
struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
1
1
2005-04-27 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* oln/core/abstract/image_with_extension.hh (real): Fix
signature ---such an image is mutable so 'real' should be
const and should return non-const.
* oln/core/gen/regular_fwd_niter.hh (friend): Fix bug.
* oln/core/gen/regular_bkd_niter.hh: Likewise.
* oln/core/gen/image_with_nbh.hh (concrete_type): Fix bug.
(image_with_nbh()): New ctor.
(image_with_nbh(size)): New ctor.
(nbh_): Fix bug ---change type so that nbh is really owned.
* oln/core/gen/regular_window.hh (operator-): Rename as...
(impl_op_minus): ...this and fix bug.
(dp): New method.
2005-04-20 Damien Thivolle <damien(a)lrde.epita.fr>
* oln/morpho/reconstruction.hh: Remove a comment.
Index: oln/core/abstract/image_with_extension.hh
===================================================================
--- oln/core/abstract/image_with_extension.hh (revision 165)
+++ oln/core/abstract/image_with_extension.hh (working copy)
@@ -73,16 +73,11 @@
{
}
- const I& real() const
+ I& real() const
{
- return this->image_.unbox();
+ return const_cast<I&>(this->image_.unbox());
}
- I& real()
- {
- return this->image_.unbox();
- }
-
~image_with_extension ()
{
// FIXME : This class must check all properties
Index: oln/core/gen/regular_fwd_niter.hh
===================================================================
--- oln/core/gen/regular_fwd_niter.hh (revision 165)
+++ oln/core/gen/regular_fwd_niter.hh (working copy)
@@ -55,6 +55,7 @@
}
friend class abstract::iter<self_type>;
+ friend class abstract::niter<self_type>;
protected:
@@ -70,7 +71,7 @@
bool impl_is_valid() const
{
- return this->pos_ != this->nbh_.card();
+ return this->pos_ != int(this->nbh_.card());
}
void impl_invalidate()
Index: oln/core/gen/regular_bkd_niter.hh
===================================================================
--- oln/core/gen/regular_bkd_niter.hh (revision 165)
+++ oln/core/gen/regular_bkd_niter.hh (working copy)
@@ -55,6 +55,7 @@
}
friend class abstract::iter<self_type>;
+ friend class abstract::niter<self_type>;
protected:
Index: oln/core/gen/image_with_nbh.hh
===================================================================
--- oln/core/gen/image_with_nbh.hh (revision 165)
+++ oln/core/gen/image_with_nbh.hh (working copy)
@@ -48,6 +48,7 @@
{
typedef is_a<abstract::image_with_nbh> image_neighbness_type;
typedef N neighb_type;
+ typedef image_with_nbh< oln_type_of(I, concrete), N> concrete_type;
};
template <typename I, typename N>
@@ -58,6 +59,16 @@
public:
+ image_with_nbh()
+ {
+ }
+
+ image_with_nbh(const oln_type_of(I, size)& size)
+ {
+ I tmp(size); // FIXME: hack
+ this->image_ = tmp;
+ }
+
image_with_nbh(abstract::image<I>& image,
const abstract::neighborhood<N>& nbh) :
super_type(image),
@@ -65,6 +76,13 @@
{
}
+ image_with_nbh(abstract::image<I>& image,
+ const abstract::neighborhood<N>& nbh) :
+ super_type(image),
+ nbh_(nbh.exact())
+ {
+ }
+
const N& impl_nbh_get() const
{
return nbh_;
@@ -72,7 +90,7 @@
protected:
- const N& nbh_;
+ N nbh_;
};
Index: oln/core/gen/regular_window.hh
===================================================================
--- oln/core/gen/regular_window.hh (revision 165)
+++ oln/core/gen/regular_window.hh (working copy)
@@ -97,11 +97,17 @@
return this->dp_[i];
}
- const self_type operator-() const
+ dpoint_type& dp(unsigned i)
{
- self_type tmp;
+ precondition(i < this->card());
+ return this->dp_[i];
+ }
+
+ const E impl_op_minus() const
+ {
+ E tmp = this->exact(); // FIXME: use clone(?)
for (unsigned i = 0; i < this->card(); ++i)
- tmp.add_(- this->dp_[i]);
+ tmp.dp(i) = - tmp.dp(i);
return tmp;
}
1
0