* mln/accu/internal/base.hh,
* mln/accu/math/sum.hh: Aesthetic changes.
* mln/data/paste_without_localization.hh: Add a missing include.
* mln/geom/rotate.hh: Add a new overload taking a box as argument.
---
milena/ChangeLog | 11 +++
milena/mln/accu/internal/base.hh | 4 +-
milena/mln/accu/math/sum.hh | 3 +-
milena/mln/data/paste_without_localization.hh | 1 +
milena/mln/geom/rotate.hh | 93 +++++++++++++++++++++----
5 files changed, 96 insertions(+), 16 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 710cfc9..15a205c 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,14 @@
+2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Small changes in Milena.
+
+ * mln/accu/internal/base.hh,
+ * mln/accu/math/sum.hh: Aesthetic changes.
+
+ * mln/data/paste_without_localization.hh: Add a missing include.
+
+ * mln/geom/rotate.hh: Add a new overload taking a box as argument.
+
2010-08-04 Guillaume Lazzara <z(a)lrde.epita.fr>
Replace deduced type 'point' by 'site'.
diff --git a/milena/mln/accu/internal/base.hh b/milena/mln/accu/internal/base.hh
index 8c03cc3..a554a11 100644
--- a/milena/mln/accu/internal/base.hh
+++ b/milena/mln/accu/internal/base.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -33,7 +34,6 @@
# include <mln/core/concept/accumulator.hh>
-
namespace mln
{
diff --git a/milena/mln/accu/math/sum.hh b/milena/mln/accu/math/sum.hh
index c7e3e47..a77e2a2 100644
--- a/milena/mln/accu/math/sum.hh
+++ b/milena/mln/accu/math/sum.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
diff --git a/milena/mln/data/paste_without_localization.hh
b/milena/mln/data/paste_without_localization.hh
index 1aad2fe..667e7f1 100644
--- a/milena/mln/data/paste_without_localization.hh
+++ b/milena/mln/data/paste_without_localization.hh
@@ -35,6 +35,7 @@
# include <mln/core/concept/image.hh>
# include <mln/core/box_runstart_piter.hh>
+# include <mln/border/get.hh>
namespace mln
{
diff --git a/milena/mln/geom/rotate.hh b/milena/mln/geom/rotate.hh
index 0d42943..1ba8cb1 100644
--- a/milena/mln/geom/rotate.hh
+++ b/milena/mln/geom/rotate.hh
@@ -72,7 +72,8 @@ namespace mln
/// of the domain before the rotation.
/// \param[in] output_domain The domain of the output image. An
/// invalid domain, causes the routine
- /// to use the rotated input_ domain.
+ /// to use a domain large enough to
+ /// display the whole original image.
///
/// \return An image with the same domain as \p input.
//
@@ -95,6 +96,24 @@ namespace mln
rotate(const Image<I>& input, double angle);
+ /// Rotate a box.
+ ///
+ /// FIXME: the return type may be too generic and may lead to
+ /// invalid covariance.
+ //
+ template <typename B>
+ B
+ rotate(const Box<B>& box_, double angle, const mln_site(B)& ref);
+
+ /// \overload
+ ///
+ /// The rotation center \p ref is set to box.pcenter().
+ //
+ template <typename B>
+ B
+ rotate(const Box<B>& box, double angle);
+
+
# ifndef MLN_INCLUDE_ONLY
@@ -112,6 +131,8 @@ namespace mln
// Do not check that output_domain_ is valid. If it is not,
// further in this routine, we define a default domain.
+ typedef mln_site(I) P;
+ mln_precondition(P::dim == 2);
mln_precondition(input.is_valid());
mln_precondition(angle >= -360.0f && angle <= 360.0f);
// mlc_converts_to(mln_exact(Ext), mln_value(I))::check();
@@ -138,26 +159,16 @@ namespace mln
S b = output_domain;
// Automatically adjusting the output domain if needed.
if (!output_domain.is_valid())
- {
- accu::shape::bbox<mln_site(I)> accu;
-
- typedef mln_site(I) P;
- accu.take(P(comp_transf(input.domain().pmin().to_vec())));
- accu.take(P(comp_transf(input.domain().pmax().to_vec())));
-
- b = accu.to_result();
- }
+ b = rotate(input.domain(), angle);
typedef
- typename mln::internal::extension_type<const I, mln_exact(Ext)>::result ext_t;
+ typename mln::internal::extension_type<const I, mln_exact(Ext)>::result ext_t;
typedef
tr_image<mln_box(I), ext_t, comp_transf_t> tr_t;
tr_t tr = transposed_image(b, ext_t(input, extension), comp_transf);
- typedef mln_site(I) P;
- P rpmin = P(rot(input.domain().pmin().to_vec()));
mln_concrete(I) output;
initialize(output, tr);
@@ -189,6 +200,62 @@ namespace mln
}
+ template <typename B>
+ B
+ rotate(const Box<B>& box_, double angle, const mln_site(B)& ref)
+ {
+ trace::entering("geom::rotate");
+
+ const B& box = exact(box_);
+
+ typedef mln_site(B) P;
+ mln_precondition(P::dim == 2);
+ mln_precondition(box.is_valid());
+ mln_precondition(angle >= -360.0f && angle <= 360.0f);
+
+ typedef fun::x2x::translation<2,double> trans_t;
+ trans_t
+ t(-1 * ref.to_vec()),
+ t_1(ref.to_vec());
+
+ typedef fun::x2x::rotation<2,double> rot_t;
+ rot_t rot(math::pi * angle / 180.f, literal::origin);
+
+ typedef
+ fun::x2x::composed<trans_t, fun::x2x::composed<rot_t, trans_t> >
+ comp_transf_t;
+
+ comp_transf_t comp_transf = compose(t_1, compose(rot, t));
+
+ accu::shape::bbox<P> accu;
+
+ P
+ top_right(box.pmin().row(),
+ box.pmax().col()),
+ bot_left(box.pmax().row(),
+ box.pmin().col());
+
+ accu.take(P(comp_transf(box.pmin().to_vec())));
+ accu.take(P(comp_transf(top_right.to_vec())));
+ accu.take(P(comp_transf(bot_left.to_vec())));
+ accu.take(P(comp_transf(box.pmax().to_vec())));
+
+ B output = accu.to_result();
+
+ trace::exiting("geom::rotate");
+ return output;
+ }
+
+
+ template <typename B>
+ B
+ rotate(const Box<B>& box, double angle)
+ {
+ return rotate(box, angle, exact(box).pcenter());
+ }
+
+
+
# endif // ! MLN_INCLUDE_ONLY
--
1.5.6.5