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

◆ extract_nd_region()

template<typename T >
std::vector< T > MayaFlux::Kakshya::extract_nd_region ( std::span< const T >  src,
const Region region,
const std::vector< DataDimension > &  dims 
)

Extract the data described by region from src using the container's dimension descriptors.

Delegates to the existing role-aware extract_region_data machinery so that the region coordinates are interpreted correctly regardless of axis order or modality. The caller decides what the region bounds mean — this function imposes no shape assumption (rectangular, cubic, or otherwise).

For interleaved image data (IMAGE_COLOR / ROW_MAJOR) the channel dimension is included in the walk if the region carries a coordinate for it; if the region has fewer coordinates than dimensions, trailing axes are included in full.

Template Parameters
TElement type of the source buffer (e.g. uint8_t).
Parameters
srcFlat source buffer in the layout described by dims.
regionN-dimensional bounds; start/end coordinate count may be less than dims.size() — missing trailing axes default to full extent.
dimsDimension descriptors from the container structure, ordered consistently with the flat buffer layout.
Returns
Flat buffer containing the extracted elements in the same axis order as dims.
Exceptions
std::invalid_argumentif dims is empty or src is smaller than the total element count implied by dims.
std::out_of_rangeif any coordinate in region exceeds the corresponding dimension size.

Definition at line 698 of file RegionUtils.hpp.

702{
703 if (dims.empty()) {
704 error<std::invalid_argument>(
705 Journal::Component::Kakshya, Journal::Context::Runtime,
706 std::source_location::current(),
707 "extract_nd_region: dims must not be empty");
708 }
709
710 uint64_t total = 1;
711 for (const auto& d : dims)
712 total *= d.size;
713
714 if (src.size() < total) {
715 error<std::invalid_argument>(
716 Journal::Component::Kakshya, Journal::Context::Runtime,
717 std::source_location::current(),
718 "extract_nd_region: src smaller than total element count implied by dims");
719 }
720
721 Region clamped = region;
722 clamped.start_coordinates.resize(dims.size(), 0);
723 clamped.end_coordinates.resize(dims.size());
724 for (size_t i = 0; i < dims.size(); ++i) {
725 if (i >= region.end_coordinates.size()) {
726 clamped.end_coordinates[i] = dims[i].size - 1;
727 } else {
728 clamped.end_coordinates[i] = std::min(region.end_coordinates[i], dims[i].size - 1);
729 }
730 }
731
732 return extract_region_data<T>(src, clamped, dims);
733}
std::vector< uint64_t > end_coordinates
Ending frame index (inclusive)
Definition Region.hpp:72
std::vector< uint64_t > start_coordinates
Starting frame index (inclusive)
Definition Region.hpp:69

References MayaFlux::Kakshya::Region::end_coordinates, MayaFlux::Journal::Kakshya, MayaFlux::Journal::Runtime, and MayaFlux::Kakshya::Region::start_coordinates.