Commit a720abc8 authored by Thierry Geraud's avatar Thierry Geraud
Browse files

2006-10-24 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr>

	Add point-wise values.
	
	* tests/core/pw_value.cc: New.
	* tests/core/Makefile.am: Update.
	* oln/core/gen/pw_value.hh: New.
	* oln/Makefile.am: Update.



git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@676 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 25cb4f81
2006-10-24 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr>
Add point-wise values.
* tests/core/pw_value.cc: New.
* tests/core/Makefile.am: Update.
* oln/core/gen/pw_value.hh: New.
* oln/Makefile.am: Update.
2006-10-24 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr>
Add a morpher to count read-write ops.
......
......@@ -123,6 +123,7 @@ nobase_oln_HEADERS = \
core/gen/grid.hh \
core/gen/mapimage.hh \
core/gen/neighb.hh \
core/gen/pw_value.hh \
core/gen/topo_add_nbh.hh \
core/gen/topo_bbox.hh \
core/gen/topo_lbbox.hh \
......
// Copyright (C) 2005, 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.
#ifndef OLN_CORE_GEN_PW_VALUE_HH
# define OLN_CORE_GEN_PW_VALUE_HH
# include <oln/core/abstract/image.hh>
# include <xtd/abstract/meta_nary_fun.hh>
# include <xtd/math.hh>
namespace xtd
{
// Fwd decl.
template <typename I>
class pw_value_type;
template <typename I, typename A>
struct res_< pw_value_type<I>, A >
{
typedef oln_rvalue(I) ret;
};
template <typename I>
class pw_value_type : public xtd::abstract::meta_nary_fun_< 1, pw_value_type<I> >
{
public:
pw_value_type(const I& ima);
template <typename P>
oln_rvalue(I) impl_calc(const P& p) const;
protected:
const I& ima_;
};
# ifndef OLN_INCLUDE_ONLY
template <typename I>
template <typename A>
oln_rvalue(I)
pw_value_type<I>::impl_calc(const A& a) const
{
mlc::assert_< mlc_is_a(A, oln::abstract::point) >::check();
return ima_(a);
}
template <typename I>
pw_value_type<I>::pw_value_type(const I& ima)
: ima_(ima)
{
}
# endif
} // end of namespace xtd
namespace oln
{
template <typename I>
xtd::m1expr_< xtd::pw_value_type<I>, xtd::arg_<1> >
pw_value(const abstract::image<I>& ima)
{
xtd::pw_value_type<I> pwv(ima.exact());
using xtd::_1;
return pwv(_1); // expects one argument (for instance a point) or an expression :)
}
} // end of namespace oln
#endif // ! OLN_CORE_GEN_PW_VALUE_HH
......@@ -27,6 +27,7 @@ check_PROGRAMS = \
image2d \
image3d \
npoints \
pw_value \
window2d \
\
at
......@@ -40,6 +41,7 @@ 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
//
// 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 pw_value.
#include <cassert>
#include <oln/basics2d.hh>
#include <oln/core/gen/pw_value.hh>
int main()
{
using namespace oln;
point2d p(0,0);
image2d<int> ima1(3,3);
ima1(p) = 1;
image2d<float> ima2(3,3);
ima2(p) = 2.3;
double d = ((pw_value(ima1) + 4 * pw_value(ima2)) / .2)(p);
assert(d > 50.9999 and d < 51.0001);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment