---
milena/ChangeLog | 4 ++
milena/mln/draw/{line.hh => dashed_line.hh} | 60 ++++++++++++++++++---------
2 files changed, 44 insertions(+), 20 deletions(-)
copy milena/mln/draw/{line.hh => dashed_line.hh} (61%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index fae42e1..bcaf644 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,7 @@
+2010-03-11 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ * mln/draw/dashed_line.hh: New draw line routine.
+
2010-02-24 Guillaume Lazzara <z(a)lrde.epita.fr>
Add white gaussian noise function.
diff --git a/milena/mln/draw/line.hh b/milena/mln/draw/dashed_line.hh
similarity index 61%
copy from milena/mln/draw/line.hh
copy to milena/mln/draw/dashed_line.hh
index 528dce3..6b0d244 100644
--- a/milena/mln/draw/line.hh
+++ b/milena/mln/draw/dashed_line.hh
@@ -1,5 +1,4 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -17,21 +16,22 @@
//
// As a special exception, you may use this file as part of a free
// software project without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
+// instantiate templates or use macros or indashed_line functions from this
// file, or you compile this file and link it with other files to produce
// an executable, this file does not by itself cause the resulting
// executable to be covered by the GNU General Public License. This
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_DRAW_LINE_HH
-# define MLN_DRAW_LINE_HH
+#ifndef MLN_DRAW_DASHED_LINE_HH
+# define MLN_DRAW_DASHED_LINE_HH
/// \file
///
-/// Draw a line in an image.
-/// \fixme Add specializations for horizontal lines (use pointers/memset).
+/// Draw a dashed_line in an image.
+/// \fixme Add specializations for horizontal dashed_lines (use pointers/memset).
+# include <mln/core/concept/function.hh>
# include <mln/core/concept/image.hh>
# include <mln/core/site_set/p_line2d.hh>
# include <mln/core/image/imorph/safe.hh>
@@ -46,12 +46,12 @@ namespace mln
namespace draw
{
- /*! Draw a line at level \p v in image \p ima between the points
- * \p beg and \p end.
+ /*! Draw a dashed line at level \p v in image \p ima between the
+ * points \p beg and \p end.
*
* \param[in,out] ima The image to be drawn.
- * \param[in] beg The start point to drawn line.
- * \param[in] end The end point to drawn line.
+ * \param[in] beg The start point to drawn dashed_line.
+ * \param[in] end The end point to drawn dashed_line.
* \param[in] v The value to assign to all drawn pixels.
*
* \pre \p ima has to be initialized.
@@ -60,27 +60,47 @@ namespace mln
*
*/
template <typename I>
- void line(Image<I>& ima,
- const mln_psite(I)& beg, const mln_psite(I)& end,
- const mln_value(I)& v);
+ void dashed_line(Image<I>& ima,
+ const mln_psite(I)& beg, const mln_psite(I)& end,
+ const mln_value(I)& v);
# ifndef MLN_INCLUDE_ONLY
+ namespace internal
+ {
+
+ template <typename I, unsigned dim>
+ struct dashed_line_f : Function_v2b<dashed_line_f<I, dim> >
+ {
+ typedef bool result;
+
+ bool operator()(const mln_site(I)& p) const
+ {
+ return p[dim] % 2;
+ }
+
+ };
+
+ } // end of namespace mln::draw::internal
+
+
+
template <typename I>
inline
- void line(Image<I>& ima_,
- const mln_psite(I)& beg, const mln_psite(I)& end,
- const mln_value(I)& v)
+ void dashed_line(Image<I>& ima_,
+ const mln_psite(I)& beg, const mln_psite(I)& end,
+ const mln_value(I)& v)
{
I& ima = exact(ima_);
mln_precondition(ima.is_valid());
+
if (! ima.has(beg))
trace::warning("Begin site is not part of the given image.");
if (! ima.has(end))
trace::warning("End site is not part of the given image.");
- data::paste(pw::cst(v) | p_line2d(beg, end),
- safe(ima).rw());
+
+ data::fill(((ima | p_line2d(beg, end)).rw() | internal::dashed_line_f<I,
1>()).rw(), v);
}
# endif // ! MLN_INCLUDE_ONLY
@@ -90,4 +110,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_DRAW_LINE_HH
+#endif // ! MLN_DRAW_DASHED_LINE_HH
--
1.5.6.5