URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-23 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Subdirectory display ready for rereading (except median).
Level review.
* mln/level/abs.hh,
* mln/level/all.hh,
* mln/level/memcpy_.hh,
* mln/level/memset_.hh,
* mln/level/paste.hh,
* mln/level/paste.spe.hh,
* mln/level/saturate.hh,
* mln/level/sort_points.hh,
* mln/level/take.hh: Review doc, add precondition and check typo.
Add metal::is_not_const.
* mln/metal/is_not_const.hh: New file for handling check in
memcpy and memset in level.
* mln/metal/all.hh: Add is_not_const header.
Add tests.
* tests/all.cc: New tests, which include all headers all.hh.
---
mln/level/abs.hh | 4 +
mln/level/all.hh | 9 +++-
mln/level/memcpy_.hh | 59 +++++++++++++++++++++++------
mln/level/memset_.hh | 57 +++++++++++++++++++++-------
mln/level/paste.hh | 3 -
mln/level/paste.spe.hh | 2
mln/level/saturate.hh | 14 ++++++
mln/level/sort_points.hh | 12 +++++
mln/level/take.hh | 2
mln/metal/all.hh | 1
mln/metal/is_not_const.hh | 68 +++++++++++++++++++++++++++++++++
tests/all.cc | 93 ++++++++++++++++++++++++++++++++++++++++++++++
12 files changed, 292 insertions(+), 32 deletions(-)
Index: trunk/milena/tests/all.cc
===================================================================
--- trunk/milena/tests/all.cc (revision 0)
+++ trunk/milena/tests/all.cc (revision 1523)
@@ -0,0 +1,93 @@
+// Copyright (C) 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
+// 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.
+
+/*! \file tests/all.cc
+ *
+ * \brief Tests with all headers. (check norris tests)
+ */
+
+
+#include <mln/test/all.hh>
+#include <mln/convert/all.hh>
+#include <mln/estim/all.hh>
+#include <mln/debug/all.hh>
+#include <mln/histo/all.hh>
+#include <mln/pw/all.hh>
+#include <mln/geom/all.hh>
+#include <mln/core/trait/all.hh>
+#include <mln/fun/i2v/all.hh>
+#include <mln/fun/p2b/all.hh>
+#include <mln/fun/p2v/all.hh>
+#include <mln/fun/v2v/all.hh>
+#include <mln/fun/x2x/all.hh>
+#include <mln/fun/all.hh>
+#include <mln/math/all.hh>
+#include <mln/set/all.hh>
+#include <mln/draw/all.hh>
+#include <mln/metal/math/all.hh>
+#include <mln/metal/all.hh>
+#include <mln/morpho/all.hh>
+#include <mln/io/pfm/all.hh>
+#include <mln/io/pgm/all.hh>
+#include <mln/io/fits/all.hh>
+#include <mln/io/ppm/all.hh>
+#include <mln/io/pbm/all.hh>
+#include <mln/io/pnm/all.hh>
+#include <mln/io/all.hh>
+#include <mln/level/naive/all.hh>
+#include <mln/level/approx/all.hh>
+#include <mln/level/all.hh>
+#include <mln/arith/all.hh>
+#include <mln/linear/all.hh>
+#include <mln/logical/all.hh>
+#include <mln/canvas/morpho/all.hh>
+#include <mln/canvas/browsing/all.hh>
+#include <mln/canvas/all.hh>
+#include <mln/accu/all.hh>
+#include <mln/norm/all.hh>
+#include <mln/value/internal/all.hh>
+#include <mln/value/all.hh>
+#include <mln/value/concept/all.hh>
+#include <mln/value/builtin/all.hh>
+#include <mln/make/all.hh>
+#include <mln/border/all.hh>
+#include <mln/labeling/all.hh>
+#include <mln/util/all.hh>
+#include <mln/trait/all.hh>
+#include <mln/trait/value/all.hh>
+#include <mln/trait/op/all.hh>
+#include <mln/tag/all.hh>
+#include <mln/trace/all.hh>
+#include <mln/literal/all.hh>
+#include <mln/display/all.hh>
+#include <mln/win/all.hh>
+
+
+int main ()
+{
+
+}
Index: trunk/milena/mln/metal/is_not_const.hh
===================================================================
--- trunk/milena/mln/metal/is_not_const.hh (revision 0)
+++ trunk/milena/mln/metal/is_not_const.hh (revision 1523)
@@ -0,0 +1,68 @@
+// Copyright (C) 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
+// 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 MLN_METAL_IS_NOT_CONST_HH
+# define MLN_METAL_IS_NOT_CONST_HH
+
+/*!
+ * \file mln/metal/is_not_const.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/metal/bool.hh>
+
+
+# define mlc_is_not_const(T) mln::metal::is_not_const< T >
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ template <typename T>
+ struct is_not_const : true_
+ {};
+
+ template <typename T>
+ struct is_not_const< const T > : false_
+ {};
+
+ template <typename T>
+ struct is_not_const< const T& > : false_
+ {};
+
+ // FIXME: What about "T*const" and "const T*"?
+
+ } // end of namespace mln::metal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_METAL_IS_NOT_CONST_HH
Index: trunk/milena/mln/metal/all.hh
===================================================================
--- trunk/milena/mln/metal/all.hh (revision 1522)
+++ trunk/milena/mln/metal/all.hh (revision 1523)
@@ -63,6 +63,7 @@
# include <mln/metal/const.hh>
# include <mln/metal/unconst.hh>
# include <mln/metal/is_const.hh>
+# include <mln/metal/is_not_const.hh>
# include <mln/metal/unptr.hh>
# include <mln/metal/unref.hh>
Index: trunk/milena/mln/level/sort_points.hh
===================================================================
--- trunk/milena/mln/level/sort_points.hh (revision 1522)
+++ trunk/milena/mln/level/sort_points.hh (revision 1523)
@@ -49,7 +49,7 @@
{
/*! Sort points the image \p input through a function \p f to set
- * the \p output image.
+ * the \p output image in increasing way.
*
* \param[in] input The input image.
*
@@ -58,6 +58,16 @@
template <typename I>
p_array<mln_point(I)> sort_points_increasing(const Image<I>& input);
+ /*! Sort points the image \p input through a function \p f to set
+ * the \p output image in decreasing way.
+ *
+ * \param[in] input The input image.
+ *
+ * \pre \p input.has_data
+ */
+ template <typename I>
+ p_array<mln_point(I)> sort_points_decreasing(const Image<I>& input);
+
# ifndef MLN_INCLUDE_ONLY
Index: trunk/milena/mln/level/take.hh
===================================================================
--- trunk/milena/mln/level/take.hh (revision 1522)
+++ trunk/milena/mln/level/take.hh (revision 1523)
@@ -53,6 +53,8 @@
* This routine runs: \n
* for all p of \p input, \p a.take( \p input(p) ) \n
*
+ * \pre \p input has to be initialized.
+ *
* \warning This routine does not perform a.init().
*/
template <typename A, typename I>
Index: trunk/milena/mln/level/saturate.hh
===================================================================
--- trunk/milena/mln/level/saturate.hh (revision 1522)
+++ trunk/milena/mln/level/saturate.hh (revision 1523)
@@ -53,6 +53,9 @@
* The saturation is based on the min and max values of the output
* value type. This assumes that the range of values in the input
* image is larger than the one of the output image.
+ *
+ * \pre \p input and \p output have to own the same domain.
+ *
*/
template <typename I, typename O>
void saturate(const Image<I>& input, Image<O>& output);
@@ -64,6 +67,9 @@
* \param[in] min The minimum output value.
* \param[in] max The maximum output value.
* \param[out] output The output image.
+ *
+ * \pre \p input and \p output have to own the same domain.
+ *
*/
template <typename I, typename O>
void saturate(const Image<I>& input,
@@ -75,7 +81,10 @@
*
* \param[in,out] input The input image.
* \param[in] min The minimum output value.
- * \param[in] max The maximum output value.
+ * \param[in] max The maximum output value
+ *
+ * \pre \p input has to be initialized.
+ *
*/
template <typename I>
void saturate_inplace(Image<I>& input,
@@ -90,6 +99,7 @@
trace::entering("level::saturate");
mln_precondition(exact(input).domain() == exact(output).domain());
+
fun::v2v::saturate<mln_value(O)> f;
level::transform(input, f, output);
@@ -104,6 +114,7 @@
trace::entering("level::saturate");
mln_precondition(exact(input).domain() == exact(output).domain());
+
fun::v2v::saturate<mln_value(O)> f(min, max);
level::transform(input, f, output);
@@ -117,6 +128,7 @@
trace::entering("level::saturate_inplace");
mln_precondition(exact(input).has_data());
+
fun::v2v::saturate<mln_value(I)> f(min, max);
level::apply(input, f);
Index: trunk/milena/mln/level/memcpy_.hh
===================================================================
--- trunk/milena/mln/level/memcpy_.hh (revision 1522)
+++ trunk/milena/mln/level/memcpy_.hh (revision 1523)
@@ -37,7 +37,7 @@
# include <mln/core/concept/image.hh>
# include <mln/core/pixel.hh>
-
+# include <mln/metal/is_not_const.hh>
namespace mln
{
@@ -52,7 +52,13 @@
* \param[in] src The source pixel (to get values).
* \param[in] n The number of pixels to copy.
*
- * \pre FIXME: !
+ * \pre \p src has to be initialized.
+ * \pre \p dest has to be initialized.
+ * \pre \p src and dest image values have to own the same sizeof.
+ * \pre \p dest pixel has to be on \p dest image domain.
+ * \pre \p src pixel has to be on \p src image domain.
+ * \pre \p dest + \p n has to be on \p dest image domain.
+ * \pre \p src + \p n has to be on \p src image domain.
*/
template <typename Pd, typename Ps>
void memcpy_(Generalized_Pixel<Pd>& dest, const Generalized_Pixel<Ps>& src,
@@ -61,20 +67,16 @@
# ifndef MLN_INCLUDE_ONLY
+ namespace impl
+ {
+
template <typename Pd, typename Ps>
- void memcpy_(Generalized_Pixel<Pd>& dest_, const Generalized_Pixel<Ps>& src_,
- std::size_t n)
+ void memcpy__(Pd& dest, const Ps& src, std::size_t n)
{
+ trace::entering("level::impl::memcpy__");
+
typedef mln_image(Pd) Id;
- // FIXME: metal::is_not_const<Id>::check();
typedef mln_image(Ps) Is;
- Pd& dest = internal::force_exact<Pd>(dest_);
- Ps& src = internal::force_exact<Ps>(src_);
-
- mln_precondition(sizeof(mln_value(Id)) == sizeof(mln_value(Is)));
- mln_precondition(dest.ima().has_data());
- mln_precondition(src.ima().has_data());
- // FIXME: Add precondition about n.
if (n == 0)
{
@@ -100,6 +102,39 @@
for (std::size_t i = 0; i < n; ++i)
*p_d++ = *p_s++;
}
+
+ trace::exiting("level::impl::memcpy__");
+ }
+
+ }
+
+ template <typename Pd, typename Ps>
+ void memcpy_(Generalized_Pixel<Pd>& dest_, const Generalized_Pixel<Ps>& src_,
+ std::size_t n)
+ {
+ trace::entering("level::memcpy_");
+
+ typedef mln_image(Pd) Id;
+ metal::is_not_const<Id>::check();
+ typedef mln_image(Ps) Is;
+ Pd& dest = internal::force_exact<Pd>(dest_);
+ Ps& src = internal::force_exact<Ps>(src_);
+
+ mln_precondition(sizeof(mln_value(Id)) == sizeof(mln_value(Is)));
+ mln_precondition(dest.ima().has_data());
+ mln_precondition(src.ima().has_data());
+
+ mln_precondition(& dest.val() >= & dest.ima()[0]);
+ mln_precondition(& dest.val() < & dest.ima()[0] + dest.ima().ncells());
+ mln_precondition(& dest.val() + n <= & dest.ima()[0] + dest.ima().ncells());
+
+ mln_precondition(& src.val() >= & src.ima()[0]);
+ mln_precondition(& src.val() < & src.ima()[0] + src.ima().ncells());
+ mln_precondition(& src.val() + n <= & src.ima()[0] + src.ima().ncells());
+
+ impl::memcpy__(dest, src, n);
+
+ trace::exiting("level::memcpy_");
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/level/memset_.hh
===================================================================
--- trunk/milena/mln/level/memset_.hh (revision 1522)
+++ trunk/milena/mln/level/memset_.hh (revision 1523)
@@ -35,7 +35,7 @@
# include <mln/core/concept/image.hh>
# include <mln/core/pixel.hh>
-
+# include <mln/metal/is_not_const.hh>
namespace mln
{
@@ -49,7 +49,9 @@
* \param[in] v The value to set pixels with.
* \param[in] n The number of pixels to set.
*
- * \pre FIXME: !
+ * \pre \p pix image has to be initialized.
+ * \pre \p pix has to be on \p pix image domain.
+ * \pre \p pix + \p n has to be on \p pix image domain.
*/
template <typename P>
void memset_(Generalized_Pixel<P>& pix,
@@ -63,7 +65,9 @@
* \param[in] v The value to set to points.
* \param[in] n The number of points to set.
*
- * \pre \p input has to be initialized. FIXME: More.
+ * \pre \p input image has to be initialized.
+ * \pre \p input has to own \p p.
+ * \pre \p p + \p n is <= \p input size.
*/
template <typename I>
void memset_(I& input, const mln_point(I)& p,
@@ -72,19 +76,15 @@
# ifndef MLN_INCLUDE_ONLY
- template <typename P>
- void memset_(Generalized_Pixel<P>& pix_,
- const mln_value(P)& v, std::size_t n)
+ namespace impl
{
- typedef mln_image(P) I;
- // FIXME: metal::is_not_const<I>::check();
- P& pix = internal::force_exact<P>(pix_);
- mln_precondition(pix.ima().has_data());
- mln_precondition(& pix.val() >= & pix.ima()[0]);
- mln_precondition(& pix.val() < & pix.ima()[0] + pix.ima().ncells());
- mln_precondition(& pix.val() + n <= & pix.ima()[0] + pix.ima().ncells());
+ template <typename P>
+ void memset__(P& pix, const mln_value(P)& v, std::size_t n)
+ {
+ trace::entering("level::impl::memset_");
+ typedef mln_image(P) I;
if (n == 0)
{
return; // no-op
@@ -108,12 +108,39 @@
for (std::size_t i = 0; i < n; ++i)
*ptr++ = v;
}
+
+ trace::exiting("level::impl::memset_");
+ }
+
+ } // end of namespace mln::level::impl
+
+
+ template <typename P>
+ void memset_(Generalized_Pixel<P>& pix_,
+ const mln_value(P)& v, std::size_t n)
+ {
+ trace::entering("level::memset_");
+
+ typedef mln_image(P) I;
+ metal::is_not_const<I>::check();
+
+ P& pix = internal::force_exact<P>(pix_);
+ mln_precondition(pix.ima().has_data());
+ mln_precondition(& pix.val() >= & pix.ima()[0]);
+ mln_precondition(& pix.val() < & pix.ima()[0] + pix.ima().ncells());
+ mln_precondition(& pix.val() + n <= & pix.ima()[0] + pix.ima().ncells());
+
+ impl::memset__(pix, v, n);
+
+ trace::exiting("level::memset_");
}
template <typename I>
void memset_(I& input, const mln_point(I)& p,
const mln_value(I)& v, std::size_t n)
{
+ trace::entering("level::memset_");
+
mlc_is(mln_trait_image_speed(I), trait::image::speed::fastest)::check();
mln_precondition(input.has_data());
@@ -121,7 +148,9 @@
mln_precondition(input.offset_at(p) + n <= input.ncells());
pixel<I> pix(input, p);
- memset_(pix, v, n);
+ impl::memset__(pix, v, n);
+
+ trace::exiting("level::memset_");
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/level/paste.spe.hh
===================================================================
--- trunk/milena/mln/level/paste.spe.hh (revision 1522)
+++ trunk/milena/mln/level/paste.spe.hh (revision 1523)
@@ -48,14 +48,12 @@
namespace impl
{
-
namespace generic
{
template <typename I, typename J>
void paste_(const I& data, J& destination);
}
-
template <typename I, typename J>
void paste_lines_(const I& data, J& destination)
{
Index: trunk/milena/mln/level/abs.hh
===================================================================
--- trunk/milena/mln/level/abs.hh (revision 1522)
+++ trunk/milena/mln/level/abs.hh (revision 1523)
@@ -69,8 +69,10 @@
void abs(const Image<I>& input, Image<O>& output)
{
trace::entering("level::abs");
+
mln_precondition(exact(input).domain() == exact(output).domain());
level::transform(input, fun::v2v::abs<mln_value(I)>(), output);
+
trace::exiting("level::abs");
}
@@ -78,8 +80,10 @@
void abs_inplace(Image<I>& input)
{
trace::entering("level::abs_inplace");
+
mln_precondition(exact(input).has_data());
level::apply(input, fun::v2v::abs<mln_value(I)>());
+
trace::exiting("level::abs_inplace");
}
Index: trunk/milena/mln/level/all.hh
===================================================================
--- trunk/milena/mln/level/all.hh (revision 1522)
+++ trunk/milena/mln/level/all.hh (revision 1523)
@@ -40,8 +40,15 @@
/// Namespace of image processing routines related to pixel levels.
namespace level
{
+
/// Implementation namespace of level namespace.
- namespace impl {}
+ namespace impl {
+
+ /// Generic implementation namespace of level namespace.
+ namespace generic {}
+
+ }
+
}
}
Index: trunk/milena/mln/level/paste.hh
===================================================================
--- trunk/milena/mln/level/paste.hh (revision 1522)
+++ trunk/milena/mln/level/paste.hh (revision 1523)
@@ -99,9 +99,10 @@
template <typename I, typename J>
void paste(const Image<I>& data_, Image<J>& destination_)
{
+ trace::entering("level::paste");
+
const I& data = exact(data_);
J& destination = exact(destination_);
- trace::entering("level::paste");
mlc_is(mln_trait_image_io(J), trait::image::io::write)::check();
mlc_converts_to(mln_value(I), mln_value(J))::check();
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-22 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Review the directory fun and add test.
* mln/fun/x2x/bijective_tr.hh,
* mln/fun/x2x/composed.hh,
* mln/fun/x2x/rotation.hh,
* mln/fun/x2x/translation.hh: Review.
* tests/fun/Makefile.am: Add tests.
* tests/fun/x2x/Makefile.am: Add tests.
* tests/fun_x2x_composed.cc,
* tests/fun_x2x_rotation.cc,
* tests/fun_x2x_translation.cc: Rename as...
* tests/fun/x2x/composed.cc,
* tests/fun/x2x/rotation.cc,
* tests/fun/x2x/translation.cc... this.
* tests/set/Makefile.am: Fix.
---
mln/fun/x2x/bijective_tr.hh | 10 ++++-
mln/fun/x2x/composed.hh | 16 +++++++--
mln/fun/x2x/rotation.hh | 25 ++------------
mln/fun/x2x/translation.hh | 9 ++---
tests/fun/Makefile.am | 2 +
tests/fun/x2x/Makefile.am | 11 ++++++
tests/fun/x2x/composed.cc | 66 +++++++++++++++++++++++++++++++++++++++
tests/fun/x2x/rotation.cc | 72 +++++++++++++++++++++++++++++++++++++++++++
tests/fun/x2x/translation.cc | 59 +++++++++++++++++++++++++++++++++++
tests/set/Makefile.am | 2 -
10 files changed, 239 insertions(+), 33 deletions(-)
Index: trunk/milena/tests/fun_x2x_translation.cc (deleted)
===================================================================
Index: trunk/milena/tests/fun_x2x_rotation.cc (deleted)
===================================================================
Index: trunk/milena/tests/fun_x2x_composed.cc (deleted)
===================================================================
Index: trunk/milena/tests/fun/x2x/translation.cc
===================================================================
--- trunk/milena/tests/fun/x2x/translation.cc (revision 0)
+++ trunk/milena/tests/fun/x2x/translation.cc (revision 1521)
@@ -0,0 +1,59 @@
+// Copyright (C) 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
+// 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.
+
+/*! \file tests/fun_x2x_translation.cc
+ *
+ * \brief Tests on mln::fun::x2x::translation.
+ */
+
+#include <cmath>
+#include <iostream>
+#include <mln/fun/x2x/translation.hh>
+#include <mln/fun/i2v/all_to.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ float
+ a = 2.3,
+ b = 0,
+ c = 2.9;
+
+ metal::vec<3,float> vec1 = make::vec(a, b, c);
+ fun::x2x::translation<3,float> tr1(all_to(1.6));
+
+ std::cout << vec1 << std::endl;
+ std::cout << tr1(vec1) << std::endl;
+ std::cout << tr1.inv()(vec1) << std::endl;
+ mln_assertion(tr1(tr1.inv()(vec1)) == vec1);
+ mln_assertion(fabs(tr1(vec1)[0] - 3.9) <= 0.125 &&
+ fabs(tr1(vec1)[1] - 1.6) <= 0.125 &&
+ fabs(tr1(vec1)[2] - 4.5) <= 0.125);
+}
Index: trunk/milena/tests/fun/x2x/rotation.cc
===================================================================
--- trunk/milena/tests/fun/x2x/rotation.cc (revision 0)
+++ trunk/milena/tests/fun/x2x/rotation.cc (revision 1521)
@@ -0,0 +1,72 @@
+// Copyright (C) 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
+// 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.
+
+/*! \file tests/fun_x2x_rotation.cc
+ *
+ * \brief Tests on mln::fun::x2x::rotation.
+ */
+
+
+#include <iostream>
+#include <mln/fun/x2x/rotation.hh>
+#include <mln/core/image2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/core/interpolated.hh>
+#include <mln/make/vec.hh>
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<int_u8> lena = io::pgm::load("../../../img/lena.pgm");
+ image2d<int_u8> out(lena.domain());
+
+ interpolated<image2d<int_u8> > inter(lena);
+
+ fun::x2x::rotation<2,float> rot1(0.1);
+
+ image2d<int_u8>::fwd_piter p(out.domain());
+
+ for_all(p)
+ {
+ metal::vec<2,float> v = rot1.inv()((point2d::vec_t)(point2d)p);
+ if (inter.owns_(v))
+ out(p) = inter(v);
+ else
+ out(p) = 255;
+ }
+ io::pgm::save(out, "out.pgm");
+
+ fun::x2x::rotation<2,float> rot2(3.14116);
+ mln_assertion(fabs(rot2(make::vec(0.0, 1.0))[0] -
+ make::vec(0.0, -1.0)[0]) <= 0.125);
+ mln_assertion(fabs(rot2(make::vec(0.0, 1.0))[1] -
+ make::vec(0.0, -1.0)[1]) <= 0.125);
+}
Index: trunk/milena/tests/fun/x2x/Makefile.am
===================================================================
--- trunk/milena/tests/fun/x2x/Makefile.am (revision 1520)
+++ trunk/milena/tests/fun/x2x/Makefile.am (revision 1521)
@@ -1,3 +1,14 @@
## Process this file through Automake to create Makefile.in -*- Makefile -*-
include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ composed \
+ rotation \
+ translation
+
+composed_SOURCES = composed.cc
+rotation_SOURCES = rotation.cc
+translation_SOURCES = translation_SOURCES
+
+TESTS = $(check_PROGRAMS)
Index: trunk/milena/tests/fun/x2x/composed.cc
===================================================================
--- trunk/milena/tests/fun/x2x/composed.cc (revision 0)
+++ trunk/milena/tests/fun/x2x/composed.cc (revision 1521)
@@ -0,0 +1,66 @@
+// Copyright (C) 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
+// 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.
+
+/*! \file tests/fun_x2x_composed.cc
+ *
+ * \brief Tests on mln::fun::x2x::composed.
+ */
+
+
+#include <iostream>
+#include <mln/fun/x2x/translation.hh>
+#include <mln/fun/x2x/rotation.hh>
+#include <mln/fun/x2x/composed.hh>
+#include <mln/fun/i2v/all_to.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ float
+ a = 2.3,
+ b = 0,
+ c = 2.9;
+
+ metal::vec<3,float> vec1 = make::vec(a, b, c);
+ fun::x2x::translation<3,float> tr(all_to(1.6));
+ fun::x2x::rotation<3,float> rot(0.3, 1);
+
+ std::cout << "vec : " << vec1 << std::endl;
+ std::cout << "tr(vec) : " << tr(vec1) << std::endl;
+ std::cout << "rot(vec) : " << rot(vec1) << std::endl;
+ std::cout << "tr(rot(vec)) : " << compose(tr, rot)(vec1) << std::endl;
+ std::cout << "rot(rot_1(vec)) : " << compose(rot, rot.inv())(vec1) << std::endl;
+ std::cout << "tr(rot(tr(vec))) : " << compose(tr, compose(rot, tr))(vec1) << std::endl;
+ std::cout << "(rototr_1)(rot(tr(vec)))) : "
+ << compose(compose(rot, tr).inv(), compose(rot, tr))(vec1) << std::endl;
+ mln_assertion(fabs(compose(rot, tr)(vec1)[0] - rot(tr(vec1))[0]) <= 0.125);
+ mln_assertion(fabs(compose(rot, tr)(vec1)[1] - rot(tr(vec1))[1]) <= 0.125);
+ mln_assertion(fabs(compose(rot, tr)(vec1)[2] - rot(tr(vec1))[2]) <= 0.125);
+}
Index: trunk/milena/tests/fun/Makefile.am
===================================================================
--- trunk/milena/tests/fun/Makefile.am (revision 1520)
+++ trunk/milena/tests/fun/Makefile.am (revision 1521)
@@ -1,3 +1,5 @@
## Process this file through Automake to create Makefile.in -*- Makefile -*-
include $(top_srcdir)/milena/tests/tests.mk
+
+SUBDIRS = x2x
Index: trunk/milena/tests/set/Makefile.am
===================================================================
--- trunk/milena/tests/set/Makefile.am (revision 1520)
+++ trunk/milena/tests/set/Makefile.am (revision 1521)
@@ -11,7 +11,7 @@
diff_SOURCES = diff.cc
inter_SOURCES = inter.cc
-is_subset_SOURCES = is_subset.cc
+is_subset_of_SOURCES = is_subset.cc
sym_diff_SOURCES = sym_diff.cc
uni_SOURCES = uni.cc
Index: trunk/milena/mln/fun/x2x/composed.hh
===================================================================
--- trunk/milena/mln/fun/x2x/composed.hh (revision 1520)
+++ trunk/milena/mln/fun/x2x/composed.hh (revision 1521)
@@ -30,7 +30,7 @@
/*! \file mln/fun/x2x/composed.hh
*
- * \brief FIXME.
+ * \brief Definition of a composed transformation.
*/
# include <mln/core/concept/function.hh>
@@ -112,8 +112,9 @@
} // end of namespace mln::fun::x2x::internal
- // FIXME: Doc!
-
+ /*! \brief Represent a composition of two transformations.
+ *
+ */
template <typename F, typename G>
struct composed
: public internal::helper_composed_<F, G, composed<F,G>,
@@ -139,6 +140,13 @@
} // end of namespace mln::fun
+ /*! \brief Do a composition of two transformations
+ *
+ * \param[in] f The first transformation.
+ * \param[in] g The second transformation.
+ *
+ * \return The composed transformation fog.
+ */
template <typename F, typename G>
fun::x2x::composed<F,G> compose(F f, G g);
@@ -232,7 +240,9 @@
template <typename F, typename G>
fun::x2x::composed<F,G> compose(F f, G g)
{
+ trace::entering("fun::x2x::compose");
fun::x2x::composed<F,G> comp(f, g);
+ trace::exiting("fun::x2x::compose");
return comp;
}
Index: trunk/milena/mln/fun/x2x/bijective_tr.hh
===================================================================
--- trunk/milena/mln/fun/x2x/bijective_tr.hh (revision 1520)
+++ trunk/milena/mln/fun/x2x/bijective_tr.hh (revision 1521)
@@ -30,7 +30,7 @@
/*! \file mln/fun/x2x/bijective_tr.hh
*
- * \brief FIXME.
+ * \brief Abstraction that describes a bijective transformation.
*/
# include <mln/core/concept/function.hh>
@@ -47,8 +47,12 @@
namespace x2x
{
- // FIXME: Doc!
-
+ /*! \brief Abstraction that describes a bijective transformation.
+ *
+ * All bijective transformation from vector to vector should
+ * should inherit this class.
+ *
+ */
template <typename E>
struct bijective_tr : public Function_x2x< E >
{
Index: trunk/milena/mln/fun/x2x/translation.hh
===================================================================
--- trunk/milena/mln/fun/x2x/translation.hh (revision 1520)
+++ trunk/milena/mln/fun/x2x/translation.hh (revision 1521)
@@ -30,7 +30,7 @@
/*! \file mln/fun/x2x/translation.hh
*
- * \brief FIXME.
+ * \brief Define a translation function.
*/
# include <mln/core/concept/function.hh>
@@ -48,8 +48,9 @@
namespace x2x
{
- // FIXME: Doc!
-
+ /*! \brief Represent a translation function.
+ *
+ */
template <unsigned n, typename C>
struct translation
@@ -82,8 +83,6 @@
template <unsigned n, typename C>
translation<n,C>::translation()
{
-// t_ = make::vec<n,C>(fun::i2v::all<C>(0));
-// this->m_ = h_mat<n,C>::Id;
}
template <unsigned n, typename C>
Index: trunk/milena/mln/fun/x2x/rotation.hh
===================================================================
--- trunk/milena/mln/fun/x2x/rotation.hh (revision 1520)
+++ trunk/milena/mln/fun/x2x/rotation.hh (revision 1521)
@@ -30,7 +30,7 @@
/*! \file mln/fun/x2x/rotation.hh
*
- * \brief FIXME.
+ * \brief Define a rotation function.
*/
# include <mln/core/concept/function.hh>
@@ -48,8 +48,9 @@
namespace x2x
{
- // FIXME: Doc!
-
+ /*! \brief Represent a rotation function.
+ *
+ */
template <unsigned n, typename C>
struct rotation
: internal::x2x_linear_impl_< metal::vec<n,C>, rotation<n,C> >
@@ -82,9 +83,6 @@
template <unsigned n, typename C>
rotation<n,C>::rotation()
{
-// alpha_ = 0;
-// dir_ = 2;
-// this->m_ = h_mat<n,C>::Id;
}
template <unsigned n, typename C>
@@ -159,21 +157,6 @@
}
}
-// template <typename C> FIXME : template parameter should be swapped
-// void
-// rotation<2,C>::update()
-// {
-// const float cos_a = cos(alpha_);
-// const float sin_a = sin(alpha_);
-
-// m_ = metal::mat<3,3,C>::Id;
-// m_(0, 0) = cos_a;
-// m_(0, 1) = -sin_a;
-// m_(1, 0) = sin_a;
-// m_(1, 1) = cos_a;
-// }
-
-
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::fun::x2x