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 
41 #include BOOST_HEADER(function.hpp)
42 
44 
45 class GfMatrix4d;
46 class GusdContext;
47 class SdfPath;
48 class SdfValueTypeName;
49 class TfToken;
50 class UsdAttribute;
51 class UsdGeomBoundable;
52 class UsdGeomImageable;
53 class UsdGeomXformable;
54 
55 //------------------------------------------------------------------------------
56 // class GusdGT_AttrFilter
57 //------------------------------------------------------------------------------
59 {
60 public:
62 
63 public:
64 
65  GUSD_API
66  explicit GusdGT_AttrFilter(const std::string& pattern="*");
67 
68  GUSD_API
70 
71  GUSD_API
72  void setPattern(GT_Owner owner, const std::string& pattern);
73 
74  GUSD_API
75  void appendPattern(GT_Owner owner, const std::string& pattern);
76 
77  GUSD_API
78  bool matches(const std::string& str) const;
79 
80  GUSD_API
81  void setActiveOwners(const OwnerArgs& owners) const;
82 
83 private:
85 
86  std::string m_overridePattern;
87 
88  mutable OwnerArgs m_activeOwners;
89 };
90 
91 //------------------------------------------------------------------------------
92 // class GusdGT_Utils
93 //------------------------------------------------------------------------------
95 {
96 public:
100 
102  };
103 
104 public:
105 
106  /// Returns the GT_Type corresponding to a USD type.
107  static GT_Type getType(const SdfValueTypeName& typeName);
108 
109  /// Returns the USD role name corresponding to the given GT type.
110  static TfToken getRole(GT_Type type);
111 
112  static bool setUsdAttribute(const UsdAttribute& destAttr,
113  const GT_DataArrayHandle& sourceAttr,
115 
117 
118  static bool setPrimvarSample( const UsdGeomImageable& usdPrim,
119  const TfToken &name,
120  const GT_DataArrayHandle& data,
121  const TfToken& interpolation,
122  UsdTimeCode time );
123 
124  static bool isDataConstant( const GT_DataArrayHandle& data );
125 
126  static void setCustomAttributesFromGTPrim(
127  const UsdGeomImageable &usdGeomPrim,
128  const GT_AttributeListHandle& gtAttrs,
129  std::set<std::string>& excludeSet,
131 
132 
133  // TODO remove
134  static bool setTransformFromGTArray(const UsdGeomXformable& usdGeom,
135  const GT_DataArrayHandle& xform,
136  const TransformLevel transformLevel,
138 
139  static GT_DataArrayHandle
140  getTransformArray(const GT_PrimitiveHandle& gtPrim);
141 
142  static GT_DataArrayHandle
144 
146 
147  static GT_DataArrayHandle
149  GT_DataArrayHandle pts,
150  const GfMatrix4d& objXform );
151 
152  static GT_DataArrayHandle
154  GT_DataArrayHandle pts,
155  const UT_Matrix4D& objXform );
156 
158  getAttributesFromPrim( const GEO_Primitive *prim );
159 
160  static std::string
161  makeValidIdentifier(const TfToken& usdFilePath, const SdfPath& nodePath);
162 
163 
164  /// Struct for querying storage by POD type.
165  /// XXX: replace this with a constexpr in C++11.
166  template <typename T>
168 };
169 //------------------------------------------------------------------------------
170 
171 
172 template <>
174 { static const GT_Storage value = GT_STORE_UINT8; };
175 
176 template <>
178 { static const GT_Storage value = GT_STORE_UINT8; };
179 
180 template <>
182 { static const GT_Storage value = GT_STORE_INT8; };
183 
184 template <>
186 { static const GT_Storage value = GT_STORE_INT16; };
187 
188 template <>
190 { static const GT_Storage value = GT_STORE_INT32; };
191 
192 template <>
194 { static const GT_Storage value = GT_STORE_INT64; };
195 
196 template <>
198 { static const GT_Storage value = GT_STORE_REAL16; };
199 
200 template <>
202 { static const GT_Storage value = GT_STORE_REAL16; };
203 
204 template <>
206 { static const GT_Storage value = GT_STORE_REAL32; };
207 
208 template <>
210 { static const GT_Storage value = GT_STORE_REAL64; };
211 
213 
214 #endif // __GUSD_GT_UTILS_H__
215 
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:291
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:1441
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:61