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;
138struct Ts_TypedKnotData :
144 bool operator==(
const Ts_TypedKnotData<T> &other)
const;
148 T GetPreValue()
const;
149 T GetPreTanSlope()
const;
150 T GetPreTanHeight()
const;
151 T GetPostTanSlope()
const;
152 T GetPostTanHeight()
const;
172static_assert(
sizeof(Ts_TypedKnotData<double>) <= 64);
180class Ts_KnotDataProxy
184 static std::unique_ptr<Ts_KnotDataProxy>
185 Create(Ts_KnotData *data,
TfType valueType);
187 virtual ~Ts_KnotDataProxy();
189 virtual Ts_KnotData* CloneData()
const = 0;
190 virtual void DeleteData() = 0;
192 virtual TfType GetValueType()
const = 0;
193 virtual bool IsDataEqualTo(
const Ts_KnotData &other)
const = 0;
195 virtual void SetValue(
VtValue value) = 0;
196 virtual void GetValue(
VtValue *valueOut)
const = 0;
197 virtual void SetPreValue(
VtValue value) = 0;
198 virtual void GetPreValue(
VtValue *valueOut)
const = 0;
200 virtual void SetPreTanSlope(
VtValue slope) = 0;
201 virtual void GetPreTanSlope(
VtValue *slopeOut)
const = 0;
202 virtual void SetPostTanSlope(
VtValue slope) = 0;
203 virtual void GetPostTanSlope(
VtValue *slopeOut)
const = 0;
210class Ts_TypedKnotDataProxy final :
211 public Ts_KnotDataProxy
214 explicit Ts_TypedKnotDataProxy(Ts_TypedKnotData<T> *data);
216 Ts_KnotData* CloneData()
const override;
217 void DeleteData()
override;
219 TfType GetValueType()
const override;
220 bool IsDataEqualTo(
const Ts_KnotData &other)
const override;
222 void SetValue(
VtValue value)
override;
223 void GetValue(
VtValue *valueOut)
const override;
224 void SetPreValue(
VtValue value)
override;
225 void GetPreValue(
VtValue *valueOut)
const override;
227 void SetPreTanSlope(
VtValue slope)
override;
228 void GetPreTanSlope(
VtValue *slopeOut)
const override;
229 void SetPostTanSlope(
VtValue slope)
override;
230 void GetPostTanSlope(
VtValue *slopeOut)
const override;
233 Ts_TypedKnotData<T> *_data;
241Ts_TypedKnotData<T>::Ts_TypedKnotData()
250#define COMP(member) \
251 if (member != other.member) \
257bool Ts_TypedKnotData<T>::operator==(
258 const Ts_TypedKnotData<T> &other)
const
278T Ts_TypedKnotData<T>::GetPreValue()
const
280 return (dualValued ? preValue : value);
284T Ts_TypedKnotData<T>::GetPreTanSlope()
const
290T Ts_TypedKnotData<T>::GetPreTanHeight()
const
292 return -preTanWidth * preTanSlope;
296T Ts_TypedKnotData<T>::GetPostTanSlope()
const
302T Ts_TypedKnotData<T>::GetPostTanHeight()
const
304 return postTanWidth * postTanSlope;
311Ts_TypedKnotDataProxy<T>::Ts_TypedKnotDataProxy(
312 Ts_TypedKnotData<T> *data)
318Ts_KnotData* Ts_TypedKnotDataProxy<T>::CloneData()
const
320 return new Ts_TypedKnotData<T>(*_data);
324void Ts_TypedKnotDataProxy<T>::DeleteData()
330TfType Ts_TypedKnotDataProxy<T>::GetValueType()
const
332 return Ts_GetType<T>();
336bool Ts_TypedKnotDataProxy<T>::IsDataEqualTo(
const Ts_KnotData &other)
const
339 const Ts_TypedKnotData<T> *typedOther =
340 static_cast<const Ts_TypedKnotData<T>*
>(&other);
342 return *_data == *typedOther;
346void Ts_TypedKnotDataProxy<T>::SetValue(
353void Ts_TypedKnotDataProxy<T>::GetValue(
356 *valueOut =
VtValue(_data->value);
360void Ts_TypedKnotDataProxy<T>::SetPreValue(
367void Ts_TypedKnotDataProxy<T>::GetPreValue(
370 *valueOut =
VtValue(_data->preValue);
374void Ts_TypedKnotDataProxy<T>::SetPreTanSlope(
381void Ts_TypedKnotDataProxy<T>::GetPreTanSlope(
384 *slopeOut =
VtValue(_data->GetPreTanSlope());
388void Ts_TypedKnotDataProxy<T>::SetPostTanSlope(
395void Ts_TypedKnotDataProxy<T>::GetPostTanSlope(
398 *slopeOut =
VtValue(_data->GetPostTanSlope());
402PXR_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.