HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
tsTest_SampleTimes.h
Go to the documentation of this file.
1 //
2 // Copyright 2023 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 
25 #ifndef PXR_BASE_TS_TS_TEST_SAMPLE_TIMES_H
26 #define PXR_BASE_TS_TS_TEST_SAMPLE_TIMES_H
27 
28 #include "pxr/pxr.h"
29 #include "pxr/base/ts/api.h"
31 
32 #include <vector>
33 #include <set>
34 
36 
38 {
39 public:
40  // A time at which to perform evaluation. Typically just a time, but can
41  // also be a "pre" time, which at a dual-valued knot can differ from the
42  // ordinary value.
44  {
45  double time = 0.0;
46  bool pre = false;
47 
48  public:
49  SampleTime();
50  SampleTime(double time);
51  SampleTime(double time, bool pre);
52  SampleTime(const SampleTime &other);
53  SampleTime& operator=(const SampleTime &other);
54  SampleTime& operator=(double time);
55  bool operator<(const SampleTime &other) const;
56  bool operator==(const SampleTime &other) const;
57  bool operator!=(const SampleTime &other) const;
58  };
59 
60  using SampleTimeSet = std::set<SampleTime>;
61 
62 public:
63  // DIRECT SPECIFICATION
64 
65  // Constructs a SampleTimes object for direct specification of times.
66  TS_API
68 
69  // Adds the specified times.
70  TS_API
71  void AddTimes(
72  const std::vector<double> &times);
73 
74  // Adds the specified times.
75  TS_API
76  void AddTimes(
77  const std::vector<SampleTime> &times);
78 
79  // SPLINE-DRIVEN
80 
81  // Constructs a SampleTimes object for specification of times based on the
82  // contents of splineData.
83  TS_API
85  const TsTest_SplineData &splineData);
86 
87  // Adds a time for each knot in splineData. For dual-valued knots, adds
88  // both a pre-time and an ordinary time.
89  TS_API
90  void AddKnotTimes();
91 
92  // Adds evenly spaced sample times within the frame range of splineData.
93  // The first sample is after the first knot, and the last sample is before
94  // the last knot.
95  TS_API
97  int numSamples);
98 
99  // Determines the time range of the knots in splineData, extends it by
100  // extrapolationFactor on each end, and adds one pre-extrapolating and one
101  // post-extrapolating sample. For example, with a time range of 10, and an
102  // extrapolationFactor of 0.25, samples will be added 2.5 time units before
103  // the first knot and 2.5 time units after the last.
104  TS_API
106  double extrapolationFactor);
107 
108  // MACRO
109 
110  // Calls AddKnotTimes(), AddUniformInterpolationTimes(200), and
111  // AddExtrapolationTimes(0.2).
112  TS_API
113  void AddStandardTimes();
114 
115  // ACCESSORS
116 
117  // Returns the set of sample times.
118  TS_API
119  const SampleTimeSet&
120  GetTimes() const;
121 
122 private:
123  SampleTimeSet _GetKnotTimes() const;
124 
125 private:
126  const bool _haveSplineData;
127  const TsTest_SplineData _splineData;
128 
129  SampleTimeSet _times;
130 };
131 
133 
134 #endif
GT_API const UT_StringHolder time
TS_API void AddStandardTimes()
TS_API void AddExtrapolationTimes(double extrapolationFactor)
TS_API void AddKnotTimes()
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
TS_API TsTest_SampleTimes()
bool operator<(const GU_TetrahedronFacet &a, const GU_TetrahedronFacet &b)
TS_API void AddTimes(const std::vector< double > &times)
#define TS_API
Definition: api.h:41
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
TS_API const SampleTimeSet & GetTimes() const
LeafData & operator=(const LeafData &)=delete
TS_API void AddUniformInterpolationTimes(int numSamples)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
std::set< SampleTime > SampleTimeSet
bool operator!=(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:165
IMF_EXPORT int numSamples(int s, int a, int b)