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;
309 std::string* reason =
nullptr);
347 template <
typename T>
352 template <
typename T>
357 template <
typename T>
362 template <
typename T>
363 bool EvalPreDerivative(
367 template <
typename T>
372 template <
typename T>
373 bool EvalPreValueHeld(
397 template <
typename Vertex>
406 return _Sample(timeInterval, timeScale, valueScale, tolerance,
416 template <
typename Vertex>
425 return _Sample(timeInterval, timeScale, valueScale, tolerance,
434 bool IsEmpty()
const;
437 bool HasValueBlocks()
const;
448 bool HasInnerLoops()
const;
451 bool HasExtrapolatingLoops()
const;
473 std::pair<VtValue, VtValue> *rangeOut)
const;
476 template <
typename T>
479 std::pair<T, T> *rangeOut)
const;
486 bool HasValueBlockAtTime(
492 TsTime startTime)
const;
497 TsTime startTime)
const;
511 template <
typename HashState>
512 friend void TfHashAppend(
516 h.Append(spline._data.get());
523 void _SetKnotUnchecked(
const TsKnot & knot);
525 template <
typename SampleHolder>
531 SampleHolder* splineSamples)
const;
534 friend Ts_SplineData* Ts_GetSplineData(
TsSpline &spline);
535 friend const Ts_SplineData* Ts_GetSplineData(
const TsSpline &spline);
537 friend struct Ts_BinaryDataAccess;
538 friend struct Ts_SplineOffsetAccess;
543 const Ts_SplineData* _GetData()
const;
550 template <
typename T>
554 Ts_EvalAspect aspect,
555 Ts_EvalLocation location)
const;
562 bool _UpdateAllTangents();
567 bool _UpdateKnotTangents(
const size_t knotIndex);
574 std::shared_ptr<Ts_SplineData> _data;
589struct Ts_SplineOffsetAccess
592 static void ApplyOffsetAndScale(
603bool TsSpline::IsHolding()
const
605 if constexpr (!Ts_IsSupportedValueType<T>::value)
610 return GetValueType() == Ts_GetType<T>();
617 const Ts_EvalAspect aspect,
618 const Ts_EvalLocation location)
const
620 const std::optional<double> result =
621 Ts_Eval(_GetData(), time, aspect, location);
628 *valueOut = T(*result);
640 const Ts_EvalAspect aspect,
641 const Ts_EvalLocation location)
const;
644bool TsSpline::Eval(
const TsTime time, T*
const valueOut)
const
646 return _Eval(time, valueOut, Ts_EvalValue, Ts_EvalAtTime);
650bool TsSpline::EvalPreValue(
const TsTime time, T*
const valueOut)
const
652 return _Eval(time, valueOut, Ts_EvalValue, Ts_EvalPre);
656bool TsSpline::EvalDerivative(
const TsTime time, T*
const valueOut)
const
658 return _Eval(time, valueOut, Ts_EvalDerivative, Ts_EvalAtTime);
662bool TsSpline::EvalPreDerivative(
const TsTime time, T*
const valueOut)
const
664 return _Eval(time, valueOut, Ts_EvalDerivative, Ts_EvalPre);
668bool TsSpline::EvalHeld(
const TsTime time, T*
const valueOut)
const
670 return _Eval(time, valueOut, Ts_EvalHeldValue, Ts_EvalAtTime);
674bool TsSpline::EvalPreValueHeld(
const TsTime time, T*
const valueOut)
const
676 return _Eval(time, valueOut, Ts_EvalHeldValue, Ts_EvalPre);
680PXR_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 bool CanBreakdown(TsTime time, std::string *reason=nullptr)
Test if a knot could be inserted by Breakdown at time.
TS_API bool IsG1Continuous() const
Not yet implemented.
TS_API TsKnotMap GetKnots() const
Returns the spline's knots.
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.
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 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 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.
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 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.
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...
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].