HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_MaterialNode.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GT_MaterialNode.h ( GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 #ifndef __GT_MaterialNode__
11 #define __GT_MaterialNode__
12 
13 #include "GT_API.h"
14 
15 #include <UT/UT_IntrusivePtr.h>
16 #include <UT/UT_Options.h>
17 #include <UT/UT_Set.h>
18 #include <UT/UT_StringMap.h>
19 
22 
23 /// An shallow abstraction of a shader node network
24 class GT_API GT_MaterialNode : public UT_IntrusiveRefCounter<GT_MaterialNode>
25 {
26 public:
28  GT_MaterialNode(const UT_StringRef &nodetype);
30 
31  // Actual name of the node
32  void setName(const UT_StringRef &name) { myName = name; }
33  // Simple name (n#) for shader references
34  void setTokenName(const UT_StringRef &name) { myToken = name; }
35 
36  void addInput(const UT_StringRef &input_name,
37  const UT_StringRef &output_name,
38  const GT_MaterialNodePtr &node);
39  void addOutputVar(const UT_StringRef &output, const UT_StringRef &varname);
40  void clearOutputVars();
41 
42  void copyParms(const GT_MaterialNodePtr &mat_node,
43  UT_Set<int> &visited);
44 
45  const UT_StringRef &name() const { return myName; }
46  const UT_StringRef &token() const { return myToken; }
47  const UT_StringHolder &type() const { return myTypeName; }
48  UT_Options &parms() { return myParms; }
49  const UT_Options &parms() const { return myParms; }
50 
52  inputs() const { return myInputs; }
53 
55  const UT_StringRef &getInputOutputName(const UT_StringRef &name) const;
56  int getInputOutputType(const UT_StringRef &name) const;
57  const UT_StringRef &getOutputVar(const UT_StringRef &output) const;
58 
59  static void addNodeDefaults(const UT_StringRef &nodetype_name,
60  const UT_Options &parm_defaults,
61  const UT_StringMap<int> &outputs);
62 
63  static const UT_StringMap<int> &getNodeOutputs(const UT_StringRef &nodetype);
64 
65  // Returns true if the network structure is the same as the network with
66  // root 'node'
67  bool networkMatch(const GT_MaterialNode *node,
68  UT_Set<int> &visited) const;
69 
70  int64 uniqueId() { return myID; }
71 
72 private:
74  UT_StringMap<UT_StringHolder> myOutputVars;
75  UT_Options myParms;
76  UT_StringHolder myTypeName;
77  UT_StringHolder myName;
78  UT_StringHolder myToken;
79  int64 myID;
80 };
81 
82 
83 #endif
UT_IntrusivePtr< GT_MaterialNode > GT_MaterialNodePtr
short * getInput(int size) override
const UT_StringHolder & type() const
void setTokenName(const UT_StringRef &name)
#define GT_API
Definition: GT_API.h:11
GLuint const GLchar * name
Definition: glcorearb.h:786
GLenum src
Definition: glcorearb.h:1793
const UT_StringMap< std::pair< GT_MaterialNodePtr, UT_StringHolder > > & inputs() const
A reference counter base class for use with UT_IntrusivePtr.
UT_IntrusiveRefCounter & operator=(const UT_IntrusiveRefCounter &) noexcept
Assignment operator: Does not modify counter.
An shallow abstraction of a shader node network.
void setName(const UT_StringRef &name)
Wrapper around hboost::intrusive_ptr.
long long int64
Definition: SYS_Types.h:116
const UT_StringRef & token() const
A map of string to various well defined value types.
Definition: UT_Options.h:84
const UT_StringRef & name() const
UT_Options & parms()
const UT_Options & parms() const