本文整理汇总了Python中GafferSceneTest类的典型用法代码示例。如果您正苦于以下问题:Python GafferSceneTest类的具体用法?Python GafferSceneTest怎么用?Python GafferSceneTest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GafferSceneTest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __writeScene
def __writeScene( self, script, args ) :
import GafferScene
import GafferSceneTest
scene = script.descendant( args["scene"].value )
if isinstance( scene, Gaffer.Node ) :
scene = next( ( x for x in scene.children( GafferScene.ScenePlug ) ), None )
if scene is None :
IECore.msg( IECore.Msg.Level.Error, "stats", "Scene \"%s\" does not exist" % args["scene"].value )
return
if args["preCache"].value :
GafferSceneTest.traverseScene( scene )
memory = _Memory.maxRSS()
with _Timer() as sceneTimer :
with self.__performanceMonitor or _NullContextManager(), self.__contextMonitor or _NullContextManager() :
with Gaffer.Context( script.context() ) as context :
for frame in self.__frames( script, args ) :
context.setFrame( frame )
GafferSceneTest.traverseScene( scene )
self.__timers["Scene generation"] = sceneTimer
self.__memory["Scene generation"] = _Memory.maxRSS() - memory
示例2: computeScene
def computeScene() :
with self.__context( script, args ) as context :
for frame in self.__frames( script, args ) :
context.setFrame( frame )
if args["sets"] :
GafferScene.SceneAlgo.sets( scene, args["sets"] )
else :
GafferSceneTest.traverseScene( scene )
示例3: computeScene
def computeScene() :
with self.__context( script, args ) as context :
for frame in self.__frames( script, args ) :
context.setFrame( frame )
if isinstance( scene, GafferDispatch.TaskNode.TaskPlug ) :
context["scene:render:sceneTranslationOnly"] = IECore.BoolData( True )
scene.execute()
else :
if args["sets"] :
GafferScene.SceneAlgo.sets( scene, args["sets"] )
else :
GafferSceneTest.traverseScene( scene )
示例4: testDispatchAndGIL
def testDispatchAndGIL( self ) :
script = Gaffer.ScriptNode()
script["plane"] = GafferScene.Plane()
script["plane"]["divisions"].setValue( imath.V2i( 20 ) )
script["sphere"] = GafferScene.Sphere()
script["expression"] = Gaffer.Expression()
script["expression"].setExpression( "parent['sphere']['radius'] = context.get( 'minRadius', 0.1 ) + context.getFrame() + float( context['instancer:id'] )" )
script["instancer"] = GafferScene.Instancer()
script["instancer"]["in"].setInput( script["plane"]["out"] )
script["instancer"]["instance"].setInput( script["sphere"]["out"] )
script["instancer"]["parent"].setValue( "/plane" )
script["pythonCommand"] = GafferDispatch.PythonCommand()
script["pythonCommand"]["command"].setValue( "pass" )
traverseConnection = Gaffer.ScopedConnection( GafferSceneTest.connectTraverseSceneToPreDispatchSignal( script["instancer"]["out"] ) )
dispatcher = GafferDispatch.LocalDispatcher()
dispatcher["jobsDirectory"].setValue( self.temporaryDirectory() )
with Gaffer.Context() as c :
for i in range( 1, 10 ) :
c.setFrame( i )
dispatcher.dispatch( [ script["pythonCommand"] ] )
示例5: testLoadReferenceAndGIL
def testLoadReferenceAndGIL( self ) :
script = Gaffer.ScriptNode()
script["plane"] = GafferScene.Plane()
script["plane"]["divisions"].setValue( imath.V2i( 20 ) )
script["sphere"] = GafferScene.Sphere()
script["expression"] = Gaffer.Expression()
script["expression"].setExpression( "parent['sphere']['radius'] = 0.1 + context.getFrame() + float( context['instancer:id'] )" )
script["instancer"] = GafferScene.Instancer()
script["instancer"]["in"].setInput( script["plane"]["out"] )
script["instancer"]["instance"].setInput( script["sphere"]["out"] )
script["instancer"]["parent"].setValue( "/plane" )
script["box"] = Gaffer.Box()
script["box"]["in"] = GafferScene.ScenePlug( flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic )
script["box"]["out"] = GafferScene.ScenePlug( direction = Gaffer.Plug.Direction.Out, flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic )
script["box"]["out"].setInput( script["box"]["in"] )
script["box"].exportForReference( self.temporaryDirectory() + "/test.grf" )
script["reference"] = Gaffer.Reference()
script["reference"].load( self.temporaryDirectory() + "/test.grf" )
script["reference"]["in"].setInput( script["instancer"]["out"] )
script["attributes"] = GafferScene.CustomAttributes()
script["attributes"]["in"].setInput( script["reference"]["out"] )
traverseConnection = Gaffer.ScopedConnection( GafferSceneTest.connectTraverseSceneToPlugDirtiedSignal( script["attributes"]["out"] ) )
with Gaffer.Context() as c :
script["reference"].load( self.temporaryDirectory() + "/test.grf" )
示例6: testThreading
def testThreading(self):
sphere = IECore.SpherePrimitive()
instanceInput = GafferSceneTest.CompoundObjectSource()
instanceInput["in"].setValue(
IECore.CompoundObject(
{
"bound": IECore.Box3fData(IECore.Box3f(IECore.V3f(-2), IECore.V3f(2))),
"children": {
"sphere": {
"object": sphere,
"bound": IECore.Box3fData(sphere.bound()),
"transform": IECore.M44fData(IECore.M44f.createScaled(IECore.V3f(2))),
}
},
}
)
)
seeds = IECore.PointsPrimitive(
IECore.V3fVectorData([IECore.V3f(1, 0, 0), IECore.V3f(1, 1, 0), IECore.V3f(0, 1, 0), IECore.V3f(0, 0, 0)])
)
seedsInput = GafferSceneTest.CompoundObjectSource()
seedsInput["in"].setValue(
IECore.CompoundObject(
{
"bound": IECore.Box3fData(IECore.Box3f(IECore.V3f(1, 0, 0), IECore.V3f(2, 1, 0))),
"children": {
"seeds": {
"bound": IECore.Box3fData(seeds.bound()),
"transform": IECore.M44fData(IECore.M44f.createTranslated(IECore.V3f(1, 0, 0))),
"object": seeds,
}
},
}
)
)
instancer = GafferScene.Instancer()
instancer["in"].setInput(seedsInput["out"])
instancer["instance"].setInput(instanceInput["out"])
instancer["parent"].setValue("/seeds")
instancer["name"].setValue("instances")
GafferSceneTest.traverseScene(instancer["out"])
示例7: testContextChangedAndGIL
def testContextChangedAndGIL( self ) :
script = Gaffer.ScriptNode()
script["plane"] = GafferScene.Plane()
script["plane"]["divisions"].setValue( imath.V2i( 20 ) )
script["sphere"] = GafferScene.Sphere()
script["expression"] = Gaffer.Expression()
script["expression"].setExpression( "parent['sphere']['radius'] = context.get( 'minRadius', 0.1 ) + context.getFrame() + float( context['instancer:id'] )" )
script["instancer"] = GafferScene.Instancer()
script["instancer"]["in"].setInput( script["plane"]["out"] )
script["instancer"]["instance"].setInput( script["sphere"]["out"] )
script["instancer"]["parent"].setValue( "/plane" )
context = Gaffer.Context()
traverseConnection = Gaffer.ScopedConnection( GafferSceneTest.connectTraverseSceneToContextChangedSignal( script["instancer"]["out"], context ) )
with context :
context.setFrame( 10 )
context.setFramesPerSecond( 50 )
context.setTime( 1 )
context.set( "a", 1 )
context.set( "a", 2.0 )
context.set( "a", "a" )
context.set( "a", imath.V2i() )
context.set( "a", imath.V3i() )
context.set( "a", imath.V2f() )
context.set( "a", imath.V3f() )
context.set( "a", imath.Color3f() )
context.set( "a", IECore.BoolData( True ) )
context["b"] = 1
context["b"] = 2.0
context["b"] = "b"
context["b"] = imath.V2i()
context["b"] = imath.V3i()
context["b"] = imath.V2f()
context["b"] = imath.V3f()
context["b"] = imath.Color3f()
context["b"] = IECore.BoolData( True )
with Gaffer.BlockedConnection( traverseConnection ) :
# Must add it with the connection disabled, otherwise
# the addition causes a traversal, and then remove() gets
# all its results from the cache.
context["minRadius"] = 0.2
context.remove( "minRadius" )
with Gaffer.BlockedConnection( traverseConnection ) :
context["minRadius"] = 0.3
del context["minRadius"]
示例8: __printScene
def __printScene(self, script, args):
import GafferScene
import GafferSceneTest
scene = script.descendant(args["scene"].value)
if isinstance(scene, Gaffer.Node):
scene = next((x for x in scene.children(GafferScene.ScenePlug)), None)
if scene is None:
IECore.msg(IECore.Msg.Level.Error, "stats", 'Scene "%s" does not exist' % args["scene"].value)
return
memory = _Memory.maxRSS()
with _Timer() as sceneTimer:
with self.__performanceMonitor or _NullContextManager():
GafferSceneTest.traverseScene(scene)
self.__timers["Scene generation"] = sceneTimer
self.__memory["Scene generation"] = _Memory.maxRSS() - memory
示例9: testAlembicThreading
def testAlembicThreading( self ) :
mesh = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) )
fileName = self.temporaryDirectory() + "/test.abc"
root = IECoreScene.SceneInterface.create( fileName, IECore.IndexedIO.OpenMode.Write )
root.writeBound( imath.Box3d( mesh.bound() ), 0 )
for i in range( 0, 1000 ) :
child = root.createChild( str( i ) )
child.writeObject( mesh, 0 )
child.writeBound( imath.Box3d( mesh.bound() ), 0 )
del root, child
sceneReader = GafferScene.SceneReader()
sceneReader["fileName"].setValue( fileName )
for i in range( 0, 20 ) :
sceneReader["refreshCount"].setValue( sceneReader["refreshCount"].getValue() + 1 )
GafferSceneTest.traverseScene( sceneReader["out"] )
示例10: testNameClashesWithThreading
def testNameClashesWithThreading( self ) :
sphere = IECoreScene.SpherePrimitive()
input1 = GafferSceneTest.CompoundObjectSource()
input1["in"].setValue(
IECore.CompoundObject( {
"bound" : IECore.Box3fData( sphere.bound() ),
"children" : {
"myLovelyObject1" : {
"bound" : IECore.Box3fData( sphere.bound() ),
"object" : sphere,
},
},
} ),
)
plane = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) )
input2 = GafferSceneTest.CompoundObjectSource()
input2["in"].setValue(
IECore.CompoundObject( {
"bound" : IECore.Box3fData( plane.bound() ),
"children" : {
"myLovelyObject1" : {
"bound" : IECore.Box3fData( plane.bound() ),
"object" : plane,
},
},
} ),
)
group = GafferScene.Group()
group["name"].setValue( "topLevel" )
group["in"][0].setInput( input1["out"] )
group["in"][1].setInput( input2["out"] )
GafferSceneTest.traverseScene( group["out"] )
示例11: testManyStringToPathCalls
def testManyStringToPathCalls( self ) :
GafferSceneTest.testManyStringToPathCalls()
示例12: traverser
def traverser() :
try :
GafferSceneTest.traverseScene( g["out"] )
except Exception, e :
exceptions.append( e )
示例13: testDynamicPlugsAndGIL
def testDynamicPlugsAndGIL( self ) :
script = Gaffer.ScriptNode()
script["plane"] = GafferScene.Plane()
script["plane"]["divisions"].setValue( imath.V2i( 20 ) )
script["sphere"] = GafferScene.Sphere()
script["expression"] = Gaffer.Expression()
script["expression"].setExpression( "parent['sphere']['radius'] = context.getFrame() + float( context['instancer:id'] )" )
script["instancer"] = GafferScene.Instancer()
script["instancer"]["in"].setInput( script["plane"]["out"] )
script["instancer"]["instance"].setInput( script["sphere"]["out"] )
script["instancer"]["parent"].setValue( "/plane" )
script["attributes"] = GafferScene.CustomAttributes()
script["attributes"]["in"].setInput( script["instancer"]["out"] )
script["outputs"] = GafferScene.Outputs()
script["outputs"]["in"].setInput( script["attributes"]["out"] )
# Simulate an InteractiveRender or Viewer traversal of the scene
# every time it is dirtied. If the GIL isn't released when dirtiness
# is signalled, we'll end up with a deadlock as the traversal enters
# python on another thread to evaluate the expression. We increment the frame
# between each test to ensure the expression result is not cached and
# we do truly enter python.
traverseConnection = Gaffer.ScopedConnection( GafferSceneTest.connectTraverseSceneToPlugDirtiedSignal( script["outputs"]["out"] ) )
with Gaffer.Context() as c :
c.setFrame( 1 )
script["attributes"]["attributes"].addMember( "test1", IECore.IntData( 10 ) )
c.setFrame( 2 )
script["attributes"]["attributes"].addOptionalMember( "test2", IECore.IntData( 20 ) )
c.setFrame( 3 )
script["attributes"]["attributes"].addMembers(
IECore.CompoundData( {
"test3" : 30,
"test4" : 40,
} )
)
c.setFrame( 4 )
p = script["attributes"]["attributes"][0]
del script["attributes"]["attributes"][p.getName()]
c.setFrame( 5 )
script["attributes"]["attributes"].addChild( p )
c.setFrame( 6 )
script["attributes"]["attributes"].removeChild( p )
c.setFrame( 7 )
script["attributes"]["attributes"].setChild( p.getName(), p )
c.setFrame( 8 )
script["attributes"]["attributes"].removeChild( p )
c.setFrame( 9 )
script["attributes"]["attributes"][p.getName()] = p
c.setFrame( 10 )
script["outputs"].addOutput( "test", IECoreScene.Output( "beauty.exr", "exr", "rgba" ) )
示例14: testFind
def testFind( self ) :
GafferSceneTest.testPathMatcherFind()
示例15: testIteratorPrune
def testIteratorPrune( self ) :
GafferSceneTest.testPathMatcherIteratorPrune()