Debian Codegraph @

tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp

raw
1 // Copyright (C) 2016 The Qt Company Ltd.
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3 #include "private/qpathclipper_p.h"
4 #include "paths.h"
5 #include "pathcompare.h"
6
7 #include <QTest>
8
9 #include <qpainterpath.h>
10 #include <qpolygon.h>
11 #include <qdebug.h>
12 #include <qpainter.h>
13 #include <qrandom.h>
14
15 #include <math.h>
16
17 class tst_QPathClipper : public QObject
18 {
19 Q_OBJECT
20
21 public:
22 tst_QPathClipper();
23 virtual ~tst_QPathClipper();
24
25 private:
26 void clipTest(int subjectIndex, int clipIndex, QPathClipper::Operation op);
27
28 QList<QPainterPath> paths;
29
30 public slots:
31 void initTestCase();
32
33 private slots:
34 void testWingedEdge();
35
36 void testComparePaths();
37
38 void clip_data();
39 void clip();
40
41 void clip2();
42 void clip3();
43
44 void testIntersections();
45 void testIntersections2();
46 void testIntersections3();
47 void testIntersections4();
48 void testIntersections5();
49 void testIntersections6();
50 void testIntersections7();
51 void testIntersections8();
52 void testIntersections9();
53
54 void zeroDerivativeCurves();
55
56 void task204301_data();
57 void task204301();
58
59 void task209056();
60 void task251909();
61
62 void qtbug3778();
63 void qtbug60024();
64 };
65
66 Q_DECLARE_METATYPE(QPainterPath)
67 Q_DECLARE_METATYPE(QPathClipper::Operation)
68
69 tst_QPathClipper::tst_QPathClipper()
70 {
71 }
72
73 tst_QPathClipper::~tst_QPathClipper()
74 {
75 }
76
77 void tst_QPathClipper::initTestCase()
78 {
79 paths << Paths::rect();
80 paths << Paths::heart();
81 paths << Paths::body();
82 paths << Paths::mailbox();
83 paths << Paths::deer();
84 paths << Paths::fire();
85
86 paths << Paths::random1();
87 paths << Paths::random2();
88
89 paths << Paths::heart2();
90 paths << Paths::rect2();
91 paths << Paths::rect3();
92 paths << Paths::rect4();
93 paths << Paths::rect5();
94 paths << Paths::rect6();
95
96 paths << Paths::frame1();
97 paths << Paths::frame2();
98 paths << Paths::frame3();
99 paths << Paths::frame4();
100
101 paths << Paths::triangle1();
102 paths << Paths::triangle2();
103
104 paths << Paths::node();
105 paths << Paths::interRect();
106
107 paths << Paths::simpleCurve();
108 paths << Paths::simpleCurve2();
109 paths << Paths::simpleCurve3();
110
111 paths << Paths::bezier1();
112 paths << Paths::bezier2();
113 paths << Paths::bezier3();
114 paths << Paths::bezier4();
115
116 paths << Paths::bezierFlower();
117 paths << Paths::lips();
118 paths << Paths::clover();
119 paths << Paths::ellipses();
120 paths << Paths::windingFill();
121 paths << Paths::oddEvenFill();
122 paths << Paths::squareWithHole();
123 paths << Paths::circleWithHole();
124 paths << Paths::bezierQuadrant();
125
126 // make sure all the bounding rects are centered at the origin
127 for (int i = 0; i < paths.size(); ++i) {
128 QRectF bounds = paths[i].boundingRect();
129
130 QTransform m(1, 0,
131 0, 1,
132 -bounds.center().x(), -bounds.center().y());
133
134 paths[i] = m.map(paths[i]);
135 }
136 }
137
138 static QPainterPath samplePath1()
139 {
140 QPainterPath path;
141 path.moveTo(QPointF(200, 246.64789));
142 path.lineTo(QPointF(200, 206.64789));
143 path.lineTo(QPointF(231.42858, 206.64789));
144 path.lineTo(QPointF(231.42858, 246.64789));
145 path.lineTo(QPointF(200, 246.64789));
146 return path;
147 }
148
149 static QPainterPath samplePath2()
150 {
151 QPainterPath path;
152 path.moveTo(QPointF(200, 146.64789));
153 path.lineTo(QPointF(200, 106.64789));
154 path.lineTo(QPointF(231.42858, 106.64789));
155 path.lineTo(QPointF(231.42858, 146.64789));
156 path.lineTo(QPointF(200, 146.64789));
157 return path;
158 }
159
160 static QPainterPath samplePath3()
161 {
162 QPainterPath path;
163 path.moveTo(QPointF(231.42858, 80.933609));
164 path.lineTo(QPointF(200, 80.933609));
165 path.lineTo(QPointF(200, 96.64788999999999));
166 path.lineTo(QPointF(231.42858, 96.64788999999999));
167 path.lineTo(QPointF(231.42858, 80.933609));
168 return path;
169 }
170
171 static QPainterPath samplePath4()
172 {
173 QPainterPath path;
174 path.moveTo(QPointF(288.571434, 80.933609));
175 path.lineTo(QPointF(431.42858, 80.933609));
176 path.lineTo(QPointF(431.42858, 96.64788999999999));
177 path.lineTo(QPointF(288.571434, 96.64788999999999));
178 path.lineTo(QPointF(288.571434, 80.933609));
179 return path;
180 }
181
182 static QPainterPath samplePath5()
183 {
184 QPainterPath path;
185 path.moveTo(QPointF(588.571434, 80.933609));
186 path.lineTo(QPointF(682.85715, 80.933609));
187 path.lineTo(QPointF(682.85715, 96.64788999999999));
188 path.lineTo(QPointF(588.571434, 96.64788999999999));
189 path.lineTo(QPointF(588.571434, 80.933609));
190 return path;
191 }
192
193 static QPainterPath samplePath6()
194 {
195 QPainterPath path;
196 path.moveTo(QPointF(588.571434, 80.933609));
197 path.lineTo(QPointF(200, 80.933609));
198 path.lineTo(QPointF(200, 446.6479));
199 path.lineTo(QPointF(682.85715, 446.6479));
200 path.lineTo(QPointF(682.85715, 96.64788999999999));
201 path.lineTo(QPointF(731.42858, 96.64788999999999));
202 path.lineTo(QPointF(731.42858, 56.64788999999999));
203 path.lineTo(QPointF(588.571434, 56.64788999999999));
204 path.lineTo(QPointF(588.571434, 80.933609));
205 return path;
206 }
207
208 static QPainterPath samplePath7()
209 {
210 QPainterPath path;
211 path.moveTo(QPointF(682.85715, 206.64789));
212 path.lineTo(QPointF(682.85715, 246.64789));
213 path.lineTo(QPointF(588.571434, 246.64789));
214 path.lineTo(QPointF(588.571434, 206.64789));
215 path.lineTo(QPointF(682.85715, 206.64789));
216 return path;
217 }
218
219 static QPainterPath samplePath8()
220 {
221 QPainterPath path;
222 path.moveTo(QPointF(682.85715, 406.64789));
223 path.lineTo(QPointF(682.85715, 446.64789));
224 path.lineTo(QPointF(588.571434, 446.64789));
225 path.lineTo(QPointF(588.571434, 406.64789));
226 path.lineTo(QPointF(682.85715, 406.64789));
227 return path;
228 }
229
230 static QPainterPath samplePath9()
231 {
232 QPainterPath path;
233 path.moveTo(QPointF(682.85715, 426.64789));
234 path.lineTo(QPointF(682.85715, 446.6479));
235 path.lineTo(QPointF(568.571434, 446.6479));
236 path.lineTo(QPointF(568.571434, 426.64789));
237 path.lineTo(QPointF(682.85715, 426.64789));
238 return path;
239 }
240
241 static QPainterPath samplePath10()
242 {
243 QPainterPath path;
244 path.moveTo(QPointF(511.42858, 446.6479));
245 path.lineTo(QPointF(368.571434, 446.6479));
246 path.lineTo(QPointF(368.571434, 426.64789));
247 path.lineTo(QPointF(511.42858, 426.64789));
248 path.lineTo(QPointF(511.42858, 446.6479));
249 return path;
250 }
251
252 static QPainterPath samplePath13()
253 {
254 QPainterPath path;
255 path.moveTo(QPointF(160, 200));
256 path.lineTo(QPointF(100, 200));
257 path.lineTo(QPointF(100, 130));
258 path.lineTo(QPointF(160, 130));
259 path.lineTo(QPointF(160, 200));
260 return path;
261 }
262
263 static QPainterPath samplePath14()
264 {
265 QPainterPath path;
266
267 path.moveTo(160, 80);
268 path.lineTo(160, 180);
269 path.lineTo(100, 180);
270 path.lineTo(100, 80);
271 path.lineTo(160, 80);
272 path.moveTo(160, 80);
273 path.lineTo(160, 100);
274 path.lineTo(120, 100);
275 path.lineTo(120, 80);
276
277 return path;
278 }
279
280 void tst_QPathClipper::clip_data()
281 {
282 //create the testtable instance and define the elements
283 QTest::addColumn<QPainterPath>("subject");
284 QTest::addColumn<QPainterPath>("clip");
285 QTest::addColumn<QPathClipper::Operation>("op");
286 QTest::addColumn<QPainterPath>("result");
287
288 //next we fill it with data
289 QTest::newRow( "simple1" ) << Paths::frame3()
290 << Paths::frame4()
291 << QPathClipper::BoolAnd
292 << samplePath1();
293
294 QTest::newRow( "simple2" ) << Paths::frame3()
295 << Paths::frame4() * QTransform().translate(0, -100)
296 << QPathClipper::BoolAnd
297 << samplePath2();
298
299 QTest::newRow( "simple3" ) << Paths::frame3()
300 << Paths::frame4() * QTransform().translate(0, -150)
301 << QPathClipper::BoolAnd
302 << samplePath3();
303
304 QTest::newRow( "simple4" ) << Paths::frame3()
305 << Paths::frame4() * QTransform().translate(200, -150)
306 << QPathClipper::BoolAnd
307 << samplePath4();
308
309 QTest::newRow( "simple5" ) << Paths::frame3()
310 << Paths::frame4() * QTransform().translate(500, -150)
311 << QPathClipper::BoolAnd
312 << samplePath5();
313
314 QTest::newRow( "simple6" ) << Paths::frame3()
315 << Paths::frame4() * QTransform().translate(500, -150)
316 << QPathClipper::BoolOr
317 << samplePath6();
318
319 QTest::newRow( "simple7" ) << Paths::frame3()
320 << Paths::frame4() * QTransform().translate(500, 0)
321 << QPathClipper::BoolAnd
322 << samplePath7();
323
324 QTest::newRow( "simple8" ) << Paths::frame3()
325 << Paths::frame4() * QTransform().translate(500, 200)
326 << QPathClipper::BoolAnd
327 << samplePath8();
328
329 QTest::newRow( "simple9" ) << Paths::frame3()
330 << Paths::frame4() * QTransform().translate(480, 220)
331 << QPathClipper::BoolAnd
332 << samplePath9();
333
334 QTest::newRow( "simple10" ) << Paths::frame3()
335 << Paths::frame4() * QTransform().translate(280, 220)
336 << QPathClipper::BoolAnd
337 << samplePath10();
338
339 QTest::newRow( "simple_move_to1" ) << Paths::rect4()
340 << Paths::rect2() * QTransform().translate(-20, 50)
341 << QPathClipper::BoolAnd
342 << samplePath13();
343
344 QTest::newRow( "simple_move_to2" ) << Paths::rect4()
345 << Paths::rect2() * QTransform().translate(-20, 0)
346 << QPathClipper::BoolAnd
347 << samplePath14();
348 }
349
350 // sanity check to make sure comparePaths declared above works
351 void tst_QPathClipper::testComparePaths()
352 {
353 QPainterPath a;
354 QPainterPath b;
355
356 a.addRect(0, 0, 10, 10);
357 b.addRect(0, 0, 10.00001, 10.00001);
358
359 QVERIFY(!QPathCompare::comparePaths(a, b));
360
361 b = QPainterPath();
362 b.addRect(0, 0, 10.00000000001, 10.00000000001);
363
364 QVERIFY(QPathCompare::comparePaths(a, b));
365
366 b = QPainterPath();
367 b.moveTo(10, 0);
368 b.lineTo(0, 0);
369 b.lineTo(0, 10);
370 b.lineTo(10, 10);
371
372 QVERIFY(QPathCompare::comparePaths(a, b));
373 b.lineTo(10, 0);
374 QVERIFY(QPathCompare::comparePaths(a, b));
375
376 b = QPainterPath();
377 b.moveTo(10, 0);
378 b.lineTo(0, 10);
379 b.lineTo(0, 0);
380 b.lineTo(10, 10);
381
382 QVERIFY(!QPathCompare::comparePaths(a, b));
383 }
384
385 void tst_QPathClipper::clip()
386 {
387 if (sizeof(double) != sizeof(qreal)) {
388 QSKIP("This test only works for qreal=double, otherwise ends in rounding errors");
389 }
390 QFETCH( QPainterPath, subject );
391 QFETCH( QPainterPath, clip );
392 QFETCH( QPathClipper::Operation, op );
393 QFETCH( QPainterPath, result);
394 QPathClipper clipper(subject, clip);
395 QPainterPath x = clipper.clip(op);
396
397 QVERIFY(QPathCompare::comparePaths(x, result));
398 }
399
400 static inline QPointF randomPointInRect(const QRectF &rect)
401 {
402 qreal rx = QRandomGenerator::global()->bounded(1.0);
403 qreal ry = QRandomGenerator::global()->bounded(1.0);
404
405 return QPointF(rect.left() + rx * rect.width(),
406 rect.top() + ry * rect.height());
407 }
408
409 void tst_QPathClipper::clipTest(int subjectIndex, int clipIndex, QPathClipper::Operation op)
410 {
411 const QPainterPath &subject = paths[subjectIndex];
412 const QPainterPath &clip = paths[clipIndex];
413 const int count = 40;
414
415 QRectF bounds = subject.boundingRect().united(clip.boundingRect());
416
417 const qreal adjustX = bounds.width() * 0.01;
418 const qreal adjustY = bounds.height() * 0.01;
419
420 // make sure we test some points that are outside both paths as well
421 bounds = bounds.adjusted(-adjustX, -adjustY, adjustX, adjustY);
422
423 const int dim = 256;
424 const qreal scale = qMin(dim / bounds.width(), dim / bounds.height());
425
426 QPathClipper clipper(subject, clip);
427 QPainterPath result = clipper.clip(op);
428
429 // using the image here is a bit of a hacky way to make sure we don't test points that
430 // are too close to the path edges to avoid test fails that are due to numerical errors
431 QImage img(dim, dim, QImage::Format_ARGB32_Premultiplied);
432 img.fill(0x0);
433 QPainter p(&img);
434 p.setRenderHint(QPainter::Antialiasing);
435 p.scale(scale, scale);
436 p.translate(-bounds.topLeft());
437 p.setPen(QPen(Qt::black, 0));
438 p.drawPath(subject);
439 p.setPen(QPen(Qt::red, 0));
440 p.drawPath(clip);
441 p.end();
442
443 for (int i = 0; i < count; ++i) {
444 QPointF point;
445 QRgb pixel;
446 do {
447 point = randomPointInRect(bounds);
448 const QPointF imagePoint = (point - bounds.topLeft()) * scale;
449
450 pixel = img.pixel(int(imagePoint.x()), int(imagePoint.y()));
451 } while (qAlpha(pixel) > 0);
452
453 const bool inSubject = subject.contains(point);
454 const bool inClip = clip.contains(point);
455
456 const bool inResult = result.contains(point);
457
458 bool expected = false;
459 switch (op) {
460 case QPathClipper::BoolAnd:
461 expected = inSubject && inClip;
462 break;
463 case QPathClipper::BoolOr:
464 expected = inSubject || inClip;
465 break;
466 case QPathClipper::BoolSub:
467 expected = inSubject && !inClip;
468 break;
469 default:
470 break;
471 }
472
473 auto failLogger = qScopeGuard([&]{
474 qCritical().noquote().nospace()
475 << "\n\tExpected: " << expected
476 << "\n\tActual: " << inResult
477 << "\n\tSubject: " << subjectIndex
478 << "\n\tClip: " << clipIndex
479 << "\n\tOp: " << (op == QPathClipper::BoolAnd
480 ? "and"
481 : op == QPathClipper::BoolOr
482 ? "or" : "sub");
483 });
484 QCOMPARE(inResult, expected);
485 failLogger.dismiss();
486 }
487 }
488
489 void tst_QPathClipper::clip2()
490 {
491 if (sizeof(double) != sizeof(qreal))
492 QSKIP("This test only works for qreal=double, otherwise ends in rounding errors");
493
494 int operation = 0;
495
496 for (int i = 0; i < paths.size(); ++i) {
497 for (int j = 0; j <= i; ++j) {
498 QPathClipper::Operation op = QPathClipper::Operation((operation++) % 3);
499 clipTest(i, j, op);
500 }
501 }
502 }
503
504 void tst_QPathClipper::clip3()
505 {
506 int operation = 0;
507
508 // this subset should work correctly for qreal = float
509 for (int i = 0; i < 20; ++i) {
510 for (int j = 0; j <= i; ++j) {
511 QPathClipper::Operation op = QPathClipper::Operation((operation++) % 3);
512 clipTest(i, j, op);
513 }
514 }
515 }
516
517 void tst_QPathClipper::testIntersections()
518 {
519 QPainterPath path1;
520 QPainterPath path2;
521
522 path1.addRect(0, 0, 100, 100);
523 path2.addRect(20, 20, 20, 20);
524 QVERIFY(path1.intersects(path2));
525 QVERIFY(path2.intersects(path1));
526 QVERIFY(path1.contains(path2));
527 QVERIFY(!path2.contains(path1));
528
529 path1 = QPainterPath();
530 path2 = QPainterPath();
531 path1.addEllipse(0, 0, 100, 100);
532 path2.addEllipse(200, 200, 100, 100);
533 QVERIFY(!path1.intersects(path2));
534 QVERIFY(!path2.intersects(path1));
535 QVERIFY(!path1.contains(path2));
536 QVERIFY(!path2.contains(path1));
537
538 path1 = QPainterPath();
539 path2 = QPainterPath();
540 path1.addEllipse(0, 0, 100, 100);
541 path2.addEllipse(50, 50, 100, 100);
542 QVERIFY(path1.intersects(path2));
543 QVERIFY(path2.intersects(path1));
544 QVERIFY(!path1.contains(path2));
545 QVERIFY(!path2.contains(path1));
546
547 path1 = QPainterPath();
548 path2 = QPainterPath();
549 path1.addRect(100, 100, 100, 100);
550 path2.addRect(50, 100, 100, 20);
551 QVERIFY(path1.intersects(path2));
552 QVERIFY(path2.intersects(path1));
553 QVERIFY(!path1.contains(path2));
554 QVERIFY(!path2.contains(path1));
555
556 path1 = QPainterPath();
557 path2 = QPainterPath();
558 path1.addRect(100, 100, 100, 100);
559 path2.addRect(110, 201, 100, 20);
560 QVERIFY(!path1.intersects(path2));
561 QVERIFY(!path2.intersects(path1));
562 QVERIFY(!path1.contains(path2));
563 QVERIFY(!path2.contains(path1));
564
565 path1 = QPainterPath();
566 path2 = QPainterPath();
567 path1.addRect(0, 0, 100, 100);
568 path2.addRect(20, 20, 20, 20);
569 path2.addRect(25, 25, 5, 5);
570 QVERIFY(path1.intersects(path2));
571 QVERIFY(path2.intersects(path1));
572 QVERIFY(path1.contains(path2));
573 QVERIFY(!path2.contains(path1));
574 }
575
576 void tst_QPathClipper::testIntersections2()
577 {
578 QPainterPath path1;
579 QPainterPath path2;
580
581 path1 = QPainterPath();
582 path2 = QPainterPath();
583
584 path1.moveTo(-8,-8);
585 path1.lineTo(107,-8);
586 path1.lineTo(107,107);
587 path1.lineTo(-8,107);
588
589 path2.moveTo(0,0);
590 path2.lineTo(100,0);
591 path2.lineTo(100,100);
592 path2.lineTo(0,100);
593 path2.lineTo(0,0);
594
595 QVERIFY(path1.intersects(path2));
596 QVERIFY(path2.intersects(path1));
597 QVERIFY(path1.contains(path2));
598 QVERIFY(!path2.contains(path1));
599
600 path1.closeSubpath();
601
602 QVERIFY(path1.intersects(path2));
603 QVERIFY(path2.intersects(path1));
604 QVERIFY(path1.contains(path2));
605 QVERIFY(!path2.contains(path1));
606 }
607
608 void tst_QPathClipper::testIntersections3()
609 {
610 QPainterPath path1 = Paths::node();
611 QPainterPath path2 = Paths::interRect();
612
613 QVERIFY(path1.intersects(path2));
614 QVERIFY(path2.intersects(path1));
615 }
616
617 void tst_QPathClipper::testIntersections4()
618 {
619 QPainterPath path1;
620 QPainterPath path2;
621
622 path1.moveTo(-5, 0);
623 path1.lineTo(5, 0);
624
625 path2.moveTo(0, -5);
626 path2.lineTo(0, 5);
627
628 QVERIFY(path1.intersects(path2));
629 QVERIFY(path2.intersects(path1));
630 }
631
632 void tst_QPathClipper::testIntersections5()
633 {
634 QPainterPath path1;
635 QPainterPath path2;
636
637 path1.addRect(0, 0, 4, 4);
638 path1.addRect(2, 1, 1, 1);
639 path2.addRect(0.5, 2, 1, 1);
640
641 QVERIFY(path1.intersects(path2));
642 QVERIFY(path2.intersects(path1));
643 }
644
645 void tst_QPathClipper::testIntersections6()
646 {
647 QPainterPath path1;
648 QPainterPath path2;
649
650 path1.moveTo(QPointF(-115.567, -98.3254));
651 path1.lineTo(QPointF(-45.9007, -98.3254));
652 path1.lineTo(QPointF(-45.9007, -28.6588));
653 path1.lineTo(QPointF(-115.567, -28.6588));
654
655 path2.moveTo(QPointF(-110, -110));
656 path2.lineTo(QPointF(110, -110));
657 path2.lineTo(QPointF(110, 110));
658 path2.lineTo(QPointF(-110, 110));
659 path2.lineTo(QPointF(-110, -110));
660
661 QVERIFY(path1.intersects(path2));
662 QVERIFY(path2.intersects(path1));
663 }
664
665
666 void tst_QPathClipper::testIntersections7()
667 {
668 QPainterPath path1;
669 QPainterPath path2;
670
671 path1.addRect(0, 0, 10, 10);
672 path2.addRect(5, 0, 10, 10);
673
674 QVERIFY(path1.intersects(path2));
675 QVERIFY(path2.intersects(path1));
676
677 path1 = QPainterPath();
678 path2 = QPainterPath();
679 path1.addRect(0, 0, 10, 10);
680 path2.addRect(0, 5, 10, 10);
681
682 QVERIFY(path1.intersects(path2));
683 QVERIFY(path2.intersects(path1));
684
685 path1 = QPainterPath();
686 path2 = QPainterPath();
687 path1.addRect(0, 0, 10, 10);
688 path2.addRect(0, 0, 10, 10);
689
690 QVERIFY(path1.intersects(path2));
691 QVERIFY(path2.intersects(path1));
692
693 ///
694 path1 = QPainterPath();
695 path2 = QPainterPath();
696 path1.addRect(1, 1, 10, 10);
697 path2.addRect(5, 1, 10, 10);
698
699 QVERIFY(path1.intersects(path2));
700 QVERIFY(path2.intersects(path1));
701
702 path1 = QPainterPath();
703 path2 = QPainterPath();
704 path1.addRect(1, 1, 10, 10);
705 path2.addRect(1, 5, 10, 10);
706
707 QVERIFY(path1.intersects(path2));
708 QVERIFY(path2.intersects(path1));
709
710 path1 = QPainterPath();
711 path2 = QPainterPath();
712 path1.addRect(1, 1, 10, 10);
713 path2.addRect(1, 1, 10, 10);
714
715 QVERIFY(path1.intersects(path2));
716 QVERIFY(path2.intersects(path1));
717
718 path1 = QPainterPath();
719 path2 = QPainterPath();
720 path1.addRect(1, 1, 10, 10);
721 path2.addRect(5, 5, 10, 10);
722
723 QVERIFY(path1.intersects(path2));
724 QVERIFY(path2.intersects(path1));
725
726 path1 = QPainterPath();
727 path2 = QPainterPath();
728 path1.addRect(1, 1, 10, 10);
729 path2.addRect(9, 9, 10, 10);
730
731 QVERIFY(path1.intersects(path2));
732 QVERIFY(path2.intersects(path1));
733
734 path1 = QPainterPath();
735 path2 = QPainterPath();
736 path1.addRect(1, 1, 10, 10);
737 path2.addRect(10, 10, 10, 10);
738
739 QVERIFY(path1.intersects(path2));
740 QVERIFY(path2.intersects(path1));
741
742 path1 = QPainterPath();
743 path2 = QPainterPath();
744 path1.addRect(1, 1, 9, 9);
745 path2.addRect(11, 11, 10, 10);
746
747 QVERIFY(!path1.intersects(path2));
748 QVERIFY(!path2.intersects(path1));
749
750 path1 = QPainterPath();
751 path2 = QPainterPath();
752 path1.addRect(1, 1, 10, 10);
753 path2.addRect(12, 12, 10, 10);
754
755 QVERIFY(!path1.intersects(path2));
756 QVERIFY(!path2.intersects(path1));
757
758 path1 = QPainterPath();
759 path2 = QPainterPath();
760 path1.addRect(11, 11, 10, 10);
761 path2.addRect(12, 12, 10, 10);
762
763 QVERIFY(path1.intersects(path2));
764 QVERIFY(path2.intersects(path1));
765
766 path1 = QPainterPath();
767 path2 = QPainterPath();
768 path1.addRect(11, 11, 10, 10);
769 path2.addRect(10, 10, 10, 10);
770
771 QVERIFY(path1.intersects(path2));
772 QVERIFY(path2.intersects(path1));
773 }
774
775
776 void tst_QPathClipper::testIntersections8()
777 {
778 QPainterPath path1 = Paths::node() * QTransform().translate(100, 50);
779 QPainterPath path2 = Paths::node() * QTransform().translate(150, 50);
780
781 QVERIFY(path1.intersects(path2));
782 QVERIFY(path2.intersects(path1));
783
784 path1 = Paths::node();
785 path2 = Paths::node();
786
787 QVERIFY(path1.intersects(path2));
788 QVERIFY(path2.intersects(path1));
789
790 path1 = Paths::node();
791 path2 = Paths::node() * QTransform().translate(0, 30);
792
793 QVERIFY(path1.intersects(path2));
794 QVERIFY(path2.intersects(path1));
795
796 path1 = Paths::node();
797 path2 = Paths::node() * QTransform().translate(30, 0);
798
799 QVERIFY(path1.intersects(path2));
800 QVERIFY(path2.intersects(path1));
801
802 path1 = Paths::node();
803 path2 = Paths::node() * QTransform().translate(30, 30);
804
805 QVERIFY(path1.intersects(path2));
806 QVERIFY(path2.intersects(path1));
807
808 path1 = Paths::node();
809 path2 = Paths::node() * QTransform().translate(1, 1);
810
811 QVERIFY(path1.intersects(path2));
812 QVERIFY(path2.intersects(path1));
813 }
814
815
816 void tst_QPathClipper::testIntersections9()
817 {
818 QPainterPath path1;
819 QPainterPath path2;
820
821 path1.addRect(QRectF(-1,143, 146, 106));
822 path2.addRect(QRectF(-9,145, 150, 100));
823
824 QVERIFY(path1.intersects(path2));
825 QVERIFY(path2.intersects(path1));
826
827 path1 = QPainterPath();
828 path2 = QPainterPath();
829
830 path1.addRect(QRectF(-1,191, 136, 106));
831 path2.addRect(QRectF(-19,194, 150, 100));
832 QVERIFY(path1.intersects(path2));
833 QVERIFY(path2.intersects(path1));
834
835 path1 = QPainterPath();
836 path2 = QPainterPath();
837
838 path1.moveTo(-1 , 143);
839 path1.lineTo(148 , 143);
840 path1.lineTo(148 , 250);
841 path1.lineTo(-1 , 250);
842
843 path2.moveTo(-5 , 146);
844 path2.lineTo(145 , 146);
845 path2.lineTo(145 , 246);
846 path2.lineTo(-5 , 246);
847 path2.lineTo(-5 , 146);
848
849 QVERIFY(path1.intersects(path2));
850 QVERIFY(path2.intersects(path1));
851 }
852
853 QPainterPath pathFromRect(qreal x, qreal y, qreal w, qreal h)
854 {
855 QPainterPath path;
856 path.addRect(QRectF(x, y, w, h));
857 return path;
858 }
859
860 QPainterPath pathFromLine(qreal x1, qreal y1, qreal x2, qreal y2)
861 {
862 QPainterPath path;
863 path.moveTo(x1, y1);
864 path.lineTo(x2, y2);
865 return path;
866 }
867
868 static int loopLength(const QWingedEdge &list, QWingedEdge::TraversalStatus status)
869 {
870 int start = status.edge;
871
872 int length = 0;
873 do {
874 ++length;
875 status = list.next(status);
876 } while (status.edge != start);
877
878 return length;
879 }
880
881 void tst_QPathClipper::testWingedEdge()
882 {
883 {
884 QWingedEdge list;
885 int e1 = list.addEdge(QPointF(0, 0), QPointF(10, 0));
886 int e2 = list.addEdge(QPointF(0, 0), QPointF(0, 10));
887 int e3 = list.addEdge(QPointF(0, 0), QPointF(-10, 0));
888 int e4 = list.addEdge(QPointF(0, 0), QPointF(0, -10));
889
890 QCOMPARE(list.edgeCount(), 4);
891 QCOMPARE(list.vertexCount(), 5);
892
893 QWingedEdge::TraversalStatus status = { e1, QPathEdge::RightTraversal, QPathEdge::Forward };
894
895 status = list.next(status);
896 QCOMPARE(status.direction, QPathEdge::Backward);
897 QCOMPARE(status.traversal, QPathEdge::LeftTraversal);
898 QCOMPARE(status.edge, e1);
899
900 status = list.next(status);
901 QCOMPARE(status.direction, QPathEdge::Forward);
902 QCOMPARE(status.traversal, QPathEdge::RightTraversal);
903 QCOMPARE(status.edge, e4);
904
905 status = list.next(status);
906 QCOMPARE(status.direction, QPathEdge::Backward);
907 QCOMPARE(status.traversal, QPathEdge::LeftTraversal);
908 QCOMPARE(status.edge, e4);
909
910 status = list.next(status);
911 QCOMPARE(status.direction, QPathEdge::Forward);
912 QCOMPARE(status.traversal, QPathEdge::RightTraversal);
913 QCOMPARE(status.edge, e3);
914
915 status = list.next(status);
916 QCOMPARE(status.direction, QPathEdge::Backward);
917 QCOMPARE(status.traversal, QPathEdge::LeftTraversal);
918 QCOMPARE(status.edge, e3);
919
920 status = list.next(status);
921 QCOMPARE(status.direction, QPathEdge::Forward);
922 QCOMPARE(status.traversal, QPathEdge::RightTraversal);
923 QCOMPARE(status.edge, e2);
924
925 status = list.next(status);
926 QCOMPARE(status.direction, QPathEdge::Backward);
927 QCOMPARE(status.traversal, QPathEdge::LeftTraversal);
928 QCOMPARE(status.edge, e2);
929
930 status = list.next(status);
931 QCOMPARE(status.direction, QPathEdge::Forward);
932 QCOMPARE(status.traversal, QPathEdge::RightTraversal);
933 QCOMPARE(status.edge, e1);
934 }
935 {
936 QWingedEdge list;
937 int e1 = list.addEdge(QPointF(5, 0), QPointF(5, 10));
938 int e2 = list.addEdge(QPointF(5, 0), QPointF(10, 5));
939 int e3 = list.addEdge(QPointF(10, 5), QPointF(5, 10));
940 int e4 = list.addEdge(QPointF(5, 0), QPointF(0, 5));
941 int e5 = list.addEdge(QPointF(0, 5), QPointF(5, 10));
942
943 QCOMPARE(list.edgeCount(), 5);
944 QCOMPARE(list.vertexCount(), 4);
945
946 QWingedEdge::TraversalStatus status = { e1, QPathEdge::RightTraversal, QPathEdge::Forward };
947
948 status = list.next(status);
949 QCOMPARE(status.direction, QPathEdge::Backward);
950 QCOMPARE(status.traversal, QPathEdge::LeftTraversal);
951 QCOMPARE(status.edge, e5);
952
953 status = list.next(status);
954 QCOMPARE(status.direction, QPathEdge::Backward);
955 QCOMPARE(status.traversal, QPathEdge::LeftTraversal);
956 QCOMPARE(status.edge, e4);
957
958 status = list.next(status);
959 QCOMPARE(status.direction, QPathEdge::Forward);
960 QCOMPARE(status.traversal, QPathEdge::RightTraversal);
961 QCOMPARE(status.edge, e1);
962
963 QCOMPARE(loopLength(list, status), 3);
964
965 status.flip();
966 QCOMPARE(status.direction, QPathEdge::Backward);
967 QCOMPARE(status.traversal, QPathEdge::LeftTraversal);
968 QCOMPARE(loopLength(list, status), 3);
969
970 status = list.next(status);
971 QCOMPARE(status.direction, QPathEdge::Forward);
972 QCOMPARE(status.traversal, QPathEdge::RightTraversal);
973 QCOMPARE(status.edge, e2);
974
975 status = list.next(status);
976 QCOMPARE(status.direction, QPathEdge::Forward);
977 QCOMPARE(status.traversal, QPathEdge::RightTraversal);
978 QCOMPARE(status.edge, e3);
979
980 status = list.next(status);
981 QCOMPARE(status.direction, QPathEdge::Backward);
982 QCOMPARE(status.traversal, QPathEdge::LeftTraversal);
983 QCOMPARE(status.edge, e1);
984
985 status = list.next(status);
986 status.flip();
987 QCOMPARE(status.direction, QPathEdge::Backward);
988 QCOMPARE(status.traversal, QPathEdge::LeftTraversal);
989 QCOMPARE(status.edge, e2);
990 QCOMPARE(loopLength(list, status), 4);
991
992 status = list.next(status);
993 QCOMPARE(status.direction, QPathEdge::Forward);
994 QCOMPARE(status.traversal, QPathEdge::RightTraversal);
995 QCOMPARE(status.edge, e4);
996
997 status = list.next(status);
998 QCOMPARE(status.direction, QPathEdge::Forward);
999 QCOMPARE(status.traversal, QPathEdge::RightTraversal);
1000 QCOMPARE(status.edge, e5);
1001
1002 status = list.next(status);
1003 QCOMPARE(status.direction, QPathEdge::Backward);
1004 QCOMPARE(status.traversal, QPathEdge::LeftTraversal);
1005 QCOMPARE(status.edge, e3);
1006
1007 status = list.next(status);
1008 QCOMPARE(status.direction, QPathEdge::Backward);
1009 QCOMPARE(status.traversal, QPathEdge::LeftTraversal);
1010 QCOMPARE(status.edge, e2);
1011 }
1012 {
1013 QPainterPath path = pathFromRect(0, 0, 20, 20);
1014 QWingedEdge list(path, QPainterPath());
1015
1016 QCOMPARE(list.edgeCount(), 4);
1017 QCOMPARE(list.vertexCount(), 4);
1018
1019 QWingedEdge::TraversalStatus status = { 0, QPathEdge::RightTraversal, QPathEdge::Forward };
1020
1021 QPathEdge *edge = list.edge(status.edge);
1022 QCOMPARE(QPointF(*list.vertex(edge->first)), QPointF(0, 0));
1023 QCOMPARE(QPointF(*list.vertex(edge->second)), QPointF(20, 0));
1024
1025 status = list.next(status);
1026 QCOMPARE(status.edge, 1);
1027
1028 status = list.next(status);
1029 QCOMPARE(status.edge, 2);
1030
1031 status = list.next(status);
1032 QCOMPARE(status.edge, 3);
1033
1034 status = list.next(status);
1035 QCOMPARE(status.edge, 0);
1036
1037 status.flipDirection();
1038 status = list.next(status);
1039 QCOMPARE(status.edge, 3);
1040
1041 status = list.next(status);
1042 QCOMPARE(status.edge, 2);
1043
1044 status = list.next(status);
1045 QCOMPARE(status.edge, 1);
1046
1047 status = list.next(status);
1048 QCOMPARE(status.edge, 0);
1049
1050 QWingedEdge list2(path, pathFromRect(10, 5, 20, 10));
1051
1052 QCOMPARE(list2.edgeCount(), 12);
1053 QCOMPARE(list2.vertexCount(), 10);
1054
1055 status.flipDirection();
1056 QCOMPARE(loopLength(list2, status), 8);
1057
1058 status = list2.next(status);
1059 edge = list2.edge(status.edge);
1060 QCOMPARE(QPointF(*list2.vertex(edge->first)), QPointF(20, 0));
1061 QCOMPARE(QPointF(*list2.vertex(edge->second)), QPointF(20, 5));
1062
1063 status = list2.next(status);
1064 status.flipTraversal();
1065
1066 edge = list2.edge(status.edge);
1067 QCOMPARE(QPointF(*list2.vertex(edge->first)), QPointF(10, 5));
1068 QCOMPARE(QPointF(*list2.vertex(edge->second)), QPointF(20, 5));
1069
1070 QCOMPARE(loopLength(list2, status), 4);
1071
1072 status.flipDirection();
1073 status = list2.next(status);
1074 status.flipTraversal();
1075
1076 edge = list2.edge(status.edge);
1077 QCOMPARE(QPointF(*list2.vertex(edge->first)), QPointF(20, 5));
1078 QCOMPARE(QPointF(*list2.vertex(edge->second)), QPointF(20, 15));
1079
1080 QCOMPARE(loopLength(list2, status), 4);
1081 status = list2.next(status);
1082 status = list2.next(status);
1083
1084 edge = list2.edge(status.edge);
1085 QCOMPARE(QPointF(*list2.vertex(edge->first)), QPointF(30, 5));
1086 QCOMPARE(QPointF(*list2.vertex(edge->second)), QPointF(30, 15));
1087 }
1088 }
1089
1090 void tst_QPathClipper::zeroDerivativeCurves()
1091 {
1092 // zero derivative at end
1093 {
1094 QPainterPath a;
1095 a.cubicTo(100, 0, 100, 100, 100, 100);
1096 a.lineTo(100, 200);
1097 a.lineTo(0, 200);
1098
1099 QPainterPath b;
1100 b.moveTo(50, 100);
1101 b.lineTo(150, 100);
1102 b.lineTo(150, 150);
1103 b.lineTo(50, 150);
1104
1105 QPainterPath c = a.united(b);
1106 QVERIFY(c.contains(QPointF(25, 125)));
1107 QVERIFY(c.contains(QPointF(75, 125)));
1108 QVERIFY(c.contains(QPointF(125, 125)));
1109 }
1110
1111 // zero derivative at start
1112 {
1113 QPainterPath a;
1114 a.cubicTo(100, 0, 100, 100, 100, 100);
1115 a.lineTo(100, 200);
1116 a.lineTo(0, 200);
1117
1118 QPainterPath b;
1119 b.moveTo(50, 100);
1120 b.lineTo(150, 100);
1121 b.lineTo(150, 150);
1122 b.lineTo(50, 150);
1123
1124 QPainterPath c = a.united(b);
1125 QVERIFY(c.contains(QPointF(25, 125)));
1126 QVERIFY(c.contains(QPointF(75, 125)));
1127 QVERIFY(c.contains(QPointF(125, 125)));
1128 }
1129 }
1130
1131 static bool strictContains(const QPainterPath &a, const QPainterPath &b)
1132 {
1133 return b.subtracted(a) == QPainterPath();
1134 }
1135
1136
1137 void tst_QPathClipper::task204301_data()
1138 {
1139 QTest::addColumn<QPolygonF>("points");
1140
1141 {
1142 QPointF a(51.09013255685567855835, 31.30814891308546066284);
1143 QPointF b(98.39898971840739250183, 11.02079074829816818237);
1144 QPointF c(91.23911846894770860672, 45.86981737054884433746);
1145 QPointF d(66.58616356085985898972, 63.10526528395712375641);
1146 QPointF e(82.08219456479714892794, 94.90238165489137145414);
1147 QPointF f(16.09013040543221251255, 105.66263409332729850121);
1148 QPointF g(10.62811442650854587555, 65.09154842235147953033);
1149 QPointF h(5.16609844751656055450, 24.52046275138854980469);
1150 QPolygonF v;
1151 v << a << b << c << d << e << f << g << h;
1152 QTest::newRow("failed_on_linux") << v;
1153 }
1154
1155 {
1156 QPointF a(50.014648437500000, 24.392089843750000);
1157 QPointF b(92.836303710937500, 5.548706054687500);
1158 QPointF c(92.145690917968750, 54.390258789062500);
1159 QPointF d(65.402221679687500, 74.345092773437500);
1160 QPointF e(80.789794921787347, 124.298095703129690);
1161 QPointF f(34.961242675812954, 87.621459960852135);
1162 QPointF g(18.305969238281250, 57.426757812500000);
1163 QPointF h(1.650695800781250, 27.232055664062500);
1164 QPolygonF v;
1165 v << a << b << c << d << e << f << g << h;
1166 QTest::newRow("failed_on_windows") << v;
1167 }
1168 }
1169
1170 void tst_QPathClipper::task204301()
1171 {
1172 QFETCH(QPolygonF, points);
1173
1174 QPointF a = points[0];
1175 QPointF b = points[1];
1176 QPointF c = points[2];
1177 QPointF d = points[3];
1178 QPointF e = points[4];
1179 QPointF f = points[5];
1180 QPointF g = points[6];
1181 QPointF h = points[7];
1182
1183 QPainterPath subA;
1184 subA.addPolygon(QPolygonF() << a << b << c << d);
1185 subA.closeSubpath();
1186
1187 QPainterPath subB;
1188 subB.addPolygon(QPolygonF() << f << e << d << g);
1189 subB.closeSubpath();
1190
1191 QPainterPath subC;
1192 subC.addPolygon(QPolygonF() << h << a << d << g);
1193 subC.closeSubpath();
1194
1195 QPainterPath path;
1196 path.addPath(subA);
1197 path.addPath(subB);
1198 path.addPath(subC);
1199
1200 QPainterPath simplified = path.simplified();
1201
1202 QVERIFY(strictContains(simplified, subA));
1203 QVERIFY(strictContains(simplified, subB));
1204 QVERIFY(strictContains(simplified, subC));
1205 }
1206
1207 void tst_QPathClipper::task209056()
1208 {
1209 QPainterPath p1;
1210 p1.moveTo( QPointF(188.506, 287.793) );
1211 p1.lineTo( QPointF(288.506, 287.793) );
1212 p1.lineTo( QPointF(288.506, 387.793) );
1213 p1.lineTo( QPointF(188.506, 387.793) );
1214 p1.lineTo( QPointF(188.506, 287.793) );
1215
1216 QPainterPath p2;
1217 p2.moveTo( QPointF(419.447, 164.383) );
1218 p2.cubicTo( QPointF(419.447, 69.5486), QPointF(419.447, 259.218),QPointF(419.447, 164.383) );
1219
1220 p2.cubicTo( QPointF(48.9378, 259.218), QPointF(131.879, 336.097),QPointF(234.192, 336.097) );
1221 p2.cubicTo( QPointF(336.506, 336.097), QPointF(419.447, 259.218),QPointF(419.447, 164.383) );
1222
1223 QPainterPath p3 = p1.intersected(p2);
1224
1225 QVERIFY(p3 != QPainterPath());
1226 }
1227
1228 void tst_QPathClipper::task251909()
1229 {
1230 QPainterPath p1;
1231 p1.moveTo(0, -10);
1232 p1.lineTo(10, -10);
1233 p1.lineTo(10, 0);
1234 p1.lineTo(0, 0);
1235
1236 QPainterPath p2;
1237 p2.moveTo(0, 8e-14);
1238 p2.lineTo(10, -8e-14);
1239 p2.lineTo(10, 10);
1240 p2.lineTo(0, 10);
1241
1242 QPainterPath result = p1.united(p2);
1243
1244 QVERIFY(result.elementCount() <= 5);
1245 }
1246
1247 void tst_QPathClipper::qtbug3778()
1248 {
1249 if (sizeof(double) != sizeof(qreal)) {
1250 QSKIP("This test only works for qreal=double, otherwise ends in rounding errors");
1251 }
1252 QPainterPath path1;
1253 path1.moveTo(200, 3.22409e-5);
1254 // e-5 and higher leads to a bug
1255 // Using 3.22409e-4 starts to work correctly
1256 path1.lineTo(0, 0);
1257 path1.lineTo(1.07025e-13, 1450);
1258 path1.lineTo(750, 950);
1259 path1.lineTo(950, 750);
1260 path1.lineTo(200, 3.22409e-13);
1261
1262 QPainterPath path2;
1263 path2.moveTo(0, 0);
1264 path2.lineTo(200, 800);
1265 path2.lineTo(600, 1500);
1266 path2.lineTo(1500, 1400);
1267 path2.lineTo(1900, 1200);
1268 path2.lineTo(2000, 1000);
1269 path2.lineTo(1400, 0);
1270 path2.lineTo(0, 0);
1271
1272 QPainterPath p12 = path1.intersected(path2);
1273
1274 QVERIFY(p12.contains(QPointF(100, 100)));
1275 }
1276
1277 void tst_QPathClipper::qtbug60024()
1278 {
1279 QPolygonF poly1, poly2;
1280 poly1 << QPointF(508.331,1010.23) ;
1281 poly1 << QPointF(492.798,1023.11) ;
1282 poly1 << QPointF(491.431,1024.23) ;
1283 poly1 << QPointF(491.928,1022.94) ;
1284 poly1 << QPointF(492.054,1022.15) ;
1285 poly1 << QPointF(492.136,1020.91) ;
1286 poly1 << QPointF(491.638,1019.2) ;
1287 poly1 << QPointF(490.436,1017.12) ;
1288 poly1 << QPointF(489.856,1016.46) ;
1289 poly1 << QPointF(489.276,1016.08) ;
1290 poly1 << QPointF(488.16,1015.54) ;
1291 poly1 << QPointF(487.33,1014.91) ;
1292 poly1 << QPointF(486.914,1014.16) ;
1293 poly1 << QPointF(486.875,1013.54) ;
1294 poly1 << QPointF(487.204,1012.38) ;
1295 poly1 << QPointF(487.412,1011.34) ;
1296 poly1 << QPointF(487.373,1009.92) ;
1297 poly1 << QPointF(487.702,1007.34) ;
1298 poly1 << QPointF(487.909,1006.3) ;
1299 poly1 << QPointF(488.242,1005.55) ;
1300 poly1 << QPointF(488.74,1004.14) ;
1301 poly1 << QPointF(489.445,1003.14) ;
1302 poly1 << QPointF(490.107,1001.56) ;
1303 poly1 << QPointF(490.064,1000.98) ;
1304 poly1 << QPointF(489.566,999.936) ;
1305 poly1 << QPointF(488.489,998.194) ;
1306 poly1 << QPointF(488.117,997.274) ;
1307 poly1 << QPointF(487.909,995.946) ;
1308 poly1 << QPointF(487.909,995.027) ;
1309 poly1 << QPointF(488.117,993.16) ;
1310 poly1 << QPointF(488.658,989.749) ;
1311 poly1 << QPointF(488.861,987.002) ;
1312 poly1 << QPointF(489.359,976.434) ;
1313 poly1 << QPointF(489.484,974.476) ;
1314 poly1 << QPointF(489.484,972.859) ;
1315 poly1 << QPointF(489.359,971.775) ;
1316 poly1 << QPointF(489.151,970.986) ;
1317 poly1 << QPointF(488.948,969.323) ;
1318 poly1 << QPointF(488.74,966.036) ;
1319 poly1 << QPointF(488.74,964.118) ;
1320 poly1 << QPointF(489.03,961.292) ;
1321 poly1 << QPointF(489.237,960.667) ;
1322 poly1 << QPointF(489.648,960.043) ;
1323 poly1 << QPointF(490.452,959.229) ;
1324 poly1 << QPointF(491.528,958.225) ;
1325 poly1 << QPointF(491.731,957.515) ;
1326 poly1 << QPointF(491.32,956.812) ;
1327 poly1 << QPointF(490.45,955.852) ;
1328 poly1 << QPointF(489.412,954.354) ;
1329 poly1 << QPointF(488.68,952.934) ;
1330 poly1 << QPointF(488.625,951.201) ;
1331 poly1 << QPointF(488.954,950.072) ;
1332 poly1 << QPointF(489.237,949.225) ;
1333 poly1 << QPointF(489.256,948.668) ;
1334 poly1 << QPointF(489.402,948.186) ;
1335 poly1 << QPointF(489.566,947.437) ;
1336 poly1 << QPointF(490.025,945.899) ;
1337 poly1 << QPointF(490.687,944.026) ;
1338 poly1 << QPointF(491.059,942.073) ;
1339 poly1 << QPointF(491.31,941.159) ;
1340 poly1 << QPointF(491.846,937.248) ;
1341 poly1 << QPointF(492.054,936.374) ;
1342 poly1 << QPointF(492.594,935.29) ;
1343 poly1 << QPointF(492.594,935.086) ;
1344 poly1 << QPointF(492.261,934.416) ;
1345 poly1 << QPointF(492.054,933.377) ;
1346 poly1 << QPointF(492.054,932.628) ;
1347 poly1 << QPointF(492.798,929.217) ;
1348 poly1 << QPointF(493.174,928.217) ;
1349 poly1 << QPointF(493.005,927.514) ;
1350 poly1 << QPointF(492.923,926.719) ;
1351 poly1 << QPointF(493.295,921.44) ;
1352 poly1 << QPointF(493.421,919.771) ;
1353 poly1 << QPointF(493.628,914.492) ;
1354 poly1 << QPointF(493.71,913.158) ;
1355 poly1 << QPointF(493.961,910.831) ;
1356 poly1 << QPointF(494.623,909.247) ;
1357 poly1 << QPointF(495.41,906.085) ;
1358 poly1 << QPointF(495.203,905.421) ;
1359 poly1 << QPointF(494.788,904.632) ;
1360 poly1 << QPointF(494.705,904.297) ;
1361 poly1 << QPointF(494.788,903.797) ;
1362 poly1 << QPointF(495.121,902.844) ;
1363 poly1 << QPointF(495.493,902.055) ;
1364 poly1 << QPointF(496.033,900.556) ;
1365 poly1 << QPointF(496.28,900.096) ;
1366 poly1 << QPointF(496.488,899.222) ;
1367 poly1 << QPointF(496.28,898.723) ;
1368 poly1 << QPointF(495.41,898.098) ;
1369 poly1 << QPointF(494.326,898.084) ;
1370 poly1 << QPointF(493.993,897.42) ;
1371 poly1 << QPointF(493.829,896.67) ;
1372 poly1 << QPointF(493.621,894.962) ;
1373 poly1 << QPointF(493.565,893.93) ;
1374 poly1 << QPointF(494.416,893.358) ;
1375 poly1 << QPointF(501.666,887.435) ;
1376 poly1 << QPointF(513.305,877.908) ;
1377 poly1 << QPointF(523.795,869.356) ;
1378 poly1 << QPointF(603.378,804.221) ;
1379 poly1 << QPointF(618.764,791.762) ;
1380 poly1 << QPointF(618.981,791.584) ;
1381 poly1 << QPointF(634.696,778.743) ;
1382 poly1 << QPointF(673.531,747.007) ;
1383 poly1 << QPointF(726.115,704.031) ;
1384 poly1 << QPointF(759.04,677.12) ;
1385 poly1 << QPointF(759.672,676.62) ;
1386 poly1 << QPointF(778.846,660.773) ;
1387 poly1 << QPointF(789.919,651.709) ;
1388 poly1 << QPointF(810.528,634.696) ;
1389 poly1 << QPointF(810.804,634.468) ;
1390 poly1 << QPointF(818.197,628.365) ;
1391 poly1 << QPointF(826.44,621.505) ;
1392 poly1 << QPointF(832.634,616.351) ;
1393 poly1 << QPointF(835.337,614.05) ;
1394 poly1 << QPointF(835.492,613.931) ;
1395 poly1 << QPointF(852.079,600.176) ;
1396 poly1 << QPointF(860.469,593.219) ;
1397 poly1 << QPointF(869.883,585.411) ;
1398 poly1 << QPointF(896.749,563.131) ;
1399 poly1 << QPointF(922.094,542.111) ;
1400 poly1 << QPointF(936.469,530.189) ;
1401 poly1 << QPointF(990.034,485.759) ;
1402 poly1 << QPointF(1001.65,476.123) ;
1403 poly1 << QPointF(1010.87,468.472) ;
1404 poly1 << QPointF(1028.6,453.769) ;
1405 poly1 << QPointF(1095.89,397.341) ;
1406 poly1 << QPointF(1130.52,368.297) ;
1407 poly1 << QPointF(1135.05,364.497) ;
1408 poly1 << QPointF(1123.55,337.582) ;
1409 poly1 << QPointF(1103.42,290.476) ;
1410 poly1 << QPointF(1095.21,271.259) ;
1411 poly1 << QPointF(1068.04,207.66) ;
1412 poly1 << QPointF(1051.62,169.118) ;
1413 poly1 << QPointF(1038.65,138.708) ;
1414 poly1 << QPointF(1027.81,113.269) ;
1415 poly1 << QPointF(1020.97,97.2145) ;
1416 poly1 << QPointF(1010.84,73.4644) ;
1417 poly1 << QPointF(988.424,20.9198) ;
1418 poly1 << QPointF(968.442,-25.9307) ;
1419 poly1 << QPointF(964.63,-34.8693) ;
1420 poly1 << QPointF(961.883,-41.3111) ;
1421 poly1 << QPointF(953.157,-61.929) ;
1422 poly1 << QPointF(949.712,-70.0717) ;
1423 poly1 << QPointF(946.048,-78.7331) ;
1424 poly1 << QPointF(945.789,-79.3443) ;
1425 poly1 << QPointF(945.548,-79.9146) ;
1426 poly1 << QPointF(941.671,-89.0782) ;
1427 poly1 << QPointF(940.408,-92.0616) ;
1428 poly1 << QPointF(940.095,-92.8021) ;
1429 poly1 << QPointF(938.65,-97.1094) ;
1430 poly1 << QPointF(934.565,-106.581) ;
1431 poly1 << QPointF(928.429,-121.542) ;
1432 poly1 << QPointF(928.24,-122.003) ;
1433 poly1 << QPointF(920.902,-139.241) ;
1434 poly1 << QPointF(910.85,-162.115) ;
1435 poly1 << QPointF(910.744,-162.357) ;
1436 poly1 << QPointF(900.875,-186.271) ;
1437 poly1 << QPointF(889.416,-213.089) ;
1438 poly1 << QPointF(883.705,-226.225) ;
1439 poly1 << QPointF(882.788,-228.422) ;
1440 poly1 << QPointF(881.399,-231.753) ;
1441 poly1 << QPointF(880.373,-234.213) ;
1442 poly1 << QPointF(875.788,-245.204) ;
1443 poly1 << QPointF(872.772,-252.085) ;
1444 poly1 << QPointF(869.686,-259.126) ;
1445 poly1 << QPointF(865.607,-268.43) ;
1446 poly1 << QPointF(868.74,-269.605) ;
1447 poly1 << QPointF(869.315,-269.834) ;
1448 poly1 << QPointF(879.443,-273.853) ;
1449 poly1 << QPointF(880.259,-274.217) ;
1450 poly1 << QPointF(888.958,-278.09) ;
1451 poly1 << QPointF(894.204,-280.426) ;
1452 poly1 << QPointF(902.866,-284.423) ;
1453 poly1 << QPointF(913.804,-289.072) ;
1454 poly1 << QPointF(917.975,-290.846) ;
1455 poly1 << QPointF(921.854,-292.375) ;
1456 poly1 << QPointF(930.52,-295.793) ;
1457 poly1 << QPointF(939.972,-299.79) ;
1458 poly1 << QPointF(940.899,-300.183) ;
1459 poly1 << QPointF(943.262,-294.709) ;
1460 poly1 << QPointF(946.922,-286.233) ;
1461 poly1 << QPointF(952.358,-273.643) ;
1462 poly1 << QPointF(959.976,-256) ;
1463 poly1 << QPointF(975.219,-220.296) ;
1464 poly1 << QPointF(988.991,-188.494) ;
1465 poly1 << QPointF(990.089,-185.959) ;
1466 poly1 << QPointF(1001.86,-158.88) ;
1467 poly1 << QPointF(1003.8,-154.245) ;
1468 poly1 << QPointF(1011.55,-135.749) ;
1469 poly1 << QPointF(1012.2,-134.199) ;
1470 poly1 << QPointF(1012.77,-132.837) ;
1471 poly1 << QPointF(1015.9,-125.529) ;
1472 poly1 << QPointF(1015.99,-125.305) ;
1473 poly1 << QPointF(1016.42,-124.299) ;
1474 poly1 << QPointF(1018.02,-120.569) ;
1475 poly1 << QPointF(1018.47,-119.395) ;
1476 poly1 << QPointF(1028.09,-97.0593) ;
1477 poly1 << QPointF(1028.89,-95.1902) ;
1478 poly1 << QPointF(1032.85,-85.957) ;
1479 poly1 << QPointF(1044.48,-58.8103) ;
1480 poly1 << QPointF(1047.23,-52.3933) ;
1481 poly1 << QPointF(1076.35,15.5527) ;
1482 poly1 << QPointF(1089.43,46.0648) ;
1483 poly1 << QPointF(1105.35,83.1913) ;
1484 poly1 << QPointF(1120.01,117.391) ;
1485 poly1 << QPointF(1131.66,144.66) ;
1486 poly1 << QPointF(1142.1,169.072) ;
1487 poly1 << QPointF(1183.42,265.698) ;
1488 poly1 << QPointF(1200.9,306.583) ;
1489 poly1 << QPointF(1208.48,324.306) ;
1490 poly1 << QPointF(1231.19,377.389) ;
1491 poly1 << QPointF(1241.55,400.064) ;
1492 poly1 << QPointF(1139.56,485.759) ;
1493 poly1 << QPointF(1104.96,514.822) ;
1494 poly1 << QPointF(1044.32,565.761) ;
1495 poly1 << QPointF(1020.92,585.411) ;
1496 poly1 << QPointF(1013.72,591.462) ;
1497 poly1 << QPointF(1012.73,592.285) ;
1498 poly1 << QPointF(926.449,663.776) ;
1499 poly1 << QPointF(843.981,732.099) ;
1500 poly1 << QPointF(826.923,746.23) ;
1501 poly1 << QPointF(810.856,759.539) ;
1502 poly1 << QPointF(736.788,820.887) ;
1503 poly1 << QPointF(709.695,843.348) ;
1504 poly1 << QPointF(693.265,856.967) ;
1505 poly1 << QPointF(690.228,859.484) ;
1506 poly1 << QPointF(673.813,873.091) ;
1507 poly1 << QPointF(672.34,874.317) ;
1508 poly1 << QPointF(618.453,919.164) ;
1509 poly1 << QPointF(607.821,928.011) ;
1510 poly1 << QPointF(596.057,937.538) ;
1511 poly1 << QPointF(580.774,950.204) ;
1512 poly1 << QPointF(573.229,956.457) ;
1513 poly1 << QPointF(533.091,989.719) ;
1514 poly1 << QPointF(513.657,1005.86) ;
1515 poly1 << QPointF(508.331,1010.23) ;
1516
1517 poly2 << QPointF(941.306,435.236) ;
1518 poly2 << QPointF(983.306,435.236) ;
1519 poly2 << QPointF(983.306,473.236) ;
1520 poly2 << QPointF(941.306,473.236) ;
1521 poly2 << QPointF(941.306,435.236) ;
1522
1523 QPainterPath path1, path2;
1524 path1.addPolygon(poly1);
1525 path2.addPolygon(poly2);
1526
1527 QVERIFY(!path1.intersects(path2));
1528 QVERIFY(path1.intersected(path2).isEmpty());
1529 }
1530
1531 QTEST_MAIN(tst_QPathClipper)
1532
1533
1534 #include "tst_qpathclipper.moc"