HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HUSD_Info.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_Info_h__
19 #define __HUSD_Info_h__
20 
21 #include "HUSD_API.h"
22 #include "HUSD_DataHandle.h"
23 #include <UT/UT_StringMap.h>
24 #include <UT/UT_ArrayStringSet.h>
25 
26 class HUSD_TimeCode;
27 enum class HUSD_XformType;
28 enum class HUSD_TimeSampling;
29 template <typename T> class UT_BoundingBoxT;
31 class UT_InfoTree;
32 class UT_Options;
34 
36 {
37 public:
38  HUSD_Info();
40  ~HUSD_Info();
41 
42  static bool isArrayValueType(const UT_StringRef &valueType);
43  static bool isTokenArrayValueType(const UT_StringRef &valueType);
44  static bool isPrimvarName(const UT_StringRef &name);
45  static void getPrimitiveKinds(UT_StringArray &kinds);
46  static void getUsdVersionInfo(UT_StringMap<UT_StringHolder> &info);
47 
48  // Get kind hierarchy information.
49  static bool isModelKind(const UT_StringRef &kind);
50  static bool isGroupKind(const UT_StringRef &kind);
51  static bool isComponentKind(const UT_StringRef &kind);
52 
53  // Get basic information from the auto lock used to construct this
54  // info object.
55  bool isStageValid() const;
56  bool getStageRootLayer(UT_StringHolder &identifier) const;
57 
58  // Reload a layer. Does the USD reload and clears Houdini-specific caches
59  // associated with loaded layers. Optionally finds all referenced layers
60  // and also reloads them (recursively).
61  static bool reload(const UT_StringRef &filepath,
62  bool recursive);
63  // Reloads as above, but uses the asset resolver context from the auto lock
64  // used to construct this info object.
65  bool reloadWithContext(const UT_StringRef &filepath,
66  bool recursive) const;
67 
68  // Returns the identifiers and a human readable name for all sublayers of
69  // the stage root layer in strongest to weakest order.
70  bool getSourceLayers(UT_StringArray &names,
71  UT_StringArray &identifiers,
72  UT_IntArray &anonymous,
73  UT_IntArray &fromsops) const;
74  bool getLayerHierarchy(UT_InfoTree &hierarchy) const;
75  bool getLayerSavePath(UT_StringHolder &savepath) const;
76  bool getLayersAboveLayerBreak(
77  UT_StringArray &identifiers) const;
78 
79  // Check if the layer specified by the file path can be found. Uses the
80  // stage's resolver context if this object was created with a lock.
81  bool getLayerExists(const UT_StringRef &filepath) const;
82 
83  // Layer information
84  bool getStartTimeCode(fpreal64 &starttimecode) const;
85  bool getEndTimeCode(fpreal64 &endtimecode) const;
86  bool getFramesPerSecond(fpreal64 &fps) const;
87  bool getTimeCodesPerSecond(fpreal64 &tcs) const;
88  bool getMetrics(UT_StringHolder &upaxis,
89  fpreal64 &metersperunit) const;
90  UT_StringHolder getCurrentRenderSettings() const;
91  bool getAllRenderSettings(UT_StringArray &paths) const;
92 
93  // General primitive information (parent, children, kinds)
94  bool isPrimAtPath(const UT_StringRef &primpath,
95  const UT_StringRef &prim_type =
97  bool isActive(const UT_StringRef &primpath) const;
98  bool isVisible(const UT_StringRef &primpath,
99  const HUSD_TimeCode &time_code,
100  HUSD_TimeSampling *time_sampling=nullptr) const;
101  bool isInstance(const UT_StringRef &primpath) const;
102  UT_StringHolder getKind(const UT_StringRef &primpath) const;
103  bool isKind(const UT_StringRef &primpath,
104  const UT_StringRef &kind) const;
105  UT_StringHolder getPrimType(const UT_StringRef &primpath) const;
106  bool isPrimType(const UT_StringRef &primpath,
107  const UT_StringRef &type) const;
108  bool hasPrimAPI(const UT_StringRef &primpath,
109  const UT_StringRef &api) const;
110  bool hasPayload(const UT_StringRef &primpath) const;
111  UT_StringHolder getIcon(const UT_StringRef &primpath) const;
112  UT_StringHolder getPurpose(const UT_StringRef &primpath) const;
113  UT_StringHolder getDrawMode(const UT_StringRef &primpath) const;
114  UT_StringHolder getAutoParentPrimKind(
115  const UT_StringRef &primpath) const;
116  bool hasChildren(const UT_StringRef &primpath) const;
117  void getChildren(const UT_StringRef &primpath,
118  UT_StringArray &childnames) const;
119 
120  // Gather general statistics about the descendants of a primitive.
122  STATS_SIMPLE_COUNTS = 0x0000,
123  STATS_PURPOSE_COUNTS = 0x0001,
124  STATS_GEOMETRY_COUNTS = 0x0002
125  };
126  void getDescendantStats(const UT_StringRef &primpath,
127  UT_Options &stats,
128  DescendantStatsFlags
129  flags = STATS_SIMPLE_COUNTS) const;
130 
131  UT_StringHolder getAncestorOfKind(const UT_StringRef &primpath,
132  const UT_StringRef &kind) const;
133  UT_StringHolder getAncestorInstanceRoot(
134  const UT_StringRef &primpath) const;
135 
136  // Attributes
137  enum class QueryAspect
138  {
139  ANY, // Any attribute
140  ARRAY // Attribute of som array type.
141  };
142  // Checks existence or property of a prim's attribute.
143  bool isAttribAtPath(const UT_StringRef &attribpath,
144  QueryAspect query = QueryAspect::ANY) const;
145  bool isAttribAtPath(const UT_StringRef &primpath,
146  const UT_StringRef &attribname,
147  QueryAspect query = QueryAspect::ANY) const;
148 
149  // Length of array attributes (1 for non-arrays).
150  exint getAttribLength(const UT_StringRef &attribpath,
151  const HUSD_TimeCode &time_code,
152  HUSD_TimeSampling *time_sampling=nullptr) const;
153  exint getAttribLength(const UT_StringRef &primpath,
154  const UT_StringRef &attribname,
155  const HUSD_TimeCode &time_code,
156  HUSD_TimeSampling *time_sampling=nullptr) const;
157 
158  // Tuple size of attributes (eg, 2,3,4 for vectors, 1 for scalars)
159  // For array attributes, returns the tuple size of contained element type.
160  exint getAttribSize(const UT_StringRef &attribpath) const;
161  exint getAttribSize(const UT_StringRef &primpath,
162  const UT_StringRef &attribname) const;
163 
164  // Returns the name of the attribute type (eg, "float", "double3[]").
165  // Note, this is different than attribute value type name (eg, "GfVec3d")
166  UT_StringHolder getAttribTypeName(const UT_StringRef &attrpath) const;
167  UT_StringHolder getAttribTypeName(const UT_StringRef &primpath,
168  const UT_StringRef &attribname) const;
169 
170  // Time samples array (may be empty)
171  bool getAttribTimeSamples(const UT_StringRef &attribpath,
172  UT_FprealArray &time_samples) const;
173  bool getAttribTimeSamples(const UT_StringRef &primpath,
174  const UT_StringRef &attribname,
175  UT_FprealArray &time_samples) const;
176 
177  // Transforms
178  UT_Matrix4D getLocalXform(const UT_StringRef &primpath,
179  const HUSD_TimeCode &time_code,
180  HUSD_TimeSampling *time_sampling=nullptr) const;
181  UT_Matrix4D getWorldXform(const UT_StringRef &primpath,
182  const HUSD_TimeCode &time_code,
183  HUSD_TimeSampling *time_sampling=nullptr) const;
184  UT_Matrix4D getParentXform(const UT_StringRef &primpath,
185  const HUSD_TimeCode &time_code,
186  HUSD_TimeSampling *time_sampling=nullptr) const;
187  bool getXformOrder(const UT_StringRef &primpath,
188  UT_StringArray &xform_order) const;
189  bool isXformReset(const UT_StringRef &primpath ) const;
190 
191  UT_StringHolder findXformName(const UT_StringRef &primpath,
192  const UT_StringRef &xform_name_suffix) const;
193  UT_StringHolder getUniqueXformName(const UT_StringRef &primpath,
194  HUSD_XformType type,
195  const UT_StringRef &xform_name_suffix) const;
196 
197  static const UT_StringHolder &getTransformAttribName();
198  static const UT_StringHolder &getTimeVaryingAttribName();
199  void getAttributeNames(const UT_StringRef &primpath,
200  UT_ArrayStringSet &attrib_names) const;
201  void extractAttributes(const UT_StringRef &primpath,
202  const UT_ArrayStringSet &which_attribs,
203  const HUSD_TimeCode &tc,
205  HUSD_TimeSampling *time_sampling=nullptr) const;
206 
207  // Bounds
208  UT_BoundingBoxD getBounds(const UT_StringRef &primpath,
209  const UT_StringArray &purposes,
210  const HUSD_TimeCode &time_code) const;
211 
212  // Point Instancers
213  bool getPointInstancerXforms( const UT_StringRef &primpath,
214  UT_Array<UT_Matrix4D> &xforms,
215  const HUSD_TimeCode &time_code);
216  UT_BoundingBoxD getPointInstancerBounds(const UT_StringRef &primpath,
217  exint instance_index,
218  const UT_StringArray &purposes,
219  const HUSD_TimeCode &time_code) const;
220 
221  // Variants
222  bool getVariantSets(const UT_StringRef &primpath,
223  UT_StringArray &vset_names) const;
224  bool getVariants(const UT_StringRef &primpath,
225  const UT_StringRef &variantset,
226  UT_StringArray &vset_names) const;
227  UT_StringHolder getVariantSelection(const UT_StringRef &primpath,
228  const UT_StringRef &variantset) const;
229 
230  // Collections
231  bool isCollectionAtPath(
232  const UT_StringRef &collectionpath) const;
233  UT_StringHolder getCollectionExpansionRule(
234  const UT_StringRef &collectionpath) const;
235  bool getCollectionIncludePaths(
236  const UT_StringRef &collectionpath,
237  UT_StringArray &primpaths) const;
238  bool getCollectionExcludePaths(
239  const UT_StringRef &collectionpath,
240  UT_StringArray &primpaths) const;
241  bool getCollectionComputedPaths(
242  const UT_StringRef &collectionpath,
243  UT_StringArray &primpaths) const;
244  bool collectionContains(
245  const UT_StringRef &collectionpath,
246  const UT_StringRef &primpath) const;
247  bool getCollections(const UT_StringRef &primpath,
249  &collection_info_map) const;
250 
251  // Materials
252  UT_StringHolder getBoundMaterial(const UT_StringRef &primpath) const;
253 
254  // Primvars
255  bool isPrimvarAtPath(const UT_StringRef &primpath,
256  const UT_StringRef &primvarname,
257  QueryAspect query = QueryAspect::ANY) const;
258  void getPrimvarNames(const UT_StringRef &primpath,
259  UT_ArrayStringSet &primvar_names) const;
260  exint getPrimvarLength(const UT_StringRef &primpath,
261  const UT_StringRef &primvarname,
262  const HUSD_TimeCode &time_code,
263  HUSD_TimeSampling *time_sampling=nullptr) const;
264  exint getPrimvarSize(const UT_StringRef &primpath,
265  const UT_StringRef &primvarname) const;
266  UT_StringHolder getPrimvarTypeName(const UT_StringRef &primpath,
267  const UT_StringRef &primvarname) const;
268  bool getPrimvarTimeSamples(const UT_StringRef &primpath,
269  const UT_StringRef &primvarname,
270  UT_FprealArray &time_samples) const;
271 
272  // Relationships
273  void getRelationshipNames(const UT_StringRef &primpath,
274  UT_ArrayStringSet &rel_names) const;
275 
276  bool isRelationshipAtPath(
277  const UT_StringRef &relpath) const;
278  bool isRelationshipAtPath(const UT_StringRef &primpath,
279  const UT_StringRef &relationahipname) const;
280 
281  bool getRelationshipTargets (
282  const UT_StringRef &relpath,
283  UT_StringArray &target_paths) const;
284  bool getRelationshipTargets (
285  const UT_StringRef &primpath,
286  const UT_StringRef &relationshipname,
287  UT_StringArray &target_paths) const;
288 
289  bool getRelationshipForwardedTargets (
290  const UT_StringRef &relpath,
291  UT_StringArray &target_paths) const;
292  bool getRelationshipForwardedTargets (
293  const UT_StringRef &primpath,
294  const UT_StringRef &relationshipname,
295  UT_StringArray &target_paths) const;
296 
297  // Metadata
298  void getMetadataNames(const UT_StringRef &object_path,
299  UT_ArrayStringSet &metadata_names) const;
300  bool isMetadataAtPath(const UT_StringRef &object_path,
301  const UT_StringRef &metadata_name,
302  QueryAspect query = QueryAspect::ANY) const;
303  exint getMetadataLength(const UT_StringRef &object_path,
304  const UT_StringRef &metadata_name) const;
305 
306  // Access information from the active layer, rather than the stage.
307  bool isActiveLayerPrimAtPath(const UT_StringRef &primpath,
308  const UT_StringRef &prim_type =
310  // Returns the identifiers and a human readable name for all sublayers of
311  // the active layer in strongest to weakest order.
312  bool getActiveLayerSubLayers(UT_StringArray &names,
313  UT_StringArray &identifiers,
314  UT_IntArray &anonymous,
315  UT_IntArray &fromsops) const;
316 
317  // Shader parameters.
318  void getShaderInputAttributeNames(
319  const UT_StringRef &primpath,
320  UT_ArrayStringSet &attrib_names) const;
321 
322 private:
323  HUSD_AutoAnyLock *myAnyLock;
324 };
325 
326 #endif
327 
GLuint const GLchar * name
Definition: glew.h:1814
Axis-aligned bounding box (AABB).
Definition: GEO_Detail.h:43
GLenum GLsizei GLsizei GLsizei GLsizei GLbitfield flags
Definition: glew.h:2864
GLint GLsizei const GLuint64 * values
Definition: glew.h:3612
int64 exint
Definition: SYS_Types.h:125
#define HUSD_API
Definition: HUSD_API.h:32
GLenum query
Definition: glew.h:5704
double fpreal64
Definition: SYS_Types.h:201
DescendantStatsFlags
Definition: HUSD_Info.h:121
static const UT_StringHolder theEmptyString
HUSD_XformType
Definition: HUSD_Utils.h:210
HUSD_TimeSampling
Definition: HUSD_Utils.h:83
GLuint const GLuint * names
Definition: glew.h:2690
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1253
A map of string to various well defined value types.
Definition: UT_Options.h:84
const GLfloat * tc
Definition: glew.h:16304
GEO_API int getPrimType(const TypeMask &mask)
UT_StringMap< UT_StringHolder > HUSD_CollectionInfoMap
Definition: HUSD_Info.h:32
GU_API GA_OffsetArray getChildren(GU_Detail *gdp, const GA_Offset &node)
GLenum const void * paths
Definition: glew.h:13589