8 #ifndef PXR_BASE_TS_SPLINE_DATA_H
9 #define PXR_BASE_TS_SPLINE_DATA_H
22 #include <unordered_map>
91 size_t *firstProtoIndexOut =
nullptr)
const;
134 template <
typename T>
171 double scale)
override;
178 std::vector<Ts_TypedKnotData<T>>
knots;
191 template <
typename T>
195 template <
typename T>
203 template <
typename T>
211 return Ts_GetType<T>();
214 template <
typename T>
220 template <
typename T>
227 template <
typename T>
253 return knots == typedOther->
knots;
256 template <
typename T>
260 times.reserve(count);
261 knots.reserve(count);
264 template <
typename T>
272 times.push_back(knotData->
time);
273 knots.push_back(*typedKnotData);
275 if (!customDataIn.
empty())
277 customData[knotData->
time] = customDataIn;
281 template <
typename T>
291 std::lower_bound(times.begin(), times.end(), knotData->
time);
294 const bool overwrite =
295 (it != times.end() && *it == knotData->
time);
300 times[idx] = knotData->
time;
301 knots[idx] = *typedKnotData;
305 times.insert(it, knotData->
time);
306 knots.insert(knots.begin() + idx, *typedKnotData);
310 if (!customDataIn.
empty())
312 customData[knotData->
time] = customDataIn;
318 template <
typename T>
321 const size_t index)
const
326 template <
typename T>
329 const TsTime
time)
const
331 const auto it = std::lower_bound(times.begin(), times.end(),
time);
332 if (it == times.end() || *it !=
time)
337 const auto knotIt = knots.begin() + (it - times.begin());
341 template <
typename T>
346 return &(knots[
index]);
350 template <
typename T>
353 const size_t index)
const
360 static_cast<Ts_KnotData&
>(out) = static_cast<const Ts_KnotData&>(in);
371 template <
typename T>
379 template <
typename T>
383 const auto it = std::lower_bound(times.begin(), times.end(),
time);
384 if (it == times.end() || *it !=
time)
390 const size_t idx = it - times.begin();
392 customData.erase(time);
393 knots.erase(knots.begin() + idx);
396 template <
typename T>
397 static void _ApplyOffsetAndScaleToKnot(
403 TF_VERIFY(scale > 0);
417 template <
typename T>
425 "collapsing/reversing time and spline representation "
439 preExtrapolation.slope /=
scale;
443 postExtrapolation.slope /=
scale;
447 if (loopParams.protoEnd > loopParams.protoStart)
450 loopParams.protoStart = loopParams.protoStart * scale +
offset;
451 loopParams.protoEnd = loopParams.protoEnd * scale +
offset;
455 for (TsTime &
time : times) {
466 _ApplyOffsetAndScaleToKnot(&knotData, offset, scale);
470 static_cast<T>(knotData.value * scale +
offset);
472 static_cast<T>(knotData.preValue * scale +
offset);
478 _ApplyOffsetAndScaleToKnot(&knotData, offset, scale);
483 if (!customData.empty())
485 std::unordered_map<TsTime, VtDictionary> newCustomData;
486 for (
const auto &mapPair : customData) {
487 newCustomData[mapPair.first * scale +
offset] = mapPair.second;
489 customData.swap(newCustomData);
493 template <
typename T>
518 template <
typename T>
520 const TsTime
time)
const
530 std::lower_bound(times.begin(), times.end(),
time);
534 if (lbIt == times.end())
543 const auto knotIt = knots.begin() + (lbIt - times.begin());
549 if (lbIt == times.begin())
556 const auto knotIt = knots.begin() + (lbIt - times.begin());
560 template <
typename T>
568 template <
typename T>
void PushKnot(const Ts_KnotData *knotData, const VtDictionary &customData) override
std::vector< Ts_TypedKnotData< T > > knots
std::unordered_map< TsTime, VtDictionary > customData
Ts_KnotData * CloneKnotAtIndex(size_t index) const override
bool operator==(const Ts_SplineData &other) const override
virtual Ts_KnotData * CloneKnotAtIndex(size_t index) const =0
GT_API const UT_StringHolder time
virtual Ts_SplineData * Clone() const =0
virtual bool operator==(const Ts_SplineData &other) const =0
bool HasValueBlockAtTime(TsTime time) const override
void RemoveKnotAtTime(TsTime time) override
virtual bool HasValueBlocks() const =0
virtual void ClearKnots()=0
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Quat< T > spline(const Quat< T > &q0, const Quat< T > &q1, const Quat< T > &q2, const Quat< T > &q3, T t) IMATH_NOEXCEPT
TsExtrapolation postExtrapolation
bool HasInnerLoops(size_t *firstProtoIndexOut=nullptr) const
constexpr auto in(type t, int set) -> bool
std::vector< TsTime > times
GA_API const UT_StringHolder scale
virtual size_t SetKnot(const Ts_KnotData *knotData, const VtDictionary &customData)=0
TsExtrapolation preExtrapolation
virtual Ts_KnotData * GetKnotPtrAtIndex(size_t index)=0
size_t GetKnotStructSize() const override
virtual bool HasValueBlockAtTime(TsTime time) const =0
virtual Ts_KnotData * CloneKnotAtTime(TsTime time) const =0
Ts_SplineData * Clone() const override
TfType GetValueType() const override
Ts_TypedKnotData< double > GetKnotDataAsDouble(size_t index) const override
Ts_KnotData * CloneKnotAtTime(TsTime time) const override
VT_API bool empty() const
true if the VtDictionary's size is 0.
void ClearKnots() override
Ts_TypedSplineData< T > * Ts_GetTypedSplineData(TsSpline &spline)
void ReserveForKnotCount(size_t count) override
size_t SetKnot(const Ts_KnotData *knotData, const VtDictionary &customData) override
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
virtual Ts_TypedKnotData< double > GetKnotDataAsDouble(size_t index) const =0
virtual void PushKnot(const Ts_KnotData *knotData, const VtDictionary &customData)=0
virtual TfType GetValueType() const =0
bool HasValueBlocks() const override
virtual void ApplyOffsetAndScale(TsTime offset, double scale)=0
#define PXR_NAMESPACE_CLOSE_SCOPE
void ApplyOffsetAndScale(TsTime offset, double scale) override
Ts_KnotData * GetKnotPtrAtIndex(size_t index) override
static Ts_SplineData * Create(TfType valueType, const Ts_SplineData *overallParamSource=nullptr)
virtual void RemoveKnotAtTime(TsTime time)=0
virtual void ReserveForKnotCount(size_t count)=0
Ts_SplineData * Ts_GetSplineData(TsSpline &spline)
virtual size_t GetKnotStructSize() const =0