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

◆ window() [1/2]

std::optional< TensorSpec > MayaFlux::Kakshya::TensorSpec::window ( const Region & region) const
nodiscard

Spec of the box a Region selects.

Bounds are inclusive. Trailing axes the region does not name span their full extent.

Returns
The window, or std::nullopt when the region is empty, names more axes than the tensor, has mismatched bounds, or the box is not addressable as described for the span overload.

Definition at line 251 of file TensorSpec.cpp.

252{
253 const size_t named = region.start_coordinates.size();
254 if (named == 0 || named != region.end_coordinates.size() || named > shape.size())
255 return std::nullopt;
256
257 std::vector<uint64_t> origin(shape.size(), 0);
258 std::vector<uint64_t> extent = shape;
259 for (size_t axis = 0; axis < named; ++axis) {
260 const uint64_t first = region.start_coordinates[axis];
261 const uint64_t last = region.end_coordinates[axis];
262 if (first > last || last >= shape[axis])
263 return std::nullopt;
264 origin[axis] = first;
265 extent[axis] = last - first + 1;
266 }
267 return window(origin, extent);
268}
std::optional< TensorSpec > window(std::span< const uint64_t > origin, std::span< const uint64_t > extent) const
Spec of the box that starts at origin and spans extent elements per axis.
std::vector< uint64_t > shape

References MayaFlux::Kakshya::Region::end_coordinates, shape, MayaFlux::Kakshya::Region::start_coordinates, and window().

Here is the call graph for this function: