All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
metrics.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 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 #ifndef PXR_USD_USD_GEOM_METRICS_H
25 #define PXR_USD_USD_GEOM_METRICS_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/usdGeom/api.h"
29 #include "pxr/base/tf/token.h"
30 #include "pxr/usd/usd/common.h"
31 
32 PXR_NAMESPACE_OPEN_SCOPE
33 
34 
81 
90 USDGEOM_API
91 TfToken UsdGeomGetStageUpAxis(const UsdStageWeakPtr &stage);
92 
101 USDGEOM_API
102 bool UsdGeomSetStageUpAxis(const UsdStageWeakPtr &stage, const TfToken &axis);
103 
119 USDGEOM_API
121 
123 
150 
152 
155 USDGEOM_API
156 double UsdGeomGetStageMetersPerUnit(const UsdStageWeakPtr &stage);
157 
160 USDGEOM_API
161 bool UsdGeomStageHasAuthoredMetersPerUnit(const UsdStageWeakPtr &stage);
162 
168 USDGEOM_API
169 bool UsdGeomSetStageMetersPerUnit(const UsdStageWeakPtr &stage,
170  double metersPerUnit);
171 
189 USDGEOM_API
190 bool UsdGeomLinearUnitsAre(double authoredUnits, double standardUnits,
191  double epsilon = 1e-5);
192 
198 public:
199  static constexpr double nanometers = 1e-9;
200  static constexpr double micrometers = 1e-6;
201  static constexpr double millimeters = 0.001;
202  static constexpr double centimeters = 0.01;
203  static constexpr double meters = 1.0;
204  static constexpr double kilometers = 1000;
205 
207  static constexpr double lightYears = 9.4607304725808e15;
208 
209  static constexpr double inches = 0.0254;
210  static constexpr double feet = 0.3048;
211  static constexpr double yards = 0.9144;
212  static constexpr double miles = 1609.344;
213 };
214 
216 
217 PXR_NAMESPACE_CLOSE_SCOPE
218 
219 #endif // PXR_USD_USD_GEOM_METRICS_H
USDGEOM_API bool UsdGeomStageHasAuthoredMetersPerUnit(const UsdStageWeakPtr &stage)
Return whether stage has an authored metersPerUnit.
Container class for static double-precision symbols representing common units of measure expressed in...
Definition: metrics.h:197
USDGEOM_API TfToken UsdGeomGetStageUpAxis(const UsdStageWeakPtr &stage)
Fetch and return stage 's upAxis.
static constexpr double lightYears
Measured for one year = 365.25 days.
Definition: metrics.h:207
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
USDGEOM_API bool UsdGeomLinearUnitsAre(double authoredUnits, double standardUnits, double epsilon=1e-5)
Return true if the two given metrics are within the provided relative epsilon of each other...
USDGEOM_API bool UsdGeomSetStageUpAxis(const UsdStageWeakPtr &stage, const TfToken &axis)
Set stage 's upAxis to axis, which must be one of UsdGeomTokens->y or UsdGeomTokens->z.
USDGEOM_API bool UsdGeomSetStageMetersPerUnit(const UsdStageWeakPtr &stage, double metersPerUnit)
Author stage's metersPerUnit.
USDGEOM_API TfToken UsdGeomGetFallbackUpAxis()
Return the site-level fallback up axis as a TfToken.
USDGEOM_API double UsdGeomGetStageMetersPerUnit(const UsdStageWeakPtr &stage)
Return stage's authored metersPerUnit, or 0.01 if unauthored.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...