HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HUSD_Utils.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Side Effects Software Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #ifndef __HUSD_Utils_h__
19 #define __HUSD_Utils_h__
20 
21 #include "HUSD_API.h"
22 #include <UT/UT_StringHolder.h>
23 
24 class HUSD_TimeCode;
25 class UT_String;
26 class OP_Node;
27 
34 
35  // By default, we only require that a primitive be "defined", meaning it
36  // is a fully instantiated prim, not just an "over" with an incomplete set
37  // of attributes and metadata.
40 };
41 
42 // This enum specifies how a reference or sublayer or payload file reference
43 // is stored in the referring layer. The AUTO method stores paths specified
44 // as relative paths as relative paths, and paths specified as absolute paths
45 // as absolute paths. Paths specified as Search Paths (neither relative nor
46 // absolute) are always saved as-is.
48 {
52 };
53 
54 // This is the order of the viewport overrides layers. Note that they are
55 // ordered strongest to weakest, so the "solo" layers override the base layer,
56 // and the "custom" layer overrides the "solo" layers.
62 };
63 #define HUSD_OVERRIDES_NUM_LAYERS 4
64 
65 // Enum valus that correspond to the SdfVariability values in the USD library.
70 };
71 
72 // Enum describing possible behaviors when layers are stripped off because of
73 // a layer break operation.
78 };
79 
80 // Enum describing the possible time sampling levels.
81 enum class HUSD_TimeSampling {
82  NONE, // no time samples; just the default value (not time varying)
83  SINGLE, // single time sample exists (value is not really time varying)
84  MULTIPLE // more than one time sample exists (value may be time varying)
85 };
86 
87 // Configures the USD library for use within Houdini. The primary purpose is to
88 // set the prefered ArResolver to be the Houdini resolver. This should be
89 // called as soon as possible after loading the HUSD library.
90 HUSD_API void
92 
93 // Modifies the passed in string to make sure it conforms to USD primitive
94 // naming restrictions. Illegal characters are replaced by underscores.
95 HUSD_API bool
96 HUSDmakeValidUsdName(UT_String &name, bool addwarnings);
97 
98 // Returns the name of the node passed through the HUSDmakeValidUsdName method.
99 // This saves several lines of code every time we use this pattern.
102 
103 // Modifies the passed in string to make sure it conforms to USD primitive
104 // naming restrictions. Illegal characters are replaced by underscores. Each
105 // path component is validated separately.
106 HUSD_API bool
107 HUSDmakeValidUsdPath(UT_String &path, bool addwarnings);
108 // Like the above method, but accepts "defaultPrim" as well.
109 HUSD_API bool
111 
112 // Returns the path of the node passed through the HUSDmakeValidUsdPath method.
113 // This saves several lines of code every time we use this pattern.
116 
117 // Modifies the passed in string to make sure it conforms to USD property
118 // naming restrictions. This includes allowing multiple nested namespaces
119 // in the name. Illegal characters are replaced by underscores.
120 HUSD_API bool
121 HUSDmakeValidUsdPropertyName(UT_String &name, bool addwarnings);
122 
123 // Modifies the passed in string to make sure it conforms to USD variant
124 // naming restrictions. Note that these are different from normal primitive
125 // naming conventions, as defined in SdfSchemaBase::IsValidVariantIdentifier:
126 // One or more letter, number, '_', '|', or '-', with an optional leading '.'
127 // Illegal characters are replaced by underscores.
128 HUSD_API bool
129 HUSDmakeValidVariantName(UT_String &name, bool addwarnings);
130 
131 // Modifies the passed in string to make sure it conforms to USD primitive
132 // naming restrictions. Leading slashes are thrown away. Illegal characters
133 // are considered an error and cause this function to return false.
134 HUSD_API bool
135 HUSDmakeValidDefaultPrim(UT_String &default_prim, bool addwarnings);
136 
137 // Returns primitive name, given the primitive path.
139 HUSDgetUsdName(const UT_StringRef &primpath);
140 
141 // Returns primitive's parent path, given the primitive path.
143 HUSDgetUsdParentPath(const UT_StringRef &primpath);
144 
145 // Return the primary alias for the specified USD primitive type.
147 HUSDgetPrimTypeAlias(const UT_StringRef &primtype);
148 
149 // If layers are stripped during a flatten operation, this function handles
150 // the error creation based on the requested response. Returns true of the
151 // requested response is to generate an error, which usually means we should
152 // also stop processing.
153 HUSD_API bool
155 
156 /// Enum of USD transform operation types.
157 /// Note, they need to correspond to UsgGeomXformOp::Type enum.
158 enum class HUSD_XformType {
162  Orient, Transform
163 };
164 
165 /// Enum of rotation axis.
166 enum class HUSD_XformAxis { X, Y, Z };
167 
168 /// Enum of rotation order.
169 enum class HUSD_XformAxisOrder { XYZ, XZY, YXZ, YZX, ZXY, ZYX };
170 
171 /// @{ Functions for obtaining transform name, suffix, and type.
173  UT_StringHolder &xform_namesuffix,
174  const UT_StringRef& xform_fullname);
178  const UT_StringRef &xform_namesuffix);
180  UT_StringHolder *xform_type = nullptr,
181  UT_StringHolder *xform_name = nullptr);
182 /// @}
183 
184 /// @{ Manipulate collection paths and components. The individual components
185 /// must be validated (see HUSDmakeValidName and HUSDmakeValidPath) before
186 /// calling these methods.
188  const UT_StringRef &collection_name);
190  UT_StringHolder &collection_name,
191  const UT_StringRef &collection_path);
193 /// @}
194 
195 /// @{ Create property paths from their components. The individual components
196 /// must be validated (see HUSDmakeValidName and HUSDmakeValidPath) before
197 /// calling these methods.
199  const UT_StringRef &property_name);
201  const UT_StringRef &attribute_name);
203  const UT_StringRef &relationship_name);
204 /// @}
205 
206 /// Returns the attribute name of the given primvar
208 
209 /// Returns the time code at which to author an attribute value.
211  const HUSD_TimeCode &timecode,
212  HUSD_TimeSampling time_sampling);
213 
214 /// Returns true if there are more than one time samples.
215 HUSD_API bool HUSDisTimeVarying(HUSD_TimeSampling time_sampling);
216 
217 /// Returns true if there is at least one time sample.
218 HUSD_API bool HUSDisTimeSampled(HUSD_TimeSampling time_sampling);
219 
220 #endif
221 
HUSD_API bool HUSDmakeValidDefaultPrim(UT_String &default_prim, bool addwarnings)
GLuint const GLchar * name
Definition: glew.h:1814
HUSD_API UT_StringHolder HUSDmakePropertyPath(const UT_StringRef &prim_path, const UT_StringRef &property_name)
HUSD_API void HUSDinitialize()
HUSD_API UT_StringHolder HUSDgetValidUsdPath(OP_Node &node)
#define HUSD_API
Definition: HUSD_API.h:32
HUSD_API bool HUSDmakeValidUsdPropertyName(UT_String &name, bool addwarnings)
HUSD_API bool HUSDmakeValidUsdPath(UT_String &path, bool addwarnings)
HUSD_API UT_StringHolder HUSDgetUsdName(const UT_StringRef &primpath)
HUSD_PrimTraversalDemands
Definition: HUSD_Utils.h:28
HUSD_XformAxis
Enum of rotation axis.
Definition: HUSD_Utils.h:166
HUSD_OverridesLayerId
Definition: HUSD_Utils.h:57
HUSD_Variability
Definition: HUSD_Utils.h:66
HUSD_API UT_StringHolder HUSDmakeCollectionPath(const UT_StringRef &prim_path, const UT_StringRef &collection_name)
HUSD_API UT_StringHolder HUSDgetUsdParentPath(const UT_StringRef &primpath)
HUSD_XformType
Definition: HUSD_Utils.h:158
HUSD_API bool HUSDmakeValidUsdName(UT_String &name, bool addwarnings)
HUSD_TimeSampling
Definition: HUSD_Utils.h:81
HUSD_API bool HUSDisValidCollectionPath(const UT_StringRef &path)
HUSD_API bool HUSDisXformAttribute(const UT_StringRef &attr, UT_StringHolder *xform_type=nullptr, UT_StringHolder *xform_name=nullptr)
Functions for obtaining transform name, suffix, and type.
HUSD_API UT_StringHolder HUSDmakeRelationshipPath(const UT_StringRef &prim_path, const UT_StringRef &relationship_name)
HUSD_API UT_StringHolder HUSDgetXformSuffix(const UT_StringRef &xform_fullname)
Functions for obtaining transform name, suffix, and type.
HUSD_API bool HUSDgetXformTypeAndSuffix(HUSD_XformType &xform_type, UT_StringHolder &xform_namesuffix, const UT_StringRef &xform_fullname)
Functions for obtaining transform name, suffix, and type.
HUSD_API bool HUSDsplitCollectionPath(UT_StringHolder &prim_path, UT_StringHolder &collection_name, const UT_StringRef &collection_path)
HUSD_StripLayerResponse
Definition: HUSD_Utils.h:74
HUSD_API HUSD_TimeCode HUSDgetEffectiveTimeCode(const HUSD_TimeCode &timecode, HUSD_TimeSampling time_sampling)
Returns the time code at which to author an attribute value.
HUSD_API bool HUSDisTimeVarying(HUSD_TimeSampling time_sampling)
Returns true if there are more than one time samples.
HUSD_API bool HUSDmakeValidUsdPathOrDefaultPrim(UT_String &path, bool addwarnings)
GLsizei const GLchar *const * path
Definition: glew.h:6461
HUSD_API bool HUSDmakeValidVariantName(UT_String &name, bool addwarnings)
HUSD_API UT_StringHolder HUSDmakeAttributePath(const UT_StringRef &prim_path, const UT_StringRef &attribute_name)
HUSD_API UT_StringHolder HUSDgetXformName(HUSD_XformType xform_type, const UT_StringRef &xform_namesuffix)
Functions for obtaining transform name, suffix, and type.
HUSD_XformAxisOrder
Enum of rotation order.
Definition: HUSD_Utils.h:169
HUSD_PathSaveStyle
Definition: HUSD_Utils.h:47
HUSD_API UT_StringHolder HUSDgetPrimvarAttribName(const UT_StringRef &primvar)
Returns the attribute name of the given primvar.
HUSD_API bool HUSDapplyStripLayerResponse(HUSD_StripLayerResponse response)
HUSD_API HUSD_XformType HUSDgetXformType(const UT_StringRef &xform_fullname)
Functions for obtaining transform name, suffix, and type.
HUSD_API bool HUSDisTimeSampled(HUSD_TimeSampling time_sampling)
Returns true if there is at least one time sample.
HUSD_API UT_StringHolder HUSDgetPrimTypeAlias(const UT_StringRef &primtype)
HUSD_API UT_StringHolder HUSDgetValidUsdName(OP_Node &node)