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;
33 
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  static bool reload(const UT_StringRef &filepath, bool recursive);
48 
49  bool isStageValid() const;
50  bool getStageRootLayer(UT_StringHolder &identifier) const;
51 
52  // Returns the identifiers and a human readable name for all sublayers of
53  // the stage root layer in strongest to weakest order.
54  bool getSourceLayers(UT_StringArray &names,
55  UT_StringArray &identifiers,
56  UT_IntArray &anonymous,
57  UT_IntArray &fromsops) const;
58  bool getLayerHierarchy(UT_InfoTree &hierarchy) const;
59  bool getLayerSavePath(UT_StringHolder &savepath) const;
60 
61  // Check if the layer specified by the file path can be found. Uses the
62  // stage's resolver context if this object was created with a lock.
63  bool getLayerExists(const UT_StringRef &filepath) const;
64 
65  // Layer information
66  bool getStartTimeCode(fpreal64 &starttimecode) const;
67  bool getEndTimeCode(fpreal64 &endtimecode) const;
68  bool getFramesPerSecond(fpreal64 &fps) const;
69  bool getTimeCodesPerSecond(fpreal64 &tcs) const;
70  bool getMetrics(UT_StringHolder &upaxis,
71  fpreal64 &metersperunit) const;
72  UT_StringHolder getCurrentRenderSettings() const;
73  bool getAllRenderSettings(UT_StringArray &paths) const;
74 
75  // General primitive information (parent, children, kinds)
76  bool isPrimAtPath(const UT_StringRef &primpath,
77  const UT_StringRef &prim_type =
79  bool isActive(const UT_StringRef &primpath) const;
80  bool isVisible(const UT_StringRef &primpath,
81  const HUSD_TimeCode &time_code,
82  HUSD_TimeSampling *time_sampling=nullptr) const;
83  bool isInstance(const UT_StringRef &primpath) const;
84  UT_StringHolder getKind(const UT_StringRef &primpath) const;
85  bool isKind(const UT_StringRef &primpath,
86  const UT_StringRef &kind) const;
87  UT_StringHolder getPrimType(const UT_StringRef &primpath) const;
88  bool isPrimType(const UT_StringRef &primpath,
89  const UT_StringRef &type) const;
90  bool hasPrimAPI(const UT_StringRef &primpath,
91  const UT_StringRef &api) const;
92  bool hasPayload(const UT_StringRef &primpath) const;
93  UT_StringHolder getPurpose(const UT_StringRef &primpath) const;
94  UT_StringHolder getDrawMode(const UT_StringRef &primpath) const;
95  UT_StringHolder getAutoParentPrimKind(
96  const UT_StringRef &primpath) const;
97  bool hasChildren(const UT_StringRef &primpath) const;
98  void getChildren(const UT_StringRef &primpath,
99  UT_StringArray &childnames) const;
100 
101  UT_StringHolder getAncestorOfKind(const UT_StringRef &primpath,
102  const UT_StringRef &kind) const;
103  UT_StringHolder getAncestorInstanceRoot(
104  const UT_StringRef &primpath) const;
105 
106  // Attributes
107  enum class QueryAspect
108  {
109  ANY, // Any attribute
110  ARRAY // Attribute of som array type.
111  };
112  // Checks existence or property of a prim's attribute.
113  bool isAttribAtPath(const UT_StringRef &attribpath,
114  QueryAspect query = QueryAspect::ANY) const;
115  bool isAttribAtPath(const UT_StringRef &primpath,
116  const UT_StringRef &attribname,
117  QueryAspect query = QueryAspect::ANY) const;
118 
119  // Length of array attributes (1 for non-arrays).
120  exint getAttribLength(const UT_StringRef &attribpath,
121  const HUSD_TimeCode &time_code,
122  HUSD_TimeSampling *time_sampling=nullptr) const;
123  exint getAttribLength(const UT_StringRef &primpath,
124  const UT_StringRef &attribname,
125  const HUSD_TimeCode &time_code,
126  HUSD_TimeSampling *time_sampling=nullptr) const;
127 
128  // Tuple size of attributes (eg, 2,3,4 for vectors, 1 for scalars)
129  // For array attributes, returns the tuple size of contained element type.
130  exint getAttribSize(const UT_StringRef &attribpath) const;
131  exint getAttribSize(const UT_StringRef &primpath,
132  const UT_StringRef &attribname) const;
133 
134  // Returns the name of the attribute type (eg, "float", "double3[]").
135  // Note, this is different than attribute value type name (eg, "GfVec3d")
136  UT_StringHolder getAttribTypeName(const UT_StringRef &attrpath) const;
137  UT_StringHolder getAttribTypeName(const UT_StringRef &primpath,
138  const UT_StringRef &attribname) const;
139 
140  // Time samples array (may be empty)
141  bool getAttribTimeSamples(const UT_StringRef &attribpath,
142  UT_FprealArray &time_samples) const;
143  bool getAttribTimeSamples(const UT_StringRef &primpath,
144  const UT_StringRef &attribname,
145  UT_FprealArray &time_samples) const;
146 
147  // Transforms
148  UT_Matrix4D getLocalXform(const UT_StringRef &primpath,
149  const HUSD_TimeCode &time_code,
150  HUSD_TimeSampling *time_sampling=nullptr) const;
151  UT_Matrix4D getWorldXform(const UT_StringRef &primpath,
152  const HUSD_TimeCode &time_code,
153  HUSD_TimeSampling *time_sampling=nullptr) const;
154  UT_Matrix4D getParentXform(const UT_StringRef &primpath,
155  const HUSD_TimeCode &time_code,
156  HUSD_TimeSampling *time_sampling=nullptr) const;
157  bool getXformOrder(const UT_StringRef &primpath,
158  UT_StringArray &xform_order) const;
159  bool isXformReset(const UT_StringRef &primpath ) const;
160 
161  UT_StringHolder findXformName(const UT_StringRef &primpath,
162  const UT_StringRef &xform_name_suffix) const;
163  UT_StringHolder getUniqueXformName(const UT_StringRef &primpath,
164  HUSD_XformType type,
165  const UT_StringRef &xform_name_suffix) const;
166 
167  static const UT_StringHolder &getTransformAttribName();
168  static const UT_StringHolder &getTimeVaryingAttribName();
169  void getAttributeNames(const UT_StringRef &primpath,
170  UT_ArrayStringSet &attrib_names) const;
171  void extractAttributes(const UT_StringRef &primpath,
172  const UT_ArrayStringSet &which_attribs,
173  const HUSD_TimeCode &tc,
175  HUSD_TimeSampling *time_sampling=nullptr) const;
176 
177  // Bounds
178  UT_BoundingBoxD getBounds(const UT_StringRef &primpath,
179  const UT_StringArray &purposes,
180  const HUSD_TimeCode &time_code) const;
181 
182  // Point Instancers
183  bool getPointInstancerXforms( const UT_StringRef &primpath,
184  UT_Array<UT_Matrix4D> &xforms,
185  const HUSD_TimeCode &time_code);
186  UT_BoundingBoxD getPointInstancerBounds(const UT_StringRef &primpath,
187  exint instance_index,
188  const UT_StringArray &purposes,
189  const HUSD_TimeCode &time_code) const;
190 
191  // Variants
192  bool getVariantSets(const UT_StringRef &primpath,
193  UT_StringArray &vset_names) const;
194  bool getVariants(const UT_StringRef &primpath,
195  const UT_StringRef &variantset,
196  UT_StringArray &vset_names) const;
197  UT_StringHolder getVariantSelection(const UT_StringRef &primpath,
198  const UT_StringRef &variantset) const;
199 
200  // Collections
201  bool isCollectionAtPath(
202  const UT_StringRef &collectionpath) const;
203  UT_StringHolder getCollectionExpansionRule(
204  const UT_StringRef &collectionpath) const;
205  bool getCollectionIncludePaths(
206  const UT_StringRef &collectionpath,
207  UT_StringArray &primpaths) const;
208  bool getCollectionExcludePaths(
209  const UT_StringRef &collectionpath,
210  UT_StringArray &primpaths) const;
211  bool getCollectionComputedPaths(
212  const UT_StringRef &collectionpath,
213  UT_StringArray &primpaths) const;
214  bool collectionContains(
215  const UT_StringRef &collectionpath,
216  const UT_StringRef &primpath) const;
217  bool getCollections(const UT_StringRef &primpath,
218  UT_ArrayStringSet &collection_paths) const;
219 
220  // Materials
221  UT_StringHolder getBoundMaterial(const UT_StringRef &primpath) const;
222 
223  // Primvars
224  bool isPrimvarAtPath(const UT_StringRef &primpath,
225  const UT_StringRef &primvarname,
226  QueryAspect query = QueryAspect::ANY) const;
227  void getPrimvarNames(const UT_StringRef &primpath,
228  UT_ArrayStringSet &primvar_names) const;
229  exint getPrimvarLength(const UT_StringRef &primpath,
230  const UT_StringRef &primvarname,
231  const HUSD_TimeCode &time_code,
232  HUSD_TimeSampling *time_sampling=nullptr) const;
233  exint getPrimvarSize(const UT_StringRef &primpath,
234  const UT_StringRef &primvarname) const;
235  UT_StringHolder getPrimvarTypeName(const UT_StringRef &primpath,
236  const UT_StringRef &primvarname) const;
237  bool getPrimvarTimeSamples(const UT_StringRef &primpath,
238  const UT_StringRef &primvarname,
239  UT_FprealArray &time_samples) const;
240 
241  // Relationships
242  void getRelationshipNames(const UT_StringRef &primpath,
243  UT_ArrayStringSet &rel_names) const;
244 
245  bool isRelationshipAtPath(
246  const UT_StringRef &relpath) const;
247  bool isRelationshipAtPath(const UT_StringRef &primpath,
248  const UT_StringRef &relationahipname) const;
249 
250  bool getRelationshipTargets (
251  const UT_StringRef &relpath,
252  UT_StringArray &target_paths) const;
253  bool getRelationshipTargets (
254  const UT_StringRef &primpath,
255  const UT_StringRef &relationshipname,
256  UT_StringArray &target_paths) const;
257 
258  bool getRelationshipForwardedTargets (
259  const UT_StringRef &relpath,
260  UT_StringArray &target_paths) const;
261  bool getRelationshipForwardedTargets (
262  const UT_StringRef &primpath,
263  const UT_StringRef &relationshipname,
264  UT_StringArray &target_paths) const;
265 
266  // Metadata
267  void getMetadataNames(const UT_StringRef &object_path,
268  UT_ArrayStringSet &metadata_names) const;
269  bool isMetadataAtPath(const UT_StringRef &object_path,
270  const UT_StringRef &metadata_name,
271  QueryAspect query = QueryAspect::ANY) const;
272  exint getMetadataLength(const UT_StringRef &object_path,
273  const UT_StringRef &metadata_name) const;
274 
275  // Access information from the active layer, rather than the stage.
276  bool isActiveLayerPrimAtPath(const UT_StringRef &primpath,
277  const UT_StringRef &prim_type =
279  // Returns the identifiers and a human readable name for all sublayers of
280  // the active layer in strongest to weakest order.
281  bool getActiveLayerSubLayers(UT_StringArray &names,
282  UT_StringArray &identifiers,
283  UT_IntArray &anonymous,
284  UT_IntArray &fromsops) const;
285 
286 private:
287  HUSD_AutoAnyLock *myAnyLock;
288 };
289 
290 #endif
291 
GLuint const GLchar * name
Definition: glew.h:1814
Axis-aligned bounding box (AABB).
Definition: GEO_Detail.h:43
GLint GLsizei const GLuint64 * values
Definition: glew.h:3612
#define HUSD_API
Definition: HUSD_API.h:32
GLenum query
Definition: glew.h:5704
int64 exint
Definition: SYS_Types.h:120
static const UT_StringHolder theEmptyString
double fpreal64
Definition: SYS_Types.h:196
HUSD_XformType
Definition: HUSD_Utils.h:178
HUSD_TimeSampling
Definition: HUSD_Utils.h:82
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:42
const GLfloat * tc
Definition: glew.h:16304
GEO_API int getPrimType(const TypeMask &mask)
GLenum const void * paths
Definition: glew.h:13589