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);
32 
33  // Actual name of the node
34  void setName(const UT_StringRef &name) { myName = name; }
35  // Simple name (n#) for shader references
36  void setTokenName(const UT_StringRef &name) { myToken = name; }
37 
38  void addInput(const UT_StringRef &input_name,
39  const UT_StringRef &output_name,
40  const GT_MaterialNodePtr &node);
41  void addOutputVar(const UT_StringRef &output, const UT_StringRef &varname);
42  void clearOutputVars();
43 
44  void copyParms(const GT_MaterialNodePtr &mat_node,
45  UT_Set<int> &visited);
46 
47  const UT_StringRef &name() const { return myName; }
48  const UT_StringRef &token() const { return myToken; }
49  const UT_StringHolder &type() const { return myTypeName; }
50  UT_Options &parms() { return myParms; }
51  const UT_Options &parms() const { return myParms; }
52 
54  inputs() const { return myInputs; }
55 
57  const UT_StringRef &getInputOutputName(const UT_StringRef &name) const;
58  int getInputOutputType(const UT_StringRef &name) const;
59  const UT_StringRef &getOutputVar(const UT_StringRef &output) const;
60 
61  static void addNodeDefaults(const UT_StringRef &nodetype_name,
62  const UT_Options &parm_defaults,
63  const UT_StringMap<int> &outputs);
64 
65  static const UT_StringMap<int> &getNodeOutputs(const UT_StringRef &nodetype);
66 
67  // Returns true if the network structure is the same as the network with
68  // root 'node'
69  bool networkMatch(const GT_MaterialNode *node,
70  UT_Set<int> &visited) const;
71 
72  int64 uniqueId() { return myID; }
73 
74 private:
76  UT_StringMap<UT_StringHolder> myOutputVars;
77  UT_Options myParms;
78  UT_StringHolder myTypeName;
79  UT_StringHolder myName;
80  UT_StringHolder myToken;
81  int64 myID;
82 };
83 
84 
85 #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:13
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
GLuint const GLchar * name
Definition: glcorearb.h:786
A map of string to various well defined value types.
Definition: UT_Options.h:84
GT_MaterialNode(const GT_MaterialNode &src)
const UT_StringRef & name() const
UT_Options & parms()
const UT_Options & parms() const
GLenum src
Definition: glcorearb.h:1793