URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-09 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Add composed transformation. (Does not work !).
* mln/fun/x2x/bijective_tr.hh: Bijective transformation.
* mln/fun/x2x/composed.hh: Composed tranformation.
* mln/fun/x2x/rotation.hh: Update.
* mln/fun/x2x/translation.hh: Update.
---
bijective_tr.hh | 68 +++++++++++++++++++++++
composed.hh | 161 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
rotation.hh | 4 -
translation.hh | 4 -
4 files changed, 233 insertions(+), 4 deletions(-)
Index: trunk/milena/mln/fun/x2x/composed.hh
===================================================================
--- trunk/milena/mln/fun/x2x/composed.hh (revision 0)
+++ trunk/milena/mln/fun/x2x/composed.hh (revision 1284)
@@ -0,0 +1,161 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_X2X_COMPOSED_HH
+# define MLN_FUN_X2X_COMPOSED_HH
+
+/*! \file mln/fun/x2x/composed.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/metal/vec.hh>
+# include <mln/metal/mat.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace x2x
+ {
+
+ // Fwd decl.
+ template <typename L, typename M>
+ struct composed;
+
+ namespace internal
+ {
+
+ template <unsigned n, typename L, unsigned m, typename M, typename E>
+ struct helper_;
+
+ template <unsigned n, typename L, typename M, typename E>
+ struct helper_<n, Function_x2x<L>, n, Function_x2x<M> > : Function_x2x<E>
+ {
+ enum {dim = n};
+ };
+
+ template <unsigned n, typename L, typename M, typename E>
+ struct helper_<n, bijective_tr<L>, n, bijective_tr<M> > : bijective_tr<E>
+ {
+ enum {dim = n};
+ typedef composed<M::invert,L::invert> invert;
+
+ invert inv() const;
+ };
+ }
+
+ // FIXME: Doc!
+
+ template <typename L, typename M>
+ struct composed : public internal::helper_< L::dim, L, M::dim, M, composed<L,M> >
+ {
+
+ typedef internal::helper_< L::dim, L, M::dim, M, composed<L,M> > Super
+
+ enum {dim = Super::dim};
+
+ typedef metal::vec<n,C> result;
+
+ composed();
+ composed(const L& tr_l, const M& tr_m);
+
+ result operator()(const metal::vec<n,C>& v) const;
+
+ void set_first(const L& tr_l);
+ void set_second(const M& tr_m);
+
+ protected:
+
+ L tr1_;
+ M tr2_;
+ metal::mat<n + 1,n + 1,C> m_;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename L, typename M>
+ composed<L,M>::composed()
+ {
+ t_ = make::vec<n,C>(0);
+ m_ = metal::mat<n+1,n+1,C>::Id;
+ }
+
+ template <typename L, typename M>
+ composed<L,M>::composed(const L& tr_l, const M& tr_m)
+ :tr1_(tr_l),
+ tr2_(tr_m)
+ {
+ m_ = metal::mat<n+1,n+1,C>::Id;
+ m_ = tr1_ * tr2_;
+ }
+
+ template <typename L, typename M>
+ composed<L,M>::result
+ composed<L,M>::operator()(const metal::vec<n,C>& v) const
+ {
+ return m_(v);
+ }
+
+ template <typename L, typename M>
+ composed<L,M>::invert
+ composed<L,M>::inv() const
+ {
+ typename composed::invert res(tr2_.inv(), tr1_.inv());
+
+ return res;
+ }
+
+ template <typename L, typename M>
+ void
+ composed<L,M>::set_first(const L& tr_l)
+ {
+ tr1_ = tr_l;
+ }
+
+ template <typename L, typename M>
+ void
+ composed<L,M>::set_second(const M& tr_m)
+ {
+ tr2_ = tr_m;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::x2x
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_X2X_COMPOSED_HH
Index: trunk/milena/mln/fun/x2x/bijective_tr.hh
===================================================================
--- trunk/milena/mln/fun/x2x/bijective_tr.hh (revision 0)
+++ trunk/milena/mln/fun/x2x/bijective_tr.hh (revision 1284)
@@ -0,0 +1,68 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_X2X_BIJECTIVE_TR_HH
+# define MLN_FUN_X2X_BIJECTIVE_TR_HH
+
+/*! \file mln/fun/x2x/bijective_tr.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/metal/vec.hh>
+# include <mln/metal/mat.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace x2x
+ {
+
+ // FIXME: Doc!
+
+ template <typename E>
+ struct bijective_tr : public Function_x2x< E >
+ {
+ typedef E::result result;
+ typedef E::invert invert;
+
+ invert inv() const;
+ };
+
+ } // end of namespace mln::fun::x2x
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_X2X_BIJECTIVE_TR_HH
Index: trunk/milena/mln/fun/x2x/translation.hh
===================================================================
--- trunk/milena/mln/fun/x2x/translation.hh (revision 1283)
+++ trunk/milena/mln/fun/x2x/translation.hh (revision 1284)
@@ -33,7 +33,7 @@
* \brief FIXME.
*/
-# include <mln/core/concept/function.hh>
+# include <mln/fun/x2x/bijective_tr.hh>
# include <mln/metal/vec.hh>
# include <mln/metal/mat.hh>
@@ -50,7 +50,7 @@
// FIXME: Doc!
template <unsigned n, typename C>
- struct translation : public Function_x2x< translation<n,C> >
+ struct translation : public bijective_tr< translation<n,C> >
{
enum {dim = n};
Index: trunk/milena/mln/fun/x2x/rotation.hh
===================================================================
--- trunk/milena/mln/fun/x2x/rotation.hh (revision 1283)
+++ trunk/milena/mln/fun/x2x/rotation.hh (revision 1284)
@@ -33,7 +33,7 @@
* \brief FIXME.
*/
-# include <mln/core/concept/function.hh>
+# include <mln/fun/x2x/bijective_tr.hh>
# include <mln/metal/vec.hh>
# include <mln/metal/mat.hh>
# include <cmath>
@@ -51,7 +51,7 @@
// FIXME: Doc!
template <unsigned n, typename C>
- struct rotation : public Function_x2x< rotation<n,C> >
+ struct rotation : public bijective_tr< rotation<n,C> >
{
enum {dim = n};
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-09 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Refactoring : move mln/core/win to mln/win.
* mln/core/win/backdiag2d.hh,
* mln/core/win/cube3d.hh,
* mln/core/win/diag2d.hh,
* mln/core/win/disk2d.hh,
* mln/core/win/hline2d.hh,
* mln/core/win/line.hh,
* mln/core/win/octagon2d.hh,
* mln/core/win/rectangle2d.hh,
* mln/core/win/segment1d.hh,
* mln/core/win/vline2d.hh,
* mln/core/win: Rename as ...
* mln/win/backdiag2d.hh,
* mln/win/cube3d.hh,
* mln/win/diag2d.hh,
* mln/win/disk2d.hh,
* mln/win/hline2d.hh,
* mln/win/line.hh,
* mln/win/octagon2d.hh,
* mln/win/rectangle2d.hh,
* mln/win/segment1d.hh,
* mln/win/vline2d.hh,
* mln/win: ...this.
* mln/level/approx/median.hh,
* sandbox/nivault/dyn_line.hh,
* sandbox/nivault/median.hh,
* sandbox/nivault/tests/pouet.cc,
* tests/convert_to_vec_p.cc,
* tests/dpoints_pixter.cc,
* tests/io_pgm16.cc,
* tests/io_ppm16.cc,
* tests/io_ppm23.cc,
* tests/level_approx_median.cc,
* tests/level_median.cc,
* tests/level_median_fast.cc,
* tests/level_median_hline2d.cc,
* tests/level_naive_median.cc,
* tests/local_convolve.cc,
* tests/main.cc,
* tests/morpho_contrast.cc,
* tests/morpho_dilation.cc,
* tests/morpho_dilation_max_h.cc,
* tests/morpho_erosion.cc,
* tests/morpho_erosion_min_h.cc,
* tests/morpho_gradient.cc,
* tests/morpho_hit_or_miss.cc,
* tests/morpho_laplacian.cc,
* tests/morpho_thinning.cc,
* tests/value_float01.cc,
* tests/w_window1d_int.cc,
* tests/w_window2d_int.cc,
* tests/w_window3d_int.cc,
* tests/win_backdiag2d.cc,
* tests/win_diag2d.cc,
* tests/win_disk2d.cc,
* tests/win_hline2d.cc,
* tests/win_octagon2d.cc,
* tests/win_rectangle2d.cc: Update according to the refactoring.
---
mln/level/approx/median.hh | 14 +-
mln/win/backdiag2d.hh | 185 +++++++++++++++++++++++++++++++++++
mln/win/cube3d.hh | 193 ++++++++++++++++++++++++++++++++++++
mln/win/diag2d.hh | 185 +++++++++++++++++++++++++++++++++++
mln/win/disk2d.hh | 179 ++++++++++++++++++++++++++++++++++
mln/win/hline2d.hh | 63 ++++++++++++
mln/win/line.hh | 183 ++++++++++++++++++++++++++++++++++
mln/win/octagon2d.hh | 215 +++++++++++++++++++++++++++++++++++++++++
mln/win/rectangle2d.hh | 198 +++++++++++++++++++++++++++++++++++++
mln/win/segment1d.hh | 181 ++++++++++++++++++++++++++++++++++
mln/win/vline2d.hh | 65 ++++++++++++
sandbox/nivault/dyn_line.hh | 2
sandbox/nivault/median.hh | 4
sandbox/nivault/tests/pouet.cc | 4
tests/convert_to_vec_p.cc | 4
tests/dpoints_pixter.cc | 2
tests/io_pgm16.cc | 2
tests/io_ppm16.cc | 2
tests/io_ppm23.cc | 2
tests/level_approx_median.cc | 4
tests/level_median.cc | 2
tests/level_median_fast.cc | 2
tests/level_median_hline2d.cc | 2
tests/level_naive_median.cc | 2
tests/local_convolve.cc | 2
tests/main.cc | 2
tests/morpho_contrast.cc | 2
tests/morpho_dilation.cc | 8 -
tests/morpho_dilation_max_h.cc | 2
tests/morpho_erosion.cc | 8 -
tests/morpho_erosion_min_h.cc | 2
tests/morpho_gradient.cc | 2
tests/morpho_hit_or_miss.cc | 2
tests/morpho_laplacian.cc | 2
tests/morpho_thinning.cc | 2
tests/value_float01.cc | 2
tests/w_window1d_int.cc | 2
tests/w_window2d_int.cc | 2
tests/w_window3d_int.cc | 2
tests/win_backdiag2d.cc | 2
tests/win_diag2d.cc | 2
tests/win_disk2d.cc | 2
tests/win_hline2d.cc | 2
tests/win_octagon2d.cc | 2
tests/win_rectangle2d.cc | 2
45 files changed, 1698 insertions(+), 51 deletions(-)
Index: trunk/milena/tests/win_hline2d.cc
===================================================================
--- trunk/milena/tests/win_hline2d.cc (revision 1282)
+++ trunk/milena/tests/win_hline2d.cc (revision 1283)
@@ -30,7 +30,7 @@
* \brief Tests on mln::win::diag2d.
*/
-#include <mln/core/win/hline2d.hh>
+#include <mln/win/hline2d.hh>
#include <mln/convert/to_image.hh>
Index: trunk/milena/tests/morpho_dilation_max_h.cc
===================================================================
--- trunk/milena/tests/morpho_dilation_max_h.cc (revision 1282)
+++ trunk/milena/tests/morpho_dilation_max_h.cc (revision 1283)
@@ -31,7 +31,7 @@
*/
#include <mln/core/image2d.hh>
-#include <mln/core/win/rectangle2d.hh>
+#include <mln/win/rectangle2d.hh>
#include <mln/core/window2d.hh>
#include <mln/io/pgm/load.hh>
Index: trunk/milena/tests/level_naive_median.cc
===================================================================
--- trunk/milena/tests/level_naive_median.cc (revision 1282)
+++ trunk/milena/tests/level_naive_median.cc (revision 1283)
@@ -31,7 +31,7 @@
*/
#include <mln/core/image2d.hh>
-#include <mln/core/win/rectangle2d.hh>
+#include <mln/win/rectangle2d.hh>
#include <mln/io/pgm/load.hh>
#include <mln/io/pgm/save.hh>
Index: trunk/milena/tests/io_ppm23.cc
===================================================================
--- trunk/milena/tests/io_ppm23.cc (revision 1282)
+++ trunk/milena/tests/io_ppm23.cc (revision 1283)
@@ -31,7 +31,7 @@
*/
#include <mln/core/image2d.hh>
-#include <mln/core/win/rectangle2d.hh>
+#include <mln/win/rectangle2d.hh>
#include <mln/value/rgb8.hh>
Index: trunk/milena/tests/level_median_hline2d.cc
===================================================================
--- trunk/milena/tests/level_median_hline2d.cc (revision 1282)
+++ trunk/milena/tests/level_median_hline2d.cc (revision 1283)
@@ -31,7 +31,7 @@
*/
#include <mln/core/image2d.hh>
-#include <mln/core/win/rectangle2d.hh>
+#include <mln/win/rectangle2d.hh>
#include <mln/io/pgm/load.hh>
#include <mln/io/pgm/save.hh>
Index: trunk/milena/tests/morpho_erosion.cc
===================================================================
--- trunk/milena/tests/morpho_erosion.cc (revision 1282)
+++ trunk/milena/tests/morpho_erosion.cc (revision 1283)
@@ -31,10 +31,10 @@
*/
#include <mln/core/image2d.hh>
-#include <mln/core/win/rectangle2d.hh>
-#include <mln/core/win/octagon2d.hh>
-#include <mln/core/win/diag2d.hh>
-#include <mln/core/win/backdiag2d.hh>
+#include <mln/win/rectangle2d.hh>
+#include <mln/win/octagon2d.hh>
+#include <mln/win/diag2d.hh>
+#include <mln/win/backdiag2d.hh>
#include <mln/core/window2d.hh>
#include <mln/io/pgm/load.hh>
Index: trunk/milena/tests/morpho_hit_or_miss.cc
===================================================================
--- trunk/milena/tests/morpho_hit_or_miss.cc (revision 1282)
+++ trunk/milena/tests/morpho_hit_or_miss.cc (revision 1283)
@@ -33,7 +33,7 @@
#include <mln/core/image2d.hh>
#include <mln/value/int_u8.hh>
-#include <mln/core/win/rectangle2d.hh>
+#include <mln/win/rectangle2d.hh>
#include <mln/core/window2d.hh>
#include <mln/geom/shift.hh>
#include <mln/set/diff.hh>
Index: trunk/milena/tests/morpho_erosion_min_h.cc
===================================================================
--- trunk/milena/tests/morpho_erosion_min_h.cc (revision 1282)
+++ trunk/milena/tests/morpho_erosion_min_h.cc (revision 1283)
@@ -31,7 +31,7 @@
*/
#include <mln/core/image2d.hh>
-#include <mln/core/win/rectangle2d.hh>
+#include <mln/win/rectangle2d.hh>
#include <mln/core/window2d.hh>
#include <mln/io/pgm/load.hh>
Index: trunk/milena/tests/convert_to_vec_p.cc
===================================================================
--- trunk/milena/tests/convert_to_vec_p.cc (revision 1282)
+++ trunk/milena/tests/convert_to_vec_p.cc (revision 1283)
@@ -34,8 +34,8 @@
#include <mln/core/point2d.hh>
#include <mln/core/vec_p.hh>
-#include <mln/core/win/segment1d.hh>
-#include <mln/core/win/rectangle2d.hh>
+#include <mln/win/segment1d.hh>
+#include <mln/win/rectangle2d.hh>
#include <mln/convert/to_vec_p.hh>
Index: trunk/milena/tests/level_median.cc
===================================================================
--- trunk/milena/tests/level_median.cc (revision 1282)
+++ trunk/milena/tests/level_median.cc (revision 1283)
@@ -31,7 +31,7 @@
*/
#include <mln/core/image2d.hh>
-#include <mln/core/win/rectangle2d.hh>
+#include <mln/win/rectangle2d.hh>
#include <mln/io/pgm/load.hh>
#include <mln/io/pgm/save.hh>
Index: trunk/milena/tests/win_diag2d.cc
===================================================================
--- trunk/milena/tests/win_diag2d.cc (revision 1282)
+++ trunk/milena/tests/win_diag2d.cc (revision 1283)
@@ -30,7 +30,7 @@
* \brief Tests on mln::win::diag2d.
*/
-#include <mln/core/win/diag2d.hh>
+#include <mln/win/diag2d.hh>
#include <mln/convert/to_image.hh>
Index: trunk/milena/tests/dpoints_pixter.cc
===================================================================
--- trunk/milena/tests/dpoints_pixter.cc (revision 1282)
+++ trunk/milena/tests/dpoints_pixter.cc (revision 1283)
@@ -31,7 +31,7 @@
*/
#include <mln/core/image2d.hh>
-#include <mln/core/win/rectangle2d.hh>
+#include <mln/win/rectangle2d.hh>
#include <mln/make/pixel.hh>
Index: trunk/milena/tests/morpho_gradient.cc
===================================================================
--- trunk/milena/tests/morpho_gradient.cc (revision 1282)
+++ trunk/milena/tests/morpho_gradient.cc (revision 1283)
@@ -31,7 +31,7 @@
*/
#include <mln/core/image2d.hh>
-#include <mln/core/win/rectangle2d.hh>
+#include <mln/win/rectangle2d.hh>
#include <mln/io/pgm/load.hh>
#include <mln/io/pgm/save.hh>
Index: trunk/milena/tests/w_window1d_int.cc
===================================================================
--- trunk/milena/tests/w_window1d_int.cc (revision 1282)
+++ trunk/milena/tests/w_window1d_int.cc (revision 1283)
@@ -31,7 +31,7 @@
*/
#include <mln/core/w_window1d_int.hh>
-#include <mln/core/win/segment1d.hh>
+#include <mln/win/segment1d.hh>
#include <mln/convert/to_image.hh>
#include <mln/convert/to_w_window.hh>
Index: trunk/milena/tests/w_window2d_int.cc
===================================================================
--- trunk/milena/tests/w_window2d_int.cc (revision 1282)
+++ trunk/milena/tests/w_window2d_int.cc (revision 1283)
@@ -31,7 +31,7 @@
*/
#include <mln/core/w_window2d_int.hh>
-#include <mln/core/win/rectangle2d.hh>
+#include <mln/win/rectangle2d.hh>
#include <mln/convert/to_image.hh>
#include <mln/convert/to_w_window.hh>
Index: trunk/milena/tests/win_disk2d.cc
===================================================================
--- trunk/milena/tests/win_disk2d.cc (revision 1282)
+++ trunk/milena/tests/win_disk2d.cc (revision 1283)
@@ -30,7 +30,7 @@
* \brief Tests on mln::win::diag2d.
*/
-#include <mln/core/win/disk2d.hh>
+#include <mln/win/disk2d.hh>
#include <mln/convert/to_image.hh>
Index: trunk/milena/tests/w_window3d_int.cc
===================================================================
--- trunk/milena/tests/w_window3d_int.cc (revision 1282)
+++ trunk/milena/tests/w_window3d_int.cc (revision 1283)
@@ -31,7 +31,7 @@
*/
#include <mln/core/w_window3d_int.hh>
-#include <mln/core/win/cube3d.hh>
+#include <mln/win/cube3d.hh>
#include <mln/convert/to_image.hh>
#include <mln/convert/to_w_window.hh>
Index: trunk/milena/tests/main.cc
===================================================================
--- trunk/milena/tests/main.cc (revision 1282)
+++ trunk/milena/tests/main.cc (revision 1283)
@@ -32,7 +32,7 @@
#include <mln/debug/println.hh>
#include <mln/core/window2d.hh>
-#include <mln/core/win/rectangle2d.hh>
+#include <mln/win/rectangle2d.hh>
#include <mln/core/neighb2d.hh>
Index: trunk/milena/tests/win_octagon2d.cc
===================================================================
--- trunk/milena/tests/win_octagon2d.cc (revision 1282)
+++ trunk/milena/tests/win_octagon2d.cc (revision 1283)
@@ -30,7 +30,7 @@
* \brief Tests on mln::win::octagon2d.
*/
-#include <mln/core/win/octagon2d.hh>
+#include <mln/win/octagon2d.hh>
#include <mln/convert/to_image.hh>
Index: trunk/milena/tests/morpho_thinning.cc
===================================================================
--- trunk/milena/tests/morpho_thinning.cc (revision 1282)
+++ trunk/milena/tests/morpho_thinning.cc (revision 1283)
@@ -33,7 +33,7 @@
#include <mln/core/image2d.hh>
#include <mln/value/int_u8.hh>
-#include <mln/core/win/rectangle2d.hh>
+#include <mln/win/rectangle2d.hh>
#include <mln/core/window2d.hh>
#include <mln/io/pgm/load.hh>
Index: trunk/milena/tests/morpho_laplacian.cc
===================================================================
--- trunk/milena/tests/morpho_laplacian.cc (revision 1282)
+++ trunk/milena/tests/morpho_laplacian.cc (revision 1283)
@@ -31,7 +31,7 @@
*/
#include <mln/core/image2d.hh>
-#include <mln/core/win/rectangle2d.hh>
+#include <mln/win/rectangle2d.hh>
#include <mln/io/pgm/load.hh>
#include <mln/io/pgm/save.hh>
Index: trunk/milena/tests/io_ppm16.cc
===================================================================
--- trunk/milena/tests/io_ppm16.cc (revision 1282)
+++ trunk/milena/tests/io_ppm16.cc (revision 1283)
@@ -31,7 +31,7 @@
*/
#include <mln/core/image2d.hh>
-#include <mln/core/win/rectangle2d.hh>
+#include <mln/win/rectangle2d.hh>
#include <mln/value/rgb8.hh>
#include <mln/value/rgb16.hh>
Index: trunk/milena/tests/level_median_fast.cc
===================================================================
--- trunk/milena/tests/level_median_fast.cc (revision 1282)
+++ trunk/milena/tests/level_median_fast.cc (revision 1283)
@@ -31,7 +31,7 @@
*/
#include <mln/core/image2d.hh>
-#include <mln/core/win/rectangle2d.hh>
+#include <mln/win/rectangle2d.hh>
#include <mln/io/pgm/load.hh>
#include <mln/io/pgm/save.hh>
Index: trunk/milena/tests/local_convolve.cc
===================================================================
--- trunk/milena/tests/local_convolve.cc (revision 1282)
+++ trunk/milena/tests/local_convolve.cc (revision 1283)
@@ -34,7 +34,7 @@
#include <mln/value/int_u8.hh>
#include <mln/core/w_window2d_int.hh>
-#include <mln/core/win/rectangle2d.hh>
+#include <mln/win/rectangle2d.hh>
#include <mln/core/pixel.hh>
#include <mln/debug/iota.hh>
Index: trunk/milena/tests/level_approx_median.cc
===================================================================
--- trunk/milena/tests/level_approx_median.cc (revision 1282)
+++ trunk/milena/tests/level_approx_median.cc (revision 1283)
@@ -31,8 +31,8 @@
*/
#include <mln/core/image2d.hh>
-#include <mln/core/win/rectangle2d.hh>
-#include <mln/core/win/octagon2d.hh>
+#include <mln/win/rectangle2d.hh>
+#include <mln/win/octagon2d.hh>
#include <mln/io/pgm/load.hh>
#include <mln/io/pgm/save.hh>
Index: trunk/milena/tests/value_float01.cc
===================================================================
--- trunk/milena/tests/value_float01.cc (revision 1282)
+++ trunk/milena/tests/value_float01.cc (revision 1283)
@@ -39,7 +39,7 @@
#include <mln/io/pgm/load.hh>
#include <mln/io/pgm/save.hh>
-#include <mln/core/win/rectangle2d.hh>
+#include <mln/win/rectangle2d.hh>
#include <mln/level/median.hh>
#include <mln/level/compare.hh>
Index: trunk/milena/tests/win_rectangle2d.cc
===================================================================
--- trunk/milena/tests/win_rectangle2d.cc (revision 1282)
+++ trunk/milena/tests/win_rectangle2d.cc (revision 1283)
@@ -30,7 +30,7 @@
* \brief Tests on mln::win::rectangle2d.
*/
-#include <mln/core/win/rectangle2d.hh>
+#include <mln/win/rectangle2d.hh>
#include <mln/geom/sym.hh>
Index: trunk/milena/tests/morpho_contrast.cc
===================================================================
--- trunk/milena/tests/morpho_contrast.cc (revision 1282)
+++ trunk/milena/tests/morpho_contrast.cc (revision 1283)
@@ -31,7 +31,7 @@
*/
#include <mln/core/image2d.hh>
-#include <mln/core/win/rectangle2d.hh>
+#include <mln/win/rectangle2d.hh>
#include <mln/io/pgm/load.hh>
#include <mln/io/pgm/save.hh>
Index: trunk/milena/tests/io_pgm16.cc
===================================================================
--- trunk/milena/tests/io_pgm16.cc (revision 1282)
+++ trunk/milena/tests/io_pgm16.cc (revision 1283)
@@ -31,7 +31,7 @@
*/
#include <mln/core/image2d.hh>
-#include <mln/core/win/rectangle2d.hh>
+#include <mln/win/rectangle2d.hh>
#include <mln/value/int_u8.hh>
#include <mln/value/int_u16.hh>
Index: trunk/milena/tests/morpho_dilation.cc
===================================================================
--- trunk/milena/tests/morpho_dilation.cc (revision 1282)
+++ trunk/milena/tests/morpho_dilation.cc (revision 1283)
@@ -31,10 +31,10 @@
*/
#include <mln/core/image2d.hh>
-#include <mln/core/win/rectangle2d.hh>
-#include <mln/core/win/octagon2d.hh>
-#include <mln/core/win/diag2d.hh>
-#include <mln/core/win/backdiag2d.hh>
+#include <mln/win/rectangle2d.hh>
+#include <mln/win/octagon2d.hh>
+#include <mln/win/diag2d.hh>
+#include <mln/win/backdiag2d.hh>
#include <mln/core/window2d.hh>
#include <mln/io/pgm/load.hh>
Index: trunk/milena/tests/win_backdiag2d.cc
===================================================================
--- trunk/milena/tests/win_backdiag2d.cc (revision 1282)
+++ trunk/milena/tests/win_backdiag2d.cc (revision 1283)
@@ -30,7 +30,7 @@
* \brief Tests on mln::win::backdiag2d.
*/
-#include <mln/core/win/backdiag2d.hh>
+#include <mln/win/backdiag2d.hh>
#include <mln/convert/to_image.hh>
Index: trunk/milena/mln/level/approx/median.hh
===================================================================
--- trunk/milena/mln/level/approx/median.hh (revision 1282)
+++ trunk/milena/mln/level/approx/median.hh (revision 1283)
@@ -34,13 +34,13 @@
*/
# include <mln/level/median.hh>
-# include <mln/core/win/rectangle2d.hh>
-# include <mln/core/win/disk2d.hh>
-# include <mln/core/win/octagon2d.hh>
-# include <mln/core/win/hline2d.hh>
-# include <mln/core/win/vline2d.hh>
-# include <mln/core/win/diag2d.hh>
-# include <mln/core/win/backdiag2d.hh>
+# include <mln/win/rectangle2d.hh>
+# include <mln/win/disk2d.hh>
+# include <mln/win/octagon2d.hh>
+# include <mln/win/hline2d.hh>
+# include <mln/win/vline2d.hh>
+# include <mln/win/diag2d.hh>
+# include <mln/win/backdiag2d.hh>
#include <time.h>
Index: trunk/milena/mln/win/vline2d.hh
===================================================================
--- trunk/milena/mln/win/vline2d.hh (revision 0)
+++ trunk/milena/mln/win/vline2d.hh (revision 1283)
@@ -0,0 +1,65 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_WIN_VLINE2D_HH
+# define MLN_CORE_WIN_VLINE2D_HH
+
+/*! \file mln/win/vline2d.hh
+ *
+ * \brief Definition of the mln::win::vline2d window.
+ */
+
+# include <mln/win/line.hh>
+# include <mln/core/grids.hh>
+
+
+namespace mln
+{
+
+ namespace win
+ {
+
+ /*! \brief Vertical line window defined on the 2D square grid.
+ *
+ * An vline2d is centered and symmetrical; so its width is 1 and
+ * its height (length) is odd.
+ *
+ * For instance: \n
+ * o \n
+ * x \n
+ * o \n
+ * is defined with length = 3.
+ */
+ typedef line<grid::square, 0, int> vline2d;
+
+ } // end of namespace mln::win
+
+} // end of namespace mln
+
+
+
+#endif // ! MLN_CORE_WIN_VLINE2D_HH
Index: trunk/milena/mln/win/hline2d.hh
===================================================================
--- trunk/milena/mln/win/hline2d.hh (revision 0)
+++ trunk/milena/mln/win/hline2d.hh (revision 1283)
@@ -0,0 +1,63 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_WIN_HLINE2D_HH
+# define MLN_CORE_WIN_HLINE2D_HH
+
+/*! \file mln/win/hline2d.hh
+ *
+ * \brief Definition of the mln::win::hline2d window.
+ */
+
+# include <mln/win/line.hh>
+# include <mln/core/grids.hh>
+
+
+namespace mln
+{
+
+ namespace win
+ {
+
+ /*! \brief Horizontal line window defined on the 2D square grid.
+ *
+ * An hline2d is centered and symmetrical; so its height is 1 and
+ * its width (length) is odd.
+ *
+ * For instance: \n
+ * o o x o o \n
+ * is defined with length = 5.
+ */
+ typedef line<grid::square, 1, int> hline2d;
+
+ } // end of namespace mln::win
+
+} // end of namespace mln
+
+
+
+#endif // ! MLN_CORE_WIN_HLINE2D_HH
Index: trunk/milena/mln/win/cube3d.hh
===================================================================
--- trunk/milena/mln/win/cube3d.hh (revision 0)
+++ trunk/milena/mln/win/cube3d.hh (revision 1283)
@@ -0,0 +1,193 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_WIN_CUBE3D_HH
+# define MLN_CORE_WIN_CUBE3D_HH
+
+/*! \file mln/win/cube3d.hh
+ *
+ * \brief Definition of the mln::win::cube3d window.
+ */
+
+# include <mln/core/concept/window.hh>
+# include <mln/core/internal/dpoints_base.hh>
+# include <mln/core/dpoint3d.hh>
+# include <mln/core/dpoints_piter.hh>
+
+
+namespace mln
+{
+
+ namespace win
+ {
+
+ /*! \brief Cube window defined on the 3D grid.
+ *
+ * An cube3d is centered and symmetrical; so
+ * its height (length) is odd.
+ *
+ * For instance: \n
+ * o o o \n
+ * o o o \n
+ * o o o \n
+
+ * o o o \n
+ * o x o \n
+ * o o o \n
+
+ * o o o \n
+ * o o o \n
+ * o o o \n
+ * is defined with length = 3.
+ */
+ struct cube3d : public Window< cube3d >,
+ public internal::dpoints_base_< dpoint3d, cube3d >
+ {
+ /// Point associated type.
+ typedef point3d point;
+
+ /// Dpoint associated type.
+ typedef dpoint3d dpoint;
+
+ /*! \brief Point_Iterator type to browse a cube such as: "for each row
+ * (increasing), for each column (increasing)."
+ */
+ typedef dpoints_fwd_piter<dpoint3d> fwd_qiter;
+
+ /*! \brief Point_Iterator type to browse a cube such as: "for each row
+ * (decreasing), for each column (decreasing)."
+ */
+ typedef dpoints_bkd_piter<dpoint3d> bkd_qiter;
+
+ /*! \brief Same as fwd_qiter.
+ */
+ typedef fwd_qiter qiter;
+
+ /*! \brief Constructor.
+ *
+ * \param[in] length Length, thus height, of the cube3d.
+ *
+ * \pre \p length is odd.
+ */
+ cube3d(unsigned length);
+
+ /*! \brief Test if the window is centered.
+ *
+ * \return True.
+ */
+ bool is_centered() const;
+
+ /*! \brief Test if the window is symmetric.
+ *
+ * \return true.
+ */
+ bool is_symmetric() const;
+
+ /*! \brief Give the cube length, that is, its height.
+ */
+ unsigned length() const;
+
+ /*! \brief Give the maximum coordinate gap between the window
+ * center and a window point.
+ */
+ unsigned delta() const;
+
+ /// Apply a central symmetry to the target window.
+ cube3d& sym();
+
+ protected:
+ unsigned length_;
+ };
+
+
+ /*! \brief Print a cube3d window \p win into the output
+ * stream \p ostr.
+ *
+ * \param[in,out] ostr An output stream.
+ * \param[in] win A cube3d window.
+ *
+ * \return The modified output stream \p ostr.
+ *
+ * \relates mln::win::cube3d
+ */
+ std::ostream& operator<<(std::ostream& ostr, const cube3d& win);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ cube3d::cube3d(unsigned length)
+ : length_(length)
+ {
+ mln_precondition(length % 2 == 1);
+ const int dind = length / 2;
+ for (int sli = - dind; sli <= dind; ++sli)
+ for (int row = - dind; row <= dind; ++row)
+ for (int col = - dind; col <= dind; ++col)
+ insert(make::dpoint3d(sli, row, col));
+ }
+
+ bool cube3d::is_centered() const
+ {
+ return true;
+ }
+
+ bool cube3d::is_symmetric() const
+ {
+ return true;
+ }
+
+ unsigned cube3d::length() const
+ {
+ return length_;
+ }
+
+ unsigned cube3d::delta() const
+ {
+ return length_ / 2;
+ }
+
+ cube3d& cube3d::sym()
+ {
+ return *this;
+ }
+
+ std::ostream& operator<<(std::ostream& ostr, const cube3d& win)
+ {
+ ostr << "[cube3d: length=" << win.length() << ']';
+ return ostr;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::win
+
+} // end of namespace mln
+
+
+
+#endif // ! MLN_CORE_WIN_CUBE3D_HH
Index: trunk/milena/mln/win/segment1d.hh
===================================================================
--- trunk/milena/mln/win/segment1d.hh (revision 0)
+++ trunk/milena/mln/win/segment1d.hh (revision 1283)
@@ -0,0 +1,181 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_WIN_SEGMENT1D_HH
+# define MLN_CORE_WIN_SEGMENT1D_HH
+
+/*! \file mln/win/segment1d.hh
+ *
+ * \brief Definition of the mln::win::segment1d window.
+ */
+
+# include <mln/core/concept/window.hh>
+# include <mln/core/internal/dpoints_base.hh>
+# include <mln/core/dpoint1d.hh>
+# include <mln/core/dpoints_piter.hh>
+
+
+namespace mln
+{
+
+ namespace win
+ {
+
+ /*! \brief Segment window defined on the 1D grid.
+ *
+ * An segment1d is centered and symmetrical; so
+ * its height (length) is odd.
+ *
+ * For instance: \n
+ * o x o \n
+ * is defined with length = 3.
+ */
+ struct segment1d : public Window< segment1d >,
+ public internal::dpoints_base_< dpoint1d, segment1d >
+ {
+ /// Point associated type.
+ typedef point1d point;
+
+ /// Dpoint associated type.
+ typedef dpoint1d dpoint;
+
+ /*! \brief Point_Iterator type to browse a segment such as: "for each row
+ * (increasing), for each column (increasing)."
+ */
+ typedef dpoints_fwd_piter<dpoint1d> fwd_qiter;
+
+ /*! \brief Point_Iterator type to browse a segment such as: "for each row
+ * (decreasing), for each column (decreasing)."
+ */
+ typedef dpoints_bkd_piter<dpoint1d> bkd_qiter;
+
+ /*! \brief Same as fwd_qiter.
+ */
+ typedef fwd_qiter qiter;
+
+ /*! \brief Constructor.
+ *
+ * \param[in] length Length, thus height, of the segment1d.
+ *
+ * \pre \p length is odd.
+ */
+ segment1d(unsigned length);
+
+ /*! \brief Test if the window is centered.
+ *
+ * \return True.
+ */
+ bool is_centered() const;
+
+ /*! \brief Test if the window is symmetric.
+ *
+ * \return true.
+ */
+ bool is_symmetric() const;
+
+ /*! \brief Give the segment length, that is, its height.
+ */
+ unsigned length() const;
+
+ /*! \brief Give the maximum coordinate gap between the window
+ * center and a window point.
+ */
+ unsigned delta() const;
+
+ /// Apply a central symmetry to the target window.
+ segment1d& sym();
+
+ protected:
+ unsigned length_;
+ };
+
+
+ /*! \brief Print a segment1D window \p win into the output
+ * stream \p ostr.
+ *
+ * \param[in,out] ostr An output stream.
+ * \param[in] win A segment1D window.
+ *
+ * \return The modified output stream \p ostr.
+ *
+ * \relates mln::win::segment1d
+ */
+ std::ostream& operator<<(std::ostream& ostr, const segment1d& win);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ segment1d::segment1d(unsigned length)
+ : length_(length)
+ {
+ mln_precondition(length % 2 == 1);
+ const int dind = length / 2;
+ for (int ind = - dind; ind <= dind; ++ind)
+ insert(make::dpoint1d(ind));
+ }
+
+ bool segment1d::is_centered() const
+ {
+ return true;
+ }
+
+ bool segment1d::is_symmetric() const
+ {
+ return true;
+ }
+
+ unsigned segment1d::length() const
+ {
+ return length_;
+ }
+
+ unsigned segment1d::delta() const
+ {
+ return length_ / 2;
+ }
+
+ segment1d& segment1d::sym()
+ {
+ return *this;
+ }
+
+ std::ostream& operator<<(std::ostream& ostr, const segment1d& win)
+ {
+ ostr << "[segment1d: length=" << win.length() << ']';
+ return ostr;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::win
+
+} // end of namespace mln
+
+
+
+#endif // ! MLN_CORE_WIN_SEGMENT1D_HH
Index: trunk/milena/mln/win/line.hh
===================================================================
--- trunk/milena/mln/win/line.hh (revision 0)
+++ trunk/milena/mln/win/line.hh (revision 1283)
@@ -0,0 +1,183 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_WIN_LINE_HH
+# define MLN_CORE_WIN_LINE_HH
+
+/*! \file mln/win/line.hh
+ *
+ * \brief Definition of the mln::win::line window.
+ */
+
+# include <mln/core/concept/window.hh>
+# include <mln/core/internal/dpoints_base.hh>
+# include <mln/core/dpoint.hh>
+# include <mln/core/dpoints_piter.hh>
+
+
+namespace mln
+{
+
+ namespace win
+ {
+
+ template <typename M, unsigned i, typename C>
+ struct line : public Window< line<M,i,C> >,
+ public internal::dpoints_base_<dpoint_<M, C>, point_<M, C> >
+ {
+ /// Point associated type.
+ typedef point_<M, int> point;
+
+ /// Dpoint associated type.
+ typedef dpoint_<M, int> dpoint;
+
+ /// Point_Iterator type to browse a line forward
+ typedef dpoints_fwd_piter<dpoint> fwd_qiter;
+
+ /// Point_Iterator type to browse a line backward
+ typedef dpoints_bkd_piter<dpoint> bkd_qiter;
+
+ /// Same as fwd_qiter
+ typedef fwd_qiter qiter;
+
+ /*! \brief Constructor.
+ *
+ * \param[in] length Length of the line.
+ *
+ * \pre \p length is odd.
+ */
+ line(unsigned length);
+
+ /*! \brief Test if the window is centered.
+ *
+ * \return True.
+ */
+ bool is_centered() const;
+
+ /*! \brief Test if the window is symmetric.
+ *
+ * \return true.
+ */
+ bool is_symmetric() const;
+
+ /*! \brief Give the hline length, that is, its width.
+ */
+ unsigned length() const;
+
+ /*! \brief Give the maximum coordinate gap between the window
+ * center and a window point.
+ */
+ unsigned delta() const;
+
+ /// Apply a central symmetry to the target window.
+ line<M,i,C>& sym();
+
+ protected:
+ unsigned length_;
+ };
+
+
+ /*! \brief Print an line window \p win into the output
+ * stream \p ostr.
+ *
+ * \param[in,out] ostr An output stream.
+ * \param[in] win An line window.
+ *
+ * \return The modified output stream \p ostr.
+ *
+ * \relates mln::win::line
+ */
+ template <typename M, unsigned i, typename C>
+ std::ostream& operator<<(std::ostream& ostr, const line<M,i,C>& win);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename M, unsigned i, typename C>
+ line<M,i,C>::line(unsigned length)
+ : length_(length)
+ {
+ mln_precondition(i < M::dim);
+ mln_precondition(length % 2 == 1);
+ const int dc = length / 2;
+ for (int c = - dc; c <= dc; ++c)
+ {
+ dpoint n;
+ n.set_all(0);
+ n[i] = c;
+ this->insert(n);
+ }
+ }
+
+ template <typename M, unsigned i, typename C>
+ bool line<M,i,C>::is_centered() const
+ {
+ return true;
+ }
+
+ template <typename M, unsigned i, typename C>
+ bool line<M,i,C>::is_symmetric() const
+ {
+ return true;
+ }
+
+ template <typename M, unsigned i, typename C>
+ unsigned line<M,i,C>::length() const
+ {
+ return length_;
+ }
+
+ template <typename M, unsigned i, typename C>
+ unsigned line<M,i,C>::delta() const
+ {
+ return length_ / 2;
+ }
+
+ template <typename M, unsigned i, typename C>
+ line<M,i,C>& line<M,i,C>::sym()
+ {
+ return *this;
+ }
+
+ template <typename M, unsigned i, typename C>
+ std::ostream& operator<<(std::ostream& ostr, const line<M,i,C>& win)
+ {
+ ostr << "[line: length=" << win.length() << ']';
+ return ostr;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::win
+
+} // end of namespace mln
+
+
+
+#endif // ! MLN_CORE_WIN_LINE_HH
Index: trunk/milena/mln/win/rectangle2d.hh
===================================================================
--- trunk/milena/mln/win/rectangle2d.hh (revision 0)
+++ trunk/milena/mln/win/rectangle2d.hh (revision 1283)
@@ -0,0 +1,198 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_WIN_RECTANGLE2D_HH
+# define MLN_CORE_WIN_RECTANGLE2D_HH
+
+/*! \file mln/win/rectangle2d.hh
+ *
+ * \brief Definition of the mln::win::rectangle2d window.
+ */
+
+# include <mln/core/concept/window.hh>
+# include <mln/core/internal/dpoints_base.hh>
+# include <mln/core/dpoint2d.hh>
+# include <mln/core/dpoints_piter.hh>
+
+
+namespace mln
+{
+
+ namespace win
+ {
+
+ /*! \brief Rectangular window defined on the 2D square grid.
+ *
+ * A rectangle2d is a 2D window with rectangular shape. It is
+ * centered and symmetrical.
+ *
+ * For instance: \n
+ * o o o o o \n
+ * o o x o o \n
+ * o o o o o \n
+ * is defined with height = 3 and width = 5.
+ */
+ struct rectangle2d : public Window< rectangle2d >,
+ public internal::dpoints_base_< dpoint2d, rectangle2d >
+ {
+ /// Point associated type.
+ typedef point2d point;
+
+ /// Dpoint associated type.
+ typedef dpoint2d dpoint;
+
+ /*! \brief Point_Iterator type to browse a rectangle such as: "for each row
+ * (increasing), for each column (increasing)."
+ */
+ typedef dpoints_fwd_piter<dpoint2d> fwd_qiter;
+
+ /*! \brief Point_Iterator type to browse a rectangle such as: "for each row
+ * (decreasing), for each column (decreasing)."
+ */
+ typedef dpoints_bkd_piter<dpoint2d> bkd_qiter;
+
+
+ /*! \brief Constructor.
+ *
+ * \param[in] height sic
+ * \param[in] width sic
+ *
+ * \pre Height and width are odd.
+ */
+ rectangle2d(unsigned height, unsigned width);
+
+
+ /*! \brief Test if the window is centered.
+ *
+ * \return True.
+ */
+ bool is_centered() const;
+
+ /*! \brief Test if the window is symmetric.
+ *
+ * \return true.
+ */
+ bool is_symmetric() const;
+
+ /*! \brief Give the rectangle height.
+ */
+ unsigned height() const;
+
+ /*! \brief Give the rectangle width.
+ */
+ unsigned width() const;
+
+ /*! \brief Give the maximum coordinate gap between the window
+ * center and a window point.
+ */
+ unsigned delta() const;
+
+ /// Apply a central symmetry to the target window.
+ rectangle2d& sym();
+
+ protected:
+ unsigned height_, width_;
+ };
+
+
+ /*! \brief Print a rectangle window \p win into the output stream \p
+ * ostr.
+ *
+ * \param[in,out] ostr An output stream.
+ * \param[in] win A rectangle window.
+ *
+ * \return The modified output stream \p ostr.
+ *
+ * \relates mln::win::rectangle2d
+ */
+ std::ostream& operator<<(std::ostream& ostr, const rectangle2d& win);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ rectangle2d::rectangle2d(unsigned height, unsigned width)
+ : height_(height),
+ width_(width)
+ {
+ mln_precondition(height % 2 == 1 && width % 2 == 1);
+ const int drow = height / 2, dcol = width / 2;
+ for (int row = - drow; row <= drow; ++row)
+ for (int col = - dcol; col <= dcol; ++col)
+ insert(make::dpoint2d(row, col));
+ }
+
+ bool rectangle2d::is_centered() const
+ {
+ return true;
+ }
+
+ bool rectangle2d::is_symmetric() const
+ {
+ return true;
+ }
+
+ unsigned rectangle2d::height() const
+ {
+ return height_;
+ }
+
+ unsigned rectangle2d::width() const
+ {
+ return width_;
+ }
+
+ unsigned rectangle2d::delta() const
+ {
+ return width_ > height_ ? width_ / 2 : height_ / 2;
+ }
+
+ rectangle2d& rectangle2d::sym()
+ {
+ return *this;
+ }
+
+ std::ostream& operator<<(std::ostream& ostr, const rectangle2d& win)
+ {
+ ostr << "[rectangle2d: width=" << win.width() << ", height=" << win.height() << ']';
+ return ostr;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::win
+
+} // end of namespace mln
+
+
+
+// when rectangle2d is involved, one surely also wants:
+# include <mln/win/hline2d.hh>
+# include <mln/win/vline2d.hh>
+
+
+#endif // ! MLN_CORE_WIN_RECTANGLE2D_HH
Index: trunk/milena/mln/win/diag2d.hh
===================================================================
--- trunk/milena/mln/win/diag2d.hh (revision 0)
+++ trunk/milena/mln/win/diag2d.hh (revision 1283)
@@ -0,0 +1,185 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_WIN_DIAG2D_HH
+# define MLN_CORE_WIN_DIAG2D_HH
+
+/*! \file mln/win/diag2d.hh
+ *
+ * \brief Definition of the mln::win::diag2d window.
+ */
+
+# include <mln/core/concept/window.hh>
+# include <mln/core/internal/dpoints_base.hh>
+# include <mln/core/dpoint2d.hh>
+# include <mln/core/dpoints_piter.hh>
+
+
+namespace mln
+{
+
+ namespace win
+ {
+
+ /*! \brief Diagonal line window defined on the 2D square grid.
+ *
+ * An diag2d is centered and symmetrical.
+ * its width (length) is odd.
+ *
+ * For instance: \n
+ * o \n
+ * o \n
+ * x \n
+ * o \n
+ * o \n
+ * is defined with length = 5.
+ */
+ struct diag2d : public Window< diag2d >,
+ public internal::dpoints_base_< dpoint2d, diag2d >
+ {
+ /// Point associated type.
+ typedef point2d point;
+
+ /// Dpoint associated type.
+ typedef dpoint2d dpoint;
+
+ /*! \brief Point_Iterator type to browse a hline such as: "for each row
+ * (increasing), for each column (increasing)."
+ */
+ typedef dpoints_fwd_piter<dpoint2d> fwd_qiter;
+
+ /*! \brief Point_Iterator type to browse a hline such as: "for each row
+ * (decreasing), for each column (decreasing)."
+ */
+ typedef dpoints_bkd_piter<dpoint2d> bkd_qiter;
+
+ /*! \brief Same as fwd_qiter.
+ */
+ typedef fwd_qiter qiter;
+
+ /*! \brief Constructor.
+ *
+ * \param[in] length Length, thus width, of the diagonal line.
+ *
+ * \pre \p length is odd.
+ */
+ diag2d(unsigned length);
+
+ /*! \brief Test if the window is centered.
+ *
+ * \return True.
+ */
+ bool is_centered() const;
+
+ /*! \brief Test if the window is symmetric.
+ *
+ * \return true.
+ */
+ bool is_symmetric() const;
+
+ /*! \brief Give the diagonal length, that is, its width.
+ */
+ unsigned length() const;
+
+ /*! \brief Give the maximum coordinate gap between the window
+ * center and a window point.
+ */
+ unsigned delta() const;
+
+ /// Apply a central symmetry to the target window.
+ diag2d& sym();
+
+ protected:
+ unsigned length_;
+ };
+
+
+ /*! \brief Print an diagonal line window \p win into the output
+ * stream \p ostr.
+ *
+ * \param[in,out] ostr An output stream.
+ * \param[in] win A diagonal line window.
+ *
+ * \return The modified output stream \p ostr.
+ *
+ * \relates mln::win::diag2d
+ */
+ std::ostream& operator<<(std::ostream& ostr, const diag2d& win);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ diag2d::diag2d(unsigned length)
+ : length_(length)
+ {
+ mln_precondition(length % 2 == 1);
+ const int dcol = length / 2;
+ for (int col = - dcol; col <= dcol; ++col)
+ insert(make::dpoint2d(-col, col));
+ }
+
+ bool diag2d::is_centered() const
+ {
+ return true;
+ }
+
+ bool diag2d::is_symmetric() const
+ {
+ return true;
+ }
+
+ unsigned diag2d::length() const
+ {
+ return length_;
+ }
+
+ unsigned diag2d::delta() const
+ {
+ return length_ / 2;
+ }
+
+ diag2d& diag2d::sym()
+ {
+ return *this;
+ }
+
+ std::ostream& operator<<(std::ostream& ostr, const diag2d& win)
+ {
+ ostr << "[diag 2d: length=" << win.length() << ']';
+ return ostr;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::win
+
+} // end of namespace mln
+
+
+
+#endif // ! MLN_CORE_WIN_DIAG2D_HH
Index: trunk/milena/mln/win/backdiag2d.hh
===================================================================
--- trunk/milena/mln/win/backdiag2d.hh (revision 0)
+++ trunk/milena/mln/win/backdiag2d.hh (revision 1283)
@@ -0,0 +1,185 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_WIN_BACKDIAG2D_HH
+# define MLN_CORE_WIN_BACKDIAG2D_HH
+
+/*! \file mln/win/backdiag2d.hh
+ *
+ * \brief Definition of the mln::win::backdiag2d window.
+ */
+
+# include <mln/core/concept/window.hh>
+# include <mln/core/internal/dpoints_base.hh>
+# include <mln/core/dpoint2d.hh>
+# include <mln/core/dpoints_piter.hh>
+
+
+namespace mln
+{
+
+ namespace win
+ {
+
+ /*! \brief Diagonal line window defined on the 2D square grid.
+ *
+ * An backdiag2d is centered and symmetrical.
+ * its width (length) is odd.
+ *
+ * For instance: \n
+ * o \n
+ * o \n
+ * x \n
+ * o \n
+ * o \n
+ * is defined with length = 5.
+ */
+ struct backdiag2d : public Window< backdiag2d >,
+ public internal::dpoints_base_< dpoint2d, backdiag2d >
+ {
+ /// Point associated type.
+ typedef point2d point;
+
+ /// Dpoint associated type.
+ typedef dpoint2d dpoint;
+
+ /*! \brief Point_Iterator type to browse a hline such as: "for each row
+ * (increasing), for each column (increasing)."
+ */
+ typedef dpoints_fwd_piter<dpoint2d> fwd_qiter;
+
+ /*! \brief Point_Iterator type to browse a hline such as: "for each row
+ * (decreasing), for each column (decreasing)."
+ */
+ typedef dpoints_bkd_piter<dpoint2d> bkd_qiter;
+
+ /*! \brief Same as fwd_qiter.
+ */
+ typedef fwd_qiter qiter;
+
+ /*! \brief Constructor.
+ *
+ * \param[in] length Length, thus width, of the diagonal line.
+ *
+ * \pre \p length is odd.
+ */
+ backdiag2d(unsigned length);
+
+ /*! \brief Test if the window is centered.
+ *
+ * \return True.
+ */
+ bool is_centered() const;
+
+ /*! \brief Test if the window is symmetric.
+ *
+ * \return true.
+ */
+ bool is_symmetric() const;
+
+ /*! \brief Give the diagonal length, that is, its width.
+ */
+ unsigned length() const;
+
+ /*! \brief Give the maximum coordinate gap between the window
+ * center and a window point.
+ */
+ unsigned delta() const;
+
+ /// Apply a central symmetry to the target window.
+ backdiag2d& sym();
+
+ protected:
+ unsigned length_;
+ };
+
+
+ /*! \brief Print an diagonal line window \p win into the output
+ * stream \p ostr.
+ *
+ * \param[in,out] ostr An output stream.
+ * \param[in] win A diagonal line window.
+ *
+ * \return The modified output stream \p ostr.
+ *
+ * \relates mln::win::backdiag2d
+ */
+ std::ostream& operator<<(std::ostream& ostr, const backdiag2d& win);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ backdiag2d::backdiag2d(unsigned length)
+ : length_(length)
+ {
+ mln_precondition(length % 2 == 1);
+ const int dcol = length / 2;
+ for (int col = - dcol; col <= dcol; ++col)
+ insert(make::dpoint2d(col, col));
+ }
+
+ bool backdiag2d::is_centered() const
+ {
+ return true;
+ }
+
+ bool backdiag2d::is_symmetric() const
+ {
+ return true;
+ }
+
+ unsigned backdiag2d::length() const
+ {
+ return length_;
+ }
+
+ unsigned backdiag2d::delta() const
+ {
+ return length_ / 2;
+ }
+
+ backdiag2d& backdiag2d::sym()
+ {
+ return *this;
+ }
+
+ std::ostream& operator<<(std::ostream& ostr, const backdiag2d& win)
+ {
+ ostr << "[diag 2d: length=" << win.length() << ']';
+ return ostr;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::win
+
+} // end of namespace mln
+
+
+
+#endif // ! MLN_CORE_WIN_BACKDIAG2D_HH
Index: trunk/milena/mln/win/octagon2d.hh
===================================================================
--- trunk/milena/mln/win/octagon2d.hh (revision 0)
+++ trunk/milena/mln/win/octagon2d.hh (revision 1283)
@@ -0,0 +1,215 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_WIN_OCTAGON2D_HH
+# define MLN_CORE_WIN_OCTAGON2D_HH
+
+/*! \file mln/win/octagon2d.hh
+ *
+ * \brief Definition of the mln::win::octagon2d window.
+ */
+
+# include <mln/core/concept/window.hh>
+# include <mln/core/internal/dpoints_base.hh>
+# include <mln/core/dpoint2d.hh>
+# include <mln/core/dpoints_piter.hh>
+
+
+namespace mln
+{
+
+ namespace win
+ {
+
+ /*! \brief Octagon window defined on the 2D square grid.
+ *
+ * An octagon2d is centered and symmetrical.
+ * The length l of the octagon is such as l = 6*x + 1
+ * where 0 <= x.
+ *
+ * For instance: \n
+ * o o o \n
+ * o o o o o \n
+ * o o o o o o o \n
+ * o o o x o o o \n
+ * o o o o o o o \n
+ * o o o o o \n
+ * o o o \n
+ * is defined with length = 7 (x = 0).
+ */
+ struct octagon2d : public Window< octagon2d >,
+ public internal::dpoints_base_< dpoint2d, octagon2d >
+ {
+ /// Point associated type.
+ typedef point2d point;
+
+ /// Dpoint associated type.
+ typedef dpoint2d dpoint;
+
+ /*! \brief Point_Iterator type to browse a hline such as: "for each row
+ * (increasing), for each column (increasing)."
+ */
+ typedef dpoints_fwd_piter<dpoint2d> fwd_qiter;
+
+ /*! \brief Point_Iterator type to browse a hline such as: "for each row
+ * (decreasing), for each column (decreasing)."
+ */
+ typedef dpoints_bkd_piter<dpoint2d> bkd_qiter;
+
+ /*! \brief Same as fwd_qiter.
+ */
+ typedef fwd_qiter qiter;
+
+ /*! \brief Constructor.
+ *
+ * \param[in] lenght Length, of the octagon.
+ *
+ * \pre \p length is such as length = 6*x + 1 where x >= 0.
+ */
+ octagon2d(unsigned length);
+
+ /*! \brief Test if the window is centered.
+ *
+ * \return True.
+ */
+ bool is_centered() const;
+
+ /*! \brief Test if the window is symmetric.
+ *
+ * \return true.
+ */
+ bool is_symmetric() const;
+
+ /*! \brief Give the octagon length, that is, its width.
+ */
+ unsigned length() const;
+
+ /*! \brief Give the maximum coordinate gap between the window
+ * center and a window point.
+ */
+ unsigned delta() const;
+
+ /// Apply a central symmetry to the target window.
+ octagon2d& sym();
+
+ protected:
+ unsigned length_;
+ };
+
+
+ /*! \brief Print an octagon window \p win into the output
+ * stream \p ostr.
+ *
+ * \param[in,out] ostr An output stream.
+ * \param[in] win An octagon window.
+ *
+ * \return The modified output stream \p ostr.
+ *
+ * \relates mln::win::octagon2d
+ */
+ std::ostream& operator<<(std::ostream& ostr, const octagon2d& win);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ octagon2d::octagon2d(unsigned length)
+ : length_(length)
+ {
+ mln_precondition(length % 6 == 1);
+ const int y = length / 6;
+ const int x = y * 2;
+ const int z = y + x;
+ insert(dpoint2d::zero);
+ for (int a = 1; a <= x; ++a)
+ for (int b = 0; b <= x; ++b)
+ {
+ insert(make::dpoint2d(a, b));
+ insert(make::dpoint2d(-b, a));
+ insert(make::dpoint2d(b, -a));
+ insert(make::dpoint2d(-a, -b));
+ }
+ for (int a = x + 1; a <= z; ++a)
+ for (int b = -2 * x + a; b <= 2 * x - a; ++b)
+ {
+ insert(make::dpoint2d(a, b));
+ insert(make::dpoint2d(a, -b));
+ insert(make::dpoint2d(-a, b));
+ insert(make::dpoint2d(-a, -b));
+ insert(make::dpoint2d(b, a));
+ insert(make::dpoint2d(b, -a));
+ insert(make::dpoint2d(-b, a));
+ insert(make::dpoint2d(-b, -a));
+ }
+ }
+
+ bool octagon2d::is_centered() const
+ {
+ return true;
+ }
+
+ bool octagon2d::is_symmetric() const
+ {
+ return true;
+ }
+
+ unsigned octagon2d::length() const
+ {
+ return length_;
+ }
+
+ unsigned octagon2d::delta() const
+ {
+ return length_ / 2;
+ }
+
+ octagon2d& octagon2d::sym()
+ {
+ return *this;
+ }
+
+ std::ostream& operator<<(std::ostream& ostr, const octagon2d& win)
+ {
+ ostr << "[octagon2d: length=" << win.length() << ']';
+ return ostr;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::win
+
+} // end of namespace mln
+
+
+
+// when rectangle2d is involved, one surely also wants:
+# include <mln/win/hline2d.hh>
+# include <mln/win/vline2d.hh>
+# include <mln/win/diag2d.hh>
+# include <mln/win/backdiag2d.hh>
+
+#endif // ! MLN_CORE_WIN_OCTAGON2D_HH
Index: trunk/milena/mln/win/disk2d.hh
===================================================================
--- trunk/milena/mln/win/disk2d.hh (revision 0)
+++ trunk/milena/mln/win/disk2d.hh (revision 1283)
@@ -0,0 +1,179 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_WIN_DISK2D_HH
+# define MLN_CORE_WIN_DISK2D_HH
+
+/*! \file mln/win/disk2d.hh
+ *
+ * \brief Definition of the mln::win::disk2d window.
+ */
+
+# include <mln/core/concept/window.hh>
+# include <mln/core/internal/dpoints_base.hh>
+# include <mln/core/dpoint2d.hh>
+# include <mln/core/dpoints_piter.hh>
+
+
+namespace mln
+{
+
+ namespace win
+ {
+
+ /*! \brief Disk window defined on the 2D square grid.
+ *
+ * An disk2d is centered and symmetrical.
+ *
+ */
+ struct disk2d : public Window< disk2d >,
+ public internal::dpoints_base_< dpoint2d, disk2d >
+ {
+ /// Point associated type.
+ typedef point2d point;
+
+ /// Dpoint associated type.
+ typedef dpoint2d dpoint;
+
+ /*! \brief Point_Iterator type to browse a hline such as: "for each row
+ * (increasing), for each column (increasing)."
+ */
+ typedef dpoints_fwd_piter<dpoint2d> fwd_qiter;
+
+ /*! \brief Point_Iterator type to browse a hline such as: "for each row
+ * (decreasing), for each column (decreasing)."
+ */
+ typedef dpoints_bkd_piter<dpoint2d> bkd_qiter;
+
+ /*! \brief Same as fwd_qiter.
+ */
+ typedef fwd_qiter qiter;
+
+ /*! \brief Constructor.
+ *
+ * \param[in] length Length, thus diameter.
+ *
+ */
+ disk2d(unsigned length);
+
+ /*! \brief Test if the window is centered.
+ *
+ * \return True.
+ */
+ bool is_centered() const;
+
+ /*! \brief Test if the window is symmetric.
+ *
+ * \return true.
+ */
+ bool is_symmetric() const;
+
+ /*! \brief Give the disk length, that is, its width.
+ */
+ unsigned length() const;
+
+ /*! \brief Give the maximum coordinate gap between the window
+ * center and a window point.
+ */
+ unsigned delta() const;
+
+ /// Apply a central symmetry to the target window.
+ disk2d& sym();
+
+ protected:
+ unsigned length_;
+ };
+
+
+ /*! \brief Print an disk window \p win into the output
+ * stream \p ostr.
+ *
+ * \param[in,out] ostr An output stream.
+ * \param[in] win A disk window.
+ *
+ * \return The modified output stream \p ostr.
+ *
+ * \relates mln::win::disk2d
+ */
+ std::ostream& operator<<(std::ostream& ostr, const disk2d& win);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ disk2d::disk2d(unsigned length)
+ : length_(length)
+ {
+ mln_precondition(length % 2 == 1);
+ const int r = length / 2;
+ const int r2 = r * r;
+ for (int a = -r; a <= r; ++a)
+ for (int b = -r; b <= r; ++b)
+ if (a * a + b * b <= r2)
+ insert(make::dpoint2d(a, b));
+ }
+
+ bool disk2d::is_centered() const
+ {
+ return true;
+ }
+
+ bool disk2d::is_symmetric() const
+ {
+ return true;
+ }
+
+ unsigned disk2d::length() const
+ {
+ return length_;
+ }
+
+ unsigned disk2d::delta() const
+ {
+ return length_ / 2;
+ }
+
+ disk2d& disk2d::sym()
+ {
+ return *this;
+ }
+
+ std::ostream& operator<<(std::ostream& ostr, const disk2d& win)
+ {
+ ostr << "[disk2d: length=" << win.length() << ']';
+ return ostr;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::win
+
+} // end of namespace mln
+
+
+
+#endif // ! MLN_CORE_WIN_DISK2D_HH
Index: trunk/milena/sandbox/nivault/dyn_line.hh
===================================================================
--- trunk/milena/sandbox/nivault/dyn_line.hh (revision 1282)
+++ trunk/milena/sandbox/nivault/dyn_line.hh (revision 1283)
@@ -28,7 +28,7 @@
#ifndef MLN_CORE_WIN_DYN_LINE_HH
# define MLN_CORE_WIN_DYN_LINE_HH
-/*! \file mln/core/win/dyn_line.hh
+/*! \file mln/win/dyn_line.hh
*
* \brief Definition of the mln::win::dyn_line window.
*/
Index: trunk/milena/sandbox/nivault/tests/pouet.cc
===================================================================
--- trunk/milena/sandbox/nivault/tests/pouet.cc (revision 1282)
+++ trunk/milena/sandbox/nivault/tests/pouet.cc (revision 1283)
@@ -1,7 +1,7 @@
#include <mln/morpho/includes.hh>
-#include <mln/core/win/dyn_line.hh>
-#include <mln/core/win/hline2d.hh>
+#include <mln/win/dyn_line.hh>
+#include <mln/win/hline2d.hh>
#include <mln/io/pgm/load.hh>
#include <mln/io/pgm/save.hh>
Index: trunk/milena/sandbox/nivault/median.hh
===================================================================
--- trunk/milena/sandbox/nivault/median.hh (revision 1282)
+++ trunk/milena/sandbox/nivault/median.hh (revision 1283)
@@ -37,8 +37,8 @@
# include <mln/geom/size2d.hh>
# include <mln/core/window2d.hh>
-# include <mln/core/win/hline2d.hh>
-# include <mln/core/win/vline2d.hh>
+# include <mln/win/hline2d.hh>
+# include <mln/win/vline2d.hh>
# include <mln/core/t_image.hh>
# include <mln/core/dpoint.hh>
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-09 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add display::show for visualize temporary image.
* show.hh: Compile with warning by tempnam function.
---
show.hh | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 94 insertions(+)
Index: trunk/milena/mln/display/show.hh
===================================================================
--- trunk/milena/mln/display/show.hh (revision 0)
+++ trunk/milena/mln/display/show.hh (revision 1279)
@@ -0,0 +1,94 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_DISPLAY_SHOW_HH
+# define MLN_DISPLAY_SHOW_HH
+
+/*! \file mln/display/show.hh
+ *
+ * \brief Create a pretty image, which display its content
+ * with red value for non-defined point site.
+ */
+
+# include <mln/trait/image_from_mesh.hh>
+# include <mln/core/image_if_value.hh>
+# include <mln/core/image2d.hh>
+# include <mln/value/rgb8.hh>
+# include <mln/level/fill.hh>
+# include <mln/level/paste.hh>
+# include <mln/display/color_pretty.hh>
+# include <mln/io/ppm/save.hh>
+# include <mln/core/image2d.hh>
+
+namespace mln
+{
+
+ namespace display
+ {
+
+ template <typename I>
+ void
+ show(const Image<I>& input_, std::string cmd = "xv");
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ template <typename I>
+ void
+ show(const Image<I>& input_, std::string cmd)
+ {
+ const I& input = exact (input_);
+ image2d<value::rgb8> out = display::color_pretty(input);
+
+ std::string tmp = tempnam (0, "ppm");
+ // Save output image from color in out.ppm.
+ io::ppm::save(out, tmp);
+
+ std::string s = cmd + " " + tmp;
+ system (s.c_str ());
+ }
+
+ } // end of namespace mln::display::impl
+
+ /// Facade.
+ template <typename I>
+ void
+ show(const Image<I>& input_, std::string cmd = "xv")
+ {
+ return impl::show(input_, cmd);
+ }
+
+# endif // !MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::display
+
+} // end of namespace mln
+
+
+#endif // ! MLN_DISPLAY_SHOW_HH
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-09 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add test for display::show.
* show.cc: New test.
---
show.cc | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
Index: trunk/milena/tests/show.cc
===================================================================
--- trunk/milena/tests/show.cc (revision 0)
+++ trunk/milena/tests/show.cc (revision 1278)
@@ -0,0 +1,67 @@
+// 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/sub_image.cc
+ *
+ * \brief Tests on mln::sub_image.
+ */
+
+# include <mln/core/image2d.hh>
+# include <mln/io/pbm/load.hh>
+# include <mln/make/win_chamfer.hh>
+# include <mln/geom/chamfer.hh>
+# include <mln/value/rgb8.hh>
+# include <mln/core/sub_image.hh>
+# include <mln/core/image_if_value.hh>
+# include <mln/core/inplace.hh>
+# include <mln/core/w_window2d_int.hh>
+# include <mln/display/show.hh>
+# include <mln/io/ppm/save.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ unsigned max = 51;
+
+
+ image2d<bool> input = io::pbm::load("../img/toto.pbm");
+
+ // Create a weighted windows :
+ // 0 2 0
+ // 2 p 2
+ // 0 2 0
+ const w_window2d_int& w_win = win_chamfer::mk_chamfer_3x3_int<2, 0> ();
+
+ // Call chamfer for a distance image.
+ image2d<unsigned> tmp = geom::chamfer(input, w_win, max);
+
+ // Call color_pretty for sub_image.
+ for (unsigned i = 2; i < 9; i += 2)
+ display::show (inplace (tmp | i));
+}