860: Update tests.

https://svn.lrde.epita.fr/svn/oln/trunk/olena Index: ChangeLog from Thierry Geraud <thierry.geraud@lrde.epita.fr> Update tests. * tests/core/image_entry.cc: Remove; obsolete. * tests/core/window2d.cc, * tests/core/point2d.cc, * tests/core/dpoint2d.cc, * tests/core/at.cc, * tests/core/Makefile.am, * tests/core/grid.cc, * tests/core/image2d.cc, * tests/core/npoints.cc, * oln/debug/print_nbh.hh, * oln/level/fill.hh: Update. oln/core/concept/image.hh | 12 +-- oln/core/equipment.hh | 23 +++++- oln/debug/print_nbh.hh | 6 + oln/level/fill.hh | 164 ++++++++++++++++------------------------------ tests/core/Makefile.am | 9 -- tests/core/at.cc | 19 ++--- tests/core/dpoint2d.cc | 10 +- tests/core/grid.cc | 18 ++--- tests/core/image2d.cc | 16 ++-- tests/core/npoints.cc | 8 +- tests/core/point2d.cc | 9 -- tests/core/window2d.cc | 54 ++++----------- 12 files changed, 145 insertions(+), 203 deletions(-) Index: tests/core/window2d.cc --- tests/core/window2d.cc (revision 859) +++ tests/core/window2d.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2006 EPITA Research and Development Laboratory +// Copyright (C) 2006, 2007 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 @@ -27,40 +27,25 @@ /// Test oln::window2d. -#include <oln/basics2d.hh> -#include <oln/debug/print.hh> -#include <oln/io/pnm.hh> -#include <oln/morpher/add_neighborhood.hh> +#include <oln/core/2d/image2d.hh> +#include <oln/core/2d/window2d.hh> -#include "data.hh" namespace test { template <typename I, typename W> - void run(const oln::abstract::image<I>& ima, - const oln::abstract::window<W>& win) + unsigned run(const oln::Point_Wise_Accessible_Image<I>& input, + const oln::Window<W>& win) { - oln_piter(I) p(ima.topo()); - oln_qiter(I) q(p, win); + oln_piter(I) p(input.points()); + oln_qiter(W) q(p, win); + unsigned count = 0; for_all(p) - { -#if 0 - // Disable the display to speed up the test. - std::cout << unsigned(ima(p)) << ": "; -#endif for_all(q) - { -#if 0 - // Likewise. - std::cout << unsigned(ima(q)) << " "; -#endif - } -#if 0 - // Likewise. - std::cout << std::endl; -#endif - } + if (input.has(q)) + ++count; + return count; } } @@ -70,16 +55,9 @@ { using namespace oln; - image2d<unsigned char> ima = io::load_pgm(rdata("lena32.pgm")); -#if 0 - // Disable the display to speed up the test. - debug::println(ima); -#endif - - window2d win; - win - .add(dpoint2d(-1, 0)) - .add(dpoint2d(-2, 0)); - - test::run(ima, win); + image2d<bool> ima(3, 3); + // 4 + 6 + 4 + + // 6 + 9 + 6 + + // 4 + 6 + 4 = 49 + assert(test::run(ima, win3x3) = 49); } Index: tests/core/point2d.cc --- tests/core/point2d.cc (revision 859) +++ tests/core/point2d.cc (working copy) @@ -25,19 +25,14 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#include <mlc/assert.hh> -#include <mlc/is_a.hh> -// FIXME: There is an inter-dependency between point2d and dpoint2d. -// Maybe we'll solve this with the interface/implementation separation? #include <oln/core/2d/point2d.hh> -#include <oln/core/2d/dpoint2d.hh> int main() { - typedef oln::point2d_<int> point_t; + typedef oln::point2d point_t; mlc::assert_< - mlc_is_a_( point_t, oln::internal::point_nd ) + mlc_is_a_( point_t, oln::Point )
::check(); } Index: tests/core/dpoint2d.cc --- tests/core/dpoint2d.cc (revision 859) +++ tests/core/dpoint2d.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2006 EPITA Research and Development Laboratory +// Copyright (C) 2006, 2007 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 @@ -29,17 +29,17 @@
#include <mlc/assert.hh> #include <mlc/is_a.hh> -#include <oln/basics2d.hh> +#include <oln/core/2d/dpoint2d.hh> int main() { - typedef oln::dpoint2d_<int> dpoint_t; + typedef oln::dpoint2d dpoint_t; mlc::assert_< - mlc_is_a_( dpoint_t, oln::internal::dpoint_nd ) + mlc_is_a_( dpoint_t, oln::Dpoint )
::check();
- typedef oln_vtype_(dpoint_t, vec) vec_t; + typedef dpoint_t::vec_t vec_t; mlc::assert_< mlc_is_a_( vec_t, mlc_comma_1(xtd::vec< 2u, int >) ) >::check(); } Index: tests/core/at.cc --- tests/core/at.cc (revision 859) +++ tests/core/at.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2006 EPITA Research and Development Laboratory +// Copyright (C) 2006, 2007 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 @@ -26,11 +26,9 @@ // Public License. #include <cassert> -// FIXME: Don't include oln/basics2d.hh, which is too big. -// (Fix.) -#include <oln/basics1d.hh> -#include <oln/basics2d.hh> -#include <oln/morpher/add_neighborhood.hh> +// FIXME: Disabled #include <oln/basics1d.hh> +#include <oln/core/2d/image2d.hh> +#include <oln/core/2d/neighb2d.hh> int @@ -46,8 +44,9 @@ assert(ima(p) = 51); - image1d<int> sig(1); - point1d i(0); - (sig + c2).at(0) = 51; - assert(sig(i) = 51); + // FIXME: Disabled +// image1d<int> sig(1); +// point1d i(0); +// (sig + c2).at(0) = 51; +// assert(sig(i) = 51); } Index: tests/core/Makefile.am --- tests/core/Makefile.am (revision 859) +++ tests/core/Makefile.am (working copy) @@ -22,26 +22,17 @@ dpoint2d \ point2d \ grid \ - image_entry \ - image1d \ image2d \ - image3d \ npoints \ - pw_value \ window2d \ - \ at # Images and auxiliary structures. dpoint2d_SOURCES = dpoint2d.cc point2d_SOURCES = point2d.cc grid_SOURCES = grid.cc -image_entry_SOURCES = image_entry.cc -image1d_SOURCES = image1d.cc image2d_SOURCES = image2d.cc -image3d_SOURCES = image3d.cc npoints_SOURCES = npoints.cc -pw_value_SOURCES = pw_value.cc window2d_SOURCES = window2d.cc # Methods. Index: tests/core/grid.cc --- tests/core/grid.cc (revision 859) +++ tests/core/grid.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2006 EPITA Research and Development Laboratory +// Copyright (C) 2006, 2007 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 @@ -28,10 +28,11 @@ /// Test grids. #include <cassert> -#include <oln/core/1d/aliases.hh> -#include <oln/core/2d/aliases.hh> -#include <oln/core/3d/aliases.hh> -#include <oln/core/gen/grid.hh> +#include <oln/core/2d/grid2d.hh> +// FIXME: Disabled. +// #include <oln/core/1d/aliases.hh> +// #include <oln/core/3d/aliases.hh> + int main() @@ -39,7 +40,8 @@ // The extra pairs of parenthesis around mlc_value are needed to // prevent the assert macro from interpreting the arguments of // mlc_value as its own. - assert((mlc_value(oln_vtype_(oln::grid1d, dimvalue))) = 1); - assert((mlc_value(oln_vtype_(oln::grid2d, dimvalue))) = 2); - assert((mlc_value(oln_vtype_(oln::grid3d, dimvalue))) = 3); + assert((mlc_value(oln::grid2d::dim)) = 2); + // FIXME: Disabled. +// assert((mlc_value(oln::grid1d::dim)) = 1); +// assert((mlc_value(oln::grid3d::dim)) = 3); } Index: tests/core/image2d.cc --- tests/core/image2d.cc (revision 859) +++ tests/core/image2d.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2006 EPITA Research and Development Laboratory +// Copyright (C) 2006, 2007 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 @@ -30,7 +30,7 @@ #include <cassert> // FIXME: We should not include oln/basics2d.hh, but // oln/core/2d/image2d.hh (and oln/core/2d/neigh2d.hh ?). -#include <oln/basics2d.hh> +#include <oln/core/2d/image2d.hh> #include <oln/level/fill.hh> int @@ -38,24 +38,24 @@ { // Fill a 2D image using its iterator. oln::image2d<char> ima1(3, 3); - oln_vtype_(oln::image2d<char>, piter) p1(ima1.topo()); + oln::image2d<char>::piter p1(ima1.points()); for_all(p1) ima1(p1) = 1; // Fill a 2D image using a classic loop. - oln::image2d<int> ima2(ima1.topo()); + oln::image2d<int> ima2(ima1.points()); for (unsigned i = 0; i < 3; ++i) for (unsigned j = 0; j < 3; ++j) - ima2(oln::point2d(i, j)) = 2; + ima2.at(i, j) = 2; // Fill a 2D image using the routine oln::level::fill. - oln::image2d<long> ima3(ima1.topo()); + oln::image2d<long> ima3(ima1.points()); oln::level::fill(ima3, 3); // Add the three images. - oln::image2d<long> sum(ima1.topo()); - oln_vtype_(oln::image2d<long>, piter) p(sum.topo()); + oln::image2d<long> sum(ima1.points()); + oln::image2d<long>::piter p(sum.points()); for_all(p) sum(p) = ima1(p) + ima2(p) + ima3(p); // And check the sum. Index: tests/core/npoints.cc --- tests/core/npoints.cc (revision 859) +++ tests/core/npoints.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2006 EPITA Research and Development Laboratory +// Copyright (C) 2006, 2007 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 @@ -28,13 +28,13 @@ /// Test image2d. #include <cassert> -#include <oln/basics2d.hh> +#include <oln/core/2d/image2d.hh> template <typename I> -unsigned npoints(const oln::abstract::image<I>& input) +unsigned npoints(const oln::Image<I>& input) { - oln_vtype(I, piter) p(input.topo()); + typename I::piter p(input.points()); unsigned count = 0; for_all(p) ++count; Index: oln/debug/print_nbh.hh --- oln/debug/print_nbh.hh (revision 859) +++ oln/debug/print_nbh.hh (working copy) @@ -49,7 +49,8 @@ // Image template <typename I> - void print_nbh(const Image<I>&, const I& input, std::ostream& ostr) + void print_nbh(const Image<I>&, + const I& input, std::ostream& ostr) { typename I::fwd_piter p(input.points()); typename I::fwd_niter n(p, input.nbhood()); @@ -67,7 +68,8 @@ // Point_Wise_Accessible_Image template <typename I> - void print_nbh(const Point_Wise_Accessible_Image<I>&,const I& input, std::ostream& ostr) + void print_nbh(const Point_Wise_Accessible_Image<I>&, + const I& input, std::ostream& ostr) { typename I::fwd_piter p(input.points()); typename I::fwd_niter n(p, input.nbhood()); Index: oln/level/fill.hh --- oln/level/fill.hh (revision 859) +++ oln/level/fill.hh (working copy) @@ -1,5 +1,5 @@ -// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 EPITA Research and -// Development Laboratory +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 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 @@ -29,12 +29,8 @@ #ifndef OLN_LEVEL_FILL_HH # define OLN_LEVEL_FILL_HH -# include <iostream> - -# include <oln/core/abstract/image.hh> -# include <oln/core/abstract/image/value_wise_accessibility/hierarchy.hh> -# include <oln/core/abstract/iterator.hh> -# include <oln/core/abstract/functions.hh> +# include <oln/core/concept/image.hh> +// # include <oln/core/concept/function.hh> namespace oln @@ -46,159 +42,119 @@ } - /// Fwd decl. - template <typename I, typename V> - I& operator<<(abstract::mutable_image<I>& input, const V values[]); - - /// Fwd decl. - template <typename I> - I& operator<<(abstract::mutable_image<I>& input, const oln_value(I)& value); - - namespace level { - /// Fwd decl. + /// Fwd decls. + template <typename I> - void fill(abstract::mutable_image<I>& input, const oln_value(I)& value); + void fill(Mutable_Image<I>& input, const oln_value(I)& value); - /// Fwd decl. template <typename I, typename V> - void fill(abstract::mutable_image<I>& input, const V values[]); + void fill(Mutable_Image<I>& input, const V values[]); - /// Fwd decl. template <typename I, typename V, typename P> - void fill(abstract::mutable_image<I>& input, V (*fun)(const P&)); + void fill(Mutable_Image<I>& input, V (*fun)(const P&)); - /// Fwd decl. - template <typename I, typename F> - void fill(abstract::mutable_image<I>& input, const abstract::fun_p2v<F>& fun); - /// Fwd decl. - template <typename I> - void fill(abstract::mutable_image_being_value_wise_random_accessible<I>& input, - const oln_value(I)& value); + + // FIXME: Inactivated. + +// template <typename I, typename F> +// void fill(Mutable_Image<I>& input, const abstract::fun_p2v<F>& fun); + +// template <typename I> +// void fill(Value_Wise_Mutable_Image<I>& input, const oln_value(I)& value); # ifndef OLN_INCLUDE_ONLY + namespace impl { - /// Generic version. template <typename I> - void fill(abstract::mutable_image<I>& input, const oln_value(I)& value) + void fill(Mutable_Image<I>& input, const oln_value(I)& value) { - oln_piter(I) p(input.topo()); + oln_piter(I) p(input.points()); for_all(p) input(p) = value; } - /// Generic version. +// template <typename I> +// void fill(Value_Wise_Mutable_Image<I>& input, +// const oln_value(I)& value) +// { +// oln_viter(I) v(input); +// for_all(v) +// input.value_(v) = value; +// } + template <typename I, typename V> - void fill(abstract::mutable_image<I>& input, const V values[]) + void fill(Mutable_Image<I>& input, const V values[]) { - oln_piter(I) p(input.topo()); + oln_piter(I) p(input.points()); unsigned i = 0; for_all(p) input(p) = values[i++]; } - /// Generic version. template <typename I, typename V, typename P> - void fill(abstract::mutable_image<I>& input, V (*fun)(const P&)) + void fill(Mutable_Image<I>& input, V (*fun)(const P&)) { - oln_piter(I) p(input.topo()); - unsigned i = 0; + oln_piter(I) p(input.points()); for_all(p) input(p) = fun(p); } - /// Generic version. - template <typename I, typename F> - void fill(abstract::mutable_image<I>& input, const abstract::fun_p2v<F>& fun) - { - oln_piter(I) p(input.topo()); - for_all(p) - input(p) = fun.exact()(p); - } - - /// Version specialized for mutable images being value-wise - /// random accessible. - template <typename I> - void fill(abstract::mutable_image_being_value_wise_random_accessible<I>& input, - const oln_value(I)& value) - { - // FIXME: We should not need to call exact() here. - oln_viter(I) v(input.exact()); - for_all(v) - input.value(v) = value; - } +// template <typename I, typename F> +// void fill(Mutable_Image<I>& input, const abstract::fun_p2v<F>& fun) +// { +// oln_piter(I) p(input.points()); +// for_all(p) +// input(p) = fun.exact()(p); +// } } // end of namespace oln::level::impl - /// Facade. + + /// Facades. + template <typename I> - void fill(abstract::mutable_image<I>& input, const oln_value(I)& value) + void fill(Mutable_Image<I>& input, const oln_value(I)& value) { - impl::fill(input.exact(), value); + impl::fill(exact(input), value); } - /// Facade. template <typename I, typename V> - void fill(abstract::mutable_image<I>& input, const V values[]) + void fill(Mutable_Image<I>& input, const V values[]) { - return impl::fill(input.exact(), values); + impl::fill(exact(input), values); } - /// Facade. template <typename I, typename V, typename P> - void fill(abstract::mutable_image<I>& input, V (*fun)(const P&)) + void fill(Mutable_Image<I>& input, V (*fun)(const P&)) { - return impl::fill(input.exact(), fun); + impl::fill(exact(input), fun); } - /// Facade. - template <typename I, typename F> - void fill(abstract::mutable_image<I>& input, const abstract::fun_p2v<F>& fun) - { - return impl::fill(input.exact(), fun); - } - - /// Facade. - template <typename I> - void fill(abstract::mutable_image_being_value_wise_random_accessible<I>& input, - const oln_value(I)& value) - { - return impl::fill(input.exact(), value); - } +// template <typename I, typename F> +// void fill(Mutable_Image<I>& input, const abstract::fun_p2v<F>& fun) +// { +// impl::fill(exact(input), fun); +// } + +// template <typename I> +// void fill(Value_Wise_Mutable_Image<I>& input, const oln_value(I)& value) +// { +// impl::fill(exact(input), value); +// } # endif } // end of namespace oln::level - -# ifndef OLN_INCLUDE_ONLY - - /// Fwd decl. - template <typename I, typename V> - I& operator<<(abstract::mutable_image<I>& input, const V values[]) - { - level::fill(input, values); - return input.exact(); - } - - /// Fwd decl. - template <typename I> - I& operator<<(abstract::mutable_image<I>& input, const oln_value(I)& value) - { - level::fill(input, value); - return input.exact(); - } - -# endif - } // end of namespace oln Index: oln/core/concept/image.hh --- oln/core/concept/image.hh (revision 859) +++ oln/core/concept/image.hh (working copy) @@ -215,7 +215,7 @@ { stc_typename(vsite); stc_typename(rvaluep); - rvaluep value(const vsite& v) const; + rvaluep value_(const vsite& v) const; protected: Value_Wise_Accessible_Image(); @@ -232,7 +232,7 @@ using Value_Wise_Accessible_Image<Exact>::value; stc_typename(lvaluep); - lvaluep value(const vsite& v); + lvaluep value_(const vsite& v); protected: Value_Wise_Mutable_Image(); @@ -440,7 +440,7 @@ template <typename Exact> typename Value_Wise_Accessible_Image<Exact>::rvaluep - Value_Wise_Accessible_Image<Exact>::value(const typename Value_Wise_Accessible_Image<Exact>::vsite& v) const + Value_Wise_Accessible_Image<Exact>::value_(const typename Value_Wise_Accessible_Image<Exact>::vsite& v) const { return exact(this)->impl_value_read(v); } @@ -454,7 +454,7 @@ template <typename Exact> typename Value_Wise_Mutable_Image<Exact>::lvaluep - Value_Wise_Mutable_Image<Exact>::value(const typename Value_Wise_Accessible_Image<Exact>::vsite& v) + Value_Wise_Mutable_Image<Exact>::value_(const typename Value_Wise_Accessible_Image<Exact>::vsite& v) { return exact(this)->impl_value_read_write(v); } @@ -514,7 +514,7 @@ Point_Wise_Accessible_Image_2D<Exact>::impl_at(coord row, coord col) const { typename Point_Wise_Accessible_Image_2D<Exact>::point p(row, col); - return this->at(p); + return this->operator()(p); } template <typename Exact> @@ -536,7 +536,7 @@ Point_Wise_Mutable_Image_2D<Exact>::impl_at(coord row, coord col) { typename Point_Wise_Mutable_Image_2D<Exact>::point p(row, col); - return this->at(p); + return this->operator()(p); } template <typename Exact> Index: oln/core/equipment.hh --- oln/core/equipment.hh (revision 859) +++ oln/core/equipment.hh (working copy) @@ -28,12 +28,14 @@ #ifndef OLN_CORE_EQUIPMENT_HH # define OLN_CORE_EQUIPMENT_HH -# include <cassert> -# include <mlc/value.hh> # include <mlc/contract.hh> # include <oln/stc/scoop.hh> // FIXME: Remove "oln/" later. +# define oln_typename_shortcut__(Type, Alias) typename Type::Alias + + + namespace oln { @@ -45,6 +47,10 @@ stc_decl_associated_type( bkd_qiter ); stc_decl_associated_type( box ); +# define oln_bkd_niter(T) oln_typename_shortcut__(T, bkd_niter) +# define oln_bkd_piter(T) oln_typename_shortcut__(T, bkd_piter) +# define oln_bkd_qiter(T) oln_typename_shortcut__(T, bkd_qiter) + // c stc_decl_associated_type( coord ); stc_decl_associated_type( ch_value ); @@ -59,6 +65,10 @@ stc_decl_associated_type( fwd_piter ); stc_decl_associated_type( fwd_qiter ); +# define oln_fwd_niter(T) oln_typename_shortcut__(T, fwd_niter) +# define oln_fwd_piter(T) oln_typename_shortcut__(T, fwd_piter) +# define oln_fwd_qiter(T) oln_typename_shortcut__(T, fwd_qiter) + // g stc_decl_associated_type( grid ); @@ -75,6 +85,8 @@ stc_decl_associated_type( nbh ); stc_decl_associated_type( niter ); +# define oln_niter(T) oln_typename_shortcut__(T, niter) + // o stc_decl_associated_type( oper ); stc_decl_associated_type( output ); @@ -85,9 +97,14 @@ stc_decl_associated_type( pset ); stc_decl_associated_type( psite ); +# define oln_piter(T) oln_typename_shortcut__(T, piter) +# define oln_point(T) oln_typename_shortcut__(T, point) + // q stc_decl_associated_type( qiter ); +# define oln_qiter(T) oln_typename_shortcut__(T, qiter) + // r stc_decl_associated_type( right ); stc_decl_associated_type( rvalue ); @@ -103,6 +120,8 @@ stc_decl_associated_type( value ); stc_decl_associated_type( vsite ); +# define oln_value(T) oln_typename_shortcut__(T, value) + } // end of namespace oln
participants (1)
-
Thierry Geraud