MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::IO::Detail::VDBArchive Class Reference

RAII boundary around tinyvdb's C read and write paths. More...

#include <VDBArchive.hpp>

+ Collaboration diagram for MayaFlux::IO::Detail::VDBArchive:

Classes

struct  State
 Built grids and the storage their borrowed pointers refer into. More...
 

Public Member Functions

bool add_grid (const Kinesis::Lattice3D &lattice, const VDBGridSpec &spec)
 Build one grid from active cells and retain it for saving.
 
size_t grid_count () const
 
std::string grid_metadata (size_t index, std::string_view key) const
 Look up a string-typed metadata entry on a grid.
 
VDBGridSummary grid_summary (size_t index) const
 Summarize one grid: name, value kind, transform, active bounds.
 
std::string_view last_error () const
 
bool open (const std::string &path)
 Open a .vdb and read every grid's tree into memory.
 
VDBArchiveoperator= (const VDBArchive &)=delete
 
VDBArchiveoperator= (VDBArchive &&)=delete
 
bool read_dense_scalar (size_t index, const glm::ivec3 &region_min, const glm::uvec3 &resolution, float background, std::vector< float > &out, bool *precision_lost=nullptr) const
 Materialize a scalar grid's cells over an explicit region.
 
bool read_dense_vector (size_t index, const glm::ivec3 &region_min, const glm::uvec3 &resolution, const glm::vec3 &background, std::vector< glm::vec3 > &out, bool *precision_lost=nullptr) const
 Materialize a vector grid's cells over an explicit region.
 
size_t read_grid_count () const
 Number of grids in the opened file, or 0 if none is open.
 
bool save (const std::string &path, uint32_t compression, int level)
 Write every added grid to one file.
 
 VDBArchive ()
 
 VDBArchive (const VDBArchive &)=delete
 
 VDBArchive (VDBArchive &&)=delete
 
 ~VDBArchive ()
 

Private Attributes

std::string m_last_error
 Set from the const read-path accessors too.
 
std::unique_ptr< Statem_state
 

Detailed Description

RAII boundary around tinyvdb's C read and write paths.

Every tvdb_ symbol, every manual allocation and every C-interop lint suppression in MayaFlux lives behind this class. Nothing above it includes a tinyvdb header, so a future change of backing library touches one translation unit.

Write path: grids accumulate through add_grid and are written together by a single save, producing one .vdb carrying every field as a separately named grid. The destructor releases whatever was built regardless of whether save ran, so an abandoned archive and a failed one clean up identically.

Read path: open() parses a file and reads every grid's tree into memory. grid_summary(), grid_metadata() and read_dense_scalar/read_dense_vector then address grids by index, in file order. An instance used for reading is not also used for writing; the two paths share the class only because they share the C boundary they hide.

Not copyable and not movable: the underlying file struct holds a pointer into this object's own grid storage on the write side, and open() leaves live pointers into mapped file data on the read side.

Definition at line 94 of file VDBArchive.hpp.


The documentation for this class was generated from the following files: