utils.h
1 //
2 // Copyright 2018 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_USD_USDMTLX_UTILS_H
9 #define PXR_USD_USDMTLX_UTILS_H
10 
11 #include "pxr/pxr.h"
12 #include "pxr/usd/usdMtlx/api.h"
13 #include "pxr/usd/sdr/declare.h"
14 #include "pxr/usd/sdf/valueTypeName.h"
16 #include "pxr/base/vt/value.h"
17 #include <MaterialXCore/Document.h>
18 #include <string>
19 #include <vector>
20 
21 PXR_NAMESPACE_OPEN_SCOPE
22 
26 USDMTLX_API
27 const SdrStringVec&
28 UsdMtlxStandardLibraryPaths();
29 
32 USDMTLX_API
33 const SdrStringVec&
34 UsdMtlxCustomSearchPaths();
35 
41 USDMTLX_API
42 const SdrStringVec&
43 UsdMtlxSearchPaths();
44 
46 USDMTLX_API
47 SdrStringVec
48 UsdMtlxStandardFileExtensions();
49 
55 USDMTLX_API
56 MaterialX::DocumentPtr
57 UsdMtlxReadDocument(const std::string& resolvedPath);
58 
63 USDMTLX_API
64 MaterialX::ConstDocumentPtr
65 UsdMtlxGetDocument(const std::string& resolvedUri);
66 
69 USDMTLX_API
70 MaterialX::ConstDocumentPtr
71 UsdMtlxGetDocumentFromString(const std::string &mtlxXml);
72 
73 // Return the version of the mtlx element. If the version cannot be
74 // found then return an invalid default version. If implicitDefault
75 // isn't null then we do to two things: we set implicitDefault to
76 // false iff the isdefaultversion attribute exists and isn't empty,
77 // otherwise we set it to true; and we return the version as a
78 // default if isdefaultversion exists and is set to "true".
79 USDMTLX_API
81 UsdMtlxGetVersion(const MaterialX::ConstInterfaceElementPtr& mtlx,
82  bool* implicitDefault = nullptr);
83 
88 USDMTLX_API
89 const std::string&
90 UsdMtlxGetSourceURI(const MaterialX::ConstElementPtr& element);
91 
98  int arraySize=0)
103  { }
104 
109 
113 
117 
121 };
122 
124 USDMTLX_API
126 UsdMtlxGetUsdType(const std::string& mtlxTypeName);
127 
133 USDMTLX_API
134 VtValue
135 UsdMtlxGetUsdValue(const MaterialX::ConstElementPtr& mtlx,
136  bool getDefaultValue = false);
137 
140 USDMTLX_API
141 std::vector<VtValue>
142 UsdMtlxGetPackedUsdValues(const std::string& values, const std::string& type);
143 
153 USDMTLX_API
154 std::vector<std::string>
155 UsdMtlxSplitStringArray(const std::string& s);
156 
157 PXR_NAMESPACE_CLOSE_SCOPE
158 
159 #endif // PXR_USD_USDMTLX_UTILS_H
Represents a value type name, i.e.
Definition: valueTypeName.h:71
SdrVersion.
Definition: declare.h:67
TfToken shaderPropertyType
The exact SdrShaderProperty type name.
Definition: utils.h:112
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:80
This file defines some macros that are useful for declaring and using static TfTokens.
int arraySize
If the value type is a fixed-size array/tuple, this will be greater then zero.
Definition: utils.h:116
SdfValueTypeName valueTypeName
The value type name that most closely matches the MaterialX type.
Definition: utils.h:108
Result of UsdMtlxGetUsdType().
Definition: utils.h:93
bool valueTypeNameIsExact
true iff the value type name is an exact match to the MaterialX type.
Definition: utils.h:120
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:89