GCC Code Coverage Report


Directory: ./
File: openvdb/openvdb/unittest/TestFile.cc
Date: 2022-07-25 17:40:05
Exec Total Coverage
Lines: 1275 1301 98.0%
Functions: 45 46 97.8%
Branches: 2052 9013 22.8%

Line Branch Exec Source
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3
4 #include <openvdb/Exceptions.h>
5 #include <openvdb/io/File.h>
6 #include <openvdb/io/io.h>
7 #include <openvdb/io/Queue.h>
8 #include <openvdb/io/Stream.h>
9 #include <openvdb/Metadata.h>
10 #include <openvdb/math/Transform.h>
11 #include <openvdb/tools/Count.h>
12 #include <openvdb/tools/LevelSetUtil.h> // for tools::sdfToFogVolume()
13 #include <openvdb/util/logging.h>
14 #include <openvdb/version.h>
15 #include <openvdb/openvdb.h>
16 #include "util.h" // for unittest_util::makeSphere()
17
18 #include <gtest/gtest.h>
19
20 #include <thread>
21 #include <chrono>
22 #include <algorithm> // for std::sort()
23 #include <cstdio> // for remove() and rename()
24 #include <fstream>
25 #include <functional> // for std::bind()
26 #include <iostream>
27 #include <map>
28 #include <memory>
29 #include <set>
30 #include <sstream>
31 #include <string>
32 #include <vector>
33 #include <sys/types.h> // for stat()
34 #include <sys/stat.h>
35 #ifndef _WIN32
36 #include <unistd.h>
37 #endif
38 #ifdef OPENVDB_USE_BLOSC
39 #include <blosc.h>
40 #include <cstring> // for memset()
41 #endif
42
43
44 25 class TestFile: public ::testing::Test
45 {
46 public:
47 25 void SetUp() override {}
48 25 void TearDown() override { openvdb::uninitialize(); }
49
50 void testHeader();
51 void testWriteGrid();
52 void testWriteMultipleGrids();
53 void testReadGridDescriptors();
54 void testEmptyGridIO();
55 void testOpen();
56 void testDelayedLoadMetadata();
57 void testNonVdbOpen();
58 };
59
60
61 ////////////////////////////////////////
62
63 void
64 1 TestFile::testHeader()
65 {
66 using namespace openvdb::io;
67
68
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 File file("something.vdb2");
69
70 std::ostringstream
71
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 ostr(std::ios_base::binary),
72
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 ostr2(std::ios_base::binary);
73
74
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 file.writeHeader(ostr2, /*seekable=*/true);
75
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 std::string uuidStr = file.getUniqueTag();
76
77
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 file.writeHeader(ostr, /*seekable=*/true);
78 // Verify that a file gets a new UUID each time it is written.
79
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(!file.isIdentical(uuidStr));
80
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 uuidStr = file.getUniqueTag();
81
82
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::istringstream istr(ostr.str(), std::ios_base::binary);
83
84 bool unique=true;
85
5/22
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
1 EXPECT_NO_THROW(unique=file.readHeader(istr));
86
87
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(!unique);//reading same file again
88
89
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 uint32_t version = openvdb::OPENVDB_FILE_VERSION;
90
91
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(version, file.fileVersion());
92
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(openvdb::OPENVDB_LIBRARY_MAJOR_VERSION, file.libraryVersion().first);
93
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(openvdb::OPENVDB_LIBRARY_MINOR_VERSION, file.libraryVersion().second);
94
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.
2 EXPECT_EQ(uuidStr, file.getUniqueTag());
95
96 //std::cerr << "\nuuid=" << uuidStr << std::endl;
97
98
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(file.isIdentical(uuidStr));
99
100 1 remove("something.vdb2");
101 1 }
102
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 TEST_F(TestFile, testHeader) { testHeader(); }
103
104
105 void
106 1 TestFile::testWriteGrid()
107 {
108 using namespace openvdb;
109 using namespace openvdb::io;
110
111 using TreeType = Int32Tree;
112 using GridType = Grid<TreeType>;
113
114 logging::LevelScope suppressLogging{logging::Level::Fatal};
115
116
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 File file("something.vdb2");
117
118
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::ostringstream ostr(std::ios_base::binary);
119
120 // Create a grid with transform.
121
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::Transform::Ptr trans = math::Transform::createLinearTransform(0.1);
122
123
1/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 GridType::Ptr grid = createGrid<GridType>(/*bg=*/1);
124 TreeType& tree = grid->tree();
125
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 grid->setTransform(trans);
126
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.setValue(Coord(10, 1, 2), 10);
127
1/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 tree.setValue(Coord(0, 0, 0), 5);
128
129 // Add some metadata.
130
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Metadata::clearRegistry();
131
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StringMetadata::registerType();
132
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 const std::string meta0Val, meta1Val("Hello, world.");
133
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
2 Metadata::Ptr stringMetadata = Metadata::createMetadata(typeNameAsString<std::string>());
134
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(stringMetadata);
135
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (stringMetadata) {
136
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->insertMeta("meta0", *stringMetadata);
137
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->metaValue<std::string>("meta0") = meta0Val;
138
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->insertMeta("meta1", *stringMetadata);
139
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 grid->metaValue<std::string>("meta1") = meta1Val;
140 }
141
142 // Create the grid descriptor out of this grid.
143
3/8
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
3 GridDescriptor gd(Name("temperature"), grid->type());
144
145 // Write out the grid.
146
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
2 file.writeGrid(gd, grid, ostr, /*seekable=*/true);
147
148
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(gd.getGridPos() != 0);
149
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(gd.getBlockPos() != 0);
150
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(gd.getEndPos() != 0);
151
152 // Read in the grid descriptor.
153
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 GridDescriptor gd2;
154
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::istringstream istr(ostr.str(), std::ios_base::binary);
155
156 // Since the input is only a fragment of a VDB file (in particular,
157 // it doesn't have a header), set the file format version number explicitly.
158
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 io::setCurrentVersion(istr);
159
160
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridBase::Ptr gd2_grid;
161
4/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
2 EXPECT_THROW(gd2.read(istr), openvdb::LookupError);
162
163 // Register the grid and the transform and the blocks.
164
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridBase::clearRegistry();
165
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridType::registerGrid();
166
167 // Register transform maps
168
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::MapRegistry::clear();
169
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::AffineMap::registerMap();
170
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::ScaleMap::registerMap();
171
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::UniformScaleMap::registerMap();
172
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::TranslationMap::registerMap();
173
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::ScaleTranslateMap::registerMap();
174
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::UniformScaleTranslateMap::registerMap();
175
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::NonlinearFrustumMap::registerMap();
176
177
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 istr.seekg(0, std::ios_base::beg);
178
5/22
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
1 EXPECT_NO_THROW(gd2_grid = gd2.read(istr));
179
180
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(gd.gridName(), gd2.gridName());
181
3/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
2 EXPECT_EQ(GridType::gridType(), gd2_grid->type());
182
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(gd.getGridPos(), gd2.getGridPos());
183
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(gd.getBlockPos(), gd2.getBlockPos());
184
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(gd.getEndPos(), gd2.getEndPos());
185
186 // Position the stream to beginning of the grid storage and read the grid.
187
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd2.seekToGrid(istr);
188
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Archive::readGridCompression(istr);
189
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd2_grid->readMeta(istr);
190 gd2_grid->readTransform(istr);
191
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd2_grid->readTopology(istr);
192
193 // Remove delay load metadata if it exists.
194
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
2 if ((*gd2_grid)["file_delayed_load"]) {
195 gd2_grid->removeMeta("file_delayed_load");
196 }
197
198 // Ensure that we have the same metadata.
199
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(grid->metaCount(), gd2_grid->metaCount());
200
2/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 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.
2 EXPECT_TRUE((*gd2_grid)["meta0"]);
201
2/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 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.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
2 EXPECT_TRUE((*gd2_grid)["meta1"]);
202
3/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
2 EXPECT_EQ(meta0Val, gd2_grid->metaValue<std::string>("meta0"));
203
3/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
2 EXPECT_EQ(meta1Val, gd2_grid->metaValue<std::string>("meta1"));
204
205 // Ensure that we have the same topology and transform.
206
5/22
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1 EXPECT_EQ(
207 grid->baseTree().leafCount(), gd2_grid->baseTree().leafCount());
208
5/22
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1 EXPECT_EQ(
209 grid->baseTree().nonLeafCount(), gd2_grid->baseTree().nonLeafCount());
210
5/22
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1 EXPECT_EQ(
211 grid->baseTree().treeDepth(), gd2_grid->baseTree().treeDepth());
212
213 //EXPECT_EQ(0.1, gd2_grid->getTransform()->getVoxelSizeX());
214 //EXPECT_EQ(0.1, gd2_grid->getTransform()->getVoxelSizeY());
215 //EXPECT_EQ(0.1, gd2_grid->getTransform()->getVoxelSizeZ());
216
217 // Read in the data blocks.
218
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd2.seekToBlocks(istr);
219
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd2_grid->readBuffers(istr);
220
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
2 TreeType::Ptr tree2 = DynamicPtrCast<TreeType>(gd2_grid->baseTreePtr());
221
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(tree2.get() != nullptr);
222
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(10, tree2->getValue(Coord(10, 1, 2)));
223
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(5, tree2->getValue(Coord(0, 0, 0)));
224
225
2/16
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1 EXPECT_EQ(1, tree2->getValue(Coord(1000, 1000, 16000)));
226 // Clear registries.
227
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridBase::clearRegistry();
228
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Metadata::clearRegistry();
229
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::MapRegistry::clear();
230
231 1 remove("something.vdb2");
232 1 }
233
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 TEST_F(TestFile, testWriteGrid) { testWriteGrid(); }
234
235
236 void
237 1 TestFile::testWriteMultipleGrids()
238 {
239 using namespace openvdb;
240 using namespace openvdb::io;
241
242 using TreeType = Int32Tree;
243 using GridType = Grid<TreeType>;
244
245 logging::LevelScope suppressLogging{logging::Level::Fatal};
246
247
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 File file("something.vdb2");
248
249
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::ostringstream ostr(std::ios_base::binary);
250
251 // Create a grid with transform.
252
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 GridType::Ptr grid = createGrid<GridType>(/*bg=*/1);
253 TreeType& tree = grid->tree();
254
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.setValue(Coord(10, 1, 2), 10);
255
1/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 tree.setValue(Coord(0, 0, 0), 5);
256
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::Transform::Ptr trans = math::Transform::createLinearTransform(0.1);
257
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 grid->setTransform(trans);
258
259
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 GridType::Ptr grid2 = createGrid<GridType>(/*bg=*/2);
260 TreeType& tree2 = grid2->tree();
261
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree2.setValue(Coord(0, 0, 0), 10);
262
1/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 tree2.setValue(Coord(1000, 1000, 1000), 50);
263
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::Transform::Ptr trans2 = math::Transform::createLinearTransform(0.2);
264
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
2 grid2->setTransform(trans2);
265
266 // Create the grid descriptor out of this grid.
267
4/10
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
3 GridDescriptor gd(Name("temperature"), grid->type());
268
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 GridDescriptor gd2(Name("density"), grid2->type());
269
270 // Write out the grids.
271
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 file.writeGrid(gd, grid, ostr, /*seekable=*/true);
272
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
2 file.writeGrid(gd2, grid2, ostr, /*seekable=*/true);
273
274
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(gd.getGridPos() != 0);
275
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(gd.getBlockPos() != 0);
276
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(gd.getEndPos() != 0);
277
278
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(gd2.getGridPos() != 0);
279
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(gd2.getBlockPos() != 0);
280
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(gd2.getEndPos() != 0);
281
282 // register the grid
283
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridBase::clearRegistry();
284
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridType::registerGrid();
285
286 // register maps
287
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::MapRegistry::clear();
288
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::AffineMap::registerMap();
289
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::ScaleMap::registerMap();
290
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::UniformScaleMap::registerMap();
291
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::TranslationMap::registerMap();
292
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::ScaleTranslateMap::registerMap();
293
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::UniformScaleTranslateMap::registerMap();
294
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::NonlinearFrustumMap::registerMap();
295
296 // Read in the first grid descriptor.
297
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 GridDescriptor gd_in;
298
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::istringstream istr(ostr.str(), std::ios_base::binary);
299
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 io::setCurrentVersion(istr);
300
301 1 GridBase::Ptr gd_in_grid;
302
5/22
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
1 EXPECT_NO_THROW(gd_in_grid = gd_in.read(istr));
303
304 // Ensure read in the right values.
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(gd.gridName(), gd_in.gridName());
306
3/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
2 EXPECT_EQ(GridType::gridType(), gd_in_grid->type());
307
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(gd.getGridPos(), gd_in.getGridPos());
308
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(gd.getBlockPos(), gd_in.getBlockPos());
309
2/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_EQ(gd.getEndPos(), gd_in.getEndPos());
310
311 // Position the stream to beginning of the grid storage and read the grid.
312
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd_in.seekToGrid(istr);
313
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Archive::readGridCompression(istr);
314
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd_in_grid->readMeta(istr);
315 gd_in_grid->readTransform(istr);
316
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd_in_grid->readTopology(istr);
317
318 // Ensure that we have the same topology and transform.
319
5/22
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1 EXPECT_EQ(
320 grid->baseTree().leafCount(), gd_in_grid->baseTree().leafCount());
321
5/22
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1 EXPECT_EQ(
322 grid->baseTree().nonLeafCount(), gd_in_grid->baseTree().nonLeafCount());
323
5/22
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1 EXPECT_EQ(
324 grid->baseTree().treeDepth(), gd_in_grid->baseTree().treeDepth());
325
326 // EXPECT_EQ(0.1, gd_in_grid->getTransform()->getVoxelSizeX());
327 // EXPECT_EQ(0.1, gd_in_grid->getTransform()->getVoxelSizeY());
328 // EXPECT_EQ(0.1, gd_in_grid->getTransform()->getVoxelSizeZ());
329
330 // Read in the data blocks.
331
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd_in.seekToBlocks(istr);
332
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd_in_grid->readBuffers(istr);
333
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
2 TreeType::Ptr grid_in = DynamicPtrCast<TreeType>(gd_in_grid->baseTreePtr());
334
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_in.get() != nullptr);
335
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(10, grid_in->getValue(Coord(10, 1, 2)));
336
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(5, grid_in->getValue(Coord(0, 0, 0)));
337
2/16
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1 EXPECT_EQ(1, grid_in->getValue(Coord(1000, 1000, 16000)));
338
339 /////////////////////////////////////////////////////////////////
340 // Now read in the second grid descriptor. Make use of hte end offset.
341 ///////////////////////////////////////////////////////////////
342
343
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd_in.seekToEnd(istr);
344
345
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 GridDescriptor gd2_in;
346 1 GridBase::Ptr gd2_in_grid;
347
5/22
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
1 EXPECT_NO_THROW(gd2_in_grid = gd2_in.read(istr));
348
349 // Ensure that we read in the right values.
350
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(gd2.gridName(), gd2_in.gridName());
351
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.
2 EXPECT_EQ(TreeType::treeType(), gd2_in_grid->type());
352
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(gd2.getGridPos(), gd2_in.getGridPos());
353
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(gd2.getBlockPos(), gd2_in.getBlockPos());
354
2/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_EQ(gd2.getEndPos(), gd2_in.getEndPos());
355
356 // Position the stream to beginning of the grid storage and read the grid.
357
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd2_in.seekToGrid(istr);
358
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Archive::readGridCompression(istr);
359
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd2_in_grid->readMeta(istr);
360 gd2_in_grid->readTransform(istr);
361
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd2_in_grid->readTopology(istr);
362
363 // Ensure that we have the same topology and transform.
364
5/22
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1 EXPECT_EQ(
365 grid2->baseTree().leafCount(), gd2_in_grid->baseTree().leafCount());
366
5/22
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1 EXPECT_EQ(
367 grid2->baseTree().nonLeafCount(), gd2_in_grid->baseTree().nonLeafCount());
368
5/22
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1 EXPECT_EQ(
369 grid2->baseTree().treeDepth(), gd2_in_grid->baseTree().treeDepth());
370 // EXPECT_EQ(0.2, gd2_in_grid->getTransform()->getVoxelSizeX());
371 // EXPECT_EQ(0.2, gd2_in_grid->getTransform()->getVoxelSizeY());
372 // EXPECT_EQ(0.2, gd2_in_grid->getTransform()->getVoxelSizeZ());
373
374 // Read in the data blocks.
375
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd2_in.seekToBlocks(istr);
376
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd2_in_grid->readBuffers(istr);
377
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
2 TreeType::Ptr grid2_in = DynamicPtrCast<TreeType>(gd2_in_grid->baseTreePtr());
378
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(grid2_in.get() != nullptr);
379
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(50, grid2_in->getValue(Coord(1000, 1000, 1000)));
380
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(10, grid2_in->getValue(Coord(0, 0, 0)));
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(2, grid2_in->getValue(Coord(100000, 100000, 16000)));
382
383 // Clear registries.
384
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridBase::clearRegistry();
385
386
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::MapRegistry::clear();
387 1 remove("something.vdb2");
388 1 }
389
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 TEST_F(TestFile, testWriteMultipleGrids) { testWriteMultipleGrids(); }
390
391
392
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 TEST_F(TestFile, testWriteFloatAsHalf)
393 {
394 using namespace openvdb;
395 using namespace openvdb::io;
396
397 using TreeType = Vec3STree;
398 using GridType = Grid<TreeType>;
399
400 // Register all grid types.
401 1 initialize();
402 // Ensure that the registry is cleared on exit.
403 1 struct Local { static void uninitialize(char*) { openvdb::uninitialize(); } };
404 SharedPtr<char> onExit(nullptr, Local::uninitialize);
405
406 // Create two test grids.
407
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 GridType::Ptr grid1 = createGrid<GridType>(/*bg=*/Vec3s(1, 1, 1));
408 TreeType& tree1 = grid1->tree();
409
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(grid1.get() != nullptr);
410
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 grid1->setTransform(math::Transform::createLinearTransform(0.1));
411
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 grid1->setName("grid1");
412
413
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 GridType::Ptr grid2 = createGrid<GridType>(/*bg=*/Vec3s(2, 2, 2));
414
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(grid2.get() != nullptr);
415 TreeType& tree2 = grid2->tree();
416
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 grid2->setTransform(math::Transform::createLinearTransform(0.2));
417 // Flag this grid for 16-bit float output.
418
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 grid2->setSaveFloatAsHalf(true);
419
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 grid2->setName("grid2");
420
421
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 1 times.
41 for (int x = 0; x < 40; ++x) {
422
2/2
✓ Branch 0 taken 1600 times.
✓ Branch 1 taken 40 times.
1640 for (int y = 0; y < 40; ++y) {
423
2/2
✓ Branch 0 taken 64000 times.
✓ Branch 1 taken 1600 times.
65600 for (int z = 0; z < 40; ++z) {
424
2/4
✓ Branch 1 taken 64000 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 64000 times.
✗ Branch 5 not taken.
128000 tree1.setValue(Coord(x, y, z), Vec3s(float(x), float(y), float(z)));
425
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
64000 tree2.setValue(Coord(x, y, z), Vec3s(float(x), float(y), float(z)));
426 }
427 }
428 }
429
430 1 GridPtrVec grids;
431 1 grids.push_back(grid1);
432 grids.push_back(grid2);
433
434 const char* filename = "something.vdb2";
435 {
436 // Write both grids to a file.
437
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 File vdbFile(filename);
438
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 vdbFile.write(grids);
439 }
440 {
441 // Verify that both grids can be read back successfully from the file.
442
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 File vdbFile(filename);
443
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 vdbFile.open();
444 GridBase::Ptr
445
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 bgrid1 = vdbFile.readGrid("grid1"),
446
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 bgrid2 = vdbFile.readGrid("grid2");
447
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 vdbFile.close();
448
449
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(bgrid1.get() != nullptr);
450
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(bgrid1->isType<GridType>());
451
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(bgrid2.get() != nullptr);
452
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(bgrid2->isType<GridType>());
453
454
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 const TreeType& btree1 = StaticPtrCast<GridType>(bgrid1)->tree();
455
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(Vec3s(10, 10, 10), btree1.getValue(Coord(10, 10, 10)));
456
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 const TreeType& btree2 = StaticPtrCast<GridType>(bgrid2)->tree();
457
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(Vec3s(10, 10, 10), btree2.getValue(Coord(10, 10, 10)));
458 }
459 1 }
460
461
462
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 TEST_F(TestFile, testWriteInstancedGrids)
463 {
464 using namespace openvdb;
465
466 // Register data types.
467 1 openvdb::initialize();
468
469 // Remove something.vdb2 when done. We must declare this here before the
470 // other grid smart_ptr's because we re-use them in the test several times.
471 // We will not be able to remove something.vdb2 on Windows if the pointers
472 // are still referencing data opened by the "file" variable.
473 const char* filename = "something.vdb2";
474 SharedPtr<const char> scopedFile(filename, ::remove);
475
476 // Create grids.
477
1/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 Int32Tree::Ptr tree1(new Int32Tree(1));
478
1/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
2 FloatTree::Ptr tree2(new FloatTree(2.0));
479 GridBase::Ptr
480
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2 grid1 = createGrid(tree1),
481
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2 grid2 = createGrid(tree1), // instance of grid1
482
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2 grid3 = createGrid(tree2),
483
3/8
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
2 grid4 = createGrid(tree2); // instance of grid3
484
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 grid1->setName("density");
485
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 grid2->setName("density_copy");
486 // Leave grid3 and grid4 unnamed.
487
488 // Create transforms.
489
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::Transform::Ptr trans1 = math::Transform::createLinearTransform(0.1);
490
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::Transform::Ptr trans2 = math::Transform::createLinearTransform(0.1);
491
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 grid1->setTransform(trans1);
492
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 grid2->setTransform(trans2);
493
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 grid3->setTransform(trans2);
494
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 grid4->setTransform(trans1);
495
496 // Set some values.
497
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 tree1->setValue(Coord(0, 0, 0), 5);
498
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 tree1->setValue(Coord(100, 0, 0), 6);
499
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 tree2->setValue(Coord(0, 0, 0), 10);
500
1/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 tree2->setValue(Coord(0, 100, 0), 11);
501
502
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 MetaMap::Ptr meta(new MetaMap);
503
4/8
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
3 meta->insertMeta("author", StringMetadata("Einstein"));
504
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 meta->insertMeta("year", Int32Metadata(2009));
505
506
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridPtrVecPtr grids(new GridPtrVec);
507
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 grids->push_back(grid1);
508
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 grids->push_back(grid2);
509
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 grids->push_back(grid3);
510
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 grids->push_back(grid4);
511
512 // Write the grids to a file and then close the file.
513 {
514
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 io::File vdbFile(filename);
515
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 vdbFile.write(*grids, *meta);
516 }
517 meta.reset();
518
519 // Read the grids back in.
520
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 io::File file(filename);
521
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 file.open();
522
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 grids = file.getGrids();
523
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
2 meta = file.getMetadata();
524
525 // Verify the metadata.
526
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(meta.get() != nullptr);
527
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(2, int(meta->metaCount()));
528
4/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
2 EXPECT_EQ(std::string("Einstein"), meta->metaValue<std::string>("author"));
529
4/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
1 EXPECT_EQ(2009, meta->metaValue<int32_t>("year"));
530
531 // Verify the grids.
532
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(grids.get() != nullptr);
533
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(4, int(grids->size()));
534
535
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
2 GridBase::Ptr grid = findGridByName(*grids, "density");
536
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.get() != nullptr);
537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 Int32Tree::Ptr density = gridPtrCast<Int32Grid>(grid)->treePtr();
538
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(density.get() != nullptr);
539
540 grid.reset();
541
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
2 grid = findGridByName(*grids, "density_copy");
542
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.get() != nullptr);
543
3/20
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
3 EXPECT_TRUE(gridPtrCast<Int32Grid>(grid)->treePtr().get() != nullptr);
544 // Verify that "density_copy" is an instance of (i.e., shares a tree with) "density".
545
2/20
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 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 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
2 EXPECT_EQ(density, gridPtrCast<Int32Grid>(grid)->treePtr());
546
547 grid.reset();
548
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
2 grid = findGridByName(*grids, "");
549
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.get() != nullptr);
550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 FloatTree::Ptr temperature = gridPtrCast<FloatGrid>(grid)->treePtr();
551
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(temperature.get() != nullptr);
552
553 grid.reset();
554
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
4 for (GridPtrVec::reverse_iterator it = grids->rbegin(); !grid && it != grids->rend(); ++it) {
555 // Search for the second unnamed grid starting from the end of the list.
556
3/4
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 2 times.
6 if ((*it)->getName() == "") grid = *it;
557 }
558
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.get() != nullptr);
559
3/20
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
3 EXPECT_TRUE(gridPtrCast<FloatGrid>(grid)->treePtr().get() != nullptr);
560 // Verify that the second unnamed grid is an instance of the first.
561
2/18
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 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 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
2 EXPECT_EQ(temperature, gridPtrCast<FloatGrid>(grid)->treePtr());
562
563
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_NEAR(5, density->getValue(Coord(0, 0, 0)), /*tolerance=*/0);
564
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_NEAR(6, density->getValue(Coord(100, 0, 0)), /*tolerance=*/0);
565
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_NEAR(10, temperature->getValue(Coord(0, 0, 0)), /*tolerance=*/0);
566
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_NEAR(11, temperature->getValue(Coord(0, 100, 0)), /*tolerance=*/0);
567
568 // Reread with instancing disabled.
569
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 file.close();
570 file.setInstancingEnabled(false);
571
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 file.open();
572
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 grids = file.getGrids();
573
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(4, int(grids->size()));
574
575
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
2 grid = findGridByName(*grids, "density");
576
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.get() != nullptr);
577
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
2 density = gridPtrCast<Int32Grid>(grid)->treePtr();
578
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(density.get() != nullptr);
579
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
2 grid = findGridByName(*grids, "density_copy");
580
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.get() != nullptr);
581
3/20
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
3 EXPECT_TRUE(gridPtrCast<Int32Grid>(grid)->treePtr().get() != nullptr);
582 // Verify that "density_copy" is *not* an instance of "density".
583
2/18
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 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.
2 EXPECT_TRUE(gridPtrCast<Int32Grid>(grid)->treePtr() != density);
584
585 // Verify that the two unnamed grids are not instances of each other.
586
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
2 grid = findGridByName(*grids, "");
587
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.get() != nullptr);
588
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
2 temperature = gridPtrCast<FloatGrid>(grid)->treePtr();
589
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(temperature.get() != nullptr);
590 grid.reset();
591
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
4 for (GridPtrVec::reverse_iterator it = grids->rbegin(); !grid && it != grids->rend(); ++it) {
592 // Search for the second unnamed grid starting from the end of the list.
593
3/4
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 2 times.
6 if ((*it)->getName() == "") grid = *it;
594 }
595
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.get() != nullptr);
596
3/20
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
3 EXPECT_TRUE(gridPtrCast<FloatGrid>(grid)->treePtr().get() != nullptr);
597
2/18
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 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.
2 EXPECT_TRUE(gridPtrCast<FloatGrid>(grid)->treePtr() != temperature);
598
599 // Rewrite with instancing disabled, then reread with instancing enabled.
600
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 file.close();
601 {
602 /// @todo (FX-7063) For now, write to a new file, then, when there's
603 /// no longer a need for delayed load from the old file, replace it
604 /// with the new file.
605 const char* tempFilename = "somethingelse.vdb";
606 SharedPtr<const char> scopedTempFile(tempFilename, ::remove);
607
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 io::File vdbFile(tempFilename);
608 vdbFile.setInstancingEnabled(false);
609
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 vdbFile.write(*grids, *meta);
610 grids.reset();
611 // Note: Windows requires that the destination not exist, before we can rename to it.
612 1 std::remove(filename);
613 1 std::rename(tempFilename, filename);
614 }
615 file.setInstancingEnabled(true);
616
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 file.open();
617
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 grids = file.getGrids();
618
2/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_EQ(4, int(grids->size()));
619
620 // Verify that "density_copy" is not an instance of "density".
621
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
2 grid = findGridByName(*grids, "density");
622
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.get() != nullptr);
623
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
2 density = gridPtrCast<Int32Grid>(grid)->treePtr();
624
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(density.get() != nullptr);
625
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(density->unallocatedLeafCount() > 0);
626
4/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
1 EXPECT_EQ(density->leafCount(), density->unallocatedLeafCount());
627
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
2 grid = findGridByName(*grids, "density_copy");
628
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.get() != nullptr);
629
3/20
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
3 EXPECT_TRUE(gridPtrCast<Int32Grid>(grid)->treePtr().get() != nullptr);
630
2/18
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 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.
2 EXPECT_TRUE(gridPtrCast<Int32Grid>(grid)->treePtr() != density);
631
632 // Verify that the two unnamed grids are not instances of each other.
633
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
2 grid = findGridByName(*grids, "");
634
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.get() != nullptr);
635
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
2 temperature = gridPtrCast<FloatGrid>(grid)->treePtr();
636
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(temperature.get() != nullptr);
637 grid.reset();
638
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
4 for (GridPtrVec::reverse_iterator it = grids->rbegin(); !grid && it != grids->rend(); ++it) {
639 // Search for the second unnamed grid starting from the end of the list.
640
3/4
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 2 times.
6 if ((*it)->getName() == "") grid = *it;
641 }
642
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.get() != nullptr);
643
3/20
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
3 EXPECT_TRUE(gridPtrCast<FloatGrid>(grid)->treePtr().get() != nullptr);
644
2/18
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 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.
2 EXPECT_TRUE(gridPtrCast<FloatGrid>(grid)->treePtr() != temperature);
645 1 }
646
647
648 void
649 1 TestFile::testReadGridDescriptors()
650 {
651 using namespace openvdb;
652 using namespace openvdb::io;
653
654 using GridType = Int32Grid;
655 using TreeType = GridType::TreeType;
656
657
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 File file("something.vdb2");
658
659
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::ostringstream ostr(std::ios_base::binary);
660
661 // Create a grid with transform.
662
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 GridType::Ptr grid = createGrid<GridType>(1);
663 TreeType& tree = grid->tree();
664
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.setValue(Coord(10, 1, 2), 10);
665
1/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 tree.setValue(Coord(0, 0, 0), 5);
666
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::Transform::Ptr trans = math::Transform::createLinearTransform(0.1);
667
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 grid->setTransform(trans);
668
669 // Create another grid with transform.
670
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 GridType::Ptr grid2 = createGrid<GridType>(2);
671 TreeType& tree2 = grid2->tree();
672
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree2.setValue(Coord(0, 0, 0), 10);
673
1/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 tree2.setValue(Coord(1000, 1000, 1000), 50);
674
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::Transform::Ptr trans2 = math::Transform::createLinearTransform(0.2);
675
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
2 grid2->setTransform(trans2);
676
677 // Create the grid descriptor out of this grid.
678
4/10
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
3 GridDescriptor gd(Name("temperature"), grid->type());
679
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 GridDescriptor gd2(Name("density"), grid2->type());
680
681 // Write out the number of grids.
682 1 int32_t gridCount = 2;
683
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 ostr.write(reinterpret_cast<char*>(&gridCount), sizeof(int32_t));
684 // Write out the grids.
685
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 file.writeGrid(gd, grid, ostr, /*seekable=*/true);
686
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 file.writeGrid(gd2, grid2, ostr, /*seekable=*/true);
687
688 // Register the grid and the transform and the blocks.
689
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridBase::clearRegistry();
690
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridType::registerGrid();
691 // register maps
692
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::MapRegistry::clear();
693
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::AffineMap::registerMap();
694
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::ScaleMap::registerMap();
695
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::UniformScaleMap::registerMap();
696
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::TranslationMap::registerMap();
697
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::ScaleTranslateMap::registerMap();
698
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::UniformScaleTranslateMap::registerMap();
699
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::NonlinearFrustumMap::registerMap();
700
701 // Read in the grid descriptors.
702
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 File file2("something.vdb2");
703
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::istringstream istr(ostr.str(), std::ios_base::binary);
704
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 io::setCurrentVersion(istr);
705
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 file2.readGridDescriptors(istr);
706
707 // Compare with the initial grid descriptors.
708
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 File::NameMapCIter it = file2.findDescriptor("temperature");
709
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(it != file2.gridDescriptors().end());
710
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 GridDescriptor file2gd = it->second;
711
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(gd.gridName(), file2gd.gridName());
712
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(gd.getGridPos(), file2gd.getGridPos());
713
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(gd.getBlockPos(), file2gd.getBlockPos());
714
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(gd.getEndPos(), file2gd.getEndPos());
715
716
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 it = file2.findDescriptor("density");
717
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(it != file2.gridDescriptors().end());
718
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 file2gd = it->second;
719
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(gd2.gridName(), file2gd.gridName());
720
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(gd2.getGridPos(), file2gd.getGridPos());
721
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(gd2.getBlockPos(), file2gd.getBlockPos());
722
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(gd2.getEndPos(), file2gd.getEndPos());
723
724 // Clear registries.
725
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridBase::clearRegistry();
726
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::MapRegistry::clear();
727
728 1 remove("something.vdb2");
729 1 }
730
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 TEST_F(TestFile, testReadGridDescriptors) { testReadGridDescriptors(); }
731
732
733
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 TEST_F(TestFile, testGridNaming)
734 {
735 using namespace openvdb;
736 using namespace openvdb::io;
737
738 using TreeType = Int32Tree;
739
740 // Register data types.
741 1 openvdb::initialize();
742
743 logging::LevelScope suppressLogging{logging::Level::Fatal};
744
745 // Create several grids that share a single tree.
746
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
2 TreeType::Ptr tree(new TreeType(1));
747
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 tree->setValue(Coord(10, 1, 2), 10);
748
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 tree->setValue(Coord(0, 0, 0), 5);
749 GridBase::Ptr
750
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2 grid1 = openvdb::createGrid(tree),
751
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2 grid2 = openvdb::createGrid(tree),
752
3/8
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
2 grid3 = openvdb::createGrid(tree);
753
754 1 std::vector<GridBase::Ptr> gridVec;
755
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gridVec.push_back(grid1);
756
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gridVec.push_back(grid2);
757
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gridVec.push_back(grid3);
758
759 // Give all grids the same name, but also some metadata to distinguish them.
760
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 for (int n = 0; n <= 2; ++n) {
761
3/6
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
6 gridVec[n]->setName("grid");
762
2/4
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
6 gridVec[n]->insertMeta("index", Int32Metadata(n));
763 }
764
765 const char* filename = "testGridNaming.vdb2";
766 SharedPtr<const char> scopedFile(filename, ::remove);
767
768 // Test first with grid instancing disabled, then with instancing enabled.
769
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 for (int instancing = 0; instancing <= 1; ++instancing) {
770 {
771 // Write the grids out to a file.
772
2/4
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 File file(filename);
773
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 file.setInstancingEnabled(instancing);
774
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
4 file.write(gridVec);
775 }
776
777 // Open the file for reading.
778
3/6
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
6 File file(filename);
779 file.setInstancingEnabled(instancing);
780
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 file.open();
781
782 2 int n = 0;
783
4/6
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 2 times.
8 for (File::NameIterator i = file.beginName(), e = file.endName(); i != e; ++i, ++n) {
784
2/18
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 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.
12 EXPECT_TRUE(file.hasGrid(i.gridName()));
785 }
786 // Verify that the file contains three grids.
787
2/16
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
2 EXPECT_EQ(3, n);
788
789 // Read each grid.
790
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for (n = -1; n <= 2; ++n) {
791
1/2
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
8 openvdb::Name name("grid");
792
793 // On the first iteration, read the grid named "grid", then read "grid[0]"
794 // (which is synonymous with "grid"), then "grid[1]", then "grid[2]".
795
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 if (n >= 0) {
796
2/4
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
12 name = GridDescriptor::nameAsString(GridDescriptor::addSuffix(name, n));
797 }
798
799
2/18
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 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.
8 EXPECT_TRUE(file.hasGrid(name));
800
801 // Read the current grid.
802
1/2
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
8 GridBase::ConstPtr grid = file.readGrid(name);
803
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 8 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.
8 EXPECT_TRUE(grid.get() != nullptr);
804
805 // Verify that the grid is named "grid".
806
3/20
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 8 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.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
16 EXPECT_EQ(openvdb::Name("grid"), grid->getName());
807
4/20
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 8 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
8 EXPECT_EQ((n < 0 ? 0 : n), grid->metaValue<openvdb::Int32>("index"));
808 }
809
810 // Read all three grids at once.
811
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 GridPtrVecPtr allGrids = file.getGrids();
812
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
2 EXPECT_TRUE(allGrids.get() != nullptr);
813
2/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
2 EXPECT_EQ(3, int(allGrids->size()));
814
815 2 GridBase::ConstPtr firstGrid;
816 std::vector<int> indices;
817
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 for (GridPtrVecCIter i = allGrids->begin(), e = allGrids->end(); i != e; ++i) {
818 GridBase::ConstPtr grid = *i;
819
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 6 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.
6 EXPECT_TRUE(grid.get() != nullptr);
820
821
3/6
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
6 indices.push_back(grid->metaValue<openvdb::Int32>("index"));
822
823 // If instancing is enabled, verify that all grids share the same tree.
824
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 if (instancing) {
825
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if (!firstGrid) firstGrid = grid;
826
3/22
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 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 19 not taken.
✗ Branch 20 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.
9 EXPECT_EQ(firstGrid->baseTreePtr(), grid->baseTreePtr());
827 }
828 }
829 // Verify that three distinct grids were read,
830 // by examining their "index" metadata.
831
2/16
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
2 EXPECT_EQ(3, int(indices.size()));
832
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 std::sort(indices.begin(), indices.end());
833
2/16
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
2 EXPECT_EQ(0, indices[0]);
834
2/16
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
2 EXPECT_EQ(1, indices[1]);
835
2/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
2 EXPECT_EQ(2, indices[2]);
836 }
837
838 {
839 // Try writing and then reading a grid with a weird name
840 // that might conflict with the grid name indexing scheme.
841
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 const openvdb::Name weirdName("grid[4]");
842
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gridVec[0]->setName(weirdName);
843 {
844
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 File file(filename);
845
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 file.write(gridVec);
846 }
847
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 File file(filename);
848
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 file.open();
849
850 // Verify that the grid can be read and that its index is 0.
851
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridBase::ConstPtr grid = file.readGrid(weirdName);
852
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.get() != nullptr);
853
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.
2 EXPECT_EQ(weirdName, grid->getName());
854
4/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
1 EXPECT_EQ(0, grid->metaValue<openvdb::Int32>("index"));
855
856 // Verify that the other grids can still be read successfully.
857
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 grid = file.readGrid("grid[0]");
858
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.get() != nullptr);
859
3/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
2 EXPECT_EQ(openvdb::Name("grid"), grid->getName());
860 // Because there are now only two grids named "grid", the one with
861 // index 1 is now "grid[0]".
862
4/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
1 EXPECT_EQ(1, grid->metaValue<openvdb::Int32>("index"));
863
864
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 grid = file.readGrid("grid[1]");
865
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.get() != nullptr);
866
3/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
2 EXPECT_EQ(openvdb::Name("grid"), grid->getName());
867 // Because there are now only two grids named "grid", the one with
868 // index 2 is now "grid[1]".
869
4/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
1 EXPECT_EQ(2, grid->metaValue<openvdb::Int32>("index"));
870
871 // Verify that there is no longer a third grid named "grid".
872
5/24
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 26 taken 1 times.
✗ Branch 27 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
3 EXPECT_THROW(file.readGrid("grid[2]"), openvdb::KeyError);
873 }
874 1 }
875
876
877
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 TEST_F(TestFile, testEmptyFile)
878 {
879 using namespace openvdb;
880 using namespace openvdb::io;
881
882 const char* filename = "testEmptyFile.vdb2";
883 SharedPtr<const char> scopedFile(filename, ::remove);
884
885 {
886
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 File file(filename);
887
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 file.write(GridPtrVec(), MetaMap());
888 }
889
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 File file(filename);
890
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 file.open();
891
892
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridPtrVecPtr grids = file.getGrids();
893
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 MetaMap::Ptr meta = file.getMetadata();
894
895
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(grids.get() != nullptr);
896
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(grids->empty());
897
898
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(meta.get() != nullptr);
899
2/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_EQ(0, int(meta->metaCount()));
900 1 }
901
902
903 void
904
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 TestFile::testEmptyGridIO()
905 {
906 using namespace openvdb;
907 using namespace openvdb::io;
908
909 using GridType = Int32Grid;
910
911 logging::LevelScope suppressLogging{logging::Level::Fatal};
912
913 const char* filename = "something.vdb2";
914 SharedPtr<const char> scopedFile(filename, ::remove);
915
916
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 File file(filename);
917
918
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::ostringstream ostr(std::ios_base::binary);
919
920 // Create a grid with transform.
921
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridType::Ptr grid = createGrid<GridType>(/*bg=*/1);
922
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::Transform::Ptr trans = math::Transform::createLinearTransform(0.1);
923
1/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 grid->setTransform(trans);
924
925 // Create another grid with transform.
926
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::Transform::Ptr trans2 = math::Transform::createLinearTransform(0.2);
927
1/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 GridType::Ptr grid2 = createGrid<GridType>(/*bg=*/2);
928
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
2 grid2->setTransform(trans2);
929
930 // Create the grid descriptor out of this grid.
931
4/10
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
3 GridDescriptor gd(Name("temperature"), grid->type());
932
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 GridDescriptor gd2(Name("density"), grid2->type());
933
934 // Write out the number of grids.
935 1 int32_t gridCount = 2;
936
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 ostr.write(reinterpret_cast<char*>(&gridCount), sizeof(int32_t));
937 // Write out the grids.
938
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 file.writeGrid(gd, grid, ostr, /*seekable=*/true);
939
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 file.writeGrid(gd2, grid2, ostr, /*seekable=*/true);
940
941 // Ensure that the block offset and the end offsets are equivalent.
942
4/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
1 EXPECT_EQ(0, int(grid->baseTree().leafCount()));
943
4/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
1 EXPECT_EQ(0, int(grid2->baseTree().leafCount()));
944
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(gd.getEndPos(), gd.getBlockPos());
945
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(gd2.getEndPos(), gd2.getBlockPos());
946
947 // Register the grid and the transform and the blocks.
948
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridBase::clearRegistry();
949
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridType::registerGrid();
950 // register maps
951
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::MapRegistry::clear();
952
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::AffineMap::registerMap();
953
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::ScaleMap::registerMap();
954
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::UniformScaleMap::registerMap();
955
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::TranslationMap::registerMap();
956
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::ScaleTranslateMap::registerMap();
957
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::UniformScaleTranslateMap::registerMap();
958
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::NonlinearFrustumMap::registerMap();
959
960 // Read in the grid descriptors.
961
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 File file2(filename);
962
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::istringstream istr(ostr.str(), std::ios_base::binary);
963
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 io::setCurrentVersion(istr);
964
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 file2.readGridDescriptors(istr);
965
966 // Compare with the initial grid descriptors.
967
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 File::NameMapCIter it = file2.findDescriptor("temperature");
968
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(it != file2.gridDescriptors().end());
969
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 GridDescriptor file2gd = it->second;
970
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 file2gd.seekToGrid(istr);
971
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridBase::Ptr gd_grid = GridBase::createGrid(file2gd.gridType());
972
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Archive::readGridCompression(istr);
973
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd_grid->readMeta(istr);
974 gd_grid->readTransform(istr);
975
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd_grid->readTopology(istr);
976
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(gd.gridName(), file2gd.gridName());
977
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(gd_grid.get() != nullptr);
978
3/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
1 EXPECT_EQ(0, int(gd_grid->baseTree().leafCount()));
979 //EXPECT_EQ(8, int(gd_grid->baseTree().nonLeafCount()));
980
3/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
1 EXPECT_EQ(4, int(gd_grid->baseTree().treeDepth()));
981
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(gd.getGridPos(), file2gd.getGridPos());
982
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(gd.getBlockPos(), file2gd.getBlockPos());
983
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(gd.getEndPos(), file2gd.getEndPos());
984
985
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 it = file2.findDescriptor("density");
986
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(it != file2.gridDescriptors().end());
987
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 file2gd = it->second;
988
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 file2gd.seekToGrid(istr);
989
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd_grid = GridBase::createGrid(file2gd.gridType());
990
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Archive::readGridCompression(istr);
991
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd_grid->readMeta(istr);
992 gd_grid->readTransform(istr);
993
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd_grid->readTopology(istr);
994
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(gd2.gridName(), file2gd.gridName());
995
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(gd_grid.get() != nullptr);
996
3/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
1 EXPECT_EQ(0, int(gd_grid->baseTree().leafCount()));
997 //EXPECT_EQ(8, int(gd_grid->nonLeafCount()));
998
3/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
1 EXPECT_EQ(4, int(gd_grid->baseTree().treeDepth()));
999
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(gd2.getGridPos(), file2gd.getGridPos());
1000
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(gd2.getBlockPos(), file2gd.getBlockPos());
1001
2/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_EQ(gd2.getEndPos(), file2gd.getEndPos());
1002
1003 // Clear registries.
1004
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridBase::clearRegistry();
1005
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::MapRegistry::clear();
1006 1 }
1007
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 TEST_F(TestFile, testEmptyGridIO) { testEmptyGridIO(); }
1008
1009
1010 1 void TestFile::testOpen()
1011 {
1012 using namespace openvdb;
1013
1014 using FloatGrid = openvdb::FloatGrid;
1015 using IntGrid = openvdb::Int32Grid;
1016 using FloatTree = FloatGrid::TreeType;
1017 using IntTree = Int32Grid::TreeType;
1018
1019 // Create a VDB to write.
1020
1021 // Create grids
1022
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 IntGrid::Ptr grid = createGrid<IntGrid>(/*bg=*/1);
1023 IntTree& tree = grid->tree();
1024
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 grid->setName("density");
1025
1026
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 FloatGrid::Ptr grid2 = createGrid<FloatGrid>(/*bg=*/2.0);
1027 FloatTree& tree2 = grid2->tree();
1028
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 grid2->setName("temperature");
1029
1030 // Create transforms
1031
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::Transform::Ptr trans = math::Transform::createLinearTransform(0.1);
1032
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::Transform::Ptr trans2 = math::Transform::createLinearTransform(0.1);
1033
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
2 grid->setTransform(trans);
1034
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 grid2->setTransform(trans2);
1035
1036 // Set some values
1037
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.setValue(Coord(0, 0, 0), 5);
1038
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.setValue(Coord(100, 0, 0), 6);
1039
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree2.setValue(Coord(0, 0, 0), 10);
1040
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2 tree2.setValue(Coord(0, 100, 0), 11);
1041
1042 MetaMap meta;
1043
4/8
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
3 meta.insertMeta("author", StringMetadata("Einstein"));
1044
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 meta.insertMeta("year", Int32Metadata(2009));
1045
1046 1 GridPtrVec grids;
1047 1 grids.push_back(grid);
1048 grids.push_back(grid2);
1049
1050
3/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
2 EXPECT_TRUE(findGridByName(grids, "density") == grid);
1051
3/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
2 EXPECT_TRUE(findGridByName(grids, "temperature") == grid2);
1052
3/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
2 EXPECT_TRUE(meta.metaValue<std::string>("author") == "Einstein");
1053
4/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
1 EXPECT_EQ(2009, meta.metaValue<int32_t>("year"));
1054
1055 // Register grid and transform.
1056
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridBase::clearRegistry();
1057
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 IntGrid::registerGrid();
1058
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 FloatGrid::registerGrid();
1059
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Metadata::clearRegistry();
1060
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StringMetadata::registerType();
1061
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Int32Metadata::registerType();
1062 // register maps
1063
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::MapRegistry::clear();
1064
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::AffineMap::registerMap();
1065
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::ScaleMap::registerMap();
1066
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::UniformScaleMap::registerMap();
1067
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::TranslationMap::registerMap();
1068
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::ScaleTranslateMap::registerMap();
1069
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::UniformScaleTranslateMap::registerMap();
1070
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::NonlinearFrustumMap::registerMap();
1071
1072 // Write the vdb out to a file.
1073
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 io::File vdbfile("something.vdb2");
1074
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 vdbfile.write(grids, meta);
1075
1076 // Now we can read in the file.
1077
3/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 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.
1 EXPECT_TRUE(!vdbfile.open());//opening the same file
1078 // Can't open same file multiple times without closing.
1079
5/22
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 1 times.
✗ Branch 21 not taken.
✓ Branch 24 taken 1 times.
✗ Branch 25 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
2 EXPECT_THROW(vdbfile.open(), openvdb::IoError);
1080
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 vdbfile.close();
1081
3/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 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.
1 EXPECT_TRUE(!vdbfile.open());//opening the same file
1082
1083
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(vdbfile.isOpen());
1084
1085
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 uint32_t version = OPENVDB_FILE_VERSION;
1086
1087
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(version, vdbfile.fileVersion());
1088
4/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
1 EXPECT_EQ(version, io::getFormatVersion(vdbfile.inputStream()));
1089
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(OPENVDB_LIBRARY_MAJOR_VERSION, vdbfile.libraryVersion().first);
1090
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(OPENVDB_LIBRARY_MINOR_VERSION, vdbfile.libraryVersion().second);
1091
3/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
2 EXPECT_EQ(OPENVDB_LIBRARY_MAJOR_VERSION,
1092 io::getLibraryVersion(vdbfile.inputStream()).first);
1093
3/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
2 EXPECT_EQ(OPENVDB_LIBRARY_MINOR_VERSION,
1094 io::getLibraryVersion(vdbfile.inputStream()).second);
1095
1096 // Ensure that we read in the vdb metadata.
1097
2/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
2 EXPECT_TRUE(vdbfile.getMetadata());
1098
5/24
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
3 EXPECT_TRUE(vdbfile.getMetadata()->metaValue<std::string>("author") == "Einstein");
1099
6/24
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
2 EXPECT_EQ(2009, vdbfile.getMetadata()->metaValue<int32_t>("year"));
1100
1101 // Ensure we got the grid descriptors.
1102
4/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
2 EXPECT_EQ(1, int(vdbfile.gridDescriptors().count("density")));
1103
4/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
2 EXPECT_EQ(1, int(vdbfile.gridDescriptors().count("temperature")));
1104
1105
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 io::File::NameMapCIter it = vdbfile.findDescriptor("density");
1106
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(it != vdbfile.gridDescriptors().end());
1107
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 io::GridDescriptor gd = it->second;
1108
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(IntTree::treeType(), gd.gridType());
1109
1110
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 it = vdbfile.findDescriptor("temperature");
1111
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(it != vdbfile.gridDescriptors().end());
1112
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd = it->second;
1113
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(FloatTree::treeType(), gd.gridType());
1114
1115 // Ensure we throw an error if there is no file.
1116
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 io::File vdbfile2("somethingelses.vdb2");
1117
5/22
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 1 times.
✗ Branch 21 not taken.
✓ Branch 24 taken 1 times.
✗ Branch 25 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
2 EXPECT_THROW(vdbfile2.open(), openvdb::IoError);
1118
4/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
2 EXPECT_THROW(vdbfile2.inputStream(), openvdb::IoError);
1119
1120 // Clear registries.
1121
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridBase::clearRegistry();
1122
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Metadata::clearRegistry();
1123
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::MapRegistry::clear();
1124
1125 // Test closing the file.
1126
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 vdbfile.close();
1127
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(vdbfile.isOpen() == false);
1128
3/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 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.
1 EXPECT_TRUE(vdbfile.fileMetadata().get() == nullptr);
1129
3/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
1 EXPECT_EQ(0, int(vdbfile.gridDescriptors().size()));
1130
4/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
2 EXPECT_THROW(vdbfile.inputStream(), openvdb::IoError);
1131
1132 1 remove("something.vdb2");
1133 1 }
1134
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 TEST_F(TestFile, testOpen) { testOpen(); }
1135
1136
1137 void
1138 1 TestFile::testNonVdbOpen()
1139 {
1140 2 std::ofstream file("dummy.vdb2", std::ios_base::binary);
1141
1142 1 int64_t something = 1;
1143
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 file.write(reinterpret_cast<char*>(&something), sizeof(int64_t));
1144
1145
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 file.close();
1146
1147
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 openvdb::io::File vdbfile("dummy.vdb2");
1148
5/22
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 1 times.
✗ Branch 21 not taken.
✓ Branch 24 taken 1 times.
✗ Branch 25 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
2 EXPECT_THROW(vdbfile.open(), openvdb::IoError);
1149
4/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
2 EXPECT_THROW(vdbfile.inputStream(), openvdb::IoError);
1150
1151 1 remove("dummy.vdb2");
1152 1 }
1153
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 TEST_F(TestFile, testNonVdbOpen) { testNonVdbOpen(); }
1154
1155
1156
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 TEST_F(TestFile, testGetMetadata)
1157 {
1158 using namespace openvdb;
1159
1160 1 GridPtrVec grids;
1161 MetaMap meta;
1162
1163
4/8
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
3 meta.insertMeta("author", StringMetadata("Einstein"));
1164
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 meta.insertMeta("year", Int32Metadata(2009));
1165
1166 // Adjust registry before writing.
1167
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Metadata::clearRegistry();
1168
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StringMetadata::registerType();
1169
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Int32Metadata::registerType();
1170
1171 // Write the vdb out to a file.
1172
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 io::File vdbfile("something.vdb2");
1173
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 vdbfile.write(grids, meta);
1174
1175 // Check if reading without opening the file
1176
4/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
2 EXPECT_THROW(vdbfile.getMetadata(), openvdb::IoError);
1177
1178
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 vdbfile.open();
1179
1180
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 MetaMap::Ptr meta2 = vdbfile.getMetadata();
1181
1182
2/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_EQ(2, int(meta2->metaCount()));
1183
1184
3/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
2 EXPECT_TRUE(meta2->metaValue<std::string>("author") == "Einstein");
1185
4/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
1 EXPECT_EQ(2009, meta2->metaValue<int32_t>("year"));
1186
1187 // Clear registry.
1188
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Metadata::clearRegistry();
1189
1190 1 remove("something.vdb2");
1191 1 }
1192
1193
1194
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 TEST_F(TestFile, testReadAll)
1195 {
1196 using namespace openvdb;
1197
1198 using FloatGrid = openvdb::FloatGrid;
1199 using IntGrid = openvdb::Int32Grid;
1200 using FloatTree = FloatGrid::TreeType;
1201 using IntTree = Int32Grid::TreeType;
1202
1203 // Create a vdb to write.
1204
1205 // Create grids
1206
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 IntGrid::Ptr grid1 = createGrid<IntGrid>(/*bg=*/1);
1207 IntTree& tree = grid1->tree();
1208
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 grid1->setName("density");
1209
1210
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 FloatGrid::Ptr grid2 = createGrid<FloatGrid>(/*bg=*/2.0);
1211 FloatTree& tree2 = grid2->tree();
1212
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 grid2->setName("temperature");
1213
1214 // Create transforms
1215
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::Transform::Ptr trans = math::Transform::createLinearTransform(0.1);
1216
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::Transform::Ptr trans2 = math::Transform::createLinearTransform(0.1);
1217
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
2 grid1->setTransform(trans);
1218
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 grid2->setTransform(trans2);
1219
1220 // Set some values
1221
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.setValue(Coord(0, 0, 0), 5);
1222
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.setValue(Coord(100, 0, 0), 6);
1223
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree2.setValue(Coord(0, 0, 0), 10);
1224
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2 tree2.setValue(Coord(0, 100, 0), 11);
1225
1226 MetaMap meta;
1227
4/8
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
3 meta.insertMeta("author", StringMetadata("Einstein"));
1228
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 meta.insertMeta("year", Int32Metadata(2009));
1229
1230 1 GridPtrVec grids;
1231 1 grids.push_back(grid1);
1232 grids.push_back(grid2);
1233
1234 // Register grid and transform.
1235
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 openvdb::initialize();
1236
1237 // Write the vdb out to a file.
1238
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 io::File vdbfile("something.vdb2");
1239
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 vdbfile.write(grids, meta);
1240
1241
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 io::File vdbfile2("something.vdb2");
1242
4/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
2 EXPECT_THROW(vdbfile2.getGrids(), openvdb::IoError);
1243
1244
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 vdbfile2.open();
1245
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(vdbfile2.isOpen());
1246
1247
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridPtrVecPtr grids2 = vdbfile2.getGrids();
1248
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 MetaMap::Ptr meta2 = vdbfile2.getMetadata();
1249
1250 // Ensure we have the metadata.
1251
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(2, int(meta2->metaCount()));
1252
3/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
2 EXPECT_TRUE(meta2->metaValue<std::string>("author") == "Einstein");
1253
4/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
1 EXPECT_EQ(2009, meta2->metaValue<int32_t>("year"));
1254
1255 // Ensure we got the grids.
1256
2/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_EQ(2, int(grids2->size()));
1257
1258 1 GridBase::Ptr grid;
1259 grid.reset();
1260
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
2 grid = findGridByName(*grids2, "density");
1261
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.get() != nullptr);
1262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 IntTree::Ptr density = gridPtrCast<IntGrid>(grid)->treePtr();
1263
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(density.get() != nullptr);
1264
1265 grid.reset();
1266
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
2 grid = findGridByName(*grids2, "temperature");
1267
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.get() != nullptr);
1268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 FloatTree::Ptr temperature = gridPtrCast<FloatGrid>(grid)->treePtr();
1269
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(temperature.get() != nullptr);
1270
1271
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_NEAR(5, density->getValue(Coord(0, 0, 0)), /*tolerance=*/0);
1272
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_NEAR(6, density->getValue(Coord(100, 0, 0)), /*tolerance=*/0);
1273
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_NEAR(10, temperature->getValue(Coord(0, 0, 0)), /*tolerance=*/0);
1274
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_NEAR(11, temperature->getValue(Coord(0, 100, 0)), /*tolerance=*/0);
1275
1276 // Clear registries.
1277
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridBase::clearRegistry();
1278
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Metadata::clearRegistry();
1279
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::MapRegistry::clear();
1280
1281
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 vdbfile2.close();
1282
1283 1 remove("something.vdb2");
1284 1 }
1285
1286
1287
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 TEST_F(TestFile, testWriteOpenFile)
1288 {
1289 using namespace openvdb;
1290
1291 1 MetaMap::Ptr meta(new MetaMap);
1292
4/8
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
3 meta->insertMeta("author", StringMetadata("Einstein"));
1293
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 meta->insertMeta("year", Int32Metadata(2009));
1294
1295 // Register metadata
1296
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Metadata::clearRegistry();
1297
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StringMetadata::registerType();
1298
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Int32Metadata::registerType();
1299
1300 // Write the metadata out to a file.
1301
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 io::File vdbfile("something.vdb2");
1302
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 vdbfile.write(GridPtrVec(), *meta);
1303
1304
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 io::File vdbfile2("something.vdb2");
1305
4/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
2 EXPECT_THROW(vdbfile2.getGrids(), openvdb::IoError);
1306
1307
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 vdbfile2.open();
1308
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(vdbfile2.isOpen());
1309
1310
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridPtrVecPtr grids = vdbfile2.getGrids();
1311
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
2 meta = vdbfile2.getMetadata();
1312
1313 // Ensure we have the metadata.
1314
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(meta.get() != nullptr);
1315
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(2, int(meta->metaCount()));
1316
3/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
2 EXPECT_TRUE(meta->metaValue<std::string>("author") == "Einstein");
1317
4/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
1 EXPECT_EQ(2009, meta->metaValue<int32_t>("year"));
1318
1319 // Ensure we got the grids.
1320
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(grids.get() != nullptr);
1321
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(0, int(grids->size()));
1322
1323 // Cannot write an open file.
1324
5/22
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 1 times.
✗ Branch 21 not taken.
✓ Branch 24 taken 1 times.
✗ Branch 25 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
2 EXPECT_THROW(vdbfile2.write(*grids), openvdb::IoError);
1325
1326
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 vdbfile2.close();
1327
1328
5/24
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
2 EXPECT_NO_THROW(vdbfile2.write(*grids));
1329
1330 // Clear registries.
1331
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Metadata::clearRegistry();
1332
1333 1 remove("something.vdb2");
1334 1 }
1335
1336
1337
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 TEST_F(TestFile, testReadGridMetadata)
1338 {
1339 using namespace openvdb;
1340
1341 1 openvdb::initialize();
1342
1343 const char* filename = "testReadGridMetadata.vdb2";
1344 SharedPtr<const char> scopedFile(filename, ::remove);
1345
1346 // Create grids
1347
1/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 Int32Grid::Ptr igrid = createGrid<Int32Grid>(/*bg=*/1);
1348
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 FloatGrid::Ptr fgrid = createGrid<FloatGrid>(/*bg=*/2.0);
1349
1350 // Add metadata.
1351
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 igrid->setName("igrid");
1352
4/8
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
3 igrid->insertMeta("author", StringMetadata("Einstein"));
1353
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 igrid->insertMeta("year", Int32Metadata(2012));
1354
1355
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 fgrid->setName("fgrid");
1356
4/8
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
3 fgrid->insertMeta("author", StringMetadata("Einstein"));
1357
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 fgrid->insertMeta("year", Int32Metadata(2012));
1358
1359 // Add transforms.
1360
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::Transform::Ptr trans = math::Transform::createLinearTransform(0.1);
1361
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
2 igrid->setTransform(trans);
1362
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
2 fgrid->setTransform(trans);
1363
1364 // Set some values.
1365
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 igrid->tree().setValue(Coord(0, 0, 0), 5);
1366
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 igrid->tree().setValue(Coord(100, 0, 0), 6);
1367
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 fgrid->tree().setValue(Coord(0, 0, 0), 10);
1368
1/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 fgrid->tree().setValue(Coord(0, 100, 0), 11);
1369
1370 1 GridPtrVec srcGrids;
1371 1 srcGrids.push_back(igrid);
1372
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 srcGrids.push_back(fgrid);
1373 std::map<std::string, GridBase::Ptr> srcGridMap;
1374
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 srcGridMap[igrid->getName()] = igrid;
1375
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 srcGridMap[fgrid->getName()] = fgrid;
1376
1377 enum { OUTPUT_TO_FILE = 0, OUTPUT_TO_STREAM = 1 };
1378
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 for (int outputMethod = OUTPUT_TO_FILE; outputMethod <= OUTPUT_TO_STREAM; ++outputMethod)
1379 {
1380
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 if (outputMethod == OUTPUT_TO_FILE) {
1381 // Write the grids to a file.
1382
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 io::File vdbfile(filename);
1383
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 vdbfile.write(srcGrids);
1384 } else {
1385 // Stream the grids to a file (i.e., without file offsets).
1386
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 std::ofstream ostrm(filename, std::ios_base::binary);
1387
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 io::Stream(ostrm).write(srcGrids);
1388 }
1389
1390 // Read just the grid-level metadata from the file.
1391
3/6
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
6 io::File vdbfile(filename);
1392
1393 // Verify that reading from an unopened file generates an exception.
1394
5/22
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 26 taken 2 times.
✗ Branch 27 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
6 EXPECT_THROW(vdbfile.readGridMetadata("igrid"), openvdb::IoError);
1395
5/22
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 26 taken 2 times.
✗ Branch 27 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
6 EXPECT_THROW(vdbfile.readGridMetadata("noname"), openvdb::IoError);
1396
4/20
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 22 taken 2 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
4 EXPECT_THROW(vdbfile.readAllGridMetadata(), openvdb::IoError);
1397
1398
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 vdbfile.open();
1399
1400
2/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
2 EXPECT_TRUE(vdbfile.isOpen());
1401
1402 // Verify that reading a nonexistent grid generates an exception.
1403
5/22
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 26 taken 2 times.
✗ Branch 27 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
6 EXPECT_THROW(vdbfile.readGridMetadata("noname"), openvdb::KeyError);
1404
1405 // Read all grids and store them in a list.
1406
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 GridPtrVecPtr gridMetadata = vdbfile.readAllGridMetadata();
1407
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
2 EXPECT_TRUE(gridMetadata.get() != nullptr);
1408
2/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
2 EXPECT_EQ(2, int(gridMetadata->size()));
1409
1410 // Read individual grids and append them to the list.
1411
3/6
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
4 GridBase::Ptr grid = vdbfile.readGridMetadata("igrid");
1412
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
2 EXPECT_TRUE(grid.get() != nullptr);
1413
3/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 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.
4 EXPECT_EQ(std::string("igrid"), grid->getName());
1414
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 gridMetadata->push_back(grid);
1415
1416
3/6
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
4 grid = vdbfile.readGridMetadata("fgrid");
1417
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
2 EXPECT_TRUE(grid.get() != nullptr);
1418
3/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 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.
4 EXPECT_EQ(std::string("fgrid"), grid->getName());
1419
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 gridMetadata->push_back(grid);
1420
1421 // Verify that the grids' metadata and transforms match the original grids'.
1422
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for (size_t i = 0, N = gridMetadata->size(); i < N; ++i) {
1423 grid = (*gridMetadata)[i];
1424
1425
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 8 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.
8 EXPECT_TRUE(grid.get() != nullptr);
1426
8/28
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 4 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 8 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
28 EXPECT_TRUE(grid->getName() == "igrid" || grid->getName() == "fgrid");
1427
3/20
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 8 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.
16 EXPECT_TRUE(grid->baseTreePtr().get() != nullptr);
1428
1429 // Since we didn't read the grid's topology, the tree should be empty.
1430
5/24
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 8 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 8 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
16 EXPECT_EQ(0, int(grid->constBaseTreePtr()->leafCount()));
1431
5/24
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 8 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 8 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
16 EXPECT_EQ(0, int(grid->constBaseTreePtr()->activeVoxelCount()));
1432
1433 // Retrieve the source grid of the same name.
1434
3/8
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
16 GridBase::ConstPtr srcGrid = srcGridMap[grid->getName()];
1435
1436 // Compare grid types and transforms.
1437
3/20
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 8 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
16 EXPECT_EQ(srcGrid->type(), grid->type());
1438
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 8 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(srcGrid->transform(), grid->transform());
1439
1440 // Compare metadata, ignoring fields that were added when the file was written.
1441 MetaMap::Ptr
1442
1/2
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
8 statsMetadata = grid->getStatsMetadata(),
1443
1/2
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
8 otherMetadata = grid->copyMeta(); // shallow copy
1444
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 8 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.
8 EXPECT_TRUE(statsMetadata->metaCount() != 0);
1445
3/6
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
24 statsMetadata->insertMeta(GridBase::META_FILE_COMPRESSION, StringMetadata(""));
1446 for (MetaMap::ConstMetaIterator it = grid->beginMeta(), end = grid->endMeta();
1447
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 8 times.
72 it != end; ++it)
1448 {
1449 // Keep all fields that exist in the source grid.
1450
2/2
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 40 times.
128 if ((*srcGrid)[it->first]) continue;
1451 // Remove any remaining grid statistics fields.
1452
1/2
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
80 if ((*statsMetadata)[it->first]) {
1453
1/2
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
40 otherMetadata->removeMeta(it->first);
1454 }
1455 // Remove delay load metadata if it exists.
1456
2/6
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 40 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
80 if ((*otherMetadata)["file_delayed_load"]) {
1457 otherMetadata->removeMeta("file_delayed_load");
1458 }
1459 }
1460
5/22
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 8 times.
✗ Branch 11 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 8 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
16 EXPECT_EQ(srcGrid->str(), otherMetadata->str());
1461
1462
1/2
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
8 const CoordBBox srcBBox = srcGrid->evalActiveVoxelBoundingBox();
1463
4/20
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 8 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
8 EXPECT_EQ(srcBBox.min().asVec3i(), grid->metaValue<Vec3i>("file_bbox_min"));
1464
4/20
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 8 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
8 EXPECT_EQ(srcBBox.max().asVec3i(), grid->metaValue<Vec3i>("file_bbox_max"));
1465
5/22
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 8 times.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 8 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
8 EXPECT_EQ(srcGrid->activeVoxelCount(),
1466 Index64(grid->metaValue<Int64>("file_voxel_count")));
1467
5/22
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 8 times.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 8 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
8 EXPECT_EQ(srcGrid->memUsage(),
1468 Index64(grid->metaValue<Int64>("file_mem_bytes")));
1469 }
1470 }
1471 1 }
1472
1473
1474
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 TEST_F(TestFile, testReadGrid)
1475 {
1476 using namespace openvdb;
1477
1478 using FloatGrid = openvdb::FloatGrid;
1479 using IntGrid = openvdb::Int32Grid;
1480 using FloatTree = FloatGrid::TreeType;
1481 using IntTree = Int32Grid::TreeType;
1482
1483 // Create a vdb to write.
1484
1485 // Create grids
1486
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 IntGrid::Ptr grid = createGrid<IntGrid>(/*bg=*/1);
1487 IntTree& tree = grid->tree();
1488
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 grid->setName("density");
1489
1490
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 FloatGrid::Ptr grid2 = createGrid<FloatGrid>(/*bg=*/2.0);
1491 FloatTree& tree2 = grid2->tree();
1492
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 grid2->setName("temperature");
1493
1494 // Create transforms
1495
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::Transform::Ptr trans = math::Transform::createLinearTransform(0.1);
1496
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::Transform::Ptr trans2 = math::Transform::createLinearTransform(0.1);
1497
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
2 grid->setTransform(trans);
1498
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 grid2->setTransform(trans2);
1499
1500 // Set some values
1501
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.setValue(Coord(0, 0, 0), 5);
1502
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.setValue(Coord(100, 0, 0), 6);
1503
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree2.setValue(Coord(0, 0, 0), 10);
1504
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2 tree2.setValue(Coord(0, 100, 0), 11);
1505
1506 MetaMap meta;
1507
4/8
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
3 meta.insertMeta("author", StringMetadata("Einstein"));
1508
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 meta.insertMeta("year", Int32Metadata(2009));
1509
1510 1 GridPtrVec grids;
1511 1 grids.push_back(grid);
1512 grids.push_back(grid2);
1513
1514 // Register grid and transform.
1515
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 openvdb::initialize();
1516
1517 // Write the vdb out to a file.
1518
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 io::File vdbfile("something.vdb2");
1519
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 vdbfile.write(grids, meta);
1520
1521
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 io::File vdbfile2("something.vdb2");
1522
1523
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 vdbfile2.open();
1524
1525
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(vdbfile2.isOpen());
1526
1527 // Get Temperature
1528
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
2 GridBase::Ptr temperature = vdbfile2.readGrid("temperature");
1529
1530
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(temperature.get() != nullptr);
1531
1532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 FloatTree::Ptr typedTemperature = gridPtrCast<FloatGrid>(temperature)->treePtr();
1533
1534
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(typedTemperature.get() != nullptr);
1535
1536
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_NEAR(10, typedTemperature->getValue(Coord(0, 0, 0)), 0);
1537
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_NEAR(11, typedTemperature->getValue(Coord(0, 100, 0)), 0);
1538
1539 // Get Density
1540
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
2 GridBase::Ptr density = vdbfile2.readGrid("density");
1541
1542
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_TRUE(density.get() != nullptr);
1543
1544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 IntTree::Ptr typedDensity = gridPtrCast<IntGrid>(density)->treePtr();
1545
1546
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(typedDensity.get() != nullptr);
1547
1548
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_NEAR(5,typedDensity->getValue(Coord(0, 0, 0)), /*tolerance=*/0);
1549
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_NEAR(6,typedDensity->getValue(Coord(100, 0, 0)), /*tolerance=*/0);
1550
1551 // Clear registries.
1552
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridBase::clearRegistry();
1553
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Metadata::clearRegistry();
1554
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::MapRegistry::clear();
1555
1556
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 vdbfile2.close();
1557
1558 1 remove("something.vdb2");
1559 1 }
1560
1561
1562 ////////////////////////////////////////
1563
1564
1565 template<typename GridT>
1566 void
1567 18 validateClippedGrid(const GridT& clipped, const typename GridT::ValueType& fg)
1568 {
1569 using namespace openvdb;
1570
1571 using ValueT = typename GridT::ValueType;
1572
1573 18 const CoordBBox bbox = clipped.evalActiveVoxelBoundingBox();
1574
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
18 EXPECT_EQ(4, bbox.min().x());
1575
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
18 EXPECT_EQ(4, bbox.min().y());
1576
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
18 EXPECT_EQ(-6, bbox.min().z());
1577
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
18 EXPECT_EQ(4, bbox.max().x());
1578
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
18 EXPECT_EQ(4, bbox.max().y());
1579
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
18 EXPECT_EQ(6, bbox.max().z());
1580
1/14
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
18 EXPECT_EQ(6 + 6 + 1, int(clipped.activeVoxelCount()));
1581
1/14
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
18 EXPECT_EQ(2, int(clipped.constTree().leafCount()));
1582
1583 typename GridT::ConstAccessor acc = clipped.getConstAccessor();
1584 18 const ValueT bg = clipped.background();
1585 Coord xyz;
1586 int &x = xyz[0], &y = xyz[1], &z = xyz[2];
1587
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 9 times.
396 for (x = -10; x <= 10; ++x) {
1588
2/2
✓ Branch 0 taken 3969 times.
✓ Branch 1 taken 189 times.
8316 for (y = -10; y <= 10; ++y) {
1589
2/2
✓ Branch 0 taken 83349 times.
✓ Branch 1 taken 3969 times.
174636 for (z = -10; z <= 10; ++z) {
1590
8/8
✓ Branch 0 taken 3969 times.
✓ Branch 1 taken 79380 times.
✓ Branch 2 taken 189 times.
✓ Branch 3 taken 3780 times.
✓ Branch 4 taken 153 times.
✓ Branch 5 taken 36 times.
✓ Branch 6 taken 117 times.
✓ Branch 7 taken 36 times.
166698 if (x == 4 && y == 4 && z >= -6 && z <= 6) {
1591
3/21
✓ Branch 1 taken 78 times.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 78 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
702 EXPECT_EQ(fg, acc.getValue(Coord(4, 4, z)));
1592 } else {
1593
3/21
✓ Branch 1 taken 55488 times.
✓ Branch 2 taken 27744 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 55488 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
332928 EXPECT_EQ(bg, acc.getValue(Coord(x, y, z)));
1594 }
1595 }
1596 }
1597 }
1598 18 }
1599
1600
1601 // See also TestGrid::testClipping()
1602
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 TEST_F(TestFile, testReadClippedGrid)
1603 {
1604 using namespace openvdb;
1605
1606 // Register types.
1607 1 openvdb::initialize();
1608
1609 // World-space clipping region
1610 1 const BBoxd clipBox(Vec3d(4.0, 4.0, -6.0), Vec3d(4.9, 4.9, 6.0));
1611
1612 // Create grids of several types and fill a cubic region of each with a foreground value.
1613
1614 1 const bool bfg = true;
1615
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 BoolGrid::Ptr bgrid = BoolGrid::create(/*bg=*/zeroVal<bool>());
1616
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 bgrid->setName("bgrid");
1617 bgrid->fill(CoordBBox(Coord(-10), Coord(10)), /*value=*/bfg, /*active=*/true);
1618
1619 1 const float ffg = 5.f;
1620
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 FloatGrid::Ptr fgrid = FloatGrid::create(/*bg=*/zeroVal<float>());
1621
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 fgrid->setName("fgrid");
1622
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 fgrid->fill(CoordBBox(Coord(-10), Coord(10)), /*value=*/ffg, /*active=*/true);
1623
1624 const Vec3s vfg(1.f, -2.f, 3.f);
1625
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 Vec3SGrid::Ptr vgrid = Vec3SGrid::create(/*bg=*/zeroVal<Vec3s>());
1626
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 vgrid->setName("vgrid");
1627
0/2
✗ Branch 1 not taken.
✗ Branch 2 not taken.
1 vgrid->fill(CoordBBox(Coord(-10), Coord(10)), /*value=*/vfg, /*active=*/true);
1628
1629 1 GridPtrVec srcGrids;
1630 1 srcGrids.push_back(bgrid);
1631 1 srcGrids.push_back(fgrid);
1632
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 srcGrids.push_back(vgrid);
1633
1634 const char* filename = "testReadClippedGrid.vdb";
1635 SharedPtr<const char> scopedFile(filename, ::remove);
1636
1637 enum { OUTPUT_TO_FILE = 0, OUTPUT_TO_STREAM = 1 };
1638
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 for (int outputMethod = OUTPUT_TO_FILE; outputMethod <= OUTPUT_TO_STREAM; ++outputMethod)
1639 {
1640
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 if (outputMethod == OUTPUT_TO_FILE) {
1641 // Write the grids to a file.
1642
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 io::File vdbfile(filename);
1643
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 vdbfile.write(srcGrids);
1644 } else {
1645 // Stream the grids to a file (i.e., without file offsets).
1646
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 std::ofstream ostrm(filename, std::ios_base::binary);
1647
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 io::Stream(ostrm).write(srcGrids);
1648 }
1649
1650 // Open the file for reading.
1651
3/6
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
6 io::File vdbfile(filename);
1652
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 vdbfile.open();
1653
1654 2 GridBase::Ptr grid;
1655
1656 // Read and clip each grid.
1657
1658
6/24
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 2 times.
✗ Branch 15 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
4 EXPECT_NO_THROW(grid = vdbfile.readGrid("bgrid", clipBox));
1659
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
2 EXPECT_TRUE(grid.get() != nullptr);
1660
4/20
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ 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 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
4 EXPECT_NO_THROW(bgrid = gridPtrCast<BoolGrid>(grid));
1661
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 validateClippedGrid(*bgrid, bfg);
1662
1663
6/24
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 2 times.
✗ Branch 15 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
4 EXPECT_NO_THROW(grid = vdbfile.readGrid("fgrid", clipBox));
1664
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
2 EXPECT_TRUE(grid.get() != nullptr);
1665
4/20
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ 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 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
4 EXPECT_NO_THROW(fgrid = gridPtrCast<FloatGrid>(grid));
1666
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 validateClippedGrid(*fgrid, ffg);
1667
1668
6/24
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 2 times.
✗ Branch 15 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
4 EXPECT_NO_THROW(grid = vdbfile.readGrid("vgrid", clipBox));
1669
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
2 EXPECT_TRUE(grid.get() != nullptr);
1670
4/22
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ 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 20 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
4 EXPECT_NO_THROW(vgrid = gridPtrCast<Vec3SGrid>(grid));
1671
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 validateClippedGrid(*vgrid, vfg);
1672 }
1673 1 }
1674
1675
1676 ////////////////////////////////////////
1677
1678
1679 namespace {
1680
1681 template<typename T, openvdb::Index Log2Dim> struct MultiPassLeafNode; // forward declaration
1682
1683 // Dummy value type
1684 using MultiPassValue = openvdb::PointIndex<openvdb::Index32, 1000>;
1685
1686 // Tree configured to match the default OpenVDB configuration
1687 using MultiPassTree = openvdb::tree::Tree<
1688 openvdb::tree::RootNode<
1689 openvdb::tree::InternalNode<
1690 openvdb::tree::InternalNode<
1691 MultiPassLeafNode<MultiPassValue, 3>, 4>, 5>>>;
1692
1693 using MultiPassGrid = openvdb::Grid<MultiPassTree>;
1694
1695
1696 template<typename T, openvdb::Index Log2Dim>
1697 struct MultiPassLeafNode: public openvdb::tree::LeafNode<T, Log2Dim>, openvdb::io::MultiPass
1698 {
1699 // The following had to be copied from the LeafNode class
1700 // to make the derived class compatible with the tree structure.
1701
1702 using LeafNodeType = MultiPassLeafNode;
1703 using Ptr = openvdb::SharedPtr<MultiPassLeafNode>;
1704 using BaseLeaf = openvdb::tree::LeafNode<T, Log2Dim>;
1705 using NodeMaskType = openvdb::util::NodeMask<Log2Dim>;
1706 using ValueType = T;
1707 using ValueOnCIter = typename BaseLeaf::template ValueIter<typename NodeMaskType::OnIterator,
1708 const MultiPassLeafNode, const ValueType, typename BaseLeaf::ValueOn>;
1709 using ChildOnIter = typename BaseLeaf::template ChildIter<typename NodeMaskType::OnIterator,
1710 MultiPassLeafNode, typename BaseLeaf::ChildOn>;
1711 using ChildOnCIter = typename BaseLeaf::template ChildIter<
1712 typename NodeMaskType::OnIterator, const MultiPassLeafNode, typename BaseLeaf::ChildOn>;
1713
1714 2 MultiPassLeafNode(const openvdb::Coord& coords, const T& value, bool active = false)
1715
1/6
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
2 : BaseLeaf(coords, value, active) {}
1716 6 MultiPassLeafNode(openvdb::PartialCreate, const openvdb::Coord& coords, const T& value,
1717 6 bool active = false): BaseLeaf(openvdb::PartialCreate(), coords, value, active) {}
1718 MultiPassLeafNode(const MultiPassLeafNode& rhs): BaseLeaf(rhs) {}
1719
1720 ValueOnCIter cbeginValueOn() const { return ValueOnCIter(this->getValueMask().beginOn(),this); }
1721 ChildOnCIter cbeginChildOn() const { return ChildOnCIter(this->getValueMask().endOn(), this); }
1722 7 ChildOnIter beginChildOn() { return ChildOnIter(this->getValueMask().endOn(), this); }
1723
1724 // Methods in use for reading and writing multiple buffers
1725
1726 void readBuffers(std::istream& is, const openvdb::CoordBBox&, bool fromHalf = false)
1727 {
1728 this->readBuffers(is, fromHalf);
1729 }
1730
1731 18 void readBuffers(std::istream& is, bool /*fromHalf*/ = false)
1732 {
1733 18 const openvdb::io::StreamMetadata::Ptr meta = openvdb::io::getStreamMetadataPtr(is);
1734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!meta) {
1735 OPENVDB_THROW(openvdb::IoError,
1736 "Cannot write out a MultiBufferLeaf without StreamMetadata.");
1737 }
1738
1739 // clamp pass to 16-bit integer
1740
1/2
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
18 const uint32_t pass(static_cast<uint16_t>(meta->pass()));
1741
1742 // Read in the stored pass number.
1743 uint32_t readPass;
1744
1/2
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
18 is.read(reinterpret_cast<char*>(&readPass), sizeof(uint32_t));
1745
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 18 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.
18 EXPECT_EQ(pass, readPass);
1746 // Record the pass number.
1747
1/4
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
18 mReadPasses.push_back(readPass);
1748
1749
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 if (pass == 0) {
1750 // Read in the node's origin.
1751 openvdb::Coord origin;
1752
1/2
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
6 is.read(reinterpret_cast<char*>(&origin), sizeof(openvdb::Coord));
1753
2/16
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 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.
6 EXPECT_EQ(origin, this->origin());
1754 }
1755 18 }
1756
1757 16 void writeBuffers(std::ostream& os, bool /*toHalf*/ = false) const
1758 {
1759 16 const openvdb::io::StreamMetadata::Ptr meta = openvdb::io::getStreamMetadataPtr(os);
1760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (!meta) {
1761 OPENVDB_THROW(openvdb::IoError,
1762 "Cannot read in a MultiBufferLeaf without StreamMetadata.");
1763 }
1764
1765 // clamp pass to 16-bit integer
1766
2/4
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
16 const uint32_t pass(static_cast<uint16_t>(meta->pass()));
1767
1768 // Leaf traversal analysis deduces the number of passes to perform for this leaf
1769 // then updates the leaf traversal value to ensure all passes will be written.
1770
3/4
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 12 times.
16 if (meta->countingPasses()) {
1771
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
4 if (mNumPasses > pass) meta->setPass(mNumPasses);
1772 return;
1773 }
1774
1775 // Record the pass number.
1776
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 12 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.
12 EXPECT_TRUE(mWritePassesPtr);
1777
1/4
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
12 const_cast<std::vector<int>&>(*mWritePassesPtr).push_back(pass);
1778
1779 // Write out the pass number.
1780
1/2
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
12 os.write(reinterpret_cast<const char*>(&pass), sizeof(uint32_t));
1781
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 8 times.
12 if (pass == 0) {
1782 // Write out the node's origin and the pass number.
1783 4 const auto origin = this->origin();
1784
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
4 os.write(reinterpret_cast<const char*>(&origin), sizeof(openvdb::Coord));
1785 }
1786 }
1787
1788
1789 uint32_t mNumPasses = 0;
1790 // Pointer to external vector in which to record passes as they are written
1791 std::vector<int>* mWritePassesPtr = nullptr;
1792 // Vector in which to record passes as they are read
1793 // (this needs to be internal, because leaf nodes are constructed as a grid is read)
1794 std::vector<int> mReadPasses;
1795 }; // struct MultiPassLeafNode
1796
1797 } // anonymous namespace
1798
1799
1800
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 TEST_F(TestFile, testMultiPassIO)
1801 {
1802 using namespace openvdb;
1803
1804 1 openvdb::initialize();
1805 1 MultiPassGrid::registerGrid();
1806
1807 // Create a multi-buffer grid.
1808 const MultiPassGrid::Ptr grid = openvdb::createGrid<MultiPassGrid>();
1809
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
2 grid->setName("test");
1810
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(math::Transform::createLinearTransform(1.0));
1811 MultiPassGrid::TreeType& tree = grid->tree();
1812
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.setValue(Coord(0, 0, 0), 5);
1813 1 tree.setValue(Coord(0, 10, 0), 5);
1814
3/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
1 EXPECT_EQ(2, int(tree.leafCount()));
1815
1816
2/8
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
3 const GridPtrVec grids{grid};
1817
1818 // Vector in which to record pass numbers (to ensure blocked ordering)
1819 std::vector<int> writePasses;
1820 {
1821 // Specify the required number of I/O passes for each leaf node.
1822 MultiPassGrid::TreeType::LeafIter leafIter = tree.beginLeaf();
1823 1 leafIter->mNumPasses = 3;
1824
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 leafIter->mWritePassesPtr = &writePasses;
1825 ++leafIter;
1826 1 leafIter->mNumPasses = 2;
1827
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 leafIter->mWritePassesPtr = &writePasses;
1828 }
1829
1830 const char* filename = "testMultiPassIO.vdb";
1831 SharedPtr<const char> scopedFile(filename, ::remove);
1832 {
1833 // Verify that passes are written to a file in the correct order.
1834
4/8
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
2 io::File(filename).write(grids);
1835
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(6, int(writePasses.size()));
1836
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(0, writePasses[0]); // leaf 0
1837
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(0, writePasses[1]); // leaf 1
1838
2/16
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1 EXPECT_EQ(1, writePasses[2]); // leaf 0
1839
2/16
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1 EXPECT_EQ(1, writePasses[3]); // leaf 1
1840
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(2, writePasses[4]); // leaf 0
1841
2/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_EQ(2, writePasses[5]); // leaf 1
1842 }
1843 {
1844 // Verify that passes are read in the correct order.
1845
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 io::File file(filename);
1846
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 file.open();
1847
4/8
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
2 const auto newGrid = GridBase::grid<MultiPassGrid>(file.readGrid("test"));
1848
1849 auto leafIter = newGrid->tree().beginLeaf();
1850
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(3, int(leafIter->mReadPasses.size()));
1851
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(0, leafIter->mReadPasses[0]);
1852
2/16
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1 EXPECT_EQ(1, leafIter->mReadPasses[1]);
1853
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(2, leafIter->mReadPasses[2]);
1854 ++leafIter;
1855
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(3, int(leafIter->mReadPasses.size()));
1856
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(0, leafIter->mReadPasses[0]);
1857
2/16
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1 EXPECT_EQ(1, leafIter->mReadPasses[1]);
1858
2/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_EQ(2, leafIter->mReadPasses[2]);
1859 }
1860 {
1861 // Verify that when using multi-pass and bbox clipping that each leaf node
1862 // is still being read before being clipped
1863
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 io::File file(filename);
1864
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 file.open();
1865 const auto newGrid = GridBase::grid<MultiPassGrid>(
1866
4/8
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
2 file.readGrid("test", BBoxd(Vec3d(0), Vec3d(1))));
1867
3/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
1 EXPECT_EQ(Index32(1), newGrid->tree().leafCount());
1868
1869 auto leafIter = newGrid->tree().beginLeaf();
1870
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(3, int(leafIter->mReadPasses.size()));
1871
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(0, leafIter->mReadPasses[0]);
1872
2/16
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1 EXPECT_EQ(1, leafIter->mReadPasses[1]);
1873
2/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_EQ(2, leafIter->mReadPasses[2]);
1874 ++leafIter;
1875
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(!leafIter); // second leaf node has now been clipped
1876 }
1877
1878 // Clear the pass data.
1879 writePasses.clear();
1880
1881 {
1882 // Verify that passes are written to and read from a non-seekable stream
1883 // in the correct order.
1884
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::ostringstream ostr(std::ios_base::binary);
1885
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
2 io::Stream(ostr).write(grids);
1886
1887
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(6, int(writePasses.size()));
1888
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(0, writePasses[0]); // leaf 0
1889
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(0, writePasses[1]); // leaf 1
1890
2/16
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1 EXPECT_EQ(1, writePasses[2]); // leaf 0
1891
2/16
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1 EXPECT_EQ(1, writePasses[3]); // leaf 1
1892
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(2, writePasses[4]); // leaf 0
1893
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(2, writePasses[5]); // leaf 1
1894
1895
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::istringstream is(ostr.str(), std::ios_base::binary);
1896
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 io::Stream strm(is);
1897
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 const auto streamedGrids = strm.getGrids();
1898
2/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_EQ(1, int(streamedGrids->size()));
1899
1900 const auto newGrid = gridPtrCast<MultiPassGrid>(*streamedGrids->begin());
1901
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(bool(newGrid));
1902 auto leafIter = newGrid->tree().beginLeaf();
1903
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(3, int(leafIter->mReadPasses.size()));
1904
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(0, leafIter->mReadPasses[0]);
1905
2/16
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1 EXPECT_EQ(1, leafIter->mReadPasses[1]);
1906
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(2, leafIter->mReadPasses[2]);
1907 ++leafIter;
1908
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(3, int(leafIter->mReadPasses.size()));
1909
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(0, leafIter->mReadPasses[0]);
1910
2/16
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1 EXPECT_EQ(1, leafIter->mReadPasses[1]);
1911
2/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_EQ(2, leafIter->mReadPasses[2]);
1912 }
1913 1 }
1914
1915
1916 ////////////////////////////////////////
1917
1918
1919
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 TEST_F(TestFile, testHasGrid)
1920 {
1921 using namespace openvdb;
1922 using namespace openvdb::io;
1923
1924 using FloatGrid = openvdb::FloatGrid;
1925 using IntGrid = openvdb::Int32Grid;
1926 using FloatTree = FloatGrid::TreeType;
1927 using IntTree = Int32Grid::TreeType;
1928
1929 // Create a vdb to write.
1930
1931 // Create grids
1932
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 IntGrid::Ptr grid = createGrid<IntGrid>(/*bg=*/1);
1933 IntTree& tree = grid->tree();
1934
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 grid->setName("density");
1935
1936
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 FloatGrid::Ptr grid2 = createGrid<FloatGrid>(/*bg=*/2.0);
1937 FloatTree& tree2 = grid2->tree();
1938
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 grid2->setName("temperature");
1939
1940 // Create transforms
1941
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::Transform::Ptr trans = math::Transform::createLinearTransform(0.1);
1942
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::Transform::Ptr trans2 = math::Transform::createLinearTransform(0.1);
1943
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
2 grid->setTransform(trans);
1944
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 grid2->setTransform(trans2);
1945
1946 // Set some values
1947
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.setValue(Coord(0, 0, 0), 5);
1948
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree.setValue(Coord(100, 0, 0), 6);
1949
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree2.setValue(Coord(0, 0, 0), 10);
1950
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2 tree2.setValue(Coord(0, 100, 0), 11);
1951
1952 MetaMap meta;
1953
4/8
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
3 meta.insertMeta("author", StringMetadata("Einstein"));
1954
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 meta.insertMeta("year", Int32Metadata(2009));
1955
1956 1 GridPtrVec grids;
1957 1 grids.push_back(grid);
1958 grids.push_back(grid2);
1959
1960 // Register grid and transform.
1961
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridBase::clearRegistry();
1962
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 IntGrid::registerGrid();
1963
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 FloatGrid::registerGrid();
1964
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Metadata::clearRegistry();
1965
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 StringMetadata::registerType();
1966
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Int32Metadata::registerType();
1967 // register maps
1968
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::MapRegistry::clear();
1969
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::AffineMap::registerMap();
1970
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::ScaleMap::registerMap();
1971
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::UniformScaleMap::registerMap();
1972
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::TranslationMap::registerMap();
1973
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::ScaleTranslateMap::registerMap();
1974
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::UniformScaleTranslateMap::registerMap();
1975
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::NonlinearFrustumMap::registerMap();
1976
1977 // Write the vdb out to a file.
1978
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 io::File vdbfile("something.vdb2");
1979
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 vdbfile.write(grids, meta);
1980
1981
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 io::File vdbfile2("something.vdb2");
1982
1983
5/22
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
3 EXPECT_THROW(vdbfile2.hasGrid("density"), openvdb::IoError);
1984
1985
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 vdbfile2.open();
1986
1987
3/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
2 EXPECT_TRUE(vdbfile2.hasGrid("density"));
1988
3/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
2 EXPECT_TRUE(vdbfile2.hasGrid("temperature"));
1989
3/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1 EXPECT_TRUE(!vdbfile2.hasGrid("Temperature"));
1990
3/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1 EXPECT_TRUE(!vdbfile2.hasGrid("densitY"));
1991
1992 // Clear registries.
1993
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridBase::clearRegistry();
1994
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Metadata::clearRegistry();
1995
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 math::MapRegistry::clear();
1996
1997
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 vdbfile2.close();
1998
1999 1 remove("something.vdb2");
2000 1 }
2001
2002
2003
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 TEST_F(TestFile, testNameIterator)
2004 {
2005 using namespace openvdb;
2006 using namespace openvdb::io;
2007
2008 using FloatGrid = openvdb::FloatGrid;
2009 using FloatTree = FloatGrid::TreeType;
2010 using IntTree = Int32Grid::TreeType;
2011
2012 // Create trees.
2013
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
2 IntTree::Ptr itree(new IntTree(1));
2014
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 itree->setValue(Coord(0, 0, 0), 5);
2015
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 itree->setValue(Coord(100, 0, 0), 6);
2016
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
2 FloatTree::Ptr ftree(new FloatTree(2.0));
2017
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 ftree->setValue(Coord(0, 0, 0), 10.0);
2018
1/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 ftree->setValue(Coord(0, 100, 0), 11.0);
2019
2020 // Create grids.
2021 1 GridPtrVec grids;
2022
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
2 GridBase::Ptr grid = createGrid(itree);
2023
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 grid->setName("density");
2024
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 grids.push_back(grid);
2025
2026
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
3 grid = createGrid(ftree);
2027
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 grid->setName("temperature");
2028
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 grids.push_back(grid);
2029
2030 // Create two unnamed grids.
2031
3/10
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
3 grids.push_back(createGrid(ftree));
2032
3/10
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
3 grids.push_back(createGrid(ftree));
2033
2034 // Create two grids with the same name.
2035
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
3 grid = createGrid(ftree);
2036
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 grid->setName("level_set");
2037
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 grids.push_back(grid);
2038
3/8
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
3 grid = createGrid(ftree);
2039
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 grid->setName("level_set");
2040
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 grids.push_back(grid);
2041
2042 // Register types.
2043
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 openvdb::initialize();
2044
2045 const char* filename = "testNameIterator.vdb2";
2046 SharedPtr<const char> scopedFile(filename, ::remove);
2047
2048 // Write the grids out to a file.
2049 {
2050
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 io::File vdbfile(filename);
2051
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 vdbfile.write(grids);
2052 }
2053
2054
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 io::File vdbfile(filename);
2055
2056 // Verify that name iteration fails if the file is not open.
2057
4/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
2 EXPECT_THROW(vdbfile.beginName(), openvdb::IoError);
2058
2059
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 vdbfile.open();
2060
2061 // Names should appear in lexicographic order.
2062
8/16
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 6 times.
✓ Branch 19 taken 1 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
8 Name names[6] = { "[0]", "[1]", "density", "level_set[0]", "level_set[1]", "temperature" };
2063 1 int count = 0;
2064
4/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 1 times.
7 for (io::File::NameIterator iter = vdbfile.beginName(); iter != vdbfile.endName(); ++iter) {
2065
2/16
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 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.
12 EXPECT_EQ(names[count], *iter);
2066
2/16
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 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.
12 EXPECT_EQ(names[count], iter.gridName());
2067
1/2
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
6 ++count;
2068
2/4
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
12 grid = vdbfile.readGrid(*iter);
2069
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 6 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.
6 EXPECT_TRUE(grid);
2070 }
2071
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(6, count);
2072
2073
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 vdbfile.close();
2074 1 }
2075
2076
2077
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 TEST_F(TestFile, testReadOldFileFormat)
2078 {
2079 /// @todo Save some old-format (prior to OPENVDB_FILE_VERSION) .vdb2 files
2080 /// to /work/rd/fx_tools/vdb_unittest/TestFile::testReadOldFileFormat/
2081 /// Verify that the files can still be read correctly.
2082 1 }
2083
2084
2085
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 TEST_F(TestFile, testCompression)
2086 {
2087 using namespace openvdb;
2088 using namespace openvdb::io;
2089
2090 using IntGrid = openvdb::Int32Grid;
2091
2092 // Register types.
2093 1 openvdb::initialize();
2094
2095 // Create reference grids.
2096
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 IntGrid::Ptr intGrid = IntGrid::create(/*background=*/0);
2097
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 intGrid->fill(CoordBBox(Coord(0), Coord(49)), /*value=*/999, /*active=*/true);
2098
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 intGrid->fill(CoordBBox(Coord(6), Coord(43)), /*value=*/0, /*active=*/false);
2099
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 intGrid->fill(CoordBBox(Coord(21), Coord(22)), /*value=*/1, /*active=*/false);
2100
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 intGrid->fill(CoordBBox(Coord(23), Coord(24)), /*value=*/2, /*active=*/false);
2101
2/18
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1 EXPECT_EQ(8, int(IntGrid::TreeType::LeafNodeType::DIM));
2102
2103
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 FloatGrid::Ptr lsGrid = createLevelSet<FloatGrid>();
2104
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 unittest_util::makeSphere(/*dim=*/Coord(100), /*ctr=*/Vec3f(50, 50, 50), /*r=*/20.0,
2105 *lsGrid, unittest_util::SPHERE_SPARSE_NARROW_BAND);
2106
3/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
1 EXPECT_EQ(int(GRID_LEVEL_SET), int(lsGrid->getGridClass()));
2107
2108
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 FloatGrid::Ptr fogGrid = lsGrid->deepCopy();
2109
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tools::sdfToFogVolume(*fogGrid);
2110
3/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
1 EXPECT_EQ(int(GRID_FOG_VOLUME), int(fogGrid->getGridClass()));
2111
2112
2113 1 GridPtrVec grids;
2114 1 grids.push_back(intGrid);
2115 1 grids.push_back(lsGrid);
2116
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 grids.push_back(fogGrid);
2117
2118 const char* filename = "testCompression.vdb2";
2119 SharedPtr<const char> scopedFile(filename, ::remove);
2120
2121 size_t uncompressedSize = 0;
2122 {
2123 // Write the grids out to a file with compression disabled.
2124
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 io::File vdbfile(filename);
2125 vdbfile.setCompression(io::COMPRESS_NONE);
2126
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 vdbfile.write(grids);
2127
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 vdbfile.close();
2128
2129 // Get the size of the file in bytes.
2130 struct stat buf;
2131 1 buf.st_size = 0;
2132
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(0, ::stat(filename, &buf));
2133 1 uncompressedSize = buf.st_size;
2134 }
2135
2136 // Write the grids out with various combinations of compression options
2137 // and verify that they can be read back successfully.
2138 // See io/Compression.h for the flag values.
2139
2140 #ifdef OPENVDB_USE_BLOSC
2141 #ifdef OPENVDB_USE_ZLIB
2142
1/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 std::vector<uint32_t> validFlags{0x0,0x1,0x2,0x3,0x4,0x6};
2143 #else
2144 std::vector<uint32_t> validFlags{0x0,0x2,0x4,0x6};
2145 #endif
2146 #else
2147 #ifdef OPENVDB_USE_ZLIB
2148 std::vector<uint32_t> validFlags{0x0,0x1,0x2,0x3};
2149 #else
2150 std::vector<uint32_t> validFlags{0x0,0x2};
2151 #endif
2152 #endif
2153
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
7 for (uint32_t flags : validFlags) {
2154
2155
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 if (flags != io::COMPRESS_NONE) {
2156
3/6
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 5 times.
✗ Branch 8 not taken.
15 io::File vdbfile(filename);
2157 vdbfile.setCompression(flags);
2158
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 vdbfile.write(grids);
2159
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 vdbfile.close();
2160 }
2161
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 if (flags != io::COMPRESS_NONE) {
2162 // Verify that the compressed file is significantly smaller than
2163 // the uncompressed file.
2164 size_t compressedSize = 0;
2165 struct stat buf;
2166 5 buf.st_size = 0;
2167
2/18
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
5 EXPECT_EQ(0, ::stat(filename, &buf));
2168 5 compressedSize = buf.st_size;
2169
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 5 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.
5 EXPECT_TRUE(compressedSize < size_t(0.75 * double(uncompressedSize)));
2170 }
2171 {
2172 // Verify that the grids can be read back successfully.
2173
2174
3/6
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
18 io::File vdbfile(filename);
2175
1/2
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
6 vdbfile.open();
2176
2177
1/2
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
6 GridPtrVecPtr inGrids = vdbfile.getGrids();
2178
2/18
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
6 EXPECT_EQ(3, int(inGrids->size()));
2179
2180 // Verify that the original and input grids are equal.
2181 {
2182 const IntGrid::Ptr grid = gridPtrCast<IntGrid>((*inGrids)[0]);
2183
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 6 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.
6 EXPECT_TRUE(grid.get() != nullptr);
2184
4/20
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
6 EXPECT_EQ(int(intGrid->getGridClass()), int(grid->getGridClass()));
2185
2186
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 6 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.
6 EXPECT_TRUE(grid->tree().hasSameTopology(intGrid->tree()));
2187
2188
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 6 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.
6 EXPECT_EQ(
2189 intGrid->tree().getValue(Coord(0)),
2190 grid->tree().getValue(Coord(0)));
2191 // Verify that leaf nodes with more than two distinct inactive values
2192 // are handled correctly (FX-7085).
2193
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 6 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.
6 EXPECT_EQ(
2194 intGrid->tree().getValue(Coord(6)),
2195 grid->tree().getValue(Coord(6)));
2196
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 6 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.
6 EXPECT_EQ(
2197 intGrid->tree().getValue(Coord(21)),
2198 grid->tree().getValue(Coord(21)));
2199
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 6 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.
6 EXPECT_EQ(
2200 intGrid->tree().getValue(Coord(23)),
2201 grid->tree().getValue(Coord(23)));
2202
2203 // Verify that the only active value in this grid is 999.
2204
1/2
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
6 const math::MinMax<Int32> extrema = tools::minMax(grid->tree());
2205
2/16
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 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.
6 EXPECT_EQ(999, extrema.min());
2206
2/18
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
6 EXPECT_EQ(999, extrema.max());
2207 }
2208
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
18 for (int idx = 1; idx <= 2; ++idx) {
2209 const FloatGrid::Ptr
2210
1/2
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
12 grid = gridPtrCast<FloatGrid>((*inGrids)[idx]),
2211 refGrid = gridPtrCast<FloatGrid>(grids[idx]);
2212
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 12 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.
12 EXPECT_TRUE(grid.get() != nullptr);
2213
4/20
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 12 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
12 EXPECT_EQ(int(refGrid->getGridClass()), int(grid->getGridClass()));
2214
2215
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 12 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.
12 EXPECT_TRUE(grid->tree().hasSameTopology(refGrid->tree()));
2216
2217 FloatGrid::ConstAccessor refAcc = refGrid->getConstAccessor();
2218
2/2
✓ Branch 0 taken 1371354 times.
✓ Branch 1 taken 12 times.
1371366 for (FloatGrid::ValueAllCIter it = grid->cbeginValueAll(); it; ++it) {
2219
2/16
✓ Branch 1 taken 1371354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1371354 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.
2742708 EXPECT_EQ(refAcc.getValue(it.getCoord()), *it);
2220 }
2221 }
2222 }
2223 }
2224 1 }
2225
2226
2227 ////////////////////////////////////////
2228
2229
2230 namespace {
2231
2232 using namespace openvdb;
2233
2234 struct TestAsyncHelper
2235 {
2236 std::set<io::Queue::Id> ids;
2237 std::map<io::Queue::Id, std::string> filenames;
2238 size_t refFileSize;
2239 bool verbose;
2240
2241
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 TestAsyncHelper(size_t _refFileSize): refFileSize(_refFileSize), verbose(false) {}
2242
2243 2 ~TestAsyncHelper()
2244 2 {
2245 // Remove output files.
2246 2 for (std::map<io::Queue::Id, std::string>::iterator it = filenames.begin();
2247
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 2 times.
20 it != filenames.end(); ++it)
2248 {
2249 18 ::remove(it->second.c_str());
2250 }
2251 filenames.clear();
2252 ids.clear();
2253 2 }
2254
2255 io::Queue::Notifier notifier()
2256 {
2257
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 return std::bind(&TestAsyncHelper::validate, this,
2258
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 std::placeholders::_1, std::placeholders::_2);
2259 }
2260
2261 18 void insert(io::Queue::Id id, const std::string& filename)
2262 {
2263 ids.insert(id);
2264 18 filenames[id] = filename;
2265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (verbose) std::cerr << "queued " << filename << " as task " << id << "\n";
2266 18 }
2267
2268 18 void validate(io::Queue::Id id, io::Queue::Status status)
2269 {
2270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (verbose) {
2271 std::ostringstream ostr;
2272 ostr << "task " << id;
2273 switch (status) {
2274 case io::Queue::UNKNOWN: ostr << " is unknown"; break;
2275 case io::Queue::PENDING: ostr << " is pending"; break;
2276 case io::Queue::SUCCEEDED: ostr << " succeeded"; break;
2277 case io::Queue::FAILED: ostr << " failed"; break;
2278 }
2279 std::cerr << ostr.str() << "\n";
2280 }
2281
2282
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if (status == io::Queue::SUCCEEDED) {
2283 // If the task completed successfully, verify that the output file's
2284 // size matches the reference file's size.
2285 struct stat buf;
2286 18 buf.st_size = 0;
2287
1/14
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
36 EXPECT_EQ(0, ::stat(filenames[id].c_str(), &buf));
2288
1/14
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
18 EXPECT_EQ(Index64(refFileSize), Index64(buf.st_size));
2289 }
2290
2291
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if (status == io::Queue::SUCCEEDED || status == io::Queue::FAILED) {
2292 ids.erase(id);
2293 }
2294 18 }
2295 }; // struct TestAsyncHelper
2296
2297 } // unnamed namespace
2298
2299
2300
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 TEST_F(TestFile, testAsync)
2301 {
2302 using namespace openvdb;
2303
2304 // Register types.
2305 1 openvdb::initialize();
2306
2307 // Create a grid.
2308 1 FloatGrid::Ptr lsGrid = createLevelSet<FloatGrid>();
2309
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 unittest_util::makeSphere(/*dim=*/Coord(100), /*ctr=*/Vec3f(50, 50, 50), /*r=*/20.0,
2310 *lsGrid, unittest_util::SPHERE_SPARSE_NARROW_BAND);
2311
2312 MetaMap fileMetadata;
2313
4/8
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
3 fileMetadata.insertMeta("author", StringMetadata("Einstein"));
2314
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 fileMetadata.insertMeta("year", Int32Metadata(2013));
2315
2316 1 GridPtrVec grids;
2317
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 grids.push_back(lsGrid);
2318
3/8
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
2 grids.push_back(lsGrid->deepCopy());
2319
3/8
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
2 grids.push_back(lsGrid->deepCopy());
2320
2321 size_t refFileSize = 0;
2322 {
2323 // Write a reference file without using asynchronous I/O.
2324 const char* filename = "testAsyncref.vdb";
2325 SharedPtr<const char> scopedFile(filename, ::remove);
2326
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 io::File f(filename);
2327
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 f.write(grids, fileMetadata);
2328
2329 // Record the size of the reference file.
2330 struct stat buf;
2331 1 buf.st_size = 0;
2332
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(0, ::stat(filename, &buf));
2333 1 refFileSize = buf.st_size;
2334 }
2335
2336 {
2337 // Output multiple files using asynchronous I/O.
2338 // Use polling to get the status of the I/O tasks.
2339
2340 1 TestAsyncHelper helper(refFileSize);
2341
2342
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 io::Queue queue;
2343
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1 times.
10 for (int i = 1; i < 10; ++i) {
2344
1/2
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
18 std::ostringstream ostr;
2345
2/4
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 ostr << "testAsync." << i << ".vdb";
2346 const std::string filename = ostr.str();
2347
2/4
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 io::Queue::Id id = queue.write(grids, io::File(filename), fileMetadata);
2348
1/2
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
9 helper.insert(id, filename);
2349 }
2350
2351 1 auto start = std::chrono::steady_clock::now();
2352
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 while (!helper.ids.empty()) {
2353 auto duration = std::chrono::duration_cast<std::chrono::seconds>(
2354 1 std::chrono::steady_clock::now() - start);
2355
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (size_t(duration.count()) > 60) break; // time out after 1 minute
2356
2357 // Wait one second for tasks to complete.
2358
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 std::this_thread::sleep_for(std::chrono::seconds(1));
2359
2360 // Poll each task in the pending map.
2361 std::set<io::Queue::Id> ids = helper.ids; // iterate over a copy
2362
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1 times.
10 for (std::set<io::Queue::Id>::iterator it = ids.begin(); it != ids.end(); ++it) {
2363 9 const io::Queue::Id id = *it;
2364
1/2
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
9 const io::Queue::Status status = queue.status(id);
2365
1/2
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
9 helper.validate(id, status);
2366 }
2367 }
2368
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(helper.ids.empty());
2369
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(queue.empty());
2370 }
2371 {
2372 // Output multiple files using asynchronous I/O.
2373 // Use notifications to get the status of the I/O tasks.
2374
2375 1 TestAsyncHelper helper(refFileSize);
2376
2377
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 io::Queue queue(/*capacity=*/2);
2378
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 queue.addNotifier(helper.notifier());
2379
2380
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1 times.
10 for (int i = 1; i < 10; ++i) {
2381
1/2
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
18 std::ostringstream ostr;
2382
2/4
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 ostr << "testAsync" << i << ".vdb";
2383 const std::string filename = ostr.str();
2384
2/4
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 io::Queue::Id id = queue.write(grids, io::File(filename), fileMetadata);
2385
1/2
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
9 helper.insert(id, filename);
2386 }
2387
3/4
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
2 while (!queue.empty()) {
2388
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 std::this_thread::sleep_for(std::chrono::seconds(1));
2389 }
2390 }
2391 {
2392 // Test queue timeout.
2393
2394
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 io::Queue queue(/*capacity=*/1);
2395
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 queue.setTimeout(0/*sec*/);
2396
2397 SharedPtr<const char>
2398 scopedFile1("testAsyncIOa.vdb", ::remove),
2399 scopedFile2("testAsyncIOb.vdb", ::remove);
2400 std::ofstream
2401
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 file1(scopedFile1.get()),
2402
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 file2(scopedFile2.get());
2403
2404
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
1 queue.write(grids, io::Stream(file1));
2405
2406 // With the queue length restricted to 1 and the timeout to 0 seconds,
2407 // the next write() call should time out immediately with an exception.
2408 // (It is possible, though highly unlikely, for the previous task to complete
2409 // in time for this write() to actually succeed.)
2410
6/24
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 27 taken 1 times.
✗ Branch 28 not taken.
✓ Branch 31 taken 1 times.
✗ Branch 32 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
3 EXPECT_THROW(queue.write(grids, io::Stream(file2)), openvdb::RuntimeError);
2411
2412
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
1 while (!queue.empty()) {
2413 std::this_thread::sleep_for(std::chrono::seconds(1));
2414 }
2415 }
2416 1 }
2417
2418
2419 #ifdef OPENVDB_USE_BLOSC
2420 // This tests for a data corruption bug that existed in versions of Blosc prior to 1.5.0
2421 // (see https://github.com/Blosc/c-blosc/pull/63).
2422
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 TEST_F(TestFile, testBlosc)
2423 {
2424 1 openvdb::initialize();
2425
2426 1 const unsigned char rawdata[] = {
2427 0x93, 0xb0, 0x49, 0xaf, 0x62, 0xad, 0xe3, 0xaa, 0xe4, 0xa5, 0x43, 0x20, 0x24,
2428 0x29, 0xc9, 0xaf, 0xee, 0xad, 0x0b, 0xac, 0x3d, 0xa8, 0x1f, 0x99, 0x53, 0x27,
2429 0xb6, 0x2b, 0x16, 0xb0, 0x5f, 0xae, 0x89, 0xac, 0x51, 0xa9, 0xfc, 0xa1, 0xc9,
2430 0x24, 0x59, 0x2a, 0x2f, 0x2d, 0xb4, 0xae, 0xeb, 0xac, 0x2f, 0xaa, 0xec, 0xa4,
2431 0x53, 0x21, 0x31, 0x29, 0x8f, 0x2c, 0x8e, 0x2e, 0x31, 0xad, 0xd6, 0xaa, 0x6d,
2432 0xa6, 0xad, 0x1b, 0x3e, 0x28, 0x0a, 0x2c, 0xfd, 0x2d, 0xf8, 0x2f, 0x45, 0xab,
2433 0x81, 0xa7, 0x1f, 0x95, 0x02, 0x27, 0x3d, 0x2b, 0x85, 0x2d, 0x75, 0x2f, 0xb6,
2434 0x30, 0x13, 0xa8, 0xb2, 0x9c, 0xf3, 0x25, 0x9c, 0x2a, 0x28, 0x2d, 0x0b, 0x2f,
2435 0x7b, 0x30, 0x68, 0x9e, 0x51, 0x25, 0x31, 0x2a, 0xe6, 0x2c, 0xbc, 0x2e, 0x4e,
2436 0x30, 0x5a, 0xb0, 0xe6, 0xae, 0x0e, 0xad, 0x59, 0xaa, 0x08, 0xa5, 0x89, 0x21,
2437 0x59, 0x29, 0xb0, 0x2c, 0x57, 0xaf, 0x8c, 0xad, 0x6f, 0xab, 0x65, 0xa7, 0xd3,
2438 0x12, 0xf5, 0x27, 0xeb, 0x2b, 0xf6, 0x2d, 0xee, 0xad, 0x27, 0xac, 0xab, 0xa8,
2439 0xb1, 0x9f, 0xa2, 0x25, 0xaa, 0x2a, 0x4a, 0x2d, 0x47, 0x2f, 0x7b, 0xac, 0x6d,
2440 0xa9, 0x45, 0xa3, 0x73, 0x23, 0x9d, 0x29, 0xb7, 0x2c, 0xa8, 0x2e, 0x51, 0x30,
2441 0xf7, 0xa9, 0xec, 0xa4, 0x79, 0x20, 0xc5, 0x28, 0x3f, 0x2c, 0x24, 0x2e, 0x09,
2442 0x30, 0xc8, 0xa5, 0xb1, 0x1c, 0x23, 0x28, 0xc3, 0x2b, 0xba, 0x2d, 0x9c, 0x2f,
2443 0xc3, 0x30, 0x44, 0x18, 0x6e, 0x27, 0x3d, 0x2b, 0x6b, 0x2d, 0x40, 0x2f, 0x8f,
2444 0x30, 0x02, 0x27, 0xed, 0x2a, 0x36, 0x2d, 0xfe, 0x2e, 0x68, 0x30, 0x66, 0xae,
2445 0x9e, 0xac, 0x96, 0xa9, 0x7c, 0xa3, 0xa9, 0x23, 0xc5, 0x29, 0xd8, 0x2c, 0xd7,
2446 0x2e, 0x0e, 0xad, 0x90, 0xaa, 0xe4, 0xa5, 0xf8, 0x1d, 0x82, 0x28, 0x2b, 0x2c,
2447 0x1e, 0x2e, 0x0c, 0x30, 0x53, 0xab, 0x9c, 0xa7, 0xd4, 0x96, 0xe7, 0x26, 0x30,
2448 0x2b, 0x7f, 0x2d, 0x6e, 0x2f, 0xb3, 0x30, 0x74, 0xa8, 0xb1, 0x9f, 0x36, 0x25,
2449 0x3e, 0x2a, 0xfa, 0x2c, 0xdd, 0x2e, 0x65, 0x30, 0xfc, 0xa1, 0xe0, 0x23, 0x82,
2450 0x29, 0x8f, 0x2c, 0x66, 0x2e, 0x23, 0x30, 0x2d, 0x22, 0xfb, 0x28, 0x3f, 0x2c,
2451 0x0a, 0x2e, 0xde, 0x2f, 0xaa, 0x28, 0x0a, 0x2c, 0xc8, 0x2d, 0x8f, 0x2f, 0xb0,
2452 0x30, 0xde, 0x2b, 0xa0, 0x2d, 0x5a, 0x2f, 0x8f, 0x30, 0x12, 0xac, 0x9d, 0xa8,
2453 0x0f, 0xa0, 0x51, 0x25, 0x66, 0x2a, 0x1b, 0x2d, 0x0b, 0x2f, 0x82, 0x30, 0x7b,
2454 0xa9, 0xea, 0xa3, 0x63, 0x22, 0x3f, 0x29, 0x7b, 0x2c, 0x60, 0x2e, 0x26, 0x30,
2455 0x76, 0xa5, 0xf8, 0x1d, 0x4c, 0x28, 0xeb, 0x2b, 0xce, 0x2d, 0xb0, 0x2f, 0xd3,
2456 0x12, 0x1d, 0x27, 0x15, 0x2b, 0x57, 0x2d, 0x2c, 0x2f, 0x85, 0x30, 0x0e, 0x26,
2457 0x74, 0x2a, 0xfa, 0x2c, 0xc3, 0x2e, 0x4a, 0x30, 0x08, 0x2a, 0xb7, 0x2c, 0x74,
2458 0x2e, 0x1d, 0x30, 0x8f, 0x2c, 0x3f, 0x2e, 0xf8, 0x2f, 0x24, 0x2e, 0xd0, 0x2f,
2459 0xc3, 0x30, 0xdb, 0xa6, 0xd3, 0x0e, 0x38, 0x27, 0x3d, 0x2b, 0x78, 0x2d, 0x5a,
2460 0x2f, 0xa3, 0x30, 0x68, 0x9e, 0x51, 0x25, 0x31, 0x2a, 0xe6, 0x2c, 0xbc, 0x2e,
2461 0x4e, 0x30, 0xa9, 0x23, 0x59, 0x29, 0x6e, 0x2c, 0x38, 0x2e, 0x06, 0x30, 0xb8,
2462 0x28, 0x10, 0x2c, 0xce, 0x2d, 0x95, 0x2f, 0xb3, 0x30, 0x9b, 0x2b, 0x7f, 0x2d,
2463 0x39, 0x2f, 0x7f, 0x30, 0x4a, 0x2d, 0xf8, 0x2e, 0x58, 0x30, 0xd0, 0x2e, 0x3d,
2464 0x30, 0x30, 0x30, 0x53, 0x21, 0xc5, 0x28, 0x24, 0x2c, 0xef, 0x2d, 0xc3, 0x2f,
2465 0xda, 0x27, 0x58, 0x2b, 0x6b, 0x2d, 0x33, 0x2f, 0x82, 0x30, 0x9c, 0x2a, 0x00,
2466 0x2d, 0xbc, 0x2e, 0x41, 0x30, 0xb0, 0x2c, 0x60, 0x2e, 0x0c, 0x30, 0x1e, 0x2e,
2467 0xca, 0x2f, 0xc0, 0x30, 0x95, 0x2f, 0x9f, 0x30, 0x8c, 0x30, 0x23, 0x2a, 0xc4,
2468 0x2c, 0x81, 0x2e, 0x23, 0x30, 0x5a, 0x2c, 0x0a, 0x2e, 0xc3, 0x2f, 0xc3, 0x30,
2469 0xad, 0x2d, 0x5a, 0x2f, 0x88, 0x30, 0x0b, 0x2f, 0x5b, 0x30, 0x3a, 0x30, 0x7f,
2470 0x2d, 0x2c, 0x2f, 0x72, 0x30, 0xc3, 0x2e, 0x37, 0x30, 0x09, 0x30, 0xb6, 0x30
2471 };
2472
2473 const char* indata = reinterpret_cast<const char*>(rawdata);
2474 size_t inbytes = sizeof(rawdata);
2475
2476 const int
2477 compbufbytes = int(inbytes + BLOSC_MAX_OVERHEAD),
2478 decompbufbytes = int(inbytes + BLOSC_MAX_OVERHEAD);
2479
2480 std::unique_ptr<char[]>
2481 1 compresseddata(new char[compbufbytes]),
2482
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 outdata(new char[decompbufbytes]);
2483
2484
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for (int compcode = 0; compcode <= BLOSC_ZLIB; ++compcode) {
2485 5 char* compname = nullptr;
2486 #if BLOSC_VERSION_MAJOR > 1 || (BLOSC_VERSION_MAJOR == 1 && BLOSC_VERSION_MINOR >= 15)
2487 if (0 > blosc_compcode_to_compname(compcode, const_cast<const char**>(&compname)))
2488 #else
2489
2/4
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
5 if (0 > blosc_compcode_to_compname(compcode, &compname))
2490 #endif
2491 continue;
2492 /// @todo This changes the compressor setting globally.
2493
2/4
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
5 if (blosc_set_compressor(compname) < 0) continue;
2494
2495
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 5 times.
25 for (int typesize = 1; typesize <= 4; ++typesize) {
2496
2497 // Compress the data.
2498 20 ::memset(compresseddata.get(), 0, compbufbytes);
2499
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
20 int compressedbytes = blosc_compress(
2500 /*clevel=*/9,
2501 /*doshuffle=*/true,
2502 typesize,
2503 /*srcsize=*/inbytes,
2504 /*src=*/indata,
2505 /*dest=*/compresseddata.get(),
2506 /*destsize=*/compbufbytes);
2507
2508
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 20 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.
20 EXPECT_TRUE(compressedbytes > 0);
2509
2510 // Decompress the data.
2511 20 ::memset(outdata.get(), 0, decompbufbytes);
2512
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
20 int outbytes = blosc_decompress(
2513 20 compresseddata.get(), outdata.get(), decompbufbytes);
2514
2515
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 20 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.
20 EXPECT_TRUE(outbytes > 0);
2516
2/16
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 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.
20 EXPECT_EQ(int(inbytes), outbytes);
2517
2518 // Compare original and decompressed data.
2519 int diff = 0;
2520
2/2
✓ Branch 0 taken 11440 times.
✓ Branch 1 taken 20 times.
11460 for (size_t i = 0; i < inbytes; ++i) {
2521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11440 times.
11440 if (outdata[i] != indata[i]) ++diff;
2522 }
2523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (diff > 0) {
2524 if (diff != 0) {
2525 FAIL() << "Your version of the Blosc library is most likely"
2526 " out of date; please install the latest version. "
2527 "(Earlier versions have a bug that can cause data corruption.)";
2528 }
2529 return;
2530 }
2531 }
2532 }
2533 }
2534 #endif
2535
2536
2537 void
2538 1 TestFile::testDelayedLoadMetadata()
2539 {
2540 1 openvdb::initialize();
2541
2542 using namespace openvdb;
2543
2544
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 io::File file("something.vdb2");
2545
2546 // Create a level set grid.
2547
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 auto lsGrid = createLevelSet<FloatGrid>();
2548
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 lsGrid->setName("sphere");
2549
1/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 unittest_util::makeSphere(/*dim=*/Coord(100), /*ctr=*/Vec3f(50, 50, 50), /*r=*/20.0,
2550 *lsGrid, unittest_util::SPHERE_SPARSE_NARROW_BAND);
2551
2552 // Write the VDB to a string stream.
2553
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::ostringstream ostr(std::ios_base::binary);
2554
2555 // Create the grid descriptor out of this grid.
2556
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 io::GridDescriptor gd(Name("sphere"), lsGrid->type());
2557
2558 // Write out the grid.
2559
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 file.writeGrid(gd, lsGrid, ostr, /*seekable=*/true);
2560
2561 // Duplicate VDB string stream.
2562
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::ostringstream ostr2(std::ios_base::binary);
2563
2564 { // Read back in, clip and write out again to verify metadata is rebuilt.
2565
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
3 std::istringstream istr(ostr.str(), std::ios_base::binary);
2566
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 io::setVersion(istr, file.libraryVersion(), file.fileVersion());
2567
2568
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 io::GridDescriptor gd2;
2569
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridBase::Ptr grid = gd2.read(istr);
2570
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd2.seekToGrid(istr);
2571
2572 1 const BBoxd clipBbox(Vec3d(-10.0,-10.0,-10.0), Vec3d(10.0,10.0,10.0));
2573
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 io::Archive::readGrid(grid, gd2, istr, clipBbox);
2574
2575 // Verify clipping is working as expected.
2576
5/24
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
2 EXPECT_TRUE(grid->baseTreePtr()->leafCount() < lsGrid->tree().leafCount());
2577
2578
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
2 file.writeGrid(gd, grid, ostr2, /*seekable=*/true);
2579 }
2580
2581 // Since the input is only a fragment of a VDB file (in particular,
2582 // it doesn't have a header), set the file format version number explicitly.
2583 // On read, the delayed load metadata for OpenVDB library versions less than 6.1
2584 // should be removed to ensure correctness as it possible for the metadata to
2585 // have been treated as unknown and blindly copied over when read and re-written
2586 // using this library version resulting in out-of-sync metadata.
2587
2588 // By default, DelayedLoadMetadata is dropped from the grid during read so
2589 // as not to be exposed to the user.
2590
2591 { // read using current library version
2592
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
3 std::istringstream istr(ostr2.str(), std::ios_base::binary);
2593
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 io::setVersion(istr, file.libraryVersion(), file.fileVersion());
2594
2595
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 io::GridDescriptor gd2;
2596
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridBase::Ptr grid = gd2.read(istr);
2597
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd2.seekToGrid(istr);
2598
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 io::Archive::readGrid(grid, gd2, istr);
2599
2600
3/22
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
1 EXPECT_TRUE(!((*grid)[GridBase::META_FILE_DELAYED_LOAD]));
2601 }
2602
2603 // To test the version mechanism, a stream metadata object is created with
2604 // a non-zero test value and set on the input stream. This disables the
2605 // behaviour where the DelayedLoadMetadata is dropped from the grid.
2606
2607
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 io::StreamMetadata::Ptr streamMetadata(new io::StreamMetadata);
2608
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 streamMetadata->__setTest(uint32_t(1));
2609
2610 { // read using current library version
2611
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
3 std::istringstream istr(ostr2.str(), std::ios_base::binary);
2612
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 io::setVersion(istr, file.libraryVersion(), file.fileVersion());
2613
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 io::setStreamMetadataPtr(istr, streamMetadata, /*transfer=*/false);
2614
2615
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 io::GridDescriptor gd2;
2616
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridBase::Ptr grid = gd2.read(istr);
2617
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd2.seekToGrid(istr);
2618
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 io::Archive::readGrid(grid, gd2, istr);
2619
2620
2/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 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.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
2 EXPECT_TRUE(((*grid)[GridBase::META_FILE_DELAYED_LOAD]));
2621 }
2622
2623 { // read using library version of 5.0
2624
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
3 std::istringstream istr(ostr2.str(), std::ios_base::binary);
2625
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 io::setVersion(istr, VersionId(5,0), file.fileVersion());
2626
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 io::setStreamMetadataPtr(istr, streamMetadata, /*transfer=*/false);
2627
2628
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 io::GridDescriptor gd2;
2629
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridBase::Ptr grid = gd2.read(istr);
2630
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd2.seekToGrid(istr);
2631
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 io::Archive::readGrid(grid, gd2, istr);
2632
2633
3/22
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
1 EXPECT_TRUE(!((*grid)[GridBase::META_FILE_DELAYED_LOAD]));
2634 }
2635
2636 { // read using library version of 4.9
2637
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
3 std::istringstream istr(ostr2.str(), std::ios_base::binary);
2638
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 io::setVersion(istr, VersionId(4,9), file.fileVersion());
2639
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 io::setStreamMetadataPtr(istr, streamMetadata, /*transfer=*/false);
2640
2641
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 io::GridDescriptor gd2;
2642
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridBase::Ptr grid = gd2.read(istr);
2643
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd2.seekToGrid(istr);
2644
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 io::Archive::readGrid(grid, gd2, istr);
2645
2646
3/22
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
1 EXPECT_TRUE(!((*grid)[GridBase::META_FILE_DELAYED_LOAD]));
2647 }
2648
2649 { // read using library version of 6.1
2650
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
3 std::istringstream istr(ostr2.str(), std::ios_base::binary);
2651
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 io::setVersion(istr, VersionId(6,1), file.fileVersion());
2652
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 io::setStreamMetadataPtr(istr, streamMetadata, /*transfer=*/false);
2653
2654
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 io::GridDescriptor gd2;
2655
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridBase::Ptr grid = gd2.read(istr);
2656
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd2.seekToGrid(istr);
2657
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 io::Archive::readGrid(grid, gd2, istr);
2658
2659
3/22
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
1 EXPECT_TRUE(!((*grid)[GridBase::META_FILE_DELAYED_LOAD]));
2660 }
2661
2662 { // read using library version of 6.2
2663
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
3 std::istringstream istr(ostr2.str(), std::ios_base::binary);
2664
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 io::setVersion(istr, VersionId(6,2), file.fileVersion());
2665
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 io::setStreamMetadataPtr(istr, streamMetadata, /*transfer=*/false);
2666
2667
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 io::GridDescriptor gd2;
2668
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GridBase::Ptr grid = gd2.read(istr);
2669
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gd2.seekToGrid(istr);
2670
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 io::Archive::readGrid(grid, gd2, istr);
2671
2672
2/20
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 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.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
2 EXPECT_TRUE(((*grid)[GridBase::META_FILE_DELAYED_LOAD]));
2673 }
2674
2675 1 remove("something.vdb2");
2676 1 }
2677
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 TEST_F(TestFile, testDelayedLoadMetadata) { testDelayedLoadMetadata(); }
2678
2679