Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
9 | ** Commercial License Usage | - |
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
11 | ** accordance with the commercial license agreement provided with the | - |
12 | ** Software or, alternatively, in accordance with the terms contained in | - |
13 | ** a written agreement between you and Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
16 | ** | - |
17 | ** GNU Lesser General Public License Usage | - |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
19 | ** General Public License version 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include "qpathclipper_p.h" | - |
43 | | - |
44 | #include <private/qbezier_p.h> | - |
45 | #include <private/qdatabuffer_p.h> | - |
46 | #include <private/qnumeric_p.h> | - |
47 | #include <qmath.h> | - |
48 | | - |
49 | /** | - |
50 | The algorithm is as follows: | - |
51 | | - |
52 | 1. Find all intersections between the two paths (including self-intersections), | - |
53 | and build a winged edge structure of non-intersecting parts. | - |
54 | 2. While there are more unhandled edges: | - |
55 | 3. Pick a y-coordinate from an unhandled edge. | - |
56 | 4. Intersect the horizontal line at y-coordinate with all edges. | - |
57 | 5. Traverse intersections left to right deciding whether each subpath should be added or not. | - |
58 | 6. If the subpath should be added, traverse the winged-edge structure and add the edges to | - |
59 | a separate winged edge structure. | - |
60 | 7. Mark all edges in subpaths crossing the horizontal line as handled. | - |
61 | 8. (Optional) Simplify the resulting winged edge structure by merging shared edges. | - |
62 | 9. Convert the resulting winged edge structure to a painter path. | - |
63 | */ | - |
64 | | - |
65 | #include <qdebug.h> | - |
66 | | - |
67 | QT_BEGIN_NAMESPACE | - |
68 | | - |
69 | static inline bool fuzzyIsNull(qreal d) | - |
70 | { | - |
71 | if (sizeof(qreal) == sizeof(double)) partially evaluated: sizeof(qreal) == sizeof(double) yes Evaluation Count:21050 | no Evaluation Count:0 |
| 0-21050 |
72 | return qAbs(d) <= 1e-12; executed: return qAbs(d) <= 1e-12; Execution Count:21050 | 21050 |
73 | else | - |
74 | return qAbs(d) <= 1e-5f; never executed: return qAbs(d) <= 1e-5f; | 0 |
75 | } | - |
76 | | - |
77 | static inline bool comparePoints(const QPointF &a, const QPointF &b) | - |
78 | { | - |
79 | return fuzzyIsNull(a.x() - b.x()) executed: return fuzzyIsNull(a.x() - b.x()) && fuzzyIsNull(a.y() - b.y()); Execution Count:11537 | 11537 |
80 | && fuzzyIsNull(a.y() - b.y()); executed: return fuzzyIsNull(a.x() - b.x()) && fuzzyIsNull(a.y() - b.y()); Execution Count:11537 | 11537 |
81 | } | - |
82 | | - |
83 | //#define QDEBUG_CLIPPER | - |
84 | static qreal dot(const QPointF &a, const QPointF &b) | - |
85 | { | - |
86 | return a.x() * b.x() + a.y() * b.y(); executed: return a.x() * b.x() + a.y() * b.y(); Execution Count:1291 | 1291 |
87 | } | - |
88 | | - |
89 | static void normalize(double &x, double &y) | - |
90 | { | - |
91 | double reciprocal = 1 / qSqrt(x * x + y * y); never executed (the execution status of this line is deduced): double reciprocal = 1 / qSqrt(x * x + y * y); | - |
92 | x *= reciprocal; never executed (the execution status of this line is deduced): x *= reciprocal; | - |
93 | y *= reciprocal; never executed (the execution status of this line is deduced): y *= reciprocal; | - |
94 | } | 0 |
95 | | - |
96 | struct QIntersection | - |
97 | { | - |
98 | qreal alphaA; | - |
99 | qreal alphaB; | - |
100 | | - |
101 | QPointF pos; | - |
102 | }; | - |
103 | | - |
104 | class QIntersectionFinder | - |
105 | { | - |
106 | public: | - |
107 | void produceIntersections(QPathSegments &segments); | - |
108 | bool hasIntersections(const QPathSegments &a, const QPathSegments &b) const; | - |
109 | | - |
110 | private: | - |
111 | bool linesIntersect(const QLineF &a, const QLineF &b) const; | - |
112 | }; | - |
113 | | - |
114 | bool QIntersectionFinder::linesIntersect(const QLineF &a, const QLineF &b) const | - |
115 | { | - |
116 | const QPointF p1 = a.p1(); executed (the execution status of this line is deduced): const QPointF p1 = a.p1(); | - |
117 | const QPointF p2 = a.p2(); executed (the execution status of this line is deduced): const QPointF p2 = a.p2(); | - |
118 | | - |
119 | const QPointF q1 = b.p1(); executed (the execution status of this line is deduced): const QPointF q1 = b.p1(); | - |
120 | const QPointF q2 = b.p2(); executed (the execution status of this line is deduced): const QPointF q2 = b.p2(); | - |
121 | | - |
122 | if (comparePoints(p1, p2) || comparePoints(q1, q2)) partially evaluated: comparePoints(p1, p2) no Evaluation Count:0 | yes Evaluation Count:104 |
partially evaluated: comparePoints(q1, q2) no Evaluation Count:0 | yes Evaluation Count:104 |
| 0-104 |
123 | return false; never executed: return false; | 0 |
124 | | - |
125 | const bool p1_equals_q1 = comparePoints(p1, q1); executed (the execution status of this line is deduced): const bool p1_equals_q1 = comparePoints(p1, q1); | - |
126 | const bool p2_equals_q2 = comparePoints(p2, q2); executed (the execution status of this line is deduced): const bool p2_equals_q2 = comparePoints(p2, q2); | - |
127 | | - |
128 | if (p1_equals_q1 && p2_equals_q2) evaluated: p1_equals_q1 yes Evaluation Count:4 | yes Evaluation Count:100 |
partially evaluated: p2_equals_q2 yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-100 |
129 | return true; executed: return true; Execution Count:4 | 4 |
130 | | - |
131 | const bool p1_equals_q2 = comparePoints(p1, q2); executed (the execution status of this line is deduced): const bool p1_equals_q2 = comparePoints(p1, q2); | - |
132 | const bool p2_equals_q1 = comparePoints(p2, q1); executed (the execution status of this line is deduced): const bool p2_equals_q1 = comparePoints(p2, q1); | - |
133 | | - |
134 | if (p1_equals_q2 && p2_equals_q1) partially evaluated: p1_equals_q2 no Evaluation Count:0 | yes Evaluation Count:100 |
never evaluated: p2_equals_q1 | 0-100 |
135 | return true; never executed: return true; | 0 |
136 | | - |
137 | const QPointF pDelta = p2 - p1; executed (the execution status of this line is deduced): const QPointF pDelta = p2 - p1; | - |
138 | const QPointF qDelta = q2 - q1; executed (the execution status of this line is deduced): const QPointF qDelta = q2 - q1; | - |
139 | | - |
140 | const qreal par = pDelta.x() * qDelta.y() - pDelta.y() * qDelta.x(); executed (the execution status of this line is deduced): const qreal par = pDelta.x() * qDelta.y() - pDelta.y() * qDelta.x(); | - |
141 | | - |
142 | if (qFuzzyIsNull(par)) { partially evaluated: qFuzzyIsNull(par) no Evaluation Count:0 | yes Evaluation Count:100 |
| 0-100 |
143 | const QPointF normal(-pDelta.y(), pDelta.x()); never executed (the execution status of this line is deduced): const QPointF normal(-pDelta.y(), pDelta.x()); | - |
144 | | - |
145 | // coinciding? | - |
146 | if (qFuzzyIsNull(dot(normal, q1 - p1))) { never evaluated: qFuzzyIsNull(dot(normal, q1 - p1)) | 0 |
147 | const qreal dp = dot(pDelta, pDelta); never executed (the execution status of this line is deduced): const qreal dp = dot(pDelta, pDelta); | - |
148 | | - |
149 | const qreal tq1 = dot(pDelta, q1 - p1); never executed (the execution status of this line is deduced): const qreal tq1 = dot(pDelta, q1 - p1); | - |
150 | const qreal tq2 = dot(pDelta, q2 - p1); never executed (the execution status of this line is deduced): const qreal tq2 = dot(pDelta, q2 - p1); | - |
151 | | - |
152 | if ((tq1 > 0 && tq1 < dp) || (tq2 > 0 && tq2 < dp)) never evaluated: tq1 > 0 never evaluated: tq1 < dp never evaluated: tq2 > 0 never evaluated: tq2 < dp | 0 |
153 | return true; never executed: return true; | 0 |
154 | | - |
155 | const qreal dq = dot(qDelta, qDelta); never executed (the execution status of this line is deduced): const qreal dq = dot(qDelta, qDelta); | - |
156 | | - |
157 | const qreal tp1 = dot(qDelta, p1 - q1); never executed (the execution status of this line is deduced): const qreal tp1 = dot(qDelta, p1 - q1); | - |
158 | const qreal tp2 = dot(qDelta, p2 - q1); never executed (the execution status of this line is deduced): const qreal tp2 = dot(qDelta, p2 - q1); | - |
159 | | - |
160 | if ((tp1 > 0 && tp1 < dq) || (tp2 > 0 && tp2 < dq)) never evaluated: tp1 > 0 never evaluated: tp1 < dq never evaluated: tp2 > 0 never evaluated: tp2 < dq | 0 |
161 | return true; never executed: return true; | 0 |
162 | } | 0 |
163 | | - |
164 | return false; never executed: return false; | 0 |
165 | } | - |
166 | | - |
167 | const qreal invPar = 1 / par; executed (the execution status of this line is deduced): const qreal invPar = 1 / par; | - |
168 | | - |
169 | const qreal tp = (qDelta.y() * (q1.x() - p1.x()) - executed (the execution status of this line is deduced): const qreal tp = (qDelta.y() * (q1.x() - p1.x()) - | - |
170 | qDelta.x() * (q1.y() - p1.y())) * invPar; executed (the execution status of this line is deduced): qDelta.x() * (q1.y() - p1.y())) * invPar; | - |
171 | | - |
172 | if (tp < 0 || tp > 1) evaluated: tp < 0 yes Evaluation Count:15 | yes Evaluation Count:85 |
evaluated: tp > 1 yes Evaluation Count:11 | yes Evaluation Count:74 |
| 11-85 |
173 | return false; executed: return false; Execution Count:26 | 26 |
174 | | - |
175 | const qreal tq = (pDelta.y() * (q1.x() - p1.x()) - executed (the execution status of this line is deduced): const qreal tq = (pDelta.y() * (q1.x() - p1.x()) - | - |
176 | pDelta.x() * (q1.y() - p1.y())) * invPar; executed (the execution status of this line is deduced): pDelta.x() * (q1.y() - p1.y())) * invPar; | - |
177 | | - |
178 | return tq >= 0 && tq <= 1; executed: return tq >= 0 && tq <= 1; Execution Count:74 | 74 |
179 | } | - |
180 | | - |
181 | bool QIntersectionFinder::hasIntersections(const QPathSegments &a, const QPathSegments &b) const | - |
182 | { | - |
183 | if (a.segments() == 0 || b.segments() == 0) partially evaluated: a.segments() == 0 no Evaluation Count:0 | yes Evaluation Count:121 |
partially evaluated: b.segments() == 0 no Evaluation Count:0 | yes Evaluation Count:121 |
| 0-121 |
184 | return false; never executed: return false; | 0 |
185 | | - |
186 | const QRectF &rb0 = b.elementBounds(0); executed (the execution status of this line is deduced): const QRectF &rb0 = b.elementBounds(0); | - |
187 | | - |
188 | qreal minX = rb0.left(); executed (the execution status of this line is deduced): qreal minX = rb0.left(); | - |
189 | qreal minY = rb0.top(); executed (the execution status of this line is deduced): qreal minY = rb0.top(); | - |
190 | qreal maxX = rb0.right(); executed (the execution status of this line is deduced): qreal maxX = rb0.right(); | - |
191 | qreal maxY = rb0.bottom(); executed (the execution status of this line is deduced): qreal maxY = rb0.bottom(); | - |
192 | | - |
193 | for (int i = 1; i < b.segments(); ++i) { evaluated: i < b.segments() yes Evaluation Count:17667 | yes Evaluation Count:121 |
| 121-17667 |
194 | const QRectF &r = b.elementBounds(i); executed (the execution status of this line is deduced): const QRectF &r = b.elementBounds(i); | - |
195 | minX = qMin(minX, r.left()); executed (the execution status of this line is deduced): minX = qMin(minX, r.left()); | - |
196 | minY = qMin(minY, r.top()); executed (the execution status of this line is deduced): minY = qMin(minY, r.top()); | - |
197 | maxX = qMax(maxX, r.right()); executed (the execution status of this line is deduced): maxX = qMax(maxX, r.right()); | - |
198 | maxY = qMax(maxY, r.bottom()); executed (the execution status of this line is deduced): maxY = qMax(maxY, r.bottom()); | - |
199 | } executed: } Execution Count:17667 | 17667 |
200 | | - |
201 | QRectF rb(minX, minY, maxX - minX, maxY - minY); executed (the execution status of this line is deduced): QRectF rb(minX, minY, maxX - minX, maxY - minY); | - |
202 | | - |
203 | for (int i = 0; i < a.segments(); ++i) { evaluated: i < a.segments() yes Evaluation Count:604 | yes Evaluation Count:43 |
| 43-604 |
204 | const QRectF &r1 = a.elementBounds(i); executed (the execution status of this line is deduced): const QRectF &r1 = a.elementBounds(i); | - |
205 | | - |
206 | if (r1.left() > rb.right() || rb.left() > r1.right()) evaluated: r1.left() > rb.right() yes Evaluation Count:192 | yes Evaluation Count:412 |
evaluated: rb.left() > r1.right() yes Evaluation Count:96 | yes Evaluation Count:316 |
| 96-412 |
207 | continue; executed: continue; Execution Count:288 | 288 |
208 | if (r1.top() > rb.bottom() || rb.top() > r1.bottom()) evaluated: r1.top() > rb.bottom() yes Evaluation Count:59 | yes Evaluation Count:257 |
evaluated: rb.top() > r1.bottom() yes Evaluation Count:70 | yes Evaluation Count:187 |
| 59-257 |
209 | continue; executed: continue; Execution Count:129 | 129 |
210 | | - |
211 | for (int j = 0; j < b.segments(); ++j) { evaluated: j < b.segments() yes Evaluation Count:50257 | yes Evaluation Count:109 |
| 109-50257 |
212 | const QRectF &r2 = b.elementBounds(j); executed (the execution status of this line is deduced): const QRectF &r2 = b.elementBounds(j); | - |
213 | | - |
214 | if (r1.left() > r2.right() || r2.left() > r1.right()) evaluated: r1.left() > r2.right() yes Evaluation Count:24436 | yes Evaluation Count:25821 |
evaluated: r2.left() > r1.right() yes Evaluation Count:23185 | yes Evaluation Count:2636 |
| 2636-25821 |
215 | continue; executed: continue; Execution Count:47621 | 47621 |
216 | if (r1.top() > r2.bottom() || r2.top() > r1.bottom()) evaluated: r1.top() > r2.bottom() yes Evaluation Count:477 | yes Evaluation Count:2159 |
evaluated: r2.top() > r1.bottom() yes Evaluation Count:2055 | yes Evaluation Count:104 |
| 104-2159 |
217 | continue; executed: continue; Execution Count:2532 | 2532 |
218 | | - |
219 | if (linesIntersect(a.lineAt(i), b.lineAt(j))) evaluated: linesIntersect(a.lineAt(i), b.lineAt(j)) yes Evaluation Count:78 | yes Evaluation Count:26 |
| 26-78 |
220 | return true; executed: return true; Execution Count:78 | 78 |
221 | } executed: } Execution Count:26 | 26 |
222 | } executed: } Execution Count:109 | 109 |
223 | | - |
224 | return false; executed: return false; Execution Count:43 | 43 |
225 | } | - |
226 | | - |
227 | namespace { | - |
228 | struct TreeNode | - |
229 | { | - |
230 | qreal splitLeft; | - |
231 | qreal splitRight; | - |
232 | bool leaf; | - |
233 | | - |
234 | int lowestLeftIndex; | - |
235 | int lowestRightIndex; | - |
236 | | - |
237 | union { | - |
238 | struct { | - |
239 | int first; | - |
240 | int last; | - |
241 | } interval; | - |
242 | struct { | - |
243 | int left; | - |
244 | int right; | - |
245 | } children; | - |
246 | } index; | - |
247 | }; | - |
248 | | - |
249 | struct RectF | - |
250 | { | - |
251 | qreal x1; | - |
252 | qreal y1; | - |
253 | qreal x2; | - |
254 | qreal y2; | - |
255 | }; | - |
256 | | - |
257 | class SegmentTree | - |
258 | { | - |
259 | public: | - |
260 | SegmentTree(QPathSegments &segments); | - |
261 | | - |
262 | QRectF boundingRect() const; | - |
263 | | - |
264 | void produceIntersections(int segment); | - |
265 | | - |
266 | private: | - |
267 | TreeNode buildTree(int first, int last, int depth, const RectF &bounds); | - |
268 | | - |
269 | void produceIntersectionsLeaf(const TreeNode &node, int segment); | - |
270 | void produceIntersections(const TreeNode &node, int segment, const RectF &segmentBounds, const RectF &nodeBounds, int axis); | - |
271 | void intersectLines(const QLineF &a, const QLineF &b, QDataBuffer<QIntersection> &intersections); | - |
272 | | - |
273 | QPathSegments &m_segments; | - |
274 | QVector<int> m_index; | - |
275 | | - |
276 | RectF m_bounds; | - |
277 | | - |
278 | QVector<TreeNode> m_tree; | - |
279 | QDataBuffer<QIntersection> m_intersections; | - |
280 | }; | - |
281 | | - |
282 | SegmentTree::SegmentTree(QPathSegments &segments) | - |
283 | : m_segments(segments), | - |
284 | m_intersections(0) | - |
285 | { | - |
286 | m_bounds.x1 = qt_inf(); executed (the execution status of this line is deduced): m_bounds.x1 = qt_inf(); | - |
287 | m_bounds.y1 = qt_inf(); executed (the execution status of this line is deduced): m_bounds.y1 = qt_inf(); | - |
288 | m_bounds.x2 = -qt_inf(); executed (the execution status of this line is deduced): m_bounds.x2 = -qt_inf(); | - |
289 | m_bounds.y2 = -qt_inf(); executed (the execution status of this line is deduced): m_bounds.y2 = -qt_inf(); | - |
290 | | - |
291 | m_index.resize(m_segments.segments()); executed (the execution status of this line is deduced): m_index.resize(m_segments.segments()); | - |
292 | | - |
293 | for (int i = 0; i < m_index.size(); ++i) { evaluated: i < m_index.size() yes Evaluation Count:488 | yes Evaluation Count:70 |
| 70-488 |
294 | m_index[i] = i; executed (the execution status of this line is deduced): m_index[i] = i; | - |
295 | | - |
296 | const QRectF &segmentBounds = m_segments.elementBounds(i); executed (the execution status of this line is deduced): const QRectF &segmentBounds = m_segments.elementBounds(i); | - |
297 | | - |
298 | if (segmentBounds.left() < m_bounds.x1) evaluated: segmentBounds.left() < m_bounds.x1 yes Evaluation Count:73 | yes Evaluation Count:415 |
| 73-415 |
299 | m_bounds.x1 = segmentBounds.left(); executed: m_bounds.x1 = segmentBounds.left(); Execution Count:73 | 73 |
300 | if (segmentBounds.top() < m_bounds.y1) evaluated: segmentBounds.top() < m_bounds.y1 yes Evaluation Count:71 | yes Evaluation Count:417 |
| 71-417 |
301 | m_bounds.y1 = segmentBounds.top(); executed: m_bounds.y1 = segmentBounds.top(); Execution Count:71 | 71 |
302 | if (segmentBounds.right() > m_bounds.x2) evaluated: segmentBounds.right() > m_bounds.x2 yes Evaluation Count:93 | yes Evaluation Count:395 |
| 93-395 |
303 | m_bounds.x2 = segmentBounds.right(); executed: m_bounds.x2 = segmentBounds.right(); Execution Count:93 | 93 |
304 | if (segmentBounds.bottom() > m_bounds.y2) evaluated: segmentBounds.bottom() > m_bounds.y2 yes Evaluation Count:155 | yes Evaluation Count:333 |
| 155-333 |
305 | m_bounds.y2 = segmentBounds.bottom(); executed: m_bounds.y2 = segmentBounds.bottom(); Execution Count:155 | 155 |
306 | } executed: } Execution Count:488 | 488 |
307 | | - |
308 | m_tree.resize(1); executed (the execution status of this line is deduced): m_tree.resize(1); | - |
309 | | - |
310 | TreeNode root = buildTree(0, m_index.size(), 0, m_bounds); executed (the execution status of this line is deduced): TreeNode root = buildTree(0, m_index.size(), 0, m_bounds); | - |
311 | m_tree[0] = root; executed (the execution status of this line is deduced): m_tree[0] = root; | - |
312 | } executed: } Execution Count:70 | 70 |
313 | | - |
314 | QRectF SegmentTree::boundingRect() const | - |
315 | { | - |
316 | return QRectF(QPointF(m_bounds.x1, m_bounds.y1), never executed: return QRectF(QPointF(m_bounds.x1, m_bounds.y1), QPointF(m_bounds.x2, m_bounds.y2)); | 0 |
317 | QPointF(m_bounds.x2, m_bounds.y2)); never executed: return QRectF(QPointF(m_bounds.x1, m_bounds.y1), QPointF(m_bounds.x2, m_bounds.y2)); | 0 |
318 | } | - |
319 | | - |
320 | static inline qreal coordinate(const QPointF &pos, int axis) | - |
321 | { | - |
322 | return axis == 0 ? pos.x() : pos.y(); executed: return axis == 0 ? pos.x() : pos.y(); Execution Count:1921 | 1921 |
323 | } | - |
324 | | - |
325 | TreeNode SegmentTree::buildTree(int first, int last, int depth, const RectF &bounds) | - |
326 | { | - |
327 | if (depth >= 24 || (last - first) <= 10) { evaluated: depth >= 24 yes Evaluation Count:4 | yes Evaluation Count:196 |
evaluated: (last - first) <= 10 yes Evaluation Count:131 | yes Evaluation Count:65 |
| 4-196 |
328 | TreeNode node; executed (the execution status of this line is deduced): TreeNode node; | - |
329 | node.leaf = true; executed (the execution status of this line is deduced): node.leaf = true; | - |
330 | node.index.interval.first = first; executed (the execution status of this line is deduced): node.index.interval.first = first; | - |
331 | node.index.interval.last = last; executed (the execution status of this line is deduced): node.index.interval.last = last; | - |
332 | | - |
333 | return node; executed: return node; Execution Count:135 | 135 |
334 | } | - |
335 | | - |
336 | int splitAxis = (depth & 1); executed (the execution status of this line is deduced): int splitAxis = (depth & 1); | - |
337 | | - |
338 | TreeNode node; executed (the execution status of this line is deduced): TreeNode node; | - |
339 | node.leaf = false; executed (the execution status of this line is deduced): node.leaf = false; | - |
340 | | - |
341 | qreal split = 0.5f * ((&bounds.x1)[splitAxis] + (&bounds.x2)[splitAxis]); executed (the execution status of this line is deduced): qreal split = 0.5f * ((&bounds.x1)[splitAxis] + (&bounds.x2)[splitAxis]); | - |
342 | | - |
343 | node.splitLeft = (&bounds.x1)[splitAxis]; executed (the execution status of this line is deduced): node.splitLeft = (&bounds.x1)[splitAxis]; | - |
344 | node.splitRight = (&bounds.x2)[splitAxis]; executed (the execution status of this line is deduced): node.splitRight = (&bounds.x2)[splitAxis]; | - |
345 | | - |
346 | node.lowestLeftIndex = INT_MAX; executed (the execution status of this line is deduced): node.lowestLeftIndex = 2147483647; | - |
347 | node.lowestRightIndex = INT_MAX; executed (the execution status of this line is deduced): node.lowestRightIndex = 2147483647; | - |
348 | | - |
349 | const int treeSize = m_tree.size(); executed (the execution status of this line is deduced): const int treeSize = m_tree.size(); | - |
350 | | - |
351 | node.index.children.left = treeSize; executed (the execution status of this line is deduced): node.index.children.left = treeSize; | - |
352 | node.index.children.right = treeSize + 1; executed (the execution status of this line is deduced): node.index.children.right = treeSize + 1; | - |
353 | | - |
354 | m_tree.resize(treeSize + 2); executed (the execution status of this line is deduced): m_tree.resize(treeSize + 2); | - |
355 | | - |
356 | int l = first; executed (the execution status of this line is deduced): int l = first; | - |
357 | int r = last - 1; executed (the execution status of this line is deduced): int r = last - 1; | - |
358 | | - |
359 | // partition into left and right sets | - |
360 | while (l <= r) { evaluated: l <= r yes Evaluation Count:882 | yes Evaluation Count:65 |
| 65-882 |
361 | const int index = m_index.at(l); executed (the execution status of this line is deduced): const int index = m_index.at(l); | - |
362 | const QRectF &segmentBounds = m_segments.elementBounds(index); executed (the execution status of this line is deduced): const QRectF &segmentBounds = m_segments.elementBounds(index); | - |
363 | | - |
364 | qreal lowCoordinate = coordinate(segmentBounds.topLeft(), splitAxis); executed (the execution status of this line is deduced): qreal lowCoordinate = coordinate(segmentBounds.topLeft(), splitAxis); | - |
365 | | - |
366 | if (coordinate(segmentBounds.center(), splitAxis) < split) { evaluated: coordinate(segmentBounds.center(), splitAxis) < split yes Evaluation Count:157 | yes Evaluation Count:725 |
| 157-725 |
367 | qreal highCoordinate = coordinate(segmentBounds.bottomRight(), splitAxis); executed (the execution status of this line is deduced): qreal highCoordinate = coordinate(segmentBounds.bottomRight(), splitAxis); | - |
368 | if (highCoordinate > node.splitLeft) evaluated: highCoordinate > node.splitLeft yes Evaluation Count:26 | yes Evaluation Count:131 |
| 26-131 |
369 | node.splitLeft = highCoordinate; executed: node.splitLeft = highCoordinate; Execution Count:26 | 26 |
370 | if (index < node.lowestLeftIndex) evaluated: index < node.lowestLeftIndex yes Evaluation Count:40 | yes Evaluation Count:117 |
| 40-117 |
371 | node.lowestLeftIndex = index; executed: node.lowestLeftIndex = index; Execution Count:40 | 40 |
372 | ++l; executed (the execution status of this line is deduced): ++l; | - |
373 | } else { executed: } Execution Count:157 | 157 |
374 | if (lowCoordinate < node.splitRight) evaluated: lowCoordinate < node.splitRight yes Evaluation Count:151 | yes Evaluation Count:574 |
| 151-574 |
375 | node.splitRight = lowCoordinate; executed: node.splitRight = lowCoordinate; Execution Count:151 | 151 |
376 | if (index < node.lowestRightIndex) evaluated: index < node.lowestRightIndex yes Evaluation Count:170 | yes Evaluation Count:555 |
| 170-555 |
377 | node.lowestRightIndex = index; executed: node.lowestRightIndex = index; Execution Count:170 | 170 |
378 | qSwap(m_index[l], m_index[r]); executed (the execution status of this line is deduced): qSwap(m_index[l], m_index[r]); | - |
379 | --r; executed (the execution status of this line is deduced): --r; | - |
380 | } executed: } Execution Count:725 | 725 |
381 | } | - |
382 | | - |
383 | RectF lbounds = bounds; executed (the execution status of this line is deduced): RectF lbounds = bounds; | - |
384 | (&lbounds.x2)[splitAxis] = node.splitLeft; executed (the execution status of this line is deduced): (&lbounds.x2)[splitAxis] = node.splitLeft; | - |
385 | | - |
386 | RectF rbounds = bounds; executed (the execution status of this line is deduced): RectF rbounds = bounds; | - |
387 | (&rbounds.x1)[splitAxis] = node.splitRight; executed (the execution status of this line is deduced): (&rbounds.x1)[splitAxis] = node.splitRight; | - |
388 | | - |
389 | TreeNode left = buildTree(first, l, depth + 1, lbounds); executed (the execution status of this line is deduced): TreeNode left = buildTree(first, l, depth + 1, lbounds); | - |
390 | m_tree[node.index.children.left] = left; executed (the execution status of this line is deduced): m_tree[node.index.children.left] = left; | - |
391 | | - |
392 | TreeNode right = buildTree(l, last, depth + 1, rbounds); executed (the execution status of this line is deduced): TreeNode right = buildTree(l, last, depth + 1, rbounds); | - |
393 | m_tree[node.index.children.right] = right; executed (the execution status of this line is deduced): m_tree[node.index.children.right] = right; | - |
394 | | - |
395 | return node; executed: return node; Execution Count:65 | 65 |
396 | } | - |
397 | | - |
398 | void SegmentTree::intersectLines(const QLineF &a, const QLineF &b, QDataBuffer<QIntersection> &intersections) | - |
399 | { | - |
400 | const QPointF p1 = a.p1(); executed (the execution status of this line is deduced): const QPointF p1 = a.p1(); | - |
401 | const QPointF p2 = a.p2(); executed (the execution status of this line is deduced): const QPointF p2 = a.p2(); | - |
402 | | - |
403 | const QPointF q1 = b.p1(); executed (the execution status of this line is deduced): const QPointF q1 = b.p1(); | - |
404 | const QPointF q2 = b.p2(); executed (the execution status of this line is deduced): const QPointF q2 = b.p2(); | - |
405 | | - |
406 | if (comparePoints(p1, p2) || comparePoints(q1, q2)) partially evaluated: comparePoints(p1, p2) no Evaluation Count:0 | yes Evaluation Count:862 |
partially evaluated: comparePoints(q1, q2) no Evaluation Count:0 | yes Evaluation Count:862 |
| 0-862 |
407 | return; | 0 |
408 | | - |
409 | const bool p1_equals_q1 = comparePoints(p1, q1); executed (the execution status of this line is deduced): const bool p1_equals_q1 = comparePoints(p1, q1); | - |
410 | const bool p2_equals_q2 = comparePoints(p2, q2); executed (the execution status of this line is deduced): const bool p2_equals_q2 = comparePoints(p2, q2); | - |
411 | | - |
412 | if (p1_equals_q1 && p2_equals_q2) evaluated: p1_equals_q1 yes Evaluation Count:70 | yes Evaluation Count:792 |
evaluated: p2_equals_q2 yes Evaluation Count:26 | yes Evaluation Count:44 |
| 26-792 |
413 | return; executed: return; Execution Count:26 | 26 |
414 | | - |
415 | const bool p1_equals_q2 = comparePoints(p1, q2); executed (the execution status of this line is deduced): const bool p1_equals_q2 = comparePoints(p1, q2); | - |
416 | const bool p2_equals_q1 = comparePoints(p2, q1); executed (the execution status of this line is deduced): const bool p2_equals_q1 = comparePoints(p2, q1); | - |
417 | | - |
418 | if (p1_equals_q2 && p2_equals_q1) evaluated: p1_equals_q2 yes Evaluation Count:451 | yes Evaluation Count:385 |
evaluated: p2_equals_q1 yes Evaluation Count:4 | yes Evaluation Count:447 |
| 4-451 |
419 | return; executed: return; Execution Count:4 | 4 |
420 | | - |
421 | const QPointF pDelta = p2 - p1; executed (the execution status of this line is deduced): const QPointF pDelta = p2 - p1; | - |
422 | const QPointF qDelta = q2 - q1; executed (the execution status of this line is deduced): const QPointF qDelta = q2 - q1; | - |
423 | | - |
424 | const qreal par = pDelta.x() * qDelta.y() - pDelta.y() * qDelta.x(); executed (the execution status of this line is deduced): const qreal par = pDelta.x() * qDelta.y() - pDelta.y() * qDelta.x(); | - |
425 | | - |
426 | if (qFuzzyIsNull(par)) { evaluated: qFuzzyIsNull(par) yes Evaluation Count:154 | yes Evaluation Count:678 |
| 154-678 |
427 | const QPointF normal(-pDelta.y(), pDelta.x()); executed (the execution status of this line is deduced): const QPointF normal(-pDelta.y(), pDelta.x()); | - |
428 | | - |
429 | // coinciding? | - |
430 | if (qFuzzyIsNull(dot(normal, q1 - p1))) { partially evaluated: qFuzzyIsNull(dot(normal, q1 - p1)) yes Evaluation Count:154 | no Evaluation Count:0 |
| 0-154 |
431 | const qreal invDp = 1 / dot(pDelta, pDelta); executed (the execution status of this line is deduced): const qreal invDp = 1 / dot(pDelta, pDelta); | - |
432 | | - |
433 | const qreal tq1 = dot(pDelta, q1 - p1) * invDp; executed (the execution status of this line is deduced): const qreal tq1 = dot(pDelta, q1 - p1) * invDp; | - |
434 | const qreal tq2 = dot(pDelta, q2 - p1) * invDp; executed (the execution status of this line is deduced): const qreal tq2 = dot(pDelta, q2 - p1) * invDp; | - |
435 | | - |
436 | if (tq1 > 0 && tq1 < 1) { evaluated: tq1 > 0 yes Evaluation Count:61 | yes Evaluation Count:93 |
evaluated: tq1 < 1 yes Evaluation Count:37 | yes Evaluation Count:24 |
| 24-93 |
437 | QIntersection intersection; executed (the execution status of this line is deduced): QIntersection intersection; | - |
438 | intersection.alphaA = tq1; executed (the execution status of this line is deduced): intersection.alphaA = tq1; | - |
439 | intersection.alphaB = 0; executed (the execution status of this line is deduced): intersection.alphaB = 0; | - |
440 | intersection.pos = q1; executed (the execution status of this line is deduced): intersection.pos = q1; | - |
441 | intersections.add(intersection); executed (the execution status of this line is deduced): intersections.add(intersection); | - |
442 | } executed: } Execution Count:37 | 37 |
443 | | - |
444 | if (tq2 > 0 && tq2 < 1) { evaluated: tq2 > 0 yes Evaluation Count:104 | yes Evaluation Count:50 |
evaluated: tq2 < 1 yes Evaluation Count:29 | yes Evaluation Count:75 |
| 29-104 |
445 | QIntersection intersection; executed (the execution status of this line is deduced): QIntersection intersection; | - |
446 | intersection.alphaA = tq2; executed (the execution status of this line is deduced): intersection.alphaA = tq2; | - |
447 | intersection.alphaB = 1; executed (the execution status of this line is deduced): intersection.alphaB = 1; | - |
448 | intersection.pos = q2; executed (the execution status of this line is deduced): intersection.pos = q2; | - |
449 | intersections.add(intersection); executed (the execution status of this line is deduced): intersections.add(intersection); | - |
450 | } executed: } Execution Count:29 | 29 |
451 | | - |
452 | const qreal invDq = 1 / dot(qDelta, qDelta); executed (the execution status of this line is deduced): const qreal invDq = 1 / dot(qDelta, qDelta); | - |
453 | | - |
454 | const qreal tp1 = dot(qDelta, p1 - q1) * invDq; executed (the execution status of this line is deduced): const qreal tp1 = dot(qDelta, p1 - q1) * invDq; | - |
455 | const qreal tp2 = dot(qDelta, p2 - q1) * invDq; executed (the execution status of this line is deduced): const qreal tp2 = dot(qDelta, p2 - q1) * invDq; | - |
456 | | - |
457 | if (tp1 > 0 && tp1 < 1) { evaluated: tp1 > 0 yes Evaluation Count:83 | yes Evaluation Count:71 |
evaluated: tp1 < 1 yes Evaluation Count:37 | yes Evaluation Count:46 |
| 37-83 |
458 | QIntersection intersection; executed (the execution status of this line is deduced): QIntersection intersection; | - |
459 | intersection.alphaA = 0; executed (the execution status of this line is deduced): intersection.alphaA = 0; | - |
460 | intersection.alphaB = tp1; executed (the execution status of this line is deduced): intersection.alphaB = tp1; | - |
461 | intersection.pos = p1; executed (the execution status of this line is deduced): intersection.pos = p1; | - |
462 | intersections.add(intersection); executed (the execution status of this line is deduced): intersections.add(intersection); | - |
463 | } executed: } Execution Count:37 | 37 |
464 | | - |
465 | if (tp2 > 0 && tp2 < 1) { evaluated: tp2 > 0 yes Evaluation Count:120 | yes Evaluation Count:34 |
evaluated: tp2 < 1 yes Evaluation Count:35 | yes Evaluation Count:85 |
| 34-120 |
466 | QIntersection intersection; executed (the execution status of this line is deduced): QIntersection intersection; | - |
467 | intersection.alphaA = 1; executed (the execution status of this line is deduced): intersection.alphaA = 1; | - |
468 | intersection.alphaB = tp2; executed (the execution status of this line is deduced): intersection.alphaB = tp2; | - |
469 | intersection.pos = p2; executed (the execution status of this line is deduced): intersection.pos = p2; | - |
470 | intersections.add(intersection); executed (the execution status of this line is deduced): intersections.add(intersection); | - |
471 | } executed: } Execution Count:35 | 35 |
472 | } executed: } Execution Count:154 | 154 |
473 | | - |
474 | return; executed: return; Execution Count:154 | 154 |
475 | } | - |
476 | | - |
477 | // if the lines are not parallel and share a common end point, then they | - |
478 | // don't intersect | - |
479 | if (p1_equals_q1 || p1_equals_q2 || p2_equals_q1 || p2_equals_q2) evaluated: p1_equals_q1 yes Evaluation Count:14 | yes Evaluation Count:664 |
evaluated: p1_equals_q2 yes Evaluation Count:408 | yes Evaluation Count:256 |
evaluated: p2_equals_q1 yes Evaluation Count:156 | yes Evaluation Count:100 |
evaluated: p2_equals_q2 yes Evaluation Count:14 | yes Evaluation Count:86 |
| 14-664 |
480 | return; executed: return; Execution Count:592 | 592 |
481 | | - |
482 | | - |
483 | const qreal tp = (qDelta.y() * (q1.x() - p1.x()) - executed (the execution status of this line is deduced): const qreal tp = (qDelta.y() * (q1.x() - p1.x()) - | - |
484 | qDelta.x() * (q1.y() - p1.y())) / par; executed (the execution status of this line is deduced): qDelta.x() * (q1.y() - p1.y())) / par; | - |
485 | const qreal tq = (pDelta.y() * (q1.x() - p1.x()) - executed (the execution status of this line is deduced): const qreal tq = (pDelta.y() * (q1.x() - p1.x()) - | - |
486 | pDelta.x() * (q1.y() - p1.y())) / par; executed (the execution status of this line is deduced): pDelta.x() * (q1.y() - p1.y())) / par; | - |
487 | | - |
488 | if (tp<0 || tp>1 || tq<0 || tq>1) partially evaluated: tp<0 no Evaluation Count:0 | yes Evaluation Count:86 |
partially evaluated: tp>1 no Evaluation Count:0 | yes Evaluation Count:86 |
partially evaluated: tq<0 no Evaluation Count:0 | yes Evaluation Count:86 |
partially evaluated: tq>1 no Evaluation Count:0 | yes Evaluation Count:86 |
| 0-86 |
489 | return; | 0 |
490 | | - |
491 | const bool p_zero = qFuzzyIsNull(tp); executed (the execution status of this line is deduced): const bool p_zero = qFuzzyIsNull(tp); | - |
492 | const bool p_one = qFuzzyIsNull(tp - 1); executed (the execution status of this line is deduced): const bool p_one = qFuzzyIsNull(tp - 1); | - |
493 | | - |
494 | const bool q_zero = qFuzzyIsNull(tq); executed (the execution status of this line is deduced): const bool q_zero = qFuzzyIsNull(tq); | - |
495 | const bool q_one = qFuzzyIsNull(tq - 1); executed (the execution status of this line is deduced): const bool q_one = qFuzzyIsNull(tq - 1); | - |
496 | | - |
497 | if ((q_zero || q_one) && (p_zero || p_one)) evaluated: q_zero yes Evaluation Count:13 | yes Evaluation Count:73 |
evaluated: q_one yes Evaluation Count:21 | yes Evaluation Count:52 |
partially evaluated: p_zero no Evaluation Count:0 | yes Evaluation Count:34 |
partially evaluated: p_one no Evaluation Count:0 | yes Evaluation Count:34 |
| 0-73 |
498 | return; | 0 |
499 | | - |
500 | QPointF pt; executed (the execution status of this line is deduced): QPointF pt; | - |
501 | if (p_zero) { evaluated: p_zero yes Evaluation Count:15 | yes Evaluation Count:71 |
| 15-71 |
502 | pt = p1; executed (the execution status of this line is deduced): pt = p1; | - |
503 | } else if (p_one) { executed: } Execution Count:15 evaluated: p_one yes Evaluation Count:17 | yes Evaluation Count:54 |
| 15-54 |
504 | pt = p2; executed (the execution status of this line is deduced): pt = p2; | - |
505 | } else if (q_zero) { executed: } Execution Count:17 evaluated: q_zero yes Evaluation Count:13 | yes Evaluation Count:41 |
| 13-41 |
506 | pt = q1; executed (the execution status of this line is deduced): pt = q1; | - |
507 | } else if (q_one) { executed: } Execution Count:13 evaluated: q_one yes Evaluation Count:21 | yes Evaluation Count:20 |
| 13-21 |
508 | pt = q2; executed (the execution status of this line is deduced): pt = q2; | - |
509 | } else { executed: } Execution Count:21 | 21 |
510 | pt = q1 + (q2 - q1) * tq; executed (the execution status of this line is deduced): pt = q1 + (q2 - q1) * tq; | - |
511 | } executed: } Execution Count:20 | 20 |
512 | | - |
513 | QIntersection intersection; executed (the execution status of this line is deduced): QIntersection intersection; | - |
514 | intersection.alphaA = tp; executed (the execution status of this line is deduced): intersection.alphaA = tp; | - |
515 | intersection.alphaB = tq; executed (the execution status of this line is deduced): intersection.alphaB = tq; | - |
516 | intersection.pos = pt; executed (the execution status of this line is deduced): intersection.pos = pt; | - |
517 | intersections.add(intersection); executed (the execution status of this line is deduced): intersections.add(intersection); | - |
518 | } executed: } Execution Count:86 | 86 |
519 | | - |
520 | void SegmentTree::produceIntersections(int segment) | - |
521 | { | - |
522 | const QRectF &segmentBounds = m_segments.elementBounds(segment); executed (the execution status of this line is deduced): const QRectF &segmentBounds = m_segments.elementBounds(segment); | - |
523 | | - |
524 | RectF sbounds; executed (the execution status of this line is deduced): RectF sbounds; | - |
525 | sbounds.x1 = segmentBounds.left(); executed (the execution status of this line is deduced): sbounds.x1 = segmentBounds.left(); | - |
526 | sbounds.y1 = segmentBounds.top(); executed (the execution status of this line is deduced): sbounds.y1 = segmentBounds.top(); | - |
527 | sbounds.x2 = segmentBounds.right(); executed (the execution status of this line is deduced): sbounds.x2 = segmentBounds.right(); | - |
528 | sbounds.y2 = segmentBounds.bottom(); executed (the execution status of this line is deduced): sbounds.y2 = segmentBounds.bottom(); | - |
529 | | - |
530 | produceIntersections(m_tree.at(0), segment, sbounds, m_bounds, 0); executed (the execution status of this line is deduced): produceIntersections(m_tree.at(0), segment, sbounds, m_bounds, 0); | - |
531 | } executed: } Execution Count:488 | 488 |
532 | | - |
533 | void SegmentTree::produceIntersectionsLeaf(const TreeNode &node, int segment) | - |
534 | { | - |
535 | const QRectF &r1 = m_segments.elementBounds(segment); executed (the execution status of this line is deduced): const QRectF &r1 = m_segments.elementBounds(segment); | - |
536 | const QLineF lineA = m_segments.lineAt(segment); executed (the execution status of this line is deduced): const QLineF lineA = m_segments.lineAt(segment); | - |
537 | | - |
538 | for (int i = node.index.interval.first; i < node.index.interval.last; ++i) { evaluated: i < node.index.interval.last yes Evaluation Count:4301 | yes Evaluation Count:651 |
| 651-4301 |
539 | const int other = m_index.at(i); executed (the execution status of this line is deduced): const int other = m_index.at(i); | - |
540 | if (other >= segment) evaluated: other >= segment yes Evaluation Count:2118 | yes Evaluation Count:2183 |
| 2118-2183 |
541 | continue; executed: continue; Execution Count:2118 | 2118 |
542 | | - |
543 | const QRectF &r2 = m_segments.elementBounds(other); executed (the execution status of this line is deduced): const QRectF &r2 = m_segments.elementBounds(other); | - |
544 | | - |
545 | if (r1.left() > r2.right() || r2.left() > r1.right()) evaluated: r1.left() > r2.right() yes Evaluation Count:291 | yes Evaluation Count:1892 |
evaluated: r2.left() > r1.right() yes Evaluation Count:523 | yes Evaluation Count:1369 |
| 291-1892 |
546 | continue; executed: continue; Execution Count:814 | 814 |
547 | if (r1.top() > r2.bottom() || r2.top() > r1.bottom()) evaluated: r1.top() > r2.bottom() yes Evaluation Count:265 | yes Evaluation Count:1104 |
evaluated: r2.top() > r1.bottom() yes Evaluation Count:242 | yes Evaluation Count:862 |
| 242-1104 |
548 | continue; executed: continue; Execution Count:507 | 507 |
549 | | - |
550 | m_intersections.reset(); executed (the execution status of this line is deduced): m_intersections.reset(); | - |
551 | | - |
552 | const QLineF lineB = m_segments.lineAt(other); executed (the execution status of this line is deduced): const QLineF lineB = m_segments.lineAt(other); | - |
553 | | - |
554 | intersectLines(lineA, lineB, m_intersections); executed (the execution status of this line is deduced): intersectLines(lineA, lineB, m_intersections); | - |
555 | | - |
556 | for (int k = 0; k < m_intersections.size(); ++k) { evaluated: k < m_intersections.size() yes Evaluation Count:224 | yes Evaluation Count:862 |
| 224-862 |
557 | QPathSegments::Intersection i_isect, j_isect; executed (the execution status of this line is deduced): QPathSegments::Intersection i_isect, j_isect; | - |
558 | i_isect.vertex = j_isect.vertex = m_segments.addPoint(m_intersections.at(k).pos); executed (the execution status of this line is deduced): i_isect.vertex = j_isect.vertex = m_segments.addPoint(m_intersections.at(k).pos); | - |
559 | | - |
560 | i_isect.t = m_intersections.at(k).alphaA; executed (the execution status of this line is deduced): i_isect.t = m_intersections.at(k).alphaA; | - |
561 | j_isect.t = m_intersections.at(k).alphaB; executed (the execution status of this line is deduced): j_isect.t = m_intersections.at(k).alphaB; | - |
562 | | - |
563 | i_isect.next = 0; executed (the execution status of this line is deduced): i_isect.next = 0; | - |
564 | j_isect.next = 0; executed (the execution status of this line is deduced): j_isect.next = 0; | - |
565 | | - |
566 | m_segments.addIntersection(segment, i_isect); executed (the execution status of this line is deduced): m_segments.addIntersection(segment, i_isect); | - |
567 | m_segments.addIntersection(other, j_isect); executed (the execution status of this line is deduced): m_segments.addIntersection(other, j_isect); | - |
568 | } executed: } Execution Count:224 | 224 |
569 | } executed: } Execution Count:862 | 862 |
570 | } executed: } Execution Count:651 | 651 |
571 | | - |
572 | void SegmentTree::produceIntersections(const TreeNode &node, int segment, const RectF &segmentBounds, const RectF &nodeBounds, int axis) | - |
573 | { | - |
574 | if (node.leaf) { evaluated: node.leaf yes Evaluation Count:651 | yes Evaluation Count:1670 |
| 651-1670 |
575 | produceIntersectionsLeaf(node, segment); executed (the execution status of this line is deduced): produceIntersectionsLeaf(node, segment); | - |
576 | return; executed: return; Execution Count:651 | 651 |
577 | } | - |
578 | | - |
579 | RectF lbounds = nodeBounds; executed (the execution status of this line is deduced): RectF lbounds = nodeBounds; | - |
580 | (&lbounds.x2)[axis] = node.splitLeft; executed (the execution status of this line is deduced): (&lbounds.x2)[axis] = node.splitLeft; | - |
581 | | - |
582 | RectF rbounds = nodeBounds; executed (the execution status of this line is deduced): RectF rbounds = nodeBounds; | - |
583 | (&rbounds.x1)[axis] = node.splitRight; executed (the execution status of this line is deduced): (&rbounds.x1)[axis] = node.splitRight; | - |
584 | | - |
585 | if (segment > node.lowestLeftIndex && (&segmentBounds.x1)[axis] <= node.splitLeft) evaluated: segment > node.lowestLeftIndex yes Evaluation Count:355 | yes Evaluation Count:1315 |
evaluated: (&segmentBounds.x1)[axis] <= node.splitLeft yes Evaluation Count:240 | yes Evaluation Count:115 |
| 115-1315 |
586 | produceIntersections(m_tree.at(node.index.children.left), segment, segmentBounds, lbounds, !axis); executed: produceIntersections(m_tree.at(node.index.children.left), segment, segmentBounds, lbounds, !axis); Execution Count:240 | 240 |
587 | | - |
588 | if (segment > node.lowestRightIndex && (&segmentBounds.x2)[axis] >= node.splitRight) evaluated: segment > node.lowestRightIndex yes Evaluation Count:1608 | yes Evaluation Count:62 |
evaluated: (&segmentBounds.x2)[axis] >= node.splitRight yes Evaluation Count:1593 | yes Evaluation Count:15 |
| 15-1608 |
589 | produceIntersections(m_tree.at(node.index.children.right), segment, segmentBounds, rbounds, !axis); executed: produceIntersections(m_tree.at(node.index.children.right), segment, segmentBounds, rbounds, !axis); Execution Count:1593 | 1593 |
590 | } executed: } Execution Count:1670 | 1670 |
591 | | - |
592 | } | - |
593 | | - |
594 | void QIntersectionFinder::produceIntersections(QPathSegments &segments) | - |
595 | { | - |
596 | SegmentTree tree(segments); executed (the execution status of this line is deduced): SegmentTree tree(segments); | - |
597 | | - |
598 | for (int i = 0; i < segments.segments(); ++i) evaluated: i < segments.segments() yes Evaluation Count:488 | yes Evaluation Count:70 |
| 70-488 |
599 | tree.produceIntersections(i); executed: tree.produceIntersections(i); Execution Count:488 | 488 |
600 | } executed: } Execution Count:70 | 70 |
601 | | - |
602 | class QKdPointTree | - |
603 | { | - |
604 | public: | - |
605 | enum Traversal { | - |
606 | TraverseBoth, | - |
607 | TraverseLeft, | - |
608 | TraverseRight, | - |
609 | TraverseNone | - |
610 | }; | - |
611 | | - |
612 | struct Node { | - |
613 | int point; | - |
614 | int id; | - |
615 | | - |
616 | Node *left; | - |
617 | Node *right; | - |
618 | }; | - |
619 | | - |
620 | QKdPointTree(const QPathSegments &segments) | - |
621 | : m_segments(&segments) | - |
622 | , m_nodes(m_segments->points()) | - |
623 | , m_id(0) | - |
624 | { | - |
625 | m_nodes.resize(m_segments->points()); executed (the execution status of this line is deduced): m_nodes.resize(m_segments->points()); | - |
626 | | - |
627 | for (int i = 0; i < m_nodes.size(); ++i) { evaluated: i < m_nodes.size() yes Evaluation Count:712 | yes Evaluation Count:70 |
| 70-712 |
628 | m_nodes.at(i).point = i; executed (the execution status of this line is deduced): m_nodes.at(i).point = i; | - |
629 | m_nodes.at(i).id = -1; executed (the execution status of this line is deduced): m_nodes.at(i).id = -1; | - |
630 | } executed: } Execution Count:712 | 712 |
631 | | - |
632 | m_rootNode = build(0, m_nodes.size()); executed (the execution status of this line is deduced): m_rootNode = build(0, m_nodes.size()); | - |
633 | } executed: } Execution Count:70 | 70 |
634 | | - |
635 | int build(int begin, int end, int depth = 0); | - |
636 | | - |
637 | Node *rootNode() | - |
638 | { | - |
639 | return &m_nodes.at(m_rootNode); executed: return &m_nodes.at(m_rootNode); Execution Count:782 | 782 |
640 | } | - |
641 | | - |
642 | inline int nextId() | - |
643 | { | - |
644 | return m_id++; executed: return m_id++; Execution Count:430 | 430 |
645 | } | - |
646 | | - |
647 | private: | - |
648 | const QPathSegments *m_segments; | - |
649 | QDataBuffer<Node> m_nodes; | - |
650 | | - |
651 | int m_rootNode; | - |
652 | int m_id; | - |
653 | }; | - |
654 | | - |
655 | template <typename T> | - |
656 | void qTraverseKdPointTree(QKdPointTree::Node &node, T &t, int depth = 0) | - |
657 | { | - |
658 | QKdPointTree::Traversal status = t(node, depth); executed (the execution status of this line is deduced): QKdPointTree::Traversal status = t(node, depth); | - |
659 | | - |
660 | const bool traverseRight = (status == QKdPointTree::TraverseBoth || status == QKdPointTree::TraverseRight); evaluated: status == QKdPointTree::TraverseBoth yes Evaluation Count:837 | yes Evaluation Count:3366 |
evaluated: status == QKdPointTree::TraverseRight yes Evaluation Count:1833 | yes Evaluation Count:1533 |
| 837-3366 |
661 | const bool traverseLeft = (status == QKdPointTree::TraverseBoth || status == QKdPointTree::TraverseLeft); evaluated: status == QKdPointTree::TraverseBoth yes Evaluation Count:837 | yes Evaluation Count:3366 |
evaluated: status == QKdPointTree::TraverseLeft yes Evaluation Count:821 | yes Evaluation Count:2545 |
| 821-3366 |
662 | | - |
663 | if (traverseLeft && node.left) evaluated: traverseLeft yes Evaluation Count:1658 | yes Evaluation Count:2545 |
evaluated: node.left yes Evaluation Count:1083 | yes Evaluation Count:575 |
| 575-2545 |
664 | QT_PREPEND_NAMESPACE(qTraverseKdPointTree<T>)(*node.left, t, depth + 1); executed: ::qTraverseKdPointTree<T>(*node.left, t, depth + 1); Execution Count:1083 | 1083 |
665 | | - |
666 | if (traverseRight && node.right) evaluated: traverseRight yes Evaluation Count:2670 | yes Evaluation Count:1533 |
evaluated: node.right yes Evaluation Count:2408 | yes Evaluation Count:262 |
| 262-2670 |
667 | QT_PREPEND_NAMESPACE(qTraverseKdPointTree<T>)(*node.right, t, depth + 1); executed: ::qTraverseKdPointTree<T>(*node.right, t, depth + 1); Execution Count:2408 | 2408 |
668 | } executed: } Execution Count:4203 | 4203 |
669 | | - |
670 | static inline qreal component(const QPointF &point, unsigned int i) | - |
671 | { | - |
672 | Q_ASSERT(i < 2); executed (the execution status of this line is deduced): qt_noop(); | - |
673 | const qreal components[] = { point.x(), point.y() }; executed (the execution status of this line is deduced): const qreal components[] = { point.x(), point.y() }; | - |
674 | return components[i]; executed: return components[i]; Execution Count:3658 | 3658 |
675 | } | - |
676 | | - |
677 | int QKdPointTree::build(int begin, int end, int depth) | - |
678 | { | - |
679 | Q_ASSERT(end > begin); executed (the execution status of this line is deduced): qt_noop(); | - |
680 | | - |
681 | const qreal pivot = component(m_segments->pointAt(m_nodes.at(begin).point), depth & 1); executed (the execution status of this line is deduced): const qreal pivot = component(m_segments->pointAt(m_nodes.at(begin).point), depth & 1); | - |
682 | | - |
683 | int first = begin + 1; executed (the execution status of this line is deduced): int first = begin + 1; | - |
684 | int last = end - 1; executed (the execution status of this line is deduced): int last = end - 1; | - |
685 | | - |
686 | while (first <= last) { evaluated: first <= last yes Evaluation Count:2946 | yes Evaluation Count:712 |
| 712-2946 |
687 | const qreal value = component(m_segments->pointAt(m_nodes.at(first).point), depth & 1); executed (the execution status of this line is deduced): const qreal value = component(m_segments->pointAt(m_nodes.at(first).point), depth & 1); | - |
688 | | - |
689 | if (value < pivot) evaluated: value < pivot yes Evaluation Count:722 | yes Evaluation Count:2224 |
| 722-2224 |
690 | ++first; executed: ++first; Execution Count:722 | 722 |
691 | else { | - |
692 | qSwap(m_nodes.at(first), m_nodes.at(last)); executed (the execution status of this line is deduced): qSwap(m_nodes.at(first), m_nodes.at(last)); | - |
693 | --last; executed (the execution status of this line is deduced): --last; | - |
694 | } executed: } Execution Count:2224 | 2224 |
695 | } | - |
696 | | - |
697 | qSwap(m_nodes.at(last), m_nodes.at(begin)); executed (the execution status of this line is deduced): qSwap(m_nodes.at(last), m_nodes.at(begin)); | - |
698 | | - |
699 | if (last > begin) evaluated: last > begin yes Evaluation Count:184 | yes Evaluation Count:528 |
| 184-528 |
700 | m_nodes.at(last).left = &m_nodes.at(build(begin, last, depth + 1)); executed: m_nodes.at(last).left = &m_nodes.at(build(begin, last, depth + 1)); Execution Count:184 | 184 |
701 | else | - |
702 | m_nodes.at(last).left = 0; executed: m_nodes.at(last).left = 0; Execution Count:528 | 528 |
703 | | - |
704 | if (last + 1 < end) evaluated: last + 1 < end yes Evaluation Count:458 | yes Evaluation Count:254 |
| 254-458 |
705 | m_nodes.at(last).right = &m_nodes.at(build(last + 1, end, depth + 1)); executed: m_nodes.at(last).right = &m_nodes.at(build(last + 1, end, depth + 1)); Execution Count:458 | 458 |
706 | else | - |
707 | m_nodes.at(last).right = 0; executed: m_nodes.at(last).right = 0; Execution Count:254 | 254 |
708 | | - |
709 | return last; executed: return last; Execution Count:712 | 712 |
710 | } | - |
711 | | - |
712 | class QKdPointFinder | - |
713 | { | - |
714 | public: | - |
715 | QKdPointFinder(int point, const QPathSegments &segments, QKdPointTree &tree) | - |
716 | : m_point(point) | - |
717 | , m_result(-1) | - |
718 | , m_segments(&segments) | - |
719 | , m_tree(&tree) | - |
720 | { | - |
721 | pointComponents[0] = segments.pointAt(point).x(); executed (the execution status of this line is deduced): pointComponents[0] = segments.pointAt(point).x(); | - |
722 | pointComponents[1] = segments.pointAt(point).y(); executed (the execution status of this line is deduced): pointComponents[1] = segments.pointAt(point).y(); | - |
723 | } executed: } Execution Count:712 | 712 |
724 | | - |
725 | inline QKdPointTree::Traversal operator()(QKdPointTree::Node &node, int depth) | - |
726 | { | - |
727 | if (m_result != -1) partially evaluated: m_result != -1 no Evaluation Count:0 | yes Evaluation Count:4203 |
| 0-4203 |
728 | return QKdPointTree::TraverseNone; never executed: return QKdPointTree::TraverseNone; | 0 |
729 | | - |
730 | const QPointF &nodePoint = m_segments->pointAt(node.point); executed (the execution status of this line is deduced): const QPointF &nodePoint = m_segments->pointAt(node.point); | - |
731 | | - |
732 | const qreal pivotComponents[] = { nodePoint.x(), nodePoint.y() }; executed (the execution status of this line is deduced): const qreal pivotComponents[] = { nodePoint.x(), nodePoint.y() }; | - |
733 | | - |
734 | const qreal pivot = pivotComponents[depth & 1]; executed (the execution status of this line is deduced): const qreal pivot = pivotComponents[depth & 1]; | - |
735 | const qreal value = pointComponents[depth & 1]; executed (the execution status of this line is deduced): const qreal value = pointComponents[depth & 1]; | - |
736 | | - |
737 | if (fuzzyIsNull(pivot - value)) { evaluated: fuzzyIsNull(pivot - value) yes Evaluation Count:1549 | yes Evaluation Count:2654 |
| 1549-2654 |
738 | const qreal pivot2 = pivotComponents[(depth + 1) & 1]; executed (the execution status of this line is deduced): const qreal pivot2 = pivotComponents[(depth + 1) & 1]; | - |
739 | const qreal value2 = pointComponents[(depth + 1) & 1]; executed (the execution status of this line is deduced): const qreal value2 = pointComponents[(depth + 1) & 1]; | - |
740 | | - |
741 | if (fuzzyIsNull(pivot2 - value2)) { evaluated: fuzzyIsNull(pivot2 - value2) yes Evaluation Count:712 | yes Evaluation Count:837 |
| 712-837 |
742 | if (node.id < 0) evaluated: node.id < 0 yes Evaluation Count:430 | yes Evaluation Count:282 |
| 282-430 |
743 | node.id = m_tree->nextId(); executed: node.id = m_tree->nextId(); Execution Count:430 | 430 |
744 | | - |
745 | m_result = node.id; executed (the execution status of this line is deduced): m_result = node.id; | - |
746 | return QKdPointTree::TraverseNone; executed: return QKdPointTree::TraverseNone; Execution Count:712 | 712 |
747 | } else | - |
748 | return QKdPointTree::TraverseBoth; executed: return QKdPointTree::TraverseBoth; Execution Count:837 | 837 |
749 | } else if (value < pivot) { evaluated: value < pivot yes Evaluation Count:821 | yes Evaluation Count:1833 |
| 821-1833 |
750 | return QKdPointTree::TraverseLeft; executed: return QKdPointTree::TraverseLeft; Execution Count:821 | 821 |
751 | } else { | - |
752 | return QKdPointTree::TraverseRight; executed: return QKdPointTree::TraverseRight; Execution Count:1833 | 1833 |
753 | } | - |
754 | } | - |
755 | | - |
756 | int result() const | - |
757 | { | - |
758 | return m_result; executed: return m_result; Execution Count:1424 | 1424 |
759 | } | - |
760 | | - |
761 | private: | - |
762 | int m_point; | - |
763 | qreal pointComponents[2]; | - |
764 | int m_result; | - |
765 | const QPathSegments *m_segments; | - |
766 | QKdPointTree *m_tree; | - |
767 | }; | - |
768 | | - |
769 | // merge all points that are within qFuzzyCompare range of each other | - |
770 | void QPathSegments::mergePoints() | - |
771 | { | - |
772 | QKdPointTree tree(*this); executed (the execution status of this line is deduced): QKdPointTree tree(*this); | - |
773 | | - |
774 | if (tree.rootNode()) { partially evaluated: tree.rootNode() yes Evaluation Count:70 | no Evaluation Count:0 |
| 0-70 |
775 | QDataBuffer<QPointF> mergedPoints(points()); executed (the execution status of this line is deduced): QDataBuffer<QPointF> mergedPoints(points()); | - |
776 | QDataBuffer<int> pointIndices(points()); executed (the execution status of this line is deduced): QDataBuffer<int> pointIndices(points()); | - |
777 | | - |
778 | for (int i = 0; i < points(); ++i) { evaluated: i < points() yes Evaluation Count:712 | yes Evaluation Count:70 |
| 70-712 |
779 | QKdPointFinder finder(i, *this, tree); executed (the execution status of this line is deduced): QKdPointFinder finder(i, *this, tree); | - |
780 | QT_PREPEND_NAMESPACE(qTraverseKdPointTree<QKdPointFinder>)(*tree.rootNode(), finder); executed (the execution status of this line is deduced): ::qTraverseKdPointTree<QKdPointFinder>(*tree.rootNode(), finder); | - |
781 | | - |
782 | Q_ASSERT(finder.result() != -1); executed (the execution status of this line is deduced): qt_noop(); | - |
783 | | - |
784 | if (finder.result() >= mergedPoints.size()) evaluated: finder.result() >= mergedPoints.size() yes Evaluation Count:430 | yes Evaluation Count:282 |
| 282-430 |
785 | mergedPoints << m_points.at(i); executed: mergedPoints << m_points.at(i); Execution Count:430 | 430 |
786 | | - |
787 | pointIndices << finder.result(); executed (the execution status of this line is deduced): pointIndices << finder.result(); | - |
788 | } executed: } Execution Count:712 | 712 |
789 | | - |
790 | for (int i = 0; i < m_segments.size(); ++i) { evaluated: i < m_segments.size() yes Evaluation Count:488 | yes Evaluation Count:70 |
| 70-488 |
791 | m_segments.at(i).va = pointIndices.at(m_segments.at(i).va); executed (the execution status of this line is deduced): m_segments.at(i).va = pointIndices.at(m_segments.at(i).va); | - |
792 | m_segments.at(i).vb = pointIndices.at(m_segments.at(i).vb); executed (the execution status of this line is deduced): m_segments.at(i).vb = pointIndices.at(m_segments.at(i).vb); | - |
793 | } executed: } Execution Count:488 | 488 |
794 | | - |
795 | for (int i = 0; i < m_intersections.size(); ++i) evaluated: i < m_intersections.size() yes Evaluation Count:448 | yes Evaluation Count:70 |
| 70-448 |
796 | m_intersections.at(i).vertex = pointIndices.at(m_intersections.at(i).vertex); executed: m_intersections.at(i).vertex = pointIndices.at(m_intersections.at(i).vertex); Execution Count:448 | 448 |
797 | | - |
798 | m_points.swap(mergedPoints); executed (the execution status of this line is deduced): m_points.swap(mergedPoints); | - |
799 | } executed: } Execution Count:70 | 70 |
800 | } executed: } Execution Count:70 | 70 |
801 | | - |
802 | void QWingedEdge::intersectAndAdd() | - |
803 | { | - |
804 | QIntersectionFinder finder; executed (the execution status of this line is deduced): QIntersectionFinder finder; | - |
805 | finder.produceIntersections(m_segments); executed (the execution status of this line is deduced): finder.produceIntersections(m_segments); | - |
806 | | - |
807 | m_segments.mergePoints(); executed (the execution status of this line is deduced): m_segments.mergePoints(); | - |
808 | | - |
809 | for (int i = 0; i < m_segments.points(); ++i) evaluated: i < m_segments.points() yes Evaluation Count:430 | yes Evaluation Count:70 |
| 70-430 |
810 | addVertex(m_segments.pointAt(i)); executed: addVertex(m_segments.pointAt(i)); Execution Count:430 | 430 |
811 | | - |
812 | QDataBuffer<QPathSegments::Intersection> intersections(m_segments.segments()); executed (the execution status of this line is deduced): QDataBuffer<QPathSegments::Intersection> intersections(m_segments.segments()); | - |
813 | for (int i = 0; i < m_segments.segments(); ++i) { evaluated: i < m_segments.segments() yes Evaluation Count:488 | yes Evaluation Count:70 |
| 70-488 |
814 | intersections.reset(); executed (the execution status of this line is deduced): intersections.reset(); | - |
815 | | - |
816 | int pathId = m_segments.pathId(i); executed (the execution status of this line is deduced): int pathId = m_segments.pathId(i); | - |
817 | | - |
818 | const QPathSegments::Intersection *isect = m_segments.intersectionAt(i); executed (the execution status of this line is deduced): const QPathSegments::Intersection *isect = m_segments.intersectionAt(i); | - |
819 | while (isect) { evaluated: isect yes Evaluation Count:448 | yes Evaluation Count:488 |
| 448-488 |
820 | intersections << *isect; executed (the execution status of this line is deduced): intersections << *isect; | - |
821 | | - |
822 | if (isect->next) { evaluated: isect->next yes Evaluation Count:258 | yes Evaluation Count:190 |
| 190-258 |
823 | isect += isect->next; executed (the execution status of this line is deduced): isect += isect->next; | - |
824 | } else { executed: } Execution Count:258 | 258 |
825 | isect = 0; executed (the execution status of this line is deduced): isect = 0; | - |
826 | } executed: } Execution Count:190 | 190 |
827 | } | - |
828 | | - |
829 | qSort(intersections.data(), intersections.data() + intersections.size()); executed (the execution status of this line is deduced): qSort(intersections.data(), intersections.data() + intersections.size()); | - |
830 | | - |
831 | int first = m_segments.segmentAt(i).va; executed (the execution status of this line is deduced): int first = m_segments.segmentAt(i).va; | - |
832 | int second = m_segments.segmentAt(i).vb; executed (the execution status of this line is deduced): int second = m_segments.segmentAt(i).vb; | - |
833 | | - |
834 | int last = first; executed (the execution status of this line is deduced): int last = first; | - |
835 | for (int j = 0; j < intersections.size(); ++j) { evaluated: j < intersections.size() yes Evaluation Count:448 | yes Evaluation Count:488 |
| 448-488 |
836 | const QPathSegments::Intersection &isect = intersections.at(j); executed (the execution status of this line is deduced): const QPathSegments::Intersection &isect = intersections.at(j); | - |
837 | | - |
838 | QPathEdge *ep = edge(addEdge(last, isect.vertex)); executed (the execution status of this line is deduced): QPathEdge *ep = edge(addEdge(last, isect.vertex)); | - |
839 | | - |
840 | if (ep) { evaluated: ep yes Evaluation Count:200 | yes Evaluation Count:248 |
| 200-248 |
841 | const int dir = m_segments.pointAt(last).y() < m_segments.pointAt(isect.vertex).y() ? 1 : -1; evaluated: m_segments.pointAt(last).y() < m_segments.pointAt(isect.vertex).y() yes Evaluation Count:39 | yes Evaluation Count:161 |
| 39-161 |
842 | if (pathId == 0) evaluated: pathId == 0 yes Evaluation Count:108 | yes Evaluation Count:92 |
| 92-108 |
843 | ep->windingA += dir; executed: ep->windingA += dir; Execution Count:108 | 108 |
844 | else | - |
845 | ep->windingB += dir; executed: ep->windingB += dir; Execution Count:92 | 92 |
846 | } | - |
847 | | - |
848 | last = isect.vertex; executed (the execution status of this line is deduced): last = isect.vertex; | - |
849 | } executed: } Execution Count:448 | 448 |
850 | | - |
851 | QPathEdge *ep = edge(addEdge(last, second)); executed (the execution status of this line is deduced): QPathEdge *ep = edge(addEdge(last, second)); | - |
852 | | - |
853 | if (ep) { evaluated: ep yes Evaluation Count:398 | yes Evaluation Count:90 |
| 90-398 |
854 | const int dir = m_segments.pointAt(last).y() < m_segments.pointAt(second).y() ? 1 : -1; evaluated: m_segments.pointAt(last).y() < m_segments.pointAt(second).y() yes Evaluation Count:94 | yes Evaluation Count:304 |
| 94-304 |
855 | if (pathId == 0) evaluated: pathId == 0 yes Evaluation Count:310 | yes Evaluation Count:88 |
| 88-310 |
856 | ep->windingA += dir; executed: ep->windingA += dir; Execution Count:310 | 310 |
857 | else | - |
858 | ep->windingB += dir; executed: ep->windingB += dir; Execution Count:88 | 88 |
859 | } | - |
860 | } executed: } Execution Count:488 | 488 |
861 | } executed: } Execution Count:70 | 70 |
862 | | - |
863 | QWingedEdge::QWingedEdge() : | - |
864 | m_edges(0), | - |
865 | m_vertices(0), | - |
866 | m_segments(0) | - |
867 | { | - |
868 | } | 0 |
869 | | - |
870 | QWingedEdge::QWingedEdge(const QPainterPath &subject, const QPainterPath &clip) : | - |
871 | m_edges(subject.elementCount()), | - |
872 | m_vertices(subject.elementCount()), | - |
873 | m_segments(subject.elementCount()) | - |
874 | { | - |
875 | m_segments.setPath(subject); executed (the execution status of this line is deduced): m_segments.setPath(subject); | - |
876 | m_segments.addPath(clip); executed (the execution status of this line is deduced): m_segments.addPath(clip); | - |
877 | | - |
878 | intersectAndAdd(); executed (the execution status of this line is deduced): intersectAndAdd(); | - |
879 | } executed: } Execution Count:70 | 70 |
880 | | - |
881 | QWingedEdge::TraversalStatus QWingedEdge::next(const QWingedEdge::TraversalStatus &status) const | - |
882 | { | - |
883 | const QPathEdge *sp = edge(status.edge); executed (the execution status of this line is deduced): const QPathEdge *sp = edge(status.edge); | - |
884 | Q_ASSERT(sp); executed (the execution status of this line is deduced): qt_noop(); | - |
885 | | - |
886 | TraversalStatus result; executed (the execution status of this line is deduced): TraversalStatus result; | - |
887 | result.edge = sp->next(status.traversal, status.direction); executed (the execution status of this line is deduced): result.edge = sp->next(status.traversal, status.direction); | - |
888 | result.traversal = status.traversal; executed (the execution status of this line is deduced): result.traversal = status.traversal; | - |
889 | result.direction = status.direction; executed (the execution status of this line is deduced): result.direction = status.direction; | - |
890 | | - |
891 | const QPathEdge *rp = edge(result.edge); executed (the execution status of this line is deduced): const QPathEdge *rp = edge(result.edge); | - |
892 | Q_ASSERT(rp); executed (the execution status of this line is deduced): qt_noop(); | - |
893 | | - |
894 | if (sp->vertex(status.direction) == rp->vertex(status.direction)) evaluated: sp->vertex(status.direction) == rp->vertex(status.direction) yes Evaluation Count:1182 | yes Evaluation Count:2457 |
| 1182-2457 |
895 | result.flip(); executed: result.flip(); Execution Count:1182 | 1182 |
896 | | - |
897 | return result; executed: return result; Execution Count:3639 | 3639 |
898 | } | - |
899 | | - |
900 | static bool isLine(const QBezier &bezier) | - |
901 | { | - |
902 | const bool equal_1_2 = comparePoints(bezier.pt1(), bezier.pt2()); executed (the execution status of this line is deduced): const bool equal_1_2 = comparePoints(bezier.pt1(), bezier.pt2()); | - |
903 | const bool equal_2_3 = comparePoints(bezier.pt2(), bezier.pt3()); executed (the execution status of this line is deduced): const bool equal_2_3 = comparePoints(bezier.pt2(), bezier.pt3()); | - |
904 | const bool equal_3_4 = comparePoints(bezier.pt3(), bezier.pt4()); executed (the execution status of this line is deduced): const bool equal_3_4 = comparePoints(bezier.pt3(), bezier.pt4()); | - |
905 | | - |
906 | // point? | - |
907 | if (equal_1_2 && equal_2_3 && equal_3_4) partially evaluated: equal_1_2 no Evaluation Count:0 | yes Evaluation Count:700 |
never evaluated: equal_2_3 never evaluated: equal_3_4 | 0-700 |
908 | return true; never executed: return true; | 0 |
909 | | - |
910 | if (comparePoints(bezier.pt1(), bezier.pt4())) partially evaluated: comparePoints(bezier.pt1(), bezier.pt4()) no Evaluation Count:0 | yes Evaluation Count:700 |
| 0-700 |
911 | return equal_1_2 || equal_3_4; never executed: return equal_1_2 || equal_3_4; | 0 |
912 | | - |
913 | return (equal_1_2 && equal_3_4) || (equal_1_2 && equal_2_3) || (equal_2_3 && equal_3_4); executed: return (equal_1_2 && equal_3_4) || (equal_1_2 && equal_2_3) || (equal_2_3 && equal_3_4); Execution Count:700 | 700 |
914 | } | - |
915 | | - |
916 | void QPathSegments::setPath(const QPainterPath &path) | - |
917 | { | - |
918 | m_points.reset(); executed (the execution status of this line is deduced): m_points.reset(); | - |
919 | m_intersections.reset(); executed (the execution status of this line is deduced): m_intersections.reset(); | - |
920 | m_segments.reset(); executed (the execution status of this line is deduced): m_segments.reset(); | - |
921 | | - |
922 | m_pathId = 0; executed (the execution status of this line is deduced): m_pathId = 0; | - |
923 | | - |
924 | addPath(path); executed (the execution status of this line is deduced): addPath(path); | - |
925 | } executed: } Execution Count:312 | 312 |
926 | | - |
927 | void QPathSegments::addPath(const QPainterPath &path) | - |
928 | { | - |
929 | int firstSegment = m_segments.size(); executed (the execution status of this line is deduced): int firstSegment = m_segments.size(); | - |
930 | | - |
931 | bool hasMoveTo = false; executed (the execution status of this line is deduced): bool hasMoveTo = false; | - |
932 | int lastMoveTo = 0; executed (the execution status of this line is deduced): int lastMoveTo = 0; | - |
933 | int last = 0; executed (the execution status of this line is deduced): int last = 0; | - |
934 | for (int i = 0; i < path.elementCount(); ++i) { evaluated: i < path.elementCount() yes Evaluation Count:3272 | yes Evaluation Count:382 |
| 382-3272 |
935 | int current = m_points.size(); executed (the execution status of this line is deduced): int current = m_points.size(); | - |
936 | | - |
937 | QPointF currentPoint; executed (the execution status of this line is deduced): QPointF currentPoint; | - |
938 | if (path.elementAt(i).type == QPainterPath::CurveToElement) evaluated: path.elementAt(i).type == QPainterPath::CurveToElement yes Evaluation Count:700 | yes Evaluation Count:2572 |
| 700-2572 |
939 | currentPoint = path.elementAt(i+2); executed: currentPoint = path.elementAt(i+2); Execution Count:700 | 700 |
940 | else | - |
941 | currentPoint = path.elementAt(i); executed: currentPoint = path.elementAt(i); Execution Count:2572 | 2572 |
942 | | - |
943 | if (i > 0 && comparePoints(m_points.at(lastMoveTo), currentPoint)) evaluated: i > 0 yes Evaluation Count:2944 | yes Evaluation Count:328 |
evaluated: comparePoints(m_points.at(lastMoveTo), currentPoint) yes Evaluation Count:468 | yes Evaluation Count:2476 |
| 328-2944 |
944 | current = lastMoveTo; executed: current = lastMoveTo; Execution Count:468 | 468 |
945 | else | - |
946 | m_points << currentPoint; executed: m_points << currentPoint; Execution Count:2804 | 2804 |
947 | | - |
948 | switch (path.elementAt(i).type) { | - |
949 | case QPainterPath::MoveToElement: | - |
950 | if (hasMoveTo && last != lastMoveTo && !comparePoints(m_points.at(last), m_points.at(lastMoveTo))) evaluated: hasMoveTo yes Evaluation Count:197 | yes Evaluation Count:328 |
evaluated: last != lastMoveTo yes Evaluation Count:2 | yes Evaluation Count:195 |
partially evaluated: !comparePoints(m_points.at(last), m_points.at(lastMoveTo)) yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-328 |
951 | m_segments << Segment(m_pathId, last, lastMoveTo); executed: m_segments << Segment(m_pathId, last, lastMoveTo); Execution Count:2 | 2 |
952 | hasMoveTo = true; executed (the execution status of this line is deduced): hasMoveTo = true; | - |
953 | last = lastMoveTo = current; executed (the execution status of this line is deduced): last = lastMoveTo = current; | - |
954 | break; executed: break; Execution Count:525 | 525 |
955 | case QPainterPath::LineToElement: | - |
956 | m_segments << Segment(m_pathId, last, current); executed (the execution status of this line is deduced): m_segments << Segment(m_pathId, last, current); | - |
957 | last = current; executed (the execution status of this line is deduced): last = current; | - |
958 | break; executed: break; Execution Count:2047 | 2047 |
959 | case QPainterPath::CurveToElement: | - |
960 | { | - |
961 | QBezier bezier = QBezier::fromPoints(m_points.at(last), path.elementAt(i), path.elementAt(i+1), path.elementAt(i+2)); executed (the execution status of this line is deduced): QBezier bezier = QBezier::fromPoints(m_points.at(last), path.elementAt(i), path.elementAt(i+1), path.elementAt(i+2)); | - |
962 | if (isLine(bezier)) { partially evaluated: isLine(bezier) no Evaluation Count:0 | yes Evaluation Count:700 |
| 0-700 |
963 | m_segments << Segment(m_pathId, last, current); never executed (the execution status of this line is deduced): m_segments << Segment(m_pathId, last, current); | - |
964 | } else { | 0 |
965 | QRectF bounds = bezier.bounds(); executed (the execution status of this line is deduced): QRectF bounds = bezier.bounds(); | - |
966 | | - |
967 | // threshold based on similar algorithm as in qtriangulatingstroker.cpp | - |
968 | int threshold = qMin<float>(64, qMax(bounds.width(), bounds.height()) * (2 * qreal(3.14) / 6)); executed (the execution status of this line is deduced): int threshold = qMin<float>(64, qMax(bounds.width(), bounds.height()) * (2 * qreal(3.14) / 6)); | - |
969 | | - |
970 | if (threshold < 3) threshold = 3; executed: threshold = 3; Execution Count:80 evaluated: threshold < 3 yes Evaluation Count:80 | yes Evaluation Count:620 |
| 80-620 |
971 | qreal one_over_threshold_minus_1 = qreal(1) / (threshold - 1); executed (the execution status of this line is deduced): qreal one_over_threshold_minus_1 = qreal(1) / (threshold - 1); | - |
972 | | - |
973 | for (int t = 1; t < threshold - 1; ++t) { evaluated: t < threshold - 1 yes Evaluation Count:16720 | yes Evaluation Count:700 |
| 700-16720 |
974 | currentPoint = bezier.pointAt(t * one_over_threshold_minus_1); executed (the execution status of this line is deduced): currentPoint = bezier.pointAt(t * one_over_threshold_minus_1); | - |
975 | | - |
976 | int index = m_points.size(); executed (the execution status of this line is deduced): int index = m_points.size(); | - |
977 | m_segments << Segment(m_pathId, last, index); executed (the execution status of this line is deduced): m_segments << Segment(m_pathId, last, index); | - |
978 | last = index; executed (the execution status of this line is deduced): last = index; | - |
979 | | - |
980 | m_points << currentPoint; executed (the execution status of this line is deduced): m_points << currentPoint; | - |
981 | } executed: } Execution Count:16720 | 16720 |
982 | | - |
983 | m_segments << Segment(m_pathId, last, current); executed (the execution status of this line is deduced): m_segments << Segment(m_pathId, last, current); | - |
984 | } executed: } Execution Count:700 | 700 |
985 | } | - |
986 | last = current; executed (the execution status of this line is deduced): last = current; | - |
987 | i += 2; executed (the execution status of this line is deduced): i += 2; | - |
988 | break; executed: break; Execution Count:700 | 700 |
989 | default: | - |
990 | Q_ASSERT(false); never executed (the execution status of this line is deduced): qt_noop(); | - |
991 | break; | 0 |
992 | } | - |
993 | } executed: } Execution Count:3272 | 3272 |
994 | | - |
995 | if (hasMoveTo && last != lastMoveTo && !comparePoints(m_points.at(last), m_points.at(lastMoveTo))) evaluated: hasMoveTo yes Evaluation Count:328 | yes Evaluation Count:54 |
evaluated: last != lastMoveTo yes Evaluation Count:55 | yes Evaluation Count:273 |
partially evaluated: !comparePoints(m_points.at(last), m_points.at(lastMoveTo)) yes Evaluation Count:55 | no Evaluation Count:0 |
| 0-328 |
996 | m_segments << Segment(m_pathId, last, lastMoveTo); executed: m_segments << Segment(m_pathId, last, lastMoveTo); Execution Count:55 | 55 |
997 | | - |
998 | for (int i = firstSegment; i < m_segments.size(); ++i) { evaluated: i < m_segments.size() yes Evaluation Count:19524 | yes Evaluation Count:382 |
| 382-19524 |
999 | const QLineF line = lineAt(i); executed (the execution status of this line is deduced): const QLineF line = lineAt(i); | - |
1000 | | - |
1001 | qreal x1 = line.p1().x(); executed (the execution status of this line is deduced): qreal x1 = line.p1().x(); | - |
1002 | qreal y1 = line.p1().y(); executed (the execution status of this line is deduced): qreal y1 = line.p1().y(); | - |
1003 | qreal x2 = line.p2().x(); executed (the execution status of this line is deduced): qreal x2 = line.p2().x(); | - |
1004 | qreal y2 = line.p2().y(); executed (the execution status of this line is deduced): qreal y2 = line.p2().y(); | - |
1005 | | - |
1006 | if (x2 < x1) evaluated: x2 < x1 yes Evaluation Count:9308 | yes Evaluation Count:10216 |
| 9308-10216 |
1007 | qSwap(x1, x2); executed: qSwap(x1, x2); Execution Count:9308 | 9308 |
1008 | if (y2 < y1) evaluated: y2 < y1 yes Evaluation Count:9298 | yes Evaluation Count:10226 |
| 9298-10226 |
1009 | qSwap(y1, y2); executed: qSwap(y1, y2); Execution Count:9298 | 9298 |
1010 | | - |
1011 | m_segments.at(i).bounds = QRectF(x1, y1, x2 - x1, y2 - y1); executed (the execution status of this line is deduced): m_segments.at(i).bounds = QRectF(x1, y1, x2 - x1, y2 - y1); | - |
1012 | } executed: } Execution Count:19524 | 19524 |
1013 | | - |
1014 | ++m_pathId; executed (the execution status of this line is deduced): ++m_pathId; | - |
1015 | } executed: } Execution Count:382 | 382 |
1016 | | - |
1017 | qreal QWingedEdge::delta(int vertex, int a, int b) const | - |
1018 | { | - |
1019 | const QPathEdge *ap = edge(a); executed (the execution status of this line is deduced): const QPathEdge *ap = edge(a); | - |
1020 | const QPathEdge *bp = edge(b); executed (the execution status of this line is deduced): const QPathEdge *bp = edge(b); | - |
1021 | | - |
1022 | double a_angle = ap->angle; executed (the execution status of this line is deduced): double a_angle = ap->angle; | - |
1023 | double b_angle = bp->angle; executed (the execution status of this line is deduced): double b_angle = bp->angle; | - |
1024 | | - |
1025 | if (vertex == ap->second) evaluated: vertex == ap->second yes Evaluation Count:157 | yes Evaluation Count:437 |
| 157-437 |
1026 | a_angle = ap->invAngle; executed: a_angle = ap->invAngle; Execution Count:157 | 157 |
1027 | | - |
1028 | if (vertex == bp->second) evaluated: vertex == bp->second yes Evaluation Count:437 | yes Evaluation Count:157 |
| 157-437 |
1029 | b_angle = bp->invAngle; executed: b_angle = bp->invAngle; Execution Count:437 | 437 |
1030 | | - |
1031 | double result = b_angle - a_angle; executed (the execution status of this line is deduced): double result = b_angle - a_angle; | - |
1032 | | - |
1033 | if (result >= 128.) partially evaluated: result >= 128. no Evaluation Count:0 | yes Evaluation Count:594 |
| 0-594 |
1034 | return result - 128.; never executed: return result - 128.; | 0 |
1035 | else if (result < 0) evaluated: result < 0 yes Evaluation Count:317 | yes Evaluation Count:277 |
| 277-317 |
1036 | return result + 128.; executed: return result + 128.; Execution Count:317 | 317 |
1037 | else | - |
1038 | return result; executed: return result; Execution Count:277 | 277 |
1039 | } | - |
1040 | | - |
1041 | static inline QPointF midPoint(const QWingedEdge &list, int ei) | - |
1042 | { | - |
1043 | const QPathEdge *ep = list.edge(ei); never executed (the execution status of this line is deduced): const QPathEdge *ep = list.edge(ei); | - |
1044 | Q_ASSERT(ep); never executed (the execution status of this line is deduced): qt_noop(); | - |
1045 | | - |
1046 | const QPointF a = *list.vertex(ep->first); never executed (the execution status of this line is deduced): const QPointF a = *list.vertex(ep->first); | - |
1047 | const QPointF b = *list.vertex(ep->second); never executed (the execution status of this line is deduced): const QPointF b = *list.vertex(ep->second); | - |
1048 | return a + 0.5 * (b - a); never executed: return a + 0.5 * (b - a); | 0 |
1049 | } | - |
1050 | | - |
1051 | QWingedEdge::TraversalStatus QWingedEdge::findInsertStatus(int vi, int ei) const | - |
1052 | { | - |
1053 | const QPathVertex *vp = vertex(vi); executed (the execution status of this line is deduced): const QPathVertex *vp = vertex(vi); | - |
1054 | | - |
1055 | Q_ASSERT(vp); executed (the execution status of this line is deduced): qt_noop(); | - |
1056 | Q_ASSERT(ei >= 0); executed (the execution status of this line is deduced): qt_noop(); | - |
1057 | Q_ASSERT(vp->edge >= 0); executed (the execution status of this line is deduced): qt_noop(); | - |
1058 | | - |
1059 | int position = vp->edge; executed (the execution status of this line is deduced): int position = vp->edge; | - |
1060 | qreal d = 128.; executed (the execution status of this line is deduced): qreal d = 128.; | - |
1061 | | - |
1062 | TraversalStatus status; executed (the execution status of this line is deduced): TraversalStatus status; | - |
1063 | status.direction = edge(vp->edge)->directionTo(vi); executed (the execution status of this line is deduced): status.direction = edge(vp->edge)->directionTo(vi); | - |
1064 | status.traversal = QPathEdge::RightTraversal; executed (the execution status of this line is deduced): status.traversal = QPathEdge::RightTraversal; | - |
1065 | status.edge = vp->edge; executed (the execution status of this line is deduced): status.edge = vp->edge; | - |
1066 | | - |
1067 | #ifdef QDEBUG_CLIPPER | - |
1068 | const QPathEdge *ep = edge(ei); | - |
1069 | qDebug() << "Finding insert status for edge" << ei << "at vertex" << QPointF(*vp) << ", angles: " << ep->angle << ep->invAngle; | - |
1070 | #endif | - |
1071 | | - |
1072 | do { | - |
1073 | status = next(status); executed (the execution status of this line is deduced): status = next(status); | - |
1074 | status.flip(); executed (the execution status of this line is deduced): status.flip(); | - |
1075 | | - |
1076 | Q_ASSERT(edge(status.edge)->vertex(status.direction) == vi); executed (the execution status of this line is deduced): qt_noop(); | - |
1077 | qreal d2 = delta(vi, ei, status.edge); executed (the execution status of this line is deduced): qreal d2 = delta(vi, ei, status.edge); | - |
1078 | | - |
1079 | #ifdef QDEBUG_CLIPPER | - |
1080 | const QPathEdge *op = edge(status.edge); | - |
1081 | qDebug() << "Delta to edge" << status.edge << d2 << ", angles: " << op->angle << op->invAngle; | - |
1082 | #endif | - |
1083 | | - |
1084 | if (d2 < d) { evaluated: d2 < d yes Evaluation Count:541 | yes Evaluation Count:53 |
| 53-541 |
1085 | position = status.edge; executed (the execution status of this line is deduced): position = status.edge; | - |
1086 | d = d2; executed (the execution status of this line is deduced): d = d2; | - |
1087 | } executed: } Execution Count:541 | 541 |
1088 | } while (status.edge != vp->edge); executed: } Execution Count:594 evaluated: status.edge != vp->edge yes Evaluation Count:92 | yes Evaluation Count:502 |
| 92-594 |
1089 | | - |
1090 | status.traversal = QPathEdge::LeftTraversal; executed (the execution status of this line is deduced): status.traversal = QPathEdge::LeftTraversal; | - |
1091 | status.direction = QPathEdge::Forward; executed (the execution status of this line is deduced): status.direction = QPathEdge::Forward; | - |
1092 | status.edge = position; executed (the execution status of this line is deduced): status.edge = position; | - |
1093 | | - |
1094 | if (edge(status.edge)->vertex(status.direction) != vi) evaluated: edge(status.edge)->vertex(status.direction) != vi yes Evaluation Count:117 | yes Evaluation Count:385 |
| 117-385 |
1095 | status.flip(); executed: status.flip(); Execution Count:117 | 117 |
1096 | | - |
1097 | #ifdef QDEBUG_CLIPPER | - |
1098 | qDebug() << "Inserting edge" << ei << "to" << (status.traversal == QPathEdge::LeftTraversal ? "left" : "right") << "of edge" << status.edge; | - |
1099 | #endif | - |
1100 | | - |
1101 | Q_ASSERT(edge(status.edge)->vertex(status.direction) == vi); executed (the execution status of this line is deduced): qt_noop(); | - |
1102 | | - |
1103 | return status; executed: return status; Execution Count:502 | 502 |
1104 | } | - |
1105 | | - |
1106 | void QWingedEdge::removeEdge(int ei) | - |
1107 | { | - |
1108 | QPathEdge *ep = edge(ei); executed (the execution status of this line is deduced): QPathEdge *ep = edge(ei); | - |
1109 | | - |
1110 | TraversalStatus status; executed (the execution status of this line is deduced): TraversalStatus status; | - |
1111 | status.direction = QPathEdge::Forward; executed (the execution status of this line is deduced): status.direction = QPathEdge::Forward; | - |
1112 | status.traversal = QPathEdge::RightTraversal; executed (the execution status of this line is deduced): status.traversal = QPathEdge::RightTraversal; | - |
1113 | status.edge = ei; executed (the execution status of this line is deduced): status.edge = ei; | - |
1114 | | - |
1115 | TraversalStatus forwardRight = next(status); executed (the execution status of this line is deduced): TraversalStatus forwardRight = next(status); | - |
1116 | forwardRight.flipDirection(); executed (the execution status of this line is deduced): forwardRight.flipDirection(); | - |
1117 | | - |
1118 | status.traversal = QPathEdge::LeftTraversal; executed (the execution status of this line is deduced): status.traversal = QPathEdge::LeftTraversal; | - |
1119 | TraversalStatus forwardLeft = next(status); executed (the execution status of this line is deduced): TraversalStatus forwardLeft = next(status); | - |
1120 | forwardLeft.flipDirection(); executed (the execution status of this line is deduced): forwardLeft.flipDirection(); | - |
1121 | | - |
1122 | status.direction = QPathEdge::Backward; executed (the execution status of this line is deduced): status.direction = QPathEdge::Backward; | - |
1123 | TraversalStatus backwardLeft = next(status); executed (the execution status of this line is deduced): TraversalStatus backwardLeft = next(status); | - |
1124 | backwardLeft.flipDirection(); executed (the execution status of this line is deduced): backwardLeft.flipDirection(); | - |
1125 | | - |
1126 | status.traversal = QPathEdge::RightTraversal; executed (the execution status of this line is deduced): status.traversal = QPathEdge::RightTraversal; | - |
1127 | TraversalStatus backwardRight = next(status); executed (the execution status of this line is deduced): TraversalStatus backwardRight = next(status); | - |
1128 | backwardRight.flipDirection(); executed (the execution status of this line is deduced): backwardRight.flipDirection(); | - |
1129 | | - |
1130 | edge(forwardRight.edge)->setNext(forwardRight.traversal, forwardRight.direction, forwardLeft.edge); executed (the execution status of this line is deduced): edge(forwardRight.edge)->setNext(forwardRight.traversal, forwardRight.direction, forwardLeft.edge); | - |
1131 | edge(forwardLeft.edge)->setNext(forwardLeft.traversal, forwardLeft.direction, forwardRight.edge); executed (the execution status of this line is deduced): edge(forwardLeft.edge)->setNext(forwardLeft.traversal, forwardLeft.direction, forwardRight.edge); | - |
1132 | | - |
1133 | edge(backwardRight.edge)->setNext(backwardRight.traversal, backwardRight.direction, backwardLeft.edge); executed (the execution status of this line is deduced): edge(backwardRight.edge)->setNext(backwardRight.traversal, backwardRight.direction, backwardLeft.edge); | - |
1134 | edge(backwardLeft.edge)->setNext(backwardLeft.traversal, backwardLeft.direction, backwardRight.edge); executed (the execution status of this line is deduced): edge(backwardLeft.edge)->setNext(backwardLeft.traversal, backwardLeft.direction, backwardRight.edge); | - |
1135 | | - |
1136 | ep->setNext(QPathEdge::Forward, ei); executed (the execution status of this line is deduced): ep->setNext(QPathEdge::Forward, ei); | - |
1137 | ep->setNext(QPathEdge::Backward, ei); executed (the execution status of this line is deduced): ep->setNext(QPathEdge::Backward, ei); | - |
1138 | | - |
1139 | QPathVertex *a = vertex(ep->first); executed (the execution status of this line is deduced): QPathVertex *a = vertex(ep->first); | - |
1140 | QPathVertex *b = vertex(ep->second); executed (the execution status of this line is deduced): QPathVertex *b = vertex(ep->second); | - |
1141 | | - |
1142 | a->edge = backwardRight.edge; executed (the execution status of this line is deduced): a->edge = backwardRight.edge; | - |
1143 | b->edge = forwardRight.edge; executed (the execution status of this line is deduced): b->edge = forwardRight.edge; | - |
1144 | } executed: } Execution Count:20 | 20 |
1145 | | - |
1146 | static int commonEdge(const QWingedEdge &list, int a, int b) | - |
1147 | { | - |
1148 | const QPathVertex *ap = list.vertex(a); executed (the execution status of this line is deduced): const QPathVertex *ap = list.vertex(a); | - |
1149 | Q_ASSERT(ap); executed (the execution status of this line is deduced): qt_noop(); | - |
1150 | | - |
1151 | const QPathVertex *bp = list.vertex(b); executed (the execution status of this line is deduced): const QPathVertex *bp = list.vertex(b); | - |
1152 | Q_ASSERT(bp); executed (the execution status of this line is deduced): qt_noop(); | - |
1153 | | - |
1154 | if (ap->edge < 0 || bp->edge < 0) evaluated: ap->edge < 0 yes Evaluation Count:82 | yes Evaluation Count:516 |
evaluated: bp->edge < 0 yes Evaluation Count:273 | yes Evaluation Count:243 |
| 82-516 |
1155 | return -1; executed: return -1; Execution Count:355 | 355 |
1156 | | - |
1157 | QWingedEdge::TraversalStatus status; executed (the execution status of this line is deduced): QWingedEdge::TraversalStatus status; | - |
1158 | status.edge = ap->edge; executed (the execution status of this line is deduced): status.edge = ap->edge; | - |
1159 | status.direction = list.edge(status.edge)->directionTo(a); executed (the execution status of this line is deduced): status.direction = list.edge(status.edge)->directionTo(a); | - |
1160 | status.traversal = QPathEdge::RightTraversal; executed (the execution status of this line is deduced): status.traversal = QPathEdge::RightTraversal; | - |
1161 | | - |
1162 | do { | - |
1163 | const QPathEdge *ep = list.edge(status.edge); executed (the execution status of this line is deduced): const QPathEdge *ep = list.edge(status.edge); | - |
1164 | | - |
1165 | if ((ep->first == a && ep->second == b) evaluated: ep->first == a yes Evaluation Count:138 | yes Evaluation Count:247 |
evaluated: ep->second == b yes Evaluation Count:110 | yes Evaluation Count:28 |
| 28-247 |
1166 | || (ep->first == b && ep->second == a)) evaluated: ep->first == b yes Evaluation Count:22 | yes Evaluation Count:253 |
partially evaluated: ep->second == a yes Evaluation Count:22 | no Evaluation Count:0 |
| 0-253 |
1167 | return status.edge; executed: return status.edge; Execution Count:132 | 132 |
1168 | | - |
1169 | status = list.next(status); executed (the execution status of this line is deduced): status = list.next(status); | - |
1170 | status.flip(); executed (the execution status of this line is deduced): status.flip(); | - |
1171 | } while (status.edge != ap->edge); executed: } Execution Count:253 evaluated: status.edge != ap->edge yes Evaluation Count:142 | yes Evaluation Count:111 |
| 111-253 |
1172 | | - |
1173 | return -1; executed: return -1; Execution Count:111 | 111 |
1174 | } | - |
1175 | | - |
1176 | static double computeAngle(const QPointF &v) | - |
1177 | { | - |
1178 | #if 1 | - |
1179 | if (v.x() == 0) { evaluated: v.x() == 0 yes Evaluation Count:218 | yes Evaluation Count:248 |
| 218-248 |
1180 | return v.y() <= 0 ? 0 : 64.; executed: return v.y() <= 0 ? 0 : 64.; Execution Count:218 | 218 |
1181 | } else if (v.y() == 0) { partially evaluated: v.y() == 0 yes Evaluation Count:248 | no Evaluation Count:0 |
| 0-248 |
1182 | return v.x() <= 0 ? 32. : 96.; executed: return v.x() <= 0 ? 32. : 96.; Execution Count:248 | 248 |
1183 | } | - |
1184 | | - |
1185 | double vx = v.x(); never executed (the execution status of this line is deduced): double vx = v.x(); | - |
1186 | double vy = v.y(); never executed (the execution status of this line is deduced): double vy = v.y(); | - |
1187 | normalize(vx, vy); never executed (the execution status of this line is deduced): normalize(vx, vy); | - |
1188 | if (vy < 0) { | 0 |
1189 | if (vx < 0) { // 0 - 32 | 0 |
1190 | return -32. * vx; never executed: return -32. * vx; | 0 |
1191 | } else { // 96 - 128 | - |
1192 | return 128. - 32. * vx; never executed: return 128. - 32. * vx; | 0 |
1193 | } | - |
1194 | } else { // 32 - 96 | - |
1195 | return 64. + 32. * vx; never executed: return 64. + 32. * vx; | 0 |
1196 | } | - |
1197 | #else | - |
1198 | // doesn't seem to be robust enough | - |
1199 | return qAtan2(v.x(), v.y()) + Q_PI; | - |
1200 | #endif | - |
1201 | } | - |
1202 | | - |
1203 | int QWingedEdge::addEdge(const QPointF &a, const QPointF &b) | - |
1204 | { | - |
1205 | int fi = insert(a); never executed (the execution status of this line is deduced): int fi = insert(a); | - |
1206 | int si = insert(b); never executed (the execution status of this line is deduced): int si = insert(b); | - |
1207 | | - |
1208 | return addEdge(fi, si); never executed: return addEdge(fi, si); | 0 |
1209 | } | - |
1210 | | - |
1211 | int QWingedEdge::addEdge(int fi, int si) | - |
1212 | { | - |
1213 | if (fi == si) evaluated: fi == si yes Evaluation Count:338 | yes Evaluation Count:598 |
| 338-598 |
1214 | return -1; executed: return -1; Execution Count:338 | 338 |
1215 | | - |
1216 | int common = commonEdge(*this, fi, si); executed (the execution status of this line is deduced): int common = commonEdge(*this, fi, si); | - |
1217 | if (common >= 0) evaluated: common >= 0 yes Evaluation Count:132 | yes Evaluation Count:466 |
| 132-466 |
1218 | return common; executed: return common; Execution Count:132 | 132 |
1219 | | - |
1220 | m_edges << QPathEdge(fi, si); executed (the execution status of this line is deduced): m_edges << QPathEdge(fi, si); | - |
1221 | | - |
1222 | int ei = m_edges.size() - 1; executed (the execution status of this line is deduced): int ei = m_edges.size() - 1; | - |
1223 | | - |
1224 | QPathVertex *fp = vertex(fi); executed (the execution status of this line is deduced): QPathVertex *fp = vertex(fi); | - |
1225 | QPathVertex *sp = vertex(si); executed (the execution status of this line is deduced): QPathVertex *sp = vertex(si); | - |
1226 | | - |
1227 | QPathEdge *ep = edge(ei); executed (the execution status of this line is deduced): QPathEdge *ep = edge(ei); | - |
1228 | | - |
1229 | const QPointF tangent = QPointF(*sp) - QPointF(*fp); executed (the execution status of this line is deduced): const QPointF tangent = QPointF(*sp) - QPointF(*fp); | - |
1230 | ep->angle = computeAngle(tangent); executed (the execution status of this line is deduced): ep->angle = computeAngle(tangent); | - |
1231 | ep->invAngle = ep->angle + 64; executed (the execution status of this line is deduced): ep->invAngle = ep->angle + 64; | - |
1232 | if (ep->invAngle >= 128) evaluated: ep->invAngle >= 128 yes Evaluation Count:233 | yes Evaluation Count:233 |
| 233 |
1233 | ep->invAngle -= 128; executed: ep->invAngle -= 128; Execution Count:233 | 233 |
1234 | | - |
1235 | QPathVertex *vertices[2] = { fp, sp }; executed (the execution status of this line is deduced): QPathVertex *vertices[2] = { fp, sp }; | - |
1236 | QPathEdge::Direction dirs[2] = { QPathEdge::Backward, QPathEdge::Forward }; executed (the execution status of this line is deduced): QPathEdge::Direction dirs[2] = { QPathEdge::Backward, QPathEdge::Forward }; | - |
1237 | | - |
1238 | #ifdef QDEBUG_CLIPPER | - |
1239 | printf("** Adding edge %d / vertices: %.07f %.07f, %.07f %.07f\n", ei, fp->x, fp->y, sp->x, sp->y); | - |
1240 | #endif | - |
1241 | | - |
1242 | for (int i = 0; i < 2; ++i) { evaluated: i < 2 yes Evaluation Count:932 | yes Evaluation Count:466 |
| 466-932 |
1243 | QPathVertex *vp = vertices[i]; executed (the execution status of this line is deduced): QPathVertex *vp = vertices[i]; | - |
1244 | if (vp->edge < 0) { evaluated: vp->edge < 0 yes Evaluation Count:430 | yes Evaluation Count:502 |
| 430-502 |
1245 | vp->edge = ei; executed (the execution status of this line is deduced): vp->edge = ei; | - |
1246 | ep->setNext(dirs[i], ei); executed (the execution status of this line is deduced): ep->setNext(dirs[i], ei); | - |
1247 | } else { executed: } Execution Count:430 | 430 |
1248 | int vi = ep->vertex(dirs[i]); executed (the execution status of this line is deduced): int vi = ep->vertex(dirs[i]); | - |
1249 | Q_ASSERT(vertex(vi) == vertices[i]); executed (the execution status of this line is deduced): qt_noop(); | - |
1250 | | - |
1251 | TraversalStatus os = findInsertStatus(vi, ei); executed (the execution status of this line is deduced): TraversalStatus os = findInsertStatus(vi, ei); | - |
1252 | QPathEdge *op = edge(os.edge); executed (the execution status of this line is deduced): QPathEdge *op = edge(os.edge); | - |
1253 | | - |
1254 | Q_ASSERT(vertex(op->vertex(os.direction)) == vertices[i]); executed (the execution status of this line is deduced): qt_noop(); | - |
1255 | | - |
1256 | TraversalStatus ns = next(os); executed (the execution status of this line is deduced): TraversalStatus ns = next(os); | - |
1257 | ns.flipDirection(); executed (the execution status of this line is deduced): ns.flipDirection(); | - |
1258 | QPathEdge *np = edge(ns.edge); executed (the execution status of this line is deduced): QPathEdge *np = edge(ns.edge); | - |
1259 | | - |
1260 | op->setNext(os.traversal, os.direction, ei); executed (the execution status of this line is deduced): op->setNext(os.traversal, os.direction, ei); | - |
1261 | np->setNext(ns.traversal, ns.direction, ei); executed (the execution status of this line is deduced): np->setNext(ns.traversal, ns.direction, ei); | - |
1262 | | - |
1263 | int oe = os.edge; executed (the execution status of this line is deduced): int oe = os.edge; | - |
1264 | int ne = ns.edge; executed (the execution status of this line is deduced): int ne = ns.edge; | - |
1265 | | - |
1266 | os = next(os); executed (the execution status of this line is deduced): os = next(os); | - |
1267 | ns = next(ns); executed (the execution status of this line is deduced): ns = next(ns); | - |
1268 | | - |
1269 | os.flipDirection(); executed (the execution status of this line is deduced): os.flipDirection(); | - |
1270 | ns.flipDirection(); executed (the execution status of this line is deduced): ns.flipDirection(); | - |
1271 | | - |
1272 | Q_ASSERT(os.edge == ei); executed (the execution status of this line is deduced): qt_noop(); | - |
1273 | Q_ASSERT(ns.edge == ei); executed (the execution status of this line is deduced): qt_noop(); | - |
1274 | | - |
1275 | ep->setNext(os.traversal, os.direction, oe); executed (the execution status of this line is deduced): ep->setNext(os.traversal, os.direction, oe); | - |
1276 | ep->setNext(ns.traversal, ns.direction, ne); executed (the execution status of this line is deduced): ep->setNext(ns.traversal, ns.direction, ne); | - |
1277 | } executed: } Execution Count:502 | 502 |
1278 | } | - |
1279 | | - |
1280 | Q_ASSERT(ep->next(QPathEdge::RightTraversal, QPathEdge::Forward) >= 0); executed (the execution status of this line is deduced): qt_noop(); | - |
1281 | Q_ASSERT(ep->next(QPathEdge::RightTraversal, QPathEdge::Backward) >= 0); executed (the execution status of this line is deduced): qt_noop(); | - |
1282 | Q_ASSERT(ep->next(QPathEdge::LeftTraversal, QPathEdge::Forward) >= 0); executed (the execution status of this line is deduced): qt_noop(); | - |
1283 | Q_ASSERT(ep->next(QPathEdge::LeftTraversal, QPathEdge::Backward) >= 0); executed (the execution status of this line is deduced): qt_noop(); | - |
1284 | | - |
1285 | return ei; executed: return ei; Execution Count:466 | 466 |
1286 | } | - |
1287 | | - |
1288 | int QWingedEdge::insert(const QPathVertex &vertex) | - |
1289 | { | - |
1290 | if (!m_vertices.isEmpty()) { never evaluated: !m_vertices.isEmpty() | 0 |
1291 | const QPathVertex &last = m_vertices.last(); never executed (the execution status of this line is deduced): const QPathVertex &last = m_vertices.last(); | - |
1292 | if (vertex.x == last.x && vertex.y == last.y) never evaluated: vertex.x == last.x never evaluated: vertex.y == last.y | 0 |
1293 | return m_vertices.size() - 1; never executed: return m_vertices.size() - 1; | 0 |
1294 | | - |
1295 | for (int i = 0; i < m_vertices.size(); ++i) { never evaluated: i < m_vertices.size() | 0 |
1296 | const QPathVertex &v = m_vertices.at(i); never executed (the execution status of this line is deduced): const QPathVertex &v = m_vertices.at(i); | - |
1297 | if (qFuzzyCompare(v.x, vertex.x) && qFuzzyCompare(v.y, vertex.y)) { never evaluated: qFuzzyCompare(v.x, vertex.x) never evaluated: qFuzzyCompare(v.y, vertex.y) | 0 |
1298 | return i; never executed: return i; | 0 |
1299 | } | - |
1300 | } | 0 |
1301 | } | 0 |
1302 | | - |
1303 | m_vertices << vertex; never executed (the execution status of this line is deduced): m_vertices << vertex; | - |
1304 | return m_vertices.size() - 1; never executed: return m_vertices.size() - 1; | 0 |
1305 | } | - |
1306 | | - |
1307 | static void addLineTo(QPainterPath &path, const QPointF &point) | - |
1308 | { | - |
1309 | const int elementCount = path.elementCount(); executed (the execution status of this line is deduced): const int elementCount = path.elementCount(); | - |
1310 | if (elementCount >= 2) { evaluated: elementCount >= 2 yes Evaluation Count:214 | yes Evaluation Count:60 |
| 60-214 |
1311 | const QPainterPath::Element &middle = path.elementAt(elementCount - 1); executed (the execution status of this line is deduced): const QPainterPath::Element &middle = path.elementAt(elementCount - 1); | - |
1312 | if (middle.type == QPainterPath::LineToElement) { evaluated: middle.type == QPainterPath::LineToElement yes Evaluation Count:213 | yes Evaluation Count:1 |
| 1-213 |
1313 | const QPointF first = path.elementAt(elementCount - 2); executed (the execution status of this line is deduced): const QPointF first = path.elementAt(elementCount - 2); | - |
1314 | const QPointF d1 = point - first; executed (the execution status of this line is deduced): const QPointF d1 = point - first; | - |
1315 | const QPointF d2 = middle - first; executed (the execution status of this line is deduced): const QPointF d2 = middle - first; | - |
1316 | | - |
1317 | const QPointF p(-d1.y(), d1.x()); executed (the execution status of this line is deduced): const QPointF p(-d1.y(), d1.x()); | - |
1318 | | - |
1319 | if (qFuzzyIsNull(dot(p, d2))) { evaluated: qFuzzyIsNull(dot(p, d2)) yes Evaluation Count:6 | yes Evaluation Count:207 |
| 6-207 |
1320 | path.setElementPositionAt(elementCount - 1, point.x(), point.y()); executed (the execution status of this line is deduced): path.setElementPositionAt(elementCount - 1, point.x(), point.y()); | - |
1321 | return; executed: return; Execution Count:6 | 6 |
1322 | } | - |
1323 | } executed: } Execution Count:207 | 207 |
1324 | } executed: } Execution Count:208 | 208 |
1325 | | - |
1326 | path.lineTo(point); executed (the execution status of this line is deduced): path.lineTo(point); | - |
1327 | } executed: } Execution Count:268 | 268 |
1328 | | - |
1329 | static void add(QPainterPath &path, const QWingedEdge &list, int edge, QPathEdge::Traversal traversal) | - |
1330 | { | - |
1331 | QWingedEdge::TraversalStatus status; executed (the execution status of this line is deduced): QWingedEdge::TraversalStatus status; | - |
1332 | status.edge = edge; executed (the execution status of this line is deduced): status.edge = edge; | - |
1333 | status.traversal = traversal; executed (the execution status of this line is deduced): status.traversal = traversal; | - |
1334 | status.direction = QPathEdge::Forward; executed (the execution status of this line is deduced): status.direction = QPathEdge::Forward; | - |
1335 | | - |
1336 | path.moveTo(*list.vertex(list.edge(edge)->first)); executed (the execution status of this line is deduced): path.moveTo(*list.vertex(list.edge(edge)->first)); | - |
1337 | | - |
1338 | do { | - |
1339 | const QPathEdge *ep = list.edge(status.edge); executed (the execution status of this line is deduced): const QPathEdge *ep = list.edge(status.edge); | - |
1340 | | - |
1341 | addLineTo(path, *list.vertex(ep->vertex(status.direction))); executed (the execution status of this line is deduced): addLineTo(path, *list.vertex(ep->vertex(status.direction))); | - |
1342 | | - |
1343 | if (status.traversal == QPathEdge::LeftTraversal) evaluated: status.traversal == QPathEdge::LeftTraversal yes Evaluation Count:6 | yes Evaluation Count:268 |
| 6-268 |
1344 | ep->flag &= ~16; executed: ep->flag &= ~16; Execution Count:6 | 6 |
1345 | else | - |
1346 | ep->flag &= ~32; executed: ep->flag &= ~32; Execution Count:268 | 268 |
1347 | | - |
1348 | status = list.next(status); executed (the execution status of this line is deduced): status = list.next(status); | - |
1349 | } while (status.edge != edge); executed: } Execution Count:274 evaluated: status.edge != edge yes Evaluation Count:213 | yes Evaluation Count:61 |
| 61-274 |
1350 | } executed: } Execution Count:61 | 61 |
1351 | | - |
1352 | void QWingedEdge::simplify() | - |
1353 | { | - |
1354 | for (int i = 0; i < edgeCount(); ++i) { evaluated: i < edgeCount() yes Evaluation Count:466 | yes Evaluation Count:70 |
| 70-466 |
1355 | const QPathEdge *ep = edge(i); executed (the execution status of this line is deduced): const QPathEdge *ep = edge(i); | - |
1356 | | - |
1357 | // if both sides are part of the inside then we can collapse the edge | - |
1358 | int flag = 0x3 << 4; executed (the execution status of this line is deduced): int flag = 0x3 << 4; | - |
1359 | if ((ep->flag & flag) == flag) { evaluated: (ep->flag & flag) == flag yes Evaluation Count:20 | yes Evaluation Count:446 |
| 20-446 |
1360 | removeEdge(i); executed (the execution status of this line is deduced): removeEdge(i); | - |
1361 | | - |
1362 | ep->flag &= ~flag; executed (the execution status of this line is deduced): ep->flag &= ~flag; | - |
1363 | } executed: } Execution Count:20 | 20 |
1364 | } executed: } Execution Count:466 | 466 |
1365 | } executed: } Execution Count:70 | 70 |
1366 | | - |
1367 | QPainterPath QWingedEdge::toPath() const | - |
1368 | { | - |
1369 | QPainterPath path; executed (the execution status of this line is deduced): QPainterPath path; | - |
1370 | | - |
1371 | for (int i = 0; i < edgeCount(); ++i) { evaluated: i < edgeCount() yes Evaluation Count:466 | yes Evaluation Count:70 |
| 70-466 |
1372 | const QPathEdge *ep = edge(i); executed (the execution status of this line is deduced): const QPathEdge *ep = edge(i); | - |
1373 | | - |
1374 | if (ep->flag & 16) { evaluated: ep->flag & 16 yes Evaluation Count:1 | yes Evaluation Count:465 |
| 1-465 |
1375 | add(path, *this, i, QPathEdge::LeftTraversal); executed (the execution status of this line is deduced): add(path, *this, i, QPathEdge::LeftTraversal); | - |
1376 | } executed: } Execution Count:1 | 1 |
1377 | | - |
1378 | if (ep->flag & 32) evaluated: ep->flag & 32 yes Evaluation Count:60 | yes Evaluation Count:406 |
| 60-406 |
1379 | add(path, *this, i, QPathEdge::RightTraversal); executed: add(path, *this, i, QPathEdge::RightTraversal); Execution Count:60 | 60 |
1380 | } executed: } Execution Count:466 | 466 |
1381 | | - |
1382 | return path; executed: return path; Execution Count:70 | 70 |
1383 | } | - |
1384 | | - |
1385 | bool QPathClipper::intersect() | - |
1386 | { | - |
1387 | if (subjectPath == clipPath) evaluated: subjectPath == clipPath yes Evaluation Count:5 | yes Evaluation Count:402 |
| 5-402 |
1388 | return true; executed: return true; Execution Count:5 | 5 |
1389 | | - |
1390 | QRectF r1 = subjectPath.controlPointRect(); executed (the execution status of this line is deduced): QRectF r1 = subjectPath.controlPointRect(); | - |
1391 | QRectF r2 = clipPath.controlPointRect(); executed (the execution status of this line is deduced): QRectF r2 = clipPath.controlPointRect(); | - |
1392 | if (qMax(r1.x(), r2.x()) > qMin(r1.x() + r1.width(), r2.x() + r2.width()) || partially evaluated: qMax(r1.x(), r2.x()) > qMin(r1.x() + r1.width(), r2.x() + r2.width()) no Evaluation Count:0 | yes Evaluation Count:402 |
| 0-402 |
1393 | qMax(r1.y(), r2.y()) > qMin(r1.y() + r1.height(), r2.y() + r2.height())) { partially evaluated: qMax(r1.y(), r2.y()) > qMin(r1.y() + r1.height(), r2.y() + r2.height()) no Evaluation Count:0 | yes Evaluation Count:402 |
| 0-402 |
1394 | // no way we could intersect | - |
1395 | return false; never executed: return false; | 0 |
1396 | } | - |
1397 | | - |
1398 | bool subjectIsRect = pathToRect(subjectPath); executed (the execution status of this line is deduced): bool subjectIsRect = pathToRect(subjectPath); | - |
1399 | bool clipIsRect = pathToRect(clipPath); executed (the execution status of this line is deduced): bool clipIsRect = pathToRect(clipPath); | - |
1400 | | - |
1401 | if (subjectIsRect && clipIsRect) evaluated: subjectIsRect yes Evaluation Count:315 | yes Evaluation Count:87 |
evaluated: clipIsRect yes Evaluation Count:214 | yes Evaluation Count:101 |
| 87-315 |
1402 | return true; executed: return true; Execution Count:214 | 214 |
1403 | else if (subjectIsRect) evaluated: subjectIsRect yes Evaluation Count:101 | yes Evaluation Count:87 |
| 87-101 |
1404 | return clipPath.intersects(r1); executed: return clipPath.intersects(r1); Execution Count:101 | 101 |
1405 | else if (clipIsRect) evaluated: clipIsRect yes Evaluation Count:3 | yes Evaluation Count:84 |
| 3-84 |
1406 | return subjectPath.intersects(r2); executed: return subjectPath.intersects(r2); Execution Count:3 | 3 |
1407 | | - |
1408 | QPathSegments a(subjectPath.elementCount()); executed (the execution status of this line is deduced): QPathSegments a(subjectPath.elementCount()); | - |
1409 | a.setPath(subjectPath); executed (the execution status of this line is deduced): a.setPath(subjectPath); | - |
1410 | QPathSegments b(clipPath.elementCount()); executed (the execution status of this line is deduced): QPathSegments b(clipPath.elementCount()); | - |
1411 | b.setPath(clipPath); executed (the execution status of this line is deduced): b.setPath(clipPath); | - |
1412 | | - |
1413 | QIntersectionFinder finder; executed (the execution status of this line is deduced): QIntersectionFinder finder; | - |
1414 | if (finder.hasIntersections(a, b)) evaluated: finder.hasIntersections(a, b) yes Evaluation Count:54 | yes Evaluation Count:30 |
| 30-54 |
1415 | return true; executed: return true; Execution Count:54 | 54 |
1416 | | - |
1417 | for (int i = 0; i < clipPath.elementCount(); ++i) { evaluated: i < clipPath.elementCount() yes Evaluation Count:1299 | yes Evaluation Count:25 |
| 25-1299 |
1418 | if (clipPath.elementAt(i).type == QPainterPath::MoveToElement) { evaluated: clipPath.elementAt(i).type == QPainterPath::MoveToElement yes Evaluation Count:76 | yes Evaluation Count:1223 |
| 76-1223 |
1419 | const QPointF point = clipPath.elementAt(i); executed (the execution status of this line is deduced): const QPointF point = clipPath.elementAt(i); | - |
1420 | if (r1.contains(point) && subjectPath.contains(point)) evaluated: r1.contains(point) yes Evaluation Count:7 | yes Evaluation Count:69 |
evaluated: subjectPath.contains(point) yes Evaluation Count:5 | yes Evaluation Count:2 |
| 2-69 |
1421 | return true; executed: return true; Execution Count:5 | 5 |
1422 | } executed: } Execution Count:71 | 71 |
1423 | } executed: } Execution Count:1294 | 1294 |
1424 | | - |
1425 | for (int i = 0; i < subjectPath.elementCount(); ++i) { evaluated: i < subjectPath.elementCount() yes Evaluation Count:83 | yes Evaluation Count:8 |
| 8-83 |
1426 | if (subjectPath.elementAt(i).type == QPainterPath::MoveToElement) { evaluated: subjectPath.elementAt(i).type == QPainterPath::MoveToElement yes Evaluation Count:27 | yes Evaluation Count:56 |
| 27-56 |
1427 | const QPointF point = subjectPath.elementAt(i); executed (the execution status of this line is deduced): const QPointF point = subjectPath.elementAt(i); | - |
1428 | if (r2.contains(point) && clipPath.contains(point)) evaluated: r2.contains(point) yes Evaluation Count:23 | yes Evaluation Count:4 |
evaluated: clipPath.contains(point) yes Evaluation Count:17 | yes Evaluation Count:6 |
| 4-23 |
1429 | return true; executed: return true; Execution Count:17 | 17 |
1430 | } executed: } Execution Count:10 | 10 |
1431 | } executed: } Execution Count:66 | 66 |
1432 | | - |
1433 | return false; executed: return false; Execution Count:8 | 8 |
1434 | } | - |
1435 | | - |
1436 | bool QPathClipper::contains() | - |
1437 | { | - |
1438 | if (subjectPath == clipPath) evaluated: subjectPath == clipPath yes Evaluation Count:5 | yes Evaluation Count:40 |
| 5-40 |
1439 | return false; executed: return false; Execution Count:5 | 5 |
1440 | | - |
1441 | QRectF r1 = subjectPath.controlPointRect(); executed (the execution status of this line is deduced): QRectF r1 = subjectPath.controlPointRect(); | - |
1442 | QRectF r2 = clipPath.controlPointRect(); executed (the execution status of this line is deduced): QRectF r2 = clipPath.controlPointRect(); | - |
1443 | if (qMax(r1.x(), r2.x()) > qMin(r1.x() + r1.width(), r2.x() + r2.width()) || partially evaluated: qMax(r1.x(), r2.x()) > qMin(r1.x() + r1.width(), r2.x() + r2.width()) no Evaluation Count:0 | yes Evaluation Count:40 |
| 0-40 |
1444 | qMax(r1.y(), r2.y()) > qMin(r1.y() + r1.height(), r2.y() + r2.height())) { partially evaluated: qMax(r1.y(), r2.y()) > qMin(r1.y() + r1.height(), r2.y() + r2.height()) no Evaluation Count:0 | yes Evaluation Count:40 |
| 0-40 |
1445 | // no intersection -> not contained | - |
1446 | return false; never executed: return false; | 0 |
1447 | } | - |
1448 | | - |
1449 | bool clipIsRect = pathToRect(clipPath); executed (the execution status of this line is deduced): bool clipIsRect = pathToRect(clipPath); | - |
1450 | if (clipIsRect) evaluated: clipIsRect yes Evaluation Count:3 | yes Evaluation Count:37 |
| 3-37 |
1451 | return subjectPath.contains(r2); executed: return subjectPath.contains(r2); Execution Count:3 | 3 |
1452 | | - |
1453 | QPathSegments a(subjectPath.elementCount()); executed (the execution status of this line is deduced): QPathSegments a(subjectPath.elementCount()); | - |
1454 | a.setPath(subjectPath); executed (the execution status of this line is deduced): a.setPath(subjectPath); | - |
1455 | QPathSegments b(clipPath.elementCount()); executed (the execution status of this line is deduced): QPathSegments b(clipPath.elementCount()); | - |
1456 | b.setPath(clipPath); executed (the execution status of this line is deduced): b.setPath(clipPath); | - |
1457 | | - |
1458 | QIntersectionFinder finder; executed (the execution status of this line is deduced): QIntersectionFinder finder; | - |
1459 | if (finder.hasIntersections(a, b)) evaluated: finder.hasIntersections(a, b) yes Evaluation Count:24 | yes Evaluation Count:13 |
| 13-24 |
1460 | return false; executed: return false; Execution Count:24 | 24 |
1461 | | - |
1462 | for (int i = 0; i < clipPath.elementCount(); ++i) { evaluated: i < clipPath.elementCount() yes Evaluation Count:126 | yes Evaluation Count:10 |
| 10-126 |
1463 | if (clipPath.elementAt(i).type == QPainterPath::MoveToElement) { evaluated: clipPath.elementAt(i).type == QPainterPath::MoveToElement yes Evaluation Count:18 | yes Evaluation Count:108 |
| 18-108 |
1464 | const QPointF point = clipPath.elementAt(i); executed (the execution status of this line is deduced): const QPointF point = clipPath.elementAt(i); | - |
1465 | if (!r1.contains(point) || !subjectPath.contains(point)) evaluated: !r1.contains(point) yes Evaluation Count:1 | yes Evaluation Count:17 |
evaluated: !subjectPath.contains(point) yes Evaluation Count:2 | yes Evaluation Count:15 |
| 1-17 |
1466 | return false; executed: return false; Execution Count:3 | 3 |
1467 | } executed: } Execution Count:15 | 15 |
1468 | } executed: } Execution Count:123 | 123 |
1469 | | - |
1470 | return true; executed: return true; Execution Count:10 | 10 |
1471 | } | - |
1472 | | - |
1473 | QPathClipper::QPathClipper(const QPainterPath &subject, | - |
1474 | const QPainterPath &clip) | - |
1475 | : subjectPath(subject) | - |
1476 | , clipPath(clip) | - |
1477 | { | - |
1478 | aMask = subjectPath.fillRule() == Qt::WindingFill ? ~0x0 : 0x1; evaluated: subjectPath.fillRule() == Qt::WindingFill yes Evaluation Count:119 | yes Evaluation Count:535 |
| 119-535 |
1479 | bMask = clipPath.fillRule() == Qt::WindingFill ? ~0x0 : 0x1; evaluated: clipPath.fillRule() == Qt::WindingFill yes Evaluation Count:263 | yes Evaluation Count:391 |
| 263-391 |
1480 | } executed: } Execution Count:654 | 654 |
1481 | | - |
1482 | template <typename Iterator, typename Equality> | - |
1483 | Iterator qRemoveDuplicates(Iterator begin, Iterator end, Equality eq) | - |
1484 | { | - |
1485 | if (begin == end) partially evaluated: begin == end no Evaluation Count:0 | yes Evaluation Count:70 |
| 0-70 |
1486 | return end; never executed: return end; | 0 |
1487 | | - |
1488 | Iterator last = begin; executed (the execution status of this line is deduced): Iterator last = begin; | - |
1489 | ++begin; executed (the execution status of this line is deduced): ++begin; | - |
1490 | Iterator insert = begin; executed (the execution status of this line is deduced): Iterator insert = begin; | - |
1491 | for (Iterator it = begin; it != end; ++it) { evaluated: it != end yes Evaluation Count:360 | yes Evaluation Count:70 |
| 70-360 |
1492 | if (!eq(*it, *last)) { evaluated: !eq(*it, *last) yes Evaluation Count:96 | yes Evaluation Count:264 |
| 96-264 |
1493 | *insert++ = *it; executed (the execution status of this line is deduced): *insert++ = *it; | - |
1494 | last = it; executed (the execution status of this line is deduced): last = it; | - |
1495 | } executed: } Execution Count:96 | 96 |
1496 | } executed: } Execution Count:360 | 360 |
1497 | | - |
1498 | return insert; executed: return insert; Execution Count:70 | 70 |
1499 | } | - |
1500 | | - |
1501 | static void clear(QWingedEdge& list, int edge, QPathEdge::Traversal traversal) | - |
1502 | { | - |
1503 | QWingedEdge::TraversalStatus status; executed (the execution status of this line is deduced): QWingedEdge::TraversalStatus status; | - |
1504 | status.edge = edge; executed (the execution status of this line is deduced): status.edge = edge; | - |
1505 | status.traversal = traversal; executed (the execution status of this line is deduced): status.traversal = traversal; | - |
1506 | status.direction = QPathEdge::Forward; executed (the execution status of this line is deduced): status.direction = QPathEdge::Forward; | - |
1507 | | - |
1508 | do { | - |
1509 | if (status.traversal == QPathEdge::LeftTraversal) evaluated: status.traversal == QPathEdge::LeftTraversal yes Evaluation Count:440 | yes Evaluation Count:178 |
| 178-440 |
1510 | list.edge(status.edge)->flag |= 1; executed: list.edge(status.edge)->flag |= 1; Execution Count:440 | 440 |
1511 | else | - |
1512 | list.edge(status.edge)->flag |= 2; executed: list.edge(status.edge)->flag |= 2; Execution Count:178 | 178 |
1513 | | - |
1514 | status = list.next(status); executed (the execution status of this line is deduced): status = list.next(status); | - |
1515 | } while (status.edge != edge); executed: } Execution Count:618 evaluated: status.edge != edge yes Evaluation Count:507 | yes Evaluation Count:111 |
| 111-618 |
1516 | } executed: } Execution Count:111 | 111 |
1517 | | - |
1518 | template <typename InputIterator> | - |
1519 | InputIterator qFuzzyFind(InputIterator first, InputIterator last, qreal val) | - |
1520 | { | - |
1521 | while (first != last && !QT_PREPEND_NAMESPACE(qFuzzyCompare)(qreal(*first), qreal(val))) partially evaluated: first != last yes Evaluation Count:299 | no Evaluation Count:0 |
evaluated: !::qFuzzyCompare(qreal(*first), qreal(val)) yes Evaluation Count:127 | yes Evaluation Count:172 |
| 0-299 |
1522 | ++first; executed: ++first; Execution Count:127 | 127 |
1523 | return first; executed: return first; Execution Count:172 | 172 |
1524 | } | - |
1525 | | - |
1526 | static bool fuzzyCompare(qreal a, qreal b) | - |
1527 | { | - |
1528 | return qFuzzyCompare(a, b); executed: return qFuzzyCompare(a, b); Execution Count:360 | 360 |
1529 | } | - |
1530 | | - |
1531 | bool QPathClipper::pathToRect(const QPainterPath &path, QRectF *rect) | - |
1532 | { | - |
1533 | if (path.elementCount() != 5) evaluated: path.elementCount() != 5 yes Evaluation Count:333 | yes Evaluation Count:705 |
| 333-705 |
1534 | return false; executed: return false; Execution Count:333 | 333 |
1535 | | - |
1536 | const bool mightBeRect = path.elementAt(0).isMoveTo() partially evaluated: path.elementAt(0).isMoveTo() yes Evaluation Count:705 | no Evaluation Count:0 |
| 0-705 |
1537 | && path.elementAt(1).isLineTo() partially evaluated: path.elementAt(1).isLineTo() yes Evaluation Count:705 | no Evaluation Count:0 |
| 0-705 |
1538 | && path.elementAt(2).isLineTo() partially evaluated: path.elementAt(2).isLineTo() yes Evaluation Count:705 | no Evaluation Count:0 |
| 0-705 |
1539 | && path.elementAt(3).isLineTo() partially evaluated: path.elementAt(3).isLineTo() yes Evaluation Count:705 | no Evaluation Count:0 |
| 0-705 |
1540 | && path.elementAt(4).isLineTo(); partially evaluated: path.elementAt(4).isLineTo() yes Evaluation Count:705 | no Evaluation Count:0 |
| 0-705 |
1541 | | - |
1542 | if (!mightBeRect) partially evaluated: !mightBeRect no Evaluation Count:0 | yes Evaluation Count:705 |
| 0-705 |
1543 | return false; never executed: return false; | 0 |
1544 | | - |
1545 | const qreal x1 = path.elementAt(0).x; executed (the execution status of this line is deduced): const qreal x1 = path.elementAt(0).x; | - |
1546 | const qreal y1 = path.elementAt(0).y; executed (the execution status of this line is deduced): const qreal y1 = path.elementAt(0).y; | - |
1547 | | - |
1548 | const qreal x2 = path.elementAt(1).x; executed (the execution status of this line is deduced): const qreal x2 = path.elementAt(1).x; | - |
1549 | const qreal y2 = path.elementAt(2).y; executed (the execution status of this line is deduced): const qreal y2 = path.elementAt(2).y; | - |
1550 | | - |
1551 | if (path.elementAt(1).y != y1) evaluated: path.elementAt(1).y != y1 yes Evaluation Count:20 | yes Evaluation Count:685 |
| 20-685 |
1552 | return false; executed: return false; Execution Count:20 | 20 |
1553 | | - |
1554 | if (path.elementAt(2).x != x2) partially evaluated: path.elementAt(2).x != x2 no Evaluation Count:0 | yes Evaluation Count:685 |
| 0-685 |
1555 | return false; never executed: return false; | 0 |
1556 | | - |
1557 | if (path.elementAt(3).x != x1 || path.elementAt(3).y != y2) partially evaluated: path.elementAt(3).x != x1 no Evaluation Count:0 | yes Evaluation Count:685 |
partially evaluated: path.elementAt(3).y != y2 no Evaluation Count:0 | yes Evaluation Count:685 |
| 0-685 |
1558 | return false; never executed: return false; | 0 |
1559 | | - |
1560 | if (path.elementAt(4).x != x1 || path.elementAt(4).y != y1) partially evaluated: path.elementAt(4).x != x1 no Evaluation Count:0 | yes Evaluation Count:685 |
partially evaluated: path.elementAt(4).y != y1 no Evaluation Count:0 | yes Evaluation Count:685 |
| 0-685 |
1561 | return false; never executed: return false; | 0 |
1562 | | - |
1563 | if (rect) partially evaluated: rect no Evaluation Count:0 | yes Evaluation Count:685 |
| 0-685 |
1564 | rect->setCoords(x1, y1, x2, y2); never executed: rect->setCoords(x1, y1, x2, y2); | 0 |
1565 | | - |
1566 | return true; executed: return true; Execution Count:685 | 685 |
1567 | } | - |
1568 | | - |
1569 | | - |
1570 | QPainterPath QPathClipper::clip(Operation operation) | - |
1571 | { | - |
1572 | op = operation; executed (the execution status of this line is deduced): op = operation; | - |
1573 | | - |
1574 | if (op != Simplify) { evaluated: op != Simplify yes Evaluation Count:148 | yes Evaluation Count:54 |
| 54-148 |
1575 | if (subjectPath == clipPath) evaluated: subjectPath == clipPath yes Evaluation Count:57 | yes Evaluation Count:91 |
| 57-91 |
1576 | return op == BoolSub ? QPainterPath() : subjectPath; executed: return op == BoolSub ? QPainterPath() : subjectPath; Execution Count:57 | 57 |
1577 | | - |
1578 | bool subjectIsRect = pathToRect(subjectPath, 0); executed (the execution status of this line is deduced): bool subjectIsRect = pathToRect(subjectPath, 0); | - |
1579 | bool clipIsRect = pathToRect(clipPath, 0); executed (the execution status of this line is deduced): bool clipIsRect = pathToRect(clipPath, 0); | - |
1580 | | - |
1581 | const QRectF clipBounds = clipPath.boundingRect(); executed (the execution status of this line is deduced): const QRectF clipBounds = clipPath.boundingRect(); | - |
1582 | const QRectF subjectBounds = subjectPath.boundingRect(); executed (the execution status of this line is deduced): const QRectF subjectBounds = subjectPath.boundingRect(); | - |
1583 | | - |
1584 | if (!clipBounds.intersects(subjectBounds)) { evaluated: !clipBounds.intersects(subjectBounds) yes Evaluation Count:6 | yes Evaluation Count:85 |
| 6-85 |
1585 | switch (op) { | - |
1586 | case BoolSub: | - |
1587 | return subjectPath; never executed: return subjectPath; | 0 |
1588 | case BoolAnd: | - |
1589 | return QPainterPath(); never executed: return QPainterPath(); | 0 |
1590 | case BoolOr: { | - |
1591 | QPainterPath result = subjectPath; never executed (the execution status of this line is deduced): QPainterPath result = subjectPath; | - |
1592 | if (result.fillRule() == clipPath.fillRule()) { partially evaluated: result.fillRule() == clipPath.fillRule() yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
1593 | result.addPath(clipPath); executed (the execution status of this line is deduced): result.addPath(clipPath); | - |
1594 | } else if (result.fillRule() == Qt::WindingFill) { executed: } Execution Count:6 never evaluated: result.fillRule() == Qt::WindingFill | 0-6 |
1595 | result = result.simplified(); never executed (the execution status of this line is deduced): result = result.simplified(); | - |
1596 | result.addPath(clipPath); never executed (the execution status of this line is deduced): result.addPath(clipPath); | - |
1597 | } else { | 0 |
1598 | result.addPath(clipPath.simplified()); never executed (the execution status of this line is deduced): result.addPath(clipPath.simplified()); | - |
1599 | } | 0 |
1600 | return result; executed: return result; Execution Count:6 | 6 |
1601 | } | - |
1602 | default: | - |
1603 | break; | 0 |
1604 | } | - |
1605 | } | 0 |
1606 | | - |
1607 | if (clipBounds.contains(subjectBounds)) { evaluated: clipBounds.contains(subjectBounds) yes Evaluation Count:19 | yes Evaluation Count:66 |
| 19-66 |
1608 | if (clipIsRect) { evaluated: clipIsRect yes Evaluation Count:7 | yes Evaluation Count:12 |
| 7-12 |
1609 | switch (op) { | - |
1610 | case BoolSub: | - |
1611 | return QPainterPath(); executed: return QPainterPath(); Execution Count:5 | 5 |
1612 | case BoolAnd: | - |
1613 | return subjectPath; never executed: return subjectPath; | 0 |
1614 | case BoolOr: | - |
1615 | return clipPath; executed: return clipPath; Execution Count:2 | 2 |
1616 | default: | - |
1617 | break; | 0 |
1618 | } | - |
1619 | } | 0 |
1620 | } else if (subjectBounds.contains(clipBounds)) { executed: } Execution Count:12 evaluated: subjectBounds.contains(clipBounds) yes Evaluation Count:54 | yes Evaluation Count:12 |
| 12-54 |
1621 | if (subjectIsRect) { partially evaluated: subjectIsRect yes Evaluation Count:54 | no Evaluation Count:0 |
| 0-54 |
1622 | switch (op) { | - |
1623 | case BoolSub: | - |
1624 | if (clipPath.fillRule() == Qt::OddEvenFill) { evaluated: clipPath.fillRule() == Qt::OddEvenFill yes Evaluation Count:4 | yes Evaluation Count:50 |
| 4-50 |
1625 | QPainterPath result = clipPath; executed (the execution status of this line is deduced): QPainterPath result = clipPath; | - |
1626 | result.addRect(subjectBounds); executed (the execution status of this line is deduced): result.addRect(subjectBounds); | - |
1627 | return result; executed: return result; Execution Count:4 | 4 |
1628 | } else { | - |
1629 | QPainterPath result = clipPath.simplified(); executed (the execution status of this line is deduced): QPainterPath result = clipPath.simplified(); | - |
1630 | result.addRect(subjectBounds); executed (the execution status of this line is deduced): result.addRect(subjectBounds); | - |
1631 | return result; executed: return result; Execution Count:50 | 50 |
1632 | } | - |
1633 | case BoolAnd: | - |
1634 | return clipPath; never executed: return clipPath; | 0 |
1635 | case BoolOr: | - |
1636 | return subjectPath; never executed: return subjectPath; | 0 |
1637 | default: | - |
1638 | break; | 0 |
1639 | } | - |
1640 | } | 0 |
1641 | } | 0 |
1642 | | - |
1643 | if (op == BoolAnd) { evaluated: op == BoolAnd yes Evaluation Count:8 | yes Evaluation Count:16 |
| 8-16 |
1644 | if (subjectIsRect) partially evaluated: subjectIsRect yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-8 |
1645 | return intersect(clipPath, subjectBounds); executed: return intersect(clipPath, subjectBounds); Execution Count:8 | 8 |
1646 | else if (clipIsRect) never evaluated: clipIsRect | 0 |
1647 | return intersect(subjectPath, clipBounds); never executed: return intersect(subjectPath, clipBounds); | 0 |
1648 | } | - |
1649 | } executed: } Execution Count:16 | 16 |
1650 | | - |
1651 | QWingedEdge list(subjectPath, clipPath); executed (the execution status of this line is deduced): QWingedEdge list(subjectPath, clipPath); | - |
1652 | | - |
1653 | doClip(list, ClipMode); executed (the execution status of this line is deduced): doClip(list, ClipMode); | - |
1654 | | - |
1655 | QPainterPath path = list.toPath(); executed (the execution status of this line is deduced): QPainterPath path = list.toPath(); | - |
1656 | return path; executed: return path; Execution Count:70 | 70 |
1657 | } | - |
1658 | | - |
1659 | bool QPathClipper::doClip(QWingedEdge &list, ClipperMode mode) | - |
1660 | { | - |
1661 | QVector<qreal> y_coords; executed (the execution status of this line is deduced): QVector<qreal> y_coords; | - |
1662 | y_coords.reserve(list.vertexCount()); executed (the execution status of this line is deduced): y_coords.reserve(list.vertexCount()); | - |
1663 | for (int i = 0; i < list.vertexCount(); ++i) evaluated: i < list.vertexCount() yes Evaluation Count:430 | yes Evaluation Count:70 |
| 70-430 |
1664 | y_coords << list.vertex(i)->y; executed: y_coords << list.vertex(i)->y; Execution Count:430 | 430 |
1665 | | - |
1666 | qSort(y_coords.begin(), y_coords.end()); executed (the execution status of this line is deduced): qSort(y_coords.begin(), y_coords.end()); | - |
1667 | y_coords.resize(qRemoveDuplicates(y_coords.begin(), y_coords.end(), fuzzyCompare) - y_coords.begin()); executed (the execution status of this line is deduced): y_coords.resize(qRemoveDuplicates(y_coords.begin(), y_coords.end(), fuzzyCompare) - y_coords.begin()); | - |
1668 | | - |
1669 | #ifdef QDEBUG_CLIPPER | - |
1670 | printf("sorted y coords:\n"); | - |
1671 | for (int i = 0; i < y_coords.size(); ++i) { | - |
1672 | printf("%.9f\n", y_coords[i]); | - |
1673 | } | - |
1674 | #endif | - |
1675 | | - |
1676 | bool found; executed (the execution status of this line is deduced): bool found; | - |
1677 | do { | - |
1678 | found = false; executed (the execution status of this line is deduced): found = false; | - |
1679 | int index = 0; executed (the execution status of this line is deduced): int index = 0; | - |
1680 | qreal maxHeight = 0; executed (the execution status of this line is deduced): qreal maxHeight = 0; | - |
1681 | for (int i = 0; i < list.edgeCount(); ++i) { evaluated: i < list.edgeCount() yes Evaluation Count:1204 | yes Evaluation Count:156 |
| 156-1204 |
1682 | QPathEdge *edge = list.edge(i); executed (the execution status of this line is deduced): QPathEdge *edge = list.edge(i); | - |
1683 | | - |
1684 | // have both sides of this edge already been handled? | - |
1685 | if ((edge->flag & 0x3) == 0x3) evaluated: (edge->flag & 0x3) == 0x3 yes Evaluation Count:600 | yes Evaluation Count:604 |
| 600-604 |
1686 | continue; executed: continue; Execution Count:600 | 600 |
1687 | | - |
1688 | QPathVertex *a = list.vertex(edge->first); executed (the execution status of this line is deduced): QPathVertex *a = list.vertex(edge->first); | - |
1689 | QPathVertex *b = list.vertex(edge->second); executed (the execution status of this line is deduced): QPathVertex *b = list.vertex(edge->second); | - |
1690 | | - |
1691 | if (qFuzzyCompare(a->y, b->y)) evaluated: qFuzzyCompare(a->y, b->y) yes Evaluation Count:320 | yes Evaluation Count:284 |
| 284-320 |
1692 | continue; executed: continue; Execution Count:320 | 320 |
1693 | | - |
1694 | found = true; executed (the execution status of this line is deduced): found = true; | - |
1695 | | - |
1696 | qreal height = qAbs(a->y - b->y); executed (the execution status of this line is deduced): qreal height = qAbs(a->y - b->y); | - |
1697 | if (height > maxHeight) { evaluated: height > maxHeight yes Evaluation Count:100 | yes Evaluation Count:184 |
| 100-184 |
1698 | index = i; executed (the execution status of this line is deduced): index = i; | - |
1699 | maxHeight = height; executed (the execution status of this line is deduced): maxHeight = height; | - |
1700 | } executed: } Execution Count:100 | 100 |
1701 | } executed: } Execution Count:284 | 284 |
1702 | | - |
1703 | if (found) { evaluated: found yes Evaluation Count:86 | yes Evaluation Count:70 |
| 70-86 |
1704 | QPathEdge *edge = list.edge(index); executed (the execution status of this line is deduced): QPathEdge *edge = list.edge(index); | - |
1705 | | - |
1706 | QPathVertex *a = list.vertex(edge->first); executed (the execution status of this line is deduced): QPathVertex *a = list.vertex(edge->first); | - |
1707 | QPathVertex *b = list.vertex(edge->second); executed (the execution status of this line is deduced): QPathVertex *b = list.vertex(edge->second); | - |
1708 | | - |
1709 | // FIXME: this can be optimized by using binary search | - |
1710 | const int first = qFuzzyFind(y_coords.begin(), y_coords.end(), qMin(a->y, b->y)) - y_coords.begin(); executed (the execution status of this line is deduced): const int first = qFuzzyFind(y_coords.begin(), y_coords.end(), qMin(a->y, b->y)) - y_coords.begin(); | - |
1711 | const int last = qFuzzyFind(y_coords.begin() + first, y_coords.end(), qMax(a->y, b->y)) - y_coords.begin(); executed (the execution status of this line is deduced): const int last = qFuzzyFind(y_coords.begin() + first, y_coords.end(), qMax(a->y, b->y)) - y_coords.begin(); | - |
1712 | | - |
1713 | Q_ASSERT(first < y_coords.size() - 1); executed (the execution status of this line is deduced): qt_noop(); | - |
1714 | Q_ASSERT(last < y_coords.size()); executed (the execution status of this line is deduced): qt_noop(); | - |
1715 | | - |
1716 | qreal bestY = 0.5 * (y_coords[first] + y_coords[first+1]); executed (the execution status of this line is deduced): qreal bestY = 0.5 * (y_coords[first] + y_coords[first+1]); | - |
1717 | qreal biggestGap = y_coords[first+1] - y_coords[first]; executed (the execution status of this line is deduced): qreal biggestGap = y_coords[first+1] - y_coords[first]; | - |
1718 | | - |
1719 | for (int i = first + 1; i < last; ++i) { evaluated: i < last yes Evaluation Count:16 | yes Evaluation Count:86 |
| 16-86 |
1720 | qreal gap = y_coords[i+1] - y_coords[i]; executed (the execution status of this line is deduced): qreal gap = y_coords[i+1] - y_coords[i]; | - |
1721 | | - |
1722 | if (gap > biggestGap) { evaluated: gap > biggestGap yes Evaluation Count:2 | yes Evaluation Count:14 |
| 2-14 |
1723 | bestY = 0.5 * (y_coords[i] + y_coords[i+1]); executed (the execution status of this line is deduced): bestY = 0.5 * (y_coords[i] + y_coords[i+1]); | - |
1724 | biggestGap = gap; executed (the execution status of this line is deduced): biggestGap = gap; | - |
1725 | } executed: } Execution Count:2 | 2 |
1726 | } executed: } Execution Count:16 | 16 |
1727 | | - |
1728 | #ifdef QDEBUG_CLIPPER | - |
1729 | printf("y: %.9f, gap: %.9f\n", bestY, biggestGap); | - |
1730 | #endif | - |
1731 | | - |
1732 | if (handleCrossingEdges(list, bestY, mode) && mode == CheckMode) partially evaluated: handleCrossingEdges(list, bestY, mode) no Evaluation Count:0 | yes Evaluation Count:86 |
never evaluated: mode == CheckMode | 0-86 |
1733 | return true; never executed: return true; | 0 |
1734 | | - |
1735 | edge->flag |= 0x3; executed (the execution status of this line is deduced): edge->flag |= 0x3; | - |
1736 | } executed: } Execution Count:86 | 86 |
1737 | } while (found); executed: } Execution Count:156 evaluated: found yes Evaluation Count:86 | yes Evaluation Count:70 |
| 70-156 |
1738 | | - |
1739 | if (mode == ClipMode) partially evaluated: mode == ClipMode yes Evaluation Count:70 | no Evaluation Count:0 |
| 0-70 |
1740 | list.simplify(); executed: list.simplify(); Execution Count:70 | 70 |
1741 | | - |
1742 | return false; executed: return false; Execution Count:70 | 70 |
1743 | } | - |
1744 | | - |
1745 | static void traverse(QWingedEdge &list, int edge, QPathEdge::Traversal traversal) | - |
1746 | { | - |
1747 | QWingedEdge::TraversalStatus status; executed (the execution status of this line is deduced): QWingedEdge::TraversalStatus status; | - |
1748 | status.edge = edge; executed (the execution status of this line is deduced): status.edge = edge; | - |
1749 | status.traversal = traversal; executed (the execution status of this line is deduced): status.traversal = traversal; | - |
1750 | status.direction = QPathEdge::Forward; executed (the execution status of this line is deduced): status.direction = QPathEdge::Forward; | - |
1751 | | - |
1752 | do { | - |
1753 | int flag = status.traversal == QPathEdge::LeftTraversal ? 1 : 2; evaluated: status.traversal == QPathEdge::LeftTraversal yes Evaluation Count:26 | yes Evaluation Count:288 |
| 26-288 |
1754 | | - |
1755 | QPathEdge *ep = list.edge(status.edge); executed (the execution status of this line is deduced): QPathEdge *ep = list.edge(status.edge); | - |
1756 | | - |
1757 | ep->flag |= (flag | (flag << 4)); executed (the execution status of this line is deduced): ep->flag |= (flag | (flag << 4)); | - |
1758 | | - |
1759 | #ifdef QDEBUG_CLIPPER | - |
1760 | qDebug() << "traverse: adding edge " << status.edge << ", mask:" << (flag << 4) <<ep->flag; | - |
1761 | #endif | - |
1762 | | - |
1763 | status = list.next(status); executed (the execution status of this line is deduced): status = list.next(status); | - |
1764 | } while (status.edge != edge); executed: } Execution Count:314 evaluated: status.edge != edge yes Evaluation Count:241 | yes Evaluation Count:73 |
| 73-314 |
1765 | } executed: } Execution Count:73 | 73 |
1766 | | - |
1767 | struct QCrossingEdge | - |
1768 | { | - |
1769 | int edge; | - |
1770 | qreal x; | - |
1771 | | - |
1772 | bool operator<(const QCrossingEdge &edge) const | - |
1773 | { | - |
1774 | return x < edge.x; executed: return x < edge.x; Execution Count:224 | 224 |
1775 | } | - |
1776 | }; | - |
1777 | | - |
1778 | static bool bool_op(bool a, bool b, QPathClipper::Operation op) | - |
1779 | { | - |
1780 | switch (op) { | - |
1781 | case QPathClipper::BoolAnd: | - |
1782 | return a && b; never executed: return a && b; | 0 |
1783 | case QPathClipper::BoolOr: // fall-through | - |
1784 | case QPathClipper::Simplify: | - |
1785 | return a || b; executed: return a || b; Execution Count:76 | 76 |
1786 | case QPathClipper::BoolSub: | - |
1787 | return a && !b; executed: return a && !b; Execution Count:56 | 56 |
1788 | default: | - |
1789 | Q_ASSERT(false); never executed (the execution status of this line is deduced): qt_noop(); | - |
1790 | return false; never executed: return false; | 0 |
1791 | } | - |
1792 | } | 0 |
1793 | | - |
1794 | bool QWingedEdge::isInside(qreal x, qreal y) const | - |
1795 | { | - |
1796 | int winding = 0; never executed (the execution status of this line is deduced): int winding = 0; | - |
1797 | for (int i = 0; i < edgeCount(); ++i) { never evaluated: i < edgeCount() | 0 |
1798 | const QPathEdge *ep = edge(i); never executed (the execution status of this line is deduced): const QPathEdge *ep = edge(i); | - |
1799 | | - |
1800 | // left xor right | - |
1801 | int w = ((ep->flag >> 4) ^ (ep->flag >> 5)) & 1; never executed (the execution status of this line is deduced): int w = ((ep->flag >> 4) ^ (ep->flag >> 5)) & 1; | - |
1802 | | - |
1803 | if (!w) | 0 |
1804 | continue; never executed: continue; | 0 |
1805 | | - |
1806 | QPointF a = *vertex(ep->first); never executed (the execution status of this line is deduced): QPointF a = *vertex(ep->first); | - |
1807 | QPointF b = *vertex(ep->second); never executed (the execution status of this line is deduced): QPointF b = *vertex(ep->second); | - |
1808 | | - |
1809 | if ((a.y() < y && b.y() > y) || (a.y() > y && b.y() < y)) { never evaluated: a.y() < y never evaluated: b.y() > y never evaluated: a.y() > y never evaluated: b.y() < y | 0 |
1810 | qreal intersectionX = a.x() + (b.x() - a.x()) * (y - a.y()) / (b.y() - a.y()); never executed (the execution status of this line is deduced): qreal intersectionX = a.x() + (b.x() - a.x()) * (y - a.y()) / (b.y() - a.y()); | - |
1811 | | - |
1812 | if (intersectionX > x) never evaluated: intersectionX > x | 0 |
1813 | winding += w; never executed: winding += w; | 0 |
1814 | } | 0 |
1815 | } | 0 |
1816 | | - |
1817 | return winding & 1; never executed: return winding & 1; | 0 |
1818 | } | - |
1819 | | - |
1820 | static QVector<QCrossingEdge> findCrossings(const QWingedEdge &list, qreal y) | - |
1821 | { | - |
1822 | QVector<QCrossingEdge> crossings; executed (the execution status of this line is deduced): QVector<QCrossingEdge> crossings; | - |
1823 | for (int i = 0; i < list.edgeCount(); ++i) { evaluated: i < list.edgeCount() yes Evaluation Count:738 | yes Evaluation Count:86 |
| 86-738 |
1824 | const QPathEdge *edge = list.edge(i); executed (the execution status of this line is deduced): const QPathEdge *edge = list.edge(i); | - |
1825 | QPointF a = *list.vertex(edge->first); executed (the execution status of this line is deduced): QPointF a = *list.vertex(edge->first); | - |
1826 | QPointF b = *list.vertex(edge->second); executed (the execution status of this line is deduced): QPointF b = *list.vertex(edge->second); | - |
1827 | | - |
1828 | if ((a.y() < y && b.y() > y) || (a.y() > y && b.y() < y)) { evaluated: a.y() < y yes Evaluation Count:345 | yes Evaluation Count:393 |
evaluated: b.y() > y yes Evaluation Count:109 | yes Evaluation Count:236 |
evaluated: a.y() > y yes Evaluation Count:393 | yes Evaluation Count:236 |
evaluated: b.y() < y yes Evaluation Count:109 | yes Evaluation Count:284 |
| 109-393 |
1829 | const qreal intersection = a.x() + (b.x() - a.x()) * (y - a.y()) / (b.y() - a.y()); executed (the execution status of this line is deduced): const qreal intersection = a.x() + (b.x() - a.x()) * (y - a.y()) / (b.y() - a.y()); | - |
1830 | const QCrossingEdge edge = { i, intersection }; executed (the execution status of this line is deduced): const QCrossingEdge edge = { i, intersection }; | - |
1831 | crossings << edge; executed (the execution status of this line is deduced): crossings << edge; | - |
1832 | } executed: } Execution Count:218 | 218 |
1833 | } executed: } Execution Count:738 | 738 |
1834 | return crossings; executed: return crossings; Execution Count:86 | 86 |
1835 | } | - |
1836 | | - |
1837 | bool QPathClipper::handleCrossingEdges(QWingedEdge &list, qreal y, ClipperMode mode) | - |
1838 | { | - |
1839 | QVector<QCrossingEdge> crossings = findCrossings(list, y); executed (the execution status of this line is deduced): QVector<QCrossingEdge> crossings = findCrossings(list, y); | - |
1840 | | - |
1841 | Q_ASSERT(!crossings.isEmpty()); executed (the execution status of this line is deduced): qt_noop(); | - |
1842 | qSort(crossings.begin(), crossings.end()); executed (the execution status of this line is deduced): qSort(crossings.begin(), crossings.end()); | - |
1843 | | - |
1844 | int windingA = 0; executed (the execution status of this line is deduced): int windingA = 0; | - |
1845 | int windingB = 0; executed (the execution status of this line is deduced): int windingB = 0; | - |
1846 | | - |
1847 | int windingD = 0; executed (the execution status of this line is deduced): int windingD = 0; | - |
1848 | | - |
1849 | #ifdef QDEBUG_CLIPPER | - |
1850 | qDebug() << "crossings:" << crossings.size(); | - |
1851 | #endif | - |
1852 | for (int i = 0; i < crossings.size() - 1; ++i) { evaluated: i < crossings.size() - 1 yes Evaluation Count:132 | yes Evaluation Count:86 |
| 86-132 |
1853 | int ei = crossings.at(i).edge; executed (the execution status of this line is deduced): int ei = crossings.at(i).edge; | - |
1854 | const QPathEdge *edge = list.edge(ei); executed (the execution status of this line is deduced): const QPathEdge *edge = list.edge(ei); | - |
1855 | | - |
1856 | windingA += edge->windingA; executed (the execution status of this line is deduced): windingA += edge->windingA; | - |
1857 | windingB += edge->windingB; executed (the execution status of this line is deduced): windingB += edge->windingB; | - |
1858 | | - |
1859 | const bool hasLeft = (edge->flag >> 4) & 1; executed (the execution status of this line is deduced): const bool hasLeft = (edge->flag >> 4) & 1; | - |
1860 | const bool hasRight = (edge->flag >> 4) & 2; executed (the execution status of this line is deduced): const bool hasRight = (edge->flag >> 4) & 2; | - |
1861 | | - |
1862 | windingD += hasLeft ^ hasRight; executed (the execution status of this line is deduced): windingD += hasLeft ^ hasRight; | - |
1863 | | - |
1864 | const bool inA = (windingA & aMask) != 0; executed (the execution status of this line is deduced): const bool inA = (windingA & aMask) != 0; | - |
1865 | const bool inB = (windingB & bMask) != 0; executed (the execution status of this line is deduced): const bool inB = (windingB & bMask) != 0; | - |
1866 | const bool inD = (windingD & 0x1) != 0; executed (the execution status of this line is deduced): const bool inD = (windingD & 0x1) != 0; | - |
1867 | | - |
1868 | const bool inside = bool_op(inA, inB, op); executed (the execution status of this line is deduced): const bool inside = bool_op(inA, inB, op); | - |
1869 | const bool add = inD ^ inside; executed (the execution status of this line is deduced): const bool add = inD ^ inside; | - |
1870 | | - |
1871 | #ifdef QDEBUG_CLIPPER | - |
1872 | printf("y %f, x %f, inA: %d, inB: %d, inD: %d, inside: %d, flag: %x, bezier: %p, edge: %d\n", y, crossings.at(i).x, inA, inB, inD, inside, edge->flag, edge->bezier, ei); | - |
1873 | #endif | - |
1874 | | - |
1875 | if (add) { evaluated: add yes Evaluation Count:73 | yes Evaluation Count:59 |
| 59-73 |
1876 | if (mode == CheckMode) partially evaluated: mode == CheckMode no Evaluation Count:0 | yes Evaluation Count:73 |
| 0-73 |
1877 | return true; never executed: return true; | 0 |
1878 | | - |
1879 | qreal y0 = list.vertex(edge->first)->y; executed (the execution status of this line is deduced): qreal y0 = list.vertex(edge->first)->y; | - |
1880 | qreal y1 = list.vertex(edge->second)->y; executed (the execution status of this line is deduced): qreal y1 = list.vertex(edge->second)->y; | - |
1881 | | - |
1882 | if (y0 < y1) { evaluated: y0 < y1 yes Evaluation Count:6 | yes Evaluation Count:67 |
| 6-67 |
1883 | if (!(edge->flag & 1)) partially evaluated: !(edge->flag & 1) yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
1884 | traverse(list, ei, QPathEdge::LeftTraversal); executed: traverse(list, ei, QPathEdge::LeftTraversal); Execution Count:6 | 6 |
1885 | | - |
1886 | if (!(edge->flag & 2)) partially evaluated: !(edge->flag & 2) no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
1887 | clear(list, ei, QPathEdge::RightTraversal); never executed: clear(list, ei, QPathEdge::RightTraversal); | 0 |
1888 | } else { executed: } Execution Count:6 | 6 |
1889 | if (!(edge->flag & 1)) evaluated: !(edge->flag & 1) yes Evaluation Count:60 | yes Evaluation Count:7 |
| 7-60 |
1890 | clear(list, ei, QPathEdge::LeftTraversal); executed: clear(list, ei, QPathEdge::LeftTraversal); Execution Count:60 | 60 |
1891 | | - |
1892 | if (!(edge->flag & 2)) partially evaluated: !(edge->flag & 2) yes Evaluation Count:67 | no Evaluation Count:0 |
| 0-67 |
1893 | traverse(list, ei, QPathEdge::RightTraversal); executed: traverse(list, ei, QPathEdge::RightTraversal); Execution Count:67 | 67 |
1894 | } executed: } Execution Count:67 | 67 |
1895 | | - |
1896 | ++windingD; executed (the execution status of this line is deduced): ++windingD; | - |
1897 | } else { executed: } Execution Count:73 | 73 |
1898 | if (!(edge->flag & 1)) evaluated: !(edge->flag & 1) yes Evaluation Count:20 | yes Evaluation Count:39 |
| 20-39 |
1899 | clear(list, ei, QPathEdge::LeftTraversal); executed: clear(list, ei, QPathEdge::LeftTraversal); Execution Count:20 | 20 |
1900 | | - |
1901 | if (!(edge->flag & 2)) evaluated: !(edge->flag & 2) yes Evaluation Count:31 | yes Evaluation Count:28 |
| 28-31 |
1902 | clear(list, ei, QPathEdge::RightTraversal); executed: clear(list, ei, QPathEdge::RightTraversal); Execution Count:31 | 31 |
1903 | } executed: } Execution Count:59 | 59 |
1904 | } | - |
1905 | | - |
1906 | return false; executed: return false; Execution Count:86 | 86 |
1907 | } | - |
1908 | | - |
1909 | namespace { | - |
1910 | | - |
1911 | QList<QPainterPath> toSubpaths(const QPainterPath &path) | - |
1912 | { | - |
1913 | | - |
1914 | QList<QPainterPath> subpaths; executed (the execution status of this line is deduced): QList<QPainterPath> subpaths; | - |
1915 | if (path.isEmpty()) partially evaluated: path.isEmpty() no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
1916 | return subpaths; never executed: return subpaths; | 0 |
1917 | | - |
1918 | QPainterPath current; executed (the execution status of this line is deduced): QPainterPath current; | - |
1919 | for (int i = 0; i < path.elementCount(); ++i) { evaluated: i < path.elementCount() yes Evaluation Count:128 | yes Evaluation Count:8 |
| 8-128 |
1920 | const QPainterPath::Element &e = path.elementAt(i); executed (the execution status of this line is deduced): const QPainterPath::Element &e = path.elementAt(i); | - |
1921 | switch (e.type) { | - |
1922 | case QPainterPath::MoveToElement: | - |
1923 | if (current.elementCount() > 1) evaluated: current.elementCount() > 1 yes Evaluation Count:8 | yes Evaluation Count:8 |
| 8 |
1924 | subpaths += current; executed: subpaths += current; Execution Count:8 | 8 |
1925 | current = QPainterPath(); executed (the execution status of this line is deduced): current = QPainterPath(); | - |
1926 | current.moveTo(e); executed (the execution status of this line is deduced): current.moveTo(e); | - |
1927 | break; executed: break; Execution Count:16 | 16 |
1928 | case QPainterPath::LineToElement: | - |
1929 | current.lineTo(e); executed (the execution status of this line is deduced): current.lineTo(e); | - |
1930 | break; executed: break; Execution Count:112 | 112 |
1931 | case QPainterPath::CurveToElement: { | - |
1932 | current.cubicTo(e, path.elementAt(i + 1), path.elementAt(i + 2)); never executed (the execution status of this line is deduced): current.cubicTo(e, path.elementAt(i + 1), path.elementAt(i + 2)); | - |
1933 | i+=2; never executed (the execution status of this line is deduced): i+=2; | - |
1934 | break; | 0 |
1935 | } | - |
1936 | case QPainterPath::CurveToDataElement: | - |
1937 | Q_ASSERT(!"toSubpaths(), bad element type"); never executed (the execution status of this line is deduced): qt_noop(); | - |
1938 | break; | 0 |
1939 | } | - |
1940 | } executed: } Execution Count:128 | 128 |
1941 | | - |
1942 | if (current.elementCount() > 1) partially evaluated: current.elementCount() > 1 yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-8 |
1943 | subpaths << current; executed: subpaths << current; Execution Count:8 | 8 |
1944 | | - |
1945 | return subpaths; executed: return subpaths; Execution Count:8 | 8 |
1946 | } | - |
1947 | | - |
1948 | enum Edge | - |
1949 | { | - |
1950 | Left, Top, Right, Bottom | - |
1951 | }; | - |
1952 | | - |
1953 | static bool isVertical(Edge edge) | - |
1954 | { | - |
1955 | return edge == Left || edge == Right; never executed: return edge == Left || edge == Right; | 0 |
1956 | } | - |
1957 | | - |
1958 | template <Edge edge> | - |
1959 | bool compare(const QPointF &p, qreal t) | - |
1960 | { | - |
1961 | switch (edge) | - |
1962 | { | - |
1963 | case Left: | - |
1964 | return p.x() < t; executed: return p.x() < t; Execution Count:96 | 96 |
1965 | case Right: | - |
1966 | return p.x() > t; executed: return p.x() > t; Execution Count:200 | 200 |
1967 | case Top: | - |
1968 | return p.y() < t; executed: return p.y() < t; Execution Count:48 | 48 |
1969 | default: | - |
1970 | return p.y() > t; executed: return p.y() > t; Execution Count:152 | 152 |
1971 | } | - |
1972 | } | 0 |
1973 | | - |
1974 | template <Edge edge> | - |
1975 | QPointF intersectLine(const QPointF &a, const QPointF &b, qreal t) | - |
1976 | { | - |
1977 | QLineF line(a, b); executed (the execution status of this line is deduced): QLineF line(a, b); | - |
1978 | switch (edge) { | - |
1979 | case Left: // fall-through | - |
1980 | case Right: | - |
1981 | return line.pointAt((t - a.x()) / (b.x() - a.x())); executed: return line.pointAt((t - a.x()) / (b.x() - a.x())); Execution Count:44 | 44 |
1982 | default: | - |
1983 | return line.pointAt((t - a.y()) / (b.y() - a.y())); executed: return line.pointAt((t - a.y()) / (b.y() - a.y())); Execution Count:44 | 44 |
1984 | } | - |
1985 | } | 0 |
1986 | | - |
1987 | void addLine(QPainterPath &path, const QLineF &line) | - |
1988 | { | - |
1989 | if (path.elementCount() > 0) evaluated: path.elementCount() > 0 yes Evaluation Count:118 | yes Evaluation Count:44 |
| 44-118 |
1990 | path.lineTo(line.p1()); executed: path.lineTo(line.p1()); Execution Count:118 | 118 |
1991 | else | - |
1992 | path.moveTo(line.p1()); executed: path.moveTo(line.p1()); Execution Count:44 | 44 |
1993 | | - |
1994 | path.lineTo(line.p2()); executed (the execution status of this line is deduced): path.lineTo(line.p2()); | - |
1995 | } executed: } Execution Count:162 | 162 |
1996 | | - |
1997 | template <Edge edge> | - |
1998 | void clipLine(const QPointF &a, const QPointF &b, qreal t, QPainterPath &result) | - |
1999 | { | - |
2000 | bool outA = compare<edge>(a, t); executed (the execution status of this line is deduced): bool outA = compare<edge>(a, t); | - |
2001 | bool outB = compare<edge>(b, t); executed (the execution status of this line is deduced): bool outB = compare<edge>(b, t); | - |
2002 | if (outA && outB) evaluated: outA yes Evaluation Count:130 | yes Evaluation Count:118 |
evaluated: outB yes Evaluation Count:86 | yes Evaluation Count:44 |
| 44-130 |
2003 | return; executed: return; Execution Count:86 | 86 |
2004 | | - |
2005 | if (outA) evaluated: outA yes Evaluation Count:44 | yes Evaluation Count:118 |
| 44-118 |
2006 | addLine(result, QLineF(intersectLine<edge>(a, b, t), b)); executed: addLine(result, QLineF(intersectLine<edge>(a, b, t), b)); Execution Count:44 | 44 |
2007 | else if(outB) evaluated: outB yes Evaluation Count:44 | yes Evaluation Count:74 |
| 44-74 |
2008 | addLine(result, QLineF(a, intersectLine<edge>(a, b, t))); executed: addLine(result, QLineF(a, intersectLine<edge>(a, b, t))); Execution Count:44 | 44 |
2009 | else | - |
2010 | addLine(result, QLineF(a, b)); executed: addLine(result, QLineF(a, b)); Execution Count:74 | 74 |
2011 | } | - |
2012 | | - |
2013 | void addBezier(QPainterPath &path, const QBezier &bezier) | - |
2014 | { | - |
2015 | if (path.elementCount() > 0) never evaluated: path.elementCount() > 0 | 0 |
2016 | path.lineTo(bezier.pt1()); never executed: path.lineTo(bezier.pt1()); | 0 |
2017 | else | - |
2018 | path.moveTo(bezier.pt1()); never executed: path.moveTo(bezier.pt1()); | 0 |
2019 | | - |
2020 | path.cubicTo(bezier.pt2(), bezier.pt3(), bezier.pt4()); never executed (the execution status of this line is deduced): path.cubicTo(bezier.pt2(), bezier.pt3(), bezier.pt4()); | - |
2021 | } | 0 |
2022 | | - |
2023 | template <Edge edge> | - |
2024 | void clipBezier(const QPointF &a, const QPointF &b, const QPointF &c, const QPointF &d, qreal t, QPainterPath &result) | - |
2025 | { | - |
2026 | QBezier bezier = QBezier::fromPoints(a, b, c, d); never executed (the execution status of this line is deduced): QBezier bezier = QBezier::fromPoints(a, b, c, d); | - |
2027 | | - |
2028 | bool outA = compare<edge>(a, t); never executed (the execution status of this line is deduced): bool outA = compare<edge>(a, t); | - |
2029 | bool outB = compare<edge>(b, t); never executed (the execution status of this line is deduced): bool outB = compare<edge>(b, t); | - |
2030 | bool outC = compare<edge>(c, t); never executed (the execution status of this line is deduced): bool outC = compare<edge>(c, t); | - |
2031 | bool outD = compare<edge>(d, t); never executed (the execution status of this line is deduced): bool outD = compare<edge>(d, t); | - |
2032 | | - |
2033 | int outCount = int(outA) + int(outB) + int(outC) + int(outD); never executed (the execution status of this line is deduced): int outCount = int(outA) + int(outB) + int(outC) + int(outD); | - |
2034 | | - |
2035 | if (outCount == 4) never evaluated: outCount == 4 | 0 |
2036 | return; | 0 |
2037 | | - |
2038 | if (outCount == 0) { never evaluated: outCount == 0 | 0 |
2039 | addBezier(result, bezier); never executed (the execution status of this line is deduced): addBezier(result, bezier); | - |
2040 | return; | 0 |
2041 | } | - |
2042 | | - |
2043 | QTransform flip = isVertical(edge) ? QTransform(0, 1, 1, 0, 0, 0) : QTransform(); never evaluated: isVertical(edge) | 0 |
2044 | QBezier unflipped = bezier; never executed (the execution status of this line is deduced): QBezier unflipped = bezier; | - |
2045 | QBezier flipped = bezier.mapBy(flip); never executed (the execution status of this line is deduced): QBezier flipped = bezier.mapBy(flip); | - |
2046 | | - |
2047 | qreal t0 = 0, t1 = 1; never executed (the execution status of this line is deduced): qreal t0 = 0, t1 = 1; | - |
2048 | int stationary = flipped.stationaryYPoints(t0, t1); never executed (the execution status of this line is deduced): int stationary = flipped.stationaryYPoints(t0, t1); | - |
2049 | | - |
2050 | qreal segments[4]; never executed (the execution status of this line is deduced): qreal segments[4]; | - |
2051 | QPointF points[4]; never executed (the execution status of this line is deduced): QPointF points[4]; | - |
2052 | points[0] = unflipped.pt1(); never executed (the execution status of this line is deduced): points[0] = unflipped.pt1(); | - |
2053 | segments[0] = 0; never executed (the execution status of this line is deduced): segments[0] = 0; | - |
2054 | | - |
2055 | int segmentCount = 0; never executed (the execution status of this line is deduced): int segmentCount = 0; | - |
2056 | if (stationary > 0) { never evaluated: stationary > 0 | 0 |
2057 | ++segmentCount; never executed (the execution status of this line is deduced): ++segmentCount; | - |
2058 | segments[segmentCount] = t0; never executed (the execution status of this line is deduced): segments[segmentCount] = t0; | - |
2059 | points[segmentCount] = unflipped.pointAt(t0); never executed (the execution status of this line is deduced): points[segmentCount] = unflipped.pointAt(t0); | - |
2060 | } | 0 |
2061 | if (stationary > 1) { never evaluated: stationary > 1 | 0 |
2062 | ++segmentCount; never executed (the execution status of this line is deduced): ++segmentCount; | - |
2063 | segments[segmentCount] = t1; never executed (the execution status of this line is deduced): segments[segmentCount] = t1; | - |
2064 | points[segmentCount] = unflipped.pointAt(t1); never executed (the execution status of this line is deduced): points[segmentCount] = unflipped.pointAt(t1); | - |
2065 | } | 0 |
2066 | ++segmentCount; never executed (the execution status of this line is deduced): ++segmentCount; | - |
2067 | segments[segmentCount] = 1; never executed (the execution status of this line is deduced): segments[segmentCount] = 1; | - |
2068 | points[segmentCount] = unflipped.pt4(); never executed (the execution status of this line is deduced): points[segmentCount] = unflipped.pt4(); | - |
2069 | | - |
2070 | qreal lastIntersection = 0; never executed (the execution status of this line is deduced): qreal lastIntersection = 0; | - |
2071 | for (int i = 0; i < segmentCount; ++i) { never evaluated: i < segmentCount | 0 |
2072 | outA = compare<edge>(points[i], t); never executed (the execution status of this line is deduced): outA = compare<edge>(points[i], t); | - |
2073 | outB = compare<edge>(points[i+1], t); never executed (the execution status of this line is deduced): outB = compare<edge>(points[i+1], t); | - |
2074 | | - |
2075 | if (outA != outB) { never evaluated: outA != outB | 0 |
2076 | qreal intersection = flipped.tForY(segments[i], segments[i+1], t); never executed (the execution status of this line is deduced): qreal intersection = flipped.tForY(segments[i], segments[i+1], t); | - |
2077 | | - |
2078 | if (outB) | 0 |
2079 | addBezier(result, unflipped.getSubRange(lastIntersection, intersection)); never executed: addBezier(result, unflipped.getSubRange(lastIntersection, intersection)); | 0 |
2080 | | - |
2081 | lastIntersection = intersection; never executed (the execution status of this line is deduced): lastIntersection = intersection; | - |
2082 | } | 0 |
2083 | } | 0 |
2084 | | - |
2085 | if (!outB) | 0 |
2086 | addBezier(result, unflipped.getSubRange(lastIntersection, 1)); never executed: addBezier(result, unflipped.getSubRange(lastIntersection, 1)); | 0 |
2087 | } | 0 |
2088 | | - |
2089 | // clips a single subpath against a single edge | - |
2090 | template <Edge edge> | - |
2091 | QPainterPath clip(const QPainterPath &path, qreal t) | - |
2092 | { | - |
2093 | QPainterPath result; executed (the execution status of this line is deduced): QPainterPath result; | - |
2094 | for (int i = 1; i < path.elementCount(); ++i) { evaluated: i < path.elementCount() yes Evaluation Count:238 | yes Evaluation Count:44 |
| 44-238 |
2095 | const QPainterPath::Element &element = path.elementAt(i); executed (the execution status of this line is deduced): const QPainterPath::Element &element = path.elementAt(i); | - |
2096 | Q_ASSERT(!element.isMoveTo()); executed (the execution status of this line is deduced): qt_noop(); | - |
2097 | if (element.isLineTo()) { partially evaluated: element.isLineTo() yes Evaluation Count:238 | no Evaluation Count:0 |
| 0-238 |
2098 | clipLine<edge>(path.elementAt(i-1), path.elementAt(i), t, result); executed (the execution status of this line is deduced): clipLine<edge>(path.elementAt(i-1), path.elementAt(i), t, result); | - |
2099 | } else { executed: } Execution Count:238 | 238 |
2100 | clipBezier<edge>(path.elementAt(i-1), path.elementAt(i), path.elementAt(i+1), path.elementAt(i+2), t, result); never executed (the execution status of this line is deduced): clipBezier<edge>(path.elementAt(i-1), path.elementAt(i), path.elementAt(i+1), path.elementAt(i+2), t, result); | - |
2101 | i += 2; never executed (the execution status of this line is deduced): i += 2; | - |
2102 | } | 0 |
2103 | } | - |
2104 | | - |
2105 | int last = path.elementCount() - 1; executed (the execution status of this line is deduced): int last = path.elementCount() - 1; | - |
2106 | if (QPointF(path.elementAt(last)) != QPointF(path.elementAt(0))) evaluated: QPointF(path.elementAt(last)) != QPointF(path.elementAt(0)) yes Evaluation Count:10 | yes Evaluation Count:34 |
| 10-34 |
2107 | clipLine<edge>(path.elementAt(last), path.elementAt(0), t, result); executed: clipLine<edge>(path.elementAt(last), path.elementAt(0), t, result); Execution Count:10 | 10 |
2108 | | - |
2109 | return result; executed: return result; Execution Count:44 | 44 |
2110 | } | - |
2111 | | - |
2112 | QPainterPath intersectPath(const QPainterPath &path, const QRectF &rect) | - |
2113 | { | - |
2114 | QList<QPainterPath> subpaths = toSubpaths(path); executed (the execution status of this line is deduced): QList<QPainterPath> subpaths = toSubpaths(path); | - |
2115 | | - |
2116 | QPainterPath result; executed (the execution status of this line is deduced): QPainterPath result; | - |
2117 | result.setFillRule(path.fillRule()); executed (the execution status of this line is deduced): result.setFillRule(path.fillRule()); | - |
2118 | for (int i = 0; i < subpaths.size(); ++i) { evaluated: i < subpaths.size() yes Evaluation Count:16 | yes Evaluation Count:8 |
| 8-16 |
2119 | QPainterPath subPath = subpaths.at(i); executed (the execution status of this line is deduced): QPainterPath subPath = subpaths.at(i); | - |
2120 | QRectF bounds = subPath.boundingRect(); executed (the execution status of this line is deduced): QRectF bounds = subPath.boundingRect(); | - |
2121 | if (bounds.intersects(rect)) { partially evaluated: bounds.intersects(rect) yes Evaluation Count:16 | no Evaluation Count:0 |
| 0-16 |
2122 | if (bounds.left() < rect.left()) evaluated: bounds.left() < rect.left() yes Evaluation Count:6 | yes Evaluation Count:10 |
| 6-10 |
2123 | subPath = clip<Left>(subPath, rect.left()); executed: subPath = clip<Left>(subPath, rect.left()); Execution Count:6 | 6 |
2124 | if (bounds.right() > rect.right()) partially evaluated: bounds.right() > rect.right() yes Evaluation Count:16 | no Evaluation Count:0 |
| 0-16 |
2125 | subPath = clip<Right>(subPath, rect.right()); executed: subPath = clip<Right>(subPath, rect.right()); Execution Count:16 | 16 |
2126 | | - |
2127 | bounds = subPath.boundingRect(); executed (the execution status of this line is deduced): bounds = subPath.boundingRect(); | - |
2128 | | - |
2129 | if (bounds.top() < rect.top()) evaluated: bounds.top() < rect.top() yes Evaluation Count:6 | yes Evaluation Count:10 |
| 6-10 |
2130 | subPath = clip<Top>(subPath, rect.top()); executed: subPath = clip<Top>(subPath, rect.top()); Execution Count:6 | 6 |
2131 | if (bounds.bottom() > rect.bottom()) partially evaluated: bounds.bottom() > rect.bottom() yes Evaluation Count:16 | no Evaluation Count:0 |
| 0-16 |
2132 | subPath = clip<Bottom>(subPath, rect.bottom()); executed: subPath = clip<Bottom>(subPath, rect.bottom()); Execution Count:16 | 16 |
2133 | | - |
2134 | if (subPath.elementCount() > 1) partially evaluated: subPath.elementCount() > 1 yes Evaluation Count:16 | no Evaluation Count:0 |
| 0-16 |
2135 | result.addPath(subPath); executed: result.addPath(subPath); Execution Count:16 | 16 |
2136 | } executed: } Execution Count:16 | 16 |
2137 | } executed: } Execution Count:16 | 16 |
2138 | return result; executed: return result; Execution Count:8 | 8 |
2139 | } | - |
2140 | | - |
2141 | } | - |
2142 | | - |
2143 | QPainterPath QPathClipper::intersect(const QPainterPath &path, const QRectF &rect) | - |
2144 | { | - |
2145 | return intersectPath(path, rect); executed: return intersectPath(path, rect); Execution Count:8 | 8 |
2146 | } | - |
2147 | | - |
2148 | QT_END_NAMESPACE | - |
2149 | | - |
| | |