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 349f9264a8d..c51af93feb0 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 @@ -101,9 +101,9 @@ private: { return static_cast(transform( r_im_.template labellized_trilinear_interpolation( - CGAL::to_double(p.x()), - CGAL::to_double(p.y()), - CGAL::to_double(p.z()), + CGAL::to_double(p.x()-r_im_.image()->tx), + CGAL::to_double(p.y()-r_im_.image()->ty), + CGAL::to_double(p.z()-r_im_.image()->tz), value_outside))); } @@ -115,9 +115,9 @@ private: return transform( r_im_.template trilinear_interpolation( - CGAL::to_double(p.x()), - CGAL::to_double(p.y()), - CGAL::to_double(p.z()), + CGAL::to_double(p.x()-r_im_.image()->tx), + CGAL::to_double(p.y()-r_im_.image()->ty), + CGAL::to_double(p.z()-r_im_.image()->tz), value_outside)); } @@ -126,9 +126,9 @@ private: CGAL::Tag_false /*trilinear*/, Labeled_tag /*labeled*/) const { - const std::ptrdiff_t px = static_cast(p.x()/r_im_.vx()); - const std::ptrdiff_t py = static_cast(p.y()/r_im_.vy()); - const std::ptrdiff_t pz = static_cast(p.z()/r_im_.vz()); + const std::ptrdiff_t px = static_cast((p.x()-r_im_.image()->tx)/r_im_.vx()); + const std::ptrdiff_t py = static_cast((p.y()-r_im_.image()->ty)/r_im_.vy()); + const std::ptrdiff_t pz = static_cast((p.z()-r_im_.image()->tz)/r_im_.vz()); const std::ptrdiff_t dimx = static_cast(r_im_.xdim()); const std::ptrdiff_t dimy = static_cast(r_im_.ydim());