All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
nodeGraph.h
Go to the documentation of this file.
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef USDSHADE_GENERATED_NODEGRAPH_H
8#define USDSHADE_GENERATED_NODEGRAPH_H
9
11
12#include "pxr/pxr.h"
13#include "pxr/usd/usdShade/api.h"
14#include "pxr/usd/usd/typed.h"
15#include "pxr/usd/usd/prim.h"
16#include "pxr/usd/usd/stage.h"
17
18#include <utility>
19#include "pxr/usd/usd/editTarget.h"
20#include "pxr/usd/usd/relationship.h"
21#include "pxr/usd/usdShade/input.h"
22#include "pxr/usd/usdShade/output.h"
25
26#include "pxr/base/vt/value.h"
27
28#include "pxr/base/gf/vec3d.h"
29#include "pxr/base/gf/vec3f.h"
31
32#include "pxr/base/tf/token.h"
33#include "pxr/base/tf/type.h"
34
35PXR_NAMESPACE_OPEN_SCOPE
36
37class SdfAssetPath;
38
39// -------------------------------------------------------------------------- //
40// NODEGRAPH //
41// -------------------------------------------------------------------------- //
42
64{
65public:
69 static const UsdSchemaKind schemaKind = UsdSchemaKind::ConcreteTyped;
70
75 explicit UsdShadeNodeGraph(const UsdPrim& prim=UsdPrim())
76 : UsdTyped(prim)
77 {
78 }
79
83 explicit UsdShadeNodeGraph(const UsdSchemaBase& schemaObj)
84 : UsdTyped(schemaObj)
85 {
86 }
87
89 USDSHADE_API
91
95 USDSHADE_API
96 static const TfTokenVector &
97 GetSchemaAttributeNames(bool includeInherited=true);
98
108 USDSHADE_API
109 static UsdShadeNodeGraph
110 Get(const UsdStagePtr &stage, const SdfPath &path);
111
134 USDSHADE_API
135 static UsdShadeNodeGraph
136 Define(const UsdStagePtr &stage, const SdfPath &path);
137
138protected:
142 USDSHADE_API
144
145private:
146 // needs to invoke _GetStaticTfType.
147 friend class UsdSchemaRegistry;
148 USDSHADE_API
149 static const TfType &_GetStaticTfType();
150
151 static bool _IsTypedSchema();
152
153 // override SchemaBase virtuals.
154 USDSHADE_API
155 const TfType &_GetTfType() const override;
156
157public:
158 // ===================================================================== //
159 // Feel free to add custom code below this line, it will be preserved by
160 // the code generator.
161 //
162 // Just remember to:
163 // - Close the class declaration with };
164 // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
165 // - Close the include guard with #endif
166 // ===================================================================== //
167 // --(BEGIN CUSTOM CODE)--
168
176 USDSHADE_API
178
188 USDSHADE_API
190
196
201 USDSHADE_API
203 const SdfValueTypeName& typeName) const;
204
207 USDSHADE_API
208 UsdShadeOutput GetOutput(const TfToken &name) const;
209
214 USDSHADE_API
215 std::vector<UsdShadeOutput> GetOutputs(bool onlyAuthored=true) const;
216
233 USDSHADE_API
235 const TfToken &outputName,
236 TfToken *sourceName,
237 UsdShadeAttributeType *sourceType) const;
238
240
273
281 USDSHADE_API
283 const SdfValueTypeName& typeName) const;
284
287 USDSHADE_API
288 UsdShadeInput GetInput(const TfToken &name) const;
289
295 USDSHADE_API
296 std::vector<UsdShadeInput> GetInputs(bool onlyAuthored=true) const;
297
299
300 // Provide custom hash and equality comparison function objects for
301 // UsdShadeNodeGraph until bug 143077 is resolved.
302
305 inline size_t operator()(const UsdShadeNodeGraph &nodeGraph) const {
306 return hash_value(nodeGraph.GetPrim());
307 }
308 };
311 {
312 inline bool operator() (UsdShadeNodeGraph const& s1,
313 UsdShadeNodeGraph const& s2) const
314 {
315 return s1.GetPrim() == s2.GetPrim();
316 }
317 };
318
319 // ---------------------------------------------------------------------- //
327
332 USDSHADE_API
333 std::vector<UsdShadeInput> GetInterfaceInputs() const;
334
337 typedef std::unordered_map<UsdShadeInput, std::vector<UsdShadeInput>,
339
341 typedef std::unordered_map<UsdShadeNodeGraph,
346
362 USDSHADE_API
364 bool computeTransitiveConsumers=false) const;
365
367
368};
369
370PXR_NAMESPACE_CLOSE_SCOPE
371
372#endif
Contains an asset path and an optional resolved path.
Definition: assetPath.h:30
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Represents a value type name, i.e.
Definition: valueTypeName.h:71
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
TfType represents a dynamic runtime type.
Definition: type.h:48
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:117
The base class for all schema types in Usd.
Definition: schemaBase.h:39
UsdPrim GetPrim() const
Return this schema object's held prim.
Definition: schemaBase.h:103
Singleton registry that provides access to schema type information and the prim definitions for regis...
UsdShadeConnectableAPI is an API schema that provides a common interface for creating outputs and mak...
This class encapsulates a shader or node-graph input, which is a connectable attribute representing a...
Definition: input.h:32
A node-graph is a container for shading nodes, as well as other node-graphs.
Definition: nodeGraph.h:64
USDSHADE_API InterfaceInputConsumersMap ComputeInterfaceInputConsumersMap(bool computeTransitiveConsumers=false) const
Walks the namespace subtree below the node-graph and computes a map containing the list of all inputs...
UsdShadeNodeGraph(const UsdSchemaBase &schemaObj)
Construct a UsdShadeNodeGraph on the prim held by schemaObj .
Definition: nodeGraph.h:83
USDSHADE_API UsdShadeNodeGraph(const UsdShadeConnectableAPI &connectable)
Constructor that takes a ConnectableAPI object.
USDSHADE_API UsdShadeConnectableAPI ConnectableAPI() const
Contructs and returns a UsdShadeConnectableAPI object with this node-graph.
std::unordered_map< UsdShadeInput, std::vector< UsdShadeInput >, UsdShadeInput::Hash > InterfaceInputConsumersMap
Map of interface inputs to corresponding vectors of inputs that consume their values.
Definition: nodeGraph.h:338
static const UsdSchemaKind schemaKind
Compile time constant representing what kind of schema this class is.
Definition: nodeGraph.h:69
USDSHADE_API UsdShadeOutput CreateOutput(const TfToken &name, const SdfValueTypeName &typeName) const
Create an output which can either have a value or can be connected.
USDSHADE_API UsdShadeInput GetInput(const TfToken &name) const
Return the requested input if it exists.
virtual USDSHADE_API ~UsdShadeNodeGraph()
Destructor.
USDSHADE_API UsdShadeShader ComputeOutputSource(const TfToken &outputName, TfToken *sourceName, UsdShadeAttributeType *sourceType) const
USDSHADE_API UsdShadeInput CreateInput(const TfToken &name, const SdfValueTypeName &typeName) const
Create an Input which can either have a value or can be connected.
USDSHADE_API UsdSchemaKind _GetSchemaKind() const override
Returns the kind of schema this class belongs to.
static USDSHADE_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
Return a vector of names of all pre-declared attributes for this schema class and all its ancestor cl...
std::unordered_map< UsdShadeNodeGraph, InterfaceInputConsumersMap, NodeGraphHasher, NodeGraphEqualFn > NodeGraphInputConsumersMap
Map of node-graphs to their associated input-consumers map.
Definition: nodeGraph.h:345
USDSHADE_API std::vector< UsdShadeInput > GetInterfaceInputs() const
Returns all the "Interface Inputs" of the node-graph.
USDSHADE_API UsdShadeOutput GetOutput(const TfToken &name) const
Return the requested output if it exists.
static USDSHADE_API UsdShadeNodeGraph Get(const UsdStagePtr &stage, const SdfPath &path)
Return a UsdShadeNodeGraph holding the prim adhering to this schema at path on stage.
static USDSHADE_API UsdShadeNodeGraph Define(const UsdStagePtr &stage, const SdfPath &path)
Attempt to ensure a UsdPrim adhering to this schema at path is defined (according to UsdPrim::IsDefin...
USDSHADE_API std::vector< UsdShadeInput > GetInputs(bool onlyAuthored=true) const
Returns all inputs present on the node-graph.
USDSHADE_API std::vector< UsdShadeOutput > GetOutputs(bool onlyAuthored=true) const
Outputs are represented by attributes in the "outputs:" namespace.
UsdShadeNodeGraph(const UsdPrim &prim=UsdPrim())
Construct a UsdShadeNodeGraph on UsdPrim prim .
Definition: nodeGraph.h:75
This class encapsulates a shader or node-graph output, which is a connectable attribute representing ...
Definition: output.h:31
Base class for all USD shaders.
Definition: shader.h:69
The base class for all typed schemas (those that can impart a typeName to a UsdPrim),...
Definition: typed.h:45
UsdSchemaKind
An enum representing which kind of schema a given schema class belongs to.
Definition: common.h:112
Hash functor.
Definition: input.h:91
Equality comparator for UsdShadeNodeGraph objects.
Definition: nodeGraph.h:311
Hash functor for UsdShadeNodeGraph objects.
Definition: nodeGraph.h:304
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
size_t hash_value(const TfToken &x)
Overload hash_value for TfToken.
Definition: token.h:437
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440