MayaFlux 1.0.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 614 of file VDBArchive.cpp.

615{
616 if (m_state->read_file_open) {
617 tvdb_file_close(&m_state->read_file);
618 m_state->read_file_open = false;
619 }
620
621 tvdb_error_t err;
622 std::memset(&err, 0, sizeof(err));
623
624 if (tvdb_file_open(&m_state->read_file, path.c_str(), nullptr, &err) != TVDB_OK) {
625 m_last_error = std::string("open failed: ")
626 + (err.message[0] != '\0' ? err.message : "unknown");
627 return false;
628 }
629 m_state->read_file_open = true;
630
631 if (tvdb_read_all_grids(&m_state->read_file, &err) != TVDB_OK) {
632 m_last_error = std::string("grid read failed: ")
633 + (err.message[0] != '\0' ? err.message : "unknown");
634 tvdb_file_close(&m_state->read_file);
635 m_state->read_file_open = false;
636 return false;
637 }
638
639 return true;
640}
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.