#include <gradientmath.h>
This class organizes a collection of gradient knots. Knots can be added in arbitrary order and are sorted as a finalization step. To avoid re-ordering data associated with the knots, e.g. colors, we maintain the original indices for data lookup.
T_Float | The type of real-valued position, recommended are Float, Float32 and Float64. |
T_Int | The type of index, recommended are Int, Int32 and Int64. We recommend to match the bitdepth of index and position. |
Public Types | |
using | FloatType = T_Float |
using | IntType = T_Int |
using | IndexedKnotType = IndexedGradientKnot< FloatType, IntType > |
Public Member Functions | |
void | Reset () |
Result< void > | ReserveMemory (IntType numKnots) |
Result< void > | InsertKnot (FloatType position) |
const IndexedKnotType & | GetSampleKnot (FloatType samplePosition) const |
const IndexedKnotType & | GetLeft (const IndexedKnotType &knot) const |
const IndexedKnotType & | GetRight (const IndexedKnotType &knot) const |
const IndexedKnotType & | GetKnot (IntType knotIndex) const |
IntType | GetCount () const |
Bool | IsEmpty () const |
Result< void > | Sort () |
Private Attributes | |
BaseArray< IndexedKnotType > | _knots |
BaseArray< T_Int > | _inversePermutation |
using FloatType = T_Float |
using IntType = T_Int |
using IndexedKnotType = IndexedGradientKnot<FloatType, IntType> |
void Reset | ( | ) |
Removes all knots.
Allocates the memory required for knot storage. If the amount of knots is known beforehand we recommend to pre-allocate memory to avoid any memory allocations during knot insertion.
[in] | numKnots | The number of knots to reserve memory for. |
Inserts a knot at the provided position. The index of the knot is implicit.ertion.
[in] | position | The position of the knot. |
const IndexedKnotType& GetSampleKnot | ( | FloatType | samplePosition | ) | const |
Return the knot left to the requested position if there is one. If there is none, the knot right next to the requested position is returned. Please note that this function is unsafe for empty gradients.
[in] | samplePosition | The requested position. |
const IndexedKnotType& GetLeft | ( | const IndexedKnotType & | knot | ) | const |
Return the knot left to a knot if there is one. If not, the knot itself is returned. Please note that this function is unsafe for empty gradients.
[in] | knot | The knot to query. |
const IndexedKnotType& GetRight | ( | const IndexedKnotType & | knot | ) | const |
Return the knot right to a knot if there is one. If not, the knot itself is returned. Please note that this function is unsafe for empty gradients.
[in] | knot | The knot to query. |
const IndexedKnotType& GetKnot | ( | IntType | knotIndex | ) | const |
Returns the knot at a specific index.
[in] | knotIndex | The index of the knot to retrieve. |
IntType GetCount | ( | ) | const |
Returns the number of knots contained.
Bool IsEmpty | ( | ) | const |
Checks whether the knot series is empty.
Result<void> Sort | ( | ) |
Sorts the knots in ascending order. The original ordering from knot insertion is preserved as an inverse permutation for later data lookup with the original indices.
|
private |
|
private |