MayaFlux 0.3.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 203 of file RegionUtils.hpp.

208{
209 if (source_spans.size() != 1) {
210 error<std::invalid_argument>(
211 Journal::Component::Kakshya, Journal::Context::Runtime,
212 std::source_location::current(),
213 "Source spans cannot be empty");
214 }
215
216 std::vector<std::vector<T>> result;
217
218 for (const auto& segment : segments) {
219 if (segment.is_cached && !segment.cache.data.empty()) {
220 for (const auto& variant : segment.cache.data) {
221 std::vector<T> converted;
222 auto span = extract_from_variant<T>(variant, converted);
223 std::vector<T> cached_data(span.begin(), span.end());
224
225 if (organization == OrganizationStrategy::INTERLEAVED) {
226 if (result.empty())
227 result.resize(1);
228 std::ranges::copy(cached_data, std::back_inserter(result[0]));
229 } else {
230 if (result.size() <= result.size())
231 result.resize(result.size() + 1);
232 result.back() = std::move(cached_data);
233 }
234 }
235 } else {
236 auto region_data = extract_region_data<T>(source_spans, segment.source_region, dimensions, organization);
237
238 if (organization == OrganizationStrategy::INTERLEAVED) {
239 if (result.empty())
240 result.resize(1);
241 std::ranges::copy(region_data[0], std::back_inserter(result[0]));
242 } else {
243 if (result.empty())
244 result.resize(region_data.size());
245 for (size_t i = 0; i < region_data.size(); ++i) {
246 std::ranges::copy(region_data[i], std::back_inserter(result[i]));
247 }
248 }
249 }
250 }
251
252 return result;
253}

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