From 86527359ed86bec3dc9977c527af656dc633610b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Tayeb?= Date: Wed, 8 Jul 2009 11:22:48 +0000 Subject: [PATCH] Minor Bug Fix: trilinear interpolation may crash when querying with coordinates between -1 and 0. Add a test on real coordinates to exit interpolation if it is < 0. --- CGALimageIO/include/CGAL/Image_3.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CGALimageIO/include/CGAL/Image_3.h b/CGALimageIO/include/CGAL/Image_3.h index f4f12d7edc5..6a9eb9fa58e 100644 --- a/CGALimageIO/include/CGAL/Image_3.h +++ b/CGALimageIO/include/CGAL/Image_3.h @@ -221,6 +221,9 @@ Image_3::trilinear_interpolation(const Coord_type& x, const Image_word_type& value_outside, Image_transform transform) const { + // Check on double/float coordinates, because (int)-0.1 gives 0 + if ( x < 0 || y < 0 || z < 0 ) return value_outside; + const Coord_type lx = x / image()->vx; const Coord_type ly = y / image()->vy; const Coord_type lz = z / image()->vz; @@ -406,6 +409,9 @@ Image_3::labellized_trilinear_interpolation(const Coord_type& x, const Coord_type& z, const Image_word_type& value_outside) const { + // Check on double/float coordinates, because (int)-0.1 gives 0 + if ( x < 0 || y < 0 || z < 0 ) return value_outside; + const int dimx = xdim(); const int dimy = ydim(); const int dimz = zdim();