def test(self): fileName = os.path.expandvars( "$GAFFER_ROOT/python/GafferTest/images/checker.exr") node = GafferCortex.ObjectReader() node["fileName"].setValue(fileName) self.assertEqual(node["fileName"].getValue(), fileName) reader = IECore.Reader.create(fileName) # check that the result is the same as loading it ourselves self.assertEqual(reader.read(), node["out"].getValue())
def testReadAfterSerialisation(self): s = Gaffer.ScriptNode() s["n"] = GafferCortex.ObjectReader() s["n"]["fileName"].setValue( os.path.dirname(__file__) + "/images/checker.exr") r = s["n"]["out"].getValue() ss = s.serialise() s = Gaffer.ScriptNode() s.execute(ss) self.assertEqual(s["n"]["out"].getValue(), r)
def testChangingFileType(self): imageFileName = os.path.expandvars( "$GAFFER_ROOT/python/GafferTest/images/checker.exr") cobFileName = os.path.expandvars( "$GAFFER_ROOT/python/GafferTest/cobs/pSphereShape1.cob") node = GafferCortex.ObjectReader() node["fileName"].setValue(imageFileName) reader = IECore.Reader.create(imageFileName) self.assertEqual(reader.read(), node["out"].getValue()) node["fileName"].setValue(cobFileName) reader = IECore.Reader.create(cobFileName) self.assertEqual(reader.read(), node["out"].getValue())
def __init__(self, name="_ObjectPreview"): Gaffer.Node.__init__(self, name) import GafferCortex self["fileName"] = Gaffer.StringPlug( defaultValue="", substitutions=Gaffer.Context.Substitutions.NoSubstitutions) self["frameRate"] = Gaffer.FloatPlug(defaultValue=24.0) self["samplesPerFrame"] = Gaffer.IntPlug(defaultValue=1, minValue=1) # single object scenes using Reader ops behind the scenes? self["ObjectReader"] = GafferCortex.ObjectReader() self["ObjectReaderExpression"] = Gaffer.Expression("Expression") self["ObjectReaderExpression"].setExpression(''' import IECore fileName = parent['fileName'] try : sequence = IECore.FileSequence( fileName ) calc = IECore.OversamplesCalculator( frameRate = parent["frameRate"], samplesPerFrame = parent["samplesPerFrame"] ) if isinstance( sequence.frameList, IECore.FrameRange ) and sequence.frameList.step == 1 : calc.setTicksPerSecond( 24 ) result = sequence.fileNameForFrame( calc.framesToTicks( context['frame'] ) ) except : result = fileName parent['ObjectReader']['fileName'] = result ''') self["ObjectToScene"] = GafferScene.ObjectToScene("ObjectToScene") self["ObjectToScene"]["object"].setInput(self["ObjectReader"]["out"]) self["out"] = GafferScene.ScenePlug( direction=Gaffer.Plug.Direction.Out) self["out"].setInput(self["ObjectToScene"]["out"])
def testReadNoFilename(self): r = GafferCortex.ObjectReader() self.assertEqual(r["out"].getValue(), r["out"].defaultValue())