Line | Branch | Exec | Source |
---|---|---|---|
1 | // Copyright Contributors to the OpenVDB Project | ||
2 | // SPDX-License-Identifier: MPL-2.0 | ||
3 | |||
4 | #include <openvdb/points/PointDataGrid.h> | ||
5 | #include <openvdb/openvdb.h> | ||
6 | #include <openvdb/io/io.h> | ||
7 | |||
8 | #include <gtest/gtest.h> | ||
9 | |||
10 | #include <cmath> | ||
11 | #include <ios> | ||
12 | #include <limits> | ||
13 | #include <memory> | ||
14 | #include <sstream> | ||
15 | #include <vector> | ||
16 | |||
17 | using namespace openvdb; | ||
18 | using namespace openvdb::points; | ||
19 | |||
20 | |||
21 | 14 | class TestPointDataLeaf: public ::testing::Test | |
22 | { | ||
23 | public: | ||
24 | 14 | void SetUp() override { openvdb::initialize(); } | |
25 | 14 | void TearDown() override { openvdb::uninitialize(); } | |
26 | }; // class TestPointDataLeaf | ||
27 | |||
28 | using LeafType = PointDataTree::LeafNodeType; | ||
29 | using ValueType = LeafType::ValueType; | ||
30 | using BufferType = LeafType::Buffer; | ||
31 | |||
32 | namespace { | ||
33 | |||
34 | bool | ||
35 | 16 | matchingNamePairs(const openvdb::NamePair& lhs, | |
36 | const openvdb::NamePair& rhs) | ||
37 | { | ||
38 |
1/2✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
|
16 | if (lhs.first != rhs.first) return false; |
39 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
|
16 | if (lhs.second != rhs.second) return false; |
40 | |||
41 | return true; | ||
42 | } | ||
43 | |||
44 | bool | ||
45 | 4 | zeroLeafValues(const LeafType* leafNode) | |
46 | { | ||
47 |
2/2✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 3 times.
|
2051 | for (openvdb::Index i = 0; i < LeafType::SIZE; i++) { |
48 |
2/2✓ Branch 0 taken 2047 times.
✓ Branch 1 taken 1 times.
|
2048 | if (leafNode->buffer().getValue(i) != LeafType::ValueType(0)) return false; |
49 | } | ||
50 | |||
51 | return true; | ||
52 | } | ||
53 | |||
54 | bool | ||
55 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | noAttributeData(const LeafType* leafNode) |
56 | { | ||
57 | const AttributeSet& attributeSet = leafNode->attributeSet(); | ||
58 | |||
59 |
2/4✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
|
2 | return attributeSet.size() == 0 && attributeSet.descriptor().size() == 0; |
60 | } | ||
61 | |||
62 | bool | ||
63 | 2 | monotonicOffsets(const LeafType& leafNode) | |
64 | { | ||
65 | int previous = -1; | ||
66 | |||
67 |
2/2✓ Branch 0 taken 507 times.
✓ Branch 1 taken 1 times.
|
508 | for (auto iter = leafNode.cbeginValueOn(); iter; ++iter) { |
68 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 506 times.
|
507 | if (previous > int(*iter)) return false; |
69 | 506 | previous = int(*iter); | |
70 | } | ||
71 | |||
72 | 1 | return true; | |
73 | } | ||
74 | |||
75 | // (borrowed from PointIndexGrid unit test) | ||
76 | |||
77 | class PointList | ||
78 | { | ||
79 | public: | ||
80 | using PosType = openvdb::Vec3R; | ||
81 | using value_type = openvdb::Vec3R; | ||
82 | |||
83 | PointList(const std::vector<openvdb::Vec3R>& points) | ||
84 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | : mPoints(&points) |
85 | { | ||
86 | } | ||
87 | |||
88 | size_t size() const { | ||
89 |
4/8✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
|
8 | return mPoints->size(); |
90 | } | ||
91 | |||
92 | void getPos(size_t n, openvdb::Vec3R& xyz) const { | ||
93 |
1/2✓ Branch 0 taken 40000 times.
✗ Branch 1 not taken.
|
40000 | xyz = (*mPoints)[n]; |
94 | } | ||
95 | |||
96 | protected: | ||
97 | std::vector<openvdb::Vec3R> const * const mPoints; | ||
98 | }; // PointList | ||
99 | |||
100 | // Generate random points by uniformly distributing points | ||
101 | // on a unit-sphere. | ||
102 | // (borrowed from PointIndexGrid unit test) | ||
103 | 1 | std::vector<openvdb::Vec3R> genPoints(const int numPoints) | |
104 | { | ||
105 | // init | ||
106 | openvdb::math::Random01 randNumber(0); | ||
107 | 1 | const int n = int(std::sqrt(double(numPoints))); | |
108 | 1 | const double xScale = (2.0 * M_PI) / double(n); | |
109 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | const double yScale = M_PI / double(n); |
110 | |||
111 | double x, y, theta, phi; | ||
112 | |||
113 | std::vector<openvdb::Vec3R> points; | ||
114 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | points.reserve(n*n); |
115 | |||
116 | // loop over a [0 to n) x [0 to n) grid. | ||
117 |
2/2✓ Branch 0 taken 200 times.
✓ Branch 1 taken 1 times.
|
201 | for (int a = 0; a < n; ++a) { |
118 |
2/2✓ Branch 0 taken 40000 times.
✓ Branch 1 taken 200 times.
|
40200 | for (int b = 0; b < n; ++b) { |
119 | |||
120 | // jitter, move to random pos. inside the current cell | ||
121 | 40000 | x = double(a) + randNumber(); | |
122 | 40000 | y = double(b) + randNumber(); | |
123 | |||
124 | // remap to a lat/long map | ||
125 | 40000 | theta = y * yScale; // [0 to PI] | |
126 | 40000 | phi = x * xScale; // [0 to 2PI] | |
127 | |||
128 | // convert to cartesian coordinates on a unit sphere. | ||
129 | // spherical coordinate triplet (r=1, theta, phi) | ||
130 | 80000 | points.emplace_back( std::sin(theta)*std::cos(phi), | |
131 | 80000 | std::sin(theta)*std::sin(phi), | |
132 |
1/4✓ Branch 1 taken 40000 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
40000 | std::cos(theta) ); |
133 | } | ||
134 | } | ||
135 | |||
136 | 1 | return points; | |
137 | } | ||
138 | |||
139 | } // namespace | ||
140 | |||
141 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | TEST_F(TestPointDataLeaf, testEmptyLeaf) |
142 | { | ||
143 | // empty leaf construction | ||
144 | |||
145 | { | ||
146 | 1 | LeafType* leafNode = new LeafType(); | |
147 | |||
148 |
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(leafNode); |
149 |
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(leafNode->isEmpty()); |
150 |
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(!leafNode->buffer().empty()); |
151 |
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(zeroLeafValues(leafNode)); |
152 |
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(noAttributeData(leafNode)); |
153 |
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(leafNode->origin() == openvdb::Coord(0, 0, 0)); |
154 | |||
155 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
2 | delete leafNode; |
156 | } | ||
157 | |||
158 | // empty leaf with non-zero origin construction | ||
159 | |||
160 | { | ||
161 | openvdb::Coord coord(20, 30, 40); | ||
162 | |||
163 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | LeafType* leafNode = new LeafType(coord); |
164 | |||
165 |
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(leafNode); |
166 |
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(leafNode->isEmpty()); |
167 |
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(!leafNode->buffer().empty()); |
168 |
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(zeroLeafValues(leafNode)); |
169 |
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(noAttributeData(leafNode)); |
170 | |||
171 |
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(leafNode->origin() == openvdb::Coord(16, 24, 40)); |
172 | |||
173 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
2 | delete leafNode; |
174 | } | ||
175 | 1 | } | |
176 | |||
177 | |||
178 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | TEST_F(TestPointDataLeaf, testOffsets) |
179 | { | ||
180 | // offsets for one point per voxel (active = true) | ||
181 | |||
182 | { | ||
183 | 1 | LeafType* leafNode = new LeafType(); | |
184 | |||
185 |
2/2✓ Branch 0 taken 512 times.
✓ Branch 1 taken 1 times.
|
513 | for (openvdb::Index i = 0; i < LeafType::SIZE; i++) { |
186 | 512 | leafNode->setOffsetOn(i, i); | |
187 | } | ||
188 | |||
189 |
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(leafNode->getValue(10) == 10); |
190 |
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(leafNode->isDense()); |
191 | |||
192 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
2 | delete leafNode; |
193 | } | ||
194 | |||
195 | // offsets for one point per voxel (active = false) | ||
196 | |||
197 | { | ||
198 | 1 | LeafType* leafNode = new LeafType(); | |
199 | |||
200 |
2/2✓ Branch 0 taken 512 times.
✓ Branch 1 taken 1 times.
|
513 | for (openvdb::Index i = 0; i < LeafType::SIZE; i++) { |
201 | 512 | leafNode->setOffsetOnly(i, i); | |
202 | } | ||
203 | |||
204 |
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(leafNode->getValue(10) == 10); |
205 |
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(leafNode->isEmpty()); |
206 | |||
207 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
2 | delete leafNode; |
208 | } | ||
209 | |||
210 | // test bulk offset replacement without activity mask update | ||
211 | |||
212 | { | ||
213 | 1 | LeafType* leafNode = new LeafType(); | |
214 | |||
215 |
2/2✓ Branch 0 taken 512 times.
✓ Branch 1 taken 1 times.
|
513 | for (openvdb::Index i = 0; i < LeafType::SIZE; ++i) { |
216 | 512 | leafNode->setOffsetOn(i, 10); | |
217 | } | ||
218 | |||
219 | 1 | std::vector<LeafType::ValueType> newOffsets(LeafType::SIZE); | |
220 | |||
221 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leafNode->setOffsets(newOffsets, /*updateValueMask*/false); |
222 | |||
223 | const LeafType::NodeMaskType& valueMask = leafNode->getValueMask(); | ||
224 |
2/2✓ Branch 0 taken 512 times.
✓ Branch 1 taken 1 times.
|
513 | for (openvdb::Index i = 0; i < LeafType::SIZE; ++i ) { |
225 |
1/16✗ Branch 1 not taken.
✓ Branch 2 taken 512 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.
|
512 | EXPECT_TRUE(valueMask.isOn(i)); |
226 | } | ||
227 | |||
228 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
2 | delete leafNode; |
229 | } | ||
230 | |||
231 | // test bulk offset replacement with activity mask update | ||
232 | |||
233 | { | ||
234 | 1 | LeafType* leafNode = new LeafType(); | |
235 | |||
236 |
2/2✓ Branch 0 taken 512 times.
✓ Branch 1 taken 1 times.
|
513 | for (openvdb::Index i = 0; i < LeafType::SIZE; ++i) { |
237 | 512 | leafNode->setOffsetOn(i, 10); | |
238 | } | ||
239 | |||
240 | 1 | std::vector<LeafType::ValueType> newOffsets(LeafType::SIZE); | |
241 | |||
242 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leafNode->setOffsets(newOffsets, /*updateValueMask*/true); |
243 | |||
244 | const LeafType::NodeMaskType& valueMask = leafNode->getValueMask(); | ||
245 |
2/2✓ Branch 0 taken 512 times.
✓ Branch 1 taken 1 times.
|
513 | for (openvdb::Index i = 0; i < LeafType::SIZE; ++i ) { |
246 |
1/16✗ Branch 0 not taken.
✓ Branch 1 taken 512 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.
|
512 | EXPECT_TRUE(valueMask.isOff(i)); |
247 | } | ||
248 | |||
249 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
2 | delete leafNode; |
250 | } | ||
251 | |||
252 | // ensure bulk offset replacement fails when vector size doesn't equal number of voxels | ||
253 | |||
254 | { | ||
255 | 1 | LeafType* leafNode = new LeafType(); | |
256 | |||
257 | std::vector<LeafType::ValueType> newOffsets; | ||
258 |
4/22✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ 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 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
|
2 | EXPECT_THROW(leafNode->setOffsets(newOffsets), openvdb::ValueError); |
259 | |||
260 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
2 | delete leafNode; |
261 | } | ||
262 | |||
263 | // test offset validation | ||
264 | |||
265 | { | ||
266 | using AttributeVec3s = TypedAttributeArray<Vec3s>; | ||
267 | using AttributeS = TypedAttributeArray<float>; | ||
268 | using Descriptor = AttributeSet::Descriptor; | ||
269 | |||
270 | // empty Descriptor should throw on leaf node initialize | ||
271 | 1 | auto emptyDescriptor = std::make_shared<Descriptor>(); | |
272 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | LeafType emptyLeafNode; |
273 |
4/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ 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 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
|
2 | EXPECT_THROW(emptyLeafNode.initializeAttributes(emptyDescriptor, 5), |
274 | openvdb::IndexError); | ||
275 | |||
276 | // create a non-empty Descriptor | ||
277 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Descriptor::Ptr descriptor = Descriptor::create(AttributeVec3s::attributeType()); |
278 | |||
279 | // ensure validateOffsets succeeds for monotonically increasing offsets that fully | ||
280 | // utilise the underlying attribute arrays | ||
281 | |||
282 | { | ||
283 | const size_t numAttributes = 1; | ||
284 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | LeafType* leafNode = new LeafType(); |
285 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leafNode->initializeAttributes(descriptor, numAttributes); |
286 | |||
287 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
2 | descriptor = descriptor->duplicateAppend("density", AttributeS::attributeType()); |
288 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | leafNode->appendAttribute(leafNode->attributeSet().descriptor(), |
289 | descriptor, descriptor->find("density")); | ||
290 | |||
291 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | std::vector<LeafType::ValueType> offsets(LeafType::SIZE); |
292 | 1 | offsets.back() = numAttributes; | |
293 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leafNode->setOffsets(offsets); |
294 | |||
295 |
5/24✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ 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 23 not taken.
✗ Branch 24 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
|
1 | EXPECT_NO_THROW(leafNode->validateOffsets()); |
296 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
2 | delete leafNode; |
297 | } | ||
298 | |||
299 | // ensure validateOffsets detects non-monotonic offset values | ||
300 | |||
301 | { | ||
302 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | LeafType* leafNode = new LeafType(); |
303 | |||
304 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | std::vector<LeafType::ValueType> offsets(LeafType::SIZE); |
305 | 1 | *offsets.begin() = 1; | |
306 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leafNode->setOffsets(offsets); |
307 | |||
308 |
4/22✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ 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 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
|
2 | EXPECT_THROW(leafNode->validateOffsets(), openvdb::ValueError); |
309 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
2 | delete leafNode; |
310 | } | ||
311 | |||
312 | // ensure validateOffsets detects inconsistent attribute array sizes | ||
313 | |||
314 | { | ||
315 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | descriptor = Descriptor::create(AttributeVec3s::attributeType()); |
316 | |||
317 | const size_t numAttributes = 1; | ||
318 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | LeafType* leafNode = new LeafType(); |
319 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leafNode->initializeAttributes(descriptor, numAttributes); |
320 | |||
321 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
2 | descriptor = descriptor->duplicateAppend("density", AttributeS::attributeType()); |
322 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
2 | leafNode->appendAttribute(leafNode->attributeSet().descriptor(), |
323 | descriptor, descriptor->find("density")); | ||
324 | |||
325 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | AttributeSet* newSet = new AttributeSet(leafNode->attributeSet(), numAttributes); |
326 |
5/12✓ 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.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
|
3 | newSet->replace("density", AttributeS::create(numAttributes+1)); |
327 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leafNode->replaceAttributeSet(newSet); |
328 | |||
329 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | std::vector<LeafType::ValueType> offsets(LeafType::SIZE); |
330 | 1 | offsets.back() = numAttributes; | |
331 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leafNode->setOffsets(offsets); |
332 | |||
333 |
4/22✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ 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 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
|
2 | EXPECT_THROW(leafNode->validateOffsets(), openvdb::ValueError); |
334 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
2 | delete leafNode; |
335 | } | ||
336 | |||
337 | // ensure validateOffsets detects unused attributes (e.g. final voxel offset not | ||
338 | // equal to size of attribute arrays) | ||
339 | |||
340 | { | ||
341 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | descriptor = Descriptor::create(AttributeVec3s::attributeType()); |
342 | |||
343 | const size_t numAttributes = 1; | ||
344 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | LeafType* leafNode = new LeafType(); |
345 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leafNode->initializeAttributes(descriptor, numAttributes); |
346 | |||
347 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
2 | descriptor = descriptor->duplicateAppend("density", AttributeS::attributeType()); |
348 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | leafNode->appendAttribute(leafNode->attributeSet().descriptor(), |
349 | descriptor, descriptor->find("density")); | ||
350 | |||
351 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | std::vector<LeafType::ValueType> offsets(LeafType::SIZE); |
352 | 1 | offsets.back() = numAttributes - 1; | |
353 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leafNode->setOffsets(offsets); |
354 | |||
355 |
4/22✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ 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 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
|
2 | EXPECT_THROW(leafNode->validateOffsets(), openvdb::ValueError); |
356 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
2 | delete leafNode; |
357 | } | ||
358 | |||
359 | // ensure validateOffsets detects out-of-bounds offset values | ||
360 | |||
361 | { | ||
362 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | descriptor = Descriptor::create(AttributeVec3s::attributeType()); |
363 | |||
364 | const size_t numAttributes = 1; | ||
365 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | LeafType* leafNode = new LeafType(); |
366 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leafNode->initializeAttributes(descriptor, numAttributes); |
367 | |||
368 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
2 | descriptor = descriptor->duplicateAppend("density", AttributeS::attributeType()); |
369 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | leafNode->appendAttribute(leafNode->attributeSet().descriptor(), |
370 | descriptor, descriptor->find("density")); | ||
371 | |||
372 |
2/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
1 | std::vector<LeafType::ValueType> offsets(LeafType::SIZE); |
373 | 1 | offsets.back() = numAttributes + 1; | |
374 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leafNode->setOffsets(offsets); |
375 | |||
376 |
4/22✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ 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 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
|
2 | EXPECT_THROW(leafNode->validateOffsets(), openvdb::ValueError); |
377 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
2 | delete leafNode; |
378 | } | ||
379 | } | ||
380 | 1 | } | |
381 | |||
382 | |||
383 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | TEST_F(TestPointDataLeaf, testSetValue) |
384 | { | ||
385 | // the following tests are not run when in debug mode due to assertions firing | ||
386 | #ifdef NDEBUG | ||
387 | LeafType leaf(openvdb::Coord(0, 0, 0)); | ||
388 | |||
389 | openvdb::Coord xyz(0, 0, 0); | ||
390 | openvdb::Index index(LeafType::coordToOffset(xyz)); | ||
391 | |||
392 | // ensure all non-modifiable operations are no-ops | ||
393 | |||
394 | leaf.setValueOnly(xyz, 10); | ||
395 | leaf.setValueOnly(index, 10); | ||
396 | leaf.setValueOff(xyz, 10); | ||
397 | leaf.setValueOff(index, 10); | ||
398 | leaf.setValueOn(xyz, 10); | ||
399 | leaf.setValueOn(index, 10); | ||
400 | |||
401 | struct Local { static inline void op(unsigned int& n) { n = 10; } }; | ||
402 | |||
403 | leaf.modifyValue(xyz, Local::op); | ||
404 | leaf.modifyValue(index, Local::op); | ||
405 | leaf.modifyValueAndActiveState(xyz, Local::op); | ||
406 | |||
407 | EXPECT_EQ(0, int(leaf.getValue(xyz))); | ||
408 | #endif | ||
409 | 1 | } | |
410 | |||
411 | |||
412 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TEST_F(TestPointDataLeaf, testMonotonicity) |
413 | { | ||
414 | 1 | LeafType leaf(openvdb::Coord(0, 0, 0)); | |
415 | |||
416 | // assign aggregate values and activate all non-even coordinate sums | ||
417 | |||
418 | unsigned sum = 0; | ||
419 | |||
420 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1 times.
|
9 | for (unsigned int i = 0; i < LeafType::DIM; i++) { |
421 |
2/2✓ Branch 0 taken 64 times.
✓ Branch 1 taken 8 times.
|
72 | for (unsigned int j = 0; j < LeafType::DIM; j++) { |
422 |
2/2✓ Branch 0 taken 512 times.
✓ Branch 1 taken 64 times.
|
576 | for (unsigned int k = 0; k < LeafType::DIM; k++) { |
423 |
2/2✓ Branch 0 taken 256 times.
✓ Branch 1 taken 256 times.
|
512 | if (((i + j + k) % 2) == 0) continue; |
424 | |||
425 |
1/2✓ Branch 1 taken 256 times.
✗ Branch 2 not taken.
|
512 | leaf.setOffsetOn(LeafType::coordToOffset(openvdb::Coord(i, j, k)), sum++); |
426 | } | ||
427 | } | ||
428 | } | ||
429 | |||
430 |
2/18✓ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(monotonicOffsets(leaf)); |
431 | |||
432 | // manually change a value and ensure offsets become non-monotonic | ||
433 | |||
434 | ✗ | leaf.setOffsetOn(500, 4); | |
435 | |||
436 |
2/18✓ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(!monotonicOffsets(leaf)); |
437 | 1 | } | |
438 | |||
439 | |||
440 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TEST_F(TestPointDataLeaf, testAttributes) |
441 | { | ||
442 | using AttributeVec3s = TypedAttributeArray<Vec3s>; | ||
443 | using AttributeI = TypedAttributeArray<int32_t>; | ||
444 | |||
445 | // create a descriptor | ||
446 | |||
447 | using Descriptor = AttributeSet::Descriptor; | ||
448 | |||
449 | 1 | Descriptor::Ptr descrA = Descriptor::create(AttributeVec3s::attributeType()); | |
450 | |||
451 | // create a leaf and initialize attributes using this descriptor | ||
452 | |||
453 |
2/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
1 | LeafType leaf(openvdb::Coord(0, 0, 0)); |
454 | |||
455 |
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(leaf.attributeSet().size(), size_t(0)); |
456 | |||
457 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leaf.initializeAttributes(descrA, /*arrayLength=*/100); |
458 | |||
459 | TypedMetadata<int> defaultValue(7); | ||
460 | Metadata& baseDefaultValue = defaultValue; | ||
461 | |||
462 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
2 | descrA = descrA->duplicateAppend("id", AttributeI::attributeType()); |
463 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
2 | leaf.appendAttribute(leaf.attributeSet().descriptor(), descrA, descrA->find("id"), |
464 | Index(1), true, &baseDefaultValue); | ||
465 | |||
466 | // note that the default value has not been added to the replacement descriptor, | ||
467 | // however the default value of the attribute is as expected | ||
468 |
4/20✓ 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.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
|
1 | EXPECT_EQ(0, |
469 | leaf.attributeSet().descriptor().getDefaultValue<int>("id")); | ||
470 |
6/24✓ 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.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
|
1 | EXPECT_EQ(7, |
471 | AttributeI::cast(*leaf.attributeSet().getConst("id")).get(0)); | ||
472 | |||
473 |
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(leaf.attributeSet().size(), size_t(2)); |
474 | |||
475 | { | ||
476 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | const AttributeArray* array = leaf.attributeSet().get(/*pos=*/0); |
477 | |||
478 |
3/18✓ 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.
✗ 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 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_EQ(array->size(), Index(100)); |
479 | } | ||
480 | |||
481 | // manually set a voxel | ||
482 | |||
483 | 1 | leaf.setOffsetOn(LeafType::SIZE - 1, 10); | |
484 | |||
485 |
2/18✓ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(!zeroLeafValues(&leaf)); |
486 | |||
487 | // neither dense nor empty | ||
488 | |||
489 |
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.isDense()); |
490 |
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.isEmpty()); |
491 | |||
492 | // clear the attributes and check voxel values are zero but value mask is not touched | ||
493 | |||
494 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leaf.clearAttributes(/*updateValueMask=*/ false); |
495 | |||
496 |
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.isDense()); |
497 |
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.isEmpty()); |
498 | |||
499 |
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(leaf.attributeSet().size(), size_t(2)); |
500 |
2/18✓ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(zeroLeafValues(&leaf)); |
501 | |||
502 | // call clearAttributes again, updating the value mask and check it is now inactive | ||
503 | |||
504 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leaf.clearAttributes(); |
505 | |||
506 |
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.isEmpty()); |
507 | |||
508 | // ensure arrays are uniform | ||
509 | |||
510 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | const AttributeArray* array0 = leaf.attributeSet().get(/*pos=*/0); |
511 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | const AttributeArray* array1 = leaf.attributeSet().get(/*pos=*/1); |
512 | |||
513 |
3/18✓ 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.
✗ 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 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_EQ(array0->size(), Index(1)); |
514 |
3/18✓ 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.
✗ 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 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_EQ(array1->size(), Index(1)); |
515 | |||
516 | // test leaf returns expected result for hasAttribute() | ||
517 | |||
518 |
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.hasAttribute(/*pos*/0)); |
519 |
2/18✓ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
2 | EXPECT_TRUE(leaf.hasAttribute("P")); |
520 | |||
521 |
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.hasAttribute(/*pos*/1)); |
522 |
2/18✓ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
2 | EXPECT_TRUE(leaf.hasAttribute("id")); |
523 | |||
524 |
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.hasAttribute(/*pos*/2)); |
525 |
2/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ 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 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
2 | EXPECT_TRUE(!leaf.hasAttribute("test")); |
526 | |||
527 | // test underlying attributeArray can be accessed by name and index, | ||
528 | // and that their types are as expected. | ||
529 | |||
530 | const LeafType* constLeaf = &leaf; | ||
531 | |||
532 |
3/20✓ 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.
✗ 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 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
|
1 | EXPECT_TRUE(matchingNamePairs(leaf.attributeArray(/*pos*/0).type(), |
533 | AttributeVec3s::attributeType())); | ||
534 |
4/22✓ 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.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
|
1 | EXPECT_TRUE(matchingNamePairs(leaf.attributeArray("P").type(), |
535 | AttributeVec3s::attributeType())); | ||
536 |
3/20✓ 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.
✗ 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 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
|
1 | EXPECT_TRUE(matchingNamePairs(leaf.attributeArray(/*pos*/1).type(), |
537 | AttributeI::attributeType())); | ||
538 |
4/22✓ 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.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
|
1 | EXPECT_TRUE(matchingNamePairs(leaf.attributeArray("id").type(), |
539 | AttributeI::attributeType())); | ||
540 | |||
541 |
3/20✓ 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.
✗ 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 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
|
1 | EXPECT_TRUE(matchingNamePairs(constLeaf->attributeArray(/*pos*/0).type(), |
542 | AttributeVec3s::attributeType())); | ||
543 |
4/22✓ 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.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
|
1 | EXPECT_TRUE(matchingNamePairs(constLeaf->attributeArray("P").type(), |
544 | AttributeVec3s::attributeType())); | ||
545 |
3/20✓ 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.
✗ 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 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
|
1 | EXPECT_TRUE(matchingNamePairs(constLeaf->attributeArray(/*pos*/1).type(), |
546 | AttributeI::attributeType())); | ||
547 |
4/22✓ 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.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
|
1 | EXPECT_TRUE(matchingNamePairs(constLeaf->attributeArray("id").type(), |
548 | AttributeI::attributeType())); | ||
549 | |||
550 | // check invalid pos or name throws | ||
551 | |||
552 |
4/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ 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 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
|
2 | EXPECT_THROW(leaf.attributeArray(/*pos=*/3), openvdb::LookupError); |
553 |
5/22✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ 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 21 not taken.
✗ Branch 22 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
|
3 | EXPECT_THROW(leaf.attributeArray("not_there"), openvdb::LookupError); |
554 | |||
555 |
4/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ 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 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
|
2 | EXPECT_THROW(constLeaf->attributeArray(/*pos=*/3), openvdb::LookupError); |
556 |
5/22✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ 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 21 not taken.
✗ Branch 22 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
|
3 | EXPECT_THROW(constLeaf->attributeArray("not_there"), openvdb::LookupError); |
557 | |||
558 | // test leaf can be successfully cast to TypedAttributeArray and check types | ||
559 | |||
560 |
3/20✓ 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.
✗ 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 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
|
1 | EXPECT_TRUE(matchingNamePairs(leaf.attributeArray(/*pos=*/0).type(), |
561 | AttributeVec3s::attributeType())); | ||
562 |
4/22✓ 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.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
|
1 | EXPECT_TRUE(matchingNamePairs(leaf.attributeArray("P").type(), |
563 | AttributeVec3s::attributeType())); | ||
564 |
3/20✓ 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.
✗ 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 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
|
1 | EXPECT_TRUE(matchingNamePairs(leaf.attributeArray(/*pos=*/1).type(), |
565 | AttributeI::attributeType())); | ||
566 |
4/22✓ 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.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
|
1 | EXPECT_TRUE(matchingNamePairs(leaf.attributeArray("id").type(), |
567 | AttributeI::attributeType())); | ||
568 | |||
569 |
3/20✓ 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.
✗ 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 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
|
1 | EXPECT_TRUE(matchingNamePairs(constLeaf->attributeArray(/*pos=*/0).type(), |
570 | AttributeVec3s::attributeType())); | ||
571 |
4/22✓ 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.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
|
1 | EXPECT_TRUE(matchingNamePairs(constLeaf->attributeArray("P").type(), |
572 | AttributeVec3s::attributeType())); | ||
573 |
3/20✓ 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.
✗ 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 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
|
1 | EXPECT_TRUE(matchingNamePairs(constLeaf->attributeArray(/*pos=*/1).type(), |
574 | AttributeI::attributeType())); | ||
575 |
4/22✓ 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.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
|
1 | EXPECT_TRUE(matchingNamePairs(constLeaf->attributeArray("id").type(), |
576 | AttributeI::attributeType())); | ||
577 | |||
578 | // check invalid pos or name throws | ||
579 | |||
580 |
4/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ 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 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
|
2 | EXPECT_THROW(leaf.attributeArray(/*pos=*/2), openvdb::LookupError); |
581 |
5/22✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ 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 21 not taken.
✗ Branch 22 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
|
3 | EXPECT_THROW(leaf.attributeArray("test"), openvdb::LookupError); |
582 | |||
583 |
4/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ 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 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
|
2 | EXPECT_THROW(constLeaf->attributeArray(/*pos=*/2), openvdb::LookupError); |
584 |
5/22✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ 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 21 not taken.
✗ Branch 22 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
|
3 | EXPECT_THROW(constLeaf->attributeArray("test"), openvdb::LookupError); |
585 | |||
586 | // check memory usage = attribute set + base leaf | ||
587 | |||
588 | // leaf.initializeAttributes(descrA, /*arrayLength=*/100); | ||
589 | |||
590 | const LeafType::BaseLeaf& baseLeaf = static_cast<LeafType::BaseLeaf&>(leaf); | ||
591 | |||
592 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | const Index64 memUsage = baseLeaf.memUsage() + leaf.attributeSet().memUsage(); |
593 | |||
594 |
3/18✓ 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.
✗ 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 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_EQ(memUsage, leaf.memUsage()); |
595 | 1 | } | |
596 | |||
597 | |||
598 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TEST_F(TestPointDataLeaf, testSteal) |
599 | { | ||
600 | using AttributeVec3s = TypedAttributeArray<Vec3s>; | ||
601 | using Descriptor = AttributeSet::Descriptor; | ||
602 | |||
603 | // create a descriptor | ||
604 | |||
605 | 1 | Descriptor::Ptr descrA = Descriptor::create(AttributeVec3s::attributeType()); | |
606 | |||
607 | // create a leaf and initialize attributes using this descriptor | ||
608 | |||
609 |
2/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
1 | LeafType leaf(openvdb::Coord(0, 0, 0)); |
610 | |||
611 |
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(leaf.attributeSet().size(), size_t(0)); |
612 | |||
613 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leaf.initializeAttributes(descrA, /*arrayLength=*/100); |
614 | |||
615 |
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(leaf.attributeSet().size(), size_t(1)); |
616 | |||
617 | // steal the attribute set | ||
618 | |||
619 | 1 | AttributeSet::UniquePtr attributeSet = leaf.stealAttributeSet(); | |
620 | |||
621 |
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(attributeSet); |
622 |
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(attributeSet->size(), size_t(1)); |
623 | |||
624 | // ensure a new attribute set has been inserted in it's place | ||
625 | |||
626 |
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(leaf.attributeSet().size(), size_t(0)); |
627 | 1 | } | |
628 | |||
629 | |||
630 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | TEST_F(TestPointDataLeaf, testTopologyCopy) |
631 | { | ||
632 | // test topology copy from a float Leaf | ||
633 | |||
634 | { | ||
635 | using FloatLeaf = openvdb::FloatTree::LeafNodeType; | ||
636 | |||
637 | // create a float leaf and activate some values | ||
638 | |||
639 | 1 | FloatLeaf floatLeaf(openvdb::Coord(0, 0, 0)); | |
640 | |||
641 | floatLeaf.setValueOn(1); | ||
642 | floatLeaf.setValueOn(4); | ||
643 | floatLeaf.setValueOn(7); | ||
644 | floatLeaf.setValueOn(8); | ||
645 | |||
646 |
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(floatLeaf.onVoxelCount(), Index64(4)); |
647 | |||
648 | // validate construction of a PointDataLeaf using a TopologyCopy | ||
649 | |||
650 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | LeafType leaf(floatLeaf, 0, openvdb::TopologyCopy()); |
651 | |||
652 |
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(leaf.onVoxelCount(), Index64(4)); |
653 | |||
654 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | LeafType leaf2(openvdb::Coord(8, 8, 8)); |
655 | |||
656 | leaf2.setValueOn(1); | ||
657 | leaf2.setValueOn(4); | ||
658 | leaf2.setValueOn(7); | ||
659 | |||
660 |
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.hasSameTopology(&leaf2)); |
661 | |||
662 | leaf2.setValueOn(8); | ||
663 | |||
664 |
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.hasSameTopology(&leaf2)); |
665 | |||
666 | // validate construction of a PointDataLeaf using an Off-On TopologyCopy | ||
667 | |||
668 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | LeafType leaf3(floatLeaf, 1, 2, openvdb::TopologyCopy()); |
669 | |||
670 |
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(leaf3.onVoxelCount(), Index64(4)); |
671 | } | ||
672 | |||
673 | // test topology copy from a PointIndexLeaf | ||
674 | |||
675 | { | ||
676 | // generate points | ||
677 | // (borrowed from PointIndexGrid unit test) | ||
678 | |||
679 | const float voxelSize = 0.01f; | ||
680 | const openvdb::math::Transform::Ptr transform = | ||
681 | 1 | openvdb::math::Transform::createLinearTransform(voxelSize); | |
682 | |||
683 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | std::vector<openvdb::Vec3R> points = genPoints(40000); |
684 | |||
685 | PointList pointList(points); | ||
686 | |||
687 | // construct point index grid | ||
688 | |||
689 | using PointIndexGrid = openvdb::tools::PointIndexGrid; | ||
690 | |||
691 | PointIndexGrid::Ptr pointGridPtr = | ||
692 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | openvdb::tools::createPointIndexGrid<PointIndexGrid>(pointList, *transform); |
693 | |||
694 | auto iter = pointGridPtr->tree().cbeginLeaf(); | ||
695 | |||
696 |
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(iter); |
697 | |||
698 | // check that the active voxel counts match for all leaves | ||
699 | |||
700 |
2/2✓ Branch 0 taken 2700 times.
✓ Branch 1 taken 1 times.
|
2701 | for ( ; iter; ++iter) { |
701 |
1/2✓ Branch 1 taken 2700 times.
✗ Branch 2 not taken.
|
2700 | LeafType leaf(*iter); |
702 | |||
703 |
2/16✓ Branch 1 taken 2700 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2700 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.
|
2700 | EXPECT_EQ(iter->onVoxelCount(), leaf.onVoxelCount()); |
704 | } | ||
705 | } | ||
706 | 1 | } | |
707 | |||
708 | |||
709 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TEST_F(TestPointDataLeaf, testEquivalence) |
710 | { | ||
711 | using AttributeVec3s = TypedAttributeArray<openvdb::Vec3s>; | ||
712 | using AttributeF = TypedAttributeArray<float>; | ||
713 | using AttributeI = TypedAttributeArray<int32_t>; | ||
714 | |||
715 | // create a descriptor | ||
716 | |||
717 | using Descriptor = AttributeSet::Descriptor; | ||
718 | |||
719 | 1 | Descriptor::Ptr descrA = Descriptor::create(AttributeVec3s::attributeType()); | |
720 | |||
721 | // create a leaf and initialize attributes using this descriptor | ||
722 | |||
723 |
2/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
1 | LeafType leaf(openvdb::Coord(0, 0, 0)); |
724 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leaf.initializeAttributes(descrA, /*arrayLength=*/100); |
725 | |||
726 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
2 | descrA = descrA->duplicateAppend("density", AttributeF::attributeType()); |
727 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
2 | leaf.appendAttribute(leaf.attributeSet().descriptor(), descrA, descrA->find("density")); |
728 | |||
729 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
2 | descrA = descrA->duplicateAppend("id", AttributeI::attributeType()); |
730 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | leaf.appendAttribute(leaf.attributeSet().descriptor(), descrA, descrA->find("id")); |
731 | |||
732 | // manually activate some voxels | ||
733 | |||
734 | leaf.setValueOn(1); | ||
735 | leaf.setValueOn(4); | ||
736 | leaf.setValueOn(7); | ||
737 | |||
738 | // manually change some values in the density array | ||
739 | |||
740 | TypedAttributeArray<float>& attr = | ||
741 |
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.
|
1 | TypedAttributeArray<float>::cast(leaf.attributeArray("density")); |
742 | |||
743 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | attr.set(0, 5.0f); |
744 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | attr.set(50, 2.0f); |
745 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | attr.set(51, 8.1f); |
746 | |||
747 | // check deep copy construction (topology and attributes) | ||
748 | |||
749 | { | ||
750 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | LeafType leaf2(leaf); |
751 | |||
752 |
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(leaf.onVoxelCount(), leaf2.onVoxelCount()); |
753 |
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.hasSameTopology(&leaf2)); |
754 | |||
755 |
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(leaf.attributeSet().size(), leaf2.attributeSet().size()); |
756 |
6/24✓ 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.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
|
1 | EXPECT_EQ(leaf.attributeSet().get(0)->size(), |
757 | leaf2.attributeSet().get(0)->size()); | ||
758 | } | ||
759 | |||
760 | // check equivalence | ||
761 | |||
762 | { | ||
763 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | LeafType leaf2(leaf); |
764 | |||
765 |
2/18✓ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(leaf == leaf2); |
766 | |||
767 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leaf2.setOrigin(openvdb::Coord(0, 8, 0)); |
768 | |||
769 |
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); |
770 | } | ||
771 | |||
772 | { | ||
773 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | LeafType leaf2(leaf); |
774 | |||
775 |
2/18✓ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(leaf == leaf2); |
776 | |||
777 | leaf2.setValueOn(10); | ||
778 | |||
779 |
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); |
780 | } | ||
781 | 1 | } | |
782 | |||
783 | |||
784 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TEST_F(TestPointDataLeaf, testIterators) |
785 | { | ||
786 | using AttributeVec3s = TypedAttributeArray<openvdb::Vec3s>; | ||
787 | using AttributeF = TypedAttributeArray<float>; | ||
788 | |||
789 | // create a descriptor | ||
790 | |||
791 | using Descriptor = AttributeSet::Descriptor; | ||
792 | |||
793 | 1 | Descriptor::Ptr descrA = Descriptor::create(AttributeVec3s::attributeType()); | |
794 | |||
795 | // create a leaf and initialize attributes using this descriptor | ||
796 | |||
797 | const size_t size = LeafType::NUM_VOXELS; | ||
798 | |||
799 |
2/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
1 | LeafType leaf(openvdb::Coord(0, 0, 0)); |
800 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leaf.initializeAttributes(descrA, /*arrayLength=*/size/2); |
801 | |||
802 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
2 | descrA = descrA->duplicateAppend("density", AttributeF::attributeType()); |
803 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | leaf.appendAttribute(leaf.attributeSet().descriptor(), descrA, descrA->find("density")); |
804 | |||
805 | { // uniform monotonic offsets, only even active | ||
806 | int offset = 0; | ||
807 | |||
808 |
2/2✓ Branch 0 taken 512 times.
✓ Branch 1 taken 1 times.
|
513 | for (Index i = 0; i < size; i++) |
809 | { | ||
810 |
2/2✓ Branch 0 taken 256 times.
✓ Branch 1 taken 256 times.
|
512 | if ((i % 2) == 0) { |
811 |
1/2✓ Branch 1 taken 256 times.
✗ Branch 2 not taken.
|
512 | leaf.setOffsetOn(i, ++offset); |
812 | } | ||
813 | else { | ||
814 |
1/2✓ Branch 1 taken 256 times.
✗ Branch 2 not taken.
|
512 | leaf.setOffsetOnly(i, ++offset); |
815 | leaf.setValueOff(i); | ||
816 | } | ||
817 | } | ||
818 | } | ||
819 | |||
820 | { // test index on | ||
821 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | LeafType::IndexOnIter iterOn(leaf.beginIndexOn()); |
822 |
3/18✓ 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.
✗ 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 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_EQ(iterCount(iterOn), Index64(size/2)); |
823 |
3/4✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
✓ Branch 3 taken 256 times.
✗ Branch 4 not taken.
|
513 | for (int i = 0; iterOn; ++iterOn, i += 2) { |
824 |
2/16✓ Branch 2 taken 256 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 256 times.
✗ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
256 | EXPECT_EQ(*iterOn, Index32(i)); |
825 | } | ||
826 | } | ||
827 | |||
828 | { // test index off | ||
829 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | LeafType::IndexOffIter iterOff(leaf.beginIndexOff()); |
830 |
3/18✓ 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.
✗ 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 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_EQ(iterCount(iterOff), Index64(size/2)); |
831 |
3/4✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
✓ Branch 3 taken 256 times.
✗ Branch 4 not taken.
|
513 | for (int i = 1; iterOff; ++iterOff, i += 2) { |
832 |
2/16✓ Branch 2 taken 256 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 256 times.
✗ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
256 | EXPECT_EQ(*iterOff, Index32(i)); |
833 | } | ||
834 | } | ||
835 | |||
836 | { // test index all | ||
837 | LeafType::IndexAllIter iterAll(leaf.beginIndexAll()); | ||
838 |
3/18✓ 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.
✗ 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 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_EQ(iterCount(iterAll), Index64(size)); |
839 |
3/4✓ Branch 0 taken 512 times.
✓ Branch 1 taken 1 times.
✓ Branch 3 taken 512 times.
✗ Branch 4 not taken.
|
1025 | for (int i = 0; iterAll; ++iterAll, ++i) { |
840 |
2/16✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 512 times.
✗ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
512 | EXPECT_EQ(*iterAll, Index32(i)); |
841 | } | ||
842 | } | ||
843 | |||
844 | 1 | } | |
845 | |||
846 | |||
847 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TEST_F(TestPointDataLeaf, testReadWriteCompression) |
848 | { | ||
849 | using namespace openvdb; | ||
850 | |||
851 | util::NodeMask<3> valueMask; | ||
852 | util::NodeMask<3> childMask; | ||
853 | |||
854 | 1 | io::StreamMetadata::Ptr nullMetadata; | |
855 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | io::StreamMetadata::Ptr streamMetadata(new io::StreamMetadata); |
856 | |||
857 | { // simple read/write test | ||
858 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | std::stringstream ss; |
859 | |||
860 | Index count = 8*8*8; | ||
861 |
3/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 1 times.
|
513 | std::unique_ptr<PointDataIndex32[]> srcBuf(new PointDataIndex32[count]); |
862 | |||
863 |
2/2✓ Branch 0 taken 512 times.
✓ Branch 1 taken 1 times.
|
513 | for (Index i = 0; i < count; i++) srcBuf[i] = i; |
864 | |||
865 | { | ||
866 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | io::writeCompressedValues(ss, srcBuf.get(), count, valueMask, childMask, false); |
867 | |||
868 |
3/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 1 times.
|
513 | std::unique_ptr<PointDataIndex32[]> destBuf(new PointDataIndex32[count]); |
869 | |||
870 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | io::readCompressedValues(ss, destBuf.get(), count, valueMask, false); |
871 | |||
872 |
2/2✓ Branch 0 taken 512 times.
✓ Branch 1 taken 1 times.
|
513 | for (Index i = 0; i < count; i++) { |
873 |
2/16✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 512 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.
|
512 | EXPECT_EQ(srcBuf.get()[i], destBuf.get()[i]); |
874 | } | ||
875 | } | ||
876 | |||
877 | const char* charBuffer = reinterpret_cast<const char*>(srcBuf.get()); | ||
878 | size_t referenceBytes = | ||
879 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | compression::bloscCompressedSize(charBuffer, count*sizeof(PointDataIndex32)); |
880 | |||
881 | { | ||
882 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | ss.str(""); |
883 | |||
884 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | io::setStreamMetadataPtr(ss, streamMetadata); |
885 | |||
886 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | io::writeCompressedValuesSize(ss, srcBuf.get(), count); |
887 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | io::writeCompressedValues(ss, srcBuf.get(), count, valueMask, childMask, false); |
888 | 1 | int magic = 1924674; | |
889 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | ss.write(reinterpret_cast<const char*>(&magic), sizeof(int)); |
890 | |||
891 |
3/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 1 times.
|
513 | std::unique_ptr<PointDataIndex32[]> destBuf(new PointDataIndex32[count]); |
892 | |||
893 | uint16_t size; | ||
894 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | ss.read(reinterpret_cast<char*>(&size), sizeof(uint16_t)); |
895 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (size == std::numeric_limits<uint16_t>::max()) size = 0; |
896 | |||
897 |
2/18✓ 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.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_EQ(size_t(size), referenceBytes); |
898 | |||
899 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | io::readCompressedValues(ss, destBuf.get(), count, valueMask, false); |
900 | |||
901 | int magic2; | ||
902 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | ss.read(reinterpret_cast<char*>(&magic2), sizeof(int)); |
903 | |||
904 |
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(magic, magic2); |
905 | |||
906 |
2/2✓ Branch 0 taken 512 times.
✓ Branch 1 taken 1 times.
|
513 | for (Index i = 0; i < count; i++) { |
907 |
2/16✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 512 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.
|
512 | EXPECT_EQ(srcBuf.get()[i], destBuf.get()[i]); |
908 | } | ||
909 | |||
910 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | io::setStreamMetadataPtr(ss, nullMetadata); |
911 | } | ||
912 | |||
913 | { // repeat but using nullptr for destination to force seek behaviour | ||
914 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | ss.str(""); |
915 | |||
916 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | io::setStreamMetadataPtr(ss, streamMetadata); |
917 | |||
918 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | io::writeCompressedValuesSize(ss, srcBuf.get(), count); |
919 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | io::writeCompressedValues(ss, srcBuf.get(), count, valueMask, childMask, false); |
920 | 1 | int magic = 3829250; | |
921 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | ss.write(reinterpret_cast<const char*>(&magic), sizeof(int)); |
922 | |||
923 | uint16_t size; | ||
924 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | ss.read(reinterpret_cast<char*>(&size), sizeof(uint16_t)); |
925 | 1 | uint16_t actualSize(size); | |
926 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (size == std::numeric_limits<uint16_t>::max()) actualSize = 0; |
927 | |||
928 |
2/18✓ 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.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_EQ(size_t(actualSize), referenceBytes); |
929 | |||
930 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | streamMetadata->setPass(size); |
931 | |||
932 | PointDataIndex32* forceSeek = nullptr; | ||
933 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | io::readCompressedValues(ss, forceSeek, count, valueMask, false); |
934 | |||
935 | int magic2; | ||
936 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | ss.read(reinterpret_cast<char*>(&magic2), sizeof(int)); |
937 | |||
938 |
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(magic, magic2); |
939 | |||
940 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | io::setStreamMetadataPtr(ss, nullMetadata); |
941 | } | ||
942 | |||
943 | #ifndef OPENVDB_USE_BLOSC | ||
944 | { // write to indicate Blosc compression | ||
945 | std::stringstream ssInvalid; | ||
946 | |||
947 | uint16_t bytes16(100); // clamp to 16-bit unsigned integer | ||
948 | ssInvalid.write(reinterpret_cast<const char*>(&bytes16), sizeof(uint16_t)); | ||
949 | |||
950 | std::unique_ptr<PointDataIndex32[]> destBuf(new PointDataIndex32[count]); | ||
951 | EXPECT_THROW(io::readCompressedValues(ssInvalid, destBuf.get(), | ||
952 | count, valueMask, false), RuntimeError); | ||
953 | } | ||
954 | #endif | ||
955 | |||
956 | #ifdef OPENVDB_USE_BLOSC | ||
957 | { // mis-matching destination bytes cause decompression failures | ||
958 |
3/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 1 times.
|
513 | std::unique_ptr<PointDataIndex32[]> destBuf(new PointDataIndex32[count]); |
959 | |||
960 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | ss.str(""); |
961 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | io::writeCompressedValues(ss, srcBuf.get(), count, valueMask, childMask, false); |
962 |
4/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ 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 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
|
2 | EXPECT_THROW(io::readCompressedValues(ss, destBuf.get(), |
963 | count+1, valueMask, false), RuntimeError); | ||
964 | |||
965 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | ss.str(""); |
966 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | io::writeCompressedValues(ss, srcBuf.get(), count, valueMask, childMask, false); |
967 |
4/22✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ 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 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
|
2 | EXPECT_THROW(io::readCompressedValues(ss, destBuf.get(), |
968 | 1, valueMask, false), RuntimeError); | ||
969 | } | ||
970 | #endif | ||
971 | |||
972 | { // seek | ||
973 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | ss.str(""); |
974 | |||
975 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | io::writeCompressedValues(ss, srcBuf.get(), count, valueMask, childMask, false); |
976 | |||
977 | 1 | int test(10772832); | |
978 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | ss.write(reinterpret_cast<const char*>(&test), sizeof(int)); |
979 | |||
980 | PointDataIndex32* buf = nullptr; | ||
981 | |||
982 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | io::readCompressedValues(ss, buf, count, valueMask, false); |
983 | int test2; | ||
984 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | ss.read(reinterpret_cast<char*>(&test2), sizeof(int)); |
985 | |||
986 |
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(test, test2); |
987 | } | ||
988 | } | ||
989 | |||
990 | { // two values for non-compressible example | ||
991 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | std::stringstream ss; |
992 | |||
993 | Index count = 2; | ||
994 |
3/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1 times.
|
3 | std::unique_ptr<PointDataIndex32[]> srcBuf(new PointDataIndex32[count]); |
995 | |||
996 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
|
3 | for (Index i = 0; i < count; i++) srcBuf[i] = i; |
997 | |||
998 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | io::writeCompressedValues(ss, srcBuf.get(), count, valueMask, childMask, false); |
999 | |||
1000 |
3/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1 times.
|
3 | std::unique_ptr<PointDataIndex32[]> destBuf(new PointDataIndex32[count]); |
1001 | |||
1002 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | io::readCompressedValues(ss, destBuf.get(), count, valueMask, false); |
1003 | |||
1004 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
|
3 | for (Index i = 0; i < count; i++) { |
1005 |
2/16✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 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.
|
2 | EXPECT_EQ(srcBuf.get()[i], destBuf.get()[i]); |
1006 | } | ||
1007 | } | ||
1008 | |||
1009 | { // throw at limit of 16-bit | ||
1010 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | std::stringstream ss; |
1011 | PointDataIndex32* buf = nullptr; | ||
1012 | Index count = std::numeric_limits<uint16_t>::max(); | ||
1013 | |||
1014 |
4/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ 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 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
|
2 | EXPECT_THROW(io::writeCompressedValues(ss, buf, count, valueMask, childMask, false), |
1015 | IoError); | ||
1016 |
4/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ 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 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
|
2 | EXPECT_THROW(io::readCompressedValues(ss, buf, count, valueMask, false), IoError); |
1017 | } | ||
1018 | 1 | } | |
1019 | |||
1020 | |||
1021 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TEST_F(TestPointDataLeaf, testIO) |
1022 | { | ||
1023 | using AttributeVec3s = TypedAttributeArray<openvdb::Vec3s>; | ||
1024 | using AttributeF = TypedAttributeArray<float>; | ||
1025 | |||
1026 | // create a descriptor | ||
1027 | |||
1028 | using Descriptor = AttributeSet::Descriptor; | ||
1029 | |||
1030 | 1 | Descriptor::Ptr descrA = Descriptor::create(AttributeVec3s::attributeType()); | |
1031 | |||
1032 | // create a leaf and initialize attributes using this descriptor | ||
1033 | |||
1034 | const size_t size = LeafType::NUM_VOXELS; | ||
1035 | |||
1036 |
2/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
1 | LeafType leaf(openvdb::Coord(0, 0, 0)); |
1037 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leaf.initializeAttributes(descrA, /*arrayLength=*/size/2); |
1038 | |||
1039 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
2 | descrA = descrA->duplicateAppend("density", AttributeF::attributeType()); |
1040 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
2 | leaf.appendAttribute(leaf.attributeSet().descriptor(), descrA, descrA->find("density")); |
1041 | |||
1042 | // manually activate some voxels | ||
1043 | |||
1044 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leaf.setOffsetOn(1, 10); |
1045 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leaf.setOffsetOn(4, 20); |
1046 | 1 | leaf.setOffsetOn(7, 5); | |
1047 | |||
1048 | // manually change some values in the density array | ||
1049 | |||
1050 | TypedAttributeArray<float>& attr = | ||
1051 |
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.
|
1 | TypedAttributeArray<float>::cast(leaf.attributeArray("density")); |
1052 | |||
1053 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | attr.set(0, 5.0f); |
1054 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | attr.set(50, 2.0f); |
1055 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | attr.set(51, 8.1f); |
1056 | |||
1057 | // read and write topology to disk | ||
1058 | |||
1059 | { | ||
1060 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | LeafType leaf2(openvdb::Coord(0, 0, 0)); |
1061 | |||
1062 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | std::ostringstream ostr(std::ios_base::binary); |
1063 | leaf.writeTopology(ostr); | ||
1064 | |||
1065 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
3 | std::istringstream istr(ostr.str(), std::ios_base::binary); |
1066 | leaf2.readTopology(istr); | ||
1067 | |||
1068 | // check topology matches | ||
1069 | |||
1070 |
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(leaf.onVoxelCount(), leaf2.onVoxelCount()); |
1071 |
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.isValueOn(4)); |
1072 |
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.isValueOn(5)); |
1073 | |||
1074 | // check only topology (values and attributes still empty) | ||
1075 | |||
1076 |
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(leaf2.getValue(4), ValueType(0)); |
1077 |
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(leaf2.attributeSet().size(), size_t(0)); |
1078 | } | ||
1079 | |||
1080 | // read and write buffers to disk | ||
1081 | |||
1082 | { | ||
1083 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | LeafType leaf2(openvdb::Coord(0, 0, 0)); |
1084 | |||
1085 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | io::StreamMetadata::Ptr streamMetadata(new io::StreamMetadata); |
1086 | |||
1087 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | std::ostringstream ostr(std::ios_base::binary); |
1088 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | io::setStreamMetadataPtr(ostr, streamMetadata); |
1089 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | io::setDataCompression(ostr, io::COMPRESS_BLOSC); |
1090 | leaf.writeTopology(ostr); | ||
1091 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1 times.
|
9 | for (Index b = 0; b < leaf.buffers(); b++) { |
1092 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | uint32_t pass = (uint32_t(leaf.buffers()) << 16) | uint32_t(b); |
1093 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | streamMetadata->setPass(pass); |
1094 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | leaf.writeBuffers(ostr); |
1095 | } | ||
1096 | { // error checking | ||
1097 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | streamMetadata->setPass(1000); |
1098 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leaf.writeBuffers(ostr); |
1099 | |||
1100 | 1 | io::StreamMetadata::Ptr meta; | |
1101 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | io::setStreamMetadataPtr(ostr, meta); |
1102 |
4/22✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ 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 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
|
2 | EXPECT_THROW(leaf.writeBuffers(ostr), openvdb::IoError); |
1103 | } | ||
1104 | |||
1105 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | std::istringstream istr(ostr.str(), std::ios_base::binary); |
1106 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | io::setStreamMetadataPtr(istr, streamMetadata); |
1107 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | io::setDataCompression(istr, io::COMPRESS_BLOSC); |
1108 | |||
1109 | // Since the input stream doesn't include a VDB header with file format version info, | ||
1110 | // tag the input stream explicitly with the current version number. | ||
1111 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | io::setCurrentVersion(istr); |
1112 | |||
1113 | leaf2.readTopology(istr); | ||
1114 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1 times.
|
9 | for (Index b = 0; b < leaf.buffers(); b++) { |
1115 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | uint32_t pass = (uint32_t(leaf.buffers()) << 16) | uint32_t(b); |
1116 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | streamMetadata->setPass(pass); |
1117 | leaf2.readBuffers(istr); | ||
1118 | } | ||
1119 | |||
1120 | // check topology matches | ||
1121 | |||
1122 |
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(leaf.onVoxelCount(), leaf2.onVoxelCount()); |
1123 |
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.isValueOn(4)); |
1124 |
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.isValueOn(5)); |
1125 | |||
1126 | // check only topology (values and attributes still empty) | ||
1127 | |||
1128 |
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(leaf2.getValue(4), ValueType(20)); |
1129 |
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(leaf2.attributeSet().size(), size_t(2)); |
1130 | } | ||
1131 | |||
1132 | { // test multi-buffer IO | ||
1133 | // create a new grid with a single origin leaf | ||
1134 | |||
1135 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | PointDataGrid::Ptr grid = PointDataGrid::create(); |
1136 |
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 | grid->setName("points"); |
1137 |
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.
|
1 | grid->tree().addLeaf(new LeafType(leaf)); |
1138 | |||
1139 | 1 | openvdb::GridCPtrVec grids; | |
1140 | ✗ | grids.push_back(grid); | |
1141 | |||
1142 | // write to file | ||
1143 | |||
1144 | { | ||
1145 |
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.
|
3 | io::File file("leaf.vdb"); |
1146 | ✗ | file.write(grids); | |
1147 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | file.close(); |
1148 | } | ||
1149 | |||
1150 | { // read grids from file (using delayed loading) | ||
1151 | 1 | PointDataGrid::Ptr gridFromDisk; | |
1152 | |||
1153 | { | ||
1154 |
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.
|
3 | io::File file("leaf.vdb"); |
1155 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | file.open(); |
1156 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | openvdb::GridBase::Ptr baseGrid = file.readGrid("points"); |
1157 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | file.close(); |
1158 | |||
1159 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | gridFromDisk = openvdb::gridPtrCast<PointDataGrid>(baseGrid); |
1160 | } | ||
1161 | |||
1162 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | LeafType* leafFromDisk = gridFromDisk->tree().probeLeaf(openvdb::Coord(0, 0, 0)); |
1163 |
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(leafFromDisk); |
1164 | |||
1165 |
2/18✓ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(leaf == *leafFromDisk); |
1166 | } | ||
1167 | |||
1168 | { // read grids from file and pre-fetch | ||
1169 | 1 | PointDataGrid::Ptr gridFromDisk; | |
1170 | |||
1171 | { | ||
1172 |
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.
|
3 | io::File file("leaf.vdb"); |
1173 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | file.open(); |
1174 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | openvdb::GridBase::Ptr baseGrid = file.readGrid("points"); |
1175 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | file.close(); |
1176 | |||
1177 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | gridFromDisk = openvdb::gridPtrCast<PointDataGrid>(baseGrid); |
1178 | } | ||
1179 | |||
1180 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | LeafType* leafFromDisk = gridFromDisk->tree().probeLeaf(openvdb::Coord(0, 0, 0)); |
1181 |
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(leafFromDisk); |
1182 | |||
1183 | const AttributeVec3s& position( | ||
1184 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | AttributeVec3s::cast(leafFromDisk->constAttributeArray("P"))); |
1185 | const AttributeF& density( | ||
1186 |
3/6✓ 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.
|
3 | AttributeF::cast(leafFromDisk->constAttributeArray("density"))); |
1187 | |||
1188 |
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(leafFromDisk->buffer().isOutOfCore()); |
1189 | #ifdef OPENVDB_USE_BLOSC | ||
1190 |
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(position.isOutOfCore()); |
1191 |
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(density.isOutOfCore()); |
1192 | #else | ||
1193 | // delayed-loading is only available on attribute arrays when using Blosc | ||
1194 | EXPECT_TRUE(!position.isOutOfCore()); | ||
1195 | EXPECT_TRUE(!density.isOutOfCore()); | ||
1196 | #endif | ||
1197 | |||
1198 | // prefetch voxel data only | ||
1199 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | prefetch(gridFromDisk->tree(), /*position=*/false, /*attributes=*/false); |
1200 | |||
1201 | // ensure out-of-core data is now in-core after pre-fetching | ||
1202 | |||
1203 |
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(!leafFromDisk->buffer().isOutOfCore()); |
1204 | #ifdef OPENVDB_USE_BLOSC | ||
1205 |
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(position.isOutOfCore()); |
1206 |
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(density.isOutOfCore()); |
1207 | #else | ||
1208 | EXPECT_TRUE(!position.isOutOfCore()); | ||
1209 | EXPECT_TRUE(!density.isOutOfCore()); | ||
1210 | #endif | ||
1211 | |||
1212 | { // re-open | ||
1213 |
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.
|
3 | io::File file("leaf.vdb"); |
1214 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | file.open(); |
1215 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | openvdb::GridBase::Ptr baseGrid = file.readGrid("points"); |
1216 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | file.close(); |
1217 | |||
1218 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | gridFromDisk = openvdb::gridPtrCast<PointDataGrid>(baseGrid); |
1219 | } | ||
1220 | |||
1221 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | leafFromDisk = gridFromDisk->tree().probeLeaf(openvdb::Coord(0, 0, 0)); |
1222 |
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(leafFromDisk); |
1223 | |||
1224 | const AttributeVec3s& position2( | ||
1225 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | AttributeVec3s::cast(leafFromDisk->constAttributeArray("P"))); |
1226 | const AttributeF& density2( | ||
1227 |
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.
|
3 | AttributeF::cast(leafFromDisk->constAttributeArray("density"))); |
1228 | |||
1229 | // prefetch voxel and position attribute data | ||
1230 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | prefetch(gridFromDisk->tree(), /*position=*/true, /*attribute=*/false); |
1231 | |||
1232 | // ensure out-of-core voxel and position data is now in-core after pre-fetching | ||
1233 | |||
1234 |
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(!leafFromDisk->buffer().isOutOfCore()); |
1235 |
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(!position2.isOutOfCore()); |
1236 | #ifdef OPENVDB_USE_BLOSC | ||
1237 |
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(density2.isOutOfCore()); |
1238 | #else | ||
1239 | EXPECT_TRUE(!density2.isOutOfCore()); | ||
1240 | #endif | ||
1241 | |||
1242 | { // re-open | ||
1243 |
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.
|
3 | io::File file("leaf.vdb"); |
1244 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | file.open(); |
1245 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | openvdb::GridBase::Ptr baseGrid = file.readGrid("points"); |
1246 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | file.close(); |
1247 | |||
1248 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | gridFromDisk = openvdb::gridPtrCast<PointDataGrid>(baseGrid); |
1249 | } | ||
1250 | |||
1251 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | leafFromDisk = gridFromDisk->tree().probeLeaf(openvdb::Coord(0, 0, 0)); |
1252 |
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(leafFromDisk); |
1253 | |||
1254 | const AttributeVec3s& position3( | ||
1255 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | AttributeVec3s::cast(leafFromDisk->constAttributeArray("P"))); |
1256 | const AttributeF& density3( | ||
1257 |
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.
|
3 | AttributeF::cast(leafFromDisk->constAttributeArray("density"))); |
1258 | |||
1259 | // prefetch all data | ||
1260 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | prefetch(gridFromDisk->tree()); |
1261 | |||
1262 | // ensure out-of-core voxel and position data is now in-core after pre-fetching | ||
1263 | |||
1264 |
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(!leafFromDisk->buffer().isOutOfCore()); |
1265 |
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(!position3.isOutOfCore()); |
1266 |
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(!density3.isOutOfCore()); |
1267 | } | ||
1268 | |||
1269 | 1 | remove("leaf.vdb"); | |
1270 | } | ||
1271 | |||
1272 | { // test multi-buffer IO with varying attribute storage per-leaf | ||
1273 | // create a new grid with three leaf nodes | ||
1274 | |||
1275 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | PointDataGrid::Ptr grid = PointDataGrid::create(); |
1276 |
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 | grid->setName("points"); |
1277 | |||
1278 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Descriptor::Ptr descrB = Descriptor::create(AttributeVec3s::attributeType()); |
1279 | |||
1280 | // create leaf nodes and initialize attributes using this descriptor | ||
1281 | |||
1282 |
2/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
1 | LeafType leaf0(openvdb::Coord(0, 0, 0)); |
1283 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | LeafType leaf1(openvdb::Coord(0, 8, 0)); |
1284 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | LeafType leaf2(openvdb::Coord(0, 0, 8)); |
1285 | |||
1286 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leaf0.initializeAttributes(descrB, /*arrayLength=*/2); |
1287 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leaf1.initializeAttributes(descrB, /*arrayLength=*/2); |
1288 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leaf2.initializeAttributes(descrB, /*arrayLength=*/2); |
1289 | |||
1290 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
2 | descrB = descrB->duplicateAppend("density", AttributeF::attributeType()); |
1291 |
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 | size_t index = descrB->find("density"); |
1292 | |||
1293 | // append density attribute to leaf 0 and leaf 2 (not leaf 1) | ||
1294 | |||
1295 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leaf0.appendAttribute(leaf0.attributeSet().descriptor(), descrB, index); |
1296 | 1 | leaf2.appendAttribute(leaf2.attributeSet().descriptor(), descrB, index); | |
1297 | |||
1298 | // manually change some values in the density array for leaf 0 and leaf 2 | ||
1299 | |||
1300 | TypedAttributeArray<float>& attr0 = | ||
1301 |
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.
|
1 | TypedAttributeArray<float>::cast(leaf0.attributeArray("density")); |
1302 | |||
1303 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | attr0.set(0, 2.0f); |
1304 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | attr0.set(1, 2.0f); |
1305 | |||
1306 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | attr0.compact(); |
1307 | |||
1308 | // compact only the attribute array in the second leaf | ||
1309 | |||
1310 | TypedAttributeArray<float>& attr2 = | ||
1311 |
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.
|
1 | TypedAttributeArray<float>::cast(leaf2.attributeArray("density")); |
1312 | |||
1313 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | attr2.set(0, 5.0f); |
1314 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | attr2.set(1, 5.0f); |
1315 | |||
1316 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | attr2.compact(); |
1317 | |||
1318 |
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(attr0.isUniform()); |
1319 |
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(attr2.isUniform()); |
1320 | |||
1321 |
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.
|
1 | grid->tree().addLeaf(new LeafType(leaf0)); |
1322 |
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.
|
1 | grid->tree().addLeaf(new LeafType(leaf1)); |
1323 |
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.
|
1 | grid->tree().addLeaf(new LeafType(leaf2)); |
1324 | |||
1325 | 1 | openvdb::GridCPtrVec grids; | |
1326 | ✗ | grids.push_back(grid); | |
1327 | |||
1328 | { // write to file | ||
1329 |
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.
|
3 | io::File file("leaf.vdb"); |
1330 | ✗ | file.write(grids); | |
1331 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | file.close(); |
1332 | } | ||
1333 | |||
1334 | { // read grids from file (using delayed loading) | ||
1335 | 1 | PointDataGrid::Ptr gridFromDisk; | |
1336 | |||
1337 | { | ||
1338 |
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.
|
3 | io::File file("leaf.vdb"); |
1339 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | file.open(); |
1340 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | openvdb::GridBase::Ptr baseGrid = file.readGrid("points"); |
1341 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | file.close(); |
1342 | |||
1343 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | gridFromDisk = openvdb::gridPtrCast<PointDataGrid>(baseGrid); |
1344 | } | ||
1345 | |||
1346 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | LeafType* leafFromDisk = gridFromDisk->tree().probeLeaf(openvdb::Coord(0, 0, 0)); |
1347 |
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(leafFromDisk); |
1348 |
2/18✓ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(leaf0 == *leafFromDisk); |
1349 | |||
1350 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | leafFromDisk = gridFromDisk->tree().probeLeaf(openvdb::Coord(0, 8, 0)); |
1351 |
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(leafFromDisk); |
1352 |
2/18✓ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(leaf1 == *leafFromDisk); |
1353 | |||
1354 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | leafFromDisk = gridFromDisk->tree().probeLeaf(openvdb::Coord(0, 0, 8)); |
1355 |
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(leafFromDisk); |
1356 |
2/18✓ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(leaf2 == *leafFromDisk); |
1357 | } | ||
1358 | |||
1359 | 1 | remove("leaf.vdb"); | |
1360 | } | ||
1361 | 1 | } | |
1362 | |||
1363 | |||
1364 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TEST_F(TestPointDataLeaf, testSwap) |
1365 | { | ||
1366 | using AttributeVec3s = TypedAttributeArray<openvdb::Vec3s>; | ||
1367 | using AttributeF = TypedAttributeArray<float>; | ||
1368 | using AttributeI = TypedAttributeArray<int>; | ||
1369 | |||
1370 | // create a descriptor | ||
1371 | |||
1372 | using Descriptor = AttributeSet::Descriptor; | ||
1373 | |||
1374 | 1 | Descriptor::Ptr descrA = Descriptor::create(AttributeVec3s::attributeType()); | |
1375 | |||
1376 | // create a leaf and initialize attributes using this descriptor | ||
1377 | |||
1378 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | const Index initialArrayLength = 100; |
1379 |
2/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
1 | LeafType leaf(openvdb::Coord(0, 0, 0)); |
1380 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leaf.initializeAttributes(descrA, /*arrayLength=*/initialArrayLength); |
1381 | |||
1382 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
2 | descrA = descrA->duplicateAppend("density", AttributeF::attributeType()); |
1383 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
2 | leaf.appendAttribute(leaf.attributeSet().descriptor(), descrA, descrA->find("density")); |
1384 | |||
1385 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
2 | descrA = descrA->duplicateAppend("id", AttributeI::attributeType()); |
1386 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
2 | leaf.appendAttribute(leaf.attributeSet().descriptor(), descrA, descrA->find("id")); |
1387 | |||
1388 | // swap out the underlying attribute set with a new attribute set with a matching | ||
1389 | // descriptor | ||
1390 | |||
1391 |
5/22✓ 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.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
|
1 | EXPECT_EQ(initialArrayLength, leaf.attributeSet().get("density")->size()); |
1392 |
5/22✓ 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.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
|
1 | EXPECT_EQ(initialArrayLength, leaf.attributeSet().get("id")->size()); |
1393 | |||
1394 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | descrA = Descriptor::create(AttributeVec3s::attributeType()); |
1395 | |||
1396 | 1 | const Index newArrayLength = initialArrayLength / 2; | |
1397 | |||
1398 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | AttributeSet* newAttributeSet(new AttributeSet(descrA, /*arrayLength*/newArrayLength)); |
1399 | |||
1400 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
2 | newAttributeSet->appendAttribute("density", AttributeF::attributeType()); |
1401 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | newAttributeSet->appendAttribute("id", AttributeI::attributeType()); |
1402 | |||
1403 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leaf.replaceAttributeSet(newAttributeSet); |
1404 | |||
1405 |
5/22✓ 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.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
|
1 | EXPECT_EQ(newArrayLength, leaf.attributeSet().get("density")->size()); |
1406 |
5/22✓ 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.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
|
1 | EXPECT_EQ(newArrayLength, leaf.attributeSet().get("id")->size()); |
1407 | |||
1408 | // ensure we refuse to swap when the attribute set is null | ||
1409 | |||
1410 |
4/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ 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 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
|
2 | EXPECT_THROW(leaf.replaceAttributeSet(nullptr), openvdb::ValueError); |
1411 | |||
1412 | // ensure we refuse to swap when the descriptors do not match, | ||
1413 | // unless we explicitly allow a mismatch. | ||
1414 | |||
1415 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Descriptor::Ptr descrB = Descriptor::create(AttributeVec3s::attributeType()); |
1416 |
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.
|
1 | AttributeSet* attributeSet = new AttributeSet(descrB, newArrayLength); |
1417 | |||
1418 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
2 | attributeSet->appendAttribute("extra", AttributeF::attributeType()); |
1419 | |||
1420 |
4/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ 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 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
|
2 | EXPECT_THROW(leaf.replaceAttributeSet(attributeSet), openvdb::ValueError); |
1421 | |||
1422 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leaf.replaceAttributeSet(attributeSet, true); |
1423 |
2/18✓ 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.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_EQ(const_cast<AttributeSet*>(&leaf.attributeSet()), attributeSet); |
1424 | 1 | } | |
1425 | |||
1426 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TEST_F(TestPointDataLeaf, testCopyOnWrite) |
1427 | { | ||
1428 | using AttributeVec3s = TypedAttributeArray<openvdb::Vec3s>; | ||
1429 | using AttributeF = TypedAttributeArray<float>; | ||
1430 | |||
1431 | // create a descriptor | ||
1432 | |||
1433 | using Descriptor = AttributeSet::Descriptor; | ||
1434 | |||
1435 | 1 | Descriptor::Ptr descrA = Descriptor::create(AttributeVec3s::attributeType()); | |
1436 | |||
1437 | // create a leaf and initialize attributes using this descriptor | ||
1438 | |||
1439 | const Index initialArrayLength = 100; | ||
1440 |
2/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
1 | LeafType leaf(openvdb::Coord(0, 0, 0)); |
1441 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leaf.initializeAttributes(descrA, /*arrayLength=*/initialArrayLength); |
1442 | |||
1443 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
2 | descrA = descrA->duplicateAppend("density", AttributeF::attributeType()); |
1444 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
2 | leaf.appendAttribute(leaf.attributeSet().descriptor(), descrA, descrA->find("density")); |
1445 | |||
1446 | const AttributeSet& attributeSet = leaf.attributeSet(); | ||
1447 | |||
1448 |
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(attributeSet.size(), size_t(2)); |
1449 | |||
1450 | // ensure attribute arrays are shared between leaf nodes until write | ||
1451 | |||
1452 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | const LeafType leafCopy(leaf); |
1453 | |||
1454 | const AttributeSet& attributeSetCopy = leafCopy.attributeSet(); | ||
1455 | |||
1456 |
2/18✓ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(attributeSet.isShared(/*pos=*/1)); |
1457 |
2/18✓ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(attributeSetCopy.isShared(/*pos=*/1)); |
1458 | |||
1459 | // test that from a const leaf, accesses to the attribute arrays do not | ||
1460 | // make then unique | ||
1461 | |||
1462 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | const AttributeArray* constArray = attributeSetCopy.getConst(/*pos=*/1); |
1463 |
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(constArray); |
1464 | |||
1465 |
2/18✓ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(attributeSet.isShared(/*pos=*/1)); |
1466 |
2/18✓ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(attributeSetCopy.isShared(/*pos=*/1)); |
1467 | |||
1468 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | constArray = attributeSetCopy.get(/*pos=*/1); |
1469 | |||
1470 |
2/18✓ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(attributeSet.isShared(/*pos=*/1)); |
1471 |
2/18✓ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(attributeSetCopy.isShared(/*pos=*/1)); |
1472 | |||
1473 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | constArray = &(leafCopy.attributeArray(/*pos=*/1)); |
1474 | |||
1475 |
2/18✓ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(attributeSet.isShared(/*pos=*/1)); |
1476 |
2/18✓ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(attributeSetCopy.isShared(/*pos=*/1)); |
1477 | |||
1478 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | constArray = &(leafCopy.attributeArray("density")); |
1479 | |||
1480 |
2/18✓ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(attributeSet.isShared(/*pos=*/1)); |
1481 |
2/18✓ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(attributeSetCopy.isShared(/*pos=*/1)); |
1482 | |||
1483 | // test makeUnique is called from non const getters | ||
1484 | |||
1485 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | AttributeArray* attributeArray = &(leaf.attributeArray(/*pos=*/1)); |
1486 |
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(attributeArray); |
1487 | |||
1488 |
2/18✓ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(!attributeSet.isShared(/*pos=*/1)); |
1489 |
2/18✓ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
1 | EXPECT_TRUE(!attributeSetCopy.isShared(/*pos=*/1)); |
1490 | 1 | } | |
1491 | |||
1492 | |||
1493 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | TEST_F(TestPointDataLeaf, testCopyDescriptor) |
1494 | { | ||
1495 | using AttributeVec3s = TypedAttributeArray<Vec3s>; | ||
1496 | using AttributeS = TypedAttributeArray<float>; | ||
1497 | |||
1498 | using LeafNode = PointDataTree::LeafNodeType; | ||
1499 | |||
1500 | 2 | PointDataTree tree; | |
1501 | |||
1502 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | LeafNode* leaf = tree.touchLeaf(openvdb::Coord(0, 0, 0)); |
1503 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | LeafNode* leaf2 = tree.touchLeaf(openvdb::Coord(0, 8, 0)); |
1504 | |||
1505 | // create a descriptor | ||
1506 | |||
1507 | using Descriptor = AttributeSet::Descriptor; | ||
1508 | |||
1509 | Descriptor::Inserter names; | ||
1510 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | names.add("density", AttributeS::attributeType()); |
1511 | |||
1512 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Descriptor::Ptr descrA = Descriptor::create(AttributeVec3s::attributeType()); |
1513 | |||
1514 | // initialize attributes using this descriptor | ||
1515 | |||
1516 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leaf->initializeAttributes(descrA, /*arrayLength=*/100); |
1517 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | leaf2->initializeAttributes(descrA, /*arrayLength=*/50); |
1518 | |||
1519 | // copy the PointDataTree and ensure that descriptors are shared | ||
1520 | |||
1521 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | PointDataTree tree2(tree); |
1522 | |||
1523 |
3/18✓ 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.
✗ 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 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_EQ(tree2.leafCount(), openvdb::Index32(2)); |
1524 | |||
1525 |
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 | descrA->setGroup("test", size_t(1)); |
1526 | |||
1527 | PointDataTree::LeafCIter iter2 = tree2.cbeginLeaf(); | ||
1528 |
3/20✓ 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.
✗ 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 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
|
2 | EXPECT_TRUE(iter2->attributeSet().descriptor().hasGroup("test")); |
1529 | ++iter2; | ||
1530 |
3/20✓ 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.
✗ 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 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
|
2 | EXPECT_TRUE(iter2->attributeSet().descriptor().hasGroup("test")); |
1531 | |||
1532 | // call makeDescriptorUnique and ensure that descriptors are no longer shared | ||
1533 | |||
1534 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Descriptor::Ptr newDescriptor = makeDescriptorUnique(tree2); |
1535 |
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(newDescriptor); |
1536 | |||
1537 |
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 | descrA->setGroup("test2", size_t(2)); |
1538 | |||
1539 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | iter2 = tree2.cbeginLeaf(); |
1540 |
3/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
|
1 | EXPECT_TRUE(!iter2->attributeSet().descriptor().hasGroup("test2")); |
1541 | ++iter2; | ||
1542 |
3/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ 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 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
|
1 | EXPECT_TRUE(!iter2->attributeSet().descriptor().hasGroup("test2")); |
1543 | 1 | } | |
1544 |