URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-01 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Move tests for border in tests.
Tests for border fill.
* border_fill: New.
* border_fill/test_border_fill_image1d_1.cc: New.
* border_fill/test_border_fill_image1d_2.cc: New.
* border_fill/test_border_fill_image1d_3.cc: New.
* border_fill/test_border_fill_image1d_4.cc: New.
* border_fill/test_border_fill_image1d_5.cc: New.
* border_fill/test_border_fill_image2d_1.cc: New.
* border_fill/test_border_fill_image2d_2.cc: New.
* border_fill/test_border_fill_image2d_3.cc: New.
* border_fill/test_border_fill_image2d_4.cc: New.
* border_fill/test_border_fill_image3d_1.cc: New.
* border_fill/test_border_fill_image3d_2.cc: New.
* border_fill/test_border_fill_image3d_3.cc: New.
* border_fill/test_border_fill_image3d_4.cc: New.
Tests for border duplicate.
* border_duplicate: New.
* border_duplicate/test_border_duplicate_image1d_1.cc: New.
* border_duplicate/test_border_duplicate_image1d_2.cc: New.
* border_duplicate/test_border_duplicate_image1d_3.cc: New.
* border_duplicate/test_border_duplicate_image1d_4.cc: New.
* border_duplicate/test_border_duplicate_image1d_5.cc: New.
* border_duplicate/test_border_duplicate_image2d_1.cc: New.
* border_duplicate/test_border_duplicate_image2d_2.cc: New.
* border_duplicate/test_border_duplicate_image2d_3.cc: New.
* border_duplicate/test_border_duplicate_image2d_4.cc: New.
* border_duplicate/test_border_duplicate_image3d_1.cc: New.
* border_duplicate/test_border_duplicate_image3d_2.cc: New.
* border_duplicate/test_border_duplicate_image3d_3.cc: New.
* border_duplicate/test_border_duplicate_image3d_4.cc: New.
---
border_duplicate/test_border_duplicate_image1d_1.cc | 54 ++++++++++++++++++
border_duplicate/test_border_duplicate_image1d_2.cc | 53 ++++++++++++++++++
border_duplicate/test_border_duplicate_image1d_3.cc | 57 ++++++++++++++++++++
border_duplicate/test_border_duplicate_image1d_4.cc | 56 +++++++++++++++++++
border_duplicate/test_border_duplicate_image1d_5.cc | 56 +++++++++++++++++++
border_duplicate/test_border_duplicate_image2d_1.cc | 54 ++++++++++++++++++
border_duplicate/test_border_duplicate_image2d_2.cc | 53 ++++++++++++++++++
border_duplicate/test_border_duplicate_image2d_3.cc | 54 ++++++++++++++++++
border_duplicate/test_border_duplicate_image2d_4.cc | 56 +++++++++++++++++++
border_duplicate/test_border_duplicate_image3d_1.cc | 53 ++++++++++++++++++
border_duplicate/test_border_duplicate_image3d_2.cc | 52 ++++++++++++++++++
border_duplicate/test_border_duplicate_image3d_3.cc | 56 +++++++++++++++++++
border_duplicate/test_border_duplicate_image3d_4.cc | 55 +++++++++++++++++++
border_fill/test_border_fill_image1d_1.cc | 51 +++++++++++++++++
border_fill/test_border_fill_image1d_2.cc | 50 +++++++++++++++++
border_fill/test_border_fill_image1d_3.cc | 54 ++++++++++++++++++
border_fill/test_border_fill_image1d_4.cc | 55 +++++++++++++++++++
border_fill/test_border_fill_image1d_5.cc | 54 ++++++++++++++++++
border_fill/test_border_fill_image2d_1.cc | 51 +++++++++++++++++
border_fill/test_border_fill_image2d_2.cc | 50 +++++++++++++++++
border_fill/test_border_fill_image2d_3.cc | 54 ++++++++++++++++++
border_fill/test_border_fill_image2d_4.cc | 54 ++++++++++++++++++
border_fill/test_border_fill_image3d_1.cc | 51 +++++++++++++++++
border_fill/test_border_fill_image3d_2.cc | 50 +++++++++++++++++
border_fill/test_border_fill_image3d_3.cc | 53 ++++++++++++++++++
border_fill/test_border_fill_image3d_4.cc | 53 ++++++++++++++++++
26 files changed, 1389 insertions(+)
Index: trunk/milena/tests/border_duplicate/test_border_duplicate_image1d_1.cc
===================================================================
--- trunk/milena/tests/border_duplicate/test_border_duplicate_image1d_1.cc (revision 0)
+++ trunk/milena/tests/border_duplicate/test_border_duplicate_image1d_1.cc (revision 1209)
@@ -0,0 +1,54 @@
+// 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/test_border_duplicate_image1d_1.cc
+ *
+ * \brief Tests on mln::border::duplicate.
+ */
+
+#include <mln/border/duplicate.hh>
+#include <mln/core/image1d_b.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/debug/println_with_border.hh>
+#include <mln/debug/iota.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ std::cout << std::endl
+ << "Test 1d size=5 with border=3 in value::int_u8"
+ << std::endl
+ << std::endl;
+ image1d_b<value::int_u8> ima(5);
+ debug::iota (ima);
+ border::duplicate (ima);
+ std::cout << std::endl;
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+}
Index: trunk/milena/tests/border_duplicate/test_border_duplicate_image2d_1.cc
===================================================================
--- trunk/milena/tests/border_duplicate/test_border_duplicate_image2d_1.cc (revision 0)
+++ trunk/milena/tests/border_duplicate/test_border_duplicate_image2d_1.cc (revision 1209)
@@ -0,0 +1,54 @@
+// 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/test_border_duplicate_image2d_1.cc
+ *
+ * \brief Tests on mln::border::duplicate.
+ */
+
+#include <mln/border/duplicate.hh>
+#include <mln/core/image2d_b.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/debug/println_with_border.hh>
+#include <mln/debug/iota.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ std::cout << std::endl
+ << "Test 2d size=5x2 with border=3 in value::int_u8"
+ << std::endl
+ << std::endl;
+ image2d_b<value::int_u8> ima(5, 2, 3);
+ debug::iota (ima);
+ border::duplicate (ima);
+ std::cout << std::endl;
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+}
Index: trunk/milena/tests/border_duplicate/test_border_duplicate_image1d_2.cc
===================================================================
--- trunk/milena/tests/border_duplicate/test_border_duplicate_image1d_2.cc (revision 0)
+++ trunk/milena/tests/border_duplicate/test_border_duplicate_image1d_2.cc (revision 1209)
@@ -0,0 +1,53 @@
+// 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_fill.cc
+ *
+ * \brief Tests on mln::border::fill.
+ */
+
+#include <mln/border/duplicate.hh>
+#include <mln/core/image1d_b.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/debug/println_with_border.hh>
+#include <mln/debug/iota.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ std::cout << std::endl
+ << "Test 1d size=8 with border=3 in int"
+ << std::endl
+ << std::endl;
+ image1d_b<int> ima(8, 3);
+ debug::iota (ima);
+ border::duplicate (ima);
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+}
Index: trunk/milena/tests/border_duplicate/test_border_duplicate_image1d_3.cc
===================================================================
--- trunk/milena/tests/border_duplicate/test_border_duplicate_image1d_3.cc (revision 0)
+++ trunk/milena/tests/border_duplicate/test_border_duplicate_image1d_3.cc (revision 1209)
@@ -0,0 +1,57 @@
+// 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_fill.cc
+ *
+ * \brief Tests on mln::border::fill.
+ */
+
+#include <mln/border/duplicate.hh>
+#include <mln/core/image1d_b.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/debug/println_with_border.hh>
+#include <mln/debug/iota.hh>
+
+
+using namespace mln;
+
+int
+main (void)
+{
+ std::cout << std::endl
+ << "Test 1d size= box [2 .. 4] with border=6 in int"
+ << std::endl
+ << std::endl;
+
+ box1d b(make::point1d(2), make::point1d(4));
+ image1d_b<int> ima(b, 6);
+ debug::iota (ima);
+ border::duplicate (ima);
+ std::cout << std::endl;
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+}
Index: trunk/milena/tests/border_duplicate/test_border_duplicate_image3d_1.cc
===================================================================
--- trunk/milena/tests/border_duplicate/test_border_duplicate_image3d_1.cc (revision 0)
+++ trunk/milena/tests/border_duplicate/test_border_duplicate_image3d_1.cc (revision 1209)
@@ -0,0 +1,53 @@
+// 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_fill.cc
+ *
+ * \brief Tests on mln::border::fill.
+ */
+
+#include <mln/border/duplicate.hh>
+#include <mln/core/image3d_b.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/debug/iota.hh>
+#include <mln/debug/println_with_border.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ std::cout << std::endl
+ << "Test 3d size=2x3x1 in value::int_u8 with border=2"
+ << std::endl
+ << std::endl;
+ image3d_b<value::int_u8> ima(2, 3, 1, 2);
+ debug::iota (ima);
+ border::duplicate (ima);
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+}
Index: trunk/milena/tests/border_duplicate/test_border_duplicate_image2d_2.cc
===================================================================
--- trunk/milena/tests/border_duplicate/test_border_duplicate_image2d_2.cc (revision 0)
+++ trunk/milena/tests/border_duplicate/test_border_duplicate_image2d_2.cc (revision 1209)
@@ -0,0 +1,53 @@
+// 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_fill.cc
+ *
+ * \brief Tests on mln::border::fill.
+ */
+
+#include <mln/border/duplicate.hh>
+#include <mln/core/image2d_b.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/debug/println_with_border.hh>
+#include <mln/debug/iota.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ std::cout << std::endl
+ << "Test 2d size=2x3 in int with border=2"
+ << std::endl
+ << std::endl;
+ image2d_b<int> i2(2, 3, 2);
+ debug::iota (i2);
+ border::duplicate (i2);
+ debug::println_with_border(i2);
+ std::cout << std::endl;
+}
Index: trunk/milena/tests/border_duplicate/test_border_duplicate_image2d_3.cc
===================================================================
--- trunk/milena/tests/border_duplicate/test_border_duplicate_image2d_3.cc (revision 0)
+++ trunk/milena/tests/border_duplicate/test_border_duplicate_image2d_3.cc (revision 1209)
@@ -0,0 +1,54 @@
+// 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_fill.cc
+ *
+ * \brief Tests on mln::border::fill.
+ */
+
+#include <mln/border/duplicate.hh>
+#include <mln/core/image2d_b.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/debug/println_with_border.hh>
+#include <mln/debug/iota.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ std::cout << std::endl
+ << "Test 2d size=[(2,6) .. (3,8)] with border=3 in int"
+ << std::endl
+ << std::endl;
+ box2d b(make::point2d(2, 6), make::point2d(3, 8));
+ image2d_b<int> ima(b, 3);
+ debug::iota (ima);
+ border::duplicate (ima);
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+}
Index: trunk/milena/tests/border_duplicate/test_border_duplicate_image3d_2.cc
===================================================================
--- trunk/milena/tests/border_duplicate/test_border_duplicate_image3d_2.cc (revision 0)
+++ trunk/milena/tests/border_duplicate/test_border_duplicate_image3d_2.cc (revision 1209)
@@ -0,0 +1,52 @@
+// 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_fill.cc
+ *
+ * \brief Tests on mln::border::fill.
+ */
+
+#include <mln/border/duplicate.hh>
+#include <mln/core/image3d_b.hh>
+#include <mln/debug/iota.hh>
+#include <mln/debug/println_with_border.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ std::cout << std::endl
+ << "Test 3d size=2x3x1 with border=1 in int"
+ << std::endl
+ << std::endl;
+ image3d_b<int> ima(2, 3, 1, 1);
+ debug::iota (ima);
+ border::duplicate (ima);
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+}
Index: trunk/milena/tests/border_duplicate/test_border_duplicate_image1d_4.cc
===================================================================
--- trunk/milena/tests/border_duplicate/test_border_duplicate_image1d_4.cc (revision 0)
+++ trunk/milena/tests/border_duplicate/test_border_duplicate_image1d_4.cc (revision 1209)
@@ -0,0 +1,56 @@
+// 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_fill.cc
+ *
+ * \brief Tests on mln::border::fill.
+ */
+
+#include <mln/border/duplicate.hh>
+#include <mln/core/image1d_b.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/debug/println_with_border.hh>
+#include <mln/debug/iota.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ std::cout << std::endl
+ << "Test 1d size= box [-6 .. -3] with border=6 in value::int_u8"
+ << std::endl
+ << std::endl;
+
+ box1d b(make::point1d(-6), make::point1d(-3));
+ image1d_b<value::int_u8> ima(b, 6);
+ debug::iota (ima);
+ border::duplicate (ima);
+ std::cout << std::endl;
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+}
Index: trunk/milena/tests/border_duplicate/test_border_duplicate_image1d_5.cc
===================================================================
--- trunk/milena/tests/border_duplicate/test_border_duplicate_image1d_5.cc (revision 0)
+++ trunk/milena/tests/border_duplicate/test_border_duplicate_image1d_5.cc (revision 1209)
@@ -0,0 +1,56 @@
+// 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_fill.cc
+ *
+ * \brief Tests on mln::border::fill.
+ */
+
+#include <mln/border/duplicate.hh>
+#include <mln/core/image1d_b.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/debug/println_with_border.hh>
+#include <mln/debug/iota.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ std::cout << std::endl
+ << "Test 1d size= box [2 .. 4] with border=0 in int"
+ << std::endl
+ << std::endl;
+
+ box1d b(make::point1d(2), make::point1d(4));
+ image1d_b<int> ima(b, 0);
+ debug::iota (ima);
+ border::duplicate (ima);
+ std::cout << std::endl;
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+}
Index: trunk/milena/tests/border_duplicate/test_border_duplicate_image3d_3.cc
===================================================================
--- trunk/milena/tests/border_duplicate/test_border_duplicate_image3d_3.cc (revision 0)
+++ trunk/milena/tests/border_duplicate/test_border_duplicate_image3d_3.cc (revision 1209)
@@ -0,0 +1,56 @@
+// 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_fill.cc
+ *
+ * \brief Tests on mln::border::fill.
+ */
+
+
+#include <mln/border/duplicate.hh>
+#include <mln/core/image3d_b.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/debug/iota.hh>
+#include <mln/debug/println_with_border.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ std::cout << std::endl
+ << "Test 3d size=[(2,6,1) .. (3,8,3)] border=1 in value::int_u8"
+ << std::endl
+ << std::endl;
+
+ box3d b(make::point3d(2, 6, 1), make::point3d(3, 8, 3));
+ image3d_b<value::int_u8> ima(b, 1);
+ debug::iota (ima);
+ border::duplicate (ima);
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+}
Index: trunk/milena/tests/border_duplicate/test_border_duplicate_image2d_4.cc
===================================================================
--- trunk/milena/tests/border_duplicate/test_border_duplicate_image2d_4.cc (revision 0)
+++ trunk/milena/tests/border_duplicate/test_border_duplicate_image2d_4.cc (revision 1209)
@@ -0,0 +1,56 @@
+// 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_fill.cc
+ *
+ * \brief Tests on mln::border::fill.
+ */
+
+
+#include <mln/border/duplicate.hh>
+#include <mln/core/image2d_b.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/debug/println_with_border.hh>
+#include <mln/debug/iota.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ std::cout << std::endl
+ << "Test 2d size=[(-6,-3) .. (-2,-1)] with border=3 in value::int_u8"
+ << std::endl
+ << std::endl;
+
+ box2d b(make::point2d(-6, -3), make::point2d(-2, -1));
+ image2d_b<value::int_u8> ima(b, 3);
+ debug::iota (ima);
+ border::duplicate (ima);
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+}
Index: trunk/milena/tests/border_duplicate/test_border_duplicate_image3d_4.cc
===================================================================
--- trunk/milena/tests/border_duplicate/test_border_duplicate_image3d_4.cc (revision 0)
+++ trunk/milena/tests/border_duplicate/test_border_duplicate_image3d_4.cc (revision 1209)
@@ -0,0 +1,55 @@
+// 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_fill.cc
+ *
+ * \brief Tests on mln::border::fill.
+ */
+
+
+#include <mln/border/duplicate.hh>
+#include <mln/core/image3d_b.hh>
+#include <mln/debug/iota.hh>
+#include <mln/debug/println_with_border.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ std::cout << std::endl
+ << "Test 3d size=[(-7,-8,-6) .. (-5,-4,-1 )] border=1 in int"
+ << std::endl
+ << std::endl;
+
+ box3d b(make::point3d(-7, -8, -6), make::point3d(-5, -4, -1));
+ image3d_b<int> ima(b, 1);
+ debug::iota (ima);
+ border::duplicate (ima);
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+}
Index: trunk/milena/tests/border_fill/test_border_fill_image2d_2.cc
===================================================================
--- trunk/milena/tests/border_fill/test_border_fill_image2d_2.cc (revision 0)
+++ trunk/milena/tests/border_fill/test_border_fill_image2d_2.cc (revision 1209)
@@ -0,0 +1,50 @@
+// 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_fill.cc
+ *
+ * \brief Tests on mln::border::fill.
+ */
+
+#include <mln/border/fill.hh>
+#include <mln/core/image2d_b.hh>
+#include <mln/debug/println_with_border.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ std::cout << std::endl
+ << "Test 2d size=2x3 in int"
+ << std::endl
+ << std::endl;
+ image2d_b<int> i2(2, 3);
+ border::fill (i2, 5);
+ debug::println_with_border(i2);
+ std::cout << std::endl;
+}
Index: trunk/milena/tests/border_fill/test_border_fill_image1d_3.cc
===================================================================
--- trunk/milena/tests/border_fill/test_border_fill_image1d_3.cc (revision 0)
+++ trunk/milena/tests/border_fill/test_border_fill_image1d_3.cc (revision 1209)
@@ -0,0 +1,54 @@
+// 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_fill.cc
+ *
+ * \brief Tests on mln::border::fill.
+ */
+
+#include <mln/core/image1d_b.hh>
+#include <mln/border/fill.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/debug/println_with_border.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ std::cout << std::endl;
+ std::cout << "Test 1d size= box [2 .. 4] with border=6 in int"
+ << std::endl;
+
+ box1d b(make::point1d(2), make::point1d(4));
+ image1d_b<int> ima(b, 6);
+
+ border::fill (ima, 9);
+ std::cout << std::endl;
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+}
Index: trunk/milena/tests/border_fill/test_border_fill_image3d_1.cc
===================================================================
--- trunk/milena/tests/border_fill/test_border_fill_image3d_1.cc (revision 0)
+++ trunk/milena/tests/border_fill/test_border_fill_image3d_1.cc (revision 1209)
@@ -0,0 +1,51 @@
+// 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_fill.cc
+ *
+ * \brief Tests on mln::border::fill.
+ */
+
+#include <mln/debug/println_with_border.hh>
+#include <mln/border/fill.hh>
+#include <mln/core/image3d_b.hh>
+#include <mln/value/int_u8.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ std::cout << std::endl
+ << "Test 3d size=2x3x1 in value::int_u8"
+ << std::endl
+ << std::endl;
+ image3d_b<value::int_u8> i4(2, 3, 1, 2);
+ border::fill (i4, 7);
+ debug::println_with_border(i4);
+ std::cout << std::endl;
+}
Index: trunk/milena/tests/border_fill/test_border_fill_image3d_2.cc
===================================================================
--- trunk/milena/tests/border_fill/test_border_fill_image3d_2.cc (revision 0)
+++ trunk/milena/tests/border_fill/test_border_fill_image3d_2.cc (revision 1209)
@@ -0,0 +1,50 @@
+// 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_fill.cc
+ *
+ * \brief Tests on mln::border::fill.
+ */
+
+#include <mln/core/image3d_b.hh>
+#include <mln/border/fill.hh>
+#include <mln/debug/println_with_border.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ std::cout << std::endl
+ << "Test 3d size=2x3x1 with border=1 in int"
+ << std::endl
+ << std::endl;
+ image3d_b<int> i3(2, 3, 1, 1);
+ border::fill (i3, 6);
+ debug::println_with_border(i3);
+ std::cout << std::endl;
+}
Index: trunk/milena/tests/border_fill/test_border_fill_image1d_4.cc
===================================================================
--- trunk/milena/tests/border_fill/test_border_fill_image1d_4.cc (revision 0)
+++ trunk/milena/tests/border_fill/test_border_fill_image1d_4.cc (revision 1209)
@@ -0,0 +1,55 @@
+// 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_fill.cc
+ *
+ * \brief Tests on mln::border::fill.
+ */
+
+#include <mln/core/image1d_b.hh>
+#include <mln/border/fill.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/debug/println_with_border.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ std::cout << std::endl;
+ std::cout << "Test 1d size= box [-6 .. -3] with border=6 in value::int_u8"
+ << std::endl;
+
+ box1d b(make::point1d(-6), make::point1d(-3));
+ image1d_b<value::int_u8> ima(b, 6);
+
+// image1d_b<value::int_u8> ima(5);
+ border::fill (ima, 7);
+ std::cout << std::endl;
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+}
Index: trunk/milena/tests/border_fill/test_border_fill_image2d_3.cc
===================================================================
--- trunk/milena/tests/border_fill/test_border_fill_image2d_3.cc (revision 0)
+++ trunk/milena/tests/border_fill/test_border_fill_image2d_3.cc (revision 1209)
@@ -0,0 +1,54 @@
+// 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_fill.cc
+ *
+ * \brief Tests on mln::border::fill.
+ */
+
+#include <mln/border/fill.hh>
+#include <mln/core/image2d_b.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/debug/println_with_border.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ std::cout << std::endl
+ << "Test 2d size=[(2,6) .. (3,8)] with border=3 in int"
+ << std::endl
+ << std::endl;
+
+ box2d b(make::point2d(2, 6), make::point2d(3, 8));
+ image2d_b<int> ima(b, 3);
+
+ border::fill (ima, 8);
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+}
Index: trunk/milena/tests/border_fill/test_border_fill_image2d_4.cc
===================================================================
--- trunk/milena/tests/border_fill/test_border_fill_image2d_4.cc (revision 0)
+++ trunk/milena/tests/border_fill/test_border_fill_image2d_4.cc (revision 1209)
@@ -0,0 +1,54 @@
+// 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_fill.cc
+ *
+ * \brief Tests on mln::border::fill.
+ */
+
+#include <mln/border/fill.hh>
+#include <mln/core/image2d_b.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/debug/println_with_border.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ std::cout << std::endl
+ << "Test 2d size=[(-6,-3) .. (-2,-1)] with border=3 in value::int_u8"
+ << std::endl
+ << std::endl;
+
+ box2d b(make::point2d(-6, -3), make::point2d(-2, -1));
+ image2d_b<value::int_u8> ima(b, 3);
+
+ border::fill (ima, 3);
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+}
Index: trunk/milena/tests/border_fill/test_border_fill_image1d_5.cc
===================================================================
--- trunk/milena/tests/border_fill/test_border_fill_image1d_5.cc (revision 0)
+++ trunk/milena/tests/border_fill/test_border_fill_image1d_5.cc (revision 1209)
@@ -0,0 +1,54 @@
+// 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_fill.cc
+ *
+ * \brief Tests on mln::border::fill.
+ */
+
+#include <mln/core/image1d_b.hh>
+#include <mln/border/fill.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/debug/println_with_border.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ std::cout << std::endl;
+ std::cout << "Test 1d size= box [2 .. 4] with border=0 in int"
+ << std::endl;
+
+ box1d b(make::point1d(2), make::point1d(4));
+ image1d_b<int> ima(b, 0);
+
+ border::fill (ima, 9);
+ std::cout << std::endl;
+ debug::println_with_border(ima);
+ std::cout << std::endl;
+}
Index: trunk/milena/tests/border_fill/test_border_fill_image3d_3.cc
===================================================================
--- trunk/milena/tests/border_fill/test_border_fill_image3d_3.cc (revision 0)
+++ trunk/milena/tests/border_fill/test_border_fill_image3d_3.cc (revision 1209)
@@ -0,0 +1,53 @@
+// 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_fill.cc
+ *
+ * \brief Tests on mln::border::fill.
+ */
+
+#include <mln/border/fill.hh>
+#include <mln/core/image3d_b.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/debug/println_with_border.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ std::cout << std::endl
+ << "Test 3d size=[(2,6,1) .. (3,8,3)] border=1 in value::int_u8"
+ << std::endl
+ << std::endl;
+
+ box3d b(make::point3d(2, 6, 1), make::point3d(3, 8, 3));
+ image3d_b<value::int_u8> i4(b, 1);
+ border::fill (i4, 2);
+ debug::println_with_border(i4);
+ std::cout << std::endl;
+}
Index: trunk/milena/tests/border_fill/test_border_fill_image3d_4.cc
===================================================================
--- trunk/milena/tests/border_fill/test_border_fill_image3d_4.cc (revision 0)
+++ trunk/milena/tests/border_fill/test_border_fill_image3d_4.cc (revision 1209)
@@ -0,0 +1,53 @@
+// 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_fill.cc
+ *
+ * \brief Tests on mln::border::fill.
+ */
+
+
+#include <mln/border/fill.hh>
+#include <mln/core/image3d_b.hh>
+#include <mln/debug/println_with_border.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ std::cout << std::endl
+ << "Test 3d size=[(-7,-8,-6) .. (-5,-4,-1 )] border=1 in int"
+ << std::endl
+ << std::endl;
+
+ box3d b(make::point3d(-7, -8, -6), make::point3d(-5, -4, -1));
+ image3d_b<int> i4(b, 1);
+ border::fill (i4, 2);
+ debug::println_with_border(i4);
+ std::cout << std::endl;
+}
Index: trunk/milena/tests/border_fill/test_border_fill_image1d_1.cc
===================================================================
--- trunk/milena/tests/border_fill/test_border_fill_image1d_1.cc (revision 0)
+++ trunk/milena/tests/border_fill/test_border_fill_image1d_1.cc (revision 1209)
@@ -0,0 +1,51 @@
+// 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_fill.cc
+ *
+ * \brief Tests on mln::border::fill.
+ */
+
+#include <mln/border/fill.hh>
+#include <mln/core/image1d_b.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/debug/println_with_border.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ std::cout << std::endl;
+ std::cout << "Test 1d size=5 with border=3 in value::int_u8"
+ << std::endl;
+ image1d_b<value::int_u8> i6(5);
+ border::fill (i6, 9);
+ std::cout << std::endl;
+ debug::println_with_border(i6);
+ std::cout << std::endl;
+}
Index: trunk/milena/tests/border_fill/test_border_fill_image2d_1.cc
===================================================================
--- trunk/milena/tests/border_fill/test_border_fill_image2d_1.cc (revision 0)
+++ trunk/milena/tests/border_fill/test_border_fill_image2d_1.cc (revision 1209)
@@ -0,0 +1,51 @@
+// 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_fill.cc
+ *
+ * \brief Tests on mln::border::fill.
+ */
+
+#include <mln/border/fill.hh>
+#include <mln/core/image2d_b.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/debug/println_with_border.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ std::cout << std::endl
+ << "Test 2d size=2x3 in value::int_u8"
+ << std::endl
+ << std::endl;
+ image2d_b<value::int_u8> i1(2, 3);
+ border::fill (i1, 8);
+ debug::println_with_border(i1);
+ std::cout << std::endl;
+}
Index: trunk/milena/tests/border_fill/test_border_fill_image1d_2.cc
===================================================================
--- trunk/milena/tests/border_fill/test_border_fill_image1d_2.cc (revision 0)
+++ trunk/milena/tests/border_fill/test_border_fill_image1d_2.cc (revision 1209)
@@ -0,0 +1,50 @@
+// 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_fill.cc
+ *
+ * \brief Tests on mln::border::fill.
+ */
+
+#include <mln/border/fill.hh>
+#include <mln/core/image1d_b.hh>
+#include <mln/debug/println_with_border.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ std::cout << std::endl;
+ std::cout << "Test 1d size=8 with border=3 in int"
+ << std::endl;
+ std::cout << std::endl;
+ image1d_b<int> i5(8);
+ border::fill (i5, 1);
+ debug::println_with_border(i5);
+ std::cout << std::endl;
+}
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-01 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Add gray values.
* mln/value/gray.hh: General gray-level class where n bits is not know
at compile-time. This class is used for exchange between gray-level
types purpose.
* mln/value/graylevel.hh: Graylevel class on n bits.
* tests/value_gray.cc: Some tests.
---
diffstat not available
Index: trunk/milena/tests/value_gray.cc
===================================================================
--- trunk/milena/tests/value_gray.cc (revision 0)
+++ trunk/milena/tests/value_gray.cc (revision 1203)
@@ -0,0 +1,44 @@
+// 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.
+
+#include <mln/value/graylevel.hh>
+
+int main()
+{
+ using namespace mln::value;
+
+ gl8 a = white;
+ gl16 b = white;
+ assert((a == b) == true);
+ gl8 c = (a + b) / 2;
+ assert(c == white);
+ c = a;
+ assert(c == white);
+
+ c = (a * 2) / 2;
+ assert(c == white);
+}
Index: trunk/milena/mln/value/graylevel.hh
===================================================================
--- trunk/milena/mln/value/graylevel.hh (revision 0)
+++ trunk/milena/mln/value/graylevel.hh (revision 1203)
@@ -0,0 +1,208 @@
+// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_VALUE_GRAYLEVEL_HH
+# define MLN_CORE_VALUE_GRAYLEVEL_HH
+
+# include <iostream>
+# include <mln/core/contract.hh>
+# include <mln/metal/math.hh>
+# include <mln/metal/bexpr.hh>
+# include <mln/value/internal/value_like.hh>
+# include <mln/value/internal/encoding.hh>
+# include <mln/value/gray.hh>
+# include <mln/value/props.hh>
+
+namespace mln
+{
+
+ namespace value
+ {
+
+ /// Fwd decl.
+ class gray;
+
+
+ /// General gray-level class on n bits.
+ template <unsigned n>
+ class graylevel
+ : public internal::value_like_< typename internal::encoding_unsigned_<n>::ret,
+ graylevel<n> >
+ {
+ protected:
+ typedef internal::value_like_< typename internal::encoding_unsigned_<n>::ret,
+ graylevel<n> > super;
+
+ public:
+
+ /// Encoding associated type.
+ typedef typename super::enc enc;
+
+ /// Ctor.
+ graylevel();
+
+ /// Ctor.
+ explicit graylevel(const int val);
+
+ /// Access to std type.
+ enc value() const;
+
+ /// Op encoding_t.
+ operator enc() const;
+
+ /// Op graylevel.
+ operator graylevel() const;
+
+ /// Op<.
+ bool operator<(const graylevel<n>& rhs) const;
+
+ graylevel<n>& operator=(const int val);
+ /// Op==.
+ // bool operator==(const graylevel<n>& rhs) const;
+
+ protected:
+ enc val_;
+ };
+
+
+ template <unsigned n>
+ struct props< graylevel<n> >
+ {
+ static const std::size_t card_ = metal::pow<2, n>::value;
+ static const graylevel<n> min() { return 0; }
+ static const graylevel<n> max() { return card_ - 1; }
+ static const unsigned nbits = n;
+ typedef data_kind kind;
+ typedef float sum;
+ typedef int interop;
+ };
+
+
+ /// Op<<.
+ template <unsigned n>
+ std::ostream& operator<<(std::ostream& ostr, const graylevel<n>& g);
+
+
+ /// Aliases.
+ typedef graylevel<8> gl8;
+ typedef graylevel<16> gl16;
+ typedef graylevel<32> gl32;
+
+
+ template <unsigned n, unsigned m>
+ bool operator==(const graylevel<n>& lhs, const graylevel<m>& rhs);
+
+ template <unsigned n, unsigned m>
+ gray operator+(const graylevel<n>& lhs, const graylevel<m>& rhs);
+
+ template <unsigned n, unsigned m>
+ gray operator-(const graylevel<n>& lhs, const graylevel<m>& rhs);
+
+ template <unsigned n>
+ gray operator*(int s, const graylevel<n>& rhs);
+
+ template <unsigned n>
+ gray operator*(const graylevel<n>& lhs, int s);
+
+ template <unsigned n>
+ gray operator/(const graylevel<n>& lhs, int s);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // Graylevel<n>.
+
+ template <unsigned n>
+ graylevel<n>::graylevel()
+ {
+ }
+
+ template <unsigned n>
+ graylevel<n>::graylevel(const int val)
+ : val_(val)
+ {
+ mln_precondition(val >= 0);
+ mln_precondition(unsigned(val) <= mln_max(enc));
+ }
+
+ template <unsigned n>
+ typename graylevel<n>::enc
+ graylevel<n>::value() const
+ {
+ return val_;
+ }
+
+ template <unsigned n>
+ graylevel<n>&
+ graylevel<n>::operator=(const int val)
+ {
+ mln_precondition(val >= 0);
+ mln_precondition(unsigned(val) <= mln_max(enc));
+ this->val_ = val;
+ return *this;
+ }
+
+ template <unsigned n>
+ graylevel<n>::operator graylevel() const
+ {
+ gray tmp(n, val_);
+ return tmp;
+ }
+
+ template <unsigned n>
+ graylevel<n>::operator typename graylevel<n>::enc() const
+ {
+ return val_;
+ }
+
+ template <unsigned n>
+ bool graylevel<n>::operator<(const graylevel<n>& rhs) const
+ {
+ return val_ < rhs.val_;
+ }
+
+ template <unsigned n>
+ std::ostream& operator<<(std::ostream& ostr, const graylevel<n>& g)
+ {
+ return ostr << g.value();
+ }
+
+ template <unsigned n, unsigned m>
+ bool operator==(const graylevel<n>& lhs, const graylevel<m>& rhs)
+ {
+ return gray(lhs) == gray(rhs);
+ }
+
+# endif
+
+
+ } // end of namespace mln::value
+
+} // end of namespace mln
+
+#endif // ! MLN_CORE_VALUE_GRAYLEVEL_HH
Index: trunk/milena/mln/value/gray.hh
===================================================================
--- trunk/milena/mln/value/gray.hh (revision 0)
+++ trunk/milena/mln/value/gray.hh (revision 1203)
@@ -0,0 +1,350 @@
+// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_VALUE_GRAY_HH
+# define MLN_VALUE_GRAY_HH
+
+# include <iostream>
+# include <mln/value/graylevel.hh>
+
+
+
+namespace mln
+{
+
+ // Fwd decls.
+ namespace value
+ {
+ template <unsigned N> class graylevel;
+ class gray;
+
+ /// General gray-level class where n bits is not know at compile-time.
+ /// This class is used for exchange between gray-level types purpose.
+
+ class gray // FIXME do we need a super class?
+ //: public mln::internal::graylevel_value_< gray >
+ {
+ public:
+
+ /// Ctor.
+ gray();
+
+ /// Ctor.
+ template <unsigned N>
+ gray(const graylevel<N>& val);
+
+ /// Ctor.
+ gray(unsigned nbits, unsigned long val);
+
+ /// Access to std type.
+ unsigned long value() const;
+
+ unsigned nbits() const;
+
+ void set_nbits(unsigned nbits);
+
+ gray to_nbits(unsigned nbits) const;
+
+ template <unsigned N>
+ operator graylevel<N>() const;
+
+ protected:
+ unsigned nbits_;
+ 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);
+ bool operator<(const gray& lhs, const gray& rhs);
+
+ gray operator+(const gray& lhs, const gray& rhs);
+ gray operator-(const gray& lhs, const gray& rhs);
+
+ gray operator*(int s, const gray& rhs);
+ gray operator*(const gray& lhs, int s);
+
+ gray operator/(const gray& lhs, int s);
+
+
+
+
+# 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)
+ {
+ return gray(lhs) + gray(rhs);
+ }
+
+ template <unsigned N, unsigned M>
+ gray operator-(const graylevel<N>& lhs, const graylevel<M>& rhs)
+ {
+ return gray(lhs) - gray(rhs);
+ }
+
+ template <unsigned N>
+ gray operator*(int s, const graylevel<N>& rhs)
+ {
+ mln_precondition(s >= 0);
+ gray tmp(N, s * rhs.value());
+ return tmp;
+ }
+
+ template <unsigned N>
+ gray operator*(const graylevel<N>& lhs, int s)
+ {
+ mln_precondition(s >= 0);
+ gray tmp(N, lhs.value() * s);
+ return tmp;
+ }
+
+ template <unsigned N>
+ gray operator/(const graylevel<N>& lhs, int s)
+ {
+ mln_precondition(s > 0);
+ gray tmp(N, lhs.value() / s);
+ return tmp;
+ }
+
+
+
+ // Gray.
+
+ gray::gray()
+ : nbits_(0)
+ {
+ }
+
+ template <unsigned n>
+ gray::gray(const graylevel<n>& g)
+ : nbits_(n),
+ val_(g.value())
+ {
+ }
+
+ gray::gray(unsigned nbits, unsigned long val)
+ : nbits_(nbits),
+ val_(val)
+ {
+ }
+
+ unsigned long gray::value() const
+ {
+ mln_invariant(nbits_ != 0);
+ return val_;
+ }
+
+ unsigned gray::nbits() const
+ {
+ return nbits_;
+ }
+
+ namespace internal
+ {
+
+ unsigned long two_pow_(unsigned n)
+ {
+ if (n == 0)
+ return 1;
+ else
+ return 2 * two_pow_(n - 1);
+ }
+
+ unsigned long two_pow_n_minus_1(unsigned n)
+ {
+ return two_pow_(n) - 1;
+ }
+
+ template <unsigned n_dest>
+ unsigned long convert(unsigned n_src, unsigned long val)
+ {
+ if (n_dest == n_src)
+ return val;
+ else
+ if (n_dest > n_src)
+ return val * two_pow_n_minus_1(n_dest) / two_pow_n_minus_1(n_src);
+ else
+ return val / two_pow_(n_src - n_dest);
+ }
+
+ } // end of mln::value::internal
+
+
+ void gray::set_nbits(unsigned nbits)
+ {
+ mln_precondition(nbits != 0);
+ mln_invariant(nbits_ != 0);
+ if (nbits == nbits_)
+ return;
+ if (nbits > nbits_)
+ {
+ val_ *= internal::two_pow_n_minus_1(nbits);
+ val_ /= internal::two_pow_n_minus_1(nbits_);
+ }
+ else // nbits < nbits_
+ {
+ val_ /= internal::two_pow_(nbits_ - nbits);
+ }
+ nbits_ = nbits;
+ }
+
+
+ gray gray::to_nbits(unsigned nbits) const
+ {
+ mln_precondition(nbits != 0);
+ mln_invariant(nbits_ != 0);
+ gray tmp(*this);
+ tmp.set_nbits(nbits);
+ return tmp;
+ }
+
+
+ template <unsigned n>
+ gray::operator graylevel<n>() const
+ {
+ mln_precondition(nbits_ != 0);
+ graylevel<n> tmp(internal::convert<n>(nbits_, val_));
+
+ mln_assertion(tmp.value() < internal::two_pow_(n));
+ return tmp;
+ }
+
+ // operators
+
+ std::ostream& operator<<(std::ostream& ostr, const gray& g)
+ {
+ return ostr << g.value() << '/' << g.nbits() << "nbits";
+ }
+
+ bool operator==(const gray& lhs, const gray& rhs)
+ {
+ mln_precondition(lhs.nbits() != 0 and rhs.nbits() != 0);
+ if (rhs.nbits() == lhs.nbits())
+ return lhs.value() == rhs.value();
+ if (lhs.nbits() > rhs.nbits())
+ return lhs.value() == rhs.to_nbits(lhs.nbits()).value();
+ else
+ return lhs.to_nbits(rhs.nbits()).value() == rhs.value();
+ }
+
+ bool operator<(const gray& lhs, const gray& rhs)
+ {
+ mln_precondition(lhs.nbits() != 0 and rhs.nbits() != 0);
+ if (rhs.nbits() == lhs.nbits())
+ return lhs.value() < rhs.value();
+ if (lhs.nbits() > rhs.nbits())
+ return lhs.value() < rhs.to_nbits(lhs.nbits()).value();
+ else
+ return lhs.to_nbits(rhs.nbits()).value() < rhs.value();
+ }
+
+ gray operator+(const gray& lhs, const gray& rhs)
+ {
+ mln_precondition(lhs.nbits() != 0 and rhs.nbits() != 0);
+ if (lhs.nbits() > rhs.nbits())
+ {
+ gray tmp(lhs.nbits(),
+ lhs.value() + rhs.to_nbits(lhs.nbits()).value());
+ return tmp;
+ }
+ else
+ {
+ gray tmp(rhs.nbits(),
+ lhs.to_nbits(rhs.nbits()).value() + rhs.value());
+ return tmp;
+ }
+ }
+
+ gray operator-(const gray& lhs, const gray& rhs)
+ {
+ mln_precondition(lhs.nbits() != 0 and rhs.nbits() != 0);
+ if (lhs.nbits() > rhs.nbits())
+ {
+ unsigned long l = rhs.to_nbits(lhs.nbits()).value();
+ assert(lhs.value() >= l);
+ gray tmp(lhs.nbits(),
+ lhs.value() - l);
+ return tmp;
+ }
+ else
+ {
+ unsigned long l = lhs.to_nbits(rhs.nbits()).value();
+ assert(l >= rhs.value());
+ gray tmp(rhs.nbits(),
+ l - rhs.value());
+ return tmp;
+ }
+ }
+
+ gray operator*(int s, const gray& rhs)
+ {
+ mln_precondition(s >= 0);
+ gray tmp(rhs.nbits(), rhs.value() * s);
+ return tmp;
+ }
+
+ gray operator*(const gray& lhs, int s)
+ {
+ mln_precondition(s >= 0);
+ gray tmp(lhs.nbits(), lhs.value() * s);
+ return tmp;
+ }
+
+ gray operator/(const gray& lhs, int s)
+ {
+ mln_precondition(s > 0);
+ gray tmp(lhs.nbits(), lhs.value() / s);
+ return tmp;
+ }
+
+// template <unsigned N>
+// graylevel<N>&
+// graylevel<N>::operator=(const gray& g)
+// {
+// mln_precondition(g.nbits() == N);
+// assert(g.value() < internal::two_pow_(N));
+// this->val = g.value(); // FIXME: Add static_cast.
+// }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::value
+
+} // end of namespace mln
+
+
+#endif // ! MLN_VALUE_GRAY_HH
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-01 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Add trait for operators * + -.
* mln/core/trait/mult.hh: Rename as...
* mln/core/trait/op_mult.hh: ...this.
* mln/core/trait/op_minus.hh: New.
* mln/core/trait/op_plus.hh: New.
* mln/core/trait/op_uminus.hh: New.
* mln/core/trait/all.hh: Include files above.
---
all.hh | 5 ++
op_minus.hh | 141 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
op_mult.hh | 141 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
op_plus.hh | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
op_uminus.hh | 83 ++++++++++++++++++++++++++++++++++
5 files changed, 505 insertions(+)
Index: trunk/milena/mln/core/trait/mult.hh (deleted)
===================================================================
Index: trunk/milena/mln/core/trait/op_plus.hh
===================================================================
--- trunk/milena/mln/core/trait/op_plus.hh (revision 0)
+++ trunk/milena/mln/core/trait/op_plus.hh (revision 1200)
@@ -0,0 +1,135 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_TRAIT_OP_PLUS_HH
+# define MLN_TRAIT_OP_PLUS_HH
+
+
+# define mln_op_plus(T, U) typename mln::trait::op_plus< T , U >::ret
+
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ template <unsigned n, typename T>
+ class vec;
+
+ template <unsigned n, unsigned m, typename T>
+ class mat;
+
+ } // end of namespace mln::metal
+
+ namespace trait
+ {
+
+ template <typename T, typename U>
+ struct op_plus;
+
+
+ template <typename T>
+ struct op_plus<T, T>
+ {
+ typedef T ret;
+ };
+
+ template <>
+ struct op_plus<int, float>
+ {
+ typedef float ret;
+ };
+ template <>
+ struct op_plus<float, int>
+ {
+ typedef float ret;
+ };
+
+ template <>
+ struct op_plus<int, double>
+ {
+ typedef double ret;
+ };
+ template <>
+ struct op_plus<double, int>
+ {
+ typedef double ret;
+ };
+
+ template <>
+ struct op_plus<double, float>
+ {
+ typedef double ret;
+ };
+ template <>
+ struct op_plus<float, double>
+ {
+ typedef double ret;
+ };
+
+ template <unsigned n, typename T, typename U>
+ struct op_plus<metal::vec<n, T>, U>
+ {
+ typedef metal::vec<n, mln_op_plus(T, U)> ret;
+ };
+ template <typename U, unsigned n, typename T>
+ struct op_plus<U, metal::vec<n, T> >
+ {
+ typedef metal::vec<n, mln_op_plus(T, U)> ret;
+ };
+
+ template <unsigned n, typename T, typename U>
+ struct op_plus<metal::vec<n, T>, metal::vec<n, U> >
+ {
+ typedef metal::vec<n, mln_op_plus(T, U)> ret;
+ };
+
+ template <unsigned n, unsigned m, typename T, typename U>
+ struct op_plus<metal::mat<n, m, T>, U>
+ {
+ typedef metal::mat<n, m, mln_op_plus(T, U)> ret;
+ };
+ template <typename U, unsigned n, unsigned m, typename T>
+ struct op_plus<U, metal::mat<n, m, T> >
+ {
+ typedef metal::mat<n, m, mln_op_plus(T, U)> ret;
+ };
+
+ template <unsigned n, unsigned m, typename T, typename U>
+ struct op_plus<metal::mat<n, m, T>, metal::mat<n, m, U> >
+ {
+ typedef metal::mat<n, m, mln_op_plus(T, U)> ret;
+ };
+
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif // ! MLN_TRAIT_OP_PLUS_HH
Index: trunk/milena/mln/core/trait/all.hh
===================================================================
--- trunk/milena/mln/core/trait/all.hh (revision 1199)
+++ trunk/milena/mln/core/trait/all.hh (revision 1200)
@@ -46,6 +46,11 @@
# include <mln/core/trait/is_fast.hh>
# include <mln/core/trait/pixter.hh>
+# include <mln/core/trait/op_mult.hh>
+# include <mln/core/trait/op_plus.hh>
+# include <mln/core/trait/op_minus.hh>
+# include <mln/core/trait/op_uminus.hh>
+# include <mln/core/trait/promote.hh>
#endif // ! MLN_CORE_TRAIT_ALL_HH
Index: trunk/milena/mln/core/trait/op_minus.hh
===================================================================
--- trunk/milena/mln/core/trait/op_minus.hh (revision 0)
+++ trunk/milena/mln/core/trait/op_minus.hh (revision 1200)
@@ -0,0 +1,141 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_TRAIT_OP_MINUS_HH
+# define MLN_TRAIT_OP_MINUS_HH
+
+
+# define mln_op_minus(T, U) typename mln::trait::op_minus< T , U >::ret
+
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ template <unsigned n, typename T>
+ class vec;
+
+ template <unsigned n, unsigned m, typename T>
+ class mat;
+
+ } // end of namespace mln::metal
+
+ namespace trait
+ {
+
+ template <typename T, typename U>
+ struct op_minus;
+
+
+ template <typename T>
+ struct op_minus<T, T>
+ {
+ typedef T ret;
+ };
+
+ template <typename T>
+ struct op_minus<unsigned, T>
+ {
+ typedef mln_op_minus(signed, T) ret;
+ };
+
+ template <>
+ struct op_minus<int, float>
+ {
+ typedef float ret;
+ };
+ template <>
+ struct op_minus<float, int>
+ {
+ typedef float ret;
+ };
+
+ template <>
+ struct op_minus<int, double>
+ {
+ typedef double ret;
+ };
+ template <>
+ struct op_minus<double, int>
+ {
+ typedef double ret;
+ };
+
+ template <>
+ struct op_minus<double, float>
+ {
+ typedef double ret;
+ };
+ template <>
+ struct op_minus<float, double>
+ {
+ typedef double ret;
+ };
+
+ template <unsigned n, typename T, typename U>
+ struct op_minus<metal::vec<n, T>, U>
+ {
+ typedef metal::vec<n, mln_op_minus(T, U)> ret;
+ };
+ template <typename U, unsigned n, typename T>
+ struct op_minus<U, metal::vec<n, T> >
+ {
+ typedef metal::vec<n, mln_op_minus(T, U)> ret;
+ };
+
+ template <unsigned n, typename T, typename U>
+ struct op_minus<metal::vec<n, T>, metal::vec<n, U> >
+ {
+ typedef metal::vec<n, mln_op_minus(T, U)> ret;
+ };
+
+ template <unsigned n, unsigned m, typename T, typename U>
+ struct op_minus<metal::mat<n, m, T>, U>
+ {
+ typedef metal::mat<n, m, mln_op_minus(T, U)> ret;
+ };
+ template <typename U, unsigned n, unsigned m, typename T>
+ struct op_minus<U, metal::mat<n, m, T> >
+ {
+ typedef metal::mat<n, m, mln_op_minus(T, U)> ret;
+ };
+
+ template <unsigned n, unsigned m, typename T, typename U>
+ struct op_minus<metal::mat<n, m, T>, metal::mat<n, m, U> >
+ {
+ typedef metal::mat<n, m, mln_op_minus(T, U)> ret;
+ };
+
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif // ! MLN_TRAIT_OP_MINUS_HH
Index: trunk/milena/mln/core/trait/op_uminus.hh
===================================================================
--- trunk/milena/mln/core/trait/op_uminus.hh (revision 0)
+++ trunk/milena/mln/core/trait/op_uminus.hh (revision 1200)
@@ -0,0 +1,83 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_TRAIT_OP_UMINUS_HH
+# define MLN_TRAIT_OP_UMINUS_HH
+
+
+# define mln_op_uminus(T) typename mln::trait::op_uminus< T >::ret
+
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ template <unsigned n, typename T>
+ class vec;
+
+ template <unsigned n, unsigned m, typename T>
+ class mat;
+
+ } // end of namespace mln::metal
+
+ namespace trait
+ {
+
+ template <typename T>
+ struct op_uminus
+ {
+ typedef T ret;
+ };
+
+
+ template <>
+ struct op_uminus<unsigned>
+ {
+ typedef signed ret;
+ };
+
+ template <unsigned n, typename T>
+ struct op_uminus<metal::vec<n, T> >
+ {
+ typedef metal::vec<n, mln_op_uminus(T)> ret;
+ };
+
+ template <unsigned n, unsigned m, typename T>
+ struct op_uminus<metal::mat<n, m, T> >
+ {
+ typedef metal::mat<n, m, mln_op_uminus(T)> ret;
+ };
+
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif // ! MLN_TRAIT_OP_UMINUS_HH
Index: trunk/milena/mln/core/trait/op_mult.hh
===================================================================
--- trunk/milena/mln/core/trait/op_mult.hh (revision 0)
+++ trunk/milena/mln/core/trait/op_mult.hh (revision 1200)
@@ -0,0 +1,141 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_TRAIT_OP_MULT_HH
+# define MLN_TRAIT_OP_MULT_HH
+
+
+# define mln_op_mult(T, U) typename mln::trait::op_mult< T , U >::ret
+
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ template <unsigned n, typename T>
+ class vec;
+
+ template <unsigned n, unsigned m, typename T>
+ class mat;
+
+ } // end of namespace mln::metal
+
+ namespace trait
+ {
+
+ template <typename T, typename U>
+ struct op_mult;
+
+
+ template <typename T>
+ struct op_mult<T, T>
+ {
+ typedef T ret;
+ };
+
+ template <>
+ struct op_mult<int, float>
+ {
+ typedef float ret;
+ };
+ template <>
+ struct op_mult<float, int>
+ {
+ typedef float ret;
+ };
+
+ template <>
+ struct op_mult<int, double>
+ {
+ typedef double ret;
+ };
+ template <>
+ struct op_mult<double, int>
+ {
+ typedef double ret;
+ };
+
+ template <>
+ struct op_mult<double, float>
+ {
+ typedef double ret;
+ };
+ template <>
+ struct op_mult<float, double>
+ {
+ typedef double ret;
+ };
+
+ template <unsigned n, typename T, typename U>
+ struct op_mult<metal::vec<n, T>, U>
+ {
+ typedef metal::vec<n, mln_op_mult(T, U)> ret;
+ };
+ template <typename U, unsigned n, typename T>
+ struct op_mult<U, metal::vec<n, T> >
+ {
+ typedef metal::vec<n, mln_op_mult(T, U)> ret;
+ };
+
+ template <unsigned n, unsigned m, typename T, typename U>
+ struct op_mult<metal::mat<n, m, T>, U>
+ {
+ typedef metal::mat<n, m, mln_op_mult(T, U)> ret;
+ };
+ template <typename U, unsigned n, unsigned m, typename T>
+ struct op_mult<U, metal::mat<n, m, T> >
+ {
+ typedef metal::mat<n, m, mln_op_mult(T, U)> ret;
+ };
+
+ template <unsigned n, unsigned o, typename T, unsigned m, typename U>
+ struct op_mult<metal::mat<n, o, T>, metal::mat<o, m, U> >
+ {
+ typedef metal::mat<n, m, mln_op_mult(T, U)> ret;
+ };
+
+ template <unsigned m, unsigned n, typename T, typename U>
+ struct op_mult<metal::mat<m, n, T>, metal::vec<n, U> >
+ {
+ typedef metal::mat<m, 1, mln_op_mult(T, U)> ret;
+ };
+
+ template <unsigned n, typename U, unsigned m, typename T>
+ struct op_mult< metal::vec<n, U>, metal::mat<n, m, T> >
+ {
+ typedef metal::mat<1, m, mln_op_mult(T, U)> ret;
+ };
+
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif // ! MLN_TRAIT_OP_MULT_HH