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"
29PXR_NAMESPACE_OPEN_SCOPE
71 TsCurveType curveType);
89 bool operator==(
const TsKnot &other)
const;
92 bool operator!=(
const TsKnot &other)
const;
103 TsTime GetTime()
const;
114 TsInterpMode GetNextInterpolation()
const;
121 TfType GetValueType()
const;
123 template <
typename T>
124 bool IsHolding()
const;
130 template <
typename T>
138 template <
typename T>
147 bool IsDualValued()
const;
153 template <
typename T>
161 template <
typename T>
166 bool ClearPreValue();
179 bool SetCurveType(TsCurveType curveType);
182 TsCurveType GetCurveType()
const;
198 bool SetPreTanWidth(TsTime width);
201 TsTime GetPreTanWidth()
const;
204 bool SetPreTanSlope(
VtValue slope);
206 template <
typename T>
207 bool SetPreTanSlope(T slope);
210 bool GetPreTanSlope(
VtValue *slopeOut)
const;
212 template <
typename T>
213 bool GetPreTanSlope(T *slopeOut)
const;
235 bool SetPostTanWidth(TsTime width);
238 TsTime GetPostTanWidth()
const;
241 bool SetPostTanSlope(
VtValue slope);
243 template <
typename T>
244 bool SetPostTanSlope(T slope);
247 bool GetPostTanSlope(
VtValue *slopeOut)
const;
249 template <
typename T>
250 bool GetPostTanSlope(T *slopeOut)
const;
295 const std::optional<TsKnot> nextKnot,
296 TsCurveType curveType = TsCurveTypeBezier);
321 bool SetCustomDataByKey(
322 const std::string &keyPath,
327 const std::string &keyPath)
const;
360 Ts_KnotData* _GetData() {
return _data; }
361 const Ts_KnotData* _GetData()
const {
return _data; }
364 template <
typename T>
365 bool _CheckInParam(T value)
const;
367 template <
typename T>
368 bool _CheckOutParam(T *valueOut)
const;
370 bool _CheckSetWidth(TsTime width)
const;
371 bool _CheckInParamVt(
VtValue value)
const;
372 bool _CheckOutParamVt(
VtValue* value)
const;
374 template <
typename T>
375 Ts_TypedKnotData<T>* _TypedData()
const;
377 template <
typename T>
378 const Ts_TypedKnotData<T>* _ConstTypedData()
const;
393 std::unique_ptr<Ts_KnotDataProxy> _proxy;
423 typename = std::enable_if_t<Ts_IsSupportedValueType<T>::value>>
443#define _MAKE_CLAUSE(unused, tuple) \
444 static_assert(std::is_same_v<TF_PP_CAT(TF_PP_CAT(Ts, \
445 TS_SPLINE_VALUE_TYPE_NAME(tuple)), Knot), \
446 TsTypedKnot<TS_SPLINE_VALUE_CPP_TYPE(tuple)>>, \
447 "Incorrect type alias for TsKnot type: " #tuple);
448TF_PP_SEQ_FOR_EACH(_MAKE_CLAUSE, ~, TS_SPLINE_SUPPORTED_VALUE_TYPES)
457bool TsKnot::_CheckInParam(
const T value)
const
459 if constexpr (!Ts_IsSupportedValueType<T>::value)
461 static_assert(Ts_IsSupportedValueType<T>::value,
462 "Cannot pass non-floating-point type as T-typed knot parameter");
467 if (GetValueType() != Ts_GetType<T>())
470 "Cannot set '%s' value into knot of type '%s'",
471 Ts_GetType<T>().GetTypeName().c_str(),
472 GetValueType().GetTypeName().c_str());
476 if (!Ts_IsFinite(value))
487bool TsKnot::_CheckOutParam(T *valueOut)
const
489 if constexpr (!Ts_IsSupportedValueType<T>::value)
491 static_assert(Ts_IsSupportedValueType<T>::value,
492 "Cannot pass non-floating-point type as T-typed knot parameter");
503 if (GetValueType() != Ts_GetType<T>())
506 "Cannot read from knot of type '%s' into '%s'",
507 GetValueType().GetTypeName().c_str(),
508 Ts_GetType<T>().GetTypeName().c_str());
518TsKnot::_TypedData()
const
520 return static_cast<Ts_TypedKnotData<T>*
>(_data);
524const Ts_TypedKnotData<T>*
525TsKnot::_ConstTypedData()
const
527 return static_cast<const Ts_TypedKnotData<T>*
>(_data);
534bool TsKnot::IsHolding()
const
536 return GetValueType() == Ts_GetType<T>();
540bool TsKnot::SetValue(
const T value)
542 if (!_CheckInParam(value))
547 _TypedData<T>()->value = value;
552bool TsKnot::GetValue(T *valueOut)
const
554 if (!_CheckOutParam(valueOut))
559 *valueOut = _ConstTypedData<T>()->value;
564bool TsKnot::SetPreValue(
const T value)
566 if (!_CheckInParam(value))
571 _data->dualValued =
true;
572 _TypedData<T>()->preValue = value;
577bool TsKnot::GetPreValue(T*
const valueOut)
const
579 if (!_CheckOutParam(valueOut))
584 if (_data->dualValued)
586 *valueOut = _ConstTypedData<T>()->preValue;
590 *valueOut = _ConstTypedData<T>()->value;
600bool TsKnot::SetPreTanSlope(
const T slope)
602 if (!_CheckInParam(slope))
607 _TypedData<T>()->preTanSlope = slope;
612bool TsKnot::GetPreTanSlope(T*
const slopeOut)
const
614 if (!_CheckOutParam(slopeOut))
619 *slopeOut = _ConstTypedData<T>()->GetPreTanSlope();
627bool TsKnot::SetPostTanSlope(
const T slope)
629 if (!_CheckInParam(slope))
634 _TypedData<T>()->postTanSlope = slope;
639bool TsKnot::GetPostTanSlope(T*
const slopeOut)
const
641 if (!_CheckOutParam(slopeOut))
646 *slopeOut = _ConstTypedData<T>()->GetPostTanSlope();
651PXR_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 TsTangentAlgorithm GetPreTanAlgorithm() const
Get the pre-tangent algorithm.
TS_API TsKnot(TfType valueType)
Creates a knot with a specified value type.
TS_API bool IsG1Continuous() const
Not yet implemented.
TS_API TsTangentAlgorithm GetPostTanAlgorithm() const
Get the post-tangent algorithm.
TS_API bool SetPostTanAlgorithm(TsTangentAlgorithm algorithm)
Set the post-tangent algorithm.
TS_API bool UpdateTangents(const std::optional< TsKnot > prevKnot, const std::optional< TsKnot > nextKnot, TsCurveType curveType=TsCurveTypeBezier)
Update tangent values algorithmically.
TS_API bool IsC1Continuous() const
Not yet implemented.
TS_API bool SetPreTanAlgorithm(TsTangentAlgorithm algorithm)
Set the pre-tangent algorithm.
TS_API TsKnot(TfType valueType, TsCurveType curveType)
Creates a knot with a specified value type and curve type.
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.