cleanup-2008 2462: Make the difference between geom and win materials.

https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena Index: ChangeLog from Thierry Geraud <thierry.geraud@lrde.epita.fr> Make the difference between geom and win materials. Move window-related routines from mln/geom to mln/win. * mln/geom/sym.hh: Move to... * mln/win/sym.hh: ...here. * mln/geom/shift.hh: Move to... * mln/win/shift.hh: ...here. * tests/geom/sym.cc: Move to... * tests/win/sym.cc: ...here and update. * tests/geom/shift.cc: Move to... * tests/win/shift.cc: ...here and update. * tests/geom/Makefile.am: Update. * mln/geom/all.hh: Update. * mln/win/all.hh: Update. Move window difference into mln/win. * mln/set/diff.hh (diff): Move overload on windows into... * mln/win/diff.hh: ...this new file. (diff): Rename as... (operator-): ...this and update. * tests/win/diff.cc: New. * tests/win/Makefile.am: Update. * tests/set/diff.cc: Update. Propagate those modifications. * tests/win/cuboid3d.cc, * tests/win/rectangle2d.cc, * tests/morpho/hit_or_miss.cc, * mln/core/alias/neighb1d.hh, * mln/core/alias/neighb3d.hh, * mln/core/neighb.hh, * mln/core/concept/window.hh, * mln/level/was.median.hh, * mln/level/median.hh, * mln/level/fast_median.hh, * mln/morpho/erosion_fast.hh, * mln/morpho/erosion.spe.hh, * mln/morpho/hit_or_miss.hh, * mln/morpho/closing.hh, * mln/morpho/opening.hh, * mln/morpho/includes.hh, * mln/morpho/dilation_fast.hh, * mln/canvas/chamfer.hh, * sandbox/duhamel/canvas_chamfer.hh, * sandbox/nivault/median.hh: Update. mln/canvas/chamfer.hh | 4 - mln/core/alias/neighb1d.hh | 1 mln/core/alias/neighb3d.hh | 8 +- mln/core/concept/window.hh | 19 ++++++ mln/core/neighb.hh | 3 - mln/geom/all.hh | 4 - mln/level/fast_median.hh | 18 +++--- mln/level/median.hh | 17 +++--- mln/level/was.median.hh | 22 ++++---- mln/morpho/closing.hh | 2 mln/morpho/dilation_fast.hh | 17 +++--- mln/morpho/erosion.spe.hh | 26 +++++---- mln/morpho/erosion_fast.hh | 19 +++--- mln/morpho/hit_or_miss.hh | 4 - mln/morpho/includes.hh | 4 + mln/morpho/opening.hh | 2 mln/set/diff.hh | 35 ------------ mln/win/all.hh | 9 +++ mln/win/diff.hh | 104 ++++++++++++++++++++++++++++++++++++++ mln/win/shift.hh | 8 +- mln/win/sym.hh | 12 ++-- sandbox/duhamel/canvas_chamfer.hh | 2 sandbox/nivault/median.hh | 2 tests/geom/Makefile.am | 6 -- tests/morpho/hit_or_miss.cc | 9 +-- tests/set/diff.cc | 36 +------------ tests/win/Makefile.am | 6 ++ tests/win/cuboid3d.cc | 4 - tests/win/diff.cc | 66 +++++++----------------- tests/win/rectangle2d.cc | 5 + tests/win/shift.cc | 4 - tests/win/sym.cc | 4 - 32 files changed, 272 insertions(+), 210 deletions(-) Index: tests/geom/Makefile.am --- tests/geom/Makefile.am (revision 2461) +++ tests/geom/Makefile.am (working copy) @@ -19,9 +19,7 @@ pmin_pmax \ resize \ seed2tiling \ -seed2tiling_roundness \ -shift \ -sym +seed2tiling_roundness bbox_SOURCES = bbox.cc max_col_SOURCES = max_col.cc @@ -40,7 +38,5 @@ resize_SOURCES = resize.cc seed2tiling_SOURCES = seed2tiling.cc seed2tiling_roundness_SOURCES = seed2tiling_roundness.cc -shift_SOURCES = shift.cc -sym_SOURCES = sym.cc TESTS = $(check_PROGRAMS) Index: tests/set/diff.cc --- tests/set/diff.cc (revision 2461) +++ tests/set/diff.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -30,41 +30,15 @@ * \brief Tests on mln::set::diff. */ -#include <mln/set/diff.hh> +#include <mln/core/site_set/p_set.hh> #include <mln/core/alias/dpoint2d.hh> +#include <mln/set/diff.hh> + int main() { using namespace mln; - { - window<dpoint2d> win1; - win1.insert( 2, 7); - win1.insert( 2, 1); - win1.insert(-4, 0); - win1.insert( 0, 0); - win1.insert( 1, 1); - win1.insert( 6, 5); - - window<dpoint2d> win2; - win2.insert( 2, 7); - win2.insert(-2, 1); - win2.insert(-4, 0); - win2.insert( 1,-1); - win2.insert( 6, 5); - - window<dpoint2d> win3 = set::diff(win1, win2); - mln_assertion(win3.has(dpoint2d( 2, 1))); - mln_assertion(win3.has(dpoint2d( 0, 0))); - mln_assertion(win3.has(dpoint2d( 1, 1))); - mln_assertion(!win3.has(dpoint2d( 2, 7))); - mln_assertion(!win3.has(dpoint2d(-2, 1))); - mln_assertion(!win3.has(dpoint2d(-4, 0))); - mln_assertion(!win3.has(dpoint2d( 1,-1))); - mln_assertion(!win3.has(dpoint2d( 6, 5))); - } - - { p_set<point2d> pst1; pst1.insert(point2d( 2, 7)); pst1.insert(point2d( 2, 1)); @@ -81,6 +55,7 @@ pst2.insert(point2d( 6, 5)); p_set<point2d> pst3 = set::diff(pst1, pst2); + mln_assertion(pst3.has(point2d( 2, 1))); mln_assertion(pst3.has(point2d( 0, 0))); mln_assertion(pst3.has(point2d( 1, 1))); @@ -90,4 +65,3 @@ mln_assertion(!pst3.has(point2d( 1,-1))); mln_assertion(!pst3.has(point2d( 6, 5))); } -} Index: tests/win/cuboid3d.cc --- tests/win/cuboid3d.cc (revision 2461) +++ tests/win/cuboid3d.cc (working copy) @@ -32,7 +32,7 @@ #include <cmath> #include <mln/win/cuboid3d.hh> -#include <mln/geom/sym.hh> +#include <mln/win/sym.hh> #include <mln/convert/to_image.hh> @@ -47,7 +47,7 @@ mln_assertion(cuboid.is_centered()); mln_assertion(cuboid.is_symmetric()); - mln_assertion(cuboid == geom::sym(cuboid)); + mln_assertion(cuboid == win::sym(cuboid)); mln_assertion(cuboid.size() == d * h * w); mln_assertion(cuboid.delta() == 3); Index: tests/win/shift.cc --- tests/win/shift.cc (revision 2451) +++ tests/win/shift.cc (working copy) @@ -28,7 +28,7 @@ #include <mln/core/alias/window2d.hh> #include <mln/core/alias/dpoint2d.hh> -#include <mln/geom/shift.hh> +#include <mln/win/shift.hh> int main() { @@ -50,5 +50,5 @@ win2.insert(dpoint2d(7,8)); win2.insert(dpoint2d(9,10)); - mln_assertion(geom::shift(win, dp) == win2); + mln_assertion(win::shift(win, dp) == win2); } Index: tests/win/Makefile.am --- tests/win/Makefile.am (revision 2461) +++ tests/win/Makefile.am (working copy) @@ -7,22 +7,28 @@ cube3d \ cuboid3d \ diag2d \ + diff \ disk2d \ hline2d \ octagon2d \ rectangle2d \ segment1d \ + shift \ + sym \ vline2d backdiag2d_SOURCES = backdiag2d.cc cube3d_SOURCES = cube3d.cc cuboid3d_SOURCES = cuboid3d.cc diag2d_SOURCES = diag2d.cc +diff_SOURCES = diff.cc disk2d_SOURCES = disk2d.cc hline2d_SOURCES = hline2d.cc octagon2d_SOURCES = octagon2d.cc rectangle2d_SOURCES = rectangle2d.cc segment1d_SOURCES = segment1d.cc +shift_SOURCES = shift.cc +sym_SOURCES = sym.cc vline2d_SOURCES = vline2d.cc TESTS = $(check_PROGRAMS) Index: tests/win/sym.cc --- tests/win/sym.cc (revision 2451) +++ tests/win/sym.cc (working copy) @@ -28,7 +28,7 @@ #include <mln/core/alias/window2d.hh> #include <mln/core/alias/dpoint2d.hh> -#include <mln/geom/sym.hh> +#include <mln/win/sym.hh> int main() { @@ -50,5 +50,5 @@ win2.insert(dpoint2d(-5,-6)); win2.insert(dpoint2d(-7,-8)); - mln_assertion(geom::sym(win) == win2); + mln_assertion(win::sym(win) == win2); } Index: tests/win/diff.cc --- tests/win/diff.cc (revision 2451) +++ tests/win/diff.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -25,69 +25,45 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/*! \file tests/set/diff.cc +/*! \file tests/win/diff.cc * - * \brief Tests on mln::set::diff. + * \brief Tests on mln::win::diff. */ -#include <mln/set/diff.hh> #include <mln/core/alias/dpoint2d.hh> +#include <mln/win/diff.hh> + int main() { using namespace mln; - { window<dpoint2d> win1; - win1.insert( 2, 7); - win1.insert( 2, 1); - win1.insert(-4, 0); - win1.insert( 0, 0); - win1.insert( 1, 1); - win1.insert( 6, 5); + win1 + .insert( 2, 7) + .insert( 2, 1) + .insert(-4, 0) + .insert( 0, 0) + .insert( 1, 1) + .insert( 6, 5); window<dpoint2d> win2; - win2.insert( 2, 7); - win2.insert(-2, 1); - win2.insert(-4, 0); - win2.insert( 1,-1); - win2.insert( 6, 5); + win2 + .insert( 2, 7) + .insert(-2, 1) + .insert(-4, 0) + .insert( 1,-1) + .insert( 6, 5); + + window<dpoint2d> win3 = win1 - win2; - window<dpoint2d> win3 = set::diff(win1, win2); mln_assertion(win3.has(dpoint2d( 2, 1))); mln_assertion(win3.has(dpoint2d( 0, 0))); mln_assertion(win3.has(dpoint2d( 1, 1))); + mln_assertion(!win3.has(dpoint2d( 2, 7))); mln_assertion(!win3.has(dpoint2d(-2, 1))); mln_assertion(!win3.has(dpoint2d(-4, 0))); mln_assertion(!win3.has(dpoint2d( 1,-1))); mln_assertion(!win3.has(dpoint2d( 6, 5))); } - - { - p_set<point2d> pst1; - pst1.insert(point2d( 2, 7)); - pst1.insert(point2d( 2, 1)); - pst1.insert(point2d(-4, 0)); - pst1.insert(point2d( 0, 0)); - pst1.insert(point2d( 1, 1)); - pst1.insert(point2d( 6, 5)); - - p_set<point2d> pst2; - pst2.insert(point2d( 2, 7)); - pst2.insert(point2d(-2, 1)); - pst2.insert(point2d(-4, 0)); - pst2.insert(point2d( 1,-1)); - pst2.insert(point2d( 6, 5)); - - p_set<point2d> pst3 = set::diff(pst1, pst2); - mln_assertion(pst3.has(point2d( 2, 1))); - mln_assertion(pst3.has(point2d( 0, 0))); - mln_assertion(pst3.has(point2d( 1, 1))); - mln_assertion(!pst3.has(point2d( 2, 7))); - mln_assertion(!pst3.has(point2d(-2, 1))); - mln_assertion(!pst3.has(point2d(-4, 0))); - mln_assertion(!pst3.has(point2d( 1,-1))); - mln_assertion(!pst3.has(point2d( 6, 5))); - } -} Index: tests/win/rectangle2d.cc --- tests/win/rectangle2d.cc (revision 2461) +++ tests/win/rectangle2d.cc (working copy) @@ -32,12 +32,13 @@ #include <cmath> #include <mln/win/rectangle2d.hh> -#include <mln/geom/sym.hh> +#include <mln/win/sym.hh> #include <mln/convert/to_image.hh> #include <mln/debug/println.hh> + int main() { using namespace mln; @@ -47,7 +48,7 @@ mln_assertion(rec.is_centered()); mln_assertion(rec.is_symmetric()); - mln_assertion(rec == geom::sym(rec)); + mln_assertion(rec == win::sym(rec)); mln_assertion(rec.size() == h * w); mln_assertion(rec.delta() == 2); Index: tests/morpho/hit_or_miss.cc --- tests/morpho/hit_or_miss.cc (revision 2461) +++ tests/morpho/hit_or_miss.cc (working copy) @@ -35,8 +35,9 @@ #include <mln/win/rectangle2d.hh> #include <mln/core/alias/window2d.hh> -#include <mln/geom/shift.hh> -#include <mln/set/diff.hh> + +#include <mln/win/shift.hh> +#include <mln/win/diff.hh> #include <mln/io/pbm/load.hh> #include <mln/io/pbm/save.hh> @@ -54,9 +55,9 @@ using namespace mln; using value::int_u8; - window2d win_hit = geom::shift(win::rectangle2d(3, 3), + window2d win_hit = win::shift(win::rectangle2d(3, 3), dpoint2d(+1, +1)); - window2d win_miss = mln::set::diff(win::rectangle2d(5, 5), win_hit); + window2d win_miss = win::rectangle2d(5, 5) - win_hit; { bool hit[] = { 0, 0, 0, 0, 0, Index: mln/core/alias/neighb1d.hh --- mln/core/alias/neighb1d.hh (revision 2461) +++ mln/core/alias/neighb1d.hh (working copy) @@ -37,7 +37,6 @@ # include <cmath> # include <mln/core/neighb.hh> # include <mln/core/alias/window1d.hh> -# include <mln/geom/sym.hh> namespace mln Index: mln/core/alias/neighb3d.hh --- mln/core/alias/neighb3d.hh (revision 2461) +++ mln/core/alias/neighb3d.hh (working copy) @@ -37,7 +37,7 @@ # include <cmath> # include <mln/core/neighb.hh> # include <mln/core/alias/window3d.hh> -# include <mln/geom/sym.hh> +# include <mln/win/sym.hh> namespace mln @@ -119,7 +119,7 @@ .insert(0, 1, 0) .insert(0, 0, 1); win - .insert(geom::sym(win)); + .insert(win::sym(win)); } return it; } @@ -139,7 +139,7 @@ .insert(1, 1, 0) .insert(1, -1, 0); win - .insert(geom::sym(win)) + .insert(win::sym(win)) .insert(c6().win()); } return it; @@ -158,7 +158,7 @@ .insert(1, -1, 1) .insert(1, -1, -1); win - .insert(geom::sym(win)) + .insert(win::sym(win)) .insert(c18().win()); } return it; Index: mln/core/neighb.hh --- mln/core/neighb.hh (revision 2461) +++ mln/core/neighb.hh (working copy) @@ -47,7 +47,8 @@ namespace mln { - // Forward declaration. + + // Forward declarations. template <typename W> class neighb_fwd_niter; template <typename W> class neighb_bkd_niter; Index: mln/core/concept/window.hh --- mln/core/concept/window.hh (revision 2461) +++ mln/core/concept/window.hh (working copy) @@ -42,6 +42,18 @@ # include <mln/core/site_set/p_array.hh> + +# define mln_is_simple_window(W) \ + \ +mln::metal::and_< mlc_is(mln_trait_window_size(W), \ + mln::trait::window::size::fixed), \ + mln::metal::and_< mlc_is(mln_trait_window_support(W), \ + mln::trait::window::support::regular), \ + mlc_is(mln_trait_window_definition(W), \ + mln::trait::window::definition::unique) > > + + + namespace mln { @@ -90,8 +102,15 @@ + template <typename W> + void check_simple(const Window<W>& win); + + + # ifndef MLN_INCLUDE_ONLY + + namespace internal { Index: mln/level/was.median.hh --- mln/level/was.median.hh (revision 2461) +++ mln/level/was.median.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -33,13 +33,17 @@ * \brief Obsolete routines for median filtering. */ -# include <mln/geom/shift.hh> +# include <mln/win/shift.hh> # include <mln/core/alias/window2d.hh> + # include <mln/geom/min_col.hh> # include <mln/geom/max_col.hh> # include <mln/geom/max_row.hh> # include <mln/geom/min_row.hh> -# include <mln/set/diff.hh> + +# include <mln/win/diff.hh> +# include <mln/win/shift.hh> + # include <mln/level/median.hh> # include <mln/win/hline2d.hh> @@ -68,12 +72,12 @@ min_col = geom::min_col(input), max_col = geom::max_col(input); window2d - win_fwd_plus = set::diff(win, geom::shift(win, left)), - win_fwd_minus = set::diff(geom::shift(win, left), win), - win_bkd_plus = set::diff(win, geom::shift(win, right)), - win_bkd_minus = set::diff(geom::shift(win, right), win), - win_bot = set::diff(win, geom::shift(win, up)), - win_top = set::diff(geom::shift(win, up), win); + win_fwd_plus = win - win::shift(win, left), + win_fwd_minus = win::shift(win, left) - win, + win_bkd_plus = win - win::shift(win, right), + win_bkd_minus = win::shift(win, right) - win, + win_bot = win - win::shift(win, up), + win_top = win::shift(win, up) - win; point2d p; mln_qiter(W) Index: mln/level/median.hh --- mln/level/median.hh (revision 2461) +++ mln/level/median.hh (working copy) @@ -38,8 +38,9 @@ # include <mln/core/concept/image.hh> # include <mln/core/window.hh> # include <mln/core/alias/dpoint2d.hh> -# include <mln/geom/shift.hh> -# include <mln/set/diff.hh> + +# include <mln/win/shift.hh> +# include <mln/win/diff.hh> # include <mln/canvas/browsing/snake_fwd.hh> # include <mln/canvas/browsing/dir_struct_elt_incr_update.hh> @@ -125,12 +126,12 @@ // aux data med(), p(), - win_fp(set::diff(win, geom::shift(win, left))), - win_fm(set::diff(geom::shift(win, left), win)), - win_bp(set::diff(win, geom::shift(win, right))), - win_bm(set::diff(geom::shift(win, right), win)), - win_dp(set::diff(win, geom::shift(win, up))), - win_dm(set::diff(geom::shift(win, up), win)), + win_fp(win - win::shift(win, left)), + win_fm(win::shift(win, left) - win), + win_bp(win - win::shift(win, right)), + win_bm(win::shift(win, right) - win), + win_dp(win - win::shift(win, up)), + win_dm(win::shift(win, up) - win), q_fp(win_fp, p), q_fm(win_fm, p), q_bp(win_bp, p), q_bm(win_bm, p), q_dp(win_dp, p), q_dm(win_dm, p) Index: mln/level/fast_median.hh --- mln/level/fast_median.hh (revision 2461) +++ mln/level/fast_median.hh (working copy) @@ -38,12 +38,14 @@ # include <mln/core/concept/image.hh> # include <mln/core/alias/window2d.hh> # include <mln/accu/median_h.hh> -# include <mln/geom/shift.hh> + +# include <mln/win/shift.hh> +# include <mln/win/diff.hh> + # include <mln/geom/min_col.hh> # include <mln/geom/min_row.hh> # include <mln/geom/max_col.hh> # include <mln/geom/max_row.hh> -# include <mln/set/diff.hh> namespace mln @@ -86,12 +88,12 @@ min_col = geom::min_col(input), max_col = geom::max_col(input); window2d - win_fwd_plus = set::diff(win, geom::shift(win, left)), - win_fwd_minus = set::diff(geom::shift(win, left), win), - win_bkd_plus = set::diff(win, geom::shift(win, right)), - win_bkd_minus = set::diff(geom::shift(win, right), win), - win_bot = set::diff(win, geom::shift(win, up)), - win_top = set::diff(geom::shift(win, up), win); + win_fwd_plus = win - win::shift(win, left), + win_fwd_minus = win::shift(win, left) - win, + win_bkd_plus = win - win::shift(win, right), + win_bkd_minus = win::shift(win, right) - win, + win_bot = win - win::shift(win, up), + win_top = win::shift(win, up) - win; accu::median_h<mln_value(I)> med; Index: mln/geom/all.hh --- mln/geom/all.hh (revision 2461) +++ mln/geom/all.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -51,11 +51,9 @@ # include <mln/geom/pmin_pmax.hh> # include <mln/geom/seeds2tiling.hh> # include <mln/geom/seeds2tiling_roundness.hh> -# include <mln/geom/shift.hh> # include <mln/geom/size1d.hh> # include <mln/geom/size2d.hh> # include <mln/geom/size3d.hh> -# include <mln/geom/sym.hh> #endif // ! MLN_GEOM_ALL_HH Index: mln/set/diff.hh --- mln/set/diff.hh (revision 2461) +++ mln/set/diff.hh (working copy) @@ -37,7 +37,6 @@ */ # include <mln/convert/to_std_set.hh> -# include <mln/convert/to_window.hh> # include <mln/convert/to_p_set.hh> # include <mln/metal/equal.hh> @@ -51,14 +50,6 @@ /*! \brief Set theoretic difference of \p lhs and \p rhs. * - * \relates mln::Window - */ - template <typename Wl, typename Wr> - window<mln_dpsite(Wl)> - diff(const Window<Wl>& lhs, const Window<Wr>& rhs); - - /*! \brief Set theoretic difference of \p lhs and \p rhs. - * * \relates mln::Site_Set */ template <typename Wl, typename Wr> @@ -70,32 +61,6 @@ template <typename Wl, typename Wr> inline - window<mln_dpsite(Wl)> - diff(const Window<Wl>& lhs_, const Window<Wr>& rhs_) - { - trace::entering("set::diff"); - mlc_is_a(mln_site(Wl), Gpoint)::check(); - mlc_is_a(mln_site(Wr), Gpoint)::check(); - mlc_converts_to(mln_dpsite(Wl), mln_dpsite(Wr))::check(); - - const Wl& lhs = exact(lhs_); - const Wr& rhs = exact(rhs_); - window<mln_dpsite(Wl)> tmp; - - const unsigned n = lhs.size(); - for (unsigned i = 0; i < n; ++i) - { - if (rhs.has(lhs.dp(i))) - continue; - tmp.insert(lhs.dp(i)); - } - - trace::exiting("set::diff"); - return tmp; - } - - template <typename Wl, typename Wr> - inline p_set<mln_psite(Wl)> diff(const Site_Set<Wl>& lhs, const Site_Set<Wr>& rhs) { Index: mln/win/diff.hh --- mln/win/diff.hh (revision 0) +++ mln/win/diff.hh (revision 0) @@ -0,0 +1,104 @@ +// Copyright (C) 2008 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_WIN_DIFF_HH +# define MLN_WIN_DIFF_HH + +/*! \file mln/win/diff.hh + * + * \brief Set difference between a couple of windows or neighborhoods. + */ + +# include <mln/core/window.hh> +# include <mln/core/neighb.hh> + + + +namespace mln +{ + + namespace win + { + + /// Set difference between a couple of windows \p win1 and \p win2. + template <typename W1, typename W2> + mln_regular(W1) + operator-(const Window<W1>& win1, const Window<W2>& win2); + + /// Set difference between a couple of neighborhoods \p nbh1 and \p nbh2. + template <typename N1, typename N2> + neighb<mln_deduce(N1, window, regular)> + operator-(const Neighborhood<N1>& nbh1, const Neighborhood<N2>& nbh2); + + +# ifndef MLN_INCLUDE_ONLY + + template <typename W1, typename W2> + inline + mln_regular(W1) + operator-(const Window<W1>& win1_, const Window<W2>& win2_) + { + trace::entering("win::diff"); + + mln_is_simple_window(W1)::check(); + mln_is_simple_window(W2)::check(); + + const W1& win1 = exact(win1_); + const W2& win2 = exact(win2_); + mln_regular(W1) tmp; + + const unsigned n = win1.size(); + for (unsigned i = 0; i < n; ++i) + { + if (win2.has(win1.dp(i))) + continue; + tmp.insert(win1.dp(i)); + } + + trace::exiting("win::diff"); + return tmp; + } + + + template <typename N1, typename N2> + neighb<mln_deduce(N1, window, regular)> + operator-(const Neighborhood<N1>& nbh1, const Neighborhood<N2>& nbh2) + { + typedef mln_deduce(N1, window, regular) W1; + W1 win = diff(exact(nbh1).win(), exact(nbh2).win()); + neighb<W1> tmp(win); + return tmp; + } + +# endif // ! MLN_INCLUDE_ONLY + + } // end of namespace mln::win + +} // end of namespace mln + + +#endif // ! MLN_WIN_DIFF_HH Index: mln/win/sym.hh --- mln/win/sym.hh (revision 2451) +++ mln/win/sym.hh (working copy) @@ -25,10 +25,10 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef MLN_GEOM_SYM_HH -# define MLN_GEOM_SYM_HH +#ifndef MLN_WIN_SYM_HH +# define MLN_WIN_SYM_HH -/*! \file mln/geom/sym.hh +/*! \file mln/win/sym.hh * * \brief Give the symmetrical object. */ @@ -41,7 +41,7 @@ namespace mln { - namespace geom + namespace win { /*! \brief Give the symmetrical window of \p win. @@ -77,9 +77,9 @@ # endif // ! MLN_INCLUDE_ONLY - } // end of namespace mln::geom + } // end of namespace mln::win } // end of namespace mln -#endif // ! MLN_GEOM_SYM_HH +#endif // ! MLN_WIN_SYM_HH Index: mln/win/all.hh --- mln/win/all.hh (revision 2461) +++ mln/win/all.hh (working copy) @@ -42,6 +42,9 @@ } + +// Types. + # include <mln/win/backdiag2d.hh> # include <mln/win/cube3d.hh> # include <mln/win/cuboid3d.hh> @@ -55,6 +58,12 @@ # include <mln/win/segment1d.hh> # include <mln/win/vline2d.hh> +// Routines. + +# include <mln/win/diff.hh> +# include <mln/win/shift.hh> +# include <mln/win/sym.hh> + #endif // ! MLN_WIN_ALL_HH Index: mln/win/shift.hh --- mln/win/shift.hh (revision 2451) +++ mln/win/shift.hh (working copy) @@ -28,7 +28,7 @@ #ifndef MLN_GEOM_SHIFT_HH # define MLN_GEOM_SHIFT_HH -/*! \file mln/geom/shift.hh +/*! \file mln/win/shift.hh * * \brief Define a function which shifts a window with a delta-point. */ @@ -78,7 +78,7 @@ mln_regular(W) tmp(win.function()); const unsigned nw = win.nwindows(); for (unsigned w = 0; w < nw; ++w) - tmp.set_window(w, geom::shift(win.window(w), dp)); + tmp.set_window(w, win::shift(win.window(w), dp)); return tmp; } @@ -91,7 +91,7 @@ mln_regular(W) shift(const Window<W>& win, const mln_dpsite(W)& dp) { - trace::entering("geom::shift"); + trace::entering("win::shift"); mlc_is(mln_trait_window_support(W), trait::window::support::regular)::check(); @@ -101,7 +101,7 @@ mln_regular(W) tmp = impl::shift_(mln_trait_window_definition(W)(), exact(win), dp); - trace::exiting("geom::shift"); + trace::exiting("win::shift"); return tmp; } Index: mln/morpho/erosion_fast.hh --- mln/morpho/erosion_fast.hh (revision 2461) +++ mln/morpho/erosion_fast.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -38,8 +38,9 @@ # include <mln/core/concept/image.hh> # include <mln/core/window.hh> # include <mln/core/alias/dpoint2d.hh> -# include <mln/geom/shift.hh> -# include <mln/set/diff.hh> + +# include <mln/win/shift.hh> +# include <mln/win/diff.hh> # include <mln/canvas/browsing/snake_fwd.hh> # include <mln/accu/min_h.hh> @@ -107,12 +108,12 @@ // aux data min(input.values()), p(), - win_fp(set::diff(win, geom::shift(win, left))), - win_fm(set::diff(geom::shift(win, left), win)), - win_bp(set::diff(win, geom::shift(win, right))), - win_bm(set::diff(geom::shift(win, right), win)), - win_dp(set::diff(win, geom::shift(win, up))), - win_dm(set::diff(geom::shift(win, up), win)), + win_fp(win - win::shift(win, left)), + win_fm(win::shift(win, left) - win), + win_bp(win - win::shift(win, right)), + win_bm(win::shift(win, right) - win), + win_dp(win - win::shift(win, up)), + win_dm(win::shift(win, up) - win), q_fp(win_fp, p), q_fm(win_fm, p), q_bp(win_bp, p), q_bm(win_bm, p), q_dp(win_dp, p), q_dm(win_dm, p) Index: mln/morpho/erosion.spe.hh --- mln/morpho/erosion.spe.hh (revision 2461) +++ mln/morpho/erosion.spe.hh (working copy) @@ -35,9 +35,11 @@ # include <mln/core/alias/window2d.hh> # include <mln/win/octagon2d.hh> # include <mln/win/rectangle2d.hh> -# include <mln/geom/shift.hh> + +# include <mln/win/shift.hh> +# include <mln/win/diff.hh> + # include <mln/accu/min_h.hh> -# include <mln/set/diff.hh> # include <mln/canvas/browsing/snake_fwd.hh> @@ -279,10 +281,10 @@ : input(input), win(win), min(), - win_left(set::diff(geom::shift(win, left), win)), - win_right(set::diff(win, geom::shift(win, left))), - win_bot(set::diff(win, geom::shift(win, up))), - win_top(set::diff(geom::shift(win, up), win)), + win_left(win::shift(win, left) - win), + win_right(win - win::shift(win, left)), + win_bot(win - win::shift(win, up)), + win_top(win::shift(win, up) - win), q_l(input, win_left, p), q_r(input, win_right, p), q_top(input, win_top, p), @@ -376,10 +378,10 @@ : input(input), win(win), min(), - win_left(set::diff(geom::shift(win, left), win)), - win_right(set::diff(win, geom::shift(win, left))), - win_bot(set::diff(win, geom::shift(win, up))), - win_top(set::diff(geom::shift(win, up), win)), + win_left(win::shift(win, left) - win), + win_right(win - win::shift(win, left)), + win_bot(win - win::shift(win, up)), + win_top(win::shift(win, up) - win), q_l(win_left, p), q_r(win_right, p), q_top(win_top, p), @@ -562,8 +564,8 @@ erosion_dispatch_wrt_win(const I& input, const W& win) { // FIXME: De-activate because, when win is multiple, - // geom::shift does not work. We have to introduce - // props from windows, then re-write geom::shift. + // win::shift does not work. We have to introduce + // props from windows, then re-write win::shift. // if (erosion_chooses_arbitrary(input, win)) // return erosion_dispatch_for_arbitrary(input, win); Index: mln/morpho/hit_or_miss.hh --- mln/morpho/hit_or_miss.hh (revision 2461) +++ mln/morpho/hit_or_miss.hh (working copy) @@ -224,7 +224,7 @@ impl::hit_or_miss_preconditions_(input, win_hit, win_miss); mln_concrete(I) output = dilation( hit_or_miss(input, win_hit, win_miss), - geom::sym(win_hit) ); + win::sym(win_hit) ); trace::exiting("morpho::hit_or_miss_opening"); return output; @@ -243,7 +243,7 @@ mln_concrete(I) output = hit_or_miss_opening(complementation(input), win_miss, win_hit); mln_postcondition( dilation( hit_or_miss(input, win_hit, win_miss), - geom::sym(win_miss) ) == output); + win::sym(win_miss) ) == output); trace::exiting("morpho::hit_or_miss_background_opening"); return output; } Index: mln/morpho/closing.hh --- mln/morpho/closing.hh (revision 2461) +++ mln/morpho/closing.hh (working copy) @@ -60,7 +60,7 @@ mln_precondition(exact(input).has_data()); mln_precondition(! exact(win).is_empty()); - mln_concrete(I) output = erosion(dilation(input, win), geom::sym(win)); + mln_concrete(I) output = erosion(dilation(input, win), win::sym(win)); mln_postcondition(output >= input); trace::exiting("morpho::closing"); Index: mln/morpho/opening.hh --- mln/morpho/opening.hh (revision 2461) +++ mln/morpho/opening.hh (working copy) @@ -60,7 +60,7 @@ mln_precondition(exact(input).has_data()); mln_precondition(! exact(win).is_empty()); - mln_concrete(I) output = dilation(erosion(input, win), geom::sym(win)); + mln_concrete(I) output = dilation(erosion(input, win), win::sym(win)); // FIXME: Is this postcondition always true, even if the // structuring element is not centered? Index: mln/morpho/includes.hh --- mln/morpho/includes.hh (revision 2461) +++ mln/morpho/includes.hh (working copy) @@ -57,7 +57,9 @@ # include <mln/extension/all.hh> -# include <mln/geom/sym.hh> +# include <mln/win/sym.hh> +# include <mln/win/shift.hh> +# include <mln/win/diff.hh> # include <mln/set/inter.hh> # include <mln/morpho/dilation.hh> Index: mln/morpho/dilation_fast.hh --- mln/morpho/dilation_fast.hh (revision 2461) +++ mln/morpho/dilation_fast.hh (working copy) @@ -38,8 +38,9 @@ # include <mln/core/concept/image.hh> # include <mln/core/window.hh> # include <mln/core/alias/dpoint2d.hh> -# include <mln/geom/shift.hh> -# include <mln/set/diff.hh> + +# include <mln/win/shift.hh> +# include <mln/win/diff.hh> # include <mln/canvas/browsing/snake_fwd.hh> # include <mln/accu/max_h.hh> @@ -107,12 +108,12 @@ // aux data max(input.values()), p(), - win_fp(set::diff(win, geom::shift(win, left))), - win_fm(set::diff(geom::shift(win, left), win)), - win_bp(set::diff(win, geom::shift(win, right))), - win_bm(set::diff(geom::shift(win, right), win)), - win_dp(set::diff(win, geom::shift(win, up))), - win_dm(set::diff(geom::shift(win, up), win)), + win_fp(win - win::shift(win, left)), + win_fm(win::shift(win, left) - win), + win_bp(win - win::shift(win, right)), + win_bm(win::shift(win, right) - win), + win_dp(win - win::shift(win, up)), + win_dm(win::shift(win, up) - win), q_fp(win_fp, p), q_fm(win_fm, p), q_bp(win_bp, p), q_bm(win_bm, p), q_dp(win_dp, p), q_dm(win_dm, p) Index: mln/canvas/chamfer.hh --- mln/canvas/chamfer.hh (revision 2461) +++ mln/canvas/chamfer.hh (working copy) @@ -34,7 +34,7 @@ */ # include <mln/core/internal/image_morpher.hh> -# include <mln/geom/sym.hh> +# include <mln/win/sym.hh> namespace mln { @@ -94,7 +94,7 @@ /// Bkd pass. { - W w_win_b = geom::sym(f.win); + W w_win_b = win::sym(f.win); mln_bkd_piter(I) p(f.input.domain()); mln_qiter(W) q(w_win_b, p); Index: sandbox/duhamel/canvas_chamfer.hh --- sandbox/duhamel/canvas_chamfer.hh (revision 2461) +++ sandbox/duhamel/canvas_chamfer.hh (working copy) @@ -75,7 +75,7 @@ /// Bkd pass. { - W w_win_b = geom::sym(f.win); + W w_win_b = win::sym(f.win); mln_bkd_piter(I) p(f.input.domain()); mln_qiter(W) q(w_win_b, p); Index: sandbox/nivault/median.hh --- sandbox/nivault/median.hh (revision 2461) +++ sandbox/nivault/median.hh (working copy) @@ -45,7 +45,7 @@ # include <mln/accu/median.hh> # include <mln/canvas/browsing/snake_fwd.hh> -# include <mln/geom/shift.hh> +# include <mln/win/shift.hh> # include <mln/set/diff.hh> # include <mln/border/resize.hh>
participants (1)
-
Thierry Geraud