HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
primvarSchema.h
Go to the documentation of this file.
1 //
2 // Copyright 2023 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 ////////////////////////////////////////////////////////////////////////
8 
9 /* ************************************************************************** */
10 /* ** ** */
11 /* ** This file is generated by a script. ** */
12 /* ** ** */
13 /* ** Do not edit it directly (unless it is within a CUSTOM CODE section)! ** */
14 /* ** Edit hdSchemaDefs.py instead to make changes. ** */
15 /* ** ** */
16 /* ************************************************************************** */
17 
18 #ifndef PXR_IMAGING_HD_PRIMVAR_SCHEMA_H
19 #define PXR_IMAGING_HD_PRIMVAR_SCHEMA_H
20 
21 /// \file
22 
23 #include "pxr/imaging/hd/api.h"
24 
25 #include "pxr/imaging/hd/schema.h"
26 
27 // --(BEGIN CUSTOM CODE: Includes)--
28 // --(END CUSTOM CODE: Includes)--
29 
31 
32 // --(BEGIN CUSTOM CODE: Declares)--
33 // --(END CUSTOM CODE: Declares)--
34 
35 #define HD_PRIMVAR_SCHEMA_TOKENS \
36  (primvarValue) \
37  (indexedPrimvarValue) \
38  (indices) \
39  (interpolation) \
40  (role) \
41  (elementSize) \
42  (transform) \
43  (constant) \
44  (uniform) \
45  (varying) \
46  (vertex) \
47  (faceVarying) \
48  (instance) \
49  (point) \
50  (normal) \
51  (vector) \
52  (color) \
53  (pointIndex) \
54  (edgeIndex) \
55  (faceIndex) \
56  (textureCoordinate) \
57 
58 TF_DECLARE_PUBLIC_TOKENS(HdPrimvarSchemaTokens, HD_API,
60 
61 //-----------------------------------------------------------------------------
62 
63 
64 class HdPrimvarSchema : public HdSchema
65 {
66 public:
67  /// \name Schema retrieval
68  /// @{
69 
70  HdPrimvarSchema(HdContainerDataSourceHandle container)
71  : HdSchema(container) {}
72 
73  /// @}
74 
75 // --(BEGIN CUSTOM CODE: Schema Methods)--
76 
77  // If the primvar does not have indices, GetPrimvarValue() and
78  // GetIndexedPrimvarValue() will return the same thing. If the primvar
79  // does has indices, GetPrimvarValue() will return the flattened value,
80  // while GetIndexedPrimvarValue() will return the unflattened value.
81  HD_API
82  HdSampledDataSourceHandle GetPrimvarValue() const;
83 
84  HD_API
85  HdSampledDataSourceHandle GetIndexedPrimvarValue() const;
86 
87  // Returns true if it contains data sources for an indexed primvar value
88  // and for indices.
89  HD_API
90  bool IsIndexed() const;
91 
92  // If the primvar does not have indices, GetFlattenedPrimvarValue() will
93  // just return the primvarValue data source which is also returned by
94  // GetPrimVarValue().
95  // If the primvar does have indices, GetFlattenedPrivmarValue() will return
96  // the flattened value.
97  //
98  // Note that GetPrimvarValue actually flattens the primvar even though
99  // the name and the grouping under ACCESSORS suggests that it is merely
100  // retrieving the primvarValue data source.
101  //
102  // The behavior of GetPrimvarValue might be conformed to simply return
103  // the primvarValue data source. Thus, clients who need the flattening
104  // behavior should explicitly call GetFlattenedPrimvarValue.
105  //
106  HD_API
107  HdSampledDataSourceHandle GetFlattenedPrimvarValue() const;
108 
109 // --(END CUSTOM CODE: Schema Methods)--
110 
111  /// \name Member accessor
112  /// @{
113 
114  HD_API
116 
117  HD_API
119 
120  HD_API
122 
123  /// The number of values in the value array that must be aggregated for
124  /// each element on the the primitive (same as UsdGeomPrimvar).
125  HD_API
127 
128  /// @}
129 
130  /// \name Schema construction
131  /// @{
132 
133  /// \deprecated Use Builder instead.
134  ///
135  /// Builds a container data source which includes the provided child data
136  /// sources. Parameters with nullptr values are excluded. This is a
137  /// low-level interface. For cases in which it's desired to define
138  /// the container with a sparse set of child fields, the Builder class
139  /// is often more convenient and readable.
140  HD_API
141  static HdContainerDataSourceHandle
143  const HdSampledDataSourceHandle &primvarValue,
144  const HdSampledDataSourceHandle &indexedPrimvarValue,
146  const HdTokenDataSourceHandle &interpolation,
147  const HdTokenDataSourceHandle &role,
148  const HdIntDataSourceHandle &elementSize
149  );
150 
151  /// \class HdPrimvarSchema::Builder
152  ///
153  /// Utility class for setting sparse sets of child data source fields to be
154  /// filled as arguments into BuildRetained. Because all setter methods
155  /// return a reference to the instance, this can be used in the "builder
156  /// pattern" form.
157  class Builder
158  {
159  public:
160  HD_API
162  const HdSampledDataSourceHandle &primvarValue);
163  HD_API
165  const HdSampledDataSourceHandle &indexedPrimvarValue);
166  HD_API
169  HD_API
171  const HdTokenDataSourceHandle &interpolation);
172  HD_API
173  Builder &SetRole(
174  const HdTokenDataSourceHandle &role);
175  HD_API
177  const HdIntDataSourceHandle &elementSize);
178 
179  /// Returns a container data source containing the members set thus far.
180  HD_API
181  HdContainerDataSourceHandle Build();
182 
183  private:
184  HdSampledDataSourceHandle _primvarValue;
185  HdSampledDataSourceHandle _indexedPrimvarValue;
187  HdTokenDataSourceHandle _interpolation;
189  HdIntDataSourceHandle _elementSize;
190 
191  };
192 
193  /// Returns token data source for use as interpolation value.
194  ///
195  /// The following values will be stored statically and reused for future
196  /// calls:
197  /// - HdPrimvarSchemaTokens->constant
198  /// - HdPrimvarSchemaTokens->uniform
199  /// - HdPrimvarSchemaTokens->varying
200  /// - HdPrimvarSchemaTokens->vertex
201  /// - HdPrimvarSchemaTokens->faceVarying
202  /// - HdPrimvarSchemaTokens->instance
203  HD_API
205  const TfToken &interpolation);
206 
207  /// Returns token data source for use as role value.
208  ///
209  /// The following values will be stored statically and reused for future
210  /// calls:
211  /// - HdPrimvarSchemaTokens->point
212  /// - HdPrimvarSchemaTokens->normal
213  /// - HdPrimvarSchemaTokens->vector
214  /// - HdPrimvarSchemaTokens->color
215  /// - HdPrimvarSchemaTokens->pointIndex
216  /// - HdPrimvarSchemaTokens->edgeIndex
217  /// - HdPrimvarSchemaTokens->faceIndex
218  /// - HdPrimvarSchemaTokens->textureCoordinate
219  HD_API
221  const TfToken &role);
222 
223  /// @}
224 };
225 
227 
228 #endif
HD_API bool IsIndexed() const
HD_API Builder & SetRole(const HdTokenDataSourceHandle &role)
GLsizei GLenum const void * indices
Definition: glcorearb.h:406
HD_API HdSampledDataSourceHandle GetIndexedPrimvarValue() const
static HD_API HdTokenDataSourceHandle BuildInterpolationDataSource(const TfToken &interpolation)
TF_DECLARE_PUBLIC_TOKENS(HdPrimvarSchemaTokens, HD_API, HD_PRIMVAR_SCHEMA_TOKENS)
HdPrimvarSchema(HdContainerDataSourceHandle container)
Definition: primvarSchema.h:70
#define HD_API
Definition: api.h:23
HD_API Builder & SetPrimvarValue(const HdSampledDataSourceHandle &primvarValue)
HD_API Builder & SetElementSize(const HdIntDataSourceHandle &elementSize)
static HD_API HdContainerDataSourceHandle BuildRetained(const HdSampledDataSourceHandle &primvarValue, const HdSampledDataSourceHandle &indexedPrimvarValue, const HdIntArrayDataSourceHandle &indices, const HdTokenDataSourceHandle &interpolation, const HdTokenDataSourceHandle &role, const HdIntDataSourceHandle &elementSize)
HD_API Builder & SetInterpolation(const HdTokenDataSourceHandle &interpolation)
HD_API HdIntDataSourceHandle GetElementSize() const
Definition: token.h:70
HdIntArrayDataSource::Handle HdIntArrayDataSourceHandle
HD_API HdSampledDataSourceHandle GetPrimvarValue() const
#define HD_PRIMVAR_SCHEMA_TOKENS
Definition: primvarSchema.h:35
HD_API Builder & SetIndices(const HdIntArrayDataSourceHandle &indices)
static HD_API HdTokenDataSourceHandle BuildRoleDataSource(const TfToken &role)
HD_API HdTokenDataSourceHandle GetRole() const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
HD_API HdContainerDataSourceHandle Build()
Returns a container data source containing the members set thus far.
HD_API Builder & SetIndexedPrimvarValue(const HdSampledDataSourceHandle &indexedPrimvarValue)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HdIntDataSource::Handle HdIntDataSourceHandle
HD_API HdSampledDataSourceHandle GetFlattenedPrimvarValue() const
HD_API HdTokenDataSourceHandle GetInterpolation() const
HdTokenDataSource::Handle HdTokenDataSourceHandle
HD_API HdIntArrayDataSourceHandle GetIndices() const