Commit c3c62f22 authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

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.
parent 26c8584d
2010-08-09 Guillaume Lazzara <z@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@lrde.epita.fr>
 
Replace deduced type 'point' by 'site'.
// 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
{
......
// 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.
//
......
......@@ -35,6 +35,7 @@
# include <mln/core/concept/image.hh>
# include <mln/core/box_runstart_piter.hh>
# include <mln/border/get.hh>
namespace mln
{
......
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment