HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
instanceSchema.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 /* ** This file is generated by a script. Do not edit directly. Edit ** */
28 /* ** defs.py or the (*)Schema.template.h files to make changes. ** */
29 /* ************************************************************************** */
30 
31 #ifndef PXR_IMAGING_HD_INSTANCE_SCHEMA_H
32 #define PXR_IMAGING_HD_INSTANCE_SCHEMA_H
33 
34 #include "pxr/imaging/hd/api.h"
35 
36 #include "pxr/imaging/hd/schema.h"
37 
39 
40 //-----------------------------------------------------------------------------
41 
42 #define HD_INSTANCE_SCHEMA_TOKENS \
43  (instance) \
44  (instancer) \
45  (prototypeIndex) \
46  (instanceIndex) \
47 
48 TF_DECLARE_PUBLIC_TOKENS(HdInstanceSchemaTokens, HD_API,
50 
51 //-----------------------------------------------------------------------------
52 // This schema can be considered the opposite of instancerTopology's
53 // "instanceLocations". When the scene coalesces scene prims into multiple
54 // instances of a single prototype, it inserts "instance" prims at the site of
55 // de-duplication. The instancer prim added to manage the prototype uses
56 // "instanceLocations" to point back to all of these instance prims.
57 //
58 // The instance prims aren't directly useful for rendering but can be useful
59 // for scene processing and data aggregation.
60 //
61 
62 class HdInstanceSchema : public HdSchema
63 {
64 public:
65  HdInstanceSchema(HdContainerDataSourceHandle container)
66  : HdSchema(container) {}
67 
68 // --(BEGIN CUSTOM CODE: Schema Methods)--
69 // --(END CUSTOM CODE: Schema Methods)--
70 
71  //ACCESSORS
72 
73 
74  // Path to instancer for which a (sub-)entry was added to its
75  // instancerTopology's instanceIndices during instance aggregation to
76  // account for this instance. Note that instanceIndices is nested, that
77  // is a vector data source containing integer arrays, one for each
78  // prototype the instancer is instancing. Thus, we need two indices to
79  // identify the entry: prototypeIndex is the outer index and
80  // instanceIndex the inner index.
81  HD_API
83 
84  // Index into vector data source at instancer's instancerTopology's
85  // instanceIndices to find entry corresponding to this instance.
86  HD_API
88 
89  // Index into int array within the vector data source at instancer's
90  // instancerTopology's instanceIndices to find entry corresponding to
91  // this instance.
92  HD_API
94 
95  // RETRIEVING AND CONSTRUCTING
96 
97  /// Builds a container data source which includes the provided child data
98  /// sources. Parameters with nullptr values are excluded. This is a
99  /// low-level interface. For cases in which it's desired to define
100  /// the container with a sparse set of child fields, the Builder class
101  /// is often more convenient and readable.
102  HD_API
103  static HdContainerDataSourceHandle
105  const HdPathDataSourceHandle &instancer,
106  const HdIntDataSourceHandle &prototypeIndex,
107  const HdIntDataSourceHandle &instanceIndex
108  );
109 
110  /// \class HdInstanceSchema::Builder
111  ///
112  /// Utility class for setting sparse sets of child data source fields to be
113  /// filled as arguments into BuildRetained. Because all setter methods
114  /// return a reference to the instance, this can be used in the "builder
115  /// pattern" form.
116  class Builder
117  {
118  public:
119  HD_API
121  const HdPathDataSourceHandle &instancer);
122  HD_API
124  const HdIntDataSourceHandle &prototypeIndex);
125  HD_API
127  const HdIntDataSourceHandle &instanceIndex);
128 
129  /// Returns a container data source containing the members set thus far.
130  HD_API
131  HdContainerDataSourceHandle Build();
132 
133  private:
134  HdPathDataSourceHandle _instancer;
135  HdIntDataSourceHandle _prototypeIndex;
136  HdIntDataSourceHandle _instanceIndex;
137  };
138 
139  /// Retrieves a container data source with the schema's default name token
140  /// "instance" from the parent container and constructs a
141  /// HdInstanceSchema instance.
142  /// Because the requested container data source may not exist, the result
143  /// should be checked with IsDefined() or a bool comparison before use.
144  HD_API
146  const HdContainerDataSourceHandle &fromParentContainer);
147 
148  /// Returns a token where the container representing this schema is found in
149  /// a container by default.
150  HD_API
151  static const TfToken &GetSchemaToken();
152 
153  /// Returns an HdDataSourceLocator (relative to the prim-level data source)
154  /// where the container representing this schema is found by default.
155  HD_API
156  static const HdDataSourceLocator &GetDefaultLocator();
157 
158 };
159 
161 
162 #endif
HdInstanceSchema(HdContainerDataSourceHandle container)
static HD_API const HdDataSourceLocator & GetDefaultLocator()
HD_API HdIntDataSourceHandle GetPrototypeIndex()
#define HD_API
Definition: api.h:40
HD_API Builder & SetInstancer(const HdPathDataSourceHandle &instancer)
HD_API HdContainerDataSourceHandle Build()
Returns a container data source containing the members set thus far.
HD_API HdIntDataSourceHandle GetInstanceIndex()
Definition: token.h:87
HD_API Builder & SetPrototypeIndex(const HdIntDataSourceHandle &prototypeIndex)
static HD_API HdInstanceSchema GetFromParent(const HdContainerDataSourceHandle &fromParentContainer)
HD_API HdPathDataSourceHandle GetInstancer()
static HD_API const TfToken & GetSchemaToken()
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
HD_API Builder & SetInstanceIndex(const HdIntDataSourceHandle &instanceIndex)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
HdIntDataSource::Handle HdIntDataSourceHandle
TF_DECLARE_PUBLIC_TOKENS(HdInstanceSchemaTokens, HD_API, HD_INSTANCE_SCHEMA_TOKENS)
HdPathDataSource::Handle HdPathDataSourceHandle
static HD_API HdContainerDataSourceHandle BuildRetained(const HdPathDataSourceHandle &instancer, const HdIntDataSourceHandle &prototypeIndex, const HdIntDataSourceHandle &instanceIndex)
#define HD_INSTANCE_SCHEMA_TOKENS