https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Get rid of the Fastest_Image concept class.
* mln/core/concept/fastest_image.hh: Remove.
* mln/core/internal/impl: New.
* mln/core/internal/image_base.hh (image_impled_): Remove;
merge with image_checked_.
* mln/core/internal/check/image_fastest.hh: Fix doc.
(offset_at): New; copy from the now removed concept class.
* mln/core/image2d_b.hh: Remove dead code.
* mln/core/concept/image.hh: Remove obsolete include.
* mln/core/concept/doc/fastest_image.hh: Rename as...
* mln/core/concept/doc/image_fastest.hh: ...this.
Update.
* mln/level/median.hh: Fix text.
* mln/level/transform.hh: Likewise.
* mln/border/resize.hh: Update sig.
* mln/border/duplicate.hh: Likewise.
* mln/morpho/erosion_fast.hh: Update text.
* mln/morpho/dilation_fast.hh: Likewise.
* tests/canvas_browsing_fwd.cc: Augment.
* tests/image2d_b.cc (check_fastest): Remove; obsolete.
mln/border/duplicate.hh | 13 ++++++----
mln/border/resize.hh | 6 ++--
mln/core/concept/doc/image_fastest.hh | 11 +++++---
mln/core/concept/image.hh | 2 -
mln/core/image2d_b.hh | 13 ----------
mln/core/internal/check/image_fastest.hh | 40 +++++++++++++++++++++++++++----
mln/core/internal/image_base.hh | 40 +++----------------------------
mln/level/median.hh | 2 -
mln/level/transform.hh | 4 ++-
mln/morpho/dilation_fast.hh | 2 -
mln/morpho/erosion_fast.hh | 2 -
tests/canvas_browsing_fwd.cc | 18 +++++++++++++
tests/image2d_b.cc | 7 -----
13 files changed, 81 insertions(+), 79 deletions(-)
Index: tests/image2d_b.cc
--- tests/image2d_b.cc (revision 1261)
+++ tests/image2d_b.cc (working copy)
@@ -36,11 +36,6 @@
#include <mln/core/init.hh>
-template <typename I>
-void check_fastest(const mln::Fastest_Image<I>&)
-{
-}
-
int main()
{
@@ -54,6 +49,4 @@
mln_assertion(f.npoints() = geom::nrows(f) * geom::ncols(f));
mln_assertion(f.ncells() = (nrows + 2 * border) * (ncols + 2 * border));
-
- check_fastest(f);
}
Index: tests/canvas_browsing_fwd.cc
--- tests/canvas_browsing_fwd.cc (revision 1261)
+++ tests/canvas_browsing_fwd.cc (working copy)
@@ -107,7 +107,25 @@
my_test(ima2, fun::p2v::iota, canvas::browsing::snake_fwd);
debug::println(ima2);
+
+ level::fill(ima2, 0);
+ my_test(ima2, fun::p2v::iota, canvas::browsing::directional, 0);
+ debug::println(ima2);
+
+ level::fill(ima2, 0);
+ my_test(ima2, fun::p2v::iota, canvas::browsing::directional, 1);
+ debug::println(ima2);
+
+
+ level::fill(ima3, 0);
+ my_test(ima3, fun::p2v::iota, canvas::browsing::directional, 0);
+ debug::println(ima3);
+
level::fill(ima3, 0);
my_test(ima3, fun::p2v::iota, canvas::browsing::directional, 1);
debug::println(ima3);
+
+ level::fill(ima3, 0);
+ my_test(ima3, fun::p2v::iota, canvas::browsing::directional, 2);
+ debug::println(ima3);
}
Index: mln/core/internal/image_base.hh
--- mln/core/internal/image_base.hh (revision 1261)
+++ mln/core/internal/image_base.hh (working copy)
@@ -35,6 +35,7 @@
# include <mln/core/concept/image.hh>
# include <mln/core/grids.hh>
+# include <mln/core/trait/qlf_value.hh>
# include <mln/core/internal/check/image_all.hh>
# include <mln/util/tracked_ptr.hh>
@@ -78,48 +79,15 @@
};
- /*! \brief Selector for image inheritance (fastest or not fastest).
- *
- * \internal
- */
- template <typename Is_fastest, typename E>
- struct select_image_concept_;
-
- template <typename E>
- struct select_image_concept_< metal::true_, E >
- : public Fastest_Image<E>
- {};
-
- template <typename E>
- struct select_image_concept_< metal::false_, E >
- : public Image<E>
- {};
-
-
-
template <typename E>
struct image_checked_
:
public check::image_all_<E>,
-
- // FIXME: first check impl w.r.t. properties, then:
- public select_image_concept_< typename mlc_equal(mln_trait_image_speed(E),
- trait::speed::fastest)::eval,
- E > // FIXME: Change to Image<E>
+ public Image<E>
{
};
- template <typename E>
- struct image_impled_
- :
- // FIXME: first fetch default impl w.r.t. properties, then:
- image_checked_<E>
- {
- };
-
-
-
/*! \brief A base class for images.
*
* Parameter \p S is a point set type.
@@ -129,7 +97,7 @@
template <typename S, typename E>
struct image_base_
:
- public image_impled_<E>
+ public image_checked_<E>
{
/// Point_Set associated type.
@@ -206,7 +174,7 @@
template <typename S, typename E>
image_base_<S,E>::image_base_(const image_base_& rhs)
- : image_impled_<E>()
+ : image_checked_<E>()
{
mln_precondition(exact(rhs).has_data()); // FIXME: Is-it too restrictive?
this->data_ = rhs.data_;
Index: mln/core/internal/check/image_fastest.hh
--- mln/core/internal/check/image_fastest.hh (revision 1261)
+++ mln/core/internal/check/image_fastest.hh (working copy)
@@ -28,11 +28,14 @@
#ifndef MLN_CORE_INTERNAL_CHECK_IMAGE_FASTEST_HH
# define MLN_CORE_INTERNAL_CHECK_IMAGE_FASTEST_HH
-/*! \file mln/core/concept/fastest_image.hh
- * \brief Definition of the concept of mln::Fastest_Image.
+/*! \file mln/core/internal/check/image_fastest.hh
+ *
+ * \brief Class that statically checks the interface of fastest
+ * images.
*/
+
namespace mln
{
@@ -43,13 +46,24 @@
{
/*! \brief FIXME
- *
- * \see mln::doc::Fastest_Image for a complete documentation of this
- * class contents.
*/
template < typename E, typename B = metal::true_ >
struct image_fastest_
{
+
+ /*! \brief Give the offset of the point \p p.
+ *
+ * \param[in] p A generalized point.
+ *
+ * \warning This method is final.
+ *
+ * \pre The image has to be initialized and to own the point \p p.
+ * \post p = point_at_offset(result)
+ */
+ template <typename P>
+ unsigned
+ offset_at(const Generalized_Point<P>& p) const;
+
protected:
image_fastest_();
};
@@ -101,6 +115,22 @@
// FIXME: how to check that qixter are defined when W is unknown!
}
+ template <typename E, typename B>
+ template <typename P>
+ unsigned // FIXME: std::size_t?
+ image_fastest_<E,B>::offset_at(const Generalized_Point<P>& p_)
const
+ {
+ // FIXME: check that P is mln_point(E)
+ const E* this_ = & internal::force_exact<E>(*this);
+ const P& p = internal::force_exact<P>(p_);
+ mln_precondition(this_->has_data());
+ mln_precondition(this_->owns_(p));
+
+ unsigned o = & this_->operator()(p) - this_->buffer();
+ mln_postcondition(p = this_->point_at_offset(o));
+ return o;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::internal::check
Index: mln/core/image2d_b.hh
--- mln/core/image2d_b.hh (revision 1261)
+++ mln/core/image2d_b.hh (working copy)
@@ -104,19 +104,6 @@
-// namespace trait
-// {
-
-// template <typename T>
-// struct is_fast< image2d_b<T> >
-// {
-// typedef metal::true_ ret;
-// };
-
-// } // end of mln::trait
-
-
-
/*! \brief Basic 2D image class.
*
* The parameter \c T is the type of pixel values. This image class
Index: mln/core/concept/image.hh
--- mln/core/concept/image.hh (revision 1261)
+++ mln/core/concept/image.hh (working copy)
@@ -196,7 +196,5 @@
} // end of namespace mln
-# include <mln/core/concept/fastest_image.hh>
-
#endif // ! MLN_CORE_CONCEPT_IMAGE_HH
Index: mln/core/concept/doc/image_fastest.hh
--- mln/core/concept/doc/image_fastest.hh (revision 1256)
+++ mln/core/concept/doc/image_fastest.hh (working copy)
@@ -25,18 +25,21 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file mln/core/concept/doc/fastest_image.hh
- * \brief This file documents the concept of mln::Fastest_Image.
+/*! \file mln/core/concept/doc/image_fastest.hh
+ *
+ * \brief This file documents the concept of images that have the
+ * speed property set to "fastest".
*/
+
namespace mln
{
namespace doc
{
- /*! \brief Documentation class for mln::Fastest_Image.
- * \see mln::Fastest_Image
+ /*! \brief Documentation class for the concept of images that have
+ * the speed property set to "fastest".
*/
template <typename E>
struct Fastest_Image : public Image<E>
Index: mln/level/median.hh
--- mln/level/median.hh (revision 1261)
+++ mln/level/median.hh (working copy)
@@ -32,7 +32,7 @@
*
* \brief Median filtering of an image.
*
- * \todo Add Fastest_Image versions.
+ * \todo Add versions for fastest and semi-linear images.
*/
# include <mln/core/concept/image.hh>
Index: mln/level/transform.hh
--- mln/level/transform.hh (revision 1261)
+++ mln/level/transform.hh (working copy)
@@ -98,9 +98,11 @@
}
+ // FIXME: Handle the cases of fastest images.
+
// template <typename I, typename F, typename O>
// void transform(metal::true_, // low quantization
-// const Fastest_Image<I>& input_, const Function_v2v<F>& f_,
Image<O>& output_)
+// const Image<I>& input_, const Function_v2v<F>& f_,
Image<O>& output_)
// {
// const I& input = exact(input_);
// const F& f = exact(f_);
Index: mln/border/resize.hh
--- mln/border/resize.hh (revision 1261)
+++ mln/border/resize.hh (working copy)
@@ -57,17 +57,17 @@
* \todo Implement it.
*/
template <typename I>
- void resize(const Fastest_Image<I>& ima, unsigned thickness);
+ void resize(const Image<I>& ima, unsigned thickness);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
- void resize(const Fastest_Image<I>& ima_, unsigned thickness)
+ void resize(const Image<I>& ima_, unsigned thickness)
{
+ mlc_is(mln_trait_image_speed(I), mln::trait::speed::fastest)::check();
const I& ima = exact(ima_);
mln_precondition(ima.has_data());
- mlc_is(mln_trait_image_speed(I), mln::trait::speed::fastest)::check();
if (ima.border() >= thickness)
return;
mln::internal::fixme();
Index: mln/border/duplicate.hh
--- mln/border/duplicate.hh (revision 1261)
+++ mln/border/duplicate.hh (working copy)
@@ -120,7 +120,7 @@
}
template <typename I>
- void duplicate_3d_(const Fastest_Image<I>& ima_)
+ void duplicate_3d_(const Image<I>& ima_)
{
const I& ima = exact(ima_);
mln_precondition(ima.has_data());
@@ -188,22 +188,25 @@
// Facade.
template <typename I>
- void duplicate(const Fastest_Image<I>& ima_)
+ void duplicate(const Image<I>& ima_)
{
- trace::entering("border::duplicate");
- typedef mln_point(I) P;
+ mlc_is(mln_trait_image_speed(I), mln::trait::speed::fastest)::check();
const I& ima = exact(ima_);
+ typedef mln_point(I) P;
+ trace::entering("border::duplicate");
+
mln_precondition(ima.has_data());
- mlc_is(mln_trait_image_speed(I), mln::trait::speed::fastest)::check();
if (!ima.border ())
return;
+
if (P::dim = 1)
impl::duplicate_1d_(ima);
if (P::dim = 2)
impl::duplicate_2d_(ima);
if (P::dim = 3)
impl::duplicate_3d_(ima);
+
trace::exiting("border::duplicate");
}
Index: mln/morpho/erosion_fast.hh
--- mln/morpho/erosion_fast.hh (revision 1261)
+++ mln/morpho/erosion_fast.hh (working copy)
@@ -32,7 +32,7 @@
*
* \brief Ero filtering of an image.
*
- * \todo Add Fastest_Image versions.
+ * \todo Add fastest versions.
*/
# include <mln/core/concept/image.hh>
Index: mln/morpho/dilation_fast.hh
--- mln/morpho/dilation_fast.hh (revision 1261)
+++ mln/morpho/dilation_fast.hh (working copy)
@@ -32,7 +32,7 @@
*
* \brief Ero filtering of an image.
*
- * \todo Add Fastest_Image versions.
+ * \todo Add fastest versions.
*/
# include <mln/core/concept/image.hh>