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.
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) {
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