primvarSchema.h
1 //
2 // Copyright 2021 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 //
25 // This file is generated by a script. Do not edit directly. Edit the
26 // schema.template.h file to make changes.
27 
28 #ifndef PXR_IMAGING_HD_PRIMVAR_SCHEMA_H
29 #define PXR_IMAGING_HD_PRIMVAR_SCHEMA_H
30 
31 #include "pxr/imaging/hd/api.h"
32 
33 #include "pxr/imaging/hd/schema.h"
34 
35 PXR_NAMESPACE_OPEN_SCOPE
36 
37 //-----------------------------------------------------------------------------
38 
39 #define HDPRIMVAR_SCHEMA_TOKENS \
40  (primvarValue) \
41  (indexedPrimvarValue) \
42  (indices) \
43  (interpolation) \
44  (role) \
45  (constant) \
46  (uniform) \
47  (varying) \
48  (vertex) \
49  (faceVarying) \
50  (instance) \
51  (point) \
52  (normal) \
53  (vector) \
54  (color) \
55  (pointIndex) \
56  (edgeIndex) \
57  (faceIndex) \
58  (textureCoordinate) \
59  (transform) \
60 
61 TF_DECLARE_PUBLIC_TOKENS(HdPrimvarSchemaTokens, HD_API,
62  HDPRIMVAR_SCHEMA_TOKENS);
63 
64 //-----------------------------------------------------------------------------
65 
66 class HdPrimvarSchema : public HdSchema
67 {
68 public:
69  HdPrimvarSchema(HdContainerDataSourceHandle container)
70  : HdSchema(container) {}
71 
72  //ACCESSORS
73 
74 
75  // If the primvar does not have indices, GetPrimvarValue() and
76  // GetIndexedPrimvarValue() will return the same thing. If the primvar
77  // does has indices, GetPrimvarValue() will return the flattened value,
78  // while GetIndexedPrimvarValue() will return the unflattened value.
79  HD_API
80  HdSampledDataSourceHandle GetPrimvarValue();
81  HD_API
82  HdSampledDataSourceHandle GetIndexedPrimvarValue();
83  HD_API
84  HdIntArrayDataSourceHandle GetIndices();
85  HD_API
86  HdTokenDataSourceHandle GetInterpolation();
87  HD_API
88  HdTokenDataSourceHandle GetRole();
89 
90  // RETRIEVING AND CONSTRUCTING
91 
97  HD_API
98  static HdContainerDataSourceHandle
99  BuildRetained(
100  const HdSampledDataSourceHandle &primvarValue,
101  const HdSampledDataSourceHandle &indexedPrimvarValue,
102  const HdIntArrayDataSourceHandle &indices,
103  const HdTokenDataSourceHandle &interpolation,
104  const HdTokenDataSourceHandle &role
105  );
106 
113  class Builder
114  {
115  public:
116  HD_API
117  Builder &SetPrimvarValue(
118  const HdSampledDataSourceHandle &primvarValue);
119  HD_API
120  Builder &SetIndexedPrimvarValue(
121  const HdSampledDataSourceHandle &indexedPrimvarValue);
122  HD_API
123  Builder &SetIndices(
124  const HdIntArrayDataSourceHandle &indices);
125  HD_API
126  Builder &SetInterpolation(
127  const HdTokenDataSourceHandle &interpolation);
128  HD_API
129  Builder &SetRole(
130  const HdTokenDataSourceHandle &role);
131 
133  HD_API
134  HdContainerDataSourceHandle Build();
135 
136  private:
137  HdSampledDataSourceHandle _primvarValue;
138  HdSampledDataSourceHandle _indexedPrimvarValue;
139  HdIntArrayDataSourceHandle _indices;
140  HdTokenDataSourceHandle _interpolation;
141  HdTokenDataSourceHandle _role;
142  };
143  // Returns true if it contains data sources for an indexed primvar value
144  // and for indices.
145  HD_API
146  bool IsIndexed();
147 
148 
158  HD_API
159  static HdTokenDataSourceHandle BuildInterpolationDataSource(
160  const TfToken &interpolation);
172  HD_API
173  static HdTokenDataSourceHandle BuildRoleDataSource(
174  const TfToken &role);
175 
176 };
177 
178 PXR_NAMESPACE_CLOSE_SCOPE
179 
180 #endif
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
Utility class for setting sparse sets of child data source fields to be filled as arguments into Buil...
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Definition: staticTokens.h:118
HD_API HdContainerDataSourceHandle Build()
Returns a container data source containing the members set thus far.
Schema classes represent a structured view of the inherently unstructured container data source passe...
Definition: schema.h:43