コード例 #1
0
    def doOperation(self, args):

        assert args["a"].value == 10
        assert abs(args["b"].value - 20.2) < 0.0001
        assert args["c"].value == 40.5
        assert args["d"].value == "hello"
        assert args["e"] == IECore.IntVectorData([2, 4, 5])
        assert args["f"] == IECore.StringVectorData([
            "one", "two", "three", "-1", "-dash", "\\-slashDash",
            "\\\\-slashSlashDash", "inline-dash"
        ])
        assert args["g"] == IECore.V2fData(imath.V2f(2, 4))
        assert args["h"] == IECore.V3fData(imath.V3f(1, 4, 8))
        assert args["i"] == IECore.V2dData(imath.V2d(2, 4))
        assert args["compound"]["j"] == IECore.V3dData(imath.V3d(1, 4, 8))
        assert args["compound"]["k"] == IECore.M44fData(
            imath.M44f(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16))
        assert args["l"] == IECore.Color3fData(imath.Color3f(1, 0, 0))
        assert args["m"] == IECore.Color4fData(imath.Color4f(1, 1, 0, 1))
        assert args["o"] == IECore.StringData("myFile.tif")
        assert args["p"] == IECore.StringData("test")
        assert args["q"] == IECore.BoolData(True)
        assert args["r"] == IECore.StringData("mySequence.####.tif")
        assert args["s"] == IECore.Box2dData(
            imath.Box2d(imath.V2d(-1, -2), imath.V2d(10, 20)))
        assert args["t"] == IECore.Box3fData(
            imath.Box3f(imath.V3f(-1, -2, -3), imath.V3f(10, 20, 30)))
        assert args["u"] == IECore.V2iData(imath.V2i(64, 128))
        assert args["v"] == IECore.V3iData(imath.V3i(25, 26, 27))
        assert self["w"].getFrameListValue().asList() == IECore.FrameRange(
            0, 500, 250).asList()
        assert args["x"] == IECore.TransformationMatrixfData()
        assert args["y"] == IECore.TransformationMatrixdData()

        return IECore.IntData(1)
コード例 #2
0
    def testVectorLinearInterpolation(self):

        self.assertEqual(
            IECore.linearObjectInterpolation(IECore.IntVectorData([1]),
                                             IECore.IntVectorData([2]), 0.5),
            None)
        self.assertEqual(
            IECore.linearObjectInterpolation(IECore.FloatVectorData([1]),
                                             IECore.FloatVectorData([2]), 0.5),
            IECore.FloatVectorData([1.5]))
        self.assertEqual(
            IECore.linearObjectInterpolation(IECore.DoubleVectorData([1]),
                                             IECore.DoubleVectorData([2]),
                                             0.5),
            IECore.DoubleVectorData([1.5]))
        self.assertEqual(
            IECore.linearObjectInterpolation(
                IECore.V2fVectorData([imath.V2f(1)]),
                IECore.V2fVectorData([imath.V2f(2)]), 0.5),
            IECore.V2fVectorData([imath.V2f(1.5)]))
        self.assertEqual(
            IECore.linearObjectInterpolation(
                IECore.V3fVectorData([imath.V3f(1)]),
                IECore.V3fVectorData([imath.V3f(2)]), 0.5),
            IECore.V3fVectorData([imath.V3f(1.5)]))
        self.assertEqual(
            IECore.linearObjectInterpolation(
                IECore.V2dVectorData([imath.V2d(1)]),
                IECore.V2dVectorData([imath.V2d(2)]), 0.5),
            IECore.V2dVectorData([imath.V2d(1.5)]))
        self.assertEqual(
            IECore.linearObjectInterpolation(
                IECore.V3dVectorData([imath.V3d(1)]),
                IECore.V3dVectorData([imath.V3d(2)]), 0.5),
            IECore.V3dVectorData([imath.V3d(1.5)]))
コード例 #3
0
    def makeRandomBound(self):
        b1 = imath.V2d(random.random(), random.random())
        b2 = imath.V2d(random.random(), random.random())
        bound = imath.Box2d(b1)
        bound.extendBy(b2)

        return bound
コード例 #4
0
ファイル: ObjectIO.py プロジェクト: yjcnbnbnb200/cortex
    def testDataTypes(self):

        d = IECore.CompoundData()
        d['a'] = IECore.IntData(1)
        d['c'] = IECore.FloatData(3)
        d['e'] = IECore.HalfData(4)
        d['f'] = IECore.V2iData(imath.V2i(1, 10))
        d['g'] = IECore.V2fData(imath.V2f(2, 31),
                                IECore.GeometricData.Interpretation.Vector)
        d['h'] = IECore.V2dData(imath.V2d(3, 551),
                                IECore.GeometricData.Interpretation.Color)
        d['i'] = IECore.V3fData(imath.V3f(1, 3, 5),
                                IECore.GeometricData.Interpretation.Point)
        d['k'] = IECore.M44fData(imath.M44f(2))
        d['l'] = IECore.HalfVectorData([1, 2, 3, 100, 9, 10, 11])
        d['m'] = IECore.V2fVectorData(
            [imath.V2f(1, 2),
             imath.V2f(3, 4),
             imath.V2f(5, 6)], IECore.GeometricData.Interpretation.Normal)
        d['x'] = IECore.StringData("testttt")
        d['z'] = IECore.StringVectorData(["a", 'b', 'adffs'])

        iface = IECore.IndexedIO.create("test/o.fio", [],
                                        IECore.IndexedIO.OpenMode.Write)
        d.save(iface, "test")

        dd = IECore.Object.load(iface, "test")
        self.assertEqual(d, dd)
コード例 #5
0
ファイル: KDTree.py プロジェクト: yjcnbnbnb200/cortex
    def makeTree(self, numPoints):
        # Make tree creation repeatable, but different for every size
        random.seed(100 + 5 * numPoints)
        self.points = IECore.V2dVectorData()

        for i in range(0, numPoints):
            self.points.append(imath.V2d(random.random(), random.random()))

        self.tree = IECore.V2dTree(self.points)
コード例 #6
0
    def testSimpleLinearInterpolation(self):

        self.assertEqual(
            IECore.linearObjectInterpolation(IECore.IntData(1),
                                             IECore.IntData(2), 0.5), None)
        self.assertEqual(
            IECore.linearObjectInterpolation(IECore.FloatData(1),
                                             IECore.FloatData(2), 0.5),
            IECore.FloatData(1.5))
        self.assertEqual(
            IECore.linearObjectInterpolation(IECore.DoubleData(1),
                                             IECore.DoubleData(2), 0.5),
            IECore.DoubleData(1.5))
        self.assertEqual(
            IECore.linearObjectInterpolation(IECore.V2fData(imath.V2f(1)),
                                             IECore.V2fData(imath.V2f(2)),
                                             0.5),
            IECore.V2fData(imath.V2f(1.5)))
        self.assertEqual(
            IECore.linearObjectInterpolation(IECore.V3fData(imath.V3f(1)),
                                             IECore.V3fData(imath.V3f(2)),
                                             0.5),
            IECore.V3fData(imath.V3f(1.5)))
        self.assertEqual(
            IECore.linearObjectInterpolation(IECore.V2dData(imath.V2d(1)),
                                             IECore.V2dData(imath.V2d(2)),
                                             0.5),
            IECore.V2dData(imath.V2d(1.5)))
        self.assertEqual(
            IECore.linearObjectInterpolation(IECore.V3dData(imath.V3d(1)),
                                             IECore.V3dData(imath.V3d(2)),
                                             0.5),
            IECore.V3dData(imath.V3d(1.5)))
        self.assertEqual(
            IECore.linearObjectInterpolation(
                IECore.Box3fData(imath.Box3f(imath.V3f(1), imath.V3f(1))),
                IECore.Box3fData(imath.Box3f(imath.V3f(2), imath.V3f(2))),
                0.5),
            IECore.Box3fData(imath.Box3f(imath.V3f(1.5), imath.V3f(1.5))))
コード例 #7
0
    def __checkParameterKnobs(self,
                              parameter,
                              node,
                              knobName=None,
                              parameterPath=None,
                              ignore=set()):

        if knobName is None:
            knobName = "parm"

        if parameterPath in ignore:
            return

        if isinstance(parameter, IECore.CompoundParameter):
            for k in parameter.keys():
                childKnobName = knobName + "_" + parameter[k].name
                if not parameterPath:
                    childParameterPath = k
                else:
                    childParameterPath = parameterPath + "." + k
                self.__checkParameterKnobs(parameter[k], node, childKnobName,
                                           childParameterPath, ignore)
        else:

            knob = node.knob(knobName)
            self.failUnless(knob is not None)

            if isinstance(knob, nuke.Enumeration_Knob):
                self.assertEqual(knob.value(),
                                 parameter.getCurrentPresetName())
            else:

                knobValue = None
                try:
                    knobValue = IECoreNuke.getKnobValue(knob)
                    if isinstance(parameter, IECore.V2dParameter):
                        # getKnobValue defaults to V2f
                        knobValue = imath.V2d(knobValue[0], knobValue[1])
                    elif isinstance(parameter, IECore.V3dParameter):
                        knobValue = imath.V3d(knobValue[0], knobValue[1],
                                              knobValue[2])
                except:
                    # not all knob types have accessors yet. some of the numeric
                    # knobs don't have them because nuke has bugs and returns those
                    # knobs as the wrong type. try to get the value another way.
                    knobValue = knob.getValue()

                self.assertEqual(parameter.getValue().value, knobValue)
コード例 #8
0
ファイル: Imath.py プロジェクト: yjcnbnbnb200/cortex
    def testConstructors(self):
        """Test V2f constructors"""
        v = imath.V2f()
        v = imath.V2f(1)
        self.assertEqual(v.x, 1)
        self.assertEqual(v.y, 1)
        v = imath.V2f(2, 3)
        self.assertEqual(v.x, 2)
        self.assertEqual(v.y, 3)

        self.assertEqual(imath.V2f(imath.V2i(1, 2)), imath.V2f(1, 2))
        self.assertEqual(imath.V2f(imath.V2f(1, 2)), imath.V2f(1, 2))
        self.assertEqual(imath.V2f(imath.V2d(1, 2)), imath.V2f(1, 2))

        self.assertEqual(imath.V2d(imath.V2i(1, 2)), imath.V2d(1, 2))
        self.assertEqual(imath.V2d(imath.V2f(1, 2)), imath.V2d(1, 2))
        self.assertEqual(imath.V2d(imath.V2d(1, 2)), imath.V2d(1, 2))

        self.assertEqual(imath.V2i(imath.V2i(1, 2)), imath.V2i(1, 2))
        self.assertEqual(imath.V2i(imath.V2f(1, 2)), imath.V2i(1, 2))
        self.assertEqual(imath.V2i(imath.V2d(1, 2)), imath.V2i(1, 2))

        self.assertEqual(imath.V3f(imath.V3i(1, 2, 3)), imath.V3f(1, 2, 3))
        self.assertEqual(imath.V3f(imath.V3f(1, 2, 3)), imath.V3f(1, 2, 3))
        self.assertEqual(imath.V3f(imath.V3d(1, 2, 3)), imath.V3f(1, 2, 3))

        self.assertEqual(imath.V3d(imath.V3i(1, 2, 3)), imath.V3d(1, 2, 3))
        self.assertEqual(imath.V3d(imath.V3f(1, 2, 3)), imath.V3d(1, 2, 3))
        self.assertEqual(imath.V3d(imath.V3d(1, 2, 3)), imath.V3d(1, 2, 3))

        self.assertEqual(imath.V3i(imath.V3i(1, 2, 3)), imath.V3i(1, 2, 3))
        self.assertEqual(imath.V3i(imath.V3f(1, 2, 3)), imath.V3i(1, 2, 3))
        self.assertEqual(imath.V3i(imath.V3d(1, 2, 3)), imath.V3i(1, 2, 3))

        v = imath.V2f([1, 1])
        self.assertEqual(v.x, 1)
        self.assertEqual(v.y, 1)

        self.assertRaises(RuntimeError, imath.V2f, [1])
        self.assertRaises(RuntimeError, imath.V2f, [1, 2, 3])
コード例 #9
0
ファイル: ReprTest.py プロジェクト: zeekindustries/cortex
    def test(self):

        for v in [
                imath.V2i(1),
                imath.V2f(1),
                imath.V2d(1.5),
                imath.V3i(1),
                imath.V3f(1),
                imath.V3d(1.5),
                imath.Box2i(),
                imath.Box2i(imath.V2i(1), imath.V2i(1)),
                imath.Box2f(imath.V2f(-1), imath.V2f(1)),
                imath.Box2f(),
                imath.Box3f(imath.V3f(-1), imath.V3f(1)),
                imath.Box3f(), "test", 10, 10.5
        ]:
            self.assertTrue(type(v) is type(eval(IECore.repr(v))))
            self.assertEqual(v, eval(IECore.repr(v)))
コード例 #10
0
	def testVectors( self ) :

		fileName = os.path.join( self.temporaryDirectory(), "attributes.scc" )
		scene = IECoreScene.SceneInterface.create( fileName, IECore.IndexedIO.Write )
		child = scene.createChild( "child" )
		for name, value in [
			( "v2f", IECore.V2fData( imath.V2f( 1, 2 ) ) ),
			( "v3f", IECore.V3fData( imath.V3f( 3, 4, 5 ) ) ),
			( "v2i", IECore.V2iData( imath.V2i( 6, 7 ) ) ),
			( "v3i", IECore.V3iData( imath.V3i( 8, 9, 10 ) ) ),
			( "v2d", IECore.V2dData( imath.V2d( 11, 12 ) ) ),
			( "v3d", IECore.V3dData( imath.V3d( 13, 14, 15 ) ) ),
		] :
			child.writeAttribute( name, value, 1 )
		del scene, child

		sceneReader = GafferScene.SceneReader()
		sceneReader["fileName"].setValue( fileName )

		childFilter = GafferScene.PathFilter()
		childFilter["paths"].setValue( IECore.StringVectorData( [ "/child" ] ) )

		visualiser = GafferScene.AttributeVisualiser()
		visualiser["in"].setInput( sceneReader["out"] )
		visualiser["filter"].setInput( childFilter["out"] )

		for name, value in [
			( "v2f", imath.Color3f( 1, 2, 0 ) ),
			( "v3f", imath.Color3f( 3, 4, 5 ) ),
			( "v2i", imath.Color3f( 6, 7, 0 ) ),
			( "v3i", imath.Color3f( 8, 9, 10 ) ),
			( "v2d", imath.Color3f( 11, 12, 0 ) ),
			( "v3d", imath.Color3f( 13, 14, 15 ) ),
		] :

			visualiser["attributeName"].setValue( name )
			self.assertEqual(
				visualiser["out"].attributes( "/child" )["gl:surface"].outputShader().parameters["Cs"].value,
				value,
			)
コード例 #11
0
    def testHash(self):

        # although the underlying data is identical, these objects
        # must not hash equal because they have different types.

        self.assertNotEqual(
            IECore.V3fData(imath.V3f(1, 2, 3)).hash(),
            IECore.Color3fData(imath.Color3f(1, 2, 3)).hash())
        self.assertNotEqual(
            IECore.IntVectorData([0, 0, 0]).hash(),
            IECore.UIntVectorData([0, 0, 0]).hash())

        a = IECore.V3fData(imath.V3f(1, 2, 3),
                           IECore.GeometricData.Interpretation.Point)
        b = a.copy()
        self.assertEqual(a.hash(), b.hash())
        b.setInterpretation(IECore.GeometricData.Interpretation.None_)
        self.assertNotEqual(a.hash(), b.hash())

        a = IECore.V2dVectorData([imath.V2d(1, 2)])
        b = a.copy()
        self.assertEqual(a.hash(), b.hash())
        b.setInterpretation(IECore.GeometricData.Interpretation.Point)
        self.assertNotEqual(a.hash(), b.hash())
コード例 #12
0
ファイル: KDTree.py プロジェクト: yjcnbnbnb200/cortex
    def randomBox(self):

        min = imath.V2d(random.random(), random.random())
        max = min + imath.V2d(random.random(), random.random())
        return imath.Box2d(min, max)
コード例 #13
0
 def rotate(self, dx, dy):
     for uid, cam in self.views.items():
         cam.rotate(imath.V2d(dx, dy))
     self._update()
コード例 #14
0
 def track(self, dx, dy):
     for cam in self.views.values():
         cam.track(imath.V2d(dx, dy))
     self._update()
コード例 #15
0
 def dolly(self, dx, dy):
     for cam in self.views.values():
         cam.dolly(imath.V2d(dx, dy))
     self._update()
コード例 #16
0
ファイル: gl.py プロジェクト: rheniser/bb_alembic
 def rotate(self, dx, dy):
     self.glcamera.rotate(imath.V2d(dx, dy))
コード例 #17
0
ファイル: gl.py プロジェクト: rheniser/bb_alembic
 def track(self, dx, dy):
     self.glcamera.track(imath.V2d(dx, dy))
コード例 #18
0
ファイル: gl.py プロジェクト: rheniser/bb_alembic
 def dolly(self, dx, dy):
     self.glcamera.dolly(imath.V2d(dx, dy))
コード例 #19
0
ファイル: USDSceneTest.py プロジェクト: SimonForgot/cortex
    def testPrimVarTypes(self):

        root = IECoreScene.SceneInterface.create(
            os.path.dirname(__file__) + "/data/primVars.usda",
            IECore.IndexedIO.OpenMode.Read)

        object = root.child("root").child("sphere").readObject(0.0)

        expected = {
            'test_Bool_Scalar_constant':
            IECore.BoolData(0),
            'test_Double2_Array_constant':
            IECore.V2dVectorData([
                imath.V2d(1.1, 1.2),
                imath.V2d(2.1, 2.2),
                imath.V2d(3.1, 3.2)
            ]),
            'test_Double2_Scalar_constant':
            IECore.V2dData(imath.V2d(0.1, 0.2)),
            'test_Double3_Array_constant':
            IECore.V3dVectorData([
                imath.V3d(1.1, 1.2, 1.3),
                imath.V3d(2.1, 2.2, 2.3),
                imath.V3d(3.1, 3.2, 3.3)
            ]),
            'test_Double3_Scalar_constant':
            IECore.V3dData(imath.V3d(0.1, 0.2, 0.3)),
            'test_Double_Array_constant':
            IECore.DoubleVectorData([1.2, 1.3, 1.4]),
            'test_Double_Scalar_constant':
            IECore.DoubleData(1.1),
            'test_Float2_Array_constant':
            IECore.V2fVectorData([
                imath.V2f(1.1, 1.2),
                imath.V2f(2.1, 2.2),
                imath.V2f(3.1, 3.2)
            ]),
            'test_Float2_Scalar_constant':
            IECore.V2fData(imath.V2f(0.1, 0.2)),
            'test_Float3_Array_constant':
            IECore.V3fVectorData([
                imath.V3f(1.1, 1.2, 1.3),
                imath.V3f(2.1, 2.2, 2.3),
                imath.V3f(3.1, 3.2, 3.3)
            ]),
            'test_Float3_Scalar_constant':
            IECore.V3fData(imath.V3f(0.1, 0.2, 0.3)),
            'test_Float_Array_constant':
            IECore.FloatVectorData([0.7, 0.8, 0.9]),
            'test_Float_Scalar_constant':
            IECore.FloatData(0.6),
            'test_Half_Array_constant':
            IECore.HalfVectorData([0.0999756, 0.199951, 0.300049]),
            'test_Half_Scalar_constant':
            IECore.HalfData(0.5),
            'test_Int2_Array_constant':
            IECore.V2iVectorData(
                [imath.V2i(3, 4),
                 imath.V2i(5, 6),
                 imath.V2i(7, 8)]),
            'test_Int2_Scalar_constant':
            IECore.V2iData(imath.V2i(1, 2)),
            'test_Int3_Array_constant':
            IECore.V3iVectorData(
                [imath.V3i(3, 4, 5),
                 imath.V3i(5, 6, 7),
                 imath.V3i(7, 8, 9)]),
            'test_Int3_Scalar_constant':
            IECore.V3iData(imath.V3i(1, 2, 3)),
            'test_Int64_Array_constant':
            IECore.Int64VectorData([
                9223372036854775805, 9223372036854775806, 9223372036854775807
            ]),
            'test_Int64_Scalar_constant':
            IECore.Int64Data(-9223372036854775808),
            'test_Int_Array_constant':
            IECore.IntVectorData([0, -1, -2]),
            'test_Int_Scalar_constant':
            IECore.IntData(-1),
            'test_String_Array_constant':
            IECore.StringVectorData(["is", "a", "test"]),
            'test_String_Scalar_constant':
            IECore.StringData('this'),
            'test_Token_Array_constant':
            IECore.InternedStringVectorData([
                IECore.InternedString("t-is"),
                IECore.InternedString("t-a"),
                IECore.InternedString("t-test")
            ]),
            'test_Token_Scalar_constant':
            IECore.InternedStringData(IECore.InternedString("t-this")),
            'test_UChar_Array_constant':
            IECore.UCharVectorData([0, 1, 2]),
            'test_UChar_Scalar_constant':
            IECore.UCharData(0),
            'test_UInt64_Array_constant':
            IECore.UInt64VectorData([
                18446744073709551613, 18446744073709551614,
                18446744073709551615
            ]),
            'test_UInt64_Scalar_constant':
            IECore.UInt64Data(18446744073709551615),
            'test_UInt_Array_constant':
            IECore.UIntVectorData([4294967293, 4294967294, 4294967295]),
            'test_UInt_Scalar_constant':
            IECore.UIntData(4294967295),
            #'test_color3d_Array_constant' : IECore.Color3dVectorData([IECore.Color3d(1.1, 1.2, 1.3), IECore.Color3d(2.1, 2.2, 2.3), IECore.Color3d(3.1, 3.2, 3.3)]),
            #'test_color3d_Scalar_constant' : IECore.Color3dData(IECore.Color3d(0.1, 0.2, 0.3)),
            'test_color3f_Array_constant':
            IECore.Color3fVectorData([
                imath.Color3f(1.1, 1.2, 1.3),
                imath.Color3f(2.1, 2.2, 2.3),
                imath.Color3f(3.1, 3.2, 3.3)
            ]),
            'test_color3f_Scalar_constant':
            IECore.Color3fData(imath.Color3f(0.1, 0.2, 0.3)),
            #'test_color4d_Array_constant' : IECore.Color4dVectorData([IECore.Color4d(1.1, 1.2, 1.3, 1.4), IECore.Color4d(2.1, 2.2, 2.3, 2.4), IECore.Color4d(3.1, 3.2, 3.3, 3.4)]),
            #'test_color4d_Scalar_constant' : IECore.Color4dData(IECore.Color4d(0.1, 0.2, 0.3, 0.4)),
            'test_color4f_Array_constant':
            IECore.Color4fVectorData([
                imath.Color4f(1.1, 1.2, 1.3, 1.4),
                imath.Color4f(2.1, 2.2, 2.3, 2.4),
                imath.Color4f(3.1, 3.2, 3.3, 3.4)
            ]),
            'test_color4f_Scalar_constant':
            IECore.Color4fData(imath.Color4f(0.1, 0.2, 0.3, 0.4)),
            'test_matrix3d_Array_constant':
            IECore.M33dVectorData([
                imath.M33d(0, 0, 0, 0, 1, 0, 0, 0, 0),
                imath.M33d(0, 0, 0, 0, 0, 0, 0, 0, 2),
                imath.M33d(0, 0, 4, 0, 0, 0, 0, 0, 0)
            ]),
            'test_matrix3d_Scalar_constant':
            IECore.M33dData(imath.M33d(0, 0, 0, 0, 0, 0, 0, 0, 0)),
            'test_matrix4d_Array_constant':
            IECore.M44dVectorData([
                imath.M44d(1, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0),
                imath.M44d(1, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
                imath.M44d(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0)
            ]),
            'test_matrix4d_Scalar_constant':
            IECore.M44dData(
                imath.M44d(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)),
            'test_normal3d_Array_constant':
            IECore.V3dVectorData([
                imath.V3d(1.1, 1.2, 1.3),
                imath.V3d(2.1, 2.2, 2.3),
                imath.V3d(3.1, 3.2, 3.3)
            ]),
            'test_normal3d_Scalar_constant':
            IECore.V3dData(imath.V3d(0.1, 0.2, 0.3)),
            'test_normal3f_Array_constant':
            IECore.V3fVectorData([
                imath.V3f(1.1, 1.2, 1.3),
                imath.V3f(2.1, 2.2, 2.3),
                imath.V3f(3.1, 3.2, 3.3)
            ]),
            'test_normal3f_Scalar_constant':
            IECore.V3fData(imath.V3f(0.1, 0.2, 0.3)),
            'test_point3d_Array_constant':
            IECore.V3dVectorData([
                imath.V3d(1.1, 1.2, 1.3),
                imath.V3d(2.1, 2.2, 2.3),
                imath.V3d(3.1, 3.2, 3.3)
            ]),
            'test_point3d_Scalar_constant':
            IECore.V3dData(imath.V3d(0.1, 0.2, 0.3)),
            'test_point3f_Array_constant':
            IECore.V3fVectorData([
                imath.V3f(1.1, 1.2, 1.3),
                imath.V3f(2.1, 2.2, 2.3),
                imath.V3f(3.1, 3.2, 3.3)
            ]),
            'test_point3f_Scalar_constant':
            IECore.V3fData(imath.V3f(0.1, 0.2, 0.3)),
            'test_quatd_Array_constant':
            IECore.QuatdVectorData([
                imath.Quatd(1, 0, 0, 0),
                imath.Quatd(0, 1, 0, 0),
                imath.Quatd(0, 0, 1, 0)
            ]),
            'test_quatd_Scalar_constant':
            IECore.QuatdData(imath.Quatd(0, 0, 0, 1)),
            'test_quatf_Array_constant':
            IECore.QuatfVectorData([
                imath.Quatf(1, 0, 0, 0),
                imath.Quatf(0, 1, 0, 0),
                imath.Quatf(0, 0, 1, 0)
            ]),
            'test_quatf_Scalar_constant':
            IECore.QuatfData(imath.Quatf(0, 0, 0, 1)),
            'test_vector3d_Array_constant':
            IECore.V3dVectorData([
                imath.V3d(1.1, 1.2, 1.3),
                imath.V3d(2.1, 2.2, 2.3),
                imath.V3d(3.1, 3.2, 3.3)
            ]),
            'test_vector3d_Scalar_constant':
            IECore.V3dData(imath.V3d(0.1, 0.2, 0.3)),
            'test_vector3f_Array_constant':
            IECore.V3fVectorData([
                imath.V3f(1.1, 1.2, 1.3),
                imath.V3f(2.1, 2.2, 2.3),
                imath.V3f(3.1, 3.2, 3.3)
            ]),
            'test_vector3f_Scalar_constant':
            IECore.V3fData(imath.V3f(0.1, 0.2, 0.3)),
        }

        for primVarName, primVarExpectedValue in expected.items():
            self.assertTrue(primVarName in object.keys())
            p = object[primVarName]
            self.assertEqual(p.data, primVarExpectedValue)
コード例 #20
0
    def __init__(self):

        IECore.Op.__init__(
            self, "test all parameter types.",
            IECore.IntParameter(
                name="result",
                description="one if everything is ok",
                defaultValue=0,
            ))

        self.parameters().addParameters([
            IECore.IntParameter(
                name="a",
                description=
                "An int which has a very long description to help test the help formatting. i wonder if there's anything more interesting i could write here.",
                defaultValue=1,
            ),
            IECore.FloatParameter(
                name="b",
                description=
                "A float which has a very long description to help test the help formatting. i wonder if there's anything more interesting i could write here.",
                defaultValue=2,
            ),
            IECore.DoubleParameter(
                name="c",
                description="A double",
                defaultValue=3,
            ),
            IECore.StringParameter(
                name="d",
                description="A string",
                defaultValue="ssss",
            ),
            IECore.IntVectorParameter(
                name="e",
                description="An array of ints",
                defaultValue=IECore.IntVectorData([4, -1, 2]),
            ),
            IECore.StringVectorParameter(
                name="f",
                description="An array of strings",
                defaultValue=IECore.StringVectorData(["one", "two", "three"]),
            ),
            IECore.V2fParameter(
                name="g",
                description="A v2f",
                defaultValue=IECore.V2fData(imath.V2f(1, 2)),
            ),
            IECore.V3fParameter(name="h",
                                description="a v3f",
                                defaultValue=IECore.V3fData(imath.V3f(1, 1,
                                                                      1)),
                                presets=(("x", imath.V3f(1, 0, 0)),
                                         ("y", imath.V3f(0, 1, 0)),
                                         ("z", imath.V3f(0, 0, 1)))),
            IECore.V2dParameter(
                name="i",
                description="a v2d",
                defaultValue=IECore.V2dData(imath.V2d(1, 1)),
            ),
            IECore.CompoundParameter(
                name="compound",
                description="a compound parameter",
                members=[
                    IECore.V3dParameter(name="j",
                                        description="a v3d",
                                        defaultValue=IECore.V3dData(
                                            imath.V3d(8, 16, 32)),
                                        presets=(("one", imath.V3d(1)),
                                                 ("two", imath.V3d(2)))),
                    IECore.M44fParameter(name="k",
                                         description="an m44f",
                                         defaultValue=IECore.M44fData(),
                                         presets=(("one", imath.M44f(1)),
                                                  ("two", imath.M44f(2)))),
                ]),
            IECore.Color3fParameter(
                name="l",
                description="a color3f",
                defaultValue=IECore.Color3fData(imath.Color3f(1, 0, 1)),
            ),
            IECore.Color4fParameter(
                name="m",
                description="a color4f",
                defaultValue=IECore.Color4fData(imath.Color4f(1, 0, 1, 0.5)),
            ),
            IECore.FileNameParameter(
                name="o",
                description="tif file please!",
                defaultValue="",
                extensions="tif",
                allowEmptyString=True,
            ),
            IECore.DirNameParameter(
                name="p",
                description="directory please!",
                defaultValue="",
                check=IECore.DirNameParameter.CheckType.MustExist,
                allowEmptyString=True,
            ),
            IECore.BoolParameter(
                name="q",
                description="blah",
                defaultValue=False,
            ),
            IECore.FileSequenceParameter(name="r",
                                         description="File sequence please!",
                                         defaultValue=""),
            IECore.Box2dParameter(name="s",
                                  description="boxboxbox",
                                  defaultValue=imath.Box2d(
                                      imath.V2d(-1), imath.V2d(1))),
            IECore.Box3fParameter(name="t",
                                  description="boxboxbox",
                                  defaultValue=imath.Box3f(
                                      imath.V3f(-1), imath.V3f(1))),
            IECore.V2iParameter(
                name="u",
                description="A v2i",
                defaultValue=IECore.V2iData(imath.V2i(2, 2)),
            ),
            IECore.V3iParameter(
                name="v",
                description="A v3i",
                defaultValue=IECore.V3iData(imath.V3i(5, 5, 5)),
            ),
            IECore.FrameListParameter(
                name="w",
                description="A FrameList",
                defaultValue="",
            ),
            IECore.TransformationMatrixfParameter(
                name="x",
                description="",
                defaultValue=IECore.TransformationMatrixf(),
            ),

            # We'd like to have one with a non-standard rotation order
            # here, but they're not currently supported in Maya.
            IECore.TransformationMatrixdParameter(
                name="y",
                description="",
                defaultValue=IECore.TransformationMatrixd(),
            ),
            IECore.ObjectParameter(name="p1",
                                   description="",
                                   defaultValue=IECore.CompoundObject(),
                                   types=[IECore.TypeId.CompoundObject]),
            IECore.LineSegment3fParameter(name="p2",
                                          description="",
                                          defaultValue=IECore.LineSegment3f(
                                              imath.V3f(1), imath.V3f(2))),
            IECore.LineSegment3dParameter(name="p3",
                                          description="",
                                          defaultValue=IECore.LineSegment3d(
                                              imath.V3d(1), imath.V3d(2))),
            IECore.DateTimeParameter(name="p4",
                                     description="",
                                     defaultValue=datetime.datetime.now()),
        ])
コード例 #21
0
    def makeBound(self):
        b1 = imath.V2d(-1, -1)
        b2 = imath.V2d(1, 1)
        bound = imath.Box2d(b1, b2)

        return bound