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

◆ read_dense_vector()

bool MayaFlux::IO::Detail::VDBArchive::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.

As read_dense_scalar, for a grid whose leaf value type is vec3f, vec3d or vec3i. Non-vec3f types are converted component-wise via MayaFlux::try_convert; precision_lost is set if any of the three components of any element lost precision.

Returns
False if index is out of range, the grid is scalar-typed, or resolution has a zero axis. Call last_error() for detail.

Definition at line 749 of file VDBArchive.cpp.

756{
757 if (!m_state->read_file_open || index >= m_state->read_file.num_grids) {
758 m_last_error = "read_dense_vector: grid index out of range";
759 return false;
760 }
761 if (resolution.x == 0 || resolution.y == 0 || resolution.z == 0) {
762 m_last_error = "read_dense_vector: zero resolution";
763 return false;
764 }
765
766 const tvdb_grid_t& grid = m_state->read_file.grids[index];
767 const tvdb_value_type_t vt = leaf_value_type(grid);
768
769 if (!is_vector_type(vt)) {
770 const char* name = tvdb_grid_name(&m_state->read_file, index);
771 m_last_error = "read_dense_vector: grid '" + std::string(name ? name : "") + "' is scalar-typed";
772 return false;
773 }
774 const size_t elem_size = tvdb_value_type_size(vt);
775 if (elem_size == 0) {
776 m_last_error = "read_dense_vector: grid has an unsupported leaf value type";
777 return false;
778 }
779
780 if (precision_lost) {
781 *precision_lost = false;
782 }
783
784 out.assign(static_cast<size_t>(resolution.x) * resolution.y * resolution.z, background);
785
786 DenseVectorCtx ctx {};
787 ctx.region_min = region_min;
788 ctx.region_max = region_min + glm::ivec3(resolution);
789 ctx.vt = vt;
790 ctx.elem_size = elem_size;
791 ctx.precision_lost = precision_lost;
792 ctx.out = &out;
793
794 tvdb_grid_visit_leaves(&grid, dense_vector_visit, &ctx);
795 return true;
796}
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.