HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
attribListsBuilder.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5 */
6 
7 #ifndef GUSD_ATTRIBLISTSBUILDER_H
8 #define GUSD_ATTRIBLISTSBUILDER_H
9 
10 #include "api.h"
11 
12 #include <GT/GT_Handles.h>
13 #include <GT/GT_Types.h>
14 #include <UT/UT_SmallArray.h>
15 #include <UT/UT_StringArray.h>
16 #include <UT/UT_StringHolder.h>
17 
18 #include <pxr/pxr.h>
19 
21 
22 struct GusdPrimvarInfo;
23 
24 /// Utility for efficiently building the GT_AttributeList for each owner type.
26 {
27 public:
28  /// Enable collecting point attributes and configure the required number of
29  /// entries for the arrays.
30  void enablePointAttribs(exint num_points);
31 
32  /// Enable collecting vertex attributes and configure the required number of
33  /// entries for the arrays.
34  void enableVertexAttribs(exint num_vertices);
35 
36  /// Enable collecting uniform attributes and configure the required number
37  /// of entries for the arrays.
38  void enableUniformAttribs(exint num_uniform);
39 
40  /// Enable collecting constant / detail attributes.
41  void enableDetailAttribs();
42 
43  /// Add an attribute to the appropriate owner's list.
44  /// (Note, for example, that constant attribs may be promoted down to prim
45  /// or point attributes for merging multiple prims).
46  /// This may fail if, for example, the data array doesn't match the
47  /// required number of entries, or if the owner type is not enabled.
48  bool add(const GusdPrimvarInfo &info, const GT_DataArrayHandle &data);
49 
50  /// Build the GT_AttributeList for point attributes. This may return nullptr
51  /// if there aren't any attributes.
52  GT_AttributeListHandle buildPointAttribs() const;
53 
54  /// Build the GT_AttributeList for vertex attributes. This may return
55  /// nullptr if there aren't any attributes.
56  GT_AttributeListHandle buildVertexAttribs() const;
57 
58  /// Build the GT_AttributeList for uniform attributes. This may return
59  /// nullptr if there aren't any attributes.
60  GT_AttributeListHandle buildUniformAttribs() const;
61 
62  /// Build the GT_AttributeList for detail attributes. This may return
63  /// nullptr if there aren't any attributes.
64  GT_AttributeListHandle buildDetailAttribs();
65 
66 private:
67  /// Record the attribute in the appropriate usdconfig* attribute(s).
68  void recordUsdConfigAttribs(const GusdPrimvarInfo &info);
69 
70  /// Builder implementation for a single GT_AttributeList.
71  class GUSD_API ListBuilder
72  {
73  public:
74  void enable(exint min_entries);
75 
76  bool isEnabled() const { return myEnabled; }
77  exint getMinEntries() const { return myMinEntries; }
78 
79  bool add(const GusdPrimvarInfo &info, const GT_DataArrayHandle &data);
80 
81  GT_AttributeListHandle makeList() const;
82 
83  private:
84  bool myEnabled = false;
85  exint myMinEntries = 0;
88  };
89 
90  ListBuilder myPointAttribs;
91  ListBuilder myVertexAttribs;
92  ListBuilder myUniformAttribs;
93  ListBuilder myDetailAttribs;
94 
95  /// @{
96  /// To correctly round-trip certain attribute types back to USD, we add
97  /// configuration attributes such as `usdconfigboolattribs` to the geometry
98  /// to indicate how they should be handled by the SOP Import LOP.
99  UT_StringArray myConstantAttribs;
100  UT_StringArray myScalarConstantAttribs;
101  UT_StringArray myBoolAttribs;
102  UT_StringArray myUIntAttribs;
103  UT_StringArray myUInt64Attribs;
104  UT_StringArray myAssetPathAttribs;
105  UT_StringArray myIndexedAttribs;
106  /// @}
107 };
108 
110 
111 #endif
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
Utility for efficiently building the GT_AttributeList for each owner type.
int64 exint
Definition: SYS_Types.h:125
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
#define GUSD_API
Definition: api.h:42
ImageBuf OIIO_API add(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
Definition: format.h:1821