nodeGraph.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 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 #ifndef USDSHADE_GENERATED_NODEGRAPH_H
25 #define USDSHADE_GENERATED_NODEGRAPH_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usdShade/api.h"
31 #include "pxr/usd/usd/typed.h"
32 #include "pxr/usd/usd/prim.h"
33 #include "pxr/usd/usd/stage.h"
34 
35 #include <utility>
36 #include "pxr/usd/usd/editTarget.h"
37 #include "pxr/usd/usd/relationship.h"
38 #include "pxr/usd/usdShade/input.h"
39 #include "pxr/usd/usdShade/output.h"
42 
43 #include "pxr/base/vt/value.h"
44 
45 #include "pxr/base/gf/vec3d.h"
46 #include "pxr/base/gf/vec3f.h"
47 #include "pxr/base/gf/matrix4d.h"
48 
49 #include "pxr/base/tf/token.h"
50 #include "pxr/base/tf/type.h"
51 
52 PXR_NAMESPACE_OPEN_SCOPE
53 
54 class SdfAssetPath;
55 
56 // -------------------------------------------------------------------------- //
57 // NODEGRAPH //
58 // -------------------------------------------------------------------------- //
59 
81 {
82 public:
87 
92  explicit UsdShadeNodeGraph(const UsdPrim& prim=UsdPrim())
93  : UsdTyped(prim)
94  {
95  }
96 
100  explicit UsdShadeNodeGraph(const UsdSchemaBase& schemaObj)
101  : UsdTyped(schemaObj)
102  {
103  }
104 
106  USDSHADE_API
107  virtual ~UsdShadeNodeGraph();
108 
112  USDSHADE_API
113  static const TfTokenVector &
114  GetSchemaAttributeNames(bool includeInherited=true);
115 
125  USDSHADE_API
126  static UsdShadeNodeGraph
127  Get(const UsdStagePtr &stage, const SdfPath &path);
128 
151  USDSHADE_API
152  static UsdShadeNodeGraph
153  Define(const UsdStagePtr &stage, const SdfPath &path);
154 
155 protected:
159  USDSHADE_API
160  UsdSchemaKind _GetSchemaKind() const override;
161 
162 private:
163  // needs to invoke _GetStaticTfType.
164  friend class UsdSchemaRegistry;
165  USDSHADE_API
166  static const TfType &_GetStaticTfType();
167 
168  static bool _IsTypedSchema();
169 
170  // override SchemaBase virtuals.
171  USDSHADE_API
172  const TfType &_GetTfType() const override;
173 
174 public:
175  // ===================================================================== //
176  // Feel free to add custom code below this line, it will be preserved by
177  // the code generator.
178  //
179  // Just remember to:
180  // - Close the class declaration with };
181  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
182  // - Close the include guard with #endif
183  // ===================================================================== //
184  // --(BEGIN CUSTOM CODE)--
185 
193  USDSHADE_API
194  UsdShadeNodeGraph(const UsdShadeConnectableAPI &connectable);
195 
205  USDSHADE_API
207 
213 
218  USDSHADE_API
219  UsdShadeOutput CreateOutput(const TfToken& name,
220  const SdfValueTypeName& typeName) const;
221 
224  USDSHADE_API
225  UsdShadeOutput GetOutput(const TfToken &name) const;
226 
231  USDSHADE_API
232  std::vector<UsdShadeOutput> GetOutputs(bool onlyAuthored=true) const;
233 
250  USDSHADE_API
252  const TfToken &outputName,
253  TfToken *sourceName,
254  UsdShadeAttributeType *sourceType) const;
255 
257 
290 
298  USDSHADE_API
299  UsdShadeInput CreateInput(const TfToken& name,
300  const SdfValueTypeName& typeName) const;
301 
304  USDSHADE_API
305  UsdShadeInput GetInput(const TfToken &name) const;
306 
312  USDSHADE_API
313  std::vector<UsdShadeInput> GetInputs(bool onlyAuthored=true) const;
314 
316 
317  // Provide custom hash and equality comparison function objects for
318  // UsdShadeNodeGraph until bug 143077 is resolved.
319 
322  inline size_t operator()(const UsdShadeNodeGraph &nodeGraph) const {
323  return hash_value(nodeGraph.GetPrim());
324  }
325  };
328  {
329  inline bool operator() (UsdShadeNodeGraph const& s1,
330  UsdShadeNodeGraph const& s2) const
331  {
332  return s1.GetPrim() == s2.GetPrim();
333  }
334  };
335 
336  // ---------------------------------------------------------------------- //
344 
349  USDSHADE_API
350  std::vector<UsdShadeInput> GetInterfaceInputs() const;
351 
354  typedef std::unordered_map<UsdShadeInput, std::vector<UsdShadeInput>,
356 
358  typedef std::unordered_map<UsdShadeNodeGraph,
363 
379  USDSHADE_API
381  bool computeTransitiveConsumers=false) const;
382 
384 
385 };
386 
387 PXR_NAMESPACE_CLOSE_SCOPE
388 
389 #endif
Hash functor.
Definition: input.h:108
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:355
UsdPrim GetPrim() const
Return this schema object's held prim.
Definition: schemaBase.h:120
USDSHADE_API UsdShadeInput GetInput(const TfToken &name) const
Return the requested input if it exists.
Represents a value type name, i.e.
Definition: valueTypeName.h:87
USDSHADE_API UsdShadeInput CreateInput(const TfToken &name, const SdfValueTypeName &typeName) const
Create an Input which can either have a value or can be connected.
A node-graph is a container for shading nodes, as well as other node-graphs.
Definition: nodeGraph.h:80
This class encapsulates a shader or node-graph input, which is a connectable attribute representing a...
Definition: input.h:48
virtual USDSHADE_API ~UsdShadeNodeGraph()
Destructor.
UsdSchemaKind
An enum representing which kind of schema a given schema class belongs to.
Definition: common.h:127
USDSHADE_API std::vector< UsdShadeInput > GetInputs(bool onlyAuthored=true) const
Returns all inputs present on the node-graph.
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...
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.
USDSHADE_API std::vector< UsdShadeOutput > GetOutputs(bool onlyAuthored=true) const
Outputs are represented by attributes in the "outputs:" namespace.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
std::unordered_map< UsdShadeNodeGraph, InterfaceInputConsumersMap, NodeGraphHasher, NodeGraphEqualFn > NodeGraphInputConsumersMap
Map of node-graphs to their associated input-consumers map.
Definition: nodeGraph.h:362
static const UsdSchemaKind schemaKind
Compile time constant representing what kind of schema this class is.
Definition: nodeGraph.h:86
UsdShadeNodeGraph(const UsdPrim &prim=UsdPrim())
Construct a UsdShadeNodeGraph on UsdPrim prim .
Definition: nodeGraph.h:92
USDSHADE_API UsdShadeConnectableAPI ConnectableAPI() const
Contructs and returns a UsdShadeConnectableAPI object with this node-graph.
USDSHADE_API std::vector< UsdShadeInput > GetInterfaceInputs() const
Returns all the "Interface Inputs" of the node-graph.
UsdShadeConnectableAPI is an API schema that provides a common interface for creating outputs and mak...
Represents a concrete typed schema.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:134
The base class for all typed schemas (those that can impart a typeName to a UsdPrim),...
Definition: typed.h:47
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
USDSHADE_API UsdShadeShader ComputeOutputSource(const TfToken &outputName, TfToken *sourceName, UsdShadeAttributeType *sourceType) const
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
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...
Hash functor for UsdShadeNodeGraph objects.
Definition: nodeGraph.h:321
Contains an asset path and an optional resolved path.
Definition: assetPath.h:47
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...
USDSHADE_API UsdShadeOutput GetOutput(const TfToken &name) const
Return the requested output if it exists.
Base class for all USD shaders.
Definition: shader.h:85
TfType represents a dynamic runtime type.
Definition: type.h:64
Singleton registry that provides access to schema type information and the prim definitions for regis...
UsdShadeNodeGraph(const UsdSchemaBase &schemaObj)
Construct a UsdShadeNodeGraph on the prim held by schemaObj .
Definition: nodeGraph.h:100
USDSHADE_API UsdShadeOutput CreateOutput(const TfToken &name, const SdfValueTypeName &typeName) const
Create an output which can either have a value or can be connected.
This class encapsulates a shader or node-graph output, which is a connectable attribute representing ...
Definition: output.h:47
The base class for all schema types in Usd.
Definition: schemaBase.h:56
Equality comparator for UsdShadeNodeGraph objects.
Definition: nodeGraph.h:327
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
USDSHADE_API UsdSchemaKind _GetSchemaKind() const override
Returns the kind of schema this class belongs to.