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

◆ detect_data_dimensions() [1/3]

std::vector< Kakshya::DataDimension > MayaFlux::Kakshya::detect_data_dimensions ( const DataVariant data)

Detect data dimensions from a DataVariant.

Parameters
dataDataVariant to analyze
Returns
Vector of DataDimension descriptors

This function analyzes the structure of the provided DataVariant and extracts dimension information, including size, stride, and semantic roles.

Definition at line 259 of file DataUtils.cpp.

260{
261 MF_WARN(Journal::Component::Kakshya, Journal::Context::Runtime,
262 "{}\n{}\n{}\n{}",
263 "Inferring structure from single DataVariant is not advisable as the method makes naive assumptions that can lead to massive computational errors. "
264 "If the variant is part of a container, region, or segment, please use the appropriate method instead. "
265 "If the variant is part of a vector, please use infer_from_data_variant_vector instead. "
266 "If you are sure you want to proceed, please ignore this warning.");
267
268 return std::visit([](const auto& vec) -> std::vector<DataDimension> {
269 using ValueType = typename std::decay_t<decltype(vec)>::value_type;
270
271 std::vector<DataDimension> dims;
272
273 if constexpr (DecimalData<ValueType>) {
274 dims.emplace_back(DataDimension::time(vec.size()));
275
276 } else if constexpr (ComplexData<ValueType>) {
277 dims.emplace_back(DataDimension::frequency(vec.size()));
278
279 } else if constexpr (IntegerData<ValueType>) {
280 dims.emplace_back(DataDimension::spatial(vec.size(), 'x'));
281 } else if constexpr (GlmData<ValueType>) {
282 constexpr size_t components = glm_component_count<ValueType>();
283 DataDimension::Role role = DataDimension::Role::CUSTOM;
284
285 if constexpr (GlmVec2Type<ValueType>) {
286 role = DataDimension::Role::UV;
287 } else if constexpr (GlmVec3Type<ValueType>) {
288 role = DataDimension::Role::POSITION;
289 } else if constexpr (GlmVec4Type<ValueType>) {
290 role = DataDimension::Role::COLOR;
291 } else if constexpr (GlmMatrixType<ValueType>) {
292 role = DataDimension::Role::CUSTOM;
293 }
294
295 dims.push_back(DataDimension::grouped(
296 "glm_structured_data",
297 static_cast<uint64_t>(vec.size()),
298 static_cast<uint8_t>(components),
299 role));
300 } else {
301 dims.emplace_back(DataDimension::time(vec.size()));
302 }
303
304 return dims;
305 },
306 data);
307}
#define MF_WARN(comp, ctx,...)

References MayaFlux::Kakshya::DataDimension::COLOR, MayaFlux::Kakshya::DataDimension::CUSTOM, MayaFlux::Kakshya::DataDimension::frequency(), MayaFlux::Kakshya::DataDimension::grouped(), MayaFlux::Journal::Kakshya, MF_WARN, MayaFlux::Kakshya::DataDimension::POSITION, MayaFlux::Journal::Runtime, MayaFlux::Kakshya::DataDimension::spatial(), MayaFlux::Kakshya::DataDimension::time(), and MayaFlux::Kakshya::DataDimension::UV.

Referenced by MayaFlux::Yantra::infer_from_data_variant(), and MayaFlux::Yantra::infer_from_data_variant_vector().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: