Commit 9296b4a9 authored by Thierry Geraud's avatar Thierry Geraud
Browse files

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.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@860 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent ae69f455
2007-03-09 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.
2007-03-08 Thierry Geraud <thierry.geraud@lrde.epita.fr>
Add the notion of image plus neighborhood and the underlying
......
......@@ -215,7 +215,7 @@ namespace oln
{
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 @@ namespace oln
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 @@ namespace oln
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 @@ namespace oln
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 @@ namespace oln
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 @@ namespace oln
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>
......
......@@ -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 @@ namespace oln
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 @@ namespace oln
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 @@ namespace oln
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 @@ namespace oln
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 @@ namespace oln
stc_decl_associated_type( value );
stc_decl_associated_type( vsite );
# define oln_value(T) oln_typename_shortcut__(T, value)
} // end of namespace oln
......
......@@ -49,7 +49,8 @@ namespace oln
// 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 @@ namespace oln
// 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());
......
// 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 @@ namespace oln
}
/// 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);
}
// template <typename I, typename F>
// void fill(Mutable_Image<I>& input, const abstract::fun_p2v<F>& fun)
// {
// impl::fill(exact(input), 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>
// 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
......
......@@ -22,26 +22,17 @@ check_PROGRAMS = \
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.
......
// 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 @@ main()
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);
}
// 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();
}
// 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 @@ main()
// 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);
}
// 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 @@ main()
{
// 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.
......
// Copyright (C) 2006 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
// of the GNU General Public License version 2 as published by the
// Free Software Foundation.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this library; see the file COPYING. If not, write to
// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
// Boston, MA 02111-1307, USA.
//
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
/// Test oln::image_entry.
#include <oln/basics2d.hh>
#include <oln/core/image_entry.hh>
namespace my
{
// Forward declaration.
struct image;
// Dummy type.
struct dummy;
}
namespace oln
{
template <>
struct set_super_type < my::image >
{
typedef image_entry< my::image > ret;
};
/// Virtual types associated to my::image.
/// \{
template<>