Commit 8c83f85b authored by Thierry Geraud's avatar Thierry Geraud
Browse files

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

	Add value cast image morpher.
	
	* tests/value_cast.cc: New.
	* tests/Makefile.am: Update.
	* oln/morpher/value_cast.hh: New.
	* oln/Makefile.am: Update.
	* oln/morpher/internal/image_value_morpher.hh (lvalue): Change
	definition mode from single_vtype to vtypes.



git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@647 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent c7bfe7d0
2006-10-16 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr>
Add value cast image morpher.
* tests/value_cast.cc: New.
* tests/Makefile.am: Update.
* oln/morpher/value_cast.hh: New.
* oln/Makefile.am: Update.
* oln/morpher/internal/image_value_morpher.hh (lvalue): Change
definition mode from single_vtype to vtypes.
2006-10-16 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr>
Add binary value type plus update image hierarchy plugs.
......
......@@ -151,6 +151,7 @@ nobase_oln_HEADERS = \
morpher/identity.hh \
morpher/tags.hh \
morpher/thru_fun.hh \
morpher/value_cast.hh \
\
value/all.hh \
value/default.hh \
......
......@@ -64,7 +64,7 @@ namespace oln
{
// Morpher type.
typedef oln::morpher::tag::identity morpher_type; // FIXME: Wrong!
typedef mlc::undefined lvalue_type;
typedef mlc::undefined value_type;
};
......@@ -75,13 +75,6 @@ namespace oln
typedef mlc::undefined ret;
};
template <typename Image, typename Exact>
struct single_vtype< morpher::internal::image_value_morpher<Image, Exact>,
typedef_::lvalue_type >
{
typedef mlc::undefined ret;
};
namespace morpher
{
......
// 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.
#ifndef OLN_MORPHER_VALUE_CAST
# define OLN_MORPHER_VALUE_CAST
# include <xtd/abstract/open_nary_fun.hh>
# include <xtd/res.hh>
# include <oln/morpher/internal/image_value_morpher.hh>
namespace oln
{
namespace morpher
{
// Forward declaration.
template <typename Image, typename Value> struct value_cast;
} // end of namespace oln::morpher
/// Super type.
template <typename Image, typename Value>
struct set_super_type< morpher::value_cast<Image, Value> >
{
typedef morpher::value_cast<Image, Value> self_t;
typedef morpher::internal::image_value_morpher<Image, self_t> ret;
};
template <typename Image, typename Value>
struct vtypes< morpher::value_cast<Image, Value> >
{
typedef Value value_type;
typedef mlc::false_ is_mutable_type;
};
template <typename Image, typename Value>
struct single_vtype< morpher::value_cast<Image, Value>, typedef_::rvalue_type >
{
typedef Value ret;
};
namespace morpher
{
/// 'Image thru Valuection' morpher.
template <typename Image, typename Value>
class value_cast : public internal::image_value_morpher< Image,
value_cast<Image, Value> >
{
private:
typedef value_cast<Image, Value> self_t;
typedef internal::image_value_morpher<Image, self_t> super_t;
typedef oln_type_of(self_t, psite) psite_t;
typedef oln_type_of(self_t, rvalue) rvalue_t;
public:
value_cast(const Image& image);
};
# ifndef OLN_INCLUDE_ONLY
template <typename Image, typename Value>
value_cast<Image, Value>::value_cast(const Image& image) :
super_t(image)
{
}
# endif
} // end of namespace oln::morpher
template <typename Value, typename I>
morpher::value_cast<I, Value>
value_cast(const abstract::image<I>& ima);
# ifndef OLN_INCLUDE_ONLY
template <typename Value, typename I>
morpher::value_cast<I, Value>
value_cast(const abstract::image<I>& ima)
{
morpher::value_cast<I, Value> tmp(ima.exact());
return tmp;
}
# endif
} // end of namespace oln
#endif // ! OLN_MORPHER_VALUE_CAST
......@@ -40,6 +40,7 @@ check_PROGRAMS = \
\
identity_morpher \
add_neighborhood_morpher \
value_cast \
morphers \
\
fill
......@@ -67,6 +68,7 @@ grey_SOURCES = grey.cc
# Morphers.
identity_morpher_SOURCES = identity_morpher.cc
add_neighborhood_morpher_SOURCES = add_neighborhood_morpher.cc
value_cast_SOURCES = value_cast.cc
morphers_SOURCES = morphers.cc
# Algorithms.
......
// 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::value_cast.cc.
#include <iostream>
#include <oln/basics2d.hh>
#include <oln/value/all.hh>
#include <oln/morpher/value_cast.hh>
template <typename T>
void print(T)
{
std::cout << "?" << std::endl;
}
void print(int)
{
std::cout << "int" << std::endl;
}
void print(float)
{
std::cout << "float" << std::endl;
}
void print(unsigned char)
{
std::cout << "unsigned char" << std::endl;
}
int main()
{
using namespace oln;
using oln::value::gl8;
point2d p(0,0);
{
image2d<int> ima(1,1);
print( value_cast<float>(ima)(p) );
}
{
image2d<bool> ima(1,1);
print( value_cast<int>(ima)(p) );
}
{
image2d<gl8> ima(1,1);
print( value_cast<unsigned char>(ima)(p) );
}
}
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