Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
April 2005
- 8 participants
- 73 discussions
2005-04-11 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* oln/core/value_box.hh: Move to...
* oln/core/gen/internal/value_box.hh: ...this.
* oln/core/abstract/struct_elt.hh: Rename as...
* oln/core/abstract/window.hh: ...this.
* oln/core/abstract/op.hh: Remove.
* oln/core/abstract/image.hh: Update.
* oln/core/abstract/piter.hh: Likewise.
* oln/core/abstract/qiter.hh: Likewise.
* oln/core/abstract/image_operator.hh: Likewise.
* oln/basics.hh: Likewise.
* oln/makefile.src: Likewise.
* oln/morpho/dilation.hh: Likewise.
* oln/morpho/splitse.hh: Likewise.
* oln/morpho/stat.hh: Likewise.
* oln/morpho/erosion.hh: Likewise.
1
0
2005-04-11 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* mlc/makefile.src: Update.
1
0
11 Apr '05
2005-04-11 Thierry Geraud <theo@shuttle>
Update files with a 2nd version of property system.
* oln/convert/nbh_to_se.hh: Update.
* oln/basics2d.hh: Likewise.
* oln/core/value_box.hh: Likewise.
* oln/core/apply.hh: Likewise.
* oln/core/ch_value_type.hh: Likewise.
* oln/core/box.hh: Likewise.
* oln/core/pw/times.hh: Likewise.
* oln/core/pw/image.hh: Likewise.
* oln/core/pw/div.hh: Likewise.
* oln/core/pw/plus.hh: Likewise.
* oln/core/pw/macros.hh: Likewise.
* oln/core/pw/abstract/function.hh: Likewise.
* oln/core/pw/abstract/binary_function.hh: Likewise.
* oln/core/pw/minus.hh: Likewise.
* oln/core/pw/literal.hh: Likewise.
* oln/core/pw/logic.hh: Likewise.
* oln/core/pw/cmp.hh: Likewise.
* oln/core/any/point.hh: Likewise.
* oln/core/abstract/niter.hh: Likewise.
* oln/core/abstract/image.hh: Likewise.
* oln/core/abstract/piter.hh: Likewise.
* oln/core/abstract/image_like_.hh: Likewise.
* oln/core/abstract/point.hh: Likewise.
* oln/core/abstract/image_operator.hh: Likewise.
* oln/core/abstract/data_storage.hh: Likewise.
* oln/core/abstract/dpoint.hh: Likewise.
* oln/core/abstract/regular_niter.hh: Likewise.
* oln/core/abstract/images.hh: Likewise.
* oln/core/abstract/image_with_data.hh: Likewise.
* oln/core/abstract/neighborhood.hh: Likewise.
* oln/core/abstract/image_by_delegation.hh: Likewise.
* oln/core/abstract/image_with_extension.hh: Likewise.
* oln/core/abstract/size.hh: Likewise.
* oln/core/abstract/internal/image_impl.hh: Likewise.
* oln/core/1d/dpoint1d.hh: Likewise.
* oln/core/1d/array1d.hh: Likewise.
* oln/core/1d/image1d.hh: Likewise.
* oln/core/1d/fwd_piter1d.hh: Likewise.
* oln/core/1d/point1d.hh: Likewise.
* oln/core/1d/size1d.hh: Likewise.
* oln/core/2d/dpoint2d.hh: Likewise.
* oln/core/2d/array2d.hh: Likewise.
* oln/core/2d/image2d.hh: Likewise.
* oln/core/2d/fwd_regular_niter2d.hh: Likewise.
* oln/core/2d/bkd_piter2d.hh: Likewise.
* oln/core/2d/fwd_piter2d.hh: Likewise.
* oln/core/2d/neighborhood2d.hh: Likewise.
* oln/core/2d/window2d.hh: Likewise.
* oln/core/2d/point2d.hh: Likewise.
* oln/core/2d/size2d.hh: Likewise.
* oln/core/3d/array3d.hh: Likewise.
* oln/core/3d/image3d.hh: Likewise.
* oln/core/3d/fwd_piter3d.hh: Likewise.
* oln/core/3d/point3d.hh: Likewise.
* oln/core/gen/image_with_nbh.hh: Likewise.
* oln/basics.hh: Likewise.
* oln/morpho/reconstruction.hh: Likewise.
* oln/morpho/splitse.hh: Likewise.
* oln/morpho/stat.hh: Likewise.
* oln/arith/ops.hh: Likewise.
* oln/arith/min.hh: Likewise.
* oln/arith/max.hh: Likewise.
* oln/io/read_image.hh: Likewise.
* oln/core/abstract/witer.hh: Update and rename as...
* oln/core/abstract/qiter.hh: ...this.
* oln/core/abstract/entry.hh: Update and rename as...
* oln/core/abstract/image_entry.hh: ...this.
* oln/core/2d/fwd_witer2d.hh: Update and rename as...
* oln/core/2d/fwd_qiter2d.hh: ...this.
* oln/core/properties.hh: Update and rename as...
* oln/core/typedefs.hh: ...this.
1
0
2005-04-11 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* mlc/typedef.hh: New file.
* mlc/implies.hh: New file.
* mlc/to_string.hh: New file.
* mlc/bool.hh (Boolean_value): Remove.
(value): Add inheritance.
(b): Rename as...
(Boolean_value): ... this.
(mlc_bool, internal::helper_get_bool): New.
(T::b): Update to mlc_bool(T).
* mlc/properties.hh: Rewrite.
* mlc/if.hh (internal::if_): Rename as...
(internal::fun_if_): ...this.
(::b): Update with mlc_bool.
* mlc/types.hh (internal::not_found): New type.
* mlc/cmp.hh (eq, neq): Add inheritance.
(is_found, is_not_found): New.
1
0
proto-1.0 130: Better code factorization in morphological reconstruction
by Damien Thivolle 08 Apr '05
by Damien Thivolle 08 Apr '05
08 Apr '05
Index: ChangeLog
from Damien Thivolle <damien(a)lrde.epita.fr>
* oln/morpho/reconstruction.hh: Improve factorization.
reconstruction.hh | 367 ++++++++++++++++++++++++++++++------------------------
1 files changed, 207 insertions(+), 160 deletions(-)
Index: oln/morpho/reconstruction.hh
--- oln/morpho/reconstruction.hh (revision 129)
+++ oln/morpho/reconstruction.hh (working copy)
@@ -93,47 +93,44 @@
namespace impl {
- template <typename I, typename N>
+ template <typename I, typename N, typename E>
struct reconstruction_sequential_ret : public reconstruction_ret<I, N>
{
typedef reconstruction_ret<I, N> super_type;
+ void fwd_loop_body()
+ {
+ static_cast<E*>((void*)this)->fwd_loop_body_impl();
+ }
- virtual const oln_type_of(I, value) process(const I& work,
- const oln_type_of(I, point)& p,
- const oln_type_of(N, window)& se,
- const oln_type_of(I, value)& v)
+ void bkd_loop_body()
{
- std::cerr << "oops in " << __func__ << std::endl;
- return oln_type_of(I, value)();
+ static_cast<E*>((void*)this)->bkd_loop_body_impl();
}
+ void preconditions()
+ {
+ precondition(this->input1.size() == this->input2.size());
+ static_cast<E*>((void*)this)->preconditions_impl();
+ }
+
void impl_run()
{
mlc::eq<oln_type_of(I, size), oln_type_of(N, size)>::ensure();
- precondition(this->input1.size() == this->input2.size());
- precondition(level::is_greater_or_equal(this->input2, this->input1));
- // Conversion of neighborhood into a SE.
- oln_type_of(N, window) se_plus = get_plus_se_p(convert::nbh_to_cse(this->nbh));
- oln_type_of(N, window) se_minus = get_minus_se_p(convert::nbh_to_cse(this->nbh));
-
I output;
output = utils::clone(this->input1);
bool non_stability = true;
- oln_type_of(I, fwd_piter) fwd_p(output.size());
- oln_type_of(I, bkd_piter) bkd_p(output.size());
while (non_stability)
{
- I work;
- work = utils::clone(output);
+ work.unbox() = utils::clone(output);
for_all (fwd_p)
- work[fwd_p] = this->process(work, fwd_p, se_plus, this->input2[fwd_p].value());
+ fwd_loop_body();
for_all (bkd_p)
- work[bkd_p] = this->process(work, bkd_p, se_minus, this->input2[bkd_p].value());
+ bkd_loop_body();
non_stability = !(level::is_equal(work, output));
- output = work;
+ output = work.unbox();
}
this->output = output;
}
@@ -142,17 +139,27 @@
reconstruction_sequential_ret(const abstract::image<I>& input1, //marker
const abstract::image<I>& input2, //mask
const abstract::neighborhood<N>& nbh)
- : super_type(input1, input2, nbh)
- {}
+ : super_type(input1, input2, nbh),
+ fwd_p(input1.size()),
+ bkd_p(input1.size())
+ {
+ se_plus = get_plus_se_p(convert::nbh_to_cse(this->nbh));
+ se_minus = get_minus_se_p(convert::nbh_to_cse(this->nbh));
+ }
+ oln_type_of(N, window) se_plus;
+ oln_type_of(N, window) se_minus;
+ oln_type_of(I, fwd_piter) fwd_p;
+ oln_type_of(I, bkd_piter) bkd_p;
+ box<I> work;
};
-
template <typename I, typename N>
- struct reconstruction_dilation_ret : public reconstruction_sequential_ret<I, N>
+ struct reconstruction_dilation_ret :
+ public reconstruction_sequential_ret<I, N, reconstruction_dilation_ret<I, N> >
{
- typedef reconstruction_sequential_ret<I, N> super_type;
+ typedef reconstruction_sequential_ret<I, N, reconstruction_dilation_ret<I, N> > super_type;
reconstruction_dilation_ret(const abstract::image<I>& input1, //marker
const abstract::image<I>& input2, //mask
@@ -161,21 +168,35 @@
: super_type(input1, input2, nbh)
{}
- const oln_type_of(I, value) process(const I& work,
- const oln_type_of(I, point)& p,
- const oln_type_of(N, window)& se,
- const oln_type_of(I, value)& v)
+ void fwd_loop_body_impl()
{
- return ntg::min(morpho::max(work, p, se), v);
+ this->work[this->fwd_p] = ntg::min(morpho::max(this->work.unbox(),
+ this->fwd_p,
+ this->se_plus),
+ this->input2[this->fwd_p].value());
}
+ void bkd_loop_body_impl()
+ {
+ this->work[this->bkd_p] = ntg::min(morpho::max(this->work.unbox(),
+ this->bkd_p,
+ this->se_minus),
+ this->input2[this->bkd_p].value());
+ }
+
+ void preconditions_impl()
+ {
+ precondition(level::is_greater_or_equal(this->input2, this->input1));
+ }
+
};
template <typename I, typename N>
- struct reconstruction_erosion_ret : public reconstruction_sequential_ret<I, N>
+ struct reconstruction_erosion_ret :
+ public reconstruction_sequential_ret<I, N, reconstruction_erosion_ret<I, N> >
{
- typedef reconstruction_sequential_ret<I, N> super_type;
+ typedef reconstruction_sequential_ret<I, N, reconstruction_erosion_ret<I, N> > super_type;
reconstruction_erosion_ret(const abstract::image<I>& input1, //marker
const abstract::image<I>& input2, //mask
@@ -184,13 +205,27 @@
: super_type(input1, input2, nbh)
{}
- const oln_type_of(I, value) process(const I& work,
- const oln_type_of(I, point)& p,
- const oln_type_of(N, window)& se,
- const oln_type_of(I, value)& v) const
+ void fwd_loop_body_impl()
{
- return ntg::max(morpho::min(work, p, se), v);
+ this->work[this->fwd_p] = ntg::max(morpho::min(this->work.unbox(),
+ this->fwd_p,
+ this->se_plus),
+ this->input2[this->fwd_p].value());
}
+
+ void bkd_loop_body_impl()
+ {
+ this->work[this->bkd_p] = ntg::max(morpho::min(this->work.unbox(),
+ this->bkd_p,
+ this->se_minus),
+ this->input2[this->bkd_p].value());
+ }
+
+ void preconditions_impl()
+ {
+ precondition(level::is_greater_or_equal(this->input1, this->input2));
+ }
+
};
}
@@ -224,93 +259,113 @@
namespace impl {
- template <typename I, typename N>
+ template <typename I, typename N, typename E>
struct reconstruction_hybrid_ret : public reconstruction_ret<I, N>
{
typedef reconstruction_ret<I, N> super_type;
- reconstruction_hybrid_ret(const abstract::image<I>& input1, //marker
- const abstract::image<I>& input2, //mask
- const abstract::neighborhood<N>& nbh)
+ bool exist_init()
+ {
+ typedef oln_type_of(N, window) se_type;
+ oln_type_of(se_type, fwd_witer) 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;
+ }
- : super_type(input1, input2, nbh)
- {}
+ void fwd_loop_body()
+ {
+ static_cast<E*>((void*)this)->fwd_loop_body_impl();
+ }
- virtual const oln_type_of(I, value) process(const I& work,
- const oln_type_of(I, point)& p,
- const oln_type_of(N, window)& se,
- const oln_type_of(I, value)& v) const
+ void bkd_loop_body()
{
- std::cerr << "oops in " << __func__ << std::endl;
- return oln_type_of(I, value)();
+ static_cast<E*>((void*)this)->bkd_loop_body_impl();
}
- virtual void loop_body(const oln_type_of(I, point)& p,
- const oln_type_of(I, point)& q,
- oln_type_of(I, concrete)& output,
- std::queue<oln_type_of(I, point) >& fifo)
+ void fifo_loop_body()
{
- std::cerr << "oops in " << __func__ << std::endl;
+ static_cast<E*>((void*)this)->fifo_loop_body_impl();
}
- virtual bool exist_init(const oln_type_of(I, point)& p,
- const oln_type_of(I, concrete)& output,
- const oln_type_of(N, window)& se) const
+ void preconditions()
{
- std::cerr << "oops in " << __func__ << std::endl;
- return true;
+ precondition(this->input1.size() == this->input2.size());
+ static_cast<E*>((void*)this)->preconditions_impl();
}
-
void impl_run()
{
mlc::eq<oln_type_of(I, size), oln_type_of(N, size)>::ensure();
- precondition(this->input1.size() == this->input2.size());
- precondition(level::is_greater_or_equal(this->input2, this->input1));
+ preconditions();
- oln_type_of(I, concrete) output;
- output = utils::clone(this->input1);
- {
- oln_type_of(N, window) se_plus = get_plus_se_p(convert::nbh_to_cse(this->nbh));
- oln_type_of(N, window) se_minus = get_minus_se_p(convert::nbh_to_cse(this->nbh));
- oln_type_of(I, fwd_piter) fwd_p(output.size());
- oln_type_of(I, fwd_piter) bkd_p(output.size());
+ this->output.unbox() = utils::clone(this->input1);
- for_all (fwd_p)
- output[fwd_p] = this->process(output, fwd_p, se_plus, this->input2[fwd_p].value());
+ std::cout << "for_all (fwd_p)" << std::endl;
+ for_all (fwd_p)
+ fwd_loop_body();
- std::queue<oln_type_of(I, point) > fifo;
- for_all (bkd_p)
- {
- output[bkd_p] = this->process(output, bkd_p, se_minus, this->input2[bkd_p].value());
- if (this->exist_init((oln_type_of(I, point))bkd_p, output, se_minus))
- fifo.push(bkd_p);
- }
+ std::cout << "for_all (bkd_p)" << std::endl;
+ for_all (bkd_p)
+ {
+ bkd_loop_body();
+ if (exist_init())
+ fifo.push(bkd_p);
+ }
// Propagation Step
- while (!fifo.empty())
- {
- oln_type_of(I, point) 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_witer) dp(w);
+ while (!fifo.empty())
+ {
+ 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_witer) dp(w);
- for_all (dp)
- {
- oln_type_of(I, point) q = (oln_type_of(window_type, dpoint))dp + p;
- this->loop_body(p, q, output, fifo);
- }
- }
- }
- this->output = output;
+ for_all (dp)
+ {
+ q = (oln_type_of(window_type, dpoint))dp + p;
+ if (this->output.hold(q))
+ fifo_loop_body();
+ }
+ }
}
+
+ protected:
+
+ reconstruction_hybrid_ret(const abstract::image<I>& input1, //marker
+ const abstract::image<I>& input2, //mask
+ const abstract::neighborhood<N>& nbh)
+
+ : super_type(input1, input2, nbh),
+ fwd_p(input1.size()),
+ bkd_p(input1.size())
+ {
+ se_plus = get_plus_se_p(convert::nbh_to_cse(this->nbh));
+ se_minus = get_minus_se_p(convert::nbh_to_cse(this->nbh));
+ }
+
+ oln_type_of(N, window) se_plus;
+ oln_type_of(N, window) se_minus;
+ oln_type_of(I, fwd_piter) fwd_p;
+ oln_type_of(I, bkd_piter) bkd_p;
+ oln_type_of(I, point) p;
+ oln_type_of(I, point) q;
+ std::queue<oln_type_of(I, point) > fifo;
+
+
};
template <typename I, typename N>
- struct reconstruction_dilation_ret : public reconstruction_hybrid_ret<I, N>
+ struct reconstruction_dilation_ret :
+ public reconstruction_hybrid_ret<I, N, reconstruction_dilation_ret<I, N> >
{
- typedef reconstruction_hybrid_ret<I, N> super_type;
+ typedef reconstruction_hybrid_ret<I, N, reconstruction_dilation_ret<I, N> > super_type;
reconstruction_dilation_ret(const abstract::image<I>& input1, //marker
const abstract::image<I>& input2, //mask
@@ -319,47 +374,43 @@
: super_type(input1, input2, nbh)
{}
- const oln_type_of(I, value) process(const I& work,
- const oln_type_of(I, point)& p,
- const oln_type_of(N, window)& se,
- const oln_type_of(I, value)& v) const
+ void fwd_loop_body_impl()
{
- return ntg::min(morpho::max(work, p, se), v);
+ this->output[this->fwd_p] = ntg::min(morpho::max(this->output.unbox(),
+ this->fwd_p,
+ this->se_plus),
+ this->input2[this->fwd_p].value());
}
- virtual void loop_body(const oln_type_of(I, point)& p,
- const oln_type_of(I, point)& q,
- oln_type_of(I, concrete)& output,
- std::queue<oln_type_of(I, point) >& fifo)
+ void bkd_loop_body_impl()
{
- if (output.hold(q))
+ this->output[this->bkd_p] = ntg::min(morpho::max(this->output.unbox(),
+ this->bkd_p,
+ this->se_minus),
+ this->input2[this->bkd_p].value());
+ }
+
+ void fifo_loop_body_impl()
+ {
+ if ((this->output[this->q] < this->output[this->p]) &&
+ (this->input2[this->q] != this->output[this->q]))
{
- if ((output[q] < output[p]) &&
- (this->input2[q] != output[q]))
- {
- output[q] = ntg::min(output[p].value(),
- this->input2[q].value());
- fifo.push(q);
- }
+ this->output[this->q] = ntg::min(this->output[this->p].value(),
+ this->input2[this->q].value());
+ this->fifo.push(this->q);
}
+ }
+ bool exist_init_impl()
+ {
+ return this->output.hold(this->q) &&
+ (this->output[this->q] < this->output[this->bkd_p]) &&
+ (this->output[this->q] < this->input2[this->q]);
}
-
- virtual bool exist_init(const oln_type_of(I, point)& p,
- const oln_type_of(I, concrete)& marker,
- const oln_type_of(N, window)& se) const
+ void preconditions_impl()
{
- typedef oln_type_of(N, window) se_type;
- oln_type_of(se_type, fwd_witer) dp(se);
- for_all (dp)
- {
- oln_type_of(I, point) q = (oln_type_of(se_type, dpoint))dp + p;
- if (marker.hold(q) && (marker[q] < marker[p]) &&
- (marker[q] < this->input2[q]))
- return true;
- }
- return false;
+ precondition(level::is_greater_or_equal(this->input2, this->input1));
}
};
@@ -367,9 +418,10 @@
template <typename I, typename N>
- struct reconstruction_erosion_ret : public reconstruction_hybrid_ret<I, N>
+ struct reconstruction_erosion_ret :
+ public reconstruction_hybrid_ret<I, N, reconstruction_erosion_ret<I, N> >
{
- typedef reconstruction_hybrid_ret<I, N> super_type;
+ typedef reconstruction_hybrid_ret<I, N, reconstruction_erosion_ret<I, N> > super_type;
reconstruction_erosion_ret(const abstract::image<I>& input1, //marker
const abstract::image<I>& input2, //mask
@@ -378,52 +430,47 @@
: super_type(input1, input2, nbh)
{}
- const oln_type_of(I, value) process(const I& work,
- const oln_type_of(I, point)& p,
- const oln_type_of(N, window)& se,
- const oln_type_of(I, value)& v) const
+ void fwd_loop_body_impl()
{
- return ntg::max(morpho::min(work, p, se), v);
+ this->output[this->fwd_p] = ntg::max(morpho::min(this->output.unbox(),
+ this->fwd_p,
+ this->se_plus),
+ this->input2[this->fwd_p].value());
}
- virtual void loop_body(const oln_type_of(I, point)& p,
- const oln_type_of(I, point)& q,
- oln_type_of(I, concrete)& output,
- std::queue<oln_type_of(I, point) >& fifo)
+ void bkd_loop_body_impl()
{
- if (output.hold(q))
+ this->output[this->bkd_p] = ntg::max(morpho::min(this->output.unbox(),
+ this->bkd_p,
+ this->se_minus),
+ this->input2[this->bkd_p].value());
+ }
+
+ void fifo_loop_body_impl()
+ {
+ if ((this->output[this->q] > this->output[this->p]) &&
+ (this->input2[this->q] != this->output[this->q]))
{
- if ((output[q] > output[p]) &&
- (this->input2[q] != output[q]))
- {
- output[q] = ntg::max(output[p].value(),
- this->input2[q].value());
- fifo.push(q);
- }
+ this->output[this->q] = ntg::max(this->output[this->p].value(),
+ this->input2[this->q].value());
+ this->fifo.push(this->q);
}
}
+ bool exist_init_impl()
+ {
+ return this->output.hold(this->q) &&
+ (this->output[this->q] > this->output[this->bkd_p]) &&
+ (this->output[this->q] > this->input2[this->q]);
+ }
- virtual bool exist_init(const oln_type_of(I, point)& p,
- const oln_type_of(I, concrete)& marker,
- const oln_type_of(N, window)& se) const
+ void preconditions_impl()
{
- typedef oln_type_of(N, window) se_type;
- oln_type_of(se_type, fwd_witer) dp(se);
- for_all (dp)
- {
- oln_type_of(I, point) q = (oln_type_of(se_type, dpoint))dp + p;
- if (marker.hold(q) && (marker[q] > marker[p]) &&
- (marker[q] > this->input2[q]))
- return true;
- }
- return false;
+ precondition(level::is_greater_or_equal(this->input1, this->input2));
}
};
-
-
}
template<class I, class N>
1
0
2005-04-08 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* oln/core/pw/logic.hh: Fix include.
* oln/core/pw/cmp.hh: Cosmetic change.
* oln/utils/md5.hh: Conform to image_valuedness.
* oln/utils/md5.hxx: Likewise.
* oln/morpho/reconstruction.hh: Likewise.
* oln/arith/min.hh: Likewise.
* oln/arith/max.hh: Likewise.
Index: oln/core/pw/logic.hh
===================================================================
--- oln/core/pw/logic.hh (revision 128)
+++ oln/core/pw/logic.hh (working copy)
@@ -30,6 +30,7 @@
# include <oln/core/abstract/image_typeness.hh>
# include <oln/core/pw/abstract/function.hh>
+# include <oln/core/pw/cmp.hh>
namespace oln {
Index: oln/core/pw/cmp.hh
===================================================================
--- oln/core/pw/cmp.hh (revision 128)
+++ oln/core/pw/cmp.hh (working copy)
@@ -129,12 +129,12 @@
# define oln_pw_decl_cmp_op(NAME, SYMBOL) \
template <typename L, typename R> \
-oln::pw::cmp<L, R, oln::pw::internal::NAME> \
+oln::pw::cmp<L, R, oln::pw::internal:: NAME > \
operator SYMBOL (const oln::pw::abstract::function<L>& lhs, \
const oln::pw::abstract::function<R>& rhs) \
{ \
precondition(lhs.size() == rhs.size()); \
- oln::pw::cmp<L, R, oln::pw::internal::NAME> tmp(lhs, rhs); \
+ oln::pw::cmp<L, R, oln::pw::internal:: NAME > tmp(lhs, rhs); \
return tmp; \
}
Index: oln/utils/md5.hh
===================================================================
--- oln/utils/md5.hh (revision 128)
+++ oln/utils/md5.hh (working copy)
@@ -31,8 +31,7 @@
# include <ntg/all.hh>
# include <vector>
-# include <oln/core/abstract/image_vectorialness.hh>
-# include <oln/core/properties.hh>
+# include <oln/core/abstract/images.hh>
# include <oln/core/abstract/piter.hh>
# include <oln/utils/key.hh>
@@ -218,11 +217,9 @@
** \param I Exact type of the image.
**
** \arg im Image to process.
- **
- ** Non vectorial image version.
*/
template <class I>
- key md5(const oln::abstract::non_vectorial_image<I> &im);
+ key md5(const oln::abstract::image<I> &im);
/*!
** \brief Compute The Md5 value of an image.
@@ -231,10 +228,10 @@
**
** \arg im Image to process.
**
- ** Vectorial image version.
+ ** For vector-valued images.
*/
template <class I>
- key md5(const oln::abstract::vectorial_image<I> &im);
+ key md5(const oln::abstract::vector_valued_image<I> &im);
} // !utils
} // !oln
Index: oln/utils/md5.hxx
===================================================================
--- oln/utils/md5.hxx (revision 128)
+++ oln/utils/md5.hxx (working copy)
@@ -286,7 +286,7 @@
// md5 implementation.
template <class I>
inline
-key md5(const oln::abstract::non_vectorial_image<I> &im)
+key md5(const oln::abstract::image<I> &im)
{
buffer b;
oln_type_of(I, fwd_piter) p(im.size());
@@ -303,7 +303,7 @@
// md5 implementation.
template <class I>
inline
-key md5(const oln::abstract::vectorial_image<I> &im)
+key md5(const oln::abstract::vector_valued_image<I> &im)
{
oln_type_of(I, fwd_piter) p(im.size());
buffer b;
Index: oln/morpho/reconstruction.hh
===================================================================
--- oln/morpho/reconstruction.hh (revision 128)
+++ oln/morpho/reconstruction.hh (working copy)
@@ -80,8 +80,8 @@
const N nbh;
- reconstruction_ret(const abstract::non_vectorial_image<I>& input1,
- const abstract::non_vectorial_image<I>& input2,
+ reconstruction_ret(const abstract::image<I>& input1,
+ const abstract::image<I>& input2,
const abstract::neighborhood<N>& nbh) :
super_type(input1.exact(), input2.exact()),
nbh(nbh.exact())
@@ -139,8 +139,8 @@
}
protected:
- reconstruction_sequential_ret(const abstract::non_vectorial_image<I>& input1, //marker
- const abstract::non_vectorial_image<I>& input2, //mask
+ reconstruction_sequential_ret(const abstract::image<I>& input1, //marker
+ const abstract::image<I>& input2, //mask
const abstract::neighborhood<N>& nbh)
: super_type(input1, input2, nbh)
{}
@@ -154,8 +154,8 @@
{
typedef reconstruction_sequential_ret<I, N> super_type;
- reconstruction_dilation_ret(const abstract::non_vectorial_image<I>& input1, //marker
- const abstract::non_vectorial_image<I>& input2, //mask
+ reconstruction_dilation_ret(const abstract::image<I>& input1, //marker
+ const abstract::image<I>& input2, //mask
const abstract::neighborhood<N>& nbh)
: super_type(input1, input2, nbh)
@@ -177,8 +177,8 @@
{
typedef reconstruction_sequential_ret<I, N> super_type;
- reconstruction_erosion_ret(const abstract::non_vectorial_image<I>& input1, //marker
- const abstract::non_vectorial_image<I>& input2, //mask
+ reconstruction_erosion_ret(const abstract::image<I>& input1, //marker
+ const abstract::image<I>& input2, //mask
const abstract::neighborhood<N>& nbh)
: super_type(input1, input2, nbh)
@@ -197,8 +197,8 @@
template<class I, class N>
reconstruction_ret<I, N>
- geodesic_reconstruction_dilation(const abstract::non_vectorial_image<I> & marker,
- const abstract::non_vectorial_image<I> & mask,
+ geodesic_reconstruction_dilation(const abstract::image<I> & marker,
+ const abstract::image<I> & mask,
const abstract::neighborhood<N>& nbh)
{
impl::reconstruction_dilation_ret<I, N> tmp(marker, mask, nbh);
@@ -208,8 +208,8 @@
template<class I, class N>
reconstruction_ret<I, N>
- geodesic_reconstruction_erosion(const abstract::non_vectorial_image<I> & marker,
- const abstract::non_vectorial_image<I> & mask,
+ geodesic_reconstruction_erosion(const abstract::image<I> & marker,
+ const abstract::image<I> & mask,
const abstract::neighborhood<N>& nbh)
{
impl::reconstruction_erosion_ret<I, N> tmp(marker, mask, nbh);
@@ -229,8 +229,8 @@
{
typedef reconstruction_ret<I, N> super_type;
- reconstruction_hybrid_ret(const abstract::non_vectorial_image<I>& input1, //marker
- const abstract::non_vectorial_image<I>& input2, //mask
+ reconstruction_hybrid_ret(const abstract::image<I>& input1, //marker
+ const abstract::image<I>& input2, //mask
const abstract::neighborhood<N>& nbh)
: super_type(input1, input2, nbh)
@@ -312,8 +312,8 @@
{
typedef reconstruction_hybrid_ret<I, N> super_type;
- reconstruction_dilation_ret(const abstract::non_vectorial_image<I>& input1, //marker
- const abstract::non_vectorial_image<I>& input2, //mask
+ reconstruction_dilation_ret(const abstract::image<I>& input1, //marker
+ const abstract::image<I>& input2, //mask
const abstract::neighborhood<N>& nbh)
: super_type(input1, input2, nbh)
@@ -371,8 +371,8 @@
{
typedef reconstruction_hybrid_ret<I, N> super_type;
- reconstruction_erosion_ret(const abstract::non_vectorial_image<I>& input1, //marker
- const abstract::non_vectorial_image<I>& input2, //mask
+ reconstruction_erosion_ret(const abstract::image<I>& input1, //marker
+ const abstract::image<I>& input2, //mask
const abstract::neighborhood<N>& nbh)
: super_type(input1, input2, nbh)
@@ -428,8 +428,8 @@
template<class I, class N>
reconstruction_ret<I, N>
- geodesic_reconstruction_dilation(const abstract::non_vectorial_image<I> & marker,
- const abstract::non_vectorial_image<I> & mask,
+ geodesic_reconstruction_dilation(const abstract::image<I> & marker,
+ const abstract::image<I> & mask,
const abstract::neighborhood<N>& nbh)
{
impl::reconstruction_dilation_ret<I, N> tmp(marker, mask, nbh);
@@ -439,8 +439,8 @@
template<class I, class N>
reconstruction_ret<I, N>
- geodesic_reconstruction_erosion(const abstract::non_vectorial_image<I> & marker,
- const abstract::non_vectorial_image<I> & mask,
+ geodesic_reconstruction_erosion(const abstract::image<I> & marker,
+ const abstract::image<I> & mask,
const abstract::neighborhood<N>& nbh)
{
impl::reconstruction_erosion_ret<I, N> tmp(marker, mask, nbh);
Index: oln/arith/min.hh
===================================================================
--- oln/arith/min.hh (revision 128)
+++ oln/arith/min.hh (working copy)
@@ -66,8 +66,8 @@
{
typedef abstract::image_binary_operator<I, I, I, min_type<I> > super_type;
- min_type(const abstract::non_vectorial_image<I>& input1,
- const abstract::non_vectorial_image<I>& input2) :
+ min_type(const abstract::image<I>& input1,
+ const abstract::image<I>& input2) :
super_type(input1.exact(), input2.exact())
{}
@@ -87,11 +87,9 @@
}
- // FIXME: replace non_vectorial_image by scalar_image
- // FIXME: cause arithmetics is not defined for Booleans and labels...
template <typename I>
- impl::min_type<I> min(const abstract::non_vectorial_image<I>& input1,
- const abstract::non_vectorial_image<I>& input2)
+ impl::min_type<I> min(const abstract::image<I>& input1,
+ const abstract::image<I>& input2)
{
impl::min_type<I> tmp(input1, input2);
tmp.run();
Index: oln/arith/max.hh
===================================================================
--- oln/arith/max.hh (revision 128)
+++ oln/arith/max.hh (working copy)
@@ -66,8 +66,8 @@
{
typedef abstract::image_binary_operator<I, I, I, max_type<I> > super_type;
- max_type(const abstract::non_vectorial_image<I>& input1,
- const abstract::non_vectorial_image<I>& input2) :
+ max_type(const abstract::image<I>& input1,
+ const abstract::image<I>& input2) :
super_type(input1.exact(), input2.exact())
{}
@@ -88,8 +88,8 @@
}
template <typename I>
- impl::max_type<I> max(const abstract::non_vectorial_image<I>& input1,
- const abstract::non_vectorial_image<I>& input2)
+ impl::max_type<I> max(const abstract::image<I>& input1,
+ const abstract::image<I>& input2)
{
impl::max_type<I> tmp(input1, input2);
tmp.run();
1
0
08 Apr '05
2005-04-08 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* oln/core/pw/logic.hh: New file.
* oln/core/abstract/image_valuedness.hh: New file.
* oln/core/abstract/image_vectorialness.hh: Remove.
* oln/core/abstract/image_typeness.hh: New file.
* oln/arith/logic.hh: New file.
* oln/core/pw/image.hh (image_vectorialness_type): Remove.
(for_all_p): Update.
* oln/core/pw/macros.hh (oln_pw_cmp_operator): New macro.
(oln_pw_cmp_operators): New macro.
* oln/core/pw/abstract/function.hh (operator!): New method.
* oln/core/pw/all.hh (oln/core/pw/logic.hh): New include.
* oln/core/pw/minus.hh: Cosmetic change.
* oln/core/pw/cmp.hh: Derive from pw::abstract::binary_function.
* oln/core/pw/logic.hh: New file.
* oln/core/properties.hh (image_typeness_type): New target.
(image_valuedness_type): Likewise.
(dummy_type): New target for temporary dummy tests.
* oln/core/abstract/image_constness.hh: Fix include.
* oln/core/abstract/image_neighbness.hh: Likewise.
* oln/core/abstract/image.hh (image_vectorialness_type): Remove.
* oln/core/abstract/image_operator.hh (abstract::image_operator):
New props and set_type_of for temporary dummy tests.
* oln/core/abstract/entry.hh (typeness::inheritance_switch): New
inheritance.
(valuedness::inheritance_switch): Likewise.
* oln/core/abstract/images.hh: Update.
* oln/core/abstract/image_with_data.hh: Cosmetic change.
* oln/core/1d/image1d.hh (image_vectorialness_type): Remove.
* oln/core/2d/image2d.hh: Likewise.
* oln/core/3d/image3d.hh: Likewise.
* oln/makefile.src: Update.
* oln/morpho/stat.hh (min, max): Change sig.
* oln/morpho/erosion.hh (morpho::impl::generic_erosion): Add
code for temporary dummy tests.
* oln/arith/ops.hh (operator+): Add erroneous overloading.
Index: oln/core/pw/image.hh
===================================================================
--- oln/core/pw/image.hh (revision 125)
+++ oln/core/pw/image.hh (working copy)
@@ -31,6 +31,7 @@
# include <mlc/any.hh>
# include <mlc/cmp.hh>
# include <oln/core/box.hh>
+# include <oln/core/abstract/image_typeness.hh>
# include <oln/core/abstract/entry.hh>
# include <oln/core/pw/abstract/function.hh>
@@ -130,7 +131,6 @@
// FIXME: AWFUL we do not know if it is 2d...
typedef is_a<abstract::image2d> image_dimension_type;
- typedef vectorialness_from_valuetype(value_type) image_vectorialness_type;
typedef fwd_piter2d piter_type;
typedef fwd_piter2d fwd_piter_type;
@@ -199,7 +199,7 @@
};
- /// Routine
+ /// Routine for_all_p.
template <typename F>
image_from_pw<F> for_all_p(const pw::abstract::function<F>& fun)
@@ -209,6 +209,16 @@
}
+ // FIXME: below, produce an error instead of correcting the client code (?)
+
+ /// Specialization of for_all_p (so that "for_all_p(p_value(ima)) == ima").
+
+ template <typename I>
+ const I& for_all_p(const pw::image<I>& pv)
+ {
+ return pv.ima.unbox();
+ }
+
/// Specialization of p_value (so that "p_value(for_all_p(fun)) == fun").
template <typename F>
@@ -220,13 +230,13 @@
+
+
/// Routine check.
- // FIXME: this should be an algorithm (pred = binary_image)
template <typename I>
- bool check(const abstract::image<I>& pred)
+ bool check(const abstract::binary_image<I>& pred)
{
- // FIXME: input should be binary
oln_type_of(I, fwd_piter) p(pred.size());
for_all (p)
if (! pred[p])
@@ -234,8 +244,6 @@
return true;
}
-
-
namespace pw {
/// Routine oln::pw::check.
@@ -243,13 +251,33 @@
template <typename F>
bool check(const pw::abstract::function<F>& pred)
{
- mlc::eq< oln_pw_value_type(F), bool >::ensure();
+ mlc::eq< oln_typeness_of(oln_pw_value_type(F)), typeness::binary_tag >::ensure();
return oln::check(for_all_p(pred));
}
} // end of namespace oln::pw
+
+
+ /// Specialization of for_all_p that gives a compile-time error.
+
+ template <typename I>
+ void for_all_p(const abstract::image<I>&)
+ {
+ struct OLENA_ERROR__arg_of__for_all_p__should_not_be_an_image();
+ }
+
+ /// Specialization of for_all_p that gives a compile-time error.
+
+ template <typename P>
+ void for_all_p(const abstract::point<P>&)
+ {
+ struct OLENA_ERROR__arg_of__for_all_p__should_not_be_a_point();
+ }
+
+
+
} // end of namespace oln
Index: oln/core/pw/macros.hh
===================================================================
--- oln/core/pw/macros.hh (revision 125)
+++ oln/core/pw/macros.hh (working copy)
@@ -35,18 +35,18 @@
# define oln_pw_size_type(F) typename oln::pw::traits<F>::size_type
-// FIXME: rename
+// FIXME: rename?
# define oln_pw_operator(NAME, SYMBOL, TYPE) \
template <typename L> \
oln::pw::NAME<L, oln::pw::literal<TYPE> > \
operator SYMBOL (const oln::pw::abstract::function<L>& lhs, \
- TYPE value) \
+ const TYPE& value) \
{ \
return lhs SYMBOL oln::pw::literal<TYPE>(value); \
} \
template <typename R> \
oln::pw::NAME<oln::pw::literal<TYPE>, R> \
-operator SYMBOL (TYPE value, \
+operator SYMBOL (const TYPE& value, \
const oln::pw::abstract::function<R>& rhs) \
{ \
return oln::pw::literal<TYPE>(value) SYMBOL rhs; \
@@ -54,4 +54,32 @@
+// FIXME: rename?
+# define oln_pw_cmp_operator(NAME, SYMBOL, TYPE) \
+template <typename L> \
+oln::pw::cmp<L, oln::pw::literal<TYPE>, oln::pw::internal::NAME> \
+operator SYMBOL (const oln::pw::abstract::function<L>& lhs, \
+ const TYPE& value) \
+{ \
+ return lhs SYMBOL oln::pw::literal<TYPE>(value); \
+} \
+template <typename R> \
+oln::pw::cmp<oln::pw::literal<TYPE>, R, oln::pw::internal::NAME> \
+operator SYMBOL (const TYPE& value, \
+ const oln::pw::abstract::function<R>& rhs) \
+{ \
+ return oln::pw::literal<TYPE>(value) SYMBOL rhs; \
+}
+
+
+// FIXME: rename?
+# define oln_pw_cmp_operators(TYPE) \
+oln_pw_cmp_operator(eq, ==, TYPE) \
+oln_pw_cmp_operator(neq, !=, TYPE) \
+oln_pw_cmp_operator(geq, >=, TYPE) \
+oln_pw_cmp_operator(leq, <=, TYPE) \
+oln_pw_cmp_operator(g, >, TYPE) \
+oln_pw_cmp_operator(l, <, TYPE)
+
+
#endif // ! OLENA_CORE_PW_MACROS_HH
Index: oln/core/pw/abstract/function.hh
===================================================================
--- oln/core/pw/abstract/function.hh (revision 125)
+++ oln/core/pw/abstract/function.hh (working copy)
@@ -47,9 +47,9 @@
}
template <typename L, typename R> struct minus;
template <typename T> struct literal;
+ template <typename F> struct not_;
-
template <typename E>
struct traits < abstract::function<E> >
{
@@ -87,7 +87,8 @@
return this->exact().impl_hold_large(p);
}
- minus< literal<value_type>, E> operator-() const;
+ minus<literal<value_type>, E> operator-() const;
+ not_<E> operator!() const;
protected:
function() {}
Index: oln/core/pw/all.hh
===================================================================
--- oln/core/pw/all.hh (revision 125)
+++ oln/core/pw/all.hh (working copy)
@@ -34,13 +34,14 @@
# include <oln/core/pw/literal.hh>
# include <oln/core/pw/cmp.hh>
+# include <oln/core/pw/logic.hh>
# include <oln/core/pw/plus.hh>
# include <oln/core/pw/minus.hh>
# include <oln/core/pw/times.hh>
# include <oln/core/pw/div.hh>
-// FIXME: not xor mod...
+// FIXME: xor mod...
#endif // ! OLENA_CORE_PW_ALL_HH
Index: oln/core/pw/minus.hh
===================================================================
--- oln/core/pw/minus.hh (revision 125)
+++ oln/core/pw/minus.hh (working copy)
@@ -77,12 +77,12 @@
};
- // FIXME: uncomment?
+ // impl of abstract::function<E>::operator-()
namespace abstract {
template <typename E>
- minus< literal<oln_pw_value_type(E)>, E>
+ minus<literal<oln_pw_value_type(E)>, E>
function<E>::operator-() const
{
typedef literal<oln_pw_value_type(E)> lit_type;
@@ -91,7 +91,7 @@
return tmp;
}
- }
+ } // end of namespace oln::pw::abstract
} // end of namespace oln::pw
Index: oln/core/pw/logic.hh
===================================================================
--- oln/core/pw/logic.hh (revision 0)
+++ oln/core/pw/logic.hh (revision 0)
@@ -0,0 +1,172 @@
+// 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_LOGIC_HH
+# define OLENA_CORE_PW_LOGIC_HH
+
+# include <oln/core/abstract/image_typeness.hh>
+# include <oln/core/pw/abstract/function.hh>
+
+
+namespace oln {
+
+
+ namespace pw { // means "point-wise"
+
+
+ // FIXME: move somewhere else
+ namespace internal
+ {
+ struct not_ {
+ template <typename T>
+ bool operator()(const T& rhs) const {
+ return !rhs;
+ }
+ };
+ struct and_ {
+ template <typename L, typename R>
+ bool operator()(const L& lhs, const R& rhs) const {
+ return lhs && rhs;
+ }
+ };
+ struct nand_ {
+ template <typename L, typename R>
+ bool operator()(const L& lhs, const R& rhs) const {
+ return !(lhs && rhs);
+ }
+ };
+ struct or_ {
+ template <typename L, typename R>
+ bool operator()(const L& lhs, const R& rhs) const {
+ return lhs || rhs;
+ }
+ };
+ struct nor_ {
+ template <typename L, typename R>
+ bool operator()(const L& lhs, const R& rhs) const {
+ return !(lhs || rhs);
+ }
+ };
+ struct xor_ {
+ template <typename L, typename R>
+ bool operator()(const L& lhs, const R& rhs) const {
+ return (lhs && !rhs) || (!lhs && rhs);
+ }
+ };
+ struct xnor_ {
+ template <typename L, typename R>
+ bool operator()(const L& lhs, const R& rhs) const {
+ return (lhs && rhs) || (!lhs && !rhs);
+ }
+ };
+ } // end of oln::pw::internal
+
+
+
+ // fwd decl
+ template <typename R> struct not_;
+
+ template <typename R>
+ struct traits < not_<R> >
+ {
+ typedef oln_pw_point_type(R) point_type;
+ typedef oln_pw_size_type(R) size_type;
+ typedef bool value_type;
+ };
+
+ template <typename R>
+ struct not_ : public abstract::function < not_<R> >
+ {
+ typedef not_<R> self_type;
+
+ typedef oln_pw_point_type(self_type) point_type;
+ typedef oln_pw_value_type(self_type) value_type;
+ typedef oln_pw_size_type(self_type) size_type;
+
+ R right;
+
+ not_(const abstract::function<R>& right) :
+ right(right.exact())
+ {
+ }
+
+ const bool impl_get(const point_type& p) const
+ {
+ return ! this->right(p);
+ }
+
+ const size_type& impl_size() const
+ {
+ return this->right.size();
+ }
+
+ bool impl_hold(const point_type& p) const
+ {
+ return this->right.hold(p);
+ }
+
+ bool impl_hold_large(const point_type& p) const
+ {
+ return this->right.hold_large(p);
+ }
+
+ };
+
+
+ // impl of abstract::function<E>::operator!()
+
+ namespace abstract {
+
+ template <typename E>
+ not_<E>
+ function<E>::operator!() const
+ {
+ mlc::eq< oln_typeness_of(oln_pw_value_type(E)), typeness::binary_tag >::ensure();
+ not_<E> tmp(this->exact());
+ return tmp;
+ }
+
+ } // end of namespace oln::pw::abstract
+
+
+ } // end of namespace oln::pw
+
+
+} // end of namespace oln
+
+
+
+/// Ops on pwf
+
+oln_pw_decl_cmp_op(and_, &&)
+oln_pw_decl_cmp_op(or_, ||)
+
+oln_pw_cmp_operator(and_, &&, bool)
+oln_pw_cmp_operator(or_, ||, bool)
+
+
+#endif // ! OLENA_CORE_PW_LOGIC_HH
Index: oln/core/pw/cmp.hh
===================================================================
--- oln/core/pw/cmp.hh (revision 125)
+++ oln/core/pw/cmp.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef OLENA_CORE_PW_CMP_HH
# define OLENA_CORE_PW_CMP_HH
-# include <oln/core/pw/abstract/function.hh>
+# include <oln/core/pw/abstract/binary_function.hh>
namespace oln {
@@ -76,59 +76,46 @@
return lhs < rhs;
}
};
- }
+ } // end of oln::pw::internal
+
// fwd decl
template <typename L, typename R, typename C> struct cmp;
template <typename L, typename R, typename C>
struct traits < cmp<L, R, C> >
{
- typedef oln_pw_point_type(L) point_type;
+ typedef abstract::binary_function<L, R, cmp<L, R, C> > super_type;
+ typedef typename traits<super_type>::point_type point_type;
+ typedef typename traits<super_type>::size_type size_type;
typedef bool value_type;
- typedef oln_pw_size_type(L) size_type;
};
+
template <typename L, typename R, typename C>
- struct cmp : public abstract::function < cmp<L, R, C> >
+ struct cmp : public abstract::binary_function < L, R, cmp<L, R, C> >
{
typedef cmp<L, R, C> self_type;
typedef oln_pw_point_type(self_type) point_type;
typedef oln_pw_size_type(self_type) size_type;
+ typedef oln_pw_value_type(self_type) value_type;
- L left;
- R right;
+ typedef abstract::binary_function < L, R, self_type > super_type;
cmp(const abstract::function<L>& left,
const abstract::function<R>& right) :
- left(left.exact()),
- right(right.exact())
+ super_type(left, right)
{
}
- const size_type& impl_size() const
- {
- return this->left.size();
- }
-
const bool impl_get(const point_type& p) const
{
static const C cmpfun = C();
return cmpfun(this->left(p), this->right(p));
}
- bool impl_hold(const point_type& p) const
- {
- return this->left.hold(p);
- }
-
- bool impl_hold_large(const point_type& p) const
- {
- return this->left.hold_large(p);
- }
-
};
} // end of namespace oln::pw
@@ -138,68 +125,30 @@
-/// Op+ on pwf
+/// Ops on pwf
-template <typename L, typename R>
-oln::pw::cmp<L, R, oln::pw::internal::eq>
-operator == (const oln::pw::abstract::function<L>& lhs,
- const oln::pw::abstract::function<R>& rhs)
-{
- precondition(lhs.size() == rhs.size());
- oln::pw::cmp<L, R, oln::pw::internal::eq> tmp(lhs, rhs);
- return tmp;
+# define oln_pw_decl_cmp_op(NAME, SYMBOL) \
+template <typename L, typename R> \
+oln::pw::cmp<L, R, oln::pw::internal::NAME> \
+operator SYMBOL (const oln::pw::abstract::function<L>& lhs, \
+ const oln::pw::abstract::function<R>& rhs) \
+{ \
+ precondition(lhs.size() == rhs.size()); \
+ oln::pw::cmp<L, R, oln::pw::internal::NAME> tmp(lhs, rhs); \
+ return tmp; \
}
-template <typename L, typename R>
-oln::pw::cmp<L, R, oln::pw::internal::neq>
-operator != (const oln::pw::abstract::function<L>& lhs,
- const oln::pw::abstract::function<R>& rhs)
-{
- precondition(lhs.size() == rhs.size());
- oln::pw::cmp<L, R, oln::pw::internal::neq> tmp(lhs, rhs);
- return tmp;
-}
+oln_pw_decl_cmp_op(eq, ==)
+oln_pw_decl_cmp_op(neq, !=)
+oln_pw_decl_cmp_op(geq, >=)
+oln_pw_decl_cmp_op(leq, <=)
+oln_pw_decl_cmp_op(g, >)
+oln_pw_decl_cmp_op(l, <)
-template <typename L, typename R>
-oln::pw::cmp<L, R, oln::pw::internal::geq>
-operator >= (const oln::pw::abstract::function<L>& lhs,
- const oln::pw::abstract::function<R>& rhs)
-{
- precondition(lhs.size() == rhs.size());
- oln::pw::cmp<L, R, oln::pw::internal::geq> tmp(lhs, rhs);
- return tmp;
-}
+oln_pw_cmp_operators(int)
+oln_pw_cmp_operators(float)
+oln_pw_cmp_operators(double)
-template <typename L, typename R>
-oln::pw::cmp<L, R, oln::pw::internal::leq>
-operator <= (const oln::pw::abstract::function<L>& lhs,
- const oln::pw::abstract::function<R>& rhs)
-{
- precondition(lhs.size() == rhs.size());
- oln::pw::cmp<L, R, oln::pw::internal::leq> tmp(lhs, rhs);
- return tmp;
-}
-template <typename L, typename R>
-oln::pw::cmp<L, R, oln::pw::internal::g>
-operator > (const oln::pw::abstract::function<L>& lhs,
- const oln::pw::abstract::function<R>& rhs)
-{
- precondition(lhs.size() == rhs.size());
- oln::pw::cmp<L, R, oln::pw::internal::g> tmp(lhs, rhs);
- return tmp;
-}
-template <typename L, typename R>
-oln::pw::cmp<L, R, oln::pw::internal::l>
-operator < (const oln::pw::abstract::function<L>& lhs,
- const oln::pw::abstract::function<R>& rhs)
-{
- precondition(lhs.size() == rhs.size());
- oln::pw::cmp<L, R, oln::pw::internal::l> tmp(lhs, rhs);
- return tmp;
-}
-
-
-
#endif // ! OLENA_CORE_PW_CMP_HH
Index: oln/core/properties.hh
===================================================================
--- oln/core/properties.hh (revision 125)
+++ oln/core/properties.hh (working copy)
@@ -75,8 +75,11 @@
struct image_neighbness_type;
struct image_constness_type;
struct image_dimension_type;
- struct image_vectorialness_type;
+ struct image_typeness_type;
+ struct image_valuedness_type;
// FIXME: ...
+
+ struct dummy_type; // FIXME: remove (test purpose!)
}
mlc_equip_namespace_for_properties();
Index: oln/core/abstract/image_constness.hh
===================================================================
--- oln/core/abstract/image_constness.hh (revision 125)
+++ oln/core/abstract/image_constness.hh (working copy)
@@ -28,7 +28,6 @@
#ifndef OLENA_CORE_ABSTRACT_IMAGE_CONSTNESS_HH
# define OLENA_CORE_ABSTRACT_IMAGE_CONSTNESS_HH
-# include <oln/core/abstract/internal/image_impl.hh>
# include <oln/core/abstract/image.hh>
/*! \namespace oln
Index: oln/core/abstract/image.hh
===================================================================
--- oln/core/abstract/image.hh (revision 125)
+++ oln/core/abstract/image.hh (working copy)
@@ -77,7 +77,6 @@
mlc_decl_prop_with_default(category::image, image_neighbness_type, is_a<abstract::image_without_nbh>);
mlc_decl_prop_with_default(category::image, image_constness_type, is_a<abstract::readonly_image>);
mlc_decl_prop(category::image, image_dimension_type);
- mlc_decl_prop(category::image, image_vectorialness_type);
//...
@@ -97,7 +96,6 @@
<< " image_constness_type = " << typeid(image_constness_type).name()
<< " image_dimension_type = " << typeid(image_dimension_type).name()
- << " image_vectorialness_type = " << typeid(image_vectorialness_type).name()
<< " image_neighbness_type = " << typeid(image_neighbness_type).name()
<< " }" << std::endl;
@@ -119,7 +117,6 @@
mlc_register_prop(category::image, image_constness_type);
mlc_register_prop(category::image, image_dimension_type);
- mlc_register_prop(category::image, image_vectorialness_type);
mlc_register_prop(category::image, image_neighbness_type);
Index: oln/core/abstract/image_vectorialness.hh
===================================================================
--- oln/core/abstract/image_vectorialness.hh (revision 125)
+++ oln/core/abstract/image_vectorialness.hh (working copy)
@@ -1,125 +0,0 @@
-// Copyright (C) 2005 EPITA Research and Development Laboratory
-//
-// This file is part of the Olena Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
-// MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#ifndef OLENA_CORE_ABSTRACT_IMAGE_VECTORIALNESS_HH
-# define OLENA_CORE_ABSTRACT_IMAGE_VECTORIALNESS_HH
-
-# include <mlc/switch.hh>
-# include <ntg/basics.hh>
-# include <oln/core/abstract/image.hh>
-
-
-/*! \namespace oln
-** \brief oln namespace.
-*/
-namespace oln {
-
- /*! \namespace oln::abstract
- ** \brief oln::abstract namespace.
- */
- namespace abstract {
-
- template <typename E>
- struct data_type_image : public virtual image<E>
- {
- protected:
- data_type_image() {}
- };
-
- template <typename E>
- struct vectorial_image : public data_type_image<E>
- {
- protected:
- vectorial_image() {}
- };
-
- template <typename E>
- struct non_vectorial_image : public data_type_image<E>
- {
- protected:
- non_vectorial_image() {}
- };
-
- template <typename E>
- struct decimal_image : public non_vectorial_image<E>
- {
- protected:
- decimal_image() {}
- };
-
- template <typename E>
- struct integer_image : public non_vectorial_image<E>
- {
- protected:
- integer_image() {}
- };
-
- template <typename E>
- struct binary_image : public non_vectorial_image<E>
- {
- protected:
- binary_image() {}
- };
-
-
- } // end of namespace oln::abstract
-
- template <typename T>
- struct vectorialness_from_valuetype
- {
- typedef typename mlc::bool_switch_<
-
- mlc::bool_case_<ntg_is_a(T, ntg::binary)::val,
- is_a<abstract::binary_image>,
-
- mlc::bool_case_<ntg_is_a(T, ntg::integer)::val,
- is_a<abstract::integer_image>,
-
- mlc::bool_case_<ntg_is_a(T, ntg::decimal)::val,
- is_a<abstract::decimal_image>,
-
- mlc::bool_case_<ntg_is_a(T, ntg::vectorial)::val,
- is_a<abstract::vectorial_image>,
-
- mlc::bool_case_<ntg_is_a(T, ntg::non_vectorial)::val,
- is_a<abstract::non_vectorial_image>,
-
- mlc::bool_case_<true,
- is_a<abstract::data_type_image> >
-
- > > > > > >::ret ret;
- };
-
- #define vectorialness_from_valuetype(T) \
- typename vectorialness_from_valuetype< T >::ret
- #define vectorialness_from_valuetype_(T) \
- vectorialness_from_valuetype< T >::ret
-
-} // end of namespace oln
-
-
-#endif // ! OLENA_CORE_ABSTRACT_IMAGE_VECTORIALNESS_HH
Index: oln/core/abstract/image_neighbness.hh
===================================================================
--- oln/core/abstract/image_neighbness.hh (revision 125)
+++ oln/core/abstract/image_neighbness.hh (working copy)
@@ -28,10 +28,6 @@
#ifndef OLENA_CORE_ABSTRACT_IMAGE_NEIGHBNESS_HH
# define OLENA_CORE_ABSTRACT_IMAGE_NEIGHBNESS_HH
-# include <mlc/bool.hh>
-
-# include <ntg/basics.hh>
-
# include <oln/core/abstract/image.hh>
/*! \namespace oln
Index: oln/core/abstract/image_operator.hh
===================================================================
--- oln/core/abstract/image_operator.hh (revision 125)
+++ oln/core/abstract/image_operator.hh (working copy)
@@ -56,6 +56,22 @@
struct set_super_type< abstract::image_binary_operator<O, I1, I2, E> > { typedef abstract::image_operator<O, E> ret; };
+ // FIXME: an extension of props; remove (test purpose!)
+ template <typename O, typename E>
+ struct set_props < category::image, abstract::image_operator<O, E> > : public props_of<category::image>
+ {
+ typedef float dummy_type;
+ };
+ template <typename O, typename E>
+ struct set_type_of < category::image,
+ abstract::image_operator<O, E>,
+ target::dummy_type >
+ {
+ typedef double ret;
+ };
+ // end of FIXME: remove (test purpose!)
+
+
namespace abstract {
Index: oln/core/abstract/entry.hh
===================================================================
--- oln/core/abstract/entry.hh (revision 125)
+++ oln/core/abstract/entry.hh (working copy)
@@ -28,13 +28,9 @@
#ifndef OLENA_CORE_ABSTRACT_ENTRY_HH
# define OLENA_CORE_ABSTRACT_ENTRY_HH
-# include <oln/core/abstract/image_constness.hh>
-# include <oln/core/abstract/image_dimension.hh>
-# include <oln/core/abstract/image_vectorialness.hh>
-# include <oln/core/abstract/image_neighbness.hh>
+# include <oln/core/abstract/images.hh>
-// FIXME: this file should move to oln/core/abstract/
namespace oln {
@@ -52,28 +48,17 @@
typedef category::image ret;
};
-
-
namespace abstract {
-// namespace internal {
-
-// template < typename isa, typename E >
-// struct inherits
-// {
-// typedef typename isa::template instantiated_with<E>::ret ret;
-// };
-
-// }
-
template <typename E>
struct image_entry :
// intrusive:
public oln_type_of_(E, image_constness) ::template instantiated_with<E>::ret,
public oln_type_of_(E, image_dimension) ::template instantiated_with<E>::ret,
public oln_type_of_(E, image_neighbness) ::template instantiated_with<E>::ret,
- public oln_type_of_(E, image_vectorialness) ::template instantiated_with<E>::ret
- // ...
+ // ...
+ public typeness::inheritance_switch<E>,
+ public valuedness::inheritance_switch<E>
{
protected:
image_entry() {}
Index: oln/core/abstract/images.hh
===================================================================
--- oln/core/abstract/images.hh (revision 125)
+++ oln/core/abstract/images.hh (working copy)
@@ -29,11 +29,19 @@
# define OLENA_CORE_ABSTRACT_IMAGES_HH
-# include <oln/core/abstract/internal/image_impl.hh>
+# include <oln/core/abstract/image.hh>
-
-# include <oln/core/abstract/image.hh>
+// hierarchies:
# include <oln/core/abstract/image_constness.hh>
+# include <oln/core/abstract/image_dimension.hh>
+# include <oln/core/abstract/image_neighbness.hh>
+# include <oln/core/abstract/image_typeness.hh>
+# include <oln/core/abstract/image_valuedness.hh>
+// hierarchy entry
+# include <oln/core/abstract/entry.hh>
+
+
+
#endif // ! OLENA_CORE_ABSTRACT_IMAGES_HH
Index: oln/core/abstract/image_with_data.hh
===================================================================
--- oln/core/abstract/image_with_data.hh (revision 125)
+++ oln/core/abstract/image_with_data.hh (working copy)
@@ -30,7 +30,6 @@
# include <mlc/tracked_ptr.hh>
-
# include <oln/core/abstract/entry.hh>
Index: oln/core/abstract/image_valuedness.hh
===================================================================
--- oln/core/abstract/image_valuedness.hh (revision 0)
+++ oln/core/abstract/image_valuedness.hh (revision 0)
@@ -0,0 +1,253 @@
+// Copyright (C) 2005 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLENA_CORE_ABSTRACT_IMAGE_VALUEDNESS_HH
+# define OLENA_CORE_ABSTRACT_IMAGE_VALUEDNESS_HH
+
+# include <ntg/decls.hh>
+# include <oln/core/abstract/image.hh>
+
+
+// image
+//
+// ^
+// |
+// -------------------------------------------------------------------------
+// | | | | |
+//
+// scalar_valued_image vector_valued_image label_valued_image data_valued_image ...
+
+
+
+
+// fwd decls
+namespace oln {
+ namespace abstract {
+ template <typename E> struct scalar_valued_image;
+ template <typename E> struct vector_valued_image;
+ template <typename E> struct label_valued_image;
+ template <typename E> struct data_valued_image;
+ }
+}
+namespace std {
+ template <class T, class A> class vector;
+ template <class T> class complex;
+}
+
+
+
+
+/*! \namespace oln
+** \brief oln namespace.
+*/
+namespace oln {
+
+
+ /*! \namespace oln::valuedness
+ ** \brief oln::valuedness namespace.
+ */
+ namespace valuedness {
+
+ enum {
+ scalar_tag = 1,
+ vector_tag = 2,
+ label_tag = 3,
+ data_tag = 4
+ };
+
+
+ template <typename T>
+ struct of
+ {
+ protected:
+
+ static T* makeT();
+ template <int tag> struct tag_is { char c[tag]; };
+
+ // scalar
+
+ template <typename E>
+ static tag_is<scalar_tag> selector(ntg::float_value<E>*);
+ template <typename E>
+ static tag_is<scalar_tag> selector(ntg::int_value<E>*);
+
+ static tag_is<scalar_tag> selector( signed int*);
+ static tag_is<scalar_tag> selector(unsigned int*);
+ static tag_is<scalar_tag> selector( signed char*);
+ static tag_is<scalar_tag> selector(unsigned char*);
+ static tag_is<scalar_tag> selector( signed short*);
+ static tag_is<scalar_tag> selector(unsigned short*);
+ static tag_is<scalar_tag> selector( signed long*);
+ static tag_is<scalar_tag> selector(unsigned long*);
+ static tag_is<scalar_tag> selector(float*);
+ static tag_is<scalar_tag> selector(double*);
+
+ // vector
+
+ template <unsigned n, typename V>
+ static tag_is<vector_tag> selector(V (*)[n]);
+ template <class V, class A>
+ static tag_is<vector_tag> selector(std::vector<V,A>*);
+ template <typename E>
+ static tag_is<vector_tag> selector(ntg::vect_value<E>*);
+ template <class V>
+ static tag_is<vector_tag> selector(std::complex<V>*);
+ template <ntg::cplx_representation R, class V>
+ static tag_is<vector_tag> selector(ntg::cplx<R,V>*);
+
+ // label
+
+ template <typename E>
+ static tag_is<label_tag> selector(ntg::enum_value<E>*);
+ static tag_is<label_tag> selector(bool*);
+ static tag_is<label_tag> selector(ntg::bin*);
+ template <class b>
+ static tag_is<label_tag> selector(ntg::int_u<1,b>*);
+ template <class b>
+ static tag_is<label_tag> selector(ntg::int_s<1,b>*);
+
+ // data
+
+ static tag_is<data_tag> selector(...); // default
+
+ public:
+
+ enum { val = sizeof(selector(makeT())) };
+ };
+
+
+ // specializations:
+
+ template <class T, class interval>
+ struct of < ntg::cycle<T, interval> >
+ {
+ enum { val = of<T>::val };
+ };
+
+ template <class T, class interval, class behavior>
+ struct of < ntg::range<T, interval, behavior> >
+ {
+ enum { val = of<T>::val };
+ };
+
+
+ // inheritance mechanism:
+
+ template <unsigned tag, typename E>
+ struct inheritance_case;
+
+ template <typename E> struct inheritance_case <scalar_tag, E> : public abstract::scalar_valued_image<E> {};
+ template <typename E> struct inheritance_case <vector_tag, E> : public abstract::vector_valued_image<E> {};
+ template <typename E> struct inheritance_case <label_tag, E> : public abstract::label_valued_image<E> {};
+ template <typename E> struct inheritance_case <data_tag, E> : public abstract::data_valued_image<E> {};
+
+ template <typename E>
+ struct inheritance_switch : public inheritance_case < of< oln_type_of(E, value) >::val, E >
+ {
+ };
+
+
+ } // end of namespace oln::valuedness
+
+
+
+
+ /*! \namespace oln::abstract
+ ** \brief oln::abstract namespace.
+ */
+ namespace abstract {
+
+
+ /*! \class abstract::scalar_image<E>
+ **
+ ** Class of images containing scalar values.
+ */
+
+ template <typename E>
+ struct scalar_valued_image : public virtual image<E>
+ {
+ protected:
+ /// Constructor (protected, empty).
+ scalar_valued_image() {}
+ };
+
+
+
+ /*! \class abstract::vector_valued_image<E>
+ **
+ ** Class of images containing vectorial values.
+ */
+
+ template <typename E>
+ struct vector_valued_image : public virtual image<E>
+ {
+ protected:
+ /// Constructor (protected, empty).
+ vector_valued_image() {}
+ };
+
+
+
+ /*! \class abstract::label_valued_image<E>
+ **
+ ** Class of images containing label values.
+ */
+
+ template <typename E>
+ struct label_valued_image : public virtual image<E>
+ {
+ protected:
+ /// Constructor (protected, empty).
+ label_valued_image() {}
+ };
+
+
+
+ /*! \class abstract::data_valued_image<E>
+ **
+ ** Class of images containing values that cannot be qualified of scalars,
+ ** vectors, or labels.
+ */
+
+ template <typename E>
+ struct data_valued_image : public virtual image<E>
+ {
+ protected:
+ /// Constructor (protected, empty).
+ data_valued_image() {}
+ };
+
+
+
+ } // end of namespace oln::abstract
+
+
+} // end of namespace oln
+
+
+
+#endif // ! OLENA_CORE_ABSTRACT_IMAGE_VALUEDNESS_HH
Index: oln/core/abstract/image_typeness.hh
===================================================================
--- oln/core/abstract/image_typeness.hh (revision 0)
+++ oln/core/abstract/image_typeness.hh (revision 0)
@@ -0,0 +1,258 @@
+// Copyright (C) 2005 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLENA_CORE_ABSTRACT_IMAGE_TYPENESS_HH
+# define OLENA_CORE_ABSTRACT_IMAGE_TYPENESS_HH
+
+# include <ntg/decls.hh>
+# include <oln/core/abstract/image.hh>
+
+
+// image
+//
+// ^
+// |
+// -------------------------------------------------
+// | | | | |
+//
+// greylevel_image color_image label_image data_image ...
+//
+// ^
+// |
+//
+// binary_image
+
+
+
+// fwd decls
+namespace oln {
+ namespace abstract {
+ template <typename E> struct greylevel_image;
+ template <typename E> struct color_image;
+ template <typename E> struct label_image;
+ template <typename E> struct binary_image;
+ template <typename E> struct data_image;
+ }
+}
+
+
+/// Macro.
+# define oln_typeness_of(T) typename typeness::tag_< typeness::of<T>::val >::ret
+
+
+
+/*! \namespace oln
+** \brief oln namespace.
+*/
+namespace oln {
+
+
+ /*! \namespace oln::typeness
+ ** \brief oln::typeness namespace.
+ */
+ namespace typeness {
+
+ enum {
+ _greylevel_tag = 1,
+ _color_tag = 2,
+ _label_tag = 3,
+ _binary_tag = 4,
+ _data_tag = 5
+ };
+
+ struct greylevel_tag;
+ struct color_tag;
+ struct label_tag;
+ struct binary_tag;
+ struct data_tag;
+
+ template <int tag> struct tag_;
+ template <> struct tag_ <_greylevel_tag> { typedef greylevel_tag ret; };
+ template <> struct tag_ <_color_tag> { typedef color_tag ret; };
+ template <> struct tag_ <_label_tag> { typedef label_tag ret; };
+ template <> struct tag_ <_binary_tag> { typedef binary_tag ret; };
+ template <> struct tag_ <_data_tag> { typedef data_tag ret; };
+
+ template <typename T>
+ struct of
+ {
+ protected:
+
+ static T* makeT();
+ template <int tag> struct tag_is { char c[tag]; };
+
+ template <typename E>
+ static tag_is<_color_tag> selector(ntg::color_value<E>*);
+
+ template <typename E>
+ static tag_is<_label_tag> selector(ntg::enum_value<E>*);
+
+ static tag_is<_binary_tag> selector(bool*);
+ static tag_is<_binary_tag> selector(ntg::bin*);
+ template <class b>
+ static tag_is<_binary_tag> selector(ntg::int_u<1,b>*);
+ template <class b>
+ static tag_is<_binary_tag> selector(ntg::int_s<1,b>*);
+
+ static tag_is<_data_tag> selector(...); // default
+
+ public:
+
+ enum { val = sizeof(selector(makeT())) };
+ };
+
+
+ // specializations:
+
+ template <class T, class interval>
+ struct of < ntg::cycle<T, interval> >
+ {
+ enum { val = of<T>::val };
+ };
+
+ template <class T, class interval, class behavior>
+ struct of < ntg::range<T, interval, behavior> >
+ {
+ enum { val = of<T>::val };
+ };
+
+
+ // inheritance mechanism:
+
+ template <typename tag, typename E>
+ struct inheritance_case;
+
+ template <typename E> struct inheritance_case <greylevel_tag, E> : public abstract::greylevel_image<E> {};
+ template <typename E> struct inheritance_case <color_tag, E> : public abstract::color_image<E> {};
+ template <typename E> struct inheritance_case <label_tag, E> : public abstract::label_image<E> {};
+ template <typename E> struct inheritance_case <binary_tag, E> : public abstract::binary_image<E> {};
+ template <typename E> struct inheritance_case <data_tag, E> : public abstract::data_image<E> {};
+
+ template <typename E>
+ struct inheritance_switch : public inheritance_case < typename tag_< of<oln_type_of(E, value)>::val >::ret, E >
+ {
+ };
+
+
+ } // end of namespace oln::typeness
+
+
+
+
+ /*! \namespace oln::abstract
+ ** \brief oln::abstract namespace.
+ */
+ namespace abstract {
+
+
+ /*! \class abstract::greylevel_image<E>
+ **
+ ** Class of greylevel images. An image that contains values whose
+ ** type is 'int' or 'unsigned char', or 'ntg::int_u<8>' (...) is
+ ** NOT a greylevel image. FIXME: say more.
+ */
+
+ template <typename E>
+ struct greylevel_image : public virtual image<E>
+ {
+ protected:
+ /// Constructor (protected, empty).
+ greylevel_image() {}
+ };
+
+
+
+ /*! \class abstract::color_image<E>
+ **
+ ** Class of color images.
+ */
+
+ template <typename E>
+ struct color_image : public virtual image<E>
+ {
+ protected:
+ /// Constructor (protected, empty).
+ color_image() {}
+ };
+
+
+
+ /*! \class abstract::label_image<E>
+ **
+ ** Class of images whose data are labels. Such images do not
+ ** support arithmetics.
+ */
+
+ template <typename E>
+ struct label_image : public virtual image<E>
+ {
+ protected:
+ /// Constructor (protected, empty).
+ label_image() {}
+ };
+
+
+
+ /*! \class abstract::binary_image<E>
+ **
+ ** Class of images whose data are Boolean values. Such images are
+ ** abstract::label_image.
+ */
+
+ template <typename E>
+ struct binary_image : public label_image<E>
+ {
+ protected:
+ /// Constructor (protected, empty).
+ binary_image() {}
+ };
+
+
+
+ /*! \class abstract::data_image<E>
+ **
+ ** Class of images whose data cannot be qualified of greylevels,
+ ** colors, or labels.
+ */
+
+ template <typename E>
+ struct data_image : public virtual image<E>
+ {
+ protected:
+ /// Constructor (protected, empty).
+ data_image() {}
+ };
+
+
+
+ } // end of namespace oln::abstract
+
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_ABSTRACT_IMAGE_TYPENESS_HH
Index: oln/core/1d/image1d.hh
===================================================================
--- oln/core/1d/image1d.hh (revision 125)
+++ oln/core/1d/image1d.hh (working copy)
@@ -31,9 +31,8 @@
# include <mlc/traits.hh>
# include <oln/core/abstract/image_with_data.hh>
-# include <oln/core/abstract/image_vectorialness.hh>
+# include <oln/core/abstract/image_like_.hh>
# include <oln/core/1d/array1d.hh>
-# include <oln/core/1d/fwd_piter1d.hh>
@@ -44,7 +43,8 @@
- // fwd decl
+ // fwd decls
+ struct fwd_piter1d;
template <typename T> class image1d;
// category
@@ -65,7 +65,6 @@
// intrusive property:
typedef is_a<abstract::image1d> image_dimension_type;
// FIXME: should be generalized
- typedef vectorialness_from_valuetype(T) image_vectorialness_type;
typedef mlc::no_type delegated_type;
Index: oln/core/2d/image2d.hh
===================================================================
--- oln/core/2d/image2d.hh (revision 125)
+++ oln/core/2d/image2d.hh (working copy)
@@ -30,12 +30,9 @@
# include <mlc/traits.hh>
-# include <oln/core/abstract/image_like_.hh>
# include <oln/core/abstract/image_with_data.hh>
-# include <oln/core/abstract/image_vectorialness.hh>
+# include <oln/core/abstract/image_like_.hh>
# include <oln/core/2d/array2d.hh>
-# include <oln/core/2d/fwd_piter2d.hh>
-# include <oln/core/2d/bkd_piter2d.hh>
/*! \namespace oln
@@ -53,7 +50,9 @@
- // fwd decl
+ // fwd decls
+ struct fwd_piter2d;
+ struct bkd_piter2d;
template <typename T> class image2d;
// category
@@ -74,7 +73,6 @@
// intrusive property:
typedef is_a<abstract::image2d> image_dimension_type;
// FIXME: should be generalized
- typedef vectorialness_from_valuetype(T) image_vectorialness_type;
typedef mlc::no_type delegated_type;
Index: oln/core/3d/image3d.hh
===================================================================
--- oln/core/3d/image3d.hh (revision 125)
+++ oln/core/3d/image3d.hh (working copy)
@@ -31,10 +31,10 @@
# include <mlc/traits.hh>
# include <oln/core/abstract/image_with_data.hh>
-# include <oln/core/abstract/image_vectorialness.hh>
+# include <oln/core/abstract/image_like_.hh>
# include <oln/core/3d/array3d.hh>
-# include <oln/core/3d/fwd_piter3d.hh>
+
/*! \namespace oln
** \brief oln namespace.
*/
@@ -42,7 +42,8 @@
- // fwd decl
+ // fwd decls
+ struct fwd_piter3d;
template <typename T> class image3d;
// category
@@ -63,7 +64,6 @@
// intrusive property:
typedef is_a<abstract::image3d> image_dimension_type;
// FIXME: should be generalized
- typedef vectorialness_from_valuetype(T) image_vectorialness_type;
typedef mlc::no_type delegated_type;
Index: oln/makefile.src
===================================================================
--- oln/makefile.src (revision 125)
+++ oln/makefile.src (working copy)
@@ -47,7 +47,8 @@
core/abstract/image_dimension.hh \
core/abstract/image_like_.hh \
core/abstract/image_operator.hh \
- core/abstract/image_vectorialness.hh \
+ core/abstract/image_typeness.hh \
+ core/abstract/image_valuedness.hh \
core/abstract/image_with_data.hh \
core/abstract/images.hh \
core/abstract/internal/image_impl.hh \
Index: oln/morpho/stat.hh
===================================================================
--- oln/morpho/stat.hh (revision 125)
+++ oln/morpho/stat.hh (working copy)
@@ -154,7 +154,7 @@
*/
template<class I, class E>
oln_type_of(I, value)
- max(const abstract::non_vectorial_image<I>& input,
+ max(const abstract::image<I>& input,
const oln_type_of(I, point)& p,
const abstract::struct_elt<E>& se)
{
@@ -176,7 +176,7 @@
*/
template<class I, class E>
oln_type_of(I, value)
- min(const abstract::non_vectorial_image<I>& input,
+ min(const abstract::image<I>& input,
const oln_type_of(I, point)& p,
// const mlc_exact_type(I)::iter_type& p,
const abstract::struct_elt<E>& se)
Index: oln/morpho/erosion.hh
===================================================================
--- oln/morpho/erosion.hh (revision 125)
+++ oln/morpho/erosion.hh (working copy)
@@ -120,8 +120,35 @@
};
+
+ // FIXME: remove (test purpose!)
+ // fwd decl
namespace morpho {
+ namespace impl {
+ template <typename I, typename S> struct generic_erosion;
+ }
+ }
+ // category
+ template <typename I, typename S>
+ struct set_category< morpho::impl::generic_erosion<I,S> > { typedef category::image ret; };
+ // super_type
+ template <typename I, typename S>
+ struct set_super_type< morpho::impl::generic_erosion<I,S> >
+ {
+ typedef morpho::erosion_ret<I,S> ret;
+ };
+ template <typename I, typename S>
+ struct set_type_of< category::image, morpho::impl::generic_erosion<I,S>, target::dummy_type >
+ {
+ typedef S ret;
+ };
+ // end of FIXME: remove (test purpose!)
+
+
+
+ namespace morpho {
+
/// Erosion return.
template <typename I, typename E>
@@ -142,6 +169,7 @@
};
+
namespace impl {
/// Erosion generic implementation.
Index: oln/arith/ops.hh
===================================================================
--- oln/arith/ops.hh (revision 125)
+++ oln/arith/ops.hh (working copy)
@@ -29,6 +29,7 @@
# define OLENA_ARITH_OPS_HH
# include <oln/core/abstract/image.hh>
+# include <oln/core/abstract/image_typeness.hh>
# include <oln/core/pw/all.hh>
@@ -130,4 +131,19 @@
+template <typename I, typename F>
+void operator + (const oln::abstract::image<I>&,
+ const oln::pw::abstract::function<F>&)
+{
+ struct OLENA_ERROR__args_are_not_compatible();
+}
+template <typename F, typename I>
+void operator + (const oln::pw::abstract::function<F>&,
+ const oln::abstract::image<I>&)
+{
+ struct OLENA_ERROR__args_are_not_compatible();
+}
+// FIXME: to be continued...
+
+
#endif // ! OLENA_ARITH_OPS_HH
Index: oln/arith/logic.hh
===================================================================
--- oln/arith/logic.hh (revision 0)
+++ oln/arith/logic.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_LOGIC_OPS_HH
+# define OLENA_LOGIC_OPS_HH
+
+# include <oln/core/abstract/image.hh>
+# include <oln/core/abstract/image_typeness.hh>
+# include <oln/core/pw/all.hh>
+
+
+/// Operator 'and' between 2 binary images.
+
+template <typename L, typename R>
+oln::image_from_pw< oln::pw::cmp< oln::pw::image<L>,
+ oln::pw::image<R>, oln::pw::internal::and_ > >
+operator && (const oln::abstract::binary_image<L>& lhs,
+ const oln::abstract::binary_image<R>& rhs)
+{
+ return oln::for_all_p(oln::p_value(lhs) && oln::p_value(rhs));
+}
+
+
+/// Operator 'or' between 2 binary images.
+
+template <typename L, typename R>
+oln::image_from_pw< oln::pw::cmp< oln::pw::image<L>,
+ oln::pw::image<R>, oln::pw::internal::or_ > >
+operator || (const oln::abstract::binary_image<L>& lhs,
+ const oln::abstract::binary_image<R>& rhs)
+{
+ return oln::for_all_p(oln::p_value(lhs) || oln::p_value(rhs));
+}
+
+
+/// Unary operator 'not' on a binary image.
+
+template <typename I>
+oln::image_from_pw< oln::pw::not_< oln::pw::image<I> > >
+operator ! (const oln::abstract::binary_image<I>& rhs)
+{
+ return oln::for_all_p(!oln::p_value(rhs));
+}
+
+
+
+#endif // ! OLENA_LOGIC_OPS_HH
1
0
2005-04-08 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* mlc/bool.hh: Extend.
Index: mlc/bool.hh
===================================================================
--- mlc/bool.hh (revision 125)
+++ mlc/bool.hh (working copy)
@@ -85,10 +85,12 @@
/// Logical binary operators between a couple of Boolean types
- template <typename L, typename R> struct and_ : public value <bool, (L::b && R::b)> {};
- template <typename L, typename R> struct or_ : public value <bool, (L::b || R::b)> {};
- template <typename L, typename R> struct nand_ : public value <bool, (L::b && !R::b)> {};
- template <typename L, typename R> struct xor_ : public value <bool, ((L::b && !R::b) || (!L::b && R::b))> {};
+ template <typename L, typename R> struct and_ : public value <bool, (L::b && R::b) > {};
+ template <typename L, typename R> struct nand_ : public value <bool, (!(L::b && R::b))> {};
+ template <typename L, typename R> struct or_ : public value <bool, (L::b || R::b) > {};
+ template <typename L, typename R> struct nor_ : public value <bool, (!(L::b || R::b))> {};
+ template <typename L, typename R> struct xor_ : public value <bool, (L::b != R::b) > {};
+ template <typename L, typename R> struct xnor_ : public value <bool, (!(L::b != R::b))> {};
} // end of namespace mlc
1
0
2005-04-08 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* ntg/decls.hh: New file.
Index: ntg/decls.hh
===================================================================
--- ntg/decls.hh (revision 0)
+++ ntg/decls.hh (revision 0)
@@ -0,0 +1,63 @@
+// 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 NTG_DECLS_HH
+# define NTG_DECLS_HH
+
+# include <ntg/vect/cplx_representation.hh>
+
+
+namespace ntg
+{
+
+ // abstract classes
+ template <typename E> class value;
+ template <typename E> class enum_value;
+ template <typename E> class real_value;
+ template <typename E> class float_value;
+ template <typename E> class int_value;
+ template <typename E> class uint_value;
+ template <typename E> class sint_value;
+ template <typename E> class vect_value;
+ template <unsigned N, class T, class E> class vec;
+ template <typename E> class color_value;
+
+ // concrete classes
+ class bin;
+ template <unsigned nbits, class behavior> class int_u;
+ template <unsigned nbits, class behavior> class int_s;
+ template <class T, class interval> class cycle;
+ template <class T, class interval, class behavior> class range;
+ template <cplx_representation R, class T> class cplx;
+ template <unsigned ncomps, unsigned qbits,
+ template <unsigned> class color_system> struct color;
+
+} // end of namespace ntg
+
+
+#endif // ! NTG_DECLS_HH
+
1
0
Index: ChangeLog
from Nicolas Widynski <nicolas.widynski(a)lrde.epita.fr>
* oln/core/abstract/niter.hh: New. Abstract neighborhood iterator class.
* oln/core/abstract/regular_niter.hh: New. Abstract neighborhood iterator for windows.
* oln/core/2d/fwd_regular_niter2d.hh: New. Concrete 2d neighborhood class
2d/fwd_regular_niter2d.hh | 138 +++++++++++++++++++++++++++++++++++++++
abstract/niter.hh | 159 ++++++++++++++++++++++++++++++++++++++++++++++
abstract/regular_niter.hh | 138 +++++++++++++++++++++++++++++++++++++++
3 files changed, 435 insertions(+)
Index: oln/core/abstract/niter.hh
--- oln/core/abstract/niter.hh (revision 0)
+++ oln/core/abstract/niter.hh (revision 0)
@@ -0,0 +1,159 @@
+// 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_ABSTRACT_NITER_HH
+# define OLENA_CORE_ABSTRACT_NITER_HH
+
+# include <vector>
+
+# include <mlc/any.hh>
+# include <mlc/types.hh>
+# include <mlc/contract.hh>
+
+# include <oln/core/gen/image_with_nbh.hh>
+# include <oln/core/abstract/point.hh>
+# include <oln/core/properties.hh>
+# include <oln/core/abstract/image.hh>
+# include <oln/core/abstract/neighborhood.hh>
+# include <oln/core/abstract/image_neighbness.hh>
+
+
+# define for_all_n(n) \
+ for(n.start(); n.is_valid(); n.next())
+
+# define for_all_remaining_n(n) \
+ for(; n.is_valid(); n.next())
+
+
+// FIXME : bad place
+# include <oln/core/abstract/piter.hh>
+
+# define for_all_n_of_p(p, n) \
+ for(p.start(); p.is_valid(); p.next()) \
+ for(n.center_at(p), n.start(); n.is_valid(); n.next())
+
+namespace oln {
+
+ // fwd decl
+ namespace abstract {
+ template <typename E> struct niter;
+ }
+
+ // category
+ template <typename E>
+ struct set_category< abstract::niter<E> > { typedef category::niter ret; };
+
+
+ /// properties of any type in category::niter
+
+ template <typename type>
+ struct props_of < category::niter, type >
+ {
+ typedef mlc::true_type user_defined_;
+
+ mlc_decl_prop(category::niter, point_type);
+ mlc_decl_prop(category::niter, dpoint_type);
+ mlc_decl_prop(category::niter, neighb_type);
+ mlc_decl_prop(category::niter, image_type);
+
+ static void echo(std::ostream& ostr)
+ {
+ ostr << "props_of( category::niter, "
+ << typeid(type).name() << ") = {"
+ << " neighb_type = " << typeid(neighb_type).name()
+ << " image_type = " << typeid(image_type).name()
+ << " point_type = " << typeid(point_type).name() << " }" << std::endl;
+ }
+
+ };
+
+ mlc_register_prop(category::niter, neighb_type);
+ mlc_register_prop(category::niter, point_type);
+ mlc_register_prop(category::niter, dpoint_type);
+ mlc_register_prop(category::niter, image_type);
+
+
+ namespace abstract {
+
+ template <typename E>
+ struct niter : public mlc::any__best_speed<E>
+ {
+
+ /// typedefs
+
+ typedef niter<E> self_type;
+
+ typedef oln_type_of(E, point) point_type;
+ typedef oln_type_of(E, neighb) neighb_type;
+ typedef oln_type_of(E, image) image_type;
+
+ void start()
+ {
+ this->exact().impl_start();
+ }
+
+ void next()
+ {
+ this->exact().impl_next();
+ }
+
+ operator point_type() const
+ {
+ return this->exact().impl_cast_point();
+ }
+
+ void center_at(const point_type& pt)
+ {
+ this->exact().impl_center_at(pt);
+ }
+
+ bool is_valid() const
+ {
+ return this->exact().impl_is_valid();
+ }
+
+ void invalidate()
+ {
+ return this->exact().impl_invalidate();
+ }
+
+ protected:
+
+ template <typename T>
+ niter(const abstract::image_with_nbh<T>& ima) :
+ p_(), nbh_(ima.nbh_get())
+ {
+ }
+
+ point_type p_;
+ const neighb_type& nbh_;
+ };
+ }
+}
+
+
+#endif // ! OLENA_CORE_ABSTRACT_NITER_HH
Index: oln/core/abstract/regular_niter.hh
--- oln/core/abstract/regular_niter.hh (revision 0)
+++ oln/core/abstract/regular_niter.hh (revision 0)
@@ -0,0 +1,138 @@
+// 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_ABSTRACT_REGULAR_NITER_HH
+# define OLENA_CORE_ABSTRACT_REGULAR_NITER_HH
+
+# include <vector>
+
+# include <mlc/any.hh>
+# include <mlc/types.hh>
+# include <mlc/contract.hh>
+
+# include <oln/core/abstract/niter.hh>
+# include <oln/core/gen/image_with_nbh.hh>
+# include <oln/core/abstract/point.hh>
+# include <oln/core/abstract/dpoint.hh>
+# include <oln/core/properties.hh>
+# include <oln/core/abstract/image.hh>
+# include <oln/core/abstract/neighborhood.hh>
+# include <oln/core/abstract/image_neighbness.hh>
+
+
+namespace oln {
+
+ // fwd decls
+
+ namespace abstract {
+ template <typename E> struct regular_niter;
+ }
+
+ // category
+
+ template <typename E>
+ struct set_category< abstract::regular_niter<E> > {
+ typedef category::niter ret;
+ };
+
+ // super type
+
+ template <typename E>
+ struct set_super_type < abstract::regular_niter<E> >
+ {
+ typedef abstract::niter<E> ret;
+ };
+
+
+ namespace abstract {
+
+ template <typename E>
+ struct regular_niter : public niter<E>
+ {
+
+ /// typedefs
+ typedef oln_type_of(E, point) point_type;
+ typedef oln_type_of(E, dpoint) dpoint_type;
+ typedef regular_niter<E> self_type;
+
+ void impl_start()
+ {
+ dp_cur_ = dp_.begin();
+ }
+
+ void impl_next()
+ {
+ precondition(this->is_valid());
+ dp_cur_ ++;
+ }
+
+ void impl_center_at(const point_type& pt)
+ {
+ this->p_ = pt;
+ dp_.clear();
+ this->exact().impl_determine_neighb();
+ }
+
+ bool impl_is_valid() const
+ {
+ return dp_cur_ != dp_.end();
+ }
+
+ const point_type impl_cast_point() const
+ {
+ precondition(this->is_valid());
+ return *dp_cur_ + this->p_;
+ }
+
+ void impl_invalidate()
+ {
+ dp_cur_ = dp_.end();
+ postcondition(! this->is_valid());
+ }
+
+ protected:
+
+ void impl_determine_neighb()
+ {
+ for (unsigned i = 0; i < this->nbh_.card(); ++i)
+ dp_.push_back(this->nbh_[i]);
+ }
+
+ template <typename T>
+ regular_niter(const abstract::image_with_nbh<T>& ima) :
+ niter<E>(ima)
+ {
+ }
+
+ typename std::vector<dpoint_type>::iterator dp_cur_;
+ std::vector<dpoint_type> dp_;
+ };
+ }
+}
+
+
+#endif // ! OLENA_CORE_ABSTRACT_REGULAR_NITER_HH
Index: oln/core/2d/fwd_regular_niter2d.hh
--- oln/core/2d/fwd_regular_niter2d.hh (revision 0)
+++ oln/core/2d/fwd_regular_niter2d.hh (revision 0)
@@ -0,0 +1,138 @@
+// 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_ABSTRACT_REGULAR_NITER_HH
+# define OLENA_CORE_ABSTRACT_REGULAR_NITER_HH
+
+# include <vector>
+
+# include <mlc/any.hh>
+# include <mlc/types.hh>
+# include <mlc/contract.hh>
+
+# include <oln/core/abstract/niter.hh>
+# include <oln/core/gen/image_with_nbh.hh>
+# include <oln/core/abstract/point.hh>
+# include <oln/core/abstract/dpoint.hh>
+# include <oln/core/properties.hh>
+# include <oln/core/abstract/image.hh>
+# include <oln/core/abstract/neighborhood.hh>
+# include <oln/core/abstract/image_neighbness.hh>
+
+
+namespace oln {
+
+ // fwd decls
+
+ namespace abstract {
+ template <typename E> struct regular_niter;
+ }
+
+ // category
+
+ template <typename E>
+ struct set_category< abstract::regular_niter<E> > {
+ typedef category::niter ret;
+ };
+
+ // super type
+
+ template <typename E>
+ struct set_super_type < abstract::regular_niter<E> >
+ {
+ typedef abstract::niter<E> ret;
+ };
+
+
+ namespace abstract {
+
+ template <typename E>
+ struct regular_niter : public niter<E>
+ {
+
+ /// typedefs
+ typedef oln_type_of(E, point) point_type;
+ typedef oln_type_of(E, dpoint) dpoint_type;
+ typedef regular_niter<E> self_type;
+
+ void impl_start()
+ {
+ dp_cur_ = dp_.begin();
+ }
+
+ void impl_next()
+ {
+ precondition(this->is_valid());
+ dp_cur_ ++;
+ }
+
+ void impl_center_at(const point_type& pt)
+ {
+ this->p_ = pt;
+ dp_.clear();
+ this->exact().impl_determine_neighb();
+ }
+
+ bool impl_is_valid() const
+ {
+ return dp_cur_ != dp_.end();
+ }
+
+ const point_type impl_cast_point() const
+ {
+ precondition(this->is_valid());
+ return *dp_cur_ + this->p_;
+ }
+
+ void impl_invalidate()
+ {
+ dp_cur_ = dp_.end();
+ postcondition(! this->is_valid());
+ }
+
+ protected:
+
+ void impl_determine_neighb()
+ {
+ for (unsigned i = 0; i < this->nbh_.card(); ++i)
+ dp_.push_back(this->nbh_[i]);
+ }
+
+ template <typename T>
+ regular_niter(const abstract::image_with_nbh<T>& ima) :
+ niter<E>(ima)
+ {
+ }
+
+ typename std::vector<dpoint_type>::iterator dp_cur_;
+ std::vector<dpoint_type> dp_;
+ };
+ }
+}
+
+
+#endif // ! OLENA_CORE_ABSTRACT_REGULAR_NITER_HH
1
0