forked from AcademySoftwareFoundation/MaterialX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PyNode.cpp
76 lines (68 loc) · 3.93 KB
/
PyNode.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//
// TM & (c) 2017 Lucasfilm Entertainment Company Ltd. and Lucasfilm Ltd.
// All rights reserved. See LICENSE.txt for license.
//
#include <PyMaterialX/PyMaterialX.h>
#include <MaterialXCore/Node.h>
namespace py = pybind11;
namespace mx = MaterialX;
void bindPyNode(py::module& mod)
{
py::class_<mx::NodePredicate>(mod, "NodePredicate");
py::class_<mx::Node, mx::NodePtr, mx::InterfaceElement>(mod, "Node")
.def("setConnectedNode", &mx::Node::setConnectedNode)
.def("getConnectedNode", &mx::Node::getConnectedNode)
.def("setConnectedNodeName", &mx::Node::setConnectedNodeName)
.def("getConnectedNodeName", &mx::Node::getConnectedNodeName)
.def("getNodeDef", &mx::Node::getNodeDef,
py::arg("target") = mx::EMPTY_STRING)
.def("getImplementation", &mx::Node::getImplementation,
py::arg("target") = mx::EMPTY_STRING)
.def("getDownstreamPorts", &mx::Node::getDownstreamPorts)
.def_readonly_static("CATEGORY", &mx::Node::CATEGORY);
py::class_<mx::GraphElement, mx::GraphElementPtr, mx::InterfaceElement>(mod, "GraphElement")
.def("addNode", &mx::GraphElement::addNode,
py::arg("category"), py::arg("name") = mx::EMPTY_STRING, py::arg("type") = mx::DEFAULT_TYPE_STRING)
.def("addNodeInstance", &mx::GraphElement::addNodeInstance,
py::arg("nodeDef"), py::arg("name") = mx::EMPTY_STRING)
.def("getNode", &mx::GraphElement::getNode)
.def("getNodes", &mx::GraphElement::getNodes,
py::arg("category") = mx::EMPTY_STRING)
.def("removeNode", &mx::GraphElement::removeNode)
.def("addMaterialNode", &mx::GraphElement::addMaterialNode,
py::arg("name") = mx::EMPTY_STRING, py::arg("shaderNode") = nullptr)
.def("getMaterialNodes", &mx::GraphElement::getMaterialNodes)
.def("addBackdrop", &mx::GraphElement::addBackdrop,
py::arg("name") = mx::EMPTY_STRING)
.def("getBackdrop", &mx::GraphElement::getBackdrop)
.def("getBackdrops", &mx::GraphElement::getBackdrops)
.def("removeBackdrop", &mx::GraphElement::removeBackdrop)
.def("flattenSubgraphs", &mx::GraphElement::flattenSubgraphs,
py::arg("target") = mx::EMPTY_STRING, py::arg("filter") = nullptr)
.def("topologicalSort", &mx::GraphElement::topologicalSort)
.def("asStringDot", &mx::GraphElement::asStringDot);
py::class_<mx::NodeGraph, mx::NodeGraphPtr, mx::GraphElement>(mod, "NodeGraph")
.def("setNodeDef", &mx::NodeGraph::setNodeDef)
.def("getNodeDef", &mx::NodeGraph::getNodeDef)
.def("getDeclaration", &mx::NodeGraph::getDeclaration)
.def("addInterfaceName", &mx::NodeGraph::addInterfaceName)
.def("removeInterfaceName", &mx::NodeGraph::removeInterfaceName)
.def("modifyInterfaceName", &mx::NodeGraph::modifyInterfaceName)
.def_readonly_static("CATEGORY", &mx::NodeGraph::CATEGORY);
py::class_<mx::Backdrop, mx::BackdropPtr, mx::Element>(mod, "Backdrop")
.def("setContainsString", &mx::Backdrop::setContainsString)
.def("hasContainsString", &mx::Backdrop::hasContainsString)
.def("getContainsString", &mx::Backdrop::getContainsString)
.def("setWidth", &mx::Backdrop::setWidth)
.def("hasWidth", &mx::Backdrop::hasWidth)
.def("getWidth", &mx::Backdrop::getWidth)
.def("setHeight", &mx::Backdrop::setHeight)
.def("hasHeight", &mx::Backdrop::hasHeight)
.def("getHeight", &mx::Backdrop::getHeight)
.def("setContainsElements", &mx::Backdrop::setContainsElements)
.def("getContainsElements", &mx::Backdrop::getContainsElements)
.def_readonly_static("CATEGORY", &mx::Backdrop::CATEGORY)
.def_readonly_static("CONTAINS_ATTRIBUTE", &mx::Backdrop::CONTAINS_ATTRIBUTE)
.def_readonly_static("WIDTH_ATTRIBUTE", &mx::Backdrop::WIDTH_ATTRIBUTE)
.def_readonly_static("HEIGHT_ATTRIBUTE", &mx::Backdrop::HEIGHT_ATTRIBUTE);
}