https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Clean level::paste; yet de-activate specializations.
* tests/level/paste.cc: Deactivate 3D tests.
* mln/core/image/instant.hh (init_): New method; fix missing.
* mln/level/paste.spe.hh (paste_dispatch): New.
De-activate specializations; it calls the generic version.
* mln/level/paste.hh (paste_tests): New in internal.
(paste): Call tests then dispatch.
mln/core/image/instant.hh | 13 ++++++
mln/level/paste.hh | 40 +++++++++++++--------
mln/level/paste.spe.hh | 86 ++++++++++++++++++++++++++--------------------
tests/level/paste.cc | 36 +++++++++----------
4 files changed, 107 insertions(+), 68 deletions(-)
Index: tests/level/paste.cc
--- tests/level/paste.cc (revision 2230)
+++ tests/level/paste.cc (working copy)
@@ -31,7 +31,7 @@
*/
#include <mln/core/image/image2d.hh>
-#include <mln/core/image/image3d.hh>
+// #include <mln/core/image/image3d.hh>
#include <mln/core/image/sub_image.hh>
#include <mln/level/fill.hh>
@@ -59,24 +59,24 @@
level::paste(ima, ima2); // Fast version.
assert(ima == (ima2 | b));
- level::impl::generic::paste_(ima, ima2); // Not so fast version...
+ level::impl::generic::paste(ima, ima2); // Not so fast version...
assert(ima == (ima2 | b));
}
- // tests in three dimension
- {
- box3d b(make::point3d(1,2, 1), make::point3d(2,4, 3));
- image3d<int> ima(b, 2);
- debug::iota(ima);
-
- box3d b2(make::point3d(-1,-2, -1), make::point3d(3,6, 3));
- image3d<int> ima2(b2, 2);
- debug::iota(ima2);
-
- level::paste(ima, ima2); // Fast version.
- assert(ima == (ima2 | b));
-
- level::impl::generic::paste_(ima, ima2); // Not so fast version...
- assert(ima == (ima2 | b));
- }
+// // tests in three dimension
+// {
+// box3d b(make::point3d(1,2, 1), make::point3d(2,4, 3));
+// image3d<int> ima(b, 2);
+// debug::iota(ima);
+
+// box3d b2(make::point3d(-1,-2, -1), make::point3d(3,6, 3));
+// image3d<int> ima2(b2, 2);
+// debug::iota(ima2);
+
+// level::paste(ima, ima2); // Fast version.
+// assert(ima == (ima2 | b));
+
+// level::impl::generic::paste(ima, ima2); // Not so fast version...
+// assert(ima == (ima2 | b));
+// }
}
Index: mln/core/image/instant.hh
--- mln/core/image/instant.hh (revision 2230)
+++ mln/core/image/instant.hh (working copy)
@@ -95,6 +95,9 @@
/// Constructor.
instant_(I& ima);
+ /// Deferred initialization.
+ void init_(I& ima);
+
/// Remove the "instant" envelope.
I& un_instant_();
I& un_instant_() const;
@@ -126,6 +129,16 @@
instant_<I>::instant_(I& ima)
{
mln_precondition(ima.has_data());
+ this->init_(ima);
+ this->data_ = new internal::data< instant_<I> >(ima);
+ }
+
+ template <typename I>
+ inline
+ void
+ instant_<I>::init_(I& ima)
+ {
+ mln_precondition(ima.has_data());
this->data_ = new internal::data< instant_<I> >(ima);
}
Index: mln/level/paste.spe.hh
--- mln/level/paste.spe.hh (revision 2230)
+++ mln/level/paste.spe.hh (working copy)
@@ -57,54 +57,68 @@
namespace generic
{
template <typename I, typename J>
- void paste_(const I& data, J& destination);
- }
-
- template <typename I, typename J>
- inline
- void paste_lines_(const I& data, J& destination)
- {
- trace::entering("level::impl::paste_lines_");
- typedef mln_psite(I) P;
- std::size_t n = data.bbox().len(P::dim - 1);
- // FIXME: Works only for raw data images
- // FIXME: For linear data images, we should get the len for each line...
-
- typename I::line_piter p(data.domain()); // FIXME: Alias mln_line_piter!
- // mln_line_piter(I) p(data.domain());
- for_all(p)
- memcpy_(inplace(make::pixel(destination, p)),
- make::pixel(data, p),
- n);
- trace::exiting("level::impl::paste_lines_");
+ void paste(const Image<I>& data, Image<J>& destination);
}
+// template <typename I, typename J>
+// inline
+// void paste_lines_(const I& data, J& destination)
+// {
+// trace::entering("level::impl::paste_lines_");
+// typedef mln_psite(I) P;
+// std::size_t n = data.bbox().len(P::dim - 1);
+// // FIXME: Works only for raw data images
+// // FIXME: For linear data images, we should get the len for each line...
+
+// typename I::line_piter p(data.domain()); // FIXME: Alias mln_line_piter!
+// // mln_line_piter(I) p(data.domain());
+// for_all(p)
+// memcpy_(inplace(make::pixel(destination, p)),
+// make::pixel(data, p),
+// n);
+// trace::exiting("level::impl::paste_lines_");
+// }
+
+
+// // Disjunction.
+
+// // Remember: raw < linear < stored, computed.
+
+// template <typename I, typename J>
+// inline
+// void paste_(trait::image::value_storage::any, const I& data,
+// trait::image::value_storage::any, J& destination)
+// {
+// generic::paste_(data, destination);
+// }
+
+// template <typename I, typename J>
+// inline
+// void paste_(trait::image::value_storage::one_block, const I& data,
+// trait::image::value_storage::one_block, J& destination)
+// {
+// if (sizeof(mln_value(I)) == sizeof(mln_value(J)))
+// paste_lines_(data, destination);
+// else
+// generic::paste_(data, destination);
+// }
- // Disjunction.
- // Remember: raw < linear < stored, computed.
+ } // end of namespace mln::level::impl
- template <typename I, typename J>
- inline
- void paste_(trait::image::value_storage::any, const I& data,
- trait::image::value_storage::any, J& destination)
+ namespace internal
{
- generic::paste_(data, destination);
- }
template <typename I, typename J>
inline
- void paste_(trait::image::value_storage::one_block, const I& data,
- trait::image::value_storage::one_block, J& destination)
+ void paste_dispatch(const Image<I>& data, Image<J>&
destination)
{
- if (sizeof(mln_value(I)) == sizeof(mln_value(J)))
- paste_lines_(data, destination);
- else
- generic::paste_(data, destination);
+ impl::generic::paste(data, destination);
+// impl::paste_(mln_trait_image_value_storage(I)(), data,
+// mln_trait_image_value_storage(J)(), destination);
}
-
- } // end of namespace mln::level::impl
+ } // end of namespace mln::level::internal
} // end of namespace mln::level
Index: mln/level/paste.hh
--- mln/level/paste.hh (revision 2230)
+++ mln/level/paste.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 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
@@ -73,6 +73,21 @@
# ifndef MLN_INCLUDE_ONLY
+ namespace internal
+ {
+
+ template <typename I, typename J>
+ inline
+ void paste_tests(const Image<I>& data, Image<J>& destination)
+ {
+ mlc_is(mln_trait_image_value_io(J), trait::image::value_io::read_write)::check();
+ mlc_converts_to(mln_value(I), mln_value(J))::check();
+ mln_precondition(exact(data).has_data());
+ mln_precondition(exact(data).domain() <= exact(destination).domain());
+ }
+
+ } // end of namespace mln::level::internal
+
namespace impl
{
@@ -81,15 +96,19 @@
template <typename I, typename J>
inline
- void paste_(const I& data, J& destination)
+ void paste(const Image<I>& data_, Image<J>& destination_)
{
- trace::entering("level::impl::generic::paste_");
+ trace::entering("level::impl::generic::paste");
+
+ internal::paste_tests(data_, destination_);
+ const I& data = exact(data_);
+ J& destination = exact(destination_);
mln_piter(I) p(data.domain());
for_all(p)
destination(p) = data(p);
- trace::exiting("level::impl::generic::paste_");
+ trace::exiting("level::impl::generic::paste");
}
} // end of namespace mln::level::impl::generic
@@ -101,19 +120,12 @@
template <typename I, typename J>
inline
- void paste(const Image<I>& data_, Image<J>& destination_)
+ void paste(const Image<I>& data, Image<J>& destination)
{
trace::entering("level::paste");
- const I& data = exact(data_);
- J& destination = exact(destination_);
-
- mlc_is(mln_trait_image_value_io(J), trait::image::value_io::read_write)::check();
- mlc_converts_to(mln_value(I), mln_value(J))::check();
- mln_precondition(data.domain() <= destination.domain());
-
- impl::paste_(mln_trait_image_value_storage(I)(), data,
- mln_trait_image_value_storage(J)(), destination);
+ internal::paste_tests(data, destination);
+ internal::paste_dispatch(data, destination);
trace::exiting("level::paste");
}