GCC Code Coverage Report


Directory: ./
File: openvdb/openvdb/unittest/TestLeafMask.cc
Date: 2022-07-25 17:40:05
Exec Total Coverage
Lines: 226 226 100.0%
Functions: 18 18 100.0%
Branches: 184 1692 10.9%

Line Branch Exec Source
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3
4 #include <openvdb/openvdb.h>
5 #include <openvdb/Types.h>
6 #include <openvdb/tools/Filter.h>
7 #include <openvdb/tree/LeafNode.h>
8 #include <openvdb/util/logging.h>
9 #include "util.h" // for unittest_util::makeSphere()
10 #include <gtest/gtest.h>
11 #include <set>
12
13 15 class TestLeafMask: public ::testing::Test
14 {
15 public:
16 15 void SetUp() override { openvdb::initialize(); }
17 15 void TearDown() override { openvdb::uninitialize(); }
18 };
19
20
21 typedef openvdb::tree::LeafNode<openvdb::ValueMask, 3> LeafType;
22
23
24 ////////////////////////////////////////
25
26
27
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 TEST_F(TestLeafMask, testGetValue)
28 {
29 {
30 LeafType leaf1(openvdb::Coord(0, 0, 0));
31 1 openvdb::tree::LeafNode<bool, 3> leaf2(openvdb::Coord(0, 0, 0));
32 EXPECT_TRUE( leaf1.memUsage() < leaf2.memUsage() );
33 //std::cerr << "\nLeafNode<ActiveState, 3> uses " << leaf1.memUsage() << " bytes" << std::endl;
34 //std::cerr << "LeafNode<bool, 3> uses " << leaf2.memUsage() << " bytes" << std::endl;
35 }
36 {
37 LeafType leaf(openvdb::Coord(0, 0, 0), false);
38
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 1 times.
513 for (openvdb::Index n = 0; n < leaf.numValues(); ++n) {
39
2/16
✓ Branch 3 taken 512 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 512 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
512 EXPECT_EQ(false, leaf.getValue(leaf.offsetToLocalCoord(n)));
40 }
41 }
42 {
43 LeafType leaf(openvdb::Coord(0, 0, 0), true);
44
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 1 times.
513 for (openvdb::Index n = 0; n < leaf.numValues(); ++n) {
45
2/16
✓ Branch 3 taken 512 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 512 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
512 EXPECT_EQ(true, leaf.getValue(leaf.offsetToLocalCoord(n)));
46 }
47 }
48 {// test Buffer::data()
49 LeafType leaf(openvdb::Coord(0, 0, 0), false);
50 leaf.fill(true);
51 LeafType::Buffer::WordType* w = leaf.buffer().data();
52
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1 times.
9 for (openvdb::Index n = 0; n < LeafType::Buffer::WORD_COUNT; ++n) {
53
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
8 EXPECT_EQ(~LeafType::Buffer::WordType(0), w[n]);
54 }
55 }
56 {// test const Buffer::data()
57 LeafType leaf(openvdb::Coord(0, 0, 0), false);
58 leaf.fill(true);
59 const LeafType& cleaf = leaf;
60 const LeafType::Buffer::WordType* w = cleaf.buffer().data();
61
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1 times.
9 for (openvdb::Index n = 0; n < LeafType::Buffer::WORD_COUNT; ++n) {
62
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
8 EXPECT_EQ(~LeafType::Buffer::WordType(0), w[n]);
63 }
64 }
65 1 }
66
67
68
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 TEST_F(TestLeafMask, testSetValue)
69 {
70 LeafType leaf(openvdb::Coord(0, 0, 0), false);
71
72 openvdb::Coord xyz(0, 0, 0);
73
1/16
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
1 EXPECT_TRUE(!leaf.isValueOn(xyz));
74 1 leaf.setValueOn(xyz);
75
1/16
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
1 EXPECT_TRUE(leaf.isValueOn(xyz));
76
77 xyz.reset(7, 7, 7);
78
1/16
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
1 EXPECT_TRUE(!leaf.isValueOn(xyz));
79 1 leaf.setValueOn(xyz);
80
1/16
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
1 EXPECT_TRUE(leaf.isValueOn(xyz));
81 1 leaf.setValueOn(xyz, true);
82
1/16
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
1 EXPECT_TRUE(leaf.isValueOn(xyz));
83 1 leaf.setValueOn(xyz, false); // value and state are the same!
84
1/16
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
1 EXPECT_TRUE(!leaf.isValueOn(xyz));
85
86 1 leaf.setValueOff(xyz);
87
1/16
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
1 EXPECT_TRUE(!leaf.isValueOn(xyz));
88
89 xyz.reset(2, 3, 6);
90 1 leaf.setValueOn(xyz);
91
1/16
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
1 EXPECT_TRUE(leaf.isValueOn(xyz));
92
93 1 leaf.setValueOff(xyz);
94
1/16
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
1 EXPECT_TRUE(!leaf.isValueOn(xyz));
95 1 }
96
97
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 TEST_F(TestLeafMask, testProbeValue)
98 {
99 LeafType leaf(openvdb::Coord(0, 0, 0));
100 1 leaf.setValueOn(openvdb::Coord(1, 6, 5));
101
102 bool val;
103
1/16
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
1 EXPECT_TRUE(leaf.probeValue(openvdb::Coord(1, 6, 5), val));
104
1/16
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
1 EXPECT_TRUE(!leaf.probeValue(openvdb::Coord(1, 6, 4), val));
105 1 }
106
107
108
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 TEST_F(TestLeafMask, testIterators)
109 {
110 LeafType leaf(openvdb::Coord(0, 0, 0));
111 1 leaf.setValueOn(openvdb::Coord(1, 2, 3));
112 1 leaf.setValueOn(openvdb::Coord(5, 2, 3));
113 openvdb::Coord sum;
114
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 for (LeafType::ValueOnIter iter = leaf.beginValueOn(); iter; ++iter) {
115 2 sum += iter.getCoord();
116 }
117
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
1 EXPECT_EQ(openvdb::Coord(1 + 5, 2 + 2, 3 + 3), sum);
118
119 1 openvdb::Index count = 0;
120
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 1 times.
1021 for (LeafType::ValueOffIter iter = leaf.beginValueOff(); iter; ++iter, ++count);
121
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
1 EXPECT_EQ(leaf.numValues() - 2, count);
122
123 1 count = 0;
124
2/2
✓ Branch 1 taken 512 times.
✓ Branch 2 taken 1 times.
1026 for (LeafType::ValueAllIter iter = leaf.beginValueAll(); iter; ++iter, ++count);
125
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
1 EXPECT_EQ(leaf.numValues(), count);
126
127 1 count = 0;
128
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
2 for (LeafType::ChildOnIter iter = leaf.beginChildOn(); iter; ++iter, ++count);
129
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
1 EXPECT_EQ(openvdb::Index(0), count);
130
131 1 count = 0;
132
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
2 for (LeafType::ChildOffIter iter = leaf.beginChildOff(); iter; ++iter, ++count);
133
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
1 EXPECT_EQ(openvdb::Index(0), count);
134
135 1 count = 0;
136
2/2
✓ Branch 1 taken 512 times.
✓ Branch 2 taken 1 times.
1026 for (LeafType::ChildAllIter iter = leaf.beginChildAll(); iter; ++iter, ++count);
137
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
1 EXPECT_EQ(leaf.numValues(), count);
138 1 }
139
140
141
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 TEST_F(TestLeafMask, testIteratorGetCoord)
142 {
143 using namespace openvdb;
144
145 LeafType leaf(openvdb::Coord(8, 8, 0));
146
147
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
1 EXPECT_EQ(Coord(8, 8, 0), leaf.origin());
148
149 1 leaf.setValueOn(Coord(1, 2, 3), -3);
150 1 leaf.setValueOn(Coord(5, 2, 3), 4);
151
152 LeafType::ValueOnIter iter = leaf.beginValueOn();
153 1 Coord xyz = iter.getCoord();
154
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
1 EXPECT_EQ(Coord(9, 10, 3), xyz);
155
156 ++iter;
157 1 xyz = iter.getCoord();
158
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
1 EXPECT_EQ(Coord(13, 10, 3), xyz);
159 1 }
160
161
162
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 TEST_F(TestLeafMask, testEquivalence)
163 {
164 using openvdb::CoordBBox;
165 using openvdb::Coord;
166 {
167 LeafType leaf(Coord(0, 0, 0), false); // false and inactive
168 LeafType leaf2(Coord(0, 0, 0), true); // true and inactive
169
170
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(leaf != leaf2);
171
172 1 leaf.fill(CoordBBox(Coord(0), Coord(LeafType::DIM - 1)), true, false);
173
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(leaf == leaf2); // true and inactive
174
175 leaf.setValuesOn(); // true and active
176
177
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
1 leaf2.fill(CoordBBox(Coord(0), Coord(LeafType::DIM - 1)), false); // false and active
178
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(leaf != leaf2);
179
180 leaf.negate(); // false and active
181
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(leaf == leaf2);
182
183 // Set some values.
184 1 leaf.setValueOn(Coord(0, 0, 0), true);
185 1 leaf.setValueOn(Coord(0, 1, 0), true);
186 1 leaf.setValueOn(Coord(1, 1, 0), true);
187 1 leaf.setValueOn(Coord(1, 1, 2), true);
188
189 1 leaf2.setValueOn(Coord(0, 0, 0), true);
190 1 leaf2.setValueOn(Coord(0, 1, 0), true);
191 1 leaf2.setValueOn(Coord(1, 1, 0), true);
192 1 leaf2.setValueOn(Coord(1, 1, 2), true);
193
194
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(leaf == leaf2);
195
196
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
1 leaf2.setValueOn(Coord(0, 0, 1), true);
197
198
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(leaf != leaf2);
199
200 1 leaf2.setValueOff(Coord(0, 0, 1), false);
201
202
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(leaf == leaf2);//values and states coinside
203
204
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
1 leaf2.setValueOn(Coord(0, 0, 1));
205
206
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(leaf != leaf2);//values and states coinside
207 }
208 {// test LeafNode<bool>::operator==()
209 LeafType leaf1(Coord(0 , 0, 0), true); // true and inactive
210 LeafType leaf2(Coord(1 , 0, 0), true); // true and inactive
211 LeafType leaf3(Coord(LeafType::DIM, 0, 0), true); // true and inactive
212 LeafType leaf4(Coord(0 , 0, 0), true, true);//true and active
213
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(leaf1 == leaf2);
214
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(leaf1 != leaf3);
215
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(leaf2 != leaf3);
216
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(leaf1 == leaf4);
217
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(leaf2 == leaf4);
218
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(leaf3 != leaf4);
219 }
220
221 1 }
222
223
224
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 TEST_F(TestLeafMask, testGetOrigin)
225 {
226 {
227 LeafType leaf(openvdb::Coord(1, 0, 0), 1);
228
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
1 EXPECT_EQ(openvdb::Coord(0, 0, 0), leaf.origin());
229 }
230 {
231 LeafType leaf(openvdb::Coord(0, 0, 0), 1);
232
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
1 EXPECT_EQ(openvdb::Coord(0, 0, 0), leaf.origin());
233 }
234 {
235 LeafType leaf(openvdb::Coord(8, 0, 0), 1);
236
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
1 EXPECT_EQ(openvdb::Coord(8, 0, 0), leaf.origin());
237 }
238 {
239 LeafType leaf(openvdb::Coord(8, 1, 0), 1);
240
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
1 EXPECT_EQ(openvdb::Coord(8, 0, 0), leaf.origin());
241 }
242 {
243 LeafType leaf(openvdb::Coord(1024, 1, 3), 1);
244
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
1 EXPECT_EQ(openvdb::Coord(128*8, 0, 0), leaf.origin());
245 }
246 {
247 LeafType leaf(openvdb::Coord(1023, 1, 3), 1);
248
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
1 EXPECT_EQ(openvdb::Coord(127*8, 0, 0), leaf.origin());
249 }
250 {
251 LeafType leaf(openvdb::Coord(512, 512, 512), 1);
252
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
1 EXPECT_EQ(openvdb::Coord(512, 512, 512), leaf.origin());
253 }
254 {
255 LeafType leaf(openvdb::Coord(2, 52, 515), 1);
256
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
1 EXPECT_EQ(openvdb::Coord(0, 48, 512), leaf.origin());
257 }
258 1 }
259
260
261
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 TEST_F(TestLeafMask, testNegativeIndexing)
262 {
263 using namespace openvdb;
264
265 LeafType leaf(openvdb::Coord(-9, -2, -8));
266
267
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
1 EXPECT_EQ(Coord(-16, -8, -8), leaf.origin());
268
269 1 leaf.setValueOn(Coord(1, 2, 3));
270 1 leaf.setValueOn(Coord(5, 2, 3));
271
272
1/16
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
1 EXPECT_TRUE(leaf.isValueOn(Coord(1, 2, 3)));
273
1/16
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
1 EXPECT_TRUE(leaf.isValueOn(Coord(5, 2, 3)));
274
275 LeafType::ValueOnIter iter = leaf.beginValueOn();
276 1 Coord xyz = iter.getCoord();
277
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
1 EXPECT_EQ(Coord(-15, -6, -5), xyz);
278
279 ++iter;
280 1 xyz = iter.getCoord();
281
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
1 EXPECT_EQ(Coord(-11, -6, -5), xyz);
282 1 }
283
284
285
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 TEST_F(TestLeafMask, testIO)
286 {
287 LeafType leaf(openvdb::Coord(1, 3, 5));
288 1 const openvdb::Coord origin = leaf.origin();
289
290 1 leaf.setValueOn(openvdb::Coord(0, 1, 0));
291 1 leaf.setValueOn(openvdb::Coord(1, 0, 0));
292
293 2 std::ostringstream ostr(std::ios_base::binary);
294
295 leaf.writeBuffers(ostr);
296
297 1 leaf.setValueOff(openvdb::Coord(0, 1, 0));
298
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 leaf.setValueOn(openvdb::Coord(0, 1, 1));
299
300
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::istringstream istr(ostr.str(), std::ios_base::binary);
301 // Since the input stream doesn't include a VDB header with file format version info,
302 // tag the input stream explicitly with the current version number.
303
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 openvdb::io::setCurrentVersion(istr);
304
305 leaf.readBuffers(istr);
306
307
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
1 EXPECT_EQ(origin, leaf.origin());
308
309
1/16
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
1 EXPECT_TRUE(leaf.isValueOn(openvdb::Coord(0, 1, 0)));
310
1/16
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
1 EXPECT_TRUE(leaf.isValueOn(openvdb::Coord(1, 0, 0)));
311
312
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(leaf.onVoxelCount() == 2);
313 1 }
314
315
316
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 TEST_F(TestLeafMask, testTopologyCopy)
317 {
318 using openvdb::Coord;
319
320 // LeafNode<float, Log2Dim> having the same Log2Dim as LeafType
321 typedef LeafType::ValueConverter<float>::Type FloatLeafType;
322
323 1 FloatLeafType fleaf(Coord(10, 20, 30), -1.0);
324 std::set<Coord> coords;
325
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 1 times.
53 for (openvdb::Index n = 0; n < fleaf.numValues(); n += 10) {
326 52 Coord xyz = fleaf.offsetToGlobalCoord(n);
327
2/4
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 52 times.
✗ Branch 5 not taken.
52 fleaf.setValueOn(xyz, float(n));
328 coords.insert(xyz);
329 }
330
331 LeafType leaf(fleaf, openvdb::TopologyCopy());
332
2/16
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1 EXPECT_EQ(fleaf.onVoxelCount(), leaf.onVoxelCount());
333
334
1/16
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
1 EXPECT_TRUE(leaf.hasSameTopology(&fleaf));
335
336
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 1 times.
53 for (LeafType::ValueOnIter iter = leaf.beginValueOn(); iter; ++iter) {
337
1/2
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
104 coords.erase(iter.getCoord());
338 }
339
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(coords.empty());
340 1 }
341
342
343
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 TEST_F(TestLeafMask, testMerge)
344 {
345 LeafType leaf(openvdb::Coord(0, 0, 0));
346
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 1 times.
53 for (openvdb::Index n = 0; n < leaf.numValues(); n += 10) {
347 52 leaf.setValueOn(n);
348 }
349
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(!leaf.isValueMaskOn());
350
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(!leaf.isValueMaskOff());
351 bool val = false, active = false;
352
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(!leaf.isConstant(val, active));
353
354 LeafType leaf2(leaf);
355 leaf2.getValueMask().toggle();
356
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(!leaf2.isValueMaskOn());
357
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(!leaf2.isValueMaskOff());
358 val = active = false;
359
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(!leaf2.isConstant(val, active));
360
361 leaf.merge<openvdb::MERGE_ACTIVE_STATES>(leaf2);
362
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(leaf.isValueMaskOn());
363
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(!leaf.isValueMaskOff());
364 val = active = false;
365
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(leaf.isConstant(val, active));
366
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(active);
367 1 }
368
369
370
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 TEST_F(TestLeafMask, testCombine)
371 {
372 struct Local {
373 512 static void op(openvdb::CombineArgs<bool>& args) {
374 512 args.setResult(args.aIsActive() ^ args.bIsActive());// state = value
375 512 }
376 };
377
378 LeafType leaf(openvdb::Coord(0, 0, 0));
379
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 1 times.
53 for (openvdb::Index n = 0; n < leaf.numValues(); n += 10) leaf.setValueOn(n);
380
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(!leaf.isValueMaskOn());
381
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(!leaf.isValueMaskOff());
382 const LeafType::NodeMaskType savedMask = leaf.getValueMask();
383 OPENVDB_LOG_DEBUG_RUNTIME(leaf.str());
384
385 LeafType leaf2(leaf);
386
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 1 times.
129 for (openvdb::Index n = 0; n < leaf.numValues(); n += 4) leaf2.setValueOn(n);
387
388
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(!leaf2.isValueMaskOn());
389
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(!leaf2.isValueMaskOff());
390 OPENVDB_LOG_DEBUG_RUNTIME(leaf2.str());
391
392 1 leaf.combine(leaf2, Local::op);
393 OPENVDB_LOG_DEBUG_RUNTIME(leaf.str());
394
395
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(leaf.getValueMask() == (savedMask ^ leaf2.getValueMask()));
396 1 }
397
398
399
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 TEST_F(TestLeafMask, testTopologyTree)
400 {
401 using namespace openvdb;
402
403 #if 0
404 FloatGrid::Ptr inGrid;
405 FloatTree::Ptr inTree;
406 {
407 //io::File vdbFile("/work/rd/fx_tools/vdb_unittest/TestGridCombine::testCsg/large1.vdb2");
408 io::File vdbFile("/hosts/whitestar/usr/pic1/VDB/bunny_0256.vdb2");
409 vdbFile.open();
410 inGrid = gridPtrCast<FloatGrid>(vdbFile.readGrid("LevelSet"));
411 EXPECT_TRUE(inGrid.get() != NULL);
412 inTree = inGrid->treePtr();
413 EXPECT_TRUE(inTree.get() != NULL);
414 }
415 #else
416 FloatGrid::Ptr inGrid = FloatGrid::create();
417
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(inGrid.get() != NULL);
418 FloatTree& inTree = inGrid->tree();
419
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
2 inGrid->setName("LevelSet");
420
421
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 unittest_util::makeSphere<FloatGrid>(Coord(128),//dim
422 1 Vec3f(0, 0, 0),//center
423 5,//radius
424 *inGrid, unittest_util::SPHERE_DENSE);
425 #endif
426
427 const Index64
428
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 floatTreeMem = inTree.memUsage(),
429
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 floatTreeLeafCount = inTree.leafCount(),
430
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 floatTreeVoxelCount = inTree.activeVoxelCount();
431
432
3/8
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
2 TreeBase::Ptr outTree(new TopologyTree(inTree, false, true, TopologyCopy()));
433
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(outTree.get() != NULL);
434
435
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 TopologyGrid::Ptr outGrid = TopologyGrid::create(*inGrid); // copy transform and metadata
436
2/6
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
2 outGrid->setTree(outTree);
437
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
2 outGrid->setName("Boolean");
438
439 const Index64
440
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 boolTreeMem = outTree->memUsage(),
441
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 boolTreeLeafCount = outTree->leafCount(),
442
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 boolTreeVoxelCount = outTree->activeVoxelCount();
443
444 #if 0
445 GridPtrVec grids;
446 grids.push_back(inGrid);
447 grids.push_back(outGrid);
448 io::File vdbFile("bool_tree.vdb2");
449 vdbFile.write(grids);
450 vdbFile.close();
451 #endif
452
453
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
1 EXPECT_EQ(floatTreeLeafCount, boolTreeLeafCount);
454
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
1 EXPECT_EQ(floatTreeVoxelCount, boolTreeVoxelCount);
455
456 //std::cerr << "\nboolTree mem=" << boolTreeMem << " bytes" << std::endl;
457 //std::cerr << "floatTree mem=" << floatTreeMem << " bytes" << std::endl;
458
459 // Considering only voxel buffer memory usage, the BoolTree would be expected
460 // to use (2 mask bits/voxel / ((32 value bits + 1 mask bit)/voxel)) = ~1/16
461 // as much memory as the FloatTree. Considering total memory usage, verify that
462 // the BoolTree is no more than 1/10 the size of the FloatTree.
463
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(boolTreeMem * 10 <= floatTreeMem);
464 1 }
465
466
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 TEST_F(TestLeafMask, testMedian)
467 {
468 using namespace openvdb;
469 LeafType leaf(openvdb::Coord(0, 0, 0), /*background=*/false);
470 bool state = false;
471
472
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
1 EXPECT_EQ(Index(0), leaf.medianOn(state));
473 EXPECT_TRUE(state == true);
474
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
1 EXPECT_EQ(leaf.numValues(), leaf.medianOff(state));
475 EXPECT_TRUE(state == false);
476
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(!leaf.medianAll());
477
478 1 leaf.setValue(Coord(0,0,0), true);
479
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
1 EXPECT_EQ(Index(1), leaf.medianOn(state));
480 EXPECT_TRUE(state == true);
481
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
1 EXPECT_EQ(leaf.numValues()-1, leaf.medianOff(state));
482 EXPECT_TRUE(state == false);
483
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(!leaf.medianAll());
484
485
486 1 leaf.setValue(Coord(0,0,1), true);
487
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
1 EXPECT_EQ(Index(2), leaf.medianOn(state));
488 EXPECT_TRUE(state == true);
489
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
1 EXPECT_EQ(leaf.numValues()-2, leaf.medianOff(state));
490 EXPECT_TRUE(state == false);
491
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(!leaf.medianAll());
492
493
494 1 leaf.setValue(Coord(5,0,1), true);
495
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
1 EXPECT_EQ(Index(3), leaf.medianOn(state));
496 EXPECT_TRUE(state == true);
497
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
1 EXPECT_EQ(leaf.numValues()-3, leaf.medianOff(state));
498 EXPECT_TRUE(state == false);
499
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(!leaf.medianAll());
500
501
502 leaf.fill(false, false);
503
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
1 EXPECT_EQ(Index(0), leaf.medianOn(state));
504 EXPECT_TRUE(state == true);
505
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
1 EXPECT_EQ(leaf.numValues(), leaf.medianOff(state));
506 EXPECT_TRUE(state == false);
507
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(!leaf.medianAll());
508
509
510
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for (Index i=0; i<leaf.numValues()/2; ++i) {
511 256 leaf.setValueOn(i, true);
512
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
256 EXPECT_TRUE(!leaf.medianAll());
513
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 256 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
256 EXPECT_EQ(Index(i+1), leaf.medianOn(state));
514 EXPECT_TRUE(state == true);
515
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 256 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
256 EXPECT_EQ(leaf.numValues()-i-1, leaf.medianOff(state));
516 EXPECT_TRUE(state == false);
517 }
518
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for (Index i=leaf.numValues()/2; i<leaf.numValues(); ++i) {
519 256 leaf.setValueOn(i, true);
520
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
256 EXPECT_TRUE(leaf.medianAll());
521
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 256 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
256 EXPECT_EQ(Index(i+1), leaf.medianOn(state));
522 EXPECT_TRUE(state == true);
523
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 256 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
256 EXPECT_EQ(leaf.numValues()-i-1, leaf.medianOff(state));
524 EXPECT_TRUE(state == false);
525 }
526 1 }
527
528 // void
529 // TestLeafMask::testFilter()
530 // {
531 // using namespace openvdb;
532
533 // BoolGrid::Ptr grid = BoolGrid::create();
534 // EXPECT_TRUE(grid.get() != NULL);
535 // BoolTree::Ptr tree = grid->treePtr();
536 // EXPECT_TRUE(tree.get() != NULL);
537 // grid->setName("filtered");
538
539 // unittest_util::makeSphere<BoolGrid>(Coord(32),// dim
540 // Vec3f(0, 0, 0),// center
541 // 10,// radius
542 // *grid, unittest_util::SPHERE_DENSE);
543
544 // BoolTree::Ptr copyOfTree(new BoolTree(*tree));
545 // BoolGrid::Ptr copyOfGrid = BoolGrid::create(copyOfTree);
546 // copyOfGrid->setName("original");
547
548 // tools::Filter<BoolGrid> filter(*grid);
549 // filter.offset(1);
550
551 // #if 0
552 // GridPtrVec grids;
553 // grids.push_back(copyOfGrid);
554 // grids.push_back(grid);
555 // io::File vdbFile("TestLeafMask::testFilter.vdb2");
556 // vdbFile.write(grids);
557 // vdbFile.close();
558 // #endif
559
560 // // Verify that offsetting all active voxels by 1 (true) has no effect,
561 // // since the active voxels were all true to begin with.
562 // EXPECT_TRUE(tree->hasSameTopology(*copyOfTree));
563 // }
564
565 #if OPENVDB_ABI_VERSION_NUMBER >= 9
566
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 TEST_F(TestLeafMask, testTransientData)
567 {
568 LeafType leaf(openvdb::Coord(0, 0, 0), /*background=*/false);
569
570
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
1 EXPECT_EQ(openvdb::Index32(0), leaf.transientData());
571 leaf.setTransientData(openvdb::Index32(5));
572
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
1 EXPECT_EQ(openvdb::Index32(5), leaf.transientData());
573 LeafType leaf2(leaf);
574
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
1 EXPECT_EQ(openvdb::Index32(5), leaf2.transientData());
575 LeafType leaf3 = leaf;
576
2/16
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1 EXPECT_EQ(openvdb::Index32(5), leaf3.transientData());
577 1 }
578 #endif
579