https://svn.lrde.epita.fr/svn/oln/trunk/milena
This patches addresses most of (if not all) the tasks from ticket #141
(
https://trac.lrde.org/olena/ticket/141).
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Complete delta-point pixel iterators.
* mln/core/dpoints_pixter.hh: Aesthetic changes.
Add some more documentation.
(dpoints_fwd_pixter(const Generalized_Pixel<Pref>& const Dps&)):
Use const_cast instead of legacy casts.
(mln::dpoints_bkd_pixter<I>): New pixel iterator class.
* mln/core/pixel.hh (mln::pixel<I>::pixel (I&)): Don't set member
value_ptr_ to 0, since the super class' ctor already takes care of
this.
* mln/core/image1d.hh
(mln::trait::bkd_qixter< image1d<T>, W >)
(mln::trait::bkd_qixter< const image1d<T>, W >)
(mln::trait::fwd_nixter< image1d<T>, W >)
(mln::trait::fwd_nixter< const image1d<T>, W >)
(mln::trait::bkd_nixter< image1d<T>, W >)
(mln::trait::bkd_nixter< const image1d<T>, W >)
* mln/core/image2d.hh
(mln::trait::bkd_qixter< image2d<T>, W >)
(mln::trait::bkd_qixter< const image2d<T>, W >)
(mln::trait::bkd_nixter< image2d<T>, W >)
(mln::trait::bkd_nixter< const image2d<T>, W >)
* mln/core/image3d.hh
(mln::trait::bkd_qixter< image3d<T>, W >)
(mln::trait::bkd_qixter< const image3d<T>, W >)
(mln::trait::fwd_nixter< image3d<T>, W >)
(mln::trait::fwd_nixter< const image3d<T>, W >)
(mln::trait::bkd_nixter< image3d<T>, W >)
(mln::trait::bkd_nixter< const image3d<T>, W >):
Define these specialisations.
* mln/core/internal/force_exact.hh (mln::internal::force_exact):
Use ptrdiff_t instead of int to store the pointer difference.
Remove dead code.
* mln/core/macros.hh
(mln_fwd_qixter_, mln_bkd_qixter_, mln_qixter_)
(mln_fwd_nixter_, mln_bkd_nixter_, mln_nixter_):
New macros.
* tests/dpoints_pixter.cc: Move...
* tests/core/dpoints_pixter.cc: ...here.
Exercise mln::dpoints_bkd_pixter as well.
* tests/Makefile.am (check_PROGRAMS): Remove dpoints_pixter.
(dpoints_pixter_SOURCES): Move...
* tests/core/Makefile.am: ...here.
(check_PROGRAMS): Add dpoints_pixter.
mln/core/dpoints_pixter.hh | 283 +++++++++++++++++++++++++++++++++------
mln/core/image1d.hh | 43 ++++-
mln/core/image2d.hh | 26 ++-
mln/core/image3d.hh | 43 ++++-
mln/core/internal/force_exact.hh | 35 +---
mln/core/macros.hh | 12 +
mln/core/pixel.hh | 1
tests/Makefile.am | 2
tests/core/Makefile.am | 2
tests/core/dpoints_pixter.cc | 38 ++---
10 files changed, 377 insertions(+), 108 deletions(-)
Index: mln/core/dpoints_pixter.hh
--- mln/core/dpoints_pixter.hh (revision 1912)
+++ mln/core/dpoints_pixter.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,11 +28,10 @@
#ifndef MLN_CORE_DPOINTS_PIXTER_HH
# define MLN_CORE_DPOINTS_PIXTER_HH
-/*! \file mln/core/dpoints_pixter.hh
- *
- * \brief Definition of forward and backward mln::dpoint_ based
- * iterators for pixels iterations.
- */
+/// \file mln/core/dpoints_pixter.hh
+///
+/// \brief Definition of forward and backward mln::dpoint-based
+/// iterators for pixels iterations.
# include <cassert>
# include <vector>
@@ -42,88 +41,183 @@
# include <mln/core/internal/pixel_impl.hh>
-
namespace mln
{
- /*! \brief A generic forward iterator on pixels of windows and of
- * neighborhoods.
- *
- * The parameter \c I is the image type.
- */
+ /*------------------------.
+ | dpoints_fwd_pixter<I>. |
+ `------------------------*/
+
+ /// \brief A generic forward iterator on the pixels of a
+ /// dpoint-based window or neighborhood.
+ ///
+ /// Parameter \c I is the image type.
template <typename I>
- class dpoints_fwd_pixter : public Pixel_Iterator< dpoints_fwd_pixter<I> >,
+ class dpoints_fwd_pixter
+ : public Pixel_Iterator< dpoints_fwd_pixter<I> >,
public internal::pixel_impl_< I, dpoints_fwd_pixter<I> >
{
typedef typename internal::pixel_impl_< I, dpoints_fwd_pixter<I> >
super_;
- public:
- /*! \brief Constructor.
- *
- * \param[in] image Image subject to iteration.
- * \param[in] dps Object that can provide a set of delta-points.
- * \param[in] p_ref Center point to iterate around.
- */
+ public:
+ /// \brief Constructor (using an image).
+ ///
+ /// \param[in] image The image to iterate over.
+ /// \param[in] dps An object (neighborhood or window) that can
+ /// provide a set of delta-points.
+ /// \param[in] p_ref Center (resp. reference) point of the
+ /// neighborhood (resp. window).
template <typename Dps, typename Pref>
dpoints_fwd_pixter(I& image,
const Dps& dps,
const Point_Site<Pref>& p_ref);
- /*! \brief Constructor.
- *
- * \param[in] pxl_ref Center (generalized) pixel to iterate around.
- * \param[in] dps Object that can provide a set of delta-points.
- */
+ /// \brief Constructor (using a generalized pixel).
+ ///
+ /// \param[in] pxl_ref Center (generalized) pixel to iterate around.
+ /// \param[in] dps An object (neighborhood or window) that can
+ /// provide a set of delta-points.
template <typename Dps, typename Pref>
dpoints_fwd_pixter(const Generalized_Pixel<Pref>& pxl_ref,
const Dps& dps);
+ /// Manipulation.
+ /// \{
/// Start an iteration.
void start();
-
/// Go to the next pixel.
void next_();
/// Invalidate the iterator.
void invalidate();
-
/// Test the iterator validity.
bool is_valid() const;
/// Force this iterator to update its location to take into
/// account that its center point may have moved.
void update();
+ /// \}
/// The value around which this iterator moves.
const mln_value(I)& center_val() const;
private:
+ template <typename Dps>
+ void init_(const Dps& dps);
- /// offset of each dpoints
+ private:
+ /// \brief Offset of each delta-point.
+ ///
+ /// offset_[0] is absolute, while other offsets are relative
+ /// (i.e., offset_[i] is the memory difference to go from pixel
+ /// i-1 to pixel i.
std::vector<int> offset_;
-
- /// current offset
+ /// Current offset.
+ // FIXME: Why not an iterator on vector offset_?
unsigned i_;
- /// reference pixel / point in the image
+ /// \brief Reference value or pixel.
+ ///
+ /// One and only one of these pointers should be non-null.
+ /// \{
+ /// Reference value the image
mln_qlf_value(I)** value_ref_;
- // or:
+ /// Reference pixel / point in the image
const mln_point(I)* p_ref_;
+ /// \}
+ };
+
+
+ /*------------------------.
+ | dpoints_bkd_pixter<I>. |
+ `------------------------*/
+
+ /// \brief A generic backward iterator on the pixels of a
+ /// dpoint-based window or neighborhood.
+ ///
+ /// Parameter \c I is the image type.
+ template <typename I>
+ class dpoints_bkd_pixter
+ : public Pixel_Iterator< dpoints_bkd_pixter<I> >,
+ public internal::pixel_impl_< I, dpoints_bkd_pixter<I> >
+ {
+ typedef typename internal::pixel_impl_< I, dpoints_bkd_pixter<I> >
super_;
+ public:
+ /// \brief Constructor (using an image).
+ ///
+ /// \param[in] image The image to iterate over.
+ /// \param[in] dps An object (neighborhood or window) that can
+ /// provide a set of delta-points.
+ /// \param[in] p_ref Center (resp. reference) point of the
+ /// neighborhood (resp. window).
+ template <typename Dps, typename Pref>
+ dpoints_bkd_pixter(I& image,
+ const Dps& dps,
+ const Point_Site<Pref>& p_ref);
+
+ /// \brief Constructor (using a generalized pixel).
+ ///
+ /// \param[in] pxl_ref Center (generalized) pixel to iterate around.
+ /// \param[in] dps An object (neighborhood or window) that can
+ /// provide a set of delta-points.
+ template <typename Dps, typename Pref>
+ dpoints_bkd_pixter(const Generalized_Pixel<Pref>& pxl_ref,
+ const Dps& dps);
+
+ /// Manipulation.
+ /// \{
+ /// Start an iteration.
+ void start();
+ /// Go to the next pixel.
+ void next_();
+
+ /// Invalidate the iterator.
+ void invalidate();
+ /// Test the iterator validity.
+ bool is_valid() const;
+
+ /// Force this iterator to update its location to take into
+ /// account that its center point may have moved.
+ void update();
+ /// \}
+ /// The value around which this iterator moves.
+ const mln_value(I)& center_val() const;
+
+ private:
template <typename Dps>
void init_(const Dps& dps);
- };
-
- // FIXME: dpoints_bkd_pixter<I>
+ private:
+ /// \brief Offset of each delta-point.
+ ///
+ /// offset_[dps.ndpoints() - 1] is absolute, while other offsets
+ /// are relative (i.e., offset_[i] is the memory difference to go
+ /// from pixel i+1 to pixel i.
+ std::vector<int> offset_;
+ /// Current offset.
+ // FIXME: Why not an iterator on vector offset_?
+ int i_;
+
+ /// \brief Reference value or pixel.
+ ///
+ /// One and only one of these pointers should be non-null.
+ /// \{
+ /// Reference value the image
+ mln_qlf_value(I)** value_ref_;
+ /// Reference pixel / point in the image
+ const mln_point(I)* p_ref_;
+ /// \}
+ };
#ifndef MLN_INCLUDE_ONLY
-
- // dpoints_fwd_pixter<I>
+ /*------------------------.
+ | dpoints_fwd_pixter<I>. |
+ `------------------------*/
template <typename I>
template <typename Dps, typename Pref>
@@ -149,8 +243,8 @@
const Pref& pxl_ref = internal::force_exact<Pref>(pxl_ref_);
mln_precondition(pxl_ref.ima().has_data());
p_ref_ = 0;
- // potential promotion from (T**) to (const T**) shall be forced:
- value_ref_ = (mln_qlf_value(I)**)(void*)(pxl_ref.address_());
+ // Potential promotion from (T**) to (const T**) shall be forced.
+ value_ref_ = const_cast<mln_qlf_value(I)**>(pxl_ref.address_());
init_(dps);
}
@@ -231,6 +325,117 @@
i_ = offset_.size();
}
+
+ /*------------------------.
+ | dpoints_bkd_pixter<I>. |
+ `------------------------*/
+
+ template <typename I>
+ template <typename Dps, typename Pref>
+ inline
+ dpoints_bkd_pixter<I>::dpoints_bkd_pixter(I& image,
+ const Dps& dps,
+ const Point_Site<Pref>& p_ref)
+ : super_(image)
+ {
+ mln_precondition(image.has_data());
+ p_ref_ = & exact(p_ref).to_point();
+ value_ref_ = 0;
+ init_(dps);
+ }
+
+ template <typename I>
+ template <typename Dps, typename Pref>
+ inline
+ dpoints_bkd_pixter<I>::dpoints_bkd_pixter(const
Generalized_Pixel<Pref>& pxl_ref_,
+ const Dps& dps)
+ : super_(internal::force_exact<Pref>(pxl_ref_).ima())
+ {
+ const Pref& pxl_ref = internal::force_exact<Pref>(pxl_ref_);
+ mln_precondition(pxl_ref.ima().has_data());
+ p_ref_ = 0;
+ // Potential promotion from (T**) to (const T**) shall be forced.
+ value_ref_ = const_cast<mln_qlf_value(I)**>(pxl_ref.address_());
+ init_(dps);
+ }
+
+ template <typename I>
+ inline
+ const mln_value(I)&
+ dpoints_bkd_pixter<I>::center_val() const
+ {
+ mln_invariant(value_ref_ != 0 || p_ref_ != 0);
+ if (p_ref_)
+ return image_(*p_ref_);
+ else
+ return **value_ref_;
+ }
+
+ template <typename I>
+ template <typename Dps>
+ inline
+ void
+ dpoints_bkd_pixter<I>::init_(const Dps& dps)
+ {
+ for (unsigned i = 0; i < dps.ndpoints(); ++i)
+ offset_.push_back(this->image_.offset(dps.dp(i)));
+ // offset_[ndpoints() - 1] is absolute
+ // other offsets are relative:
+ if (dps.ndpoints() > 1)
+ for (unsigned i = 0; i < dps.ndpoints() - 1; ++i)
+ offset_[i] -= offset_[i + 1];
+ invalidate();
+ }
+
+ template <typename I>
+ inline
+ void
+ dpoints_bkd_pixter<I>::update()
+ {
+ if (is_valid())
+ {
+ if (p_ref_)
+ this->value_ptr_ = & image_(*p_ref_) + offset_[i_];
+ else
+ this->value_ptr_ = * value_ref_ + offset_[i_];
+ }
+ }
+
+ template <typename I>
+ inline
+ void
+ dpoints_bkd_pixter<I>::start()
+ {
+ i_ = offset_.size() - 1;
+ update();
+ }
+
+ template <typename I>
+ inline
+ void
+ dpoints_bkd_pixter<I>::next_()
+ {
+ --i_;
+ if (is_valid())
+ this->value_ptr_ += offset_[i_];
+ }
+
+ template <typename I>
+ inline
+ bool
+ dpoints_bkd_pixter<I>::is_valid() const
+ {
+ return i_ >= 0;
+ }
+
+ template <typename I>
+ inline
+ void
+ dpoints_bkd_pixter<I>::invalidate()
+ {
+ i_ = -1;
+ }
+
#endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
Index: mln/core/pixel.hh
--- mln/core/pixel.hh (revision 1912)
+++ mln/core/pixel.hh (working copy)
@@ -74,7 +74,6 @@
pixel<I>::pixel(I& image)
: super(image)
{
- this->value_ptr_ = 0;
}
template <typename I>
Index: mln/core/image1d.hh
--- mln/core/image1d.hh (revision 1912)
+++ mln/core/image1d.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +28,8 @@
#ifndef MLN_CORE_IMAGE1D_HH
# define MLN_CORE_IMAGE1D_HH
-/*! \file mln/core/image1d.hh
- *
- * \brief Definition of the basic mln::image1d class.
- */
+/// \file mln/core/image1d.hh
+/// \brief Definition of the basic mln::image1d class.
# include <mln/core/internal/fixme.hh>
# include <mln/core/internal/image_primary.hh>
@@ -553,11 +551,40 @@
template <typename T, typename W>
struct bkd_qixter< image1d<T>, W >
{
- // FIXME: Implement dpoints_bkd_pixter.
- typedef mln::internal::fixme ret;
+ typedef dpoints_bkd_pixter< image1d<T> > ret;
+ };
+
+ template <typename T, typename W>
+ struct bkd_qixter< const image1d<T>, W >
+ {
+ typedef dpoints_bkd_pixter< const image1d<T> > ret;
+ };
+
+ // nixter
+
+ template <typename T, typename W>
+ struct fwd_nixter< image1d<T>, W >
+ {
+ typedef dpoints_fwd_pixter< image1d<T> > ret;
+ };
+
+ template <typename T, typename W>
+ struct fwd_nixter< const image1d<T>, W >
+ {
+ typedef dpoints_fwd_pixter< const image1d<T> > ret;
+ };
+
+ template <typename T, typename W>
+ struct bkd_nixter< image1d<T>, W >
+ {
+ typedef dpoints_bkd_pixter< image1d<T> > ret;
};
- // FIXME: Nixters (see in image2d.hh)
+ template <typename T, typename W>
+ struct bkd_nixter< const image1d<T>, W >
+ {
+ typedef dpoints_bkd_pixter< const image1d<T> > ret;
+ };
} // end of namespace mln::trait
Index: mln/core/image2d.hh
--- mln/core/image2d.hh (revision 1912)
+++ mln/core/image2d.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +28,8 @@
#ifndef MLN_CORE_IMAGE2D_HH
# define MLN_CORE_IMAGE2D_HH
-/*! \file mln/core/image2d.hh
- *
- * \brief Definition of the basic mln::image2d class.
- */
+/// \file mln/core/image2d.hh
+/// \brief Definition of the basic mln::image2d class.
# include <mln/core/internal/image_primary.hh>
# include <mln/core/internal/fixme.hh>
@@ -581,8 +579,13 @@
template <typename T, typename W>
struct bkd_qixter< image2d<T>, W >
{
- // FIXME: Implement dpoints_bkd_pixter.
- typedef mln::internal::fixme ret;
+ typedef dpoints_bkd_pixter< image2d<T> > ret;
+ };
+
+ template <typename T, typename W>
+ struct bkd_qixter< const image2d<T>, W >
+ {
+ typedef dpoints_bkd_pixter< const image2d<T> > ret;
};
// nixter
@@ -602,8 +605,13 @@
template <typename T, typename N>
struct bkd_nixter< image2d<T>, N >
{
- // FIXME: Implement dpoints_bkd_pixter.
- typedef mln::internal::fixme ret;
+ typedef dpoints_bkd_pixter< image2d<T> > ret;
+ };
+
+ template <typename T, typename N>
+ struct bkd_nixter< const image2d<T>, N >
+ {
+ typedef dpoints_bkd_pixter< const image2d<T> > ret;
};
} // end of namespace mln::trait
Index: mln/core/image3d.hh
--- mln/core/image3d.hh (revision 1912)
+++ mln/core/image3d.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +28,8 @@
#ifndef MLN_CORE_IMAGE3D_HH
# define MLN_CORE_IMAGE3D_HH
-/*! \file mln/core/image3d.hh
- *
- * \brief Definition of the basic mln::image3d class.
- */
+/// \file mln/core/image3d.hh
+/// \brief Definition of the basic mln::image3d class.
# include <mln/core/internal/fixme.hh>
# include <mln/core/internal/image_primary.hh>
@@ -593,11 +591,40 @@
template <typename T, typename W>
struct bkd_qixter< image3d<T>, W >
{
- // FIXME: Implement dpoints_bkd_pixter.
- typedef mln::internal::fixme ret;
+ typedef dpoints_bkd_pixter< image3d<T> > ret;
+ };
+
+ template <typename T, typename W>
+ struct bkd_qixter< const image3d<T>, W >
+ {
+ typedef dpoints_bkd_pixter< const image3d<T> > ret;
+ };
+
+ // nixter
+
+ template <typename T, typename W>
+ struct fwd_nixter< image3d<T>, W >
+ {
+ typedef dpoints_fwd_pixter< image3d<T> > ret;
+ };
+
+ template <typename T, typename W>
+ struct fwd_nixter< const image3d<T>, W >
+ {
+ typedef dpoints_fwd_pixter< const image3d<T> > ret;
+ };
+
+ template <typename T, typename W>
+ struct bkd_nixter< image3d<T>, W >
+ {
+ typedef dpoints_bkd_pixter< image3d<T> > ret;
};
- // FIXME: Nixters (see in image2d.hh)
+ template <typename T, typename W>
+ struct bkd_nixter< const image3d<T>, W >
+ {
+ typedef dpoints_bkd_pixter< const image3d<T> > ret;
+ };
} // end of namespace mln::trait
Index: mln/core/internal/force_exact.hh
--- mln/core/internal/force_exact.hh (revision 1912)
+++ mln/core/internal/force_exact.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,12 +28,10 @@
#ifndef MLN_CORE_INTERNAL_FORCE_EXACT_HH
# define MLN_CORE_INTERNAL_FORCE_EXACT_HH
-/*! \file mln/core/internal/force_exact.hh
- *
- * \brief Definition of a violent cast for internal use only.
- *
- */
+/// \file mln/core/internal/force_exact.hh
+/// \brief Definition of a violent cast for internal use only.
+#include <cstddef>
namespace mln
@@ -42,27 +40,20 @@
namespace internal
{
- /*! \internal Violent cast.
- * This cast is an alternative to the mln::exact cast.
- * It is used for objects that do not derive from
- * mln::Object.
- * Warning Do not to use this cast!
- * see mln::exact
- */
+ /** \internal Violent cast.
+
+ This cast is an alternative to the mln::exact cast. It is
+ used for objects that do not derive from mln::Object.
+ Warning: Do not use this cast, unless you know what you are
+ doing.
+
+ \see mln::exact. */
template <typename E, typename T>
E& force_exact(const T& ref)
{
- /*
- static const E exact_obj;
- static const Type& exact_obj_ref = exact_obj;
- static const int exact_offset =
- (const char*)(void*)(&exact_obj_ref)
- - (const char*)(void*)(&exact_obj);
- return *(E*)((char*)(this_) - exact_offset);
- */
static const E* exact_obj;
static const T& exact_obj_ref = *exact_obj;
- static const int exact_offset =
+ static const ptrdiff_t exact_offset =
(const char*)(void*)(&exact_obj_ref)
- (const char*)(void*)( exact_obj);
return *(E*)((char*)(&ref) - exact_offset);
Index: mln/core/macros.hh
--- mln/core/macros.hh (revision 1912)
+++ mln/core/macros.hh (working copy)
@@ -293,15 +293,23 @@
# define mln_fwd_qixter(I, W) typename mln::trait::fwd_qixter< I, W >::ret
+# define mln_fwd_qixter_(I, W) mln::trait::fwd_qixter< I, W >::ret
+
# define mln_bkd_qixter(I, W) typename mln::trait::bkd_qixter< I, W >::ret
+# define mln_bkd_qixter_(I, W) mln::trait::bkd_qixter< I, W >::ret
+
# define mln_qixter(I, W) mln_fwd_qixter(I, W)
+# define mln_qixter_(I, W) mln_fwd_qixter_(I, W)
# define mln_fwd_nixter(I, N) typename mln::trait::fwd_nixter< I, N >::ret
-# define mln_bkd_nixter(I, N) typename mln::trait::bkd_nixter< I, N >::ret
-# define mln_nixter(I, N) mln_fwd_nixter(I, N)
+# define mln_fwd_nixter_(I, N) mln::trait::fwd_nixter< I, N >::ret
+# define mln_bkd_nixter(I, N) typename mln::trait::bkd_nixter< I, N >::ret
+# define mln_bkd_nixter_(I, N) mln::trait::bkd_nixter< I, N >::ret
+# define mln_nixter(I, N) mln_fwd_nixter(I, N)
+# define mln_nixter_(I, N) mln_fwd_nixter_(I, N)
#endif // ! MLN_CORE_MACROS_HH
Index: tests/core/dpoints_pixter.cc
--- tests/core/dpoints_pixter.cc (revision 1912)
+++ tests/core/dpoints_pixter.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,45 +25,49 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/dpoints_pixter.cc
- *
- * \brief Test on mln::dpoints_fwd_pixter.
- */
+/// \file tests/dpoints_pixter.cc
+/// \brief Test on mln::dpoints_fwd_pixter and mln::dpoints_bkd_pixter.
#include <mln/core/image2d.hh>
#include <mln/win/rectangle2d.hh>
#include <mln/make/pixel.hh>
-
template <typename I, typename W>
void test_fill(I& ima, const W& win)
{
mln_piter(I) p(ima.domain());
- mln_qixter(I, W) q(ima, win, p);
+ mln_fwd_qixter(I, W) fq(ima, win, p);
+ for_all(p)
+ {
+ unsigned i = 0;
+ for_all(fq)
+ ++i, fq.val() = 51;
+ mln_assertion(i == 9);
+ }
+ mln_bkd_qixter(I, W) bq(ima, win, p);
for_all(p)
{
unsigned i = 0;
- for_all(q)
- ++i, q.val() = 51;
+ for_all(bq)
+ ++i, bq.val() = 42;
mln_assertion(i == 9);
}
}
-
-// FIXME: test promotion and other constructions
-
+// FIXME: Test promotion and other constructions.
template <typename P, typename W>
void test_pixel(const P& pxl, const W& win)
{
- mln_qixter(mln_image(P), W) q(pxl, win);
- for_all(q)
- q.val() = 2 * q.val();
+ mln_fwd_qixter(mln_image(P), W) fq(pxl, win);
+ for_all(fq)
+ fq.val() = 2 * fq.val();
+ mln_bkd_qixter(mln_image(P), W) bq(pxl, win);
+ for_all(bq)
+ bq.val() = bq.val() + 1;
}
-
-
int main()
{
using namespace mln;
Index: tests/Makefile.am
--- tests/Makefile.am (revision 1912)
+++ tests/Makefile.am (working copy)
@@ -51,7 +51,6 @@
dpoint1d \
dpoint2d \
dpoint3d \
- dpoints_pixter \
\
estim_mean \
\
@@ -141,7 +140,6 @@
dpoint1d_SOURCES = dpoint1d.cc
dpoint2d_SOURCES = dpoint2d.cc
dpoint3d_SOURCES = dpoint3d.cc
-dpoints_pixter_SOURCES = dpoints_pixter.cc
estim_mean_SOURCES = estim_mean.cc
Index: tests/core/Makefile.am
--- tests/core/Makefile.am (revision 1912)
+++ tests/core/Makefile.am (working copy)
@@ -5,6 +5,7 @@
check_PROGRAMS = \
category \
clone \
+ dpoints_pixter \
exact \
h_vec \
initialize \
@@ -37,6 +38,7 @@
category_SOURCES = category.cc
clone_SOURCES = clone.cc
+dpoints_pixter_SOURCES = dpoints_pixter.cc
exact_SOURCES = exact.cc
h_vec_SOURCES = h_vec.cc
initialize_SOURCES = initialize.cc