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

◆ advance_position()

bool MayaFlux::Kakshya::RegionSegment::advance_position ( uint64_t  steps = 1,
uint32_t  dimension = 0 
)
inline

Advance the current position within the segment.

Parameters
stepsNumber of steps to advance.
dimensionDimension to advance.
Returns
True if not at end, false if at end.

Definition at line 193 of file RegionSegment.hpp.

194 {
195
196 if (current_position.empty() || segment_size.empty() || dimension >= current_position.size()) {
197 return false;
198 }
199
200 current_position[dimension] += steps;
201
202 // return current_position[dimension] < segment_size[dimension];
203
204 for (size_t dim = dimension; dim < current_position.size(); ++dim) {
205 if (current_position[dim] >= segment_size[dim]) {
206 if (dim == current_position.size() - 1) {
207 return false;
208 }
209
210 uint64_t overflow = current_position[dim] / segment_size[dim];
212
213 if (dim + 1 < current_position.size()) {
214 current_position[dim + 1] += overflow;
215 }
216 } else {
217 break;
218 }
219 }
220
221 return !is_at_end();
222 }
std::vector< uint64_t > segment_size
Size in each dimension.
bool is_at_end() const
Check if the current position is at the end of the segment.
std::vector< uint64_t > current_position
Current position within segment.