Blender V4.3
blender::bke::curves::IndexRangeCyclic Class Reference

#include <BKE_curves_utils.hh>

Classes

struct  CyclicIterator
 

Public Member Functions

constexpr IndexRangeCyclic ()=default
 
 ~IndexRangeCyclic ()=default
 
constexpr IndexRangeCyclic (const int start, const int end, const int iterable_range_size, const int cycles)
 
constexpr IndexRangeCyclic (const int start, const int end, const int iterable_range_size)
 
template<typename IndexT >
constexpr IndexT next_index (const IndexT index, const bool cyclic)
 
template<typename IndexT >
constexpr IndexT previous_index (const IndexT index, const bool cyclic)
 
constexpr IndexRangeCyclic push_loop (const int n=1) const
 
constexpr IndexRangeCyclic push_front (const int n=1) const
 
constexpr IndexRangeCyclic push_back (const int n=1) const
 
constexpr IndexRangeCyclic drop_front (const int n=1) const
 
constexpr IndexRangeCyclic drop_back (const int n=1) const
 
constexpr IndexRange curve_range () const
 
constexpr IndexRange range_before_loop () const
 
constexpr IndexRange range_after_loop () const
 
constexpr int size_range () const
 
constexpr int size_before_loop () const
 
constexpr int size_after_loop () const
 
constexpr int size () const
 
constexpr int cycles () const
 
constexpr int first () const
 
constexpr int last () const
 
constexpr int one_after_last () const
 
constexpr bool operator== (const IndexRangeCyclic &other) const
 
constexpr bool operator!= (const IndexRangeCyclic &other) const
 
constexpr CyclicIterator begin () const
 
constexpr CyclicIterator end () const
 

Static Public Member Functions

static IndexRangeCyclic get_range_from_size (const int start_index, const int iterator_size, const int iterable_range_size)
 
static IndexRangeCyclic get_range_between_endpoints (const CurvePoint start_point, const CurvePoint end_point, const int iterable_range_size)
 

Detailed Description

Cyclical index range. Allows iteration over a plain 'IndexRange' interval on form [start, end) while also supporting treating the underlying array as a cyclic array where the last index is followed by the first index in the 'cyclical' range. The cyclical index range can then be considered a combination of the intervals separated by the last index of the underlying array, namely [start, range_size) and [0, end) where start/end is the indices iterated between and range_size is the size of the underlying array. To cycle the underlying array the interval [0, range_size) can be iterated over an arbitrary amount of times in between.

Definition at line 80 of file BKE_curves_utils.hh.

Constructor & Destructor Documentation

◆ IndexRangeCyclic() [1/3]

blender::bke::curves::IndexRangeCyclic::IndexRangeCyclic ( )
constexprdefault

◆ ~IndexRangeCyclic()

blender::bke::curves::IndexRangeCyclic::~IndexRangeCyclic ( )
default

◆ IndexRangeCyclic() [2/3]

blender::bke::curves::IndexRangeCyclic::IndexRangeCyclic ( const int start,
const int end,
const int iterable_range_size,
const int cycles )
inlineconstexpr

Definition at line 99 of file BKE_curves_utils.hh.

◆ IndexRangeCyclic() [3/3]

blender::bke::curves::IndexRangeCyclic::IndexRangeCyclic ( const int start,
const int end,
const int iterable_range_size )
inlineconstexpr

Create an iterator over the cyclical interval [start_index, end_index).

Definition at line 110 of file BKE_curves_utils.hh.

Member Function Documentation

◆ begin()

CyclicIterator blender::bke::curves::IndexRangeCyclic::begin ( ) const
inlineconstexpr

Definition at line 399 of file BKE_curves_utils.hh.

◆ curve_range()

IndexRange blender::bke::curves::IndexRangeCyclic::curve_range ( ) const
inlineconstexpr

Get the index range for the curve buffer.

Definition at line 304 of file BKE_curves_utils.hh.

References size_range().

Referenced by blender::geometry::copy_point_data_between_endpoints(), and blender::geometry::sample_interval_bezier().

◆ cycles()

int blender::bke::curves::IndexRangeCyclic::cycles ( ) const
inlineconstexpr

Return the number of times the iterator will cycle before ending.

Definition at line 366 of file BKE_curves_utils.hh.

Referenced by blender::geometry::copy_point_data_between_endpoints(), get_range_between_endpoints(), and blender::geometry::sample_interval_bezier().

◆ drop_back()

IndexRangeCyclic blender::bke::curves::IndexRangeCyclic::drop_back ( const int n = 1) const
inlineconstexpr

Returns a new range with n indices removed from the end of the range. This invokes undefined behavior when n is negative or n is larger then the underlying range.

Definition at line 284 of file BKE_curves_utils.hh.

References BLI_assert, int, num_cycles, and size_range().

◆ drop_front()

IndexRangeCyclic blender::bke::curves::IndexRangeCyclic::drop_front ( const int n = 1) const
inlineconstexpr

Returns a new range with n indices removed from the beginning of the range. This invokes undefined behavior.

Definition at line 262 of file BKE_curves_utils.hh.

References BLI_assert, int, num_cycles, and size_range().

Referenced by blender::geometry::sample_interval_bezier(), and blender::geometry::sample_interval_linear().

◆ end()

CyclicIterator blender::bke::curves::IndexRangeCyclic::end ( ) const
inlineconstexpr

Definition at line 404 of file BKE_curves_utils.hh.

◆ first()

int blender::bke::curves::IndexRangeCyclic::first ( ) const
inlineconstexpr

◆ get_range_between_endpoints()

static IndexRangeCyclic blender::bke::curves::IndexRangeCyclic::get_range_between_endpoints ( const CurvePoint start_point,
const CurvePoint end_point,
const int iterable_range_size )
inlinestatic

Create a cyclical iterator for all control points within the interval [start_point, end_point] including any control point at the start or end point.

Parameters
start_pointPoint on the curve that define the starting point of the interval.
end_pointPoint on the curve that define the end point of the interval (included).
iterable_range_sizeSize of the underlying range (superset to the cyclical range).

Definition at line 154 of file BKE_curves_utils.hh.

References BLI_assert, cycles(), blender::bke::curves::CurveSegment::index, IndexRangeCyclic(), blender::bke::curves::CurvePoint::is_controlpoint(), blender::bke::curves::CurveSegment::next_index, and blender::bke::curves::CurvePoint::parameter.

◆ get_range_from_size()

static IndexRangeCyclic blender::bke::curves::IndexRangeCyclic::get_range_from_size ( const int start_index,
const int iterator_size,
const int iterable_range_size )
inlinestatic

Create a cyclical iterator of the specified size.

Parameters
start_pointPoint on the curve that define the starting point of the interval.
iterator_sizeNumber of elements to iterate (size of the iterated cyclical range).
iterable_range_sizeSize of the underlying range (superset to the cyclical range).

Definition at line 125 of file BKE_curves_utils.hh.

References BLI_assert, and IndexRangeCyclic().

◆ last()

int blender::bke::curves::IndexRangeCyclic::last ( ) const
inlineconstexpr

Definition at line 376 of file BKE_curves_utils.hh.

References BLI_assert, int, and size().

◆ next_index()

template<typename IndexT >
IndexT blender::bke::curves::IndexRangeCyclic::next_index ( const IndexT index,
const bool cyclic )
inlineconstexpr

Next index within the iterable range.

Definition at line 183 of file BKE_curves_utils.hh.

References blender::is_same_any_v, next_index(), and size_range().

Referenced by next_index().

◆ one_after_last()

int blender::bke::curves::IndexRangeCyclic::one_after_last ( ) const
inlineconstexpr

◆ operator!=()

bool blender::bke::curves::IndexRangeCyclic::operator!= ( const IndexRangeCyclic & other) const
inlineconstexpr

Definition at line 392 of file BKE_curves_utils.hh.

References operator==().

◆ operator==()

bool blender::bke::curves::IndexRangeCyclic::operator== ( const IndexRangeCyclic & other) const
inlineconstexpr

Definition at line 387 of file BKE_curves_utils.hh.

Referenced by operator!=().

◆ previous_index()

template<typename IndexT >
IndexT blender::bke::curves::IndexRangeCyclic::previous_index ( const IndexT index,
const bool cyclic )
inlineconstexpr

Previous index within the iterable range.

Definition at line 196 of file BKE_curves_utils.hh.

References blender::is_same_any_v, and size_range().

◆ push_back()

IndexRangeCyclic blender::bke::curves::IndexRangeCyclic::push_back ( const int n = 1) const
inlineconstexpr

Increment the range by adding the given number of indices to the end of the iterated range. This invokes undefined behavior when n is negative.

Definition at line 241 of file BKE_curves_utils.hh.

References BLI_assert, int, num_cycles, and size_range().

◆ push_front()

IndexRangeCyclic blender::bke::curves::IndexRangeCyclic::push_front ( const int n = 1) const
inlineconstexpr

Increment the range by adding the given number of indices to the beginning of the iterated range. This invokes undefined behavior when n is negative.

Definition at line 219 of file BKE_curves_utils.hh.

References BLI_assert, int, num_cycles, and size_range().

◆ push_loop()

IndexRangeCyclic blender::bke::curves::IndexRangeCyclic::push_loop ( const int n = 1) const
inlineconstexpr

Increment the range by adding n loops to the range. This invokes undefined behavior when n is negative.

Definition at line 210 of file BKE_curves_utils.hh.

◆ range_after_loop()

IndexRange blender::bke::curves::IndexRangeCyclic::range_after_loop ( ) const
inlineconstexpr

Range between the first element in the iterable range up to the last element in the range.

Definition at line 320 of file BKE_curves_utils.hh.

References size_after_loop().

◆ range_before_loop()

IndexRange blender::bke::curves::IndexRangeCyclic::range_before_loop ( ) const
inlineconstexpr

Range between the first element up to the end of the range.

Definition at line 312 of file BKE_curves_utils.hh.

References size_before_loop().

◆ size()

int blender::bke::curves::IndexRangeCyclic::size ( ) const
inlineconstexpr

Number of elements iterated by the cyclical index range.

Definition at line 353 of file BKE_curves_utils.hh.

References int, and size_before_loop().

Referenced by last().

◆ size_after_loop()

int blender::bke::curves::IndexRangeCyclic::size_after_loop ( ) const
inlineconstexpr

Number of elements between the first element in the iterable range up to the last element in the range.

Definition at line 345 of file BKE_curves_utils.hh.

Referenced by blender::geometry::copy_point_data_between_endpoints(), range_after_loop(), and blender::geometry::sample_interval_bezier().

◆ size_before_loop()

int blender::bke::curves::IndexRangeCyclic::size_before_loop ( ) const
inlineconstexpr

Number of elements between the first element in the range up to the last element in the curve.

Definition at line 336 of file BKE_curves_utils.hh.

Referenced by blender::geometry::copy_point_data_between_endpoints(), range_before_loop(), blender::geometry::sample_interval_bezier(), and size().

◆ size_range()

int blender::bke::curves::IndexRangeCyclic::size_range ( ) const
inlineconstexpr

Number of elements in the underlying iterable range.

Definition at line 328 of file BKE_curves_utils.hh.

Referenced by curve_range(), drop_back(), drop_front(), next_index(), previous_index(), push_back(), push_front(), and blender::geometry::sample_interval_bezier().


The documentation for this class was generated from the following file: