last-svn-commit-466-gc3d187e Fix more warnings in Milena.

* mln/convert/impl/from_float_to_value.hh: Add an overload for short int. * mln/io/fld/load.hh: Use convert::from_to. * mln/io/fld/max_components.hh: Explicitly cast values to unsigned. --- milena/ChangeLog | 11 ++++++++ milena/mln/convert/impl/from_float_to_value.hh | 10 +++++++ milena/mln/io/fld/load.hh | 13 ++++++--- milena/mln/io/fld/max_components.hh | 32 ++++++++++++++--------- 4 files changed, 48 insertions(+), 18 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 5ae192f..489ca03 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,14 @@ +2010-08-12 Guillaume Lazzara <z@lrde.epita.fr> + + Fix more warnings in Milena. + + * mln/convert/impl/from_float_to_value.hh: Add an overload for + short int. + + * mln/io/fld/load.hh: Use convert::from_to. + + * mln/io/fld/max_components.hh: Explicitly cast values to unsigned. + 2010-08-11 Guillaume Lazzara <z@lrde.epita.fr> Fix more tests in Milena. diff --git a/milena/mln/convert/impl/from_float_to_value.hh b/milena/mln/convert/impl/from_float_to_value.hh index 9b5e3f0..f516419 100644 --- a/milena/mln/convert/impl/from_float_to_value.hh +++ b/milena/mln/convert/impl/from_float_to_value.hh @@ -143,6 +143,16 @@ namespace mln to = math::round<int>()(from); } + // float-> short + inline + void + from_to_(const float& from, + short& to) + { + to = math::round<short>()(from); + } + + } // end of namespace mln::convert::over_load # endif // ! MLN_INCLUDE_ONLY diff --git a/milena/mln/io/fld/load.hh b/milena/mln/io/fld/load.hh index 048630f..33768df 100644 --- a/milena/mln/io/fld/load.hh +++ b/milena/mln/io/fld/load.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2008, 2009, 2010 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -43,6 +44,9 @@ /// /// FIXME: pnm::load uses special implementation if sizeof(int_u8) != 1 ?? what ?? +# include <fstream> +# include <iostream> + # include <mln/core/concept/image.hh> # include <mln/io/fld/header.hh> # include <mln/io/fld/load_header.hh> @@ -54,8 +58,7 @@ # include <mln/geom/nsites.hh> -# include <fstream> -# include <iostream> +# include <mln/convert/from_to.hh> namespace mln { @@ -220,8 +223,8 @@ namespace mln box<mln_site(I)> bbox; for (int i = 0; i < hder.ndim; ++i) { - bbox.pmin()[i] = hder.min_ext[i]; - bbox.pmax()[i] = hder.max_ext[i]; + convert::from_to(hder.min_ext[i], bbox.pmin()[i]); + convert::from_to(hder.max_ext[i], bbox.pmax()[i]); } ima.init_(bbox); diff --git a/milena/mln/io/fld/max_components.hh b/milena/mln/io/fld/max_components.hh index 70931b6..d57310a 100644 --- a/milena/mln/io/fld/max_components.hh +++ b/milena/mln/io/fld/max_components.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2008, 2009, 2010 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -26,6 +27,11 @@ #ifndef MLN_IO_FLD_MAX_COMPONENTS_HH # define MLN_IO_FLD_MAX_COMPONENTS_HH +/// \file +/// +/// \fixme Don't we want to change the return type 'unsigned' to a +/// larger type or make it templated? + # include <mln/algebra/vec.hh> # include <mln/value/rgb.hh> # include <mln/io/fld/header.hh> @@ -41,53 +47,53 @@ namespace mln template <typename V> inline - unsigned int max_component(const V&); + unsigned max_component(const V&); template <unsigned n, typename V> inline - unsigned int max_component(const algebra::vec<n, V>& v); + unsigned max_component(const algebra::vec<n, V>& v); template <unsigned n> inline - unsigned int max_component(const value::rgb<n>&); + unsigned max_component(const value::rgb<n>&); inline - unsigned int max_component(const fld::data_type::E& t); + unsigned max_component(const fld::data_type::E& t); # ifndef MLN_INCLUDE_ONLY template <typename V> inline - unsigned int max_component(const V&) + unsigned max_component(const V&) { - return mln_max(V); + return unsigned(mln_max(V)); } template <unsigned n, typename V> inline - unsigned int max_component(const algebra::vec<n, V>& v) + unsigned max_component(const algebra::vec<n, V>& v) { - return mln_max(V); + return unsigned(mln_max(V)); } template <unsigned n> inline - unsigned int max_component(const value::rgb<n>&) + unsigned max_component(const value::rgb<n>&) { return mln_max(mln::value::int_u<n>); } inline - unsigned int max_component(const fld::data_type::E& t) + unsigned max_component(const fld::data_type::E& t) { switch (t) { case data_type::BYTE: return mln_max(unsigned char); case data_type::SHORT: return mln_max(unsigned short); case data_type::INTEGER: return mln_max(unsigned); - case data_type::FLOAT: return mln_max(float); - case data_type::DOUBLE: return mln_max(double); + case data_type::FLOAT: return unsigned(mln_max(float)); + case data_type::DOUBLE: return unsigned(mln_max(double)); default: return 0; } } -- 1.5.6.5
participants (1)
-
Guillaume Lazzara