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

◆ extract() [1/2]

std::optional< Kakshya::VolumeData > MayaFlux::IO::VolumeReader::extract ( const Kinesis::Lattice3D lattice,
const VolumeReadOptions options = {} 
) const

Extract every selected grid onto a caller-supplied lattice.

Parameters
latticeOutput lattice, as in the load() overload.
optionsGrid selection.
Returns
Populated VolumeData, or nullopt if no file is open or on failure; check get_last_error().

Definition at line 200 of file VolumeReader.cpp.

202{
203 if (!m_is_open) {
204 set_error("No file open");
205 return std::nullopt;
206 }
207
208 const size_t count = m_archive->read_grid_count();
209 if (count == 0) {
210 set_error("No grids in file");
211 return std::nullopt;
212 }
213
214 const auto indices = select_indices(*m_archive, count, options.field_names);
215 if (indices.empty()) {
216 set_error("No matching grids");
217 return std::nullopt;
218 }
219
220 const auto first = m_archive->grid_summary(indices.front());
221 if (glm::any(glm::lessThanEqual(first.voxel_size, glm::vec3(0.0F)))) {
222 set_error("First selected grid has a degenerate voxel size");
223 return std::nullopt;
224 }
225
226 const glm::vec3 region_min_f = (lattice.bounds.min - first.translation) / first.voxel_size + glm::vec3(0.5F);
227 const glm::ivec3 region_min = glm::ivec3(glm::round(region_min_f));
228
229 return materialize(indices, region_min, lattice);
230}
glm::ivec3 region_min
size_t count
void set_error(std::string msg) const
std::optional< Kakshya::VolumeData > materialize(const std::vector< size_t > &indices, const glm::ivec3 &region_min, const Kinesis::Lattice3D &lattice) const
Build VolumeData from selected grids over an explicit region.
std::unique_ptr< Detail::VDBArchive > m_archive

References MayaFlux::Kinesis::Lattice3D::bounds, count, MayaFlux::IO::VolumeReadOptions::field_names, m_archive, m_is_open, materialize(), MayaFlux::Kinesis::AABB3D::min, region_min, and set_error().

+ Here is the call graph for this function: