MaterialX  1.36.1
Public Member Functions | Static Public Member Functions | Static Public Attributes | Related Functions | List of all members
MaterialX::Document Class Reference

A MaterialX document, which represents the top-level element in the MaterialX ownership hierarchy. More...

#include <Document.h>

Inheritance diagram for MaterialX::Document:
MaterialX::GraphElement MaterialX::InterfaceElement MaterialX::TypedElement MaterialX::Element MaterialX::ObservedDocument

Public Member Functions

 Document (ElementPtr parent, const string &name)
 
virtual void initialize ()
 Initialize the document, removing any existing content.
 
virtual DocumentPtr copy ()
 Create a deep copy of the document.
 
void importLibrary (ConstDocumentPtr library, const CopyOptions *copyOptions=nullptr)
 Import the given document as a library within this document. More...
 
NodeGraph Elements
NodeGraphPtr addNodeGraph (const string &name=EMPTY_STRING)
 Add a NodeGraph to the document. More...
 
NodeGraphPtr getNodeGraph (const string &name) const
 Return the NodeGraph, if any, with the given name.
 
vector< NodeGraphPtrgetNodeGraphs () const
 Return a vector of all NodeGraph elements in the document.
 
void removeNodeGraph (const string &name)
 Remove the NodeGraph, if any, with the given name.
 
vector< PortElementPtrgetMatchingPorts (const string &nodeName) const
 Return a vector of all port elements that match the given node name. More...
 
Material Elements
MaterialPtr addMaterial (const string &name=EMPTY_STRING)
 Add a Material to the document. More...
 
MaterialPtr getMaterial (const string &name) const
 Return the Material, if any, with the given name.
 
vector< MaterialPtrgetMaterials () const
 Return a vector of all Material elements in the document.
 
void removeMaterial (const string &name)
 Remove the Material, if any, with the given name.
 
GeomInfo Elements
GeomInfoPtr addGeomInfo (const string &name=EMPTY_STRING, const string &geom=UNIVERSAL_GEOM_NAME)
 Add a GeomInfo to the document. More...
 
GeomInfoPtr getGeomInfo (const string &name) const
 Return the GeomInfo, if any, with the given name.
 
vector< GeomInfoPtrgetGeomInfos () const
 Return a vector of all GeomInfo elements in the document.
 
void removeGeomInfo (const string &name)
 Remove the GeomInfo, if any, with the given name.
 
Look Elements
LookPtr addLook (const string &name=EMPTY_STRING)
 Add a Look to the document. More...
 
LookPtr getLook (const string &name) const
 Return the Look, if any, with the given name.
 
vector< LookPtrgetLooks () const
 Return a vector of all Look elements in the document.
 
void removeLook (const string &name)
 Remove the Look, if any, with the given name.
 
Collection Elements
CollectionPtr addCollection (const string &name=EMPTY_STRING)
 Add a Collection to the document. More...
 
CollectionPtr getCollection (const string &name) const
 Return the Collection, if any, with the given name.
 
vector< CollectionPtrgetCollections () const
 Return a vector of all Collection elements in the document.
 
void removeCollection (const string &name)
 Remove the Collection, if any, with the given name.
 
TypeDef Elements
TypeDefPtr addTypeDef (const string &name)
 Add a TypeDef to the document. More...
 
TypeDefPtr getTypeDef (const string &name) const
 Return the TypeDef, if any, with the given name.
 
vector< TypeDefPtr > getTypeDefs () const
 Return a vector of all TypeDef elements in the document.
 
void removeTypeDef (const string &name)
 Remove the TypeDef, if any, with the given name.
 
NodeDef Elements
NodeDefPtr addNodeDef (const string &name=EMPTY_STRING, const string &type=DEFAULT_TYPE_STRING, const string &node=EMPTY_STRING)
 Add a NodeDef to the document. More...
 
NodeDefPtr getNodeDef (const string &name) const
 Return the NodeDef, if any, with the given name.
 
vector< NodeDefPtr > getNodeDefs () const
 Return a vector of all NodeDef elements in the document.
 
void removeNodeDef (const string &name)
 Remove the NodeDef, if any, with the given name.
 
vector< NodeDefPtr > getMatchingNodeDefs (const string &nodeName) const
 Return a vector of all NodeDef elements that match the given node name.
 
PropertySet Elements
PropertySetPtr addPropertySet (const string &name=EMPTY_STRING)
 Add a PropertySet to the document. More...
 
PropertySetPtr getPropertySet (const string &name) const
 Return the PropertySet, if any, with the given name.
 
vector< PropertySetPtrgetPropertySets () const
 Return a vector of all PropertySet elements in the document.
 
void removePropertySet (const string &name)
 Remove the PropertySet, if any, with the given name.
 
VariantSet Elements
VariantSetPtr addVariantSet (const string &name=EMPTY_STRING)
 Add a VariantSet to the document. More...
 
VariantSetPtr getVariantSet (const string &name) const
 Return the VariantSet, if any, with the given name.
 
vector< VariantSetPtrgetVariantSets () const
 Return a vector of all VariantSet elements in the document.
 
void removeVariantSet (const string &name)
 Remove the VariantSet, if any, with the given name.
 
Implementation Elements
ImplementationPtr addImplementation (const string &name=EMPTY_STRING)
 Add an Implementation to the document. More...
 
ImplementationPtr getImplementation (const string &name) const
 Return the Implementation, if any, with the given name.
 
vector< ImplementationPtrgetImplementations () const
 Return a vector of all Implementation elements in the document.
 
void removeImplementation (const string &name)
 Remove the Implementation, if any, with the given name.
 
vector< InterfaceElementPtrgetMatchingImplementations (const string &nodeDef) const
 Return a vector of all node implementations that match the given NodeDef string. More...
 
Version
std::pair< int, int > getVersionIntegers () const override
 Return the major and minor versions as an integer pair.
 
void upgradeVersion ()
 Upgrade the content of this document from earlier supported versions to the library version. More...
 
Color Management System
void setColorManagementSystem (const string &cms)
 Set the color management system string.
 
bool hasColorManagementSystem () const
 Return true if a color management system string has been set.
 
const string & getColorManagementSystem () const
 Return the color management system string.
 
Color Management Config
void setColorManagementConfig (const string &cmsConfig)
 Set the color management config string.
 
bool hasColorManagementConfig () const
 Return true if a color management config string has been set.
 
const string & getColorManagementConfig () const
 Return the color management config string.
 
Validation
bool validate (string *message=nullptr) const override
 Validate that the given document is consistent with the MaterialX specification. More...
 
Callbacks
virtual void enableCallbacks ()
 Enable all observer callbacks.
 
virtual void disableCallbacks ()
 Disable all observer callbacks.
 
virtual void onAddElement (ElementPtr parent, ElementPtr elem)
 Called when an element is added to the element tree.
 
virtual void onRemoveElement (ElementPtr parent, ElementPtr elem)
 Called when an element is removed from the element tree.
 
virtual void onSetAttribute (ElementPtr elem, const string &attrib, const string &value)
 Called when an attribute of an element is set to a new value.
 
virtual void onRemoveAttribute (ElementPtr elem, const string &attrib)
 Called when an attribute of an element is removed.
 
virtual void onInitialize ()
 Called when a document is initialized.
 
virtual void onRead ()
 Called when data is read into the current document.
 
virtual void onWrite ()
 Called when data is written from the current document.
 
virtual void onBeginUpdate ()
 Called before a set of document updates is performed.
 
virtual void onEndUpdate ()
 Called after a set of document updates is performed.
 
- Public Member Functions inherited from MaterialX::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< NodePtrgetNodes (const string &category=EMPTY_STRING) const
 Return a vector of all Nodes in the graph, optionally filtered by the given category string. More...
 
void removeNode (const string &name)
 Remove the Node, if any, with the given name.
 
void flattenSubgraphs (const string &target=EMPTY_STRING)
 Flatten any references to graph-based node definitions within this node graph, replacing each reference with the equivalent node network. More...
 
vector< ElementPtrtopologicalSort () const
 Return a vector of all children (nodes and outputs) sorted in topological order. More...
 
string asStringDot () const
 Convert this graph to a string in the DOT language syntax. More...
 
- Public Member Functions inherited from MaterialX::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.
 
ParameterPtr addParameter (const string &name=DEFAULT_TYPE_STRING, const string &type=DEFAULT_TYPE_STRING)
 Add a Parameter to this interface. More...
 
ParameterPtr getParameter (const string &name) const
 Return the Parameter, if any, with the given name.
 
vector< ParameterPtrgetParameters () const
 Return a vector of all Parameter elements.
 
size_t getParameterCount () const
 Return the number of Parameter elements.
 
void removeParameter (const string &name)
 Remove the Parameter, if any, with the given name.
 
ParameterPtr getActiveParameter (const string &name) const
 Return the first Parameter with the given name that belongs to this interface, taking interface inheritance into account. More...
 
vector< ParameterPtrgetActiveParameters () const
 Return a vector of all Parameter elements that belong to this interface, taking interface inheritance into account. More...
 
InputPtr addInput (const string &name=DEFAULT_TYPE_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< InputPtrgetInputs () 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. More...
 
vector< InputPtrgetActiveInputs () const
 Return a vector of all Input elements that belong to this interface, taking inheritance into account. More...
 
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< OutputPtrgetOutputs () 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. More...
 
vector< OutputPtrgetActiveOutputs () const
 Return a vector of all Output elements that belong to this interface, taking inheritance into account. 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< TokenPtrgetTokens () 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. More...
 
vector< TokenPtrgetActiveTokens () const
 Return a vector of all Token elements that belong to this interface, taking inheritance into account. More...
 
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< ValueElementPtrgetActiveValueElements () const
 Return a vector of all value elements that belong to this interface, taking inheritance into account. More...
 
template<class T >
ParameterPtr setParameterValue (const string &name, const T &value, const string &type=EMPTY_STRING)
 Set the typed value of a parameter by its name, creating a child element to hold the parameter if needed. More...
 
ValuePtr getParameterValue (const string &name, const string &target=EMPTY_STRING) const
 Return the typed value of a parameter by its name, taking both the calling element and its declaration 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. More...
 
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. More...
 
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. More...
 
virtual ConstNodeDefPtr getDeclaration (const string &target=EMPTY_STRING) const
 Return the first declaration of this interface, optionally filtered by the given target name. More...
 
bool isTypeCompatible (ConstInterfaceElementPtr rhs) const
 Return true if the given interface element is type compatible with this one. More...
 
- Public Member Functions inherited from MaterialX::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.
 
const string & getType () const
 Return the element's type string.
 
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 MaterialX::Element
bool operator== (const Element &rhs) const
 Return true if the given element tree, including all descendants, is identical to this one. More...
 
bool operator!= (const Element &rhs) const
 Return true if the given element tree, including all descendants, differs from this one. More...
 
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)
 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. More...
 
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. More...
 
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. More...
 
void setTarget (const string &target)
 Set the element's target string.
 
bool hasTarget () const
 Return true if the given element has a target string.
 
const string & getTarget () const
 Return the element's target string.
 
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. More...
 
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. More...
 
void setVersionString (const string &version)
 Set the version string of this element.
 
bool hasVersionString () const
 Return true if this element has a version string.
 
const string & getVersionString () const
 Return the version string of this element.
 
void setDefaultVersion (bool defaultVersion)
 Set the default version flag of this element.
 
bool getDefaultVersion () const
 Return the default version flag 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, const string &name=EMPTY_STRING)
 Add a child element of the given category and name. 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 type, 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 StringVecgetAttributeNames () 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 >
const T getTypedAttribute (const string &attrib) const
 Return the 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.
 
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 (ConstMaterialPtr material=nullptr) 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 (ConstMaterialPtr material=nullptr, 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.
 
ElementPtr getUpstreamElement (ConstMaterialPtr material=nullptr, 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. More...
 
void copyContentFrom (ConstElementPtr source, const CopyOptions *copyOptions=nullptr)
 Copy all attributes and descendants from the given element to this one. More...
 
void clearContent ()
 Clear all attributes and descendants from this element.
 
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. More...
 
StringResolverPtr createStringResolver (const string &geom=EMPTY_STRING, ConstMaterialPtr material=nullptr, const string &target=EMPTY_STRING, const string &type=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. More...
 

Static Public Member Functions

template<class T >
static shared_ptr< T > createDocument ()
 Create a new document of the given subclass.
 

Static Public Attributes

static const string CATEGORY
 
static const string CMS_ATTRIBUTE = "cms"
 
static const string CMS_CONFIG_ATTRIBUTE = "cmsconfig"
 
- Static Public Attributes inherited from MaterialX::InterfaceElement
static const string NODE_DEF_ATTRIBUTE = "nodedef"
 
- Static Public Attributes inherited from MaterialX::TypedElement
static const string TYPE_ATTRIBUTE = "type"
 
- Static Public Attributes inherited from MaterialX::Element
static const string NAME_ATTRIBUTE = "name"
 
static const string FILE_PREFIX_ATTRIBUTE = "fileprefix"
 
static const string GEOM_PREFIX_ATTRIBUTE = "geomprefix"
 
static const string COLOR_SPACE_ATTRIBUTE = "colorspace"
 
static const string TARGET_ATTRIBUTE = "target"
 
static const string VERSION_ATTRIBUTE = "version"
 
static const string DEFAULT_VERSION_ATTRIBUTE = "isdefaultversion"
 
static const string INHERIT_ATTRIBUTE = "inherit"
 
static const string NAMESPACE_ATTRIBUTE = "namespace"
 

Related Functions

(Note that these are not member functions.)

DocumentPtr createDocument ()
 Create a new Document.
 

Additional Inherited Members

- Protected Types inherited from MaterialX::InterfaceElement
using NodeDefPtr = shared_ptr< NodeDef >
 
using ConstNodeDefPtr = shared_ptr< const NodeDef >
 
- Protected Types inherited from MaterialX::TypedElement
using TypeDefPtr = shared_ptr< class TypeDef >
 
- Protected Types inherited from MaterialX::Element
using DocumentPtr = shared_ptr< Document >
 
using ConstDocumentPtr = shared_ptr< const Document >
 
using ConstMaterialPtr = shared_ptr< const Material >
 
- Protected Member Functions inherited from MaterialX::GraphElement
 GraphElement (ElementPtr parent, const string &category, const string &name)
 
- Protected Member Functions inherited from MaterialX::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 MaterialX::TypedElement
 TypedElement (ElementPtr parent, const string &category, const string &name)
 
- Protected Member Functions inherited from MaterialX::Element
 Element (ElementPtr parent, const string &category, const string &name)
 
template<class T >
shared_ptr< T > resolveRootNameReference (const string &name) const
 
void validateRequire (bool expression, bool &res, string *message, string errorDesc) const
 
ElementPtr getSelfNonConst () const
 
- Protected Attributes inherited from MaterialX::Element
string _category
 
string _name
 
string _sourceUri
 
ElementMap _childMap
 
vector< ElementPtr_childOrder
 
StringMap _attributeMap
 
StringVec _attributeOrder
 
weak_ptr< Element_parent
 
weak_ptr< Element_root
 

Detailed Description

A MaterialX document, which represents the top-level element in the MaterialX ownership hierarchy.

Use the factory function createDocument() to create a Document instance.

Member Function Documentation

◆ addCollection()

CollectionPtr MaterialX::Document::addCollection ( const string &  name = EMPTY_STRING)
inline

Add a Collection to the document.

Parameters
nameThe name of the new Collection. If no name is specified, then a unique name will automatically be generated.
Returns
A shared pointer to the new Collection.

◆ addGeomInfo()

GeomInfoPtr MaterialX::Document::addGeomInfo ( const string &  name = EMPTY_STRING,
const string &  geom = UNIVERSAL_GEOM_NAME 
)
inline

Add a GeomInfo to the document.

Parameters
nameThe name of the new GeomInfo. If no name is specified, then a unique name will automatically be generated.
geomAn optional geometry string for the GeomInfo.
Returns
A shared pointer to the new GeomInfo.

◆ addImplementation()

ImplementationPtr MaterialX::Document::addImplementation ( const string &  name = EMPTY_STRING)
inline

Add an Implementation to the document.

Parameters
nameThe name of the new Implementation. If no name is specified, then a unique name will automatically be generated.
Returns
A shared pointer to the new Implementation.

◆ addLook()

LookPtr MaterialX::Document::addLook ( const string &  name = EMPTY_STRING)
inline

Add a Look to the document.

Parameters
nameThe name of the new Look. If no name is specified, then a unique name will automatically be generated.
Returns
A shared pointer to the new Look.

◆ addMaterial()

MaterialPtr MaterialX::Document::addMaterial ( const string &  name = EMPTY_STRING)
inline

Add a Material to the document.

Parameters
nameThe name of the new Material. If no name is specified, then a unique name will automatically be generated.
Returns
A shared pointer to the new Material.

◆ addNodeDef()

NodeDefPtr MaterialX::Document::addNodeDef ( const string &  name = EMPTY_STRING,
const string &  type = DEFAULT_TYPE_STRING,
const string &  node = EMPTY_STRING 
)
inline

Add a NodeDef to the document.

Parameters
nameThe name of the new NodeDef. If no name is specified, then a unique name will automatically be generated.
typeAn optional type string.
nodeAn optional node string.
Returns
A shared pointer to the new NodeDef.

◆ addNodeGraph()

NodeGraphPtr MaterialX::Document::addNodeGraph ( const string &  name = EMPTY_STRING)
inline

Add a NodeGraph to the document.

Parameters
nameThe name of the new NodeGraph. If no name is specified, then a unique name will automatically be generated.
Returns
A shared pointer to the new NodeGraph.

◆ addPropertySet()

PropertySetPtr MaterialX::Document::addPropertySet ( const string &  name = EMPTY_STRING)
inline

Add a PropertySet to the document.

Parameters
nameThe name of the new PropertySet. If no name is specified, then a unique name will automatically be generated.
Returns
A shared pointer to the new PropertySet.

◆ addTypeDef()

TypeDefPtr MaterialX::Document::addTypeDef ( const string &  name)
inline

Add a TypeDef to the document.

Parameters
nameThe name of the new TypeDef. If no name is specified, then a unique name will automatically be generated.
Returns
A shared pointer to the new TypeDef.

◆ addVariantSet()

VariantSetPtr MaterialX::Document::addVariantSet ( const string &  name = EMPTY_STRING)
inline

Add a VariantSet to the document.

Parameters
nameThe name of the new VariantSet. If no name is specified, then a unique name will automatically be generated.
Returns
A shared pointer to the new VariantSet.

◆ getMatchingImplementations()

vector< InterfaceElementPtr > MaterialX::Document::getMatchingImplementations ( const string &  nodeDef) const

Return a vector of all node implementations that match the given NodeDef string.

Note that a node implementation may be either an Implementation element or NodeGraph element.

◆ getMatchingPorts()

vector< PortElementPtr > MaterialX::Document::getMatchingPorts ( const string &  nodeName) const

Return a vector of all port elements that match the given node name.

Port elements support spatially-varying upstream connections to nodes, and include both Input and Output elements.

◆ importLibrary()

void MaterialX::Document::importLibrary ( ConstDocumentPtr  library,
const CopyOptions copyOptions = nullptr 
)

Import the given document as a library within this document.

The contents of the library document are copied into this one, and are assigned the source URI of the library.

Parameters
libraryThe library document to be imported.
copyOptionsAn optional pointer to a CopyOptions object. If provided, then the given options will affect the behavior of the import function. Defaults to a null pointer.

◆ upgradeVersion()

void MaterialX::Document::upgradeVersion ( )

Upgrade the content of this document from earlier supported versions to the library version.

Documents from future versions are left unmodified.

◆ validate()

bool MaterialX::Document::validate ( string *  message = nullptr) const
overridevirtual

Validate that the given document is consistent with the MaterialX specification.

Parameters
messageAn optional output string, to which a description of each error will be appended.
Returns
True if the document passes all tests, false otherwise.

Reimplemented from MaterialX::Element.


The documentation for this class was generated from the following files: