
* milena/headers.mk: add new headers to distribution. * milena/mln/core/image/graph_elt_neighborhood.hh, * milena/mln/core/image/line_graph_elt_neighborhood.hh: new files. Add new aliases for graph based neighborhoods. * milena/mln/core/image/graph_elt_window.hh, * milena/mln/core/image/line_graph_elt_window.hh, * milena/mln/core/internal/neighborhood_base.hh, * milena/tests/core/image/graph_image.cc, * milena/tests/core/image/line_graph_image.cc, * milena/tests/core/other/graph_elt_neighborhood.cc, * milena/tests/core/other/line_graph_elt_neighborhood.cc, * milena/tools/area_flooding.cc: make use of these new aliases. * milena/tests/unit_test/Makefile.am, * milena/tests/unit_test/mln_core_image_graph_elt_neighborhood.cc, * milena/tests/unit_test/mln_core_image_line_graph_elt_neighborhood.cc: Add new unit tests. --- milena/ChangeLog | 24 ++++++ milena/headers.mk | 2 + milena/mln/core/image/graph_elt_neighborhood.hh | 79 ++++++++++++++++++++ milena/mln/core/image/graph_elt_window.hh | 14 +--- .../mln/core/image/line_graph_elt_neighborhood.hh | 79 ++++++++++++++++++++ milena/mln/core/image/line_graph_elt_window.hh | 15 +--- milena/mln/core/internal/neighborhood_base.hh | 5 +- milena/tests/core/image/graph_image.cc | 5 +- milena/tests/core/image/line_graph_image.cc | 5 +- milena/tests/core/other/graph_elt_neighborhood.cc | 6 +- .../core/other/line_graph_elt_neighborhood.cc | 6 +- milena/tests/unit_test/Makefile.am | 4 + .../mln_core_image_graph_elt_neighborhood.cc | 11 +++ .../mln_core_image_line_graph_elt_neighborhood.cc | 11 +++ milena/tools/area_flooding.cc | 5 +- 15 files changed, 230 insertions(+), 41 deletions(-) create mode 100644 milena/mln/core/image/graph_elt_neighborhood.hh create mode 100644 milena/mln/core/image/line_graph_elt_neighborhood.hh create mode 100644 milena/tests/unit_test/mln_core_image_graph_elt_neighborhood.cc create mode 100644 milena/tests/unit_test/mln_core_image_line_graph_elt_neighborhood.cc diff --git a/milena/ChangeLog b/milena/ChangeLog index 7b4a1f2..f0f8199 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,27 @@ +2009-01-05 Guillaume Lazzara <z@lrde.epita.fr> + + Add graph_elt_neighborhood and line_graph_elt_neighborhood aliases. + + * milena/headers.mk: add new headers to distribution. + + * milena/mln/core/image/graph_elt_neighborhood.hh, + * milena/mln/core/image/line_graph_elt_neighborhood.hh: new files. Add + new aliases for graph based neighborhoods. + + * milena/mln/core/image/graph_elt_window.hh, + * milena/mln/core/image/line_graph_elt_window.hh, + * milena/mln/core/internal/neighborhood_base.hh, + * milena/tests/core/image/graph_image.cc, + * milena/tests/core/image/line_graph_image.cc, + * milena/tests/core/other/graph_elt_neighborhood.cc, + * milena/tests/core/other/line_graph_elt_neighborhood.cc, + * milena/tools/area_flooding.cc: make use of these new aliases. + + * milena/tests/unit_test/Makefile.am, + * milena/tests/unit_test/mln_core_image_graph_elt_neighborhood.cc, + * milena/tests/unit_test/mln_core_image_line_graph_elt_neighborhood.cc: + Add new unit tests. + 2009-01-05 Nicolas Ballas <ballas@lrde.epita.fr> Update documentation on properties. diff --git a/milena/headers.mk b/milena/headers.mk index b348a9e..3365173 100644 --- a/milena/headers.mk +++ b/milena/headers.mk @@ -885,6 +885,7 @@ mln/core/image/t_image.hh \ mln/core/image/hexa_piter.hh \ mln/core/image/value_enc_image.hh \ mln/core/image/fun_image.hh \ +mln/core/image/graph_elt_neighborhood.hh \ mln/core/image/sub_image_if.hh \ mln/core/image/all.hh \ mln/core/image/mono_rle_image.hh \ @@ -909,6 +910,7 @@ mln/core/image/image1d.hh \ mln/core/image/extension_val.hh \ mln/core/image/image_if.hh \ mln/core/image/hexa.hh \ +mln/core/image/line_graph_elt_neighborhood.hh \ mln/core/image/extended.hh \ mln/core/image/image2d_h.hh \ mln/core/image/image2d.hh \ diff --git a/milena/mln/core/image/graph_elt_neighborhood.hh b/milena/mln/core/image/graph_elt_neighborhood.hh new file mode 100644 index 0000000..dc08ad9 --- /dev/null +++ b/milena/mln/core/image/graph_elt_neighborhood.hh @@ -0,0 +1,79 @@ +// 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_CORE_IMAGE_GRAPH_ELT_NEIGHBORHOOD_HH +# define MLN_CORE_IMAGE_GRAPH_ELT_NEIGHBORHOOD_HH + +/// \file mln/core/image/graph_elt_neighborhood.hh +/// +/// Definition of the elementary ``neighborhood'' on a graph. + +# include <mln/core/neighb.hh> +# include <mln/core/image/graph_elt_window.hh> + + +namespace mln +{ + + namespace internal + { + + template <typename G, typename F, typename E> + struct neighborhood_impl<graph_elt_window<G,F>,E> + : public neighborhood_extra_impl<graph_elt_window<G,F>,E> + { + }; + + } // end of namespace mln::internal + + + /// Elementary neighborhood on graph class. + template <typename G, typename F> + struct graph_elt_neighborhood + : public neighb< graph_elt_window<G,F> > + { + typedef neighb< graph_elt_window<G,F> > super_; + + graph_elt_neighborhood(); + }; + + +# ifndef MLN_INCLUDE_ONLY + +template <typename G, typename F> +inline +graph_elt_neighborhood<G,F>::graph_elt_neighborhood() +{ +} + +# endif // ! MLN_INCLUDE_ONLY + +} + +#endif // ! MLN_CORE_IMAGE_GRAPH_ELT_NEIGHBORHOOD_HH + diff --git a/milena/mln/core/image/graph_elt_window.hh b/milena/mln/core/image/graph_elt_window.hh index 2e47cb2..e1929df 100644 --- a/milena/mln/core/image/graph_elt_window.hh +++ b/milena/mln/core/image/graph_elt_window.hh @@ -46,18 +46,6 @@ namespace mln /// Forward declaration template <typename G, typename F> class graph_elt_window; - namespace internal - { - - template <typename G, typename F, typename E> - struct neighborhood_impl<graph_elt_window<G,F>,E> - : public neighborhood_extra_impl<graph_elt_window<G,F>,E> - { - }; - - } // end of namespace mln::internal - - namespace trait { @@ -72,7 +60,7 @@ namespace mln } // end of namespace mln::trait - /// \brief Elementary window on graph class. + /// Elementary window on graph class. template <typename G, typename F> class graph_elt_window : public graph_window_base<mln_result(F), graph_elt_window<G,F> > diff --git a/milena/mln/core/image/line_graph_elt_neighborhood.hh b/milena/mln/core/image/line_graph_elt_neighborhood.hh new file mode 100644 index 0000000..92c7611 --- /dev/null +++ b/milena/mln/core/image/line_graph_elt_neighborhood.hh @@ -0,0 +1,79 @@ +// 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_CORE_IMAGE_GRAPH_ELT_NEIGHBORHOOD_HH +# define MLN_CORE_IMAGE_GRAPH_ELT_NEIGHBORHOOD_HH + +/// \file mln/core/image/line_graph_elt_neighborhood.hh +/// +/// Definition of the elementary ``neighborhood'' on a line graph. + +# include <mln/core/neighb.hh> +# include <mln/core/image/line_graph_elt_window.hh> + + +namespace mln +{ + + namespace internal + { + + template <typename G, typename F, typename E> + struct neighborhood_impl<line_graph_elt_window<G,F>,E> + : public neighborhood_extra_impl<line_graph_elt_window<G,F>,E> + { + }; + + } // end of namespace mln::internal + + + /// Elementary neighborhood on line graph class. + template <typename G, typename F> + struct line_graph_elt_neighborhood + : public neighb< line_graph_elt_window<G,F> > + { + typedef neighb< line_graph_elt_window<G,F> > super_; + + line_graph_elt_neighborhood(); + }; + + +# ifndef MLN_INCLUDE_ONLY + +template <typename G, typename F> +inline +line_graph_elt_neighborhood<G,F>::line_graph_elt_neighborhood() +{ +} + +# endif // ! MLN_INCLUDE_ONLY + +} + +#endif // ! MLN_CORE_IMAGE_GRAPH_ELT_NEIGHBORHOOD_HH + diff --git a/milena/mln/core/image/line_graph_elt_window.hh b/milena/mln/core/image/line_graph_elt_window.hh index 9717f48..d9f7138 100644 --- a/milena/mln/core/image/line_graph_elt_window.hh +++ b/milena/mln/core/image/line_graph_elt_window.hh @@ -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 @@ -46,17 +46,6 @@ namespace mln /// Forward declaration template <typename G, typename F> class line_graph_elt_window; - namespace internal - { - - template <typename G, typename F, typename E> - struct neighborhood_impl<line_graph_elt_window<G,F>,E> - : public neighborhood_extra_impl<line_graph_elt_window<G,F>,E> - { - }; - - } // end of namespace mln::internal - namespace trait { diff --git a/milena/mln/core/internal/neighborhood_base.hh b/milena/mln/core/internal/neighborhood_base.hh index 4879fc1..35349fc 100644 --- a/milena/mln/core/internal/neighborhood_base.hh +++ b/milena/mln/core/internal/neighborhood_base.hh @@ -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 @@ -143,7 +144,7 @@ namespace mln // neighborhood_base - + template <typename W, typename E> inline neighborhood_base<W,E>::neighborhood_base() diff --git a/milena/tests/core/image/graph_image.cc b/milena/tests/core/image/graph_image.cc index f12d8f9..e8a71f2 100644 --- a/milena/tests/core/image/graph_image.cc +++ b/milena/tests/core/image/graph_image.cc @@ -33,6 +33,7 @@ #include <mln/core/site_set/p_vertices.hh> #include <mln/core/image/graph_elt_window.hh> +#include <mln/core/image/graph_elt_neighborhood.hh> #include <mln/core/concept/function.hh> #include <mln/core/neighb.hh> #include <mln/core/var.hh> @@ -204,8 +205,8 @@ int main() } } - typedef neighb<win_t> neighb_t; - neighb_t neigh(win); + typedef graph_elt_neighborhood<util::graph, fsite_t> neighb_t; + neighb_t neigh; { // Neighborhood - Forward iteration mln_niter_(neighb_t) n(neigh, p); diff --git a/milena/tests/core/image/line_graph_image.cc b/milena/tests/core/image/line_graph_image.cc index d565a9f..fe660f5 100644 --- a/milena/tests/core/image/line_graph_image.cc +++ b/milena/tests/core/image/line_graph_image.cc @@ -34,6 +34,7 @@ /// Required for line graph images. #include <mln/core/site_set/p_edges.hh> #include <mln/core/image/line_graph_elt_window.hh> +#include <mln/core/image/line_graph_elt_neighborhood.hh> #include <mln/core/neighb.hh> #include <mln/core/var.hh> #include <mln/pw/all.hh> @@ -163,8 +164,8 @@ int main() } - typedef neighb<win_t> neighb_t; - neighb_t neigh(win); + typedef line_graph_elt_neighborhood<util::graph, fsite_t> neighb_t; + neighb_t neigh; { // Neighborhood - Forward iteration diff --git a/milena/tests/core/other/graph_elt_neighborhood.cc b/milena/tests/core/other/graph_elt_neighborhood.cc index 797b826..aafe485 100644 --- a/milena/tests/core/other/graph_elt_neighborhood.cc +++ b/milena/tests/core/other/graph_elt_neighborhood.cc @@ -33,12 +33,12 @@ #include <vector> -#include <mln/core/neighb.hh> #include <mln/core/alias/point2d.hh> -#include <mln/core/image/graph_elt_window.hh> #include <mln/core/site_set/p_vertices.hh> #include <mln/util/graph.hh> +#include <mln/core/image/graph_elt_neighborhood.hh> + unsigned fwd_neighb[] = { 0, 2, 3 }; unsigned bkd_neighb[] = { 3, 2, 0 }; @@ -101,7 +101,7 @@ int main() mln_psite_(pv_t) p(pg, 1); // ``Sliding'' neighborhood of a psite of PG. - typedef neighb< graph_elt_window<G, F> > nbh_t; + typedef graph_elt_neighborhood<G, F> nbh_t; nbh_t nbh; unsigned i = 0; diff --git a/milena/tests/core/other/line_graph_elt_neighborhood.cc b/milena/tests/core/other/line_graph_elt_neighborhood.cc index 197091e..cbc7d75 100644 --- a/milena/tests/core/other/line_graph_elt_neighborhood.cc +++ b/milena/tests/core/other/line_graph_elt_neighborhood.cc @@ -32,11 +32,11 @@ #include <vector> #include <mln/core/alias/point2d.hh> -#include <mln/core/neighb.hh> #include <mln/core/site_set/p_edges.hh> -#include <mln/core/image/line_graph_elt_window.hh> #include <mln/util/graph.hh> +#include <mln/core/image/line_graph_elt_neighborhood.hh> + unsigned fwd_neighb[] = { 0, 2, 4 }; unsigned bkd_neighb[] = { 4, 2, 0 }; @@ -100,7 +100,7 @@ int main() mln_psite_(pe_t) p(pe, 1); // ``Sliding'' neighborhood of a psite of PLG. - typedef neighb< line_graph_elt_window<G, F> > nbh_t; + typedef line_graph_elt_neighborhood<G, F> nbh_t; nbh_t nbh; unsigned i = 0; diff --git a/milena/tests/unit_test/Makefile.am b/milena/tests/unit_test/Makefile.am index 91e56f5..168c709 100644 --- a/milena/tests/unit_test/Makefile.am +++ b/milena/tests/unit_test/Makefile.am @@ -856,6 +856,7 @@ mln_core_image_t_image \ mln_core_image_hexa_piter \ mln_core_image_value_enc_image \ mln_core_image_fun_image \ +mln_core_image_graph_elt_neighborhood \ mln_core_image_sub_image_if \ mln_core_image_all \ mln_core_image_mono_rle_image \ @@ -880,6 +881,7 @@ mln_core_image_image1d \ mln_core_image_extension_val \ mln_core_image_image_if \ mln_core_image_hexa \ +mln_core_image_line_graph_elt_neighborhood \ mln_core_image_extended \ mln_core_image_image2d_h \ mln_core_image_image2d \ @@ -1862,6 +1864,7 @@ mln_core_image_t_image_SOURCES = mln_core_image_t_image.cc mln_core_image_hexa_piter_SOURCES = mln_core_image_hexa_piter.cc mln_core_image_value_enc_image_SOURCES = mln_core_image_value_enc_image.cc mln_core_image_fun_image_SOURCES = mln_core_image_fun_image.cc +mln_core_image_graph_elt_neighborhood_SOURCES = mln_core_image_graph_elt_neighborhood.cc mln_core_image_sub_image_if_SOURCES = mln_core_image_sub_image_if.cc mln_core_image_all_SOURCES = mln_core_image_all.cc mln_core_image_mono_rle_image_SOURCES = mln_core_image_mono_rle_image.cc @@ -1886,6 +1889,7 @@ mln_core_image_image1d_SOURCES = mln_core_image_image1d.cc mln_core_image_extension_val_SOURCES = mln_core_image_extension_val.cc mln_core_image_image_if_SOURCES = mln_core_image_image_if.cc mln_core_image_hexa_SOURCES = mln_core_image_hexa.cc +mln_core_image_line_graph_elt_neighborhood_SOURCES = mln_core_image_line_graph_elt_neighborhood.cc mln_core_image_extended_SOURCES = mln_core_image_extended.cc mln_core_image_image2d_h_SOURCES = mln_core_image_image2d_h.cc mln_core_image_image2d_SOURCES = mln_core_image_image2d.cc diff --git a/milena/tests/unit_test/mln_core_image_graph_elt_neighborhood.cc b/milena/tests/unit_test/mln_core_image_graph_elt_neighborhood.cc new file mode 100644 index 0000000..b5c220b --- /dev/null +++ b/milena/tests/unit_test/mln_core_image_graph_elt_neighborhood.cc @@ -0,0 +1,11 @@ +// Unit test for mln/core/image/graph_elt_neighborhood.hh. +// Generated by ./build_unit_test.sh, do not modify. + +// Include the file twice, so we detect missing inclusion guards. +#include <mln/core/image/graph_elt_neighborhood.hh> +#include <mln/core/image/graph_elt_neighborhood.hh> + +int main() +{ + // Nothing. +} diff --git a/milena/tests/unit_test/mln_core_image_line_graph_elt_neighborhood.cc b/milena/tests/unit_test/mln_core_image_line_graph_elt_neighborhood.cc new file mode 100644 index 0000000..9e4a7de --- /dev/null +++ b/milena/tests/unit_test/mln_core_image_line_graph_elt_neighborhood.cc @@ -0,0 +1,11 @@ +// Unit test for mln/core/image/line_graph_elt_neighborhood.hh. +// Generated by ./build_unit_test.sh, do not modify. + +// Include the file twice, so we detect missing inclusion guards. +#include <mln/core/image/line_graph_elt_neighborhood.hh> +#include <mln/core/image/line_graph_elt_neighborhood.hh> + +int main() +{ + // Nothing. +} diff --git a/milena/tools/area_flooding.cc b/milena/tools/area_flooding.cc index da7c378..fc5c444 100644 --- a/milena/tools/area_flooding.cc +++ b/milena/tools/area_flooding.cc @@ -57,8 +57,7 @@ #include <mln/core/routine/duplicate.hh> #include <mln/core/image/image2d.hh> -#include <mln/core/alias/neighb2d.hh> -#include <mln/core/image/line_graph_elt_window.hh> +#include <mln/core/image/line_graph_elt_neighborhood.hh> #include <mln/core/var.hh> #include <mln/morpho/line_gradient.hh> @@ -114,7 +113,7 @@ int main(int argc, char* argv[]) /* FIXME: I'm not sure this is the way it should be done. Anyway, we should implement this as a canvas. */ - typedef neighb< line_graph_elt_window<util::graph, lg_ima_t::pset::fun_t> > nbh_t; + typedef line_graph_elt_neighborhood<util::graph, lg_ima_t::pset::fun_t> nbh_t; nbh_t nbh; unsigned area = 0; -- 1.5.6.5