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 Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 /* ************************************************************************** */
27 /* ** ** */
28 /* ** This file is generated by a script. ** */
29 /* ** ** */
30 /* ** Do not edit it directly (unless it is within a CUSTOM CODE section)! ** */
31 /* ** Edit hdGen/schema.py instead to make changes. ** */
32 /* ** ** */
33 /* ************************************************************************** */
34 
35 #ifndef PXR_IMAGING_HD_PRIMVAR_SCHEMA_H
36 #define PXR_IMAGING_HD_PRIMVAR_SCHEMA_H
37 
38 #include "pxr/imaging/hd/api.h"
39 
40 #include "pxr/imaging/hd/schema.h"
41 
42 // --(BEGIN CUSTOM CODE: Includes)--
43 // --(END CUSTOM CODE: Includes)--
44 
46 
47 //-----------------------------------------------------------------------------
48 
49 // --(BEGIN CUSTOM CODE: Declares)--
50 // --(END CUSTOM CODE: Declares)--
51 
52 //-----------------------------------------------------------------------------
53 
54 #define HD_PRIMVAR_SCHEMA_TOKENS \
55  (primvarValue) \
56  (indexedPrimvarValue) \
57  (indices) \
58  (interpolation) \
59  (role) \
60  (transform) \
61  (constant) \
62  (uniform) \
63  (varying) \
64  (vertex) \
65  (faceVarying) \
66  (instance) \
67  (point) \
68  (normal) \
69  (vector) \
70  (color) \
71  (pointIndex) \
72  (edgeIndex) \
73  (faceIndex) \
74  (textureCoordinate) \
75 
76 TF_DECLARE_PUBLIC_TOKENS(HdPrimvarSchemaTokens, HD_API,
78 
79 //-----------------------------------------------------------------------------
80 
81 
82 class HdPrimvarSchema : public HdSchema
83 {
84 public:
85  HdPrimvarSchema(HdContainerDataSourceHandle container)
86  : HdSchema(container) {}
87 
88 // --(BEGIN CUSTOM CODE: Schema Methods)--
89 
90  // If the primvar does not have indices, GetPrimvarValue() and
91  // GetIndexedPrimvarValue() will return the same thing. If the primvar
92  // does has indices, GetPrimvarValue() will return the flattened value,
93  // while GetIndexedPrimvarValue() will return the unflattened value.
94  HD_API
95  HdSampledDataSourceHandle GetPrimvarValue();
96 
97  HD_API
98  HdSampledDataSourceHandle GetIndexedPrimvarValue();
99 
100  // Returns true if it contains data sources for an indexed primvar value
101  // and for indices.
102  HD_API
103  bool IsIndexed();
104 
105  // If the primvar does not have indices, GetFlattenedPrimvarValue() will
106  // just return the primvarValue data source which is also returned by
107  // GetPrimVarValue().
108  // If the primvar does have indices, GetFlattenedPrivmarValue() will return
109  // the flattened value.
110  //
111  // Note that GetPrimvarValue actually flattens the primvar even though
112  // the name and the grouping under ACCESSORS suggests that it is merely
113  // retrieving the primvarValue data source.
114  //
115  // The behavior of GetPrimvarValue might be conformed to simply return
116  // the primvarValue data source. Thus, clients who need the flattening
117  // behavior should explicitly call GetFlattenedPrimvarValue.
118  //
119  HD_API
120  HdSampledDataSourceHandle GetFlattenedPrimvarValue();
121 
122 // --(END CUSTOM CODE: Schema Methods)--
123 
124  //ACCESSORS
125 
126  HD_API
128  HD_API
130  HD_API
132 
133  // RETRIEVING AND CONSTRUCTING
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  );
149 
150  /// \class HdPrimvarSchema::Builder
151  ///
152  /// Utility class for setting sparse sets of child data source fields to be
153  /// filled as arguments into BuildRetained. Because all setter methods
154  /// return a reference to the instance, this can be used in the "builder
155  /// pattern" form.
156  class Builder
157  {
158  public:
159  HD_API
161  const HdSampledDataSourceHandle &primvarValue);
162  HD_API
164  const HdSampledDataSourceHandle &indexedPrimvarValue);
165  HD_API
168  HD_API
170  const HdTokenDataSourceHandle &interpolation);
171  HD_API
172  Builder &SetRole(
173  const HdTokenDataSourceHandle &role);
174 
175  /// Returns a container data source containing the members set thus far.
176  HD_API
177  HdContainerDataSourceHandle Build();
178 
179  private:
180  HdSampledDataSourceHandle _primvarValue;
181  HdSampledDataSourceHandle _indexedPrimvarValue;
183  HdTokenDataSourceHandle _interpolation;
185 
186  };
187 
188  /// Returns token data source for use as interpolation value.
189  /// Values of...
190  /// - HdPrimvarSchemaTokens->constant
191  /// - HdPrimvarSchemaTokens->uniform
192  /// - HdPrimvarSchemaTokens->varying
193  /// - HdPrimvarSchemaTokens->vertex
194  /// - HdPrimvarSchemaTokens->faceVarying
195  /// - HdPrimvarSchemaTokens->instance
196  /// ...will be stored statically and reused for future calls.
197  HD_API
199  const TfToken &interpolation);
200 
201  /// Returns token data source for use as role value.
202  /// Values of...
203  /// - HdPrimvarSchemaTokens->point
204  /// - HdPrimvarSchemaTokens->normal
205  /// - HdPrimvarSchemaTokens->vector
206  /// - HdPrimvarSchemaTokens->color
207  /// - HdPrimvarSchemaTokens->pointIndex
208  /// - HdPrimvarSchemaTokens->edgeIndex
209  /// - HdPrimvarSchemaTokens->faceIndex
210  /// - HdPrimvarSchemaTokens->textureCoordinate
211  /// ...will be stored statically and reused for future calls.
212  HD_API
214  const TfToken &role);
215 };
216 
218 
219 #endif
HD_API bool IsIndexed()
HD_API Builder & SetRole(const HdTokenDataSourceHandle &role)
GLsizei GLenum const void * indices
Definition: glcorearb.h:406
static HD_API HdTokenDataSourceHandle BuildInterpolationDataSource(const TfToken &interpolation)
TF_DECLARE_PUBLIC_TOKENS(HdPrimvarSchemaTokens, HD_API, HD_PRIMVAR_SCHEMA_TOKENS)
static HD_API HdContainerDataSourceHandle BuildRetained(const HdSampledDataSourceHandle &primvarValue, const HdSampledDataSourceHandle &indexedPrimvarValue, const HdIntArrayDataSourceHandle &indices, const HdTokenDataSourceHandle &interpolation, const HdTokenDataSourceHandle &role)
HdPrimvarSchema(HdContainerDataSourceHandle container)
Definition: primvarSchema.h:85
#define HD_API
Definition: api.h:40
HD_API Builder & SetPrimvarValue(const HdSampledDataSourceHandle &primvarValue)
HD_API HdSampledDataSourceHandle GetFlattenedPrimvarValue()
HD_API Builder & SetInterpolation(const HdTokenDataSourceHandle &interpolation)
Definition: token.h:87
HD_API HdSampledDataSourceHandle GetPrimvarValue()
HdIntArrayDataSource::Handle HdIntArrayDataSourceHandle
HD_API HdTokenDataSourceHandle GetInterpolation()
#define HD_PRIMVAR_SCHEMA_TOKENS
Definition: primvarSchema.h:54
HD_API Builder & SetIndices(const HdIntArrayDataSourceHandle &indices)
static HD_API HdTokenDataSourceHandle BuildRoleDataSource(const TfToken &role)
HD_API HdIntArrayDataSourceHandle GetIndices()
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
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:91
HD_API HdTokenDataSourceHandle GetRole()
HdTokenDataSource::Handle HdTokenDataSourceHandle
HD_API HdSampledDataSourceHandle GetIndexedPrimvarValue()