Line | Branch | Exec | Source |
---|---|---|---|
1 | // Copyright Contributors to the OpenVDB Project | ||
2 | // SPDX-License-Identifier: MPL-2.0 | ||
3 | |||
4 | #include "gtest/gtest.h" | ||
5 | |||
6 | #include <openvdb/openvdb.h> | ||
7 | #include <openvdb/tools/Count.h> | ||
8 | #include <openvdb/tools/LevelSetSphere.h> // tools::createLevelSetSphere | ||
9 | #include <openvdb/tools/LevelSetUtil.h> // tools::sdfToFogVolume | ||
10 | #include <openvdb/tree/ValueAccessor.h> | ||
11 | #include <openvdb/io/TempFile.h> | ||
12 | |||
13 | |||
14 | 4 | class TestCount: public ::testing::Test | |
15 | { | ||
16 | }; | ||
17 | |||
18 | |||
19 | //////////////////////////////////////// | ||
20 | |||
21 | |||
22 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TEST_F(TestCount, testCount) |
23 | { | ||
24 | using namespace openvdb; | ||
25 | |||
26 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | auto grid = tools::createLevelSetSphere<FloatGrid>(25.0f, Vec3f(0), 0.1f); |
27 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | tools::sdfToFogVolume(*grid); // convert to fog volume to generate active tiles |
28 | |||
29 | // count the number of active voxels by hand in active tiles and leaf nodes | ||
30 | |||
31 | using Internal1NodeT = FloatTree::RootNodeType::ChildNodeType; | ||
32 | using Internal2NodeT = Internal1NodeT::ChildNodeType; | ||
33 | using LeafNodeT = Internal2NodeT::ChildNodeType; | ||
34 | |||
35 | 1 | Index64 activeVoxelCount1(0); | |
36 | 1 | Index64 activeLeafVoxelCount1(0); | |
37 | 1 | Index64 inactiveVoxelCount1(0); | |
38 | 1 | Index64 inactiveLeafVoxelCount1(0); | |
39 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Index64 activeTileCount1(0); |
40 | |||
41 | const auto& tree = grid->tree(); | ||
42 | |||
43 | // ensure there are active tiles in this example grid | ||
44 | |||
45 |
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(tree.activeTileCount() > 0); |
46 | |||
47 | const auto& root = tree.root(); | ||
48 | |||
49 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
2 | for (auto valueIter = root.cbeginValueOn(); valueIter; ++valueIter) { |
50 | ✗ | activeVoxelCount1 += Internal1NodeT::NUM_VOXELS; | |
51 | ✗ | activeTileCount1++; | |
52 | } | ||
53 | |||
54 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
2 | for (auto valueIter = root.cbeginValueOff(); valueIter; ++valueIter) { |
55 | ✗ | if (!math::isApproxEqual(*valueIter, root.background())) { | |
56 | ✗ | inactiveVoxelCount1 += Internal1NodeT::NUM_VOXELS; | |
57 | } | ||
58 | } | ||
59 | |||
60 |
2/2✓ Branch 1 taken 8 times.
✓ Branch 2 taken 1 times.
|
10 | for (auto internal1Iter = root.cbeginChildOn(); internal1Iter; ++internal1Iter) { |
61 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
|
16 | for (auto valueIter = internal1Iter->cbeginValueOn(); valueIter; ++valueIter) { |
62 | 8 | activeVoxelCount1 += Internal2NodeT::NUM_VOXELS; | |
63 | 8 | activeTileCount1++; | |
64 | } | ||
65 |
2/2✓ Branch 0 taken 262088 times.
✓ Branch 1 taken 8 times.
|
262096 | for (auto valueIter = internal1Iter->cbeginChildOff(); valueIter; ++valueIter) { |
66 |
3/4✓ Branch 1 taken 262088 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 262080 times.
✓ Branch 4 taken 8 times.
|
262088 | if (!valueIter.isValueOn()) { |
67 | 262080 | inactiveVoxelCount1 += Internal2NodeT::NUM_VOXELS; | |
68 | } | ||
69 | } | ||
70 | |||
71 |
2/2✓ Branch 0 taken 56 times.
✓ Branch 1 taken 8 times.
|
64 | for (auto internal2Iter = internal1Iter->cbeginChildOn(); internal2Iter; ++internal2Iter) { |
72 |
2/2✓ Branch 0 taken 82730 times.
✓ Branch 1 taken 56 times.
|
82786 | for (auto valueIter = internal2Iter->cbeginValueOn(); valueIter; ++valueIter) { |
73 | 82730 | activeVoxelCount1 += LeafNodeT::NUM_VOXELS; | |
74 | 82730 | activeTileCount1++; | |
75 | } | ||
76 |
2/2✓ Branch 0 taken 208856 times.
✓ Branch 1 taken 56 times.
|
208912 | for (auto valueIter = internal2Iter->cbeginChildOff(); valueIter; ++valueIter) { |
77 |
3/4✓ Branch 1 taken 208856 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126126 times.
✓ Branch 4 taken 82730 times.
|
208856 | if (!valueIter.isValueOn()) { |
78 | 126126 | inactiveVoxelCount1 += LeafNodeT::NUM_VOXELS; | |
79 | } | ||
80 | } | ||
81 | |||
82 |
2/2✓ Branch 0 taken 20520 times.
✓ Branch 1 taken 56 times.
|
20576 | for (auto leafIter = internal2Iter->cbeginChildOn(); leafIter; ++leafIter) { |
83 |
1/2✓ Branch 1 taken 20520 times.
✗ Branch 2 not taken.
|
20520 | activeVoxelCount1 += leafIter->onVoxelCount(); |
84 |
1/2✓ Branch 1 taken 20520 times.
✗ Branch 2 not taken.
|
20520 | activeLeafVoxelCount1 += leafIter->onVoxelCount(); |
85 |
1/2✓ Branch 1 taken 20520 times.
✗ Branch 2 not taken.
|
20520 | inactiveVoxelCount1 += leafIter->offVoxelCount(); |
86 | 20520 | inactiveLeafVoxelCount1 += leafIter->offVoxelCount(); | |
87 | } | ||
88 | } | ||
89 | } | ||
90 | |||
91 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | Index64 activeVoxelCount2 = tools::countActiveVoxels(grid->tree()); |
92 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | Index64 activeLeafVoxelCount2 = tools::countActiveLeafVoxels(grid->tree()); |
93 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | Index64 inactiveVoxelCount2 = tools::countInactiveVoxels(grid->tree()); |
94 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | Index64 inactiveLeafVoxelCount2 = tools::countInactiveLeafVoxels(grid->tree()); |
95 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | Index64 activeTileCount2 = tools::countActiveTiles(grid->tree()); |
96 | |||
97 |
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(activeVoxelCount1, activeVoxelCount2); |
98 |
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(activeLeafVoxelCount1, activeLeafVoxelCount2); |
99 |
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(inactiveVoxelCount1, inactiveVoxelCount2); |
100 |
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(inactiveLeafVoxelCount1, inactiveLeafVoxelCount2); |
101 |
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(activeTileCount1, activeTileCount2); |
102 | 1 | } | |
103 | |||
104 | |||
105 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TEST_F(TestCount, testCountBBox) |
106 | { | ||
107 | using namespace openvdb; | ||
108 | |||
109 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | auto grid = tools::createLevelSetSphere<FloatGrid>(10.0f, Vec3f(0), 0.1f); |
110 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | tools::sdfToFogVolume(*grid); // convert to fog volume to generate active tiles |
111 | |||
112 | // ensure there are active tiles in this example grid | ||
113 | |||
114 |
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(grid->tree().activeTileCount() > 0); |
115 | |||
116 | { // entire bbox | ||
117 | 1 | const CoordBBox bbox(Coord(-110), Coord(110)); | |
118 | |||
119 | // count manually - iterate over all Coords in bbox and test each one | ||
120 | |||
121 | 1 | Index64 activeVoxelCount1(0); | |
122 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Index64 activeLeafVoxelCount1(0); |
123 | tree::ValueAccessor<const FloatTree> acc(grid->constTree()); | ||
124 |
2/2✓ Branch 0 taken 10793861 times.
✓ Branch 1 taken 1 times.
|
10793862 | for (auto iter = bbox.begin(); iter; ++iter) { |
125 |
2/2✓ Branch 1 taken 4187707 times.
✓ Branch 2 taken 6606154 times.
|
10793861 | if (acc.isValueOn(*iter)) { |
126 | 4187707 | activeVoxelCount1++; | |
127 |
2/2✓ Branch 1 taken 959547 times.
✓ Branch 2 taken 3228160 times.
|
4187707 | if (acc.isVoxel(*iter)) { |
128 | 959547 | activeLeafVoxelCount1++; | |
129 | } | ||
130 | } | ||
131 | } | ||
132 | |||
133 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | Index64 activeVoxelCount2 = tools::countActiveVoxels(grid->tree(), bbox, false); |
134 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | Index64 activeLeafVoxelCount2 = tools::countActiveLeafVoxels(grid->tree(), bbox, false); |
135 | |||
136 |
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(activeVoxelCount1, activeVoxelCount2); |
137 |
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(activeLeafVoxelCount1, activeLeafVoxelCount2); |
138 | } | ||
139 | |||
140 | { // tiny bbox | ||
141 | 1 | const CoordBBox bbox(Coord(-2), Coord(2)); | |
142 | |||
143 | // count manually - iterate over all Coords in bbox and test each one | ||
144 | |||
145 | 1 | Index64 activeVoxelCount1(0); | |
146 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Index64 activeLeafVoxelCount1(0); |
147 | tree::ValueAccessor<const FloatTree> acc(grid->constTree()); | ||
148 |
2/2✓ Branch 0 taken 125 times.
✓ Branch 1 taken 1 times.
|
126 | for (auto iter = bbox.begin(); iter; ++iter) { |
149 |
1/2✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
|
125 | if (acc.isValueOn(*iter)) { |
150 | 125 | activeVoxelCount1++; | |
151 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
|
125 | if (acc.isVoxel(*iter)) { |
152 | ✗ | activeLeafVoxelCount1++; | |
153 | } | ||
154 | } | ||
155 | } | ||
156 | |||
157 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | Index64 activeVoxelCount2 = tools::countActiveVoxels(grid->tree(), bbox); |
158 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | Index64 activeLeafVoxelCount2 = tools::countActiveLeafVoxels(grid->tree(), bbox); |
159 | |||
160 |
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(activeVoxelCount1, activeVoxelCount2); |
161 |
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(activeLeafVoxelCount1, activeLeafVoxelCount2); |
162 | } | ||
163 | |||
164 | { // subset bbox | ||
165 | 1 | const CoordBBox bbox(Coord(-80, -110, -80), Coord(80, 110, 80)); | |
166 | |||
167 | // count manually - iterate over all Coords in bbox and test each one | ||
168 | |||
169 | 1 | Index64 activeVoxelCount1(0); | |
170 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Index64 activeLeafVoxelCount1(0); |
171 | tree::ValueAccessor<const FloatTree> acc(grid->constTree()); | ||
172 |
2/2✓ Branch 0 taken 5728541 times.
✓ Branch 1 taken 1 times.
|
5728542 | for (auto iter = bbox.begin(); iter; ++iter) { |
173 |
2/2✓ Branch 1 taken 3741359 times.
✓ Branch 2 taken 1987182 times.
|
5728541 | if (acc.isValueOn(*iter)) { |
174 | 3741359 | activeVoxelCount1++; | |
175 |
2/2✓ Branch 1 taken 665519 times.
✓ Branch 2 taken 3075840 times.
|
3741359 | if (acc.isVoxel(*iter)) { |
176 | 665519 | activeLeafVoxelCount1++; | |
177 | } | ||
178 | } | ||
179 | } | ||
180 | |||
181 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | Index64 activeVoxelCount2 = tools::countActiveVoxels(grid->tree(), bbox); |
182 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | Index64 activeLeafVoxelCount2 = tools::countActiveLeafVoxels(grid->tree(), bbox); |
183 | |||
184 |
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(activeVoxelCount1, activeVoxelCount2); |
185 |
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(activeLeafVoxelCount1, activeLeafVoxelCount2); |
186 | } | ||
187 | 1 | } | |
188 | |||
189 | |||
190 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TEST_F(TestCount, testMemUsage) |
191 | { | ||
192 | using namespace openvdb; | ||
193 | |||
194 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | auto grid = tools::createLevelSetSphere<FloatGrid>(10.0f, Vec3f(0), 0.1f); |
195 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | tools::sdfToFogVolume(*grid); // convert to fog volume to generate active tiles |
196 | |||
197 | // count the memory usage manually across all nodes | ||
198 | |||
199 | using Internal1NodeT = FloatTree::RootNodeType::ChildNodeType; | ||
200 | using Internal2NodeT = Internal1NodeT::ChildNodeType; | ||
201 | |||
202 | const auto& tree = grid->tree(); | ||
203 | |||
204 | // ensure there are active tiles in this example grid | ||
205 | |||
206 |
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(tree.activeTileCount() > 0); |
207 | |||
208 | const auto& root = tree.root(); | ||
209 | |||
210 | Index64 internalNodeMemUsage(0); | ||
211 | 1 | Index64 expectedMaxMem(sizeof(tree) + sizeof(root)); | |
212 | Index64 leafCount(0); | ||
213 | |||
214 |
2/2✓ Branch 1 taken 8 times.
✓ Branch 2 taken 1 times.
|
10 | for (auto internal1Iter = root.cbeginChildOn(); internal1Iter; ++internal1Iter) { |
215 | internalNodeMemUsage += Internal1NodeT::NUM_VALUES * sizeof(Internal1NodeT::UnionType); | ||
216 | internalNodeMemUsage += internal1Iter->getChildMask().memUsage(); | ||
217 | internalNodeMemUsage += internal1Iter->getValueMask().memUsage(); | ||
218 | 8 | internalNodeMemUsage += sizeof(Coord); | |
219 | |||
220 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
|
16 | for (auto internal2Iter = internal1Iter->cbeginChildOn(); internal2Iter; ++internal2Iter) { |
221 | internalNodeMemUsage += Internal2NodeT::NUM_VALUES * sizeof(Internal2NodeT::UnionType); | ||
222 | internalNodeMemUsage += internal2Iter->getChildMask().memUsage(); | ||
223 | internalNodeMemUsage += internal2Iter->getValueMask().memUsage(); | ||
224 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | internalNodeMemUsage += sizeof(Coord); |
225 | |||
226 |
2/2✓ Branch 0 taken 3263 times.
✓ Branch 1 taken 8 times.
|
3271 | for (auto leafIter = internal2Iter->cbeginChildOn(); leafIter; ++leafIter) { |
227 |
3/18✓ Branch 1 taken 3263 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 3263 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 3263 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 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
|
3263 | EXPECT_EQ(leafIter->memUsage(), leafIter->memUsageIfLoaded()); |
228 | 3263 | expectedMaxMem += leafIter->memUsageIfLoaded(); | |
229 | 3263 | ++leafCount; | |
230 | } | ||
231 | } | ||
232 | } | ||
233 | |||
234 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | expectedMaxMem += internalNodeMemUsage; |
235 | |||
236 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | Index64 inCoreMemUsage = tools::memUsage(grid->tree()); |
237 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | Index64 memUsageIfLoaded = tools::memUsageIfLoaded(grid->tree()); |
238 | |||
239 |
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(expectedMaxMem, inCoreMemUsage); |
240 |
1/14✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
|
1 | EXPECT_EQ(expectedMaxMem, memUsageIfLoaded); |
241 | |||
242 | // Write out the grid and read it in with delay-loading. Check the | ||
243 | // expected memory usage values.] | ||
244 | |||
245 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | openvdb::initialize(); |
246 | |||
247 | std::string filename; | ||
248 | |||
249 | // write out grid to a temp file | ||
250 | { | ||
251 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | io::TempFile file; |
252 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | filename = file.filename(); |
253 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | io::File fileOut(filename); |
254 |
4/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
|
3 | fileOut.write({grid}); |
255 | } | ||
256 | |||
257 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | io::File fileIn(filename); |
258 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | fileIn.open(true); // delay-load |
259 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | auto grids = fileIn.getGrids(); |
260 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | fileIn.close(); |
261 | |||
262 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
2 | grid = GridBase::grid<FloatGrid>((*grids)[0]); |
263 |
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(grid); |
264 | |||
265 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | inCoreMemUsage = tools::memUsage(grid->tree()); |
266 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | memUsageIfLoaded = tools::memUsageIfLoaded(grid->tree()); |
267 | |||
268 |
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(expectedMaxMem, memUsageIfLoaded); |
269 |
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(inCoreMemUsage < expectedMaxMem); |
270 | |||
271 | // in core memory should be the max memory without the leaf buffers but | ||
272 | // with the FileInfo | ||
273 | |||
274 | const Index64 leafBuffers = sizeof(FloatGrid::ValueType) * FloatTree::LeafNodeType::SIZE; | ||
275 | const Index64 fileInfo = sizeof(FloatTree::LeafNodeType::Buffer::FileInfo); | ||
276 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | const Index64 expectedInCoreMemUsage = expectedMaxMem + (leafCount * (-leafBuffers + fileInfo)); |
277 |
1/14✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
|
1 | EXPECT_EQ(expectedInCoreMemUsage, inCoreMemUsage); |
278 | |||
279 | 1 | std::remove(filename.c_str()); | |
280 | |||
281 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | openvdb::uninitialize(); |
282 | 1 | } | |
283 | |||
284 | |||
285 | namespace { | ||
286 | |||
287 | /// Helper function to test tools::minMax() for various tree types | ||
288 | template<typename TreeT> | ||
289 | void | ||
290 | 8 | minMaxTest() | |
291 | { | ||
292 | using ValueT = typename TreeT::ValueType; | ||
293 | |||
294 | const ValueT | ||
295 | 8 | zero = openvdb::zeroVal<ValueT>(), | |
296 | 8 | minusTwo = zero + (-2), | |
297 | 8 | plusTwo = zero + 2, | |
298 | 8 | five = zero + 5, | |
299 | 8 | ten = zero + 10, | |
300 | 8 | twenty = zero + 20; | |
301 | |||
302 | static constexpr int64_t DIM = TreeT::LeafNodeType::DIM; | ||
303 | |||
304 | 16 | TreeT tree(/*background=*/five); | |
305 | |||
306 | // No set voxels (defaults to min = max = zero) | ||
307 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
8 | openvdb::math::MinMax<ValueT> extrema = openvdb::tools::minMax(tree); |
308 |
1/14✗ Branch 0 not taken.
✓ Branch 1 taken 4 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.
|
8 | EXPECT_EQ(zero, extrema.min()); |
309 |
1/14✗ Branch 0 not taken.
✓ Branch 1 taken 4 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.
|
8 | EXPECT_EQ(zero, extrema.max()); |
310 | |||
311 | // Only one set voxel | ||
312 | 8 | tree.setValue(openvdb::Coord(0), minusTwo); | |
313 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
8 | extrema = openvdb::tools::minMax(tree); |
314 |
1/14✗ Branch 0 not taken.
✓ Branch 1 taken 4 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.
|
8 | EXPECT_EQ(minusTwo, extrema.min()); |
315 |
1/14✗ Branch 0 not taken.
✓ Branch 1 taken 4 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.
|
8 | EXPECT_EQ(minusTwo, extrema.max()); |
316 | |||
317 | // Multiple set voxels, single value | ||
318 | 8 | tree.setValue(openvdb::Coord(DIM), minusTwo); | |
319 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
8 | extrema = openvdb::tools::minMax(tree); |
320 |
1/14✗ Branch 0 not taken.
✓ Branch 1 taken 4 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.
|
8 | EXPECT_EQ(minusTwo, extrema.min()); |
321 |
1/14✗ Branch 0 not taken.
✓ Branch 1 taken 4 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.
|
8 | EXPECT_EQ(minusTwo, extrema.max()); |
322 | |||
323 | // Multiple set voxels, multiple values | ||
324 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
8 | tree.setValue(openvdb::Coord(DIM), plusTwo); |
325 | 8 | tree.setValue(openvdb::Coord(DIM*2), zero); | |
326 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
8 | extrema = openvdb::tools::minMax(tree); |
327 |
1/14✗ Branch 0 not taken.
✓ Branch 1 taken 4 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.
|
8 | EXPECT_EQ(minusTwo, extrema.min()); |
328 |
1/14✗ Branch 0 not taken.
✓ Branch 1 taken 4 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.
|
8 | EXPECT_EQ(plusTwo, extrema.max()); |
329 | |||
330 | // add some empty leaf nodes to test the join op | ||
331 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
8 | tree.setValueOnly(openvdb::Coord(DIM*3), ten); |
332 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
8 | tree.setValueOnly(openvdb::Coord(DIM*4),-ten); |
333 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
8 | extrema = openvdb::tools::minMax(tree); |
334 |
1/14✗ Branch 0 not taken.
✓ Branch 1 taken 4 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.
|
8 | EXPECT_EQ(minusTwo, extrema.min()); |
335 |
1/14✗ Branch 0 not taken.
✓ Branch 1 taken 4 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.
|
8 | EXPECT_EQ(plusTwo, extrema.max()); |
336 | |||
337 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
8 | tree.clear(); |
338 | |||
339 | // test tiles | ||
340 | using NodeChainT = typename TreeT::RootNodeType::NodeChainType; | ||
341 | using ChildT1 = typename NodeChainT::template Get<1>; // Leaf parent | ||
342 | using ChildT2 = typename NodeChainT::template Get<2>; // ChildT1 parent | ||
343 |
2/4✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
16 | tree.addTile(ChildT2::LEVEL, openvdb::Coord(0), -ten, true); |
344 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
8 | tree.addTile(ChildT2::LEVEL, openvdb::Coord(ChildT2::DIM), ten, true); |
345 |
2/4✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
16 | tree.addTile(ChildT1::LEVEL, openvdb::Coord(ChildT2::DIM + ChildT2::DIM), -twenty, false); |
346 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
8 | tree.setValueOnly(openvdb::Coord(-1), twenty); |
347 | 8 | tree.setValue(openvdb::Coord(-2), five); | |
348 | |||
349 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
8 | extrema = openvdb::tools::minMax(tree); |
350 |
2/16✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 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.
|
8 | EXPECT_EQ(-ten, extrema.min()); |
351 |
1/14✗ Branch 0 not taken.
✓ Branch 1 taken 4 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.
|
8 | EXPECT_EQ( ten, extrema.max()); |
352 | 8 | } | |
353 | |||
354 | /// Specialization for boolean trees | ||
355 | template<> | ||
356 | void | ||
357 | 1 | minMaxTest<openvdb::BoolTree>() | |
358 | { | ||
359 | 2 | openvdb::BoolTree tree(/*background=*/false); | |
360 | |||
361 | // No set voxels (defaults to min = max = zero) | ||
362 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | openvdb::math::MinMax<bool> extrema = openvdb::tools::minMax(tree); |
363 |
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(false, extrema.min()); |
364 |
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(false, extrema.max()); |
365 | |||
366 | // Only one set voxel | ||
367 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | tree.setValue(openvdb::Coord(0, 0, 0), true); |
368 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | extrema = openvdb::tools::minMax(tree); |
369 |
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(true, extrema.min()); |
370 |
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(true, extrema.max()); |
371 | |||
372 | // Multiple set voxels, single value | ||
373 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | tree.setValue(openvdb::Coord(-10, -10, -10), true); |
374 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | extrema = openvdb::tools::minMax(tree); |
375 |
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(true, extrema.min()); |
376 |
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(true, extrema.max()); |
377 | |||
378 | // Multiple set voxels, multiple values | ||
379 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | tree.setValue(openvdb::Coord(10, 10, 10), false); |
380 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | extrema = openvdb::tools::minMax(tree); |
381 |
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(false, extrema.min()); |
382 |
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(true, extrema.max()); |
383 | 1 | } | |
384 | |||
385 | /// Specialization for Coord trees | ||
386 | template<> | ||
387 | void | ||
388 | 1 | minMaxTest<openvdb::Coord>() | |
389 | { | ||
390 | using CoordTree = openvdb::tree::Tree4<openvdb::Coord,5,4,3>::Type; | ||
391 | const openvdb::Coord backg(5,4,-6), a(5,4,-7), b(5,5,-6); | ||
392 | |||
393 | 2 | CoordTree tree(backg); | |
394 | |||
395 | // No set voxels (defaults to min = max = zero) | ||
396 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | openvdb::math::MinMax<openvdb::Coord> extrema = openvdb::tools::minMax(tree); |
397 |
1/14✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
|
1 | EXPECT_EQ(openvdb::Coord(0), extrema.min()); |
398 |
1/14✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
|
1 | EXPECT_EQ(openvdb::Coord(0), extrema.max()); |
399 | |||
400 | // Only one set voxel | ||
401 | 1 | tree.setValue(openvdb::Coord(0, 0, 0), a); | |
402 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | extrema = openvdb::tools::minMax(tree); |
403 |
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(a, extrema.min()); |
404 |
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(a, extrema.max()); |
405 | |||
406 | // Multiple set voxels | ||
407 | ✗ | tree.setValue(openvdb::Coord(-10, -10, -10), b); | |
408 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | extrema = openvdb::tools::minMax(tree); |
409 |
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(a, extrema.min()); |
410 |
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(b, extrema.max()); |
411 | 1 | } | |
412 | |||
413 | } // unnamed namespace | ||
414 | |||
415 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | TEST_F(TestCount, testMinMax) |
416 | { | ||
417 | 1 | minMaxTest<openvdb::BoolTree>(); | |
418 | 1 | minMaxTest<openvdb::FloatTree>(); | |
419 | 1 | minMaxTest<openvdb::Int32Tree>(); | |
420 | 1 | minMaxTest<openvdb::Vec3STree>(); | |
421 | 1 | minMaxTest<openvdb::Vec2ITree>(); | |
422 | 1 | minMaxTest<openvdb::Coord>(); | |
423 | 1 | } | |
424 |