
https://svn.lrde.epita.fr/svn/oln/trunk/milena Index: ChangeLog from Thierry Geraud <thierry.geraud@lrde.epita.fr> Fix g++-3.4 warnings. * mln/world/binary_2d/enlarge.hh (do_threshold): Fix. Upgrade doc. * mln/core/image/edge_image.hh: Likewise. * mln/core/dpoint.hh: Likewise. (dpoint): Fix implicit cast. * mln/metal/converts_to.hh: Upgrade doc. (converts_to): Add overloads to quiet g++-3.4. * mln/level: Remove directory. * mln/algebra/mat.hh: Upgrade doc. (inverse): Fix; use float instead of T. * mln/io/off/load.hh: Upgrade doc. (read_face_data): Fix missing scaling to 255. Add explicit conversion. * tests/core/image/graph_image.cc, * tests/core/image/edge_image.cc, * tests/core/image/line_graph_image.cc, * tests/core/image/vertex_image.cc: Upgrade doc. (X): New. (expected_fwd_nb, expected_bkd_nb): Update. Fix negative value stored as unsigned. mln/algebra/mat.hh | 15 +++++++------ mln/core/dpoint.hh | 12 +++++------ mln/core/image/edge_image.hh | 2 - mln/io/off/load.hh | 13 ++++++----- mln/metal/converts_to.hh | 38 ++++++++++++++++++++++++++++------- mln/world/binary_2d/enlarge.hh | 4 +-- tests/core/image/edge_image.cc | 24 +++++++++++----------- tests/core/image/graph_image.cc | 31 ++++++++++++++-------------- tests/core/image/line_graph_image.cc | 21 +++++++++++-------- tests/core/image/vertex_image.cc | 29 +++++++++++++------------- 10 files changed, 110 insertions(+), 79 deletions(-) Index: mln/world/binary_2d/enlarge.hh --- mln/world/binary_2d/enlarge.hh (revision 3945) +++ mln/world/binary_2d/enlarge.hh (working copy) @@ -30,7 +30,7 @@ /// \file mln/world/binary_2d/enlarge.hh /// -/// Enlarge 2^n times a binary image. +/// \brief Enlarge 2^n times a binary image. /// /// \todo Make it much more generic. @@ -97,7 +97,7 @@ int do_threshold(float value) { - return 255.f * value; + return static_cast<int>(255.f * value); } } // end of namespace mln::world::binary_2d Index: mln/core/image/edge_image.hh --- mln/core/image/edge_image.hh (revision 3945) +++ mln/core/image/edge_image.hh (working copy) @@ -31,7 +31,7 @@ /// \file mln/core/image/edge_image.hh /// -/// Image based on graph edges. +/// \brief Image based on graph edges. # include <mln/core/concept/graph.hh> # include <mln/core/site_set/p_edges.hh> Index: mln/core/dpoint.hh --- mln/core/dpoint.hh (revision 3945) +++ mln/core/dpoint.hh (working copy) @@ -1,5 +1,5 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2007, 2008, 2009 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -31,7 +31,7 @@ /// \file mln/core/dpoint.hh /// -/// Definition of the generic delta-point class mln::dpoint. +/// \brief Definition of the generic delta-point class mln::dpoint. # include <mln/core/def/coord.hh> # include <mln/core/concept/gdpoint.hh> @@ -53,7 +53,7 @@ /// \} - /// Generic delta-point class. + /// \brief Generic delta-point class. /// /// Parameters are \c G the dimension of the space and \c C the /// coordinate type in this space. @@ -168,9 +168,9 @@ { unsigned j = 0; for (unsigned i = dim - 2; i < dim; ++i) - coord_[i] = v[j++]; + coord_[i] = static_cast<C>(v[j++]); for (unsigned i = 2; i < dim; ++i, ++j) - coord_[i-j] = v[j]; + coord_[i-j] = static_cast<C>(v[j]); } } Index: mln/metal/converts_to.hh --- mln/metal/converts_to.hh (revision 3945) +++ mln/metal/converts_to.hh (working copy) @@ -1,5 +1,5 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2007, 2008, 2009a EPITA Research and Development +// Laboratory (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -31,10 +31,11 @@ /// \file mln/metal/converts_to.hh /// -/// Definition of a type that means "converts to". +/// \brief Definition of a type that means "converts to". # include <mln/metal/is_a.hh> # include <mln/metal/const.hh> +# include <mln/core/def/coord.hh> # define mlc_converts_to(T, U) mln::metal::converts_to< T, U > @@ -44,6 +45,13 @@ namespace mln { + // Forward declarations. + namespace value { + template <unsigned n> struct int_u; + template <unsigned n> struct int_s; + } + + namespace metal { @@ -61,16 +69,14 @@ - /*! \brief "converts-to" check. - * - * FIXME: Doc! - */ + /// \brief "converts-to" check. template <typename T, typename U> struct converts_to : bool_<( sizeof(internal::helper_converts_to_<T, U>::selector(*internal::make_<mlc_const(T)>::ptr()) ) == sizeof(internal::yes_) )> {}; + template <typename T, typename U> struct converts_to<T*, U*> : converts_to<T, U> {}; @@ -79,8 +85,26 @@ struct converts_to<T**, U**> : false_ {}; + + + // Below, a few hacks to quiet g++-3.4 warnings: + + template <> struct converts_to< float, int > : true_ {}; + template <> struct converts_to< float, def::coord > : true_ {}; + template <unsigned n> struct converts_to< float, value::int_u<n> > : true_ {}; + template <unsigned n> struct converts_to< float, value::int_s<n> > : true_ {}; + + template <> struct converts_to< double, int > : true_ {}; + template <> struct converts_to< double, def::coord > : true_ {}; + template <unsigned n> struct converts_to< double, value::int_u<n> > : true_ {}; + template <unsigned n> struct converts_to< double, value::int_s<n> > : true_ {}; + + // End of hacks. + } // end of namespace mln::metal + + } // end of namespace mln Index: mln/algebra/mat.hh --- mln/algebra/mat.hh (revision 3945) +++ mln/algebra/mat.hh (working copy) @@ -31,7 +31,7 @@ /// \file mln/algebra/mat.hh /// -/// Definition of a generic matrix class. +/// \brief Definition of a generic matrix class. # include <iostream> @@ -547,28 +547,29 @@ return tmp; } + namespace internal { template <typename T> inline - mat<2,2,T> + mat<2,2,float> inverse(const mat<2,2,T>& m) { - T d = det(m); + float d = det(m); mln_precondition(d != 0); - return make<T>( + m(1,1) / d, - m(0,1) / d, + return make<float>( + m(1,1) / d, - m(0,1) / d, - m(1,0) / d, + m(0,0) / d ); } template <typename T> inline - mat<3,3,T> + mat<3,3,float> inverse(const mat<3,3,T>& m) { - T d = det(m); + float d = det(m); mln_precondition(d != 0); - return make<T>( det(make(m(1,1), m(1,2), + return make<float>( det(make(m(1,1), m(1,2), m(2,1), m(2,2))), det(make(m(0,2), m(0,1), Index: mln/io/off/load.hh --- mln/io/off/load.hh (revision 3945) +++ mln/io/off/load.hh (working copy) @@ -1,4 +1,5 @@ -// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -29,20 +30,18 @@ # define MLN_IO_OFF_LOAD_HH /// \file mln/io/off/load.hh -/// Input loading function for OFF files. +/// +/// \brief Input loading function for OFF files. /// /// \see http://shape.cs.princeton.edu/benchmark/documentation/off_format.html /// \see https://people.scs.fsu.edu/~burkardt/html/off_format.html # include <cstdlib> - # include <iostream> # include <fstream> - # include <string> # include <mln/literal/black.hh> - # include <mln/core/concept/object.hh> # include <mln/core/alias/complex_image.hh> @@ -546,7 +545,9 @@ mln_assertion(0.0f <= g); mln_assertion(g <= 1.0f); mln_assertion(0.0f <= b); mln_assertion(b <= 1.0f); mln_assertion(0.0f <= a); mln_assertion(a <= 1.0f); - face_value.push_back(value::rgb8(r, g, b)); + face_value.push_back(value::rgb8(int(255 * r), + int(255 * g), + int(255 * b))); } /* \} */ Index: tests/core/image/graph_image.cc --- tests/core/image/graph_image.cc (revision 3945) +++ tests/core/image/graph_image.cc (working copy) @@ -1,4 +1,5 @@ -// Copyright(C) 2007, 2008 EPITA Research and Development Laboratory(LRDE) +// Copyright(C) 2007, 2008, 2009 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -27,7 +28,7 @@ /// \file tests/core/image/graph_image.cc /// -/// Tests on mln::graph_image. +/// \brief Tests on mln::graph_image. #include <vector> @@ -37,16 +38,13 @@ #include <mln/core/concept/function.hh> #include <mln/core/neighb.hh> #include <mln/core/var.hh> - #include <mln/accu/bbox.hh> - #include <mln/fun/i2v/array.hh> - #include <mln/util/graph.hh> - #include <mln/debug/draw_graph.hh> #include <mln/debug/println.hh> + /* The graph is as follows: 0 1 2 3 4 @@ -61,19 +59,22 @@ */ +static const unsigned X = mln_max(unsigned); // Invalid id. + + // Expected neighbors for forward and backward iteration. -// -1 is an invalid id. -static unsigned expected_fwd_nb[5][3] = { { 1, -1, -1 }, +// X is an invalid id. +static unsigned expected_fwd_nb[5][3] = { { 1, X, X }, { 0, 2, 3 }, - { 1, 4, -1 }, - { 1, 4, -1 }, - { 3, 2, -1 } }; + { 1, 4, X }, + { 1, 4, X }, + { 3, 2, X } }; -static unsigned expected_bkd_nb[5][3] = { { 1, -1, -1 }, +static unsigned expected_bkd_nb[5][3] = { { 1, X, X }, { 3, 2, 0 }, - { 4, 1, -1 }, - { 4, 1, -1 }, - { 2, 3, -1 } }; + { 4, 1, X }, + { 4, 1, X }, + { 2, 3, X } }; int main() Index: tests/core/image/edge_image.cc --- tests/core/image/edge_image.cc (revision 3945) +++ tests/core/image/edge_image.cc (working copy) @@ -27,22 +27,19 @@ /// \file tests/core/image/edge_image.cc /// -/// Tests on mln::edge_image. +/// \brief Tests on mln::edge_image. #include <vector> #include <mln/core/image/edge_image.hh> #include <mln/core/image/image2d.hh> - #include <mln/accu/bbox.hh> - #include <mln/fun/i2v/array.hh> - #include <mln/util/graph.hh> #include <mln/util/site_pair.hh> - #include <mln/debug/draw_graph.hh> + /* The graph is as follows: 0 1 2 3 4 @@ -57,19 +54,22 @@ */ +static const unsigned X = mln_max(unsigned); // Invalid id. + + // Expected neighbors for forward and backward iteration. -// -1 is an invalid id. -static unsigned expected_fwd_nb[5][3] = { { 1, 2, -1 }, +// X is an invalid id. +static unsigned expected_fwd_nb[5][3] = { { 1, 2, X }, { 0, 2, 4 }, { 0, 1, 3 }, - { 2, 4, -1 }, - { 1, 3, -1 } }; + { 2, 4, X }, + { 1, 3, X } }; -static unsigned expected_bkd_nb[5][3] = { { 2, 1, -1 }, +static unsigned expected_bkd_nb[5][3] = { { 2, 1, X }, { 4, 2, 0 }, { 3, 1, 0 }, - { 4, 2, -1 }, - { 3, 1, -1 } }; + { 4, 2, X }, + { 3, 1, X } }; int main() Index: tests/core/image/line_graph_image.cc --- tests/core/image/line_graph_image.cc (revision 3945) +++ tests/core/image/line_graph_image.cc (working copy) @@ -28,7 +28,7 @@ /// \file tests/core/image/line_graph_image.cc /// -/// Tests on mln::line_graph_image. +/// \brief Tests on mln::line_graph_image. #include <mln/core/alias/point2d.hh> @@ -59,18 +59,21 @@ */ +static const unsigned X = mln_max(unsigned); // Invalid id. + + // Expected neighbors for forward and backward iteration. -static unsigned expected_fwd_nbh[5][3] = { { 1, -1, -1 }, +static unsigned expected_fwd_nbh[5][3] = { { 1, X, X }, { 0, 2, 3 }, - { 1, 4, -1 }, - { 1, 4, -1 }, - { 3, 2, -1 } }; + { 1, 4, X }, + { 1, 4, X }, + { 3, 2, X } }; -static unsigned expected_bkd_nbh[5][3] = { { 1, 0, -1 }, +static unsigned expected_bkd_nbh[5][3] = { { 1, 0, X }, { 3, 2, 0 }, - { 4, 1, -1 }, - { 4, 1, -1 }, - { 2, 3, -1 } }; + { 4, 1, X }, + { 4, 1, X }, + { 2, 3, X } }; int main() Index: tests/core/image/vertex_image.cc --- tests/core/image/vertex_image.cc (revision 3945) +++ tests/core/image/vertex_image.cc (working copy) @@ -27,22 +27,20 @@ /// \file tests/core/image/vertex_image.cc /// -/// Tests on mln::vertex_image. +/// \brief Tests on mln::vertex_image. #include <vector> #include <mln/core/image/vertex_image.hh> #include <mln/make/vertex_image.hh> #include <mln/core/image/image2d.hh> - #include <mln/accu/bbox.hh> - #include <mln/fun/i2v/array.hh> - #include <mln/util/graph.hh> - #include <mln/debug/draw_graph.hh> + + /* The graph is as follows: 0 1 2 3 4 @@ -57,19 +55,22 @@ */ +static const unsigned X = mln_max(unsigned); // Invalid id. + + // Expected neighbors for forward and backward iteration. -// -1 is an invalid id. -static unsigned expected_fwd_nb[5][3] = { { 1, -1, -1 }, +// X is an invalid id. +static unsigned expected_fwd_nb[5][3] = { { 1, X, X }, { 0, 2, 3 }, - { 1, 4, -1 }, - { 1, 4, -1 }, - { 3, 2, -1 } }; + { 1, 4, X }, + { 1, 4, X }, + { 3, 2, X } }; -static unsigned expected_bkd_nb[5][3] = { { 1, -1, -1 }, +static unsigned expected_bkd_nb[5][3] = { { 1, X, X }, { 3, 2, 0 }, - { 4, 1, -1 }, - { 4, 1, -1 }, - { 2, 3, -1 } }; + { 4, 1, X }, + { 4, 1, X }, + { 2, 3, X } }; int main()
participants (1)
-
Thierry Geraud