예제 #1
0
def testSpecializingPass():
    coralApp.init()
    
    collapsed0 = coralApp.createNode("CollapsedNode", "collapsed0", coralApp.rootNode())
    in0 = coralApp.createAttribute("PassThroughAttribute", "in0", collapsed0, input = True)
    out0 = coralApp.createAttribute("PassThroughAttribute", "out0", collapsed0, output = True)
    
    collapsed = coralApp.createNode("CollapsedNode", "collapsed", collapsed0)
    in1 = coralApp.createAttribute("PassThroughAttribute", "in", collapsed, input = True)
    out1 = coralApp.createAttribute("PassThroughAttribute", "out", collapsed, output = True)
    add = coralApp.createNode("Add", "addNode", collapsed)
    
    _coral.NetworkManager.connect(in1, add.inputAttributeAt(0))
    _coral.NetworkManager.connect(add.outputAttributeAt(0), out1)
    
    _coral.NetworkManager.connect(in0, in1)
    _coral.NetworkManager.connect(out1, out0)

    float1 = coralApp.createNode("Float", "float1", coralApp.rootNode())
    floats = coralApp.createNode("Vec3", "floats", coralApp.rootNode())
    
    _coral.NetworkManager.connect(out0, floats.inputAttributeAt(0))
    _coral.NetworkManager.connect(float1.outputAttributeAt(0), in0)
    
    assert add.inputAttributeAt(0).specialization() == ["Float"]
    assert add.outputAttributeAt(0).specialization() == ["Float"]
    
    assert in0.specialization() == ["Float"]
    assert in1.specialization() == ["Float"]
    
    assert out1.specialization() == ["Float"] 
    
    coralApp.finalize()
예제 #2
0
def testCollapsingBug1():
    coralApp.init()

    collapsed = coralApp.createNode("CollapsedNode", "collapsed",
                                    coralApp.rootNode())
    in1 = coralApp.createAttribute("PassThroughAttribute",
                                   "in",
                                   collapsed,
                                   input=True)
    add = coralApp.createNode("Add", "addNode", collapsed)

    _coral.NetworkManager.connect(in1, add.inputAttributeAt(0))

    float1 = coralApp.createNode("Float", "float1", coralApp.rootNode())

    _coral.NetworkManager.connect(float1.outputAttributeAt(0), in1)

    newCollapsed = coralApp.collapseNodes([collapsed])
    print "testing collapsing operation won't add erroneous output attributes"
    assert newCollapsed.outputAttributes() == []

    print "testing collapsing operation won't disconnect erroneous attributes"
    assert in1.isConnectedTo(add.inputAttributeAt(0))

    coralApp.finalize()
예제 #3
0
def testNesting():
    coralApp.init()
    
    root = coralApp.findNode("root")
    n1 = coralApp.createNode("CollapsedNode", "n1", root)
    n2 = coralApp.createNode("CollapsedNode", "n2", n1)

    coralApp.finalize()
예제 #4
0
def testNesting():
    coralApp.init()

    root = coralApp.findNode("root")
    n1 = coralApp.createNode("CollapsedNode", "n1", root)
    n2 = coralApp.createNode("CollapsedNode", "n2", n1)

    coralApp.finalize()
예제 #5
0
def testNodeDeletion():
    coralApp.init()
    
    coralApp.createNode("Float", "test", coralApp.findNode("root"))
    coralApp.deleteNodes([coralApp.findNode("root.test")])
    
    assert _coral.NetworkManager.objectCount() == 1
    
    coralApp.finalize()
예제 #6
0
def testNodeDeletion():
    coralApp.init()

    coralApp.createNode("Float", "test", coralApp.findNode("root"))
    coralApp.deleteNodes([coralApp.findNode("root.test")])

    assert _coral.NetworkManager.objectCount() == 1

    coralApp.finalize()
예제 #7
0
def testFindObject():
    coralApp.init()
    
    root = coralApp.findNode("root")
    n1 = coralApp.createNode("CollapsedNode", "n1", root)
    n2 = coralApp.createNode("CollapsedNode", "n2", n1)
    
    assert coralApp.findObject(n2.fullName()) is n2
    
    coralApp.finalize()
예제 #8
0
def testFindObject():
    coralApp.init()

    root = coralApp.findNode("root")
    n1 = coralApp.createNode("CollapsedNode", "n1", root)
    n2 = coralApp.createNode("CollapsedNode", "n2", n1)

    assert coralApp.findObject(n2.fullName()) is n2

    coralApp.finalize()
예제 #9
0
def testSaveScript():
    coralApp.init()

    root = coralApp.findNode("root")
    n1 = coralApp.createNode("Float", "n1", root)
    n2 = coralApp.createNode("Float", "n2", root)
    n3 = coralApp.createNode("Add", "n3", root)

    n1.outputAttributeAt(0).outValue().setFloatValueAt(0, 5.0)

    _coral.NetworkManager.connect(n1.outputAttributeAt(0),
                                  n3.inputAttributeAt(0))

    saveScript = root.contentAsScript()

    coralApp.finalize()

    coralApp.init()
    coralApp.setShouldLogInfos(False)

    coralApp._executeNetworkScript(saveScript)

    n1 = coralApp.findNode("root.n1")
    n2 = coralApp.findNode("root.n2")
    n3 = coralApp.findNode("root.n3")

    assert n1 is not None
    assert n2 is not None
    assert n3 is not None

    n1Floats = n1.outputAttributeAt(0).outValue().getFloat()
    assert n1Floats[0] == 5.0

    assert n3.inputAttributeAt(0).input() is n1.outputAttributeAt(0)

    collapsedNode = coralApp.collapseNodes([n3])

    root = coralApp.findNode("root")

    saveScript = root.contentAsScript()
    coralApp.finalize()

    coralApp.init()
    coralApp._executeNetworkScript(saveScript)

    collapseNode = coralApp.findNode("root.CollapsedNode")
    assert collapseNode is not None
    assert len(collapseNode.attributes()) > 0

    coralApp.finalize()
예제 #10
0
def testSaveScript():
    coralApp.init()
    
    root = coralApp.findNode("root")
    n1 = coralApp.createNode("Float", "n1", root)
    n2 = coralApp.createNode("Float", "n2", root)
    n3 = coralApp.createNode("Add", "n3", root)
    
    n1.outputAttributeAt(0).outValue().setFloatValueAt(0, 5.0)
    
    _coral.NetworkManager.connect(n1.outputAttributeAt(0), n3.inputAttributeAt(0))
    
    saveScript = root.contentAsScript()
    
    coralApp.finalize()
    
    coralApp.init()
    coralApp.setShouldLogInfos(False)
    
    coralApp._executeNetworkScript(saveScript)
    
    n1 = coralApp.findNode("root.n1")
    n2 = coralApp.findNode("root.n2")
    n3 = coralApp.findNode("root.n3")
    
    assert n1 is not None
    assert n2 is not None
    assert n3 is not None
    
    n1Floats = n1.outputAttributeAt(0).outValue().getFloat()
    assert n1Floats[0] == 5.0
    
    assert n3.inputAttributeAt(0).input() is n1.outputAttributeAt(0)
    
    collapsedNode = coralApp.collapseNodes([n3])
    
    root = coralApp.findNode("root")
    
    saveScript = root.contentAsScript()
    coralApp.finalize()
    
    coralApp.init()
    coralApp._executeNetworkScript(saveScript)
    
    collapseNode = coralApp.findNode("root.CollapsedNode")
    assert collapseNode is not None
    assert len(collapseNode.attributes()) > 0
    
    coralApp.finalize()
예제 #11
0
def testCollapsedNode():
    coralApp.init()
    
    root = coralApp.findNode("root")
    n1 = coralApp.createNode("Float", "n1", root)
    n2 = coralApp.createNode("Float", "n2", root)
    n3 = coralApp.createNode("Add", "n3", root)
    
    _coral.NetworkManager.connect(n1.outputAttributeAt(0), n3.inputAttributeAt(0))
    
    collapsedNode = coralApp.collapseNodes([n3])
    
    assert collapsedNode in root.nodes()
    
    coralApp.finalize()
예제 #12
0
def testCollapsedNode():
    coralApp.init()

    root = coralApp.findNode("root")
    n1 = coralApp.createNode("Float", "n1", root)
    n2 = coralApp.createNode("Float", "n2", root)
    n3 = coralApp.createNode("Add", "n3", root)

    _coral.NetworkManager.connect(n1.outputAttributeAt(0),
                                  n3.inputAttributeAt(0))

    collapsedNode = coralApp.collapseNodes([n3])

    assert collapsedNode in root.nodes()

    coralApp.finalize()
예제 #13
0
def testSpecializingPass():
    coralApp.init()

    collapsed0 = coralApp.createNode("CollapsedNode", "collapsed0",
                                     coralApp.rootNode())
    in0 = coralApp.createAttribute("PassThroughAttribute",
                                   "in0",
                                   collapsed0,
                                   input=True)
    out0 = coralApp.createAttribute("PassThroughAttribute",
                                    "out0",
                                    collapsed0,
                                    output=True)

    collapsed = coralApp.createNode("CollapsedNode", "collapsed", collapsed0)
    in1 = coralApp.createAttribute("PassThroughAttribute",
                                   "in",
                                   collapsed,
                                   input=True)
    out1 = coralApp.createAttribute("PassThroughAttribute",
                                    "out",
                                    collapsed,
                                    output=True)
    add = coralApp.createNode("Add", "addNode", collapsed)

    _coral.NetworkManager.connect(in1, add.inputAttributeAt(0))
    _coral.NetworkManager.connect(add.outputAttributeAt(0), out1)

    _coral.NetworkManager.connect(in0, in1)
    _coral.NetworkManager.connect(out1, out0)

    float1 = coralApp.createNode("Float", "float1", coralApp.rootNode())
    floats = coralApp.createNode("Vec3", "floats", coralApp.rootNode())

    _coral.NetworkManager.connect(out0, floats.inputAttributeAt(0))
    _coral.NetworkManager.connect(float1.outputAttributeAt(0), in0)

    assert add.inputAttributeAt(0).specialization() == ["Float"]
    assert add.outputAttributeAt(0).specialization() == ["Float"]

    assert in0.specialization() == ["Float"]
    assert in1.specialization() == ["Float"]

    assert out1.specialization() == ["Float"]

    coralApp.finalize()
예제 #14
0
def testCollapsingBug1():
    coralApp.init()
    
    collapsed = coralApp.createNode("CollapsedNode", "collapsed", coralApp.rootNode())
    in1 = coralApp.createAttribute("PassThroughAttribute", "in", collapsed, input = True)
    add = coralApp.createNode("Add", "addNode", collapsed)
    
    _coral.NetworkManager.connect(in1, add.inputAttributeAt(0))

    float1 = coralApp.createNode("Float", "float1", coralApp.rootNode())
        
    _coral.NetworkManager.connect(float1.outputAttributeAt(0), in1)
    
    newCollapsed = coralApp.collapseNodes([collapsed])
    print "testing collapsing operation won't add erroneous output attributes"
    assert newCollapsed.outputAttributes() == []
    
    print "testing collapsing operation won't disconnect erroneous attributes"
    assert in1.isConnectedTo(add.inputAttributeAt(0))
    
    coralApp.finalize()
예제 #15
0
def testDeletingAttributes():
    coralApp.init()

    root = coralApp.findNode("root")
    n1 = coralApp.createNode("Float", "n1", root)
    n2 = coralApp.createNode("Float", "n2", root)
    n3 = coralApp.createNode("Add", "n3", root)
    n4 = coralApp.createNode("Add", "n4", root)
    n5 = coralApp.createNode("Float", "n5", root)
    n6 = coralApp.createNode("Add", "n6", root)

    _coral.NetworkManager.connect(n1.outputAttributeAt(0),
                                  n3.inputAttributeAt(0))
    _coral.NetworkManager.connect(n2.outputAttributeAt(0),
                                  n3.inputAttributeAt(1))
    _coral.NetworkManager.connect(n3.outputAttributeAt(0),
                                  n4.inputAttributeAt(0))
    _coral.NetworkManager.connect(n5.outputAttributeAt(0),
                                  n4.inputAttributeAt(1))
    _coral.NetworkManager.connect(n3.outputAttributeAt(0),
                                  n6.inputAttributeAt(1))

    coralApp.deleteNodes([n3, n5, n6])

    coralApp.finalize()
예제 #16
0
def testDeletingAttributes():
    coralApp.init()
    
    root = coralApp.findNode("root")
    n1 = coralApp.createNode("Float", "n1", root)
    n2 = coralApp.createNode("Float", "n2", root)
    n3 = coralApp.createNode("Add", "n3", root)
    n4 = coralApp.createNode("Add", "n4", root)
    n5 = coralApp.createNode("Float", "n5", root)
    n6 = coralApp.createNode("Add", "n6", root)

    _coral.NetworkManager.connect(n1.outputAttributeAt(0), n3.inputAttributeAt(0))
    _coral.NetworkManager.connect(n2.outputAttributeAt(0), n3.inputAttributeAt(1))
    _coral.NetworkManager.connect(n3.outputAttributeAt(0), n4.inputAttributeAt(0))
    _coral.NetworkManager.connect(n5.outputAttributeAt(0), n4.inputAttributeAt(1))
    _coral.NetworkManager.connect(n3.outputAttributeAt(0), n6.inputAttributeAt(1))

    coralApp.deleteNodes([n3, n5, n6])
    
    coralApp.finalize()