All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
knotMap.h
1//
2// Copyright 2024 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7
8#ifndef PXR_BASE_TS_KNOT_MAP_H
9#define PXR_BASE_TS_KNOT_MAP_H
10
11#include "pxr/pxr.h"
12#include "pxr/base/ts/api.h"
13#include "pxr/base/ts/knot.h"
14#include "pxr/base/ts/types.h"
16
17#include <vector>
18#include <initializer_list>
19#include <utility>
20
21PXR_NAMESPACE_OPEN_SCOPE
22
23struct Ts_SplineData;
24
25
37{
38public:
39 using KnotVec = std::vector<TsKnot>;
40
41 using iterator = KnotVec::iterator;
42 using const_iterator = KnotVec::const_iterator;
43 using reverse_iterator = KnotVec::reverse_iterator;
44 using const_reverse_iterator = KnotVec::const_reverse_iterator;
45
46public:
49
50 TS_API
51 TsKnotMap();
52
53 TS_API
54 TsKnotMap(std::initializer_list<TsKnot> knots);
55
56 TS_API
57 bool operator==(const TsKnotMap &other) const;
58
59 TS_API
60 bool operator!=(const TsKnotMap &other) const;
61
68
69 TS_API
70 iterator begin();
71
72 TS_API
73 const_iterator begin() const;
74
75 TS_API
76 const_iterator cbegin() const;
77
78 TS_API
79 iterator end();
80
81 TS_API
82 const_iterator end() const;
83
84 TS_API
85 const_iterator cend() const;
86
87 TS_API
88 reverse_iterator rbegin();
89
90 TS_API
91 const_reverse_iterator rbegin() const;
92
93 TS_API
94 const_reverse_iterator crbegin() const;
95
96 TS_API
97 reverse_iterator rend();
98
99 TS_API
100 const_reverse_iterator rend() const;
101
102 TS_API
103 const_reverse_iterator crend() const;
104
111
112 TS_API
113 size_t size() const;
114
115 TS_API
116 bool empty() const;
117
118 TS_API
119 void reserve(size_t size);
120
127
128 TS_API
129 void clear();
130
131 TS_API
132 void swap(TsKnotMap &other);
133
138 TS_API
139 std::pair<iterator, bool> insert(const TsKnot &knot);
140
143 TS_API
144 size_t erase(TsTime time);
145
147 TS_API
148 iterator erase(iterator i);
149
151 TS_API
152 iterator erase(iterator first, iterator last);
153
160
162 TS_API
163 iterator find(TsTime time);
164
166 TS_API
167 const_iterator find(TsTime time) const;
168
172 TS_API
173 iterator lower_bound(TsTime time);
174
176 TS_API
177 const_iterator lower_bound(TsTime time) const;
178
182
186 TS_API
187 iterator FindClosest(TsTime time);
188
190 TS_API
191 const_iterator FindClosest(TsTime time) const;
192
194 TS_API
196
199 TS_API
201
203 TS_API
204 bool HasCurveSegments() const;
205
207
208private:
209 friend class TsSpline;
210
211 // Constructor for copying knot data from SplineData into KnotMap.
212 TS_API
213 TsKnotMap(const Ts_SplineData *data);
214
215private:
216 // Knot objects.
217 KnotVec _knots;
218};
219
220
221PXR_NAMESPACE_CLOSE_SCOPE
222
223#endif
A basic mathematical interval class.
Definition: interval.h:33
TfType represents a dynamic runtime type.
Definition: type.h:48
A knot belonging to a TsSpline.
Definition: knot.h:38
The knots in a spline.
Definition: knotMap.h:37
TS_API TfType GetValueType() const
Returns the value type of the knots, or Unknown if empty.
TS_API iterator FindClosest(TsTime time)
Returns the knot whose time most closely (or exactly) matches the specified time.
TS_API iterator erase(iterator i)
Removes a knot. Returns the iterator after it.
TS_API const_iterator lower_bound(TsTime time) const
Const version of lower_bound().
TS_API size_t erase(TsTime time)
Removes the knot at the specified time, if it exists.
TS_API const_iterator find(TsTime time) const
Const version of find().
TS_API std::pair< iterator, bool > insert(const TsKnot &knot)
Inserts a knot.
TS_API GfInterval GetTimeSpan() const
Returns the time interval containing the first and last knot.
TS_API bool HasCurveSegments() const
Returns whether there are any segments with curve interpolation.
TS_API iterator find(TsTime time)
Exact matches only; returns end() if not found.
TS_API const_iterator FindClosest(TsTime time) const
Const version of FindClosest().
TS_API iterator erase(iterator first, iterator last)
Removes a range of knots. Returns the iterator after the last removed.
TS_API iterator lower_bound(TsTime time)
If there is a knot at the specified time, returns that.
A mathematical description of a curved function from time to value.
Definition: spline.h:59