https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Add qiters for oln::morpher::slice.
* oln/core/type_fun/slice.hh
(TYPE_FUNCTION_slice_piter_NOT_DEFINED_FOR_THIS_PARAMETER): Rename
as...
(TYPE_FUNCTION_slice_iterator_NOT_DEFINED_FOR_THIS_PARAMETER):
...this.
Adjust.
(oln::type_fun::slice_piter): Rename as...
(oln::type_fun::slice_iterator): ...this.
(oln::type_fun::slice_iterator<fwd_qiter2d>)
(oln::type_fun::slice_iterator<bkd_qiter2d>)
(oln::type_fun::slice_iterator<fwd_qiter3d>)
(oln::type_fun::slice_iterator<bkd_qiter3d>)
* oln/core/iterator_vtypes.hh: s/slice_piter/slice_iterator/g.
(oln::single_vtype<morpher::slice<Image>, typedef_::fwd_qiter_type>)
(oln::single_vtype<morpher::slice<Image>, typedef_::bkd_qiter_type>)
* oln/morpher/slice.hh: Adjust comments.
* tests/morphers/slice_morpher.cc: s/ima_with_nbh/slice/g
Test fwd_qiter on oln::morpher::slice.
oln/core/iterator_vtypes.hh | 31 +++++++++++++++++++++++++---
oln/core/type_fun/slice.hh | 44 ++++++++++++++++++++++++++++++----------
oln/morpher/slice.hh | 4 +--
tests/morphers/slice_morpher.cc | 42 ++++++++++++++++++++++++++------------
4 files changed, 93 insertions(+), 28 deletions(-)
Index: oln/core/type_fun/slice.hh
--- oln/core/type_fun/slice.hh (revision 666)
+++ oln/core/type_fun/slice.hh (working copy)
@@ -145,7 +145,7 @@
/// Error messages raised by static assertions/abortions.
namespace ERROR
{
- struct TYPE_FUNCTION_slice_piter_NOT_DEFINED_FOR_THIS_PARAMETER;
+ struct TYPE_FUNCTION_slice_iterator_NOT_DEFINED_FOR_THIS_PARAMETER;
struct TYPE_FUNCTION_slice_topo_NOT_DEFINED_FOR_THIS_PARAMETER;
}
@@ -153,9 +153,9 @@
namespace type_fun
{
- /*------------------------.
- | type_fun::slice_piter. |
- `------------------------*/
+ /*---------------------------.
+ | type_fun::slice_iterator. |
+ `---------------------------*/
/// Type function returning the ``sliced'' piter corresponding to
/// \a Piter
@@ -163,10 +163,10 @@
/// Default version, undefined.
template <typename Piter>
- struct slice_piter :
+ struct slice_iterator :
public mlc::abort_<
Piter,
- oln::ERROR::TYPE_FUNCTION_slice_piter_NOT_DEFINED_FOR_THIS_PARAMETER
+ oln::ERROR::TYPE_FUNCTION_slice_iterator_NOT_DEFINED_FOR_THIS_PARAMETER
{
typedef mlc::undefined ret;
@@ -178,34 +178,58 @@
// --------- //
template <>
- struct slice_piter<fwd_piter2d>
+ struct slice_iterator<fwd_piter2d>
{
typedef fwd_piter1d ret;
};
template <>
- struct slice_piter<bkd_piter2d>
+ struct slice_iterator<bkd_piter2d>
{
typedef bkd_piter1d ret;
};
+ template <>
+ struct slice_iterator<fwd_qiter2d>
+ {
+ typedef fwd_qiter1d ret;
+ };
+
+ template <>
+ struct slice_iterator<bkd_qiter2d>
+ {
+ typedef bkd_qiter1d ret;
+ };
+
// --------- //
// image3d. //
// --------- //
template <>
- struct slice_piter<fwd_piter3d>
+ struct slice_iterator<fwd_piter3d>
{
typedef fwd_piter2d ret;
};
template <>
- struct slice_piter<bkd_piter3d>
+ struct slice_iterator<bkd_piter3d>
{
typedef bkd_piter2d ret;
};
+ template <>
+ struct slice_iterator<fwd_qiter3d>
+ {
+ typedef fwd_qiter2d ret;
+ };
+
+ template <>
+ struct slice_iterator<bkd_qiter3d>
+ {
+ typedef bkd_qiter2d ret;
+ };
+
/// \}
Index: oln/core/iterator_vtypes.hh
--- oln/core/iterator_vtypes.hh (revision 666)
+++ oln/core/iterator_vtypes.hh (working copy)
@@ -284,6 +284,8 @@
template <typename Piter, typename Topo> class piter_slice_;
+ // piters.
+
/// fwd_piter vtype of morpher::slice.
template <typename Image>
struct single_vtype< morpher::slice<Image>, typedef_::fwd_piter_type >
@@ -291,7 +293,7 @@
private:
typedef oln_type_of(Image, fwd_piter) orig_fwd_piter;
public:
- typedef typename type_fun::slice_piter<orig_fwd_piter>::ret ret;
+ typedef typename type_fun::slice_iterator<orig_fwd_piter>::ret ret;
};
/// bkd_piter vtype of morpher::slice.
@@ -301,11 +303,34 @@
private:
typedef oln_type_of(Image, bkd_piter) orig_bkd_piter;
public:
- typedef typename type_fun::slice_piter<orig_bkd_piter>::ret ret;
+ typedef typename type_fun::slice_iterator<orig_bkd_piter>::ret ret;
+ };
+
+
+ // qiters.
+
+ /// fwd_qiter vtype of morpher::slice.
+ template <typename Image>
+ struct single_vtype< morpher::slice<Image>, typedef_::fwd_qiter_type >
+ {
+ private:
+ typedef oln_type_of(Image, fwd_qiter) orig_fwd_qiter;
+ public:
+ typedef typename type_fun::slice_iterator<orig_fwd_qiter>::ret ret;
+ };
+
+ /// bkd_qiter vtype of morpher::slice.
+ template <typename Image>
+ struct single_vtype< morpher::slice<Image>, typedef_::bkd_qiter_type >
+ {
+ private:
+ typedef oln_type_of(Image, bkd_qiter) orig_bkd_qiter;
+ public:
+ typedef typename type_fun::slice_iterator<orig_bkd_qiter>::ret ret;
};
- // FIXME: What about niters and qiter?
+ // FIXME: What about niters?
} // end of namespace oln
Index: oln/morpher/slice.hh
--- oln/morpher/slice.hh (revision 666)
+++ oln/morpher/slice.hh (working copy)
@@ -90,8 +90,8 @@
// fwd_piter_type: see oln/core/iterator_vtypes.hh.
// bkd_piter_type: see oln/core/iterator_vtypes.hh.
- // FIXME: fwd_qiter_type?
- // FIXME: bkd_qiter_type?
+ // fwd_qiter_type: see oln/core/iterator_vtypes.hh.
+ // bkd_qiter_type: see oln/core/iterator_vtypes.hh.
typedef oln::morpher::tag::slice morpher_type;
Index: tests/morphers/slice_morpher.cc
--- tests/morphers/slice_morpher.cc (revision 666)
+++ tests/morphers/slice_morpher.cc (working copy)
@@ -33,7 +33,8 @@
#include <mlc/is_a.hh>
// FIXME: We should not include oln/basics2d.hh and oln/basics3d.hh,
-// but only oln/core/2d/image2d.hh and oln/core/3d/image3d.hh.
+// but only oln/core/3d/image3d.hh and oln/core/2d/image2d.hh,
+// oln/core/2d/window2d.
#include <oln/basics2d.hh>
#include <oln/basics3d.hh>
#include <oln/morpher/slice.hh>
@@ -45,7 +46,7 @@
main()
{
/*---------------.
- | image2d<int>. |
+ | image3d<int>. |
`---------------*/
typedef oln::image3d<int> image_t;
@@ -58,27 +59,27 @@
/*----------------------------.
- | add_slice< image2d<int> >. |
+ | add_slice< image3d<int> >. |
`----------------------------*/
typedef oln::morpher::slice<image_t> slice_t;
// Check that the instantiated slice morpher realizes the suited
// interfaces.
- mlc::assert_< mlc::eq_<oln_type_of_(slice_t, grid), oln::grid2d>
>::check();
+ mlc::assert_< mlc::eq_<oln_grid_(slice_t), oln::grid2d> >::check();
mlc::assert_< mlc_is_a_(slice_t, oln::abstract::image2d) >::check();
mlc::assert_< mlc_is_a_(slice_t, oln::abstract::mutable_image) >::check();
// Create a slice of \a ima along the 2nd axis (which the ``row''
// axis, numbered 1), and check its peoperties.
int slice_row = 2;
- slice_t ima_with_nbh(ima, 1, slice_row);
- assert(ima_with_nbh.bbox().nrows() == 3);
- assert(ima_with_nbh.bbox().ncols() == 5);
- // Fill a slice of \a ima by filling \a ima_with_nbh.
- oln::level::fill (ima_with_nbh, 51);
+ slice_t slice(ima, 1, slice_row);
+ assert(slice.bbox().nrows() == 3);
+ assert(slice.bbox().ncols() == 5);
+ // Fill a slice of \a ima by filling \a slice.
+ oln::level::fill (slice, 51);
- // Check that \a ima has been altered, by comapring it to a similar
+ // Check that \a ima has been altered, by comparing it to a similar
// 3D image.
image_t ref(3, 4, 5);
oln::level::fill (ref, 42);
@@ -86,7 +87,22 @@
for (unsigned c = 0; c < ima.bbox().ncols(); ++c)
ref.at(s, slice_row, c) = 51;
// FIXME: Implement equality on images.
- oln_type_of_(image_t, piter) p (ima.topo());
- for_all (p)
- assert(ima(p) == ref(p));
+ oln_piter_(image_t) pi (ima.topo());
+ for_all (pi)
+ assert(ima(pi) == ref(pi));
+
+ // Test foward q-iterator.
+ typedef oln::window2d slice_win_t;
+ slice_win_t win_c4p;
+ win_c4p.
+ add(oln::dpoint2d(-1, 0)).
+ add(oln::dpoint2d(+1, 0)).
+ add(oln::dpoint2d( 0, -1)).
+ add(oln::dpoint2d( 0, +1));
+ oln_piter_(slice_t) ps (slice.topo());
+ oln_qiter_(slice_t) q (ps, win_c4p);
+ for_all (ps)
+ for_all (q)
+ if (slice.has(q))
+ assert(slice(q) == 51);
}