https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix many little things in weighted window related stuff.
* tests/core/alias/w_window1d_int.cc: Fix doc.
* tests/core/alias/window1d.cc: Likewise.
Remove echo on std::cout.
* tests/core/alias/w_window3d_int.cc: Likewise.
* tests/core/alias/window3d.cc: Likewise.
* tests/core/alias/w_window2d_int.cc: Fix doc.
* tests/core/alias/window2d.cc: Remove useless include.
* mln/trait/image_from_grid.hh: Update doc style.
* mln/core/concept/weighted_window.hh: Likewise.
(sym): Fix sig in doc.
(W): Rename this parameter as...
(E): ...this to remain consistent with othe concept files.
(is_empty, is_centered, delta): Move to...
* mln/core/internal/weighted_window_base.hh: ...this new file.
* mln/core/concept/object.hh: Include some more metal stuff.
* mln/core/concept/window.hh
(level::fill): Replace by plain code to supress dep.
(internal::bbox_): Move this hack into...
* mln/core/internal/geom_bbox.hh: ...this new file.
Update include.
* mln/core/w_window.hh (w_window): Update inheritance.
* mln/core/internal/window_base.hh: Fix copyright.
* mln/make/w_window2d.hh: Fix missing include.
* mln/convert/to_image.hh: Likewise.
(to_image): Fix sig in the Weighted_Window overload.
mln/convert/to_image.hh | 11 +
mln/core/concept/object.hh | 2
mln/core/concept/weighted_window.hh | 63 ++++------
mln/core/concept/window.hh | 39 +-----
mln/core/internal/geom_bbox.hh | 75 ++++++++++++
mln/core/internal/weighted_window_base.hh | 178 ++++++++++++++++++++++++++++++
mln/core/internal/window_base.hh | 2
mln/core/w_window.hh | 57 ++-------
mln/make/w_window2d.hh | 1
mln/trait/image_from_grid.hh | 12 +-
tests/core/alias/w_window1d_int.cc | 5
tests/core/alias/w_window2d_int.cc | 8 -
tests/core/alias/w_window3d_int.cc | 15 --
tests/core/alias/window1d.cc | 9 -
tests/core/alias/window2d.cc | 1
tests/core/alias/window3d.cc | 14 --
16 files changed, 339 insertions(+), 153 deletions(-)
Index: tests/core/alias/w_window1d_int.cc
--- tests/core/alias/w_window1d_int.cc (revision 2767)
+++ tests/core/alias/w_window1d_int.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008 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
@@ -26,7 +27,7 @@
// Public License.
/// \file tests/core/alias/w_window1d_int.cc
-/// \brief Tests on mln::w_window1d_int.
+/// Tests on mln::w_window1d_int.
#include <mln/core/alias/w_window1d_int.hh>
#include <mln/win/segment1d.hh>
Index: tests/core/alias/window1d.cc
--- tests/core/alias/window1d.cc (revision 2767)
+++ tests/core/alias/window1d.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -31,9 +32,7 @@
*/
#include <mln/core/alias/window1d.hh>
-#include <mln/core/image/image1d.hh>
#include <mln/convert/to_image.hh>
-#include <mln/debug/println.hh>
@@ -46,14 +45,12 @@
mln_assertion(w.is_centered() == false);
mln_assertion(w.is_symmetric() == true);
- // FIXME: Does not compile as expected.
+ // As expected, the code below does not compile:
// w.insert(-1,0);
w.insert(-1);
w.insert( 1);
image1d<bool> ima = convert::to_image(w);
- debug::println(ima);
-
mln_assertion(w.delta() == 1);
}
Index: tests/core/alias/w_window2d_int.cc
--- tests/core/alias/w_window2d_int.cc (revision 2767)
+++ tests/core/alias/w_window2d_int.cc (working copy)
@@ -1,4 +1,5 @@
// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,10 +26,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/core/alias/w_window2d_int.cc
- *
- * \brief Tests on mln::w_window2d_int.
- */
+/// \file tests/core/alias/w_window2d_int.cc
+///
+/// Tests on mln::w_window2d_int.
#include <mln/core/alias/w_window2d_int.hh>
#include <mln/win/rectangle2d.hh>
Index: tests/core/alias/window2d.cc
--- tests/core/alias/window2d.cc (revision 2767)
+++ tests/core/alias/window2d.cc (working copy)
@@ -31,7 +31,6 @@
/// Tests on mln::window2d.
#include <mln/core/alias/window2d.hh>
-#include <mln/core/image/image2d.hh>
#include <mln/convert/to_image.hh>
Index: tests/core/alias/w_window3d_int.cc
--- tests/core/alias/w_window3d_int.cc (revision 2767)
+++ tests/core/alias/w_window3d_int.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,10 +26,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/core/alias/w_window3d_int.cc
- *
- * \brief Tests on mln::w_window3d_int.
- */
+/// tests/core/alias/w_window3d_int.cc
+///
+/// Tests on mln::w_window3d_int.
#include <mln/core/alias/w_window3d_int.hh>
#include <mln/win/cube3d.hh>
@@ -38,8 +38,6 @@
#include <mln/convert/to_fun.hh>
#include <mln/estim/sum.hh>
-#include <mln/debug/println.hh>
-
int f(mln::point3d p)
{
@@ -64,8 +62,6 @@
w_window3d_int w_win = make::w_window3d(ws);
image3d<int> ima = convert::to_image(w_win);
- debug::println(ima);
- std::cout << std::endl;
w_window3d_int w_win_2 = convert::to<w_window3d_int>(ima);
mln_assertion(w_win_2 == w_win);
}
@@ -77,7 +73,6 @@
// -2 -1 0 +1 +2
// -1 0 +1 +2 +3
image3d<int> ima = convert::to_image(w_win);
- debug::println(ima);
mln_assertion(estim::sum(ima) == 0);
}
Index: tests/core/alias/window3d.cc
--- tests/core/alias/window3d.cc (revision 2767)
+++ tests/core/alias/window3d.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -31,10 +32,7 @@
*/
#include <mln/core/alias/window3d.hh>
-#include <mln/core/image/image3d.hh>
#include <mln/convert/to_image.hh>
-#include <mln/debug/println.hh>
-
int main()
@@ -46,12 +44,10 @@
mln_assertion(w.is_centered() == false);
mln_assertion(w.is_symmetric() == true);
- w.insert(dpoint3d(-1, -1, -1));
- w.insert(dpoint3d( 1, 1, 1));
- w.insert(dpoint3d( 0, 0, 2));
+ w.insert(-1, -1, -1);
+ w.insert( 1, 1, 1);
+ w.insert( 0, 0, 2);
image3d<bool> ima = convert::to_image(w);
- debug::println(ima);
-
mln_assertion(w.delta() == 2);
}
Index: mln/trait/image_from_grid.hh
--- mln/trait/image_from_grid.hh (revision 2767)
+++ mln/trait/image_from_grid.hh (working copy)
@@ -1,4 +1,5 @@
// Copyright (C) 2007, 2008 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
@@ -28,10 +29,13 @@
#ifndef MLN_TRAIT_IMAGE_FROM_MESH_HH
# define MLN_TRAIT_IMAGE_FROM_MESH_HH
-/*! \file mln/trait/image_from_grid.hh
- *
- * \brief Definition of the "image from mesh" trait.
- */
+/// \file mln/trait/image_from_grid.hh
+///
+/// Definition of the "image from mesh" trait.
+///
+/// This file shall not include the concrete image types it returns;
+/// otherwise we get circular dependencies. As a consequence the user
+/// shall include the appropriate image type she deals with.
# include <mln/core/grids.hh>
Index: mln/core/w_window.hh
--- mln/core/w_window.hh (revision 2767)
+++ mln/core/w_window.hh (working copy)
@@ -37,7 +37,7 @@
# include <map>
-# include <mln/core/concept/weighted_window.hh>
+# include <mln/core/internal/weighted_window_base.hh>
# include <mln/core/concept/image.hh>
# include <mln/core/site_set/box.hh>
# include <mln/core/window.hh>
@@ -45,7 +45,6 @@
# include <mln/value/ops.hh>
# include <mln/util/ord.hh>
-# include <mln/level/fill.hh>
# include <mln/geom/bbox.hh> // FIXME: We may have some dep trouble with this
include.
# include <mln/literal/zero.hh>
# include <mln/convert/to.hh>
@@ -63,7 +62,7 @@
{
template <typename D, typename W>
- struct window_< mln::w_window<D,W> > : window_<W>
+ struct window_< mln::w_window<D,W> > : window_< mln::window<D>
>
{
// Same traits as its corresponding window.
};
@@ -78,23 +77,15 @@
* the type of weights.
*/
template <typename D, typename W>
- struct w_window : public Weighted_Window< w_window<D,W> >
+ struct w_window : public internal::weighted_window_base< mln::window<D>,
+ w_window<D,W> >
{
/// Dpsite associated type.
typedef D dpsite;
- /// Psite associated type.
- typedef mln_psite(D) psite;
-
- /// Site associated type.
- typedef mln_site(D) site;
-
/// Weight associated type.
typedef W weight;
- /// Window associated type.
- typedef mln::window<D> window;
-
/// Site_Iterator type to browse (forward) the points of a generic w_window.
typedef with_w_< dpsites_fwd_piter< w_window<D, W> >, W >
fwd_qiter;
@@ -118,12 +109,6 @@
const std::vector<W>& weights() const;
- // Give the \p i-th delta-point.
- const D& dp(unsigned i) const;
-
- /// Give the number of delta-points.
- unsigned size() const;
-
/// Give access to the vector of delta-points.
const std::vector<D>& std_vector() const;
@@ -237,25 +222,6 @@
template <typename D, typename W>
inline
- const D&
- w_window<D,W>::dp(unsigned i) const
- {
- mln_precondition(i < win_.size());
- mln_invariant(wei_.size() == win_.size());
- return win_.dp(i);
- }
-
- template <typename D, typename W>
- inline
- unsigned
- w_window<D,W>::size() const
- {
- mln_invariant(wei_.size() == win_.size());
- return win_.size();
- }
-
- template <typename D, typename W>
- inline
const std::vector<D>&
w_window<D,W>::std_vector() const
{
@@ -344,9 +310,10 @@
mlc_converts_to(mln_value(I), W)::check();
const I& ima = exact(from_);
to.clear();
+ mln_value(I) zero = literal::zero;
mln_piter(I) p(ima.domain());
for_all(p)
- if (ima(p) != literal::zero)
+ if (ima(p) != zero)
to.insert(ima(p), convert::to<D>(p));
}
@@ -363,8 +330,13 @@
// mln_precondition(w_win.is_valid());
ima.init_(geom::bbox(w_win));
- level::fill(ima, literal::zero);
-
+ {
+ // level::fill(ima, literal::zero) is:
+ mln_value(I) zero = literal::zero;
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ ima(p) = zero;
+ }
unsigned n = w_win.size();
for (unsigned i = 0; i < n; ++i)
ima(convert::to<P>(w_win.dp(i))) = w_win.w(i);
@@ -407,9 +379,10 @@
box<P> b(all_to(-s), all_to(+s));
mln_fwd_piter(box<P>) p(b);
unsigned i = 0;
+ V zero = literal::zero;
for_all(p)
{
- if (weight[i] != literal::zero)
+ if (weight[i] != zero)
to.insert(weight[i], convert::to<D>(p));
++i;
}
Index: mln/core/concept/weighted_window.hh
--- mln/core/concept/weighted_window.hh (revision 2767)
+++ mln/core/concept/weighted_window.hh (working copy)
@@ -29,10 +29,11 @@
#ifndef MLN_CORE_CONCEPT_WEIGHTED_WINDOW_HH
# define MLN_CORE_CONCEPT_WEIGHTED_WINDOW_HH
-/*! \file mln/core/concept/weighted_window.hh
- *
- * \brief Definition of the concept of mln::Weighted_Window.
- */
+/// \file mln/core/concept/weighted_window.hh
+///
+/// Definition of the concept of mln::Weighted_Window.
+///
+/// \todo Make ::sym() be optional.
# include <mln/core/concept/object.hh>
# include <mln/core/concept/iterator.hh>
@@ -42,8 +43,9 @@
namespace mln
{
- // Fwd decl.
- template <typename W> struct Weighted_Window;
+ // Forward declaration.
+ template <typename E> struct Weighted_Window;
+
// Weighted_Window category flag type.
template <>
@@ -59,8 +61,8 @@
* \see mln::doc::Weighted_Window for a complete documentation of
* this class contents.
*/
- template <typename W>
- struct Weighted_Window : public Object<W>
+ template <typename E>
+ struct Weighted_Window : public Object<E>
{
typedef Weighted_Window<void> category;
@@ -74,29 +76,9 @@
typedef weight;
typedef window;
- E& sym();
+ void sym();
*/
- /// Test if the weighted window is empty; final method.
- bool is_empty() const
- {
- return exact(this)->win().is_empty();
- }
-
- /// Test if the weighted window is centered; final method.
- bool is_centered() const
- {
- return exact(this)->win().is_centered();
- }
-
- // FIXME: Remove because too ambiguous: bool is_symmetric() const
-
- /// Give the maximum coordinate gap.
- unsigned delta() const
- {
- return exact(this)->win().delta();
- }
-
protected:
Weighted_Window();
};
@@ -110,24 +92,27 @@
W operator-(const Weighted_Window<W>& rhs);
+
# ifndef MLN_INCLUDE_ONLY
- template <typename W>
+ template <typename E>
inline
- Weighted_Window<W>::Weighted_Window()
+ Weighted_Window<E>::Weighted_Window()
{
- //typedef mln_psite(E) point;
- //typedef mln_dpsite(E) dpoint;
- typedef mln_weight(W) weight;
- typedef mln_window(W) window;
+ typedef mln_site(E) site;
+ typedef mln_psite(E) psite;
+ typedef mln_dpsite(E) dpsite;
+
+ typedef mln_weight(E) weight;
+ typedef mln_window(E) window;
- typedef mln_fwd_qiter(W) fwd_qiter;
- typedef mln_bkd_qiter(W) bkd_qiter;
+ typedef mln_fwd_qiter(E) fwd_qiter;
+ typedef mln_bkd_qiter(E) bkd_qiter;
- void (W::*m1)() = & W::sym;
+ void (E::*m1)() = & E::sym;
m1 = 0;
- const window& (W::*m2)() const = & W::win;
+ const window& (E::*m2)() const = & E::win;
m2 = 0;
}
Index: mln/core/concept/object.hh
--- mln/core/concept/object.hh (revision 2767)
+++ mln/core/concept/object.hh (working copy)
@@ -47,6 +47,8 @@
# include <mln/metal/is_a.hh>
# include <mln/metal/is.hh>
# include <mln/metal/is_not.hh>
+# include <mln/metal/equal.hh>
+# include <mln/metal/not_equal.hh>
# include <mln/metal/converts_to.hh>
# include <mln/metal/ret.hh>
# include <mln/metal/unqualif.hh>
Index: mln/core/concept/window.hh
--- mln/core/concept/window.hh (revision 2767)
+++ mln/core/concept/window.hh (working copy)
@@ -38,8 +38,6 @@
*
* \todo The is_centered() method could also exist when the window is
* not regular...
- *
- * \todo Remove hack.
*/
# include <mln/core/concept/object.hh>
@@ -47,10 +45,7 @@
# include <mln/trait/windows.hh>
# include <mln/core/site_set/p_array.hh>
-
-# include <mln/accu/bbox.hh>
-# include <mln/literal/origin.hh>
-# include <mln/level/fill.hh>
+# include <mln/core/internal/geom_bbox.hh> // For use in convert::from_to.
# include <mln/convert/from_to.hxx>
@@ -307,27 +302,6 @@
namespace convert
{
- namespace internal
- {
-
-
- // FIXME: Hack to avoid including geom::bbox (circular
- // dependency).
-
- template <typename W>
- box<mln_psite(W)> bbox_(const Window<W>& win)
- {
- typedef mln_psite(W) P;
- accu::bbox<P> b;
- P O = literal::origin;
- mln_qiter(W) q(exact(win), O);
- for_all(q)
- b.take(q);
- return b;
- }
-
- }
-
template <typename W, typename I>
void
from_to(const Window<W>& win_, Image<I>& ima_)
@@ -343,9 +317,14 @@
// mln_precondition(win.is_valid());
mln_precondition(! ima.has_data());
- ima.init_(internal::bbox_(win)); // geom::bbox(win));
- level::fill(ima, false);
-
+ // Hack (below) to avoid circular dependency.
+ ima.init_(mln::internal::geom_bbox(win));
+ {
+ // level::fill(ima, false) is:
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ ima(p) = false;
+ }
unsigned n = win.size();
for (unsigned i = 0; i < n; ++i)
ima(convert::to<P>(win.dp(i))) = true;
Index: mln/core/internal/geom_bbox.hh
--- mln/core/internal/geom_bbox.hh (revision 0)
+++ mln/core/internal/geom_bbox.hh (revision 0)
@@ -0,0 +1,75 @@
+// Copyright (C) 2008 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_INTERNAL_GEOM_BBOX_HH
+# define MLN_CORE_INTERNAL_GEOM_BBOX_HH
+
+/// \file mln/core/internal/geom_bbox.hh
+///
+/// \internal Routine that computes a bounding box from a window.
+/// This file is included in mln/core/concept/window.hh and avoid
+/// circular dependency since mln/geom/bbox.hh cannot be included in
+/// concept files.
+
+# include <mln/accu/bbox.hh>
+# include <mln/literal/origin.hh>
+
+
+namespace mln
+{
+
+ namespace internal
+ {
+
+ template <typename W>
+ box<mln_psite(W)>
+ geom_bbox(const W& win);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename W>
+ box<mln_psite(W)>
+ geom_bbox(const W& win)
+ {
+ typedef mln_psite(W) P;
+ accu::bbox<P> b;
+ P O = literal::origin;
+ mln_qiter(W) q(exact(win), O);
+ for_all(q)
+ b.take(q);
+ return b;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::internal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_INTERNAL_GEOM_BBOX_HH
Index: mln/core/internal/weighted_window_base.hh
--- mln/core/internal/weighted_window_base.hh (revision 0)
+++ mln/core/internal/weighted_window_base.hh (revision 0)
@@ -0,0 +1,178 @@
+// Copyright (C) 2008 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_INTERNAL_WEIGHTED_WINDOW_BASE_HH
+# define MLN_CORE_INTERNAL_WEIGHTED_WINDOW_BASE_HH
+
+/// \file mln/core/internal/weighted_window_base.hh
+///
+/// Definition of a base class for weighted window classes.
+
+# include <mln/core/concept/weighted_window.hh>
+
+
+namespace mln
+{
+
+ namespace internal
+ {
+
+ /// Base class for weighted window classes.
+ ///
+ /// \p W is the corresponding window type.
+
+ template <typename W, typename E>
+ struct weighted_window_base : public Weighted_Window<E>
+ {
+
+ /// Window associated type.
+ typedef W window;
+
+ /// Dpsite associated type.
+ typedef mln_dpsite(W) dpsite;
+
+ /// Psite associated type.
+ typedef mln_psite(W) psite;
+
+ /// Site associated type.
+ typedef mln_site(W) site;
+
+ /// Test if the weighted window is empty; final method.
+ bool is_empty() const;
+
+ /// Give the window size; final method. This method is valid
+ /// iff the underlying window has a fixed size.
+ unsigned size() const;
+
+ /// Test if the weighted window is centered; final method. This
+ /// method is valid iff the support is regular and the
+ /// definition is not varying.
+ bool is_centered() const;
+
+ /// Give the maximum coordinate gap; final method. This method
+ /// is valid iff the support is regular and the definition is
+ /// not varying.
+ unsigned delta() const;
+
+ /// Give the \p i-th delta-point; final method. This method is
+ /// valid iff the support is regular and the definition is
+ /// unique.
+ const mln_dpsite(W)& dp(unsigned i) const;
+
+ /// Test if the \p dp delta-point is in this window; final
+ /// method. This method is valid iff the support is regular and
+ /// the definition is unique.
+ bool has(const mln_dpsite(W)& dp) const;
+
+ protected:
+ weighted_window_base();
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename W, typename E>
+ inline
+ weighted_window_base<W,E>::weighted_window_base()
+ {
+ }
+
+ template <typename W, typename E>
+ inline
+ bool
+ weighted_window_base<W,E>::is_empty() const
+ {
+ return exact(this)->win().is_empty();
+ }
+
+ template <typename W, typename E>
+ inline
+ unsigned
+ weighted_window_base<W,E>::size() const
+ {
+ mlc_equal(mln_trait_window_size(W),
+ trait::window::size::fixed)::check();
+ return exact(this)->win().size();
+ }
+
+ template <typename W, typename E>
+ inline
+ bool
+ weighted_window_base<W,E>::is_centered() const
+ {
+ mlc_equal(mln_trait_window_support(W),
+ trait::window::support::regular)::check();
+ mlc_not_equal(mln_trait_window_definition(W),
+ trait::window::definition::varying)::check();
+ return exact(this)->win().is_centered();
+ }
+
+ template <typename W, typename E>
+ inline
+ unsigned
+ weighted_window_base<W,E>::delta() const
+ {
+ mlc_equal(mln_trait_window_support(W),
+ trait::window::support::regular)::check();
+ mlc_not_equal(mln_trait_window_definition(W),
+ trait::window::definition::varying)::check();
+ return exact(this)->win().delta();
+ }
+
+ template <typename W, typename E>
+ inline
+ const mln_dpsite(W)&
+ weighted_window_base<W,E>::dp(unsigned i) const
+ {
+ mlc_equal(mln_trait_window_support(W),
+ trait::window::support::regular)::check();
+ mlc_equal(mln_trait_window_definition(W),
+ trait::window::definition::unique)::check();
+ mln_precondition(i < this->size());
+ return exact(this)->win().dp(i);
+ }
+
+ template <typename W, typename E>
+ inline
+ bool
+ weighted_window_base<W,E>::has(const mln_dpsite(W)& dp) const
+ {
+ mlc_equal(mln_trait_window_support(W),
+ trait::window::support::regular)::check();
+ mlc_equal(mln_trait_window_definition(W),
+ trait::window::definition::unique)::check();
+ return exact(this)->win().has(dp);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::internal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_INTERNAL_WEIGHTED_WINDOW_BASE_HH
Index: mln/core/internal/window_base.hh
--- mln/core/internal/window_base.hh (revision 2767)
+++ mln/core/internal/window_base.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
Index: mln/make/w_window2d.hh
--- mln/make/w_window2d.hh (revision 2767)
+++ mln/make/w_window2d.hh (working copy)
@@ -36,6 +36,7 @@
# include <mln/core/w_window.hh>
# include <mln/core/alias/dpoint2d.hh>
+# include <mln/convert/from_to.hxx>
namespace mln
Index: mln/convert/to_image.hh
--- mln/convert/to_image.hh (revision 2767)
+++ mln/convert/to_image.hh (working copy)
@@ -40,12 +40,13 @@
# include <mln/core/concept/weighted_window.hh>
# include <mln/core/concept/neighborhood.hh>
-# include <mln/literal/zero.hh>
# include <mln/geom/bbox.hh>
# include <mln/level/fill.hh>
# include <mln/histo/data.hh>
-
+# include <mln/core/image/image1d.hh>
+# include <mln/core/image/image2d.hh>
+# include <mln/core/image/image3d.hh>
namespace mln
@@ -68,7 +69,7 @@
/// Convert a weighted window \p w_win into an image.
template <typename W>
- mln_image_from_grid(mln_site(W)::grid, bool)
+ mln_image_from_grid(mln_site(W)::grid, mln_weight(W))
to_image(const Weighted_Window<W>& w_win);
/// Convert a neighborhood \p nbh into a binary image.
@@ -114,12 +115,12 @@
template <typename W>
inline
- mln_image_from_grid(mln_site(W)::grid, bool)
+ mln_image_from_grid(mln_site(W)::grid, mln_weight(W))
to_image(const Weighted_Window<W>& w_win)
{
mln_is_simple_window(W)::check();
// mln_precondition(exact(w_win).is_valid());
- mln_image_from_grid(mln_site(W)::grid, bool) tmp;
+ mln_image_from_grid(mln_site(W)::grid, mln_weight(W)) tmp;
convert::from_to(exact(w_win), tmp);
return tmp;
}