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

		v = GafferArnold.ArnoldVDB()

		# Just an empty procedural at this point.
		self.assertEqual( v["out"].childNames( "/" ), IECore.InternedStringVectorData( [ "volume" ] ) )
		self.assertSceneValid( v["out"] )
		self.assertEqual( v["out"].bound( "/volume" ), imath.Box3f( imath.V3f( -0.5 ), imath.V3f( 0.5 ) ) )
		self.assertTrue( isinstance( v["out"].object( "/volume" ), IECoreScene.ExternalProcedural ) )

		# If we enter a valid vdb filename, then we should get something
		# with the right bounds, and the right parameters in the procedural.
		v["fileName"].setValue( os.path.join( os.path.dirname( __file__ ), "volumes", "sphere.vdb" ) )
		self.assertEqual( v["out"].bound( "/volume" ), imath.Box3f( imath.V3f( -1.1, 1.1, -1.1 ), imath.V3f( 1.1, 2.9, 1.1 ) ) )

		procedural = v["out"].object( "/volume" )
		self.assertTrue( isinstance( procedural, IECoreScene.ExternalProcedural ) )
		self.assertEqual( procedural.getBound(), v["out"].bound( "/volume" ) )
		self.assertEqual( procedural.getFileName(), "volume" )
		self.assertEqual( procedural.parameters()["filename" ].value, v["fileName"].getValue() )
		self.assertEqual( procedural.parameters()["grids" ], IECore.StringVectorData( [ v["grids"].getValue() ] ) )

		# Invalid grid names should create errors.
		v["grids"].setValue( "notAGrid" )
		with six.assertRaisesRegex( self, Gaffer.ProcessException, "has no grid named \"notAGrid\"" ) as caught :
			v["out"].bound( "/volume" )

		# As should invalid file names.
		v["grids"].setValue( "density" )
		v["fileName"].setValue( "notAFile.vdb" )
		with six.assertRaisesRegex( self, Gaffer.ProcessException, "No such file or directory" ) :
			v["out"].bound( "/volume" )
コード例 #2
0
	def testStepSize( self ) :

		v = GafferArnold.ArnoldVDB()
		v["fileName"].setValue( os.path.join( os.path.dirname( __file__ ), "volumes", "sphere.vdb" ) )

		self.assertEqual( v["stepSize"].getValue(), 0 )
		self.assertEqual( v["stepScale"].getValue(), 1 )

		# Step size should be calculated for us.
		self.assertAlmostEqual( v["out"].object( "/volume" ).parameters()["step_size"].value, 0.2 )
		# But we can scale it if we want.
		v["stepScale"].setValue( 4 )
		self.assertAlmostEqual( v["out"].object( "/volume" ).parameters()["step_size"].value, 0.8 )
		# Or override it entirely.
		v["stepSize"].setValue( 0.01 )
		self.assertAlmostEqual( v["out"].object( "/volume" ).parameters()["step_size"].value, 0.04 )