MCPcopy Create free account
hub / github.com/ImageEngine/cortex / testDeprecatedSplines

Method testDeprecatedSplines

test/IECoreScene/SceneCacheTest.py:1204–1277  ·  view source on GitHub ↗
( self )

Source from the content-addressed store, hash-verified

1202 self.assertEqual( c.readAttribute( a, 0 ), objectVector )
1203
1204 def testDeprecatedSplines( self ) :
1205
1206 # Test with a file saved from old Gaffer, this hopefully makes sure this is working in practice
1207 fileName = pathlib.Path( __file__ ).parent / "data" / "oldSplines.scc"
1208 root = IECoreScene.SceneInterface.create( str( fileName ), IECore.IndexedIO.OpenMode.Read )
1209 child = root.child( "cube" )
1210
1211 shaderNetwork = child.readAttribute( "ai:surface", 0 )
1212 self.assertEqual(
1213 shaderNetwork.getShader( "ColorSpline" ).parameters["spline"],
1214 IECore.RampfColor3fData( IECore.RampfColor3f(
1215 (
1216 ( 0, imath.Color3f( 0, 0, 0 ) ),
1217 ( 0.4, imath.Color3f( 0.3, 0.5, 0.9 ) ),
1218 ( 0.7, imath.Color3f( 0.8, 0.7, 0.3) ),
1219 ( 1, imath.Color3f( 1, 1, 1 ) )
1220 ),
1221 IECore.RampInterpolation.Linear
1222 ) )
1223 )
1224
1225 self.assertEqual(
1226 shaderNetwork.getShader( "FloatSpline" ).parameters["spline"],
1227 IECore.RampffData(IECore.Rampff(
1228 (
1229 ( 0, 0 ),
1230 ( 0.3, 0.8 ),
1231 ( 0.7, 0.7 ),
1232 ( 0.9, 0.1 ),
1233 ( 1, 1 ),
1234 ),
1235 IECore.RampInterpolation.BSpline
1236 ) )
1237 )
1238
1239 # A more synthetic test to exercise the compatibility for all spline types
1240
1241 for interp in IECore.RampInterpolation.values.keys():
1242 ramp = IECore.RampfColor3f(
1243 (
1244 ( 0, imath.Color3f( 0 ) ),
1245 ( 0.3, imath.Color3f( 0.8, 0.5, 0.4 ) ),
1246 ( 0.7, imath.Color3f( 0.7, 0.1, 0.2 ) ),
1247 ( 0.9, imath.Color3f( 0.1, 0.4, 0.6 ) ),
1248 ( 1, imath.Color3f( 1 ) ),
1249 ),
1250 IECore.RampInterpolation( interp )
1251 )
1252
1253 s = IECoreScene.Shader( "standard_surface" )
1254
1255 # Instead of writing out the Ramp, write out the Ramp's evaluator. This is wrong, but it matches
1256 # how things used to work, when Spline was the primary representation.
1257 s.parameters["test"] = IECore.SplinefColor3fData( ramp.evaluator() )
1258 shaderNetwork = IECoreScene.ShaderNetwork(
1259 shaders = {
1260 "shader" : s
1261 },

Callers

nothing calls this directly

Calls 15

getShaderMethod · 0.95
createChildMethod · 0.95
childMethod · 0.95
evaluatorMethod · 0.80
ShaderNetworkMethod · 0.80
MemoryIndexedIOMethod · 0.80
SceneCacheMethod · 0.80
strFunction · 0.50
createMethod · 0.45
childMethod · 0.45
readAttributeMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected