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"
20#include "pxr/base/vt/value.h"
22#include "pxr/base/tf/type.h"
28PXR_NAMESPACE_OPEN_SCOPE
86 bool operator==(
const TsSpline &other)
const;
89 bool operator!=(
const TsSpline &other)
const;
96 static bool IsSupportedValueType(
TfType valueType);
99 TfType GetValueType()
const;
101 template <
typename T>
102 bool IsHolding()
const;
114 void SetCurveType(TsCurveType curveType);
117 TsCurveType GetCurveType()
const;
155 bool IsPreExtrapolationValid()
const;
165 bool IsPostExtrapolationValid()
const;
188 [[deprecated(
"TsSpline inner looping is deprecated")]]
190 void SetInnerLoopParams(
191 const Ts_LoopParams ¶ms);
193 [[deprecated(
"TsSpline inner looping is deprecated")]]
195 Ts_LoopParams GetInnerLoopParams()
const;
209 std::string *reasonOut =
nullptr)
const;
275 [[deprecated(
"TsSpline inner looping is deprecated")]]
289 [[deprecated(
"TsSpline inner looping is deprecated")]]
357 std::string* reason =
nullptr);
395 template <
typename T>
400 template <
typename T>
405 template <
typename T>
410 template <
typename T>
411 bool EvalPreDerivative(
415 template <
typename T>
420 template <
typename T>
421 bool EvalPreValueHeld(
448 template <
typename Vertex>
457 return _Sample(timeInterval, timeScale, valueScale, tolerance,
467 template <
typename Vertex>
476 return _Sample(timeInterval, timeScale, valueScale, tolerance,
632 bool IsEmpty()
const;
635 bool HasValueBlocks()
const;
647 [[deprecated(
"TsSpline inner looping is deprecated")]]
652 bool HasExtrapolatingLoops()
const;
674 std::pair<VtValue, VtValue> *rangeOut)
const;
677 template <
typename T>
680 std::pair<T, T> *rangeOut)
const;
687 bool HasValueBlockAtTime(
693 TsTime startTime)
const;
698 TsTime startTime)
const;
712 template <
typename HashState>
713 friend void TfHashAppend(
717 h.Append(spline._data.get());
735 void _SetInnerLoopParams(
736 const Ts_LoopParams ¶ms);
739 Ts_LoopParams _GetInnerLoopParams()
const;
742 bool _BakeInnerLoops();
745 TsKnotMap _GetKnotsWithInnerLoopsBaked()
const;
748 bool _HasInnerLoops()
const;
756 void _SetKnotUnchecked(
const TsKnot & knot);
758 template <
typename SampleHolder>
764 SampleHolder* splineSamples)
const;
767 friend Ts_SplineData* Ts_GetSplineData(
TsSpline &spline);
768 friend const Ts_SplineData* Ts_GetSplineData(
const TsSpline &spline);
770 friend struct Ts_BinaryDataAccess;
771 friend struct Ts_SplineOffsetAccess;
781 const Ts_SplineData* _GetData()
const;
788 template <
typename T>
792 Ts_EvalAspect aspect,
793 Ts_EvalLocation location)
const;
800 bool _UpdateAllTangents();
805 bool _UpdateKnotTangents(
const size_t knotIndex);
812 std::shared_ptr<Ts_SplineData> _data;
820std::ostream& operator<<(std::ostream& out,
const TsSpline &spline);
830struct Ts_SplineOffsetAccess
833 static void ApplyOffsetAndScale(
844bool TsSpline::IsHolding()
const
846 if constexpr (!Ts_IsSupportedValueType<T>::value)
851 return GetValueType() == Ts_GetType<T>();
858 const Ts_EvalAspect aspect,
859 const Ts_EvalLocation location)
const
861 const std::optional<double> result =
862 Ts_Eval(_GetData(), time, aspect, location);
869 *valueOut = T(*result);
881 const Ts_EvalAspect aspect,
882 const Ts_EvalLocation location)
const;
885bool TsSpline::Eval(
const TsTime time, T*
const valueOut)
const
887 return _Eval(time, valueOut, Ts_EvalValue, Ts_EvalAtTime);
891bool TsSpline::EvalPreValue(
const TsTime time, T*
const valueOut)
const
893 return _Eval(time, valueOut, Ts_EvalValue, Ts_EvalPre);
897bool TsSpline::EvalDerivative(
const TsTime time, T*
const valueOut)
const
899 return _Eval(time, valueOut, Ts_EvalDerivative, Ts_EvalAtTime);
903bool TsSpline::EvalPreDerivative(
const TsTime time, T*
const valueOut)
const
905 return _Eval(time, valueOut, Ts_EvalDerivative, Ts_EvalPre);
909bool TsSpline::EvalHeld(
const TsTime time, T*
const valueOut)
const
911 return _Eval(time, valueOut, Ts_EvalHeldValue, Ts_EvalAtTime);
915bool TsSpline::EvalPreValueHeld(
const TsTime time, T*
const valueOut)
const
917 return _Eval(time, valueOut, Ts_EvalHeldValue, Ts_EvalPre);
921PXR_NAMESPACE_CLOSE_SCOPE
#define VT_VALUE_TYPE_CAN_TRANSFORM(T)
A helper for specializing the above trait.
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 bool CanBreakdown(TsTime time, std::string *reason=nullptr)
Test if a knot could be inserted by Breakdown at time.
TS_API TsSpline GetTruncated(const GfInterval &interval, TsExtrapolation preFallback=TsExtrapolation(TsExtrapValueBlock), TsExtrapolation postFallback=TsExtrapolation(TsExtrapValueBlock)) const
Returns a new spline resulting from truncation of the given spline to the given interval.
TS_API bool IsG1Continuous() const
Not yet implemented.
TS_API TsKnotMap GetKnots() const
Returns the spline's knots.
TS_API GfInterval Diff(const TsSpline &other, const GfInterval &compareInterval) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
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.
TS_API TsKnotMap GetKnotsWithInnerLoopsBaked() const
Return all the knots on the spline, including knots generated by inner looping.
bool GetValueRange(const GfInterval &timeSpan, std::pair< T, T > *rangeOut) const
Not yet implemented.
static TS_API TsSpline Concatenate(const std::vector< TsSpline > &splines)
Returns a spline resulting from the concatenation of the given splines.
TS_API TsKnotMap GetKnots(const GfInterval &timeInterval) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
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 GfInterval Diff(const TsSpline &other) const
Compare two splines.
TS_API TsSpline GetTimeScaled(double timeScale, double timeOffset) const
Returns a new spline resulting from time scaling the knots of a given spline, applying first the scal...
TS_API void SetPreExtrapolation(const TsExtrapolation &extrap)
Sets pre extrapolation.
TS_API bool ClearRedundantKnots(VtValue defaultValue=VtValue(), const GfInterval &interval=GfInterval::GetFullInterval())
Not yet implemented.
bool Sample(const GfInterval &timeInterval, double timeScale, double valueScale, double tolerance, TsSplineSamples< Vertex > *splineSamples) const
Evaluates the value of the TsSpline over the given time interval, typically for drawing.
TS_API bool IsSegmentMonotonic(TsTime startTime) const
Not yet implemented.
TS_API bool HasInnerLoops() const
TS_API TsKnotMap GetKnotsWithLoopsBaked(const GfInterval &interval) const
Return baked knots that will replicate this spline over the given time interval without any looping.
TS_API void RemoveKnot(TsTime time, GfInterval *affectedIntervalOut=nullptr)
Incompletely implemented; affectedIntervalOut is not yet populated.
TS_API bool IsTimeValued() const
Convenience function that returns true if the value type of the spline is GfTimeCode or GfDuration.
bool Sample(const GfInterval &timeInterval, double timeScale, double valueScale, double tolerance, TsSplineSamplesWithSources< Vertex > *splineSamples) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
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 Breakdown(TsTime time, GfInterval *affectedIntervalOut=nullptr)
Add a knot at the specified time.
TS_API bool HasLoops() const
Convenience for HasInnerLoops() || HasExtrapolatingLoops().
TS_API void SetKnots(const TsKnotMap &knots)
Clears existing knots and sets the given knots.
TS_API bool HasRegressiveTangents() const
Returns whether this spline has any tangents long enough to cause regression; or, if the current auth...
TS_API void SetPostExtrapolation(const TsExtrapolation &extrap)
Sets post extrapolation.
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.
static TS_API TsAntiRegressionMode GetAntiRegressionAuthoringMode()
Returns the current effective anti-regression authoring mode.
TS_API bool BakeInnerLoops()
Bake inner loops in the spline.
TS_API bool IsC0Continuous() const
Not yet implemented.
TsSplineSamples<Vertex> holds a collection of piecewise linear polylines that approximate a TsSpline.
TsSplineSamplesWithSources<Vertex> is a TsSplineSamples<Vertex> that also includes source information...
A map with string keys and VtValue values.
Provides a container which may hold any type, and provides introspection and iteration over array typ...