BUG: Backport Voronoi infinite loop fix to release-5.4#6052
Conversation
|
| Filename | Overview |
|---|---|
| Modules/Segmentation/Voronoi/include/itkVoronoiDiagram2DGenerator.hxx | Core fix: stall counter + degenerate-edge discard replaces the previously unbounded retry loop; variable scoping conflict with release-5.4 resolved correctly via block-scope redeclarations of frontbnd/backbnd. |
| Modules/Segmentation/Voronoi/test/itkVoronoiDiagram2DInfiniteLoopTest.cxx | New regression test with hardcoded near-collinear seeds that previously caused an infinite loop; uses ITK_TRY_EXPECT_NO_EXCEPTION and verifies all 6 cell boundaries are non-empty. |
| Modules/Segmentation/Voronoi/test/CMakeLists.txt | Adds new test source and itk_add_test() registration; minor formatting inconsistency in the NAME keyword layout compared to the rest of the file. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[ConstructDiagram: pop first edge → seed chain] --> B[remainingBeforeStall = deque.size]
B --> C{deque empty\nor stall=0?}
C -- No --> D[pop edge from deque\ndecrement stall counter]
D --> E{edgeStart ≈ edgeEnd\ndifferentPoint = false?}
E -- Yes: degenerate --> F[discard edge\nreset stall counter]
F --> C
E -- No: valid edge --> G{Can attach to\nchain front/back?}
G -- Yes --> H[attach edge\nupdate front/back\nreset stall counter]
H --> C
G -- No: boundary bridge? --> I{Boundary ID\nmatch?}
I -- Yes --> J[insert bridge + edge\nreset stall counter]
J --> C
I -- No --> K[push edge back\nno stall reset]
K --> C
C -- Yes: done --> L{deque empty?}
L -- Yes --> M[close chain if needed\nbuild cell]
L -- No: stuck edges remain --> N[itkExceptionMacro\nunexpected configuration]
Reviews (1): Last reviewed commit: "BUG: Fix infinite loop in VoronoiDiagram..." | Re-trigger Greptile
09a39e0 to
0db6b82
Compare
|
CI failures are known flakes — not related to this PR's code changes.
All 8 Voronoi tests pass locally (verified on macOS ARM64). The |
|
/azp run ITK.macOS.Python |
5a3c880 to
784cbd6
Compare
Backport the itk_dict.txt word list from upstream/main to release-5.4, then add 20 words found in release-5.4 source that are not in main's dictionary (code identifiers in ThirdParty headers, legitimate terms like Hounsfield and Dask, and variable names in comments that cannot be changed on the release branch). Uses main's sort order to minimize future merge diffs.
784cbd6 to
6b157cf
Compare
5934cc8
into
InsightSoftwareConsortium:release-5.4
Backport
3b3f3c24d4frommaintorelease-5.4. Fixes an infinite loop inVoronoiDiagram2DGenerator::ConstructDiagramwhen Fortune's algorithm produces degenerate near-zero-length edges.Part of #6051 (backport candidates for 5.4.6).
Cherry-pick details
Cherry-picked from commit
3b3f3c24d4(merged to main via PR #6017). Required manual conflict resolution:itkVoronoiDiagram2DGenerator.hxx: movedfrontbnd/backbnddeclarations from function scope into block scope (release-5.4 had them at outer scope; main moved them to inner loop + second usage block)CMakeLists.txt: added new test file to the test list while preserving release-5.4 formatting styleLocal build and test verified: 8/8 Voronoi tests pass including the new
itkVoronoiDiagram2DInfiniteLoopTest.