Skip to content

Commit

Permalink
[fuseCut] Fix incorrect rounding of integer division result
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
p12tic committed Oct 1, 2022
1 parent a9f4a3d commit 8bb2785
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/aliceVision/fuseCut/DelaunayGraphCut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -1063,7 +1063,8 @@ void DelaunayGraphCut::fuseFromDepthMaps(const StaticVector<int>& 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<Point3d> verticesCoordsPrepare(realMaxVertices);
std::vector<double> pixSizePrepare(realMaxVertices);
Expand Down Expand Up @@ -1135,8 +1136,8 @@ void DelaunayGraphCut::fuseFromDepthMaps(const StaticVector<int>& 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)
{
Expand Down

0 comments on commit 8bb2785

Please sign in to comment.