3507: Various small fixes.

* headers.mk: update dist header list. * mln/algebra/vec.hh: add contructor and operator= with literal::zero. * mln/canvas/distance_front.hh: avoid a warning. * mln/fun/i2v/array.hh, * mln/fun/l2l/relabel.hh, * mln/convert/from_to.hxx: add new from_to over_loads. * mln/convert/impl/all.hh, * mln/convert/impl/from_unsigned_to_value.hh: add a new from_to implementation to fix ambiguities with from_int_to_value and from_float_to_value. * mln/win/essential.hh, * mln/core/internal/image_identity.hh: update doc. * mln/core/routine/essential.hh: fix includes. * mln/fun/essential.hh: include fun/meta/essential.hh. * mln/util/soft_heap.hh: fix guards. --- milena/ChangeLog | 28 +++++ milena/headers.mk | 12 +- milena/mln/algebra/vec.hh | 26 ++++- milena/mln/canvas/distance_front.hh | 1 + milena/mln/convert/from_to.hxx | 42 +++++++ milena/mln/convert/impl/all.hh | 1 + milena/mln/convert/impl/from_unsigned_to_value.hh | 132 +++++++++++++++++++++ milena/mln/core/internal/image_identity.hh | 15 +-- milena/mln/core/routine/essential.hh | 12 +- milena/mln/fun/essential.hh | 10 +- milena/mln/fun/i2v/array.hh | 34 ++++++ milena/mln/fun/l2l/relabel.hh | 34 ++++++ milena/mln/util/soft_heap.hh | 6 +- milena/mln/win/essential.hh | 9 +- 14 files changed, 328 insertions(+), 34 deletions(-) create mode 100644 milena/mln/convert/impl/from_unsigned_to_value.hh diff --git a/milena/ChangeLog b/milena/ChangeLog index 4f0c24c..199bdd1 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,33 @@ 2009-03-10 Guillaume Lazzara <lazzara@lrde.epita.fr> + Various small fixes. + + * headers.mk: update dist header list. + + * mln/algebra/vec.hh: add contructor and operator= with literal::zero. + + * mln/canvas/distance_front.hh: avoid a warning. + + * mln/fun/i2v/array.hh, + * mln/fun/l2l/relabel.hh, + * mln/convert/from_to.hxx: add new from_to over_loads. + + * mln/convert/impl/all.hh, + * mln/convert/impl/from_unsigned_to_value.hh: add a new from_to + implementation to fix ambiguities with from_int_to_value and + from_float_to_value. + + * mln/win/essential.hh, + * mln/core/internal/image_identity.hh: update doc. + + * mln/core/routine/essential.hh: fix includes. + + * mln/fun/essential.hh: include fun/meta/essential.hh. + + * mln/util/soft_heap.hh: fix guards. + +2009-03-10 Guillaume Lazzara <lazzara@lrde.epita.fr> + Add meta::first and meta::second. * mln/fun/meta/all.hh, diff --git a/milena/headers.mk b/milena/headers.mk index e37427e..9513a84 100644 --- a/milena/headers.mk +++ b/milena/headers.mk @@ -95,6 +95,7 @@ mln/util/line_graph.hh \ mln/util/ord.hh \ mln/util/tree_fast_to_image.hh \ mln/util/tree.hh \ +mln/util/couple.hh \ mln/util/index.hh \ mln/util/multi_site.hh \ mln/util/branch_iter.hh \ @@ -367,6 +368,7 @@ mln/value/label_8.hh \ mln/value/essential.hh \ mln/accu/tuple.hh \ mln/accu/min_h.hh \ +mln/accu/stat/deviation.hh \ mln/accu/max.hh \ mln/accu/lor.hh \ mln/accu/rank.hh \ @@ -602,7 +604,6 @@ mln/linear/log.hh \ mln/linear/essential.hh \ mln/morpho/thinning.hh \ mln/morpho/meyer_wst.hh \ -mln/morpho/opening.hh \ mln/morpho/includes.hh \ mln/morpho/elementary/opening.hh \ mln/morpho/elementary/gradient_internal.hh \ @@ -634,7 +635,9 @@ mln/morpho/closing/leveling.hh \ mln/morpho/closing/area_on_vertices.hh \ mln/morpho/closing/area.hh \ mln/morpho/closing/volume.hh \ +mln/morpho/closing/sum.hh \ mln/morpho/closing/height.hh \ +mln/morpho/closing/structural.hh \ mln/morpho/closing/essential.hh \ mln/morpho/laplacian.hh \ mln/morpho/all.hh \ @@ -647,6 +650,7 @@ mln/morpho/opening/area_on_vertices.hh \ mln/morpho/opening/area.hh \ mln/morpho/opening/volume.hh \ mln/morpho/opening/height.hh \ +mln/morpho/opening/structural.hh \ mln/morpho/opening/essential.hh \ mln/morpho/attribute/all.hh \ mln/morpho/attribute/volume.hh \ @@ -665,15 +669,12 @@ mln/morpho/tree/data.hh \ mln/morpho/tree/compute_attribute_image.hh \ mln/morpho/general.spe.hh \ mln/morpho/min.hh \ -mln/morpho/closing.hh \ mln/morpho/top_hat.hh \ mln/morpho/erosion.hh \ mln/morpho/leveling_filter.hh \ -mln/morpho/closing_sum.hh \ mln/morpho/Rd.hh \ mln/morpho/thick_miss.hh \ mln/morpho/algebraic_filter.hh \ -mln/morpho/closing_attribute.hh \ mln/morpho/rank_filter.hh \ mln/morpho/essential.hh \ mln/topo/n_face_iter.hh \ @@ -708,6 +709,7 @@ mln/essential/routine.hh \ mln/essential/3d.hh \ mln/essential/2d.hh \ mln/win/inter.hh \ +mln/win/sphere3d.hh \ mln/win/backdiag2d.hh \ mln/win/segment1d.hh \ mln/win/cuboid3d.hh \ @@ -718,10 +720,10 @@ mln/win/multiple_size.hh \ mln/win/cube3d.hh \ mln/win/shift.hh \ mln/win/sym.hh \ +mln/win/ball.hh \ mln/win/diff.hh \ mln/win/multiple.hh \ mln/win/diag2d.hh \ -mln/win/ball3d.hh \ mln/win/disk2d.hh \ mln/win/rectangle2d.hh \ mln/win/hline2d.hh \ diff --git a/milena/mln/algebra/vec.hh b/milena/mln/algebra/vec.hh index da2541c..9563a27 100644 --- a/milena/mln/algebra/vec.hh +++ b/milena/mln/algebra/vec.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2006, 2008 EPITA Research and Development Laboratory +// Copyright (C) 2006, 2008, 2009 EPITA Research and Development Laboratory // (LRDE) // // This file is part of the Olena Library. This library is free @@ -39,6 +39,7 @@ # include <mln/core/concept/object.hh> # include <mln/literal/zero.hh> +# include <mln/literal/origin.hh> # include <mln/norm/l2.hh> # include <mln/trait/all.hh> # include <mln/trait/value_.hh> @@ -188,11 +189,16 @@ namespace mln vec(); - /// \{ Constructors/assignments with literal zero. + /// \{ Constructors/assignments with literal::zero. vec(const literal::zero_t&); vec& operator=(const literal::zero_t&); /// \} + /// \{ Constructors/assignments with literal::origin. + vec(const literal::origin_t&); + vec& operator=(const literal::origin_t&); + /// \} + vec(const vec<n, T>& rhs); template <typename U> @@ -386,6 +392,22 @@ namespace mln template <unsigned n, typename T> inline + vec<n,T>::vec(const literal::origin_t&) + { + this->set_all(0); + } + + template <unsigned n, typename T> + inline + vec<n,T>& + vec<n,T>::operator=(const literal::origin_t&) + { + this->set_all(0); + return *this; + } + + template <unsigned n, typename T> + inline vec<n,T>::vec(const vec<n,T>& rhs) : super_() { diff --git a/milena/mln/canvas/distance_front.hh b/milena/mln/canvas/distance_front.hh index f374a2b..3eb8eeb 100644 --- a/milena/mln/canvas/distance_front.hh +++ b/milena/mln/canvas/distance_front.hh @@ -88,6 +88,7 @@ namespace mln (void) nbh; (void) max; (void) functor; + (void) w_win; } diff --git a/milena/mln/convert/from_to.hxx b/milena/mln/convert/from_to.hxx index df12d5d..d4ccc22 100644 --- a/milena/mln/convert/from_to.hxx +++ b/milena/mln/convert/from_to.hxx @@ -76,6 +76,10 @@ namespace mln namespace i2v { template <typename T> class array; } + + namespace l2l { + template <typename T> class relabel; + } } namespace histo { @@ -333,17 +337,55 @@ namespace mln void from_to_(const util::array<T>& from, fun::i2v::array<T>& to); + // util::array<T> -> fun::i2v::array<U> + template <typename T, typename U> + void + from_to_(const util::array<T>& from, fun::i2v::array<U>& to); + // std::vector<T> -> fun::i2v::array<T> template <typename T> void from_to_(const std::vector<T>& from, fun::i2v::array<T>& to); + // std::vector<T> -> fun::i2v::array<U> + template <typename T, typename U> + void + from_to_(const std::vector<T>& from, fun::i2v::array<U>& to); + + // util::array<T1> -> util::array<T2> + template <typename T1, typename T2> + void + from_to_(const util::array<T1>& from, util::array<T2>& to); + + + + // util::array<T> -> fun::l2l::relabel<T> + template <typename T> + void + from_to_(const util::array<T>& from, fun::l2l::relabel<T>& to); + + // util::array<T> -> fun::l2l::relabel<U> + template <typename T, typename U> + void + from_to_(const util::array<T>& from, fun::l2l::relabel<U>& to); + + // std::vector<T> -> fun::l2l::relabel<T> + template <typename T> + void + from_to_(const std::vector<T>& from, fun::l2l::relabel<T>& to); + + // std::vector<T> -> fun::l2l::relabel<U> + template <typename T, typename U> + void + from_to_(const std::vector<T>& from, fun::l2l::relabel<U>& to); + // util::array<T1> -> util::array<T2> template <typename T1, typename T2> void from_to_(const util::array<T1>& from, util::array<T2>& to); + // Accumulator<A> -> mln_result(A) template <typename A> void diff --git a/milena/mln/convert/impl/all.hh b/milena/mln/convert/impl/all.hh index dcaaf24..28cdde1 100644 --- a/milena/mln/convert/impl/all.hh +++ b/milena/mln/convert/impl/all.hh @@ -38,6 +38,7 @@ # include <mln/convert/impl/from_image_to_site_set.hh> # include <mln/convert/impl/from_int_to_value.hh> # include <mln/convert/impl/from_site_set_to_image.hh> +# include <mln/convert/impl/from_unsigned_to_value.hh> # include <mln/convert/impl/from_value_to_value.hh> diff --git a/milena/mln/convert/impl/from_unsigned_to_value.hh b/milena/mln/convert/impl/from_unsigned_to_value.hh new file mode 100644 index 0000000..4c6bac7 --- /dev/null +++ b/milena/mln/convert/impl/from_unsigned_to_value.hh @@ -0,0 +1,132 @@ +// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef MLN_CONVERT_IMPL_FROM_UNSIGNED_TO_VALUE_HH +# define MLN_CONVERT_IMPL_FROM_UNSIGNED_TO_VALUE_HH + +/// \file mln/convert/impl/from_unsigned_to_value.hh +/// +/// General conversion procedure from an unsigned to a value. +/// +/// \todo Augment code + add checks. + +# include <utility> +# include <mln/value/concept/integer.hh> +# include <mln/core/concept/value.hh> +# include <mln/math/round.hh> + + + + +namespace mln +{ + + namespace convert + { + + /// Conversion of an unsigned \p from towards a value \p to. + template <typename V> + void + from_to(const unsigned& from, Value<V>& to); + + +# ifndef MLN_INCLUDE_ONLY + + namespace impl + { + + // Case 1: + + template <typename V> + inline + void + from_unsigned_to_value(const unsigned& from, + mln::value::Integer<V>& to) + { + exact(to) = from; + } + + template <unsigned n> + inline + void + from_unsigned_to_value(const unsigned& from, + mln::value::label<n>& to) + { + exact(to) = from; + } + + // Default: no conversion defined. + + template <typename V> + inline + void + from_unsigned_to_value(const unsigned&, + Value<V>&) + { + mlc_abort(V)::check(); + } + + } // end of namespace mln::convert::impl + + + namespace internal + { + + template <typename V> + inline + void + from_unsigned_to_value_dispatch(const unsigned& from, Value<V>& to) + { + impl::from_unsigned_to_value(from, exact(to)); + } + + } // end of namespace mln::convert::unsignedernal + + + namespace over_load + { + + // Facades. + // unsigned-> Value + template <typename V> + void + from_to_(const unsigned& from, Value<V>& to) + { + internal::from_unsigned_to_value_dispatch(from, to); + } + + } // end of namespace mln::convert::over_load + + +# endif // ! MLN_INCLUDE_ONLY + + } // end of namespace mln::convert + +} // end of namespace mln + + +#endif // ! MLN_CONVERT_IMPL_FROM_UNSIGNED_TO_VALUE_HH diff --git a/milena/mln/core/internal/image_identity.hh b/milena/mln/core/internal/image_identity.hh index 3a2b20b..bddcdf7 100644 --- a/milena/mln/core/internal/image_identity.hh +++ b/milena/mln/core/internal/image_identity.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2009 EPITA Research and Development Laboratory // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -28,13 +28,12 @@ #ifndef MLN_CORE_INTERNAL_IMAGE_IDENTITY_HH # define MLN_CORE_INTERNAL_IMAGE_IDENTITY_HH -/*! \file mln/core/internal/image_identity.hh - * - * \brief Definition of a base class for image morphers w.r.t. identity. - * - * \todo Move "fastest impl" elsewhere; it can be used by some other - * classes. - */ +/// \file mln/core/internal/image_identity.hh +/// +/// Definition of a base class for image morphers w.r.t. identity. +/// +/// \todo Move "fastest impl" elsewhere; it can be used by some other +/// classes. # include <mln/core/internal/image_morpher.hh> diff --git a/milena/mln/core/routine/essential.hh b/milena/mln/core/routine/essential.hh index 26568e5..dfc3d44 100644 --- a/milena/mln/core/routine/essential.hh +++ b/milena/mln/core/routine/essential.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory +// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -28,11 +28,11 @@ #ifndef MLN_CORE_ROUTINE_ESSENTIAL_HH_ # define MLN_CORE_ROUTINE_ESSENTIAL_HH_ -# include <mln/core/routine/duplicate.hh> -# include <mln/core/routine/exact.hh> -# include <mln/core/routine/extend.hh> -# include <mln/core/routine/initialize.hh> -# include <mln/core/routine/ops.hh> +/// \file mln/core/routine/essential.hh +/// +/// File that includes essential core routines. + +# include <mln/core/routine/all.hh> #endif // !MLN_CORE_ROUTINE_ESSENTIAL_HH_ diff --git a/milena/mln/fun/essential.hh b/milena/mln/fun/essential.hh index 9626e45..393242e 100644 --- a/milena/mln/fun/essential.hh +++ b/milena/mln/fun/essential.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory +// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -28,14 +28,14 @@ #ifndef MLN_FUN_ESSENTIAL_HH # define MLN_FUN_ESSENTIAL_HH -/*! \file mln/fun/essential.hh - * - * \brief File that includes essential fun-related routines. - */ +/// \file mln/fun/essential.hh +/// +/// File that includes essential fun-related routines. # include <mln/fun/c.hh> # include <mln/fun/ops.hh> # include <mln/fun/i2v/essential.hh> +# include <mln/fun/meta/essential.hh> # include <mln/fun/p2b/essential.hh> # include <mln/fun/p2v/essential.hh> # include <mln/fun/v2b/essential.hh> diff --git a/milena/mln/fun/i2v/array.hh b/milena/mln/fun/i2v/array.hh index 13b6d5e..cd00db5 100644 --- a/milena/mln/fun/i2v/array.hh +++ b/milena/mln/fun/i2v/array.hh @@ -75,11 +75,22 @@ namespace mln void from_to_(const util::array<T>& from, fun::i2v::array<T>& to); + template <typename T, typename U> + inline + void + from_to_(const util::array<T>& from, fun::i2v::array<U>& to); + template <typename T> inline void from_to_(const std::vector<T>& from, fun::i2v::array<T>& to); + template <typename T, typename U> + inline + void + from_to_(const std::vector<T>& from, fun::i2v::array<U>& to); + + } // end of namespace mln::convert::over_load } // end of namespace mln::convert @@ -157,6 +168,17 @@ namespace mln to = fun::i2v::array<T>(from); } + template <typename T, typename U> + inline + void + from_to_(const util::array<T>& from, fun::i2v::array<U>& to) + { + mlc_converts_to(T,U)::check(); + + for (unsigned i = 0; i < from.nelements(); ++i) + to.append(convert::to<U>(from[i])); + } + template <typename T> inline void @@ -165,6 +187,18 @@ namespace mln to = fun::i2v::array<T>(from); } + template <typename T, typename U> + inline + void + from_to_(const std::vector<T>& from, fun::i2v::array<U>& to) + { + mlc_converts_to(T,U)::check(); + + for (unsigned i = 0; i < from.size(); ++i) + to.append(convert::to<U>(from[i])); + } + + } // end of namespace mln::convert::over_load } // end of namespace mln::convert diff --git a/milena/mln/fun/l2l/relabel.hh b/milena/mln/fun/l2l/relabel.hh index 16da5b4..a57f3d4 100644 --- a/milena/mln/fun/l2l/relabel.hh +++ b/milena/mln/fun/l2l/relabel.hh @@ -72,12 +72,24 @@ namespace mln from_to_(const util::array<L>& from, fun::l2l::relabel<L>& to); + template <typename T, typename L> + inline + void + from_to_(const util::array<T>& from, + fun::l2l::relabel<L>& to); + template <typename L> inline void from_to_(const std::vector<L>& from, fun::l2l::relabel<L>& to); + template <typename T, typename L> + inline + void + from_to_(const std::vector<T>& from, + fun::l2l::relabel<L>& to); + } // end of namespace mln::convert::over_load } // end of namespace mln::convert @@ -155,6 +167,17 @@ namespace mln to = fun::l2l::relabel<L>(from); } + template <typename T, typename L> + inline + void + from_to_(const util::array<T>& from, fun::l2l::relabel<L>& to) + { + mlc_converts_to(T,L)::check(); + + for (unsigned i = 0; i < from.nelements(); ++i) + to.append(convert::to<L>(from[i])); + } + template <typename L> inline void @@ -163,6 +186,17 @@ namespace mln to = fun::l2l::relabel<L>(from); } + template <typename T, typename L> + inline + void + from_to_(const std::vector<T>& from, fun::l2l::relabel<L>& to) + { + mlc_converts_to(T,L)::check(); + + for (unsigned i = 0; i < from.size(); ++i) + to.append(convert::to<L>(from[i])); + } + } // end of namespace mln::convert::over_load } // end of namespace mln::convert diff --git a/milena/mln/util/soft_heap.hh b/milena/mln/util/soft_heap.hh index bff9d11..e0f8768 100644 --- a/milena/mln/util/soft_heap.hh +++ b/milena/mln/util/soft_heap.hh @@ -25,8 +25,8 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef MLN_UTIL_FAST_HEAP_HH -# define MLN_UTIL_FAST_HEAP_HH +#ifndef MLN_UTIL_SOFT_HEAP_HH +# define MLN_UTIL_SOFT_HEAP_HH /// \file mln/util/soft_heap.hh /// @@ -1132,4 +1132,4 @@ namespace mln } // end of namespace mln -#endif // ! MLN_UTIL_FAST_HEAP_HH +#endif // ! MLN_UTIL_SOFT_HEAP_HH diff --git a/milena/mln/win/essential.hh b/milena/mln/win/essential.hh index e6fe809..00a4995 100644 --- a/milena/mln/win/essential.hh +++ b/milena/mln/win/essential.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory +// Copyright (C) 2009 EPITA Research and Development Laboratory // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -28,10 +28,9 @@ #ifndef MLN_WIN_ESSENTIAL_HH # define MLN_WIN_ESSENTIAL_HH -/*! \file mln/win/essential.hh - * - * \brief File that includes essential win-related routines. - */ +/// \file mln/win/essential.hh +/// +/// File that includes essential win-related routines. // Types. -- 1.5.6.5
participants (1)
-
Guillaume Lazzara