Merge pull request #5022 from Megidd/fix-infinite-loop

Mesh: Infinite loop when repairing mesh facet indices
This commit is contained in:
Yorik van Havre
2021-09-13 11:36:21 +02:00
committed by GitHub
3 changed files with 12 additions and 7 deletions

View File

@@ -1249,9 +1249,12 @@ bool MeshFixCorruptedFacets::Fixup()
if ( it->Area() <= FLOAT_EPS )
{
unsigned long uId = it.Position();
cTopAlg.RemoveCorruptedFacet(uId);
// due to a modification of the array the iterator became invalid
it.Set(uId-1);
bool removed = cTopAlg.RemoveCorruptedFacet(uId);
if (removed) {
// due to a modification of the array the iterator became invalid
it.Set(uId-1);
}
}
}

View File

@@ -1474,9 +1474,9 @@ void MeshTopoAlgorithm::RemoveDegeneratedFacet(unsigned long index)
}
}
void MeshTopoAlgorithm::RemoveCorruptedFacet(unsigned long index)
bool MeshTopoAlgorithm::RemoveCorruptedFacet(unsigned long index)
{
if (index >= _rclMesh._aclFacetArray.size()) return;
if (index >= _rclMesh._aclFacetArray.size()) return false;
MeshFacet& rFace = _rclMesh._aclFacetArray[index];
// coincident corners (topological)
@@ -1494,9 +1494,11 @@ void MeshTopoAlgorithm::RemoveCorruptedFacet(unsigned long index)
rFace._aulNeighbours[1] = ULONG_MAX;
rFace._aulNeighbours[2] = ULONG_MAX;
_rclMesh.DeleteFacet(index);
return;
return true;
}
}
return false;
}
void MeshTopoAlgorithm::FillupHoles(unsigned long length, int level,

View File

@@ -240,7 +240,7 @@ public:
* Removes the corrupted facet at position \a index from the mesh structure.
* A facet is corrupted if the indices of its corner points are not all different.
*/
void RemoveCorruptedFacet(unsigned long index);
bool RemoveCorruptedFacet(unsigned long index);
/**
* Closes holes in the mesh that consists of up to \a length edges. In case a fit
* needs to be done then the points of the neighbours of \a level rings will be used.