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
olena-2.0-63-g9846847 mln/registration/icp.hh: Add a missing initialization.
by Guillaume Lazzara 22 Jun '12
by Guillaume Lazzara 22 Jun '12
22 Jun '12
---
milena/ChangeLog | 4 ++++
milena/mln/registration/icp.hh | 2 +-
2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 306ac9d..c5146c0 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,9 @@
2012-05-07 Guillaume Lazzara <z(a)lrde.epita.fr>
+ * mln/registration/icp.hh: Add a missing initialization.
+
+2012-05-07 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* mln/io/magick/save.hh: Add generic and fast implementations.
2012-05-07 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/milena/mln/registration/icp.hh b/milena/mln/registration/icp.hh
index 9448a2f..aa263f7 100644
--- a/milena/mln/registration/icp.hh
+++ b/milena/mln/registration/icp.hh
@@ -532,7 +532,7 @@ namespace mln
const vec3d_f& qT)
{
/// Spx: cross-covariance matrix.
- algebra::mat<3u,3u,float> Spx;
+ algebra::mat<3u,3u,float> Spx(literal::zero);
mln_piter(p_array<P>) p(P_);
// FIXME: could we use an accu?
--
1.7.2.5
1
0
22 Jun '12
---
scribo/ChangeLog | 4 +
scribo/scribo/debug/logger.hh | 249 ++++++++++++++++++++++++++++++++++++++++-
2 files changed, 250 insertions(+), 3 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 69814de..1122e11 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,7 @@
+2012-05-07 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ * scribo/debug/logger.hh: Improve log system.
+
2012-04-05 Guillaume Lazzara <z(a)lrde.epita.fr>
Remove useless targets in scribo/src/binarization.
diff --git a/scribo/scribo/debug/logger.hh b/scribo/scribo/debug/logger.hh
index f16dd89..5822cf3 100644
--- a/scribo/scribo/debug/logger.hh
+++ b/scribo/scribo/debug/logger.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2011 EPITA Research and Development Laboratory
+// Copyright (C) 2011, 2012 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of Olena.
@@ -27,6 +27,8 @@
#ifndef SCRIBO_CORE_LOGGER_HH
# define SCRIBO_CORE_LOGGER_HH
+# include <iostream>
+# include <ctype.h>
# include <mln/core/concept/image.hh>
# include <mln/data/wrap.hh>
# include <mln/value/int_u8.hh>
@@ -34,6 +36,7 @@
# include <mln/io/pbm/save.hh>
# include <mln/io/pgm/save.hh>
# include <mln/io/ppm/save.hh>
+# include <mln/util/timer.hh>
namespace scribo
{
@@ -41,15 +44,48 @@ namespace scribo
namespace debug
{
+ /*! \brief Enum defining different level of image logging
+
+ According to the debug level set in #logger_ the image may
+ be saved or not.
+ */
enum Level
{
None = 0,
Special, // Reserved
Results,
AuxiliaryResults,
- All
+ All,
+ InvalidLevel // Reserved
};
+ /*! \brief Enum defining different modes of text logging
+
+ According to the verbose mode set in #logger_ the text may
+ be logged or not.
+ */
+ enum VerboseMode
+ {
+ Mute = 0,
+ UserDebug, // Reserved
+ Time,
+ Low,
+ Medium,
+ Full,
+ Invalid, // Reserved
+ };
+
+
+ /*! \brief returns the corresponding verboseMode from its name.
+
+ \internal
+ \warning Don't forget to update this function if a VerboseMode
+ value is added.
+ \endinternal
+ */
+ VerboseMode txt_to_verbose_mode(const std::string& name);
+
+
namespace internal
{
@@ -60,6 +96,22 @@ namespace scribo
public:
static logger_& instance();
+ /// Text Logging
+ /// @{
+ bool is_verbose() const;
+ bool is_at_verbose_mode(VerboseMode mode) const;
+
+ bool set_verbose_mode(VerboseMode mode);
+ VerboseMode verbose_mode() const;
+
+ void set_verbose_prefix(const std::string& prefix);
+
+ void log(VerboseMode mode, const std::string& text);
+ /// @}
+
+
+ /// Image Logging
+ /// @{
bool is_enabled() const;
bool is_at_level(Level level) const;
@@ -72,6 +124,37 @@ namespace scribo
template <typename I>
void log_image(Level dbg_level,
const Image<I>& ima, const char *name);
+ /// @}
+
+ /*! \brief Time Logging
+
+ This class provides two timers in order to performs
+ benchmarks inside a program.
+
+ Local time logging is meant to be used for benchmarking a
+ small portion of code, whereas global time logging is meant
+ to benchmark a whole program.
+
+ They can be used both at the same time.
+
+ Stopping time logging will output the computed time if
+ Verbose mode is higher or equal to #Time.
+ */
+ /// @{
+ void start_local_time_logging();
+ void stop_local_time_logging(const std::string& time_title);
+
+ void start_global_time_logging();
+ void stop_global_time_logging(const std::string& time_title);
+ /// @}
+
+
+ /*! \brief Quickly logs text.
+ It uses the default log mode to know if the text
+ */
+ template <typename V>
+ logger_& operator<<(const V&v);
+ logger_& operator<<(std::ostream& (*f)(std::ostream&));
private: // Methods
logger_();
@@ -110,6 +193,12 @@ namespace scribo
private: // Attributes
Level level_;
+ VerboseMode verbose_mode_;
+ std::string verbose_prefix_;
+ std::ostream& stream_;
+
+ mln::util::timer t_local_;
+ mln::util::timer t_global_;
};
} // end of namespace scribo::debug::internal
@@ -124,6 +213,14 @@ namespace scribo
namespace internal
{
+ std::string to_upper(const std::string& s)
+ {
+ std::string out(s);
+ for (size_t i = 0; i < s.size(); ++i)
+ out[i] = toupper(s[i]);
+ return out;
+ }
+
inline
logger_&
logger_::instance()
@@ -135,7 +232,10 @@ namespace scribo
inline
logger_::logger_()
- : level_(None)
+ : level_(None),
+ verbose_mode_(Mute),
+ stream_(std::cerr),
+ verbose_prefix_("LOG: ")
{
// Magick::InitializeMagick(0);
}
@@ -143,6 +243,7 @@ namespace scribo
inline
logger_::logger_(const logger_&)
+ : stream_(std::cerr)
{
abort();
}
@@ -150,6 +251,64 @@ namespace scribo
inline
bool
+ logger_::is_verbose() const
+ {
+ return verbose_mode_ > Mute;
+ }
+
+
+ inline
+ bool
+ logger_::is_at_verbose_mode(VerboseMode mode) const
+ {
+ return mode == verbose_mode_;
+ }
+
+
+ inline
+ bool
+ logger_::set_verbose_mode(VerboseMode mode)
+ {
+ if (mode != Invalid)
+ {
+ verbose_mode_ = mode;
+ return true;
+ }
+ return false;
+ }
+
+
+ inline
+ VerboseMode
+ logger_::verbose_mode() const
+ {
+ return verbose_mode_;
+ }
+
+
+ inline
+ void
+ logger_::set_verbose_prefix(const std::string& prefix)
+ {
+ verbose_prefix_ = prefix;
+ }
+
+
+ inline
+ void
+ logger_::log(VerboseMode mode, const std::string& text)
+ {
+# ifndef SCRIBO_NDEBUG
+ if (verbose_mode_ < mode)
+ return;
+
+ std::cerr << verbose_prefix_ << text << std::endl;
+# endif // ! SCRIBO_NDEBUG
+ }
+
+
+ inline
+ bool
logger_::is_enabled() const
{
return level_ != None;
@@ -212,6 +371,44 @@ namespace scribo
}
+ inline
+ void
+ logger_::start_local_time_logging()
+ {
+ t_local_.restart();
+ }
+
+
+ inline
+ void
+ logger_::stop_local_time_logging(const std::string& time_title)
+ {
+ t_local_.stop();
+ if (verbose_mode_ >= Time)
+ std::cerr << time_title << " " << t_local_ << "s" << std::endl;
+ }
+
+
+ inline
+ void
+ logger_::start_global_time_logging()
+ {
+ t_global_.restart();
+ }
+
+
+ inline
+ void
+ logger_::stop_global_time_logging(const std::string& time_title)
+ {
+ t_global_.stop();
+ if (verbose_mode_ >= Time)
+ std::cerr << time_title << " " << t_global_ << "s" << std::endl;
+ }
+
+
+ // Private dispatch
+
template <unsigned n, typename I>
void
logger_::log_image_dispatch(const value::int_u<n>&, const Image<I>& ima, const char *name)
@@ -273,6 +470,26 @@ namespace scribo
mln::debug::filename(name + ".pgm"));
}
+
+ template <typename V>
+ logger_&
+ logger_::operator<<(const V& v)
+ {
+ if (verbose_mode_ >= Low)
+ stream_ << v;
+ return *this;
+ }
+
+
+ logger_&
+ logger_::operator<<(std::ostream& (*f)(std::ostream&))
+ {
+ if (verbose_mode_ >= Low)
+ f(stream_);
+ return *this;
+ }
+
+
} // end of namespace scribo::debug::internal
@@ -284,6 +501,32 @@ namespace scribo
}
+ VerboseMode txt_to_verbose_mode(const std::string& name)
+ {
+ struct mode_name
+ {
+ const char *name;
+ VerboseMode mode;
+ };
+ static const mode_name mode[] = {
+ { "MUTE", Mute },
+ { "USERDEBUG", UserDebug },
+ { "TIME", Time },
+ { "LOW", Low },
+ { "MEDIUM", Medium },
+ { "FULL", Full },
+ { "INVALID", Invalid }
+ };
+
+ unsigned i;
+ std::string name_ = internal::to_upper(name);
+ for (i = 0; mode[i].mode != Invalid; ++i)
+ if (mode[i].name == name_)
+ break;
+
+ return mode[i].mode;
+ };
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace scribo::debug
--
1.7.2.5
1
0
olena-2.0-65-ge1b3bd7 Rely on Argument-Dependent Lookup (ADL) in from_to_ overloads.
by Guillaume Lazzara 22 Jun '12
by Guillaume Lazzara 22 Jun '12
22 Jun '12
* mln/accu/count_labels.hh,
* mln/convert/from_to.hxx ,
* mln/convert/to.hh,
* mln/core/alias/point1d.hh,
* mln/core/alias/point2d.hh,
* mln/core/alias/point3d.hh,
* mln/core/dpoint.hh,
* mln/core/internal/neighborhood_base.hh,
* mln/core/point.hh,
* mln/core/site_set/p_centered.hh,
* mln/core/site_set/p_vaccess.hh,
* mln/fun/v2v/hsl_to_rgb.hh,
* mln/fun/v2v/rgb_to_hsl.hh,
* mln/io/magick/save.hh,
* mln/io/plot/save.hh,
* mln/labeling/blobs_and_compute.hh,
* mln/labeling/value_and_compute.hh,
* mln/make/w_window2d.hh,
* mln/win/multiple.hh,
* mln/win/multiple_size.hh,
* tests/accu/site_set/rectangularity.cc,
* tests/core/other/graph_elt_neighborhood.cc,
* tests/core/other/graph_elt_window.cc,
* tests/core/other/point_set_compatibility.cc,
* tests/draw/graph.cc: Update forward declarations and includes.
* mln/algebra/vec.hh,
* mln/convert/from_to.hh,
* mln/convert/impl/from_double_to_value.hh,
* mln/convert/impl/from_float_to_value.hh,
* mln/convert/impl/from_image_to_site_set.hh,
* mln/convert/impl/from_int_to_value.hh,
* mln/convert/impl/from_unsigned_to_value.hh,
* mln/convert/impl/from_value_to_value.hh,
* mln/core/alias/neighb2d.hh,
* mln/core/alias/neighb3d.hh,
* mln/core/alias/window1d.hh,
* mln/core/alias/window2d.hh,
* mln/core/alias/window3d.hh,
* mln/core/concept/accumulator.hh,
* mln/core/concept/gdpoint.hh,
* mln/core/concept/gpoint.hh,
* mln/core/concept/image.hh,
* mln/core/concept/proxy.hh,
* mln/core/concept/site_set.hh,
* mln/core/concept/window.hh,
* mln/core/image/graph_window_if_piter.hh,
* mln/core/image/image1d.hh,
* mln/core/mixed_neighb.hh,
* mln/core/neighb.hh,
* mln/core/site_set/operators.hh,
* mln/core/w_window.hh,
* mln/fun/i2v/array.hh,
* mln/util/object_id.hh,
* mln/value/hsl.hh,
* mln/value/int_u.hh,
* mln/value/label.hh,
* mln/value/qt/rgb32.hh,
* mln/value/rgb.hh,
* mln/histo/array.hh,
* mln/util/array.hh: Move from_to_ overloads in the same namespace
as their first argument.
---
milena/ChangeLog | 67 +++
milena/mln/accu/count_labels.hh | 4 +-
milena/mln/algebra/vec.hh | 165 +++++++-
milena/mln/convert/from_to.hh | 130 +++---
milena/mln/convert/from_to.hxx | 441 +-------------------
milena/mln/convert/impl/from_double_to_value.hh | 159 ++++----
milena/mln/convert/impl/from_float_to_value.hh | 179 ++++----
milena/mln/convert/impl/from_image_to_site_set.hh | 8 +-
milena/mln/convert/impl/from_int_to_value.hh | 101 ++---
milena/mln/convert/impl/from_unsigned_to_value.hh | 140 +++----
milena/mln/convert/impl/from_value_to_value.hh | 7 +-
milena/mln/convert/to.hh | 1 -
milena/mln/core/alias/neighb2d.hh | 75 ++--
milena/mln/core/alias/neighb3d.hh | 51 +--
milena/mln/core/alias/point1d.hh | 5 +-
milena/mln/core/alias/point2d.hh | 5 +-
milena/mln/core/alias/point3d.hh | 5 +-
milena/mln/core/alias/window1d.hh | 51 +--
milena/mln/core/alias/window2d.hh | 100 ++---
milena/mln/core/alias/window3d.hh | 56 +--
milena/mln/core/concept/accumulator.hh | 70 +--
milena/mln/core/concept/gdpoint.hh | 60 +--
milena/mln/core/concept/gpoint.hh | 122 ++----
milena/mln/core/concept/image.hh | 89 ++--
milena/mln/core/concept/proxy.hh | 53 +--
milena/mln/core/concept/site_set.hh | 113 +++---
milena/mln/core/concept/window.hh | 109 ++---
milena/mln/core/dpoint.hh | 1 -
milena/mln/core/image/graph_window_if_piter.hh | 4 +-
milena/mln/core/image/image1d.hh | 65 +---
milena/mln/core/internal/neighborhood_base.hh | 9 +-
milena/mln/core/mixed_neighb.hh | 72 ++--
milena/mln/core/neighb.hh | 76 ++---
milena/mln/core/point.hh | 172 ++-------
milena/mln/core/site_set/operators.hh | 13 +-
milena/mln/core/site_set/p_centered.hh | 5 +-
milena/mln/core/site_set/p_vaccess.hh | 4 +-
milena/mln/core/w_window.hh | 191 +++------
milena/mln/fun/i2v/array.hh | 154 +++----
milena/mln/fun/v2v/hsl_to_rgb.hh | 10 +-
milena/mln/fun/v2v/rgb_to_hsl.hh | 4 +-
milena/mln/histo/array.hh | 34 ++-
milena/mln/io/magick/save.hh | 8 +-
milena/mln/io/plot/save.hh | 5 +-
milena/mln/labeling/blobs_and_compute.hh | 5 +-
milena/mln/labeling/value_and_compute.hh | 5 +-
milena/mln/make/w_window2d.hh | 5 +-
milena/mln/util/array.hh | 138 ++++---
milena/mln/util/object_id.hh | 46 +--
milena/mln/value/hsl.hh | 104 +++---
milena/mln/value/int_u.hh | 168 ++++----
milena/mln/value/label.hh | 152 +++----
milena/mln/value/qt/rgb32.hh | 78 +---
milena/mln/value/rgb.hh | 196 ++++------
milena/mln/win/multiple.hh | 5 +-
milena/mln/win/multiple_size.hh | 3 +-
milena/tests/accu/site_set/rectangularity.cc | 4 +-
milena/tests/core/other/graph_elt_neighborhood.cc | 3 +-
milena/tests/core/other/graph_elt_window.cc | 5 +-
milena/tests/core/other/point_set_compatibility.cc | 4 +-
milena/tests/draw/graph.cc | 4 +-
61 files changed, 1623 insertions(+), 2495 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index c5146c0..96019b5 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,70 @@
+2012-05-10 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Rely on Argument-Dependent Lookup (ADL) in from_to_ overloads.
+
+ * mln/accu/count_labels.hh,
+ * mln/convert/from_to.hxx ,
+ * mln/convert/to.hh,
+ * mln/core/alias/point1d.hh,
+ * mln/core/alias/point2d.hh,
+ * mln/core/alias/point3d.hh,
+ * mln/core/dpoint.hh,
+ * mln/core/internal/neighborhood_base.hh,
+ * mln/core/point.hh,
+ * mln/core/site_set/p_centered.hh,
+ * mln/core/site_set/p_vaccess.hh,
+ * mln/fun/v2v/hsl_to_rgb.hh,
+ * mln/fun/v2v/rgb_to_hsl.hh,
+ * mln/io/magick/save.hh,
+ * mln/io/plot/save.hh,
+ * mln/labeling/blobs_and_compute.hh,
+ * mln/labeling/value_and_compute.hh,
+ * mln/make/w_window2d.hh,
+ * mln/win/multiple.hh,
+ * mln/win/multiple_size.hh,
+ * tests/accu/site_set/rectangularity.cc,
+ * tests/core/other/graph_elt_neighborhood.cc,
+ * tests/core/other/graph_elt_window.cc,
+ * tests/core/other/point_set_compatibility.cc,
+ * tests/draw/graph.cc: Update forward declarations and includes.
+
+ * mln/algebra/vec.hh,
+ * mln/convert/from_to.hh,
+ * mln/convert/impl/from_double_to_value.hh,
+ * mln/convert/impl/from_float_to_value.hh,
+ * mln/convert/impl/from_image_to_site_set.hh,
+ * mln/convert/impl/from_int_to_value.hh,
+ * mln/convert/impl/from_unsigned_to_value.hh,
+ * mln/convert/impl/from_value_to_value.hh,
+ * mln/core/alias/neighb2d.hh,
+ * mln/core/alias/neighb3d.hh,
+ * mln/core/alias/window1d.hh,
+ * mln/core/alias/window2d.hh,
+ * mln/core/alias/window3d.hh,
+ * mln/core/concept/accumulator.hh,
+ * mln/core/concept/gdpoint.hh,
+ * mln/core/concept/gpoint.hh,
+ * mln/core/concept/image.hh,
+ * mln/core/concept/proxy.hh,
+ * mln/core/concept/site_set.hh,
+ * mln/core/concept/window.hh,
+ * mln/core/image/graph_window_if_piter.hh,
+ * mln/core/image/image1d.hh,
+ * mln/core/mixed_neighb.hh,
+ * mln/core/neighb.hh,
+ * mln/core/site_set/operators.hh,
+ * mln/core/w_window.hh,
+ * mln/fun/i2v/array.hh,
+ * mln/util/object_id.hh,
+ * mln/value/hsl.hh,
+ * mln/value/int_u.hh,
+ * mln/value/label.hh,
+ * mln/value/qt/rgb32.hh,
+ * mln/value/rgb.hh,
+ * mln/histo/array.hh,
+ * mln/util/array.hh: Move from_to_ overloads in the same namespace
+ as their first argument.
+
2012-05-07 Guillaume Lazzara <z(a)lrde.epita.fr>
* mln/registration/icp.hh: Add a missing initialization.
diff --git a/milena/mln/accu/count_labels.hh b/milena/mln/accu/count_labels.hh
index 07c48b2..c81cc9c 100644
--- a/milena/mln/accu/count_labels.hh
+++ b/milena/mln/accu/count_labels.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2012 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -30,6 +31,7 @@
///
/// Define an accumulator that counts the number of different labels.
+# include <vector>
# include <mln/accu/internal/base.hh>
# include <mln/core/concept/meta_accumulator.hh>
# include <mln/metal/is_a.hh>
diff --git a/milena/mln/algebra/vec.hh b/milena/mln/algebra/vec.hh
index bbe23c8..772c46e 100644
--- a/milena/mln/algebra/vec.hh
+++ b/milena/mln/algebra/vec.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2006, 2008, 2009, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2006, 2008, 2009, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -69,6 +69,14 @@ namespace mln
mln_sum_product(C,C) l2(const algebra::vec<n,C>& vec);
}
+ namespace value {
+ template <unsigned n> struct rgb;
+ }
+
+ template <typename G, typename C> struct point;
+ template <typename E> struct Gpoint;
+ // end of forward declarations
+
namespace trait
{
@@ -261,6 +269,38 @@ namespace mln
vec& operator=(const mat<n, 1, U>& rhs);
};
+
+ /// \internal Conversion: vec -> rgb.
+ template <typename T, unsigned m>
+ void from_to_(const vec<3,T>& from, value::rgb<m>& to_);
+
+ /// \internal Conversion: vec<1,C1> -> point<G,C2>
+ template <typename C1, typename G, typename C2>
+ inline
+ void
+ from_to_(const vec<1,C1>& from, point<G,C2>& to);
+
+ /// \internal Conversion: vec<n,C1> -> point<G,C2>
+ template <unsigned n, typename C1, typename G, typename C2>
+ void
+ from_to_(const vec<n,C1>& from, point<G,C2>& to);
+
+ /// \internal Conversion: vec<1,C1> -> point<G,C1>
+ template <typename C1, typename G>
+ inline
+ void
+ from_to_(const vec<1,C1>& from, point<G,C1>& to);
+
+ /// \internal Conversion: vec<n,C1> -> point<G,C1>
+ template <unsigned n, typename C1, typename G>
+ void
+ from_to_(const vec<n,C1>& from, point<G,C1>& to);
+
+ /// \internal Conversion: vec -> gpoint
+ template <unsigned n, typename T, typename P>
+ void
+ from_to_(const vec<n,T>& from, Gpoint<P>& to);
+
} // end of namespace mln::algebra
@@ -434,6 +474,46 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
+ namespace internal
+ {
+
+ template <typename C, typename C2>
+ inline
+ C
+ convert_data_(metal::bool_<false>, const C2& v)
+ {
+ return static_cast<C>(v);
+ }
+
+ template <typename C, typename C2>
+ inline
+ C
+ convert_data_(metal::bool_<true>, const C2& v)
+ {
+ return static_cast<C>(round(v));
+ }
+
+ template <typename C, typename C2>
+ inline
+ C
+ convert_data(const C2& v)
+ {
+ // If (C != float && C != double) && (C2 == float || C2 == double)
+ // => We want to round the value.
+ // Otherwise we can just statically cast.
+ //
+ return convert_data_<C>(
+ typename mlc_and(
+ mlc_and(mlc_is_not(C,float),
+ mlc_is_not(C,double)),
+ mlc_or(mlc_is(C2,float),
+ mlc_is(C2, double)))::eval(), v);
+ }
+
+ } // end of namespace mln::internal
+
+
+
namespace algebra
{
@@ -733,6 +813,87 @@ namespace mln
}
+ // Conversions
+
+
+ template <typename T, unsigned m>
+ inline
+ void
+ from_to_(const vec<3,T>& from, value::rgb<m>& to)
+ {
+ algebra::vec<3, unsigned> tmp;
+ for (unsigned i = 0; i < 3; ++i)
+ tmp[i] = static_cast<unsigned>(from[i]); // FIXME: Use from_to_ instead of cast.
+
+ to = value::rgb<m>(tmp);
+ }
+
+ template <unsigned n, typename C1, typename G, typename C2>
+ inline
+ void
+ from_to_(const mln::algebra::vec<n,C1>& from, point<G,C2>& to)
+ {
+ mlc_converts_to(C1, C2)::check();
+ enum { dim = G::dim };
+ mlc_bool(G::dim == n)::check();
+
+ unsigned j = 0;
+ for (unsigned i = dim - 2; i < dim; ++i)
+ to[i] = mln::internal::convert_data<C2>(from[j++]);
+ for (unsigned i = 2; i < dim; ++i, ++j)
+ to[i-j] = mln::internal::convert_data<C2>(from[j]);
+ }
+
+ template <typename C1, typename G, typename C2>
+ inline
+ void
+ from_to_(const mln::algebra::vec<1,C1>& from, point<G,C2>& to)
+ {
+ mlc_converts_to(C1, C2)::check();
+ enum { dim = G::dim };
+ mlc_bool(G::dim == 1)::check();
+
+ to[0] = mln::internal::convert_data<C2>(from[0]);
+ }
+
+ template <unsigned n, typename C1, typename G>
+ inline
+ void
+ from_to_(const mln::algebra::vec<n,C1>& from, point<G,C1>& to)
+ {
+ enum { dim = G::dim };
+ mlc_bool(G::dim == n)::check();
+
+ unsigned j = 0;
+ for (unsigned i = dim - 2; i < dim; ++i)
+ to[i] = from[j++];
+ for (unsigned i = 2; i < dim; ++i, ++j)
+ to[i-j] = from[j];
+ }
+
+ template <typename C1, typename G>
+ inline
+ void
+ from_to_(const mln::algebra::vec<1,C1>& from, point<G,C1>& to)
+ {
+ enum { dim = G::dim };
+ mlc_bool(G::dim == 1)::check();
+
+ to[0] = from[0];
+ }
+
+ template <unsigned n, typename T, typename P>
+ inline
+ void
+ from_to_(const vec<n,T>& from, Gpoint<P>& to_)
+ {
+ mlc_bool(P::dim == n)::check();
+ P& to = exact(to_);
+ for (unsigned i = 0; i < n; ++i)
+ to[i] = static_cast< typename P::coord >(from[i]); // FIXME: cast -> best effort...
+ }
+
+
} // end of namespace mln::algebra
diff --git a/milena/mln/convert/from_to.hh b/milena/mln/convert/from_to.hh
index 1b04847..272a47d 100644
--- a/milena/mln/convert/from_to.hh
+++ b/milena/mln/convert/from_to.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2010 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2010, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -38,7 +38,6 @@
/// \todo Find a solution for g++-2.95 and '...'; see FIXME below.
# include <mln/convert/impl/all.hh>
-# include <mln/convert/from_to.hxx>
# include <mln/metal/abort.hh>
# include <mln/metal/converts_to.hh>
@@ -64,8 +63,71 @@ namespace mln
from_to(const F& from, T& to);
+ } // end of namespace mln::convert
+
+} // end of namespace mln
+
+
# ifndef MLN_INCLUDE_ONLY
+// Exact same type.
+template <typename T>
+inline
+void
+from_to_(const T& from, T& to)
+{
+ to = from;
+}
+
+
+// Default conversion.
+template <typename F, typename T>
+inline
+void
+from_to_(const F& from, T& to)
+{
+ to = mln::value::cast<T>(from);
+}
+
+
+namespace mln
+{
+
+ // Exact same type.
+ template <typename T>
+ inline
+ void
+ from_to_(const T& from, T& to)
+ {
+ to = from;
+ }
+
+ // Object -> Object (F not convertible towards T)
+ // No conversion exists!
+ template <typename F, typename T>
+ void
+ from_to_(const Object<F>&, Object<T>&)
+ {
+ // This particular from-to is not defined!
+ //
+ // Either this conversion is meaningless or an overload is
+ // missing.
+ mlc_abort(F)::check();
+ }
+
+
+ // Object -> Object
+ template <typename T>
+ inline
+ void
+ from_to_(const Object<T>& from, Object<T>& to)
+ {
+ exact(to) = exact(from);
+ }
+
+ namespace convert
+ {
+
namespace internal
{
@@ -128,7 +190,7 @@ namespace mln
from_to_dispatch(metal::false_,
const Object<F>& from, Object<T>& to)
{
- over_load::from_to_(exact(from), exact(to));
+ from_to_(exact(from), exact(to));
}
@@ -158,7 +220,7 @@ namespace mln
from_to_dispatch(metal::false_, const F& from,
metal::false_, T& to)
{
- over_load::from_to_(from, to);
+ from_to_(from, to);
}
@@ -169,7 +231,7 @@ namespace mln
from_to_dispatch(metal::true_, const F& from,
metal::false_, T& to)
{
- over_load::from_to_(exact(from), to);
+ from_to_(exact(from), to);
}
@@ -180,7 +242,7 @@ namespace mln
from_to_dispatch(metal::false_, const F& from,
metal::true_, T& to)
{
- over_load::from_to_(from, exact(to));
+ from_to_(from, exact(to));
}
// Object -> Object
@@ -197,58 +259,6 @@ namespace mln
} // end of namespace mln::convert::internal
- namespace over_load
- {
-
-
- // Object -> Object (F not convertible towards T)
- // No conversion exists!
- template <typename F, typename T>
- void
- from_to_(const Object<F>&, Object<T>&)
- {
- // This particular from-to is not defined!
- //
- // Either this conversion is meaningless or an overload is
- // missing.
- mlc_abort(F)::check();
- }
-
-
- // Object -> Object
- template <typename T>
- inline
- void
- from_to_(const Object<T>& from, Object<T>& to)
- {
- exact(to) = exact(from);
- }
-
-
- // Exact same type.
- template <typename T>
- inline
- void
- from_to_(const T& from, T& to)
- {
- to = from;
- }
-
-
- // Default conversion.
- template <typename F, typename T>
- inline
- void
- from_to_(const F& from, T& to)
- {
- to = mln::value::cast<T>(from);
- }
-
-
- } // end of namespace mln::convert::over_load
-
-
-
// Facade
template <typename F, typename T>
@@ -263,11 +273,11 @@ namespace mln
}
-# endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln::convert
} // end of namespace mln
+# endif // ! MLN_INCLUDE_ONLY
+
#endif // ! MLN_CONVERT_FROM_TO_HH
diff --git a/milena/mln/convert/from_to.hxx b/milena/mln/convert/from_to.hxx
index a0e22df..81bc108 100644
--- a/milena/mln/convert/from_to.hxx
+++ b/milena/mln/convert/from_to.hxx
@@ -1,5 +1,5 @@
-// Copyright (C) 2008, 2009, 2010, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2010, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -29,78 +29,9 @@
/// \internal \file mln/convert/from_to.hxx
-// All overloaded "convert::from_to" routines have to be declared in
-// the present file. It allows for *deferred* use of these routines.
-
-# include <mln/core/def/all.hh>
-# include <mln/core/grids.hh>
-# include <mln/util/couple.hh>
-
-//FIXME: have a forward declaration.
-# include <vector>
-# include <set>
-
-
namespace mln
{
-
- // Forward declarations.
-
- template <typename E> struct Accumulator;
- template <typename E> struct Gdpoint;
- template <typename E> struct Gpoint;
- template <typename E> struct Image;
- template <typename E> struct Object;
- template <typename E> struct Proxy;
- template <typename E> struct Site_Set;
- template <typename E> struct Value;
- template <typename E> struct Weighted_Window;
- template <typename E> struct Window;
-
- template <typename G, typename C> struct dpoint;
- template <typename G, typename C> struct point;
-
- template <typename D> class neighb;
- template <typename D> class window;
- template <typename D, typename W> struct w_window;
-
- template <typename T> struct image1d;
-
- namespace algebra {
- template <unsigned n, typename T> class vec;
- template <unsigned d, typename C> class h_vec;
- }
-
- namespace fun {
- namespace i2v {
- template <typename T> class array;
- }
- }
-
- namespace histo {
- template <typename T> struct array;
- }
-
- namespace util {
- template <typename T> class array;
- template <typename Tag, typename V> class object_id;
- }
-
- namespace value {
- namespace qt { struct rgb32; }
- template <unsigned n> struct rgb;
- template <typename H, typename S, typename L> class hsl_;
- template <unsigned n> struct int_u;
- template <unsigned n> struct label;
- }
-
- // end of Forward declarations.
-
-
-
- // convert::to
-
namespace convert
{
@@ -108,378 +39,10 @@ namespace mln
T
to(const O& from);
- } // end of namespace mln::convert
-
-
-
- // convert::from_to
-
- namespace convert
- {
-
- // Facade
-
template <typename F, typename T>
void
from_to(const F& from, T& to);
-
- namespace over_load
- {
-
- // Guard.
- template <typename F, typename T>
- void
- from_to_(const Object<F>&, Object<T>&);
- // end of Guard.
-
- // Object -> Object
- template <typename T>
- void
- from_to_(const Object<T>& from, Object<T>& to);
-
- // Object -> Object
- template <typename T>
- void
- from_to_(const T& from, T& to);
-
- // point -> point.
- template <typename G, typename C1, typename C2>
- inline
- void
- from_to_(const point<G,C1>& from, point<G,C2>& to);
-
- // algebra::vec -> point
- template <unsigned n, typename C1, typename G, typename C2>
- void
- from_to_(const algebra::vec<n,C1>& from, point<G,C2>& to);
-
- // algebra::vec -> point
- template <unsigned n, typename C1, typename G>
- void
- from_to_(const algebra::vec<n,C1>& from, point<G,C1>& to);
-
- // algebra::vec -> Gpoint.
- template <unsigned n, typename T, typename P>
- void
- from_to_(const algebra::vec<n,T>& from, Gpoint<P>& to_);
-
- // algebra::vec -> rgb.
- template <typename T, unsigned m>
- void
- from_to_(const algebra::vec<3,T>& from, value::rgb<m>& to);
-
-
- // bool -> rgb.
- template <unsigned m>
- void
- from_to_(bool from, value::rgb<m>& to);
-
- // rgb32 -> bool
- void
- from_to_(const value::qt::rgb32& from, bool& to);
-
- // bool -> rgb32
- void
- from_to_(const bool& from, value::qt::rgb32& to);
-
- // int_u -> rgb.
- template <unsigned m>
- void from_to_(const value::int_u<m>& from, value::rgb<m>& to);
-
- // int_u -> qt::rgb32.
- template <unsigned m>
- void from_to_(const value::int_u<m>& from, value::qt::rgb32& to);
-
- // int_u -> label
- template <unsigned n>
- void from_to_(const value::int_u<n>& from, value::label<n>& to_);
-
- // int_u -> unsigned
- template <unsigned n>
- void from_to_(const value::int_u<n>& from, unsigned& to_);
-
- // int_u -> bool.
- template <unsigned n>
- void
- from_to_(const value::int_u<n>& from, bool& to_);
-
- // int_u -> float
- template <unsigned n>
- void from_to_(const value::int_u<n>& from, float& to_);
-
- // int_u -> double
- template <unsigned n>
- void from_to_(const value::int_u<n>& from, double& to_);
-
- // label -> int_u.
- template <unsigned n>
- void
- from_to_(const value::label<n>& from, value::int_u<n>& to_);
-
- // label -> bool
- template <unsigned n>
- void from_to_(const value::label<n>& from, bool& to_);
-
- // int_u<n> -> label<m> with n < m
- template <unsigned n, unsigned m>
- void
- from_to_(const value::int_u<n>& from, value::label<m>& to_);
-
- // hsl -> rgb8.
- template <typename H, typename S, typename L>
- void from_to_(const value::hsl_<H,S,L>&, value::rgb<8>& to);
-
- // hsl -> rgb16.
- template <typename H, typename S, typename L>
- void from_to_(const value::hsl_<H,S,L>&, value::rgb<16>& to);
-
- // hsl -> qt::rgb32.
- template <typename H, typename S, typename L>
- void from_to_(const value::hsl_<H,S,L>&, value::qt::rgb32& to);
-
- // rgb to hsl
- void
- from_to_(const value::rgb<16>& from, value::hsl_<float,float,float>& to);
-
- // rgb to hsl
- void
- from_to_(const value::rgb<8>& from, value::hsl_<float,float,float>& to);
-
- // rgb -> bool.
- template <unsigned m>
- void from_to_(const value::rgb<m>& from, bool& to);
-
-
- // C-array -> Image.
- template <typename V, unsigned S, typename I>
- void
- from_to_(const V (&values)[S], Image<I>& to);
-
- // C-array -> w_window
- template <typename V, unsigned S, typename D, typename W>
- void
- from_to_(const V (&weight)[S], w_window<D,W>& to);
-
-
- // C-array -> window2d
- template <unsigned S>
- void
- from_to_(const bool (&values)[S],
- window< dpoint<grid::square, def::coord> >& win);
-
- template <unsigned R, unsigned C>
- void
- from_to_(const bool (&values)[R][C],
- window< dpoint<grid::square, def::coord> >& win);
-
-
- // C-array -> window3d
- template <unsigned S>
- void
- from_to_(const bool (&values)[S],
- window< dpoint<grid::cube, def::coord> >& win);
-
-
- // C-array -> neighb2d
- template <unsigned S>
- void
- from_to_(const bool (&values)[S],
- neighb< window< dpoint<grid::square, def::coord> > >& nbh);
-
- template <unsigned R, unsigned C>
- void
- from_to_(bool const (&values)[R][C],
- neighb< window< dpoint<grid::square, def::coord> > >& nbh);
-
-
- // C-array -> neighb3d
- template <unsigned S>
- void
- from_to_(const bool (&values)[S],
- neighb< window< dpoint<grid::cube, def::coord> > >& nbh);
-
-
-
- // Gdpoint -> point
- template <typename D>
- void
- from_to_(const Gdpoint<D>& from, mln_site(D)& to);
-
-
- // Value -> Value
- template <typename F, typename T>
- void
- from_to_(const Value<F>& from, Value<T>& to);
-
- // double-> Value
- template <typename V>
- void
- from_to_(const double& from, Value<V>& to);
-
- // double-> unsigned
- void
- from_to_(const double& from, unsigned& to);
-
- // double-> int
- void
- from_to_(const double& from, int& to);
-
- // float -> Value
- template <typename V>
- void
- from_to_(const float& from, Value<V>& to);
-
- // float -> unsigned
- void
- from_to_(const float& from, unsigned& to);
-
- // float -> int
- void
- from_to_(const float& from, int& to);
-
- // int -> Value
- template <typename T>
- void
- from_to_(const int& from, Value<T>& to);
-
- // Proxy -> T
- template <typename P, typename T>
- void
- from_to_(const Proxy<P>& from, T& to);
-
-
- // Gpoint -> algebra::vec.
- template <typename P, unsigned n, typename T>
- void
- from_to_(const Gpoint<P>& from, algebra::vec<n,T>& to);
-
- // Gpoint -> delta-point
- template <typename P>
- void
- from_to_(const Gpoint<P>& from, mln_delta(P)& to);
-
-
- // Image -> Site_Set.
- template <typename I, typename S>
- void
- from_to_(const Image<I>& from, Site_Set<S>& to);
-
- // Image -> w_window
- template <typename I, typename D, typename W>
- void
- from_to_(const Image<I>& from, w_window<D,W>& to);
-
-
- // neighb<W> -> W
- template <typename W>
- void
- from_to_(const mln::neighb<W>& from, W& to);
-
- // W -> neighb<W>
- template <typename W>
- void
- from_to_(const W& from, mln::neighb<W>& to);
-
-
- // Window -> Image
- template <typename W, typename I>
- void
- from_to_(const Window<W>& from, Image<I>& to);
-
-
- // w_window -> Image
- template <typename D, typename W, typename I>
- void
- from_to_(const w_window<D,W>& from, Image<I>& to);
-
-
-
- // util::array<T> -> fun::i2v::array<T>
- template <typename T>
- void
- from_to_(const util::array<T>& from, fun::i2v::array<T>& to);
-
- // util::array<T> -> fun::i2v::array<U>
- template <typename T, typename U>
- void
- from_to_(const util::array<T>& from, fun::i2v::array<U>& to);
-
- // std::vector<T> -> fun::i2v::array<T>
- template <typename T>
- void
- from_to_(const std::vector<T>& from, fun::i2v::array<T>& to);
-
- // std::vector<T> -> fun::i2v::array<U>
- template <typename T, typename U>
- void
- from_to_(const std::vector<T>& from, fun::i2v::array<U>& to);
-
- // util::array<T1> -> util::array<T2>
- template <typename T1, typename T2>
- void
- from_to_(const util::array<T1>& from, util::array<T2>& to);
-
-
-
- // util::array<T1> -> util::array<T2>
- template <typename T1, typename T2>
- void
- from_to_(const util::array<T1>& from, util::array<T2>& to);
-
- // fun::i2v::array<T1> -> util::array<T2>
- template <typename T1, typename T2>
- void
- from_to_(const fun::i2v::array<T1>& from, util::array<T2>& to);
-
-
- // Accumulator<A> -> mln_result(A)
- template <typename A>
- void
- from_to_(const Accumulator<A>& from, mln_result(A)& to);
-
-
-
- // Site_Set -> Image.
- template <typename S, typename I>
- void
- from_to_(const Site_Set<S>& from, Image<I>& to);
-
- // Site_Set -> std::set
- template <typename S, typename P, typename C_>
- void
- from_to_(const Site_Set<S>& from, std::set<P,C_>& to);
-
- // std::set -> Site_Set
- template <typename P, typename C_, typename S>
- void
- from_to_(const std::set<P,C_>& from, Site_Set<S>& to);
-
- // histo::array -> image1d
- template <typename V, typename T>
- void
- from_to_(const histo::array<V>& from, image1d<T>& to);
-
- // util::array -> image1d
- template <typename V, typename T>
- void
- from_to_(const util::array<V>& from, image1d<T>& to);
-
- // util::couple<T, U> -> util::couple<V, W>
- template <typename T, typename U, typename V, typename W>
- void
- from_to_(const util::couple<T, U>& from, util::couple<V, W>& to)
- {
- from_to(from.first(), to.first());
- from_to(from.second(), to.second());
- }
-
- // util::object_id<Tag,V> -> V.
- template <typename Tag, typename V>
- void from_to_(const util::object_id<Tag,V>& from, V& to_);
-
- } // end of namespace mln::convert::over_load
-
} // end of namespace mln::convert
} // end of namespace mln
diff --git a/milena/mln/convert/impl/from_double_to_value.hh b/milena/mln/convert/impl/from_double_to_value.hh
index fd2b32a..eaae734 100644
--- a/milena/mln/convert/impl/from_double_to_value.hh
+++ b/milena/mln/convert/impl/from_double_to_value.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2009, 2010, 2011 EPITA Research and Development
+// Copyright (C) 2009, 2010, 2011, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -45,113 +45,106 @@
namespace mln
{
+ /// \internal Conversion: double-> Value
+ template <typename V>
+ void from_to_(const double& from, Value<V>& to);
+
+ /// \internal Conversion: double-> unsigned
+ void from_to_(const double& from, unsigned& to);
+
+ /// \internal Conversion: double-> int
+ void from_to_(const double& from, int& to);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
namespace convert
{
- /// Conversion of a double \p from towards a value \p to.
+ namespace impl
+ {
+
+ // Case 1:
+
template <typename V>
+ inline
void
- from_to(const double& from, Value<V>& to);
-
+ from_double_to_value(const double& from,
+ mln::value::Integer<V>& to)
+ {
+ exact(to) = math::round<V>()(from);
+ }
-# ifndef MLN_INCLUDE_ONLY
+ // Case 2:
- namespace impl
+ template <typename V>
+ inline
+ void
+ from_double_to_value(const double& from,
+ mln::value::Floating<V>& to)
{
+ exact(to) = from;
+ }
- // Case 1:
-
- template <typename V>
- inline
- void
- from_double_to_value(const double& from,
- mln::value::Integer<V>& to)
- {
- exact(to) = math::round<V>()(from);
- }
- // Case 2:
+ // Default: no conversion defined.
- template <typename V>
- inline
- void
- from_double_to_value(const double& from,
- mln::value::Floating<V>& to)
- {
- exact(to) = from;
- }
+ template <typename V>
+ inline
+ void
+ from_double_to_value(const double& from,
+ Value<V>& to)
+ {
+ (void) from;
+ (void) to;
+ mlc_abort(V)::check();
+ }
+ } // end of namespace mln::convert::impl
- // Default: no conversion defined.
- template <typename V>
- inline
- void
- from_double_to_value(const double& from,
- Value<V>& to)
- {
- (void) from;
- (void) to;
- mlc_abort(V)::check();
- }
+ namespace internal
+ {
- } // end of namespace mln::convert::impl
+ template <typename V>
+ inline
+ void
+ from_double_to_value_dispatch(const double& from, Value<V>& to)
+ {
+ impl::from_double_to_value(from, exact(to));
+ }
+ } // end of namespace mln::convert::internal
- namespace internal
- {
+ } // end of namespace mln::convert
- template <typename V>
- inline
- void
- from_double_to_value_dispatch(const double& from, Value<V>& to)
- {
- impl::from_double_to_value(from, exact(to));
- }
- } // end of namespace mln::convert::internal
+ template <typename V>
+ inline
+ void
+ from_to_(const double& from, Value<V>& to)
+ {
+ convert::internal::from_double_to_value_dispatch(from, to);
+ }
+ inline
+ void
+ from_to_(const double& from, unsigned& to)
+ {
+ mln_precondition(from >= 0);
+ to = math::round<unsigned>()(from);
+ }
- namespace over_load
- {
+ inline
+ void
+ from_to_(const double& from, int& to)
+ {
+ to = math::round<int>()(from);
+ }
- // Facades.
-
-
- // double-> Value
- template <typename V>
- inline
- void
- from_to_(const double& from, Value<V>& to)
- {
- internal::from_double_to_value_dispatch(from, to);
- }
-
- // double-> unsigned
- inline
- void
- from_to_(const double& from,
- unsigned& to)
- {
- mln_precondition(from >= 0);
- to = math::round<unsigned>()(from);
- }
-
- // double-> int
- inline
- void
- from_to_(const double& from,
- int& to)
- {
- to = math::round<int>()(from);
- }
-
- } // end of namespace mln::convert::over_load
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::convert
-
} // end of namespace mln
diff --git a/milena/mln/convert/impl/from_float_to_value.hh b/milena/mln/convert/impl/from_float_to_value.hh
index aa880d8..0a275ed 100644
--- a/milena/mln/convert/impl/from_float_to_value.hh
+++ b/milena/mln/convert/impl/from_float_to_value.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2008, 2009, 2010, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2010, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -45,123 +45,116 @@
namespace mln
{
+ /// \internal Conversion: float-> Value
+ template <typename V>
+ void from_to_(const float& from, Value<V>& to);
+
+ /// \internal Conversion: float-> unsigned
+ void from_to_(const float& from, unsigned& to);
+
+ /// \internal Conversion: float-> int
+ void from_to_(const float& from, int& to);
+
+ /// \internal Conversion: float-> short
+ void from_to_(const float& from, short& to);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
namespace convert
{
- /// Conversion of a float \p from towards a value \p to.
+ namespace impl
+ {
+
+ // Case 1:
+
template <typename V>
+ inline
void
- from_to(const float& from, Value<V>& to);
-
+ from_float_to_value(const float& from,
+ mln::value::Integer<V>& to)
+ {
+ exact(to) = math::round<V>()(from);
+ }
-# ifndef MLN_INCLUDE_ONLY
+ // Case 2:
- namespace impl
+ template <typename V>
+ inline
+ void
+ from_float_to_value(const float& from,
+ mln::value::Floating<V>& to)
{
+ exact(to) = from;
+ }
- // Case 1:
- template <typename V>
- inline
- void
- from_float_to_value(const float& from,
- mln::value::Integer<V>& to)
- {
- exact(to) = math::round<V>()(from);
- }
+ // Default: no conversion defined.
- // Case 2:
+ template <typename V>
+ inline
+ void
+ from_float_to_value(const float& from,
+ Value<V>& to)
+ {
+ (void) from;
+ (void) to;
+ mlc_abort(V)::check();
+ }
- template <typename V>
- inline
- void
- from_float_to_value(const float& from,
- mln::value::Floating<V>& to)
- {
- exact(to) = from;
- }
+ } // end of namespace mln::convert::impl
- // Default: no conversion defined.
+ namespace internal
+ {
- template <typename V>
- inline
- void
- from_float_to_value(const float& from,
- Value<V>& to)
- {
- (void) from;
- (void) to;
- mlc_abort(V)::check();
- }
+ template <typename V>
+ inline
+ void
+ from_float_to_value_dispatch(const float& from, Value<V>& to)
+ {
+ impl::from_float_to_value(from, exact(to));
+ }
- } // end of namespace mln::convert::impl
+ } // end of namespace mln::convert::internal
+ } // end of namespace mln::convert
- namespace internal
- {
- template <typename V>
- inline
- void
- from_float_to_value_dispatch(const float& from, Value<V>& to)
- {
- impl::from_float_to_value(from, exact(to));
- }
+ template <typename V>
+ inline
+ void
+ from_to_(const float& from, Value<V>& to)
+ {
+ convert::internal::from_float_to_value_dispatch(from, to);
+ }
- } // end of namespace mln::convert::internal
+ inline
+ void
+ from_to_(const float& from, unsigned& to)
+ {
+ mln_precondition(from >= 0);
+ to = math::round<unsigned>()(from);
+ }
+ inline
+ void
+ from_to_(const float& from, int& to)
+ {
+ to = math::round<int>()(from);
+ }
- namespace over_load
- {
+ inline
+ void
+ from_to_(const float& from, short& to)
+ {
+ to = math::round<short>()(from);
+ }
- // Facades.
-
-
- // float-> Value
- template <typename V>
- inline
- void
- from_to_(const float& from, Value<V>& to)
- {
- internal::from_float_to_value_dispatch(from, to);
- }
-
- // float-> unsigned
- inline
- void
- from_to_(const float& from,
- unsigned& to)
- {
- mln_precondition(from >= 0);
- to = math::round<unsigned>()(from);
- }
-
- // float-> int
- inline
- void
- from_to_(const float& from,
- int& to)
- {
- to = math::round<int>()(from);
- }
-
- // float-> short
- inline
- void
- from_to_(const float& from,
- short& to)
- {
- to = math::round<short>()(from);
- }
-
-
- } // end of namespace mln::convert::over_load
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::convert
-
} // end of namespace mln
diff --git a/milena/mln/convert/impl/from_image_to_site_set.hh b/milena/mln/convert/impl/from_image_to_site_set.hh
index 65873b6..e78538b 100644
--- a/milena/mln/convert/impl/from_image_to_site_set.hh
+++ b/milena/mln/convert/impl/from_image_to_site_set.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2011, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -94,8 +94,8 @@ namespace mln
p.next();
}
while (p.is_valid() && input(p) == true &&
- // p follows q in a run, i.e., "p == q + right":
- cut_(p.to_site()) == cut_(q) && p.last_coord() == q.last_coord() + 1);
+ // p follows q in a run, i.e., "p == q + right":
+ cut_(p.to_site()) == cut_(q) && p.last_coord() == q.last_coord() + 1);
s.insert(p_run<P>(start, q));
}
}
@@ -123,7 +123,7 @@ namespace mln
p.next();
}
while (p.is_valid() && input(p) == v &&
- cut_(p.to_site()) == cut_(q) && p.last_coord() == q.last_coord() + 1);
+ cut_(p.to_site()) == cut_(q) && p.last_coord() == q.last_coord() + 1);
s.insert(v, p_run<P>(start, q));
}
}
diff --git a/milena/mln/convert/impl/from_int_to_value.hh b/milena/mln/convert/impl/from_int_to_value.hh
index c22dfb1..4074ed0 100644
--- a/milena/mln/convert/impl/from_int_to_value.hh
+++ b/milena/mln/convert/impl/from_int_to_value.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2010 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2010, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -44,79 +44,72 @@
namespace mln
{
- namespace convert
- {
-
- /// Conversion of a int \p from towards a value \p to.
- template <typename V>
- void
- from_to(const int& from, Value<V>& to);
+ /// \internal Conversion: int-> Value
+ template <typename V>
+ void from_to_(const int& from, Value<V>& to);
# ifndef MLN_INCLUDE_ONLY
- namespace impl
- {
+ namespace convert
+ {
- // Case 1:
+ namespace impl
+ {
- template <typename V>
- inline
- void
- from_int_to_value(const int& from,
- mln::value::Integer<V>& to)
- {
- exact(to) = from;
- }
+ // Case 1:
- // Default: no conversion defined.
+ template <typename V>
+ inline
+ void
+ from_int_to_value(const int& from,
+ mln::value::Integer<V>& to)
+ {
+ exact(to) = from;
+ }
- template <typename V>
- inline
- void
- from_int_to_value(const int& from,
- Value<V>& to)
- {
- (void) from;
- (void) to;
- mlc_abort(V)::check();
- }
+ // Default: no conversion defined.
- } // end of namespace mln::convert::impl
+ template <typename V>
+ inline
+ void
+ from_int_to_value(const int& from,
+ Value<V>& to)
+ {
+ (void) from;
+ (void) to;
+ mlc_abort(V)::check();
+ }
+ } // end of namespace mln::convert::impl
- namespace internal
- {
+ namespace internal
+ {
- template <typename V>
- inline
- void
- from_int_to_value_dispatch(const int& from, Value<V>& to)
- {
- impl::from_int_to_value(from, exact(to));
- }
+ template <typename V>
+ inline
+ void
+ from_int_to_value_dispatch(const int& from, Value<V>& to)
+ {
+ impl::from_int_to_value(from, exact(to));
+ }
- } // end of namespace mln::convert::internal
+ } // end of namespace mln::convert::internal
+ } // end of namespace mln::convert
- namespace over_load
- {
- // Facades.
- // int-> Value
- template <typename V>
- void
- from_to_(const int& from, Value<V>& to)
- {
- internal::from_int_to_value_dispatch(from, to);
- }
+ // Facades.
- } // end of namespace mln::convert::over_load
+ template <typename V>
+ void
+ from_to_(const int& from, Value<V>& to)
+ {
+ convert::internal::from_int_to_value_dispatch(from, to);
+ }
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::convert
-
} // end of namespace mln
diff --git a/milena/mln/convert/impl/from_unsigned_to_value.hh b/milena/mln/convert/impl/from_unsigned_to_value.hh
index 783b5e9..383f989 100644
--- a/milena/mln/convert/impl/from_unsigned_to_value.hh
+++ b/milena/mln/convert/impl/from_unsigned_to_value.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2009, 2010, 2011 EPITA Research and Development
+// Copyright (C) 2009, 2010, 2011, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -45,102 +45,92 @@
namespace mln
{
- namespace convert
- {
- /// Conversion of an unsigned \p from towards a value \p to.
- template <typename V>
- void
- from_to(const unsigned& from, Value<V>& to);
+ /// \internal Conversion: unsigned-> Value
+ template <typename V>
+ void from_to_(const unsigned& from, Value<V>& to);
+
+ /// \internal Conversion: unsigned -> bool
+ void from_to_(const unsigned& from, bool& to);
+
- /// Conversion of an unsigned \p from towards a bool \p to.
- inline
- void
- from_to_(const unsigned& from, bool& to);
# ifndef MLN_INCLUDE_ONLY
- namespace impl
+ namespace convert
+ {
+
+ namespace impl
+ {
+
+ // Case 1:
+
+ template <typename V>
+ inline
+ void
+ from_unsigned_to_value(const unsigned& from,
+ mln::value::Integer<V>& to)
{
+ exact(to) = from;
+ }
+
+ template <unsigned n>
+ inline
+ void
+ from_unsigned_to_value(const unsigned& from,
+ mln::value::label<n>& to)
+ {
+ exact(to) = from;
+ }
+
+ // Default: no conversion defined.
- // Case 1:
-
- template <typename V>
- inline
- void
- from_unsigned_to_value(const unsigned& from,
- mln::value::Integer<V>& to)
- {
- exact(to) = from;
- }
-
- template <unsigned n>
- inline
- void
- from_unsigned_to_value(const unsigned& from,
- mln::value::label<n>& to)
- {
- exact(to) = from;
- }
-
- // Default: no conversion defined.
-
- template <typename V>
- inline
- void
- from_unsigned_to_value(const unsigned&,
- Value<V>&)
- {
- mlc_abort(V)::check();
- }
-
- } // end of namespace mln::convert::impl
-
-
- namespace internal
+ template <typename V>
+ inline
+ void
+ from_unsigned_to_value(const unsigned&,
+ Value<V>&)
{
+ mlc_abort(V)::check();
+ }
- template <typename V>
- inline
- void
- from_unsigned_to_value_dispatch(const unsigned& from, Value<V>& to)
- {
- impl::from_unsigned_to_value(from, exact(to));
- }
+ } // end of namespace mln::convert::impl
- } // end of namespace mln::convert::unsignedernal
+ namespace internal
+ {
- namespace over_load
+ template <typename V>
+ inline
+ void
+ from_unsigned_to_value_dispatch(const unsigned& from, Value<V>& to)
{
+ impl::from_unsigned_to_value(from, exact(to));
+ }
- // Facades.
- // unsigned-> Value
- template <typename V>
- void
- from_to_(const unsigned& from, Value<V>& to)
- {
- internal::from_unsigned_to_value_dispatch(from, to);
- }
+ } // end of namespace mln::convert::unsignedernal
+
+ } // end of namespace mln::convert
- // Facades.
- // unsigned-> bool
- inline
- void
- from_to_(const unsigned& from, bool& to)
- {
- to = (from != 0u);
- }
+ template <typename V>
+ void
+ from_to_(const unsigned& from, Value<V>& to)
+ {
+ convert::internal::from_unsigned_to_value_dispatch(from, to);
+ }
- } // end of namespace mln::convert::over_load
+ inline
+ void
+ from_to_(const unsigned& from, bool& to)
+ {
+ to = (from != 0u);
+ }
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::convert
-
} // end of namespace mln
diff --git a/milena/mln/convert/impl/from_value_to_value.hh b/milena/mln/convert/impl/from_value_to_value.hh
index 347338b..fea91a3 100644
--- a/milena/mln/convert/impl/from_value_to_value.hh
+++ b/milena/mln/convert/impl/from_value_to_value.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -41,8 +42,6 @@
# include <mln/core/site_set/p_run.hh>
# include <mln/metal/converts_to.hh>
-# include <mln/convert/from_to.hxx>
-
namespace mln
{
@@ -93,7 +92,7 @@ namespace mln
{
// No concept based conversion. Trying to find more specific
// conversion with other from_to overloads.
- convert::over_load::from_to_(exact(from), exact(to));
+ from_to_(exact(from), exact(to));
}
diff --git a/milena/mln/convert/to.hh b/milena/mln/convert/to.hh
index f88f621..5c46416 100644
--- a/milena/mln/convert/to.hh
+++ b/milena/mln/convert/to.hh
@@ -36,7 +36,6 @@
# include <mln/metal/equal.hh>
# include <mln/trace/all.hh>
# include <mln/convert/from_to.hh>
-# include <mln/convert/from_to.hxx>
namespace mln
diff --git a/milena/mln/core/alias/neighb2d.hh b/milena/mln/core/alias/neighb2d.hh
index ee86509..63fbc55 100644
--- a/milena/mln/core/alias/neighb2d.hh
+++ b/milena/mln/core/alias/neighb2d.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -123,22 +124,13 @@ namespace mln
neighb< win::multiple<window2d, mln::fun::p2b::chess> > c6_2d();
+ /// \internal Conversion: bool[] -> neighb2d
+ template <unsigned S>
+ void from_to_(const bool (&values)[S], neighb2d& nbh);
- namespace convert
- {
-
- namespace over_load
- {
-
- template <unsigned S>
- void from_to_(const bool (&values)[S], neighb2d& nbh);
-
- template <unsigned R, unsigned C>
- void from_to_(bool const (&values)[R][C], neighb2d& nbh);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ /// \internal Conversion: bool[][] -> neighb2d
+ template <unsigned R, unsigned C>
+ void from_to_(bool const (&values)[R][C], neighb2d& nbh);
@@ -208,48 +200,39 @@ namespace mln
bool vert[] = { 1, 1, 0,
1, 0, 1,
0, 1, 1 };
-
+
bool hori[] = { 0, 1, 1,
1, 0, 1,
1, 1, 0 };
-
+
return make::double_neighb2d(fun::p2b::chess(),
vert,
hori);
}
- namespace convert
+ template <unsigned S>
+ void
+ from_to_(const bool (&values)[S], neighb2d& nbh)
{
+ enum { h = mlc_sqrt_int(S) / 2 };
+ mlc_bool((2 * h + 1) * (2 * h + 1) == S)::check();
+ window2d& win = nbh.hook_win_();
+ convert::from_to(values, win);
+ mln_postcondition(win.is_neighbable_());
+ }
- namespace over_load
- {
-
- template <unsigned S>
- void
- from_to_(const bool (&values)[S], neighb2d& nbh)
- {
- enum { h = mlc_sqrt_int(S) / 2 };
- mlc_bool((2 * h + 1) * (2 * h + 1) == S)::check();
- window2d& win = nbh.hook_win_();
- convert::from_to(values, win);
- mln_postcondition(win.is_neighbable_());
- }
-
- template <unsigned R, unsigned C>
- void
- from_to_(bool const (&values)[R][C], neighb2d& nbh)
- {
- mlc_bool(R % 2 == 1)::check();
- mlc_bool(C % 2 == 1)::check();
- window2d& win = nbh.hook_win_();
- convert::from_to(values, win);
- mln_postcondition(win.is_neighbable_());
- }
-
- } // end of namespace mln::convert::over_load
+ template <unsigned R, unsigned C>
+ void
+ from_to_(bool const (&values)[R][C], neighb2d& nbh)
+ {
+ mlc_bool(R % 2 == 1)::check();
+ mlc_bool(C % 2 == 1)::check();
+ window2d& win = nbh.hook_win_();
+ convert::from_to(values, win);
+ mln_postcondition(win.is_neighbable_());
+ }
- } // end of namespace mln::convert
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/alias/neighb3d.hh b/milena/mln/core/alias/neighb3d.hh
index a5dead7..cb2d809 100644
--- a/milena/mln/core/alias/neighb3d.hh
+++ b/milena/mln/core/alias/neighb3d.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -203,21 +204,9 @@ namespace mln
const neighb3d& c26();
-
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <unsigned S>
- void from_to_(const bool (&values)[S], neighb3d& nbh);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
+ /// \internal Conversion: bool[] -> neighb3d
+ template <unsigned S>
+ void from_to_(const bool (&values)[S], neighb3d& nbh);
# ifndef MLN_INCLUDE_ONLY
@@ -325,29 +314,19 @@ namespace mln
}
- namespace convert
+ template <unsigned S>
+ void
+ from_to_(const bool (&values)[S], neighb3d& nbh)
{
-
- namespace over_load
- {
-
- template <unsigned S>
- void
- from_to_(const bool (&values)[S], neighb3d& nbh)
- {
# ifndef NDEBUG
- const int h = unsigned(std::pow(float(S), float(1. / 3.))) / 2;
- mln_precondition((2 * h + 1) * (2 * h + 1) * (2 * h + 1) == S);
+ const int h = unsigned(std::pow(float(S), float(1. / 3.))) / 2;
+ mln_precondition((2 * h + 1) * (2 * h + 1) * (2 * h + 1) == S);
# endif // ! NDEBUG
- window3d win;
- from_to_(values, win);
- mln_precondition(win.is_neighbable_());
- nbh.change_window(win);
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ window3d win;
+ from_to_(values, win);
+ mln_precondition(win.is_neighbable_());
+ nbh.change_window(win);
+ }
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/alias/point1d.hh b/milena/mln/core/alias/point1d.hh
index 5cd9803..f3cde66 100644
--- a/milena/mln/core/alias/point1d.hh
+++ b/milena/mln/core/alias/point1d.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -31,6 +32,8 @@
/// Definition of the mln::point1d and mln::point1df aliases and of
/// their construction routines.
+# include <mln/core/def/coord.hh>
+# include <mln/core/def/coordf.hh>
# include <mln/core/point.hh>
// For site_const_impl and site_mutable_impl.
# include <mln/core/concept/site_proxy.hh>
diff --git a/milena/mln/core/alias/point2d.hh b/milena/mln/core/alias/point2d.hh
index dd79faa..5a7ae65 100644
--- a/milena/mln/core/alias/point2d.hh
+++ b/milena/mln/core/alias/point2d.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -31,6 +32,8 @@
/// Definition of the mln::point2d and mln::point2df aliases and of
/// their construction routines.
+# include <mln/core/def/coord.hh>
+# include <mln/core/def/coordf.hh>
# include <mln/core/point.hh>
// For site_const_impl and site_mutable_impl.
# include <mln/core/concept/site_proxy.hh>
diff --git a/milena/mln/core/alias/point3d.hh b/milena/mln/core/alias/point3d.hh
index 6aaede0..bfc6bee 100644
--- a/milena/mln/core/alias/point3d.hh
+++ b/milena/mln/core/alias/point3d.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -31,6 +32,8 @@
/// Definition of the mln::point3d and mln::point3df aliases and of
/// their construction routines.
+# include <mln/core/def/coord.hh>
+# include <mln/core/def/coordf.hh>
# include <mln/core/point.hh>
// For site_const_impl and site_mutable_impl:
# include <mln/core/concept/site_proxy.hh>
diff --git a/milena/mln/core/alias/window1d.hh b/milena/mln/core/alias/window1d.hh
index 6564e43..dd2d4fc 100644
--- a/milena/mln/core/alias/window1d.hh
+++ b/milena/mln/core/alias/window1d.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -47,45 +48,25 @@ namespace mln
typedef window<mln::dpoint1d> window1d;
- namespace convert
- {
-
- namespace over_load
- {
-
- template <unsigned M>
- void from_to_(const bool (&values)[M], window1d& win);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
+ /// \internal Conversion: bool[] -> window1d
+ template <unsigned M>
+ void from_to_(const bool (&values)[M], window1d& win);
# ifndef MLN_INCLUDE_ONLY
- namespace convert
+ template <unsigned M>
+ void
+ from_to_(bool const (&values)[M], window1d& win)
{
-
- namespace over_load
- {
-
- template <unsigned M>
- void
- from_to_(bool const (&values)[M], window1d& win)
- {
- mlc_bool(M % 2 == 1)::check();
- win.clear();
- const int h = int(M) / 2;
- unsigned i = 0;
- for (int ind = - h; ind <= h; ++ind)
- if (values[i++])
- win.insert(ind);
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ mlc_bool(M % 2 == 1)::check();
+ win.clear();
+ const int h = int(M) / 2;
+ unsigned i = 0;
+ for (int ind = - h; ind <= h; ++ind)
+ if (values[i++])
+ win.insert(ind);
+ }
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/alias/window2d.hh b/milena/mln/core/alias/window2d.hh
index 5b8fe31..aa56837 100644
--- a/milena/mln/core/alias/window2d.hh
+++ b/milena/mln/core/alias/window2d.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2010, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -35,7 +35,6 @@
# include <mln/core/window.hh>
# include <mln/core/alias/dpoint2d.hh>
# include <mln/metal/math/sqrt.hh>
-# include <mln/convert/from_to.hxx>
namespace mln
@@ -81,22 +80,13 @@ namespace mln
const window2d& win_c8p();
- namespace convert
- {
-
- namespace over_load
- {
-
- template <unsigned S>
- void from_to_(const bool (&values)[S], window2d& win);
-
- template <unsigned R, unsigned C>
- void from_to_(const bool (&values)[R][C], window2d& win);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ /// \internal Conversion: bool[] -> window2d
+ template <unsigned S>
+ void from_to_(const bool (&values)[S], window2d& win);
+ /// \internal Conversion: bool[][] -> window2d
+ template <unsigned R, unsigned C>
+ void from_to_(const bool (&values)[R][C], window2d& win);
# ifndef MLN_INCLUDE_ONLY
@@ -138,50 +128,40 @@ namespace mln
}
- namespace convert
+ template <unsigned S>
+ void
+ from_to_(const bool (&values)[S], window2d& win)
{
+ enum { H = mlc_sqrt_int(S) / 2 };
+ mlc_bool((2 * H + 1) * (2 * H + 1) == S)::check();
+ win.clear();
+ unsigned i = 0;
+ const def::coord
+ h = static_cast<def::coord>(H),
+ _h = static_cast<def::coord>(-h);
+ for (def::coord row = _h; row <= h; ++row)
+ for (def::coord col = _h; col <= h; ++col)
+ if (values[i++])
+ win.insert(row, col);
+ }
- namespace over_load
- {
-
- template <unsigned S>
- void
- from_to_(const bool (&values)[S], window2d& win)
- {
- enum { H = mlc_sqrt_int(S) / 2 };
- mlc_bool((2 * H + 1) * (2 * H + 1) == S)::check();
- win.clear();
- unsigned i = 0;
- const def::coord
- h = static_cast<def::coord>(H),
- _h = static_cast<def::coord>(-h);
- for (def::coord row = _h; row <= h; ++row)
- for (def::coord col = _h; col <= h; ++col)
- if (values[i++])
- win.insert(row, col);
- }
-
- template <unsigned R, unsigned C>
- void
- from_to_(const bool (&values)[R][C], window2d& win)
- {
- mlc_bool(R % 2 == 1)::check();
- mlc_bool(C % 2 == 1)::check();
- win.clear();
- const def::coord
- drow = static_cast<def::coord>(R / 2),
- _drow = static_cast<def::coord>(- drow),
- dcol = static_cast<def::coord>(C / 2),
- _dcol = static_cast<def::coord>(- dcol);
- for (def::coord row = _drow; row <= drow; ++row)
- for (def::coord col = _dcol; col <= dcol; ++col)
- if (values[row + drow][col + dcol])
- win.insert(row, col);
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ template <unsigned R, unsigned C>
+ void
+ from_to_(const bool (&values)[R][C], window2d& win)
+ {
+ mlc_bool(R % 2 == 1)::check();
+ mlc_bool(C % 2 == 1)::check();
+ win.clear();
+ const def::coord
+ drow = static_cast<def::coord>(R / 2),
+ _drow = static_cast<def::coord>(- drow),
+ dcol = static_cast<def::coord>(C / 2),
+ _dcol = static_cast<def::coord>(- dcol);
+ for (def::coord row = _drow; row <= drow; ++row)
+ for (def::coord col = _dcol; col <= dcol; ++col)
+ if (values[row + drow][col + dcol])
+ win.insert(row, col);
+ }
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/alias/window3d.hh b/milena/mln/core/alias/window3d.hh
index 108ea4e..6a29c06 100644
--- a/milena/mln/core/alias/window3d.hh
+++ b/milena/mln/core/alias/window3d.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -97,19 +98,9 @@ namespace mln
const window3d& win_c8p_3d();
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <unsigned M>
- void from_to_(bool const (&values)[M], window3d& win);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ /// \internal Conversion: bool[] -> window3d
+ template <unsigned M>
+ void from_to_(bool const (&values)[M], window3d& win);
@@ -151,30 +142,23 @@ namespace mln
return it;
}
- namespace convert
- {
- namespace over_load
- {
+ // Conversion
- template <unsigned M>
- void
- from_to_(bool const (&values)[M], window3d& win)
- {
- const int h = unsigned(std::pow(float(M), float(1. / 3.))) / 2;
- mln_precondition((2 * h + 1) * (2 * h + 1) * (2 * h + 1) == M);
- win.clear();
- unsigned i = 0;
- for (int sli = - h; sli <= h; ++sli)
- for (int row = - h; row <= h; ++row)
- for (int col = - h; col <= h; ++col)
- if (values[i++])
- win.insert(sli, row, col);
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ template <unsigned M>
+ void
+ from_to_(bool const (&values)[M], window3d& win)
+ {
+ const int h = unsigned(std::pow(float(M), float(1. / 3.))) / 2;
+ mln_precondition((2 * h + 1) * (2 * h + 1) * (2 * h + 1) == M);
+ win.clear();
+ unsigned i = 0;
+ for (int sli = - h; sli <= h; ++sli)
+ for (int row = - h; row <= h; ++row)
+ for (int col = - h; col <= h; ++col)
+ if (values[i++])
+ win.insert(sli, row, col);
+ }
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/concept/accumulator.hh b/milena/mln/core/concept/accumulator.hh
index a28664e..968ec3a 100644
--- a/milena/mln/core/concept/accumulator.hh
+++ b/milena/mln/core/concept/accumulator.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -40,25 +40,6 @@
namespace mln
{
- // Forward declaration.
- template <typename E> struct Accumulator;
-
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename A>
- void
- from_to_(const Accumulator<A>& from, mln_result(A)& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
// Accumulator category flag type.
template <>
struct Accumulator<void>
@@ -118,39 +99,19 @@ namespace mln
template <typename T>
void take_n_times_(unsigned n, const T& t);
-
+
protected:
Accumulator();
};
-# ifndef MLN_INCLUDE_ONLY
-
-
- // convert::from_to_
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename A>
- void
- from_to_(const Accumulator<A>& from_, mln_result(A)& to)
- {
- const A& from = exact(from_);
- if (from.is_valid())
- to = from.to_result();
- else
- to = mln_result(A)();
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ /// \internal Conversion: Accumulator -> mln_result(A)
+ template <typename A>
+ void
+ from_to_(const Accumulator<A>& from, mln_result(A)& to);
+# ifndef MLN_INCLUDE_ONLY
// Accumulator<E>
@@ -235,6 +196,21 @@ namespace mln
exact(this)->take(t);
}
+
+ // Conversions
+
+ template <typename A>
+ void
+ from_to_(const Accumulator<A>& from_, mln_result(A)& to)
+ {
+ const A& from = exact(from_);
+ if (from.is_valid())
+ to = from.to_result();
+ else
+ to = mln_result(A)();
+ }
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
diff --git a/milena/mln/core/concept/gdpoint.hh b/milena/mln/core/concept/gdpoint.hh
index 722db89..2a7adf9 100644
--- a/milena/mln/core/concept/gdpoint.hh
+++ b/milena/mln/core/concept/gdpoint.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -134,28 +134,10 @@ namespace mln
operator*(const Gdpoint<D>& lhs, const value::Scalar<S>& rhs);
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename D>
- void
- from_to_(const Gdpoint<D>& from, mln_site(D)& to);
-
-// template <typename D, unsigned n, typename T>
-// void
-// from_to_(const Gdpoint<D>& from, algebra::vec<n,T>& to);
-
-// template <unsigned n, typename T, typename D>
-// void
-// from_to_(const algebra::vec<n,T>& from, Gdpoint<D>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ /// \internal Conversion: gdpoint -> mln_site
+ template <typename D>
+ void
+ from_to_(const Gdpoint<D>& from, mln_site(D)& to);
# ifndef MLN_INCLUDE_ONLY
@@ -220,26 +202,18 @@ namespace mln
}
- namespace convert
- {
+ // Conversions
- namespace over_load
- {
-
- template <typename D>
- inline
- void
- from_to_(const Gdpoint<D>& dp_, mln_site(D)& p)
- {
- enum { n = D::dim };
- const D& dp = exact(dp_);
- for (unsigned i = 0; i < n; ++i)
- p[i] = dp[i];
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ template <typename D>
+ inline
+ void
+ from_to_(const Gdpoint<D>& dp_, mln_site(D)& p)
+ {
+ enum { n = D::dim };
+ const D& dp = exact(dp_);
+ for (unsigned i = 0; i < n; ++i)
+ p[i] = dp[i];
+ }
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/concept/gpoint.hh b/milena/mln/core/concept/gpoint.hh
index 410b36a..d51b2f4 100644
--- a/milena/mln/core/concept/gpoint.hh
+++ b/milena/mln/core/concept/gpoint.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -128,30 +128,6 @@ namespace mln
};
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename P>
- void
- from_to_(const Gpoint<P>& from, mln_delta(P)& to);
-
- template <typename P, unsigned n, typename T>
- void
- from_to_(const Gpoint<P>& from, algebra::vec<n,T>& to);
-
- template <unsigned n, typename T, typename P>
- void
- from_to_(const algebra::vec<n,T>& from, Gpoint<P>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
-
/// Equality comparison between a couple of grid point \p lhs
/// and \p rhs.
/*!
@@ -289,6 +265,17 @@ namespace mln
// FIXME : add operators and traits?
+ /// \internal Conversion: gpoint -> mln_delta
+ template <typename P>
+ void
+ from_to_(const Gpoint<P>& from, mln_delta(P)& to);
+
+ /// \internal Conversion: gpoint -> algebra::vec
+ template <typename P, unsigned n, typename T>
+ void
+ from_to_(const Gpoint<P>& from, algebra::vec<n,T>& to);
+
+
# ifndef MLN_INCLUDE_ONLY
@@ -306,59 +293,6 @@ namespace mln
(void) m;
}
-
- // convert::from_to_
-
- namespace convert
- {
-
- namespace over_load
- {
-
- // Gpoint -> delta
- template <typename P>
- inline
- void
- from_to_(const Gpoint<P>& p_, mln_delta(P)& dp)
- {
- // Instead of "dp.to_vec() = exact(p).to_vec();" that
- // does not compile (cause to_vec returns const), we
- // have:
- enum { n = P::dim };
- const P& p = exact(p_);
- for (unsigned i = 0; i < n; ++i)
- dp[i] = p[i];
- }
-
- // Gpoint -> algebra::vec.
- template <typename P, unsigned n, typename T>
- inline
- void
- from_to_(const Gpoint<P>& from_, algebra::vec<n,T>& to)
- {
- mlc_bool(n == P::dim)::check();
- const P& from = exact(from_);
- for (unsigned i = 0; i < n; ++i)
- to[i] = static_cast< T >(from[i]); // FIXME: cast -> best effort...
- }
-
- // algebra::vec -> Gpoint.
- template <unsigned n, typename T, typename P>
- inline
- void
- from_to_(const algebra::vec<n,T>& from, Gpoint<P>& to_)
- {
- mlc_bool(P::dim == n)::check();
- P& to = exact(to_);
- for (unsigned i = 0; i < n; ++i)
- to[i] = static_cast< typename P::coord >(from[i]); // FIXME: cast -> best effort...
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
// Operators.
template <typename L, typename R>
@@ -454,6 +388,36 @@ namespace mln
return tmp;
}
+
+
+ // Conversions
+
+ template <typename P>
+ inline
+ void
+ from_to_(const Gpoint<P>& p_, mln_delta(P)& dp)
+ {
+ // Instead of "dp.to_vec() = exact(p).to_vec();" that
+ // does not compile (cause to_vec returns const), we
+ // have:
+ enum { n = P::dim };
+ const P& p = exact(p_);
+ for (unsigned i = 0; i < n; ++i)
+ dp[i] = p[i];
+ }
+
+ template <typename P, unsigned n, typename T>
+ inline
+ void
+ from_to_(const Gpoint<P>& from_, algebra::vec<n,T>& to)
+ {
+ mlc_bool(n == P::dim)::check();
+ const P& from = exact(from_);
+ for (unsigned i = 0; i < n; ++i)
+ to[i] = static_cast< T >(from[i]); // FIXME: cast -> best effort...
+ }
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
diff --git a/milena/mln/core/concept/image.hh b/milena/mln/core/concept/image.hh
index 4c70768..a79cd37 100644
--- a/milena/mln/core/concept/image.hh
+++ b/milena/mln/core/concept/image.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -55,6 +55,7 @@ namespace mln
// Forward declarations.
template <typename E> struct Image;
template <typename E> struct Literal;
+ template <typename D, typename W> struct w_window;
// Image category flag type.
@@ -121,20 +122,15 @@ namespace mln
};
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename V, unsigned S, typename I>
- void
- from_to_(const V (&values)[S], Image<I>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ /// \internal Conversion: image -> w_window
+ template <typename I, typename D, typename W>
+ void
+ from_to_(const Image<I>& from, w_window<D,W>& to);
+ /// \internal Conversion: values[] -> image
+ template <typename V, unsigned S, typename I>
+ void
+ from_to_(const V (&values)[S], Image<I>& to);
# ifndef MLN_INCLUDE_ONLY
@@ -269,43 +265,48 @@ namespace mln
}
- namespace convert
+ template <typename I, typename D, typename W>
+ void
+ from_to_(const Image<I>& from_, w_window<D,W>& to)
{
+ mlc_converts_to(mln_deduce(I, psite, delta), D)::check();
+ mlc_converts_to(mln_value(I), W)::check();
+ const I& ima = exact(from_);
+ to.clear();
+ mln_value(I) zero = literal::zero;
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ if (ima(p) != zero)
+ to.insert(ima(p), convert::to<D>(p));
+ }
- namespace over_load
- {
-
- template <typename V, unsigned S, typename I>
- void
- from_to_(const V (&values)[S], Image<I>& to_)
- {
- mlc_bool(S != 0)::check();
- mlc_converts_to(V, mln_value(I))::check();
- typedef mln_site(I) P;
- enum { d = P::dim,
- s = mlc_root(d, S)::value };
- metal::bool_<(mlc_pow_int(s, d) == S)>::check();
-
- I& to = exact(to_);
- mln_precondition(! to.is_valid());
-
- box<P> b(all_to(0), all_to(s - 1));
- to.init_(b);
- mln_fwd_piter(box<P>) p(b);
- unsigned i = 0;
- for_all(p)
- to(p) = values[i++];
- }
-
- } // end of namespace mln::convert::over_load
+ template <typename V, unsigned S, typename I>
+ void
+ from_to_(const V (&values)[S], Image<I>& to_)
+ {
+ mlc_bool(S != 0)::check();
+ mlc_converts_to(V, mln_value(I))::check();
+ typedef mln_site(I) P;
+ enum { d = P::dim,
+ s = mlc_root(d, S)::value };
+ metal::bool_<(mlc_pow_int(s, d) == S)>::check();
+
+ I& to = exact(to_);
+ mln_precondition(! to.is_valid());
+
+ box<P> b(all_to(0), all_to(s - 1));
+ to.init_(b);
+ mln_fwd_piter(box<P>) p(b);
+ unsigned i = 0;
+ for_all(p)
+ to(p) = values[i++];
+ }
- } // end of namespace mln::convert
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
-
# include <mln/core/routine/initialize.hh>
diff --git a/milena/mln/core/concept/proxy.hh b/milena/mln/core/concept/proxy.hh
index f22f342..8c4d2e9 100644
--- a/milena/mln/core/concept/proxy.hh
+++ b/milena/mln/core/concept/proxy.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2011, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -144,16 +144,6 @@ namespace mln
template <typename E> struct Literal;
- namespace convert
- {
-
- template <typename F, typename T>
- void from_to(const F& from, T& to);
-
- }
-
-
-
namespace trait
{
@@ -245,21 +235,10 @@ namespace mln
};
- // convert::from_to_
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename P, typename T>
- void
- from_to_(const Proxy<P>& from, T& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ /// \internal Conversion: proxy -> T
+ template <typename P, typename T>
+ void
+ from_to_(const Proxy<P>& from, T& to);
@@ -337,24 +316,14 @@ namespace mln
- // convert::from_to_
+ // Conversion
- namespace convert
+ template <typename P, typename T>
+ void
+ from_to_(const Proxy<P>& from, T& to)
{
-
- namespace over_load
- {
-
- template <typename P, typename T>
- void
- from_to_(const Proxy<P>& from, T& to)
- {
- convert::from_to(exact(from).unproxy_(), to);
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ convert::from_to(exact(from).unproxy_(), to);
+ }
// unproxy_rec
diff --git a/milena/mln/core/concept/site_set.hh b/milena/mln/core/concept/site_set.hh
index bbf217c..2e25f93 100644
--- a/milena/mln/core/concept/site_set.hh
+++ b/milena/mln/core/concept/site_set.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -87,26 +87,26 @@ namespace mln
};
+ /// \internal Conversion: site_set -> std::set
+ template <typename S, typename P, typename C_>
+ void
+ from_to_(const Site_Set<S>& from, std::set<P,C_>& to);
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename S, typename P, typename C_>
- void
- from_to_(const Site_Set<S>& from, std::set<P,C_>& to);
+} // end of namespace mln
- template <typename P, typename C_, typename S>
- void
- from_to_(const std::set<P,C_>& from, Site_Set<S>& to);
+namespace std
+{
- } // end of namespace mln::convert::over_load
+ /// \internal Conversion: std::set -> site_set
+ template <typename P, typename C_, typename S>
+ void
+ from_to_(const set<P,C_>& from, mln::Site_Set<S>& to);
- } // end of namespace mln::convert
+} // end of namespace std
+namespace mln
+{
namespace trait
{
@@ -125,49 +125,12 @@ namespace mln
} // end of namespace mln::trait
-
+} // end of namespace mln
# ifndef MLN_INCLUDE_ONLY
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename S, typename P, typename C_>
- inline
- void
- from_to_(const Site_Set<S>& from_, std::set<P,C_>& to)
- {
- mlc_converts_to(mln_psite(S), P)::check();
- const S& from = exact(from_);
- to.clear();
- mln_piter(S) p(from);
- for_all(p)
- to.insert(p);
- }
-
-
- template <typename P, typename C_, typename S>
- inline
- void
- from_to_(const std::set<P,C_>& from, Site_Set<S>& to_)
- {
- mlc_converts_to(P, mln_i_element(S))::check();
- S& to = exact(to_);
- to.clear();
- for (typename std::set<P>::const_iterator i = from.begin();
- i != from.end();
- ++i)
- to.insert(*i);
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
+namespace mln
+{
namespace internal
{
@@ -293,10 +256,46 @@ namespace mln
internal::site_set_contents_check< mln_trait_site_set_contents(E), E >::run();
}
-# endif // ! MLN_INCLUDE_ONLY
+
+ // Conversion
+
+ template <typename S, typename P, typename C_>
+ inline
+ void
+ from_to_(const Site_Set<S>& from_, std::set<P,C_>& to)
+ {
+ mlc_converts_to(mln_psite(S), P)::check();
+ const S& from = exact(from_);
+ to.clear();
+ mln_piter(S) p(from);
+ for_all(p)
+ to.insert(p);
+ }
} // end of namespace mln
+namespace std
+{
+
+ template <typename P, typename C_, typename S>
+ inline
+ void
+ from_to_(const set<P,C_>& from, mln::Site_Set<S>& to_)
+ {
+ mlc_converts_to(P, mln_i_element(S))::check();
+ S& to = exact(to_);
+ to.clear();
+ for (typename set<P>::const_iterator i = from.begin();
+ i != from.end();
+ ++i)
+ to.insert(*i);
+ }
+
+} // end of namespace std
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
# include <mln/core/site_set/operators.hh>
# include <mln/core/routine/ops.hh>
diff --git a/milena/mln/core/concept/window.hh b/milena/mln/core/concept/window.hh
index 3b2eafb..9aa58bd 100644
--- a/milena/mln/core/concept/window.hh
+++ b/milena/mln/core/concept/window.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -40,8 +40,7 @@
# include <mln/trait/windows.hh>
# include <mln/core/site_set/p_array.hh>
-# include <mln/core/internal/geom_bbox.hh> // For use in convert::from_to.
-# include <mln/convert/from_to.hxx>
+# include <mln/core/internal/geom_bbox.hh> // For use in from_to_.
# include <mln/util/array.hh>
@@ -112,34 +111,24 @@ namespace mln
std::ostream& operator<<(std::ostream& ostr, const Window<W>& win);
+ /// \internal Conversion: window -> image
+ template <typename W, typename I>
+ void
+ from_to_(const Window<W>& from, Image<I>& to);
+
+
// FIXME: Move as a method of Image?
template <typename I, typename W>
util::array<int>
offsets_wrt(const Image<I>& ima, const Window<W>& win);
-
+
template <typename I, typename W>
util::array<int>
positive_offsets_wrt(const Image<I>& ima, const Window<W>& win);
-
+
template <typename I, typename W>
util::array<int>
negative_offsets_wrt(const Image<I>& ima, const Window<W>& win);
-
-
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename W, typename I>
- void
- from_to_(const Window<W>& from, Image<I>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
@@ -305,7 +294,7 @@ namespace mln
}
ostr << " ]";
}
-
+
} // end of namespace mln::internal
template <typename W>
@@ -323,6 +312,35 @@ namespace mln
}
+ template <typename W, typename I>
+ void
+ from_to_(const Window<W>& win_, Image<I>& ima_)
+ {
+ mln_is_simple_window(W)::check();
+ typedef mln_psite(I) P;
+ mlc_converts_to(mln_dpsite(W), mln_delta(P))::check();
+ mlc_equal(mln_value(I), bool)::check();
+
+ const W& win = exact(win_);
+ I& ima = exact(ima_);
+
+ mln_precondition(win.is_valid());
+ mln_precondition(! ima.is_valid());
+
+ // Hack (below) to avoid circular dependency.
+ ima.init_(mln::internal::geom_bbox(win));
+ {
+ // data::fill(ima, false) is:
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ ima(p) = false;
+ }
+ unsigned n = win.size();
+ for (unsigned i = 0; i < n; ++i)
+ ima(convert::to<P>(win.dp(i))) = true;
+ }
+
+
template <typename I, typename W>
inline
util::array<int>
@@ -337,7 +355,7 @@ namespace mln
util::array<int> arr;
unsigned n = win.size();
-
+
for (unsigned i = 0; i < n; ++i)
arr.append(ima.delta_index(win.dp(i)));
@@ -359,7 +377,7 @@ namespace mln
util::array<int> arr;
unsigned n = win.size();
-
+
for (unsigned i = 0; i < n; ++i)
{
int offset = ima.delta_index(win.dp(i));
@@ -385,7 +403,7 @@ namespace mln
util::array<int> arr;
unsigned n = win.size();
-
+
for (unsigned i = 0; i < n; ++i)
{
int offset = ima.delta_index(win.dp(i));
@@ -396,45 +414,6 @@ namespace mln
return arr;
}
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename W, typename I>
- void
- from_to_(const Window<W>& win_, Image<I>& ima_)
- {
- mln_is_simple_window(W)::check();
- typedef mln_psite(I) P;
- mlc_converts_to(mln_dpsite(W), mln_delta(P))::check();
- mlc_equal(mln_value(I), bool)::check();
-
- const W& win = exact(win_);
- I& ima = exact(ima_);
-
- mln_precondition(win.is_valid());
- mln_precondition(! ima.is_valid());
-
- // Hack (below) to avoid circular dependency.
- ima.init_(mln::internal::geom_bbox(win));
- {
- // data::fill(ima, false) is:
- mln_piter(I) p(ima.domain());
- for_all(p)
- ima(p) = false;
- }
- unsigned n = win.size();
- for (unsigned i = 0; i < n; ++i)
- ima(convert::to<P>(win.dp(i))) = true;
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
diff --git a/milena/mln/core/dpoint.hh b/milena/mln/core/dpoint.hh
index f4d603e..0e5c0ef 100644
--- a/milena/mln/core/dpoint.hh
+++ b/milena/mln/core/dpoint.hh
@@ -33,7 +33,6 @@
# include <mln/core/def/coord.hh>
# include <mln/core/concept/gdpoint.hh>
# include <mln/core/internal/coord_impl.hh>
-# include <mln/fun/i2v/all.hh>
# include <mln/algebra/vec.hh>
# include <mln/metal/converts_to.hh>
diff --git a/milena/mln/core/image/graph_window_if_piter.hh b/milena/mln/core/image/graph_window_if_piter.hh
index 068fbdb..1060f15 100644
--- a/milena/mln/core/image/graph_window_if_piter.hh
+++ b/milena/mln/core/image/graph_window_if_piter.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2012 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -30,6 +31,7 @@
///
/// \brief Definition of a site iterator on a custom graph window.
+# include <mln/core/concept/window.hh>
# include <mln/core/internal/is_masked_impl_selector.hh>
# include <mln/core/internal/site_relative_iterator_base.hh>
diff --git a/milena/mln/core/image/image1d.hh b/milena/mln/core/image/image1d.hh
index 6d10aa5..53e8611 100644
--- a/milena/mln/core/image/image1d.hh
+++ b/milena/mln/core/image/image1d.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -122,27 +122,6 @@ namespace mln
template <typename T> struct image1d;
-
- namespace convert
- {
-
- namespace over_load
- {
-
- // histo::array -> image1d.
- template <typename V, typename T>
- void from_to_(const histo::array<V>& from, image1d<T>& to);
-
- // util::array -> image1d.
- template <typename V, typename T>
- void from_to_(const util::array<V>& from, image1d<T>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
-
/// Basic 1D image class.
///
/// The parameter \c T is the type of pixel values. This image class
@@ -578,46 +557,6 @@ namespace mln
namespace mln
{
-
- namespace convert
- {
-
- namespace over_load
- {
-
- // histo::array -> image1d.
- template <typename V, typename T>
- inline
- void
- from_to_(const histo::array<V>& from, image1d<T>& to)
- {
- // FIXME: The code should looks like:
-
-// box1d b(point1d(mln_min(V)), point1d(mln_max(V)));
-// ima.init_(b, 0);
-// for_all(v)
-// from_to(h(v), ima.at_( index_of(v) ));
- to.init_(make::box1d(from.nvalues()));
- for (unsigned i = 0; i < from.nvalues(); ++i)
- from_to(from[i], to(point1d(i)));
- }
-
- // util::array -> image1d.
- template <typename V, typename T>
- inline
- void
- from_to_(const util::array<V>& from, image1d<T>& to)
- {
- to.init_(make::box1d(from.nelements()));
- for (unsigned i = 0; i < from.nelements(); ++i)
- from_to(from[i], to(point1d(i)));
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
namespace trait
{
diff --git a/milena/mln/core/internal/neighborhood_base.hh b/milena/mln/core/internal/neighborhood_base.hh
index f1765c9..f96b8f4 100644
--- a/milena/mln/core/internal/neighborhood_base.hh
+++ b/milena/mln/core/internal/neighborhood_base.hh
@@ -42,6 +42,7 @@ namespace mln
// Forward declaration.
+ template <typename W> class neighb;
namespace win
{
template <unsigned n, typename W, typename F>
@@ -66,25 +67,25 @@ namespace mln
/// Give the foreground neighborhood in the case of a dual
/// neighborhood. For instance, with (object:c4, background:c8),
/// the result is c4.
-
+
neighb<W> foreground() const
{
W win = internal::force_exact<E>(*this).win().window_(1); // True, so object.
neighb<W> nbh(win);
return nbh;
}
-
+
/// Give the background neighborhood in the case of a dual
/// neighborhood. For instance, with (object:c4, background:c8),
/// the result is c8.
-
+
neighb<W> background() const
{
W win = internal::force_exact<E>(*this).win().window_(0); // False, so background.
neighb<W> nbh(win);
return nbh;
}
-
+
};
diff --git a/milena/mln/core/mixed_neighb.hh b/milena/mln/core/mixed_neighb.hh
index 7789aba..2c89131 100644
--- a/milena/mln/core/mixed_neighb.hh
+++ b/milena/mln/core/mixed_neighb.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2012 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -50,27 +51,6 @@ namespace mln
// Forward declarations.
template <typename W> class mixed_neighb_fwd_niter;
template <typename W> class mixed_neighb_bkd_niter;
- template <typename W> class mixed_neighb;
-
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename W>
- void
- from_to_(const mln::mixed_neighb<W>& from, W& to);
-
- template <typename W>
- void
- from_to_(const W& from, mln::mixed_neighb<W>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
/// Adapter class from window to neighborhood.
@@ -103,6 +83,18 @@ namespace mln
};
+ /// \internal Conversion: mixed_neighb<W> -> W
+ template <typename W>
+ void
+ from_to_(const mln::mixed_neighb<W>& from, W& to);
+
+ /// \internal Conversion: mixed_neighb<W> -> W
+ template <typename W>
+ void
+ from_to_(const W& from, mln::mixed_neighb<W>& to);
+
+
+
// mixed_neighb_fwd_niter<W>
template <typename W>
@@ -167,33 +159,21 @@ namespace mln
}
- // mln::convert::from_to
+ // Conversion
- namespace convert
+ template <typename W>
+ void
+ from_to_(const mln::mixed_neighb<W>& from, W& to)
{
+ to = from.win();
+ }
- namespace over_load
- {
-
- template <typename W>
- void
- from_to_(const mln::mixed_neighb<W>& from, W& to)
- {
- to = from.win();
- }
-
- template <typename W>
- void
- from_to_(const W& from, mln::mixed_neighb<W>& to)
- {
- to.change_window(from);
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
+ template <typename W>
+ void
+ from_to_(const W& from, mln::mixed_neighb<W>& to)
+ {
+ to.change_window(from);
+ }
// mixed_neighb_fwd_niter<W>
diff --git a/milena/mln/core/neighb.hh b/milena/mln/core/neighb.hh
index db31bea..4f348b1 100644
--- a/milena/mln/core/neighb.hh
+++ b/milena/mln/core/neighb.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -47,26 +47,6 @@ namespace mln
// Forward declarations.
template <typename W> class neighb_fwd_niter;
template <typename W> class neighb_bkd_niter;
- template <typename W> class neighb;
-
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename W>
- void
- from_to_(const mln::neighb<W>& from, W& to);
-
- template <typename W>
- void
- from_to_(const W& from, mln::neighb<W>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
@@ -99,6 +79,17 @@ namespace mln
};
+ /// \internal Conversions: neighb<W> -> W
+ template <typename W>
+ void
+ from_to_(const mln::neighb<W>& from, W& to);
+
+ /// \internal Conversions: W -> neighb<W>
+ template <typename W>
+ void
+ from_to_(const W& from, mln::neighb<W>& to);
+
+
// neighb_fwd_niter<W>
template <typename W>
@@ -159,35 +150,6 @@ namespace mln
}
- // mln::convert::from_to
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename W>
- void
- from_to_(const mln::neighb<W>& from, W& to)
- {
- to = from.win();
- }
-
- template <typename W>
- void
- from_to_(const W& from, mln::neighb<W>& to)
- {
- to.change_window(from);
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
-
-
// neighb_fwd_niter<W>
template <typename W>
@@ -224,6 +186,20 @@ namespace mln
this->i_.init_(nbh.win(), c);
}
+ template <typename W>
+ void
+ from_to_(const neighb<W>& from, W& to)
+ {
+ to = from.win();
+ }
+
+ template <typename W>
+ void
+ from_to_(const W& from, neighb<W>& to)
+ {
+ to.change_window(from);
+ }
+
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/point.hh b/milena/mln/core/point.hh
index d415cf8..03afe57 100644
--- a/milena/mln/core/point.hh
+++ b/milena/mln/core/point.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008, 2009, 2010, 2011 EPITA Research and
+// Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 EPITA Research and
// Development Laboratory (LRDE)
//
// This file is part of Olena.
@@ -41,7 +41,6 @@
# include <mln/core/concept/proxy.hh>
# include <mln/core/concept/gpoint.hh>
# include <mln/core/internal/coord_impl.hh>
-# include <mln/fun/i2v/all_to.hh>
# include <mln/metal/bool.hh>
# include <mln/metal/is_not.hh>
@@ -65,29 +64,6 @@ namespace mln
/// \}
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename G, typename C1, typename C2>
- void from_to_(const point<G,C1>& from, point<G,C2>& to);
-
- template <unsigned n, typename C1, typename G, typename C2>
- void
- from_to_(const mln::algebra::vec<n,C1>& from, point<G,C2>& to);
-
- template <unsigned n, typename C1, typename G>
- void
- from_to_(const mln::algebra::vec<n,C1>& from, point<G,C1>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
-
namespace internal
{
// This is a hack so that g++-2.95 can compile the method
@@ -224,6 +200,12 @@ namespace mln
mln::algebra::vec<G::dim, C> coord_;
};
+
+ /// \internal Conversion: point -> point
+ template <typename G, typename C1, typename C2>
+ void from_to_(const point<G,C1>& from, point<G,C2>& to);
+
+
namespace internal
{
@@ -260,126 +242,6 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
- namespace internal
- {
-
- template <typename C, typename C2>
- inline
- C
- convert_data_(metal::bool_<false>, const C2& v)
- {
- return static_cast<C>(v);
- }
-
- template <typename C, typename C2>
- inline
- C
- convert_data_(metal::bool_<true>, const C2& v)
- {
- return static_cast<C>(round(v));
- }
-
- template <typename C, typename C2>
- inline
- C
- convert_data(const C2& v)
- {
- // If (C != float && C != double) && (C2 == float || C2 == double)
- // => We want to round the value.
- // Otherwise we can just statically cast.
- //
- return convert_data_<C>(
- typename mlc_and(
- mlc_and(mlc_is_not(C,float),
- mlc_is_not(C,double)),
- mlc_or(mlc_is(C2,float),
- mlc_is(C2, double)))::eval(), v);
- }
-
-
-
- } // end of namespace mln::internal
-
-
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename G, typename C1, typename C2>
- inline
- void
- from_to_(const point<G,C1>& from, point<G,C2>& to)
- {
- mlc_converts_to(C1,C2)::check();
- enum { dim = G::dim };
-
- for (unsigned i = 0; i < dim; ++i)
- to[i] = mln::internal::convert_data<C2>(from[i]);
- }
-
-
- template <unsigned n, typename C1, typename G, typename C2>
- inline
- void
- from_to_(const mln::algebra::vec<n,C1>& from, point<G,C2>& to)
- {
- mlc_converts_to(C1, C2)::check();
- enum { dim = G::dim };
- mlc_bool(G::dim == n)::check();
-
- unsigned j = 0;
- for (unsigned i = dim - 2; i < dim; ++i)
- to[i] = mln::internal::convert_data<C2>(from[j++]);
- for (unsigned i = 2; i < dim; ++i, ++j)
- to[i-j] = mln::internal::convert_data<C2>(from[j]);
- }
-
- template <typename C1, typename G, typename C2>
- inline
- void
- from_to_(const mln::algebra::vec<1,C1>& from, point<G,C2>& to)
- {
- mlc_converts_to(C1, C2)::check();
- enum { dim = G::dim };
- mlc_bool(G::dim == 1)::check();
-
- to[0] = mln::internal::convert_data<C2>(from[0]);
- }
-
- template <unsigned n, typename C1, typename G>
- inline
- void
- from_to_(const mln::algebra::vec<n,C1>& from, point<G,C1>& to)
- {
- enum { dim = G::dim };
- mlc_bool(G::dim == n)::check();
-
- unsigned j = 0;
- for (unsigned i = dim - 2; i < dim; ++i)
- to[i] = from[j++];
- for (unsigned i = 2; i < dim; ++i, ++j)
- to[i-j] = from[j];
- }
-
- template <typename C1, typename G>
- inline
- void
- from_to_(const mln::algebra::vec<1,C1>& from, point<G,C1>& to)
- {
- enum { dim = G::dim };
- mlc_bool(G::dim == 1)::check();
-
- to[0] = from[0];
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
template <typename G, typename C>
inline
const C& point<G,C>::operator[](unsigned i) const
@@ -426,7 +288,7 @@ namespace mln
inline
point<G,C>::point(const mln::algebra::vec<dim,C2>& v)
{
- convert::over_load::from_to_(v, *this);
+ from_to_(v, *this);
}
@@ -434,7 +296,7 @@ namespace mln
inline
point<G,C>::point(const mln::algebra::vec<dim,C>& v)
{
- convert::over_load::from_to_(v, *this);
+ from_to_(v, *this);
}
@@ -638,6 +500,22 @@ namespace mln
return coord_;
}
+
+ // Conversions
+
+ template <typename G, typename C1, typename C2>
+ inline
+ void
+ from_to_(const point<G,C1>& from, point<G,C2>& to)
+ {
+ mlc_converts_to(C1,C2)::check();
+ enum { dim = G::dim };
+
+ for (unsigned i = 0; i < dim; ++i)
+ to[i] = mln::internal::convert_data<C2>(from[i]);
+ }
+
+
namespace internal
{
diff --git a/milena/mln/core/site_set/operators.hh b/milena/mln/core/site_set/operators.hh
index 89637ad..9cf2509 100644
--- a/milena/mln/core/site_set/operators.hh
+++ b/milena/mln/core/site_set/operators.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -121,8 +122,8 @@ namespace mln
typedef mln_site(Sl) P;
mlc_converts_to(mln_psite(Sr), P)::check();
std::set< P, util::ord<P> > sl, sr, sd;
- convert::over_load::from_to_(lhs, sl);
- convert::over_load::from_to_(rhs, sr);
+ from_to_(lhs, sl);
+ from_to_(rhs, sr);
std::set_symmetric_difference(sl.begin(), sl.end(),
sr.begin(), sr.end(),
std::inserter(sd, sd.begin()),
@@ -136,7 +137,7 @@ namespace mln
to_std_set(const Site_Set<S>& s)
{
std::set< mln_site(S), util::ord<mln_site(S)> > std_s;
- convert::over_load::from_to_(s, std_s);
+ from_to_(s, std_s);
return std_s;
}
@@ -148,8 +149,8 @@ namespace mln
typedef mln_site(Sl) P;
mlc_converts_to(mln_psite(Sr), P)::check();
std::set< P, util::ord<P> > sl, sr;
- convert::over_load::from_to_(lhs, sl);
- convert::over_load::from_to_(rhs, sr);
+ from_to_(lhs, sl);
+ from_to_(rhs, sr);
return std::includes(sr.begin(), sr.end(),
sl.begin(), sl.end(),
util::ord<P>());
diff --git a/milena/mln/core/site_set/p_centered.hh b/milena/mln/core/site_set/p_centered.hh
index 4c4efd9..cf2bd5c 100644
--- a/milena/mln/core/site_set/p_centered.hh
+++ b/milena/mln/core/site_set/p_centered.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -34,7 +35,7 @@
/// \todo Add the bkd iter.
/// \todo Code is_valid() and change_target() for the site set.
-
+# include <mln/core/concept/window.hh>
# include <mln/core/internal/site_set_base.hh>
# include <mln/core/internal/site_set_iterator_base.hh>
diff --git a/milena/mln/core/site_set/p_vaccess.hh b/milena/mln/core/site_set/p_vaccess.hh
index 677ae2b..d7a753c 100644
--- a/milena/mln/core/site_set/p_vaccess.hh
+++ b/milena/mln/core/site_set/p_vaccess.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -31,6 +32,7 @@
/// \todo Fix the FIXMEs.
# include <utility>
+# include <vector>
# include <mln/core/concept/site_set.hh>
# include <mln/core/site_set/p_double.hh>
# include <mln/core/internal/site_set_base.hh>
diff --git a/milena/mln/core/w_window.hh b/milena/mln/core/w_window.hh
index d463697..1022dd5 100644
--- a/milena/mln/core/w_window.hh
+++ b/milena/mln/core/w_window.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -55,29 +56,6 @@ namespace mln
template <typename It, typename W> struct with_w_;
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename I, typename D, typename W>
- void
- from_to_(const Image<I>& from, w_window<D,W>& to);
-
- template <typename D, typename W, typename I>
- void
- from_to_(const w_window<D,W>& from, Image<I>& to);
-
- template <typename V, unsigned S, typename D, typename W>
- void
- from_to_(const V (&weight)[S], w_window<D,W>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
namespace trait
{
@@ -164,6 +142,15 @@ namespace mln
bool operator==(const w_window<D,Wl>& lhs, const w_window<D,Wr>& rhs);
+ /// \internal Conversions: w_window -> image
+ template <typename D, typename W, typename I>
+ void from_to_(const w_window<D,W>& from, Image<I>& to);
+
+ /// \internal Conversions: weight[] -> w_window
+ template <typename V, unsigned S, typename D, typename W>
+ void from_to_(const V (&weight)[S], w_window<D,W>& to);
+
+
/// Decorator to handle weights for iterators on window points.
template <typename It, typename W>
@@ -195,7 +182,7 @@ namespace mln
wei_(ds.weights())
{
}
-
+
template <typename It, typename W>
inline
W
@@ -312,107 +299,6 @@ namespace mln
}
- // convert::from_to_
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename I, typename D, typename W>
- void
- from_to_(const Image<I>& from_, w_window<D,W>& to)
- {
- mlc_converts_to(mln_deduce(I, psite, delta), D)::check();
- mlc_converts_to(mln_value(I), W)::check();
- const I& ima = exact(from_);
- to.clear();
- mln_value(I) zero = literal::zero;
- mln_piter(I) p(ima.domain());
- for_all(p)
- if (ima(p) != zero)
- to.insert(ima(p), convert::to<D>(p));
- }
-
- template <typename D, typename W, typename I>
- void
- from_to_(const w_window<D,W>& w_win, Image<I>& ima_)
- {
- typedef mln_site(I) P;
- mlc_converts_to(D, mln_delta(P))::check();
- mlc_converts_to(W, mln_value(I))::check();
-
- I& ima = exact(ima_);
- mln_precondition(! ima.is_valid());
- mln_precondition(w_win.is_valid());
-
- ima.init_(geom::bbox(w_win));
- {
- // data::fill(ima, literal::zero) is:
- mln_value(I) zero = literal::zero;
- mln_piter(I) p(ima.domain());
- for_all(p)
- ima(p) = zero;
- }
-
- unsigned n = w_win.size();
- for (unsigned i = 0; i < n; ++i)
- ima(convert::to<P>(w_win.dp(i))) = w_win.w(i);
- }
-
- // FIXME: Sample code (below) to generalize the code above:
-
-// template <typename W>
-// inline
-// mln_image_from(W, mln_weight(W)) to_image(const Weighted_Window<W>& w_win_)
-// {
-// const W& w_win = exact(w_win_);
-// mln_precondition(! w_win.is_empty());
-
-// typedef mln_psite(W) P;
-// box<P> b = geom::bbox(w_win);
-// mln_image_from(W, mln_weight(W)) ima(b);
-// // Fill the image with zeros, as (weighted) windows are not
-// // necessarily box-shaped (there might be holes corresponding to
-// // null weights).
-// data::fill(ima, literal::zero);
-// P O = P::origin;
-// mln_qiter(W) q(w_win, O);
-// for_all(q)
-// ima(q) = q.w();
-// return ima;
-// }
-
- template <typename V, unsigned S, typename D, typename W>
- void
- from_to_(const V (&weight)[S], w_window<D,W>& to)
- {
- mlc_bool(S != 0)::check();
- mlc_converts_to(V, W)::check();
- enum { d = D::dim,
- s = mlc_root(d,S)::value / 2 };
- metal::bool_<(mlc_pow_int(2 * s + 1, d) == S)>::check();
- to.clear();
- typedef mln_site(D) P;
- box<P> b(all_to(-s), all_to(+s));
- mln_fwd_piter(box<P>) p(b);
- unsigned i = 0;
- V zero = literal::zero;
- for_all(p)
- {
- if (weight[i] != zero)
- to.insert(weight[i], convert::to<D>(p));
- ++i;
- }
-
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
// operators
template <typename D, typename W>
@@ -442,6 +328,59 @@ namespace mln
return true;
}
+
+ // Conversions
+
+ template <typename D, typename W, typename I>
+ void
+ from_to_(const w_window<D,W>& w_win, Image<I>& ima_)
+ {
+ typedef mln_site(I) P;
+ mlc_converts_to(D, mln_delta(P))::check();
+ mlc_converts_to(W, mln_value(I))::check();
+
+ I& ima = exact(ima_);
+ mln_precondition(! ima.is_valid());
+ mln_precondition(w_win.is_valid());
+
+ ima.init_(geom::bbox(w_win));
+ {
+ // data::fill(ima, literal::zero) is:
+ mln_value(I) zero = literal::zero;
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ ima(p) = zero;
+ }
+
+ unsigned n = w_win.size();
+ for (unsigned i = 0; i < n; ++i)
+ ima(convert::to<P>(w_win.dp(i))) = w_win.w(i);
+ }
+
+ template <typename V, unsigned S, typename D, typename W>
+ void
+ from_to_(const V (&weight)[S], w_window<D,W>& to)
+ {
+ mlc_bool(S != 0)::check();
+ mlc_converts_to(V, W)::check();
+ enum { d = D::dim,
+ s = mlc_root(d,S)::value / 2 };
+ metal::bool_<(mlc_pow_int(2 * s + 1, d) == S)>::check();
+ to.clear();
+ typedef mln_site(D) P;
+ box<P> b(all_to(-s), all_to(+s));
+ mln_fwd_piter(box<P>) p(b);
+ unsigned i = 0;
+ V zero = literal::zero;
+ for_all(p)
+ {
+ if (weight[i] != zero)
+ to.insert(weight[i], convert::to<D>(p));
+ ++i;
+ }
+
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
diff --git a/milena/mln/fun/i2v/array.hh b/milena/mln/fun/i2v/array.hh
index 21ddbac..a0e392a 100644
--- a/milena/mln/fun/i2v/array.hh
+++ b/milena/mln/fun/i2v/array.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -49,38 +50,9 @@ namespace mln
} // end of namespace mln::fun::i2v
} // end of namespace mln::fun
-
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename T>
- inline
- void
- from_to_(const util::array<T>& from, fun::i2v::array<T>& to);
-
- template <typename T, typename U>
- inline
- void
- from_to_(const util::array<T>& from, fun::i2v::array<U>& to);
-
- template <typename T>
- inline
- void
- from_to_(const std::vector<T>& from, fun::i2v::array<T>& to);
-
- template <typename T, typename U>
- inline
- void
- from_to_(const std::vector<T>& from, fun::i2v::array<U>& to);
-
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ namespace util {
+ template <typename T> class array;
+ }
namespace fun
@@ -158,14 +130,41 @@ namespace mln
const array<T>& a);
+ /// \internal Conversion: fun::i2v::array -> util::array
+ template <typename T1, typename T2>
+ void
+ from_to_(const fun::i2v::array<T1>& from, util::array<T2>& to);
+
} // end of namespace mln::fun::i2v
} // end of namespace mln::fun
+} // end of namespace mln
+
+
+namespace std
+{
+
+ /// \internal Conversion: std::vectorfun::i2v::array<T> -> fun::i2v::array<T>
+ template <typename T>
+ inline
+ void
+ from_to_(const vector<T>& from, mln::fun::i2v::array<T>& to);
+
+ /// \internal Conversion: std::vector<T> -> mln::fun::i2v::array<U>
+ template <typename T, typename U>
+ inline
+ void
+ from_to_(const vector<T>& from, mln::fun::i2v::array<U>& to);
+
+} // end of namespace std
# ifndef MLN_INCLUDE_ONLY
+namespace mln
+{
+
// Init.
template <typename T1, typename T2>
@@ -177,57 +176,6 @@ namespace mln
}
- // convert::from_to
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename T>
- inline
- void
- from_to_(const util::array<T>& from, fun::i2v::array<T>& to)
- {
- to = fun::i2v::array<T>(from);
- }
-
- template <typename T, typename U>
- inline
- void
- from_to_(const util::array<T>& from, fun::i2v::array<U>& to)
- {
- to.resize(from.nelements());
- for (unsigned i = 0; i < from.nelements(); ++i)
- to(i) = convert::to<U>(from[i]);
- }
-
- template <typename T>
- inline
- void
- from_to_(const std::vector<T>& from, fun::i2v::array<T>& to)
- {
- to = fun::i2v::array<T>(from);
- }
-
- template <typename T, typename U>
- inline
- void
- from_to_(const std::vector<T>& from, fun::i2v::array<U>& to)
- {
- to.resize(from.nelements());
- for (unsigned i = 0; i < from.size(); ++i)
- to(i) = convert::to<U>(from[i]);
- }
-
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
-
/// fun::i2v::array
namespace fun
@@ -366,6 +314,18 @@ namespace mln
}
+ // Conversion
+
+ template <typename T1, typename T2>
+ void
+ from_to_(const array<T1>& from, util::array<T2>& to)
+ {
+ to.resize(from.size());
+
+ for (unsigned i = 0; i < from.size(); ++i)
+ to[i] = convert::to<T2>(from(i));
+ }
+
} // end of namespace mln::fun::i2v
} // end of namespace mln::fun
@@ -379,9 +339,31 @@ namespace mln
return tmp;
}
-# endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln
+namespace std
+{
+
+ template <typename T>
+ inline
+ void
+ from_to_(const vector<T>& from, mln::fun::i2v::array<T>& to)
+ {
+ to = mln::fun::i2v::array<T>(from);
+ }
+
+ template <typename T, typename U>
+ inline
+ void
+ from_to_(const vector<T>& from, mln::fun::i2v::array<U>& to)
+ {
+ to.resize(from.nelements());
+ for (unsigned i = 0; i < from.size(); ++i)
+ to(i) = mln::convert::to<U>(from[i]);
+ }
+
+} // end of namespace std
+
+# endif // ! MLN_INCLUDE_ONLY
#endif // ! MLN_FUN_I2V_ARRAY_HH
diff --git a/milena/mln/fun/v2v/hsl_to_rgb.hh b/milena/mln/fun/v2v/hsl_to_rgb.hh
index dbedcf4..3a606d0 100644
--- a/milena/mln/fun/v2v/hsl_to_rgb.hh
+++ b/milena/mln/fun/v2v/hsl_to_rgb.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2011, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -48,14 +48,6 @@
namespace mln
{
- // Forward declarations
- namespace value
- {
- template <typename H, typename S, typename L> class hsl_;
- typedef hsl_<float, float, float> hsl_f;
- template <unsigned n> struct rgb;
- }
-
namespace fun
{
diff --git a/milena/mln/fun/v2v/rgb_to_hsl.hh b/milena/mln/fun/v2v/rgb_to_hsl.hh
index 7ec9b72..11339fd 100644
--- a/milena/mln/fun/v2v/rgb_to_hsl.hh
+++ b/milena/mln/fun/v2v/rgb_to_hsl.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2011, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -35,8 +35,6 @@
# include <mln/trait/value_.hh>
-# include <mln/value/rgb.hh>
-
namespace mln
{
diff --git a/milena/mln/histo/array.hh b/milena/mln/histo/array.hh
index 0f4ed77..b60bad3 100644
--- a/milena/mln/histo/array.hh
+++ b/milena/mln/histo/array.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -35,10 +36,17 @@
# include <mln/value/set.hh>
+// For conversion
+# include <mln/convert/from_to.hh>
+# include <mln/make/box1d.hh>
+
namespace mln
{
+ // Forward declaration
+ template <typename T> struct image1d;
+
namespace histo
{
@@ -76,8 +84,9 @@ namespace mln
template <typename T>
std::ostream& operator<<(std::ostream& ostr, const array<T>& h);
-
-
+ /// \internal Conversion: histo::array -> image1d.
+ template <typename V, typename T>
+ void from_to_(const array<V>& from, image1d<T>& to);
# ifndef MLN_INCLUDE_ONLY
@@ -185,6 +194,25 @@ namespace mln
return ostr;
}
+
+ // Conversions
+
+ template <typename V, typename T>
+ inline
+ void
+ from_to_(const array<V>& from, image1d<T>& to)
+ {
+ // FIXME: The code should looks like:
+
+// box1d b(point1d(mln_min(V)), point1d(mln_max(V)));
+// ima.init_(b, 0);
+// for_all(v)
+// from_to(h(v), ima.at_( index_of(v) ));
+ to.init_(make::box1d(from.nvalues()));
+ for (unsigned i = 0; i < from.nvalues(); ++i)
+ convert::from_to(from[i], to(point1d(i)));
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::histo
diff --git a/milena/mln/io/magick/save.hh b/milena/mln/io/magick/save.hh
index d3c4aa6..80b20df 100644
--- a/milena/mln/io/magick/save.hh
+++ b/milena/mln/io/magick/save.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2009, 2010, 2011 EPITA Research and Development
+// Copyright (C) 2009, 2010, 2011, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -42,12 +42,16 @@
# include <mln/metal/equal.hh>
-# include <mln/core/concept/image.hh>
+# include <mln/core/alias/dpoint2d.hh>
+# include <mln/core/pixter2d.hh>
# include <mln/value/int_u8.hh>
# include <mln/value/rgb8.hh>
# include <mln/value/qt/rgb32.hh>
+# include <mln/geom/nrows.hh>
+# include <mln/geom/ncols.hh>
+
namespace mln
{
diff --git a/milena/mln/io/plot/save.hh b/milena/mln/io/plot/save.hh
index d217915..b16499b 100644
--- a/milena/mln/io/plot/save.hh
+++ b/milena/mln/io/plot/save.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2009, 2010, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -35,6 +35,7 @@
# include <fstream>
# include <mln/core/image/image1d.hh>
# include <mln/util/array.hh>
+# include <mln/histo/array.hh>
namespace mln
diff --git a/milena/mln/labeling/blobs_and_compute.hh b/milena/mln/labeling/blobs_and_compute.hh
index e8f784c..744d411 100644
--- a/milena/mln/labeling/blobs_and_compute.hh
+++ b/milena/mln/labeling/blobs_and_compute.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2009, 2010, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -38,6 +38,7 @@
# include <mln/labeling/blobs.hh>
# include <mln/labeling/compute.hh>
+# include <mln/util/couple.hh>
namespace mln
{
diff --git a/milena/mln/labeling/value_and_compute.hh b/milena/mln/labeling/value_and_compute.hh
index d93fce9..e82d8f4 100644
--- a/milena/mln/labeling/value_and_compute.hh
+++ b/milena/mln/labeling/value_and_compute.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2010, 2012 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -34,6 +35,8 @@
# include <mln/core/concept/neighborhood.hh>
# include <mln/canvas/labeling/video.hh>
# include <mln/data/fill.hh>
+# include <mln/util/array.hh>
+# include <mln/util/couple.hh>
diff --git a/milena/mln/make/w_window2d.hh b/milena/mln/make/w_window2d.hh
index 663f9ed..24e086d 100644
--- a/milena/mln/make/w_window2d.hh
+++ b/milena/mln/make/w_window2d.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -33,7 +34,7 @@
# include <mln/core/w_window.hh>
# include <mln/core/alias/dpoint2d.hh>
-# include <mln/convert/from_to.hxx>
+# include <mln/convert/from_to.hh>
namespace mln
diff --git a/milena/mln/util/array.hh b/milena/mln/util/array.hh
index c7febfe..76c05fe 100644
--- a/milena/mln/util/array.hh
+++ b/milena/mln/util/array.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2011, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -38,6 +38,7 @@
# include <iostream>
# include <algorithm>
+# include <mln/core/alias/box1d.hh>
# include <mln/core/concept/function.hh>
# include <mln/core/concept/proxy.hh>
# include <mln/core/concept/iterator.hh>
@@ -48,34 +49,14 @@
namespace mln
{
- namespace util
- {
-
- /// Forward declaration.
- template <typename T>
- class array;
-
- } // end of namespace mln::util
-
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename T1, typename T2>
- void
- from_to_(const util::array<T1>& from, util::array<T2>& to);
-
- template <typename T1, typename T2>
- void
- from_to_(const fun::i2v::array<T1>& from, util::array<T2>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
+ // Forward declarations.
+ namespace fun {
+ namespace i2v {
+ template <typename T> class array;
+ }
+ }
+ template <typename V> struct image1d;
+ // End of forward declarations
namespace util
@@ -97,7 +78,7 @@ namespace mln
//
template <typename T>
class array
- : public fun::internal::selector_from_result_<T, array<T> >::ret
+ : public mln::fun::internal::selector_from_result_<T, array<T> >::ret
// public Function_v2v< mln::util::array<T> >
{
@@ -225,6 +206,28 @@ namespace mln
const array<T>& rhs);
+ /// \internal Conversion: array -> array
+ template <typename T1, typename T2>
+ void
+ from_to_(const array<T1>& from, array<T2>& to);
+
+ /// \internal Conversion: array<T> -> fun::i2v::array<T>
+ template <typename T>
+ inline
+ void
+ from_to_(const array<T>& from, fun::i2v::array<T>& to);
+
+ /// \internal Conversion: array<T> -> fun::i2v::array<U>
+ template <typename T, typename U>
+ inline
+ void
+ from_to_(const array<T>& from, fun::i2v::array<U>& to);
+
+ /// \internal Conversion: util::array -> image1d.
+ template <typename V, typename T>
+ void from_to_(const util::array<V>& from, image1d<T>& to);
+
+
// array_fwd_iter<T>
template <typename T>
@@ -382,40 +385,6 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
- // convert::from_to_
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename T1, typename T2>
- void
- from_to_(const util::array<T1>& from, util::array<T2>& to)
- {
- to.resize(from.nelements());
-
- for (unsigned i = 0; i < from.nelements(); ++i)
- to[i] = convert::to<T2>(from[i]);
- }
-
- template <typename T1, typename T2>
- void
- from_to_(const fun::i2v::array<T1>& from, util::array<T2>& to)
- {
- to.resize(from.size());
-
- for (unsigned i = 0; i < from.size(); ++i)
- to[i] = convert::to<T2>(from(i));
- }
-
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
namespace util
{
@@ -605,6 +574,47 @@ namespace mln
}
+ // Conversions
+
+ template <typename T1, typename T2>
+ void
+ from_to_(const array<T1>& from, array<T2>& to)
+ {
+ to.resize(from.nelements());
+
+ for (unsigned i = 0; i < from.nelements(); ++i)
+ to[i] = convert::to<T2>(from[i]);
+ }
+
+ template <typename T>
+ inline
+ void
+ from_to_(const array<T>& from, fun::i2v::array<T>& to)
+ {
+ to = fun::i2v::array<T>(from);
+ }
+
+ template <typename T, typename U>
+ inline
+ void
+ from_to_(const array<T>& from, fun::i2v::array<U>& to)
+ {
+ to.resize(from.nelements());
+ for (unsigned i = 0; i < from.nelements(); ++i)
+ to(i) = convert::to<U>(from[i]);
+ }
+
+ template <typename V, typename T>
+ inline
+ void
+ from_to_(const array<V>& from, image1d<T>& to)
+ {
+ to.init_(make::box1d(from.nelements()));
+ for (unsigned i = 0; i < from.nelements(); ++i)
+ from_to(from[i], to(point1d(i)));
+ }
+
+
// util::array_fwd_iter<T>
diff --git a/milena/mln/util/object_id.hh b/milena/mln/util/object_id.hh
index 525ff15..1d2b361 100644
--- a/milena/mln/util/object_id.hh
+++ b/milena/mln/util/object_id.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2009, 2011 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2009, 2011, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -39,24 +39,6 @@
namespace mln
{
- // Forward declaration
- namespace util { template <typename Tag, typename V> class object_id; }
-
- namespace convert
- {
-
- namespace over_load
- {
-
- // object_id<Tag,V> -> V.
- template <typename Tag, typename V>
- void from_to_(const util::object_id<Tag,V>& from, V& to_);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
namespace util
{
@@ -109,6 +91,10 @@ namespace mln
bool
operator<(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs);
+ /// \internal Conversion: object_id<Tag,V> -> V.
+ template <typename Tag, typename V>
+ void from_to_(const util::object_id<Tag,V>& from, V& to_);
+
} // end of namespace mln::util
# ifndef MLN_INCLUDE_ONLY
@@ -228,24 +214,16 @@ namespace mln
return lhs.value() < rhs.value();
}
- } // end of namespace mln::util
- namespace convert
- {
+ // Conversions
- namespace over_load
+ template <typename Tag, typename V>
+ void from_to_(const util::object_id<Tag,V>& from, V& to_)
{
+ to_ = from.value();
+ }
- // object_id<Tag,V> -> V.
- template <typename Tag, typename V>
- void from_to_(const util::object_id<Tag,V>& from, V& to_)
- {
- to_ = from.value();
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ } // end of namespace mln::util
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/value/hsl.hh b/milena/mln/value/hsl.hh
index 0901904..6f716f4 100644
--- a/milena/mln/value/hsl.hh
+++ b/milena/mln/value/hsl.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -32,43 +33,23 @@
#include <mln/value/int_u.hh>
#include <mln/algebra/vec.hh>
-// Used in from_to
-#include <mln/fun/v2v/rgb_to_hsl.hh>
-
namespace mln
{
// Forward declarations.
- namespace value
- {
-
- template <typename H, typename S, typename L>
- class hsl_;
-
+ namespace value {
+ namespace qt {
+ struct rgb32;
+ }
+ template <typename H, typename S, typename L> class hsl_;
}
+} // end of namespace mln
- namespace convert
- {
-
- namespace over_load
- {
-
- // rgb to hsl_
- void
- from_to_(const value::rgb<16>& from, value::hsl_<float,float,float>& to);
-
- // rgb to hsl_
- void
- from_to_(const value::rgb<8>& from, value::hsl_<float,float,float>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
+namespace mln
+{
namespace trait
{
@@ -251,6 +232,17 @@ namespace mln
operator==(const hsl_<H,S,L>& lhs, const hsl_<H,S,L>& rhs);
/// \}
+
+ // Conversions
+
+ /// \internal Conversion: hsl -> qt::rgb32.
+ template <typename H, typename S, typename L>
+ void from_to_(const hsl_<H,S,L>& from, qt::rgb32& to);
+
+ /// \internal Conversion: hsl -> rgb8.
+ template <typename H, typename S, typename L>
+ void from_to_(const value::hsl_<H,S,L>&, value::rgb<8>& to);
+
} // end of namespace mln::value
@@ -261,19 +253,31 @@ namespace mln
namespace v2v
{
- template <typename T_hsl>
- struct f_rgb_to_hsl_;
+ template <typename T_rgb>
+ struct f_hsl_to_rgb_;
- typedef f_rgb_to_hsl_<value::hsl_f> f_rgb_to_hsl_f_t;
+ typedef f_hsl_to_rgb_< value::rgb<8> > f_hsl_to_rgb_3x8_t;
+// typedef f_hsl_to_rgb_< value::rgb<16> > f_hsl_to_rgb_3x16_t;
- extern f_rgb_to_hsl_f_t f_rgb_to_hsl_f;
+ extern f_hsl_to_rgb_3x8_t f_hsl_to_rgb_3x8;
+// extern f_hsl_to_rgb_3x16_t f_hsl_to_rgb_3x16;
}
}
+} // end of namespace mln
+
+
+// Used in from_to
+# include <mln/value/rgb.hh>
+# include <mln/fun/v2v/hsl_to_rgb.hh>
+
+
# ifndef MLN_INCLUDE_ONLY
+namespace mln
+{
namespace value
{
@@ -380,32 +384,24 @@ namespace mln
&& lhs.lum() == rhs.lum();
}
- } // end of namespace mln::value
-
- namespace convert
- {
+ // Conversions
- namespace over_load
+ template <typename H, typename S, typename L>
+ void from_to_(const hsl_<H,S,L>& from, qt::rgb32& to)
{
+ rgb<8> v = fun::v2v::f_hsl_to_rgb_3x8(from);
+ to = v.to_equiv();
+ }
- inline
- void
- from_to_(const value::rgb<16>& from, value::hsl_<float,float,float>& to)
- {
- to = fun::v2v::f_rgb_to_hsl_f(from);
- }
-
- inline
- void
- from_to_(const value::rgb<8>& from, value::hsl_<float,float,float>& to)
- {
- to = fun::v2v::f_rgb_to_hsl_f(from);
- }
-
- } // end of namespace mln::convert::over_load
+ template <typename H, typename S, typename L>
+ void
+ from_to_(const hsl_<H,S,L>& from, rgb<8>& to)
+ {
+ to = fun::v2v::f_hsl_to_rgb_3x8(from);
+ }
- } // end of namespace mln::convert
+ } // end of namespace mln::value
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/value/int_u.hh b/milena/mln/value/int_u.hh
index f3786f9..d051c13 100644
--- a/milena/mln/value/int_u.hh
+++ b/milena/mln/value/int_u.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2010, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -31,8 +31,6 @@
///
/// Define a generic class for unsigned integers.
-# include <mln/trait/all.hh> // FIXME!
-
# include <mln/value/ops.hh>
# include <mln/metal/math/pow.hh>
@@ -48,19 +46,21 @@
namespace mln
{
- namespace value
- {
- // Forward declaration.
+ // Forward declarations.
+ namespace value {
+ namespace qt {
+ struct rgb32;
+ }
template <unsigned n> struct int_u;
+ template <unsigned n> struct rgb;
}
namespace literal
{
- // Forward declarations.
struct zero_t;
struct one_t;
}
-
+ // End of forward declarations
namespace trait
{
@@ -110,42 +110,6 @@ namespace mln
} // end of namespace mln::trait
- namespace convert
- {
-
- namespace over_load
- {
-
- // int_u -> unsigned.
- template <unsigned n>
- void
- from_to_(const value::int_u<n>& from, unsigned& to_);
-
-
- // int_u -> bool.
- template <unsigned n>
- void
- from_to_(const value::int_u<n>& from, bool& to_);
-
-
- // int_u -> float.
- template <unsigned n>
- void
- from_to_(const value::int_u<n>& from, float& to_);
-
-
- // int_u -> double.
- template <unsigned n>
- void
- from_to_(const value::int_u<n>& from, double& to_);
-
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
-
namespace value
{
@@ -216,57 +180,41 @@ namespace mln
template <unsigned n>
std::istream& operator>>(std::istream& istr, int_u<n>& i);
- } // end of namespace mln::value
-# ifndef MLN_INCLUDE_ONLY
- namespace convert
- {
+ // Conversions
- namespace over_load
- {
+ /// \internal Conversion: int_u -> unsigned.
+ template <unsigned n>
+ void from_to_(const int_u<n>& from, unsigned& to_);
- // int_u -> unsigned.
- template <unsigned n>
- inline
- void
- from_to_(const value::int_u<n>& from, unsigned& to_)
- {
- to_ = from;
- }
- // int_u -> bool.
- template <unsigned n>
- inline
- void
- from_to_(const value::int_u<n>& from, bool& to_)
- {
- to_ = (from != 0u);
- }
+ /// \internal Conversion: int_u -> bool.
+ template <unsigned n>
+ void from_to_(const int_u<n>& from, bool& to_);
- // int_u -> float.
- template <unsigned n>
- inline
- void
- from_to_(const value::int_u<n>& from, float& to_)
- {
- to_ = static_cast<float>(from);
- }
- // int_u -> double.
- template <unsigned n>
- inline
- void
- from_to_(const value::int_u<n>& from, double& to_)
- {
- to_ = static_cast<double>(from);
- }
+ /// \internal Conversion: int_u -> float.
+ template <unsigned n>
+ void from_to_(const int_u<n>& from, float& to_);
- } // end of namespace mln::convert::over_load
+ /// \internal Conversion: int_u -> double.
+ template <unsigned n>
+ void
+ from_to_(const int_u<n>& from, double& to_);
- } // end of namespace mln::convert
+ /// \internal Conversion: Conversion: int_u -> rgb.
+ template <unsigned m>
+ void from_to_(const int_u<m>& from, qt::rgb32& to);
+ /// \internal Conversion: int_u -> rgb.
+ template <unsigned m>
+ void from_to_(const int_u<m>& from, rgb<m>& to);
+
+ } // end of namespace mln::value
+
+# ifndef MLN_INCLUDE_ONLY
namespace value
{
@@ -367,6 +315,56 @@ namespace mln
return istr >> i.handle_();
}
+
+ // Conversions
+
+ template <unsigned n>
+ inline
+ void
+ from_to_(const int_u<n>& from, unsigned& to_)
+ {
+ to_ = from;
+ }
+
+ template <unsigned n>
+ inline
+ void
+ from_to_(const int_u<n>& from, bool& to_)
+ {
+ to_ = (from != 0u);
+ }
+
+ template <unsigned n>
+ inline
+ void
+ from_to_(const int_u<n>& from, float& to_)
+ {
+ to_ = static_cast<float>(from);
+ }
+
+ template <unsigned n>
+ inline
+ void
+ from_to_(const int_u<n>& from, double& to_)
+ {
+ to_ = static_cast<double>(from);
+ }
+
+ template <unsigned m>
+ void
+ from_to_(const int_u<m>& from, qt::rgb32& to)
+ {
+ mlc_bool(m <= 8)::check();
+ to = qt::rgb32(from, from, from);
+ }
+
+ template <unsigned m>
+ void
+ from_to_(const int_u<m>& from, rgb<m>& to)
+ {
+ to = rgb<m>(from, from, from);
+ }
+
} // end of namespace mln::value
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/value/label.hh b/milena/mln/value/label.hh
index 5c983e5..dd0f924 100644
--- a/milena/mln/value/label.hh
+++ b/milena/mln/value/label.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008, 2009, 2010, 2011 EPITA Research and
+// Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 EPITA Research and
// Development Laboratory (LRDE)
//
// This file is part of Olena.
@@ -91,43 +91,6 @@ namespace mln
} // end of namespace trait
-
- namespace convert
- {
-
- namespace over_load
- {
-
- // int_u -> label.
- template <unsigned n>
- void
- from_to_(const value::int_u<n>& from, value::label<n>& to_);
-
- // label -> int_u.
- template <unsigned n>
- void
- from_to_(const value::label<n>& from, value::int_u<n>& to_);
-
-
- // int_u -> label.
- template <unsigned n, unsigned m>
- void
- from_to_(const value::int_u<n>& from, value::label<m>& to_);
-
- // label -> bool.
- template <unsigned n>
- void
- from_to_(const value::label<n>& from, bool& to_);
-
- // label -> unsigned.
- template <unsigned n>
- void
- from_to_(const value::label<n>& from, unsigned& to_);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
namespace value
{
@@ -197,70 +160,32 @@ namespace mln
std::ostream& operator<<(std::ostream& ostr, const label<n>& l);
- } // end of namespace mln::value
-
-
-# ifndef MLN_INCLUDE_ONLY
-
-
- namespace convert
- {
-
- namespace over_load
- {
-
- // int_u -> label.
- template <unsigned n>
- inline
- void
- from_to_(const value::int_u<n>& from, value::label<n>& to_)
- {
- to_ = from;
- }
+ /// \internal Conversion: int_u -> label.
+ template <unsigned n>
+ void from_to_(const value::int_u<n>& from, value::label<n>& to_);
- // label -> int_u.
- template <unsigned n>
- void
- from_to_(const value::label<n>& from, value::int_u<n>& to_)
- {
- to_ = from;
- }
+ /// \internal Conversion: label -> int_u.
+ template <unsigned n>
+ void from_to_(const value::label<n>& from, value::int_u<n>& to_);
- // int_u<n> -> label<m> with n < m.
- template <unsigned n, unsigned m>
- inline
- void
- from_to_(const value::int_u<n>& from, value::label<m>& to_)
- {
- enum { valid = n < m };
- metal::bool_<valid>::check();
- to_ = from;
- }
+ /// \internal Conversion: int_u -> label.
+ template <unsigned n, unsigned m>
+ void from_to_(const value::int_u<n>& from, value::label<m>& to_);
- // int_u<n> -> bool
- template <unsigned n>
- inline
- void
- from_to_(const value::label<n>& from, bool& to_)
- {
- to_ = (from != 0u);
- }
+ /// \internal Conversion: label -> bool.
+ template <unsigned n>
+ void from_to_(const value::label<n>& from, bool& to_);
- // int_u<n> -> unsigned
- template <unsigned n>
- inline
- void
- from_to_(const value::label<n>& from, unsigned& to_)
- {
- to_ = from;
- }
+ /// \internal Conversion: label -> unsigned.
+ template <unsigned n>
+ void from_to_(const value::label<n>& from, unsigned& to_);
- } // end of namespace mln::convert::over_load
+ } // end of namespace mln::value
- } // end of namespace mln::convert
+# ifndef MLN_INCLUDE_ONLY
namespace value
@@ -355,6 +280,47 @@ namespace mln
return ostr << debug::format(i.to_equiv());
}
+ template <unsigned n>
+ inline
+ void
+ from_to_(const value::int_u<n>& from, value::label<n>& to_)
+ {
+ to_ = from;
+ }
+
+ template <unsigned n>
+ void
+ from_to_(const value::label<n>& from, value::int_u<n>& to_)
+ {
+ to_ = from;
+ }
+
+ template <unsigned n, unsigned m>
+ inline
+ void
+ from_to_(const value::int_u<n>& from, value::label<m>& to_)
+ {
+ enum { valid = n < m };
+ metal::bool_<valid>::check();
+ to_ = from;
+ }
+
+ template <unsigned n>
+ inline
+ void
+ from_to_(const value::label<n>& from, bool& to_)
+ {
+ to_ = (from != 0u);
+ }
+
+ template <unsigned n>
+ inline
+ void
+ from_to_(const value::label<n>& from, unsigned& to_)
+ {
+ to_ = from;
+ }
+
} // end of namespace mln::value
diff --git a/milena/mln/value/qt/rgb32.hh b/milena/mln/value/qt/rgb32.hh
index 511d6a7..67bf1eb 100644
--- a/milena/mln/value/qt/rgb32.hh
+++ b/milena/mln/value/qt/rgb32.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2010, 2012 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -75,34 +76,6 @@ namespace mln
/// \}
}
-
- namespace convert
- {
-
- namespace over_load
- {
-
- // int_u -> rgb.
- template <unsigned m>
- void from_to_(const value::int_u<m>& from, value::qt::rgb32& to);
-
- // hsl -> rgb32.
- template <typename H, typename S, typename L>
- void from_to_(const value::hsl_<H,S,L>&, value::qt::rgb32& to);
-
- // rgb32 -> bool.
- void from_to_(const value::qt::rgb32& from, bool& to);
-
-
- // bool -> rgb32.
- void from_to_(const bool& from, value::qt::rgb32& to);
-
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
namespace trait
{
template <>
@@ -350,14 +323,18 @@ namespace mln
/// \}
+ /// \internal Conversion: Conversion: #value::qt::rgb32 -> bool.
+ void from_to_(const rgb32& from, bool& to);
+
+ /// \internal Conversion: bool -> #value::qt::rgb32.
+ void from_to_(const bool& from, value::qt::rgb32& to);
+
} // end of namespace mln::value::qt
} // end of namespace mln::value
} // end of namespace mln
-
-
# ifndef MLN_INCLUDE_ONLY
namespace mln
@@ -752,45 +729,15 @@ namespace mln
return istr >> c.red() >> c.green() >> c.blue();
}
- } // end of namespace mln::value::qt
-
- } // end of namespace mln::value
-
-
- namespace convert
- {
-
- namespace over_load
- {
- // int_u -> qt::rgb32
- template <unsigned m>
- void
- from_to_(const value::int_u<m>& from, value::qt::rgb32& to)
- {
- mlc_bool(m <= 8)::check();
- to = value::qt::rgb32(from, from, from);
- }
+ // Conversions
-
- // hsl -> rgb8.
- template <typename H, typename S, typename L>
- void from_to_(const value::hsl_<H,S,L>& from, value::qt::rgb32& to)
- {
- value::rgb8 v = fun::v2v::f_hsl_to_rgb_3x8(from);
- to = v.to_equiv();
- }
-
-
- // qt::rgb32 -> bool
inline
- void from_to_(const value::qt::rgb32& from, bool& to)
+ void from_to_(const rgb32& from, bool& to)
{
to = ((from == literal::black) ? false : true);
}
-
- // bool -> qt::rgb32
inline
void from_to_(const bool& from, value::qt::rgb32& to)
{
@@ -800,10 +747,9 @@ namespace mln
to = literal::black;
}
+ } // end of namespace mln::value::qt
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ } // end of namespace mln::value
} // end of namespace mln
diff --git a/milena/mln/value/rgb.hh b/milena/mln/value/rgb.hh
index c9d2f53..1c812d7 100644
--- a/milena/mln/value/rgb.hh
+++ b/milena/mln/value/rgb.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2010, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -30,7 +30,6 @@
# include <mln/value/ops.hh>
-# include <mln/fun/v2v/hsl_to_rgb.hh>
# include <mln/value/concept/vectorial.hh>
# include <mln/value/int_u.hh>
# include <mln/algebra/vec.hh>
@@ -46,28 +45,18 @@ namespace mln
{
// Forward declaration.
- namespace value { template <unsigned n> struct rgb; }
+ namespace value {
+ template <unsigned n> struct rgb;
+ template <typename H, typename S, typename L> class hsl_;
-
-
- namespace fun
- {
-
- namespace v2v
- {
-
- template <typename T_rgb>
- struct f_hsl_to_rgb_;
-
- typedef f_hsl_to_rgb_< value::rgb<8> > f_hsl_to_rgb_3x8_t;
-// typedef f_hsl_to_rgb_< value::rgb<16> > f_hsl_to_rgb_3x16_t;
-
- extern f_hsl_to_rgb_3x8_t f_hsl_to_rgb_3x8;
-// extern f_hsl_to_rgb_3x16_t f_hsl_to_rgb_3x16;
-
- }
-
- }
+ }
+ namespace fun {
+ namespace v2v {
+ template <typename T_hsl> struct f_rgb_to_hsl_;
+ typedef f_rgb_to_hsl_<value::hsl_<float, float, float> > f_rgb_to_hsl_f_t;
+ extern f_rgb_to_hsl_f_t f_rgb_to_hsl_f;
+ }
+ }
namespace literal
@@ -104,42 +93,6 @@ namespace mln
template <typename H, typename S, typename L> class hsl_;
}
-
- namespace convert
- {
-
- namespace over_load
- {
-
- // algebra::vec -> rgb.
- template <typename T, unsigned m>
- void from_to_(const algebra::vec<3,T>& from, value::rgb<m>& to_);
-
- // bool -> rgb.
- template <unsigned m>
- void from_to_(bool from, value::rgb<m>& to);
-
- // int_u -> rgb.
- template <unsigned m>
- void from_to_(const value::int_u<m>& from, value::rgb<m>& to);
-
- // hsl -> rgb8.
- template <typename H, typename S, typename L>
- void from_to_(const value::hsl_<H,S,L>&, value::rgb<8>& to);
-
-// // hsl -> rgb16.
-// template <typename H, typename S, typename L>
-// void from_to_(const value::hsl_<H,S,L>&, value::rgb<16>& to);
-
- // rgb -> bool.
- template <unsigned m>
- void from_to_(const value::rgb<m>& from, bool& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
namespace trait
{
template < unsigned n >
@@ -395,14 +348,38 @@ namespace mln
operator/(const rgb<n>& lhs, const mln::value::scalar_<S>& s);
/// \}
+ } // end of namespace mln::value
+
+
+ // Conversions
+
+ namespace value
+ {
+
+ /// \internal Conversion: rgb -> bool.
+ template <unsigned m>
+ void from_to_(const value::rgb<m>& from, bool& to);
+
+ /// \internal Conversion: rgb to hsl_
+ void
+ from_to_(const rgb<16>& from, hsl_<float,float,float>& to);
+
+ /// \internal Conversion: rgb to hsl_
+ void
+ from_to_(const rgb<8>& from, hsl_<float,float,float>& to);
+
+ /// \internal Conversion: bool -> rgb.
+ template <unsigned m>
+ void from_to_(bool from, value::rgb<m>& to);
} // end of namespace mln::value
} // end of namespace mln
-// // Needed by from_to_.
-// # include <mln/fun/v2v/rgb_to_hsl.hh>
+// Used in from_to
+# include <mln/value/hsl.hh>
+# include <mln/fun/v2v/rgb_to_hsl.hh>
# ifndef MLN_INCLUDE_ONLY
@@ -755,75 +732,46 @@ namespace mln
return istr >> c.red() >> c.green() >> c.blue();
}
- } // end of namespace mln::value
+ // Conversions
- namespace convert
- {
-
- namespace over_load
+ template <unsigned m>
+ void
+ from_to_(const rgb<m>& from, bool& to)
{
+ to = (from.red() != 0 && from.green() != 0 && from.blue() != 0);
+ }
- // algebra::vec -> rgb.
- template <typename T, unsigned m>
- inline
- void
- from_to_(const algebra::vec<3,T>& from, value::rgb<m>& to)
- {
- algebra::vec<3, unsigned> tmp;
- for (unsigned i = 0; i < 3; ++i)
- tmp[i] = static_cast<unsigned>(from[i]); // FIXME: Use from_to_ instead of cast.
-
- to = value::rgb<m>(tmp);
- }
-
- // bool -> rgb.
- template <unsigned m>
- void
- from_to_(bool from, value::rgb<m>& to)
- {
- static literal::white_t* white_ = 0;
- static literal::black_t* black_ = 0;
- // We do not use literal::white (the object) so that we
- // do not introduce any coupling with the file where
- // literals are defined.
- if (from)
- to = *white_;
- else
- to = *black_;
- }
-
- template <unsigned m>
- void
- from_to_(const value::int_u<m>& from, value::rgb<m>& to)
- {
- to = value::rgb<m>(from, from, from);
- }
+ inline
+ void
+ from_to_(const rgb<16>& from, hsl_<float,float,float>& to)
+ {
+ to = fun::v2v::f_rgb_to_hsl_f(from);
+ }
- template <typename H, typename S, typename L>
- void
- from_to_(const value::hsl_<H,S,L>& from, value::rgb<8>& to)
- {
- to = fun::v2v::f_hsl_to_rgb_3x8(from);
- }
-
-// template <typename H, typename S, typename L>
-// void
-// from_to_(const value::hsl_<H,S,L>& from, value::rgb<16>& to)
-// {
-// to = fun::v2v::f_hsl_to_rgb_3x16(from);
-// }
-
- template <unsigned m>
- void
- from_to_(const value::rgb<m>& from, bool& to)
- {
- to = (from.red() != 0 && from.green() != 0 && from.blue() != 0);
- }
+ inline
+ void
+ from_to_(const rgb<8>& from, hsl_<float,float,float>& to)
+ {
+ to = fun::v2v::f_rgb_to_hsl_f(from);
+ }
- } // end of namespace mln::convert::over_load
+ template <unsigned m>
+ void
+ from_to_(bool from, mln::value::rgb<m>& to)
+ {
+ static mln::literal::white_t* white_ = 0;
+ static mln::literal::black_t* black_ = 0;
+ // We do not use literal::white (the object) so that we
+ // do not introduce any coupling with the file where
+ // literals are defined.
+ if (from)
+ to = *white_;
+ else
+ to = *black_;
+ }
- } // end of namespace mln::convert
+ } // end of namespace mln::value
} // end of namespace mln
diff --git a/milena/mln/win/multiple.hh b/milena/mln/win/multiple.hh
index 18b65c8..869ad7c 100644
--- a/milena/mln/win/multiple.hh
+++ b/milena/mln/win/multiple.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -32,7 +33,7 @@
///
/// \todo Implementation of the bkd_qiter (see FIXME).
-# include <mln/core/internal/window_base.hh>
+# include <mln/core/window.hh>
# include <mln/core/internal/site_relative_iterator_base.hh>
# include <mln/util/array.hh>
diff --git a/milena/mln/win/multiple_size.hh b/milena/mln/win/multiple_size.hh
index 765e83d..43861f3 100644
--- a/milena/mln/win/multiple_size.hh
+++ b/milena/mln/win/multiple_size.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2011, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -49,6 +49,7 @@ namespace mln
template <unsigned n, typename W, typename F> class multiple_size;
template <unsigned n, typename W, typename F> class multiple_size_qiter;
}
+ template <typename D> class window;
diff --git a/milena/tests/accu/site_set/rectangularity.cc b/milena/tests/accu/site_set/rectangularity.cc
index 8919494..7adbb60 100644
--- a/milena/tests/accu/site_set/rectangularity.cc
+++ b/milena/tests/accu/site_set/rectangularity.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2012 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -61,5 +62,6 @@ int main()
{
accu::site_set::rectangularity<point2d> a;
accu::site_set::rectangularity<point2d> b = exact(a);
+ (void) b;
}
}
diff --git a/milena/tests/core/other/graph_elt_neighborhood.cc b/milena/tests/core/other/graph_elt_neighborhood.cc
index 7206d92..356fc4a 100644
--- a/milena/tests/core/other/graph_elt_neighborhood.cc
+++ b/milena/tests/core/other/graph_elt_neighborhood.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -31,6 +31,7 @@
#include <mln/core/alias/point2d.hh>
#include <mln/core/site_set/p_vertices.hh>
+#include <mln/fun/i2v/array.hh>
#include <mln/util/graph.hh>
#include <mln/core/image/graph_elt_neighborhood.hh>
diff --git a/milena/tests/core/other/graph_elt_window.cc b/milena/tests/core/other/graph_elt_window.cc
index 6e56a89..15a74d3 100644
--- a/milena/tests/core/other/graph_elt_window.cc
+++ b/milena/tests/core/other/graph_elt_window.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -30,7 +31,7 @@
#include <mln/core/alias/point2d.hh>
#include <mln/core/image/graph_elt_window.hh>
#include <mln/core/site_set/p_vertices.hh>
-
+#include <mln/fun/i2v/array.hh>
#include <mln/util/graph.hh>
unsigned fwd_neighb[] = { 0, 2, 3 };
diff --git a/milena/tests/core/other/point_set_compatibility.cc b/milena/tests/core/other/point_set_compatibility.cc
index 095ca46..ac73ab6 100644
--- a/milena/tests/core/other/point_set_compatibility.cc
+++ b/milena/tests/core/other/point_set_compatibility.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -25,6 +26,7 @@
#include <mln/core/alias/point2d.hh>
+#include <mln/fun/i2v/array.hh>
#include <mln/core/site_set/p_array.hh>
#include <mln/core/site_set/p_set.hh>
#include <mln/core/site_set/p_vertices.hh>
diff --git a/milena/tests/draw/graph.cc b/milena/tests/draw/graph.cc
index c15ab57..845d318 100644
--- a/milena/tests/draw/graph.cc
+++ b/milena/tests/draw/graph.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -26,6 +27,7 @@
#include <vector>
#include <utility>
+#include <mln/fun/i2v/array.hh>
#include <mln/core/image/image2d.hh>
#include <mln/core/alias/point2d.hh>
#include <mln/debug/println.hh>
--
1.7.2.5
1
0
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch gimpplugin has been created
at 6c0b45ce7368a98b667f55af8c63c750931b822c (commit)
- Log -----------------------------------------------------------------
6c0b45c backup
069c248 backup basic plugin
bab624b New GIMP image wrapper.
ad921ba First attempts for gimp plugin
9177e80 Move Otsu's threshold computation in a separate routine.
2fb4b79 Add Niblack's binarization algorithm.
-----------------------------------------------------------------------
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch skewness has been created
at d1d6d8452e7be68f882d711281d77fbb8d6b8765 (commit)
- Log -----------------------------------------------------------------
d1d6d84 scribo/binarization/all.hh: Add more includes.
22aace9 scribo/binarization/otsu.hh: Fix namespace ambiguities.
c2dc161 mln/fun/x2x/rotation.hh: Remove alpha and axis attributes.
d50796a mln/registration/icp.hh: Cleanup some debug.
1ff7fba mln/geom/rotate.hh: Add support for n-D images.
87c1ef5 mln/algebra/mat.hh: Add implementations for 4x4 matrices.
7fb7ed4 New routines to get bottom left and top right sites.
8e2e7f1 Improve conversion between algebra::h_mat and algebra::quat.
68ec926 Rely on Argument-Dependent Lookup (ADL) in from_to_ overloads.
bd0b64a demos/graph/region_adjacency_graph.cc: Add program arguments.
1a12c68 Small fixes in Scribo.
590eeaa Add a better support for different k values in Sauvola Multiscale.
9bf1541 Add a default verbose mode in debug::logger.
73d0b5d Make use of logger features.
2f3154f Fix arguments.
ab0cdca Fix call to sauvola_ms.
948844a Make use of new logger features.
f9ea569 Cleanup Kim's binarization.
00db91c Make integral browsing canvas robust to large windows.
89004a2 Backup
17a98b3 bACKUP
146727e Backup
3987224 Backup: cleanup Sauvola's debug.
258f415 BACKUP
5ef0358 Add Wolf's binarization algorithm.
4aaafbb backup
9a341b3 backup new area thresholds.
2867bcb Improve debug output for sauvola_ms.
4fae4c0 Use C8 neighborhood for labeling in sauvola_ms.
4ad97fb Fix warning in Otsu related files.
8766c50 Fix and improve sauvola_ms_debug
ef55c70 Fix invalid line offset due to input image size.
2b17781 Fix binarization tests.
d5ba09d Revamp *_threshold functions.
f853081 Refactoring of local threshold binarization algorithms
d303f0b Backup
b781ec6 Very fast classic sauvola.
3ca5ebf Working optimized sauvola classic
b98b0d1 backup
effe50e Backup
574c613 backup
07c26a2 BACKUP - fixed by theo
bd5b77d backup - fast multiscale binarization + skewness/revert on input image.
e69e187 Working sauvola_ms_rv
62c6860 BACKUP
d60f027 Backup
3a65b8d Improve option parser.
9aec998 Add Readme files about contests.
8c4e2dd Fix compilation in Scribo.
e1b3bd7 Rely on Argument-Dependent Lookup (ADL) in from_to_ overloads.
183d831 scribo/debug/logger.hh: Improve log system.
9846847 mln/registration/icp.hh: Add a missing initialization.
13097b1 mln/io/magick/save.hh: Add generic and fast implementations
b7cf120 mln/draw/box_plain.hh: Fix unused variable warning.
6bc3a11 Remove useless targets in scribo/src/binarization.
03eaf1c Cleanup text_in_picture_dual.
962ceb9 Make unskew an option in content_in_doc.
-----------------------------------------------------------------------
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch cleanup has been updated
via cfc65f324dbe578cea17162f954e90e696f260c3 (commit)
from b2369d6d4c5f48d3b44808b8be120cc380363774 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
cfc65f3 Ensure `bootstrap -r' regenerates all files.
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 7 +++++++
bootstrap | 23 +++++++++++++++++------
2 files changed, 24 insertions(+), 6 deletions(-)
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch apps-morphers has been updated
via b4ca8d4c88354e1577271f6103b13e1ab1f285c6 (commit)
via 08bc024b524e8e1c89b9baa4070eb562715f0b03 (commit)
via 72ee021ea66c1cb31d559c7803596199c11dea02 (commit)
via 3864857f85d254caf232b2a9fb4c547d7bf8f11a (commit)
via f8e2ffe537bc8dc29cc432ef21462dee8046d0dc (commit)
via bc142a16b5a6963f43b63f286e4f201a69ad9211 (commit)
from 3363574ac18e8b13b42f21d354a1901a511c513d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
b4ca8d4 Improve the (movie) output of apps/morphers/iz.
08bc024 Use the lazy recorder morpher in apps/morphers/iz.
72ee021 Add rules to build and run apps/morphers/iz.
3864857 New example demonstrating the use of influence zones.
f8e2ffe New ``lazy'' recorder morpher in apps/morpher.
bc142a1 Render the recorder morpher more generic.
-----------------------------------------------------------------------
Summary of changes:
milena/ChangeLog | 66 ++++++++
milena/apps/morphers/Makefile.am | 36 ++++-
milena/apps/morphers/iz.cc | 173 ++++++++++++++++++++
milena/apps/morphers/iz_input.pbm | Bin 0 -> 21890 bytes
.../morphers/{recorder.cc => lazy_recorder.cc} | 11 +-
.../morphers/{recorder.hh => lazy_recorder.hh} | 79 ++++++---
milena/apps/morphers/recorder.hh | 11 +-
7 files changed, 337 insertions(+), 39 deletions(-)
create mode 100644 milena/apps/morphers/iz.cc
create mode 100644 milena/apps/morphers/iz_input.pbm
copy milena/apps/morphers/{recorder.cc => lazy_recorder.cc} (88%)
copy milena/apps/morphers/{recorder.hh => lazy_recorder.hh} (64%)
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0
olena-2.0-22-gb4ca8d4 Improve the (movie) output of apps/morphers/iz.
by Roland Levillain 21 Jun '12
by Roland Levillain 21 Jun '12
21 Jun '12
* apps/morphers/iz.cc (save_colorized): Skip consecutive identical
frames.
Swap the frame reconstruction and write operations, so that the
last frame is eventually saved.
* apps/morphers/Makefile.am (tmp_iz.avi): Use a speedup of 50
instead of 10.
---
milena/ChangeLog | 11 +++++++++++
milena/apps/morphers/Makefile.am | 2 +-
milena/apps/morphers/iz.cc | 21 +++++++++++++--------
3 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index a8c9cad..fdb278b 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,16 @@
2012-06-21 Roland Levillain <roland(a)lrde.epita.fr>
+ Improve the (movie) output of apps/morphers/iz.
+
+ * apps/morphers/iz.cc (save_colorized): Skip consecutive identical
+ frames.
+ Swap the frame reconstruction and write operations, so that the
+ last frame is eventually saved.
+ * apps/morphers/Makefile.am (tmp_iz.avi): Use a speedup of 50
+ instead of 10.
+
+2012-06-21 Roland Levillain <roland(a)lrde.epita.fr>
+
Use the lazy recorder morpher in apps/morphers/iz.
* apps/morphers/iz.cc (main): Here.
diff --git a/milena/apps/morphers/Makefile.am b/milena/apps/morphers/Makefile.am
index 829ba8a..309e089 100644
--- a/milena/apps/morphers/Makefile.am
+++ b/milena/apps/morphers/Makefile.am
@@ -52,7 +52,7 @@ iz_output.ppm: iz$(EXEEXT) iz_input.pbm
./$< $(srcdir)/iz_input.pbm $@
# Likewise, the dependency of this target is a (wrong) shortcut.
tmp_iz.avi: iz_output.ppm
- mencoder "mf://tmp_iz*.png" -o tmp_iz.avi -ovc lavc -lavcopts vcodec=mjpeg -speed 10
+ mencoder "mf://tmp_iz*.png" -o tmp_iz.avi -ovc lavc -lavcopts vcodec=mjpeg -speed 50
endif HAVE_MAGICKXX
MOSTLYCLEANFILES = \
diff --git a/milena/apps/morphers/iz.cc b/milena/apps/morphers/iz.cc
index 729b2f9..4216dc5 100644
--- a/milena/apps/morphers/iz.cc
+++ b/milena/apps/morphers/iz.cc
@@ -43,19 +43,24 @@ save_colorized(const mln::decorated_image< I, lazy_recorder<I> >& rec,
const std::string& prefix)
{
mln_concrete(I) frame = mln::duplicate(rec.decoration().initial);
+ std::stringstream s;
+ s << std::setfill ('0') << std::setw (6) << 0;
+ mln::io::magick::save(mln::labeling::colorize(mln::value::rgb8(), frame),
+ prefix + s.str() + ".png");
for (size_t i = 0; i < rec.decoration().sequence.size(); ++i)
{
+ // Next change (`frame(p)' is assigned the value `v' in the next
+ // frame).
+ mln_psite(I) p = rec.decoration().sequence[i].first;
+ mln_value(I) v = rec.decoration().sequence[i].second;
+ // Skip consecutive identical frames.
+ if (frame(p) == v)
+ continue;
+ frame(p) = v;
std::stringstream s;
- s << std::setfill ('0') << std::setw (6) << i;
+ s << std::setfill ('0') << std::setw (6) << i + 1;
mln::io::magick::save(mln::labeling::colorize(mln::value::rgb8(), frame),
prefix + s.str() + ".png");
- // Apply the I-th change to the next frame.
- //
- // Changes are applied after the I-th image has been written,
- // to mimic the behavior of the original recorder morpher (see
- // recorder.hh).
- frame(rec.decoration().sequence[i].first) =
- rec.decoration().sequence[i].second;
}
}
--
1.7.2.5
1
0
olena-2.0-21-g08bc024 Use the lazy recorder morpher in apps/morphers/iz.
by Roland Levillain 21 Jun '12
by Roland Levillain 21 Jun '12
21 Jun '12
* apps/morphers/iz.cc (main): Here.
Save the sequence of recorder images as PNG images using Magick++.
(save_colorized): New function.
* apps/morphers/Makefile.am
(noinst_PROGRAMS, iz_SOURCES) [HAVE_MAGICKXX]: Build `iz' only if
Magick++ is available.
(iz_output.ppm) [HAVE_MAGICKXX]: Likewise.
(iz_CPPFLAGS, iz_LDFLAGS) [HAVE_MAGICKXX]: New.
(tmp_iz.avi) [HAVE_MAGICKXX]: New target.
(MOSTLYCLEANFILES): Add tmp_iz??????.png.
---
milena/ChangeLog | 15 ++++++++++++
milena/apps/morphers/Makefile.am | 16 ++++++++++--
milena/apps/morphers/iz.cc | 47 ++++++++++++++++++++++++++++++++++---
3 files changed, 71 insertions(+), 7 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index c5eb04c..a8c9cad 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,18 @@
+2012-06-21 Roland Levillain <roland(a)lrde.epita.fr>
+
+ Use the lazy recorder morpher in apps/morphers/iz.
+
+ * apps/morphers/iz.cc (main): Here.
+ Save the sequence of recorder images as PNG images using Magick++.
+ (save_colorized): New function.
+ * apps/morphers/Makefile.am
+ (noinst_PROGRAMS, iz_SOURCES) [HAVE_MAGICKXX]: Build `iz' only if
+ Magick++ is available.
+ (iz_output.ppm) [HAVE_MAGICKXX]: Likewise.
+ (iz_CPPFLAGS, iz_LDFLAGS) [HAVE_MAGICKXX]: New.
+ (tmp_iz.avi) [HAVE_MAGICKXX]: New target.
+ (MOSTLYCLEANFILES): Add tmp_iz??????.png.
+
2012-06-20 Roland Levillain <roland(a)lrde.epita.fr>
Add rules to build and run apps/morphers/iz.
diff --git a/milena/apps/morphers/Makefile.am b/milena/apps/morphers/Makefile.am
index fd5edda..829ba8a 100644
--- a/milena/apps/morphers/Makefile.am
+++ b/milena/apps/morphers/Makefile.am
@@ -28,8 +28,7 @@ noinst_PROGRAMS = \
recorder-bft \
recorder-wst \
mask+recorder \
- lazy_recorder \
- iz
+ lazy_recorder
noinst_HEADERS = recorder.hh lazy_recorder.hh
@@ -39,12 +38,22 @@ recorder_bft_SOURCES = recorder-bft.cc image2d-skel.hh
recorder_wst_SOURCES = recorder-wst.cc
mask_recorder_SOURCES = mask+recorder.cc
lazy_recorder_SOURCES = lazy_recorder.cc
-iz_SOURCES = iz.cc
EXTRA_DIST = iz_input.pbm
+
+if HAVE_MAGICKXX
+noinst_PROGRAMS += iz
+iz_SOURCES = iz.cc
+iz_CPPFLAGS = $(AM_CPPFLAGS) $(MAGICKXX_CPPFLAGS)
+iz_LDFLAGS = $(AM_LDFLAGS) $(MAGICKXX_LDFLAGS)
+
# This target is phony: `iz' never writes `iz_output.ppm' actually.
iz_output.ppm: iz$(EXEEXT) iz_input.pbm
./$< $(srcdir)/iz_input.pbm $@
+# Likewise, the dependency of this target is a (wrong) shortcut.
+tmp_iz.avi: iz_output.ppm
+ mencoder "mf://tmp_iz*.png" -o tmp_iz.avi -ovc lavc -lavcopts vcodec=mjpeg -speed 10
+endif HAVE_MAGICKXX
MOSTLYCLEANFILES = \
lena-mask-channel.ppm \
@@ -59,6 +68,7 @@ MOSTLYCLEANFILES = \
tmp_ws.ppm \
tmp_lab.pgm \
tmp_iz.pgm \
+ tmp_iz??????.png \
tmp_iz.ppm \
tmp_iz_input.ppm
diff --git a/milena/apps/morphers/iz.cc b/milena/apps/morphers/iz.cc
index d02fd40..729b2f9 100644
--- a/milena/apps/morphers/iz.cc
+++ b/milena/apps/morphers/iz.cc
@@ -24,14 +24,40 @@
#include <mln/make/w_window2d.hh>
+#include "apps/morphers/lazy_recorder.hh"
+
#include <mln/io/pbm/load.hh>
#include <mln/io/pbm/save.hh>
#include <mln/io/pgm/save.hh>
#include <mln/io/ppm/save.hh>
+#include <mln/io/magick/save.hh>
#include <mln/literal/colors.hh>
+// Save as PNG directly, instead of using PPM as intermediate format.
+template <typename I>
+inline
+void
+save_colorized(const mln::decorated_image< I, lazy_recorder<I> >& rec,
+ const std::string& prefix)
+{
+ mln_concrete(I) frame = mln::duplicate(rec.decoration().initial);
+ for (size_t i = 0; i < rec.decoration().sequence.size(); ++i)
+ {
+ std::stringstream s;
+ s << std::setfill ('0') << std::setw (6) << i;
+ mln::io::magick::save(mln::labeling::colorize(mln::value::rgb8(), frame),
+ prefix + s.str() + ".png");
+ // Apply the I-th change to the next frame.
+ //
+ // Changes are applied after the I-th image has been written,
+ // to mimic the behavior of the original recorder morpher (see
+ // recorder.hh).
+ frame(rec.decoration().sequence[i].first) =
+ rec.decoration().sequence[i].second;
+ }
+}
void usage(char* argv[])
@@ -43,6 +69,9 @@ void usage(char* argv[])
int main(int argc, char* argv[])
{
+ // Initialize Magick++.
+ Magick::InitializeMagick(*argv);
+
using namespace mln;
using value::int_u8;
@@ -112,15 +141,25 @@ int main(int argc, char* argv[])
0, c4(), nlabels),
lab);
+ decorated_image< image2d<unsigned>,
+ lazy_recorder< image2d<unsigned> > > rec_lab =
+ lazy_record(lab);
+
io::pgm::save(data::saturate(value::int_u8(), lab), "tmp_lab.pgm");
- data::paste(transform::influence_zone_front(lab | (pw::value(ws) == pw::cst(0)),
- c8(),
- make::w_window2d(ww)),
- lab);
+ image_if< decorated_image< image2d<unsigned int>,
+ lazy_recorder< image2d<unsigned int> > >,
+ fun::eq_v2b_expr_< pw::value_< image2d<unsigned int> >,
+ pw::cst_<int> > > rec_iz =
+ transform::influence_zone_front(rec_lab | (pw::value(ws) == pw::cst(0)),
+ c8(),
+ make::w_window2d(ww));
+ data::paste(rec_iz, lab);
io::pgm::save(data::saturate(value::int_u8(), lab), "tmp_iz.pgm");
+ save_colorized(rec_iz.unmorph_(), "tmp_iz");
+
image2d<value::rgb8> output = labeling::colorize(value::rgb8(), lab);
io::ppm::save(output, "tmp_iz.ppm");
--
1.7.2.5
1
0
21 Jun '12
* apps/morphers/lazy_recorder.hh: New.
* apps/morphers/lazy_recorder.cc: New test.
* apps/morphers/Makefile.am (noinst_HEADERS):
Add lazy_recorder.hh.
(noinst_PROGRAMS): Add lazy_recorder.
(lazy_recorder_SOURCES): New.
(MOSTLYCLEANFILES): Add lena-fill-lazy??????.ppm.
---
milena/ChangeLog | 12 +++
milena/apps/morphers/Makefile.am | 9 ++-
.../morphers/{recorder.cc => lazy_recorder.cc} | 11 ++--
.../morphers/{recorder.hh => lazy_recorder.hh} | 76 +++++++++++++-------
4 files changed, 74 insertions(+), 34 deletions(-)
copy milena/apps/morphers/{recorder.cc => lazy_recorder.cc} (88%)
copy milena/apps/morphers/{recorder.hh => lazy_recorder.hh} (66%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 6f9f9f0..920aac7 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,17 @@
2012-06-21 Roland Levillain <roland(a)lrde.epita.fr>
+ New ``lazy'' recorder morpher in apps/morpher.
+
+ * apps/morphers/lazy_recorder.hh: New.
+ * apps/morphers/lazy_recorder.cc: New test.
+ * apps/morphers/Makefile.am (noinst_HEADERS):
+ Add lazy_recorder.hh.
+ (noinst_PROGRAMS): Add lazy_recorder.
+ (lazy_recorder_SOURCES): New.
+ (MOSTLYCLEANFILES): Add lena-fill-lazy??????.ppm.
+
+2012-06-21 Roland Levillain <roland(a)lrde.epita.fr>
+
Render the recorder morpher more generic.
* apps/morphers/recorder.hh (recorder<I>::sequence): Store a
diff --git a/milena/apps/morphers/Makefile.am b/milena/apps/morphers/Makefile.am
index 8633933..5dbcc7e 100644
--- a/milena/apps/morphers/Makefile.am
+++ b/milena/apps/morphers/Makefile.am
@@ -1,4 +1,4 @@
-# Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE).
+# Copyright (C) 2011, 2012 EPITA Research and Development Laboratory (LRDE).
#
# This file is part of Olena.
#
@@ -27,19 +27,22 @@ noinst_PROGRAMS = \
recorder \
recorder-bft \
recorder-wst \
- mask+recorder
+ mask+recorder \
+ lazy_recorder
-noinst_HEADERS = recorder.hh
+noinst_HEADERS = recorder.hh lazy_recorder.hh
mask_channel_SOURCES = mask+channel.cc
recorder_SOURCES = recorder.cc
recorder_bft_SOURCES = recorder-bft.cc image2d-skel.hh
recorder_wst_SOURCES = recorder-wst.cc
mask_recorder_SOURCES = mask+recorder.cc
+lazy_recorder_SOURCES = lazy_recorder.cc
MOSTLYCLEANFILES = \
lena-mask-channel.ppm \
lena-fill??????.ppm \
+ lena-fill-lazy??????.ppm \
lena-bft??????.pbm \
lena-wst??????.ppm \
lena-roi-fill??????.ppm
diff --git a/milena/apps/morphers/recorder.cc b/milena/apps/morphers/lazy_recorder.cc
similarity index 88%
copy from milena/apps/morphers/recorder.cc
copy to milena/apps/morphers/lazy_recorder.cc
index 86af667..f3c770e 100644
--- a/milena/apps/morphers/recorder.cc
+++ b/milena/apps/morphers/lazy_recorder.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2011, 2012 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -24,7 +24,8 @@
// executable file might be covered by the GNU General Public License.
/// \file
-/// \brief Exercise a morpher recording every change in the morphed image.
+/// \brief Exercise a morpher recording every change in the morphed
+/// image in a lazy fashion.
///
/// To produce an AVI movie from the `lena-fill*.ppm' files, use:
///
@@ -43,7 +44,7 @@
#include <mln/io/ppm/load.hh>
-#include "apps/morphers/recorder.hh"
+#include "apps/morphers/lazy_recorder.hh"
#include "apps/data.hh"
@@ -55,7 +56,7 @@ int main()
typedef image2d<rgb8> I;
I lena = io::ppm::load<rgb8>(MLN_IMG_DIR "/tiny.ppm");
- decorated_image< I, recorder<I> > lena_rec = record(lena);
+ decorated_image< I, lazy_recorder<I> > lena_rec = lazy_record(lena);
data::fill(lena_rec, literal::green);
- ppm::save(lena_rec, "lena-fill");
+ ppm::save(lena_rec, "lena-fill-lazy");
}
diff --git a/milena/apps/morphers/recorder.hh b/milena/apps/morphers/lazy_recorder.hh
similarity index 66%
copy from milena/apps/morphers/recorder.hh
copy to milena/apps/morphers/lazy_recorder.hh
index a2222a3..a9e0f08 100644
--- a/milena/apps/morphers/recorder.hh
+++ b/milena/apps/morphers/lazy_recorder.hh
@@ -23,12 +23,16 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef APPS_MORPHERS_RECORDER_HH
-# define APPS_MORPHERS_RECORDER_HH
+#ifndef APPS_MORPHERS_LAZY_RECORDER_HH
+# define APPS_MORPHERS_LAZY_RECORDER_HH
/// \file
-/// \brief Morpher recording every change in the morphed image,
-/// storing snapshots of the morphed image at each write operation.
+/// \brief Morpher recording every change in the morphed image in a
+/// lazy fashion, storing each write operation (i.e., the (site,
+/// value) pairs).
+///
+/// The data recorded by this morpher can thus be used to ``replay''
+/// the set of changes applied to an image.
///
/// \todo Split and move this into the library?
@@ -51,22 +55,22 @@
// Forward declaration.
-template <typename I> struct recorder;
+template <typename I> struct lazy_recorder;
/* FIXME: mln::decorated_image lacks a proper definition of
properties! (see mln/core/image/imorph/decorated_image.hh). We use
the following (minimal) set of properties as a workaround for the
- recorder decoration. */
+ lazy_recorder decoration. */
namespace mln
{
namespace trait
{
template <typename I>
- struct image_< decorated_image< I, recorder<I> > >
+ struct image_< decorated_image< I, lazy_recorder<I> > >
: default_image_morpher< I,
mln_value(I),
- decorated_image< I, recorder<I> > >
+ decorated_image< I, lazy_recorder<I> > >
{
typedef trait::image::category::identity_morpher category;
@@ -80,24 +84,37 @@ namespace mln
} // end of namespace mln
-// Recorder.
+// ``Lazy'' recorder.
template <typename I>
-struct recorder
+struct lazy_recorder
{
+ lazy_recorder()
+ {
+ }
+
+ lazy_recorder(mln::Image<I>& ima)
+ : initial(mln::duplicate(ima))
+ {
+ }
+
void reading(const I&, const mln_psite(I)&) const
{
// N/A.
}
- void writing(I& ima, const mln_psite(I)&, const mln_value(I)&)
+ void writing(I&, const mln_psite(I)& p, const mln_value(I)& v)
{
- sequence.push_back(mln::duplicate(ima));
+ sequence.push_back(std::make_pair(p, v));
}
- std::vector<mln_concrete(I)> sequence;
+ /// The initial image.
+ mln_concrete(I) initial;
+ /// The sequence of changes (list of (psite, value) pairs).
+ // Make it a tracked_ptr to avoid costly copy operations?
+ std::vector< std::pair<mln_psite(I), mln_value(I)> > sequence;
};
-/* Skeleton of an image decorated with a recorder.
+/* Skeleton of an image decorated with a lazy_recorder.
Initialy, I (Roland) wanted to add this to mln/trait/ch_value.hh:
@@ -108,14 +125,14 @@ struct recorder
typedef M< mln_ch_value(I, V), D > ret;
};
- However, this would not work in the case of the recorder since the
+ However, this would not work in the case of the lazy_recorder since the
type D of the data attached to the image (of type I) has to be
changed as well. Indeed the initial decoration contains a sequence
of images of type I, which should be changed into a sequence of
images of type mln_ch_value(I, V).
There are several option to improve this. One is to create a
- ch_value trait for data/decorations such as `recorder<I>'. Another
+ ch_value trait for data/decorations such as `lazy_recorder<I>'. Another
one is to refine the skeleton of decorated_image<I, D> to have it
convey the type the data stored in the decoration, e.g, changing
@@ -128,7 +145,7 @@ struct recorder
but this seems overly complicated.
The workaround chosen here is very local, and address the very
- specific case of decorated_image< I, recorder<I> >. */
+ specific case of decorated_image< I, lazy_recorder<I> >. */
namespace mln
{
@@ -138,11 +155,11 @@ namespace mln
{
template < typename I, typename V >
struct ch_value_< decorated_image< tag::image_<I>,
- tag::data_< recorder<I> > >,
+ tag::data_< lazy_recorder<I> > >,
V >
{
typedef decorated_image< mln_ch_value(I, V),
- recorder< mln_ch_value(I, V) > > ret;
+ lazy_recorder< mln_ch_value(I, V) > > ret;
};
} // end namespace mln::trait::impl
@@ -153,10 +170,10 @@ namespace mln
// Helper.
template <typename I>
inline
-mln::decorated_image< I, recorder<I> >
-record(mln::Image<I>& ima)
+mln::decorated_image< I, lazy_recorder<I> >
+lazy_record(mln::Image<I>& ima)
{
- return mln::decorate(ima, recorder<I>());
+ return mln::decorate(ima, lazy_recorder<I>(ima));
}
@@ -166,17 +183,24 @@ namespace ppm
template <typename I>
inline
void
- save(const mln::decorated_image< I, recorder<I> >& rec,
+ save(const mln::decorated_image< I, lazy_recorder<I> >& rec,
const std::string& prefix)
{
+ mln_concrete(I) frame = mln::duplicate(rec.decoration().initial);
for (size_t i = 0; i < rec.decoration().sequence.size(); ++i)
{
std::stringstream s;
s << std::setfill ('0') << std::setw (6) << i;
- mln::io::ppm::save(rec.decoration().sequence[i],
- prefix + s.str() + ".ppm");
+ mln::io::ppm::save(frame, prefix + s.str() + ".ppm");
+ // Apply the I-th change to the next frame.
+ //
+ // Changes are applied after the I-th image has been written,
+ // to mimic the behavior of the original recorder morpher (see
+ // recorder.hh).
+ frame(rec.decoration().sequence[i].first) =
+ rec.decoration().sequence[i].second;
}
}
}
-#endif // ! APPS_MORPHERS_RECORDER_HH
+#endif // ! APPS_MORPHERS_LAZY_RECORDER_HH
--
1.7.2.5
1
0