MaterialX 1.39.1
|
A node graph element within a Document. More...
#include <Node.h>
Public Member Functions | |
NodeGraph (ElementPtr parent, const string &name) | |
Material References | |
vector< OutputPtr > | getMaterialOutputs () const |
Return all material-type outputs of the nodegraph. | |
NodeDef References | |
void | setNodeDef (ConstNodeDefPtr nodeDef) |
Set the NodeDef element referenced by this NodeGraph. | |
NodeDefPtr | getNodeDef () const |
Return the NodeDef element referenced by this NodeGraph. | |
InterfaceElementPtr | getImplementation () const |
Return the first implementation for this node graph. More... | |
Traversal | |
vector< PortElementPtr > | getDownstreamPorts () const |
Return a vector of all downstream ports that connect to this graph, ordered by the names of the port elements. | |
Utility | |
ConstInterfaceElementPtr | getDeclaration (const string &target=EMPTY_STRING) const override |
Return the first declaration of this interface, optionally filtered by the given target name. More... | |
InputPtr | addInterfaceName (const string &inputPath, const string &interfaceName) |
Add an interface name to an existing NodeDef associated with this NodeGraph. More... | |
void | removeInterfaceName (const string &inputPath) |
Remove an interface name from an existing NodeDef associated with this NodeGraph. More... | |
void | modifyInterfaceName (const string &inputPath, const string &interfaceName) |
Modify the interface name on an existing NodeDef associated with this NodeGraph. More... | |
Validation | |
bool | validate (string *message=nullptr) const override |
Validate that the given element tree, including all descendants, is consistent with the MaterialX specification. More... | |
Public Member Functions inherited from GraphElement | |
NodePtr | addNode (const string &category, const string &name=EMPTY_STRING, const string &type=DEFAULT_TYPE_STRING) |
Add a Node to the graph. More... | |
NodePtr | addNodeInstance (ConstNodeDefPtr nodeDef, const string &name=EMPTY_STRING) |
Add a Node that is an instance of the given NodeDef. | |
NodePtr | getNode (const string &name) const |
Return the Node, if any, with the given name. | |
vector< NodePtr > | getNodes (const string &category=EMPTY_STRING) const |
Return a vector of all Nodes in the graph, optionally filtered by the given category string. | |
vector< NodePtr > | getNodesOfType (const string &nodeType) const |
Return a vector of nodes in the graph which have a given type. | |
void | removeNode (const string &name) |
Remove the Node, if any, with the given name. | |
NodePtr | addMaterialNode (const string &name=EMPTY_STRING, ConstNodePtr shaderNode=nullptr) |
Add a material node to the graph, optionally connecting it to the given shader node. | |
vector< NodePtr > | getMaterialNodes () const |
Return a vector of all material nodes. | |
BackdropPtr | addBackdrop (const string &name=EMPTY_STRING) |
Add a Backdrop to the graph. | |
BackdropPtr | getBackdrop (const string &name) const |
Return the Backdrop, if any, with the given name. | |
vector< BackdropPtr > | getBackdrops () const |
Return a vector of all Backdrop elements in the graph. | |
void | removeBackdrop (const string &name) |
Remove the Backdrop, if any, with the given name. | |
void | flattenSubgraphs (const string &target=EMPTY_STRING, NodePredicate filter=nullptr) |
Flatten all subgraphs at the root scope of this graph element, recursively replacing each graph-defined node with its equivalent node network. More... | |
vector< ElementPtr > | topologicalSort () const |
Return a vector of all children (nodes and outputs) sorted in topological order. | |
NodePtr | addGeomNode (ConstGeomPropDefPtr geomPropDef, const string &namePrefix) |
If not yet present, add a geometry node to this graph matching the given property definition and name prefix. | |
string | asStringDot () const |
Convert this graph to a string in the DOT language syntax. More... | |
Public Member Functions inherited from InterfaceElement | |
void | setNodeDefString (const string &nodeDef) |
Set the NodeDef string for the interface. | |
bool | hasNodeDefString () const |
Return true if the given interface has a NodeDef string. | |
const string & | getNodeDefString () const |
Return the NodeDef string for the interface. | |
InputPtr | addInput (const string &name=EMPTY_STRING, const string &type=DEFAULT_TYPE_STRING) |
Add an Input to this interface. More... | |
InputPtr | getInput (const string &name) const |
Return the Input, if any, with the given name. | |
vector< InputPtr > | getInputs () const |
Return a vector of all Input elements. | |
size_t | getInputCount () const |
Return the number of Input elements. | |
void | removeInput (const string &name) |
Remove the Input, if any, with the given name. | |
InputPtr | getActiveInput (const string &name) const |
Return the first Input with the given name that belongs to this interface, taking interface inheritance into account. | |
vector< InputPtr > | getActiveInputs () const |
Return a vector of all Input elements that belong to this interface, taking inheritance into account. | |
OutputPtr | addOutput (const string &name=EMPTY_STRING, const string &type=DEFAULT_TYPE_STRING) |
Add an Output to this interface. More... | |
OutputPtr | getOutput (const string &name) const |
Return the Output, if any, with the given name. | |
vector< OutputPtr > | getOutputs () const |
Return a vector of all Output elements. | |
size_t | getOutputCount () const |
Return the number of Output elements. | |
void | removeOutput (const string &name) |
Remove the Output, if any, with the given name. | |
OutputPtr | getActiveOutput (const string &name) const |
Return the first Output with the given name that belongs to this interface, taking interface inheritance into account. | |
vector< OutputPtr > | getActiveOutputs () const |
Return a vector of all Output elements that belong to this interface, taking inheritance into account. | |
void | setConnectedOutput (const string &inputName, OutputPtr output) |
Set the output to which the given input is connected, creating a child input if needed. More... | |
OutputPtr | getConnectedOutput (const string &inputName) const |
Return the output connected to the given input. More... | |
TokenPtr | addToken (const string &name=EMPTY_STRING) |
Add a Token to this interface. More... | |
TokenPtr | getToken (const string &name) const |
Return the Token, if any, with the given name. | |
vector< TokenPtr > | getTokens () const |
Return a vector of all Token elements. | |
void | removeToken (const string &name) |
Remove the Token, if any, with the given name. | |
TokenPtr | getActiveToken (const string &name) const |
Return the first Token with the given name that belongs to this interface, taking interface inheritance into account. | |
vector< TokenPtr > | getActiveTokens () const |
Return a vector of all Token elements that belong to this interface, taking inheritance into account. | |
ValueElementPtr | getValueElement (const string &name) const |
Return the ValueElement, if any, with the given name. | |
ValueElementPtr | getActiveValueElement (const string &name) const |
Return the first value element with the given name that belongs to this interface, taking interface inheritance into account. More... | |
vector< ValueElementPtr > | getActiveValueElements () const |
Return a vector of all value elements that belong to this interface, taking inheritance into account. More... | |
template<class T > | |
InputPtr | setInputValue (const string &name, const T &value, const string &type=EMPTY_STRING) |
Set the typed value of an input by its name, creating a child element to hold the input if needed. | |
ValuePtr | getInputValue (const string &name, const string &target=EMPTY_STRING) const |
Return the typed value of an input by its name, taking both the calling element and its declaration into account. More... | |
TokenPtr | setTokenValue (const string &name, const string &value) |
Set the string value of a Token by its name, creating a child element to hold the Token if needed. | |
string | getTokenValue (const string &name) |
Return the string value of a Token by its name, or an empty string if the given Token is not present. | |
void | setTarget (const string &target) |
Set the target string of this interface. | |
bool | hasTarget () const |
Return true if the given interface has a target string. | |
const string & | getTarget () const |
Return the target string of this interface. | |
void | setVersionString (const string &version) |
Set the version string of this interface. | |
bool | hasVersionString () const |
Return true if this interface has a version string. | |
const string & | getVersionString () const |
Return the version string of this interface. | |
void | setVersionIntegers (int majorVersion, int minorVersion) |
Set the major and minor versions as an integer pair. | |
virtual std::pair< int, int > | getVersionIntegers () const |
Return the major and minor versions as an integer pair. More... | |
void | setDefaultVersion (bool defaultVersion) |
Set the default version flag of this element. | |
bool | getDefaultVersion () const |
Return the default version flag of this element. | |
void | clearContent () override |
Clear all attributes and descendants from this element. More... | |
bool | hasExactInputMatch (ConstInterfaceElementPtr declaration, string *message=nullptr) const |
Return true if this instance has an exact input match with the given declaration, where each input of this the instance corresponds to a declaration input of the same name and type. More... | |
Public Member Functions inherited from TypedElement | |
void | setType (const string &type) |
Set the element's type string. | |
bool | hasType () const |
Return true if the given element has a type string. | |
virtual const string & | getType () const |
Return the element's type string. More... | |
bool | isColorType () const |
Return true if the element is of color type. | |
bool | isMultiOutputType () const |
Return true if the element is of multi-output type. | |
TypeDefPtr | getTypeDef () const |
Return the TypeDef declaring the type string of this element. More... | |
Public Member Functions inherited from Element | |
Element (const Element &)=delete | |
Element & | operator= (const Element &)=delete |
bool | operator== (const Element &rhs) const |
Return true if the given element tree, including all descendants, is identical to this one. | |
bool | operator!= (const Element &rhs) const |
Return true if the given element tree, including all descendants, differs from this one. | |
void | setCategory (const string &category) |
Set the element's category string. | |
const string & | getCategory () const |
Return the element's category string. More... | |
void | setName (const string &name) |
Set the element's name string. More... | |
const string & | getName () const |
Return the element's name string. | |
string | getNamePath (ConstElementPtr relativeTo=nullptr) const |
Return the element's hierarchical name path, relative to the root document. More... | |
ElementPtr | getDescendant (const string &namePath) const |
Return the element specified by the given hierarchical name path, relative to the current element. More... | |
void | setFilePrefix (const string &prefix) |
Set the element's file prefix string. | |
bool | hasFilePrefix () const |
Return true if the given element has a file prefix string. | |
const string & | getFilePrefix () const |
Return the element's file prefix string. | |
const string & | getActiveFilePrefix () const |
Return the file prefix string that is active at the scope of this element, taking all ancestor elements into account. | |
void | setGeomPrefix (const string &prefix) |
Set the element's geom prefix string. | |
bool | hasGeomPrefix () const |
Return true if the given element has a geom prefix string. | |
const string & | getGeomPrefix () const |
Return the element's geom prefix string. | |
const string & | getActiveGeomPrefix () const |
Return the geom prefix string that is active at the scope of this element, taking all ancestor elements into account. | |
void | setColorSpace (const string &colorSpace) |
Set the element's color space string. | |
bool | hasColorSpace () const |
Return true if the given element has a color space string. | |
const string & | getColorSpace () const |
Return the element's color space string. | |
const string & | getActiveColorSpace () const |
Return the color space string that is active at the scope of this element, taking all ancestor elements into account. | |
void | setInheritString (const string &inherit) |
Set the inherit string of this element. | |
bool | hasInheritString () const |
Return true if this element has an inherit string. | |
const string & | getInheritString () const |
Return the inherit string of this element. | |
void | setInheritsFrom (ConstElementPtr super) |
Set the element that this one directly inherits from. | |
ElementPtr | getInheritsFrom () const |
Return the element, if any, that this one directly inherits from. | |
bool | hasInheritedBase (ConstElementPtr base) const |
Return true if this element has the given element as an inherited base, taking the full inheritance chain into account. | |
bool | hasInheritanceCycle () const |
Return true if the inheritance chain for this element contains a cycle. | |
void | setNamespace (const string &space) |
Set the namespace string of this element. | |
bool | hasNamespace () const |
Return true if this element has a namespace string. | |
const string & | getNamespace () const |
Return the namespace string of this element. | |
string | getQualifiedName (const string &name) const |
Return a qualified version of the given name, taking the namespace at the scope of this element into account. | |
void | setDocString (const string &doc) |
Set the documentation string of this element. | |
string | getDocString () const |
Return the documentation string of this element. | |
template<class T > | |
bool | isA (const string &category=EMPTY_STRING) const |
Return true if this element belongs to the given subclass. More... | |
template<class T > | |
shared_ptr< T > | asA () |
Dynamic cast to an instance of the given subclass. | |
template<class T > | |
shared_ptr< const T > | asA () const |
Dynamic cast to a const instance of the given subclass. | |
template<class T > | |
shared_ptr< T > | addChild (const string &name=EMPTY_STRING) |
Add a child element of the given subclass and name. More... | |
ElementPtr | addChildOfCategory (const string &category, string name=EMPTY_STRING) |
Add a child element of the given category and name. More... | |
ElementPtr | changeChildCategory (ElementPtr child, const string &category) |
Change the category of the given child element. More... | |
ElementPtr | getChild (const string &name) const |
Return the child element, if any, with the given name. | |
template<class T > | |
shared_ptr< T > | getChildOfType (const string &name) const |
Return the child element, if any, with the given name and subclass. More... | |
const vector< ElementPtr > & | getChildren () const |
Return a constant vector of all child elements. More... | |
template<class T > | |
vector< shared_ptr< T > > | getChildrenOfType (const string &category=EMPTY_STRING) const |
Return a vector of all child elements that are instances of the given subclass, optionally filtered by the given category string. More... | |
void | setChildIndex (const string &name, int index) |
Set the index of the child, if any, with the given name. More... | |
int | getChildIndex (const string &name) const |
Return the index of the child, if any, with the given name. More... | |
void | removeChild (const string &name) |
Remove the child element, if any, with the given name. | |
template<class T > | |
void | removeChildOfType (const string &name) |
Remove the child element, if any, with the given name and subclass. More... | |
void | setAttribute (const string &attrib, const string &value) |
Set the value string of the given attribute. | |
bool | hasAttribute (const string &attrib) const |
Return true if the given attribute is present. | |
const string & | getAttribute (const string &attrib) const |
Return the value string of the given attribute. More... | |
const StringVec & | getAttributeNames () const |
Return a vector of stored attribute names, in the order they were set. | |
template<class T > | |
void | setTypedAttribute (const string &attrib, const T &data) |
Set the value of an implicitly typed attribute. More... | |
template<class T > | |
T | getTypedAttribute (const string &attrib) const |
Return the value of an implicitly typed attribute. More... | |
void | removeAttribute (const string &attrib) |
Remove the given attribute, if present. | |
ElementPtr | getSelf () |
Return our self pointer. | |
ConstElementPtr | getSelf () const |
Return our self pointer. | |
ElementPtr | getParent () |
Return our parent element. | |
ConstElementPtr | getParent () const |
Return our parent element. | |
ElementPtr | getRoot () |
Return the root element of our tree. | |
ConstElementPtr | getRoot () const |
Return the root element of our tree. | |
DocumentPtr | getDocument () |
Return the root document of our tree. | |
ConstDocumentPtr | getDocument () const |
Return the root document of our tree. | |
template<class T > | |
shared_ptr< T > | getAncestorOfType () |
Return the first ancestor of the given subclass, or an empty shared pointer if no ancestor of this subclass is found. | |
template<class T > | |
shared_ptr< const T > | getAncestorOfType () const |
Return the first ancestor of the given subclass, or an empty shared pointer if no ancestor of this subclass is found. | |
TreeIterator | traverseTree () const |
Traverse the tree from the given element to each of its descendants in depth-first order, using pre-order visitation. More... | |
GraphIterator | traverseGraph () const |
Traverse the dataflow graph from the given element to each of its upstream sources in depth-first order, using pre-order visitation. More... | |
virtual Edge | getUpstreamEdge (size_t index=0) const |
Return the Edge with the given index that lies directly upstream from this element in the dataflow graph. More... | |
virtual size_t | getUpstreamEdgeCount () const |
Return the number of queriable upstream edges for this element. More... | |
ElementPtr | getUpstreamElement (size_t index=0) const |
Return the Element with the given index that lies directly upstream from this one in the dataflow graph. More... | |
InheritanceIterator | traverseInheritance () const |
Traverse the inheritance chain from the given element to each element from which it inherits. More... | |
void | setSourceUri (const string &sourceUri) |
Set the element's source URI. More... | |
bool | hasSourceUri () const |
Return true if this element has a source URI. | |
const string & | getSourceUri () const |
Return the element's source URI. | |
const string & | getActiveSourceUri () const |
Return the source URI that is active at the scope of this element, taking all ancestor elements into account. | |
void | copyContentFrom (const ConstElementPtr &source) |
Copy all attributes and descendants from the given element to this one. More... | |
string | createValidChildName (string name) const |
Using the input name as a starting point, modify it to create a valid, unique name for a child element. | |
StringResolverPtr | createStringResolver (const string &geom=EMPTY_STRING) const |
Construct a StringResolver at the scope of this element. More... | |
string | asString () const |
Return a single-line description of this element, including its category, name, and attributes. | |
Static Public Attributes | |
static const string | CATEGORY |
Static Public Attributes inherited from InterfaceElement | |
static const string | NODE_DEF_ATTRIBUTE |
static const string | TARGET_ATTRIBUTE |
static const string | VERSION_ATTRIBUTE |
static const string | DEFAULT_VERSION_ATTRIBUTE |
Static Public Attributes inherited from TypedElement | |
static const string | TYPE_ATTRIBUTE |
Static Public Attributes inherited from Element | |
static const string | NAME_ATTRIBUTE |
static const string | FILE_PREFIX_ATTRIBUTE |
static const string | GEOM_PREFIX_ATTRIBUTE |
static const string | COLOR_SPACE_ATTRIBUTE |
static const string | INHERIT_ATTRIBUTE |
static const string | NAMESPACE_ATTRIBUTE |
static const string | DOC_ATTRIBUTE |
static const string | XPOS_ATTRIBUTE |
static const string | YPOS_ATTRIBUTE |
Additional Inherited Members | |
Protected Types inherited from InterfaceElement | |
using | NodeDefPtr = shared_ptr< NodeDef > |
using | ConstNodeDefPtr = shared_ptr< const NodeDef > |
Protected Types inherited from TypedElement | |
using | TypeDefPtr = shared_ptr< class TypeDef > |
Protected Types inherited from Element | |
using | DocumentPtr = shared_ptr< Document > |
using | ConstDocumentPtr = shared_ptr< const Document > |
Protected Member Functions inherited from GraphElement | |
GraphElement (ElementPtr parent, const string &category, const string &name) | |
Protected Member Functions inherited from InterfaceElement | |
InterfaceElement (ElementPtr parent, const string &category, const string &name) | |
void | registerChildElement (ElementPtr child) override |
void | unregisterChildElement (ElementPtr child) override |
Protected Member Functions inherited from TypedElement | |
TypedElement (ElementPtr parent, const string &category, const string &name) | |
Protected Member Functions inherited from Element | |
Element (ElementPtr parent, const string &category, const string &name) | |
template<class T > | |
shared_ptr< T > | resolveNameReference (const string &name, ConstElementPtr parent=nullptr) const |
void | validateRequire (bool expression, bool &res, string *message, const string &errorDesc) const |
virtual void | registerChildElement (ElementPtr child) |
virtual void | unregisterChildElement (ElementPtr child) |
ElementPtr | getSelfNonConst () const |
Protected Attributes inherited from Element | |
string | _category |
string | _name |
string | _sourceUri |
ElementMap | _childMap |
vector< ElementPtr > | _childOrder |
StringMap | _attributeMap |
StringVec | _attributeOrder |
weak_ptr< Element > | _parent |
weak_ptr< Element > | _root |
A node graph element within a Document.
InputPtr addInterfaceName | ( | const string & | inputPath, |
const string & | interfaceName | ||
) |
|
overridevirtual |
Return the first declaration of this interface, optionally filtered by the given target name.
Reimplemented from InterfaceElement.
InterfaceElementPtr getImplementation | ( | ) | const |
Return the first implementation for this node graph.
void modifyInterfaceName | ( | const string & | inputPath, |
const string & | interfaceName | ||
) |
void removeInterfaceName | ( | const string & | inputPath | ) |
|
overridevirtual |
Validate that the given element tree, including all descendants, is consistent with the MaterialX specification.
Reimplemented from Element.