From 06eb921215157f846e04a698438b1a5a8639a40a Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 20 Oct 2014 12:39:03 +0200 Subject: [PATCH] fix the use of integers patch suggested by Bryn Lloyd on cgal-discuss to avoid an integer overflow problem that occurs when generating a 3D mesh from very large images --- CGAL_ImageIO/include/CGAL/Image_3.h | 24 +++++++++---------- .../Image_to_labeled_function_wrapper.h | 6 ++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/CGAL_ImageIO/include/CGAL/Image_3.h b/CGAL_ImageIO/include/CGAL/Image_3.h index 4fea8f4e90b..3050dcfb774 100644 --- a/CGAL_ImageIO/include/CGAL/Image_3.h +++ b/CGAL_ImageIO/include/CGAL/Image_3.h @@ -32,7 +32,7 @@ #include #include - +#include #if defined(BOOST_MSVC) # pragma warning(push) @@ -124,11 +124,11 @@ public: image()->data = d; } - unsigned int xdim() const { return image_ptr->xdim; } - unsigned int ydim() const { return image_ptr->ydim; } - unsigned int zdim() const { return image_ptr->zdim; } + std::size_t xdim() const { return image_ptr->xdim; } + std::size_t ydim() const { return image_ptr->ydim; } + std::size_t zdim() const { return image_ptr->zdim; } - unsigned int size() const { return xdim() * ydim() * zdim(); } + std::size_t size() const { return xdim() * ydim() * zdim(); } double vx() const { return image_ptr->vx; } double vy() const { return image_ptr->vy; } @@ -237,10 +237,10 @@ Image_3::trilinear_interpolation(const Coord_type& x, const Coord_type lx = x / image()->vx; const Coord_type ly = y / image()->vy; const Coord_type lz = z / image()->vz; - const int dimx = xdim(); - const int dimy = ydim(); - const int dimz = zdim(); - const int dimxy = dimx*dimy; + const std::size_t dimx = xdim(); + const std::size_t dimy = ydim(); + const std::size_t dimz = zdim(); + const std::size_t dimxy = dimx*dimy; if(lx < 0 || ly < 0 || @@ -425,9 +425,9 @@ Image_3::labellized_trilinear_interpolation(const Coord_type& x, Coord_type lx = x / image()->vx; Coord_type ly = y / image()->vy; Coord_type lz = z / image()->vz; - const int dimx = xdim(); - const int dimy = ydim(); - const int dimz = zdim(); + const std::size_t dimx = xdim(); + const std::size_t dimy = ydim(); + const std::size_t dimz = zdim(); if( lx < 0 || ly < 0 || diff --git a/Mesh_3/include/CGAL/Mesh_3/Image_to_labeled_function_wrapper.h b/Mesh_3/include/CGAL/Mesh_3/Image_to_labeled_function_wrapper.h index 2bc4051397e..8b95beb6417 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Image_to_labeled_function_wrapper.h +++ b/Mesh_3/include/CGAL/Mesh_3/Image_to_labeled_function_wrapper.h @@ -86,9 +86,9 @@ public: const int py = static_cast(p.y()/r_im_.vy()); const int pz = static_cast(p.z()/r_im_.vz()); - const int dimx = r_im_.xdim(); - const int dimy = r_im_.ydim(); - const int dimz = r_im_.zdim(); + const std::size_t dimx = r_im_.xdim(); + const std::size_t dimy = r_im_.ydim(); + const std::size_t dimz = r_im_.zdim(); if(px < 0 || py < 0 ||