8#ifndef PXR_BASE_TS_KNOT_H
9#define PXR_BASE_TS_KNOT_H
12#include "pxr/base/ts/api.h"
13#include "pxr/base/ts/knotData.h"
14#include "pxr/base/ts/typeHelpers.h"
16#include "pxr/base/vt/value.h"
18#include "pxr/base/tf/type.h"
26PXR_NAMESPACE_OPEN_SCOPE
59 TsCurveType curveType = TsCurveTypeBezier);
77 bool operator==(
const TsKnot &other)
const;
80 bool operator!=(
const TsKnot &other)
const;
91 TsTime GetTime()
const;
102 TsInterpMode GetNextInterpolation()
const;
109 TfType GetValueType()
const;
111 template <
typename T>
112 bool IsHolding()
const;
118 template <
typename T>
126 template <
typename T>
135 bool IsDualValued()
const;
141 template <
typename T>
149 template <
typename T>
154 bool ClearPreValue();
168 bool SetCurveType(TsCurveType curveType);
171 TsCurveType GetCurveType()
const;
187 bool SetPreTanWidth(TsTime width);
190 TsTime GetPreTanWidth()
const;
193 bool SetPreTanSlope(
VtValue slope);
195 template <
typename T>
196 bool SetPreTanSlope(T slope);
199 bool GetPreTanSlope(
VtValue *slopeOut)
const;
201 template <
typename T>
202 bool GetPreTanSlope(T *slopeOut)
const;
209 bool SetPostTanWidth(TsTime width);
212 TsTime GetPostTanWidth()
const;
215 bool SetPostTanSlope(
VtValue slope);
217 template <
typename T>
218 bool SetPostTanSlope(T slope);
221 bool GetPostTanSlope(
VtValue *slopeOut)
const;
223 template <
typename T>
224 bool GetPostTanSlope(T *slopeOut)
const;
249 bool SetCustomDataByKey(
250 const std::string &keyPath,
255 const std::string &keyPath)
const;
288 Ts_KnotData* _GetData() {
return _data; }
289 const Ts_KnotData* _GetData()
const {
return _data; }
292 template <
typename T>
293 bool _CheckInParam(T value)
const;
295 template <
typename T>
296 bool _CheckOutParam(T *valueOut)
const;
298 bool _CheckGetWidth()
const;
299 bool _CheckSetWidth(TsTime width)
const;
300 bool _CheckInParamVt(
VtValue value)
const;
301 bool _CheckOutParamVt(
VtValue* value)
const;
303 template <
typename T>
304 Ts_TypedKnotData<T>* _TypedData()
const;
306 template <
typename T>
307 const Ts_TypedKnotData<T>* _ConstTypedData()
const;
322 std::unique_ptr<Ts_KnotDataProxy> _proxy;
352 typename = std::enable_if_t<Ts_IsSupportedValueType<T>::value>>
376bool TsKnot::_CheckInParam(
const T value)
const
378 if constexpr (!Ts_IsSupportedValueType<T>::value)
380 static_assert(Ts_IsSupportedValueType<T>::value,
381 "Cannot pass non-floating-point type as T-typed knot parameter");
386 if (GetValueType() != Ts_GetType<T>())
389 "Cannot set '%s' value into knot of type '%s'",
390 Ts_GetType<T>().GetTypeName().c_str(),
391 GetValueType().GetTypeName().c_str());
395 if (!Ts_IsFinite(value))
406bool TsKnot::_CheckOutParam(T *valueOut)
const
408 if constexpr (!Ts_IsSupportedValueType<T>::value)
410 static_assert(Ts_IsSupportedValueType<T>::value,
411 "Cannot pass non-floating-point type as T-typed knot parameter");
422 if (GetValueType() != Ts_GetType<T>())
425 "Cannot read from knot of type '%s' into '%s'",
426 GetValueType().GetTypeName().c_str(),
427 Ts_GetType<T>().GetTypeName().c_str());
437TsKnot::_TypedData()
const
439 return static_cast<Ts_TypedKnotData<T>*
>(_data);
443const Ts_TypedKnotData<T>*
444TsKnot::_ConstTypedData()
const
446 return static_cast<const Ts_TypedKnotData<T>*
>(_data);
453bool TsKnot::IsHolding()
const
455 return GetValueType() == Ts_GetType<T>();
459bool TsKnot::SetValue(
const T value)
461 if (!_CheckInParam(value))
466 _TypedData<T>()->value = value;
471bool TsKnot::GetValue(T *valueOut)
const
473 if (!_CheckOutParam(valueOut))
478 *valueOut = _ConstTypedData<T>()->value;
483bool TsKnot::SetPreValue(
const T value)
485 if (!_CheckInParam(value))
490 _data->dualValued =
true;
491 _TypedData<T>()->preValue = value;
496bool TsKnot::GetPreValue(T*
const valueOut)
const
498 if (!_CheckOutParam(valueOut))
503 if (_data->dualValued)
505 *valueOut = _ConstTypedData<T>()->preValue;
509 *valueOut = _ConstTypedData<T>()->value;
519bool TsKnot::SetPreTanSlope(
const T slope)
521 if (!_CheckInParam(slope))
526 _TypedData<T>()->preTanSlope = slope;
531bool TsKnot::GetPreTanSlope(T*
const slopeOut)
const
533 if (!_CheckOutParam(slopeOut))
538 *slopeOut = _ConstTypedData<T>()->GetPreTanSlope();
546bool TsKnot::SetPostTanSlope(
const T slope)
548 if (!_CheckInParam(slope))
553 _TypedData<T>()->postTanSlope = slope;
558bool TsKnot::GetPostTanSlope(T*
const slopeOut)
const
560 if (!_CheckOutParam(slopeOut))
565 *slopeOut = _ConstTypedData<T>()->GetPostTanSlope();
570PXR_NAMESPACE_CLOSE_SCOPE
Low-level utilities for informing users of various internal and external diagnostic conditions.
TfType represents a dynamic runtime type.
A knot-construction convenience.
A knot-construction convenience.
A knot-construction convenience.
A knot belonging to a TsSpline.
TS_API TsKnot()
Default constructor creates a double-typed knot.
TS_API bool IsG1Continuous() const
Not yet implemented.
TS_API TsKnot(TfType valueType, TsCurveType curveType=TsCurveTypeBezier)
Creates a knot with a specified value type.
TS_API bool IsC1Continuous() const
Not yet implemented.
TS_API bool SetNextInterpolation(TsInterpMode mode)
Sets the interpolation mode of the spline segment following this knot.
TS_API bool IsC0Continuous() const
Not yet implemented.
An authoring helper class that enforces non-regression in splines.
A mathematical description of a curved function from time to value.
A convenience for constructing knots with specified types.
A map with string keys and VtValue values.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
#define TF_CODING_ERROR(fmt, args)
Issue an internal programming error, but continue execution.
This header serves to simply bring in the half float datatype and provide a hash_value function.