示例#1
0
    def testWriteAnimatedBounds(self):

        aBound1 = imath.Box3d(imath.V3d(-2), imath.V3d(2))
        aBound2 = imath.Box3d(imath.V3d(0), imath.V3d(4))

        bBound1 = imath.Box3d(imath.V3d(-1), imath.V3d(1))
        bBound2 = imath.Box3d(imath.V3d(1), imath.V3d(3))

        a = IECoreAlembic.AlembicScene("/tmp/test.abc",
                                       IECore.IndexedIO.OpenMode.Write)
        a.writeBound(aBound1, 0)
        a.writeBound(aBound2, 1)

        b = a.createChild("b")
        b.writeBound(bBound1, 0)
        b.writeBound(bBound2, 1)

        del a, b

        a = IECoreAlembic.AlembicScene("/tmp/test.abc",
                                       IECore.IndexedIO.OpenMode.Read)
        self.assertEqual(a.numBoundSamples(), 2)
        self.assertEqual(a.readBoundAtSample(0), aBound1)
        self.assertEqual(a.readBoundAtSample(1), aBound2)
        self.assertEqual(a.readBound(0), aBound1)
        self.assertEqual(a.readBound(1), aBound2)

        b = a.child("b")
        self.assertEqual(b.numBoundSamples(), 2)
        self.assertEqual(b.readBoundAtSample(0), bBound1)
        self.assertEqual(b.readBoundAtSample(1), bBound2)
        self.assertEqual(b.readBound(0), bBound1)
        self.assertEqual(b.readBound(1), bBound2)
示例#2
0
    def testWriteAnimatedObject(self):

        o1 = IECoreScene.PointsPrimitive(IECore.V3fVectorData([imath.V3f(0)]))
        o1["id"] = IECoreScene.PrimitiveVariable(
            IECoreScene.PrimitiveVariable.Interpolation.Vertex,
            IECore.UInt64VectorData([0]))
        o1["test"] = IECoreScene.PrimitiveVariable(
            IECoreScene.PrimitiveVariable.Interpolation.Vertex,
            IECore.IntVectorData([1]))

        o2 = IECoreScene.PointsPrimitive(IECore.V3fVectorData([imath.V3f(1)]))
        o2["id"] = IECoreScene.PrimitiveVariable(
            IECoreScene.PrimitiveVariable.Interpolation.Vertex,
            IECore.UInt64VectorData([0]))
        o2["test"] = IECoreScene.PrimitiveVariable(
            IECoreScene.PrimitiveVariable.Interpolation.Vertex,
            IECore.IntVectorData([2]))

        a = IECoreAlembic.AlembicScene("/tmp/test.abc",
                                       IECore.IndexedIO.OpenMode.Write)
        c = a.createChild("o")
        c.writeObject(o1, 0)
        c.writeObject(o2, 1)
        del a, c

        a = IECoreAlembic.AlembicScene("/tmp/test.abc",
                                       IECore.IndexedIO.OpenMode.Read)
        c = a.child("o")

        self.assertEqual(c.numObjectSamples(), 2)

        o1r = c.readObjectAtSample(0)

        self.assertEqual(c.readObjectAtSample(0), o1)
        self.assertEqual(c.readObjectAtSample(1), o2)
示例#3
0
    def testWriteGeometricTypedData(self):

        o = IECoreScene.PointsPrimitive(IECore.V3fVectorData([imath.V3f(0)]))
        o["id"] = IECoreScene.PrimitiveVariable(
            IECoreScene.PrimitiveVariable.Interpolation.Vertex,
            IECore.UInt64VectorData([0]))
        o["v3f"] = IECoreScene.PrimitiveVariable(
            IECoreScene.PrimitiveVariable.Interpolation.Vertex,
            IECore.V3fVectorData([imath.V3f(1)],
                                 IECore.GeometricData.Interpretation.Vector))
        o["n3f"] = IECoreScene.PrimitiveVariable(
            IECoreScene.PrimitiveVariable.Interpolation.Vertex,
            IECore.V3fVectorData([imath.V3f(1)],
                                 IECore.GeometricData.Interpretation.Normal))
        o["p3f"] = IECoreScene.PrimitiveVariable(
            IECoreScene.PrimitiveVariable.Interpolation.Vertex,
            IECore.V3fVectorData([imath.V3f(1)],
                                 IECore.GeometricData.Interpretation.Point))

        a = IECoreAlembic.AlembicScene("/tmp/test.abc",
                                       IECore.IndexedIO.OpenMode.Write)
        c = a.createChild("o")
        c.writeObject(o, 0)
        del a, c

        a = IECoreAlembic.AlembicScene("/tmp/test.abc",
                                       IECore.IndexedIO.OpenMode.Read)
        c = a.child("o")
        self.assertEqual(c.readObjectAtSample(0), o)
示例#4
0
    def testReacquireChildDuringWriting(self):

        plane0 = IECoreScene.MeshPrimitive.createPlane(
            imath.Box2f(imath.V2f(-1), imath.V2f(1)))
        plane1 = IECoreScene.MeshPrimitive.createPlane(
            imath.Box2f(imath.V2f(-2), imath.V2f(2)))

        def writeHierarchy(a, plane, time):

            c = a.child(
                "c",
                IECoreScene.SceneInterface.MissingBehaviour.CreateIfMissing)
            d = c.child(
                "d",
                IECoreScene.SceneInterface.MissingBehaviour.CreateIfMissing)

            d.writeObject(plane, time)

        a = IECoreAlembic.AlembicScene("/tmp/test.abc",
                                       IECore.IndexedIO.OpenMode.Write)

        writeHierarchy(a, plane0, 0)
        writeHierarchy(a, plane1, 1)

        del a
        a = IECoreAlembic.AlembicScene("/tmp/test.abc",
                                       IECore.IndexedIO.OpenMode.Read)
        d = a.child("c").child("d")
        self.assertEqual(d.numObjectSamples(), 2)
        self.assertEqual(d.readObjectAtSample(0), plane0)
        self.assertEqual(d.readObjectAtSample(1), plane1)
示例#5
0
	def testSamples( self ) :
	
		a = IECoreAlembic.AlembicInput( os.path.dirname( __file__ ) + "/data/animatedCube.abc" )
		
		self.assertEqual( a.numSamples(), 10 )
		for i in range( 0, a.numSamples() ) :
			self.assertAlmostEqual( a.timeAtSample( i ), (i + 1) / 24.0 )
		
		p = a.child( "persp" )
		self.assertEqual( p.numSamples(), 1 )	
		self.assertEqual( p.timeAtSample( 0 ), 1 / 24.0 )
		
		t = a.child( "pCube1" )
		self.assertEqual( t.numSamples(), 10 )	
		for i in range( 0, t.numSamples() ) :
			self.assertAlmostEqual( t.timeAtSample( i ), (i + 1) / 24.0 )
	
		m = t.child( "pCubeShape1" )
		self.assertEqual( m.numSamples(), 10 )	
		for i in range( 0, m.numSamples() ) :
			self.assertAlmostEqual( m.timeAtSample( i ), (i + 1) / 24.0 )
		
		a = IECoreAlembic.AlembicInput( os.path.dirname( __file__ ) + "/data/noTopLevelStoredBounds.abc" )
		
		self.assertEqual( a.numSamples(), 0 )
		
		# no time samples at the top level, so this should throw an exception:
		self.assertRaises( Exception, a.timeAtSample, 0 )
		
		# should throw the RIGHT exceptions:
		try:
			a.timeAtSample(0)
		except Exception, e:
			self.assertEqual( str(e), "Invalid Argument : Sample index out of range" )
示例#6
0
    def testWritePointsWithoutIDs(self):

        # IDs a required by alembic and are  generated in the writer if they're not present
        # So we should expect them to be in the deserialized alembic file.
        numParticles = 1024 * 1024 * 16
        o1 = IECoreScene.PointsPrimitive(
            IECore.V3fVectorData([imath.V3f(0)] * numParticles))

        o1["a"] = IECoreScene.PrimitiveVariable(
            IECoreScene.PrimitiveVariable.Interpolation.Vertex,
            IECore.FloatVectorData([0] * numParticles))
        o1["b"] = IECoreScene.PrimitiveVariable(
            IECoreScene.PrimitiveVariable.Interpolation.Vertex,
            IECore.FloatVectorData([1] * numParticles))

        a = IECoreAlembic.AlembicScene("/tmp/test.abc",
                                       IECore.IndexedIO.OpenMode.Write)
        c = a.createChild("o")
        c.writeObject(o1, 0)
        del a, c

        a = IECoreAlembic.AlembicScene("/tmp/test.abc",
                                       IECore.IndexedIO.OpenMode.Read)
        c = a.child("o")

        self.assertEqual(c.numObjectSamples(), 1)

        ro1 = c.readObjectAtSample(0)
        self.assertTrue("id" in ro1)
        self.assertEqual(ro1["id"].data,
                         IECore.UInt64VectorData(range(numParticles)))

        del ro1["id"]
        self.assertEqual(ro1, o1)
示例#7
0
	def testCanWeRoundTripIndexedPrimvars( self ) :

		plane = IECore.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) )

		data = IECore.FloatVectorData( [1] )
		indices = IECore.IntVectorData( [0, 0, 0, 0] )

		primVar = IECore.PrimitiveVariable( IECore.PrimitiveVariable.Interpolation.FaceVarying, data, indices )

		plane["test"] = primVar

		outputFilename = "/tmp/test.abc"

		root = IECoreAlembic.AlembicScene( outputFilename, IECore.IndexedIO.OpenMode.Write )

		location = root.child( "object", IECore.SceneInterface.MissingBehaviour.CreateIfMissing )

		location.writeObject( plane, 0 )

		del location
		del root

		root = IECoreAlembic.AlembicScene( outputFilename, IECore.IndexedIO.OpenMode.Read )

		c = root.child( "object" )

		object = c.readObjectAtSample( 0 )

		self.assertEqual( object["test"].data, IECore.FloatVectorData( [1] ) )
		self.assertEqual( object["test"].indices, IECore.IntVectorData( [0, 0, 0, 0] ) )
示例#8
0
	def __testWriteObject( self, sourceFile, sourcePath ) :

		a1 = IECoreAlembic.AlembicScene( sourceFile, IECore.IndexedIO.OpenMode.Read )
		o1 = a1.scene( sourcePath ).readObject( 0 )

		a2 = IECoreAlembic.AlembicScene( "/tmp/test.abc", IECore.IndexedIO.OpenMode.Write )
		a2.createChild( "o" ).writeObject( o1, 0 )
		del a2

		a3 = IECoreAlembic.AlembicScene( "/tmp/test.abc", IECore.IndexedIO.OpenMode.Read )
		o2 = a3.child( "o" ).readObject( 0 )

		self.assertEqual( o2, o1 )
示例#9
0
	def testHasStoredBound( self ) :
	
		a = IECoreAlembic.AlembicInput( os.path.dirname( __file__ ) + "/data/animatedCube.abc" )
		
		self.assertEqual( a.hasStoredBound(), True )
		self.assertEqual( a.child( "persp" ).hasStoredBound(), False )
		self.assertEqual( a.child( "persp" ).child( "perspShape" ).hasStoredBound(), False )
		self.assertEqual( a.child( "pCube1" ).hasStoredBound(), False )
		self.assertEqual( a.child( "pCube1" ).child( "pCubeShape1" ).hasStoredBound(), True )		
		self.assertEqual( a.child( "front" ).hasStoredBound(), False )
		self.assertEqual( a.child( "front" ).child( "frontShape" ).hasStoredBound(), False )
		
		a = IECoreAlembic.AlembicInput( os.path.dirname( __file__ ) + "/data/noTopLevelStoredBounds.abc" )
		self.assertEqual( a.hasStoredBound(), False )
示例#10
0
    def testMetaData(self):

        a = IECoreAlembic.AlembicInput(
            os.path.dirname(__file__) + "/data/cube.abc")

        m = a.metaData()
        self.failUnless(isinstance(m, IECore.CompoundData))
示例#11
0
	def testHierarchy( self ) :
	
		a = IECoreAlembic.AlembicInput( os.path.dirname( __file__ ) + "/data/cube.abc" )
		self.assertEqual( a.numChildren(), 1 )
		self.assertEqual( a.childNames(), IECore.StringVectorData( [ "group1" ] ) )
				
		g1 = a.child( 0 )
		g2 = a.child( "group1" )
		
		self.assertEqual( g1.name(), g2.name() )
		self.assertEqual( g1.name(), "group1" )
		
		self.assertEqual( g1.fullName(), g2.fullName() )
		self.assertEqual( g1.fullName(), "/group1" )
		
		self.assertEqual( g1.numChildren(), 1 )
		self.assertEqual( g1.childNames(), IECore.StringVectorData( [ "pCube1" ] ) )
		
		c = g1.child( 0 )
		self.assertEqual( c.name(), "pCube1" )
		self.assertEqual( c.fullName(), "/group1/pCube1" )
		
		self.assertEqual( c.numChildren(), 1 )
		self.assertEqual( c.childNames(), IECore.StringVectorData( [ "pCubeShape1" ] ) )
		
		cs = c.child( 0 )
		self.assertEqual( cs.numChildren(), 0 )
		self.assertEqual( cs.childNames(), IECore.StringVectorData() )
		
		self.assertRaises( Exception, cs.child, 0 )
		self.assertRaises( Exception, cs.child, "iDontExist" )
示例#12
0
    def testConvertUVs(self):

        a = IECoreAlembic.AlembicInput(
            os.path.dirname(__file__) + "/data/coloredMesh.abc")
        m = a.child("pPlane1").child("pPlaneShape1").objectAtSample(
            0, IECore.MeshPrimitive.staticTypeId())

        self.failUnless("uv" in m)

        self.assertEqual(m["uv"].interpolation,
                         IECore.PrimitiveVariable.Interpolation.FaceVarying)

        self.failUnless(isinstance(m["uv"].data, IECore.V2fVectorData))
        self.assertEqual(m["uv"].data.getInterpretation(),
                         IECore.GeometricData.Interpretation.UV)
        self.failUnless(isinstance(m["uv"].indices, IECore.IntVectorData))

        self.assertEqual(
            len(m["uv"].data),
            m.variableSize(IECore.PrimitiveVariable.Interpolation.Vertex))
        self.assertEqual(
            len(m["uv"].indices),
            m.variableSize(IECore.PrimitiveVariable.Interpolation.FaceVarying))

        self.failUnless(m.isPrimitiveVariableValid(m["uv"]))
示例#13
0
    def testAnimation(self):

        a = GafferScene.AlembicSource()
        a["fileName"].setValue(
            os.path.dirname(__file__) + "/alembicFiles/animatedCube.abc")

        self.assertSceneValid(a["out"])

        b = IECoreAlembic.AlembicInput(
            os.path.dirname(__file__) + "/alembicFiles/animatedCube.abc")
        c = b.child("pCube1").child("pCubeShape1")
        numSamples = b.numSamples()
        startTime = b.timeAtSample(0)
        endTime = b.timeAtSample(numSamples - 1)

        for i in range(0, numSamples * 2):
            time = startTime + (endTime -
                                startTime) * float(i) / (numSamples * 2 - 1)
            c = Gaffer.Context()
            c.setFrame(time * 24)
            with c:
                self.assertBoxesAlmostEqual(a["out"].bound("/"),
                                            b.boundAtTime(time), 6)
                self.assertBoxesAlmostEqual(
                    a["out"].bound("/pCube1/pCubeShape1"), b.boundAtTime(time),
                    6)
示例#14
0
	def testBound( self ) :
	
		a = IECoreAlembic.AlembicInput( os.path.dirname( __file__ ) + "/data/cube.abc" )
		self.assertEqual( a.boundAtSample(), IECore.Box3d( IECore.V3d( -2 ), IECore.V3d( 2 ) ) )
		
		cs = a.child( "group1" ).child( "pCube1" ).child( "pCubeShape1" )
		self.assertEqual( cs.boundAtSample(), IECore.Box3d( IECore.V3d( -1 ), IECore.V3d( 1 ) ) )		
示例#15
0
    def doOperation(self, args):

        inFile = IECoreAlembic.AlembicInput(args["inputFile"].value)
        outFile = IECore.ModelCache(args["outputFile"].value,
                                    IECore.IndexedIO.OpenMode.Write)

        time = inFile.timeAtSample(0)

        def walk(alembicInput, modelCache):

            o = alembicInput.objectAtTime(time,
                                          IECore.Primitive.staticTypeId())
            if o is not None:
                modelCache.writeObject(o)

            t = alembicInput.transformAtTime(time)
            modelCache.writeTransform(t)

            numChildren = alembicInput.numChildren()
            for i in range(0, numChildren):
                alembicChild = alembicInput.child(i)
                modelCacheChild = modelCache.writableChild(alembicChild.name())
                walk(alembicChild, modelCacheChild)

        walk(inFile, outFile)

        return args["outputFile"].value
示例#16
0
    def testAnimation(self):

        a = GafferScene.AlembicSource()
        a["fileName"].setValue(
            os.path.dirname(__file__) + "/alembicFiles/animatedCube.abc")

        # We have to skip the test of built in sets, because our alembic file contains cameras
        # and alembic doesn't provide a means of flagging them upfront.
        self.assertSceneValid(a["out"], assertBuiltInSetsComplete=False)

        b = IECoreAlembic.AlembicInput(
            os.path.dirname(__file__) + "/alembicFiles/animatedCube.abc")
        c = b.child("pCube1").child("pCubeShape1")
        numSamples = b.numSamples()
        startTime = b.timeAtSample(0)
        endTime = b.timeAtSample(numSamples - 1)

        for i in range(0, numSamples * 2):
            time = startTime + (endTime -
                                startTime) * float(i) / (numSamples * 2 - 1)
            c = Gaffer.Context()
            c.setTime(time)
            with c:
                self.assertBoxesAlmostEqual(a["out"].bound("/"),
                                            b.boundAtTime(time), 6)
                self.assertBoxesAlmostEqual(
                    a["out"].bound("/pCube1/pCubeShape1"), b.boundAtTime(time),
                    6)
    def test(self):

        IECoreAlembic.ABCToMDC()(inputFile=os.path.dirname(__file__) +
                                 "/data/cube.abc",
                                 outputFile="/tmp/test.mdc")

        m = IECore.ModelCache("/tmp/test.mdc", IECore.IndexedIO.OpenMode.Read)
        self.assertEqual(m.childNames(), ["group1"])
        self.assertEqual(m.readBound(),
                         IECore.Box3d(IECore.V3d(-2), IECore.V3d(2)))
        self.assertEqual(m.readObject(), None)
        self.assertEqual(m.readTransform(), IECore.M44d())

        g = m.readableChild("group1")
        self.assertEqual(
            g.readTransform(),
            IECore.M44d.createScaled(IECore.V3d(2)) *
            IECore.M44d.createTranslated(IECore.V3d(2, 0, 0)))
        self.assertEqual(g.readObject(), None)
        self.assertEqual(g.childNames(), ["pCube1"])

        t = g.readableChild("pCube1")
        self.assertEqual(t.readTransform(),
                         IECore.M44d.createTranslated(IECore.V3d(-1, 0, 0)))
        self.assertEqual(t.readObject(), None)
        self.assertEqual(t.childNames(), ["pCubeShape1"])

        s = t.readableChild("pCubeShape1")
        self.assertEqual(s.readTransform(), IECore.M44d())
        self.assertEqual(s.readBound(),
                         IECore.Box3d(IECore.V3d(-1), IECore.V3d(1)))
        self.assertEqual(s.childNames(), [])
示例#18
0
    def testPoints(self):

        a = IECoreAlembic.AlembicInput(
            os.path.dirname(__file__) + "/data/points.abc")
        p = a.child("particle1").child("particleShape1")
        points = p.objectAtSample(9)

        self.assertTrue(isinstance(points, IECore.PointsPrimitive))
        self.assertEqual(points.numPoints, 9)

        self.assertTrue(points.arePrimitiveVariablesValid())

        self.assertTrue(isinstance(points["P"].data, IECore.V3fVectorData))
        self.assertEqual(points["P"].data.getInterpretation(),
                         IECore.GeometricData.Interpretation.Point)
        self.assertEqual(points["velocity"].data.getInterpretation(),
                         IECore.GeometricData.Interpretation.Vector)

        self.assertTrue(isinstance(points["id"].data, IECore.UInt64VectorData))

        for i in range(0, 9):

            self.assertTrue(
                points["P"].data[i].normalized().equalWithAbsError(
                    points["velocity"].data[i].normalized(), 0.00001), )
            self.assertEqual(points["id"].data[i], i)
示例#19
0
	def testSampleInterval( self ) :
	
		a = IECoreAlembic.AlembicInput( os.path.dirname( __file__ ) + "/data/animatedCube.abc" )
		
		# persp has only one sample, so should always be reading from that regardless the time
		p = a.child( "persp" )
		t = -1000
		while t < 1000 :
			t += .01
			self.assertEqual( p.sampleIntervalAtTime( t ), ( 0, 0, 0 ) )
	
		# pCube1 has a sample per frame
		t = a.child( "pCube1" )
		for i in range( 0, t.numSamples() ) :
			# reads on the frame should not need
			# interpolation.
			v = t.sampleIntervalAtTime( t.timeAtSample( i ) )
			self.assertEqual( v[0], 0 )
			self.assertEqual( v[1], i )
			self.assertEqual( v[1], i )
			# reads in between frames should need
			# interpolation
			if i < t.numSamples() -1 :
				v = t.sampleIntervalAtTime( t.timeAtSample( i ) + 1 / 48.0 )
				self.assertAlmostEqual( v[0], 0.5 )
				self.assertEqual( v[1], i )	
				self.assertEqual( v[2], i + 1 )			
示例#20
0
	def testConvertArbGeomParams( self ) :
	
		a = IECoreAlembic.AlembicInput( os.path.dirname( __file__ ) + "/data/coloredMesh.abc" )
		
		m = a.child( "pPlane1" ).child( "pPlaneShape1" ).objectAtSample( 0, IECore.MeshPrimitive.staticTypeId() )
				
		self.failUnless( m.arePrimitiveVariablesValid() )
				
		self.failUnless( "colorSet1" in m )
		self.assertEqual( m["colorSet1"].interpolation, IECore.PrimitiveVariable.Interpolation.FaceVarying )
		self.failUnless( isinstance( m["colorSet1"].data, IECore.Color4fVectorData ) )
		self.assertEqual( len( m["colorSet1"].data ), 4 )
		self.assertEqual(
			m["colorSet1"].data,
			IECore.Color4fVectorData( [
				IECore.Color4f( 0, 1, 0, 1 ),
				IECore.Color4f( 0, 0, 1, 1 ),
				IECore.Color4f( 0, 0, 0, 1 ),
				IECore.Color4f( 1, 0, 0, 1 ),												
			] )
		)
		
		self.failUnless( "ABC_int" in m )
		self.assertEqual( m["ABC_int"].interpolation, IECore.PrimitiveVariable.Interpolation.Constant )
		self.assertEqual( m["ABC_int"].data, IECore.IntVectorData( [ 10 ] ) )
示例#21
0
	def testConverterAccess( self ) :
	
		a = IECoreAlembic.AlembicInput( os.path.dirname( __file__ ) + "/data/animatedCube.abc" )
		m = a.child( "pCube1" ).child( "pCubeShape1" )
		c = m.converter()
		
		mesh = c.convert()
		self.failUnless( isinstance( mesh, IECore.MeshPrimitive ) )
示例#22
0
	def testCamera( self ) :
	
		a = IECoreAlembic.AlembicInput( os.path.dirname( __file__ ) + "/data/animatedCube.abc" )
		
		c = a.child( "persp" ).child( "perspShape" ).objectAtSample( 0 )
		self.failUnless( isinstance( c, IECore.Camera ) )		
		
		c = a.child( "persp" ).child( "perspShape" ).objectAtTime( 0 )
		self.failUnless( isinstance( c, IECore.Camera ) )		
示例#23
0
	def testConstruction( self ) :

		fileName = os.path.dirname( __file__ ) + "/data/cube.abc"

		s = IECore.SceneInterface.create( fileName, IECore.IndexedIO.OpenMode.Read )
		self.assertEqual( s.fileName(), fileName )

		s = IECoreAlembic.AlembicScene( fileName, IECore.IndexedIO.OpenMode.Read )
		self.assertEqual( s.fileName(), fileName )
示例#24
0
	def testRotatingTransformAtSample( self ) :
	
		a = IECoreAlembic.AlembicInput( os.path.dirname( __file__ ) + "/data/rotatingCube.abc" )		

		t = a.child( "pCube1" )	
		for i in range( 0, 24 ) :
			ti = t.transformAtSample( i )
			mi = IECore.M44d.createRotated( IECore.V3d( IECore.degreesToRadians( 90 * i ), 0, 0 ) )
			self.failUnless( ti.equalWithAbsError( mi, 0.0000000000001 ) )
示例#25
0
	def testConvertNormals( self ) :
	
		a = IECoreAlembic.AlembicInput( os.path.dirname( __file__ ) + "/data/animatedCube.abc" )
		m = a.child( "pCube1" ).child( "pCubeShape1" )
		mesh = m.objectAtSample( 0 )
		
		self.failUnless( "N" in mesh )
		self.failUnless( isinstance( mesh["N"].data, IECore.V3fVectorData ) )
		self.assertEqual( mesh["N"].interpolation, IECore.PrimitiveVariable.Interpolation.FaceVarying )
		self.assertEqual( mesh["N"].data.getInterpretation(), IECore.GeometricData.Interpretation.Normal )
示例#26
0
    def __init__(self, fileNameOrAlembicInput, path, root="/", filter=None):

        Gaffer.Path.__init__(self, path, root, filter=filter)

        if isinstance(fileNameOrAlembicInput, basestring):
            self.__rootInput = IECoreAlembic(fileNameOrAlembicInput)
        else:
            assert (isinstance(fileNameOrAlembicInput,
                               IECoreAlembic.AlembicInput))
            self.__rootInput = fileNameOrAlembicInput
示例#27
0
	def testHierarchyIgnoresShadingGroups( self ) :

		a = IECoreAlembic.AlembicInput( os.path.dirname( __file__ ) + "/data/sphereWithShadingGroups.abc" )
		self.assertEqual( a.numChildren(), 1 )
		self.assertEqual( a.childNames(), IECore.StringVectorData( [ "pSphere1" ] ) )

		g = a.child( "pSphere1" )
		m = g.child( "pSphereShape1" )

		self.assertEqual( m.numChildren(), 0 )
		self.assertEqual( m.childNames(), IECore.StringVectorData() )
示例#28
0
	def testInterpolatedRotate( self ) :
			
		a = IECoreAlembic.AlembicInput( os.path.dirname( __file__ ) + "/data/rotatingCube.abc" )		

		t = a.child( "pCube1" )	
		for i in range( 0, t.numSamples() * 2 - 1 ) :
			frame = i / 2.0 + 1
			time = frame / 24.0
			matrix = t.transformAtTime( time )
			expectedMatrix = IECore.M44d.createRotated( IECore.V3d( IECore.degreesToRadians( 90 * i * 0.5 ), 0, 0 ) )
			self.failUnless( matrix.equalWithAbsError( expectedMatrix, 0.0000001 ) )
示例#29
0
	def testConvertMesh( self ) :
	
		a = IECoreAlembic.AlembicInput( os.path.dirname( __file__ ) + "/data/cube.abc" )
		
		c = a.child( "group1" ).child( "pCube1" )
		self.assertEqual( c.objectAtSample( 0, IECore.MeshPrimitive.staticTypeId() ), None )
		
		cs = c.child( "pCubeShape1" )
		m = cs.objectAtSample( 0, IECore.MeshPrimitive.staticTypeId() )
		
		self.failUnless( isinstance( m, IECore.MeshPrimitive ) )
示例#30
0
	def testNURBSCircle( self ) :

		a = IECoreAlembic.AlembicInput( os.path.dirname( __file__ ) + "/data/curves.abc" )
		c = a.child( "nurbsCircle" ).child( "nurbsCircleShape" )
		curves = c.objectAtSample( 0 )

		self.assertTrue( isinstance( curves, IECore.CurvesPrimitive ) )
		self.assertEqual( curves.basis(), IECore.CubicBasisf.bSpline() )
		self.assertEqual( curves.verticesPerCurve(), IECore.IntVectorData( [ 11 ] ) )
		self.assertEqual( curves.periodic(), True )
		self.assertTrue( curves.arePrimitiveVariablesValid() )