|
HDK
|
#include <spline.h>
Public Member Functions | |
| template<> | |
| TS_API bool | _Eval (const TsTime time, VtValue *const valueOut, const Ts_EvalAspect aspect, const Ts_EvalLocation location) const |
Construction and value semantics | |
This is a lightweight class that wraps a shared pointer. It is intended to be used as a value type, and copied freely. Move semantics are not implemented; there would be no benefit. | |
| TS_API | TsSpline () |
| TS_API | TsSpline (TfType valueType) |
| Creates a spline with a specified value type. More... | |
| TS_API | TsSpline (const TsSpline &other) |
| TS_API TsSpline & | operator= (const TsSpline &other) |
| TS_API bool | operator== (const TsSpline &other) const |
| TS_API bool | operator!= (const TsSpline &other) const |
Curve types | |
| TS_API void | SetCurveType (TsCurveType curveType) |
| TS_API TsCurveType | GetCurveType () const |
Extrapolation | |
| TS_API void | SetPreExtrapolation (const TsExtrapolation &extrap) |
| TS_API TsExtrapolation | GetPreExtrapolation () const |
| TS_API void | SetPostExtrapolation (const TsExtrapolation &extrap) |
| TS_API TsExtrapolation | GetPostExtrapolation () const |
Inner loops | |
Loop params are only valid when all of the following are true:
Any loop params may be set, and will be stored. Whenever the above conditions are not met, the stored params will be ignored. To determine if loop params are currently valid, call HasInnerLoops. To disable inner loops, call | |
| TS_API void | SetInnerLoopParams (const TsLoopParams ¶ms) |
| TS_API TsLoopParams | GetInnerLoopParams () const |
Knots | |
| TS_API void | SetKnots (const TsKnotMap &knots) |
| TS_API bool | CanSetKnot (const TsKnot &knot, std::string *reasonOut=nullptr) const |
| TS_API bool | SetKnot (const TsKnot &knot, GfInterval *affectedIntervalOut=nullptr) |
| TS_API TsKnotMap | GetKnots () const |
| TS_API TsKnotMap | GetKnots (const GfInterval &timeInterval) const |
| TS_API bool | GetKnot (TsTime time, TsKnot *knotOut) const |
Removing knots | |
| TS_API void | ClearKnots () |
| TS_API void | RemoveKnot (TsTime time, GfInterval *affectedIntervalOut=nullptr) |
| TS_API bool | ClearRedundantKnots (VtValue defaultValue=VtValue(), const GfInterval &interval=GfInterval::GetFullInterval()) |
| Not yet implemented. More... | |
Loop baking | |
| TS_API bool | BakeInnerLoops () |
| TS_API TsKnotMap | GetKnotsWithInnerLoopsBaked () const |
| TS_API TsKnotMap | GetKnotsWithLoopsBaked (const GfInterval &interval) const |
Breakdowns | |
| TS_API bool | Breakdown (TsTime time, GfInterval *affectedIntervalOut=nullptr) |
| TS_API bool | CanBreakdown (TsTime time, std::string *reason=nullptr) |
Evaluation | |
In all of these templated methods, the T parameter may be the value type of the spline (double/float/GfHalf), or VtValue. | |
| template<typename T > | |
| bool | Eval (TsTime time, T *valueOut) const |
| Evaluates the value of the TsSpline over the given time interval, typically for drawing. More... | |
| template<typename T > | |
| bool | EvalPreValue (TsTime time, T *valueOut) const |
| Evaluates the value of the TsSpline over the given time interval, typically for drawing. More... | |
| template<typename T > | |
| bool | EvalDerivative (TsTime time, T *valueOut) const |
| Evaluates the value of the TsSpline over the given time interval, typically for drawing. More... | |
| template<typename T > | |
| bool | EvalPreDerivative (TsTime time, T *valueOut) const |
| Evaluates the value of the TsSpline over the given time interval, typically for drawing. More... | |
| template<typename T > | |
| bool | EvalHeld (TsTime time, T *valueOut) const |
| Evaluates the value of the TsSpline over the given time interval, typically for drawing. More... | |
| template<typename T > | |
| bool | EvalPreValueHeld (TsTime time, T *valueOut) const |
| Evaluates the value of the TsSpline over the given time interval, typically for drawing. More... | |
| TS_API bool | DoSidesDiffer (TsTime time) const |
| Evaluates the value of the TsSpline over the given time interval, typically for drawing. More... | |
| template<typename Vertex > | |
| 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. More... | |
| template<typename Vertex > | |
| bool | Sample (const GfInterval &timeInterval, double timeScale, double valueScale, double tolerance, TsSplineSamplesWithSources< Vertex > *splineSamples) const |
Spline comparison | |
| TS_API GfInterval | Diff (const TsSpline &other) const |
| Compare two splines. More... | |
| TS_API GfInterval | Diff (const TsSpline &other, const GfInterval &compareInterval) const |
| Compare two splines in a specific input time interval. More... | |
Whole-spline queries | |
| TS_API bool | IsEmpty () const |
| Not yet implemented. More... | |
| TS_API bool | HasValueBlocks () const |
| Not yet implemented. More... | |
| TS_API bool | IsVarying () const |
| Not yet implemented. More... | |
| TS_API bool | HasLoops () const |
| Convenience for HasInnerLoops() || HasExtrapolatingLoops(). More... | |
| TS_API bool | HasInnerLoops () const |
| Not yet implemented. More... | |
| TS_API bool | HasExtrapolatingLoops () const |
| Not yet implemented. More... | |
| TS_API bool | IsLinear () const |
| Not yet implemented. More... | |
| TS_API bool | IsC0Continuous () const |
| Not yet implemented. More... | |
| TS_API bool | IsG1Continuous () const |
| Not yet implemented. More... | |
| TS_API bool | IsC1Continuous () const |
| Not yet implemented. More... | |
| TS_API bool | GetValueRange (const GfInterval &timeSpan, std::pair< VtValue, VtValue > *rangeOut) const |
| Not yet implemented. More... | |
| template<typename T > | |
| bool | GetValueRange (const GfInterval &timeSpan, std::pair< T, T > *rangeOut) const |
| Not yet implemented. More... | |
Within-spline queries | |
| TS_API bool | HasValueBlockAtTime (TsTime time) const |
| Not yet implemented. More... | |
| TS_API bool | IsSegmentFlat (TsTime startTime) const |
| Not yet implemented. More... | |
| TS_API bool | IsSegmentMonotonic (TsTime startTime) const |
| Not yet implemented. More... | |
| TS_API bool | IsKnotRedundant (TsTime time, VtValue defaultValue=VtValue()) const |
| Not yet implemented. More... | |
Friends | |
| class | TsRegressionPreventer |
| struct | Ts_BinaryDataAccess |
| struct | Ts_SplineOffsetAccess |
| template<typename HashState > | |
| void | TfHashAppend (HashState &h, const TsSpline &spline) |
| Ts_SplineData * | Ts_GetSplineData (TsSpline &spline) |
| const Ts_SplineData * | Ts_GetSplineData (const TsSpline &spline) |
Value types | |
| TS_API TfType | GetValueType () const |
| template<typename T > | |
| bool | IsHolding () const |
| TS_API void | SetTimeValued (bool timeValued) |
| TS_API bool | IsTimeValued () const |
| static TS_API bool | IsSupportedValueType (TfType valueType) |
Anti-regression | |
See page_ts_regression for a general introduction to regression and anti-regression.
| |
| TS_API bool | HasRegressiveTangents () const |
| TS_API bool | AdjustRegressiveTangents () |
| static TS_API TsAntiRegressionMode | GetAntiRegressionAuthoringMode () |
A mathematical description of a curved function from time to value.
This class is STILL IN DEVELOPMENT.
Splines are are supported only for floating-point scalar value types. This class is non-templated, but can hold data for varying value types (double, float, and half). All knots in a spline must have the same value type.
Splines are defined by knots. The curve passes through each knot, and in between, the shape of the curve is controlled by tangents specified at the knots.
Splines typically have Bezier or Hermite curve segments with controllable tangents; linear and held (flat) interpolation are also supported. Outside of the time span of knots, the extrapolation of the curve can be specified.
The main service provided by splines is evaluation: determining the curve's value at a given time.
Splines are copy-on-write. Copying a spline object is cheap; the copy will point to the same data on the heap. Copying, and then modifying one of the copies, will incur the cost of duplicating the data, including all the knots.
| TS_API TsSpline::TsSpline | ( | ) |
Default constructor creates a spline without a value type. The value type becomes established when the first knot is added.
Default constructor creates a spline without a value type. The value type becomes established when the first knot is added.
| TS_API bool TsSpline::_Eval | ( | const TsTime | time, |
| VtValue *const | valueOut, | ||
| const Ts_EvalAspect | aspect, | ||
| const Ts_EvalLocation | location | ||
| ) | const |
| TS_API bool TsSpline::AdjustRegressiveTangents | ( | ) |
Shorten any regressive tangents; or, if the current authoring mode is Contain, any tangents that exceed their segment interval. Return whether anything was changed.
| TS_API bool TsSpline::BakeInnerLoops | ( | ) |
Bake inner loops in the spline.
Modify the spline by baking out the knots generated by inner looping to explicit knots and resetting the looping parameters to default.
| TS_API bool TsSpline::Breakdown | ( | TsTime | time, |
| GfInterval * | affectedIntervalOut = nullptr |
||
| ) |
Add a knot at the specified time. The new knot is defined so that the shape of the curve is changed as little as possible. If necessary, neighboring knots may also be modified.
There are some situations where a new knot cannot be inserted. For example, if there is already a knot at the requested time, or if the requested insertion time is in a region of the spline that is looped from either extrapolation or inner looping. Use CanBreakdown to see if a breakdown would succeed.
| TS_API bool TsSpline::CanBreakdown | ( | TsTime | time, |
| std::string * | reason = nullptr |
||
| ) |
Test if a knot could be inserted by Breakdown at time.
Breakdown or false if not. If false is returned and reason is not nullptr then a description of the failure will be stored in reason. This is the same error or warning message that would have been emitted by Breakdown if it had failed to insert a knot. Incompletely implemented; affectedIntervalOut is not yet populated.
Incompletely implemented; affectedIntervalOut is not yet populated.
| TS_API bool TsSpline::ClearRedundantKnots | ( | VtValue | defaultValue = VtValue(), |
| const GfInterval & | interval = GfInterval::GetFullInterval() |
||
| ) |
Not yet implemented.
| TS_API GfInterval TsSpline::Diff | ( | const TsSpline & | other | ) | const |
Compare two splines.
Returns the time interval over which this spline and other have differences. Diff compares the "segments" of a spline where a segment is the span between adjacent knots (or between the end knots and infinity). The returned time interval encompases all of the differing segments in the splines.
For example, if spline1 has knots at times 1, 2, 3, 4, and 5, and spline2 is a copy of spline1 with the value at time 3 changed, calling:
Would set diffInterval to the half-open interval [2.0 .. 4.0).
Note that this implementation is fairly conservative, in that it will never miss any changes but may report differences that do not appear to be obviously different to the casual observer.
Diff considers interpolated segments with different interpolation modes to be different, even if the evaluated numeric values are ultimately the same. A linear segment with a slope of 0.0 is considered different than a held segment with the same end points. Two linear segments with the same end points but different tangents are also considered different. Extrapolation on the other hand is always either a value-block, a straight ray from an end point to infinity, or some repeated loop over the spline's knots. Value-blocks and extrapolated rays are considered identical if they start from the same end-point with the same slope, even if they are generated by different types of extrapolation. Extrapolated loops are considered identical if they produce the same segments.
| TS_API GfInterval TsSpline::Diff | ( | const TsSpline & | other, |
| const GfInterval & | compareInterval | ||
| ) | const |
Compare two splines in a specific input time interval.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This method is identical to the above method but it limits the reported differences to the provided compareInterval. If there are no differences in the compareInterval, an empty GfInterval is returned, even if there may be differences outside of compareInterval
| TS_API bool TsSpline::DoSidesDiffer | ( | TsTime | time | ) | const |
Evaluates the value of the TsSpline over the given time interval, typically for drawing.
Sample creates a piecewise linear approximation of the spline curve. When the returned samples are scaled by timeScale and valueScale and linearly interpolated, the reconstructed curve will nowhere have an error greater than tolerance.
The values of timeScale and valueScale are typically chosen to scale the spline's units to pixels and then tolerance represents the allowed deviation in pixel space from a theoretical exact answer.
timeInterval must not be empty and timeScale, valueScale, and tolerance must all be greater than 0.0. If any of these conditions are not met, Sample returns false and *splineSamples is unchanged. Otherwise, true is returned and splineSamples is populated.
| bool TsSpline::Eval | ( | TsTime | time, |
| T * | valueOut | ||
| ) | const |
Evaluates the value of the TsSpline over the given time interval, typically for drawing.
Sample creates a piecewise linear approximation of the spline curve. When the returned samples are scaled by timeScale and valueScale and linearly interpolated, the reconstructed curve will nowhere have an error greater than tolerance.
The values of timeScale and valueScale are typically chosen to scale the spline's units to pixels and then tolerance represents the allowed deviation in pixel space from a theoretical exact answer.
timeInterval must not be empty and timeScale, valueScale, and tolerance must all be greater than 0.0. If any of these conditions are not met, Sample returns false and *splineSamples is unchanged. Otherwise, true is returned and splineSamples is populated.
| bool TsSpline::EvalDerivative | ( | TsTime | time, |
| T * | valueOut | ||
| ) | const |
Evaluates the value of the TsSpline over the given time interval, typically for drawing.
Sample creates a piecewise linear approximation of the spline curve. When the returned samples are scaled by timeScale and valueScale and linearly interpolated, the reconstructed curve will nowhere have an error greater than tolerance.
The values of timeScale and valueScale are typically chosen to scale the spline's units to pixels and then tolerance represents the allowed deviation in pixel space from a theoretical exact answer.
timeInterval must not be empty and timeScale, valueScale, and tolerance must all be greater than 0.0. If any of these conditions are not met, Sample returns false and *splineSamples is unchanged. Otherwise, true is returned and splineSamples is populated.
| bool TsSpline::EvalHeld | ( | TsTime | time, |
| T * | valueOut | ||
| ) | const |
Evaluates the value of the TsSpline over the given time interval, typically for drawing.
Sample creates a piecewise linear approximation of the spline curve. When the returned samples are scaled by timeScale and valueScale and linearly interpolated, the reconstructed curve will nowhere have an error greater than tolerance.
The values of timeScale and valueScale are typically chosen to scale the spline's units to pixels and then tolerance represents the allowed deviation in pixel space from a theoretical exact answer.
timeInterval must not be empty and timeScale, valueScale, and tolerance must all be greater than 0.0. If any of these conditions are not met, Sample returns false and *splineSamples is unchanged. Otherwise, true is returned and splineSamples is populated.
| bool TsSpline::EvalPreDerivative | ( | TsTime | time, |
| T * | valueOut | ||
| ) | const |
Evaluates the value of the TsSpline over the given time interval, typically for drawing.
Sample creates a piecewise linear approximation of the spline curve. When the returned samples are scaled by timeScale and valueScale and linearly interpolated, the reconstructed curve will nowhere have an error greater than tolerance.
The values of timeScale and valueScale are typically chosen to scale the spline's units to pixels and then tolerance represents the allowed deviation in pixel space from a theoretical exact answer.
timeInterval must not be empty and timeScale, valueScale, and tolerance must all be greater than 0.0. If any of these conditions are not met, Sample returns false and *splineSamples is unchanged. Otherwise, true is returned and splineSamples is populated.
| bool TsSpline::EvalPreValue | ( | TsTime | time, |
| T * | valueOut | ||
| ) | const |
Evaluates the value of the TsSpline over the given time interval, typically for drawing.
Sample creates a piecewise linear approximation of the spline curve. When the returned samples are scaled by timeScale and valueScale and linearly interpolated, the reconstructed curve will nowhere have an error greater than tolerance.
The values of timeScale and valueScale are typically chosen to scale the spline's units to pixels and then tolerance represents the allowed deviation in pixel space from a theoretical exact answer.
timeInterval must not be empty and timeScale, valueScale, and tolerance must all be greater than 0.0. If any of these conditions are not met, Sample returns false and *splineSamples is unchanged. Otherwise, true is returned and splineSamples is populated.
| bool TsSpline::EvalPreValueHeld | ( | TsTime | time, |
| T * | valueOut | ||
| ) | const |
Evaluates the value of the TsSpline over the given time interval, typically for drawing.
Sample creates a piecewise linear approximation of the spline curve. When the returned samples are scaled by timeScale and valueScale and linearly interpolated, the reconstructed curve will nowhere have an error greater than tolerance.
The values of timeScale and valueScale are typically chosen to scale the spline's units to pixels and then tolerance represents the allowed deviation in pixel space from a theoretical exact answer.
timeInterval must not be empty and timeScale, valueScale, and tolerance must all be greater than 0.0. If any of these conditions are not met, Sample returns false and *splineSamples is unchanged. Otherwise, true is returned and splineSamples is populated.
|
static |
Returns the current effective anti-regression authoring mode. This may come from the overall default of Keep Ratio; the build-configured default defined by PXR_TS_DEFAULT_ANTI_REGRESSION_AUTHORING_MODE; or a TsAntiRegressionAuthoringSelector.
| TS_API TsCurveType TsSpline::GetCurveType | ( | ) | const |
| TS_API TsLoopParams TsSpline::GetInnerLoopParams | ( | ) | const |
Retrieves a copy of the knot at the specified time, if one exists. This must be an original knot, not a knot that is echoed due to looping. Returns true on success, false if there is no such knot.
Returns the spline's knots. These are the original knots; if inner or extrapolating loops are present, this set of knots does not reflect that.
| TS_API TsKnotMap TsSpline::GetKnots | ( | const GfInterval & | timeInterval | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Get the spline's knots that affect the specified time interval.
Return a TsKnotMap containing the knots that affect the time interval. This may include knots outside the time interval if they affect the curve inside the time interval. For example, if there are knots at times 10, 20, and 30. Calling GetKnots with a timeInteval of [15 .. 25] may return all 3 knots since the knots at 10 and 30 may affect the shape of the spline at times that are inside the timeInterval.
Return all the knots on the spline, including knots generated by inner looping.
These knots can be used to create a new spline that does not use looping but has the same shape as this spline. Note that extrapolated knots are not included in the result. If you want to include extrapolated knots use GetKnotsWithLoopsBaked and provide a time interval over which knots should be expanded.
| TS_API TsKnotMap TsSpline::GetKnotsWithLoopsBaked | ( | const GfInterval & | interval | ) | const |
Return baked knots that will replicate this spline over the given time interval without any looping.
Return a TsKnotMap containing baked knots that will replicate the shape of the spline over the time interval without using any looping. Both inner and extrapolation loops are included in the returned knots.
If extrapolation loops are in use, the specified interval argument, must specify a finite time interval since extrapolation looping extends to infinity and will generate a theoretically infinite number of knots. Attempts to bake an infinite number of knots will emit a coding error and return an empty TsKnotMap.
| TS_API TsExtrapolation TsSpline::GetPostExtrapolation | ( | ) | const |
| TS_API TsExtrapolation TsSpline::GetPreExtrapolation | ( | ) | const |
| TS_API bool TsSpline::GetValueRange | ( | const GfInterval & | timeSpan, |
| std::pair< VtValue, VtValue > * | rangeOut | ||
| ) | const |
Not yet implemented.
| bool TsSpline::GetValueRange | ( | const GfInterval & | timeSpan, |
| std::pair< T, T > * | rangeOut | ||
| ) | const |
Not yet implemented.
| TS_API bool TsSpline::HasExtrapolatingLoops | ( | ) | const |
Not yet implemented.
| TS_API bool TsSpline::HasInnerLoops | ( | ) | const |
Not yet implemented.
| TS_API bool TsSpline::HasLoops | ( | ) | const |
Convenience for HasInnerLoops() || HasExtrapolatingLoops().
| TS_API bool TsSpline::HasRegressiveTangents | ( | ) | const |
Returns whether this spline has any tangents long enough to cause regression; or, if the current authoring mode is Contain, whether this spline has any tangents that exceed their segment interval.
| TS_API bool TsSpline::HasValueBlockAtTime | ( | TsTime | time | ) | const |
Not yet implemented.
| TS_API bool TsSpline::HasValueBlocks | ( | ) | const |
Not yet implemented.
| TS_API bool TsSpline::IsC0Continuous | ( | ) | const |
Not yet implemented.
| TS_API bool TsSpline::IsC1Continuous | ( | ) | const |
Not yet implemented.
| TS_API bool TsSpline::IsEmpty | ( | ) | const |
Not yet implemented.
| TS_API bool TsSpline::IsG1Continuous | ( | ) | const |
Not yet implemented.
Not yet implemented.
| TS_API bool TsSpline::IsLinear | ( | ) | const |
Not yet implemented.
| TS_API bool TsSpline::IsSegmentFlat | ( | TsTime | startTime | ) | const |
Not yet implemented.
| TS_API bool TsSpline::IsSegmentMonotonic | ( | TsTime | startTime | ) | const |
Not yet implemented.
| TS_API bool TsSpline::IsTimeValued | ( | ) | const |
| TS_API bool TsSpline::IsVarying | ( | ) | const |
Not yet implemented.
| TS_API bool TsSpline::operator!= | ( | const TsSpline & | other | ) | const |
Default constructor creates a spline without a value type. The value type becomes established when the first knot is added.
Default constructor creates a spline without a value type. The value type becomes established when the first knot is added.
Default constructor creates a spline without a value type. The value type becomes established when the first knot is added.
| TS_API void TsSpline::RemoveKnot | ( | TsTime | time, |
| GfInterval * | affectedIntervalOut = nullptr |
||
| ) |
Incompletely implemented; affectedIntervalOut is not yet populated.
|
inline |
Evaluates the value of the TsSpline over the given time interval, typically for drawing.
Sample creates a piecewise linear approximation of the spline curve. When the returned samples are scaled by timeScale and valueScale and linearly interpolated, the reconstructed curve will nowhere have an error greater than tolerance.
The values of timeScale and valueScale are typically chosen to scale the spline's units to pixels and then tolerance represents the allowed deviation in pixel space from a theoretical exact answer.
timeInterval must not be empty and timeScale, valueScale, and tolerance must all be greater than 0.0. If any of these conditions are not met, Sample returns false and *splineSamples is unchanged. Otherwise, true is returned and splineSamples is populated.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. When passed a TsSplineSamplesWithSources<Vertex> class, the returned information contains a TsSplineSampleSource value for each polyline. The TsSplineSampleSource indicates the source region (extrapolation, looping, normal interpolation, etc.) of the spline generated that polyline.
| TS_API void TsSpline::SetCurveType | ( | TsCurveType | curveType | ) |
| TS_API void TsSpline::SetInnerLoopParams | ( | const TsLoopParams & | params | ) |
| TS_API bool TsSpline::SetKnot | ( | const TsKnot & | knot, |
| GfInterval * | affectedIntervalOut = nullptr |
||
| ) |
Incompletely implemented; affectedIntervalOut is not yet populated.
Incompletely implemented; affectedIntervalOut is not yet populated.
| TS_API void TsSpline::SetPostExtrapolation | ( | const TsExtrapolation & | extrap | ) |
| TS_API void TsSpline::SetPreExtrapolation | ( | const TsExtrapolation & | extrap | ) |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |