https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Help g++-3.3 to compile.
* mln/trait/value/internal/comp.hh,
* mln/world/inter_pixel/separator_to_pixels.hh,
* mln/core/image/imorph/tr_image.hh,
* mln/geom/rotate.hh,
* mln/fun/unary.hh,
* mln/labeling/wrap.hh,
* tests/world/inter_pixel/is_separator.cc,
* tests/world/inter_pixel/is_pixel.cc,
* tests/world/inter_pixel/immerse.cc: Help g++-3.3 to compile.
* demos/genericity/neighborhood/input: New directory.
* demos/genericity/neighborhood/output: New directory.
* demos/genericity/neighborhood/world.pbm,
* demos/genericity/neighborhood/drawing.pbm: Move...
* demos/genericity/neighborhood/input/world.pbm,
* demos/genericity/neighborhood/input/drawing.pbm: ...here.
mln/core/image/imorph/tr_image.hh | 11 ++++--
mln/fun/unary.hh | 12 ++++++-
mln/geom/rotate.hh | 2 -
mln/labeling/wrap.hh | 8 +++-
mln/trait/value/internal/comp.hh | 44 +++++++++++++++++----------
mln/world/inter_pixel/separator_to_pixels.hh | 40 ++++++++++++++++++------
tests/world/inter_pixel/immerse.cc | 4 +-
tests/world/inter_pixel/is_pixel.cc | 8 +++-
tests/world/inter_pixel/is_separator.cc | 10 +++---
9 files changed, 96 insertions(+), 43 deletions(-)
Index: mln/trait/value/internal/comp.hh
--- mln/trait/value/internal/comp.hh (revision 4236)
+++ mln/trait/value/internal/comp.hh (working copy)
@@ -185,8 +185,18 @@
}
};
+
+ // Technical note:
+ //
+ // We distinguish between a type T being a C-array type (T =
+ // U[dim]) and T a "regular" type (meaning "not a C-array
+ // type"). We have two stages to help g++-3.3 which has
+ // difficulty in solving such partial specializations.
+
+ // Regular case.
+
template <typename T, unsigned i, unsigned dim>
- struct get_comp
+ struct get_comp_with_regular_
{
typedef mln::trait::value_<T> Tr;
typedef typename Tr::comp C;
@@ -199,38 +209,42 @@
}
};
-
- template <typename T, unsigned i, unsigned dim>
- struct get_comp< T[dim], i, dim >
+ template <typename T>
+ struct get_comp_with_regular_< T, 0, 1 >
{
typedef T ret;
- static ret on(const T (&v)[dim])
+ static ret on(const T& v)
{
- return v[i];
+ return v;
}
};
- template <typename T>
- struct get_comp< T, 0, 1 >
+ template <typename T, unsigned i, unsigned dim>
+ struct get_comp : get_comp_with_regular_<T, i, dim>
+ {
+ };
+
+ // C-array case.
+
+ template <typename T, unsigned i, unsigned dim>
+ struct get_comp_with_C_array
{
typedef T ret;
- static ret on(const T& v)
+ static ret on(const T (&v)[dim])
{
- return v;
+ return v[i];
}
};
- template <typename T>
- struct get_comp< T[1], 0, 1 > // Disambiguate between both
- // previous specialization.
+ template <typename T, unsigned i, unsigned dim>
+ struct get_comp< T[dim], i, dim > : get_comp_with_C_array<T, i, dim>
{
- typedef T ret;
- static ret on(const T (&v)[1]) { return v[0]; }
};
+
// comp< T, i >
template <typename T, unsigned i>
Index: mln/world/inter_pixel/separator_to_pixels.hh
--- mln/world/inter_pixel/separator_to_pixels.hh (revision 4236)
+++ mln/world/inter_pixel/separator_to_pixels.hh (working copy)
@@ -69,10 +69,15 @@
Gpoint<P>& p1_, Gpoint<P>& p2_)
{
const P& s = exact(s_);
- mln_precondition(is_separator()(s));
+ P& p1 = exact(p1_);
+ P& p2 = exact(p2_);
- P &p1 = exact(p1_),
- &p2 = exact(p2_);
+ {
+ // Pre-condition.
+ is_separator is_separator_;
+ mln_precondition(is_separator_(s));
+ (void) is_separator_;
+ }
// FIXME: 2D only.
if (s.row() % 2)
@@ -88,8 +93,13 @@
p2 = point2d(s.row(), s.col() + 1);
}
- mln_postcondition(is_pixel()(p1));
- mln_postcondition(is_pixel()(p2));
+ {
+ // Post-conditions.
+ is_pixel is_pixel_;
+ mln_postcondition(is_pixel_(p1));
+ mln_postcondition(is_pixel_(p2));
+ (void) is_pixel_;
+ }
}
template <typename Ps, typename P>
@@ -99,15 +109,25 @@
Gpoint<P>& p1_, Gpoint<P>& p2_)
{
const Ps& s = exact(s_);
- mln_precondition(is_separator()(s));
+ P& p1 = exact(p1_);
+ P& p2 = exact(p2_);
- P &p1 = exact(p1_),
- &p2 = exact(p2_);
+ {
+ // Pre-condition.
+ is_separator is_separator_;
+ mln_precondition(is_separator_(s));
+ (void) is_separator_;
+ }
separator_to_pixels(s.to_site(), p1, p2);
- mln_postcondition(is_pixel()(p1));
- mln_postcondition(is_pixel()(p2));
+ {
+ // Post-conditions.
+ is_pixel is_pixel_;
+ mln_postcondition(is_pixel_(p1));
+ mln_postcondition(is_pixel_(p2));
+ (void) is_pixel_;
+ }
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/image/imorph/tr_image.hh
--- mln/core/image/imorph/tr_image.hh (revision 4236)
+++ mln/core/image/imorph/tr_image.hh (working copy)
@@ -126,8 +126,11 @@
/// Test if a pixel value is accessible at \p p.
using super_::has;
+ enum { dim_ = site::dim };
+ typedef mln::algebra::vec<dim_, float> vec_t;
+
/// Test if a pixel value is accessible at \p v.
- bool has(const mln::algebra::vec<site::dim, float>& v) const;
+ bool has(const vec_t& v) const;
/// Read-only access of pixel value at point site \p p.
/// Mutable access is only OK for reading (not writing).
@@ -194,11 +197,11 @@
template <typename S, typename I, typename T>
inline
bool
- tr_image<S,I,T>::has(const algebra::vec<site::dim, float>& v) const
+ tr_image<S,I,T>::has(const vec_t& v) const
{
mln_psite(I) p;
- algebra::vec<I::site::dim, float> v2 = this->data_->tr_.inv()(v);
- for (unsigned i = 0; i < I::site::dim; ++i)
+ algebra::vec<site::dim, float> v2 = this->data_->tr_.inv()(v);
+ for (unsigned i = 0; i < site::dim; ++i)
p[i] = static_cast<int>(v2[i]);
return this->delegatee_().has(p);
}
Index: mln/geom/rotate.hh
--- mln/geom/rotate.hh (revision 4236)
+++ mln/geom/rotate.hh (working copy)
@@ -146,7 +146,7 @@
typedef
tr_image<mln_box(I), extension_val<const I>, comp_transf_t> tr_t;
- tr_t tr = transposed_image(b, extend(input, extension_), comp_transf);
+ tr_t tr = transposed_image(b, extend(input, extension), comp_transf);
typedef mln_site(I) P;
P rpmin = P(rot(input.domain().pmin().to_vec()));
Index: mln/fun/unary.hh
--- mln/fun/unary.hh (revision 4236)
+++ mln/fun/unary.hh (working copy)
@@ -30,6 +30,7 @@
# include <mln/fun/spe/unary.hh>
# include <mln/trait/next/solve.hh>
+
namespace mln
{
@@ -69,13 +70,20 @@
template <typename T>
typename with<T>::ret::template lresult_with<T>::ret operator()(T&
v) const
{
- return typename with<T>::ret(state()).apply_rw(v);
+ // See the commentary in next method.
+ typedef typename with<T>::ret fun_t;
+ fun_t f(state());
+ return f.apply_rw(v);
}
template <typename T, typename R>
void set(T& v, const R& r) const
{
- typename with<T>::ret(state()).set(v, r);
+ // Decomposing "with<T>::ret(state()).set(v, r)" into 3 lines
+ // helps g++-3.3!
+ typedef typename with<T>::ret fun_t;
+ fun_t f(state());
+ f.set(v, r);
}
template <typename U>
Index: mln/labeling/wrap.hh
--- mln/labeling/wrap.hh (revision 4236)
+++ mln/labeling/wrap.hh (working copy)
@@ -38,6 +38,7 @@
# include <mln/metal/is_a.hh>
# include <mln/value/label_8.hh>
+
namespace mln
{
@@ -62,7 +63,7 @@
///
/// \return A new image with values wrapped with type label_8.
template <typename I>
- mln_ch_value(I,value::label_8)
+ mln_ch_value(I, mln::value::label_8)
wrap(const Image<I>& input);
@@ -88,10 +89,10 @@
template <typename I>
inline
- mln_ch_value(I,value::label_8)
+ mln_ch_value(I, mln::value::label_8)
wrap(const Image<I>& input)
{
- return wrap(value::label_8(), input);
+ return wrap(mln::value::label_8(), input);
}
# endif // ! MLN_INCLUDE_ONLY
@@ -100,4 +101,5 @@
} // end of namespace mln
+
#endif // ! MLN_LABELING_WRAP_HH
Index: tests/world/inter_pixel/is_separator.cc
--- tests/world/inter_pixel/is_separator.cc (revision 4236)
+++ tests/world/inter_pixel/is_separator.cc (working copy)
@@ -34,8 +34,10 @@
point2d p00(0, 0), p01(0, 1), p10(1, 0), p11(1, 1);
- mln_assertion(! is_separator()(p00));
- mln_assertion( is_separator()(p01));
- mln_assertion(! is_separator()(p11));
- mln_assertion( is_separator()(p10));
+ is_separator is_separator_; // Help g++-3.3.
+
+ mln_assertion(! is_separator_(p00));
+ mln_assertion( is_separator_(p01));
+ mln_assertion(! is_separator_(p11));
+ mln_assertion( is_separator_(p10));
}
Index: tests/world/inter_pixel/is_pixel.cc
--- tests/world/inter_pixel/is_pixel.cc (revision 4236)
+++ tests/world/inter_pixel/is_pixel.cc (working copy)
@@ -34,7 +34,9 @@
point2d p00(0, 0), p01(0, 1), p11(1, 1);
- mln_assertion( is_pixel()(p00));
- mln_assertion(! is_pixel()(p01));
- mln_assertion(! is_pixel()(p11));
+ is_pixel is_pixel_; // Help g++-3.3.
+
+ mln_assertion( is_pixel_(p00));
+ mln_assertion(! is_pixel_(p01));
+ mln_assertion(! is_pixel_(p11));
}
Index: tests/world/inter_pixel/immerse.cc
--- tests/world/inter_pixel/immerse.cc (revision 4236)
+++ tests/world/inter_pixel/immerse.cc (working copy)
@@ -54,7 +54,9 @@
mln_assertion(imax == (make::image2d(refs) | is_pixel()));
+ is_pixel is_pixel_; // Help g++-3.3.
+
mln_piter_(Ix) p(imax.domain());
for_all(p)
- mln_assertion(is_pixel()(p));
+ mln_assertion(is_pixel_(p));
}
Property changes on: demos/genericity/neighborhood/input/world.pbm
___________________________________________________________________
Added: svn:mergeinfo
Property changes on: demos/genericity/neighborhood/input/drawing.pbm
___________________________________________________________________
Added: svn:mergeinfo