Пример #1
0
    def callback2(result):
        def callback3(result):
            print('callback3: ' + fabric.stringify(result))
            fabricClient.close()

        print('callback2: ' + fabric.stringify(result))
        ap.produceAsync(4, 8, callback3)
Пример #2
0
def callback1( result ):
  def callback2( result ):
    def callback3( result ):
      print( 'callback3: ' + fabric.stringify(result) )
      fabricClient.close()
    print( 'callback2: ' + fabric.stringify(result) )
    ap.produceAsync(  4, 8, callback3 )
  print( 'callback1: ' + fabric.stringify(result) )
  ap.produceAsync( 5, callback2 )
Пример #3
0
  'members': [ { 'x':'Scalar' }, { 'y':'Scalar' } ],
  'constructor': Vec2,
  'klBindings': {
    'filename': "(inline)",
    'sourceCode': "\
function Vec2(Scalar x, Scalar y)\n\
{\n\
  this.x = x;\n\
  this.y = y;\n\
}\n\
"
  }
}

fabricClient.RegisteredTypesManager.registerType( 'Vec2', desc )
print(fabric.stringify(fabricClient.RT.getRegisteredTypes()['Vec2']))

node = fabricClient.DependencyGraph.createNode("foo")
node.addMember( 'vec2', 'Vec2' )
node.setData( 'vec2', 0, Vec2( 5.6, 4.3 ) )
data = node.getData("vec2", 0)
print( fabric.stringify( data ) )
print( data.sum() )

op = fabricClient.DG.createOperator("op")
op.setSourceCode("(inline)", "use Vec2; operator entry( io Vec2 vec2 ) { vec2 = Vec2(8.9, 2.3); }")
op.setEntryPoint("entry")
if len( op.getErrors() ) > 0:
  print( "ERRORS: " + str( op.getErrors() ) )
  if len( op.getDiagnostics() ) > 0:
    print( "DIAGNOSTICS: " + str( op.getDiagnostics() ) )
Пример #4
0
#
#  Copyright 2010-2012 Fabric Engine Inc. All rights reserved.
#

import fabric
F = fabric.createClient()

o = F.DG.createOperator("op")
o.setSourceCode("\
operator entry(io Size a, io String b) {\n\
  report 'Hello ' + a + ' ' + b;\n\
}\n\
")
o.setEntryPoint("entry")

b = F.DG.createBinding()
b.setOperator(o)
b.setParameterLayout(["self.foo", "self.bar"])

n = F.DG.createNode("node")
n.addMember("foo", "String")
n.addMember("bar", "Size")
n.bindings.append(b)
print(fabric.stringify(n.getErrors()))

F.close()
Пример #5
0
  report "Members: " + i + " " + s;\n\
  otherC = c;\n\
  otherC.resize(Size(3));\n\
  report "Container string: " + otherC + " Count: " + otherC.size + " Is valid: " + Boolean(otherC);\n\
  report "To fix: i.size is wrong! LLVM doesn\'t know about aliasing!";\n\
  i[2] = 1;\n\
  s[2] = "test";\n\
  report "Member sizes: " + s.size;\n\
  report "Members: " + i + " " + s;\n\
  //Now test accessing uninitialized Container\n\
  Container bad;\n\
  report bad.size();\n\
}\n\
')
if len(op.getDiagnostics()) > 0:
    print(fabric.stringify(op.getDiagnostics()))

opBinding = fabricClient.DG.createBinding()
opBinding.setOperator(op)
opBinding.setParameterLayout(
    ["self", "self.intMember<>", "self.stringMember<>"])
node.bindings.append(opBinding)
try:
    node.evaluate()
except Exception as e:
    print("Runtime eval error (uninit container access): " + str(e))

# Error test: we are not allowed to have io Container along with members elements
badOp = fabricClient.DependencyGraph.createOperator("badOp")
badOp.setEntryPoint("badOp")
badOp.setSourceCode('\
Пример #6
0
try:
  fabricClient.IO.putTextFileContent("dummy", "badHandle")
except Exception as e:
  print('Bad handle error: ' + str(e))

readOnlyFileAndFolderHandles = fabricClient.IO.queryUserFileAndFolderHandle(fabricClient.IO.forOpen, "dummy title", "txt", "testfile")

try: 
  fabricClient.IO.putTextFileContent(readOnlyFileAndFolderHandles['file'], "dummy")
except Exception as e:
  print('No write access error: ' + str(e))


fileAndFolderHandles = fabricClient.IO.queryUserFileAndFolderHandle(fabricClient.IO.forOpenWithWriteAccess, "dummy title", "txt", "testfile")
print( 'File and folder handles: ' + fabric.stringify(fileAndFolderHandles));
print('User file name: ' + fabricClient.IO.getFileHandleInfo(fileAndFolderHandles['file'])['fileName'])

relativeFileHandle = fabricClient.IO.buildFileHandleFromRelativePath(fileAndFolderHandles['folder'] + '/SubDir/testfile2.txt')

try:
  dummy = fabricClient.IO.getTextFileContent(relativeFileHandle)
except Exception as e:
  print('File not found error')#'e' has random handle name; don't display it

fabricClient.IO.putTextFileContent(relativeFileHandle,"FileBody")
body = fabricClient.IO.getTextFileContent(relativeFileHandle)
print('File content: ' + body)

fabricClient.IO.putTextFileContent(relativeFileHandle," with appended text",True)
body = fabricClient.IO.getTextFileContent(relativeFileHandle)
Пример #7
0
#
#  Copyright 2010-2012 Fabric Engine Inc. All rights reserved.
#

import fabric
F = fabric.createClient()

def mapNamedObjectsToNames( objects ):
  result = []
  for i in range( 0, len( objects ) ):
    result.append( objects[i].getName() )
  return result

e = F.DG.createEvent("event")
print(e.getName())
print(e.getType())

print(fabric.stringify(mapNamedObjectsToNames(e.getEventHandlers())))
eh = F.DG.createEventHandler("eventHandler")
e.appendEventHandler(eh)
print(fabric.stringify(mapNamedObjectsToNames(e.getEventHandlers())))

e.fire()

F.close()
Пример #8
0
  report 'parent data: ' + arg;\n\
}\n\
")
diagnostics = op.getDiagnostics()
if len(diagnostics) > 0:
    for i in diagnostics:
        print(diagnostics[i].line + ": " + diagnostics[i].desc)
    print("Full code:")
    print(op.getFullSourceCode())
else:
    parentNode = fabricClient.DependencyGraph.createNode("parentNode")
    parentNode.addMember("msa", "MyStruct[]")
    parentNode.resize(2)
    parentNode.setData("msa", 0, [MyStruct(42, 3.141), MyStruct(64, 5.67)])
    parentNode.setData("msa", 1, [MyStruct(7, 2.718)])
    print(fabric.stringify(parentNode.getData("msa", 0)))
    print(fabric.stringify(parentNode.getData("msa", 1)))

    binding = fabricClient.DG.createBinding()
    binding.setOperator(op)
    binding.setParameterLayout(["parent.msa<>"])

    node = fabricClient.DependencyGraph.createNode("node")
    node.setDependency(parentNode, "parent")
    node.bindings.append(binding)
    errors = node.getErrors()
    if len(errors) > 0:
        for i in errors:
            print(errors[i])
    else:
        node.evaluate()
Пример #9
0
#
#  Copyright 2010-2012 Fabric Engine Inc. All rights reserved.
#

import fabric
F = fabric.createClient()

eh = F.DG.createEventHandler("event handler")
print(eh.getName())
print(eh.getType())

def mapNamedObjectsToNames( objects ):
  result = []
  for i in range( 0, len( objects ) ):
    result.append( objects[i].getName() )
  return result

print(fabric.stringify((mapNamedObjectsToNames(eh.getChildEventHandlers()))))

childEventHandler = F.DG.createEventHandler("child event handler")
eh.appendChildEventHandler(childEventHandler)
print(fabric.stringify((mapNamedObjectsToNames(eh.getChildEventHandlers()))))

eh.appendChildEventHandler(F.DG.createEventHandler("another child event handler"))
print(fabric.stringify((mapNamedObjectsToNames(eh.getChildEventHandlers()))))

eh.removeChildEventHandler(childEventHandler)
print(fabric.stringify((mapNamedObjectsToNames(eh.getChildEventHandlers()))))

F.close()
Пример #10
0
import fabric
F = fabric.createClient()

eh = F.DG.createEventHandler("event handler")
print(eh.getName())
print(eh.getType())


def mapNamedObjectsToNames(objects):
    result = []
    for i in range(0, len(objects)):
        result.append(objects[i].getName())
    return result


print(fabric.stringify((mapNamedObjectsToNames(eh.getChildEventHandlers()))))

childEventHandler = F.DG.createEventHandler("child event handler")
eh.appendChildEventHandler(childEventHandler)
print(fabric.stringify((mapNamedObjectsToNames(eh.getChildEventHandlers()))))

eh.appendChildEventHandler(
    F.DG.createEventHandler("another child event handler"))
print(fabric.stringify((mapNamedObjectsToNames(eh.getChildEventHandlers()))))

eh.removeChildEventHandler(childEventHandler)
print(fabric.stringify((mapNamedObjectsToNames(eh.getChildEventHandlers()))))

F.close()
Пример #11
0
#
#  Copyright 2010-2012 Fabric Engine Inc. All rights reserved.
#

import fabric
F = fabric.createClient()
n = F.DG.createNode("n")

n.addMember("foo", "String[String]")
a = n.getData("foo", 0)
print(fabric.stringify(a))
a['x'] = "bar"
n.setData("foo", 0, a)
a = n.getData("foo", 0)
print(fabric.stringify(a))
a['x'] = "baz"
n.setData("foo", 0, a)
a = n.getData("foo", 0)
print(fabric.stringify(a))

n.addMember("bar", "Scalar[Scalar]")
a = n.getData("bar", 0)
print(fabric.stringify(a))
a[2.4] = 3.14
a[7.9] = 2.71
n.setData("bar", 0, a)
a = n.getData("bar", 0)
print(fabric.stringify(a))

a = {}
for i in range(0, 4096):
Пример #12
0
 def callback3( result ):
   print( 'callback3: ' + fabric.stringify(result) )
   fabricClient.close()
Пример #13
0
#
#  Copyright 2010-2012 Fabric Engine Inc. All rights reserved.
#

import fabric
fabricClient = fabric.createClient()

node = fabricClient.DependencyGraph.createNode("foo")
node.addMember( "foo", "Integer", 17 )
node.addMember( "bar", "String", "red" )
node.addMember( "baz", "Scalar[]", [3.141] )
print(fabric.stringify(node.getBulkData()))
print(fabric.stringify(node.getSliceBulkData(0)))
node.setBulkData({'foo':[42],'bar':["fred"],'baz':[[4.5,3.6]]})
print(fabric.stringify(node.getBulkData()))
print(fabric.stringify(node.getSliceBulkData(0)))
node.resize(2)
print(fabric.stringify(node.getBulkData()))
print(fabric.stringify(node.getSliceBulkData(0)))
print(fabric.stringify(node.getSliceBulkData(1)))
print(fabric.stringify(node.getSlicesBulkData([1,0,1])))
node.setSliceBulkData(1, {'foo':18,'bar':"hello",'baz':[]})
print(fabric.stringify(node.getBulkData()))
print(fabric.stringify(node.getSliceBulkData(0)))
print(fabric.stringify(node.getSliceBulkData(1)))
print(fabric.stringify(node.getSlicesBulkData([1,0,1])))

fabricClient.close()
Пример #14
0
  MyStruct ms;\n\
  ms.i = 42;\n\
  ms.s = 3.141;\n\
  \n\
  arg.push( ms );\n\
}\n\
")
diagnostics = op.getDiagnostics()
if len(diagnostics) > 0:
    for i in diagnostics:
        print(diagnostics[i].line + ": " + diagnostics[i].desc)
    print("Full code:")
    print(op.getFullSourceCode())
else:
    binding = fabricClient.DG.createBinding()
    binding.setOperator(op)
    binding.setParameterLayout(["self.msaa"])

    node = fabricClient.DependencyGraph.createNode("node")
    node.addMember("msaa", "MyStruct[]")
    node.bindings.append(binding)
    errors = node.getErrors()
    if len(errors) > 0:
        for i in errors:
            print(errors[i])
    else:
        node.evaluate()
        print(fabric.stringify(node.getData("msaa", 0)))

fabricClient.close()
Пример #15
0
    fabricClient.IO.putTextFileContent("dummy", "badHandle")
except Exception as e:
    print('Bad handle error: ' + str(e))

readOnlyFileAndFolderHandles = fabricClient.IO.queryUserFileAndFolderHandle(
    fabricClient.IO.forOpen, "dummy title", "txt", "testfile")

try:
    fabricClient.IO.putTextFileContent(readOnlyFileAndFolderHandles['file'],
                                       "dummy")
except Exception as e:
    print('No write access error: ' + str(e))

fileAndFolderHandles = fabricClient.IO.queryUserFileAndFolderHandle(
    fabricClient.IO.forOpenWithWriteAccess, "dummy title", "txt", "testfile")
print('File and folder handles: ' + fabric.stringify(fileAndFolderHandles))
print('User file name: ' + fabricClient.IO.getFileHandleInfo(
    fileAndFolderHandles['file'])['fileName'])

relativeFileHandle = fabricClient.IO.buildFileHandleFromRelativePath(
    fileAndFolderHandles['folder'] + '/SubDir/testfile2.txt')

try:
    dummy = fabricClient.IO.getTextFileContent(relativeFileHandle)
except Exception as e:
    print(
        'File not found error')  #'e' has random handle name; don't display it

fabricClient.IO.putTextFileContent(relativeFileHandle, "FileBody")
body = fabricClient.IO.getTextFileContent(relativeFileHandle)
print('File content: ' + body)
Пример #16
0
require FabricOBJ;\n\
\n\
operator load(\n\
  io String url,\n\
  io FabricResource resource,\n\
  io OBJDataHandle objParseHandle\n\
  )\n\
{\n\
  report "Loaded " + url + " (mime type " + resource.mimeType + ")";\n\
  report "OBJ data size is " + resource.data.dataSize();\n\
  FabricOBJDecode(resource.data.data(), resource.data.dataSize(), false, false, false, objParseHandle);\n\
}\n\
')

if len( loadOp.getDiagnostics() ) > 0:
  print('load: ' + fabric.stringify(loadOp.getDiagnostics()))

loadOpBinding = fabricClient.DG.createBinding()
loadOpBinding.setOperator(loadOp)
loadOpBinding.setParameterLayout([
  "self.url",
  "self.resource",
  "self.objParseHandle"
])

rlnode = fabricClient.DependencyGraph.createResourceLoadNode("rlnode")
rlnode.addMember("objParseHandle", "OBJDataHandle")
rlnode.bindings.append(loadOpBinding)
rlnode.setData("url", 0, "testfile://test.obj")

resizeOp = fabricClient.DependencyGraph.createOperator("resize")
Пример #17
0
dgnode1.addMember("a", "Size[]")
dgnode1.resize(32)

operatorInit = F.DG.createOperator("initiate")
operatorInit.setSourceCode(
    "operator initiate(in Size index, io Size a[]) {\n"
    + '  report("Setting index " + index);\n'
    + "  a.push(index);\n"
    + "}\n"
)
operatorInit.setEntryPoint("initiate")
operatorInit.setMainThreadOnly(True)

if len(operatorInit.getErrors()) > 0:
    if len(operatorInit.getDiagnostics()) > 0:
        print("operatorInit1: " + fabric.stringify(operatorInit.getDiagnostics()))

bindingInit = F.DG.createBinding()
bindingInit.setOperator(operatorInit)
bindingInit.setParameterLayout(["self.index", "self.a"])

operatorInit2 = F.DG.createOperator("initiate2")
operatorInit2.setSourceCode(
    "operator initiate2(in Container container, io Size a<>[]) {\n"
    + "  for (Size i=0; i<container.size; ++i)\n"
    + "    a[i].push(Size(2*i));\n"
    + "}\n"
)
operatorInit2.setEntryPoint("initiate2")
operatorInit2.setMainThreadOnly(True)
Пример #18
0
opTwo.setSourceCode("operator entry( io Scalar input, io Scalar output ) { output = 3 * input; }")

bindingTwo = fabricClient.DependencyGraph.createBinding()
bindingTwo.setOperator( opTwo )
bindingTwo.setParameterLayout( [ "self.input", "self.output" ] )

node = fabricClient.DependencyGraph.createNode( "parent" )
node.addMember( "input", "Scalar" )
node.addMember( "output", "Scalar" )
node.resize( 2 )
node.setData( 'input', 0, 3 )
node.setData( 'input', 1, 7 )
node.setData( 'output', 0, 0 )
node.setData( 'output', 1, 0 )
node.evaluate()
print(fabric.stringify(node.getBulkData()))
print("bindings.length = " + str(node.bindings.getLength()))

node.setData( 'output', 0, 0 )
node.setData( 'output', 1, 0 )
node.bindings.append( bindingOne )
node.evaluate()
print(fabric.stringify(node.getBulkData()))
print("bindings.length = " + str(node.bindings.getLength()))

node.setData( 'output', 0, 0 )
node.setData( 'output', 1, 0 )
node.bindings.remove(0)
node.evaluate()
print(fabric.stringify(node.getBulkData()))
print("bindings.length = " + str(node.bindings.getLength()))
Пример #19
0
#
#  Copyright 2010-2012 Fabric Engine Inc. All rights reserved.
#

import fabric
F = fabric.createClient()
n = F.DG.createNode("n")

n.addMember("foo","String[String]")
a = n.getData("foo", 0)
print(fabric.stringify(a))
a['x'] = "bar"
n.setData("foo",0,a)
a = n.getData("foo", 0)
print(fabric.stringify(a))
a['x'] = "baz"
n.setData("foo",0,a)
a = n.getData("foo", 0)
print(fabric.stringify(a))

n.addMember("bar","Scalar[Scalar]")
a = n.getData("bar", 0)
print(fabric.stringify(a))
a[2.4] = 3.14
a[7.9] = 2.71
n.setData("bar", 0, a )
a = n.getData("bar", 0)
print(fabric.stringify(a))

a = {}
for i in range( 0, 4096 ):
Пример #20
0
require FabricOBJ;\n\
\n\
operator load(\n\
  io String url,\n\
  io FabricResource resource,\n\
  io OBJDataHandle objParseHandle\n\
  )\n\
{\n\
  report "Loaded " + url + " (mime type " + resource.mimeType + ")";\n\
  report "OBJ data size is " + resource.data.dataSize();\n\
  FabricOBJDecode(resource.data.data(), resource.data.dataSize(), false, false, false, objParseHandle);\n\
}\n\
')

if len(loadOp.getDiagnostics()) > 0:
    print('load: ' + fabric.stringify(loadOp.getDiagnostics()))

loadOpBinding = fabricClient.DG.createBinding()
loadOpBinding.setOperator(loadOp)
loadOpBinding.setParameterLayout(
    ["self.url", "self.resource", "self.objParseHandle"])

rlnode = fabricClient.DependencyGraph.createResourceLoadNode("rlnode")
rlnode.addMember("objParseHandle", "OBJDataHandle")
rlnode.bindings.append(loadOpBinding)
rlnode.setData("url", 0, "testfile://test.obj")

resizeOp = fabricClient.DependencyGraph.createOperator("resize")
resizeOp.setEntryPoint("resize")
resizeOp.setSourceCode('\
require FabricOBJ;\n\
Пример #21
0
def printErrors( obj ):
  if len( obj.getErrors() ) > 0:
    print obj.getName() + ': errors: ' + fabric.stringify( obj.getErrors() )
Пример #22
0
def printErrors(obj):
    if len(obj.getErrors()) > 0:
        print obj.getName() + ': errors: ' + fabric.stringify(obj.getErrors())
Пример #23
0
dgnode2.resize(count)

# create dependencies between the nodes
dgnode2.setDependency(dgnode1, 'otherNode')

# create three operators, one to initiate the data, one to add, and one to mul
operatorInit = F.DG.createOperator("initiate")
operatorInit.setSourceCode(
  'operator initiate(in Size index, io Scalar a, io Scalar b) {\n'+
  '  a = 12.5 * Scalar(index);\n'+
  '  b = 1.73 * Scalar(index);\n'+
  '}\n')
operatorInit.setEntryPoint('initiate')
if len( operatorInit.getErrors() ) > 0:
  if len( operatorInit.getDiagnostics() ) > 0:
    print(fabric.stringify(opreatorInit.getDiagnostics()))

operatorAdd = F.DG.createOperator("add")
operatorAdd.setSourceCode(
  'operator add(io Scalar a, io Scalar b, io Scalar result) {\n'+
  '  result = a + b;\n'+
  '}\n')
operatorAdd.setEntryPoint('add')

if len( operatorAdd.getErrors() ) > 0:
  if len( operatorAdd.getDiagnostics() ) > 0:
    print(fabric.stringify(opreatorAdd.getDiagnostics()))

operatorMul = F.DG.createOperator("operatorMul")
operatorMul.setSourceCode(
  'operator mul(io Scalar input<>, io Scalar result, in Size index) {\n'+
Пример #24
0
#
#  Copyright 2010-2012 Fabric Engine Inc. All rights reserved.
#

import fabric
F = fabric.createClient()


def mapNamedObjectsToNames(objects):
    result = []
    for i in range(0, len(objects)):
        result.append(objects[i].getName())
    return result


e = F.DG.createEvent("event")
print(e.getName())
print(e.getType())

print(fabric.stringify(mapNamedObjectsToNames(e.getEventHandlers())))
eh = F.DG.createEventHandler("eventHandler")
e.appendEventHandler(eh)
print(fabric.stringify(mapNamedObjectsToNames(e.getEventHandlers())))

e.fire()

F.close()
Пример #25
0
};\n\
\n\
operator load( io String url, io FabricResource resource )\n\
{\n\
  report "Loaded " + url + " (mime type " + resource.mimeType + ")";\n\
  report "EXR data size is " + resource.data.dataSize();\n\
  Size imageWidth, imageHeight;\n\
  Color imagePixels[];\n\
  FabricEXRDecode( resource.data.data(), resource.data.dataSize(), imageWidth, imageHeight, imagePixels );\n\
  report "Image dimensions are "+imageWidth+" by "+imageHeight;\n\
  report "Image pixels size is "+imagePixels.size;\n\
}\n\
')

if len( op.getDiagnostics() ) > 0:
  print(fabric.stringify(op.getDiagnostics()))

binding = fabricClient.DG.createBinding()
binding.setOperator(op)
binding.setParameterLayout([
  "loadnode.url",
  "loadnode.resource"
])

rlnode = fabricClient.DependencyGraph.createResourceLoadNode("rlnode")
rlnode.setData("url", 0, "testfile://sample.exr")

node = fabricClient.DependencyGraph.createNode("node")
node.setDependency(rlnode, "loadnode")
node.bindings.append(binding)
node.evaluate()
Пример #26
0
 def callback3(result):
     print('callback3: ' + fabric.stringify(result))
     fabricClient.close()
Пример #27
0
  report("Members: " + i + " " + s);\n\
  otherC = c;\n\
  otherC.resize(Size(3));\n\
  report("Container string: " + otherC + " Count: " + otherC.size + " Is valid: " + Boolean(otherC));\n\
  report("To fix: i.size is wrong! LLVM doesn\'t know about aliasing!");\n\
  i[2] = 1;\n\
  s[2] = "test";\n\
  report("Member sizes: " + s.size);\n\
  report("Members: " + i + " " + s);\n\
  //Now test accessing uninitialized Container\n\
  Container bad;\n\
  report(bad.size());\n\
}\n\
');
if len( op.getDiagnostics() ) > 0:
  print(fabric.stringify(op.getDiagnostics()));

opBinding = fabricClient.DG.createBinding();
opBinding.setOperator(op);
opBinding.setParameterLayout([
  "self",
  "self.intMember<>",
  "self.stringMember<>"
]);
node.bindings.append(opBinding);
try:
  node.evaluate();
except Exception as e:
  print("Runtime eval error (uninit container access): " + str(e) );

# Error test: we are not allowed to have io Container along with members elements
Пример #28
0
#
#  Copyright 2010-2012 Fabric Engine Inc. All rights reserved.
#

import json
import fabric
F = fabric.createClient()

b = F.DG.createBinding()
print(fabric.stringify(b.getOperator()))
print(fabric.stringify(b.getParameterLayout()))

o = F.DG.createOperator("op")
b.setOperator(o)
print(fabric.stringify(b.getOperator().getName()))

b.setParameterLayout(["self.foo"])
print(fabric.stringify(b.getParameterLayout()))

F.close()

Пример #29
0
  MyStruct ms;\n\
  ms.i = 42;\n\
  ms.s = 3.141;\n\
  \n\
  arg.push( ms );\n\
}\n\
" )
diagnostics = op.getDiagnostics()
if len( diagnostics ) > 0:
  for i in diagnostics:
    print( diagnostics[i].line + ": " + diagnostics[i].desc )
  print( "Full code:" )
  print( op.getFullSourceCode() )
else:
  binding = fabricClient.DG.createBinding()
  binding.setOperator(op)
  binding.setParameterLayout(["self.msaa"])
  
  node = fabricClient.DependencyGraph.createNode( "node" )
  node.addMember( "msaa", "MyStruct[]" )
  node.bindings.append(binding)
  errors = node.getErrors()
  if len( errors ) > 0:
    for i in errors:
      print( errors[i] )
  else:
    node.evaluate()
    print(fabric.stringify( node.getData("msaa", 0) ))

fabricClient.close()
Пример #30
0
  report('parent data: ' + arg);\n\
}\n\
")
diagnostics = op.getDiagnostics()
if len( diagnostics ) > 0:
  for i in diagnostics:
    print( diagnostics[i].line + ": " + diagnostics[i].desc )
  print( "Full code:" )
  print( op.getFullSourceCode() )
else:
  parentNode = fabricClient.DependencyGraph.createNode( "parentNode" )
  parentNode.addMember( "msa", "MyStruct[]" )
  parentNode.resize( 2 )
  parentNode.setData( "msa", 0, [MyStruct( 42, 3.141 ), MyStruct( 64, 5.67 ) ] )
  parentNode.setData( "msa", 1, [MyStruct( 7, 2.718 )] )
  print(fabric.stringify( parentNode.getData("msa", 0) ))
  print(fabric.stringify( parentNode.getData("msa", 1) ))

  binding = fabricClient.DG.createBinding()
  binding.setOperator(op)
  binding.setParameterLayout(["parent.msa<>"])

  node = fabricClient.DependencyGraph.createNode( "node" )
  node.setDependency( parentNode, "parent" )
  node.bindings.append(binding)
  errors = node.getErrors()
  if len( errors ) > 0:
    for i in errors:
      print( errors[i] )
  else:
    node.evaluate()
Пример #31
0
};\n\
\n\
operator load( io String url, io FabricResource resource )\n\
{\n\
  report "Loaded " + url + " (mime type " + resource.mimeType + ")";\n\
  report "EXR data size is " + resource.data.dataSize();\n\
  Size imageWidth, imageHeight;\n\
  Color imagePixels[];\n\
  FabricEXRDecode( resource.data.data(), resource.data.dataSize(), imageWidth, imageHeight, imagePixels );\n\
  report "Image dimensions are "+imageWidth+" by "+imageHeight;\n\
  report "Image pixels size is "+imagePixels.size;\n\
}\n\
')

if len(op.getDiagnostics()) > 0:
    print(fabric.stringify(op.getDiagnostics()))

binding = fabricClient.DG.createBinding()
binding.setOperator(op)
binding.setParameterLayout(["loadnode.url", "loadnode.resource"])

rlnode = fabricClient.DependencyGraph.createResourceLoadNode("rlnode")
rlnode.setData("url", 0, "testfile://sample.exr")

node = fabricClient.DependencyGraph.createNode("node")
node.setDependency(rlnode, "loadnode")
node.bindings.append(binding)
node.evaluate()

fabricClient.close()
Пример #32
0
opTwo.setSourceCode("operator entry( io Scalar input, io Scalar output ) { output = 3 * input; }")

bindingTwo = fabricClient.DependencyGraph.createBinding()
bindingTwo.setOperator( opTwo )
bindingTwo.setParameterLayout( [ "self.input", "self.output" ] )

node = fabricClient.DependencyGraph.createNode( "parent" )
node.addMember( "input", "Scalar" )
node.addMember( "output", "Scalar" )
node.resize( 2 )
node.setData( 'input', 0, 3 )
node.setData( 'input', 1, 7 )
node.setData( 'output', 0, 0 )
node.setData( 'output', 1, 0 )
node.evaluate()
print(fabric.stringify(node.getBulkData()))
print("bindings.length = " + str(node.bindings.getLength()))

node.setData( 'output', 0, 0 )
node.setData( 'output', 1, 0 )
node.bindings.append( bindingOne )
node.evaluate()
print(fabric.stringify(node.getBulkData()))
print("bindings.length = " + str(node.bindings.getLength()))

node.setData( 'output', 0, 0 )
node.setData( 'output', 1, 0 )
node.bindings.remove(0)
node.evaluate()
print(fabric.stringify(node.getBulkData()))
print("bindings.length = " + str(node.bindings.getLength()))
Пример #33
0
#
#  Copyright 2010-2012 Fabric Engine Inc. All rights reserved.
#

import fabric
F = fabric.createClient()

o = F.DG.createOperator("op")
o.setSourceCode("\
operator entry(io Size a, io String b) {\n\
  report 'Hello ' + a + ' ' + b;\n\
}\n\
")
o.setEntryFunctionName("entry")

b = F.DG.createBinding()
b.setOperator(o)
b.setParameterLayout([
  "self.foo",
  "self.bar"
])

n = F.DG.createNode("node")
n.addMember("foo", "String")
n.addMember("bar", "Size")
n.bindings.append(b)
print(fabric.stringify(n.getErrors()))

F.close()
Пример #34
0
dgnode1 = F.DG.createNode("myNode1")
dgnode1.addMember('a', 'Size[]')
dgnode1.resize(32)

operatorInit = F.DG.createOperator("initiate")
operatorInit.setSourceCode(
    'operator initiate(in Size index, io Size a[]) {\n' +
    '  report("Setting index " + index);\n' + '  a.push(index);\n' + '}\n')
operatorInit.setEntryPoint('initiate')
operatorInit.setMainThreadOnly(True)

if len(operatorInit.getErrors()) > 0:
    if len(operatorInit.getDiagnostics()) > 0:
        print('operatorInit1: ' +
              fabric.stringify(operatorInit.getDiagnostics()))

bindingInit = F.DG.createBinding()
bindingInit.setOperator(operatorInit)
bindingInit.setParameterLayout(['self.index', 'self.a'])

operatorInit2 = F.DG.createOperator("initiate2")
operatorInit2.setSourceCode(
    'operator initiate2(in Container container, io Size a<>[]) {\n' +
    '  for (Size i=0; i<container.size; ++i)\n' +
    '    a[i].push(Size(2*i));\n' + '}\n')
operatorInit2.setEntryPoint('initiate2')
operatorInit2.setMainThreadOnly(True)

if len(operatorInit2.getErrors()) > 0:
    if len(operatorInit2.getDiagnostics()) > 0:
Пример #35
0
  'members': [ { 'x':'Scalar' }, { 'y':'Scalar' } ],
  'constructor': Vec2,
  'klBindings': {
    'filename': "(inline)",
    'sourceCode': "\
function Vec2(Scalar x, Scalar y)\n\
{\n\
  this.x = x;\n\
  this.y = y;\n\
}\n\
"
  }
}

fabricClient.RegisteredTypesManager.registerType( 'Vec2', desc )
print(fabric.stringify(fabricClient.RT.getRegisteredTypes()['Vec2']))

node = fabricClient.DependencyGraph.createNode("foo")
node.addMember( 'vec2', 'Vec2' )
node.setData( 'vec2', 0, Vec2( 5.6, 4.3 ) )
data = node.getData("vec2", 0)
print( fabric.stringify( data ) )
print( data.sum() )

op = fabricClient.DG.createOperator("op")
op.setSourceCode("(inline)", "use Vec2; operator entry( io Vec2 vec2 ) { vec2 = Vec2(8.9, 2.3); }")
op.setEntryFunctionName("entry")
if len( op.getErrors() ) > 0:
  print( "ERRORS: " + str( op.getErrors() ) )
  if len( op.getDiagnostics() ) > 0:
    print( "DIAGNOSTICS: " + str( op.getDiagnostics() ) )
Пример #36
0
#
#  Copyright 2010-2012 Fabric Engine Inc. All rights reserved.
#

import fabric
fabricClient = fabric.createClient()

desc = {
  'members': [ { 'x':'Scalar' }, { 'y':'Data' } ]
}

fabricClient.RegisteredTypesManager.registerType( 'DataMember', desc )
print(fabric.stringify(fabricClient.RT.getRegisteredTypes()['DataMember']))

node = fabricClient.DependencyGraph.createNode("foo")
node.addMember( 'foo', 'DataMember' )
data = node.getData("foo", 0)
print( fabric.stringify( data ) )

data.x = 1.0
data.y = True
node.setData("foo", 0, data)

data = node.getData("foo", 0)
print( fabric.stringify( data ) )

fabricClient.close()