コード例 #1
0
    def testComputeCacheRecursion(self):

        script = Gaffer.ScriptNode()

        script["plane"] = GafferScene.Plane()

        script["filter1"] = GafferScene.PathFilter()
        script["filter1"]["paths"].setValue(IECore.StringVectorData(["/*"]))

        script["filterResults1"] = GafferScene.FilterResults()
        script["filterResults1"]["scene"].setInput(script["plane"]["out"])
        script["filterResults1"]["filter"].setInput(script["filter1"]["out"])

        script["filter2"] = GafferScene.PathFilter()
        script["expression"] = Gaffer.Expression()
        script["expression"].setExpression(
            'parent["filter2"]["paths"] = IECore.StringVectorData( parent["filterResults1"]["out"].value.paths() )'
        )

        script["filterResults2"] = GafferScene.FilterResults()
        script["filterResults2"]["scene"].setInput(script["plane"]["out"])
        script["filterResults2"]["filter"].setInput(script["filter2"]["out"])

        h = script["filterResults2"]["out"].hash()
        Gaffer.ValuePlug.clearCache()
        script["filterResults2"]["out"].getValue(h)
コード例 #2
0
ファイル: FilterResultsTest.py プロジェクト: tws0002/gaffer
	def testChangingFilter( self ) :

		p = GafferScene.Plane()
		s = GafferScene.Sphere()
		g = GafferScene.Group()
		g["in"][0].setInput( p["out"] )
		g["in"][1].setInput( s["out"] )

		f = GafferScene.PathFilter()
		f["paths"].setValue( IECore.StringVectorData( [ "/group/*" ] ) )

		n = GafferScene.FilterResults()
		n["scene"].setInput( g["out"] )
		n["filter"].setInput( f["out"] )

		self.assertEqual(
			n["out"].getValue().value,
			GafferScene.PathMatcher( [
				"/group/sphere",
				"/group/plane"
			] )
		)

		f["paths"].setValue( IECore.StringVectorData( [ "/group/p*" ] ) )

		self.assertEqual(
			n["out"].getValue().value,
			GafferScene.PathMatcher( [
				"/group/plane"
			] )
		)
コード例 #3
0
ファイル: FilterResultsTest.py プロジェクト: tws0002/gaffer
	def testOutputIntoExpression( self ) :

		script = Gaffer.ScriptNode()

		script["plane"] = GafferScene.Plane()

		script["sphere"] = GafferScene.Sphere()

		script["instancer"] = GafferScene.Instancer()
		script["instancer"]["in"].setInput( script["plane"]["out"] )
		script["instancer"]["instance"].setInput( script["sphere"]["out"] )
		script["instancer"]["parent"].setValue( "/plane" )

		script["filter"] = GafferScene.PathFilter()
		script["filter"]["paths"].setValue( IECore.StringVectorData( [ "/plane/instances/*/sphere" ] ) )

		script["filterResults"] = GafferScene.FilterResults()
		script["filterResults"]["scene"].setInput( script["instancer"]["out"] )
		script["filterResults"]["filter"].setInput( script["filter"]["out"] )

		script["filterResults"]["user"]["strings"] = Gaffer.StringVectorDataPlug( defaultValue = IECore.StringVectorData() )

		script["expression"] = Gaffer.Expression()
		script["expression"].setExpression( "parent['filterResults']['user']['strings'] = IECore.StringVectorData( sorted( parent['filterResults']['out'].value.paths() ) )" )

		self.assertEqual(
			script["filterResults"]["user"]["strings"].getValue(),
			IECore.StringVectorData( [
				"/plane/instances/0/sphere",
				"/plane/instances/1/sphere",
				"/plane/instances/2/sphere",
				"/plane/instances/3/sphere",
			] )
		)
コード例 #4
0
    def testRootMatchVsNoMatch(self):

        plane = GafferScene.Plane()
        pathFilter = GafferScene.PathFilter()

        filterResults = GafferScene.FilterResults()
        filterResults["scene"].setInput(plane["out"])
        filterResults["filter"].setInput(pathFilter["out"])
        self.assertEqual(filterResults["outStrings"].getValue(),
                         IECore.StringVectorData())

        pathFilter["paths"].setValue(IECore.StringVectorData(["/"]))
        self.assertEqual(filterResults["outStrings"].getValue(),
                         IECore.StringVectorData(["/"]))
コード例 #5
0
    def testRoot(self):

        # /group
        #    /group
        #        /plane
        #    /plane

        plane = GafferScene.Plane()

        innerGroup = GafferScene.Group()
        innerGroup["in"][0].setInput(plane["out"])

        outerGroup = GafferScene.Group()
        outerGroup["in"][0].setInput(innerGroup["out"])
        outerGroup["in"][1].setInput(plane["out"])

        filter = GafferScene.PathFilter()
        filter["paths"].setValue(IECore.StringVectorData(["/..."]))

        filterResults = GafferScene.FilterResults()
        filterResults["scene"].setInput(outerGroup["out"])
        filterResults["filter"].setInput(filter["out"])

        self.assertEqual(
            filterResults["out"].getValue().value,
            IECore.PathMatcher([
                "/",
                "/group",
                "/group/group",
                "/group/group/plane",
                "/group/plane",
            ]))

        hash = filterResults["out"].hash()

        filterResults["root"].setValue("/group/group")
        self.assertEqual(
            filterResults["out"].getValue().value,
            IECore.PathMatcher([
                "/group/group",
                "/group/group/plane",
            ]))
        self.assertNotEqual(filterResults["out"].hash(), hash)
コード例 #6
0
ファイル: FilterResultsTest.py プロジェクト: wubugui/gaffer
    def testChangingScene(self):

        p = GafferScene.Plane()
        g = GafferScene.Group()
        g["in"][0].setInput(p["out"])

        f = GafferScene.PathFilter()
        f["paths"].setValue(IECore.StringVectorData(["/group/plain"]))

        n = GafferScene.FilterResults()
        n["scene"].setInput(g["out"])
        n["filter"].setInput(f["out"])

        self.assertEqual(n["out"].getValue().value, IECore.PathMatcher())

        p["name"].setValue("plain")

        self.assertEqual(n["out"].getValue().value,
                         IECore.PathMatcher(["/group/plain"]))
コード例 #7
0
ファイル: FilterResultsTest.py プロジェクト: tws0002/gaffer
	def testDirtyPropagation( self ) :

		p = GafferScene.Plane()
		p["sets"].setValue( "A" )

		f = GafferScene.SetFilter()
		f["set"].setValue( "A" )

		n = GafferScene.FilterResults()
		n["scene"].setInput( p["out"] )
		n["filter"].setInput( f["out"] )

		cs = GafferTest.CapturingSlot( n.plugDirtiedSignal() )

		f["set"].setValue( "planeSet" )
		self.assertTrue( n["out"] in { x[0] for x in cs } )
		del cs[:]

		p["name"].setValue( "thing" )
		self.assertTrue( n["out"] in { x[0] for x in cs } )
コード例 #8
0
    def testComputePerformance(self):

        sphere = GafferScene.Sphere()

        duplicate = GafferScene.Duplicate()
        duplicate["in"].setInput(sphere["out"])
        duplicate["target"].setValue('/sphere')
        duplicate["copies"].setValue(1000000)

        pathFilter = GafferScene.PathFilter()
        pathFilter["paths"].setValue(IECore.StringVectorData(['...']))

        filterResults = GafferScene.FilterResults()
        filterResults["scene"].setInput(duplicate["out"])
        filterResults["filter"].setInput(pathFilter["out"])

        # Evaluate the root childNames beforehand to focus our timing on the compute
        duplicate["out"].childNames("/")

        with GafferTest.TestRunner.PerformanceScope():
            filterResults["out"].getValue()
コード例 #9
0
#  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
#  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
#  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
#  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
#  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
#  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
##########################################################################

import IECore

import Gaffer
import GafferScene

_filterResults = GafferScene.FilterResults()
_filteredPaths = Gaffer.PathMatcherDataPlug(
    "__filteredPaths", defaultValue=IECore.PathMatcherData())


def __branchCreatorGetItem(originalGetItem):
    def getItem(self, key):

        # In Gaffer 0.54, a connection between these internal implementation details was accidentally
        # serialised into scripts. The implementation has since been replaced, but we need to provide
        # proxies to keep the bogus serialisations loading quietly.
        if key == "__filteredPaths":
            return _filteredPaths
        elif key == "__filterResults":
            return _filterResults