itemviews/qbsptree.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4QBspTree::QBspTree() : depth(6), visited(0) {}
executed: }
Execution Count:16
16
5 -
6void QBspTree::create(int n, int d) -
7{ -
8 -
9 if (d == -1) {
partially evaluated: d == -1
TRUEFALSE
yes
Evaluation Count:15
no
Evaluation Count:0
0-15
10 int c; -
11 for (c = 0; n; ++c)
evaluated: n
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:15
15-20
12 n = n / 10;
executed: n = n / 10;
Execution Count:20
20
13 depth = c << 1; -
14 } else {
executed: }
Execution Count:15
15
15 depth = d; -
16 }
never executed: }
0
17 depth = qMax(depth, uint(1)); -
18 -
19 nodes.resize((1 << depth) - 1); -
20 leaves.resize(1 << depth); -
21}
executed: }
Execution Count:15
15
22 -
23void QBspTree::destroy() -
24{ -
25 leaves.clear(); -
26 nodes.clear(); -
27}
executed: }
Execution Count:247
247
28 -
29void QBspTree::climbTree(const QRect &rect, callback *function, QBspTreeData data) -
30{ -
31 if (nodes.isEmpty())
partially evaluated: nodes.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:168
0-168
32 return;
never executed: return;
0
33 ++visited; -
34 climbTree(rect, function, data, 0); -
35}
executed: }
Execution Count:168
168
36 -
37void QBspTree::climbTree(const QRect &area, callback *function, QBspTreeData data, int index) -
38{ -
39 if (index >= nodes.count()) {
evaluated: index >= nodes.count()
TRUEFALSE
yes
Evaluation Count:1213
yes
Evaluation Count:2851
1213-2851
40 qt_noop(); -
41 function(leaf(index - nodes.count()), area, visited, data); -
42 return;
executed: return;
Execution Count:1213
1213
43 } -
44 -
45 Node::Type t = (Node::Type) nodes.at(index).type; -
46 -
47 int pos = nodes.at(index).pos; -
48 int idx = firstChildIndex(index); -
49 if (t == Node::VerticalPlane) {
evaluated: t == Node::VerticalPlane
TRUEFALSE
yes
Evaluation Count:1184
yes
Evaluation Count:1667
1184-1667
50 if (area.left() < pos)
evaluated: area.left() < pos
TRUEFALSE
yes
Evaluation Count:863
yes
Evaluation Count:321
321-863
51 climbTree(area, function, data, idx);
executed: climbTree(area, function, data, idx);
Execution Count:863
863
52 if (area.right() >= pos)
evaluated: area.right() >= pos
TRUEFALSE
yes
Evaluation Count:546
yes
Evaluation Count:638
546-638
53 climbTree(area, function, data, idx + 1);
executed: climbTree(area, function, data, idx + 1);
Execution Count:546
546
54 } else {
executed: }
Execution Count:1184
1184
55 if (area.top() < pos)
evaluated: area.top() < pos
TRUEFALSE
yes
Evaluation Count:1226
yes
Evaluation Count:441
441-1226
56 climbTree(area, function, data, idx);
executed: climbTree(area, function, data, idx);
Execution Count:1226
1226
57 if (area.bottom() >= pos)
evaluated: area.bottom() >= pos
TRUEFALSE
yes
Evaluation Count:734
yes
Evaluation Count:933
734-933
58 climbTree(area, function, data, idx + 1);
executed: climbTree(area, function, data, idx + 1);
Execution Count:734
734
59 }
executed: }
Execution Count:1667
1667
60} -
61 -
62void QBspTree::init(const QRect &area, int depth, NodeType type, int index) -
63{ -
64 Node::Type t = Node::None; -
65 if (type == Node::Both)
evaluated: type == Node::Both
TRUEFALSE
yes
Evaluation Count:142
yes
Evaluation Count:27
27-142
66 t = (depth & 1) ? Node::HorizontalPlane : Node::VerticalPlane;
executed: t = (depth & 1) ? Node::HorizontalPlane : Node::VerticalPlane;
Execution Count:142
evaluated: (depth & 1)
TRUEFALSE
yes
Evaluation Count:95
yes
Evaluation Count:47
47-142
67 else -
68 t = type;
executed: t = type;
Execution Count:27
27
69 QPoint center = area.center(); -
70 nodes[index].pos = (t == Node::VerticalPlane ? center.x() : center.y());
evaluated: t == Node::VerticalPlane
TRUEFALSE
yes
Evaluation Count:50
yes
Evaluation Count:119
50-119
71 nodes[index].type = t; -
72 -
73 QRect front = area; -
74 QRect back = area; -
75 -
76 if (t == Node::VerticalPlane) {
evaluated: t == Node::VerticalPlane
TRUEFALSE
yes
Evaluation Count:50
yes
Evaluation Count:119
50-119
77 front.setLeft(center.x()); -
78 back.setRight(center.x() - 1); -
79 } else {
executed: }
Execution Count:50
50
80 front.setTop(center.y()); -
81 back.setBottom(center.y() - 1); -
82 }
executed: }
Execution Count:119
119
83 -
84 int idx = firstChildIndex(index); -
85 if (--depth) {
evaluated: --depth
TRUEFALSE
yes
Evaluation Count:76
yes
Evaluation Count:93
76-93
86 init(back, depth, type, idx); -
87 init(front, depth, type, idx + 1); -
88 }
executed: }
Execution Count:76
76
89}
executed: }
Execution Count:169
169
90 -
91void QBspTree::insert(QVector<int> &leaf, const QRect &, uint, QBspTreeData data) -
92{ -
93 leaf.append(data.i); -
94}
executed: }
Execution Count:872
872
95 -
96void QBspTree::remove(QVector<int> &leaf, const QRect &, uint, QBspTreeData data) -
97{ -
98 int i = leaf.indexOf(data.i); -
99 if (i != -1)
partially evaluated: i != -1
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
0-11
100 leaf.remove(i);
executed: leaf.remove(i);
Execution Count:11
11
101}
executed: }
Execution Count:11
11
102 -
103 -
104 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial