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