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/types.h"
15#include "pxr/base/ts/typeHelpers.h"
17#include "pxr/base/vt/value.h"
20#include "pxr/base/tf/preprocessorUtilsLite.h"
21#include "pxr/base/tf/type.h"
28PXR_NAMESPACE_OPEN_SCOPE
61 TsCurveType curveType = TsCurveTypeBezier);
79 bool operator==(
const TsKnot &other)
const;
82 bool operator!=(
const TsKnot &other)
const;
93 TsTime GetTime()
const;
104 TsInterpMode GetNextInterpolation()
const;
111 TfType GetValueType()
const;
113 template <
typename T>
114 bool IsHolding()
const;
120 template <
typename T>
128 template <
typename T>
137 bool IsDualValued()
const;
143 template <
typename T>
151 template <
typename T>
156 bool ClearPreValue();
170 bool SetCurveType(TsCurveType curveType);
173 TsCurveType GetCurveType()
const;
189 bool SetPreTanWidth(TsTime width);
192 TsTime GetPreTanWidth()
const;
195 bool SetPreTanSlope(
VtValue slope);
197 template <
typename T>
198 bool SetPreTanSlope(T slope);
201 bool GetPreTanSlope(
VtValue *slopeOut)
const;
203 template <
typename T>
204 bool GetPreTanSlope(T *slopeOut)
const;
211 bool SetPostTanWidth(TsTime width);
214 TsTime GetPostTanWidth()
const;
217 bool SetPostTanSlope(
VtValue slope);
219 template <
typename T>
220 bool SetPostTanSlope(T slope);
223 bool GetPostTanSlope(
VtValue *slopeOut)
const;
225 template <
typename T>
226 bool GetPostTanSlope(T *slopeOut)
const;
251 bool SetCustomDataByKey(
252 const std::string &keyPath,
257 const std::string &keyPath)
const;
290 Ts_KnotData* _GetData() {
return _data; }
291 const Ts_KnotData* _GetData()
const {
return _data; }
294 template <
typename T>
295 bool _CheckInParam(T value)
const;
297 template <
typename T>
298 bool _CheckOutParam(T *valueOut)
const;
300 bool _CheckGetWidth()
const;
301 bool _CheckSetWidth(TsTime width)
const;
302 bool _CheckInParamVt(
VtValue value)
const;
303 bool _CheckOutParamVt(
VtValue* value)
const;
305 template <
typename T>
306 Ts_TypedKnotData<T>* _TypedData()
const;
308 template <
typename T>
309 const Ts_TypedKnotData<T>* _ConstTypedData()
const;
324 std::unique_ptr<Ts_KnotDataProxy> _proxy;
354 typename = std::enable_if_t<Ts_IsSupportedValueType<T>::value>>
374#define _MAKE_CLAUSE(unused, tuple) \
375 static_assert(std::is_same_v<TF_PP_CAT(TF_PP_CAT(Ts, \
376 TS_SPLINE_VALUE_TYPE_NAME(tuple)), Knot), \
377 TsTypedKnot<TS_SPLINE_VALUE_CPP_TYPE(tuple)>>, \
378 "Incorrect type alias for TsKnot type: " #tuple);
379TF_PP_SEQ_FOR_EACH(_MAKE_CLAUSE, ~, TS_SPLINE_SUPPORTED_VALUE_TYPES)
388bool TsKnot::_CheckInParam(
const T value)
const
390 if constexpr (!Ts_IsSupportedValueType<T>::value)
392 static_assert(Ts_IsSupportedValueType<T>::value,
393 "Cannot pass non-floating-point type as T-typed knot parameter");
398 if (GetValueType() != Ts_GetType<T>())
401 "Cannot set '%s' value into knot of type '%s'",
402 Ts_GetType<T>().GetTypeName().c_str(),
403 GetValueType().GetTypeName().c_str());
407 if (!Ts_IsFinite(value))
418bool TsKnot::_CheckOutParam(T *valueOut)
const
420 if constexpr (!Ts_IsSupportedValueType<T>::value)
422 static_assert(Ts_IsSupportedValueType<T>::value,
423 "Cannot pass non-floating-point type as T-typed knot parameter");
434 if (GetValueType() != Ts_GetType<T>())
437 "Cannot read from knot of type '%s' into '%s'",
438 GetValueType().GetTypeName().c_str(),
439 Ts_GetType<T>().GetTypeName().c_str());
449TsKnot::_TypedData()
const
451 return static_cast<Ts_TypedKnotData<T>*
>(_data);
455const Ts_TypedKnotData<T>*
456TsKnot::_ConstTypedData()
const
458 return static_cast<const Ts_TypedKnotData<T>*
>(_data);
465bool TsKnot::IsHolding()
const
467 return GetValueType() == Ts_GetType<T>();
471bool TsKnot::SetValue(
const T value)
473 if (!_CheckInParam(value))
478 _TypedData<T>()->value = value;
483bool TsKnot::GetValue(T *valueOut)
const
485 if (!_CheckOutParam(valueOut))
490 *valueOut = _ConstTypedData<T>()->value;
495bool TsKnot::SetPreValue(
const T value)
497 if (!_CheckInParam(value))
502 _data->dualValued =
true;
503 _TypedData<T>()->preValue = value;
508bool TsKnot::GetPreValue(T*
const valueOut)
const
510 if (!_CheckOutParam(valueOut))
515 if (_data->dualValued)
517 *valueOut = _ConstTypedData<T>()->preValue;
521 *valueOut = _ConstTypedData<T>()->value;
531bool TsKnot::SetPreTanSlope(
const T slope)
533 if (!_CheckInParam(slope))
538 _TypedData<T>()->preTanSlope = slope;
543bool TsKnot::GetPreTanSlope(T*
const slopeOut)
const
545 if (!_CheckOutParam(slopeOut))
550 *slopeOut = _ConstTypedData<T>()->GetPreTanSlope();
558bool TsKnot::SetPostTanSlope(
const T slope)
560 if (!_CheckInParam(slope))
565 _TypedData<T>()->postTanSlope = slope;
570bool TsKnot::GetPostTanSlope(T*
const slopeOut)
const
572 if (!_CheckOutParam(slopeOut))
577 *slopeOut = _ConstTypedData<T>()->GetPostTanSlope();
582PXR_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.