All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
190  USDSHADE_API
191  UsdShadeNodeGraph(const UsdShadeConnectableAPI &connectable);
192 
202  USDSHADE_API
204 
210 
215  USDSHADE_API
216  UsdShadeOutput CreateOutput(const TfToken& name,
217  const SdfValueTypeName& typeName) const;
218 
221  USDSHADE_API
222  UsdShadeOutput GetOutput(const TfToken &name) const;
223 
228  USDSHADE_API
229  std::vector<UsdShadeOutput> GetOutputs(bool onlyAuthored=true) const;
230 
247  USDSHADE_API
249  const TfToken &outputName,
250  TfToken *sourceName,
251  UsdShadeAttributeType *sourceType) const;
252 
254 
287 
295  USDSHADE_API
296  UsdShadeInput CreateInput(const TfToken& name,
297  const SdfValueTypeName& typeName) const;
298 
301  USDSHADE_API
302  UsdShadeInput GetInput(const TfToken &name) const;
303 
309  USDSHADE_API
310  std::vector<UsdShadeInput> GetInputs(bool onlyAuthored=true) const;
311 
313 
314  // Provide custom hash and equality comparison function objects for
315  // UsdShadeNodeGraph until bug 143077 is resolved.
316 
319  inline size_t operator()(const UsdShadeNodeGraph &nodeGraph) const {
320  return hash_value(nodeGraph.GetPrim());
321  }
322  };
325  {
326  inline bool operator() (UsdShadeNodeGraph const& s1,
327  UsdShadeNodeGraph const& s2) const
328  {
329  return s1.GetPrim() == s2.GetPrim();
330  }
331  };
332 
333  // ---------------------------------------------------------------------- //
341 
346  USDSHADE_API
347  std::vector<UsdShadeInput> GetInterfaceInputs() const;
348 
351  typedef std::unordered_map<UsdShadeInput, std::vector<UsdShadeInput>,
353 
355  typedef std::unordered_map<UsdShadeNodeGraph,
360 
376  USDSHADE_API
378  bool computeTransitiveConsumers=false) const;
379 
381 
385  USDSHADE_API
386  bool
387  CanConnectOutputToSource(const UsdShadeOutput &output,
388  const UsdAttribute &source,
389  std::string *reason) const override;
390 
391  USDSHADE_API
392  bool IsContainer() const override;
393  };
394 
395 };
396 
397 PXR_NAMESPACE_CLOSE_SCOPE
398 
399 #endif
USDSHADE_API UsdShadeInput CreateInput(const TfToken &name, const SdfValueTypeName &typeName) const
Create an Input which can either have a value or can be connected.
Hash functor.
Definition: input.h:108
UsdShadeNodeGraph provides its own connectability behavior, to support nesting of node graphs...
Definition: nodeGraph.h:384
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:352
Represents a value type name, i.e.
Definition: valueTypeName.h:87
USDSHADE_API std::vector< UsdShadeOutput > GetOutputs(bool onlyAuthored=true) const
Outputs are represented by attributes in the &quot;outputs:&quot; namespace.
Scenegraph object for authoring and retrieving numeric, string, and array valued data, sampled over time.
Definition: attribute.h:176
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
USDSHADE_API UsdShadeOutput CreateOutput(const TfToken &name, const SdfValueTypeName &typeName) const
Create an output which can either have a value or can be connected.
virtual USDSHADE_API ~UsdShadeNodeGraph()
Destructor.
UsdSchemaKind
An enum representing which kind of schema a given schema class belongs to.
Definition: common.h:127
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.
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:359
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
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 &quot;Prim&quot; as ...
Definition: prim.h:132
The base class for all typed schemas (those that can impart a typeName to a UsdPrim), and therefore the base class for all instantiable and &quot;IsA&quot; schemas.
Definition: typed.h:47
USDSHADE_API UsdShadeInput GetInput(const TfToken &name) const
Return the requested input if it exists.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
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...
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
USDSHADE_API UsdShadeConnectableAPI ConnectableAPI() const
Contructs and returns a UsdShadeConnectableAPI object with this node-graph.
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:318
USDSHADE_API std::vector< UsdShadeInput > GetInputs(bool onlyAuthored=true) const
Returns all inputs present on the node-graph.
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...
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
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
USDSHADE_API std::vector< UsdShadeInput > GetInterfaceInputs() const
Returns all the &quot;Interface Inputs&quot; of the node-graph.
Equality comparator for UsdShadeNodeGraph objects.
Definition: nodeGraph.h:324
USDSHADE_API UsdShadeShader ComputeOutputSource(const TfToken &outputName, TfToken *sourceName, UsdShadeAttributeType *sourceType) const
UsdShadeConnectableAPIBehavior defines the compatibilty and behavior UsdShadeConnectableAPIof when ap...
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.
USDSHADE_API UsdShadeOutput GetOutput(const TfToken &name) const
Return the requested output if it exists.
UsdPrim GetPrim() const
Return this schema object&#39;s held prim.
Definition: schemaBase.h:120