MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ open()

bool MayaFlux::IO::Detail::VDBArchive::open ( const std::string &  path)

Open a .vdb and read every grid's tree into memory.

Replaces whatever a previous open() on this instance had loaded. Does not touch the write-side grid accumulation, so an instance is safe to open for reading even if add_grid was never called — the two are independent state.

Parameters
pathSource path, already resolved by the caller.
Returns
False on failure; call last_error() for detail.

Definition at line 648 of file VDBArchive.cpp.

649{
650 if (m_state->read_file_open) {
651 tvdb_file_close(&m_state->read_file);
652 m_state->read_file_open = false;
653 }
654
655 tvdb_error_t err;
656 std::memset(&err, 0, sizeof(err));
657
658 if (tvdb_file_open(&m_state->read_file, path.c_str(), nullptr, &err) != TVDB_OK) {
659 m_last_error = std::string("open failed: ")
660 + (err.message[0] != '\0' ? err.message : "unknown");
661 return false;
662 }
663 m_state->read_file_open = true;
664
665 if (tvdb_read_all_grids(&m_state->read_file, &err) != TVDB_OK) {
666 m_last_error = std::string("grid read failed: ")
667 + (err.message[0] != '\0' ? err.message : "unknown");
668 tvdb_file_close(&m_state->read_file);
669 m_state->read_file_open = false;
670 return false;
671 }
672
673 return true;
674}
std::string m_last_error
Set from the const read-path accessors too.
std::unique_ptr< State > m_state

References m_last_error, and m_state.