https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix missing tests in morpho.
* tests/morpho/top_hat.cc: New.
* tests/morpho/Makefile.am: Update.
* tests/morpho/closing/area.cc,
* tests/morpho/closing/height.cc (Copyright): Fix.
* tests/morpho/closing/structural.cc: New.
* tests/morpho/closing/Makefile.am: Update.
* tests/morpho/opening/volume.cc,
* tests/morpho/opening/area.cc,
* tests/morpho/opening/height.cc (Copyright): Fix.
* tests/morpho/opening/structural.cc: New.
* tests/morpho/opening/Makefile.am: Update.
Makefile.am | 12 ++++------
closing/Makefile.am | 2 +
closing/area.cc | 4 +--
closing/height.cc | 5 ++--
closing/structural.cc | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++
opening/Makefile.am | 2 +
opening/area.cc | 4 +--
opening/height.cc | 4 ++-
opening/structural.cc | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++
opening/volume.cc | 4 ++-
top_hat.cc | 24 ++++++++++----------
11 files changed, 152 insertions(+), 27 deletions(-)
Index: tests/morpho/top_hat.cc
--- tests/morpho/top_hat.cc (revision 3462)
+++ tests/morpho/top_hat.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,10 +26,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/morpho/elementary/top_hat.cc
- *
- * \brief Test on mln::morpho::elementary::top_hat's.
- */
+/// \file tests/morpho/elementary/top_hat.cc
+///
+/// Test on mln::morpho::top_hat.
#include <mln/core/image/image2d.hh>
#include <mln/core/alias/neighb2d.hh>
@@ -37,7 +37,7 @@
#include <mln/debug/iota.hh>
#include <mln/debug/println.hh>
-#include <mln/morpho/elementary/top_hat.hh>
+#include <mln/morpho/top_hat.hh>
int main()
@@ -51,15 +51,15 @@
debug::iota(ima);
debug::println(ima);
- debug::println( morpho::elementary::top_hat_white(ima, c4()) );
- debug::println( morpho::elementary::top_hat_black(ima, c4()) );
- debug::println( morpho::elementary::top_hat_self_complementary(ima, c4()) );
+ debug::println( morpho::top_hat_white(ima, c4().win()) );
+ debug::println( morpho::top_hat_black(ima, c4().win()) );
+ debug::println( morpho::top_hat_self_complementary(ima, c4().win()) );
image2d<bool> msk(3, 3, 0);
data::fill(msk, pw::value(ima) >= pw::cst(5u));
debug::println(msk);
- debug::println( morpho::elementary::top_hat_white(msk, c4()) );
- debug::println( morpho::elementary::top_hat_black(msk, c4()) );
- debug::println( morpho::elementary::top_hat_self_complementary(msk, c4()) );
+ debug::println( morpho::top_hat_white(msk, c4().win()) );
+ debug::println( morpho::top_hat_black(msk, c4().win()) );
+ debug::println( morpho::top_hat_self_complementary(msk, c4().win()) );
}
Property changes on: tests/morpho/top_hat.cc
___________________________________________________________________
Added: svn:mergeinfo
Index: tests/morpho/closing/Makefile.am
--- tests/morpho/closing/Makefile.am (revision 3463)
+++ tests/morpho/closing/Makefile.am (working copy)
@@ -8,6 +8,7 @@
height \
area \
volume \
+ structural \
sum
leveling_SOURCES = leveling.cc
@@ -15,6 +16,7 @@
height_SOURCES = height.cc
area_SOURCES = area.cc
volume_SOURCES = volume.cc
+structural_SOURCES = structural.cc
sum_SOURCES = sum.cc
TESTS = $(check_PROGRAMS)
Index: tests/morpho/closing/area.cc
--- tests/morpho/closing/area.cc (revision 3463)
+++ tests/morpho/closing/area.cc (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
Index: tests/morpho/closing/height.cc
--- tests/morpho/closing/height.cc (revision 3463)
+++ tests/morpho/closing/height.cc (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -41,6 +41,7 @@
#include "tests/data.hh"
+
int main()
{
using namespace mln;
Index: tests/morpho/closing/structural.cc
--- tests/morpho/closing/structural.cc (revision 0)
+++ tests/morpho/closing/structural.cc (revision 0)
@@ -0,0 +1,59 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// 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/morpho/closing/structural.cc
+///
+/// Test on mln::morpho::closing::structural.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/core/alias/window2d.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/morpho/closing/structural.hh>
+
+#include "tests/data.hh"
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<int_u8> lena, out;
+ io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+
+ bool w[] = { 0, 1, 1,
+ 0, 0, 1,
+ 0, 0, 1 };
+
+ out = morpho::closing::structural(lena,
+ convert::to<window2d>(w));
+ io::pgm::save(out, "out.pgm");
+}
Index: tests/morpho/opening/Makefile.am
--- tests/morpho/opening/Makefile.am (revision 3463)
+++ tests/morpho/opening/Makefile.am (working copy)
@@ -8,6 +8,7 @@
height \
area \
volume \
+ structural \
sum
leveling_SOURCES = leveling.cc
@@ -15,6 +16,7 @@
height_SOURCES = height.cc
area_SOURCES = area.cc
volume_SOURCES = volume.cc
+structural_SOURCES = structural.cc
sum_SOURCES = sum.cc
TESTS = $(check_PROGRAMS)
Index: tests/morpho/opening/volume.cc
--- tests/morpho/opening/volume.cc (revision 3463)
+++ tests/morpho/opening/volume.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -40,6 +41,7 @@
#include "tests/data.hh"
+
int main()
{
using namespace mln;
Index: tests/morpho/opening/area.cc
--- tests/morpho/opening/area.cc (revision 3463)
+++ tests/morpho/opening/area.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -41,7 +42,6 @@
#include "tests/data.hh"
-
int main()
{
using namespace mln;
Index: tests/morpho/opening/height.cc
--- tests/morpho/opening/height.cc (revision 3463)
+++ tests/morpho/opening/height.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -40,6 +41,7 @@
#include "tests/data.hh"
+
int main()
{
using namespace mln;
Index: tests/morpho/opening/structural.cc
--- tests/morpho/opening/structural.cc (revision 0)
+++ tests/morpho/opening/structural.cc (revision 0)
@@ -0,0 +1,59 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// 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/morpho/opening/structural.cc
+///
+/// Test on mln::morpho::opening::structural.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/core/alias/window2d.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/morpho/opening/structural.hh>
+
+#include "tests/data.hh"
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<int_u8> lena, out;
+ io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+
+ bool w[] = { 0, 1, 1,
+ 0, 0, 1,
+ 0, 0, 1 };
+
+ out = morpho::opening::structural(lena,
+ convert::to<window2d>(w));
+ io::pgm::save(out, "out.pgm");
+}
Index: tests/morpho/Makefile.am
--- tests/morpho/Makefile.am (revision 3463)
+++ tests/morpho/Makefile.am (working copy)
@@ -30,7 +30,9 @@
meyer_wst_long \
rank_filter \
skeleton_constrained \
- thinning
+ thinning \
+ top_hat
+
# -------------- #
# Normal tests. #
@@ -38,7 +40,6 @@
# FIXME: Have erosion and dilation perform symmetric tests.
erosion_SOURCES = erosion.cc
-
contrast_SOURCES = contrast.cc
general_SOURCES = general.cc
gradient_SOURCES = gradient.cc
@@ -48,21 +49,18 @@
graph_image_morpho_SOURCES = graph_image_morpho.cc
graph_image_wst_SOURCES = graph_image_wst.cc
-
line_graph_image_morpho_SOURCES = line_graph_image_morpho.cc
line_graph_image_wst_SOURCES = line_graph_image_wst.cc
-
complex_image_morpho_SOURCES = complex_image_morpho.cc
complex_image_wst_SOURCES = complex_image_wst.cc
meyer_wst_SOURCES = meyer_wst.cc
-
rank_filter_SOURCES = rank_filter.cc
-
skeleton_constrained_SOURCES = skeleton_constrained.cc
-
+top_hat_SOURCES = top_hat.cc
combined_SOURCES = combined.cc
+
# --------------- #
# Complex tests. #
# --------------- #
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Have win::disk2d and win::sphere3d (new) rely on win::ball.
* mln/win/ball.hh: New.
(diameter): New method; replace both...
(disk2d::length): ...this and...
(ball3d::length): ...this.
* mln/win/ball3d.hh: Rename as...
* mln/win/sphere3d.hh: ...this.
(ball3d): Remove; replace by...
(sphere3d): ...this new typedef.
* mln/win/disk2d.hh (disk2d): Remove; replace by...
(disk2d): ...this new typedef.
* mln/win/all.hh (Copyright): Fix.
(include): Update.
* tests/win/ball.cc: New.
* tests/win/sphere3d.cc: New.
* tests/win/disk2d.cc: Remove echo.
* tests/win/Makefile.am: Update.
mln/win/all.hh | 5 +
mln/win/ball.hh | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++
mln/win/disk2d.hh | 78 ++------------------------
mln/win/sphere3d.hh | 86 +++-------------------------
tests/win/Makefile.am | 4 +
tests/win/ball.cc | 53 +++++++++++++++++
tests/win/disk2d.cc | 9 ---
tests/win/sphere3d.cc | 42 ++++++++++++++
8 files changed, 271 insertions(+), 156 deletions(-)
Index: mln/win/all.hh
--- mln/win/all.hh (revision 3458)
+++ mln/win/all.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA, 2009 Research and Development
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
@@ -46,7 +46,7 @@
// Types.
# include <mln/win/backdiag2d.hh>
-# include <mln/win/ball3d.hh>
+# include <mln/win/ball.hh>
# include <mln/win/cube3d.hh>
# include <mln/win/cuboid3d.hh>
# include <mln/win/diag2d.hh>
@@ -58,6 +58,7 @@
# include <mln/win/octagon2d.hh>
# include <mln/win/rectangle2d.hh>
# include <mln/win/segment1d.hh>
+# include <mln/win/sphere3d.hh>
# include <mln/win/vline2d.hh>
// Routines.
Index: mln/win/ball.hh
--- mln/win/ball.hh (revision 0)
+++ mln/win/ball.hh (revision 0)
@@ -0,0 +1,150 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// 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_WIN_BALL_HH
+# define MLN_WIN_BALL_HH
+
+/// \file mln/win/ball.hh
+///
+/// Definition of the mln::win::ball window.
+
+# include <mln/core/internal/classical_window_base.hh>
+# include <mln/core/dpoint.hh>
+# include <mln/core/site_set/box.hh>
+# include <mln/fun/i2v/all_to.hh>
+
+
+namespace mln
+{
+
+ // Forward declaration.
+ namespace win { template <typename G, typename C> struct ball; }
+
+
+ namespace trait
+ {
+
+ template <typename G, typename C>
+ struct window_< mln::win::ball<G,C> > : classical_window_
+ {
+ };
+
+ } // end of namespace trait
+
+
+
+ namespace win
+ {
+
+ /*! \brief Generic ball window defined on a given grid.
+ *
+ * A ball is centered and symmetric; so its diameter is odd.
+ *
+ * G is the given grid on which the ball is defined and C is the
+ * type of coordinates.
+ */
+ template <typename G, typename C>
+ struct ball : public internal::classical_window_base< dpoint<G,C>, ball<G,C> >
+ {
+
+ /// Constructor.
+ /// \param[in] diameter Diameter of the ball.
+ /// \pre \p diameter is odd.
+ ball(unsigned diameter);
+
+ /// Give the ball diameter.
+ unsigned diameter() const;
+
+ /// Give the maximum coordinate gap between the window
+ /// center and a window point.
+ unsigned delta_() const;
+
+ void print_(std::ostream& ostr) const;
+
+ protected:
+ unsigned diameter_;
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename G, typename C>
+ inline
+ ball<G,C>::ball(unsigned diameter)
+ : diameter_(diameter)
+ {
+ mln_precondition(diameter % 2 == 1);
+ int
+ radius = diameter / 2,
+ sqr_radius = radius * radius;
+ typedef point<G,C> P;
+ box<P> b(all_to(-radius), all_to(+radius));
+ P O = literal::origin;
+ mln_piter(box<P>) p(b);
+ for_all(p)
+ {
+ unsigned d = 0;
+ for (unsigned i = 0; i < P::dim; ++i)
+ d += p[i] * p[i];
+ if (d <= sqr_radius)
+ this->insert(p - O);
+ }
+ }
+
+ template <typename G, typename C>
+ inline
+ unsigned ball<G,C>::diameter() const
+ {
+ return diameter_;
+ }
+
+ template <typename G, typename C>
+ inline
+ unsigned ball<G,C>::delta_() const
+ {
+ return diameter_ / 2;
+ }
+
+ template <typename G, typename C>
+ inline
+ void
+ ball<G,C>::print_(std::ostream& ostr) const
+ {
+ ostr << "[ball: diameter=" << diameter_ << ']';
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::win
+
+} // end of namespace mln
+
+
+
+#endif // ! MLN_WIN_BALL_HH
Index: mln/win/sphere3d.hh
--- mln/win/sphere3d.hh (revision 3457)
+++ mln/win/sphere3d.hh (working copy)
@@ -26,94 +26,28 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WIN_BALL3D_HH
-# define MLN_WIN_BALL3D_HH
+#ifndef MLN_WIN_SPHERE3D_HH
+# define MLN_WIN_SPHERE3D_HH
-/// \file mln/win/ball3d.hh
+/// \file mln/win/sphere3d.hh
///
-/// Definition of the mln::win::ball3d window.
+/// Definition of the mln::win::sphere3d window.
-# include <mln/core/internal/classical_window_base.hh>
+# include <mln/win/ball.hh>
# include <mln/core/alias/dpoint3d.hh>
namespace mln
{
- mln_internal_add_classical_window_trait(ball3d);
-
-
namespace win
{
- /*! \brief Ball (sphere) window defined on the 3D square grid.
- *
- * A ball3d is centered and symmetric.
- *
- */
- struct ball3d : public internal::classical_window_base< dpoint3d, ball3d >
- {
- /*! \brief Constructor.
- *
- * \param[in] length Length, thus diameter.
- *
- */
- ball3d(unsigned length);
-
- /*! \brief Give the disk diameter.
- */
- unsigned length() const;
-
- /*! \brief Give the maximum coordinate gap between the window
- * center and a window point.
- */
- unsigned delta_() const;
-
- void print_(std::ostream& ostr) const;
-
- protected:
- unsigned length_;
- };
-
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- inline
- ball3d::ball3d(unsigned length)
- : length_(length)
- {
- mln_precondition(length % 2 == 1);
- const def::coord
- r = static_cast<def::coord>(length / 2),
- minus_r = static_cast<def::coord>(-r),
- r2 = static_cast<def::coord>(r * r);
- for (def::coord a = minus_r; a <= r; ++a)
- for (def::coord b = minus_r; b <= r; ++b)
- for (def::coord c = minus_r; c <= r; ++c)
- if (a * a + b * b + c * c <= r2)
- insert(dpoint3d(a, b, c));
- }
-
- inline
- unsigned ball3d::length() const
- {
- return length_;
- }
-
- inline
- unsigned ball3d::delta_() const
- {
- return length_ / 2;
- }
-
- inline
- void ball3d::print_(std::ostream& ostr) const
- {
- ostr << "[ball3d: length=" << length_ << ']';
- }
+ /// 3D sphere window; precisely, ball-shaped window defined on the
+ /// 3D cubic grid.
+ //
+ typedef ball<grid::cube, def::coord> sphere3d;
-# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::win
@@ -121,4 +55,4 @@
-#endif // ! MLN_WIN_BALL3D_HH
+#endif // ! MLN_WIN_SPHERE3D_HH
Index: mln/win/disk2d.hh
--- mln/win/disk2d.hh (revision 3458)
+++ mln/win/disk2d.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -33,86 +33,22 @@
///
/// Definition of the mln::win::disk2d window.
-# include <mln/core/internal/classical_window_base.hh>
+# include <mln/win/ball.hh>
# include <mln/core/alias/dpoint2d.hh>
namespace mln
{
- mln_internal_add_classical_window_trait(disk2d);
-
namespace win
{
- /*! \brief Disk window defined on the 2D square grid.
- *
- * A disk2d is centered and symmetric.
- *
- */
- struct disk2d : public internal::classical_window_base< dpoint2d, disk2d >
- {
- /*! \brief Constructor.
- *
- * \param[in] length Length, thus diameter.
- *
- */
- disk2d(unsigned length);
-
- /*! \brief Give the disk diameter.
- */
- unsigned length() const;
-
- /*! \brief Give the maximum coordinate gap between the window
- * center and a window point.
- */
- unsigned delta_() const;
-
- void print_(std::ostream& ostr) const;
-
- protected:
- unsigned length_;
- };
-
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- inline
- disk2d::disk2d(unsigned length)
- : length_(length)
- {
- mln_precondition(length % 2 == 1);
- const def::coord
- r = static_cast<def::coord>(length / 2),
- minus_r = static_cast<def::coord>(-r),
- r2 = static_cast<def::coord>(r * r);
- for (def::coord a = minus_r; a <= r; ++a)
- for (def::coord b = minus_r; b <= r; ++b)
- if (a * a + b * b <= r2)
- insert(dpoint2d(a, b));
- }
-
- inline
- unsigned disk2d::length() const
- {
- return length_;
- }
-
- inline
- unsigned disk2d::delta_() const
- {
- return length_ / 2;
- }
-
- inline
- void disk2d::print_(std::ostream& ostr) const
- {
- ostr << "[disk2d: length=" << length_ << ']';
- }
+ /// 2D disk window; precisely, ball-shaped window defined on the
+ /// 2D square grid.
+ //
+ typedef ball<grid::square, def::coord> disk2d;
-# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::win
Index: tests/win/ball.cc
--- tests/win/ball.cc (revision 0)
+++ tests/win/ball.cc (revision 0)
@@ -0,0 +1,53 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// 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/win/ball.cc
+///
+/// Tests on mln::win::ball.
+
+#include <mln/win/ball.hh>
+#include <mln/convert/to_image.hh>
+#include <mln/debug/println.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ win::ball<grid::square, def::coord> b(7);
+ mln_assertion(b.delta() == 3);
+ mln_assertion(b.size() == 29);
+
+ debug::println(convert::to_image(b));
+ // - - - | - - -
+ // - | | | | | -
+ // - | | | | | -
+ // | | | | | | |
+ // - | | | | | -
+ // - | | | | | -
+ // - - - | - - -
+}
Index: tests/win/sphere3d.cc
--- tests/win/sphere3d.cc (revision 0)
+++ tests/win/sphere3d.cc (revision 0)
@@ -0,0 +1,42 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// 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/win/sphere3d.cc
+///
+/// Tests on mln::win::sphere3d.
+
+#include <mln/win/sphere3d.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ win::sphere3d s(3);
+ mln_assertion(s.delta() == 1);
+ mln_assertion(s.size() == 7);
+}
Index: tests/win/disk2d.cc
--- tests/win/disk2d.cc (revision 3458)
+++ tests/win/disk2d.cc (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -31,10 +31,7 @@
/// Tests on mln::win::disk2d.
#include <cmath>
-
#include <mln/win/disk2d.hh>
-#include <mln/convert/to_image.hh>
-#include <mln/debug/println.hh>
int main()
@@ -56,6 +53,4 @@
std::abs(x) > 27 ||
std::abs(y) > 27);
}
-
- debug::println(convert::to_image(disk));
}
Index: tests/win/Makefile.am
--- tests/win/Makefile.am (revision 3458)
+++ tests/win/Makefile.am (working copy)
@@ -4,6 +4,7 @@
check_PROGRAMS = \
backdiag2d \
+ ball \
cube3d \
cuboid3d \
diag2d \
@@ -15,10 +16,12 @@
rectangle2d \
segment1d \
shift \
+ sphere3d \
sym \
vline2d
backdiag2d_SOURCES = backdiag2d.cc
+ball_SOURCES = ball.cc
cube3d_SOURCES = cube3d.cc
cuboid3d_SOURCES = cuboid3d.cc
diag2d_SOURCES = diag2d.cc
@@ -30,6 +33,7 @@
rectangle2d_SOURCES = rectangle2d.cc
segment1d_SOURCES = segment1d.cc
shift_SOURCES = shift.cc
+sphere3d_SOURCES = sphere3d.cc
sym_SOURCES = sym.cc
vline2d_SOURCES = vline2d.cc