7#ifndef PXR_USD_SDF_COMPOSE_TIME_SAMPLE_SERIES_H
8#define PXR_USD_SDF_COMPOSE_TIME_SAMPLE_SERIES_H
11#include "pxr/usd/sdf/api.h"
14PXR_NAMESPACE_OPEN_SCOPE
17inline auto Sdf_timesEqualDefaultFn = [](
double t1,
double t2) {
43 class GetTimeFn,
class GetValueFn,
44 class ComposeFn,
class OutputFn,
45 class TimesEqualFn =
decltype(Sdf_timesEqualDefaultFn)>
47SdfComposeTimeSampleSeries(
48 Iter strongBegin, Iter strongEnd,
49 Iter weakBegin, Iter weakEnd,
50 GetTimeFn
const &getTime,
51 GetValueFn
const &getValue,
52 ComposeFn
const &composeFn,
53 OutputFn
const &outputFn,
54 TimesEqualFn
const ×Equal = Sdf_timesEqualDefaultFn)
57 if (weakBegin == weakEnd) {
58 while (strongBegin != strongEnd) {
59 outputFn(getValue(strongBegin), getTime(strongBegin));
64 if (strongBegin == strongEnd) {
65 while (weakBegin != weakEnd) {
66 outputFn(getValue(weakBegin), getTime(weakBegin));
72 auto held = [&getTime, ×Equal](Iter iter, Iter begin, Iter end,
74 return iter == end || (!timesEqual(
75 getTime(iter), time) && iter != begin)
80 constexpr double inf = std::numeric_limits<double>::infinity();
82 Iter strongIter = strongBegin;
83 Iter weakIter = weakBegin;
85 while (strongIter != strongEnd || weakIter != weakEnd) {
86 const double strongTime =
87 strongIter == strongEnd ? inf : getTime(strongIter);
88 const double weakTime =
89 weakIter == weakEnd ? inf : getTime(weakIter);
90 if (strongTime <= weakTime) {
91 if (
auto composed = composeFn(
93 getValue(held(weakIter, weakBegin, weakEnd,
95 outputFn(std::move(*composed), strongTime);
98 outputFn(getValue(strongIter), strongTime);
102 if (
auto composed = composeFn(
103 getValue(held(strongIter, strongBegin, strongEnd,
105 getValue(weakIter))) {
106 outputFn(std::move(*composed), weakTime);
116 if (strongIter == strongEnd) {
119 else if (weakIter == weakEnd) {
123 if (timesEqual(strongTime, weakTime)) {
124 ++strongIter, ++weakIter;
126 else if (strongTime < weakTime) {
136PXR_NAMESPACE_CLOSE_SCOPE
bool GfIsClose(GfColor const &c1, GfColor const &c2, double tolerance)
Tests for equality of the RGB tuple in a color with a given tolerance, returning true if the length o...
Assorted mathematical utility functions.