def testIntData(self): with IECoreArnold.UniverseBlock(writable=True): n = arnold.AiNode("standard_surface") IECoreArnold.ParameterAlgo.setParameter(n, "customInt", IECore.IntData(42)) IECoreArnold.ParameterAlgo.setParameter(n, "customUInt", IECore.UIntData(43)) IECoreArnold.ParameterAlgo.setParameter( n, "customIntVectorData", IECore.IntVectorData([5, 6, 7])) IECoreArnold.ParameterAlgo.setParameter( n, "customUIntVectorData", IECore.UIntVectorData([12, 2147483649])) self.assertEqual(arnold.AiNodeGetInt(n, "customInt"), 42) self.assertEqual(arnold.AiNodeGetUInt(n, "customUInt"), 43) a = arnold.AiNodeGetArray(n, "customIntVectorData") self.assertEqual(arnold.AiArrayGetNumElements(a.contents), 3) self.assertEqual(arnold.AiArrayGetInt(a, 0), 5) self.assertEqual(arnold.AiArrayGetInt(a, 1), 6) self.assertEqual(arnold.AiArrayGetInt(a, 2), 7) a = arnold.AiNodeGetArray(n, "customUIntVectorData") self.assertEqual(arnold.AiArrayGetNumElements(a.contents), 2) self.assertEqual(arnold.AiArrayGetUInt(a, 0), 12) self.assertEqual(arnold.AiArrayGetUInt(a, 1), 2147483649)
def testIndexedFaceVaryingPrimitiveVariables(self): m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f(imath.V2f(-1), imath.V2f(1)), imath.V2i(2, 1), ) self.assertEqual( m.variableSize( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying), 8) m["myPrimVar"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, IECore.FloatVectorData([5, 10]), IECore.IntVectorData([0, 0, 0, 0, 1, 1, 1, 1])) with IECoreArnold.UniverseBlock(writable=True) as universe: n = IECoreArnold.NodeAlgo.convert(m, universe, "testMesh") a = arnold.AiNodeGetArray(n, "myPrimVar") ia = arnold.AiNodeGetArray(n, "myPrimVaridxs") self.assertEqual(arnold.AiArrayGetNumElements(a.contents), 2) self.assertEqual(arnold.AiArrayGetNumElements(ia.contents), 8) for i in range(0, len(m["myPrimVar"].data)): self.assertEqual(arnold.AiArrayGetFlt(a, i), m["myPrimVar"].data[i]) for i in range(0, len(m["myPrimVar"].indices)): self.assertEqual(arnold.AiArrayGetUInt(ia, i), m["myPrimVar"].indices[i])
def testCornersAndCreases(self): m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f(imath.V2f(-1), imath.V2f(1))) m.setInterpolation("catmullClark") m.setCorners(IECore.IntVectorData([3]), IECore.FloatVectorData([5])) m.setCreases(IECore.IntVectorData([3]), IECore.IntVectorData([0, 1, 2]), IECore.FloatVectorData([6])) with IECoreArnold.UniverseBlock(writable=True) as universe: n = IECoreArnold.NodeAlgo.convert(m, universe, "testMesh") idxArray = arnold.AiNodeGetArray(n, "crease_idxs") for i, v in enumerate([0, 1, 1, 2, 3, 3]): self.assertEqual(arnold.AiArrayGetUInt(idxArray, i), v) sharpnessArray = arnold.AiNodeGetArray(n, "crease_sharpness") for i, v in enumerate([6, 6, 5]): self.assertEqual(arnold.AiArrayGetFlt(sharpnessArray, i), v)
def testFaceVaryingPrimitiveVariables( self ) : m = IECore.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ), IECore.V2i( 2 ), ) self.assertEqual( m.variableSize( IECore.PrimitiveVariable.Interpolation.FaceVarying ), 16 ) m["myPrimVar"] = IECore.PrimitiveVariable( IECore.PrimitiveVariable.Interpolation.FaceVarying, IECore.FloatVectorData( range( 0, 16 ) ) ) with IECoreArnold.UniverseBlock( writable = True ) : n = IECoreArnold.NodeAlgo.convert( m ) a = arnold.AiNodeGetArray( n, "myPrimVar" ) ia = arnold.AiNodeGetArray( n, "myPrimVaridxs" ) self.assertEqual( a.contents.nelements, 16 ) self.assertEqual( ia.contents.nelements, 16 ) for i in range( 0, 16 ) : self.assertEqual( arnold.AiArrayGetFlt( a, i ), i ) self.assertEqual( arnold.AiArrayGetUInt( ia, i ), i )