https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Several bug fixes.
* mln/topo/is_simple_cell.hh (operator): Fix g++-3.3 issue.
* mln/core/internal/check/image_fastest.hh: Fix Z's fix.
* mln/data/transform.spe.hh,
* mln/data/apply.spe.hh: Fix non-updated guard.
* tests/data/transform.cc: Have it pass.
mln/core/internal/check/image_fastest.hh | 2
mln/data/apply.spe.hh | 14 ++---
mln/data/transform.spe.hh | 7 +-
mln/topo/is_simple_cell.hh | 8 ++-
tests/data/transform.cc | 79 ++++++++++++++++++-------------
5 files changed, 64 insertions(+), 46 deletions(-)
Index: mln/topo/is_simple_cell.hh
--- mln/topo/is_simple_cell.hh (revision 4054)
+++ mln/topo/is_simple_cell.hh (working copy)
@@ -27,6 +27,7 @@
# define MLN_TOPO_IS_SIMPLE_CELL_HH
/// \file
+///
/// \brief Testing whether a facet is a simple cell.
# include <mln/core/concept/function.hh>
@@ -40,6 +41,7 @@
# include <mln/make/attachment.hh>
+
namespace mln
{
@@ -74,7 +76,8 @@
void set_image(const mln::Image<I>& ima);
/// Based on the algorithm A2 from couprie.08.pami.
- bool operator()(const psite& p) const;
+ bool operator()(const mln::complex_psite<I::dim,mln_geom(I)>& p) const;
+ // Tech note: The argument type above is explicit to help g++-3.3.
private:
const I* ima_;
@@ -109,7 +112,8 @@
template <typename I>
inline
bool
- is_simple_cell<I>::operator()(const is_simple_cell<I>::psite& p)
const
+ is_simple_cell<I>::operator()(const
mln::complex_psite<I::dim,mln_geom(I)>& p) const
+ // Tech note: The argument type above is explicit to help g++-3.3.
{
mln_precondition(ima_);
Index: mln/core/internal/check/image_fastest.hh
--- mln/core/internal/check/image_fastest.hh (revision 4054)
+++ mln/core/internal/check/image_fastest.hh (working copy)
@@ -118,7 +118,7 @@
unsigned (E::*m8)() const = & E::nelements;
m8 = 0;
-# if (defined(__GNUC__) && __GNUC__ >= 3) || !defined(__INTEL_COMPILER)
+# if (defined(__GNUC__) && __GNUC__ >= 3) &&
!defined(__INTEL_COMPILER)
unsigned (E::*m9)(const psite& p) const = & E::index_of_point;
m9 = 0;
# endif
Index: mln/data/transform.spe.hh
--- mln/data/transform.spe.hh (revision 4054)
+++ mln/data/transform.spe.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -36,9 +37,9 @@
/// Actually the patch was no acceptable solution to the lut problem
/// (for some values, we cannot compute f(v) to put into the lut...)
-# ifndef MLN_LEVEL_TRANSFORM_HH
+# ifndef MLN_DATA_TRANSFORM_HH
# error "Forbidden inclusion of *.spe.hh"
-# endif // ! MLN_LEVEL_TRANSFORM_HH
+# endif // ! MLN_DATA_TRANSFORM_HH
# include <mln/core/concept/image.hh>
# include <mln/core/concept/function.hh>
Index: mln/data/apply.spe.hh
--- mln/data/apply.spe.hh (revision 4054)
+++ mln/data/apply.spe.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2009 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -26,14 +27,13 @@
#ifndef MLN_DATA_APPLY_SPE_HH
# define MLN_DATA_APPLY_SPE_HH
-/*! \file
- *
- * \brief Specializations for mln::data::apply.
- */
+/// \file
+///
+/// \brief Specializations for mln::data::apply.
-# ifndef MLN_LEVEL_APPLY_HH
+# ifndef MLN_DATA_APPLY_HH
# error "Forbidden inclusion of *.spe.hh"
-# endif // ! MLN_LEVEL_APPLY_HH
+# endif // ! MLN_DATA_APPLY_HH
# include <mln/core/concept/image.hh>
# include <mln/core/concept/function.hh>
Index: tests/data/transform.cc
--- tests/data/transform.cc (revision 4054)
+++ tests/data/transform.cc (working copy)
@@ -35,23 +35,32 @@
#include <mln/core/image/dmorph/sub_image.hh>
#include <mln/core/image/dmorph/extension_val.hh>
-
#include <mln/data/fill.hh>
#include <mln/data/transform.hh>
#include <mln/data/paste.hh>
-
-#include <mln/core/var.hh>
-
#include <mln/fun/p2b/chess.hh>
#include <mln/fun/p2v/iota.hh>
-#include <mln/debug/iota.hh>
-#include <mln/debug/println.hh>
+namespace my
+{
-struct mysqrt : mln::Function_v2v<mysqrt>
+ template <typename I>
+ void iota(I& ima)
+ {
+ unsigned i = 0;
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ {
+ ima(p) = i * i;
+ i += 1;
+ }
+ }
+
+ struct sqrt : mln::Function_v2v<sqrt>
{
typedef unsigned short result;
+
template <typename T>
result operator()(T c) const
{
@@ -59,20 +68,24 @@
}
};
+} // end of namespace mln
+
int main()
{
using namespace mln;
- const unsigned size = 50;
+ const unsigned size = 5;
+ box2d b = make::box2d(1,1, 3,3);
+
/// image 1d test
{
image1d<unsigned short> ima(size);
image1d<unsigned short> out(size);
- debug::iota(ima);
- out = data::transform(ima, mysqrt());
+ my::iota(ima);
+ out = data::transform(ima, my::sqrt());
box_fwd_piter_<point1d> p(out.domain());
for_all(p)
@@ -85,8 +98,8 @@
image2d<unsigned short> ima(size, size);
image2d<unsigned short> out(size, size);
- debug::iota(ima);
- out = data::transform(ima, mysqrt());
+ my::iota(ima);
+ out = data::transform(ima, my::sqrt());
box_fwd_piter_<point2d> p(out.domain());
for_all(p)
@@ -98,7 +111,7 @@
image2d<unsigned short> ima(size, size);
data::fill_with_value(ima, 51);
- data::transform(ima, mysqrt());
+ data::transform(ima, my::sqrt());
}
@@ -107,8 +120,8 @@
image3d<unsigned short> ima(size, size, size);
image3d<unsigned short> out(size, size, size);
- debug::iota(ima);
- out = data::transform(ima, mysqrt());
+ my::iota(ima);
+ out = data::transform(ima, my::sqrt());
box_fwd_piter_<point3d> p(out.domain());
for_all(p)
@@ -118,20 +131,20 @@
/// pw image test
{
fun::p2v::iota f;
- const pw::image<fun::p2v::iota, box2d> ima(f, make::box2d(2,2, 5,5));
- image2d<unsigned short> out(8, 8);
+ const pw::image<fun::p2v::iota, box2d> ima(f, b);
+ image2d<unsigned short> out(size, size);
- data::fill(out, (short unsigned int)0);
- out = data::transform(ima, mysqrt());
+ data::fill(out, 0u);
+ out = data::transform(ima, my::sqrt());
}
// flat image test
{
- flat_image<short, box2d> ima(5, make::box2d(size, size));
+ flat_image<short, box2d> ima(5, b);
image2d<unsigned short> out(size, size);
- data::fill_with_value(ima, 51);
- out = data::transform(ima, mysqrt());
+ data::fill_with_value(ima, 169);
+ out = data::transform(ima, my::sqrt());
box2d::piter p(out.domain());
for_all(p)
@@ -147,8 +160,8 @@
II ima_if = ima | fun::p2b::chess();
data::fill_with_value(ima, 0);
- debug::iota(ima);
- II out = data::transform(ima_if, mysqrt());
+ my::iota(ima);
+ II out = data::transform(ima_if, my::sqrt());
II::piter p(ima_if.domain());
for_all(p)
@@ -165,10 +178,10 @@
II cast(in);
III out(size, size);
- data::fill(in, (unsigned short)51);
- data::fill(out, (unsigned short)42);
+ data::fill(in, 169u);
+ data::fill(out, 81u);
- out = data::transform(cast, mysqrt());
+ out = data::transform(cast, my::sqrt());
II::piter p(cast.domain());
for_all(p)
@@ -182,10 +195,10 @@
typedef sub_image< image2d<unsigned short>, box2d > III;
I ima(size, size);
- II sub_ima(ima, make::box2d(4,4, 10,10));
+ II sub_ima(ima, b);
- data::fill(ima, 51);
- III out = data::transform(sub_ima, mysqrt());
+ data::fill(ima, 169);
+ III out = data::transform(sub_ima, my::sqrt());
II::piter p(sub_ima.domain());
for_all(p)
@@ -199,10 +212,10 @@
typedef extension_val< image2d<unsigned short> > III;
I ima(size, size);
- II extend_ima(ima, 5);
+ II extend_ima(ima, 169);
- data::fill(ima, 51);
- III out = data::transform(extend_ima, mysqrt());
+ data::fill(ima, 169);
+ III out = data::transform(extend_ima, my::sqrt());
II::piter p(extend_ima.domain());
for_all(p)