Skip to content

Commit b64e15f

Browse files
committed
Add regression test for #957
1 parent 1ef1da4 commit b64e15f

File tree

1 file changed

+53
-19
lines changed

1 file changed

+53
-19
lines changed

CPP/Tests/TestPolytreeHoles.cpp

Lines changed: 53 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -229,33 +229,67 @@ TEST(Clipper2Tests, TestPolytreeHoles8) // #942
229229
Paths64 subject;
230230
PolyTree64 solution;
231231
Clipper64 c;
232-
subject.push_back(MakePath({ 1588700,-8717600, 1616200,-8474800,
232+
subject.push_back(MakePath({ 1588700,-8717600, 1616200,-8474800,
233233
1588700,-8474800 }));
234-
subject.push_back(MakePath({ 13583800,-15601600, 13582800,-15508500,
234+
subject.push_back(MakePath({ 13583800,-15601600, 13582800,-15508500,
235235
13555300,-15508500, 13555500,-15182200, 13010900,-15185400 }));
236236
subject.push_back(MakePath({ 956700,-3092300, 1152600,3147400, 25600,3151700 }));
237-
subject.push_back(MakePath({ 22575900,-16604000, 31286800,-12171900,
238-
31110200,4882800, 30996200,4826300, 30414400,5447400, 30260000,5391500,
239-
29662200,5805400, 28844500,5337900, 28435000,5789300, 27721400,5026400,
240-
22876300,5034300, 21977700,4414900, 21148000,4654700, 20917600,4653400,
241-
19334300,12411000, -2591700,12177200, 53200,3151100, -2564300,12149800,
242-
7819400,4692400, 10116000,5228600, 6975500,3120100, 7379700,3124700,
243-
11037900,596200, 12257000,2587800, 12257000,596200, 15227300,2352700,
244-
18444400,1112100, 19961100,5549400, 20173200,5078600, 20330000,5079300,
245-
20970200,4544300, 20989600,4563700, 19465500,1112100, 21611600,4182100,
246-
22925100,1112200, 22952700,1637200, 23059000,1112200, 24908100,4181200,
247-
27070100,3800600, 27238000,3800700, 28582200,520300, 29367800,1050100,
248-
29291400,179400, 29133700,360700, 29056700,312600, 29121900,332500,
249-
29269900,162300, 28941400,213100, 27491300,-3041500, 27588700,-2997800,
250-
22104900,-16142800, 13010900,-15603000, 13555500,-15182200,
251-
13555300,-15508500, 13582800,-15508500, 13583100,-15154700,
252-
1588700,-8822800, 1588700,-8379900, 1588700,-8474800, 1616200,-8474800,
237+
subject.push_back(MakePath({ 22575900,-16604000, 31286800,-12171900,
238+
31110200,4882800, 30996200,4826300, 30414400,5447400, 30260000,5391500,
239+
29662200,5805400, 28844500,5337900, 28435000,5789300, 27721400,5026400,
240+
22876300,5034300, 21977700,4414900, 21148000,4654700, 20917600,4653400,
241+
19334300,12411000, -2591700,12177200, 53200,3151100, -2564300,12149800,
242+
7819400,4692400, 10116000,5228600, 6975500,3120100, 7379700,3124700,
243+
11037900,596200, 12257000,2587800, 12257000,596200, 15227300,2352700,
244+
18444400,1112100, 19961100,5549400, 20173200,5078600, 20330000,5079300,
245+
20970200,4544300, 20989600,4563700, 19465500,1112100, 21611600,4182100,
246+
22925100,1112200, 22952700,1637200, 23059000,1112200, 24908100,4181200,
247+
27070100,3800600, 27238000,3800700, 28582200,520300, 29367800,1050100,
248+
29291400,179400, 29133700,360700, 29056700,312600, 29121900,332500,
249+
29269900,162300, 28941400,213100, 27491300,-3041500, 27588700,-2997800,
250+
22104900,-16142800, 13010900,-15603000, 13555500,-15182200,
251+
13555300,-15508500, 13582800,-15508500, 13583100,-15154700,
252+
1588700,-8822800, 1588700,-8379900, 1588700,-8474800, 1616200,-8474800,
253253
1003900,-630100, 1253300,-12284500, 12983400,-16239900 }));
254254
subject.push_back(MakePath({ 198200,12149800, 1010600,12149800, 1011500,11859600 }));
255255
subject.push_back(MakePath({ 21996700,-7432000, 22096700,-7432000, 22096700,-7332000 }));
256256
c.AddSubject(subject);
257257
c.Execute(ClipType::Union, FillRule::NonZero, solution);
258-
259258
EXPECT_TRUE(solution.Count() == 1 && solution[0]->Count() == 2 && (*solution[0])[1]->Count() == 1);
260259
}
261260

261+
TEST(Clipper2Tests, TestPolytreeHoles9) // #957
262+
{
263+
Paths64 subject = {
264+
MakePath({ 77910,46865, 78720,46865, 78720,48000, 77910,48000, 77910,46865}),
265+
MakePath({ 82780,53015, 93600,53015, 93600,54335, 82780,54335, 82780,53015}),
266+
MakePath({ 82780,48975, 84080,48975, 84080,53015, 82780,53015, 82780,48975}),
267+
MakePath({ 77910,48000, 84080,48000, 84080,48975, 77910,48975, 77910,48000}),
268+
MakePath({ 89880,40615, 90700,40615, 90700,46865, 89880,46865, 89880,40615}),
269+
MakePath({ 92700,54335, 93600,54335, 93600,61420, 92700,61420, 92700,54335}),
270+
MakePath({ 78950,47425, 84080,47425, 84080,47770, 78950,47770, 78950,47425}),
271+
MakePath({ 82780,61420, 93600,61420, 93600,62435, 82780,62435, 82780,61420}),
272+
MakePath({ 101680,63085, 100675,63085, 100675,47770, 100680,47770, 100680,40615, 101680,40615, 101680,63085}),
273+
MakePath({ 76195,39880, 89880,39880, 89880,41045, 76195,41045, 76195,39880}),
274+
MakePath({ 85490,56145, 90520,56145, 90520,59235, 85490,59235, 85490,56145}),
275+
MakePath({ 89880,39880, 101680,39880, 101680,40615, 89880,40615, 89880,39880}),
276+
MakePath({ 89880,46865, 100680,46865, 100680,47770, 89880,47770, 89880,46865}),
277+
MakePath({ 82780,54335, 83280,54335, 83280,61420, 82780,61420, 82780,54335}),
278+
MakePath({ 76195,41045, 76855,41045, 76855,62665, 76195,62665, 76195,41045}),
279+
MakePath({ 76195,62665, 100675,62665, 100675,63085, 76195,63085, 76195,62665}),
280+
MakePath({ 82780,41045, 84080,41045, 84080,47425, 82780,47425, 82780,41045}) };
281+
282+
PolyTree64 solution;
283+
Clipper64 c;
284+
c.AddSubject(subject);
285+
c.Execute(ClipType::Union, FillRule::NonZero, solution);
286+
287+
// Polytree with 1 polygon.
288+
// + -Polygon(0) contains 2 holes.
289+
// + -Hole(0) contains 1 nested polygon.
290+
// + -Polygon(0) contains 1 hole.
291+
// + -Hole(0) contains 1 nested polygon.
292+
293+
EXPECT_TRUE(solution.Count() == 1 && solution[0]->Count() == 2 && (*solution[0])[0]->Count() == 1);
294+
}
295+

0 commit comments

Comments
 (0)