Skip to content

Commit c6ccef6

Browse files
ILoveGoulashhjmjohnson
authored andcommitted
ENH: Add test of infinite loop in VoronoiDiagram2DGenerator
Tests and resolves #4386 where specific values caused deadlocks.
1 parent b3cf50c commit c6ccef6

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

Modules/Segmentation/Voronoi/test/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ itk_add_test(
2929
ITKVoronoiTestDriver
3030
itkVoronoiSegmentationRGBImageFilterTest
3131
)
32+
itk_add_test(
33+
NAME itkVoronoiDiagram2DInfiniteLoopTest
34+
COMMAND
35+
ITKVoronoiTestDriver
36+
itkVoronoiDiagram2DInfiniteLoopTest
37+
)
38+
3239
itk_add_test(
3340
NAME itkVoronoiDiagram2DTest
3441
COMMAND
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*=========================================================================
2+
*
3+
* Copyright NumFOCUS
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0.txt
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*=========================================================================*/
18+
19+
#include "itkVoronoiDiagram2DGenerator.h"
20+
#include "itkTestingMacros.h"
21+
22+
int
23+
itkVoronoiDiagram2DInfiniteLoopTest(int argc, char * argv[])
24+
{
25+
if (argc != 0)
26+
{
27+
std::cerr << "Takes no parameters." << std::endl;
28+
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << std::endl;
29+
return EXIT_FAILURE;
30+
}
31+
32+
// From https://github.com/InsightSoftwareConsortium/ITK/issues/4386
33+
using VoronoiDiagramType = itk::VoronoiDiagram2D<double>;
34+
using VoronoiGeneratorType = itk::VoronoiDiagram2DGenerator<double>;
35+
using PointType = VoronoiDiagramType::PointType;
36+
VoronoiGeneratorType::Pointer vg = VoronoiGeneratorType::New();
37+
vg->SetOrigin(PointType{ { -1.61569, -1.76726 } });
38+
vg->SetBoundary(PointType{ { 1.60174, 1.76345 } });
39+
vg->AddOneSeed(PointType{ { -1.39649, 0.322212 } });
40+
vg->AddOneSeed(PointType{ { -1.30128, 0.231786 } });
41+
vg->AddOneSeed(PointType{ { -1.21509, 0.0515039 } });
42+
vg->AddOneSeed(PointType{ { -1.22364, -0.030281 } });
43+
vg->AddOneSeed(PointType{ { -1.22125, -0.120815 } });
44+
vg->AddOneSeed(PointType{ { -1.25159, -0.23593 } });
45+
vg->Update();
46+
47+
return EXIT_SUCCESS;
48+
}

0 commit comments

Comments
 (0)