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

◆ load_volume()

std::shared_ptr< Buffers::VolumeGridBuffer > MayaFlux::IO::IOManager::load_volume ( const std::string &  filepath,
const IO::VolumeReadOptions &  options = {} 
)

Load a volume file into a newly constructed VolumeGridBuffer.

Opens the file via IO::VolumeReader, reads every selected grid into VolumeData, constructs a VolumeGridBuffer with one FieldDecl per field — name and semantics from the file, stride sizeof(float) for a scalar field or sizeof(glm::vec4) for a vector one, the GPU layout every vector field uses regardless of what VolumeData stores — over the file's own lattice, and seeds it via IO::upload_volume. Mirrors load_mesh: construction and GPU registration only, nothing about processing chain or rendering.

setup_processors() and any simulation wiring via setup_flow() are left to the caller, as VolumeGridBuffer's own usage example assumes. Nothing about an imported file says whether the caller wants to keep simulating what it loaded, run it once as a mask, or read it once and discard the buffer — so nothing here decides that for them.

The returned buffer is retained for the lifetime of IOManager; see get_loaded_volumes().

Parameters
filepathPath to the volume file (.vdb).
optionsGrid selection, forwarded to VolumeReader::load().
Returns
Constructed and seeded VolumeGridBuffer, or nullptr on failure.

Definition at line 1278 of file IOManager.cpp.

1279{
1280 IO::VolumeReader reader;
1281
1282 if (!reader.can_read(filepath)) {
1284 "IOManager::load_volume: unsupported format '{}'", filepath);
1285 return nullptr;
1286 }
1287
1288 auto data = reader.load(filepath, options);
1289 if (!data) {
1291 "IOManager::load_volume: failed to load '{}' — {}",
1292 filepath, reader.get_last_error());
1293 return nullptr;
1294 }
1295
1297
1298 if (!buffer) {
1300 "IOManager::load_volume: failed to construct or upload VolumeGridBuffer for '{}'", filepath);
1301 return nullptr;
1302 }
1303
1304 m_loaded_volumes.push_back(buffer);
1305
1307 "IOManager::load_volume: {} field(s) from '{}'",
1308 data->fields.size(),
1309 std::filesystem::path(filepath).filename().string());
1310
1311 return buffer;
1312}
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
std::shared_ptr< NetworkGeometryBuffer > buffer
std::vector< std::shared_ptr< Buffers::VolumeGridBuffer > > m_loaded_volumes
std::shared_ptr< Buffers::BufferManager > m_buffer_manager
std::shared_ptr< Buffers::VolumeGridBuffer > create_volume_grid_buffer(const std::shared_ptr< Buffers::BufferManager > &buffer_manager, const Kakshya::VolumeData &volume_data)
@ FileIO
Filesystem I/O operations.
@ API
MayaFlux/API Wrapper and convenience functions.

References MayaFlux::Journal::API, buffer, MayaFlux::IO::VolumeReader::can_read(), MayaFlux::IO::Detail::create_volume_grid_buffer(), MayaFlux::Journal::FileIO, MayaFlux::IO::VolumeReader::get_last_error(), MayaFlux::IO::VolumeReader::load(), m_buffer_manager, m_loaded_volumes, MF_ERROR, and MF_INFO.

+ Here is the call graph for this function: