MayaFlux 0.4.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 208 of file DataUtils.cpp.

209{
210 MF_WARN(Journal::Component::Kakshya, Journal::Context::Runtime,
211 "{}\n{}\n{}\n{}",
212 "Inferring structure from single DataVariant is not advisable as the method makes naive assumptions that can lead to massive computational errors. "
213 "If the variant is part of a container, region, or segment, please use the appropriate method instead. "
214 "If the variant is part of a vector, please use infer_from_data_variant_vector instead. "
215 "If you are sure you want to proceed, please ignore this warning.");
216
217 return std::visit([](const auto& vec) -> std::vector<DataDimension> {
218 using ValueType = typename std::decay_t<decltype(vec)>::value_type;
219
220 std::vector<DataDimension> dims;
221
222 if constexpr (DecimalData<ValueType>) {
223 dims.emplace_back(DataDimension::time(vec.size()));
224
225 } else if constexpr (ComplexData<ValueType>) {
226 dims.emplace_back(DataDimension::frequency(vec.size()));
227
228 } else if constexpr (IntegerData<ValueType>) {
229 dims.emplace_back(DataDimension::spatial(vec.size(), 'x'));
230 } else if constexpr (GlmData<ValueType>) {
231 constexpr size_t components = glm_component_count<ValueType>();
232 DataDimension::Role role = DataDimension::Role::CUSTOM;
233
234 if constexpr (GlmVec2Type<ValueType>) {
235 role = DataDimension::Role::UV;
236 } else if constexpr (GlmVec3Type<ValueType>) {
237 role = DataDimension::Role::POSITION;
238 } else if constexpr (GlmVec4Type<ValueType>) {
239 role = DataDimension::Role::COLOR;
240 } else if constexpr (GlmMatrixType<ValueType>) {
241 role = DataDimension::Role::CUSTOM;
242 }
243
244 dims.push_back(DataDimension::grouped(
245 "glm_structured_data",
246 static_cast<uint64_t>(vec.size()),
247 static_cast<uint8_t>(components),
248 role));
249 } else {
250 dims.emplace_back(DataDimension::time(vec.size()));
251 }
252
253 return dims;
254 },
255 data);
256}
#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: