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/keyFrame.h"
14#include "pxr/base/ts/keyFrameMap.h"
15#include "pxr/base/ts/types.h"
16#include "pxr/base/ts/loopParams.h"
17#include "pxr/base/vt/value.h"
26PXR_NAMESPACE_OPEN_SCOPE
65 TsExtrapolationType leftExtrapolation = TsExtrapolationHeld,
66 TsExtrapolationType rightExtrapolation = TsExtrapolationHeld,
67 const TsLoopParams &loopParams = TsLoopParams());
72 explicit TsSpline(
const std::vector<TsKeyFrame> & keyFrames,
73 TsExtrapolationType leftExtrapolation = TsExtrapolationHeld,
74 TsExtrapolationType rightExtrapolation = TsExtrapolationHeld,
75 const TsLoopParams &loopParams = TsLoopParams());
109 -std::numeric_limits<double>::infinity(),
110 std::numeric_limits<double>::infinity())));
136 std::vector<TsKeyFrame>
156 const TsKeyFrame & kf, std::string *reason=
nullptr )
const;
176 std::optional<TsKeyFrame>
178 bool flatTangents,
double tangentLength,
200 Breakdown(
const std::set<double> & times, TsKnotType type,
201 bool flatTangents,
double tangentLength,
217 Breakdown(
const std::vector<double> & times, TsKnotType type,
218 bool flatTangents,
double tangentLength,
219 const std::vector<VtValue> & values,
238 const std::vector<TsKnotType> & types,
239 bool flatTangents,
double tangentLength,
240 const std::vector<VtValue> & values,
248 TsTime time,
GfInterval *intervalAffected=
nullptr);
259 std::optional<TsKeyFrame>
265 std::optional<TsKeyFrame>
271 std::optional<TsKeyFrame>
351 TsExtrapolationType left, TsExtrapolationType right);
356 std::pair<TsExtrapolationType, TsExtrapolationType>
362 const std::type_info &
380 TsTime time, TsSide side=TsRight )
const;
394 TsTime time, TsSide side=TsRight )
const;
430 TsTime startTime, TsTime endTime,
431 double timeScale,
double valueScale,
432 double tolerance )
const;
435 std::pair<VtValue, VtValue>
436 GetRange( TsTime startTime, TsTime endTime )
const;
459 void BakeSplineLoops();
470 typedef TsKeyFrameMap::const_reverse_iterator const_reverse_iterator;
476 typedef const_reverse_iterator reverse_iterator;
521 const_reverse_iterator
rend()
const {
544 size_t count(
const TsTime &t)
const {
552 void _BreakdownMultipleValues(
const std::vector<double> ×,
553 TsKnotType type,
bool flatTangents,
double tangentLength,
554 const std::vector<VtValue> &values,
558 void _BreakdownMultipleKnotTypes(
const std::vector<double> ×,
559 const std::vector<TsKnotType> &types,
560 bool flatTangents,
double tangentLength,
561 const std::vector<VtValue> &values,
569 _GetBreakdown(
TsKeyFrameMap* newKeyframes,
double x, TsKnotType type,
570 bool flatTangents,
double tangentLength,
573 typedef std::vector<std::pair<TsTime, VtValue>> _Samples;
577 void _BreakdownSamples(
578 const _Samples &samples,
581 double tangentLength,
587 bool _IsVarying(
double tolerance)
const;
594 std::shared_ptr<TsSpline_KeyFrames> _data;
600PXR_NAMESPACE_CLOSE_SCOPE
A basic mathematical interval class.
GfMultiInterval represents a subset of the real number line as an ordered set of non-intersecting GfI...
TfType represents a dynamic runtime type.
Specifies the value of an TsSpline object at a particular point in time.
An ordered sequence of keyframes with STL-compliant API for finding, inserting, and erasing keyframes...
Maintains the keyframes for a spline.
Represents a spline value object.
TS_API const_iterator lower_bound(const TsTime &t) const
Returns a const_iterator to the first KeyFrame with a time that is not less than t.
TS_API bool DoSidesDiffer(TsTime time) const
Returns whether the left-side value and the right-side value at the specified time are different.
TS_API bool IsTimeLooped(TsTime time) const
Is the given time in the "unrolled" region of a spline that is looping; i.e.
TS_API std::string GetTypeName() const
Returns the typename of the value type for keyframes in this spline, If no keyframes have been set,...
TS_API std::optional< TsKeyFrame > GetClosestKeyFrame(TsTime targetTime) const
Finds the keyframe closest to the given time.
TS_API void Breakdown(const std::vector< double > ×, const std::vector< TsKnotType > &types, bool flatTangents, double tangentLength, const std::vector< VtValue > &values, GfInterval *intervalAffected=nullptr, TsKeyFrameMap *keyFramesAtTimes=nullptr)
Breaks down simultaneously at several times with knot types specified for each time.
TS_API VtValue EvalDerivative(TsTime time, TsSide side=TsRight) const
Evaluates the derivative of the spline at the given time, interpolating the keyframes.
TS_API size_t count(const TsTime &t) const
Returns the number (either 0 or 1) of KeyFrames with time t.
TS_API TsSpline(const std::vector< TsKeyFrame > &keyFrames, TsExtrapolationType leftExtrapolation=TsExtrapolationHeld, TsExtrapolationType rightExtrapolation=TsExtrapolationHeld, const TsLoopParams &loopParams=TsLoopParams())
Constructs a spline with the key frames keyFrames, and optionally given extrapolation and looping par...
TS_API const_iterator begin() const
Return a const_iterator pointing to the beginning of the spline.
TS_API TsLoopParams GetLoopParams() const
Return an object describing all the looping parameters for this spline.
TS_API bool ClearRedundantKeyFrames(const VtValue &defaultValue=VtValue(), const GfMultiInterval &intervals=GfMultiInterval(GfInterval(-std::numeric_limits< double >::infinity(), std::numeric_limits< double >::infinity())))
Removes redundant keyframes from the spline in the specified multi-interval.
TS_API void RemoveKeyFrame(TsTime time, GfInterval *intervalAffected=nullptr)
Removes the keyframe at the given time, optionally returning the time range affected.
TS_API TfType GetType() const
Returns the TfType of the value type for keyframes in this spline.
TS_API bool IsLinear() const
Returns whether spline represents a simple linear relationship.
TS_API TsSamples Sample(TsTime startTime, TsTime endTime, double timeScale, double valueScale, double tolerance) const
Evaluates the value of the spline over the given time interval.
TS_API bool CanSetKeyFrame(const TsKeyFrame &kf, std::string *reason=nullptr) const
Checks if the given keyframe is a valid candidate to set, optionally returning the reason if it canno...
TS_API void SetKeyFrame(TsKeyFrame kf, GfInterval *intervalAffected=nullptr)
Sets a keyframe, optionally returning the time range affected.
TS_API const_iterator upper_bound(const TsTime &t) const
Returns a const_iterator to the first KeyFrame with a time that is greater than t.
TS_API std::optional< TsKeyFrame > GetClosestKeyFrameAfter(TsTime targetTime) const
Finds the closest keyframe after the given time.
TS_API std::optional< TsKeyFrame > Breakdown(double x, TsKnotType type, bool flatTangents, double tangentLength, const VtValue &value=VtValue(), GfInterval *intervalAffected=nullptr)
Breakdown at time x.
TS_API GfInterval GetFrameRange() const
Returns the minimum and maximum keyframe frames in the spline.
TS_API VtValue EvalHeld(TsTime time, TsSide side=TsRight) const
Evaluates the value of the spline at the given time without any interpolation, as if all keyframes an...
TS_API bool KeyFrameIsInLoopedRange(const TsKeyFrame &kf)
Returns whether the given key frame is in the looped interval, but not in the master interval.
TS_API void Breakdown(const std::vector< double > ×, TsKnotType type, bool flatTangents, double tangentLength, const std::vector< VtValue > &values, GfInterval *intervalAffected=nullptr, TsKeyFrameMap *keyFramesAtTimes=nullptr)
Breaks down simultaneously at several times.
TS_API bool IsEmpty() const
Returns whether there are any keyframes.
TS_API const_iterator find(const TsTime &t) const
Returns a const_iterator to the KeyFrame at time t.
TS_API bool IsSegmentValueMonotonic(const TsKeyFrame &kf1, const TsKeyFrame &kf2) const
Returns true if the segment between the given (adjacent) key frames is monotonic (i....
TS_API const TsKeyFrameMap & GetKeyFrames() const
Returns the keyframes in this spline.
TS_API bool empty() const
Return true if this spline has no KeyFrames.
TS_API const_iterator end() const
Returns a const_iterator pointing to the end of the spline.
TS_API std::vector< TsKeyFrame > GetKeyFramesInMultiInterval(const GfMultiInterval &) const
Returns the keyframes contained in the given GfMultiInterval.
TS_API TsSpline(const TsKeyFrameMap &keyFrames, TsExtrapolationType leftExtrapolation=TsExtrapolationHeld, TsExtrapolationType rightExtrapolation=TsExtrapolationHeld, const TsLoopParams &loopParams=TsLoopParams())
Constructs a spline with the key frames keyFrames, and optionally given extrapolation and looping par...
TS_API const_reverse_iterator rbegin() const
Return a const_reverse_iterator pointing to the end of the spline.
TS_API bool IsVaryingSignificantly() const
Like IsVarying(), but for splines of type double, allows tiny value differences.
TS_API const std::type_info & GetTypeid() const
Returns the typeid of the value type for keyframes in this spline.
TS_API bool IsKeyFrameRedundant(TsTime keyFrameTime, const VtValue &defaultValue=VtValue()) const
Returns true if the key frame at the given time is redundant.
TS_API const TsKeyFrameMap & GetRawKeyFrames() const
Returns the "raw" keyframes in this spline whether or not this spline is looping.
TS_API bool operator==(const TsSpline &rhs) const
Equality operator.
TS_API void SetExtrapolation(TsExtrapolationType left, TsExtrapolationType right)
Sets the spline's extrapolation type on each side.
TS_API bool IsKeyFrameRedundant(const TsKeyFrame &keyFrame, const VtValue &defaultValue=VtValue()) const
Returns true if the given key frame is redundant.
TS_API bool IsSegmentFlat(const TsKeyFrame &kf1, const TsKeyFrame &kf2) const
Returns true if the segment between the given (adjacent) key frames is flat.
TS_API TsSpline()
Constructs a spline with no key frames and held extrapolation.
TS_API bool IsSegmentValueMonotonic(TsTime startTime, TsTime endTime) const
Returns true if the segment between the given (adjacent) key frames is monotonic (i....
TS_API bool HasRedundantKeyFrames(const VtValue &defaultValue=VtValue()) const
Returns true if any of this spline's key frames are redundant.
const_iterator iterator
Some utilities (such as TfIterator) expect a class named 'iterator'.
TS_API bool operator!=(const TsSpline &rhs) const
Inequality operator.
TS_API void SwapKeyFrames(std::vector< TsKeyFrame > *swapInto)
Replaces the KeyFrames in this TsSpline with those in swapInto, and puts the KeyFrames in this TsSpli...
TS_API bool IsVarying() const
Returns true if the value of the spline changes over time, whether due to differing values among keyf...
TS_API void SetLoopParams(const TsLoopParams &)
Set the looping parameters for this spline.
TS_API bool IsSegmentFlat(TsTime startTime, TsTime endTime) const
Returns true if the segment between the given (adjacent) key frames is flat.
TS_API VtValue Eval(TsTime time, TsSide side=TsRight) const
Evaluates the value of the spline at the given time, interpolating the keyframes.
TS_API size_t size() const
\group Container API
TS_API std::pair< TsExtrapolationType, TsExtrapolationType > GetExtrapolation() const
Returns the spline's extrapolation type on each side (first is the left side).
TS_API const_reverse_iterator rend() const
Returns a const_reverse_iterator pointing to the beginning of the spline.
TS_API void Clear()
Removes all keyframes.
TS_API std::optional< TsKeyFrame > GetClosestKeyFrameBefore(TsTime targetTime) const
Finds the closest keyframe before the given time.
TS_API void Breakdown(const std::set< double > ×, TsKnotType type, bool flatTangents, double tangentLength, const VtValue &value=VtValue(), GfInterval *intervalAffected=nullptr, TsKeyFrameMap *keyFramesAtTimes=nullptr)
Breaks down simultaneously at several times.
TS_API TsSpline(const TsSpline &other)
Copy construct.
TsKeyFrameMap::const_iterator const_iterator
Our iterators are simply iterators into the contained TsKeyFrameMap We only expose const iterators be...
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].