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

◆ to_nddata()

template<typename T >
requires (ArithmeticData<T> && DataVariantElement<T>)
std::optional< CompositeProjection > MayaFlux::Kakshya::CompositeSlice::to_nddata ( std::string_view  field_name) const

Materialize one exact-type arithmetic field as homogeneous NDData.

Template Parameters
TDeclared field type and supported DataVariant element type.
Parameters
field_nameField to project.
Returns
Owning values, presence mask, and dimension metadata; or std::nullopt if the field is absent from the layout or has another type. Missing values are zero-filled and marked absent in the mask.

Definition at line 217 of file CompositeAccess.hpp.

218{
219 const auto field_index = layout().find_field(field_name);
220 if (!field_index || layout().fields()[*field_index].type != std::type_index(typeid(T)))
221 return std::nullopt;
222
223 std::vector<T> values(m_count);
224 std::vector<uint8_t> presence(m_count, 0);
225 for (size_t i = 0; i < m_count; ++i) {
226 const auto element = at(i);
227 if (!element)
228 return std::nullopt;
229 if (auto value = element->get<T>(field_name)) {
230 values[i] = *value;
231 presence[i] = 1;
232 }
233 }
234
235 CompositeProjection result;
236 result.values = std::move(values);
237 result.presence = std::move(presence);
238 result.dimensions.emplace_back(std::string(field_name), m_count, 1, DataDimension::Role::CUSTOM);
239 return result;
240}
glm::vec3 value
std::vector< std::byte > values
Definition VDBWriter.cpp:26
vk::PhysicalDeviceType type
Definition VKDevice.cpp:126
std::optional< size_t > find_field(std::string_view name) const noexcept
Find a field index by name, or std::nullopt if absent.
Definition Composite.cpp:54
std::optional< Composite > at(size_t index) const noexcept
Borrow a selected element by slice-relative index.
const CompositeLayout & layout() const noexcept
Shared layout of all selected elements.
@ CUSTOM
User-defined or application-specific.

References MayaFlux::Kakshya::DataDimension::CUSTOM, MayaFlux::Kakshya::CompositeProjection::dimensions, MayaFlux::Kakshya::CompositeProjection::presence, type, value, values, and MayaFlux::Kakshya::CompositeProjection::values.