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"
22#include "pxr/base/tf/preprocessorUtilsLite.h"
23#include "pxr/base/tf/type.h"
31PXR_NAMESPACE_OPEN_SCOPE
73 TsCurveType curveType);
91 bool operator==(
const TsKnot &other)
const;
94 bool operator!=(
const TsKnot &other)
const;
105 TsTime GetTime()
const;
116 TsInterpMode GetNextInterpolation()
const;
123 TfType GetValueType()
const;
125 template <
typename T>
126 bool IsHolding()
const;
132 template <
typename T>
140 template <
typename T>
149 bool IsDualValued()
const;
155 template <
typename T>
163 template <
typename T>
168 bool ClearPreValue();
181 bool SetCurveType(TsCurveType curveType);
184 TsCurveType GetCurveType()
const;
200 bool SetPreTanWidth(TsTime width);
203 TsTime GetPreTanWidth()
const;
206 bool SetPreTanSlope(
VtValue slope);
208 template <
typename T>
209 bool SetPreTanSlope(T slope);
212 bool GetPreTanSlope(
VtValue *slopeOut)
const;
214 template <
typename T>
215 bool GetPreTanSlope(T *slopeOut)
const;
237 bool SetPostTanWidth(TsTime width);
240 TsTime GetPostTanWidth()
const;
243 bool SetPostTanSlope(
VtValue slope);
245 template <
typename T>
246 bool SetPostTanSlope(T slope);
249 bool GetPostTanSlope(
VtValue *slopeOut)
const;
251 template <
typename T>
252 bool GetPostTanSlope(T *slopeOut)
const;
297 const std::optional<TsKnot> nextKnot,
298 TsCurveType curveType = TsCurveTypeBezier);
323 bool SetCustomDataByKey(
324 const std::string &keyPath,
329 const std::string &keyPath)
const;
362 Ts_KnotData* _GetData() {
return _data; }
363 const Ts_KnotData* _GetData()
const {
return _data; }
366 template <
typename T>
367 bool _CheckInParam(T value)
const;
369 template <
typename T>
370 bool _CheckOutParam(T *valueOut)
const;
372 bool _CheckSetWidth(TsTime width)
const;
373 bool _CheckInParamVt(
VtValue value)
const;
374 bool _CheckOutParamVt(
VtValue* value)
const;
382 template <
typename T>
383 Ts_TypedKnotData<Ts_StorageType<T>>* _TypedData()
const;
385 template <
typename T>
386 const Ts_TypedKnotData<Ts_StorageType<T>>* _ConstTypedData()
const;
401 std::unique_ptr<Ts_KnotDataProxy> _proxy;
435 typename = std::enable_if_t<Ts_IsSupportedValueType<T>::value>>
463#define _MAKE_CLAUSE(unused, tuple) \
464 static_assert(std::is_same_v<TF_PP_CAT(TF_PP_CAT(Ts, \
465 TS_SPLINE_VALUE_TYPE_NAME(tuple)), Knot), \
466 TsTypedKnot<TS_SPLINE_VALUE_CPP_TYPE(tuple)>>, \
467 "Incorrect type alias for TsKnot type: " #tuple);
468TF_PP_SEQ_FOR_EACH(_MAKE_CLAUSE, ~, TS_SPLINE_SUPPORTED_VALUE_TYPES)
477bool TsKnot::_CheckInParam(
const T value)
const
479 if constexpr (!Ts_IsSupportedValueType<T>::value)
481 static_assert(Ts_IsSupportedValueType<T>::value,
482 "Cannot pass unsupported type as T-typed knot parameter");
487 if (GetValueType() != Ts_GetType<T>())
490 "Cannot set '%s' value into knot of type '%s'",
491 Ts_GetType<T>().GetTypeName().c_str(),
492 GetValueType().GetTypeName().c_str());
496 if (!Ts_IsFinite(value))
507bool TsKnot::_CheckOutParam(T *valueOut)
const
509 if constexpr (!Ts_IsSupportedValueType<T>::value)
511 static_assert(Ts_IsSupportedValueType<T>::value,
512 "Cannot pass non-floating-point type as T-typed knot parameter");
523 if (GetValueType() != Ts_GetType<T>())
526 "Cannot read from knot of type '%s' into '%s'",
527 GetValueType().GetTypeName().c_str(),
528 Ts_GetType<T>().GetTypeName().c_str());
537Ts_TypedKnotData<Ts_StorageType<T>>*
538TsKnot::_TypedData()
const
540 return static_cast<Ts_TypedKnotData<Ts_StorageType<T>
>*>(_data);
544const Ts_TypedKnotData<Ts_StorageType<T>>*
545TsKnot::_ConstTypedData()
const
547 return static_cast<const Ts_TypedKnotData<Ts_StorageType<T>
>*>(_data);
554bool TsKnot::IsHolding()
const
556 return GetValueType() == Ts_GetType<T>();
560bool TsKnot::SetValue(
const T value)
562 if (!_CheckInParam(value))
567 _TypedData<T>()->value = Ts_StorageType<T>(value);
572bool TsKnot::GetValue(T *valueOut)
const
574 if (!_CheckOutParam(valueOut))
579 *valueOut = _ConstTypedData<T>()->value;
584bool TsKnot::SetPreValue(
const T value)
586 if (!_CheckInParam(value))
591 _data->dualValued =
true;
592 _TypedData<T>()->preValue = Ts_StorageType<T>(value);
597bool TsKnot::GetPreValue(T*
const valueOut)
const
599 if (!_CheckOutParam(valueOut))
604 if (_data->dualValued)
606 *valueOut = _ConstTypedData<T>()->preValue;
610 *valueOut = _ConstTypedData<T>()->value;
620bool TsKnot::SetPreTanSlope(
const T slope)
622 if (!_CheckInParam(slope))
627 _TypedData<T>()->preTanSlope = Ts_StorageType<T>(slope);
632bool TsKnot::GetPreTanSlope(T*
const slopeOut)
const
634 if (!_CheckOutParam(slopeOut))
639 *slopeOut = _ConstTypedData<T>()->GetPreTanSlope();
647bool TsKnot::SetPostTanSlope(
const T slope)
649 if (!_CheckInParam(slope))
654 _TypedData<T>()->postTanSlope = Ts_StorageType<T>(slope);
659bool TsKnot::GetPostTanSlope(T*
const slopeOut)
const
661 if (!_CheckOutParam(slopeOut))
666 *slopeOut = _ConstTypedData<T>()->GetPostTanSlope();
671PXR_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-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 knot-construction convenience.
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.