6 #ifndef MATERIALX_SHADERGRAPH_H
7 #define MATERIALX_SHADERGRAPH_H
62 bool isAGraph()
const override {
return true; }
68 const ShaderNode* getNode(
const string& name)
const;
71 const vector<ShaderNode*>&
getNodes()
const {
return _nodeOrder; }
113 void topologicalSort();
127 void createConnectedNodes(
const ElementPtr& downstreamElement,
167 void bypass(
ShaderNode* node,
size_t inputIndex,
size_t outputIndex = 0);
177 const string& sourceColorSpace,
const string& targetColorSpace,
bool asInput);
187 std::unordered_map<string, ShaderNodePtr>
_nodeMap;
220 return !(*
this == rhs);
242 return _upstream == rhs._upstream &&
243 _downstream == rhs._downstream &&
244 _stack == rhs._stack;
248 return !(*
this == rhs);
277 using StackFrame = std::pair<ShaderOutput*, size_t>;
278 std::vector<StackFrame> _stack;
279 std::set<ShaderOutput*> _path;
280 std::set<ShaderGraphEdge> _visitedEdges;
std::unordered_map< ShaderInput *, UnitTransform > _inputUnitTransformMap
ShaderGraphOutputSocket * addOutputSocket(const string &name, const TypeDesc *type)
ShaderGraphEdge operator*() const
Dereference this iterator, returning the current output in the traversal.
ShaderGraphInputSocket * getInputSocket(size_t index)
Get socket by index.
vector< ShaderInput * > _inputOrder
bool operator==(const ShaderGraphEdgeIterator &rhs) const
std::unordered_map< string, ShaderNodePtr > _nodeMap
#define MATERIALX_NAMESPACE_BEGIN
ShaderOutput * getOutput(size_t index=0)
ShaderInput * getInput(size_t index)
Get inputs/outputs by index.
shared_ptr< class UnitSystem > UnitSystemPtr
A shared pointer to a UnitSystem.
vector< ShaderOutput * > _outputOrder
ShaderGraphOutputSocket * getOutputSocket(const string &name)
shared_ptr< const Node > ConstNodePtr
A shared pointer to a const Node.
size_t numOutputs() const
const vector< ShaderGraphOutputSocket * > & getOutputSockets() const
ShaderGraphOutputSocket * getOutputSocket(size_t index=0)
const ShaderGraphInputSocket * getInputSocket(size_t index) const
std::vector< ShaderNode * > _nodeOrder
bool operator!=(const ShaderGraphEdgeIterator &rhs) const
ShaderGraphEdgeIterator & begin()
Return a reference to this iterator to begin traversal.
size_t numInputSockets() const
Get number of input sockets.
ShaderGraphInputSocket * addInputSocket(const string &name, const TypeDesc *type)
ShaderGraphEdge(ShaderOutput *up, ShaderInput *down)
GLint GLint GLsizei GLint GLenum GLenum type
bool operator<(const ShaderGraphEdge &rhs) const
shared_ptr< class ColorManagementSystem > ColorManagementSystemPtr
A shared pointer to a ColorManagementSystem.
ShaderGraphInputSocket * getInputSocket(const string &name)
Get socket by name.
shared_ptr< class ShaderNode > ShaderNodePtr
Shared pointer to a ShaderNode.
bool operator==(const ShaderGraphEdge &rhs) const
static ShaderNodePtr create(const ShaderGraph *parent, const string &name, const NodeDef &nodeDef, GenContext &context)
Create a new node from a nodedef.
GLuint const GLchar * name
shared_ptr< class ShaderGraph > ShaderGraphPtr
A shared pointer to a shader graph.
bool operator!=(const ShaderGraphEdge &rhs) const
GA_API const UT_StringHolder transform
const ShaderGraphOutputSocket * getOutputSocket(size_t index=0) const
const ShaderGraphOutputSocket * getOutputSocket(const string &name) const
size_t numOutputSockets() const
Get number of output sockets.
virtual ~ShaderGraph()
Destructor.
std::unordered_map< ShaderOutput *, ColorSpaceTransform > _outputColorTransformMap
~ShaderGraphEdgeIterator()
bool isAGraph() const override
Return true if this node is a graph.
IdentifierMap _identifiers
const vector< ShaderNode * > & getNodes() const
Get a vector of all nodes in order.
std::unordered_map< string, size_t > IdentifierMap
const ShaderGraphInputSocket * getInputSocket(const string &name) const
const vector< ShaderGraphInputSocket * > & getInputSockets() const
Get vector of sockets.
std::set< string > StringSet
A set of strings.
std::unordered_map< ShaderOutput *, UnitTransform > _outputUnitTransformMap
shared_ptr< Element > ElementPtr
A shared pointer to an Element.
shared_ptr< ValueElement > ValueElementPtr
A shared pointer to a ValueElement.
#define MATERIALX_NAMESPACE_END
std::unordered_map< ShaderInput *, ColorSpaceTransform > _inputColorTransformMap
size_t numInputs() const
Get number of inputs/outputs.
ConstDocumentPtr _document
shared_ptr< const Document > ConstDocumentPtr
A shared pointer to a const Document.
IdentifierMap & getIdentifierMap()
Return the map of unique identifiers used in the scope of this graph.