8#ifndef PXR_BASE_TS_SPLINE_H
9#define PXR_BASE_TS_SPLINE_H
12#include "pxr/base/ts/api.h"
13#include "pxr/base/ts/splineData.h"
14#include "pxr/base/ts/knotMap.h"
15#include "pxr/base/ts/knot.h"
16#include "pxr/base/ts/types.h"
17#include "pxr/base/ts/typeHelpers.h"
18#include "pxr/base/ts/eval.h"
19#include "pxr/base/vt/value.h"
21#include "pxr/base/tf/type.h"
27PXR_NAMESPACE_OPEN_SCOPE
85 bool operator==(
const TsSpline &other)
const;
88 bool operator!=(
const TsSpline &other)
const;
95 static bool IsSupportedValueType(
TfType valueType);
98 TfType GetValueType()
const;
100 template <
typename T>
101 bool IsHolding()
const;
104 void SetTimeValued(
bool timeValued);
107 bool IsTimeValued()
const;
114 void SetCurveType(TsCurveType curveType);
117 TsCurveType GetCurveType()
const;
124 void SetPreExtrapolation(
131 void SetPostExtrapolation(
157 void SetInnerLoopParams(
174 std::string *reasonOut =
nullptr)
const;
289 template <
typename T>
294 template <
typename T>
299 template <
typename T>
304 template <
typename T>
305 bool EvalPreDerivative(
309 template <
typename T>
314 template <
typename T>
315 bool EvalPreValueHeld(
328 bool IsEmpty()
const;
331 bool HasValueBlocks()
const;
342 bool HasInnerLoops()
const;
345 bool HasExtrapolatingLoops()
const;
367 std::pair<VtValue, VtValue> *rangeOut)
const;
370 template <
typename T>
373 std::pair<T, T> *rangeOut)
const;
380 bool HasValueBlockAtTime(
386 TsTime startTime)
const;
391 TsTime startTime)
const;
405 template <
typename HashState>
406 friend void TfHashAppend(
410 h.Append(spline._data.get());
415 void _SetKnotUnchecked(
const TsKnot & knot);
418 friend Ts_SplineData* Ts_GetSplineData(
TsSpline &spline);
419 friend const Ts_SplineData* Ts_GetSplineData(
const TsSpline &spline);
421 friend struct Ts_BinaryDataAccess;
422 friend struct Ts_SplineOffsetAccess;
427 const Ts_SplineData* _GetData()
const;
434 template <
typename T>
438 Ts_EvalAspect aspect,
439 Ts_EvalLocation location)
const;
446 std::shared_ptr<Ts_SplineData> _data;
461struct Ts_SplineOffsetAccess
464 static void ApplyOffsetAndScale(
475bool TsSpline::IsHolding()
const
477 if constexpr (!Ts_IsSupportedValueType<T>::value)
482 return GetValueType() == Ts_GetType<T>();
489 const Ts_EvalAspect aspect,
490 const Ts_EvalLocation location)
const
492 const std::optional<double> result =
493 Ts_Eval(_GetData(), time, aspect, location);
500 *valueOut = T(*result);
505bool TsSpline::Eval(
const TsTime time, T*
const valueOut)
const
507 return _Eval(time, valueOut, Ts_EvalValue, Ts_EvalAtTime);
511bool TsSpline::EvalPreValue(
const TsTime time, T*
const valueOut)
const
513 return _Eval(time, valueOut, Ts_EvalValue, Ts_EvalPre);
517bool TsSpline::EvalDerivative(
const TsTime time, T*
const valueOut)
const
519 return _Eval(time, valueOut, Ts_EvalDerivative, Ts_EvalAtTime);
523bool TsSpline::EvalPreDerivative(
const TsTime time, T*
const valueOut)
const
525 return _Eval(time, valueOut, Ts_EvalDerivative, Ts_EvalPre);
529bool TsSpline::EvalHeld(
const TsTime time, T*
const valueOut)
const
531 return _Eval(time, valueOut, Ts_EvalHeldValue, Ts_EvalAtTime);
535bool TsSpline::EvalPreValueHeld(
const TsTime time, T*
const valueOut)
const
537 return _Eval(time, valueOut, Ts_EvalHeldValue, Ts_EvalPre);
541PXR_NAMESPACE_CLOSE_SCOPE
A basic mathematical interval class.
static GfInterval GetFullInterval()
Returns the full interval (-inf, inf).
TfType represents a dynamic runtime type.
A knot belonging to a TsSpline.
An authoring helper class that enforces non-regression in splines.
A mathematical description of a curved function from time to value.
TS_API const TsKnotMap & GetKnotsWithInnerLoopsBaked() const
Not yet implemented.
TS_API bool IsG1Continuous() const
Not yet implemented.
TS_API TsKnotMap GetKnots() const
Returns the spline's knots.
TS_API bool Split(TsTime time, GfInterval *affectedIntervalOut=nullptr)
Not yet implemented.
TS_API bool IsLinear() const
Not yet implemented.
TS_API bool SetKnot(const TsKnot &knot, GfInterval *affectedIntervalOut=nullptr)
Incompletely implemented; affectedIntervalOut is not yet populated.
bool GetValueRange(const GfInterval &timeSpan, std::pair< T, T > *rangeOut) const
Not yet implemented.
TS_API bool GetValueRange(const GfInterval &timeSpan, std::pair< VtValue, VtValue > *rangeOut) const
Not yet implemented.
TS_API bool IsC1Continuous() const
Not yet implemented.
TS_API TsSpline(TfType valueType)
Creates a spline with a specified value type.
TS_API bool ClearRedundantKnots(VtValue defaultValue=VtValue(), const GfInterval &interval=GfInterval::GetFullInterval())
Not yet implemented.
TS_API bool IsSegmentMonotonic(TsTime startTime) const
Not yet implemented.
TS_API void RemoveKnot(TsTime time, GfInterval *affectedIntervalOut=nullptr)
Incompletely implemented; affectedIntervalOut is not yet populated.
TS_API TsSpline()
Default constructor creates a spline without a value type.
TS_API bool AdjustRegressiveTangents()
Shorten any regressive tangents; or, if the current authoring mode is Contain, any tangents that exce...
TS_API bool HasLoops() const
Convenience for HasInnerLoops() || HasExtrapolatingLoops().
TS_API bool HasRegressiveTangents() const
Returns whether this spline has any tangents long enough to cause regression; or, if the current auth...
TS_API bool IsSegmentFlat(TsTime startTime) const
Not yet implemented.
TS_API bool IsVarying() const
Not yet implemented.
TS_API bool GetKnot(TsTime time, TsKnot *knotOut) const
Retrieves a copy of the knot at the specified time, if one exists.
TS_API bool IsKnotRedundant(TsTime time, VtValue defaultValue=VtValue()) const
Not yet implemented.
TS_API const TsKnotMap & GetKnotsWithLoopsBaked(const GfInterval &interval) const
Not yet implemented.
static TS_API TsAntiRegressionMode GetAntiRegressionAuthoringMode()
Returns the current effective anti-regression authoring mode.
TS_API bool BakeLoops(const GfInterval &interval)
Not yet implemented.
TS_API bool IsC0Continuous() const
Not yet implemented.
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].