GCC Code Coverage Report


Directory: ./
File: openvdb/openvdb/unittest/TestFilter.cc
Date: 2022-07-25 17:40:05
Exec Total Coverage
Lines: 201 201 100.0%
Functions: 8 8 100.0%
Branches: 323 1714 18.8%

Line Branch Exec Source
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3
4 #include <openvdb/Types.h>
5 #include <openvdb/openvdb.h>
6 #include <openvdb/tools/Filter.h>
7 #include <openvdb/tools/ValueTransformer.h>
8 #include "util.h" // for unittest_util::makeSphere()
9 #include "gtest/gtest.h"
10
11 // @todo gaussian!
12 4 class TestFilter: public ::testing::Test {};
13
14
15 ////////////////////////////////////////
16
17
18 inline openvdb::FloatGrid::ConstPtr
19 3 createReferenceGrid(const openvdb::Coord& dim)
20 {
21 openvdb::FloatGrid::Ptr referenceGrid =
22
1/2
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 openvdb::FloatGrid::create(/*background=*/5.0);
23
24 const openvdb::Vec3f center(25.0f, 20.0f, 20.0f);
25 const float radius = 10.0f;
26
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 unittest_util::makeSphere<openvdb::FloatGrid>(
27 dim, center, radius, *referenceGrid, unittest_util::SPHERE_DENSE);
28
29
3/20
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 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.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
3 EXPECT_EQ(dim[0]*dim[1]*dim[2],
30 int(referenceGrid->tree().activeVoxelCount()));
31 3 return referenceGrid;
32 }
33
34
35 ////////////////////////////////////////
36
37
38
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 TEST_F(TestFilter, testOffset)
39 {
40 const openvdb::Coord dim(40);
41 1 const openvdb::FloatGrid::ConstPtr referenceGrid = createReferenceGrid(dim);
42 const openvdb::FloatTree& sphere = referenceGrid->tree();
43
44 openvdb::Coord xyz;
45
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 openvdb::FloatGrid::Ptr grid = referenceGrid->deepCopy();
46 openvdb::FloatTree& tree = grid->tree();
47 openvdb::tools::Filter<openvdb::FloatGrid> filter(*grid);
48 const float offset = 2.34f;
49 filter.setGrainSize(0);//i.e. disable threading
50
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 filter.offset(offset);
51
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 1 times.
41 for (int x=0; x<dim[0]; ++x) {
52 40 xyz[0]=x;
53
2/2
✓ Branch 0 taken 1600 times.
✓ Branch 1 taken 40 times.
1640 for (int y=0; y<dim[1]; ++y) {
54 1600 xyz[1]=y;
55
2/2
✓ Branch 0 taken 64000 times.
✓ Branch 1 taken 1600 times.
65600 for (int z=0; z<dim[2]; ++z) {
56
1/2
✓ Branch 1 taken 64000 times.
✗ Branch 2 not taken.
64000 xyz[2]=z;
57
1/2
✓ Branch 1 taken 64000 times.
✗ Branch 2 not taken.
64000 float delta = sphere.getValue(xyz) + offset - tree.getValue(xyz);
58 //if (fabs(delta)>0.0001f) std::cerr << " failed at " << xyz << std::endl;
59
2/16
✓ Branch 1 taken 64000 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 64000 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.
64000 EXPECT_NEAR(0.0f, delta, /*tolerance=*/0.0001);
60 }
61 }
62 }
63 filter.setGrainSize(1);//i.e. enable threading
64
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 filter.offset(-offset);//default is multi-threaded
65
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 1 times.
41 for (int x=0; x<dim[0]; ++x) {
66 40 xyz[0]=x;
67
2/2
✓ Branch 0 taken 1600 times.
✓ Branch 1 taken 40 times.
1640 for (int y=0; y<dim[1]; ++y) {
68 1600 xyz[1]=y;
69
2/2
✓ Branch 0 taken 64000 times.
✓ Branch 1 taken 1600 times.
65600 for (int z=0; z<dim[2]; ++z) {
70
1/2
✓ Branch 1 taken 64000 times.
✗ Branch 2 not taken.
64000 xyz[2]=z;
71
1/2
✓ Branch 1 taken 64000 times.
✗ Branch 2 not taken.
64000 float delta = sphere.getValue(xyz) - tree.getValue(xyz);
72 //if (fabs(delta)>0.0001f) std::cerr << " failed at " << xyz << std::endl;
73
2/16
✓ Branch 1 taken 64000 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 64000 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.
64000 EXPECT_NEAR(0.0f, delta, /*tolerance=*/0.0001);
74 }
75 }
76 }
77 1 }
78
79
80
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 TEST_F(TestFilter, testMedian)
81 {
82 const openvdb::Coord dim(40);
83 1 const openvdb::FloatGrid::ConstPtr referenceGrid = createReferenceGrid(dim);
84 const openvdb::FloatTree& sphere = referenceGrid->tree();
85
86 openvdb::Coord xyz;
87
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 openvdb::FloatGrid::Ptr filteredGrid = referenceGrid->deepCopy();
88 openvdb::FloatTree& filteredTree = filteredGrid->tree();
89 const int width = 2;
90 openvdb::math::DenseStencil<openvdb::FloatGrid> stencil(*referenceGrid, width);
91 openvdb::tools::Filter<openvdb::FloatGrid> filter(*filteredGrid);
92
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 filter.median(width, /*interations=*/1);
93 std::vector<float> tmp;
94
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 1 times.
41 for (int x=0; x<dim[0]; ++x) {
95 40 xyz[0]=x;
96
2/2
✓ Branch 0 taken 1600 times.
✓ Branch 1 taken 40 times.
1640 for (int y=0; y<dim[1]; ++y) {
97 1600 xyz[1]=y;
98
2/2
✓ Branch 0 taken 64000 times.
✓ Branch 1 taken 1600 times.
65600 for (int z=0; z<dim[2]; ++z) {
99 64000 xyz[2]=z;
100
2/2
✓ Branch 0 taken 320000 times.
✓ Branch 1 taken 64000 times.
384000 for (int i = xyz[0] - width, ie= xyz[0] + width; i <= ie; ++i) {
101 openvdb::Coord ijk(i,0,0);
102
2/2
✓ Branch 0 taken 1600000 times.
✓ Branch 1 taken 320000 times.
1920000 for (int j = xyz[1] - width, je = xyz[1] + width; j <= je; ++j) {
103 ijk.setY(j);
104
2/2
✓ Branch 0 taken 8000000 times.
✓ Branch 1 taken 1600000 times.
9600000 for (int k = xyz[2] - width, ke = xyz[2] + width; k <= ke; ++k) {
105 ijk.setZ(k);
106
1/2
✓ Branch 1 taken 8000000 times.
✗ Branch 2 not taken.
8000000 tmp.push_back(sphere.getValue(ijk));
107 }
108 }
109 }
110
1/2
✓ Branch 1 taken 64000 times.
✗ Branch 2 not taken.
64000 std::sort(tmp.begin(), tmp.end());
111 stencil.moveTo(xyz);
112
3/18
✓ Branch 1 taken 64000 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 64000 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 64000 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.
64000 EXPECT_NEAR(
113 tmp[(tmp.size()-1)/2], stencil.median(), /*tolerance=*/0.0001);
114
3/18
✓ Branch 1 taken 64000 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 64000 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 64000 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.
64000 EXPECT_NEAR(
115 stencil.median(), filteredTree.getValue(xyz), /*tolerance=*/0.0001);
116 tmp.clear();
117 }
118 }
119 }
120 1 }
121
122
123
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 TEST_F(TestFilter, testMean)
124 {
125 const openvdb::Coord dim(40);
126 1 const openvdb::FloatGrid::ConstPtr referenceGrid = createReferenceGrid(dim);
127 const openvdb::FloatTree& sphere = referenceGrid->tree();
128
129 openvdb::Coord xyz;
130
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 openvdb::FloatGrid::Ptr filteredGrid = referenceGrid->deepCopy();
131 openvdb::FloatTree& filteredTree = filteredGrid->tree();
132 const int width = 2;
133 openvdb::math::DenseStencil<openvdb::FloatGrid> stencil(*referenceGrid, width);
134 openvdb::tools::Filter<openvdb::FloatGrid> filter(*filteredGrid);
135
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 filter.mean(width, /*interations=*/1);
136
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 1 times.
41 for (int x=0; x<dim[0]; ++x) {
137 40 xyz[0]=x;
138
2/2
✓ Branch 0 taken 1600 times.
✓ Branch 1 taken 40 times.
1640 for (int y=0; y<dim[1]; ++y) {
139 1600 xyz[1]=y;
140
2/2
✓ Branch 0 taken 64000 times.
✓ Branch 1 taken 1600 times.
65600 for (int z=0; z<dim[2]; ++z) {
141 64000 xyz[2]=z;
142 double sum =0.0, count=0.0;
143
2/2
✓ Branch 0 taken 320000 times.
✓ Branch 1 taken 64000 times.
384000 for (int i = xyz[0] - width, ie= xyz[0] + width; i <= ie; ++i) {
144 openvdb::Coord ijk(i,0,0);
145
2/2
✓ Branch 0 taken 1600000 times.
✓ Branch 1 taken 320000 times.
1920000 for (int j = xyz[1] - width, je = xyz[1] + width; j <= je; ++j) {
146 ijk.setY(j);
147
2/2
✓ Branch 0 taken 8000000 times.
✓ Branch 1 taken 1600000 times.
9600000 for (int k = xyz[2] - width, ke = xyz[2] + width; k <= ke; ++k) {
148 ijk.setZ(k);
149 8000000 sum += sphere.getValue(ijk);
150 8000000 count += 1.0;
151 }
152 }
153 }
154 stencil.moveTo(xyz);
155
2/16
✓ Branch 1 taken 64000 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 64000 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.
64000 EXPECT_NEAR(
156 sum/count, stencil.mean(), /*tolerance=*/0.0001);
157
2/16
✓ Branch 1 taken 64000 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 64000 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.
128000 EXPECT_NEAR(
158 stencil.mean(), filteredTree.getValue(xyz), 0.0001);
159 }
160 }
161 }
162 1 }
163
164
165
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 TEST_F(TestFilter, testFilterTiles)
166 {
167 using openvdb::Coord;
168 using openvdb::Index32;
169 using openvdb::Index64;
170
171 using InternalNode1 = openvdb::FloatTree::RootNodeType::ChildNodeType; // usually 4096^3
172 using InternalNode2 = InternalNode1::ChildNodeType; // usually 128^3
173 using LeafT = openvdb::FloatTree::LeafNodeType;
174
175 struct Settings {
176 Settings(Index32 a, Index64 b, Index32 c, Index64 d)
177 2 : mLevel(a), mVoxels(b), mLeafs(c), mTiles(d) {}
178 Index32 mLevel; // level to create the tile
179 Index64 mVoxels; // expected active voxel count
180 Index32 mLeafs; // num leaf nodes after tile processing
181 Index64 mTiles; // num tiles after tile processing
182 };
183
184
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 struct CheckMeanValues {
185 mutable openvdb::math::DenseStencil<openvdb::FloatGrid> mStencil;
186 CheckMeanValues(openvdb::math::DenseStencil<openvdb::FloatGrid>& s) : mStencil(s) {}
187 695480 inline void operator()(const openvdb::FloatTree::ValueOnCIter& iter) const {
188 695480 mStencil.moveTo(iter.getCoord());
189
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 695480 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
1390960 EXPECT_NEAR(mStencil.mean(), *iter, /*tolerance=*/0.0001);
190 695480 }
191 };
192
193
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 struct CheckMedianValues {
194 mutable openvdb::math::DenseStencil<openvdb::FloatGrid> mStencil;
195 CheckMedianValues(openvdb::math::DenseStencil<openvdb::FloatGrid>& s) : mStencil(s) {}
196 695480 inline void operator()(const openvdb::FloatTree::ValueOnCIter& iter) const {
197 695480 mStencil.moveTo(iter.getCoord());
198
1/14
✗ Branch 2 not taken.
✓ Branch 3 taken 695480 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
695480 EXPECT_NEAR(mStencil.median(), *iter, /*tolerance=*/0.0001);
199 695480 }
200 };
201
202 std::vector<Settings> tests;
203 // leaf level tile, 8x8x8, 512 voxels
204
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tests.emplace_back(Settings(1, 512, 1, 0));
205
206 // given a dimension in voxels, compute how many boundary nodes exist
207 auto computeBoundaryNodeCount = [](const Index32 voxels, const Index32 nodedim) {
208 Index32 leafPerDim = voxels/nodedim;
209 Index32 faceLeafNodes = openvdb::math::Pow2(leafPerDim);
210 Index32 boundary = faceLeafNodes * 2; // x faces
211 boundary += (faceLeafNodes * 2) - ((leafPerDim)*2)*2; // y faces
212 boundary += openvdb::math::Pow2(leafPerDim-2)*2; // z faces
213 return boundary;
214 };
215
216 // first internal node, usually 128x128x128, 2097152 voxels
217 // with a width =1 and iter = 1 all edge leaf nodes should be generated
218 Index32 expectedLeafNodes = computeBoundaryNodeCount(InternalNode2::DIM, LeafT::DIM);
219 Index32 expectedTiles = InternalNode2::NUM_VALUES - expectedLeafNodes;
220
1/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 tests.emplace_back(Settings(2, InternalNode2::NUM_VOXELS, expectedLeafNodes, expectedTiles));
221
222 // @note Not testing larger tiles values as it requires more memory/time.
223 // Uncomment the below test to test with level 3 tiles.
224 /*
225 expectedLeafNodes = computeBoundaryNodeCount(InternalNode1::DIM, LeafT::DIM);
226 Index32 numBoundary = computeBoundaryNodeCount(InternalNode1::DIM, InternalNode2::DIM);
227 expectedTiles = InternalNode1::NUM_VALUES - numBoundary;
228 expectedTiles += (numBoundary * InternalNode2::NUM_VALUES) - expectedLeafNodes;
229 tests.emplace_back(Settings(3, InternalNode1::NUM_VOXELS, expectedLeafNodes, expectedTiles));
230 */
231
232
233 int width = 1, iter = 1;
234
235 // Test the behaviour with tiled grids - the mean/median tests check that the
236 // filtering operations correctly create leaf nodes on all face/edge/vertex
237 // boundaries of a given tile as the tiles value differs from the trees
238 // background value
239
240
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 for(const auto& test : tests)
241 {
242 { // single tile
243 2 openvdb::FloatGrid::ConstPtr refTile;
244 {
245
2/6
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2 openvdb::FloatGrid::Ptr ref = openvdb::FloatGrid::create(0.0f);
246 auto& tree = ref->tree();
247
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 tree.addTile(test.mLevel, Coord(0), 1.0f, true);
248
3/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
2 EXPECT_EQ(Index32(0), tree.leafCount());
249
3/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
2 EXPECT_EQ(Index64(1), tree.activeTileCount());
250
3/20
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
2 EXPECT_EQ(test.mVoxels, tree.activeVoxelCount());
251
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(1.0f, tree.getValue(Coord(0)));
252
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 2 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.
2 EXPECT_TRUE(tree.isValueOn(Coord(0)));
253 refTile = ref;
254 }
255
256
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 openvdb::math::DenseStencil<openvdb::FloatGrid> stencil(*refTile, width);
257
258 { // offset
259
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 openvdb::FloatGrid::Ptr grid = refTile->deepCopy();
260 auto& tree = grid->tree();
261 openvdb::tools::Filter<openvdb::FloatGrid> filter(*grid);
262 // disable tile processing, do nothing
263 filter.setProcessTiles(false);
264
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 filter.offset(1.0f);
265
3/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
2 EXPECT_EQ(Index32(0), tree.leafCount());
266
3/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
2 EXPECT_EQ(Index64(1), tree.activeTileCount());
267
3/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
2 EXPECT_EQ(test.mVoxels, tree.activeVoxelCount());
268
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(1.0f, tree.getValue(Coord(0)));
269
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 2 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.
2 EXPECT_TRUE(tree.isValueOn(Coord(0)));
270
271 // enable
272 filter.setProcessTiles(true);
273
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 filter.offset(1.0f);
274
3/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
2 EXPECT_EQ(Index32(0), tree.leafCount());
275
3/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
2 EXPECT_EQ(Index64(1), tree.activeTileCount());
276
3/20
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
2 EXPECT_EQ(test.mVoxels, tree.activeVoxelCount());
277
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(2.0f, tree.getValue(Coord(0)));
278
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 2 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.
2 EXPECT_TRUE(tree.isValueOn(Coord(0)));
279 }
280
281 { // mean
282
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 openvdb::FloatGrid::Ptr grid = refTile->deepCopy();
283 auto& tree = grid->tree();
284 openvdb::tools::Filter<openvdb::FloatGrid> filter(*grid);
285 // disable tile processing, do nothing
286 filter.setProcessTiles(false);
287
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 filter.mean(width, iter);
288
3/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
2 EXPECT_EQ(Index32(0), tree.leafCount());
289
3/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
2 EXPECT_EQ(Index64(1), tree.activeTileCount());
290
3/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
2 EXPECT_EQ(test.mVoxels, tree.activeVoxelCount());
291
2/22
✓ 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 17 not taken.
✗ Branch 18 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
2 EXPECT_EQ(1.0f, tree.getValue(Coord(0)));
292
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 2 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.
2 EXPECT_TRUE(tree.isValueOn(Coord(0)));
293
294 // enable
295 filter.setProcessTiles(true);
296
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 filter.mean(width, iter);
297
3/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
2 EXPECT_EQ(test.mLeafs, tree.leafCount());
298
3/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
2 EXPECT_EQ(test.mTiles, tree.activeTileCount());
299
3/20
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
2 EXPECT_EQ(test.mVoxels, tree.activeVoxelCount());
300 CheckMeanValues op(stencil);
301
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 openvdb::tools::foreach(tree.cbeginValueOn(), op, true, false);
302 }
303
304 { // median
305
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 openvdb::FloatGrid::Ptr grid = refTile->deepCopy();
306 auto& tree = grid->tree();
307 openvdb::tools::Filter<openvdb::FloatGrid> filter(*grid);
308 // disable tile processing, do nothing
309 filter.setProcessTiles(false);
310
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 filter.median(width, iter);
311
3/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
2 EXPECT_EQ(Index32(0), tree.leafCount());
312
4/20
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
2 EXPECT_EQ(Index64(1), tree.activeTileCount());
313
3/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
2 EXPECT_EQ(test.mVoxels, tree.activeVoxelCount());
314
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(1.0f, tree.getValue(Coord(0)));
315
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 2 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.
2 EXPECT_TRUE(tree.isValueOn(Coord(0)));
316
317 // enable
318 filter.setProcessTiles(true);
319
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 filter.median(width, iter);
320
3/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
2 EXPECT_EQ(test.mLeafs, tree.leafCount());
321
3/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
2 EXPECT_EQ(test.mTiles, tree.activeTileCount());
322
3/20
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
2 EXPECT_EQ(test.mVoxels, tree.activeVoxelCount());
323 CheckMedianValues op(stencil);
324
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 openvdb::tools::foreach(tree.cbeginValueOn(), op, true, false);
325
326 }
327 }
328 }
329
330 // test with matching background - tree should not
331 // be voxelized as there is no work to do
332
333
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 for(const auto& test : tests)
334 {
335 // Test the behaviour with tiled grids
336 { // single tile
337 2 openvdb::FloatGrid::ConstPtr refTile;
338 {
339
2/6
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2 openvdb::FloatGrid::Ptr ref = openvdb::FloatGrid::create(1.0f);
340 auto& tree = ref->tree();
341
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 tree.addTile(test.mLevel, Coord(0), 1.0f, true);
342
3/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
2 EXPECT_EQ(Index32(0), tree.leafCount());
343
3/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
2 EXPECT_EQ(Index64(1), tree.activeTileCount());
344
3/20
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
2 EXPECT_EQ(test.mVoxels, tree.activeVoxelCount());
345
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(1.0f, tree.getValue(Coord(0)));
346
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 2 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.
2 EXPECT_TRUE(tree.isValueOn(Coord(0)));
347 refTile = ref;
348 }
349
350
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 openvdb::math::DenseStencil<openvdb::FloatGrid> stencil(*refTile, width);
351
352 { // mean
353
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 openvdb::FloatGrid::Ptr grid = refTile->deepCopy();
354 auto& tree = grid->tree();
355 openvdb::tools::Filter<openvdb::FloatGrid> filter(*grid);
356 filter.setProcessTiles(true);
357
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 filter.mean(width, iter);
358
3/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
2 EXPECT_EQ(Index32(0), tree.leafCount());
359
3/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
2 EXPECT_EQ(Index64(1), tree.activeTileCount());
360
3/20
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
2 EXPECT_EQ(test.mVoxels, tree.activeVoxelCount());
361
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(1.0f, tree.getValue(Coord(0)));
362
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 2 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.
2 EXPECT_TRUE(tree.isValueOn(Coord(0)));
363 }
364
365 { // median
366
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 openvdb::FloatGrid::Ptr grid = refTile->deepCopy();
367 auto& tree = grid->tree();
368 openvdb::tools::Filter<openvdb::FloatGrid> filter(*grid);
369 filter.setProcessTiles(true);
370
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 filter.median(width, iter);
371
3/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
2 EXPECT_EQ(Index32(0), tree.leafCount());
372
3/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
2 EXPECT_EQ(Index64(1), tree.activeTileCount());
373
3/20
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 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.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
2 EXPECT_EQ(test.mVoxels, tree.activeVoxelCount());
374
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(1.0f, tree.getValue(Coord(0)));
375
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 2 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.
2 EXPECT_TRUE(tree.isValueOn(Coord(0)));
376 }
377 }
378 }
379
380 // test that node neighbours with a different value forces
381 // voxelization with different width/iter combos. Ensure
382 // matching background with main tile
383
384 { // single tile at level 1
385 1 openvdb::FloatGrid::ConstPtr refTile;
386 {
387
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 openvdb::FloatGrid::Ptr ref = openvdb::FloatGrid::create(1.0f);
388 auto& tree = ref->tree();
389
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.addTile(1, Coord(0), 1.0f, true);
390
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(Index32(0), tree.leafCount());
391
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(Index64(1), tree.activeTileCount());
392
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 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
1 EXPECT_EQ(Index64(LeafT::NUM_VALUES), tree.activeVoxelCount());
393
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(1.0f, tree.getValue(Coord(0)));
394
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(tree.isValueOn(Coord(0)));
395 refTile = ref;
396 }
397
398 { // mean
399
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 openvdb::FloatGrid::Ptr grid = refTile->deepCopy();
400 auto& tree = grid->tree();
401 openvdb::tools::Filter<openvdb::FloatGrid> filter(*grid);
402 //
403 filter.setProcessTiles(true);
404
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 filter.mean(1, 1);
405
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(Index32(0), tree.leafCount());
406
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(Index64(1), tree.activeTileCount());
407
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(Index64(LeafT::NUM_VALUES), tree.activeVoxelCount());
408
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(1.0f, tree.getValue(Coord(0)));
409
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(tree.isValueOn(Coord(0)));
410
411 // create leaf neighbour
412 1 tree.touchLeaf(Coord(-1,0,0));
413
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(Index32(1), tree.leafCount());
414
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(Index64(1), tree.activeTileCount());
415
416
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 filter.mean(1, 1);
417
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(Index32(2), tree.leafCount());
418
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(Index64(0), tree.activeTileCount());
419
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 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
1 EXPECT_EQ(Index64(LeafT::NUM_VALUES), tree.activeVoxelCount());
420 }
421 }
422
423 {
424 // single tile at a given level with a leaf and level 1 neighbour
425 3 auto reset = [](const int level) {
426
1/2
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 openvdb::FloatGrid::Ptr ref = openvdb::FloatGrid::create(1.0f);
427 auto& tree = ref->tree();
428
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 tree.addTile(level, Coord(0), 1.0f, true);
429
3/18
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 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.
3 EXPECT_EQ(Index32(0), tree.leafCount());
430
3/18
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 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.
3 EXPECT_EQ(Index64(1), tree.activeTileCount());
431
2/16
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 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.
3 EXPECT_EQ(1.0f, tree.getValue(Coord(0)));
432
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 3 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.
3 EXPECT_TRUE(tree.isValueOn(Coord(0)));
433
434 // create a leaf and tile neighbour
435 3 tree.touchLeaf(Coord(-int(LeafT::DIM),0,0));
436
3/18
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 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.
3 EXPECT_EQ(Index32(1), tree.leafCount());
437
3/18
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 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.
3 EXPECT_EQ(Index64(1), tree.activeTileCount());
438 // create tile level 1 neighbour with a different value
439
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 tree.addTile(1, Coord(-int(LeafT::DIM),0,LeafT::DIM*3), 2.0f, true);
440
3/18
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 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.
3 EXPECT_EQ(Index32(1), tree.leafCount());
441
3/20
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 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.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
3 EXPECT_EQ(Index64(2), tree.activeTileCount());
442 3 return ref;
443 };
444
445 {
446
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 openvdb::FloatGrid::Ptr grid = reset(3);
447 auto& tree = grid->tree();
448 openvdb::tools::Filter<openvdb::FloatGrid> filter(*grid);
449 filter.setProcessTiles(true);
450 // with a width = 9 and iter = 1, only face neighbours need to be
451 // created. for a leaf at (-8,0,0) which is on the corner, this
452 // creates 4 nodes. for a tile at (-8,0,24) this creates 5 nodes
453 // (+ itself becomes a leaf)
454
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 filter.mean(/*width*/LeafT::DIM+1, /*iter*/1);
455 // 2 leaf nodes from the tile/leaf neighbours + their neighbours
456
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(Index32(2+4+5), tree.leafCount());
457
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((Index64(InternalNode1::NUM_VALUES) - 1) +
458 (Index64(InternalNode2::NUM_VALUES) - (4+5)), tree.activeTileCount());
459
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 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
1 EXPECT_EQ(Index64(InternalNode1::NUM_VOXELS) +
460 Index64(LeafT::NUM_VOXELS), tree.activeVoxelCount());
461 }
462
463 {
464
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 openvdb::FloatGrid::Ptr grid = reset(3);
465 auto& tree = grid->tree();
466 openvdb::tools::Filter<openvdb::FloatGrid> filter(*grid);
467 filter.setProcessTiles(true);
468 // with width = 2 and iter = 2, edge/vertex neighbours should also be voxelized
469
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 filter.mean(/*width*/2, /*iter*/2);
470
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(Index32(2+4+6), tree.leafCount());
471
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((Index64(InternalNode1::NUM_VALUES) - 1) +
472 (Index64(InternalNode2::NUM_VALUES) - (4+6)), tree.activeTileCount());
473
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 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
1 EXPECT_EQ(Index64(InternalNode1::NUM_VOXELS) +
474 Index64(LeafT::NUM_VOXELS), tree.activeVoxelCount());
475 }
476
477 {
478
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 openvdb::FloatGrid::Ptr grid = reset(2); // test at level 2 for speed
479 auto& tree = grid->tree();
480 openvdb::tools::Filter<openvdb::FloatGrid> filter(*grid);
481 filter.setProcessTiles(true);
482 // with width = 1 and iter = 9 - checks an iter count > LeafT::DIM
483
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 filter.mean(/*width*/1, /*iter*/LeafT::DIM+1);
484
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(Index32(38), tree.leafCount());
485
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((Index64(InternalNode2::NUM_VALUES) - 36), tree.activeTileCount());
486
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 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
1 EXPECT_EQ(Index64(InternalNode2::NUM_VOXELS) +
487 Index64(LeafT::NUM_VOXELS), tree.activeVoxelCount());
488 }
489 }
490 1 }
491
492