GCC Code Coverage Report


Directory: ./
File: openvdb/openvdb/unittest/TestGridBbox.cc
Date: 2022-07-25 17:40:05
Exec Total Coverage
Lines: 41 43 95.3%
Functions: 2 2 100.0%
Branches: 42 292 14.4%

Line Branch Exec Source
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3
4 #include <openvdb/openvdb.h>
5 #include <openvdb/tree/Tree.h>
6 #include <openvdb/tree/LeafNode.h>
7 #include <openvdb/Types.h>
8 #include <openvdb/Exceptions.h>
9
10 #include <gtest/gtest.h>
11
12
13 2 class TestGridBbox: public ::testing::Test
14 {
15 };
16
17
18 ////////////////////////////////////////
19
20
21
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 TEST_F(TestGridBbox, testLeafBbox)
22 {
23 2 openvdb::FloatTree tree(/*fillValue=*/256.0f);
24
25 1 openvdb::CoordBBox bbox;
26
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.evalLeafBoundingBox(bbox));
27
28 // Add values to buffer zero.
29
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.setValue(openvdb::Coord( 0, 9, 9), 2.0);
30
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.setValue(openvdb::Coord(100, 35, 800), 2.5);
31
32 // Coordinates in CoordBBox are inclusive!
33
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.evalLeafBoundingBox(bbox));
34
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, 8, 8), bbox.min());
35
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(104-1, 40-1, 808-1), bbox.max());
36
37 // Test negative coordinates.
38
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.setValue(openvdb::Coord(-100, -35, -800), 2.5);
39
40
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.evalLeafBoundingBox(bbox));
41
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(-104, -40, -800), bbox.min());
42
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(104-1, 40-1, 808-1), bbox.max());
43
44 // Clear the tree without trimming.
45
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.setValueOff(openvdb::Coord( 0, 9, 9));
46
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.setValueOff(openvdb::Coord(100, 35, 800));
47 tree.setValueOff(openvdb::Coord(-100, -35, -800));
48
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.evalLeafBoundingBox(bbox));
49 1 }
50
51
52
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 TEST_F(TestGridBbox, testGridBbox)
53 {
54 2 openvdb::FloatTree tree(/*fillValue=*/256.0f);
55
56 1 openvdb::CoordBBox bbox;
57
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.evalActiveVoxelBoundingBox(bbox));
58
59 // Add values to buffer zero.
60
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.setValue(openvdb::Coord( 1, 0, 0), 1.5);
61
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.setValue(openvdb::Coord( 0, 12, 8), 2.0);
62
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.setValue(openvdb::Coord( 1, 35, 800), 2.5);
63
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.setValue(openvdb::Coord(100, 0, 16), 3.0);
64
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.setValue(openvdb::Coord( 1, 0, 16), 3.5);
65
66 // Coordinates in CoordBBox are inclusive!
67
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.evalActiveVoxelBoundingBox(bbox));
68
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
1 EXPECT_EQ(openvdb::Coord( 0, 0, 0), bbox.min());
69
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(100, 35, 800), bbox.max());
70
71 // Test negative coordinates.
72
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.setValue(openvdb::Coord(-100, -35, -800), 2.5);
73
74
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.evalActiveVoxelBoundingBox(bbox));
75
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(-100, -35, -800), bbox.min());
76
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(100, 35, 800), bbox.max());
77
78 // Clear the tree without trimming.
79
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.setValueOff(openvdb::Coord( 1, 0, 0));
80
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.setValueOff(openvdb::Coord( 0, 12, 8));
81
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.setValueOff(openvdb::Coord( 1, 35, 800));
82
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.setValueOff(openvdb::Coord(100, 0, 16));
83
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.setValueOff(openvdb::Coord( 1, 0, 16));
84 tree.setValueOff(openvdb::Coord(-100, -35, -800));
85
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.evalActiveVoxelBoundingBox(bbox));
86 1 }
87