<s> import unittest <EOL> import IECore <EOL> import GafferScene <EOL> import GafferSceneTest <EOL> class SceneAlgoTest ( GafferSceneTest . SceneTestCase ) : <EOL> def test ( self ) : <EOL> sphere = GafferScene . Sphere ( ) <EOL> plane = GafferScene . Plane ( ) <EOL> group = GafferScene . Group ( ) <EOL> group [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( sphere [ "<STR_LIT>" ] ) <EOL> group [ "<STR_LIT>" ] [ <NUM_LIT:1> ] . setInput ( plane [ "<STR_LIT>" ] ) <EOL> plane2 = GafferScene . Plane ( ) <EOL> plane2 [ "<STR_LIT>" ] . setValue ( IECore . V2i ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> instancer = GafferScene . Instancer ( ) <EOL> instancer [ "<STR_LIT>" ] . setInput ( plane2 [ "<STR_LIT>" ] ) <EOL> instancer [ "<STR_LIT>" ] . setValue ( "<STR_LIT>" ) <EOL> instancer [ "<STR_LIT>" ] . setInput ( group [ "<STR_LIT>" ] ) <EOL> filter = GafferScene . PathFilter ( ) <EOL> filter [ "<STR_LIT>" ] . setValue ( IECore . StringVectorData ( [ "<STR_LIT>" ] ) ) <EOL> matchingPaths = GafferScene . PathMatcher ( ) <EOL> GafferScene . matchingPaths ( filter , instancer [ "<STR_LIT>" ] , matchingPaths ) <EOL> self . assertEqual ( len ( matchingPaths . paths ( ) ) , <NUM_LIT:1000> ) <EOL> self . assertEqual ( matchingPaths . match ( "<STR_LIT>" ) , GafferScene . Filter . Result . ExactMatch ) <EOL> self . assertEqual ( matchingPaths . match ( "<STR_LIT>" ) , GafferScene . Filter . Result . ExactMatch ) <EOL> self . assertEqual ( matchingPaths . match ( "<STR_LIT>" ) , GafferScene . Filter . Result . NoMatch ) <EOL> def testExists ( self ) : <EOL> sphere = GafferScene . Sphere ( ) <EOL> plane = GafferScene . Plane ( ) <EOL> group = GafferScene . Group ( ) <EOL> group [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( sphere [ "<STR_LIT>" ] ) <EOL> group [ "<STR_LIT>" ] [ <NUM_LIT:1> ] . setInput ( plane [ "<STR_LIT>" ] ) <EOL> self . assertTrue ( GafferScene . exists ( group [ "<STR_LIT>" ] , "<STR_LIT:/>" ) ) <EOL> self . assertTrue ( GafferScene . exists ( group [ "<STR_LIT>" ] , "<STR_LIT>" ) ) <EOL> self . assertTrue ( GafferScene . exists ( group [ "<STR_LIT>" ] , "<STR_LIT>" ) ) <EOL> self . assertTrue ( GafferScene . exists ( group [ "<STR_LIT>" ] , "<STR_LIT>" ) ) <EOL> self . assertFalse ( GafferScene . exists ( group [ "<STR_LIT>" ] , "<STR_LIT>" ) ) <EOL> self . assertFalse ( GafferScene . exists ( group [ "<STR_LIT>" ] , "<STR_LIT>" ) ) <EOL> self . assertFalse ( GafferScene . exists ( group [ "<STR_LIT>" ] , "<STR_LIT>" ) ) <EOL> self . assertFalse ( GafferScene . exists ( group [ "<STR_LIT>" ] , "<STR_LIT>" ) ) <EOL> def testVisible ( self ) : <EOL> sphere = GafferScene . Sphere ( ) <EOL> group = GafferScene . Group ( ) <EOL> group [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( sphere [ "<STR_LIT>" ] ) <EOL> group2 = GafferScene . Group ( ) <EOL> group2 [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( group [ "<STR_LIT>" ] ) <EOL> visibleFilter = GafferScene . PathFilter ( ) <EOL> attributes1 = GafferScene . StandardAttributes ( ) <EOL> attributes1 [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( True ) <EOL> attributes1 [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT:value>" ] . setValue ( True ) <EOL> attributes1 [ "<STR_LIT>" ] . setInput ( group2 [ "<STR_LIT>" ] ) <EOL> attributes1 [ "<STR_LIT>" ] . setInput ( visibleFilter [ "<STR_LIT>" ] ) <EOL> invisibleFilter = GafferScene . PathFilter ( ) <EOL> attributes2 = GafferScene . StandardAttributes ( ) <EOL> attributes2 [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( True ) <EOL> attributes2 [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT:value>" ] . setValue ( False ) <EOL> attributes2 [ "<STR_LIT>" ] . setInput ( attributes1 [ "<STR_LIT>" ] ) <EOL> attributes2 [ "<STR_LIT>" ] . setInput ( invisibleFilter [ "<STR_LIT>" ] ) <EOL> self . assertTrue ( GafferScene . visible ( attributes2 [ "<STR_LIT>" ] , "<STR_LIT>" ) ) <EOL> self . assertTrue ( GafferScene . visible ( attributes2 [ "<STR_LIT>" ] , "<STR_LIT>" ) ) <EOL> self . assertTrue ( GafferScene . visible ( attributes2 [ "<STR_LIT>" ] , "<STR_LIT>" ) ) <EOL> self . assertTrue ( GafferScene . visible ( attributes2 [ "<STR_LIT>" ] , "<STR_LIT:/>" ) ) <EOL> visibleFilter [ "<STR_LIT>" ] . setValue ( IECore . StringVectorData ( [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( GafferScene . visible ( attributes2 [ "<STR_LIT>" ] , "<STR_LIT>" ) ) <EOL> self . assertTrue ( GafferScene . visible ( attributes2 [ "<STR_LIT>" ] , "<STR_LIT>" ) ) <EOL> self . assertTrue ( GafferScene . visible ( attributes2 [ "<STR_LIT>" ] , "<STR_LIT>" ) ) <EOL> self . assertTrue ( GafferScene . visible ( attributes2 [ "<STR_LIT>" ] , "<STR_LIT:/>" ) ) <EOL> invisibleFilter [ "<STR_LIT>" ] . setValue ( IECore . StringVectorData ( [ "<STR_LIT>" ] ) ) <EOL> self . assertFalse ( GafferScene . visible ( attributes2 [ "<STR_LIT>" ] , "<STR_LIT>" ) ) <EOL> self . assertFalse ( GafferScene . visible ( attributes2 [ "<STR_LIT>" ] , "<STR_LIT>" ) ) <EOL> self . assertTrue ( GafferScene . visible ( attributes2 [ "<STR_LIT>" ] , "<STR_LIT>" ) ) <EOL> self . assertTrue ( GafferScene . visible ( attributes2 [ "<STR_LIT>" ] , "<STR_LIT:/>" ) ) <EOL> visibleFilter [ "<STR_LIT>" ] . setValue ( IECore . StringVectorData ( [ "<STR_LIT>" ] ) ) <EOL> self . assertFalse ( GafferScene . visible ( attributes2 [ "<STR_LIT>" ] , "<STR_LIT>" ) ) <EOL> self . assertFalse ( GafferScene . visible ( attributes2 [ "<STR_LIT>" ] , "<STR_LIT>" ) ) <EOL> self . assertTrue ( GafferScene . visible ( attributes2 [ "<STR_LIT>" ] , "<STR_LIT>" ) ) <EOL> self . assertTrue ( GafferScene . visible ( attributes2 [ "<STR_LIT>" ] , "<STR_LIT:/>" ) ) <EOL> def testSetExists ( self ) : <EOL> plane = GafferScene . Plane ( ) <EOL> plane [ "<STR_LIT>" ] . setValue ( "<STR_LIT>" ) <EOL> self . assertTrue ( GafferScene . setExists ( plane [ "<STR_LIT>" ] , "<STR_LIT:A>" ) ) <EOL> self . assertTrue ( GafferScene . setExists ( plane [ "<STR_LIT>" ] , "<STR_LIT:B>" ) ) <EOL> self . assertFalse ( GafferScene . setExists ( plane [ "<STR_LIT>" ] , "<STR_LIT:U+0020>" ) ) <EOL> self . assertFalse ( GafferScene . setExists ( plane [ "<STR_LIT>" ] , "<STR_LIT>" ) ) <EOL> self . assertFalse ( GafferScene . setExists ( plane [ "<STR_LIT>" ] , "<STR_LIT:C>" ) ) <EOL> def testSets ( self ) : <EOL> light = GafferSceneTest . TestLight ( ) <EOL> light [ "<STR_LIT>" ] . setValue ( "<STR_LIT>" ) <EOL> sets = GafferScene . sets ( light [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( set ( sets . keys ( ) ) , { "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT:B>" , "<STR_LIT:C>" } ) <EOL> for n in sets . keys ( ) : <EOL> self . assertEqual ( sets [ n ] , light [ "<STR_LIT>" ] . set ( n ) ) <EOL> self . assertFalse ( sets [ n ] . isSame ( light [ "<STR_LIT>" ] . set ( n , _copy = False ) ) ) <EOL> sets = GafferScene . sets ( light [ "<STR_LIT>" ] , _copy = False ) <EOL> self . assertEqual ( set ( sets . keys ( ) ) , { "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT:B>" , "<STR_LIT:C>" } ) <EOL> for n in sets . keys ( ) : <EOL> self . assertTrue ( sets [ n ] . isSame ( light [ "<STR_LIT>" ] . set ( n , _copy = False ) ) ) <EOL> def testMatchingPathsWithPathMatcher ( self ) : <EOL> s = GafferScene . Sphere ( ) <EOL> g = GafferScene . Group ( ) <EOL> g [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( s [ "<STR_LIT>" ] ) <EOL> g [ "<STR_LIT>" ] [ <NUM_LIT:1> ] . setInput ( s [ "<STR_LIT>" ] ) <EOL> g [ "<STR_LIT>" ] [ <NUM_LIT:2> ] . setInput ( s [ "<STR_LIT>" ] ) <EOL> f = GafferScene . PathMatcher ( [ "<STR_LIT>" ] ) <EOL> m = GafferScene . PathMatcher ( ) <EOL> GafferScene . matchingPaths ( f , g [ "<STR_LIT>" ] , m ) <EOL> self . assertEqual ( set ( m . paths ( ) ) , { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" } ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
