From 1dadfe41b2d9e534f5e7a53e8a78b5fa0a4463fd Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 2 Oct 2022 02:56:12 +0300 Subject: [PATCH] [fuseCut] Fix incorrect rounding of integer division result The intention here likely was to get floating-point division result and round it upwards. However, the division was performed with integer arguments, fractional part was lost and thus std::ceil did nothing. --- src/aliceVision/fuseCut/DelaunayGraphCut.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/aliceVision/fuseCut/DelaunayGraphCut.cpp b/src/aliceVision/fuseCut/DelaunayGraphCut.cpp index 4dd7e9643c..b5d91cdd5b 100644 --- a/src/aliceVision/fuseCut/DelaunayGraphCut.cpp +++ b/src/aliceVision/fuseCut/DelaunayGraphCut.cpp @@ -958,8 +958,8 @@ void DelaunayGraphCut::addMaskHelperPoints(const Point3d voxel[8], const StaticV } } - int syMax = std::ceil(height / step); - int sxMax = std::ceil(width / step); + int syMax = divideRoundUp(height, step); + int sxMax = divideRoundUp(width, step); for(int sy = 0; sy < syMax; ++sy) { @@ -1063,7 +1063,8 @@ void DelaunayGraphCut::fuseFromDepthMaps(const StaticVector& cams, const Po { const auto& imgParams = _mp.getImageParams(i); startIndex[i] = realMaxVertices; - realMaxVertices += std::ceil(imgParams.width / step) * std::ceil(imgParams.height / step); + realMaxVertices += divideRoundUp(imgParams.width, step) * + divideRoundUp(imgParams.height, step); } std::vector verticesCoordsPrepare(realMaxVertices); std::vector pixSizePrepare(realMaxVertices); @@ -1135,8 +1136,8 @@ void DelaunayGraphCut::fuseFromDepthMaps(const StaticVector& cams, const Po } } - int syMax = std::ceil(height/step); - int sxMax = std::ceil(width/step); + int syMax = divideRoundUp(height, step); + int sxMax = divideRoundUp(width, step); #pragma omp parallel for for(int sy = 0; sy < syMax; ++sy) {