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 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_INSTANCE_SCHEMA_H
19 #define PXR_IMAGING_HD_INSTANCE_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_INSTANCE_SCHEMA_TOKENS \
36  (instance) \
37  (instancer) \
38  (prototypeIndex) \
39  (instanceIndex) \
40 
41 TF_DECLARE_PUBLIC_TOKENS(HdInstanceSchemaTokens, HD_API,
43 
44 //-----------------------------------------------------------------------------
45 
46 // This schema can be considered the opposite of instancerTopology's
47 // "instanceLocations". When the scene coalesces scene prims into multiple
48 // instances of a single prototype, it inserts "instance" prims at the site of
49 // de-duplication. The instancer prim added to manage the prototype uses
50 // "instanceLocations" to point back to all of these instance prims.
51 //
52 // The instance prims aren't directly useful for rendering but can be useful
53 // for scene processing and data aggregation.
54 //
55 
56 class HdInstanceSchema : public HdSchema
57 {
58 public:
59  /// \name Schema retrieval
60  /// @{
61 
62  HdInstanceSchema(HdContainerDataSourceHandle container)
63  : HdSchema(container) {}
64 
65  /// Retrieves a container data source with the schema's default name token
66  /// "instance" from the parent container and constructs a
67  /// HdInstanceSchema instance.
68  /// Because the requested container data source may not exist, the result
69  /// should be checked with IsDefined() or a bool comparison before use.
70  HD_API
72  const HdContainerDataSourceHandle &fromParentContainer);
73 
74  /// @}
75 
76 // --(BEGIN CUSTOM CODE: Schema Methods)--
77 // --(END CUSTOM CODE: Schema Methods)--
78 
79  /// \name Member accessor
80  /// @{
81 
82  /// Path to instancer for which a (sub-)entry was added to its
83  /// instancerTopology's instanceIndices during instance aggregation to
84  /// account for this instance. Note that instanceIndices is nested, that
85  /// is a vector data source containing integer arrays, one for each
86  /// prototype the instancer is instancing. Thus, we need two indices to
87  /// identify the entry: prototypeIndex is the outer index and
88  /// instanceIndex the inner index.
89  HD_API
91 
92  /// Index into vector data source at instancer's instancerTopology's
93  /// instanceIndices to find entry corresponding to this instance.
94  HD_API
96 
97  /// Index into int array within the vector data source at instancer's
98  /// instancerTopology's instanceIndices to find entry corresponding to
99  /// this instance.
100  HD_API
102 
103  /// @}
104 
105  /// \name Schema location
106  /// @{
107 
108  /// Returns a token where the container representing this schema is found in
109  /// a container by default.
110  HD_API
111  static const TfToken &GetSchemaToken();
112 
113  /// Returns an HdDataSourceLocator (relative to the prim-level data source)
114  /// where the container representing this schema is found by default.
115  HD_API
116  static const HdDataSourceLocator &GetDefaultLocator();
117 
118  /// @}
119 
120  /// \name Schema construction
121  /// @{
122 
123  /// \deprecated Use Builder instead.
124  ///
125  /// Builds a container data source which includes the provided child data
126  /// sources. Parameters with nullptr values are excluded. This is a
127  /// low-level interface. For cases in which it's desired to define
128  /// the container with a sparse set of child fields, the Builder class
129  /// is often more convenient and readable.
130  HD_API
131  static HdContainerDataSourceHandle
133  const HdPathDataSourceHandle &instancer,
134  const HdIntDataSourceHandle &prototypeIndex,
135  const HdIntDataSourceHandle &instanceIndex
136  );
137 
138  /// \class HdInstanceSchema::Builder
139  ///
140  /// Utility class for setting sparse sets of child data source fields to be
141  /// filled as arguments into BuildRetained. Because all setter methods
142  /// return a reference to the instance, this can be used in the "builder
143  /// pattern" form.
144  class Builder
145  {
146  public:
147  HD_API
149  const HdPathDataSourceHandle &instancer);
150  HD_API
152  const HdIntDataSourceHandle &prototypeIndex);
153  HD_API
155  const HdIntDataSourceHandle &instanceIndex);
156 
157  /// Returns a container data source containing the members set thus far.
158  HD_API
159  HdContainerDataSourceHandle Build();
160 
161  private:
162  HdPathDataSourceHandle _instancer;
163  HdIntDataSourceHandle _prototypeIndex;
164  HdIntDataSourceHandle _instanceIndex;
165 
166  };
167 
168  /// @}
169 };
170 
172 
173 #endif
HdInstanceSchema(HdContainerDataSourceHandle container)
static HD_API const HdDataSourceLocator & GetDefaultLocator()
#define HD_API
Definition: api.h:23
HD_API Builder & SetInstancer(const HdPathDataSourceHandle &instancer)
HD_API HdContainerDataSourceHandle Build()
Returns a container data source containing the members set thus far.
Definition: token.h:70
HD_API Builder & SetPrototypeIndex(const HdIntDataSourceHandle &prototypeIndex)
static HD_API HdInstanceSchema GetFromParent(const HdContainerDataSourceHandle &fromParentContainer)
static HD_API const TfToken & GetSchemaToken()
HD_API HdIntDataSourceHandle GetInstanceIndex() const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
HD_API Builder & SetInstanceIndex(const HdIntDataSourceHandle &instanceIndex)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HD_API HdPathDataSourceHandle GetInstancer() const
HdIntDataSource::Handle HdIntDataSourceHandle
TF_DECLARE_PUBLIC_TOKENS(HdInstanceSchemaTokens, HD_API, HD_INSTANCE_SCHEMA_TOKENS)
HD_API HdIntDataSourceHandle GetPrototypeIndex() const
HdPathDataSource::Handle HdPathDataSourceHandle
static HD_API HdContainerDataSourceHandle BuildRetained(const HdPathDataSourceHandle &instancer, const HdIntDataSourceHandle &prototypeIndex, const HdIntDataSourceHandle &instanceIndex)
#define HD_INSTANCE_SCHEMA_TOKENS