diff --git a/source/JsMaterialX/JsMaterialXCore/JsElement.cpp b/source/JsMaterialX/JsMaterialXCore/JsElement.cpp index 7b7e324f7c..c912d036c1 100644 --- a/source/JsMaterialX/JsMaterialXCore/JsElement.cpp +++ b/source/JsMaterialX/JsMaterialXCore/JsElement.cpp @@ -21,12 +21,12 @@ namespace mx = MaterialX; #define BIND_VALUE_ELEMENT_FUNC_INSTANCE(NAME, T) \ BIND_MEMBER_FUNC("setValue" #NAME, mx::ValueElement, setValue, 1, 2, const T&, stRef) -#define BIND_ELEMENT_CHILD_FUNC_INSTANCE(NAME, T) \ - /*BIND_MEMBER_FUNC("addChild" #NAME, mx::Element, addChild, 0, 1, stRef) */\ - /*.function("getChildOfType" #NAME, &mx::Element::getChildOfType) */\ - /*BIND_MEMBER_FUNC("getChildrenOfType" #NAME, mx::Element, getChildrenOfType, 0, 1, stRef)*/\ - /*.function("removeChildOfType" #NAME, &mx::Element::removeChildOfType) */\ - BIND_MEMBER_FUNC("isA" #NAME, mx::Element, isA, 0, 1, stRef) \ +#define BIND_ELEMENT_CHILD_FUNC_INSTANCE(NAME, T) \ + BIND_MEMBER_FUNC("addChild" #NAME, mx::Element, addChild, 0, 1, stRef) \ + .function("getChildOfType" #NAME, &mx::Element::getChildOfType) \ + BIND_MEMBER_FUNC("getChildrenOfType" #NAME, mx::Element, getChildrenOfType, 0, 1, stRef) \ + .function("removeChildOfType" #NAME, &mx::Element::removeChildOfType) \ + BIND_MEMBER_FUNC("isA" #NAME, mx::Element, isA, 0, 1, stRef) \ .function("asA" #NAME, ems::select_overload()>(&mx::Element::asA)) #define BIND_ELEMENT_FUNC_INSTANCE(NAME, T) \ diff --git a/source/MaterialXCore/Document.h b/source/MaterialXCore/Document.h index 08debd6b1f..ef843435f3 100644 --- a/source/MaterialXCore/Document.h +++ b/source/MaterialXCore/Document.h @@ -80,13 +80,13 @@ class MX_CORE_API Document : public GraphElement /// Return the NodeGraph, if any, with the given name. NodeGraphPtr getNodeGraph(const string& name) const { - return hasDataLibrary() ? getChildOfType(getRegisteredDataLibrary(), name) : getChildOfType(name); + return hasDataLibrary() ? getChildofTypeFromLibrary(getRegisteredDataLibrary(), name) : getChildOfType(name); } /// Return a vector of all NodeGraph elements in the document. vector getNodeGraphs() const { - return hasDataLibrary() ? getChildrenOfType(getRegisteredDataLibrary()) : getChildrenOfType(); + return hasDataLibrary() ? getChildrenOfTypeFromLibrary(getRegisteredDataLibrary()) : getChildrenOfType(); } /// Remove the NodeGraph, if any, with the given name. @@ -347,13 +347,13 @@ class MX_CORE_API Document : public GraphElement /// Return the NodeDef, if any, with the given name. NodeDefPtr getNodeDef(const string& name) const { - return hasDataLibrary() ? getChildOfType(getRegisteredDataLibrary(), name) : getChildOfType(name); + return hasDataLibrary() ? getChildofTypeFromLibrary(getRegisteredDataLibrary(), name) : getChildOfType(name); } /// Return a vector of all NodeDef elements in the document. vector getNodeDefs() const { - return hasDataLibrary() ? getChildrenOfType(getRegisteredDataLibrary()) : getChildrenOfType(); + return hasDataLibrary() ? getChildrenOfTypeFromLibrary(getRegisteredDataLibrary()) : getChildrenOfType(); } /// Remove the NodeDef, if any, with the given name. @@ -384,13 +384,13 @@ class MX_CORE_API Document : public GraphElement /// Return the AttributeDef, if any, with the given name. AttributeDefPtr getAttributeDef(const string& name) const { - return hasDataLibrary() ? getChildOfType(getRegisteredDataLibrary(), name) : getChildOfType(name); + return hasDataLibrary() ? getChildofTypeFromLibrary(getRegisteredDataLibrary(), name) : getChildOfType(name); } /// Return a vector of all AttributeDef elements in the document. vector getAttributeDefs() const { - return hasDataLibrary() ? getChildrenOfType(getRegisteredDataLibrary()) : getChildrenOfType(); + return hasDataLibrary() ? getChildrenOfTypeFromLibrary(getRegisteredDataLibrary()) : getChildrenOfType(); } /// Remove the AttributeDef, if any, with the given name. @@ -416,13 +416,13 @@ class MX_CORE_API Document : public GraphElement /// Return the AttributeDef, if any, with the given name. TargetDefPtr getTargetDef(const string& name) const { - return hasDataLibrary() ? getChildOfType(getRegisteredDataLibrary(), name) : getChildOfType(name); + return hasDataLibrary() ? getChildofTypeFromLibrary(getRegisteredDataLibrary(), name) : getChildOfType(name); } /// Return a vector of all TargetDef elements in the document. vector getTargetDefs() const { - return hasDataLibrary() ? getChildrenOfType(getRegisteredDataLibrary()) : getChildrenOfType(); + return hasDataLibrary() ? getChildrenOfTypeFromLibrary(getRegisteredDataLibrary()) : getChildrenOfType(); } /// Remove the TargetDef, if any, with the given name. @@ -512,13 +512,13 @@ class MX_CORE_API Document : public GraphElement /// Return the Implementation, if any, with the given name. ImplementationPtr getImplementation(const string& name) const { - return hasDataLibrary() ? getChildOfType(getRegisteredDataLibrary(), name) : getChildOfType(name); + return hasDataLibrary() ? getChildofTypeFromLibrary(getRegisteredDataLibrary(), name) : getChildOfType(name); } /// Return a vector of all Implementation elements in the document. vector getImplementations() const { - return hasDataLibrary() ? getChildrenOfType(getRegisteredDataLibrary()) : getChildrenOfType(); + return hasDataLibrary() ? getChildrenOfTypeFromLibrary(getRegisteredDataLibrary()) : getChildrenOfType(); } /// Remove the Implementation, if any, with the given name. @@ -548,13 +548,13 @@ class MX_CORE_API Document : public GraphElement /// Return the UnitDef, if any, with the given name. UnitDefPtr getUnitDef(const string& name) const { - return hasDataLibrary() ? getChildOfType(getRegisteredDataLibrary(), name) : getChildOfType(name); + return hasDataLibrary() ? getChildofTypeFromLibrary(getRegisteredDataLibrary(), name) : getChildOfType(name); } /// Return a vector of all Member elements in the TypeDef. vector getUnitDefs() const { - return hasDataLibrary() ? getChildrenOfType(getRegisteredDataLibrary()) : getChildrenOfType(); + return hasDataLibrary() ? getChildrenOfTypeFromLibrary(getRegisteredDataLibrary()) : getChildrenOfType(); } /// Remove the UnitDef, if any, with the given name. @@ -579,13 +579,13 @@ class MX_CORE_API Document : public GraphElement /// Return the UnitTypeDef, if any, with the given name. UnitTypeDefPtr getUnitTypeDef(const string& name) const { - return hasDataLibrary() ? getChildOfType(getRegisteredDataLibrary(), name) : getChildOfType(name); + return hasDataLibrary() ? getChildofTypeFromLibrary(getRegisteredDataLibrary(), name) : getChildOfType(name); } /// Return a vector of all UnitTypeDef elements in the document. vector getUnitTypeDefs() const { - return hasDataLibrary() ? getChildrenOfType(getRegisteredDataLibrary()) : getChildrenOfType(); + return hasDataLibrary() ? getChildrenOfTypeFromLibrary(getRegisteredDataLibrary()) : getChildrenOfType(); } /// Remove the UnitTypeDef, if any, with the given name. diff --git a/source/MaterialXCore/Element.h b/source/MaterialXCore/Element.h index 8fe62c4710..046b9d9ece 100644 --- a/source/MaterialXCore/Element.h +++ b/source/MaterialXCore/Element.h @@ -448,7 +448,7 @@ class MX_CORE_API Element : public std::enable_shared_from_this /// Return the child element from data library , if any, with the given name and subclass. /// If a child with the given name exists, but belongs to a different /// subclass, then an empty shared pointer is returned. - template shared_ptr getChildOfType(ConstElementPtr datalibrary, const string& name) const + template shared_ptr getChildofTypeFromLibrary(ConstElementPtr datalibrary, const string& name) const { ElementPtr child = datalibrary ? datalibrary->getChild(name) : nullptr; if (!child) @@ -487,7 +487,7 @@ class MX_CORE_API Element : public std::enable_shared_from_this /// Return a combined vector of all child elements including the Data Library that are instances of the given /// subclass, optionally filtered by the given category string. The returned /// vector maintains the order in which children were added. - template vector> getChildrenOfType(ConstElementPtr datalibrary, const string& category = EMPTY_STRING) const + template vector> getChildrenOfTypeFromLibrary(ConstElementPtr datalibrary, const string& category = EMPTY_STRING) const { vector> libraryChildren = datalibrary ? datalibrary->getChildrenOfType(category) : vector>(); vector> children = getChildrenOfType(category); diff --git a/source/MaterialXCore/Interface.cpp b/source/MaterialXCore/Interface.cpp index 8f3f1b3acd..923660b015 100644 --- a/source/MaterialXCore/Interface.cpp +++ b/source/MaterialXCore/Interface.cpp @@ -284,7 +284,7 @@ GeomPropDefPtr Input::getDefaultGeomProp() const { ConstDocumentPtr doc = getDocument(); if (doc->hasDataLibrary()) - return doc->getChildOfType(doc->getRegisteredDataLibrary(),defaultGeomProp); + return doc->getChildofTypeFromLibrary(doc->getRegisteredDataLibrary(),defaultGeomProp); else return doc->getChildOfType(defaultGeomProp); } diff --git a/source/MaterialXGenShader/ShaderGraph.cpp b/source/MaterialXGenShader/ShaderGraph.cpp index 3b0c280e21..0f39b46c32 100644 --- a/source/MaterialXGenShader/ShaderGraph.cpp +++ b/source/MaterialXGenShader/ShaderGraph.cpp @@ -202,11 +202,11 @@ void ShaderGraph::addDefaultGeomNode(ShaderInput* input, const GeomPropDef& geom // input here and ignore the type of the geomprop. They are required to have the same type. string geomNodeDefName = "ND_" + geomprop.getGeomProp() + "_" + input->getType().getName(); NodeDefPtr geomNodeDef = _document->getNodeDef(geomNodeDefName); - if (!geomNodeDef) - { - throw ExceptionShaderGenError("Could not find a nodedef named '" + geomNodeDefName + - "' for defaultgeomprop on input '" + input->getFullName() + "'"); - } + if (!geomNodeDef) + { + throw ExceptionShaderGenError("Could not find a nodedef named '" + geomNodeDefName + + "' for defaultgeomprop on input '" + input->getFullName() + "'"); + } ShaderNodePtr geomNode = ShaderNode::create(this, geomNodeName, *geomNodeDef, context); addNode(geomNode); diff --git a/source/PyMaterialX/PyMaterialXCore/PyElement.cpp b/source/PyMaterialX/PyMaterialXCore/PyElement.cpp index be77e09923..cb70d04704 100644 --- a/source/PyMaterialX/PyMaterialXCore/PyElement.cpp +++ b/source/PyMaterialX/PyMaterialXCore/PyElement.cpp @@ -14,8 +14,8 @@ #define BIND_ELEMENT_FUNC_INSTANCE(T) \ .def("_addChild" #T, &mx::Element::addChild) \ -/*.def("_getChildOfType" #T, &mx::Element::getChildOfType) */\ -/*.def("_getChildrenOfType" #T, &mx::Element::getChildrenOfType, py::arg("category") = mx::EMPTY_STRING) */\ +.def("_getChildOfType" #T, &mx::Element::getChildOfType) \ +.def("_getChildrenOfType" #T, &mx::Element::getChildrenOfType, py::arg("category") = mx::EMPTY_STRING) \ .def("_removeChildOfType" #T, &mx::Element::removeChildOfType) #define BIND_VALUE_ELEMENT_FUNC_INSTANCE(NAME, T) \