https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Start cleaning weighted windows and linear operators.
* mln/core/w_window.hh (trait): New
* mln/make/w_window.hh: Fix.
* tests/make/w_window.cc: New.
* tests/make/Makefile.am: Update.
* mln/trait/image_from_mesh.hh: Rename as...
* mln/trait/image_from_grid.hh: ...this.
(image_from_mesh, mln_image_from_mesh): Rename as...
(image_from_grid, mln_image_from_grid): ...these.
* mln/draw/label.hh,
* mln/trait/ch_value.hh,
* mln/display/color_pretty.hh,
* mln/display/remove.hh,
* mln/display/save.hh,
* mln/display/show.hh: Update.
* mln/border/resize.hh: Remove dead code.
* mln/convert/from_to.hxx: Disambiguate doc.
mln/border/resize.hh | 4 --
mln/convert/from_to.hxx | 2 -
mln/core/w_window.hh | 18 +++++++++--
mln/display/color_pretty.hh | 14 ++++----
mln/display/remove.hh | 2 -
mln/display/save.hh | 2 -
mln/display/show.hh | 2 -
mln/draw/label.hh | 6 +--
mln/make/w_window.hh | 17 ++++++++--
mln/trait/ch_value.hh | 6 +--
mln/trait/image_from_grid.hh | 14 ++++----
tests/make/Makefile.am | 4 +-
tests/make/w_window.cc | 68 +++++++++++++++++++++++++++++++++++++++++++
13 files changed, 123 insertions(+), 36 deletions(-)
Index: tests/make/w_window.cc
--- tests/make/w_window.cc (revision 0)
+++ tests/make/w_window.cc (revision 0)
@@ -0,0 +1,68 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/make/w_window.cc
+ *
+ * \brief Tests on mln::make::w_window.
+ *
+ * \todo Remove std::cout.
+ */
+
+#include <mln/core/alias/window2d.hh>
+// #include <mln/core/w_window.hh>
+#include <mln/core/alias/w_window2d_int.hh>
+
+
+struct test : mln::Function_p2v<test>
+{
+ typedef int result;
+ int operator()(const mln::point2d& p) const
+ {
+ return p.row() + p.col();
+ }
+};
+
+
+int main()
+{
+ using namespace mln;
+
+ bool vals[] = { 1, 1, 0, 0, 1,
+ 1, 1, 1, 1, 0,
+ 0, 1, 1, 1, 0,
+ 0, 1, 1, 1, 0,
+ 0, 1, 0, 0, 0 };
+ window2d win;
+ convert::from_to(vals, win);
+
+ w_window2d_int w_win = make::w_window(win, test());
+ std::cout << w_win << std::endl;
+
+
+// mln_assertion( count(ima, make::w_window(ima, c4(), c8()))
+// == c4().size() + c8().size() );
+}
Index: tests/make/Makefile.am
--- tests/make/Makefile.am (revision 2731)
+++ tests/make/Makefile.am (working copy)
@@ -4,9 +4,11 @@
check_PROGRAMS = \
dual_neighb \
- mat
+ mat \
+ w_window
dual_neighb_SOURCES = dual_neighb.cc
mat_SOURCES = mat.cc
+w_window_SOURCES = w_window.cc
TESTS = $(check_PROGRAMS)
Index: mln/trait/ch_value.hh
--- mln/trait/ch_value.hh (revision 2731)
+++ mln/trait/ch_value.hh (working copy)
@@ -34,7 +34,7 @@
*/
# include <mln/tag/skeleton.hh>
-# include <mln/trait/image_from_mesh.hh>
+# include <mln/trait/image_from_grid.hh>
# define mln_ch_value(I, V) typename mln::trait::ch_value< I, V >::ret
@@ -159,7 +159,7 @@
{
// FIXME: what about S::site having no grid?
typedef mln_deduce(S, site, grid) grid;
- typedef typename image_from_mesh< grid, V >::ret ret;
+ typedef typename image_from_grid< grid, V >::ret ret;
};
template < template <class, class> class M, typename T, typename S,
@@ -168,7 +168,7 @@
{
// FIXME: what about S::site having no grid?
typedef mln_deduce(S, site, grid) grid;
- typedef typename image_from_mesh< grid, V >::ret ret;
+ typedef typename image_from_grid< grid, V >::ret ret;
};
Index: mln/trait/image_from_grid.hh
--- mln/trait/image_from_grid.hh (revision 2730)
+++ mln/trait/image_from_grid.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,7 +28,7 @@
#ifndef MLN_TRAIT_IMAGE_FROM_MESH_HH
# define MLN_TRAIT_IMAGE_FROM_MESH_HH
-/*! \file mln/trait/image_from_mesh.hh
+/*! \file mln/trait/image_from_grid.hh
*
* \brief Definition of the "image from mesh" trait.
*/
@@ -36,7 +36,7 @@
# include <mln/core/grids.hh>
-# define mln_image_from_mesh(I, V) typename mln::trait::image_from_mesh< I, V
>::ret
+# define mln_image_from_grid(G, V) typename mln::trait::image_from_grid< G, V
>::ret
@@ -53,22 +53,22 @@
namespace trait
{
- template <typename M, typename V> struct image_from_mesh;
+ template <typename M, typename V> struct image_from_grid;
template <typename V>
- struct image_from_mesh< grid::tick, V >
+ struct image_from_grid< grid::tick, V >
{
typedef image1d<V> ret;
};
template <typename V>
- struct image_from_mesh< grid::square, V >
+ struct image_from_grid< grid::square, V >
{
typedef image2d<V> ret;
};
template <typename V>
- struct image_from_mesh< grid::cube, V >
+ struct image_from_grid< grid::cube, V >
{
typedef image3d<V> ret;
};
Index: mln/core/w_window.hh
--- mln/core/w_window.hh (revision 2731)
+++ mln/core/w_window.hh (working copy)
@@ -50,10 +50,22 @@
namespace mln
{
- // Fwd decl.
+ // Forward declarations.
+ template <typename D, typename W> struct w_window;
template <typename It, typename W> struct with_w_;
+ namespace trait
+ {
+
+ template <typename D, typename W>
+ struct window_< mln::w_window<D,W> > : window_<W>
+ {
+ // Same traits as its corresponding window.
+ };
+
+ } // end of namespace mln::trait
+
/*! \brief Generic w_window class.
*
@@ -64,7 +76,7 @@
template <typename D, typename W>
struct w_window : public Weighted_Window< w_window<D,W> >
{
- /// DPsite associated type.
+ /// Dpsite associated type.
typedef D dpsite;
/// Psite associated type.
@@ -338,7 +350,7 @@
{
ostr << '[';
for (unsigned i = 0; i < w_win.win().size(); ++i)
- ostr << w_win.vect()[i] << ':' << w_win.w(i) <<
' ';
+ ostr << w_win.dp(i) << ':' << w_win.w(i) << '
';
return ostr << ']';
}
Index: mln/draw/label.hh
--- mln/draw/label.hh (revision 2731)
+++ mln/draw/label.hh (working copy)
@@ -38,7 +38,7 @@
# include <mln/pw/image.hh>
# include <mln/pw/cst.hh>
-# include <mln/trait/image_from_mesh.hh>
+# include <mln/trait/image_from_grid.hh>
# include <mln/core/image/sub_image.hh>
# include <mln/value/rgb8.hh>
# include <mln/level/fill.hh>
@@ -64,14 +64,14 @@
*
*/
template <typename I>
- typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret
+ typename trait::image_from_grid < mln_mesh(I), value::rgb8 >::ret
label(Image<I>& input, const value::rgb8& background);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
- typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret
+ typename trait::image_from_grid < mln_mesh(I), value::rgb8 >::ret
label(Image<I>& input, const value::rgb8& background)
{
typedef mln_value(I) V;
Index: mln/border/resize.hh
--- mln/border/resize.hh (revision 2731)
+++ mln/border/resize.hh (working copy)
@@ -93,10 +93,6 @@
mln_concrete(I) memo = clone(ima);
ima.resize_(thickness);
level::fill(ima, memo);
- // level::paste(memo, ima);
-// mln_piter(I) p(ima.domain());
-// for_all(p)
-// ima(p) = memo(p);
}
// ext_domain: /any/
Index: mln/make/w_window.hh
--- mln/make/w_window.hh (revision 2731)
+++ mln/make/w_window.hh (working copy)
@@ -47,7 +47,7 @@
/*! \brief Create a mln::w_window from a window and a weight
* function.
*
- * \param[in] win The window.
+ * \param[in] win A simple window.
* \param[in] wei A weight function.
*
* \return A weighted window.
@@ -64,15 +64,24 @@
mln::w_window<mln_dpsite(W), mln_result(F)>
w_window(const Window<W>& win_, const Function_p2v<F>& wei_)
{
+ trace::entering("make::w_window");
+
+ mln_is_simple_window(W)::check();
+
const W& win = exact(win_);
const F& wei = exact(wei_);
mln_precondition(! win.is_empty());
+
typedef mln_dpsite(W) D;
- typedef mln_psite(D) P;
mln::w_window<D, mln_result(F)> w_win;
- mln_qiter(W) q(win, P::origin);
+
+ typedef mln_psite(D) P;
+ P O = literal::origin;
+ mln_qiter(W) q(win, O);
for_all(q)
- w_win.insert(wei(q), q - P::origin);
+ w_win.insert(wei(q), q - O);
+
+ trace::exiting("make::w_window");
return w_win;
}
Index: mln/convert/from_to.hxx
--- mln/convert/from_to.hxx (revision 2731)
+++ mln/convert/from_to.hxx (working copy)
@@ -133,7 +133,7 @@
void
from_to(const Proxy<P>& from, T& to);
- // Gpoint -> delta
+ // Gpoint -> delta-point
template <typename P>
void
from_to(const Gpoint<P>& from, mln_delta(P)& to);
Index: mln/display/color_pretty.hh
--- mln/display/color_pretty.hh (revision 2731)
+++ mln/display/color_pretty.hh (working copy)
@@ -34,7 +34,7 @@
* with red value for undefined point site.
*/
-# include <mln/trait/image_from_mesh.hh>
+# include <mln/trait/image_from_grid.hh>
# include <mln/core/image/image2d.hh>
# include <mln/value/rgb8.hh>
# include <mln/level/fill.hh>
@@ -62,7 +62,7 @@
*
*/
template <typename I>
- typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret
+ typename trait::image_from_grid < mln_mesh(I), value::rgb8 >::ret
color_pretty(const Image<I>& input_);
@@ -79,7 +79,7 @@
*
*/
template <typename I>
- typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret
+ typename trait::image_from_grid < mln_mesh(I), value::rgb8 >::ret
color_pretty_rgb(const Image<I>& input_,
const p_set<mln_psite(I) >& s1_,
const p_set<mln_psite(I) >& s2_,
@@ -116,7 +116,7 @@
template <typename I>
inline
- typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret
+ typename trait::image_from_grid < mln_mesh(I), value::rgb8 >::ret
color_pretty(const Image<I>& input_)
{
trace::entering("display::impl::color_pretty");
@@ -139,7 +139,7 @@
template <typename I>
inline
- typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret
+ typename trait::image_from_grid < mln_mesh(I), value::rgb8 >::ret
color_pretty_rgb(const Image<I>& input_,
const p_set<mln_psite(I) >& s1_,
const p_set<mln_psite(I) >& s2_,
@@ -185,7 +185,7 @@
template <typename I>
inline
- typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret
+ typename trait::image_from_grid < mln_mesh(I), value::rgb8 >::ret
color_pretty(const Image<I>& input_)
{
trace::entering("display::color_pretty");
@@ -204,7 +204,7 @@
template <typename I>
inline
- typename trait::image_from_mesh < mln_mesh(I), value::rgb8 >::ret
+ typename trait::image_from_grid < mln_mesh(I), value::rgb8 >::ret
color_pretty_rgb(const Image<I>& input_,
const p_set<mln_psite(I) >& s1_,
const p_set<mln_psite(I) >& s2_,
Index: mln/display/remove.hh
--- mln/display/remove.hh (revision 2731)
+++ mln/display/remove.hh (working copy)
@@ -34,7 +34,7 @@
*
*/
-# include <mln/trait/image_from_mesh.hh>
+# include <mln/trait/image_from_grid.hh>
# include <mln/core/image_if_value.hh>
# include <mln/core/image/image2d.hh>
# include <mln/display/save.hh>
Index: mln/display/save.hh
--- mln/display/save.hh (revision 2731)
+++ mln/display/save.hh (working copy)
@@ -34,7 +34,7 @@
* files.
*/
-# include <mln/trait/image_from_mesh.hh>
+# include <mln/trait/image_from_grid.hh>
# include <mln/core/image_if_value.hh>
# include <mln/core/image/image2d.hh>
# include <mln/value/rgb8.hh>
Index: mln/display/show.hh
--- mln/display/show.hh (revision 2731)
+++ mln/display/show.hh (working copy)
@@ -34,7 +34,7 @@
* given viewer (default display).
*/
-# include <mln/trait/image_from_mesh.hh>
+# include <mln/trait/image_from_grid.hh>
# include <mln/core/image_if_value.hh>
# include <mln/core/image/image2d.hh>
# include <mln/display/save.hh>