MayaFlux 0.4.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 716 of file RegionUtils.hpp.

720{
721 if (dims.empty()) {
722 error<std::invalid_argument>(
723 Journal::Component::Kakshya, Journal::Context::Runtime,
724 std::source_location::current(),
725 "extract_nd_region: dims must not be empty");
726 }
727
728 uint64_t total = 1;
729 for (const auto& d : dims)
730 total *= d.size;
731
732 if (src.size() < total) {
733 error<std::invalid_argument>(
734 Journal::Component::Kakshya, Journal::Context::Runtime,
735 std::source_location::current(),
736 "extract_nd_region: src smaller than total element count implied by dims");
737 }
738
739 Region clamped = region;
740 clamped.start_coordinates.resize(dims.size(), 0);
741 clamped.end_coordinates.resize(dims.size());
742 for (size_t i = 0; i < dims.size(); ++i) {
743 if (i >= region.end_coordinates.size()) {
744 clamped.end_coordinates[i] = dims[i].size - 1;
745 } else {
746 clamped.end_coordinates[i] = std::min(region.end_coordinates[i], dims[i].size - 1);
747 }
748 }
749
750 return extract_region_data<T>(src, clamped, dims);
751}
Range size
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.