8#ifndef PXR_BASE_TS_KNOT_DATA_H
9#define PXR_BASE_TS_KNOT_DATA_H
12#include "pxr/base/ts/api.h"
13#include "pxr/base/ts/types.h"
14#include "pxr/base/ts/typeHelpers.h"
15#include "pxr/base/vt/value.h"
16#include "pxr/base/tf/type.h"
21PXR_NAMESPACE_OPEN_SCOPE
72 static Ts_KnotData* Create(
TfType valueType);
75 bool operator==(
const Ts_KnotData &other)
const;
80 TsTime GetPreTanWidth()
const
85 TsTime GetPostTanWidth()
const
90 void SetPreTanWidth(
const TsTime width)
95 void SetPostTanWidth(
const TsTime width)
123 TsInterpMode nextInterp : 3;
126 TsCurveType curveType : 2;
132 TsTangentAlgorithm preTanAlgorithm : 4;
133 TsTangentAlgorithm postTanAlgorithm : 4;
142struct Ts_TypedKnotData :
148 bool operator==(
const Ts_TypedKnotData<T> &other)
const;
152 T GetPreValue()
const;
153 T GetPreTanSlope()
const;
154 T GetPreTanHeight()
const;
155 T GetPostTanSlope()
const;
156 T GetPostTanHeight()
const;
162 bool UpdateTangents(
const Ts_TypedKnotData<T>* prevData,
163 const Ts_TypedKnotData<T>* nextData,
164 const TsCurveType curveType);
168 bool _UpdateTangent(
const Ts_TypedKnotData<T>* prevData,
169 const Ts_TypedKnotData<T>* nextData,
170 TsCurveType curveType,
174 bool _UpdateTangentAutoEase(
const Ts_TypedKnotData<T>* prevData,
175 const Ts_TypedKnotData<T>* nextData,
199class Ts_KnotDataProxy
203 static std::unique_ptr<Ts_KnotDataProxy>
204 Create(Ts_KnotData *data,
TfType valueType);
206 virtual ~Ts_KnotDataProxy();
208 virtual Ts_KnotData* CloneData()
const = 0;
209 virtual void DeleteData() = 0;
211 virtual TfType GetValueType()
const = 0;
212 virtual bool IsDataEqualTo(
const Ts_KnotData &other)
const = 0;
214 virtual void SetValue(
VtValue value) = 0;
215 virtual void GetValue(
VtValue *valueOut)
const = 0;
216 virtual void SetPreValue(
VtValue value) = 0;
217 virtual void GetPreValue(
VtValue *valueOut)
const = 0;
219 virtual void SetPreTanSlope(
VtValue slope) = 0;
220 virtual void GetPreTanSlope(
VtValue *slopeOut)
const = 0;
221 virtual void SetPostTanSlope(
VtValue slope) = 0;
222 virtual void GetPostTanSlope(
VtValue *slopeOut)
const = 0;
224 virtual bool UpdateTangents(
const Ts_KnotDataProxy* prevProxy,
225 const Ts_KnotDataProxy* nextProxy,
226 const TsCurveType curveType) = 0;
233class Ts_TypedKnotDataProxy final :
234 public Ts_KnotDataProxy
237 explicit Ts_TypedKnotDataProxy(Ts_TypedKnotData<T> *data);
239 Ts_KnotData* CloneData()
const override;
240 void DeleteData()
override;
242 TfType GetValueType()
const override;
243 bool IsDataEqualTo(
const Ts_KnotData &other)
const override;
245 void SetValue(
VtValue value)
override;
246 void GetValue(
VtValue *valueOut)
const override;
247 void SetPreValue(
VtValue value)
override;
248 void GetPreValue(
VtValue *valueOut)
const override;
250 void SetPreTanSlope(
VtValue slope)
override;
251 void GetPreTanSlope(
VtValue *slopeOut)
const override;
252 void SetPostTanSlope(
VtValue slope)
override;
253 void GetPostTanSlope(
VtValue *slopeOut)
const override;
255 bool UpdateTangents(
const Ts_KnotDataProxy* prevProxy,
256 const Ts_KnotDataProxy* nextProxy,
257 const TsCurveType curveType)
override;
260 Ts_TypedKnotData<T> *_data;
268Ts_TypedKnotData<T>::Ts_TypedKnotData()
277#define COMP(member) \
278 if (member != other.member) \
284bool Ts_TypedKnotData<T>::operator==(
285 const Ts_TypedKnotData<T> &other)
const
301 COMP(preTanAlgorithm);
302 COMP(postTanAlgorithm);
310T Ts_TypedKnotData<T>::GetPreValue()
const
312 return (dualValued ? preValue : value);
316T Ts_TypedKnotData<T>::GetPreTanSlope()
const
322T Ts_TypedKnotData<T>::GetPreTanHeight()
const
324 return -preTanWidth * preTanSlope;
328T Ts_TypedKnotData<T>::GetPostTanSlope()
const
334T Ts_TypedKnotData<T>::GetPostTanHeight()
const
336 return postTanWidth * postTanSlope;
343Ts_TypedKnotDataProxy<T>::Ts_TypedKnotDataProxy(
344 Ts_TypedKnotData<T> *data)
350Ts_KnotData* Ts_TypedKnotDataProxy<T>::CloneData()
const
352 return new Ts_TypedKnotData<T>(*_data);
356void Ts_TypedKnotDataProxy<T>::DeleteData()
362TfType Ts_TypedKnotDataProxy<T>::GetValueType()
const
364 return Ts_GetType<T>();
368bool Ts_TypedKnotDataProxy<T>::IsDataEqualTo(
const Ts_KnotData &other)
const
371 const Ts_TypedKnotData<T> *typedOther =
372 static_cast<const Ts_TypedKnotData<T>*
>(&other);
374 return *_data == *typedOther;
378void Ts_TypedKnotDataProxy<T>::SetValue(
385void Ts_TypedKnotDataProxy<T>::GetValue(
388 *valueOut =
VtValue(_data->value);
392void Ts_TypedKnotDataProxy<T>::SetPreValue(
399void Ts_TypedKnotDataProxy<T>::GetPreValue(
402 *valueOut =
VtValue(_data->preValue);
406void Ts_TypedKnotDataProxy<T>::SetPreTanSlope(
413void Ts_TypedKnotDataProxy<T>::GetPreTanSlope(
416 *slopeOut =
VtValue(_data->GetPreTanSlope());
420void Ts_TypedKnotDataProxy<T>::SetPostTanSlope(
427void Ts_TypedKnotDataProxy<T>::GetPostTanSlope(
430 *slopeOut =
VtValue(_data->GetPostTanSlope());
434bool Ts_TypedKnotDataProxy<T>::UpdateTangents(
435 const Ts_KnotDataProxy* prevProxy,
436 const Ts_KnotDataProxy* nextProxy,
437 const TsCurveType curveType)
439 const Ts_TypedKnotDataProxy<T>* prevTypedProxy =
440 dynamic_cast<const Ts_TypedKnotDataProxy<T>*
>(prevProxy);
441 const Ts_TypedKnotData<T>* prevData = (prevTypedProxy
442 ? prevTypedProxy->_data
444 const Ts_TypedKnotDataProxy<T>* nextTypedProxy =
445 dynamic_cast<const Ts_TypedKnotDataProxy<T>*
>(nextProxy);
446 const Ts_TypedKnotData<T>* nextData = (nextTypedProxy
447 ? nextTypedProxy->_data
450 return _data->UpdateTangents(prevData, nextData, curveType);
454PXR_NAMESPACE_CLOSE_SCOPE
TfType represents a dynamic runtime type.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
T const & UncheckedGet() const &
Returns a const reference to the held object if the held object is of type T.