
2005-04-14 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr> * oln/core/abstract/niter.hh (start): Rename as... (start_): ...this. (center_at): Add invalidate call. * oln/core/abstract/iter.hh (start): Move to... * oln/core/abstract/piter.hh (start): ...here. * oln/core/abstract/qiter.hh: ...and here. * oln/core/apply.hh: Update. * oln/core/pw/image.hh: Likewise. * oln/core/gen/regular_fwd_niter.hh: Likewise. * oln/core/gen/regular_bkd_niter.hh: Likewise. * oln/core/gen/regular_fwd_qiter.hh: Likewise. * oln/core/gen/regular_bkd_qiter.hh: Likewise. * oln/utils/md5.hxx: Likewise. * oln/utils/clone.hh: Likewise. * oln/fancy/iota.hh: Likewise. * oln/morpho/reconstruction.hh: Likewise. * oln/morpho/dilation.hh: Likewise. * oln/morpho/splitse.hh: Likewise. * oln/morpho/geodesic_dilation.hh: Likewise. * oln/morpho/stat.hh: Likewise. * oln/morpho/erosion.hh: Likewise. * oln/morpho/geodesic_erosion.hh: Likewise. * oln/level/fill.hh: Likewise. * oln/level/compare.hh: Likewise. * oln/arith/min.hh: Likewise. * oln/arith/max.hh: Likewise. Index: oln/core/apply.hh =================================================================== --- oln/core/apply.hh (revision 146) +++ oln/core/apply.hh (working copy) @@ -80,7 +80,7 @@ { output_type tmp(input_.size()); oln_type_of(I, fwd_piter) p(input_.size()); - for_all(p) + for_all_p (p) tmp[p] = f_(input_[p]); this->output = tmp; } @@ -154,7 +154,7 @@ { output_type tmp(input1_.size()); oln_type_of(I1, fwd_piter) p(input1_.size()); - for_all(p) + for_all_p (p) tmp[p] = f_(input1_[p], input2_[p]); this->output = tmp; } Index: oln/core/abstract/niter.hh =================================================================== --- oln/core/abstract/niter.hh (revision 146) +++ oln/core/abstract/niter.hh (working copy) @@ -110,12 +110,13 @@ void start_at_p(const point_type& p) { this->center_at(p); - this->start(); + this->start_(); } void center_at(const point_type& p) { this->p_ = p; + this->invalidate(); } protected: @@ -129,10 +130,16 @@ { } + void start_() + { + this->exact().impl_start_(); + } + ~niter() { get_props<category::niter, E>::ensure(); mlc_check_method_impl(E, const point_type, cast_point, , const); + mlc_check_method_impl(E, void, start_, , ); } }; Index: oln/core/abstract/piter.hh =================================================================== --- oln/core/abstract/piter.hh (revision 146) +++ oln/core/abstract/piter.hh (working copy) @@ -112,6 +112,11 @@ return this->p_; } + void start() + { + this->exact().impl_start(); + } + protected: piter(const size_type& s) : @@ -126,6 +131,7 @@ ~piter() { get_props<category::piter, E>::ensure(); + mlc_check_method_impl(E, void, start, , ); } }; Index: oln/core/abstract/qiter.hh =================================================================== --- oln/core/abstract/qiter.hh (revision 146) +++ oln/core/abstract/qiter.hh (working copy) @@ -110,12 +110,13 @@ void start_at_p(const point_type& p) { this->center_at(p); - this->start(); + this->start_(); } void center_at(const point_type& p) { this->p_ = p; + this->invalidate(); } protected: @@ -130,10 +131,16 @@ mlc::eq< grid_type, oln_wn_type_of(window_type, grid) >::ensure(); } + void start_() + { + this->exact().impl_start_(); + } + ~qiter() { get_props<category::qiter, E>::ensure(); mlc_check_method_impl(E, const point_type, cast_point, , const); + mlc_check_method_impl(E, void, start_, , ); } }; Index: oln/core/abstract/iter.hh =================================================================== --- oln/core/abstract/iter.hh (revision 146) +++ oln/core/abstract/iter.hh (working copy) @@ -34,16 +34,6 @@ # include <oln/core/typedefs.hh> - -# define for_all(i) \ - for(i.start(); i.is_valid(); i.next()) - -# define for_all_remaining(i) \ - for(; i.is_valid(); i.next()) - - - - namespace oln { namespace abstract { @@ -52,11 +42,6 @@ struct iter : public mlc::any<E> { - void start() - { - this->exact().impl_start(); - } - void next() { precondition(this->is_valid()); @@ -80,7 +65,6 @@ ~iter() { - mlc_check_method_impl(E, void, start, , ); mlc_check_method_impl(E, void, next, , ); mlc_check_method_impl(E, bool, is_valid, , const); mlc_check_method_impl(E, void, invalidate, , ); Index: oln/core/pw/image.hh =================================================================== --- oln/core/pw/image.hh (revision 146) +++ oln/core/pw/image.hh (working copy) @@ -235,7 +235,7 @@ bool check(const abstract::binary_image<I>& pred) { oln_type_of(I, fwd_piter) p(pred.size()); - for_all (p) + for_all_p (p) if (! pred[p]) return false; return true; Index: oln/core/gen/regular_fwd_niter.hh =================================================================== --- oln/core/gen/regular_fwd_niter.hh (revision 146) +++ oln/core/gen/regular_fwd_niter.hh (working copy) @@ -58,7 +58,7 @@ protected: - void impl_start() + void impl_start_() { this->pos_ = 0; } Index: oln/core/gen/regular_bkd_niter.hh =================================================================== --- oln/core/gen/regular_bkd_niter.hh (revision 146) +++ oln/core/gen/regular_bkd_niter.hh (working copy) @@ -58,7 +58,7 @@ protected: - void impl_start() + void impl_start_() { this->pos_ = this->nbh_.card() - 1; } Index: oln/core/gen/regular_fwd_qiter.hh =================================================================== --- oln/core/gen/regular_fwd_qiter.hh (revision 146) +++ oln/core/gen/regular_fwd_qiter.hh (working copy) @@ -57,7 +57,7 @@ protected: - void impl_start() + void impl_start_() { this->pos_ = 0; } Index: oln/core/gen/regular_bkd_qiter.hh =================================================================== --- oln/core/gen/regular_bkd_qiter.hh (revision 146) +++ oln/core/gen/regular_bkd_qiter.hh (working copy) @@ -58,7 +58,7 @@ protected: - void impl_start() + void impl_start_() { this->pos_ = this->win_.card() - 1; } Index: oln/utils/md5.hxx =================================================================== --- oln/utils/md5.hxx (revision 146) +++ oln/utils/md5.hxx (working copy) @@ -291,7 +291,7 @@ buffer b; oln_type_of(I, fwd_piter) p(im.size()); - for_all(p) + for_all_p (p) b.add(im[p].value()); b.append_padding(); b.append_length(); @@ -309,7 +309,7 @@ buffer b; // unsigned nb = - for_all(p) + for_all_p (p) { for (unsigned i = 0; i < ntg_nb_comp(oln_type_of(I, value)); ++i) b.add(im[p].value()[i]); Index: oln/utils/clone.hh =================================================================== --- oln/utils/clone.hh (revision 146) +++ oln/utils/clone.hh (working copy) @@ -77,7 +77,7 @@ this->output = tmp; oln_type_of(I, fwd_piter) p(this->input.size()); - for_all(p) + for_all_p (p) this->output[p] = this->input[p]; } }; Index: oln/fancy/iota.hh =================================================================== --- oln/fancy/iota.hh (revision 146) +++ oln/fancy/iota.hh (working copy) @@ -43,7 +43,7 @@ { unsigned counter = 0; oln_type_of(I, fwd_piter) p(inout.size()); - for_all(p) + for_all_p (p) inout[p] = ++counter; } Index: oln/morpho/reconstruction.hh =================================================================== --- oln/morpho/reconstruction.hh (revision 146) +++ oln/morpho/reconstruction.hh (working copy) @@ -123,9 +123,9 @@ while (non_stability) { work.unbox() = utils::clone(output); - for_all (fwd_p) + for_all_p (fwd_p) fwd_loop_body(); - for_all (bkd_p) + for_all_p (bkd_p) bkd_loop_body(); non_stability = !(level::is_equal(work, output)); @@ -265,15 +265,16 @@ bool exist_init() { - typedef oln_type_of(N, window) se_type; - oln_type_of(se_type, fwd_qiter) dp(se_minus); - for_all (dp) - { - q = (oln_type_of(se_type, dpoint))dp + - (oln_type_of(I, point))bkd_p; - if (static_cast<E*>((void*)this)->exist_init_impl()) - return true; - } + // FIXME: to many changes => rewrite! +// typedef oln_type_of(N, window) se_type; +// oln_type_of(se_type, fwd_qiter) dp(se_minus); +// for_all (dp) +// { +// q = (oln_type_of(se_type, dpoint))dp + +// (oln_type_of(I, point))bkd_p; +// if (static_cast<E*>((void*)this)->exist_init_impl()) +// return true; +// } return false; } @@ -305,12 +306,10 @@ this->output.unbox() = utils::clone(this->input1); - std::cout << "for_all (fwd_p)" << std::endl; - for_all (fwd_p) + for_all_p (fwd_p) fwd_loop_body(); - std::cout << "for_all (bkd_p)" << std::endl; - for_all (bkd_p) + for_all_p (bkd_p) { bkd_loop_body(); if (exist_init()) @@ -321,16 +320,16 @@ { p = fifo.front(); fifo.pop(); - typedef oln_type_of(N, window) window_type; - window_type w = convert::nbh_to_se(this->nbh); - oln_type_of(window_type, fwd_qiter) dp(w); + // FIXME: AWFUL commented cause too many changes! +// typedef oln_type_of(N, window) window_type; +// window_type w = convert::nbh_to_se(this->nbh); +// oln_wn_type_of(window_type, fwd_iter) q(w); - for_all (dp) - { - q = (oln_type_of(window_type, dpoint))dp + p; - if (this->output.hold(q)) - fifo_loop_body(); - } +// for_all_q_of_p (q) +// { +// if (this->output.hold(q)) +// fifo_loop_body(); +// } } } Index: oln/morpho/dilation.hh =================================================================== --- oln/morpho/dilation.hh (revision 146) +++ oln/morpho/dilation.hh (working copy) @@ -50,7 +50,7 @@ { oln_type_of(I, concrete) output(input.size()); oln_type_of(I, fwd_piter) p(input.size()); - for_all (p) + for_all_p (p) output[p] = morpho::max(input, p, win); return output; } @@ -176,7 +176,7 @@ this->output = tmp; oln_type_of(I, fwd_piter) p(this->input.size()); - for_all (p) + for_all_p (p) this->output[p] = morpho::max(this->input, p, this->win); } }; Index: oln/morpho/splitse.hh =================================================================== --- oln/morpho/splitse.hh (revision 146) +++ oln/morpho/splitse.hh (working copy) @@ -78,20 +78,20 @@ W get_plus_win_only(const abstract::window<W>& win) { - oln_wn_type_of(W, fwd_qiter) dp(win.exact()); + oln_wn_type_of(W, fwd_iter) q(win.exact()); W out; - - for_all (dp) - { - 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; - } - } + // FIXME: too many changes: rewrite! +// for_all (q) +// { +// 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; } @@ -112,23 +112,24 @@ W get_plus_win_p(const abstract::window<W>& win) { - oln_wn_type_of(W, fwd_qiter) dp(win.exact()); + oln_wn_type_of(W, fwd_iter) q(win.exact()); W out; - for_all (dp) - { - 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); - } + // FIXME: too many changes: rewrite! +// for_all (dp) +// { +// 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; } @@ -148,20 +149,21 @@ W get_minus_win_only(const abstract::window<W>& win) { - oln_wn_type_of(W, fwd_qiter) dp(win.exact()); + oln_wn_type_of(W, fwd_iter) q(win.exact()); W out; - for_all (dp) - { - 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; - } - } + // FIXME: too many changes: rewrite! +// for_all (dp) +// { +// 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; } @@ -182,23 +184,24 @@ W get_minus_win_p(const abstract::window<W>& win) { - oln_wn_type_of(W, fwd_qiter) dp(win.exact()); + oln_wn_type_of(W, fwd_iter) q(win.exact()); W out; - for_all (dp) - { - 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); - } + // FIXME: too many changes: rewrite! +// for_all (dp) +// { +// 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; } Index: oln/morpho/geodesic_dilation.hh =================================================================== --- oln/morpho/geodesic_dilation.hh (revision 146) +++ oln/morpho/geodesic_dilation.hh (working copy) @@ -59,7 +59,7 @@ oln_type_of(I1, concrete) output(marker.size()); marker.border_adapt_copy(marker.nbh_get().delta()); oln_type_of(I1, piter) p(marker); - for_all (p) + for_all_p (p) output[p] = arith::min(morpho::max(marker, p, convert::nbh_to_cse(marker.nbh_get())), mask[p]); return output; Index: oln/morpho/stat.hh =================================================================== --- oln/morpho/stat.hh (revision 146) +++ oln/morpho/stat.hh (working copy) @@ -100,7 +100,7 @@ oln_wn_type_of(W, fwd_iter) q(win); q.start_at(p); V val = input[q]; - for_all_remaining (q) + for_all_remaining_q (q) if (input.hold(q)) if (val > input[q].value()) val = input[q].value(); Index: oln/morpho/erosion.hh =================================================================== --- oln/morpho/erosion.hh (revision 146) +++ oln/morpho/erosion.hh (working copy) @@ -49,7 +49,7 @@ { oln_type_of(I, concrete) output(input.size()); oln_type_of(I, fwd_piter) p(input.size()); - for_all (p) + for_all_p (p) output[p] = morpho::min(input, p, win); return output; } @@ -166,7 +166,7 @@ this->output = tmp; oln_type_of(I, fwd_piter) p(this->input.size()); - for_all (p) + for_all_p (p) this->output[p] = morpho::min(this->input, p, this->win); } }; Index: oln/morpho/geodesic_erosion.hh =================================================================== --- oln/morpho/geodesic_erosion.hh (revision 146) +++ oln/morpho/geodesic_erosion.hh (working copy) @@ -59,7 +59,7 @@ oln_type_of(I1, concrete) output(marker.size()); marker.border_adapt_copy(marker.nbh_get().delta()); oln_type_of(I1, piter) p(marker); - for_all (p) + for_all_p (p) output[p] = arith::max(morpho::min(marker, p, convert::nbh_to_cse(marker.nbh_get())), mask[p]); return output; Index: oln/level/fill.hh =================================================================== --- oln/level/fill.hh (revision 146) +++ oln/level/fill.hh (working copy) @@ -34,16 +34,18 @@ namespace level { + // FIXME: AWFUL in place!!! + /*! \brief Fill the image with a value. */ template <class I> I - fill(abstract::image<I>& im, const oln_type_of(I, value)& val) + fill(abstract::image<I>& input, const oln_type_of(I, value)& val) { - oln_type_of(I, fwd_piter) p(im.size()); - for_all(p) - im[p] = val; - return im.exact(); + oln_type_of(I, fwd_piter) p(input.size()); + for_all_p (p) + input[p] = val; + return input.exact(); } } // end of namespace level Index: oln/level/compare.hh =================================================================== --- oln/level/compare.hh (revision 146) +++ oln/level/compare.hh (working copy) @@ -46,7 +46,7 @@ precondition(input1.size() == input2.size()); oln_type_of(I1, fwd_piter) p(input1.size()); - for_all (p) + for_all_p (p) if (!(input1[p] >= input2[p])) return false; return true; @@ -64,7 +64,7 @@ precondition(input1.size() == input2.size()); oln_type_of(I1, fwd_piter) p(input1.size()); - for_all (p) + for_all_p (p) if (!(input1[p] > input2[p])) return false; return true; @@ -82,7 +82,7 @@ precondition(input1.size() == input2.size()); oln_type_of(I1, fwd_piter) p(input1.size()); - for_all (p) + for_all_p (p) if (!(input1[p] <= input2[p])) return false; return true; @@ -100,7 +100,7 @@ precondition(input1.size() == input2.size()); oln_type_of(I1, fwd_piter) p(input1.size()); - for_all (p) + for_all_p (p) if (!(input1[p] < input2[p])) return false; return true; @@ -119,7 +119,7 @@ precondition(input1.size() == input2.size()); oln_type_of(I1, fwd_piter) p(input1.size()); - for_all (p) + for_all_p (p) if (!(input1[p] == input2[p])) return false; return true; Index: oln/arith/min.hh =================================================================== --- oln/arith/min.hh (revision 146) +++ oln/arith/min.hh (working copy) @@ -70,7 +70,7 @@ I output(this->input1.size()); oln_type_of(I, fwd_piter) p(this->input1.size()); - for_all(p) + for_all_p (p) output[p] = ntg::min(this->input1[p].value(), this->input2[p].value()); this->output = output; Index: oln/arith/max.hh =================================================================== --- oln/arith/max.hh (revision 146) +++ oln/arith/max.hh (working copy) @@ -70,7 +70,7 @@ I output(this->input1.size()); oln_type_of(I, fwd_piter) p(this->input1.size()); - for_all(p) + for_all_p (p) output[p] = ntg::max(this->input1[p].value(), this->input2[p].value()); this->output = output;