Commit 7ade09da authored by Ugo Jardonnet's avatar Ugo Jardonnet
Browse files

Portability fix.

	Partially fix portability problem due to wrong cast
	of size_t to unsigned:
	* mln/histo/data.hh,
	* mln/debug/println_with_border.spe.hh,
	* mln/core/image/translate_image.hh,
	* mln/draw/graph.hh,
	* mln/level/all.hh,
	* mln/accu/count_adjacent_vertices.hh,
	* mln/accu/count.hh,
	* mln/accu/min_h.hh,
	* mln/accu/rank.hh,
	* mln/accu/max_h.hh,
	* mln/accu/median_alt.hh,
	* mln/accu/median_h.hh,
	* mln/accu/volume.hh,
	* mln/accu/height.hh,
	* mln/border/fill.hh,
	* mln/border/duplicate.hh,
	* mln/border/mirror.hh,
	* mln/geom/resize.hh,
	* mln/morpho/closing_volume.hh,
	* mln/morpho/closing_area.hh,
	* mln/morpho/closing_height.hh,
	* mln/morpho/opening_area_on_vertices.hh,
	* mln/morpho/opening_volume.hh,
	* mln/morpho/closing_area_on_vertices.hh,
	* mln/morpho/opening_height.hh,
	* mln/morpho/opening_area.hh: Remove wrong use of std::size_t.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008@2742 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 82c9b492
2008-10-30 Ugo Jardonnet <jardonnet@lrde.epita.fr>
Portability fix.
Partially fix portability problem due to wrong cast
of size_t to unsigned:
* mln/histo/data.hh,
* mln/debug/println_with_border.spe.hh,
* mln/core/image/translate_image.hh,
* mln/draw/graph.hh,
* mln/level/all.hh,
* mln/accu/count_adjacent_vertices.hh,
* mln/accu/count.hh,
* mln/accu/min_h.hh,
* mln/accu/rank.hh,
* mln/accu/max_h.hh,
* mln/accu/median_alt.hh,
* mln/accu/median_h.hh,
* mln/accu/volume.hh,
* mln/accu/height.hh,
* mln/border/fill.hh,
* mln/border/duplicate.hh,
* mln/border/mirror.hh,
* mln/geom/resize.hh,
* mln/morpho/closing_volume.hh,
* mln/morpho/closing_area.hh,
* mln/morpho/closing_height.hh,
* mln/morpho/opening_area_on_vertices.hh,
* mln/morpho/opening_volume.hh,
* mln/morpho/closing_area_on_vertices.hh,
* mln/morpho/opening_height.hh,
* mln/morpho/opening_area.hh: Remove wrong use of std::size_t.
2008-10-30 Ugo Jardonnet <ugo.jardonnet@lrde.epita.fr>
 
Add majority accu.
......
......@@ -43,7 +43,7 @@ namespace mln
/// \brief Generic counter accumulator class.
/// The parameter \a T is the type to be count.
template <typename T>
struct count : public mln::accu::internal::base< std::size_t , count<T> >
struct count : public mln::accu::internal::base< unsigned , count<T> >
{
typedef T argument;
......@@ -56,11 +56,11 @@ namespace mln
void take(const count<T>& other);
/// Force the value of the counter to \a c.
void set_value(std::size_t c);
void set_value(unsigned c);
/// \}
/// Get the value of the accumulator.
std::size_t to_result() const;
unsigned to_result() const;
/// Check whether this accu is able to return a result.
/// Always true here.
......@@ -68,7 +68,7 @@ namespace mln
protected:
/// The value of the counter.
std::size_t count_;
unsigned count_;
};
namespace meta
......@@ -122,7 +122,7 @@ namespace mln
template <typename T>
inline
std::size_t
unsigned
count<T>::to_result() const
{
return count_;
......@@ -131,7 +131,7 @@ namespace mln
template <typename T>
inline
void
count<T>::set_value(std::size_t c)
count<T>::set_value(unsigned c)
{
count_ = c;
}
......
......@@ -54,7 +54,7 @@ namespace mln
/// mln::opening_area_on_vertices.
template <typename P, typename V>
struct count_adjacent_vertices
: public mln::accu::internal::base< std::size_t,
: public mln::accu::internal::base< unsigned,
count_adjacent_vertices<P, V> >
{
typedef mln::util::pix< mln::line_graph_image<P, V> > argument;
......@@ -68,11 +68,11 @@ namespace mln
void take(const count_adjacent_vertices<P, V>& other);
/// Force the value of the counter to \a c.
void set_value(std::size_t c);
void set_value(unsigned c);
/// \}
/// Get the value of the accumulator.
std::size_t to_result() const;
unsigned to_result() const;
protected:
/// Update the value of the counter.
......@@ -80,7 +80,7 @@ namespace mln
protected:
/// The value of the counter.
std::size_t count__;
unsigned count__;
/// The set of adjacent vertices.
std::set<util::vertex_id> vertices_;
};
......@@ -142,7 +142,7 @@ namespace mln
template <typename P, typename V>
inline
std::size_t
unsigned
count_adjacent_vertices<P, V>::to_result() const
{
return count__;
......@@ -151,7 +151,7 @@ namespace mln
template <typename P, typename V>
inline
void
count_adjacent_vertices<P, V>::set_value(std::size_t c)
count_adjacent_vertices<P, V>::set_value(unsigned c)
{
count__ = c;
/// Reset the other member.
......
......@@ -59,7 +59,7 @@ namespace mln
/// of pixels is built.
template <typename I>
struct height
: public mln::accu::internal::base< std::size_t , height<I> >
: public mln::accu::internal::base< unsigned , height<I> >
{
/// \brief The accumulated data type.
///
......@@ -80,11 +80,11 @@ namespace mln
void take(const height<I>& other);
/// Force the value of the counter to \a h.
void set_value(std::size_t h);
void set_value(unsigned h);
/// \}
/// Get the value of the accumulator.
std::size_t to_result() const;
unsigned to_result() const;
/// Check whether this accu is able to return a result.
/// Always true here.
......@@ -96,7 +96,7 @@ namespace mln
/// The maximum level in the component.
value max_level__;
/// The height of the component.
std::size_t height_;
unsigned height_;
};
......@@ -156,7 +156,7 @@ namespace mln
template <typename I>
inline
std::size_t
unsigned
height<I>::to_result() const
{
return height_;
......@@ -165,7 +165,7 @@ namespace mln
template <typename I>
inline
void
height<I>::set_value(std::size_t h)
height<I>::set_value(unsigned h)
{
height_ = h;
// Reset the other members.
......
......@@ -82,9 +82,9 @@ namespace mln
mutable accu::histo<V> h_;
const value::set<V>& s_; // derived from h_
mutable std::size_t sum_;
mutable unsigned sum_;
mutable bool valid_;
mutable std::size_t i_; // the max index
mutable unsigned i_; // the max index
mutable argument t_; // the max argument
// Auxiliary methods
......
......@@ -83,10 +83,10 @@ namespace mln
/// derived from h_
const S& s_;
std::size_t sum_minus_, sum_plus_;
unsigned sum_minus_, sum_plus_;
/// the median index
std::size_t i_;
unsigned i_;
/// the median argument
argument t_;
......
......@@ -79,10 +79,10 @@ namespace mln
mutable accu::histo<V> h_;
const value::set<V>& s_; // derived from h_
mutable std::size_t sum_minus_, sum_plus_;
mutable unsigned sum_minus_, sum_plus_;
mutable bool valid_;
mutable std::size_t i_; // the median_h index
mutable unsigned i_; // the median_h index
mutable argument t_; // the median_h value
// Auxiliary methods
......
......@@ -83,9 +83,9 @@ namespace mln
mutable accu::histo<V> h_;
const value::set<V>& s_; // derived from h_
mutable std::size_t sum_;
mutable unsigned sum_;
mutable bool valid_;
mutable std::size_t i_; // the min index
mutable unsigned i_; // the min index
mutable argument t_; // the min value
// Auxiliary methods
......
......@@ -88,10 +88,10 @@ namespace mln
mutable accu::histo<T> h_;
const S& s_; // derived from h_
mutable std::size_t sum_minus_, sum_plus_;
mutable unsigned sum_minus_, sum_plus_;
mutable bool valid_;
mutable std::size_t i_; // the median index
mutable unsigned i_; // the median index
mutable argument t_; // the median value
// Auxiliary methods
......
......@@ -58,7 +58,7 @@ namespace mln
/// of pixels is built.
template <typename I>
struct volume
: public mln::accu::internal::base< std::size_t , volume<I> >
: public mln::accu::internal::base< unsigned , volume<I> >
{
/// \brief The accumulated data type.
///
......@@ -79,11 +79,11 @@ namespace mln
void take(const volume<I>& other);
/// Force the value of the counter to \a v.
void set_value(std::size_t v);
void set_value(unsigned v);
/// \}
/// Get the value of the accumulator.
std::size_t to_result() const;
unsigned to_result() const;
/// Check whether this accu is able to return a result.
/// Always true here.
......@@ -93,9 +93,9 @@ namespace mln
/// The reference level (the level of the component's root).
value ref_level__;
/// The area of the component.
std::size_t area__;
unsigned area__;
/// The volume of the component.
std::size_t volume_;
unsigned volume_;
};
......@@ -175,7 +175,7 @@ namespace mln
template <typename I>
inline
std::size_t
unsigned
volume<I>::to_result() const
{
return volume_;
......@@ -184,7 +184,7 @@ namespace mln
template <typename I>
inline
void
volume<I>::set_value(std::size_t v)
volume<I>::set_value(unsigned v)
{
volume_ = v;
// Reset the other members.
......
......@@ -35,7 +35,6 @@
# include <mln/core/concept/image.hh>
# include <mln/level/memset_.hh>
# include <mln/core/line_piter.hh>
# include <mln/core/pixel.hh>
......@@ -71,14 +70,14 @@ namespace mln
typedef mln_psite(I) P;
typename I::line_piter pl(ima.domain());
std::size_t len_c = exact(ima).bbox().len(P::dim - 1);
std::size_t border = ima.border ();
unsigned len_c = exact(ima).bbox().len(P::dim - 1);
unsigned border = ima.border ();
for (std::size_t i = 0; i < border; ++i)
for (unsigned i = 0; i < border; ++i)
const_cast<I&>(ima)[i] = ima[border];
std::size_t st = border + len_c - 1;
for (std::size_t i = st + 1; i < ima.nelements (); ++i)
unsigned st = border + len_c - 1;
for (unsigned i = st + 1; i < ima.nelements (); ++i)
const_cast<I&>(ima)[i] = ima[st];
trace::exiting("border::impl::duplicate_1d_");
......@@ -92,34 +91,34 @@ namespace mln
typedef mln_psite(I) P;
typename I::line_piter pl(ima.domain());
std::size_t border = ima.border ();
std::size_t border_2x = 2 * ima.border ();
std::size_t len_c = exact(ima).bbox().len(1);
std::size_t len_r = exact(ima).bbox().len(0);
std::size_t real_len_c = len_c + border_2x;
std::size_t st;
unsigned border = ima.border ();
unsigned border_2x = 2 * ima.border ();
unsigned len_c = exact(ima).bbox().len(1);
unsigned len_r = exact(ima).bbox().len(0);
unsigned real_len_c = len_c + border_2x;
unsigned st;
// Duplicate
for_all (pl)
{
st = ima.index_of_point (pl);
for (std::size_t i = 1; i <= border; ++i)
for (unsigned i = 1; i <= border; ++i)
const_cast<I&>(ima)[st - i] = ima[st];
st = st + len_c - 1;
for (std::size_t i = 1; i <= border; ++i)
for (unsigned i = 1; i <= border; ++i)
const_cast<I&>(ima)[st + i] = ima[st];
}
// Duplicate n first * border line
st = real_len_c * border;
for (std::size_t k = 0; k < border; ++k)
for (std::size_t i = 0; i < real_len_c; ++i)
for (unsigned k = 0; k < border; ++k)
for (unsigned i = 0; i < real_len_c; ++i)
const_cast<I&>(ima)[k * real_len_c + i] = ima[st + i];
// Duplicate n last * border line
st = real_len_c * (border + len_r - 1);
for (std::size_t k = 1; k <= border; ++k)
for (std::size_t i = st; i < st + real_len_c; ++i)
for (unsigned k = 1; k <= border; ++k)
for (unsigned i = st; i < st + real_len_c; ++i)
const_cast<I&>(ima)[k * real_len_c + i] = ima[i];
trace::exiting("border::impl::duplicate_2d_");
......@@ -136,56 +135,56 @@ namespace mln
typedef mln_psite(I) P;
typename I::line_piter pl(ima.domain());
std::size_t border = ima.border ();
std::size_t border_2x = 2 * ima.border ();
std::size_t len_c = exact(ima).bbox().len(P::dim - 1);
std::size_t len_r = exact(ima).bbox().len(1);
std::size_t len_s = exact(ima).bbox().len(0);
std::size_t real_len_c = len_c + border_2x;
std::size_t real_len_r = len_r + border_2x;
std::size_t face = real_len_c * real_len_r;
std::size_t st;
unsigned border = ima.border ();
unsigned border_2x = 2 * ima.border ();
unsigned len_c = exact(ima).bbox().len(P::dim - 1);
unsigned len_r = exact(ima).bbox().len(1);
unsigned len_s = exact(ima).bbox().len(0);
unsigned real_len_c = len_c + border_2x;
unsigned real_len_r = len_r + border_2x;
unsigned face = real_len_c * real_len_r;
unsigned st;
pl.start ();
for (std::size_t k = 0; k < len_s; ++k)
for (unsigned k = 0; k < len_s; ++k)
{
// Duplicate
for (std::size_t j = 0; j < len_r; ++j)
for (unsigned j = 0; j < len_r; ++j)
{
st = ima.index_of_point (pl);
for (std::size_t i = 1; i <= border; ++i)
for (unsigned i = 1; i <= border; ++i)
const_cast<I&>(ima)[st - i] = ima[st];
st = st + len_c - 1;
for (std::size_t i = 1; i <= border; ++i)
for (unsigned i = 1; i <= border; ++i)
const_cast<I&>(ima)[st + i] = ima[st];
pl.next ();
}
// Duplicate n last * border line
st = border * face + k * face + border * real_len_c ;
for (std::size_t j = 1; j <= border; ++j)
for (std::size_t i = 0; i < real_len_c; ++i)
for (unsigned j = 1; j <= border; ++j)
for (unsigned i = 0; i < real_len_c; ++i)
const_cast<I&>(ima)[st - j * real_len_c + i] = ima[st + i];
// Duplicate n last * border line
st = border * face + k * face + (len_r + border - 1) * real_len_c ;
for (std::size_t j = 1; j <= border; ++j)
for (std::size_t i = 0; i < real_len_c; ++i)
for (unsigned j = 1; j <= border; ++j)
for (unsigned i = 0; i < real_len_c; ++i)
const_cast<I&>(ima)[st + j * real_len_c + i] = ima[st + i];
}
// Duplicate n first * border face
st = border * face;
for (std::size_t k = 0; k < border; ++k)
for (std::size_t i = 0; i < face; ++i)
for (unsigned k = 0; k < border; ++k)
for (unsigned i = 0; i < face; ++i)
const_cast<I&>(ima)[k * face + i] = ima[st + i];
// Duplicate n last * border face
st = (len_s + border - 1) * face;
for (std::size_t k = 1; k <= border; ++k)
for (std::size_t i = 0; i < face; ++i)
for (unsigned k = 1; k <= border; ++k)
for (unsigned i = 0; i < face; ++i)
const_cast<I&>(ima)[st + k * face + i] = ima[st + i];
trace::exiting("border::impl::duplicate_3d_");
......
......@@ -92,12 +92,12 @@ namespace mln
typedef mln_psite(I) P;
mln_box_runstart_piter(I) pl(ima.domain());
std::size_t len_r = pl.run_length();
std::size_t st = 0;
unsigned len_r = pl.run_length();
unsigned st = 0;
for_all (pl)
{
std::size_t end = ima.index_of_point (pl);
unsigned end = ima.index_of_point (pl);
std::memset((void*)&ima.element(st),
*(const int*)(&v),
end - st);
......@@ -122,17 +122,17 @@ namespace mln
typedef mln_psite(I) P;
mln_box_runstart_piter(I) pl(ima.domain());
std::size_t len_r = pl.run_length();
std::size_t st = 0;
unsigned len_r = pl.run_length();
unsigned st = 0;
for_all (pl)
{
std::size_t end = ima.index_of_point (pl);
for (std::size_t i = st; i < end; ++i)
unsigned end = ima.index_of_point (pl);
for (unsigned i = st; i < end; ++i)
(const_cast<I&>(ima)).element(i) = v;
st = end + len_r;
}
for (std::size_t i = st; i < ima.nelements (); ++i)
for (unsigned i = st; i < ima.nelements (); ++i)
const_cast<I&>(ima).element(i) = v;
trace::exiting("border::impl::fill_size_n");
......
......@@ -78,9 +78,9 @@ namespace mln
trace::entering("border::impl::mirror_");
I& ima = const_cast<I&>(ima_);
std::size_t border = ima.border ();
std::size_t nbinds = geom::ninds(ima);
std::size_t min;
unsigned border = ima.border ();
unsigned nbinds = geom::ninds(ima);
unsigned min;
if (border > nbinds)
min = nbinds;
......@@ -89,7 +89,7 @@ namespace mln
/// left border
{
std::size_t i = 0;
unsigned i = 0;
for (; i < min; ++i)
ima.element(border - 1 - i) = ima(point1d(i));
......@@ -99,7 +99,7 @@ namespace mln
/// right border
{
std::size_t i = 0,
unsigned i = 0,
j = nbinds - 1;
for (;
i < min;
......@@ -121,58 +121,58 @@ namespace mln
trace::entering("border::impl::mirror_");
I& ima = const_cast<I&>(ima_);
std::size_t border = ima.border ();
std::size_t nbrows = geom::max_row(ima) - geom::min_row(ima);
std::size_t nbcols = geom::max_col(ima) - geom::min_col(ima);
std::size_t real_nbcols = (nbcols + 1) + 2 * border;
std::size_t start = real_nbcols * border + border;
std::size_t s = start;
unsigned border = ima.border ();
unsigned nbrows = geom::max_row(ima) - geom::min_row(ima);
unsigned nbcols = geom::max_col(ima) - geom::min_col(ima);
unsigned real_nbcols = (nbcols + 1) + 2 * border;
unsigned start = real_nbcols * border + border;
unsigned s = start;
// mirror top left corner
for (std::size_t i = 0; i < border; ++i)
for (std::size_t j = 0; j < border; ++j)
for (unsigned i = 0; i < border; ++i)
for (unsigned j = 0; j < border; ++j)
ima.element(i * ((nbcols + 1) + 2 * border) + j) = ima.element(s);
// mirror top left corner
s = start + nbcols;
for (std::size_t i = 0; i < border; ++i)
for (std::size_t j = 1; j <= border; ++j)
for (unsigned i = 0; i < border; ++i)
for (unsigned j = 1; j <= border; ++j)
ima.element(i * ((nbcols + 1) + 2 * border) + (nbcols + border + j)) = ima.element(s);
// mirror bottom left corner
s = start + (nbrows * real_nbcols);
for (std::size_t i = 1; i <= border; ++i)
for (std::size_t j = 1; j <= border; ++j)
for (unsigned i = 1; i <= border; ++i)
for (unsigned j = 1; j <= border; ++j)
ima.element(s - i + (j * (real_nbcols))) = ima.element(s);
// mirror bottom right corner
s = start + (nbrows * real_nbcols) + nbcols;
for (std::size_t i = 1; i <= border; ++i)
for (std::size_t j = 1; j <= border; ++j)
for (unsigned i = 1; i <= border; ++i)
for (unsigned j = 1; j <= border; ++j)
ima.element(s + i + (j * real_nbcols)) = ima.element(s);
// mirror top border
s = start;
for (std::size_t i = 0; i <= nbcols; ++i)
for (std::size_t j = 1; j <= border; ++j)
for (unsigned i = 0; i <= nbcols; ++i)
for (unsigned j = 1; j <= border; ++j)
ima.element(s + i - (j * real_nbcols)) = ima.element(s + i + ((j - 1)* real_nbcols));
// mirror left border
s = start;
for (std::size_t i = 0; i <= nbrows; ++i)
for (std::size_t j = 1; j <= border; ++j)
for (unsigned i = 0; i <= nbrows; ++i)
for (unsigned j = 1; j <= border; ++j)
ima.element(s + (i * real_nbcols) - j) = ima.element(s + (i * real_nbcols) + (j - 1));
// mirror right border
s = start;
for (std::size_t i = 0; i <= nbrows; ++i)
for (std::size_t j = 1; j <= border; ++j)
for (unsigned i = 0; i <= nbrows; ++i)
for (unsigned j = 1; j <= border; ++j)
ima.element(s + (i * real_nbcols + nbcols) + j) = ima.element(s + (i * real_nbcols + nbcols) - (j - 1));