URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-11 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add tests for border resize with image_if and sub_image.
* border_resize_image_if.cc,
* border_resize_sub_image.cc: New test for border resize.
* show.cc: Update.
---
border_resize_image_if.cc | 80 +++++++++++++++++++++++++++++++++++++++++++++
border_resize_sub_image.cc | 78 +++++++++++++++++++++++++++++++++++++++++++
show.cc | 2 -
3 files changed, 159 insertions(+), 1 deletion(-)
Index: trunk/milena/tests/border_resize_sub_image.cc
===================================================================
--- trunk/milena/tests/border_resize_sub_image.cc (revision 0)
+++ trunk/milena/tests/border_resize_sub_image.cc (revision 1315)
@@ -0,0 +1,78 @@
+// 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/border_resize_sub_image.cc
+ *
+ * \brief Tests on mln::border::resize.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/core/sub_image.hh>
+#include <mln/core/image_if.hh>
+#include <mln/fun/p2b/chess.hh>
+
+#include <mln/border/get.hh>
+#include <mln/literal/origin.hh>
+#include <mln/border/resize.hh>
+
+struct my_box2d : mln::Function_p2b< my_box2d >
+{
+ my_box2d(const mln::box2d& b)
+ : b_(b)
+ {
+ }
+ mln::box2d b_;
+ bool operator()(const mln::point2d& p) const
+ {
+ return b_.has(p);
+ }
+};
+
+
+
+int main()
+{
+ using namespace mln;
+
+ typedef image2d<int> I;
+ unsigned border = 42;
+ unsigned new_border = 51;
+
+ box2d b(literal::origin, point2d(1,1));
+ I ima(3,3, border);
+
+ mln_assertion(border::get(ima) == border);
+ sub_image<I, box2d> sub(ima, b);
+ mln_assertion( sub.has (point2d(2,2)) == false &&
+ sub.owns_(point2d(2,2)) == false );
+
+
+
+
+ /// Cannot resize a subimage => compilation error.
+ border::resize (sub, new_border);
+}
Index: trunk/milena/tests/border_resize_image_if.cc
===================================================================
--- trunk/milena/tests/border_resize_image_if.cc (revision 0)
+++ trunk/milena/tests/border_resize_image_if.cc (revision 1315)
@@ -0,0 +1,80 @@
+// 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/border_resize_image_if.cc
+ *
+ * \brief Tests on mln::border::resize.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/core/sub_image.hh>
+#include <mln/core/image_if.hh>
+#include <mln/fun/p2b/chess.hh>
+
+#include <mln/border/get.hh>
+#include <mln/literal/origin.hh>
+#include <mln/border/resize.hh>
+
+struct my_box2d : mln::Function_p2b< my_box2d >
+{
+ my_box2d(const mln::box2d& b)
+ : b_(b)
+ {
+ }
+ mln::box2d b_;
+ bool operator()(const mln::point2d& p) const
+ {
+ return b_.has(p);
+ }
+};
+
+
+
+int main()
+{
+ using namespace mln;
+
+ typedef image2d<int> I;
+ unsigned border = 42;
+ unsigned new_border = 51;
+
+ box2d b(literal::origin, point2d(1,1));
+ I ima(3,3, border);
+
+ mln_assertion(border::get(ima) == border);
+ mln_assertion( ima.has(point2d(2,2)) == true );
+
+ my_box2d f_b(b);
+ image_if<I, my_box2d> imaif(ima, f_b);
+ mln_assertion( imaif.has (point2d(2,2)) == false &&
+ imaif.owns_(point2d(2,2)) == true );
+
+
+ mln_assertion(border::get(imaif) == border);
+ border::resize (imaif, new_border);
+ mln_assertion(border::get(imaif) == new_border);
+}
Index: trunk/milena/tests/show.cc
===================================================================
--- trunk/milena/tests/show.cc (revision 1314)
+++ trunk/milena/tests/show.cc (revision 1315)
@@ -62,6 +62,6 @@
image2d<unsigned> tmp = geom::chamfer(input, w_win, max);
// Call color_pretty for sub_image.
- for (unsigned i = 2; i < 9; i += 2)
+ for (unsigned i = 2; i < 22; i += 2)
display::show (inplace (tmp | i));
}
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add a new border computation mode and change image_if meaning.
* mln/metal/is.hh: Fix typo.
* mln/metal/is_not.hh: New.
* tests/metal_is.cc: Augment.
* mln/core/internal/image_if_base.hh: Change semantics; now
access to outside domain is OK.
(owns_): New.
(border): Explicit delegation to I in trait::.
* tests/trait_images.cc: Augment.
* tests/border_get.cc: New.
* mln/border/get.hh: .
* mln/border/find.hh: New.
* mln/core/init.hh (init_): Use border::find instead of
border::get.
* mln/core/concept/doc/image.hh: Fix type.
* mln/core/image2d.hh (swap_): Shorten code.
mln/border/find.hh | 28 ++++++------
mln/border/get.hh | 29 ++++++------
mln/core/concept/doc/image.hh | 2
mln/core/image2d.hh | 26 +----------
mln/core/init.hh | 7 ++-
mln/core/internal/image_if_base.hh | 14 ++++++
mln/metal/is.hh | 2
mln/metal/is_not.hh | 63 +++++++++++++++++++++++++++
tests/border_get.cc | 84 +++++++++++++++++++++++++++++++++++++
tests/metal_is.cc | 5 ++
tests/trait_images.cc | 8 +++
11 files changed, 211 insertions(+), 57 deletions(-)
Index: tests/metal_is.cc
--- tests/metal_is.cc (revision 1310)
+++ tests/metal_is.cc (working copy)
@@ -31,6 +31,7 @@
*/
#include <mln/metal/is.hh>
+#include <mln/metal/is_not.hh>
@@ -79,4 +80,8 @@
metal::is<int, float>::check_not();
metal::is<from_1, dest>::check_not();
metal::is<from_2, dest>::check_not();
+
+ metal::is_not<int, float>::check();
+ metal::is_not<from_1, dest>::check();
+ metal::is_not<from_2, dest>::check();
}
Index: tests/trait_images.cc
--- tests/trait_images.cc (revision 1310)
+++ tests/trait_images.cc (working copy)
@@ -46,11 +46,17 @@
std::cout << "image2d: ";
mln::trait::image::print<I>(std::cout);
+ typedef sub_image<I, box2d> Isub;
std::cout << std::endl
<< "sub_image< image2d >: ";
- mln::trait::image::print< sub_image<I, box2d> >(std::cout);
+ mln::trait::image::print< Isub >(std::cout);
std::cout << std::endl
<< "image_if< image2d >: ";
mln::trait::image::print< image_if<I, fun::p2b::chess_t> >(std::cout);
+
+
+ std::cout << std::endl
+ << "image_if< sub_image< image2d > >: ";
+ mln::trait::image::print< image_if<Isub, fun::p2b::chess_t> >(std::cout);
}
Index: tests/border_get.cc
--- tests/border_get.cc (revision 0)
+++ tests/border_get.cc (revision 0)
@@ -0,0 +1,84 @@
+// 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/border_get.cc
+ *
+ * \brief Tests on mln::border::get.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/core/sub_image.hh>
+#include <mln/core/image_if.hh>
+#include <mln/fun/p2b/chess.hh>
+
+#include <mln/border/get.hh>
+#include <mln/literal/origin.hh>
+
+
+struct my_box2d : mln::Function_p2b< my_box2d >
+{
+ my_box2d(const mln::box2d& b)
+ : b_(b)
+ {
+ }
+ mln::box2d b_;
+ bool operator()(const mln::point2d& p) const
+ {
+ return b_.has(p);
+ }
+};
+
+
+
+int main()
+{
+ using namespace mln;
+
+ typedef image2d<int> I;
+
+ box2d b(literal::origin, point2d(1,1));
+ I ima(3,3, 51);
+
+// mln_assertion(border::get(ima) = 51);
+// mln_assertion( ima.has(point2d(2,2)) = true );
+
+// sub_image<I, box2d> sub(ima, b);
+// mln_assertion( sub.has (point2d(2,2)) = false &&
+// sub.owns_(point2d(2,2)) = false );
+// mln_assertion(border::get(sub) = 0);
+
+ my_box2d f_b(b);
+ image_if<I, my_box2d> imaif(ima, f_b);
+ mln_assertion( imaif.has (point2d(2,2)) = false &&
+ imaif.owns_(point2d(2,2)) = true );
+ mln_assertion(border::get(imaif) = 51);
+
+
+// std::cout << std::endl
+// << "image_if< image2d >: ";
+// mln::trait::image::print< image_if<I, fun::p2b::chess_t> >(std::cout);
+}
Index: mln/core/internal/image_if_base.hh
--- mln/core/internal/image_if_base.hh (revision 1310)
+++ mln/core/internal/image_if_base.hh (working copy)
@@ -84,6 +84,8 @@
typedef mlc_if( I_data_are_linear_,
trait::image::data::stored, // if linear then just stored
I_data_ ) data; // otherwise like I
+
+ typedef mln_trait_image_border(I) border;
};
} // end of namespace mln::trait
@@ -105,6 +107,10 @@
void init_(I& ima, const F& f);
+ /// Test if the image owns the point site \p p.
+ /// The result is the same than over the underlying image.
+ bool owns_(const mln_psite(I)& p) const; // Overload the def "owns_ -> has".
+
protected:
/// Constructor from an image \p ima and a predicate \p f.
@@ -158,6 +164,14 @@
}
template <typename I, typename F, typename E>
+ bool
+ image_if_base_<I,F,E>::owns_(const mln_psite(I)& p) const
+ {
+ mln_precondition(this->has_data());
+ return this->data_->ima_.owns_(p);
+ }
+
+ template <typename I, typename F, typename E>
void
image_if_base_<I,F,E>::init_(I& ima, const F& f)
{
Index: mln/core/init.hh
--- mln/core/init.hh (revision 1310)
+++ mln/core/init.hh (working copy)
@@ -35,7 +35,7 @@
# include <mln/tag/init.hh>
# include <mln/geom/bbox.hh>
-# include <mln/border/get.hh>
+# include <mln/border/find.hh>
@@ -81,7 +81,10 @@
template <typename I>
void init_(tag::border_t, unsigned& bdr, const Image<I>& ima)
{
- bdr = border::get(ima);
+ // 'Find' means that we want a value; this is not always the
+ // border thickness of 'ima', but it can be the thickness of
+ // a morphed / underlying image over which ima is constructed.
+ bdr = border::find(ima);
}
template <typename I>
Index: mln/core/concept/doc/image.hh
--- mln/core/concept/doc/image.hh (revision 1310)
+++ mln/core/concept/doc/image.hh (working copy)
@@ -75,7 +75,7 @@
*/
bool has_data() const;
- /*! \brief Test if the image owns the poinst site \p p.
+ /*! \brief Test if the image owns the point site \p p.
*
* \return True if accessing the image value at \p p is
* possible, that is, does not abort the execution.
Index: mln/core/image2d.hh
--- mln/core/image2d.hh (revision 1310)
+++ mln/core/image2d.hh (working copy)
@@ -318,29 +318,9 @@
void
data_< image2d<T> >::swap_(data_< image2d<T> >& other_)
{
-
- T* sw_buffer_ = this->buffer_;
- this->buffer_ = other_.buffer_;
- other_.buffer_ = sw_buffer_;
-
- T** sw_array_ = this->array_;
- this->array_ = other_.array_;
- other_.array_ = sw_array_;
-
- unsigned sw_bdr_ = this->bdr_;
- this->bdr_ = other_.bdr_;
- other_.bdr_ = sw_bdr_;
-
- /// box2d vb_ virtual box, i.e., box including the virtual border
- box2d sw_vb_ = this->vb_;
- this->vb_ = other_.vb_;
- other_.vb_ = sw_vb_;
-
- /// box2d b_ theoretical box
- box2d sw_b_ = this->b_;
- this->b_ = other_.b_;
- other_.b_ = sw_b_;
-
+ data_< image2d<T> > self_ = *this;
+ *this = other_;
+ other_ = self_;
}
template <typename T>
Index: mln/metal/is_not.hh
--- mln/metal/is_not.hh (revision 0)
+++ mln/metal/is_not.hh (revision 0)
@@ -0,0 +1,63 @@
+// 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_CORE_METAL_IS_NOT_HH
+# define MLN_CORE_METAL_IS_NOT_HH
+
+/*! \file mln/metal/is_not.hh
+ *
+ * \brief Definition of a type that means "is not".
+ */
+
+# include <mln/metal/is.hh>
+
+
+# define mlc_is_not(T, U) mln::metal::is_not< T, U >
+
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ /*! \brief "is_not" check.
+ *
+ * FIXME: Doc!
+ */
+ template <typename T, typename U>
+ struct is_not : not_< is<T, U> >::eval
+ {
+ };
+
+ } // end of namespace mln::metal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_METAL_IS_NOT_HH
Index: mln/metal/is.hh
--- mln/metal/is.hh (revision 1310)
+++ mln/metal/is.hh (working copy)
@@ -30,7 +30,7 @@
/*! \file mln/metal/is.hh
*
- * \brief Definition of a type that means "converts to".
+ * \brief Definition of a type that means "is".
*/
# include <mln/metal/is_a.hh>
Index: mln/border/get.hh
--- mln/border/get.hh (revision 1310)
+++ mln/border/get.hh (working copy)
@@ -33,7 +33,7 @@
* \brief FIXME.
*/
-# include <mln/core/internal/image_morpher.hh>
+# include <mln/border/find.hh>
namespace mln
@@ -56,28 +56,26 @@
namespace impl
{
- template <typename I, typename S, typename E>
- unsigned get__(const mln::internal::image_morpher_<I,S,E>& ima)
- {
- return border::get(*ima.delegatee_());
- }
-
- template <typename S, typename E>
- unsigned get__(const mln::internal::image_base_<S,E>&)
+ template <typename I>
+ unsigned get_(trait::image::border::any, trait::image::category::primary,
+ const I& ima)
{
- return 0;
+ return ima.border();
}
template <typename I>
- unsigned get_(trait::image::speed::any, const I& ima)
+ unsigned get_(trait::image::border::any, trait::image::category::morpher,
+ const I& ima)
{
- return border::impl::get__(ima);
+ return border::get( *ima.delegatee_() );
}
+
template <typename I>
- unsigned get_(trait::image::speed::fastest, const I& ima)
+ unsigned get_(trait::image::border::none, trait::image::category::any,
+ const I& ima)
{
- return ima.border();
+ return 0;
}
} // end of namespace mln::border::impl
@@ -89,7 +87,8 @@
unsigned get(const Image<I>& ima)
{
mln_precondition(exact(ima).has_data());
- return border::impl::get_(mln_trait_image_speed(I)(), exact(ima));
+ return border::impl::get_(mln_trait_image_border(I)(), mln_trait_image_category(I)(),
+ exact(ima));
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/border/find.hh
--- mln/border/find.hh (revision 1310)
+++ mln/border/find.hh (working copy)
@@ -25,10 +25,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_BORDER_GET_HH
-# define MLN_BORDER_GET_HH
+#ifndef MLN_BORDER_FIND_HH
+# define MLN_BORDER_FIND_HH
-/*! \file mln/border/get.hh
+/*! \file mln/border/find.hh
*
* \brief FIXME.
*/
@@ -42,13 +42,13 @@
namespace border
{
- /*! Get the virtual (outer) border thickness of image \p ima.
+ /*! Find the virtual (outer) border thickness of image \p ima.
*
* \param[in] ima The image.
* \result The border thickness (0 if there is no border).
*/
template <typename I>
- unsigned get(const Image<I>& ima);
+ unsigned find(const Image<I>& ima);
# ifndef MLN_INCLUDE_ONLY
@@ -57,25 +57,25 @@
{
template <typename I, typename S, typename E>
- unsigned get__(const mln::internal::image_morpher_<I,S,E>& ima)
+ unsigned find__(const mln::internal::image_morpher_<I,S,E>& ima)
{
- return border::get(*ima.delegatee_());
+ return border::find(*ima.delegatee_());
}
template <typename S, typename E>
- unsigned get__(const mln::internal::image_base_<S,E>&)
+ unsigned find__(const mln::internal::image_base_<S,E>&)
{
return 0;
}
template <typename I>
- unsigned get_(trait::image::speed::any, const I& ima)
+ unsigned find_(trait::image::speed::any, const I& ima)
{
- return border::impl::get__(ima);
+ return border::impl::find__(ima);
}
template <typename I>
- unsigned get_(trait::image::speed::fastest, const I& ima)
+ unsigned find_(trait::image::speed::fastest, const I& ima)
{
return ima.border();
}
@@ -86,10 +86,10 @@
// Facade.
template <typename I>
- unsigned get(const Image<I>& ima)
+ unsigned find(const Image<I>& ima)
{
mln_precondition(exact(ima).has_data());
- return border::impl::get_(mln_trait_image_speed(I)(), exact(ima));
+ return border::impl::find_(mln_trait_image_speed(I)(), exact(ima));
}
# endif // ! MLN_INCLUDE_ONLY
@@ -99,4 +99,4 @@
} // end of namespace mln
-#endif // ! MLN_BORDER_GET_HH
+#endif // ! MLN_BORDER_FIND_HH
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-11 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add tests for border::resize.
* border_resize_image1d_1.cc,
* border_resize_image1d_2.cc,
* border_resize_image1d_3.cc,
* border_resize_image2d_1.cc,
* border_resize_image2d_2.cc,
* border_resize_image2d_3.cc,
* border_resize_image3d_1.cc,
* border_resize_image3d_2.cc,
* border_resize_image3d_3.cc: New tests.
---
border_resize_image1d_1.cc | 73 ++++++++++++++++++++++++++++++++++++++++++++
border_resize_image1d_2.cc | 73 ++++++++++++++++++++++++++++++++++++++++++++
border_resize_image1d_3.cc | 73 ++++++++++++++++++++++++++++++++++++++++++++
border_resize_image2d_1.cc | 73 ++++++++++++++++++++++++++++++++++++++++++++
border_resize_image2d_2.cc | 74 +++++++++++++++++++++++++++++++++++++++++++++
border_resize_image2d_3.cc | 74 +++++++++++++++++++++++++++++++++++++++++++++
border_resize_image3d_1.cc | 74 +++++++++++++++++++++++++++++++++++++++++++++
border_resize_image3d_2.cc | 73 ++++++++++++++++++++++++++++++++++++++++++++
border_resize_image3d_3.cc | 73 ++++++++++++++++++++++++++++++++++++++++++++
9 files changed, 660 insertions(+)
Index: trunk/milena/tests/border_resize_image2d_2.cc
===================================================================
--- trunk/milena/tests/border_resize_image2d_2.cc (revision 0)
+++ trunk/milena/tests/border_resize_image2d_2.cc (revision 1309)
@@ -0,0 +1,74 @@
+// 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/border_resize_image?d_?.cc
+ *
+ * \brief Tests on mln::border::resize.
+ */
+
+
+#include <mln/core/image2d.hh>
+#include <mln/debug/iota.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/border/resize.hh>
+#include <mln/debug/println_with_border.hh>
+#include <mln/border/fill.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ unsigned border = 2;
+ unsigned new_border = 5;
+
+ std::cout << std::endl
+ << "Test 2d resize"
+ << std::endl
+ << std::endl;
+ image2d<value::int_u8> ima(4, 5, border);
+ debug::iota(ima);
+ border::fill(ima, 8);
+
+
+ std::cout << "before resize ("
+ << border
+ << ")"
+ << std::endl;
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+
+
+ border::resize (ima, new_border);
+ std::cout << "after resize ("
+ << new_border
+ << ")"
+ << std::endl;
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+
+}
Index: trunk/milena/tests/border_resize_image3d_3.cc
===================================================================
--- trunk/milena/tests/border_resize_image3d_3.cc (revision 0)
+++ trunk/milena/tests/border_resize_image3d_3.cc (revision 1309)
@@ -0,0 +1,73 @@
+// 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/border_resize_image?d_?.cc
+ *
+ * \brief Tests on mln::border::resize.
+ */
+
+
+#include <mln/core/image3d.hh>
+#include <mln/debug/iota.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/border/resize.hh>
+#include <mln/debug/println_with_border.hh>
+#include <mln/border/fill.hh>
+#include <mln/level/fill.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ unsigned border = 3;
+ unsigned new_border = 1;
+
+ std::cout << std::endl
+ << "Test 3d resize"
+ << std::endl
+ << std::endl;
+ image3d<value::int_u8> ima(1, 3, 2, border);
+ level::fill (ima, 2);
+ border::fill(ima, 8);
+
+ std::cout << "before resize ("
+ << border
+ << ")"
+ << std::endl;
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+
+
+ border::resize (ima, new_border);
+ std::cout << "after resize ("
+ << new_border
+ << ")"
+ << std::endl;
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+}
Index: trunk/milena/tests/border_resize_image1d_2.cc
===================================================================
--- trunk/milena/tests/border_resize_image1d_2.cc (revision 0)
+++ trunk/milena/tests/border_resize_image1d_2.cc (revision 1309)
@@ -0,0 +1,73 @@
+// 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/border_resize_image1d_2.cc
+ *
+ * \brief Tests on mln::border::resize.
+ */
+
+
+#include <mln/core/image1d.hh>
+#include <mln/debug/iota.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/border/resize.hh>
+#include <mln/debug/println_with_border.hh>
+#include <mln/border/fill.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ unsigned border = 3;
+ unsigned new_border = 6;
+
+ std::cout << std::endl
+ << "Test 1d resize"
+ << std::endl
+ << std::endl;
+ image1d<int> ima(6, border);
+ debug::iota(ima);
+ border::fill(ima, 8);
+
+
+ std::cout << "before resize ("
+ << border
+ << ")"
+ << std::endl;
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+
+
+ border::resize (ima, new_border);
+ std::cout << "after resize ("
+ << new_border
+ << ")"
+ << std::endl;
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+}
Index: trunk/milena/tests/border_resize_image3d_1.cc
===================================================================
--- trunk/milena/tests/border_resize_image3d_1.cc (revision 0)
+++ trunk/milena/tests/border_resize_image3d_1.cc (revision 1309)
@@ -0,0 +1,74 @@
+// 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/border_resize_image3d_1.cc
+ *
+ * \brief Tests on mln::border::resize.
+ */
+
+
+#include <mln/core/image3d.hh>
+#include <mln/debug/iota.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/border/resize.hh>
+#include <mln/debug/println_with_border.hh>
+#include <mln/border/fill.hh>
+#include <mln/level/fill.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ unsigned border = 1;
+ unsigned new_border = 3;
+
+ std::cout << std::endl
+ << "Test 3d resize"
+ << std::endl
+ << std::endl;
+ image3d<value::int_u8> ima(3, 1, 2, border);
+ level::fill (ima, 2);
+ border::fill(ima, 8);
+
+ std::cout << "before resize ("
+ << border
+ << ")"
+ << std::endl;
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+
+
+ border::resize (ima, new_border);
+ std::cout << "after resize ("
+ << new_border
+ << ")"
+ << std::endl;
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+
+}
Index: trunk/milena/tests/border_resize_image2d_3.cc
===================================================================
--- trunk/milena/tests/border_resize_image2d_3.cc (revision 0)
+++ trunk/milena/tests/border_resize_image2d_3.cc (revision 1309)
@@ -0,0 +1,74 @@
+// 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/border_resize_image?d_?.cc
+ *
+ * \brief Tests on mln::border::resize.
+ */
+
+
+#include <mln/core/image2d.hh>
+#include <mln/debug/iota.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/border/resize.hh>
+#include <mln/debug/println_with_border.hh>
+#include <mln/border/fill.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ unsigned border = 3;
+ unsigned new_border = 2;
+
+ std::cout << std::endl
+ << "Test 2d resize"
+ << std::endl
+ << std::endl;
+ image2d<value::int_u8> ima(4, 5, border);
+ debug::iota(ima);
+ border::fill(ima, 8);
+
+
+ std::cout << "before resize ("
+ << border
+ << ")"
+ << std::endl;
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+
+
+ border::resize (ima, new_border);
+ std::cout << "after resize ("
+ << new_border
+ << ")"
+ << std::endl;
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+
+}
Index: trunk/milena/tests/border_resize_image2d_1.cc
===================================================================
--- trunk/milena/tests/border_resize_image2d_1.cc (revision 0)
+++ trunk/milena/tests/border_resize_image2d_1.cc (revision 1309)
@@ -0,0 +1,73 @@
+// 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/border_resize_image?d_?.cc
+ *
+ * \brief Tests on mln::border::resize.
+ */
+
+
+#include <mln/core/image2d.hh>
+#include <mln/debug/iota.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/border/resize.hh>
+#include <mln/debug/println_with_border.hh>
+#include <mln/border/fill.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ unsigned border = 1;
+ unsigned new_border = 3;
+
+ std::cout << std::endl
+ << "Test 2d resize"
+ << std::endl
+ << std::endl;
+ image2d<value::int_u8> ima(3, 2, border);
+ debug::iota(ima);
+ border::fill(ima, 8);
+
+ std::cout << "before resize ("
+ << border
+ << ")"
+ << std::endl;
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+
+
+ border::resize (ima, new_border);
+ std::cout << "after resize ("
+ << new_border
+ << ")"
+ << std::endl;
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+
+}
Index: trunk/milena/tests/border_resize_image1d_3.cc
===================================================================
--- trunk/milena/tests/border_resize_image1d_3.cc (revision 0)
+++ trunk/milena/tests/border_resize_image1d_3.cc (revision 1309)
@@ -0,0 +1,73 @@
+// 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/border_resize_image1d_3.cc
+ *
+ * \brief Tests on mln::border::resize.
+ */
+
+
+#include <mln/core/image1d.hh>
+#include <mln/debug/iota.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/border/resize.hh>
+#include <mln/debug/println_with_border.hh>
+#include <mln/border/fill.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ unsigned border = 3;
+ unsigned new_border = 1;
+
+ std::cout << std::endl
+ << "Test 1d resize"
+ << std::endl
+ << std::endl;
+ image1d<value::int_u8> ima(5, border);
+ debug::iota(ima);
+ border::fill(ima, 8);
+
+ std::cout << "before resize ("
+ << border
+ << ")"
+ << std::endl;
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+
+
+ border::resize (ima, new_border);
+ std::cout << "after resize ("
+ << new_border
+ << ")"
+ << std::endl;
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+
+}
Index: trunk/milena/tests/border_resize_image3d_2.cc
===================================================================
--- trunk/milena/tests/border_resize_image3d_2.cc (revision 0)
+++ trunk/milena/tests/border_resize_image3d_2.cc (revision 1309)
@@ -0,0 +1,73 @@
+// 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/border_resize_image3d_2.cc
+ *
+ * \brief Tests on mln::border::resize.
+ */
+
+
+#include <mln/core/image3d.hh>
+#include <mln/debug/iota.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/border/resize.hh>
+#include <mln/debug/println_with_border.hh>
+#include <mln/border/fill.hh>
+#include <mln/level/fill.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ unsigned border = 2;
+ unsigned new_border = 4;
+
+ std::cout << std::endl
+ << "Test 3d resize"
+ << std::endl
+ << std::endl;
+ image3d<int> ima(2, 3, 2, border);
+ level::fill (ima, 2);
+ border::fill(ima, 8);
+
+ std::cout << "before resize ("
+ << border
+ << ")"
+ << std::endl;
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+
+
+ border::resize (ima, new_border);
+ std::cout << "after resize ("
+ << new_border
+ << ")"
+ << std::endl;
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+}
Index: trunk/milena/tests/border_resize_image1d_1.cc
===================================================================
--- trunk/milena/tests/border_resize_image1d_1.cc (revision 0)
+++ trunk/milena/tests/border_resize_image1d_1.cc (revision 1309)
@@ -0,0 +1,73 @@
+// 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/border_resize_image1d_1.cc
+ *
+ * \brief Tests on mln::border::resize.
+ */
+
+
+#include <mln/core/image1d.hh>
+#include <mln/debug/iota.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/border/resize.hh>
+#include <mln/debug/println_with_border.hh>
+#include <mln/border/fill.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ unsigned border = 1;
+ unsigned new_border = 3;
+
+ std::cout << std::endl
+ << "Test 1d resize"
+ << std::endl
+ << std::endl;
+ image1d<value::int_u8> ima(3, border);
+ debug::iota(ima);
+ border::fill(ima, 8);
+
+
+ std::cout << "before resize ("
+ << border
+ << ")"
+ << std::endl;
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+
+
+ border::resize (ima, new_border);
+ std::cout << "after resize ("
+ << new_border
+ << ")"
+ << std::endl;
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+}
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-11 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Add black and white literals.
* mln/core/concept/object.hh: Remove literals/zero.hh include
* mln/literal/black.hh: New.
* mln/literal/white.hh: New.
* mln/value/gray.hh: Remove old black and white variables.
* mln/value/graylevel.hh: Add cpy Ctor and assigment with literals.
* tests/value_graylevel.cc: Update.
---
mln/core/concept/object.hh | 2 -
mln/literal/black.hh | 58 +++++++++++++++++++++++++++++++++++++++++++++
mln/literal/white.hh | 58 +++++++++++++++++++++++++++++++++++++++++++++
mln/value/gray.hh | 9 ------
mln/value/graylevel.hh | 42 ++++++++++++++++++++++++++++----
tests/value_graylevel.cc | 25 ++++++++++++++++---
6 files changed, 175 insertions(+), 19 deletions(-)
Index: trunk/milena/tests/value_graylevel.cc
===================================================================
--- trunk/milena/tests/value_graylevel.cc (revision 1306)
+++ trunk/milena/tests/value_graylevel.cc (revision 1307)
@@ -30,6 +30,11 @@
* \brief Tests on mln::value::graylevel.
*/
+
+#include <mln/literal/black.hh>
+
+#include <mln/literal/white.hh>
+
#include <mln/value/graylevel.hh>
@@ -37,18 +42,30 @@
{
using namespace mln::value;
- gl8 a = white;
- gl16 b = white;
+ using mln::literal::white;
+ using mln::literal::black;
+
+ gl8 a (white);
+ gl16 b = black;
+
+
mln_assertion(a == b);
gl8 c = (a + b) / 2;
+
+ // FIXME cant't compare with literals.
mln_assertion(c == white);
+ // FIXME can't compare with int
+ mln_assertion(c == 255);
+
c = a;
- mln_assertion(c == white);
+ // FIXME cant't compare with literals.
+ //mln_assertion(c == white);
c = (a * 2) / 2;
- mln_assertion(c == white);
+ // FIXME cant't compare with literals.
+ //mln_assertion(c == white);
c = c / 6;
}
Index: trunk/milena/mln/core/concept/object.hh
===================================================================
--- trunk/milena/mln/core/concept/object.hh (revision 1306)
+++ trunk/milena/mln/core/concept/object.hh (revision 1307)
@@ -99,7 +99,7 @@
# include <mln/core/exact.hh>
-# include <mln/literal/zero.hh>
+//# include <mln/literal/zero.hh>
# include <mln/core/ops.hh> // FIXME: Read FIXME in mln/metal/binary_arith_trait.hh!
Index: trunk/milena/mln/literal/black.hh
===================================================================
--- trunk/milena/mln/literal/black.hh (revision 0)
+++ trunk/milena/mln/literal/black.hh (revision 1307)
@@ -0,0 +1,58 @@
+// 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_LITERAL_BLACK_HH
+# define MLN_LITERAL_BLACK_HH
+
+/*! \file mln/literal/black.hh
+ * \brief Definition of the literal of mln::black.
+ *
+ */
+
+# include <mln/core/concept/literal.hh>
+
+namespace mln
+{
+
+ namespace literal
+ {
+
+ /// Type of literal black.
+ struct black_t : public Literal<black_t>
+ {
+ };
+
+
+ /// Literal black.
+ static black_t black = black_t();
+
+ } // end of namespace mln::literal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_LITERAL_BLACK_HH
Index: trunk/milena/mln/literal/white.hh
===================================================================
--- trunk/milena/mln/literal/white.hh (revision 0)
+++ trunk/milena/mln/literal/white.hh (revision 1307)
@@ -0,0 +1,58 @@
+// 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_LITERAL_WHITE_HH
+# define MLN_LITERAL_WHITE_HH
+
+/*! \file mln/literal/white.hh
+ * \brief Definition of the literal of mln::white.
+ *
+ */
+
+# include <mln/core/concept/literal.hh>
+
+namespace mln
+{
+
+ namespace literal
+ {
+
+ /// Type of literal white.
+ struct white_t : public Literal<white_t>
+ {
+ };
+
+
+ /// Literal white.
+ static white_t white = white_t();
+
+ } // end of namespace mln::literal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_LITERAL_WHITE_HH
Index: trunk/milena/mln/value/graylevel.hh
===================================================================
--- trunk/milena/mln/value/graylevel.hh (revision 1306)
+++ trunk/milena/mln/value/graylevel.hh (revision 1307)
@@ -42,13 +42,15 @@
namespace mln
{
+ /// Fwd decl.
+ namespace literal { struct black_t; struct white_t; }
+
namespace value
{
/// Fwd decl.
class gray;
-
/// General gray-level class on n bits.
template <unsigned n>
struct graylevel
@@ -66,10 +68,21 @@
/// Ctor.
explicit graylevel(int val);
+ /// \{ Ctors with literals.
+ graylevel(const literal::black_t&);
+ graylevel(const literal::white_t&);
+ /// \}
+
/// Access to std type.
mln_enc(int_u<n>) value() const;
+ /// Assigment with int.
graylevel<n>& operator=(int val);
+
+ /// \{ Assigment with literals.
+ graylevel<n>& operator=(const literal::white_t&);
+ graylevel<n>& operator=(const literal::black_t&);
+ /// \}
};
@@ -126,6 +139,19 @@
this->v_ = val;
}
+
+ template <unsigned n>
+ graylevel<n>::graylevel(const literal::black_t&)
+ {
+ this->v_ = 0;
+ }
+
+ template <unsigned n>
+ graylevel<n>::graylevel(const literal::white_t&)
+ {
+ this->v_ = mln_max(mln_enc(int_u<n>));
+ }
+
template <unsigned n>
mln_enc(int_u<n>)
graylevel<n>::value() const
@@ -135,11 +161,17 @@
template <unsigned n>
graylevel<n>&
- graylevel<n>::operator=(int val)
+ graylevel<n>::operator=(const literal::black_t&)
{
- mln_precondition(val >= 0);
- mln_precondition(unsigned(val) <= mln_max(mln_enc(int_u<n>)));
- this->v_ = val;
+ this->v_ = 0;
+ return *this;
+ }
+
+ template <unsigned n>
+ graylevel<n>&
+ graylevel<n>::operator=(const literal::white_t&)
+ {
+ this->v_ = mln_max(mln_enc(int_u<n>));
return *this;
}
Index: trunk/milena/mln/value/gray.hh
===================================================================
--- trunk/milena/mln/value/gray.hh (revision 1306)
+++ trunk/milena/mln/value/gray.hh (revision 1307)
@@ -83,12 +83,6 @@
unsigned long val_;
};
- /// White.
- extern const gray white;
-
- /// Black.
- extern const gray black;
-
std::ostream& operator<<(std::ostream& ostr, const gray& g);
bool operator==(const gray& lhs, const gray& rhs);
@@ -107,9 +101,6 @@
# ifndef MLN_INCLUDE_ONLY
- const gray white = gray(1, 1);
- const gray black = gray(1, 0);
-
template <unsigned N, unsigned M>
gray operator+(const graylevel<N>& lhs, const graylevel<M>& rhs)
{
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-11 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Add tests for mat and vec and h_mat and h_vec.
* tests/fun_x2x_translation.cc: Fix.
* mln/make/vec.hh,
* mln/metal/mat.hh,
* mln/metal/vec.hh: Update.
* tests/mat.cc: New.
* tests/vec.cc: New.
---
mln/make/vec.hh | 20 -------------
mln/metal/mat.hh | 16 ++++++++++
mln/metal/vec.hh | 1
tests/fun_x2x_translation.cc | 2 -
tests/mat.cc | 60 ++++++++++++++++++++++++++++++++++++++++
tests/vec.cc | 64 +++++++++++++++++++++++++++++++++++++++++++
6 files changed, 142 insertions(+), 21 deletions(-)
Index: trunk/milena/tests/fun_x2x_translation.cc
===================================================================
--- trunk/milena/tests/fun_x2x_translation.cc (revision 1304)
+++ trunk/milena/tests/fun_x2x_translation.cc (revision 1305)
@@ -47,7 +47,7 @@
c = 2.9;
metal::vec<3,float> vec1 = make::vec(a, b, c);
- fun::x2x::translation<3,float> tr1(make::vec<3, float>(all(1.6)));
+ fun::x2x::translation<3,float> tr1(all(1.6));
std::cout << vec1 << std::endl;
std::cout << tr1(vec1) << std::endl;
Index: trunk/milena/tests/mat.cc
===================================================================
--- trunk/milena/tests/mat.cc (revision 0)
+++ trunk/milena/tests/mat.cc (revision 1305)
@@ -0,0 +1,60 @@
+// 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/image2d.cc
+ *
+ * \brief Tests on mln::image2d.
+ */
+
+
+#include <iostream>
+#include <mln/fun/i2v/all.hh>
+#include <mln/metal/mat.hh>
+#include <mln/core/h_mat.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ metal::mat<1,3,float> m1(all(4.));
+ metal::mat<2,2,float> m2 = metal::mat<2,2,float>::Id;
+
+ h_mat<1,float> hm1(m2);
+ h_mat<2,float> hm2;
+ h_mat<3,float> hm3(all(1.5));
+
+ metal::mat<4,4,float> m4 = hm3;
+
+ std::cout << "m1 = " << m1 << ";" << std::endl;
+ std::cout << "m2 = " << m2 << ";" << std::endl;
+ std::cout << "m4 = " << m4 << ";" << std::endl;
+ std::cout << "hm1 = " << hm1 << ";" << std::endl;
+ std::cout << "hm2 = " << hm2 << ";" << std::endl;
+ std::cout << "hm3 = " << hm3 << ";" << std::endl;
+}
Index: trunk/milena/tests/vec.cc
===================================================================
--- trunk/milena/tests/vec.cc (revision 0)
+++ trunk/milena/tests/vec.cc (revision 1305)
@@ -0,0 +1,64 @@
+// 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/image2d.cc
+ *
+ * \brief Tests on mln::image2d.
+ */
+
+
+#include <iostream>
+#include <mln/fun/i2v/all.hh>
+#include <mln/metal/vec.hh>
+#include <mln/core/h_vec.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ metal::vec<1,float> v1(all(4.));
+ metal::vec<2,float> v2 = make::vec(6., 2.8);
+
+ h_vec<1,float> hv1;
+ h_vec<2,float> hv2(v2);
+ h_vec<3,float> hv3(all(1.5));
+
+ hv3 += make::vec(0., 0., 0., 0.5);
+
+ metal::vec<3,float> v3 = hv3;
+ metal::vec<4,float> v4 = hv3;
+
+ std::cout << "v1 = " << v1 << ";" << std::endl;
+ std::cout << "v2 = " << v2 << ";" << std::endl;
+ std::cout << "v3 = " << v3 << ";" << std::endl;
+ std::cout << "v4 = " << v4 << ";" << std::endl;
+ std::cout << "hv1 = " << hv1 << ";" << std::endl;
+ std::cout << "hv2 = " << hv2 << ";" << std::endl;
+ std::cout << "hv3 = " << hv3 << ";" << std::endl;
+}
Index: trunk/milena/mln/metal/mat.hh
===================================================================
--- trunk/milena/mln/metal/mat.hh (revision 1304)
+++ trunk/milena/mln/metal/mat.hh (revision 1305)
@@ -31,6 +31,7 @@
# include <iostream>
# include <mln/core/concept/object.hh>
+# include <mln/core/concept/function.hh>
# include <mln/core/contract.hh>
# include <mln/trait/all.hh>
# include <mln/value/props.hh>
@@ -66,6 +67,10 @@
template <typename U>
mat(const mat<n,m,U>& rhs);
+ /// Constructor; coordinates are set by function \p f.
+ template <typename F>
+ mat(const Function_i2v<F>& f);
+
template <typename U>
mat& operator=(const mat<n,m,U>& rhs);
@@ -281,6 +286,17 @@
}
template <unsigned n, unsigned m, typename T>
+ template <typename F>
+ mat<n,m,T>::mat(const Function_i2v<F>& f_)
+ {
+ mlc_converts_to(mln_result(F), T)::check();
+ const F& f = exact(f_);
+ for (unsigned i = 0; i < n; ++i)
+ for (unsigned j = 0; j < m; ++j)
+ data_[i][j] = f(i * n + j);
+ }
+
+ template <unsigned n, unsigned m, typename T>
template <typename U>
mat<n,m,T>&
mat<n,m,T>::operator=(const mat<n,m,U>& rhs)
Index: trunk/milena/mln/metal/vec.hh
===================================================================
--- trunk/milena/mln/metal/vec.hh (revision 1304)
+++ trunk/milena/mln/metal/vec.hh (revision 1305)
@@ -414,6 +414,7 @@
template <typename F>
vec<n, T>::vec(const Function_i2v<F>& f_)
{
+ mlc_converts_to(mln_result(F), T)::check();
const F& f = exact(f_);
for (unsigned i = 0; i < n; ++i)
data_[i] = f(i);
Index: trunk/milena/mln/make/vec.hh
===================================================================
--- trunk/milena/mln/make/vec.hh (revision 1304)
+++ trunk/milena/mln/make/vec.hh (revision 1305)
@@ -45,15 +45,6 @@
/*! \brief Create an mln::metal::vec<n,T>.
*
- * \param[in] f Function.
- *
- * \return A nD vector filled with the function \p f .
- */
- template <unsigned n, typename T, typename F>
- metal::vec<n, T> vec(const Function_i2v<F>& f_);
-
- /*! \brief Create an mln::metal::vec<n,T>.
- *
* \param[in] v_0 First coordinate.
*
* \return A 1D vector.
@@ -97,17 +88,6 @@
# ifndef MLN_INCLUDE_ONLY
- template <unsigned n, typename T, typename F>
- metal::vec<n, T> vec(const Function_i2v<F>& f_)
- {
- mlc_converts_to(mln_result(F), T)::check();
- F f = exact(f_);
- metal::vec<n, T> tmp;
- for (unsigned i; i < n; ++i)
- tmp[i] = f(i);
- return tmp;
- }
-
template <typename T>
metal::vec<1, T> vec(const T& v_0)
{