HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_Utils.h
Go to the documentation of this file.
1 //
2 // Copyright 2017 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 __GUSD_GT_UTILS_H__
25 #define __GUSD_GT_UTILS_H__
26 
27 #include "gusd/api.h"
28 
29 #include <GT/GT_Primitive.h>
30 #include <GEO/GEO_Primitive.h>
31 #include <UT/UT_Map.h>
32 #include <UT/UT_Options.h>
33 #include <UT/UT_Set.h>
34 #include <UT/UT_Variadic.h>
35 
36 #include "pxr/pxr.h"
37 #include "pxr/base/gf/half.h"
38 #include "pxr/usd/usd/common.h"
39 #include "pxr/usd/usd/timeCode.h"
40 
42 
43 class GfMatrix4d;
44 class GusdContext;
45 class SdfPath;
46 class SdfValueTypeName;
47 class TfToken;
48 class UsdAttribute;
49 class UsdGeomBoundable;
50 class UsdGeomImageable;
51 class UsdGeomXformable;
52 
53 //------------------------------------------------------------------------------
54 // class GusdGT_AttrFilter
55 //------------------------------------------------------------------------------
57 {
58 public:
60 
61 public:
62 
63  GUSD_API
64  explicit GusdGT_AttrFilter(const std::string& pattern="*");
65 
66  GUSD_API
68 
69  GUSD_API
70  void setPattern(GT_Owner owner, const std::string& pattern);
71 
72  GUSD_API
73  void appendPattern(GT_Owner owner, const std::string& pattern);
74 
75  GUSD_API
76  bool matches(const std::string& str) const;
77 
78  GUSD_API
79  void setActiveOwners(const OwnerArgs& owners) const;
80 
81 private:
83 
84  std::string m_overridePattern;
85 
86  mutable OwnerArgs m_activeOwners;
87 };
88 
89 //------------------------------------------------------------------------------
90 // class GusdGT_Utils
91 //------------------------------------------------------------------------------
93 {
94 public:
98 
100  };
101 
102 public:
103 
104  /// Returns the GT_Type corresponding to a USD type.
105  static GT_Type getType(const SdfValueTypeName& typeName);
106 
107  /// Returns the USD role name corresponding to the given GT type.
108  static TfToken getRole(GT_Type type);
109 
110  static bool setUsdAttribute(const UsdAttribute& destAttr,
111  const GT_DataArrayHandle& sourceAttr,
113 
115 
116  static bool setPrimvarSample( const UsdGeomImageable& usdPrim,
117  const TfToken &name,
118  const GT_DataArrayHandle& data,
119  const TfToken& interpolation,
120  UsdTimeCode time );
121 
122  static bool isDataConstant( const GT_DataArrayHandle& data );
123 
124  static void setCustomAttributesFromGTPrim(
125  const UsdGeomImageable &usdGeomPrim,
126  const GT_AttributeListHandle& gtAttrs,
127  std::set<std::string>& excludeSet,
129 
130 
131  // TODO remove
132  static bool setTransformFromGTArray(const UsdGeomXformable& usdGeom,
133  const GT_DataArrayHandle& xform,
134  const TransformLevel transformLevel,
136 
137  static GT_DataArrayHandle
138  getTransformArray(const GT_PrimitiveHandle& gtPrim);
139 
140  static GT_DataArrayHandle
142 
144 
145  static GT_DataArrayHandle
147  GT_DataArrayHandle pts,
148  const GfMatrix4d& objXform );
149 
150  static GT_DataArrayHandle
152  GT_DataArrayHandle pts,
153  const UT_Matrix4D& objXform );
154 
156  getAttributesFromPrim( const GEO_Primitive *prim );
157 
158  static std::string
159  makeValidIdentifier(const TfToken& usdFilePath, const SdfPath& nodePath);
160 
161 
162  /// Struct for querying storage by POD type.
163  /// XXX: replace this with a constexpr in C++11.
164  template <typename T>
166 };
167 //------------------------------------------------------------------------------
168 
169 
170 template <>
172 { static const GT_Storage value = GT_STORE_UINT8; };
173 
174 template <>
176 { static const GT_Storage value = GT_STORE_UINT8; };
177 
178 template <>
180 { static const GT_Storage value = GT_STORE_INT8; };
181 
182 template <>
184 { static const GT_Storage value = GT_STORE_INT16; };
185 
186 template <>
188 { static const GT_Storage value = GT_STORE_INT32; };
189 
190 template <>
192 { static const GT_Storage value = GT_STORE_INT64; };
193 
194 template <>
196 { static const GT_Storage value = GT_STORE_REAL16; };
197 
198 template <>
200 { static const GT_Storage value = GT_STORE_REAL16; };
201 
202 template <>
204 { static const GT_Storage value = GT_STORE_REAL32; };
205 
206 template <>
208 { static const GT_Storage value = GT_STORE_REAL64; };
209 
211 
212 #endif // __GUSD_GT_UTILS_H__
213 
GT_Storage
Definition: GT_Types.h:19
static bool setPrimvarSample(const UsdGeomImageable &usdPrim, const TfToken &name, const GT_DataArrayHandle &data, const TfToken &interpolation, UsdTimeCode time)
GUSD_API void setPattern(GT_Owner owner, const std::string &pattern)
int int32
Definition: SYS_Types.h:39
static constexpr UsdTimeCode Default()
Definition: timeCode.h:112
static GT_DataArrayHandle transformPoints(GT_DataArrayHandle pts, const GfMatrix4d &objXform)
GT_API const UT_StringHolder time
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
GT_Type
Definition: GT_Types.h:36
GUSD_API GusdGT_AttrFilter(const std::string &pattern="*")
float fpreal32
Definition: SYS_Types.h:200
static GT_DataArrayHandle getTransformArray(const GT_PrimitiveHandle &gtPrim)
static TfToken getRole(GT_Type type)
Returns the USD role name corresponding to the given GT type.
double fpreal64
Definition: SYS_Types.h:201
unsigned char uint8
Definition: SYS_Types.h:36
GUSD_API bool matches(const std::string &str) const
GUSD_API void appendPattern(GT_Owner owner, const std::string &pattern)
Definition: token.h:87
static GT_DataArrayHandle getPackedTransformArray(const GT_PrimitiveHandle &gtPrim)
long long int64
Definition: SYS_Types.h:116
GUSD_API void setActiveOwners(const OwnerArgs &owners) const
static std::string makeValidIdentifier(const TfToken &usdFilePath, const SdfPath &nodePath)
GLuint const GLchar * name
Definition: glcorearb.h:786
signed char int8
Definition: SYS_Types.h:35
Definition: path.h:290
GLushort pattern
Definition: glad.h:2583
static GT_DataArrayHandle getExtentsArray(const GT_PrimitiveHandle &gtPrim)
GT_Owner
Definition: GT_Types.h:90
static bool setTransformFromGTArray(const UsdGeomXformable &usdGeom, const GT_DataArrayHandle &xform, const TransformLevel transformLevel, UsdTimeCode time=UsdTimeCode::Default())
static bool isDataConstant(const GT_DataArrayHandle &data)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
static GfMatrix4d getMatrixFromGTArray(const GT_DataArrayHandle &xform)
short int16
Definition: SYS_Types.h:37
static GT_AttributeListHandle getAttributesFromPrim(const GEO_Primitive *prim)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
static void setCustomAttributesFromGTPrim(const UsdGeomImageable &usdGeomPrim, const GT_AttributeListHandle &gtAttrs, std::set< std::string > &excludeSet, UsdTimeCode time=UsdTimeCode::Default())
#define GUSD_API
Definition: api.h:40
Definition: core.h:1131
static bool setUsdAttribute(const UsdAttribute &destAttr, const GT_DataArrayHandle &sourceAttr, UsdTimeCode time=UsdTimeCode::Default())
static GT_Type getType(const SdfValueTypeName &typeName)
Returns the GT_Type corresponding to a USD type.
type
Definition: core.h:1059
Definition: format.h:895
UT_VariadicT< GT_Owner > OwnerArgs
Definition: GT_Utils.h:59