SortedGradientKnots< T_Float, T_Int > Class Template Reference

#include <gradientmath.h>

详细描述

template<typename T_Float, typename T_Int>
class maxon::SortedGradientKnots< T_Float, T_Int >

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.

Template Parameters
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 >

公共成员函数

void  重置 ()
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

Member Typedef Documentation

◆  FloatType

using FloatType = T_Float

◆  IntType

using IntType = T_Int

◆  IndexedKnotType

using IndexedKnotType = IndexedGradientKnot < FloatType , IntType >

成员函数文档编制

◆  Reset()

void Reset ( )

Removes all knots.

◆  ReserveMemory()

Result <void> ReserveMemory ( IntType   numKnots )

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.
返回
OK on success.

◆  InsertKnot()

Result <void> InsertKnot ( FloatType   position )

Inserts a knot at the provided position. The index of the knot is implicit.ertion.

参数
[in] position The position of the knot.
返回
OK on success.

◆  GetSampleKnot()

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.
返回
The requested knot.

◆  GetLeft()

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.
返回
The requested neighboring knot.

◆  GetRight()

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.
返回
The requested neighboring knot.

◆  GetKnot()

const IndexedKnotType & GetKnot ( IntType   knotIndex ) const

Returns the knot at a specific index.

参数
[in] knotIndex The index of the knot to retrieve.
返回
The requested knot.

◆  GetCount()

IntType GetCount ( ) const

Returns the number of knots contained.

返回
The number of knots.

◆  IsEmpty()

Bool IsEmpty ( ) const

Checks whether the knot series is empty.

返回
True if there are no knots.

◆  Sort()

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.

返回
OK on success.

Member Data Documentation

◆  _knots

BaseArray < IndexedKnotType > _knots
private

◆  _inversePermutation

BaseArray <T_Int> _inversePermutation
private