Merge pull request #5478 from janetournois/Tet_remeshing-fix_bad_alloc-jtournois

Tetrahedral_remeshing - fix bad_alloc for very small input mesh
This commit is contained in:
Laurent Rineau 2021-03-10 09:45:39 +01:00
commit fe9a97d86f
1 changed files with 9 additions and 3 deletions

View File

@ -382,11 +382,17 @@ private:
minMax[3 + j] = PN[6 * i + j];
}
for (std::size_t i = 0; i < 3; i++) {
minMax[i] -= 0.001f;
minMax[3 + i] += 0.001f;
minMax[i] *= 0.99;
minMax[3 + i] *= 1.01;
}
for (std::size_t i = 0; i < 3; i++)
{
res[i] = (std::size_t)ceil((minMax[3 + i] - minMax[i]) / cellSize);
if(res[1] == 0)
res[i] = 1;
}
std::size_t LUTSize = res[0] * res[1] * res[2];
LUT.resize(LUTSize);
LUT.assign(LUTSize, 0);
@ -463,7 +469,7 @@ private:
{
if (vp[j] < 0)
p[j] = 0;
if (vp[j] >= res[j])
else if (vp[j] >= res[j])
p[j] = res[j] - 1;
else
p[j] = static_cast<std::size_t>(std::floor(vp[j]));