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"
21#include "pxr/base/tf/preprocessorUtilsLite.h"
22#include "pxr/base/tf/type.h"
30PXR_NAMESPACE_OPEN_SCOPE
72 TsCurveType curveType);
90 bool operator==(
const TsKnot &other)
const;
93 bool operator!=(
const TsKnot &other)
const;
104 TsTime GetTime()
const;
115 TsInterpMode GetNextInterpolation()
const;
122 TfType GetValueType()
const;
124 template <
typename T>
125 bool IsHolding()
const;
131 template <
typename T>
139 template <
typename T>
148 bool IsDualValued()
const;
154 template <
typename T>
162 template <
typename T>
167 bool ClearPreValue();
180 bool SetCurveType(TsCurveType curveType);
183 TsCurveType GetCurveType()
const;
199 bool SetPreTanWidth(TsTime width);
202 TsTime GetPreTanWidth()
const;
205 bool SetPreTanSlope(
VtValue slope);
207 template <
typename T>
208 bool SetPreTanSlope(T slope);
211 bool GetPreTanSlope(
VtValue *slopeOut)
const;
213 template <
typename T>
214 bool GetPreTanSlope(T *slopeOut)
const;
236 bool SetPostTanWidth(TsTime width);
239 TsTime GetPostTanWidth()
const;
242 bool SetPostTanSlope(
VtValue slope);
244 template <
typename T>
245 bool SetPostTanSlope(T slope);
248 bool GetPostTanSlope(
VtValue *slopeOut)
const;
250 template <
typename T>
251 bool GetPostTanSlope(T *slopeOut)
const;
296 const std::optional<TsKnot> nextKnot,
297 TsCurveType curveType = TsCurveTypeBezier);
322 bool SetCustomDataByKey(
323 const std::string &keyPath,
328 const std::string &keyPath)
const;
361 Ts_KnotData* _GetData() {
return _data; }
362 const Ts_KnotData* _GetData()
const {
return _data; }
365 template <
typename T>
366 bool _CheckInParam(T value)
const;
368 template <
typename T>
369 bool _CheckOutParam(T *valueOut)
const;
371 bool _CheckSetWidth(TsTime width)
const;
372 bool _CheckInParamVt(
VtValue value)
const;
373 bool _CheckOutParamVt(
VtValue* value)
const;
381 template <
typename T>
382 Ts_TypedKnotData<Ts_StorageType<T>>* _TypedData()
const;
384 template <
typename T>
385 const Ts_TypedKnotData<Ts_StorageType<T>>* _ConstTypedData()
const;
400 std::unique_ptr<Ts_KnotDataProxy> _proxy;
432 typename = std::enable_if_t<Ts_IsSupportedValueType<T>::value>>
456#define _MAKE_CLAUSE(unused, tuple) \
457 static_assert(std::is_same_v<TF_PP_CAT(TF_PP_CAT(Ts, \
458 TS_SPLINE_VALUE_TYPE_NAME(tuple)), Knot), \
459 TsTypedKnot<TS_SPLINE_VALUE_CPP_TYPE(tuple)>>, \
460 "Incorrect type alias for TsKnot type: " #tuple);
461TF_PP_SEQ_FOR_EACH(_MAKE_CLAUSE, ~, TS_SPLINE_SUPPORTED_VALUE_TYPES)
470bool TsKnot::_CheckInParam(
const T value)
const
472 if constexpr (!Ts_IsSupportedValueType<T>::value)
474 static_assert(Ts_IsSupportedValueType<T>::value,
475 "Cannot pass unsupported type as T-typed knot parameter");
480 if (GetValueType() != Ts_GetType<T>())
483 "Cannot set '%s' value into knot of type '%s'",
484 Ts_GetType<T>().GetTypeName().c_str(),
485 GetValueType().GetTypeName().c_str());
489 if (!Ts_IsFinite(value))
500bool TsKnot::_CheckOutParam(T *valueOut)
const
502 if constexpr (!Ts_IsSupportedValueType<T>::value)
504 static_assert(Ts_IsSupportedValueType<T>::value,
505 "Cannot pass non-floating-point type as T-typed knot parameter");
516 if (GetValueType() != Ts_GetType<T>())
519 "Cannot read from knot of type '%s' into '%s'",
520 GetValueType().GetTypeName().c_str(),
521 Ts_GetType<T>().GetTypeName().c_str());
530Ts_TypedKnotData<Ts_StorageType<T>>*
531TsKnot::_TypedData()
const
533 return static_cast<Ts_TypedKnotData<Ts_StorageType<T>
>*>(_data);
537const Ts_TypedKnotData<Ts_StorageType<T>>*
538TsKnot::_ConstTypedData()
const
540 return static_cast<const Ts_TypedKnotData<Ts_StorageType<T>
>*>(_data);
547bool TsKnot::IsHolding()
const
549 return GetValueType() == Ts_GetType<T>();
553bool TsKnot::SetValue(
const T value)
555 if (!_CheckInParam(value))
560 _TypedData<T>()->value = Ts_StorageType<T>(value);
565bool TsKnot::GetValue(T *valueOut)
const
567 if (!_CheckOutParam(valueOut))
572 *valueOut = _ConstTypedData<T>()->value;
577bool TsKnot::SetPreValue(
const T value)
579 if (!_CheckInParam(value))
584 _data->dualValued =
true;
585 _TypedData<T>()->preValue = Ts_StorageType<T>(value);
590bool TsKnot::GetPreValue(T*
const valueOut)
const
592 if (!_CheckOutParam(valueOut))
597 if (_data->dualValued)
599 *valueOut = _ConstTypedData<T>()->preValue;
603 *valueOut = _ConstTypedData<T>()->value;
613bool TsKnot::SetPreTanSlope(
const T slope)
615 if (!_CheckInParam(slope))
620 _TypedData<T>()->preTanSlope = Ts_StorageType<T>(slope);
625bool TsKnot::GetPreTanSlope(T*
const slopeOut)
const
627 if (!_CheckOutParam(slopeOut))
632 *slopeOut = _ConstTypedData<T>()->GetPreTanSlope();
640bool TsKnot::SetPostTanSlope(
const T slope)
642 if (!_CheckInParam(slope))
647 _TypedData<T>()->postTanSlope = Ts_StorageType<T>(slope);
652bool TsKnot::GetPostTanSlope(T*
const slopeOut)
const
654 if (!_CheckOutParam(slopeOut))
659 *slopeOut = _ConstTypedData<T>()->GetPostTanSlope();
664PXR_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 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.