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
- 9625 discussions
14 Apr '05
2005-04-14 Thierry GERAUD <theo(a)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;
1
0
2005-04-14 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* oln/core/2d/fwd_niter2d.hh: Remove (obsolete; replaced by
niter2d.hh).
* oln/core/1d/niter1d.hh: New file.
* oln/core/1d/bkd_piter1d.hh: New file.
* oln/core/1d/qiter1d.hh: New file.
* oln/core/1d/neighborhood1d.hh: New file.
* oln/core/2d/niter2d.hh: New file.
* oln/core/2d/qiter2d.hh: New file.
* oln/core/3d/niter3d.hh: New file.
* oln/core/3d/bkd_piter3d.hh: New file.
* oln/core/3d/qiter3d.hh: New file.
* oln/core/3d/neighborhood3d.hh: New file.
* oln/core/gen/regular_bkd_niter.hh: New file.
* oln/core/gen/regular_bkd_qiter.hh: New file.
* oln/core/gen/regular_qiter.hh: New file.
* oln/core/gen/regular_neighborhood.hh: New file.
* oln/makefile.src: Update.
* oln/basics1d.hh: Add includes.
* oln/basics2d.hh: Likewise.
* oln/basics3d.hh: Likewise.
* oln/core/typedefs.hh: Add typedef decls.
* oln/core/abstract/niter.hh (start_at_p): New method.
(nbh_): Remove reference in type.
* oln/core/abstract/qiter.hh (for_all_q): Rename as...
(for_all_q_of_p): ...this.
(grid_type): New property.
(qiter): Rewrite.
* oln/core/abstract/point.hh (fwd_less, bkd_less): New methods.
* oln/core/abstract/dpoint.hh (fwd_less, bkd_less): New methods.
(dim): New method.
(operator!=, operator-): New operators.
(fwd_less_dpoint): New function object type.
* oln/core/abstract/neighborhood.hh: Rewrite.
* oln/core/abstract/window.hh (grid_type): New property.
(fwd_qiter_type): Rename as...
(fwd_iter_type): ...this.
(qiter.hh): New include.
* oln/core/1d/dpoint1d.hh: Update.
* oln/core/1d/image1d.hh: Likewise.
* oln/core/1d/window1d.hh: Likewise.
* oln/core/1d/point1d.hh: Likewise.
* oln/core/2d/dpoint2d.hh: Likewise.
* oln/core/2d/image2d.hh: Likewise.
* oln/core/2d/window2d.hh: Likewise.
* oln/core/2d/neighborhood2d.hh: Likewise.
* oln/core/2d/point2d.hh: Likewise.
* oln/core/3d/dpoint3d.hh: Likewise.
* oln/core/3d/image3d.hh: Likewise.
* oln/core/3d/window3d.hh: Likewise.
* oln/core/3d/point3d.hh: Likewise.
* oln/core/any/grid.hh: Likewise.
* oln/core/any/point.hh: Likewise.
* oln/core/any/dpoint.hh: Likewise.
* oln/core/gen/regular_niter.hh: Likewise.
* oln/core/gen/regular_fwd_niter.hh: Likewise.
* oln/core/gen/regular_fwd_qiter.hh: Likewise.
* oln/core/gen/regular_window.hh: Likewise.
* oln/morpho/cc_tarjan.hh: Likewise.
* oln/morpho/stat.hh: Likewise.
* oln/morpho/geodesic_dilation.hh: Likewise.
* oln/morpho/geodesic_erosion.hh: Add file and update.
Index: oln/basics1d.hh
===================================================================
--- oln/basics1d.hh (revision 144)
+++ oln/basics1d.hh (working copy)
@@ -34,5 +34,7 @@
# include <oln/core/1d/size1d.hh>
# include <oln/core/1d/point1d.hh>
# include <oln/core/1d/image1d.hh>
+# include <oln/core/1d/window1d.hh>
+# include <oln/core/1d/neighborhood1d.hh>
#endif // ! OLENA_BASICS1D_HH
Index: oln/basics2d.hh
===================================================================
--- oln/basics2d.hh (revision 144)
+++ oln/basics2d.hh (working copy)
@@ -34,8 +34,6 @@
# include <oln/core/2d/size2d.hh>
# include <oln/core/2d/point2d.hh>
# include <oln/core/2d/image2d.hh>
-# include <oln/core/2d/fwd_piter2d.hh>
-# include <oln/core/2d/bkd_piter2d.hh>
# include <oln/core/2d/window2d.hh>
# include <oln/core/2d/neighborhood2d.hh>
Index: oln/core/typedefs.hh
===================================================================
--- oln/core/typedefs.hh (revision 144)
+++ oln/core/typedefs.hh (working copy)
@@ -28,9 +28,9 @@
#ifndef OLENA_CORE_TYPEDEFS_HH
# define OLENA_CORE_TYPEDEFS_HH
-// FIXME: rename this present file (?)
+# include <iostream>
-
+# include <mlc/contract.hh>
# include <mlc/types.hh>
# include <mlc/cmp.hh>
# include <mlc/typedef.hh>
@@ -45,10 +45,16 @@
mlc_equip_namespace_with_properties();
- // category::image
+ // general
mlc_decl_typedef(grid_type);
+ mlc_decl_typedef(iter_type);
+ mlc_decl_typedef(fwd_iter_type);
+ mlc_decl_typedef(bkd_iter_type);
+
+ // category::image
+
mlc_decl_typedef(data_type);
mlc_decl_typedef(value_type);
mlc_decl_typedef(neighb_type);
@@ -59,7 +65,6 @@
mlc_decl_typedef(image_type);
mlc_decl_typedef(concrete_type);
- mlc_decl_typedef(iter_type);
mlc_decl_typedef(piter_type);
mlc_decl_typedef(fwd_piter_type);
mlc_decl_typedef(bkd_piter_type);
Index: oln/core/abstract/niter.hh
===================================================================
--- oln/core/abstract/niter.hh (revision 144)
+++ oln/core/abstract/niter.hh (working copy)
@@ -107,6 +107,12 @@
return this->exact().impl_cast_point();
}
+ void start_at_p(const point_type& p)
+ {
+ this->center_at(p);
+ this->start();
+ }
+
void center_at(const point_type& p)
{
this->p_ = p;
@@ -114,15 +120,15 @@
protected:
- niter(const neighb_type& ima) :
+ const neighb_type nbh_; // copy is safe
+ point_type p_;
+
+ niter(const neighb_type& nbh) :
nbh_(nbh),
p_()
{
}
- const neighb_type& nbh_;
- point_type p_;
-
~niter()
{
get_props<category::niter, E>::ensure();
Index: oln/core/abstract/qiter.hh
===================================================================
--- oln/core/abstract/qiter.hh (revision 144)
+++ oln/core/abstract/qiter.hh (working copy)
@@ -29,12 +29,13 @@
# define OLENA_CORE_ABSTRACT_QITER_HH
# include <oln/core/abstract/iter.hh>
+# include <oln/core/abstract/grid.hh>
# include <oln/core/abstract/window.hh>
# include <oln/core/typedefs.hh>
-# define for_all_q( q ) \
- for(q.ensure_is_qiter(), q.start(); q.is_valid(); q.next())
+# define for_all_q_of_p(q, p) \
+ for(q.ensure_is_qiter(), q.center_at(p), q.start(); q.is_valid(); q.next())
# define for_all_remaining_q( q ) \
for(q.ensure_is_piter(); q.is_valid(); q.next())
@@ -57,6 +58,7 @@
template <>
struct set_default_props < category::qiter >
{
+ typedef mlc::undefined_type grid_type;
typedef mlc::undefined_type window_type;
};
@@ -65,18 +67,21 @@
template <typename Q>
struct get_props < category::qiter, Q >
{
+ typedef oln_qit_type_of(Q, grid) grid_type;
typedef oln_qit_type_of(Q, window) window_type;
static void echo(std::ostream& ostr)
{
ostr << "props_of( oln::category::qiter, " << mlc_to_string(Q) << " ) =" << std::endl
<< "{" << std::endl
+ << "\t grid_type = " << mlc_to_string(grid_type) << std::endl
<< "\t window_type = " << mlc_to_string(window_type) << std::endl
<< "}" << std::endl;
}
static void ensure()
{
+ mlc::is_ok< grid_type >::ensure();
mlc::is_ok< window_type >::ensure();
}
};
@@ -89,22 +94,46 @@
struct qiter : public iter<E>
{
+ typedef oln_qit_type_of(E, grid) grid_type;
typedef oln_qit_type_of(E, window) window_type;
+ typedef oln_grd_type_of(grid_type, point) point_type;
+
void ensure_is_qiter() {}
+ operator point_type() const
+ {
+ precondition(this->is_valid());
+ return this->exact().impl_cast_point();
+ }
+
+ void start_at_p(const point_type& p)
+ {
+ this->center_at(p);
+ this->start();
+ }
+
+ void center_at(const point_type& p)
+ {
+ this->p_ = p;
+ }
+
protected:
+ const window_type win_; // copy is safe
+ point_type p_;
+
qiter(const window_type& win) :
- win_(win)
+ win_(win),
+ p_()
{
+ mlc::eq< grid_type, oln_wn_type_of(window_type, grid) >::ensure();
}
- const window_type& win_;
-
~qiter()
{
get_props<category::qiter, E>::ensure();
+ mlc_check_method_impl(E, const point_type, cast_point, , const);
}
};
Index: oln/core/abstract/point.hh
===================================================================
--- oln/core/abstract/point.hh (revision 144)
+++ oln/core/abstract/point.hh (working copy)
@@ -130,11 +130,17 @@
return this->exact().impl_eq(rhs.exact());
}
-// // FIXME: compiler error (cannot be overloaded)
-// bool operator==(const any_point& rhs) const
-// {
-// return true;
-// }
+ /// Anteriority w.r.t. to a fwd image browsing.
+ bool fwd_less(const exact_type& rhs) const
+ {
+ return this->exact().impl_fwd_less(rhs.exact());
+ }
+
+ /// Anteriority w.r.t. to a bkd image browsing.
+ bool bkd_less(const exact_type& rhs) const
+ {
+ return not *this == rhs and not this->fwd_less(rhs);
+ }
/*! \brief Test difference of two points. Nota bene: this method
** is concrete (and based on abstract::point::operator==).
@@ -143,7 +149,7 @@
*/
bool operator!=(const exact_type& rhs) const
{
- return ! this->operator==(rhs);
+ return not this->operator==(rhs);
}
// FIXME: doc...
@@ -184,11 +190,12 @@
{
get_props<category::point, E>::ensure();
- mlc_check_method_impl(E, bool, eq, const exact_type&, const);
- mlc_check_method_impl(E, const exact_type, plus, const dpoint_type&, const);
- mlc_check_method_impl(E, const dpoint_type, minus, const exact_type&, const);
- mlc_check_method_impl(E, const coord_type, nth, unsigned, const);
- mlc_check_method_impl(E, coord_type&, nth, unsigned, );
+ mlc_check_method_impl(E, bool, eq, const exact_type&, const);
+ mlc_check_method_impl(E, bool, fwd_less, const exact_type&, const);
+ mlc_check_method_impl(E, const exact_type, plus, const dpoint_type&, const);
+ mlc_check_method_impl(E, const dpoint_type, minus, const exact_type&, const);
+ mlc_check_method_impl(E, const coord_type, nth, unsigned, const);
+ mlc_check_method_impl(E, coord_type&, nth, unsigned, );
}
};
Index: oln/core/abstract/dpoint.hh
===================================================================
--- oln/core/abstract/dpoint.hh (revision 144)
+++ oln/core/abstract/dpoint.hh (working copy)
@@ -29,6 +29,7 @@
# define OLENA_CORE_ABSTRACT_DPOINT_HH
# include <mlc/any.hh>
+# include <mlc/contract.hh>
# include <oln/core/coord.hh>
# include <oln/core/typedefs.hh>
@@ -62,39 +63,79 @@
return this->exact().impl_eq(rhs.exact());
}
- /// Test difference between two dpoints.
- bool operator!=(const exact_type& rhs) const
+ /// Anteriority w.r.t. to a fwd image browsing.
+ bool fwd_less(const exact_type& rhs) const
{
- return ! this->operator==(rhs);
+ return this->exact().impl_fwd_less(rhs.exact());
}
-
+
+ /// Anteriority w.r.t. to a bkd image browsing.
+ bool bkd_less(const exact_type& rhs) const
+ {
+ return ! *this == rhs && ! this->fwd_less(rhs);
+ }
+
const coord_t nth(unsigned i) const
{
- // FIXME: add precondition
+ precondition(i < this->dim());
return this->exact().impl_nth(i);
}
coord_t& nth(unsigned i)
{
- // FIXME: add precondition
+ precondition(i < this->dim());
return this->exact().impl_nth(i);
}
+ unsigned dim() const
+ {
+ return this->exact().impl_dim();
+ }
+
+
+ /// Test difference between two dpoints.
+ bool operator!=(const exact_type& rhs) const
+ {
+ return ! this->operator==(rhs);
+ }
+
+ /// Unarity minus.
+ const exact_type operator-() const
+ {
+ exact_type tmp;
+ for (unsigned c = 0; c < this->dim(); ++c)
+ tmp.nth(c) = - this->nth(c);
+ return tmp;
+ }
+
protected:
dpoint() {}
~dpoint()
{
- mlc_check_method_impl(E, bool, eq, const exact_type&, const);
- mlc_check_method_impl(E, const coord_t, nth, unsigned, const);
- mlc_check_method_impl(E, coord_t&, nth, unsigned, );
+ mlc_check_method_impl(E, bool, eq, const exact_type&, const);
+ mlc_check_method_impl(E, bool, fwd_less, const exact_type&, const);
+ mlc_check_method_impl(E, const coord_t, nth, unsigned, const);
+ mlc_check_method_impl(E, coord_t&, nth, unsigned, );
+ mlc_check_method_impl(E, unsigned, dim, , const);
}
};
} // end of namespace abstract
+
+ struct fwd_less_dpoint
+ {
+ template <typename D>
+ bool operator()(const abstract::dpoint<D>& lhs, const abstract::dpoint<D>& rhs) const
+ {
+ return lhs.fwd_less(rhs.exact());
+ }
+ };
+
+
} // end of namespace oln
Index: oln/core/abstract/neighborhood.hh
===================================================================
--- oln/core/abstract/neighborhood.hh (revision 144)
+++ oln/core/abstract/neighborhood.hh (working copy)
@@ -28,14 +28,7 @@
#ifndef OLENA_CORE_NEIGHBORHOOD_HH
# define OLENA_CORE_NEIGHBORHOOD_HH
-# include <vector>
-# include <utility>
-# include <iostream>
-
# include <oln/core/typedefs.hh>
-# include <oln/core/coord.hh>
-# include <oln/core/abstract/dpoint.hh>
-# include <oln/core/accum.hh>
# define oln_nbh_type_of(NeighborhoodType, Alias) \
@@ -60,7 +53,7 @@
};
- /// Retrieval of any image type properties (FIXME: say 'packing').
+ /// Retrieval of any neighborhood type properties.
template <typename N>
struct get_props < category::neighborhood, N >
@@ -72,10 +65,11 @@
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
- << std::endl;
+ << "}" << std::endl;
}
static void ensure()
@@ -92,148 +86,31 @@
namespace abstract {
/*!
- ** Structuring elements (set of dpoints).
+ ** Class for neighborhoods.
**
- ** This abstract class defines several virtual methods for its
- ** subclasses. Its goal is to deal with a set of 'move' points.
*/
- template<class E>
- class neighborhood : public mlc::any__best_memory<E>
+ template <typename E>
+ struct neighborhood : public mlc::any<E>
{
- // FIXME: rewrite this class
-
- public:
-
- typedef oln_nbh_type_of(E, dpoint) dpoint_type;
-
- typedef E exact_type;
-
- bool
- has(const dpoint_type& dp) const
- {
- return this->exact().impl_has(dp.exact());
- }
-
- unsigned
- card() const
- {
- return this->exact().impl_card();
- }
-
- exact_type&
- add(const dpoint_type& dp)
- {
- return this->exact().impl_add(dp);
- }
-
- dpoint_type
- dp(unsigned i) const
- {
- return this->exact().impl_at(i);
- }
-
- const dpoint_type
- operator[](unsigned i) const
- {
- return this->exact().impl_at(i);
- }
-
- coord_t
- get_delta() const
- {
- return this->exact().impl_get_delta();
- }
-
- coord_t
- delta_update(const dpoint_type& dp)
- {
- return this->exact().impl_delta_update(dp);
- }
-
protected:
+
+ neighborhood()
+ {}
- bool
- impl_has(const dpoint_type& dp) const
- {
- return std::find(dp_.begin(), dp_.end(), dp) != dp_.end();
- }
-
- exact_type&
- impl_add(const dpoint_type& dp)
- {
- if (!(impl_has(dp)))
- {
- this->dp_.push_back(dp);
- this->dp_.push_back(-dp);
- }
- this->delta_update(dp);
- return this->exact();
- }
-
- coord_t
- impl_get_delta() const
- {
- return delta_;
- }
-
- unsigned
- impl_card() const
- {
- return dp_.size();
- }
-
- const dpoint_type
- impl_at(unsigned i) const
- {
- precondition(i < this->card());
- return dp_[i];
- }
-
- neighborhood() : dp_(), delta_(0)
- {};
-
- neighborhood(unsigned size) : dp_(), delta_(0)
- {
- dp_.reserve(size);
- };
-
- /// Attributes
-
- std::vector<dpoint_type> dp_;
- max_accumulator<coord_t> delta_;
-
- /// Destructor.
-
~neighborhood()
{
get_props<category::neighborhood, E>::ensure();
-// bool has(const dpoint_type& dp) const
-// unsigned card() const
-// exact_type& add(const dpoint_type& dp)
-// dpoint_type dp(unsigned i) const
-// const dpoint_type operator[](unsigned i) const
-// coord_t get_delta() const
-// coord_t delta_update(const dpoint_type& dp)
}
};
- } // end of abstract
+ } // end of namespace abstract::oln
-} // end of oln
+} // end of namespace oln
-template<class E>
-std::ostream&
-operator<<(std::ostream& o, const oln::abstract::neighborhood<E>& se)
-{
- unsigned c = se.card();
- o << "[";
- for (unsigned i = 0; i < c; ++i)
- o << se.dp(i);
- o << "]";
- return o;
-}
+# include <oln/core/abstract/niter.hh>
+
#endif // ! OLENA_CORE_NEIGHBORHOOD_HH
Index: oln/core/abstract/window.hh
===================================================================
--- oln/core/abstract/window.hh (revision 144)
+++ oln/core/abstract/window.hh (working copy)
@@ -28,15 +28,7 @@
#ifndef OLENA_CORE_ABSTRACT_WINDOW_HH
# define OLENA_CORE_ABSTRACT_WINDOW_HH
-# include <vector>
-# include <utility>
-# include <iostream>
-
-# include <mlc/types.hh>
# include <oln/core/typedefs.hh>
-# include <oln/core/coord.hh>
-# include <oln/core/abstract/dpoint.hh>
-# include <oln/core/accum.hh>
# define oln_wn_type_of(WindowType, Alias) \
@@ -54,34 +46,38 @@
template <>
struct set_default_props < category::window >
{
+ typedef mlc::undefined_type grid_type;
typedef mlc::undefined_type dpoint_type;
typedef mlc::undefined_type size_type;
- typedef mlc::undefined_type fwd_qiter_type;
+ typedef mlc::undefined_type fwd_iter_type;
};
template <typename W>
struct get_props < category::window, W >
{
- typedef oln_wn_type_of(W, dpoint) dpoint_type;
- typedef oln_wn_type_of(W, size) size_type;
- typedef oln_wn_type_of(W, fwd_qiter) fwd_qiter_type;
+ typedef oln_wn_type_of(W, grid) grid_type;
+ typedef oln_wn_type_of(W, dpoint) dpoint_type;
+ typedef oln_wn_type_of(W, size) size_type;
+ typedef oln_wn_type_of(W, fwd_iter) fwd_iter_type;
static void echo(std::ostream& ostr)
{
ostr << "props_of( oln::category::window, " << mlc_to_string(W) << " ) =" << 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 fwd_qiter_type = " << mlc_to_string(fwd_qiter_type) << std::endl
+ << "\t grid_type = " << mlc_to_string(grid_type) << std::endl
+ << "\t dpoint_type = " << mlc_to_string(dpoint_type) << std::endl
+ << "\t size_type = " << mlc_to_string(size_type) << std::endl
+ << "\t fwd_iter_type = " << mlc_to_string(fwd_iter_type) << std::endl
<< "}" << std::endl;
}
static void ensure()
{
- mlc::is_ok< dpoint_type >::ensure();
- mlc::is_ok< size_type >::ensure();
- mlc::is_ok< fwd_qiter_type >::ensure();
+ mlc::is_ok< grid_type >::ensure();
+ mlc::is_ok< dpoint_type >::ensure();
+ mlc::is_ok< size_type >::ensure();
+ mlc::is_ok< fwd_iter_type >::ensure();
}
};
@@ -117,5 +113,7 @@
} // end of namespace oln
+# include <oln/core/abstract/qiter.hh>
+
#endif // ! OLENA_CORE_ABSTRACT_WINDOW_HH
Index: oln/core/1d/dpoint1d.hh
===================================================================
--- oln/core/1d/dpoint1d.hh (revision 144)
+++ oln/core/1d/dpoint1d.hh (working copy)
@@ -95,6 +95,11 @@
return this->index_ == rhs.index_;
}
+ bool impl_fwd_less(const dpoint1d& rhs) const
+ {
+ return this->index_ < rhs.index_;
+ }
+
const coord_t impl_nth(unsigned i) const
{
precondition(i == 0);
@@ -107,6 +112,11 @@
return index_;
}
+ unsigned impl_dim() const
+ {
+ return 1;
+ }
+
coord_t index_;
};
Index: oln/core/1d/niter1d.hh
===================================================================
--- oln/core/1d/niter1d.hh (revision 0)
+++ oln/core/1d/niter1d.hh (revision 0)
@@ -0,0 +1,48 @@
+// 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_1D_NITER1D_HH
+# define OLENA_CORE_1D_NITER1D_HH
+
+# include <oln/core/1d/grid1d.hh>
+# include <oln/core/1d/point1d.hh>
+# include <oln/core/1d/dpoint1d.hh>
+# include <oln/core/1d/neighborhood1d.hh>
+
+# include <oln/core/gen/regular_fwd_niter.hh>
+# include <oln/core/gen/regular_bkd_niter.hh>
+
+
+namespace oln {
+
+ typedef regular_fwd_niter<grid1d> fwd_niter1d;
+ typedef regular_bkd_niter<grid1d> bkd_niter1d;
+
+}
+
+
+#endif // ! OLENA_CORE_1D_NITER1D_HH
Index: oln/core/1d/image1d.hh
===================================================================
--- oln/core/1d/image1d.hh (revision 144)
+++ oln/core/1d/image1d.hh (working copy)
@@ -131,4 +131,8 @@
} // end of namespace oln
+# include <oln/core/1d/fwd_piter1d.hh>
+# include <oln/core/1d/bkd_piter1d.hh>
+
+
#endif // ! OLENA_CORE_1D_IMAGE1D_HH
Index: oln/core/1d/bkd_piter1d.hh
===================================================================
--- oln/core/1d/bkd_piter1d.hh (revision 0)
+++ oln/core/1d/bkd_piter1d.hh (revision 0)
@@ -0,0 +1,103 @@
+// 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_CORE_1D_BKD_PITER1D_HH
+# define OLENA_CORE_1D_BKD_PITER1D_HH
+
+# include <mlc/contract.hh>
+# include <oln/core/abstract/piter.hh>
+# include <oln/core/1d/point1d.hh>
+# include <oln/core/1d/size1d.hh>
+
+
+namespace oln {
+
+
+ // fwd decl
+ struct bkd_piter1d;
+
+ // super type
+ template <>
+ struct set_super_type < bkd_piter1d > { typedef abstract::piter< bkd_piter1d > ret; };
+
+ // props
+ template <>
+ struct set_props < category::piter, bkd_piter1d >
+ {
+ typedef point1d point_type;
+ typedef size1d size_type;
+ };
+
+
+
+ struct bkd_piter1d : public abstract::piter< bkd_piter1d >
+ {
+ typedef bkd_piter1d self_type;
+ typedef abstract::piter<self_type> super_type;
+
+ bkd_piter1d(const size1d& size) :
+ super_type(size)
+ {
+ this->invalidate();
+ }
+
+ friend class abstract::iter<self_type>;
+ friend class abstract::piter<self_type>;
+
+ protected:
+
+ void impl_start()
+ {
+ this->p_.index() = this->s_.nindices() - 1;
+ postcondition(this->p_.index().is_defined());
+ }
+
+ bool impl_is_valid() const
+ {
+ precondition(this->p_.index().is_defined());
+ return this->p_.index() >= 0;
+ }
+
+ void impl_next()
+ {
+ precondition(this->p_.index().is_defined());
+ precondition(this->p_.index() >= 0 && this->p_.index() < this->s_.nindices());
+ --this->p_.index();
+ postcondition(this->p_.index().is_defined());
+ }
+
+ void impl_invalidate()
+ {
+ this->p_.index() = -1;
+ postcondition(this->p_.index().is_defined());
+ }
+
+ };
+}
+
+
+#endif // ! OLENA_CORE_1D_BKD_PITER1D_HH
Index: oln/core/1d/qiter1d.hh
===================================================================
--- oln/core/1d/qiter1d.hh (revision 0)
+++ oln/core/1d/qiter1d.hh (revision 0)
@@ -0,0 +1,48 @@
+// 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_1D_QITER1D_HH
+# define OLENA_CORE_1D_QITER1D_HH
+
+# include <oln/core/1d/grid1d.hh>
+# include <oln/core/1d/point1d.hh>
+# include <oln/core/1d/dpoint1d.hh>
+# include <oln/core/1d/window1d.hh>
+
+# include <oln/core/gen/regular_fwd_qiter.hh>
+# include <oln/core/gen/regular_bkd_qiter.hh>
+
+
+namespace oln {
+
+ typedef regular_fwd_qiter<grid1d> fwd_qiter1d;
+ typedef regular_bkd_qiter<grid1d> bkd_qiter1d;
+
+}
+
+
+#endif // ! OLENA_CORE_1D_QITER1D_HH
Index: oln/core/1d/window1d.hh
===================================================================
--- oln/core/1d/window1d.hh (revision 144)
+++ oln/core/1d/window1d.hh (working copy)
@@ -28,9 +28,10 @@
#ifndef OLENA_CORE_WINDOW1D_HH
# define OLENA_CORE_WINDOW1D_HH
-# include <oln/core/gen/regular_window.hh>
# include <oln/core/1d/grid1d.hh>
# include <oln/core/1d/dpoint1d.hh>
+# include <oln/core/gen/regular_window.hh>
+# include <oln/core/1d/qiter1d.hh>
namespace oln {
Index: oln/core/1d/neighborhood1d.hh
===================================================================
--- oln/core/1d/neighborhood1d.hh (revision 0)
+++ oln/core/1d/neighborhood1d.hh (revision 0)
@@ -0,0 +1,50 @@
+// 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_NEIGHBORHOOD1D_HH
+# define OLENA_CORE_NEIGHBORHOOD1D_HH
+
+# include <oln/core/1d/window1d.hh>
+# include <oln/core/gen/regular_neighborhood.hh>
+# include <oln/core/1d/niter1d.hh>
+
+
+namespace oln {
+
+ typedef regular_neighborhood< grid1d > neighborhood1d;
+
+ inline const neighborhood1d&
+ neighb_c2()
+ {
+ static const neighborhood1d neighb(win_c2_only());
+ return neighb;
+ }
+
+} // end of namespace oln
+
+
+#endif // OLENA_CORE_NEIGHBORHOOD2D_HH
Index: oln/core/1d/point1d.hh
===================================================================
--- oln/core/1d/point1d.hh (revision 144)
+++ oln/core/1d/point1d.hh (working copy)
@@ -96,6 +96,11 @@
return this->index_ == rhs.index_;
}
+ bool impl_fwd_less(const point1d& rhs) const
+ {
+ return this->index_ < rhs.index_;
+ }
+
const coord_t impl_nth(unsigned i) const
{
precondition(i == 0);
Index: oln/core/2d/dpoint2d.hh
===================================================================
--- oln/core/2d/dpoint2d.hh (revision 144)
+++ oln/core/2d/dpoint2d.hh (working copy)
@@ -105,6 +105,13 @@
return this->row_ == rhs.row_ && this->col_ == rhs.col_;
}
+ bool impl_fwd_less(const dpoint2d& rhs) const
+ {
+ return
+ this->row_ < rhs.row_
+ || (this->row_ == rhs.row_ && this->col_ < rhs.col_);
+ }
+
const coord_t impl_nth(unsigned i) const
{
precondition(i < 2);
@@ -123,6 +130,11 @@
return col_;
}
+ unsigned impl_dim() const
+ {
+ return 2;
+ }
+
coord_t row_, col_;
};
Index: oln/core/2d/fwd_niter2d.hh
===================================================================
--- oln/core/2d/fwd_niter2d.hh (revision 145)
+++ oln/core/2d/fwd_niter2d.hh (working copy)
@@ -1,46 +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_2D_FWD_NITER2D_HH
-# define OLENA_CORE_2D_FWD_NITER2D_HH
-
-# include <oln/core/2d/grid2d.hh>
-# include <oln/core/2d/point2d.hh>
-# include <oln/core/2d/dpoint2d.hh>
-# include <oln/core/2d/neighborhood2d.hh>
-
-# include <oln/core/gen/regular_fwd_niter.hh>
-
-
-namespace oln {
-
- typedef regular_fwd_niter<grid2d> fwd_niter2d;
-
-}
-
-
-#endif // ! OLENA_CORE_2D_FWD_NITER2D_HH
Index: oln/core/2d/niter2d.hh
===================================================================
--- oln/core/2d/niter2d.hh (revision 0)
+++ oln/core/2d/niter2d.hh (revision 0)
@@ -0,0 +1,48 @@
+// 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_2D_NITER2D_HH
+# define OLENA_CORE_2D_NITER2D_HH
+
+# include <oln/core/2d/grid2d.hh>
+# include <oln/core/2d/point2d.hh>
+# include <oln/core/2d/dpoint2d.hh>
+# include <oln/core/2d/neighborhood2d.hh>
+
+# include <oln/core/gen/regular_fwd_niter.hh>
+# include <oln/core/gen/regular_bkd_niter.hh>
+
+
+namespace oln {
+
+ typedef regular_fwd_niter<grid2d> fwd_niter2d;
+ typedef regular_bkd_niter<grid2d> bkd_niter2d;
+
+}
+
+
+#endif // ! OLENA_CORE_2D_NITER2D_HH
Index: oln/core/2d/image2d.hh
===================================================================
--- oln/core/2d/image2d.hh (revision 144)
+++ oln/core/2d/image2d.hh (working copy)
@@ -31,6 +31,7 @@
# include <oln/core/abstract/image_with_data.hh>
# include <oln/core/abstract/image_like_.hh>
# include <oln/core/2d/array2d.hh>
+# include <oln/core/2d/niter2d.hh>
/*! \namespace oln
@@ -51,7 +52,6 @@
// fwd decls
struct fwd_piter2d;
struct bkd_piter2d;
- struct fwd_niter2d;
template <typename T> class image2d;
// super
@@ -166,4 +166,8 @@
} // end of namespace oln
+# include <oln/core/2d/fwd_piter2d.hh>
+# include <oln/core/2d/bkd_piter2d.hh>
+
+
#endif // ! OLENA_CORE_IMAGE2D_HH
Index: oln/core/2d/qiter2d.hh
===================================================================
--- oln/core/2d/qiter2d.hh (revision 0)
+++ oln/core/2d/qiter2d.hh (revision 0)
@@ -0,0 +1,48 @@
+// 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_2D_QITER2D_HH
+# define OLENA_CORE_2D_QITER2D_HH
+
+# include <oln/core/2d/grid2d.hh>
+# include <oln/core/2d/point2d.hh>
+# include <oln/core/2d/dpoint2d.hh>
+# include <oln/core/2d/window2d.hh>
+
+# include <oln/core/gen/regular_fwd_qiter.hh>
+# include <oln/core/gen/regular_bkd_qiter.hh>
+
+
+namespace oln {
+
+ typedef regular_fwd_qiter<grid2d> fwd_qiter2d;
+ typedef regular_bkd_qiter<grid2d> bkd_qiter2d;
+
+}
+
+
+#endif // ! OLENA_CORE_2D_QITER2D_HH
Index: oln/core/2d/window2d.hh
===================================================================
--- oln/core/2d/window2d.hh (revision 144)
+++ oln/core/2d/window2d.hh (working copy)
@@ -28,9 +28,10 @@
#ifndef OLENA_CORE_WINDOW2D_HH
# define OLENA_CORE_WINDOW2D_HH
-# include <oln/core/gen/regular_window.hh>
# include <oln/core/2d/dpoint2d.hh>
# include <oln/core/2d/grid2d.hh>
+# include <oln/core/gen/regular_window.hh>
+# include <oln/core/2d/qiter2d.hh>
namespace oln
Index: oln/core/2d/neighborhood2d.hh
===================================================================
--- oln/core/2d/neighborhood2d.hh (revision 144)
+++ oln/core/2d/neighborhood2d.hh (working copy)
@@ -28,106 +28,31 @@
#ifndef OLENA_CORE_NEIGHBORHOOD2D_HH
# define OLENA_CORE_NEIGHBORHOOD2D_HH
-# include <oln/core/coord.hh>
-# include <oln/core/abstract/neighborhood.hh>
-# include <oln/core/2d/dpoint2d.hh>
-# include <oln/core/2d/size2d.hh>
# include <oln/core/2d/window2d.hh>
+# include <oln/core/gen/regular_neighborhood.hh>
+# include <oln/core/2d/niter2d.hh>
namespace oln {
- class neighborhood2d; // forward declaration
+ typedef regular_neighborhood< grid2d > neighborhood2d;
- // super_type
- template <>
- struct set_super_type< neighborhood2d > { typedef abstract::neighborhood< neighborhood2d > ret; };
-
- template <>
- struct set_props< category::neighborhood, neighborhood2d >
- {
- typedef dpoint2d dpoint_type;
- typedef size2d size_type;
- typedef window2d window_type;
- };
-
-
- class neighborhood2d : public abstract::neighborhood< neighborhood2d >
- {
-
- public:
-
- typedef abstract::neighborhood< neighborhood2d > super_type;
-
- /*!
- ** \brief Construct a neighborhood of 2 dimensions.
- */
- neighborhood2d() :
- super_type()
- {
- }
-
- /*!
- ** \brief Construct a neighborhood of 2 dimensions.
- ** \arg size The number of element.
- */
- neighborhood2d(unsigned size) :
- super_type(size)
- {
- }
-
- /*!
- ** \brief Construct a neighborhood of 2 dimensions from several points.
- ** \arg n The number of element.
- ** \arg crd The coordinates of the elements
- */
- neighborhood2d(unsigned n, const coord_t crd[]) :
- super_type(n)
- {
- for (unsigned i = 0; i < 2 * n; i += 2)
- this->add(dpoint2d(crd[i], crd[i+1]));
- }
-
- neighborhood2d&
- add(const dpoint2d& dp)
- {
- return this->exact().impl_add(dp);
- }
-
- neighborhood2d&
- add(coord_t row, coord_t col)
- {
- dpoint2d dp(row, col);
- return add(dp);
- }
-
- coord_t
- impl_delta_update(const dpoint2d& dp)
- {
- delta_(abs(dp.row()));
- delta_(abs(dp.col()));
- return delta_;
- }
-
- };
-
-
inline const neighborhood2d&
neighb_c4()
{
- static const coord_t crd[] = { 0,1, 1,0 };
- static const neighborhood2d neighb(2, crd);
+ static const neighborhood2d neighb(win_c4_only());
return neighb;
}
inline const neighborhood2d&
neighb_c8()
{
- static const coord_t crd[] = { 0,1, 1,1, 1,0, 1,-1 };
- static const neighborhood2d neighb(4, crd);
+ static const neighborhood2d neighb(win_c8_only());
return neighb;
}
-} // end of oln
+} // end of namespace oln
+
+
#endif // OLENA_CORE_NEIGHBORHOOD2D_HH
Index: oln/core/2d/point2d.hh
===================================================================
--- oln/core/2d/point2d.hh (revision 144)
+++ oln/core/2d/point2d.hh (working copy)
@@ -108,6 +108,13 @@
return this->row_ == rhs.row_ && this->col_ == rhs.col_;
}
+ bool impl_fwd_less(const point2d& rhs) const
+ {
+ return
+ this->row_ < rhs.row_
+ || (this->row_ == rhs.row_ && this->col_ < rhs.col_);
+ }
+
const coord_t impl_nth(unsigned i) const
{
precondition(i < 2);
Index: oln/core/3d/dpoint3d.hh
===================================================================
--- oln/core/3d/dpoint3d.hh (revision 144)
+++ oln/core/3d/dpoint3d.hh (working copy)
@@ -99,6 +99,15 @@
return this->row_ == rhs.row_ && this->col_ == rhs.col_ && this->slice_ == rhs.slice_;
}
+ bool impl_fwd_less(const dpoint3d& rhs) const
+ {
+ return
+ this->slice_ < rhs.slice_
+ || (this->slice_ == rhs.slice_
+ && (this->row_ < rhs.row_
+ || (this->row_ == rhs.row_ && this->col_ < rhs.col_)));
+ }
+
const coord_t impl_nth(unsigned i) const
{
precondition(i < 3);
@@ -132,6 +141,11 @@
return dummy;
}
+ unsigned impl_dim() const
+ {
+ return 3;
+ }
+
coord_t slice_, row_, col_;
};
Index: oln/core/3d/niter3d.hh
===================================================================
--- oln/core/3d/niter3d.hh (revision 0)
+++ oln/core/3d/niter3d.hh (revision 0)
@@ -0,0 +1,48 @@
+// 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_3D_NITER3D_HH
+# define OLENA_CORE_3D_NITER3D_HH
+
+# include <oln/core/3d/grid3d.hh>
+# include <oln/core/3d/point3d.hh>
+# include <oln/core/3d/dpoint3d.hh>
+# include <oln/core/3d/neighborhood3d.hh>
+
+# include <oln/core/gen/regular_fwd_niter.hh>
+# include <oln/core/gen/regular_bkd_niter.hh>
+
+
+namespace oln {
+
+ typedef regular_fwd_niter<grid3d> fwd_niter3d;
+ typedef regular_bkd_niter<grid3d> bkd_niter3d;
+
+}
+
+
+#endif // ! OLENA_CORE_3D_NITER3D_HH
Index: oln/core/3d/image3d.hh
===================================================================
--- oln/core/3d/image3d.hh (revision 144)
+++ oln/core/3d/image3d.hh (working copy)
@@ -131,4 +131,8 @@
} // end of namespace oln
+# include <oln/core/3d/fwd_piter3d.hh>
+# include <oln/core/3d/bkd_piter3d.hh>
+
+
#endif // ! OLENA_CORE_3D_IMAGE3D_HH
Index: oln/core/3d/bkd_piter3d.hh
===================================================================
--- oln/core/3d/bkd_piter3d.hh (revision 0)
+++ oln/core/3d/bkd_piter3d.hh (revision 0)
@@ -0,0 +1,123 @@
+// 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_CORE_3D_BKD_PITER3D_HH
+# define OLENA_CORE_3D_BKD_PITER3D_HH
+
+# include <mlc/contract.hh>
+
+# include <oln/core/abstract/piter.hh>
+# include <oln/core/3d/point3d.hh>
+# include <oln/core/3d/size3d.hh>
+
+
+namespace oln {
+
+ // fwd decl
+ struct bkd_piter3d;
+
+ // props
+ template <>
+ struct set_props < category::piter, bkd_piter3d >
+ {
+ typedef point3d point_type;
+ typedef size3d size_type;
+ };
+
+
+
+ struct bkd_piter3d : public abstract::piter< bkd_piter3d >
+ {
+ typedef bkd_piter3d self_type;
+ typedef abstract::piter<self_type> super_type;
+
+ bkd_piter3d(const size3d& size) :
+ super_type(size)
+ {
+ this->invalidate();
+ }
+
+ friend class abstract::iter<self_type>;
+ friend class abstract::piter<self_type>;
+
+ protected:
+
+ void impl_start()
+ {
+ this->p_.row() = this->s_.nrows() - 1;
+ this->p_.col() = this->s_.ncols() - 1;
+ this->p_.slice() = this->s_.nslices() - 1;
+ postcondition(this->p_.row().is_defined() &&
+ this->p_.col().is_defined() &&
+ this->p_.slice().is_defined());
+ }
+
+ bool impl_is_valid() const
+ {
+ precondition(this->p_.row().is_defined() &&
+ this->p_.col().is_defined() &&
+ this->p_.slice().is_defined());
+ return this->p_.slice() >= 0;
+ }
+
+ void impl_next()
+ {
+ precondition(this->p_.row().is_defined() &&
+ this->p_.col().is_defined() &&
+ this->p_.slice().is_defined());
+ precondition(this->p_.row() >= 0 && this->p_.row() < this->s_.nrows() &&
+ this->p_.col() >= 0 && this->p_.col() < this->s_.ncols() &&
+ this->p_.slice() >= 0 && this->p_.slice() < this->s_.nslices());
+ --this->p_.col();
+ if (this->p_.col() >= 0)
+ return;
+ this->p_.col() = this->s_.ncols() - 1;
+; --this->p_.row();
+ if (this->p_.row() >= 0)
+ return;
+ this->p_.row() = this->s_.nrows() - 1;
+ --this->p_.slice();
+ postcondition(this->p_.row().is_defined() &&
+ this->p_.col().is_defined() &&
+ this->p_.slice().is_defined());
+ }
+
+ void impl_invalidate()
+ {
+ this->p_.row() = -1;
+ this->p_.col() = -1;
+ this->p_.slice() = -1;
+ postcondition(this->p_.row().is_defined() &&
+ this->p_.col().is_defined() &&
+ this->p_.slice().is_defined());
+ }
+
+ };
+}
+
+
+#endif // ! OLENA_CORE_3D_BKD_PITER3D_HH
Index: oln/core/3d/qiter3d.hh
===================================================================
--- oln/core/3d/qiter3d.hh (revision 0)
+++ oln/core/3d/qiter3d.hh (revision 0)
@@ -0,0 +1,48 @@
+// 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_3D_QITER3D_HH
+# define OLENA_CORE_3D_QITER3D_HH
+
+# include <oln/core/3d/grid3d.hh>
+# include <oln/core/3d/point3d.hh>
+# include <oln/core/3d/dpoint3d.hh>
+# include <oln/core/3d/window3d.hh>
+
+# include <oln/core/gen/regular_fwd_qiter.hh>
+# include <oln/core/gen/regular_bkd_qiter.hh>
+
+
+namespace oln {
+
+ typedef regular_fwd_qiter<grid3d> fwd_qiter3d;
+ typedef regular_bkd_qiter<grid3d> bkd_qiter3d;
+
+}
+
+
+#endif // ! OLENA_CORE_3D_QITER3D_HH
Index: oln/core/3d/window3d.hh
===================================================================
--- oln/core/3d/window3d.hh (revision 144)
+++ oln/core/3d/window3d.hh (working copy)
@@ -28,9 +28,10 @@
#ifndef OLENA_CORE_WINDOW3D_HH
# define OLENA_CORE_WINDOW3D_HH
-# include <oln/core/gen/regular_window.hh>
# include <oln/core/3d/dpoint3d.hh>
# include <oln/core/3d/grid3d.hh>
+# include <oln/core/gen/regular_window.hh>
+# include <oln/core/3d/qiter3d.hh>
namespace oln {
Index: oln/core/3d/neighborhood3d.hh
===================================================================
--- oln/core/3d/neighborhood3d.hh (revision 0)
+++ oln/core/3d/neighborhood3d.hh (revision 0)
@@ -0,0 +1,65 @@
+// 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_NEIGHBORHOOD3D_HH
+# define OLENA_CORE_NEIGHBORHOOD3D_HH
+
+# include <oln/core/3d/window3d.hh>
+# include <oln/core/gen/regular_neighborhood.hh>
+# include <oln/core/3d/niter3d.hh>
+
+
+namespace oln {
+
+ typedef regular_neighborhood< grid3d > neighborhood3d;
+
+ inline const neighborhood3d&
+ neighb_c6()
+ {
+ static const neighborhood3d neighb(win_c6_only());
+ return neighb;
+ }
+
+ inline const neighborhood3d&
+ neighb_c18()
+ {
+ static const neighborhood3d neighb(win_c18_only());
+ return neighb;
+ }
+
+ inline const neighborhood3d&
+ neighb_c26()
+ {
+ static const neighborhood3d neighb(win_c26_only());
+ return neighb;
+ }
+
+
+} // end of namespace oln
+
+
+#endif // OLENA_CORE_NEIGHBORHOOD3D_HH
Index: oln/core/3d/point3d.hh
===================================================================
--- oln/core/3d/point3d.hh (revision 144)
+++ oln/core/3d/point3d.hh (working copy)
@@ -104,6 +104,15 @@
this->col_ == rhs.col_;
}
+ bool impl_fwd_less(const point3d& rhs) const
+ {
+ return
+ this->slice_ < rhs.slice_
+ || (this->slice_ == rhs.slice_
+ && (this->row_ < rhs.row_
+ || (this->row_ == rhs.row_ && this->col_ < rhs.col_)));
+ }
+
const point3d impl_plus(const dpoint3d& rhs) const;
const dpoint3d impl_minus(const point3d& rhs) const;
Index: oln/core/any/grid.hh
===================================================================
--- oln/core/any/grid.hh (revision 144)
+++ oln/core/any/grid.hh (working copy)
@@ -38,6 +38,7 @@
struct any_grid;
struct any_point;
struct any_dpoint;
+ struct any_size;
struct any_coord;
// super type
@@ -54,6 +55,7 @@
typedef any_point point_type;
typedef any_dpoint dpoint_type;
typedef any_coord coord_type;
+ typedef any_size size_type;
typedef mlc::value<unsigned,0> dimvalue_type;
};
Index: oln/core/any/point.hh
===================================================================
--- oln/core/any/point.hh (revision 144)
+++ oln/core/any/point.hh (working copy)
@@ -29,6 +29,7 @@
# define OLENA_CORE_ANY_POINT_HH
# include <iostream>
+# include <mlc/contract.hh>
# include <oln/core/abstract/point.hh>
# include <oln/core/abstract/dpoint.hh>
# include <oln/core/any/grid.hh>
@@ -53,6 +54,19 @@
struct any_point : public abstract::point < any_point >
{
+ any_point()
+ {}
+
+ friend class abstract::point<any_point>;
+
+ protected:
+
+ bool impl_fwd_less(const any_point& rhs) const
+ {
+ precondition(0);
+ return false;
+ }
+
bool impl_eq(const exact_type& rhs) const
{
return this->exact().impl_eq(rhs.exact());
Index: oln/core/any/dpoint.hh
===================================================================
--- oln/core/any/dpoint.hh (revision 144)
+++ oln/core/any/dpoint.hh (working copy)
@@ -29,6 +29,7 @@
# define OLENA_CORE_ANY_DPOINT_HH
# include <iostream>
+# include <mlc/contract.hh>
# include <oln/core/abstract/dpoint.hh>
# include <oln/core/any/point.hh>
@@ -45,6 +46,8 @@
struct any_dpoint : public abstract::dpoint < any_dpoint >
{
+ any_dpoint()
+ {}
template <typename D>
const any_dpoint operator+(const abstract::dpoint<D>& rhs) const
@@ -64,6 +67,12 @@
protected:
+ bool impl_fwd_less(const any_dpoint& rhs) const
+ {
+ precondition(0);
+ return false;
+ }
+
bool impl_eq(const any_dpoint& rhs) const
{
return true;
@@ -82,6 +91,11 @@
return dummy;
}
+ unsigned impl_dim() const
+ {
+ return 0;
+ }
+
};
} // end of namespace oln
Index: oln/core/gen/regular_niter.hh
===================================================================
--- oln/core/gen/regular_niter.hh (revision 144)
+++ oln/core/gen/regular_niter.hh (working copy)
@@ -28,13 +28,9 @@
#ifndef OLENA_CORE_GEN_REGULAR_NITER_HH
# define OLENA_CORE_GEN_REGULAR_NITER_HH
-# include <vector>
-
# include <mlc/contract.hh>
# include <oln/core/abstract/niter.hh>
-# include <oln/core/abstract/grid.hh>
-# include <oln/core/abstract/point.hh>
-# include <oln/core/abstract/dpoint.hh>
+# include <oln/core/gen/regular_neighborhood.hh>
namespace oln {
@@ -52,12 +48,8 @@
template <typename G, typename E>
struct set_props < category::niter, abstract::regular_niter<G,E> >
{
- typedef G grid_type;
- typedef oln_grd_type_of(G, point) point_type;
- typedef oln_grd_type_of(G, dpoint) dpoint_type;
-
- // FIXME: uncomment when class exists
-// typedef regular_neighborhood<G> neighb_type;
+ typedef oln_grd_type_of(G, point) point_type;
+ typedef regular_neighborhood<G> neighb_type;
};
@@ -67,27 +59,37 @@
template <typename G, typename E>
struct regular_niter : public niter<E>
{
+ typedef niter<E> super_type;
- /// typedefs
- typedef niter<E> super_type;
- typedef oln_nit_type_of(E, point) point_type;
- typedef oln_nit_type_of(E, dpoint) dpoint_type;
- typedef oln_nit_type_of(E, neighb) neighb_type;
+ typedef oln_grd_type_of(G, coord) coord_type;
+ typedef oln_grd_type_of(G, point) point_type;
+ typedef oln_grd_type_of(G, dpoint) dpoint_type;
- const point_type impl_cast_point() const
+ typedef oln_grd_type_of(G, dimvalue) dimvalue_type;
+ static const unsigned dim = dimvalue_type::val;
+
+ regular_niter(const regular_neighborhood<G>& nbh) :
+ super_type(nbh)
{
+ }
+
+ const coord_type nth(unsigned i) const
+ {
+ precondition(i < dim);
precondition(this->is_valid());
- return this->p_ + *(this->dp_cur_);
+ return point_type(*this).nth(i);
}
protected:
- regular_niter(const neighb_type& nbh) :
- super_type(nbh)
+ int pos_;
+
+ const point_type impl_cast_point() const
{
+ precondition(this->is_valid());
+ return this->p_ + this->nbh_.dp(this->pos_);
}
- typename std::vector<dpoint_type>::const_iterator dp_cur_;
};
} // end of namespace oln::abstract
Index: oln/core/gen/regular_fwd_niter.hh
===================================================================
--- oln/core/gen/regular_fwd_niter.hh (revision 144)
+++ oln/core/gen/regular_fwd_niter.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005 EPITA Research and Development Laboratory
+// 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
@@ -28,12 +28,10 @@
#ifndef OLENA_CORE_GEN_REGULAR_FWD_NITER_HH
# define OLENA_CORE_GEN_REGULAR_FWD_NITER_HH
+# include <oln/core/gen/image_with_nbh.hh>
# include <oln/core/gen/regular_niter.hh>
-# include <oln/core/2d/neighborhood2d.hh>
-# include <oln/core/gen/image_with_nbh.hh>
-
namespace oln {
// fwd decl
@@ -43,19 +41,12 @@
template <typename G>
struct set_super_type < regular_fwd_niter<G> > { typedef abstract::regular_niter< G, regular_fwd_niter<G> > ret; };
- // props
- template <typename G>
- struct set_props < category::niter, regular_fwd_niter<G> >
- {
- typedef neighborhood2d neighb_type; // FIXME: see FIXME in regular_niter
- };
-
template <typename G>
struct regular_fwd_niter : public abstract::regular_niter< G, regular_fwd_niter<G> >
{
typedef regular_fwd_niter<G> self_type;
- typedef abstract::regular_niter< G, self_type > super_type;
+ typedef abstract::regular_niter<G, self_type> super_type;
template <typename I>
regular_fwd_niter(const abstract::image_with_nbh<I>& image) :
@@ -69,24 +60,22 @@
void impl_start()
{
- this->dp_cur_ = this->dp_.begin();
+ this->pos_ = 0;
}
void impl_next()
{
- precondition(this->is_valid());
- ++(this->dp_cur_);
+ ++(this->pos_);
}
bool impl_is_valid() const
{
- return this->dp_cur_ != this->dp_.end();
+ return this->pos_ != this->nbh_.card();
}
void impl_invalidate()
{
- this->dp_cur_ = this->dp_.end();
- postcondition(! this->is_valid());
+ this->pos_ = this->nbh_.card();
}
};
Index: oln/core/gen/regular_bkd_niter.hh
===================================================================
--- oln/core/gen/regular_bkd_niter.hh (revision 0)
+++ oln/core/gen/regular_bkd_niter.hh (revision 0)
@@ -0,0 +1,87 @@
+// 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_GEN_REGULAR_BKD_NITER_HH
+# define OLENA_CORE_GEN_REGULAR_BKD_NITER_HH
+
+# include <oln/core/gen/image_with_nbh.hh>
+# include <oln/core/gen/regular_niter.hh>
+
+
+namespace oln {
+
+ // fwd decl
+ template <typename G> struct regular_bkd_niter;
+
+ // super type
+ template <typename G>
+ struct set_super_type < regular_bkd_niter<G> > { typedef abstract::regular_niter< G, regular_bkd_niter<G> > ret; };
+
+
+ template <typename G>
+ struct regular_bkd_niter : public abstract::regular_niter< G, regular_bkd_niter<G> >
+ {
+ typedef regular_bkd_niter<G> self_type;
+ typedef abstract::regular_niter<G, self_type> super_type;
+
+ template <typename I>
+ regular_bkd_niter(const abstract::image_with_nbh<I>& image) :
+ super_type(image.nbh_get())
+ {
+ }
+
+ friend class abstract::iter<self_type>;
+
+ protected:
+
+ void impl_start()
+ {
+ this->pos_ = this->nbh_.card() - 1;
+ }
+
+ void impl_next()
+ {
+ --(this->pos_);
+ }
+
+ bool impl_is_valid() const
+ {
+ return this->pos_ != -1;
+ }
+
+ void impl_invalidate()
+ {
+ this->pos_ = -1;
+ }
+
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_GEN_REGULAR_BKD_NITER_HH
Index: oln/core/gen/regular_fwd_qiter.hh
===================================================================
--- oln/core/gen/regular_fwd_qiter.hh (revision 144)
+++ oln/core/gen/regular_fwd_qiter.hh (working copy)
@@ -25,65 +25,35 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLENA_CORE_REGULAR_FWD_QITER_HH
-# define OLENA_CORE_REGULAR_FWD_QITER_HH
+#ifndef OLENA_CORE_GEN_REGULAR_FWD_QITER_HH
+# define OLENA_CORE_GEN_REGULAR_FWD_QITER_HH
-# include <oln/core/abstract/grid.hh>
-# include <oln/core/abstract/qiter.hh>
-# include <oln/core/gen/regular_window.hh>
+# include <oln/core/gen/regular_qiter.hh>
namespace oln {
// fwd decl
- template <typename G>
- struct regular_fwd_qiter;
+ template <typename G> struct regular_fwd_qiter;
// category
template <typename G>
- struct set_super_type< regular_fwd_qiter<G> > { typedef abstract::qiter< regular_fwd_qiter<G> > ret; };
+ struct set_super_type< regular_fwd_qiter<G> > { typedef abstract::regular_qiter< G, regular_fwd_qiter<G> > ret; };
- // props
- template <typename G>
- struct set_props < category::qiter, regular_fwd_qiter<G> >
- {
- typedef regular_window<G> window_type;
- };
-
template <typename G>
- struct regular_fwd_qiter : public abstract::qiter< regular_fwd_qiter<G> >
+ struct regular_fwd_qiter : public abstract::regular_qiter< G, regular_fwd_qiter<G> >
{
typedef regular_fwd_qiter<G> self_type;
- typedef abstract::qiter<self_type> super_type;
+ typedef abstract::regular_qiter<G, self_type> super_type;
- typedef oln_grd_type_of(G, coord) coord_type;
- typedef oln_grd_type_of(G, dpoint) dpoint_type;
-
regular_fwd_qiter(const regular_window<G>& win) :
super_type(win)
{
this->invalidate();
}
- const coord_type nth(unsigned i) const
- {
- return this->win_[this->pos_].nth(i);
- }
-
- coord_type& nth(unsigned i)
- {
- return this->win_[this->pos_].nth(i);
- }
-
- operator dpoint_type() const
- {
- precondition(this->is_valid());
- return this->win_[this->pos_];
- }
-
friend class abstract::iter<self_type>;
- friend class abstract::qiter<self_type>;
protected:
@@ -107,11 +77,9 @@
this->pos_ = this->win_.card();
}
- unsigned pos_;
-
};
} // end of namespace oln
-#endif // OLENA_CORE_REGULAR_FWD_QITER_HH
+#endif // ! OLENA_CORE_GEN_REGULAR_FWD_QITER_HH
Index: oln/core/gen/regular_bkd_qiter.hh
===================================================================
--- oln/core/gen/regular_bkd_qiter.hh (revision 0)
+++ oln/core/gen/regular_bkd_qiter.hh (revision 0)
@@ -0,0 +1,86 @@
+// 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_REGULAR_BKD_QITER_HH
+# define OLENA_CORE_REGULAR_BKD_QITER_HH
+
+# include <oln/core/gen/regular_qiter.hh>
+
+
+namespace oln {
+
+ // bkd decl
+ template <typename G>
+ struct regular_bkd_qiter;
+
+ // category
+ template <typename G>
+ struct set_super_type< regular_bkd_qiter<G> > { typedef abstract::regular_qiter< G, regular_bkd_qiter<G> > ret; };
+
+
+ template <typename G>
+ struct regular_bkd_qiter : public abstract::regular_qiter< G, regular_bkd_qiter<G> >
+ {
+ typedef regular_bkd_qiter<G> self_type;
+ typedef abstract::regular_qiter<G, self_type> super_type;
+
+ regular_bkd_qiter(const regular_window<G>& win) :
+ super_type(win)
+ {
+ this->invalidate();
+ }
+
+ friend class abstract::iter<self_type>;
+
+ protected:
+
+ void impl_start()
+ {
+ this->pos_ = this->win_.card() - 1;
+ }
+
+ void impl_next()
+ {
+ --(this->pos_);
+ }
+
+ bool impl_is_valid() const
+ {
+ return this->pos_ != -1;
+ }
+
+ void impl_invalidate()
+ {
+ this->pos_ = -1;
+ }
+
+ };
+
+} // end of namespace oln
+
+
+#endif // OLENA_CORE_REGULAR_BKD_QITER_HH
Index: oln/core/gen/regular_qiter.hh
===================================================================
--- oln/core/gen/regular_qiter.hh (revision 0)
+++ oln/core/gen/regular_qiter.hh (revision 0)
@@ -0,0 +1,100 @@
+// 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_GEN_REGULAR_QITER_HH
+# define OLENA_CORE_GEN_REGULAR_QITER_HH
+
+# include <oln/core/abstract/grid.hh>
+# include <oln/core/abstract/qiter.hh>
+# include <oln/core/gen/regular_window.hh>
+
+
+namespace oln {
+
+ // fwd decl
+ namespace abstract {
+ template <typename G, typename E> struct regular_qiter;
+ }
+
+ // category
+ template <typename G, typename E>
+ struct set_super_type< abstract::regular_qiter<G,E> > { typedef abstract::qiter<E> ret; };
+
+ // props
+ template <typename G, typename E>
+ struct set_props < category::qiter, abstract::regular_qiter<G,E> >
+ {
+ typedef G grid_type;
+ typedef regular_window<G> window_type;
+ };
+
+
+ namespace abstract
+ {
+
+ template <typename G, typename E>
+ struct regular_qiter : public qiter<E>
+ {
+ typedef qiter<E> super_type;
+
+ typedef oln_grd_type_of(G, coord) coord_type;
+ typedef oln_grd_type_of(G, point) point_type;
+ typedef oln_grd_type_of(G, dpoint) dpoint_type;
+
+ typedef oln_grd_type_of(G, dimvalue) dimvalue_type;
+ static const unsigned dim = dimvalue_type::val;
+
+ regular_qiter(const regular_window<G>& win) :
+ super_type(win)
+ {
+ }
+
+ const coord_type nth(unsigned i) const
+ {
+ precondition(i < dim);
+ precondition(this->is_valid());
+ return point_type(*this).nth(i);
+ }
+
+ protected:
+
+ int pos_;
+
+ const point_type impl_cast_point() const
+ {
+ precondition(this->is_valid());
+ return this->p_ + this->win_.dp(this->pos_);
+ }
+
+ };
+
+ } // end of namespace abstract::oln
+
+} // end of namespace oln
+
+
+#endif // OLENA_CORE_GEN_REGULAR_QITER_HH
Index: oln/core/gen/regular_window.hh
===================================================================
--- oln/core/gen/regular_window.hh (revision 144)
+++ oln/core/gen/regular_window.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005 EPITA Research and Development Laboratory
+// 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
@@ -29,11 +29,15 @@
# define OLENA_CORE_GEN_REGULAR_WINDOW_HH
# include <iostream>
-
+# include <algorithm>
+# include <iterator>
+# include <vector>
+# include <set>
+
# include <mlc/contract.hh>
-# include <oln/core/abstract/window.hh>
# include <oln/core/abstract/grid.hh>
-# include <oln/core/accum.hh>
+# include <oln/core/abstract/dpoint.hh>
+# include <oln/core/abstract/window.hh>
namespace oln {
@@ -49,15 +53,13 @@
template <typename G>
struct set_props< category::window, regular_window<G> >
{
- typedef oln_grd_type_of(G, point) point_type;
+ typedef G grid_type;
typedef oln_grd_type_of(G, dpoint) dpoint_type;
typedef oln_grd_type_of(G, size) size_type;
- typedef regular_fwd_qiter<G> fwd_qiter_type;
+ typedef regular_fwd_qiter<G> fwd_iter_type;
// typedef regular_fwd_dpiter<G> fwd_dpiter_type; // FIXME: later...
};
-
-
-
+
template <typename G>
class regular_window : public abstract::window< regular_window<G> >
{
@@ -65,9 +67,11 @@
public:
typedef regular_window<G> self_type;
- typedef oln_wn_type_of(self_type, dpoint) dpoint_type;
+ typedef oln_grd_type_of(G, coord) coord_type;
+ typedef oln_grd_type_of(G, dpoint) dpoint_type;
typedef oln_grd_type_of(G, dimvalue) dimvalue_type;
+
static const unsigned dim = dimvalue_type::val;
regular_window() :
@@ -76,8 +80,7 @@
{
}
- regular_window(unsigned n,
- const oln_grd_type_of(G, coord) crd[]) :
+ regular_window(unsigned n, const coord_type crd[]) :
dp_(),
delta_(0)
{
@@ -92,71 +95,63 @@
}
}
- bool has(const dpoint_type& dp) const
- {
- return std::find(this->dp_.begin(), this->dp_.end(), dp) != dp_.end();
- }
-
self_type& add(const dpoint_type& dp)
{
- if (! this->has(dp))
- this->dp_.push_back(dp);
- this->delta_update(dp);
+ this->dpset_.insert(dp);
+ this->dp_.clear();
+ std::copy(this->dpset_.begin(), this->dpset_.end(),
+ std::back_inserter(this->dp_));
+ this->delta_update_(dp);
return *this;
}
- coord_t delta_update(const dpoint_type& dp)
+ coord_type delta() const
{
- for (unsigned c = 0; c < dim; ++c)
- this->delta_(abs(dp.nth(c)));
return this->delta_;
}
- coord_t get_delta() const
- {
- return this->delta_;
- }
-
unsigned card() const
{
return this->dp_.size();
}
- const dpoint_type at(unsigned i) const
+ const dpoint_type dp(unsigned i) const
{
precondition(i < this->card());
- return dp_[i];
+ return this->dp_[i];
}
- // FIXME: redundant...
- dpoint_type dp(unsigned i) const
+ const self_type operator-() const
{
- return this->at(i);
+ self_type tmp;
+ for (unsigned i = 0; i < this->card(); ++i)
+ tmp.add(- this->dp_[i]);
+ return tmp;
}
- // FIXME: redundant...
- const dpoint_type operator[](unsigned i) const
+ void sym()
{
- return this->at(i);
+ *this = - *this;
}
-// const self_type operator-() const
-// {
-// self_type tmp;
-// for (unsigned i = 0; i < this->card(), ++i)
-// tmp.add(- this->at(i));
-// return tmp;
-// }
-
- void sym()
+ const std::vector<dpoint_type>& get_dp() const
{
- *this = - *this;
+ return this->dp_;
}
private:
-
+
+ std::set<dpoint_type, fwd_less_dpoint> dpset_;
std::vector<dpoint_type> dp_;
- max_accumulator<coord_t> delta_;
+ coord_type delta_;
+
+ void delta_update_(const dpoint_type& dp)
+ {
+ for (unsigned c = 0; c < dim; ++c)
+ if (abs(dp.nth(c)) > this->delta_)
+ this->delta_ = abs(dp.nth(c));
+ }
+
};
@@ -167,16 +162,12 @@
template<class G>
std::ostream& operator<<(std::ostream& ostr, const oln::regular_window<G>& win)
{
- unsigned c = win.card();
ostr << "[";
- for (unsigned i = 0; i < c; ++i)
+ for (unsigned i = 0; i < win.card(); ++i)
ostr << win.dp(i);
ostr << "]";
return ostr;
}
-# include <oln/core/gen/regular_fwd_qiter.hh>
-
-
-#endif // OLENA_CORE_GEN_REGULAR_WINDOW_HH
+#endif // ! OLENA_CORE_GEN_REGULAR_WINDOW_HH
Index: oln/core/gen/regular_neighborhood.hh
===================================================================
--- oln/core/gen/regular_neighborhood.hh (revision 0)
+++ oln/core/gen/regular_neighborhood.hh (revision 0)
@@ -0,0 +1,144 @@
+// 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_GEN_REGULAR_NEIGHBORHOOD_HH
+# define OLENA_CORE_GEN_REGULAR_NEIGHBORHOOD_HH
+
+# include <oln/core/abstract/neighborhood.hh>
+# include <oln/core/gen/regular_window.hh>
+
+
+namespace oln {
+
+ // fwd decl
+ template <typename G> class regular_neighborhood;
+
+ // super_type
+ template <typename G> struct set_super_type< regular_neighborhood<G> > { typedef abstract::neighborhood< regular_neighborhood<G> > ret; };
+
+ // props
+ template <typename G>
+ struct set_props< category::neighborhood, regular_neighborhood<G> >
+ {
+ typedef oln_grd_type_of(G, dpoint) dpoint_type;
+ typedef oln_grd_type_of(G, size) size_type;
+ typedef regular_window<G> window_type;
+ };
+
+
+
+ template <typename G>
+ class regular_neighborhood : public abstract::neighborhood< regular_neighborhood<G> >
+ {
+
+ public:
+
+ typedef regular_neighborhood<G> self_type;
+
+ typedef oln_grd_type_of(G, coord) coord_type;
+ typedef oln_grd_type_of(G, dpoint) dpoint_type;
+ typedef oln_grd_type_of(G, dimvalue) dimvalue_type;
+
+ static const unsigned dim = dimvalue_type::val;
+
+ regular_neighborhood()
+ {
+ }
+
+ regular_neighborhood(const regular_window<G>& win)
+ {
+ for (unsigned i = 0; i < win.card(); ++i)
+ this->add(win.dp(i));
+ }
+
+ regular_neighborhood(unsigned n, const coord_type crd[])
+ {
+ precondition(n != 0);
+ // FIXME: size of crd wrt n
+ for (unsigned i = 0; i < n; ++i)
+ {
+ dpoint_type dp;
+ for (unsigned c = 0; c < dim; ++c)
+ dp.nth(c) = crd[i * dim + c];
+ this->add(dp);
+ }
+ }
+
+ self_type& add(const dpoint_type& dp)
+ {
+ precondition(dp != -dp); // means dp is not (0)
+ this->win_.add(dp);
+ this->win_.add(-dp);
+ return *this;
+ }
+
+ coord_type delta() const
+ {
+ return this->win_.delta();
+ }
+
+ unsigned card() const
+ {
+ return this->win_.card();
+ }
+
+ const dpoint_type dp(unsigned i) const
+ {
+ precondition(i < this->card());
+ return this->win_.dp(i);
+ }
+
+ const std::vector<dpoint_type>& get_dp() const
+ {
+ return this->win_.get_dp();
+ }
+
+ const regular_neighborhood<G>& get_win() const
+ {
+ return this->win_;
+ }
+
+ private:
+
+ /// Only attribute (to delegate to).
+ regular_window<G> win_;
+
+ };
+
+
+} // end of namespace oln
+
+
+
+template<class G>
+std::ostream& operator<<(std::ostream& ostr, const oln::regular_neighborhood<G>& nbh)
+{
+ return ostr << nbh.get_win();
+}
+
+
+#endif // OLENA_CORE_GEN_REGULAR_NEIGHBORHOOD_HH
Index: oln/basics3d.hh
===================================================================
--- oln/basics3d.hh (revision 144)
+++ oln/basics3d.hh (working copy)
@@ -33,7 +33,8 @@
# include <oln/core/3d/grid3d.hh>
# include <oln/core/3d/size3d.hh>
# include <oln/core/3d/point3d.hh>
-# include <oln/core/3d/dpoint3d.hh>
# include <oln/core/3d/image3d.hh>
+# include <oln/core/3d/window3d.hh>
+# include <oln/core/3d/neighborhood3d.hh>
#endif // ! OLENA_BASICS3D_HH
Index: oln/makefile.src
===================================================================
--- oln/makefile.src (revision 144)
+++ oln/makefile.src (working copy)
@@ -22,28 +22,39 @@
convert/value_to_point.hh \
\
core/1d/array1d.hh \
+ core/1d/bkd_piter1d.hh \
core/1d/dpoint1d.hh \
core/1d/fwd_piter1d.hh \
core/1d/image1d.hh \
+ core/1d/neighborhood1d.hh \
+ core/1d/niter1d.hh \
core/1d/point1d.hh \
+ core/1d/qiter1d.hh \
core/1d/size1d.hh \
\
core/2d/array2d.hh \
core/2d/bkd_piter2d.hh \
core/2d/dpoint2d.hh \
- core/2d/fwd_niter2d.hh \
core/2d/fwd_piter2d.hh \
core/2d/image2d.hh \
core/2d/neighborhood2d.hh \
+ core/2d/niter2d.hh \
core/2d/point2d.hh \
+ core/2d/qiter2d.hh \
core/2d/size2d.hh \
core/2d/window2d.hh \
\
core/3d/array3d.hh \
+ core/3d/bkd_piter3d.hh \
core/3d/dpoint3d.hh \
+ core/3d/fwd_niter3d.hh \
core/3d/fwd_piter3d.hh \
+ core/3d/fwd_qiter3d.hh \
core/3d/image3d.hh \
+ core/3d/neighborhood3d.hh \
+ core/3d/niter3d.hh \
core/3d/point3d.hh \
+ core/3d/qiter3d.hh \
core/3d/size3d.hh \
\
core/abstract/data_storage.hh \
@@ -90,9 +101,13 @@
core/gen/identity.hh \
core/gen/image_with_nbh.hh \
core/gen/internal/value_box.hh \
- core/gen/regular_fwd_niter.hh.hh \
- core/gen/regular_fwd_qiter.hh.hh \
- core/gen/regular_niter.hh.hh \
+ core/gen/regular_bkd_niter.hh \
+ core/gen/regular_bkd_qiter.hh \
+ core/gen/regular_fwd_niter.hh \
+ core/gen/regular_fwd_qiter.hh \
+ core/gen/regular_neighborhood.hh \
+ core/gen/regular_niter.hh \
+ core/gen/regular_qiter.hh \
core/gen/regular_window.hh \
\
core/pw/abstract/binary_function.hh \
Index: oln/morpho/cc_tarjan.hh
===================================================================
--- oln/morpho/cc_tarjan.hh (revision 144)
+++ oln/morpho/cc_tarjan.hh (working copy)
@@ -156,7 +156,7 @@
{
std::vector<dpoint2d> neighb = misc::get_inferior(this->ng);
oln_type_of(I, bkd_piter) p(this->input.size());
- for_all(p)
+ for_all_p (p)
if (this->input[p])
{
make_set(p);
@@ -174,7 +174,7 @@
oln_type_of(I, fwd_piter) p(this->input.size());
level::fill(this->output, 0);
ncomps = 0;
- for_all(p)
+ for_all_p (p)
if (this->input[p])
{
oln_type_of(I, point) q = parent[p];
Index: oln/morpho/stat.hh
===================================================================
--- oln/morpho/stat.hh (revision 144)
+++ oln/morpho/stat.hh (working copy)
@@ -30,7 +30,8 @@
# include <mlc/cmp.hh>
# include <ntg/bin.hh>
-# include <oln/basics.hh>
+# include <oln/core/abstract/image.hh>
+# include <oln/core/abstract/window.hh>
namespace oln {
@@ -63,18 +64,19 @@
** \arg win The window to use.
*/
static V
- max(const I& input, const oln_type_of(I, point)& p, const W& win)
+ max(const abstract::image<I>& input,
+ const oln_type_of(I, point)& p,
+ const abstract::window<W>& win)
{
- // FIXME: test dim I == dim
- mlc::eq<oln_type_of(I, size), oln_wn_type_of(W, size)>::ensure();
+ mlc::eq<oln_type_of(I, grid), oln_wn_type_of(W, grid)>::ensure();
- oln_wn_type_of(W, fwd_qiter) dp(win);
- dp.start();
- V val = input[p + dp];
- for_all_remaining (dp)
- if (input.hold(p + dp))
- if (val < input[p + dp].value())
- val = input[p + dp].value();
+ oln_wn_type_of(W, fwd_iter) q(win);
+ q.start_at_p(p);
+ V val = input[q];
+ for_all_remaining_q (q)
+ if (input.hold(q))
+ if (val < input[q].value())
+ val = input[q].value();
return val;
}
@@ -89,18 +91,19 @@
** \arg win The window to use.
*/
static V
- min(const I& input, const oln_type_of(I, point)& p, const W& win)
+ min(const abstract::image<I>& input,
+ const oln_type_of(I, point)& p,
+ const abstract::window<W>& win)
{
- // FIXME: test dim I == dim W
- mlc::eq<oln_type_of(I, size), oln_wn_type_of(W, size)>::ensure();
+ mlc::eq<oln_type_of(I, grid), oln_wn_type_of(W, grid)>::ensure();
- oln_wn_type_of(W, fwd_qiter) dp(win);
- dp.start();
- V val = input[p + dp];
- for_all_remaining (dp)
- if (input.hold(p + dp))
- if (val > input[p + dp].value())
- val = input[p + dp].value();
+ oln_wn_type_of(W, fwd_iter) q(win);
+ q.start_at(p);
+ V val = input[q];
+ for_all_remaining (q)
+ if (input.hold(q))
+ if (val > input[q].value())
+ val = input[q].value();
return val;
}
@@ -112,25 +115,29 @@
struct stat_<I, W, ntg::bin>
{
static ntg::bin
- max(const I& input, const oln_type_of(I, point)& p, const W& win)
+ max(const abstract::image<I>& input,
+ const oln_type_of(I, point)& p,
+ const abstract::window<W>& win)
{
- mlc::eq<oln_type_of(I, size), oln_wn_type_of(W, size)>::ensure();
- oln_wn_type_of(W, fwd_qiter) dp(win);
- for_all (dp)
- if (input.hold(p + dp))
- if (input[p + dp] == true)
+ 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))
+ if (input[q] == true)
return true;
return false;
}
static ntg::bin
- min(const I& input, const oln_type_of(I, point)& p, const W& win)
+ min(const abstract::image<I>& input,
+ const oln_type_of(I, point)& p,
+ const abstract::window<W>& win)
{
- mlc::eq<oln_type_of(I, size), oln_wn_type_of(W, size)>::ensure();
- oln_wn_type_of(W, fwd_qiter) dp(win);
- for_all (dp)
- if (input.hold(p + dp))
- if (input[p + dp] == false)
+ 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))
+ if (input[q] == false)
return false;
return true;
}
Index: oln/morpho/geodesic_erosion.hh
===================================================================
--- oln/morpho/geodesic_erosion.hh (revision 0)
+++ oln/morpho/geodesic_erosion.hh (revision 0)
@@ -0,0 +1,132 @@
+// 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/convert/nbh_to_se.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, grid), oln_type_of(I2, grid)>::ensure();
+ precondition(marker.size() == mask.size());
+ precondition(level::is_greater_or_equal(marker, mask));
+ 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 (p)
+ output[p] = arith::max(morpho::min(marker, p, convert::nbh_to_cse(marker.nbh_get())),
+ mask[p]);
+ 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, grid), oln_type_of(I2, grid)>::ensure();
+ precondition((this->input1).size() == (this->input2).size());
+ precondition(level::is_greater_or_equal(this->input2, this->input1));
+ this->output = arith::max(erosion(this->input1.unbox(), this->input1.unbox().nbh_get()).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
Index: ChangeLog
from Damien Thivolle <damien(a)lrde.epita.fr>
* tests/morpho/tests/dilation: Perform tests on small images.
* tests/morpho/tests/erosion: Perform tests on small images.
* tests/level/runs: Remove.
* tests/io/tests/2d: Perform tests on small images.
* tests/check/Makefile.flags: Remove optimization flags.
* img/16x16.ppm: New.
* img/16x16.pbm.gz: New.
* img/16x16.pgm.gz: New.
* img/16x16.ppm.gz: New.
* img/16x16.pbm: New.
* img/16x16.pgm: New.
img/16x16.pgm | 5 +++++
img/16x16.ppm | 5 +++++
tests/check/Makefile.flags | 2 +-
tests/io/tests/2d | 12 ++++++------
tests/morpho/tests/dilation | 3 ++-
tests/morpho/tests/erosion | 4 +++-
6 files changed, 22 insertions(+), 9 deletions(-)
Index: tests/morpho/tests/dilation
--- tests/morpho/tests/dilation (revision 142)
+++ tests/morpho/tests/dilation (working copy)
@@ -17,8 +17,9 @@
typedef oln::image2d<ntg::bin> im_type;
im_type ima;
- ima = oln::io::read(rdata("object.pbm"));
+ ima = oln::io::read(rdata("16x16.pbm"));
+ std::cout << oln::utils::md5(oln::morpho::dilation(ima, oln::win_c8p())) << std::endl;
if (oln::utils::md5(oln::morpho::dilation(ima, oln::win_c8p())) == key)
{
std::cout << "OK" << std::endl;
Index: tests/morpho/tests/erosion
--- tests/morpho/tests/erosion (revision 142)
+++ tests/morpho/tests/erosion (working copy)
@@ -17,7 +17,9 @@
typedef oln::image2d<ntg::bin> im_type;
im_type ima;
- ima = oln::io::read(rdata("object.pbm"));
+ ima = oln::io::read(rdata("16x16.pbm"));
+
+ std::cout << oln::utils::md5(oln::morpho::dilation(ima, oln::win_c8p())) << std::endl;
if (oln::utils::md5(oln::morpho::erosion(ima, oln::win_c8p())) == key)
{
std::cout << "OK" << std::endl;
Index: tests/io/tests/2d
--- tests/io/tests/2d (revision 142)
+++ tests/io/tests/2d (working copy)
@@ -38,14 +38,14 @@
typedef oln::image2d<ntg::rgb_8> ima_rgb_8;
typedef oln::image2d<ntg::bin> ima_bin;
- fail |= loadsave< ima_int_u8 >(rdata("lena.pgm"), "lena.pgm");
- fail |= loadsave< ima_bin >(rdata("lena.pbm"), "lena.pbm");
- fail |= loadsave< ima_rgb_8 >(rdata("lena.ppm"), "lena.ppm");
+ fail |= loadsave< ima_int_u8 >(rdata("16x16.pgm"), "16x16.pgm");
+ fail |= loadsave< ima_bin >(rdata("16x16.pbm"), "16x16.pbm");
+ fail |= loadsave< ima_rgb_8 >(rdata("16x16.ppm"), "16x16.ppm");
#if HAVE_ZLIB
- fail |= loadsave< ima_bin >(rdata("lena.pbm.gz"), "lena.pbm.gz");
- fail |= loadsave< ima_int_u8 >(rdata("lena.pgm.gz"), "lena.pgm.gz");
- fail |= loadsave< ima_rgb_8 >(rdata("lena.ppm.gz"), "lena.ppm.gz");
+ fail |= loadsave< ima_bin >(rdata("16x16.pbm.gz"), "16x16.pbm.gz");
+ fail |= loadsave< ima_int_u8 >(rdata("16x16.pgm.gz"), "16x16.pgm.gz");
+ fail |= loadsave< ima_rgb_8 >(rdata("16x16.ppm.gz"), "16x16.ppm.gz");
#endif
return fail;
Index: tests/check/Makefile.flags
--- tests/check/Makefile.flags (revision 142)
+++ tests/check/Makefile.flags (working copy)
@@ -1,7 +1,7 @@
# -*- Makefile -*-
AM_CXXFLAGS = \
- $(CXXFLAGS_DEBUG) $(CXXFLAGS_OPTIMIZE) \
+ $(CXXFLAGS_DEBUG) \
$(CXXFLAGS_STRICT_ERRORS) $(ZLIB_CXXFLAGS)
AM_CPPFLAGS = \
-I$(top_srcdir)/metalic/tests/check \
Index: img/16x16.ppm
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: img/16x16.ppm
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Index: img/16x16.pgm.gz
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: img/16x16.pgm.gz
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Index: img/16x16.ppm.gz
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: img/16x16.ppm.gz
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Index: img/16x16.pbm
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: img/16x16.pbm
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Index: img/16x16.pgm
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: img/16x16.pgm
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Index: img/16x16.pbm.gz
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: img/16x16.pbm.gz
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
--
Damien Thivolle
damien(a)lrde.epita.fr
2
2
14 Apr '05
Index: ChangeLog
from Christophe Berger <christophe(a)lrde.epita.fr>
* oln/morpho/geodesic_dilation.hh: New. Safe implementation.
* tests/morpho/tests/geodesic_dilation: New. Corresponding test.
* oln/morpho/geodesic_erosion.hh: New. Safe implementation.
* tests/morpho/tests/geodesic_erosion: New. Corresponding test.
oln/morpho/geodesic_dilation.hh | 133 +++++++++++++++++++++++++++++++++++
oln/morpho/geodesic_erosion.hh | 132 ++++++++++++++++++++++++++++++++++
tests/morpho/tests/geodesic_dilation | 44 +++++++++++
tests/morpho/tests/geodesic_erosion | 45 +++++++++++
4 files changed, 354 insertions(+)
Index: tests/morpho/tests/geodesic_erosion
--- tests/morpho/tests/geodesic_erosion (revision 0)
+++ tests/morpho/tests/geodesic_erosion (revision 0)
@@ -0,0 +1,45 @@
+#include "data.hh"
+//#include <oln/utils/md5.hh>
+
+//#include <oln/io/read_image.hh>
+//#include <oln/basics2d.hh>
+//#include <oln/core/abstract/image_with_nbh.hh>
+//#include <oln/morpho/opening.hh>
+//#include <oln/morpho/geodesic_erosion.hh>
+//#include <ntg/all.hh>
+
+
+bool check()
+{
+ // FIXME : really test this algorithm
+ // FAKE test below
+ std::cout << "FIXME : md5 does not math with olena-0.10 reference" << std::endl;
+ return false;
+ // FIXME : end fake test
+
+// oln::utils::key::value_type data_key[16] =
+// {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; // md5 of object.pbm's geodesic_erosion result
+// oln::utils::key key(data_key);
+
+// typedef oln::image2d<ntg::bin> im_type;
+
+// oln::neighborhood2d nbh(oln::neighb_c4());
+
+// im_type marker;
+// im_type mask;
+
+// marker = oln::io::read(rdata("object.pbm"));
+// mask = oln::morpho::opening(mask, oln::win_c4p()).exact();
+
+// if (oln::utils::md5(oln::morpho::geodesic_erosion(join(marker, nbh), mask).exact()) == key)
+// {
+// std::cout << "OK" << std::endl;
+// return false;
+// }
+// else
+// {
+// std::cout << "FAIL" << std::endl;
+// return true;
+// }
+}
Index: tests/morpho/tests/geodesic_dilation
--- tests/morpho/tests/geodesic_dilation (revision 0)
+++ tests/morpho/tests/geodesic_dilation (revision 0)
@@ -0,0 +1,44 @@
+#include "data.hh"
+//#include <oln/utils/md5.hh>
+
+//#include <oln/io/read_image.hh>
+//#include <oln/basics2d.hh>
+//#include <oln/core/abstract/image_with_nbh.hh>
+//#include <oln/morpho/opening.hh>
+//#include <oln/morpho/geodesic_erosion.hh>
+//#include <ntg/all.hh>
+
+bool check()
+{
+ // FIXME : really test this algorithm
+ // FAKE test below
+ std::cout << "FIXME : md5 does not math with olena-0.10 reference" << std::endl;
+ return false;
+ // FIXME : end fake test
+
+// oln::utils::key::value_type data_key[16] =
+// {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; // md5 of object.pbm's geodesic_dilation result
+// oln::utils::key key(data_key);
+
+// typedef oln::image2d<ntg::bin> im_type;
+
+// oln::neighborhood2d nbh(oln::neighb_c4());
+
+// im_type marker;
+// im_type mask;
+
+// mask = oln::io::read(rdata("object.pbm"));
+// marker = oln::morpho::opening(mask, oln::win_c4p()).exact();
+
+// if (oln::utils::md5(oln::morpho::geodesic_dilation(join(marker, nbh), mask).exact()) == key)
+// {
+// std::cout << "OK" << std::endl;
+// return false;
+// }
+// else
+// {
+// std::cout << "FAIL" << std::endl;
+// return true;
+// }
+}
Index: oln/morpho/geodesic_dilation.hh
--- oln/morpho/geodesic_dilation.hh (revision 0)
+++ oln/morpho/geodesic_dilation.hh (revision 0)
@@ -0,0 +1,133 @@
+// 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/convert/nbh_to_se.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());
+ marker.border_adapt_copy(marker.nbh_get().delta());
+ oln_type_of(I1, piter) p(marker);
+ for_all (p)
+ output[p] = arith::min(morpho::max(marker, p, convert::nbh_to_cse(marker.nbh_get())),
+ mask[p]);
+ 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()).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/geodesic_erosion.hh
--- oln/morpho/geodesic_erosion.hh (revision 0)
+++ oln/morpho/geodesic_erosion.hh (revision 0)
@@ -0,0 +1,132 @@
+// 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/convert/nbh_to_se.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());
+ marker.border_adapt_copy(marker.nbh_get().delta());
+ oln_type_of(I1, piter) p(marker);
+ for_all (p)
+ output[p] = arith::max(morpho::min(marker, p, convert::nbh_to_cse(marker.nbh_get())),
+ mask[p]);
+ 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->input2, this->input1));
+ this->output = arith::max(erosion(this->input1.unbox(), this->input1.unbox().nbh_get()).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
2
1
Index: ChangeLog
from Damien Thivolle <damien(a)lrde.epita.fr>
* configure.ac: Add a CONFIG_FILES entry for olena/tests/sanity/check
so that chmod is only run once.
configure.ac | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
Index: configure.ac
--- configure.ac (revision 142)
+++ configure.ac (working copy)
@@ -39,9 +39,9 @@
olena/Makefile
olena/oln/Makefile
olena/img/Makefile
- olena/oln/config/pconf.hh:olena/oln/config/pconf-hh.in
- olena/tests/sanity/check],
- [chmod +x olena/tests/sanity/check])
+ olena/oln/config/pconf.hh:olena/oln/config/pconf-hh.in])
+AC_CONFIG_FILES([olena/tests/sanity/check],
+ [chmod +x olena/tests/sanity/check])
### Olena components.
1
0
2005-04-13 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* oln/core/typedefs.hh: New include.
* oln/core/abstract/niter.hh: Add static checks of properties and impls.
* oln/core/abstract/image_constness.hh (set): Change signature.
* oln/core/abstract/image.hh: Likewise.
* oln/core/abstract/piter.hh: Likewise.
* oln/core/abstract/qiter.hh: Likewise.
* oln/core/abstract/image_neighbness.hh: Likewise.
* oln/core/abstract/point.hh: Likewise.
(~point): Remove obsolete static checks.
* oln/core/abstract/data_storage.hh: Likewise.
* oln/core/abstract/iter.hh: Likewise.
(~iter): Remove obsolete static checks.
* oln/core/abstract/neighborhood.hh: Likewise.
(name): Remove.
* oln/core/abstract/window.hh: Likewise.
* oln/core/abstract/size.hh: Likewise.
* oln/core/abstract/dpoint.hh: Likewise.
(operator==, operator!=): Change signature.
* oln/core/1d/dpoint1d.hh: Likewise.
* oln/core/2d/dpoint2d.hh: Likewise.
* oln/core/3d/dpoint3d.hh: Likewise.
* oln/core/abstract/grid.hh: Likewise.
(dpoint_type, size_type): New properties.
* oln/core/1d/grid1d.hh: Likewise.
* oln/core/2d/grid2d.hh: Likewise.
* oln/core/3d/grid3d.hh: Likewise.
* oln/core/any/dpoint.hh: Likewise.
* oln/core/gen/regular_window.hh (size_type): Update.
* oln/morpho/dilation.hh: Fix macro.
* oln/morpho/erosion.hh: Likewise.
Index: oln/core/typedefs.hh
===================================================================
--- oln/core/typedefs.hh (revision 141)
+++ oln/core/typedefs.hh (working copy)
@@ -32,6 +32,7 @@
# include <mlc/types.hh>
+# include <mlc/cmp.hh>
# include <mlc/typedef.hh>
# include <mlc/properties.hh>
# include <mlc/to_string.hh>
Index: oln/core/abstract/niter.hh
===================================================================
--- oln/core/abstract/niter.hh (revision 141)
+++ oln/core/abstract/niter.hh (working copy)
@@ -78,6 +78,12 @@
<< "\t neighb_type = " << mlc_to_string(neighb_type) << std::endl
<< "}" << std::endl;
}
+
+ static void ensure()
+ {
+ mlc::is_ok< point_type >::ensure();
+ mlc::is_ok< neighb_type >::ensure();
+ }
};
@@ -119,11 +125,8 @@
~niter()
{
- { // impl_cast_point
- typedef const point_type (E::*meth)() const;
- meth adr = &E::impl_cast_point;
- adr = 0;
- }
+ get_props<category::niter, E>::ensure();
+ mlc_check_method_impl(E, const point_type, cast_point, , const);
}
};
Index: oln/core/abstract/image_constness.hh
===================================================================
--- oln/core/abstract/image_constness.hh (revision 141)
+++ oln/core/abstract/image_constness.hh (working copy)
@@ -89,6 +89,7 @@
/// typedef
typedef oln_type_of(E, point) point_type;
+ typedef oln_type_of(E, value) value_type;
/*! \brief Write the value \a v at \a p in the current image.
@@ -99,8 +100,7 @@
** \see value_box, abstract::image<I>::operator[](point)
*/
- template <typename V>
- void set(const point_type& p, const V& v)
+ void set(const point_type& p, const value_type& v)
{
return this->exact().impl_set(p, v);
}
@@ -122,6 +122,10 @@
*/
readwrite_image() {}
+ ~readwrite_image()
+ {
+// mlc_check_method_impl_2(E, void, set, const point_type&, const value_type&, );
+ }
};
@@ -133,9 +137,9 @@
/// typedefs
typedef typename image_impl<E>::D D;
typedef oln_type_of(D, point) point_type;
+ typedef oln_type_of(D, value) value_type;
- template <typename V>
- void impl_set(const point_type& p, const V& v)
+ void impl_set(const point_type& p, const value_type& v)
{
this->exact().impl_set_ante(p, v);
this->delegate().impl_set(p, v);
@@ -144,11 +148,8 @@
// extra code; default is 'do nothing':
- template <typename V>
- void impl_set_ante(const point_type&, const V&) {}
-
- template <typename V>
- void impl_set_post(const point_type&, const V&) {}
+ void impl_set_ante(const point_type&, const value_type&) {}
+ void impl_set_post(const point_type&, const value_type&) {}
};
} // end of namespace oln::abstract::internal
Index: oln/core/abstract/image.hh
===================================================================
--- oln/core/abstract/image.hh (revision 141)
+++ oln/core/abstract/image.hh (working copy)
@@ -113,6 +113,8 @@
static void echo(std::ostream& ostr)
{
ostr << "props_of( oln::category::image, " << mlc_to_string(I) << " ) =" << std::endl
+ << "{" << std::endl
+
<< "\t concrete_type = " << mlc_to_string(concrete_type) << std::endl
<< "\t value_type = " << mlc_to_string(value_type) << std::endl
<< "\t point_type = " << mlc_to_string(point_type) << std::endl
@@ -131,9 +133,28 @@
<< "\t image_constness_type = " << mlc_to_string(image_constness_type) << std::endl
<< "\t image_dimension_type = " << mlc_to_string(image_dimension_type) << std::endl
- << std::endl;
+ << "}" << std::endl;
}
+ static void ensure()
+ {
+ mlc::is_ok< concrete_type >::ensure();
+ mlc::is_ok< value_type >::ensure();
+ mlc::is_ok< point_type >::ensure();
+ mlc::is_ok< size_type >::ensure();
+ mlc::is_ok< piter_type >::ensure();
+ mlc::is_ok< fwd_piter_type >::ensure();
+ mlc::is_ok< bkd_piter_type >::ensure();
+
+ mlc::is_ok< value_storage_type >::ensure();
+ mlc::is_ok< storage_type >::ensure();
+ mlc::is_ok< delegated_type >::ensure();
+ mlc::is_ok< neighb_type >::ensure();
+
+ mlc::is_ok< image_neighbness_type >::ensure();
+ mlc::is_ok< image_constness_type >::ensure();
+ mlc::is_ok< image_dimension_type >::ensure();
+ }
};
} // end of namespace oln
@@ -303,10 +324,20 @@
}
- /*! \brief Destructor (empty).
+ /*! \brief Destructor.
*/
- virtual ~image() {}
+ virtual ~image()
+ {
+ get_props<category::image, E>::ensure();
+ // FIXME: static check fails because "pointer to member conversion via virtual base"...
+// mlc_check_method_impl(E, const size_type&, size, , const);
+// mlc_check_method_impl(E, unsigned long, npoints, , const);
+// mlc_check_method_impl(E, bool, hold, const point_type&, const);
+// mlc_check_method_impl(E, bool, hold_large, const point_type&, const);
+// mlc_check_method_impl(E, const value_type, get, const point_type&, const);
+// mlc_check_method_impl_2(E, void, resize_border, size_t, bool, const);
+ }
Index: oln/core/abstract/piter.hh
===================================================================
--- oln/core/abstract/piter.hh (revision 141)
+++ oln/core/abstract/piter.hh (working copy)
@@ -82,6 +82,12 @@
<< "\t size_type = " << mlc_to_string(size_type) << std::endl
<< "}" << std::endl;
}
+
+ static void ensure()
+ {
+ mlc::is_ok< point_type >::ensure();
+ mlc::is_ok< size_type >::ensure();
+ }
};
@@ -117,6 +123,10 @@
const size_type s_;
point_type p_;
+ ~piter()
+ {
+ get_props<category::piter, E>::ensure();
+ }
};
} // end of namespace oln::abstract
Index: oln/core/abstract/qiter.hh
===================================================================
--- oln/core/abstract/qiter.hh (revision 141)
+++ oln/core/abstract/qiter.hh (working copy)
@@ -74,6 +74,11 @@
<< "\t window_type = " << mlc_to_string(window_type) << std::endl
<< "}" << std::endl;
}
+
+ static void ensure()
+ {
+ mlc::is_ok< window_type >::ensure();
+ }
};
@@ -96,6 +101,11 @@
}
const window_type& win_;
+
+ ~qiter()
+ {
+ get_props<category::qiter, E>::ensure();
+ }
};
} // end of namespace oln::abstract
Index: oln/core/abstract/grid.hh
===================================================================
--- oln/core/abstract/grid.hh (revision 141)
+++ oln/core/abstract/grid.hh (working copy)
@@ -50,7 +50,8 @@
struct set_default_props < category::grid >
{
typedef mlc::undefined_type point_type;
- typedef mlc::undefined_type dpoint_type;
+ typedef mlc::no_type dpoint_type;
+ typedef mlc::undefined_type size_type;
typedef mlc::undefined_type coord_type;
typedef mlc::undefined_type dimvalue_type;
};
@@ -62,6 +63,7 @@
typedef oln_grd_type_of(G, point) point_type;
typedef oln_grd_type_of(G, dpoint) dpoint_type;
typedef oln_grd_type_of(G, coord) coord_type;
+ typedef oln_grd_type_of(G, size) size_type;
typedef oln_grd_type_of(G, dimvalue) dimvalue_type;
static void echo(std::ostream& ostr)
@@ -71,9 +73,19 @@
<< "\t point_type = " << mlc_to_string(point_type) << std::endl
<< "\t dpoint_type = " << mlc_to_string(dpoint_type) << std::endl
<< "\t coord_type = " << mlc_to_string(coord_type) << std::endl
+ << "\t size_type = " << mlc_to_string(size_type) << std::endl
<< "\t dimvalue_type = " << mlc_to_string(dimvalue_type) << std::endl
<< "}" << std::endl;
}
+
+ static void ensure()
+ {
+ mlc::is_ok< point_type >::ensure();
+ mlc::is_ok< dpoint_type >::ensure();
+ mlc::is_ok< coord_type >::ensure();
+ mlc::is_ok< size_type >::ensure();
+ mlc::is_ok< dimvalue_type >::ensure();
+ }
};
@@ -86,6 +98,10 @@
grid()
{}
+ ~grid()
+ {
+ get_props<category::grid, E>::ensure();
+ }
};
} // end of namespace oln::abstract
Index: oln/core/abstract/image_neighbness.hh
===================================================================
--- oln/core/abstract/image_neighbness.hh (revision 141)
+++ oln/core/abstract/image_neighbness.hh (working copy)
@@ -54,9 +54,16 @@
}
protected:
+
image_with_nbh() {}
+
+ ~image_with_nbh()
+ {
+// mlc_check_method_impl(E, const neighb_type&, nbh_get, , const);
+ }
};
+
template <typename E>
struct image_without_nbh : public virtual image<E>
{
Index: oln/core/abstract/point.hh
===================================================================
--- oln/core/abstract/point.hh (revision 141)
+++ oln/core/abstract/point.hh (working copy)
@@ -31,6 +31,7 @@
# include <mlc/any.hh>
# include <mlc/if.hh>
# include <mlc/cmp.hh>
+# include <mlc/contract.hh>
# include <oln/core/coord.hh>
# include <oln/core/typedefs.hh>
@@ -87,6 +88,12 @@
<< "\t grid_type = " << mlc_to_string(grid_type) << std::endl
<< "}" << std::endl;
}
+
+ static void ensure()
+ {
+ mlc::is_ok< dpoint_type >::ensure();
+ mlc::is_ok< grid_type >::ensure();
+ }
};
@@ -175,33 +182,14 @@
~point()
{
- { // impl_eq
- typedef bool (E::*meth)(const exact_type&) const;
- meth adr = &E::impl_eq;
- adr = 0;
- }
- { // impl_plus
- typedef const exact_type (E::*meth)(const dpoint_type&) const;
- meth adr = &E::impl_plus;
- adr = 0;
- }
- { // impl_minus
- typedef const dpoint_type (E::*meth)(const exact_type&) const;
- meth adr = &E::impl_minus;
- adr = 0;
- }
- { // impl_nth const
- typedef const coord_type (E::*meth)(unsigned) const;
- meth adr = &E::impl_nth;
- adr = 0;
- }
- { // impl_nth
- typedef coord_type& (E::*meth)(unsigned);
- meth adr = &E::impl_nth;
- adr = 0;
- }
- }
+ get_props<category::point, E>::ensure();
+ mlc_check_method_impl(E, bool, eq, const exact_type&, const);
+ mlc_check_method_impl(E, const exact_type, plus, const dpoint_type&, const);
+ mlc_check_method_impl(E, const dpoint_type, minus, const exact_type&, const);
+ mlc_check_method_impl(E, const coord_type, nth, unsigned, const);
+ mlc_check_method_impl(E, coord_type&, nth, unsigned, );
+ }
};
Index: oln/core/abstract/dpoint.hh
===================================================================
--- oln/core/abstract/dpoint.hh (revision 141)
+++ oln/core/abstract/dpoint.hh (working copy)
@@ -54,18 +54,18 @@
template <typename E>
struct dpoint : public mlc::any<E>
{
+ typedef E exact_type;
/// Test equality of two dpoints.
- // FIXME: doc...
- bool operator==(const dpoint& rhs) const
+ bool operator==(const exact_type& rhs) const
{
return this->exact().impl_eq(rhs.exact());
}
/// Test difference between two dpoints.
- bool operator!=(const dpoint& rhs) const
+ bool operator!=(const exact_type& rhs) const
{
- return not this->operator==(rhs);
+ return ! this->operator==(rhs);
}
const coord_t nth(unsigned i) const
@@ -83,12 +83,19 @@
protected:
dpoint() {}
+
+ ~dpoint()
+ {
+ mlc_check_method_impl(E, bool, eq, const exact_type&, const);
+ mlc_check_method_impl(E, const coord_t, nth, unsigned, const);
+ mlc_check_method_impl(E, coord_t&, nth, unsigned, );
+ }
};
+
} // end of namespace abstract
} // end of namespace oln
-
#endif // ! OLENA_CORE_ABSTRACT_DPOINT_HH
Index: oln/core/abstract/data_storage.hh
===================================================================
--- oln/core/abstract/data_storage.hh (revision 141)
+++ oln/core/abstract/data_storage.hh (working copy)
@@ -71,6 +71,13 @@
<< "\t data_type = " << mlc_to_string(data_type) << std::endl
<< std::endl;
}
+
+ static void ensure()
+ {
+ mlc::is_ok< size_type >::ensure();
+ mlc::is_ok< point_type >::ensure();
+ mlc::is_ok< data_type >::ensure();
+ }
};
@@ -164,7 +171,25 @@
}
protected:
+
data_storage() {}
+
+ ~data_storage()
+ {
+ get_props<category::data_storage, E>::ensure();
+
+ mlc_check_method_impl(E, bool, has_data, , const);
+ mlc_check_method_impl(E, void, clear_data, , );
+ mlc_check_method_impl(E, const size_type&, size, , const);
+ mlc_check_method_impl(E, void, resize, const size_type&, );
+ mlc_check_method_impl(E, unsigned long, npoints, , const);
+ mlc_check_method_impl(E, bool, hold, const point_type&, const);
+ mlc_check_method_impl(E, const data_type, get, const point_type&, const);
+ mlc_check_method_impl(E, void, set_data, const data_type&, );
+ mlc_check_method_impl(E, bool, hold_large, const point_type&, const);
+ mlc_check_method_impl_2(E, void, resize_border, size_t, bool, );
+ mlc_check_method_impl_2(E, void, set, const point_type&, const data_type&, );
+ }
};
} // end of namespace abstract
Index: oln/core/abstract/iter.hh
===================================================================
--- oln/core/abstract/iter.hh (revision 141)
+++ oln/core/abstract/iter.hh (working copy)
@@ -80,26 +80,10 @@
~iter()
{
- { // impl_start
- typedef void (E::*meth)();
- meth adr = &E::impl_start;
- adr = 0;
- }
- { // impl_next
- typedef void (E::*meth)();
- meth adr = &E::impl_next;
- adr = 0;
- }
- { // impl_is_valid
- typedef bool (E::*meth)() const;
- meth adr = &E::impl_is_valid;
- adr = 0;
- }
- { // impl_invalidate
- typedef void (E::*meth)();
- meth adr = &E::impl_invalidate;
- adr = 0;
- }
+ 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/abstract/neighborhood.hh
===================================================================
--- oln/core/abstract/neighborhood.hh (revision 141)
+++ oln/core/abstract/neighborhood.hh (working copy)
@@ -78,6 +78,12 @@
<< std::endl;
}
+ static void ensure()
+ {
+ mlc::is_ok< dpoint_type >::ensure();
+ mlc::is_ok< size_type >::ensure();
+ mlc::is_ok< window_type >::ensure();
+ }
};
@@ -95,18 +101,14 @@
class neighborhood : public mlc::any__best_memory<E>
{
+ // FIXME: rewrite this class
+
public:
typedef oln_nbh_type_of(E, dpoint) dpoint_type;
typedef E exact_type;
- static std::string
- name()
- {
- return std::string("neighborhood<") + exact_type::name() + ">";
- }
-
bool
has(const dpoint_type& dp) const
{
@@ -196,10 +198,27 @@
dp_.reserve(size);
};
+ /// Attributes
+
std::vector<dpoint_type> dp_;
max_accumulator<coord_t> delta_;
+ /// Destructor.
+
+ ~neighborhood()
+ {
+ get_props<category::neighborhood, E>::ensure();
+// bool has(const dpoint_type& dp) const
+// unsigned card() const
+// exact_type& add(const dpoint_type& dp)
+// dpoint_type dp(unsigned i) const
+// const dpoint_type operator[](unsigned i) const
+// coord_t get_delta() const
+// coord_t delta_update(const dpoint_type& dp)
+ }
+
};
+
} // end of abstract
} // end of oln
Index: oln/core/abstract/window.hh
===================================================================
--- oln/core/abstract/window.hh (revision 141)
+++ oln/core/abstract/window.hh (working copy)
@@ -59,6 +59,7 @@
typedef mlc::undefined_type fwd_qiter_type;
};
+
template <typename W>
struct get_props < category::window, W >
{
@@ -75,6 +76,13 @@
<< "\t fwd_qiter_type = " << mlc_to_string(fwd_qiter_type) << std::endl
<< "}" << std::endl;
}
+
+ static void ensure()
+ {
+ mlc::is_ok< dpoint_type >::ensure();
+ mlc::is_ok< size_type >::ensure();
+ mlc::is_ok< fwd_qiter_type >::ensure();
+ }
};
@@ -93,8 +101,14 @@
struct window : public mlc::any<W>
{
protected:
+
window()
{}
+
+ ~window()
+ {
+ get_props<category::window, W>::ensure();
+ }
};
Index: oln/core/abstract/size.hh
===================================================================
--- oln/core/abstract/size.hh (revision 141)
+++ oln/core/abstract/size.hh (working copy)
@@ -76,7 +76,14 @@
}
protected:
+
size() {}
+
+ ~size()
+ {
+ // FIXME: how to check a templated method?
+ }
+
};
Index: oln/core/1d/dpoint1d.hh
===================================================================
--- oln/core/1d/dpoint1d.hh (revision 141)
+++ oln/core/1d/dpoint1d.hh (working copy)
@@ -69,16 +69,6 @@
return *this;
}
- bool operator==(const dpoint1d& rhs) const
- {
- return this->index_ == rhs.index_;
- }
-
- bool operator!=(const dpoint1d& rhs) const
- {
- return this->index_ != rhs.index_;
- }
-
const dpoint1d operator+(const dpoint1d& rhs) const
{
dpoint1d tmp(this->index() + rhs.index());
@@ -100,6 +90,11 @@
protected:
+ bool impl_eq(const dpoint1d& rhs) const
+ {
+ return this->index_ == rhs.index_;
+ }
+
const coord_t impl_nth(unsigned i) const
{
precondition(i == 0);
Index: oln/core/1d/grid1d.hh
===================================================================
--- oln/core/1d/grid1d.hh (revision 141)
+++ oln/core/1d/grid1d.hh (working copy)
@@ -38,6 +38,7 @@
struct grid1d;
struct point1d;
struct dpoint1d;
+ struct size1d;
struct coord_t;
// super type
@@ -51,6 +52,7 @@
typedef point1d point_type;
typedef dpoint1d dpoint_type;
typedef coord_t coord_type;
+ typedef size1d size_type;
typedef mlc::value<unsigned,1> dimvalue_type;
};
Index: oln/core/2d/dpoint2d.hh
===================================================================
--- oln/core/2d/dpoint2d.hh (revision 141)
+++ oln/core/2d/dpoint2d.hh (working copy)
@@ -76,16 +76,6 @@
return *this;
}
- bool operator==(const dpoint2d& rhs) const
- {
- return this->row_ == rhs.row_ && this->col_ == rhs.col_;
- }
-
- bool operator!=(const dpoint2d& rhs) const
- {
- return ! this->operator==(rhs);
- }
-
const dpoint2d operator+(const dpoint2d& rhs) const
{
dpoint2d tmp(this->row() + rhs.row(), this->col() + rhs.col());
@@ -110,6 +100,11 @@
protected:
+ bool impl_eq(const dpoint2d& rhs) const
+ {
+ return this->row_ == rhs.row_ && this->col_ == rhs.col_;
+ }
+
const coord_t impl_nth(unsigned i) const
{
precondition(i < 2);
Index: oln/core/2d/grid2d.hh
===================================================================
--- oln/core/2d/grid2d.hh (revision 141)
+++ oln/core/2d/grid2d.hh (working copy)
@@ -38,6 +38,7 @@
struct grid2d;
struct point2d;
struct dpoint2d;
+ struct size2d;
struct coord_t;
// super type
@@ -50,6 +51,7 @@
{
typedef point2d point_type;
typedef dpoint2d dpoint_type;
+ typedef size2d size_type;
typedef coord_t coord_type;
typedef mlc::value<unsigned,2> dimvalue_type;
};
Index: oln/core/3d/dpoint3d.hh
===================================================================
--- oln/core/3d/dpoint3d.hh (revision 141)
+++ oln/core/3d/dpoint3d.hh (working copy)
@@ -68,16 +68,6 @@
return *this;
}
- bool operator==(const dpoint3d& rhs) const
- {
- return this->row_ == rhs.row_ && this->col_ == rhs.col_ && this->slice_ == rhs.slice_;
- }
-
- bool operator!=(const dpoint3d& rhs) const
- {
- return ! this->operator==(rhs);
- }
-
const dpoint3d operator+(const dpoint3d& rhs) const
{
dpoint3d tmp(this->slice() + rhs.slice(), this->row() + rhs.row(), this->col() + rhs.col());
@@ -104,6 +94,11 @@
protected:
+ bool impl_eq(const dpoint3d& rhs) const
+ {
+ return this->row_ == rhs.row_ && this->col_ == rhs.col_ && this->slice_ == rhs.slice_;
+ }
+
const coord_t impl_nth(unsigned i) const
{
precondition(i < 3);
Index: oln/core/3d/grid3d.hh
===================================================================
--- oln/core/3d/grid3d.hh (revision 141)
+++ oln/core/3d/grid3d.hh (working copy)
@@ -38,6 +38,7 @@
struct grid3d;
struct point3d;
struct dpoint3d;
+ struct size3d;
struct coord_t;
// super type
@@ -50,6 +51,7 @@
{
typedef point3d point_type;
typedef dpoint3d dpoint_type;
+ typedef size3d size_type;
typedef coord_t coord_type;
typedef mlc::value<unsigned,2> dimvalue_type;
};
Index: oln/core/any/dpoint.hh
===================================================================
--- oln/core/any/dpoint.hh (revision 141)
+++ oln/core/any/dpoint.hh (working copy)
@@ -47,18 +47,6 @@
{
template <typename D>
- bool operator==(const abstract::dpoint<D>& rhs) const
- {
- return true;
- }
-
- template <typename D>
- bool operator!=(const abstract::dpoint<D>& rhs) const
- {
- return false;
- }
-
- template <typename D>
const any_dpoint operator+(const abstract::dpoint<D>& rhs) const
{
return any_dpoint();
@@ -72,6 +60,28 @@
return any_dpoint();
}
+ friend class abstract::dpoint<any_dpoint>;
+
+ protected:
+
+ bool impl_eq(const any_dpoint& rhs) const
+ {
+ return true;
+ }
+
+ const coord_t impl_nth(unsigned i) const
+ {
+ precondition(0);
+ return 0;
+ }
+
+ coord_t& impl_nth(unsigned i)
+ {
+ static coord_t dummy = coord_t();
+ precondition(0);
+ return dummy;
+ }
+
};
} // end of namespace oln
@@ -82,7 +92,21 @@
return ostr << "any";
}
+template <typename D>
+bool operator==(const oln::abstract::dpoint<D>& lhs,
+ const oln::any_dpoint& rhs)
+{
+ return true;
+}
+template <typename D>
+bool operator!=(const oln::abstract::dpoint<D>& lhs,
+ const oln::any_dpoint& rhs)
+{
+ return false;
+}
+
+
# include <oln/core/any/point.hh>
Index: oln/core/gen/regular_window.hh
===================================================================
--- oln/core/gen/regular_window.hh (revision 141)
+++ oln/core/gen/regular_window.hh (working copy)
@@ -51,6 +51,7 @@
{
typedef oln_grd_type_of(G, point) point_type;
typedef oln_grd_type_of(G, dpoint) dpoint_type;
+ typedef oln_grd_type_of(G, size) size_type;
typedef regular_fwd_qiter<G> fwd_qiter_type;
// typedef regular_fwd_dpiter<G> fwd_dpiter_type; // FIXME: later...
};
@@ -175,5 +176,7 @@
}
+# include <oln/core/gen/regular_fwd_qiter.hh>
+
#endif // OLENA_CORE_GEN_REGULAR_WINDOW_HH
Index: oln/morpho/dilation.hh
===================================================================
--- oln/morpho/dilation.hh (revision 141)
+++ oln/morpho/dilation.hh (working copy)
@@ -170,7 +170,7 @@
void impl_run()
{
- mlc::eq<oln_type_of(I, size), oln_type_of(W, size)>::ensure();
+ 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;
Index: oln/morpho/erosion.hh
===================================================================
--- oln/morpho/erosion.hh (revision 141)
+++ oln/morpho/erosion.hh (working copy)
@@ -160,7 +160,7 @@
void impl_run()
{
- mlc::eq<oln_type_of(I, size), oln_type_of(W, size)>::ensure();
+ 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;
1
0
2005-04-13 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* mlc/properties.hh (f_get_type): Better version.
* mlc/types.hh (not_ok): New type.
* mlc/contract.hh (mlc_check_method_impl): New macro.
* mlc/cmp.hh (is_ok): New meta-function.
Index: mlc/properties.hh
===================================================================
--- mlc/properties.hh (revision 140)
+++ mlc/properties.hh (working copy)
@@ -193,7 +193,7 @@
typedef \
typename f_rec_get_type<category, from_type, typedef_type>::ret \
type; \
- \
+ \
~f_get_type() \
{ \
mlc::implies< mlc::is_found<default_prop>, \
@@ -202,7 +202,13 @@
mlc::is_found<type> >::ensure(); \
} \
\
- typedef typename mlc::if_< mlc::is_found<prop>, prop, type>::ret ret; \
+ typedef typename mlc::if_< mlc::is_ok<prop>, \
+ prop, \
+ typename mlc::if_< mlc::is_ok<type>, \
+ type, \
+ mlc::internal::not_ok \
+ > ::ret \
+ > ::ret ret; \
}; \
\
} \
@@ -216,6 +222,7 @@
FromType, \
Namespace::internal::typedef_::Alias##_type>::ret
+
# define mlc_type_of(Namespace, Category, FromType, Alias) \
typename mlc_type_of_(Namespace, Category, FromType, Alias)
Index: mlc/types.hh
===================================================================
--- mlc/types.hh (revision 140)
+++ mlc/types.hh (working copy)
@@ -51,14 +51,14 @@
class no_type { private: no_type(); };
class default_type { private: default_type(); };
-
namespace internal
{
class not_found { private: not_found(); };
+ class not_ok { private: not_ok(); };
} // end of namespace mlc::internal
+
-
} // end of namespace mlc
Index: mlc/contract.hh
===================================================================
--- mlc/contract.hh (revision 140)
+++ mlc/contract.hh (working copy)
@@ -40,4 +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; \
+ 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; \
+} \
+struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
+
+
#endif // ! METALIC_CONTRACT_HH
Index: mlc/cmp.hh
===================================================================
--- mlc/cmp.hh (revision 140)
+++ mlc/cmp.hh (working copy)
@@ -79,6 +79,16 @@
{
};
+
+
+ template <typename T>
+ struct is_ok : public and_< and_< neq<T, internal::not_found>,
+ neq<T, internal::not_ok> >,
+ neq<T, undefined_type> >
+ {
+ };
+
+
} // end of namespace mlc
1
0
https://svn.lrde.epita.fr/svn/oln/prototypes/proto-1.0
ChangeLog | 11 +++++++++++
oln/core/apply.hh | 12 ++++++------
tests/core/tests/apply-binary | 16 +++++++---------
tests/core/tests/apply-unary | 18 +++++++++---------
4 files changed, 33 insertions(+), 24 deletions(-)
Index: olena/ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Fix oln::apply.
* oln/core/apply.hh (apply1_type::impl_run)
(apply2_type::impl_run): Catch up with the new image_operator
definition.
* tests/core/tests/apply-unary, tests/core/tests/apply-binary: Fix
tests.
Conform to Olena coding standard.
2005-04-13 Roland Levillain <roland(a)lrde.epita.fr>
Index: olena/tests/core/tests/apply-unary
--- olena/tests/core/tests/apply-unary (revision 139)
+++ olena/tests/core/tests/apply-unary (working copy)
@@ -50,8 +50,8 @@
{
oln::image2d<int> ima;
ima = oln::apply(f_mult_3(), ima1);
- if (oln::level::is_equal(ima, ima2))
- return false;
+ if (!oln::level::is_equal(ima, ima2))
+ return true;
}
// oln::apply, with a mlc::unary_function built using the helper
@@ -59,8 +59,8 @@
{
oln::image2d<int> ima;
ima = oln::apply(mlc::make_unary_fun(mult_3), ima1);
- if (oln::level::is_equal(ima, ima2))
- return false;
+ if (!oln::level::is_equal(ima, ima2))
+ return true;
}
// oln::apply, with a mlc::unary_function built using the helper
@@ -68,8 +68,8 @@
{
oln::image2d<int> ima;
ima = oln::apply (mlc::make_unary_fun(std::negate<int>()), ima1);
- if (oln::level::is_equal(ima, ima3))
- return false;
+ if (!oln::level::is_equal(ima, ima3))
+ return true;
}
// oln::apply, with a (more complex) mlc::unary_function built using
@@ -79,9 +79,9 @@
ima =
oln::apply (mlc::make_unary_fun(std::bind2nd(std::multiplies<int>(), 3)),
ima1);
- if (oln::level::is_equal(ima, ima2))
- return false;
+ if (!oln::level::is_equal(ima, ima2))
+ return true;
}
- return true;
+ return false;
}
Index: olena/tests/core/tests/apply-binary
--- olena/tests/core/tests/apply-binary (revision 139)
+++ olena/tests/core/tests/apply-binary (working copy)
@@ -50,19 +50,17 @@
// oln::apply, with a hand-made mlc::abstract::binary_function.
{
oln::image2d<int> ima;
-
ima = oln::apply(f_mult(), ima1, ima2);
- if (oln::level::is_equal(ima, ima3))
- return false;
+ if (!oln::level::is_equal(ima, ima3))
+ return true;
}
-
// oln::apply, with a mlc::binary_function built using the helper
// function mlc::make_binary_fun on a classic function.
{
oln::image2d<int> ima;
ima = oln::apply(mlc::make_binary_fun(mult), ima1, ima2);
- if (oln::level::is_equal(ima, ima3))
- return false;
+ if (!oln::level::is_equal(ima, ima3))
+ return true;
}
// oln::apply, with a mlc::binary_function built using the helper
@@ -71,9 +69,9 @@
oln::image2d<int> ima;
ima =
oln::apply (mlc::make_binary_fun(std::multiplies<int>()), ima1, ima2);
- if (oln::level::is_equal(ima, ima3))
- return false;
+ if (!oln::level::is_equal(ima, ima3))
+ return true;
}
- return true;
+ return false;
}
Index: olena/oln/core/apply.hh
--- olena/oln/core/apply.hh (revision 139)
+++ olena/oln/core/apply.hh (working copy)
@@ -78,11 +78,11 @@
void impl_run()
{
- output_type output(input_.size());
+ output_type tmp(input_.size());
oln_type_of(I, fwd_piter) p(input_.size());
for_all(p)
- output[p] = f_(input_[p]);
- this->image_ = output;
+ tmp[p] = f_(input_[p]);
+ this->output = tmp;
}
};
@@ -152,11 +152,11 @@
void impl_run()
{
- output_type output(input1_.size());
+ output_type tmp(input1_.size());
oln_type_of(I1, fwd_piter) p(input1_.size());
for_all(p)
- output[p] = f_(input1_[p], input2_[p]);
- this->image_ = output;
+ tmp[p] = f_(input1_[p], input2_[p]);
+ this->output = tmp;
}
};
1
0
https://svn.lrde.epita.fr/svn/oln/prototypes/proto-1.0/olena
ChangeLog | 13 +++++
oln/core/any/grid.hh | 71 +++++++++++++++++++++++++++
oln/core/any/point.hh | 12 ++++
oln/core/pw/apply.hh | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++
oln/makefile.src | 2
tests/pw/Makefile.am | 5 +
tests/pw/tests/apply | 18 +++++++
7 files changed, 247 insertions(+), 1 deletion(-)
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Add apply on point-wise functions.
* oln/core/pw/apply.hh: New file.
* tests/pw/Makefile.am: New file.
* tests/pw/tests/apply: New test.
* oln/core/any/grid.hh: New file.
* oln/core/any/point.hh: Conform to abstract::point constraints.
* oln/makefile.src (OLN_DEP): Add core/any/grid.hh and
core/pw/apply.hh.
2005-04-13 Roland Levillain <roland(a)lrde.epita.fr>
Property changes on: tests/pw
___________________________________________________________________
Name: svn:ignore
+ Makefile.in
Makefile
Index: tests/pw/tests/apply
--- tests/pw/tests/apply (revision 0)
+++ tests/pw/tests/apply (revision 0)
@@ -0,0 +1,18 @@
+ // -*- C++ -*-
+#include <iostream>
+
+#include <cmath>
+#include <oln/core/pw/apply.hh>
+#include <oln/core/pw/literal.hh>
+#include <oln/core/any/point.hh>
+
+using namespace oln;
+
+bool check()
+{
+ any_point p;
+ pw::literal<int> pv1 (p_lit(42));
+
+ int res = p_apply(mlc::make_unary_fun(std::negate<int>()), pv1)(p);
+ return !(res == -42);
+}
Index: tests/pw/Makefile.am
--- tests/pw/Makefile.am (revision 0)
+++ tests/pw/Makefile.am (revision 0)
@@ -0,0 +1,5 @@
+include ../check/Makefile.runtests
+include ../check/Makefile.check
+
+
+check-local: check-runtests
Index: oln/core/pw/apply.hh
--- oln/core/pw/apply.hh (revision 0)
+++ oln/core/pw/apply.hh (revision 0)
@@ -0,0 +1,127 @@
+// 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_APPLY_HH
+# define OLENA_CORE_PW_APPLY_HH
+
+# include <mlc/fun.hh>
+# include <oln/core/pw/abstract/function.hh>
+# include <oln/core/pw/macros.hh>
+
+
+namespace oln {
+
+ /*--------.
+ | Unary. |
+ `--------*/
+
+ // fwd decl
+ namespace pw {
+ template <typename F, typename T>
+ struct apply;
+ }
+
+ // super type
+ template <typename F, typename T>
+ struct set_super_type < pw::apply<F, T> >
+ {
+ typedef pw::abstract::function< pw::apply<F, T> > ret;
+ };
+
+ // props
+ template <typename F, typename T>
+ struct set_props < category::pw, pw::apply<F, T> >
+ {
+ typedef oln_pw_type_of(T, point) point_type;
+ typedef typename F::result_type value_type;
+ typedef oln_pw_type_of(T, size) size_type;
+ };
+
+
+ namespace pw {
+
+ template <typename F, typename T>
+ struct apply : public abstract::function < apply<F, T> >
+ {
+ typedef apply<F, T> 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::function<self_type> super_type;
+
+ F f_;
+ T input_;
+
+ apply(const mlc::abstract::unary_function<F>& f,
+ const abstract::function<T>& input) :
+ super_type(),
+ f_(f.exact()),
+ input_(input.exact())
+ {
+ }
+
+ const size_type& impl_size() const
+ {
+ return input_.size();
+ }
+
+ const value_type impl_get(const point_type& p) const
+ {
+ return f_(input_(p));
+ }
+
+ bool impl_hold(const point_type& p) const
+ {
+ return input_.hold(p);
+ }
+
+ bool impl_hold_large(const point_type& p) const
+ {
+ return input_.hold_large(p);
+ }
+ };
+
+
+ } // end of namespace oln::pw
+
+} // end of namespace oln
+
+
+/// apply function on pwf
+
+template <typename F, typename T>
+oln::pw::apply<F, T> p_apply (const mlc::abstract::unary_function<F>& f,
+ const oln::pw::abstract::function<T>& x)
+{
+ oln::pw::apply<F, T> tmp(f, x);
+ return tmp;
+}
+
+
+#endif // ! OLENA_CORE_PW_APPLY_HH
Index: oln/core/any/grid.hh
--- oln/core/any/grid.hh (revision 0)
+++ oln/core/any/grid.hh (revision 0)
@@ -0,0 +1,71 @@
+// 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_ANY_GRID_HH
+# define OLENA_CORE_ANY_GRID_HH
+
+# include <mlc/value.hh>
+# include <oln/core/abstract/grid.hh>
+
+
+namespace oln {
+
+ // fwd decls
+ struct any_grid;
+ struct any_point;
+ struct any_dpoint;
+ struct any_coord;
+
+ // super type
+ template <>
+ struct set_super_type < any_grid >
+ {
+ typedef abstract::grid< any_grid > ret;
+ };
+
+ // props
+ template <>
+ struct set_props < category::grid, any_grid >
+ {
+ typedef any_point point_type;
+ typedef any_dpoint dpoint_type;
+ typedef any_coord coord_type;
+ typedef mlc::value<unsigned,0> dimvalue_type;
+ };
+
+ struct any_grid : public abstract::grid< any_grid >
+ {
+ protected:
+ any_grid()
+ {}
+ };
+
+} // end of namespace oln
+
+
+
+#endif // ! OLENA_CORE_ANY_GRID_HH
Index: oln/core/any/point.hh
--- oln/core/any/point.hh (revision 138)
+++ oln/core/any/point.hh (working copy)
@@ -31,6 +31,7 @@
# include <iostream>
# include <oln/core/abstract/point.hh>
# include <oln/core/abstract/dpoint.hh>
+# include <oln/core/any/grid.hh>
namespace oln {
@@ -38,32 +39,41 @@
// fwd decls
struct any_point;
struct any_dpoint;
+ struct any_grid;
// props
template <>
struct set_props < category::point, any_point >
{
typedef any_dpoint dpoint_type;
+ typedef any_grid grid_type;
+ typedef any_coord coord_type;
};
struct any_point : public abstract::point < any_point >
{
-
bool impl_eq(const exact_type& rhs) const
{
return this->exact().impl_eq(rhs.exact());
}
+ const any_point impl_plus(const any_dpoint& rhs) const;
+
template <typename D>
const any_point impl_plus(const abstract::dpoint<D>& rhs) const
{
return any_point();
}
+ const any_dpoint impl_minus(const any_point& rhs) const;
+
template <typename P>
const any_dpoint impl_minus(const abstract::point<P>& rhs) const;
+ const any_coord impl_nth(unsigned i) const;
+
+ any_coord& impl_nth(unsigned i);
};
Index: oln/makefile.src
--- oln/makefile.src (revision 138)
+++ oln/makefile.src (working copy)
@@ -77,6 +77,7 @@
\
core/any/all.hh \
core/any/dpoint.hh \
+ core/any/grid.hh \
core/any/point.hh \
core/any/size.hh \
\
@@ -96,6 +97,7 @@
\
core/pw/abstract/binary_function.hh \
core/pw/abstract/function.hh \
+ core/pw/apply.hh \
core/pw/all.hh \
core/pw/cmp.hh \
core/pw/div.hh \
1
0
https://svn.lrde.epita.fr/svn/oln/prototypes/proto-1.0
ChangeLog | 28 ++++++++++++++++++++++++++++
oln/core/2d/array2d.hh | 2 --
oln/core/2d/dpoint2d.hh | 4 ++++
oln/core/2d/point2d.hh | 4 ++++
oln/core/2d/size2d.hh | 5 +++++
oln/core/abstract/image.hh | 1 -
oln/core/abstract/qiter.hh | 1 +
oln/core/any/dpoint.hh | 2 +-
oln/core/any/point.hh | 2 +-
oln/io/read_image.hh | 6 +++---
oln/io/read_image_2d_pnm.hh | 39 +++++++++++++--------------------------
oln/io/write_image.hh | 3 ++-
oln/io/write_image_2d_pnm.hh | 2 +-
oln/makefile.src | 1 -
14 files changed, 63 insertions(+), 37 deletions(-)
Index: olena/ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Repair the I/O routines.
* oln/io/read_image_2d_pnm.hh: Use output_ instead of image_.
(output): Remove method.
(read): Use the semantics of real image operator: return a
read_image_2d_raw instead of an image.
* oln/io/read_image.hh: Adjust.
* oln/io/write_image_2d_pnm.hh (impl_run): Rename as...
(run): ...this.
* oln/core/2d/array2d.hh: Do not set exact_ptr, since this class
not longer inherits from mlc::any__best_speed, but from mlc::any.
Please G++ and clean up.
* oln/core/abstract/qiter.hh (set_default_props): Add template <>
qualifier.
* oln/core/any/point.hh (operator<<): Do not name the second
argument.
* oln/core/any/dpoint.hh (operator<<): Likewise.
* oln/core/2d/point2d.hh (super_type): New typedef.
Explicitely call the super type ctor in ctors.
* oln/core/2d/dpoint2d.hh Likewise.
* oln/core/2d/size2d.hh: Likewise.
* oln/makefile.src (OLN_DEP): Remove core/2d/fwd_qiter2d.hh.
Index: olena/oln/core/abstract/image.hh
--- olena/oln/core/abstract/image.hh (revision 137)
+++ olena/oln/core/abstract/image.hh (working copy)
@@ -167,7 +167,6 @@
{
/// typedefs
-
typedef oln_type_of(E, size) size_type;
typedef oln_type_of(E, value) value_type;
typedef oln_type_of(E, point) point_type;
Index: olena/oln/core/abstract/qiter.hh
--- olena/oln/core/abstract/qiter.hh (revision 137)
+++ olena/oln/core/abstract/qiter.hh (working copy)
@@ -54,6 +54,7 @@
/// Default properties of any type in category::qiter.
+ template <>
struct set_default_props < category::qiter >
{
typedef mlc::undefined_type window_type;
Index: olena/oln/core/2d/dpoint2d.hh
--- olena/oln/core/2d/dpoint2d.hh (revision 137)
+++ olena/oln/core/2d/dpoint2d.hh (working copy)
@@ -47,17 +47,21 @@
struct dpoint2d : public abstract::dpoint < dpoint2d >
{
+ typedef abstract::dpoint< dpoint2d > super_type;
+
dpoint2d()
{
}
dpoint2d(coord_t row_, coord_t col_) :
+ super_type(),
row_(row_),
col_(col_)
{
}
dpoint2d(const dpoint2d& rhs) :
+ super_type(),
row_(rhs.row_),
col_(rhs.col_)
{
Index: olena/oln/core/2d/array2d.hh
--- olena/oln/core/2d/array2d.hh (revision 137)
+++ olena/oln/core/2d/array2d.hh (working copy)
@@ -79,7 +79,6 @@
array_(0),
size_()
{
- this->exact_ptr = this;
invariant_();
}
@@ -93,7 +92,6 @@
array_(0),
size_()
{
- this->exact_ptr = this;
this->resize(s);
}
Index: olena/oln/core/2d/point2d.hh
--- olena/oln/core/2d/point2d.hh (revision 137)
+++ olena/oln/core/2d/point2d.hh (working copy)
@@ -59,18 +59,22 @@
struct point2d : public abstract::point< point2d >
{
+ typedef abstract::point< point2d > super_type;
+
point2d()
{
// no initialization here so that row_ and col_ are 'undef'
}
point2d(coord_t row_, coord_t col_) :
+ super_type(),
row_(row_),
col_(col_)
{
}
point2d(const point2d& rhs) :
+ super_type(),
row_(rhs.row_),
col_(rhs.col_)
{
Index: olena/oln/core/2d/size2d.hh
--- olena/oln/core/2d/size2d.hh (revision 137)
+++ olena/oln/core/2d/size2d.hh (working copy)
@@ -46,24 +46,29 @@
struct size2d : public abstract::size< size2d >
{
+ typedef abstract::size< size2d > super_type;
+
size2d()
{
// no initialization here so that members are 'undef'
}
size2d(coord_t nrows_, coord_t ncols_) :
+ super_type(),
nrows_(nrows_),
ncols_(ncols_),
border_(2) // FIXME: 2!
{}
size2d(coord_t nrows_, coord_t ncols_, coord_t border_) :
+ super_type(),
nrows_(nrows_),
ncols_(ncols_),
border_(border_)
{}
size2d(const size2d& rhs) :
+ super_type(),
nrows_(rhs.nrows_),
ncols_(rhs.ncols_),
border_(rhs.border_)
Index: olena/oln/core/any/point.hh
--- olena/oln/core/any/point.hh (revision 137)
+++ olena/oln/core/any/point.hh (working copy)
@@ -81,7 +81,7 @@
} // end of namespace oln
-std::ostream& operator<<(std::ostream& ostr, const oln::any_point& p)
+std::ostream& operator<<(std::ostream& ostr, const oln::any_point&)
{
return ostr << "any";
}
Index: olena/oln/core/any/dpoint.hh
--- olena/oln/core/any/dpoint.hh (revision 137)
+++ olena/oln/core/any/dpoint.hh (working copy)
@@ -77,7 +77,7 @@
} // end of namespace oln
-std::ostream& operator<<(std::ostream& ostr, const oln::any_dpoint& dp)
+std::ostream& operator<<(std::ostream& ostr, const oln::any_dpoint&)
{
return ostr << "any";
}
Index: olena/oln/makefile.src
--- olena/oln/makefile.src (revision 137)
+++ olena/oln/makefile.src (working copy)
@@ -33,7 +33,6 @@
core/2d/dpoint2d.hh \
core/2d/fwd_niter2d.hh \
core/2d/fwd_piter2d.hh \
- core/2d/fwd_qiter2d.hh \
core/2d/image2d.hh \
core/2d/neighborhood2d.hh \
core/2d/point2d.hh \
Index: olena/oln/io/write_image_2d_pnm.hh
--- olena/oln/io/write_image_2d_pnm.hh (revision 137)
+++ olena/oln/io/write_image_2d_pnm.hh (working copy)
@@ -70,7 +70,7 @@
bin_v = 0;
}
- void impl_run()
+ void run()
{
point2d p;
value_type c;
Index: olena/oln/io/read_image_2d_pnm.hh
--- olena/oln/io/read_image_2d_pnm.hh (revision 137)
+++ olena/oln/io/read_image_2d_pnm.hh (working copy)
@@ -68,36 +68,25 @@
namespace impl {
template <typename I>
- struct read_image_2d_raw : public oln::abstract::image_operator<I, read_image_2d_raw<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::abstract::image_operator<I, read_image_2d_raw<I> >
+ super_type;
typedef oln_type_of(I, value) value_type;
- // commented below cause 'image_' is inherited
-// mlc::box<I> image_;
-
std::istream& istr_;
internal::pnm_info& info_;
char v;
int offset;
- read_image_2d_raw(I& image,
- std::istream &istr,
+ read_image_2d_raw(std::istream &istr,
internal::pnm_info &info) :
- super_type(image),
+ super_type(),
istr_(istr),
info_(info),
offset(-1)
{
- this->image_ = image;
- }
-
-
- read_image_2d_raw<I>& output(I& output)
- {
- output = this->image_;
- return *this;
}
template <typename E>
@@ -110,7 +99,8 @@
template <typename E>
void precond(ntg::vect_value<E>& c)
{
- precondition(ntg_max_val(ntg_comp_type(value_type)) <= info_.max_val);
+ precondition(ntg_max_val(ntg_comp_type(value_type)) <=
+ info_.max_val);
precondition(info_.type == "P6");
precondition(ntg_nb_comp(value_type) == 3);
}
@@ -134,7 +124,7 @@
read_value_type(c);
tmp[p] = c;
}
- this->image_ = tmp;
+ this->output = tmp;
}
//FIXME: Should work with builtin types.
@@ -175,16 +165,13 @@
}
};
-
-
template <typename I>
- void read(abstract::image2d<I>& ima,
- std::istream& istr,
- internal::pnm_info info)
+ read_image_2d_raw<I>
+ read(std::istream& istr, internal::pnm_info info)
{
- read_image_2d_raw<I> tmp(ima.exact(), istr, info);
+ read_image_2d_raw<I> tmp(istr, info);
tmp.run();
- tmp.output(ima.exact());
+ return tmp;
}
}
Index: olena/oln/io/write_image.hh
--- olena/oln/io/write_image.hh (revision 137)
+++ olena/oln/io/write_image.hh (working copy)
@@ -89,7 +89,8 @@
void write(const abstract::image<I>& ima, const std::string& name)
{
std::string ext;
- oln_type_of(I, value) t;
+ // FIXME: Unused?
+ // oln_type_of(I, value) t;
ext = internal::utils::extension(name);
Index: olena/oln/io/read_image.hh
--- olena/oln/io/read_image.hh (revision 137)
+++ olena/oln/io/read_image.hh (working copy)
@@ -76,17 +76,17 @@
if (internal::read_pnm_header(istr, info))
if ((ext == "ppm" || ext == "pnm") && info.type == "P6")
- impl::read(ima.exact(), istr, info);
+ 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")
- impl::read(ima.exact(), istr, info);
+ 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")
- impl::read(ima.exact(), istr, info);
+ 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;
1
0