Skip to content
Snippets Groups Projects
Commit 48d91b99 authored by Oliver Ruebel's avatar Oliver Ruebel
Browse files

Throw exception if merge tree gets stuck in a loop

parent c7ea03ee
Branches
Tags
2 merge requests!2615Draft: DONTMERGE ME: TEST FOR 1.7.0-rc1 is our 9th official release of VTK-m.,!2420Add/ct iter check
......@@ -377,6 +377,7 @@ inline void ActiveGraph::MakeMergeTree(MergeTree& tree, MeshExtrema& meshExtrema
DebugPrint("Active Graph Computation Starting", __FILE__, __LINE__);
// loop until we run out of active edges
vtkm::Id maxNumIterations = this->EdgeSorter.GetNumberOfValues();
this->NumIterations = 0;
while (true)
{ // main loop
......@@ -385,7 +386,16 @@ inline void ActiveGraph::MakeMergeTree(MergeTree& tree, MeshExtrema& meshExtrema
// test whether there are any left (if not, we're on the trunk)
if (this->EdgeSorter.GetNumberOfValues() <= 0)
{
break;
}
// test whether we are in a bad infinite loop due to bad input data. Usually
// this is not an issue for the merge tree (only for the contour tree), but
// we check just to make absolutely sure we won't get stuck in an infinite loop
if (this->NumIterations >= maxNumIterations)
{
throw new std::domain_error("Bad iteration. Merge tree unable to process all edges.");
}
// find & label the extrema with their governing saddles
FindGoverningSaddles();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment