AcademySoftwareFoundation / AcademySoftwareFoundation/openvdb

[BUG] order of grids different when using openvdb::io::File vs openvdb::io::Stream

Open
#1,379 1 comment 0 reactions 1 assignee Claimed by @apradhana View on GitHub
bug
Dominant language
C++
Stars
3.4k
Forks
774
Avg merge
3d 9h
Merged PRs (30d)
34

Description

Windows 10
VDB 9.0
Clang 13 LLVM

When a .vdb file is opened with openvdb::io::File and iterated, the order of the names is different then when using openvdb::io::Stream and iterating.

```
openvdb::io::File file(sequence_filename);
// Open the file. This reads the file header, but not any grids.
file.open();

if (file.isOpen()) {
std::string channel_names[3];
uint32_t numChannels(0);

for (openvdb::io::File::NameIterator nameIter = file.beginName(); nameIter != file.endName(); ++nameIter)
{
channel_names[numChannels] = nameIter.gridName();
++numChannels;
}

FMT_LOG_WARN(VOX_LOG, "{:d} channels " " [{:s}] [{:s}] [{:s}]", numChannels, channel_names[0], channel_names[1],
channel_names[2]);
}
file.close();
```

and

```
std::ifstream file(frame_data.path, std::ios_base::in | std::ios_base::binary);
openvdb::io::Stream const stream(file, false); // *bugfix - parameter false, disables "delayed" loading of voxel data. If delayed-loading is on, the performance tanks! speedup++
openvdb::GridPtrVecPtr const grids(stream.getGrids());

file.close();

uint32_t const grid_count(SFM::min(3, grids->size()));
for (uint32_t grid_index = 0; grid_index < grid_count; ++grid_index) {

GridType::Ptr const grid(openvdb::GridBase::grid((*grids)[grid_index]));

std::string const name(grid->getName()); // debug breakpoint here
}
```

Order of grid names needs to be the same when opened with openvdb::io::File or openvdb::io::Stream

The code above is a simple example needed to reproduce the problem and observe the resulting bug.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.