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/tree/LeafManager.h> | ||
6 | #include <openvdb/util/CpuTimer.h> | ||
7 | #include "util.h" // for unittest_util::makeSphere() | ||
8 | #include "gtest/gtest.h" | ||
9 | |||
10 | |||
11 | 4 | class TestLeafManager: public ::testing::Test | |
12 | { | ||
13 | public: | ||
14 | 4 | void SetUp() override { openvdb::initialize(); } | |
15 | 4 | void TearDown() override { openvdb::uninitialize(); } | |
16 | }; | ||
17 | |||
18 | |||
19 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TEST_F(TestLeafManager, testBasics) |
20 | { | ||
21 | using openvdb::CoordBBox; | ||
22 | using openvdb::Coord; | ||
23 | using openvdb::Vec3f; | ||
24 | using openvdb::FloatGrid; | ||
25 | using openvdb::FloatTree; | ||
26 | |||
27 | const Vec3f center(0.35f, 0.35f, 0.35f); | ||
28 | const float radius = 0.15f; | ||
29 | const int dim = 128, half_width = 5; | ||
30 | const float voxel_size = 1.0f/dim; | ||
31 | |||
32 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | FloatGrid::Ptr grid = FloatGrid::create(/*background=*/half_width*voxel_size); |
33 | FloatTree& tree = grid->tree(); | ||
34 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
|
2 | grid->setTransform(openvdb::math::Transform::createLinearTransform(/*voxel size=*/voxel_size)); |
35 | |||
36 | unittest_util::makeSphere<FloatGrid>( | ||
37 | ✗ | Coord(dim), center, radius, *grid, unittest_util::SPHERE_SPARSE_NARROW_BAND); | |
38 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | const size_t leafCount = tree.leafCount(); |
39 | |||
40 | //grid->print(std::cout, 3); | ||
41 | {// test with no aux buffers | ||
42 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | openvdb::tree::LeafManager<FloatTree> r(tree); |
43 |
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(leafCount, r.leafCount()); |
44 |
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(size_t(0), r.auxBufferCount()); |
45 |
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(size_t(0), r.auxBuffersPerLeaf()); |
46 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | size_t n = 0; |
47 |
2/2✓ Branch 0 taken 205 times.
✓ Branch 1 taken 1 times.
|
411 | for (FloatTree::LeafCIter iter=tree.cbeginLeaf(); iter; ++iter, ++n) { |
48 |
3/20✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
✓ Branch 3 taken 205 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 205 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
|
205 | EXPECT_TRUE(r.leaf(n) == *iter); |
49 |
2/18✓ Branch 2 taken 205 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 205 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
205 | EXPECT_TRUE(r.getBuffer(n,0) == iter->buffer()); |
50 | } | ||
51 |
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(r.leafCount(), n); |
52 |
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(!r.swapBuffer(0,0)); |
53 | |||
54 | r.rebuildAuxBuffers(2); | ||
55 | |||
56 |
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(leafCount, r.leafCount()); |
57 |
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(size_t(2), r.auxBuffersPerLeaf()); |
58 |
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(size_t(2*leafCount),r.auxBufferCount()); |
59 | |||
60 |
2/2✓ Branch 0 taken 205 times.
✓ Branch 1 taken 1 times.
|
206 | for (n=0; n<leafCount; ++n) { |
61 |
2/18✓ Branch 3 taken 205 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 205 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
|
205 | EXPECT_TRUE(r.getBuffer(n,0) == r.getBuffer(n,1)); |
62 |
2/18✓ Branch 3 taken 205 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 205 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
|
205 | EXPECT_TRUE(r.getBuffer(n,1) == r.getBuffer(n,2)); |
63 |
2/18✓ Branch 3 taken 205 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 205 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
|
205 | EXPECT_TRUE(r.getBuffer(n,0) == r.getBuffer(n,2)); |
64 | } | ||
65 | } | ||
66 | {// test with 2 aux buffers | ||
67 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | openvdb::tree::LeafManager<FloatTree> r(tree, 2); |
68 |
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(leafCount, r.leafCount()); |
69 |
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(size_t(2), r.auxBuffersPerLeaf()); |
70 |
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(size_t(2*leafCount),r.auxBufferCount()); |
71 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | size_t n = 0; |
72 |
2/2✓ Branch 0 taken 205 times.
✓ Branch 1 taken 1 times.
|
411 | for (FloatTree::LeafCIter iter=tree.cbeginLeaf(); iter; ++iter, ++n) { |
73 |
3/20✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
✓ Branch 3 taken 205 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 205 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
|
205 | EXPECT_TRUE(r.leaf(n) == *iter); |
74 |
2/18✓ Branch 2 taken 205 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 205 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
205 | EXPECT_TRUE(r.getBuffer(n,0) == iter->buffer()); |
75 | |||
76 |
2/18✓ Branch 3 taken 205 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 205 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
|
205 | EXPECT_TRUE(r.getBuffer(n,0) == r.getBuffer(n,1)); |
77 |
2/18✓ Branch 3 taken 205 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 205 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
|
205 | EXPECT_TRUE(r.getBuffer(n,1) == r.getBuffer(n,2)); |
78 |
2/18✓ Branch 3 taken 205 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 205 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
|
205 | EXPECT_TRUE(r.getBuffer(n,0) == r.getBuffer(n,2)); |
79 | } | ||
80 |
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(r.leafCount(), n); |
81 |
2/2✓ Branch 0 taken 205 times.
✓ Branch 1 taken 1 times.
|
206 | for (n=0; n<leafCount; ++n) r.leaf(n).buffer().setValue(4,2.4f); |
82 |
2/2✓ Branch 0 taken 205 times.
✓ Branch 1 taken 1 times.
|
206 | for (n=0; n<leafCount; ++n) { |
83 |
1/16✗ Branch 2 not taken.
✓ Branch 3 taken 205 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 18 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
|
410 | EXPECT_TRUE(r.getBuffer(n,0) != r.getBuffer(n,1)); |
84 |
2/18✓ Branch 3 taken 205 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 205 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
|
205 | EXPECT_TRUE(r.getBuffer(n,1) == r.getBuffer(n,2)); |
85 |
1/16✗ Branch 2 not taken.
✓ Branch 3 taken 205 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 18 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
|
410 | EXPECT_TRUE(r.getBuffer(n,0) != r.getBuffer(n,2)); |
86 | } | ||
87 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | r.syncAllBuffers(); |
88 |
2/2✓ Branch 0 taken 205 times.
✓ Branch 1 taken 1 times.
|
206 | for (n=0; n<leafCount; ++n) { |
89 |
2/18✓ Branch 3 taken 205 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 205 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
|
205 | EXPECT_TRUE(r.getBuffer(n,0) == r.getBuffer(n,1)); |
90 |
2/18✓ Branch 3 taken 205 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 205 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
|
205 | EXPECT_TRUE(r.getBuffer(n,1) == r.getBuffer(n,2)); |
91 |
2/18✓ Branch 3 taken 205 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 205 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
|
205 | EXPECT_TRUE(r.getBuffer(n,0) == r.getBuffer(n,2)); |
92 | } | ||
93 |
2/2✓ Branch 0 taken 205 times.
✓ Branch 1 taken 1 times.
|
206 | for (n=0; n<leafCount; ++n) r.getBuffer(n,1).setValue(4,5.4f); |
94 |
2/2✓ Branch 0 taken 205 times.
✓ Branch 1 taken 1 times.
|
206 | for (n=0; n<leafCount; ++n) { |
95 |
1/16✗ Branch 2 not taken.
✓ Branch 3 taken 205 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 18 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
|
410 | EXPECT_TRUE(r.getBuffer(n,0) != r.getBuffer(n,1)); |
96 |
1/16✗ Branch 2 not taken.
✓ Branch 3 taken 205 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 18 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
|
410 | EXPECT_TRUE(r.getBuffer(n,1) != r.getBuffer(n,2)); |
97 |
2/18✓ Branch 3 taken 205 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 205 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
|
205 | EXPECT_TRUE(r.getBuffer(n,0) == r.getBuffer(n,2)); |
98 | } | ||
99 |
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(r.swapLeafBuffer(1)); |
100 |
2/2✓ Branch 0 taken 205 times.
✓ Branch 1 taken 1 times.
|
206 | for (n=0; n<leafCount; ++n) { |
101 |
1/16✗ Branch 2 not taken.
✓ Branch 3 taken 205 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 18 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
|
410 | EXPECT_TRUE(r.getBuffer(n,0) != r.getBuffer(n,1)); |
102 |
2/18✓ Branch 3 taken 205 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 205 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
|
205 | EXPECT_TRUE(r.getBuffer(n,1) == r.getBuffer(n,2)); |
103 |
1/16✗ Branch 2 not taken.
✓ Branch 3 taken 205 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 18 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
|
410 | EXPECT_TRUE(r.getBuffer(n,0) != r.getBuffer(n,2)); |
104 | } | ||
105 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | r.syncAuxBuffer(1); |
106 |
2/2✓ Branch 0 taken 205 times.
✓ Branch 1 taken 1 times.
|
206 | for (n=0; n<leafCount; ++n) { |
107 |
2/18✓ Branch 3 taken 205 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 205 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
|
205 | EXPECT_TRUE(r.getBuffer(n,0) == r.getBuffer(n,1)); |
108 |
1/16✗ Branch 2 not taken.
✓ Branch 3 taken 205 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 18 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
|
410 | EXPECT_TRUE(r.getBuffer(n,1) != r.getBuffer(n,2)); |
109 |
1/16✗ Branch 2 not taken.
✓ Branch 3 taken 205 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 18 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
|
410 | EXPECT_TRUE(r.getBuffer(n,0) != r.getBuffer(n,2)); |
110 | } | ||
111 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | r.syncAuxBuffer(2); |
112 |
2/2✓ Branch 0 taken 205 times.
✓ Branch 1 taken 1 times.
|
206 | for (n=0; n<leafCount; ++n) { |
113 |
2/18✓ Branch 3 taken 205 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 205 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
|
205 | EXPECT_TRUE(r.getBuffer(n,0) == r.getBuffer(n,1)); |
114 |
2/18✓ Branch 3 taken 205 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 205 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
|
205 | EXPECT_TRUE(r.getBuffer(n,1) == r.getBuffer(n,2)); |
115 | } | ||
116 | } | ||
117 | {// test with const tree (buffers are not swappable) | ||
118 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | openvdb::tree::LeafManager<const FloatTree> r(tree); |
119 | |||
120 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | for (size_t numAuxBuffers = 0; numAuxBuffers <= 2; ++numAuxBuffers += 2) { |
121 | r.rebuildAuxBuffers(numAuxBuffers); | ||
122 | |||
123 |
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(leafCount, r.leafCount()); |
124 |
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(int(numAuxBuffers * leafCount), int(r.auxBufferCount())); |
125 |
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(numAuxBuffers, r.auxBuffersPerLeaf()); |
126 | |||
127 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | size_t n = 0; |
128 |
2/2✓ Branch 0 taken 205 times.
✓ Branch 1 taken 1 times.
|
411 | for (FloatTree::LeafCIter iter = tree.cbeginLeaf(); iter; ++iter, ++n) { |
129 |
3/20✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
✓ Branch 3 taken 205 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 205 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
|
205 | EXPECT_TRUE(r.leaf(n) == *iter); |
130 | // Verify that each aux buffer was initialized with a copy of the leaf buffer. | ||
131 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
|
205 | for (size_t bufIdx = 0; bufIdx < numAuxBuffers; ++bufIdx) { |
132 | ✗ | EXPECT_TRUE(r.getBuffer(n, bufIdx) == iter->buffer()); | |
133 | } | ||
134 | } | ||
135 |
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(r.leafCount(), n); |
136 | |||
137 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | for (size_t i = 0; i < numAuxBuffers; ++i) { |
138 | ✗ | for (size_t j = 0; j < numAuxBuffers; ++j) { | |
139 | // Verify that swapping buffers with themselves and swapping | ||
140 | // leaf buffers with aux buffers have no effect. | ||
141 | ✗ | const bool canSwap = (i != j && i != 0 && j != 0); | |
142 | ✗ | EXPECT_EQ(canSwap, r.swapBuffer(i, j)); | |
143 | } | ||
144 | } | ||
145 | } | ||
146 | } | ||
147 | 1 | } | |
148 | |||
149 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | TEST_F(TestLeafManager, testActiveLeafVoxelCount) |
150 | { | ||
151 | using namespace openvdb; | ||
152 | |||
153 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
|
5 | for (const Int32 dim: { 87, 1023, 1024, 2023 }) { |
154 | 4 | const CoordBBox denseBBox{Coord{0}, Coord{dim - 1}}; | |
155 | 4 | const auto size = denseBBox.volume(); | |
156 | |||
157 | // Create a large dense tree for testing but use a MaskTree to | ||
158 | // minimize the memory overhead | ||
159 | 8 | MaskTree tree{false}; | |
160 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | tree.denseFill(denseBBox, true, true); |
161 | // Add some tiles, which should not contribute to the leaf voxel count. | ||
162 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | tree.addTile(/*level=*/2, Coord{10000}, true, true); |
163 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | tree.addTile(/*level=*/1, Coord{-10000}, true, true); |
164 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | tree.addTile(/*level=*/1, Coord{20000}, false, false); |
165 | |||
166 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
8 | tree::LeafManager<MaskTree> mgr(tree); |
167 | |||
168 | // On a dual CPU Intel(R) Xeon(R) E5-2697 v3 @ 2.60GHz | ||
169 | // the speedup of LeafManager::activeLeafVoxelCount over | ||
170 | // Tree::activeLeafVoxelCount is ~15x (assuming a LeafManager already exists) | ||
171 | //openvdb::util::CpuTimer t("\nTree::activeVoxelCount"); | ||
172 | const auto treeActiveVoxels = tree.activeVoxelCount(); | ||
173 | //t.restart("\nTree::activeLeafVoxelCount"); | ||
174 | 4 | const auto treeActiveLeafVoxels = tree.activeLeafVoxelCount(); | |
175 | //t.restart("\nLeafManager::activeLeafVoxelCount"); | ||
176 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | const auto mgrActiveLeafVoxels = mgr.activeLeafVoxelCount();//multi-threaded |
177 | //t.stop(); | ||
178 | //std::cerr << "Old1 = " << treeActiveVoxels << " old2 = " << treeActiveLeafVoxels | ||
179 | // << " New = " << mgrActiveLeafVoxels << std::endl; | ||
180 |
1/16✗ 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 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
4 | EXPECT_TRUE(size < treeActiveVoxels); |
181 |
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.
|
4 | EXPECT_EQ(size, treeActiveLeafVoxels); |
182 |
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.
|
4 | EXPECT_EQ(size, mgrActiveLeafVoxels); |
183 | } | ||
184 | 1 | } | |
185 | |||
186 | namespace { | ||
187 | |||
188 | struct ForeachOp | ||
189 | { | ||
190 | 1 | ForeachOp(float v) : mV(v) {} | |
191 | template <typename T> | ||
192 | 2 | void operator()(T &leaf, size_t) const | |
193 | { | ||
194 |
2/2✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 2 times.
|
1026 | for (typename T::ValueOnIter iter = leaf.beginValueOn(); iter; ++iter) { |
195 |
2/2✓ Branch 0 taken 512 times.
✓ Branch 1 taken 512 times.
|
1024 | if ( *iter > mV) iter.setValue( 2.0f ); |
196 | } | ||
197 | 2 | } | |
198 | const float mV; | ||
199 | };// ForeachOp | ||
200 | |||
201 | struct ReduceOp | ||
202 | { | ||
203 | 1 | ReduceOp(float v) : mV(v), mN(0) {} | |
204 | ReduceOp(const ReduceOp &other) : mV(other.mV), mN(other.mN) {} | ||
205 | 1 | ReduceOp(const ReduceOp &other, tbb::split) : mV(other.mV), mN(0) {} | |
206 | template <typename T> | ||
207 | 2 | void operator()(T &leaf, size_t) | |
208 | { | ||
209 |
2/2✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 2 times.
|
1026 | for (typename T::ValueOnIter iter = leaf.beginValueOn(); iter; ++iter) { |
210 |
2/2✓ Branch 0 taken 512 times.
✓ Branch 1 taken 512 times.
|
1024 | if ( *iter > mV) ++mN; |
211 | } | ||
212 | 2 | } | |
213 | 1 | void join(const ReduceOp &other) {mN += other.mN;} | |
214 | const float mV; | ||
215 | openvdb::Index mN; | ||
216 | };// ReduceOp | ||
217 | |||
218 | }//unnamed namespace | ||
219 | |||
220 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | TEST_F(TestLeafManager, testForeach) |
221 | { | ||
222 | using namespace openvdb; | ||
223 | |||
224 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | FloatTree tree( 0.0f ); |
225 | const int dim = int(FloatTree::LeafNodeType::dim()); | ||
226 | 1 | const CoordBBox bbox1(Coord(0),Coord(dim-1)); | |
227 | 1 | const CoordBBox bbox2(Coord(dim),Coord(2*dim-1)); | |
228 | |||
229 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | tree.fill( bbox1, -1.0f); |
230 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | tree.fill( bbox2, 1.0f); |
231 | tree.voxelizeActiveTiles(); | ||
232 | |||
233 |
2/2✓ Branch 0 taken 512 times.
✓ Branch 1 taken 1 times.
|
513 | for (CoordBBox::Iterator<true> iter(bbox1); iter; ++iter) { |
234 |
2/16✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 512 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
512 | EXPECT_EQ( -1.0f, tree.getValue(*iter)); |
235 | } | ||
236 |
2/2✓ Branch 0 taken 512 times.
✓ Branch 1 taken 1 times.
|
513 | for (CoordBBox::Iterator<true> iter(bbox2); iter; ++iter) { |
237 |
2/16✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 512 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
512 | EXPECT_EQ( 1.0f, tree.getValue(*iter)); |
238 | } | ||
239 | |||
240 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | tree::LeafManager<FloatTree> r(tree); |
241 |
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(size_t(2), r.leafCount()); |
242 |
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(size_t(0), r.auxBufferCount()); |
243 |
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(size_t(0), r.auxBuffersPerLeaf()); |
244 | |||
245 | ForeachOp op(0.0f); | ||
246 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | r.foreach(op); |
247 | |||
248 |
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(size_t(2), r.leafCount()); |
249 |
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(size_t(0), r.auxBufferCount()); |
250 |
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(size_t(0), r.auxBuffersPerLeaf()); |
251 | |||
252 |
2/2✓ Branch 0 taken 512 times.
✓ Branch 1 taken 1 times.
|
513 | for (CoordBBox::Iterator<true> iter(bbox1); iter; ++iter) { |
253 |
2/16✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 512 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
512 | EXPECT_EQ( -1.0f, tree.getValue(*iter)); |
254 | } | ||
255 |
2/2✓ Branch 0 taken 512 times.
✓ Branch 1 taken 1 times.
|
513 | for (CoordBBox::Iterator<true> iter(bbox2); iter; ++iter) { |
256 |
2/16✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 512 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
512 | EXPECT_EQ( 2.0f, tree.getValue(*iter)); |
257 | } | ||
258 | 1 | } | |
259 | |||
260 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | TEST_F(TestLeafManager, testReduce) |
261 | { | ||
262 | using namespace openvdb; | ||
263 | |||
264 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | FloatTree tree( 0.0f ); |
265 | const int dim = int(FloatTree::LeafNodeType::dim()); | ||
266 | 1 | const CoordBBox bbox1(Coord(0),Coord(dim-1)); | |
267 | 1 | const CoordBBox bbox2(Coord(dim),Coord(2*dim-1)); | |
268 | |||
269 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | tree.fill( bbox1, -1.0f); |
270 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | tree.fill( bbox2, 1.0f); |
271 | tree.voxelizeActiveTiles(); | ||
272 | |||
273 |
2/2✓ Branch 0 taken 512 times.
✓ Branch 1 taken 1 times.
|
513 | for (CoordBBox::Iterator<true> iter(bbox1); iter; ++iter) { |
274 |
2/16✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 512 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
512 | EXPECT_EQ( -1.0f, tree.getValue(*iter)); |
275 | } | ||
276 |
2/2✓ Branch 0 taken 512 times.
✓ Branch 1 taken 1 times.
|
513 | for (CoordBBox::Iterator<true> iter(bbox2); iter; ++iter) { |
277 |
2/16✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 512 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
512 | EXPECT_EQ( 1.0f, tree.getValue(*iter)); |
278 | } | ||
279 | |||
280 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | tree::LeafManager<FloatTree> r(tree); |
281 |
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(size_t(2), r.leafCount()); |
282 |
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(size_t(0), r.auxBufferCount()); |
283 |
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(size_t(0), r.auxBuffersPerLeaf()); |
284 | |||
285 | ReduceOp op(0.0f); | ||
286 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | r.reduce(op); |
287 |
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(FloatTree::LeafNodeType::numValues(), op.mN); |
288 | |||
289 |
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(size_t(2), r.leafCount()); |
290 |
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(size_t(0), r.auxBufferCount()); |
291 |
2/22✓ 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 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.
|
1 | EXPECT_EQ(size_t(0), r.auxBuffersPerLeaf()); |
292 | |||
293 | 1 | Index n = 0; | |
294 |
2/2✓ Branch 0 taken 512 times.
✓ Branch 1 taken 1 times.
|
513 | for (CoordBBox::Iterator<true> iter(bbox1); iter; ++iter) { |
295 |
1/2✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
|
512 | ++n; |
296 |
2/16✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 512 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
512 | EXPECT_EQ( -1.0f, tree.getValue(*iter)); |
297 | } | ||
298 |
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(FloatTree::LeafNodeType::numValues(), n); |
299 | |||
300 | 1 | n = 0; | |
301 |
2/2✓ Branch 0 taken 512 times.
✓ Branch 1 taken 1 times.
|
513 | for (CoordBBox::Iterator<true> iter(bbox2); iter; ++iter) { |
302 |
1/2✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
|
512 | ++n; |
303 |
2/16✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 512 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
512 | EXPECT_EQ( 1.0f, tree.getValue(*iter)); |
304 | } | ||
305 |
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(FloatTree::LeafNodeType::numValues(), n); |
306 | 1 | } | |
307 |