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

◆ extract_segments_data()

template<typename T >
std::vector< std::vector< T > > MayaFlux::Kakshya::extract_segments_data ( const std::vector< RegionSegment > &  segments,
const std::vector< std::span< const T > > &  source_spans,
const std::vector< DataDimension > &  dimensions,
OrganizationStrategy  organization 
)

Extract data for multiple segments from multi-channel source data.

Template Parameters
TData type.
Parameters
segmentsVector of region segments to extract.
source_spansVector of source data spans (one per channel).
dimensionsDimension descriptors.
organizationStorage organization strategy.
Returns
Vector of vectors, each containing extracted data for one segment.

Definition at line 221 of file RegionUtils.hpp.

226{
227 if (source_spans.size() != 1) {
228 error<std::invalid_argument>(
229 Journal::Component::Kakshya, Journal::Context::Runtime,
230 std::source_location::current(),
231 "Source spans cannot be empty");
232 }
233
234 std::vector<std::vector<T>> result;
235
236 for (const auto& segment : segments) {
237 if (segment.is_cached && !segment.cache.data.empty()) {
238 for (const auto& variant : segment.cache.data) {
239 std::vector<T> converted;
240 auto span = extract_from_variant<T>(variant, converted);
241 std::vector<T> cached_data(span.begin(), span.end());
242
243 if (organization == OrganizationStrategy::INTERLEAVED) {
244 if (result.empty())
245 result.resize(1);
246 std::ranges::copy(cached_data, std::back_inserter(result[0]));
247 } else {
248 if (result.size() <= result.size())
249 result.resize(result.size() + 1);
250 result.back() = std::move(cached_data);
251 }
252 }
253 } else {
254 auto region_data = extract_region_data<T>(source_spans, segment.source_region, dimensions, organization);
255
256 if (organization == OrganizationStrategy::INTERLEAVED) {
257 if (result.empty())
258 result.resize(1);
259 std::ranges::copy(region_data[0], std::back_inserter(result[0]));
260 } else {
261 if (result.empty())
262 result.resize(region_data.size());
263 for (size_t i = 0; i < region_data.size(); ++i) {
264 std::ranges::copy(region_data[i], std::back_inserter(result[i]));
265 }
266 }
267 }
268 }
269
270 return result;
271}

References INTERLEAVED, MayaFlux::Journal::Kakshya, and MayaFlux::Journal::Runtime.