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