Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- 9625 discussions
04 Oct '07
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fast is Fastest and speed trait is used in inheritance.
Fast actually is fastEST.
* mln/core/concept/fast_image.hh: Rename as...
* mln/core/concept/fastest_image.hh: ...this new file.
* mln/core/concept/doc/fast_image.hh: Rename as...
* mln/core/concept/doc/fastest_image.hh: ...this new file.
* mln/core/internal/image_base.hh: Use speed trait for
inheritance.
* mln/core/trait/is_fast.hh: Remove; obsolete.
* mln/core/trait/all.hh: Update.
* mln/histo/compute.hh,
* mln/debug/iota.hh,
* mln/debug/println_with_border.hh,
* mln/core/image2d_b.hh,
* mln/core/concept/image.hh,
* mln/core/image1d_b.hh,
* mln/core/image3d_b.hh,
* mln/arith/plus.hh,
* mln/arith/min.hh,
* mln/arith/revert.hh,
* mln/arith/minus.hh,
* mln/level/take.hh,
* mln/level/assign.hh,
* mln/level/apply.hh,
* mln/level/fill.hh,
* mln/level/memcpy_.hh,
* mln/level/memset_.hh,
* mln/level/median.hh,
* mln/level/transform.hh,
* mln/linear/convolve.hh,
* mln/linear/local/convolve.hh,
* mln/accu/take.hh,
* mln/border/resize.hh,
* mln/border/fill.hh,
* mln/border/duplicate.hh,
* mln/border/mirror.hh,
* mln/border/get.hh,
* mln/test/predicate.hh,
* mln/morpho/erosion_fast.hh,
* mln/morpho/dilation_fast.hh,
* mln/io/internal/pnm/save.hh,
* mln/logical/and.hh,
* mln/logical/and_not.hh,
* mln/logical/or.hh,
* mln/logical/not.hh,
* mln/labeling/level.hh,
* mln/labeling/base.hh: Update.
* tests/image2d_b.cc: Augment.
Only keep the generic impl in the main file.
* mln/level/paste.hh: Split file into this and...
* mln/level/paste.spe.hh: ...this new file.
(paste_generic_): Rename as...
(paste_): ...this and move in impl::generic.
* tests/level_paste.cc: Update.
Misc.
* tests/literal_zero.cc,
* mln/core/macros.hh: Clean.
mln/accu/take.hh | 2
mln/arith/min.hh | 4 -
mln/arith/minus.hh | 4 -
mln/arith/plus.hh | 4 -
mln/arith/revert.hh | 2
mln/border/duplicate.hh | 10 ++--
mln/border/fill.hh | 8 +--
mln/border/get.hh | 2
mln/border/mirror.hh | 4 -
mln/border/resize.hh | 4 -
mln/core/concept/doc/fastest_image.hh | 10 ++--
mln/core/concept/fastest_image.hh | 22 ++++-----
mln/core/concept/image.hh | 2
mln/core/image1d_b.hh | 13 -----
mln/core/image2d_b.hh | 16 +++---
mln/core/image3d_b.hh | 11 ----
mln/core/internal/image_base.hh | 17 ++++---
mln/core/macros.hh | 11 +++-
mln/core/trait/all.hh | 1
mln/debug/iota.hh | 2
mln/debug/println_with_border.hh | 10 ++--
mln/histo/compute.hh | 2
mln/io/internal/pnm/save.hh | 12 ++---
mln/labeling/base.hh | 2
mln/labeling/level.hh | 18 +++----
mln/level/apply.hh | 2
mln/level/assign.hh | 2
mln/level/fill.hh | 4 -
mln/level/median.hh | 2
mln/level/memcpy_.hh | 4 -
mln/level/memset_.hh | 8 +--
mln/level/paste.hh | 59 +++++++------------------
mln/level/paste.spe.hh | 79 ++++++++--------------------------
mln/level/take.hh | 2
mln/level/transform.hh | 2
mln/linear/convolve.hh | 4 -
mln/linear/local/convolve.hh | 2
mln/logical/and.hh | 2
mln/logical/and_not.hh | 2
mln/logical/not.hh | 2
mln/logical/or.hh | 2
mln/morpho/dilation_fast.hh | 2
mln/morpho/erosion_fast.hh | 2
mln/test/predicate.hh | 2
tests/image2d_b.cc | 8 +++
tests/level_paste.cc | 2
tests/literal_zero.cc | 1
47 files changed, 158 insertions(+), 230 deletions(-)
Index: tests/literal_zero.cc
--- tests/literal_zero.cc (revision 1248)
+++ tests/literal_zero.cc (working copy)
@@ -31,7 +31,6 @@
*/
#include <mln/literal/zero.hh>
-// #include <mln/core/concept/object.hh>
int main()
Index: tests/image2d_b.cc
--- tests/image2d_b.cc (revision 1248)
+++ tests/image2d_b.cc (working copy)
@@ -36,6 +36,12 @@
#include <mln/core/init.hh>
+template <typename I>
+void check_fastest(const mln::Fastest_Image<I>&)
+{
+}
+
+
int main()
{
using namespace mln;
@@ -48,4 +54,6 @@
mln_assertion(f.npoints() = geom::nrows(f) * geom::ncols(f));
mln_assertion(f.ncells() = (nrows + 2 * border) * (ncols + 2 * border));
+
+ check_fastest(f);
}
Index: tests/level_paste.cc
--- tests/level_paste.cc (revision 1248)
+++ tests/level_paste.cc (working copy)
@@ -58,5 +58,5 @@
level::paste(ima, ima2); // Fast version.
debug::println(ima2);
- level::impl::paste_generic_(ima, ima2); // Not so fast version...
+ level::impl::generic::paste_(ima, ima2); // Not so fast version...
}
Index: mln/histo/compute.hh
--- mln/histo/compute.hh (revision 1248)
+++ mln/histo/compute.hh (working copy)
@@ -65,7 +65,7 @@
}
template <typename I>
- data<mln_vset(I)> compute(const Fast_Image<I>& input_)
+ data<mln_vset(I)> compute(const Fastest_Image<I>& input_)
{
const I& input = exact(input_);
data<mln_vset(I)> h(input.values());
Index: mln/debug/iota.hh
--- mln/debug/iota.hh (revision 1248)
+++ mln/debug/iota.hh (working copy)
@@ -63,7 +63,7 @@
}
template <typename I>
- void iota(Fast_Image<I>& input_)
+ void iota(Fastest_Image<I>& input_)
{
unsigned i = 0;
I& input = exact(input_);
Index: mln/debug/println_with_border.hh
--- mln/debug/println_with_border.hh (revision 1248)
+++ mln/debug/println_with_border.hh (working copy)
@@ -48,7 +48,7 @@
/// Print the image \p input on the standard output.
template <typename I>
- void println_with_border(const Fast_Image<I>& input);
+ void println_with_border(const Fastest_Image<I>& input);
# ifndef MLN_INCLUDE_ONLY
@@ -58,7 +58,7 @@
// generic version
template <typename S, typename I>
- void println_with_border(const S&, const Fast_Image<I>& input_)
+ void println_with_border(const S&, const Fastest_Image<I>& input_)
{
const I& input = exact(input_);
for (size_t i = 0; i < input.ncells(); i++)
@@ -68,7 +68,7 @@
// 2D version
template <typename I>
- void println_with_border(const box2d& b, const Fast_Image<I>& input_)
+ void println_with_border(const box2d& b, const Fastest_Image<I>& input_)
{
const I& input = exact(input_);
const std::size_t ncols = b.ncols() + 2 * input.border();
@@ -83,7 +83,7 @@
// 3D version
template <typename I>
- void println_with_border(const box3d& b, const Fast_Image<I>& input_)
+ void println_with_border(const box3d& b, const Fastest_Image<I>& input_)
{
const I& ima = exact(input_);
typedef mln_point(I) P;
@@ -115,7 +115,7 @@
// facade
template <typename I>
- void println_with_border(const Fast_Image<I>& input)
+ void println_with_border(const Fastest_Image<I>& input)
{
impl::println_with_border(exact(input).bbox(), exact(input));
}
Index: mln/core/macros.hh
--- mln/core/macros.hh (revision 1248)
+++ mln/core/macros.hh (working copy)
@@ -34,6 +34,13 @@
*/
+// a
+
+/// Shortcut to access the argument type associated to T.
+# define mln_argument(T) typename T::argument
+# define mln_argument_(T) T::argument
+
+
// b
/// Shortcut to access the bkd_niter type associated to T.
@@ -161,10 +168,6 @@
# define mln_value(T) typename T::value
# define mln_value_(T) T::value
-/// Shortcut to access the argument type associated to T.
-# define mln_argument(T) typename T::argument
-# define mln_argument_(T) T::argument
-
/// Shortcut to test if the values of an image with type \c I are lowly quantifized.
# define mln_is_value_lowq(I) mln_is_lowq( mln_value(I) )
Index: mln/core/internal/image_base.hh
--- mln/core/internal/image_base.hh (revision 1248)
+++ mln/core/internal/image_base.hh (working copy)
@@ -36,6 +36,7 @@
# include <mln/core/concept/image.hh>
# include <mln/core/grids.hh>
# include <mln/util/tracked_ptr.hh>
+# include <mln/metal/equal.hh>
@@ -77,16 +78,16 @@
};
- /*! \brief Selector for image inheritance (fast or regular).
+ /*! \brief Selector for image inheritance (fastest or not fastest).
*
* \internal
*/
- template <typename Is_fast, typename E>
+ template <typename Is_fastest, typename E>
struct select_image_concept_;
template <typename E>
struct select_image_concept_< metal::true_, E >
- : public Fast_Image<E>
+ : public Fastest_Image<E>
{};
template <typename E>
@@ -105,7 +106,8 @@
template <typename S, typename E>
struct image_base_
- : public select_image_concept_< typename trait::is_fast<E>::ret,
+ : public select_image_concept_< typename mlc_equal(mln_trait_image_speed(E),
+ trait::speed::fastest)::eval,
E >
{
/// Point_Set associated type.
@@ -169,6 +171,10 @@
// Internal data, sharable by several images.
util::tracked_ptr< internal::data_<E> > data_;
+
+ typedef select_image_concept_< typename mlc_equal(mln_trait_image_speed(E),
+ trait::speed::fastest)::eval,
+ E > super_;
};
@@ -182,8 +188,7 @@
template <typename S, typename E>
image_base_<S,E>::image_base_(const image_base_& rhs)
- : select_image_concept_< typename trait::is_fast<E>::ret,
- E >()
+ : super_()
{
mln_precondition(exact(rhs).has_data()); // FIXME: Is-it too restrictive?
this->data_ = rhs.data_;
Index: mln/core/image2d_b.hh
--- mln/core/image2d_b.hh (revision 1248)
+++ mln/core/image2d_b.hh (working copy)
@@ -104,16 +104,16 @@
- namespace trait
- {
+// namespace trait
+// {
- template <typename T>
- struct is_fast< image2d_b<T> >
- {
- typedef metal::true_ ret;
- };
+// template <typename T>
+// struct is_fast< image2d_b<T> >
+// {
+// typedef metal::true_ ret;
+// };
- } // end of mln::trait
+// } // end of mln::trait
Index: mln/core/trait/all.hh
--- mln/core/trait/all.hh (revision 1248)
+++ mln/core/trait/all.hh (working copy)
@@ -44,7 +44,6 @@
}
-# include <mln/core/trait/is_fast.hh>
# include <mln/core/trait/pixter.hh>
Index: mln/core/concept/image.hh
--- mln/core/concept/image.hh (revision 1248)
+++ mln/core/concept/image.hh (working copy)
@@ -193,7 +193,7 @@
} // end of namespace mln
-# include <mln/core/concept/fast_image.hh>
+# include <mln/core/concept/fastest_image.hh>
#endif // ! MLN_CORE_CONCEPT_IMAGE_HH
Index: mln/core/concept/doc/fastest_image.hh
--- mln/core/concept/doc/fastest_image.hh (revision 1248)
+++ mln/core/concept/doc/fastest_image.hh (working copy)
@@ -25,8 +25,8 @@
// 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.
+/*! \file mln/core/concept/doc/fastest_image.hh
+ * \brief This file documents the concept of mln::Fastest_Image.
*/
namespace mln
@@ -35,11 +35,11 @@
namespace doc
{
- /*! \brief Documentation class for mln::Fast_Image.
- * \see mln::Fast_Image
+ /*! \brief Documentation class for mln::Fastest_Image.
+ * \see mln::Fastest_Image
*/
template <typename E>
- struct Fast_Image : public Image<E>
+ struct Fastest_Image : public Image<E>
{
/*! \brief Give the border thickness.
Index: mln/core/concept/fastest_image.hh
--- mln/core/concept/fastest_image.hh (revision 1248)
+++ mln/core/concept/fastest_image.hh (working copy)
@@ -25,11 +25,11 @@
// 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
+#ifndef MLN_CORE_CONCEPT_FASTEST_IMAGE_HH
+# define MLN_CORE_CONCEPT_FASTEST_IMAGE_HH
-/*! \file mln/core/concept/fast_image.hh
- * \brief Definition of the concept of mln::Fast_Image.
+/*! \file mln/core/concept/fastest_image.hh
+ * \brief Definition of the concept of mln::Fastest_Image.
*/
# include <mln/core/concept/image.hh>
@@ -40,13 +40,13 @@
namespace mln
{
- /*! \brief Base class for implementation of fast image classes.
+ /*! \brief Base class for implementation of fastest image classes.
*
- * \see mln::doc::Fast_Image for a complete documentation of this
+ * \see mln::doc::Fastest_Image for a complete documentation of this
* class contents.
*/
template <typename E>
- struct Fast_Image : public Image<E>
+ struct Fastest_Image : public Image<E>
{
/*
unsigned border();
@@ -78,7 +78,7 @@
offset_at(const Generalized_Point<P>& p) const;
protected:
- Fast_Image();
+ Fastest_Image();
};
@@ -87,7 +87,7 @@
template <typename E>
template <typename P>
unsigned // FIXME: std::size_t?
- Fast_Image<E>::offset_at(const Generalized_Point<P>& p_) const
+ Fastest_Image<E>::offset_at(const Generalized_Point<P>& p_) const
{
// FIXME: check that P is mln_point(E)
const E* this_ = exact(this);
@@ -101,7 +101,7 @@
}
template <typename E>
- Fast_Image<E>::Fast_Image()
+ Fastest_Image<E>::Fastest_Image()
{
typedef mln_point(E) point;
typedef mln_dpoint(E) dpoint;
@@ -142,4 +142,4 @@
} // end of namespace mln
-#endif // ! MLN_CORE_CONCEPT_FAST_IMAGE_HH
+#endif // ! MLN_CORE_CONCEPT_FASTEST_IMAGE_HH
Index: mln/core/image1d_b.hh
--- mln/core/image1d_b.hh (revision 1248)
+++ mln/core/image1d_b.hh (working copy)
@@ -56,19 +56,6 @@
template <typename T> struct image1d_b;
- namespace trait
- {
-
- template <typename T>
- struct is_fast< image1d_b<T> >
- {
- typedef metal::true_ ret;
- };
-
- } // end of mln::trait
-
-
-
namespace internal
{
Index: mln/core/image3d_b.hh
--- mln/core/image3d_b.hh (revision 1248)
+++ mln/core/image3d_b.hh (working copy)
@@ -56,17 +56,6 @@
template <typename T> struct image3d_b;
- namespace trait
- {
-
- template <typename T>
- struct is_fast< image3d_b<T> >
- {
- typedef metal::true_ ret;
- };
-
- } // end of mln::trait
-
namespace internal
{
Index: mln/arith/plus.hh
--- mln/arith/plus.hh (revision 1248)
+++ mln/arith/plus.hh (working copy)
@@ -118,7 +118,7 @@
}
template <typename L, typename R, typename O>
- void plus_(const Fast_Image<L>& lhs, const Fast_Image<R>& rhs, Fast_Image<O>& output)
+ void plus_(const Fastest_Image<L>& lhs, const Fastest_Image<R>& rhs, Fastest_Image<O>& output)
{
mln_pixter(const L) lp(exact(lhs));
mln_pixter(const R) rp(exact(rhs));
@@ -138,7 +138,7 @@
}
template <typename L, typename R>
- void plus_inplace_(Fast_Image<L>& lhs, const Fast_Image<R>& rhs)
+ void plus_inplace_(Fastest_Image<L>& lhs, const Fastest_Image<R>& rhs)
{
mln_pixter(L) lp(exact(lhs));
mln_pixter(const R) rp(exact(rhs));
Index: mln/arith/min.hh
--- mln/arith/min.hh (revision 1248)
+++ mln/arith/min.hh (working copy)
@@ -87,7 +87,7 @@
}
template <typename L, typename R, typename O>
- void min_(const Fast_Image<L>& lhs, const Fast_Image<R>& rhs, Fast_Image<O>& output)
+ void min_(const Fastest_Image<L>& lhs, const Fastest_Image<R>& rhs, Fastest_Image<O>& output)
{
mln_pixter(const L) lp(exact(lhs));
mln_pixter(const R) rp(exact(rhs));
@@ -108,7 +108,7 @@
}
template <typename L, typename R>
- void min_inplace_(Fast_Image<L>& lhs, const Fast_Image<R>& rhs)
+ void min_inplace_(Fastest_Image<L>& lhs, const Fastest_Image<R>& rhs)
{
mln_pixter(L) lp(exact(lhs));
mln_pixter(const R) rp(exact(rhs));
Index: mln/arith/revert.hh
--- mln/arith/revert.hh (revision 1248)
+++ mln/arith/revert.hh (working copy)
@@ -89,7 +89,7 @@
}
template <typename I, typename O>
- void revert_(const Fast_Image<I>& input, Fast_Image<O>& output)
+ void revert_(const Fastest_Image<I>& input, Fastest_Image<O>& output)
{
typedef mln_value(I) V;
mln_pixter(const I) ip(exact(input));
Index: mln/arith/minus.hh
--- mln/arith/minus.hh (revision 1248)
+++ mln/arith/minus.hh (working copy)
@@ -86,7 +86,7 @@
}
template <typename L, typename R, typename O>
- void minus_(const Fast_Image<L>& lhs, const Fast_Image<R>& rhs, Fast_Image<O>& output)
+ void minus_(const Fastest_Image<L>& lhs, const Fastest_Image<R>& rhs, Fastest_Image<O>& output)
{
mln_pixter(const L) lp(exact(lhs));
mln_pixter(const R) rp(exact(rhs));
@@ -106,7 +106,7 @@
}
template <typename L, typename R>
- void minus_inplace_(Fast_Image<L>& lhs, const Fast_Image<R>& rhs)
+ void minus_inplace_(Fastest_Image<L>& lhs, const Fastest_Image<R>& rhs)
{
mln_pixter(L) lp(exact(lhs));
mln_pixter(const R) rp(exact(rhs));
Index: mln/level/take.hh
--- mln/level/take.hh (revision 1248)
+++ mln/level/take.hh (working copy)
@@ -72,7 +72,7 @@
}
template <typename A, typename I>
- void take(const Fast_Image<I>& input_, A& a)
+ void take(const Fastest_Image<I>& input_, A& a)
{
const I& input = exact(input_);
mln_pixter(const I) pxl(input);
Index: mln/level/assign.hh
--- mln/level/assign.hh (revision 1248)
+++ mln/level/assign.hh (working copy)
@@ -75,7 +75,7 @@
}
template <typename L, typename R>
- void assign(Fast_Image<L>& target_, const Fast_Image<R>& data_)
+ void assign(Fastest_Image<L>& target_, const Fastest_Image<R>& data_)
{
L& target = exact(target_);
const R& data = exact(data_);
Index: mln/level/apply.hh
--- mln/level/apply.hh (revision 1248)
+++ mln/level/apply.hh (working copy)
@@ -76,7 +76,7 @@
}
template <typename I, typename F>
- void apply_(Fast_Image<I>& input_, const F& f)
+ void apply_(Fastest_Image<I>& input_, const F& f)
{
I& input = exact(input_);
mln_pixter(I) pxl(input);
Index: mln/level/fill.hh
--- mln/level/fill.hh (revision 1248)
+++ mln/level/fill.hh (working copy)
@@ -32,7 +32,7 @@
*
* \brief Fill an image, that is, set pixel values.
*
- * \todo Re-organize this file contents + Overload for fast images.
+ * \todo Re-organize this file contents + Overload for fastest images.
*/
# include <cstring>
@@ -141,7 +141,7 @@
}
template <typename I>
- void fill_with_value(Fast_Image<I>& ima_, const mln_value(I)& value)
+ void fill_with_value(Fastest_Image<I>& ima_, const mln_value(I)& value)
{
I& ima = exact(ima_);
level::memset_(ima, ima.point_at_offset(0), value, ima.ncells());
Index: mln/level/memcpy_.hh
--- mln/level/memcpy_.hh (revision 1248)
+++ mln/level/memcpy_.hh (working copy)
@@ -30,12 +30,12 @@
/*! \file mln/level/memcpy_.hh
*
- * \brief Same as std::memcpy but for fast images.
+ * \brief Same as std::memcpy but for fastest images.
*
* \todo Overload with images and points; Cf. memset_.
*/
-# include <mln/core/concept/fast_image.hh>
+# include <mln/core/concept/image.hh>
# include <mln/core/pixel.hh>
Index: mln/level/memset_.hh
--- mln/level/memset_.hh (revision 1248)
+++ mln/level/memset_.hh (working copy)
@@ -30,10 +30,10 @@
/*! \file mln/level/memset_.hh
*
- * \brief Same as std::memset but for fast images.
+ * \brief Same as std::memset but for fastest images.
*/
-# include <mln/core/concept/fast_image.hh>
+# include <mln/core/concept/image.hh>
# include <mln/core/pixel.hh>
@@ -66,7 +66,7 @@
* \pre \p input has to be initialized. FIXME: More.
*/
template <typename I>
- void memset_(Fast_Image<I>& input, const mln_point(I)& p,
+ void memset_(Fastest_Image<I>& input, const mln_point(I)& p,
const mln_value(I)& v, std::size_t n);
@@ -111,7 +111,7 @@
}
template <typename I>
- void memset_(Fast_Image<I>& input_, const mln_point(I)& p,
+ void memset_(Fastest_Image<I>& input_, const mln_point(I)& p,
const mln_value(I)& v, std::size_t n)
{
I& input = exact(input_);
Index: mln/level/median.hh
--- mln/level/median.hh (revision 1248)
+++ mln/level/median.hh (working copy)
@@ -32,7 +32,7 @@
*
* \brief Median filtering of an image.
*
- * \todo Add Fast_Image versions.
+ * \todo Add Fastest_Image versions.
*/
# include <mln/core/concept/image.hh>
Index: mln/level/paste.spe.hh
--- mln/level/paste.spe.hh (revision 1247)
+++ mln/level/paste.spe.hh (working copy)
@@ -25,60 +25,37 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_LEVEL_PASTE_HH
-# define MLN_LEVEL_PASTE_HH
+#ifndef MLN_LEVEL_PASTE_SPE_HH
+# define MLN_LEVEL_PASTE_SPE_HH
-/*! \file mln/level/paste.hh
+/*! \file mln/level/paste.spe.hh
*
- * \brief Paste the contents of an image into another one.
+ * \brief Specializations for mln::level::paste.
*/
-# include <mln/core/concept/image.hh>
-# include <mln/core/inplace.hh>
# include <mln/level/memcpy_.hh>
+
+# ifndef MLN_INCLUDE_ONLY
+
namespace mln
{
namespace level
{
- /*! Paste the contents of image \p data into the image \p
- * destination.
- *
- * \param[in] data The input image providing pixels values.
- * \param[in,out] destination The image in which values are
- * assigned.
- *
- * This routine runs: \n
- * for all p of \p data, \p destination(p) = \p data(p).
- *
- * \warning The definition domain of \p data has to be included in
- * the one of \p destination; so using mln::safe_image does not
- * make pasting outside the destination domain work.
- *
- * \pre \p data.domain <= \p destination.domain
- */
- template <typename I, typename J>
- void paste(const Image<I>& data, Image<J>& destination);
-
-
-# ifndef MLN_INCLUDE_ONLY
-
namespace impl
{
- template <typename I, typename J>
- void paste_generic_(const I& data, J& destination)
+
+ namespace generic
{
- trace::entering("level::impl::paste_generic_");
- mln_piter(I) p(data.domain());
- for_all(p)
- destination(p) = data(p);
- trace::exiting("level::impl::paste_generic_");
+ template <typename I, typename J>
+ void paste_(const I& data, J& destination);
}
+
template <typename I, typename J>
void paste_lines_(const I& data, J& destination)
{
@@ -96,13 +73,16 @@
trace::exiting("level::impl::paste_lines_");
}
+
// Disjunction.
+ // Remember: raw < linear < stored, computed.
+
template <typename I, typename J>
void paste_(mln::trait::data::any, const I& data,
mln::trait::data::any, J& destination)
{
- paste_generic_(data, destination);
+ generic::paste_(data, destination);
}
template <typename I, typename J>
@@ -112,36 +92,17 @@
if (sizeof(mln_value(I)) = sizeof(mln_value(J)))
paste_lines_(data, destination);
else
- paste_generic_(data, destination);
+ generic::paste_(data, destination);
}
- } // end of namespace mln::level::impl
-
- // Facade.
-
- template <typename I, typename J>
- void paste(const Image<I>& data_, Image<J>& destination_)
- {
- trace::entering("level::paste");
- mlc_is(mln_trait_image_io(J), trait::io::write)::check();
- mlc_converts_to(mln_value(I), mln_value(J))::check();
-
- const I& data = exact(data_);
- J& destination = exact(destination_);
- mln_precondition(data.domain() <= destination.domain());
-
- // Remember: raw < linear < stored, computed.
- impl::paste_(mln_trait_image_data(I)(), data,
- mln_trait_image_data(J)(), destination);
- trace::exiting("level::paste");
- }
-
-# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace mln::level::impl
} // end of namespace mln::level
} // end of namespace mln
+# endif // ! MLN_INCLUDE_ONLY
+
#endif // ! MLN_LEVEL_PASTE_HH
Index: mln/level/transform.hh
--- mln/level/transform.hh (revision 1248)
+++ mln/level/transform.hh (working copy)
@@ -100,7 +100,7 @@
// template <typename I, typename F, typename O>
// void transform(metal::true_, // low quantization
-// const Fast_Image<I>& input_, const Function_v2v<F>& f_, Image<O>& output_)
+// const Fastest_Image<I>& input_, const Function_v2v<F>& f_, Image<O>& output_)
// {
// const I& input = exact(input_);
// const F& f = exact(f_);
Index: mln/level/paste.hh
--- mln/level/paste.hh (revision 1248)
+++ mln/level/paste.hh (working copy)
@@ -35,7 +35,11 @@
# include <mln/core/concept/image.hh>
# include <mln/core/inplace.hh>
-# include <mln/level/memcpy_.hh>
+
+
+// Specializations are in:
+# include <mln/level/paste.spe.hh>
+
namespace mln
@@ -64,56 +68,28 @@
void paste(const Image<I>& data, Image<J>& destination);
+
# ifndef MLN_INCLUDE_ONLY
namespace impl
{
- template <typename I, typename J>
- void paste_generic_(const I& data, J& destination)
+ namespace generic
{
- trace::entering("level::impl::paste_generic_");
- mln_piter(I) p(data.domain());
- for_all(p)
- destination(p) = data(p);
- trace::exiting("level::impl::paste_generic_");
- }
template <typename I, typename J>
- void paste_lines_(const I& data, J& destination)
+ void paste_(const I& data, J& destination)
{
- trace::entering("level::impl::paste_lines_");
- typedef mln_point(I) P;
- std::size_t n = data.bbox().len(P::dim - 1);
- // FIXME: Works only for raw data images
- // FIXME: For linear data images, we should get the len for each line...
+ trace::entering("level::impl::generic::paste_");
- typename I::line_piter p(data.domain()); // FIXME: Alias mln_line_piter!
+ mln_piter(I) p(data.domain());
for_all(p)
- memcpy_(inplace(make::pixel(destination, p)),
- make::pixel(data, p),
- n);
- trace::exiting("level::impl::paste_lines_");
- }
-
- // Disjunction.
+ destination(p) = data(p);
- template <typename I, typename J>
- void paste_(mln::trait::data::any, const I& data,
- mln::trait::data::any, J& destination)
- {
- paste_generic_(data, destination);
+ trace::exiting("level::impl::generic::paste_");
}
- template <typename I, typename J>
- void paste_(mln::trait::data::raw, const I& data,
- mln::trait::data::raw, J& destination)
- {
- if (sizeof(mln_value(I)) = sizeof(mln_value(J)))
- paste_lines_(data, destination);
- else
- paste_generic_(data, destination);
- }
+ } // end of namespace mln::level::impl::generic
} // end of namespace mln::level::impl
@@ -123,17 +99,17 @@
template <typename I, typename J>
void paste(const Image<I>& data_, Image<J>& destination_)
{
+ const I& data = exact(data_);
+ J& destination = exact(destination_);
trace::entering("level::paste");
+
mlc_is(mln_trait_image_io(J), trait::io::write)::check();
mlc_converts_to(mln_value(I), mln_value(J))::check();
-
- const I& data = exact(data_);
- J& destination = exact(destination_);
mln_precondition(data.domain() <= destination.domain());
- // Remember: raw < linear < stored, computed.
impl::paste_(mln_trait_image_data(I)(), data,
mln_trait_image_data(J)(), destination);
+
trace::exiting("level::paste");
}
@@ -144,4 +120,5 @@
} // end of namespace mln
+
#endif // ! MLN_LEVEL_PASTE_HH
Index: mln/linear/convolve.hh
--- mln/linear/convolve.hh (revision 1248)
+++ mln/linear/convolve.hh (working copy)
@@ -87,8 +87,8 @@
}
template <typename I, typename W, typename O>
- void convolve_(const Fast_Image<I>& input_, const Weighted_Window<W>& w_win_,
- Fast_Image<O>& output_)
+ void convolve_(const Fastest_Image<I>& input_, const Weighted_Window<W>& w_win_,
+ Fastest_Image<O>& output_)
{
const I& input = exact(input_);
const W& w_win = exact(w_win_);
Index: mln/linear/local/convolve.hh
--- mln/linear/local/convolve.hh (revision 1248)
+++ mln/linear/local/convolve.hh (working copy)
@@ -103,7 +103,7 @@
}
template <typename I, typename P, typename W, typename R>
- void convolve(const Fast_Image<I>& input_,
+ void convolve(const Fastest_Image<I>& input_,
const Generalized_Point<P>& p_,
const W& w_win,
R& result)
Index: mln/accu/take.hh
--- mln/accu/take.hh (revision 1248)
+++ mln/accu/take.hh (working copy)
@@ -75,7 +75,7 @@
a.take(make::pix(input, p));
}
- // FIXME: We need an impl for pixels of fast images.
+ // FIXME: We need an impl for pixels of fastest images.
} // end of namespace mln::accu::impl
Index: mln/border/resize.hh
--- mln/border/resize.hh (revision 1248)
+++ mln/border/resize.hh (working copy)
@@ -57,13 +57,13 @@
* \todo Implement it.
*/
template <typename I>
- void resize(const Fast_Image<I>& ima, unsigned thickness);
+ void resize(const Fastest_Image<I>& ima, unsigned thickness);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
- void resize(const Fast_Image<I>& ima_, unsigned thickness)
+ void resize(const Fastest_Image<I>& ima_, unsigned thickness)
{
const I& ima = exact(ima_);
mln_precondition(ima.has_data());
Index: mln/border/fill.hh
--- mln/border/fill.hh (revision 1248)
+++ mln/border/fill.hh (working copy)
@@ -53,7 +53,7 @@
* \todo Implement it + optimize with memset if possible.
*/
template <typename I>
- void fill(const Fast_Image<I>& ima, const mln_value(I)& v);
+ void fill(const Fastest_Image<I>& ima, const mln_value(I)& v);
# ifndef MLN_INCLUDE_ONLY
@@ -61,7 +61,7 @@
{
template <typename I>
- void fill_size_1_(const Fast_Image<I>& ima_, const mln_value(I)& v)
+ void fill_size_1_(const Fastest_Image<I>& ima_, const mln_value(I)& v)
{
typedef mln_point(I) P;
const I& ima = exact(ima_);
@@ -84,7 +84,7 @@
}
template <typename I>
- void fill_size_n_(const Fast_Image<I>& ima_, const mln_value(I)& v)
+ void fill_size_n_(const Fastest_Image<I>& ima_, const mln_value(I)& v)
{
typedef mln_point(I) P;
const I& ima = exact(ima_);
@@ -108,7 +108,7 @@
// Facade.
template <typename I>
- void fill(const Fast_Image<I>& ima_, const mln_value(I)& v)
+ void fill(const Fastest_Image<I>& ima_, const mln_value(I)& v)
{
trace::entering("border::fill");
typedef mln_point(I) P;
Index: mln/border/duplicate.hh
--- mln/border/duplicate.hh (revision 1248)
+++ mln/border/duplicate.hh (working copy)
@@ -55,7 +55,7 @@
* \todo Implement it + optimize with memcpy if possible.
*/
template <typename I>
- void duplicate(const Fast_Image<I>& ima);
+ void duplicate(const Fastest_Image<I>& ima);
# ifndef MLN_INCLUDE_ONLY
@@ -64,7 +64,7 @@
{
template <typename I>
- void duplicate_1d_(const Fast_Image<I>& ima_)
+ void duplicate_1d_(const Fastest_Image<I>& ima_)
{
const I& ima = exact(ima_);
mln_precondition(ima.has_data());
@@ -83,7 +83,7 @@
}
template <typename I>
- void duplicate_2d_(const Fast_Image<I>& ima_)
+ void duplicate_2d_(const Fastest_Image<I>& ima_)
{
const I& ima = exact(ima_);
mln_precondition(ima.has_data());
@@ -122,7 +122,7 @@
}
template <typename I>
- void duplicate_3d_(const Fast_Image<I>& ima_)
+ void duplicate_3d_(const Fastest_Image<I>& ima_)
{
const I& ima = exact(ima_);
mln_precondition(ima.has_data());
@@ -190,7 +190,7 @@
// Facade.
template <typename I>
- void duplicate(const Fast_Image<I>& ima_)
+ void duplicate(const Fastest_Image<I>& ima_)
{
trace::entering("border::duplicate");
typedef mln_point(I) P;
Index: mln/border/mirror.hh
--- mln/border/mirror.hh (revision 1248)
+++ mln/border/mirror.hh (working copy)
@@ -53,13 +53,13 @@
* \todo Implement it + optimize with memset if possible.
*/
template <typename I>
- void mirror(const Fast_Image<I>& ima);
+ void mirror(const Fastest_Image<I>& ima);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
- void mirror(const Fast_Image<I>& ima_)
+ void mirror(const Fastest_Image<I>& ima_)
{
const I& ima = exact(ima_);
mln_precondition(ima.has_data());
Index: mln/border/get.hh
--- mln/border/get.hh (revision 1248)
+++ mln/border/get.hh (working copy)
@@ -75,7 +75,7 @@
}
template <typename I>
- unsigned get_(const Fast_Image<I>& ima)
+ unsigned get_(const Fastest_Image<I>& ima)
{
return exact(ima).border();
}
Index: mln/test/predicate.hh
--- mln/test/predicate.hh (revision 1248)
+++ mln/test/predicate.hh (working copy)
@@ -80,7 +80,7 @@
}
template <typename I, typename F>
- bool predicate_(const Fast_Image<I>& ima_, const F& f)
+ bool predicate_(const Fastest_Image<I>& ima_, const F& f)
{
const I& ima = exact(ima_);
mln_pixter(const I) pxl(ima);
Index: mln/morpho/erosion_fast.hh
--- mln/morpho/erosion_fast.hh (revision 1248)
+++ mln/morpho/erosion_fast.hh (working copy)
@@ -32,7 +32,7 @@
*
* \brief Ero filtering of an image.
*
- * \todo Add Fast_Image versions.
+ * \todo Add Fastest_Image versions.
*/
# include <mln/core/concept/image.hh>
Index: mln/morpho/dilation_fast.hh
--- mln/morpho/dilation_fast.hh (revision 1248)
+++ mln/morpho/dilation_fast.hh (working copy)
@@ -32,7 +32,7 @@
*
* \brief Ero filtering of an image.
*
- * \todo Add Fast_Image versions.
+ * \todo Add Fastest_Image versions.
*/
# include <mln/core/concept/image.hh>
Index: mln/io/internal/pnm/save.hh
--- mln/io/internal/pnm/save.hh (revision 1248)
+++ mln/io/internal/pnm/save.hh (working copy)
@@ -93,7 +93,7 @@
file.write((char*)(&c), sizeof(E));
}
- // save data for (sizeof(int_u8) != 1) and non fast images
+ // save data for (sizeof(int_u8) != 1) and non fastest images
template <typename I>
void save_data_uncontiguous(std::ofstream& file,
const Image< I >& ima_)
@@ -112,11 +112,11 @@
write_value(file, ima(p));
}
- // save data when (sizeof(int_u8) = 1) with fast images
+ // save data when (sizeof(int_u8) = 1) with fastest images
// (faster)
template <typename I>
void save_data_contiguous(std::ofstream& file,
- const Fast_Image<I>& ima_)
+ const Fastest_Image<I>& ima_)
{
const I& ima = exact(ima_);
const int
@@ -130,10 +130,10 @@
}
- // caller for fast images
+ // caller for fastest images
template <typename I>
void save_data(std::ofstream& file,
- const Fast_Image<I>& ima)
+ const Fastest_Image<I>& ima)
{
if (sizeof(value::int_u8) = 1)
save_data_contiguous(file, ima);
@@ -141,7 +141,7 @@
save_data_uncontiguous(file, ima);
}
- // caller for non fast images
+ // caller for non fastest images
template <typename I>
void save_data(std::ofstream& file,
const Image<I>& ima)
Index: mln/logical/and.hh
--- mln/logical/and.hh (revision 1248)
+++ mln/logical/and.hh (working copy)
@@ -88,7 +88,7 @@
}
template <typename L, typename R, typename O>
- void and__(const Fast_Image<L>& lhs, const Fast_Image<R>& rhs, Fast_Image<O>& output)
+ void and__(const Fastest_Image<L>& lhs, const Fastest_Image<R>& rhs, Fastest_Image<O>& output)
{
mln_pixter(const L) lp(exact(lhs));
mln_pixter(const R) rp(exact(rhs));
Index: mln/logical/and_not.hh
--- mln/logical/and_not.hh (revision 1248)
+++ mln/logical/and_not.hh (working copy)
@@ -88,7 +88,7 @@
}
template <typename L, typename R, typename O>
- void and_not_(const Fast_Image<L>& lhs, const Fast_Image<R>& rhs, Fast_Image<O>& output)
+ void and_not_(const Fastest_Image<L>& lhs, const Fastest_Image<R>& rhs, Fastest_Image<O>& output)
{
mln_pixter(const L) lp(exact(lhs));
mln_pixter(const R) rp(exact(rhs));
Index: mln/logical/or.hh
--- mln/logical/or.hh (revision 1248)
+++ mln/logical/or.hh (working copy)
@@ -88,7 +88,7 @@
}
template <typename L, typename R, typename O>
- void or__(const Fast_Image<L>& lhs, const Fast_Image<R>& rhs, Fast_Image<O>& output)
+ void or__(const Fastest_Image<L>& lhs, const Fastest_Image<R>& rhs, Fastest_Image<O>& output)
{
mln_pixter(const L) lp(exact(lhs));
mln_pixter(const R) rp(exact(rhs));
Index: mln/logical/not.hh
--- mln/logical/not.hh (revision 1248)
+++ mln/logical/not.hh (working copy)
@@ -83,7 +83,7 @@
}
template <typename I, typename O>
- void not__(const Fast_Image<I>& input, Fast_Image<O>& output)
+ void not__(const Fastest_Image<I>& input, Fastest_Image<O>& output)
{
mln_pixter(const I) ip(exact(input));
mln_pixter(O) op(exact(output));
Index: mln/labeling/level.hh
--- mln/labeling/level.hh (revision 1248)
+++ mln/labeling/level.hh (working copy)
@@ -34,7 +34,7 @@
* level.
*/
-# include <mln/core/concept/fast_image.hh>
+# include <mln/core/concept/image.hh>
# include <mln/labeling/base.hh>
# include <mln/level/fill.hh>
@@ -62,8 +62,8 @@
Image<O>& output, unsigned& nlabels);
template <typename I, typename N, typename O>
- bool level_fast(const Fast_Image<I>& input, const mln_value(I)& val, const Neighborhood<N>& nbh,
- Fast_Image<O>& output, unsigned& nlabels);
+ bool level_fast(const Fastest_Image<I>& input, const mln_value(I)& val, const Neighborhood<N>& nbh,
+ Fastest_Image<O>& output, unsigned& nlabels);
# ifndef MLN_INCLUDE_ONLY
@@ -83,7 +83,7 @@
typedef mln_pset(I_) S;
const S& s;
- void init() { mln::level::fill(this->output, 0); }
+ void init() { mln::level::fill(this->output, 0); } // FIXME: use literal::zero
bool handles(const P& p) const { return input(p) = val; }
bool equiv(const P& n, const P&) const { return input(n) = val; }
@@ -121,7 +121,7 @@
// typedef mln_pset(I_) S;
// const S& s;
- void init() { level::fill(this->output, 0); }
+ void init() { mln::level::fill(this->output, 0); }
bool handles(unsigned p) const { return this->input[p] = val; }
bool equiv(unsigned n, unsigned) const { return this->input[n] = val; }
@@ -136,8 +136,8 @@
template <typename I, typename N, typename O>
- bool level_fast_(const Fast_Image<I>& input, const mln_value(I)& val, const Neighborhood<N>& nbh,
- Fast_Image<O>& output, unsigned& nlabels)
+ bool level_fast_(const Fastest_Image<I>& input, const mln_value(I)& val, const Neighborhood<N>& nbh,
+ Fastest_Image<O>& output, unsigned& nlabels)
{
typedef level_fast_t<I,N,O> F;
F f(exact(input), val, exact(nbh), exact(output));
@@ -161,8 +161,8 @@
}
template <typename I, typename N, typename O>
- bool level_fast(const Fast_Image<I>& input, const mln_value(I)& val, const Neighborhood<N>& nbh,
- Fast_Image<O>& output, unsigned& nlabels)
+ bool level_fast(const Fastest_Image<I>& input, const mln_value(I)& val, const Neighborhood<N>& nbh,
+ Fastest_Image<O>& output, unsigned& nlabels)
{
mln_precondition(exact(output).domain() = exact(input).domain());
return impl::level_fast_(exact(input), val, nbh, output, nlabels);
Index: mln/labeling/base.hh
--- mln/labeling/base.hh (revision 1248)
+++ mln/labeling/base.hh (working copy)
@@ -84,7 +84,7 @@
};
- /// Base class for labeling functors on fast images.
+ /// Base class for labeling functors on fastest images.
template <typename I_, typename N_, typename O_>
struct base_fast_
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-04 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Rename x variables into t in accumulators.
* mln/accu/count.hh,
* mln/accu/histo.hh,
* mln/accu/max.hh,
* mln/accu/max_h.hh,
* mln/accu/mean.hh,
* mln/accu/median.hh,
* mln/accu/median_alt.hh,
* mln/accu/min.hh,
* mln/accu/min_h.hh,
* mln/accu/p.hh,
* mln/accu/pair.hh,
* mln/accu/sum.hh,
* mln/accu/v.hh,
* mln/core/concept/accumulator.hh,
* mln/core/concept/doc/accumulator.hh: Rename.
* tests/value_float01.cc: Fix warnings.
---
mln/accu/count.hh | 36 +++++++++---------
mln/accu/histo.hh | 20 +++++-----
mln/accu/max.hh | 64 ++++++++++++++++----------------
mln/accu/max_h.hh | 42 ++++++++++-----------
mln/accu/mean.hh | 50 ++++++++++++-------------
mln/accu/median.hh | 32 ++++++++--------
mln/accu/median_alt.hh | 42 ++++++++++-----------
mln/accu/min.hh | 72 ++++++++++++++++++------------------
mln/accu/min_h.hh | 42 ++++++++++-----------
mln/accu/p.hh | 12 +++---
mln/accu/pair.hh | 62 +++++++++++++++----------------
mln/accu/sum.hh | 40 ++++++++++----------
mln/accu/v.hh | 12 +++---
mln/core/concept/accumulator.hh | 2 -
mln/core/concept/doc/accumulator.hh | 4 +-
tests/value_float01.cc | 8 ++--
16 files changed, 270 insertions(+), 270 deletions(-)
Index: trunk/milena/tests/value_float01.cc
===================================================================
--- trunk/milena/tests/value_float01.cc (revision 1247)
+++ trunk/milena/tests/value_float01.cc (revision 1248)
@@ -48,11 +48,11 @@
using namespace mln::value;
using mln::value::int_u8;
-float fi(int x) { return 0.5; }
-int ii(int x) { return 1; }
+float fi(int) { return 0.5; }
+int ii(int) { return 1; }
-float fd(double x) { return 0.5; }
-int id(double x) { return 1; }
+float fd(double) { return 0.5; }
+int id(double) { return 1; }
struct tofloat01 : mln::Function_v2v<tofloat01>
Index: trunk/milena/mln/core/concept/doc/accumulator.hh
===================================================================
--- trunk/milena/mln/core/concept/doc/accumulator.hh (revision 1247)
+++ trunk/milena/mln/core/concept/doc/accumulator.hh (revision 1248)
@@ -50,8 +50,8 @@
/// Initialize the accumulator.
void init();
- /// Take into account a argument \p x (an element).
- void take(const argument& x);
+ /// Take into account a argument \p t (an element).
+ void take(const argument& t);
/// Take into account another accumulator \p other.
void take(const E& other);
Index: trunk/milena/mln/core/concept/accumulator.hh
===================================================================
--- trunk/milena/mln/core/concept/accumulator.hh (revision 1247)
+++ trunk/milena/mln/core/concept/accumulator.hh (revision 1248)
@@ -68,7 +68,7 @@
typedef argument;
typedef result;
void init();
- void take(const argument& x);
+ void take(const argument& t);
void take(const E& other);
result to_result() const;
operator result_() const;
Index: trunk/milena/mln/accu/min.hh
===================================================================
--- trunk/milena/mln/accu/min.hh (revision 1247)
+++ trunk/milena/mln/accu/min.hh (revision 1248)
@@ -48,26 +48,26 @@
/*! Generic min accumulator class.
*
- * The parameter \c V is the type of values.
+ * The parameter \c T is the type of values.
*/
- template <typename V>
- struct min_ : public mln::accu::internal::base_< V, min_<V> >
+ template <typename T>
+ struct min_ : public mln::accu::internal::base_< T, min_<T> >
{
- typedef V argument;
- typedef V result;
+ typedef T argument;
+ typedef T result;
min_();
void init();
- void take_as_init(const argument& x);
- void take(const argument& x);
- void take(const min_<V>& other);
+ void take_as_init(const argument& t);
+ void take(const argument& t);
+ void take(const min_<T>& other);
- V to_result() const;
+ T to_result() const;
protected:
- V x_;
+ T t_;
};
@@ -77,10 +77,10 @@
// FIXME: Doc!
struct min : public Meta_Accumulator< min >
{
- template <typename V>
+ template <typename T>
struct with
{
- typedef min_<V> ret;
+ typedef min_<T> ret;
};
};
@@ -88,17 +88,17 @@
// // FIXME: Sample code.
-// template <typename V>
-// struct p_min_ : public p_< min_<V> >
+// template <typename T>
+// struct p_min_ : public p_< min_<T> >
// {
// };
// struct p_min : public Meta_Accumulator< p_min >
// {
-// template <typename V>
+// template <typename T>
// struct with
// {
-// typedef p_min_<V> ret;
+// typedef p_min_<T> ret;
// };
// };
@@ -106,45 +106,45 @@
# ifndef MLN_INCLUDE_ONLY
- template <typename V>
- min_<V>::min_()
+ template <typename T>
+ min_<T>::min_()
{
init();
}
- template <typename V>
+ template <typename T>
void
- min_<V>::init()
+ min_<T>::init()
{
- x_ = mln_max(V);
+ t_ = mln_max(T);
}
- template <typename V>
- void min_<V>::take_as_init(const argument& x)
+ template <typename T>
+ void min_<T>::take_as_init(const argument& t)
{
- x_ = x;
+ t_ = t;
}
- template <typename V>
- void min_<V>::take(const argument& x)
+ template <typename T>
+ void min_<T>::take(const argument& t)
{
- if (x < x_)
- x_ = x;
+ if (t < t_)
+ t_ = t;
}
- template <typename V>
+ template <typename T>
void
- min_<V>::take(const min_<V>& other)
+ min_<T>::take(const min_<T>& other)
{
- if (other.x_ < x_)
- x_ = other.x_;
+ if (other.t_ < t_)
+ t_ = other.t_;
}
- template <typename V>
- V
- min_<V>::to_result() const
+ template <typename T>
+ T
+ min_<T>::to_result() const
{
- return x_;
+ return t_;
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/accu/max.hh
===================================================================
--- trunk/milena/mln/accu/max.hh (revision 1247)
+++ trunk/milena/mln/accu/max.hh (revision 1248)
@@ -47,26 +47,26 @@
/*! Generic max accumulator class.
*
- * The parameter \c V is the type of values.
+ * The parameter \c T is the type of values.
*/
- template <typename V>
- struct max_ : public mln::accu::internal::base_< V , max_<V> >
+ template <typename T>
+ struct max_ : public mln::accu::internal::base_< T , max_<T> >
{
- typedef V argument;
- typedef V result;
+ typedef T argument;
+ typedef T result;
max_();
void init();
- void take_as_init(const argument& x);
- void take(const argument& x);
- void take(const max_<V>& other);
+ void take_as_init(const argument& t);
+ void take(const argument& t);
+ void take(const max_<T>& other);
- V to_result() const;
+ T to_result() const;
protected:
- V x_;
+ T t_;
};
@@ -76,10 +76,10 @@
// FIXME: Doc!
struct max : public Meta_Accumulator< max >
{
- template <typename V>
+ template <typename T>
struct with
{
- typedef max_<V> ret;
+ typedef max_<T> ret;
};
};
@@ -87,47 +87,47 @@
# ifndef MLN_INCLUDE_ONLY
- template <typename V>
- max_<V>::max_()
+ template <typename T>
+ max_<T>::max_()
{
init();
}
- template <typename V>
+ template <typename T>
void
- max_<V>::init()
+ max_<T>::init()
{
- x_ = mln_min(V);
+ t_ = mln_min(T);
}
- template <typename V>
+ template <typename T>
void
- max_<V>::take_as_init(const argument& x)
+ max_<T>::take_as_init(const argument& t)
{
- x_ = x;
+ t_ = t;
}
- template <typename V>
+ template <typename T>
void
- max_<V>::take(const argument& x)
+ max_<T>::take(const argument& t)
{
- if (x > x_)
- x_ = x;
+ if (t > t_)
+ t_ = t;
}
- template <typename V>
+ template <typename T>
void
- max_<V>::take(const max_<V>& other)
+ max_<T>::take(const max_<T>& other)
{
- if (other.x_ > x_)
- x_ = other.x_;
+ if (other.t_ > t_)
+ t_ = other.t_;
}
- template <typename V>
- V
- max_<V>::to_result() const
+ template <typename T>
+ T
+ max_<T>::to_result() const
{
- return x_;
+ return t_;
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/accu/histo.hh
===================================================================
--- trunk/milena/mln/accu/histo.hh (revision 1247)
+++ trunk/milena/mln/accu/histo.hh (revision 1248)
@@ -61,12 +61,12 @@
typedef mln_value(S) argument;
typedef const std::vector<std::size_t>& result;
- void take(const argument& x);
+ void take(const argument& t);
void take(const histo<S>& other);
- void untake(const argument& x);
+ void untake(const argument& t);
void init();
- std::size_t operator()(const argument& x) const;
+ std::size_t operator()(const argument& t) const;
std::size_t operator[](std::size_t i) const;
std::size_t nvalues() const;
std::size_t sum() const;
@@ -110,9 +110,9 @@
template <typename S>
void
- histo<S>::take(const argument& x)
+ histo<S>::take(const argument& t)
{
- ++h_[s_.index_of(x)];
+ ++h_[s_.index_of(t)];
++sum_;
}
@@ -127,11 +127,11 @@
template <typename S>
void
- histo<S>::untake(const argument& x)
+ histo<S>::untake(const argument& t)
{
- mln_precondition(h_[s_.index_of(x)] > 0);
+ mln_precondition(h_[s_.index_of(t)] > 0);
mln_precondition(sum_ > 0);
- --h_[s_.index_of(x)];
+ --h_[s_.index_of(t)];
--sum_;
}
@@ -145,9 +145,9 @@
template <typename S>
std::size_t
- histo<S>::operator()(const argument& x) const
+ histo<S>::operator()(const argument& t) const
{
- return h_[s_.index_of(x)];
+ return h_[s_.index_of(t)];
}
template <typename S>
Index: trunk/milena/mln/accu/count.hh
===================================================================
--- trunk/milena/mln/accu/count.hh (revision 1247)
+++ trunk/milena/mln/accu/count.hh (revision 1248)
@@ -46,17 +46,17 @@
/*! Generic counter accumulator class.
*/
- template <typename V>
- struct count_ : public mln::accu::internal::base_< std::size_t , count_<V> >
+ template <typename T>
+ struct count_ : public mln::accu::internal::base_< std::size_t , count_<T> >
{
- typedef V argument;
+ typedef T argument;
typedef std::size_t result; // FIXME: Up in Accumulator.
count_();
void init();
void take(const argument&);
- void take(const count_<V>& other);
+ void take(const count_<T>& other);
std::size_t to_result() const;
void set_value(std::size_t c);
@@ -70,53 +70,53 @@
// FIXME: Doc!
struct count : public Meta_Accumulator< count >
{
- template <typename V>
+ template <typename T>
struct with
{
- typedef count_<V> ret;
+ typedef count_<T> ret;
};
};
# ifndef MLN_INCLUDE_ONLY
- template <typename V>
- count_<V>::count_()
+ template <typename T>
+ count_<T>::count_()
{
init();
}
- template <typename V>
+ template <typename T>
void
- count_<V>::init()
+ count_<T>::init()
{
count__ = 0;
}
- template <typename V>
+ template <typename T>
void
- count_<V>::take(const argument&)
+ count_<T>::take(const argument&)
{
++count__;
}
- template <typename V>
+ template <typename T>
void
- count_<V>::take(const count_<V>& other)
+ count_<T>::take(const count_<T>& other)
{
count__ += other.count__;
}
- template <typename V>
+ template <typename T>
std::size_t
- count_<V>::to_result() const
+ count_<T>::to_result() const
{
return count__;
}
- template <typename V>
+ template <typename T>
void
- count_<V>::set_value(std::size_t c)
+ count_<T>::set_value(std::size_t c)
{
count__ = c;
}
Index: trunk/milena/mln/accu/min_h.hh
===================================================================
--- trunk/milena/mln/accu/min_h.hh (revision 1247)
+++ trunk/milena/mln/accu/min_h.hh (revision 1248)
@@ -57,10 +57,10 @@
min_h();
void init();
- void take(const argument& x);
- void take_as_init(const argument& x);
+ void take(const argument& t);
+ void take_as_init(const argument& t);
void take(const min_h<S>& other);
- void untake(const argument& x);
+ void untake(const argument& t);
unsigned card() const { return h_.sum(); }
@@ -76,7 +76,7 @@
mutable std::size_t sum_;
mutable bool valid_;
mutable std::size_t i_; // the min index
- mutable argument x_; // the min value
+ mutable argument t_; // the min value
// Auxiliary methods
void update_() const;
@@ -105,15 +105,15 @@
template <typename S>
void
- min_h<S>::take(const argument& x)
+ min_h<S>::take(const argument& t)
{
- h_.take(x);
+ h_.take(t);
if (h_.sum() == 1)
{
- this->take_as_init(x);
+ this->take_as_init(t);
return;
}
- if (x < x_)
+ if (t < t_)
{
++sum_;
valid_ = false;
@@ -134,23 +134,23 @@
template <typename S>
void
- min_h<S>::untake(const argument& x)
+ min_h<S>::untake(const argument& t)
{
- mln_precondition(h_(x) != 0);
- h_.untake(x);
+ mln_precondition(h_(t) != 0);
+ h_.untake(t);
if (h_.sum() == 0)
{
init();
return;
}
- if (x < x_)
+ if (t < t_)
{
mln_invariant(sum_ >= 1);
--sum_;
valid_ = false;
}
else
- if (x == x_ && h_[i_] == 0)
+ if (t == t_ && h_[i_] == 0)
valid_ = false;
}
@@ -177,7 +177,7 @@
sum_ -= h_[i_];
}
while (sum_ != 0);
- x_ = s_[i_];
+ t_ = s_[i_];
}
template <typename S>
@@ -187,7 +187,7 @@
do
++i_;
while (h_[i_] == 0);
- x_ = s_[i_];
+ t_ = s_[i_];
}
template <typename S>
@@ -197,18 +197,18 @@
h_.init();
sum_ = 0;
i_ = mln_max(argument);
- x_ = s_[i_];
+ t_ = s_[i_];
valid_ = true;
}
template <typename S>
void
- min_h<S>::take_as_init(const argument& x)
+ min_h<S>::take_as_init(const argument& t)
{
- h_.take(x);
+ h_.take(t);
sum_ = 0;
- i_ = s_.index_of(x);
- x_ = x;
+ i_ = s_.index_of(t);
+ t_ = t;
valid_ = true;
}
@@ -218,7 +218,7 @@
{
if (! valid_)
update_();
- return x_;
+ return t_;
}
template <typename S>
Index: trunk/milena/mln/accu/pair.hh
===================================================================
--- trunk/milena/mln/accu/pair.hh (revision 1247)
+++ trunk/milena/mln/accu/pair.hh (revision 1248)
@@ -51,14 +51,14 @@
/*! Generic pair of accumulators.
*
- * The parameter \c V is the type of values.
+ * The parameter \c T is the type of values.
*
- * \todo Check that, when V is not provided, A1 and A2 have the same value.
+ * \todo Check that, when T is not provided, A1 and A2 have the same value.
*/
- template <typename A1, typename A2, typename V = mln_argument(A1)>
- struct pair_ : public mln::accu::internal::base_< std::pair< mlc_unqualif(mln_result(A1)) , mlc_unqualif(mln_result(A2)) > , pair_<A1,A2,V> >
+ template <typename A1, typename A2, typename T = mln_argument(A1)>
+ struct pair_ : public mln::accu::internal::base_< std::pair< mlc_unqualif(mln_result(A1)) , mlc_unqualif(mln_result(A2)) > , pair_<A1,A2,T> >
{
- typedef V argument;
+ typedef T argument;
typedef mlc_unqualif(mln_result(A1)) result_1;
typedef mlc_unqualif(mln_result(A2)) result_2;
@@ -68,9 +68,9 @@
pair_(const A1& a1, const A2& a2);
void init();
- void take_as_init(const argument& x);
- void take(const argument& x);
- void take(const pair_<A1,A2,V>& other);
+ void take_as_init(const argument& t);
+ void take(const argument& t);
+ void take(const pair_<A1,A2,T>& other);
result to_result() const;
void get_result(result_1& r1, result_2& r2) const;
@@ -87,67 +87,67 @@
template <typename A1, typename A2>
struct pair : public Meta_Accumulator< pair<A1,A2> >
{
- template <typename V>
+ template <typename T>
struct with
{
- typedef mln_accu_with(A1, V) A1_V;
- typedef mln_accu_with(A2, V) A2_V;
- typedef pair_<A1_V, A2_V, V> ret;
+ typedef mln_accu_with(A1, T) A1_T;
+ typedef mln_accu_with(A2, T) A2_T;
+ typedef pair_<A1_T, A2_T, T> ret;
};
};
# ifndef MLN_INCLUDE_ONLY
- template <typename A1, typename A2, typename V>
- pair_<A1,A2,V>::pair_()
+ template <typename A1, typename A2, typename T>
+ pair_<A1,A2,T>::pair_()
{
init();
}
- template <typename A1, typename A2, typename V>
+ template <typename A1, typename A2, typename T>
void
- pair_<A1,A2,V>::init()
+ pair_<A1,A2,T>::init()
{
a1_.init();
a2_.init();
}
- template <typename A1, typename A2, typename V>
+ template <typename A1, typename A2, typename T>
void
- pair_<A1,A2,V>::take_as_init(const argument& x)
+ pair_<A1,A2,T>::take_as_init(const argument& t)
{
- a1_.take_as_init(x);
- a2_.take_as_init(x);
+ a1_.take_as_init(t);
+ a2_.take_as_init(t);
}
- template <typename A1, typename A2, typename V>
+ template <typename A1, typename A2, typename T>
void
- pair_<A1,A2,V>::take(const argument& x)
+ pair_<A1,A2,T>::take(const argument& t)
{
- a1_.take(x);
- a2_.take(x);
+ a1_.take(t);
+ a2_.take(t);
}
- template <typename A1, typename A2, typename V>
+ template <typename A1, typename A2, typename T>
void
- pair_<A1,A2,V>::take(const pair_<A1,A2,V>& other)
+ pair_<A1,A2,T>::take(const pair_<A1,A2,T>& other)
{
a1_.take(other.a1_);
a2_.take(other.a2_);
}
- template <typename A1, typename A2, typename V>
- typename pair_<A1,A2,V>::result
- pair_<A1,A2,V>::to_result() const
+ template <typename A1, typename A2, typename T>
+ typename pair_<A1,A2,T>::result
+ pair_<A1,A2,T>::to_result() const
{
result tmp(a1_.to_result(), a2_.to_result());
return tmp;
}
- template <typename A1, typename A2, typename V>
+ template <typename A1, typename A2, typename T>
void
- pair_<A1,A2,V>::get_result(result_1& r1,
+ pair_<A1,A2,T>::get_result(result_1& r1,
result_2& r2) const
{
r1 = a1_.to_result();
Index: trunk/milena/mln/accu/max_h.hh
===================================================================
--- trunk/milena/mln/accu/max_h.hh (revision 1247)
+++ trunk/milena/mln/accu/max_h.hh (revision 1248)
@@ -57,10 +57,10 @@
max_h();
void init();
- void take(const argument& x);
- void take_as_init(const argument& x);
+ void take(const argument& t);
+ void take_as_init(const argument& t);
void take(const max_h<S>& other);
- void untake(const argument& x);
+ void untake(const argument& t);
unsigned card() const { return h_.sum(); }
@@ -76,7 +76,7 @@
mutable std::size_t sum_;
mutable bool valid_;
mutable std::size_t i_; // the max index
- mutable argument x_; // the max argument
+ mutable argument t_; // the max argument
// Auxiliary methods
void update_() const;
@@ -105,15 +105,15 @@
template <typename S>
void
- max_h<S>::take(const argument& x)
+ max_h<S>::take(const argument& t)
{
- h_.take(x);
+ h_.take(t);
if (h_.sum() == 1)
{
- this->take_as_init(x);
+ this->take_as_init(t);
return;
}
- if (x > x_)
+ if (t > t_)
{
++sum_;
valid_ = false;
@@ -134,23 +134,23 @@
template <typename S>
void
- max_h<S>::untake(const argument& x)
+ max_h<S>::untake(const argument& t)
{
- mln_precondition(h_(x) != 0);
- h_.untake(x);
+ mln_precondition(h_(t) != 0);
+ h_.untake(t);
if (h_.sum() == 0)
{
init();
return;
}
- if (x > x_)
+ if (t > t_)
{
mln_invariant(sum_ >= 1);
--sum_;
valid_ = false;
}
else
- if (x == x_ && h_[i_] == 0)
+ if (t == t_ && h_[i_] == 0)
valid_ = false;
}
@@ -173,7 +173,7 @@
do
--i_;
while (h_[i_] == 0);
- x_ = s_[i_];
+ t_ = s_[i_];
}
template <typename S>
@@ -186,7 +186,7 @@
if (h_[i_] != 0)
sum_ -= h_[i_];
} while (sum_ != 0);
- x_ = s_[i_];
+ t_ = s_[i_];
}
template <typename S>
@@ -196,18 +196,18 @@
h_.init();
sum_ = 0;
i_ = mln_min(argument);
- x_ = s_[i_];
+ t_ = s_[i_];
valid_ = true;
}
template <typename S>
void
- max_h<S>::take_as_init(const argument& x)
+ max_h<S>::take_as_init(const argument& t)
{
- h_.take(x);
+ h_.take(t);
sum_ = 0;
- i_ = s_.index_of(x);
- x_ = x;
+ i_ = s_.index_of(t);
+ t_ = t;
valid_ = true;
}
@@ -217,7 +217,7 @@
{
if (! valid_)
update_();
- return x_;
+ return t_;
}
template <typename S>
Index: trunk/milena/mln/accu/median.hh
===================================================================
--- trunk/milena/mln/accu/median.hh (revision 1247)
+++ trunk/milena/mln/accu/median.hh (revision 1248)
@@ -57,9 +57,9 @@
median();
void init();
- void take(const argument& x);
+ void take(const argument& t);
void take(const median<S>& other);
- void untake(const argument& x);
+ void untake(const argument& t);
unsigned card() const { return h_.sum(); }
@@ -76,7 +76,7 @@
mutable bool valid_;
mutable std::size_t i_; // the median index
- mutable argument x_; // the median value
+ mutable argument t_; // the median value
// Auxiliary methods
void update_() const;
@@ -105,13 +105,13 @@
template <typename S>
void
- median<S>::take(const argument& x)
+ median<S>::take(const argument& t)
{
- h_.take(x);
+ h_.take(t);
- if (x < x_)
+ if (t < t_)
++sum_minus_;
- else if (x > x_)
+ else if (t > t_)
++sum_plus_;
if (valid_)
@@ -139,14 +139,14 @@
template <typename S>
void
- median<S>::untake(const argument& x)
+ median<S>::untake(const argument& t)
{
- mln_precondition(h_(x) != 0);
- h_.untake(x);
+ mln_precondition(h_(t) != 0);
+ h_.untake(t);
- if (x < x_)
+ if (t < t_)
--sum_minus_;
- else if (x > x_)
+ else if (t > t_)
--sum_plus_;
if (valid_)
@@ -191,7 +191,7 @@
sum_minus_ -= h_[i_];
}
while (2 * sum_minus_ > h_.sum());
- x_ = s_[i_];
+ t_ = s_[i_];
}
template <typename S>
@@ -207,7 +207,7 @@
sum_plus_ -= h_[i_];
}
while (2 * sum_plus_ > h_.sum());
- x_ = s_[i_];
+ t_ = s_[i_];
}
template <typename S>
@@ -218,7 +218,7 @@
sum_minus_ = 0;
sum_plus_ = 0;
i_ = (mln_max(argument) - mln_min(argument)) / 2;
- x_ = s_[i_];
+ t_ = s_[i_];
valid_ = true;
}
@@ -228,7 +228,7 @@
{
if (! valid_)
update_();
- return x_;
+ return t_;
}
template <typename S>
Index: trunk/milena/mln/accu/median_alt.hh
===================================================================
--- trunk/milena/mln/accu/median_alt.hh (revision 1247)
+++ trunk/milena/mln/accu/median_alt.hh (revision 1248)
@@ -54,8 +54,8 @@
median_alt(const Value_Set<S>& s);
- void take(const argument& x);
- void untake(const argument& x);
+ void take(const argument& t);
+ void untake(const argument& t);
void init();
argument to_result() const;
@@ -64,7 +64,7 @@
void debug__() const
{
std::cout << " i = " << i_
- << " x = " << x_
+ << " t = " << t_
<< " s = " << sum_minus_ << " ; " << h_[i_] << " ; " << sum_plus_ << " = " << h_.sum()
<< std::endl;
}
@@ -77,7 +77,7 @@
std::size_t sum_minus_, sum_plus_;
std::size_t i_; // the median index
- argument x_; // the median argument
+ argument t_; // the median argument
// Auxiliary methods
void go_minus_();
@@ -109,24 +109,24 @@
template <typename S>
void
- median_alt<S>::take(const argument& x)
+ median_alt<S>::take(const argument& t)
{
// update h_
- h_.take(x);
+ h_.take(t);
// particular case:
// current state was initialization
if (h_[i_] == 0)
{
// std::cout << "init!" << std::endl;
- i_ = s_.index_of(x);
- x_ = x;
+ i_ = s_.index_of(t);
+ t_ = t;
return;
}
// particular case:
// the median does not change
- if (x == x_)
+ if (t == t_)
{
// std::cout << "no change!" << std::endl;
return;
@@ -134,14 +134,14 @@
// general case:
- if (x < x_)
+ if (t < t_)
{
++sum_minus_;
if (2 * sum_minus_ > h_.sum())
go_minus_();
}
else
- // x > x_
+ // t > t_
{
++sum_plus_;
if (2 * sum_plus_ > h_.sum())
@@ -152,12 +152,12 @@
template <typename S>
void
- median_alt<S>::untake(const argument& x)
+ median_alt<S>::untake(const argument& t)
{
- mln_precondition(h_(x) != 0);
+ mln_precondition(h_(t) != 0);
// update h_
- h_.untake(x);
+ h_.untake(t);
// particular case:
// the only value has been removed
@@ -168,20 +168,20 @@
}
// general case:
- if (x < x_)
+ if (t < t_)
{
--sum_minus_;
if (2 * sum_plus_ > h_.sum())
go_plus_();
}
- else if (x > x_)
+ else if (t > t_)
{
--sum_plus_;
if (2 * sum_minus_ > h_.sum())
go_minus_();
}
else
- // x == x_
+ // t == t_
{
if (h_[i_] == 0)
{
@@ -216,7 +216,7 @@
sum_minus_ -= h_[i_];
}
while (2 * sum_minus_ > h_.sum());
- x_ = s_[i_];
+ t_ = s_[i_];
}
@@ -233,7 +233,7 @@
sum_plus_ -= h_[i_];
}
while (2 * sum_plus_ > h_.sum());
- x_ = s_[i_];
+ t_ = s_[i_];
}
@@ -245,14 +245,14 @@
sum_minus_ = 0;
sum_plus_ = 0;
i_ = (mln_max(argument) - mln_min(argument)) / 2;
- x_ = s_[i_];
+ t_ = s_[i_];
}
template <typename S>
typename median_alt<S>::argument
median_alt<S>::to_result() const
{
- return x_;
+ return t_;
}
template <typename S>
Index: trunk/milena/mln/accu/p.hh
===================================================================
--- trunk/milena/mln/accu/p.hh (revision 1247)
+++ trunk/milena/mln/accu/p.hh (revision 1248)
@@ -61,8 +61,8 @@
p_(const A& a);
void init();
- void take_as_init(const argument& x);
- void take(const argument& x);
+ void take_as_init(const argument& t);
+ void take(const argument& t);
void take(const p_<A>& other);
result to_result() const;
@@ -109,16 +109,16 @@
template <typename A>
void
- p_<A>::take_as_init(const argument& x)
+ p_<A>::take_as_init(const argument& t)
{
- a_.take_as_init(x.p()); // FIXME: Generalize with "psite(x)".
+ a_.take_as_init(t.p()); // FIXME: Generalize with "psite(t)".
}
template <typename A>
void
- p_<A>::take(const argument& x)
+ p_<A>::take(const argument& t)
{
- a_.take(x.p());
+ a_.take(t.p());
}
template <typename A>
Index: trunk/milena/mln/accu/sum.hh
===================================================================
--- trunk/milena/mln/accu/sum.hh (revision 1247)
+++ trunk/milena/mln/accu/sum.hh (revision 1248)
@@ -50,21 +50,21 @@
/*! Generic sum accumulator class.
*
- * Parameter \c V is the type of values that we sum. Parameter \c
+ * Parameter \c T is the type of values that we sum. Parameter \c
* S is the type to store the value sum; the default type of
- * \c S is the summation type (property) of \c V.
+ * \c S is the summation type (property) of \c T.
*/
- template <typename V, typename S = mln_sum(V)>
- struct sum_ : public mln::accu::internal::base_< S, sum_<V,S> >
+ template <typename T, typename S = mln_sum(T)>
+ struct sum_ : public mln::accu::internal::base_< S, sum_<T,S> >
{
- typedef V argument;
+ typedef T argument;
typedef S result;
sum_();
void init();
- void take(const argument& x);
- void take(const sum_<V,S>& other);
+ void take(const argument& t);
+ void take(const sum_<T,S>& other);
S to_result() const;
@@ -81,10 +81,10 @@
// FIXME: Doc!
struct sum : public Meta_Accumulator< sum >
{
- template <typename V, typename S = mln_sum(V)>
+ template <typename T, typename S = mln_sum(T)>
struct with
{
- typedef sum_<V, S> ret;
+ typedef sum_<T, S> ret;
};
};
@@ -92,35 +92,35 @@
# ifndef MLN_INCLUDE_ONLY
- template <typename V, typename S>
- sum_<V,S>::sum_()
+ template <typename T, typename S>
+ sum_<T,S>::sum_()
{
init();
}
- template <typename V, typename S>
+ template <typename T, typename S>
void
- sum_<V,S>::init()
+ sum_<T,S>::init()
{
s_ = literal::zero;
}
- template <typename V, typename S>
- void sum_<V,S>::take(const argument& x)
+ template <typename T, typename S>
+ void sum_<T,S>::take(const argument& t)
{
- s_ += x;
+ s_ += t;
}
- template <typename V, typename S>
+ template <typename T, typename S>
void
- sum_<V,S>::take(const sum_<V,S>& other)
+ sum_<T,S>::take(const sum_<T,S>& other)
{
s_ += other.s_;
}
- template <typename V, typename S>
+ template <typename T, typename S>
S
- sum_<V,S>::to_result() const
+ sum_<T,S>::to_result() const
{
return s_;
}
Index: trunk/milena/mln/accu/v.hh
===================================================================
--- trunk/milena/mln/accu/v.hh (revision 1247)
+++ trunk/milena/mln/accu/v.hh (revision 1248)
@@ -57,8 +57,8 @@
val_(const A& a);
void init();
- void take_as_init(const argument& x);
- void take(const argument& x);
+ void take_as_init(const argument& t);
+ void take(const argument& t);
void take(const val_<A>& other);
template <typename I>
@@ -118,16 +118,16 @@
template <typename A>
void
- val_<A>::take_as_init(const argument& x)
+ val_<A>::take_as_init(const argument& t)
{
- a_.take_as_init(x);
+ a_.take_as_init(t);
}
template <typename A>
void
- val_<A>::take(const argument& x)
+ val_<A>::take(const argument& t)
{
- a_.take(x);
+ a_.take(t);
}
template <typename A>
Index: trunk/milena/mln/accu/mean.hh
===================================================================
--- trunk/milena/mln/accu/mean.hh (revision 1247)
+++ trunk/milena/mln/accu/mean.hh (revision 1248)
@@ -49,32 +49,32 @@
/*! Generic mean accumulator class.
*
- * Parameter \c V is the type of values that we sum. Parameter \c
+ * Parameter \c T is the type of values that we sum. Parameter \c
* S is the type to store the sum of values; the default type of
- * \c S is the summation type (property) of \c V. Parameter \c M
+ * \c S is the summation type (property) of \c T. Parameter \c M
* is the type of the mean value; the default type of \c M is \c
* S.
*/
- template <typename V,
- typename S = mln_sum(V),
+ template <typename T,
+ typename S = mln_sum(T),
typename M = S>
- struct mean_ : public mln::accu::internal::base_< M , mean_<V,S,M> >
+ struct mean_ : public mln::accu::internal::base_< M , mean_<T,S,M> >
{
- typedef V argument;
+ typedef T argument;
typedef M result;
mean_();
void init();
- void take(const argument& x);
- void take(const mean_<V,S,M>& other);
+ void take(const argument& t);
+ void take(const mean_<T,S,M>& other);
M to_result() const;
protected:
- accu::count_<V> count_;
- accu::sum_<V,S> sum_;
+ accu::count_<T> count_;
+ accu::sum_<T,S> sum_;
};
@@ -87,50 +87,50 @@
// FIXME: Doc!
struct mean : public Meta_Accumulator< mean >
{
- template < typename V,
- typename S = mln_sum(V),
+ template < typename T,
+ typename S = mln_sum(T),
typename M = S >
struct with
{
- typedef mean_<V,S,M> ret;
+ typedef mean_<T,S,M> ret;
};
};
# ifndef MLN_INCLUDE_ONLY
- template <typename V, typename S, typename M>
- mean_<V,S,M>::mean_()
+ template <typename T, typename S, typename M>
+ mean_<T,S,M>::mean_()
{
init();
}
- template <typename V, typename S, typename M>
+ template <typename T, typename S, typename M>
void
- mean_<V,S,M>::init()
+ mean_<T,S,M>::init()
{
count_.init();
sum_.init();
}
- template <typename V, typename S, typename M>
- void mean_<V,S,M>::take(const argument& x)
+ template <typename T, typename S, typename M>
+ void mean_<T,S,M>::take(const argument& t)
{
- count_.take(x);
- sum_.take(x);
+ count_.take(t);
+ sum_.take(t);
}
- template <typename V, typename S, typename M>
+ template <typename T, typename S, typename M>
void
- mean_<V,S,M>::take(const mean_<V,S,M>& other)
+ mean_<T,S,M>::take(const mean_<T,S,M>& other)
{
count_.take(other.count_);
sum_.take(other.sum_);
}
- template <typename V, typename S, typename M>
+ template <typename T, typename S, typename M>
M
- mean_<V,S,M>::to_result() const
+ mean_<T,S,M>::to_result() const
{
return sum_.to_result() / count_.to_result();
}
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Handle multiple super-categories.
* mln/trait/solve.hh (super_category_): New to handle multiple
super-categories.
* tests/trait_super.cc: New.
* mln/core/w_window.hh (sym): Fix; my fault!
* mln/core/win/hline2d.hh: Add FIXME for Simon.
* mln/accu/min.hh: Add FIXME for Matthieu.
* mln/value/builtin.hh (Integer, Symbolic, Floating): New.
(category): Specialize for some builtins.
mln/accu/min.hh | 19 ++++++
mln/core/w_window.hh | 2
mln/core/win/hline2d.hh | 14 ++++
mln/trait/solve.hh | 52 ++++++++++++++--
mln/value/builtin.hh | 46 ++++++++++++--
tests/trait_super.cc | 152 ++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 272 insertions(+), 13 deletions(-)
Index: tests/trait_super.cc
--- tests/trait_super.cc (revision 0)
+++ tests/trait_super.cc (revision 0)
@@ -0,0 +1,152 @@
+// 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/trait_super.cc
+ *
+ * \brief Tests on mln::trait::solve.
+ */
+
+#include <mln/trait/op_uminus.hh>
+#include <mln/core/concept/object.hh>
+#include <mln/value/int_u8.hh>
+
+
+namespace my
+{
+
+
+ // Value.
+
+ template <typename E> struct Value;
+
+ template <> struct Value<void> { typedef mln::Object<void> super; };
+
+ template <typename E>
+ struct Value
+ {
+ typedef Value<void> category;
+ protected:
+ Value() {}
+ };
+
+
+ // Integer.
+
+ template <typename E> struct Integer;
+
+ template <> struct Integer<void> { typedef Value<void> super; };
+
+ template <typename E>
+ struct Integer
+ {
+ typedef Integer<void> category;
+ };
+
+ template <>
+ struct Integer<int>
+ {
+ typedef Integer<void> category;
+ int i;
+ Integer(int i) : i(i) {}
+ };
+
+
+ // Built_In.
+
+ template <typename E> struct Built_In;
+
+ template <> struct Built_In<void> { typedef void* super; }; // cause several posible
+
+
+ // test.
+
+ struct test // like a built-in: no inheritance!
+ {
+ void is_test() {}
+ };
+
+
+// template <typename I>
+// void foo(const Integer<I>&)
+// {
+// std::cout << "Int" << std::endl;
+// }
+
+// template <typename I>
+// void foo(const Value<I>&)
+// {
+// std::cout << "Value" << std::endl;
+// }
+
+} // my
+
+
+
+namespace mln
+{
+
+ template <>
+ struct category< my::test >
+ {
+ typedef my::Built_In<void> ret;
+ typedef my::Integer<void> super;
+ };
+
+// template <>
+// struct category< int >
+// {
+// typedef my::Built_In<void> ret;
+// typedef my::Integer<void> super;
+// };
+
+ namespace trait
+ {
+
+ template <typename T>
+ struct set_unary_< op_uminus, my::Integer, T >
+ {
+ typedef bool ret;
+ };
+
+ } // mln::trait
+
+} // mln
+
+
+int main()
+{
+ using namespace mln;
+
+ mln_trait_op_uminus_(my::test) tmp;
+ tmp = true;
+
+// int i;
+// my::foo<int>(i);
+
+// mln_trait_op_plus_(value::int_u8, int) t;
+// void* v = t;
+}
Index: mln/trait/solve.hh
--- mln/trait/solve.hh (revision 1246)
+++ mln/trait/solve.hh (working copy)
@@ -87,13 +87,37 @@
{
};
+
+ template < template <class> class Category, typename T,
+ typename Super_Category >
+ struct super_category_;
+
+ template < template <class> class Category, typename T,
+ template <class> class Super_Category >
+ struct super_category_< Category, T,
+ Super_Category<void> >
+ {
+ typedef Super_Category<void> ret; // One super category: keep it.
+ };
+
+ template < template <class> class Category, typename T >
+ struct super_category_< Category, T,
+ void* > // Meaning: several super categories exist, depending on T.
+ {
+ typedef typename mln::category< T >::super ret; // Specific call depending on T.
+ };
+
} // end of namespace mln::trait::internal
template < template <class> class Name,
template <class> class Category_T, typename T >
- struct set_unary_ : internal::set_unary_super_< Name,
- typename Category_T<void>::super, T >
+ struct set_unary_
+ :
+ internal::set_unary_super_< Name,
+ typename internal::super_category_< Category_T, T,
+ typename Category_T<void>::super >::ret,
+ T >
{
};
@@ -125,6 +149,14 @@
{
};
+ template < template <class> class Name,
+ template <class> class Category_T, typename T >
+ struct helper_solve_unary_< Name,
+ Category_T<void*>, T > : helper_choose_unary_< Name,
+ Category_T, T >
+ {
+ };
+
} // end of namespace mln::trait::internal
@@ -245,13 +277,21 @@
// Construct a treillis in a static recursive way!
typedef typename internal::set_binary_super_< Name,
- typename Category_L<void>::super, L,
- Category_R<void>, R >::ret
+ typename internal::super_category_< Category_L,
+ L,
+ typename Category_L<void>::super >::ret,
+ L,
+ Category_R<void>,
+ R >::ret
L_ret;
typedef typename internal::set_binary_super_< Name,
- Category_L<void>, L,
- typename Category_R<void>::super, R >::ret
+ Category_L<void>,
+ L,
+ typename internal::super_category_< Category_R,
+ R,
+ typename Category_R<void>::super >::ret,
+ R >::ret
R_ret;
typedef typename internal::merge_binary_ret_< L_ret, R_ret >::ret ret;
Index: mln/core/w_window.hh
--- mln/core/w_window.hh (revision 1246)
+++ mln/core/w_window.hh (working copy)
@@ -257,7 +257,7 @@
{
w_window<D,W> tmp;
for (unsigned i = 0; i < this->ndpoints(); ++i)
- tmp.insert(this->w(i), this->dp(i));
+ tmp.insert(this->w(i), - this->dp(i));
*this = tmp;
return *this;
}
Index: mln/core/win/hline2d.hh
--- mln/core/win/hline2d.hh (revision 1246)
+++ mln/core/win/hline2d.hh (working copy)
@@ -61,6 +61,20 @@
}
};
+
+// // FIXME for Simon
+
+// // Was:
+// struct hline2d : public Window< hline2d >,
+// public internal::dpoints_base_< dpoint2d, hline2d >
+// {};
+
+// // Will be:
+// template <typename M, unsigned i, typename C >
+// struct line : public Window< line<M,i,C> >,
+// public internal::dpoints_base_< dpoint_<M, C>, line<M,i,C> >
+// {};
+
} // end of namespace mln::win
} // end of namespace mln
Index: mln/accu/min.hh
--- mln/accu/min.hh (revision 1246)
+++ mln/accu/min.hh (working copy)
@@ -85,6 +85,25 @@
};
+
+// // FIXME: Sample code.
+
+// template <typename V>
+// struct p_min_ : public p_< min_<V> >
+// {
+// };
+
+// struct p_min : public Meta_Accumulator< p_min >
+// {
+// template <typename V>
+// struct with
+// {
+// typedef p_min_<V> ret;
+// };
+// };
+
+
+
# ifndef MLN_INCLUDE_ONLY
template <typename V>
Index: mln/value/builtin.hh
--- mln/value/builtin.hh (revision 1246)
+++ mln/value/builtin.hh (working copy)
@@ -43,15 +43,49 @@
// The case of built-in types.
template <typename E>
- struct Built_In
+ struct Built_In;
+
+ template <>
+ struct Built_In<void>
+ {
+ typedef void* super; // Every builtin belongs to a sub-category of Value but we do not know which one.
+ };
+
+
+ template <typename E> struct Symbolic;
+
+ template <>
+ struct Symbolic<void>
{
- typedef Value<void> super; // Builtins belong to a sub-category of values.
+ typedef Value<void> super;
};
- template <> struct category< int > { typedef Built_In<void> ret; };
- template <> struct category< unsigned > { typedef Built_In<void> ret; };
- template <> struct category< float > { typedef Built_In<void> ret; };
- template <> struct category< double > { typedef Built_In<void> ret; };
+
+ template <typename E> struct Integer;
+
+ template <>
+ struct Integer<void>
+ {
+ typedef Value<void> super;
+ };
+
+
+ template <typename E> struct Floating;
+
+ template <>
+ struct Floating<void>
+ {
+ typedef Value<void> super;
+ };
+
+
+ template <> struct category< bool > { typedef Built_In<void> ret; typedef Symbolic<void> super; };
+
+ template <> struct category< int > { typedef Built_In<void> ret; typedef Integer<void> super; };
+ template <> struct category< unsigned > { typedef Built_In<void> ret; typedef Integer<void> super; };
+
+ template <> struct category< float > { typedef Built_In<void> ret; typedef Floating<void> super; };
+ template <> struct category< double > { typedef Built_In<void> ret; typedef Floating<void> super; };
// FIXME: ...
1
0
04 Oct '07
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-04 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Rename typedef value by argument in accumulators.
* mln/accu/bbox.hh,
* mln/accu/count.hh,
* mln/accu/histo.hh,
* mln/accu/internal/base.hh,
* mln/accu/max.hh,
* mln/accu/max_h.hh,
* mln/accu/mean.hh,
* mln/accu/median.hh,
* mln/accu/median_alt.hh,
* mln/accu/min.hh,
* mln/accu/min_h.hh,
* mln/accu/nil.hh,
* mln/accu/p.hh,
* mln/accu/pair.hh,
* mln/accu/sum.hh,
* mln/accu/v.hh,
* mln/core/concept/accumulator.hh,
* mln/core/concept/doc/accumulator.hh,
* mln/core/grids.hh,
* mln/core/macros.hh: (typedef value) Rename as...
(typedef argument) ... this.
---
accu/bbox.hh | 2 -
accu/count.hh | 6 ++--
accu/histo.hh | 22 ++++++++--------
accu/max.hh | 26 ++++++++++----------
accu/max_h.hh | 52 ++++++++++++++++++++--------------------
accu/mean.hh | 10 +++----
accu/median.hh | 42 ++++++++++++++++----------------
accu/median_alt.hh | 50 +++++++++++++++++++-------------------
accu/min.hh | 26 ++++++++++----------
accu/min_h.hh | 52 ++++++++++++++++++++--------------------
accu/nil.hh | 10 +++----
accu/p.hh | 14 +++++-----
accu/pair.hh | 20 +++++++--------
accu/sum.hh | 8 +++---
accu/v.hh | 14 +++++-----
core/concept/accumulator.hh | 16 ++++++------
core/concept/doc/accumulator.hh | 8 +++---
core/grids.hh | 6 ++++
core/macros.hh | 4 +++
19 files changed, 199 insertions(+), 189 deletions(-)
Index: trunk/milena/mln/core/macros.hh
===================================================================
--- trunk/milena/mln/core/macros.hh (revision 1245)
+++ trunk/milena/mln/core/macros.hh (revision 1246)
@@ -161,6 +161,10 @@
# define mln_value(T) typename T::value
# define mln_value_(T) T::value
+/// Shortcut to access the argument type associated to T.
+# define mln_argument(T) typename T::argument
+# define mln_argument_(T) T::argument
+
/// Shortcut to test if the values of an image with type \c I are lowly quantifized.
# define mln_is_value_lowq(I) mln_is_lowq( mln_value(I) )
Index: trunk/milena/mln/core/concept/doc/accumulator.hh
===================================================================
--- trunk/milena/mln/core/concept/doc/accumulator.hh (revision 1245)
+++ trunk/milena/mln/core/concept/doc/accumulator.hh (revision 1246)
@@ -41,8 +41,8 @@
template <typename E>
struct Accumulator
{
- /// The value type of elements to accumulate.
- typedef void value;
+ /// The argument type of elements to accumulate.
+ typedef void argument;
/// The value type to return.
typedef void result_;
@@ -50,8 +50,8 @@
/// Initialize the accumulator.
void init();
- /// Take into account a value \p v (an element).
- void take(const value& v);
+ /// Take into account a argument \p x (an element).
+ void take(const argument& x);
/// Take into account another accumulator \p other.
void take(const E& other);
Index: trunk/milena/mln/core/concept/accumulator.hh
===================================================================
--- trunk/milena/mln/core/concept/accumulator.hh (revision 1245)
+++ trunk/milena/mln/core/concept/accumulator.hh (revision 1246)
@@ -65,10 +65,10 @@
typedef Accumulator<void> category;
/*
- typedef value;
+ typedef argument;
typedef result;
void init();
- void take(const value& v);
+ void take(const argument& x);
void take(const E& other);
result to_result() const;
operator result_() const;
@@ -76,7 +76,7 @@
// Default impl.
template <typename T>
- void take_as_init(const T& t); // 't' is either value or E.
+ void take_as_init(const T& t); // 't' is either argument or E.
protected:
Accumulator();
@@ -89,25 +89,25 @@
template <typename E>
Accumulator<E>::Accumulator()
{
- typedef mln_value(E) value;
+ typedef mln_argument(E) argument;
typedef mln_result(E) result;
void (E::*m1)() = & E::init;
m1 = 0;
- void (E::*m2)(const value&) = & E::take;
+ void (E::*m2)(const argument&) = & E::take;
m2 = 0;
void (E::*m3)(const E&) = & E::take;
m3 = 0;
result (E::*m4)() const = & E::to_result;
m4 = 0;
- result (E::*m5)() const = & E::operator result;
- m5 = 0;
+// result (E::*m5)() const = & E::operator result;
+// m5 = 0;
}
template <typename E>
template <typename T>
void
- Accumulator<E>::take_as_init(const T& t) // either value or E
+ Accumulator<E>::take_as_init(const T& t) // either argument or E
{
exact(this)->init();
exact(this)->take(t);
Index: trunk/milena/mln/core/grids.hh
===================================================================
--- trunk/milena/mln/core/grids.hh (revision 1245)
+++ trunk/milena/mln/core/grids.hh (revision 1246)
@@ -57,6 +57,12 @@
enum { dim = 2 };
};
+ struct hexa : public Regular_Grid< hexa >
+ {
+ typedef metal::false_ aligned;
+ enum { dim = 2 };
+ };
+
struct cube : public Regular_Grid< cube >
{
typedef metal::true_ aligned;
Index: trunk/milena/mln/accu/nil.hh
===================================================================
--- trunk/milena/mln/accu/nil.hh (revision 1245)
+++ trunk/milena/mln/accu/nil.hh (revision 1246)
@@ -52,14 +52,14 @@
template <typename T>
struct nil_ : public mln::accu::internal::base_< util::ignore , nil_<T> >
{
- typedef util::eat value;
+ typedef util::eat argument;
typedef util::ignore result;
nil_();
void init();
- void take_as_init(const value&);
- void take(const value&);
+ void take_as_init(const argument&);
+ void take(const argument&);
void take(const nil_<T>&);
util::ignore to_result() const;
@@ -93,13 +93,13 @@
template <typename T>
void
- nil_<T>::take(const value&)
+ nil_<T>::take(const argument&)
{
}
template <typename T>
void
- nil_<T>::take_as_init(const value&)
+ nil_<T>::take_as_init(const argument&)
{
}
Index: trunk/milena/mln/accu/min.hh
===================================================================
--- trunk/milena/mln/accu/min.hh (revision 1245)
+++ trunk/milena/mln/accu/min.hh (revision 1246)
@@ -53,21 +53,21 @@
template <typename V>
struct min_ : public mln::accu::internal::base_< V, min_<V> >
{
- typedef V value;
+ typedef V argument;
typedef V result;
min_();
void init();
- void take_as_init(const value& v);
- void take(const value& v);
+ void take_as_init(const argument& x);
+ void take(const argument& x);
void take(const min_<V>& other);
V to_result() const;
protected:
- V v_;
+ V x_;
};
@@ -97,35 +97,35 @@
void
min_<V>::init()
{
- v_ = mln_max(V);
+ x_ = mln_max(V);
}
template <typename V>
- void min_<V>::take_as_init(const value& v)
+ void min_<V>::take_as_init(const argument& x)
{
- v_ = v;
+ x_ = x;
}
template <typename V>
- void min_<V>::take(const value& v)
+ void min_<V>::take(const argument& x)
{
- if (v < v_)
- v_ = v;
+ if (x < x_)
+ x_ = x;
}
template <typename V>
void
min_<V>::take(const min_<V>& other)
{
- if (other.v_ < v_)
- v_ = other.v_;
+ if (other.x_ < x_)
+ x_ = other.x_;
}
template <typename V>
V
min_<V>::to_result() const
{
- return v_;
+ return x_;
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/accu/max.hh
===================================================================
--- trunk/milena/mln/accu/max.hh (revision 1245)
+++ trunk/milena/mln/accu/max.hh (revision 1246)
@@ -52,21 +52,21 @@
template <typename V>
struct max_ : public mln::accu::internal::base_< V , max_<V> >
{
- typedef V value;
+ typedef V argument;
typedef V result;
max_();
void init();
- void take_as_init(const value& v);
- void take(const value& v);
+ void take_as_init(const argument& x);
+ void take(const argument& x);
void take(const max_<V>& other);
V to_result() const;
protected:
- V v_;
+ V x_;
};
@@ -97,37 +97,37 @@
void
max_<V>::init()
{
- v_ = mln_min(V);
+ x_ = mln_min(V);
}
template <typename V>
void
- max_<V>::take_as_init(const value& v)
+ max_<V>::take_as_init(const argument& x)
{
- v_ = v;
+ x_ = x;
}
template <typename V>
void
- max_<V>::take(const value& v)
+ max_<V>::take(const argument& x)
{
- if (v > v_)
- v_ = v;
+ if (x > x_)
+ x_ = x;
}
template <typename V>
void
max_<V>::take(const max_<V>& other)
{
- if (other.v_ > v_)
- v_ = other.v_;
+ if (other.x_ > x_)
+ x_ = other.x_;
}
template <typename V>
V
max_<V>::to_result() const
{
- return v_;
+ return x_;
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/accu/histo.hh
===================================================================
--- trunk/milena/mln/accu/histo.hh (revision 1245)
+++ trunk/milena/mln/accu/histo.hh (revision 1246)
@@ -58,15 +58,15 @@
histo(const Value_Set<S>& s);
histo();
- typedef mln_value(S) value;
+ typedef mln_value(S) argument;
typedef const std::vector<std::size_t>& result;
- void take(const value& v);
+ void take(const argument& x);
void take(const histo<S>& other);
- void untake(const value& v);
+ void untake(const argument& x);
void init();
- std::size_t operator()(const value& v) const;
+ std::size_t operator()(const argument& x) const;
std::size_t operator[](std::size_t i) const;
std::size_t nvalues() const;
std::size_t sum() const;
@@ -110,9 +110,9 @@
template <typename S>
void
- histo<S>::take(const value& v)
+ histo<S>::take(const argument& x)
{
- ++h_[s_.index_of(v)];
+ ++h_[s_.index_of(x)];
++sum_;
}
@@ -127,11 +127,11 @@
template <typename S>
void
- histo<S>::untake(const value& v)
+ histo<S>::untake(const argument& x)
{
- mln_precondition(h_[s_.index_of(v)] > 0);
+ mln_precondition(h_[s_.index_of(x)] > 0);
mln_precondition(sum_ > 0);
- --h_[s_.index_of(v)];
+ --h_[s_.index_of(x)];
--sum_;
}
@@ -145,9 +145,9 @@
template <typename S>
std::size_t
- histo<S>::operator()(const value& v) const
+ histo<S>::operator()(const argument& x) const
{
- return h_[s_.index_of(v)];
+ return h_[s_.index_of(x)];
}
template <typename S>
Index: trunk/milena/mln/accu/count.hh
===================================================================
--- trunk/milena/mln/accu/count.hh (revision 1245)
+++ trunk/milena/mln/accu/count.hh (revision 1246)
@@ -49,13 +49,13 @@
template <typename V>
struct count_ : public mln::accu::internal::base_< std::size_t , count_<V> >
{
- typedef V value;
+ typedef V argument;
typedef std::size_t result; // FIXME: Up in Accumulator.
count_();
void init();
- void take(const value&);
+ void take(const argument&);
void take(const count_<V>& other);
std::size_t to_result() const;
@@ -95,7 +95,7 @@
template <typename V>
void
- count_<V>::take(const value&)
+ count_<V>::take(const argument&)
{
++count__;
}
Index: trunk/milena/mln/accu/bbox.hh
===================================================================
--- trunk/milena/mln/accu/bbox.hh (revision 1245)
+++ trunk/milena/mln/accu/bbox.hh (revision 1246)
@@ -51,7 +51,7 @@
template <typename P>
struct bbox : public mln::accu::internal::base_< const box_<P>& , bbox<P> >
{
- typedef P value;
+ typedef P argument;
typedef const box_<P>& result;
bbox();
Index: trunk/milena/mln/accu/min_h.hh
===================================================================
--- trunk/milena/mln/accu/min_h.hh (revision 1245)
+++ trunk/milena/mln/accu/min_h.hh (revision 1246)
@@ -50,21 +50,21 @@
template <typename S>
struct min_h : public mln::accu::internal::base_< mln_value(S) , min_h<S> >
{
- typedef mln_value(S) value;
- typedef value result;
+ typedef mln_value(S) argument;
+ typedef argument result;
min_h(const Value_Set<S>& s);
min_h();
void init();
- void take(const value& v);
- void take_as_init(const value& v);
+ void take(const argument& x);
+ void take_as_init(const argument& x);
void take(const min_h<S>& other);
- void untake(const value& v);
+ void untake(const argument& x);
unsigned card() const { return h_.sum(); }
- value to_result() const;
+ result to_result() const;
const accu::histo<S>& histo() const;
@@ -76,7 +76,7 @@
mutable std::size_t sum_;
mutable bool valid_;
mutable std::size_t i_; // the min index
- mutable value v_; // the min value
+ mutable argument x_; // the min value
// Auxiliary methods
void update_() const;
@@ -105,15 +105,15 @@
template <typename S>
void
- min_h<S>::take(const value& v)
+ min_h<S>::take(const argument& x)
{
- h_.take(v);
+ h_.take(x);
if (h_.sum() == 1)
{
- this->take_as_init(v);
+ this->take_as_init(x);
return;
}
- if (v < v_)
+ if (x < x_)
{
++sum_;
valid_ = false;
@@ -134,23 +134,23 @@
template <typename S>
void
- min_h<S>::untake(const value& v)
+ min_h<S>::untake(const argument& x)
{
- mln_precondition(h_(v) != 0);
- h_.untake(v);
+ mln_precondition(h_(x) != 0);
+ h_.untake(x);
if (h_.sum() == 0)
{
init();
return;
}
- if (v < v_)
+ if (x < x_)
{
mln_invariant(sum_ >= 1);
--sum_;
valid_ = false;
}
else
- if (v == v_ && h_[i_] == 0)
+ if (x == x_ && h_[i_] == 0)
valid_ = false;
}
@@ -177,7 +177,7 @@
sum_ -= h_[i_];
}
while (sum_ != 0);
- v_ = s_[i_];
+ x_ = s_[i_];
}
template <typename S>
@@ -187,7 +187,7 @@
do
++i_;
while (h_[i_] == 0);
- v_ = s_[i_];
+ x_ = s_[i_];
}
template <typename S>
@@ -196,29 +196,29 @@
{
h_.init();
sum_ = 0;
- i_ = mln_max(value);
- v_ = s_[i_];
+ i_ = mln_max(argument);
+ x_ = s_[i_];
valid_ = true;
}
template <typename S>
void
- min_h<S>::take_as_init(const value& v)
+ min_h<S>::take_as_init(const argument& x)
{
- h_.take(v);
+ h_.take(x);
sum_ = 0;
- i_ = s_.index_of(v);
- v_ = v;
+ i_ = s_.index_of(x);
+ x_ = x;
valid_ = true;
}
template <typename S>
- typename min_h<S>::value
+ typename min_h<S>::argument
min_h<S>::to_result() const
{
if (! valid_)
update_();
- return v_;
+ return x_;
}
template <typename S>
Index: trunk/milena/mln/accu/pair.hh
===================================================================
--- trunk/milena/mln/accu/pair.hh (revision 1245)
+++ trunk/milena/mln/accu/pair.hh (revision 1246)
@@ -55,10 +55,10 @@
*
* \todo Check that, when V is not provided, A1 and A2 have the same value.
*/
- template <typename A1, typename A2, typename V = mln_value(A1)>
+ template <typename A1, typename A2, typename V = mln_argument(A1)>
struct pair_ : public mln::accu::internal::base_< std::pair< mlc_unqualif(mln_result(A1)) , mlc_unqualif(mln_result(A2)) > , pair_<A1,A2,V> >
{
- typedef V value;
+ typedef V argument;
typedef mlc_unqualif(mln_result(A1)) result_1;
typedef mlc_unqualif(mln_result(A2)) result_2;
@@ -68,8 +68,8 @@
pair_(const A1& a1, const A2& a2);
void init();
- void take_as_init(const value& v);
- void take(const value& v);
+ void take_as_init(const argument& x);
+ void take(const argument& x);
void take(const pair_<A1,A2,V>& other);
result to_result() const;
@@ -115,18 +115,18 @@
template <typename A1, typename A2, typename V>
void
- pair_<A1,A2,V>::take_as_init(const value& v)
+ pair_<A1,A2,V>::take_as_init(const argument& x)
{
- a1_.take_as_init(v);
- a2_.take_as_init(v);
+ a1_.take_as_init(x);
+ a2_.take_as_init(x);
}
template <typename A1, typename A2, typename V>
void
- pair_<A1,A2,V>::take(const value& v)
+ pair_<A1,A2,V>::take(const argument& x)
{
- a1_.take(v);
- a2_.take(v);
+ a1_.take(x);
+ a2_.take(x);
}
template <typename A1, typename A2, typename V>
Index: trunk/milena/mln/accu/max_h.hh
===================================================================
--- trunk/milena/mln/accu/max_h.hh (revision 1245)
+++ trunk/milena/mln/accu/max_h.hh (revision 1246)
@@ -50,21 +50,21 @@
template <typename S>
struct max_h : public mln::accu::internal::base_< mln_value(S) , max_h<S> >
{
- typedef mln_value(S) value;
- typedef value result;
+ typedef mln_value(S) argument;
+ typedef argument result;
max_h(const Value_Set<S>& s);
max_h();
void init();
- void take(const value& v);
- void take_as_init(const value& v);
+ void take(const argument& x);
+ void take_as_init(const argument& x);
void take(const max_h<S>& other);
- void untake(const value& v);
+ void untake(const argument& x);
unsigned card() const { return h_.sum(); }
- value to_result() const;
+ argument to_result() const;
const accu::histo<S>& histo() const;
@@ -76,7 +76,7 @@
mutable std::size_t sum_;
mutable bool valid_;
mutable std::size_t i_; // the max index
- mutable value v_; // the max value
+ mutable argument x_; // the max argument
// Auxiliary methods
void update_() const;
@@ -105,15 +105,15 @@
template <typename S>
void
- max_h<S>::take(const value& v)
+ max_h<S>::take(const argument& x)
{
- h_.take(v);
+ h_.take(x);
if (h_.sum() == 1)
{
- this->take_as_init(v);
+ this->take_as_init(x);
return;
}
- if (v > v_)
+ if (x > x_)
{
++sum_;
valid_ = false;
@@ -134,23 +134,23 @@
template <typename S>
void
- max_h<S>::untake(const value& v)
+ max_h<S>::untake(const argument& x)
{
- mln_precondition(h_(v) != 0);
- h_.untake(v);
+ mln_precondition(h_(x) != 0);
+ h_.untake(x);
if (h_.sum() == 0)
{
init();
return;
}
- if (v > v_)
+ if (x > x_)
{
mln_invariant(sum_ >= 1);
--sum_;
valid_ = false;
}
else
- if (v == v_ && h_[i_] == 0)
+ if (x == x_ && h_[i_] == 0)
valid_ = false;
}
@@ -173,7 +173,7 @@
do
--i_;
while (h_[i_] == 0);
- v_ = s_[i_];
+ x_ = s_[i_];
}
template <typename S>
@@ -186,7 +186,7 @@
if (h_[i_] != 0)
sum_ -= h_[i_];
} while (sum_ != 0);
- v_ = s_[i_];
+ x_ = s_[i_];
}
template <typename S>
@@ -195,29 +195,29 @@
{
h_.init();
sum_ = 0;
- i_ = mln_min(value);
- v_ = s_[i_];
+ i_ = mln_min(argument);
+ x_ = s_[i_];
valid_ = true;
}
template <typename S>
void
- max_h<S>::take_as_init(const value& v)
+ max_h<S>::take_as_init(const argument& x)
{
- h_.take(v);
+ h_.take(x);
sum_ = 0;
- i_ = s_.index_of(v);
- v_ = v;
+ i_ = s_.index_of(x);
+ x_ = x;
valid_ = true;
}
template <typename S>
- typename max_h<S>::value
+ typename max_h<S>::argument
max_h<S>::to_result() const
{
if (! valid_)
update_();
- return v_;
+ return x_;
}
template <typename S>
Index: trunk/milena/mln/accu/median.hh
===================================================================
--- trunk/milena/mln/accu/median.hh (revision 1245)
+++ trunk/milena/mln/accu/median.hh (revision 1246)
@@ -50,20 +50,20 @@
template <typename S>
struct median : public mln::accu::internal::base_< mln_value(S), median<S> >
{
- typedef mln_value(S) value;
- typedef value result;
+ typedef mln_value(S) argument;
+ typedef argument result;
median(const Value_Set<S>& s);
median();
void init();
- void take(const value& v);
+ void take(const argument& x);
void take(const median<S>& other);
- void untake(const value& v);
+ void untake(const argument& x);
unsigned card() const { return h_.sum(); }
- value to_result() const;
+ argument to_result() const;
const accu::histo<S>& histo() const;
@@ -76,7 +76,7 @@
mutable bool valid_;
mutable std::size_t i_; // the median index
- mutable value v_; // the median value
+ mutable argument x_; // the median value
// Auxiliary methods
void update_() const;
@@ -105,13 +105,13 @@
template <typename S>
void
- median<S>::take(const value& v)
+ median<S>::take(const argument& x)
{
- h_.take(v);
+ h_.take(x);
- if (v < v_)
+ if (x < x_)
++sum_minus_;
- else if (v > v_)
+ else if (x > x_)
++sum_plus_;
if (valid_)
@@ -139,14 +139,14 @@
template <typename S>
void
- median<S>::untake(const value& v)
+ median<S>::untake(const argument& x)
{
- mln_precondition(h_(v) != 0);
- h_.untake(v);
+ mln_precondition(h_(x) != 0);
+ h_.untake(x);
- if (v < v_)
+ if (x < x_)
--sum_minus_;
- else if (v > v_)
+ else if (x > x_)
--sum_plus_;
if (valid_)
@@ -191,7 +191,7 @@
sum_minus_ -= h_[i_];
}
while (2 * sum_minus_ > h_.sum());
- v_ = s_[i_];
+ x_ = s_[i_];
}
template <typename S>
@@ -207,7 +207,7 @@
sum_plus_ -= h_[i_];
}
while (2 * sum_plus_ > h_.sum());
- v_ = s_[i_];
+ x_ = s_[i_];
}
template <typename S>
@@ -217,18 +217,18 @@
h_.init();
sum_minus_ = 0;
sum_plus_ = 0;
- i_ = (mln_max(value) - mln_min(value)) / 2;
- v_ = s_[i_];
+ i_ = (mln_max(argument) - mln_min(argument)) / 2;
+ x_ = s_[i_];
valid_ = true;
}
template <typename S>
- typename median<S>::value
+ typename median<S>::argument
median<S>::to_result() const
{
if (! valid_)
update_();
- return v_;
+ return x_;
}
template <typename S>
Index: trunk/milena/mln/accu/median_alt.hh
===================================================================
--- trunk/milena/mln/accu/median_alt.hh (revision 1245)
+++ trunk/milena/mln/accu/median_alt.hh (revision 1246)
@@ -50,21 +50,21 @@
template <typename S>
struct median_alt : : public mln::accu::internal::base_< mln_value(S), median_alt<S> >
{
- typedef mln_value(S) value;
+ typedef mln_value(S) argument;
median_alt(const Value_Set<S>& s);
- void take(const value& v);
- void untake(const value& v);
+ void take(const argument& x);
+ void untake(const argument& x);
void init();
- value to_result() const;
+ argument to_result() const;
// FIXME: remove
void debug__() const
{
std::cout << " i = " << i_
- << " v = " << v_
+ << " x = " << x_
<< " s = " << sum_minus_ << " ; " << h_[i_] << " ; " << sum_plus_ << " = " << h_.sum()
<< std::endl;
}
@@ -77,7 +77,7 @@
std::size_t sum_minus_, sum_plus_;
std::size_t i_; // the median index
- value v_; // the median value
+ argument x_; // the median argument
// Auxiliary methods
void go_minus_();
@@ -109,24 +109,24 @@
template <typename S>
void
- median_alt<S>::take(const value& v)
+ median_alt<S>::take(const argument& x)
{
// update h_
- h_.take(v);
+ h_.take(x);
// particular case:
// current state was initialization
if (h_[i_] == 0)
{
// std::cout << "init!" << std::endl;
- i_ = s_.index_of(v);
- v_ = v;
+ i_ = s_.index_of(x);
+ x_ = x;
return;
}
// particular case:
// the median does not change
- if (v == v_)
+ if (x == x_)
{
// std::cout << "no change!" << std::endl;
return;
@@ -134,14 +134,14 @@
// general case:
- if (v < v_)
+ if (x < x_)
{
++sum_minus_;
if (2 * sum_minus_ > h_.sum())
go_minus_();
}
else
- // v > v_
+ // x > x_
{
++sum_plus_;
if (2 * sum_plus_ > h_.sum())
@@ -152,12 +152,12 @@
template <typename S>
void
- median_alt<S>::untake(const value& v)
+ median_alt<S>::untake(const argument& x)
{
- mln_precondition(h_(v) != 0);
+ mln_precondition(h_(x) != 0);
// update h_
- h_.untake(v);
+ h_.untake(x);
// particular case:
// the only value has been removed
@@ -168,20 +168,20 @@
}
// general case:
- if (v < v_)
+ if (x < x_)
{
--sum_minus_;
if (2 * sum_plus_ > h_.sum())
go_plus_();
}
- else if (v > v_)
+ else if (x > x_)
{
--sum_plus_;
if (2 * sum_minus_ > h_.sum())
go_minus_();
}
else
- // v == v_
+ // x == x_
{
if (h_[i_] == 0)
{
@@ -216,7 +216,7 @@
sum_minus_ -= h_[i_];
}
while (2 * sum_minus_ > h_.sum());
- v_ = s_[i_];
+ x_ = s_[i_];
}
@@ -233,7 +233,7 @@
sum_plus_ -= h_[i_];
}
while (2 * sum_plus_ > h_.sum());
- v_ = s_[i_];
+ x_ = s_[i_];
}
@@ -244,15 +244,15 @@
h_.init();
sum_minus_ = 0;
sum_plus_ = 0;
- i_ = (mln_max(value) - mln_min(value)) / 2;
- v_ = s_[i_];
+ i_ = (mln_max(argument) - mln_min(argument)) / 2;
+ x_ = s_[i_];
}
template <typename S>
- typename median_alt<S>::value
+ typename median_alt<S>::argument
median_alt<S>::to_result() const
{
- return v_;
+ return x_;
}
template <typename S>
Index: trunk/milena/mln/accu/p.hh
===================================================================
--- trunk/milena/mln/accu/p.hh (revision 1245)
+++ trunk/milena/mln/accu/p.hh (revision 1246)
@@ -53,7 +53,7 @@
template <typename A>
struct p_ : public mln::accu::internal::base_< mln_result(A) , p_<A> >
{
- typedef mln_value(A) value;
+ typedef mln_value(A) argument;
typedef mln_result(A) result;
@@ -61,8 +61,8 @@
p_(const A& a);
void init();
- void take_as_init(const value& v);
- void take(const value& v);
+ void take_as_init(const argument& x);
+ void take(const argument& x);
void take(const p_<A>& other);
result to_result() const;
@@ -109,16 +109,16 @@
template <typename A>
void
- p_<A>::take_as_init(const value& v)
+ p_<A>::take_as_init(const argument& x)
{
- a_.take_as_init(v.p()); // FIXME: Generalize with "psite(v)".
+ a_.take_as_init(x.p()); // FIXME: Generalize with "psite(x)".
}
template <typename A>
void
- p_<A>::take(const value& v)
+ p_<A>::take(const argument& x)
{
- a_.take(v.p());
+ a_.take(x.p());
}
template <typename A>
Index: trunk/milena/mln/accu/sum.hh
===================================================================
--- trunk/milena/mln/accu/sum.hh (revision 1245)
+++ trunk/milena/mln/accu/sum.hh (revision 1246)
@@ -57,13 +57,13 @@
template <typename V, typename S = mln_sum(V)>
struct sum_ : public mln::accu::internal::base_< S, sum_<V,S> >
{
- typedef V value;
+ typedef V argument;
typedef S result;
sum_();
void init();
- void take(const value& v);
+ void take(const argument& x);
void take(const sum_<V,S>& other);
S to_result() const;
@@ -106,9 +106,9 @@
}
template <typename V, typename S>
- void sum_<V,S>::take(const value& v)
+ void sum_<V,S>::take(const argument& x)
{
- s_ += v;
+ s_ += x;
}
template <typename V, typename S>
Index: trunk/milena/mln/accu/v.hh
===================================================================
--- trunk/milena/mln/accu/v.hh (revision 1245)
+++ trunk/milena/mln/accu/v.hh (revision 1246)
@@ -50,15 +50,15 @@
template <typename A>
struct val_ : public mln::accu::internal::base_< mln_result(A) , val_<A> >
{
- typedef mln_value(A) value;
+ typedef mln_argument(A) argument;
typedef mln_result(A) result;
val_();
val_(const A& a);
void init();
- void take_as_init(const value& v);
- void take(const value& v);
+ void take_as_init(const argument& x);
+ void take(const argument& x);
void take(const val_<A>& other);
template <typename I>
@@ -118,16 +118,16 @@
template <typename A>
void
- val_<A>::take_as_init(const value& v)
+ val_<A>::take_as_init(const argument& x)
{
- a_.take_as_init(v);
+ a_.take_as_init(x);
}
template <typename A>
void
- val_<A>::take(const value& v)
+ val_<A>::take(const argument& x)
{
- a_.take(v);
+ a_.take(x);
}
template <typename A>
Index: trunk/milena/mln/accu/internal/base.hh
===================================================================
Index: trunk/milena/mln/accu/mean.hh
===================================================================
--- trunk/milena/mln/accu/mean.hh (revision 1245)
+++ trunk/milena/mln/accu/mean.hh (revision 1246)
@@ -60,13 +60,13 @@
typename M = S>
struct mean_ : public mln::accu::internal::base_< M , mean_<V,S,M> >
{
- typedef V value;
+ typedef V argument;
typedef M result;
mean_();
void init();
- void take(const value& v);
+ void take(const argument& x);
void take(const mean_<V,S,M>& other);
M to_result() const;
@@ -114,10 +114,10 @@
}
template <typename V, typename S, typename M>
- void mean_<V,S,M>::take(const value& v)
+ void mean_<V,S,M>::take(const argument& x)
{
- count_.take(v);
- sum_.take(v);
+ count_.take(x);
+ sum_.take(x);
}
template <typename V, typename S, typename M>
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-04 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Add generic line.
* mln/core/win/line.hh: New.
* mln/core/win/hline2d.hh,
* mln/core/win/vline2d.hh: Now inherit of line.
* tests/win_hline2d.cc: New.
---
mln/core/win/hline2d.hh | 125 +-------------------------------
mln/core/win/line.hh | 185 ++++++++++++++++++++++++++++++++++++++++++++++++
mln/core/win/vline2d.hh | 125 +-------------------------------
tests/win_hline2d.cc | 48 ++++++++++++
4 files changed, 247 insertions(+), 236 deletions(-)
Index: trunk/milena/tests/win_hline2d.cc
===================================================================
--- trunk/milena/tests/win_hline2d.cc (revision 0)
+++ trunk/milena/tests/win_hline2d.cc (revision 1245)
@@ -0,0 +1,48 @@
+// 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/win_diag2d.cc
+ *
+ * \brief Tests on mln::win::diag2d.
+ */
+
+#include <mln/core/win/hline2d.hh>
+
+#include <mln/convert/to_image.hh>
+
+#include <mln/debug/println.hh>
+
+int main()
+{
+ using namespace mln;
+
+ const unsigned l = 5;
+ win::hline2d hline(l);
+
+ debug::println(convert::to_image(hline));
+}
+
Index: trunk/milena/mln/core/win/vline2d.hh
===================================================================
--- trunk/milena/mln/core/win/vline2d.hh (revision 1244)
+++ trunk/milena/mln/core/win/vline2d.hh (revision 1245)
@@ -33,10 +33,8 @@
* \brief Definition of the mln::win::vline2d window.
*/
-# include <mln/core/concept/window.hh>
-# include <mln/core/internal/dpoints_base.hh>
-# include <mln/core/dpoint2d.hh>
-# include <mln/core/dpoints_piter.hh>
+# include <mln/core/win/line.hh>
+# include <mln/core/grids.hh>
namespace mln
@@ -56,123 +54,14 @@
* o \n
* is defined with length = 5.
*/
- struct vline2d : public Window< vline2d >,
- public internal::dpoints_base_< dpoint2d, vline2d >
+ struct vline2d : public line<grid::square, 0, vline2d>
{
- /// Point associated type.
- typedef point2d point;
-
- /// Dpoint associated type.
- typedef dpoint2d dpoint;
-
- /*! \brief Point_Iterator type to browse a vline such as: "for each row
- * (increasing), for each column (increasing)."
- */
- typedef dpoints_fwd_piter<dpoint2d> fwd_qiter;
-
- /*! \brief Point_Iterator type to browse a vline such as: "for each row
- * (decreasing), for each column (decreasing)."
- */
- typedef dpoints_bkd_piter<dpoint2d> bkd_qiter;
-
- /*! \brief Same as fwd_qiter.
- */
- typedef fwd_qiter qiter;
-
- /*! \brief Constructor.
- *
- * \param[in] length Length, thus height, of the vertical line.
- *
- * \pre \p length is odd.
- */
- vline2d(unsigned length);
-
- /*! \brief Test if the window is centered.
- *
- * \return True.
- */
- bool is_centered() const;
-
- /*! \brief Test if the window is symmetric.
- *
- * \return true.
- */
- bool is_symmetric() const;
-
- /*! \brief Give the vline length, that is, its height.
- */
- unsigned length() const;
-
- /*! \brief Give the maximum coordinate gap between the window
- * center and a window point.
- */
- unsigned delta() const;
-
- /// Apply a central symmetry to the target window.
- vline2d& sym();
-
- protected:
- unsigned length_;
- };
-
-
- /*! \brief Print a vertical 2D line window \p win into the output
- * stream \p ostr.
- *
- * \param[in,out] ostr An output stream.
- * \param[in] win A vertical 2D line window.
- *
- * \return The modified output stream \p ostr.
- *
- * \relates mln::win::vline2d
- */
- std::ostream& operator<<(std::ostream& ostr, const vline2d& win);
-
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- vline2d::vline2d(unsigned length)
- : length_(length)
+ // Ctor.
+ vline2d(unsigned length)
+ : line<grid::square, 0, vline2d>(length)
{
- mln_precondition(length % 2 == 1);
- const int drow = length / 2;
- for (int row = - drow; row <= drow; ++row)
- insert(make::dpoint2d(row, 0));
}
-
- bool vline2d::is_centered() const
- {
- return true;
- }
-
- bool vline2d::is_symmetric() const
- {
- return true;
- }
-
- unsigned vline2d::length() const
- {
- return length_;
- }
-
- unsigned vline2d::delta() const
- {
- return length_ / 2;
- }
-
- vline2d& vline2d::sym()
- {
- return *this;
- }
-
- std::ostream& operator<<(std::ostream& ostr, const vline2d& win)
- {
- ostr << "[line2d: length=" << win.length() << ']';
- return ostr;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
+ };
} // end of namespace mln::win
Index: trunk/milena/mln/core/win/hline2d.hh
===================================================================
--- trunk/milena/mln/core/win/hline2d.hh (revision 1244)
+++ trunk/milena/mln/core/win/hline2d.hh (revision 1245)
@@ -33,10 +33,8 @@
* \brief Definition of the mln::win::hline2d window.
*/
-# include <mln/core/concept/window.hh>
-# include <mln/core/internal/dpoints_base.hh>
-# include <mln/core/dpoint2d.hh>
-# include <mln/core/dpoints_piter.hh>
+# include <mln/core/win/line.hh>
+# include <mln/core/grids.hh>
namespace mln
@@ -54,123 +52,14 @@
* o o x o o \n
* is defined with length = 5.
*/
- struct hline2d : public Window< hline2d >,
- public internal::dpoints_base_< dpoint2d, hline2d >
+ struct hline2d : public line<grid::square, 1, hline2d>
{
- /// Point associated type.
- typedef point2d point;
-
- /// Dpoint associated type.
- typedef dpoint2d dpoint;
-
- /*! \brief Point_Iterator type to browse a hline such as: "for each row
- * (increasing), for each column (increasing)."
- */
- typedef dpoints_fwd_piter<dpoint2d> fwd_qiter;
-
- /*! \brief Point_Iterator type to browse a hline such as: "for each row
- * (decreasing), for each column (decreasing)."
- */
- typedef dpoints_bkd_piter<dpoint2d> bkd_qiter;
-
- /*! \brief Same as fwd_qiter.
- */
- typedef fwd_qiter qiter;
-
- /*! \brief Constructor.
- *
- * \param[in] length Length, thus width, of the horizontal line.
- *
- * \pre \p length is odd.
- */
- hline2d(unsigned length);
-
- /*! \brief Test if the window is centered.
- *
- * \return True.
- */
- bool is_centered() const;
-
- /*! \brief Test if the window is symmetric.
- *
- * \return true.
- */
- bool is_symmetric() const;
-
- /*! \brief Give the hline length, that is, its width.
- */
- unsigned length() const;
-
- /*! \brief Give the maximum coordinate gap between the window
- * center and a window point.
- */
- unsigned delta() const;
-
- /// Apply a central symmetry to the target window.
- hline2d& sym();
-
- protected:
- unsigned length_;
- };
-
-
- /*! \brief Print an horizontal 2D line window \p win into the output
- * stream \p ostr.
- *
- * \param[in,out] ostr An output stream.
- * \param[in] win An horizontal 2D line window.
- *
- * \return The modified output stream \p ostr.
- *
- * \relates mln::win::hline2d
- */
- std::ostream& operator<<(std::ostream& ostr, const hline2d& win);
-
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- hline2d::hline2d(unsigned length)
- : length_(length)
+ // Ctor.
+ hline2d(unsigned length)
+ : line<grid::square, 1, hline2d>(length)
{
- mln_precondition(length % 2 == 1);
- const int dcol = length / 2;
- for (int col = - dcol; col <= dcol; ++col)
- insert(make::dpoint2d(0, col));
}
-
- bool hline2d::is_centered() const
- {
- return true;
- }
-
- bool hline2d::is_symmetric() const
- {
- return true;
- }
-
- unsigned hline2d::length() const
- {
- return length_;
- }
-
- unsigned hline2d::delta() const
- {
- return length_ / 2;
- }
-
- hline2d& hline2d::sym()
- {
- return *this;
- }
-
- std::ostream& operator<<(std::ostream& ostr, const hline2d& win)
- {
- ostr << "[line2d: length=" << win.length() << ']';
- return ostr;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
+ };
} // end of namespace mln::win
Index: trunk/milena/mln/core/win/line.hh
===================================================================
--- trunk/milena/mln/core/win/line.hh (revision 0)
+++ trunk/milena/mln/core/win/line.hh (revision 1245)
@@ -0,0 +1,185 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_WIN_LINE_HH
+# define MLN_CORE_WIN_LINE_HH
+
+/*! \file mln/core/win/line.hh
+ *
+ * \brief Definition of the mln::win::line window.
+ */
+
+# include <mln/core/concept/window.hh>
+# include <mln/core/internal/dpoints_base.hh>
+# include <mln/core/dpoint.hh>
+# include <mln/core/dpoints_piter.hh>
+
+
+namespace mln
+{
+
+ namespace win
+ {
+
+ template <typename M, unsigned i, typename E>
+ struct line : public Window<E>,
+ public internal::dpoints_base_
+ <dpoint_
+ <M, int>, point_
+ <M, int> >
+ {
+ /// Point associated type.
+ typedef point_<M, int> point;
+
+ /// Dpoint associated type.
+ typedef dpoint_<M, int> dpoint;
+
+ /// Point_Iterator type to browse a line forward
+ typedef dpoints_fwd_piter<dpoint> fwd_qiter;
+
+ /// Point_Iterator type to browse a line backward
+ typedef dpoints_bkd_piter<dpoint> bkd_qiter;
+
+ /// Same as fwd_qiter
+ typedef fwd_qiter qiter;
+
+ /*! \brief Constructor.
+ *
+ * \param[in] length Length of the line.
+ *
+ * \pre \p length is odd.
+ */
+ line(unsigned length);
+
+ /*! \brief Test if the window is centered.
+ *
+ * \return True.
+ */
+ bool is_centered() const;
+
+ /*! \brief Test if the window is symmetric.
+ *
+ * \return true.
+ */
+ bool is_symmetric() const;
+
+ /*! \brief Give the hline length, that is, its width.
+ */
+ unsigned length() const;
+
+ /*! \brief Give the maximum coordinate gap between the window
+ * center and a window point.
+ */
+ unsigned delta() const;
+
+ /// Apply a central symmetry to the target window.
+ E& sym();
+
+ protected:
+ unsigned length_;
+ };
+
+
+ /*! \brief Print an line window \p win into the output
+ * stream \p ostr.
+ *
+ * \param[in,out] ostr An output stream.
+ * \param[in] win An line window.
+ *
+ * \return The modified output stream \p ostr.
+ *
+ * \relates mln::win::line
+ */
+ template <typename M, unsigned i, typename E>
+ std::ostream& operator<<(std::ostream& ostr, const line<M,i,E>& win);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename M, unsigned i, typename E>
+ line<M,i,E>::line(unsigned length)
+ : length_(length)
+ {
+ mln_precondition(i < M::dim);
+ mln_precondition(length % 2 == 1);
+ const int dcol = length / 2;
+ for (int col = - dcol; col <= dcol; ++col)
+ {
+ dpoint n;
+ n[i] = col;
+ insert(n);
+ }
+ }
+
+ template <typename M, unsigned i, typename E>
+ bool line<M,i,E>::is_centered() const
+ {
+ return true;
+ }
+
+ template <typename M, unsigned i, typename E>
+ bool line<M,i,E>::is_symmetric() const
+ {
+ return true;
+ }
+
+ template <typename M, unsigned i, typename E>
+ unsigned line<M,i,E>::length() const
+ {
+ return length_;
+ }
+
+ template <typename M, unsigned i, typename E>
+ unsigned line<M,i,E>::delta() const
+ {
+ return length_ / 2;
+ }
+
+ template <typename M, unsigned i, typename E>
+ E& line<M,i,E>::sym()
+ {
+ return exact(*this);
+ }
+
+ template <typename M, unsigned i, typename E>
+ std::ostream& operator<<(std::ostream& ostr, const line<M,i,E>& win)
+ {
+ ostr << "[line: length=" << win.length() << ']';
+ return ostr;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::win
+
+} // end of namespace mln
+
+
+
+#endif // ! MLN_CORE_WIN_LINE_HH
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-04 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Fix chamfer.
* chamfer.hh: Update.
---
chamfer.hh | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
Index: trunk/milena/sandbox/duhamel/chamfer.hh
===================================================================
--- trunk/milena/sandbox/duhamel/chamfer.hh (revision 1243)
+++ trunk/milena/sandbox/duhamel/chamfer.hh (revision 1244)
@@ -27,6 +27,7 @@
# include <mln/core/image_if_interval.hh>
# include <mln/core/dpoint2d.hh>
+# include <math.h>
namespace mln
{
@@ -50,7 +51,7 @@
{
int ws[] = { 0, d21, 0, d21, 0,
d21, d11, d10, d11, d21,
- 0, d10, 0, d10, 0,
+ 0, d10, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0 };
@@ -72,13 +73,24 @@
{
float ws[] = { 0, d21, 0, d21, 0,
d21, d11, d10, d11, d21,
- 0, d10, 0, d10, 0,
+ 0, d10, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0 };
return (make::w_window2d(ws));
}
+ const w_window2d_float
+ mk_chamfer_exact()
+ {
+ float r2 = sqrt(2);
+ float ws[] = { r2, 1, r2,
+ 1, 0, 0,
+ 0, 0, 0 };
+
+ return (make::w_window2d(ws));
+ }
+
} // end of mln::win_chamfer
template <typename I, typename W>
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-04 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Update chamfer.
* chamfer.cc: Test for chamfer.
* chamfer.hh: New split of old version.
* color_sub.cc,
* color_sub.hh,
* main.cc: Update.
---
chamfer.cc | 121 ++++++++++++------------------------------------------
chamfer.hh | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
color_sub.cc | 3 -
color_sub.hh | 23 +++++-----
main.cc | 1
5 files changed, 173 insertions(+), 106 deletions(-)
Index: trunk/milena/sandbox/duhamel/main.cc
===================================================================
--- trunk/milena/sandbox/duhamel/main.cc (revision 1242)
+++ trunk/milena/sandbox/duhamel/main.cc (revision 1243)
@@ -26,6 +26,7 @@
{
}
+
int
main (void)
{
Index: trunk/milena/sandbox/duhamel/color_sub.cc
===================================================================
--- trunk/milena/sandbox/duhamel/color_sub.cc (revision 1242)
+++ trunk/milena/sandbox/duhamel/color_sub.cc (revision 1243)
@@ -57,8 +57,7 @@
image2d_b<value::int_u8> ima(3,3);
debug::iota(ima);
std::cout << ima.domain() << std::endl;
- image2d_b<value::rgb8> out(ima.domain ().bbox ());
- color(inplace (ima | 6), out);
+ image2d_b<value::rgb8> out = color(inplace (ima | 6));
io::ppm::save(out, "out.ppm");
debug::println(out);
}
Index: trunk/milena/sandbox/duhamel/chamfer.cc
===================================================================
--- trunk/milena/sandbox/duhamel/chamfer.cc (revision 1242)
+++ trunk/milena/sandbox/duhamel/chamfer.cc (revision 1243)
@@ -1,6 +1,9 @@
#include <mln/core/image2d_b.hh>
#include <mln/core/sub_image.hh>
+#include <mln/core/image_if_value.hh>
#include <mln/core/neighb2d.hh>
+#include <mln/core/inplace.hh>
+
#include <mln/value/int_u8.hh>
#include <mln/level/fill.hh>
#include <mln/level/stretch.hh>
@@ -12,6 +15,7 @@
# include <mln/labeling/base.hh>
# include <mln/debug/println.hh>
# include <mln/core/window2d.hh>
+# include <mln/core/w_window2d_int.hh>
# include <mln/convert/to_window.hh>
# include <mln/core/concept/dpoint.hh>
# include <mln/core/concept/neighborhood.hh>
@@ -20,114 +24,43 @@
# include <mln/pw/cst.hh>
# include <mln/metal/is_a.hh>
+# include <mln/core/image_if_interval.hh>
+#include "chamfer.hh"
-namespace mln
-{
- namespace convert
- {
-// template <typename N>
-// window<mln_dpoint(N)> to_upper_window(const Neighborhood<N>& nbh_)
-// {
-// const N& nbh = exact(nbh_);
-// typedef mln_dpoint(N) D;
-// typedef mln_point(D) P;
-// window<D> win;
-// mln_niter(N) n(nbh, P::zero);
-// for_all(n)
-// if (n > P::zero)
-// win.insert(n - P::zero);
-// return win;
-// }
- template <typename N>
- window<mln_dpoint(N)> to_lower_window(const Neighborhood<N>& nbh_)
- {
- const N& nbh = exact(nbh_);
- typedef mln_dpoint(N) D;
- typedef mln_point(D) P;
- window<D> win;
- mln_niter(N) n(nbh, P::zero);
- for_all(n)
- if (n < P::zero)
- win.insert(n - P::zero);
- return win;
- }
-
- } // end of namespace convert
-
- template <typename I, typename N, typename J>
- void
- chamfer (Image<I>& ima_, const Neighborhood<N>& nbh_,
- mln_point(I)& point, unsigned max, Image<J>& out_)
+int main()
{
- I& ima = exact (ima_);
- J& out = exact (out_);
+ using namespace mln;
+ unsigned max = 51;
- typedef window<mln_dpoint(I)> W;
+ image2d_b<bool> ima(9, 9);
- /// Init.
{
- level::fill (out, max);
- out(point) = 0;
+ level::fill(ima, false);
+ ima.at(4,4) = true;
+ const w_window2d_int& w_win = win_chamfer::mk_chamfer_3x3_int<2, 0> ();
+ image2d_b<unsigned> out = chamfer(ima, w_win, max);
+ debug::println(out | value::interval(0, 8));
}
- /// Fwd pass.
{
- mln_fwd_piter (I) p (ima.domain ());
- W win = convert::to_upper_window(nbh_);
- mln_qiter(W) n(win, p);
-
- for_all (p)
- {
- for_all (n)
- {
- if (out(n) > out(p) + 1)
- out(n) = out(p) + 1;
- }
- }
+ level::fill(ima, false);
+ ima.at(4,4) = true;
+ const w_window2d_int& w_win = win_chamfer::mk_chamfer_3x3_int<2, 3> ();
+ image2d_b<unsigned> out = chamfer(ima, w_win, max);
+ debug::println(out | value::interval(0, 8));
}
- /// Bkd pass.
{
- mln_bkd_piter (I) p (ima.domain ());
- W win = convert::to_lower_window(nbh_);
- mln_qiter(W) n( win, p);
-
+ level::fill(ima, false);
+ ima.at(4,4) = true;
+ const w_window2d_int& w_win = win_chamfer::mk_chamfer_5x5_int<4, 6, 9> ();
+ image2d_b<unsigned> out = chamfer(ima, w_win, max);
+ image2d_b<unsigned>::fwd_piter p(out.domain());
for_all (p)
- {
- for_all (n)
- {
- if (out(n) > out(p) + 1)
- out(n) = out(p) + 1;
- }
- }
+ out(p) = out(p) / 2;
+ debug::println(out | value::interval(0, 8));
}
- }
-} // end of mln
-int main ()
-{
- using namespace mln;
- using value::int_u8;
-
- {
- image2d_b<int_u8> ima (9, 9);
- image2d_b<unsigned> out (ima.domain ());
- point2d p = make::point2d(4,4);
-
- chamfer (ima, c4(), p, 255, out);
- debug::println (out);
- }
-
-
-
- {
- image2d_b<int_u8> ima (1000, 1000);
- image2d_b<unsigned> out (ima.domain ());
- point2d p = make::point2d(4,4);
-
- chamfer (ima, c4(), p, 255, out);
- }
- // debug::println (out);
}
Index: trunk/milena/sandbox/duhamel/color_sub.hh
===================================================================
--- trunk/milena/sandbox/duhamel/color_sub.hh (revision 1242)
+++ trunk/milena/sandbox/duhamel/color_sub.hh (revision 1243)
@@ -37,24 +37,27 @@
namespace mln
{
- template <typename I, typename J>
- void
- color (Image<I>& ima_ , Image<J>& out_)
+ template <typename I>
+ mln_ch_value (I, value::rgb8)
+ color (const Image<I>& input_)
{
- I& ima = exact (ima_);
- J& out = exact (out_);
- // image2d_b<value::rgb8> out(ima.domain ().bbox ());
+ const I& input = exact (input_);
- level::fill (out, value::rgb8(255, 0, 0));
+ mln_ch_value(I, value::rgb8) output;
+ initialize(output, input);
+
+ // image2d_b<value::rgb8> output(ima.domain ().bbox ());
+
+ level::fill (output, value::rgb8(255, 0, 0));
{
- mln_piter(I) p (ima.domain ());
+ mln_piter(I) p (input.domain ());
for_all (p)
{
- out(p) = value::rgb8(ima(p));
+ output(p) = value::rgb8(input(p));
}
}
- // return out;
+ return output;
}
}
Index: trunk/milena/sandbox/duhamel/chamfer.hh
===================================================================
--- trunk/milena/sandbox/duhamel/chamfer.hh (revision 0)
+++ trunk/milena/sandbox/duhamel/chamfer.hh (revision 1243)
@@ -0,0 +1,131 @@
+#include <mln/core/image2d_b.hh>
+#include <mln/core/sub_image.hh>
+#include <mln/core/image_if_value.hh>
+#include <mln/core/neighb2d.hh>
+#include <mln/core/inplace.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/level/fill.hh>
+#include <mln/level/stretch.hh>
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/core/mesh_image.hh>
+# include <mln/labeling/base.hh>
+# include <mln/debug/println.hh>
+# include <mln/core/window2d.hh>
+# include <mln/core/w_window2d_int.hh>
+# include <mln/core/w_window2d_float.hh>
+# include <mln/convert/to_window.hh>
+# include <mln/core/concept/dpoint.hh>
+# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/window.hh>
+# include <mln/pw/image.hh>
+# include <mln/pw/cst.hh>
+# include <mln/metal/is_a.hh>
+
+# include <mln/core/image_if_interval.hh>
+# include <mln/core/dpoint2d.hh>
+
+namespace mln
+{
+ namespace win_chamfer
+ {
+
+ template<int d10, int d11>
+ const w_window2d_int
+ mk_chamfer_3x3_int()
+ {
+ int ws[] = { d11, d10, d11,
+ d10, 0, 0,
+ 0, 0, 0 };
+
+ return (make::w_window2d(ws));
+ }
+
+ template<int d10, int d11, int d21>
+ const w_window2d_int
+ mk_chamfer_5x5_int()
+ {
+ int ws[] = { 0, d21, 0, d21, 0,
+ d21, d11, d10, d11, d21,
+ 0, d10, 0, d10, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0 };
+
+ return (make::w_window2d(ws));
+ }
+
+ const w_window2d_float
+ mk_chamfer_3x3_float(float d10, float d11)
+ {
+ float ws[] = { d11, d10, d11,
+ d10, 0, 0,
+ 0, 0, 0 };
+
+ return (make::w_window2d(ws));
+ }
+
+ const w_window2d_float
+ mk_chamfer_5x5_float(float d10, float d11, float d21)
+ {
+ float ws[] = { 0, d21, 0, d21, 0,
+ d21, d11, d10, d11, d21,
+ 0, d10, 0, d10, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0 };
+
+ return (make::w_window2d(ws));
+ }
+
+ } // end of mln::win_chamfer
+
+ template <typename I, typename W>
+ mln_ch_value(I, unsigned)
+ chamfer(const Image<I>& input_, const Weighted_Window<W>& w_win_,
+ unsigned max = mln_max(unsigned))
+ {
+ const I& input = exact(input_);
+ const W& w_win = exact(w_win_);
+
+ mln_ch_value(I, unsigned) output;
+ initialize(output, input);
+
+ /// Init.
+ {
+ level::fill(inplace(output | (input | true).domain()), 0);
+ level::fill(inplace(output | (input | false).domain()), max);
+ }
+
+ /// Fwd pass.
+ {
+ mln_fwd_piter(I) p(input.domain());
+ mln_qiter(W) q(w_win, p);
+
+ for_all(p) if (input(p) == false)
+ for_all(q) if (input.has(q))
+ if (output(q) != max
+ && output(q) + q.w() < output(p))
+ output(p) = output(q) + q.w();
+ }
+
+ /// Bkd pass.
+ {
+
+ W w_win_b = geom::sym(w_win);
+
+ mln_bkd_piter(I) p(input.domain());
+ mln_qiter(W) q(w_win_b, p);
+
+ for_all(p) if (input(p) == false)
+ for_all(q) if (input.has(q))
+ if (output(q) != max
+ && output(q) + q.w() < output(p))
+ output(p) = output(q) + q.w();
+ }
+
+ return output;
+ }
+
+} // end of mln
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-04 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Fix chamfer.
* chamfer.cc: .
---
chamfer.cc | 1 -
1 file changed, 1 deletion(-)
Index: trunk/milena/sandbox/duhamel/chamfer.cc
===================================================================
--- trunk/milena/sandbox/duhamel/chamfer.cc (revision 1241)
+++ trunk/milena/sandbox/duhamel/chamfer.cc (revision 1242)
@@ -75,7 +75,6 @@
/// Fwd pass.
{
mln_fwd_piter (I) p (ima.domain ());
- p = point;
W win = convert::to_upper_window(nbh_);
mln_qiter(W) n(win, p);
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-04 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add chamfer in sadbox.
* chamfer.cc: New.
* color_sub.cc: .
* color_sub.hh: New : split ols version.
* labeling_algo.cc: .
* labeling_level_fast.cc: .
---
chamfer.cc | 134 +++++++++++++++++++++++++++++++++++++++++++++++++
color_sub.cc | 23 --------
color_sub.hh | 60 +++++++++++++++++++++
labeling_algo.cc | 20 ++-----
labeling_level_fast.cc | 11 +---
5 files changed, 205 insertions(+), 43 deletions(-)
Index: trunk/milena/sandbox/duhamel/labeling_algo.cc
===================================================================
--- trunk/milena/sandbox/duhamel/labeling_algo.cc (revision 1240)
+++ trunk/milena/sandbox/duhamel/labeling_algo.cc (revision 1241)
@@ -36,15 +36,14 @@
# include <mln/value/int_u8.hh>
# include <mln/level/fill.hh>
# include <mln/level/stretch.hh>
-# include <mln/level/saturate.hh>
# include <mln/border/fill.hh>
# include <mln/io/pbm/load.hh>
# include <mln/io/pgm/save.hh>
# include <mln/labeling/foreground.hh>
# include <mln/debug/println.hh>
-# include <mln/debug/println_with_border.hh>
# include <mln/draw/mesh.hh>
-# include "labeling_algo.hh"
+# include <mln/geom/seeds2tiling.hh>
+# include <mln/make/voronoi.hh>
int main()
{
@@ -52,7 +51,7 @@
using value::int_u8;
// image2d_b<bool> in = io::pbm::load("../../img/toto.pbm");
- image2d_b<bool> in = io::pbm::load("test.pbm");
+ image2d_b<bool> in = io::pbm::load("toto.pbm");
image2d_b<int_u8> lab(in.domain());
image2d_b<int_u8> inte(in.domain());
@@ -64,28 +63,21 @@
std::vector<int_u8> vec;
image2d_b<int> input(in.domain());
- // debug::println (in | make::box2d (100,100));
level::fill(input, lab);
lab(make::point2d (0,0)) = 0;
- inte = make_algo(lab, c4 ());
+ inte = geom::seeds2tiling(lab, c4 ());
border::fill (inte, 0);
image2d_b<int_u8> inte2(inte.domain());
level::stretch (inte, inte2);
- io::pgm::save(inte, "inte.pgm");
- io::pgm::save(inte2, "inte2.pgm");
-
- debug::println(lab | make::box2d (30,30) );
-
- // mesh_p<point2d> m = make::graph_with_no_border(inte, c4());
+ io::pgm::save(inte2, "inte.pgm");
mesh_p<point2d> m = make::voronoi(inte, lab, c4());
- std::cout << "OK" << std::endl;
+ std::cout << "OK : generate inte.pgm and out.pgm" << std::endl;
draw::mesh (out, m, 255, 128);
- // debug::println(out);
io::pgm::save(out, "out.pgm");
}
Index: trunk/milena/sandbox/duhamel/color_sub.cc
===================================================================
--- trunk/milena/sandbox/duhamel/color_sub.cc (revision 1240)
+++ trunk/milena/sandbox/duhamel/color_sub.cc (revision 1241)
@@ -48,26 +48,7 @@
#include <mln/core/image_if_value.hh>
#include <mln/debug/iota.hh>
-namespace mln
-{
- template <typename I, typename J>
- void
- color (Image<I>& ima_, Image<J>& out_)
- {
- I& ima = exact (ima_);
- J& out = exact (out_);
-
- level::fill (out, value::rgb8(255, 0, 0));
-
- {
- mln_piter(I) p (ima.domain ());
- for_all (p)
- {
- out(p) = value::rgb8(ima(p));
- }
- }
- }
-}
+#include "color_sub.hh"
int main()
{
@@ -75,8 +56,8 @@
image2d_b<value::int_u8> ima(3,3);
debug::iota(ima);
- image2d_b<value::rgb8> out(ima.domain ().bbox ());
std::cout << ima.domain() << std::endl;
+ image2d_b<value::rgb8> out(ima.domain ().bbox ());
color(inplace (ima | 6), out);
io::ppm::save(out, "out.ppm");
debug::println(out);
Index: trunk/milena/sandbox/duhamel/chamfer.cc
===================================================================
--- trunk/milena/sandbox/duhamel/chamfer.cc (revision 0)
+++ trunk/milena/sandbox/duhamel/chamfer.cc (revision 1241)
@@ -0,0 +1,134 @@
+#include <mln/core/image2d_b.hh>
+#include <mln/core/sub_image.hh>
+#include <mln/core/neighb2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/level/fill.hh>
+#include <mln/level/stretch.hh>
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/core/mesh_image.hh>
+# include <mln/labeling/base.hh>
+# include <mln/debug/println.hh>
+# include <mln/core/window2d.hh>
+# include <mln/convert/to_window.hh>
+# include <mln/core/concept/dpoint.hh>
+# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/window.hh>
+# include <mln/pw/image.hh>
+# include <mln/pw/cst.hh>
+# include <mln/metal/is_a.hh>
+
+
+
+namespace mln
+{
+ namespace convert
+ {
+// template <typename N>
+// window<mln_dpoint(N)> to_upper_window(const Neighborhood<N>& nbh_)
+// {
+// const N& nbh = exact(nbh_);
+// typedef mln_dpoint(N) D;
+// typedef mln_point(D) P;
+// window<D> win;
+// mln_niter(N) n(nbh, P::zero);
+// for_all(n)
+// if (n > P::zero)
+// win.insert(n - P::zero);
+// return win;
+// }
+
+ template <typename N>
+ window<mln_dpoint(N)> to_lower_window(const Neighborhood<N>& nbh_)
+ {
+ const N& nbh = exact(nbh_);
+ typedef mln_dpoint(N) D;
+ typedef mln_point(D) P;
+ window<D> win;
+ mln_niter(N) n(nbh, P::zero);
+ for_all(n)
+ if (n < P::zero)
+ win.insert(n - P::zero);
+ return win;
+ }
+
+ } // end of namespace convert
+
+ template <typename I, typename N, typename J>
+ void
+ chamfer (Image<I>& ima_, const Neighborhood<N>& nbh_,
+ mln_point(I)& point, unsigned max, Image<J>& out_)
+ {
+ I& ima = exact (ima_);
+ J& out = exact (out_);
+
+ typedef window<mln_dpoint(I)> W;
+
+ /// Init.
+ {
+ level::fill (out, max);
+ out(point) = 0;
+ }
+
+ /// Fwd pass.
+ {
+ mln_fwd_piter (I) p (ima.domain ());
+ p = point;
+ W win = convert::to_upper_window(nbh_);
+ mln_qiter(W) n(win, p);
+
+ for_all (p)
+ {
+ for_all (n)
+ {
+ if (out(n) > out(p) + 1)
+ out(n) = out(p) + 1;
+ }
+ }
+ }
+
+ /// Bkd pass.
+ {
+ mln_bkd_piter (I) p (ima.domain ());
+ W win = convert::to_lower_window(nbh_);
+ mln_qiter(W) n( win, p);
+
+ for_all (p)
+ {
+ for_all (n)
+ {
+ if (out(n) > out(p) + 1)
+ out(n) = out(p) + 1;
+ }
+ }
+ }
+ }
+} // end of mln
+
+int main ()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ {
+ image2d_b<int_u8> ima (9, 9);
+ image2d_b<unsigned> out (ima.domain ());
+ point2d p = make::point2d(4,4);
+
+ chamfer (ima, c4(), p, 255, out);
+ debug::println (out);
+ }
+
+
+
+ {
+ image2d_b<int_u8> ima (1000, 1000);
+ image2d_b<unsigned> out (ima.domain ());
+ point2d p = make::point2d(4,4);
+
+ chamfer (ima, c4(), p, 255, out);
+ }
+ // debug::println (out);
+}
Index: trunk/milena/sandbox/duhamel/labeling_level_fast.cc
===================================================================
--- trunk/milena/sandbox/duhamel/labeling_level_fast.cc (revision 1240)
+++ trunk/milena/sandbox/duhamel/labeling_level_fast.cc (revision 1241)
@@ -40,11 +40,7 @@
#include <mln/io/pgm/save.hh>
#include <mln/labeling/level.hh>
#include <mln/debug/iota.hh>
-#include <mln/debug/println_with_border.hh>
-
-#include "paste.hh"
-#include "fill.hh"
-
+#include <mln/debug/println.hh>
int main()
{
@@ -56,12 +52,11 @@
image2d_b<value::int_u8> i1(5, 5, border);
debug::iota(i1);
i1[10] = i1[17] = i1[18] = i1[25] = i1[26] = i1[22] = i1[29] = 2;
- // i1[5] = i1[6] = 2;
- debug::println_with_border(i1);
+ debug::println(i1);
unsigned n;
image2d_b<value::int_u8> out(i1.domain(), border);
- labeling_level_fast(i1, 2, c4(), out, n);
+ labeling::level_fast(i1, 2, c4(), out, n);
std::cout << "n = " << n << std::endl;
debug::println(out);
Index: trunk/milena/sandbox/duhamel/color_sub.hh
===================================================================
--- trunk/milena/sandbox/duhamel/color_sub.hh (revision 0)
+++ trunk/milena/sandbox/duhamel/color_sub.hh (revision 1241)
@@ -0,0 +1,60 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/sub_image.hh
+ *
+ * \brief .
+ */
+
+#include <mln/core/image_if_value.hh>
+#include <mln/core/image2d_b.hh>
+#include <mln/value/rgb8.hh>
+#include <mln/level/fill.hh>
+
+namespace mln
+{
+ template <typename I, typename J>
+ void
+ color (Image<I>& ima_ , Image<J>& out_)
+ {
+ I& ima = exact (ima_);
+ J& out = exact (out_);
+ // image2d_b<value::rgb8> out(ima.domain ().bbox ());
+
+ level::fill (out, value::rgb8(255, 0, 0));
+
+ {
+ mln_piter(I) p (ima.domain ());
+
+ for_all (p)
+ {
+ out(p) = value::rgb8(ima(p));
+ }
+ }
+ // return out;
+ }
+}
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-04 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Update doc of accus. Update Accumulator.
* mln/core/concept/accumulator.hh: Test if the convertion operator
exist.
* mln/core/concept/doc/accumulator.hh: Add operator result().
---
accumulator.hh | 3 +++
doc/accumulator.hh | 7 +++++++
2 files changed, 10 insertions(+)
Index: trunk/milena/mln/core/concept/doc/accumulator.hh
===================================================================
--- trunk/milena/mln/core/concept/doc/accumulator.hh (revision 1239)
+++ trunk/milena/mln/core/concept/doc/accumulator.hh (revision 1240)
@@ -44,6 +44,9 @@
/// The value type of elements to accumulate.
typedef void value;
+ /// The value type to return.
+ typedef void result_;
+
/// Initialize the accumulator.
void init();
@@ -52,6 +55,10 @@
/// Take into account another accumulator \p other.
void take(const E& other);
+
+ /// Convert the accumulator into the result.
+ operator result_() const;
+
};
} // end of namespace mln::doc
Index: trunk/milena/mln/core/concept/accumulator.hh
===================================================================
--- trunk/milena/mln/core/concept/accumulator.hh (revision 1239)
+++ trunk/milena/mln/core/concept/accumulator.hh (revision 1240)
@@ -71,6 +71,7 @@
void take(const value& v);
void take(const E& other);
result to_result() const;
+ operator result_() const;
*/
// Default impl.
@@ -99,6 +100,8 @@
m3 = 0;
result (E::*m4)() const = & E::to_result;
m4 = 0;
+ result (E::*m5)() const = & E::operator result;
+ m5 = 0;
}
template <typename E>
1
0