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  (colorSpace) \
42  (elementSize) \
43  (transform) \
44  (constant) \
45  (uniform) \
46  (varying) \
47  (vertex) \
48  (faceVarying) \
49  (instance) \
50  (point) \
51  (normal) \
52  (vector) \
53  (color) \
54  (pointIndex) \
55  (edgeIndex) \
56  (faceIndex) \
57  (textureCoordinate) \
58 
59 TF_DECLARE_PUBLIC_TOKENS(HdPrimvarSchemaTokens, HD_API,
61 
62 //-----------------------------------------------------------------------------
63 
64 
65 /// \class HdPrimvarSchema
66 ///
67 class HdPrimvarSchema : public HdSchema
68 {
69 public:
70  /// \name Schema retrieval
71  /// @{
72 
73  HdPrimvarSchema(HdContainerDataSourceHandle container)
74  : HdSchema(container) {}
75 
76  /// @}
77 
78 // --(BEGIN CUSTOM CODE: Schema Methods)--
79 
80  // If the primvar does not have indices, GetPrimvarValue() and
81  // GetIndexedPrimvarValue() will return the same thing. If the primvar
82  // does has indices, GetPrimvarValue() will return the flattened value,
83  // while GetIndexedPrimvarValue() will return the unflattened value.
84  HD_API
85  HdSampledDataSourceHandle GetPrimvarValue() const;
86 
87  HD_API
88  HdSampledDataSourceHandle GetIndexedPrimvarValue() const;
89 
90  // Returns true if it contains data sources for an indexed primvar value
91  // and for indices.
92  HD_API
93  bool IsIndexed() const;
94 
95  // If the primvar does not have indices, GetFlattenedPrimvarValue() will
96  // just return the primvarValue data source which is also returned by
97  // GetPrimVarValue().
98  // If the primvar does have indices, GetFlattenedPrivmarValue() will return
99  // the flattened value.
100  //
101  // Note that GetPrimvarValue actually flattens the primvar even though
102  // the name and the grouping under ACCESSORS suggests that it is merely
103  // retrieving the primvarValue data source.
104  //
105  // The behavior of GetPrimvarValue might be conformed to simply return
106  // the primvarValue data source. Thus, clients who need the flattening
107  // behavior should explicitly call GetFlattenedPrimvarValue.
108  //
109  HD_API
110  HdSampledDataSourceHandle GetFlattenedPrimvarValue() const;
111 
112 // --(END CUSTOM CODE: Schema Methods)--
113 
114  /// \name Member accessor
115  /// @{
116 
117  HD_API
119 
120  HD_API
122 
123  HD_API
125 
126  HD_API
128 
129  /// The number of values in the value array that must be aggregated for
130  /// each element on the the primitive (same as UsdGeomPrimvar).
131  HD_API
133 
134  /// @}
135 
136  /// \name Schema construction
137  /// @{
138 
139  /// \deprecated Use Builder instead.
140  ///
141  /// Builds a container data source which includes the provided child data
142  /// sources. Parameters with nullptr values are excluded. This is a
143  /// low-level interface. For cases in which it's desired to define
144  /// the container with a sparse set of child fields, the Builder class
145  /// is often more convenient and readable.
146  HD_API
147  static HdContainerDataSourceHandle
149  const HdSampledDataSourceHandle &primvarValue,
150  const HdSampledDataSourceHandle &indexedPrimvarValue,
152  const HdTokenDataSourceHandle &interpolation,
153  const HdTokenDataSourceHandle &role,
154  const HdTokenDataSourceHandle &colorSpace,
155  const HdIntDataSourceHandle &elementSize
156  );
157 
158  /// \class HdPrimvarSchema::Builder
159  ///
160  /// Utility class for setting sparse sets of child data source fields to be
161  /// filled as arguments into BuildRetained. Because all setter methods
162  /// return a reference to the instance, this can be used in the "builder
163  /// pattern" form.
164  class Builder
165  {
166  public:
167  HD_API
169  const HdSampledDataSourceHandle &primvarValue);
170  HD_API
172  const HdSampledDataSourceHandle &indexedPrimvarValue);
173  HD_API
176  HD_API
178  const HdTokenDataSourceHandle &interpolation);
179  HD_API
180  Builder &SetRole(
181  const HdTokenDataSourceHandle &role);
182  HD_API
184  const HdTokenDataSourceHandle &colorSpace);
185  HD_API
187  const HdIntDataSourceHandle &elementSize);
188 
189  /// Returns a container data source containing the members set thus far.
190  HD_API
191  HdContainerDataSourceHandle Build();
192 
193  private:
194  HdSampledDataSourceHandle _primvarValue;
195  HdSampledDataSourceHandle _indexedPrimvarValue;
197  HdTokenDataSourceHandle _interpolation;
199  HdTokenDataSourceHandle _colorSpace;
200  HdIntDataSourceHandle _elementSize;
201 
202  };
203 
204  /// Returns token data source for use as interpolation value.
205  ///
206  /// The following values will be stored statically and reused for future
207  /// calls:
208  /// - HdPrimvarSchemaTokens->constant
209  /// - HdPrimvarSchemaTokens->uniform
210  /// - HdPrimvarSchemaTokens->varying
211  /// - HdPrimvarSchemaTokens->vertex
212  /// - HdPrimvarSchemaTokens->faceVarying
213  /// - HdPrimvarSchemaTokens->instance
214  HD_API
216  const TfToken &interpolation);
217 
218  /// Returns token data source for use as role value.
219  ///
220  /// The following values will be stored statically and reused for future
221  /// calls:
222  /// - HdPrimvarSchemaTokens->point
223  /// - HdPrimvarSchemaTokens->normal
224  /// - HdPrimvarSchemaTokens->vector
225  /// - HdPrimvarSchemaTokens->color
226  /// - HdPrimvarSchemaTokens->pointIndex
227  /// - HdPrimvarSchemaTokens->edgeIndex
228  /// - HdPrimvarSchemaTokens->faceIndex
229  /// - HdPrimvarSchemaTokens->textureCoordinate
230  HD_API
232  const TfToken &role);
233 
234  /// @}
235 };
236 
238 
239 #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 HdContainerDataSourceHandle BuildRetained(const HdSampledDataSourceHandle &primvarValue, const HdSampledDataSourceHandle &indexedPrimvarValue, const HdIntArrayDataSourceHandle &indices, const HdTokenDataSourceHandle &interpolation, const HdTokenDataSourceHandle &role, const HdTokenDataSourceHandle &colorSpace, const HdIntDataSourceHandle &elementSize)
HD_API HdTokenDataSourceHandle GetColorSpace() const
static HD_API HdTokenDataSourceHandle BuildInterpolationDataSource(const TfToken &interpolation)
TF_DECLARE_PUBLIC_TOKENS(HdPrimvarSchemaTokens, HD_API, HD_PRIMVAR_SCHEMA_TOKENS)
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
HdPrimvarSchema(HdContainerDataSourceHandle container)
Definition: primvarSchema.h:73
#define HD_API
Definition: api.h:23
HD_API Builder & SetPrimvarValue(const HdSampledDataSourceHandle &primvarValue)
HD_API Builder & SetElementSize(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
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
HD_API Builder & SetColorSpace(const HdTokenDataSourceHandle &colorSpace)
HdIntDataSource::Handle HdIntDataSourceHandle
HD_API HdSampledDataSourceHandle GetFlattenedPrimvarValue() const
HD_API HdTokenDataSourceHandle GetInterpolation() const
HdTokenDataSource::Handle HdTokenDataSourceHandle
HD_API HdIntArrayDataSourceHandle GetIndices() const