
* mln/accu/label_used.hh, * mln/core/internal/labeled_image_base.hh, * mln/labeling/colorize.hh, * mln/labeling/compute.hh, * mln/labeling/superpose.hh, * mln/make/relabelfun.hh, * mln/set/compute_with_weights.hh: Make use of value::next. --- milena/ChangeLog | 12 ++++++++++++ milena/mln/accu/label_used.hh | 3 ++- milena/mln/core/internal/labeled_image_base.hh | 6 ++++-- milena/mln/labeling/colorize.hh | 7 ++++--- milena/mln/labeling/compute.hh | 23 ++++++++++++----------- milena/mln/labeling/relabel.hh | 6 ++---- milena/mln/labeling/superpose.hh | 14 +++++++++----- milena/mln/make/relabelfun.hh | 9 +++++---- milena/mln/set/compute_with_weights.hh | 6 ++++-- 9 files changed, 54 insertions(+), 32 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index a5da997..5feeb2c 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,17 @@ 2010-10-21 Guillaume Lazzara <z@lrde.epita.fr> + Make use of value::next in Milena. + + * mln/accu/label_used.hh, + * mln/core/internal/labeled_image_base.hh, + * mln/labeling/colorize.hh, + * mln/labeling/compute.hh, + * mln/labeling/superpose.hh, + * mln/make/relabelfun.hh, + * mln/set/compute_with_weights.hh: Make use of value::next. + +2010-10-21 Guillaume Lazzara <z@lrde.epita.fr> + Add value::next routine. * mln/value/label.hh: Include next routine. diff --git a/milena/mln/accu/label_used.hh b/milena/mln/accu/label_used.hh index d6d2b20..69121b1 100644 --- a/milena/mln/accu/label_used.hh +++ b/milena/mln/accu/label_used.hh @@ -34,6 +34,7 @@ # include <mln/accu/internal/base.hh> # include <mln/core/concept/meta_accumulator.hh> # include <mln/math/max.hh> +# include <mln/value/next.hh> # include <mln/fun/i2v/array.hh> @@ -117,7 +118,7 @@ namespace mln label_used<L>::take(const argument& l) { if (label_used_.size() <= l) - label_used_.resize(unsigned(l) + 1, false); + label_used_.resize(value::next(l), false); label_used_(l) = true; } diff --git a/milena/mln/core/internal/labeled_image_base.hh b/milena/mln/core/internal/labeled_image_base.hh index 86bb077..45f3ed2 100644 --- a/milena/mln/core/internal/labeled_image_base.hh +++ b/milena/mln/core/internal/labeled_image_base.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -40,6 +41,7 @@ # include <mln/labeling/relabel.hh> # include <mln/util/array.hh> +# include <mln/value/next.hh> # include <mln/pw/cst.hh> # include <mln/pw/value.hh> @@ -279,7 +281,7 @@ namespace mln labeled_image_base<I,E>::update_data(const fun::i2v::array<mln_value(I)>& relabel_fun) { util::array<accu::shape::bbox<mln_psite(I)> > - new_bboxes(static_cast<unsigned>(this->data_->nlabels_) + 1); + new_bboxes(mln::value::next(this->data_->nlabels_)); exact(this)->init_update_data_(); diff --git a/milena/mln/labeling/colorize.hh b/milena/mln/labeling/colorize.hh index 78a06f4..673af27 100644 --- a/milena/mln/labeling/colorize.hh +++ b/milena/mln/labeling/colorize.hh @@ -1,5 +1,5 @@ -// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2008, 2009, 2010 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -40,6 +40,7 @@ # include <mln/accu/stat/max.hh> # include <mln/util/array.hh> # include <mln/util/set.hh> +# include <mln/value/next.hh> namespace mln @@ -192,7 +193,7 @@ namespace mln // mlc_is_a(mln_value(L), mln::value::Symbolic)::check(); (void) value; - unsigned label_count = static_cast<unsigned>(nlabels) + 1; + unsigned label_count = value::next(nlabels); static fun::i2v::array<V> f(0); int diff_size = f.size() - label_count; if (diff_size < 0) diff --git a/milena/mln/labeling/compute.hh b/milena/mln/labeling/compute.hh index 56cb92a..5e5c5f0 100644 --- a/milena/mln/labeling/compute.hh +++ b/milena/mln/labeling/compute.hh @@ -51,6 +51,7 @@ # include <mln/util/array.hh> # include <mln/convert/from_to.hh> # include <mln/geom/ncols.hh> +# include <mln/value/next.hh> namespace mln @@ -210,7 +211,7 @@ namespace mln const A& a = exact(a_); const L& label = exact(label_); - util::array<A> accus(static_cast<unsigned>(nlabels) + 1, a); + util::array<A> accus(value::next(nlabels), a); mln_piter(L) p(label.domain()); for_all(p) @@ -244,12 +245,12 @@ namespace mln trace::entering("labeling::impl::generic::compute"); internal::compute_tests(A(), label_, nlabels); - if (static_cast<unsigned>(nlabels) + 1 != accus.size()) + if (value::next(nlabels) != accus.size()) { accus.resize(0); // Make sure all the accumulators are // re-initialized when resizing on next // line. - accus.resize(static_cast<unsigned>(nlabels) + 1); + accus.resize(value::next(nlabels)); } const L& label = exact(label_); @@ -291,7 +292,7 @@ namespace mln const I& input = exact(input_); const L& label = exact(label_); - util::array<A> accus(static_cast<unsigned>(nlabels) + 1, a); + util::array<A> accus(value::next(nlabels), a); mln_piter(I) p(input.domain()); for_all(p) @@ -330,12 +331,12 @@ namespace mln const L& label = exact(label_); (void) nlabels; - if (static_cast<unsigned>(nlabels) + 1 != accus.size()) + if (value::next(nlabels) != accus.size()) { accus.resize(0); // Make sure all the accumulators are // re-initialized when resizing on next // line. - accus.resize(static_cast<unsigned>(nlabels) + 1); + accus.resize(value::next(nlabels)); } mln_piter(I) p(input.domain()); @@ -383,7 +384,7 @@ namespace mln // FIXME: check image properties + add doc. - util::array<A> accus(static_cast<unsigned>(nlabels) + 1, a); + util::array<A> accus(value::next(nlabels), a); unsigned ncols = geom::ncols(label); @@ -438,12 +439,12 @@ namespace mln const L& label = exact(label_); (void) nlabels; - if (static_cast<unsigned>(nlabels) + 1 != accus.size()) + if (value::next(nlabels) != accus.size()) { accus.resize(0); // Make sure all the accumulators are // re-initialized when resizing on next // line. - accus.resize(static_cast<unsigned>(nlabels) + 1); + accus.resize(value::next(nlabels)); } unsigned ncols = geom::ncols(label); @@ -742,7 +743,7 @@ namespace mln typedef util::array<mln_result(A)> R; R res = internal::compute_dispatch(accus, label, nlabels); - mln_postcondition(res.nelements() == static_cast<unsigned>(nlabels) + 1); + mln_postcondition(res.nelements() == value::next(nlabels)); trace::exiting("labeling::compute"); return res; @@ -764,7 +765,7 @@ namespace mln typedef util::array<mln_result(A)> R; R res = internal::compute_dispatch(a, label, nlabels); - mln_postcondition(res.nelements() == static_cast<unsigned>(nlabels) + 1); + mln_postcondition(res.nelements() == value::next(nlabels)); trace::exiting("labeling::compute"); return res; diff --git a/milena/mln/labeling/relabel.hh b/milena/mln/labeling/relabel.hh index c3a473f..91db122 100644 --- a/milena/mln/labeling/relabel.hh +++ b/milena/mln/labeling/relabel.hh @@ -1,5 +1,5 @@ -// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2008, 2009, 2010 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -39,8 +39,6 @@ # include <mln/data/transform.hh> # include <mln/data/transform_inplace.hh> -# include <mln/value/label.hh> - namespace mln diff --git a/milena/mln/labeling/superpose.hh b/milena/mln/labeling/superpose.hh index 7d0b3e3..1df647c 100644 --- a/milena/mln/labeling/superpose.hh +++ b/milena/mln/labeling/superpose.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -37,6 +38,9 @@ # include <mln/data/paste.hh> # include <mln/pw/all.hh> +# include <mln/value/next.hh> +# include <mln/value/equiv.hh> + namespace mln { @@ -94,18 +98,18 @@ namespace mln mln_concrete(I) output = duplicate(lhs); util::array<mln_value(J)> - rebase_lbl(static_cast<unsigned>(rhs_nlabels) + 1); + rebase_lbl(value::next(rhs_nlabels)); rebase_lbl(0) = 0; for (unsigned i = 1; i <= rhs_nlabels; ++i) - rebase_lbl(i) = i + static_cast<unsigned>(lhs_nlabels); + rebase_lbl(i) = i + value::equiv(lhs_nlabels); data::paste(labeling::relabel(rhs, rhs_nlabels, rebase_lbl) | (pw::value(rhs) != pw::cst(literal::zero)), output); - new_nlabels = static_cast<unsigned>(lhs_nlabels) - + static_cast<unsigned>(rhs_nlabels) + 1; + new_nlabels = value::equiv(lhs_nlabels) + + value::equiv(rhs_nlabels) + 1; trace::exiting("mln::labeling::superpose"); return output; diff --git a/milena/mln/make/relabelfun.hh b/milena/mln/make/relabelfun.hh index 0a841f2..bc423fb 100644 --- a/milena/mln/make/relabelfun.hh +++ b/milena/mln/make/relabelfun.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2008, 2009, 2010 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -32,7 +33,7 @@ # include <mln/core/concept/function.hh> # include <mln/fun/i2v/array.hh> -# include <mln/value/label.hh> +# include <mln/value/next.hh> namespace mln { @@ -87,7 +88,7 @@ namespace mln const F& fv2b = exact(fv2b_); - unsigned nlabels_i = static_cast<unsigned>(nlabels) + 1; + unsigned nlabels_i = value::next(nlabels); V tmp_nlabels = literal::zero; fun::i2v::array<V> fi2v(nlabels_i, literal::zero); for (V i = 1; i < nlabels_i; ++i) @@ -110,7 +111,7 @@ namespace mln const F& fv2v = exact(fv2v_); - unsigned nlabels_i = static_cast<unsigned>(nlabels) + 1; + unsigned nlabels_i = value::next(nlabels); util::array<V> new_labels(nlabels_i, mln_max(V)); new_labels(0) = literal::zero; diff --git a/milena/mln/set/compute_with_weights.hh b/milena/mln/set/compute_with_weights.hh index b2ae04d..24da256 100644 --- a/milena/mln/set/compute_with_weights.hh +++ b/milena/mln/set/compute_with_weights.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2008, 2009, 2010 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -37,6 +38,7 @@ # include <mln/core/concept/site_set.hh> # include <mln/util/array.hh> # include <mln/convert/from_to.hh> +# include <mln/value/next.hh> namespace mln @@ -187,7 +189,7 @@ namespace mln internal::compute_with_weights_tests(a, w, label); - util::array<A> accus(static_cast<unsigned>(nlabels) + 1, a); + util::array<A> accus(value::next(nlabels), a); mln_piter(I) p(w.domain()); for_all(p) -- 1.5.6.5