LRE
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
List overview
Download
Olena-patches
----- 2025 -----
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
olena-patches@lrde.epita.fr
9625 discussions
Start a n
N
ew thread
3100: Clean up apps/statues/ a bit.
by Roland Levillain
* apps/statues/mesh-max-curv.cc, apps/statues/mesh-pinv-curv.cc, * apps/statues/mesh-segm.cc, apps/statues/mesh-skel.cc: s/exit/std::exit/. * apps/statues/mesh-pinv-curv.cc (pi): Make it a constant. * apps/statues/mesh-max-curv.cc (pi): Remove useless constant. Remove useless #include directives. Typo in comment. * apps/statues/mesh-skel.cc: Fix Doxygen headers. * apps/statues/mesh-complex-segm.cc: Aesthetic changes. --- milena/ChangeLog | 14 ++++++++++++++ milena/apps/statues/mesh-complex-segm.cc | 26 ++++++++++---------------- milena/apps/statues/mesh-max-curv.cc | 16 ++++++---------- milena/apps/statues/mesh-pinv-curv.cc | 8 ++++---- milena/apps/statues/mesh-segm.cc | 6 +++--- milena/apps/statues/mesh-skel.cc | 8 ++++---- 6 files changed, 41 insertions(+), 37 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index ef8b409..aa168d3 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,19 @@ 2008-12-30 Roland Levillain <roland(a)lrde.epita.fr> + Clean up apps/statues/ a bit. + + * apps/statues/mesh-max-curv.cc, apps/statues/mesh-pinv-curv.cc, + * apps/statues/mesh-segm.cc, apps/statues/mesh-skel.cc: + s/exit/std::exit/. + * apps/statues/mesh-pinv-curv.cc (pi): Make it a constant. + * apps/statues/mesh-max-curv.cc (pi): Remove useless constant. + Remove useless #include directives. + Typo in comment. + * apps/statues/mesh-skel.cc: Fix Doxygen headers. + * apps/statues/mesh-complex-segm.cc: Aesthetic changes. + +2008-12-30 Roland Levillain <roland(a)lrde.epita.fr> + Disable graph-based applications depending on Trimesh. * apps/statues/Makefile.am (bin_PROGRAMS) diff --git a/milena/apps/statues/mesh-complex-segm.cc b/milena/apps/statues/mesh-complex-segm.cc index 00c9d13..80f87a1 100644 --- a/milena/apps/statues/mesh-complex-segm.cc +++ b/milena/apps/statues/mesh-complex-segm.cc @@ -55,7 +55,7 @@ int main(int argc, char* argv[]) { std::cerr << "usage: " << argv[0] << " input.off lambda output.off" << std::endl; - exit(1); + std::exit(1); } std::string input_filename = argv[1]; @@ -77,23 +77,18 @@ int main(int argc, char* argv[]) mln::io::off::load(input, input_filename); // Values on edges. - - /* FIXME: To be improved: instead of computing the curvature on - edges from a mean of the curvature on adjacent polygons, compute - it directly from the curvature on vertices. We should probably - integrate Trimesh's curvature computation into Milena. */ mln::p_n_faces_fwd_piter<D, G> e(input.domain(), 1); typedef mln::complex_higher_neighborhood<D, G> adj_polygons_nbh_t; adj_polygons_nbh_t adj_polygons_nbh; - mln_niter_(adj_polygons_nbh_t) p(adj_polygons_nbh, e); + mln_niter_(adj_polygons_nbh_t) adj_p(adj_polygons_nbh, e); // Iterate on edges (1-faces). for_all(e) { float s = 0.0f; unsigned n = 0; - for_all(p) + for_all(adj_p) { - s += input(p); + s += input(adj_p); ++n; } input(e) = s / n; @@ -118,14 +113,13 @@ int main(int argc, char* argv[]) | WST. | `------*/ - /* FIXME: Note that the WST is either doing too much work, since we - have not constrained the domain of the image to 1-faces only. - + /* FIXME: Note that the WST is doing too much work, since we have + not constrained the domain of the image to 1-faces only. It would be great if we could use something like this: - closed_input | mln::p_faces<1, D, G>(closed_input.domain()) + closed_input | mln::p_faces<1, D, G>(closed_input.domain()) - as input of the WST. */ + as input of the WST. */ // Compute the WST on edges. typedef unsigned wst_val_t; @@ -138,8 +132,8 @@ int main(int argc, char* argv[]) // Label polygons (i.e., propagate labels from edges to polygons). for_all(e) if (wshed(e) != 0) - for_all(p) - wshed(p) = wshed(e); + for_all(adj_p) + wshed(adj_p) = wshed(e); /*---------. | Output. | diff --git a/milena/apps/statues/mesh-max-curv.cc b/milena/apps/statues/mesh-max-curv.cc index 8fc9a06..5524282 100644 --- a/milena/apps/statues/mesh-max-curv.cc +++ b/milena/apps/statues/mesh-max-curv.cc @@ -30,7 +30,6 @@ /// a mesh. #include <cstdlib> -#include <cmath> #include <algorithm> #include <vector> @@ -47,17 +46,13 @@ #include "io.hh" -// Doesn't C++ have a better way to express Pi? -const float pi = 4 * atanf(1); - - int main(int argc, char* argv[]) { if (argc != 3) { std::cerr << "usage: " << argv[0] << " input.off output.off" << std::endl; - exit(1); + std::exit(1); } std::string input_filename = argv[1]; @@ -69,13 +64,14 @@ int main(int argc, char* argv[]) // object. TriMesh* mesh_ptr = TriMesh::read(input_filename.c_str()); if (!mesh_ptr) - exit(2); + std::exit(2); TriMesh& mesh = *mesh_ptr; // Computes faces (triangles). mesh.need_faces(); // Computation of the curvature on each vertex of the mesh. mesh.need_curvatures(); + std::vector<float> vertex_m(mesh.vertices.size(), 0.f); for (unsigned v = 0; v < mesh.vertices.size(); ++v) // Max curvature. @@ -84,7 +80,7 @@ int main(int argc, char* argv[]) // For each face of the mesh, computean an average curvature value // from the mean curvature at its vertices. - std::vector<float> face_m(mesh.faces.size(), 42.f); + std::vector<float> face_m(mesh.faces.size(), 0.f); mln::accu::min_max<float> acc; for (unsigned f = 0; f < mesh.faces.size(); ++f) { @@ -103,7 +99,7 @@ int main(int argc, char* argv[]) // FIXME: Taken from mln/level/stretch.hh (this should be factored). float min = min_max.first; float max = min_max.second; - // Don't normalize actually if the curvature is constants (i.e., + // Don't normalize actually if the curvature is constant (i.e., // if min == max). if (min != max) { @@ -122,7 +118,7 @@ int main(int argc, char* argv[]) { std::cerr << "Error opening " << output_filename.c_str() << " for writing." << std::endl; - exit(2); + std::exit(2); } write_off_float(mesh_ptr, normalized_face_m, f_out); fclose(f_out); diff --git a/milena/apps/statues/mesh-pinv-curv.cc b/milena/apps/statues/mesh-pinv-curv.cc index 8f38c57..d7dd773 100644 --- a/milena/apps/statues/mesh-pinv-curv.cc +++ b/milena/apps/statues/mesh-pinv-curv.cc @@ -43,7 +43,7 @@ // Doesn't C++ have a better way to express Pi? -const float pi = 4 * atanf(1); +static const float pi = 4 * atanf(1); int main(int argc, char* argv[]) @@ -52,7 +52,7 @@ int main(int argc, char* argv[]) { std::cerr << "usage: " << argv[0] << " input.off output.off" << std::endl; - exit(1); + std::exit(1); } std::string input_filename = argv[1]; @@ -64,7 +64,7 @@ int main(int argc, char* argv[]) // object. TriMesh* mesh_ptr = TriMesh::read(input_filename.c_str()); if (!mesh_ptr) - exit(2); + std::exit(2); TriMesh& mesh = *mesh_ptr; // Computes faces (triangles). @@ -98,7 +98,7 @@ int main(int argc, char* argv[]) { std::cerr << "Error opening " << output_filename.c_str() << " for writing." << std::endl; - exit(2); + std::exit(2); } write_off_float(mesh_ptr, face_h_inv, f_out); fclose(f_out); diff --git a/milena/apps/statues/mesh-segm.cc b/milena/apps/statues/mesh-segm.cc index 5ab247f..46391a1 100644 --- a/milena/apps/statues/mesh-segm.cc +++ b/milena/apps/statues/mesh-segm.cc @@ -62,7 +62,7 @@ int main(int argc, char* argv[]) { std::cerr << "usage: " << argv[0] << " input.off lambda output.off" << std::endl; - exit(1); + std::exit(1); } std::string input_filename = argv[1]; @@ -79,7 +79,7 @@ int main(int argc, char* argv[]) // object. TriMesh* mesh_ptr = TriMesh::read(input_filename.c_str()); if (!mesh_ptr) - exit(2); + std::exit(2); TriMesh& mesh = *mesh_ptr; // Computes faces (triangles). @@ -224,7 +224,7 @@ int main(int argc, char* argv[]) { std::cerr << "Error opening " << output_filename.c_str() << " for writing." << std::endl; - exit(2); + std::exit(2); } write_off_colored(mesh_ptr, face_color, f_out); fclose(f_out); diff --git a/milena/apps/statues/mesh-skel.cc b/milena/apps/statues/mesh-skel.cc index e45d07c..c4fd0f2 100644 --- a/milena/apps/statues/mesh-skel.cc +++ b/milena/apps/statues/mesh-skel.cc @@ -25,7 +25,7 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/// \file apps/statues/mesh-segm.cc +/// \file apps/statues/mesh-skel.cc /// \brief A program computing a skeleton of the surface of the /// (triangle) mesh of a statue. @@ -62,7 +62,7 @@ int main(int argc, char* argv[]) { std::cerr << "usage: " << argv[0] << " input.off lambda output.off" << std::endl; - exit(1); + std::exit(1); } std::string input_filename = argv[1]; @@ -79,7 +79,7 @@ int main(int argc, char* argv[]) // object. TriMesh* mesh_ptr = TriMesh::read(input_filename.c_str()); if (!mesh_ptr) - exit(2); + std::exit(2); TriMesh& mesh = *mesh_ptr; // Computes faces (triangles). @@ -201,7 +201,7 @@ int main(int argc, char* argv[]) { std::cerr << "Error opening " << output_filename.c_str() << " for writing." << std::endl; - exit(2); + std::exit(2); } write_off_binary(mesh_ptr, face_value, f_out); fclose(f_out); -- 1.6.0.4
16Â years
1
0
0
0
3099: Disable graph-based applications depending on Trimesh.
by Roland Levillain
* apps/statues/Makefile.am (bin_PROGRAMS) (mesh_segm_SOURCES, mesh_segm_CPPFLAGS) (mesh_segm_LDFLAGS, mesh_segm_LDADD) (mesh_skel_SOURCES, mesh_skel_CPPFLAGS) (mesh_skel_LDFLAGS, mesh_skel_LDADD): Disable mesh-segm and mesh-skel. --- milena/ChangeLog | 11 +++++++++++ milena/apps/statues/Makefile.am | 20 ++++++++++---------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 8572d83..ef8b409 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,16 @@ 2008-12-30 Roland Levillain <roland(a)lrde.epita.fr> + Disable graph-based applications depending on Trimesh. + + * apps/statues/Makefile.am (bin_PROGRAMS) + (mesh_segm_SOURCES, mesh_segm_CPPFLAGS) + (mesh_segm_LDFLAGS, mesh_segm_LDADD) + (mesh_skel_SOURCES, mesh_skel_CPPFLAGS) + (mesh_skel_LDFLAGS, mesh_skel_LDADD): + Disable mesh-segm and mesh-skel. + +2008-12-30 Roland Levillain <roland(a)lrde.epita.fr> + Add a squared L2-norm. * mln/norm/l2.hh (mln::norm::internal::sqr_l2_(const V&)): diff --git a/milena/apps/statues/Makefile.am b/milena/apps/statues/Makefile.am index c38cfa8..0d1bfc1 100644 --- a/milena/apps/statues/Makefile.am +++ b/milena/apps/statues/Makefile.am @@ -25,17 +25,17 @@ LDADD_trimesh = -L$(top_builddir)/external/trimesh/libsrc -ltrimesh $(GLLIBS) ## Graph-based applications, depending on Trimesh. ## ## ------------------------------------------------ ## -bin_PROGRAMS = mesh-segm mesh-skel +# bin_PROGRAMS += mesh-segm mesh-skel +# +# mesh_segm_SOURCES = mesh-segm.cc io.hh +# mesh_segm_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_trimesh) +# mesh_segm_LDFLAGS = $(LDFLAGS_trimesh) +# mesh_segm_LDADD = $(LDADD_trimesh) -mesh_segm_SOURCES = mesh-segm.cc io.hh -mesh_segm_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_trimesh) -mesh_segm_LDFLAGS = $(LDFLAGS_trimesh) -mesh_segm_LDADD = $(LDADD_trimesh) - -mesh_skel_SOURCES = mesh-skel.cc io.hh -mesh_skel_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_trimesh) -mesh_skel_LDFLAGS = $(LDFLAGS_trimesh) -mesh_skel_LDADD = $(LDADD_trimesh) +# mesh_skel_SOURCES = mesh-skel.cc io.hh +# mesh_skel_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_trimesh) +# mesh_skel_LDFLAGS = $(LDFLAGS_trimesh) +# mesh_skel_LDADD = $(LDADD_trimesh) ## -------------------------------------------------- ## ## Complex-based applications, depending on Trimesh. ## -- 1.6.0.4
16Â years
1
0
0
0
3098: Add a squared L2-norm.
by Roland Levillain
* mln/norm/l2.hh (mln::norm::internal::sqr_l2_(const V&)): New function. (mln::norm::sqr_l2(const C (&vec)[n])) (mln::norm::sqr_l2(const algebra::vec<n,C>&)): New facades. --- milena/ChangeLog | 10 ++++++++++ milena/mln/norm/l2.hh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 0 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index a2f96af..8572d83 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,15 @@ 2008-12-30 Roland Levillain <roland(a)lrde.epita.fr> + Add a squared L2-norm. + + * mln/norm/l2.hh (mln::norm::internal::sqr_l2_(const V&)): + New function. + (mln::norm::sqr_l2(const C (&vec)[n])) + (mln::norm::sqr_l2(const algebra::vec<n,C>&)): + New facades. + +2008-12-30 Roland Levillain <roland(a)lrde.epita.fr> + Add a missing accessor in mln::p_complex. * mln/core/site_set/p_complex.hh diff --git a/milena/mln/norm/l2.hh b/milena/mln/norm/l2.hh index 397c7e7..03e1142 100644 --- a/milena/mln/norm/l2.hh +++ b/milena/mln/norm/l2.hh @@ -46,6 +46,13 @@ namespace mln { + // Forward declaration. + namespace algebra + { + template <unsigned n, typename T> class vec; + } + + namespace norm { @@ -58,6 +65,15 @@ namespace mln mln_sum(C) l2(const algebra::vec<n,C>& vec); /// \} + /// Squared L2-norm of a vector \a vec. + /// \{ + template <unsigned n, typename C> + mln_sum(C) sqr_l2(const C (&vec)[n]); + + template <unsigned n, typename C> + mln_sum(C) sqr_l2(const algebra::vec<n,C>& vec); + /// \} + /// L2-norm distance between vectors \a vec1 and \p vec2. /// \{ template <unsigned n, typename C> @@ -92,6 +108,17 @@ namespace mln template <unsigned n, typename C, typename V> inline mln_sum(C) + sqr_l2_(const V& vec) + { + mln_sum(C) m = 0; + for (unsigned i = 0; i < n; ++i) + m += mln::math::sqr(vec[i]); + return m; + } + + template <unsigned n, typename C, typename V> + inline + mln_sum(C) l2_distance_(const V& vec1, const V& vec2) { typedef mln_sum(C) D; @@ -127,6 +154,24 @@ namespace mln return impl::l2_<n, C>(vec); } + + template <unsigned n, typename C> + inline + mln_sum(C) + sqr_l2(const C (&vec)[n]) + { + return impl::sqr_l2_<n, C>(vec); + } + + template <unsigned n, typename C> + inline + mln_sum(C) + sqr_l2(const algebra::vec<n,C>& vec) + { + return impl::sqr_l2_<n, C>(vec); + } + + template <unsigned n, typename C> inline mln_sum(C) -- 1.6.0.4
16Â years
1
0
0
0
3097: Add a missing accessor in mln::p_complex.
by Roland Levillain
* mln/core/site_set/p_complex.hh (mln::p_complex::nfaces(unsigned)): New accessor. --- milena/ChangeLog | 7 +++++++ milena/mln/core/site_set/p_complex.hh | 12 +++++++++++- 2 files changed, 18 insertions(+), 1 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 9f8c3b6..a2f96af 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,12 @@ 2008-12-30 Roland Levillain <roland(a)lrde.epita.fr> + Add a missing accessor in mln::p_complex. + + * mln/core/site_set/p_complex.hh + (mln::p_complex::nfaces(unsigned)): New accessor. + +2008-12-30 Roland Levillain <roland(a)lrde.epita.fr> + Fix complex-based image-related #include's. * mln/core/internal/complex_neighborhood_base.hh: Include diff --git a/milena/mln/core/site_set/p_complex.hh b/milena/mln/core/site_set/p_complex.hh index f071f6a..cfeb0c2 100644 --- a/milena/mln/core/site_set/p_complex.hh +++ b/milena/mln/core/site_set/p_complex.hh @@ -151,8 +151,10 @@ namespace mln /// `known'.) unsigned nsites() const; - /// Return The number of faces in the complex. + /// Return the number of faces in the complex. unsigned nfaces() const; + /// Return the number of \a n-faces in the complex. + unsigned nfaces(unsigned n) const; // FIXME: Add nfaces(unsigned) routines? Yes, if this can // simplify (and lighten) the implementation of piters, psites, @@ -252,6 +254,14 @@ namespace mln template <unsigned D, typename G> inline + unsigned + p_complex<D, G>::nfaces(unsigned n) const + { + return cplx_.nfaces(n); + } + + template <unsigned D, typename G> + inline bool p_complex<D, G>::is_valid() const { -- 1.6.0.4
16Â years
1
0
0
0
3096: Fix complex-based image-related #include's.
by Roland Levillain
* mln/core/internal/complex_neighborhood_base.hh: Include mln/core/image/complex_neighborhood_piter.hh. * mln/core/internal/complex_window_p_base.hh: Include mln/core/image/complex_window_piter.hh --- milena/ChangeLog | 9 +++++++++ .../mln/core/internal/complex_neighborhood_base.hh | 1 + milena/mln/core/internal/complex_window_p_base.hh | 2 +- 3 files changed, 11 insertions(+), 1 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 10acf7f..9f8c3b6 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,14 @@ 2008-12-30 Roland Levillain <roland(a)lrde.epita.fr> + Fix complex-based image-related #include's. + + * mln/core/internal/complex_neighborhood_base.hh: Include + mln/core/image/complex_neighborhood_piter.hh. + * mln/core/internal/complex_window_p_base.hh: Include + mln/core/image/complex_window_piter.hh + +2008-12-30 Roland Levillain <roland(a)lrde.epita.fr> + Reorganize tests in apps/statues/. * apps/statues/test.in: Split into... diff --git a/milena/mln/core/internal/complex_neighborhood_base.hh b/milena/mln/core/internal/complex_neighborhood_base.hh index d422792..231170b 100644 --- a/milena/mln/core/internal/complex_neighborhood_base.hh +++ b/milena/mln/core/internal/complex_neighborhood_base.hh @@ -35,6 +35,7 @@ # include <mln/core/concept/neighborhood.hh> # include <mln/core/site_set/complex_psite.hh> +# include <mln/core/image/complex_neighborhood_piter.hh> // FIXME: Factor with mln::internal::complex_window_base. diff --git a/milena/mln/core/internal/complex_window_p_base.hh b/milena/mln/core/internal/complex_window_p_base.hh index c02ba4b..efc6ea9 100644 --- a/milena/mln/core/internal/complex_window_p_base.hh +++ b/milena/mln/core/internal/complex_window_p_base.hh @@ -35,10 +35,10 @@ # include <mln/core/concept/window.hh> # include <mln/core/site_set/complex_psite.hh> +# include <mln/core/image/complex_window_piter.hh> # include <mln/topo/centered_iter_adapter.hh> - // FIXME: Factor with mln::internal::complex_neighborhood_base. -- 1.6.0.4
16Â years
1
0
0
0
3095: Configure segmentation tests in milena/apps/statues/.
by Roland Levillain
* configure.ac: Configure milena/apps/statues/test-mesh-segm and milena/apps/statues/test-mesh-complex-segm. --- ChangeLog | 7 +++++++ configure.ac | 7 +++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 080f0e9..61c54b7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2008-12-30 Roland Levillain <roland(a)lrde.epita.fr> + Configure segmentation tests in milena/apps/statues/. + + * configure.ac: Configure milena/apps/statues/test-mesh-segm and + milena/apps/statues/test-mesh-complex-segm. + +2008-12-30 Roland Levillain <roland(a)lrde.epita.fr> + * COPYING: Fix indentation. 2008-12-22 Guillaume Lazzara <z(a)lrde.epita.fr> diff --git a/configure.ac b/configure.ac index 5d7b719..6a4c5a2 100644 --- a/configure.ac +++ b/configure.ac @@ -266,8 +266,11 @@ AC_CONFIG_FILES([ #]) # Configure tests. -AC_CONFIG_FILES([milena/apps/statues/test], - [chmod +x milena/apps/statues/test]) +# FIXME: Consider using `sed' instead of `configure' to create these tests. +AC_CONFIG_FILES([milena/apps/statues/test-mesh-segm], + [chmod +x milena/apps/statues/test-mesh-segm]) +AC_CONFIG_FILES([milena/apps/statues/test-mesh-complex-segm], + [chmod +x milena/apps/statues/test-mesh-complex-segm]) AC_OUTPUT -- 1.6.0.4
16Â years
1
0
0
0
3094: Reorganize tests in apps/statues/.
by Roland Levillain
* apps/statues/test.in: Split into... * apps/statues/test-mesh-segm.in, * apps/statues/test-mesh-complex-segm.in: ...these (new) files. * apps/statues/Makefile.am (TESTS): Adjust. --- milena/ChangeLog | 10 ++++++++++ milena/apps/statues/Makefile.am | 2 +- milena/apps/statues/test-mesh-complex-segm.in | 9 +++++++++ milena/apps/statues/test-mesh-segm.in | 9 +++++++++ milena/apps/statues/test.in | 13 ------------- 5 files changed, 29 insertions(+), 14 deletions(-) create mode 100644 milena/apps/statues/test-mesh-complex-segm.in create mode 100755 milena/apps/statues/test-mesh-segm.in delete mode 100755 milena/apps/statues/test.in diff --git a/milena/ChangeLog b/milena/ChangeLog index 4aaf4dc..10acf7f 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,13 @@ +2008-12-30 Roland Levillain <roland(a)lrde.epita.fr> + + Reorganize tests in apps/statues/. + + * apps/statues/test.in: Split into... + * apps/statues/test-mesh-segm.in, + * apps/statues/test-mesh-complex-segm.in: + ...these (new) files. + * apps/statues/Makefile.am (TESTS): Adjust. + 2008-12-30 Thierry Geraud <thierry.geraud(a)lrde.epita.fr> Fix warnings due to g++ -Wconversion option. diff --git a/milena/apps/statues/Makefile.am b/milena/apps/statues/Makefile.am index d1e65f7..c38cfa8 100644 --- a/milena/apps/statues/Makefile.am +++ b/milena/apps/statues/Makefile.am @@ -61,4 +61,4 @@ bin_PROGRAMS += mesh-complex-segm mesh_complex_segm_SOURCES = mesh-complex-segm.cc -TESTS = test +TESTS = test-mesh-segm test-mesh-complex-segm diff --git a/milena/apps/statues/test-mesh-complex-segm.in b/milena/apps/statues/test-mesh-complex-segm.in new file mode 100644 index 0000000..05a28ca --- /dev/null +++ b/milena/apps/statues/test-mesh-complex-segm.in @@ -0,0 +1,9 @@ +#! /bin/sh + +set -ex + +mesh_dir=@top_srcdir@/milena/mesh + +time ./mesh-complex-segm $mesh_dir/socket-max-curv.off 25 socket-max-curv-segm.off +time ./mesh-complex-segm $mesh_dir/teapot-max-curv.off 50 teapot-max-curv-segm.off +time ./mesh-complex-segm $mesh_dir/bunny-holefilled-pinv-curv.off 500 bunny-holefilled-pinv-curv-segm.off diff --git a/milena/apps/statues/test-mesh-segm.in b/milena/apps/statues/test-mesh-segm.in new file mode 100755 index 0000000..181a1fd --- /dev/null +++ b/milena/apps/statues/test-mesh-segm.in @@ -0,0 +1,9 @@ +#! /bin/sh + +set -ex + +mesh_dir=@top_srcdir@/milena/mesh + +time ./mesh-segm $mesh_dir/socket.off 25 socket-segm.off +time ./mesh-segm $mesh_dir/teapot.off 50 teapot-segm.off +time ./mesh-segm $mesh_dir/bunny-holefilled.off 500 bunny-holefilled-segm.off diff --git a/milena/apps/statues/test.in b/milena/apps/statues/test.in deleted file mode 100755 index 92c9d31..0000000 --- a/milena/apps/statues/test.in +++ /dev/null @@ -1,13 +0,0 @@ -#! /bin/sh - -set -ex - -mesh_dir=@top_srcdir@/milena/mesh - -time ./mesh-segm $mesh_dir/socket.off 25 socket-segm.off -time ./mesh-segm $mesh_dir/teapot.off 50 teapot-segm.off -time ./mesh-segm $mesh_dir/bunny-holefilled.off 500 bunny-holefilled-segm.off - -time ./mesh-complex-segm $mesh_dir/socket-max-curv.off 25 socket-max-curv-segm.off -time ./mesh-complex-segm $mesh_dir/teapot-max-curv.off 50 teapot-max-curv-segm.off -time ./mesh-complex-segm $mesh_dir/bunny-holefilled-pinv-curv.off 500 bunny-holefilled-pinv-curv-segm.off -- 1.6.0.4
16Â years
1
0
0
0
3093: COPYING: Fix indentation.
by Roland Levillain
--- COPYING | 2 +- ChangeLog | 4 ++++ 2 files changed, 5 insertions(+), 1 deletions(-) diff --git a/COPYING b/COPYING index 890f89a..8f0f085 100644 --- a/COPYING +++ b/COPYING @@ -2,7 +2,7 @@ Version 2, June 1991 Copyright (C) 1989, 1991, 2006 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. diff --git a/ChangeLog b/ChangeLog index 5f2cd3b..080f0e9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2008-12-30 Roland Levillain <roland(a)lrde.epita.fr> + + * COPYING: Fix indentation. + 2008-12-22 Guillaume Lazzara <z(a)lrde.epita.fr> Fix configure.ac and INSTALL files. -- 1.6.0.4
16Â years
1
0
0
0
3092: Fix warnings due to g++ -Wconversion option.
by Thierry Geraud
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog from Thierry Geraud <thierry.geraud(a)lrde.epita.fr> Fix warnings due to g++ -Wconversion option. * mln/core/site_set/box.hh, * mln/core/site_set/p_line2d.hh, * mln/core/image/extension_val.hh, * mln/math/jacobi.hh, * mln/level/transform.hh, * mln/data/paste.spe.hh, * mln/data/fill_with_image.hh, * mln/data/fill_with_value.spe.hh, * mln/data/fill.hh, * mln/data/paste.hh, * mln/data/fill_with_value.hh, * mln/linear/gaussian.hh, * mln/accu/convolve.hh, * mln/value/ops.hh, * mln/value/int_u_sat.hh, * mln/border/mirror.hh, * mln/convert/to_image.hh, * mln/geom/essential.hh, * mln/fun/v2v/inc.hh, * mln/fun/v2v/cast.hh, * mln/fun/v2v/linear.hh, * mln/fun/v2v/dec.hh, * mln/win/cuboid3d.hh, * mln/win/cube3d.hh, * mln/algebra/quat.hh, * mln/algebra/vec.hh, * mln/io/pbm/load.hh, * mln/norm/linfty.hh, * mln/norm/l1.hh, * mln/norm/l2.hh, * mln/canvas/browsing/snake_fwd.hh, * mln/canvas/browsing/dir_struct_elt_incr_update.hh, * tests/opt/at.cc, * tests/level/transform_inplace.cc, * tests/level/transform.cc, * tests/level/sort_psites.cc, * tests/level/Makefile.am, * tests/data/paste.cc, * tests/data/fill_with_image.cc, * tests/linear/convolve.cc, * tests/linear/convolve_directional.cc, * tests/linear/gaussian.cc, * tests/norm/l2.cc, * tests/norm/common.hh, * tests/norm/linfty.cc: Fix warning with Wconversion. Upgrade file doc style. Layout. Remove a couple of (full of crap) files. * mln/geom/resize.hh: Remove. * mln/geom/all.hh: Update. * tests/geom/resize.cc: Remove. * tests/geom/Makefile.am: Update. * tests/level/sort_psites_full.cc: Remove. mln/accu/convolve.hh | 6 - mln/algebra/quat.hh | 25 ++-- mln/algebra/vec.hh | 2 mln/border/mirror.hh | 16 +- mln/canvas/browsing/dir_struct_elt_incr_update.hh | 8 - mln/canvas/browsing/snake_fwd.hh | 2 mln/convert/to_image.hh | 8 - mln/core/image/extension_val.hh | 18 +-- mln/core/site_set/box.hh | 8 - mln/core/site_set/p_line2d.hh | 20 ++- mln/data/fill.hh | 12 +- mln/data/fill_with_image.hh | 15 +- mln/data/fill_with_value.hh | 2 mln/data/fill_with_value.spe.hh | 9 - mln/data/paste.hh | 17 +- mln/data/paste.spe.hh | 11 - mln/fun/v2v/cast.hh | 14 +- mln/fun/v2v/dec.hh | 11 - mln/fun/v2v/inc.hh | 11 - mln/fun/v2v/linear.hh | 26 +++- mln/geom/all.hh | 5 mln/geom/essential.hh | 13 +- mln/io/pbm/load.hh | 2 mln/level/transform.hh | 18 +-- mln/linear/gaussian.hh | 129 +++++++++++----------- mln/math/jacobi.hh | 51 ++++---- mln/norm/l1.hh | 29 +++- mln/norm/l2.hh | 29 +++- mln/norm/linfty.hh | 15 +- mln/value/int_u_sat.hh | 20 +-- mln/value/ops.hh | 22 ++- mln/win/cube3d.hh | 18 +-- mln/win/cuboid3d.hh | 21 ++- tests/data/fill_with_image.cc | 6 - tests/data/paste.cc | 6 - tests/geom/Makefile.am | 2 tests/level/Makefile.am | 4 tests/level/sort_psites.cc | 19 +-- tests/level/transform.cc | 16 +- tests/level/transform_inplace.cc | 61 +++++----- tests/linear/convolve.cc | 22 +-- tests/linear/convolve_directional.cc | 10 - tests/linear/gaussian.cc | 10 - tests/norm/common.hh | 18 ++- tests/norm/l2.cc | 15 +- tests/norm/linfty.cc | 14 +- tests/opt/at.cc | 8 - 47 files changed, 449 insertions(+), 375 deletions(-) Index: mln/core/site_set/box.hh --- mln/core/site_set/box.hh (revision 3091) +++ mln/core/site_set/box.hh (working copy) @@ -314,8 +314,8 @@ mln_precondition(is_valid()); for (unsigned i = 0; i < P::dim; ++i) { - pmin_[i] -= b; - pmax_[i] += b; + pmin_[i] = static_cast<mln_coord(P)>(pmin_[i] - b); + pmax_[i] = static_cast<mln_coord(P)>(pmax_[i] + b); } mln_postcondition(is_valid()); } @@ -326,8 +326,8 @@ box<P>::enlarge(unsigned dim, unsigned b) { mln_precondition(is_valid()); - pmin_[dim] -= b; - pmax_[dim] += b; + pmin_[dim] = static_cast<mln_coord(P)>(pmin_[dim] - b); + pmax_[dim] = static_cast<mln_coord(P)>(pmax_[dim] + b); mln_postcondition(is_valid()); } Index: mln/core/site_set/p_line2d.hh --- mln/core/site_set/p_line2d.hh (revision 3091) +++ mln/core/site_set/p_line2d.hh (working copy) @@ -1,4 +1,5 @@ // Copyright (C) 2007, 2008 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 @@ -35,7 +36,11 @@ # include <mln/core/site_set/p_array.hh> # include <mln/core/alias/box2d.hh> -# include <mln/math/all.hh> + +# include <mln/math/sign.hh> +# include <mln/math/abs.hh> +# include <mln/math/min.hh> +# include <mln/math/max.hh> namespace mln @@ -187,7 +192,8 @@ int e = ddrow - dcol; for (int i = 0; i < dcol; ++i) { - arr_.append(point2d(row, col)); + arr_.append(point2d(static_cast<def::coord>(row), + static_cast<def::coord>(col))); while (e >= 0) { row += srow; @@ -202,7 +208,8 @@ int e = ddcol - drow; for (int i = 0; i < drow; ++i) { - arr_.append(point2d(row, col)); + arr_.append(point2d(static_cast<def::coord>(row), + static_cast<def::coord>(col))); while (e >= 0) { col += scol; @@ -213,7 +220,8 @@ } } if (! is_end_excluded) - arr_.append(point2d(row, col)); + arr_.append(point2d(static_cast<def::coord>(row), + static_cast<def::coord>(col))); // Compute bb_. point2d end_ = arr_[arr_.nsites() - 1]; @@ -280,8 +288,8 @@ p_line2d::to_vec() const { algebra::vec<2, float> res; - res[0] = end().row() - begin().row(); - res[1] = end().col() - begin().col(); + res[0] = float(end().row() - begin().row()); + res[1] = float(end().col() - begin().col()); return res; } Index: mln/core/image/extension_val.hh --- mln/core/image/extension_val.hh (revision 3091) +++ mln/core/image/extension_val.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory +// Copyright (C) 2008 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 @@ -28,14 +28,12 @@ #ifndef MLN_CORE_IMAGE_EXTENSION_VAL_HH # define MLN_CORE_IMAGE_EXTENSION_VAL_HH -/*! - * \file mln/core/image/extension_val.hh - * - * \brief Definition of a morpher that extends the domain of an image. - * - * \todo Use the 'instant' mechanism. - * \todo Use an envelop as lvalue to test extension writing. - */ +/// \file mln/core/image/extension_val.hh +/// +/// \brief Definition of a morpher that extends the domain of an image. +/// +/// \todo Use the 'instant' mechanism. +/// \todo Use an envelop as lvalue to test extension writing. # include <mln/core/internal/image_identity.hh> @@ -267,7 +265,7 @@ void init_(tag::extension_t, V& target, const extension_val<I>& model) { mlc_converts_to(mln_value(I), V)::check(); - target = model.extension(); + target = static_cast<V>(model.extension()); } # endif // ! MLN_INCLUDE_ONLY Index: mln/math/jacobi.hh --- mln/math/jacobi.hh (revision 3091) +++ mln/math/jacobi.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory +// Copyright (C) 2008 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 @@ -28,12 +28,17 @@ #ifndef MLN_MATH_JACOBI_HH # define MLN_MATH_JACOBI_HH +/// \file mln/math/jacobi.hh + +# include <cmath> + # include <mln/algebra/quat.hh> # include <mln/algebra/mat.hh> // from num. rec. in C // FIXME: what about numrec licence? + namespace mln { @@ -42,12 +47,14 @@ algebra::quat jacobi(algebra::mat < 4, 4, float >a); + # ifndef MLN_INCLUDE_ONLY // FIXME: nD ? #define rotateJacobi(a,i,j,k,l) g=a(i,j);h=a(k,l);a(i,j)=g-s*(h+g*tau); \ a(k,l)=h+s*(g-h*tau) + algebra::quat jacobi(algebra::mat < 4, 4, float >a) { float dd, d[4]; @@ -57,23 +64,23 @@ for (ip = 0; ip < 4; ip++) { for (iq = 0; iq < 4; iq++) - v(ip, iq) = 0.0; - v(ip, ip) = 1.0; + v(ip, iq) = 0.0f; + v(ip, ip) = 1.0f; } for (ip = 0; ip < 4; ip++) { b[ip] = d[ip] = a(ip, ip); - z[ip] = 0.0; + z[ip] = 0.0f; } while (1) { - sm = 0.0; + sm = 0.0f; for (ip = 0; ip < 3; ip++) { for (iq = ip + 1; iq < 4; iq++) - sm += fabs(a(ip, iq)); + sm += std::fabs(a(ip, iq)); } - if (sm < 1e-12) + if (sm < 1e-12f) { // 1e-12 dd = d[0]; iq = 0; @@ -90,7 +97,7 @@ if (i < 4) { i++; - tresh = 0.0125 * sm; + tresh = 0.0125f * sm; } else tresh = 0.0; @@ -98,27 +105,26 @@ { for (iq = ip + 1; iq < 4; iq++) { - g = 100.0 * fabs(a(ip, iq)); - if (i > 4 && (float)(fabs(d[ip])+g) == - (float)fabs(d[ip]) - && (float)(fabs(d[iq])+g) == (float)fabs(d[iq])) - a(ip, iq) = 0.0; - else if (fabs(a(ip, iq)) > tresh) + g = 100.0f * std::fabs(a(ip, iq)); + if (i > 4 && std::fabs(d[ip]) + g == std::fabs(d[ip]) + && std::fabs(d[iq]) + g == std::fabs(d[iq])) + a(ip, iq) = 0.0f; + else if (std::fabs(a(ip, iq)) > tresh) { h = d[iq] - d[ip]; - if ((float)(fabs(h)+g) == (float)fabs(h)) // unsafe? + if (std::fabs(h) + g == std::fabs(h)) // unsafe? t = (a(ip, iq)) / h; else { - theta = 0.5 * h / (a(ip, iq)); - t = 1.0 / (fabs(theta) + sqrt(1.0 + + theta = 0.5f * h / (a(ip, iq)); + t = 1.0f / (std::fabs(theta) + std::sqrt(1.0f + theta * theta)); - if (theta < 0.0) + if (theta < 0.0f) t = -t; } - c = 1.0 / sqrt(1 + t * t); + c = 1.0f / std::sqrt(1 + t * t); s = t * c; - tau = s / (1.0 + c); + tau = s / (1.0f + c); h = t * a(ip, iq); z[ip] -= h; z[iq] += h; @@ -140,7 +146,7 @@ { b[ip] += z[ip]; d[ip] = b[ip]; - z[ip] = 0.0; + z[ip] = 0.0f; } } } @@ -151,5 +157,6 @@ } // end of namespace mln -#endif /* MLN_MATH_JACOBI_HH */ + +#endif // ! MLN_MATH_JACOBI_HH Index: mln/level/transform.hh --- mln/level/transform.hh (revision 3091) +++ mln/level/transform.hh (working copy) @@ -29,14 +29,13 @@ #ifndef MLN_LEVEL_TRANSFORM_HH # define MLN_LEVEL_TRANSFORM_HH -/*! \file mln/level/transform.hh - * - * \brief Transform the contents of an image into another one. - * - * \todo Clean this file + overload with pixel iterators. - * - * \todo Re-activate tests and make them static. - */ +/// \file mln/level/transform.hh +/// +/// Transform the contents of an image into another one. +/// +/// \todo Clean this file + overload with pixel iterators. +/// +/// \todo Re-activate tests and make them static. # include <mln/core/concept/image.hh> # include <mln/core/concept/function.hh> @@ -145,9 +144,6 @@ mln_ch_value(I, mln_result(F)) output; initialize(output, input); - mlc_is(mln_trait_image_pw_io(mln_ch_value(I, mln_result(F))), - trait::image::pw_io::read_write)::check(); - mln_piter(I) p(input.domain()); for_all(p) output(p) = f(input(p)); Index: mln/data/paste.spe.hh --- mln/data/paste.spe.hh (revision 3091) +++ mln/data/paste.spe.hh (working copy) @@ -1,4 +1,5 @@ // Copyright (C) 2007, 2008 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 @@ -28,11 +29,9 @@ #ifndef MLN_DATA_PASTE_SPE_HH # define MLN_DATA_PASTE_SPE_HH -/*! \file mln/data/paste.spe.hh - * - * \brief Specializations for mln::data::paste. - * - */ +/// \file mln/data/paste.spe.hh +/// +/// Specializations for mln::data::paste. # ifndef MLN_DATA_PASTE_HH # error "Forbidden inclusion of *.spe.hh" @@ -89,7 +88,7 @@ po.start(); for_all(pi) { - po.val() = pi.val(); + po.val() = static_cast<mln_value(J)>(pi.val()); po.next(); } trace::exiting("data::impl::paste_fast"); Index: mln/data/fill_with_image.hh --- mln/data/fill_with_image.hh (revision 3091) +++ mln/data/fill_with_image.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory +// Copyright (C) 2008 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 @@ -28,12 +28,11 @@ #ifndef MLN_DATA_FILL_WITH_IMAGE_HH # define MLN_DATA_FILL_WITH_IMAGE_HH -/*! \file mln/data/fill_with_image.hh - * - * \brief Fill an image with the values from another image. - * - * \todo Specialize with line_piter... - */ +/// \file mln/data/fill_with_image.hh +/// +/// Fill an image with the values from another image. +/// +/// \todo Specialize with line_piter... # include <mln/core/concept/image.hh> @@ -107,7 +106,7 @@ mln_piter(I) p(ima.domain()); for_all(p) - ima(p) = data(p); + ima(p) = static_cast<mln_value(I)>(data(p)); trace::exiting("data::impl::generic::fill_with_image"); } Index: mln/data/fill_with_value.spe.hh --- mln/data/fill_with_value.spe.hh (revision 3091) +++ mln/data/fill_with_value.spe.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory +// Copyright (C) 2008 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,8 +29,8 @@ # define MLN_DATA_FILL_WITH_VALUE_SPE_HH /// \file mln/data/fill_with_value.spe.hh -/// Specializations for mln::data::fill_with_value. /// +/// Specializations for mln::data::fill_with_value. # ifndef MLN_DATA_FILL_WITH_VALUE_HH # error "Forbidden inclusion of *.spe.hh" @@ -87,7 +87,8 @@ mlc_is(mln_trait_image_value_access(I), trait::image::value_access::direct))::check(); - data::memset_(ima, ima.point_at_index(0), val, ima.nelements()); + mln_value(I) v = static_cast<mln_value(I)>(val); + data::memset_(ima, ima.point_at_index(0), v, ima.nelements()); trace::exiting("data::impl::fill_with_value_one_block"); } @@ -123,7 +124,7 @@ mlc_is(mln_trait_image_vw_io(I), trait::image::vw_io::read_write))::check(); - ima.val() = val; + ima.val() = static_cast<mln_value(I)>(val); trace::exiting("data::impl::fill_with_value_singleton"); } Index: mln/data/fill.hh --- mln/data/fill.hh (revision 3091) +++ mln/data/fill.hh (working copy) @@ -1,4 +1,5 @@ // Copyright (C) 2007, 2008 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 @@ -28,12 +29,11 @@ #ifndef MLN_DATA_FILL_HH # define MLN_DATA_FILL_HH -/*! \file mln/data/fill.hh - * - * \brief Fill an image, that is, set pixel values. - * - * \todo Add a conversion "arr->fun" then get rid of the C array overload. - */ +/// \file mln/data/fill.hh +/// +/// Fill an image, that is, set pixel values. +/// +/// \todo Add a conversion "arr->fun" then get rid of the C array overload. # include <mln/core/concept/function.hh> # include <mln/pw/image.hh> Index: mln/data/paste.hh --- mln/data/paste.hh (revision 3091) +++ mln/data/paste.hh (working copy) @@ -1,4 +1,5 @@ // Copyright (C) 2007, 2008 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 @@ -28,16 +29,12 @@ #ifndef MLN_DATA_PASTE_HH # define MLN_DATA_PASTE_HH -/*! \file mln/data/paste.hh - * - * \brief Paste the contents of an image into another one. - * - */ +/// \file mln/data/paste.hh +/// +/// Paste the contents of an image into another one. # include <mln/core/concept/image.hh> - - // Specializations are in: # include <mln/data/paste.spe.hh> @@ -65,10 +62,8 @@ /// /// \pre \p input.domain <= \p output.domain /// - /// \{ template <typename I, typename J> void paste(const Image<I>& input, Image<J>& output); - /// \} @@ -95,6 +90,7 @@ } // end of namespace mln::data::internal + namespace impl { @@ -115,7 +111,7 @@ mln_piter(I) p(input.domain()); for_all(p) - output(p) = input(p); + output(p) = static_cast<mln_value(J)>(input(p)); trace::exiting("data::impl::generic::paste"); } @@ -133,7 +129,6 @@ { trace::entering("data::paste"); - internal::paste_tests(input, output); internal::paste_(input, output); Index: mln/data/fill_with_value.hh --- mln/data/fill_with_value.hh (revision 3091) +++ mln/data/fill_with_value.hh (working copy) @@ -104,7 +104,7 @@ mlc_is(mln_trait_image_pw_io(I), trait::image::pw_io::read_write)::check(); - mln_value(I) v = exact(val); + mln_value(I) v = static_cast<mln_value(I)>(exact(val)); mln_piter(I) p(ima.domain()); for_all(p) ima(p) = v; Index: mln/linear/gaussian.hh --- mln/linear/gaussian.hh (revision 3091) +++ mln/linear/gaussian.hh (working copy) @@ -33,26 +33,21 @@ /// /// Gaussian filter. /// -/// \todo Add a clean reference David Deriche +/// \todo Add a clean reference Rachid Deriche /// Recursively implementing the gaussian and its derivatives (1993) +# include <vector> +# include <cmath> + # include <mln/core/concept/image.hh> # include <mln/core/alias/point2d.hh> -# include <mln/data/paste.hh> +# include <mln/extension/adjust_fill.hh> # include <mln/geom/ncols.hh> # include <mln/geom/nrows.hh> - -# include <mln/trait/image/props.hh> - -# include <mln/extension/adjust_fill.hh> +# include <mln/data/paste.hh> # include <mln/level/stretch.hh> - # include <mln/algebra/vec.hh> -# include <vector> -# include <cmath> - -# include <mln/debug/println.hh> namespace mln { @@ -111,10 +106,10 @@ w0 /= s; w1 /= s; - float sin0 = sin(w0); - float sin1 = sin(w1); - float cos0 = cos(w0); - float cos1 = cos(w1); + float sin0 = std::sin(w0); + float sin1 = std::sin(w1); + float cos0 = std::cos(w0); + float cos1 = std::cos(w1); int sign = 1; float n_ = norm(a0, a1, b0, b1, c0, c1, cos0, sin0, cos1, sin1, sign); @@ -125,37 +120,37 @@ c1 /= n_; n[3] = - exp(-b1 - 2*b0) * (c1 * sin1 - cos1 * c0) + - exp(-b0 - 2*b1) * (a1 * sin0 - cos0 * a0); + std::exp(-b1 - 2*b0) * (c1 * sin1 - cos1 * c0) + + std::exp(-b0 - 2*b1) * (a1 * sin0 - cos0 * a0); n[2] = - 2 * exp(-b0 - b1) * ((a0 + c0) * cos1 * cos0 - + 2 * std::exp(-b0 - b1) * ((a0 + c0) * cos1 * cos0 - cos1 * a1 * sin0 - cos0 * c1 * sin1) + - c0 * exp(-2*b0) + a0 * exp(-2*b1); + c0 * std::exp(-2*b0) + a0 * std::exp(-2*b1); n[1] = - exp(-b1) * (c1 * sin1 - (c0 + 2 * a0) * cos1) + - exp(-b0) * (a1 * sin0 - (2 * c0 + a0) * cos0); + std::exp(-b1) * (c1 * sin1 - (c0 + 2 * a0) * cos1) + + std::exp(-b0) * (a1 * sin0 - (2 * c0 + a0) * cos0); n[0] = a0 + c0; d[4] = - exp(-2 * b0 - 2 * b1); + std::exp(-2 * b0 - 2 * b1); d[3] = - -2 * cos0 * exp(-b0 - 2*b1) - - 2 * cos1 * exp(-b1 - 2*b0); + -2 * cos0 * std::exp(-b0 - 2*b1) - + 2 * cos1 * std::exp(-b1 - 2*b0); d[2] = - 4 * cos1 * cos0 * exp(-b0 - b1) + - exp(-2*b1) + exp(-2*b0); + 4 * cos1 * cos0 * std::exp(-b0 - b1) + + std::exp(-2*b1) + std::exp(-2*b0); d[1] = - -2 * exp(-b1) * cos1 - 2 * exp(-b0) * cos0; + -2 * std::exp(-b1) * cos1 - 2 * std::exp(-b0) * cos0; for (unsigned i = 1; i <= 3; ++i) { dm[i] = d[i]; - nm[i] = sign * (n[i] - d[i] * n[0]); + nm[i] = float(sign) * (n[i] - d[i] * n[0]); } dm[4] = d[4]; - nm[4] = sign * (-d[4] * n[0]); + nm[4] = float(sign) * (-d[4] * n[0]); } @@ -267,14 +262,14 @@ float cos1, float sin1, int& sign) { - float expb0 = exp(b0); - float exp2b0 = exp(2.0 * b0); + float expb0 = std::exp(b0); + float exp2b0 = std::exp(2.f * b0); float scale0 = 1 + exp2b0 - 2 * cos0 * expb0; float scaleA = 2 * a1 * sin0 * expb0 - a0 * (1 - exp2b0); - float expb1 = exp(b1); - float exp2b1 = exp(2.0 * b1); + float expb1 = std::exp(b1); + float exp2b1 = std::exp(2.f * b1); float scale1 = 1 + exp2b1 - 2 * cos1 * expb1; float scaleC = 2 * c1 * sin1 * expb1 - c0 * (1 - exp2b1); @@ -295,16 +290,16 @@ float cos1, float sin1, int& sign) { - float expb0 = exp(b0); - float exp2b0 = exp(2.0 * b0); + float expb0 = std::exp(b0); + float exp2b0 = std::exp(2.f * b0); float scale0 = 1 + exp2b0 - 2 * cos0 * expb0; scale0 *= scale0; float scaleA = - 2 * a1 * sin0 * expb0 * (1 - exp2b0) + 2 * a0 * expb0 * (2 * expb0 - cos0 * (1 + exp2b0)); - float expb1 = exp(b1); - float exp2b1 = exp(2.0 * b1); + float expb1 = std::exp(b1); + float exp2b1 = std::exp(2.f * b1); float scale1 = 1 + exp2b1 - 2 * cos1 * expb1; scale1 *= scale1; @@ -327,8 +322,8 @@ float cos1, float sin1, int& sign) { - float expb0 = exp(b0); - float exp2b0 = exp(2.0 * b0); + float expb0 = std::exp(b0); + float exp2b0 = std::exp(2.f * b0); float scale0 = 1 + exp2b0 - 2 * cos0 * expb0; scale0 *= scale0 * scale0; @@ -338,8 +333,8 @@ a0 * expb0 * (2 * expb0 * (2 - cos0 * cos0) * (1 - exp2b0) - cos0 * (1 - exp2b0 * exp2b0)); - float expb1 = exp(b1); - float exp2b1 = exp(2.0 * b1); + float expb1 = std::exp(b1); + float exp2b1 = std::exp(2.f * b1); float scale1 = 1 + exp2b1 - 2 * cos1 * expb1; scale1 *= scale1 * scale1; @@ -368,9 +363,9 @@ recursivefilter_<mln_value(I)>(img, coef, - point1d(-img.border()), - point1d(geom::ninds(img) - 1 + - img.border()), + point1d(static_cast<def::coord>(-img.border())), + point1d(static_cast<def::coord>(geom::ninds(img) - 1 + + img.border())), geom::ninds(img) + 2 * img.border(), dpoint1d(1)); } @@ -391,9 +386,11 @@ // Apply on rows. for (unsigned j = 0; j < geom::ncols(img); ++j) recursivefilter_<mln_value(I)>(img, coef, - point2d(-img.border(), j), - point2d(geom::nrows(img) - 1 + - img.border(), j), + point2d(static_cast<def::coord>(-img.border()), + static_cast<def::coord>(j)), + point2d(static_cast<def::coord>(geom::nrows(img) - 1 + + img.border()), + static_cast<def::coord>(j)), geom::nrows(img) + 2 * img.border(), dpoint2d(1, 0)); } @@ -403,9 +400,11 @@ // Apply on columns. for (unsigned i = 0; i < geom::nrows(img); ++i) recursivefilter_<mln_value(I)>(img, coef, - point2d(i, -img.border()), - point2d(i, geom::ncols(img) - 1 + - img.border()), + point2d(static_cast<def::coord>(i), + static_cast<def::coord>(-img.border())), + point2d(static_cast<def::coord>(i), + static_cast<def::coord>(geom::ncols(img) - 1 + + img.border())), geom::ncols(img) + 2 * img.border(), dpoint2d(0, 1)); } @@ -426,9 +425,13 @@ for (unsigned j = 0; j < geom::nrows(img); ++j) for (unsigned k = 0; k < geom::ncols(img); ++k) recursivefilter_<mln_value(I)>(img, coef, - point3d(-img.border(), j , k), - point3d(geom::nslis(img) - 1 + - img.border(), j, k), + point3d(static_cast<def::coord>(-img.border()), + static_cast<def::coord>(j), + static_cast<def::coord>(k)), + point3d(static_cast<def::coord>(geom::nslis(img) - 1 + + img.border()), + static_cast<def::coord>(j), + static_cast<def::coord>(k)), geom::nslis(img) + 2 * img.border(), dpoint3d(1, 0, 0)); @@ -441,9 +444,13 @@ for (unsigned i = 0; i < geom::nslis(img); ++i) for (unsigned k = 0; k < geom::ncols(img); ++k) recursivefilter_<mln_value(I)>(img, coef, - point3d(i, -img.border(), k), - point3d(i, geom::nrows(img) - 1 + - img.border(), k), + point3d(static_cast<def::coord>(i), + static_cast<def::coord>(-img.border()), + static_cast<def::coord>(k)), + point3d(static_cast<def::coord>(i), + static_cast<def::coord>(geom::nrows(img) - 1 + + img.border()), + static_cast<def::coord>(k)), geom::nrows(img) + 2 * img.border(), dpoint3d(0, 1, 0)); @@ -455,9 +462,13 @@ for (unsigned i = 0; i < geom::nslis(img); ++i) for (unsigned j = 0; j < geom::nrows(img); ++i) recursivefilter_<mln_value(I)>(img, coef, - point3d(i, j, -img.border()), - point3d(i, j, geom::ncols(img) - - 1 + img.border()), + point3d(static_cast<def::coord>(i), + static_cast<def::coord>(j), + static_cast<def::coord>(-img.border())), + point3d(static_cast<def::coord>(i), + static_cast<def::coord>(j), + static_cast<def::coord>(geom::ncols(img) - + 1 + img.border())), geom::ncols(img) + 2 * img.border(), dpoint3d(0, 0, 1)); Index: mln/accu/convolve.hh --- mln/accu/convolve.hh (revision 3091) +++ mln/accu/convolve.hh (working copy) @@ -103,7 +103,7 @@ void convolve<T1,T2,R>::take(const argument& t) { - s_ += t.first * t.second; + s_ = static_cast<S>(s_ + static_cast<S>(t.first) * static_cast<S>(t.second)); } template <typename T1, typename T2, typename R> @@ -111,7 +111,7 @@ void convolve<T1,T2,R>::take(const T1& t1, const T2& t2) { - s_ += t1 * t2; + s_ = static_cast<S>(s_ + static_cast<S>(t1) * static_cast<S>(t2)); } template <typename T1, typename T2, typename R> @@ -119,7 +119,7 @@ void convolve<T1,T2,R>::take(const convolve<T1,T2,R>& other) { - s_ += other.s_; + s_ = static_cast<S>(s_ + other.s_); } template <typename T1, typename T2, typename R> Index: mln/value/ops.hh --- mln/value/ops.hh (revision 3091) +++ mln/value/ops.hh (working copy) @@ -1,4 +1,5 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -28,10 +29,9 @@ #ifndef MLN_VALUE_OPS_HH # define MLN_VALUE_OPS_HH -/*! \file mln/value/ops.hh - * - * \brief Definitions of operators for value types. - */ +/// \file mln/value/ops.hh +/// +/// Definitions of operators for value types. # include <mln/trait/op/all.hh> # include <mln/value/builtin/all.hh> @@ -216,7 +216,8 @@ mln_trait_op_plus(Vl, Vr) operator + (const value::Scalar<Vl>& lhs, const value::Scalar<Vr>& rhs) { - return value::equiv(lhs) + value::equiv(rhs); + typedef mln_trait_op_plus(Vl, Vr) R; + return static_cast<R>(value::equiv(lhs)) + static_cast<R>(value::equiv(rhs)); } template <typename Vl, typename Vr> @@ -224,7 +225,8 @@ mln_trait_op_minus(Vl, Vr) operator - (const value::Scalar<Vl>& lhs, const value::Scalar<Vr>& rhs) { - return value::equiv(lhs) - value::equiv(rhs); + typedef mln_trait_op_minus(Vl, Vr) R; + return static_cast<R>(value::equiv(lhs)) - static_cast<R>(value::equiv(rhs)); } template <typename Vl, typename Vr> @@ -232,7 +234,8 @@ mln_trait_op_times(Vl, Vr) operator * (const value::Scalar<Vl>& lhs, const value::Scalar<Vr>& rhs) { - return value::equiv(lhs) * value::equiv(rhs); + typedef mln_trait_op_times(Vl, Vr) R; + return static_cast<R>(value::equiv(lhs)) * static_cast<R>(value::equiv(rhs)); } template <typename Vl, typename Vr> @@ -256,7 +259,8 @@ mln_trait_op_uminus(S) operator - (const value::scalar_<S>& rhs) { - return - rhs.to_equiv(); + typedef mln_trait_op_uminus(S) R; + return static_cast<R>(- rhs.to_equiv()); } template <typename S, typename O> Index: mln/value/int_u_sat.hh --- mln/value/int_u_sat.hh (revision 3091) +++ mln/value/int_u_sat.hh (working copy) @@ -29,11 +29,10 @@ #ifndef MLN_VALUE_INT_U_SAT_HH # define MLN_VALUE_INT_U_SAT_HH -/*! \file mln/value/int_u_sat.hh - * - * \brief Define a generic class for unsigned integers with saturation - * behavior. - */ +/// \file mln/value/int_u_sat.hh +/// +/// Define a generic class for unsigned integers with saturation +/// behavior. # include <mln/metal/math/pow.hh> # include <mln/value/internal/value_like.hh> @@ -117,6 +116,9 @@ /// Self subtraction. int_u_sat<n>& operator-=(int i); + + private: + typedef mln_enc(int_u<n>) enc_; }; @@ -155,9 +157,9 @@ // Explicitly cast I to unsigned to avoid a warning between // signed and unsigned values from the compiler. else if (static_cast<unsigned>(i) > max_) - this->v_ = max_; + this->v_ = static_cast<enc_>(max_); else - this->v_ = i; + this->v_ = static_cast<enc_>(i); } template <unsigned n> @@ -178,9 +180,9 @@ // Explicitly cast I to unsigned to avoid a warning between // signed and unsigned values from the compiler. else if (static_cast<unsigned>(i) > max_) - this->v_ = max_; + this->v_ = static_cast<enc_>(max_); else - this->v_ = i; + this->v_ = static_cast<enc_>(i); return *this; } Index: mln/border/mirror.hh --- mln/border/mirror.hh (revision 3091) +++ mln/border/mirror.hh (working copy) @@ -81,9 +81,10 @@ trace::entering("border::impl::mirror_"); I& ima = const_cast<I&>(ima_); - unsigned border = ima.border(); - unsigned nbinds = geom::ninds(ima); - unsigned min; + def::coord + border = static_cast<def::coord>(ima.border()), + nbinds = static_cast<def::coord>(geom::ninds(ima)), + min; if (border > nbinds) min = nbinds; @@ -92,18 +93,19 @@ /// left border { - unsigned i = 0; + def::coord i = 0; for (; i < min; ++i) ima.element(border - 1 - i) = ima(point1d(i)); for (; i < border; ++i) - ima.element(border - 1 - i) = ima(point1d(min - 1)); + ima.element(border - 1 - i) = ima(point1d(static_cast<def::coord>(min - 1))); } /// right border { - unsigned i = 0, - j = nbinds - 1; + def::coord + i = 0, + j = static_cast<def::coord>(nbinds - 1); for (; i < min; ++i, --j) Index: mln/convert/to_image.hh --- mln/convert/to_image.hh (revision 3091) +++ mln/convert/to_image.hh (working copy) @@ -140,10 +140,12 @@ image1d<unsigned> to_image(const histo::data<T>& h) { - T v_min = h.vset()[0], - v_max = h.vset()[h.vset().nvalues() - 1]; + def::coord + n = static_cast<def::coord>(h.vset().nvalues()), + v_min = static_cast<def::coord>(h.vset()[0]), + v_max = static_cast<def::coord>(h.vset()[n - 1]); image1d<unsigned> ima(make::box1d(v_min, v_max)); - for (unsigned i = 0; i < h.vset().nvalues(); ++i) + for (def::coord i = 0; i < n; ++i) ima(point1d(i)) = h[i]; return ima; } Index: mln/geom/essential.hh --- mln/geom/essential.hh (revision 3091) +++ mln/geom/essential.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory +// Copyright (C) 2008 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 @@ -28,10 +28,9 @@ #ifndef MLN_GEOM_ESSENTIAL_HH # define MLN_GEOM_ESSENTIAL_HH -/*! \file mln/geom/essential.hh - * - * \brief File that includes essential geometry related things. - */ +/// \file mln/geom/essential.hh +/// +/// File that includes essential geometry related things. namespace mln @@ -43,12 +42,11 @@ /// Implementation namespace of geom namespace. namespace impl {} } - } + # include <mln/geom/bbox.hh> # include <mln/geom/chamfer.hh> -# include <mln/geom/resize.hh> # include <mln/geom/size1d.hh> # include <mln/geom/size2d.hh> # include <mln/geom/size3d.hh> @@ -64,4 +62,5 @@ # include <mln/geom/min_row.hh> # include <mln/geom/min_sli.hh> + #endif // ! MLN_GEOM_ESSENTIAL_HH Index: mln/geom/all.hh --- mln/geom/all.hh (revision 3091) +++ mln/geom/all.hh (working copy) @@ -1,4 +1,5 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2007, 2008 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 @@ -63,11 +64,11 @@ # include <mln/geom/nsites.hh> # include <mln/geom/nslis.hh> # include <mln/geom/pmin_pmax.hh> -# include <mln/geom/resize.hh> # include <mln/geom/seeds2tiling.hh> # include <mln/geom/seeds2tiling_roundness.hh> # include <mln/geom/size1d.hh> # include <mln/geom/size2d.hh> # include <mln/geom/size3d.hh> + #endif // ! MLN_GEOM_ALL_HH Index: mln/fun/v2v/inc.hh --- mln/fun/v2v/inc.hh (revision 3091) +++ mln/fun/v2v/inc.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory +// Copyright (C) 2008 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 @@ -28,10 +28,9 @@ #ifndef MLN_FUN_V2V_INC_HH # define MLN_FUN_V2V_INC_HH -/*! \file mln/fun/v2v/inc.hh - * - * \brief Incrementation function. - */ +/// \file mln/fun/v2v/inc.hh +/// +/// Incrementation function. # include <mln/fun/internal/selector.hh> @@ -63,7 +62,7 @@ T inc<T>::operator()(const T& t) const { - return t + 1; + return static_cast<T>(t + 1); } # endif // ! MLN_INCLUDE_ONLY Index: mln/fun/v2v/cast.hh --- mln/fun/v2v/cast.hh (revision 3091) +++ mln/fun/v2v/cast.hh (working copy) @@ -1,4 +1,5 @@ // Copyright (C) 2007, 2008 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 @@ -28,13 +29,12 @@ #ifndef MLN_FUN_V2V_CAST_HH # define MLN_FUN_V2V_CAST_HH -/*! \file mln/fun/v2v/cast.hh - * - * \brief FIXME. - * - * \todo The function is intrisically meta; how to handle that - * particular case? - */ +/// \file mln/fun/v2v/cast.hh +/// +/// FIXME. +/// +/// \todo The function is intrisically meta; how to handle that +/// particular case? # include <mln/core/concept/function.hh> # include <mln/value/cast.hh> Index: mln/fun/v2v/linear.hh --- mln/fun/v2v/linear.hh (revision 3091) +++ mln/fun/v2v/linear.hh (working copy) @@ -1,4 +1,5 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -28,12 +29,12 @@ #ifndef MLN_FUN_V2V_LINEAR_HH # define MLN_FUN_V2V_LINEAR_HH -/*! \file mln/fun/v2v/linear.hh - * - * \brief FIXME. - */ +/// \file mln/fun/v2v/linear.hh +/// +/// FIXME. # include <mln/core/concept/function.hh> +# include <mln/convert/to.hh> namespace mln @@ -57,8 +58,12 @@ struct linear : public Function_v2v< linear<V,T,R> > { typedef R result; + R operator()(const V& v) const; + template <typename U> + R operator()(const U& u) const; + linear(T a, T b); T a, b; }; @@ -79,7 +84,16 @@ R linear<V,T,R>::operator()(const V& v) const { - return R(a * T(v) + b); + return convert::to<R>(a * static_cast<T>(v) + b); + } + + template <typename V, typename T, typename R> + template <typename U> + inline + R + linear<V,T,R>::operator()(const U& u) const + { + return this->operator()(static_cast<V>(u)); } # endif // ! MLN_INCLUDE_ONLY Index: mln/fun/v2v/dec.hh --- mln/fun/v2v/dec.hh (revision 3091) +++ mln/fun/v2v/dec.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory +// Copyright (C) 2008 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 @@ -28,10 +28,9 @@ #ifndef MLN_FUN_V2V_DEC_HH # define MLN_FUN_V2V_DEC_HH -/*! \file mln/fun/v2v/dec.hh - * - * \brief Decrementation function. - */ +/// \file mln/fun/v2v/dec.hh +/// +/// Decrementation function. # include <mln/fun/internal/selector.hh> @@ -63,7 +62,7 @@ T dec<T>::operator()(const T& t) const { - return t - 1; + return static_cast<T>(t - 1); } # endif // ! MLN_INCLUDE_ONLY Index: mln/win/cuboid3d.hh --- mln/win/cuboid3d.hh (revision 3091) +++ mln/win/cuboid3d.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory +// Copyright (C) 2008 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,7 +29,8 @@ # define MLN_WIN_CUBOID3D_HH /// \file mln/win/cuboid3d.hh -/// \brief Definition of the mln::win::cuboid3d window. +/// +/// Definition of the mln::win::cuboid3d window. # include <mln/core/internal/classical_window_base.hh> # include <mln/core/alias/dpoint3d.hh> @@ -126,12 +127,16 @@ width_(width) { mln_precondition(height % 2 == 1 && width % 2 == 1); - const int dsli = depth / 2; - const int drow = height / 2; - const int dcol = width / 2; - for (int sli = -dsli; sli <= dsli; ++sli) - for (int row = -drow; row <= drow; ++row) - for (int col = -dcol; col <= dcol; ++col) + const def::coord + dsli = static_cast<def::coord>(depth / 2), + drow = static_cast<def::coord>(height / 2), + dcol = static_cast<def::coord>(width / 2), + minus_dsli = static_cast<def::coord>(- dsli), + minus_drow = static_cast<def::coord>(- drow), + minus_dcol = static_cast<def::coord>(- dcol); + for (def::coord sli = minus_dsli; sli <= dsli; ++sli) + for (def::coord row = minus_drow; row <= drow; ++row) + for (def::coord col = minus_dcol; col <= dcol; ++col) insert(dpoint3d(sli, row, col)); } Index: mln/win/cube3d.hh --- mln/win/cube3d.hh (revision 3091) +++ mln/win/cube3d.hh (working copy) @@ -1,4 +1,5 @@ // Copyright (C) 2007, 2008 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 @@ -28,10 +29,9 @@ #ifndef MLN_WIN_CUBE3D_HH # define MLN_WIN_CUBE3D_HH -/*! \file mln/win/cube3d.hh - * - * \brief Definition of the mln::win::cube3d window. - */ +/// \file mln/win/cube3d.hh +/// +/// Definition of the mln::win::cube3d window. # include <mln/core/internal/classical_window_base.hh> # include <mln/core/alias/dpoint3d.hh> @@ -99,10 +99,12 @@ : length_(length) { mln_precondition(length % 2 == 1); - const int dind = length / 2; - for (int sli = - dind; sli <= dind; ++sli) - for (int row = - dind; row <= dind; ++row) - for (int col = - dind; col <= dind; ++col) + const def::coord + d = static_cast<def::coord>(length / 2), + minus_d = static_cast<def::coord>(- d); + for (def::coord sli = minus_d; sli <= d; ++sli) + for (def::coord row = minus_d; row <= d; ++row) + for (def::coord col = minus_d; col <= d; ++col) insert(dpoint3d(sli, row, col)); } Index: mln/algebra/quat.hh --- mln/algebra/quat.hh (revision 3091) +++ mln/algebra/quat.hh (working copy) @@ -1,4 +1,5 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -28,10 +29,9 @@ #ifndef MLN_ALGEBRA_QUAT_HH # define MLN_ALGEBRA_QUAT_HH -/*! \file mln/algebra/quat.hh - * - * \brief Define a class for quaternion algebra values. - */ +/// \file mln/algebra/quat.hh +/// +/// Define a class for quaternion algebra values. # include <cmath> @@ -47,6 +47,7 @@ // FIXME: pow, exp etc... are def here and in value::... + namespace mln { @@ -427,15 +428,15 @@ inline void quat::set_unit(float theta, const algebra::vec<3,T>& uv) { - static const float pi = 3.14159265358979323846; + static const float pi = 3.14159265358979323846f; mln_precondition(theta > - pi - mln_epsilon(float) && theta < pi + mln_epsilon(float)); mln_precondition(about_equal(norm::l2(uv), 1.f)); (void) pi; - this->v_[0] = cos(theta); - float sint = sin(theta); + this->v_[0] = std::cos(theta); + float sint = std::sin(theta); this->v_[1] = uv[0] * sint; this->v_[2] = uv[1] * sint; this->v_[3] = uv[2] * sint; @@ -456,7 +457,7 @@ float quat::theta() const { mln_precondition(is_unit()); - return acos(s()); + return std::acos(s()); } inline @@ -558,7 +559,7 @@ float theta = norm::l2(v); mln_precondition(!about_equal(theta, 0.f)); algebra::vec<3, float> uv = v / theta; - return quat(cos(theta), sin(theta) * uv); + return quat(std::cos(theta), std::sin(theta) * uv); } @@ -611,11 +612,11 @@ quat slerp(const quat& p, const quat& q, float h) { assert(interpol_ok(p, q, h)); - float omega = acos(p.sprod(q)); + float omega = std::acos(p.sprod(q)); return about_equal(omega, 0.f) ? lerp(p, q, h) : - quat((sin((1-h)*omega) * p + sin(h*omega) * q) / sin(omega)); + quat((std::sin((1-h)*omega) * p + std::sin(h*omega) * q) / std::sin(omega)); } inline Index: mln/algebra/vec.hh --- mln/algebra/vec.hh (revision 3091) +++ mln/algebra/vec.hh (working copy) @@ -434,7 +434,7 @@ float n_l2 = 0; for (unsigned i = 0; i < n; ++i) n_l2 += data_[i] * data_[i]; - n_l2 = sqrt(n_l2); + n_l2 = float(std::sqrt(n_l2)); for (unsigned i = 0; i < n; ++i) data_[i] = static_cast<T>(data_[i] / n_l2); return *this; Index: mln/io/pbm/load.hh --- mln/io/pbm/load.hh (revision 3091) +++ mln/io/pbm/load.hh (working copy) @@ -115,7 +115,7 @@ if (i % 8 == 0) file.read((char*)(&c), 1); ima(p) = !(c & 128); - c *= 2; + c = static_cast<char>(c * 2); ++i; } } Index: mln/norm/linfty.hh --- mln/norm/linfty.hh (revision 3091) +++ mln/norm/linfty.hh (working copy) @@ -1,4 +1,5 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -28,12 +29,12 @@ #ifndef MLN_NORM_LINFTY_HH # define MLN_NORM_LINFTY_HH -/*! \file mln/norm/linfty.hh - * - * \brief Define some L-infinity-norm related routines. - * \see
http://mathworld.wolfram.com/L-Infinity-Norm.html
for more - * information. - */ +/// \file mln/norm/linfty.hh +/// +/// Define some L-infinity-norm related routines. +/// +/// \see
http://mathworld.wolfram.com/L-Infinity-Norm.html
for more +/// information. # include <mln/math/abs.hh> # include <mln/algebra/vec.hh> Index: mln/norm/l1.hh --- mln/norm/l1.hh (revision 3091) +++ mln/norm/l1.hh (working copy) @@ -1,4 +1,5 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -28,11 +29,10 @@ #ifndef MLN_NORM_L1_HH # define MLN_NORM_L1_HH -/*! \file mln/norm/l1.hh - * - * \brief Define some L1-norm related routines. - * \see
http://mathworld.wolfram.com/L1-Norm.html
for more information. - */ +/// \file mln/norm/l1.hh +/// +/// \brief Define some L1-norm related routines. +/// \see
http://mathworld.wolfram.com/L1-Norm.html
for more information. # include <mln/math/abs.hh> # include <mln/algebra/vec.hh> @@ -40,6 +40,7 @@ // FIXME: Use mln_sum_x (to be renamed as mln_sum_product) instead of // mln_sum. + namespace mln { @@ -75,9 +76,13 @@ mln_sum(C) l1_(const V& vec) { - mln_sum(C) m = 0; + typedef mln_sum(C) M; + M m = 0; for (unsigned i = 0; i < n; ++i) - m += mln::math::abs (vec[i]); + { + M v_i = static_cast<M>(mln::math::abs(vec[i])); + m = static_cast<M>(m + v_i); + } return m; } @@ -86,9 +91,13 @@ mln_sum(C) l1_distance_(const V& vec1, const V& vec2) { - mln_sum(C) d = 0; + typedef mln_sum(C) D; + D d = 0; for (unsigned i = 0; i < n; ++i) - d += mln::math::abs (vec1[i] - vec2[i]); + { + D v1_v2 = static_cast<D>(mln::math::abs(vec1[i] - vec2[i])); + d = static_cast<D>(d + v1_v2); + } return d; } Index: mln/norm/l2.hh --- mln/norm/l2.hh (revision 3091) +++ mln/norm/l2.hh (working copy) @@ -1,4 +1,5 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -28,11 +29,11 @@ #ifndef MLN_NORM_L2_HH # define MLN_NORM_L2_HH -/*! \file mln/norm/l2.hh - * - * \brief Define some L2-norm related routines. - * \see
http://mathworld.wolfram.com/L2-Norm.html
for more information. - */ +/// \file mln/norm/l2.hh +/// +/// Define some L2-norm related routines. +/// +/// \see
http://mathworld.wolfram.com/L2-Norm.html
for more information. # include <mln/math/sqr.hh> # include <mln/math/sqrt.hh> @@ -78,9 +79,13 @@ mln_sum(C) l2_(const V& vec) { - mln_sum(C) m = 0; + typedef mln_sum(C) M; + M m = 0; for (unsigned i = 0; i < n; ++i) - m += mln::math::sqr(vec[i]); + { + M sqr_v_i = static_cast<M>(mln::math::sqr(vec[i])); + m = static_cast<M>(m + sqr_v_i); + } return mln::math::sqrt(m); } @@ -89,9 +94,13 @@ mln_sum(C) l2_distance_(const V& vec1, const V& vec2) { - mln_sum(C) d = 0; + typedef mln_sum(C) D; + D d = 0; for (unsigned i = 0; i < n; ++i) - d += mln::math::sqr(vec1[i] - vec2[i]); + { + D sqr_v1_v2 = static_cast<D>(mln::math::sqr(vec1[i] - vec2[i])); + d = static_cast<D>(d + sqr_v1_v2); + } return mln::math::sqrt(d); } Index: mln/canvas/browsing/snake_fwd.hh --- mln/canvas/browsing/snake_fwd.hh (revision 3091) +++ mln/canvas/browsing/snake_fwd.hh (working copy) @@ -105,7 +105,7 @@ // trait::image::dimension::two_d)::check(); trace::entering("canvas::browsing::snake_fwd"); mln_precondition(f.input.has_data()); - int + def::coord min_row = geom::min_row(f.input), max_row = geom::max_row(f.input), min_col = geom::min_col(f.input), max_col = geom::max_col(f.input); Index: mln/canvas/browsing/dir_struct_elt_incr_update.hh --- mln/canvas/browsing/dir_struct_elt_incr_update.hh (revision 3091) +++ mln/canvas/browsing/dir_struct_elt_incr_update.hh (working copy) @@ -36,6 +36,7 @@ # include <mln/core/concept/browsing.hh> # include <mln/core/concept/image.hh> + namespace mln { @@ -110,11 +111,12 @@ pmin = f.input.domain().pmin(), pmax = f.input.domain().pmax(); - const mln_deduce(I, site, coord) + typedef mln_deduce(I, site, coord) C; + const C pmin_dir = pmin[f.dir], pmax_dir = pmax[f.dir], - pmin_dir_plus_half_length = pmin_dir + f.length / 2, - pmax_dir_minus_half_length = pmax_dir - f.length / 2; + pmin_dir_plus_half_length = static_cast<C>(pmin_dir + f.length / 2), + pmax_dir_minus_half_length = static_cast<C>(pmax_dir - f.length / 2); mln_psite(I) pt, pu; Index: tests/opt/at.cc --- tests/opt/at.cc (revision 3091) +++ tests/opt/at.cc (working copy) @@ -78,7 +78,7 @@ const II csub_ima(ima, make::box1d(4, 10)); point1d p(5); - data::fill(ima, 51); + data::fill(ima, short(51)); mln_assertion(csub_ima(p) == opt::at(csub_ima, 5)); opt::at(sub_ima, 5) = 12; mln_assertion(sub_ima(p) == 12); @@ -92,7 +92,7 @@ const II ccast(in); point1d p(5); - data::fill(in, 51); + data::fill(in, (unsigned short)51); mln_assertion(ccast(p) == opt::at(ccast, 5)); // FIXME //opt::at(cast, 5) = 12; @@ -120,7 +120,7 @@ const II csub_ima(ima, make::box2d(4, 4, 10, 10)); point2d p(5, 5); - data::fill(ima, 51); + data::fill(ima, short(51)); mln_assertion(csub_ima(p) == opt::at(csub_ima, 5, 5)); opt::at(sub_ima, 5, 5) = 12; mln_assertion(sub_ima(p) == 12); @@ -134,7 +134,7 @@ const II ccast(in); point2d p(5,5); - data::fill(in, 51); + data::fill(in, (unsigned short)51); mln_assertion(ccast(p) == opt::at(ccast, 5, 5)); // FIXME //opt::at(cast, 5) = 12; Index: tests/level/transform_inplace.cc --- tests/level/transform_inplace.cc (revision 3091) +++ tests/level/transform_inplace.cc (working copy) @@ -27,7 +27,7 @@ /// \file tests/level/transform_inplace.cc /// -/// Tests on mln::level::transform_inplace +/// Tests on mln::level::transform_inplace. #include <mln/core/image/image1d.hh> @@ -37,19 +37,17 @@ #include <mln/core/image/image_if.hh> #include <mln/core/image/sub_image.hh> #include <mln/core/image/extension_val.hh> - - #include <mln/core/routine/duplicate.hh> - #include <mln/fun/v2v/inc.hh> #include <mln/fun/v2v/dec.hh> +#include <mln/fun/p2b/chess.hh> + #include <mln/debug/iota.hh> #include <mln/level/transform_inplace.hh> #include <mln/level/compare.hh> -#include <mln/fun/p2b/chess.hh> int main() @@ -60,24 +58,26 @@ // image 2d tests { - image2d<int> ref(size, size); + typedef int T; + image2d<T> ref(size, size); debug::iota(ref); - image2d<int> ima = duplicate(ref); - level::transform_inplace(ima, fun::v2v::inc<int>()); - level::transform_inplace(ima, fun::v2v::dec<int>()); + image2d<T> ima = duplicate(ref); + level::transform_inplace(ima, fun::v2v::inc<T>()); + level::transform_inplace(ima, fun::v2v::dec<T>()); mln_assertion(ima == ref); } /// image 1d test { - image1d<unsigned short> ref(size); + typedef unsigned short T; + image1d<T> ref(size); debug::iota(ref); - image1d<unsigned short> ima = duplicate(ref); - level::transform_inplace(ima, fun::v2v::inc<int>()); - level::transform_inplace(ima, fun::v2v::dec<int>()); + image1d<T> ima = duplicate(ref); + level::transform_inplace(ima, fun::v2v::inc<T>()); + level::transform_inplace(ima, fun::v2v::dec<T>()); mln_assertion(ima == ref); } @@ -85,30 +85,34 @@ /// image 3d test { - image3d<unsigned short> ref(size, size, size); + typedef unsigned short T; + image3d<T> ref(size, size, size); debug::iota(ref); - image3d<unsigned short> ima = duplicate(ref); - level::transform_inplace(ima, fun::v2v::inc<int>()); - level::transform_inplace(ima, fun::v2v::dec<int>()); + image3d<T> ima = duplicate(ref); + level::transform_inplace(ima, fun::v2v::inc<T>()); + level::transform_inplace(ima, fun::v2v::dec<T>()); mln_assertion(ima == ref); } // flat image test { - flat_image<short, box2d> ref(5, make::box2d(size, size)); + typedef short T; + flat_image<T, box2d> + ref(5, make::box2d(size, size)), + ima(5, make::box2d(size, size)); - flat_image<short, box2d> ima(5, make::box2d(size, size)); - level::transform_inplace(ima, fun::v2v::inc<int>()); - level::transform_inplace(ima, fun::v2v::dec<int>()); + level::transform_inplace(ima, fun::v2v::inc<T>()); + level::transform_inplace(ima, fun::v2v::dec<T>()); mln_assertion(ima == ref); } // image if test { - typedef image2d<unsigned short> I; + typedef unsigned short T; + typedef image2d<T> I; typedef image_if<I, fun::p2b::chess> II; I ref(size, size); @@ -118,8 +122,8 @@ I ima = duplicate(ref); II ima_if = ima | fun::p2b::chess(); - level::transform_inplace(ima_if, fun::v2v::inc<int>()); - level::transform_inplace(ima_if, fun::v2v::dec<int>()); + level::transform_inplace(ima_if, fun::v2v::inc<T>()); + level::transform_inplace(ima_if, fun::v2v::dec<T>()); mln_assertion(ima_if == ref_if); } @@ -145,16 +149,17 @@ // extended image test { - typedef image2d<int> I; - typedef extension_val< image2d<int> > II; + typedef int T; + typedef image2d<T> I; + typedef extension_val< image2d<T> > II; I ref(size, size); I ima = duplicate(ref); II extend_ima(ima, 5); - level::transform_inplace(extend_ima, fun::v2v::inc<int>()); - level::transform_inplace(extend_ima, fun::v2v::dec<int>()); + level::transform_inplace(extend_ima, fun::v2v::inc<T>()); + level::transform_inplace(extend_ima, fun::v2v::dec<T>()); mln_assertion(extend_ima == ref); Index: tests/level/transform.cc --- tests/level/transform.cc (revision 3091) +++ tests/level/transform.cc (working copy) @@ -1,4 +1,5 @@ // Copyright (C) 2007, 2008 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/level/transform.cc /// -/// Tests on mln::level::transform +/// Tests on mln::level::transform. #include <cmath> @@ -54,12 +55,14 @@ #include <mln/debug/iota.hh> #include <mln/debug/println.hh> + struct mysqrt : mln::Function_v2v<mysqrt> { typedef unsigned short result; - result operator()(unsigned short c) const + template <typename T> + result operator()(T c) const { - return result( std::sqrt(float(c)) ); + return static_cast<result>( std::sqrt(float(c)) ); } }; @@ -121,12 +124,11 @@ /// pw image test { - const pw::image<fun::p2v::iota, box2d> ima(fun::p2v::iota(), make::box2d(2,2, 5,5)); image2d<short unsigned int> out(8, 8); - data::fill(out, 0); + data::fill(out, (short unsigned int)0); out = level::transform(ima, mysqrt()); } @@ -171,8 +173,8 @@ II cast(in); III out(size, size); - data::fill(in, 51); - data::fill(out, 42); + data::fill(in, (unsigned short)51); + data::fill(out, (unsigned short)42); out = level::transform(cast, mysqrt()); Index: tests/level/sort_psites.cc --- tests/level/sort_psites.cc (revision 3091) +++ tests/level/sort_psites.cc (working copy) @@ -1,4 +1,5 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2007, 2008 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 @@ -25,10 +26,9 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/*! \file tests/level/sort_psites.cc - * - * \brief Tests on mln::level::sort_psites. - */ +/// \file tests/level/sort_psites.cc +/// +/// Tests on mln::level::sort_psites. #include <mln/core/image/image2d.hh> #include <mln/debug/iota.hh> @@ -48,12 +48,13 @@ p_array<point2d> array_inc_ref; p_array<point2d> array_dec_ref; - for (int i = 0; i < 3; ++i) - for (int j = 0; j < 3; ++j) + typedef def::coord C; + for (C i = 0; i < 3; ++i) + for (C j = 0; j < 3; ++j) array_inc_ref.append(point2d(i, j)); - for (int i = 2; i >= 0; --i) - for (int j = 2; j >= 0; --j) + for (C i = 2; i >= 0; --i) + for (C j = 2; j >= 0; --j) array_dec_ref.append(point2d(i, j)); mln_assertion(array_inc == array_inc_ref); Index: tests/level/Makefile.am --- tests/level/Makefile.am (revision 3091) +++ tests/level/Makefile.am (working copy) @@ -22,7 +22,6 @@ paste \ saturate \ sort_psites \ - sort_psites_full \ stretch \ transform \ transform_inplace \ @@ -50,7 +49,4 @@ transform_inplace_SOURCES = transform_inplace.cc update_SOURCES = update.cc -# Lengthy tests. -sort_psites_full_SOURCES = sort_psites_full.cc - TESTS = $(check_PROGRAMS) Index: tests/data/paste.cc --- tests/data/paste.cc (revision 3091) +++ tests/data/paste.cc (working copy) @@ -113,7 +113,7 @@ make::box2d(2,2, 5,5)); image2d<short unsigned int> out(8, 8); - data::fill(out, 0); + data::fill(out, (short unsigned int)0); data::paste(ima, out); } @@ -154,8 +154,8 @@ II cast(in); III out(size, size); - data::fill(in, 51); - data::fill(out, 42); + data::fill(in, (unsigned short)51); + data::fill(out, (unsigned short)42); data::paste(cast, out); Index: tests/data/fill_with_image.cc --- tests/data/fill_with_image.cc (revision 3091) +++ tests/data/fill_with_image.cc (working copy) @@ -149,7 +149,7 @@ make::box2d(-2,-2, 15,15)); image2d<short unsigned int> out(8, 8); - data::fill(out, 0); + data::fill(out, (short unsigned int)0); data::fill_with_image(out, ima); } @@ -191,8 +191,8 @@ II cast(in); I out(size, size); - data::fill(in, 51); - data::fill(out, 42); + data::fill(in, (unsigned short)51); + data::fill(out, (unsigned short)42); data::fill_with_image(out, cast); Index: tests/linear/convolve.cc --- tests/linear/convolve.cc (revision 3091) +++ tests/linear/convolve.cc (working copy) @@ -26,10 +26,9 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/*! \file tests/linear/convolve.cc - * - * \brief Tests on mln::linear::convolve. - */ +/// \file tests/linear/convolve.cc +/// +/// Tests on mln::linear::convolve. #include <mln/core/image/image2d.hh> #include <mln/value/int_u8.hh> @@ -56,13 +55,14 @@ image2d<int_u8> lena; io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm"); - float ws[] = { .04, .04, .04, .04, .04, - .04, .04, .04, .04, .04, - .04, .04, .04, .04, .04, - .04, .04, .04, .04, .04, - .04, .04, .04, .04, .04 }; - w_window2d_float w = make::w_window2d(ws); - image2d<float> tmp = linear::convolve(lena, w); + float w = .04f; + float ws[] = { w, w, w, w, w, + w, w, w, w, w, + w, w, w, w, w, + w, w, w, w, w, + w, w, w, w, w }; + w_window2d_float w_win = make::w_window2d(ws); + image2d<float> tmp = linear::convolve(lena, w_win); io::pgm::save(level::transform(tmp, math::round<int_u8>()), "out.pgm"); Index: tests/linear/convolve_directional.cc --- tests/linear/convolve_directional.cc (revision 3091) +++ tests/linear/convolve_directional.cc (working copy) @@ -26,10 +26,9 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/*! \file tests/linear/convolve_directional.cc - * - * \brief Tests on mln::linear::convolve_directional. - */ +/// \file tests/linear/convolve_directional.cc +/// +/// Tests on mln::linear::convolve_directional. #include <mln/core/image/image2d.hh> #include <mln/value/int_u8.hh> @@ -56,7 +55,8 @@ image2d<int_u8> lena; io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm"); - float ws[] = { .11, .11, .11, .11, .11, .11, .11, .11, .11 }; + float w = .11f; + float ws[] = { w, w, w, w, w, w, w, w, w }; image2d<float> tmp = linear::convolve_directional(lena, 1, ws); io::pgm::save(level::transform(tmp, math::round<int_u8>()), Index: tests/linear/gaussian.cc --- tests/linear/gaussian.cc (revision 3091) +++ tests/linear/gaussian.cc (working copy) @@ -1,4 +1,5 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2007, 2008 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 @@ -25,10 +26,9 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/*! \file tests/linear/gaussian.cc - * - * \brief Test on mln::linear::gaussian. - */ +/// \file tests/linear/gaussian.cc +/// +/// Test on mln::linear::gaussian. #include <mln/core/image/image2d.hh> #include <mln/value/int_u8.hh> Index: tests/geom/Makefile.am --- tests/geom/Makefile.am (revision 3091) +++ tests/geom/Makefile.am (working copy) @@ -18,7 +18,6 @@ nsites \ nslis \ pmin_pmax \ -resize \ seed2tiling \ seed2tiling_roundness @@ -38,7 +37,6 @@ nsites_SOURCES = nsites.cc nslis_SOURCES = nslis.cc pmin_pmax_SOURCES = pmin_pmax.cc -resize_SOURCES = resize.cc seed2tiling_SOURCES = seed2tiling.cc seed2tiling_roundness_SOURCES = seed2tiling_roundness.cc Index: tests/norm/l2.cc --- tests/norm/l2.cc (revision 3091) +++ tests/norm/l2.cc (working copy) @@ -1,4 +1,5 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -25,10 +26,9 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/*! \file tests/norm/l2.cc - * - * \brief Test the L2-norm. - */ +/// \file tests/norm/l2.cc +/// +/// \brief Test the L2-norm. #include <cmath> #include <cassert> @@ -59,14 +59,15 @@ } } + int main() { typedef mln::algebra::vec<3, int> vec_t; // Reference value. - float d = std::sqrt((4 - 2) * (4 - 2) + + float d = float(std::sqrt((4 - 2) * (4 - 2) + (1 + 2) * (1 + 2) + - (0 - 3) * (0 - 3)); + (0 - 3) * (0 - 3))); // Tests using mln::algebra::vec. vec_t t, u; Index: tests/norm/common.hh --- tests/norm/common.hh (revision 3091) +++ tests/norm/common.hh (working copy) @@ -1,4 +1,5 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -32,27 +33,32 @@ #include <mln/math/abs.hh> + // FIXME: We should have a almost_equal function somewhere in Milena. -static const float epsilon = 0.0001; +static const float epsilon = 0.0001f; + namespace test { template <typename Norm, typename V> void - check_norm(const Norm norm, const V& vec1, const V& vec2) + check_norm(const Norm& norm, const V& vec1, const V& vec2) { assert(mln::math::abs(norm(vec1) - norm(vec2)) < epsilon); } template <typename Distance, typename V, typename S> void - check_distance (const Distance dist, const V& vec1, const V& vec2, + check_distance(const Distance& dist, const V& vec1, const V& vec2, const S& ref_val) { - assert(mln::math::abs(dist(vec1, vec2) - ref_val) < epsilon); + float delta = mln::math::abs(static_cast<float>(dist(vec1, vec2)) + - static_cast<float>(ref_val)); + assert(delta < epsilon); } -} // End of namespace test. +} // end of namespace test. + #endif // !TESTS_NORM_COMMON_HH Index: tests/norm/linfty.cc --- tests/norm/linfty.cc (revision 3091) +++ tests/norm/linfty.cc (working copy) @@ -1,4 +1,5 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -25,10 +26,9 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/*! \file tests/norm/linfty.cc - * - * \brief Test the L-infinity-norm. - */ +/// \file tests/norm/linfty.cc +/// +/// Test the L-infinity-norm. #include <tests/norm/common.hh> @@ -62,9 +62,9 @@ typedef mln::algebra::vec<3, int> vec_t; // Reference value. - float d = std::max(std::abs(4 - 2), + float d = float(std::max(std::abs(4 - 2), std::max(std::abs(1 + 2), - std::abs(0 - 4))); + std::abs(0 - 4)))); vec_t t, u; t.set(2, -2, 4);
16Â years
1
0
0
0
3091: Fix warnings due to g++ Wconversion option.
by Thierry Geraud
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog from Thierry Geraud <thierry.geraud(a)lrde.epita.fr> Fix warnings due to g++ Wconversion option. * mln/debug/iota.spe.hh, * mln/debug/put_word.hh, * mln/debug/println.spe.hh, * mln/core/site_set/box.hh, * mln/core/site_set/box_piter.hh, * mln/core/image/image1d.hh, * mln/core/image/image2d.hh, * mln/core/image/image3d.hh, * mln/core/point.hh, * mln/core/box_runstart_piter.hh, * mln/core/alias/window2d.hh, * mln/core/concept/site_set.hh, * mln/core/dpoint.hh, * mln/math/abs.hh, * mln/opt/at.hh, * mln/accu/sum.hh, * mln/accu/line.hh, * mln/accu/mean.hh, * mln/value/float01_.hh, * mln/value/int_s.hh, * mln/value/int_u.hh, * mln/value/float01.hh, * mln/make/win_chamfer.hh, * mln/make/image.hh, * mln/make/box2d_h.hh, * mln/make/point2d_h.hh, * mln/make/dpoint2d_h.hh, * mln/make/box1d.hh, * mln/make/box2d.hh, * mln/make/box3d.hh, * mln/border/mirror.hh, * mln/convert/to_image.hh, * mln/win/line.hh, * mln/win/diag2d.hh, * mln/win/backdiag2d.hh, * mln/win/octagon2d.hh, * mln/win/disk2d.hh, * mln/algebra/mat.hh, * mln/algebra/h_vec.hh, * mln/algebra/vec.hh, * mln/io/pnm/save_header.hh, * mln/io/pnm/load_header.hh, * mln/io/pnm/save.hh, * mln/io/pnm/load.hh, * mln/io/pbm/save.hh, * tests/data/fill.cc, * tests/border/fill_full.cc, * tests/convert/to_p_array.cc, * tests/convert/to_image.cc, * tests/win/diag2d.cc: Use static_cast. Replace int by def::coord when needed. mln/accu/line.hh | 8 ++--- mln/accu/mean.hh | 8 +++-- mln/accu/sum.hh | 2 - mln/algebra/h_vec.hh | 10 +++--- mln/algebra/mat.hh | 17 +++++------ mln/algebra/vec.hh | 21 ++++++++------ mln/border/mirror.hh | 15 ++++++---- mln/convert/to_image.hh | 1 mln/core/alias/window2d.hh | 21 +++++++++----- mln/core/box_runstart_piter.hh | 15 +++++----- mln/core/concept/site_set.hh | 10 ------ mln/core/dpoint.hh | 3 +- mln/core/image/image1d.hh | 11 ++++--- mln/core/image/image2d.hh | 14 +++++---- mln/core/image/image3d.hh | 16 ++++++---- mln/core/point.hh | 4 +- mln/core/site_set/box.hh | 18 ++++++------ mln/core/site_set/box_piter.hh | 2 - mln/debug/iota.spe.hh | 2 - mln/debug/println.spe.hh | 14 +++++---- mln/debug/put_word.hh | 13 ++++---- mln/io/pbm/save.hh | 33 +++++++++++----------- mln/io/pnm/load.hh | 16 ++++------ mln/io/pnm/load_header.hh | 2 - mln/io/pnm/save.hh | 22 ++++++--------- mln/io/pnm/save_header.hh | 16 ++++------ mln/make/box1d.hh | 10 +++--- mln/make/box2d.hh | 8 ++--- mln/make/box2d_h.hh | 21 +++++++------- mln/make/box3d.hh | 12 ++++---- mln/make/dpoint2d_h.hh | 14 ++++----- mln/make/image.hh | 20 +++++++++---- mln/make/point2d_h.hh | 14 ++++----- mln/make/win_chamfer.hh | 58 +++++++++++++++++++-------------------- mln/math/abs.hh | 9 ++---- mln/opt/at.hh | 60 ++++++++++++++++++++--------------------- mln/value/float01.hh | 12 ++++---- mln/value/float01_.hh | 13 +++++--- mln/value/int_s.hh | 17 ++++++----- mln/value/int_u.hh | 4 +- mln/win/backdiag2d.hh | 14 +++++---- mln/win/diag2d.hh | 17 ++++++----- mln/win/disk2d.hh | 20 +++++++------ mln/win/line.hh | 6 ++-- mln/win/octagon2d.hh | 57 +++++++++++++++++++++++--------------- tests/border/fill_full.cc | 8 ++--- tests/convert/to_image.cc | 1 tests/convert/to_p_array.cc | 10 ++++-- tests/data/fill.cc | 20 +++++-------- tests/win/diag2d.cc | 17 +++++------ 50 files changed, 402 insertions(+), 354 deletions(-) Index: mln/debug/iota.spe.hh --- mln/debug/iota.spe.hh (revision 3090) +++ mln/debug/iota.spe.hh (working copy) @@ -63,7 +63,7 @@ unsigned i = 0; mln_pixter(I) p(input); for_all(p) - p.val() = ++i % mln_max(mln_value(I)); + p.val() = static_cast<mln_value(I)>(++i % mln_max(mln_value(I))); } # endif // ! MLN_INCLUDE_ONLY Index: mln/debug/put_word.hh --- mln/debug/put_word.hh (revision 3090) +++ mln/debug/put_word.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory +// Copyright (C) 2008 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 @@ -28,10 +28,9 @@ #ifndef MLN_DEBUG_PUT_WORD_HH # define MLN_DEBUG_PUT_WORD_HH -/*! \file mln/debug/put_word.hh - * - * \brief Write a word in a 2D image of characters. - */ +/// \file mln/debug/put_word.hh +/// +/// Write a word in a 2D image of characters. # include <string> # include <mln/core/image/image2d.hh> @@ -62,7 +61,9 @@ mln_precondition(inout.has(word_start)); point2d word_end = word_start; - word_end.last_coord() += word.length() - 1; + + word_end.last_coord() = static_cast<def::coord>(word_end.last_coord() + word.length() - 1); + if (!inout.has(word_end)) trace::warning("Cannot write text outside the image domain"); Index: mln/debug/println.spe.hh --- mln/debug/println.spe.hh (revision 3090) +++ mln/debug/println.spe.hh (working copy) @@ -84,9 +84,9 @@ void println(const box2d& b, const image2d<char>& input) { - for (int row = b.min_row(); row <= b.max_row(); ++row) + for (def::coord row = b.min_row(); row <= b.max_row(); ++row) { - for (int col = b.min_col(); col <= b.max_col(); ++col) + for (def::coord col = b.min_col(); col <= b.max_col(); ++col) std::cout << opt::at(input, row, col) << ' '; std::cout << std::endl; } @@ -115,14 +115,16 @@ { std::ostringstream oss; oss << format(input(p)); - point2d w( p.row() - b.min_row(), - (p.col() - b.min_col()) * len); + def::coord + row = static_cast<def::coord>(p.row() - b.min_row()), + col = static_cast<def::coord>((p.col() - b.min_col()) * len); + point2d w(row, col); put_word(output, w, oss.str()); } - for (unsigned row = 0; row < b.nrows(); ++row) + for (def::coord row = 0; row < def::coord(b.nrows()); ++row) { - for (unsigned col = 0; col < b.ncols() * len; ++col) + for (def::coord col = 0; col < def::coord(b.ncols() * len); ++col) std::cout << opt::at(output, row, col); std::cout << std::endl; } Index: mln/core/site_set/box.hh --- mln/core/site_set/box.hh (revision 3090) +++ mln/core/site_set/box.hh (working copy) @@ -1,4 +1,5 @@ // Copyright (C) 2007, 2008 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 @@ -28,12 +29,11 @@ #ifndef MLN_CORE_SITE_SET_BOX_HH # define MLN_CORE_SITE_SET_BOX_HH -/*! \file mln/core/site_set/box.hh - * - * \brief This file defines a generic box class. - * - * \todo Test if the safety code in box::box() is not too slow. - */ +/// \file mln/core/site_set/box.hh +/// +/// This file defines a generic box class. +/// +/// \todo Test if the safety code in box::box() is not too slow. # include <mln/core/concept/box.hh> # include <mln/core/internal/box_impl.hh> @@ -357,8 +357,8 @@ for (unsigned i = 0; i < P::dim; ++i) { - tmp.pmin_[i] -= b; - tmp.pmax_[i] += b; + tmp.pmin_[i] = static_cast<mln_coord(P)>(tmp.pmin_[i] - b); + tmp.pmax_[i] = static_cast<mln_coord(P)>(tmp.pmax_[i] + b); } mln_postcondition(tmp.is_valid()); return tmp; @@ -372,7 +372,7 @@ mln_precondition(is_valid()); P center; for (unsigned i = 0; i < P::dim; ++i) - center[i] = pmin_[i] + ((pmax_[i] - pmin_[i]) / 2); + center[i] = static_cast<mln_coord(P)>(pmin_[i] + ((pmax_[i] - pmin_[i]) / 2)); return center; } Index: mln/core/site_set/box_piter.hh --- mln/core/site_set/box_piter.hh (revision 3090) +++ mln/core/site_set/box_piter.hh (working copy) @@ -165,7 +165,7 @@ void box_fwd_piter_<P>::invalidate_() { - p_[0] = (s_->pmax()[0] + 1); + p_[0] = static_cast<def::coord>(s_->pmax()[0] + 1); } template <typename P> Index: mln/core/image/image1d.hh --- mln/core/image/image1d.hh (revision 3090) +++ mln/core/image/image1d.hh (working copy) @@ -181,10 +181,10 @@ // ----------------- /// Read-only access to the image value located at (\p index). - const T& at(int index) const; + const T& at(def::coord index) const; /// Read-write access to the image value located at (\p index). - T& at(int index); + T& at(def::coord index); /// Fast Image method @@ -426,7 +426,7 @@ template <typename T> inline const T& - image1d<T>::at(int index) const + image1d<T>::at(def::coord index) const { mln_precondition(this->has(point1d(index))); return this->data_->array_[index]; @@ -435,7 +435,7 @@ template <typename T> inline T& - image1d<T>::at(int index) + image1d<T>::at(def::coord index) { mln_precondition(this->has(point1d(index))); return this->data_->array_[index]; @@ -494,7 +494,8 @@ image1d<T>::point_at_index(unsigned i) const { mln_precondition(i < nelements()); - point1d p = point1d(i + this->data_->vb_.min_ind()); + def::coord ind = static_cast<def::coord>(i + this->data_->vb_.min_ind()); + point1d p = point1d(ind); mln_postcondition(& this->operator()(p) == this->data_->buffer_ + i); return p; } Index: mln/core/image/image2d.hh --- mln/core/image/image2d.hh (revision 3090) +++ mln/core/image/image2d.hh (working copy) @@ -205,10 +205,10 @@ // ----------------- /// Read-only access to the image value located at (\p row, \p col). - const T& at(int row, int col) const; + const T& at(def::coord row, def::coord col) const; /// Read-write access to the image value located at (\p row, \p col). - T& at(int row, int col); + T& at(def::coord row, def::coord col); /// Give the number of rows. unsigned nrows() const; @@ -463,7 +463,7 @@ template <typename T> inline const T& - image2d<T>::at(int row, int col) const + image2d<T>::at(def::coord row, def::coord col) const { mln_precondition(this->has(point2d(row, col))); return this->data_->array_[row][col]; @@ -472,7 +472,7 @@ template <typename T> inline T& - image2d<T>::at(int row, int col) + image2d<T>::at(def::coord row, def::coord col) { mln_precondition(this->has(point2d(row, col))); return this->data_->array_[row][col]; @@ -569,8 +569,10 @@ image2d<T>::point_at_index(unsigned i) const { mln_precondition(i < nelements()); - point2d p = point2d(i / this->data_->vb_.len(1) + this->data_->vb_.min_row(), - i % this->data_->vb_.len(1) + this->data_->vb_.min_col()); + def::coord + row = static_cast<def::coord>(i / this->data_->vb_.len(1) + this->data_->vb_.min_row()), + col = static_cast<def::coord>(i % this->data_->vb_.len(1) + this->data_->vb_.min_col()); + point2d p = point2d(row, col); mln_postcondition(& this->operator()(p) == this->data_->buffer_ + i); return p; } Index: mln/core/image/image3d.hh --- mln/core/image/image3d.hh (revision 3090) +++ mln/core/image/image3d.hh (working copy) @@ -201,11 +201,11 @@ /// Read-only access to the image value located at (\p sli, \p /// row, \p col). - const T& at(int sli, int row, int col) const; + const T& at(def::coord sli, def::coord row, def::coord col) const; /// Read-write access to the image value located at (\p sli, \p /// row, \p col). - T& at(int sli, int row, int col); + T& at(def::coord sli, def::coord row, def::coord col); /// Fast Image method @@ -484,7 +484,7 @@ template <typename T> inline const T& - image3d<T>::at(int sli, int row, int col) const + image3d<T>::at(def::coord sli, def::coord row, def::coord col) const { mln_precondition(this->has(point3d(sli, row, col))); return data_->array_[sli][row][col]; @@ -493,7 +493,7 @@ template <typename T> inline T& - image3d<T>::at(int sli, int row, int col) + image3d<T>::at(def::coord sli, def::coord row, def::coord col) { mln_precondition(this->has(point3d(sli, row, col))); return data_->array_[sli][row][col]; @@ -533,9 +533,11 @@ image3d<T>::point_at_index(unsigned o) const { mln_precondition(o < nelements()); - point3d p = point3d(o / (data_->vb_.len(1) * data_->vb_.len(2)) + data_->vb_.min_sli(), - (o % (data_->vb_.len(1) * data_->vb_.len(2))) / data_->vb_.len(2) + data_->vb_.min_row(), - o % data_->vb_.len(2) + data_->vb_.min_col()); + def::coord + sli = static_cast<def::coord>(o / (data_->vb_.len(1) * data_->vb_.len(2)) + data_->vb_.min_sli()), + row = static_cast<def::coord>((o % (data_->vb_.len(1) * data_->vb_.len(2))) / data_->vb_.len(2) + data_->vb_.min_row()), + col = static_cast<def::coord>(o % data_->vb_.len(2) + data_->vb_.min_col()); + point3d p = point3d(sli, row, col); mln_postcondition(& this->operator()(p) == this->data_->buffer_ + o); return p; } Index: mln/core/point.hh --- mln/core/point.hh (revision 3090) +++ mln/core/point.hh (working copy) @@ -298,7 +298,7 @@ mlc_converts_to(mln_result(F), C)::check(); const F& f = exact(f_); for (unsigned i = 0; i < dim; ++i) - coord_[i] = f(i); + coord_[i] = static_cast<C>( f(i) ); } template <typename G, typename C> @@ -369,7 +369,7 @@ point<G,C>::operator+=(const delta& dp) { for (unsigned i = 0; i < dim; ++i) - coord_[i] += dp[i]; + coord_[i] = static_cast<C>(coord_[i] + dp[i]); return *this; } Index: mln/core/box_runstart_piter.hh --- mln/core/box_runstart_piter.hh (revision 3090) +++ mln/core/box_runstart_piter.hh (working copy) @@ -1,4 +1,5 @@ // Copyright (C) 2007, 2008 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 @@ -28,18 +29,18 @@ #ifndef MLN_CORE_BOX_RUNSTART_PITER_HH # define MLN_CORE_BOX_RUNSTART_PITER_HH -/*! \file mln/core/box_runstart_piter.hh - * - * \brief Definition of iterators on points by lines. - * - */ +/// \file mln/core/box_runstart_piter.hh +/// +/// Definition of iterators on points by lines. # include <mln/core/internal/site_iterator_base.hh> # include <mln/core/site_set/box.hh> + #define mln_box_runstart_piter(I) typename mln::box_runstart_piter< mln_psite(I) > #define mln_box_runstart_piter_(I) mln::box_runstart_piter<mln_psite(I)> + namespace mln { @@ -111,7 +112,7 @@ bool box_runstart_piter<P>::is_valid_() const { - return p_[0] != s_->pmax()[0] + 1; + return p_[0] != static_cast<mln_coord(P)>(s_->pmax()[0] + 1); } template <typename P> @@ -119,7 +120,7 @@ void box_runstart_piter<P>::invalidate_() { - p_[0] = s_->pmax()[0] + 1; + p_[0] = static_cast<mln_coord(P)>(s_->pmax()[0] + 1); } template <typename P> Index: mln/core/alias/window2d.hh --- mln/core/alias/window2d.hh (revision 3090) +++ mln/core/alias/window2d.hh (working copy) @@ -107,12 +107,15 @@ void from_to_(const bool (&values)[S], window2d& win) { - enum { h = mlc_sqrt_int(S) / 2 }; - mlc_bool((2 * h + 1) * (2 * h + 1) == S)::check(); + enum { H = mlc_sqrt_int(S) / 2 }; + mlc_bool((2 * H + 1) * (2 * H + 1) == S)::check(); win.clear(); unsigned i = 0; - for (int row = - h; row <= h; ++row) - for (int col = - h; col <= h; ++col) + const def::coord + h = static_cast<def::coord>(H), + _h = static_cast<def::coord>(-h); + for (def::coord row = _h; row <= h; ++row) + for (def::coord col = _h; col <= h; ++col) if (values[i++]) win.insert(row, col); } @@ -124,9 +127,13 @@ mlc_bool(R % 2 == 1)::check(); mlc_bool(C % 2 == 1)::check(); win.clear(); - const int drow = int(R) / 2, dcol = int(C) / 2; - for (int row = - drow; row <= drow; ++row) - for (int col = - dcol; col <= dcol; ++col) + const def::coord + drow = static_cast<def::coord>(R / 2), + _drow = static_cast<def::coord>(- drow), + dcol = static_cast<def::coord>(C / 2), + _dcol = static_cast<def::coord>(- dcol); + for (def::coord row = _drow; row <= drow; ++row) + for (def::coord col = _dcol; col <= dcol; ++col) if (values[row + drow][col + dcol]) win.insert(row, col); } Index: mln/core/concept/site_set.hh --- mln/core/concept/site_set.hh (revision 3090) +++ mln/core/concept/site_set.hh (working copy) @@ -48,17 +48,9 @@ namespace mln { - // Forward declarations. + // Forward declaration. template <typename E> struct Site_Set; - namespace convert - { - - template <typename F, typename T> - void from_to(const F& from, T& to); - - } - /// Site_Set category flag type. template <> Index: mln/core/dpoint.hh --- mln/core/dpoint.hh (revision 3090) +++ mln/core/dpoint.hh (working copy) @@ -40,6 +40,7 @@ # include <mln/algebra/vec.hh> # include <mln/metal/converts_to.hh> + namespace mln { @@ -232,7 +233,7 @@ mlc_converts_to(mln_result(F), C)::check(); const F& f = exact(f_); for (unsigned i = 0; i < dim; ++i) - coord_[i] = f(i); + coord_[i] = static_cast<C>(f(i)); } template <typename G, typename C> Index: mln/math/abs.hh --- mln/math/abs.hh (revision 3090) +++ mln/math/abs.hh (working copy) @@ -29,10 +29,9 @@ #ifndef MLN_MATH_ABS_HH # define MLN_MATH_ABS_HH -/*! \file mln/math/abs.hh - * - * \brief Define the absolute value (abs) routine. - */ +/// \file mln/math/abs.hh +/// +/// Define the absolute value (abs) routine. # include <cmath> # include <cstdlib> @@ -77,7 +76,7 @@ inline T abs(const T& v) { - return v >= 0 ? v : -v; + return v >= 0 ? v : static_cast<T>(-v); } inline int abs(int v) { return std::abs(v); } Index: mln/opt/at.hh --- mln/opt/at.hh (revision 3090) +++ mln/opt/at.hh (working copy) @@ -49,25 +49,25 @@ /// One dimension template <typename I> - mln_rvalue(I) at(const Image<I>& ima, int ind); + mln_rvalue(I) at(const Image<I>& ima, def::coord ind); template <typename I> - mln_lvalue(I) at(Image<I>& ima, int ind); + mln_lvalue(I) at(Image<I>& ima, def::coord ind); /// Two dimensions template <typename I> - mln_rvalue(I) at(const Image<I>& ima, int row, int col); + mln_rvalue(I) at(const Image<I>& ima, def::coord row, def::coord col); template <typename I> - mln_lvalue(I) at(Image<I>& ima, int row, int col); + mln_lvalue(I) at(Image<I>& ima, def::coord row, def::coord col); /// Three dimensions template <typename I> - mln_rvalue(I) at(const Image<I>& ima, int sli, int row, int col); + mln_rvalue(I) at(const Image<I>& ima, def::coord sli, def::coord row, def::coord col); template <typename I> - mln_lvalue(I) at(Image<I>& ima, int sli, int row, int col); + mln_lvalue(I) at(Image<I>& ima, def::coord sli, def::coord row, def::coord col); # ifndef MLN_INCLUDE_ONLY @@ -80,7 +80,7 @@ template <typename I> inline mln_rvalue(I) at_1d_impl(trait::image::category::domain_morpher, - const Image<I>& ima, int ind) + const Image<I>& ima, def::coord ind) { point1d p(ind); return exact(ima)(p); @@ -89,7 +89,7 @@ template <typename I> inline mln_rvalue(I) at_1d_impl(trait::image::category::morpher, - const Image<I>& ima, int ind) + const Image<I>& ima, def::coord ind) { // FIXME: what about morpher that modify the image value? // (through a function for instance) @@ -99,7 +99,7 @@ template <typename I> inline mln_rvalue(I) at_1d_impl(trait::image::category::primary, - const Image<I>& ima, int ind) + const Image<I>& ima, def::coord ind) { return exact(ima).at(ind); } @@ -108,7 +108,7 @@ template <typename I> inline mln_lvalue(I) at_1d_impl(trait::image::category::domain_morpher, - Image<I>& ima, int ind) + Image<I>& ima, def::coord ind) { mlc_is(mln_trait_image_pw_io(I), trait::image::pw_io::read_write)::check(); @@ -120,7 +120,7 @@ template <typename I> inline mln_lvalue(I) at_1d_impl(trait::image::category::morpher, - Image<I>& ima, int ind) + Image<I>& ima, def::coord ind) { // FIXME: what about morpher that modify the image value? // (through a function for instance) @@ -130,7 +130,7 @@ template <typename I> inline mln_lvalue(I) at_1d_impl(trait::image::category::primary, - Image<I>& ima, int ind) + Image<I>& ima, def::coord ind) { return exact(ima).at(ind); } @@ -139,7 +139,7 @@ template <typename I> inline - mln_rvalue(I) at(const Image<I>& ima, int ind) + mln_rvalue(I) at(const Image<I>& ima, def::coord ind) { mlc_is(mln_trait_image_dimension(I), trait::image::dimension::one_d)::check(); @@ -148,7 +148,7 @@ } template <typename I> - mln_lvalue(I) at(Image<I>& ima, int ind) + mln_lvalue(I) at(Image<I>& ima, def::coord ind) { mlc_is(mln_trait_image_dimension(I), trait::image::dimension::one_d)::check(); @@ -165,7 +165,7 @@ template <typename I> inline mln_rvalue(I) at_2d_impl(trait::image::category::domain_morpher, - const Image<I>& ima, int row, int col) + const Image<I>& ima, def::coord row, def::coord col) { point2d p(row, col); return exact(ima)(p); @@ -174,7 +174,7 @@ template <typename I> inline mln_rvalue(I) at_2d_impl(trait::image::category::morpher, - const Image<I>& ima, int row, int col) + const Image<I>& ima, def::coord row, def::coord col) { // FIXME: what about morpher that modify the image value? // (through a function for instance) @@ -184,7 +184,7 @@ template <typename I> inline mln_rvalue(I) at_2d_impl(trait::image::category::primary, - const Image<I>& ima, int row, int col) + const Image<I>& ima, def::coord row, def::coord col) { return exact(ima).at(row, col); } @@ -193,7 +193,7 @@ template <typename I> inline mln_lvalue(I) at_2d_impl(trait::image::category::domain_morpher, - Image<I>& ima, int row, int col) + Image<I>& ima, def::coord row, def::coord col) { mlc_is(mln_trait_image_pw_io(I), trait::image::pw_io::read_write)::check(); @@ -205,7 +205,7 @@ template <typename I> inline mln_lvalue(I) at_2d_impl(trait::image::category::morpher, - Image<I>& ima, int row, int col) + Image<I>& ima, def::coord row, def::coord col) { // FIXME: what about morpher that modify the image value? // (through a function for instance) @@ -215,7 +215,7 @@ template <typename I> inline mln_lvalue(I) at_2d_impl(trait::image::category::primary, - Image<I>& ima, int row, int col) + Image<I>& ima, def::coord row, def::coord col) { return exact(ima).at(row, col); } @@ -224,7 +224,7 @@ template <typename I> inline - mln_rvalue(I) at(const Image<I>& ima, int row, int col) + mln_rvalue(I) at(const Image<I>& ima, def::coord row, def::coord col) { mlc_is(mln_trait_image_dimension(I), trait::image::dimension::two_d)::check(); @@ -233,7 +233,7 @@ } template <typename I> - mln_lvalue(I) at(Image<I>& ima, int row, int col) + mln_lvalue(I) at(Image<I>& ima, def::coord row, def::coord col) { mlc_is(mln_trait_image_dimension(I), trait::image::dimension::two_d)::check(); @@ -249,7 +249,7 @@ template <typename I> inline mln_rvalue(I) at_3d_impl(trait::image::category::domain_morpher, - const Image<I>& ima, int sli, int row, int col) + const Image<I>& ima, def::coord sli, def::coord row, def::coord col) { point3d p(sli, row, col); return exact(ima)(p); @@ -258,7 +258,7 @@ template <typename I> inline mln_rvalue(I) at_3d_impl(trait::image::category::morpher, - const Image<I>& ima, int sli, int row, int col) + const Image<I>& ima, def::coord sli, def::coord row, def::coord col) { // FIXME: what about morpher that modify the image value? // (through a function for instance) @@ -268,7 +268,7 @@ template <typename I> inline mln_rvalue(I) at_3d_impl(trait::image::category::primary, - const Image<I>& ima, int sli, int row, int col) + const Image<I>& ima, def::coord sli, def::coord row, def::coord col) { return exact(ima).at(sli, row, col); } @@ -277,7 +277,7 @@ template <typename I> inline mln_lvalue(I) at_3d_impl(trait::image::category::domain_morpher, - Image<I>& ima, int sli, int row, int col) + Image<I>& ima, def::coord sli, def::coord row, def::coord col) { mlc_is(mln_trait_image_pw_io(I), trait::image::pw_io::read_write)::check(); @@ -289,7 +289,7 @@ template <typename I> inline mln_lvalue(I) at_3d_impl(trait::image::category::morpher, - Image<I>& ima, int sli, int row, int col) + Image<I>& ima, def::coord sli, def::coord row, def::coord col) { // FIXME: what about morpher that modify the image value? // (through a function for instance) @@ -299,7 +299,7 @@ template <typename I> inline mln_lvalue(I) at_3d_impl(trait::image::category::primary, - Image<I>& ima, int sli, int row, int col) + Image<I>& ima, def::coord sli, def::coord row, def::coord col) { return exact(ima).at(sli, row, col); } @@ -308,7 +308,7 @@ template <typename I> inline - mln_rvalue(I) at(const Image<I>& ima, int sli, int row, int col) + mln_rvalue(I) at(const Image<I>& ima, def::coord sli, def::coord row, def::coord col) { mlc_is(mln_trait_image_dimension(I), trait::image::dimension::three_d)::check(); @@ -318,7 +318,7 @@ } template <typename I> - mln_lvalue(I) at(Image<I>& ima, int sli, int row, int col) + mln_lvalue(I) at(Image<I>& ima, def::coord sli, def::coord row, def::coord col) { mlc_is(mln_trait_image_dimension(I), trait::image::dimension::three_d)::check(); Index: mln/accu/sum.hh --- mln/accu/sum.hh (revision 3090) +++ mln/accu/sum.hh (working copy) @@ -123,7 +123,7 @@ inline void sum<T,S>::take(const argument& t) { - s_ += t; + s_ += static_cast<S>(t); } template <typename T, typename S> Index: mln/accu/line.hh --- mln/accu/line.hh (revision 3090) +++ mln/accu/line.hh (working copy) @@ -125,8 +125,8 @@ O& output = exact(output_); // Avoid warning in signed/unsigned comparison. - const def::coord len = len_; - const def::coord half_length = half_length_; + const def::coord len = static_cast<def::coord>(len_); + const def::coord half_length = static_cast<def::coord>(half_length_); // Checks and tests. internal::line_tests<Meta_Accu, Dir>(input, @@ -136,7 +136,7 @@ // Initialization. const def::coord start = p_start[Dir]; - const def::coord last = start + len - 1; + const def::coord last = static_cast<def::coord>(start + len - 1); A a; // Accumulator. a.init(); P p; // Current point. @@ -159,7 +159,7 @@ P p_plus = p_start; def::coord& plus = p_plus[Dir]; - plus += half_length; + plus = static_cast<def::coord>(plus + half_length); while (cur < start + half_length && cur < last) { Index: mln/accu/mean.hh --- mln/accu/mean.hh (revision 3090) +++ mln/accu/mean.hh (working copy) @@ -1,4 +1,5 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2007, 2008 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 @@ -149,14 +150,15 @@ M mean<T,S,M>::to_result() const { - return sum_.to_result() / count_.to_result(); + S n = static_cast<S>(count_.to_result()); + return static_cast<M>(sum_.to_result() / n); } template <typename T, typename S, typename M> inline mean<T,S,M>::operator M() const { - return M(sum_.to_result() / count_.to_result()); + return to_result(); } template <typename T, typename S, typename M> Index: mln/value/float01_.hh --- mln/value/float01_.hh (revision 3090) +++ mln/value/float01_.hh (working copy) @@ -113,6 +113,9 @@ /// Conversion to a float. operator float() const; + + private: + typedef mln_enc(int_u<n>) enc_; }; @@ -166,7 +169,7 @@ { mln_precondition(val >= 0); mln_precondition(val <= 1); - this->v_ = int(val * (mln_card(float01_<n>) - 1)); // FIXME + this->v_ = static_cast<enc_>(val * (mln_card(float01_<n>) - 1)); // FIXME } template <unsigned n> @@ -174,7 +177,7 @@ float float01_<n>::value() const { - return float(this->v_) / (mln_card(float01_<n>) - 1); // FIXME + return float(this->v_) / float(mln_card(float01_<n>) - 1); // FIXME } template <unsigned n> @@ -182,7 +185,7 @@ void float01_<n>::set_ind(unsigned long val) { - this->v_ = val; + this->v_ = static_cast<enc_>(val); } template <unsigned n> @@ -192,7 +195,7 @@ { mln_precondition(val >= 0); mln_precondition(val <= 1); - this->v_ = int(val * (mln_card(float01_<n>) - 1)); // FIXME + this->v_ = static_cast<enc_>(val * (mln_card(float01_<n>) - 1)); // FIXME return *this; } @@ -200,7 +203,7 @@ inline float01_<n>::operator float() const { - return float(this->v_) / (mln_card(float01_<n>) - 1); + return float(this->v_) / float(mln_card(float01_<n>) - 1); } Index: mln/value/int_s.hh --- mln/value/int_s.hh (revision 3090) +++ mln/value/int_s.hh (working copy) @@ -1,4 +1,5 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -28,10 +29,9 @@ #ifndef MLN_VALUE_INT_S_HH # define MLN_VALUE_INT_S_HH -/*! \file mln/value/int_s.hh - * - * \brief Define a generic class for signed integers. - */ +/// \file mln/value/int_s.hh +/// +/// Define a generic class for signed integers. # include <mln/value/ops.hh> @@ -139,6 +139,9 @@ /// Unit value. static const int_s<n> one; + + private: + typedef typename internal::encoding_signed_<n>::ret enc_; }; @@ -184,7 +187,7 @@ static const int min = - max; mln_precondition(i >= min); mln_precondition(i <= max); - this->v_ = i; + this->v_ = static_cast<enc_>(i); } template <unsigned n> @@ -196,7 +199,7 @@ static const int min = - max; mln_precondition(i >= min); mln_precondition(i <= max); - this->v_ = i; + this->v_ = static_cast<enc_>(i); return *this; } Index: mln/value/int_u.hh --- mln/value/int_u.hh (revision 3090) +++ mln/value/int_u.hh (working copy) @@ -183,7 +183,7 @@ { mln_precondition(i >= 0); mln_precondition(unsigned(i) <= mln_max(enc_)); - this->v_ = enc_(i); + this->v_ = static_cast<enc_>(i); } template <unsigned n> @@ -240,7 +240,7 @@ { mln_precondition(i >= 0); mln_precondition(unsigned(i) <= mln_max(enc_)); - this->v_ = i; + this->v_ = static_cast<enc_>(i); return *this; } Index: mln/value/float01.hh --- mln/value/float01.hh (revision 3090) +++ mln/value/float01.hh (working copy) @@ -1,5 +1,5 @@ -// Copyright (C) 2006, 2007, 2008 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2006, 2007, 2008 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 @@ -167,16 +167,16 @@ inline float01::float01(unsigned nbits, float val) - : nbits_(nbits), - val_(unsigned(val * internal::two_pow_n_minus_1(nbits))) + : nbits_(nbits) { + val_ = static_cast<unsigned long>(val * float(internal::two_pow_n_minus_1(nbits))); } inline float float01::value() const { mln_invariant(nbits_ != 0); - return double(val_) / internal::two_pow_n_minus_1(nbits_); + return float(val_) / float(internal::two_pow_n_minus_1(nbits_)); } inline @@ -228,7 +228,7 @@ float01::operator float() const { mln_precondition(nbits_ != 0); - float tmp = float(val_) / internal::two_pow_n_minus_1(nbits_); + float tmp = float(val_) / float(internal::two_pow_n_minus_1(nbits_)); return tmp; } Index: mln/make/win_chamfer.hh --- mln/make/win_chamfer.hh (revision 3090) +++ mln/make/win_chamfer.hh (working copy) @@ -1,4 +1,5 @@ // Copyright (C) 2006, 2008 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 @@ -25,18 +26,20 @@ // reasons why the executable file might be covered by the GNU General // Public License. - #ifndef MLN_MAKE_WIN_CHAMFER_HH -# define MLN_MAKE_WIN_CHAMFER_HH\ +# define MLN_MAKE_WIN_CHAMFER_HH /// \file mln/make/win_chamfer.hh /// /// Routine to create chamfer mln::w_window2d_int. +/// +/// \todo Revamp! +# include <cmath> # include <mln/core/alias/w_window2d_int.hh> # include <mln/core/alias/w_window2d_float.hh> -# include <math.h> + namespace mln { @@ -45,46 +48,40 @@ { template<int d10, int d11> - const mln::w_window2d_int mk_chamfer_3x3_int(); + mln::w_window2d_int + mk_chamfer_3x3_int(); template<int d10, int d11, int d21> - const mln::w_window2d_int mk_chamfer_5x5_int(); + mln::w_window2d_int + mk_chamfer_5x5_int(); - const mln::w_window2d_float mk_chamfer_3x3_float(float d10, float d11); + mln::w_window2d_float + mk_chamfer_3x3_float(float d10, float d11); - const mln::w_window2d_float + mln::w_window2d_float mk_chamfer_5x5_float(float d10, float d11, float d21); - const mln::w_window2d_float mk_chamfer_exact(); - - } // end of namespace mln::make - -} // end of namespace mln + mln::w_window2d_float + mk_chamfer_exact(); # ifndef MLN_INCLUDE_ONLY -namespace mln -{ - - namespace make - { - template<int d10, int d11> inline - const mln::w_window2d_int + mln::w_window2d_int mk_chamfer_3x3_int() { int ws[] = { d11, d10, d11, d10, 0, 0, 0, 0, 0 }; - return (make::w_window2d(ws)); + return make::w_window2d(ws); } template<int d10, int d11, int d21> inline - const mln::w_window2d_int + mln::w_window2d_int mk_chamfer_5x5_int() { int ws[] = { 0, d21, 0, d21, 0, @@ -93,22 +90,22 @@ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - return (make::w_window2d(ws)); + return make::w_window2d(ws); } inline - const mln::w_window2d_float + mln::w_window2d_float mk_chamfer_3x3_float(float d10, float d11) { float ws[] = { d11, d10, d11, d10, 0, 0, 0, 0, 0 }; - return (make::w_window2d(ws)); + return make::w_window2d(ws); } inline - const mln::w_window2d_float + mln::w_window2d_float mk_chamfer_5x5_float(float d10, float d11, float d21) { float ws[] = { 0, d21, 0, d21, 0, @@ -117,25 +114,26 @@ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - return (make::w_window2d(ws)); + return make::w_window2d(ws); } inline - const mln::w_window2d_float + mln::w_window2d_float mk_chamfer_exact() { - float r2 = sqrt(2); + float r2 = static_cast<float>(std::sqrt(2)); float ws[] = { r2, 1, r2, 1, 0, 0, 0, 0, 0 }; - return (make::w_window2d(ws)); + return make::w_window2d(ws); } +# endif // ! MLN_INCLUDE_ONLY + } // end of namespace mln::make } // end of namespace mln -# endif // !MLN_INCLUDE_ONLY #endif // ! MLN_MAKE_WIN_CHAMFER_HH Index: mln/make/image.hh --- mln/make/image.hh (revision 3090) +++ mln/make/image.hh (working copy) @@ -85,7 +85,8 @@ { mlc_bool(L != 0)::check(); mln::image1d<V> tmp(L); - for (unsigned ind = 0; ind < L; ++ind) + const def::coord ninds = static_cast<def::coord>(L); + for (def::coord ind = 0; ind < ninds; ++ind) tmp(point1d(ind)) = values[ind]; return tmp; } @@ -96,8 +97,11 @@ { mlc_bool(R != 0 && C != 0)::check(); mln::image2d<V> tmp(R, C); - for (unsigned row = 0; row < R; ++row) - for (unsigned col = 0; col < C; ++col) + const def::coord + nrows = static_cast<def::coord>(R), + ncols = static_cast<def::coord>(C); + for (def::coord row = 0; row < nrows; ++row) + for (def::coord col = 0; col < ncols; ++col) opt::at(tmp, row, col) = values[row][col]; return tmp; } @@ -108,9 +112,13 @@ { mlc_bool(S != 0 && R != 0 && C != 0)::check(); mln::image3d<V> tmp(S, R, C); - for (unsigned sli = 0; sli < S; ++sli) - for (unsigned row = 0; row < R; ++row) - for (unsigned col = 0; col < C; ++col) + const def::coord + nslis = static_cast<def::coord>(S), + nrows = static_cast<def::coord>(R), + ncols = static_cast<def::coord>(C); + for (def::coord sli = 0; sli < nslis; ++sli) + for (def::coord row = 0; row < nrows; ++row) + for (def::coord col = 0; col < ncols; ++col) opt::at(tmp, sli, row, col) = values[sli][row][col]; return tmp; } Index: mln/make/box2d_h.hh --- mln/make/box2d_h.hh (revision 3090) +++ mln/make/box2d_h.hh (working copy) @@ -1,4 +1,5 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -28,10 +29,9 @@ #ifndef MLN_MAKE_BOX2D_H_HH # define MLN_MAKE_BOX2D_H_HH -/*! \file mln/make/box2d_h.hh - * - * \brief Routines to construct an mln::box2d_h. - */ +/// \file mln/make/box2d_h.hh +/// +/// Routines to construct an mln::box2d_h. # include <mln/core/alias/box2d_h.hh> # include <mln/make/point2d_h.hh> @@ -68,8 +68,8 @@ * * \return A 2D_H box. */ - mln::box2d_h box2d_h(int min_row, int min_col, - int max_row, int max_col); + mln::box2d_h box2d_h(def::coord min_row, def::coord min_col, + def::coord max_row, def::coord max_col); # ifndef MLN_INCLUDE_ONLY @@ -79,13 +79,14 @@ { mln_precondition(nrows != 0 && ncols != 0); mln::box2d_h tmp(point2d_h(0, 0), - point2d_h(nrows - 1, ncols - 1)); + point2d_h(static_cast<def::coord>(nrows - 1), + static_cast<def::coord>(ncols - 1))); return tmp; } inline - mln::box2d_h box2d_h(int min_row, int min_col, - int max_row, int max_col) + mln::box2d_h box2d_h(def::coord min_row, def::coord min_col, + def::coord max_row, def::coord max_col) { mln_precondition(max_row >= min_row && max_col >= min_col); mln::box2d_h tmp(point2d_h(min_row, min_col), Index: mln/make/point2d_h.hh --- mln/make/point2d_h.hh (revision 3090) +++ mln/make/point2d_h.hh (working copy) @@ -1,4 +1,5 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -28,10 +29,9 @@ #ifndef MLN_MAKE_POINT2D_H_HH # define MLN_MAKE_POINT2D_H_HH -/*! \file mln/make/point2d_h.hh - * - * \brief Routine to construct an mln::point2d_h. - */ +/// \file mln/make/point2d_h.hh +/// +/// Routine to construct an mln::point2d_h. # include <mln/core/alias/point2d_h.hh> @@ -49,13 +49,13 @@ * * \return A 2D point. */ - mln::point2d_h point2d_h(int row, int col); + mln::point2d_h point2d_h(def::coord row, def::coord col); # ifndef MLN_INCLUDE_ONLY inline - mln::point2d_h point2d_h(int row, int col) + mln::point2d_h point2d_h(def::coord row, def::coord col) { mln::point2d_h tmp; tmp[0] = row; Index: mln/make/dpoint2d_h.hh --- mln/make/dpoint2d_h.hh (revision 3090) +++ mln/make/dpoint2d_h.hh (working copy) @@ -1,4 +1,5 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -28,10 +29,9 @@ #ifndef MLN_MAKE_DPOINT2D_H_HH # define MLN_MAKE_DPOINT2D_H_HH -/*! \file mln/make/dpoint2d_h.hh - * - * \brief Routine to construct an mln::dpoint2d_h. - */ +/// \file mln/make/dpoint2d_h.hh +/// +/// Routine to construct an mln::dpoint2d_h. # include <mln/core/alias/dpoint2d_h.hh> @@ -49,13 +49,13 @@ * * \return A 2D dpoint. */ - mln::dpoint2d_h dpoint2d_h(int row, int col); + mln::dpoint2d_h dpoint2d_h(def::coord row, def::coord col); # ifndef MLN_INCLUDE_ONLY inline - mln::dpoint2d_h dpoint2d_h(int row, int col) + mln::dpoint2d_h dpoint2d_h(def::coord row, def::coord col) { mln::dpoint2d_h tmp; tmp[0] = row; Index: mln/make/box1d.hh --- mln/make/box1d.hh (revision 3090) +++ mln/make/box1d.hh (working copy) @@ -1,4 +1,5 @@ // Copyright (C) 2007, 2008 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 @@ -28,10 +29,9 @@ #ifndef MLN_MAKE_BOX1D_HH # define MLN_MAKE_BOX1D_HH -/*! \file mln/make/box1d.hh - * - * \brief Routines to construct an mln::box1d. - */ +/// \file mln/make/box1d.hh +/// +/// Routines to construct an mln::box1d. # include <mln/core/alias/box1d.hh> @@ -74,7 +74,7 @@ { mln_precondition(ninds != 0); mln::box1d tmp(point1d(0), - point1d(ninds - 1)); + point1d(static_cast<def::coord>(ninds - 1))); return tmp; } Index: mln/make/box2d.hh --- mln/make/box2d.hh (revision 3090) +++ mln/make/box2d.hh (working copy) @@ -1,4 +1,5 @@ // Copyright (C) 2007, 2008 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 @@ -28,10 +29,9 @@ #ifndef MLN_MAKE_BOX2D_HH # define MLN_MAKE_BOX2D_HH -/*! \file mln/make/box2d.hh - * - * \brief Routines to construct an mln::box2d. - */ +/// \file mln/make/box2d.hh +/// +/// Routines to construct an mln::box2d. # include <mln/core/alias/box2d.hh> Index: mln/make/box3d.hh --- mln/make/box3d.hh (revision 3090) +++ mln/make/box3d.hh (working copy) @@ -1,4 +1,5 @@ // Copyright (C) 2007, 2008 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 @@ -28,10 +29,9 @@ #ifndef MLN_MAKE_BOX3D_HH # define MLN_MAKE_BOX3D_HH -/*! \file mln/make/box3d.hh - * - * \brief Routines to construct an mln::box3d. - */ +/// \file mln/make/box3d.hh +/// +/// Routines to construct an mln::box3d. # include <mln/core/alias/box3d.hh> @@ -84,7 +84,9 @@ { mln_precondition(nrows != 0 && ncols != 0 && nslis != 0); mln::box3d tmp(point3d(0, 0, 0), - point3d(nslis - 1, nrows - 1, ncols - 1)); + point3d(static_cast<def::coord>(nslis - 1), + static_cast<def::coord>(nrows - 1), + static_cast<def::coord>(ncols - 1))); return tmp; } Index: mln/border/mirror.hh --- mln/border/mirror.hh (revision 3090) +++ mln/border/mirror.hh (working copy) @@ -1,4 +1,5 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -28,11 +29,12 @@ #ifndef MLN_BORDER_MIRROR_HH # define MLN_BORDER_MIRROR_HH -/*! \file mln/border/mirror.hh - * - * \brief Define function that fills border using nearer pixels with a - * mirroring effect. - */ +/// \file mln/border/mirror.hh +/// +/// Define function that fills border using nearer pixels with a +/// mirroring effect. +/// +/// \todo Awful code: rewrite it! # include <mln/core/image/image1d.hh> # include <mln/core/image/image2d.hh> @@ -47,6 +49,7 @@ # include <mln/geom/max_col.hh> # include <mln/geom/ninds.hh> + namespace mln { Index: mln/convert/to_image.hh --- mln/convert/to_image.hh (revision 3090) +++ mln/convert/to_image.hh (working copy) @@ -47,6 +47,7 @@ # include <mln/core/image/image1d.hh> # include <mln/core/image/image2d.hh> # include <mln/core/image/image3d.hh> +# include <mln/convert/from_to.hh> namespace mln Index: mln/win/line.hh --- mln/win/line.hh (revision 3090) +++ mln/win/line.hh (working copy) @@ -111,8 +111,10 @@ mln_precondition(length % 2 == 1); dpoint<M,C> n; n.set_all(0); - const int dc = length / 2; - for (int c = - dc; c <= dc; ++c) + const def::coord + dc = static_cast<def::coord>(length / 2), + minus_dc = static_cast<def::coord>(- dc); + for (def::coord c = minus_dc; c <= dc; ++c) { n[i] = c; this->insert(n); Index: mln/win/diag2d.hh --- mln/win/diag2d.hh (revision 3090) +++ mln/win/diag2d.hh (working copy) @@ -1,4 +1,5 @@ // Copyright (C) 2007, 2008 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 @@ -28,10 +29,9 @@ #ifndef MLN_WIN_DIAG2D_HH # define MLN_WIN_DIAG2D_HH -/*! \file mln/win/diag2d.hh - * - * \brief Definition of the mln::win::diag2d window. - */ +/// \file mln/win/diag2d.hh +/// +/// Definition of the mln::win::diag2d window. # include <mln/core/internal/classical_window_base.hh> # include <mln/core/alias/dpoint2d.hh> @@ -93,9 +93,12 @@ : length_(length) { mln_precondition(length % 2 == 1); - const int dcol = length / 2; - for (int col = - dcol; col <= dcol; ++col) - insert(dpoint2d(-col, col)); + const def::coord + dcol = static_cast<def::coord>(length) / 2, + minus_dcol = static_cast<def::coord>(-dcol); + for (def::coord col = minus_dcol; col <= dcol; ++col) + insert(dpoint2d(static_cast<def::coord>(-col), + col)); } inline Index: mln/win/backdiag2d.hh --- mln/win/backdiag2d.hh (revision 3090) +++ mln/win/backdiag2d.hh (working copy) @@ -1,4 +1,5 @@ // Copyright (C) 2007, 2008 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 @@ -28,10 +29,9 @@ #ifndef MLN_WIN_BACKDIAG2D_HH # define MLN_WIN_BACKDIAG2D_HH -/*! \file mln/win/backdiag2d.hh - * - * \brief Definition of the mln::win::backdiag2d window. - */ +/// \file mln/win/backdiag2d.hh +/// +/// Definition of the mln::win::backdiag2d window. # include <mln/core/internal/classical_window_base.hh> # include <mln/core/alias/dpoint2d.hh> @@ -93,8 +93,10 @@ : length_(length) { mln_precondition(length % 2 == 1); - const int dcol = length / 2; - for (int col = - dcol; col <= dcol; ++col) + const def::coord + dcol = static_cast<def::coord>(length / 2), + minus_dcol = static_cast<def::coord>(- dcol); + for (def::coord col = minus_dcol; col <= dcol; ++col) insert(dpoint2d(col, col)); } Index: mln/win/octagon2d.hh --- mln/win/octagon2d.hh (revision 3090) +++ mln/win/octagon2d.hh (working copy) @@ -1,4 +1,5 @@ // Copyright (C) 2007, 2008 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 @@ -28,10 +29,9 @@ #ifndef MLN_WIN_OCTAGON2D_HH # define MLN_WIN_OCTAGON2D_HH -/*! \file mln/win/octagon2d.hh - * - * \brief Definition of the mln::win::octagon2d window. - */ +/// \file mln/win/octagon2d.hh +/// +/// Definition of the mln::win::octagon2d window. # include <mln/core/internal/classical_window_base.hh> # include <mln/core/alias/dpoint2d.hh> @@ -101,29 +101,42 @@ : length_(length) { mln_precondition(length % 6 == 1); - const int y = length / 6; - const int x = y * 2; - const int z = y + x; + const def::coord + y = static_cast<def::coord>(length / 6), + x = static_cast<def::coord>(y * 2), + z = static_cast<def::coord>(y + x); insert(dpoint2d(0, 0)); - for (int a = 1; a <= x; ++a) - for (int b = 0; b <= x; ++b) + for (def::coord a = 1; a <= x; ++a) + for (def::coord b = 0; b <= x; ++b) { + def::coord + _a = static_cast<def::coord>(-a), + _b = static_cast<def::coord>(-b); insert(dpoint2d(a, b)); - insert(dpoint2d(-b, a)); - insert(dpoint2d(b, -a)); - insert(dpoint2d(-a, -b)); - } - for (int a = x + 1; a <= z; ++a) - for (int b = -2 * x + a; b <= 2 * x - a; ++b) - { + insert(dpoint2d(_b, a)); + insert(dpoint2d(b, _a)); + insert(dpoint2d(_a, _b)); + } + const def::coord a_min = static_cast<def::coord>(x + 1); + for (def::coord a = a_min; a <= z; ++a) + { + const def::coord + b_min = static_cast<def::coord>(-2 * x + a), + b_max = static_cast<def::coord>(2 * x - a); + for (def::coord b = b_min; b <= b_max; ++b) + { + def::coord + _a = static_cast<def::coord>(-a), + _b = static_cast<def::coord>(-b); insert(dpoint2d(a, b)); - insert(dpoint2d(a, -b)); - insert(dpoint2d(-a, b)); - insert(dpoint2d(-a, -b)); + insert(dpoint2d(a, _b)); + insert(dpoint2d(_a, b)); + insert(dpoint2d(_a, _b)); insert(dpoint2d(b, a)); - insert(dpoint2d(b, -a)); - insert(dpoint2d(-b, a)); - insert(dpoint2d(-b, -a)); + insert(dpoint2d(b, _a)); + insert(dpoint2d(_b, a)); + insert(dpoint2d(_b, _a)); + } } } Index: mln/win/disk2d.hh --- mln/win/disk2d.hh (revision 3090) +++ mln/win/disk2d.hh (working copy) @@ -1,4 +1,5 @@ // Copyright (C) 2007, 2008 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 @@ -28,10 +29,9 @@ #ifndef MLN_WIN_DISK2D_HH # define MLN_WIN_DISK2D_HH -/*! \file mln/win/disk2d.hh - * - * \brief Definition of the mln::win::disk2d window. - */ +/// \file mln/win/disk2d.hh +/// +/// Definition of the mln::win::disk2d window. # include <mln/core/internal/classical_window_base.hh> # include <mln/core/alias/dpoint2d.hh> @@ -48,7 +48,7 @@ /*! \brief Disk window defined on the 2D square grid. * - * An disk2d is centered and symmetric. + * A disk2d is centered and symmetric. * */ struct disk2d : public internal::classical_window_base< dpoint2d, disk2d > @@ -84,10 +84,12 @@ : length_(length) { mln_precondition(length % 2 == 1); - const int r = length / 2; - const int r2 = r * r; - for (int a = -r; a <= r; ++a) - for (int b = -r; b <= r; ++b) + const def::coord + r = static_cast<def::coord>(length / 2), + minus_r = static_cast<def::coord>(-r), + r2 = static_cast<def::coord>(r * r); + for (def::coord a = minus_r; a <= r; ++a) + for (def::coord b = minus_r; b <= r; ++b) if (a * a + b * b <= r2) insert(dpoint2d(a, b)); } Index: mln/algebra/mat.hh --- mln/algebra/mat.hh (revision 3090) +++ mln/algebra/mat.hh (working copy) @@ -1,4 +1,5 @@ -// Copyright (C) 2006 EPITA Research and Development Laboratory +// Copyright (C) 2006, 2008 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 @@ -28,11 +29,9 @@ #ifndef MLN_ALGEBRA_MAT_HH # define MLN_ALGEBRA_MAT_HH -/*! - * \file mln/algebra/mat.hh - * - * \brief Definition of a generic matrix class. - */ +/// \file mln/algebra/mat.hh +/// +/// Definition of a generic matrix class. # include <iostream> @@ -309,7 +308,7 @@ { for (unsigned i = 0; i < n; ++i) for (unsigned j = 0; j < m; ++j) - data_[i][j] = rhs(i, j); + data_[i][j] = static_cast<T>( rhs(i, j) ); } template <unsigned n, unsigned m, typename T> @@ -321,7 +320,7 @@ const F& f = exact(f_); for (unsigned i = 0; i < n; ++i) for (unsigned j = 0; j < m; ++j) - data_[i][j] = f(i * n + j); + data_[i][j] = static_cast<T>( f(i * n + j) ); } template <unsigned n, unsigned m, typename T> @@ -332,7 +331,7 @@ { for (unsigned i = 0; i < n; ++i) for (unsigned j = 0; j < m; ++j) - data_[i][j] = rhs(i, j); + data_[i][j] = static_cast<T>( rhs(i, j) ); return *this; } Index: mln/algebra/h_vec.hh --- mln/algebra/h_vec.hh (revision 3090) +++ mln/algebra/h_vec.hh (working copy) @@ -1,4 +1,5 @@ // Copyright (C) 2007, 2008 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 @@ -28,10 +29,9 @@ #ifndef MLN_ALGEBRA_H_VEC_HH # define MLN_ALGEBRA_H_VEC_HH -/*! \file mln/algebra/h_vec.hh - * - * \brief Definition of a vector with homogeneous coordinates. - */ +/// \file mln/algebra/h_vec.hh +/// +/// Definition of a vector with homogeneous coordinates. # include <mln/algebra/vec.hh> # include <mln/literal/one.hh> @@ -150,7 +150,7 @@ vec<d,C> tmp; for (unsigned i = 0; i < d; ++i) - tmp[i] = this->data_[i] / w; + tmp[i] = static_cast<C>(this->data_[i] / w); return tmp; } Index: mln/algebra/vec.hh --- mln/algebra/vec.hh (revision 3090) +++ mln/algebra/vec.hh (working copy) @@ -383,7 +383,7 @@ : super_() { for (unsigned i = 0; i < n; ++i) - data_[i] = rhs[i]; + data_[i] = static_cast<T>(rhs[i]); } template <unsigned n, typename T> @@ -392,7 +392,7 @@ vec<n,T>& vec<n,T>::operator=(const vec<n, U>& rhs) { for (unsigned i = 0; i < n; ++i) - data_[i] = rhs[i]; + data_[i] = static_cast<T>(rhs[i]); return *this; } @@ -436,7 +436,7 @@ n_l2 += data_[i] * data_[i]; n_l2 = sqrt(n_l2); for (unsigned i = 0; i < n; ++i) - data_[i] = T(data_[i] / n_l2); + data_[i] = static_cast<T>(data_[i] / n_l2); return *this; } @@ -448,7 +448,7 @@ mlc_converts_to(mln_result(F), T)::check(); const F& f = exact(f_); for (unsigned i = 0; i < n; ++i) - data_[i] = f(i); + data_[i] = static_cast<T>(f(i)); } @@ -478,7 +478,8 @@ vec<n, mln_trait_op_plus(T,U)> operator+(const vec<n,T>& lhs, const vec<n,U>& rhs) { - vec<n, mln_trait_op_plus(T,U)> tmp; + typedef mln_trait_op_plus(T,U) R; + vec<n, R> tmp; for (unsigned i = 0; i < n; ++i) tmp[i] = lhs[i] + rhs[i]; return tmp; @@ -489,7 +490,8 @@ vec<n, mln_trait_op_minus(T,U)> operator-(const vec<n,T>& lhs, const vec<n,U>& rhs) { - vec<n, mln_trait_op_minus(T,U)> tmp; + typedef mln_trait_op_minus(T,U) R; + vec<n, R> tmp; for (unsigned i = 0; i < n; ++i) tmp[i] = lhs[i] - rhs[i]; return tmp; @@ -500,6 +502,7 @@ mln_sum_x(T,U) operator*(const vec<n,T>& lhs, const vec<n,U>& rhs) { + typedef mln_sum_x(T,U) R; mln_sum_x(T,U) tmp(literal::zero); for (unsigned i = 0; i < n; ++i) tmp += lhs[i] * rhs[i]; @@ -521,7 +524,8 @@ // If we really want to propage the "scalar" status then // we shall allow for scalar(scalar(..)) !!! => FIXME - vec<n, mln_trait_op_times(T, S)> tmp; + typedef mln_trait_op_times(T, S) R; + vec<n, R> tmp; for (unsigned i = 0; i < n; ++i) tmp[i] = lhs[i] * s.to_equiv(); return tmp; @@ -533,7 +537,8 @@ operator/(const vec<n,T>& lhs, const mln::value::scalar_<S>& s) { mln_precondition(value::equiv(s) != (S)(literal::zero)); - vec<n, mln_trait_op_div(T, S)> tmp; + typedef mln_trait_op_div(T, S) R; + vec<n, R> tmp; for (unsigned i = 0; i < n; ++i) tmp[i] = lhs[i] / s.to_equiv(); return tmp; Index: mln/io/pnm/save_header.hh --- mln/io/pnm/save_header.hh (revision 3090) +++ mln/io/pnm/save_header.hh (working copy) @@ -1,5 +1,5 @@ -// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 EPITA -// Research and Development Laboratory +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 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,12 +29,9 @@ #ifndef MLN_IO_PNM_SAVE_HEADER_HH # define MLN_IO_PNM_SAVE_HEADER_HH -/*! - * \file mln/io/pnm/save_header.hh - * - * \brief Define a function which saves header for PNM image. - * - */ +/// \file mln/io/pnm/save_header.hh +/// +/// Define a function which saves header for PNM image. # include <iostream> # include <fstream> @@ -45,6 +42,7 @@ # include <mln/geom/nrows.hh> # include <mln/geom/ncols.hh> + namespace mln { @@ -70,7 +68,7 @@ template <typename I> inline - void save_header(const char type, + void save_header(char type, const I& ima, const std::string& filename, std::ofstream& file) { Index: mln/io/pnm/load_header.hh --- mln/io/pnm/load_header.hh (revision 3090) +++ mln/io/pnm/load_header.hh (working copy) @@ -60,7 +60,7 @@ // check magic if (istr.get() != 'P' ) goto err; - type = istr.get(); + type = static_cast<char>(istr.get()); if (type < '1' || type > '6') goto err; Index: mln/io/pnm/save.hh --- mln/io/pnm/save.hh (revision 3090) +++ mln/io/pnm/save.hh (working copy) @@ -1,5 +1,5 @@ // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 EPITA -// Research and Development Laboratory +// 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,13 +29,10 @@ #ifndef MLN_IO_PNM_SAVE_HH # define MLN_IO_PNM_SAVE_HH -/*! - * \file mln/io/pnm/save.hh - * - * \brief Define a function which saves an image of kind PNM into - * given path. - * - */ +/// \file mln/io/pnm/save.hh +/// +/// Define a function which saves an image of kind PNM into +/// given path. # include <iostream> # include <fstream> @@ -72,7 +69,8 @@ * \param[in,out] filename the destination. */ template <typename I> - void save(const int type, const Image<I>& ima_, const std::string& filename); + void save(char type, const Image<I>& ima_, const std::string& filename); + # ifndef MLN_INCLUDE_ONLY @@ -116,7 +114,7 @@ void save_data_uncontiguous(std::ofstream& file, const I& ima) { - const int + const def::coord min_row = geom::min_row(ima), max_row = geom::max_row(ima), min_col = geom::min_col(ima), @@ -136,7 +134,7 @@ const I& ima_) { const I& ima = exact(ima_); - const int + const def::coord min_row = geom::min_row(ima), max_row = geom::max_row(ima); point2d p; @@ -175,7 +173,7 @@ template <typename I> inline - void save(const int type, const Image<I>& ima_, const std::string& filename) + void save(char type, const Image<I>& ima_, const std::string& filename) { trace::entering("mln::io::pnm::save"); const I& ima = exact(ima_); Index: mln/io/pnm/load.hh --- mln/io/pnm/load.hh (revision 3090) +++ mln/io/pnm/load.hh (working copy) @@ -29,12 +29,10 @@ #ifndef MLN_IO_PNM_LOAD_HH # define MLN_IO_PNM_LOAD_HH -/*! - * \file mln/io/pnm/load.hh - * - * \brief Define a function which loads an image of kind PNM 8/16bits with - * given path. - */ +/// \file mln/io/pnm/load.hh +/// +/// Define a function which loads an image of kind PNM 8/16bits with +/// given path. # include <iostream> # include <fstream> @@ -104,7 +102,7 @@ inline void load_raw_2d_uncontiguous(std::ifstream& file, image2d<V>& ima) { - const int + const def::coord min_row = geom::min_row(ima), max_row = geom::max_row(ima), min_col = geom::min_col(ima), @@ -171,7 +169,7 @@ char type = 0; int nrows, ncols; unsigned int maxval; - read_header(type_ - 3, type_, file, type, + read_header(static_cast<char>(type_ - 3), type_, file, type, nrows, ncols, maxval); if (max_component(V()) != maxval) @@ -223,7 +221,7 @@ char type = 0; int nrows, ncols; unsigned int maxval; - read_header(type_ - 3, type_, file, type, + read_header(static_cast<char>(type_ - 3), type_, file, type, nrows, ncols, maxval); if (max_component(mln_value(I)()) != maxval) Index: mln/io/pbm/save.hh --- mln/io/pbm/save.hh (revision 3090) +++ mln/io/pbm/save.hh (working copy) @@ -1,5 +1,5 @@ // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 EPITA -// Research and Development Laboratory +// 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,13 +29,10 @@ #ifndef MLN_IO_PBM_SAVE_HH # define MLN_IO_PBM_SAVE_HH -/*! - * \file mln/io/pbm/save.hh - * - * \brief Define a function which saves an image of kind pbm into - * given path. - * - */ +/// \file mln/io/pbm/save.hh +/// +/// Define a function which saves an image of kind pbm into +/// given path. # include <iostream> # include <fstream> @@ -86,27 +83,31 @@ io::pnm::save_header(PBM, ima, filename, file); - int ncols = geom::ncols(ima); - int col = 0; - int stride = 0; + def::coord + ncols = static_cast<def::coord>(geom::ncols(ima)), + col = 0, + stride = 0; unsigned char c = 0; mln_fwd_piter(I) p(ima.domain()); for_all(p) { - c <<= 1; - c += (ima(p) == true ? 0 : 1); // In pbm, '0' means 'white' so 'object', thus 'true'! + c = static_cast<unsigned char>(c << 1); + if (ima(p) == false) + ++c; // In pbm, '0' means 'white' so 'object', thus 'true'! if (++col >= ncols) { - c <<= (8 - stride - 1); + c = static_cast<unsigned char>(c << (8 - stride - 1)); file << c; - c = col = stride = 0; + c = 0; + col = stride = 0; } else if (++stride >= 8) { file << c; - c = stride = 0; + c = 0; + stride = 0; } } mln_postcondition(stride == 0); Index: tests/data/fill.cc --- tests/data/fill.cc (revision 3090) +++ tests/data/fill.cc (working copy) @@ -1,4 +1,5 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -25,30 +26,25 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/*! \file tests/data/fill.cc - * - * \brief Tests on mln::data::fill - */ +/// \file tests/data/fill.cc +/// +/// Tests on mln::data::fill #include <mln/core/image/image2d.hh> #include <mln/data/fill.hh> + int main() { using namespace mln; - unsigned u = 300; - unsigned char uc = u; - mln_assertion(uc == 44); - - { const unsigned size = 3; image2d<unsigned> ima(size, size); + + unsigned u = 300; data::fill(ima, u); box_fwd_piter_<point2d> p(ima.domain()); for_all (p) mln_assertion (ima(p) == u); } - -} Index: tests/border/fill_full.cc --- tests/border/fill_full.cc (revision 3090) +++ tests/border/fill_full.cc (working copy) @@ -258,8 +258,8 @@ { typedef value::float01_8 T; - T value = T(0.9999); - T v = T(0.111); + T value = static_cast<T>(0.9999f); + T v = static_cast<T>(0.111f); for (int i = 1; i < limits; ++i) for (int j = 1; j < limits; ++j) @@ -273,8 +273,8 @@ { typedef value::float01_16 T; - T value = T(0.9999); - T v = T(0.111); + T value = static_cast<T>(0.9999f); + T v = static_cast<T>(0.111f); for (int i = 1; i < limits; ++i) for (int j = 1; j < limits; ++j) Index: tests/convert/to_p_array.cc --- tests/convert/to_p_array.cc (revision 3090) +++ tests/convert/to_p_array.cc (working copy) @@ -1,4 +1,5 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2007, 2008 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 @@ -38,6 +39,7 @@ #include <mln/convert/to_p_array.hh> + int main() { using namespace mln; @@ -48,7 +50,7 @@ vec1d v1(convert::to_p_array(win1d, p1)); { - unsigned col = 4; + def::coord col = 4; for (size_t i=0; i < v1.nsites(); i++) mln_assertion(v1[i] == point1d(col++)); } @@ -58,11 +60,11 @@ win::rectangle2d win2d(3, 3); vec2d v2(convert::to_p_array(win2d, p2)); - unsigned row = 9; + def::coord row = 9; for (unsigned col = 0; col < v2.nsites(); ++col) { if (col > 0 && !(col%3)) ++row; - mln_assertion(v2[col] == point2d(row, 9 + (col%3))); + mln_assertion(v2[col] == point2d(row, static_cast<def::coord>(9 + (col%3)))); } } Index: tests/convert/to_image.cc --- tests/convert/to_image.cc (revision 3090) +++ tests/convert/to_image.cc (working copy) @@ -27,6 +27,7 @@ // Public License. /// \file tests/convert/to_image.cc +/// /// Tests on mln::convert::to_image. #include <mln/core/image/image2d.hh> Index: tests/win/diag2d.cc --- tests/win/diag2d.cc (revision 3090) +++ tests/win/diag2d.cc (working copy) @@ -1,4 +1,5 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2007, 2008 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 @@ -25,19 +26,17 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/*! \file tests/win/diag2d.cc - * - * \brief Tests on mln::win::diag2d. - */ +/// \file tests/win/diag2d.cc +/// +/// Tests on mln::win::diag2d. #include <cmath> #include <mln/win/diag2d.hh> - #include <mln/convert/to_image.hh> - #include <mln/debug/println.hh> + int main() { using namespace mln; @@ -47,8 +46,8 @@ mln_assertion(diag.delta() == 2); - for (int x = -5; x <= 5; ++x) - for (int y = -5; y <= 5; ++y) + for (def::coord x = -5; x <= 5; ++x) + for (def::coord y = -5; y <= 5; ++y) { mln_assertion(((abs(x) <= 2) && (abs(y) <= 2)) || !diag.has(dpoint2d(x, y)));
16Â years
1
0
0
0
← Newer
1
...
637
638
639
640
641
642
643
...
963
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
Results per page:
10
25
50
100
200