Loading...
Searching...
No Matches
layerOffset.h
Go to the documentation of this file.
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_USD_SDF_LAYER_OFFSET_H
8#define PXR_USD_SDF_LAYER_OFFSET_H
9
11
12#include "pxr/pxr.h"
13#include "pxr/usd/sdf/api.h"
14
15#include <iosfwd>
16#include <vector>
17
18PXR_NAMESPACE_OPEN_SCOPE
19
20class SdfTimeCode;
21
44{
45public:
48
50 explicit SdfLayerOffset(double offset = 0.0, double scale = 1.0)
51 : _offset(offset), _scale(scale) {}
52
54
57
59 double GetOffset() const { return _offset; }
60
62 double GetScale() const { return _scale; }
63
65 void SetOffset(double newOffset) { _offset = newOffset; }
66
68 void SetScale(double newScale) { _scale = newScale; }
69
74 bool IsIdentity() const {
75 // Check for the common case of exact identity.
76 if (_offset == 0.0 && _scale == 1.0) {
77 return true;
78 }
79 return *this == SdfLayerOffset {};
80 }
81
85 SDF_API
86 bool IsValid() const;
87
89 SDF_API
91
94
96 SDF_API
97 size_t GetHash() const;
98
100 struct Hash {
101 size_t operator()(const SdfLayerOffset &offset) const {
102 return offset.GetHash();
103 }
104 };
105
106 friend inline size_t hash_value(const SdfLayerOffset &offset) {
107 return offset.GetHash();
108 }
109
111
114
120 SDF_API
121 bool operator==(const SdfLayerOffset &rhs) const;
122
124 bool operator!=(const SdfLayerOffset &rhs) const {
125 return !(*this == rhs);
126 }
127
130 SDF_API
131 bool operator<(const SdfLayerOffset &rhs) const;
132
134 bool operator>(const SdfLayerOffset& rhs) const {
135 return rhs < *this;
136 }
137
139 bool operator>=(const SdfLayerOffset& rhs) const {
140 return !(*this < rhs);
141 }
142
144 bool operator<=(const SdfLayerOffset& rhs) const {
145 return !(*this > rhs);
146 }
147
150 SDF_API
152
154 SDF_API
155 double operator*(double rhs) const;
156
158 SDF_API
160
162
163private:
164 double _offset;
165 double _scale;
166};
167
168typedef std::vector<SdfLayerOffset> SdfLayerOffsetVector;
169
172SDF_API
173std::ostream & operator<<( std::ostream &out,
174 const SdfLayerOffset &layerOffset );
175
176PXR_NAMESPACE_CLOSE_SCOPE
177
178#endif // PXR_USD_SDF_LAYER_OFFSET_H
Represents a time offset and scale between layers.
Definition: layerOffset.h:44
bool operator>(const SdfLayerOffset &rhs) const
Definition: layerOffset.h:134
double GetScale() const
Returns the time scale factor.
Definition: layerOffset.h:62
bool IsIdentity() const
Returns true if this is an identity transformation, with an offset of 0.0 and a scale of 1....
Definition: layerOffset.h:74
SDF_API SdfLayerOffset GetInverse() const
Gets the inverse offset, which performs the opposite transformation.
SDF_API bool IsValid() const
Returns true if this offset is valid, i.e.
bool operator>=(const SdfLayerOffset &rhs) const
Definition: layerOffset.h:139
bool operator!=(const SdfLayerOffset &rhs) const
Definition: layerOffset.h:124
SDF_API SdfLayerOffset operator*(const SdfLayerOffset &rhs) const
Composes this with the offset rhs, such that the resulting offset is equivalent to first applying rhs...
SDF_API bool operator==(const SdfLayerOffset &rhs) const
Returns whether the offsets are equal.
SDF_API bool operator<(const SdfLayerOffset &rhs) const
Returns whether this offset is less than another.
bool operator<=(const SdfLayerOffset &rhs) const
Definition: layerOffset.h:144
SdfLayerOffset(double offset=0.0, double scale=1.0)
Constructs a new SdfLayerOffset instance.
Definition: layerOffset.h:50
SDF_API SdfTimeCode operator*(const SdfTimeCode &rhs) const
Applies the offset to the given value.
void SetOffset(double newOffset)
Sets the time offset.
Definition: layerOffset.h:65
double GetOffset() const
Returns the time offset.
Definition: layerOffset.h:59
SDF_API double operator*(double rhs) const
Applies the offset to the given value.
void SetScale(double newScale)
Sets the time scale factor.
Definition: layerOffset.h:68
SDF_API size_t GetHash() const
Returns hash for this offset.
Value type that represents a time code.
Definition: timeCode.h:29
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
Hash functor for hash maps and sets.
Definition: layerOffset.h:100