All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
utils.h
1 //
2 // Copyright 2018 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 
25 #ifndef USDMTLX_UTILS_H
26 #define USDMTLX_UTILS_H
27 
28 #include "pxr/pxr.h"
29 #include "pxr/usd/usdMtlx/api.h"
30 #include "pxr/usd/ndr/declare.h"
31 #include "pxr/usd/sdf/valueTypeName.h"
32 #include "pxr/base/vt/value.h"
33 #include <MaterialXCore/Document.h>
34 #include <string>
35 #include <vector>
36 
37 PXR_NAMESPACE_OPEN_SCOPE
38 
42 USDMTLX_LOCAL
43 NdrStringVec
44 UsdMtlxGetSearchPathsFromEnvVar(const char* name);
45 
47 USDMTLX_LOCAL
48 NdrStringVec
49 UsdMtlxMergeSearchPaths(const NdrStringVec& stronger,
50  const NdrStringVec& weaker);
51 
55 USDMTLX_LOCAL
56 NdrStringVec
57 UsdMtlxStandardLibraryPaths();
58 
60 USDMTLX_LOCAL
61 NdrStringVec
62 UsdMtlxStandardFileExtensions();
63 
68 USDMTLX_LOCAL
69 MaterialX::ConstDocumentPtr
70 UsdMtlxGetDocument(const std::string& resolvedUri);
71 
74 USDMTLX_LOCAL
75 MaterialX::ConstDocumentPtr
76 UsdMtlxGetDocumentFromString(const std::string &mtlxXml);
77 
78 // Return the version of the mtlx element. If the version cannot be
79 // found then return an invalid default version. If implicitDefault
80 // isn't null then we do to two things: we set implicitDefault to
81 // false iff the isdefaultversion attribute exists and isn't empty,
82 // otherwise we set it to true; and we return the version as a
83 // default if isdefaultversion exists and is set to "true".
84 USDMTLX_LOCAL
85 NdrVersion
86 UsdMtlxGetVersion(const MaterialX::ConstElementPtr& mtlx,
87  bool* implicitDefault = nullptr);
88 
93 USDMTLX_LOCAL
94 const std::string&
95 UsdMtlxGetSourceURI(const MaterialX::ConstElementPtr& element);
96 
103  : valueTypeName(valueTypeName)
104  , shaderPropertyType(shaderPropertyType)
105  , valueTypeNameIsExact(valueTypeNameIsExact)
106  { }
107 
112 
116 
120 };
121 
123 USDMTLX_LOCAL
125 UsdMtlxGetUsdType(const std::string& mtlxTypeName);
126 
132 USDMTLX_LOCAL
133 VtValue
134 UsdMtlxGetUsdValue(const MaterialX::ConstElementPtr& mtlx,
135  bool getDefaultValue = false);
136 
139 USDMTLX_LOCAL
140 std::vector<VtValue>
141 UsdMtlxGetPackedUsdValues(const std::string& values, const std::string& type);
142 
152 USDMTLX_LOCAL
153 std::vector<std::string>
154 UsdMtlxSplitStringArray(const std::string& s);
155 
156 PXR_NAMESPACE_CLOSE_SCOPE
157 
158 #endif // USDMTLX_UTILS_H
Represents a value type name, i.e.
Definition: valueTypeName.h:83
TfToken shaderPropertyType
The exact SdrShaderProperty type name.
Definition: utils.h:115
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
SdfValueTypeName valueTypeName
The value type name that most closely matches the MaterialX type.
Definition: utils.h:111
Result of UsdMtlxGetUsdType().
Definition: utils.h:98
bool valueTypeNameIsExact
true iff the value type name is an exact match to the MaterialX type.
Definition: utils.h:119
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:182