https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Clean-up and update pixel related material.
* tests/README: New.
* mln/core/trait: New.
* mln/core/trait/pixter.hh: New.
* mln/core/internal/pixel_impl.hh: New.
* mln/core/internal/fixme.hh: New.
* mln/core/concept/fast_image.hh: New.
* mln/core/concept/doc/fast_iterator.hh: Rename as...
* mln/core/concept/doc/pixel_iterator.hh: ...this new file.
Update.
* mln/core/concept/doc/fast_image.hh: New.
* mln/core/concept/doc/genpixel.hh: New.
* mln/core/tags.hh: New.
* mln/metal: New.
* mln/metal/none.hh: New.
* mln/core/internal/lineary_pixel_iterator_base.hh: Remove.
* mln/core/dpoints_piter.hh,
* mln/core/box_piter.hh,
* mln/core/internal/image_base.hh,
* mln/core/internal/piter_adaptor.hh,
* mln/core/concept/genpoint.hh,
* mln/core/concept/psite.hh,
* mln/core/concept/point.hh,
* mln/core/concept/doc/genpoint.hh (pointer): Rename as...
(pointer_): ...this.
* tests/window2d.cc: Cosmetic change.
* TODO: Update.
* mln/core/macros.hh (mln_ima): Remove.
(*ixter): Update.
(mln_piter, mln_qiter, mln_niter): Update.
* mln/core/psubset.hh (bkd_piter): Use fixme.
(npoints): Update.
* mln/core/box.hh (piter): Remove.
* mln/core/rectangle2d.hh (bkd_piter): Use fixme.
* mln/core/pixter2d_b.hh: Clean-up and update.
* mln/core/window.hh (bkd_piter): Use fixme.
* mln/core/dpoints_pixter.hh: Clean-up and update.
* mln/core/internal/pixel_iterator_base.hh: Clean-up and update.
* mln/core/internal/box_impl.hh: Touch doc.
* mln/core/internal/image_base.hh (dpoint, coord): New.
(pointer): Update.
* mln/core/pixel.hh: Clean-up and update.
* mln/core/hline2d.hh (bkd_piter): Use fixme.
* mln/core/concept/image.hh (piter): Remove.
(dpoint, coord): New.
* mln/core/concept/pixel_iterator.hh: Update.
* mln/core/concept/point_set.hh (piter): Remove.
* mln/core/concept/object.hh: New include.
* mln/core/concept/doc/image.hh: Update.
* mln/core/concept/doc/point_set.hh: Update.
* mln/core/concept/genpixel.hh: Clean-up and update.
* mln/core/vline2d.hh (bkd_piter): Use fixme.
* mln/core/image2d_b.hh: Clean-up and update.
(buffer): New.
(offset, point_at_offset): Fix.
* mln/level/fast_median.hh: Update.
* mln/level/median.hh: Prefer mln_coord to int.
* mln/canvas/sbrowsing.hh: Update doc.
* tests/fast_median.cc,
* tests/pixter_point2d.cc,
* tests/pixter_dpoint2d.cc,
* tests/pixel.cc: Update.
TODO | 55 +++++++--
mln/canvas/sbrowsing.hh | 18 ++-
mln/core/box.hh | 4
mln/core/box_piter.hh | 8 -
mln/core/concept/doc/fast_image.hh | 92 ++++++++++++++++
mln/core/concept/doc/genpixel.hh | 78 +++++++++++++
mln/core/concept/doc/genpoint.hh | 2
mln/core/concept/doc/image.hh | 17 +--
mln/core/concept/doc/pixel_iterator.hh | 24 ++--
mln/core/concept/doc/point_set.hh | 4
mln/core/concept/fast_image.hh | 96 +++++++++++++++++
mln/core/concept/genpixel.hh | 62 +----------
mln/core/concept/genpoint.hh | 7 -
mln/core/concept/image.hh | 8 +
mln/core/concept/object.hh | 1
mln/core/concept/pixel_iterator.hh | 32 ++---
mln/core/concept/point.hh | 4
mln/core/concept/point_set.hh | 4
mln/core/concept/psite.hh | 2
mln/core/dpoints_piter.hh | 8 -
mln/core/dpoints_pixter.hh | 104 +++++++++++-------
mln/core/hline2d.hh | 2
mln/core/image2d_b.hh | 128 +++++++++++++++++-----
mln/core/internal/box_impl.hh | 2
mln/core/internal/fixme.hh | 55 +++++++++
mln/core/internal/image_base.hh | 10 +
mln/core/internal/piter_adaptor.hh | 6 -
mln/core/internal/pixel_impl.hh | 174 ++++++++++++++++++-------------
mln/core/internal/pixel_iterator_base.hh | 135 ++++++------------------
mln/core/macros.hh | 50 +++++---
mln/core/pixel.hh | 104 +++++-------------
mln/core/pixter2d_b.hh | 75 ++++++-------
mln/core/psubset.hh | 7 -
mln/core/rectangle2d.hh | 2
mln/core/tags.hh | 50 ++++++++
mln/core/trait/pixter.hh | 111 +++++++++++++++++++
mln/core/vline2d.hh | 2
mln/core/window.hh | 2
mln/level/fast_median.hh | 19 +--
mln/level/median.hh | 11 +
mln/metal/none.hh | 57 ++++++++++
tests/README | 1
tests/fast_median.cc | 4
tests/pixel.cc | 7 -
tests/pixter_dpoint2d.cc | 84 ++++++++++----
tests/pixter_point2d.cc | 28 ++--
tests/window2d.cc | 3
47 files changed, 1177 insertions(+), 582 deletions(-)
Index: tests/window2d.cc
--- tests/window2d.cc (revision 1024)
+++ tests/window2d.cc (working copy)
@@ -42,12 +42,15 @@
using namespace mln;
window2d w;
+
mln_assertion(w.is_centered() = false);
mln_assertion(w.is_symmetric() = true);
w.insert(make::dpoint2d(-1,-1));
w.insert(make::dpoint2d( 1, 1));
+
image2d_b<bool> ima = convert::to_image(w);
debug::println(ima);
+
mln_assertion(w.delta() = 1);
}
Index: tests/README
--- tests/README (revision 0)
+++ tests/README (revision 0)
@@ -0,0 +1 @@
+g++-4.1 -I.. -ansi -pedantic -W -Wall -Wextra -Wconversion sample.cc
Index: tests/fast_median.cc
--- tests/fast_median.cc (revision 1024)
+++ tests/fast_median.cc (working copy)
@@ -55,7 +55,7 @@
p.row() = p.col() = 1;
{
- mln_qixter(I) qix(win, p, input);
+ mln_qixter(I, W) qix(input, win, p);
for_all(qix)
std::cout << *qix << ' ';
std::cout << " : " << qix.center_value() <<
std::endl;
@@ -63,7 +63,7 @@
{
pixel<I> pix(input, p);
- mln_qixter(I) qix(win, pix, input);
+ mln_qixter(I, W) qix(input, win, pix);
for_all(qix)
std::cout << *qix << ' ';
std::cout << " : " << qix.center_value() <<
std::endl;
Index: tests/pixter_point2d.cc
--- tests/pixter_point2d.cc (revision 1024)
+++ tests/pixter_point2d.cc (working copy)
@@ -34,31 +34,29 @@
{
using namespace mln;
- image2d_b<int> ima(20, 20);
+ typedef image2d_b<int> I;
+ I ima(20, 20);
- image2d_b<int>::piter p(ima.domain());
- image2d_b<int>::pixter f(ima);
+ mln_piter_(I) p(ima.domain());
+
+ mln_pixter_(I) pix(ima);
int i = 0;
for_all(p)
- {
ima(p) = i++;
- }
i = 0;
- for_all(f)
+ for_all(pix)
{
- assert(*f = i ++);
- *f = 5;
+ mln_assertion(*pix = i ++);
+ *pix = 5;
}
for_all(p)
- {
- assert(ima(p) = 5);
- }
+ mln_assertion(ima(p) = 5);
- f.start();
- assert(f.is_valid());
- f.invalidate();
- assert(!f.is_valid());
+ pix.start();
+ mln_assertion(pix.is_valid());
+ pix.invalidate();
+ mln_assertion(! pix.is_valid());
}
Index: tests/pixter_dpoint2d.cc
--- tests/pixter_dpoint2d.cc (revision 1024)
+++ tests/pixter_dpoint2d.cc (working copy)
@@ -1,37 +1,73 @@
+// 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/pixter_dpoint2d.cc
+ *
+ * \brief Test on mln::dpoints_fwd_pixter.
+ */
+
#include <cassert>
#include <iostream>
+
#include <mln/core/image2d_b.hh>
#include <mln/core/window.hh>
-#include <mln/level/fill.hh>
#include <mln/core/dpoints_pixter.hh>
-int
-main()
+#include <mln/level/fill.hh>
+
+
+int main()
{
using namespace mln;
- typedef image2d_b<int> I;
+ typedef image2d_b<int> I;
+ typedef I::dpoint D;
+ typedef window_<D> W;
- I ima(20, 20);
- level::fill(ima, 5);
- I::piter f(ima.domain());
- window_<I::dpoint> set;
-
- set.insert(make::dpoint2d(0, -1));
- set.insert(make::dpoint2d(0, -1));
- set.insert(make::dpoint2d(1, 0));
- set.insert(make::dpoint2d(1, 0));
+ typedef dpoints_fwd_pixter<I> qixter;
- for_all(f)
- {
- if (f[0] > 0 && f[1] > 0 && f[0] < 19 && f[1] <
19)
- {
- I::qixter dit(set, f, ima);
+ const unsigned size = 20;
+ I ima(size, size);
- for_all(dit)
- {
- assert(*dit = 5);
- }
- }
- }
+ const int value = 51;
+ level::fill(ima, value);
+
+ W win;
+ win
+ .insert(make::dpoint2d(0, -1))
+ .insert(make::dpoint2d(0, -1))
+ .insert(make::dpoint2d(1, 0))
+ .insert(make::dpoint2d(1, 0));
+
+ mln_piter_(I) p(ima.domain());
+ qixter qix(ima, win, p);
+
+ for_all(p)
+ if (p[0] > 0 && p[1] > 0 && p[0] < size - 1 && p[1]
< size - 1)
+ for_all(qix)
+ mln_assertion(*qix = value);
}
Index: tests/pixel.cc
--- tests/pixel.cc (revision 1024)
+++ tests/pixel.cc (working copy)
@@ -42,15 +42,13 @@
I ima(3, 3);
{
- pixel<I> pxl(ima);
- pxl.site() = make::point2d(1, 1);
+ pixel<I> pxl(ima, make::point2d(1, 1));
*pxl = 51;
mln_assertion(ima.at(1,1) = 51);
}
{
- pixel<const I> pxl(ima);
- pxl.site() = make::point2d(1, 1);
+ pixel<const I> pxl(ima, make::point2d(1, 1));
ima.at(1,1) = 51;
mln_assertion(*pxl = 51);
@@ -58,4 +56,5 @@
// *pxl = 0;
// assignment of read-only location
}
+
}
Index: TODO
--- TODO (revision 1024)
+++ TODO (working copy)
@@ -1,25 +1,54 @@
-*- outline -*-
-* compilation
+* large changes
-g++-4.1 -I.. int_u8.cc -Wall -Wextra -Wconversion
+introduce grids
-* value
+* adds-on
-Value_Set
-props { ... }
-notion of lowq
-+ values() : vset dans Image ?
+** abstractions
+Function_i2i
+Weighted_Window
-* function
+** types
-Function_p2v
-Function_p2b
-Function_v2w
+value::proxy to dispatch read/write + the corresponding image type
+a mean_value object { sum; count } and operator+
+value_cast<T>(image)
+t_image to "transpose" the 0 and the i-th coordinates
+image defined by f/pset
-F apply(I, F)
-O transform(I, F)
+** extensions
+in Fast_Image: memcpy and memset-like methods (?)
+.offset() into GenPixel
+notion of low-quantization
+vset and .values() in Image
+built-in op objects -> reverse lhs/rhs
+
+
+* renaming
+
+GenPixel, GenPoint, Psite, Piter: longer name (?)
+mlc into metal
+point-wise material: pw::value_of, pw::constant, and pw::variable
+kind-related: mln_value_kind(I) and mln_kind(V)
+
+
+* clean-up
+
+accu::histo and median: remove inheritance
+
+
+* processing routines
+
+reconstructions + their canvases
+fast versions of level::fill and level::paste
+histogram class
+sorting points w.r.t. their value (array of offsets, psites, points)
+border::* and no-op versions if not fast image
+arith::inplace_plus et al.
+linear:: for convolutions
Index: mln/core/dpoints_piter.hh
--- mln/core/dpoints_piter.hh (revision 1024)
+++ mln/core/dpoints_piter.hh (working copy)
@@ -78,7 +78,7 @@
operator mln_point(D) () const;
/// Address of the point this iterator designates.
- const point* pointer() const;
+ const point* pointer_() const;
/// Test the iterator validity.
bool is_valid() const;
@@ -108,7 +108,7 @@
unsigned i_;
point p_; // location of this iterator; p_ makes this iterator be
- // itself a potential center point (Cf. the pointer() method).
+ // itself a potential center point (Cf. the pointer_() method).
};
@@ -119,7 +119,7 @@
dpoints_fwd_piter<D>::dpoints_fwd_piter(const Dps& dps,
const GenPoint<Pref>& p_ref)
: dps_(exact(dps).vec()),
- p_ref_(* internal::force_exact<Pref>(p_ref).pointer())
+ p_ref_(* internal::force_exact<Pref>(p_ref).pointer_())
{
invalidate();
}
@@ -133,7 +133,7 @@
template <typename D>
const mln_point(D)*
- dpoints_fwd_piter<D>::pointer() const
+ dpoints_fwd_piter<D>::pointer_() const
{
return & p_;
}
Index: mln/core/macros.hh
--- mln/core/macros.hh (revision 1024)
+++ mln/core/macros.hh (working copy)
@@ -81,29 +81,20 @@
/// Shortcut to access the fwd_piter type associated to T.
# define mln_fwd_piter(T) typename T::fwd_piter
-/// Shortcut to access the fwd_pixter type associated to T.
-# define mln_fwd_pixter(T) typename T::fwd_pixter
-
/// Shortcut to access the bkd_piter type associated to T.
# define mln_bkd_piter(T) typename T::bkd_piter
/// Shortcut to access the fwd_qiter type associated to T.
# define mln_fwd_qiter(T) typename T::fwd_qiter
-/// Shortcut to access the fwd_qixter type associated to T.
-# define mln_fwd_qixter(T) typename T::fwd_qixter
-
/// Shortcut to access the fwd_viter type associated to T.
# define mln_fwd_viter(T) typename T::fwd_viter
// i
-/// Shortcut to access the fwd_viter type associated to T.
+/// Shortcut to access the image type associated to T.
# define mln_image(T) typename T::image
-/// Shortcut to access the fwd_viter type associated to T.
-# define mln_ima(T) typename T::ima
-
// l
@@ -115,10 +106,8 @@
// p
/// Shortcut to access the piter type associated to T.
-# define mln_piter(T) typename T::piter
-
-/// Shortcut to access the pixter type associated to T.
-# define mln_pixter(T) typename T::pixter
+# define mln_piter(T) typename T::fwd_piter
+# define mln_piter_(T) T::fwd_piter
/// Shortcut to access the pset type associated to T.
# define mln_pset(T) typename T::pset
@@ -133,16 +122,13 @@
// q
/// Shortcut to access the qiter type associated to T.
-# define mln_qiter(T) typename T::qiter
-
-// Shortcut to access to the qixter type associated to T
-# define mln_qixter(T) typename T::qixter
+# define mln_qiter(T) typename T::fwd_qiter
// n
/// Shortcut to access the niter type associated to T.
-# define mln_niter(T) typename T::niter
+# define mln_niter(T) typename T::fwd_niter
// r
@@ -160,7 +146,9 @@
# define mln_value(T) typename T::value
/// Shortcut to access the viter type associated to T.
-# define mln_viter(T) typename T::viter
+# define mln_viter(T) typename T::fwd_viter
+
+
@@ -172,4 +160,26 @@
# define mln_ch_value(I, T) typename I::template change_value<T>::ret
+
+// FIXME: Doc!
+
+# define mln_fwd_pixter(I) typename mln::trait::fwd_pixter<I>::ret
+# define mln_fwd_pixter_(I) mln::trait::fwd_pixter<I>::ret
+
+# define mln_bkd_pixter(I) typename mln::trait::bkd_pixter<I>::ret
+# define mln_pixter(I) mln_fwd_pixter(I)
+# define mln_pixter_(I) mln_fwd_pixter_(I)
+
+
+# define mln_fwd_qixter(I, W) typename mln::trait::fwd_qixter<I, W>::ret
+# define mln_bkd_qixter(I, W) typename mln::trait::bkd_qixter<I, W>::ret
+# define mln_qixter(I, W) mln_fwd_qixter(I, W)
+
+
+# define mln_fwd_nixter(I, N) typename mln::trait::fwd_nixter<I, N>::ret
+# define mln_bkd_nixter(I, N) typename mln::trait::bkd_nixter<I, N>::ret
+# define mln_nixter(I, N) mln_fwd_nixter(I, N)
+
+
+
#endif // ! MLN_CORE_MACROS_HH
Index: mln/core/trait/pixter.hh
--- mln/core/trait/pixter.hh (revision 0)
+++ mln/core/trait/pixter.hh (revision 0)
@@ -0,0 +1,111 @@
+// 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_TRAIT_PIXTER_HH
+# define MLN_CORE_TRAIT_PIXTER_HH
+
+/*! \file mln/core/trait/pixter.hh
+ *
+ * \brief Definition of some traits over image types.
+ */
+
+# include <mln/metal/none.hh>
+
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+
+ // pixter
+
+ template <typename I>
+ struct fwd_pixter
+ {
+ typedef metal::none ret;
+ };
+
+ template <typename I>
+ struct bkd_pixter
+ {
+ typedef metal::none ret;
+ };
+
+ template <typename I>
+ struct pixter : fwd_pixter<I>
+ {
+ };
+
+
+ // qixter
+
+ template <typename I, typename W>
+ struct fwd_qixter
+ {
+ typedef metal::none ret;
+ };
+
+ template <typename I, typename W>
+ struct bkd_qixter
+ {
+ typedef metal::none ret;
+ };
+
+ template <typename I, typename W>
+ struct qixter : fwd_qixter<I, W>
+ {
+ };
+
+
+ // nixter
+
+ template <typename I, typename N>
+ struct fwd_nixter
+ {
+ typedef metal::none ret;
+ };
+
+ template <typename I, typename N>
+ struct bkd_nixter
+ {
+ typedef metal::none ret;
+ };
+
+ template <typename I, typename N>
+ struct nixter : fwd_nixter<I, N>
+ {
+ };
+
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_TRAIT_PIXTER_HH
Index: mln/core/psubset.hh
--- mln/core/psubset.hh (revision 1024)
+++ mln/core/psubset.hh (working copy)
@@ -78,10 +78,7 @@
typedef psubset_fwd_piter_<S,F> fwd_piter;
/// Backward Piter associated type.
- typedef psubset_fwd_piter_<S,F> bkd_piter; // FIXME: bkd!!!
-
- /// Piter associated type.
- typedef fwd_piter piter;
+ typedef internal::fixme bkd_piter;
/// Constructor without argument.
@@ -180,7 +177,7 @@
psubset<S,F>::npoints() const
{
std::size_t n = 0;
- piter p(*this);
+ fwd_piter p(*this);
for_all(p)
++n;
return n;
Index: mln/core/box.hh
--- mln/core/box.hh (revision 1024)
+++ mln/core/box.hh (working copy)
@@ -70,10 +70,6 @@
*/
typedef box_bkd_piter_<P> bkd_piter;
- /*! \brief Piter associated type.
- */
- typedef fwd_piter piter;
-
/*! \brief Minimum point.
*/
P pmin() const;
Index: mln/core/rectangle2d.hh
--- mln/core/rectangle2d.hh (revision 1024)
+++ mln/core/rectangle2d.hh (working copy)
@@ -70,7 +70,7 @@
/*! \brief Piter type to browse a rectangle such as: "for each row
* (decreasing), for each column (decreasing)."
*/
- typedef dpoints_fwd_piter<dpoint2d> bkd_qiter; // FIXME: bkd!!!
+ typedef internal::fixme bkd_qiter;
/*! \brief Same as fwd_qiter.
*/
Index: mln/core/box_piter.hh
--- mln/core/box_piter.hh (revision 1024)
+++ mln/core/box_piter.hh (working copy)
@@ -76,7 +76,7 @@
operator P() const;
/// Address of the point.
- const P* pointer() const;
+ const P* pointer_() const;
/// Give the i-th coordinate.
coord operator[](unsigned i) const;
@@ -136,7 +136,7 @@
operator P() const;
/// Address of the point.
- const P* pointer() const;
+ const P* pointer_() const;
/// Give the i-th coordinate.
coord operator[](unsigned i) const;
@@ -183,7 +183,7 @@
template <typename P>
const P*
- box_fwd_piter_<P>::pointer() const
+ box_fwd_piter_<P>::pointer_() const
{
return & p_;
}
@@ -254,7 +254,7 @@
template <typename P>
const P*
- box_bkd_piter_<P>::pointer() const
+ box_bkd_piter_<P>::pointer_() const
{
return & p_;
}
Index: mln/core/pixter2d_b.hh
--- mln/core/pixter2d_b.hh (revision 1024)
+++ mln/core/pixter2d_b.hh (working copy)
@@ -28,80 +28,77 @@
#ifndef MLN_CORE_PIXTER2D_B_HH
# define MLN_CORE_PIXTER2D_B_HH
-# include <mln/core/internal/lineary_pixel_iterator_base.hh>
-# include <mln/core/point2d.hh>
-# include <iostream>
-
-
-//FIXME comment
/*! \file mln/core/pixter2d_b.hh
*
* \brief Pixel iterator class on a image 2d with border.
*/
+# include <mln/core/internal/pixel_iterator_base.hh>
+# include <mln/core/point2d.hh>
+
namespace mln
{
- // Forward declaration
- template <typename T> class image2d_b;
-
- template <typename T>
- class fwd_pixter2d_b :
- public internal::lineary_pixel_iterator_base_<image2d_b<T>,
fwd_pixter2d_b<T> >
+ template <typename I>
+ class fwd_pixter2d_b : public internal::pixel_iterator_base_< I,
fwd_pixter2d_b<I> >
{
- typedef internal::lineary_pixel_iterator_base_<image2d_b<T>,
fwd_pixter2d_b<T> > super;
+ typedef internal::pixel_iterator_base_< I, fwd_pixter2d_b<I> > super_;
+ typedef mln_value(super_) value_;
public:
- /// Image pixel value type.
- typedef mln_value(image2d_b<T>) value;
/*! \brief Constructor.
*
- * \param[in] ima Image to iterate.
+ * \param[in] image Image to iterate over its pixels.
*/
- fwd_pixter2d_b(image2d_b<T>& image);
- /// Move the iterator on the next element.
+ fwd_pixter2d_b(I& image);
+
+ /// Go to the next pixel.
void next_();
private:
- /// Size of the image border.
- unsigned border_size_;
+
+ /// Twice the size of the image border.
+ unsigned border_x2_;
+
/// Row offset.
unsigned row_offset_;
- /// End of a row.
- value *eor_;
+
+ /// End of the current row.
+ value_* eor_;
};
+
+ // FIXME: bkd_pixter2d_b
+
+
#ifndef MLN_INCLUDE_ONLY
- template <typename T>
- fwd_pixter2d_b<T>::fwd_pixter2d_b(image2d_b<T>& image) :
- super(image),
- border_size_(image.border()),
- row_offset_((image.domain().pmax()[1] - image.domain().pmin()[1])
- + 2 * border_size_ + 1)
+ template <typename I>
+ fwd_pixter2d_b<I>::fwd_pixter2d_b(I& image) :
+ super_(image)
{
- this->start_ = &image(image.domain().pmin());
- this->eor_ = &image(make::point2d(image.domain().pmin()[0],
image.domain().pmax()[1])) + 1;
- this->eoi_ = &image(image.domain().pmax()) + 1;
+ mln_precondition(image.has_data());
+ border_x2_ = 2 * image.border();
+ row_offset_ = image.max_col() - image.min_col() + 1 + border_x2_;
+ eor_ = & image.at(image.min_row(), image.max_col()) + 1;
}
- template <typename T>
- void fwd_pixter2d_b<T>::next_()
+ template <typename I>
+ void
+ fwd_pixter2d_b<I>::next_()
{
- ++(this->value_ptr_);
-
- if (this->value_ptr_ = this->eor_ && this->value_ptr_ !=
this->eoi_)
+ ++this->value_ptr_;
+ if (this->value_ptr_ = eor_ && this->value_ptr_ != this->eoi_)
{
- this->value_ptr_ += 2 * this->border_size_;
- this->eor_ += this->row_offset_;
+ this->value_ptr_ += border_x2_;
+ eor_ += row_offset_;
}
}
#endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln
#endif // ! MLN_CORE_PIXTER2D_B_HH
Index: mln/core/window.hh
--- mln/core/window.hh (revision 1024)
+++ mln/core/window.hh (working copy)
@@ -75,7 +75,7 @@
/*! \brief Piter type to browse the points of a generic window
* w.r.t. the reverse ordering of delta-points.
*/
- typedef dpoints_bkd_piter<D> bkd_qiter;
+ typedef internal::fixme bkd_qiter;
/*! \brief Same as fwd_qiter.
*/
Index: mln/core/dpoints_pixter.hh
--- mln/core/dpoints_pixter.hh (revision 1024)
+++ mln/core/dpoints_pixter.hh (working copy)
@@ -28,47 +28,60 @@
#ifndef MLN_CORE_DPOINTS_PIXTER_HH
# define MLN_CORE_DPOINTS_PIXTER_HH
+/*! \file mln/core/dpoints_pixter.hh
+ *
+ * \brief Definition of mln::dpoints_fwd_pixter and
+ * mln::dpoints_bkd_pixter.
+ */
+
# include <cassert>
# include <vector>
-# include <mln/core/internal/pixel_iterator_base.hh>
+
+# include <mln/core/concept/pixel_iterator.hh>
+# include <mln/core/concept/genpixel.hh>
+# include <mln/core/internal/pixel_impl.hh>
+
namespace mln
{
- /*! \brief A generic forward iterator on image pixel of a windows and of
+ /*! \brief A generic forward iterator on pixels of windows and of
* neighborhoods.
*
* The parameter \c I is the image type.
*/
template <typename I>
- class dpoints_pixter : public internal::pixel_iterator_base_< I,
dpoints_pixter<I> >
+ class dpoints_fwd_pixter : public Pixel_Iterator< dpoints_fwd_pixter<I> >,
+ public internal::pixel_impl_< I, dpoints_fwd_pixter<I> >
{
- typedef typename internal::pixel_iterator_base_< I, dpoints_pixter<I> >
super;
+ typedef typename internal::pixel_impl_< I, dpoints_fwd_pixter<I> >
super;
public:
- /// Image pixel value
- typedef mln_value(I) value;
- /// Image pixel rvalue
- typedef mln_rvalue(I) rvalue;
- /// Image pixel lvalue
- typedef mln_lvalue(I) lvalue;
+ /// Using super value type.
+ typedef mln_value(super) value;
/*! \brief Constructor.
*
- * \param[in] dps Object that can provide an array of delta-points.
- * \param[in] p_ref Center point to iterate around.
- * \param[in] ima Image to iterate.
+ * \param[in] image Image subject to iteration.
+ * \param[in] dps Object that can provide a set of delta-points.
+ * \param[in] p_ref Center (generalized) point to iterate around.
*/
template <typename Dps, typename Pref>
- dpoints_pixter(const Dps& dps,
- const GenPoint<Pref>& p_ref,
- I& image);
+ dpoints_fwd_pixter(I& image,
+ const Dps& dps,
+ const GenPoint<Pref>& p_ref);
+ /*! \brief Constructor.
+ *
+ * \param[in] image Image subject to iteration.
+ * \param[in] dps Object that can provide a set of delta-points.
+ * \param[in] p_ref Center (generalized) pixel to iterate around.
+ */
template <typename Dps, typename Pref>
- dpoints_pixter(const Dps& dps,
- const GenPixel<Pref>& p_ref,
- I& image);
+ dpoints_fwd_pixter(I& image,
+ const Dps& dps,
+ const GenPixel<Pref>& p_ref);
/// Start an iteration.
void start();
@@ -87,7 +100,7 @@
void update();
/// The value around which this iterator moves.
- const value& center_value() const;
+ const mln_value(I)& center_value() const;
private:
@@ -95,7 +108,7 @@
std::vector<int> offset_;
/// current offset
- int i_;
+ unsigned i_;
/// reference pixel / point in the image
value** value_ref_;
@@ -108,16 +121,24 @@
};
+ // FIXME: dpoints_bkd_pixter<I>
+
+
+
#ifndef MLN_INCLUDE_ONLY
+
+ // dpoints_fwd_pixter<I>
+
template <typename I>
template <typename Dps, typename Pref>
- dpoints_pixter<I>::dpoints_pixter(const Dps& dps,
- const GenPoint<Pref>& p_ref,
- I& image)
+ dpoints_fwd_pixter<I>::dpoints_fwd_pixter(I& image,
+ const Dps& dps,
+ const GenPoint<Pref>& p_ref)
: super(image)
{
- p_ref_ = internal::force_exact<Pref>(p_ref).pointer();
+ mln_precondition(image.has_data());
+ p_ref_ = internal::force_exact<Pref>(p_ref).pointer_();
value_ref_ = 0;
init_(dps);
}
@@ -125,19 +146,20 @@
template <typename I>
template <typename Dps, typename Pref>
- dpoints_pixter<I>::dpoints_pixter(const Dps& dps,
- const GenPixel<Pref>& p_ref,
- I& image)
+ dpoints_fwd_pixter<I>::dpoints_fwd_pixter(I& image,
+ const Dps& dps,
+ const GenPixel<Pref>& p_ref)
: super(image)
{
+ mln_precondition(image.has_data());
p_ref_ = 0;
- value_ref_ = internal::force_exact<Pref>(p_ref).address();
+ value_ref_ = internal::force_exact<Pref>(p_ref).address_();
init_(dps);
}
template <typename I>
const mln_value(I)&
- dpoints_pixter<I>::center_value() const
+ dpoints_fwd_pixter<I>::center_value() const
{
mln_invariant(value_ref_ != 0 || p_ref_ != 0);
if (p_ref_)
@@ -149,21 +171,21 @@
template <typename I>
template <typename Dps>
void
- dpoints_pixter<I>::init_(const Dps& dps)
+ dpoints_fwd_pixter<I>::init_(const Dps& dps)
{
for (unsigned i = 0; i < dps.nelements(); ++i)
offset_.push_back(this->image_.offset(dps.element(i)));
-
+ // offset_[0] is absolute
+ // other offsets are relative:
if (dps.nelements() > 1)
for (unsigned i = dps.nelements() - 1; i > 0; --i)
offset_[i] -= offset_[i - 1];
-
- // offset_[0] is absolute; other offsets are relative.
invalidate();
}
template <typename I>
- void dpoints_pixter<I>::update()
+ void
+ dpoints_fwd_pixter<I>::update()
{
if (is_valid())
{
@@ -175,27 +197,31 @@
}
template <typename I>
- void dpoints_pixter<I>::start()
+ void
+ dpoints_fwd_pixter<I>::start()
{
i_ = 0;
update();
}
template <typename I>
- void dpoints_pixter<I>::next_()
+ void
+ dpoints_fwd_pixter<I>::next_()
{
++i_;
this->value_ptr_ += offset_[i_];
}
template <typename I>
- bool dpoints_pixter<I>::is_valid() const
+ bool
+ dpoints_fwd_pixter<I>::is_valid() const
{
return i_ != offset_.size();
}
template <typename I>
- void dpoints_pixter<I>::invalidate()
+ void
+ dpoints_fwd_pixter<I>::invalidate()
{
i_ = offset_.size();
}
Index: mln/core/internal/pixel_impl.hh
--- mln/core/internal/pixel_impl.hh (revision 1024)
+++ mln/core/internal/pixel_impl.hh (working copy)
@@ -25,15 +25,16 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_INTERNAL_PIXEL_ITERATOR_BASE_HH
-# define MLN_CORE_INTERNAL_PIXEL_ITERATOR_BASE_HH
+#ifndef MLN_CORE_INTERNAL_PIXEL_IMPL_HH
+# define MLN_CORE_INTERNAL_PIXEL_IMPL_HH
-/*! \file mln/core/internal/pixel_iterator_base.hh
+/*! \file mln/core/internal/pixel_impl.hh
*
- * \brief Base class for Pixel_Iterator concept implementation classes.
+ * \brief Define a couple of implementation classes to provide methods
+ * to classes of generalized pixels.
*/
-# include <mln/core/concept/pixel_iterator.hh>
+# include <mln/core/internal/force_exact.hh>
namespace mln
@@ -42,11 +43,13 @@
namespace internal
{
- /*! \brief pixel_iterator_base_ class
+ /*! \brief Implementation class to equip generalized pixel
+ * classes based on mutable images.
*
+ * \internal
*/
template <typename I, typename E>
- class pixel_iterator_base_ : public Pixel_Iterator<E>
+ class pixel_impl_
{
public:
@@ -68,111 +71,138 @@
/// Address of the current iterator value/pixel.
- value** address() const;
+ value** address_() const;
+ protected:
- // FIXME: Inactivated:
+ /// Image associated to the iterator
+ I& image_;
-// /// I type.
-// typedef I ima;
+ /// Current pixel / value
+ value* value_ptr_;
-// /// Image psite type.
-// typedef mln_psite(I) psite;
+ /// Constructor
+ pixel_impl_(I& image);
-// /// Get the image associated to the current pixel iterator.
-// const ima& image() const;
+ private:
+ bool is_valid_() const;
+ };
-// /// psite associated to the iterator.
-// const psite& site() const;
-// /// psite associated to the iterator.
-// psite& site();
+ /*! \brief Implementation class to equip generalized pixel
+ * classes based on constant images.
+ *
+ * \internal
+ */
+ template <typename I, typename E>
+ class pixel_impl_< const I, E >
+ {
+ public:
-// /// Address of the current iterator value/pixel.
-// value* address();
+ /// Image value type.
+ typedef mln_value(I) value;
+
+ /// Image rvalue type.
+ typedef mln_rvalue(I) rvalue;
+
+
+ /// Get the pixel iterator value.
+ rvalue operator*() const;
+
+
+ /// Address of the current iterator value/pixel.
+ value** address_() const;
protected:
/// Image associated to the iterator
- I& image_;
+ const I& image_;
/// Current pixel / value
- value* value_ptr_;
-
- // FIXME: Inactivated:
+ const value* value_ptr_;
-// /// Psite of the pixel
-// psite p_;
+ /// Constructor
+ pixel_impl_(const I& image);
- pixel_iterator_base_(I& image);
+ private:
+ bool is_valid_() const;
};
+
#ifndef MLN_INCLUDE_ONLY
+ // pixel_impl_<I, E>
+
template <typename I, typename E>
- pixel_iterator_base_<I, E>::pixel_iterator_base_(I& image) :
+ bool
+ pixel_impl_<I, E>::is_valid_() const
+ {
+ return value_ptr_ != 0 &&
internal::force_exact<E>(*this).is_valid();
+ }
+
+ template <typename I, typename E>
+ pixel_impl_<I, E>::pixel_impl_(I& image) :
image_(image),
value_ptr_(0)
{
}
-// template <typename I, typename E>
-// const typename pixel_iterator_base_<I, E>::ima&
-// pixel_iterator_base_<I, E>::image() const
-// {
-// return ima_;
-// }
-
template <typename I, typename E>
mln_lvalue(I)
- pixel_iterator_base_<I, E>::operator* ()
+ pixel_impl_<I, E>::operator*()
+ {
+ mln_precondition(is_valid_());
+ return *value_ptr_;
+ }
+
+ template <typename I, typename E>
+ mln_rvalue(I)
+ pixel_impl_<I, E>::operator*() const
{
- mln_precondition(exact(this)->is_valid());
- mln_precondition(value_ptr_ != 0);
+ mln_precondition(is_valid_());
return *value_ptr_;
}
template <typename I, typename E>
+ mln_value(I) **
+ pixel_impl_<I, E>::address_() const
+ {
+ mln_precondition(is_valid_());
+ return (value**)(& this->value_ptr_);
+ }
+
+
+ // pixel_impl_<const I, E>
+
+ template <typename I, typename E>
+ bool
+ pixel_impl_<const I, E>::is_valid_() const
+ {
+ return value_ptr_ != 0 &&
internal::force_exact<E>(*this).is_valid();
+ }
+
+ template <typename I, typename E>
+ pixel_impl_<const I, E>::pixel_impl_(const I& image) :
+ image_(image),
+ value_ptr_(0)
+ {
+ }
+
+ template <typename I, typename E>
mln_rvalue(I)
- pixel_iterator_base_<I, E>::operator* () const
+ pixel_impl_<const I, E>::operator*() const
{
- mln_precondition(exact(this)->is_valid());
- mln_precondition(value_ptr_ != 0);
+ mln_precondition(is_valid_());
return *value_ptr_;
}
template <typename I, typename E>
mln_value(I) **
- pixel_iterator_base_<I, E>::address() const
+ pixel_impl_<const I, E>::address_() const
{
- mln_precondition(exact(this)->is_valid());
- mln_precondition(value_ptr_ != 0);
- return & (mln_value(I)*)(value_ptr_);
- }
-
-// template <typename I, typename E>
-// mln_value(I)*
-// pixel_iterator_base_<I, E>::address()
-// {
-// mln_precondition(exact(this)->is_valid());
-// return value_ptr_;
-// }
-
-// template <typename I, typename E>
-// const typename pixel_iterator_base_<I, E>::psite&
-// pixel_iterator_base_<I, E>::site() const
-// {
-// //FIXME: update psite
-// return p_;
-// }
-
-// template <typename I, typename E>
-// typename pixel_iterator_base_<I, E>::psite&
-// pixel_iterator_base_<I, E>::site()
-// {
-// //FIXME: update psite
-// return p_;
-// }
+ mln_precondition(is_valid_());
+ return (value**)(& this->value_ptr_);
+ }
#endif // ! MLN_INCLUDE_ONLY
@@ -181,4 +211,4 @@
} // end of namespace mln
-#endif // ! MLN_CORE_INTERNAL_PIXEL_ITERATOR_BASE_HH
+#endif // ! MLN_CORE_INTERNAL_PIXEL_IMPL_HH
Index: mln/core/internal/pixel_iterator_base.hh
--- mln/core/internal/pixel_iterator_base.hh (revision 1024)
+++ mln/core/internal/pixel_iterator_base.hh (working copy)
@@ -30,10 +30,11 @@
/*! \file mln/core/internal/pixel_iterator_base.hh
*
- * \brief Base class for Pixel_Iterator concept implementation classes.
+ * \brief Base class to factor code for pixel iterator classes.
*/
# include <mln/core/concept/pixel_iterator.hh>
+# include <mln/core/internal/pixel_impl.hh>
namespace mln
@@ -42,138 +43,74 @@
namespace internal
{
- /*! \brief pixel_iterator_base_ class
+ /*! \brief A base class for pixel iterators.
*
*/
template <typename I, typename E>
- class pixel_iterator_base_ : public Pixel_Iterator<E>
+ class pixel_iterator_base_ : public Pixel_Iterator<E>,
+ public internal::pixel_impl_<I, E>
{
- public:
-
- /// Image value type.
- typedef mln_value(I) value;
-
- /// Image lvalue type.
- typedef mln_lvalue(I) lvalue;
-
- /// Image rvalue type.
- typedef mln_rvalue(I) rvalue;
-
-
- /// pixel iterator value.
- lvalue operator* ();
-
- /// Get the pixel iterator value.
- rvalue operator* () const;
-
-
- /// Address of the current iterator value/pixel.
- value** address() const;
-
+ typedef internal::pixel_impl_<I, E> super_;
+ typedef mln_value(super_) value_;
- // FIXME: Inactivated:
-
-// /// I type.
-// typedef I ima;
-
-// /// Image psite type.
-// typedef mln_psite(I) psite;
-
-// /// Get the image associated to the current pixel iterator.
-// const ima& image() const;
+ public:
-// /// psite associated to the iterator.
-// const psite& site() const;
+ /// Start an iteration.
+ void start();
-// /// psite associated to the iterator.
-// psite& site();
+ /// Invalidate the iterator.
+ void invalidate();
-// /// Address of the current iterator value/pixel.
-// value* address();
+ /// Test if the iterator is valid.
+ bool is_valid() const;
protected:
- /// Image associated to the iterator
- I& image_;
-
- /// Current pixel / value
- value* value_ptr_;
+ /// Beginning of the image.
+ value_* boi_;
- // FIXME: Inactivated:
-
-// /// Psite of the pixel
-// psite p_;
+ /// End of the image (past-the-end).
+ value_* eoi_;
+ /// Constructor.
pixel_iterator_base_(I& image);
};
+
#ifndef MLN_INCLUDE_ONLY
template <typename I, typename E>
- pixel_iterator_base_<I, E>::pixel_iterator_base_(I& image) :
- image_(image),
- value_ptr_(0)
+ pixel_iterator_base_<I, E>::pixel_iterator_base_(I& image)
+ : super_(image)
{
+ mln_precondition(image.has_data());
+ I& ima = this->image_;
+ boi_ = & ima( ima.domain().pmin() );
+ eoi_ = & ima( ima.domain().pmax() ) + 1;
+ invalidate();
}
-// template <typename I, typename E>
-// const typename pixel_iterator_base_<I, E>::ima&
-// pixel_iterator_base_<I, E>::image() const
-// {
-// return ima_;
-// }
-
template <typename I, typename E>
- mln_lvalue(I)
- pixel_iterator_base_<I, E>::operator* ()
+ void
+ pixel_iterator_base_<I, E>::start()
{
- mln_precondition(exact(this)->is_valid());
- mln_precondition(value_ptr_ != 0);
- return *value_ptr_;
+ this->value_ptr_ = boi_;
}
template <typename I, typename E>
- mln_rvalue(I)
- pixel_iterator_base_<I, E>::operator* () const
+ void
+ pixel_iterator_base_<I, E>::invalidate()
{
- mln_precondition(exact(this)->is_valid());
- mln_precondition(value_ptr_ != 0);
- return *value_ptr_;
+ this->value_ptr_ = eoi_;
}
template <typename I, typename E>
- mln_value(I) **
- pixel_iterator_base_<I, E>::address() const
+ bool
+ pixel_iterator_base_<I, E>::is_valid() const
{
- mln_precondition(exact(this)->is_valid());
- mln_precondition(value_ptr_ != 0);
- return & (mln_value(I)*)(value_ptr_);
+ return this->value_ptr_ != eoi_;
}
-// template <typename I, typename E>
-// mln_value(I)*
-// pixel_iterator_base_<I, E>::address()
-// {
-// mln_precondition(exact(this)->is_valid());
-// return value_ptr_;
-// }
-
-// template <typename I, typename E>
-// const typename pixel_iterator_base_<I, E>::psite&
-// pixel_iterator_base_<I, E>::site() const
-// {
-// //FIXME: update psite
-// return p_;
-// }
-
-// template <typename I, typename E>
-// typename pixel_iterator_base_<I, E>::psite&
-// pixel_iterator_base_<I, E>::site()
-// {
-// //FIXME: update psite
-// return p_;
-// }
-
#endif // ! MLN_INCLUDE_ONLY
} // end of namespace internal
Index: mln/core/internal/fixme.hh
--- mln/core/internal/fixme.hh (revision 0)
+++ mln/core/internal/fixme.hh (revision 0)
@@ -0,0 +1,55 @@
+// 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_INTERNAL_FIXME_HH
+# define MLN_CORE_INTERNAL_FIXME_HH
+
+/*! \file mln/core/internal/fixme.hh
+ *
+ * \brief Definition of mln::fixme for internal use only.
+ */
+
+
+namespace mln
+{
+
+ namespace internal
+ {
+
+ /*! \brief A FIXME class to make explicit in code that a type is
+ * not yet implemented.
+ *
+ * \internal
+ */
+ struct fixme;
+
+ } // end of namespace mln::internal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_INTERNAL_FIXME_HH
Index: mln/core/internal/box_impl.hh
--- mln/core/internal/box_impl.hh (revision 1024)
+++ mln/core/internal/box_impl.hh (working copy)
@@ -48,7 +48,7 @@
// box_impl
/*! \brief Implementation class to equip objects having a bounding
- * box with methods.
+ * box.
*
* \internal
*/
Index: mln/core/internal/image_base.hh
--- mln/core/internal/image_base.hh (revision 1024)
+++ mln/core/internal/image_base.hh (working copy)
@@ -58,14 +58,20 @@
/// Point associated type.
typedef mln_point(S) point;
+
+ /// Dpoint associated type.
+ typedef mln_dpoint(point) dpoint;
+
+ /// Coordinate associated type.
+ typedef mln_coord(point) coord;
+
+
/// Forward Piter associated type.
typedef mln_fwd_piter(S) fwd_piter;
/// Backward Piter associated type.
typedef mln_bkd_piter(S) bkd_piter;
- /// Piter associated type.
- typedef fwd_piter piter;
/// Test if \p p belongs to the image domain.
bool has(const psite& p) const;
Index: mln/core/internal/piter_adaptor.hh
--- mln/core/internal/piter_adaptor.hh (revision 1024)
+++ mln/core/internal/piter_adaptor.hh (working copy)
@@ -77,7 +77,7 @@
operator mln_point(Pi) () const;
/// Address of the point.
- const point* pointer() const;
+ const point* pointer_() const;
/// Give the i-th coordinate.
coord operator[](unsigned i) const;
@@ -120,9 +120,9 @@
template <typename Pi, typename E>
const mln_point(Pi)*
- piter_adaptor_<Pi,E>::pointer() const
+ piter_adaptor_<Pi,E>::pointer_() const
{
- return piter_.pointer();
+ return piter_.pointer_();
}
template <typename Pi, typename E>
Index: mln/core/pixel.hh
--- mln/core/pixel.hh (revision 1024)
+++ mln/core/pixel.hh (working copy)
@@ -34,57 +34,36 @@
*/
# include <mln/core/concept/genpixel.hh>
+# include <mln/core/internal/pixel_impl.hh>
namespace mln
{
- template <typename I>
- struct pixel_lvalue
- {
- typedef mln_lvalue(I) ret;
- };
-
- template <typename I>
- struct pixel_lvalue< const I >
- {
- typedef mln_rvalue(I) ret;
- };
-
-
-
/*! \brief Generic pixel class.
*
* The parameter is \c I the type of the image it belongs to.
*/
template <typename I>
struct pixel : public Object< pixel<I> >,
- public GenPixel< pixel<I> >
+ public GenPixel< pixel<I> >,
+ internal::pixel_impl_< I, pixel<I> >
{
- typedef mln_psite(I) psite;
- typedef mln_value(I) value;
- typedef mln_rvalue(I) rvalue;
- typedef I ima;
-
- pixel(I& ima);
- pixel(I& ima, const psite& p);
-
- const I& image() const;
+ /// Constructor.
+ pixel(I& image);
- const psite& site() const;
- psite& site();
+ /// Constructor.
+ pixel(I& image, const mln_point(I)& p);
- mln_rvalue(I) operator*() const;
- mln_lvalue(I) operator*();
+ /// Change the pixel to the one at point \p p.
+ void change_to(const mln_point(I)& p);
- value** address() const;
+ /// Test if this pixel is valid.
+ bool is_valid() const;
- protected:
-
- I& ima_;
- psite p_;
- value* value_ptr_;
+ private:
+ typedef internal::pixel_impl_<I, pixel<I> > super;
};
@@ -92,58 +71,37 @@
template <typename I>
pixel<I>::pixel(I& image)
- : ima_(image)
- {
- }
-
- template <typename I>
- pixel<I>::pixel(I& image, const psite& p)
- : ima_(image),
- p_(p)
- {
- value_ptr_ = & ima_(p);
- }
-
- template <typename I>
- const I&
- pixel<I>::image() const
- {
- return ima_;
- }
-
- template <typename I>
- const mln_psite(I)&
- pixel<I>::site() const
- {
- return p_;
- }
-
- template <typename I>
- mln_psite(I)&
- pixel<I>::site()
+ : super(image)
{
- return p_;
+ this->value_ptr_ = 0;
}
template <typename I>
- mln_rvalue(I)
- pixel<I>::operator*() const
+ pixel<I>::pixel(I& image, const mln_point(I)& p)
+ : super(image)
{
- return ima_(p_);
+ mln_precondition(this->image_.owns_(p));
+ change_to(p);
}
template <typename I>
- mln_lvalue(I)
- pixel<I>::operator*()
+ void
+ pixel<I>::change_to(const mln_point(I)& p)
{
- return ima_(p_);
+ mln_precondition(this->image_.owns_(p));
+ this->value_ptr_ = & this->image_(p);
}
template <typename I>
- mln_value(I)**
- pixel<I>::address() const
+ bool
+ pixel<I>::is_valid() const
{
- return (mln_value(I)**)(& this->value_ptr_);
+ I& ima = this->image_;
+ if (this->value_ptr_ = 0 || ! ima.has_data())
+ return false;
+ int o = this->value_ptr_ - ima.buffer();
+ mln_point(I) p = ima.point_at_offset(o);
+ return ima.owns_(p);
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/hline2d.hh
--- mln/core/hline2d.hh (revision 1024)
+++ mln/core/hline2d.hh (working copy)
@@ -68,7 +68,7 @@
/*! \brief Piter type to browse a hline such as: "for each row
* (decreasing), for each column (decreasing)."
*/
- typedef dpoints_fwd_piter<dpoint2d> bkd_qiter; // FIXME: bkd!!!
+ typedef internal::fixme bkd_qiter;
/*! \brief Same as fwd_qiter.
*/
Index: mln/core/concept/image.hh
--- mln/core/concept/image.hh (revision 1024)
+++ mln/core/concept/image.hh (working copy)
@@ -74,7 +74,9 @@
typedef point;
typedef psite;
- typedef piter;
+ typedef coord;
+ typedef dpoint;
+
typedef fwd_piter;
typedef bkd_piter;
@@ -99,7 +101,9 @@
typedef mln_point(E) point;
typedef mln_psite(E) psite;
- typedef mln_piter(E) piter;
+ typedef mln_coord(E) coord;
+ typedef mln_dpoint(E) dpoint;
+
typedef mln_fwd_piter(E) fwd_piter;
typedef mln_bkd_piter(E) bkd_piter;
Index: mln/core/concept/genpoint.hh
--- mln/core/concept/genpoint.hh (revision 1024)
+++ mln/core/concept/genpoint.hh (working copy)
@@ -36,9 +36,6 @@
# include <mlc/same_coord.hh>
# include <mln/core/concept/object.hh>
-
-# include <mln/core/macros.hh>
-# include <mln/core/contract.hh>
# include <mln/core/internal/force_exact.hh>
@@ -73,7 +70,7 @@
either Point
or operator point() const;
- const point* pointer() const;
+ const point* pointer_() const;
coord operator[](unsigned i) const;
*/
@@ -218,7 +215,7 @@
typedef mln_point(E) point;
typedef mln_dpoint(E) dpoint;
typedef mln_coord(E) coord;
- const point* (E::*m1)() const = & E::pointer;
+ const point* (E::*m1)() const = & E::pointer_;
m1 = 0;
coord (E::*m2)(unsigned i) const = & E::operator[];
m2 = 0;
Index: mln/core/concept/psite.hh
--- mln/core/concept/psite.hh (revision 1024)
+++ mln/core/concept/psite.hh (working copy)
@@ -65,7 +65,7 @@
public GenPoint<E>
{
/*
- const point* pointer() const
+ const point* pointer_() const
{
return & (exact(this)->operator point());
}
Index: mln/core/concept/point.hh
--- mln/core/concept/point.hh (revision 1024)
+++ mln/core/concept/point.hh (working copy)
@@ -55,7 +55,7 @@
/*! \brief The pointer is this point address.
*/
- const P* pointer() const;
+ const P* pointer_() const;
protected:
Point();
@@ -105,7 +105,7 @@
}
template <typename P>
- const P* Point<P>::pointer() const
+ const P* Point<P>::pointer_() const
{
return exact(this);
}
Index: mln/core/concept/pixel_iterator.hh
--- mln/core/concept/pixel_iterator.hh (revision 1024)
+++ mln/core/concept/pixel_iterator.hh (working copy)
@@ -28,53 +28,53 @@
#ifndef MLN_CORE_CONCEPT_PIXEL_ITERATOR_HH
# define MLN_CORE_CONCEPT_PIXEL_ITERATOR_HH
-/*! \file mln/core/concept/fast_iterator.hh
+/*! \file mln/core/concept/pixel_iterator.hh
+ *
* \brief Definition of the concept of mln::Pixel_Iterator.
*/
# include <mln/core/concept/iterator.hh>
# include <mln/core/concept/genpixel.hh>
+
namespace mln
{
- /*! \brief Pixel Iterator concept class.
+ /*! \brief Base class for the implementation of pixel iterator
+ * classes.
*
- * \see FIXME
+ * An iterator on pixels is an iterator that is bound to a
+ * particular image and that browses over a set of image pixels.
+ *
+ * \see mln::doc::Pixel_Iterator for a complete documentation of
+ * this class contents.
*/
template <typename E>
- struct Pixel_Iterator :
- public Iterator<E>,
+ struct Pixel_Iterator : public Iterator<E>,
public GenPixel<E>
{
/*
- typedef rvalue
- typedef lvalue
+ typedef lvalue;
+
lvalue operator* ();
- rvalue operator* () const;
*/
protected:
Pixel_Iterator();
};
+
#ifndef MLN_INCLUDE_ONLY
template <typename E>
Pixel_Iterator<E>::Pixel_Iterator()
{
- typedef mln_value(E) value;
- typedef mln_rvalue(E) rvalue;
typedef mln_lvalue(E) lvalue;
-
- lvalue (E::*m1)() = & E::operator*;
- m1 = 0;
- rvalue (E::*m2)() const = & E::operator*;
- m2 = 0;
+ lvalue (E::*m)() = & E::operator*;
+ m = 0;
}
#endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln
Index: mln/core/concept/fast_image.hh
--- mln/core/concept/fast_image.hh (revision 0)
+++ mln/core/concept/fast_image.hh (revision 0)
@@ -0,0 +1,96 @@
+// 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_CONCEPT_FAST_IMAGE_HH
+# define MLN_CORE_CONCEPT_FAST_IMAGE_HH
+
+/*! \file mln/core/concept/fast_image.hh
+ * \brief Definition of the concept of mln::Fast_Image.
+ */
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/trait/pixter.hh>
+
+
+namespace mln
+{
+
+ /*! \brief Base class for implementation of fast image classes.
+ *
+ * \see mln::doc::Fast_Image for a complete documentation of this
+ * class contents.
+ */
+ template <typename E>
+ struct Fast_Image : public Image<E>
+ {
+ /*
+ unsigned border();
+
+ int offset(const dpoint& dp);
+ unsigned offset(const point& p);
+ point point_at_offset(unsigned o) const;
+
+ const value* buffer() const;
+ */
+
+ protected:
+ Fast_Image();
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename E>
+ Fast_Image<E>::Fast_Image()
+ {
+ typedef mln_point(E) point;
+ typedef mln_dpoint(E) dpoint;
+ typedef mln_value(E) value;
+
+ typedef mln_fwd_pixter(E) fwd_pixter;
+ typedef mln_bkd_pixter(E) bkd_pixter;
+
+ int (E::*m1)(const dpoint&) = & E::offset;
+ m1 = 0;
+ unsigned (E::*m2)(const point&) = & E::offset;
+ m2 = 0;
+ point (E::*m3)(unsigned) const = & E::point_at_offset;
+ m3 = 0;
+ const value* (E::*m4)() const = & E::buffer;
+ m4 = 0;
+ unsigned (E::*m5)() const = & E::border;
+ m5 = 0;
+
+ // FIXME: how to check that qixter are defined when W is unknown!
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_CONCEPT_FAST_IMAGE_HH
Index: mln/core/concept/point_set.hh
--- mln/core/concept/point_set.hh (revision 1024)
+++ mln/core/concept/point_set.hh (working copy)
@@ -29,6 +29,7 @@
# define MLN_CORE_CONCEPT_POINT_SET_HH
/*! \file mln/core/concept/point_set.hh
+ *
* \brief Definition of the concept of mln::Point_Set.
*/
@@ -50,7 +51,7 @@
/*
typedef point;
typedef psite;
- typedef piter;
+
typedef fwd_piter;
typedef bkd_piter;
@@ -127,7 +128,6 @@
typedef mln_point(E) point;
typedef mln_psite(E) psite;
- typedef mln_piter(E) piter;
typedef mln_fwd_piter(E) fwd_piter;
typedef mln_bkd_piter(E) bkd_piter;
Index: mln/core/concept/object.hh
--- mln/core/concept/object.hh (revision 1024)
+++ mln/core/concept/object.hh (working copy)
@@ -38,6 +38,7 @@
# include <mln/core/macros.hh>
# include <mln/core/contract.hh>
+# include <mln/core/internal/fixme.hh>
/*! \namespace mln
Index: mln/core/concept/doc/image.hh
--- mln/core/concept/doc/image.hh (revision 1024)
+++ mln/core/concept/doc/image.hh (working copy)
@@ -121,10 +121,16 @@
*/
typedef void psite;
- /*! \brief Piter associated type.
- * \invariant This type has to derive from mln::Piter.
+
+ /*! \brief Coordinate associated type.
+ */
+ typedef void coord;
+
+ /*! \brief Dpoint associated type.
+ * \invariant This type has to derive from mln::Dpoint.
*/
- typedef void piter;
+ typedef void dpoint;
+
/*! \brief Forward point iterator associated type.
* \invariant This type has to derive from mln::Piter.
@@ -136,6 +142,7 @@
*/
typedef void bkd_piter;
+
/*! \brief Test if \p p belongs to the image domain.
*
* \param[in] p A point site.
@@ -162,10 +169,6 @@
std::size_t npoints() const;
};
- template <typename E>
- struct Fast_Image : public Image<E>
- {
- };
} // end of namespace mln::doc
Index: mln/core/concept/doc/genpoint.hh
--- mln/core/concept/doc/genpoint.hh (revision 1024)
+++ mln/core/concept/doc/genpoint.hh (working copy)
@@ -79,7 +79,7 @@
*
* \return A point address.
*/
- const point* pointer() const;
+ const point* pointer_() const;
/*! \brief Read-only access to the \p i-th coordinate value.
*
Index: mln/core/concept/doc/pixel_iterator.hh
--- mln/core/concept/doc/pixel_iterator.hh (revision 1024)
+++ mln/core/concept/doc/pixel_iterator.hh (working copy)
@@ -25,8 +25,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file mln/core/concept/doc/fast_iterator.hh
- * \brief This file documents the concept of mln::Fast_Iterator.
+/*! \file mln/core/concept/doc/pixel_iterator.hh
+ *
+ * \brief This file documents the concept of mln::Pixel_Iterator.
*/
namespace mln
@@ -34,24 +35,29 @@
namespace doc
{
+
/*! \brief Documentation class for mln::Iterator.
- * \see mln::Fast_Iterator
+ * \see mln::Pixel_Iterator
*/
template <typename E>
- struct Fast_Iterator : public Iterator<E>
+ struct Pixel_Iterator : public Iterator<E>,
+ public GenPixel<E>
{
- /*! \brief Dereference operator.
- * return the current pixel
+ /*! \brief Type returned by the read-write dereference operator.
*/
- rvalue operator* ();
+ typedef void lvalue;
/*! \brief Dereference operator.
- * return the current pixel
+ *
+ * \return The current pixel value; this value cannot be
+ * modified.
*/
lvalue operator* () const;
+
protected:
- Fast_Iterator();
+ Pixel_Iterator();
};
+
} // end of namespace doc
} // end of namespace mln
Index: mln/core/concept/doc/fast_image.hh
--- mln/core/concept/doc/fast_image.hh (revision 0)
+++ mln/core/concept/doc/fast_image.hh (revision 0)
@@ -0,0 +1,92 @@
+// 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 mln/core/concept/doc/fast_image.hh
+ * \brief This file documents the concept of mln::Fast_Image.
+ */
+
+namespace mln
+{
+
+ namespace doc
+ {
+
+ /*! \brief Documentation class for mln::Fast_Image.
+ * \see mln::Fast_Image
+ */
+ template <typename E>
+ struct Fast_Image : public Image<E>
+ {
+
+ /*! \brief Give the border thickness.
+ *
+ * \pre The image has to be initialized.
+ */
+ unsigned border();
+
+ /*! \brief Give the offset corresponding to the delta-point \p
+ * dp.
+ *
+ * \param[in] p A delta-point.
+ *
+ * \pre The image has to be initialized.
+ */
+ int offset(const dpoint& dp);
+
+
+ /*! \brief Give the offset of the point \p p.
+ *
+ * \param[in] p A point.
+ *
+ * \pre The image has to own the point \p p.
+ */
+ unsigned offset(const point& p);
+
+
+ /*! \brief Give the point at offset \p o.
+ *
+ * \param[in] p An offset.
+ *
+ * \pre The image has to be initialized.
+ * \pre o < ncells()
+ */
+ point point_at_offset(unsigned o) const;
+
+
+ /*! \brief Give a hook to the value buffer.
+ *
+ * \internal
+ *
+ * \pre The image has to be initialized.
+ */
+ const value* buffer() const;
+
+ };
+
+ } // end of namespace mln::doc
+
+} // end of namespace mln
Index: mln/core/concept/doc/point_set.hh
--- mln/core/concept/doc/point_set.hh (revision 1024)
+++ mln/core/concept/doc/point_set.hh (working copy)
@@ -50,10 +50,6 @@
*/
typedef void psite;
- /*! \brief Piter associated type.
- */
- typedef void piter;
-
/*! \brief Forward Piter associated type.
*/
typedef void fwd_piter;
Index: mln/core/concept/doc/genpixel.hh
--- mln/core/concept/doc/genpixel.hh (revision 0)
+++ mln/core/concept/doc/genpixel.hh (revision 0)
@@ -0,0 +1,78 @@
+// 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_CONCEPT_DOC_GENPIXEL_HH
+# define MLN_CORE_CONCEPT_DOC_GENPIXEL_HH
+
+/*! \file mln/core/concept/doc/genpixel.hh
+ * \brief This file documents the concept of mln::GenPixel.
+ */
+
+
+namespace mln
+{
+
+ namespace doc
+ {
+
+ /*! \brief Documentation class for mln::GenPixel.
+ *
+ * \see mln::GenPixel
+ */
+ template <typename E>
+ struct GenPixel
+ {
+
+ /// Value associated type.
+ typedef void value;
+
+ /// Read-only value associated type.
+ typedef void rvalue;
+
+
+ /*! \brief Give the value of this generalized pixel.
+ *
+ * \return A read-only value.
+ */
+ rvalue operator*() const;
+
+ /*! \brief Give a hook to the value address.
+ *
+ * This method allows for iterators to refer to a generalized
+ * pixel.
+ *
+ * \return A pointer to the value address.
+ */
+ value** address_() const;
+
+ protected:
+ GenPixel();
+ };
+
+ } // end of namespace mln::doc
+
+} // end of namespace mln
Index: mln/core/concept/genpixel.hh
--- mln/core/concept/genpixel.hh (revision 1024)
+++ mln/core/concept/genpixel.hh (working copy)
@@ -29,13 +29,11 @@
# define MLN_CORE_CONCEPT_GENPIXEL_HH
/*! \file mln/core/concept/genpixel.hh
+ *
* \brief Definition of the concept of mln::Genpixel.
*/
# include <mln/core/concept/object.hh>
-
-# include <mln/core/macros.hh>
-# include <mln/core/contract.hh>
# include <mln/core/internal/force_exact.hh>
@@ -58,75 +56,29 @@
template <typename E>
struct GenPixel
{
-
/*
- typedef rvalue;
typedef value;
- // FIXME: lvalue?
-
-
- // FIXME: Inactivated:
- // typedef ima; // not const!
- // typedef psite;
- // const ima& image() const;
- // const psite& site() const; // FIXME ou cpy
- // value* address();
+ typedef rvalue;
rvalue operator*() const;
- lvalue operator*();
-
- const value*& address() const;
+ value** address_() const;
*/
-
protected:
GenPixel();
-
};
- /*! \brief Print a generalized pixel \p p into the output stream \p
- * ostr.
- *
- * \param[in,out] ostr An output stream.
- * \param[in] p A generalized pixel.
- *
- * \return The modified output stream \p ostr.
- *
- * \relates mln::GenPixel
- */
- template <typename P>
- std::ostream& operator<<(std::ostream& ostr, const GenPixel<P>&
pxl);
-
-
# ifndef MLN_INCLUDE_ONLY
-
template <typename E>
GenPixel<E>::GenPixel()
{
typedef mln_value(E) value;
typedef mln_rvalue(E) rvalue;
-
- // FIXME: Inactivated:
-
-// typedef mln_ima(E) ima;
-// typedef mln_psite(E) psite;
-// const ima& (E::*m1)() const = & E::image;
-// m1 = 0;
-// const psite& (E::*m2)() const = & E::site;
-// m2 = 0;
-
- rvalue (E::*m3)() const = & E::operator*;
- m3 = 0;
-// const value *const & (E::*m4)() const = & E::address;
-// m4 = 0;
- }
-
-
- template <typename P>
- std::ostream& operator<<(std::ostream& ostr, const GenPixel<P>&
pxl)
- {
- return ostr << pxl.psite() << '@' << & pxl.image();
+ rvalue (E::*m1)() const = & E::operator*;
+ m1 = 0;
+ value** (E::*m2)() const = & E::address_;
+ m2 = 0;
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/tags.hh
--- mln/core/tags.hh (revision 0)
+++ mln/core/tags.hh (revision 0)
@@ -0,0 +1,50 @@
+// 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_TAGS_HH
+# define MLN_CORE_TAGS_HH
+
+/*! \file mln/core/tags.hh
+ *
+ * \brief Define a set of tags for images types.
+ */
+
+
+namespace mln
+{
+
+ namespace tag
+ {
+
+ // FIXME: ...
+
+ } // end of namespace mln::core
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_TAGS_HH
Index: mln/core/vline2d.hh
--- mln/core/vline2d.hh (revision 1024)
+++ mln/core/vline2d.hh (working copy)
@@ -70,7 +70,7 @@
/*! \brief Piter type to browse a vline such as: "for each row
* (decreasing), for each column (decreasing)."
*/
- typedef dpoints_fwd_piter<dpoint2d> bkd_qiter; // FIXME: bkd!!!
+ typedef internal::fixme bkd_qiter;
/*! \brief Same as fwd_qiter.
*/
Index: mln/core/image2d_b.hh
--- mln/core/image2d_b.hh (revision 1024)
+++ mln/core/image2d_b.hh (working copy)
@@ -39,8 +39,12 @@
# include <mln/border/thickness.hh>
# include <mln/fun/all.hh>
-# include <mln/core/pixter2d_b.hh>
-# include <mln/core/dpoints_pixter.hh>
+
+
+// FIXME:
+
+// # include <mln/core/pixter2d_b.hh>
+// # include <mln/core/dpoints_pixter.hh>
namespace mln
@@ -64,18 +68,19 @@
typedef dpoint2d dpoint;
typedef mln_fwd_piter(box2d) fwd_piter;
typedef mln_bkd_piter(box2d) bkd_piter;
- typedef fwd_piter piter;
// end of warning
- /// Forward pixel iterator associated to image2d
- typedef fwd_pixter2d_b<T> fwd_pixter;
- /// Foward pixel iterator on dpoints assoicated to image 2d
- typedef dpoints_pixter< image2d_b<T> > fwd_qixter;
+ // FIXME:
+// /// Forward pixel iterator associated to image2d
+// typedef fwd_pixter2d_b<T> fwd_pixter;
- typedef fwd_pixter pixter;
- typedef fwd_qixter qixter;
+// /// Foward pixel iterator on dpoints assoicated to image 2d
+// typedef dpoints_pixter< image2d_b<T> > fwd_qixter;
+
+// typedef fwd_pixter pixter;
+// typedef fwd_qixter qixter;
/// Value associated type.
@@ -153,14 +158,17 @@
/// Fast Image method
- /// Return the offset corresponding to the dpoint \p dp.
+ /// Give the offset corresponding to the delta-point \p dp.
int offset(const dpoint2d& dp);
- /// Return the offset corresponding to the dpoint \p p.
- int offset(const point2d& p);
+ /// Give the offset corresponding to the point \p p.
+ unsigned offset(const point2d& p);
+
+ /// Give the point corresponding to the offset \p o.
+ point2d point_at_offset(unsigned o) const;
- /// Return the point corresponding to the offset \p offset.
- point2d point_at_offset(int offset);
+ /// Give a hook to the value buffer.
+ const T* buffer() const;
private:
@@ -340,6 +348,46 @@
deallocate_();
}
+ template <typename T>
+ const T*
+ image2d_b<T>::buffer() const
+ {
+ mln_precondition(this->has_data());
+ return buffer_;
+ }
+
+ template <typename T>
+ int
+ image2d_b<T>::offset(const dpoint2d& dp)
+ {
+ mln_precondition(this->has_data());
+ int o = dp[0] * vb_.len(1) + dp[1];
+ return o;
+ }
+
+ template <typename T>
+ unsigned
+ image2d_b<T>::offset(const point2d& p)
+ {
+ mln_precondition(this->owns_(p));
+ unsigned o = & this->operator()(p) - this->buffer_;
+ mln_postcondition(p = point_at_offset(o));
+ return o;
+ }
+
+ template <typename T>
+ point2d
+ image2d_b<T>::point_at_offset(unsigned o) const
+ {
+ mln_precondition(o < ncells());
+ mln_precondition(this->has_data());
+ point2d p = make::point2d(o / vb_.len(1) + vb_.min_row(),
+ o % vb_.len(1) + vb_.min_col());
+ mln_postcondition(& this->operator()(p) = this->buffer_ + o);
+ return p;
+ }
+
+
// private
template <typename T>
@@ -388,28 +436,52 @@
}
}
- template <typename T>
- int
- image2d_b<T>::offset(const dpoint2d& dp)
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+
+# include <mln/core/trait/pixter.hh>
+# include <mln/core/dpoints_pixter.hh>
+# include <mln/core/pixter2d_b.hh>
+
+
+namespace mln
+{
+
+ namespace trait
{
- return dp[0] * vb_.len(1) + dp[1];
- }
+
+ // pixter
template <typename T>
- int
- image2d_b<T>::offset(const point2d& p)
+ struct fwd_pixter< image2d_b<T> >
{
- return p[0] * vb_.len(1) + p[1];
- }
+ typedef fwd_pixter2d_b< image2d_b<T> > ret;
+ };
template <typename T>
- point2d
- image2d_b<T>::point_at_offset(int offset)
+ struct bkd_pixter< image2d_b<T> >
{
- return point2d(offset / (vb_.len(1) + 1), offset % (vb_.len(1) + 1));
- }
+ typedef internal::fixme ret;
+ };
-# endif // ! MLN_INCLUDE_ONLY
+ // qixter
+
+ template <typename T, typename W>
+ struct fwd_qixter< image2d_b<T>, W >
+ {
+ typedef dpoints_fwd_pixter< image2d_b<T> > ret;
+ };
+
+ template <typename T, typename W>
+ struct bkd_qixter< image2d_b<T>, W >
+ {
+ typedef internal::fixme ret;
+ };
+
+ } // end of namespace mln::trait
} // end of namespace mln
Index: mln/metal/none.hh
--- mln/metal/none.hh (revision 0)
+++ mln/metal/none.hh (revision 0)
@@ -0,0 +1,57 @@
+// 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_METAL_NONE_HH
+# define MLN_CORE_METAL_NONE_HH
+
+/*! \file mln/core/metal/none.hh
+ *
+ * \brief Definition of a type that means "none".
+ */
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+
+ /*! \brief Type meaning "none".
+ *
+ * This type is for use when a type is required and none can be
+ * provided.
+ */
+ struct none;
+
+
+ } // end of namespace mln::metal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_METAL_NONE_HH
Index: mln/level/fast_median.hh
--- mln/level/fast_median.hh (revision 1024)
+++ mln/level/fast_median.hh (working copy)
@@ -36,7 +36,6 @@
# include <mln/core/concept/image.hh>
# include <mln/core/window2d.hh>
# include <mln/accu/median.hh>
-# include <ostream>
namespace mln
@@ -85,24 +84,20 @@
win_bot = win - (win + up),
win_top = (win + up) - win;
-
-
- //Fixme bug
- point2d p;
-
accu::median_on<mln_value(I)> med;
// initialization
- p = input.domain().pmin() + up;
- mln_qixter(I)
- q_fp(win_fwd_plus, p, input), q_fm(win_fwd_minus, p, input),
- q_bp(win_bkd_plus, p, input), q_bm(win_bkd_minus, p, input),
- q_top(win_top, p, input), q_bot(win_bot, p, input);
+ point2d p = input.domain().pmin() + up;
+
+ mln_qixter(I, window2d)
+ q_fp(input, win_fwd_plus, p), q_fm(input, win_fwd_minus, p),
+ q_bp(input, win_bkd_plus, p), q_bm(input, win_bkd_minus, p),
+ q_top(input, win_top, p), q_bot(input, win_bot, p);
med.init();
{
- mln_qixter(I) q(win, p, input);
+ mln_qixter(I, W) q(input, win, p);
for_all(q)
med.take(*q);
}
Index: mln/level/median.hh
--- mln/level/median.hh (revision 1024)
+++ mln/level/median.hh (working copy)
@@ -160,21 +160,22 @@
template <typename I, typename O>
void median(const I& input, const hline2d& win, O& output)
{
- const int
+ typedef mln_coord(I) coord;
+ const coord
max_row = input.max_row(),
min_col = input.min_col(),
max_col = input.max_col();
- const unsigned half = win.length() / 2;
+ const coord half = win.length() / 2;
point2d p;
- int& row = p.row();
- int& col = p.col();
+ coord& row = p.row();
+ coord& col = p.col();
accu::median_on<mln_value(I)> med;
for (row = input.min_row(); row <= max_row; ++row)
{
- int ct, cu;
+ coord ct, cu;
// initialization (before first point of the row)
med.init();
Index: mln/canvas/sbrowsing.hh
--- mln/canvas/sbrowsing.hh (revision 1024)
+++ mln/canvas/sbrowsing.hh (working copy)
@@ -45,12 +45,18 @@
/*! FIXME: Doc!
*
*
- * F should be
- * {
- * input; p; --- attributes
- * void init();
- * void down(); void fwd(); void bkd(); --- methods
- * }
+ * F shall feature: \n
+ * { \n
+ * --- as attributes: \n
+ * input; \n
+ * p; \n
+ * --- as methods: \n
+ * void init(); \n
+ * void down(); \n
+ * void fwd(); \n
+ * void bkd(); \n
+ * } \n
+ *
*/
template <typename F>
void sbrowsing(F& f);