diff --git a/.travis.yml b/.travis.yml index 006f45c1fb..b6dd7ec403 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,23 +13,37 @@ addons: packages: - gcc-4.8 - g++-4.8 - - libboost1.55-all-dev - - libopenexr-dev - - libtbb-dev - - libfreetype6-dev cache: directories: - sconsCache + - pyIlmBaseInstall install: - if [ -n "$COMPILER_VERSION" ]; then export CXX="${CXX}-${COMPILER_VERSION}"; fi + - python ./config/travis/installDependencies.py + - export DEPENDENCIES=`pwd`/dependencies script: # Preload libSegFault when running tests, so we get stack # traces from any crashes. - export LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so - - scons -j 2 testCore testCorePython testScene CXX=$CXX CXXSTD=$CXXSTD DEBUG=$DEBUG ENV_VARS_TO_IMPORT="PATH TRAVIS LD_PRELOAD" RMAN_ROOT=$DELIGHT BOOST_LIB_SUFFIX="" BUILD_CACHEDIR=sconsCache + - export LD_LIBRARY_PATH=$DEPENDENCIES/lib + - scons -j 2 + testCore testCorePython testScene + CXX=$CXX + CXXSTD=$CXXSTD + BOOST_INCLUDE_PATH=$DEPENDENCIES/include + PYTHON=$DEPENDENCIES/bin/python + PYTHON_INCLUDE_PATH=$DEPENDENCIES/include/python2.7 + PYTHON_LINK_FLAGS=-lpython2.7 + LIBPATH=$DEPENDENCIES/lib + PYTHONPATH=$DEPENDENCIES/lib/python2.7/site-packages + DEBUG=$DEBUG + ENV_VARS_TO_IMPORT="PATH TRAVIS LD_PRELOAD LD_LIBRARY_PATH" + RMAN_ROOT=$DELIGHT + BOOST_LIB_SUFFIX="" + BUILD_CACHEDIR=sconsCache - cat test/IECore/results.txt before_cache: diff --git a/SConstruct b/SConstruct index 1b5ce03a9f..5831ec2208 100644 --- a/SConstruct +++ b/SConstruct @@ -249,6 +249,11 @@ o.Add( "/usr/lib", ) +o.Add( + "PYTHONPATH", + "A colon separated list of paths to search for python modules on.", + "", +) # Python options @@ -1171,7 +1176,7 @@ else: if env.has_key("BOOST_MINOR_VERSION") and env["BOOST_MINOR_VERSION"] >= 35 : testEnv.Append( LIBS=["boost_test_exec_monitor" + env["BOOST_LIB_SUFFIX"] ] ) -testEnv["ENV"]["PYTHONPATH"] = "./python" +testEnv["ENV"]["PYTHONPATH"] = "./python:" + testEnv.subst( "$PYTHONPATH" ) ########################################################################################### # Helper functions diff --git a/config/ie/options b/config/ie/options index ea1351b39f..a946cdf8ba 100644 --- a/config/ie/options +++ b/config/ie/options @@ -203,7 +203,9 @@ PYTHON_INCLUDE_PATH = pythonReg["location"] + "/" + compiler + "/" + compilerVer PYTHON_LINK_FLAGS = pythonReg["moduleLinkFlags"] if PYTHON_LINK_FLAGS=="" : - PYTHON_LINK_FLAGS = "-L" + pythonReg["location"] + "/" + compiler + "/" + compilerVersion + "/lib -lpython" + pythonVersion + PYTHON_LINK_FLAGS = "-L" + pythonReg["location"] + "/" + compiler + "/" + compilerVersion + "/lib -lpython" + pythonVersion + +PYTHONPATH = "/software/apps/openexr/" + openEXRVersion + "/" + platform + "/" + compiler + "/" + compilerVersion + "/python/" + pythonVersion + "/boost/" + boostVersion + "/lib64/python" + pythonVersion + "/site-packages" # get the installation locations right INSTALL_PREFIX = getOption( "INSTALL_PREFIX", os.path.expanduser( "~" ) ) diff --git a/config/travis/installDependencies.py b/config/travis/installDependencies.py new file mode 100644 index 0000000000..d24f3bc9c7 --- /dev/null +++ b/config/travis/installDependencies.py @@ -0,0 +1,72 @@ +########################################################################## +# +# Copyright (c) 2017, Image Engine Design Inc. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of Image Engine Design nor the names of any +# other contributors to this software may be used to endorse or +# promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +########################################################################## + +import os +import re +import sys +import glob +import shutil +import urllib + +# Download and unpack the prebuilt dependency package. We use the packages +# for Gaffer, since we know they also include everything needed by Cortex, +# and we don't want to maintain multiple packages (one is enough of a pain +# already). + +platform = "osx" if sys.platform == "darwin" else "linux" +downloadURL = "https://github.com/GafferHQ/dependencies/releases/download/0.42.0.0/gafferDependencies-0.42.0.0-" + platform + ".tar.gz" +dependenciesDir = "dependencies" + +sys.stderr.write( "Downloading dependencies \"%s\"" % downloadURL ) +tarFileName, headers = urllib.urlretrieve( downloadURL ) + +os.makedirs( dependenciesDir ) +os.system( "tar xf %s -C %s --strip-components=1" % ( tarFileName, dependenciesDir ) ) + +# Remove all Cortex related files from the package, so there is no conflict +# with the files generated by our build. + +for pattern in [ + "include/IECore*", + "lib/libIECore*", + "python/IECore*", + "arnold", + "renderMan", + "procedurals", +] : + for f in glob.glob( os.path.join( dependenciesDir, pattern ) ) : + if os.path.isdir( f ) : + shutil.rmtree( f ) + else : + os.remove( f ) diff --git a/contrib/IECoreAlembic/test/IECoreAlembic/AlembicInputTest.py b/contrib/IECoreAlembic/test/IECoreAlembic/AlembicInputTest.py index b31fbc1d57..b7273bceee 100644 --- a/contrib/IECoreAlembic/test/IECoreAlembic/AlembicInputTest.py +++ b/contrib/IECoreAlembic/test/IECoreAlembic/AlembicInputTest.py @@ -35,6 +35,7 @@ import os import math import unittest +import imath import IECore import IECoreScene @@ -102,24 +103,24 @@ def testMetaData( self ) : 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 ) ) ) + self.assertEqual( a.boundAtSample(), imath.Box3d( imath.V3d( -2 ), imath.V3d( 2 ) ) ) cs = a.child( "group1" ).child( "pCube1" ).child( "pCubeShape1" ) - self.assertEqual( cs.boundAtSample(), IECore.Box3d( IECore.V3d( -1 ), IECore.V3d( 1 ) ) ) + self.assertEqual( cs.boundAtSample(), imath.Box3d( imath.V3d( -1 ), imath.V3d( 1 ) ) ) def testTransform( self ) : a = IECoreAlembic.AlembicInput( os.path.dirname( __file__ ) + "/data/cube.abc" ) - self.assertEqual( a.transformAtSample(), IECore.M44d() ) + self.assertEqual( a.transformAtSample(), imath.M44d() ) g = a.child( "group1" ) - self.assertEqual( g.transformAtSample(), IECore.M44d.createScaled( IECore.V3d( 2 ) ) * IECore.M44d.createTranslated( IECore.V3d( 2, 0, 0 ) ) ) + self.assertEqual( g.transformAtSample(), imath.M44d().scale( imath.V3d( 2 ) ) * imath.M44d().translate( imath.V3d( 2, 0, 0 ) ) ) c = g.child( "pCube1" ) - self.assertEqual( c.transformAtSample(), IECore.M44d.createTranslated( IECore.V3d( -1, 0, 0 ) ) ) + self.assertEqual( c.transformAtSample(), imath.M44d().translate( imath.V3d( -1, 0, 0 ) ) ) cs = c.child( "pCubeShape1" ) - self.assertEqual( cs.transformAtSample(), IECore.M44d() ) + self.assertEqual( cs.transformAtSample(), imath.M44d() ) def testConvertSubD( self ) : @@ -149,10 +150,10 @@ def testConvertArbGeomParams( self ) : self.assertEqual( m["colorSet1"].expandedData(), IECore.Color4fVectorData( [ - IECore.Color4f( 1, 0, 0, 1 ), - IECore.Color4f( 0, 0, 0, 1 ), - IECore.Color4f( 0, 0, 1, 1 ), - IECore.Color4f( 0, 1, 0, 1 ), + imath.Color4f( 1, 0, 0, 1 ), + imath.Color4f( 0, 0, 0, 1 ), + imath.Color4f( 0, 0, 1, 1 ), + imath.Color4f( 0, 1, 0, 1 ), ] ) ) @@ -267,16 +268,16 @@ def testTransformAtSample( self ) : t = a.child( "pCube1" ) matrix = t.transformAtSample() - self.assertEqual( matrix, IECore.M44d() ) + self.assertEqual( matrix, imath.M44d() ) self.assertEqual( matrix, t.transformAtSample( 0 ) ) for i in range( 1, t.numSamples() ) : matrix2 = t.transformAtSample( i ) self.assertNotEqual( matrix, matrix2 ) - expectedMatrix = IECore.M44d.createTranslated( IECore.V3d( i / 9.0, 0, 0 ) ) + expectedMatrix = imath.M44d().translate( imath.V3d( i / 9.0, 0, 0 ) ) self.failUnless( matrix2.equalWithAbsError( expectedMatrix, 0.0000001 ) ) - self.assertEqual( t.transformAtSample( t.numSamples() - 1 ), IECore.M44d.createTranslated( IECore.V3d( 1, 0, 0 ) ) ) + self.assertEqual( t.transformAtSample( t.numSamples() - 1 ), imath.M44d().translate( imath.V3d( 1, 0, 0 ) ) ) def testConvertInterpolated( self ) : @@ -298,7 +299,7 @@ def testRotatingTransformAtSample( self ) : 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 ) ) + mi = imath.M44d().rotate( imath.V3d( IECore.degreesToRadians( 90 * i ), 0, 0 ) ) self.failUnless( ti.equalWithAbsError( mi, 0.0000000000001 ) ) def testInterpolatedTranslate( self ) : @@ -310,7 +311,7 @@ def testInterpolatedTranslate( self ) : frame = i / 2.0 + 1 time = frame / 24.0 matrix = t.transformAtTime( time ) - expectedMatrix = IECore.M44d.createTranslated( IECore.V3d( i / 18.0, 0, 0 ) ) + expectedMatrix = imath.M44d().translate( imath.V3d( i / 18.0, 0, 0 ) ) self.failUnless( matrix.equalWithAbsError( expectedMatrix, 0.0000001 ) ) def testInterpolatedRotate( self ) : @@ -322,7 +323,7 @@ def testInterpolatedRotate( self ) : 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 ) ) + expectedMatrix = imath.M44d().rotate( imath.V3d( IECore.degreesToRadians( 90 * i * 0.5 ), 0, 0 ) ) self.failUnless( matrix.equalWithAbsError( expectedMatrix, 0.0000001 ) ) def testHasStoredBound( self ) : @@ -343,16 +344,16 @@ def testHasStoredBound( self ) : def testBoundAtSample( self ) : a = IECoreAlembic.AlembicInput( os.path.dirname( __file__ ) + "/data/animatedCube.abc" ) - self.assertEqual( a.boundAtSample( 0 ), IECore.Box3d( IECore.V3d( -0.5 ), IECore.V3d( 0.5 ) ) ) - self.assertEqual( a.boundAtSample( a.numSamples()-1 ), IECore.Box3d( IECore.V3d( 0.5, -0.5, -0.5 ), IECore.V3d( 1.5, 2, 0.5 ) ) ) + self.assertEqual( a.boundAtSample( 0 ), imath.Box3d( imath.V3d( -0.5 ), imath.V3d( 0.5 ) ) ) + self.assertEqual( a.boundAtSample( a.numSamples()-1 ), imath.Box3d( imath.V3d( 0.5, -0.5, -0.5 ), imath.V3d( 1.5, 2, 0.5 ) ) ) t = a.child( "pCube1" ) self.assertRaises( Exception, t.boundAtSample, 0 ) self.assertRaises( Exception, t.boundAtSample, t.numSamples() - 1 ) m = t.child( "pCubeShape1" ) - self.assertEqual( m.boundAtSample( 0 ), IECore.Box3d( IECore.V3d( -0.5 ), IECore.V3d( 0.5 ) ) ) - self.assertEqual( m.boundAtSample( m.numSamples()-1 ), IECore.Box3d( IECore.V3d( -0.5, -0.5, -0.5 ), IECore.V3d( 0.5, 2, 0.5 ) ) ) + self.assertEqual( m.boundAtSample( 0 ), imath.Box3d( imath.V3d( -0.5 ), imath.V3d( 0.5 ) ) ) + self.assertEqual( m.boundAtSample( m.numSamples()-1 ), imath.Box3d( imath.V3d( -0.5, -0.5, -0.5 ), imath.V3d( 0.5, 2, 0.5 ) ) ) def testBoundAtTime( self ) : @@ -376,8 +377,8 @@ def lerp( a, b, x ) : def lerpBox( a, b, x ) : r = a.__class__() - r.min = lerp( a.min, b.min, x ) - r.max = lerp( a.max, b.max, x ) + r.setMin( lerp( a.min(), b.min(), x ) ) + r.setMax( lerp( a.max(), b.max(), x ) ) return r numSteps = 100 @@ -388,17 +389,17 @@ def lerpBox( a, b, x ) : aBound = a.boundAtTime( time ) expectedABound = lerpBox( aStartBound, aEndBound, lerpFactor ) - self.failUnless( aBound.min.equalWithAbsError( expectedABound.min, 0.000001 ) ) - self.failUnless( aBound.max.equalWithAbsError( expectedABound.max, 0.000001 ) ) + self.failUnless( aBound.min().equalWithAbsError( expectedABound.min(), 0.000001 ) ) + self.failUnless( aBound.max().equalWithAbsError( expectedABound.max(), 0.000001 ) ) mBound = m.boundAtTime( time ) expectedMBound = lerpBox( mStartBound, mEndBound, lerpFactor ) - self.failUnless( mBound.min.equalWithAbsError( expectedMBound.min, 0.000001 ) ) - self.failUnless( mBound.max.equalWithAbsError( expectedMBound.max, 0.000001 ) ) + self.failUnless( mBound.min().equalWithAbsError( expectedMBound.min(), 0.000001 ) ) + self.failUnless( mBound.max().equalWithAbsError( expectedMBound.max(), 0.000001 ) ) tBound = t.boundAtTime( time ) - self.failUnless( tBound.min.equalWithAbsError( expectedMBound.min, 0.000001 ) ) - self.failUnless( tBound.max.equalWithAbsError( expectedMBound.max, 0.000001 ) ) + self.failUnless( tBound.min().equalWithAbsError( expectedMBound.min(), 0.000001 ) ) + self.failUnless( tBound.max().equalWithAbsError( expectedMBound.max(), 0.000001 ) ) def testConvertNormals( self ) : @@ -446,7 +447,7 @@ def testLinearCurves( self ) : self.assertEqual( curves["P"].data, IECore.V3fVectorData( - [ IECore.V3f( 2, 0, 1 ), IECore.V3f( 2, 0, -1 ) ], + [ imath.V3f( 2, 0, 1 ), imath.V3f( 2, 0, -1 ) ], IECore.GeometricData.Interpretation.Point ) ) diff --git a/contrib/IECoreAlembic/test/IECoreAlembic/AlembicSceneTest.py b/contrib/IECoreAlembic/test/IECoreAlembic/AlembicSceneTest.py index 1903002b52..a3c2dd8dc8 100644 --- a/contrib/IECoreAlembic/test/IECoreAlembic/AlembicSceneTest.py +++ b/contrib/IECoreAlembic/test/IECoreAlembic/AlembicSceneTest.py @@ -35,6 +35,7 @@ import os import shutil import unittest +import imath import IECore import IECoreScene @@ -166,10 +167,10 @@ def testConvertMesh( self ) : def testBound( self ) : a = IECoreScene.SceneInterface.create( os.path.dirname( __file__ ) + "/data/cube.abc", IECore.IndexedIO.OpenMode.Read ) - self.assertEqual( a.readBoundAtSample( 0 ), IECore.Box3d( IECore.V3d( -2 ), IECore.V3d( 2 ) ) ) + self.assertEqual( a.readBoundAtSample( 0 ), imath.Box3d( imath.V3d( -2 ), imath.V3d( 2 ) ) ) cs = a.child( "group1" ).child( "pCube1" ) - self.assertEqual( cs.readBoundAtSample( 0 ), IECore.Box3d( IECore.V3d( -1 ), IECore.V3d( 1 ) ) ) + self.assertEqual( cs.readBoundAtSample( 0 ), imath.Box3d( imath.V3d( -1 ), imath.V3d( 1 ) ) ) def testTransform( self ) : @@ -180,17 +181,17 @@ def testTransform( self ) : self.assertEqual( c.numTransformSamples(), 10 ) matrix = c.readTransformAsMatrixAtSample( 0 ) - self.assertEqual( matrix, IECore.M44d() ) + self.assertEqual( matrix, imath.M44d() ) for i in range( 1, c.numTransformSamples() ) : matrix2 = c.readTransformAsMatrixAtSample( i ) self.assertNotEqual( matrix, matrix2 ) - expectedMatrix = IECore.M44d.createTranslated( IECore.V3d( i / 9.0, 0, 0 ) ) + expectedMatrix = imath.M44d().translate( imath.V3d( i / 9.0, 0, 0 ) ) self.failUnless( matrix2.equalWithAbsError( expectedMatrix, 0.0000001 ) ) self.assertEqual( c.readTransformAsMatrixAtSample( c.numTransformSamples() - 1 ), - IECore.M44d.createTranslated( IECore.V3d( 1, 0, 0 ) ) + imath.M44d().translate( imath.V3d( 1, 0, 0 ) ) ) def testConvertSubD( self ) : @@ -216,10 +217,10 @@ def testConvertArbGeomParams( self ) : self.assertEqual( m["colorSet1"].expandedData(), IECore.Color4fVectorData( [ - IECore.Color4f( 1, 0, 0, 1 ), - IECore.Color4f( 0, 0, 0, 1 ), - IECore.Color4f( 0, 0, 1, 1 ), - IECore.Color4f( 0, 1, 0, 1 ), + imath.Color4f( 1, 0, 0, 1 ), + imath.Color4f( 0, 0, 0, 1 ), + imath.Color4f( 0, 0, 1, 1 ), + imath.Color4f( 0, 1, 0, 1 ), ] ) ) @@ -336,7 +337,7 @@ def testRotatingTransformAtSample( self ) : t = a.child( "pCube1" ) for i in range( 0, 24 ) : ti = t.readTransformAsMatrixAtSample( i ) - mi = IECore.M44d.createRotated( IECore.V3d( IECore.degreesToRadians( 90 * i ), 0, 0 ) ) + mi = imath.M44d().rotate( imath.V3d( IECore.degreesToRadians( 90 * i ), 0, 0 ) ) self.failUnless( ti.equalWithAbsError( mi, 0.0000000000001 ) ) def testInterpolatedTranslate( self ) : @@ -349,7 +350,7 @@ def testInterpolatedTranslate( self ) : frame = i / 2.0 + 1 time = frame / 24.0 matrix = t.readTransformAsMatrix( time ) - expectedMatrix = IECore.M44d.createTranslated( IECore.V3d( i / 18.0, 0, 0 ) ) + expectedMatrix = imath.M44d().translate( imath.V3d( i / 18.0, 0, 0 ) ) self.failUnless( matrix.equalWithAbsError( expectedMatrix, 0.0000001 ) ) def testInterpolatedRotate( self ) : @@ -362,7 +363,7 @@ def testInterpolatedRotate( self ) : frame = i / 2.0 + 1 time = frame / 24.0 matrix = t.readTransformAsMatrix( time ) - expectedMatrix = IECore.M44d.createRotated( IECore.V3d( IECore.degreesToRadians( 90 * i * 0.5 ), 0, 0 ) ) + expectedMatrix = imath.M44d().rotate( imath.V3d( IECore.degreesToRadians( 90 * i * 0.5 ), 0, 0 ) ) self.failUnless( matrix.equalWithAbsError( expectedMatrix, 0.0000001 ) ) def testHasBound( self ) : @@ -381,12 +382,12 @@ def testHasBound( self ) : def testBoundAtSample( self ) : a = IECoreScene.SceneInterface.create( os.path.dirname( __file__ ) + "/data/animatedCube.abc", IECore.IndexedIO.OpenMode.Read ) - self.assertEqual( a.readBoundAtSample( 0 ), IECore.Box3d( IECore.V3d( -0.5 ), IECore.V3d( 0.5 ) ) ) - self.assertEqual( a.readBoundAtSample( a.numBoundSamples()-1 ), IECore.Box3d( IECore.V3d( 0.5, -0.5, -0.5 ), IECore.V3d( 1.5, 2, 0.5 ) ) ) + self.assertEqual( a.readBoundAtSample( 0 ), imath.Box3d( imath.V3d( -0.5 ), imath.V3d( 0.5 ) ) ) + self.assertEqual( a.readBoundAtSample( a.numBoundSamples()-1 ), imath.Box3d( imath.V3d( 0.5, -0.5, -0.5 ), imath.V3d( 1.5, 2, 0.5 ) ) ) t = a.child( "pCube1" ) - self.assertEqual( t.readBoundAtSample( 0 ), IECore.Box3d( IECore.V3d( -0.5 ), IECore.V3d( 0.5 ) ) ) - self.assertEqual( t.readBoundAtSample( t.numBoundSamples()-1 ), IECore.Box3d( IECore.V3d( -0.5, -0.5, -0.5 ), IECore.V3d( 0.5, 2, 0.5 ) ) ) + self.assertEqual( t.readBoundAtSample( 0 ), imath.Box3d( imath.V3d( -0.5 ), imath.V3d( 0.5 ) ) ) + self.assertEqual( t.readBoundAtSample( t.numBoundSamples()-1 ), imath.Box3d( imath.V3d( -0.5, -0.5, -0.5 ), imath.V3d( 0.5, 2, 0.5 ) ) ) def testBoundAtTime( self ) : @@ -409,8 +410,8 @@ def lerp( a, b, x ) : def lerpBox( a, b, x ) : r = a.__class__() - r.min = lerp( a.min, b.min, x ) - r.max = lerp( a.max, b.max, x ) + r.setMin( lerp( a.min(), b.min(), x ) ) + r.setMax( lerp( a.max(), b.max(), x ) ) return r numSteps = 100 @@ -421,13 +422,13 @@ def lerpBox( a, b, x ) : aBound = a.readBound( time ) expectedABound = lerpBox( aStartBound, aEndBound, lerpFactor ) - self.failUnless( aBound.min.equalWithAbsError( expectedABound.min, 0.000001 ) ) - self.failUnless( aBound.max.equalWithAbsError( expectedABound.max, 0.000001 ) ) + self.failUnless( aBound.min().equalWithAbsError( expectedABound.min(), 0.000001 ) ) + self.failUnless( aBound.max().equalWithAbsError( expectedABound.max(), 0.000001 ) ) mBound = m.readBound( time ) expectedMBound = lerpBox( mStartBound, mEndBound, lerpFactor ) - self.failUnless( mBound.min.equalWithAbsError( expectedMBound.min, 0.000001 ) ) - self.failUnless( mBound.max.equalWithAbsError( expectedMBound.max, 0.000001 ) ) + self.failUnless( mBound.min().equalWithAbsError( expectedMBound.min(), 0.000001 ) ) + self.failUnless( mBound.max().equalWithAbsError( expectedMBound.max(), 0.000001 ) ) def testConvertNormals( self ) : @@ -461,7 +462,7 @@ def testLinearCurves( self ) : self.assertEqual( curves["P"].data, IECore.V3fVectorData( - [ IECore.V3f( 2, 0, 1 ), IECore.V3f( 2, 0, -1 ) ], + [ imath.V3f( 2, 0, 1 ), imath.V3f( 2, 0, -1 ) ], IECore.GeometricData.Interpretation.Point ) ) @@ -572,7 +573,7 @@ def testWindingOrder( self ) : IECoreScene.MeshNormalsOp()( input = m, copyInput = False ) for n in m["N"].data : - self.assertTrue( n.equalWithAbsError( IECore.V3f( 0, 1, 0 ), 0.000001 ) ) + self.assertTrue( n.equalWithAbsError( imath.V3f( 0, 1, 0 ), 0.000001 ) ) def testWriteConstruction( self ) : @@ -605,7 +606,7 @@ def testWriteHierarchy( self ) : def testWriteStaticTransform( self ) : - matrix = IECore.M44d().translate( IECore.V3d( 1 ) ) + matrix = imath.M44d().translate( imath.V3d( 1 ) ) a = IECoreAlembic.AlembicScene( "/tmp/test.abc", IECore.IndexedIO.OpenMode.Write ) self.assertRaises( RuntimeError, a.writeTransform, IECore.M44dData( matrix ), 0 ) @@ -616,7 +617,7 @@ def testWriteStaticTransform( self ) : a = IECoreAlembic.AlembicScene( "/tmp/test.abc", IECore.IndexedIO.OpenMode.Read ) self.assertEqual( a.numTransformSamples(), 0 ) - self.assertEqual( a.readTransformAsMatrix( 0 ), IECore.M44d() ) + self.assertEqual( a.readTransformAsMatrix( 0 ), imath.M44d() ) b = a.child( "b" ) self.assertEqual( b.numTransformSamples(), 1 ) @@ -626,8 +627,8 @@ def testWriteStaticTransform( self ) : def testWriteAnimatedTransform( self ) : - matrix1 = IECore.M44d().translate( IECore.V3d( 1 ) ) - matrix2 = IECore.M44d().translate( IECore.V3d( 2 ) ) + matrix1 = imath.M44d().translate( imath.V3d( 1 ) ) + matrix2 = imath.M44d().translate( imath.V3d( 2 ) ) a = IECoreAlembic.AlembicScene( "/tmp/test.abc", IECore.IndexedIO.OpenMode.Write ) @@ -644,12 +645,12 @@ def testWriteAnimatedTransform( self ) : self.assertEqual( b.readTransformAsMatrixAtSample( 1 ), matrix2 ) self.assertEqual( b.readTransformAsMatrix( 0 ), matrix1 ) self.assertEqual( b.readTransformAsMatrix( 1 ), matrix2 ) - self.assertEqual( b.readTransformAsMatrix( 0.5 ), IECore.M44d().translate( IECore.V3d( 1.5 ) ) ) + self.assertEqual( b.readTransformAsMatrix( 0.5 ), imath.M44d().translate( imath.V3d( 1.5 ) ) ) def testWriteStaticBounds( self ) : - aBound = IECore.Box3d( IECore.V3d( -2 ), IECore.V3d( 2 ) ) - bBound = IECore.Box3d( IECore.V3d( -1 ), IECore.V3d( 1 ) ) + aBound = imath.Box3d( imath.V3d( -2 ), imath.V3d( 2 ) ) + bBound = imath.Box3d( imath.V3d( -1 ), imath.V3d( 1 ) ) a = IECoreAlembic.AlembicScene( "/tmp/test.abc", IECore.IndexedIO.OpenMode.Write ) a.writeBound( aBound, 0 ) @@ -671,11 +672,11 @@ def testWriteStaticBounds( self ) : def testWriteAnimatedBounds( self ) : - aBound1 = IECore.Box3d( IECore.V3d( -2 ), IECore.V3d( 2 ) ) - aBound2 = IECore.Box3d( IECore.V3d( 0 ), IECore.V3d( 4 ) ) + aBound1 = imath.Box3d( imath.V3d( -2 ), imath.V3d( 2 ) ) + aBound2 = imath.Box3d( imath.V3d( 0 ), imath.V3d( 4 ) ) - bBound1 = IECore.Box3d( IECore.V3d( -1 ), IECore.V3d( 1 ) ) - bBound2 = IECore.Box3d( IECore.V3d( 1 ), IECore.V3d( 3 ) ) + 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 ) @@ -729,11 +730,11 @@ def testWriteCurves( self ) : def testWriteAnimatedObject( self ) : - o1 = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ IECore.V3f( 0 ) ] ) ) + 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( [ IECore.V3f( 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 ] ) ) @@ -758,7 +759,7 @@ 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( [ IECore.V3f( 0 ) ] * numParticles ) ) + 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 ) ) @@ -782,11 +783,11 @@ def testWritePointsWithoutIDs( self ): def testWriteGeometricTypedData( self ) : - o = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ IECore.V3f( 0 ) ] ) ) + 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( [ IECore.V3f( 1 ) ], IECore.GeometricData.Interpretation.Vector ) ) - o["n3f"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f( 1 ) ], IECore.GeometricData.Interpretation.Normal ) ) - o["p3f"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f( 1 ) ], IECore.GeometricData.Interpretation.Point ) ) + 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" ) @@ -799,8 +800,8 @@ def testWriteGeometricTypedData( self ) : def testReacquireChildDuringWriting( self ) : - plane0 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) - plane1 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -2 ), IECore.V2f( 2 ) ) ) + 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 ) : @@ -823,7 +824,7 @@ def writeHierarchy( a, plane, time ) : def testCanWeRoundTripIndexedPrimvars( self ) : - plane = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + plane = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) data = IECore.FloatVectorData( [1] ) indices = IECore.IntVectorData( [0, 0, 0, 0] ) diff --git a/contrib/IECoreAppleseed/test/IECoreAppleseed/AttributeTest.py b/contrib/IECoreAppleseed/test/IECoreAppleseed/AttributeTest.py index 45e846feed..a31e6b8f2f 100644 --- a/contrib/IECoreAppleseed/test/IECoreAppleseed/AttributeTest.py +++ b/contrib/IECoreAppleseed/test/IECoreAppleseed/AttributeTest.py @@ -36,6 +36,7 @@ import unittest import appleseed +import imath import IECore import IECoreScene @@ -51,7 +52,7 @@ def testVisbility( self ) : r = IECoreAppleseed.Renderer() r.worldBegin() - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) r.attributeBegin() r.setAttribute( "name", IECore.StringData( "plane" ) ) @@ -74,7 +75,7 @@ def testShadingSamples( self ) : self._createDefaultShader( r ) - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) r.attributeBegin() r.setAttribute( "name", IECore.StringData( "plane1" ) ) @@ -110,8 +111,8 @@ def testAlphaMaps( self ) : r.attributeBegin() r.setAttribute( "name", IECore.StringData( "plane" ) ) r.setAttribute( "as:alpha_map", IECore.StringData( os.path.dirname( __file__ ) + "/data/textures/leaf.exr" ) ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) - IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -4 ), IECore.V2f( 4 ) ) ).render( r ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) + IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -4 ), imath.V2f( 4 ) ) ).render( r ) r.attributeEnd() del r @@ -137,7 +138,7 @@ def testMediumPriorities( self ) : self._createDefaultShader( r ) - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) r.attributeBegin() r.setAttribute( "name", IECore.StringData( "plane1" ) ) diff --git a/contrib/IECoreAppleseed/test/IECoreAppleseed/MeshTest.py b/contrib/IECoreAppleseed/test/IECoreAppleseed/MeshTest.py index 945b1c7a3e..42cd95f073 100644 --- a/contrib/IECoreAppleseed/test/IECoreAppleseed/MeshTest.py +++ b/contrib/IECoreAppleseed/test/IECoreAppleseed/MeshTest.py @@ -34,6 +34,7 @@ import os import unittest +import imath import IECore import IECoreScene @@ -48,7 +49,7 @@ def testUVs( self ) : r = IECoreAppleseed.Renderer() r.worldBegin() r.setAttribute( "name", IECore.StringData( "plane" ) ) - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -6 ), IECore.V2f( 6 ) ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -6 ), imath.V2f( 6 ) ) ) uvData = m["uv"].data m.render( r ) @@ -77,18 +78,18 @@ def testVertexUVs( self ) : mesh["P"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 1, 1, 0 ), - IECore.V3f( 0, 1, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 1, 1, 0 ), + imath.V3f( 0, 1, 0 ), ] ) ) mesh["uv"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V2fVectorData( [ - IECore.V2f( 0, 0 ), - IECore.V2f( 1, 1 ), - IECore.V2f( 0, 1 ) + imath.V2f( 0, 0 ), + imath.V2f( 1, 1 ), + imath.V2f( 0, 1 ) ] ), ) @@ -122,20 +123,20 @@ def testFaceVaryingIndexedUVs( self ) : mesh["P"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 1, 0, 0 ), - IECore.V3f( 1, 1, 0 ), - IECore.V3f( 0, 1, 0 ) + imath.V3f( 0, 0, 0 ), + imath.V3f( 1, 0, 0 ), + imath.V3f( 1, 1, 0 ), + imath.V3f( 0, 1, 0 ) ] ) ) mesh["uv"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, IECore.V2fVectorData( [ - IECore.V2f( 0, 0 ), - IECore.V2f( 1, 0 ), - IECore.V2f( 1, 1 ), - IECore.V2f( 0, 1 ) + imath.V2f( 0, 0 ), + imath.V2f( 1, 0 ), + imath.V2f( 1, 1 ), + imath.V2f( 0, 1 ) ] ), mesh.vertexIds ) diff --git a/contrib/IECoreAppleseed/test/IECoreAppleseed/MotionTest.py b/contrib/IECoreAppleseed/test/IECoreAppleseed/MotionTest.py index 535400a71c..3ef4aa203c 100644 --- a/contrib/IECoreAppleseed/test/IECoreAppleseed/MotionTest.py +++ b/contrib/IECoreAppleseed/test/IECoreAppleseed/MotionTest.py @@ -35,6 +35,7 @@ import os import appleseed +import imath import IECore import IECoreScene @@ -50,9 +51,9 @@ def testCameraMotionBlur( self ) : with IECoreScene.MotionBlock( r, [ 0.25, 0.5, 0.75 ] ) : - r.setTransform( IECore.M44f.createTranslated( IECore.V3f( 0 ) ) ) - r.setTransform( IECore.M44f.createTranslated( IECore.V3f( 1 ) ) ) - r.setTransform( IECore.M44f.createTranslated( IECore.V3f( 2 ) ) ) + r.setTransform( imath.M44f().translate( imath.V3f( 0 ) ) ) + r.setTransform( imath.M44f().translate( imath.V3f( 1 ) ) ) + r.setTransform( imath.M44f().translate( imath.V3f( 2 ) ) ) r.camera( "camera", {} ) @@ -76,11 +77,11 @@ def testTransformationMotionBlur( self ) : with IECoreScene.MotionBlock( r, [ 0.25, 0.5, 0.75 ] ) : - r.setTransform( IECore.M44f.createTranslated( IECore.V3f( 0 ) ) ) - r.setTransform( IECore.M44f.createTranslated( IECore.V3f( 1 ) ) ) - r.setTransform( IECore.M44f.createTranslated( IECore.V3f( 2 ) ) ) + r.setTransform( imath.M44f().translate( imath.V3f( 0 ) ) ) + r.setTransform( imath.M44f().translate( imath.V3f( 1 ) ) ) + r.setTransform( imath.M44f().translate( imath.V3f( 2 ) ) ) - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) m.render( r ) r.attributeEnd() @@ -97,14 +98,14 @@ def testTransformationMotionBlur( self ) : def testDeformationMotionBlurPow2NumSamples( self ) : r = IECoreAppleseed.Renderer() - r.camera( "camera", { "shutter" : IECore.V2fData( IECore.V2f( 0.25, 0.75 ) ) } ) + r.camera( "camera", { "shutter" : IECore.V2fData( imath.V2f( 0.25, 0.75 ) ) } ) r.worldBegin() self._createDefaultShader( r ) - m1 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) - m2 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -2 ), IECore.V2f( 2 ) ) ) + m1 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) + m2 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -2 ), imath.V2f( 2 ) ) ) r.attributeBegin() r.setAttribute( "name", "object" ) @@ -126,15 +127,15 @@ def testDeformationMotionBlurPow2NumSamples( self ) : def testDeformationMotionBlurNonPow2NumSamples( self ) : r = IECoreAppleseed.Renderer() - r.camera( "camera", { "shutter" : IECore.V2fData( IECore.V2f( 0.25, 0.75 ) ) } ) + r.camera( "camera", { "shutter" : IECore.V2fData( imath.V2f( 0.25, 0.75 ) ) } ) r.worldBegin() self._createDefaultShader( r ) - m1 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) - m2 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -2 ), IECore.V2f( 2 ) ) ) - m3 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -3 ), IECore.V2f( 3 ) ) ) + m1 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) + m2 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -2 ), imath.V2f( 2 ) ) ) + m3 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -3 ), imath.V2f( 3 ) ) ) r.attributeBegin() r.setAttribute( "name", "object" ) diff --git a/contrib/IECoreAppleseed/test/IECoreAppleseed/PrimitiveConverterTest.py b/contrib/IECoreAppleseed/test/IECoreAppleseed/PrimitiveConverterTest.py index 57d34690d1..5fe4f9de7d 100644 --- a/contrib/IECoreAppleseed/test/IECoreAppleseed/PrimitiveConverterTest.py +++ b/contrib/IECoreAppleseed/test/IECoreAppleseed/PrimitiveConverterTest.py @@ -35,6 +35,7 @@ import os import appleseed +import imath import IECore import IECoreScene @@ -51,9 +52,9 @@ def testSingleMaterial( self ) : self._createDefaultShader( r ) - m1 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m1 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) m2 = m1.copy() - m3 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -2 ), IECore.V2f( 2 ) ) ) + m3 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -2 ), imath.V2f( 2 ) ) ) m1.render( r ) m2.render( r ) @@ -68,7 +69,7 @@ def testMultipleMaterialsNoInstancing( self ) : r = IECoreAppleseed.Renderer() r.worldBegin() - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) self._createDefaultShader( r ) m.render( r ) @@ -87,7 +88,7 @@ def testAttributesNoInstancing( self ) : self._createDefaultShader( r ) - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) m.render( r ) r.attributeBegin() @@ -116,9 +117,9 @@ def testNoAutoInstancing( self ) : self._createDefaultShader( r ) - m1 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m1 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) m2 = m1.copy() - m3 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -2 ), IECore.V2f( 2 ) ) ) + m3 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -2 ), imath.V2f( 2 ) ) ) m1.render( r ) m2.render( r ) diff --git a/contrib/IECoreAppleseed/test/IECoreAppleseed/RendererTest.py b/contrib/IECoreAppleseed/test/IECoreAppleseed/RendererTest.py index 0ba8ec1703..bfd7521f9d 100644 --- a/contrib/IECoreAppleseed/test/IECoreAppleseed/RendererTest.py +++ b/contrib/IECoreAppleseed/test/IECoreAppleseed/RendererTest.py @@ -34,6 +34,7 @@ import os import shutil +import imath import IECore import IECoreScene @@ -64,7 +65,7 @@ def testAppleseedOutput( self ) : with IECoreScene.WorldBlock( r ) : self._createDefaultShader( r ) - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) m.render( r ) self.failUnless( os.path.exists( self.__appleseedFileName ) ) diff --git a/contrib/IECoreArnold/test/IECoreArnold/AutomaticInstancingTest.py b/contrib/IECoreArnold/test/IECoreArnold/AutomaticInstancingTest.py index b8e9f84b2e..37539177d6 100644 --- a/contrib/IECoreArnold/test/IECoreArnold/AutomaticInstancingTest.py +++ b/contrib/IECoreArnold/test/IECoreArnold/AutomaticInstancingTest.py @@ -38,6 +38,7 @@ import unittest import arnold +import imath import IECore import IECoreScene @@ -63,7 +64,7 @@ def testOnByDefault( self ) : with IECoreScene.WorldBlock( r ) : - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) m.render( r ) m.render( r ) @@ -85,7 +86,7 @@ def testEnabling( self ) : r.setAttribute( "ai:automaticInstancing", IECore.BoolData( True ) ) - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) m.render( r ) m.render( r ) @@ -107,7 +108,7 @@ def testDisabling( self ) : r.setAttribute( "ai:automaticInstancing", IECore.BoolData( False ) ) - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) m.render( r ) m.render( r ) @@ -128,11 +129,11 @@ def __init__( self ) : def bound( self ) : - return IECore.Box3f( IECore.V3f( -10, -10, -0.01 ), IECore.V3f( 10, 10, 0.01 ) ) + return imath.Box3f( imath.V3f( -10, -10, -0.01 ), imath.V3f( 10, 10, 0.01 ) ) def render( self, renderer ) : - IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -10 ), IECore.V2f( 10 ) ) ).render( renderer ) + IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -10 ), imath.V2f( 10 ) ) ).render( renderer ) def hash( self ): @@ -152,7 +153,7 @@ def arnoldMessageCallback( logMask, severity, msg, tabs ) : with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) for i in range( 0, 100 ) : r.procedural( PlaneProcedural() ) diff --git a/contrib/IECoreArnold/test/IECoreArnold/CameraAlgoTest.py b/contrib/IECoreArnold/test/IECoreArnold/CameraAlgoTest.py index 9be96334f1..8a772ac32f 100644 --- a/contrib/IECoreArnold/test/IECoreArnold/CameraAlgoTest.py +++ b/contrib/IECoreArnold/test/IECoreArnold/CameraAlgoTest.py @@ -35,6 +35,7 @@ import unittest import arnold +import imath import IECore import IECoreScene @@ -51,8 +52,8 @@ def testConvertPerspective( self ) : parameters = { "projection" : "perspective", "projection:fov" : 45.0, - "resolution" : IECore.V2i( 512 ), - "screenWindow" : IECore.Box2f( IECore.V2f( -1, -0.5 ), IECore.V2f( 1, 0.5 ) ) + "resolution" : imath.V2i( 512 ), + "screenWindow" : imath.Box2f( imath.V2f( -1, -0.5 ), imath.V2f( 1, 0.5 ) ) } ), "testCamera" diff --git a/contrib/IECoreArnold/test/IECoreArnold/CurvesTest.py b/contrib/IECoreArnold/test/IECoreArnold/CurvesTest.py index a78cb0b474..af812f69ba 100644 --- a/contrib/IECoreArnold/test/IECoreArnold/CurvesTest.py +++ b/contrib/IECoreArnold/test/IECoreArnold/CurvesTest.py @@ -36,6 +36,7 @@ import unittest import arnold +import imath import IECore import IECoreScene @@ -50,12 +51,12 @@ def testMotion( self ) : c1["P"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, - IECore.V3fVectorData( [ IECore.V3f( 1 ) ] * 4 ), + IECore.V3fVectorData( [ imath.V3f( 1 ) ] * 4 ), ) c2["P"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, - IECore.V3fVectorData( [ IECore.V3f( 2 ) ] * 4 ), + IECore.V3fVectorData( [ imath.V3f( 2 ) ] * 4 ), ) with IECoreArnold.UniverseBlock( writable = True ) : @@ -79,7 +80,7 @@ def testNPrimitiveVariable( self ) : c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 4 ] ), IECore.CubicBasisf.catmullRom() ) c["P"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, - IECore.V3fVectorData( [ IECore.V3f( x, 0, 0 ) for x in range( 0, 4 ) ] ) + IECore.V3fVectorData( [ imath.V3f( x, 0, 0 ) for x in range( 0, 4 ) ] ) ) with IECoreArnold.UniverseBlock( writable = True ) : @@ -94,7 +95,7 @@ def testNPrimitiveVariable( self ) : c["N"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, - IECore.V3fVectorData( [ IECore.V3f( 0, math.sin( x ), math.cos( x ) ) for x in range( 0, 4 ) ] ) + IECore.V3fVectorData( [ imath.V3f( 0, math.sin( x ), math.cos( x ) ) for x in range( 0, 4 ) ] ) ) n = IECoreArnold.NodeAlgo.convert( c, "testCurve" ) @@ -110,7 +111,7 @@ def testNPrimitiveVariable( self ) : c2 = c.copy() c2["N"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, - IECore.V3fVectorData( [ IECore.V3f( 0, math.sin( x + 0.2 ), math.cos( x + 0.2 ) ) for x in range( 0, 4 ) ] ) + IECore.V3fVectorData( [ imath.V3f( 0, math.sin( x + 0.2 ), math.cos( x + 0.2 ) ) for x in range( 0, 4 ) ] ) ) n = IECoreArnold.NodeAlgo.convert( [ c, c2 ], 0.0, 1.0, "testCurve" ) diff --git a/contrib/IECoreArnold/test/IECoreArnold/InstancingConverterTest.py b/contrib/IECoreArnold/test/IECoreArnold/InstancingConverterTest.py index e75039d09f..ebad25c052 100644 --- a/contrib/IECoreArnold/test/IECoreArnold/InstancingConverterTest.py +++ b/contrib/IECoreArnold/test/IECoreArnold/InstancingConverterTest.py @@ -40,6 +40,7 @@ import random import arnold +import imath import IECore import IECoreScene @@ -53,9 +54,9 @@ def test( self ) : c = IECoreArnold.InstancingConverter() - m1 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m1 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) m2 = m1.copy() - m3 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -2 ), IECore.V2f( 2 ) ) ) + m3 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -2 ), imath.V2f( 2 ) ) ) am1 = c.convert( m1, "testMesh" ) self.assertEqual( arnold.AiNodeEntryGetName( arnold.AiNodeGetNodeEntry( am1 ) ), "polymesh" ) @@ -75,7 +76,7 @@ def testThreading( self ) : meshes = [] for i in range( 0, 1000 ) : - meshes.append( IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -i ), IECore.V2f( i ) ) ) ) + meshes.append( IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -i ), imath.V2f( i ) ) ) ) def f( nodeList ) : for i in range( 0, 10000 ) : @@ -123,8 +124,8 @@ def testUserSuppliedHash( self ) : c = IECoreArnold.InstancingConverter() - m1 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) - m2 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -2 ), IECore.V2f( 2 ) ) ) + m1 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) + m2 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -2 ), imath.V2f( 2 ) ) ) h1 = IECore.MurmurHash() h2 = IECore.MurmurHash() @@ -150,8 +151,8 @@ def testMotion( self ) : c = IECoreArnold.InstancingConverter() - m1 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) - m2 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -2 ), IECore.V2f( 2 ) ) ) + m1 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) + m2 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -2 ), imath.V2f( 2 ) ) ) n1 = c.convert( [ m1, m2 ], -0.25, 0.25, "testMesh" ) self.assertEqual( arnold.AiNodeEntryGetName( arnold.AiNodeGetNodeEntry( n1 ) ), "polymesh" ) diff --git a/contrib/IECoreArnold/test/IECoreArnold/MeshTest.py b/contrib/IECoreArnold/test/IECoreArnold/MeshTest.py index bab1cb96c3..bf7234b92a 100644 --- a/contrib/IECoreArnold/test/IECoreArnold/MeshTest.py +++ b/contrib/IECoreArnold/test/IECoreArnold/MeshTest.py @@ -37,6 +37,7 @@ import unittest import arnold +import imath import IECore import IECoreScene @@ -47,7 +48,7 @@ class MeshTest( unittest.TestCase ) : def testUVs( self ) : - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) uvData = m["uv"].data with IECoreArnold.UniverseBlock( writable = True ) : @@ -67,7 +68,7 @@ def testUVs( self ) : def testIndexedUVs( self ) : - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) m["uv"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, m["uv"].data, IECore.IntVectorData( [ 0, 3, 1, 2 ] ) ) uvData = m["uv"].data uvIds = m["uv"].indices @@ -92,7 +93,7 @@ def testIndexedUVs( self ) : def testAdditionalUVs( self ) : - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) m["myMap"] = m["uv"] uvData = m["uv"].data @@ -116,12 +117,12 @@ def testNormals( self ) : r = IECoreArnold.Renderer() r.display( "test", "ieDisplay", "rgba", { "driverType" : "ImageDisplayDriver", "handle" : "testHandle" } ) with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) r.shader( "surface", "utility", { "shade_mode" : "flat", "color_mode" : "n" } ) - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -0.9 ), IECore.V2f( 0.9 ) ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -0.9 ), imath.V2f( 0.9 ) ) ) m["N"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, - IECore.V3fVectorData( [ IECore.V3f( 1, 0, 0 ), IECore.V3f( 1, 0, 0 ), IECore.V3f( 1, 0, 0 ), IECore.V3f( 1, 0, 0 ) ] ) + IECore.V3fVectorData( [ imath.V3f( 1, 0, 0 ), imath.V3f( 1, 0, 0 ), imath.V3f( 1, 0, 0 ), imath.V3f( 1, 0, 0 ) ] ) ) m.render( r ) @@ -131,7 +132,7 @@ def testNormals( self ) : # the utility shader encodes the normals in the range 0-1 rather than -1-1, # which is why we're checking G and B against .5 rather than 0. - dimensions = image.dataWindow.size() + IECore.V2i( 1 ) + dimensions = image.dataWindow.size() + imath.V2i( 1 ) index = dimensions.x * int(dimensions.y * 0.5) + int(dimensions.x * 0.5) self.assertAlmostEqual( image["R"][index], 1, 4 ) self.assertAlmostEqual( image["G"][index], 0.5, 4 ) @@ -139,14 +140,14 @@ def testNormals( self ) : def testVertexPrimitiveVariables( self ) : - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) m["myPrimVar"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.FloatVectorData( [ 0, 1, 2, 3 ] ) ) m["myV3fPrimVar"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, - IECore.V3fVectorData( [ IECore.V3f( v ) for v in range( 0, 4 ) ] ) + IECore.V3fVectorData( [ imath.V3f( v ) for v in range( 0, 4 ) ] ) ) with IECoreArnold.UniverseBlock( writable = True ) : @@ -162,8 +163,8 @@ def testVertexPrimitiveVariables( self ) : def testFaceVaryingPrimitiveVariables( self ) : m = IECoreScene.MeshPrimitive.createPlane( - IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ), - IECore.V2i( 2 ), + imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ), + imath.V2i( 2 ), ) self.assertEqual( m.variableSize( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying ), 16 ) @@ -185,12 +186,12 @@ def testFaceVaryingPrimitiveVariables( self ) : def testMotion( self ) : - m1 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m1 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) IECoreScene.MeshNormalsOp()( input = m1, copyInput = False ) m2 = m1.copy() - m2["P"].data[0] -= IECore.V3f( 0, 0, 1 ) - m2["P"].data[1] -= IECore.V3f( 0, 0, 1 ) + m2["P"].data[0] -= imath.V3f( 0, 0, 1 ) + m2["P"].data[1] -= imath.V3f( 0, 0, 1 ) IECoreScene.MeshNormalsOp()( input = m2, copyInput = False ) with IECoreArnold.UniverseBlock( writable = True ) : @@ -207,22 +208,22 @@ def testMotion( self ) : for i in range( 0, 4 ) : p = arnold.AiArrayGetVec( vList, i ) - self.assertEqual( IECore.V3f( p.x, p.y, p.z ), m1["P"].data[i] ) + self.assertEqual( imath.V3f( p.x, p.y, p.z ), m1["P"].data[i] ) n = arnold.AiArrayGetVec( nList, i ) - self.assertEqual( IECore.V3f( n.x, n.y, n.z ), m1["N"].data[i] ) + self.assertEqual( imath.V3f( n.x, n.y, n.z ), m1["N"].data[i] ) for i in range( 4, 8 ) : p = arnold.AiArrayGetVec( vList, i ) - self.assertEqual( IECore.V3f( p.x, p.y, p.z ), m2["P"].data[i-4] ) + self.assertEqual( imath.V3f( p.x, p.y, p.z ), m2["P"].data[i-4] ) n = arnold.AiArrayGetVec( nList, i ) - self.assertEqual( IECore.V3f( n.x, n.y, n.z ), m2["N"].data[i-4] ) + self.assertEqual( imath.V3f( n.x, n.y, n.z ), m2["N"].data[i-4] ) self.assertEqual( arnold.AiNodeGetFlt( node, "motion_start" ), -0.25 ) self.assertEqual( arnold.AiNodeGetFlt( node, "motion_end" ), 0.25 ) def testClashingPrimitiveVariables( self ) : # make sure that names of arnold built-in's can't be used as names for primitive variables - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) m["name"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, @@ -242,7 +243,7 @@ def testClashingPrimitiveVariables( self ) : def testPointTypePrimitiveVariables( self ) : # make sure that we can add prim vars of both vector and point type, and differentiate between the two. - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) points = IECore.V3fVectorData( [] ) IECore.setGeometricInterpretation( points, IECore.GeometricData.Interpretation.Point ) @@ -262,7 +263,7 @@ def testPointTypePrimitiveVariables( self ) : def testBoolVectorPrimitiveVariables( self ) : - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) m["myBoolPrimVar"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.BoolVectorData( [ True, False, True, False ] ) diff --git a/contrib/IECoreArnold/test/IECoreArnold/ParameterAlgoTest.py b/contrib/IECoreArnold/test/IECoreArnold/ParameterAlgoTest.py index bbf7742f91..78b0cf5516 100644 --- a/contrib/IECoreArnold/test/IECoreArnold/ParameterAlgoTest.py +++ b/contrib/IECoreArnold/test/IECoreArnold/ParameterAlgoTest.py @@ -35,6 +35,7 @@ import unittest import arnold +import imath import IECore import IECoreArnold @@ -112,7 +113,7 @@ def testDoubleData( self ) : IECoreArnold.ParameterAlgo.setParameter( n, "customFloat", IECore.DoubleData( 0.25 ) ) self.assertEqual( arnold.AiNodeGetFlt( n, "customFloat" ), 0.25 ) - IECoreArnold.ParameterAlgo.setParameter( n, "customMatrix", IECore.M44dData( IECore.M44d( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ) ) ) + IECoreArnold.ParameterAlgo.setParameter( n, "customMatrix", IECore.M44dData( imath.M44d( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ) ) ) m = arnold.AiNodeGetMatrix( n, "customMatrix" ) self.assertEqual( [ list( i ) for i in m.data ], @@ -137,10 +138,10 @@ def testVectorIntData( self ) : n = arnold.AiNode( "standard_surface" ) - IECoreArnold.ParameterAlgo.setParameter( n, "customV2i", IECore.V2iData( IECore.V2i( 3, 4 ) ) ) + IECoreArnold.ParameterAlgo.setParameter( n, "customV2i", IECore.V2iData( imath.V2i( 3, 4 ) ) ) self.assertEqual( arnold.AiNodeGetVec2( n, "customV2i" ), arnold.AtVector2( 3, 4 ) ) - IECoreArnold.ParameterAlgo.setParameter( n, "customV3i", IECore.V3iData( IECore.V3i( 3, 4, 5 ) ) ) + IECoreArnold.ParameterAlgo.setParameter( n, "customV3i", IECore.V3iData( imath.V3i( 3, 4, 5 ) ) ) self.assertEqual( arnold.AiNodeGetVec( n, "customV3i" ), arnold.AtVector( 3, 4, 5 ) ) diff --git a/contrib/IECoreArnold/test/IECoreArnold/PointsTest.py b/contrib/IECoreArnold/test/IECoreArnold/PointsTest.py index dc188ae64b..f09c269bed 100644 --- a/contrib/IECoreArnold/test/IECoreArnold/PointsTest.py +++ b/contrib/IECoreArnold/test/IECoreArnold/PointsTest.py @@ -37,6 +37,7 @@ import random import arnold +import imath import IECore import IECoreScene @@ -49,7 +50,7 @@ def testConverterResultType( self ) : with IECoreArnold.UniverseBlock( writable = True ) : - p = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ IECore.V3f( i ) for i in range( 0, 10 ) ] ) ) + p = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ imath.V3f( i ) for i in range( 0, 10 ) ] ) ) n = IECoreArnold.NodeAlgo.convert( p, "testPoints" ) self.failUnless( type( n ) is type( arnold.AiNode( "points" ) ) ) @@ -58,7 +59,7 @@ def testMode( self ) : with IECoreArnold.UniverseBlock( writable = True ) : - p = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ IECore.V3f( i ) for i in range( 0, 10 ) ] ) ) + p = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ imath.V3f( i ) for i in range( 0, 10 ) ] ) ) n = IECoreArnold.NodeAlgo.convert( p, "testPoints" ) self.assertEqual( arnold.AiNodeGetStr( n, "mode" ), "disk" ) @@ -85,7 +86,7 @@ def testDiskRendering( self ) : p = IECore.V3fVectorData( numPoints ) random.seed( 0 ) for i in range( 0, numPoints ) : - p[i] = IECore.V3f( random.random() * 4, random.random() * 4, random.random() * 4 ) + p[i] = imath.V3f( random.random() * 4, random.random() * 4, random.random() * 4 ) p = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, p ) r = IECoreArnold.Renderer() @@ -93,16 +94,16 @@ def testDiskRendering( self ) : r.camera( "main", { "projection" : IECore.StringData( "orthographic" ), - "resolution" : IECore.V2iData( IECore.V2i( 256 ) ), - "clippingPlanes" : IECore.V2fData( IECore.V2f( 1, 1000 ) ), - "screenWindow" : IECore.Box2fData( IECore.Box2f( IECore.V2f( -3 ), IECore.V2f( 3 ) ) ) + "resolution" : IECore.V2iData( imath.V2i( 256 ) ), + "clippingPlanes" : IECore.V2fData( imath.V2f( 1, 1000 ) ), + "screenWindow" : IECore.Box2fData( imath.Box2f( imath.V2f( -3 ), imath.V2f( 3 ) ) ) } ) r.display( "test", "ieDisplay", "rgba", { "driverType" : "ImageDisplayDriver", "handle" : "testHandle" } ) with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( -2, -2, -10 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( -2, -2, -10 ) ) ) r.points( numPoints, { "P" : p } ) image = IECoreImage.ImageDisplayDriver.removeStoredImage( "testHandle" ) @@ -176,13 +177,13 @@ def testBooleanPrimitiveVariable( self ) : def testMotion( self ) : - p1 = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ IECore.V3f( 10 ) ] * 10 ) ) + p1 = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ imath.V3f( 10 ) ] * 10 ) ) p1["width"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.FloatVectorData( [ 1 ] * 10 ), ) - p2 = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ IECore.V3f( 20 ) ] * 10 ) ) + p2 = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ imath.V3f( 20 ) ] * 10 ) ) p2["width"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.FloatVectorData( [ 2 ] * 10 ), diff --git a/contrib/IECoreArnold/test/IECoreArnold/ProceduralTest.py b/contrib/IECoreArnold/test/IECoreArnold/ProceduralTest.py index 02e4533e4f..e89498ec31 100644 --- a/contrib/IECoreArnold/test/IECoreArnold/ProceduralTest.py +++ b/contrib/IECoreArnold/test/IECoreArnold/ProceduralTest.py @@ -35,6 +35,7 @@ import re import arnold import unittest +import imath import IECore import IECoreScene @@ -53,7 +54,7 @@ def __init__( self, radius=1 ) : def bound( self ) : - return IECore.Box3f( IECore.V3f( -self.__radius ), IECore.V3f( self.__radius ) ) + return imath.Box3f( imath.V3f( -self.__radius ), imath.V3f( self.__radius ) ) def render( self, renderer ) : @@ -76,7 +77,7 @@ def __init__( self, transform, child ) : def bound( self ) : b = self.__child.bound() - b = b.transform( self.__transform ) + b = b * self.__transform return b def render( self, renderer ) : @@ -137,7 +138,7 @@ def testTransformingProceduralBounds( self ) : r.procedural( self.TransformingProcedural( - IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ), + imath.M44f().translate( imath.V3f( 0, 0, -5 ) ), self.SphereProcedural() ) ) @@ -157,9 +158,9 @@ def testNestedTransformingProceduralBounds( self ) : r.procedural( self.TransformingProcedural( - IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ), + imath.M44f().translate( imath.V3f( 0, 0, -5 ) ), self.TransformingProcedural( - IECore.M44f.createScaled( IECore.V3f( 0.2 ) ), + imath.M44f().scale( imath.V3f( 0.2 ) ), self.SphereProcedural() ) ) @@ -176,14 +177,14 @@ def testProceduralInheritsShader( self ) : r.procedural( self.ShaderProcedural( - IECoreScene.Shader( "flat", "surface", { "color" : IECore.Color3f( 0, 1, 0 ) } ), + IECoreScene.Shader( "flat", "surface", { "color" : imath.Color3f( 0, 1, 0 ) } ), self.SphereProcedural() ) ) i = IECoreImage.ImageDisplayDriver.removeStoredImage( "testHandle" ) - dimensions = i.dataWindow.size() + IECore.V2i( 1 ) + dimensions = i.dataWindow.size() + imath.V2i( 1 ) index = dimensions.x * int(dimensions.y * 0.5) + int(dimensions.x * 0.5) self.assertEqual( i["R"][index], 0 ) self.assertAlmostEqual( i["G"][index], 1, 6 ) @@ -199,7 +200,7 @@ def __init__( self ) : def bound( self ) : - return IECore.Box3f() + return imath.Box3f() def render( self, renderer ) : diff --git a/contrib/IECoreArnold/test/IECoreArnold/RendererTest.py b/contrib/IECoreArnold/test/IECoreArnold/RendererTest.py index 1e7568b1e1..8dfb4e2181 100644 --- a/contrib/IECoreArnold/test/IECoreArnold/RendererTest.py +++ b/contrib/IECoreArnold/test/IECoreArnold/RendererTest.py @@ -37,6 +37,7 @@ import unittest import arnold +import imath import IECore import IECoreScene @@ -86,7 +87,7 @@ def testOptions( self ) : self.assertEqual( r.getOption( "user:myLovelyUserOption" ), IECore.StringData( "oooh!" ) ) # check that set/get for other renderers is ignored - r.setOption( "ri:pixelSamples", IECore.V2iData( IECore.V2i( 1, 1 ) ) ) + r.setOption( "ri:pixelSamples", IECore.V2iData( imath.V2i( 1, 1 ) ) ) self.assertEqual( r.getOption( "ri:pixelSamples" ), None ) def testDisplay( self ) : @@ -166,12 +167,12 @@ def testShader( self ) : with IECoreScene.WorldBlock( r ) : - r.shader( "surface", "standard_surface", { "emission" : 1.0, "emission_color" : IECore.Color3f( 1, 0, 0 ) } ) + r.shader( "surface", "standard_surface", { "emission" : 1.0, "emission_color" : imath.Color3f( 1, 0, 0 ) } ) r.sphere( 1, -1, 1, 360, {} ) image = IECoreImage.ImageDisplayDriver.removeStoredImage( "test" ) - dimensions = image.dataWindow.size() + IECore.V2i( 1 ) + dimensions = image.dataWindow.size() + imath.V2i( 1 ) index = dimensions.x * int(dimensions.y * 0.5) + int(dimensions.x * 0.5) self.assertAlmostEqual( image["A"][index], 1, 5 ) self.assertAlmostEqual( image["R"][index], 1, 5 ) @@ -196,7 +197,7 @@ def testReferenceExistingShader( self ) : image = IECoreImage.ImageDisplayDriver.removeStoredImage( "test" ) - dimensions = image.dataWindow.size() + IECore.V2i( 1 ) + dimensions = image.dataWindow.size() + imath.V2i( 1 ) index = dimensions.x * int(dimensions.y * 0.5) + int(dimensions.x * 0.5) self.assertAlmostEqual( image["A"][index], 1, 5 ) self.assertAlmostEqual( image["R"][index], 1, 5 ) @@ -256,7 +257,7 @@ def testDefaultCamera( self ) : # render a plane at z==0 and check we can't see it with the default camera - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -0.1 ), IECore.V2f( 0.1 ) ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -0.1 ), imath.V2f( 0.1 ) ) ) r = IECoreArnold.Renderer() @@ -267,9 +268,9 @@ def testDefaultCamera( self ) : m.render( r ) image = IECoreImage.ImageDisplayDriver.removeStoredImage( "test" ) - self.assertEqual( image.dataWindow, IECore.Box2i( IECore.V2i( 0 ), IECore.V2i( 639, 479 ) ) ) + self.assertEqual( image.dataWindow, imath.Box2i( imath.V2i( 0 ), imath.V2i( 639, 479 ) ) ) - dimensions = image.dataWindow.size() + IECore.V2i( 1 ) + dimensions = image.dataWindow.size() + imath.V2i( 1 ) index = dimensions.x * int(dimensions.y * 0.5) + int(dimensions.x * 0.5) self.failUnless( image["A"][index] < 0.5 ) @@ -284,13 +285,13 @@ def testDefaultCamera( self ) : with IECoreScene.WorldBlock( r ) : with IECoreScene.TransformBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -1 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -1 ) ) ) m.render( r ) image = IECoreImage.ImageDisplayDriver.removeStoredImage( "test" ) - self.assertEqual( image.dataWindow, IECore.Box2i( IECore.V2i( 0 ), IECore.V2i( 639, 479 ) ) ) + self.assertEqual( image.dataWindow, imath.Box2i( imath.V2i( 0 ), imath.V2i( 639, 479 ) ) ) - dimensions = image.dataWindow.size() + IECore.V2i( 1 ) + dimensions = image.dataWindow.size() + imath.V2i( 1 ) index = dimensions.x * int(dimensions.y * 0.5) + int(dimensions.x * 0.5) self.failUnless( image["A"][index] > 0.9 ) @@ -304,16 +305,16 @@ def testDefaultCamera( self ) : r.setOption( "ai:AA_samples", IECore.IntData( 3 ) ) with IECoreScene.TransformBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, 1 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, 1 ) ) ) r.camera( "main", {} ) with IECoreScene.WorldBlock( r ) : m.render( r ) image = IECoreImage.ImageDisplayDriver.removeStoredImage( "test" ) - self.assertEqual( image.dataWindow, IECore.Box2i( IECore.V2i( 0 ), IECore.V2i( 639, 479 ) ) ) + self.assertEqual( image.dataWindow, imath.Box2i( imath.V2i( 0 ), imath.V2i( 639, 479 ) ) ) - dimensions = image.dataWindow.size() + IECore.V2i( 1 ) + dimensions = image.dataWindow.size() + imath.V2i( 1 ) index = dimensions.x * int(dimensions.y * 0.5) + int(dimensions.x * 0.5) self.failUnless( image["A"][index] > 0.9 ) @@ -326,22 +327,22 @@ def testCameraXYOrientation( self ) : r.display( "test", "ieDisplay", "rgba", { "driverType" : "ImageDisplayDriver", "handle" : "test" } ) with IECoreScene.TransformBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, 1 ) ) ) - r.camera( "main", { "resolution" : IECore.V2iData( IECore.V2i( 512 ) ) } ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, 1 ) ) ) + r.camera( "main", { "resolution" : IECore.V2iData( imath.V2i( 512 ) ) } ) with IECoreScene.WorldBlock( r ) : - r.shader( "surface", "utility", { "color" : IECore.Color3f( 1, 0, 0 ) } ) - IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( 0.75, -0.25 ), IECore.V2f( 1.25, 0.25 ) ) ).render( r ) + r.shader( "surface", "utility", { "color" : imath.Color3f( 1, 0, 0 ) } ) + IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( 0.75, -0.25 ), imath.V2f( 1.25, 0.25 ) ) ).render( r ) - r.shader( "surface", "utility", { "color" : IECore.Color3f( 0, 1, 0 ) } ) - IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -0.25, 0.75 ), IECore.V2f( 0.25, 1.25 ) ) ).render( r ) + r.shader( "surface", "utility", { "color" : imath.Color3f( 0, 1, 0 ) } ) + IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -0.25, 0.75 ), imath.V2f( 0.25, 1.25 ) ) ).render( r ) # check we get the colors we'd expect where we expect them image = IECoreImage.ImageDisplayDriver.removeStoredImage( "test" ) self.failUnless( image is not None ) - dimensions = image.dataWindow.size() + IECore.V2i( 1 ) + dimensions = image.dataWindow.size() + imath.V2i( 1 ) index = dimensions.x * int(dimensions.y * 0.5) + int(dimensions.x * 1) - 1 self.assertAlmostEqual( image["A"][index], 1, 5 ) self.assertAlmostEqual( image["R"][index], 1, 5 ) @@ -358,33 +359,33 @@ def testCameraAspectRatio( self ) : r = IECoreArnold.Renderer() - r.camera( "main", { "resolution" : IECore.V2i( 640, 480 ), "screenWindow" : IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 640, 480 ) ) } ) + r.camera( "main", { "resolution" : imath.V2i( 640, 480 ), "screenWindow" : imath.Box2f( imath.V2f( 0 ), imath.V2f( 640, 480 ) ) } ) r.display( "test", "ieDisplay", "rgba", { "driverType" : "ImageDisplayDriver", "handle" : "test" } ) with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) - r.shader( "surface", "utility", { "shading_mode" : "flat", "color" : IECore.Color3f( 1, 0, 0 ) } ) - IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( 2 ), IECore.V2f( 638, 478 ) ) ).render( r ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) + r.shader( "surface", "utility", { "shading_mode" : "flat", "color" : imath.Color3f( 1, 0, 0 ) } ) + IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( 2 ), imath.V2f( 638, 478 ) ) ).render( r ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -1 ) ) ) - r.shader( "surface", "utility", { "shade_mode" : "flat", "color" : IECore.Color3f( 0, 1, 0 ) } ) - IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 640, 480 ) ) ).render( r ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -1 ) ) ) + r.shader( "surface", "utility", { "shade_mode" : "flat", "color" : imath.Color3f( 0, 1, 0 ) } ) + IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( 0 ), imath.V2f( 640, 480 ) ) ).render( r ) image = IECoreImage.ImageDisplayDriver.removeStoredImage( "test" ) self.failUnless( image is not None ) - dimensions = image.dataWindow.size() + IECore.V2i( 1 ) + dimensions = image.dataWindow.size() + imath.V2i( 1 ) edges = [ - IECore.V2i( 0 ), - IECore.V2i( 320, 0 ), - IECore.V2i( 639, 0 ), - IECore.V2i( 639, 240 ), - IECore.V2i( 639, 479 ), - IECore.V2i( 320, 479 ), - IECore.V2i( 0, 479 ), - IECore.V2i( 0, 240 ), + imath.V2i( 0 ), + imath.V2i( 320, 0 ), + imath.V2i( 639, 0 ), + imath.V2i( 639, 240 ), + imath.V2i( 639, 479 ), + imath.V2i( 320, 479 ), + imath.V2i( 0, 479 ), + imath.V2i( 0, 240 ), ] for point in edges : @@ -393,14 +394,14 @@ def testCameraAspectRatio( self ) : self.failUnless( image["G"][index] > 0.8 ) innerEdges = [ - IECore.V2i( 3, 3 ), - IECore.V2i( 320, 3 ), - IECore.V2i( 637, 3 ), - IECore.V2i( 636, 240 ), - IECore.V2i( 636, 477 ), - IECore.V2i( 320, 477 ), - IECore.V2i( 3, 477 ), - IECore.V2i( 3, 240 ), + imath.V2i( 3, 3 ), + imath.V2i( 320, 3 ), + imath.V2i( 637, 3 ), + imath.V2i( 636, 240 ), + imath.V2i( 636, 477 ), + imath.V2i( 320, 477 ), + imath.V2i( 3, 477 ), + imath.V2i( 3, 240 ), ] for point in innerEdges : @@ -420,7 +421,7 @@ def __init__( self ) : def bound( self ) : - return IECore.Box3f( IECore.V3f( -1 ), IECore.V3f( 1 ) ) + return imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ) def render( self, renderer ) : @@ -439,7 +440,7 @@ def hash( self ): with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) r.setAttribute( "user:test", IECore.IntData( 0 ) ) r.procedural( TestProcedural() ) @@ -459,13 +460,13 @@ def performCurvesTest( self, curvesPrimitive, expectedImage ) : r.display( "test", "ieDisplay", "rgba", { "driverType" : "ImageDisplayDriver", "handle" : "test" } ) with IECoreScene.TransformBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, 2 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, 2 ) ) ) r.camera( "main", { - "resolution" : IECore.V2i( 512 ), + "resolution" : imath.V2i( 512 ), "projectin" : "orthographic", - "screenWindow" : IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ), + "screenWindow" : imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ), } ) @@ -488,10 +489,10 @@ def testBezierCurves( self ) : False, IECore.V3fVectorData( [ - IECore.V3f( 0.8, 0.2, 0 ), - IECore.V3f( 0.2, 0.2, 0 ), - IECore.V3f( 0.2, 0.8, 0 ), - IECore.V3f( 0.8, 0.8, 0 ), + imath.V3f( 0.8, 0.2, 0 ), + imath.V3f( 0.2, 0.2, 0 ), + imath.V3f( 0.2, 0.8, 0 ), + imath.V3f( 0.8, 0.8, 0 ), ] ) @@ -509,10 +510,10 @@ def testBSplineCurves( self ) : False, IECore.V3fVectorData( [ - IECore.V3f( 0.8, 0.2, 0 ), - IECore.V3f( 0.2, 0.2, 0 ), - IECore.V3f( 0.2, 0.8, 0 ), - IECore.V3f( 0.8, 0.8, 0 ), + imath.V3f( 0.8, 0.2, 0 ), + imath.V3f( 0.2, 0.2, 0 ), + imath.V3f( 0.2, 0.8, 0 ), + imath.V3f( 0.8, 0.8, 0 ), ] ) @@ -544,7 +545,7 @@ def __displacementRender( self, doDisplacement ) : with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) r.setAttribute( "ai:polymesh:subdiv_iterations", IECore.IntData( 5 ) ) @@ -552,7 +553,7 @@ def __displacementRender( self, doDisplacement ) : if doDisplacement : r.shader( "displacement", "noise", {} ) - mesh = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -2 ), IECore.V2f( 2 ) ) ) + mesh = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -2 ), imath.V2f( 2 ) ) ) mesh.interpolation = "catmullClark" mesh.render( r ) @@ -593,11 +594,11 @@ def testShapeAttributes( self ) : with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) r.setAttribute( "ai:polymesh:subdiv_iterations", IECore.IntData( 10 ) ) - mesh = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -2 ), IECore.V2f( 2 ) ) ) + mesh = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -2 ), imath.V2f( 2 ) ) ) mesh.render( r ) shapes = self.__allNodes( type = arnold.AI_NODE_SHAPE ) @@ -619,11 +620,11 @@ def testEnumAttributes( self ) : with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) r.setAttribute( "ai:polymesh:subdiv_type", source ) - mesh = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -2 ), IECore.V2f( 2 ) ) ) + mesh = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -2 ), imath.V2f( 2 ) ) ) mesh.render( r ) shapes = self.__allNodes( type = arnold.AI_NODE_SHAPE ) @@ -641,17 +642,17 @@ def testShaderConnections( self ) : with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) - r.shader( "shader", "flat", { "color" : IECore.Color3f( 1, 0, 0 ), "__handle" : "myInputShader" } ) + r.shader( "shader", "flat", { "color" : imath.Color3f( 1, 0, 0 ), "__handle" : "myInputShader" } ) r.shader( "surface", "standard_surface", { "emission" : 1.0, "emission_color" : "link:myInputShader" } ) - mesh = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + mesh = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) mesh.render( r ) image = IECoreImage.ImageDisplayDriver.removeStoredImage( "test" ) - dimensions = image.dataWindow.size() + IECore.V2i( 1 ) + dimensions = image.dataWindow.size() + imath.V2i( 1 ) index = dimensions.x * int(dimensions.y * 0.5) + int(dimensions.x * 0.5) self.assertAlmostEqual( image["R"][index], 1, 5 ) self.assertEqual( image["G"][index], 0 ) @@ -665,11 +666,11 @@ def testMissingShaderConnectionWarnings( self ) : with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) m = IECore.CapturingMessageHandler() with m : - r.shader( "shader", "flat", { "color" : IECore.Color3f( 1, 0, 0 ), "__handle" : "myInputShader" } ) + r.shader( "shader", "flat", { "color" : imath.Color3f( 1, 0, 0 ), "__handle" : "myInputShader" } ) r.shader( "surface", "standard_surface", { "emission" : 1.0, "emission_color" : "link:oopsWrongOne" } ) self.assertEqual( len( m.messages ), 1 ) @@ -684,18 +685,18 @@ def testLight( self ) : with IECoreScene.WorldBlock( r ) : - r.light( "point_light", "handle", { "intensity" : 1.0, "color" : IECore.Color3f( 1, 0.5, 0.25 ) } ) + r.light( "point_light", "handle", { "intensity" : 1.0, "color" : imath.Color3f( 1, 0.5, 0.25 ) } ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -1 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -1 ) ) ) r.shader( "surface", "standard_surface", {} ) - mesh = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + mesh = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) mesh.render( r ) image = IECoreImage.ImageDisplayDriver.removeStoredImage( "test" ) - dimensions = image.dataWindow.size() + IECore.V2i( 1 ) + dimensions = image.dataWindow.size() + imath.V2i( 1 ) index = dimensions.x * int(dimensions.y * 0.5) + int(dimensions.x * 0.5) self.assertTrue( image["R"][index] > 0.2 ) self.assertAlmostEqual( image["R"][index] * 0.5, image["G"][index] ) @@ -710,12 +711,12 @@ def testExternalProcedural( self ) : r.procedural( r.ExternalProcedural( "volume", - IECore.Box3f( - IECore.V3f( 1, 2, 3 ), - IECore.V3f( 4, 5, 6 ) + imath.Box3f( + imath.V3f( 1, 2, 3 ), + imath.V3f( 4, 5, 6 ) ), { - "colorParm" : IECore.Color3f( 1, 2, 3 ), + "colorParm" : imath.Color3f( 1, 2, 3 ), "stringParm" : "test", "floatParm" : 1.5, "intParm" : 2, @@ -739,7 +740,7 @@ def testPixelAspectRatio( self ) : r = IECoreArnold.Renderer( self.__assFileName ) - r.camera( "main", { "resolution" : IECore.V2i( 640, 480 ), "pixelAspectRatio" : 2.0 } ) + r.camera( "main", { "resolution" : imath.V2i( 640, 480 ), "pixelAspectRatio" : 2.0 } ) with IECoreScene.WorldBlock( r ) : pass @@ -770,23 +771,23 @@ def testDeformationMotionBlur( self ) : r.display( "test", "ieDisplay", "rgba", { "driverType" : "ImageDisplayDriver", "handle" : "test" } ) r.setOption( "ai:AA_samples", IECore.IntData( 20 ) ) - r.camera( "main", { "resolution" : IECore.V2i( 128, 128 ), "shutter" : IECore.V2f( 0, 1 ) } ) + r.camera( "main", { "resolution" : imath.V2i( 128, 128 ), "shutter" : imath.V2f( 0, 1 ) } ) with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) with IECoreScene.MotionBlock( r, [ 0, 1 ] ) : - mesh = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1.5, -0.5 ), IECore.V2f( -0.5, 0.5 ) ) ) + mesh = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1.5, -0.5 ), imath.V2f( -0.5, 0.5 ) ) ) mesh.render( r ) - mesh = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( 0.5, -0.5 ), IECore.V2f( 1.5, 0.5 ) ) ) + mesh = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( 0.5, -0.5 ), imath.V2f( 1.5, 0.5 ) ) ) mesh.render( r ) image = IECoreImage.ImageDisplayDriver.removeStoredImage( "test" ) - dimensions = image.dataWindow.size() + IECore.V2i( 1 ) + dimensions = image.dataWindow.size() + imath.V2i( 1 ) index = dimensions.x * int(dimensions.y * 0.5) + int(dimensions.x * 0.5) self.assertAlmostEqual( image["A"][index], 0.5, 2 ) @@ -797,24 +798,24 @@ def testTransformationMotionBlur( self ) : r.display( "test", "ieDisplay", "rgba", { "driverType" : "ImageDisplayDriver", "handle" : "test" } ) r.setOption( "ai:AA_samples", IECore.IntData( 20 ) ) - r.camera( "main", { "resolution" : IECore.V2i( 128, 128 ), "shutter" : IECore.V2f( 0, 1 ) } ) + r.camera( "main", { "resolution" : imath.V2i( 128, 128 ), "shutter" : imath.V2f( 0, 1 ) } ) with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) with IECoreScene.MotionBlock( r, [ 0, 1 ] ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( -1, 0, 0 ) ) ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 1, 0, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( -1, 0, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 1, 0, 0 ) ) ) - mesh = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -0.5 ), IECore.V2f( 0.5 ) ) ) + mesh = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -0.5 ), imath.V2f( 0.5 ) ) ) mesh.render( r ) image = IECoreImage.ImageDisplayDriver.removeStoredImage( "test" ) - dimensions = image.dataWindow.size() + IECore.V2i( 1 ) + dimensions = image.dataWindow.size() + imath.V2i( 1 ) index = dimensions.x * int(dimensions.y * 0.5) + int(dimensions.x * 0.5) self.assertAlmostEqual( image["A"][index], 0.5, 2 ) @@ -825,32 +826,32 @@ def testNonUniformMotionBlur( self ) : r.display( "test", "ieDisplay", "rgba", { "driverType" : "ImageDisplayDriver", "handle" : "test" } ) r.setOption( "ai:AA_samples", IECore.IntData( 20 ) ) - r.camera( "main", { "resolution" : IECore.V2i( 128, 128 ), "shutter" : IECore.V2f( 0, 1 ) } ) + r.camera( "main", { "resolution" : imath.V2i( 128, 128 ), "shutter" : imath.V2f( 0, 1 ) } ) with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) # A motion block that has slightly non-uniform sampling, but not enough to notice # We should allow it, since the user won't notice that Arnold is ignoring the non-uniformity with IECoreScene.MotionBlock( r, [ 0, 0.3333, 0.6666, 1 ] ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( -1, 0, 0 ) ) ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( -0.3333333333, 0, 0 ) ) ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0.33333333333, 0, 0 ) ) ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 1, 0, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( -1, 0, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( -0.3333333333, 0, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0.33333333333, 0, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 1, 0, 0 ) ) ) with self.assertRaises( RuntimeError ): # This block is actually non-uniform, and won't render correctly, so we should fail with IECoreScene.MotionBlock( r, [ 0, 0.333, 0.666, 2 ] ): pass - mesh = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -0.5 ), IECore.V2f( 0.5 ) ) ) + mesh = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -0.5 ), imath.V2f( 0.5 ) ) ) mesh.render( r ) image = IECoreImage.ImageDisplayDriver.removeStoredImage( "test" ) - dimensions = image.dataWindow.size() + IECore.V2i( 1 ) + dimensions = image.dataWindow.size() + imath.V2i( 1 ) index = dimensions.x * int(dimensions.y * 0.5) + int(dimensions.x * 0.5) self.assertAlmostEqual( image["A"][index], 0.5, 2 ) @@ -866,7 +867,7 @@ def testProcedural( self ) : r.procedural( r.ExternalProcedural( "volume", - IECore.Box3f( IECore.V3f( -1, -2, -3 ), IECore.V3f( 4, 5, 6 ) ), + imath.Box3f( imath.V3f( -1, -2, -3 ), imath.V3f( 4, 5, 6 ) ), { "testFloat" : 0.5 } diff --git a/contrib/IECoreArnold/test/IECoreArnold/SphereAlgoTest.py b/contrib/IECoreArnold/test/IECoreArnold/SphereAlgoTest.py index 12f3551ebb..6e37f69793 100644 --- a/contrib/IECoreArnold/test/IECoreArnold/SphereAlgoTest.py +++ b/contrib/IECoreArnold/test/IECoreArnold/SphereAlgoTest.py @@ -35,6 +35,7 @@ import unittest import arnold +import imath import IECore import IECoreScene @@ -70,13 +71,13 @@ def testConvertWithMotion( self ) : def testPrimitiveVariables( self ) : s = IECoreScene.SpherePrimitive() - s["v"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.V3f( 1, 2, 3 ) ) - s["c"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.Color3f( 1, 2, 3 ) ) + s["v"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, imath.V3f( 1, 2, 3 ) ) + s["c"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, imath.Color3f( 1, 2, 3 ) ) s["s"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, "test" ) s["i"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, 11 ) s["b"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, True ) s["f"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, 2.5 ) - s["m"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.M44f( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) ) + s["m"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, imath.M44f( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) ) with IECoreArnold.UniverseBlock( writable = True ) : diff --git a/contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py b/contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py index eb9d343a27..9365276997 100644 --- a/contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py +++ b/contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py @@ -1,6 +1,41 @@ +########################################################################## +# +# Copyright (c) 2017, Image Engine Design Inc. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of Image Engine Design nor the names of any +# other contributors to this software may be used to endorse or +# promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +########################################################################## + import os import math import unittest +import imath import IECore import IECoreScene @@ -8,6 +43,7 @@ class USDSceneTest( unittest.TestCase ) : + def testConstruction( self ) : fileName = os.path.dirname( __file__ ) + "/data/cube.usda" @@ -146,7 +182,7 @@ def testBound( self ) : bound = cube.readBound( 0.0 ) - self.assertEqual( bound, IECore.Box3d( IECore.V3d( -0.5 ), IECore.V3d( 0.5 ) ) ) + self.assertEqual( bound, imath.Box3d( imath.V3d( -0.5 ), imath.V3d( 0.5 ) ) ) def testTransform ( self ) : @@ -155,8 +191,9 @@ def testTransform ( self ) : transform = plane.readTransformAsMatrix( 0.0 ) - expectedMatrix = IECore.M44d.createTranslated( IECore.V3d( 2.0, 0.0, 0.0 ) ) + expectedMatrix = imath.M44d().translate( imath.V3d( 2.0, 0.0, 0.0 ) ) self.assertEqual( transform, expectedMatrix ) - +if __name__ == "__main__": + unittest.main() diff --git a/contrib/scripts/9to10/__init__.py b/contrib/scripts/9to10/__init__.py index 5117e80502..6f0b9fd204 100644 --- a/contrib/scripts/9to10/__init__.py +++ b/contrib/scripts/9to10/__init__.py @@ -51,5 +51,5 @@ # documentation on how to write a fixer. import fix_import_star -import fix_scene +import fix_modules diff --git a/contrib/scripts/9to10/fix_scene.py b/contrib/scripts/9to10/fix_modules.py similarity index 77% rename from contrib/scripts/9to10/fix_scene.py rename to contrib/scripts/9to10/fix_modules.py index 1163d9da96..0f49baddcf 100644 --- a/contrib/scripts/9to10/fix_scene.py +++ b/contrib/scripts/9to10/fix_modules.py @@ -38,11 +38,14 @@ from lib2to3.pytree import Leaf, Node from lib2to3.pygram import python_symbols as syms +import imath import IECoreScene -class FixScene( BaseFix ) : +class FixModules( BaseFix ) : PATTERN = """ + imathImport=simple_stmt< import_name< 'import' 'imath' > "\\n" > + | coreImport=simple_stmt< import_name< 'import' 'IECore' > "\\n" > | sceneImport=simple_stmt< import_name< 'import' 'IECoreScene' > "\\n" > @@ -53,6 +56,7 @@ class FixScene( BaseFix ) : def start_tree( self, tree, filename ) : self.__coreImport = None + self.__haveImathImport = False self.__haveSceneImport = False def transform( self, node, results ) : @@ -61,6 +65,10 @@ def transform( self, node, results ) : self.__coreImport = results["coreImport"] + elif "imathImport" in results and node.depth() == 1 : + + self.__haveImathImport = True + elif "sceneImport" in results and node.depth() == 1 : self.__haveSceneImport = True @@ -79,26 +87,39 @@ def transform( self, node, results ) : results["module"].value = "IECoreScene" node.changed() - if not self.__haveSceneImport and self.__coreImport is not None : + if not self.__haveSceneImport : + self.__insertImport( "IECoreScene", 1 ) + self.__haveSceneImport = True + + elif "name" in results and hasattr( imath, results["name"].value ) : + + results["module"].value = "imath" + node.changed() + + if not self.__haveImathImport : + self.__insertImport( "imath", 0 ) + self.__haveImathImport = True - sceneImport = Node( + def __insertImport( self, module, offset ) : + + if self.__coreImport is None : + return + + importLine = Node( + syms.simple_stmt, + [ + Node( syms.import_name, [ Leaf( token.NAME, u"import" ), - Leaf( token.NAME, "IECoreScene", prefix=" " ) - ] - ) - sceneImportLine = Node( - syms.simple_stmt, - [ - sceneImport, - Newline() + Leaf( token.NAME, module, prefix=" " ) ] - ) - - self.__coreImport.parent.insert_child( - self.__coreImport.parent.children.index( self.__coreImport ) + 1, - sceneImportLine - ) - - self.__haveSceneImport = True + ), + Newline() + ] + ) + + self.__coreImport.parent.insert_child( + self.__coreImport.parent.children.index( self.__coreImport ) + offset, + importLine + ) diff --git a/include/IECore/BoxAlgo.h b/include/IECore/BoxAlgo.h index 17f9a2806e..46a0312287 100644 --- a/include/IECore/BoxAlgo.h +++ b/include/IECore/BoxAlgo.h @@ -46,6 +46,9 @@ namespace IECore { +namespace BoxAlgo +{ + /// Streaming for Imath::Box types template std::ostream &operator <<( std::ostream &os, const Imath::Box &obj ); @@ -54,6 +57,20 @@ std::ostream &operator <<( std::ostream &os, const Imath::Box &obj ); template Imath::Vec2 closestPointInBox(const Imath::Vec2& p, const Imath::Box< Imath::Vec2 >& box ); +/// Returns true if the box contains containee. +template +bool contains( const Imath::Box &box, const Imath::Box &containee ); + +/// Splits the box into two across the specified axis. +template +void split( const Imath::Box &box, Imath::Box &low, Imath::Box &high, int axis ); + +/// Splits the box into two across the major axis. +template +void split( const Imath::Box &box, Imath::Box &low, Imath::Box &high ); + +} // namespace BoxAlgo + } // namespace IECore #include "IECore/BoxAlgo.inl" diff --git a/include/IECore/BoxAlgo.inl b/include/IECore/BoxAlgo.inl index 2497c5cfa7..f7f9677e8b 100644 --- a/include/IECore/BoxAlgo.inl +++ b/include/IECore/BoxAlgo.inl @@ -38,6 +38,9 @@ namespace IECore { +namespace BoxAlgo +{ + template std::ostream &operator <<( std::ostream &os, const Imath::Box &obj ) { @@ -79,6 +82,51 @@ Imath::Vec2 closestPointInBox(const Imath::Vec2& p, const Imath::Box< Imat return b; } +template +bool contains( const Imath::Box &box, const Imath::Box &containee ) +{ + for( unsigned int i = 0; i < T::dimensions(); ++i ) + { + if( containee.min[i] < box.min[i] ) + { + return false; + } + if( containee.max[i] > box.max[i] ) + { + return false; + } + } + return true; +} + +template +void split( const Imath::Box &box, Imath::Box &low, Imath::Box &high, int axis ) +{ + for( int i = 0; i < T::dimensions(); ++i ) + { + if( i == axis ) + { + typename T::BaseType mid = (box.min[i] + box.max[i]) / 2; + low.min[i] = box.min[i]; + low.max[i] = high.min[i] = mid; + high.max[i] = box.max[i]; + } + else + { + low.min[i] = high.min[i] = box.min[i]; + low.max[i] = high.max[i] = box.max[i]; + } + } +} + +template +void split( const Imath::Box &box, Imath::Box &low, Imath::Box &high ) +{ + split( box, low, high, box.majorAxis() ); +} + +} // namespace BoxAlgo + } // namespace IECore #endif // IE_CORE_BOXALGO_INL diff --git a/include/IECore/DespatchTypedData.inl b/include/IECore/DespatchTypedData.inl index bb65ce4d8e..2bedda7d09 100644 --- a/include/IECore/DespatchTypedData.inl +++ b/include/IECore/DespatchTypedData.inl @@ -197,14 +197,6 @@ typename Functor::ReturnType despatchTypedData( Data *data, Functor &functor, Er return typename Detail::DespatchTypedData< Functor, Color4fData, ErrorHandler > ::template Func()( static_cast( data ), functor, errorHandler ); - case Color3dDataTypeId : - return - typename Detail::DespatchTypedData< Functor, Color3dData, ErrorHandler > - ::template Func()( static_cast( data ), functor, errorHandler ); - case Color4dDataTypeId : - return - typename Detail::DespatchTypedData< Functor, Color4dData, ErrorHandler > - ::template Func()( static_cast( data ), functor, errorHandler ); case Box2iDataTypeId : return typename Detail::DespatchTypedData< Functor, Box2iData, ErrorHandler > @@ -406,15 +398,6 @@ typename Functor::ReturnType despatchTypedData( Data *data, Functor &functor, Er return typename Detail::DespatchTypedData< Functor, Color4fVectorData, ErrorHandler > ::template Func()( static_cast( data ), functor, errorHandler ); - case Color3dVectorDataTypeId : - return - typename Detail::DespatchTypedData< Functor, Color3dVectorData, ErrorHandler > - ::template Func()( static_cast( data ), functor, errorHandler ); - case Color4dVectorDataTypeId : - return - typename Detail::DespatchTypedData< Functor, Color4dVectorData, ErrorHandler > - ::template Func()( static_cast( data ), functor, errorHandler ); - default : throw InvalidArgumentException( "Data supplied is not of a known TypedData type." ); } diff --git a/include/IECore/Random.h b/include/IECore/RandomAlgo.h similarity index 93% rename from include/IECore/Random.h rename to include/IECore/RandomAlgo.h index 0780fdf83c..f3c1a46ab2 100644 --- a/include/IECore/Random.h +++ b/include/IECore/RandomAlgo.h @@ -32,14 +32,17 @@ // ////////////////////////////////////////////////////////////////////////// -#ifndef IECORE_RANDOM_H -#define IECORE_RANDOM_H +#ifndef IECORE_RANDOMALGO_H +#define IECORE_RANDOMALGO_H #include "OpenEXR/ImathRandom.h" namespace IECore { +namespace RandomAlgo +{ + /// Returns a random barycentric coordinate. template Vec barycentricRand( Rand &rand ); @@ -53,8 +56,10 @@ Vec triangleRand( const Vec &v0, const Vec &v1, const Vec &v2, Rand &rand ); template Vec cosineHemisphereRand( Rand &rand ); +} // namespace RandomAlgo + } // namespace IECore -#include "IECore/Random.inl" +#include "IECore/RandomAlgo.inl" -#endif // IECORE_RANDOM_H +#endif // IECORE_RANDOMALGO_H diff --git a/include/IECore/Random.inl b/include/IECore/RandomAlgo.inl similarity index 95% rename from include/IECore/Random.inl rename to include/IECore/RandomAlgo.inl index cd6d6244e6..cf1d5f40ae 100644 --- a/include/IECore/Random.inl +++ b/include/IECore/RandomAlgo.inl @@ -32,8 +32,8 @@ // ////////////////////////////////////////////////////////////////////////// -#ifndef IECORE_RANDOM_INL -#define IECORE_RANDOM_INL +#ifndef IECORE_RANDOMALGO_INL +#define IECORE_RANDOMALGO_INL #include "OpenEXR/ImathMath.h" #include "OpenEXR/ImathVec.h" @@ -41,6 +41,9 @@ namespace IECore { +namespace RandomAlgo +{ + template Vec barycentricRand( Rand &rand ) { @@ -76,6 +79,8 @@ Vec cosineHemisphereRand( Rand &rand ) return result; } +} // namespace RandomAlgo + } // namespace IECore -#endif // IECORE_RANDOM_INL +#endif // IECORE_RANDOMALGO_INL diff --git a/include/IECore/SimpleTypedData.h b/include/IECore/SimpleTypedData.h index 03b61d6d1e..ac3623b36b 100644 --- a/include/IECore/SimpleTypedData.h +++ b/include/IECore/SimpleTypedData.h @@ -78,8 +78,6 @@ IECORE_DECLARE_GEOMETRICTYPEDDATA( V3dData, Imath::V3d, double, SimpleDataHolder IECORE_DECLARE_TYPEDDATA( Color3fData, Imath::Color3f, float, SimpleDataHolder ) IECORE_DECLARE_TYPEDDATA( Color4fData, Imath::Color4f, float, SimpleDataHolder ) -IECORE_DECLARE_TYPEDDATA( Color3dData, Imath::Color3, double, SimpleDataHolder ) -IECORE_DECLARE_TYPEDDATA( Color4dData, Imath::Color4, double, SimpleDataHolder ) IECORE_DECLARE_TYPEDDATA( Box2iData, Imath::Box2i, int, SimpleDataHolder ) IECORE_DECLARE_TYPEDDATA( Box3iData, Imath::Box3i, int, SimpleDataHolder ) IECORE_DECLARE_TYPEDDATA( Box2fData, Imath::Box2f, float, SimpleDataHolder ) diff --git a/include/IECore/TypeIds.h b/include/IECore/TypeIds.h index 43a95acb8f..665b77d22a 100644 --- a/include/IECore/TypeIds.h +++ b/include/IECore/TypeIds.h @@ -89,12 +89,12 @@ enum TypeId QuatdDataTypeId = 43, Color3fDataTypeId = 44, Color4fDataTypeId = 45, - Color3dDataTypeId = 46, - Color4dDataTypeId = 47, + Color3dDataTypeId = 46, // Obsolete + Color4dDataTypeId = 47, // Obsolete Color3fVectorDataTypeId = 48, Color4fVectorDataTypeId = 49, - Color3dVectorDataTypeId = 50, - Color4dVectorDataTypeId = 51, + Color3dVectorDataTypeId = 50, // Obsolete + Color4dVectorDataTypeId = 51, // Obsolete BlindDataHolderTypeId = 52, CompoundObjectTypeId = 55, M33fDataTypeId = 56, diff --git a/include/IECore/VectorTypedData.h b/include/IECore/VectorTypedData.h index d9d2c4ccbe..80f10c2f1a 100644 --- a/include/IECore/VectorTypedData.h +++ b/include/IECore/VectorTypedData.h @@ -89,9 +89,7 @@ IECORE_DECLARE_TYPEDDATA( M44dVectorData, std::vector, double, Shar IECORE_DECLARE_TYPEDDATA( QuatfVectorData, std::vector, float, SharedDataHolder ) IECORE_DECLARE_TYPEDDATA( QuatdVectorData, std::vector, double, SharedDataHolder ) IECORE_DECLARE_TYPEDDATA( Color3fVectorData, std::vector, float, SharedDataHolder ) -IECORE_DECLARE_TYPEDDATA( Color3dVectorData, std::vector >, double, SharedDataHolder ) IECORE_DECLARE_TYPEDDATA( Color4fVectorData, std::vector, float, SharedDataHolder ) -IECORE_DECLARE_TYPEDDATA( Color4dVectorData, std::vector >, double, SharedDataHolder ) } // namespace IECore diff --git a/include/IECorePython/ImathPlaneBinding.h b/include/IECorePython/BoxAlgoBinding.h similarity index 87% rename from include/IECorePython/ImathPlaneBinding.h rename to include/IECorePython/BoxAlgoBinding.h index 35620d3792..33817fbafb 100644 --- a/include/IECorePython/ImathPlaneBinding.h +++ b/include/IECorePython/BoxAlgoBinding.h @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. +// Copyright (c) 2017, Image Engine Design Inc. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -32,16 +32,16 @@ // ////////////////////////////////////////////////////////////////////////// -#ifndef IECOREPYTHON_IMATHPLANEBINDING_H -#define IECOREPYTHON_IMATHPLANEBINDING_H +#ifndef IECOREPYTHON_BOXALGOBINDING_H +#define IECOREPYTHON_BOXALGOBINDING_H #include "IECorePython/Export.h" namespace IECorePython { -IECOREPYTHON_API void bindImathPlane(); +IECOREPYTHON_API void bindBoxAlgo(); -} +} // namespace IECorePython -#endif // IECOREPYTHON_IMATHPLANEBINDING_H +#endif // IECOREPYTHON_BOXALGOBINDING_H diff --git a/include/IECorePython/ImathBinding.h b/include/IECorePython/ImathBinding.h deleted file mode 100644 index 1972c32b19..0000000000 --- a/include/IECorePython/ImathBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREPYTHON_IMATHBINDING_H -#define IECOREPYTHON_IMATHBINDING_H - -#include "IECorePython/Export.h" - -namespace IECorePython -{ -IECOREPYTHON_API void bindImath(); -} - -#endif // IECOREPYTHON_IMATHBINDING_H diff --git a/include/IECorePython/ImathBoxBinding.h b/include/IECorePython/ImathBoxBinding.h deleted file mode 100644 index 372bc90975..0000000000 --- a/include/IECorePython/ImathBoxBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREPYTHON_IMATHBOXBINDING_H -#define IECOREPYTHON_IMATHBOXBINDING_H - -#include "IECorePython/Export.h" - -namespace IECorePython -{ -IECOREPYTHON_API void bindImathBox(); -} - -#endif // IECOREPYTHON_IMATHBOXBINDING_H diff --git a/include/IECorePython/ImathColorBinding.h b/include/IECorePython/ImathColorBinding.h deleted file mode 100644 index 624550c00e..0000000000 --- a/include/IECorePython/ImathColorBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREPYTHON_IMATHCOLORBINDING_H -#define IECOREPYTHON_IMATHCOLORBINDING_H - -#include "IECorePython/Export.h" - -namespace IECorePython -{ -IECOREPYTHON_API void bindImathColor(); -} - -#endif // IECOREPYTHON_IMATHCOLORBINDING_H diff --git a/include/IECorePython/ImathMatrixBinding.h b/include/IECorePython/ImathMatrixBinding.h deleted file mode 100644 index cb07e2afa6..0000000000 --- a/include/IECorePython/ImathMatrixBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREPYTHON_IMATHMATRIXBINDING_H -#define IECOREPYTHON_IMATHMATRIXBINDING_H - -#include "IECorePython/Export.h" - -namespace IECorePython -{ -IECOREPYTHON_API void bindImathMatrix(); -} - -#endif // IECOREPYTHON_IMATHMATRIXBINDING_H diff --git a/include/IECorePython/ImathQuatBinding.h b/include/IECorePython/ImathQuatBinding.h deleted file mode 100644 index 7819c250b8..0000000000 --- a/include/IECorePython/ImathQuatBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREPYTHON_IMATHQUATBINDING_H -#define IECOREPYTHON_IMATHQUATBINDING_H - -#include "IECorePython/Export.h" - -namespace IECorePython -{ -IECOREPYTHON_API void bindImathQuat(); -} - -#endif // IECOREPYTHON_IMATHQUATBINDING_H diff --git a/include/IECorePython/ImathRandomBinding.h b/include/IECorePython/ImathRandomBinding.h deleted file mode 100644 index b192098e17..0000000000 --- a/include/IECorePython/ImathRandomBinding.h +++ /dev/null @@ -1,47 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREPYTHON_IMATHRANDOMBINDING_H -#define IECOREPYTHON_IMATHRANDOMBINDING_H - -#include "IECorePython/Export.h" - -namespace IECorePython -{ - -IECOREPYTHON_API void bindImathRandom(); - -} - -#endif // IECOREPYTHON_IMATHRANDOMBINDING_H diff --git a/include/IECorePython/ImathRootsBinding.h b/include/IECorePython/ImathRootsBinding.h deleted file mode 100644 index 4a59738d7a..0000000000 --- a/include/IECorePython/ImathRootsBinding.h +++ /dev/null @@ -1,47 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREPYTHON_IMATHROOTSBINDING_H -#define IECOREPYTHON_IMATHROOTSBINDING_H - -#include "IECorePython/Export.h" - -namespace IECorePython -{ - -IECOREPYTHON_API void bindImathRoots(); - -} - -#endif // IECOREPYTHON_IMATHROOTSBINDING_H diff --git a/include/IECorePython/ImathVecBinding.h b/include/IECorePython/ImathVecBinding.h deleted file mode 100644 index afe9383a44..0000000000 --- a/include/IECorePython/ImathVecBinding.h +++ /dev/null @@ -1,47 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREPYTHON_IMATHVECBINDING_H -#define IECOREPYTHON_IMATHVECBINDING_H - -#include "IECorePython/Export.h" - -namespace IECorePython -{ - -IECOREPYTHON_API void bindImathVec(); - -} - -#endif // IECOREPYTHON_IMATHVECBINDING_H diff --git a/include/IECorePython/ImathEulerBinding.h b/include/IECorePython/RandomAlgoBinding.h similarity index 87% rename from include/IECorePython/ImathEulerBinding.h rename to include/IECorePython/RandomAlgoBinding.h index 810ddf52a9..1e2ef65691 100644 --- a/include/IECorePython/ImathEulerBinding.h +++ b/include/IECorePython/RandomAlgoBinding.h @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. +// Copyright (c) 2017, Image Engine Design Inc. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -32,16 +32,16 @@ // ////////////////////////////////////////////////////////////////////////// -#ifndef IECOREPYTHON_IMATHEULERBINDING_H -#define IECOREPYTHON_IMATHEULERBINDING_H +#ifndef IECOREPYTHON_RANDOMALGOBINDING_H +#define IECOREPYTHON_RANDOMALGOBINDING_H #include "IECorePython/Export.h" namespace IECorePython { -IECOREPYTHON_API void bindImathEuler(); +IECOREPYTHON_API void bindRandomAlgo(); -} +} // namespace IECorePython -#endif // IECOREPYTHON_IMATHEULERBINDING_H +#endif // IECOREPYTHON_RANDOMALGOBINDING_H diff --git a/python/IECore/ClassLsOp.py b/python/IECore/ClassLsOp.py index 5e5d03296c..2d2166a712 100644 --- a/python/IECore/ClassLsOp.py +++ b/python/IECore/ClassLsOp.py @@ -32,25 +32,26 @@ # ########################################################################## -from IECore import * import os import os.path -class ClassLsOp( Op ) : +import IECore + +class ClassLsOp( IECore.Op ) : def __init__( self ) : - Op.__init__( self, "Lists installed classes which can be loaded with IECore.ClassLoader.", - Parameter( + IECore.Op.__init__( self, "Lists installed classes which can be loaded with IECore.ClassLoader.", + IECore.Parameter( name = "result", description = "A list of classes.", - defaultValue = StringVectorData() + defaultValue = IECore.StringVectorData() ) ) self.parameters().addParameters( [ - StringParameter( + IECore.StringParameter( name = "type", description = "The type of class to list.", defaultValue = "op", @@ -60,23 +61,23 @@ def __init__( self ) : ), presetsOnly = True, ), - StringParameter( + IECore.StringParameter( name = "match", description = "A glob style match string used to list only a subset of classes.", defaultValue = "*", ), - StringParameter( + IECore.StringParameter( name = "searchPath", description = "When type is set to \"other\", this specifies a colon separated list of paths to search for classes on.", defaultValue = "", ), - StringParameter( + IECore.StringParameter( name = "searchPathEnvVar", description = "When type is set to \"other\", this specifies an environment variable " "specifying a list of paths to search for classes on.", defaultValue = "", ), - StringParameter( + IECore.StringParameter( name = "resultType", description = "The format of the result", defaultValue = "string", @@ -93,7 +94,7 @@ def doOperation( self, operands ) : t = operands["type"].value if t=="op" : - loader = ClassLoader.defaultOpLoader() + loader = IECore.ClassLoader.defaultOpLoader() else : if operands["searchPath"].value and operands["searchPathEnvVar"].value : raise RuntimeError( "Cannot specify both searchPath and searchPathEnvVar." ) @@ -101,17 +102,17 @@ def doOperation( self, operands ) : raise RuntimeError( "Must specify either searchPath or searchPathEnvVar." ) if operands["searchPath"].value : - sp = SearchPath( operands["searchPath"].value, ":" ) + sp = IECore.SearchPath( operands["searchPath"].value, ":" ) else : - sp = SearchPath( os.path.expandvars( os.environ[operands["searchPathEnvVar"].value] ), ":" ) + sp = IECore.SearchPath( os.path.expandvars( os.environ[operands["searchPathEnvVar"].value] ), ":" ) - loader = ClassLoader( sp ) + loader = IECore.ClassLoader( sp ) classes = loader.classNames( operands["match"].value ) if operands["resultType"].value == "string" : - return StringData( "\n".join( classes ) ) + return IECore.StringData( "\n".join( classes ) ) else : - return StringVectorData( classes ) + return IECore.StringVectorData( classes ) -registerRunTimeTyped( ClassLsOp ) +IECore.registerRunTimeTyped( ClassLsOp ) diff --git a/python/IECore/CompoundVectorParameter.py b/python/IECore/CompoundVectorParameter.py index dbf102a347..cc9eff3d69 100644 --- a/python/IECore/CompoundVectorParameter.py +++ b/python/IECore/CompoundVectorParameter.py @@ -32,38 +32,38 @@ # ########################################################################## -from IECore import * +import IECore ## This class is a CompoundParameter that only accepts vector parameters with the same length. # \ingroup python -class CompoundVectorParameter ( CompoundParameter ): +class CompoundVectorParameter ( IECore.CompoundParameter ): def __testParameterType( self, parameter ): data = parameter.getValue() - if not isSequenceDataType( data ): + if not IECore.isSequenceDataType( data ): raise TypeError, "The parameter %s cannot be added because it does not hold vector data object." % parameter.name # overwrites base class definition just to limit the parameter types accepted. def addParameter( self, parameter ): self.__testParameterType( parameter ) - CompoundParameter.addParameter( self, parameter ) + IECore.CompoundParameter.addParameter( self, parameter ) # overwrites base class definition just to limit the parameter types accepted. def addParameters( self, parameters ): for parameter in parameters: self.__testParameterType( parameter ) - CompoundParameter.addParameters( self, parameters ) + IECore.CompoundParameter.addParameters( self, parameters ) # overwrites base class definition just to limit the parameter types accepted. def insertParameter( self, parameter, other ): self.__testParameterType( parameter ) - CompoundParameter.insertParameter( self, parameter, other ) + IECore.CompoundParameter.insertParameter( self, parameter, other ) ## Returns true only if all the vector parameters are of the same length and they also validate ok. def valueValid( self, value ) : - res = CompoundParameter.valueValid( self, value ) + res = IECore.CompoundParameter.valueValid( self, value ) if not res[0]: return res @@ -81,4 +81,4 @@ def valueValid( self, value ) : return ( True, "" ) -registerRunTimeTyped( CompoundVectorParameter ) +IECore.registerRunTimeTyped( CompoundVectorParameter ) diff --git a/python/IECore/DataTraits.py b/python/IECore/DataTraits.py index 685e3cbc8c..2122423dbe 100644 --- a/python/IECore/DataTraits.py +++ b/python/IECore/DataTraits.py @@ -34,7 +34,9 @@ import string import datetime -import _IECore as IECore +import imath + +import IECore from Log import * ## Utility function that recognizes objects that are simple types. That means, @@ -73,19 +75,6 @@ def isSimpleNumericDataType(obj): return True return False -## Utility function that recognizes objects that hold values as matrices. -# For example the IMath types: V2f, M33f, Color3f. But not vectors of those types. -## \ingroup python -def isMatrixDataType(obj): - - if not hasattr(obj.__class__, "value"): - return False - ##\ todo: this attr doesn't guarantee a matrix or not. Quats and transformation matrices don't have dimension attrs - if hasattr(obj.value.__class__, "dimensions"): - # vectors, colors and matrices - return True - return False - ## Utility function that returns ``True`` if a Data object obj could be created with a dict. # ## \ingroup python @@ -128,34 +117,34 @@ def isSequenceDataType(obj): IECore.Int64Data: (int, False), IECore.UInt64Data: (int, False), - IECore.V2fDataBase: (IECore.V2f, True), - IECore.V2dDataBase: (IECore.V2d, True), - IECore.V2iDataBase: (IECore.V2i, True), - IECore.V3iDataBase: (IECore.V3i, True), - IECore.V3fDataBase: (IECore.V3f, True), - IECore.V3dDataBase: (IECore.V3d, True), - IECore.V2fData: (IECore.V2f, True), - IECore.V2dData: (IECore.V2d, True), - IECore.V2iData: (IECore.V2i, True), - IECore.V3iData: (IECore.V3i, True), - IECore.V3fData: (IECore.V3f, True), - IECore.V3dData: (IECore.V3d, True), - IECore.QuatfData: (IECore.Quatf, True), - IECore.QuatdData: (IECore.Quatd, True), - IECore.Color3fData: (IECore.Color3f, True), - IECore.Color3dData: (IECore.Color3d, True), - IECore.Color4fData: (IECore.Color4f, True), - IECore.Color4dData: (IECore.Color4d, True), - IECore.Box2iData: (IECore.Box2i, True), - IECore.Box3iData: (IECore.Box3i, True), - IECore.Box2fData: (IECore.Box2f, True), - IECore.Box2dData: (IECore.Box2d, True), - IECore.Box3fData: (IECore.Box3f, True), - IECore.Box3dData: (IECore.Box3d, True), - IECore.M33fData: (IECore.M33f, True), - IECore.M33dData: (IECore.M33d, True), - IECore.M44fData: (IECore.M44f, True), - IECore.M44dData: (IECore.M44d, True), + IECore.V2fDataBase: (imath.V2f, True), + IECore.V2dDataBase: (imath.V2d, True), + IECore.V2iDataBase: (imath.V2i, True), + IECore.V3iDataBase: (imath.V3i, True), + IECore.V3fDataBase: (imath.V3f, True), + IECore.V3dDataBase: (imath.V3d, True), + IECore.V2fData: (imath.V2f, True), + IECore.V2dData: (imath.V2d, True), + IECore.V2iData: (imath.V2i, True), + IECore.V3iData: (imath.V3i, True), + IECore.V3fData: (imath.V3f, True), + IECore.V3dData: (imath.V3d, True), + IECore.QuatfData: (imath.Quatf, True), + IECore.QuatdData: (imath.Quatd, True), + IECore.Color3fData: (imath.Color3f, True), + #IECore.Color3dData: (IECore.Color3d, True), + IECore.Color4fData: (imath.Color4f, True), + #IECore.Color4dData: (IECore.Color4d, True), + IECore.Box2iData: (imath.Box2i, True), + IECore.Box3iData: (imath.Box3i, True), + IECore.Box2fData: (imath.Box2f, True), + IECore.Box2dData: (imath.Box2d, True), + IECore.Box3fData: (imath.Box3f, True), + IECore.Box3dData: (imath.Box3d, True), + IECore.M33fData: (imath.M33f, True), + IECore.M33dData: (imath.M33d, True), + IECore.M44fData: (imath.M44f, True), + IECore.M44dData: (imath.M44d, True), IECore.BoolVectorData: ( list, False, bool), IECore.CharVectorData: (list, False, str), @@ -171,34 +160,34 @@ def isSequenceDataType(obj): IECore.UShortVectorData: (list, False, int), IECore.Int64VectorData: (list, False, int), IECore.UInt64VectorData: (list, False, int), - IECore.V2fVectorDataBase: (list, False, IECore.V2f), - IECore.V2dVectorDataBase: (list, False, IECore.V2d), - IECore.V2iVectorDataBase: (list, False, IECore.V2i), - IECore.V3fVectorDataBase: (list, False, IECore.V3f), - IECore.V3dVectorDataBase: (list, False, IECore.V3d), - IECore.V3iVectorDataBase: (list, False, IECore.V3i), - IECore.V2fVectorData: (list, False, IECore.V2f), - IECore.V2dVectorData: (list, False, IECore.V2d), - IECore.V2iVectorData: (list, False, IECore.V2i), - IECore.V3fVectorData: (list, False, IECore.V3f), - IECore.V3dVectorData: (list, False, IECore.V3d), - IECore.V3iVectorData: (list, False, IECore.V3i), - IECore.QuatfVectorData: (list, False, IECore.Quatf), - IECore.QuatdVectorData: (list, False, IECore.Quatd), - IECore.Box2iVectorData: (list, False, IECore.Box2i), - IECore.Box2fVectorData: (list, False, IECore.Box2f), - IECore.Box2dVectorData: (list, False, IECore.Box2d), - IECore.Box3iVectorData: (list, False, IECore.Box3i), - IECore.Box3fVectorData: (list, False, IECore.Box3f), - IECore.Box3dVectorData: (list, False, IECore.Box3d), - IECore.M33fVectorData: (list, False, IECore.M33f), - IECore.M33dVectorData: (list, False, IECore.M33d), - IECore.M44fVectorData: (list, False, IECore.M44f), - IECore.M44dVectorData: (list, False, IECore.M44d), - IECore.Color3fVectorData: (list, False, IECore.Color3f), - IECore.Color3dVectorData: (list, False, IECore.Color3d), - IECore.Color4fVectorData: (list, False, IECore.Color4f), - IECore.Color4dVectorData: (list, False, IECore.Color4d), + IECore.V2fVectorDataBase: (list, False, imath.V2f), + IECore.V2dVectorDataBase: (list, False, imath.V2d), + IECore.V2iVectorDataBase: (list, False, imath.V2i), + IECore.V3fVectorDataBase: (list, False, imath.V3f), + IECore.V3dVectorDataBase: (list, False, imath.V3d), + IECore.V3iVectorDataBase: (list, False, imath.V3i), + IECore.V2fVectorData: (list, False, imath.V2f), + IECore.V2dVectorData: (list, False, imath.V2d), + IECore.V2iVectorData: (list, False, imath.V2i), + IECore.V3fVectorData: (list, False, imath.V3f), + IECore.V3dVectorData: (list, False, imath.V3d), + IECore.V3iVectorData: (list, False, imath.V3i), + IECore.QuatfVectorData: (list, False, imath.Quatf), + IECore.QuatdVectorData: (list, False, imath.Quatd), + IECore.Box2iVectorData: (list, False, imath.Box2i), + IECore.Box2fVectorData: (list, False, imath.Box2f), + IECore.Box2dVectorData: (list, False, imath.Box2d), + IECore.Box3iVectorData: (list, False, imath.Box3i), + IECore.Box3fVectorData: (list, False, imath.Box3f), + IECore.Box3dVectorData: (list, False, imath.Box3d), + IECore.M33fVectorData: (list, False, imath.M33f), + IECore.M33dVectorData: (list, False, imath.M33d), + IECore.M44fVectorData: (list, False, imath.M44f), + IECore.M44dVectorData: (list, False, imath.M44d), + IECore.Color3fVectorData: (list, False, imath.Color3f), + #IECore.Color3dVectorData: (list, False, IECore.Color3d), + IECore.Color4fVectorData: (list, False, imath.Color4f), + #IECore.Color4dVectorData: (list, False, IECore.Color4d), IECore.CompoundData: (dict, True, None), IECore.CompoundDataBase: (dict, True, None), @@ -295,7 +284,7 @@ def dataFromElement(element): dataType = dataTypeFromElement(element) return dataType(element) -__all__ = [ "isSimpleDataType", "isSimpleNumericDataType", "isMatrixDataType", "isMappingDataType", +__all__ = [ "isSimpleDataType", "isSimpleNumericDataType", "isMappingDataType", "isSequenceDataType", "getDataDerivedTypes", "elementTypeFromDataType", "valueTypeFromSequenceType", "dataTypeFromElementType", "dataTypeFromElement", "dataFromElement", ] diff --git a/python/IECore/Log.py b/python/IECore/Log.py index 372b057ab1..14f016708b 100644 --- a/python/IECore/Log.py +++ b/python/IECore/Log.py @@ -35,7 +35,7 @@ import os, sys, traceback import inspect, string import warnings -from IECore import * +import IECore ## Set the environment variable and the current LevelFilteredMessageHandler. # Parameters: @@ -48,7 +48,7 @@ ## \ingroup python def setLogLevelByName( levelName ): - setLogLevel( MessageHandler.stringAsLevel( levelName ) ) + IECore.setLogLevel( IECore.MessageHandler.stringAsLevel( levelName ) ) ## Set the environment variable and the current LevelFilteredMessageHandler. # Parameters: @@ -60,18 +60,18 @@ def setLogLevelByName( levelName ): ## \ingroup python def setLogLevel( level ): - assert( isinstance( level, MessageHandler.Level ) and level!=MessageHandler.Level.Invalid ) + assert( isinstance( level, IECore.MessageHandler.Level ) and level!=IECore.MessageHandler.Level.Invalid ) - os.environ["IECORE_LOG_LEVEL"] = MessageHandler.levelAsString( level ) + os.environ["IECORE_LOG_LEVEL"] = IECore.MessageHandler.levelAsString( level ) - current = MessageHandler.currentHandler() - if not isinstance( current, LevelFilteredMessageHandler ) : - msg( Msg.Level.Warning, "IECore.setLogLevel", "Failed to set log level - current handler is not a LevelFilteredMessageHandler" ) + current = IECore.MessageHandler.currentHandler() + if not isinstance( current, IECore.LevelFilteredMessageHandler ) : + IECore.msg( IECore.Msg.Level.Warning, "IECore.setLogLevel", "Failed to set log level - current handler is not a LevelFilteredMessageHandler" ) return current.setLevel( level ) - debug("setLogLevel(", level, ")") + IECore.debug("setLogLevel(", level, ")") def __getCallStr(frame): return frame.f_globals.get("__name__", frame.f_globals.get("__file__", "N/A")) @@ -98,7 +98,7 @@ def showCallStack(): callstack += "> " + str(index) + ": " + __getCallStr(f) + " #" + str(f.f_lineno) + "\n" f = f.f_back index += 1 - Msg.output(Msg.Level.Debug, __getCallContext( withLineNumber = True ), callstack ) + IECore.Msg.output(IECore.Msg.Level.Debug, __getCallContext( withLineNumber = True ), callstack ) ## Use this function to get information about the context where the exception happened. # Returns a tuple of strings (location, stack trace) for the captured exception. @@ -127,7 +127,7 @@ def debugException(*args): exceptInfo = "" for (module, line, function, location) in etb: exceptInfo += "> File " + str(module) + ", line " + str(line) + ", in " + str(function) + "\n> " + str(location) + "\n" - Msg.output(Msg.Level.Debug, __getCallContext( withLineNumber = True ), "[EXCEPTION CAPTURED] " + stdStr + "\n> Exception traceback:\n" + exceptInfo + exceptionType) + IECore.Msg.output(IECore.Msg.Level.Debug, __getCallContext( withLineNumber = True ), "[EXCEPTION CAPTURED] " + stdStr + "\n> Exception traceback:\n" + exceptInfo + exceptionType) ## Sends debug messages to the current message handler. # Every message include information about the module and line number from where this function was called. @@ -137,7 +137,7 @@ def debugException(*args): def debug(*args): stdStr = string.join(map(str, args), " ") - Msg.output(Msg.Level.Debug, __getCallContext( withLineNumber = True ), stdStr ) + IECore.Msg.output(IECore.Msg.Level.Debug, __getCallContext( withLineNumber = True ), stdStr ) # Sends warning messages to the current message handler. # Parameters: @@ -146,7 +146,7 @@ def debug(*args): def warning(*args): stdStr = string.join(map(str, args), " ") - Msg.output(Msg.Level.Warning, __getCallContext(), stdStr ) + IECore.Msg.output(IECore.Msg.Level.Warning, __getCallContext(), stdStr ) # Sends info messages to the current message handler. # Parameters: @@ -155,7 +155,7 @@ def warning(*args): def info(*args): stdStr = string.join(map(str, args), " ") - Msg.output(Msg.Level.Info, __getCallContext(), stdStr ) + IECore.Msg.output(IECore.Msg.Level.Info, __getCallContext(), stdStr ) # Sends error messages to the current message handler. # Parameters: @@ -164,7 +164,7 @@ def info(*args): def error(*args): stdStr = string.join(map(str, args), " ") - Msg.output(Msg.Level.Error, __getCallContext(), stdStr ) + IECore.Msg.output(IECore.Msg.Level.Error, __getCallContext(), stdStr ) __all__ = [ "setLogLevelByName", "setLogLevel", "showCallStack", "exceptionInfo", "debugException", "debug", "warning", "info", "error", diff --git a/python/IECore/LsHeaderOp.py b/python/IECore/LsHeaderOp.py index 72ba16ef53..a21df8dfca 100644 --- a/python/IECore/LsHeaderOp.py +++ b/python/IECore/LsHeaderOp.py @@ -32,33 +32,33 @@ # ########################################################################## -from IECore import * +import IECore -class LsHeaderOp( Op ) : +class LsHeaderOp( IECore.Op ) : def __init__( self ) : - Op.__init__( self, "Lists the contents of Cortex file headers.", - Parameter( + IECore.Op.__init__( self, "Lists the contents of Cortex file headers.", + IECore.Parameter( name = "result", description = "A list of meta-data contained in the file header.", - defaultValue = StringVectorData() + defaultValue = IECore.StringVectorData() ) ) self.parameters().addParameters( [ - FileNameParameter( + IECore.FileNameParameter( name = "file", description = "The file to list the header from.", defaultValue = "", - check = FileNameParameter.CheckType.MustExist, - extensions = " ".join( Reader.supportedExtensions() ), + check = IECore.FileNameParameter.CheckType.MustExist, + extensions = " ".join( IECore.Reader.supportedExtensions() ), allowEmptyString = False, ), - StringParameter( + IECore.StringParameter( name = "resultType", description = "The format of the result", defaultValue = "string", @@ -71,20 +71,20 @@ def __init__( self ) : ] ) - self.userData()["UI"] = CompoundObject( + self.userData()["UI"] = IECore.CompoundObject( { - "showResult": BoolData( True ), - "closeAfterExecution": BoolData( True ), + "showResult": IECore.BoolData( True ), + "closeAfterExecution": IECore.BoolData( True ), } ) def doOperation( self, operands ) : try: - reader = Reader.create( operands["file"].value ) + reader = IECore.Reader.create( operands["file"].value ) headers = reader.readHeader() except: - debugException( "Error reading header" ) + IECore.debugException( "Error reading header" ) headers = None if headers is None: @@ -99,12 +99,12 @@ def formatCompound( compound, lines, level = 0 ): for key in compound.keys(): value = compound[ key ] - if isinstance( value, CompoundObject ) or isinstance( value, CompoundData ): + if isinstance( value, IECore.CompoundObject ) or isinstance( value, IECore.CompoundData ): lines.append( levelStr + key + ": " ) formatCompound( value, lines, level + 1 ) - elif isSimpleDataType( value ): + elif IECore.isSimpleDataType( value ): lines.append( levelStr + key + ": " + str(value.value) ) - elif isSequenceDataType( value ): + elif IECore.isSequenceDataType( value ): lines.append( levelStr + key + ": " + ", ".join( map( str, value ) ) ) else: lines.append( levelStr + key + ": " + str(value) ) @@ -113,8 +113,8 @@ def formatCompound( compound, lines, level = 0 ): formatCompound( headers, headerLines ) if operands.resultType.value == "string" : - return StringData( "\n".join( headerLines ) ) + return IECore.StringData( "\n".join( headerLines ) ) else : - return StringVectorData( headerLines ) + return IECore.StringVectorData( headerLines ) -registerRunTimeTyped( LsHeaderOp ) +IECore.registerRunTimeTyped( LsHeaderOp ) diff --git a/python/IECore/OptionalCompoundParameter.py b/python/IECore/OptionalCompoundParameter.py index 27c38242f9..4569fb81b4 100644 --- a/python/IECore/OptionalCompoundParameter.py +++ b/python/IECore/OptionalCompoundParameter.py @@ -32,8 +32,7 @@ # ########################################################################## -import _IECore as IECore -from IECore import registerRunTimeTyped +import IECore ## This class implements a CompoundParameter that do not validate optional parameters if they are undefined. # This CompoundParameter derived class allows one to set a group of obligatory parameters that should always @@ -115,4 +114,4 @@ def __setattr__( self, attrName, attrValue ): else: parameter.smartSetValue( attrValue ) -registerRunTimeTyped( OptionalCompoundParameter ) +IECore.registerRunTimeTyped( OptionalCompoundParameter ) diff --git a/python/IECore/ParameterParser.py b/python/IECore/ParameterParser.py index 16da767965..a534ef9c9a 100644 --- a/python/IECore/ParameterParser.py +++ b/python/IECore/ParameterParser.py @@ -34,6 +34,7 @@ ########################################################################## import inspect +import imath import IECore @@ -436,13 +437,13 @@ def __parseTransformationMatrix( dataType, args, parameter ) : raise SyntaxError( "Expected 29 values." ) if dataType == IECore.TransformationMatrixfData : - vecType = IECore.V3f - angleType = IECore.Eulerf - orientationType = IECore.Quatf + vecType = imath.V3f + angleType = imath.Eulerf + orientationType = imath.Quatf else : - vecType = IECore.V3d - angleType = IECore.Eulerd - orientationType = IECore.Quatd + vecType = imath.V3d + angleType = imath.Eulerd + orientationType = imath.Quatd t = type(dataType().value)() @@ -456,7 +457,7 @@ def __parseTransformationMatrix( dataType, args, parameter ) : del args[0:3] t.rotate = angleType( float(args[0]), float(args[1]), float(args[2] ) ) - t.rotate.setOrder( getattr( angleType.Order, args[3] ) ) + t.rotate.setOrder( getattr( imath.Eulerf, args[3] ) ) del args[0:4] t.rotationOrientation = orientationType( float(args[0]), float(args[1]), float(args[2] ), float(args[3]) ) @@ -507,18 +508,27 @@ def _serialiseUsingRepr( parameter, value ) : def __serialiseTransformationMatrix( parameter, value ) : + def serialiseVec( vec ) : + + return [ str( vec[x] ) for x in range( 0, vec.dimensions() ) ] + + def serialiseQuat( quat ) : + + return [ str( quat.r() ) ] + serialiseVec( quat.v() ) + t = value.value retList = [] - retList.extend( str(t.translate).split() ) - retList.extend( str(t.scale).split() ) - retList.extend( str(t.shear).split() ) - retList.extend( str(t.rotate).split() ) - retList.append( str(t.rotate.order()) ) - retList.extend( str(t.rotationOrientation).split() ) - retList.extend( str(t.rotatePivot).split() ) - retList.extend( str(t.rotatePivotTranslation).split() ) - retList.extend( str(t.scalePivot).split() ) - retList.extend( str(t.scalePivotTranslation).split() ) + retList.extend( serialiseVec( t.translate ) ) + retList.extend( serialiseVec( t.scale ) ) + retList.extend( serialiseVec( t.shear ) ) + retList.extend( serialiseVec( t.rotate ) ) + retList.append( str( t.rotate.order() ) ) + retList.extend( serialiseQuat( t.rotationOrientation ) ) + retList.extend( serialiseVec( t.rotatePivot ) ) + retList.extend( serialiseVec( t.rotatePivotTranslation ) ) + retList.extend( serialiseVec( t.scalePivot ) ) + retList.extend( serialiseVec( t.scalePivotTranslation ) ) + return retList def __serialiseObject( parameter, value ) : @@ -528,6 +538,31 @@ def __serialiseObject( parameter, value ) : buf = mio.buffer() return [ IECore.decToHexCharVector( buf ) ] +def __serialiseVec( parameter, value ) : + + vec = value.value + return [ str( vec[x] ) for x in range( 0, vec.dimensions() ) ] + +def __serialiseBox( parameter, value ) : + + box = value.value + result = [] + for vec in box.min(), box.max() : + for x in range( 0, vec.dimensions() ) : + result.append( str( vec[x] ) ) + + return result + +def __serialiseLineSegment( parameter, value ) : + + line = value.value + result = [] + for vec in line.p0, line.p1 : + for x in range( 0, vec.dimensions() ) : + result.append( str( vec[x] ) ) + + return result + ParameterParser.registerType( IECore.BoolParameter.staticTypeId(), __parseBool, __serialiseUsingStr ) ParameterParser.registerType( IECore.IntParameter.staticTypeId(), ( lambda args, parameter : __parseNumeric( IECore.IntData, True, args, parameter ) ), __serialiseUsingStr ) ParameterParser.registerType( IECore.FloatParameter.staticTypeId(), ( lambda args, parameter : __parseNumeric( IECore.FloatData, False, args, parameter ) ), __serialiseUsingStr ) @@ -545,24 +580,24 @@ def __serialiseObject( parameter, value ) : ParameterParser.registerType( IECore.IntVectorParameter.staticTypeId(), ( lambda args, parameter : __parseNumericArray( IECore.IntVectorData, True, args, parameter ) ), __serialiseUsingSplitStr ) ParameterParser.registerType( IECore.FloatVectorParameter.staticTypeId(), ( lambda args, parameter : __parseNumericArray( IECore.FloatVectorData, False, args, parameter ) ), __serialiseUsingSplitStr ) ParameterParser.registerType( IECore.DoubleVectorParameter.staticTypeId(), ( lambda args, parameter : __parseNumericArray( IECore.DoubleVectorData, False, args, parameter ) ), __serialiseUsingSplitStr ) -ParameterParser.registerType( IECore.V2iParameter.staticTypeId(), ( lambda args, parameter : __parseNumericCompound( IECore.V2iData, IECore.V2i, 2, True, args, parameter ) ), __serialiseUsingSplitStr ) -ParameterParser.registerType( IECore.V3iParameter.staticTypeId(), ( lambda args, parameter : __parseNumericCompound( IECore.V3iData, IECore.V3i, 3, True, args, parameter ) ), __serialiseUsingSplitStr ) -ParameterParser.registerType( IECore.V2fParameter.staticTypeId(), ( lambda args, parameter : __parseNumericCompound( IECore.V2fData, IECore.V2f, 2, False, args, parameter ) ), __serialiseUsingSplitStr ) -ParameterParser.registerType( IECore.V3fParameter.staticTypeId(), ( lambda args, parameter : __parseNumericCompound( IECore.V3fData, IECore.V3f, 3, False, args, parameter ) ), __serialiseUsingSplitStr ) -ParameterParser.registerType( IECore.V2dParameter.staticTypeId(), ( lambda args, parameter : __parseNumericCompound( IECore.V2dData, IECore.V2d, 2, False, args, parameter ) ), __serialiseUsingSplitStr ) -ParameterParser.registerType( IECore.V3dParameter.staticTypeId(), ( lambda args, parameter : __parseNumericCompound( IECore.V3dData, IECore.V3d, 3, False, args, parameter ) ), __serialiseUsingSplitStr ) -ParameterParser.registerType( IECore.Color3fParameter.staticTypeId(), ( lambda args, parameter : __parseNumericCompound( IECore.Color3fData, IECore.Color3f, 3, False, args, parameter ) ), __serialiseUsingSplitStr ) -ParameterParser.registerType( IECore.Color4fParameter.staticTypeId(), ( lambda args, parameter : __parseNumericCompound( IECore.Color4fData, IECore.Color4f, 4, False, args, parameter ) ), __serialiseUsingSplitStr ) -ParameterParser.registerType( IECore.M44fParameter.staticTypeId(), ( lambda args, parameter : __parseNumericCompound( IECore.M44fData, IECore.M44f, 16, False, args, parameter ) ), __serialiseUsingSplitStr ) -ParameterParser.registerType( IECore.M44dParameter.staticTypeId(), ( lambda args, parameter : __parseNumericCompound( IECore.M44dData, IECore.M44d, 16, False, args, parameter ) ), __serialiseUsingSplitStr ) -ParameterParser.registerType( IECore.Box2fParameter.staticTypeId(), ( lambda args, parameter : __parseBoxOrLine( IECore.Box2fData, IECore.Box2f, IECore.V2f, False, args, parameter ) ), __serialiseUsingSplitStr ) -ParameterParser.registerType( IECore.Box3fParameter.staticTypeId(), ( lambda args, parameter : __parseBoxOrLine( IECore.Box3fData, IECore.Box3f, IECore.V3f, False, args, parameter ) ), __serialiseUsingSplitStr ) -ParameterParser.registerType( IECore.Box2dParameter.staticTypeId(), ( lambda args, parameter : __parseBoxOrLine( IECore.Box2dData, IECore.Box2d, IECore.V2d, False, args, parameter ) ), __serialiseUsingSplitStr ) -ParameterParser.registerType( IECore.Box3dParameter.staticTypeId(), ( lambda args, parameter : __parseBoxOrLine( IECore.Box3dData, IECore.Box3d, IECore.V3d, False, args, parameter ) ), __serialiseUsingSplitStr ) -ParameterParser.registerType( IECore.Box2iParameter.staticTypeId(), ( lambda args, parameter : __parseBoxOrLine( IECore.Box2iData, IECore.Box2i, IECore.V2i, True, args, parameter ) ), __serialiseUsingSplitStr ) -ParameterParser.registerType( IECore.Box3iParameter.staticTypeId(), ( lambda args, parameter : __parseBoxOrLine( IECore.Box3iData, IECore.Box3i, IECore.V3i, True, args, parameter ) ), __serialiseUsingSplitStr ) -ParameterParser.registerType( IECore.LineSegment3fParameter.staticTypeId(), ( lambda args, parameter : __parseBoxOrLine( IECore.LineSegment3fData, IECore.LineSegment3f, IECore.V3f, False, args, parameter ) ), __serialiseUsingSplitStr ) -ParameterParser.registerType( IECore.LineSegment3dParameter.staticTypeId(), ( lambda args, parameter : __parseBoxOrLine( IECore.LineSegment3dData, IECore.LineSegment3d, IECore.V3d, False, args, parameter ) ), __serialiseUsingSplitStr ) +ParameterParser.registerType( IECore.V2iParameter.staticTypeId(), ( lambda args, parameter : __parseNumericCompound( IECore.V2iData, imath.V2i, 2, True, args, parameter ) ), __serialiseVec ) +ParameterParser.registerType( IECore.V3iParameter.staticTypeId(), ( lambda args, parameter : __parseNumericCompound( IECore.V3iData, imath.V3i, 3, True, args, parameter ) ), __serialiseVec ) +ParameterParser.registerType( IECore.V2fParameter.staticTypeId(), ( lambda args, parameter : __parseNumericCompound( IECore.V2fData, imath.V2f, 2, False, args, parameter ) ), __serialiseVec ) +ParameterParser.registerType( IECore.V3fParameter.staticTypeId(), ( lambda args, parameter : __parseNumericCompound( IECore.V3fData, imath.V3f, 3, False, args, parameter ) ), __serialiseVec ) +ParameterParser.registerType( IECore.V2dParameter.staticTypeId(), ( lambda args, parameter : __parseNumericCompound( IECore.V2dData, imath.V2d, 2, False, args, parameter ) ), __serialiseVec ) +ParameterParser.registerType( IECore.V3dParameter.staticTypeId(), ( lambda args, parameter : __parseNumericCompound( IECore.V3dData, imath.V3d, 3, False, args, parameter ) ), __serialiseVec ) +ParameterParser.registerType( IECore.Color3fParameter.staticTypeId(), ( lambda args, parameter : __parseNumericCompound( IECore.Color3fData, imath.Color3f, 3, False, args, parameter ) ), __serialiseVec ) +ParameterParser.registerType( IECore.Color4fParameter.staticTypeId(), ( lambda args, parameter : __parseNumericCompound( IECore.Color4fData, imath.Color4f, 4, False, args, parameter ) ), __serialiseVec ) +ParameterParser.registerType( IECore.M44fParameter.staticTypeId(), ( lambda args, parameter : __parseNumericCompound( IECore.M44fData, imath.M44f, 16, False, args, parameter ) ), __serialiseUsingSplitStr ) +ParameterParser.registerType( IECore.M44dParameter.staticTypeId(), ( lambda args, parameter : __parseNumericCompound( IECore.M44dData, imath.M44d, 16, False, args, parameter ) ), __serialiseUsingSplitStr ) +ParameterParser.registerType( IECore.Box2fParameter.staticTypeId(), ( lambda args, parameter : __parseBoxOrLine( IECore.Box2fData, imath.Box2f, imath.V2f, False, args, parameter ) ), __serialiseBox ) +ParameterParser.registerType( IECore.Box3fParameter.staticTypeId(), ( lambda args, parameter : __parseBoxOrLine( IECore.Box3fData, imath.Box3f, imath.V3f, False, args, parameter ) ), __serialiseBox ) +ParameterParser.registerType( IECore.Box2dParameter.staticTypeId(), ( lambda args, parameter : __parseBoxOrLine( IECore.Box2dData, imath.Box2d, imath.V2d, False, args, parameter ) ), __serialiseBox ) +ParameterParser.registerType( IECore.Box3dParameter.staticTypeId(), ( lambda args, parameter : __parseBoxOrLine( IECore.Box3dData, imath.Box3d, imath.V3d, False, args, parameter ) ), __serialiseBox ) +ParameterParser.registerType( IECore.Box2iParameter.staticTypeId(), ( lambda args, parameter : __parseBoxOrLine( IECore.Box2iData, imath.Box2i, imath.V2i, True, args, parameter ) ), __serialiseBox ) +ParameterParser.registerType( IECore.Box3iParameter.staticTypeId(), ( lambda args, parameter : __parseBoxOrLine( IECore.Box3iData, imath.Box3i, imath.V3i, True, args, parameter ) ), __serialiseBox ) +ParameterParser.registerType( IECore.LineSegment3fParameter.staticTypeId(), ( lambda args, parameter : __parseBoxOrLine( IECore.LineSegment3fData, IECore.LineSegment3f, imath.V3f, False, args, parameter ) ), __serialiseLineSegment ) +ParameterParser.registerType( IECore.LineSegment3dParameter.staticTypeId(), ( lambda args, parameter : __parseBoxOrLine( IECore.LineSegment3dData, IECore.LineSegment3d, imath.V3d, False, args, parameter ) ), __serialiseLineSegment ) ParameterParser.registerType( IECore.SplineffParameter.staticTypeId(), None, _serialiseUsingRepr ) ParameterParser.registerType( IECore.SplinefColor3fParameter.staticTypeId(), None, _serialiseUsingRepr ) ParameterParser.registerType( IECore.TransformationMatrixfParameter.staticTypeId(), ( lambda args, parameter : __parseTransformationMatrix( IECore.TransformationMatrixfData, args, parameter ) ), __serialiseTransformationMatrix ) diff --git a/python/IECore/SearchReplaceOp.py b/python/IECore/SearchReplaceOp.py index 8482ea2963..b06fbe026e 100644 --- a/python/IECore/SearchReplaceOp.py +++ b/python/IECore/SearchReplaceOp.py @@ -36,14 +36,14 @@ import tempfile import os import re -from IECore import * +import IECore -class SearchReplaceOp( Op ) : +class SearchReplaceOp( IECore.Op ) : def __init__( self ) : - Op.__init__( self, "Performs a search and replace on ASCII text files.", - FileNameParameter( + IECore.Op.__init__( self, "Performs a search and replace on ASCII text files.", + IECore.FileNameParameter( name = "result", description = "The resulting file. Maya be the same as the input file.", defaultValue = "", @@ -53,31 +53,31 @@ def __init__( self ) : self.parameters().addParameters( [ - FileNameParameter( + IECore.FileNameParameter( name = "source", description = "The source file.", defaultValue = "", extensions = "ma rib shk nk", - check = FileNameParameter.CheckType.MustExist, + check = IECore.FileNameParameter.CheckType.MustExist, allowEmptyString = False, ), - FileNameParameter( + IECore.FileNameParameter( name = "destination", description = "The destination file.", defaultValue = "", allowEmptyString = False, ), - StringParameter( + IECore.StringParameter( name = "searchFor", description = "The pattern to search for", defaultValue = "", ), - BoolParameter( + IECore.BoolParameter( name = "regexpSearch", description = "Enable to perform searching based on regular expressions", defaultValue = False ), - StringParameter( + IECore.StringParameter( name = "replaceWith", description = "The string with which to replace patterns which match the search criteria", defaultValue = "", @@ -131,6 +131,6 @@ def doOperation( self, operands ) : os.chmod( destination, inFileStat ) - return StringData( destination ) + return IECore.StringData( destination ) -registerRunTimeTyped( SearchReplaceOp ) +IECore.registerRunTimeTyped( SearchReplaceOp ) diff --git a/python/IECore/SequenceCatOp.py b/python/IECore/SequenceCatOp.py index 51b4f52ebf..f582ab8958 100644 --- a/python/IECore/SequenceCatOp.py +++ b/python/IECore/SequenceCatOp.py @@ -32,14 +32,14 @@ # ########################################################################## -from IECore import * +import IECore -class SequenceCatOp( Op ) : +class SequenceCatOp( IECore.Op ) : def __init__( self ) : - Op.__init__( self, "Concatenates file sequences to stdout.", - IntParameter( + IECore.Op.__init__( self, "Concatenates file sequences to stdout.", + IECore.IntParameter( name = "result", description = "The number of files .", defaultValue = 0, @@ -47,11 +47,11 @@ def __init__( self ) : ) self.parameters().addParameter( - FileSequenceParameter( + IECore.FileSequenceParameter( name = "src", description = "The source file sequence.", defaultValue = "", - check = FileSequenceParameter.CheckType.MustExist, + check = IECore.FileSequenceParameter.CheckType.MustExist, allowEmptyString = False, minSequenceSize = 1, ) @@ -61,8 +61,8 @@ def doOperation( self, operands ) : src = self.parameters()["src"].getFileSequenceValue() - cat( src ) + IECore.cat( src ) - return IntData( len( src.fileNames() ) ) + return IECore.IntData( len( src.fileNames() ) ) -registerRunTimeTyped( SequenceCatOp ) +IECore.registerRunTimeTyped( SequenceCatOp ) diff --git a/python/IECore/SequenceConvertOp.py b/python/IECore/SequenceConvertOp.py index ca2504db81..5aa8cf7d34 100755 --- a/python/IECore/SequenceConvertOp.py +++ b/python/IECore/SequenceConvertOp.py @@ -32,26 +32,26 @@ # ########################################################################## -from IECore import * +import IECore -class SequenceConvertOp( Op ) : +class SequenceConvertOp( IECore.Op ) : def __init__( self ) : - Op.__init__( self, + IECore.Op.__init__( self, "This Op converts file sequences from one format to another. " "It supports all input formats for which a reader is available " - "(" + " ".join( Reader.supportedExtensions() ) + ") and all output " - "formats for which a writer is available (" + " ".join( Reader.supportedExtensions() ) + "). " + "(" + " ".join( IECore.Reader.supportedExtensions() ) + ") and all output " + "formats for which a writer is available (" + " ".join( IECore.Reader.supportedExtensions() ) + "). " "Because of it's general nature it doesn't support any additional options such as " "compression types for image formats. Also please note that not all combinations are " "possible - for instance you cannot convert an OBJ to a JPEG." , - FileSequenceParameter( + IECore.FileSequenceParameter( name = "result", description = "The new file sequence.", defaultValue = "", - check = FileSequenceParameter.CheckType.DontCare, + check = IECore.FileSequenceParameter.CheckType.DontCare, allowEmptyString = True, minSequenceSize = 1, ) @@ -59,22 +59,22 @@ def __init__( self ) : self.parameters().addParameters( [ - FileSequenceParameter( + IECore.FileSequenceParameter( name = "src", description = "The source file sequence.", defaultValue = "", - check = FileSequenceParameter.CheckType.MustExist, + check = IECore.FileSequenceParameter.CheckType.MustExist, allowEmptyString = False, - extensions = Reader.supportedExtensions(), + extensions = IECore.Reader.supportedExtensions(), minSequenceSize = 1, ), - FileSequenceParameter( + IECore.FileSequenceParameter( name = "dst", description = "The destination file sequence.", defaultValue = "", - check = FileSequenceParameter.CheckType.MustNotExist, + check = IECore.FileSequenceParameter.CheckType.MustNotExist, allowEmptyString = False, - extensions = Writer.supportedExtensions(), + extensions = IECore.Writer.supportedExtensions(), minSequenceSize = 1, ) ] @@ -85,21 +85,21 @@ def doOperation( self, operands ) : src = self.parameters()["src"].getFileSequenceValue() dst = self.parameters()["dst"].getFileSequenceValue() # if no frame list is specified on the dst parameter, then we use the same as src parameter. - if isinstance( dst.frameList, EmptyFrameList ): + if isinstance( dst.frameList, IECore.EmptyFrameList ): dst.frameList = src.frameList # compare extensions, if extensions match, simply copy if src.fileName.split('.')[-1] == dst.fileName.split('.')[-1]: - cpOp = SequenceCpOp() + cpOp = IECore.SequenceCpOp() cpOp['src'] = operands["src"] cpOp['dst'] = operands["dst"] cpOp() else: # if extensions don't match, read and write for (sf, df) in zip(src.fileNames(), dst.fileNames()): - img = Reader.create(sf).read() - Writer.create(img, df).write() + img = IECore.Reader.create(sf).read() + IECore.Writer.create(img, df).write() - return StringData(str(dst)) + return IECore.StringData(str(dst)) -registerRunTimeTyped( SequenceConvertOp ) +IECore.registerRunTimeTyped( SequenceConvertOp ) diff --git a/python/IECore/SequenceCpOp.py b/python/IECore/SequenceCpOp.py index 9b8c679b09..0dcea75a1e 100644 --- a/python/IECore/SequenceCpOp.py +++ b/python/IECore/SequenceCpOp.py @@ -32,37 +32,37 @@ # ########################################################################## -from IECore import * +import IECore -class SequenceCpOp( Op ) : +class SequenceCpOp( IECore.Op ) : def __init__( self ) : - Op.__init__( self, "Copies file sequences.", - FileSequenceParameter( + IECore.Op.__init__( self, "Copies file sequences.", + IECore.FileSequenceParameter( name = "result", description = "The new file sequence.", defaultValue = "", - check = FileSequenceParameter.CheckType.DontCare, + check = IECore.FileSequenceParameter.CheckType.DontCare, allowEmptyString = True, ) ) self.parameters().addParameters( [ - FileSequenceParameter( + IECore.FileSequenceParameter( name = "src", description = "The source file sequence.", defaultValue = "", - check = FileSequenceParameter.CheckType.MustExist, + check = IECore.FileSequenceParameter.CheckType.MustExist, allowEmptyString = False, minSequenceSize = 1, ), - FileSequenceParameter( + IECore.FileSequenceParameter( name = "dst", description = "The destination file sequence.", defaultValue = "", - check = FileSequenceParameter.CheckType.MustNotExist, + check = IECore.FileSequenceParameter.CheckType.MustNotExist, allowEmptyString = False, minSequenceSize = 1, ) @@ -74,11 +74,11 @@ def doOperation( self, operands ) : src = self.parameters()["src"].getFileSequenceValue() dst = self.parameters()["dst"].getFileSequenceValue() # if no frame list is specified on the dst parameter, then we use the same as src parameter. - if isinstance( dst.frameList, EmptyFrameList ): + if isinstance( dst.frameList, IECore.EmptyFrameList ): dst.frameList = src.frameList - cp( src, dst ) + IECore.cp( src, dst ) - return StringData( str(dst) ) + return IECore.StringData( str(dst) ) -registerRunTimeTyped( SequenceCpOp ) +IECore.registerRunTimeTyped( SequenceCpOp ) diff --git a/python/IECore/SequenceLsOp.py b/python/IECore/SequenceLsOp.py index 39d55785ba..2371a486a4 100644 --- a/python/IECore/SequenceLsOp.py +++ b/python/IECore/SequenceLsOp.py @@ -32,61 +32,61 @@ # ########################################################################## -from IECore import * +import IECore import os import os.path import datetime -class SequenceLsOp( Op ) : +class SequenceLsOp( IECore.Op ) : def __init__( self ) : - Op.__init__( self, "Lists file sequences.", - Parameter( + IECore.Op.__init__( self, "Lists file sequences.", + IECore.Parameter( name = "result", description = "A list of matching sequences.", - defaultValue = StringVectorData() + defaultValue = IECore.StringVectorData() ) ) - self.userData()["UI"] = CompoundObject( + self.userData()["UI"] = IECore.CompoundObject( { - "showResult": BoolData( True ), + "showResult": IECore.BoolData( True ), } ) self.parameters().addParameters( [ - DirNameParameter( + IECore.DirNameParameter( name = "dir", description = "The directory to look for sequences in.", defaultValue = "./", - check = DirNameParameter.CheckType.MustExist, + check = IECore.DirNameParameter.CheckType.MustExist, allowEmptyString = False, ), - BoolParameter( + IECore.BoolParameter( name = "recurse", description = "When on, recursively searches all subdirectories for sequences.", defaultValue = False, ), - BoolParameter( + IECore.BoolParameter( name = "followLinks", description = "When on, follow symbolic links during directory traversal.", defaultValue = False, ), - IntParameter( + IECore.IntParameter( name = "maxDepth", description = "The maximum depth to recursion - this can be used to prevent accidental traversing of huge hierarchies.", defaultValue = 1000, minValue = 1, ), - IntParameter( + IECore.IntParameter( name = "minSequenceSize", description = "The minimum number of files to be considered a sequence", defaultValue = 2, minValue = 1, ), - StringParameter( + IECore.StringParameter( name = "type", description = "The file types of the sequences to classify.", defaultValue = "any", @@ -97,7 +97,7 @@ def __init__( self ) : ), presetsOnly = True, ), - StringParameter( + IECore.StringParameter( name = "resultType", description = "The type of the result returned.", defaultValue = "string", @@ -107,12 +107,12 @@ def __init__( self ) : ), presetsOnly = True, ), - BoolParameter( + IECore.BoolParameter( name = "contiguousSequencesOnly", description = "When on, only sequences without missing frames are returned.", defaultValue = False, ), - StringParameter( + IECore.StringParameter( name = "format", description = "The format of the result. This can be used to return strings suitable for viewing a sequence in a particular package.", defaultValue = "<#PADDING> ", @@ -124,31 +124,31 @@ def __init__( self ) : ( "rv", "rv <#PADDING>" ), ) ), - StringVectorParameter( + IECore.StringVectorParameter( name = "extensions", description = "A list of file extensions which the sequences must have if they are to be listed. An empty list" "means that any sequence will be listed. The . character should be omitted from the extension.", - defaultValue = StringVectorData(), + defaultValue = IECore.StringVectorData(), presets = ( - ( "images", StringVectorData( [ "tif", "tiff", "jpg", "jpeg", "exr", "cin", "dpx", "ppm", "png", "gif", "iff", "raw", "cr2" ] ) ), + ( "images", IECore.StringVectorData( [ "tif", "tiff", "jpg", "jpeg", "exr", "cin", "dpx", "ppm", "png", "gif", "iff", "raw", "cr2" ] ) ), ) ), - CompoundParameter( + IECore.CompoundParameter( name = "advanced", description = "Advanced paramaters for filtering results based on various criteria", members = [ - CompoundParameter( + IECore.CompoundParameter( name = "modificationTime", description = "Controls for filtering results based on modification time", members = [ - BoolParameter( + IECore.BoolParameter( name = "enabled", description = "Enable filtering based on modification time", defaultValue = False ), - StringParameter( + IECore.StringParameter( name = "mode", description = "Changes the mode of modified time operation, e.g. before or after", defaultValue = "before", @@ -162,12 +162,12 @@ def __init__( self ) : ), # \todo Use a TimePeriodParameter here instead of seaprate start/end times - DateTimeParameter( + IECore.DateTimeParameter( name = "startTime", description = "The (local) start time at which to make modification time comparisons against", defaultValue = datetime.datetime.now() ), - DateTimeParameter( + IECore.DateTimeParameter( name = "endTime", description = "The (local) end time at which to make modification time comparisons against", defaultValue = datetime.datetime.now() @@ -204,7 +204,7 @@ def __walk(top, topdown=True, followlinks=False): for name in dirs: path = join(top, name) if followlinks or not islink(path): - for x in SequenceLsOp.__walk(path, topdown, followlinks): + for x in IECore.SequenceLsOp.__walk(path, topdown, followlinks): yield x if not topdown: @@ -218,7 +218,7 @@ def doOperation( self, operands ) : if baseDirectory != "/" and baseDirectory[-1] == '/' : baseDirectory = baseDirectory[:-1] - sequences = ls( baseDirectory, operands["minSequenceSize"].value ) + sequences = IECore.ls( baseDirectory, operands["minSequenceSize"].value ) # If we've passed in a directory which isn't the current one it is convenient to get that included in the returned sequence names relDir = os.path.normpath( baseDirectory ) != "." @@ -229,7 +229,7 @@ def doOperation( self, operands ) : if operands["recurse"].value : # \todo Can safely use os.walk here after Python 2.6, which introduced the followlinks parameter - for root, dirs, files in SequenceLsOp.__walk( baseDirectory, topdown = True, followlinks = operands["followLinks"].value ) : + for root, dirs, files in IECore.SequenceLsOp.__walk( baseDirectory, topdown = True, followlinks = operands["followLinks"].value ) : relRoot = root[len(baseDirectory)+1:] if relRoot!="" : depth = len( relRoot.split( "/" ) ) @@ -240,7 +240,7 @@ def doOperation( self, operands ) : dirs[:] = [] for d in dirs : - ss = ls( os.path.join( root, d ), operands["minSequenceSize"].value ) + ss = IECore.ls( os.path.join( root, d ), operands["minSequenceSize"].value ) if ss : for s in ss : @@ -384,8 +384,8 @@ def matchAnyFilter( sequence ) : # return the result as the requested type if operands["resultType"].value == "string" : - return StringData( "\n".join( sequences ) ) + return IECore.StringData( "\n".join( sequences ) ) else : - return StringVectorData( sequences ) + return IECore.StringVectorData( sequences ) -registerRunTimeTyped( SequenceLsOp ) +IECore.registerRunTimeTyped( SequenceLsOp ) diff --git a/python/IECore/SequenceMergeOp.py b/python/IECore/SequenceMergeOp.py index a312b54a69..2d5ac426ab 100644 --- a/python/IECore/SequenceMergeOp.py +++ b/python/IECore/SequenceMergeOp.py @@ -35,51 +35,51 @@ # \ingroup python import os -from IECore import * +import IECore # The SequenceMergeOp is a base class for Ops which perform merging of two file sequences into a single file sequence. -class SequenceMergeOp( Op ) : +class SequenceMergeOp( IECore.Op ) : def __init__( self, description, extensions = [] ) : assert( type( extensions ) is list ) - Op.__init__( + IECore.Op.__init__( self, description, - StringVectorParameter( + IECore.StringVectorParameter( name = "result", description = "The names of the files created", - defaultValue = StringVectorData([]) + defaultValue = IECore.StringVectorData([]) ) ) self.parameters().addParameters( [ - FileSequenceParameter( + IECore.FileSequenceParameter( name = "fileSequence1", description = "The first input sequence", defaultValue = "", - check = FileSequenceParameter.CheckType.MustExist, + check = IECore.FileSequenceParameter.CheckType.MustExist, allowEmptyString = False, extensions = extensions, minSequenceSize = 1, ), - FileSequenceParameter( + IECore.FileSequenceParameter( name = "fileSequence2", description = "The second input sequence", defaultValue = "", - check = FileSequenceParameter.CheckType.MustExist, + check = IECore.FileSequenceParameter.CheckType.MustExist, allowEmptyString = False, extensions = extensions, minSequenceSize = 1, ), - FileSequenceParameter( + IECore.FileSequenceParameter( name = "outputFileSequence", description = "The output file sequence to generate. For each frame in this sequence, the corresponding inputs for that frame are merged", defaultValue = "", allowEmptyString = False, - check = FileSequenceParameter.CheckType.MustNotExist, + check = IECore.FileSequenceParameter.CheckType.MustNotExist, minSequenceSize = 1, ), ] @@ -109,6 +109,6 @@ def doOperation( self, args ) : resultFiles.append( outputFileName ) - return StringVectorData( resultFiles ) + return IECore.StringVectorData( resultFiles ) -registerRunTimeTyped( SequenceMergeOp ) +IECore.registerRunTimeTyped( SequenceMergeOp ) diff --git a/python/IECore/SequenceMvOp.py b/python/IECore/SequenceMvOp.py index 5ee17186a9..be92e07c9e 100644 --- a/python/IECore/SequenceMvOp.py +++ b/python/IECore/SequenceMvOp.py @@ -32,18 +32,18 @@ # ########################################################################## -from IECore import * +import IECore -class SequenceMvOp( Op ) : +class SequenceMvOp( IECore.Op ) : def __init__( self ) : - Op.__init__( self, "Moves file sequences.", - FileSequenceParameter( + IECore.Op.__init__( self, "Moves file sequences.", + IECore.FileSequenceParameter( name = "result", description = "The new file sequence.", defaultValue = "", - check = FileSequenceParameter.CheckType.DontCare, + check = IECore.FileSequenceParameter.CheckType.DontCare, allowEmptyString = True, minSequenceSize = 1, ) @@ -51,19 +51,19 @@ def __init__( self ) : self.parameters().addParameters( [ - FileSequenceParameter( + IECore.FileSequenceParameter( name = "src", description = "The source file sequence.", defaultValue = "", - check = FileSequenceParameter.CheckType.MustExist, + check = IECore.FileSequenceParameter.CheckType.MustExist, allowEmptyString = False, minSequenceSize = 1, ), - FileSequenceParameter( + IECore.FileSequenceParameter( name = "dst", description = "The destination file sequence.", defaultValue = "", - check = FileSequenceParameter.CheckType.MustNotExist, + check = IECore.FileSequenceParameter.CheckType.MustNotExist, allowEmptyString = False, minSequenceSize = 1, ) @@ -75,11 +75,11 @@ def doOperation( self, operands ) : src = self.parameters()["src"].getFileSequenceValue() dst = self.parameters()["dst"].getFileSequenceValue() # if no frame list is specified on the dst parameter, then we use the same as src parameter. - if isinstance( dst.frameList, EmptyFrameList ): + if isinstance( dst.frameList, IECore.EmptyFrameList ): dst.frameList = src.frameList - mv( src, dst ) + IECore.mv( src, dst ) - return StringData( str(dst) ) + return IECore.StringData( str(dst) ) -registerRunTimeTyped( SequenceMvOp ) +IECore.registerRunTimeTyped( SequenceMvOp ) diff --git a/python/IECore/SequenceRenumberOp.py b/python/IECore/SequenceRenumberOp.py index 3b6ca4276d..e3a73a0483 100644 --- a/python/IECore/SequenceRenumberOp.py +++ b/python/IECore/SequenceRenumberOp.py @@ -32,18 +32,18 @@ # ########################################################################## -from IECore import * +import IECore -class SequenceRenumberOp( Op ) : +class SequenceRenumberOp( IECore.Op ) : def __init__( self ) : - Op.__init__( self, "Renumbers file sequences.", - FileSequenceParameter( + IECore.Op.__init__( self, "Renumbers file sequences.", + IECore.FileSequenceParameter( name = "result", description = "The new file sequence.", defaultValue = "", - check = FileSequenceParameter.CheckType.DontCare, + check = IECore.FileSequenceParameter.CheckType.DontCare, allowEmptyString = True, minSequenceSize = 1, ) @@ -51,28 +51,28 @@ def __init__( self ) : self.parameters().addParameters( [ - FileSequenceParameter( + IECore.FileSequenceParameter( name = "src", description = "The source file sequence.", defaultValue = "", - check = FileSequenceParameter.CheckType.MustExist, + check = IECore.FileSequenceParameter.CheckType.MustExist, allowEmptyString = False, minSequenceSize = 1, ), - FileSequenceParameter( + IECore.FileSequenceParameter( name = "dst", description = "The destination file sequence. This may be left blank, in which case the source sequence is renumbered in place.", defaultValue = "", - check = FileSequenceParameter.CheckType.DontCare, + check = IECore.FileSequenceParameter.CheckType.DontCare, allowEmptyString = True, minSequenceSize = 1, ), - IntParameter( + IECore.IntParameter( name = "multiply", description = "A number multiplied with each frame number before offsetting.", defaultValue = 1, ), - IntParameter( + IECore.IntParameter( name = "offset", description = "A number added to each frame number after multiplication.", defaultValue = 0, @@ -89,10 +89,10 @@ def doOperation( self, operands ) : frames = [ x * operands["multiply"].value + operands["offset"].value for x in src.frameList.asList() ] - dst.frameList = frameListFromList( frames ) + dst.frameList = IECore.frameListFromList( frames ) - mv( src, dst ) + IECore.mv( src, dst ) - return StringData( dst.fileName ) + return IECore.StringData( dst.fileName ) -registerRunTimeTyped( SequenceRenumberOp ) +IECore.registerRunTimeTyped( SequenceRenumberOp ) diff --git a/python/IECore/SequenceRmOp.py b/python/IECore/SequenceRmOp.py index 7d94d6e20c..10752a228d 100644 --- a/python/IECore/SequenceRmOp.py +++ b/python/IECore/SequenceRmOp.py @@ -32,18 +32,18 @@ # ########################################################################## -from IECore import * +import IECore -class SequenceRmOp( Op ) : +class SequenceRmOp( IECore.Op ) : def __init__( self ) : - Op.__init__( self, "Removes file sequences.", - FileSequenceParameter( + IECore.Op.__init__( self, "Removes file sequences.", + IECore.FileSequenceParameter( name = "result", description = "The removed file sequence.", defaultValue = "", - check = FileSequenceParameter.CheckType.DontCare, + check = IECore.FileSequenceParameter.CheckType.DontCare, allowEmptyString = True, minSequenceSize = 1, ) @@ -51,11 +51,11 @@ def __init__( self ) : self.parameters().addParameters( [ - FileSequenceParameter( + IECore.FileSequenceParameter( name = "seq", description = "The file sequence to remove.", defaultValue = "", - check = FileSequenceParameter.CheckType.MustExist, + check = IECore.FileSequenceParameter.CheckType.MustExist, allowEmptyString = False, minSequenceSize = 1, ) @@ -64,8 +64,8 @@ def __init__( self ) : def doOperation( self, operands ) : - rm( self.parameters()["seq"].getFileSequenceValue() ) + IECore.rm( self.parameters()["seq"].getFileSequenceValue() ) - return StringData( operands["seq"].value ) + return IECore.StringData( operands["seq"].value ) -registerRunTimeTyped( SequenceRmOp ) +IECore.registerRunTimeTyped( SequenceRmOp ) diff --git a/python/IECore/__init__.py b/python/IECore/__init__.py index 5c8250a50a..4a932270c2 100644 --- a/python/IECore/__init__.py +++ b/python/IECore/__init__.py @@ -52,6 +52,8 @@ __import__( "sys" ).getdlopenflags() | __import__( "ctypes" ).RTLD_GLOBAL ) +__import__( "imath" ) + from _IECore import * # access by a shorter name for convenience diff --git a/python/IECoreNuke/FnAxis.py b/python/IECoreNuke/FnAxis.py index f2530bd2c2..2a7aa4c659 100644 --- a/python/IECoreNuke/FnAxis.py +++ b/python/IECoreNuke/FnAxis.py @@ -34,6 +34,7 @@ import math import nuke +import imath import IECore from KnobAccessors import getKnobValue @@ -53,16 +54,16 @@ def __init__( self, node ) : ## Returns the transformation matrix for the local axis knob. # This ignores any parent transforms. - def getLocalMatrix( self, resultType=IECore.M44f ) : + def getLocalMatrix( self, resultType=imath.M44f ) : - vectorType = IECore.V3f - eulerType = IECore.Eulerf - if resultType==IECore.M44d : - vectorType = IECore.V3d - eulerType = IECore.Eulerd + vectorType = imath.V3f + eulerType = imath.Eulerf + if resultType==imath.M44d : + vectorType = imath.V3d + eulerType = imath.Eulerd translate = getKnobValue( self.__node.knob( "translate" ), resultType=vectorType ) - translate = resultType.createTranslated( translate ) + translate = resultType().translate( translate ) pivot = getKnobValue( self.__node.knob( "pivot" ), resultType=vectorType ) @@ -71,14 +72,14 @@ def getLocalMatrix( self, resultType=IECore.M44f ) : rotOrderKnob = self.__node.knob( "rot_order" ) rotateOrder = rotOrderKnob.enumName( int(rotOrderKnob.getValue()) ) - rotate = eulerType( rotate, getattr( eulerType.Order, rotateOrder ), eulerType.InputLayout.XYZLayout ) + rotate = eulerType( rotate, getattr( eulerType.Order, rotateOrder ) ) rotate = rotate.toMatrix44() - rotate = resultType.createTranslated( -pivot ) * rotate * resultType.createTranslated( pivot ) + rotate = resultType().translate( -pivot ) * rotate * resultType().translate( pivot ) scale = getKnobValue( self.__node.knob( "scaling" ), resultType=vectorType ) scale *= self.__node.knob( "uniform_scale" ).getValue() - scale = resultType.createScaled( scale ) - scale = resultType.createTranslated( -pivot ) * scale * resultType.createTranslated( pivot ) + scale = resultType().scale( scale ) + scale = resultType().translate( -pivot ) * scale * resultType().translate( pivot ) orderKnob = self.__node.knob( "xform_order" ) order = orderKnob.enumName( int(orderKnob.getValue()) ) diff --git a/python/IECoreNuke/KnobAccessors.py b/python/IECoreNuke/KnobAccessors.py index 8046dea32b..2fc31cd936 100644 --- a/python/IECoreNuke/KnobAccessors.py +++ b/python/IECoreNuke/KnobAccessors.py @@ -33,6 +33,7 @@ ########################################################################## import nuke +import imath import IECore __getters = {} @@ -74,7 +75,7 @@ def setKnobValue( knob, value, **kwArgs ) : # XY Knob -def __getXY( knob, resultType=IECore.V2f ) : +def __getXY( knob, resultType=imath.V2f ) : return resultType( knob.getValue( 0 ), knob.getValue( 1 ) ) @@ -87,7 +88,7 @@ def __setXY( knob, value ) : # XYZ Knob -def __getXYZ( knob, resultType=IECore.V3f ) : +def __getXYZ( knob, resultType=imath.V3f ) : return resultType( knob.getValue( 0 ), knob.getValue( 1 ), knob.getValue( 2 ) ) @@ -102,7 +103,7 @@ def __setXYZ( knob, value ) : # Color Knob -def __getColor( knob, resultType=IECore.Color3f ) : +def __getColor( knob, resultType=imath.Color3f ) : return resultType( knob.getValue( 0 ), knob.getValue( 1 ), knob.getValue( 2 ) ) @@ -128,11 +129,11 @@ def __setString( knob, value ) : # Box3 Knob -def __getBox3( knob, resultType=IECore.Box3f ) : +def __getBox3( knob, resultType=imath.Box3f ) : - vectorType = IECore.V3f - if resultType == IECore.Box3d : - vectorType = IECore.V3d + vectorType = imath.V3f + if resultType == imath.Box3d : + vectorType = imath.V3d value = knob.getValue() return resultType( vectorType( *value[:3] ), vectorType( *value[3:] ) ) diff --git a/python/IECoreScene/IDXReader.py b/python/IECoreScene/IDXReader.py index d7fd2fa787..adc6fc9c89 100644 --- a/python/IECoreScene/IDXReader.py +++ b/python/IECoreScene/IDXReader.py @@ -33,6 +33,7 @@ ########################################################################## import re +import imath import IECore import IECoreScene @@ -137,7 +138,7 @@ def doOperation( self, args ) : except ValueError: continue; - p.append( IECore.V3f( x, y, z ) ) + p.append( imath.V3f( x, y, z ) ) nos.append( int(points[k]["PointNo"]) ) @@ -166,7 +167,7 @@ def doOperation( self, args ) : tx = float( points[ stnNo ]["East"] ) ty = float( points[ stnNo ]["Elevation"] ) tz = -float( points[ stnNo ]["North"] ) # Handedness... - primitive.blindData()["STN_POSITION"] = IECore.V3fData( IECore.V3f( tx, ty, tz ) ) + primitive.blindData()["STN_POSITION"] = IECore.V3fData( imath.V3f( tx, ty, tz ) ) if stnNo in annotations: primitive.blindData()["STN_ANNOTATION"] = IECore.StringData( annotations[stnNo]["Annotation"] ) diff --git a/python/IECoreScene/PointsExpressionOp.py b/python/IECoreScene/PointsExpressionOp.py deleted file mode 100644 index 64ccf80eab..0000000000 --- a/python/IECoreScene/PointsExpressionOp.py +++ /dev/null @@ -1,146 +0,0 @@ -########################################################################## -# -# Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Image Engine Design nor the names of any -# other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import IECore -import IECoreScene - -class PointsExpressionOp( IECore.ModifyOp ) : - - def __init__( self ) : - - IECore.ModifyOp.__init__( self, "Modifies the primitive variables of a PointsPrimitive using a python expression.", - IECore.ObjectParameter( - name = "result", - description = "The modified points primitive.", - defaultValue = IECoreScene.PointsPrimitive( 0 ), - type = IECoreScene.PointsPrimitive.staticTypeId(), - ), - IECore.ObjectParameter( - name = "input", - description = "The points primitive to modify.", - defaultValue = IECoreScene.PointsPrimitive( 0 ), - type = IECoreScene.PointsPrimitive.staticTypeId(), - ) - ) - - self.parameters().addParameters( - - [ - IECore.StringParameter( - name = "expression", - description = "A python expression applied on a per point basis. This may read from or assign to any of the per point" - "primitive variables, and also assign any True value to the variable \"remove\" to have the point removed. The variable \"i\"" - "holds the index for the current point.", - defaultValue = "", - ) - ] - ) - - def modify( self, pointsPrim, operands ) : - - # this dictionary derived class provides the locals for - # the expressions. it overrides the item accessors to - # provide access into the point data - class LocalsDict( dict ) : - - def __init__( self, p ) : - - self.__numPoints = p.numPoints - self.__vectors = {} - for k in p.keys() : - try : - if len( p[k].data ) == p.numPoints : - self.__vectors[k] = p[k].data - except : - pass - - self.__vectors["remove"] = IECore.BoolVectorData( p.numPoints ) - self.__haveRemovals = False - - def __getitem__( self, n ) : - - vector = self.__vectors.get( n, None ) - if vector is None : - return dict.__getitem__( self, n ) - else : - return vector[self["i"]] - - def __setitem__( self, n, v ) : - - vector = self.__vectors.get( n, None ) - if vector is None : - dict.__setitem__( self, n, v ) - else : - vector[self["i"]] = v - if n=="remove" and v : - self.__haveRemovals = True - - def removals( self ) : - - if self.__haveRemovals : - return self.__vectors["remove"] - else : - return None - - # get globals and locals for expressions - g = globals() - l = LocalsDict( pointsPrim ) - - # run the expression for each point - e = compile( operands["expression"].value, "expression", "exec" ) - for i in range( 0, pointsPrim.numPoints ) : - - l["i"] = i - exec e in g, l - - # filter out any points if requested - removals = l.removals() - if removals : - - newNumPoints = pointsPrim.numPoints - for k in pointsPrim.keys() : - - try : - primVar = pointsPrim[k] - if len( primVar.data )==pointsPrim.numPoints : - primVar.data = IECore.VectorDataFilterOp()( input = primVar.data, filter = removals, invert=True ) - pointsPrim[k] = primVar - newNumPoints = primVar.data.size() - except : - # we'll get exceptions for data types which don't define len() - pass - - pointsPrim.numPoints = newNumPoints - -IECore.registerRunTimeTyped( PointsExpressionOp ) diff --git a/python/IECoreScene/SWAReader.py b/python/IECoreScene/SWAReader.py index cce8131c5d..c26871b4c1 100644 --- a/python/IECoreScene/SWAReader.py +++ b/python/IECoreScene/SWAReader.py @@ -33,6 +33,7 @@ ########################################################################## import re +import imath import IECore import IECoreScene @@ -97,9 +98,9 @@ def doOperation( self, args ) : else : treeData = [ float( x ) for x in line.split() ] assert( len( treeData ) == 10 ) - p.append( IECore.V3f( treeData[0], treeData[2], -treeData[1] ) ) - ya = IECore.V3f( treeData[3], treeData[5], -treeData[4] ) - xa = IECore.V3f( treeData[6], treeData[8], -treeData[7] ) + p.append( imath.V3f( treeData[0], treeData[2], -treeData[1] ) ) + ya = imath.V3f( treeData[3], treeData[5], -treeData[4] ) + xa = imath.V3f( treeData[6], treeData[8], -treeData[7] ) za = xa.cross( ya ) xAxis.append( xa ) yAxis.append( ya ) diff --git a/python/IECoreScene/__init__.py b/python/IECoreScene/__init__.py index 6710d47fa8..f838c1fa9e 100644 --- a/python/IECoreScene/__init__.py +++ b/python/IECoreScene/__init__.py @@ -38,7 +38,6 @@ from RemovePrimitiveVariables import RemovePrimitiveVariables from RenamePrimitiveVariables import RenamePrimitiveVariables -from PointsExpressionOp import PointsExpressionOp from AttributeBlock import AttributeBlock from TransformBlock import TransformBlock from WorldBlock import WorldBlock diff --git a/src/IECore/DataCastOp.cpp b/src/IECore/DataCastOp.cpp index 5098becdbf..16c6960cba 100644 --- a/src/IECore/DataCastOp.cpp +++ b/src/IECore/DataCastOp.cpp @@ -306,45 +306,25 @@ ObjectPtr DataCastOp::doOperation( const CompoundObject * operands ) { CASTVECTORDATA( V3d, DoubleVector ) CASTDATA( V3d, V3f ) - CASTDATA( V3d, Color3d ) default: break; } break; case Color3fDataTypeId: switch ( targetType ) { - CASTDATA( Color3f, Color3d ) CASTDATA( Color3f, V3f ) CASTDATA( Color3f, V3d ) CASTVECTORDATA( Color3f, FloatVector ) default: break; } break; - case Color3dDataTypeId: - switch ( targetType ) - { - CASTDATA( Color3d, Color3f ) - CASTDATA( Color3d, V3d ) - CASTVECTORDATA( Color3d, DoubleVector ) - default: break; - } - break; case Color4fDataTypeId: switch ( targetType ) { - CASTDATA( Color4f, Color4d ) CASTVECTORDATA( Color4f, FloatVector ) default: break; } break; - case Color4dDataTypeId: - switch ( targetType ) - { - CASTDATA( Color4d, Color4f ) - CASTVECTORDATA( Color4d, DoubleVector ) - default: break; - } - break; case Box2iDataTypeId: switch ( targetType ) { @@ -634,7 +614,6 @@ ObjectPtr DataCastOp::doOperation( const CompoundObject * operands ) CASTVECTORDATA( V3fVector, FloatVector ) CASTVECTORDATA( V3fVector, V3dVector ) CASTVECTORDATA( V3fVector, Color3fVector ) - CASTVECTORDATA( V3fVector, Color3dVector ) CASTVECTORDATA( V3fVector, Box3fVector ) default: break; } @@ -647,7 +626,6 @@ ObjectPtr DataCastOp::doOperation( const CompoundObject * operands ) CASTVECTORDATA( V3dVector, DoubleVector ) CASTVECTORDATA( V3dVector, V3fVector ) CASTVECTORDATA( V3dVector, Color3fVector ) - CASTVECTORDATA( V3dVector, Color3dVector ) CASTVECTORDATA( V3dVector, Box3dVector ) default: break; } @@ -660,7 +638,6 @@ ObjectPtr DataCastOp::doOperation( const CompoundObject * operands ) CASTVECTORDATA( Color3fVector, FloatVector ) CASTVECTORDATA( Color3fVector, V3fVector ) CASTVECTORDATA( Color3fVector, V3dVector ) - CASTVECTORDATA( Color3fVector, Color3dVector ) CASTVECTORDATA( Color3fVector, Box3fVector ) default: break; } diff --git a/src/IECore/SimpleTypedData.cpp b/src/IECore/SimpleTypedData.cpp index c9b3e9b419..20564eb5d2 100644 --- a/src/IECore/SimpleTypedData.cpp +++ b/src/IECore/SimpleTypedData.cpp @@ -112,8 +112,6 @@ IE_CORE_DEFINEIMATHGEOMETRICTYPEDDATASPECIALISATION( V3dData, V3dDataTypeId, V3d IE_CORE_DEFINEIMATHTYPEDDATASPECIALISATION( Color3fData, Color3fDataTypeId, 3 ) IE_CORE_DEFINEIMATHTYPEDDATASPECIALISATION( Color4fData, Color4fDataTypeId, 4 ) -IE_CORE_DEFINEIMATHTYPEDDATASPECIALISATION( Color3dData, Color3dDataTypeId, 3 ) -IE_CORE_DEFINEIMATHTYPEDDATASPECIALISATION( Color4dData, Color4dDataTypeId, 4 ) IE_CORE_DEFINEIMATHTYPEDDATASPECIALISATION( Box2iData, Box2iDataTypeId, 4 ) IE_CORE_DEFINEIMATHTYPEDDATASPECIALISATION( Box3iData, Box3iDataTypeId, 6 ) IE_CORE_DEFINEIMATHTYPEDDATASPECIALISATION( Box2fData, Box2fDataTypeId, 4 ) @@ -138,8 +136,6 @@ IECORE_DEFINE_ZERO_INITIALISED_CONSTRUCTOR( V2dDataBase ) IECORE_DEFINE_ZERO_INITIALISED_CONSTRUCTOR( V3dDataBase ) IECORE_DEFINE_ZERO_INITIALISED_CONSTRUCTOR( Color3fData ) IECORE_DEFINE_ZERO_INITIALISED_CONSTRUCTOR( Color4fData ) -IECORE_DEFINE_ZERO_INITIALISED_CONSTRUCTOR( Color3dData ) -IECORE_DEFINE_ZERO_INITIALISED_CONSTRUCTOR( Color4dData ) template<> void StringData::memoryUsage( Object::MemoryAccumulator &accumulator ) const @@ -316,8 +312,6 @@ template class IECORE_API GeometricTypedData; template class IECORE_API TypedData; template class IECORE_API TypedData; -template class IECORE_API TypedData >; -template class IECORE_API TypedData >; template class IECORE_API TypedData; template class IECORE_API TypedData; template class IECORE_API TypedData; diff --git a/src/IECore/VectorTypedData.cpp b/src/IECore/VectorTypedData.cpp index b750f56b1d..42c9c5611b 100644 --- a/src/IECore/VectorTypedData.cpp +++ b/src/IECore/VectorTypedData.cpp @@ -215,8 +215,6 @@ IE_CORE_DEFINEIMATHVECTORTYPEDDATASPECIALISATION( QuatfVectorData, QuatfVectorDa IE_CORE_DEFINEIMATHVECTORTYPEDDATASPECIALISATION( QuatdVectorData, QuatdVectorDataTypeId, 4 ) IE_CORE_DEFINEIMATHVECTORTYPEDDATASPECIALISATION( Color3fVectorData, Color3fVectorDataTypeId, 3 ) IE_CORE_DEFINEIMATHVECTORTYPEDDATASPECIALISATION( Color4fVectorData, Color4fVectorDataTypeId, 4 ) -IE_CORE_DEFINEIMATHVECTORTYPEDDATASPECIALISATION( Color3dVectorData, Color3dVectorDataTypeId, 3 ) -IE_CORE_DEFINEIMATHVECTORTYPEDDATASPECIALISATION( Color4dVectorData, Color4dVectorDataTypeId, 4 ) // the string type needs it's own memoryUsage so we don't use the whole macro for it's specialisations @@ -439,8 +437,6 @@ template class IECORE_API GeometricTypedData >; template class IECORE_API TypedData >; template class IECORE_API TypedData >; -template class IECORE_API TypedData > >; -template class IECORE_API TypedData > >; template class IECORE_API TypedData >; template class IECORE_API TypedData >; template class IECORE_API TypedData >; diff --git a/src/IECorePython/BoxAlgoBinding.cpp b/src/IECorePython/BoxAlgoBinding.cpp new file mode 100644 index 0000000000..406bcfaadf --- /dev/null +++ b/src/IECorePython/BoxAlgoBinding.cpp @@ -0,0 +1,97 @@ +////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2017, Image Engine Design Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// * Neither the name of Image Engine Design nor the names of any +// other contributors to this software may be used to endorse or +// promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////// + +#include "boost/python.hpp" + +#include "IECore/BoxAlgo.h" + +#include "IECorePython/BoxAlgoBinding.h" + +using namespace boost::python; +using namespace Imath; +using namespace IECore; +using namespace IECorePython; + +namespace +{ + +template +static tuple split1( const Box &box, int axis ) +{ + Box low, high; + BoxAlgo::split( box, low, high, axis ); + return make_tuple( low, high ); +} + +template +static tuple split2( const Box &box ) +{ + Box low, high; + BoxAlgo::split( box, low, high ); + return make_tuple( low, high ); +} + +template +void bind() +{ + def( "contains", &BoxAlgo::contains ); + def( "split", &split1 ); + def( "split", &split2 ); +} + +} // namespace + +void IECorePython::bindBoxAlgo() +{ + object boxAlgoModule( borrowed( PyImport_AddModule( "IECore.BoxAlgo" ) ) ); + scope().attr( "BoxAlgo" ) = boxAlgoModule; + + scope boxAlgoScope( boxAlgoModule ); + + def( "closestPointInBox", &BoxAlgo::closestPointInBox ); + def( "closestPointInBox", &BoxAlgo::closestPointInBox ); + def( "closestPointInBox", &BoxAlgo::closestPointInBox ); + def( "closestPointInBox", &BoxAlgo::closestPointInBox ); + + bind(); + bind(); + bind(); + bind(); + + bind(); + bind(); + bind(); + bind(); + +} diff --git a/src/IECorePython/IECoreBinding.cpp b/src/IECorePython/IECoreBinding.cpp new file mode 100644 index 0000000000..8d8bd7110b --- /dev/null +++ b/src/IECorePython/IECoreBinding.cpp @@ -0,0 +1,302 @@ +////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2017, Image Engine Design Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// * Neither the name of Image Engine Design nor the names of any +// other contributors to this software may be used to endorse or +// promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////// + +#include "OpenEXR/ImathBox.h" +#include "OpenEXR/ImathColor.h" +#include "OpenEXR/ImathEuler.h" +#include "OpenEXR/ImathMatrix.h" +#include "OpenEXR/ImathPlane.h" +#include "OpenEXR/ImathVec.h" + +#include "IECorePython/IECoreBinding.h" + +using namespace std; +using namespace Imath; + +namespace IECorePython +{ + +#define DEFINEVECSTRSPECIALISATION( VEC )\ +\ +template<>\ +std::string repr( VEC &x )\ +{\ + std::stringstream s;\ + s << "imath." << #VEC << "( ";\ + for( unsigned i=0; i( x[i] );\ + if( i!=VEC::dimensions()-1 )\ + {\ + s << ", ";\ + }\ + }\ + s << " )";\ + return s.str();\ +}\ +\ +template<>\ +std::string str( VEC &x )\ +{\ + std::stringstream s;\ + for( unsigned i=0; i( x[i] );\ + if( i!=VEC::dimensions()-1 )\ + {\ + s << " ";\ + }\ + }\ + return s.str();\ +}\ + +DEFINEVECSTRSPECIALISATION( V2i ); +DEFINEVECSTRSPECIALISATION( V2f ); +DEFINEVECSTRSPECIALISATION( V2d ); +DEFINEVECSTRSPECIALISATION( V3i ); +DEFINEVECSTRSPECIALISATION( V3f ); +DEFINEVECSTRSPECIALISATION( V3d ); + +#define DEFINEBOXSTRSPECIALISATION( BOX )\ +\ +template<>\ +std::string repr( BOX &x )\ +{\ + std::stringstream s;\ + s << "imath." << #BOX << "(";\ + if( !x.isEmpty() )\ + {\ + s << " " << repr( x.min ) << ", ";\ + s << repr( x.max ) << " ";\ + }\ + s << ")";\ + return s.str();\ +}\ +\ +template<>\ +std::string str( BOX &x )\ +{\ + std::stringstream s;\ + s << str( x.min ) << " " << str( x.max );\ + return s.str();\ +}\ + +DEFINEBOXSTRSPECIALISATION( Box2i ); +DEFINEBOXSTRSPECIALISATION( Box3i ); +DEFINEBOXSTRSPECIALISATION( Box2f ); +DEFINEBOXSTRSPECIALISATION( Box3f ); +DEFINEBOXSTRSPECIALISATION( Box2d ); +DEFINEBOXSTRSPECIALISATION( Box3d ); + +#define DEFINECOLSTRSPECIALISATION( COL )\ +\ +template<>\ +std::string repr( COL &x )\ +{\ + std::stringstream s;\ + s << "imath." << #COL << "( ";\ + for( unsigned i=0; i( x[i] );\ + if( i!=COL::dimensions()-1 )\ + {\ + s << ", ";\ + }\ + }\ + s << " )";\ + return s.str();\ +}\ +\ +template<>\ +std::string str( COL &x )\ +{\ + std::stringstream s;\ + for( unsigned i=0; i( x[i] );\ + if( i!=COL::dimensions()-1 )\ + {\ + s << " ";\ + }\ + }\ + return s.str();\ +}\ + +DEFINECOLSTRSPECIALISATION( Color3f ); +DEFINECOLSTRSPECIALISATION( Color4f ); + +/// \todo Handle rotation order +#define DEFINEEULERSTRSPECIALISATION( EULER )\ +\ +template<>\ +std::string repr( EULER &x )\ +{\ + std::stringstream s;\ + s << "imath." << #EULER << "( ";\ + for( unsigned i=0; i\ +std::string str( EULER &x )\ +{\ + std::stringstream s;\ + for( unsigned i=0; i\ +string repr( TYPE &x )\ +{\ + stringstream s;\ + s << "imath." << #TYPE << "( ";\ + for( int i=0; i\ +string str( TYPE &x )\ +{\ + stringstream s;\ + for( int i=0; i\ +std::string repr( PLANE &x )\ +{\ + std::stringstream s;\ + s << "imath." << #PLANE << "( ";\ + s << repr( x.normal ) << ", ";\ + s << x.distance;\ + s << " )";\ + return s.str();\ +}\ +\ +template<>\ +std::string str( PLANE &x )\ +{\ + std::stringstream s;\ + s << str( x.normal ) << " " << str( x.distance );\ + return s.str();\ +}\ + +DEFINEPLANEPECIALISATION( Plane3f ); +DEFINEPLANEPECIALISATION( Plane3d ); + +#define DEFINEQUATSTRSPECIALISATION( QUAT )\ +\ +template<>\ +std::string repr( QUAT &x )\ +{\ + std::stringstream s;\ + s << "imath." << #QUAT << "( ";\ + for( unsigned i=0; i<4; i++ )\ + {\ + s << x[i];\ + if( i!=3 )\ + {\ + s << ", ";\ + }\ + }\ + s << " )";\ + return s.str();\ +}\ +\ +template<>\ +std::string str( QUAT &x )\ +{\ + std::stringstream s;\ + for( unsigned i=0; i<4; i++ )\ + {\ + s << x[i];\ + if( i!=3 )\ + {\ + s << " ";\ + }\ + }\ + return s.str();\ +}\ + +DEFINEQUATSTRSPECIALISATION( Quatf ); +DEFINEQUATSTRSPECIALISATION( Quatd ); + +} // namespace IECorePython diff --git a/src/IECorePython/ImathBoxBinding.cpp b/src/IECorePython/ImathBoxBinding.cpp deleted file mode 100644 index abbd1460a6..0000000000 --- a/src/IECorePython/ImathBoxBinding.cpp +++ /dev/null @@ -1,173 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -// This include needs to be the very first to prevent problems with warnings -// regarding redefinition of _POSIX_C_SOURCE -#include "boost/python.hpp" - -// System includes -#include -#include -#include - -#include "OpenEXR/ImathBox.h" -#include "OpenEXR/ImathBoxAlgo.h" - -#include "IECore/VectorTraits.h" -#include "IECore/BoxOps.h" -#include "IECorePython/ImathBoxBinding.h" -#include "IECorePython/IECoreBinding.h" - -using namespace boost::python; -using namespace Imath; -using namespace IECore; - -namespace IECorePython -{ - -template -class_< Box > bindBox(const char *bindName); - -void bindImathBox() -{ - bindBox("Box2f"); - bindBox("Box2d"); - - class_< Box3f > cf = bindBox("Box3f"); - cf.def("transform", ( Box3f (*)(const Box3f &, const Matrix44&) )&transform); - cf.def("transform", ( Box3f (*)(const Box3f &, const Matrix44&) )&transform); - - class_< Box3d > cd = bindBox("Box3d"); - cd.def("transform", ( Box3d (*)(const Box3d &, const Matrix44&) )&transform); - cd.def("transform", ( Box3d (*)(const Box3d &, const Matrix44&) )&transform); - - bindBox("Box2i"); - bindBox("Box3i"); -} - -/// \todo The only reason this is a macro is so that it can turn the class type to a string. We should probably do this -/// with a small traits class instead, and get rid of the macro. -#define DEFINEBOXSTRSPECIALISATION( BOX ) \ - \ -template<> \ -std::string repr( BOX &x ) \ -{ \ - std::stringstream s; \ - s << "IECore." << #BOX << "( "; \ - s << repr( x.min ) << ", "; \ - s << repr( x.max ); \ - s << " )"; \ - return s.str(); \ -} \ - \ -template<> \ -std::string str( BOX &x ) \ -{ \ - std::stringstream s; \ - s << str( x.min ) << " " << str( x.max ); \ - return s.str(); \ -} \ - -DEFINEBOXSTRSPECIALISATION( Box2i ); -DEFINEBOXSTRSPECIALISATION( Box3i ); -DEFINEBOXSTRSPECIALISATION( Box2f ); -DEFINEBOXSTRSPECIALISATION( Box3f ); -DEFINEBOXSTRSPECIALISATION( Box2d ); -DEFINEBOXSTRSPECIALISATION( Box3d ); - -template -static tuple split1( const Box &box, int axis ) -{ - Box low, high; - boxSplit( box, low, high, axis ); - return make_tuple( low, high ); -} - -template -static tuple split2( const Box &box ) -{ - Box low, high; - boxSplit( box, low, high ); - return make_tuple( low, high ); -} - -template -class_< Box > bindBox(const char *bindName) -{ - void (Box::*eb1)(const T&) = &Box::extendBy; - void (Box::*eb2)(const Box&) = &Box::extendBy; - - bool (Box::*i1)(const T&) const = &Box::intersects; - bool (Box::*i2)(const Box&) const = &Box::intersects; - - class_< Box > myClass(bindName); - myClass.def_readwrite("min", &Box::min) - .def_readwrite("max", &Box::max) - - .def(init<>()) - .def(init()) - .def(init()) - - .def(self == self) - .def(self != self) - - .def("makeEmpty", &Box::makeEmpty) - .def("extendBy", eb1) - .def("extendBy", eb2) - - .def("size", &Box::size) - .def("center", &Box::center) - .def("intersects", i1) - .def("intersects", i2) - .def("contains", &boxContains > ) - - .def("majorAxis", &Box::majorAxis) - - .def("isEmpty", &Box::isEmpty) - .def("hasVolume", &Box::hasVolume) - - .def("dimensions", &VectorTraits::dimensions).staticmethod("dimensions") - - .def( "__str__", &IECorePython::str > ) - .def( "__repr__", &IECorePython::repr > ) - - .def( "split", &split1 ) - .def( "split", &split2 ) - - - ; - return myClass; -} - -} diff --git a/src/IECorePython/ImathColorBinding.cpp b/src/IECorePython/ImathColorBinding.cpp deleted file mode 100644 index b3cb8445b8..0000000000 --- a/src/IECorePython/ImathColorBinding.cpp +++ /dev/null @@ -1,256 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "OpenEXR/ImathColor.h" -#include "OpenEXR/ImathColorAlgo.h" - -#include "IECorePython/ImathColorBinding.h" -#include "IECorePython/IECoreBinding.h" - -using namespace boost::python; -using namespace Imath; - -namespace IECorePython -{ - -template -struct ColorIndexer -{ - typedef typename T::BaseType V; - static V get(const T &x, int i) - { - // Do we want to handle backward indexing? - if ( i >= 0 && i < static_cast(T::dimensions()) ) - { - return x[i]; - } - else - { - /// \todo Give a description of the error! NB Boost 1.38.0 will translate these into IndexError python exceptions - throw std::out_of_range(""); - } - - } - - static void set(T &x, int i, const V &v) - { - if ( i >= 0 && i < static_cast(T::dimensions()) ) - { - x[i] = v; - } - else - { - /// \todo Give a description of the error! NB Boost 1.38.0 will translate these into IndexError python exceptions - throw std::out_of_range(""); - } - } - -}; - -/// \todo The only reason this is a macro is so that it can turn the class type to a string. We should probably do this -/// with a small traits class instead, and get rid of the macro. -#define DEFINECOLSTRSPECIALISATION( COL ) \ - \ -template<> \ -std::string repr( COL &x ) \ -{ \ - std::stringstream s; \ - s << "IECore." << #COL << "( "; \ - for( unsigned i=0; i( x[i] ); \ - if( i!=COL::dimensions()-1 ) \ - { \ - s << ", "; \ - } \ - } \ - s << " )"; \ - return s.str(); \ -} \ - \ -template<> \ -std::string str( COL &x ) \ -{ \ - std::stringstream s; \ - for( unsigned i=0; i( x[i] ); \ - if( i!=COL::dimensions()-1 ) \ - { \ - s << " "; \ - } \ - } \ - return s.str(); \ -} \ - -DEFINECOLSTRSPECIALISATION( Color3f ); -DEFINECOLSTRSPECIALISATION( Color4f ); -typedef Color3 Color3d; -typedef Color4 Color4d; -DEFINECOLSTRSPECIALISATION( Color3d ); -DEFINECOLSTRSPECIALISATION( Color4d ); - -template -T hsvToRGB( const T &c ) -{ - return hsv2rgb( c ); -} - -template -T rgbToHSV( const T &c ) -{ - return rgb2hsv( c ); -} - -template -void bindColorCommon( class_ &c ) -{ - - c.def( self==self ); - c.def( self!=self ); - - c.def( self += self ); - c.def( self + self ); - - c.def( self -= self ); - c.def( self - self ); - - c.def( -self ); - c.def( "negate", &T::negate, return_self<>() ); - - c.def( self *= self ); - - c.def( self *= typename T::BaseType() ); - - c.def( self * self ); - c.def( self * typename T::BaseType() ); - c.def( typename T::BaseType() * self ); - - c.def( self /= self ); - c.def( self /= typename T::BaseType() ); - c.def( self / self ); - c.def( self / typename T::BaseType() ); - - c.def( "dimensions", &T::dimensions ).staticmethod( "dimensions" ); - - // [] operator support - c.def("__getitem__", &ColorIndexer< T >::get); - c.def("__setitem__", &ColorIndexer< T >::set); - - c.def( "baseTypeMin", &T::baseTypeMin ).staticmethod( "baseTypeMin" ); - c.def( "baseTypeMax", &T::baseTypeMax ).staticmethod( "baseTypeMax" ); - c.def( "baseTypeSmallest", &T::baseTypeSmallest ).staticmethod( "baseTypeSmallest" ); - c.def( "baseTypeEpsilon", &T::baseTypeEpsilon ).staticmethod( "baseTypeEpsilon" ); - - c.def( "hsvToRGB", &hsvToRGB ); - c.def( "rgbToHSV", &rgbToHSV ); - - c.def( "__str__", &str ); - c.def( "__repr__", &repr ); -} - -/// We need this and equalWithRelError so that we can call them passing colors instead of vectors. -/// We deliberately don't expose the fact that Color3 derives from Vec3 because we think that is weird. -template -static bool equalWithAbsError( const T &c1, const T &c2, typename T::BaseType e ) -{ - return c1.equalWithAbsError( c2, e ); -} - -template -static bool equalWithRelError( const T &c1, const T &c2, typename T::BaseType e ) -{ - return c1.equalWithRelError( c2, e ); -} - -template -void bindColor3( const char *typeName ) -{ - - // we deliberately don't expose the fact that - // Color3 derives from Vec3 because we think - // that is weird. - class_ c = class_( typeName ) - - .def_readwrite( "r", &T::x ) - .def_readwrite( "g", &T::y ) - .def_readwrite( "b", &T::z ) - - .def( init<>() ) - .def( init() ) - .def( init() ) - .def( init() ) - .def( init () ) - .def( init () ) - - .def( "equalWithAbsError", &equalWithAbsError ) - .def( "equalWithRelError", &equalWithRelError ) - ; - - bindColorCommon( c ); - -} - -template -void bindColor4( const char *typeName ) -{ - class_ c = class_( typeName ) - - .def_readwrite( "r", &T::r ) - .def_readwrite( "g", &T::g ) - .def_readwrite( "b", &T::b ) - .def_readwrite( "a", &T::a ) - - .def( init<>() ) - .def( init() ) - .def( init() ) - .def( init() ) - - ; - - bindColorCommon( c ); - -} - -void bindImathColor() -{ - bindColor3( "Color3f" ); - bindColor4( "Color4f" ); - bindColor3 >( "Color3d" ); - bindColor4 >( "Color4d" ); -} - -} // namespace IECorePython diff --git a/src/IECorePython/ImathColorVectorBinding.cpp b/src/IECorePython/ImathColorVectorBinding.cpp index 345fa4a3ab..13015d6439 100644 --- a/src/IECorePython/ImathColorVectorBinding.cpp +++ b/src/IECorePython/ImathColorVectorBinding.cpp @@ -58,15 +58,11 @@ namespace IECorePython IECOREPYTHON_DEFINEVECTORDATASTRSPECIALISATION( Color3f ) IECOREPYTHON_DEFINEVECTORDATASTRSPECIALISATION( Color4f ) -IECOREPYTHON_DEFINEVECTORDATASTRSPECIALISATION( Color3 ) -IECOREPYTHON_DEFINEVECTORDATASTRSPECIALISATION( Color4 ) void bindImathColorVectorTypedData() { BIND_OPERATED_VECTOR_TYPEDDATA ( Color3f, "Color3f") BIND_OPERATED_VECTOR_TYPEDDATA ( Color4f, "Color4f") - BIND_OPERATED_VECTOR_TYPEDDATA ( Color3, "Color3d") - BIND_OPERATED_VECTOR_TYPEDDATA ( Color4, "Color4d") } } // namespace IECorePython diff --git a/src/IECorePython/ImathEulerBinding.cpp b/src/IECorePython/ImathEulerBinding.cpp deleted file mode 100644 index 47138c895d..0000000000 --- a/src/IECorePython/ImathEulerBinding.cpp +++ /dev/null @@ -1,254 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -// This include needs to be the very first to prevent problems with warnings -// regarding redefinition of _POSIX_C_SOURCE -#include "boost/python.hpp" - -// System includes -#include -#include - -#include "OpenEXR/ImathEuler.h" - -#include "IECorePython/ImathVecBinding.h" -#include "IECorePython/IECoreBinding.h" - -using namespace boost::python; -using namespace Imath; -using namespace std; - -namespace IECorePython -{ - -template -void bindEuler(const char *bindName); - -void bindImathEuler() -{ - bindEuler("Eulerf"); - bindEuler("Eulerd"); -} -/// \todo Handle rotation order -#define DEFINEEULERSTRSPECIALISATION( EULER )\ -\ -template<>\ -std::string repr( EULER &x )\ -{\ - std::stringstream s;\ - s << "IECore." << #EULER << "( ";\ - for( unsigned i=0; i\ -std::string str( EULER &x )\ -{\ - std::stringstream s;\ - for( unsigned i=0; i -struct EulerHelper -{ - typedef typename Euler::Order OrderType; - - static boost::python::tuple angleOrder( Euler &e ) - { - int i, j, k; - e.angleOrder( i, j, k ); - - return boost::python::make_tuple( i, j, k ); - } - - static boost::python::tuple angleMapping( Euler &e ) - { - int i, j, k; - e.angleMapping( i, j, k ); - - return boost::python::make_tuple( i, j, k ); - } - - static Vec3 simpleXYZRotation( Vec3 xyzRot, const Vec3 &targetXyzRot ) - { - Euler::simpleXYZRotation( xyzRot, targetXyzRot ); - - return xyzRot; - } - - static Vec3 nearestRotation( Vec3 xyzRot, const Vec3 &targetXyzRot, OrderType order ) - { - Euler::nearestRotation( xyzRot, targetXyzRot, order ); - - return xyzRot; - } - - static Vec3 nearestRotation( Vec3 xyzRot, const Vec3 &targetXyzRot ) - { - Euler::nearestRotation( xyzRot, targetXyzRot, (OrderType)(Euler::XYZ) ); - return xyzRot; - } -}; - -template -void bindEuler(const char *bindName) -{ - /// We need these typedefs so we can instantiate the "optional" and "enum_" templates. - // Without them, the enums defined in Imath::Euler aren't types. - typedef typename Euler::Order OrderType; - typedef typename Euler::InputLayout InputLayoutType; - typedef typename Euler::Axis AxisType; - - void (Euler::*extractM33)(const Matrix33&) = &Euler::extract; - void (Euler::*extractM44)(const Matrix44&) = &Euler::extract; - void (Euler::*extractQuat)(const Quat&) = &Euler::extract; - - Vec3 (*nearestRotation1)( Vec3, const Vec3 &, OrderType )= &EulerHelper::nearestRotation; - Vec3 (*nearestRotation2)( Vec3, const Vec3 & )= &EulerHelper::nearestRotation; - - object euler = class_< Euler, bases< Vec3 > >(bindName) - - .def( init<>() ) - .def( init< const Euler & >() ) - .def( init< OrderType >() ) - .def( init< const Vec3 &, optional< OrderType, InputLayoutType > >() ) - .def( init< T, T, T, optional< OrderType, InputLayoutType > >() ) - .def( init< const Euler &, optional< OrderType > >() ) - .def( init< const Matrix33 &, optional< OrderType > > () ) - .def( init< const Matrix44 &, optional< OrderType > > () ) - - .def( "__str__", &IECorePython::str > ) - .def( "__repr__", &IECorePython::repr > ) - - - .def( "legal", &Euler::legal ).staticmethod("legal") - - .def( "setXYZVector", &Euler::setXYZVector ) - - .def( "order", &Euler::order ) - .def( "setOrder", &Euler::setOrder ) - - .def( "set", &Euler::set ) - - .def( "extract", extractM33 ) - .def( "extract", extractM44 ) - .def( "extract", extractQuat ) - - .def( "toMatrix33", &Euler::toMatrix33 ) - .def( "toMatrix44", &Euler::toMatrix44 ) - .def( "toQuat", &Euler::toQuat ) - .def( "toXYZVector", &Euler::toXYZVector ) - - .def( "angleOrder", &EulerHelper::angleOrder ) - .def( "angleMapping", &EulerHelper::angleOrder ) - - .def( "angleMod", &Euler::angleMod ).staticmethod("angleMod") - .def( "simpleXYZRotation", &EulerHelper::simpleXYZRotation ).staticmethod("simpleXYZRotation") - .def( "nearestRotation", nearestRotation1 ) - .def( "nearestRotation", nearestRotation2 ).staticmethod("nearestRotation") - - .def( "makeNear", &Euler::makeNear ) - - .def( "frameStatic", &Euler::frameStatic ) - .def( "initialRepeated", &Euler::initialRepeated ) - .def( "parityEven", &Euler::parityEven ) - .def( "initialAxis", &Euler::initialAxis ) - ; - - scope eulerScope (euler ); - - enum_< OrderType >( "Order" ) - .value( "XYZ", Euler::XYZ ) - .value( "XZY", Euler::XZY ) - .value( "YZX", Euler::YZX ) - .value( "YXZ", Euler::YXZ ) - .value( "ZXY", Euler::ZXY ) - .value( "ZYX", Euler::ZYX ) - - .value( "XZX", Euler::XZX ) - .value( "XYX", Euler::XYX ) - .value( "YXY", Euler::YXY ) - .value( "YZY", Euler::YZY ) - .value( "ZYZ", Euler::ZYZ ) - .value( "ZXZ", Euler::ZXZ ) - - .value( "XYZr", Euler::XYZr ) - .value( "XZYr", Euler::XZYr ) - .value( "YZXr", Euler::YZXr ) - .value( "YXZr", Euler::YXZr ) - .value( "ZXYr", Euler::ZXYr ) - .value( "ZYXr", Euler::ZYXr ) - - .value( "XZXr", Euler::XZXr ) - .value( "XYXr", Euler::XYXr ) - .value( "YXYr", Euler::YXYr ) - .value( "YZYr", Euler::YZYr ) - .value( "ZYZr", Euler::ZYZr ) - .value( "ZXZr", Euler::ZXZr ) - - .value( "Default", Euler::Default ) - ; - - enum_< InputLayoutType >( "InputLayout" ) - .value( "XYZLayout", Euler::XYZLayout ) - .value( "IJKLayout", Euler::IJKLayout ) - ; - - enum_< AxisType >( "Axis" ) - .value( "X", Euler::X ) - .value( "Y", Euler::Y ) - .value( "Z", Euler::Z ) - ; -} - -} diff --git a/src/IECorePython/ImathMatrixBinding.cpp b/src/IECorePython/ImathMatrixBinding.cpp deleted file mode 100644 index 347d25aab3..0000000000 --- a/src/IECorePython/ImathMatrixBinding.cpp +++ /dev/null @@ -1,653 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -// This include needs to be the very first to prevent problems with warnings -// regarding redefinition of _POSIX_C_SOURCE -#include "boost/python.hpp" - -// System includes -#include -#include - -#include "OpenEXR/ImathMatrix.h" -#include "OpenEXR/ImathMatrixAlgo.h" - -#include "IECore/Exception.h" -#include "IECore/MatrixAlgo.h" -#include "IECore/MatrixTraits.h" -#include "IECorePython/ImathMatrixBinding.h" -#include "IECorePython/IECoreBinding.h" - -using namespace boost::python; -using namespace Imath; -using namespace std; -using namespace IECore; - -// Binding implementations -namespace IECorePython -{ - -template -static const char *typeName() -{ - BOOST_STATIC_ASSERT( sizeof(L) == 0 ); - return ""; -} - -template<> -const char *typeName() -{ - return "M33f"; -} - -template<> -const char *typeName() -{ - return "M33d"; -} - -template<> -const char *typeName() -{ - return "M44f"; -} - -template<> -const char *typeName() -{ - return "M44d"; -} - -template -void bindMatrix33(); - -template -void bindMatrix44(); - -void bindImathMatrix() -{ - bindMatrix33(); - bindMatrix33(); - - bindMatrix44(); - bindMatrix44(); -} - -template -struct MatrixBaseType -{ - typedef float BaseType; -}; - -template<> -struct MatrixBaseType< M33d > -{ - typedef double BaseType; -}; - -template<> -struct MatrixBaseType< M44d > -{ - typedef double BaseType; -}; - -template -struct MatrixDimensions -{ - static boost::python::tuple get(const T &x) - { - return boost::python::make_tuple(3, 3); - } -}; - -template -struct MatrixDimensions< Matrix44 > -{ - static boost::python::tuple get(const Matrix44 &x) - { - return boost::python::make_tuple(4, 4); - } -}; - -template -M *constructFromList( list l ) -{ - if ( IECorePython::len( l ) != (int)(MatrixTraits::dimensions() * MatrixTraits::dimensions() ) ) - { - throw InvalidArgumentException( std::string( "Invalid list length given to IECore." ) + typeName() + " constructor" ); - } - - M *r = new M(); - - int i = 0; - for ( unsigned row = 0; row < MatrixTraits::dimensions(); row ++ ) - { - for ( unsigned col = 0; col < MatrixTraits::dimensions(); col ++ ) - { - extract< typename MatrixTraits::BaseType > ex( l[i++] ); - if ( !ex.check() ) - { - throw InvalidArgumentException( std::string( "Invalid list element given to IECore." ) + typeName() + " constructor" ); - } - - (*r)[row][col] = ex(); - } - } - - return r ; -} - -template -M *constructFromMatrix33( const T &m ) -{ - return new M( - m[0][0], m[0][1], m[0][2], - m[1][0], m[1][1], m[1][2], - m[2][0], m[2][1], m[2][2] - ); -} - -template -M *constructFromMatrix44( const T &m ) -{ - return new M( - m[0][0], m[0][1], m[0][2], m[0][3], - m[1][0], m[1][1], m[1][2], m[1][3], - m[2][0], m[2][1], m[2][2], m[2][3], - m[3][0], m[3][1], m[3][2], m[3][3] - ); -} - -template -struct MatrixWrapper -{ - typedef typename MatrixBaseType::BaseType V; - static V get(const T &m, boost::python::tuple i) - { - static boost::python::tuple dims = MatrixDimensions::get(m); - - int x = extract(i[0]); - int y = extract(i[1]); - - if (x < 0 || x >= extract(dims[0]) || - y < 0 || y >= extract(dims[1])) - { - /// \todo Give a description of the error! NB Boost 1.38.0 will translate these into IndexError python exceptions - throw std::out_of_range(""); - } - - return m[x][y]; - } - - static void set(T &m, boost::python::tuple i, const V &v) - { - static boost::python::tuple dims = MatrixDimensions::get(m); - - int x = extract(i[0]); - int y = extract(i[1]); - - if (x < 0 || x >= extract(dims[0]) || - y < 0 || y >= extract(dims[1])) - { - /// \todo Give a description of the error! NB Boost 1.38.0 will translate these into IndexError python exceptions - throw std::out_of_range(""); - } - - m[x][y] = v; - } -}; - -template -static M createScaled( const V &s ) -{ - M m; - m.scale( s ); - return m; -} - -template -static M createTranslated( const V &s ) -{ - M m; - m.translate( s ); - return m; -} - -template -static M createRotated( const V &s ) -{ - M m; - m.rotate( s ); - return m; -} - -template -static V multVecMatrix( const M &m, const V &v ) -{ - V result; - m.multVecMatrix( v, result ); - return result; -} - -template -static V multDirMatrix( const M &m, const V &v ) -{ - V result; - m.multDirMatrix( v, result ); - return result; -} - -template -V extractScaling( const M &m ) -{ - V s; - extractScaling( m, s ); - return s; -} - -template -M sansScaling2( const M &m ) -{ - return sansScaling( m, true ); -} - -template -void removeScaling( M &m ) -{ - removeScaling( m, true ); -} - -template -boost::python::tuple extractScalingAndShear33( const Matrix33 &m ) -{ - Vec2 scl; - T shr; - extractScalingAndShear( m, scl, shr ); - return boost::python::make_tuple( scl, shr ); -} - -template -boost::python::tuple extractScalingAndShear44( const Matrix44 &m ) -{ - Vec3 scl; - Vec3 shr; - extractScalingAndShear( m, scl, shr ); - return boost::python::make_tuple( scl, shr ); -} - -template -M sansScalingAndShear( const M &m ) -{ - return sansScalingAndShear( m, true ); -} - -template -void removeScalingAndShear( M &m ) -{ - removeScalingAndShear( m, true ); -} - -template -boost::python::tuple extractAndRemoveScalingAndShear33( Matrix33 &m ) -{ - Vec2 scl; - T shr; - extractAndRemoveScalingAndShear( m, scl, shr, true ); - return boost::python::make_tuple( scl, shr ); -} - -template -boost::python::tuple extractAndRemoveScalingAndShear44( Matrix44 &m ) -{ - Vec3 scl, shr; - extractAndRemoveScalingAndShear( m, scl, shr, true ); - return boost::python::make_tuple( scl, shr ); -} - -template -V extractEulerXYZ( const M &m ) -{ - V r; - extractEulerXYZ( m, r ); - return r; -} - -template -V extractEulerZYX( const M &m ) -{ - V r; - extractEulerZYX( m, r ); - return r; -} - -template -boost::python::tuple extractSHRT44( const Matrix44 &m ) -{ - Vec3 s, h, r, t; - extractSHRT( m, s, h, r, t, true ); - return boost::python::make_tuple( s, h, r, t ); -} - -template -boost::python::tuple extractSHRT33( const Matrix33 &m ) -{ - Vec2 s, t; - T h, r; - extractSHRT( m, s, h, r, t, true ); - return boost::python::make_tuple( s, h, r, t ); -} - -#define DEFINEMATRIXSTRSPECIALISATION( TYPE, D )\ -template<>\ -string repr( TYPE &x )\ -{\ - stringstream s;\ - s << "IECore." << typeName() << "( ";\ - for( int i=0; i\ -string str( TYPE &x )\ -{\ - stringstream s;\ - for( int i=0; i -void bindMatrix33() -{ - const Matrix33 &(Matrix33::*setScale1)(const Vec2 &) = &Matrix33::setScale; - const Matrix33 &(Matrix33::*setScale2)(T) = &Matrix33::setScale; - - const Matrix33 &(Matrix33::*setShear1)(const T &) = &Matrix33::template setShear; - const Matrix33 &(Matrix33::*setShear2)(const Vec2 &) = &Matrix33::template setShear; - - const Matrix33 &(Matrix33::*shear1)(const T &) = &Matrix33::template shear; - const Matrix33 &(Matrix33::*shear2)(const Vec2 &) = &Matrix33::template shear; - - const char *bindName = typeName >(); - - class_< Matrix33 > cls( bindName ); - - cls.def(init<>()); - cls.def(init()); - cls.def(init()); - cls.def("__init__", make_constructor( &constructFromMatrix33< Matrix33, Matrix33 > ) ); - cls.def("__init__", make_constructor( &constructFromMatrix33< Matrix33, Matrix33 > ) ); - cls.def("__init__", make_constructor( &constructFromList< Matrix33 > ) ); - - cls.def("dimensions", &MatrixDimensions >::get); - - // [] operator support - cls.def("__getitem__", &MatrixWrapper< Matrix33 >::get); - cls.def("__setitem__", &MatrixWrapper< Matrix33 >::set); - - cls.def("makeIdentity", &Matrix33::makeIdentity); - - cls.def(self == self); - cls.def(self != self); - - cls.def("equalWithAbsError", &Matrix33::equalWithAbsError); - cls.def("equalWithRelError", &Matrix33::equalWithRelError); - - cls.def(self += self); - cls.def(self += T()); - cls.def(self + self); - - cls.def(self -= self); - cls.def(self -= T()); - cls.def(self - self); - - cls.def(- self); - cls.def("negate", &Matrix33::negate, return_self<>()); - - cls.def(self *= T()); - cls.def(self * T()); - - cls.def(self *= self); - cls.def(self * self); - - cls.def("multVecMatrix", multVecMatrix, Vec2 > ); - cls.def("multDirMatrix", multDirMatrix, Vec2 > ); - - cls.def(self /= T()); - cls.def(self / T()); - - cls.def("transpose", &Matrix33::transpose, return_self<>()); - cls.def("transposed", &Matrix33::transposed); - - cls.def("invert", &Matrix33::invert, return_self<>(), Matrix33InvertOverloads() ); - cls.def("inverse", &Matrix33::inverse, Matrix33InverseOverloads() ); - cls.def("gjInvert", &Matrix33::gjInvert, return_self<>(), Matrix33GJInvertOverloads() ); - cls.def("gjInverse", &Matrix33::gjInverse, Matrix33GJInverseOverloads() ); - - cls.def("setRotation", &Matrix33::template setRotation, return_self<>()); - cls.def("rotate", &Matrix33::template rotate, return_self<>()); - - cls.def("setScale", setScale1, return_self<>()); - cls.def("setScale", setScale2, return_self<>()); - - cls.def("scale", &Matrix33::template scale, return_self<>()); - cls.def("setTranslation", &Matrix33::template setTranslation, return_self<>()); - - cls.def("translation", &Matrix33::translation); - cls.def("translate", &Matrix33::template translate, return_self<>()); - - cls.def("setShear", setShear1, return_self<>()); - cls.def("setShear", setShear2, return_self<>()); - - cls.def("shear", shear1, return_self<>()); - cls.def("shear", shear2, return_self<>()); - - cls.def("baseTypeMin", &Matrix33::baseTypeMin).staticmethod("baseTypeMin"); - cls.def("baseTypeMax", &Matrix33::baseTypeMax).staticmethod("baseTypeMax"); - cls.def("baseTypeSmallest", &Matrix33::baseTypeSmallest).staticmethod("baseTypeSmallest"); - cls.def("baseTypeEpsilon", &Matrix33::baseTypeEpsilon).staticmethod("baseTypeEpsilon"); - - cls.def("__str__", &IECorePython::str > ); - cls.def("__repr__", &IECorePython::repr > ); - - cls.def("createScaled", &createScaled, Vec2 > ).staticmethod( "createScaled" ); - cls.def("createTranslated", &createTranslated, Vec2 > ).staticmethod( "createTranslated" ); - cls.def("createRotated", &createRotated, T > ).staticmethod( "createRotated" ); - - cls.def("extractScaling", &extractScaling, Vec2 > ); - cls.def("sansScaling", (Matrix33(*)( const Matrix33 &))&sansScaling2 > ); - cls.def("removeScaling", &removeScaling > ); - cls.def("extractScalingAndShear", &extractScalingAndShear33 ); - cls.def("sansScalingAndShear", &sansScalingAndShear > ); - cls.def("removeScalingAndShear", &removeScalingAndShear > ); - cls.def("extractAndRemoveScalingAndShear", &extractAndRemoveScalingAndShear33 ); - cls.def("extractSHRT", &extractSHRT33 ); - - cls.def("determinant", (float (*)( const Matrix33 & ))&IECore::determinant ); - ; - -} - - -BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Matrix44InvertOverloads, invert, 0, 1); -BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Matrix44InverseOverloads, inverse, 0, 1); -BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Matrix44GJInvertOverloads, gjInvert, 0, 1); -BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Matrix44GJInverseOverloads, gjInverse, 0, 1); - -template -void bindMatrix44() -{ - const Matrix44 &(Matrix44::*setScale1)(const Vec3 &) = &Matrix44::setScale; - const Matrix44 &(Matrix44::*setScale2)(T) = &Matrix44::setScale; - - const Matrix44 &(Matrix44::*setShear2)(const Vec3 &) = &Matrix44::template setShear; - - const Matrix44 &(Matrix44::*shear2)(const Vec3 &) = &Matrix44::template shear; - - const char *bindName = typeName >(); - - class_< Matrix44 > cls( bindName ); - - cls.def(init<>()); - cls.def(init()); - cls.def(init()); - cls.def(init, Vec3 >()); - cls.def("__init__", make_constructor( &constructFromMatrix44< Matrix44, Matrix44 > ) ); - cls.def("__init__", make_constructor( &constructFromMatrix44< Matrix44, Matrix44 > ) ); - cls.def("__init__", make_constructor( &constructFromList< Matrix44 > ) ); - - cls.def("dimensions", &MatrixDimensions >::get); - - // [] operator support - cls.def("__getitem__", &MatrixWrapper< Matrix44 >::get); - cls.def("__setitem__", &MatrixWrapper< Matrix44 >::set); - - cls.def("makeIdentity", &Matrix44::makeIdentity); - - cls.def(self == self); - cls.def(self != self); - - cls.def("equalWithAbsError", &Matrix44::equalWithAbsError); - cls.def("equalWithRelError", &Matrix44::equalWithRelError); - - cls.def(self += self); - cls.def(self += T()); - cls.def(self + self); - - cls.def(self -= self); - cls.def(self -= T()); - cls.def(self - self); - - cls.def(- self); - cls.def("negate", &Matrix44::negate, return_self<>()); - - cls.def(self *= T()); - cls.def(self * T()); - - cls.def(self *= self); - cls.def(self * self); - - cls.def("multVecMatrix", multVecMatrix, Vec3 > ); - cls.def("multDirMatrix", multDirMatrix, Vec3 > ); - - cls.def(self /= T()); - cls.def(self / T()); - - cls.def("transpose", &Matrix44::transpose, return_self<>()); - cls.def("transposed", &Matrix44::transposed); - - cls.def("invert", &Matrix44::invert, return_self<>(), Matrix44InvertOverloads() ); - cls.def("inverse", &Matrix44::inverse, Matrix44InverseOverloads() ); - cls.def("gjInvert", &Matrix44::gjInvert, return_self<>(), Matrix44GJInvertOverloads() ); - cls.def("gjInverse", &Matrix44::gjInverse, Matrix44GJInverseOverloads() ); - - cls.def("setEulerAngles", &Matrix44::template setEulerAngles, return_self<>()); - cls.def("setAxisAngle", &Matrix44::template setAxisAngle, return_self<>()); - cls.def("rotate", &Matrix44::template rotate, return_self<>()); - - cls.def("setScale", setScale1, return_self<>()); - cls.def("setScale", setScale2, return_self<>()); - - cls.def("scale", &Matrix44::template scale, return_self<>()); - cls.def("setTranslation", &Matrix44::template setTranslation, return_self<>()); - - cls.def("translation", &Matrix44::translation); - cls.def("translate", &Matrix44::template translate, return_self<>()); - - cls.def("setShear", setShear2, return_self<>()); - - cls.def("shear", shear2, return_self<>()); - - cls.def("baseTypeMin", &Matrix44::baseTypeMin).staticmethod("baseTypeMin"); - cls.def("baseTypeMax", &Matrix44::baseTypeMax).staticmethod("baseTypeMax"); - cls.def("baseTypeSmallest", &Matrix44::baseTypeSmallest).staticmethod("baseTypeSmallest"); - cls.def("baseTypeEpsilon", &Matrix44::baseTypeEpsilon).staticmethod("baseTypeEpsilon"); - - cls.def("__str__", &IECorePython::str > ); - cls.def("__repr__", &IECorePython::repr > ); - - cls.def("createScaled", &createScaled, Vec3 > ).staticmethod( "createScaled" ); - cls.def("createTranslated", &createTranslated, Vec3 > ).staticmethod( "createTranslated" ); - cls.def("createRotated", &createRotated, Vec3 > ).staticmethod( "createRotated" ); - cls.def("createAimed", &Imath::rotationMatrix ); - cls.def("createAimed", &Imath::rotationMatrixWithUpDir ).staticmethod( "createAimed" ); - cls.def("createFromBasis", &matrixFromBasis ).staticmethod( "createFromBasis" ); - - cls.def("extractScaling", &extractScaling, Vec3 > ); - cls.def("sansScaling", &sansScaling2 > ); - cls.def("removeScaling", &removeScaling > ); - cls.def("extractScalingAndShear", &extractScalingAndShear44 ); - cls.def("sansScalingAndShear", &sansScalingAndShear > ); - cls.def("removeScalingAndShear", &removeScalingAndShear > ); - cls.def("extractAndRemoveScalingAndShear", &extractAndRemoveScalingAndShear44 ); - cls.def("extractEulerXYZ", &extractEulerXYZ, Vec3 > ); - cls.def("extractEulerZYX", &extractEulerZYX, Vec3 > ); - cls.def("extractQuat", &extractQuat ); - cls.def("extractSHRT", &extractSHRT44 ); - - cls.def("determinant", (float (*)( const Matrix44 & ))&IECore::determinant ); - ; -} - -} diff --git a/src/IECorePython/ImathPlaneBinding.cpp b/src/IECorePython/ImathPlaneBinding.cpp deleted file mode 100644 index 9301837adb..0000000000 --- a/src/IECorePython/ImathPlaneBinding.cpp +++ /dev/null @@ -1,119 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -// This include needs to be the very first to prevent problems with warnings -// regarding redefinition of _POSIX_C_SOURCE -#include "boost/python.hpp" - -// System includes -#include -#include - -#include "OpenEXR/ImathPlane.h" -#include "OpenEXR/ImathVec.h" - -#include "IECorePython/ImathPlaneBinding.h" -#include "IECorePython/IECoreBinding.h" - -using namespace boost::python; -using namespace Imath; -using namespace std; - -namespace IECorePython -{ - -template -void bindPlane3(const char *bindName); - -void bindImathPlane() -{ - bindPlane3("Plane3f"); - bindPlane3("Plane3d"); -} - -#define DEFINEPLANEPECIALISATION( PLANE )\ -\ -template<>\ -std::string repr( PLANE &x )\ -{\ - std::stringstream s;\ - s << "IECore." << #PLANE << "( ";\ - s << repr( x.normal ) << ", ";\ - s << x.distance;\ - s << " )";\ - return s.str();\ -}\ -\ -template<>\ -std::string str( PLANE &x )\ -{\ - std::stringstream s;\ - s << str( x.normal ) << " " << str( x.distance );\ - return s.str();\ -}\ - -DEFINEPLANEPECIALISATION( Plane3f ); -DEFINEPLANEPECIALISATION( Plane3d ); - -template -void bindPlane3(const char *bindName) -{ - - void (Plane3::*set1)(const Vec3 &, T) = &Plane3::set; - void (Plane3::*set2)(const Vec3 &, const Vec3 &) = &Plane3::set; - void (Plane3::*set3)(const Vec3 &, const Vec3 &, const Vec3 &) = &Plane3::set; - - class_< Plane3 >(bindName) - .def_readwrite("normal", &Plane3::normal) - .def_readwrite("distance", &Plane3::distance) - - .def(init<>()) - .def(init &, T>()) - .def(init &, const Vec3 & >()) - .def(init &, const Vec3 &, const Vec3 & >()) - - .def( "set", set1 ) - .def( "set", set2 ) - .def( "set", set3 ) - - .def( "distanceTo", &Plane3::distanceTo ) - .def( "reflectPoint", &Plane3::reflectPoint ) - .def( "reflectVector", &Plane3::reflectVector ) - - .def( "__str__", &IECorePython::str > ) - .def( "__repr__", &IECorePython::repr > ) - ; -} - -} diff --git a/src/IECorePython/ImathQuatBinding.cpp b/src/IECorePython/ImathQuatBinding.cpp deleted file mode 100644 index 2de853fcae..0000000000 --- a/src/IECorePython/ImathQuatBinding.cpp +++ /dev/null @@ -1,201 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -// This include needs to be the very first to prevent problems with warnings -// regarding redefinition of _POSIX_C_SOURCE -#include "boost/python.hpp" - -// System includes -#include -#include - -#include "OpenEXR/ImathQuat.h" - -#include "IECore/QuatAlgo.h" - -#include "IECorePython/ImathQuatBinding.h" -#include "IECorePython/IECoreBinding.h" - -using namespace boost::python; -using namespace Imath; -using namespace IECore; - -namespace IECorePython -{ - -template -void bindQuat(const char *bindName); - -void bindImathQuat() -{ - bindQuat("Quatf"); - bindQuat("Quatd"); -} - -template -struct QuatIndexer -{ - static T get(const Quat &x, int i) - { - // Do we want to handle backward indexing? - if ( i >= 0 && i < 4 ) - { - return x[i]; - } - else - { - /// \todo Give a description of the error! NB Boost 1.38.0 will translate these into IndexError python exceptions - throw std::out_of_range(""); - } - - } - - static void set(Quat &x, int i, const T &v) - { - if ( i >= 0 && i < 4 ) - { - x[i] = v; - } - else - { - /// \todo Give a description of the error! NB Boost 1.38.0 will translate these into IndexError python exceptions - throw std::out_of_range(""); - } - } - - -}; - -/// \todo The only reason this is a macro is so that it can turn the class type to a string. We should probably do this -/// with a small traits class instead, and get rid of the macro. -#define DEFINEQUATSTRSPECIALISATION( QUAT ) \ - \ -template<> \ -std::string repr( QUAT &x ) \ -{ \ - std::stringstream s; \ - s << "IECore." << #QUAT << "( "; \ - for( unsigned i=0; i<4; i++ ) \ - { \ - s << x[i]; \ - if( i!=3 ) \ - { \ - s << ", "; \ - } \ - } \ - s << " )"; \ - return s.str(); \ -} \ - \ -template<> \ -std::string str( QUAT &x ) \ -{ \ - std::stringstream s; \ - for( unsigned i=0; i<4; i++ ) \ - { \ - s << x[i]; \ - if( i!=3 ) \ - { \ - s << " "; \ - } \ - } \ - return s.str(); \ -} \ - -DEFINEQUATSTRSPECIALISATION( Quatf ); -DEFINEQUATSTRSPECIALISATION( Quatd ); - -template -void bindQuat(const char *bindName) -{ - class_< Quat >(bindName) - .def_readwrite("r", &Quat::r) - .def_readwrite("v", &Quat::v) - - // [] operator support - .def("__getitem__", &QuatIndexer::get) - .def("__setitem__", &QuatIndexer::set) - - .def(init<>()) - .def(init >()) - .def(init()) - .def(init >()) - - .def("identity", &Quat::identity).staticmethod("identity") - - .def(self ^ self) - - .def(self *= self) - .def(self *= T()) - .def(self /= self) - .def(self /= T()) - .def(self += self) - .def(self -= self) - - .def(self == self) - .def(self != self) - - .def( self * self ) - - .def( ~self ) - - .def("invert", &Quat::invert, return_self<>()) - .def("inverse", &Quat::inverse) - .def("normalize", &Quat::normalize, return_self<>()) - .def("normalized", &Quat::normalized) - .def("length", &Quat::length) - - .def("setAxisAngle", &Quat::setAxisAngle, return_self<>()) - .def("setRotation", &Quat::setRotation, return_self<>()) - - .def("angle", &Quat::angle) - .def("axis", &Quat::axis) - - .def("toMatrix33", &Quat::toMatrix33) - .def("toMatrix44", &Quat::toMatrix44) - - .def("log", &Quat::log) - .def("exp", &Quat::exp) - - .def("__str__", IECorePython::str >) - .def("__repr__", IECorePython::repr >) - ; - - def("slerp", IECore::slerp); - def("slerpShortestArc", IECore::slerpShortestArc); - def("squad", squad); - def("spline", spline); -} - -} diff --git a/src/IECorePython/ImathRandomBinding.cpp b/src/IECorePython/ImathRandomBinding.cpp deleted file mode 100644 index 2c350732b8..0000000000 --- a/src/IECorePython/ImathRandomBinding.cpp +++ /dev/null @@ -1,219 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2013, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -// This include needs to be the very first to prevent problems with warnings -// regarding redefinition of _POSIX_C_SOURCE -#include "boost/python.hpp" - -#include "IECorePython/ImathRandomBinding.h" -#include "IECore/VectorTypedData.h" -#include "IECore/Random.h" - -#include "OpenEXR/ImathRandom.h" -#include "OpenEXR/ImathVec.h" -#include "OpenEXR/ImathColor.h" - -#include "boost/type_traits.hpp" - -using namespace boost::python; -using namespace boost; -using namespace Imath; -using namespace IECore; - -namespace IECorePython -{ - -template -float nextFloat( R &r ) -{ - return r.nextf(); -} - -template -T nextVec( R &r ) -{ - T result; - for( unsigned int i=0; i -struct Vectoriser -{ -// typedef ResultType::ValueType T; - typedef typename ResultType::Ptr ResultTypePtr; - typedef typename ResultType::ValueType ValueType; - typedef typename ValueType::iterator Iterator; - - static ResultTypePtr vectorise( R &r, size_t size ) - { - ResultTypePtr result = new ResultType; - ValueType &v = result->writable(); - v.resize( size ); - for( Iterator it=v.begin(); it!=v.end(); it++ ) - { - *it = F( r ); - } - return result; - }; - - template - static ResultTypePtr vectoriseSeededT( R &r, typename S::ConstPtr seeds ) - { - const typename S::ValueType &seedsV = seeds->readable(); - ResultTypePtr result = new ResultType; - ValueType &v = result->writable(); - v.resize( seedsV.size() ); - typename S::ValueType::const_iterator sIt = seedsV.begin(); - for( Iterator it=v.begin(); it!=v.end(); it++ ) - { - r.init( (long unsigned int)(*sIt++) ); - *it = F( r ); - } - return result; - } - - static ResultTypePtr vectoriseSeeded( R &r, ConstDataPtr seeds ) - { - switch( seeds->typeId() ) - { - case FloatVectorDataTypeId : - return vectoriseSeededT( r, boost::static_pointer_cast( seeds ) ); - case DoubleVectorDataTypeId : - return vectoriseSeededT( r, boost::static_pointer_cast( seeds ) ); - case IntVectorDataTypeId : - return vectoriseSeededT( r, boost::static_pointer_cast( seeds ) ); - case UIntVectorDataTypeId : - return vectoriseSeededT( r, boost::static_pointer_cast( seeds ) ); - default : - throw Exception( "Unsupported type for seeds parameter." ); - } - return nullptr; - } - -}; - -template -void bindRand( const char *className ) -{ - - class_( className ) - .def( init() ) - .def( "init", &T::init ) - .def( "nextb", &T::nextb ) - .def( "nexti", &T::nexti ) - .def( "nextf", (F (T::*)())&T::nextf ) - .def( "nextf", (F (T::*)( F, F ))&T::nextf ) - .def( "fVector", &Vectoriser >::vectoriseSeeded ) - .def( "fVector", &Vectoriser >::vectorise ) - .def( "nextV2f", &nextVec ) - .def( "nextV3f", &nextVec ) - .def( "nextV2d", &nextVec ) - .def( "nextV3d", &nextVec ) - .def( "v2fVector", &Vectoriser >::vectoriseSeeded ) - .def( "v2fVector", &Vectoriser >::vectorise ) - .def( "v2dVector", &Vectoriser >::vectoriseSeeded ) - .def( "v2dVector", &Vectoriser >::vectorise ) - .def( "v3fVector", &Vectoriser >::vectoriseSeeded ) - .def( "v3fVector", &Vectoriser >::vectorise ) - .def( "v3dVector", &Vectoriser >::vectoriseSeeded ) - .def( "v3dVector", &Vectoriser >::vectorise ) - .def( "nextColor3f", &nextVec ) - .def( "color3fVector", &Vectoriser >::vectoriseSeeded ) - .def( "color3fVector", &Vectoriser >::vectorise ) - .def( "gauss", &gaussRand ) - .def( "gaussVector", &Vectoriser >::vectoriseSeeded ) - .def( "gaussVector", &Vectoriser >::vectorise ) - .def( "solidCirclef", &solidSphereRand ) - .def( "solidCircled", &solidSphereRand ) - .def( "solidCirclefVector", &Vectoriser >::vectoriseSeeded ) - .def( "solidCirclefVector", &Vectoriser >::vectorise ) - .def( "solidCircledVector", &Vectoriser >::vectoriseSeeded ) - .def( "solidCircledVector", &Vectoriser >::vectorise ) - .def( "solidSpheref", &solidSphereRand ) - .def( "solidSphered", &solidSphereRand ) - .def( "solidSpherefVector", &Vectoriser >::vectoriseSeeded ) - .def( "solidSpherefVector", &Vectoriser >::vectorise ) - .def( "solidSpheredVector", &Vectoriser >::vectoriseSeeded ) - .def( "solidSpheredVector", &Vectoriser >::vectorise ) - .def( "hollowCirclef", &hollowSphereRand ) - .def( "hollowCircled", &hollowSphereRand ) - .def( "hollowCirclefVector", &Vectoriser >::vectoriseSeeded ) - .def( "hollowCirclefVector", &Vectoriser >::vectorise ) - .def( "hollowCircledVector", &Vectoriser >::vectoriseSeeded ) - .def( "hollowCircledVector", &Vectoriser >::vectorise ) - .def( "hollowSpheref", &hollowSphereRand ) - .def( "hollowSphered", &hollowSphereRand ) - .def( "hollowSpherefVector", &Vectoriser >::vectoriseSeeded ) - .def( "hollowSpherefVector", &Vectoriser >::vectorise ) - .def( "hollowSpheredVector", &Vectoriser >::vectoriseSeeded ) - .def( "hollowSpheredVector", &Vectoriser >::vectorise ) - .def( "gaussCirclef", &gaussSphereRand ) - .def( "gaussCircled", &gaussSphereRand ) - .def( "gaussCirclefVector", &Vectoriser >::vectoriseSeeded ) - .def( "gaussCirclefVector", &Vectoriser >::vectorise ) - .def( "gaussCircledVector", &Vectoriser >::vectoriseSeeded ) - .def( "gaussCircledVector", &Vectoriser >::vectorise ) - .def( "gaussSpheref", &gaussSphereRand ) - .def( "gaussSphered", &gaussSphereRand ) - .def( "gaussSpherefVector", &Vectoriser >::vectoriseSeeded ) - .def( "gaussSpherefVector", &Vectoriser >::vectorise ) - .def( "gaussSpheredVector", &Vectoriser >::vectoriseSeeded ) - .def( "gaussSpheredVector", &Vectoriser >::vectorise ) - .def( "cosineHemispheref", &cosineHemisphereRand ) - .def( "cosineHemisphered", &cosineHemisphereRand ) - .def( "cosineHemispherefVector", &Vectoriser >::vectoriseSeeded ) - .def( "cosineHemispherefVector", &Vectoriser >::vectorise ) - .def( "cosineHemispheredVector", &Vectoriser >::vectoriseSeeded ) - .def( "cosineHemispheredVector", &Vectoriser >::vectorise ) - .def( "barycentricf", &barycentricRand ) - .def( "barycentricd", &barycentricRand ) - .def( "barycentricfVector", &Vectoriser >::vectoriseSeeded ) - .def( "barycentricfVector", &Vectoriser >::vectorise ) - .def( "barycentricdVector", &Vectoriser >::vectoriseSeeded ) - .def( "barycentricdVector", &Vectoriser >::vectorise ) - ; - -} - -void bindImathRandom() -{ - bindRand( "Rand32" ); - bindRand( "Rand48" ); -} - -} // namespace IECorePython diff --git a/src/IECorePython/ImathRootsBinding.cpp b/src/IECorePython/ImathRootsBinding.cpp deleted file mode 100644 index 9c22d7280f..0000000000 --- a/src/IECorePython/ImathRootsBinding.cpp +++ /dev/null @@ -1,113 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -// This include needs to be the very first to prevent problems with warnings -// regarding redefinition of _POSIX_C_SOURCE -#include "boost/python.hpp" - -#include "OpenEXR/ImathRoots.h" - -#include "IECorePython/ImathRootsBinding.h" - -using namespace boost::python; -using namespace Imath; - -namespace IECorePython -{ - -tuple solveLinearWrapper( double a, double b ) -{ - double x; - int s = solveLinear( a, b, x ); - switch( s ) - { - case 0 : - return tuple(); - case 1 : - return make_tuple( x ); - default : - PyErr_SetString( PyExc_ArithmeticError, "Infinite solutions." ); - throw_error_already_set(); - return tuple(); // should never get here - } -} - -tuple solveQuadraticWrapper( double a, double b, double c ) -{ - double x[2]; - int s = solveQuadratic( a, b, c, x ); - switch( s ) - { - case 0 : - return tuple(); - case 1 : - return make_tuple( x[0] ); - case 2 : - return make_tuple( x[0], x[1] ); - default : - PyErr_SetString( PyExc_ArithmeticError, "Infinite solutions." ); - throw_error_already_set(); - return tuple(); // should never get here - } -} - -tuple solveCubicWrapper( double a, double b, double c, double d ) -{ - double x[3]; - int s = solveCubic( a, b, c, d, x ); - switch( s ) - { - case 0 : - return tuple(); - case 1 : - return make_tuple( x[0] ); - case 2 : - return make_tuple( x[0], x[1] ); - case 3 : - return make_tuple( x[0], x[1], x[2] ); - default : - PyErr_SetString( PyExc_ArithmeticError, "Infinite solutions." ); - throw_error_already_set(); - return tuple(); // should never get here - } -} - -void bindImathRoots() -{ - def( "solveLinear", &solveLinearWrapper ); - def( "solveQuadratic", &solveQuadraticWrapper ); - def( "solveCubic", &solveCubicWrapper ); -} - -} diff --git a/src/IECorePython/ImathVecBinding.cpp b/src/IECorePython/ImathVecBinding.cpp deleted file mode 100644 index 422b36430b..0000000000 --- a/src/IECorePython/ImathVecBinding.cpp +++ /dev/null @@ -1,401 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of Image Engine Design nor the names of any -// other contributors to this software may be used to endorse or -// promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////// - -// This include needs to be the very first to prevent problems with warnings -// regarding redefinition of _POSIX_C_SOURCE -#include "boost/python.hpp" - -// System includes -#include -#include - -#include "OpenEXR/ImathVec.h" -#include "OpenEXR/ImathMatrix.h" - -#include "IECore/Exception.h" - -#include "IECorePython/ImathVecBinding.h" -#include "IECorePython/IECoreBinding.h" - -using namespace boost::python; -using namespace Imath; -using namespace std; -using namespace IECore; - -namespace IECorePython -{ - -template -static const char *typeName() -{ - BOOST_STATIC_ASSERT( sizeof(L) == 0 ); - return ""; -} - -template<> -const char *typeName() -{ - return "V2f"; -} - -template<> -const char *typeName() -{ - return "V2d"; -} - -template<> -const char *typeName() -{ - return "V2i"; -} - -template<> -const char *typeName() -{ - return "V3f"; -} - -template<> -const char *typeName() -{ - return "V3d"; -} - -template<> -const char *typeName() -{ - return "V3i"; -} - -template -void bindVec2(); - -template -void bindVec3(); - -void bindImathVec() -{ - bindVec2(); - bindVec2(); - bindVec2(); - - bindVec3(); - bindVec3(); - bindVec3(); -} - -template -struct VectorIndexer -{ - typedef typename T::BaseType V; - static V get(const T &x, int i) - { - // Do we want to handle backward indexing? - if ( i >= 0 && i < static_cast(T::dimensions()) ) - { - return x[i]; - } - else - { - /// \todo Give a description of the error! NB Boost 1.38.0 will translate these into IndexError python exceptions - throw std::out_of_range(""); - } - - } - - static void set(T &x, int i, const V &v) - { - if ( i >= 0 && i < static_cast(T::dimensions()) ) - { - x[i] = v; - } - else - { - /// \todo Give a description of the error! NB Boost 1.38.0 will translate these into IndexError python exceptions - throw std::out_of_range(""); - } - } - -}; - -#define DEFINEVECSTRSPECIALISATION( VEC )\ -\ -template<>\ -std::string repr( VEC &x )\ -{\ - std::stringstream s;\ - s << "IECore." << typeName() << "( ";\ - for( unsigned i=0; i( x[i] );\ - if( i!=VEC::dimensions()-1 )\ - {\ - s << ", ";\ - }\ - }\ - s << " )";\ - return s.str();\ -}\ -\ -template<>\ -std::string str( VEC &x )\ -{\ - std::stringstream s;\ - for( unsigned i=0; i( x[i] );\ - if( i!=VEC::dimensions()-1 )\ - {\ - s << " ";\ - }\ - }\ - return s.str();\ -}\ - -DEFINEVECSTRSPECIALISATION( V2i ); -DEFINEVECSTRSPECIALISATION( V2f ); -DEFINEVECSTRSPECIALISATION( V2d ); -DEFINEVECSTRSPECIALISATION( V3i ); -DEFINEVECSTRSPECIALISATION( V3f ); -DEFINEVECSTRSPECIALISATION( V3d ); - -template -V *constructFromList( list l ) -{ - if ( IECorePython::len( l ) != (int)V::dimensions() ) - { - throw InvalidArgumentException( std::string( "Invalid list length given to IECore." ) + typeName() + " constructor" ); - } - - V *r = new V(); - - for ( unsigned i = 0; i < V::dimensions(); i ++ ) - { - extract< typename V::BaseType > ex( l[i] ); - if ( !ex.check() ) - { - throw InvalidArgumentException( std::string( "Invalid list element given to IECore." ) + typeName() + " constructor" ); - } - - (*r)[i] = ex(); - } - - return r ; -} - -template -void bindVec2() -{ - // To allow correct resolve of overloaded methods - void (Vec2::*sv1)(T, T) = &Vec2::template setValue; - void (Vec2::*sv2)(const Vec2&) = &Vec2::template setValue; - - const char *bindName = typeName >(); - - class_< Vec2 >( bindName ) - .def_readwrite("x", &Vec2::x) - .def_readwrite("y", &Vec2::y) - - // [] operator support - .def("__getitem__", &VectorIndexer >::get) - .def("__setitem__", &VectorIndexer >::set) - - .def(init<>()) - .def(init()) - .def(init()) - - .def(init &>()) - .def(init &>()) - .def(init &>()) - - .def("__init__", make_constructor( &constructFromList< Vec2 > ) ) - - .def("setValue", sv1) - .def("setValue", sv2) - - .def(self == self) - .def(self != self) - - .def("equalWithAbsError", &Vec2::equalWithAbsError) - .def("equalWithRelError", &Vec2::equalWithRelError) - - .def("dot", &Vec2::dot) - - .def("cross", &Vec2::cross) - - .def(self ^ self) - - .def(self % self) - - .def(self += self) - .def(self + self) - - .def(self -= self) - .def(self - self) - - .def(- self) - .def("negate", &Vec2::negate, return_self<>()) - - .def(self *= self) - .def(self *= T()) - .def(self * self) - .def(self * T()) - .def(T() * self) - - .def(self /= self) - .def(self /= T()) - .def(self / self) - .def(self / T()) - - .def(self * Matrix33()) - .def(self *= Matrix33()) - - .def("length", &Vec2::length) - .def("length2", &Vec2::length2) - - .def("normalize", &Vec2::normalize, return_self<>()) - .def("normalizeExc", &Vec2::normalizeExc, return_self<>()) - .def("normalizeNonNull", &Vec2::normalizeNonNull, return_self<>()) - - .def("normalized", &Vec2::normalized) - .def("normalizedExc", &Vec2::normalizedExc) - .def("normalizedNonNull", &Vec2::normalizedNonNull) - - .def("dimensions", &Vec2::dimensions).staticmethod("dimensions") - - .def("baseTypeMin", &Vec2::baseTypeMin).staticmethod("baseTypeMin") - .def("baseTypeMax", &Vec2::baseTypeMax).staticmethod("baseTypeMax") - .def("baseTypeSmallest", &Vec2::baseTypeSmallest).staticmethod("baseTypeSmallest") - .def("baseTypeEpsilon", &Vec2::baseTypeEpsilon).staticmethod("baseTypeEpsilon") - - .def( "__str__", &IECorePython::str > ) - .def( "__repr__", &IECorePython::repr > ) - ; -} - - -template -void bindVec3() -{ - // To allow correct resolve of overloaded methods - void (Vec3::*sv1)(T, T, T) = &Vec3::template setValue; - void (Vec3::*sv2)(const Vec3&) = &Vec3::template setValue; - - const char *bindName = typeName >(); - - class_< Vec3 >( bindName ) - .def_readwrite("x", &Vec3::x) - .def_readwrite("y", &Vec3::y) - .def_readwrite("z", &Vec3::z) - - // [] operator support - .def("__getitem__", &VectorIndexer >::get) - .def("__setitem__", &VectorIndexer >::set) - - .def(init<>()) - .def(init()) - .def(init()) - - .def(init &>()) - .def(init &>()) - .def(init &>()) - - .def("__init__", make_constructor( &constructFromList< Vec3 > ) ) - - .def("setValue", sv1) - .def("setValue", sv2) - - .def(self == self) - .def(self != self) - - .def("equalWithAbsError", &Vec3::equalWithAbsError) - .def("equalWithRelError", &Vec3::equalWithRelError) - - .def("dot", &Vec3::dot) - - .def("cross", &Vec3::cross) - - .def(self ^ self) - - .def(self %= self) - .def(self % self) - - .def(self += self) - .def(self + self) - - .def(self -= self) - .def(self - self) - - .def(- self) - .def("negate", &Vec3::negate, return_self<>()) - - .def(self *= self) - .def(self *= T()) - .def(self * self) - .def(self * T()) - .def(T() * self) - - .def(self /= self) - .def(self /= T()) - .def(self / self) - .def(self / T()) - - .def(self * Matrix44()) - .def(self *= Matrix44()) - - .def("length", &Vec3::length) - .def("length2", &Vec3::length2) - - .def("normalize", &Vec3::normalize, return_self<>()) - .def("normalizeExc", &Vec3::normalizeExc, return_self<>()) - .def("normalizeNonNull", &Vec3::normalizeNonNull, return_self<>()) - - .def("normalized", &Vec3::normalized) - .def("normalizedExc", &Vec3::normalizedExc) - .def("normalizedNonNull", &Vec3::normalizedNonNull) - - .def("dimensions", &Vec3::dimensions).staticmethod("dimensions") - - .def("baseTypeMin", &Vec3::baseTypeMin).staticmethod("baseTypeMin") - .def("baseTypeMax", &Vec3::baseTypeMax).staticmethod("baseTypeMax") - .def("baseTypeSmallest", &Vec3::baseTypeSmallest).staticmethod("baseTypeSmallest") - .def("baseTypeEpsilon", &Vec3::baseTypeEpsilon).staticmethod("baseTypeEpsilon") - - .def( "__str__", &IECorePython::str > ) - .def( "__repr__", &IECorePython::repr > ) - ; -} - -} diff --git a/src/IECorePython/MurmurHashBinding.cpp b/src/IECorePython/MurmurHashBinding.cpp index 0d9a8c461a..eab31b895d 100644 --- a/src/IECorePython/MurmurHashBinding.cpp +++ b/src/IECorePython/MurmurHashBinding.cpp @@ -88,9 +88,7 @@ void bindMurmurHash() .def( "append", (MurmurHash &(MurmurHash::*)( const Imath::V3f & ))&MurmurHash::append, return_self<>() ) .def( "append", (MurmurHash &(MurmurHash::*)( const Imath::V3d & ))&MurmurHash::append, return_self<>() ) .def( "append", (MurmurHash &(MurmurHash::*)( const Imath::Color3f & ))&MurmurHash::append, return_self<>() ) - .def( "append", (MurmurHash &(MurmurHash::*)( const Imath::Color3 & ))&MurmurHash::append, return_self<>() ) .def( "append", (MurmurHash &(MurmurHash::*)( const Imath::Color4f & ))&MurmurHash::append, return_self<>() ) - .def( "append", (MurmurHash &(MurmurHash::*)( const Imath::Color4 & ))&MurmurHash::append, return_self<>() ) .def( "append", (MurmurHash &(MurmurHash::*)( const Imath::M33f & ))&MurmurHash::append, return_self<>() ) .def( "append", (MurmurHash &(MurmurHash::*)( const Imath::M33d & ))&MurmurHash::append, return_self<>() ) .def( "append", (MurmurHash &(MurmurHash::*)( const Imath::M44f & ))&MurmurHash::append, return_self<>() ) @@ -125,9 +123,7 @@ void bindMurmurHash() .def( "append", &appendArray, return_self<>() ) .def( "append", &appendArray, return_self<>() ) .def( "append", &appendArray, return_self<>() ) - .def( "append", &appendArray >, return_self<>() ) .def( "append", &appendArray, return_self<>() ) - .def( "append", &appendArray >, return_self<>() ) .def( "append", &appendArray, return_self<>() ) .def( "append", &appendArray, return_self<>() ) .def( "append", &appendArray, return_self<>() ) diff --git a/src/IECorePython/ImathBinding.cpp b/src/IECorePython/RandomAlgoBinding.cpp similarity index 63% rename from src/IECorePython/ImathBinding.cpp rename to src/IECorePython/RandomAlgoBinding.cpp index dbc35153ac..eb9160142d 100644 --- a/src/IECorePython/ImathBinding.cpp +++ b/src/IECorePython/RandomAlgoBinding.cpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2007-2010, Image Engine Design Inc. All rights reserved. +// Copyright (c) 2017, Image Engine Design Inc. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -32,31 +32,46 @@ // ////////////////////////////////////////////////////////////////////////// +#include "boost/python.hpp" -#include "IECorePython/ImathBinding.h" -#include "IECorePython/ImathVecBinding.h" -#include "IECorePython/ImathBoxBinding.h" -#include "IECorePython/ImathQuatBinding.h" -#include "IECorePython/ImathMatrixBinding.h" -#include "IECorePython/ImathColorBinding.h" -#include "IECorePython/ImathEulerBinding.h" -#include "IECorePython/ImathRootsBinding.h" -#include "IECorePython/ImathPlaneBinding.h" +#include "IECore/RandomAlgo.h" -// Binding implementations -namespace IECorePython +#include "IECorePython/RandomAlgoBinding.h" + +using namespace boost::python; +using namespace Imath; +using namespace IECore; +using namespace IECorePython; + +namespace { -void bindImath() +template +void bind() { - bindImathVec(); - bindImathBox(); - bindImathQuat(); - bindImathMatrix(); - bindImathColor(); - bindImathEuler(); - bindImathRoots(); - bindImathPlane(); + + def( "barycentricRandf", &RandomAlgo::barycentricRand ); + def( "barycentricRandd", &RandomAlgo::barycentricRand ); + + def( "triangleRandf", &RandomAlgo::barycentricRand ); + def( "triangleRandd", &RandomAlgo::barycentricRand ); + + def( "cosineHemisphereRandf", &RandomAlgo::cosineHemisphereRand ); + def( "cosineHemisphereRandd", &RandomAlgo::cosineHemisphereRand ); + } +} // namespace + +void IECorePython::bindRandomAlgo() +{ + + object randomAlgoModule( borrowed( PyImport_AddModule( "IECore.RandomAlgo" ) ) ); + scope().attr( "RandomAlgo" ) = randomAlgoModule; + + scope randomAlgoScope( randomAlgoModule ); + + bind(); + bind(); + } diff --git a/src/IECorePython/SimpleTypedDataBinding.cpp b/src/IECorePython/SimpleTypedDataBinding.cpp index 17b9455c85..9c2662b3d9 100644 --- a/src/IECorePython/SimpleTypedDataBinding.cpp +++ b/src/IECorePython/SimpleTypedDataBinding.cpp @@ -250,8 +250,6 @@ DEFINETYPEDDATASTRSPECIALISATION( Box3f ); DEFINETYPEDDATASTRSPECIALISATION( Box3d ); DEFINETYPEDDATASTRSPECIALISATION( Color3f ); DEFINETYPEDDATASTRSPECIALISATION( Color4f ); -DEFINETYPEDDATASTRSPECIALISATION( Color3 ); -DEFINETYPEDDATASTRSPECIALISATION( Color4 ); DEFINETYPEDDATASTRSPECIALISATION( M33f ); DEFINETYPEDDATASTRSPECIALISATION( M33d ); DEFINETYPEDDATASTRSPECIALISATION( M44f ); @@ -370,6 +368,9 @@ void bindAllSimpleTypedData() bindNumericMethods( ui64dc ); ui64dc.def( "__long__", &getValue ); + bindSimpleData(); + bindSimpleData(); + bindSimpleGeometricData(); bindSimpleGeometricData(); bindSimpleGeometricData(); @@ -401,14 +402,6 @@ void bindAllSimpleTypedData() bindSimpleData(); - bindSimpleData(); - - bindSimpleData(); - - bindSimpleData(); - - bindSimpleData(); - bindSimpleData(); bindSimpleData(); diff --git a/src/IECorePythonModule/IECore.cpp b/src/IECorePythonModule/IECore.cpp index b21a25c0d3..826f7f39ee 100644 --- a/src/IECorePythonModule/IECore.cpp +++ b/src/IECorePythonModule/IECore.cpp @@ -41,10 +41,11 @@ #include "tbb/tbb_thread.h" +#include "OpenEXR/ImathEuler.h" + #include "IECorePython/RefCountedBinding.h" #include "IECorePython/RunTimeTypedBinding.h" #include "IECorePython/ExceptionBinding.h" -#include "IECorePython/ImathBinding.h" #include "IECorePython/KDTreeBinding.h" #include "IECorePython/IndexedIOBinding.h" #include "IECorePython/DataBinding.h" @@ -100,7 +101,6 @@ #include "IECorePython/DataCastOpBinding.h" #include "IECorePython/DataPromoteOpBinding.h" #include "IECorePython/MatrixMultiplyOpBinding.h" -#include "IECorePython/ImathRandomBinding.h" #include "IECorePython/RandomRotationOpBinding.h" #include "IECorePython/InternedStringBinding.h" #include "IECorePython/InverseDistanceWeightedInterpolationBinding.h" @@ -155,6 +155,8 @@ #include "IECorePython/StandardRadialLensModelBinding.h" #include "IECorePython/ObjectPoolBinding.h" #include "IECorePython/DataAlgoBinding.h" +#include "IECorePython/BoxAlgoBinding.h" +#include "IECorePython/RandomAlgoBinding.h" #include "IECore/IECore.h" using namespace IECorePython; @@ -173,6 +175,11 @@ bool isDebug() #endif } +std::string defaultRepr( object &o ) +{ + return extract( o.attr( "__repr__" )() ); +} + } // namespace // Module declaration @@ -182,7 +189,6 @@ BOOST_PYTHON_MODULE(_IECore) bindRefCounted(); bindRunTimeTyped(); bindException(); - bindImath(); bindKDTree(); bindObject(); bindCompoundObject(); @@ -239,7 +245,6 @@ BOOST_PYTHON_MODULE(_IECore) bindDataCastOp(); bindDataPromoteOp(); bindMatrixMultiplyOp(); - bindImathRandom(); bindRandomRotationOp(); bindInternedString(); bindInverseDistanceWeightedInterpolation(); @@ -293,6 +298,8 @@ BOOST_PYTHON_MODULE(_IECore) bindStandardRadialLensModel(); bindObjectPool(); bindDataAlgo(); + bindBoxAlgo(); + bindRandomAlgo(); def( "majorVersion", &IECore::majorVersion ); def( "minorVersion", &IECore::minorVersion ); @@ -302,4 +309,38 @@ BOOST_PYTHON_MODULE(_IECore) def( "withFreeType", &IECore::withFreeType ); def( "initThreads", &PyEval_InitThreads ); def( "hardwareConcurrency", &tbb::tbb_thread::hardware_concurrency ); + + // Expose our own implementation of `repr()` for all the Imath + // types, along with a fallback version for all other types. This + // gives us a way of reliably round-tripping values through + // `eval( repr( value) )`, which is needed in Gaffer's serialisation + // among other places. The standard imath versions aren't suitable + // for this because they don't include the module prefix. + + def( "repr", &defaultRepr ); + def( "repr", &repr ); + def( "repr", &repr ); + def( "repr", &repr ); + def( "repr", &repr ); + def( "repr", &repr ); + def( "repr", &repr ); + def( "repr", &repr ); + def( "repr", &repr ); + def( "repr", &repr ); + def( "repr", &repr ); + def( "repr", &repr ); + def( "repr", &repr ); + def( "repr", &repr ); + def( "repr", &repr ); + def( "repr", &repr ); + def( "repr", &repr ); + def( "repr", &repr ); + def( "repr", &repr ); + def( "repr", &repr ); + def( "repr", &repr ); + def( "repr", &repr ); + def( "repr", &repr ); + def( "repr", &repr ); + def( "repr", &repr ); + } diff --git a/test/IECore/All.py b/test/IECore/All.py index c14ea9a643..4ff4838a03 100644 --- a/test/IECore/All.py +++ b/test/IECore/All.py @@ -104,9 +104,7 @@ from BezierAlgoTest import * from UnicodeToStringTest import * from RadixSortTest import * -from ImathRootsTest import * from AngleConversionTest import * -from RandomTest import * from SplineTest import * from SplineDataTest import * from TypeIdTest import * @@ -151,6 +149,9 @@ from RefCountedTest import RefCountedTest from DataAlgoTest import DataAlgoTest from PolygonAlgoTest import PolygonAlgoTest +from BoxAlgoTest import BoxAlgoTest +from RandomAlgoTest import RandomAlgoTest +from ReprTest import ReprTest unittest.TestProgram( testRunner = unittest.TextTestRunner( diff --git a/test/IECore/AngleConversionTest.py b/test/IECore/AngleConversionTest.py index 84ca79d2a6..73be7ee70f 100644 --- a/test/IECore/AngleConversionTest.py +++ b/test/IECore/AngleConversionTest.py @@ -34,15 +34,16 @@ import math import unittest +import imath import IECore class AngleConversionTest( unittest.TestCase ) : def test( self ) : - d = IECore.V3f( 180, 90, 360 ) + d = imath.V3f( 180, 90, 360 ) r = IECore.degreesToRadians( d ) - self.assert_( isinstance( r, IECore.V3f ) ) + self.assert_( isinstance( r, imath.V3f ) ) self.assert_( r.equalWithAbsError( d * math.pi / 180.0, 0.0001 ) ) self.assertAlmostEqual( IECore.radiansToDegrees( math.pi ), 180, 6 ) diff --git a/test/IECore/BezierAlgoTest.py b/test/IECore/BezierAlgoTest.py index 0ff1b2a89f..bf90a6bbe8 100644 --- a/test/IECore/BezierAlgoTest.py +++ b/test/IECore/BezierAlgoTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import math @@ -42,16 +43,16 @@ def testCubic( self ) : def c( p, v ) : - p.append( IECore.V3f( v[0], v[1], 0 ) ) + p.append( imath.V3f( v[0], v[1], 0 ) ) p = IECore.V3fVectorData() - IECore.bezierSubdivide( IECore.V2f( 0 ), IECore.V2f( 0, 1 ), IECore.V2f( 1, 1 ), IECore.V2f( 1, 0 ), 0.01, lambda v : c( p, v ) ) + IECore.bezierSubdivide( imath.V2f( 0 ), imath.V2f( 0, 1 ), imath.V2f( 1, 1 ), imath.V2f( 1, 0 ), 0.01, lambda v : c( p, v ) ) - self.assertEqual( p[0], IECore.V3f( 0 ) ) - self.assertEqual( p[-1], IECore.V3f( 1, 0, 0 ) ) + self.assertEqual( p[0], imath.V3f( 0 ) ) + self.assertEqual( p[-1], imath.V3f( 1, 0, 0 ) ) - b = IECore.Box3f( IECore.V3f( 0, 0, 0 ), IECore.V3f( 1, 1, 0 ) ) + b = imath.Box3f( imath.V3f( 0, 0, 0 ), imath.V3f( 1, 1, 0 ) ) for i in range( 0, p.size()-1 ) : self.assert_( b.intersects( p[i] ) ) @@ -61,16 +62,16 @@ def testQuadratic( self ) : def c( p, v ) : - p.append( IECore.V3f( v[0], v[1], 0 ) ) + p.append( imath.V3f( v[0], v[1], 0 ) ) p = IECore.V3fVectorData() - IECore.bezierSubdivide( IECore.V2f( 0 ), IECore.V2f( 1, 1 ), IECore.V2f( 2, 0 ), 0.01, lambda v : c( p, v ) ) + IECore.bezierSubdivide( imath.V2f( 0 ), imath.V2f( 1, 1 ), imath.V2f( 2, 0 ), 0.01, lambda v : c( p, v ) ) - self.assertEqual( p[0], IECore.V3f( 0 ) ) - self.assertEqual( p[-1], IECore.V3f( 2, 0, 0 ) ) + self.assertEqual( p[0], imath.V3f( 0 ) ) + self.assertEqual( p[-1], imath.V3f( 2, 0, 0 ) ) - b = IECore.Box3f( IECore.V3f( 0, 0, 0 ), IECore.V3f( 2, 1, 0 ) ) + b = imath.Box3f( imath.V3f( 0, 0, 0 ), imath.V3f( 2, 1, 0 ) ) for i in range( 0, p.size()-1 ) : self.assert_( b.intersects( p[i] ) ) diff --git a/test/IECore/BoundedKDTree.py b/test/IECore/BoundedKDTree.py index 427baa0891..e4c3780bab 100644 --- a/test/IECore/BoundedKDTree.py +++ b/test/IECore/BoundedKDTree.py @@ -35,6 +35,7 @@ import math import random import unittest +import imath import IECore class TestBoundedKDTree: @@ -75,17 +76,17 @@ def doIntersectingBounds(self, numBounds): class TestBoundedKDTreeBox3f(unittest.TestCase, TestBoundedKDTree): def makeRandomBound( self ) : - b1 = IECore.V3f( random.random(), random.random(), random.random() ) - b2 = IECore.V3f( random.random(), random.random(), random.random() ) - bound = IECore.Box3f( b1 ) + b1 = imath.V3f( random.random(), random.random(), random.random() ) + b2 = imath.V3f( random.random(), random.random(), random.random() ) + bound = imath.Box3f( b1 ) bound.extendBy( b2 ) return bound def makeBound( self ) : - b1 = IECore.V3f( -3, -3, -3 ) - b2 = IECore.V3f( -2, -2, -2 ) - bound = IECore.Box3f( b1, b2 ) + b1 = imath.V3f( -3, -3, -3 ) + b2 = imath.V3f( -2, -2, -2 ) + bound = imath.Box3f( b1, b2 ) return bound @@ -124,17 +125,17 @@ def testIntersectingBounds(self): class TestBoundedKDTreeBox3d(unittest.TestCase, TestBoundedKDTree): def makeRandomBound( self ) : - b1 = IECore.V3d( random.random(), random.random(), random.random() ) - b2 = IECore.V3d( random.random(), random.random(), random.random() ) - bound = IECore.Box3d( b1 ) + b1 = imath.V3d( random.random(), random.random(), random.random() ) + b2 = imath.V3d( random.random(), random.random(), random.random() ) + bound = imath.Box3d( b1 ) bound.extendBy( b2 ) return bound def makeBound( self ) : - b1 = IECore.V3d( -1, -1, -1) - b2 = IECore.V3d( 1, 1, 1 ) - bound = IECore.Box3d( b1, b2 ) + b1 = imath.V3d( -1, -1, -1) + b2 = imath.V3d( 1, 1, 1 ) + bound = imath.Box3d( b1, b2 ) return bound @@ -173,17 +174,17 @@ def testIntersectingBounds(self): class TestBoundedKDTreeBox2f(unittest.TestCase, TestBoundedKDTree): def makeRandomBound( self ) : - b1 = IECore.V2f( random.random(), random.random() ) - b2 = IECore.V2f( random.random(), random.random() ) - bound = IECore.Box2f( b1 ) + b1 = imath.V2f( random.random(), random.random() ) + b2 = imath.V2f( random.random(), random.random() ) + bound = imath.Box2f( b1 ) bound.extendBy( b2 ) return bound def makeBound( self ) : - b1 = IECore.V2f( -1, -1 ) - b2 = IECore.V2f( 1, 1 ) - bound = IECore.Box2f( b1, b2 ) + b1 = imath.V2f( -1, -1 ) + b2 = imath.V2f( 1, 1 ) + bound = imath.Box2f( b1, b2 ) return bound @@ -223,17 +224,17 @@ def testIntersectingBounds(self): class TestBoundedKDTreeBox2d(unittest.TestCase, TestBoundedKDTree): def makeRandomBound( self ) : - b1 = IECore.V2d( random.random(), random.random() ) - b2 = IECore.V2d( random.random(), random.random() ) - bound = IECore.Box2d( b1 ) + b1 = imath.V2d( random.random(), random.random() ) + b2 = imath.V2d( random.random(), random.random() ) + bound = imath.Box2d( b1 ) bound.extendBy( b2 ) return bound def makeBound( self ) : - b1 = IECore.V2d( -1, -1 ) - b2 = IECore.V2d( 1, 1 ) - bound = IECore.Box2d( b1, b2 ) + b1 = imath.V2d( -1, -1 ) + b2 = imath.V2d( 1, 1 ) + bound = imath.Box2d( b1, b2 ) return bound diff --git a/test/IECoreScene/PointsExpressionOp.py b/test/IECore/BoxAlgoTest.py similarity index 54% rename from test/IECoreScene/PointsExpressionOp.py rename to test/IECore/BoxAlgoTest.py index 7f10b4b1d2..e59c7990a0 100644 --- a/test/IECoreScene/PointsExpressionOp.py +++ b/test/IECore/BoxAlgoTest.py @@ -1,6 +1,6 @@ ########################################################################## # -# Copyright (c) 2007, Image Engine Design Inc. All rights reserved. +# Copyright (c) 2017, Image Engine Design Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -33,52 +33,49 @@ ########################################################################## import unittest +import imath + import IECore -import IECoreScene -class TestPointsExpressionTest( unittest.TestCase ) : +class BoxAlgoTest( unittest.TestCase ) : - def setUp( self ) : + def testContains( self ) : - numPoints = 100 + b1 = imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ) + b2 = imath.Box3f( imath.V3f( 0, -0.5, 0.5 ), imath.V3f( 0.1, 0, 0.9 ) ) + b3 = imath.Box3f( imath.V3f( -1.2, -0.6, 0.4 ), imath.V3f( 0.2, 0.1, 1 ) ) - points = IECore.V3fVectorData( numPoints ) - colors = IECore.Color3fVectorData( numPoints ) - ints = IECore.IntVectorData( numPoints ) + self.assertTrue( IECore.BoxAlgo.contains( b1, b2 ) ) + self.assertFalse( IECore.BoxAlgo.contains( b2, b1 ) ) - self.p = IECoreScene.PointsPrimitive( numPoints ) - self.p["P"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, points ) - self.p["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Varying, colors ) - self.p["int"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Varying, ints ) + self.assertFalse( IECore.BoxAlgo.contains( b2, b3 ) ) + self.assertTrue( IECore.BoxAlgo.contains( b3, b2 ) ) - def testRemoval( self ) : + self.assertFalse( IECore.BoxAlgo.contains( b3, b1 ) ) + self.assertFalse( IECore.BoxAlgo.contains( b1, b3 ) ) - o = IECoreScene.PointsExpressionOp() - p = o( input = self.p, expression = "remove = i % 2" ) + def testSplit( self ) : - self.assertEqual( p.numPoints, self.p.numPoints / 2 ) - for k in p.keys() : - self.assertEqual( len( p[k].data ), len( self.p[k].data ) / 2 ) + r = imath.Rand32() + for i in range( 0, 100 ) : - def testAssignment( self ) : + b = imath.Box3f() + b.extendBy( imath.V3f( r.nextf(), r.nextf(), r.nextf() ) ) + b.extendBy( imath.V3f( r.nextf(), r.nextf(), r.nextf() ) ) - o = IECoreScene.PointsExpressionOp() - p = o( input = self.p, expression = "int = i * 10" ) + major = b.majorAxis() - self.assertEqual( p.numPoints, self.p.numPoints ) - ints = p["int"].data - for i in range( p.numPoints ) : - self.assertEqual( i * 10, ints[i] ) + low, high = IECore.BoxAlgo.split( b ) + low2, high2 = IECore.BoxAlgo.split( b, major ) - def testGlobals( self ) : + self.assertEqual( low, low2 ) + self.assertEqual( high, high2 ) - o = IECoreScene.PointsExpressionOp() - p = o( input = self.p, expression = "P = IECore.V3f( i )" ) + b2 = imath.Box3f() + b2.extendBy( low ) + b2.extendBy( high ) - points = p["P"].data - for i in range( p.numPoints ) : - self.assert_( points[i].equalWithAbsError( IECore.V3f( i ), 0.0001 ) ) + self.assertEqual( b, b2 ) if __name__ == "__main__": unittest.main() - diff --git a/test/IECore/CompoundData.py b/test/IECore/CompoundData.py index 2c93fc4922..a49069b996 100644 --- a/test/IECore/CompoundData.py +++ b/test/IECore/CompoundData.py @@ -39,6 +39,7 @@ import unittest import sys import subprocess +import imath import IECore diff --git a/test/IECore/CompoundVectorParameterTest.py b/test/IECore/CompoundVectorParameterTest.py index 735b4dfe06..e4bf64f3a5 100644 --- a/test/IECore/CompoundVectorParameterTest.py +++ b/test/IECore/CompoundVectorParameterTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore @@ -44,7 +45,7 @@ def testConstruction( self ) : # test valid parameters c.addParameter( IECore.IntVectorParameter( 'a', '', IECore.IntVectorData( [ 1, 2 ] ) ) ) c.addParameter( IECore.BoolVectorParameter( 'b', '', IECore.BoolVectorData( [ False, False ] ) ) ) - c.addParameters( [ IECore.V2fVectorParameter( 'c', '', IECore.V2fVectorData( [ IECore.V2f(), IECore.V2f() ] ) ), + c.addParameters( [ IECore.V2fVectorParameter( 'c', '', IECore.V2fVectorData( [ imath.V2f(), imath.V2f() ] ) ), IECore.StringVectorParameter( 'd', '', IECore.StringVectorData( [ 'one', 'two' ] ) ) ] ) self.assertEqual( len(c.keys()), 4 ) diff --git a/test/IECore/CubicBasisTest.py b/test/IECore/CubicBasisTest.py index 540a7bdc7b..90f254851b 100644 --- a/test/IECore/CubicBasisTest.py +++ b/test/IECore/CubicBasisTest.py @@ -35,25 +35,26 @@ import math import unittest import random +import imath import IECore class CubicTest( unittest.TestCase ) : def testConstructor( self ) : - m = IECore.M44f( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ) + m = imath.M44f( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ) b = IECore.CubicBasisf( m, 10 ) self.assertEqual( b.matrix, m ) self.assertEqual( b.step, 10 ) def testAccessors( self ) : - m = IECore.M44f( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ) + m = imath.M44f( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ) b = IECore.CubicBasisf( m, 10 ) self.assertEqual( b.matrix, m ) self.assertEqual( b.step, 10 ) - m2 = IECore.M44f( 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 ) + m2 = imath.M44f( 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 ) b.matrix = m2 self.assertEqual( b.matrix, m2 ) @@ -104,10 +105,10 @@ def testCall( self ) : b = IECore.CubicBasisf.bezier() - p0 = IECore.V3f( 0 ) - p1 = IECore.V3f( 0, 1, 0 ) - p2 = IECore.V3f( 1, 1, 0 ) - p3 = IECore.V3f( 1, 0, 0 ) + p0 = imath.V3f( 0 ) + p1 = imath.V3f( 0, 1, 0 ) + p2 = imath.V3f( 1, 1, 0 ) + p3 = imath.V3f( 1, 0, 0 ) p = b( 0, p0, p1, p2, p3 ) self.assertEqual( p, p0 ) diff --git a/test/IECore/DataAlgoTest.py b/test/IECore/DataAlgoTest.py index 287697b32b..f210cd2ce7 100644 --- a/test/IECore/DataAlgoTest.py +++ b/test/IECore/DataAlgoTest.py @@ -34,6 +34,7 @@ import unittest import math +import imath import IECore class DataAlgoTest( unittest.TestCase ) : @@ -42,8 +43,8 @@ def testGetGeometricInterpretation( self ) : self.assertEqual( IECore.GeometricData.Interpretation.Vector, IECore.getGeometricInterpretation( IECore.V3fVectorData( [], IECore.GeometricData.Interpretation.Vector ) ) ) self.assertEqual( IECore.GeometricData.Interpretation.Normal, IECore.getGeometricInterpretation( IECore.V3fVectorData( [], IECore.GeometricData.Interpretation.Normal ) ) ) - self.assertEqual( IECore.GeometricData.Interpretation.Point, IECore.getGeometricInterpretation( IECore.V3fData( IECore.V3f( 1 ), IECore.GeometricData.Interpretation.Point ) ) ) - self.assertEqual( IECore.GeometricData.Interpretation.None, IECore.getGeometricInterpretation( IECore.V3fData( IECore.V3f( 1 ), IECore.GeometricData.Interpretation.None ) ) ) + self.assertEqual( IECore.GeometricData.Interpretation.Point, IECore.getGeometricInterpretation( IECore.V3fData( imath.V3f( 1 ), IECore.GeometricData.Interpretation.Point ) ) ) + self.assertEqual( IECore.GeometricData.Interpretation.None, IECore.getGeometricInterpretation( IECore.V3fData( imath.V3f( 1 ), IECore.GeometricData.Interpretation.None ) ) ) self.assertEqual( IECore.GeometricData.Interpretation.None, IECore.getGeometricInterpretation( IECore.FloatData( 5 ) ) ) self.assertEqual( IECore.GeometricData.Interpretation.None, IECore.getGeometricInterpretation( IECore.StringData( "foo" ) ) ) @@ -56,7 +57,7 @@ def testSetGeometricInterpretation( self ) : IECore.setGeometricInterpretation( v, IECore.GeometricData.Interpretation.Normal ) self.assertEqual( IECore.GeometricData.Interpretation.Normal, IECore.getGeometricInterpretation( v ) ) - v = IECore.V3fData( IECore.V3f( 0 ) ) + v = IECore.V3fData( imath.V3f( 0 ) ) self.assertEqual( IECore.GeometricData.Interpretation.None, IECore.getGeometricInterpretation( v ) ) IECore.setGeometricInterpretation( v, IECore.GeometricData.Interpretation.Point ) self.assertEqual( IECore.GeometricData.Interpretation.Point, IECore.getGeometricInterpretation( v ) ) diff --git a/test/IECore/DataCastOp.py b/test/IECore/DataCastOp.py index 0add1aa02a..2d0422918d 100644 --- a/test/IECore/DataCastOp.py +++ b/test/IECore/DataCastOp.py @@ -34,6 +34,7 @@ import unittest import os.path +import imath import IECore @@ -44,24 +45,24 @@ def testTypeConvertion( self ) : self.assertEqual( IECore.DataCastOp()( object = IECore.FloatData( 2 ), targetType = int(IECore.TypeId.DoubleData) ), IECore.DoubleData( 2 ) ) self.assertEqual( IECore.DataCastOp()( object = IECore.DoubleData( 2 ), targetType = int(IECore.TypeId.FloatData) ), IECore.FloatData( 2 ) ) self.assertEqual( IECore.DataCastOp()( object = IECore.IntData( 2 ), targetType = int(IECore.TypeId.UIntData) ), IECore.UIntData( 2 ) ) - self.assertEqual( IECore.DataCastOp()( object = IECore.V3fData( IECore.V3f( 2 ) ), targetType = int(IECore.TypeId.V3dData) ), IECore.V3dData( IECore.V3d( 2 ) ) ) - self.assertEqual( IECore.DataCastOp()( object = IECore.QuatfData( IECore.Quatf( 1,2,3,4 ) ), targetType = int(IECore.TypeId.QuatdData) ), IECore.QuatdData( IECore.Quatd( 1,2,3,4 ) ) ) + self.assertEqual( IECore.DataCastOp()( object = IECore.V3fData( imath.V3f( 2 ) ), targetType = int(IECore.TypeId.V3dData) ), IECore.V3dData( imath.V3d( 2 ) ) ) + self.assertEqual( IECore.DataCastOp()( object = IECore.QuatfData( imath.Quatf( 1,2,3,4 ) ), targetType = int(IECore.TypeId.QuatdData) ), IECore.QuatdData( imath.Quatd( 1,2,3,4 ) ) ) def testStructureConvertion( self ) : - self.assertEqual( IECore.DataCastOp()( object = IECore.V3fData( IECore.V3f( 1, 2, 3 ) ), targetType = int(IECore.TypeId.FloatVectorData) ), IECore.FloatVectorData( [ 1, 2, 3 ] ) ) - self.assertEqual( IECore.DataCastOp()( object = IECore.V3fData( IECore.V3f( 1, 2, 3 ) ), targetType = int(IECore.TypeId.Color3fData) ), IECore.Color3fData( IECore.Color3f( 1, 2, 3 ) ) ) - self.assertEqual( IECore.DataCastOp()( object = IECore.V3fVectorData( [ IECore.V3f(1), IECore.V3f(2), IECore.V3f(3) ] ), targetType = int(IECore.TypeId.FloatVectorData) ), IECore.FloatVectorData( [ 1, 1, 1, 2, 2, 2, 3, 3, 3 ] ) ) + self.assertEqual( IECore.DataCastOp()( object = IECore.V3fData( imath.V3f( 1, 2, 3 ) ), targetType = int(IECore.TypeId.FloatVectorData) ), IECore.FloatVectorData( [ 1, 2, 3 ] ) ) + self.assertEqual( IECore.DataCastOp()( object = IECore.V3fData( imath.V3f( 1, 2, 3 ) ), targetType = int(IECore.TypeId.Color3fData) ), IECore.Color3fData( imath.Color3f( 1, 2, 3 ) ) ) + self.assertEqual( IECore.DataCastOp()( object = IECore.V3fVectorData( [ imath.V3f(1), imath.V3f(2), imath.V3f(3) ] ), targetType = int(IECore.TypeId.FloatVectorData) ), IECore.FloatVectorData( [ 1, 1, 1, 2, 2, 2, 3, 3, 3 ] ) ) - self.assertEqual( IECore.DataCastOp()( object = IECore.FloatVectorData( [ 1, 2, 3 ] ), targetType = int(IECore.TypeId.V3fData) ), IECore.V3fData( IECore.V3f( 1, 2, 3 ) ) ) - self.assertEqual( IECore.DataCastOp()( object = IECore.Color3fData( IECore.Color3f( 1, 2, 3 ) ), targetType = int(IECore.TypeId.V3fData) ), IECore.V3fData( IECore.V3f( 1, 2, 3 ) ) ) - self.assertEqual( IECore.DataCastOp()( object = IECore.FloatVectorData( [ 1, 1, 1, 2, 2, 2, 3, 3, 3 ] ), targetType = int(IECore.TypeId.V3fVectorData) ), IECore.V3fVectorData( [ IECore.V3f(1), IECore.V3f(2), IECore.V3f(3) ] ) ) - self.assertEqual( IECore.DataCastOp()( object = IECore.V3fVectorData( [ IECore.V3f(1), IECore.V3f(2), IECore.V3f(3) ] ), targetType = int(IECore.TypeId.Color3fVectorData) ), IECore.Color3fVectorData( [ IECore.Color3f(1), IECore.Color3f(2), IECore.Color3f(3) ] ) ) - self.assertEqual( IECore.DataCastOp()( object = IECore.V3dVectorData( [ IECore.V3d(1), IECore.V3d(2), IECore.V3d(3) ] ), targetType = int(IECore.TypeId.Color3fVectorData) ), IECore.Color3fVectorData( [ IECore.Color3f(1), IECore.Color3f(2), IECore.Color3f(3) ] ) ) + self.assertEqual( IECore.DataCastOp()( object = IECore.FloatVectorData( [ 1, 2, 3 ] ), targetType = int(IECore.TypeId.V3fData) ), IECore.V3fData( imath.V3f( 1, 2, 3 ) ) ) + self.assertEqual( IECore.DataCastOp()( object = IECore.Color3fData( imath.Color3f( 1, 2, 3 ) ), targetType = int(IECore.TypeId.V3fData) ), IECore.V3fData( imath.V3f( 1, 2, 3 ) ) ) + self.assertEqual( IECore.DataCastOp()( object = IECore.FloatVectorData( [ 1, 1, 1, 2, 2, 2, 3, 3, 3 ] ), targetType = int(IECore.TypeId.V3fVectorData) ), IECore.V3fVectorData( [ imath.V3f(1), imath.V3f(2), imath.V3f(3) ] ) ) + self.assertEqual( IECore.DataCastOp()( object = IECore.V3fVectorData( [ imath.V3f(1), imath.V3f(2), imath.V3f(3) ] ), targetType = int(IECore.TypeId.Color3fVectorData) ), IECore.Color3fVectorData( [ imath.Color3f(1), imath.Color3f(2), imath.Color3f(3) ] ) ) + self.assertEqual( IECore.DataCastOp()( object = IECore.V3dVectorData( [ imath.V3d(1), imath.V3d(2), imath.V3d(3) ] ), targetType = int(IECore.TypeId.Color3fVectorData) ), IECore.Color3fVectorData( [ imath.Color3f(1), imath.Color3f(2), imath.Color3f(3) ] ) ) def testInvalidConversions( self ) : tests = [ ( IECore.FloatVectorData( [ 1, 2, 3 ] ), int(IECore.TypeId.V2fData) ), - ( IECore.M33f(), int( IECore.TypeId.M44fData ) ), + ( imath.M33f(), int( IECore.TypeId.M44fData ) ), ( IECore.FloatVectorData( [ 1, 2, 3, 4 ] ), int(IECore.TypeId.V3fData) ), ( IECore.FloatVectorData( [ 1, 2 ] ), int(IECore.TypeId.V3fData) ), ( IECore.FloatVectorData( [ 1, 2, 3, 4 ] ), int(IECore.TypeId.V3fVectorData) ), diff --git a/test/IECore/DataConvertOpTest.py b/test/IECore/DataConvertOpTest.py index 7a98132142..f47fb741f5 100644 --- a/test/IECore/DataConvertOpTest.py +++ b/test/IECore/DataConvertOpTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore @@ -66,7 +67,7 @@ def testDimensionUpConversion( self ) : self.assertEqual( o, - IECore.V3fVectorData( [ IECore.V3f( 0, 0.5, 1 ), IECore.V3f( 0.1, 2, 10 ) ] ) + IECore.V3fVectorData( [ imath.V3f( 0, 0.5, 1 ), imath.V3f( 0.1, 2, 10 ) ] ) ) @@ -74,7 +75,7 @@ def testDimensionDownConversion( self ) : o = IECore.DataConvertOp()( - data = IECore.V3iVectorData( [ IECore.V3i( 1, 2, 3 ), IECore.V3i( 4, 5, 6 ) ] ), + data = IECore.V3iVectorData( [ imath.V3i( 1, 2, 3 ), imath.V3i( 4, 5, 6 ) ] ), targetType = IECore.IntVectorData.staticTypeId() ) diff --git a/test/IECore/DataInterleaveOpTest.py b/test/IECore/DataInterleaveOpTest.py index fd7dc64005..1471630985 100644 --- a/test/IECore/DataInterleaveOpTest.py +++ b/test/IECore/DataInterleaveOpTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore @@ -142,7 +143,7 @@ def testInterleaveIntoV3( self ) : self.assertEqual( o, - IECore.V3iVectorData( [ IECore.V3i( 1, 11, 21 ), IECore.V3i( 2, 12, 22 ), ] ) + IECore.V3iVectorData( [ imath.V3i( 1, 11, 21 ), imath.V3i( 2, 12, 22 ), ] ) ) diff --git a/test/IECore/DataPromoteOp.py b/test/IECore/DataPromoteOp.py index bff7a14cec..eb8c56dda6 100644 --- a/test/IECore/DataPromoteOp.py +++ b/test/IECore/DataPromoteOp.py @@ -34,6 +34,7 @@ import unittest import os.path +import imath import IECore @@ -55,19 +56,19 @@ def testVector( self ) : op = IECore.DataPromoteOp() - self.assertEqual( op( object = self.__makeVectorSourceData( IECore.IntVectorData ), targetType=int(IECore.TypeId.V3fVectorData) ), IECore.V3fVectorData( [ IECore.V3f( x ) for x in v ] ) ) - self.assertEqual( op( object = self.__makeVectorSourceData( IECore.ShortVectorData ), targetType=int(IECore.TypeId.V3dVectorData) ), IECore.V3dVectorData( [ IECore.V3d( x ) for x in v ] ) ) - self.assertEqual( op( object = self.__makeVectorSourceData( IECore.HalfVectorData ), targetType=int(IECore.TypeId.Color3fVectorData) ), IECore.Color3fVectorData( [ IECore.Color3f( x ) for x in v ] ) ) - self.assertEqual( op( object = self.__makeVectorSourceData( IECore.HalfVectorData ), targetType=int(IECore.TypeId.Color3fVectorData) ), IECore.Color3fVectorData( [ IECore.Color3f( x ) for x in v ] ) ) - self.assertEqual( op( object = self.__makeVectorSourceData( IECore.HalfVectorData ), targetType=int(IECore.TypeId.V2fVectorData) ), IECore.V2fVectorData( [ IECore.V2f( x ) for x in v ] ) ) + self.assertEqual( op( object = self.__makeVectorSourceData( IECore.IntVectorData ), targetType=int(IECore.TypeId.V3fVectorData) ), IECore.V3fVectorData( [ imath.V3f( x ) for x in v ] ) ) + self.assertEqual( op( object = self.__makeVectorSourceData( IECore.ShortVectorData ), targetType=int(IECore.TypeId.V3dVectorData) ), IECore.V3dVectorData( [ imath.V3d( x ) for x in v ] ) ) + self.assertEqual( op( object = self.__makeVectorSourceData( IECore.HalfVectorData ), targetType=int(IECore.TypeId.Color3fVectorData) ), IECore.Color3fVectorData( [ imath.Color3f( x ) for x in v ] ) ) + self.assertEqual( op( object = self.__makeVectorSourceData( IECore.HalfVectorData ), targetType=int(IECore.TypeId.Color3fVectorData) ), IECore.Color3fVectorData( [ imath.Color3f( x ) for x in v ] ) ) + self.assertEqual( op( object = self.__makeVectorSourceData( IECore.HalfVectorData ), targetType=int(IECore.TypeId.V2fVectorData) ), IECore.V2fVectorData( [ imath.V2f( x ) for x in v ] ) ) def testSimple( self ) : op = IECore.DataPromoteOp() - self.assertEqual( op( object = IECore.IntData(2), targetType=int(IECore.TypeId.V3fData) ), IECore.V3fData( IECore.V3f(2.0) ) ) - self.assertEqual( op( object = IECore.IntData(2), targetType=int(IECore.TypeId.V3dData) ), IECore.V3dData( IECore.V3d(2.0) ) ) - self.assertEqual( op( object = IECore.IntData(2), targetType=int(IECore.TypeId.Color3fData) ), IECore.Color3fData( IECore.Color3f(2.0) ) ) + self.assertEqual( op( object = IECore.IntData(2), targetType=int(IECore.TypeId.V3fData) ), IECore.V3fData( imath.V3f(2.0) ) ) + self.assertEqual( op( object = IECore.IntData(2), targetType=int(IECore.TypeId.V3dData) ), IECore.V3dData( imath.V3d(2.0) ) ) + self.assertEqual( op( object = IECore.IntData(2), targetType=int(IECore.TypeId.Color3fData) ), IECore.Color3fData( imath.Color3f(2.0) ) ) if __name__ == "__main__": unittest.main() diff --git a/test/IECore/DataTraitsTest.py b/test/IECore/DataTraitsTest.py index 63331e1f9e..6198e1115d 100644 --- a/test/IECore/DataTraitsTest.py +++ b/test/IECore/DataTraitsTest.py @@ -47,7 +47,7 @@ class DataTraitsTest( unittest.TestCase ) : ##\ todo: it seems that vectors, colors, and boxes shouldn't qualify as matrixData __matrixData = [ IECore.V2fData(), IECore.V2dData(), IECore.V2iData(), IECore.V3fData(), IECore.V3dData(), IECore.V3iData(), - IECore.Color3fData(), IECore.Color3dData(), IECore.Color4fData(), IECore.Color4dData(), IECore.Box2iData(), IECore.Box3iData(), IECore.Box2fData(), + IECore.Color3fData(), IECore.Color4fData(), IECore.Box2iData(), IECore.Box3iData(), IECore.Box2fData(), IECore.Box2dData(), IECore.Box3fData(), IECore.Box3dData(), IECore.M33fData(), IECore.M33dData(), IECore.M44fData(), IECore.M44dData() ] __sequenceData = [ IECore.BoolVectorData(), IECore.CharVectorData(), IECore.UCharVectorData(), IECore.StringVectorData(), @@ -56,8 +56,7 @@ class DataTraitsTest( unittest.TestCase ) : IECore.V2dVectorData(), IECore.V2iVectorData(), IECore.V3fVectorData(), IECore.V3dVectorData(), IECore.V3iVectorData(), IECore.QuatfVectorData(), IECore.QuatdVectorData(), IECore.Box2iVectorData(), IECore.Box2fVectorData(), IECore.Box2dVectorData(), IECore.Box3iVectorData(), IECore.Box3fVectorData(), IECore.Box3dVectorData(), IECore.M33fVectorData(), IECore.M33dVectorData(), - IECore.M44fVectorData(), IECore.M44dVectorData(), IECore.Color3fVectorData(), IECore.Color3dVectorData(), IECore.Color4fVectorData(), - IECore.Color4dVectorData() ] + IECore.M44fVectorData(), IECore.M44dVectorData(), IECore.Color3fVectorData(), IECore.Color4fVectorData() ] ##\ todo: it seems that transformation matrices should qualify as matrixData __complexData = [ IECore.TransformationMatrixfData(), IECore.TransformationMatrixdData(), IECore.QuatfData(), IECore.QuatdData(), @@ -98,22 +97,6 @@ def testIsSimpleNumericDataType( self ) : for data in falseData : self.assertFalse( IECore.DataTraits.isSimpleNumericDataType( data ) ) - def testIsMatrixDataType( self ) : - - trueData = [] - trueData.extend( DataTraitsTest.__matrixData ) - for data in trueData : - self.assertTrue( IECore.DataTraits.isMatrixDataType( data ) ) - - falseData = [] - falseData.extend( DataTraitsTest.__simpleData ) - falseData.extend( DataTraitsTest.__simpleNumericData ) - falseData.extend( DataTraitsTest.__sequenceData ) - falseData.extend( DataTraitsTest.__complexData ) - falseData.extend( DataTraitsTest.__compoundData ) - for data in falseData : - self.assertFalse( IECore.DataTraits.isMatrixDataType( data ) ) - def testIsMappingDataType( self ) : trueData = [] diff --git a/test/IECore/Imath.py b/test/IECore/Imath.py index 81fe1fc7d8..096a5576a7 100644 --- a/test/IECore/Imath.py +++ b/test/IECore/Imath.py @@ -37,6 +37,7 @@ import math import unittest import random +import imath import IECore @@ -44,54 +45,54 @@ class ImathV2f(unittest.TestCase): def testConstructors(self): """Test V2f constructors""" - v = IECore.V2f() - v = IECore.V2f(1) + v = imath.V2f() + v = imath.V2f(1) self.assertEqual(v.x, 1) self.assertEqual(v.y, 1) - v = IECore.V2f(2, 3) + v = imath.V2f(2, 3) self.assertEqual(v.x, 2) self.assertEqual(v.y, 3) - self.assertEqual( IECore.V2f( IECore.V2i( 1, 2 ) ), IECore.V2f( 1, 2 ) ) - self.assertEqual( IECore.V2f( IECore.V2f( 1, 2 ) ), IECore.V2f( 1, 2 ) ) - self.assertEqual( IECore.V2f( IECore.V2d( 1, 2 ) ), IECore.V2f( 1, 2 ) ) + 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( IECore.V2d( IECore.V2i( 1, 2 ) ), IECore.V2d( 1, 2 ) ) - self.assertEqual( IECore.V2d( IECore.V2f( 1, 2 ) ), IECore.V2d( 1, 2 ) ) - self.assertEqual( IECore.V2d( IECore.V2d( 1, 2 ) ), IECore.V2d( 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( IECore.V2i( IECore.V2i( 1, 2 ) ), IECore.V2i( 1, 2 ) ) - self.assertEqual( IECore.V2i( IECore.V2f( 1, 2 ) ), IECore.V2i( 1, 2 ) ) - self.assertEqual( IECore.V2i( IECore.V2d( 1, 2 ) ), IECore.V2i( 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( IECore.V3f( IECore.V3i( 1, 2, 3 ) ), IECore.V3f( 1, 2, 3 ) ) - self.assertEqual( IECore.V3f( IECore.V3f( 1, 2, 3 ) ), IECore.V3f( 1, 2, 3 ) ) - self.assertEqual( IECore.V3f( IECore.V3d( 1, 2, 3 ) ), IECore.V3f( 1, 2, 3 ) ) + 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( IECore.V3d( IECore.V3i( 1, 2, 3 ) ), IECore.V3d( 1, 2, 3 ) ) - self.assertEqual( IECore.V3d( IECore.V3f( 1, 2, 3 ) ), IECore.V3d( 1, 2, 3 ) ) - self.assertEqual( IECore.V3d( IECore.V3d( 1, 2, 3 ) ), IECore.V3d( 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( IECore.V3i( IECore.V3i( 1, 2, 3 ) ), IECore.V3i( 1, 2, 3 ) ) - self.assertEqual( IECore.V3i( IECore.V3f( 1, 2, 3 ) ), IECore.V3i( 1, 2, 3 ) ) - self.assertEqual( IECore.V3i( IECore.V3d( 1, 2, 3 ) ), IECore.V3i( 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 = IECore.V2f( [ 1, 1 ] ) + v = imath.V2f( [ 1, 1 ] ) self.assertEqual(v.x, 1) self.assertEqual(v.y, 1) - self.assertRaises( RuntimeError, IECore.V2f, [ 1 ] ) - self.assertRaises( RuntimeError, IECore.V2f, [ 1, 2, 3 ] ) + self.assertRaises( RuntimeError, imath.V2f, [ 1 ] ) + self.assertRaises( RuntimeError, imath.V2f, [ 1, 2, 3 ] ) def testDimensions(self): """Test V2f dimensions""" - v = IECore.V2f() + v = imath.V2f() self.assertEqual( v.dimensions(), 2 ) def testIndexing(self): """Test V2f indexing via operator[]""" - v1 = IECore.V2f(1.0, 2.0) + v1 = imath.V2f(1.0, 2.0) self.assertEqual(v1[0], 1.0) self.assertEqual(v1[1], 2.0) @@ -105,8 +106,8 @@ def testIndexing(self): def testCopyAndAssign(self): """Test V2f copy construction and assignment""" - v1 = IECore.V2f(2.0) - v2 = IECore.V2f(3.0) + v1 = imath.V2f(2.0) + v2 = imath.V2f(3.0) v2 = v1 # v2 should now contain contents of v1, v1 should be unchanged @@ -119,28 +120,28 @@ def testCopyAndAssign(self): def testEquality(self): """Test V2f comparison for equality""" - v1 = IECore.V2f(1.00) - v2 = IECore.V2f(1.01) + v1 = imath.V2f(1.00) + v2 = imath.V2f(1.01) self.assert_( v1.equalWithAbsError(v2, 0.01) ) - v1 = IECore.V2f(2.0) - v2 = IECore.V2f(3.0) + v1 = imath.V2f(2.0) + v2 = imath.V2f(3.0) self.assert_( v1.equalWithRelError(v2, 0.5) ) - v1 = IECore.V2f(1.0) - v2 = IECore.V2f(1.0) + v1 = imath.V2f(1.0) + v2 = imath.V2f(1.0) self.assert_( v1 == v2 ) - v1 = IECore.V2f(1.0) - v2 = IECore.V2f(1.1) + v1 = imath.V2f(1.0) + v2 = imath.V2f(1.1) self.assert_( v1 != v2 ) def testDotProduct(self): """Test V2f dot product""" - v1 = IECore.V2f(3.0) - v2 = IECore.V2f(4.0) + v1 = imath.V2f(3.0) + v2 = imath.V2f(4.0) # By definition self.assertEqual( v1.dot(v2), 3*4 + 3*4) @@ -157,8 +158,8 @@ def testDotProduct(self): def testCrossProduct(self): """Test V2f cross product""" - v1 = IECore.V2f(2.0, 2.0) - v2 = IECore.V2f(0.0, 2.0) + v1 = imath.V2f(2.0, 2.0) + v2 = imath.V2f(0.0, 2.0) # Area of parallelogram, by definition self.assertEqual( v1.cross(v2), 4.0 ) @@ -167,149 +168,143 @@ def testCrossProduct(self): self.assertEqual( v1.cross(v2), v1 % v2 ) # ImathVec.h comment validity - self.assertEqual( v1.cross(v2), (IECore.V3f(v1.x, v1.y, 0.0) % IECore.V3f(v2.x, v2.y, 0.0)).z ) + self.assertEqual( v1.cross(v2), (imath.V3f(v1.x, v1.y, 0.0) % imath.V3f(v2.x, v2.y, 0.0)).z ) def testOperators(self): """Test V2f arithmetic operators""" - v1 = IECore.V2f(3.4, 9.2) - v2 = IECore.V2f(5.3, -0.4) + v1 = imath.V2f(3.4, 9.2) + v2 = imath.V2f(5.3, -0.4) # ADDITION # By definition - self.assertEqual( v1 + v2, IECore.V2f( v1.x + v2.x, v1.y + v2.y ) ) + self.assertEqual( v1 + v2, imath.V2f( v1.x + v2.x, v1.y + v2.y ) ) # Commutative self.assertEqual( v1 + v2, v2 + v1 ) # Assignment - v1_copy = IECore.V2f(v1) + v1_copy = imath.V2f(v1) temp = v1 temp += v2 - self.assert_( temp is v1 ) self.assertEqual( temp, (v1_copy + v2)) # SUBTRACTION # By definition - self.assertEqual( v1 - v2, IECore.V2f( v1.x - v2.x, v1.y - v2.y ) ) + self.assertEqual( v1 - v2, imath.V2f( v1.x - v2.x, v1.y - v2.y ) ) self.assertEqual( v1 - v2, -v2 + v1 ) # Assignment - v1_copy = IECore.V2f(v1) + v1_copy = imath.V2f(v1) temp = v1 temp -= v2 - self.assert_( temp is v1 ) self.assertEqual( temp, v1_copy - v2) # NEGATION - self.assertEqual( -v1, IECore.V2f( -v1.x, -v1.y) ) + self.assertEqual( -v1, imath.V2f( -v1.x, -v1.y) ) self.assertEqual( -v1, v1.negate() ) self.assertEqual( -( -v1), v1 ) # MULTIPLICATION # By definition - self.assertEqual( v1 * v2, IECore.V2f(v1.x * v2.x, v1.y * v2.y) ) + self.assertEqual( v1 * v2, imath.V2f(v1.x * v2.x, v1.y * v2.y) ) c = 3 - self.assertEqual( v1 * c, IECore.V2f(v1.x * c, v1.y * c) ) + self.assertEqual( v1 * c, imath.V2f(v1.x * c, v1.y * c) ) # Commutative self.assertEqual( v1 * v2, v2 * v1 ) - self.assertEqual( c * v1, IECore.V2f(v1.x * c, v1.y * c) ) + self.assertEqual( c * v1, imath.V2f(v1.x * c, v1.y * c) ) # Assignment - v1_copy = IECore.V2f(v1) + v1_copy = imath.V2f(v1) temp = v1 temp *= v2 - self.assert_( temp is v1 ) self.assertEqual( temp, v1_copy * v2) - v1_copy = IECore.V2f(v1) + v1_copy = imath.V2f(v1) temp = v1 temp *= c - self.assert_( temp is v1 ) self.assertEqual( temp, v1_copy * c) # DIVISION # By definition - self.assertEqual( v1 / v2, IECore.V2f(v1.x / v2.x, v1.y / v2.y) ) - self.assertEqual( v1 / c, IECore.V2f(v1.x / c, v1.y / c) ) + self.assertEqual( v1 / v2, imath.V2f(v1.x / v2.x, v1.y / v2.y) ) + self.assertEqual( v1 / c, imath.V2f(v1.x / c, v1.y / c) ) # Assignment - v1_copy = IECore.V2f(v1) + v1_copy = imath.V2f(v1) temp = v1 temp /= v2 - self.assert_( temp is v1 ) self.assertEqual( temp, v1_copy / v2) - v1_copy = IECore.V2f(v1) + v1_copy = imath.V2f(v1) temp = v1 temp /= c - self.assert_( temp is v1 ) self.assertEqual( temp, v1_copy / c) # matrix multiplication - v1 = IECore.V2f( 1, 2 ) - m = IECore.M33f.createTranslated( IECore.V2f( 1, 2 ) ) + v1 = imath.V2f( 1, 2 ) + m = imath.M33f().translate( imath.V2f( 1, 2 ) ) v2 = v1 * m v1 *= m self.assertEqual( v1, v2 ) - self.assertEqual( v1, IECore.V2f( 2, 4 ) ) + self.assertEqual( v1, imath.V2f( 2, 4 ) ) def testMiscMethods(self): """Test V2f miscellaneous methods""" - v1 = IECore.V2f(2.3, -4.98) + v1 = imath.V2f(2.3, -4.98) self.assertAlmostEqual( v1.length2(), v1.dot(v1), 3 ) self.assertAlmostEqual( v1.length(), math.sqrt(v1.dot(v1)), 3 ) self.assertAlmostEqual( v1.length() * v1.length(), v1.length2(), 3 ) - v1 = IECore.V2f(10.0, 0.0) + v1 = imath.V2f(10.0, 0.0) self.assertEqual( v1.normalized(), v1 / v1.length() ) - self.assertEqual( v1, IECore.V2f(10.0, 0.0) ) + self.assertEqual( v1, imath.V2f(10.0, 0.0) ) v1.normalize() - self.assertEqual( v1, IECore.V2f(1.0, 0.0) ) + self.assertEqual( v1, imath.V2f(1.0, 0.0) ) class ImathV3f(unittest.TestCase): def testConstructors(self): """Test V3f constructors""" - v = IECore.V3f() - v = IECore.V3f(1) + v = imath.V3f() + v = imath.V3f(1) self.assertEqual(v.x, 1) self.assertEqual(v.y, 1) self.assertEqual(v.z, 1) - v = IECore.V3f(2, 3, 4) + v = imath.V3f(2, 3, 4) self.assertEqual(v.x, 2) self.assertEqual(v.y, 3) self.assertEqual(v.z, 4) - v = IECore.V3f( [ 1, 1, 1 ] ) + v = imath.V3f( [ 1, 1, 1 ] ) self.assertEqual(v.x, 1) self.assertEqual(v.y, 1) self.assertEqual(v.z, 1) - self.assertRaises( RuntimeError, IECore.V3f, [ 1 ] ) - self.assertRaises( RuntimeError, IECore.V3f, [ 1, 2 ] ) - self.assertRaises( RuntimeError, IECore.V3f, [ 1, 2, 3, 4 ] ) + self.assertRaises( RuntimeError, imath.V3f, [ 1 ] ) + self.assertRaises( RuntimeError, imath.V3f, [ 1, 2 ] ) + self.assertRaises( RuntimeError, imath.V3f, [ 1, 2, 3, 4 ] ) def testDimensions(self): """Test V3f dimensions""" - v = IECore.V3f() + v = imath.V3f() self.assertEqual( v.dimensions(), 3 ) def testIndexing(self): """Test V3f indexing via operator[]""" - v1 = IECore.V3f(1.0, 2.0, 3.0) + v1 = imath.V3f(1.0, 2.0, 3.0) self.assertEqual(v1[0], 1.0) self.assertEqual(v1[1], 2.0) @@ -326,8 +321,8 @@ def testIndexing(self): def testCopyAndAssign(self): """Test V3f copy construction and assignment""" - v1 = IECore.V3f(2.0) - v2 = IECore.V3f(3.0) + v1 = imath.V3f(2.0) + v2 = imath.V3f(3.0) v2 = v1 # v2 should now contain contents of v1, v1 should be unchanged @@ -342,28 +337,28 @@ def testCopyAndAssign(self): def testEquality(self): """Test V3f comparison for equality""" - v1 = IECore.V3f(1.00) - v2 = IECore.V3f(1.01) + v1 = imath.V3f(1.00) + v2 = imath.V3f(1.01) self.assert_( v1.equalWithAbsError(v2, 0.01) ) - v1 = IECore.V3f(2.0) - v2 = IECore.V3f(3.0) + v1 = imath.V3f(2.0) + v2 = imath.V3f(3.0) self.assert_( v1.equalWithRelError(v2, 0.5) ) - v1 = IECore.V3f(1.0) - v2 = IECore.V3f(1.0) + v1 = imath.V3f(1.0) + v2 = imath.V3f(1.0) self.assert_( v1 == v2 ) - v1 = IECore.V3f(1.0) - v2 = IECore.V3f(1.1) + v1 = imath.V3f(1.0) + v2 = imath.V3f(1.1) self.assert_( v1 != v2 ) def testDotProduct(self): """Test V3f dot product""" - v1 = IECore.V3f(3.0) - v2 = IECore.V3f(4.0) + v1 = imath.V3f(3.0) + v2 = imath.V3f(4.0) # By definition self.assertEqual( v1.dot(v2), 3*4 + 3*4 + 3*4) @@ -380,155 +375,149 @@ def testDotProduct(self): def testCrossProduct(self): """Test V3f cross product""" - v1 = IECore.V3f(1.0, 0.0, 0.0) - v2 = IECore.V3f(0.0, 1.0, 0.0) + v1 = imath.V3f(1.0, 0.0, 0.0) + v2 = imath.V3f(0.0, 1.0, 0.0) # Area of "parallelogram", by definition - self.assertEqual( v1.cross(v2), IECore.V3f(0.0, 0.0, 1.0) ) + self.assertEqual( v1.cross(v2), imath.V3f(0.0, 0.0, 1.0) ) # Operator/method equivalence self.assertEqual( v1.cross(v2), v1 % v2 ) def testOperators(self): """Test V3f arithmetic operators""" - v1 = IECore.V3f(3.4, 9.2, 18.05) - v2 = IECore.V3f(5.3, -0.4, -5.7 ) + v1 = imath.V3f(3.4, 9.2, 18.05) + v2 = imath.V3f(5.3, -0.4, -5.7 ) # ADDITION # By definition - self.assertEqual( v1 + v2, IECore.V3f( v1.x + v2.x, v1.y + v2.y, v1.z + v2.z ) ) + self.assertEqual( v1 + v2, imath.V3f( v1.x + v2.x, v1.y + v2.y, v1.z + v2.z ) ) # Commutative self.assertEqual( v1 + v2, v2 + v1 ) # Assignment - v1_copy = IECore.V3f(v1) + v1_copy = imath.V3f(v1) temp = v1 temp += v2 - self.assert_( temp is v1 ) self.assertEqual( temp, (v1_copy + v2)) # SUBTRACTION # By definition - self.assertEqual( v1 - v2, IECore.V3f( v1.x - v2.x, v1.y - v2.y, v1.z - v2.z ) ) + self.assertEqual( v1 - v2, imath.V3f( v1.x - v2.x, v1.y - v2.y, v1.z - v2.z ) ) self.assertEqual( v1 - v2, -v2 + v1 ) # Assignment - v1_copy = IECore.V3f(v1) + v1_copy = imath.V3f(v1) temp = v1 temp -= v2 - self.assert_( temp is v1 ) self.assertEqual( temp, v1_copy - v2) # NEGATION - self.assertEqual( -v1, IECore.V3f( -v1.x, -v1.y, -v1.z) ) + self.assertEqual( -v1, imath.V3f( -v1.x, -v1.y, -v1.z) ) self.assertEqual( -v1, v1.negate() ) self.assertEqual( -( -v1), v1 ) # MULTIPLICATION # By definition - self.assertEqual( v1 * v2, IECore.V3f(v1.x * v2.x, v1.y * v2.y, v1.z * v2.z ) ) + self.assertEqual( v1 * v2, imath.V3f(v1.x * v2.x, v1.y * v2.y, v1.z * v2.z ) ) c = 3 - self.assertEqual( v1 * c, IECore.V3f(v1.x * c, v1.y * c, v1.z * c) ) + self.assertEqual( v1 * c, imath.V3f(v1.x * c, v1.y * c, v1.z * c) ) # Commutative self.assertEqual( v1 * v2, v2 * v1 ) - self.assertEqual( c * v1, IECore.V3f(v1.x * c, v1.y * c, v1.z * c) ) + self.assertEqual( c * v1, imath.V3f(v1.x * c, v1.y * c, v1.z * c) ) # Assignment - v1_copy = IECore.V3f(v1) + v1_copy = imath.V3f(v1) temp = v1 temp *= v2 - self.assert_( temp is v1 ) self.assertEqual( temp, v1_copy * v2) - v1_copy = IECore.V3f(v1) + v1_copy = imath.V3f(v1) temp = v1 temp *= c - self.assert_( temp is v1 ) self.assertEqual( temp, v1_copy * c) # DIVISION # By definition - self.assertEqual( v1 / v2, IECore.V3f(v1.x / v2.x, v1.y / v2.y, v1.z / v2.z) ) - self.assertEqual( v1 / c, IECore.V3f(v1.x / c, v1.y / c, v1.z / c) ) + self.assertEqual( v1 / v2, imath.V3f(v1.x / v2.x, v1.y / v2.y, v1.z / v2.z) ) + self.assertEqual( v1 / c, imath.V3f(v1.x / c, v1.y / c, v1.z / c) ) # Assignment - v1_copy = IECore.V3f(v1) + v1_copy = imath.V3f(v1) temp = v1 temp /= v2 - self.assert_( temp is v1 ) self.assertEqual( temp, v1_copy / v2) - v1_copy = IECore.V3f(v1) + v1_copy = imath.V3f(v1) temp = v1 temp /= c - self.assert_( temp is v1 ) self.assertEqual( temp, v1_copy / c) # matrix multiplication - v1 = IECore.V3f( 1, 2, 3 ) - m = IECore.M44f.createTranslated( IECore.V3f( 1, 2, 3 ) ) + v1 = imath.V3f( 1, 2, 3 ) + m = imath.M44f().translate( imath.V3f( 1, 2, 3 ) ) v2 = v1 * m v1 *= m self.assertEqual( v1, v2 ) - self.assertEqual( v1, IECore.V3f( 2, 4, 6 ) ) + self.assertEqual( v1, imath.V3f( 2, 4, 6 ) ) def testMiscMethods(self): """Test V3f miscellaneous methods""" - v1 = IECore.V3f(41.4, 2.3, -4.98) + v1 = imath.V3f(41.4, 2.3, -4.98) self.assertAlmostEqual( v1.length2(), v1.dot(v1), 3 ) self.assertAlmostEqual( v1.length(), math.sqrt(v1.dot(v1)), 3 ) self.assertAlmostEqual( v1.length() * v1.length(), v1.length2(), 3 ) - v1 = IECore.V3f(10.0, 0.0, 0.0) + v1 = imath.V3f(10.0, 0.0, 0.0) self.assertEqual( v1.normalized(), v1 / v1.length() ) - self.assertEqual( v1, IECore.V3f(10.0, 0.0, 0.0) ) + self.assertEqual( v1, imath.V3f(10.0, 0.0, 0.0) ) v1.normalize() - self.assertEqual( v1, IECore.V3f(1.0, 0.0, 0.0) ) + self.assertEqual( v1, imath.V3f(1.0, 0.0, 0.0) ) def testRepr( self ) : - v1 = IECore.V3f( 0.091242323423 ) - v2 = eval( repr( v1 ) ) + v1 = imath.V3f( 0.091242323423 ) + v2 = eval( "imath." + repr( v1 ) ) self.assertEqual( v1, v2 ) class ImathBox3f(unittest.TestCase): def testConstructors(self): """Test Box3f constructors""" - b = IECore.Box3f() + b = imath.Box3f() self.assert_( b.isEmpty() ) - b = IECore.Box3f( IECore.V3f(1.0, 1.0, 1.0) ) - self.assertEqual( b.min, IECore.V3f(1.0, 1.0, 1.0) ) - self.assertEqual( b.max, IECore.V3f(1.0, 1.0, 1.0) ) + b = imath.Box3f( imath.V3f(1.0, 1.0, 1.0) ) + self.assertEqual( b.min(), imath.V3f(1.0, 1.0, 1.0) ) + self.assertEqual( b.max(), imath.V3f(1.0, 1.0, 1.0) ) - b = IECore.Box3f( IECore.V3f(-1.0, -1.0, -1.0), IECore.V3f(1.0, 1.0, 1.0) ) - self.assertEqual( b.min, IECore.V3f(-1.0, -1.0, -1.0) ) - self.assertEqual( b.max, IECore.V3f( 1.0, 1.0, 1.0) ) + b = imath.Box3f( imath.V3f(-1.0, -1.0, -1.0), imath.V3f(1.0, 1.0, 1.0) ) + self.assertEqual( b.min(), imath.V3f(-1.0, -1.0, -1.0) ) + self.assertEqual( b.max(), imath.V3f( 1.0, 1.0, 1.0) ) def testEquality(self): """Test Box3f comparison for equality""" - b1 = IECore.Box3f( IECore.V3f(1.0, 2.0, 3.0) ) - b2 = IECore.Box3f( IECore.V3f(1.0, 2.0, 3.0) ) + b1 = imath.Box3f( imath.V3f(1.0, 2.0, 3.0) ) + b2 = imath.Box3f( imath.V3f(1.0, 2.0, 3.0) ) self.assert_( b1 == b2 ) - b2 = IECore.Box3f( IECore.V3f(3.0, 2.0, 1.0) ) + b2 = imath.Box3f( imath.V3f(3.0, 2.0, 1.0) ) self.assert_( b1 != b2 ) def testMiscMethods(self): """Test Box3f miscellaneous methods""" - b1 = IECore.Box3f( IECore.V3f(-1.0, -1.0, -1.0), IECore.V3f(2.0, 2.0, 2.0) ) + b1 = imath.Box3f( imath.V3f(-1.0, -1.0, -1.0), imath.V3f(2.0, 2.0, 2.0) ) self.assertEqual( b1.isEmpty(), False ) self.assert_( b1.hasVolume() ) @@ -536,116 +525,67 @@ def testMiscMethods(self): self.assert_( b1.isEmpty() ) self.assertEqual( b1.hasVolume(), False ) - b1 = IECore.Box3f( IECore.V3f(-1.0, -1.0, -1.0), IECore.V3f(10.0, 2.0, 2.0) ) + b1 = imath.Box3f( imath.V3f(-1.0, -1.0, -1.0), imath.V3f(10.0, 2.0, 2.0) ) X_AXIS = 0 self.assertEqual( b1.majorAxis(), X_AXIS ) - self.assertEqual( b1.center(), (b1.min + b1.max) / 2.0 ) + self.assertEqual( b1.center(), (b1.min() + b1.max()) / 2.0 ) - b2 = IECore.Box3f( IECore.V3f(-0.5), IECore.V3f(1.0) ) + b2 = imath.Box3f( imath.V3f(-0.5), imath.V3f(1.0) ) self.assert_( b2.intersects(b1) ) - b2 = IECore.Box3f( IECore.V3f(-5.0), IECore.V3f(-2.0) ) + b2 = imath.Box3f( imath.V3f(-5.0), imath.V3f(-2.0) ) self.failIf( b2.intersects(b1) ) - self.assertEqual( b2.size(), b2.max - b2.min ) + self.assertEqual( b2.size(), b2.max() - b2.min() ) - b = IECore.Box3f( IECore.V3f(1), IECore.V3f(2) ) - m = IECore.M44f() - m[0,0]=2 - m[1,1]=2 - m[2,2]=2 - self.assertEqual( b.transform( m ), IECore.Box3f( IECore.V3f(2), IECore.V3f(4) ) ) - m = IECore.M44d() - m[0,0]=2 - m[1,1]=2 - m[2,2]=2 - self.assertEqual( b.transform( m ), IECore.Box3f( IECore.V3f(2), IECore.V3f(4) ) ) - - def testContains( self ) : - - b1 = IECore.Box3f( IECore.V3f( -1 ), IECore.V3f( 1 ) ) - b2 = IECore.Box3f( IECore.V3f( 0, -0.5, 0.5 ), IECore.V3f( 0.1, 0, 0.9 ) ) - b3 = IECore.Box3f( IECore.V3f( -1.2, -0.6, 0.4 ), IECore.V3f( 0.2, 0.1, 1 ) ) - - self.assert_( b1.contains( b2 ) ) - self.assert_( not b2.contains( b1 ) ) - - self.assert_( not b2.contains( b3 ) ) - self.assert_( b3.contains( b2 ) ) - - self.assert_( not b3.contains( b1 ) ) - self.assert_( not b1.contains( b3 ) ) - - def testSplit( self ) : - - r = IECore.Rand32() - for i in range( 0, 100 ) : - - b = IECore.Box3f() - b.extendBy( r.nextV3f() ) - b.extendBy( r.nextV3f() ) - - major = b.majorAxis() - - low, high = b.split() - low2, high2 = b.split( major ) - - self.assertEqual( low, low2 ) - self.assertEqual( high, high2 ) - - b2 = IECore.Box3f() - b2.extendBy( low ) - b2.extendBy( high ) - - self.assertEqual( b, b2 ) + b = imath.Box3f( imath.V3f(1), imath.V3f(2) ) + m = imath.M44f() + m[0][0]=2 + m[1][1]=2 + m[2][2]=2 + self.assertEqual( b * m, imath.Box3f( imath.V3f(2), imath.V3f(4) ) ) + m = imath.M44d() + m[0][0]=2 + m[1][1]=2 + m[2][2]=2 + self.assertEqual( b * m, imath.Box3f( imath.V3f(2), imath.V3f(4) ) ) class ImathQuatf(unittest.TestCase): def testConstructors(self): """Test Quatf constructors""" - q = IECore.Quatf() - q = IECore.Quatf(q) - q = IECore.Quatf(0.1, 0.2, 0.3, 0.4) - q = IECore.Quatf(0.1, IECore.V3f(0.2, 0.3, 0.4)) - q = IECore.Quatf.identity() - self.assertEqual( q, IECore.Quatf(1,0,0,0) ) - - def testIndexing(self): - """Test Quatf indexing via operator[]""" - - q = IECore.Quatf( 1, 2, 3, 4 ) - - self.assertEqual( q[0], 1 ) - self.assertEqual( q[1], 2 ) - self.assertEqual( q[2], 3 ) - self.assertEqual( q[3], 4 ) - - self.assertEqual( q[0], q.r ) - self.assertEqual( q[1], q.v.x ) - self.assertEqual( q[2], q.v.y ) - self.assertEqual( q[3], q.v.z ) + q = imath.Quatf() + q = imath.Quatf(q) + q = imath.Quatf(0.1, 0.2, 0.3, 0.4) + q = imath.Quatf(0.1, imath.V3f(0.2, 0.3, 0.4)) def testEquality(self): """Test Quatf comparison for equality""" - q1 = IECore.Quatf( 1, 2, 3, 4 ) - q2 = IECore.Quatf( 1, 2, 3, 4 ) + q1 = imath.Quatf( 1, 2, 3, 4 ) + q2 = imath.Quatf( 1, 2, 3, 4 ) self.assertEqual(q1, q1) self.assertEqual(q1, q2) - q2 = IECore.Quatf( 5, 2, 3, 4 ) + q2 = imath.Quatf( 5, 2, 3, 4 ) self.assert_( q1 != q2 ) def testMiscMethods(self): """Test Quatf miscellaneous methods""" - q1 = IECore.Quatf( 1, 2, 3, 4 ) - self.assertAlmostEqual( q1.length(), math.sqrt(q1[0]*q1[0]+(q1.v^q1.v)), 3 ) + q1 = imath.Quatf( 1, 2, 3, 4 ) + self.assertAlmostEqual( + q1.length(), + math.sqrt( + q1.r()*q1.r()+(q1.v()^q1.v()) + ), + 3 + ) # axis/angle - axis = IECore.V3f( 1, 2, 3 ) + axis = imath.V3f( 1, 2, 3 ) axis.normalize() q1.setAxisAngle( axis, 0.5 ) @@ -656,7 +596,7 @@ def testMiscMethods(self): self.assertAlmostEqual( q1.angle(), 0.5, 3 ) # Rotate x axis onto y axis - q1.setRotation( IECore.V3f(1,0,0), IECore.V3f(0,1,0) ) + q1.setRotation( imath.V3f(1,0,0), imath.V3f(0,1,0) ) #We should have gone 90 degrees about the +ve z-axis self.assertAlmostEqual( q1.angle(), 90.0 * math.pi / 180.0, 3 ) @@ -666,44 +606,44 @@ def testMiscMethods(self): self.assertAlmostEqual( q1.axis().z, 1.0, 3 ) #inversion - q1 = IECore.Quatf( 1, 2, 3, 4 ) + q1 = imath.Quatf( 1, 2, 3, 4 ) qdot = q1 ^ q1 - qi_test = IECore.Quatf( q1.r / qdot, -q1.v / qdot) + qi_test = imath.Quatf( q1.r() / qdot, -q1.v() / qdot) qi = q1.inverse() - self.assertAlmostEqual(qi[0], qi_test[0], 3) - self.assertAlmostEqual(qi[1], qi_test[1], 3) - self.assertAlmostEqual(qi[2], qi_test[2], 3) - self.assertAlmostEqual(qi[3], qi_test[3], 3) + self.assertAlmostEqual(qi.r(), qi_test.r(), 3) + self.assertAlmostEqual(qi.v()[0], qi_test.v()[0], 3) + self.assertAlmostEqual(qi.v()[1], qi_test.v()[1], 3) + self.assertAlmostEqual(qi.v()[2], qi_test.v()[2], 3) q1.invert() - self.assertAlmostEqual(qi[0], qi_test[0], 3) - self.assertAlmostEqual(qi[1], qi_test[1], 3) - self.assertAlmostEqual(qi[2], qi_test[2], 3) - self.assertAlmostEqual(qi[3], qi_test[3], 3) + self.assertAlmostEqual(qi.r(), qi_test.r(), 3) + self.assertAlmostEqual(qi.v()[0], qi_test.v()[0], 3) + self.assertAlmostEqual(qi.v()[1], qi_test.v()[1], 3) + self.assertAlmostEqual(qi.v()[2], qi_test.v()[2], 3) #slerp - q2 = IECore.Quatf( 0.5, 0.6, 0.7, 0.8 ) - qs = IECore.slerp(q1, q2, 0.5) + q2 = imath.Quatf( 0.5, 0.6, 0.7, 0.8 ) + qs = q1.slerp(q2, 0.5) # normalization qn = qi.normalized() - qn_test = IECore.Quatf( qi.r / qi.length(), qi.v / qi.length() ) + qn_test = imath.Quatf( qi.r() / qi.length(), qi.v() / qi.length() ) - self.assertAlmostEqual(qn[0], qn_test[0], 3) - self.assertAlmostEqual(qn[1], qn_test[1], 3) - self.assertAlmostEqual(qn[2], qn_test[2], 3) - self.assertAlmostEqual(qn[3], qn_test[3], 3) + self.assertAlmostEqual(qn.r(), qn_test.r(), 3) + self.assertAlmostEqual(qn.v()[0], qn_test.v()[0], 3) + self.assertAlmostEqual(qn.v()[1], qn_test.v()[1], 3) + self.assertAlmostEqual(qn.v()[2], qn_test.v()[2], 3) qn = qi.normalize() - self.assertAlmostEqual(qn[0], qn_test[0], 3) - self.assertAlmostEqual(qn[1], qn_test[1], 3) - self.assertAlmostEqual(qn[2], qn_test[2], 3) - self.assertAlmostEqual(qn[3], qn_test[3], 3) + self.assertAlmostEqual(qn.r(), qn_test.r(), 3) + self.assertAlmostEqual(qn.v()[0], qn_test.v()[0], 3) + self.assertAlmostEqual(qn.v()[1], qn_test.v()[1], 3) + self.assertAlmostEqual(qn.v()[2], qn_test.v()[2], 3) #matrix conversion - fromDir = IECore.V3f(1,0,0) - toDir = IECore.V3f(0,1,0) + fromDir = imath.V3f(1,0,0) + toDir = imath.V3f(0,1,0) q1.setRotation( fromDir, toDir ) m = q1.toMatrix33() m = q1.toMatrix44() @@ -711,109 +651,97 @@ def testMiscMethods(self): def testOperators(self): """Test Quatf operators""" - q1 = IECore.Quatf( 1, 2, 3, 4 ) - q2 = IECore.Quatf( 5, 6, 7, 8 ) - self.assertAlmostEqual( q1 ^ q2, q1.r * q2.r + (q1.v ^ q2.v ), 3 ) + q1 = imath.Quatf( 1, 2, 3, 4 ) + q2 = imath.Quatf( 5, 6, 7, 8 ) + self.assertAlmostEqual( q1 ^ q2, q1.r() * q2.r() + (q1.v() ^ q2.v() ), 3 ) def testSlerpStability( self ) : - q1 = IECore.Quatd( 0.60477471085951961527, 0.19082800913200048676, -0.73048263950686898038, 0.25343112163777203882, ) - q2 = IECore.Quatd( 0.6047747108595192822, 0.190828009132000459, -0.73048263950686909141, 0.25343112163777264945, ) + q1 = imath.Quatd( 0.60477471085951961527, 0.19082800913200048676, -0.73048263950686898038, 0.25343112163777203882, ) + q2 = imath.Quatd( 0.6047747108595192822, 0.190828009132000459, -0.73048263950686909141, 0.25343112163777264945, ) - q3 = IECore.slerp( q1, q2, 0.5 ) + q3 = q1.slerp( q2, 0.5 ) - self.assert_( q1.v.equalWithAbsError( q3.v, 0.000000000000001 ) ) - self.assertAlmostEqual( q1.r, q3.r, 14 ) + self.assert_( q1.v().equalWithAbsError( q3.v(), 0.000000000000001 ) ) + self.assertAlmostEqual( q1.r(), q3.r(), 14 ) class ImathM33f(unittest.TestCase): def testConstructors(self): """Test M33f constructors""" - m = IECore.M33f() + m = imath.M33f() - m = IECore.M33f(2) + m = imath.M33f(2) - m = IECore.M33f(1, 0, 0, + m = imath.M33f(1, 0, 0, 0, 1, 0, 0, 0, 1); - m = IECore.M33f( [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ] ) - - self.assertRaises( RuntimeError, IECore.M33f, [ 1 ] ) - self.assertRaises( RuntimeError, IECore.M33f, [ 1, 2 ] ) - self.assertRaises( RuntimeError, IECore.M33f, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ] ) - - def testDimensions(self): - """Test M33f dimensions""" - - m1 = IECore.M33f() - d = m1.dimensions() - self.assertEqual( d[0], 3 ) - self.assertEqual( d[1], 3 ) + m = imath.M33f( 1, 0, 0, 0, 1, 0, 0, 0, 1 ) def testCopyAndAssign(self): """Test M33f copy construction and assignment""" - m1 = IECore.M33f() - m2 = IECore.M33f(m1) + m1 = imath.M33f() + m2 = imath.M33f(m1) self.failIf(m1 is m2) def testIndexing(self): """Test M33f indexing via [] operator""" - m = IECore.M33f() - - # test tuple indexing: - m[(0,0)] = 10.0 - m[(0,1)] = 11.0 - m[(0,2)] = 12.0 - m[(1,0)] = 13.0 - m[(1,1)] = 14.0 - m[(1,2)] = 15.0 - m[(2,0)] = 16.0 - m[(2,1)] = 17.0 - m[(2,2)] = 18.0 - - # test __getitem__( tuple ): - self.assertEqual( m[(0,0)], 10.0 ) - self.assertEqual( m[(0,1)], 11.0 ) - self.assertEqual( m[(0,2)], 12.0 ) - self.assertEqual( m[(1,0)], 13.0 ) - self.assertEqual( m[(1,1)], 14.0 ) - self.assertEqual( m[(1,2)], 15.0 ) - self.assertEqual( m[(2,0)], 16.0 ) - self.assertEqual( m[(2,1)], 17.0 ) - self.assertEqual( m[(2,2)], 18.0 ) - - self.assertEqual( m, IECore.M33f( 10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0 ) ) + m = imath.M33f() + + # test __setitem__ + m[0][0] = 10.0 + m[0][1] = 11.0 + m[0][2] = 12.0 + m[1][0] = 13.0 + m[1][1] = 14.0 + m[1][2] = 15.0 + m[2][0] = 16.0 + m[2][1] = 17.0 + m[2][2] = 18.0 + + # test __getitem__ + self.assertEqual( m[0][0], 10.0 ) + self.assertEqual( m[0][1], 11.0 ) + self.assertEqual( m[0][2], 12.0 ) + self.assertEqual( m[1][0], 13.0 ) + self.assertEqual( m[1][1], 14.0 ) + self.assertEqual( m[1][2], 15.0 ) + self.assertEqual( m[2][0], 16.0 ) + self.assertEqual( m[2][1], 17.0 ) + self.assertEqual( m[2][2], 18.0 ) + + self.assertEqual( m, imath.M33f( 10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0 ) ) def testOperators(self): """Test M33f operators""" x = 10 y = 2 - m1 = IECore.M33f(x) - m2 = IECore.M33f(y) + m1 = imath.M33f(x) + m2 = imath.M33f(y) - self.assertEqual(m1 + m2, IECore.M33f(x + y)) - self.assertEqual(m1 - m2, IECore.M33f(x - y)) - self.assertEqual(m1 * y, IECore.M33f(x * y)) - self.assertEqual(m1 / y, IECore.M33f(x / y)) + self.assertEqual(m1 + m2, imath.M33f(x + y)) + self.assertEqual(m1 - m2, imath.M33f(x - y)) + self.assertEqual(m1 * y, imath.M33f(x * y)) + self.assertEqual(m1 / y, imath.M33f(x / y)) def testMiscellaneousMethods(self): """Test M33f miscellaneous methods""" - m1 = IECore.M33f() + m1 = imath.M33f() m1.makeIdentity() - m1 = IECore.M33f(3) - m2 = IECore.M33f(3.1) + m1 = imath.M33f(3) + m2 = imath.M33f(3.1) self.assert_( m1.equalWithAbsError(m2, 0.1) ) - m1 = IECore.M33f(2) - m2 = IECore.M33f(3) + m1 = imath.M33f(2) + m2 = imath.M33f(3) self.assert_( m1.equalWithRelError(m2, 0.51) ) - m1 = IECore.M33f(1, 0, 0, + m1 = imath.M33f(1, 0, 0, 0, 2, 0, 0, 0, 3) self.assertEqual( m1.transposed().transposed(), m1) @@ -822,185 +750,135 @@ def testMiscellaneousMethods(self): def testEquality(self): """Test M33f comparison for equality""" - m1 = IECore.M33f(3) - m2 = IECore.M33f(3) + m1 = imath.M33f(3) + m2 = imath.M33f(3) self.assertEqual(m1, m2) - def testCreate(self ) : - - self.assertEqual( IECore.M33f(), IECore.M33f.createScaled( IECore.V2f( 1 ) ) ) - - m = IECore.M33f() - m.scale( IECore.V2f( 2, 3 ) ) - self.assertEqual( m, IECore.M33f.createScaled( IECore.V2f( 2, 3 ) ) ) - - self.assertEqual( IECore.M33f(), IECore.M33f.createTranslated( IECore.V2f( 0 ) ) ) - - m = IECore.M33f() - m.translate( IECore.V2f( 2, 3 ) ) - self.assertEqual( m, IECore.M33f.createTranslated( IECore.V2f( 2, 3 ) ) ) - - self.assertEqual( IECore.M33f(), IECore.M33f.createRotated( 0 ) ) - - m = IECore.M33f() - m.rotate( 2 ) - self.assertEqual( m, IECore.M33f.createRotated( 2 ) ) - def testMultMethods( self ) : - v = IECore.M33f.createTranslated( IECore.V2f( 1, 2 ) ).multVecMatrix( IECore.V2f( 0 ) ) - self.assertEqual( v, IECore.V2f( 1, 2 ) ) + v = imath.M33f().translate( imath.V2f( 1, 2 ) ).multVecMatrix( imath.V2f( 0 ) ) + self.assertEqual( v, imath.V2f( 1, 2 ) ) - v = IECore.M33f.createTranslated( IECore.V2f( 1, 2 ) ).multDirMatrix( IECore.V2f( 1 ) ) - self.assertEqual( v, IECore.V2f( 1 ) ) + v = imath.M33f().translate( imath.V2f( 1, 2 ) ).multDirMatrix( imath.V2f( 1 ) ) + self.assertEqual( v, imath.V2f( 1 ) ) def testDeterminant( self ) : - m = IECore.M33f() + m = imath.M33f() self.assertAlmostEqual( m.determinant(), 1, 10 ) - m.scale( IECore.V2f( -1, 1 ) ) + m.scale( imath.V2f( -1, 1 ) ) self.assertAlmostEqual( m.determinant(), -1, 10 ) - m.scale( IECore.V2f( 1, -1 ) ) + m.scale( imath.V2f( 1, -1 ) ) self.assertAlmostEqual( m.determinant(), 1, 10 ) - m.scale( IECore.V2f( 3, -1 ) ) + m.scale( imath.V2f( 3, -1 ) ) self.assertAlmostEqual( m.determinant(), -3, 10 ) - m.scale( IECore.V2f( 3, 3 ) ) + m.scale( imath.V2f( 3, 3 ) ) self.assertAlmostEqual( m.determinant(), -27, 10 ) - r = IECore.curry( random.uniform, -10, 10 ) - for i in range( 0, 1000 ) : - - m = IECore.M33f( r(), r(), r(), r(), r(), r(), r(), r(), r() ) - d = m.determinant() - - if math.fabs( d ) > 0.00001 : - - mi = m.inverse() - di = mi.determinant() - - self.assertAlmostEqual( d, 1/di, 1 ) - - mt = m.transposed() - self.assertAlmostEqual( d, mt.determinant(), 3 ) - def testConstructFromOtherType( self ) : - md = IECore.M33d( 1, 2, 3, 4, 5, 6, 7, 8, 9 ) - mf = IECore.M33f( 1, 2, 3, 4, 5, 6, 7, 8, 9 ) + md = imath.M33d( 1, 2, 3, 4, 5, 6, 7, 8, 9 ) + mf = imath.M33f( 1, 2, 3, 4, 5, 6, 7, 8, 9 ) - mf2 = IECore.M33f( md ) + mf2 = imath.M33f( md ) self.assertEqual( mf2, mf ) - md2 = IECore.M33d( mf ) + md2 = imath.M33d( mf ) self.assertEqual( md2, md ) class ImathM44f(unittest.TestCase): def testConstructors(self): """Test M44f constructors""" - m = IECore.M44f(1., 0., 0., 0., + m = imath.M44f(1., 0., 0., 0., 0., 1., 0., 0., 0., 0., 1., 0., 0., 0., 0., 1.); - m3 = IECore.M33f(1., 0., 0., + m3 = imath.M33f(1., 0., 0., 0., 1., 0., 0., 0., 1.) - t = IECore.V3f(5., 5., 5.) - - m = IECore.M44f(m3, t) - - m = IECore.M44f( [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ] ) + t = imath.V3f(5., 5., 5.) - self.assertRaises( RuntimeError, IECore.M44f, [ 1 ] ) - self.assertRaises( RuntimeError, IECore.M44f, [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] ) - self.assertRaises( RuntimeError, IECore.M44f, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ] ) - - def testDimensions(self): - """Test M44f dimensions""" - - m1 = IECore.M44f() - d = m1.dimensions() - self.assertEqual( d[0], 4 ) - self.assertEqual( d[1], 4 ) + m = imath.M44f( 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ) def testCopyAndAssign(self): """Test M44f copy construction and assignment""" - m1 = IECore.M44f() - m2 = IECore.M44f(m1) + m1 = imath.M44f() + m2 = imath.M44f(m1) self.failIf(m1 is m2) m1 = m2 def testIndexing(self): """Test M44f indexing via [] operator""" - m = IECore.M44f() + m = imath.M44f() # test tuple indexing: - m[(0,0)] = 10.0 - m[(0,1)] = 11.0 - m[(0,2)] = 12.0 - m[(0,3)] = 13.0 - m[(1,0)] = 14.0 - m[(1,1)] = 15.0 - m[(1,2)] = 16.0 - m[(1,3)] = 17.0 - m[(2,0)] = 18.0 - m[(2,1)] = 19.0 - m[(2,2)] = 20.0 - m[(2,3)] = 21.0 - m[(3,0)] = 22.0 - m[(3,1)] = 23.0 - m[(3,2)] = 24.0 - m[(3,3)] = 25.0 + m[0][0] = 10.0 + m[0][1] = 11.0 + m[0][2] = 12.0 + m[0][3] = 13.0 + m[1][0] = 14.0 + m[1][1] = 15.0 + m[1][2] = 16.0 + m[1][3] = 17.0 + m[2][0] = 18.0 + m[2][1] = 19.0 + m[2][2] = 20.0 + m[2][3] = 21.0 + m[3][0] = 22.0 + m[3][1] = 23.0 + m[3][2] = 24.0 + m[3][3] = 25.0 # test __getitem__( tuple ): - self.assertEqual( m[(0,0)], 10.0 ) - self.assertEqual( m[(0,1)], 11.0 ) - self.assertEqual( m[(0,2)], 12.0 ) - self.assertEqual( m[(0,3)], 13.0 ) - self.assertEqual( m[(1,0)], 14.0 ) - self.assertEqual( m[(1,1)], 15.0 ) - self.assertEqual( m[(1,2)], 16.0 ) - self.assertEqual( m[(1,3)], 17.0 ) - self.assertEqual( m[(2,0)], 18.0 ) - self.assertEqual( m[(2,1)], 19.0 ) - self.assertEqual( m[(2,2)], 20.0 ) - self.assertEqual( m[(2,3)], 21.0 ) - self.assertEqual( m[(3,0)], 22.0 ) - self.assertEqual( m[(3,1)], 23.0 ) - self.assertEqual( m[(3,2)], 24.0 ) - self.assertEqual( m[(3,3)], 25.0 ) - - self.assertEqual( m, IECore.M44f( 10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0 ) ) + self.assertEqual( m[0][0], 10.0 ) + self.assertEqual( m[0][1], 11.0 ) + self.assertEqual( m[0][2], 12.0 ) + self.assertEqual( m[0][3], 13.0 ) + self.assertEqual( m[1][0], 14.0 ) + self.assertEqual( m[1][1], 15.0 ) + self.assertEqual( m[1][2], 16.0 ) + self.assertEqual( m[1][3], 17.0 ) + self.assertEqual( m[2][0], 18.0 ) + self.assertEqual( m[2][1], 19.0 ) + self.assertEqual( m[2][2], 20.0 ) + self.assertEqual( m[2][3], 21.0 ) + self.assertEqual( m[3][0], 22.0 ) + self.assertEqual( m[3][1], 23.0 ) + self.assertEqual( m[3][2], 24.0 ) + self.assertEqual( m[3][3], 25.0 ) + + self.assertEqual( m, imath.M44f( 10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0 ) ) def testOperators(self): """Test M44f operators""" x = 10 y = 2 - m1 = IECore.M44f(x) - m2 = IECore.M44f(y) + m1 = imath.M44f(x) + m2 = imath.M44f(y) - self.assertEqual(m1 + m2, IECore.M44f(x + y)) - self.assertEqual(m1 - m2, IECore.M44f(x - y)) - self.assertEqual(m1 * y, IECore.M44f(x * y)) - self.assertEqual(m1 / y, IECore.M44f(x / y)) + self.assertEqual(m1 + m2, imath.M44f(x + y)) + self.assertEqual(m1 - m2, imath.M44f(x - y)) + self.assertEqual(m1 * y, imath.M44f(x * y)) + self.assertEqual(m1 / y, imath.M44f(x / y)) def testMiscellaneousMethods(self): """Test M44f miscellaneous methods""" - m1 = IECore.M44f() + m1 = imath.M44f() m1.makeIdentity() - m1 = IECore.M44f(3) - m2 = IECore.M44f(3.1) + m1 = imath.M44f(3) + m2 = imath.M44f(3.1) self.assert_( m1.equalWithAbsError(m2, 0.1) ) - m1 = IECore.M44f(2) - m2 = IECore.M44f(3) + m1 = imath.M44f(2) + m2 = imath.M44f(3) self.assert_( m1.equalWithRelError(m2, 0.51) ) - m1 = IECore.M44f(1, 0, 0, 0, + m1 = imath.M44f(1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 4) @@ -1009,73 +887,30 @@ def testMiscellaneousMethods(self): def testEquality(self): """Test M44f comparison for equality""" - m1 = IECore.M44f(3) - m2 = IECore.M44f(3) + m1 = imath.M44f(3) + m2 = imath.M44f(3) self.assertEqual(m1, m2) - def testCreate(self ) : - - self.assertEqual( IECore.M44f(), IECore.M44f.createScaled( IECore.V3f( 1 ) ) ) - - m = IECore.M44f() - m.scale( IECore.V3f( 2, 3, 4 ) ) - self.assertEqual( m, IECore.M44f.createScaled( IECore.V3f( 2, 3, 4 ) ) ) - - self.assertEqual( IECore.M44f(), IECore.M44f.createTranslated( IECore.V3f( 0 ) ) ) - - m = IECore.M44f() - m.translate( IECore.V3f( 2, 3, 4 ) ) - self.assertEqual( m, IECore.M44f.createTranslated( IECore.V3f( 2, 3, 4 ) ) ) - - self.assertEqual( IECore.M44f(), IECore.M44f.createRotated( IECore.V3f( 0 ) ) ) - - m = IECore.M44f() - m.rotate( IECore.V3f( 1, 2, 3 ) ) - self.assertEqual( m, IECore.M44f.createRotated( IECore.V3f( 1, 2, 3 ) ) ) - - m = IECore.M44f.createAimed( IECore.V3f( 1, 0, 0 ), IECore.V3f( 0, 1, 0 ) ) - self.assert_( IECore.V3f( 0, 1, 0 ).equalWithAbsError( IECore.V3f( 1, 0, 0 ) * m, 0.0000001 ) ) - - m = IECore.M44f.createAimed( IECore.V3f( 1, 0, 0 ), IECore.V3f( 0, 0, 1 ), IECore.V3f( 0, 1, 0 ) ) - self.assert_( IECore.V3f( 0, 0, 1 ).equalWithAbsError( IECore.V3f( 1, 0, 0 ) * m, 0.0000001 ) ) - self.assert_( IECore.V3f( 0, 1, 0 ).equalWithAbsError( IECore.V3f( 0, 1, 0 ) * m, 0.0000001 ) ) - def testMultMethods( self ) : - v = IECore.M44f.createTranslated( IECore.V3f( 1, 2, 3 ) ).multVecMatrix( IECore.V3f( 0 ) ) - self.assertEqual( v, IECore.V3f( 1, 2, 3 ) ) - - v = IECore.M44f.createTranslated( IECore.V3f( 1, 2, 3 ) ).multDirMatrix( IECore.V3f( 1 ) ) - self.assertEqual( v, IECore.V3f( 1 ) ) - - def testFromBasis( self ) : - - for i in range( 0, 10000 ) : + v = imath.M44f().translate( imath.V3f( 1, 2, 3 ) ).multVecMatrix( imath.V3f( 0 ) ) + self.assertEqual( v, imath.V3f( 1, 2, 3 ) ) - m = IECore.M44f() - m.translate( IECore.V3f( random.uniform( -1000, 1000 ), random.uniform( -1000, 1000 ), random.uniform( -1000, 1000 ) ) ) - m.rotate( IECore.V3f( random.uniform( -1000, 1000 ), random.uniform( -1000, 1000 ), random.uniform( -1000, 1000 ) ) ) - m.scale( IECore.V3f( random.uniform( -100, 100 ), random.uniform( -100, 100 ), random.uniform( -100, 100 ) ) ) - - x = m.multDirMatrix( IECore.V3f( 1, 0, 0 ) ) - y = m.multDirMatrix( IECore.V3f( 0, 1, 0 ) ) - z = m.multDirMatrix( IECore.V3f( 0, 0, 1 ) ) - o = IECore.V3f( 0, 0, 0 ) * m - - self.assertEqual( IECore.M44f.createFromBasis( x, y, z, o ), m ) + v = imath.M44f().translate( imath.V3f( 1, 2, 3 ) ).multDirMatrix( imath.V3f( 1 ) ) + self.assertEqual( v, imath.V3f( 1 ) ) def testDeterminant( self ) : - m = IECore.M44f() + m = imath.M44f() self.assertAlmostEqual( m.determinant(), 1, 10 ) - m.scale( IECore.V3f( -1, 1, 1 ) ) + m.scale( imath.V3f( -1, 1, 1 ) ) self.assertAlmostEqual( m.determinant(), -1, 10 ) - m.scale( IECore.V3f( 1, -1, 1 ) ) + m.scale( imath.V3f( 1, -1, 1 ) ) self.assertAlmostEqual( m.determinant(), 1, 10 ) - m.scale( IECore.V3f( 3, -1, 1 ) ) + m.scale( imath.V3f( 3, -1, 1 ) ) self.assertAlmostEqual( m.determinant(), -3, 10 ) - m.scale( IECore.V3f( 3, 3, 1 ) ) + m.scale( imath.V3f( 3, 3, 1 ) ) self.assertAlmostEqual( m.determinant(), -27, 10 ) random.seed( 42 ) @@ -1083,7 +918,7 @@ def testDeterminant( self ) : r = IECore.curry( random.uniform, -2, 2 ) for i in range( 0, 1000 ) : - m = IECore.M44f( r(), r(), r(), r(), r(), r(), r(), r(), r(), r(), r(), r(), r(), r(), r(), r() ) + m = imath.M44f( r(), r(), r(), r(), r(), r(), r(), r(), r(), r(), r(), r(), r(), r(), r(), r() ) d = m.determinant() if math.fabs( d ) > 0.00001 : @@ -1091,51 +926,51 @@ def testDeterminant( self ) : mi = m.inverse() di = mi.determinant() - self.assertAlmostEqual( d, 1/di, 4 ) + self.assertAlmostEqual( d, 1/di, 3 ) mt = m.transposed() self.assertAlmostEqual( d, mt.determinant(), 4 ) for i in range( 0, 1000 ) : - m = IECore.M44f() - m.translate( IECore.V3f( r(), r(), r() ) ) + m = imath.M44f() + m.translate( imath.V3f( r(), r(), r() ) ) self.assertAlmostEqual( m.determinant(), 1, 10 ) def testConstructFromOtherType( self ) : - md = IECore.M44d( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ) - mf = IECore.M44f( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ) + md = imath.M44d( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ) + mf = imath.M44f( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ) - mf2 = IECore.M44f( md ) + mf2 = imath.M44f( md ) self.assertEqual( mf2, mf ) - md2 = IECore.M44d( mf ) + md2 = imath.M44d( mf ) self.assertEqual( md2, md ) class ImathColor3Test( unittest.TestCase ) : def test( self ) : - c = IECore.Color3f( 1 ) + c = imath.Color3f( 1 ) self.assertEqual( c.r, 1 ) self.assertEqual( c.g, 1 ) self.assertEqual( c.b, 1 ) - c = IECore.Color3f( 1, 2, 3 ) + c = imath.Color3f( 1, 2, 3 ) self.assertEqual( c.r, 1 ) self.assertEqual( c.g, 2 ) self.assertEqual( c.b, 3 ) - cc = IECore.Color3f( c ) + cc = imath.Color3f( c ) self.assertEqual( c, cc ) - c = IECore.Color3f( IECore.V3f(1,2,3) ) + c = imath.Color3f( imath.V3f(1,2,3) ) self.assertEqual( c.r, 1 ) self.assertEqual( c.g, 2 ) self.assertEqual( c.b, 3 ) - c = IECore.Color3f( IECore.V3d(1,2,3) ) + c = imath.Color3f( imath.V3d(1,2,3) ) self.assertEqual( c.r, 1 ) self.assertEqual( c.g, 2 ) self.assertEqual( c.b, 3 ) @@ -1150,28 +985,28 @@ def test( self ) : self.assertEqual( cm.g, -8 ) self.assertEqual( cm.b, -18 ) - cm -= IECore.Color3f( 2 ) - self.assertEqual( cm, IECore.Color3f( -4, -10, -20 ) ) + cm -= imath.Color3f( 2 ) + self.assertEqual( cm, imath.Color3f( -4, -10, -20 ) ) self.assertEqual( c.dimensions(), 3 ) def testHSVTransforms( self ) : - c = IECore.Color3f( 0.1, 0.2, 0.3 ) + c = imath.Color3f( 0.1, 0.2, 0.3 ) - chsv = c.rgbToHSV() - self.assertEqual( c, IECore.Color3f( 0.1, 0.2, 0.3 ) ) - self.failUnless( isinstance( chsv, IECore.Color3f ) ) - self.failUnless( chsv.equalWithAbsError( IECore.Color3f( 0.5833, 0.6667, 0.3 ), 0.001 ) ) + chsv = c.rgb2hsv() + self.assertEqual( c, imath.Color3f( 0.1, 0.2, 0.3 ) ) + self.failUnless( isinstance( chsv, imath.Color3f ) ) + self.failUnless( chsv.equalWithAbsError( imath.Color3f( 0.5833, 0.6667, 0.3 ), 0.001 ) ) - crgb = chsv.hsvToRGB() - self.failUnless( chsv.equalWithAbsError( IECore.Color3f( 0.5833, 0.6667, 0.3 ), 0.001 ) ) + crgb = chsv.hsv2rgb() + self.failUnless( chsv.equalWithAbsError( imath.Color3f( 0.5833, 0.6667, 0.3 ), 0.001 ) ) self.failUnless( crgb.equalWithAbsError( c, 0.001 ) ) def testRepr( self ) : - c1 = IECore.Color3f( 0.091242323423 ) - c2 = eval( repr( c1 ) ) + c1 = imath.Color3f( 0.091242323423 ) + c2 = eval( "imath." + repr( c1 ) ) self.assertEqual( c1, c2 ) class ImathEulerfTest( unittest.TestCase ) : @@ -1180,98 +1015,86 @@ def testConstructors(self): """Test Eulerf constructors""" # - e = IECore.Eulerf() + e = imath.Eulerf() self.assertEqual( e.x, 0 ) self.assertEqual( e.y, 0 ) self.assertEqual( e.z, 0 ) - self.assertEqual( e.order(), IECore.Eulerf.Order.Default ) - self.assertEqual( e.order(), IECore.Eulerf.Order.XYZ ) + self.assertEqual( e.order(), imath.Eulerf.Order.XYZ ) # - ecopy = IECore.Eulerf(e) + ecopy = imath.Eulerf(e) self.assertEqual( ecopy.x, 0 ) self.assertEqual( ecopy.y, 0 ) self.assertEqual( ecopy.z, 0 ) - self.assertEqual( ecopy.order(), IECore.Eulerf.Order.Default ) - self.assertEqual( ecopy.order(), IECore.Eulerf.Order.XYZ ) + self.assertEqual( ecopy.order(), imath.Eulerf.Order.XYZ ) # - e = IECore.Eulerf( IECore.Eulerf.Order.ZYX ) - self.assertEqual( e.order(), IECore.Eulerf.Order.ZYX ) + e = imath.Eulerf( imath.Eulerf.Order.ZYX ) + self.assertEqual( e.order(), imath.Eulerf.Order.ZYX ) # - e = IECore.Eulerf( IECore.V3f( 0, 0, 0 ) ) - self.assertEqual( e.order(), IECore.Eulerf.Order.Default ) - self.assertEqual( e.order(), IECore.Eulerf.Order.XYZ ) + e = imath.Eulerf( imath.V3f( 0, 0, 0 ) ) + self.assertEqual( e.order(), imath.Eulerf.Order.XYZ ) - e = IECore.Eulerf( IECore.V3f( 0, 0, 0 ), IECore.Eulerf.Order.ZYX ) - self.assertEqual( e.order(), IECore.Eulerf.Order.ZYX ) + e = imath.Eulerf( imath.V3f( 0, 0, 0 ), imath.Eulerf.Order.ZYX ) + self.assertEqual( e.order(), imath.Eulerf.Order.ZYX ) # - e = IECore.Eulerf( 0, 0, 0 ) - e = IECore.Eulerf( IECore.V3f( 0, 0, 0 ) ) - self.assertEqual( e.order(), IECore.Eulerf.Order.Default ) - self.assertEqual( e.order(), IECore.Eulerf.Order.XYZ ) - - e = IECore.Eulerf( 0, 0, 0, IECore.Eulerf.Order.ZYX ) - self.assertEqual( e.order(), IECore.Eulerf.Order.ZYX ) + e = imath.Eulerf( 0, 0, 0 ) + e = imath.Eulerf( imath.V3f( 0, 0, 0 ) ) + self.assertEqual( e.order(), imath.Eulerf.Order.XYZ ) - e = IECore.Eulerf( 0, 0, 0, IECore.Eulerf.Order.ZYX, IECore.Eulerf.InputLayout.XYZLayout ) - self.assertEqual( e.order(), IECore.Eulerf.Order.ZYX ) + e = imath.Eulerf( 0, 0, 0, imath.Eulerf.Order.ZYX ) + self.assertEqual( e.order(), imath.Eulerf.Order.ZYX ) # - e = IECore.Eulerf( IECore.M33f() ) - e = IECore.Eulerf( IECore.V3f( 0, 0, 0 ) ) - self.assertEqual( e.order(), IECore.Eulerf.Order.Default ) - self.assertEqual( e.order(), IECore.Eulerf.Order.XYZ ) + e = imath.Eulerf( imath.M33f() ) + e = imath.Eulerf( imath.V3f( 0, 0, 0 ) ) + self.assertEqual( e.order(), imath.Eulerf.Order.XYZ ) - e = IECore.Eulerf( IECore.M33f(), IECore.Eulerf.Order.ZYX ) - self.assertEqual( e.order(), IECore.Eulerf.Order.ZYX ) + e = imath.Eulerf( imath.M33f(), imath.Eulerf.Order.ZYX ) + self.assertEqual( e.order(), imath.Eulerf.Order.ZYX ) # - e = IECore.Eulerf( IECore.M44f() ) - e = IECore.Eulerf( IECore.V3f( 0, 0, 0 ) ) - self.assertEqual( e.order(), IECore.Eulerf.Order.Default ) - self.assertEqual( e.order(), IECore.Eulerf.Order.XYZ ) + e = imath.Eulerf( imath.M44f() ) + e = imath.Eulerf( imath.V3f( 0, 0, 0 ) ) + self.assertEqual( e.order(), imath.Eulerf.Order.XYZ ) - e = IECore.Eulerf( IECore.M44f(), IECore.Eulerf.Order.ZYX ) - self.assertEqual( e.order(), IECore.Eulerf.Order.ZYX ) + e = imath.Eulerf( imath.M44f(), imath.Eulerf.Order.ZYX ) + self.assertEqual( e.order(), imath.Eulerf.Order.ZYX ) def testOrder(self): """Test Eulerf order""" - self.assertEqual( len( IECore.Eulerf.Order.values ), 24 ) + self.assertEqual( len( imath.Eulerf.Order.values ), 24 ) - e = IECore.Eulerf() - - for order in IECore.Eulerf.Order.values.values(): - self.assert_( IECore.Eulerf.legal( order ) ) + e = imath.Eulerf() + for order in imath.Eulerf.Order.values.values(): e.setOrder( order ) - self.assertEqual( e.order(), order ) def testMisc(self): """Test Eulerf miscellaneous""" - self.assertEqual( len(IECore.Eulerf.Axis.values), 3 ) - self.assertEqual( len(IECore.Eulerf.InputLayout.values), 2 ) + self.assertEqual( len(imath.Eulerf.Axis.values), 3 ) + self.assertEqual( len(imath.Eulerf.InputLayout.values), 2 ) - self.assert_( IECore.V3f in IECore.Eulerf.__bases__ ) + self.assert_( imath.V3f in imath.Eulerf.__bases__ ) def testExtract(self): """Test Eulerf extract""" - e = IECore.Eulerf() - e.extract( IECore.M33f() ) + e = imath.Eulerf() + e.extract( imath.M33f() ) - e.extract( IECore.M44f() ) + e.extract( imath.M44f() ) - e.extract( IECore.Quatf() ) + e.extract( imath.Quatf() ) m = e.toMatrix33() m = e.toMatrix44() @@ -1282,78 +1105,40 @@ def testAngleOrder(self): """Test Eulerf angleOrder""" - e = IECore.Eulerf() + e = imath.Eulerf() o = e.angleOrder() - self.assert_( type(o) is tuple ) + self.assertIsInstance( o, imath.V3i ) self.assertEqual( len(o), 3 ) - def testAngleMapping(self): - - """Test Eulerf angleMapping""" - - e = IECore.Eulerf() - - m = e.angleMapping() - - self.assert_( type(m) is tuple ) - self.assertEqual( len(m), 3 ) - - def testStr(self): """Test Eulerf str""" - e = IECore.Eulerf() - self.assertEqual( str(e), "0 0 0" ) + e = imath.Eulerf() + self.assertEqual( str(e), "Eulerf(0, 0, 0, EULER_XYZ)" ) def testRepr(self): """Test Eulerf repr""" - e = IECore.Eulerf() - self.assertEqual( repr(e), "IECore.Eulerf( 0, 0, 0 )" ) - - def testSimpleXYZRotation(self): - - e = IECore.Eulerf( math.pi * 6, math.pi * 10, -math.pi * 20 ) - ee = IECore.Eulerf( e ) - t = IECore.Eulerf( 0, 0, 0 ) - - es = IECore.Eulerf.simpleXYZRotation( e, t ) - - # check that the simple rotations are in an appropriate range - for r in es : - self.assert_( math.fabs( r ) <= math.pi ) - - # and that the original vector isn't modified in place - self.assertEqual( ee, e ) - - def testNearestRotation(self): - - e = IECore.Eulerf( math.pi * 6, math.pi * 10, -math.pi * 20 ) - ee = IECore.Eulerf( e ) - t = IECore.Eulerf( 0, 0, 0 ) - - en = IECore.Eulerf.nearestRotation( e, t ) - - # check that the original vector isn't modified in place - self.assertEqual( ee, e ) + e = imath.Eulerf() + self.assertEqual( repr(e), "Eulerf(0, 0, 0, EULER_XYZ)" ) class ImathPlane3fTest( unittest.TestCase ) : def testConstructors( self ) : - p = IECore.Plane3f( IECore.V3f( 0, 0, 0 ), IECore.V3f( 1, 0, 0 ) ) - self.assertEqual( p.normal, IECore.V3f( 1, 0, 0 ) ) - self.assertEqual( p.distance, 0 ) + p = imath.Plane3f( imath.V3f( 0, 0, 0 ), imath.V3f( 1, 0, 0 ) ) + self.assertEqual( p.normal(), imath.V3f( 1, 0, 0 ) ) + self.assertEqual( p.distance(), 0 ) - p = IECore.Plane3f( IECore.V3f( 0, 0, 0 ), IECore.V3f( 0, 1, 0 ), IECore.V3f( 0, 0, 1 ) ) - self.assertEqual( p.normal, IECore.V3f( 1, 0, 0 ) ) - self.assertEqual( p.distance, 0 ) + p = imath.Plane3f( imath.V3f( 0, 0, 0 ), imath.V3f( 0, 1, 0 ), imath.V3f( 0, 0, 1 ) ) + self.assertEqual( p.normal(), imath.V3f( 1, 0, 0 ) ) + self.assertEqual( p.distance(), 0 ) - p = IECore.Plane3f( IECore.V3f( 2, 2, 2 ), IECore.V3f( 2, 3, 2 ), IECore.V3f( 2, 2, 3 ) ) - self.assertEqual( p.normal, IECore.V3f( 1, 0, 0 ) ) - self.assertEqual( p.distance, 2 ) + p = imath.Plane3f( imath.V3f( 2, 2, 2 ), imath.V3f( 2, 3, 2 ), imath.V3f( 2, 2, 3 ) ) + self.assertEqual( p.normal(), imath.V3f( 1, 0, 0 ) ) + self.assertEqual( p.distance(), 2 ) if __name__ == "__main__": diff --git a/test/IECore/ImathVectorData.py b/test/IECore/ImathVectorData.py index caaf7701d6..1e1b345a74 100644 --- a/test/IECore/ImathVectorData.py +++ b/test/IECore/ImathVectorData.py @@ -36,6 +36,7 @@ import math import unittest +import imath import IECore from VectorData import BaseVectorDataTest @@ -43,7 +44,7 @@ class V2fVectorDataTest(BaseVectorDataTest, unittest.TestCase): def __init__(self, param1): - BaseVectorDataTest.__init__(self, IECore.V2fVectorData, IECore.V2f) + BaseVectorDataTest.__init__(self, IECore.V2fVectorData, imath.V2f) unittest.TestCase.__init__(self, param1) def testConstructors(self): @@ -109,7 +110,7 @@ def testByValueItem(self): class V2dVectorDataTest(BaseVectorDataTest, unittest.TestCase): def __init__(self, param1): - BaseVectorDataTest.__init__(self, IECore.V2dVectorData, IECore.V2d) + BaseVectorDataTest.__init__(self, IECore.V2dVectorData, imath.V2d) unittest.TestCase.__init__(self, param1) def testConstructors(self): @@ -175,7 +176,7 @@ def testByValueItem(self): class V2iVectorDataTest(BaseVectorDataTest, unittest.TestCase): def __init__(self, param1): - BaseVectorDataTest.__init__(self, IECore.V2iVectorData, IECore.V2i) + BaseVectorDataTest.__init__(self, IECore.V2iVectorData, imath.V2i) unittest.TestCase.__init__(self, param1) def testConstructors(self): @@ -241,7 +242,7 @@ def testByValueItem(self): class V3fVectorDataTest(BaseVectorDataTest, unittest.TestCase): def __init__(self, param1): - BaseVectorDataTest.__init__(self, IECore.V3fVectorData, IECore.V3f) + BaseVectorDataTest.__init__(self, IECore.V3fVectorData, imath.V3f) unittest.TestCase.__init__(self, param1) def testConstructors(self): @@ -306,31 +307,31 @@ def testByValueItem(self): def testOperatedInterpretation( self ) : - v = IECore.V3fVectorData( [ IECore.V3f(1), IECore.V3f(2), IECore.V3f(3) ], IECore.GeometricData.Interpretation.Vector ) + v = IECore.V3fVectorData( [ imath.V3f(1), imath.V3f(2), imath.V3f(3) ], IECore.GeometricData.Interpretation.Vector ) self.assertEqual( v.getInterpretation(), IECore.GeometricData.Interpretation.Vector ) # add and iadd - v2 = v + IECore.V3fVectorData( [ IECore.V3f(4), IECore.V3f(5), IECore.V3f(6) ] ) + v2 = v + IECore.V3fVectorData( [ imath.V3f(4), imath.V3f(5), imath.V3f(6) ] ) self.assertEqual( v2.getInterpretation(), IECore.GeometricData.Interpretation.Vector ) - v2 += IECore.V3fVectorData( [ IECore.V3f(7), IECore.V3f(8), IECore.V3f(9) ], IECore.GeometricData.Interpretation.Normal ) + v2 += IECore.V3fVectorData( [ imath.V3f(7), imath.V3f(8), imath.V3f(9) ], IECore.GeometricData.Interpretation.Normal ) self.assertEqual( v2.getInterpretation(), IECore.GeometricData.Interpretation.Vector ) # sub and isub - v3 = v - IECore.V3fVectorData( [ IECore.V3f(4), IECore.V3f(5), IECore.V3f(6) ], IECore.GeometricData.Interpretation.Normal ) + v3 = v - IECore.V3fVectorData( [ imath.V3f(4), imath.V3f(5), imath.V3f(6) ], IECore.GeometricData.Interpretation.Normal ) self.assertEqual( v3.getInterpretation(), IECore.GeometricData.Interpretation.Vector ) - v3 -= IECore.V3fVectorData( [ IECore.V3f(7), IECore.V3f(8), IECore.V3f(9) ] ) + v3 -= IECore.V3fVectorData( [ imath.V3f(7), imath.V3f(8), imath.V3f(9) ] ) self.assertEqual( v3.getInterpretation(), IECore.GeometricData.Interpretation.Vector ) # mul and imul - v4 = v * IECore.V3fVectorData( [ IECore.V3f(4), IECore.V3f(5), IECore.V3f(6) ] ) + v4 = v * IECore.V3fVectorData( [ imath.V3f(4), imath.V3f(5), imath.V3f(6) ] ) self.assertEqual( v4.getInterpretation(), IECore.GeometricData.Interpretation.Vector ) - v4 *= IECore.V3fVectorData( [ IECore.V3f(7), IECore.V3f(8), IECore.V3f(9) ], IECore.GeometricData.Interpretation.Point ) + v4 *= IECore.V3fVectorData( [ imath.V3f(7), imath.V3f(8), imath.V3f(9) ], IECore.GeometricData.Interpretation.Point ) self.assertEqual( v4.getInterpretation(), IECore.GeometricData.Interpretation.Vector ) # div and idiv - v5 = v / IECore.V3fVectorData( [ IECore.V3f(4), IECore.V3f(5), IECore.V3f(6) ] ) + v5 = v / IECore.V3fVectorData( [ imath.V3f(4), imath.V3f(5), imath.V3f(6) ] ) self.assertEqual( v5.getInterpretation(), IECore.GeometricData.Interpretation.Vector ) - v5 /= IECore.V3fVectorData( [ IECore.V3f(7), IECore.V3f(8), IECore.V3f(9) ], IECore.GeometricData.Interpretation.Color ) + v5 /= IECore.V3fVectorData( [ imath.V3f(7), imath.V3f(8), imath.V3f(9) ], IECore.GeometricData.Interpretation.Color ) self.assertEqual( v5.getInterpretation(), IECore.GeometricData.Interpretation.Vector ) # slices @@ -346,7 +347,7 @@ def testOperatedInterpretation( self ) : class V3dVectorDataTest(BaseVectorDataTest, unittest.TestCase): def __init__(self, param1): - BaseVectorDataTest.__init__(self, IECore.V3dVectorData, IECore.V3d) + BaseVectorDataTest.__init__(self, IECore.V3dVectorData, imath.V3d) unittest.TestCase.__init__(self, param1) def testConstructors(self): @@ -412,7 +413,7 @@ def testByValueItem(self): class V3iVectorDataTest(BaseVectorDataTest, unittest.TestCase): def __init__(self, param1): - BaseVectorDataTest.__init__(self, IECore.V3iVectorData, IECore.V3i) + BaseVectorDataTest.__init__(self, IECore.V3iVectorData, imath.V3i) unittest.TestCase.__init__(self, param1) def testConstructors(self): @@ -476,7 +477,7 @@ def testByValueItem(self): BaseVectorDataTest.testByValueItem(self) def createBox3f(value): - return IECore.Box3f(IECore.V3f(value)) + return imath.Box3f(imath.V3f(value)) class Box3fVectorDataTest(BaseVectorDataTest, unittest.TestCase): @@ -545,7 +546,7 @@ def testByValueItem(self): BaseVectorDataTest.testByValueItem(self) def createBox3d(value): - return IECore.Box3d(IECore.V3d(value)) + return imath.Box3d(imath.V3d(value)) class Box3dVectorDataTest(BaseVectorDataTest, unittest.TestCase): @@ -616,7 +617,7 @@ def testByValueItem(self): class M33fVectorDataTest(BaseVectorDataTest, unittest.TestCase): def __init__(self, param1): - BaseVectorDataTest.__init__(self, IECore.M33fVectorData, IECore.M33f) + BaseVectorDataTest.__init__(self, IECore.M33fVectorData, imath.M33f) unittest.TestCase.__init__(self, param1) def testConstructors(self): @@ -695,7 +696,7 @@ def testByValueItem(self): class M33dVectorDataTest(BaseVectorDataTest, unittest.TestCase): def __init__(self, param1): - BaseVectorDataTest.__init__(self, IECore.M33dVectorData, IECore.M33d) + BaseVectorDataTest.__init__(self, IECore.M33dVectorData, imath.M33d) unittest.TestCase.__init__(self, param1) def testConstructors(self): @@ -774,7 +775,7 @@ def testByValueItem(self): class M44fVectorDataTest(BaseVectorDataTest, unittest.TestCase): def __init__(self, param1): - BaseVectorDataTest.__init__(self, IECore.M44fVectorData, IECore.M44f) + BaseVectorDataTest.__init__(self, IECore.M44fVectorData, imath.M44f) unittest.TestCase.__init__(self, param1) def testConstructors(self): @@ -853,7 +854,7 @@ def testByValueItem(self): class M44dVectorDataTest(BaseVectorDataTest, unittest.TestCase): def __init__(self, param1): - BaseVectorDataTest.__init__(self, IECore.M44dVectorData, IECore.M44d) + BaseVectorDataTest.__init__(self, IECore.M44dVectorData, imath.M44d) unittest.TestCase.__init__(self, param1) def testConstructors(self): @@ -930,7 +931,7 @@ def testByValueItem(self): BaseVectorDataTest.testByValueItem(self) def createQuatf(value): - return IECore.Quatf(value, 0, 0, 0) + return imath.Quatf(value, 0, 0, 0) class QuatfVectorDataTest(BaseVectorDataTest, unittest.TestCase): @@ -999,7 +1000,7 @@ def testByValueItem(self): BaseVectorDataTest.testByValueItem(self) def createQuatd(value): - return IECore.Quatd(value, 0, 0, 0) + return imath.Quatd(value, 0, 0, 0) class QuatdVectorDataTest(BaseVectorDataTest, unittest.TestCase): @@ -1070,7 +1071,7 @@ def testByValueItem(self): class Color3fVectorDataTest(BaseVectorDataTest, unittest.TestCase): def __init__(self, param1): - BaseVectorDataTest.__init__(self, IECore.Color3fVectorData, IECore.Color3f) + BaseVectorDataTest.__init__(self, IECore.Color3fVectorData, imath.Color3f) unittest.TestCase.__init__(self, param1) def testConstructors(self): @@ -1136,7 +1137,7 @@ def testByValueItem(self): class Color4fVectorDataTest(BaseVectorDataTest, unittest.TestCase): def __init__(self, param1): - BaseVectorDataTest.__init__(self, IECore.Color4fVectorData, IECore.Color4f) + BaseVectorDataTest.__init__(self, IECore.Color4fVectorData, imath.Color4f) unittest.TestCase.__init__(self, param1) def testConstructors(self): @@ -1199,137 +1200,137 @@ def testByValueItem(self): """Test Color4fVectorData by value return type""" BaseVectorDataTest.testByValueItem(self) -class Color3dVectorDataTest(BaseVectorDataTest, unittest.TestCase): +# class Color3dVectorDataTest(BaseVectorDataTest, unittest.TestCase): - def __init__(self, param1): - BaseVectorDataTest.__init__(self, IECore.Color3dVectorData, IECore.Color3d) - unittest.TestCase.__init__(self, param1) +# def __init__(self, param1): +# BaseVectorDataTest.__init__(self, IECore.Color3dVectorData, IECore.Color3d) +# unittest.TestCase.__init__(self, param1) - def testConstructors(self): - """Test Color3dVectorData constructors""" - BaseVectorDataTest.testConstructors(self) +# def testConstructors(self): +# """Test Color3dVectorData constructors""" +# BaseVectorDataTest.testConstructors(self) - def testResize(self): - """Test Color3dVectorData resizing""" - BaseVectorDataTest.testResize(self) +# def testResize(self): +# """Test Color3dVectorData resizing""" +# BaseVectorDataTest.testResize(self) - def testAssignment(self): - """Test Color3dVectorData assignment""" - BaseVectorDataTest.testAssignment(self) +# def testAssignment(self): +# """Test Color3dVectorData assignment""" +# BaseVectorDataTest.testAssignment(self) - def testNegativeIndexing(self): - """Test Color3dVectorData negative indexing""" - BaseVectorDataTest.testNegativeIndexing(self) +# def testNegativeIndexing(self): +# """Test Color3dVectorData negative indexing""" +# BaseVectorDataTest.testNegativeIndexing(self) - def testCopyOnWrite(self): - """Test Color3dVectorData copy-on-write behavior""" - BaseVectorDataTest.testCopyOnWrite(self) +# def testCopyOnWrite(self): +# """Test Color3dVectorData copy-on-write behavior""" +# BaseVectorDataTest.testCopyOnWrite(self) - def testContains(self): - """Test Color3dVectorData contains function""" - BaseVectorDataTest.testContains(self) +# def testContains(self): +# """Test Color3dVectorData contains function""" +# BaseVectorDataTest.testContains(self) - def testExtend(self): - """Test Color3dVectorData extend function""" - BaseVectorDataTest.testExtend(self) +# def testExtend(self): +# """Test Color3dVectorData extend function""" +# BaseVectorDataTest.testExtend(self) - def testSlices(self): - """Test Color3dVectorData slicing behavior""" - BaseVectorDataTest.testSlices(self) +# def testSlices(self): +# """Test Color3dVectorData slicing behavior""" +# BaseVectorDataTest.testSlices(self) - def testEquality(self): - """Test Color3dVectorData equality function""" - BaseVectorDataTest.testEquality(self) +# def testEquality(self): +# """Test Color3dVectorData equality function""" +# BaseVectorDataTest.testEquality(self) - def testComparison(self): - """Test Color3dVectorData comparison function""" - pass +# def testComparison(self): +# """Test Color3dVectorData comparison function""" +# pass - def testSumOperations(self): - """Test Color3dVectorData sum operations""" - BaseVectorDataTest.testSumOperations(self) +# def testSumOperations(self): +# """Test Color3dVectorData sum operations""" +# BaseVectorDataTest.testSumOperations(self) - def testSubOperations(self): - """Test Color3dVectorData subtraction operations""" - BaseVectorDataTest.testSubOperations(self) +# def testSubOperations(self): +# """Test Color3dVectorData subtraction operations""" +# BaseVectorDataTest.testSubOperations(self) - def testMultOperations(self): - """Test Color3dVectorData multiplication operations""" - BaseVectorDataTest.testMultOperations(self) +# def testMultOperations(self): +# """Test Color3dVectorData multiplication operations""" +# BaseVectorDataTest.testMultOperations(self) - def testDivOperations(self): - """Test Color3dVectorData division operations""" - BaseVectorDataTest.testDivOperations(self) +# def testDivOperations(self): +# """Test Color3dVectorData division operations""" +# BaseVectorDataTest.testDivOperations(self) - def testByValueItem(self): - """Test Color3dVectorData by value return type""" - BaseVectorDataTest.testByValueItem(self) +# def testByValueItem(self): +# """Test Color3dVectorData by value return type""" +# BaseVectorDataTest.testByValueItem(self) -class Color4dVectorDataTest(BaseVectorDataTest, unittest.TestCase): +# class Color4dVectorDataTest(BaseVectorDataTest, unittest.TestCase): - def __init__(self, param1): - BaseVectorDataTest.__init__(self, IECore.Color4dVectorData, IECore.Color4d) - unittest.TestCase.__init__(self, param1) +# def __init__(self, param1): +# BaseVectorDataTest.__init__(self, IECore.Color4dVectorData, IECore.Color4d) +# unittest.TestCase.__init__(self, param1) - def testConstructors(self): - """Test Color4dVectorData constructors""" - BaseVectorDataTest.testConstructors(self) +# def testConstructors(self): +# """Test Color4dVectorData constructors""" +# BaseVectorDataTest.testConstructors(self) - def testResize(self): - """Test Color4dVectorData resizing""" - BaseVectorDataTest.testResize(self) +# def testResize(self): +# """Test Color4dVectorData resizing""" +# BaseVectorDataTest.testResize(self) - def testAssignment(self): - """Test Color4dVectorData assignment""" - BaseVectorDataTest.testAssignment(self) +# def testAssignment(self): +# """Test Color4dVectorData assignment""" +# BaseVectorDataTest.testAssignment(self) - def testNegativeIndexing(self): - """Test Color4dVectorData negative indexing""" - BaseVectorDataTest.testNegativeIndexing(self) +# def testNegativeIndexing(self): +# """Test Color4dVectorData negative indexing""" +# BaseVectorDataTest.testNegativeIndexing(self) - def testCopyOnWrite(self): - """Test Color4dVectorData copy-on-write behavior""" - BaseVectorDataTest.testCopyOnWrite(self) +# def testCopyOnWrite(self): +# """Test Color4dVectorData copy-on-write behavior""" +# BaseVectorDataTest.testCopyOnWrite(self) - def testContains(self): - """Test Color4dVectorData contains function""" - BaseVectorDataTest.testContains(self) +# def testContains(self): +# """Test Color4dVectorData contains function""" +# BaseVectorDataTest.testContains(self) - def testExtend(self): - """Test Color4dVectorData extend function""" - BaseVectorDataTest.testExtend(self) +# def testExtend(self): +# """Test Color4dVectorData extend function""" +# BaseVectorDataTest.testExtend(self) - def testSlices(self): - """Test Color4dVectorData slicing behavior""" - BaseVectorDataTest.testSlices(self) +# def testSlices(self): +# """Test Color4dVectorData slicing behavior""" +# BaseVectorDataTest.testSlices(self) - def testEquality(self): - """Test Color4dVectorData equality function""" - BaseVectorDataTest.testEquality(self) +# def testEquality(self): +# """Test Color4dVectorData equality function""" +# BaseVectorDataTest.testEquality(self) - def testComparison(self): - """Test Color4dVectorData comparison function""" - pass +# def testComparison(self): +# """Test Color4dVectorData comparison function""" +# pass - def testSumOperations(self): - """Test Color4dVectorData sum operations""" - BaseVectorDataTest.testSumOperations(self) +# def testSumOperations(self): +# """Test Color4dVectorData sum operations""" +# BaseVectorDataTest.testSumOperations(self) - def testSubOperations(self): - """Test Color4dVectorData subtraction operations""" - BaseVectorDataTest.testSubOperations(self) +# def testSubOperations(self): +# """Test Color4dVectorData subtraction operations""" +# BaseVectorDataTest.testSubOperations(self) - def testMultOperations(self): - """Test Color4dVectorData multiplication operations""" - BaseVectorDataTest.testMultOperations(self) +# def testMultOperations(self): +# """Test Color4dVectorData multiplication operations""" +# BaseVectorDataTest.testMultOperations(self) - def testDivOperations(self): - """Test Color4dVectorData division operations""" - BaseVectorDataTest.testDivOperations(self) +# def testDivOperations(self): +# """Test Color4dVectorData division operations""" +# BaseVectorDataTest.testDivOperations(self) - def testByValueItem(self): - """Test Color4dVectorData by value return type""" - BaseVectorDataTest.testByValueItem(self) +# def testByValueItem(self): +# """Test Color4dVectorData by value return type""" +# BaseVectorDataTest.testByValueItem(self) if __name__ == "__main__": unittest.main() diff --git a/test/IECore/InverseDistanceWeightedInterpolation.py b/test/IECore/InverseDistanceWeightedInterpolation.py index 9d5507ce1b..19871ddf08 100644 --- a/test/IECore/InverseDistanceWeightedInterpolation.py +++ b/test/IECore/InverseDistanceWeightedInterpolation.py @@ -35,6 +35,7 @@ import random import unittest import os +import imath import IECore class TestInverseDistanceWeightedInterpolation(unittest.TestCase): @@ -44,10 +45,10 @@ def testSimple( self ): p = IECore.V3fVectorData() v = IECore.FloatVectorData() - p.append( IECore.V3f( -1, 1, 0 ) ) - p.append( IECore.V3f( -1, -1, 0 ) ) - p.append( IECore.V3f( 1, 1, 0 ) ) - p.append( IECore.V3f( 1, -1, 0 ) ) + p.append( imath.V3f( -1, 1, 0 ) ) + p.append( imath.V3f( -1, -1, 0 ) ) + p.append( imath.V3f( 1, 1, 0 ) ) + p.append( imath.V3f( 1, -1, 0 ) ) v.append( 1 ) v.append( 2 ) @@ -74,7 +75,7 @@ def testRandomPoints( self ): for i in range( 0, numPoints ): - p.append( IECore.V2f( random.uniform( 0, size ), random.uniform( 0, size ) ) ) + p.append( imath.V2f( random.uniform( 0, size ), random.uniform( 0, size ) ) ) v.append( random.uniform( 0, 1 ) ) idw = IECore.InverseDistanceWeightedInterpolationV2ff( p, v, 10 ) @@ -94,7 +95,7 @@ def testRandomPoints( self ): for i in range( 0, 10 ): for j in range( 0, 10 ) : - r = idw( IECore.V2f( i, j ) ) + r = idw( imath.V2f( i, j ) ) self.assertAlmostEqual( r, expected[i*10 + j], 5 ) def testVectorQueries( self ): @@ -109,7 +110,7 @@ def testVectorQueries( self ): for i in range( 0, numPoints ): - p.append( IECore.V2f( random.uniform( 0, size ), random.uniform( 0, size ) ) ) + p.append( imath.V2f( random.uniform( 0, size ), random.uniform( 0, size ) ) ) v.append( random.uniform( 0, 1 ) ) idw = IECore.InverseDistanceWeightedInterpolationV2ff( p, v, 10 ) @@ -117,7 +118,7 @@ def testVectorQueries( self ): queryPoints = IECore.V2fVectorData() for i in range( 0, size ): for j in range( 0, size ) : - queryPoints.append( IECore.V2f( i, j ) ) + queryPoints.append( imath.V2f( i, j ) ) f = idw( queryPoints ) diff --git a/test/IECore/KDTree.py b/test/IECore/KDTree.py index 457003a70a..6b83319671 100644 --- a/test/IECore/KDTree.py +++ b/test/IECore/KDTree.py @@ -34,6 +34,7 @@ import random import unittest +import imath import IECore class TestKDTree: @@ -137,15 +138,15 @@ def makeTree(self, numPoints): self.points = IECore.V2fVectorData() for i in range(0, numPoints): - self.points.append( IECore.V2f( random.random(), random.random() ) ) + self.points.append( imath.V2f( random.random(), random.random() ) ) self.tree = IECore.V2fTree( self.points ) def randomBox( self ) : - min = IECore.V2f( random.random(), random.random() ) - max = min + IECore.V2f( random.random(), random.random() ) - return IECore.Box2f( min, max ) + min = imath.V2f( random.random(), random.random() ) + max = min + imath.V2f( random.random(), random.random() ) + return imath.Box2f( min, max ) def testConstructors(self): """Test KDTreeV2f constructors""" @@ -185,15 +186,15 @@ def makeTree(self, numPoints): self.points = IECore.V2dVectorData() for i in range(0, numPoints): - self.points.append( IECore.V2d( random.random(), random.random() ) ) + self.points.append( imath.V2d( random.random(), random.random() ) ) self.tree = IECore.V2dTree( self.points ) def randomBox( self ) : - min = IECore.V2d( random.random(), random.random() ) - max = min + IECore.V2d( random.random(), random.random() ) - return IECore.Box2d( min, max ) + min = imath.V2d( random.random(), random.random() ) + max = min + imath.V2d( random.random(), random.random() ) + return imath.Box2d( min, max ) def testConstructors(self): """Test KDTreeV2d constructors""" @@ -233,15 +234,15 @@ def makeTree(self, numPoints): self.points = IECore.V3fVectorData() for i in range(0, numPoints): - self.points.append( IECore.V3f( random.random(), random.random(), random.random() ) ) + self.points.append( imath.V3f( random.random(), random.random(), random.random() ) ) self.tree = IECore.V3fTree( self.points ) def randomBox( self ) : - min = IECore.V3f( random.random(), random.random(), random.random() ) - max = min + IECore.V3f( random.random(), random.random(), random.random() ) - return IECore.Box3f( min, max ) + min = imath.V3f( random.random(), random.random(), random.random() ) + max = min + imath.V3f( random.random(), random.random(), random.random() ) + return imath.Box3f( min, max ) def testConstructors(self): """Test KDTreeV3f constructors""" @@ -281,15 +282,15 @@ def makeTree(self, numPoints): self.points = IECore.V3dVectorData() for i in range(0, numPoints): - self.points.append( IECore.V3d( random.random(), random.random(), random.random() ) ) + self.points.append( imath.V3d( random.random(), random.random(), random.random() ) ) self.tree = IECore.V3dTree( self.points ) def randomBox( self ) : - min = IECore.V3d( random.random(), random.random(), random.random() ) - max = min + IECore.V3d( random.random(), random.random(), random.random() ) - return IECore.Box3d( min, max ) + min = imath.V3d( random.random(), random.random(), random.random() ) + max = min + imath.V3d( random.random(), random.random(), random.random() ) + return imath.Box3d( min, max ) def testConstructors(self): """Test KDTreeV3d constructors""" diff --git a/test/IECore/LineSegmentTest.py b/test/IECore/LineSegmentTest.py index 4e9b7c6c21..73be8bfa1a 100644 --- a/test/IECore/LineSegmentTest.py +++ b/test/IECore/LineSegmentTest.py @@ -34,6 +34,7 @@ import unittest import math +import imath import IECore class LineSegmentTest( unittest.TestCase ) : @@ -42,8 +43,8 @@ def testConstructor( self ) : l = IECore.LineSegment3f() - p0 = IECore.V3f( 1, 2, 3 ) - p1 = IECore.V3f( 4, 5, 6 ) + p0 = imath.V3f( 1, 2, 3 ) + p1 = imath.V3f( 4, 5, 6 ) l = IECore.LineSegment3f( p0, p1 ) self.assertEqual( l.p0, p0 ) @@ -53,34 +54,34 @@ def testPointAccess( self ) : l = IECore.LineSegment3f() - l.p0 = IECore.V3f( 1, 2, 3 ) - self.assertEqual( l.p0, IECore.V3f( 1, 2, 3 ) ) + l.p0 = imath.V3f( 1, 2, 3 ) + self.assertEqual( l.p0, imath.V3f( 1, 2, 3 ) ) - l.p1 = IECore.V3f( 4, 5, 6 ) - self.assertEqual( l.p1, IECore.V3f( 4, 5, 6 ) ) + l.p1 = imath.V3f( 4, 5, 6 ) + self.assertEqual( l.p1, imath.V3f( 4, 5, 6 ) ) def testCall( self ) : - l = IECore.LineSegment3f( IECore.V3f( 0 ), IECore.V3f( 1 ) ) + l = IECore.LineSegment3f( imath.V3f( 0 ), imath.V3f( 1 ) ) - self.assertEqual( l( 0 ), IECore.V3f( 0 ) ) - self.assertEqual( l( 1 ), IECore.V3f( 1 ) ) - self.assertEqual( l( 0.5 ), IECore.V3f( 0.5 ) ) - self.assertEqual( l( -1 ), IECore.V3f( -1 ) ) - self.assertEqual( l( 2 ), IECore.V3f( 2 ) ) + self.assertEqual( l( 0 ), imath.V3f( 0 ) ) + self.assertEqual( l( 1 ), imath.V3f( 1 ) ) + self.assertEqual( l( 0.5 ), imath.V3f( 0.5 ) ) + self.assertEqual( l( -1 ), imath.V3f( -1 ) ) + self.assertEqual( l( 2 ), imath.V3f( 2 ) ) def testLength( self ) : - l = IECore.LineSegment3f( IECore.V3f( 1 ), IECore.V3f( 2 ) ) + l = IECore.LineSegment3f( imath.V3f( 1 ), imath.V3f( 2 ) ) - self.assertEqual( l.length(), IECore.V3f( 1 ).length() ) - self.assertEqual( l.length2(), IECore.V3f( 1 ).length2() ) + self.assertEqual( l.length(), imath.V3f( 1 ).length() ) + self.assertEqual( l.length2(), imath.V3f( 1 ).length2() ) def testClosestPointTo( self ) : - l = IECore.LineSegment3f( IECore.V3f( 1 ), IECore.V3f( 2 ) ) + l = IECore.LineSegment3f( imath.V3f( 1 ), imath.V3f( 2 ) ) - r = IECore.Rand32( 100 ) + r = imath.Rand32( 100 ) for i in range( 0, 1000 ) : @@ -97,7 +98,7 @@ def testClosestPointTo( self ) : p = l( r.nextf( 1, 2 ) ) self.assert_( l.closestPointTo( p ).equalWithAbsError( l.p1, 0.00001 ) ) - t = l.direction().cross( IECore.V3f( 0, 1, 0 ) ) + t = l.direction().cross( imath.V3f( 0, 1, 0 ) ) for i in range( 0, 1000 ) : pl = l( r.nextf( 0, 1 ) ) @@ -118,7 +119,7 @@ def testClosestPointTo( self ) : def testClosestPoints( self ) : - r = IECore.Rand32( 100 ) + r = imath.Rand32( 100 ) for i in range( 0, 1000 ) : x = r.nextf( -10, 10 ) @@ -126,8 +127,8 @@ def testClosestPoints( self ) : z1 = r.nextf( -10, 10 ) z2 = r.nextf( -10, 10 ) - l1 = IECore.LineSegment3f( IECore.V3f( -10, y, z1 ), IECore.V3f( 10, y, z1 ) ) - l2 = IECore.LineSegment3f( IECore.V3f( x, -10, z2 ), IECore.V3f( x, 10, z2 ) ) + l1 = IECore.LineSegment3f( imath.V3f( -10, y, z1 ), imath.V3f( 10, y, z1 ) ) + l2 = IECore.LineSegment3f( imath.V3f( x, -10, z2 ), imath.V3f( x, 10, z2 ) ) p1, p2 = l1.closestPoints( l2 ) p3, p4 = l2.closestPoints( l1 ) @@ -140,16 +141,16 @@ def testClosestPoints( self ) : # | ------ # | # | - l1 = IECore.LineSegment3f( IECore.V3f( 0, 0, 0 ), IECore.V3f( 0, 2, 0 ) ) - l2 = IECore.LineSegment3f( IECore.V3f( 1, 1, 0 ), IECore.V3f( 3, 1, 0 ) ) + l1 = IECore.LineSegment3f( imath.V3f( 0, 0, 0 ), imath.V3f( 0, 2, 0 ) ) + l2 = IECore.LineSegment3f( imath.V3f( 1, 1, 0 ), imath.V3f( 3, 1, 0 ) ) p1, p2 = l1.closestPoints( l2 ) p3, p4 = l2.closestPoints( l1 ) self.assertEqual( p1, p4 ) self.assertEqual( p2, p3 ) - self.assertEqual( p1, IECore.V3f( 0, 1, 0 ) ) - self.assertEqual( p2, IECore.V3f( 1, 1, 0 ) ) + self.assertEqual( p1, imath.V3f( 0, 1, 0 ) ) + self.assertEqual( p2, imath.V3f( 1, 1, 0 ) ) # \ # \ @@ -157,49 +158,49 @@ def testClosestPoints( self ) : # / # / - l1 = IECore.LineSegment3f( IECore.V3f( 0, 0, 0 ), IECore.V3f( 2, 2, 0 ) ) - l2 = IECore.LineSegment3f( IECore.V3f( 0, 5, 0 ), IECore.V3f( 2, 3, 0 ) ) + l1 = IECore.LineSegment3f( imath.V3f( 0, 0, 0 ), imath.V3f( 2, 2, 0 ) ) + l2 = IECore.LineSegment3f( imath.V3f( 0, 5, 0 ), imath.V3f( 2, 3, 0 ) ) p1, p2 = l1.closestPoints( l2 ) p3, p4 = l2.closestPoints( l1 ) self.assertEqual( p1, p4 ) self.assertEqual( p2, p3 ) - self.assertEqual( p1, IECore.V3f( 2, 2, 0 ) ) - self.assertEqual( p2, IECore.V3f( 2, 3, 0 ) ) + self.assertEqual( p1, imath.V3f( 2, 2, 0 ) ) + self.assertEqual( p2, imath.V3f( 2, 3, 0 ) ) def testTransform( self ) : - l1 = IECore.LineSegment3f( IECore.V3f( 0, 0, 0 ), IECore.V3f( 0, 2, 0 ) ) + l1 = IECore.LineSegment3f( imath.V3f( 0, 0, 0 ), imath.V3f( 0, 2, 0 ) ) l2 = IECore.LineSegment3f( l1 ) self.assertEqual( l1, l2 ) - t = IECore.M44f.createTranslated( IECore.V3f( 1 ) ) + t = imath.M44f().translate( imath.V3f( 1 ) ) l3 = l2 * t self.assertEqual( l1, l2 ) - self.assertEqual( l3.p0, l2.p0 + IECore.V3f( 1 ) ) - self.assertEqual( l3.p1, l2.p1 + IECore.V3f( 1 ) ) + self.assertEqual( l3.p0, l2.p0 + imath.V3f( 1 ) ) + self.assertEqual( l3.p1, l2.p1 + imath.V3f( 1 ) ) l1 *= t - self.assertEqual( l1.p0, l2.p0 + IECore.V3f( 1 ) ) - self.assertEqual( l1.p1, l2.p1 + IECore.V3f( 1 ) ) + self.assertEqual( l1.p0, l2.p0 + imath.V3f( 1 ) ) + self.assertEqual( l1.p1, l2.p1 + imath.V3f( 1 ) ) def testIntersect( self ) : - l = IECore.LineSegment3f( IECore.V3f( 0, -1, 0 ), IECore.V3f( 0, 1, 0 ) ) - p = IECore.Plane3f( IECore.V3f( 0, 1, 0 ), 0 ) - self.assertEqual( l.intersect( p ), ( True, IECore.V3f( 0, 0, 0 ) ) ) + l = IECore.LineSegment3f( imath.V3f( 0, -1, 0 ), imath.V3f( 0, 1, 0 ) ) + p = imath.Plane3f( imath.V3f( 0, 1, 0 ), 0 ) + self.assertEqual( l.intersect( p ), ( True, imath.V3f( 0, 0, 0 ) ) ) self.assertEqual( l.intersectT( p ), ( True, 0.5 ) ) - p = IECore.Plane3f( IECore.V3f( -1, 0, 0 ), 10 ) + p = imath.Plane3f( imath.V3f( -1, 0, 0 ), 10 ) self.assertEqual( l.intersect( p )[0], False ) self.assertEqual( l.intersectT( p )[0], False ) def testRepr( self ) : - p0 = IECore.V3f( 0, 0, 0 ) - p1 = IECore.V3f( 0, 0, 0 ) + p0 = imath.V3f( 0, 0, 0 ) + p1 = imath.V3f( 0, 0, 0 ) l = IECore.LineSegment3f( p0, p1 ) self.assertEqual( repr(l), "IECore.LineSegment3f( " + repr(p0) + ", " + repr(p1) + " )" ) diff --git a/test/IECore/Math.py b/test/IECore/Math.py index ae60a18556..e1e93ce8c9 100644 --- a/test/IECore/Math.py +++ b/test/IECore/Math.py @@ -34,21 +34,22 @@ import os import unittest +import imath import IECore class MathTest( unittest.TestCase ) : def testSign( self ) : - self.assertEqual( IECore.sign( 0 ), 0 ) - self.assertEqual( IECore.sign( 1 ), 1 ) - self.assertEqual( IECore.sign( 1000 ), 1 ) - self.assertEqual( IECore.sign( -1 ), -1 ) - self.assertEqual( IECore.sign( -1000 ), -1 ) + self.assertEqual( imath.sign( 0 ), 0 ) + self.assertEqual( imath.sign( 1 ), 1 ) + self.assertEqual( imath.sign( 1000 ), 1 ) + self.assertEqual( imath.sign( -1 ), -1 ) + self.assertEqual( imath.sign( -1000 ), -1 ) - self.assertEqual( IECore.sign( 0.0 ), 0 ) - self.assertEqual( IECore.sign( 0.1 ), 1 ) - self.assertEqual( IECore.sign( -0.1 ), -1 ) + self.assertEqual( imath.sign( 0.0 ), 0 ) + self.assertEqual( imath.sign( 0.1 ), 1 ) + self.assertEqual( imath.sign( -0.1 ), -1 ) if __name__ == "__main__": unittest.main() diff --git a/test/IECore/MatrixMultiplyOp.py b/test/IECore/MatrixMultiplyOp.py index ba666f982c..ebc087268e 100644 --- a/test/IECore/MatrixMultiplyOp.py +++ b/test/IECore/MatrixMultiplyOp.py @@ -34,6 +34,7 @@ import unittest import os.path +import imath import IECore @@ -41,16 +42,16 @@ class TestMultiplyMatrixOp( unittest.TestCase ) : def testMultiplication( self ) : vectorTypes = [ - IECore.V3fVectorData( [ IECore.V3f(1), IECore.V3f(2), IECore.V3f(3) ], IECore.GeometricData.Interpretation.Vector ), - IECore.V3dVectorData( [ IECore.V3d(1), IECore.V3d(2), IECore.V3d(3) ], IECore.GeometricData.Interpretation.Vector ), + IECore.V3fVectorData( [ imath.V3f(1), imath.V3f(2), imath.V3f(3) ], IECore.GeometricData.Interpretation.Vector ), + IECore.V3dVectorData( [ imath.V3d(1), imath.V3d(2), imath.V3d(3) ], IECore.GeometricData.Interpretation.Vector ), ] matrixTypes = [ - IECore.M33fData( IECore.M33f() * 3 ), - IECore.M33dData( IECore.M33d() * 3 ), - IECore.M44fData( IECore.M44f().createScaled( IECore.V3f(3) ) ), - IECore.M44dData( IECore.M44d().createScaled( IECore.V3d(3) ) ), - IECore.TransformationMatrixfData( IECore.TransformationMatrixf( IECore.V3f( 3 ), IECore.Eulerf(), IECore.V3f( 0 ) ) ), - IECore.TransformationMatrixdData( IECore.TransformationMatrixd( IECore.V3d( 3 ), IECore.Eulerd(), IECore.V3d( 0 ) ) ), + IECore.M33fData( imath.M33f() * 3 ), + IECore.M33dData( imath.M33d() * 3 ), + IECore.M44fData( imath.M44f().scale( imath.V3f(3) ) ), + IECore.M44dData( imath.M44d().scale( imath.V3d(3) ) ), + IECore.TransformationMatrixfData( IECore.TransformationMatrixf( imath.V3f( 3 ), imath.Eulerf(), imath.V3f( 0 ) ) ), + IECore.TransformationMatrixdData( IECore.TransformationMatrixd( imath.V3d( 3 ), imath.Eulerd(), imath.V3d( 0 ) ) ), ] for vector in vectorTypes: @@ -66,55 +67,55 @@ def testMultiplication( self ) : def testInterpretations( self ) : - v = IECore.V3fVectorData( [ IECore.V3f( 1 ), IECore.V3f( 2 ), IECore.V3f( 3 ) ], IECore.GeometricData.Interpretation.Point ) + v = IECore.V3fVectorData( [ imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ) ], IECore.GeometricData.Interpretation.Point ) o = IECore.MatrixMultiplyOp() # as points - vt = o( object = v.copy(), matrix = IECore.M44fData( IECore.M44f.createTranslated( IECore.V3f( 1, 2, 3 ) ) ) ) + vt = o( object = v.copy(), matrix = IECore.M44fData( imath.M44f().translate( imath.V3f( 1, 2, 3 ) ) ) ) for i in range( v.size() ) : - self.assertEqual( vt[i], v[i] + IECore.V3f( 1, 2, 3 ) ) + self.assertEqual( vt[i], v[i] + imath.V3f( 1, 2, 3 ) ) # as vectors v2 = v.copy() v2.setInterpretation( IECore.GeometricData.Interpretation.Vector ) - vt = o( object = v2, matrix = IECore.M44fData( IECore.M44f.createTranslated( IECore.V3f( 1, 2, 3 ) ) ) ) + vt = o( object = v2, matrix = IECore.M44fData( imath.M44f().translate( imath.V3f( 1, 2, 3 ) ) ) ) for i in range( v.size() ) : self.assertEqual( vt[i], v[i] ) - vt = o( object = v2, matrix = IECore.M44fData( IECore.M44f.createScaled( IECore.V3f( 1, 2, 3 ) ) ) ) + vt = o( object = v2, matrix = IECore.M44fData( imath.M44f().scale( imath.V3f( 1, 2, 3 ) ) ) ) for i in range( v.size() ) : - self.assertEqual( vt[i], v[i] * IECore.V3f( 1, 2, 3 ) ) + self.assertEqual( vt[i], v[i] * imath.V3f( 1, 2, 3 ) ) # as normals v3 = v.copy() v3.setInterpretation( IECore.GeometricData.Interpretation.Normal ) - vt = o( object = v3, matrix = IECore.M44fData( IECore.M44f.createTranslated( IECore.V3f( 1, 2, 3 ) ) ) ) + vt = o( object = v3, matrix = IECore.M44fData( imath.M44f().translate( imath.V3f( 1, 2, 3 ) ) ) ) for i in range( v.size() ) : self.assertEqual( vt[i], v[i] ) - vt = o( object = v3, matrix = IECore.M44fData( IECore.M44f.createScaled( IECore.V3f( 1, 2, 3 ) ) ) ) + vt = o( object = v3, matrix = IECore.M44fData( imath.M44f().scale( imath.V3f( 1, 2, 3 ) ) ) ) for i in range( v.size() ) : - self.assertNotEqual( vt[i], v[i] * IECore.V3f( 1, 2, 3 ) ) + self.assertNotEqual( vt[i], v[i] * imath.V3f( 1, 2, 3 ) ) # nothing happens for numeric v4 = v.copy() v4.setInterpretation( IECore.GeometricData.Interpretation.None ) - vt = o( object = v4, matrix = IECore.M44fData( IECore.M44f.createTranslated( IECore.V3f( 1, 2, 3 ) ) ) ) + vt = o( object = v4, matrix = IECore.M44fData( imath.M44f().translate( imath.V3f( 1, 2, 3 ) ) ) ) for i in range( v.size() ) : self.assertEqual( vt[i], v[i] ) - vt = o( object = v4, matrix = IECore.M44fData( IECore.M44f.createScaled( IECore.V3f( 1, 2, 3 ) ) ) ) + vt = o( object = v4, matrix = IECore.M44fData( imath.M44f().scale( imath.V3f( 1, 2, 3 ) ) ) ) for i in range( v.size() ) : self.assertEqual( vt[i], v[i] ) # nothing happens for color v5 = v.copy() v5.setInterpretation( IECore.GeometricData.Interpretation.Color ) - vt = o( object = v5, matrix = IECore.M44fData( IECore.M44f.createTranslated( IECore.V3f( 1, 2, 3 ) ) ) ) + vt = o( object = v5, matrix = IECore.M44fData( imath.M44f().translate( imath.V3f( 1, 2, 3 ) ) ) ) for i in range( v.size() ) : self.assertEqual( vt[i], v[i] ) - vt = o( object = v5, matrix = IECore.M44fData( IECore.M44f.createScaled( IECore.V3f( 1, 2, 3 ) ) ) ) + vt = o( object = v5, matrix = IECore.M44fData( imath.M44f().scale( imath.V3f( 1, 2, 3 ) ) ) ) for i in range( v.size() ) : self.assertEqual( vt[i], v[i] ) diff --git a/test/IECore/MurmurHashTest.py b/test/IECore/MurmurHashTest.py index 084fef1223..cb2756c1b7 100644 --- a/test/IECore/MurmurHashTest.py +++ b/test/IECore/MurmurHashTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore @@ -144,8 +145,8 @@ def testTypeDoesntMatter( self ) : h1 = IECore.MurmurHash() h2 = IECore.MurmurHash() - h1.append( IECore.V3f( 1, 2, 3 ) ) - h2.append( IECore.Color3f( 1, 2, 3 ) ) + h1.append( imath.V3f( 1, 2, 3 ) ) + h2.append( imath.Color3f( 1, 2, 3 ) ) self.assertEqual( h1, h2 ) @@ -159,7 +160,7 @@ def testTypeDoesntMatter( self ) : def testAllDimensionsOfImathVecs( self ) : - vv = [ IECore.V3f( 1, 2, 3 ), IECore.Color4f( 1, 2, 3, 4 ) ] + vv = [ imath.V3f( 1, 2, 3 ), imath.Color4f( 1, 2, 3, 4 ) ] for v in vv : h = IECore.MurmurHash() h.append( v ) @@ -173,20 +174,21 @@ def testAllDimensionsOfImathVecs( self ) : def testAllElementsOfImathBoxes( self ) : vv = [ - IECore.Box3f( IECore.V3f( 1, 2, 3 ), IECore.V3f( 4, 5, 6 ) ), - IECore.Box2f( IECore.V2f( 1, 2 ), IECore.V2f( 3, 4 ) ), + imath.Box3f( imath.V3f( 1, 2, 3 ), imath.V3f( 4, 5, 6 ) ), + imath.Box2f( imath.V2f( 1, 2 ), imath.V2f( 3, 4 ) ), ] for v in vv : h = IECore.MurmurHash() h.append( v ) - for m in v.min, v.max : - for i in range( 0, m.dimensions() ) : - m[i] = 0 - nextH = IECore.MurmurHash() - nextH.append( v ) - self.assertNotEqual( h, nextH ) - h = nextH + for m in range( 0, 1 ) : + for i in range( 0, v.min().dimensions() ) : + minMax = [ v.min(), v.max() ] + minMax[m][i] = 0 + v2 = v.__class__( *minMax ) + h2 = IECore.MurmurHash() + h2.append( v2 ) + self.assertNotEqual( h, h2 ) def testCopyFrom( self ) : diff --git a/test/IECore/ObjectIO.py b/test/IECore/ObjectIO.py index 7add6d065b..47215a29dd 100644 --- a/test/IECore/ObjectIO.py +++ b/test/IECore/ObjectIO.py @@ -35,6 +35,7 @@ import os import unittest import random +import imath import IECore class TestObjectIO( unittest.TestCase ) : @@ -100,7 +101,7 @@ def testImathArrayIO( self ) : o = IECore.V3fVectorData() o.setInterpretation( IECore.GeometricData.Interpretation.Vector ) for i in range( 0, 1000 ) : - o.append( IECore.V3f( i*3, i*3 + 1, i*3 + 2 ) ) + o.append( imath.V3f( i*3, i*3 + 1, i*3 + 2 ) ) self.assertEqual( o.size(), 1000 ) o.save( iface, "test" ) @@ -167,13 +168,13 @@ def testDataTypes( self ): d['a'] = IECore.IntData(1) d['c'] = IECore.FloatData(3) d['e'] = IECore.HalfData(4) - d['f'] = IECore.V2iData( IECore.V2i(1,10) ) - d['g'] = IECore.V2fData( IECore.V2f(2,31), IECore.GeometricData.Interpretation.Vector ) - d['h'] = IECore.V2dData( IECore.V2d(3,551), IECore.GeometricData.Interpretation.Color ) - d['i'] = IECore.V3fData( IECore.V3f(1,3,5), IECore.GeometricData.Interpretation.Point ) - d['k'] = IECore.M44fData( IECore.M44f(2) ) + 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( [ IECore.V2f(1,2), IECore.V2f(3,4), IECore.V2f(5,6) ], IECore.GeometricData.Interpretation.Normal ) + 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' ] ) diff --git a/test/IECore/ObjectInterpolation.py b/test/IECore/ObjectInterpolation.py index 494ac8f470..b94e0d1ab4 100644 --- a/test/IECore/ObjectInterpolation.py +++ b/test/IECore/ObjectInterpolation.py @@ -34,6 +34,7 @@ ########################################################################## import unittest +import imath import IECore class TestObjectInterpolation( unittest.TestCase ) : @@ -43,31 +44,31 @@ 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( IECore.V2f(1) ), IECore.V2fData( IECore.V2f(2) ), 0.5 ), IECore.V2fData( IECore.V2f(1.5) ) ) - self.assertEqual( IECore.linearObjectInterpolation( IECore.V3fData( IECore.V3f(1) ), IECore.V3fData( IECore.V3f(2) ), 0.5 ), IECore.V3fData( IECore.V3f(1.5) ) ) - self.assertEqual( IECore.linearObjectInterpolation( IECore.V2dData( IECore.V2d(1) ), IECore.V2dData( IECore.V2d(2) ), 0.5 ), IECore.V2dData( IECore.V2d(1.5) ) ) - self.assertEqual( IECore.linearObjectInterpolation( IECore.V3dData( IECore.V3d(1) ), IECore.V3dData( IECore.V3d(2) ), 0.5 ), IECore.V3dData( IECore.V3d(1.5) ) ) - self.assertEqual( IECore.linearObjectInterpolation( IECore.Box3fData( IECore.Box3f( IECore.V3f(1), IECore.V3f(1) ) ), IECore.Box3fData( IECore.Box3f( IECore.V3f(2), IECore.V3f(2) ) ), 0.5 ), IECore.Box3fData( IECore.Box3f( IECore.V3f(1.5), IECore.V3f(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) ) ) ) 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( [IECore.V2f(1)] ), IECore.V2fVectorData( [IECore.V2f(2)] ), 0.5 ), IECore.V2fVectorData( [IECore.V2f(1.5)] ) ) - self.assertEqual( IECore.linearObjectInterpolation( IECore.V3fVectorData( [IECore.V3f(1)] ), IECore.V3fVectorData( [IECore.V3f(2)] ), 0.5 ), IECore.V3fVectorData( [IECore.V3f(1.5)] ) ) - self.assertEqual( IECore.linearObjectInterpolation( IECore.V2dVectorData( [IECore.V2d(1)] ), IECore.V2dVectorData( [IECore.V2d(2)] ), 0.5 ), IECore.V2dVectorData( [IECore.V2d(1.5)] ) ) - self.assertEqual( IECore.linearObjectInterpolation( IECore.V3dVectorData( [IECore.V3d(1)] ), IECore.V3dVectorData( [IECore.V3d(2)] ), 0.5 ), IECore.V3dVectorData( [IECore.V3d(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)] ) ) def testMatrixInterpolation( self ): - m1 = IECore.M44d() - m1.translate( IECore.V3d(1,0,0) ) - m2 = IECore.M44d() - m2.translate( IECore.V3d(0,1,0) ) - m2.scale( IECore.V3d(9,9,9) ) - mx = IECore.M44d() - mx.translate( IECore.V3d(0.5,0.5,0) ) - mx.scale( IECore.V3d(5,5,5) ) + m1 = imath.M44d() + m1.translate( imath.V3d(1,0,0) ) + m2 = imath.M44d() + m2.translate( imath.V3d(0,1,0) ) + m2.scale( imath.V3d(9,9,9) ) + mx = imath.M44d() + mx.translate( imath.V3d(0.5,0.5,0) ) + mx.scale( imath.V3d(5,5,5) ) self.assertEqual( IECore.linearObjectInterpolation( IECore.M44dData(m1), IECore.M44dData(m2), 0.5 ), IECore.M44dData(mx) ) def __buildTree( self, compoundType, seed ): @@ -79,9 +80,9 @@ def buildCompound( compoundType, seed ): c[ "int" ] = IECore.IntData( intSeed ) c[ "float" ] = IECore.FloatData( seed ) c[ "double" ] = IECore.DoubleData( seed ) - c[ "box" ] = IECore.Box3fData( IECore.Box3f( IECore.V3f( seed ), IECore.V3f( seed ) ) ) - c[ "color" ] = IECore.Color3fData( IECore.Color3f( seed, seed, seed ) ) - c[ "v3d" ] = IECore.V3dData( IECore.V3d( seed, seed, seed ) ) + c[ "box" ] = IECore.Box3fData( imath.Box3f( imath.V3f( seed ), imath.V3f( seed ) ) ) + c[ "color" ] = IECore.Color3fData( imath.Color3f( seed, seed, seed ) ) + c[ "v3d" ] = IECore.V3dData( imath.V3d( seed, seed, seed ) ) return c c = buildCompound( compoundType, seed ) diff --git a/test/IECore/ParameterParser.py b/test/IECore/ParameterParser.py index 491bc23066..e7879caf0e 100644 --- a/test/IECore/ParameterParser.py +++ b/test/IECore/ParameterParser.py @@ -34,6 +34,7 @@ ########################################################################## import unittest +import imath import IECore import shlex @@ -76,8 +77,8 @@ def testParameterTypes( self ) : "-u", "64", "128", "-v", "25", "26", "27", "-w", "0-500x250", - "-x", '0', '0', '0', '1', '1', '1', '0', '0', '0', '0', '0', '0', 'Default', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - "-y", '0', '0', '0', '1', '1', '1', '0', '0', '0', '0', '0', '0', 'Default', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + "-x", '0', '0', '0', '1', '1', '1', '0', '0', '0', '0', '0', '0', 'XYZ', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + "-y", '0', '0', '0', '1', '1', '1', '0', '0', '0', '0', '0', '0', 'XYZ', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', ], a.parameters() ) @@ -354,16 +355,16 @@ def testTransformationMatrixParsing( self ) : IECore.ParameterParser().parse( args, p ) t = p["t"].getTypedValue() - self.assertEqual( t.translate,IECore.V3f( 1,2,3 ) ) - self.assertEqual( t.scale,IECore.V3f( 10,11,12 ) ) - self.assertEqual( t.shear, IECore.V3f( 4,5,6 ) ) - self.assertEqual( t.rotate, IECore.V3f( 7,8,9 ) ) - self.assertEqual( t.rotate.order(),IECore.Eulerf.Order.ZYX ) - self.assertEqual( t.rotationOrientation, IECore.Quatf( 1,21,22,23 ) ) - self.assertEqual( t.rotatePivot, IECore.V3f( 26,27,28 ) ) - self.assertEqual( t.rotatePivotTranslation, IECore.V3f( 36,37,38 ) ) - self.assertEqual( t.scalePivot, IECore.V3f( 46,47,48 ) ) - self.assertEqual( t.scalePivotTranslation, IECore.V3f( 56,57,58 ) ) + self.assertEqual( t.translate,imath.V3f( 1,2,3 ) ) + self.assertEqual( t.scale,imath.V3f( 10,11,12 ) ) + self.assertEqual( t.shear, imath.V3f( 4,5,6 ) ) + self.assertEqual( t.rotate, imath.V3f( 7,8,9 ) ) + self.assertEqual( t.rotate.order(),imath.Eulerf.Order.ZYX ) + self.assertEqual( t.rotationOrientation, imath.Quatf( 1,21,22,23 ) ) + self.assertEqual( t.rotatePivot, imath.V3f( 26,27,28 ) ) + self.assertEqual( t.rotatePivotTranslation, imath.V3f( 36,37,38 ) ) + self.assertEqual( t.scalePivot, imath.V3f( 46,47,48 ) ) + self.assertEqual( t.scalePivotTranslation, imath.V3f( 56,57,58 ) ) def testLineSegmentParsing( self ) : @@ -374,24 +375,24 @@ def testLineSegmentParsing( self ) : IECore.LineSegment3fParameter( name = "f", description = "", - defaultValue = IECore.LineSegment3f( IECore.V3f( 1 ), IECore.V3f( 2 ) ) + defaultValue = IECore.LineSegment3f( imath.V3f( 1 ), imath.V3f( 2 ) ) ), IECore.LineSegment3dParameter( name = "d", description = "", - defaultValue = IECore.LineSegment3d( IECore.V3d( 1 ), IECore.V3d( 2 ) ) + defaultValue = IECore.LineSegment3d( imath.V3d( 1 ), imath.V3d( 2 ) ) ), ] ) - args = "-f 1 2 3 4 5 6 -d 6 5 4 3 2 1".split() + args = "-f 1.0 2.0 3.0 4.0 5.0 6.0 -d 6.0 5.0 4.0 3.0 2.0 1.0".split() IECore.ParameterParser().parse( args, p ) - self.assertEqual( p["f"].getTypedValue(), IECore.LineSegment3f( IECore.V3f( 1, 2, 3 ), IECore.V3f( 4, 5, 6 ) ) ) - self.assertEqual( p["d"].getTypedValue(), IECore.LineSegment3d( IECore.V3d( 6, 5, 4 ), IECore.V3d( 3, 2, 1 ) ) ) + self.assertEqual( p["f"].getTypedValue(), IECore.LineSegment3f( imath.V3f( 1, 2, 3 ), imath.V3f( 4, 5, 6 ) ) ) + self.assertEqual( p["d"].getTypedValue(), IECore.LineSegment3d( imath.V3d( 6, 5, 4 ), imath.V3d( 3, 2, 1 ) ) ) self.assertEqual( IECore.ParameterParser().serialise( p ), args ) @@ -489,12 +490,12 @@ def testNoValueProvidedSyntaxError( self ) : IECore.V2iParameter( name = "v2i", description = "d", - defaultValue = IECore.V2i( 0 ), + defaultValue = imath.V2i( 0 ), ), IECore.Box3fParameter( name = "box3f", description = "d", - defaultValue = IECore.Box3f( IECore.V3f( 0 ), IECore.V3f( 1 ) ), + defaultValue = imath.Box3f( imath.V3f( 0 ), imath.V3f( 1 ) ), ), IECore.SplineffParameter( name = "spline", diff --git a/test/IECore/Parameters.py b/test/IECore/Parameters.py index 61510514b2..4718fbe0fd 100644 --- a/test/IECore/Parameters.py +++ b/test/IECore/Parameters.py @@ -37,6 +37,7 @@ import unittest import os +import imath import IECore @@ -188,7 +189,7 @@ def testRunTimeTyping( self ) : c = IECore.V3fParameter( name = "i", description = "d", - defaultValue = IECore.V3f( 1 ), + defaultValue = imath.V3f( 1 ), ) self.assertEqual( c.typeId(), IECore.TypeId.V3fParameter ) self.assertEqual( c.typeName(), "V3fParameter" ) @@ -388,11 +389,11 @@ class TestTypedParameter( unittest.TestCase ) : def testConstructor( self ) : - p = IECore.V2fParameter( "n", "d", IECore.V2f( 10 ) ) + p = IECore.V2fParameter( "n", "d", imath.V2f( 10 ) ) self.assertEqual( p.name, "n" ) self.assertEqual( p.description, "d" ) - self.assertEqual( p.defaultValue, IECore.V2fData( IECore.V2f( 10 ) ) ) - self.assertEqual( p.getValue(), IECore.V2fData( IECore.V2f( 10 ) ) ) + self.assertEqual( p.defaultValue, IECore.V2fData( imath.V2f( 10 ) ) ) + self.assertEqual( p.getValue(), IECore.V2fData( imath.V2f( 10 ) ) ) self.assertEqual (p.userData(), IECore.CompoundObject() ) def testUserData( self ): @@ -400,7 +401,7 @@ def testUserData( self ): compound["first"] = IECore.IntData() compound["second"] = IECore.QuatfData() compound["third"] = IECore.StringData("test") - p = IECore.Box3dParameter( "name", "description", IECore.Box3d(), userData = compound ) + p = IECore.Box3dParameter( "name", "description", imath.Box3d(), userData = compound ) self.assertEqual( p.userData(), compound ) self.assert_(not p.userData().isSame(compound) ) data = p.userData() @@ -412,68 +413,68 @@ def testPresets( self ) : p = IECore.V3fParameter( name = "n", description = "d", - defaultValue = IECore.V3f( 2 ), + defaultValue = imath.V3f( 2 ), presets = ( - ( "one", IECore.V3f( 1 ) ), - ( "two", IECore.V3f( 2 ) ), - ( "three", IECore.V3f( 3 ) ), + ( "one", imath.V3f( 1 ) ), + ( "two", imath.V3f( 2 ) ), + ( "three", imath.V3f( 3 ) ), ), presetsOnly = True, ) pr = p.getPresets() self.assertEqual( len( pr ), 3 ) - self.assertEqual( pr["one"], IECore.V3fData( IECore.V3f( 1 ) ) ) - self.assertEqual( pr["two"], IECore.V3fData( IECore.V3f( 2 ) ) ) - self.assertEqual( pr["three"], IECore.V3fData( IECore.V3f( 3 ) ) ) + self.assertEqual( pr["one"], IECore.V3fData( imath.V3f( 1 ) ) ) + self.assertEqual( pr["two"], IECore.V3fData( imath.V3f( 2 ) ) ) + self.assertEqual( pr["three"], IECore.V3fData( imath.V3f( 3 ) ) ) p.setValue( "one" ) - self.assertEqual( p.getValue(), IECore.V3fData( IECore.V3f( 1 ) ) ) + self.assertEqual( p.getValue(), IECore.V3fData( imath.V3f( 1 ) ) ) # overriding presets p.setPresets( [ - ( "four", IECore.V3fData( IECore.V3f(4) ) ), - ( "one", IECore.V3fData( IECore.V3f(1) ) ), + ( "four", IECore.V3fData( imath.V3f(4) ) ), + ( "one", IECore.V3fData( imath.V3f(1) ) ), ] ) pr = p.getPresets() self.assertEqual( len( pr ), 2 ) - self.assertEqual( pr["four"], IECore.V3fData( IECore.V3f(4) ) ) - self.assertEqual( pr["one"], IECore.V3fData( IECore.V3f(1) ) ) + self.assertEqual( pr["four"], IECore.V3fData( imath.V3f(4) ) ) + self.assertEqual( pr["one"], IECore.V3fData( imath.V3f(1) ) ) self.assertEqual( p.presetNames(), ("four", "one") ) p.setValue("four") - self.assertEqual( p.getValue(), IECore.V3fData(IECore.V3f(4)) ) + self.assertEqual( p.getValue(), IECore.V3fData(imath.V3f(4)) ) def testPresetsOnly( self ) : p = IECore.V3fParameter( name = "n", description = "d", - defaultValue = IECore.V3f( 2 ), + defaultValue = imath.V3f( 2 ), presets = ( - ( "one", IECore.V3f( 1 ) ), - ( "two", IECore.V3f( 2 ) ), - ( "three", IECore.V3f( 3 ) ), + ( "one", imath.V3f( 1 ) ), + ( "two", imath.V3f( 2 ) ), + ( "three", imath.V3f( 3 ) ), ), presetsOnly = True, ) - self.assertRaises( RuntimeError, p.setValidatedValue, IECore.V3fData( IECore.V3f( 20 ) ) ) + self.assertRaises( RuntimeError, p.setValidatedValue, IECore.V3fData( imath.V3f( 20 ) ) ) p = IECore.V3fParameter( name = "n", description = "d", - defaultValue = IECore.V3f( 2 ), + defaultValue = imath.V3f( 2 ), presets = ( - ( "one", IECore.V3f( 1 ) ), - ( "two", IECore.V3f( 2 ) ), - ( "three", IECore.V3f( 3 ) ), + ( "one", imath.V3f( 1 ) ), + ( "two", imath.V3f( 2 ) ), + ( "three", imath.V3f( 3 ) ), ), presetsOnly = False, ) - p.setValue( IECore.V3fData( IECore.V3f( 20 ) ) ) + p.setValue( IECore.V3fData( imath.V3f( 20 ) ) ) def testTypedValueFns( self ) : @@ -485,26 +486,26 @@ def testTypedValueFns( self ) : self.assertEqual( p.typedDefaultValue, "10" ) self.assertRaises( AttributeError, setattr, p, "typedDefaultValue", "20" ) - p = IECore.V3fParameter( name="n", description="d", defaultValue = IECore.V3f( 1, 2, 3 ) ) - self.assertEqual( p.getTypedValue(), IECore.V3f( 1, 2, 3 ) ) - p.setTypedValue( IECore.V3f( 12, 13, 14 ) ) - self.assertEqual( p.getTypedValue(), IECore.V3f( 12, 13, 14 ) ) - self.assertEqual( p.getValue(), IECore.V3fData( IECore.V3f( 12, 13, 14 ) ) ) + p = IECore.V3fParameter( name="n", description="d", defaultValue = imath.V3f( 1, 2, 3 ) ) + self.assertEqual( p.getTypedValue(), imath.V3f( 1, 2, 3 ) ) + p.setTypedValue( imath.V3f( 12, 13, 14 ) ) + self.assertEqual( p.getTypedValue(), imath.V3f( 12, 13, 14 ) ) + self.assertEqual( p.getValue(), IECore.V3fData( imath.V3f( 12, 13, 14 ) ) ) - self.assertEqual( p.typedDefaultValue, IECore.V3f( 1, 2, 3 ) ) - self.assertRaises( AttributeError, setattr, p, "typedDefaultValue", IECore.V3f( 4, 5, 6 ) ) + self.assertEqual( p.typedDefaultValue, imath.V3f( 1, 2, 3 ) ) + self.assertRaises( AttributeError, setattr, p, "typedDefaultValue", imath.V3f( 4, 5, 6 ) ) def testSmartSetValue( self ): """Test python overwriting: smartSetValue()""" - p = IECore.V2fParameter( "p", "description", IECore.V2f( 10 ) ) - q = IECore.V2fParameter( "q", "description", IECore.V2f( 2 ) ) - self.assert_( p.getValue() == IECore.V2fData( IECore.V2f( 10 ) ) ) + p = IECore.V2fParameter( "p", "description", imath.V2f( 10 ) ) + q = IECore.V2fParameter( "q", "description", imath.V2f( 2 ) ) + self.assert_( p.getValue() == IECore.V2fData( imath.V2f( 10 ) ) ) p.smartSetValue( q.getValue() ) - self.assert_( p.getValue() == IECore.V2fData( IECore.V2f( 2 ) ) ) - p.smartSetValue( IECore.V2f( 3 ) ) - self.assert_( p.getValue() == IECore.V2fData( IECore.V2f( 3 ) ) ) - p.smartSetValue( IECore.V2fData( IECore.V2f( 4 ) ) ) - self.assert_( p.getValue() == IECore.V2fData( IECore.V2f( 4 ) ) ) + self.assert_( p.getValue() == IECore.V2fData( imath.V2f( 2 ) ) ) + p.smartSetValue( imath.V2f( 3 ) ) + self.assert_( p.getValue() == IECore.V2fData( imath.V2f( 3 ) ) ) + p.smartSetValue( IECore.V2fData( imath.V2f( 4 ) ) ) + self.assert_( p.getValue() == IECore.V2fData( imath.V2f( 4 ) ) ) def testOrderedPresets( self ) : @@ -526,39 +527,39 @@ def testOrderedPresets( self ) : def testInterpretation( self ) : - p = IECore.V3fParameter( name="n", description="d", defaultValue = IECore.V3f( 1, 2, 3 ) ) - self.assertEqual( p.defaultValue, IECore.V3fData( IECore.V3f( 1, 2, 3 ) ) ) + p = IECore.V3fParameter( name="n", description="d", defaultValue = imath.V3f( 1, 2, 3 ) ) + self.assertEqual( p.defaultValue, IECore.V3fData( imath.V3f( 1, 2, 3 ) ) ) self.assertEqual( p.defaultValue.getInterpretation(), IECore.GeometricData.Interpretation.None ) - self.assertEqual( p.getValue(), IECore.V3fData( IECore.V3f( 1, 2, 3 ) ) ) + self.assertEqual( p.getValue(), IECore.V3fData( imath.V3f( 1, 2, 3 ) ) ) self.assertEqual( p.getValue().getInterpretation(), IECore.GeometricData.Interpretation.None ) - value = IECore.V3fData( IECore.V3f( 12, 13, 14 ) ) + value = IECore.V3fData( imath.V3f( 12, 13, 14 ) ) value.setInterpretation( IECore.GeometricData.Interpretation.Vector ) p.setValue( value ) - self.assertNotEqual( p.getValue(), IECore.V3fData( IECore.V3f( 12, 13, 14 ) ) ) + self.assertNotEqual( p.getValue(), IECore.V3fData( imath.V3f( 12, 13, 14 ) ) ) self.assertEqual( p.getValue(), value ) self.assertEqual( p.getValue().getInterpretation(), IECore.GeometricData.Interpretation.Vector ) - dv = IECore.V3fData( IECore.V3f( 1, 2, 3 ), IECore.GeometricData.Interpretation.Normal ) + dv = IECore.V3fData( imath.V3f( 1, 2, 3 ), IECore.GeometricData.Interpretation.Normal ) p = IECore.V3fParameter( name="n", description="d", defaultValue = dv ) - self.assertNotEqual( p.defaultValue, IECore.V3fData( IECore.V3f( 1, 2, 3 ) ) ) + self.assertNotEqual( p.defaultValue, IECore.V3fData( imath.V3f( 1, 2, 3 ) ) ) self.assertEqual( p.defaultValue, dv ) self.assertEqual( p.defaultValue.getInterpretation(), IECore.GeometricData.Interpretation.Normal ) - self.assertNotEqual( p.getValue(), IECore.V3fData( IECore.V3f( 1, 2, 3 ) ) ) + self.assertNotEqual( p.getValue(), IECore.V3fData( imath.V3f( 1, 2, 3 ) ) ) self.assertEqual( p.getValue(), dv ) self.assertEqual( p.getValue().getInterpretation(), IECore.GeometricData.Interpretation.Normal ) - dv = IECore.V3fVectorData( [ IECore.V3f( 1, 2, 3 ) ], IECore.GeometricData.Interpretation.Normal ) + dv = IECore.V3fVectorData( [ imath.V3f( 1, 2, 3 ) ], IECore.GeometricData.Interpretation.Normal ) p = IECore.V3fVectorParameter( name="n", description="d", defaultValue = dv ) - self.assertNotEqual( p.defaultValue, IECore.V3fVectorData( [ IECore.V3f( 1, 2, 3 ) ] ) ) + self.assertNotEqual( p.defaultValue, IECore.V3fVectorData( [ imath.V3f( 1, 2, 3 ) ] ) ) self.assertEqual( p.defaultValue, dv ) self.assertEqual( p.defaultValue.getInterpretation(), IECore.GeometricData.Interpretation.Normal ) - self.assertNotEqual( p.getValue(), IECore.V3fVectorData( [ IECore.V3f( 1, 2, 3 ) ] ) ) + self.assertNotEqual( p.getValue(), IECore.V3fVectorData( [ imath.V3f( 1, 2, 3 ) ] ) ) self.assertEqual( p.getValue(), dv ) self.assertEqual( p.getValue().getInterpretation(), IECore.GeometricData.Interpretation.Normal ) - p.setValue( IECore.V3fVectorData( [ IECore.V3f( 12, 13, 14 ) ] ) ) - self.assertEqual( p.getValue(), IECore.V3fVectorData( [ IECore.V3f( 12, 13, 14 ) ] ) ) + p.setValue( IECore.V3fVectorData( [ imath.V3f( 12, 13, 14 ) ] ) ) + self.assertEqual( p.getValue(), IECore.V3fVectorData( [ imath.V3f( 12, 13, 14 ) ] ) ) self.assertEqual( p.getValue().getInterpretation(), IECore.GeometricData.Interpretation.None ) class TestValidatedStringParameter( unittest.TestCase ) : @@ -745,10 +746,10 @@ def testLazyValidation( self ) : self.assertRaises( RuntimeError, i.validate ) self.assertRaises( RuntimeError, i.getValidatedValue ) - i = IECore.V3fParameter( name = "n", description = "d", defaultValue = IECore.V3f( 10 ) ) - i.validate( IECore.V3fData( IECore.V3f( 10 ) ) ) + i = IECore.V3fParameter( name = "n", description = "d", defaultValue = imath.V3f( 10 ) ) + i.validate( IECore.V3fData( imath.V3f( 10 ) ) ) self.assertRaises( RuntimeError, i.validate, IECore.FloatData( 20 ) ) - i.setValue( IECore.V3fData( IECore.V3f( 20 ) ) ) + i.setValue( IECore.V3fData( imath.V3f( 20 ) ) ) i.validate() i.setValue( IECore.FloatData( 10 ) ) self.assertRaises( RuntimeError, i.validate ) @@ -796,13 +797,13 @@ def testUserData( self ) : def testErrorMessage( self ) : p = IECore.ObjectParameter( name = "name", description = "description", defaultValue = IECore.FloatData( 1 ), types = [IECore.TypeId.FloatData] ) - self.assertEqual( p.valueValid( IECore.V3fData( IECore.V3f( 1 ) ) )[1], "Object is not of type FloatData" ) + self.assertEqual( p.valueValid( IECore.V3fData( imath.V3f( 1 ) ) )[1], "Object is not of type FloatData" ) p = IECore.ObjectParameter( name = "name", description = "description", defaultValue = IECore.FloatData( 1 ), types = [IECore.TypeId.FloatData, IECore.TypeId.IntData] ) - self.assertEqual( p.valueValid( IECore.V3fData( IECore.V3f( 1 ) ) )[1], "Object is not of type FloatData or IntData" ) + self.assertEqual( p.valueValid( IECore.V3fData( imath.V3f( 1 ) ) )[1], "Object is not of type FloatData or IntData" ) p = IECore.ObjectParameter( name = "name", description = "description", defaultValue = IECore.FloatData( 1 ), types = [IECore.TypeId.FloatData, IECore.TypeId.DoubleData, IECore.TypeId.IntData] ) - self.assertEqual( p.valueValid( IECore.V3fData( IECore.V3f( 1 ) ) )[1], "Object is not of type FloatData, DoubleData or IntData" ) + self.assertEqual( p.valueValid( IECore.V3fData( imath.V3f( 1 ) ) )[1], "Object is not of type FloatData, DoubleData or IntData" ) def testOrderedPresets( self ) : @@ -826,17 +827,17 @@ def testOrderedPresets( self ) : # overriding presets p.setPresets( [ - ( "four", IECore.V3fData( IECore.V3f(4) ) ), - ( "one", IECore.V3fData( IECore.V3f(1) ) ), + ( "four", IECore.V3fData( imath.V3f(4) ) ), + ( "one", IECore.V3fData( imath.V3f(1) ) ), ] ) pr = p.getPresets() self.assertEqual( len( pr ), 2 ) - self.assertEqual( pr["four"], IECore.V3fData( IECore.V3f(4) ) ) - self.assertEqual( pr["one"], IECore.V3fData( IECore.V3f(1) ) ) + self.assertEqual( pr["four"], IECore.V3fData( imath.V3f(4) ) ) + self.assertEqual( pr["one"], IECore.V3fData( imath.V3f(1) ) ) self.assertEqual( p.presetNames(), ("four", "one") ) p.setValue("four") - self.assertEqual( p.getValue(), IECore.V3fData(IECore.V3f(4)) ) + self.assertEqual( p.getValue(), IECore.V3fData(imath.V3f(4)) ) class TestTypedObjectParameter( unittest.TestCase ) : @@ -988,16 +989,16 @@ def test( self ) : self.assertEqual( p.description, "d" ) self.assertEqual( p.valueValid()[0], True ) - self.failUnless( isinstance( p.getTypedValue().translate, IECore.V3f ) ) - self.assertEqual( p.getTypedValue().translate, IECore.V3f( 0,0,0 ) ) - self.assertEqual( p.getTypedValue().rotate, IECore.Eulerf( 0,0,0 ) ) - self.assertEqual( p.getTypedValue().rotationOrientation, IECore.Quatf( 1,0,0,0 ) ) - self.assertEqual( p.getTypedValue().scale, IECore.V3f( 1,1,1 ) ) - self.assertEqual( p.getTypedValue().shear, IECore.V3f( 0,0,0 ) ) - self.assertEqual( p.getTypedValue().rotatePivot, IECore.V3f( 0,0,0 ) ) - self.assertEqual( p.getTypedValue().rotatePivotTranslation, IECore.V3f( 0,0,0 ) ) - self.assertEqual( p.getTypedValue().scalePivot, IECore.V3f( 0,0,0 ) ) - self.assertEqual( p.getTypedValue().scalePivotTranslation, IECore.V3f( 0,0,0 ) ) + self.failUnless( isinstance( p.getTypedValue().translate, imath.V3f ) ) + self.assertEqual( p.getTypedValue().translate, imath.V3f( 0,0,0 ) ) + self.assertEqual( p.getTypedValue().rotate, imath.Eulerf( 0,0,0 ) ) + self.assertEqual( p.getTypedValue().rotationOrientation, imath.Quatf( 1,0,0,0 ) ) + self.assertEqual( p.getTypedValue().scale, imath.V3f( 1,1,1 ) ) + self.assertEqual( p.getTypedValue().shear, imath.V3f( 0,0,0 ) ) + self.assertEqual( p.getTypedValue().rotatePivot, imath.V3f( 0,0,0 ) ) + self.assertEqual( p.getTypedValue().rotatePivotTranslation, imath.V3f( 0,0,0 ) ) + self.assertEqual( p.getTypedValue().scalePivot, imath.V3f( 0,0,0 ) ) + self.assertEqual( p.getTypedValue().scalePivotTranslation, imath.V3f( 0,0,0 ) ) tm = IECore.TransformationMatrixdData() p = IECore.TransformationMatrixdParameter( @@ -1011,16 +1012,16 @@ def test( self ) : self.assertEqual( p.description, "d" ) self.assertEqual( p.valueValid()[0], True ) - self.failUnless( isinstance( p.getTypedValue().translate, IECore.V3d ) ) - self.assertEqual( p.getTypedValue().translate, IECore.V3d( 0,0,0 ) ) - self.assertEqual( p.getTypedValue().rotate, IECore.Eulerd( 0,0,0 ) ) - self.assertEqual( p.getTypedValue().rotationOrientation, IECore.Quatd( 1,0,0,0 ) ) - self.assertEqual( p.getTypedValue().scale, IECore.V3d( 1,1,1 ) ) - self.assertEqual( p.getTypedValue().shear, IECore.V3d( 0,0,0 ) ) - self.assertEqual( p.getTypedValue().rotatePivot, IECore.V3d( 0,0,0 ) ) - self.assertEqual( p.getTypedValue().rotatePivotTranslation, IECore.V3d( 0,0,0 ) ) - self.assertEqual( p.getTypedValue().scalePivot, IECore.V3d( 0,0,0 ) ) - self.assertEqual( p.getTypedValue().scalePivotTranslation, IECore.V3d( 0,0,0 ) ) + self.failUnless( isinstance( p.getTypedValue().translate, imath.V3d ) ) + self.assertEqual( p.getTypedValue().translate, imath.V3d( 0,0,0 ) ) + self.assertEqual( p.getTypedValue().rotate, imath.Eulerd( 0,0,0 ) ) + self.assertEqual( p.getTypedValue().rotationOrientation, imath.Quatd( 1,0,0,0 ) ) + self.assertEqual( p.getTypedValue().scale, imath.V3d( 1,1,1 ) ) + self.assertEqual( p.getTypedValue().shear, imath.V3d( 0,0,0 ) ) + self.assertEqual( p.getTypedValue().rotatePivot, imath.V3d( 0,0,0 ) ) + self.assertEqual( p.getTypedValue().rotatePivotTranslation, imath.V3d( 0,0,0 ) ) + self.assertEqual( p.getTypedValue().scalePivot, imath.V3d( 0,0,0 ) ) + self.assertEqual( p.getTypedValue().scalePivotTranslation, imath.V3d( 0,0,0 ) ) class TestPathVectorParameter( unittest.TestCase ) : diff --git a/test/IECore/PerlinNoise.py b/test/IECore/PerlinNoise.py index f7c349f974..496b0becfe 100644 --- a/test/IECore/PerlinNoise.py +++ b/test/IECore/PerlinNoise.py @@ -34,6 +34,7 @@ import os import unittest +import imath import IECore import random @@ -86,7 +87,7 @@ def testV2ff( self ) : for i in range( 0, height ) : for j in range( 0, width ) : - f = 0.5 + n.noise( IECore.V2f( i/50.0, j/50.0 ) ) + f = 0.5 + n.noise( imath.V2f( i/50.0, j/50.0 ) ) self.assertAlmostEqual( f, expected[i*height + j], 4 ) def testV3ff( self ) : @@ -162,7 +163,7 @@ def testV3ff( self ) : for frame in range( 0, 5 ) : for i in range( 0, height ) : for j in range( 0, width ) : - f = 0.5 + n.noise( IECore.V3f( i/50.0, j/50.0, frame/10.0 ) ) + f = 0.5 + n.noise( imath.V3f( i/50.0, j/50.0, frame/10.0 ) ) self.assertAlmostEqual( f, expected[frame][i*height + j], 4 ) def testV2fColor3f( self ) : @@ -213,7 +214,7 @@ def testV2fColor3f( self ) : for i in range( 0, height ) : for j in range( 0, width ) : - c = n.noise( IECore.V2f( i/50.0, j/50.0 ) ) + c = n.noise( imath.V2f( i/50.0, j/50.0 ) ) self.assertAlmostEqual( c.r + 0.5, rExpected[i*height + j], 4 ) self.assertAlmostEqual( c.g + 0.5, gExpected[i*height + j], 4 ) self.assertAlmostEqual( c.b + 0.5, bExpected[i*height + j], 4 ) @@ -357,7 +358,7 @@ def testRepeatability( self ) : for i in range( 0, height ) : for j in range( 0, width ) : - self.assertAlmostEqual( n.noise( IECore.V2f( i/50.0, j/50.0 ) ), n2.noise( IECore.V2f( i/50.0, j/50.0 ) ), 10 ) + self.assertAlmostEqual( n.noise( imath.V2f( i/50.0, j/50.0 ) ), n2.noise( imath.V2f( i/50.0, j/50.0 ) ), 10 ) def testFilterWidth( self ) : @@ -366,7 +367,7 @@ def testFilterWidth( self ) : for i in range( 1, 50 ) : for j in range( 1, 50 ) : - p = IECore.V2f( i/50.0, j/50.0 ) + p = imath.V2f( i/50.0, j/50.0 ) self.failUnless( n.noise( p ) != 0 ) self.failUnless( n.noise( p, 0.5 ) != 0 ) self.failUnless( n.noise( p, 0.6 ) == 0 ) diff --git a/test/IECore/PointDistributionTest.py b/test/IECore/PointDistributionTest.py index 1936ac87e7..d9318bdf91 100644 --- a/test/IECore/PointDistributionTest.py +++ b/test/IECore/PointDistributionTest.py @@ -35,6 +35,7 @@ import os import unittest import math +import imath import IECore @@ -44,7 +45,7 @@ def testNoFunctors( self ) : pd = IECore.PointDistribution.defaultInstance() - bound = IECore.Box2f( IECore.V2f( 0.25 ), IECore.V2f( 0.75 ) ) + bound = imath.Box2f( imath.V2f( 0.25 ), imath.V2f( 0.75 ) ) points = pd( bound, 20000, None ) self.assert_( points.isInstanceOf( IECore.V2fVectorData.staticTypeId() ) ) @@ -56,11 +57,11 @@ def testDensityOnly( self ) : pd = IECore.PointDistribution.defaultInstance() - bound = IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) + bound = imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) def density( p ) : - if (p - IECore.V2f( 0.5 )).length() < 0.5 : + if (p - imath.V2f( 0.5 )).length() < 0.5 : return 1 else : return 0 @@ -71,13 +72,13 @@ def density( p ) : self.assert_( abs( len( points ) - math.pi * .5 * .5 * 20000 ) < 50 ) for p in points : self.assert_( bound.intersects( p ) ) - self.assert_( (p - IECore.V2f( 0.5 )).length() < 0.5 ) + self.assert_( (p - imath.V2f( 0.5 )).length() < 0.5 ) def testEmitterOnly( self ) : pd = IECore.PointDistribution.defaultInstance() - bound = IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) + bound = imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) points = [] def emit( p ) : @@ -91,11 +92,11 @@ def testEmitterAndDensity( self ) : pd = IECore.PointDistribution.defaultInstance() - bound = IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) + bound = imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) def density( p ) : - if (p - IECore.V2f( 0.5 )).length() < 0.5 : + if (p - imath.V2f( 0.5 )).length() < 0.5 : return 1 else : return 0 @@ -110,17 +111,17 @@ def emit( p ) : self.assert_( abs( len( points ) - math.pi * .5 * .5 * 20000 ) < 50 ) for p in points : self.assert_( bound.intersects( p ) ) - self.assert_( (p - IECore.V2f( 0.5 )).length() < 0.5 ) + self.assert_( (p - imath.V2f( 0.5 )).length() < 0.5 ) def testDistanceBetweenPoints( self ) : pd = IECore.PointDistribution.defaultInstance() - bound = IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) + bound = imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) def density( p ) : - if (p - IECore.V2f( 0.5 )).length() < 0.5 : + if (p - imath.V2f( 0.5 )).length() < 0.5 : return 1 else : return 0 diff --git a/test/IECore/PolygonAlgoTest.py b/test/IECore/PolygonAlgoTest.py index d3367aa744..ed66e5f8a1 100644 --- a/test/IECore/PolygonAlgoTest.py +++ b/test/IECore/PolygonAlgoTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import math @@ -41,60 +42,60 @@ class PolygonAlgoTest( unittest.TestCase ) : def testNormal( self ) : p = IECore.V3fVectorData( [ - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 1, 0, 0 ), - IECore.V3f( 1, 1, 0 ), - IECore.V3f( 0, 1, 0 ) + imath.V3f( 0, 0, 0 ), + imath.V3f( 1, 0, 0 ), + imath.V3f( 1, 1, 0 ), + imath.V3f( 0, 1, 0 ) ] ) - self.assertEqual( IECore.polygonNormal( p ), IECore.V3f( 0, 0, 1 ) ) + self.assertEqual( IECore.polygonNormal( p ), imath.V3f( 0, 0, 1 ) ) p = IECore.V3fVectorData( [ - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 0, 1, 0 ), - IECore.V3f( 1, 1, 0 ), - IECore.V3f( 1, 0, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 0, 1, 0 ), + imath.V3f( 1, 1, 0 ), + imath.V3f( 1, 0, 0 ), ] ) - self.assertEqual( IECore.polygonNormal( p ), IECore.V3f( 0, 0, -1 ) ) + self.assertEqual( IECore.polygonNormal( p ), imath.V3f( 0, 0, -1 ) ) def testConcaveNormal( self ) : p = IECore.V3fVectorData( [ - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 1, -1, 0 ), - IECore.V3f( 0.2, 0, 0 ), - IECore.V3f( 1, 1, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 1, -1, 0 ), + imath.V3f( 0.2, 0, 0 ), + imath.V3f( 1, 1, 0 ), ] ) - self.assertEqual( IECore.polygonNormal( p ), IECore.V3f( 0, 0, 1 ) ) + self.assertEqual( IECore.polygonNormal( p ), imath.V3f( 0, 0, 1 ) ) p = IECore.V3fVectorData( [ - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 1, 1, 0 ), - IECore.V3f( 0.2, 0, 0 ), - IECore.V3f( 1, -1, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 1, 1, 0 ), + imath.V3f( 0.2, 0, 0 ), + imath.V3f( 1, -1, 0 ), ] ) - self.assertEqual( IECore.polygonNormal( p ), IECore.V3f( 0, 0, -1 ) ) + self.assertEqual( IECore.polygonNormal( p ), imath.V3f( 0, 0, -1 ) ) def testWinding2D( self ) : p = IECore.V2fVectorData( [ - IECore.V2f( 0, 0 ), - IECore.V2f( 1, 0 ), - IECore.V2f( 1, 1 ), - IECore.V2f( 0, 1 ), + imath.V2f( 0, 0 ), + imath.V2f( 1, 0 ), + imath.V2f( 1, 1 ), + imath.V2f( 0, 1 ), ] ) self.assertEqual( IECore.polygonWinding( p ), IECore.Winding.CounterClockwise ) self.assertNotEqual( IECore.polygonWinding( p ), IECore.Winding.Clockwise ) p = IECore.V2fVectorData( [ - IECore.V2f( 0, 0 ), - IECore.V2f( 0, 1 ), - IECore.V2f( 1, 1 ), - IECore.V2f( 1, 0 ), + imath.V2f( 0, 0 ), + imath.V2f( 0, 1 ), + imath.V2f( 1, 1 ), + imath.V2f( 1, 0 ), ] ) self.assertNotEqual( IECore.polygonWinding( p ), IECore.Winding.CounterClockwise ) @@ -103,46 +104,50 @@ def testWinding2D( self ) : def testWinding3D( self ) : p = IECore.V3fVectorData( [ - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 1, 0, 0 ), - IECore.V3f( 1, 1, 0 ), - IECore.V3f( 0, 1, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 1, 0, 0 ), + imath.V3f( 1, 1, 0 ), + imath.V3f( 0, 1, 0 ), ] ) - self.assertEqual( IECore.polygonWinding( p, IECore.V3f( 0, 0, -1 ) ), IECore.Winding.CounterClockwise ) - self.assertNotEqual( IECore.polygonWinding( p, IECore.V3f( 0, 0, -1 ) ), IECore.Winding.Clockwise ) - self.assertEqual( IECore.polygonWinding( p, IECore.V3f( 0, 0, 1 ) ), IECore.Winding.Clockwise ) - self.assertNotEqual( IECore.polygonWinding( p, IECore.V3f( 0, 0, 1 ) ), IECore.Winding.CounterClockwise ) + self.assertEqual( IECore.polygonWinding( p, imath.V3f( 0, 0, -1 ) ), IECore.Winding.CounterClockwise ) + self.assertNotEqual( IECore.polygonWinding( p, imath.V3f( 0, 0, -1 ) ), IECore.Winding.Clockwise ) + self.assertEqual( IECore.polygonWinding( p, imath.V3f( 0, 0, 1 ) ), IECore.Winding.Clockwise ) + self.assertNotEqual( IECore.polygonWinding( p, imath.V3f( 0, 0, 1 ) ), IECore.Winding.CounterClockwise ) p = IECore.V3fVectorData( [ - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 0, 1, 0 ), - IECore.V3f( 1, 1, 0 ), - IECore.V3f( 1, 0, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 0, 1, 0 ), + imath.V3f( 1, 1, 0 ), + imath.V3f( 1, 0, 0 ), ] ) - self.assertNotEqual( IECore.polygonWinding( p, IECore.V3f( 0, 0, -1 ) ), IECore.Winding.CounterClockwise ) - self.assertEqual( IECore.polygonWinding( p, IECore.V3f( 0, 0, -1 ) ), IECore.Winding.Clockwise ) - self.assertEqual( IECore.polygonWinding( p, IECore.V3f( 0, 0, 1 ) ), IECore.Winding.CounterClockwise ) - self.assertNotEqual( IECore.polygonWinding( p, IECore.V3f( 0, 0, 1 ) ), IECore.Winding.Clockwise ) + self.assertNotEqual( IECore.polygonWinding( p, imath.V3f( 0, 0, -1 ) ), IECore.Winding.CounterClockwise ) + self.assertEqual( IECore.polygonWinding( p, imath.V3f( 0, 0, -1 ) ), IECore.Winding.Clockwise ) + self.assertEqual( IECore.polygonWinding( p, imath.V3f( 0, 0, 1 ) ), IECore.Winding.CounterClockwise ) + self.assertNotEqual( IECore.polygonWinding( p, imath.V3f( 0, 0, 1 ) ), IECore.Winding.Clockwise ) def testBound( self ) : p = IECore.V3fVectorData( [ - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 1, 0, 0 ), - IECore.V3f( 1, 1, 0 ), - IECore.V3f( 0, 1, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 1, 0, 0 ), + imath.V3f( 1, 1, 0 ), + imath.V3f( 0, 1, 0 ), ] ) - self.assertEqual( IECore.polygonBound( p ), IECore.Box3f( IECore.V3f( 0 ), IECore.V3f( 1, 1, 0 ) ) ) + self.assertEqual( IECore.polygonBound( p ), imath.Box3f( imath.V3f( 0 ), imath.V3f( 1, 1, 0 ) ) ) def testArea3D( self ) : - r = IECore.Rand32() + r = imath.Rand32() for i in range( 0, 1000 ) : - p = IECore.V3fVectorData( [ r.nextV3f(), r.nextV3f(), r.nextV3f() ] ) + p = IECore.V3fVectorData( [ + imath.V3f( r.nextf(), r.nextf(), r.nextf() ), + imath.V3f( r.nextf(), r.nextf(), r.nextf() ), + imath.V3f( r.nextf(), r.nextf(), r.nextf() ) + ] ) self.assertAlmostEqual( IECore.polygonArea( p ), IECore.triangleArea( p[0], p[1], p[2] ), 4 ) if __name__ == "__main__": diff --git a/test/IECore/RandomTest.py b/test/IECore/RandomAlgoTest.py similarity index 63% rename from test/IECore/RandomTest.py rename to test/IECore/RandomAlgoTest.py index 3c319ab9ca..c686665bbb 100644 --- a/test/IECore/RandomTest.py +++ b/test/IECore/RandomAlgoTest.py @@ -1,6 +1,6 @@ ########################################################################## # -# Copyright (c) 2008-2010, Image Engine Design Inc. All rights reserved. +# Copyright (c) 2017, Image Engine Design Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -33,46 +33,33 @@ ########################################################################## import unittest +import imath + import IECore -class RandomTest( unittest.TestCase ) : +class RandomAlgoTest( unittest.TestCase ) : def testCosineHemisphere( self ) : - r = IECore.Rand32() - - v = r.cosineHemispherefVector( 1000 ) + r = imath.Rand32() - for i in range( 0, v.size() ) : + for i in range( 0, 1000 ) : - self.assert_( v[i].z >= 0 ) - self.assertAlmostEqual( v[i].length(), 1, 6 ) + v = IECore.RandomAlgo.cosineHemisphereRandf( r ) + self.assertTrue( v.z >= 0 ) + self.assertAlmostEqual( v.length(), 1, 6 ) def testBarycentric( self ) : - r = IECore.Rand32() - - f = r.barycentricf() - self.assert_( ( f[0] + f[1] + f[2] ) == 1.0 ) - - d = r.barycentricd() - self.assert_( ( d[0] + d[1] + d[2] ) == 1.0 ) - - fvs = r.barycentricfVector( IECore.IntVectorData( [ 1, 2, 3, 4, 5 ] ) ) - for i in range( 0, fvs.size() ) : - self.assert_( ( fvs[i][0] + fvs[i][1] + fvs[i][2] ) == 1.0 ) + r = imath.Rand32() - fv = r.barycentricfVector( 5 ) - for i in range( 0, fv.size() ) : - self.assert_( ( fv[i][0] + fv[i][1] + fv[i][2] ) == 1.0 ) + for i in range( 0, 1000 ) : - dvs = r.barycentricdVector( IECore.IntVectorData( [ 1, 2, 3, 4, 5 ] ) ) - for i in range( 0, dvs.size() ) : - self.assert_( ( dvs[i][0] + dvs[i][1] + dvs[i][2] ) == 1.0 ) + f = IECore.RandomAlgo.barycentricRandf( r ) + self.assertTrue( ( f[0] + f[1] + f[2] ) == 1.0 ) - dv = r.barycentricdVector( 5 ) - for i in range( 0, dv.size() ) : - self.assert_( ( dv[i][0] + dv[i][1] + dv[i][2] ) == 1.0 ) + d = IECore.RandomAlgo.barycentricRandd( r ) + self.assert_( ( d[0] + d[1] + d[2] ) == 1.0 ) if __name__ == "__main__": unittest.main() diff --git a/test/IECore/ImathRootsTest.py b/test/IECore/ReprTest.py similarity index 63% rename from test/IECore/ImathRootsTest.py rename to test/IECore/ReprTest.py index da4656a54a..6423a93ac4 100644 --- a/test/IECore/ImathRootsTest.py +++ b/test/IECore/ReprTest.py @@ -1,6 +1,6 @@ ########################################################################## # -# Copyright (c) 2008, Image Engine Design Inc. All rights reserved. +# Copyright (c) 2017, Image Engine Design Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -32,47 +32,35 @@ # ########################################################################## -"""Unit test for Imath binding""" - -import math import unittest -import random -import IECore - -class ImathRootsTest( unittest.TestCase ) : - - def testLinear( self ) : - - x = IECore.solveLinear( 1, 1 ) - self.assert_( isinstance( x, tuple ) ) - self.assertEqual( len( x ), 1 ) - self.assertEqual( x[0], -1 ) +import imath - x = IECore.solveLinear( 0, 1 ) - self.assert_( isinstance( x, tuple ) ) - self.assertEqual( len( x ), 0 ) - - self.assertRaises( ArithmeticError, IECore.solveLinear, 0, 0 ) - - def testQuadratic( self ) : - - x = IECore.solveQuadratic( 1, 0, -1 ) - self.assert_( isinstance( x, tuple ) ) - self.assertEqual( len( x ), 2 ) - self.assert_( -1 in x ) - self.assert_( 1 in x ) - - self.assertRaises( ArithmeticError, IECore.solveQuadratic, 0, 0, 0 ) +import IECore - def testCubic( self ) : +class ReprTest( unittest.TestCase ) : - x = IECore.solveCubic( 1, 0, 0, -1 ) - self.assert_( isinstance( x, tuple ) ) - self.assertEqual( len( x ), 1 ) - self.assertEqual( x[0], 1 ) + def test( self ) : - self.assertRaises( ArithmeticError, IECore.solveCubic, 0, 0, 0, 0 ) + 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 ) ) ) if __name__ == "__main__": - unittest.main() + unittest.main() diff --git a/test/IECore/SimpleTypedData.py b/test/IECore/SimpleTypedData.py index e07df6f5ed..ca0470fc1a 100644 --- a/test/IECore/SimpleTypedData.py +++ b/test/IECore/SimpleTypedData.py @@ -38,6 +38,7 @@ import math import unittest import random +import imath import IECore @@ -254,14 +255,13 @@ def testUInt64Data(self): def testImathVecTypes(self): types = [ - [IECore.V2fData, IECore.V2f], - [IECore.V3fData, IECore.V3f], - [IECore.V2dData, IECore.V2d], - [IECore.V3dData, IECore.V3d], - [IECore.Color3fData, IECore.Color3f], - [IECore.Color3dData, IECore.Color3d], - [IECore.Color4fData, IECore.Color4f], - [IECore.Color4dData, IECore.Color4d], ] + [IECore.V2fData, imath.V2f], + [IECore.V3fData, imath.V3f], + [IECore.V2dData, imath.V2d], + [IECore.V3dData, imath.V3d], + [IECore.Color3fData, imath.Color3f], + [IECore.Color4fData, imath.Color4f], + ] for t, vt in types : @@ -269,7 +269,7 @@ def testImathVecTypes(self): v = vt( 10 ) self.assertEqual( " ".join( ["10"] * vt.dimensions() ), str( t( v ) ) ) - self.assertEqual( "IECore." + t.__name__ + "( " + "IECore." + vt.__name__ + "( " + ", ".join( ["10"] * vt.dimensions() ) + " ) )", repr( t( v ) ) ) + self.assertEqual( "IECore." + t.__name__ + "( " + "imath." + vt.__name__ + "( " + ", ".join( ["10"] * vt.dimensions() ) + " ) )", repr( t( v ) ) ) self.failUnless( t.hasBase() ) for i in range( 0, 1000 ) : @@ -283,18 +283,18 @@ def testImathVecTypes(self): def testImathBoxTypes(self): types = [ - [IECore.Box2fData, IECore.Box2f, IECore.V2f], - [IECore.Box3fData, IECore.Box3f, IECore.V3f], - [IECore.Box2dData, IECore.Box2d, IECore.V2d], - [IECore.Box3dData, IECore.Box3d, IECore.V3d] ] + [IECore.Box2fData, imath.Box2f, imath.V2f], + [IECore.Box3fData, imath.Box3f, imath.V3f], + [IECore.Box2dData, imath.Box2d, imath.V2d], + [IECore.Box3dData, imath.Box3d, imath.V3d] ] for t, bt, vt in types : v = vt( 1 ) b = bt( v, v ) self.assertEqual( " ".join( ["1"]*vt.dimensions()*2 ), str( t( b ) ) ) - vr = "IECore." + vt.__name__ + "( " + ", ".join( ["1"]*vt.dimensions() ) + " )" - br = "IECore." + bt.__name__ + "( " + vr + ", " + vr + " )" + vr = "imath." + vt.__name__ + "( " + ", ".join( ["1"]*vt.dimensions() ) + " )" + br = "imath." + bt.__name__ + "( " + vr + ", " + vr + " )" self.assertEqual( "IECore." + t.__name__ + "( " + br + " )", repr( t( b ) ) ) self.failUnless( t.hasBase() ) @@ -394,8 +394,8 @@ def testStreaming( self ) : def testLineSegmentData( self ) : for vt, dt in [ - ( IECore.V3f, IECore.LineSegment3fData ), - ( IECore.V3d, IECore.LineSegment3dData ), + ( imath.V3f, IECore.LineSegment3fData ), + ( imath.V3d, IECore.LineSegment3dData ), ] : d = dt() diff --git a/test/IECore/SplineDataTest.py b/test/IECore/SplineDataTest.py index ed98ed7b23..9834072c28 100644 --- a/test/IECore/SplineDataTest.py +++ b/test/IECore/SplineDataTest.py @@ -35,6 +35,7 @@ import os import math import unittest +import imath import IECore class SplineDataTest( unittest.TestCase ) : @@ -89,10 +90,10 @@ def testIO( self ) : def testColorIO( self ) : s = IECore.SplinefColor3f( IECore.CubicBasisf.linear() ) - s[0] = IECore.Color3f( 1 ) - s[1] = IECore.Color3f( 2 ) - s[2] = IECore.Color3f( 3 ) - s[3] = IECore.Color3f( 4 ) + s[0] = imath.Color3f( 1 ) + s[1] = imath.Color3f( 2 ) + s[2] = imath.Color3f( 3 ) + s[3] = imath.Color3f( 4 ) sd = IECore.SplinefColor3fData( s ) @@ -105,10 +106,10 @@ def testColorIO( self ) : def testRepr( self ) : s = IECore.SplinefColor3f( IECore.CubicBasisf.linear() ) - s[0] = IECore.Color3f( 1 ) - s[1] = IECore.Color3f( 2 ) - s[2] = IECore.Color3f( 3 ) - s[3] = IECore.Color3f( 4 ) + s[0] = imath.Color3f( 1 ) + s[1] = imath.Color3f( 2 ) + s[2] = imath.Color3f( 3 ) + s[3] = imath.Color3f( 4 ) sd = IECore.SplinefColor3fData( s ) @@ -119,15 +120,15 @@ def testRepr( self ) : def testHash( self ) : s = IECore.SplinefColor3f( IECore.CubicBasisf.linear() ) - s[0] = IECore.Color3f( 1 ) - s[1] = IECore.Color3f( 2 ) - s[2] = IECore.Color3f( 3 ) - s[3] = IECore.Color3f( 4 ) + s[0] = imath.Color3f( 1 ) + s[1] = imath.Color3f( 2 ) + s[2] = imath.Color3f( 3 ) + s[3] = imath.Color3f( 4 ) s = IECore.SplinefColor3fData( s ) h = s.hash() - s.value[4] = IECore.Color3f( 5 ) + s.value[4] = imath.Color3f( 5 ) self.assertNotEqual( s.hash(), h ) h = s.hash() diff --git a/test/IECore/SplineTest.py b/test/IECore/SplineTest.py index 66220fc143..47faa9dd11 100644 --- a/test/IECore/SplineTest.py +++ b/test/IECore/SplineTest.py @@ -35,6 +35,7 @@ import math import unittest import random +import imath import IECore class SplineTest( unittest.TestCase ) : @@ -171,10 +172,10 @@ def testRepr( self ) : self.assertEqual( s, ss ) s = IECore.SplinefColor3f() - s[0] = IECore.Color3f( 1, 0, 0 ) - s[1] = IECore.Color3f( 0, 1, 0 ) - s[2] = IECore.Color3f( 1, 1, 0 ) - s[10] = IECore.Color3f( 0, 0, 1 ) + s[0] = imath.Color3f( 1, 0, 0 ) + s[1] = imath.Color3f( 0, 1, 0 ) + s[2] = imath.Color3f( 1, 1, 0 ) + s[10] = imath.Color3f( 0, 0, 1 ) ss = eval( repr( s ) ) self.assertEqual( s, ss ) diff --git a/test/IECore/StandardRadialLensModelTest.py b/test/IECore/StandardRadialLensModelTest.py index 5ce1c2d702..2ec5ed5b06 100644 --- a/test/IECore/StandardRadialLensModelTest.py +++ b/test/IECore/StandardRadialLensModelTest.py @@ -1,3 +1,4 @@ +import imath ########################################################################## # # Copyright (c) 2013, Image Engine Design Inc. All rights reserved. @@ -58,12 +59,12 @@ def testStandardRadialLensModel( self ): lens.validate() # Test the full-format distortion. - window = IECore.Box2i( IECore.V2i( 0, 0 ), IECore.V2i( 2047, 1555 ) ) + window = imath.Box2i( imath.V2i( 0, 0 ), imath.V2i( 2047, 1555 ) ) bbox = lens.bounds( IECore.LensModel.Distort, window, 2048, 1556 ) - self.assertEqual( bbox, IECore.Box2i( IECore.V2i( 268, 37 ), IECore.V2i( 2034, 1439 ) ) ) + self.assertEqual( bbox, imath.Box2i( imath.V2i( 268, 37 ), imath.V2i( 2034, 1439 ) ) ) bbox = lens.bounds( IECore.LensModel.Undistort, window, 2048, 1556 ) - self.assertEqual( bbox, IECore.Box2i( IECore.V2i( -1309, -659 ), IECore.V2i( 2243, 2740 ) ) ) + self.assertEqual( bbox, imath.Box2i( imath.V2i( -1309, -659 ), imath.V2i( 2243, 2740 ) ) ) def testStandardRadialLensModelWindowed( self ): @@ -78,12 +79,12 @@ def testStandardRadialLensModelWindowed( self ): lens.validate() # Test windowed distortion. - window = IECore.Box2i( IECore.V2i( 140, 650 ), IECore.V2i( 1697, 1359 ) ) + window = imath.Box2i( imath.V2i( 140, 650 ), imath.V2i( 1697, 1359 ) ) bbox = lens.bounds( IECore.LensModel.Undistort, window, 2048, 1556 ) - self.assertEqual( bbox, IECore.Box2i( IECore.V2i( -635, 650 ), IECore.V2i( 1729, 2044 ) ) ) + self.assertEqual( bbox, imath.Box2i( imath.V2i( -635, 650 ), imath.V2i( 1729, 2044 ) ) ) bbox = lens.bounds( IECore.LensModel.Distort, window, 2048, 1556 ) - self.assertEqual( bbox, IECore.Box2i( IECore.V2i( 351, 640 ), IECore.V2i( 1696, 1298 ) ) ) + self.assertEqual( bbox, imath.Box2i( imath.V2i( 351, 640 ), imath.V2i( 1696, 1298 ) ) ) def testStandardRadialLensModelCreatorFromName( self ): diff --git a/test/IECore/TransformationMatrixData.py b/test/IECore/TransformationMatrixData.py index f4b88a73a9..e82674bee7 100644 --- a/test/IECore/TransformationMatrixData.py +++ b/test/IECore/TransformationMatrixData.py @@ -37,6 +37,7 @@ import os, os.path import math import unittest +import imath import IECore import random @@ -45,24 +46,24 @@ class TransformationMatrixfTest(unittest.TestCase): def testConstructors(self): """Test TransformationMatrixf constructors""" a = IECore.TransformationMatrixf() - self.assertEqual( a.transform, IECore.M44f() ) - a = IECore.TransformationMatrixf( IECore.V3f( 2, 2, 2 ), IECore.Eulerf(), IECore.V3f( 1, 0, 0 ) ) - self.assert_( a.transform.equalWithAbsError( IECore.M44f().scale( IECore.V3f(2,2,2) ) * IECore.M44f().translate( IECore.V3f(1,0,0) ), 0.01) ) + self.assertEqual( a.transform, imath.M44f() ) + a = IECore.TransformationMatrixf( imath.V3f( 2, 2, 2 ), imath.Eulerf(), imath.V3f( 1, 0, 0 ) ) + self.assert_( a.transform.equalWithAbsError( imath.M44f().scale( imath.V3f(2,2,2) ) * imath.M44f().translate( imath.V3f(1,0,0) ), 0.01) ) b = IECore.TransformationMatrixf( a ) self.assertEqual( a.transform, b.transform ) def testAttributes(self): """Test TransformationMatrixf attributes""" a = IECore.TransformationMatrixf() - self.assertEqual( a.scalePivot, IECore.V3f( 0, 0, 0 ) ) - self.assertEqual( a.scale, IECore.V3f( 1, 1, 1 ) ) - self.assertEqual( a.shear, IECore.V3f( 0, 0, 0 ) ) - self.assertEqual( a.scalePivotTranslation, IECore.V3f( 0, 0, 0 ) ) - self.assertEqual( a.rotatePivot, IECore.V3f( 0, 0, 0 ) ) - self.assertEqual( a.rotationOrientation, IECore.Quatf() ) - self.assertEqual( a.rotate, IECore.Eulerf() ) - self.assertEqual( a.rotatePivotTranslation, IECore.V3f( 0, 0, 0 ) ) - self.assertEqual( a.translate, IECore.V3f( 0, 0, 0 ) ) + self.assertEqual( a.scalePivot, imath.V3f( 0, 0, 0 ) ) + self.assertEqual( a.scale, imath.V3f( 1, 1, 1 ) ) + self.assertEqual( a.shear, imath.V3f( 0, 0, 0 ) ) + self.assertEqual( a.scalePivotTranslation, imath.V3f( 0, 0, 0 ) ) + self.assertEqual( a.rotatePivot, imath.V3f( 0, 0, 0 ) ) + self.assertEqual( a.rotationOrientation, imath.Quatf() ) + self.assertEqual( a.rotate, imath.Eulerf() ) + self.assertEqual( a.rotatePivotTranslation, imath.V3f( 0, 0, 0 ) ) + self.assertEqual( a.translate, imath.V3f( 0, 0, 0 ) ) try: a.transform = 1 except: @@ -73,19 +74,19 @@ def testAttributes(self): def testTransform(self): """Test TransformationMatrixf transform""" a = IECore.TransformationMatrixf() - a.scale = IECore.V3f( 2, 2, 2 ) - self.assertEqual( a.transform, IECore.M44f().scale( IECore.V3f( 2, 2, 2 ) ) ) - a.rotate = IECore.Eulerf( 0.2, 0.2, 0.2 ) - self.assert_( a.transform.equalWithAbsError( IECore.M44f().scale( IECore.V3f( 2, 2, 2 ) ) * IECore.Eulerf( 0.2, 0.2, 0.2 ).toMatrix44(), 0.01 ) ) + a.scale = imath.V3f( 2, 2, 2 ) + self.assertEqual( a.transform, imath.M44f().scale( imath.V3f( 2, 2, 2 ) ) ) + a.rotate = imath.Eulerf( 0.2, 0.2, 0.2 ) + self.assert_( a.transform.equalWithAbsError( imath.M44f().scale( imath.V3f( 2, 2, 2 ) ) * imath.Eulerf( 0.2, 0.2, 0.2 ).toMatrix44(), 0.01 ) ) def testComparison(self): """Test TransformationMatrixf comparison""" a = IECore.TransformationMatrixf() b = IECore.TransformationMatrixf() self.assertEqual( a, b ) - b.scalePivot = IECore.V3f( 0.00001, 0, 0 ) + b.scalePivot = imath.V3f( 0.00001, 0, 0 ) self.assertNotEqual( a, b ) - a.scalePivot = IECore.V3f( 0.00001, 0, 0 ) + a.scalePivot = imath.V3f( 0.00001, 0, 0 ) self.assertEqual( a, b ) class TransformationMatrixdTest(unittest.TestCase): @@ -93,24 +94,24 @@ class TransformationMatrixdTest(unittest.TestCase): def testConstructors(self): """Test TransformationMatrixd constructors""" a = IECore.TransformationMatrixd() - self.assertEqual( a.transform, IECore.M44d() ) - a = IECore.TransformationMatrixd( IECore.V3d( 2, 2, 2 ), IECore.Eulerd(), IECore.V3d( 1, 0, 0 ) ) - self.assert_( a.transform.equalWithAbsError( IECore.M44d().scale( IECore.V3d(2,2,2) ) * IECore.M44d().translate( IECore.V3d(1,0,0) ), 0.01 ) ) + self.assertEqual( a.transform, imath.M44d() ) + a = IECore.TransformationMatrixd( imath.V3d( 2, 2, 2 ), imath.Eulerd(), imath.V3d( 1, 0, 0 ) ) + self.assert_( a.transform.equalWithAbsError( imath.M44d().scale( imath.V3d(2,2,2) ) * imath.M44d().translate( imath.V3d(1,0,0) ), 0.01 ) ) b = IECore.TransformationMatrixd( a ) self.assertEqual( a.transform, b.transform ) def testAttributes(self): """Test TransformationMatrixd attributes""" a = IECore.TransformationMatrixd() - self.assertEqual( a.scalePivot, IECore.V3d( 0, 0, 0 ) ) - self.assertEqual( a.scale, IECore.V3d( 1, 1, 1 ) ) - self.assertEqual( a.shear, IECore.V3d( 0, 0, 0 ) ) - self.assertEqual( a.scalePivotTranslation, IECore.V3d( 0, 0, 0 ) ) - self.assertEqual( a.rotatePivot, IECore.V3d( 0, 0, 0 ) ) - self.assertEqual( a.rotationOrientation, IECore.Quatd() ) - self.assertEqual( a.rotate, IECore.Eulerd() ) - self.assertEqual( a.rotatePivotTranslation, IECore.V3d( 0, 0, 0 ) ) - self.assertEqual( a.translate, IECore.V3d( 0, 0, 0 ) ) + self.assertEqual( a.scalePivot, imath.V3d( 0, 0, 0 ) ) + self.assertEqual( a.scale, imath.V3d( 1, 1, 1 ) ) + self.assertEqual( a.shear, imath.V3d( 0, 0, 0 ) ) + self.assertEqual( a.scalePivotTranslation, imath.V3d( 0, 0, 0 ) ) + self.assertEqual( a.rotatePivot, imath.V3d( 0, 0, 0 ) ) + self.assertEqual( a.rotationOrientation, imath.Quatd() ) + self.assertEqual( a.rotate, imath.Eulerd() ) + self.assertEqual( a.rotatePivotTranslation, imath.V3d( 0, 0, 0 ) ) + self.assertEqual( a.translate, imath.V3d( 0, 0, 0 ) ) try: a.transform = 1 except: @@ -121,19 +122,19 @@ def testAttributes(self): def testTransform(self): """Test TransformationMatrixd transform""" a = IECore.TransformationMatrixd() - a.scale = IECore.V3d( 2, 2, 2 ) - self.assertEqual( a.transform, IECore.M44d().scale( IECore.V3d( 2, 2, 2 ) ) ) - a.rotate = IECore.Eulerd( 0.2, 0.2, 0.2 ) - self.assert_( a.transform.equalWithAbsError( IECore.M44d().scale( IECore.V3d( 2, 2, 2 ) ) * IECore.Eulerd( 0.2, 0.2, 0.2 ).toMatrix44(), 0.01 ) ) + a.scale = imath.V3d( 2, 2, 2 ) + self.assertEqual( a.transform, imath.M44d().scale( imath.V3d( 2, 2, 2 ) ) ) + a.rotate = imath.Eulerd( 0.2, 0.2, 0.2 ) + self.assert_( a.transform.equalWithAbsError( imath.M44d().scale( imath.V3d( 2, 2, 2 ) ) * imath.Eulerd( 0.2, 0.2, 0.2 ).toMatrix44(), 0.01 ) ) def testComparison(self): """Test TransformationMatrixd comparison""" a = IECore.TransformationMatrixd() b = IECore.TransformationMatrixd() self.assertEqual( a, b ) - b.scalePivot = IECore.V3d( 0.00001, 0, 0 ) + b.scalePivot = imath.V3d( 0.00001, 0, 0 ) self.assertNotEqual( a, b ) - a.scalePivot = IECore.V3d( 0.00001, 0, 0 ) + a.scalePivot = imath.V3d( 0.00001, 0, 0 ) self.assertEqual( a, b ) class TransformationMatrixDatafTest(unittest.TestCase): @@ -144,21 +145,21 @@ def testConstructors(self): """Test TransformationMatrixfData constructors""" a = IECore.TransformationMatrixfData() self.assertEqual( a.value, IECore.TransformationMatrixf() ) - a = IECore.TransformationMatrixfData( IECore.TransformationMatrixf( IECore.V3f( 2, 2, 2 ), IECore.Eulerf(), IECore.V3f( 1, 0, 0 ) ) ) - self.assertEqual( a.value.scale, IECore.V3f( 2, 2, 2 ) ) + a = IECore.TransformationMatrixfData( IECore.TransformationMatrixf( imath.V3f( 2, 2, 2 ), imath.Eulerf(), imath.V3f( 1, 0, 0 ) ) ) + self.assertEqual( a.value.scale, imath.V3f( 2, 2, 2 ) ) def testCopy(self): """Test TransformationMatrixfData copy""" - a = IECore.TransformationMatrixfData( IECore.TransformationMatrixf( IECore.V3f( 2, 2, 2 ), IECore.Eulerf(), IECore.V3f( 1, 0, 0 ) ) ) - self.assertEqual( a.value.scale, IECore.V3f( 2, 2, 2 ) ) + a = IECore.TransformationMatrixfData( IECore.TransformationMatrixf( imath.V3f( 2, 2, 2 ), imath.Eulerf(), imath.V3f( 1, 0, 0 ) ) ) + self.assertEqual( a.value.scale, imath.V3f( 2, 2, 2 ) ) b = a.copy() a.value = IECore.TransformationMatrixf() - self.assertEqual( b.value.scale, IECore.V3f( 2, 2, 2 ) ) - self.assertEqual( a.value.scale, IECore.V3f( 1, 1, 1 ) ) + self.assertEqual( b.value.scale, imath.V3f( 2, 2, 2 ) ) + self.assertEqual( a.value.scale, imath.V3f( 1, 1, 1 ) ) def testIO(self): """Test TransformationMatrixfData IO""" - a = IECore.TransformationMatrixfData( IECore.TransformationMatrixf( IECore.V3f(2,3,4), IECore.Eulerf(), IECore.V3f(1,2,3) ) ) + a = IECore.TransformationMatrixfData( IECore.TransformationMatrixf( imath.V3f(2,3,4), imath.Eulerf(), imath.V3f(1,2,3) ) ) w = IECore.ObjectWriter( a, self.testFile ) w.write() @@ -169,21 +170,21 @@ def testIO(self): def testInterpolation(self): """Test TranformationMatrixfData interpolation""" a = IECore.TransformationMatrixfData() - b = IECore.TransformationMatrixfData( IECore.TransformationMatrixf( IECore.V3f(2,3,4), IECore.Eulerf(), IECore.V3f(1,2,3) ) ) + b = IECore.TransformationMatrixfData( IECore.TransformationMatrixf( imath.V3f(2,3,4), imath.Eulerf(), imath.V3f(1,2,3) ) ) c = IECore.linearObjectInterpolation( a, b, 0.5 ) self.assertEqual( type(c), IECore.TransformationMatrixfData ) - self.assert_( c.value.scale.equalWithAbsError( IECore.V3f( 1.5, 2, 2.5 ), 0.01 ) ) - self.assert_( c.value.translate.equalWithAbsError( IECore.V3f( 0.5, 1, 1.5 ), 0.01 ) ) + self.assert_( c.value.scale.equalWithAbsError( imath.V3f( 1.5, 2, 2.5 ), 0.01 ) ) + self.assert_( c.value.translate.equalWithAbsError( imath.V3f( 0.5, 1, 1.5 ), 0.01 ) ) def testComparison(self): """Test TransformationMatrixfData comparison""" a = IECore.TransformationMatrixfData() b = IECore.TransformationMatrixfData() self.assertEqual( a, b ) - b.value = IECore.TransformationMatrixf( IECore.V3f( 0.00001, 0, 0 ), IECore.Eulerf(), IECore.V3f(0,0,0) ) + b.value = IECore.TransformationMatrixf( imath.V3f( 0.00001, 0, 0 ), imath.Eulerf(), imath.V3f(0,0,0) ) self.assertNotEqual( a, b ) - a.value = IECore.TransformationMatrixf( IECore.V3f( 0.00001, 0, 0 ), IECore.Eulerf(), IECore.V3f(0,0,0) ) + a.value = IECore.TransformationMatrixf( imath.V3f( 0.00001, 0, 0 ), imath.Eulerf(), imath.V3f(0,0,0) ) self.assertEqual( a, b ) def testHash( self ) : @@ -193,7 +194,18 @@ def modifyAndTest( data, field, index ) : h = data.hash() v = data.value f = getattr( v, field ) - f[index] += 1 + if isinstance( f, imath.Quatf ) : + # imath omits the indexing operator + # from its bindings, so we have to do + # it all manually + if index == 0 : + f.setR( f.r() + 1 ) + else : + fv = f.v() + fv[index-1] += 1 + f.setV( fv ) + else : + f[index] += 1 setattr( v, field, f ) data.value = v self.assertNotEqual( data.hash(), h ) @@ -240,7 +252,7 @@ def modifyAndTest( data, field, index ) : h = d.hash() v = d.value r = v.rotate - r.setOrder( IECore.Eulerf.Order.ZYX ) + r.setOrder( imath.Eulerf.Order.ZYX ) v.rotate = r d.value = v self.assertNotEqual( d.hash(), h ) @@ -257,21 +269,21 @@ def testConstructors(self): """Test TransformationMatrixdData constructors""" a = IECore.TransformationMatrixdData() self.assertEqual( a.value, IECore.TransformationMatrixd() ) - a = IECore.TransformationMatrixdData( IECore.TransformationMatrixd( IECore.V3d( 2, 2, 2 ), IECore.Eulerd(), IECore.V3d( 1, 0, 0 ) ) ) - self.assertEqual( a.value.scale, IECore.V3d( 2, 2, 2 ) ) + a = IECore.TransformationMatrixdData( IECore.TransformationMatrixd( imath.V3d( 2, 2, 2 ), imath.Eulerd(), imath.V3d( 1, 0, 0 ) ) ) + self.assertEqual( a.value.scale, imath.V3d( 2, 2, 2 ) ) def testCopy(self): """Test TransformationMatrixdData copy""" - a = IECore.TransformationMatrixdData( IECore.TransformationMatrixd( IECore.V3d( 2, 2, 2 ), IECore.Eulerd(), IECore.V3d( 1, 0, 0 ) ) ) - self.assertEqual( a.value.scale, IECore.V3d( 2, 2, 2 ) ) + a = IECore.TransformationMatrixdData( IECore.TransformationMatrixd( imath.V3d( 2, 2, 2 ), imath.Eulerd(), imath.V3d( 1, 0, 0 ) ) ) + self.assertEqual( a.value.scale, imath.V3d( 2, 2, 2 ) ) b = a.copy() a.value = IECore.TransformationMatrixd() - self.assertEqual( b.value.scale, IECore.V3d( 2, 2, 2 ) ) - self.assertEqual( a.value.scale, IECore.V3d( 1, 1, 1 ) ) + self.assertEqual( b.value.scale, imath.V3d( 2, 2, 2 ) ) + self.assertEqual( a.value.scale, imath.V3d( 1, 1, 1 ) ) def testIO(self): """Test TransformationMatrixdData IO""" - a = IECore.TransformationMatrixdData( IECore.TransformationMatrixd( IECore.V3d(2,3,4), IECore.Eulerd(), IECore.V3d(1,2,3) ) ) + a = IECore.TransformationMatrixdData( IECore.TransformationMatrixd( imath.V3d(2,3,4), imath.Eulerd(), imath.V3d(1,2,3) ) ) w = IECore.ObjectWriter( a, self.testFile ) w.write() @@ -282,26 +294,26 @@ def testIO(self): def testInterpolation(self): """Test TranformationMatrixdData interpolation""" a = IECore.TransformationMatrixdData() - b = IECore.TransformationMatrixdData( IECore.TransformationMatrixd( IECore.V3d(2,3,4), IECore.Eulerd(), IECore.V3d(1,2,3) ) ) + b = IECore.TransformationMatrixdData( IECore.TransformationMatrixd( imath.V3d(2,3,4), imath.Eulerd(), imath.V3d(1,2,3) ) ) c = IECore.linearObjectInterpolation( a, b, 0.5 ) self.assertEqual( type(c), IECore.TransformationMatrixdData ) - self.assert_( c.value.scale.equalWithAbsError( IECore.V3d( 1.5, 2, 2.5 ), 0.01 ) ) - self.assert_( c.value.translate.equalWithAbsError( IECore.V3d( 0.5, 1, 1.5 ), 0.01 ) ) + self.assert_( c.value.scale.equalWithAbsError( imath.V3d( 1.5, 2, 2.5 ), 0.01 ) ) + self.assert_( c.value.translate.equalWithAbsError( imath.V3d( 0.5, 1, 1.5 ), 0.01 ) ) # try rotation interpolation... - d = IECore.TransformationMatrixdData( IECore.TransformationMatrixd( IECore.V3d(2,3,4), IECore.Eulerd( 1., 2., 3. ), IECore.V3d(1,2,3) ) ) + d = IECore.TransformationMatrixdData( IECore.TransformationMatrixd( imath.V3d(2,3,4), imath.Eulerd( 1., 2., 3. ), imath.V3d(1,2,3) ) ) e = IECore.linearObjectInterpolation( b, d, 0.2 ) - self.assert_( e.value.rotate.equalWithAbsError( IECore.V3d( -0.341406, 0.189475, 0.191253 ), 0.001 ) ) + self.assert_( e.value.rotate.equalWithAbsError( imath.V3d( -0.341406, 0.189475, 0.191253 ), 0.001 ) ) def testComparison(self): """Test TransformationMatrixdData comparison""" a = IECore.TransformationMatrixdData() b = IECore.TransformationMatrixdData() self.assertEqual( a, b ) - b.value = IECore.TransformationMatrixd( IECore.V3d( 0.00001, 0, 0 ), IECore.Eulerd(), IECore.V3d(0,0,0) ) + b.value = IECore.TransformationMatrixd( imath.V3d( 0.00001, 0, 0 ), imath.Eulerd(), imath.V3d(0,0,0) ) self.assertNotEqual( a, b ) - a.value = IECore.TransformationMatrixd( IECore.V3d( 0.00001, 0, 0 ), IECore.Eulerd(), IECore.V3d(0,0,0) ) + a.value = IECore.TransformationMatrixd( imath.V3d( 0.00001, 0, 0 ), imath.Eulerd(), imath.V3d(0,0,0) ) self.assertEqual( a, b ) def tearDown(self): diff --git a/test/IECore/TriangleAlgoTest.py b/test/IECore/TriangleAlgoTest.py index 60b8301442..e98f26ba7a 100644 --- a/test/IECore/TriangleAlgoTest.py +++ b/test/IECore/TriangleAlgoTest.py @@ -34,30 +34,31 @@ import unittest import math +import imath import IECore class TriangleAlgoTest( unittest.TestCase ) : def testContainsPoint( self ) : - r = IECore.Rand32() - v0 = IECore.V3f( 0, 0, 0 ) - v1 = IECore.V3f( 1, 0, 0 ) - v2 = IECore.V3f( 0, 1, 0 ) + r = imath.Rand32() + v0 = imath.V3f( 0, 0, 0 ) + v1 = imath.V3f( 1, 0, 0 ) + v2 = imath.V3f( 0, 1, 0 ) for i in range( 0, 10000 ) : - p = IECore.V3f( r.nextf( -1, 1 ), r.nextf( -1, 1 ), 0 ) + p = imath.V3f( r.nextf( -1, 1 ), r.nextf( -1, 1 ), 0 ) if p.x < 0 or p.y < 0 or p.x + p.y > 1 : self.failIf( IECore.triangleContainsPoint( v0, v1, v2, p ) ) else : self.failUnless( IECore.triangleContainsPoint( v0, v1, v2, p ) ) - r = IECore.Rand32() + r = imath.Rand32() for i in range( 0, 10000 ) : - v0 = r.nextV3f() - v1 = r.nextV3f() - v2 = r.nextV3f() + v0 = imath.V3f( r.nextf(), r.nextf(), r.nextf() ) + v1 = imath.V3f( r.nextf(), r.nextf(), r.nextf() ) + v2 = imath.V3f( r.nextf(), r.nextf(), r.nextf() ) if IECore.triangleArea( v0, v1, v2 ) > 0.01 : u = r.nextf( 0, 1 ) @@ -70,23 +71,23 @@ def testContainsPoint( self ) : def testNormal( self ) : - v0 = IECore.V3f( 0, 0, 0 ) - v1 = IECore.V3f( 1, 0, 0 ) - v2 = IECore.V3f( 0, 1, 0 ) + v0 = imath.V3f( 0, 0, 0 ) + v1 = imath.V3f( 1, 0, 0 ) + v2 = imath.V3f( 0, 1, 0 ) n = IECore.triangleNormal( v0, v1, v2 ) - self.assertEqual( n, IECore.V3f( 0, 0, 1 ) ) + self.assertEqual( n, imath.V3f( 0, 0, 1 ) ) def testContainsPointWithBarycentric( self ) : - r = IECore.Rand32() - v0 = IECore.V3f( 0, 0, 0 ) - v1 = IECore.V3f( 1, 0, 0 ) - v2 = IECore.V3f( 0, 1, 0 ) + r = imath.Rand32() + v0 = imath.V3f( 0, 0, 0 ) + v1 = imath.V3f( 1, 0, 0 ) + v2 = imath.V3f( 0, 1, 0 ) for i in range( 0, 10000 ) : - b = IECore.V3f( r.nextf( -1, 1 ), r.nextf( -1, 1 ), 0 ) + b = imath.V3f( r.nextf( -1, 1 ), r.nextf( -1, 1 ), 0 ) b.z = 1 - ( b.x + b.y ) p = IECore.trianglePoint( v0, v1, v2, b ) if p.x < 0 or p.y < 0 or p.x + p.y > 1 : diff --git a/test/IECore/Turbulence.py b/test/IECore/Turbulence.py index 251797b072..985aa605fa 100644 --- a/test/IECore/Turbulence.py +++ b/test/IECore/Turbulence.py @@ -34,6 +34,7 @@ import os import unittest +import imath import IECore class TestTurbulence( unittest.TestCase ) : @@ -91,7 +92,7 @@ def test2d( self ) : for i in range( 0, height ) : for j in range( 0, width ) : - f = 0.5 + t.turbulence( IECore.V2f( i/50.0, j/50.0 ) ) + f = 0.5 + t.turbulence( imath.V2f( i/50.0, j/50.0 ) ) self.assertAlmostEqual( f, expected[i*height + j], 5 ) def testNaN( self ) : @@ -103,7 +104,7 @@ def testNaN( self ) : turbulent = True ) - f = t.turbulence( IECore.V2f( 21.3, 51.2 ) ) + f = t.turbulence( imath.V2f( 21.3, 51.2 ) ) self.assert_( f == f ) if __name__ == "__main__": diff --git a/test/IECore/TypedDataTest.py b/test/IECore/TypedDataTest.py index 4ea0bc43bd..9797cff2ff 100644 --- a/test/IECore/TypedDataTest.py +++ b/test/IECore/TypedDataTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore class TestTypedData( unittest.TestCase ) : @@ -45,35 +46,35 @@ def testRValueFromT( self ) : c["b"] = True c["c"] = "hello" c["d"] = 10.1 - c["e"] = IECore.V3f( 1, 2, 3 ) + c["e"] = imath.V3f( 1, 2, 3 ) self.assertEqual( c["a"], IECore.IntData( 1 ) ) self.assertEqual( c["b"], IECore.BoolData( True ) ) self.assertEqual( c["c"], IECore.StringData( "hello" ) ) self.assertEqual( c["d"], IECore.FloatData( 10.1 ) ) - self.assertEqual( c["e"], IECore.V3fData( IECore.V3f( 1, 2, 3 ) ) ) + self.assertEqual( c["e"], IECore.V3fData( imath.V3f( 1, 2, 3 ) ) ) def testInterpretation( self ) : - self.assertNotEqual( IECore.V3fData( IECore.V3f( 1, 2, 3 ) ), IECore.V3fData( IECore.V3f( 1, 2, 3 ), IECore.GeometricData.Interpretation.Point )) - self.assertEqual( IECore.V3fData( IECore.V3f( 1, 2, 3 ) ), IECore.V3fData( IECore.V3f( 1, 2, 3 ), IECore.GeometricData.Interpretation.None )) - self.assertEqual( IECore.V3fData( IECore.V3f( 1, 2, 3 ) ), IECore.V3fData( IECore.V3f( 1, 2, 3 ), IECore.GeometricData.Interpretation.Numeric )) + self.assertNotEqual( IECore.V3fData( imath.V3f( 1, 2, 3 ) ), IECore.V3fData( imath.V3f( 1, 2, 3 ), IECore.GeometricData.Interpretation.Point )) + self.assertEqual( IECore.V3fData( imath.V3f( 1, 2, 3 ) ), IECore.V3fData( imath.V3f( 1, 2, 3 ), IECore.GeometricData.Interpretation.None )) + self.assertEqual( IECore.V3fData( imath.V3f( 1, 2, 3 ) ), IECore.V3fData( imath.V3f( 1, 2, 3 ), IECore.GeometricData.Interpretation.Numeric )) def testHash( self ) : # although the underlying data is identical, these objects # must not hash equal because they have different types. - self.assertNotEqual( IECore.V3fData( IECore.V3f( 1, 2, 3 ) ).hash(), IECore.Color3fData( IECore.Color3f( 1, 2, 3 ) ).hash() ) + 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( IECore.V3f( 1, 2, 3 ), IECore.GeometricData.Interpretation.Point ) + 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( [ IECore.V2d( 1, 2 ) ] ) + a = IECore.V2dVectorData( [ imath.V2d( 1, 2 ) ] ) b = a.copy() self.assertEqual( a.hash(), b.hash() ) b.setInterpretation( IECore.GeometricData.Interpretation.Point ) diff --git a/test/IECore/VectorData.py b/test/IECore/VectorData.py index 3878cdd6dd..4446e38015 100644 --- a/test/IECore/VectorData.py +++ b/test/IECore/VectorData.py @@ -36,6 +36,7 @@ import math import unittest +import imath import IECore @@ -1174,10 +1175,10 @@ class TestVectorDataStrRepr( unittest.TestCase ) : def test( self ) : - l = [ IECore.V3f( 2 ), IECore.V3f( 4 ), IECore.V3f( 5 ) ] + l = [ imath.V3f( 2 ), imath.V3f( 4 ), imath.V3f( 5 ) ] d = IECore.V3fVectorData( l ) - self.assertEqual( " ".join( [str(x) for x in l] ), str( d ) ) - self.assertEqual( "IECore.V3fVectorData( [ " + ", ".join( [repr( x ) for x in l] ) + " ] )", repr( d ) ) + self.assertEqual( str( d ), "2 2 2 4 4 4 5 5 5" ) + self.assertEqual( repr( d ), "IECore.V3fVectorData( [ imath.V3f( 2, 2, 2 ), imath.V3f( 4, 4, 4 ), imath.V3f( 5, 5, 5 ) ] )" ) l = [ "one", "two", "three" ] d = IECore.StringVectorData( l ) diff --git a/test/IECore/VectorDataFilterOp.py b/test/IECore/VectorDataFilterOp.py index 6878f24113..c59458b2e6 100644 --- a/test/IECore/VectorDataFilterOp.py +++ b/test/IECore/VectorDataFilterOp.py @@ -34,6 +34,7 @@ import unittest import random +import imath import IECore @@ -83,7 +84,7 @@ def testOperateInPlace( self ) : for j in range( 0, random.randint( 0, 1000 ) ) : m.append( random.randint( 0,1 ) ) n += m[-1] - v.append( IECore.V3f( 0 ) ) + v.append( imath.V3f( 0 ) ) IECore.VectorDataFilterOp()( input = v, copyInput = False, filter = m ) self.assertEqual( len( v ), n ) diff --git a/test/IECore/ops/floatParameter/floatParameter-1.py b/test/IECore/ops/floatParameter/floatParameter-1.py index 3146170557..147cff7c04 100644 --- a/test/IECore/ops/floatParameter/floatParameter-1.py +++ b/test/IECore/ops/floatParameter/floatParameter-1.py @@ -32,15 +32,15 @@ # ########################################################################## -from IECore import * +import IECore -class floatParameter( Op ) : +class floatParameter( IECore.Op ) : def __init__( self ) : - Op.__init__( self, + IECore.Op.__init__( self, "", - FloatParameter( + IECore.FloatParameter( name = "result", description = "", defaultValue = 0, @@ -49,7 +49,7 @@ def __init__( self ) : self.parameters().addParameter( - FloatParameter( + IECore.FloatParameter( name = "f", description = "", defaultValue = 1, @@ -60,4 +60,4 @@ def doOperation( self, args ) : return args["f"].copy() -registerRunTimeTyped( floatParameter ) +IECore.registerRunTimeTyped( floatParameter ) diff --git a/test/IECore/ops/matrixParameter/matrixParameter-1.py b/test/IECore/ops/matrixParameter/matrixParameter-1.py index 6b9201d16c..3b0c4d5e6e 100644 --- a/test/IECore/ops/matrixParameter/matrixParameter-1.py +++ b/test/IECore/ops/matrixParameter/matrixParameter-1.py @@ -32,15 +32,17 @@ # ########################################################################## -from IECore import * +import imath -class matrixParameter( Op ) : +import IECore + +class matrixParameter( IECore.Op ) : def __init__( self ) : - Op.__init__( self, + IECore.Op.__init__( self, "test matrix parameter", - IntParameter( + IECore.IntParameter( name = "result", description = "one if everything is ok", defaultValue = 0, @@ -48,17 +50,17 @@ def __init__( self ) : ) self.parameters().addParameter( - M44fParameter( + IECore.M44fParameter( "matrix", "", - M44f(), + imath.M44f(), ) ) def doOperation( self, args ) : - assert args["matrix"] == M44fData( M44f() ) + assert args["matrix"] == IECore.M44fData( imath.M44f() ) - return IntData( 1 ) + return IECore.IntData( 1 ) -registerRunTimeTyped( matrixParameter ) +IECore.registerRunTimeTyped( matrixParameter ) diff --git a/test/IECore/ops/parameterTypes/parameterTypes-1.py b/test/IECore/ops/parameterTypes/parameterTypes-1.py index 61dcfae651..4b63ae4e45 100644 --- a/test/IECore/ops/parameterTypes/parameterTypes-1.py +++ b/test/IECore/ops/parameterTypes/parameterTypes-1.py @@ -32,16 +32,18 @@ # ########################################################################## -from IECore import * import datetime +import imath -class parameterTypes( Op ) : +import IECore + +class parameterTypes( IECore.Op ) : def __init__( self ) : - Op.__init__( self, + IECore.Op.__init__( self, "test all parameter types.", - IntParameter( + IECore.IntParameter( name = "result", description = "one if everything is ok", defaultValue = 0, @@ -52,89 +54,89 @@ def __init__( self ) : [ - IntParameter( + 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, ), - FloatParameter( + 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, ), - DoubleParameter( + IECore.DoubleParameter( name = "c", description = "A double", defaultValue = 3, ), - StringParameter( + IECore.StringParameter( name = "d", description = "A string", defaultValue = "ssss", ), - IntVectorParameter( + IECore.IntVectorParameter( name = "e", description = "An array of ints", - defaultValue = IntVectorData( [ 4, -1, 2 ] ), + defaultValue = IECore.IntVectorData( [ 4, -1, 2 ] ), ), - StringVectorParameter( + IECore.StringVectorParameter( name = "f", description = "An array of strings", - defaultValue = StringVectorData( ["one", "two", "three" ]), + defaultValue = IECore.StringVectorData( ["one", "two", "three" ]), ), - V2fParameter( + IECore.V2fParameter( name = "g", description = "A v2f", - defaultValue = V2fData( V2f( 1,2 ) ), + defaultValue = IECore.V2fData( imath.V2f( 1,2 ) ), ), - V3fParameter( + IECore.V3fParameter( name = "h", description = "a v3f", - defaultValue = V3fData( V3f( 1, 1, 1 ) ), + defaultValue = IECore.V3fData( imath.V3f( 1, 1, 1 ) ), presets = ( - ( "x", V3f( 1, 0, 0 ) ), - ( "y", V3f( 0, 1, 0 ) ), - ( "z", V3f( 0, 0, 1 ) ) + ( "x", imath.V3f( 1, 0, 0 ) ), + ( "y", imath.V3f( 0, 1, 0 ) ), + ( "z", imath.V3f( 0, 0, 1 ) ) ) ), - V2dParameter( + IECore.V2dParameter( name = "i", description = "a v2d", - defaultValue = V2dData( V2d( 1, 1 ) ), + defaultValue = IECore.V2dData( imath.V2d( 1, 1 ) ), ), - CompoundParameter( + IECore.CompoundParameter( name = "compound", description = "a compound parameter", members = [ - V3dParameter( + IECore.V3dParameter( name = "j", description = "a v3d", - defaultValue = V3dData( V3d( 8, 16, 32 ) ), + defaultValue = IECore.V3dData( imath.V3d( 8, 16, 32 ) ), presets = ( - ( "one", V3d( 1 ) ), - ( "two", V3d( 2 ) ) + ( "one", imath.V3d( 1 ) ), + ( "two", imath.V3d( 2 ) ) ) ), - M44fParameter( + IECore.M44fParameter( name = "k", description = "an m44f", - defaultValue = M44fData( ), + defaultValue = IECore.M44fData( ), presets = ( - ( "one", M44f( 1 ) ), - ( "two", M44f( 2 ) ) + ( "one", imath.M44f( 1 ) ), + ( "two", imath.M44f( 2 ) ) ) ), @@ -142,19 +144,19 @@ def __init__( self ) : ), - Color3fParameter( + IECore.Color3fParameter( name = "l", description = "a color3f", - defaultValue = Color3fData( Color3f( 1, 0, 1 )), + defaultValue = IECore.Color3fData( imath.Color3f( 1, 0, 1 )), ), - Color4fParameter( + IECore.Color4fParameter( name = "m", description = "a color4f", - defaultValue = Color4fData( Color4f( 1, 0, 1, 0.5 ) ), + defaultValue = IECore.Color4fData( imath.Color4f( 1, 0, 1, 0.5 ) ), ), - FileNameParameter( + IECore.FileNameParameter( name = "o", description = "tif file please!", defaultValue = "", @@ -162,91 +164,91 @@ def __init__( self ) : allowEmptyString = True, ), - DirNameParameter( + IECore.DirNameParameter( name = "p", description = "directory please!", defaultValue = "", - check = DirNameParameter.CheckType.MustExist, + check = IECore.DirNameParameter.CheckType.MustExist, allowEmptyString = True, ), - BoolParameter( + IECore.BoolParameter( name = "q", description = "blah", defaultValue = False, ), - FileSequenceParameter( + IECore.FileSequenceParameter( name = "r", description = "File sequence please!", defaultValue = "" ), - Box2dParameter( + IECore.Box2dParameter( name = "s", description = "boxboxbox", - defaultValue = Box2d( V2d( -1 ), V2d( 1 ) ) + defaultValue = imath.Box2d( imath.V2d( -1 ), imath.V2d( 1 ) ) ), - Box3fParameter( + IECore.Box3fParameter( name = "t", description = "boxboxbox", - defaultValue = Box3f( V3f( -1 ), V3f( 1 ) ) + defaultValue = imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ) ), - V2iParameter( + IECore.V2iParameter( name = "u", description = "A v2i", - defaultValue = V2iData( V2i( 2, 2 ) ), + defaultValue = IECore.V2iData( imath.V2i( 2, 2 ) ), ), - V3iParameter( + IECore.V3iParameter( name = "v", description = "A v3i", - defaultValue = V3iData( V3i( 5, 5, 5 ) ), + defaultValue = IECore.V3iData( imath.V3i( 5, 5, 5 ) ), ), - FrameListParameter( + IECore.FrameListParameter( name = "w", description = "A FrameList", defaultValue = "", ), - TransformationMatrixfParameter( + IECore.TransformationMatrixfParameter( name = "x", description = "", - defaultValue = TransformationMatrixf(), + defaultValue = IECore.TransformationMatrixf(), ), # We'd like to have one with a non-standard rotation order # here, but they're not currently supported in Maya. - TransformationMatrixdParameter( + IECore.TransformationMatrixdParameter( name = "y", description = "", - defaultValue = TransformationMatrixd(), + defaultValue = IECore.TransformationMatrixd(), ), - ObjectParameter( + IECore.ObjectParameter( name = "p1", description = "", - defaultValue = CompoundObject(), - types = [ TypeId.CompoundObject ] + defaultValue = IECore.CompoundObject(), + types = [ IECore.TypeId.CompoundObject ] ), - LineSegment3fParameter( + IECore.LineSegment3fParameter( name = "p2", description = "", - defaultValue = LineSegment3f( V3f( 1 ), V3f( 2 ) ) + defaultValue = IECore.LineSegment3f( imath.V3f( 1 ), imath.V3f( 2 ) ) ), - LineSegment3dParameter( + IECore.LineSegment3dParameter( name = "p3", description = "", - defaultValue = LineSegment3d( V3d( 1 ), V3d( 2 ) ) + defaultValue = IECore.LineSegment3d( imath.V3d( 1 ), imath.V3d( 2 ) ) ), - DateTimeParameter( + IECore.DateTimeParameter( name = "p4", description = "", defaultValue = datetime.datetime.now() @@ -260,27 +262,27 @@ def doOperation( self, args ) : assert abs(args["b"].value-20.2) < 0.0001 assert args["c"].value==40.5 assert args["d"].value=="hello" - assert args["e"] == IntVectorData( [2, 4, 5] ) - assert args["f"] == StringVectorData( ["one", "two", "three"] ) - assert args["g"] == V2fData( V2f( 2, 4 ) ) - assert args["h"] == V3fData( V3f( 1, 4, 8 ) ) - assert args["i"] == V2dData( V2d( 2, 4 ) ) - assert args["compound"]["j"] == V3dData( V3d( 1, 4, 8 ) ) - assert args["compound"]["k"] == M44fData( M44f( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ) ) - assert args["l"] == Color3fData( Color3f( 1, 0, 0 ) ) - assert args["m"] == Color4fData( Color4f( 1, 1, 0, 1 ) ) - assert args["o"] == StringData( "myFile.tif" ) - assert args["p"] == StringData( "test" ) - assert args["q"] == BoolData( True ) - assert args["r"] == StringData( "mySequence.####.tif" ) - assert args["s"] == Box2dData( Box2d( V2d( -1, -2 ), V2d( 10, 20 ) ) ) - assert args["t"] == Box3fData( Box3f( V3f( -1, -2, -3), V3f( 10, 20, 30) ) ) - assert args["u"] == V2iData( V2i( 64, 128 ) ) - assert args["v"] == V3iData( V3i( 25, 26, 27 ) ) - assert self["w"].getFrameListValue().asList() == FrameRange( 0, 500, 250 ).asList() - assert args["x"] == TransformationMatrixfData() - assert args["y"] == TransformationMatrixdData() - - return IntData( 1 ) - -registerRunTimeTyped( parameterTypes ) + assert args["e"] == IECore.IntVectorData( [2, 4, 5] ) + assert args["f"] == IECore.StringVectorData( ["one", "two", "three"] ) + 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 ) + +IECore.registerRunTimeTyped( parameterTypes ) diff --git a/test/IECore/ops/presetParsing/presetParsing-1.py b/test/IECore/ops/presetParsing/presetParsing-1.py index 9bfb407d12..3d82a3cdfa 100644 --- a/test/IECore/ops/presetParsing/presetParsing-1.py +++ b/test/IECore/ops/presetParsing/presetParsing-1.py @@ -32,15 +32,17 @@ # ########################################################################## -from IECore import * +import imath -class presetParsing( Op ) : +import IECore + +class presetParsing( IECore.Op ) : def __init__( self ) : - Op.__init__( self, + IECore.Op.__init__( self, "An Op to test the parsing of parameter presets.", - IntParameter( + IECore.IntParameter( name = "result", description = "d", defaultValue = 2, @@ -51,47 +53,47 @@ def __init__( self ) : [ - V3fParameter( + IECore.V3fParameter( name = "h", description = "a v3f", - defaultValue = V3fData(), + defaultValue = IECore.V3fData(), presets = ( - ( "x", V3f( 1, 0, 0 ) ), - ( "y", V3f( 0, 1, 0 ) ), - ( "z", V3f( 0, 0, 1 ) ) + ( "x", imath.V3f( 1, 0, 0 ) ), + ( "y", imath.V3f( 0, 1, 0 ) ), + ( "z", imath.V3f( 0, 0, 1 ) ) ) ), - V2dParameter( + IECore.V2dParameter( name = "i", description = "a v2d", - defaultValue = V2dData( V2d( 0 ) ), + defaultValue = IECore.V2dData( imath.V2d( 0 ) ), ), - CompoundParameter( + IECore.CompoundParameter( name = "compound", description = "a compound parameter", members = [ - V3dParameter( + IECore.V3dParameter( name = "j", description = "a v3d", - defaultValue = V3dData(), + defaultValue = IECore.V3dData(), presets = ( - ( "one", V3d( 1 ) ), - ( "two", V3d( 2 ) ) + ( "one", imath.V3d( 1 ) ), + ( "two", imath.V3d( 2 ) ) ) ), - M44fParameter( + IECore.M44fParameter( name = "k", description = "an m44f", - defaultValue = M44fData(), + defaultValue = IECore.M44fData(), presets = ( - ( "one", M44f( 1 ) ), - ( "two", M44f( 2 ) ) + ( "one", imath.M44f( 1 ) ), + ( "two", imath.M44f( 2 ) ) ) ), @@ -104,15 +106,15 @@ def __init__( self ) : def doOperation( self, operands ) : - assert operands["h"] == V3fData( V3f( 1, 0, 0 ) ) + assert operands["h"] == IECore.V3fData( imath.V3f( 1, 0, 0 ) ) - assert operands["i"] == V2dData( V2d( 0 ) ) + assert operands["i"] == IECore.V2dData( imath.V2d( 0 ) ) - compoundPreset = CompoundObject() - compoundPreset["j"] = V3dData( V3d( 1 ) ) - compoundPreset["k"] = M44fData( M44f( 1 ) ) + compoundPreset = IECore.CompoundObject() + compoundPreset["j"] = IECore.V3dData( imath.V3d( 1 ) ) + compoundPreset["k"] = IECore.M44fData( imath.M44f( 1 ) ) assert operands["compound"] == compoundPreset - return IntData( 1 ) + return IECore.IntData( 1 ) -registerRunTimeTyped( presetParsing ) +IECore.registerRunTimeTyped( presetParsing ) diff --git a/test/IECore/ops/stringParsing/stringParsing-1.py b/test/IECore/ops/stringParsing/stringParsing-1.py index 8ff8b88e39..0cf565990a 100644 --- a/test/IECore/ops/stringParsing/stringParsing-1.py +++ b/test/IECore/ops/stringParsing/stringParsing-1.py @@ -32,15 +32,15 @@ # ########################################################################## -from IECore import * +import IECore -class stringParsing( Op ) : +class stringParsing( IECore.Op ) : def __init__( self ) : - Op.__init__( self, + IECore.Op.__init__( self, "test various problem cases with string parsing.", - IntParameter( + IECore.IntParameter( name = "result", description = "one if everything is ok", defaultValue = 0, @@ -50,22 +50,22 @@ def __init__( self ) : self.parameters().addParameters( [ - StringParameter( + IECore.StringParameter( name = "emptyString", description = "", defaultValue = "notEmpty", ), - StringParameter( + IECore.StringParameter( name = "normalString", description = "", defaultValue = "", ), - StringParameter( + IECore.StringParameter( name = "stringWithSpace", description = "", defaultValue = "noSpacesHere", ), - StringParameter( + IECore.StringParameter( name = "stringWithManySpaces", description = "", defaultValue = "noSpacesHere", @@ -81,6 +81,6 @@ def doOperation( self, args ) : assert args["stringWithSpace"].value == "hello there" assert args["stringWithManySpaces"].value == "hello there old chap" - return IntData( 1 ) + return IECore.IntData( 1 ) -registerRunTimeTyped( stringParsing ) +IECore.registerRunTimeTyped( stringParsing ) diff --git a/test/IECoreGL/BufferTest.py b/test/IECoreGL/BufferTest.py index d8517fab96..f75a453854 100644 --- a/test/IECoreGL/BufferTest.py +++ b/test/IECoreGL/BufferTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreGL @@ -43,7 +44,7 @@ class BufferTest( unittest.TestCase ) : def test( self ) : - d = IECore.V3fVectorData( [ IECore.V3f( x ) for x in range( 0, 100 ) ] ) + d = IECore.V3fVectorData( [ imath.V3f( x ) for x in range( 0, 100 ) ] ) b = IECoreGL.CachedConverter.defaultCachedConverter().convert( d ) self.failUnless( isinstance( b, IECoreGL.Buffer ) ) @@ -53,7 +54,7 @@ def test( self ) : b2 = IECoreGL.CachedConverter.defaultCachedConverter().convert( d ) self.failUnless( b2.isSame( b ) ) - d2 = IECore.V3fVectorData( [ IECore.V3f( x * 2 ) for x in range( 0, 50 ) ] ) + d2 = IECore.V3fVectorData( [ imath.V3f( x * 2 ) for x in range( 0, 50 ) ] ) b3 = IECoreGL.CachedConverter.defaultCachedConverter().convert( d2 ) self.failUnless( isinstance( b, IECoreGL.Buffer ) ) diff --git a/test/IECoreGL/CachedConverterTest.py b/test/IECoreGL/CachedConverterTest.py index 14b54baf16..7f8d403d5d 100644 --- a/test/IECoreGL/CachedConverterTest.py +++ b/test/IECoreGL/CachedConverterTest.py @@ -34,6 +34,7 @@ import unittest import threading +import imath import IECore import IECoreScene @@ -48,15 +49,15 @@ def test( self ) : c = IECoreGL.CachedConverter( 500 * 1024 * 1024 ) # 500 megs - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( -1 ) ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( -1 ) ) ) gm = c.convert( m ) - m2 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( -1 ) ) ) + m2 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( -1 ) ) ) gm2 = c.convert( m2 ) self.failUnless( gm.isSame( gm2 ) ) - m3 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( -1 ) ) ) + m3 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( -1 ) ) ) m3["a"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.IntData( 1 ) ) gm3 = c.convert( m3 ) @@ -72,14 +73,14 @@ def testDefaultInstance( self ) : def testThreading( self ) : - r = IECore.Rand32() + r = imath.Rand32() pv = IECore.V3fVectorData() for i in range( 0, 10000 ) : - pv.append( r.nextV3f() ) + pv.append( imath.V3f( r.nextf(), r.nextf(), r.nextf() ) ) p = IECoreScene.PointsPrimitive( pv.copy() ) - pv.append( r.nextV3f() ) + pv.append( imath.V3f( r.nextf(), r.nextf(), r.nextf() ) ) p2 = IECoreScene.PointsPrimitive( pv.copy() ) self.assertNotEqual( p, p2 ) @@ -112,14 +113,14 @@ def t() : def testThrashing( self ) : - r = IECore.Rand32() + r = imath.Rand32() pv = IECore.V3fVectorData() for i in range( 0, 10000 ) : - pv.append( r.nextV3f() ) + pv.append( imath.V3f( r.nextf(), r.nextf(), r.nextf() ) ) p = IECoreScene.PointsPrimitive( pv.copy() ) - pv.append( r.nextV3f() ) + pv.append( imath.V3f( r.nextf(), r.nextf(), r.nextf() ) ) p2 = IECoreScene.PointsPrimitive( pv.copy() ) self.assertNotEqual( p, p2 ) @@ -144,11 +145,11 @@ def t() : def testThrashingAndThreadingWithTextures( self ) : - dataWindow = IECore.Box2i( IECore.V2i( 0 ), IECore.V2i( 15 ) ) + dataWindow = imath.Box2i( imath.V2i( 0 ), imath.V2i( 15 ) ) - i1 = IECoreImage.ImagePrimitive.createRGBFloat( IECore.Color3f( 1, 0.5, 0.25 ), dataWindow, dataWindow ) - i2 = IECoreImage.ImagePrimitive.createRGBFloat( IECore.Color3f( 0.75, 0.65, 0.55 ), dataWindow, dataWindow ) - p = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ IECore.V3f( 0 ) ] * 10 ) ) + i1 = IECoreImage.ImagePrimitive.createRGBFloat( imath.Color3f( 1, 0.5, 0.25 ), dataWindow, dataWindow ) + i2 = IECoreImage.ImagePrimitive.createRGBFloat( imath.Color3f( 0.75, 0.65, 0.55 ), dataWindow, dataWindow ) + p = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ imath.V3f( 0 ) ] * 10 ) ) for i in range( 0, 1 ) : diff --git a/test/IECoreGL/Camera.py b/test/IECoreGL/Camera.py index 1f53a60756..46110e38be 100644 --- a/test/IECoreGL/Camera.py +++ b/test/IECoreGL/Camera.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene import IECoreImage @@ -52,16 +53,16 @@ def testPositioning( self ) : r.setOption( "gl:searchPath:shader", IECore.StringData( os.path.dirname( __file__ ) + "/shaders" ) ) r.display( os.path.dirname( __file__ ) + "/output/testCamera.tif", "tiff", "rgba", {} ) - r.camera( "main", { "resolution" : IECore.V2iData( IECore.V2i( 512 ) ), "projection" : IECore.StringData( "perspective" ) } ) + r.camera( "main", { "resolution" : IECore.V2iData( imath.V2i( 512 ) ), "projection" : IECore.StringData( "perspective" ) } ) r.worldBegin() - r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( IECore.Color3f( 1, 0, 0 ) ) } ) - IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -0.1 ), IECore.V2f( 0.1 ) ) ).render( r ) + r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( imath.Color3f( 1, 0, 0 ) ) } ) + IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -0.1 ), imath.V2f( 0.1 ) ) ).render( r ) r.worldEnd() # check that nothing appears in the output image i = IECore.Reader.create( os.path.dirname( __file__ ) + "/output/testCamera.tif" ).read() - dimensions = i.dataWindow.size() + IECore.V2i( 1 ) + dimensions = i.dataWindow.size() + imath.V2i( 1 ) midpoint = dimensions.x * dimensions.y/2 + dimensions.x/2 self.assertEqual( i["G"][midpoint], 0 ) @@ -72,19 +73,19 @@ def testPositioning( self ) : r.display( os.path.dirname( __file__ ) + "/output/testCamera.tif", "tiff", "rgba", {} ) r.transformBegin() - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, 1 ) ) ) - r.camera( "main", { "resolution" : IECore.V2iData( IECore.V2i( 512 ) ), "projection" : IECore.StringData( "perspective" ) } ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, 1 ) ) ) + r.camera( "main", { "resolution" : IECore.V2iData( imath.V2i( 512 ) ), "projection" : IECore.StringData( "perspective" ) } ) r.transformEnd() r.worldBegin() - r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( IECore.Color3f( 1, 0, 0 ) ) } ) - IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -0.1 ), IECore.V2f( 0.1 ) ) ).render( r ) + r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( imath.Color3f( 1, 0, 0 ) ) } ) + IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -0.1 ), imath.V2f( 0.1 ) ) ).render( r ) r.worldEnd() # check that something appears in the output image i = IECore.Reader.create( os.path.dirname( __file__ ) + "/output/testCamera.tif" ).read() - dimensions = i.dataWindow.size() + IECore.V2i( 1 ) + dimensions = i.dataWindow.size() + imath.V2i( 1 ) midpoint = dimensions.x * dimensions.y/2 + dimensions.x/2 self.assertEqual( i["A"][midpoint], 1 ) @@ -97,20 +98,20 @@ def testXYOrientation( self ) : r.setOption( "gl:searchPath:shader", IECore.StringData( os.path.dirname( __file__ ) + "/shaders" ) ) r.display( os.path.dirname( __file__ ) + "/output/testCamera.tif", "tiff", "rgba", {} ) r.transformBegin() - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, 1 ) ) ) - r.camera( "main", { "resolution" : IECore.V2iData( IECore.V2i( 512 ) ) } ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, 1 ) ) ) + r.camera( "main", { "resolution" : IECore.V2iData( imath.V2i( 512 ) ) } ) r.transformEnd() r.worldBegin() - r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( IECore.Color3f( 1, 0, 0 ) ) } ) - IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( 0.75, -0.25 ), IECore.V2f( 1.25, 0.25 ) ) ).render( r ) - r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( IECore.Color3f( 0, 1, 0 ) ) } ) - IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -0.25, 0.75 ), IECore.V2f( 0.25, 1.25 ) ) ).render( r ) + r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( imath.Color3f( 1, 0, 0 ) ) } ) + IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( 0.75, -0.25 ), imath.V2f( 1.25, 0.25 ) ) ).render( r ) + r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( imath.Color3f( 0, 1, 0 ) ) } ) + IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -0.25, 0.75 ), imath.V2f( 0.25, 1.25 ) ) ).render( r ) r.worldEnd() # check we get the colors we'd expect where we expect them i = IECore.Reader.create( os.path.dirname( __file__ ) + "/output/testCamera.tif" ).read() - dimensions = i.dataWindow.size() + IECore.V2i( 1 ) + dimensions = i.dataWindow.size() + imath.V2i( 1 ) index = dimensions.x * dimensions.y/2 + dimensions.x - 1 self.assertEqual( i["A"][index], 1 ) self.assertEqual( i["R"][index], 1 ) diff --git a/test/IECoreGL/CoordinateSystemTest.py b/test/IECoreGL/CoordinateSystemTest.py index d77e0f99a2..645ec4948b 100644 --- a/test/IECoreGL/CoordinateSystemTest.py +++ b/test/IECoreGL/CoordinateSystemTest.py @@ -35,6 +35,7 @@ import unittest import os.path import shutil +import imath import IECore import IECoreScene @@ -54,16 +55,16 @@ def testNoVisualisation( self ) : r.camera( "main", { "projection" : IECore.StringData( "orthographic" ), - "resolution" : IECore.V2iData( IECore.V2i( 256 ) ), - "clippingPlanes" : IECore.V2fData( IECore.V2f( 1, 1000 ) ), - "screenWindow" : IECore.Box2fData( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + "resolution" : IECore.V2iData( imath.V2i( 256 ) ), + "clippingPlanes" : IECore.V2fData( imath.V2f( 1, 1000 ) ), + "screenWindow" : IECore.Box2fData( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) } ) r.display( self.__outputFileName, "tif", "rgba", {} ) with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) r.coordinateSystem( "myCoordSys" ) i = IECore.Reader.create( self.__outputFileName ).read() @@ -79,9 +80,9 @@ def testVisualisation( self ) : r.camera( "main", { "projection" : IECore.StringData( "orthographic" ), - "resolution" : IECore.V2iData( IECore.V2i( 256 ) ), - "clippingPlanes" : IECore.V2fData( IECore.V2f( 1, 1000 ) ), - "screenWindow" : IECore.Box2fData( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + "resolution" : IECore.V2iData( imath.V2i( 256 ) ), + "clippingPlanes" : IECore.V2fData( imath.V2f( 1, 1000 ) ), + "screenWindow" : IECore.Box2fData( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) } ) r.display( self.__outputFileName, "tif", "rgba", {} ) @@ -90,7 +91,7 @@ def testVisualisation( self ) : with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) r.coordinateSystem( "myCoordSys" ) i = IECore.Reader.create( self.__outputFileName ).read() diff --git a/test/IECoreGL/CurvesPrimitiveTest.py b/test/IECoreGL/CurvesPrimitiveTest.py index eb918f1d19..b71c4a9189 100644 --- a/test/IECoreGL/CurvesPrimitiveTest.py +++ b/test/IECoreGL/CurvesPrimitiveTest.py @@ -35,6 +35,7 @@ import unittest import os.path import shutil +import imath import IECore import IECoreScene @@ -92,9 +93,9 @@ def performTest( self, curvesPrimitive, attributes=[], testPixels=[], testImage= r.camera( "main", { "projection" : IECore.StringData( "orthographic" ), - "resolution" : IECore.V2iData( IECore.V2i( 256 ) ), - "clippingPlanes" : IECore.V2fData( IECore.V2f( 1, 1000 ) ), - "screenWindow" : IECore.Box2fData( IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) ) + "resolution" : IECore.V2iData( imath.V2i( 256 ) ), + "clippingPlanes" : IECore.V2fData( imath.V2f( 1, 1000 ) ), + "screenWindow" : IECore.Box2fData( imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) } ) r.display( self.outputFileName, "tif", "rgba", {} ) @@ -104,24 +105,24 @@ def performTest( self, curvesPrimitive, attributes=[], testPixels=[], testImage= for a in attributes : r.setAttribute( a[0], a[1] ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) if shader : shader.render( r ) else : - r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( IECore.Color3f( 0, 0, 1 ) ) } ) + r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( imath.Color3f( 0, 0, 1 ) ) } ) curvesPrimitive.render( r ) i = IECore.Reader.create( self.outputFileName ).read() - dimensions = i.dataWindow.size() + IECore.V2i( 1 ) + dimensions = i.dataWindow.size() + imath.V2i( 1 ) for t in testPixels : xOffset = 1 if t[0].x == 1 else 0 yOffset = 1 if t[0].y == 1 else 0 index = dimensions.x * int(dimensions.y * t[0].y - yOffset) + int(dimensions.x * t[0].x) - xOffset - c = IECore.Color4f( + c = imath.Color4f( i["R"][index], i["G"][index], i["B"][index], @@ -188,15 +189,15 @@ def testLinearNonPeriodicAsLines( self ) : False, IECore.V3fVectorData( [ - IECore.V3f( 1, 0, 0 ), - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 0, 0.5, 0 ), - IECore.V3f( 0.5, 0.5, 0 ), - - IECore.V3f( 0.5, 0.5, 0 ), - IECore.V3f( 1, 0.5, 0 ), - IECore.V3f( 1, 1, 0 ), - IECore.V3f( 0, 1, 0 ), + imath.V3f( 1, 0, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 0, 0.5, 0 ), + imath.V3f( 0.5, 0.5, 0 ), + + imath.V3f( 0.5, 0.5, 0 ), + imath.V3f( 1, 0.5, 0 ), + imath.V3f( 1, 1, 0 ), + imath.V3f( 0, 1, 0 ), ] ) @@ -206,19 +207,19 @@ def testLinearNonPeriodicAsLines( self ) : ( "gl:curvesPrimitive:useGLLines", IECore.BoolData( True ) ), ], [ - ( IECore.V2f( 0, 0 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 0.5, 0 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 1, 0 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 1, 0.25 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 1, 0.5 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 0, 0.25 ), IECore.Color4f( 0, 0, 0, 0 ) ), - ( IECore.V2f( 0, 0.5 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 0.5, 0.5 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 0, 0.75 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 1, 0.75 ), IECore.Color4f( 0, 0, 0, 0 ) ), - ( IECore.V2f( 1, 1 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 0.5, 1 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 0, 1 ), IECore.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 0, 0 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 0.5, 0 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 1, 0 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 1, 0.25 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 1, 0.5 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 0, 0.25 ), imath.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 0, 0.5 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 0.5, 0.5 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 0, 0.75 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 1, 0.75 ), imath.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 1, 1 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 0.5, 1 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 0, 1 ), imath.Color4f( 0, 0, 1, 1 ) ), ] ) @@ -233,10 +234,10 @@ def testOverriddenLinearPeriodicAsLines( self ) : True, IECore.V3fVectorData( [ - IECore.V3f( 1, 0, 0 ), - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 0, 1, 0 ), - IECore.V3f( 1, 1, 0 ), + imath.V3f( 1, 0, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 0, 1, 0 ), + imath.V3f( 1, 1, 0 ), ] ) @@ -247,19 +248,19 @@ def testOverriddenLinearPeriodicAsLines( self ) : ( "gl:curvesPrimitive:ignoreBasis", IECore.BoolData( True ) ), ], [ - ( IECore.V2f( 0, 0 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 0.5, 0 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 1, 0 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 1, 0.5 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 1, 1 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 0.5, 1 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 0, 1 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 0, 0.5 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 0.5, 0.5 ), IECore.Color4f( 0, 0, 0, 0 ) ), - ( IECore.V2f( 0.1, 0.1 ), IECore.Color4f( 0, 0, 0, 0 ) ), - ( IECore.V2f( 0.9, 0.1 ), IECore.Color4f( 0, 0, 0, 0 ) ), - ( IECore.V2f( 0.9, 0.9 ), IECore.Color4f( 0, 0, 0, 0 ) ), - ( IECore.V2f( 0.1, 0.9 ), IECore.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 0, 0 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 0.5, 0 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 1, 0 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 1, 0.5 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 1, 1 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 0.5, 1 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 0, 1 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 0, 0.5 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 0.5, 0.5 ), imath.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 0.1, 0.1 ), imath.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 0.9, 0.1 ), imath.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 0.9, 0.9 ), imath.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 0.1, 0.9 ), imath.Color4f( 0, 0, 0, 0 ) ), ] ) @@ -279,10 +280,10 @@ def testFallbackLinearPeriodicAsLines( self ) : True, IECore.V3fVectorData( [ - IECore.V3f( 1, 0, 0 ), - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 0, 1, 0 ), - IECore.V3f( 1, 1, 0 ), + imath.V3f( 1, 0, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 0, 1, 0 ), + imath.V3f( 1, 1, 0 ), ] ) @@ -291,19 +292,19 @@ def testFallbackLinearPeriodicAsLines( self ) : ( "gl:curvesPrimitive:glLineWidth", IECore.FloatData( 4 ) ), ], [ - ( IECore.V2f( 0, 0 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 0.5, 0 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 1, 0 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 1, 0.5 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 1, 1 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 0.5, 1 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 0, 1 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 0, 0.5 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 0.5, 0.5 ), IECore.Color4f( 0, 0, 0, 0 ) ), - ( IECore.V2f( 0.1, 0.1 ), IECore.Color4f( 0, 0, 0, 0 ) ), - ( IECore.V2f( 0.9, 0.1 ), IECore.Color4f( 0, 0, 0, 0 ) ), - ( IECore.V2f( 0.9, 0.9 ), IECore.Color4f( 0, 0, 0, 0 ) ), - ( IECore.V2f( 0.1, 0.9 ), IECore.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 0, 0 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 0.5, 0 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 1, 0 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 1, 0.5 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 1, 1 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 0.5, 1 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 0, 1 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 0, 0.5 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 0.5, 0.5 ), imath.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 0.1, 0.1 ), imath.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 0.9, 0.1 ), imath.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 0.9, 0.9 ), imath.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 0.1, 0.9 ), imath.Color4f( 0, 0, 0, 0 ) ), ] ) @@ -319,10 +320,10 @@ def testLinearPeriodicAsLines( self ) : True, IECore.V3fVectorData( [ - IECore.V3f( 1, 0, 0 ), - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 0, 1, 0 ), - IECore.V3f( 1, 1, 0 ), + imath.V3f( 1, 0, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 0, 1, 0 ), + imath.V3f( 1, 1, 0 ), ] ) @@ -332,19 +333,19 @@ def testLinearPeriodicAsLines( self ) : ( "gl:curvesPrimitive:useGLLines", IECore.BoolData( True ) ), ], [ - ( IECore.V2f( 0, 0 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 0.5, 0 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 1, 0 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 1, 0.5 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 1, 1 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 0.5, 1 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 0, 1 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 0, 0.5 ), IECore.Color4f( 0, 0, 1, 1 ) ), - ( IECore.V2f( 0.5, 0.5 ), IECore.Color4f( 0, 0, 0, 0 ) ), - ( IECore.V2f( 0.1, 0.1 ), IECore.Color4f( 0, 0, 0, 0 ) ), - ( IECore.V2f( 0.9, 0.1 ), IECore.Color4f( 0, 0, 0, 0 ) ), - ( IECore.V2f( 0.9, 0.9 ), IECore.Color4f( 0, 0, 0, 0 ) ), - ( IECore.V2f( 0.1, 0.9 ), IECore.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 0, 0 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 0.5, 0 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 1, 0 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 1, 0.5 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 1, 1 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 0.5, 1 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 0, 1 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 0, 0.5 ), imath.Color4f( 0, 0, 1, 1 ) ), + ( imath.V2f( 0.5, 0.5 ), imath.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 0.1, 0.1 ), imath.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 0.9, 0.1 ), imath.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 0.9, 0.9 ), imath.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 0.1, 0.9 ), imath.Color4f( 0, 0, 0, 0 ) ), ] ) @@ -361,10 +362,10 @@ def testBSplinePeriodicAsLines( self ) : True, IECore.V3fVectorData( [ - IECore.V3f( 1, 0, 0 ), - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 0, 1, 0 ), - IECore.V3f( 1, 1, 0 ), + imath.V3f( 1, 0, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 0, 1, 0 ), + imath.V3f( 1, 1, 0 ), ] ) @@ -388,10 +389,10 @@ def testBSplinePeriodicAsRibbons( self ) : True, IECore.V3fVectorData( [ - IECore.V3f( 1, 0, 0 ), - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 0, 1, 0 ), - IECore.V3f( 1, 1, 0 ), + imath.V3f( 1, 0, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 0, 1, 0 ), + imath.V3f( 1, 1, 0 ), ] ) @@ -419,10 +420,10 @@ def testBezierAsRibbons( self ) : False, IECore.V3fVectorData( [ - IECore.V3f( 0.8, 0.2, 0 ), - IECore.V3f( 0.2, 0.2, 0 ), - IECore.V3f( 0.2, 0.8, 0 ), - IECore.V3f( 0.8, 0.8, 0 ), + imath.V3f( 0.8, 0.2, 0 ), + imath.V3f( 0.2, 0.2, 0 ), + imath.V3f( 0.2, 0.8, 0 ), + imath.V3f( 0.8, 0.8, 0 ), ] ) @@ -449,10 +450,10 @@ def testLinearRibbons( self ) : False, IECore.V3fVectorData( [ - IECore.V3f( 0.8, 0.2, 0 ), - IECore.V3f( 0.2, 0.2, 0 ), - IECore.V3f( 0.2, 0.8, 0 ), - IECore.V3f( 0.8, 0.8, 0 ), + imath.V3f( 0.8, 0.2, 0 ), + imath.V3f( 0.2, 0.2, 0 ), + imath.V3f( 0.2, 0.8, 0 ), + imath.V3f( 0.8, 0.8, 0 ), ] ) @@ -479,10 +480,10 @@ def testLinearPeriodicRibbons( self ) : True, IECore.V3fVectorData( [ - IECore.V3f( 0.8, 0.2, 0 ), - IECore.V3f( 0.2, 0.2, 0 ), - IECore.V3f( 0.2, 0.8, 0 ), - IECore.V3f( 0.8, 0.8, 0 ), + imath.V3f( 0.8, 0.2, 0 ), + imath.V3f( 0.2, 0.2, 0 ), + imath.V3f( 0.2, 0.8, 0 ), + imath.V3f( 0.8, 0.8, 0 ), ] ) @@ -509,15 +510,15 @@ def testSeveralBSplineRibbons( self ) : True, IECore.V3fVectorData( [ - IECore.V3f( 0.4, 0.2, 0 ), - IECore.V3f( 0.2, 0.2, 0 ), - IECore.V3f( 0.2, 0.4, 0 ), - IECore.V3f( 0.4, 0.4, 0 ), - - IECore.V3f( 0.8, 0.6, 0 ), - IECore.V3f( 0.6, 0.6, 0 ), - IECore.V3f( 0.6, 0.8, 0 ), - IECore.V3f( 0.8, 0.8, 0 ), + imath.V3f( 0.4, 0.2, 0 ), + imath.V3f( 0.2, 0.2, 0 ), + imath.V3f( 0.2, 0.4, 0 ), + imath.V3f( 0.4, 0.4, 0 ), + + imath.V3f( 0.8, 0.6, 0 ), + imath.V3f( 0.6, 0.6, 0 ), + imath.V3f( 0.6, 0.8, 0 ), + imath.V3f( 0.8, 0.8, 0 ), ] ) @@ -545,15 +546,15 @@ def testSeveralBSplineLines( self ) : True, IECore.V3fVectorData( [ - IECore.V3f( 0.4, 0.2, 0 ), - IECore.V3f( 0.2, 0.2, 0 ), - IECore.V3f( 0.2, 0.4, 0 ), - IECore.V3f( 0.4, 0.4, 0 ), - - IECore.V3f( 0.8, 0.6, 0 ), - IECore.V3f( 0.6, 0.6, 0 ), - IECore.V3f( 0.6, 0.8, 0 ), - IECore.V3f( 0.8, 0.8, 0 ), + imath.V3f( 0.4, 0.2, 0 ), + imath.V3f( 0.2, 0.2, 0 ), + imath.V3f( 0.2, 0.4, 0 ), + imath.V3f( 0.4, 0.4, 0 ), + + imath.V3f( 0.8, 0.6, 0 ), + imath.V3f( 0.6, 0.6, 0 ), + imath.V3f( 0.6, 0.8, 0 ), + imath.V3f( 0.8, 0.8, 0 ), ] ) @@ -577,10 +578,10 @@ def testRibbonWindingOrder( self ) : True, IECore.V3fVectorData( [ - IECore.V3f( 1, 0, 0 ), - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 0, 1, 0 ), - IECore.V3f( 1, 1, 0 ), + imath.V3f( 1, 0, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 0, 1, 0 ), + imath.V3f( 1, 1, 0 ), ] ) @@ -608,10 +609,10 @@ def testLinearRibbonWindingOrder( self ) : True, IECore.V3fVectorData( [ - IECore.V3f( 0.8, 0.2, 0 ), - IECore.V3f( 0.2, 0.2, 0 ), - IECore.V3f( 0.2, 0.8, 0 ), - IECore.V3f( 0.8, 0.8, 0 ), + imath.V3f( 0.8, 0.2, 0 ), + imath.V3f( 0.2, 0.2, 0 ), + imath.V3f( 0.2, 0.8, 0 ), + imath.V3f( 0.8, 0.8, 0 ), ] ) @@ -637,15 +638,15 @@ def testLinearLinesWithVertexColor( self ) : False, IECore.V3fVectorData( [ - IECore.V3f( 1, 0, 0 ), - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 0, 0.5, 0 ), - IECore.V3f( 0.5, 0.5, 0 ), - - IECore.V3f( 0.5, 0.5, 0 ), - IECore.V3f( 1, 0.5, 0 ), - IECore.V3f( 1, 1, 0 ), - IECore.V3f( 0, 1, 0 ), + imath.V3f( 1, 0, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 0, 0.5, 0 ), + imath.V3f( 0.5, 0.5, 0 ), + + imath.V3f( 0.5, 0.5, 0 ), + imath.V3f( 1, 0.5, 0 ), + imath.V3f( 1, 1, 0 ), + imath.V3f( 0, 1, 0 ), ] ) @@ -654,15 +655,15 @@ def testLinearLinesWithVertexColor( self ) : IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.Color3fVectorData( [ - IECore.Color3f( 1, 0, 0 ), - IECore.Color3f( 0, 1, 0 ), - IECore.Color3f( 0, 0, 1 ), - IECore.Color3f( 0, 1, 0 ), - - IECore.Color3f( 1, 0, 0 ), - IECore.Color3f( 0, 1, 0 ), - IECore.Color3f( 0, 0, 1 ), - IECore.Color3f( 0, 1, 0 ), + imath.Color3f( 1, 0, 0 ), + imath.Color3f( 0, 1, 0 ), + imath.Color3f( 0, 0, 1 ), + imath.Color3f( 0, 1, 0 ), + + imath.Color3f( 1, 0, 0 ), + imath.Color3f( 0, 1, 0 ), + imath.Color3f( 0, 0, 1 ), + imath.Color3f( 0, 1, 0 ), ] ) ) @@ -687,20 +688,20 @@ def testLinearLinesWithUniformColor( self ) : False, IECore.V3fVectorData( [ - IECore.V3f( 1, 0, 0 ), - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 0, 0.5, 0 ), - IECore.V3f( 0.5, 0.5, 0 ), - - IECore.V3f( 0.5, 0.5, 0 ), - IECore.V3f( 1, 0.5, 0 ), - IECore.V3f( 1, 1, 0 ), - IECore.V3f( 0, 1, 0 ), + imath.V3f( 1, 0, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 0, 0.5, 0 ), + imath.V3f( 0.5, 0.5, 0 ), + + imath.V3f( 0.5, 0.5, 0 ), + imath.V3f( 1, 0.5, 0 ), + imath.V3f( 1, 1, 0 ), + imath.V3f( 0, 1, 0 ), ] ) ) - c["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.Color3fVectorData( [ IECore.Color3f( 1, 0, 0 ), IECore.Color3f( 0, 1, 0 ) ] ) ) + c["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.Color3fVectorData( [ imath.Color3f( 1, 0, 0 ), imath.Color3f( 0, 1, 0 ) ] ) ) self.performTest( @@ -722,20 +723,20 @@ def testLinearLinesWithConstantColor( self ) : False, IECore.V3fVectorData( [ - IECore.V3f( 1, 0, 0 ), - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 0, 0.5, 0 ), - IECore.V3f( 0.5, 0.5, 0 ), - - IECore.V3f( 0.5, 0.5, 0 ), - IECore.V3f( 1, 0.5, 0 ), - IECore.V3f( 1, 1, 0 ), - IECore.V3f( 0, 1, 0 ), + imath.V3f( 1, 0, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 0, 0.5, 0 ), + imath.V3f( 0.5, 0.5, 0 ), + + imath.V3f( 0.5, 0.5, 0 ), + imath.V3f( 1, 0.5, 0 ), + imath.V3f( 1, 1, 0 ), + imath.V3f( 0, 1, 0 ), ] ) ) - c["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.Color3fData( IECore.Color3f( 1, 0, 0 ) ) ) + c["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.Color3fData( imath.Color3f( 1, 0, 0 ) ) ) self.performTest( diff --git a/test/IECoreGL/DiskPrimitiveTest.py b/test/IECoreGL/DiskPrimitiveTest.py index 9f3b40aad5..83dfc669a4 100644 --- a/test/IECoreGL/DiskPrimitiveTest.py +++ b/test/IECoreGL/DiskPrimitiveTest.py @@ -35,6 +35,7 @@ import unittest import os.path import shutil +import imath import IECore import IECoreScene @@ -55,18 +56,18 @@ def test( self ) : r.camera( "main", { "projection" : IECore.StringData( "orthographic" ), - "resolution" : IECore.V2iData( IECore.V2i( 256 ) ), - "clippingPlanes" : IECore.V2fData( IECore.V2f( 1, 1000 ) ), - "screenWindow" : IECore.Box2fData( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + "resolution" : IECore.V2iData( imath.V2i( 256 ) ), + "clippingPlanes" : IECore.V2fData( imath.V2f( 1, 1000 ) ), + "screenWindow" : IECore.Box2fData( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) } ) r.display( self.outputFileName, "tif", "rgba", {} ) with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) - r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( IECore.Color3f( 0, 0, 1 ) ) } ) + r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( imath.Color3f( 0, 0, 1 ) ) } ) r.disk( 1, 0, 360, {} ) i = IECore.Reader.create( self.outputFileName ).read() @@ -99,23 +100,23 @@ def testWindingOrder( self ) : r.camera( "main", { "projection" : IECore.StringData( "orthographic" ), - "resolution" : IECore.V2iData( IECore.V2i( 256 ) ), - "clippingPlanes" : IECore.V2fData( IECore.V2f( 1, 1000 ) ), - "screenWindow" : IECore.Box2fData( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + "resolution" : IECore.V2iData( imath.V2i( 256 ) ), + "clippingPlanes" : IECore.V2fData( imath.V2f( 1, 1000 ) ), + "screenWindow" : IECore.Box2fData( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) } ) r.display( self.outputFileName, "tif", "rgba", {} ) with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) r.setAttribute( "doubleSided", IECore.BoolData( False ) ) - r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( IECore.Color3f( 0, 0, 1 ) ) } ) + r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( imath.Color3f( 0, 0, 1 ) ) } ) r.disk( 1, 0, 360, {} ) image = IECore.Reader.create( self.outputFileName ).read() - dimensions = image.dataWindow.size() + IECore.V2i( 1 ) + dimensions = image.dataWindow.size() + imath.V2i( 1 ) index = dimensions.x * dimensions.y/2 + dimensions.x/2 self.assertEqual( image["A"][index], 1 ) @@ -127,24 +128,24 @@ def testWindingOrder( self ) : r.camera( "main", { "projection" : IECore.StringData( "orthographic" ), - "resolution" : IECore.V2iData( IECore.V2i( 256 ) ), - "clippingPlanes" : IECore.V2fData( IECore.V2f( 1, 1000 ) ), - "screenWindow" : IECore.Box2fData( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + "resolution" : IECore.V2iData( imath.V2i( 256 ) ), + "clippingPlanes" : IECore.V2fData( imath.V2f( 1, 1000 ) ), + "screenWindow" : IECore.Box2fData( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) } ) r.display( self.outputFileName, "tif", "rgba", {} ) with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) r.setAttribute( "doubleSided", IECore.BoolData( False ) ) r.setAttribute( "rightHandedOrientation", IECore.BoolData( False ) ) - r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( IECore.Color3f( 0, 0, 1 ) ) } ) + r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( imath.Color3f( 0, 0, 1 ) ) } ) r.disk( 1, 0, 360, {} ) image = IECore.Reader.create( self.outputFileName ).read() - dimensions = image.dataWindow.size() + IECore.V2i( 1 ) + dimensions = image.dataWindow.size() + imath.V2i( 1 ) index = dimensions.x * dimensions.y/2 + dimensions.x/2 self.assertEqual( image["A"][index], 0 ) diff --git a/test/IECoreGL/Group.py b/test/IECoreGL/Group.py index 88b564f1ef..fb702ea843 100644 --- a/test/IECoreGL/Group.py +++ b/test/IECoreGL/Group.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene @@ -46,9 +47,9 @@ def test( self ) : g = IECoreGL.Group() - self.assertEqual( g.getTransform(), IECore.M44f() ) - g.setTransform( IECore.M44f.createScaled( IECore.V3f( 3 ) ) ) - self.assertEqual( g.getTransform(), IECore.M44f.createScaled( IECore.V3f( 3 ) ) ) + self.assertEqual( g.getTransform(), imath.M44f() ) + g.setTransform( imath.M44f().scale( imath.V3f( 3 ) ) ) + self.assertEqual( g.getTransform(), imath.M44f().scale( imath.V3f( 3 ) ) ) self.assertEqual( g.children(), [] ) diff --git a/test/IECoreGL/ImmediateRenderer.py b/test/IECoreGL/ImmediateRenderer.py index 6faf363518..7d914a603c 100644 --- a/test/IECoreGL/ImmediateRenderer.py +++ b/test/IECoreGL/ImmediateRenderer.py @@ -35,6 +35,7 @@ import unittest import os.path import shutil +import imath import IECore import IECoreImage @@ -55,26 +56,26 @@ def test( self ) : r.camera( "main", { "projection" : IECore.StringData( "perspective" ), "projection:fov" : IECore.FloatData( 45 ), - "resolution" : IECore.V2iData( IECore.V2i( 256 ) ), - "clippingPlanes" : IECore.V2fData( IECore.V2f( 1, 1000 ) ), - "screenWindow" : IECore.Box2fData( IECore.Box2f( IECore.V2f( -0.5 ), IECore.V2f( 0.5 ) ) ) + "resolution" : IECore.V2iData( imath.V2i( 256 ) ), + "clippingPlanes" : IECore.V2fData( imath.V2f( 1, 1000 ) ), + "screenWindow" : IECore.Box2fData( imath.Box2f( imath.V2f( -0.5 ), imath.V2f( 0.5 ) ) ) } ) r.display( outputFileName, "tif", "rgba", {} ) r.worldBegin() - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) - r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( IECore.Color3f( 0, 0, 1 ) ) } ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) + r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( imath.Color3f( 0, 0, 1 ) ) } ) r.sphere( 1, -1, 1, 360, {} ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 1, 0 ) ) ) - r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( IECore.Color3f( 1, 1, 0 ) ) } ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 1, 0 ) ) ) + r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( imath.Color3f( 1, 1, 0 ) ) } ) r.sphere( 1, -1, 1, 360, {} ) r.worldEnd() i = IECore.Reader.create( outputFileName ).read() - dimensions = i.dataWindow.size() + IECore.V2i( 1 ) + dimensions = i.dataWindow.size() + imath.V2i( 1 ) index = int(dimensions.x * 0.5) self.assertEqual( i["A"][index], 1 ) self.assertEqual( i["R"][index], 1 ) diff --git a/test/IECoreGL/InstancingTest.py b/test/IECoreGL/InstancingTest.py index 65344d22cd..5f8f41ac1b 100644 --- a/test/IECoreGL/InstancingTest.py +++ b/test/IECoreGL/InstancingTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene @@ -55,7 +56,7 @@ def __init__( self, meshes, name="/1", depth=0, maxDepth=8 ) : def bound( self ) : - b = IECore.Box3f() + b = imath.Box3f() for m in self.__meshes : b.extendBy( m.bound() ) return b @@ -101,8 +102,8 @@ def __collectMeshes( self, group, result ) : def testAutomaticInstancingOn( self ) : - m1 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) ) - m2 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m1 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) + m2 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) r = IECoreGL.Renderer() r.setOption( "gl:mode", IECore.StringData( "deferred" ) ) @@ -120,8 +121,8 @@ def testAutomaticInstancingOn( self ) : def testAutomaticInstancingOff( self ) : - m1 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) ) - m2 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m1 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) + m2 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) r = IECoreGL.Renderer() r.setOption( "gl:mode", IECore.StringData( "deferred" ) ) diff --git a/test/IECoreGL/MeshPrimitiveTest.py b/test/IECoreGL/MeshPrimitiveTest.py index 6dca28836d..bee0cb14d1 100644 --- a/test/IECoreGL/MeshPrimitiveTest.py +++ b/test/IECoreGL/MeshPrimitiveTest.py @@ -35,6 +35,7 @@ import unittest import os import shutil +import imath import IECore import IECoreScene @@ -84,16 +85,16 @@ def testVertexAttributes( self ) : r.camera( "main", { "projection" : IECore.StringData( "orthographic" ), - "resolution" : IECore.V2iData( IECore.V2i( 256 ) ), - "clippingPlanes" : IECore.V2fData( IECore.V2f( 1, 1000 ) ), - "screenWindow" : IECore.Box2fData( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + "resolution" : IECore.V2iData( imath.V2i( 256 ) ), + "clippingPlanes" : IECore.V2fData( imath.V2f( 1, 1000 ) ), + "screenWindow" : IECore.Box2fData( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) } ) r.display( self.outputFileName, "tif", "rgba", {} ) with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -15 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -15 ) ) ) r.shader( "surface", "showUV", { "gl:fragmentSource" : IECore.StringData( fragmentSource ), "gl:vertexSource" : IECore.StringData( vertexSource ) @@ -127,34 +128,34 @@ def testUniformCs( self ) : r.camera( "main", { "projection" : IECore.StringData( "orthographic" ), - "resolution" : IECore.V2iData( IECore.V2i( 256 ) ), - "clippingPlanes" : IECore.V2fData( IECore.V2f( 1, 1000 ) ), - "screenWindow" : IECore.Box2fData( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + "resolution" : IECore.V2iData( imath.V2i( 256 ) ), + "clippingPlanes" : IECore.V2fData( imath.V2f( 1, 1000 ) ), + "screenWindow" : IECore.Box2fData( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) } ) r.display( self.outputFileName, "tif", "rgba", {} ) with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -15 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -15 ) ) ) r.shader( "surface", "test", { "gl:fragmentSource" : IECore.StringData( fragmentSource ) } ) - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ), IECore.V2i( 2 ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ), imath.V2i( 2 ) ) m["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.Color3fVectorData( [ - IECore.Color3f( 1, 0, 0 ), - IECore.Color3f( 0, 1, 0 ), - IECore.Color3f( 0, 0, 1 ), - IECore.Color3f( 1, 1, 1, ), + imath.Color3f( 1, 0, 0 ), + imath.Color3f( 0, 1, 0 ), + imath.Color3f( 0, 0, 1 ), + imath.Color3f( 1, 1, 1, ), ] ) ) m.render( r ) image = IECore.Reader.create( self.outputFileName ).read() - dimensions = image.dataWindow.size() + IECore.V2i( 1 ) + dimensions = image.dataWindow.size() + imath.V2i( 1 ) index = dimensions.x * int(dimensions.y * 0.75) + int(dimensions.x * 0.25) self.assertEqual( image["R"][index], 1 ) self.assertEqual( image["G"][index], 0 ) @@ -177,7 +178,7 @@ def testUniformCs( self ) : def testBound( self ) : - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -0.5 ), IECore.V2f( 0.5 ) ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -0.5 ), imath.V2f( 0.5 ) ) ) m2 = IECoreGL.ToGLMeshConverter( m ).convert() self.assertEqual( m.bound(), m2.bound() ) @@ -202,25 +203,25 @@ def testFaceNormals( self ) : r.camera( "main", { "projection" : IECore.StringData( "orthographic" ), - "resolution" : IECore.V2iData( IECore.V2i( 256 ) ), - "clippingPlanes" : IECore.V2fData( IECore.V2f( 1, 1000 ) ), - "screenWindow" : IECore.Box2fData( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + "resolution" : IECore.V2iData( imath.V2i( 256 ) ), + "clippingPlanes" : IECore.V2fData( imath.V2f( 1, 1000 ) ), + "screenWindow" : IECore.Box2fData( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) } ) r.display( self.outputFileName, "tif", "rgba", {} ) with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -15 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -15 ) ) ) r.shader( "surface", "test", { "gl:fragmentSource" : IECore.StringData( fragmentSource ) } ) - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -0.5 ), IECore.V2f( 0.5 ) ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -0.5 ), imath.V2f( 0.5 ) ) ) self.assertTrue( "N" not in m ) m.render( r ) image = IECore.Reader.create( self.outputFileName ).read() - dimensions = image.dataWindow.size() + IECore.V2i( 1 ) + dimensions = image.dataWindow.size() + imath.V2i( 1 ) index = dimensions.x * dimensions.y/2 + dimensions.x/2 self.assertEqual( image["R"][index], 0 ) self.assertEqual( image["G"][index], 0 ) diff --git a/test/IECoreGL/Orientation.py b/test/IECoreGL/Orientation.py index 6f67b56e3c..886361021d 100644 --- a/test/IECoreGL/Orientation.py +++ b/test/IECoreGL/Orientation.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene import IECoreImage @@ -49,7 +50,7 @@ class OrientationTest( unittest.TestCase ) : # viewing down the negative Z axis. def makePlane( self ) : - V = IECore.V3f + V = imath.V3f p = IECore.V3fVectorData( [ V( 1, -1, 0 ), V( 1, 1, 0 ), V( -1, 1, 0 ), V( -1, -1, 0 ) ] ) nVerts = IECore.IntVectorData( [ 4 ] ) vertIds = IECore.IntVectorData( [ 0, 1, 2, 3 ] ) @@ -76,16 +77,16 @@ def testMesh( self ) : r = IECoreGL.Renderer() r.setOption( "gl:mode", IECore.StringData( "immediate" ) ) r.display( outputFileName, "tiff", "rgba", {} ) - r.camera( "main", { "resolution" : IECore.V2iData( IECore.V2i( 256 ) ) } ) + r.camera( "main", { "resolution" : IECore.V2iData( imath.V2i( 256 ) ) } ) r.worldBegin() r.setAttribute( "doubleSided", IECore.BoolData( False ) ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) self.makePlane().render( r ) r.worldEnd() # check that something appears in the output image i = IECore.Reader.create( outputFileName ).read() - dimensions = i.dataWindow.size() + IECore.V2i( 1 ) + dimensions = i.dataWindow.size() + imath.V2i( 1 ) index = dimensions.x * int(dimensions.y * 0.5) + int(dimensions.x * 0.5) self.assertEqual( i["A"][index], 1 ) @@ -93,17 +94,17 @@ def testMesh( self ) : r = IECoreGL.Renderer() r.setOption( "gl:mode", IECore.StringData( "immediate" ) ) r.display( outputFileName, "tiff", "rgba", {} ) - r.camera( "main", { "resolution" : IECore.V2iData( IECore.V2i( 256 ) ) } ) + r.camera( "main", { "resolution" : IECore.V2iData( imath.V2i( 256 ) ) } ) r.worldBegin() r.setAttribute( "doubleSided", IECore.BoolData( False ) ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) - r.concatTransform( IECore.M44f.createRotated( IECore.V3f( 0, math.pi, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().rotate( imath.V3f( 0, math.pi, 0 ) ) ) self.makePlane().render( r ) r.worldEnd() # check that nothing appears in the output image i = IECore.Reader.create( outputFileName ).read() - dimensions = i.dataWindow.size() + IECore.V2i( 1 ) + dimensions = i.dataWindow.size() + imath.V2i( 1 ) index = dimensions.x * int(dimensions.y * 0.5) + int(dimensions.x * 0.5) self.assertEqual( i["A"][index], 0 ) @@ -118,19 +119,19 @@ def testFlippingTransforms( self ) : r = IECoreGL.Renderer() r.setOption( "gl:mode", IECore.StringData( "immediate" ) ) r.display( outputFileName, "tiff", "rgba", {} ) - r.camera( "main", { "resolution" : IECore.V2iData( IECore.V2i( 256 ) ) } ) + r.camera( "main", { "resolution" : IECore.V2iData( imath.V2i( 256 ) ) } ) r.worldBegin() self.assertEqual( r.getAttribute( "rightHandedOrientation" ), IECore.BoolData( True ) ) r.setAttribute( "doubleSided", IECore.BoolData( False ) ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) - r.concatTransform( IECore.M44f.createScaled( IECore.V3f( -1, 1, 1 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().scale( imath.V3f( -1, 1, 1 ) ) ) self.assertEqual( r.getAttribute( "rightHandedOrientation" ), IECore.BoolData( False ) ) self.makePlane().render( r ) r.worldEnd() # check that something appears in the output image i = IECore.Reader.create( outputFileName ).read() - dimensions = i.dataWindow.size() + IECore.V2i( 1 ) + dimensions = i.dataWindow.size() + imath.V2i( 1 ) index = dimensions.x * int(dimensions.y * 0.5) + int(dimensions.x * 0.5) self.assertEqual( i["A"][index], 1 ) @@ -145,18 +146,18 @@ def testFlippingTransformsAndTransformEnd( self ) : r = IECoreGL.Renderer() r.setOption( "gl:mode", IECore.StringData( "immediate" ) ) r.display( outputFileName, "tiff", "rgba", {} ) - r.camera( "main", { "resolution" : IECore.V2iData( IECore.V2i( 256 ) ) } ) + r.camera( "main", { "resolution" : IECore.V2iData( imath.V2i( 256 ) ) } ) r.worldBegin() if 1 : self.assertEqual( r.getAttribute( "rightHandedOrientation" ), IECore.BoolData( True ) ) r.setAttribute( "doubleSided", IECore.BoolData( False ) ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) r.transformBegin() if 1 : - r.concatTransform( IECore.M44f.createScaled( IECore.V3f( -1, 1, 1 ) ) ) + r.concatTransform( imath.M44f().scale( imath.V3f( -1, 1, 1 ) ) ) self.assertEqual( r.getAttribute( "rightHandedOrientation" ), IECore.BoolData( False ) ) self.makePlane().render( r ) @@ -168,7 +169,7 @@ def testFlippingTransformsAndTransformEnd( self ) : # check that something appears in the output image i = IECore.Reader.create( outputFileName ).read() - dimensions = i.dataWindow.size() + IECore.V2i( 1 ) + dimensions = i.dataWindow.size() + imath.V2i( 1 ) index = dimensions.x * int(dimensions.y * 0.5) + int(dimensions.x * 0.5) self.assertEqual( i["A"][index], 1 ) diff --git a/test/IECoreGL/PointsPrimitive.py b/test/IECoreGL/PointsPrimitive.py index 170d01d38d..b8f3408228 100644 --- a/test/IECoreGL/PointsPrimitive.py +++ b/test/IECoreGL/PointsPrimitive.py @@ -36,6 +36,7 @@ import random import os import shutil +import imath import IECore import IECoreScene @@ -105,7 +106,7 @@ def testVertexAttributes( self ) : g = IECore.IntVectorData( numPoints ) random.seed( 0 ) for i in range( 0, numPoints ) : - p[i] = IECore.V3f( random.random() * 4, random.random() * 4, random.random() * 4 ) + p[i] = imath.V3f( random.random() * 4, random.random() * 4, random.random() * 4 ) g[i] = int( random.uniform( 0.0, 255.0 ) ) p = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, p ) g = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, g ) @@ -116,16 +117,16 @@ def testVertexAttributes( self ) : r.camera( "main", { "projection" : IECore.StringData( "orthographic" ), - "resolution" : IECore.V2iData( IECore.V2i( 256 ) ), - "clippingPlanes" : IECore.V2fData( IECore.V2f( 1, 1000 ) ), - "screenWindow" : IECore.Box2fData( IECore.Box2f( IECore.V2f( -3 ), IECore.V2f( 3 ) ) ) + "resolution" : IECore.V2iData( imath.V2i( 256 ) ), + "clippingPlanes" : IECore.V2fData( imath.V2f( 1, 1000 ) ), + "screenWindow" : IECore.Box2fData( imath.Box2f( imath.V2f( -3 ), imath.V2f( 3 ) ) ) } ) r.display( self.outputFileName, "exr", "rgba", {} ) with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( -2, -2, -10 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( -2, -2, -10 ) ) ) r.shader( "surface", "grey", { "gl:vertexSource" : vertexSource, "gl:fragmentSource" : IECore.StringData( fragmentSource ) } ) r.points( numPoints, { "P" : p, "greyTo255" : g } ) @@ -154,9 +155,9 @@ def testEmptyPointsPrimitive( self ): r.setOption( "gl:searchPath:shaderInclude", IECore.StringData( "./glsl" ) ) r.camera( "main", { "projection" : IECore.StringData( "orthographic" ), - "resolution" : IECore.V2iData( IECore.V2i( 256 ) ), - "clippingPlanes" : IECore.V2fData( IECore.V2f( 1, 1000 ) ), - "screenWindow" : IECore.Box2fData( IECore.Box2f( IECore.V2f( -3 ), IECore.V2f( 3 ) ) ) + "resolution" : IECore.V2iData( imath.V2i( 256 ) ), + "clippingPlanes" : IECore.V2fData( imath.V2f( 1, 1000 ) ), + "screenWindow" : IECore.Box2fData( imath.Box2f( imath.V2f( -3 ), imath.V2f( 3 ) ) ) } ) r.display( self.outputFileName, "exr", "rgba", {} ) @@ -176,7 +177,7 @@ def performAimTest( self, projection, expectedImage, particleType ) : p = IECore.V3fVectorData() for x in range( -2, 3 ) : for y in range( -2, 3 ) : - p.append( IECore.V3f( x, y, 0 ) ) + p.append( imath.V3f( x, y, 0 ) ) r = IECoreGL.Renderer() r.setOption( "gl:mode", IECore.StringData( "immediate" ) ) @@ -185,16 +186,16 @@ def performAimTest( self, projection, expectedImage, particleType ) : r.camera( "main", { "projection" : IECore.StringData( projection ), "projection:fov" : IECore.FloatData( 20 ), - "resolution" : IECore.V2iData( IECore.V2i( 256 ) ), - "clippingPlanes" : IECore.V2fData( IECore.V2f( 1, 1000 ) ), - "screenWindow" : IECore.Box2fData( IECore.Box2f( IECore.V2f( -3 ), IECore.V2f( 3 ) ) ) + "resolution" : IECore.V2iData( imath.V2i( 256 ) ), + "clippingPlanes" : IECore.V2fData( imath.V2f( 1, 1000 ) ), + "screenWindow" : IECore.Box2fData( imath.Box2f( imath.V2f( -3 ), imath.V2f( 3 ) ) ) } ) r.display( self.outputFileName, "exr", "rgba", {} ) with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -6 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -6 ) ) ) r.shader( "surface", "white", { "gl:fragmentSource" : IECore.StringData( fragmentSource ) } ) r.points( p.size(), { @@ -241,16 +242,16 @@ def testGLPoints( self ) : r.camera( "main", { "projection" : IECore.StringData( "orthographic" ), "projection:fov" : IECore.FloatData( 20 ), - "resolution" : IECore.V2iData( IECore.V2i( 256 ) ), - "clippingPlanes" : IECore.V2fData( IECore.V2f( 1, 1000 ) ), - "screenWindow" : IECore.Box2fData( IECore.Box2f( IECore.V2f( -3 ), IECore.V2f( 3 ) ) ) + "resolution" : IECore.V2iData( imath.V2i( 256 ) ), + "clippingPlanes" : IECore.V2fData( imath.V2f( 1, 1000 ) ), + "screenWindow" : IECore.Box2fData( imath.Box2f( imath.V2f( -3 ), imath.V2f( 3 ) ) ) } ) r.display( self.outputFileName, "tif", "rgba", {} ) with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -6 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -6 ) ) ) r.shader( "surface", "white", { "gl:fragmentSource" : IECore.StringData( fragmentSource ) } ) @@ -259,7 +260,7 @@ def testGLPoints( self ) : r.setAttribute( "gl:pointsPrimitive:glPointWidth", IECore.FloatData( 20 ) ) r.points( 1, { - "P" : IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f( 0 ) ] ) ), + "P" : IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f( 0 ) ] ) ), "type" : IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.StringData( "gl:point" ) ) } ) @@ -269,7 +270,7 @@ def testGLPoints( self ) : r.setAttribute( "gl:pointsPrimitive:glPointWidth", IECore.FloatData( 10 ) ) r.points( 1, { - "P" : IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f( 1, 0, 0 ) ] ) ), + "P" : IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f( 1, 0, 0 ) ] ) ), "type" : IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.StringData( "gl:point" ) ) } ) @@ -297,15 +298,15 @@ def testTexturing( self ) : r.setOption( "gl:searchPath:shaderInclude", IECore.StringData( "./glsl" ) ) r.camera( "main", { "projection" : IECore.StringData( "orthographic" ), - "resolution" : IECore.V2iData( IECore.V2i( 1024 ) ), - "clippingPlanes" : IECore.V2fData( IECore.V2f( 1, 1000 ) ), - "screenWindow" : IECore.Box2fData( IECore.Box2f( IECore.V2f( -.5 ), IECore.V2f( .5 ) ) ) + "resolution" : IECore.V2iData( imath.V2i( 1024 ) ), + "clippingPlanes" : IECore.V2fData( imath.V2f( 1, 1000 ) ), + "screenWindow" : IECore.Box2fData( imath.Box2f( imath.V2f( -.5 ), imath.V2f( .5 ) ) ) } ) r.display( self.outputFileName, "exr", "rgba", {} ) with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -6 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -6 ) ) ) r.shader( "surface", "test", @@ -316,7 +317,7 @@ def testTexturing( self ) : ) r.points( 1, { - "P" : IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f( 0 ) ] ) ), + "P" : IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f( 0 ) ] ) ), "type" : IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.StringData( "patch" ) ) } ) @@ -333,25 +334,25 @@ def performTest( rightHandedOrientation, expectedAlpha ) : r.setOption( "gl:searchPath:shaderInclude", IECore.StringData( "./glsl" ) ) r.camera( "main", { "projection" : IECore.StringData( "orthographic" ), - "resolution" : IECore.V2iData( IECore.V2i( 1024 ) ), - "clippingPlanes" : IECore.V2fData( IECore.V2f( 1, 1000 ) ), - "screenWindow" : IECore.Box2fData( IECore.Box2f( IECore.V2f( -.5 ), IECore.V2f( .5 ) ) ) + "resolution" : IECore.V2iData( imath.V2i( 1024 ) ), + "clippingPlanes" : IECore.V2fData( imath.V2f( 1, 1000 ) ), + "screenWindow" : IECore.Box2fData( imath.Box2f( imath.V2f( -.5 ), imath.V2f( .5 ) ) ) } ) r.display( self.outputFileName, "exr", "rgba", {} ) with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -6 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -6 ) ) ) r.setAttribute( "doubleSided", IECore.BoolData( False ) ) r.setAttribute( "rightHandedOrientation", IECore.BoolData( rightHandedOrientation ) ) r.points( 1, { - "P" : IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f( 0 ) ] ) ), + "P" : IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f( 0 ) ] ) ), } ) i = IECore.Reader.create( self.outputFileName ).read() - dimensions = i.dataWindow.size() + IECore.V2i( 1 ) + dimensions = i.dataWindow.size() + imath.V2i( 1 ) index = dimensions.x * int(dimensions.y * 0.5) + int(dimensions.x * 0.5) self.assertEqual( i["A"][index], expectedAlpha ) @@ -367,7 +368,7 @@ def testAspectAndRotation( self ) : } """ - random = IECore.Rand48() + random = imath.Rand48() p = IECore.V3fVectorData() r = IECore.FloatVectorData() @@ -375,7 +376,7 @@ def testAspectAndRotation( self ) : a = IECore.FloatVectorData() for x in range( -2, 3 ) : for y in range( -2, 3 ) : - p.append( IECore.V3f( x, y, 0 ) ) + p.append( imath.V3f( x, y, 0 ) ) r.append( random.nextf( 0, 360 ) ) w.append( random.nextf( 0.25, 0.5 ) ) a.append( random.nextf( 0.5, 2 ) ) @@ -386,16 +387,16 @@ def testAspectAndRotation( self ) : renderer.camera( "main", { "projection" : IECore.StringData( "orthographic" ), - "resolution" : IECore.V2iData( IECore.V2i( 512 ) ), - "clippingPlanes" : IECore.V2fData( IECore.V2f( 1, 1000 ) ), - "screenWindow" : IECore.Box2fData( IECore.Box2f( IECore.V2f( -3 ), IECore.V2f( 3 ) ) ) + "resolution" : IECore.V2iData( imath.V2i( 512 ) ), + "clippingPlanes" : IECore.V2fData( imath.V2f( 1, 1000 ) ), + "screenWindow" : IECore.Box2fData( imath.Box2f( imath.V2f( -3 ), imath.V2f( 3 ) ) ) } ) renderer.display( self.outputFileName, "exr", "rgba", { "quantize" : IECore.FloatVectorData( [ 0, 0, 0, 0 ] ) } ) with IECoreScene.WorldBlock( renderer ) : - renderer.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -6 ) ) ) + renderer.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -6 ) ) ) renderer.shader( "surface", "white", { "gl:fragmentSource" : IECore.StringData( fragmentSource ) } ) renderer.points( p.size(), { @@ -416,17 +417,17 @@ def testBound( self ) : p = IECoreGL.PointsPrimitive( IECoreGL.PointsPrimitive.Type.Point ) - self.assertEqual( p.bound(), IECore.Box3f() ) + self.assertEqual( p.bound(), imath.Box3f() ) p.addPrimitiveVariable( "P", IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, - IECore.V3fVectorData( [ IECore.V3f( -1 ), IECore.V3f( 10 ) ] ) + IECore.V3fVectorData( [ imath.V3f( -1 ), imath.V3f( 10 ) ] ) ) ) - self.assertEqual( p.bound(), IECore.Box3f( IECore.V3f( -1.5 ), IECore.V3f( 10.5 ) ) ) + self.assertEqual( p.bound(), imath.Box3f( imath.V3f( -1.5 ), imath.V3f( 10.5 ) ) ) p.addPrimitiveVariable( "constantwidth", @@ -436,7 +437,7 @@ def testBound( self ) : ) ) - self.assertEqual( p.bound(), IECore.Box3f( IECore.V3f( -2 ), IECore.V3f( 11 ) ) ) + self.assertEqual( p.bound(), imath.Box3f( imath.V3f( -2 ), imath.V3f( 11 ) ) ) p.addPrimitiveVariable( "width", @@ -446,7 +447,7 @@ def testBound( self ) : ) ) - self.assertEqual( p.bound(), IECore.Box3f( IECore.V3f( -1.5 ), IECore.V3f( 12 ) ) ) + self.assertEqual( p.bound(), imath.Box3f( imath.V3f( -1.5 ), imath.V3f( 12 ) ) ) p.addPrimitiveVariable( "patchaspectratio", @@ -456,7 +457,7 @@ def testBound( self ) : ) ) - self.assertEqual( p.bound(), IECore.Box3f( IECore.V3f( -2 ), IECore.V3f( 12 ) ) ) + self.assertEqual( p.bound(), imath.Box3f( imath.V3f( -2 ), imath.V3f( 12 ) ) ) def testUniformShaderParameters( self ) : @@ -473,25 +474,25 @@ def testUniformShaderParameters( self ) : r.setOption( "gl:searchPath:shaderInclude", IECore.StringData( "./glsl" ) ) r.camera( "main", { "projection" : IECore.StringData( "orthographic" ), - "resolution" : IECore.V2iData( IECore.V2i( 1024 ) ), - "clippingPlanes" : IECore.V2fData( IECore.V2f( 1, 1000 ) ), - "screenWindow" : IECore.Box2fData( IECore.Box2f( IECore.V2f( -.5 ), IECore.V2f( .5 ) ) ) + "resolution" : IECore.V2iData( imath.V2i( 1024 ) ), + "clippingPlanes" : IECore.V2fData( imath.V2f( 1, 1000 ) ), + "screenWindow" : IECore.Box2fData( imath.Box2f( imath.V2f( -.5 ), imath.V2f( .5 ) ) ) } ) r.display( self.outputFileName, "exr", "rgba", {} ) with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -6 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -6 ) ) ) - r.shader( "surface", "test", { "gl:fragmentSource" : fragmentSource, "myColor" : IECore.Color3f( 1, 0, 0 ) } ) + r.shader( "surface", "test", { "gl:fragmentSource" : fragmentSource, "myColor" : imath.Color3f( 1, 0, 0 ) } ) r.points( 1, { - "P" : IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f( 0 ) ] ) ), + "P" : IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f( 0 ) ] ) ), } ) i = IECore.Reader.create( self.outputFileName ).read() - dimensions = i.dataWindow.size() + IECore.V2i( 1 ) + dimensions = i.dataWindow.size() + imath.V2i( 1 ) index = dimensions.x * int(dimensions.y * 0.5) + int(dimensions.x * 0.5) self.assertEqual( i["A"][index], 1 ) self.assertEqual( i["R"][index], 1 ) @@ -507,9 +508,9 @@ def testWireframeShading( self ) : "main", { "projection" : IECore.StringData( "orthographic" ), - "resolution" : IECore.V2iData( IECore.V2i( 1024 ) ), - "clippingPlanes" : IECore.V2fData( IECore.V2f( 1, 1000 ) ), - "screenWindow" : IECore.Box2fData( IECore.Box2f( IECore.V2f( -.5 ), IECore.V2f( .5 ) ) ) + "resolution" : IECore.V2iData( imath.V2i( 1024 ) ), + "clippingPlanes" : IECore.V2fData( imath.V2f( 1, 1000 ) ), + "screenWindow" : IECore.Box2fData( imath.Box2f( imath.V2f( -.5 ), imath.V2f( .5 ) ) ) } ) @@ -517,18 +518,18 @@ def testWireframeShading( self ) : with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -6 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -6 ) ) ) r.setAttribute( "gl:primitive:wireframe", True ) - r.setAttribute( "gl:primitive:wireframeColor", IECore.Color4f( 1, 0, 0, 1 ) ) + r.setAttribute( "gl:primitive:wireframeColor", imath.Color4f( 1, 0, 0, 1 ) ) r.setAttribute( "gl:primitive:wireframeWidth", 5.0 ) r.setAttribute( "gl:primitive:solid", False ) r.points( 1, { - "P" : IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f( 0 ) ] ) ), + "P" : IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f( 0 ) ] ) ), } ) i = IECore.Reader.create( self.outputFileName ).read() - dimensions = i.dataWindow.size() + IECore.V2i( 1 ) + dimensions = i.dataWindow.size() + imath.V2i( 1 ) index = dimensions.x * int(dimensions.y * 0.5) + int(dimensions.x * 0.5) self.assertEqual( i["A"][index], 1 ) self.assertEqual( i["R"][index], 1 ) @@ -544,9 +545,9 @@ def testVertexCs( self ) : "main", { "projection" : IECore.StringData( "orthographic" ), - "resolution" : IECore.V2iData( IECore.V2i( 1024 ) ), - "clippingPlanes" : IECore.V2fData( IECore.V2f( 1, 1000 ) ), - "screenWindow" : IECore.Box2fData( IECore.Box2f( IECore.V2f( -1), IECore.V2f( 1 ) ) ) + "resolution" : IECore.V2iData( imath.V2i( 1024 ) ), + "clippingPlanes" : IECore.V2fData( imath.V2f( 1, 1000 ) ), + "screenWindow" : IECore.Box2fData( imath.Box2f( imath.V2f( -1), imath.V2f( 1 ) ) ) } ) @@ -554,15 +555,15 @@ def testVertexCs( self ) : with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -6 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -6 ) ) ) r.points( 2, { - "P" : IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f( -.5 ), IECore.V3f( .5 ) ] ) ), - "Cs" : IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.Color3fVectorData( [ IECore.Color3f( 1, 0, 0 ), IECore.Color3f( 0, 1, 0 ) ] ) ), + "P" : IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f( -.5 ), imath.V3f( .5 ) ] ) ), + "Cs" : IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.Color3fVectorData( [ imath.Color3f( 1, 0, 0 ), imath.Color3f( 0, 1, 0 ) ] ) ), } ) i = IECore.Reader.create( self.outputFileName ).read() - dimensions = i.dataWindow.size() + IECore.V2i( 1 ) + dimensions = i.dataWindow.size() + imath.V2i( 1 ) index = dimensions.x * int(dimensions.y * 0.75) + int(dimensions.x * 0.25) self.assertEqual( i["A"][index], 1 ) self.assertEqual( i["R"][index], 1 ) diff --git a/test/IECoreGL/Renderer.py b/test/IECoreGL/Renderer.py index aaeb5acdbe..51718500ec 100644 --- a/test/IECoreGL/Renderer.py +++ b/test/IECoreGL/Renderer.py @@ -39,6 +39,7 @@ import threading import math import shutil +import imath import IECore import IECoreScene @@ -80,9 +81,9 @@ def testOptions( self ) : self.assertEqual( r.getOption( "searchPath:shader" ), IECore.StringData( "t" ) ) self.assertEqual( r.getOption( "gl:searchPath:shader" ), IECore.StringData( "t" ) ) - self.assertEqual( r.getOption( "shutter" ), IECore.V2fData( IECore.V2f( 0 ) ) ) - r.setOption( "shutter", IECore.V2fData( IECore.V2f( 1, 2 ) ) ) - self.assertEqual( r.getOption( "shutter" ), IECore.V2fData( IECore.V2f( 1, 2 ) ) ) + self.assertEqual( r.getOption( "shutter" ), IECore.V2fData( imath.V2f( 0 ) ) ) + r.setOption( "shutter", IECore.V2fData( imath.V2f( 1, 2 ) ) ) + self.assertEqual( r.getOption( "shutter" ), IECore.V2fData( imath.V2f( 1, 2 ) ) ) self.assertEqual( r.getOption( "gl:drawCoordinateSystems" ), IECore.BoolData( False ) ) r.setOption( "gl:drawCoordinateSystems", IECore.BoolData( True ) ) @@ -101,10 +102,10 @@ def testAttributes( self ) : r.worldBegin() - self.assertEqual( r.getAttribute( "color" ), IECore.Color3fData( IECore.Color3f( 1 ) ) ) - self.assertEqual( r.getAttribute( "opacity" ), IECore.Color3fData( IECore.Color3f( 1 ) ) ) - self.assertEqual( r.getAttribute( "gl:color" ), IECore.Color4fData( IECore.Color4f( 1 ) ) ) - self.assertEqual( r.getAttribute( "gl:blend:color" ), IECore.Color4fData( IECore.Color4f( 1 ) ) ) + self.assertEqual( r.getAttribute( "color" ), IECore.Color3fData( imath.Color3f( 1 ) ) ) + self.assertEqual( r.getAttribute( "opacity" ), IECore.Color3fData( imath.Color3f( 1 ) ) ) + self.assertEqual( r.getAttribute( "gl:color" ), IECore.Color4fData( imath.Color4f( 1 ) ) ) + self.assertEqual( r.getAttribute( "gl:blend:color" ), IECore.Color4fData( imath.Color4f( 1 ) ) ) self.assertEqual( r.getAttribute( "gl:blend:srcFactor" ), IECore.StringData( "srcAlpha" ) ) self.assertEqual( r.getAttribute( "gl:blend:dstFactor" ), IECore.StringData( "oneMinusSrcAlpha" ) ) self.assertEqual( r.getAttribute( "gl:blend:equation" ), IECore.StringData( "add" ) ) @@ -130,26 +131,26 @@ def testAttributes( self ) : self.assertEqual( r.getAttribute( "gl:automaticInstancing" ), IECore.BoolData( True ) ) self.assertEqual( r.getAttribute( "automaticInstancing" ), IECore.BoolData( True ) ) - r.setAttribute( "color", IECore.Color3fData( IECore.Color3f( 0, 1, 2 ) ) ) - self.assertEqual( r.getAttribute( "color" ), IECore.Color3fData( IECore.Color3f( 0, 1, 2 ) ) ) + r.setAttribute( "color", IECore.Color3fData( imath.Color3f( 0, 1, 2 ) ) ) + self.assertEqual( r.getAttribute( "color" ), IECore.Color3fData( imath.Color3f( 0, 1, 2 ) ) ) # opacity is an odd one - it's set as a color but as it's averaged internally # the result you get should be a greyscale value. - r.setAttribute( "opacity", IECore.Color3fData( IECore.Color3f( 3, 1, 2 ) ) ) - self.assertEqual( r.getAttribute( "opacity" ), IECore.Color3fData( IECore.Color3f( 2 ) ) ) + r.setAttribute( "opacity", IECore.Color3fData( imath.Color3f( 3, 1, 2 ) ) ) + self.assertEqual( r.getAttribute( "opacity" ), IECore.Color3fData( imath.Color3f( 2 ) ) ) - self.assertEqual( r.getAttribute( "gl:color" ), IECore.Color4fData( IECore.Color4f( 0, 1, 2, 2 ) ) ) - r.setAttribute( "gl:color", IECore.Color4fData( IECore.Color4f( 1, 2, 3, 4 ) ) ) - self.assertEqual( r.getAttribute( "gl:color" ), IECore.Color4fData( IECore.Color4f( 1, 2, 3, 4 ) ) ) + self.assertEqual( r.getAttribute( "gl:color" ), IECore.Color4fData( imath.Color4f( 0, 1, 2, 2 ) ) ) + r.setAttribute( "gl:color", IECore.Color4fData( imath.Color4f( 1, 2, 3, 4 ) ) ) + self.assertEqual( r.getAttribute( "gl:color" ), IECore.Color4fData( imath.Color4f( 1, 2, 3, 4 ) ) ) - r.setAttribute( "gl:blend:color", IECore.Color4fData( IECore.Color4f( 0, 1, 0, 1 ) ) ) - self.assertEqual( r.getAttribute( "gl:blend:color" ), IECore.Color4fData( IECore.Color4f( 0, 1, 0, 1 ) ) ) + r.setAttribute( "gl:blend:color", IECore.Color4fData( imath.Color4f( 0, 1, 0, 1 ) ) ) + self.assertEqual( r.getAttribute( "gl:blend:color" ), IECore.Color4fData( imath.Color4f( 0, 1, 0, 1 ) ) ) r.attributeBegin() - r.setAttribute( "color", IECore.Color3fData( IECore.Color3f( 0 ) ) ) - self.assertEqual( r.getAttribute( "gl:color" ), IECore.Color4fData( IECore.Color4f( 0, 0, 0, 4 ) ) ) + r.setAttribute( "color", IECore.Color3fData( imath.Color3f( 0 ) ) ) + self.assertEqual( r.getAttribute( "gl:color" ), IECore.Color4fData( imath.Color4f( 0, 0, 0, 4 ) ) ) r.attributeEnd() - self.assertEqual( r.getAttribute( "gl:color" ), IECore.Color4fData( IECore.Color4f( 1, 2, 3, 4 ) ) ) + self.assertEqual( r.getAttribute( "gl:color" ), IECore.Color4fData( imath.Color4f( 1, 2, 3, 4 ) ) ) factors = [ "zero", "one", "srcColor", "oneMinusSrcColor", "dstColor", "oneMinusDstColor", "srcAlpha", "oneMinusSrcAlpha", "dstAlpha", "oneMinusDstAlpha", "dstAlpha", "oneMinusDstAlpha", @@ -259,7 +260,7 @@ def testStackBug( self ) : r.shader( "surface", "rgbColor", { "red" : IECore.FloatData( 1 ), "green" : IECore.FloatData( 0 ), "blue" : IECore.FloatData( 0 ) } ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) r.attributeBegin() @@ -268,16 +269,16 @@ def testStackBug( self ) : r.attributeEnd() - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( -1, 0, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( -1, 0, 0 ) ) ) r.sphere( 1, -1, 1, 360, {} ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 2, 0, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 2, 0, 0 ) ) ) r.sphere( 1, -1, 1, 360, {} ) r.worldEnd() i = IECore.Reader.create( os.path.dirname( __file__ ) + "/output/testStackBug.tif" ).read() - dimensions = i.dataWindow.size() + IECore.V2i( 1 ) + dimensions = i.dataWindow.size() + imath.V2i( 1 ) index = dimensions.x * int(dimensions.y * 0.5) + int(dimensions.x * 0.5) self.assertEqual( i["R"][index], 1 ) self.assertEqual( i["G"][index], 1 ) @@ -303,7 +304,7 @@ def testPrimVars( self ) : r.shader( "surface", "rgbColor", {} ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) r.attributeBegin() @@ -319,7 +320,7 @@ def testPrimVars( self ) : r.attributeEnd() - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( -1, 0, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( -1, 0, 0 ) ) ) r.sphere( 1, -1, 1, 360, { @@ -329,7 +330,7 @@ def testPrimVars( self ) : } ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 2, 0, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 2, 0, 0 ) ) ) r.sphere( 1, -1, 1, 360, { @@ -342,7 +343,7 @@ def testPrimVars( self ) : r.worldEnd() i = IECore.Reader.create( os.path.dirname( __file__ ) + "/output/testPrimVars.tif" ).read() - dimensions = i.dataWindow.size() + IECore.V2i( 1 ) + dimensions = i.dataWindow.size() + imath.V2i( 1 ) index = dimensions.x * int(dimensions.y * 0.5) self.assertEqual( i["R"][index], 0 ) self.assertEqual( i["G"][index], 1 ) @@ -367,8 +368,8 @@ def testShader( self ) : r.setOption( "gl:searchPath:shaderInclude", IECore.StringData( os.path.dirname( __file__ ) + "/shaders/include" ) ) r.worldBegin() - r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( IECore.Color3f( 1, 0, 0 ) ) } ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( imath.Color3f( 1, 0, 0 ) ) } ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) r.sphere( 1, -1, 1, 360, {} ) r.worldEnd() @@ -395,7 +396,7 @@ def testEdits( self ): with IECore.CapturingMessageHandler() as handler : r.attributeBegin() - r.setAttribute( "gl:color", IECore.Color4fData( IECore.Color4f( 1, 2, 3, 4 ) ) ) + r.setAttribute( "gl:color", IECore.Color4fData( imath.Color4f( 1, 2, 3, 4 ) ) ) r.attributeEnd() self.assertEqual( len( handler.messages ), 3 ) @@ -404,7 +405,7 @@ def testEdits( self ): r.command( "editBegin", {} ) r.attributeBegin() - r.setAttribute( "gl:color", IECore.Color4fData( IECore.Color4f( 1, 2, 3, 4 ) ) ) + r.setAttribute( "gl:color", IECore.Color4fData( imath.Color4f( 1, 2, 3, 4 ) ) ) r.attributeEnd() r.command( "editEnd", {} ) @@ -501,7 +502,7 @@ def __init__( proc ): IECoreScene.Renderer.Procedural.__init__( proc ) def bound( proc ) : - return IECore.Box3f( IECore.V3f( -1 ), IECore.V3f( 1 ) ) + return imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ) def render( proc, renderer ): commandResult = renderer.command( "removeObject", { "name" : IECore.StringData( "sphereOne" ) } ) @@ -534,10 +535,10 @@ def testRemoveObjectWithResourcesDuringProcedural( self ) : IECore.SplinefColor3f( IECore.CubicBasisf.catmullRom(), ( - ( 0, IECore.Color3f( 1 ) ), - ( 0, IECore.Color3f( 1 ) ), - ( 1, IECore.Color3f( 0 ) ), - ( 1, IECore.Color3f( 0 ) ), + ( 0, imath.Color3f( 1 ) ), + ( 0, imath.Color3f( 1 ) ), + ( 1, imath.Color3f( 0 ) ), + ( 1, imath.Color3f( 0 ) ), ), ), ), @@ -558,7 +559,7 @@ def __init__( proc, level=0 ) : def bound( proc ) : - return IECore.Box3f( IECore.V3f( -1 ), IECore.V3f( 1 ) ) + return imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ) def render( proc, renderer ): @@ -600,7 +601,7 @@ def threadedRendering(): r.worldBegin() r.shader( "surface", "failWithoutPreprocessing", {} ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) r.worldEnd() allScenes.append( r.scene() ) @@ -627,26 +628,26 @@ def __init__( self, level = 0 ): self.threadsUsed.clear() def bound( self ) : - return IECore.Box3f( IECore.V3f( -1 ), IECore.V3f( 1 ) ) + return imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ) def render( self, renderer ): # registers this thread id self.threadsUsed.add( threading.currentThread().getName() ) renderer.attributeBegin() - renderer.setAttribute( "color", IECore.Color3fData( IECore.Color3f( float(self.__level)/self.maxLevel, 0, 1 - float(self.__level)/self.maxLevel ) ) ) + renderer.setAttribute( "color", IECore.Color3fData( imath.Color3f( float(self.__level)/self.maxLevel, 0, 1 - float(self.__level)/self.maxLevel ) ) ) renderer.transformBegin() - renderer.concatTransform( IECore.M44f.createTranslated(IECore.V3f( 0, 0.5, 0 )) ) - renderer.concatTransform( IECore.M44f.createScaled( IECore.V3f(0.5) ) ) + renderer.concatTransform( imath.M44f().translate(imath.V3f( 0, 0.5, 0 )) ) + renderer.concatTransform( imath.M44f().scale( imath.V3f(0.5) ) ) renderer.sphere( 1, -1, 1, 360, {} ) renderer.transformEnd() # end of recursion if self.__level < self.maxLevel : renderer.transformBegin() - renderer.concatTransform( IECore.M44f.createTranslated(IECore.V3f( 0, -0.5, 0 )) ) + renderer.concatTransform( imath.M44f().translate(imath.V3f( 0, -0.5, 0 )) ) for i in xrange( 0, 2 ) : renderer.transformBegin() - renderer.concatTransform( IECore.M44f.createTranslated(IECore.V3f( (i - 0.5) , 0, 0)) ) - renderer.concatTransform( IECore.M44f.createScaled( IECore.V3f(0.5) ) ) + renderer.concatTransform( imath.M44f().translate(imath.V3f( (i - 0.5) , 0, 0)) ) + renderer.concatTransform( imath.M44f().scale( imath.V3f(0.5) ) ) proc = TestRenderer.RecursiveProcedural( self.__level + 1 ) renderer.procedural( proc ) renderer.transformEnd() @@ -729,15 +730,15 @@ def renderWithCulling( box ): r.worldEnd() return self.__countChildrenRecursive( r.scene().root() ) - noCullingCounter = renderWithCulling( IECore.Box3f() ) + noCullingCounter = renderWithCulling( imath.Box3f() ) # verify that only half of the things are renderer when the giving culling box is defined. - self.assertEqual( renderWithCulling( IECore.Box3f( IECore.V3f(2,-1,-1), IECore.V3f(3,1,1) ) ) * 2, noCullingCounter ) + self.assertEqual( renderWithCulling( imath.Box3f( imath.V3f(2,-1,-1), imath.V3f(3,1,1) ) ) * 2, noCullingCounter ) def testWorldSpaceCulling( self ): p = self.RecursiveProcedural() - box = IECore.Box3f( IECore.V3f(0.001,-1,-1), IECore.V3f(1,1,1) ) + box = imath.Box3f( imath.V3f(0.001,-1,-1), imath.V3f(1,1,1) ) r = IECoreGL.Renderer() r.setOption( "gl:mode", IECore.StringData( "deferred" ) ) @@ -748,7 +749,7 @@ def testWorldSpaceCulling( self ): r.procedural( p ) # half-inside: 32 elements (full procedural renders 63 elements) r.transformBegin() if True: - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f(-2, 0, 0) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f(-2, 0, 0) ) ) # everything in this block is culled r.sphere( 1, 0, 1, 360, {} ) r.procedural( p ) @@ -760,43 +761,43 @@ def testTransformsInImmediateRenderer( self ): r = IECoreGL.Renderer() r.setOption( "gl:mode", IECore.StringData( "immediate" ) ) r.transformBegin() - r.concatTransform( IECore.M44f.createRotated( IECore.V3f( 1, 1, 1 ) ) ) - r.camera( "main", { "resolution" : IECore.V2iData( IECore.V2i( 512 ) ), "projection" : IECore.StringData( "perspective" ) } ) + r.concatTransform( imath.M44f().rotate( imath.V3f( 1, 1, 1 ) ) ) + r.camera( "main", { "resolution" : IECore.V2iData( imath.V2i( 512 ) ), "projection" : IECore.StringData( "perspective" ) } ) r.transformEnd() r.worldBegin() # confirm that the camera transformation is not affecting the world space matrix - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 1, 0, 0 ) ) ) - self.assert_( r.getTransform().equalWithAbsError( IECore.M44f.createTranslated( IECore.V3f( 1, 0, 0 ) ), 1e-4 ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 1, 0, 0 ) ) ) + self.assert_( r.getTransform().equalWithAbsError( imath.M44f().translate( imath.V3f( 1, 0, 0 ) ), 1e-4 ) ) # confirm that setting the world space transform does not affect the camera matrix (that was already set in openGL ) - r.setTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 1, 0 ) ) ) - self.assert_( r.getTransform().equalWithAbsError( IECore.M44f.createTranslated( IECore.V3f( 0, 1, 0 ) ), 1e-4 ) ) + r.setTransform( imath.M44f().translate( imath.V3f( 0, 1, 0 ) ) ) + self.assert_( r.getTransform().equalWithAbsError( imath.M44f().translate( imath.V3f( 0, 1, 0 ) ), 1e-4 ) ) r.worldEnd() def testTransformsInDeferredRenderer( self ): r = IECoreGL.Renderer() r.setOption( "gl:mode", IECore.StringData( "deferred" ) ) r.transformBegin() - r.concatTransform( IECore.M44f.createRotated( IECore.V3f( 1, 1, 1 ) ) ) - r.camera( "main", { "resolution" : IECore.V2iData( IECore.V2i( 512 ) ), "projection" : IECore.StringData( "perspective" ) } ) + r.concatTransform( imath.M44f().rotate( imath.V3f( 1, 1, 1 ) ) ) + r.camera( "main", { "resolution" : IECore.V2iData( imath.V2i( 512 ) ), "projection" : IECore.StringData( "perspective" ) } ) r.transformEnd() r.worldBegin() # confirm that the camera transformation is not affecting the world space matrix - self.assert_( r.getTransform().equalWithAbsError( IECore.M44f(), 1e-4 ) ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 1, 0, 0 ) ) ) - r.concatTransform( IECore.M44f.createRotated( IECore.V3f( 1, 1, 1 ) ) ) + self.assert_( r.getTransform().equalWithAbsError( imath.M44f(), 1e-4 ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 1, 0, 0 ) ) ) + r.concatTransform( imath.M44f().rotate( imath.V3f( 1, 1, 1 ) ) ) m = r.getTransform() r.transformBegin() if True: # confirm that the transformBegin did not change the current transform self.assert_( r.getTransform().equalWithAbsError( m, 1e-4 ) ) # confirm that concatenate transform works - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 1, 0, 0 ) ) ) - self.assert_( r.getTransform().equalWithAbsError( IECore.M44f.createTranslated( IECore.V3f( 1, 0, 0 ) ) * m, 1e-4 ) ) - r.concatTransform( IECore.M44f.createScaled( IECore.V3f(0.5) ) ) - self.assert_( r.getTransform().equalWithAbsError( IECore.M44f.createScaled( IECore.V3f(0.5) ) * IECore.M44f.createTranslated( IECore.V3f( 1, 0, 0 ) ) * m, 1e-4 ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 1, 0, 0 ) ) ) + self.assert_( r.getTransform().equalWithAbsError( imath.M44f().translate( imath.V3f( 1, 0, 0 ) ) * m, 1e-4 ) ) + r.concatTransform( imath.M44f().scale( imath.V3f(0.5) ) ) + self.assert_( r.getTransform().equalWithAbsError( imath.M44f().scale( imath.V3f(0.5) ) * imath.M44f().translate( imath.V3f( 1, 0, 0 ) ) * m, 1e-4 ) ) # confirm that setting the world space transform works too - m2 = IECore.M44f.createTranslated( IECore.V3f( 0, 1, 0 ) ) + m2 = imath.M44f().translate( imath.V3f( 0, 1, 0 ) ) r.setTransform( m2 ) self.assert_( r.getTransform().equalWithAbsError( m2, 1e-4 ) ) @@ -805,8 +806,8 @@ def testTransformsInDeferredRenderer( self ): # confirm that the attributeBegin did not change the current transform self.assert_( r.getTransform().equalWithAbsError( m2, 1e-4 ) ) # confirm that setting the world space transform works too - r.setTransform( IECore.M44f.createRotated( IECore.V3f( 3, 1, 0 ) ) ) - self.assert_( r.getTransform().equalWithAbsError( IECore.M44f.createRotated( IECore.V3f( 3, 1, 0 ) ), 1e-4 ) ) + r.setTransform( imath.M44f().rotate( imath.V3f( 3, 1, 0 ) ) ) + self.assert_( r.getTransform().equalWithAbsError( imath.M44f().rotate( imath.V3f( 3, 1, 0 ) ), 1e-4 ) ) r.attributeEnd() # confirms that attributeEnd recovers the matrix. self.assert_( r.getTransform().equalWithAbsError( m2, 1e-4 ) ) @@ -821,37 +822,37 @@ def testInstances(self): r = IECoreGL.Renderer() r.instanceBegin( "instanceA", {} ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 1, 0, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 1, 0, 0 ) ) ) r.transformBegin() - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 1, 0, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 1, 0, 0 ) ) ) r.sphere( 1, -1, 1, 360, {} ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 1, 0, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 1, 0, 0 ) ) ) r.sphere( 1, -1, 1, 360, {} ) r.transformEnd() - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( -1, 0, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( -1, 0, 0 ) ) ) r.sphere( 1, -1, 1, 360, {} ) r.instanceEnd() r.instanceBegin( "instanceB", {} ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, 10 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, 10 ) ) ) r.instance( "instanceA" ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, 20 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, 20 ) ) ) r.instance( "instanceA" ) r.instanceEnd() r.setOption( "gl:mode", IECore.StringData( "deferred" ) ) r.worldBegin() - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 5, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 5, 0 ) ) ) r.instance( "instanceB" ) - r.setTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 10, 0 ) ) ) + r.setTransform( imath.M44f().translate( imath.V3f( 0, 10, 0 ) ) ) r.instance( "instanceB" ) r.worldEnd() g = r.scene().root() self.assertEqual( self.__countChildrenRecursive( g ), 12 ) - self.assert_( g.bound().min.equalWithAbsError( IECore.V3f( -1, 4, 9 ), 0.001 ) ) - self.assert_( g.bound().max.equalWithAbsError( IECore.V3f( 4, 11, 31 ), 0.001 ) ) + self.assert_( g.bound().min().equalWithAbsError( imath.V3f( -1, 4, 9 ), 0.001 ) ) + self.assert_( g.bound().max().equalWithAbsError( imath.V3f( 4, 11, 31 ), 0.001 ) ) def testCuriousCrashOnThreadedProceduralsAndAttribute( self ): @@ -862,7 +863,7 @@ def __init__( self, level = 0 ): IECoreScene.Renderer.Procedural.__init__( self ) self.__level = level def bound( self ) : - return IECore.Box3f( IECore.V3f( -1 ), IECore.V3f( 1 ) ) + return imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ) def render( self, renderer ): if self.__level < 2 : for i in xrange( 0, 50 ) : @@ -894,25 +895,25 @@ def doTest( depthTest, r, g, b ) : renderer.camera( "main", { "projection" : IECore.StringData( "orthographic" ), - "resolution" : IECore.V2iData( IECore.V2i( 256 ) ), - "clippingPlanes" : IECore.V2fData( IECore.V2f( 1, 1000 ) ), - "screenWindow" : IECore.Box2fData( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + "resolution" : IECore.V2iData( imath.V2i( 256 ) ), + "clippingPlanes" : IECore.V2fData( imath.V2f( 1, 1000 ) ), + "screenWindow" : IECore.Box2fData( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) } ) renderer.display( os.path.dirname( __file__ ) + "/output/depthTest.tif", "tif", "rgba", {} ) - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) with IECoreScene.WorldBlock( renderer ) : renderer.setAttribute( "gl:depthTest", IECore.BoolData( depthTest ) ) - renderer.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -1 ) ) ) - renderer.shader( "surface", "color", { "colorValue" : IECore.Color3fData( IECore.Color3f( 1, 0, 0 ) ) } ) + renderer.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -1 ) ) ) + renderer.shader( "surface", "color", { "colorValue" : IECore.Color3fData( imath.Color3f( 1, 0, 0 ) ) } ) m.render( renderer ) - renderer.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -1 ) ) ) - renderer.shader( "surface", "color", { "colorValue" : IECore.Color3fData( IECore.Color3f( 0, 1, 0 ) ) } ) + renderer.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -1 ) ) ) + renderer.shader( "surface", "color", { "colorValue" : IECore.Color3fData( imath.Color3f( 0, 1, 0 ) ) } ) m.render( renderer ) i = IECore.Reader.create( os.path.dirname( __file__ ) + "/output/depthTest.tif" ).read() @@ -937,9 +938,9 @@ def doRender( mode, visibility ) : r.camera( "main", { "projection" : IECore.StringData( "perspective" ), "projection:fov" : IECore.FloatData( 20 ), - "resolution" : IECore.V2iData( IECore.V2i( 256 ) ), - "clippingPlanes" : IECore.V2fData( IECore.V2f( 1, 1000 ) ), - "screenWindow" : IECore.Box2fData( IECore.Box2f( IECore.V2f( -3 ), IECore.V2f( 3 ) ) ) + "resolution" : IECore.V2iData( imath.V2i( 256 ) ), + "clippingPlanes" : IECore.V2fData( imath.V2f( 1, 1000 ) ), + "screenWindow" : IECore.Box2fData( imath.Box2f( imath.V2f( -3 ), imath.V2f( 3 ) ) ) } ) if mode=="immediate" : @@ -947,10 +948,10 @@ def doRender( mode, visibility ) : with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) r.setAttribute( "gl:visibility:camera", IECore.BoolData( visibility ) ) - r.points( 1, { "P" : IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f( 0 ) ] ) ) } ) + r.points( 1, { "P" : IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f( 0 ) ] ) ) } ) return r @@ -981,7 +982,7 @@ def testWarningMessages( self ): c = IECore.CapturingMessageHandler() with c : with IECoreScene.WorldBlock( r ): - r.shader( "shader", "color", { "colorValue" : IECore.Color3fData( IECore.Color3f( 1, 0, 0 ) ) } ) + r.shader( "shader", "color", { "colorValue" : IECore.Color3fData( imath.Color3f( 1, 0, 0 ) ) } ) self.assertEqual( len( c.messages ), 1 ) self.assertEqual( c.messages[0].level, IECore.Msg.Level.Warning ) @@ -990,7 +991,7 @@ def testWarningMessages( self ): c = IECore.CapturingMessageHandler() with c : with IECoreScene.WorldBlock( r ): - r.shader( "ri:shader", "color", { "colorValue" : IECore.Color3fData( IECore.Color3f( 1, 0, 0 ) ) } ) + r.shader( "ri:shader", "color", { "colorValue" : IECore.Color3fData( imath.Color3f( 1, 0, 0 ) ) } ) self.assertEqual( len( c.messages ), 0 ) @@ -998,7 +999,7 @@ def testWarningMessages( self ): c = IECore.CapturingMessageHandler() with c : with IECoreScene.WorldBlock( r ): - r.shader( "gl:surface", "color", { "colorValue" : IECore.Color3fData( IECore.Color3f( 1, 0, 0 ) ) } ) + r.shader( "gl:surface", "color", { "colorValue" : IECore.Color3fData( imath.Color3f( 1, 0, 0 ) ) } ) self.assertEqual( len( c.messages ), 0 ) @@ -1007,7 +1008,7 @@ def testWarningMessages( self ): c = IECore.CapturingMessageHandler() with c : with IECoreScene.WorldBlock( r ): - r.shader( "lg:shader", "color", { "colorValue" : IECore.Color3fData( IECore.Color3f( 1, 0, 0 ) ) } ) + r.shader( "lg:shader", "color", { "colorValue" : IECore.Color3fData( imath.Color3f( 1, 0, 0 ) ) } ) self.assertEqual( len( c.messages ), 0 ) @@ -1015,7 +1016,7 @@ def testWarningMessages( self ): c = IECore.CapturingMessageHandler() with c : with IECoreScene.WorldBlock( r ): - r.shader( "gl:nonsense", "color", { "colorValue" : IECore.Color3fData( IECore.Color3f( 1, 0, 0 ) ) } ) + r.shader( "gl:nonsense", "color", { "colorValue" : IECore.Color3fData( imath.Color3f( 1, 0, 0 ) ) } ) self.assertEqual( len( c.messages ), 1 ) self.assertEqual( c.messages[0].level, IECore.Msg.Level.Warning ) diff --git a/test/IECoreGL/Selection.py b/test/IECoreGL/Selection.py index df9c073082..bfcc981968 100644 --- a/test/IECoreGL/Selection.py +++ b/test/IECoreGL/Selection.py @@ -35,6 +35,7 @@ import unittest import inspect import os.path +import imath import IECore import IECoreScene @@ -52,24 +53,24 @@ def testSelect( self ) : with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) r.setAttribute( "name", IECore.StringData( "one" ) ) - r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( IECore.Color3f( 1, 0, 0 ) ) } ) + r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( imath.Color3f( 1, 0, 0 ) ) } ) r.sphere( 1, -1, 1, 360, {} ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( -1, 0, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( -1, 0, 0 ) ) ) r.setAttribute( "name", IECore.StringData( "two" ) ) r.sphere( 1, -1, 1, 360, {} ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 2, 0, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 2, 0, 0 ) ) ) r.setAttribute( "name", IECore.StringData( "three" ) ) r.sphere( 1, -1, 1, 360, {} ) s = r.scene() s.setCamera( IECoreGL.PerspectiveCamera() ) - ss = s.select( IECoreGL.Selector.Mode.GLSelect, IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) ) + ss = s.select( IECoreGL.Selector.Mode.GLSelect, imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) names = [ IECoreGL.NameStateComponent.nameFromGLName( x.name ) for x in ss ] self.assertEqual( len( names ), 3 ) self.assert_( "one" in names ) @@ -84,44 +85,44 @@ def testRegionSelect( self ) : with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) - r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( IECore.Color3f( 1, 0, 0 ) ) } ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( -2, -2, 0 ) ) ) + r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( imath.Color3f( 1, 0, 0 ) ) } ) + r.concatTransform( imath.M44f().translate( imath.V3f( -2, -2, 0 ) ) ) r.setAttribute( "name", IECore.StringData( "red" ) ) r.sphere( 1, -1, 1, 360, {} ) - r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( IECore.Color3f( 0, 1, 0 ) ) } ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 4, 0 ) ) ) + r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( imath.Color3f( 0, 1, 0 ) ) } ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 4, 0 ) ) ) r.setAttribute( "name", IECore.StringData( "green" ) ) r.sphere( 1, -1, 1, 360, {} ) - r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( IECore.Color3f( 0, 0, 1 ) ) } ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 4, 0, 0 ) ) ) + r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( imath.Color3f( 0, 0, 1 ) ) } ) + r.concatTransform( imath.M44f().translate( imath.V3f( 4, 0, 0 ) ) ) r.setAttribute( "name", IECore.StringData( "blue" ) ) r.sphere( 1, -1, 1, 360, {} ) - r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( IECore.Color3f( 1, 1, 1 ) ) } ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, -4, 0 ) ) ) + r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( imath.Color3f( 1, 1, 1 ) ) } ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, -4, 0 ) ) ) r.setAttribute( "name", IECore.StringData( "white" ) ) r.sphere( 1, -1, 1, 360, {} ) s = r.scene() s.setCamera( IECoreGL.PerspectiveCamera() ) - ss = s.select( IECoreGL.Selector.Mode.GLSelect, IECore.Box2f( IECore.V2f( 0, 0.5 ), IECore.V2f( 0.5, 1 ) ) ) + ss = s.select( IECoreGL.Selector.Mode.GLSelect, imath.Box2f( imath.V2f( 0, 0.5 ), imath.V2f( 0.5, 1 ) ) ) self.assertEqual( len( ss ), 1 ) self.assertEqual( IECoreGL.NameStateComponent.nameFromGLName( ss[0].name ), "red" ) - ss = s.select( IECoreGL.Selector.Mode.GLSelect, IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 0.5 ) ) ) + ss = s.select( IECoreGL.Selector.Mode.GLSelect, imath.Box2f( imath.V2f( 0 ), imath.V2f( 0.5 ) ) ) self.assertEqual( len( ss ), 1 ) self.assertEqual( IECoreGL.NameStateComponent.nameFromGLName( ss[0].name ), "green" ) - ss = s.select( IECoreGL.Selector.Mode.GLSelect, IECore.Box2f( IECore.V2f( 0.5, 0 ), IECore.V2f( 1, 0.5 ) ) ) + ss = s.select( IECoreGL.Selector.Mode.GLSelect, imath.Box2f( imath.V2f( 0.5, 0 ), imath.V2f( 1, 0.5 ) ) ) self.assertEqual( len( ss ), 1 ) self.assertEqual( IECoreGL.NameStateComponent.nameFromGLName( ss[0].name ), "blue" ) - ss = s.select( IECoreGL.Selector.Mode.GLSelect, IECore.Box2f( IECore.V2f( 0.5 ), IECore.V2f( 1 ) ) ) + ss = s.select( IECoreGL.Selector.Mode.GLSelect, imath.Box2f( imath.V2f( 0.5 ), imath.V2f( 1 ) ) ) self.assertEqual( len( ss ), 1 ) self.assertEqual( IECoreGL.NameStateComponent.nameFromGLName( ss[0].name ), "white" ) @@ -132,32 +133,32 @@ def testIDSelect( self ) : with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( -1, 0, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( -1, 0, 0 ) ) ) r.setAttribute( "name", IECore.StringData( "frontLeft" ) ) r.sphere( 1, -1, 1, 360, {} ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -1 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -1 ) ) ) r.setAttribute( "name", IECore.StringData( "backLeft" ) ) r.sphere( 1, -1, 1, 360, {} ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 2, 0, 1 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 2, 0, 1 ) ) ) r.setAttribute( "name", IECore.StringData( "frontRight" ) ) r.sphere( 1, -1, 1, 360, {} ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -1 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -1 ) ) ) r.setAttribute( "name", IECore.StringData( "backRight" ) ) r.sphere( 1, -1, 1, 360, {} ) s = r.scene() s.setCamera( IECoreGL.OrthographicCamera() ) - ss = s.select( IECoreGL.Selector.Mode.IDRender, IECore.Box2f( IECore.V2f( 0.25, 0.5 ), IECore.V2f( 0.26, 0.51 ) ) ) + ss = s.select( IECoreGL.Selector.Mode.IDRender, imath.Box2f( imath.V2f( 0.25, 0.5 ), imath.V2f( 0.26, 0.51 ) ) ) self.assertEqual( len( ss ), 1 ) self.assertEqual( IECoreGL.NameStateComponent.nameFromGLName( ss[0].name ), "frontLeft" ) - ss = s.select( IECoreGL.Selector.Mode.IDRender, IECore.Box2f( IECore.V2f( 0.75, 0.5 ), IECore.V2f( 0.76, 0.51 ) ) ) + ss = s.select( IECoreGL.Selector.Mode.IDRender, imath.Box2f( imath.V2f( 0.75, 0.5 ), imath.V2f( 0.76, 0.51 ) ) ) self.assertEqual( len( ss ), 1 ) self.assertEqual( IECoreGL.NameStateComponent.nameFromGLName( ss[0].name ), "frontRight" ) @@ -168,7 +169,7 @@ def testIDSelectDepths( self ) : with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) r.setAttribute( "name", IECore.StringData( "ball" ) ) r.sphere( 1, -1, 1, 360, {} ) @@ -176,11 +177,11 @@ def testIDSelectDepths( self ) : scene = r.scene() scene.setCamera( IECoreGL.OrthographicCamera() ) - s1 = scene.select( IECoreGL.Selector.Mode.GLSelect, IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) ) + s1 = scene.select( IECoreGL.Selector.Mode.GLSelect, imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) self.assertEqual( len( s1 ), 1 ) self.assertEqual( IECoreGL.NameStateComponent.nameFromGLName( s1[0].name ), "ball" ) - s2 = scene.select( IECoreGL.Selector.Mode.IDRender, IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) ) + s2 = scene.select( IECoreGL.Selector.Mode.IDRender, imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) self.assertEqual( len( s2 ), 1 ) self.assertEqual( IECoreGL.NameStateComponent.nameFromGLName( s2[0].name ), "ball" ) @@ -193,32 +194,32 @@ def testOcclusionQuerySelect( self ) : with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( -1, 0, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( -1, 0, 0 ) ) ) r.setAttribute( "name", IECore.StringData( "frontLeft" ) ) r.sphere( 1, -1, 1, 360, {} ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -1 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -1 ) ) ) r.setAttribute( "name", IECore.StringData( "backLeft" ) ) r.sphere( 1, -1, 1, 360, {} ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 2, 0, 1 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 2, 0, 1 ) ) ) r.setAttribute( "name", IECore.StringData( "frontRight" ) ) r.sphere( 1, -1, 1, 360, {} ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -1 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -1 ) ) ) r.setAttribute( "name", IECore.StringData( "backRight" ) ) r.sphere( 1, -1, 1, 360, {} ) s = r.scene() s.setCamera( IECoreGL.OrthographicCamera() ) - ss = s.select( IECoreGL.Selector.Mode.OcclusionQuery, IECore.Box2f( IECore.V2f( 0, 0 ), IECore.V2f( 0.25, 1 ) ) ) + ss = s.select( IECoreGL.Selector.Mode.OcclusionQuery, imath.Box2f( imath.V2f( 0, 0 ), imath.V2f( 0.25, 1 ) ) ) self.assertEqual( len( ss ), 2 ) self.assertEqual( set( [ IECoreGL.NameStateComponent.nameFromGLName( x.name ) for x in ss ] ), set( ( "frontLeft", "backLeft" ) ) ) - ss = s.select( IECoreGL.Selector.Mode.OcclusionQuery, IECore.Box2f( IECore.V2f( 0.75, 0 ), IECore.V2f( 1, 1 ) ) ) + ss = s.select( IECoreGL.Selector.Mode.OcclusionQuery, imath.Box2f( imath.V2f( 0.75, 0 ), imath.V2f( 1, 1 ) ) ) self.assertEqual( len( ss ), 2 ) self.assertEqual( set( [ IECoreGL.NameStateComponent.nameFromGLName( x.name ) for x in ss ] ), set( ( "frontRight", "backRight" ) ) ) @@ -234,32 +235,32 @@ def testIDSelectWithAdditionalDisplayStyles( self ) : r.setAttribute( "gl:primitive:outline", IECore.BoolData( True ) ) r.setAttribute( "gl:primitive:points", IECore.BoolData( True ) ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( -1, 0, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( -1, 0, 0 ) ) ) r.setAttribute( "name", IECore.StringData( "frontLeft" ) ) r.sphere( 1, -1, 1, 360, {} ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -1 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -1 ) ) ) r.setAttribute( "name", IECore.StringData( "backLeft" ) ) r.sphere( 1, -1, 1, 360, {} ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 2, 0, 1 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 2, 0, 1 ) ) ) r.setAttribute( "name", IECore.StringData( "frontRight" ) ) r.sphere( 1, -1, 1, 360, {} ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -1 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -1 ) ) ) r.setAttribute( "name", IECore.StringData( "backRight" ) ) r.sphere( 1, -1, 1, 360, {} ) s = r.scene() s.setCamera( IECoreGL.OrthographicCamera() ) - ss = s.select( IECoreGL.Selector.Mode.IDRender, IECore.Box2f( IECore.V2f( 0.25, 0.5 ), IECore.V2f( 0.26, 0.51 ) ) ) + ss = s.select( IECoreGL.Selector.Mode.IDRender, imath.Box2f( imath.V2f( 0.25, 0.5 ), imath.V2f( 0.26, 0.51 ) ) ) self.assertEqual( len( ss ), 1 ) self.assertEqual( IECoreGL.NameStateComponent.nameFromGLName( ss[0].name ), "frontLeft" ) - ss = s.select( IECoreGL.Selector.Mode.IDRender, IECore.Box2f( IECore.V2f( 0.75, 0.5 ), IECore.V2f( 0.76, 0.51 ) ) ) + ss = s.select( IECoreGL.Selector.Mode.IDRender, imath.Box2f( imath.V2f( 0.75, 0.5 ), imath.V2f( 0.76, 0.51 ) ) ) self.assertEqual( len( ss ), 1 ) self.assertEqual( IECoreGL.NameStateComponent.nameFromGLName( ss[0].name ), "frontRight" ) @@ -271,16 +272,16 @@ def testPointsPrimitiveSelect( self ) : with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) r.setAttribute( "name", IECore.StringData( "pointsNeedSelectingToo" ) ) - r.points( 1, { "P" : IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f( 0 ) ] ) ) } ) + r.points( 1, { "P" : IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f( 0 ) ] ) ) } ) s = r.scene() s.setCamera( IECoreGL.PerspectiveCamera() ) for mode in ( IECoreGL.Selector.Mode.GLSelect, IECoreGL.Selector.Mode.OcclusionQuery, IECoreGL.Selector.Mode.IDRender ) : - ss = s.select( mode, IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) ) + ss = s.select( mode, imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) names = [ IECoreGL.NameStateComponent.nameFromGLName( x.name ) for x in ss ] self.assertEqual( len( names ), 1 ) self.assertEqual( names[0], "pointsNeedSelectingToo" ) @@ -293,7 +294,7 @@ def testCurvesPrimitiveSelect( self ) : with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) r.setAttribute( "name", IECore.StringData( "curvesNeedSelectingToo" ) ) @@ -304,7 +305,7 @@ def testCurvesPrimitiveSelect( self ) : { "P" : IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, - IECore.V3fVectorData( [ IECore.V3f( -1, -1, 0, ), IECore.V3f( 1, 1, 0 ) ] ) + IECore.V3fVectorData( [ imath.V3f( -1, -1, 0, ), imath.V3f( 1, 1, 0 ) ] ) ) } ) @@ -313,7 +314,7 @@ def testCurvesPrimitiveSelect( self ) : s.setCamera( IECoreGL.PerspectiveCamera() ) for mode in ( IECoreGL.Selector.Mode.GLSelect, IECoreGL.Selector.Mode.OcclusionQuery, IECoreGL.Selector.Mode.IDRender ) : - ss = s.select( mode, IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) ) + ss = s.select( mode, imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) names = [ IECoreGL.NameStateComponent.nameFromGLName( x.name ) for x in ss ] self.assertEqual( len( names ), 1 ) self.assertEqual( names[0], "curvesNeedSelectingToo" ) @@ -326,7 +327,7 @@ def testCurvesPrimitiveSelectUsingLines( self ) : with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) r.setAttribute( "name", IECore.StringData( "curvesNeedSelectingToo" ) ) r.setAttribute( "gl:curvesPrimitive:useGLLines", IECore.BoolData( True ) ) @@ -338,7 +339,7 @@ def testCurvesPrimitiveSelectUsingLines( self ) : { "P" : IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, - IECore.V3fVectorData( [ IECore.V3f( -1, -1, 0, ), IECore.V3f( 1, 1, 0 ) ] ) + IECore.V3fVectorData( [ imath.V3f( -1, -1, 0, ), imath.V3f( 1, 1, 0 ) ] ) ) } ) @@ -347,7 +348,7 @@ def testCurvesPrimitiveSelectUsingLines( self ) : s.setCamera( IECoreGL.PerspectiveCamera() ) for mode in ( IECoreGL.Selector.Mode.GLSelect, IECoreGL.Selector.Mode.OcclusionQuery, IECoreGL.Selector.Mode.IDRender ) : - ss = s.select( mode, IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) ) + ss = s.select( mode, imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) names = [ IECoreGL.NameStateComponent.nameFromGLName( x.name ) for x in ss ] self.assertEqual( len( names ), 1 ) self.assertEqual( names[0], "curvesNeedSelectingToo" ) @@ -360,7 +361,7 @@ def testCurvesPrimitiveSelectUsingWireframeLines( self ) : with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) r.setAttribute( "name", IECore.StringData( "curvesNeedSelectingToo" ) ) r.setAttribute( "gl:curvesPrimitive:useGLLines", IECore.BoolData( True ) ) @@ -374,7 +375,7 @@ def testCurvesPrimitiveSelectUsingWireframeLines( self ) : { "P" : IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, - IECore.V3fVectorData( [ IECore.V3f( -1, -1, 0, ), IECore.V3f( 1, 1, 0 ) ] ) + IECore.V3fVectorData( [ imath.V3f( -1, -1, 0, ), imath.V3f( 1, 1, 0 ) ] ) ) } ) @@ -383,7 +384,7 @@ def testCurvesPrimitiveSelectUsingWireframeLines( self ) : s.setCamera( IECoreGL.PerspectiveCamera() ) for mode in ( IECoreGL.Selector.Mode.GLSelect, IECoreGL.Selector.Mode.OcclusionQuery, IECoreGL.Selector.Mode.IDRender ) : - ss = s.select( mode, IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) ) + ss = s.select( mode, imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) names = [ IECoreGL.NameStateComponent.nameFromGLName( x.name ) for x in ss ] self.assertEqual( len( names ), 1 ) self.assertEqual( names[0], "curvesNeedSelectingToo" ) @@ -396,13 +397,13 @@ def testContextManager( self ) : with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) r.setAttribute( "name", IECore.StringData( "one" ) ) - r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( IECore.Color3f( 1, 0, 0 ) ) } ) + r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( imath.Color3f( 1, 0, 0 ) ) } ) r.sphere( 1, -1, 1, 360, {} ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( -1, 0, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( -1, 0, 0 ) ) ) r.setAttribute( "name", IECore.StringData( "two" ) ) r.sphere( 1, -1, 1, 360, {} ) @@ -412,7 +413,7 @@ def testContextManager( self ) : IECoreGL.PerspectiveCamera().render( IECoreGL.State.defaultState() ) hits = [] - with IECoreGL.Selector( IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ), IECoreGL.Selector.Mode.IDRender, hits ) as selector : + with IECoreGL.Selector( imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ), IECoreGL.Selector.Mode.IDRender, hits ) as selector : IECoreGL.State.bindBaseState() selector.baseState().bind() scene.root().render( selector.baseState() ) @@ -430,13 +431,13 @@ def testSelectableFlag( self ) : with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) r.setAttribute( "name", IECore.StringData( "selectableObj" ) ) - r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( IECore.Color3f( 1, 0, 0 ) ) } ) + r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( imath.Color3f( 1, 0, 0 ) ) } ) r.sphere( 1, -1, 1, 360, {} ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( -1, 0, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( -1, 0, 0 ) ) ) r.setAttribute( "name", IECore.StringData( "unselectableObj" ) ) r.setAttribute( "gl:primitive:selectable", IECore.BoolData( False ) ) @@ -446,7 +447,7 @@ def testSelectableFlag( self ) : s.setCamera( IECoreGL.PerspectiveCamera() ) for mode in ( IECoreGL.Selector.Mode.GLSelect, IECoreGL.Selector.Mode.OcclusionQuery, IECoreGL.Selector.Mode.IDRender ) : - ss = s.select( mode, IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) ) + ss = s.select( mode, imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) names = [ IECoreGL.NameStateComponent.nameFromGLName( x.name ) for x in ss ] self.assertEqual( names, [ "selectableObj" ] ) @@ -457,10 +458,10 @@ def testIDSelectWithCustomVertexShader( self ) : with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) # translate to the left with the transform stack - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( -1, 0, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( -1, 0, 0 ) ) ) # but translate back to the right using a vertex shader r.shader( @@ -486,7 +487,7 @@ def testIDSelectWithCustomVertexShader( self ) : """ ), - "offset" : IECore.V3f( 2, 0, 0 ), + "offset" : imath.V3f( 2, 0, 0 ), } @@ -499,11 +500,11 @@ def testIDSelectWithCustomVertexShader( self ) : s.setCamera( IECoreGL.OrthographicCamera() ) # on the left should be nothing, because the vertex shader moved it over - ss = s.select( IECoreGL.Selector.Mode.IDRender, IECore.Box2f( IECore.V2f( 0.25, 0.5 ), IECore.V2f( 0.26, 0.51 ) ) ) + ss = s.select( IECoreGL.Selector.Mode.IDRender, imath.Box2f( imath.V2f( 0.25, 0.5 ), imath.V2f( 0.26, 0.51 ) ) ) self.assertEqual( len( ss ), 0 ) # and on the right we should find the sphere - ss = s.select( IECoreGL.Selector.Mode.IDRender, IECore.Box2f( IECore.V2f( 0.75, 0.5 ), IECore.V2f( 0.76, 0.51 ) ) ) + ss = s.select( IECoreGL.Selector.Mode.IDRender, imath.Box2f( imath.V2f( 0.75, 0.5 ), imath.V2f( 0.76, 0.51 ) ) ) self.assertEqual( len( ss ), 1 ) self.assertEqual( IECoreGL.NameStateComponent.nameFromGLName( ss[0].name ), "sphere" ) diff --git a/test/IECoreGL/ShadingTest.py b/test/IECoreGL/ShadingTest.py index 861afb9ab5..1728e58b77 100644 --- a/test/IECoreGL/ShadingTest.py +++ b/test/IECoreGL/ShadingTest.py @@ -36,6 +36,7 @@ import unittest import shutil import inspect +import imath import IECore import IECoreScene @@ -50,8 +51,8 @@ class ShadingTest( unittest.TestCase ) : def mesh( self ) : - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -0.1 ), IECore.V2f( 0.1 ) ) ) - m["N"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f( 0, 0, 1 ) ] * 4 ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -0.1 ), imath.V2f( 0.1 ) ) ) + m["N"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f( 0, 0, 1 ) ] * 4 ) ) return m def constantShader( self ) : @@ -256,9 +257,9 @@ def renderImage( self, group ) : r.camera( "main", { "projection" : "orthographic" , - "resolution" : IECore.V2i( 256 ), - "clippingPlanes" : IECore.V2f( 1, 1000 ), - "screenWindow" : IECore.Box2f( IECore.V2f( -0.5 ), IECore.V2f( 0.5 ) ) + "resolution" : imath.V2i( 256 ), + "clippingPlanes" : imath.V2f( 1, 1000 ), + "screenWindow" : imath.Box2f( imath.V2f( -0.5 ), imath.V2f( 0.5 ) ) } ) r.display( self.__imageFileName, "tif", "rgba", {} ) @@ -267,7 +268,7 @@ def renderImage( self, group ) : with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) group.render( r ) @@ -275,13 +276,13 @@ def renderImage( self, group ) : def assertImageValues( self, image, tests ) : - dimensions = image.dataWindow.size() + IECore.V2i( 1 ) + dimensions = image.dataWindow.size() + imath.V2i( 1 ) for t in tests : index = dimensions.x * int(dimensions.y * t[0].y) + int(dimensions.x * t[0].x) - c = IECore.Color4f( + c = imath.Color4f( image["R"][index], image["G"][index], image["B"][index], @@ -316,8 +317,8 @@ def testBasicPositioning( self ) : self.assertImageValues( image, [ - ( IECore.V2f( 0.5 ), IECore.Color4f( 1, 1, 1, 1 ) ), - ( IECore.V2f( 0.3, 0.5 ), IECore.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 0.5 ), imath.Color4f( 1, 1, 1, 1 ) ), + ( imath.V2f( 0.3, 0.5 ), imath.Color4f( 0, 0, 0, 0 ) ), ] ) @@ -330,8 +331,8 @@ def testUniformBoolParameters( self ) : c2 = c1.copy() c1.state()[0].parameters["rB"] = IECore.BoolData( 1 ) - c1.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( 0.2, 0, 0 ) ) ) ) - c2.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( -0.2, 0, 0 ) ) ) ) + c1.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 0.2, 0, 0 ) ) ) ) + c2.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( -0.2, 0, 0 ) ) ) ) g = IECoreScene.Group() g.addChild( c1 ) @@ -342,8 +343,8 @@ def testUniformBoolParameters( self ) : self.assertImageValues( image, [ - ( IECore.V2f( 0.7, 0.5 ), IECore.Color4f( 1, 0, 0, 1 ) ), - ( IECore.V2f( 0.3, 0.5 ), IECore.Color4f( 0, 0, 0, 1 ) ), + ( imath.V2f( 0.7, 0.5 ), imath.Color4f( 1, 0, 0, 1 ) ), + ( imath.V2f( 0.3, 0.5 ), imath.Color4f( 0, 0, 0, 1 ) ), ] ) @@ -356,8 +357,8 @@ def testUniformFloatParameters( self ) : c2 = c1.copy() c1.state()[0].parameters["rF"] = IECore.FloatData( 1 ) - c1.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( 0.2, 0, 0 ) ) ) ) - c2.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( -0.2, 0, 0 ) ) ) ) + c1.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 0.2, 0, 0 ) ) ) ) + c2.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( -0.2, 0, 0 ) ) ) ) g = IECoreScene.Group() g.addChild( c1 ) @@ -368,8 +369,8 @@ def testUniformFloatParameters( self ) : self.assertImageValues( image, [ - ( IECore.V2f( 0.7, 0.5 ), IECore.Color4f( 1, 0, 0, 1 ) ), - ( IECore.V2f( 0.3, 0.5 ), IECore.Color4f( 0, 0, 0, 1 ) ), + ( imath.V2f( 0.7, 0.5 ), imath.Color4f( 1, 0, 0, 1 ) ), + ( imath.V2f( 0.3, 0.5 ), imath.Color4f( 0, 0, 0, 1 ) ), ] ) @@ -382,8 +383,8 @@ def testUniformIntParameters( self ) : c2 = c1.copy() c1.state()[0].parameters["gI"] = IECore.FloatData( 1 ) - c1.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( 0.2, 0, 0 ) ) ) ) - c2.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( -0.2, 0, 0 ) ) ) ) + c1.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 0.2, 0, 0 ) ) ) ) + c2.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( -0.2, 0, 0 ) ) ) ) g = IECoreScene.Group() g.addChild( c1 ) @@ -394,8 +395,8 @@ def testUniformIntParameters( self ) : self.assertImageValues( image, [ - ( IECore.V2f( 0.7, 0.5 ), IECore.Color4f( 0, 1, 0, 1 ) ), - ( IECore.V2f( 0.3, 0.5 ), IECore.Color4f( 0, 0, 0, 1 ) ), + ( imath.V2f( 0.7, 0.5 ), imath.Color4f( 0, 1, 0, 1 ) ), + ( imath.V2f( 0.3, 0.5 ), imath.Color4f( 0, 0, 0, 1 ) ), ] ) @@ -406,11 +407,11 @@ def testUniform2fParameters( self ) : c1.addState( self.colorShader() ) c2 = c1.copy() - c1.state()[0].parameters["rgF"] = IECore.V2fData( IECore.V2f( 0, 1 ) ) - c2.state()[0].parameters["rgF"] = IECore.V2fData( IECore.V2f( 1, 0 ) ) + c1.state()[0].parameters["rgF"] = IECore.V2fData( imath.V2f( 0, 1 ) ) + c2.state()[0].parameters["rgF"] = IECore.V2fData( imath.V2f( 1, 0 ) ) - c1.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( 0.2, 0, 0 ) ) ) ) - c2.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( -0.2, 0, 0 ) ) ) ) + c1.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 0.2, 0, 0 ) ) ) ) + c2.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( -0.2, 0, 0 ) ) ) ) g = IECoreScene.Group() g.addChild( c1 ) @@ -421,8 +422,8 @@ def testUniform2fParameters( self ) : self.assertImageValues( image, [ - ( IECore.V2f( 0.7, 0.5 ), IECore.Color4f( 0, 1, 0, 1 ) ), - ( IECore.V2f( 0.3, 0.5 ), IECore.Color4f( 1, 0, 0, 1 ) ), + ( imath.V2f( 0.7, 0.5 ), imath.Color4f( 0, 1, 0, 1 ) ), + ( imath.V2f( 0.3, 0.5 ), imath.Color4f( 1, 0, 0, 1 ) ), ] ) @@ -433,11 +434,11 @@ def testUniform2iParameters( self ) : c1.addState( self.colorShader() ) c2 = c1.copy() - c1.state()[0].parameters["rgF"] = IECore.V2iData( IECore.V2i( 0, 1 ) ) - c2.state()[0].parameters["rgF"] = IECore.V2iData( IECore.V2i( 1, 0 ) ) + c1.state()[0].parameters["rgF"] = IECore.V2iData( imath.V2i( 0, 1 ) ) + c2.state()[0].parameters["rgF"] = IECore.V2iData( imath.V2i( 1, 0 ) ) - c1.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( 0.2, 0, 0 ) ) ) ) - c2.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( -0.2, 0, 0 ) ) ) ) + c1.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 0.2, 0, 0 ) ) ) ) + c2.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( -0.2, 0, 0 ) ) ) ) g = IECoreScene.Group() g.addChild( c1 ) @@ -448,8 +449,8 @@ def testUniform2iParameters( self ) : self.assertImageValues( image, [ - ( IECore.V2f( 0.7, 0.5 ), IECore.Color4f( 0, 1, 0, 1 ) ), - ( IECore.V2f( 0.3, 0.5 ), IECore.Color4f( 1, 0, 0, 1 ) ), + ( imath.V2f( 0.7, 0.5 ), imath.Color4f( 0, 1, 0, 1 ) ), + ( imath.V2f( 0.3, 0.5 ), imath.Color4f( 1, 0, 0, 1 ) ), ] ) @@ -460,11 +461,11 @@ def testUniform3fParameters( self ) : c1.addState( self.colorShader() ) c2 = c1.copy() - c1.state()[0].parameters["rgbF"] = IECore.V3fData( IECore.V3f( 0, 1, 1 ) ) - c2.state()[0].parameters["rgbF"] = IECore.V3fData( IECore.V3f( 1, 1, 0 ) ) + c1.state()[0].parameters["rgbF"] = IECore.V3fData( imath.V3f( 0, 1, 1 ) ) + c2.state()[0].parameters["rgbF"] = IECore.V3fData( imath.V3f( 1, 1, 0 ) ) - c1.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( 0.2, 0, 0 ) ) ) ) - c2.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( -0.2, 0, 0 ) ) ) ) + c1.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 0.2, 0, 0 ) ) ) ) + c2.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( -0.2, 0, 0 ) ) ) ) g = IECoreScene.Group() g.addChild( c1 ) @@ -475,8 +476,8 @@ def testUniform3fParameters( self ) : self.assertImageValues( image, [ - ( IECore.V2f( 0.7, 0.5 ), IECore.Color4f( 0, 1, 1, 1 ) ), - ( IECore.V2f( 0.3, 0.5 ), IECore.Color4f( 1, 1, 0, 1 ) ), + ( imath.V2f( 0.7, 0.5 ), imath.Color4f( 0, 1, 1, 1 ) ), + ( imath.V2f( 0.3, 0.5 ), imath.Color4f( 1, 1, 0, 1 ) ), ] ) @@ -487,11 +488,11 @@ def testUniform3iParameters( self ) : c1.addState( self.colorShader() ) c2 = c1.copy() - c1.state()[0].parameters["rgbI"] = IECore.V3iData( IECore.V3i( 0, 1, 1 ) ) - c2.state()[0].parameters["rgbI"] = IECore.V3iData( IECore.V3i( 1, 1, 0 ) ) + c1.state()[0].parameters["rgbI"] = IECore.V3iData( imath.V3i( 0, 1, 1 ) ) + c2.state()[0].parameters["rgbI"] = IECore.V3iData( imath.V3i( 1, 1, 0 ) ) - c1.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( 0.2, 0, 0 ) ) ) ) - c2.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( -0.2, 0, 0 ) ) ) ) + c1.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 0.2, 0, 0 ) ) ) ) + c2.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( -0.2, 0, 0 ) ) ) ) g = IECoreScene.Group() g.addChild( c1 ) @@ -502,8 +503,8 @@ def testUniform3iParameters( self ) : self.assertImageValues( image, [ - ( IECore.V2f( 0.7, 0.5 ), IECore.Color4f( 0, 1, 1, 1 ) ), - ( IECore.V2f( 0.3, 0.5 ), IECore.Color4f( 1, 1, 0, 1 ) ), + ( imath.V2f( 0.7, 0.5 ), imath.Color4f( 0, 1, 1, 1 ) ), + ( imath.V2f( 0.3, 0.5 ), imath.Color4f( 1, 1, 0, 1 ) ), ] ) @@ -514,11 +515,11 @@ def testConstantPrimVarTemporarilyOverridesShaderParameter( self ) : c1.addState( self.colorShader() ) c2 = c1.copy() - c1.state()[0].parameters["rgbF"] = IECore.V3iData( IECore.V3i( 0, 1, 1 ) ) - c1.children()[0]["rgbF"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.V3fData( IECore.V3f( 1, 1, 0 ) ) ) + c1.state()[0].parameters["rgbF"] = IECore.V3iData( imath.V3i( 0, 1, 1 ) ) + c1.children()[0]["rgbF"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.V3fData( imath.V3f( 1, 1, 0 ) ) ) - c1.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( 0.2, 0, 0 ) ) ) ) - c2.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( -0.2, 0, 0 ) ) ) ) + c1.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 0.2, 0, 0 ) ) ) ) + c2.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( -0.2, 0, 0 ) ) ) ) g = IECoreScene.Group() g.addChild( c1 ) @@ -529,8 +530,8 @@ def testConstantPrimVarTemporarilyOverridesShaderParameter( self ) : self.assertImageValues( image, [ - ( IECore.V2f( 0.7, 0.5 ), IECore.Color4f( 1, 1, 0, 1 ) ), - ( IECore.V2f( 0.3, 0.5 ), IECore.Color4f( 0, 0, 0, 1 ) ), + ( imath.V2f( 0.7, 0.5 ), imath.Color4f( 1, 1, 0, 1 ) ), + ( imath.V2f( 0.3, 0.5 ), imath.Color4f( 0, 0, 0, 1 ) ), ] ) @@ -541,10 +542,10 @@ def testSplineAsTexture( self ) : c1.addState( self.textureShader() ) c2 = c1.copy() - c1.state()[0].parameters["sampler"] = self.splineGradient( IECore.Color3f( 1, 0, 0 ), IECore.Color3f( 1, 0, 0 ) ) + c1.state()[0].parameters["sampler"] = self.splineGradient( imath.Color3f( 1, 0, 0 ), imath.Color3f( 1, 0, 0 ) ) - c1.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( 0.2, 0, 0 ) ) ) ) - c2.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( -0.2, 0, 0 ) ) ) ) + c1.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 0.2, 0, 0 ) ) ) ) + c2.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( -0.2, 0, 0 ) ) ) ) g = IECoreScene.Group() g.addChild( c1 ) @@ -555,8 +556,8 @@ def testSplineAsTexture( self ) : self.assertImageValues( image, [ - ( IECore.V2f( 0.7, 0.5 ), IECore.Color4f( 1, 0, 0, 1 ) ), - ( IECore.V2f( 0.3, 0.5 ), IECore.Color4f( 0, 0, 0, 1 ) ), + ( imath.V2f( 0.7, 0.5 ), imath.Color4f( 1, 0, 0, 1 ) ), + ( imath.V2f( 0.3, 0.5 ), imath.Color4f( 0, 0, 0, 1 ) ), ] ) @@ -569,8 +570,8 @@ def testImageFileAsTexture( self ) : c2 = c1.copy() c1.state()[0].parameters["sampler"] = IECore.StringData( os.path.dirname( __file__ ) + "/images/yellow.exr" ) - c1.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( 0.2, 0, 0 ) ) ) ) - c2.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( -0.2, 0, 0 ) ) ) ) + c1.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 0.2, 0, 0 ) ) ) ) + c2.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( -0.2, 0, 0 ) ) ) ) g = IECoreScene.Group() g.addChild( c1 ) @@ -581,8 +582,8 @@ def testImageFileAsTexture( self ) : self.assertImageValues( image, [ - ( IECore.V2f( 0.7, 0.5 ), IECore.Color4f( 1, 1, 0, 1 ) ), - ( IECore.V2f( 0.3, 0.5 ), IECore.Color4f( 0, 0, 0, 1 ) ), + ( imath.V2f( 0.7, 0.5 ), imath.Color4f( 1, 1, 0, 1 ) ), + ( imath.V2f( 0.3, 0.5 ), imath.Color4f( 0, 0, 0, 1 ) ), ] ) @@ -608,8 +609,8 @@ def testCompoundDataAsTexture( self ) : c2 = c1.copy() c1.state()[0].parameters["sampler"] = yellowCompoundData - c1.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( 0.2, 0, 0 ) ) ) ) - c2.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( -0.2, 0, 0 ) ) ) ) + c1.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 0.2, 0, 0 ) ) ) ) + c2.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( -0.2, 0, 0 ) ) ) ) g = IECoreScene.Group() g.addChild( c1 ) @@ -620,8 +621,8 @@ def testCompoundDataAsTexture( self ) : self.assertImageValues( image, [ - ( IECore.V2f( 0.7, 0.5 ), IECore.Color4f( 1, 1, 0, 1 ) ), - ( IECore.V2f( 0.3, 0.5 ), IECore.Color4f( 0, 0, 0, 1 ) ), + ( imath.V2f( 0.7, 0.5 ), imath.Color4f( 1, 1, 0, 1 ) ), + ( imath.V2f( 0.3, 0.5 ), imath.Color4f( 0, 0, 0, 1 ) ), ] ) @@ -635,7 +636,7 @@ def testWireframe( self ) : { "gl:primitive:solid" : IECore.BoolData( False ), "gl:primitive:wireframe" : IECore.BoolData( True ), - "gl:primitive:wireframeColor" : IECore.Color4f( 1, 0, 0, 1 ), + "gl:primitive:wireframeColor" : imath.Color4f( 1, 0, 0, 1 ), "gl:primitive:wireframeWidth" : 6.0, } ) @@ -646,8 +647,8 @@ def testWireframe( self ) : self.assertImageValues( image, [ - ( IECore.V2f( 0.5, 0.5 ), IECore.Color4f( 1, 0, 0, 1 ) ), - ( IECore.V2f( 0.55, 0.5 ), IECore.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 0.5, 0.5 ), imath.Color4f( 1, 0, 0, 1 ) ), + ( imath.V2f( 0.55, 0.5 ), imath.Color4f( 0, 0, 0, 0 ) ), ] ) @@ -656,15 +657,15 @@ def testSameMeshTwoShaders( self ) : c1 = IECoreScene.Group() c1.addChild( self.mesh() ) c1.addState( self.colorShader() ) - c1.state()[0].parameters["rgbF"] = IECore.V3fData( IECore.V3f( 0, 1, 1 ) ) + c1.state()[0].parameters["rgbF"] = IECore.V3fData( imath.V3f( 0, 1, 1 ) ) c2 = IECoreScene.Group() c2.addChild( self.mesh() ) c2.addState( self.textureShader() ) c2.state()[0].parameters["sampler"] = IECore.StringData( os.path.dirname( __file__ ) + "/images/yellow.exr" ) - c1.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( 0.2, 0, 0 ) ) ) ) - c2.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( -0.2, 0, 0 ) ) ) ) + c1.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 0.2, 0, 0 ) ) ) ) + c2.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( -0.2, 0, 0 ) ) ) ) g = IECoreScene.Group() g.addChild( c1 ) @@ -675,8 +676,8 @@ def testSameMeshTwoShaders( self ) : self.assertImageValues( image, [ - ( IECore.V2f( 0.7, 0.5 ), IECore.Color4f( 0, 1, 1, 1 ) ), - ( IECore.V2f( 0.3, 0.5 ), IECore.Color4f( 1, 1, 0, 1 ) ), + ( imath.V2f( 0.7, 0.5 ), imath.Color4f( 0, 1, 1, 1 ) ), + ( imath.V2f( 0.3, 0.5 ), imath.Color4f( 1, 1, 0, 1 ) ), ] ) @@ -688,7 +689,7 @@ def testGeometryShaderViaParameters( self ) : g = IECoreScene.Group() - p = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ IECore.V3f( 0 ) ] ) ) + p = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ imath.V3f( 0 ) ] ) ) p["type"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.StringData( "gl:point" ) ) g.addChild( p ) @@ -700,13 +701,13 @@ def testGeometryShaderViaParameters( self ) : self.assertImageValues( image, [ - ( IECore.V2f( 0.125, 0.5 ), IECore.Color4f( 0, 0, 0, 0 ) ), - ( IECore.V2f( 0.25, 0.5 ), IECore.Color4f( 1, 1, 1, 1 ) ), - ( IECore.V2f( 0.375, 0.5 ), IECore.Color4f( 0, 0, 0, 0 ) ), - ( IECore.V2f( 0.5, 0.5 ), IECore.Color4f( 1, 1, 1, 1 ) ), - ( IECore.V2f( 0.625, 0.5 ), IECore.Color4f( 0, 0, 0, 0 ) ), - ( IECore.V2f( 0.75, 0.5 ), IECore.Color4f( 1, 1, 1, 1 ) ), - ( IECore.V2f( 0.875, 0.5 ), IECore.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 0.125, 0.5 ), imath.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 0.25, 0.5 ), imath.Color4f( 1, 1, 1, 1 ) ), + ( imath.V2f( 0.375, 0.5 ), imath.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 0.5, 0.5 ), imath.Color4f( 1, 1, 1, 1 ) ), + ( imath.V2f( 0.625, 0.5 ), imath.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 0.75, 0.5 ), imath.Color4f( 1, 1, 1, 1 ) ), + ( imath.V2f( 0.875, 0.5 ), imath.Color4f( 0, 0, 0, 0 ) ), ] ) @@ -718,7 +719,7 @@ def testGeometryShaderViaFile( self ) : g = IECoreScene.Group() - p = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ IECore.V3f( 0 ) ] ) ) + p = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ imath.V3f( 0 ) ] ) ) p["type"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.StringData( "gl:point" ) ) g.addChild( p ) @@ -730,13 +731,13 @@ def testGeometryShaderViaFile( self ) : self.assertImageValues( image, [ - ( IECore.V2f( 0.125, 0.5 ), IECore.Color4f( 0, 0, 0, 0 ) ), - ( IECore.V2f( 0.25, 0.5 ), IECore.Color4f( 1, 1, 1, 1 ) ), - ( IECore.V2f( 0.375, 0.5 ), IECore.Color4f( 0, 0, 0, 0 ) ), - ( IECore.V2f( 0.5, 0.5 ), IECore.Color4f( 1, 1, 1, 1 ) ), - ( IECore.V2f( 0.625, 0.5 ), IECore.Color4f( 0, 0, 0, 0 ) ), - ( IECore.V2f( 0.75, 0.5 ), IECore.Color4f( 1, 1, 1, 1 ) ), - ( IECore.V2f( 0.875, 0.5 ), IECore.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 0.125, 0.5 ), imath.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 0.25, 0.5 ), imath.Color4f( 1, 1, 1, 1 ) ), + ( imath.V2f( 0.375, 0.5 ), imath.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 0.5, 0.5 ), imath.Color4f( 1, 1, 1, 1 ) ), + ( imath.V2f( 0.625, 0.5 ), imath.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 0.75, 0.5 ), imath.Color4f( 1, 1, 1, 1 ) ), + ( imath.V2f( 0.875, 0.5 ), imath.Color4f( 0, 0, 0, 0 ) ), ] ) @@ -748,11 +749,11 @@ def testCsParameterTrumpsColorAttribute( self ) : g = IECoreScene.Group() g.addChild( self.mesh() ) - g.addState( IECoreScene.AttributeState( { "color" : IECore.Color3f( 1, 0, 0 ) } ) ) + g.addState( IECoreScene.AttributeState( { "color" : imath.Color3f( 1, 0, 0 ) } ) ) g.addState( self.constantShader() ) image = self.renderImage( g ) - self.assertImageValues( image, [ ( IECore.V2f( 0.5 ), IECore.Color4f( 1, 0, 0, 1 ) ) ] ) + self.assertImageValues( image, [ ( imath.V2f( 0.5 ), imath.Color4f( 1, 0, 0, 1 ) ) ] ) # but if there is a Cs parameter, it should override the colour # from the attribute state. @@ -760,14 +761,14 @@ def testCsParameterTrumpsColorAttribute( self ) : g = IECoreScene.Group() g.addChild( self.mesh() ) - g.addState( IECoreScene.AttributeState( { "color" : IECore.Color3f( 1, 0, 0 ) } ) ) + g.addState( IECoreScene.AttributeState( { "color" : imath.Color3f( 1, 0, 0 ) } ) ) s = self.constantShader() - s.parameters["Cs"] = IECore.Color3f( 0, 1, 0 ) + s.parameters["Cs"] = imath.Color3f( 0, 1, 0 ) g.addState( s ) image = self.renderImage( g ) - self.assertImageValues( image, [ ( IECore.V2f( 0.5 ), IECore.Color4f( 0, 1, 0, 1 ) ) ] ) + self.assertImageValues( image, [ ( imath.V2f( 0.5 ), imath.Color4f( 0, 1, 0, 1 ) ) ] ) def testColorAttributeDoesntAffectWireframe( self ) : @@ -777,10 +778,10 @@ def testColorAttributeDoesntAffectWireframe( self ) : g.addState( IECoreScene.AttributeState( { - "color" : IECore.Color3f( 1, 0, 0 ), + "color" : imath.Color3f( 1, 0, 0 ), "gl:primitive:solid" : IECore.BoolData( False ), "gl:primitive:wireframe" : IECore.BoolData( True ), - "gl:primitive:wireframeColor" : IECore.Color4f( 0, 1, 0, 1 ), + "gl:primitive:wireframeColor" : imath.Color4f( 0, 1, 0, 1 ), "gl:primitive:wireframeWidth" : 6.0, } ) @@ -791,7 +792,7 @@ def testColorAttributeDoesntAffectWireframe( self ) : self.assertImageValues( image, [ - ( IECore.V2f( 0.5, 0.5 ), IECore.Color4f( 0, 1, 0, 1 ) ), + ( imath.V2f( 0.5, 0.5 ), imath.Color4f( 0, 1, 0, 1 ) ), ] ) @@ -801,7 +802,7 @@ def testVertexCsDoesntAffectWireframe( self ) : m["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.Color3fVectorData( - [ IECore.Color3f( 0 ) ] * len( m["P"].data ) + [ imath.Color3f( 0 ) ] * len( m["P"].data ) ) ) @@ -813,7 +814,7 @@ def testVertexCsDoesntAffectWireframe( self ) : { "gl:primitive:solid" : IECore.BoolData( True ), "gl:primitive:wireframe" : IECore.BoolData( True ), - "gl:primitive:wireframeColor" : IECore.Color4f( 0, 1, 0, 1 ), + "gl:primitive:wireframeColor" : imath.Color4f( 0, 1, 0, 1 ), "gl:primitive:wireframeWidth" : 6.0, } ) @@ -839,14 +840,14 @@ def testUniformFloatArrayParameters( self ) : c3 = c1.copy() c4 = c1.copy() c1.state()[0].parameters["f"] = IECore.FloatVectorData( [ i for i in range( 8 ) ] ) - c2.state()[0].parameters["f2"] = IECore.V2fVectorData( [ IECore.V2f( i, 100.0 / 16) for i in range( 8 ) ] ) - c3.state()[0].parameters["f3"] = IECore.V3fVectorData( [ IECore.V3f( i, 100.0 / 16, 100 * 0.5 ** ( i + 2 )) for i in range( 8 ) ] ) - c4.state()[0].parameters["f4"] = IECore.Color4fVectorData( [ IECore.Color4f( i, 100.0 / 32, 100 * 0.5 ** ( i + 2), 0.0 ) for i in range( 8 ) ] ) + c2.state()[0].parameters["f2"] = IECore.V2fVectorData( [ imath.V2f( i, 100.0 / 16) for i in range( 8 ) ] ) + c3.state()[0].parameters["f3"] = IECore.V3fVectorData( [ imath.V3f( i, 100.0 / 16, 100 * 0.5 ** ( i + 2 )) for i in range( 8 ) ] ) + c4.state()[0].parameters["f4"] = IECore.Color4fVectorData( [ imath.Color4f( i, 100.0 / 32, 100 * 0.5 ** ( i + 2), 0.0 ) for i in range( 8 ) ] ) - c1.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( -0.2, 0.2, 0 ) ) ) ) - c2.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( 0.2, 0.2, 0 ) ) ) ) - c3.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( -0.2, -0.2, 0 ) ) ) ) - c4.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( 0.2, -0.2, 0 ) ) ) ) + c1.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( -0.2, 0.2, 0 ) ) ) ) + c2.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 0.2, 0.2, 0 ) ) ) ) + c3.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( -0.2, -0.2, 0 ) ) ) ) + c4.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 0.2, -0.2, 0 ) ) ) ) g = IECoreScene.Group() g.addChild( c1 ) @@ -859,10 +860,10 @@ def testUniformFloatArrayParameters( self ) : self.assertImageValues( image, [ - ( IECore.V2f( 0.3, 0.3 ), IECore.Color4f( 0.28, 0, 0, 1 ) ), - ( IECore.V2f( 0.7, 0.3 ), IECore.Color4f( 0.28, 0.5, 0, 1 ) ), - ( IECore.V2f( 0.3, 0.7 ), IECore.Color4f( 0.28, 0.5, 0.5, 1 ) ), - ( IECore.V2f( 0.7, 0.7 ), IECore.Color4f( 0.28, 0.25, 0.5, 1 ) ), + ( imath.V2f( 0.3, 0.3 ), imath.Color4f( 0.28, 0, 0, 1 ) ), + ( imath.V2f( 0.7, 0.3 ), imath.Color4f( 0.28, 0.5, 0, 1 ) ), + ( imath.V2f( 0.3, 0.7 ), imath.Color4f( 0.28, 0.5, 0.5, 1 ) ), + ( imath.V2f( 0.7, 0.7 ), imath.Color4f( 0.28, 0.25, 0.5, 1 ) ), ] ) @@ -875,12 +876,12 @@ def testUniformIntArrayParameters( self ) : c2 = c1.copy() c3 = c1.copy() c1.state()[0].parameters["i"] = IECore.FloatVectorData( [ i for i in range( 8 ) ] ) - c2.state()[0].parameters["i2"] = IECore.V2fVectorData( [ IECore.V2f( i, 100.0 / 16) for i in range( 8 ) ] ) - c3.state()[0].parameters["i3"] = IECore.V3fVectorData( [ IECore.V3f( i, 100.0 / 16, 100 * 0.5 ** ( i + 2 )) for i in range( 8 ) ] ) + c2.state()[0].parameters["i2"] = IECore.V2fVectorData( [ imath.V2f( i, 100.0 / 16) for i in range( 8 ) ] ) + c3.state()[0].parameters["i3"] = IECore.V3fVectorData( [ imath.V3f( i, 100.0 / 16, 100 * 0.5 ** ( i + 2 )) for i in range( 8 ) ] ) - c1.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( -0.2, 0.2, 0 ) ) ) ) - c2.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( 0.2, 0.2, 0 ) ) ) ) - c3.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( -0.2, -0.2, 0 ) ) ) ) + c1.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( -0.2, 0.2, 0 ) ) ) ) + c2.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 0.2, 0.2, 0 ) ) ) ) + c3.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( -0.2, -0.2, 0 ) ) ) ) g = IECoreScene.Group() g.addChild( c1 ) @@ -893,9 +894,9 @@ def testUniformIntArrayParameters( self ) : self.assertImageValues( image, [ - ( IECore.V2f( 0.3, 0.3 ), IECore.Color4f( 0.28, 0, 0, 1 ) ), - ( IECore.V2f( 0.7, 0.3 ), IECore.Color4f( 0.28, 0.48, 0, 1 ) ), - ( IECore.V2f( 0.3, 0.7 ), IECore.Color4f( 0.28, 0.48, 0.47, 1 ) ), + ( imath.V2f( 0.3, 0.3 ), imath.Color4f( 0.28, 0, 0, 1 ) ), + ( imath.V2f( 0.7, 0.3 ), imath.Color4f( 0.28, 0.48, 0, 1 ) ), + ( imath.V2f( 0.3, 0.7 ), imath.Color4f( 0.28, 0.48, 0.47, 1 ) ), ] ) @@ -908,15 +909,15 @@ def testMatrixParameters( self ) : c2 = c1.copy() c3 = c1.copy() c4 = c1.copy() - c1.state()[0].parameters["m3"] = IECore.M33fData( IECore.M33f( [ i * 0.1 for i in range( 9 ) ] ) ) - c2.state()[0].parameters["m4"] = IECore.M44fData( IECore.M44f( [ i * 0.01 for i in range( 16 ) ] ) ) - c3.state()[0].parameters["m3v"] = IECore.M33fVectorData( [ IECore.M33f( [0,0,0, i * 0.01, i * 0.02, i * 0.03, 0,0,0] ) for i in range( 8 ) ] ) - c4.state()[0].parameters["m4v"] = IECore.M44fVectorData( [ IECore.M44f( [0,0,0,0, i * 0.005, i * 0.01, i * 0.02, 0, 0,0,0,0,0,0,0,0 ] ) for i in range( 8 ) ] ) + c1.state()[0].parameters["m3"] = IECore.M33fData( imath.M33f( *[ i * 0.1 for i in range( 9 ) ] ) ) + c2.state()[0].parameters["m4"] = IECore.M44fData( imath.M44f( *[ i * 0.01 for i in range( 16 ) ] ) ) + c3.state()[0].parameters["m3v"] = IECore.M33fVectorData( [ imath.M33f( *[0,0,0, i * 0.01, i * 0.02, i * 0.03, 0,0,0] ) for i in range( 8 ) ] ) + c4.state()[0].parameters["m4v"] = IECore.M44fVectorData( [ imath.M44f( *[0,0,0,0, i * 0.005, i * 0.01, i * 0.02, 0, 0,0,0,0,0,0,0,0 ] ) for i in range( 8 ) ] ) - c1.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( -0.2, 0.2, 0 ) ) ) ) - c2.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( 0.2, 0.2, 0 ) ) ) ) - c3.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( -0.2, -0.2, 0 ) ) ) ) - c4.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( 0.2, -0.2, 0 ) ) ) ) + c1.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( -0.2, 0.2, 0 ) ) ) ) + c2.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 0.2, 0.2, 0 ) ) ) ) + c3.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( -0.2, -0.2, 0 ) ) ) ) + c4.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 0.2, -0.2, 0 ) ) ) ) g = IECoreScene.Group() g.addChild( c1 ) @@ -929,10 +930,10 @@ def testMatrixParameters( self ) : self.assertImageValues( image, [ - ( IECore.V2f( 0.3, 0.3 ), IECore.Color4f( 0.6, 0.7, 0.8, 1 ) ), - ( IECore.V2f( 0.7, 0.3 ), IECore.Color4f( 0.20, 0.22, 0.24, 1 ) ), - ( IECore.V2f( 0.3, 0.7 ), IECore.Color4f( 0.28, 0.56, 0.84, 1 ) ), - ( IECore.V2f( 0.7, 0.7 ), IECore.Color4f( 0.14, 0.28, 0.56, 1 ) ), + ( imath.V2f( 0.3, 0.3 ), imath.Color4f( 0.6, 0.7, 0.8, 1 ) ), + ( imath.V2f( 0.7, 0.3 ), imath.Color4f( 0.20, 0.22, 0.24, 1 ) ), + ( imath.V2f( 0.3, 0.7 ), imath.Color4f( 0.28, 0.56, 0.84, 1 ) ), + ( imath.V2f( 0.7, 0.7 ), imath.Color4f( 0.14, 0.28, 0.56, 1 ) ), ] ) @@ -950,7 +951,7 @@ def renderOffsetImage( offset ) : { "gl:primitive:solid" : IECore.BoolData( True ), "gl:primitive:wireframe" : IECore.BoolData( True ), - "gl:primitive:wireframeColor" : IECore.Color4f( 0, 1, 0, 1 ), + "gl:primitive:wireframeColor" : imath.Color4f( 0, 1, 0, 1 ), "gl:primitive:wireframeWidth" : 6.0, } ) @@ -963,31 +964,31 @@ def renderOffsetImage( offset ) : # and renders red in the fragment shader. The wireframe # shading should inherit the offset but not the red. - image = renderOffsetImage( offset = IECore.V3f( 0.2, 0, 0 ) ) + image = renderOffsetImage( offset = imath.V3f( 0.2, 0, 0 ) ) self.assertImageValues( image, [ - ( IECore.V2f( 0.5, 0.5 ), IECore.Color4f( 0, 0, 0, 0 ) ), - ( IECore.V2f( 0.6, 0.5 ), IECore.Color4f( 0, 1, 0, 1 ) ), - ( IECore.V2f( 0.65, 0.5 ), IECore.Color4f( 1, 0, 0, 1 ) ), - ( IECore.V2f( 0.7, 0.5 ), IECore.Color4f( 0, 1, 0, 1 ) ), - ( IECore.V2f( 0.75, 0.5 ), IECore.Color4f( 1, 0, 0, 1 ) ), - ( IECore.V2f( 0.8, 0.5 ), IECore.Color4f( 0, 1, 0, 1 ) ), + ( imath.V2f( 0.5, 0.5 ), imath.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 0.6, 0.5 ), imath.Color4f( 0, 1, 0, 1 ) ), + ( imath.V2f( 0.65, 0.5 ), imath.Color4f( 1, 0, 0, 1 ) ), + ( imath.V2f( 0.7, 0.5 ), imath.Color4f( 0, 1, 0, 1 ) ), + ( imath.V2f( 0.75, 0.5 ), imath.Color4f( 1, 0, 0, 1 ) ), + ( imath.V2f( 0.8, 0.5 ), imath.Color4f( 0, 1, 0, 1 ) ), ] ) - image = renderOffsetImage( offset = IECore.V3f( -0.2, 0, 0 ) ) + image = renderOffsetImage( offset = imath.V3f( -0.2, 0, 0 ) ) self.assertImageValues( image, [ - ( IECore.V2f( 0.2, 0.5 ), IECore.Color4f( 0, 1, 0, 1 ) ), - ( IECore.V2f( 0.25, 0.5 ), IECore.Color4f( 1, 0, 0, 1 ) ), - ( IECore.V2f( 0.3, 0.5 ), IECore.Color4f( 0, 1, 0, 1 ) ), - ( IECore.V2f( 0.35, 0.5 ), IECore.Color4f( 1, 0, 0, 1 ) ), - ( IECore.V2f( 0.4, 0.5 ), IECore.Color4f( 0, 1, 0, 1 ) ), - ( IECore.V2f( 0.5, 0.5 ), IECore.Color4f( 0, 0, 0, 0 ) ), + ( imath.V2f( 0.2, 0.5 ), imath.Color4f( 0, 1, 0, 1 ) ), + ( imath.V2f( 0.25, 0.5 ), imath.Color4f( 1, 0, 0, 1 ) ), + ( imath.V2f( 0.3, 0.5 ), imath.Color4f( 0, 1, 0, 1 ) ), + ( imath.V2f( 0.35, 0.5 ), imath.Color4f( 1, 0, 0, 1 ) ), + ( imath.V2f( 0.4, 0.5 ), imath.Color4f( 0, 1, 0, 1 ) ), + ( imath.V2f( 0.5, 0.5 ), imath.Color4f( 0, 0, 0, 0 ) ), ] ) diff --git a/test/IECoreGL/TextTest.py b/test/IECoreGL/TextTest.py index 5173644e7c..76c2574b1c 100644 --- a/test/IECoreGL/TextTest.py +++ b/test/IECoreGL/TextTest.py @@ -35,6 +35,7 @@ import unittest import os.path import shutil +import imath import IECore import IECoreScene @@ -63,19 +64,19 @@ def testMeshes( self ) : r.camera( "main", { "projection" : IECore.StringData( "orthographic" ), - "resolution" : IECore.V2iData( IECore.V2i( 256 ) ), - "clippingPlanes" : IECore.V2fData( IECore.V2f( 1, 1000 ) ), - "screenWindow" : IECore.Box2fData( IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) ), + "resolution" : IECore.V2iData( imath.V2i( 256 ) ), + "clippingPlanes" : IECore.V2fData( imath.V2f( 1, 1000 ) ), + "screenWindow" : IECore.Box2fData( imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ), } ) r.display( self.outputFileName, "tiff", "rgba", {} ) with IECoreScene.WorldBlock( r ) : - r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( IECore.Color3f( 0, 0, 1 ) ) } ) + r.shader( "surface", "color", { "colorValue" : IECore.Color3fData( imath.Color3f( 0, 0, 1 ) ) } ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0.1, 0.1, -3 ) ) ) - r.concatTransform( IECore.M44f.createScaled( IECore.V3f( 0.15 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0.1, 0.1, -3 ) ) ) + r.concatTransform( imath.M44f().scale( imath.V3f( 0.15 ) ) ) r.text( "Vera.ttf", "hello world", 1, {} ) @@ -98,17 +99,17 @@ def testSprites( self ) : r.camera( "main", { "projection" : IECore.StringData( "orthographic" ), - "resolution" : IECore.V2iData( IECore.V2i( 256 ) ), - "clippingPlanes" : IECore.V2fData( IECore.V2f( 1, 1000 ) ), - "screenWindow" : IECore.Box2fData( IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) ), + "resolution" : IECore.V2iData( imath.V2i( 256 ) ), + "clippingPlanes" : IECore.V2fData( imath.V2f( 1, 1000 ) ), + "screenWindow" : IECore.Box2fData( imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ), } ) r.display( self.outputFileName, "tiff", "rgba", {} ) with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0.1, 0.1, -3 ) ) ) - r.concatTransform( IECore.M44f.createScaled( IECore.V3f( 0.15 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0.1, 0.1, -3 ) ) ) + r.concatTransform( imath.M44f().scale( imath.V3f( 0.15 ) ) ) r.setAttribute( "gl:depthMask", IECore.BoolData( False ) ) r.setAttribute( "gl:textPrimitive:type", IECore.StringData( "sprite" ) ) diff --git a/test/IECoreGL/Texture.py b/test/IECoreGL/Texture.py index 722e357c85..4c5a483812 100644 --- a/test/IECoreGL/Texture.py +++ b/test/IECoreGL/Texture.py @@ -37,6 +37,7 @@ import unittest import os.path import shutil +import imath import IECore import IECoreScene @@ -69,9 +70,9 @@ def performShaderParameterTest( self, shaderParameter ) : r.camera( "main", { "projection" : IECore.StringData( "perspective" ), "projection:fov" : IECore.FloatData( 45 ), - "resolution" : IECore.V2iData( IECore.V2i( 256 ) ), - "clippingPlanes" : IECore.V2fData( IECore.V2f( 1, 1000 ) ), - "screenWindow" : IECore.Box2fData( IECore.Box2f( IECore.V2f( -0.5 ), IECore.V2f( 0.5 ) ) ) + "resolution" : IECore.V2iData( imath.V2i( 256 ) ), + "clippingPlanes" : IECore.V2fData( imath.V2f( 1, 1000 ) ), + "screenWindow" : IECore.Box2fData( imath.Box2f( imath.V2f( -0.5 ), imath.V2f( 0.5 ) ) ) } ) r.display( outputFileName, "tif", "rgba", {} ) @@ -94,7 +95,7 @@ def performShaderParameterTest( self, shaderParameter ) : with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, -5 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 0, -5 ) ) ) r.shader( "surface", "color", { diff --git a/test/IECoreGL/ToGLConverterTest.py b/test/IECoreGL/ToGLConverterTest.py index 9b94108d70..0a34b65903 100644 --- a/test/IECoreGL/ToGLConverterTest.py +++ b/test/IECoreGL/ToGLConverterTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene @@ -47,7 +48,7 @@ def testFactory( self ) : # mesh - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) c = IECoreGL.ToGLConverter.create( m ) self.failUnless( isinstance( c, IECoreGL.ToGLMeshConverter ) ) @@ -90,10 +91,10 @@ def testFactory( self ) : IECore.SplinefColor3f( IECore.CubicBasisf.catmullRom(), ( - ( 0, IECore.Color3f( 1 ) ), - ( 0, IECore.Color3f( 1 ) ), - ( 1, IECore.Color3f( 0 ) ), - ( 1, IECore.Color3f( 0 ) ), + ( 0, imath.Color3f( 1 ) ), + ( 0, imath.Color3f( 1 ) ), + ( 1, imath.Color3f( 0 ) ), + ( 1, imath.Color3f( 0 ) ), ), ), ) @@ -105,10 +106,10 @@ def testFactory( self ) : IECore.SplinefColor4f( IECore.CubicBasisf.catmullRom(), ( - ( 0, IECore.Color4f( 1 ) ), - ( 0, IECore.Color4f( 1 ) ), - ( 1, IECore.Color4f( 0 ) ), - ( 1, IECore.Color4f( 0 ) ), + ( 0, imath.Color4f( 1 ) ), + ( 0, imath.Color4f( 1 ) ), + ( 1, imath.Color4f( 0 ) ), + ( 1, imath.Color4f( 0 ) ), ), ), ) @@ -133,7 +134,7 @@ def testFactory( self ) : # images - image = IECoreImage.ImagePrimitive.createRGBFloat( IECore.Color3f( 1, 0, 0 ), IECore.Box2i( IECore.V2i( 256 ), ), IECore.Box2i( IECore.V2i( 256 ) ) ) + image = IECoreImage.ImagePrimitive.createRGBFloat( imath.Color3f( 1, 0, 0 ), imath.Box2i( imath.V2i( 256 ), ), imath.Box2i( imath.V2i( 256 ) ) ) c = IECoreGL.ToGLConverter.create( image ) self.failUnless( isinstance( c, IECoreGL.ToGLTextureConverter ) ) diff --git a/test/IECoreGL/ToGLStateConverterTest.py b/test/IECoreGL/ToGLStateConverterTest.py index 0eace73017..2e5cbad385 100644 --- a/test/IECoreGL/ToGLStateConverterTest.py +++ b/test/IECoreGL/ToGLStateConverterTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene @@ -48,13 +49,13 @@ def test( self ) : ( "doubleSided", IECore.BoolData( True ), IECoreGL.DoubleSidedStateComponent( True ) ), ( "gl:primitive:wireframe", IECore.BoolData( True ), IECoreGL.Primitive.DrawWireframe( True ) ), ( "gl:primitive:wireframeWidth", IECore.FloatData( 2.5 ), IECoreGL.Primitive.WireframeWidth( 2.5 ) ), - ( "gl:primitive:wireframeColor", IECore.Color4fData( IECore.Color4f( 0.1, 0.25, 0.5, 1 ) ), IECoreGL.WireframeColorStateComponent( IECore.Color4f( 0.1, 0.25, 0.5, 1 ) ) ), + ( "gl:primitive:wireframeColor", IECore.Color4fData( imath.Color4f( 0.1, 0.25, 0.5, 1 ) ), IECoreGL.WireframeColorStateComponent( imath.Color4f( 0.1, 0.25, 0.5, 1 ) ) ), ( "gl:primitive:bound", IECore.BoolData( True ), IECoreGL.Primitive.DrawBound( True ) ), - ( "gl:primitive:boundColor", IECore.Color4fData( IECore.Color4f( 0.1, 0.25, 0.5, 1 ) ), IECoreGL.BoundColorStateComponent( IECore.Color4f( 0.1, 0.25, 0.5, 1 ) ) ), + ( "gl:primitive:boundColor", IECore.Color4fData( imath.Color4f( 0.1, 0.25, 0.5, 1 ) ), IECoreGL.BoundColorStateComponent( imath.Color4f( 0.1, 0.25, 0.5, 1 ) ) ), ( "gl:primitive:solid", IECore.BoolData( True ), IECoreGL.Primitive.DrawSolid( True ) ), ( "gl:primitive:points", IECore.BoolData( True ), IECoreGL.Primitive.DrawPoints( True ) ), ( "gl:primitive:pointWidth", IECore.FloatData( 2.5 ), IECoreGL.Primitive.PointWidth( 2.5 ) ), - ( "gl:primitive:pointColor", IECore.Color4fData( IECore.Color4f( 0.1, 0.25, 0.5, 1 ) ), IECoreGL.PointColorStateComponent( IECore.Color4f( 0.1, 0.25, 0.5, 1 ) ) ), + ( "gl:primitive:pointColor", IECore.Color4fData( imath.Color4f( 0.1, 0.25, 0.5, 1 ) ), IECoreGL.PointColorStateComponent( imath.Color4f( 0.1, 0.25, 0.5, 1 ) ) ), ( "gl:pointsPrimitive:useGLPoints", IECore.StringData( "forGLPoints" ), IECoreGL.PointsPrimitive.UseGLPoints( IECoreGL.GLPointsUsage.ForPointsOnly ) ), ( "gl:pointsPrimitive:glPointWidth", IECore.FloatData( 1.5 ), IECoreGL.PointsPrimitive.GLPointWidth( 1.5 ) ), ( "gl:curvesPrimitive:useGLLines", IECore.BoolData( True ), IECoreGL.CurvesPrimitive.UseGLLines( True ) ), diff --git a/test/IECoreHoudini/CobIOTranslator.py b/test/IECoreHoudini/CobIOTranslator.py index 95e41dc168..2a69248ed3 100644 --- a/test/IECoreHoudini/CobIOTranslator.py +++ b/test/IECoreHoudini/CobIOTranslator.py @@ -33,6 +33,7 @@ ########################################################################## import hou +import imath import IECore import IECoreScene import IECoreHoudini @@ -185,7 +186,7 @@ def testCantReadBadCob( self ) : os.remove( "testCobIO.cob" ) def testCobWithNonPrimitiveData( self ) : - IECore.ObjectWriter( IECore.V3f( 1 ), TestCobIOTranslator.__testFile ).write() + IECore.ObjectWriter( imath.V3f( 1 ), TestCobIOTranslator.__testFile ).write() reader = self.reader() geo = reader.geometry() prims = geo.prims() @@ -197,7 +198,7 @@ def testCobWithNonPrimitiveData( self ) : converter = IECoreHoudini.FromHoudiniGeometryConverter.create( reader ) self.assertTrue( isinstance( converter, IECoreHoudini.FromHoudiniCortexObjectConverter ) ) result = converter.convert() - self.assertEqual( result, IECore.V3fData( IECore.V3f( 1 ) ) ) + self.assertEqual( result, IECore.V3fData( imath.V3f( 1 ) ) ) def testReadWritePDC( self ) : points = self.points() diff --git a/test/IECoreHoudini/FromHoudiniCurvesConverter.py b/test/IECoreHoudini/FromHoudiniCurvesConverter.py index c96e238db3..4f805684f5 100644 --- a/test/IECoreHoudini/FromHoudiniCurvesConverter.py +++ b/test/IECoreHoudini/FromHoudiniCurvesConverter.py @@ -155,8 +155,8 @@ def verifyLinearCurves( self, sop ) : bBox = result.bound() hBBox = geo.boundingBox() for i in range( 0, 3 ) : - self.assertAlmostEqual( bBox.min[i], hBBox.minvec()[i] ) - self.assertAlmostEqual( bBox.max[i], hBBox.maxvec()[i] ) + self.assertAlmostEqual( bBox.min()[i], hBBox.minvec()[i] ) + self.assertAlmostEqual( bBox.max()[i], hBBox.maxvec()[i] ) self.assertEqual( result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ), len(geo.points()) ) self.assertEqual( result.verticesPerCurve().size(), len(geo.prims()) ) @@ -245,8 +245,8 @@ def verifyBSplineCurves( self, sop ) : bBox = result.bound() hBBox = geo.boundingBox() for i in range( 0, 3 ) : - self.assertAlmostEqual( bBox.min[i], hBBox.minvec()[i] ) - self.assertAlmostEqual( bBox.max[i], hBBox.maxvec()[i] ) + self.assertAlmostEqual( bBox.min()[i], hBBox.minvec()[i] ) + self.assertAlmostEqual( bBox.max()[i], hBBox.maxvec()[i] ) if result.periodic() : extraPoints = 0 diff --git a/test/IECoreHoudini/FromHoudiniPointsConverter.py b/test/IECoreHoudini/FromHoudiniPointsConverter.py index f051561379..0883754d13 100644 --- a/test/IECoreHoudini/FromHoudiniPointsConverter.py +++ b/test/IECoreHoudini/FromHoudiniPointsConverter.py @@ -36,6 +36,7 @@ ########################################################################## import hou +import imath import IECore import IECoreScene import IECoreHoudini @@ -127,12 +128,12 @@ def testConvertMesh( self ) : self.assertEqual( result.typeId(), IECoreScene.PointsPrimitive.staticTypeId() ) bbox = result.bound() - self.assertEqual( bbox.min.x, -2.0 ) - self.assertEqual( bbox.max.x, 2.0 ) + self.assertEqual( bbox.min().x, -2.0 ) + self.assertEqual( bbox.max().x, 2.0 ) self.assertEqual( result.numPoints, 100 ) for i in range( result.numPoints ) : - self.assert_( result["P"].data[i].x >= bbox.min.x ) - self.assert_( result["P"].data[i].x <= bbox.max.x ) + self.assert_( result["P"].data[i].x >= bbox.min().x ) + self.assert_( result["P"].data[i].x <= bbox.max().x ) # test prim/vertex attributes def testConvertPrimVertAttributes( self ) : @@ -232,12 +233,12 @@ def testConvertPrimVertAttributes( self ) : self.assert_( result.isInstanceOf( IECoreScene.TypeId.PointsPrimitive ) ) bbox = result.bound() - self.assertEqual( bbox.min.x, -2.0 ) - self.assertEqual( bbox.max.x, 2.0 ) + self.assertEqual( bbox.min().x, -2.0 ) + self.assertEqual( bbox.max().x, 2.0 ) self.assertEqual( result.numPoints, 100 ) for i in range( result.numPoints ) : - self.assert_( result["P"].data[i].x >= bbox.min.x ) - self.assert_( result["P"].data[i].x <= bbox.max.x ) + self.assert_( result["P"].data[i].x >= bbox.min().x ) + self.assert_( result["P"].data[i].x <= bbox.max().x ) # test point attributes self.assert_( "P" in result ) @@ -470,12 +471,12 @@ def testConvertMeshPrimVertAttributes( self ) : self.assert_( result.isInstanceOf( IECoreScene.TypeId.PointsPrimitive ) ) bbox = result.bound() - self.assertEqual( bbox.min.x, -2.0 ) - self.assertEqual( bbox.max.x, 2.0 ) + self.assertEqual( bbox.min().x, -2.0 ) + self.assertEqual( bbox.max().x, 2.0 ) self.assertEqual( result.numPoints, 100 ) for i in range( result.numPoints ) : - self.assert_( result["P"].data[i].x >= bbox.min.x ) - self.assert_( result["P"].data[i].x <= bbox.max.x ) + self.assert_( result["P"].data[i].x >= bbox.min().x ) + self.assert_( result["P"].data[i].x <= bbox.max().x ) # integer and float list attributes are not currently supported, so should not appear in the primitive variable lists: self.assertTrue( "vert_iList" not in result.keys() ) @@ -537,15 +538,15 @@ def testConvertMeshPrimVertAttributes( self ) : self.assert_( result["vert_f3"].data[i][j] >= 0.0 ) self.assert_( result["vert_f3"].data[i][j] < 400.1 ) - self.assertAlmostEqual( result["orient"].data[i][0], i * 0.4,5 ) - self.assertAlmostEqual( result["orient"].data[i][1], i * 0.1,5 ) - self.assertAlmostEqual( result["orient"].data[i][2], i * 0.2,5 ) - self.assertAlmostEqual( result["orient"].data[i][3], i * 0.3,5 ) + self.assertAlmostEqual( result["orient"].data[i].r(), i * 0.4,5 ) + self.assertAlmostEqual( result["orient"].data[i].v()[0], i * 0.1,5 ) + self.assertAlmostEqual( result["orient"].data[i].v()[1], i * 0.2,5 ) + self.assertAlmostEqual( result["orient"].data[i].v()[2], i * 0.3,5 ) - self.assertAlmostEqual( result["quat_2"].data[i][0], i * 0.8,5 ) - self.assertAlmostEqual( result["quat_2"].data[i][1], i * 0.2,5 ) - self.assertAlmostEqual( result["quat_2"].data[i][2], i * 0.4,5 ) - self.assertAlmostEqual( result["quat_2"].data[i][3], i * 0.6,5 ) + self.assertAlmostEqual( result["quat_2"].data[i].r(), i * 0.8,5 ) + self.assertAlmostEqual( result["quat_2"].data[i].v()[0], i * 0.2,5 ) + self.assertAlmostEqual( result["quat_2"].data[i].v()[1], i * 0.4,5 ) + self.assertAlmostEqual( result["quat_2"].data[i].v()[2], i * 0.6,5 ) self.assertEqual( result["vert_i1"].data.typeId(), IECore.IntVectorData.staticTypeId() ) self.assertEqual( result["vert_i2"].data.typeId(), IECore.V2iVectorData.staticTypeId() ) @@ -575,54 +576,50 @@ def testConvertMeshPrimVertAttributes( self ) : self.assertEqual( result["m44"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) self.assertEqual( result["m44"].data.typeId(), IECore.M44fVectorData.staticTypeId() ) - matrixScale = IECore.M44f.extractSHRT( result["m44"].data[0] )[0] - matrixRot = IECore.M44f.extractSHRT( result["m44"].data[0] )[2] - matrixTranslation = IECore.M44f.extractSHRT( result["m44"].data[0] )[3] - self.assertEqual( matrixTranslation, IECore.V3f( 10,20,30 ) ) - self.assertTrue( matrixRot.equalWithRelError( IECore.V3f( math.pi / 6, math.pi / 4, math.pi / 3 ), 1.e-5 ) ) - self.assertTrue( matrixScale.equalWithRelError( IECore.V3f( 3, 4, 5 ), 1.e-5 ) ) + matrixScale, matrixShear, matrixRot, matrixTranslation = imath.V3f(), imath.V3f(), imath.V3f(), imath.V3f() + result["m44"].data[0].extractSHRT( matrixScale, matrixShear, matrixRot, matrixTranslation ) + + self.assertEqual( matrixTranslation, imath.V3f( 10,20,30 ) ) + self.assertTrue( matrixRot.equalWithRelError( imath.V3f( math.pi / 6, math.pi / 4, math.pi / 3 ), 1.e-5 ) ) + self.assertTrue( matrixScale.equalWithRelError( imath.V3f( 3, 4, 5 ), 1.e-5 ) ) self.assertEqual( result["detail_m44"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) self.assertEqual( result["detail_m44"].data.typeId(), IECore.M44fData.staticTypeId() ) - matrixScale = IECore.M44f.extractSHRT( result["detail_m44"].data.value )[0] - matrixRot = IECore.M44f.extractSHRT( result["detail_m44"].data.value )[2] - matrixTranslation = IECore.M44f.extractSHRT( result["detail_m44"].data.value )[3] - self.assertEqual( matrixTranslation, IECore.V3f( 10,20,30 ) ) - self.assertTrue( matrixRot.equalWithRelError( IECore.V3f( math.pi / 6, math.pi / 4, math.pi / 3 ), 1.e-5 ) ) - self.assertTrue( matrixScale.equalWithRelError( IECore.V3f( 3, 4, 5 ), 1.e-5 ) ) + result["detail_m44"].data.value.extractSHRT( matrixScale, matrixShear, matrixRot, matrixTranslation ) + self.assertEqual( matrixTranslation, imath.V3f( 10,20,30 ) ) + self.assertTrue( matrixRot.equalWithRelError( imath.V3f( math.pi / 6, math.pi / 4, math.pi / 3 ), 1.e-5 ) ) + self.assertTrue( matrixScale.equalWithRelError( imath.V3f( 3, 4, 5 ), 1.e-5 ) ) self.assertEqual( result["m33"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) self.assertEqual( result["m33"].data.typeId(), IECore.M33fVectorData.staticTypeId() ) m3 = result["m33"].data[0] - m4 = IECore.M44f( - m3[(0,0)], m3[(0,1)], m3[(0,2)], 0.0, - m3[(1,0)], m3[(1,1)], m3[(1,2)], 0.0, - m3[(2,0)], m3[(2,1)], m3[(2,2)], 0.0, + m4 = imath.M44f( + m3[0][0], m3[0][1], m3[0][2], 0.0, + m3[1][0], m3[1][1], m3[1][2], 0.0, + m3[2][0], m3[2][1], m3[2][2], 0.0, 0.0, 0.0, 0.0, 1.0 ) - matrixScale = IECore.M44f.extractSHRT( m4 )[0] - matrixRot = IECore.M44f.extractSHRT( m4 )[2] - self.assertTrue( matrixRot.equalWithRelError( IECore.V3f( math.pi / 6, math.pi / 4, math.pi / 3 ), 1.e-5 ) ) - self.assertTrue( matrixScale.equalWithRelError( IECore.V3f( 3, 4, 5 ), 1.e-5 ) ) + m4.extractSHRT( matrixScale, matrixShear, matrixRot, matrixTranslation ) + self.assertTrue( matrixRot.equalWithRelError( imath.V3f( math.pi / 6, math.pi / 4, math.pi / 3 ), 1.e-5 ) ) + self.assertTrue( matrixScale.equalWithRelError( imath.V3f( 3, 4, 5 ), 1.e-5 ) ) self.assertEqual( result["detail_m33"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) self.assertEqual( result["detail_m33"].data.typeId(), IECore.M33fData.staticTypeId() ) m3 = result["detail_m33"].data.value - m4 = IECore.M44f( - m3[(0,0)], m3[(0,1)], m3[(0,2)], 0.0, - m3[(1,0)], m3[(1,1)], m3[(1,2)], 0.0, - m3[(2,0)], m3[(2,1)], m3[(2,2)], 0.0, + m4 = imath.M44f( + m3[0][0], m3[0][1], m3[0][2], 0.0, + m3[1][0], m3[1][1], m3[1][2], 0.0, + m3[2][0], m3[2][1], m3[2][2], 0.0, 0.0, 0.0, 0.0, 1.0 ) - matrixScale = IECore.M44f.extractSHRT( m4 )[0] - matrixRot = IECore.M44f.extractSHRT( m4 )[2] - self.assertTrue( matrixRot.equalWithRelError( IECore.V3f( math.pi / 6, math.pi / 4, math.pi / 3 ), 1.e-5 ) ) - self.assertTrue( matrixScale.equalWithRelError( IECore.V3f( 3, 4, 5 ), 1.e-5 ) ) + m4.extractSHRT( matrixScale, matrixShear, matrixRot, matrixTranslation ) + self.assertTrue( matrixRot.equalWithRelError( imath.V3f( math.pi / 6, math.pi / 4, math.pi / 3 ), 1.e-5 ) ) + self.assertTrue( matrixScale.equalWithRelError( imath.V3f( 3, 4, 5 ), 1.e-5 ) ) self.assert_( result.arePrimitiveVariablesValid() ) @@ -679,7 +676,7 @@ def testPointAttributes( self ) : attr.parm("value2").set(456.789) result = IECoreHoudini.FromHoudiniPointsConverter( attr ).convert() self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V2fVectorData ) - self.assertEqual( result["test_attribute"].data[0], IECore.V2f( 123.456, 456.789 ) ) + self.assertEqual( result["test_attribute"].data[0], imath.V2f( 123.456, 456.789 ) ) self.assertEqual( result["test_attribute"].data.size(), 5000 ) self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) self.assert_( result.arePrimitiveVariablesValid() ) @@ -687,7 +684,7 @@ def testPointAttributes( self ) : attr.parm("type").set(1) # int result = IECoreHoudini.FromHoudiniPointsConverter( attr ).convert() self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V2iVectorData ) - self.assertEqual( result["test_attribute"].data[0], IECore.V2i( 123, 456 ) ) + self.assertEqual( result["test_attribute"].data[0], imath.V2i( 123, 456 ) ) self.assertEqual( result["test_attribute"].data.size(), 5000 ) self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) self.assert_( result.arePrimitiveVariablesValid() ) @@ -697,7 +694,7 @@ def testPointAttributes( self ) : attr.parm("value3").set(999.999) result = IECoreHoudini.FromHoudiniPointsConverter( attr ).convert() self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V3fVectorData ) - self.assertEqual( result["test_attribute"].data[0],IECore.V3f( 123.456, 456.789, 999.999 ) ) + self.assertEqual( result["test_attribute"].data[0],imath.V3f( 123.456, 456.789, 999.999 ) ) self.assertEqual( result["test_attribute"].data.size(), 5000 ) self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) self.assert_( result.arePrimitiveVariablesValid() ) @@ -705,7 +702,7 @@ def testPointAttributes( self ) : attr.parm("type").set(1) # int result = IECoreHoudini.FromHoudiniPointsConverter( attr ).convert() self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V3iVectorData ) - self.assertEqual( result["test_attribute"].data[0], IECore.V3i( 123, 456, 999 ) ) + self.assertEqual( result["test_attribute"].data[0], imath.V3i( 123, 456, 999 ) ) self.assertEqual( result["test_attribute"].data.size(), 5000 ) self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) self.assert_( result.arePrimitiveVariablesValid() ) @@ -745,14 +742,14 @@ def testDetailAttributes( self ) : attr.parm("value2").set(456.789) result = IECoreHoudini.FromHoudiniPointsConverter( attr ).convert() self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V2fData ) - self.assertEqual( result["test_attribute"].data.value, IECore.V2f( 123.456, 456.789 ) ) + self.assertEqual( result["test_attribute"].data.value, imath.V2f( 123.456, 456.789 ) ) self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) self.assert_( result.arePrimitiveVariablesValid() ) attr.parm("type").set(1) # int result = IECoreHoudini.FromHoudiniPointsConverter( attr ).convert() self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V2iData ) - self.assertEqual( result["test_attribute"].data.value, IECore.V2i( 123, 456 ) ) + self.assertEqual( result["test_attribute"].data.value, imath.V2i( 123, 456 ) ) self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) self.assert_( result.arePrimitiveVariablesValid() ) @@ -761,14 +758,14 @@ def testDetailAttributes( self ) : attr.parm("value3").set(999.999) result = IECoreHoudini.FromHoudiniPointsConverter( attr ).convert() self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V3fData ) - self.assertEqual( result["test_attribute"].data.value, IECore.V3f( 123.456, 456.789, 999.999 ) ) + self.assertEqual( result["test_attribute"].data.value, imath.V3f( 123.456, 456.789, 999.999 ) ) self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) self.assert_( result.arePrimitiveVariablesValid() ) attr.parm("type").set(1) # int result = IECoreHoudini.FromHoudiniPointsConverter( attr ).convert() self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V3iData ) - self.assertEqual( result["test_attribute"].data.value, IECore.V3i( 123, 456, 999 ) ) + self.assertEqual( result["test_attribute"].data.value, imath.V3i( 123, 456, 999 ) ) self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) self.assert_( result.arePrimitiveVariablesValid() ) @@ -870,11 +867,11 @@ def testParticlePrimitive( self ) : self.assertEqual( points.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ), 21 ) self.assertEqual( points["float3detail"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) self.assertEqual( type(points["float3detail"].data), IECore.V3fData ) - self.assert_( points["float3detail"].data.value.equalWithRelError( IECore.V3f( 1, 2, 3 ), 1e-10 ) ) + self.assert_( points["float3detail"].data.value.equalWithRelError( imath.V3f( 1, 2, 3 ), 1e-10 ) ) self.assertEqual( type(points["float3point"].data), IECore.V3fVectorData ) self.assertEqual( points["float3point"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) for p in points["float3point"].data : - self.assert_( p.equalWithRelError( IECore.V3f( 1, 2, 3 ), 1e-10 ) ) + self.assert_( p.equalWithRelError( imath.V3f( 1, 2, 3 ), 1e-10 ) ) self.assert_( points.arePrimitiveVariablesValid() ) diff --git a/test/IECoreHoudini/FromHoudiniPolygonsConverter.py b/test/IECoreHoudini/FromHoudiniPolygonsConverter.py index 1b7e611fab..f9ae83e45c 100644 --- a/test/IECoreHoudini/FromHoudiniPolygonsConverter.py +++ b/test/IECoreHoudini/FromHoudiniPolygonsConverter.py @@ -36,6 +36,7 @@ ########################################################################## import hou +import imath import IECore import IECoreScene import IECoreHoudini @@ -129,8 +130,8 @@ def testConvertMesh( self ) : self.assertEqual( result.typeId(), IECoreScene.MeshPrimitive.staticTypeId() ) bbox = result.bound() - self.assertEqual( bbox.min.x, -1.5 ) - self.assertEqual( bbox.max.x, 1.5 ) + self.assertEqual( bbox.min().x, -1.5 ) + self.assertEqual( bbox.max().x, 1.5 ) self.assertEqual( result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ), 100 ) self.assertEqual( result.numFaces(), 100 ) @@ -249,8 +250,8 @@ def testConvertPrimVertAttributes( self ) : self.assert_( result.isInstanceOf( IECoreScene.TypeId.MeshPrimitive ) ) bbox = result.bound() - self.assertEqual( bbox.min.x, -1.5 ) - self.assertEqual( bbox.max.x, 1.5 ) + self.assertEqual( bbox.min().x, -1.5 ) + self.assertEqual( bbox.max().x, 1.5 ) self.assertEqual( result.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ), 100 ) self.assertEqual( result.numFaces(), 100 ) @@ -397,7 +398,7 @@ def testPointAttributes( self ) : attr.parm("value2").set(456.789) result = IECoreHoudini.FromHoudiniPolygonsConverter( attr ).convert() self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V2fVectorData ) - self.assertEqual( result["test_attribute"].data[0], IECore.V2f( 123.456, 456.789 ) ) + self.assertEqual( result["test_attribute"].data[0], imath.V2f( 123.456, 456.789 ) ) self.assertEqual( result["test_attribute"].data.size(), 100 ) self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) self.assert_( result.arePrimitiveVariablesValid() ) @@ -405,7 +406,7 @@ def testPointAttributes( self ) : attr.parm("type").set(1) # int result = IECoreHoudini.FromHoudiniPolygonsConverter( attr ).convert() self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V2iVectorData ) - self.assertEqual( result["test_attribute"].data[0], IECore.V2i( 123, 456 ) ) + self.assertEqual( result["test_attribute"].data[0], imath.V2i( 123, 456 ) ) self.assertEqual( result["test_attribute"].data.size(), 100 ) self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) self.assert_( result.arePrimitiveVariablesValid() ) @@ -415,7 +416,7 @@ def testPointAttributes( self ) : attr.parm("value3").set(999.999) result = IECoreHoudini.FromHoudiniPolygonsConverter( attr ).convert() self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V3fVectorData ) - self.assertEqual( result["test_attribute"].data[0],IECore.V3f( 123.456, 456.789, 999.999 ) ) + self.assertEqual( result["test_attribute"].data[0],imath.V3f( 123.456, 456.789, 999.999 ) ) self.assertEqual( result["test_attribute"].data.size(), 100 ) self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) self.assert_( result.arePrimitiveVariablesValid() ) @@ -423,7 +424,7 @@ def testPointAttributes( self ) : attr.parm("type").set(1) # int result = IECoreHoudini.FromHoudiniPolygonsConverter( attr ).convert() self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V3iVectorData ) - self.assertEqual( result["test_attribute"].data[0], IECore.V3i( 123, 456, 999 ) ) + self.assertEqual( result["test_attribute"].data[0], imath.V3i( 123, 456, 999 ) ) self.assertEqual( result["test_attribute"].data.size(), 100 ) self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) self.assert_( result.arePrimitiveVariablesValid() ) @@ -463,14 +464,14 @@ def testDetailAttributes( self ) : attr.parm("value2").set(456.789) result = IECoreHoudini.FromHoudiniPolygonsConverter( attr ).convert() self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V2fData ) - self.assertEqual( result["test_attribute"].data.value, IECore.V2f( 123.456, 456.789 ) ) + self.assertEqual( result["test_attribute"].data.value, imath.V2f( 123.456, 456.789 ) ) self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) self.assert_( result.arePrimitiveVariablesValid() ) attr.parm("type").set(1) # int result = IECoreHoudini.FromHoudiniPolygonsConverter( attr ).convert() self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V2iData ) - self.assertEqual( result["test_attribute"].data.value, IECore.V2i( 123, 456 ) ) + self.assertEqual( result["test_attribute"].data.value, imath.V2i( 123, 456 ) ) self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) self.assert_( result.arePrimitiveVariablesValid() ) @@ -479,14 +480,14 @@ def testDetailAttributes( self ) : attr.parm("value3").set(999.999) result = IECoreHoudini.FromHoudiniPolygonsConverter( attr ).convert() self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V3fData ) - self.assertEqual( result["test_attribute"].data.value, IECore.V3f( 123.456, 456.789, 999.999 ) ) + self.assertEqual( result["test_attribute"].data.value, imath.V3f( 123.456, 456.789, 999.999 ) ) self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) self.assert_( result.arePrimitiveVariablesValid() ) attr.parm("type").set(1) # int result = IECoreHoudini.FromHoudiniPolygonsConverter( attr ).convert() self.assertEqual( result["test_attribute"].data.typeId(), IECore.TypeId.V3iData ) - self.assertEqual( result["test_attribute"].data.value, IECore.V3i( 123, 456, 999 ) ) + self.assertEqual( result["test_attribute"].data.value, imath.V3i( 123, 456, 999 ) ) self.assertEqual( result["test_attribute"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) self.assert_( result.arePrimitiveVariablesValid() ) @@ -603,7 +604,7 @@ def testWindingOrder( self ) : self.assertEqual( vertexIds.size(), 4 ) loop = IECore.V3fVectorData( [ p[vertexIds[0]], p[vertexIds[1]], p[vertexIds[2]], p[vertexIds[3]] ] ) - self.assert_( IECore.polygonNormal( loop ).equalWithAbsError( IECore.V3f( 0, 1, 0 ), 0.0001 ) ) + self.assert_( IECore.polygonNormal( loop ).equalWithAbsError( imath.V3f( 0, 1, 0 ), 0.0001 ) ) # testing vertex data order def testVertexDataOrder( self ) : diff --git a/test/IECoreHoudini/LiveSceneTest.py b/test/IECoreHoudini/LiveSceneTest.py index b11e9a4612..7d35a9b2cd 100644 --- a/test/IECoreHoudini/LiveSceneTest.py +++ b/test/IECoreHoudini/LiveSceneTest.py @@ -35,6 +35,7 @@ import unittest import hou +import imath import IECore import IECoreScene @@ -366,14 +367,14 @@ def testReadMesh( self ) : self.assertEqual( len( vertList ), 8 ) # check the verts are in local space - self.assertEqual( vertList.count( IECore.V3f( -0.5, -0.5, 0.5 ) ), 1 ) - self.assertEqual( vertList.count( IECore.V3f( 0.5, -0.5, 0.5 ) ), 1 ) - self.assertEqual( vertList.count( IECore.V3f( -0.5, 0.5, 0.5 ) ), 1 ) - self.assertEqual( vertList.count( IECore.V3f( 0.5, 0.5, 0.5 ) ), 1 ) - self.assertEqual( vertList.count( IECore.V3f( -0.5, 0.5, -0.5 ) ), 1 ) - self.assertEqual( vertList.count( IECore.V3f( 0.5, 0.5, -0.5 ) ), 1 ) - self.assertEqual( vertList.count( IECore.V3f( -0.5, -0.5, -0.5 ) ), 1 ) - self.assertEqual( vertList.count( IECore.V3f( 0.5, -0.5, -0.5 ) ), 1 ) + self.assertEqual( vertList.count( imath.V3f( -0.5, -0.5, 0.5 ) ), 1 ) + self.assertEqual( vertList.count( imath.V3f( 0.5, -0.5, 0.5 ) ), 1 ) + self.assertEqual( vertList.count( imath.V3f( -0.5, 0.5, 0.5 ) ), 1 ) + self.assertEqual( vertList.count( imath.V3f( 0.5, 0.5, 0.5 ) ), 1 ) + self.assertEqual( vertList.count( imath.V3f( -0.5, 0.5, -0.5 ) ), 1 ) + self.assertEqual( vertList.count( imath.V3f( 0.5, 0.5, -0.5 ) ), 1 ) + self.assertEqual( vertList.count( imath.V3f( -0.5, -0.5, -0.5 ) ), 1 ) + self.assertEqual( vertList.count( imath.V3f( 0.5, -0.5, -0.5 ) ), 1 ) # check read primvars self.assertEqual( mesh["P"], box1.readObjectPrimitiveVariables( [ "P" ], 0 )["P"] ) @@ -422,18 +423,18 @@ def testReadBound( self ) : hou.node( "/obj/sub1/torus2/actualTorus" ).parm( "rows" ).set( 100 ) hou.node( "/obj/sub1/torus2/actualTorus" ).parm( "cols" ).set( 100 ) - self.assertEqual( scene.child( "box2" ).readBound( 0 ), IECore.Box3d( IECore.V3d( -0.5 ), IECore.V3d( 0.5 ) ) ) + self.assertEqual( scene.child( "box2" ).readBound( 0 ), imath.Box3d( imath.V3d( -0.5 ), imath.V3d( 0.5 ) ) ) sub1 = scene.child( "sub1" ) box1 = sub1.child( "box1" ) - self.assertEqual( box1.readBound( 0 ), IECore.Box3d( IECore.V3d( -0.5 ), IECore.V3d( 0.5 ) ) ) + self.assertEqual( box1.readBound( 0 ), imath.Box3d( imath.V3d( -0.5 ), imath.V3d( 0.5 ) ) ) torus1 = sub1.child( "torus1" ) torus2 = torus1.child( "torus2" ) - self.assertEqual( torus2.readBound( 0 ), IECore.Box3d( IECore.V3d( -1.5, -0.5, -1.5 ), IECore.V3d( 1.5, 0.5, 1.5 ) ) ) - self.assertEqual( torus1.readBound( 0 ), IECore.Box3d( IECore.V3d( -2.5, -0.5, -1.5 ), IECore.V3d( 1.5, 0.5, 3.5 ) ) ) - self.assertEqual( sub1.readBound( 0 ), IECore.Box3d( IECore.V3d( -1.5 ), IECore.V3d( 3.5, 2.5, 5.5 ) ) ) - self.assertEqual( scene.readBound( 0 ), IECore.Box3d( IECore.V3d( -0.5 ), IECore.V3d( 4.5, 3.5, 6.5 ) ) ) + self.assertEqual( torus2.readBound( 0 ), imath.Box3d( imath.V3d( -1.5, -0.5, -1.5 ), imath.V3d( 1.5, 0.5, 1.5 ) ) ) + self.assertEqual( torus1.readBound( 0 ), imath.Box3d( imath.V3d( -2.5, -0.5, -1.5 ), imath.V3d( 1.5, 0.5, 3.5 ) ) ) + self.assertEqual( sub1.readBound( 0 ), imath.Box3d( imath.V3d( -1.5 ), imath.V3d( 3.5, 2.5, 5.5 ) ) ) + self.assertEqual( scene.readBound( 0 ), imath.Box3d( imath.V3d( -0.5 ), imath.V3d( 4.5, 3.5, 6.5 ) ) ) def testAnimatedBound( self ) : @@ -452,32 +453,32 @@ def testAnimatedBound( self ) : hou.node( "/obj/sub1/torus2/actualTorus" ).parm( "rows" ).set( 100 ) hou.node( "/obj/sub1/torus2/actualTorus" ).parm( "cols" ).set( 100 ) - self.assertEqual( scene.child( "box2" ).readBound( 0 ), IECore.Box3d( IECore.V3d( -0.5 ), IECore.V3d( 0.5 ) ) ) + self.assertEqual( scene.child( "box2" ).readBound( 0 ), imath.Box3d( imath.V3d( -0.5 ), imath.V3d( 0.5 ) ) ) sub1 = scene.child( "sub1" ) box1 = sub1.child( "box1" ) - self.assertEqual( box1.readBound( 0 ), IECore.Box3d( IECore.V3d( -0.5 ), IECore.V3d( 0.5 ) ) ) + self.assertEqual( box1.readBound( 0 ), imath.Box3d( imath.V3d( -0.5 ), imath.V3d( 0.5 ) ) ) torus1 = sub1.child( "torus1" ) torus2 = torus1.child( "torus2" ) - self.assertEqual( torus2.readBound( 0 ), IECore.Box3d( IECore.V3d( -1.5, -0.5, -1.5 ), IECore.V3d( 1.5, 0.5, 1.5 ) ) ) - self.assertEqual( torus1.readBound( 0 ), IECore.Box3d( IECore.V3d( -2.5, -0.5, -1.5 ), IECore.V3d( 1.5, 0.5, 3.5 ) ) ) - self.assertEqual( sub1.readBound( 0 ), IECore.Box3d( IECore.V3d( -2.5, -0.5, -1.5 ), IECore.V3d( 1.5, 0.5, 3.5 ) ) ) - self.assertEqual( scene.readBound( 0 ), IECore.Box3d( IECore.V3d( -1.5, -0.5, -0.5 ), IECore.V3d( 2.5, 1.5, 4.5 ) ) ) + self.assertEqual( torus2.readBound( 0 ), imath.Box3d( imath.V3d( -1.5, -0.5, -1.5 ), imath.V3d( 1.5, 0.5, 1.5 ) ) ) + self.assertEqual( torus1.readBound( 0 ), imath.Box3d( imath.V3d( -2.5, -0.5, -1.5 ), imath.V3d( 1.5, 0.5, 3.5 ) ) ) + self.assertEqual( sub1.readBound( 0 ), imath.Box3d( imath.V3d( -2.5, -0.5, -1.5 ), imath.V3d( 1.5, 0.5, 3.5 ) ) ) + self.assertEqual( scene.readBound( 0 ), imath.Box3d( imath.V3d( -1.5, -0.5, -0.5 ), imath.V3d( 2.5, 1.5, 4.5 ) ) ) # time 1 - self.assertEqual( box1.readBound( 1 ), IECore.Box3d( IECore.V3d( -0.5 ), IECore.V3d( 0.5 ) ) ) - self.assertEqual( torus2.readBound( 1 ), IECore.Box3d( IECore.V3d( -1.5, -0.5, -1.5 ), IECore.V3d( 1.5, 0.5, 1.5 ) ) ) - self.assertEqual( torus1.readBound( 1 ), IECore.Box3d( IECore.V3d( -2.5, -0.5, -1.5 ), IECore.V3d( 1.5, 0.5, 3.5 ) ) ) - self.assertEqual( sub1.readBound( 1 ), IECore.Box3d( IECore.V3d( -1.5 ), IECore.V3d( 2.5, 1.5, 4.5 ) ) ) - self.assertEqual( scene.readBound( 1 ), IECore.Box3d( IECore.V3d( -0.5 ), IECore.V3d( 3.5, 2.5, 5.5 ) ) ) + self.assertEqual( box1.readBound( 1 ), imath.Box3d( imath.V3d( -0.5 ), imath.V3d( 0.5 ) ) ) + self.assertEqual( torus2.readBound( 1 ), imath.Box3d( imath.V3d( -1.5, -0.5, -1.5 ), imath.V3d( 1.5, 0.5, 1.5 ) ) ) + self.assertEqual( torus1.readBound( 1 ), imath.Box3d( imath.V3d( -2.5, -0.5, -1.5 ), imath.V3d( 1.5, 0.5, 3.5 ) ) ) + self.assertEqual( sub1.readBound( 1 ), imath.Box3d( imath.V3d( -1.5 ), imath.V3d( 2.5, 1.5, 4.5 ) ) ) + self.assertEqual( scene.readBound( 1 ), imath.Box3d( imath.V3d( -0.5 ), imath.V3d( 3.5, 2.5, 5.5 ) ) ) # time 1.5 - self.assertEqual( box1.readBound( 1.5 ), IECore.Box3d( IECore.V3d( -0.5 ), IECore.V3d( 0.5 ) ) ) - self.assertEqual( torus2.readBound( 1.5 ), IECore.Box3d( IECore.V3d( -1.5, -0.5, -1.5 ), IECore.V3d( 1.5, 0.5, 1.5 ) ) ) - self.assertEqual( torus1.readBound( 1.5 ), IECore.Box3d( IECore.V3d( -2.5, -0.5, -1.5 ), IECore.V3d( 1.5, 0.5, 3.5 ) ) ) - self.assertEqual( sub1.readBound( 1.5 ), IECore.Box3d( IECore.V3d( -2 ), IECore.V3d( 3, 2, 5 ) ) ) - self.assertEqual( scene.readBound( 1.5 ), IECore.Box3d( IECore.V3d( -1 ), IECore.V3d( 4, 3, 6 ) ) ) + self.assertEqual( box1.readBound( 1.5 ), imath.Box3d( imath.V3d( -0.5 ), imath.V3d( 0.5 ) ) ) + self.assertEqual( torus2.readBound( 1.5 ), imath.Box3d( imath.V3d( -1.5, -0.5, -1.5 ), imath.V3d( 1.5, 0.5, 1.5 ) ) ) + self.assertEqual( torus1.readBound( 1.5 ), imath.Box3d( imath.V3d( -2.5, -0.5, -1.5 ), imath.V3d( 1.5, 0.5, 3.5 ) ) ) + self.assertEqual( sub1.readBound( 1.5 ), imath.Box3d( imath.V3d( -2 ), imath.V3d( 3, 2, 5 ) ) ) + self.assertEqual( scene.readBound( 1.5 ), imath.Box3d( imath.V3d( -1 ), imath.V3d( 4, 3, 6 ) ) ) def testReadTransformMethods( self ) : @@ -534,11 +535,11 @@ def testAnimatedTransform( self ) : transform0_5 = torus1.readTransform( 0.5 ).value transform1 = torus1.readTransform( 1 ).value - self.assertEqual( transform0.translate, IECore.V3d( 0, 1, 2 ) ) + self.assertEqual( transform0.translate, imath.V3d( 0, 1, 2 ) ) self.assertAlmostEqual( transform0_5.translate.x, 0.5, 5 ) self.assertAlmostEqual( transform0_5.translate.y, 1.5, 5 ) self.assertAlmostEqual( transform0_5.translate.z, 2.5, 5 ) - self.assertEqual( transform1.translate, IECore.V3d( 1, 2, 3 ) ) + self.assertEqual( transform1.translate, imath.V3d( 1, 2, 3 ) ) def testFlatGeoWithGap( self ) : @@ -1075,13 +1076,13 @@ def testMultipleTransforms( self ) : sc = IECoreHoudini.LiveScene() sub1Sc = sc.scene(["sub1"]) sub1Transform = sub1Sc.readTransform( 0 ).value - self.assertEqual( sub1Transform.translate, IECore.V3d( 5.0, 5.0, 0.0 ) ) + self.assertEqual( sub1Transform.translate, imath.V3d( 5.0, 5.0, 0.0 ) ) sub2Sc = sub1Sc.child("sub2") sub2Transform = sub2Sc.readTransform( 0 ).value - self.assertEqual( sub2Transform.translate, IECore.V3d( 0.0, 0.0, 0.0 ) ) + self.assertEqual( sub2Transform.translate, imath.V3d( 0.0, 0.0, 0.0 ) ) sub3Sc = sub1Sc.child("sub3") sub3Transform = sub3Sc.readTransform( 0 ).value - self.assertEqual( sub3Transform.translate, IECore.V3d( 0.0, 0.0, 0.0 ) ) + self.assertEqual( sub3Transform.translate, imath.V3d( 0.0, 0.0, 0.0 ) ) def testIgnoreNonOBJNodes( self ) : diff --git a/test/IECoreHoudini/OpHolder.py b/test/IECoreHoudini/OpHolder.py index 8a0fbcc386..c44c2ee7d3 100644 --- a/test/IECoreHoudini/OpHolder.py +++ b/test/IECoreHoudini/OpHolder.py @@ -36,6 +36,7 @@ ########################################################################## import hou +import imath import IECore import IECoreScene import IECoreHoudini @@ -156,7 +157,7 @@ def testWireTogether(self): print_op.cook() fn = IECoreHoudini.FnOpHolder(print_op) result = fn.getParameterised().resultParameter().getValue() - self.assertEqual( result, IECore.V3fVectorData( [IECore.V3f(5,7,9),IECore.V3f(5,7,9),IECore.V3f(5,7,9)] ) ) + self.assertEqual( result, IECore.V3fVectorData( [imath.V3f(5,7,9),imath.V3f(5,7,9),imath.V3f(5,7,9)] ) ) # test that a hip with opHolders wired together can be saved and reloaded & still evaluate def testSaveLoad(self): @@ -184,7 +185,7 @@ def testSaveLoad(self): n.cook() fn = IECoreHoudini.FnOpHolder(n) result = fn.getParameterised().resultParameter().getValue() - self.assertEqual( result, IECore.V3fVectorData( [IECore.V3f(5,7,9),IECore.V3f(5,7,9),IECore.V3f(5,7,9)] ) ) + self.assertEqual( result, IECore.V3fVectorData( [imath.V3f(5,7,9),imath.V3f(5,7,9),imath.V3f(5,7,9)] ) ) # tests changing op and inputs def testChangingOp( self ) : @@ -323,15 +324,15 @@ def testCompoundParameters(self): p = op.parmTuple( "parm_compound_2_j" ) p.set( [123.456, 456.789, 0.0] ) - self.assert_( ( cl.parameters()["compound_2"]["j"].getValue().value - IECore.V3d( 8,16,32 ) ).length() < 0.001 ) + self.assert_( ( cl.parameters()["compound_2"]["j"].getValue().value - imath.V3d( 8,16,32 ) ).length() < 0.001 ) op.cook() - self.assert_( ( cl.parameters()["compound_2"]["j"].getValue().value - IECore.V3d( 123.456, 456.789, 0 ) ).length() < 0.001 ) + self.assert_( ( cl.parameters()["compound_2"]["j"].getValue().value - imath.V3d( 123.456, 456.789, 0 ) ).length() < 0.001 ) # test that caching parameters works op.parm( "__classReloadButton" ).pressButton() op.cook() self.assertEqual( cl.parameters()["compound_3"]["compound_4"]["some_int"].getValue().value, 345 ) - self.assert_( ( cl.parameters()["compound_2"]["j"].getValue().value - IECore.V3d( 123.456, 456.789, 0 ) ).length() < 0.001 ) + self.assert_( ( cl.parameters()["compound_2"]["j"].getValue().value - imath.V3d( 123.456, 456.789, 0 ) ).length() < 0.001 ) def testObjectParameterConversion(self): (op,fn)=self.testOpHolder() @@ -632,7 +633,7 @@ def testSetOpValues( self ) : self.assertEqual( tuple(op.parameters()['frequency'].getTypedValue()), holder.parmTuple( "parm_frequency" ).eval() ) ( holder2, fn2 ) = self.testOpHolder() - op.parameters()['frequency'].setTypedValue( IECore.V3f( 0.2, 0.4, 0.6 ) ) + op.parameters()['frequency'].setTypedValue( imath.V3f( 0.2, 0.4, 0.6 ) ) fn2.setOp( op ) self.assertEqual( tuple(op.parameters()['frequency'].defaultValue.value), holder2.parmTuple( "parm_frequency" ).parmTemplate().defaultValue() ) self.assertNotEqual( tuple(op.parameters()['frequency'].defaultValue.value), holder2.parmTuple( "parm_frequency" ).eval() ) diff --git a/test/IECoreHoudini/SceneCacheTest.py b/test/IECoreHoudini/SceneCacheTest.py index 98ef945d63..a7ebbb662d 100644 --- a/test/IECoreHoudini/SceneCacheTest.py +++ b/test/IECoreHoudini/SceneCacheTest.py @@ -35,6 +35,7 @@ import os import uuid import hou +import imath import IECore import IECoreScene import IECoreHoudini @@ -113,31 +114,31 @@ def rop( self, rootObject ) : rop.parmTuple( "f" ).deleteAllKeyframes() return rop - def writeSCC( self, rotation=IECore.V3d( 0, 0, 0 ), time=0 ) : + def writeSCC( self, rotation=imath.V3d( 0, 0, 0 ), time=0 ) : scene = IECoreScene.SceneCache( self._testFile, IECore.IndexedIO.OpenMode.Write ) sc = scene.createChild( str( 1 ) ) - mesh = IECoreScene.MeshPrimitive.createBox(IECore.Box3f(IECore.V3f(0),IECore.V3f(1))) - mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ IECore.V3f( 1, 0, 0 ) ] * 6 ) ) + mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) + mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ imath.V3f( 1, 0, 0 ) ] * 6 ) ) sc.writeObject( mesh, time ) - matrix = IECore.M44d.createTranslated( IECore.V3d( 1, 0, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 1, 0, 0 ) ) matrix = matrix.rotate( rotation ) sc.writeTransform( IECore.M44dData( matrix ), time ) sc = sc.createChild( str( 2 ) ) - mesh = IECoreScene.MeshPrimitive.createBox(IECore.Box3f(IECore.V3f(0),IECore.V3f(1))) - mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ IECore.V3f( 0, 1, 0 ) ] * 6 ) ) + mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) + mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ imath.V3f( 0, 1, 0 ) ] * 6 ) ) sc.writeObject( mesh, time ) - matrix = IECore.M44d.createTranslated( IECore.V3d( 2, 0, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 2, 0, 0 ) ) matrix = matrix.rotate( rotation ) sc.writeTransform( IECore.M44dData( matrix ), time ) sc = sc.createChild( str( 3 ) ) - mesh = IECoreScene.MeshPrimitive.createBox(IECore.Box3f(IECore.V3f(0),IECore.V3f(1))) - mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ IECore.V3f( 0, 0, 1 ) ] * 6 ) ) + mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) + mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ imath.V3f( 0, 0, 1 ) ] * 6 ) ) sc.writeObject( mesh, time ) - matrix = IECore.M44d.createTranslated( IECore.V3d( 3, 0, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 3, 0, 0 ) ) matrix = matrix.rotate( rotation ) sc.writeTransform( IECore.M44dData( matrix ), time ) @@ -216,7 +217,7 @@ def testSimple( node ) : testSimple( xform ) testSimple( geo ) - self.writeSCC( rotation = IECore.V3d( 0, 0, IECore.degreesToRadians( -30 ) ) ) + self.writeSCC( rotation = imath.V3d( 0, 0, IECore.degreesToRadians( -30 ) ) ) def testRotated( node ) : @@ -260,7 +261,7 @@ def testSimple( node ) : testSimple( xform ) testSimple( geo ) - self.writeSCC( rotation = IECore.V3d( 0, 0, IECore.degreesToRadians( -30 ) ) ) + self.writeSCC( rotation = imath.V3d( 0, 0, IECore.degreesToRadians( -30 ) ) ) def testRotated( node ) : @@ -522,21 +523,21 @@ def writeTestFile() : scene = IECoreScene.SceneCache( self._testFile, IECore.IndexedIO.OpenMode.Write ) sc = scene.createChild( str( 1 ) ) - matrix = IECore.M44d.createTranslated( IECore.V3d( 1, 0, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 1, 0, 0 ) ) sc.writeTransform( IECore.M44dData( matrix ), 0 ) sc = sc.createChild( str( 2 ) ) - matrix = IECore.M44d.createTranslated( IECore.V3d( 2, 0, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 2, 0, 0 ) ) sc.writeTransform( IECore.M44dData( matrix ), 0 ) sc = sc.createChild( str( 3 ) ) - matrix = IECore.M44d.createTranslated( IECore.V3d( 3, 0, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 3, 0, 0 ) ) sc.writeTransform( IECore.M44dData( matrix ), 0 ) - mesh = IECoreScene.MeshPrimitive.createBox(IECore.Box3f(IECore.V3f(0),IECore.V3f(1))) + mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) mesh["Pref"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, mesh["P"].data ) mesh["otherP"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, mesh["P"].data ) - mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f( 0, 0, 1 ) ] * 8 ) ) + mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f( 0, 0, 1 ) ] * 8 ) ) sc.writeObject( mesh, 0 ) writeTestFile() @@ -685,11 +686,11 @@ def testSopAttributeCopy( self ) : self.assertEqual( node.geometry().vertexAttribs(), tuple() ) self.assertEqual( node.geometry().globalAttribs(), tuple() ) # ensure the rest does not transform along with P by making sure it matches the static P - original = IECoreScene.MeshPrimitive.createBox(IECore.Box3f(IECore.V3f(0),IECore.V3f(1))) + original = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) for point in node.geometry().points() : rest = point.attribValue( "rest" ) self.assertNotEqual( point.attribValue( "P" ), rest ) - self.assertEqual( original["P"].data[ point.number() % 8 ], IECore.V3f( rest[0], rest[1], rest[2] ) ) + self.assertEqual( original["P"].data[ point.number() % 8 ], imath.V3f( rest[0], rest[1], rest[2] ) ) # copying multiple prim vars node.parm( "attributeCopy" ).set( "P:Pref Cs:Cspecial" ) @@ -702,7 +703,7 @@ def testSopAttributeCopy( self ) : for point in node.geometry().points() : rest = point.attribValue( "rest" ) self.assertNotEqual( point.attribValue( "P" ), rest ) - self.assertEqual( original["P"].data[ point.number() % 8 ], IECore.V3f( rest[0], rest[1], rest[2] ) ) + self.assertEqual( original["P"].data[ point.number() % 8 ], imath.V3f( rest[0], rest[1], rest[2] ) ) for prim in node.geometry().prims() : self.assertEqual( prim.attribValue( "Cd" ), prim.attribValue( "Cspecial" ) ) @@ -1091,7 +1092,7 @@ def writeDualTaggedSCC( self ) : sc1 = scene.child( str(1 ) ) sc4 = sc1.createChild( str(4) ) sc4.writeTags( [ "d" ] ) - box = IECoreScene.MeshPrimitive.createBox(IECore.Box3f(IECore.V3f(0),IECore.V3f(1))) + box = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) sc5 = sc4.createChild( str(5) ) sc5.writeObject( box, 0 ) @@ -1328,15 +1329,15 @@ def testEmptyTags( self ) : scene = IECoreScene.SceneCache( self._testFile, IECore.IndexedIO.OpenMode.Write ) sc = scene.createChild( str( 1 ) ) - matrix = IECore.M44d.createTranslated( IECore.V3d( 1, 0, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 1, 0, 0 ) ) sc.writeTransform( IECore.M44dData( matrix ), 0 ) sc = sc.createChild( str( 2 ) ) - matrix = IECore.M44d.createTranslated( IECore.V3d( 2, 0, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 2, 0, 0 ) ) sc.writeTransform( IECore.M44dData( matrix ), 0 ) sc = sc.createChild( str( 3 ) ) - matrix = IECore.M44d.createTranslated( IECore.V3d( 3, 0, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 3, 0, 0 ) ) sc.writeTransform( IECore.M44dData( matrix ), 0 ) del scene, sc @@ -1544,13 +1545,13 @@ def writeAttributeSCC( self ) : sc2 = sc1.child( str( 2 ) ) sc3 = sc2.child( str( 3 ) ) sc1.writeAttribute( "label", IECore.StringData( "a" ), 0 ) - sc1.writeAttribute( "color", IECore.Color3dData( IECore.Color3d( 0.5 ) ), 0 ) + sc1.writeAttribute( "color", IECore.Color3fData( imath.Color3f( 0.5 ) ), 0 ) sc2.writeAttribute( "label", IECore.StringData( "b" ), 0 ) sc2.writeAttribute( "material", IECore.StringData( "rubber" ), 0 ) sc3.writeAttribute( "label", IECore.StringData( "c" ), 0 ) - sc3.writeAttribute( "animColor", IECore.Color3dData( IECore.Color3d( 0 ) ), 0 ) - sc3.writeAttribute( "animColor", IECore.Color3dData( IECore.Color3d( 0.5 ) ), 0.5 ) - sc3.writeAttribute( "animColor", IECore.Color3dData( IECore.Color3d( 1 ) ), 1 ) + sc3.writeAttribute( "animColor", IECore.Color3fData( imath.Color3f( 0 ) ), 0 ) + sc3.writeAttribute( "animColor", IECore.Color3fData( imath.Color3f( 0.5 ) ), 0.5 ) + sc3.writeAttribute( "animColor", IECore.Color3fData( imath.Color3f( 1 ) ), 1 ) return scene @@ -1588,7 +1589,7 @@ def testLiveAttributes( self ) : self.assertTrue( a.hasAttribute( attr ) ) self.assertFalse( a.hasAttribute( "material" ) ) self.assertEqual( a.readAttribute( "label", 0 ), IECore.StringData( "a" ) ) - self.assertEqual( a.readAttribute( "color", 0 ), IECore.Color3dData( IECore.Color3d( 0.5 ) ) ) + self.assertEqual( a.readAttribute( "color", 0 ), IECore.Color3fData( imath.Color3f( 0.5 ) ) ) b = a.child( "2" ) self.assertEqual( sorted(b.attributeNames()), [ "label", "material", "sceneInterface:animatedObjectPrimVars" ] ) @@ -1605,9 +1606,9 @@ def testLiveAttributes( self ) : self.assertFalse( c.hasAttribute( "color" ) ) self.assertFalse( c.hasAttribute( "material" ) ) self.assertEqual( c.readAttribute( "label", 0 ), IECore.StringData( "c" ) ) - self.assertEqual( c.readAttribute( "animColor", 0 ), IECore.Color3dData( IECore.Color3d( 0 ) ) ) - self.assertEqual( c.readAttribute( "animColor", 0.5 ), IECore.Color3dData( IECore.Color3d( 0.5 ) ) ) - self.assertEqual( c.readAttribute( "animColor", 1 ), IECore.Color3dData( IECore.Color3d( 1 ) ) ) + self.assertEqual( c.readAttribute( "animColor", 0 ), IECore.Color3fData( imath.Color3f( 0 ) ) ) + self.assertEqual( c.readAttribute( "animColor", 0.5 ), IECore.Color3fData( imath.Color3f( 0.5 ) ) ) + self.assertEqual( c.readAttribute( "animColor", 1 ), IECore.Color3fData( imath.Color3f( 1 ) ) ) def testFullPathName( self ) : @@ -1710,25 +1711,25 @@ def writeAnimSCC( self, rotate = False ) : sc1 = scene.child( str( 1 ) ) sc2 = sc1.child( str( 2 ) ) sc3 = sc2.child( str( 3 ) ) - mesh = IECoreScene.MeshPrimitive.createBox(IECore.Box3f(IECore.V3f(0),IECore.V3f(1))) + mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) for time in [ 0.5, 1, 1.5, 2, 5, 10 ] : - matrix = IECore.M44d.createTranslated( IECore.V3d( 1, time, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 1, time, 0 ) ) if rotate : - matrix.rotate( IECore.V3d( time, 0, 0 ) ) + matrix.rotate( imath.V3d( time, 0, 0 ) ) sc1.writeTransform( IECore.M44dData( matrix ), time ) - mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ IECore.V3f( time, 1, 0 ) ] * 6 ) ) + mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ imath.V3f( time, 1, 0 ) ] * 6 ) ) sc2.writeObject( mesh, time ) - matrix = IECore.M44d.createTranslated( IECore.V3d( 2, time, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 2, time, 0 ) ) if rotate : - matrix.rotate( IECore.V3d( time, 0, 0 ) ) + matrix.rotate( imath.V3d( time, 0, 0 ) ) sc2.writeTransform( IECore.M44dData( matrix ), time ) - matrix = IECore.M44d.createTranslated( IECore.V3d( 3, time, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 3, time, 0 ) ) if rotate : - matrix.rotate( IECore.V3d( time, 0, 0 ) ) + matrix.rotate( imath.V3d( time, 0, 0 ) ) sc3.writeTransform( IECore.M44dData( matrix ), time ) return scene @@ -1779,26 +1780,26 @@ def testAnimatedScene( self ) : c = [ x for x in b.children() if x.name() != "geo" ][0] for time in times : if hou.applicationVersion()[0] >= 14 : - self.assertEqual( IECore.M44d( list(xform.localTransformAtTime( time - spf ).asTuple()) ), IECore.M44d() ) - self.assertEqual( IECore.M44d( list(a.localTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 1, time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(b.localTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 2, time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(c.localTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 3, time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(xform.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d() ) - self.assertEqual( IECore.M44d( list(a.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 1, time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(b.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 3, time * 2, 0 ) ) ) - self.assertEqual( IECore.M44d( list(c.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 6, time * 3, 0 ) ) ) + self.assertEqual( imath.M44d( *(xform.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d() ) + self.assertEqual( imath.M44d( *(a.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 1, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(b.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 2, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(c.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 3, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(xform.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d() ) + self.assertEqual( imath.M44d( *(a.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 1, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(b.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 3, time * 2, 0 ) ) ) + self.assertEqual( imath.M44d( *(c.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 6, time * 3, 0 ) ) ) else : - self.assertEqual( IECore.M44d( list(xform.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d() ) - self.assertEqual( IECore.M44d( list(a.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 1, time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(b.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 2, time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(c.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 3, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(xform.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d() ) + self.assertEqual( imath.M44d( *(a.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 1, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(b.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 2, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(c.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 3, time, 0 ) ) ) for time in times : hou.setTime( time - spf ) - self.assertEqual( IECore.M44d( list(xform.parmTransform().asTuple()) ), IECore.M44d() ) - self.assertEqual( IECore.M44d( list(a.parmTransform().asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 1, time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(b.parmTransform().asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 2, time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(c.parmTransform().asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 3, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(xform.parmTransform().asTuple()) ), imath.M44d() ) + self.assertEqual( imath.M44d( *(a.parmTransform().asTuple()) ), imath.M44d().translate( imath.V3d( 1, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(b.parmTransform().asTuple()) ), imath.M44d().translate( imath.V3d( 2, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(c.parmTransform().asTuple()) ), imath.M44d().translate( imath.V3d( 3, time, 0 ) ) ) xform.parm( "hierarchy" ).set( IECoreHoudini.SceneCacheNode.Hierarchy.Parenting ) xform.parm( "collapse" ).pressButton() @@ -1808,26 +1809,26 @@ def testAnimatedScene( self ) : c = xform.children()[2] for time in times : if hou.applicationVersion()[0] >= 14 : - self.assertEqual( IECore.M44d( list(xform.localTransformAtTime( time - spf ).asTuple()) ), IECore.M44d() ) - self.assertEqual( IECore.M44d( list(a.localTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 1, time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(b.localTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 2, time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(c.localTransformAtTime( time -spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 3, time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(xform.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d() ) - self.assertEqual( IECore.M44d( list(a.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 1, time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(b.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 3, 2*time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(c.worldTransformAtTime( time -spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 6, 3*time, 0 ) ) ) + self.assertEqual( imath.M44d( *(xform.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d() ) + self.assertEqual( imath.M44d( *(a.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 1, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(b.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 2, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(c.localTransformAtTime( time -spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 3, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(xform.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d() ) + self.assertEqual( imath.M44d( *(a.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 1, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(b.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 3, 2*time, 0 ) ) ) + self.assertEqual( imath.M44d( *(c.worldTransformAtTime( time -spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 6, 3*time, 0 ) ) ) else : - self.assertEqual( IECore.M44d( list(xform.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d() ) - self.assertEqual( IECore.M44d( list(a.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 1, time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(b.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 3, 2*time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(c.worldTransformAtTime( time -spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 6, 3*time, 0 ) ) ) + self.assertEqual( imath.M44d( *(xform.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d() ) + self.assertEqual( imath.M44d( *(a.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 1, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(b.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 3, 2*time, 0 ) ) ) + self.assertEqual( imath.M44d( *(c.worldTransformAtTime( time -spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 6, 3*time, 0 ) ) ) for time in times : hou.setTime( time - spf ) - self.assertEqual( IECore.M44d( list(xform.parmTransform().asTuple()) ), IECore.M44d() ) - self.assertEqual( IECore.M44d( list(a.parmTransform().asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 1, time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(b.parmTransform().asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 2, time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(c.parmTransform().asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 3, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(xform.parmTransform().asTuple()) ), imath.M44d() ) + self.assertEqual( imath.M44d( *(a.parmTransform().asTuple()) ), imath.M44d().translate( imath.V3d( 1, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(b.parmTransform().asTuple()) ), imath.M44d().translate( imath.V3d( 2, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(c.parmTransform().asTuple()) ), imath.M44d().translate( imath.V3d( 3, time, 0 ) ) ) def testSopXformNameMode( self ) : @@ -2124,7 +2125,7 @@ def compareScene( self, a, b, time = 0, bakedObjects = [], parentTransform = Non if b.name() in bakedObjects : aTransform = a.readTransformAsMatrix( time ) parentTransform = aTransform if parentTransform is None else aTransform * parentTransform - self.assertEqual( b.readTransformAsMatrix( time ), IECore.M44d() ) + self.assertEqual( b.readTransformAsMatrix( time ), imath.M44d() ) else : self.assertEqual( set(a.readTags(IECoreScene.SceneInterface.LocalTag)), set(b.readTags(IECoreScene.SceneInterface.LocalTag)) ) self.assertEqual( set(a.readTags(IECoreScene.SceneInterface.DescendantTag)), set(b.readTags(IECoreScene.SceneInterface.DescendantTag)) ) @@ -2133,8 +2134,8 @@ def compareScene( self, a, b, time = 0, bakedObjects = [], parentTransform = Non self.assertTrue( a.readTransformAsMatrix( time ).equalWithAbsError( b.readTransformAsMatrix( time ), 1e-6 ) ) ab = a.readBound( time ) bb = b.readBound( time ) - self.assertTrue( ab.min.equalWithAbsError( bb.min, 1e-6 ) ) - self.assertTrue( ab.max.equalWithAbsError( bb.max, 1e-6 ) ) + self.assertTrue( ab.min().equalWithAbsError( bb.min(), 1e-6 ) ) + self.assertTrue( ab.max().equalWithAbsError( bb.max(), 1e-6 ) ) aAttrs = a.attributeNames() bAttrs = b.attributeNames() @@ -2252,21 +2253,21 @@ def testRopFlattenedWithGaps( self ) : scene = IECoreScene.SceneCache( self._testFile, IECore.IndexedIO.OpenMode.Write ) sc = scene.createChild( str( 1 ) ) - mesh = IECoreScene.MeshPrimitive.createBox(IECore.Box3f(IECore.V3f(0),IECore.V3f(1))) - mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ IECore.V3f( 1, 0, 0 ) ] * 6 ) ) + mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) + mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ imath.V3f( 1, 0, 0 ) ] * 6 ) ) sc.writeObject( mesh, 0 ) - matrix = IECore.M44d.createTranslated( IECore.V3d( 1, 0, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 1, 0, 0 ) ) sc.writeTransform( IECore.M44dData( matrix ), 0 ) sc = sc.createChild( str( 2 ) ) - matrix = IECore.M44d.createTranslated( IECore.V3d( 2, 0, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 2, 0, 0 ) ) sc.writeTransform( IECore.M44dData( matrix ), 0 ) sc = sc.createChild( str( 3 ) ) - mesh = IECoreScene.MeshPrimitive.createBox(IECore.Box3f(IECore.V3f(0),IECore.V3f(1))) - mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ IECore.V3f( 0, 0, 1 ) ] * 6 ) ) + mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) + mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ imath.V3f( 0, 0, 1 ) ] * 6 ) ) sc.writeObject( mesh, 0 ) - matrix = IECore.M44d.createTranslated( IECore.V3d( 3, 0, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 3, 0, 0 ) ) sc.writeTransform( IECore.M44dData( matrix ), 0 ) del scene, sc @@ -2309,12 +2310,12 @@ def testRopTopLevelGeo( self ) : self.assertEqual( len( rop.errors() ) , 0 ) output = IECoreScene.SceneCache( self._testOutFile, IECore.IndexedIO.OpenMode.Read ) self.assertEqual( output.name(), "/" ) - self.assertEqual( output.readTransformAsMatrix( 0 ), IECore.M44d() ) + self.assertEqual( output.readTransformAsMatrix( 0 ), imath.M44d() ) self.assertFalse( output.hasObject() ) self.assertEqual( output.childNames(), [ "ieSceneCacheGeometry1" ] ) root = output.child( "ieSceneCacheGeometry1" ) self.assertEqual( root.name(), "ieSceneCacheGeometry1" ) - self.assertEqual( root.readTransformAsMatrix( 0 ), IECore.M44d() ) + self.assertEqual( root.readTransformAsMatrix( 0 ), imath.M44d() ) self.assertTrue( root.hasObject() ) obj = root.readObject( 0 ) self.assertTrue( isinstance( obj, IECoreScene.Group ) ) @@ -2341,12 +2342,12 @@ def testRopFlattenedAndHidden( self ) : self.assertEqual( len( rop.errors() ) , 0 ) output = IECoreScene.SceneCache( self._testOutFile, IECore.IndexedIO.OpenMode.Read ) self.assertEqual( output.name(), "/" ) - self.assertEqual( output.readTransformAsMatrix( 0 ), IECore.M44d() ) + self.assertEqual( output.readTransformAsMatrix( 0 ), imath.M44d() ) self.assertFalse( output.hasObject() ) self.assertEqual( output.childNames(), [ "ieSceneCacheGeometry1" ] ) root = output.child( "ieSceneCacheGeometry1" ) self.assertEqual( root.name(), "ieSceneCacheGeometry1" ) - self.assertEqual( root.readTransformAsMatrix( 0 ), IECore.M44d() ) + self.assertEqual( root.readTransformAsMatrix( 0 ), imath.M44d() ) self.assertTrue( root.hasObject() ) obj = root.readObject( 0 ) self.assertTrue( isinstance( obj, IECoreScene.Group ) ) @@ -2443,7 +2444,7 @@ def testRopForceObjects( self ) : s = self.writeAttributeSCC() d = s.child( "1" ).createChild( "4" ) e = d.createChild( "5" ) - box = IECoreScene.MeshPrimitive.createBox(IECore.Box3f(IECore.V3f(0),IECore.V3f(1))) + box = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) d.writeObject( box, 0 ) e.writeObject( box, 0 ) @@ -2705,11 +2706,11 @@ def testLiveScene( self ) : def testTopologyChanges( self ) : - plane = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) - box = IECoreScene.MeshPrimitive.createBox( IECore.Box3f( IECore.V3f( 0 ), IECore.V3f( 1 ) ) ) - box["Cd"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.Color3fVectorData( [ IECore.Color3f( 1, 0, 0 ) ] * box.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) ) ) - box2 = IECoreScene.MeshPrimitive.createBox( IECore.Box3f( IECore.V3f( 2 ), IECore.V3f( 3 ) ) ) - box2["Cd"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.Color3fVectorData( [ IECore.Color3f( 0, 1, 0 ) ] * box.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) ) ) + plane = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) + box = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( 0 ), imath.V3f( 1 ) ) ) + box["Cd"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.Color3fVectorData( [ imath.Color3f( 1, 0, 0 ) ] * box.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) ) ) + box2 = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( 2 ), imath.V3f( 3 ) ) ) + box2["Cd"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.Color3fVectorData( [ imath.Color3f( 0, 1, 0 ) ] * box.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) ) ) s = IECoreScene.SceneCache( self._testFile, IECore.IndexedIO.OpenMode.Write ) a = s.createChild( "a" ) @@ -2876,9 +2877,9 @@ def testNonPrimitiveCortexObjects( self ) : coordChild = scene.child( "1" ).createChild( "coord" ) coord = IECoreScene.CoordinateSystem() coord.setName( "testing" ) - coord.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( 1, 2, 3 ) ) ) ) + coord.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 1, 2, 3 ) ) ) ) coordChild.writeObject( coord, 0 ) - coord.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( 1, 5, 5 ) ) ) ) + coord.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 1, 5, 5 ) ) ) ) coordChild.writeObject( coord, 1 ) intsChild = scene.createChild( "ints" ) intsChild.writeObject( IECore.IntVectorData( [ 1, 10, 20, 30 ] ), 0 ) @@ -2972,7 +2973,7 @@ def testCoordinateSystemNoTransform( self ) : coord.setName( "testing" ) coordChild.writeObject( coord, 0 ) coordChild2 = coordChild.createChild( "other") - coordChild2.writeTransform( IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 1, 2, 3 ) ) ), 0 ) + coordChild2.writeTransform( IECore.M44dData( imath.M44d().translate( imath.V3d( 1, 2, 3 ) ) ), 0 ) coordChild2.writeObject( coord, 0 ) del scene, coordChild, coordChild2 @@ -3013,14 +3014,14 @@ def testObjectMerge( self ) : self.assertEqual( geo.points()[0].position(), hou.Vector3( 3.5, 0.5, 0.5 ) ) self.assertEqual( geo.boundingBox(), hou.BoundingBox( 3, 0, 0, 4, 1, 1 ) ) mesh = IECoreHoudini.FromHoudiniGeometryConverter.create( merge ).convert() - self.assertEqual( mesh.bound(), IECore.Box3f( IECore.V3f( 3, 0, 0 ), IECore.V3f( 4, 1, 1 ) ) ) + self.assertEqual( mesh.bound(), imath.Box3f( imath.V3f( 3, 0, 0 ), imath.V3f( 4, 1, 1 ) ) ) # didn't affect the original SOP because it stores it's own copy of the prim geo = origSop.geometry() self.assertEqual( geo.points()[0].position(), hou.Vector3( 0.5, 0.5, 0.5 ) ) self.assertEqual( geo.boundingBox(), hou.BoundingBox( 0, 0, 0, 1, 1, 1 ) ) mesh = IECoreHoudini.FromHoudiniGeometryConverter.create( origSop ).convert() - self.assertEqual( mesh.bound(), IECore.Box3f( IECore.V3f( 0 ), IECore.V3f( 1 ) ) ) + self.assertEqual( mesh.bound(), imath.Box3f( imath.V3f( 0 ), imath.V3f( 1 ) ) ) # transformable at the SOP level as well sopXform = merge.createOutputNode( "xform" ) @@ -3029,14 +3030,14 @@ def testObjectMerge( self ) : self.assertEqual( geo.points()[0].position(), hou.Vector3( 3.5, 7.5, 0.5 ) ) self.assertEqual( geo.boundingBox(), hou.BoundingBox( 3, 7, 0, 4, 8, 1 ) ) mesh = IECoreHoudini.FromHoudiniGeometryConverter.create( sopXform ).convert() - self.assertEqual( mesh.bound(), IECore.Box3f( IECore.V3f( 3, 7, 0 ), IECore.V3f( 4, 8, 1 ) ) ) + self.assertEqual( mesh.bound(), imath.Box3f( imath.V3f( 3, 7, 0 ), imath.V3f( 4, 8, 1 ) ) ) # didn't affect the input SOP because it stores it's own copy of the prim geo = merge.geometry() self.assertEqual( geo.points()[0].position(), hou.Vector3( 3.5, 0.5, 0.5 ) ) self.assertEqual( geo.boundingBox(), hou.BoundingBox( 3, 0, 0, 4, 1, 1 ) ) mesh = IECoreHoudini.FromHoudiniGeometryConverter.create( merge ).convert() - self.assertEqual( mesh.bound(), IECore.Box3f( IECore.V3f( 3, 0, 0 ), IECore.V3f( 4, 1, 1 ) ) ) + self.assertEqual( mesh.bound(), imath.Box3f( imath.V3f( 3, 0, 0 ), imath.V3f( 4, 1, 1 ) ) ) def testPointsDontAccumulate( self ) : @@ -3088,10 +3089,10 @@ def testTimeDependent( self ) : for time in [ 0.5, 1, 1.5, 2, 5, 10 ] : - matrix = IECore.M44d.createTranslated( IECore.V3d( 2, time, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 2, time, 0 ) ) sc2.writeTransform( IECore.M44dData( matrix ), time ) - matrix = IECore.M44d.createTranslated( IECore.V3d( 3, time, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 3, time, 0 ) ) sc3.writeTransform( IECore.M44dData( matrix ), time ) del scene, sc1, sc2, sc3 @@ -3113,13 +3114,13 @@ def testTimeDependent( self ) : sc2 = sc1.child( str( 2 ) ) sc3 = sc2.child( str( 3 ) ) - mesh = IECoreScene.MeshPrimitive.createBox(IECore.Box3f(IECore.V3f(0),IECore.V3f(1))) + mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) for time in [ 0.5, 1, 1.5, 2, 5, 10 ] : - matrix = IECore.M44d.createTranslated( IECore.V3d( 2, time, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 2, time, 0 ) ) sc2.writeTransform( IECore.M44dData( matrix ), time ) - mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ IECore.V3f( time, 1, 0 ) ] * 6 ) ) + mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ imath.V3f( time, 1, 0 ) ] * 6 ) ) sc2.writeObject( mesh, time ) del scene, sc1, sc2, sc3 @@ -3177,26 +3178,26 @@ def testTransformOverride( self ) : c = [ x for x in b.children() if x.name() != "geo" ][0] for time in times : if hou.applicationVersion()[0] >= 14 : - self.assertEqual( IECore.M44d( list(xform.localTransformAtTime( time - spf ).asTuple()) ), IECore.M44d() ) - self.assertEqual( IECore.M44d( list(a.localTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 1, time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(b.localTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 2, time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(c.localTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 3, time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(xform.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d() ) - self.assertEqual( IECore.M44d( list(a.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 1, time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(b.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 3, time * 2, 0 ) ) ) - self.assertEqual( IECore.M44d( list(c.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 6, time * 3, 0 ) ) ) + self.assertEqual( imath.M44d( *(xform.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d() ) + self.assertEqual( imath.M44d( *(a.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 1, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(b.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 2, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(c.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 3, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(xform.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d() ) + self.assertEqual( imath.M44d( *(a.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 1, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(b.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 3, time * 2, 0 ) ) ) + self.assertEqual( imath.M44d( *(c.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 6, time * 3, 0 ) ) ) else : - self.assertEqual( IECore.M44d( list(xform.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d() ) - self.assertEqual( IECore.M44d( list(a.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 1, time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(b.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 2, time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(c.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 3, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(xform.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d() ) + self.assertEqual( imath.M44d( *(a.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 1, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(b.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 2, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(c.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 3, time, 0 ) ) ) for time in times : hou.setTime( time - spf ) - self.assertEqual( IECore.M44d( list(xform.parmTransform().asTuple()) ), IECore.M44d() ) - self.assertEqual( IECore.M44d( list(a.parmTransform().asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 1, time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(b.parmTransform().asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 2, time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(c.parmTransform().asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 3, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(xform.parmTransform().asTuple()) ), imath.M44d() ) + self.assertEqual( imath.M44d( *(a.parmTransform().asTuple()) ), imath.M44d().translate( imath.V3d( 1, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(b.parmTransform().asTuple()) ), imath.M44d().translate( imath.V3d( 2, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(c.parmTransform().asTuple()) ), imath.M44d().translate( imath.V3d( 3, time, 0 ) ) ) a.parm( "overrideTransform" ).set( True ) c.parm( "overrideTransform" ).set( True ) @@ -3204,26 +3205,26 @@ def testTransformOverride( self ) : for time in times : if hou.applicationVersion()[0] >= 14 : - self.assertEqual( IECore.M44d( list(xform.localTransformAtTime( time - spf ).asTuple()) ), IECore.M44d() ) - self.assertEqual( IECore.M44d( list(a.localTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 0, 0, 0 ) ) ) - self.assertEqual( IECore.M44d( list(b.localTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 2, time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(c.localTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( time, 0, 0 ) ) ) - self.assertEqual( IECore.M44d( list(xform.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d() ) - self.assertEqual( IECore.M44d( list(a.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 0, 0, 0 ) ) ) - self.assertEqual( IECore.M44d( list(b.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 2, time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(c.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 2 + time, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(xform.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d() ) + self.assertEqual( imath.M44d( *(a.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 0, 0, 0 ) ) ) + self.assertEqual( imath.M44d( *(b.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 2, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(c.localTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( time, 0, 0 ) ) ) + self.assertEqual( imath.M44d( *(xform.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d() ) + self.assertEqual( imath.M44d( *(a.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 0, 0, 0 ) ) ) + self.assertEqual( imath.M44d( *(b.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 2, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(c.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 2 + time, time, 0 ) ) ) else : - self.assertEqual( IECore.M44d( list(xform.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d() ) - self.assertEqual( IECore.M44d( list(a.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 0, 0, 0 ) ) ) - self.assertEqual( IECore.M44d( list(b.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 2, time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(c.worldTransformAtTime( time - spf ).asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( time, 0, 0 ) ) ) + self.assertEqual( imath.M44d( *(xform.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d() ) + self.assertEqual( imath.M44d( *(a.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 0, 0, 0 ) ) ) + self.assertEqual( imath.M44d( *(b.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( 2, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(c.worldTransformAtTime( time - spf ).asTuple()) ), imath.M44d().translate( imath.V3d( time, 0, 0 ) ) ) for time in times : hou.setTime( time - spf ) - self.assertEqual( IECore.M44d( list(xform.parmTransform().asTuple()) ), IECore.M44d() ) - self.assertEqual( IECore.M44d( list(a.parmTransform().asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 0, 0, 0 ) ) ) - self.assertEqual( IECore.M44d( list(b.parmTransform().asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( 2, time, 0 ) ) ) - self.assertEqual( IECore.M44d( list(c.parmTransform().asTuple()) ), IECore.M44d.createTranslated( IECore.V3d( time, 0, 0 ) ) ) + self.assertEqual( imath.M44d( *(xform.parmTransform().asTuple()) ), imath.M44d() ) + self.assertEqual( imath.M44d( *(a.parmTransform().asTuple()) ), imath.M44d().translate( imath.V3d( 0, 0, 0 ) ) ) + self.assertEqual( imath.M44d( *(b.parmTransform().asTuple()) ), imath.M44d().translate( imath.V3d( 2, time, 0 ) ) ) + self.assertEqual( imath.M44d( *(c.parmTransform().asTuple()) ), imath.M44d().translate( imath.V3d( time, 0, 0 ) ) ) def testGeometryTypes( self ) : @@ -3311,21 +3312,21 @@ def testGeometryTypes( self ) : bWorld = aWorld * b.readTransformAsMatrix( time ) cWorld = bWorld * c.readTransformAsMatrix( time ) - self.assertTrue( IECore.V3d( list(aPoint.position()) ).equalWithAbsError( aWorld.multVecMatrix( a.readBound( time ).center() ), 1e-6 ) ) - self.assertTrue( IECore.V3d( list(bPoint.position()) ).equalWithAbsError( bWorld.multVecMatrix( b.readBound( time ).center() ), 1e-6 ) ) - self.assertTrue( IECore.V3d( list(cPoint.position()) ).equalWithAbsError( cWorld.multVecMatrix( c.readBound( time ).center() ), 1e-6 ) ) + self.assertTrue( imath.V3d( list(aPoint.position()) ).equalWithAbsError( aWorld.multVecMatrix( a.readBound( time ).center() ), 1e-6 ) ) + self.assertTrue( imath.V3d( list(bPoint.position()) ).equalWithAbsError( bWorld.multVecMatrix( b.readBound( time ).center() ), 1e-6 ) ) + self.assertTrue( imath.V3d( list(cPoint.position()) ).equalWithAbsError( cWorld.multVecMatrix( c.readBound( time ).center() ), 1e-6 ) ) - self.assertTrue( IECore.V3d( list(aPoint.attribValue( "basis1" )) ).equalWithAbsError( IECore.V3d( aWorld[(0,0)], aWorld[(0,1)], aWorld[(0,2)] ), 1e-6 ) ) - self.assertTrue( IECore.V3d( list(aPoint.attribValue( "basis2" )) ).equalWithAbsError( IECore.V3d( aWorld[(1,0)], aWorld[(1,1)], aWorld[(1,2)] ), 1e-6 ) ) - self.assertTrue( IECore.V3d( list(aPoint.attribValue( "basis3" )) ).equalWithAbsError( IECore.V3d( aWorld[(2,0)], aWorld[(2,1)], aWorld[(2,2)] ), 1e-6 ) ) + self.assertTrue( imath.V3d( list(aPoint.attribValue( "basis1" )) ).equalWithAbsError( imath.V3d( aWorld[0][0], aWorld[0][1], aWorld[0][2] ), 1e-6 ) ) + self.assertTrue( imath.V3d( list(aPoint.attribValue( "basis2" )) ).equalWithAbsError( imath.V3d( aWorld[1][0], aWorld[1][1], aWorld[1][2] ), 1e-6 ) ) + self.assertTrue( imath.V3d( list(aPoint.attribValue( "basis3" )) ).equalWithAbsError( imath.V3d( aWorld[2][0], aWorld[2][1], aWorld[2][2] ), 1e-6 ) ) - self.assertTrue( IECore.V3d( list(bPoint.attribValue( "basis1" )) ).equalWithAbsError( IECore.V3d( bWorld[(0,0)], bWorld[(0,1)], bWorld[(0,2)] ), 1e-6 ) ) - self.assertTrue( IECore.V3d( list(bPoint.attribValue( "basis2" )) ).equalWithAbsError( IECore.V3d( bWorld[(1,0)], bWorld[(1,1)], bWorld[(1,2)] ), 1e-6 ) ) - self.assertTrue( IECore.V3d( list(bPoint.attribValue( "basis3" )) ).equalWithAbsError( IECore.V3d( bWorld[(2,0)], bWorld[(2,1)], bWorld[(2,2)] ), 1e-6 ) ) + self.assertTrue( imath.V3d( list(bPoint.attribValue( "basis1" )) ).equalWithAbsError( imath.V3d( bWorld[0][0], bWorld[0][1], bWorld[0][2] ), 1e-6 ) ) + self.assertTrue( imath.V3d( list(bPoint.attribValue( "basis2" )) ).equalWithAbsError( imath.V3d( bWorld[1][0], bWorld[1][1], bWorld[1][2] ), 1e-6 ) ) + self.assertTrue( imath.V3d( list(bPoint.attribValue( "basis3" )) ).equalWithAbsError( imath.V3d( bWorld[2][0], bWorld[2][1], bWorld[2][2] ), 1e-6 ) ) - self.assertTrue( IECore.V3d( list(cPoint.attribValue( "basis1" )) ).equalWithAbsError( IECore.V3d( cWorld[(0,0)], cWorld[(0,1)], cWorld[(0,2)] ), 1e-6 ) ) - self.assertTrue( IECore.V3d( list(cPoint.attribValue( "basis2" )) ).equalWithAbsError( IECore.V3d( cWorld[(1,0)], cWorld[(1,1)], cWorld[(1,2)] ), 1e-6 ) ) - self.assertTrue( IECore.V3d( list(cPoint.attribValue( "basis3" )) ).equalWithAbsError( IECore.V3d( cWorld[(2,0)], cWorld[(2,1)], cWorld[(2,2)] ), 1e-6 ) ) + self.assertTrue( imath.V3d( list(cPoint.attribValue( "basis1" )) ).equalWithAbsError( imath.V3d( cWorld[0][0], cWorld[0][1], cWorld[0][2] ), 1e-6 ) ) + self.assertTrue( imath.V3d( list(cPoint.attribValue( "basis2" )) ).equalWithAbsError( imath.V3d( cWorld[1][0], cWorld[1][1], cWorld[1][2] ), 1e-6 ) ) + self.assertTrue( imath.V3d( list(cPoint.attribValue( "basis3" )) ).equalWithAbsError( imath.V3d( cWorld[2][0], cWorld[2][1], cWorld[2][2] ), 1e-6 ) ) def testNonExistantAttributes( self ) : @@ -3406,10 +3407,10 @@ def write() : scene = self.writeSCC() sc = scene.createChild( str( 4 ) ) - mesh = IECoreScene.MeshPrimitive.createBox(IECore.Box3f(IECore.V3f(0),IECore.V3f(1))) - mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ IECore.V3f( 1, 0, 0 ) ] * 6 ) ) + mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) + mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ imath.V3f( 1, 0, 0 ) ] * 6 ) ) mesh.blindData()["name"] = IECore.StringData( "blindName" ) - matrix = IECore.M44d.createTranslated( IECore.V3d( 1, 0, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 1, 0, 0 ) ) for time in ( 0, 1, 2 ) : sc.writeObject( mesh, time ) sc.writeTransform( IECore.M44dData( matrix ), time ) diff --git a/test/IECoreHoudini/ToHoudiniCompoundObjectConverter.py b/test/IECoreHoudini/ToHoudiniCompoundObjectConverter.py index b690b4565b..a1cb3337ee 100644 --- a/test/IECoreHoudini/ToHoudiniCompoundObjectConverter.py +++ b/test/IECoreHoudini/ToHoudiniCompoundObjectConverter.py @@ -33,6 +33,7 @@ ########################################################################## import hou +import imath import IECore import IECoreScene import IECoreHoudini @@ -51,7 +52,7 @@ def mesh( self ) : intRange = range( 1, 25 ) floatVectorData = IECore.FloatVectorData( [ x+0.5 for x in intRange ] ) - color3fVectorData = IECore.Color3fVectorData( [ IECore.Color3f( x, x+0.5, x+0.75 ) for x in intRange ] ) + color3fVectorData = IECore.Color3fVectorData( [ imath.Color3f( x, x+0.5, x+0.75 ) for x in intRange ] ) stringVectorData = IECore.StringVectorData( [ "string number %d!" % x for x in intRange ] ) detailInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Constant @@ -60,8 +61,8 @@ def mesh( self ) : vertexInterpolation = IECoreScene.PrimitiveVariable.Interpolation.FaceVarying pData = IECore.V3fVectorData( [ - IECore.V3f( 0, 1, 2 ), IECore.V3f( 1 ), IECore.V3f( 2 ), IECore.V3f( 3 ), - IECore.V3f( 4 ), IECore.V3f( 5 ), IECore.V3f( 6 ), IECore.V3f( 7 ), + imath.V3f( 0, 1, 2 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ), + imath.V3f( 4 ), imath.V3f( 5 ), imath.V3f( 6 ), imath.V3f( 7 ), ], IECore.GeometricData.Interpretation.Point ) mesh["P"] = IECoreScene.PrimitiveVariable( pointInterpolation, pData ) mesh["floatPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, floatVectorData[:8] ) @@ -81,16 +82,16 @@ def mesh( self ) : def points( self ) : pData = IECore.V3fVectorData( [ - IECore.V3f( 0, 1, 2 ), IECore.V3f( 1 ), IECore.V3f( 2 ), IECore.V3f( 3 ), - IECore.V3f( 4 ), IECore.V3f( 5 ), IECore.V3f( 6 ), IECore.V3f( 7 ), - IECore.V3f( 8 ), IECore.V3f( 9 ), IECore.V3f( 10 ), IECore.V3f( 11 ), + imath.V3f( 0, 1, 2 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ), + imath.V3f( 4 ), imath.V3f( 5 ), imath.V3f( 6 ), imath.V3f( 7 ), + imath.V3f( 8 ), imath.V3f( 9 ), imath.V3f( 10 ), imath.V3f( 11 ), ] ) points = IECoreScene.PointsPrimitive( pData ) intRange = range( 1, 13 ) floatVectorData = IECore.FloatVectorData( [ x+0.5 for x in intRange ] ) - color3fVectorData = IECore.Color3fVectorData( [ IECore.Color3f( x, x+0.5, x+0.75 ) for x in intRange ] ) + color3fVectorData = IECore.Color3fVectorData( [ imath.Color3f( x, x+0.5, x+0.75 ) for x in intRange ] ) stringVectorData = IECore.StringVectorData( [ "string number %d!" % x for x in intRange ] ) detailInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Constant diff --git a/test/IECoreHoudini/ToHoudiniCortexObjectConverter.py b/test/IECoreHoudini/ToHoudiniCortexObjectConverter.py index 9d2ab54902..1f1cc13f94 100644 --- a/test/IECoreHoudini/ToHoudiniCortexObjectConverter.py +++ b/test/IECoreHoudini/ToHoudiniCortexObjectConverter.py @@ -33,6 +33,7 @@ ########################################################################## import hou +import imath import IECore import IECoreScene import IECoreHoudini @@ -51,7 +52,7 @@ def mesh( self ) : intRange = range( 1, 25 ) floatVectorData = IECore.FloatVectorData( [ x+0.5 for x in intRange ] ) - color3fVectorData = IECore.Color3fVectorData( [ IECore.Color3f( x, x+0.5, x+0.75 ) for x in intRange ] ) + color3fVectorData = IECore.Color3fVectorData( [ imath.Color3f( x, x+0.5, x+0.75 ) for x in intRange ] ) stringVectorData = IECore.StringVectorData( [ "string number %d!" % x for x in intRange ] ) detailInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Constant @@ -60,8 +61,8 @@ def mesh( self ) : vertexInterpolation = IECoreScene.PrimitiveVariable.Interpolation.FaceVarying pData = IECore.V3fVectorData( [ - IECore.V3f( 0, 1, 2 ), IECore.V3f( 1 ), IECore.V3f( 2 ), IECore.V3f( 3 ), - IECore.V3f( 4 ), IECore.V3f( 5 ), IECore.V3f( 6 ), IECore.V3f( 7 ), + imath.V3f( 0, 1, 2 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ), + imath.V3f( 4 ), imath.V3f( 5 ), imath.V3f( 6 ), imath.V3f( 7 ), ], IECore.GeometricData.Interpretation.Point ) mesh["P"] = IECoreScene.PrimitiveVariable( pointInterpolation, pData ) mesh["floatPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, floatVectorData[:8] ) @@ -81,16 +82,16 @@ def mesh( self ) : def points( self ) : pData = IECore.V3fVectorData( [ - IECore.V3f( 0, 1, 2 ), IECore.V3f( 1 ), IECore.V3f( 2 ), IECore.V3f( 3 ), - IECore.V3f( 4 ), IECore.V3f( 5 ), IECore.V3f( 6 ), IECore.V3f( 7 ), - IECore.V3f( 8 ), IECore.V3f( 9 ), IECore.V3f( 10 ), IECore.V3f( 11 ), + imath.V3f( 0, 1, 2 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ), + imath.V3f( 4 ), imath.V3f( 5 ), imath.V3f( 6 ), imath.V3f( 7 ), + imath.V3f( 8 ), imath.V3f( 9 ), imath.V3f( 10 ), imath.V3f( 11 ), ] ) points = IECoreScene.PointsPrimitive( pData ) intRange = range( 1, 13 ) floatVectorData = IECore.FloatVectorData( [ x+0.5 for x in intRange ] ) - color3fVectorData = IECore.Color3fVectorData( [ IECore.Color3f( x, x+0.5, x+0.75 ) for x in intRange ] ) + color3fVectorData = IECore.Color3fVectorData( [ imath.Color3f( x, x+0.5, x+0.75 ) for x in intRange ] ) stringVectorData = IECore.StringVectorData( [ "string number %d!" % x for x in intRange ] ) detailInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Constant @@ -396,10 +397,10 @@ def testAttributeFilter( self ) : self.assertEqual( result.keys(), [ 'P', 'floatPrim' ] ) # verify we can filter uvs - mesh = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) ) + mesh = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) IECoreScene.TriangulateOp()( input=mesh, copyInput=False ) IECoreScene.MeshNormalsOp()( input=mesh, copyInput=False ) - mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, IECore.V3fVectorData( [ IECore.V3f( 1, 0, 0 ) ] * 6, IECore.GeometricData.Interpretation.Color ) ) + mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, IECore.V3fVectorData( [ imath.V3f( 1, 0, 0 ) ] * 6, IECore.GeometricData.Interpretation.Color ) ) mesh["width"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.FloatVectorData( [ 1 ] * 4 ) ) mesh["Pref"] = mesh["P"] diff --git a/test/IECoreHoudini/ToHoudiniCurvesConverter.py b/test/IECoreHoudini/ToHoudiniCurvesConverter.py index 2db0b955b5..5496a7e3f9 100644 --- a/test/IECoreHoudini/ToHoudiniCurvesConverter.py +++ b/test/IECoreHoudini/ToHoudiniCurvesConverter.py @@ -33,6 +33,7 @@ ########################################################################## import hou +import imath import IECore import IECoreScene import IECoreHoudini @@ -49,10 +50,10 @@ class TestToHoudiniCurvesConverter( IECoreHoudini.TestCase ) : __testScene = "test/converterTest.hip" __curveCoordinates = [ - IECore.V3fVectorData( [ IECore.V3f( 2.42892,0,-1.04096 ), IECore.V3f( 1.69011,0,-9.88746 ), IECore.V3f( 5.74288,0,-4.50183 ), IECore.V3f( 2.69113,0,-2.78439 ), IECore.V3f( 5.8923,0,1.53021 ), IECore.V3f( 6.20965,-9.53674e-07,2.03933 ), IECore.V3f( 2.72012,0,2.5738 ), IECore.V3f( 1.76971,0,-0.632637 ) ] ), - IECore.V3fVectorData( [ IECore.V3f( -0.560781,0,-1.04096 ), IECore.V3f( 2.21995,0,-6.31734 ), IECore.V3f( 4.77513,0,-6.61752 ), IECore.V3f( 4.10862,0,-2.78439 ), IECore.V3f( 4.29081,0,1.53021 ), IECore.V3f( 6.20965,-9.53674e-07,3.7489 ), IECore.V3f( -2.61584,0,2.5738 ), IECore.V3f( -1.45801,0,0.780965 ) ] ), - IECore.V3fVectorData( [ IECore.V3f( 2.42892,0,-1.04096 ), IECore.V3f( 2.21995,0,-4.51254 ), IECore.V3f( 4.77513,0,-4.50183 ), IECore.V3f( 6.32944,0,-2.78439 ), IECore.V3f( 7.231,0,1.53021 ), IECore.V3f( 6.20965,-9.53674e-07,3.7489 ), IECore.V3f( 2.72012,0,2.5738 ), IECore.V3f( 1.76971,0,0.780965 ) ] ), - IECore.V3fVectorData( [ IECore.V3f( 5.83427,0,-1.04096 ), IECore.V3f( 2.21995,0,-4.51254 ), IECore.V3f( 6.14141,0,-4.50183 ), IECore.V3f( 7.48932,0,-2.78439 ), IECore.V3f( 9.0197,0,1.53021 ), IECore.V3f( 6.20965,-9.53674e-07,1.2141 ), IECore.V3f( 2.72012,0,2.5738 ), IECore.V3f( 3.23728,0,0.780965 ) ] ) + IECore.V3fVectorData( [ imath.V3f( 2.42892,0,-1.04096 ), imath.V3f( 1.69011,0,-9.88746 ), imath.V3f( 5.74288,0,-4.50183 ), imath.V3f( 2.69113,0,-2.78439 ), imath.V3f( 5.8923,0,1.53021 ), imath.V3f( 6.20965,-9.53674e-07,2.03933 ), imath.V3f( 2.72012,0,2.5738 ), imath.V3f( 1.76971,0,-0.632637 ) ] ), + IECore.V3fVectorData( [ imath.V3f( -0.560781,0,-1.04096 ), imath.V3f( 2.21995,0,-6.31734 ), imath.V3f( 4.77513,0,-6.61752 ), imath.V3f( 4.10862,0,-2.78439 ), imath.V3f( 4.29081,0,1.53021 ), imath.V3f( 6.20965,-9.53674e-07,3.7489 ), imath.V3f( -2.61584,0,2.5738 ), imath.V3f( -1.45801,0,0.780965 ) ] ), + IECore.V3fVectorData( [ imath.V3f( 2.42892,0,-1.04096 ), imath.V3f( 2.21995,0,-4.51254 ), imath.V3f( 4.77513,0,-4.50183 ), imath.V3f( 6.32944,0,-2.78439 ), imath.V3f( 7.231,0,1.53021 ), imath.V3f( 6.20965,-9.53674e-07,3.7489 ), imath.V3f( 2.72012,0,2.5738 ), imath.V3f( 1.76971,0,0.780965 ) ] ), + IECore.V3fVectorData( [ imath.V3f( 5.83427,0,-1.04096 ), imath.V3f( 2.21995,0,-4.51254 ), imath.V3f( 6.14141,0,-4.50183 ), imath.V3f( 7.48932,0,-2.78439 ), imath.V3f( 9.0197,0,1.53021 ), imath.V3f( 6.20965,-9.53674e-07,1.2141 ), imath.V3f( 2.72012,0,2.5738 ), imath.V3f( 3.23728,0,0.780965 ) ] ) ] def curves( self, basis=IECore.CubicBasisf.linear(), periodic=False, numCurves=4 ) : @@ -73,22 +74,22 @@ def curves( self, basis=IECore.CubicBasisf.linear(), periodic=False, numCurves=4 curves = IECoreScene.CurvesPrimitive( vertsPerCurve, basis, periodic ) floatData = IECore.FloatData( 1.5 ) - v2fData = IECore.V2fData( IECore.V2f( 1.5, 2.5 ) ) - v3fData = IECore.V3fData( IECore.V3f( 1.5, 2.5, 3.5 ) ) - color3fData = IECore.Color3fData( IECore.Color3f( 1.5, 2.5, 3.5 ) ) + v2fData = IECore.V2fData( imath.V2f( 1.5, 2.5 ) ) + v3fData = IECore.V3fData( imath.V3f( 1.5, 2.5, 3.5 ) ) + color3fData = IECore.Color3fData( imath.Color3f( 1.5, 2.5, 3.5 ) ) intData = IECore.IntData( 1 ) - v2iData = IECore.V2iData( IECore.V2i( 1, 2 ) ) - v3iData = IECore.V3iData( IECore.V3i( 1, 2, 3 ) ) + v2iData = IECore.V2iData( imath.V2i( 1, 2 ) ) + v3iData = IECore.V3iData( imath.V3i( 1, 2, 3 ) ) stringData = IECore.StringData( "this is a string" ) intRange = range( 1, pData.size()+1 ) floatVectorData = IECore.FloatVectorData( [ x+0.5 for x in intRange ] ) - v2fVectorData = IECore.V2fVectorData( [ IECore.V2f( x, x+0.5 ) for x in intRange ] ) - v3fVectorData = IECore.V3fVectorData( [ IECore.V3f( x, x+0.5, x+0.75 ) for x in intRange ] ) - color3fVectorData = IECore.Color3fVectorData( [ IECore.Color3f( x, x+0.5, x+0.75 ) for x in intRange ] ) + v2fVectorData = IECore.V2fVectorData( [ imath.V2f( x, x+0.5 ) for x in intRange ] ) + v3fVectorData = IECore.V3fVectorData( [ imath.V3f( x, x+0.5, x+0.75 ) for x in intRange ] ) + color3fVectorData = IECore.Color3fVectorData( [ imath.Color3f( x, x+0.5, x+0.75 ) for x in intRange ] ) intVectorData = IECore.IntVectorData( intRange ) - v2iVectorData = IECore.V2iVectorData( [ IECore.V2i( x, -x ) for x in intRange ] ) - v3iVectorData = IECore.V3iVectorData( [ IECore.V3i( x, -x, x*2 ) for x in intRange ] ) + v2iVectorData = IECore.V2iVectorData( [ imath.V2i( x, -x ) for x in intRange ] ) + v3iVectorData = IECore.V3iVectorData( [ imath.V3i( x, -x, x*2 ) for x in intRange ] ) stringVectorData = IECore.StringVectorData( [ "string number %06d!" % x for x in intRange ] ) detailInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Constant @@ -830,7 +831,7 @@ def testVertAttribsCantBeConverted( self ) : def testBadCurve( self ) : curves = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 7 ] ), IECore.CubicBasisf.bSpline(), False ) - curves['P'] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f( 0 ), IECore.V3f( 0 ), IECore.V3f( 0 ), IECore.V3f( 1 ), IECore.V3f( 2 ), IECore.V3f( 2 ), IECore.V3f( 2 ) ] ) ) + curves['P'] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f( 0 ), imath.V3f( 0 ), imath.V3f( 0 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 2 ), imath.V3f( 2 ) ] ) ) self.failUnless( curves.arePrimitiveVariablesValid() ) sop = self.emptySop() @@ -901,9 +902,9 @@ def testAttributeFilter( self ) : for key in curves.keys() : if key != "P" : del curves[key] - rand = IECore.Rand32() - curves["uv"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V2fVectorData( [ IECore.V2f( rand.nextf() ) for x in range( 0, 32 ) ] ) ) - curves["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ IECore.V3f( 1, 0, 0 ) ] * 4, IECore.GeometricData.Interpretation.Color ) ) + rand = imath.Rand32() + curves["uv"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V2fVectorData( [ imath.V2f( rand.nextf() ) for x in range( 0, 32 ) ] ) ) + curves["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ imath.V3f( 1, 0, 0 ) ] * 4, IECore.GeometricData.Interpretation.Color ) ) curves["width"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.FloatVectorData( [ 1 ] * 32 ) ) curves["Pref"] = curves["P"] @@ -943,9 +944,9 @@ def testStandardAttributeConversion( self ) : for key in curves.keys() : if key != "P" : del curves[key] - rand = IECore.Rand32() - curves["uv"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V2fVectorData( [ IECore.V2f( rand.nextf() ) for x in range( 0, 32 ) ] ) ) - curves["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ IECore.V3f( 1, 0, 0 ) ] * 4, IECore.GeometricData.Interpretation.Color ) ) + rand = imath.Rand32() + curves["uv"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V2fVectorData( [ imath.V2f( rand.nextf() ) for x in range( 0, 32 ) ] ) ) + curves["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ imath.V3f( 1, 0, 0 ) ] * 4, IECore.GeometricData.Interpretation.Color ) ) curves["width"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.FloatVectorData( [ 1 ] * 32 ) ) curves["Pref"] = curves["P"] diff --git a/test/IECoreHoudini/ToHoudiniGroupConverter.py b/test/IECoreHoudini/ToHoudiniGroupConverter.py index 40539d8bea..4eb69a917f 100644 --- a/test/IECoreHoudini/ToHoudiniGroupConverter.py +++ b/test/IECoreHoudini/ToHoudiniGroupConverter.py @@ -33,6 +33,7 @@ ########################################################################## import hou +import imath import IECore import IECoreScene import IECoreHoudini @@ -53,30 +54,30 @@ class TestToHoudiniGroupConverter( IECoreHoudini.TestCase ) : def points( self ) : pData = IECore.V3fVectorData( [ - IECore.V3f( 0, 1, 2 ), IECore.V3f( 1 ), IECore.V3f( 2 ), IECore.V3f( 3 ), - IECore.V3f( 4 ), IECore.V3f( 5 ), IECore.V3f( 6 ), IECore.V3f( 7 ), - IECore.V3f( 8 ), IECore.V3f( 9 ), IECore.V3f( 10 ), IECore.V3f( 11 ), + imath.V3f( 0, 1, 2 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ), + imath.V3f( 4 ), imath.V3f( 5 ), imath.V3f( 6 ), imath.V3f( 7 ), + imath.V3f( 8 ), imath.V3f( 9 ), imath.V3f( 10 ), imath.V3f( 11 ), ] ) points = IECoreScene.PointsPrimitive( pData ) floatData = IECore.FloatData( 1.5 ) - v2fData = IECore.V2fData( IECore.V2f( 1.5, 2.5 ) ) - v3fData = IECore.V3fData( IECore.V3f( 1.5, 2.5, 3.5 ) ) - color3fData = IECore.Color3fData( IECore.Color3f( 1.5, 2.5, 3.5 ) ) + v2fData = IECore.V2fData( imath.V2f( 1.5, 2.5 ) ) + v3fData = IECore.V3fData( imath.V3f( 1.5, 2.5, 3.5 ) ) + color3fData = IECore.Color3fData( imath.Color3f( 1.5, 2.5, 3.5 ) ) intData = IECore.IntData( 1 ) - v2iData = IECore.V2iData( IECore.V2i( 1, 2 ) ) - v3iData = IECore.V3iData( IECore.V3i( 1, 2, 3 ) ) + v2iData = IECore.V2iData( imath.V2i( 1, 2 ) ) + v3iData = IECore.V3iData( imath.V3i( 1, 2, 3 ) ) stringData = IECore.StringData( "this is a string" ) intRange = range( 1, 13 ) floatVectorData = IECore.FloatVectorData( [ x+0.5 for x in intRange ] ) - v2fVectorData = IECore.V2fVectorData( [ IECore.V2f( x, x+0.5 ) for x in intRange ] ) - v3fVectorData = IECore.V3fVectorData( [ IECore.V3f( x, x+0.5, x+0.75 ) for x in intRange ] ) - color3fVectorData = IECore.Color3fVectorData( [ IECore.Color3f( x, x+0.5, x+0.75 ) for x in intRange ] ) + v2fVectorData = IECore.V2fVectorData( [ imath.V2f( x, x+0.5 ) for x in intRange ] ) + v3fVectorData = IECore.V3fVectorData( [ imath.V3f( x, x+0.5, x+0.75 ) for x in intRange ] ) + color3fVectorData = IECore.Color3fVectorData( [ imath.Color3f( x, x+0.5, x+0.75 ) for x in intRange ] ) intVectorData = IECore.IntVectorData( intRange ) - v2iVectorData = IECore.V2iVectorData( [ IECore.V2i( x, -x ) for x in intRange ] ) - v3iVectorData = IECore.V3iVectorData( [ IECore.V3i( x, -x, x*2 ) for x in intRange ] ) + v2iVectorData = IECore.V2iVectorData( [ imath.V2i( x, -x ) for x in intRange ] ) + v3iVectorData = IECore.V3iVectorData( [ imath.V3i( x, -x, x*2 ) for x in intRange ] ) stringVectorData = IECore.StringVectorData( [ "string number %d!" % x for x in intRange ] ) detailInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Constant @@ -112,22 +113,22 @@ def mesh( self ) : mesh = IECoreScene.MeshPrimitive( vertsPerFace, vertexIds ) floatData = IECore.FloatData( 1.5 ) - v2fData = IECore.V2fData( IECore.V2f( 1.5, 2.5 ) ) - v3fData = IECore.V3fData( IECore.V3f( 1.5, 2.5, 3.5 ) ) - color3fData = IECore.Color3fData( IECore.Color3f( 1.5, 2.5, 3.5 ) ) + v2fData = IECore.V2fData( imath.V2f( 1.5, 2.5 ) ) + v3fData = IECore.V3fData( imath.V3f( 1.5, 2.5, 3.5 ) ) + color3fData = IECore.Color3fData( imath.Color3f( 1.5, 2.5, 3.5 ) ) intData = IECore.IntData( 1 ) - v2iData = IECore.V2iData( IECore.V2i( 1, 2 ) ) - v3iData = IECore.V3iData( IECore.V3i( 1, 2, 3 ) ) + v2iData = IECore.V2iData( imath.V2i( 1, 2 ) ) + v3iData = IECore.V3iData( imath.V3i( 1, 2, 3 ) ) stringData = IECore.StringData( "this is a string" ) intRange = range( 1, 25 ) floatVectorData = IECore.FloatVectorData( [ x+0.5 for x in intRange ] ) - v2fVectorData = IECore.V2fVectorData( [ IECore.V2f( x, x+0.5 ) for x in intRange ] ) - v3fVectorData = IECore.V3fVectorData( [ IECore.V3f( x, x+0.5, x+0.75 ) for x in intRange ] ) - color3fVectorData = IECore.Color3fVectorData( [ IECore.Color3f( x, x+0.5, x+0.75 ) for x in intRange ] ) + v2fVectorData = IECore.V2fVectorData( [ imath.V2f( x, x+0.5 ) for x in intRange ] ) + v3fVectorData = IECore.V3fVectorData( [ imath.V3f( x, x+0.5, x+0.75 ) for x in intRange ] ) + color3fVectorData = IECore.Color3fVectorData( [ imath.Color3f( x, x+0.5, x+0.75 ) for x in intRange ] ) intVectorData = IECore.IntVectorData( intRange ) - v2iVectorData = IECore.V2iVectorData( [ IECore.V2i( x, -x ) for x in intRange ] ) - v3iVectorData = IECore.V3iVectorData( [ IECore.V3i( x, -x, x*2 ) for x in intRange ] ) + v2iVectorData = IECore.V2iVectorData( [ imath.V2i( x, -x ) for x in intRange ] ) + v3iVectorData = IECore.V3iVectorData( [ imath.V3i( x, -x, x*2 ) for x in intRange ] ) stringVectorData = IECore.StringVectorData( [ "string number %d!" % x for x in intRange ] ) detailInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Constant @@ -147,8 +148,8 @@ def mesh( self ) : # add all valid point attrib types pData = IECore.V3fVectorData( [ - IECore.V3f( 0, 1, 2 ), IECore.V3f( 1 ), IECore.V3f( 2 ), IECore.V3f( 3 ), - IECore.V3f( 4 ), IECore.V3f( 5 ), IECore.V3f( 6 ), IECore.V3f( 7 ), + imath.V3f( 0, 1, 2 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ), + imath.V3f( 4 ), imath.V3f( 5 ), imath.V3f( 6 ), imath.V3f( 7 ), ], IECore.GeometricData.Interpretation.Point ) mesh["P"] = IECoreScene.PrimitiveVariable( pointInterpolation, pData ) mesh["floatPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, floatVectorData[:8] ) @@ -379,21 +380,21 @@ def testAdjustedStringVectorIndices( self ) : def testTransforms( self ) : def add( parent, child, vec ) : - child.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( vec ) ) ) + child.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( vec ) ) ) parent.addChild( child ) if random.random() > 0.75 : child.addChild( self.mesh() ) group = IECoreScene.Group() - group.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( 5, 0, 0 ) ) ) ) + group.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 5, 0, 0 ) ) ) ) for i in range( 0, 50 ) : - add( group, self.meshGroup(), IECore.V3f( random.random(), random.random(), random.random() ) * 3 ) + add( group, self.meshGroup(), imath.V3f( random.random(), random.random(), random.random() ) * 3 ) null = self.emptySop() self.failUnless( IECoreHoudini.ToHoudiniGroupConverter( group ).convert( null ) ) houdiniBound = null.geometry().boundingBox() - bound = IECore.Box3f( IECore.V3f( list(houdiniBound.minvec()) ), IECore.V3f( list(houdiniBound.maxvec()) ) ) + bound = imath.Box3f( imath.V3f( list(houdiniBound.minvec()) ), imath.V3f( list(houdiniBound.maxvec()) ) ) self.assertEqual( group.bound(), bound ) def testCannotConvertIntoReadOnlyHOMGeo( self ) : @@ -421,15 +422,16 @@ def testConvertIntoWritableHOMGeo( self ) : self.assertEqual( sop.geometry().prims(), tuple() ) sop.type().definition().sections()["PythonCook"].setContents( """ +import imath import IECore import IECoreScene import IECoreHoudini group = IECoreScene.Group() -mesh = IECoreScene.MeshPrimitive.createBox( IECore.Box3f( IECore.V3f( -1 ), IECore.V3f( 1 ) ) ) +mesh = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ) ) mesh.blindData()["name"] = IECore.StringData( "mesh" ) -points = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ IECore.V3f( x ) for x in range( 0, 20 ) ] ) ) +points = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ imath.V3f( x ) for x in range( 0, 20 ) ] ) ) points.blindData()["name"] = IECore.StringData( "points" ) -curves = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 4 ] ), IECore.CubicBasisf.linear(), False, IECore.V3fVectorData( [ IECore.V3f( x ) for x in range( 0, 4 ) ] ) ) +curves = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 4 ] ), IECore.CubicBasisf.linear(), False, IECore.V3fVectorData( [ imath.V3f( x ) for x in range( 0, 4 ) ] ) ) curves.blindData()["name"] = IECore.StringData( "curves" ) group.addChild( mesh ) group.addChild( points ) @@ -482,10 +484,10 @@ def testAttributeFilter( self ) : self.assertEqual( sorted([ x.name() for x in sop.geometry().globalAttribs() ]), [] ) # verify we can filter uvs - mesh = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) ) + mesh = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) IECoreScene.TriangulateOp()( input=mesh, copyInput=False ) IECoreScene.MeshNormalsOp()( input=mesh, copyInput=False ) - mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, IECore.V3fVectorData( [ IECore.V3f( 1, 0, 0 ) ] * 6, IECore.GeometricData.Interpretation.Color ) ) + mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, IECore.V3fVectorData( [ imath.V3f( 1, 0, 0 ) ] * 6, IECore.GeometricData.Interpretation.Color ) ) mesh["width"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.FloatVectorData( [ 1 ] * 4 ) ) mesh["Pref"] = mesh["P"] group = IECoreScene.Group() @@ -527,10 +529,10 @@ def testStandardAttributeConversion( self ) : sop = self.emptySop() - mesh = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) ) + mesh = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) IECoreScene.TriangulateOp()( input=mesh, copyInput=False ) IECoreScene.MeshNormalsOp()( input=mesh, copyInput=False ) - mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, IECore.V3fVectorData( [ IECore.V3f( 1, 0, 0 ) ] * 6, IECore.GeometricData.Interpretation.Color ) ) + mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, IECore.V3fVectorData( [ imath.V3f( 1, 0, 0 ) ] * 6, IECore.GeometricData.Interpretation.Color ) ) mesh["width"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.FloatVectorData( [ 1 ] * 4 ) ) mesh["Pref"] = mesh["P"] diff --git a/test/IECoreHoudini/ToHoudiniPointsConverter.py b/test/IECoreHoudini/ToHoudiniPointsConverter.py index 1b9bd035f8..a308ad0c25 100644 --- a/test/IECoreHoudini/ToHoudiniPointsConverter.py +++ b/test/IECoreHoudini/ToHoudiniPointsConverter.py @@ -33,6 +33,7 @@ ########################################################################## import hou +import imath import IECore import IECoreScene import IECoreHoudini @@ -50,37 +51,37 @@ class TestToHoudiniPointsConverter( IECoreHoudini.TestCase ) : def points( self ) : pData = IECore.V3fVectorData( [ - IECore.V3f( 0, 1, 2 ), IECore.V3f( 1 ), IECore.V3f( 2 ), IECore.V3f( 3 ), - IECore.V3f( 4 ), IECore.V3f( 5 ), IECore.V3f( 6 ), IECore.V3f( 7 ), - IECore.V3f( 8 ), IECore.V3f( 9 ), IECore.V3f( 10 ), IECore.V3f( 11 ), + imath.V3f( 0, 1, 2 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ), + imath.V3f( 4 ), imath.V3f( 5 ), imath.V3f( 6 ), imath.V3f( 7 ), + imath.V3f( 8 ), imath.V3f( 9 ), imath.V3f( 10 ), imath.V3f( 11 ), ] ) points = IECoreScene.PointsPrimitive( pData ) floatData = IECore.FloatData( 1.5 ) - v2fData = IECore.V2fData( IECore.V2f( 1.5, 2.5 ) ) - v3fData = IECore.V3fData( IECore.V3f( 1.5, 2.5, 3.5 ) ) - v3fData = IECore.V3fData( IECore.V3f( 1.5, 2.5, 3.5 ) ) - color3fData = IECore.Color3fData( IECore.Color3f( 1.5, 2.5, 3.5 ) ) + v2fData = IECore.V2fData( imath.V2f( 1.5, 2.5 ) ) + v3fData = IECore.V3fData( imath.V3f( 1.5, 2.5, 3.5 ) ) + v3fData = IECore.V3fData( imath.V3f( 1.5, 2.5, 3.5 ) ) + color3fData = IECore.Color3fData( imath.Color3f( 1.5, 2.5, 3.5 ) ) intData = IECore.IntData( 1 ) - v2iData = IECore.V2iData( IECore.V2i( 1, 2 ) ) - v3iData = IECore.V3iData( IECore.V3i( 1, 2, 3 ) ) + v2iData = IECore.V2iData( imath.V2i( 1, 2 ) ) + v3iData = IECore.V3iData( imath.V3i( 1, 2, 3 ) ) stringData = IECore.StringData( "this is a string" ) - m33fData = IECore.M33fData( IECore.M33f(1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0) ) - m44fData = IECore.M44fData( IECore.M44f(1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0) ) + m33fData = IECore.M33fData( imath.M33f(1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0) ) + m44fData = IECore.M44fData( imath.M44f(1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0) ) intRange = range( 1, 13 ) floatVectorData = IECore.FloatVectorData( [ x+0.5 for x in intRange ] ) - v2fVectorData = IECore.V2fVectorData( [ IECore.V2f( x, x+0.5 ) for x in intRange ] ) - v3fVectorData = IECore.V3fVectorData( [ IECore.V3f( x, x+0.5, x+0.75 ) for x in intRange ] ) - color3fVectorData = IECore.Color3fVectorData( [ IECore.Color3f( x, x+0.5, x+0.75 ) for x in intRange ] ) - quatVectorData = IECore.QuatfVectorData( [ IECore.Quatf( x, x+0.25, x+0.5, x+0.75 ) for x in intRange ] ) + v2fVectorData = IECore.V2fVectorData( [ imath.V2f( x, x+0.5 ) for x in intRange ] ) + v3fVectorData = IECore.V3fVectorData( [ imath.V3f( x, x+0.5, x+0.75 ) for x in intRange ] ) + color3fVectorData = IECore.Color3fVectorData( [ imath.Color3f( x, x+0.5, x+0.75 ) for x in intRange ] ) + quatVectorData = IECore.QuatfVectorData( [ imath.Quatf( x, x+0.25, x+0.5, x+0.75 ) for x in intRange ] ) intVectorData = IECore.IntVectorData( intRange ) - v2iVectorData = IECore.V2iVectorData( [ IECore.V2i( x, -x ) for x in intRange ] ) - v3iVectorData = IECore.V3iVectorData( [ IECore.V3i( x, -x, x*2 ) for x in intRange ] ) + v2iVectorData = IECore.V2iVectorData( [ imath.V2i( x, -x ) for x in intRange ] ) + v3iVectorData = IECore.V3iVectorData( [ imath.V3i( x, -x, x*2 ) for x in intRange ] ) stringVectorData = IECore.StringVectorData( [ "string number %06d!" % x for x in intRange ] ) - m33fVectorData = IECore.M33fVectorData( [ IECore.M33f(1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0) for x in intRange ] ) - m44fVectorData = IECore.M44fVectorData( [ IECore.M44f(1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0) for x in intRange ] ) + m33fVectorData = IECore.M33fVectorData( [ imath.M33f(1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0) for x in intRange ] ) + m44fVectorData = IECore.M44fVectorData( [ imath.M44f(1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0) for x in intRange ] ) detailInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Constant uniformInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Uniform @@ -149,18 +150,18 @@ def comparePrimAndSop( self, prim, sop ) : self.assertEqual( prim[key].data.value, geo.attribValue( key ) ) def toTuple( v ): - if isinstance( v, IECore.M33f ): + if isinstance( v, imath.M33f ): return ( - v[(0,0)], v[(0,1)], v[(0,2)], - v[(1,0)], v[(1,1)], v[(1,2)], - v[(2,0)], v[(2,1)], v[(2,2)] + v[0][0], v[0][1], v[0][2], + v[1][0], v[1][1], v[1][2], + v[2][0], v[2][1], v[2][2] ) - elif isinstance( v, IECore.M44f ): + elif isinstance( v, imath.M44f ): return ( - v[(0,0)], v[(0,1)], v[(0,2)], v[(0,3)], - v[(1,0)], v[(1,1)], v[(1,2)], v[(1,3)], - v[(2,0)], v[(2,1)], v[(2,2)], v[(2,3)], - v[(3,0)], v[(3,1)], v[(3,2)], v[(3,3)] + v[0][0], v[0][1], v[0][2], v[0][3], + v[1][0], v[1][1], v[1][2], v[1][3], + v[2][0], v[2][1], v[2][2], v[2][3], + v[3][0], v[3][1], v[3][2], v[3][3] ) else: return tuple( v ) @@ -182,7 +183,7 @@ def toTuple( v ): self.assertEqual( geo.findPrimAttrib( "quatPrim" ).qualifier(), "Quaternion" ) data = prim["quatPrim"].data for i in range( 0, data.size() ) : - components = ( data[i][1], data[i][2], data[i][3], data[i][0] ) + components = ( data[i].v()[0], data[i].v()[1], data[i].v()[2], data[i].r() ) self.assertEqual( components, sopPrims[i].attribValue( "quatPrim" ) ) data = prim["stringPrim"].data @@ -204,7 +205,7 @@ def toTuple( v ): self.assertEqual( geo.findPointAttrib( "quatPoint" ).qualifier(), "Quaternion" ) data = prim["quatPoint"].data for i in range( 0, data.size() ) : - components = ( data[i][1], data[i][2], data[i][3], data[i][0] ) + components = ( data[i].v()[0], data[i].v()[1], data[i].v()[2], data[i].r() ) self.assertEqual( components, sopPoints[i].attribValue( "quatPoint" ) ) data = prim["stringPoint"].data @@ -227,18 +228,18 @@ def comparePrimAndAppendedSop( self, prim, sop, origSopPrim, multipleConversions self.assertEqual( prim[key].data.value, geo.attribValue( key ) ) def toTuple( v ): - if isinstance( v, IECore.M33f ): + if isinstance( v, imath.M33f ): return ( - v[(0,0)], v[(0,1)], v[(0,2)], - v[(1,0)], v[(1,1)], v[(1,2)], - v[(2,0)], v[(2,1)], v[(2,2)] + v[0][0], v[0][1], v[0][2], + v[1][0], v[1][1], v[1][2], + v[2][0], v[2][1], v[2][2] ) - elif isinstance( v, IECore.M44f ): + elif isinstance( v, imath.M44f ): return ( - v[(0,0)], v[(0,1)], v[(0,2)], v[(0,3)], - v[(1,0)], v[(1,1)], v[(1,2)], v[(1,3)], - v[(2,0)], v[(2,1)], v[(2,2)], v[(2,3)], - v[(3,0)], v[(3,1)], v[(3,2)], v[(3,3)] + v[0][0], v[0][1], v[0][2], v[0][3], + v[1][0], v[1][1], v[1][2], v[1][3], + v[2][0], v[2][1], v[2][2], v[2][3], + v[3][0], v[3][1], v[3][2], v[3][3] ) else: return tuple( v ) @@ -292,12 +293,12 @@ def toTuple( v ): if multipleConversions or key is "P" : defaultValue = origSopPrim[key].data + elif isinstance( data, IECore.M33fVectorData ) : + defaultValue = [ [ 0 ] * 9 ] * origSopPrim.numPoints + elif isinstance( data, IECore.M44fVectorData ) : + defaultValue = [ [ 0 ] * 16 ] * origSopPrim.numPoints else : - d = data[0].dimensions() - if isinstance( d, tuple ): - defaultValue = [ [ 0 ] * d[0] * d[1] ] * origSopPrim.numPoints - else: - defaultValue = [ [ 0 ] * data[0].dimensions() ] * origSopPrim.numPoints + defaultValue = [ [ 0 ] * data[0].dimensions() ] * origSopPrim.numPoints for i in range( 0, origSopPrim.numPoints ) : self.assertEqual( toTuple(defaultValue[i]), sopPoints[ i ].attribValue( key ) ) @@ -655,8 +656,8 @@ def testAttributeFilter( self ) : def testStandardAttributeConversion( self ) : sop = self.emptySop() - points = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ IECore.V3f( 1 ) ] * 10 ) ) - points["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f( 1, 0, 0 ) ] * 10, IECore.GeometricData.Interpretation.Color ) ) + points = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ imath.V3f( 1 ) ] * 10 ) ) + points["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f( 1, 0, 0 ) ] * 10, IECore.GeometricData.Interpretation.Color ) ) points["width"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.FloatVectorData( [ 1 ] * 10 ) ) points["Pref"] = points["P"] diff --git a/test/IECoreHoudini/ToHoudiniPolygonsConverter.py b/test/IECoreHoudini/ToHoudiniPolygonsConverter.py index 1c7119cb29..20de002ee5 100644 --- a/test/IECoreHoudini/ToHoudiniPolygonsConverter.py +++ b/test/IECoreHoudini/ToHoudiniPolygonsConverter.py @@ -33,6 +33,7 @@ ########################################################################## import hou +import imath import IECore import IECoreScene import IECoreHoudini @@ -54,22 +55,22 @@ def mesh( self ) : mesh = IECoreScene.MeshPrimitive( vertsPerFace, vertexIds ) floatData = IECore.FloatData( 1.5 ) - v2fData = IECore.V2fData( IECore.V2f( 1.5, 2.5 ), IECore.GeometricData.Interpretation.Vector ) - v3fData = IECore.V3fData( IECore.V3f( 1.5, 2.5, 3.5 ) ) - color3fData = IECore.Color3fData( IECore.Color3f( 1.5, 2.5, 3.5 ) ) + v2fData = IECore.V2fData( imath.V2f( 1.5, 2.5 ), IECore.GeometricData.Interpretation.Vector ) + v3fData = IECore.V3fData( imath.V3f( 1.5, 2.5, 3.5 ) ) + color3fData = IECore.Color3fData( imath.Color3f( 1.5, 2.5, 3.5 ) ) intData = IECore.IntData( 1 ) - v2iData = IECore.V2iData( IECore.V2i( 1, 2 ) ) - v3iData = IECore.V3iData( IECore.V3i( 1, 2, 3 ) ) + v2iData = IECore.V2iData( imath.V2i( 1, 2 ) ) + v3iData = IECore.V3iData( imath.V3i( 1, 2, 3 ) ) stringData = IECore.StringData( "this is a string" ) intRange = range( 1, 25 ) floatVectorData = IECore.FloatVectorData( [ x+0.5 for x in intRange ] ) - v2fVectorData = IECore.V2fVectorData( [ IECore.V2f( x, x+0.5 ) for x in intRange ] ) - v3fVectorData = IECore.V3fVectorData( [ IECore.V3f( x, x+0.5, x+0.75 ) for x in intRange ], IECore.GeometricData.Interpretation.Normal ) - color3fVectorData = IECore.Color3fVectorData( [ IECore.Color3f( x, x+0.5, x+0.75 ) for x in intRange ] ) + v2fVectorData = IECore.V2fVectorData( [ imath.V2f( x, x+0.5 ) for x in intRange ] ) + v3fVectorData = IECore.V3fVectorData( [ imath.V3f( x, x+0.5, x+0.75 ) for x in intRange ], IECore.GeometricData.Interpretation.Normal ) + color3fVectorData = IECore.Color3fVectorData( [ imath.Color3f( x, x+0.5, x+0.75 ) for x in intRange ] ) intVectorData = IECore.IntVectorData( intRange ) - v2iVectorData = IECore.V2iVectorData( [ IECore.V2i( x, -x ) for x in intRange ] ) - v3iVectorData = IECore.V3iVectorData( [ IECore.V3i( x, -x, x*2 ) for x in intRange ] ) + v2iVectorData = IECore.V2iVectorData( [ imath.V2i( x, -x ) for x in intRange ] ) + v3iVectorData = IECore.V3iVectorData( [ imath.V3i( x, -x, x*2 ) for x in intRange ] ) stringVectorData = IECore.StringVectorData( [ "string number %06d!" % x for x in intRange ] ) detailInterpolation = IECoreScene.PrimitiveVariable.Interpolation.Constant @@ -89,8 +90,8 @@ def mesh( self ) : # add all valid point attrib types pData = IECore.V3fVectorData( [ - IECore.V3f( 0, 1, 2 ), IECore.V3f( 1 ), IECore.V3f( 2 ), IECore.V3f( 3 ), - IECore.V3f( 4 ), IECore.V3f( 5 ), IECore.V3f( 6 ), IECore.V3f( 7 ), + imath.V3f( 0, 1, 2 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ), + imath.V3f( 4 ), imath.V3f( 5 ), imath.V3f( 6 ), imath.V3f( 7 ), ], IECore.GeometricData.Interpretation.Point ) mesh["P"] = IECoreScene.PrimitiveVariable( pointInterpolation, pData ) mesh["floatPoint"] = IECoreScene.PrimitiveVariable( pointInterpolation, floatVectorData[:8] ) @@ -832,10 +833,10 @@ def testAttributeFilter( self ) : self.assertEqual( sorted([ x.name() for x in sop.geometry().globalAttribs() ]), [] ) # verify we can filter uvs - mesh = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) ) + mesh = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) IECoreScene.TriangulateOp()( input=mesh, copyInput=False ) IECoreScene.MeshNormalsOp()( input=mesh, copyInput=False ) - mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, IECore.V3fVectorData( [ IECore.V3f( 1, 0, 0 ) ] * 6, IECore.GeometricData.Interpretation.Color ) ) + mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, IECore.V3fVectorData( [ imath.V3f( 1, 0, 0 ) ] * 6, IECore.GeometricData.Interpretation.Color ) ) mesh["width"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.FloatVectorData( [ 1 ] * 4 ) ) mesh["Pref"] = mesh["P"] @@ -865,10 +866,10 @@ def testAttributeFilter( self ) : def testStandardAttributeConversion( self ) : sop = self.emptySop() - mesh = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) ) + mesh = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) IECoreScene.TriangulateOp()( input=mesh, copyInput=False ) IECoreScene.MeshNormalsOp()( input=mesh, copyInput=False ) - mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, IECore.V3fVectorData( [ IECore.V3f( 1, 0, 0 ) ] * 6, IECore.GeometricData.Interpretation.Color ) ) + mesh["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, IECore.V3fVectorData( [ imath.V3f( 1, 0, 0 ) ] * 6, IECore.GeometricData.Interpretation.Color ) ) mesh["width"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.FloatVectorData( [ 1 ] * 4 ) ) mesh["Pref"] = mesh["P"] @@ -924,7 +925,7 @@ def testCannotTransformRest( self ) : merge.parm( "xformtype" ).set( 1 ) merge.parm( "objpath1" ).set( sop.path() ) - mesh = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) ) + mesh = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) IECoreScene.TriangulateOp()( input=mesh, copyInput=False ) IECoreScene.MeshNormalsOp()( input=mesh, copyInput=False ) mesh["Pref"] = mesh["P"] @@ -939,14 +940,14 @@ def testCannotTransformRest( self ) : i = 0 for point in geo.points() : restValue = point.attribValue( "rest" ) - self.assertAlmostEqual( IECore.V3f( restValue[0], restValue[1], restValue[2] ), prefData[i] ) + self.assertAlmostEqual( imath.V3f( restValue[0], restValue[1], restValue[2] ), prefData[i] ) self.assertTrue( point.position().isAlmostEqual( hou.Vector3(restValue) ) ) i += 1 i = 0 for point in geo2.points() : restValue = point.attribValue( "rest" ) - self.assertAlmostEqual( IECore.V3f( restValue[0], restValue[1], restValue[2] ), prefData[i] ) + self.assertAlmostEqual( imath.V3f( restValue[0], restValue[1], restValue[2] ), prefData[i] ) self.assertFalse( point.position().isAlmostEqual( hou.Vector3(restValue) ) ) i += 1 @@ -959,14 +960,14 @@ def testCannotTransformRest( self ) : i = 0 for point in geo.points() : restValue = point.attribValue( "Pref" ) - self.assertAlmostEqual( IECore.V3f( restValue[0], restValue[1], restValue[2] ), prefData[i] ) + self.assertAlmostEqual( imath.V3f( restValue[0], restValue[1], restValue[2] ), prefData[i] ) self.assertTrue( point.position().isAlmostEqual( hou.Vector3(restValue) ) ) i += 1 i = 0 for point in geo2.points() : restValue = point.attribValue( "Pref" ) - self.assertAlmostEqual( IECore.V3f( restValue[0], restValue[1], restValue[2] ), prefData[i] ) + self.assertAlmostEqual( imath.V3f( restValue[0], restValue[1], restValue[2] ), prefData[i] ) self.assertFalse( point.position().isAlmostEqual( hou.Vector3(restValue) ) ) i += 1 diff --git a/test/IECoreHoudini/ops/noiseDeformer/noiseDeformer-1.py b/test/IECoreHoudini/ops/noiseDeformer/noiseDeformer-1.py index bbf9d4f1df..7a6a0f3261 100644 --- a/test/IECoreHoudini/ops/noiseDeformer/noiseDeformer-1.py +++ b/test/IECoreHoudini/ops/noiseDeformer/noiseDeformer-1.py @@ -1,3 +1,4 @@ +import imath import IECore import IECoreScene import hou @@ -27,7 +28,7 @@ def __init__( self ) : IECore.V3fParameter( name = "frequency", description = "The frequency of the displacement noise.", - defaultValue = IECore.V3f(1.0) ) + defaultValue = imath.V3f(1.0) ) ] ) @@ -52,7 +53,7 @@ def doOperation( self, args ) : new_p = [] for p in p_data: noise_val = mag * ( hou.hmath.noise3d( [p.x * freq.x, p.y * freq.y, p.z * freq.z] ) - hou.Vector3(.5,.5,.5) ) * 2 - new_p.append( p + IECore.V3f( noise_val[0], noise_val[1], noise_val[2] ) ) + new_p.append( p + imath.V3f( noise_val[0], noise_val[1], noise_val[2] ) ) # overwrite with our new P and return from the Op prim['P'] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( new_p ) ) diff --git a/test/IECoreHoudini/ops/parameters/compoundParameters/compoundParameters-1.py b/test/IECoreHoudini/ops/parameters/compoundParameters/compoundParameters-1.py index 2f46449ee3..7a20cc755e 100644 --- a/test/IECoreHoudini/ops/parameters/compoundParameters/compoundParameters-1.py +++ b/test/IECoreHoudini/ops/parameters/compoundParameters/compoundParameters-1.py @@ -1,3 +1,4 @@ +import imath ########################################################################## # # Copyright 2010 Dr D Studios Pty Limited (ACN 127 184 954) (Dr. D Studios), @@ -62,13 +63,13 @@ def __init__( self ) : IECore.V3dParameter( name = "j", description = "a v3d", - defaultValue = IECore.V3dData( IECore.V3d( 8, 16, 32 ) ), + defaultValue = IECore.V3dData( imath.V3d( 8, 16, 32 ) ), userData = { "UI" : { "label" : IECore.StringData( "A Vector" ) } }, ), IECore.Color3fParameter( name = "k", description = "an m44f", - defaultValue = IECore.Color3f(1,0.5,0), + defaultValue = imath.Color3f(1,0.5,0), userData = { "UI" : { "label" : IECore.StringData( "A Colour" ) } }, ), ] @@ -82,17 +83,17 @@ def __init__( self ) : IECore.V3dParameter( name = "j", description = "a v3d", - defaultValue = IECore.V3dData( IECore.V3d( 8, 16, 32 ) ), + defaultValue = IECore.V3dData( imath.V3d( 8, 16, 32 ) ), presets = ( - ( "one", IECore.V3d( 1 ) ), - ( "two", IECore.V3d( 2 ) ) + ( "one", imath.V3d( 1 ) ), + ( "two", imath.V3d( 2 ) ) ), userData = { "UI" : { "label" : IECore.StringData( "Compound->V3d" ) } }, ), IECore.V2fParameter( name = "k", description = "an v2f", - defaultValue = IECore.V2f(1,1) + defaultValue = imath.V2f(1,1) ), ] ), diff --git a/test/IECoreHoudini/ops/parameters/groupParam/groupParam-2.py b/test/IECoreHoudini/ops/parameters/groupParam/groupParam-2.py index 6bc5836a3c..b4117867d6 100644 --- a/test/IECoreHoudini/ops/parameters/groupParam/groupParam-2.py +++ b/test/IECoreHoudini/ops/parameters/groupParam/groupParam-2.py @@ -42,7 +42,7 @@ def doOperation( self, args ) : group = args["inputA"] if args["switch"].value == 20 else args["inputB"] for child in group.children() : - if child.isInstanceOf( IECore.TypeId.Primitive ) : + if child.isInstanceOf( IECoreScene.TypeId.Primitive ) : return child.copy() return self.resultParameter().defaultValue.copy() diff --git a/test/IECoreHoudini/ops/vectors/V3fVectorCreator/V3fVectorCreator-1.py b/test/IECoreHoudini/ops/vectors/V3fVectorCreator/V3fVectorCreator-1.py index 8bbcf7227f..bb7a6a6e14 100644 --- a/test/IECoreHoudini/ops/vectors/V3fVectorCreator/V3fVectorCreator-1.py +++ b/test/IECoreHoudini/ops/vectors/V3fVectorCreator/V3fVectorCreator-1.py @@ -1,3 +1,4 @@ +import imath import IECore class V3fVectorCreator( IECore.Op ) : @@ -23,7 +24,7 @@ def __init__( self ) : IECore.V3fParameter( name = "value", description = "Value to put in each of the vector elements.", - defaultValue = IECore.V3f(1) + defaultValue = imath.V3f(1) ) ] ) diff --git a/test/IECoreImage/EnvMapSamplerTest.py b/test/IECoreImage/EnvMapSamplerTest.py index 92bd99fddc..c1f6e8d0b8 100644 --- a/test/IECoreImage/EnvMapSamplerTest.py +++ b/test/IECoreImage/EnvMapSamplerTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreImage @@ -77,7 +78,7 @@ def testColorSums( self ) : for i in range( 0, 10 ) : lights = IECoreImage.EnvMapSampler()( image=image, subdivisionDepth=i ) - colorSum = sum( lights["colors"], IECore.Color3f( 0 ) ) + colorSum = sum( lights["colors"], imath.Color3f( 0 ) ) if lastColorSum : self.assertAlmostEqual( colorSum[0], lastColorSum[0], 5 ) diff --git a/test/IECoreImage/FontTest.py b/test/IECoreImage/FontTest.py index 60f81b29e1..c739e0c744 100644 --- a/test/IECoreImage/FontTest.py +++ b/test/IECoreImage/FontTest.py @@ -53,7 +53,8 @@ def testImages( self ) : for c in range( 0, 128 ) : i = f.image( chr( c ) ) - self.assert_( i.displayWindow.contains( i.dataWindow ) ) + self.assert_( i.displayWindow.intersects( i.dataWindow.min() ) ) + self.assert_( i.displayWindow.intersects( i.dataWindow.max() ) ) self.assert_( len( i ), 1 ) self.assert_( "Y" in i ) self.assert_( i.channelValid( "Y" ) ) diff --git a/test/IECoreImage/ImageCropOpTest.py b/test/IECoreImage/ImageCropOpTest.py index 8ac3ac7235..6e77ac4d80 100644 --- a/test/IECoreImage/ImageCropOpTest.py +++ b/test/IECoreImage/ImageCropOpTest.py @@ -34,6 +34,7 @@ import unittest import sys, os +import imath import IECore import IECoreImage @@ -46,7 +47,7 @@ class ImageCropOpTest(unittest.TestCase): def __fromNukeCrop( self, x, y, r, t, h = 1556 ) : # Nuke is flipped in the vertical, and would use a bound of ((0,2),(0,2)) for a 2x2 image. - return IECore.Box2i( IECore.V2i( x , h - t ), IECore.V2i( r - 1, h - y - 1 ) ) + return imath.Box2i( imath.V2i( x , h - t ), imath.V2i( r - 1, h - y - 1 ) ) def testCrop(self): @@ -54,13 +55,13 @@ def testCrop(self): tests = [ { - "cropBox": IECore.Box2i( IECore.V2i( 855, 170 ), IECore.V2i( 1460, 1465 ) ), + "cropBox": imath.Box2i( imath.V2i( 855, 170 ), imath.V2i( 1460, 1465 ) ), "checkFile": "test/IECoreImage/data/exr/imageCropDataWindow.exr", "matchDataWindow" : False, "resetOrigin" : True }, { - "cropBox": IECore.Box2i( IECore.V2i( 855, 170 ), IECore.V2i( 1460, 1465 ) ), + "cropBox": imath.Box2i( imath.V2i( 855, 170 ), imath.V2i( 1460, 1465 ) ), "checkFile": "test/IECoreImage/data/exr/imageCropDataWindowMatched.exr", "matchDataWindow" : True, "resetOrigin" : True @@ -78,7 +79,7 @@ def testCrop(self): "resetOrigin" : False }, { - "cropBox": IECore.Box2i( IECore.V2i( -10, -10 ), IECore.V2i( 3000, 3000 ) ), + "cropBox": imath.Box2i( imath.V2i( -10, -10 ), imath.V2i( 3000, 3000 ) ), "checkFile": inputFile, "matchDataWindow" : False, "resetOrigin" : False diff --git a/test/IECoreImage/ImageDiffOpTest.py b/test/IECoreImage/ImageDiffOpTest.py index 4c3a709fb5..2a2c938a8b 100644 --- a/test/IECoreImage/ImageDiffOpTest.py +++ b/test/IECoreImage/ImageDiffOpTest.py @@ -34,6 +34,7 @@ import unittest import sys +import imath import IECore import IECoreImage @@ -53,8 +54,8 @@ def testOffsetDisplayWindows(self): self.assertFalse( res.value ) # Offset the display and data windows. - offsetDisplayWindow = IECore.Box2i( imageA.displayWindow.min + IECore.V2i( -261, 172 ), imageA.displayWindow.max + IECore.V2i( -261, 172 ) ) - offsetDataWindow = IECore.Box2i( imageA.dataWindow.min + IECore.V2i( -261, 172 ), imageA.dataWindow.max + IECore.V2i( -261, 172 ) ) + offsetDisplayWindow = imath.Box2i( imageA.displayWindow.min() + imath.V2i( -261, 172 ), imageA.displayWindow.max() + imath.V2i( -261, 172 ) ) + offsetDataWindow = imath.Box2i( imageA.dataWindow.min() + imath.V2i( -261, 172 ), imageA.dataWindow.max() + imath.V2i( -261, 172 ) ) imageA.displayWindow = offsetDisplayWindow imageA.dataWindow = offsetDataWindow @@ -139,7 +140,7 @@ def testMissingChannels(self): op = IECoreImage.ImageDiffOp() - w = IECore.Box2i( IECore.V2i( 0, 0 ), IECore.V2i( 99, 99 ) ) + w = imath.Box2i( imath.V2i( 0, 0 ), imath.V2i( 99, 99 ) ) f = IECore.FloatVectorData() f.resize( 100 * 100, 0 ) diff --git a/test/IECoreImage/ImageDisplayDriverTest.py b/test/IECoreImage/ImageDisplayDriverTest.py index 8b8ba5a514..20c49b7cdb 100644 --- a/test/IECoreImage/ImageDisplayDriverTest.py +++ b/test/IECoreImage/ImageDisplayDriverTest.py @@ -39,16 +39,17 @@ import glob import sys import time +import imath import IECore import IECoreImage class ImageDisplayDriverTest(unittest.TestCase): def testConstruction( self ): - idd = IECoreImage.ImageDisplayDriver( IECore.Box2i( IECore.V2i(0,0), IECore.V2i(100,100) ), IECore.Box2i( IECore.V2i(10,10), IECore.V2i(40,40) ), [ 'r','g','b' ], IECore.CompoundData() ) + idd = IECoreImage.ImageDisplayDriver( imath.Box2i( imath.V2i(0,0), imath.V2i(100,100) ), imath.Box2i( imath.V2i(10,10), imath.V2i(40,40) ), [ 'r','g','b' ], IECore.CompoundData() ) self.assertEqual( idd.scanLineOrderOnly(), False ) - self.assertEqual( idd.displayWindow(), IECore.Box2i( IECore.V2i(0,0), IECore.V2i(100,100) ) ) - self.assertEqual( idd.dataWindow(), IECore.Box2i( IECore.V2i(10,10), IECore.V2i(40,40) ) ) + self.assertEqual( idd.displayWindow(), imath.Box2i( imath.V2i(0,0), imath.V2i(100,100) ) ) + self.assertEqual( idd.dataWindow(), imath.Box2i( imath.V2i(10,10), imath.V2i(40,40) ) ) self.assertEqual( idd.channelNames(), [ 'r', 'g', 'b' ] ) def __prepareBuf( self, buf, width, offset, red, green, blue ): @@ -66,21 +67,21 @@ def testComplete( self ): red = img['R'] green = img['G'] blue = img['B'] - width = img.dataWindow.max.x - img.dataWindow.min.x + 1 + width = img.dataWindow.max().x - img.dataWindow.min().x + 1 buf = IECore.FloatVectorData( width * 3 ) - for i in xrange( 0, img.dataWindow.max.y - img.dataWindow.min.y + 1 ): + for i in xrange( 0, img.dataWindow.max().y - img.dataWindow.min().y + 1 ): self.__prepareBuf( buf, width, i*width, red, green, blue ) - idd.imageData( IECore.Box2i( IECore.V2i( img.dataWindow.min.x, i + img.dataWindow.min.y ), IECore.V2i( img.dataWindow.max.x, i + img.dataWindow.min.y) ), buf ) + idd.imageData( imath.Box2i( imath.V2i( img.dataWindow.min().x, i + img.dataWindow.min().y ), imath.V2i( img.dataWindow.max().x, i + img.dataWindow.min().y) ), buf ) idd.imageClose() self.assertEqual( idd.image(), img ) def testFactory( self ): - idd = IECoreImage.DisplayDriver.create( "ImageDisplayDriver", IECore.Box2i( IECore.V2i(0,0), IECore.V2i(100,100) ), IECore.Box2i( IECore.V2i(10,10), IECore.V2i(40,40) ), [ 'r', 'g', 'b' ], IECore.CompoundData() ) + idd = IECoreImage.DisplayDriver.create( "ImageDisplayDriver", imath.Box2i( imath.V2i(0,0), imath.V2i(100,100) ), imath.Box2i( imath.V2i(10,10), imath.V2i(40,40) ), [ 'r', 'g', 'b' ], IECore.CompoundData() ) self.failUnless( isinstance( idd, IECoreImage.ImageDisplayDriver ) ) self.assertEqual( idd.scanLineOrderOnly(), False ) - self.assertEqual( idd.displayWindow(), IECore.Box2i( IECore.V2i(0,0), IECore.V2i(100,100) ) ) - self.assertEqual( idd.dataWindow(), IECore.Box2i( IECore.V2i(10,10), IECore.V2i(40,40) ) ) + self.assertEqual( idd.displayWindow(), imath.Box2i( imath.V2i(0,0), imath.V2i(100,100) ) ) + self.assertEqual( idd.dataWindow(), imath.Box2i( imath.V2i(10,10), imath.V2i(40,40) ) ) self.assertEqual( idd.channelNames(), [ 'r', 'g', 'b' ] ) # test if all symbols are gone after the tests. @@ -107,11 +108,11 @@ def testImagePool( self ) : red = img['R'] green = img['G'] blue = img['B'] - width = img.dataWindow.max.x - img.dataWindow.min.x + 1 + width = img.dataWindow.max().x - img.dataWindow.min().x + 1 buf = IECore.FloatVectorData( width * 3 ) - for i in xrange( 0, img.dataWindow.max.y - img.dataWindow.min.y + 1 ): + for i in xrange( 0, img.dataWindow.max().y - img.dataWindow.min().y + 1 ): self.__prepareBuf( buf, width, i*width, red, green, blue ) - idd.imageData( IECore.Box2i( IECore.V2i( img.dataWindow.min.x, i + img.dataWindow.min.y ), IECore.V2i( img.dataWindow.max.x, i + img.dataWindow.min.y) ), buf ) + idd.imageData( imath.Box2i( imath.V2i( img.dataWindow.min().x, i + img.dataWindow.min().y ), imath.V2i( img.dataWindow.max().x, i + img.dataWindow.min().y) ), buf ) idd.imageClose() @@ -121,7 +122,7 @@ def testImagePool( self ) : def testAcceptsRepeatedData( self ) : - window = IECore.Box2i( IECore.V2i( 0 ), IECore.V2i( 15 ) ) + window = imath.Box2i( imath.V2i( 0 ), imath.V2i( 15 ) ) dd = IECoreImage.ImageDisplayDriver( window, window, [ "Y" ], IECore.CompoundData() ) self.assertEqual( dd.acceptsRepeatedData(), True ) @@ -170,7 +171,7 @@ def testTransfer( self ): red = img['R'] green = img['G'] blue = img['B'] - width = img.dataWindow.max.x - img.dataWindow.min.x + 1 + width = img.dataWindow.max().x - img.dataWindow.min().x + 1 params = IECore.CompoundData() params['displayHost'] = IECore.StringData('localhost') @@ -181,9 +182,9 @@ def testTransfer( self ): idd = IECoreImage.ClientDisplayDriver( img.displayWindow, img.dataWindow, list( img.channelNames() ), params ) buf = IECore.FloatVectorData( width * 3 ) - for i in xrange( 0, img.dataWindow.max.y - img.dataWindow.min.y + 1 ): + for i in xrange( 0, img.dataWindow.max().y - img.dataWindow.min().y + 1 ): self.__prepareBuf( buf, width, i*width, red, green, blue ) - idd.imageData( IECore.Box2i( IECore.V2i( img.dataWindow.min.x, i + img.dataWindow.min.y ), IECore.V2i( img.dataWindow.max.x, i + img.dataWindow.min.y) ), buf ) + idd.imageData( imath.Box2i( imath.V2i( img.dataWindow.min().x, i + img.dataWindow.min().y ), imath.V2i( img.dataWindow.max().x, i + img.dataWindow.min().y) ), buf ) idd.imageClose() newImg = IECoreImage.ImageDisplayDriver.removeStoredImage( "myHandle" ) @@ -205,7 +206,7 @@ def testWrongSocketException( self ) : "remoteDisplayType" : "ImageDisplayDriver", } ) - dw = IECore.Box2i( IECore.V2i( 0 ), IECore.V2i( 255 ) ) + dw = imath.Box2i( imath.V2i( 0 ), imath.V2i( 255 ) ) self.assertRaises( RuntimeError, IECoreImage.ClientDisplayDriver, dw, dw, [ "R", "G", "B" ], parameters ) try : @@ -223,7 +224,7 @@ def testWrongHostException( self ) : "remoteDisplayType" : "ImageDisplayDriver", } ) - dw = IECore.Box2i( IECore.V2i( 0 ), IECore.V2i( 255 ) ) + dw = imath.Box2i( imath.V2i( 0 ), imath.V2i( 255 ) ) self.assertRaises( RuntimeError, IECoreImage.ClientDisplayDriver, dw, dw, [ "R", "G", "B" ], parameters ) try : @@ -235,7 +236,7 @@ def testWrongHostException( self ) : def testAcceptsRepeatedData( self ) : - window = IECore.Box2i( IECore.V2i( 0 ), IECore.V2i( 15 ) ) + window = imath.Box2i( imath.V2i( 0 ), imath.V2i( 15 ) ) dd = IECoreImage.ClientDisplayDriver( window, window, diff --git a/test/IECoreImage/ImagePrimitiveTest.py b/test/IECoreImage/ImagePrimitiveTest.py index 4853691764..46a436ad78 100644 --- a/test/IECoreImage/ImagePrimitiveTest.py +++ b/test/IECoreImage/ImagePrimitiveTest.py @@ -34,6 +34,7 @@ import os import unittest +import imath import IECore import IECoreImage @@ -43,32 +44,32 @@ class ImagePrimitiveTest( unittest.TestCase ) : def testConstructor( self ) : """ Test IECoreImage.ImagePrimitive constructor """ - windowMin = IECore.V2i( 0, 0 ) - windowMax = IECore.V2i( 100, 100 ) - w = IECore.Box2i( windowMin, windowMax ) + windowMin = imath.V2i( 0, 0 ) + windowMax = imath.V2i( 100, 100 ) + w = imath.Box2i( windowMin, windowMax ) i = IECoreImage.ImagePrimitive( w, w ) self.assertEqual( i.dataWindow, w ) self.assertEqual( i.displayWindow, w ) - i.dataWindow = IECore.Box2i( windowMin, IECore.V2i( 10, 10 ) ) - self.assertEqual( i.dataWindow, IECore.Box2i( windowMin, IECore.V2i( 10, 10 ) ) ) + i.dataWindow = imath.Box2i( windowMin, imath.V2i( 10, 10 ) ) + self.assertEqual( i.dataWindow, imath.Box2i( windowMin, imath.V2i( 10, 10 ) ) ) self.assertEqual( i.displayWindow, w ) - i.displayWindow = IECore.Box2i( windowMin, IECore.V2i( 10, 10 ) ) - self.assertEqual( i.displayWindow, IECore.Box2i( windowMin, IECore.V2i( 10, 10 ) ) ) + i.displayWindow = imath.Box2i( windowMin, imath.V2i( 10, 10 ) ) + self.assertEqual( i.displayWindow, imath.Box2i( windowMin, imath.V2i( 10, 10 ) ) ) def testDataWindow( self ) : - displayWindow = IECore.Box2i( IECore.V2i( 0, 0 ), IECore.V2i( 99, 99 ) ) - dataWindow = IECore.Box2i( IECore.V2i( 50, 50 ), IECore.V2i( 99, 99 ) ) + displayWindow = imath.Box2i( imath.V2i( 0, 0 ), imath.V2i( 99, 99 ) ) + dataWindow = imath.Box2i( imath.V2i( 50, 50 ), imath.V2i( 99, 99 ) ) img = IECoreImage.ImagePrimitive( dataWindow, displayWindow ) def testDataWindow( self ) : """ Test IECoreImage.ImagePrimitive data window """ - displayWindow = IECore.Box2i( IECore.V2i( 0, 0 ), IECore.V2i( 99, 99 ) ) - dataWindow = IECore.Box2i( IECore.V2i( 50, 50 ), IECore.V2i( 99, 99 ) ) + displayWindow = imath.Box2i( imath.V2i( 0, 0 ), imath.V2i( 99, 99 ) ) + dataWindow = imath.Box2i( imath.V2i( 50, 50 ), imath.V2i( 99, 99 ) ) img = IECoreImage.ImagePrimitive( dataWindow, displayWindow ) dataWindowArea = 50 * 50 @@ -84,9 +85,9 @@ def testDataWindow( self ) : def testLoadSave( self ) : """ Test IECoreImage.ImagePrimitive load/save """ - windowMin = IECore.V2i( 0, 0 ) - windowMax = IECore.V2i( 100, 100 ) - w = IECore.Box2i( windowMin, windowMax ) + windowMin = imath.V2i( 0, 0 ) + windowMax = imath.V2i( 100, 100 ) + w = imath.Box2i( windowMin, windowMax ) i = IECoreImage.ImagePrimitive( w, w ) i["R"] = IECore.FloatVectorData( 101 * 101 ) i["G"] = IECore.FloatVectorData( 101 * 101 ) @@ -107,9 +108,9 @@ def testChannelNames( self ) : """ Test IECoreImage.ImagePrimitive channel names """ - windowMin = IECore.V2i( 0, 0 ) - windowMax = IECore.V2i( 99, 99 ) - w = IECore.Box2i( windowMin, windowMax ) + windowMin = imath.V2i( 0, 0 ) + windowMax = imath.V2i( 99, 99 ) + w = imath.Box2i( windowMin, windowMax ) i = IECoreImage.ImagePrimitive( w, w ) r = IECore.FloatVectorData() @@ -145,9 +146,9 @@ def testChannelNames( self ) : def testCreateChannel( self ) : - windowMin = IECore.V2i( 0, 0 ) - windowMax = IECore.V2i( 99, 99 ) - w = IECore.Box2i( windowMin, windowMax ) + windowMin = imath.V2i( 0, 0 ) + windowMax = imath.V2i( 99, 99 ) + w = imath.Box2i( windowMin, windowMax ) i = IECoreImage.ImagePrimitive( w, w ) i.createFloatChannel( "R" ) @@ -160,12 +161,12 @@ def testCreateChannel( self ) : def testErrors( self ) : - windowMin = IECore.V2i( 0, 0 ) - windowMax = IECore.V2i( 99, 99 ) - w = IECore.Box2i( windowMin, windowMax ) + windowMin = imath.V2i( 0, 0 ) + windowMax = imath.V2i( 99, 99 ) + w = imath.Box2i( windowMin, windowMax ) i = IECoreImage.ImagePrimitive( w, w ) - empty = IECore.Box2i() + empty = imath.Box2i() self.assertRaises( RuntimeError, setattr, i, "displayWindow", empty ) @@ -173,7 +174,7 @@ def testErrors( self ) : def testChannelValid( self ) : - b = IECore.Box2i( IECore.V2i( 0 ), IECore.V2i( 9 ) ) + b = imath.Box2i( imath.V2i( 0 ), imath.V2i( 9 ) ) i = IECoreImage.ImagePrimitive( b, b ) d = IECore.FloatVectorData( [1] ) @@ -205,15 +206,15 @@ def testConvenienceConstructors( self ) : """ Test IECoreImage.ImagePrimitive convenience constructors """ - window1Min = IECore.V2i( 0, 0 ) - window1Max = IECore.V2i( 15, 15 ) - w1 = IECore.Box2i( window1Min, window1Max ) + window1Min = imath.V2i( 0, 0 ) + window1Max = imath.V2i( 15, 15 ) + w1 = imath.Box2i( window1Min, window1Max ) - window2Min = IECore.V2i( 4, 4 ) - window2Max = IECore.V2i( 11, 11 ) - w2 = IECore.Box2i( window2Min, window2Max ) + window2Min = imath.V2i( 4, 4 ) + window2Max = imath.V2i( 11, 11 ) + w2 = imath.Box2i( window2Min, window2Max ) - fill = IECore.Color3f( 0.49, 0.50, 0.51 ) + fill = imath.Color3f( 0.49, 0.50, 0.51 ) i = IECoreImage.ImagePrimitive.createRGBFloat( fill, w1, w2 ) self.assert_( i.isInstanceOf( IECoreImage.ImagePrimitive.staticTypeId() ) ) @@ -262,22 +263,22 @@ def testSpaces( self ) : # one pixel image 0,0 -> 0,0 - onePixelWindow = IECore.Box2i( IECore.V2i( 0 ), IECore.V2i( 0 ) ) + onePixelWindow = imath.Box2i( imath.V2i( 0 ), imath.V2i( 0 ) ) i = IECoreImage.ImagePrimitive( onePixelWindow, onePixelWindow ) m = i.pixelToObjectMatrix() - self.assertEqual( IECore.V2f( 0 ) * m, IECore.V2f( 0 ) ) + self.assertEqual( imath.V2f( 0 ) * m, imath.V2f( 0 ) ) m2 = i.objectToPixelMatrix() self.assertEqual( m2, m.inverse() ) m = i.pixelToUVMatrix() - self.assertEqual( IECore.V2f( 0 ) * m, IECore.V2f( 0.5 ) ) + self.assertEqual( imath.V2f( 0 ) * m, imath.V2f( 0.5 ) ) m2 = i.uvToPixelMatrix() self.assertEqual( m2, m.inverse() ) m = i.objectToUVMatrix() - self.assertEqual( IECore.V2f( -0.5 ) * m, IECore.V2f( 0, 1 ) ) - self.assertEqual( IECore.V2f( 0.5 ) * m, IECore.V2f( 1, 0 ) ) + self.assertEqual( imath.V2f( -0.5 ) * m, imath.V2f( 0, 1 ) ) + self.assertEqual( imath.V2f( 0.5 ) * m, imath.V2f( 1, 0 ) ) m2 = i.uvToObjectMatrix() self.assertEqual( m2, m.inverse() ) @@ -293,24 +294,24 @@ def testSpaces( self ) : # two pixel image 0,0 -> 1,1 - twoPixelWindow = IECore.Box2i( IECore.V2i( 0 ), IECore.V2i( 1 ) ) + twoPixelWindow = imath.Box2i( imath.V2i( 0 ), imath.V2i( 1 ) ) i = IECoreImage.ImagePrimitive( twoPixelWindow, twoPixelWindow ) m = i.pixelToObjectMatrix() - self.assertEqual( IECore.V2f( 0 ) * m, IECore.V2f( -0.5, 0.5 ) ) - self.assertEqual( IECore.V2f( 1 ) * m, IECore.V2f( 0.5, -0.5 ) ) + self.assertEqual( imath.V2f( 0 ) * m, imath.V2f( -0.5, 0.5 ) ) + self.assertEqual( imath.V2f( 1 ) * m, imath.V2f( 0.5, -0.5 ) ) m2 = i.objectToPixelMatrix() self.assertEqual( m2, m.inverse() ) m = i.pixelToUVMatrix() - self.assertEqual( IECore.V2f( 0 ) * m, IECore.V2f( 0.25 ) ) - self.assertEqual( IECore.V2f( 1 ) * m, IECore.V2f( 0.75 ) ) + self.assertEqual( imath.V2f( 0 ) * m, imath.V2f( 0.25 ) ) + self.assertEqual( imath.V2f( 1 ) * m, imath.V2f( 0.75 ) ) m2 = i.uvToPixelMatrix() self.assertEqual( m2, m.inverse() ) m = i.objectToUVMatrix() - self.assertEqual( IECore.V2f( -1 ) * m, IECore.V2f( 0, 1 ) ) - self.assertEqual( IECore.V2f( 1 ) * m, IECore.V2f( 1, 0 ) ) + self.assertEqual( imath.V2f( -1 ) * m, imath.V2f( 0, 1 ) ) + self.assertEqual( imath.V2f( 1 ) * m, imath.V2f( 1, 0 ) ) m2 = i.uvToObjectMatrix() self.assertEqual( m2, m.inverse() ) @@ -326,24 +327,24 @@ def testSpaces( self ) : # three by two pixel image 10,20 -> 12,21 - threeTwoPixelWindowOffset = IECore.Box2i( IECore.V2i( 10, 20 ), IECore.V2i( 12, 21 ) ) + threeTwoPixelWindowOffset = imath.Box2i( imath.V2i( 10, 20 ), imath.V2i( 12, 21 ) ) i = IECoreImage.ImagePrimitive( threeTwoPixelWindowOffset, threeTwoPixelWindowOffset ) m = i.pixelToObjectMatrix() - self.assertEqual( IECore.V2f( 10, 20 ) * m, IECore.V2f( -1, 0.5 ) ) - self.assertEqual( IECore.V2f( 12, 21 ) * m, IECore.V2f( 1, -0.5 ) ) + self.assertEqual( imath.V2f( 10, 20 ) * m, imath.V2f( -1, 0.5 ) ) + self.assertEqual( imath.V2f( 12, 21 ) * m, imath.V2f( 1, -0.5 ) ) m2 = i.objectToPixelMatrix() self.assertEqual( m2, m.inverse() ) m = i.pixelToUVMatrix() - self.failUnless( (IECore.V2f( 10, 20 ) * m).equalWithAbsError( IECore.V2f( 1 / 6.0, 1 / 4.0 ), 0.00001 ) ) - self.failUnless( (IECore.V2f( 12, 21 ) * m).equalWithAbsError( IECore.V2f( 5 / 6.0, 3 / 4.0 ), 0.00001 ) ) + self.failUnless( (imath.V2f( 10, 20 ) * m).equalWithAbsError( imath.V2f( 1 / 6.0, 1 / 4.0 ), 0.00001 ) ) + self.failUnless( (imath.V2f( 12, 21 ) * m).equalWithAbsError( imath.V2f( 5 / 6.0, 3 / 4.0 ), 0.00001 ) ) m2 = i.uvToPixelMatrix() self.assertEqual( m2, m.inverse() ) m = i.objectToUVMatrix() - self.assertEqual( IECore.V2f( -1.5, -1 ) * m, IECore.V2f( 0, 1 ) ) - self.assertEqual( IECore.V2f( 1.5, 1 ) * m, IECore.V2f( 1, 0 ) ) + self.assertEqual( imath.V2f( -1.5, -1 ) * m, imath.V2f( 0, 1 ) ) + self.assertEqual( imath.V2f( 1.5, 1 ) * m, imath.V2f( 1, 0 ) ) m2 = i.uvToObjectMatrix() self.assertEqual( m2, m.inverse() ) @@ -359,15 +360,15 @@ def testSpaces( self ) : def testHash( self ) : - w = IECore.Box2i( IECore.V2i( 0 ), IECore.V2i( 10 ) ) + w = imath.Box2i( imath.V2i( 0 ), imath.V2i( 10 ) ) i = IECoreImage.ImagePrimitive( w, w ) h = i.hash() - i.displayWindow = IECore.Box2i( IECore.V2i( 10 ), IECore.V2i( 20 ) ) + i.displayWindow = imath.Box2i( imath.V2i( 10 ), imath.V2i( 20 ) ) self.assertNotEqual( i.hash(), h ) h = i.hash() - i.dataWindow = IECore.Box2i( IECore.V2i( 10 ), IECore.V2i( 20 ) ) + i.dataWindow = imath.Box2i( imath.V2i( 10 ), imath.V2i( 20 ) ) self.assertNotEqual( i.hash(), h ) h = i.hash() diff --git a/test/IECoreImage/ImageReaderTest.py b/test/IECoreImage/ImageReaderTest.py index eea0cf5d52..a78126f1a7 100644 --- a/test/IECoreImage/ImageReaderTest.py +++ b/test/IECoreImage/ImageReaderTest.py @@ -35,6 +35,7 @@ import os import sys import unittest +import imath import IECore import IECoreImage @@ -129,18 +130,18 @@ def testReadHeader( self ): self.assertTrue( "diffuse.green" in c ) self.assertTrue( "diffuse.blue" in c ) - self.assertEqual( h['displayWindow'], IECore.Box2iData( IECore.Box2i( IECore.V2i(0,0), IECore.V2i(255,255) ) ) ) - self.assertEqual( h['dataWindow'], IECore.Box2iData( IECore.Box2i( IECore.V2i(0,0), IECore.V2i(255,255) ) ) ) + self.assertEqual( h['displayWindow'], IECore.Box2iData( imath.Box2i( imath.V2i(0,0), imath.V2i(255,255) ) ) ) + self.assertEqual( h['dataWindow'], IECore.Box2iData( imath.Box2i( imath.V2i(0,0), imath.V2i(255,255) ) ) ) def testDataAndDisplayWindows( self ) : r = IECoreImage.ImageReader( "test/IECoreImage/data/exr/AllHalfValues.exr" ) - self.assertEqual( r.dataWindow(), IECore.Box2i( IECore.V2i( 0 ), IECore.V2i( 255 ) ) ) - self.assertEqual( r.displayWindow(), IECore.Box2i( IECore.V2i( 0 ), IECore.V2i( 255 ) ) ) + self.assertEqual( r.dataWindow(), imath.Box2i( imath.V2i( 0 ), imath.V2i( 255 ) ) ) + self.assertEqual( r.displayWindow(), imath.Box2i( imath.V2i( 0 ), imath.V2i( 255 ) ) ) r = IECoreImage.ImageReader( "test/IECoreImage/data/exr/uvMapWithDataWindow.100x100.exr" ) - self.assertEqual( r.dataWindow(), IECore.Box2i( IECore.V2i( 25 ), IECore.V2i( 49 ) ) ) - self.assertEqual( r.displayWindow(), IECore.Box2i( IECore.V2i( 0 ), IECore.V2i( 99 ) ) ) + self.assertEqual( r.dataWindow(), imath.Box2i( imath.V2i( 25 ), imath.V2i( 49 ) ) ) + self.assertEqual( r.displayWindow(), imath.Box2i( imath.V2i( 0 ), imath.V2i( 99 ) ) ) r = IECoreImage.ImageReader( "thisFileDoesntExist.exr" ) self.assertRaises( Exception, r.dataWindow ) @@ -153,8 +154,8 @@ def testReadImage( self ) : i = r.read() self.assertEqual( i.typeId(), IECoreImage.ImagePrimitive.staticTypeId() ) - self.assertEqual( i.dataWindow, IECore.Box2i( IECore.V2i( 0 ), IECore.V2i( 255 ) ) ) - self.assertEqual( i.displayWindow, IECore.Box2i( IECore.V2i( 0 ), IECore.V2i( 255 ) ) ) + self.assertEqual( i.dataWindow, imath.Box2i( imath.V2i( 0 ), imath.V2i( 255 ) ) ) + self.assertEqual( i.displayWindow, imath.Box2i( imath.V2i( 0 ), imath.V2i( 255 ) ) ) self.assertTrue( i.channelsValid() ) @@ -186,8 +187,8 @@ def testNonZeroDataWindowOrigin( self ) : r = IECoreImage.ImageReader( "test/IECoreImage/data/exr/uvMapWithDataWindow.100x100.exr" ) i = r.read() - self.assertEqual( i.dataWindow, IECore.Box2i( IECore.V2i( 25 ), IECore.V2i( 49 ) ) ) - self.assertEqual( i.displayWindow, IECore.Box2i( IECore.V2i( 0 ), IECore.V2i( 99 ) ) ) + self.assertEqual( i.dataWindow, imath.Box2i( imath.V2i( 25 ), imath.V2i( 49 ) ) ) + self.assertEqual( i.displayWindow, imath.Box2i( imath.V2i( 0 ), imath.V2i( 99 ) ) ) self.assertTrue( i.channelsValid() ) @@ -196,15 +197,15 @@ def testOrientation( self ) : img = IECore.Reader.create( "test/IECoreImage/data/exr/uvMap.512x256.exr" ).read() indexedColors = { - 0 : IECore.V3f( 0, 0, 0 ), - 511 : IECore.V3f( 1, 0, 0 ), - 512 * 255 : IECore.V3f( 0, 1, 0 ), - 512 * 255 + 511 : IECore.V3f( 1, 1, 0 ), + 0 : imath.V3f( 0, 0, 0 ), + 511 : imath.V3f( 1, 0, 0 ), + 512 * 255 : imath.V3f( 0, 1, 0 ), + 512 * 255 + 511 : imath.V3f( 1, 1, 0 ), } for index, expectedColor in indexedColors.items() : - color = IECore.V3f( img["R"][index], img["G"][index], img["B"][index] ) + color = imath.V3f( img["R"][index], img["G"][index], img["B"][index] ) self.assertTrue( ( color - expectedColor).length() < 1.e-6 ) @@ -219,9 +220,9 @@ def testHeaderToBlindData( self ) : 'channelNames': IECore.StringVectorData( [ "R", "G", "B" ] ), 'oiio:ColorSpace': IECore.StringData( "Linear" ), 'compression': IECore.StringData( "piz" ), - 'screenWindowCenter': IECore.V2fData( IECore.V2f(0,0) ), - 'displayWindow': IECore.Box2iData( IECore.Box2i( IECore.V2i(0,0), IECore.V2i(511,255) ) ), - 'dataWindow': IECore.Box2iData( IECore.Box2i( IECore.V2i(0,0), IECore.V2i(511,255) ) ), + 'screenWindowCenter': IECore.V2fData( imath.V2f(0,0) ), + 'displayWindow': IECore.Box2iData( imath.Box2i( imath.V2i(0,0), imath.V2i(511,255) ) ), + 'dataWindow': IECore.Box2iData( imath.Box2i( imath.V2i(0,0), imath.V2i(511,255) ) ), 'PixelAspectRatio': IECore.FloatData( 1 ), 'screenWindowWidth': IECore.FloatData( 1 ), 'deep': IECore.BoolData( False ), @@ -298,8 +299,8 @@ def testTiff( self ) : r["rawChannels"] = IECore.BoolData( True ) imgRaw = r.read() - self.assertEqual( img.displayWindow, IECore.Box2i( IECore.V2i( 0, 0 ), IECore.V2i( 199, 99 ) ) ) - self.assertEqual( img.dataWindow, IECore.Box2i( IECore.V2i( 0, 0 ), IECore.V2i( 199, 99 ) ) ) + self.assertEqual( img.displayWindow, imath.Box2i( imath.V2i( 0, 0 ), imath.V2i( 199, 99 ) ) ) + self.assertEqual( img.dataWindow, imath.Box2i( imath.V2i( 0, 0 ), imath.V2i( 199, 99 ) ) ) self.assertTrue( img.channelsValid() ) self.assertTrue( imgRaw.channelsValid() ) diff --git a/test/IECoreImage/ImageWriterTest.py b/test/IECoreImage/ImageWriterTest.py index aac9daee3b..71389eb3c4 100644 --- a/test/IECoreImage/ImageWriterTest.py +++ b/test/IECoreImage/ImageWriterTest.py @@ -35,6 +35,7 @@ import os import datetime import unittest +import imath import IECore import IECoreImage @@ -78,8 +79,8 @@ def __makeFloatImage( self, dataWindow, displayWindow, withAlpha = False, dataTy img = IECoreImage.ImagePrimitive( dataWindow, displayWindow ) - w = dataWindow.max.x - dataWindow.min.x + 1 - h = dataWindow.max.y - dataWindow.min.y + 1 + w = dataWindow.max().x - dataWindow.min().x + 1 + h = dataWindow.max().y - dataWindow.min().y + 1 area = w * h R = dataType( area ) @@ -114,8 +115,8 @@ def __makeIntImage( self, dataWindow, displayWindow, dataType = IECore.UIntVecto img = IECoreImage.ImagePrimitive( dataWindow, displayWindow ) - w = dataWindow.max.x - dataWindow.min.x + 1 - h = dataWindow.max.y - dataWindow.min.y + 1 + w = dataWindow.max().x - dataWindow.min().x + 1 + h = dataWindow.max().y - dataWindow.min().y + 1 area = w * h R = dataType( area ) @@ -142,8 +143,8 @@ def __makeGreyscaleImage( self, dataWindow, displayWindow ) : img = IECoreImage.ImagePrimitive( dataWindow, displayWindow ) - w = dataWindow.max.x - dataWindow.min.x + 1 - h = dataWindow.max.y - dataWindow.min.y + 1 + w = dataWindow.max().x - dataWindow.min().x + 1 + h = dataWindow.max().y - dataWindow.min().y + 1 area = w * h Y = IECore.FloatVectorData( area ) @@ -186,9 +187,9 @@ def testSupportedExtensions( self ) : def testCanWrite( self ) : - displayWindow = IECore.Box2i( - IECore.V2i( 0, 0 ), - IECore.V2i( 99, 99 ) + displayWindow = imath.Box2i( + imath.V2i( 0, 0 ), + imath.V2i( 99, 99 ) ) dataWindow = displayWindow @@ -211,9 +212,9 @@ def testCanWrite( self ) : def testWrite( self ) : - displayWindow = IECore.Box2i( - IECore.V2i( 0, 0 ), - IECore.V2i( 99, 99 ) + displayWindow = imath.Box2i( + imath.V2i( 0, 0 ), + imath.V2i( 99, 99 ) ) dataWindow = displayWindow @@ -241,9 +242,9 @@ def testWrite( self ) : def testWriteIncomplete( self ) : - displayWindow = IECore.Box2i( - IECore.V2i( 0, 0 ), - IECore.V2i( 99, 99 ) + displayWindow = imath.Box2i( + imath.V2i( 0, 0 ), + imath.V2i( 99, 99 ) ) dataWindow = displayWindow @@ -251,9 +252,9 @@ def testWriteIncomplete( self ) : imgOrig = self.__makeFloatImage( dataWindow, displayWindow ) # We don't have enough data to fill this dataWindow - imgOrig.dataWindow = IECore.Box2i( - IECore.V2i( 0, 0 ), - IECore.V2i( 199, 199 ) + imgOrig.dataWindow = imath.Box2i( + imath.V2i( 0, 0 ), + imath.V2i( 199, 199 ) ) self.failIf( imgOrig.channelsValid() ) @@ -266,16 +267,16 @@ def testWriteIncomplete( self ) : def testWindowWrite( self ) : - dataWindow = IECore.Box2i( - IECore.V2i( 0, 0 ), - IECore.V2i( 99, 99 ) + dataWindow = imath.Box2i( + imath.V2i( 0, 0 ), + imath.V2i( 99, 99 ) ) imgOrig = self.__makeFloatImage( dataWindow, dataWindow ) - imgOrig.displayWindow = IECore.Box2i( - IECore.V2i( -20, -20 ), - IECore.V2i( 199, 199 ) + imgOrig.displayWindow = imath.Box2i( + imath.V2i( -20, -20 ), + imath.V2i( 199, 199 ) ) w = IECore.Writer.create( imgOrig, "test/IECoreImage/data/exr/output.exr" ) @@ -308,9 +309,9 @@ def testOversizeDataWindow( self ) : def testBlindDataToHeader( self ) : - displayWindow = IECore.Box2i( - IECore.V2i( 0, 0 ), - IECore.V2i( 9, 9 ) + displayWindow = imath.Box2i( + imath.V2i( 0, 0 ), + imath.V2i( 9, 9 ) ) dataWindow = displayWindow @@ -319,15 +320,15 @@ def testBlindDataToHeader( self ) : "two": IECore.FloatData( 2 ), "three": IECore.DoubleData( 3 ), "four" : { - "five": IECore.V2fData( IECore.V2f(5) ), - "six": IECore.V2iData( IECore.V2i(6) ), - "seven": IECore.V3fData( IECore.V3f(7) ), - "eight": IECore.V3iData( IECore.V3i(8) ), + "five": IECore.V2fData( imath.V2f(5) ), + "six": IECore.V2iData( imath.V2i(6) ), + "seven": IECore.V3fData( imath.V3f(7) ), + "eight": IECore.V3iData( imath.V3i(8) ), "nine": { - "ten": IECore.Box2iData( IECore.Box2i( IECore.V2i(0), IECore.V2i(10) ) ), - "eleven": IECore.Box2fData( IECore.Box2f( IECore.V2f(0), IECore.V2f(11) ) ), - "twelve": IECore.M33fData( IECore.M33f(12) ), - "thirteen": IECore.M44fData( IECore.M44f(13) ), + "ten": IECore.Box2iData( imath.Box2i( imath.V2i(0), imath.V2i(10) ) ), + "eleven": IECore.Box2fData( imath.Box2f( imath.V2f(0), imath.V2f(11) ) ), + "twelve": IECore.M33fData( imath.M33f(12) ), + "thirteen": IECore.M44fData( imath.M44f(13) ), }, "fourteen": IECore.StringData( "fourteen" ), "fifteen": IECore.TimeCodeData( IECore.TimeCode( 1, 2, 3, 4, dropFrame = True, bgf2 = True, binaryGroup4 = 4 ) ), @@ -365,9 +366,9 @@ def testBlindDataToHeader( self ) : def testJPG( self ) : - displayWindow = IECore.Box2i( - IECore.V2i( 0, 0 ), - IECore.V2i( 99, 99 ) + displayWindow = imath.Box2i( + imath.V2i( 0, 0 ), + imath.V2i( 99, 99 ) ) dataWindow = displayWindow @@ -425,9 +426,9 @@ def testJPG( self ) : def testGreyscaleJPG( self ) : - displayWindow = IECore.Box2i( - IECore.V2i( 0, 0 ), - IECore.V2i( 199, 99 ) + displayWindow = imath.Box2i( + imath.V2i( 0, 0 ), + imath.V2i( 199, 99 ) ) dataWindow = displayWindow @@ -452,9 +453,9 @@ def testGreyscaleJPG( self ) : @unittest.skipIf( not os.path.exists( os.environ.get( "OCIO", "" ) ), "Insufficient color specification. Linear -> Cineon conversion is not possible with an OCIO config" ) def testDPX( self ) : - displayWindow = IECore.Box2i( - IECore.V2i( 0, 0 ), - IECore.V2i( 99, 99 ) + displayWindow = imath.Box2i( + imath.V2i( 0, 0 ), + imath.V2i( 99, 99 ) ) dataWindow = displayWindow @@ -513,9 +514,9 @@ def testDPX( self ) : def testTIF( self ) : - displayWindow = IECore.Box2i( - IECore.V2i( 0, 0 ), - IECore.V2i( 99, 99 ) + displayWindow = imath.Box2i( + imath.V2i( 0, 0 ), + imath.V2i( 99, 99 ) ) dataWindow = displayWindow @@ -572,9 +573,9 @@ def testTIF( self ) : def testAlphaTIF( self ) : - displayWindow = IECore.Box2i( - IECore.V2i( 0, 0 ), - IECore.V2i( 99, 99 ) + displayWindow = imath.Box2i( + imath.V2i( 0, 0 ), + imath.V2i( 99, 99 ) ) dataWindow = displayWindow @@ -594,9 +595,9 @@ def testAlphaTIF( self ) : def testGreyscaleTIF( self ) : - displayWindow = IECore.Box2i( - IECore.V2i( 0, 0 ), - IECore.V2i( 199, 99 ) + displayWindow = imath.Box2i( + imath.V2i( 0, 0 ), + imath.V2i( 199, 99 ) ) dataWindow = displayWindow @@ -673,9 +674,9 @@ def testEXRCompressionParameter( self ): def testJPGQualityParameter( self ) : - w = IECore.Box2i( - IECore.V2i( 0, 0 ), - IECore.V2i( 99, 99) + w = imath.Box2i( + imath.V2i( 0, 0 ), + imath.V2i( 99, 99) ) img = self.__makeFloatImage( w, w ) @@ -706,9 +707,9 @@ def testJPGQualityParameter( self ) : def testTIFBitdepthParameter( self ) : - displayWindow = IECore.Box2i( - IECore.V2i( 0, 0 ), - IECore.V2i( 199, 99 ) + displayWindow = imath.Box2i( + imath.V2i( 0, 0 ), + imath.V2i( 199, 99 ) ) dataWindow = displayWindow diff --git a/test/IECoreImage/LuminanceOpTest.py b/test/IECoreImage/LuminanceOpTest.py index 8913b934e4..a8e2eaf2b4 100644 --- a/test/IECoreImage/LuminanceOpTest.py +++ b/test/IECoreImage/LuminanceOpTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreImage @@ -51,13 +52,13 @@ def testParameterDefaults( self ) : def testSeparateRGB( self ) : - w = IECore.Box2i( IECore.V2i( 0 ), IECore.V2i( 2, 0 ) ) + w = imath.Box2i( imath.V2i( 0 ), imath.V2i( 2, 0 ) ) i = IECoreImage.ImagePrimitive( w, w ) i["R"] = IECore.FloatVectorData( [ 1, 2, 3 ] ) i["G"] = IECore.FloatVectorData( [ 4, 5, 6 ] ) i["B"] = IECore.FloatVectorData( [ 7, 8, 9 ] ) - ii = IECoreImage.LuminanceOp()( input=i, weights=IECore.Color3f( 1, 2, 3 ) ) + ii = IECoreImage.LuminanceOp()( input=i, weights=imath.Color3f( 1, 2, 3 ) ) self.assert_( not "R" in ii ) self.assert_( not "G" in ii ) @@ -72,9 +73,9 @@ def testSeparateRGB( self ) : def testCs( self ) : i = IECoreImage.ImagePrimitive() - i["Cs"] = IECore.Color3fVectorData( [ IECore.Color3f( 1, 2, 3 ), IECore.Color3f( 10, 11, 12 ) ] ) + i["Cs"] = IECore.Color3fVectorData( [ imath.Color3f( 1, 2, 3 ), imath.Color3f( 10, 11, 12 ) ] ) - ii = IECoreImage.LuminanceOp()( input=i, weights=IECore.Color3f( 1, 2, 3 ), removeColorChannels=False ) + ii = IECoreImage.LuminanceOp()( input=i, weights=imath.Color3f( 1, 2, 3 ), removeColorChannels=False ) self.assert_( "Cs" in ii ) self.assert_( "Y" in ii ) diff --git a/test/IECoreImage/MedianCutSamplerTest.py b/test/IECoreImage/MedianCutSamplerTest.py index 7a7248288d..5382c6cd0f 100644 --- a/test/IECoreImage/MedianCutSamplerTest.py +++ b/test/IECoreImage/MedianCutSamplerTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreImage @@ -62,10 +63,10 @@ def test( self ) : areaSum = 0 for i in range( 0, len( centroids ) ) : c = centroids[i] - c = IECore.V2i( int(c.x), int(c.y) ) + c = imath.V2i( int(c.x), int(c.y) ) self.assert_( dataWindow.intersects( c ) ) self.assert_( areas[i].intersects( c ) ) - s = areas[i].size() + IECore.V2i( 1 ) + s = areas[i].size() + imath.V2i( 1 ) areaSum += s.x * s.y self.assertEqual( areaSum, luminanceImage.channelSize() ) diff --git a/test/IECoreImage/SplineToImageTest.py b/test/IECoreImage/SplineToImageTest.py index 2d431d5a91..ead484b696 100644 --- a/test/IECoreImage/SplineToImageTest.py +++ b/test/IECoreImage/SplineToImageTest.py @@ -35,6 +35,7 @@ import unittest import os import sys +import imath import IECore import IECoreImage @@ -51,10 +52,10 @@ def test( self ) : sd = IECore.SplineffData( s ) - i = IECoreImage.SplineToImage()( spline=sd, resolution=IECore.V2i( 10, 256 ) ) + i = IECoreImage.SplineToImage()( spline=sd, resolution=imath.V2i( 10, 256 ) ) - self.assertEqual( i.dataWindow, IECore.Box2i( IECore.V2i( 0 ), IECore.V2i( 9, 255 ) ) ) - self.assertEqual( i.displayWindow, IECore.Box2i( IECore.V2i( 0 ), IECore.V2i( 9, 255 ) ) ) + self.assertEqual( i.dataWindow, imath.Box2i( imath.V2i( 0 ), imath.V2i( 9, 255 ) ) ) + self.assertEqual( i.displayWindow, imath.Box2i( imath.V2i( 0 ), imath.V2i( 9, 255 ) ) ) self.assertEqual( len( i ), 1 ) self.assert_( "Y" in i ) diff --git a/test/IECoreImage/SummedAreaOpTest.py b/test/IECoreImage/SummedAreaOpTest.py index ac55399418..5b9f04f722 100644 --- a/test/IECoreImage/SummedAreaOpTest.py +++ b/test/IECoreImage/SummedAreaOpTest.py @@ -34,6 +34,7 @@ import unittest import math +import imath import IECore import IECoreImage @@ -41,7 +42,7 @@ class SummedAreaOpTest( unittest.TestCase ) : def test( self ) : - b = IECore.Box2i( IECore.V2i( 0 ), IECore.V2i( 1 ) ) + b = imath.Box2i( imath.V2i( 0 ), imath.V2i( 1 ) ) i = IECoreImage.ImagePrimitive( b, b ) i["Y"] = IECore.FloatVectorData( [ 1, 2, 3, 4 ] ) diff --git a/test/IECoreMaya/FnParameterisedHolderTest.py b/test/IECoreMaya/FnParameterisedHolderTest.py index 6fca30c93b..58e9c6a100 100644 --- a/test/IECoreMaya/FnParameterisedHolderTest.py +++ b/test/IECoreMaya/FnParameterisedHolderTest.py @@ -39,6 +39,7 @@ import maya.cmds import maya.OpenMaya +import imath import IECore import IECoreScene @@ -161,12 +162,12 @@ def testSetNodeValuesUndo( self ) : fnF.copyTo( fList ) self.assertEqual( fList, [ "one", "two", "three" ] ) - self.assertEqual( op["g"].getTypedValue(), IECore.V2f( 1, 2 ) ) + self.assertEqual( op["g"].getTypedValue(), imath.V2f( 1, 2 ) ) gPlug = fnPH.parameterPlug( op["g"] ) self.assertEqual( gPlug.child( 0 ).asFloat(), 1 ) self.assertEqual( gPlug.child( 1 ).asFloat(), 2 ) - self.assertEqual( op["h"].getTypedValue(), IECore.V3f( 1, 1, 1 ) ) + self.assertEqual( op["h"].getTypedValue(), imath.V3f( 1, 1, 1 ) ) hPlug = fnPH.parameterPlug( op["h"] ) self.assertEqual( hPlug.child( 0 ).asFloat(), 1 ) self.assertEqual( hPlug.child( 1 ).asFloat(), 1 ) @@ -176,7 +177,7 @@ def testSetNodeValuesUndo( self ) : qPlug = fnPH.parameterPlug( op["q"] ) self.assertEqual( qPlug.asBool(), False ) - self.assertEqual( op["t"].getTypedValue(), IECore.Box3f( IECore.V3f( -1 ), IECore.V3f( 1 ) ) ) + self.assertEqual( op["t"].getTypedValue(), imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ) ) tPlug = fnPH.parameterPlug( op["t"] ) self.assertEqual( tPlug.child( 0 ).child( 0 ).asFloat(), -1 ) self.assertEqual( tPlug.child( 0 ).child( 1 ).asFloat(), -1 ) @@ -197,10 +198,10 @@ def testSetNodeValuesUndo( self ) : op["d"].setTypedValue( "a" ) op["e"].setValue( IECore.IntVectorData( [ 1, 2, 3, 4 ] ) ) op["f"].setValue( IECore.StringVectorData( [ "hi" ] ) ) - op["g"].setTypedValue( IECore.V2f( 10, 100 ) ) - op["h"].setTypedValue( IECore.V3f( -1, -2, -3 ) ) + op["g"].setTypedValue( imath.V2f( 10, 100 ) ) + op["h"].setTypedValue( imath.V3f( -1, -2, -3 ) ) op["q"].setTypedValue( True ) - op["t"].setTypedValue( IECore.Box3f( IECore.V3f( -10 ), IECore.V3f( 0 ) ) ) + op["t"].setTypedValue( imath.Box3f( imath.V3f( -10 ), imath.V3f( 0 ) ) ) # check they are changed self.assertEqual( op["a"].getNumericValue(), 10 ) @@ -209,10 +210,10 @@ def testSetNodeValuesUndo( self ) : self.assertEqual( op["d"].getTypedValue(), "a" ) self.assertEqual( op["e"].getValue(), IECore.IntVectorData( [ 1, 2, 3, 4 ] ) ) self.assertEqual( op["f"].getValue(), IECore.StringVectorData( [ "hi" ] ) ) - self.assertEqual( op["g"].getTypedValue(), IECore.V2f( 10, 100 ) ) - self.assertEqual( op["h"].getTypedValue(), IECore.V3f( -1, -2, -3 ) ) + self.assertEqual( op["g"].getTypedValue(), imath.V2f( 10, 100 ) ) + self.assertEqual( op["h"].getTypedValue(), imath.V3f( -1, -2, -3 ) ) self.assertEqual( op["q"].getTypedValue(), True ) - self.assertEqual( op["t"].getTypedValue(), IECore.Box3f( IECore.V3f( -10 ), IECore.V3f( 0 ) ) ) + self.assertEqual( op["t"].getTypedValue(), imath.Box3f( imath.V3f( -10 ), imath.V3f( 0 ) ) ) # push the changes onto the node fnPH.setNodeValues() @@ -263,10 +264,10 @@ def testSetNodeValuesUndo( self ) : self.assertEqual( op["d"].getTypedValue(), "a" ) self.assertEqual( op["e"].getValue(), IECore.IntVectorData( [ 1, 2, 3, 4 ] ) ) self.assertEqual( op["f"].getValue(), IECore.StringVectorData( [ "hi" ] ) ) - self.assertEqual( op["g"].getTypedValue(), IECore.V2f( 10, 100 ) ) - self.assertEqual( op["h"].getTypedValue(), IECore.V3f( -1, -2, -3 ) ) + self.assertEqual( op["g"].getTypedValue(), imath.V2f( 10, 100 ) ) + self.assertEqual( op["h"].getTypedValue(), imath.V3f( -1, -2, -3 ) ) self.assertEqual( op["q"].getTypedValue(), True ) - self.assertEqual( op["t"].getTypedValue(), IECore.Box3f( IECore.V3f( -10 ), IECore.V3f( 0 ) ) ) + self.assertEqual( op["t"].getTypedValue(), imath.Box3f( imath.V3f( -10 ), imath.V3f( 0 ) ) ) # undo, and check the node values are back to before @@ -315,10 +316,10 @@ def testSetNodeValuesUndo( self ) : self.assertEqual( op["d"].getTypedValue(), "a" ) self.assertEqual( op["e"].getValue(), IECore.IntVectorData( [ 1, 2, 3, 4 ] ) ) self.assertEqual( op["f"].getValue(), IECore.StringVectorData( [ "hi" ] ) ) - self.assertEqual( op["g"].getTypedValue(), IECore.V2f( 10, 100 ) ) - self.assertEqual( op["h"].getTypedValue(), IECore.V3f( -1, -2, -3 ) ) + self.assertEqual( op["g"].getTypedValue(), imath.V2f( 10, 100 ) ) + self.assertEqual( op["h"].getTypedValue(), imath.V3f( -1, -2, -3 ) ) self.assertEqual( op["q"].getTypedValue(), True ) - self.assertEqual( op["t"].getTypedValue(), IECore.Box3f( IECore.V3f( -10 ), IECore.V3f( 0 ) ) ) + self.assertEqual( op["t"].getTypedValue(), imath.Box3f( imath.V3f( -10 ), imath.V3f( 0 ) ) ) # redo, and check they are changed again ############################################################################# @@ -367,10 +368,10 @@ def testSetNodeValuesUndo( self ) : self.assertEqual( op["d"].getTypedValue(), "a" ) self.assertEqual( op["e"].getValue(), IECore.IntVectorData( [ 1, 2, 3, 4 ] ) ) self.assertEqual( op["f"].getValue(), IECore.StringVectorData( [ "hi" ] ) ) - self.assertEqual( op["g"].getTypedValue(), IECore.V2f( 10, 100 ) ) - self.assertEqual( op["h"].getTypedValue(), IECore.V3f( -1, -2, -3 ) ) + self.assertEqual( op["g"].getTypedValue(), imath.V2f( 10, 100 ) ) + self.assertEqual( op["h"].getTypedValue(), imath.V3f( -1, -2, -3 ) ) self.assertEqual( op["q"].getTypedValue(), True ) - self.assertEqual( op["t"].getTypedValue(), IECore.Box3f( IECore.V3f( -10 ), IECore.V3f( 0 ) ) ) + self.assertEqual( op["t"].getTypedValue(), imath.Box3f( imath.V3f( -10 ), imath.V3f( 0 ) ) ) def testSetNodeValueUndo( self ) : @@ -710,10 +711,10 @@ def testArrayPlugCreation( self ) : def testMatrixVectorPlugs( self ) : - m44fVector = IECore.M44fVectorData( [ IECore.M44f( 1 ), IECore.M44f( 2 ), IECore.M44f( 3 ) ] ) - m44dVector = IECore.M44dVectorData( [ IECore.M44d( 1 ), IECore.M44d( 2 ), IECore.M44d( 3 ) ] ) - reverseM44fVector = IECore.M44fVectorData( [ IECore.M44f( 3 ), IECore.M44f( 2 ), IECore.M44f( 1 ) ] ) - reverseM44dVector = IECore.M44dVectorData( [ IECore.M44d( 3 ), IECore.M44d( 2 ), IECore.M44d( 1 ) ] ) + m44fVector = IECore.M44fVectorData( [ imath.M44f( 1 ), imath.M44f( 2 ), imath.M44f( 3 ) ] ) + m44dVector = IECore.M44dVectorData( [ imath.M44d( 1 ), imath.M44d( 2 ), imath.M44d( 3 ) ] ) + reverseM44fVector = IECore.M44fVectorData( [ imath.M44f( 3 ), imath.M44f( 2 ), imath.M44f( 1 ) ] ) + reverseM44dVector = IECore.M44dVectorData( [ imath.M44d( 3 ), imath.M44d( 2 ), imath.M44d( 1 ) ] ) mayaArray = [] for i in range( 0, 3 ) : diff --git a/test/IECoreMaya/FnSceneShapeTest.py b/test/IECoreMaya/FnSceneShapeTest.py index d37e516ab9..25a8d47302 100644 --- a/test/IECoreMaya/FnSceneShapeTest.py +++ b/test/IECoreMaya/FnSceneShapeTest.py @@ -36,6 +36,7 @@ import os import maya.cmds +import imath import IECore import IECoreScene @@ -49,24 +50,24 @@ def setUp( self ) : scene = IECoreScene.SceneCache( FnSceneShapeTest.__testFile, IECore.IndexedIO.OpenMode.Write ) sc = scene.createChild( str(1) ) - mesh = IECoreScene.MeshPrimitive.createBox(IECore.Box3f(IECore.V3f(0),IECore.V3f(1))) - mesh["Cd"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ IECore.V3f( 1, 0, 0 ) ] * 6 ) ) + mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) + mesh["Cd"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ imath.V3f( 1, 0, 0 ) ] * 6 ) ) sc.writeObject( mesh, 0.0 ) - matrix = IECore.M44d.createTranslated( IECore.V3d( 1, 0, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 1, 0, 0 ) ) sc.writeTransform( IECore.M44dData( matrix ), 0.0 ) sc = sc.createChild( "child" ) - mesh = IECoreScene.MeshPrimitive.createBox(IECore.Box3f(IECore.V3f(0),IECore.V3f(1))) - mesh["Cd"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ IECore.V3f( 0, 1, 0 ) ] * 6 ) ) + mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) + mesh["Cd"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ imath.V3f( 0, 1, 0 ) ] * 6 ) ) sc.writeObject( mesh, 0.0 ) - matrix = IECore.M44d.createTranslated( IECore.V3d( 2, 0, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 2, 0, 0 ) ) sc.writeTransform( IECore.M44dData( matrix ), 0.0 ) sc = sc.createChild( str( 3 ) ) - mesh = IECoreScene.MeshPrimitive.createBox(IECore.Box3f(IECore.V3f(0),IECore.V3f(1))) - mesh["Cd"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ IECore.V3f( 0, 0, 1 ) ] * 6 ) ) + mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) + mesh["Cd"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ imath.V3f( 0, 0, 1 ) ] * 6 ) ) sc.writeObject( mesh, 0.0 ) - matrix = IECore.M44d.createTranslated( IECore.V3d( 3, 0, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 3, 0, 0 ) ) sc.writeTransform( IECore.M44dData( matrix ), 0.0 ) return scene @@ -322,9 +323,9 @@ def testQuery( self ): def createSceneFile(): scene = IECoreScene.SceneCache( FnSceneShapeTest.__testFile, IECore.IndexedIO.OpenMode.Write ) sc = scene.createChild( str(1) ) - curves = IECoreScene.CurvesPrimitive.createBox(IECore.Box3f(IECore.V3f(0),IECore.V3f(1))) # 6 curves. + curves = IECoreScene.CurvesPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) # 6 curves. sc.writeObject( curves, 0.0 ) - matrix = IECore.M44d.createTranslated( IECore.V3d( 0, 0, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 0, 0, 0 ) ) sc.writeTransform( IECore.M44dData( matrix ), 0.0 ) createSceneFile() diff --git a/test/IECoreMaya/FromMayaCameraConverterTest.py b/test/IECoreMaya/FromMayaCameraConverterTest.py index 1174468ff2..73b049693f 100644 --- a/test/IECoreMaya/FromMayaCameraConverterTest.py +++ b/test/IECoreMaya/FromMayaCameraConverterTest.py @@ -34,6 +34,7 @@ import maya.cmds import maya.OpenMaya +import imath import IECore import IECoreScene @@ -74,11 +75,11 @@ def testPerspective( self ) : camera = IECoreMaya.FromMayaCameraConverter( "perspShape" ).convert() self.assertEqual( camera.getName(), "perspShape" ) - self.assertEqual( camera.getTransform().transform(), IECore.M44f( maya.cmds.getAttr( "persp.worldMatrix[0]" ) ) ) - self.assertEqual( camera.parameters()["resolution"].value, IECore.V2i( maya.cmds.getAttr( "defaultResolution.width" ), maya.cmds.getAttr( "defaultResolution.height" ) ) ) - self.assertEqual( camera.parameters()["clippingPlanes"].value, IECore.V2f( maya.cmds.getAttr( "perspShape.nearClipPlane" ), maya.cmds.getAttr( "perspShape.farClipPlane" ) ) ) + self.assertEqual( camera.getTransform().transform(), imath.M44f( *maya.cmds.getAttr( "persp.worldMatrix[0]" ) ) ) + self.assertEqual( camera.parameters()["resolution"].value, imath.V2i( maya.cmds.getAttr( "defaultResolution.width" ), maya.cmds.getAttr( "defaultResolution.height" ) ) ) + self.assertEqual( camera.parameters()["clippingPlanes"].value, imath.V2f( maya.cmds.getAttr( "perspShape.nearClipPlane" ), maya.cmds.getAttr( "perspShape.farClipPlane" ) ) ) self.assertEqual( camera.parameters()["projection"].value, "perspective" ) - self.assertEqual( camera.blindData()["maya"]["aperture"].value, IECore.V2f( maya.cmds.getAttr( "perspShape.horizontalFilmAperture" ), maya.cmds.getAttr( "perspShape.verticalFilmAperture" ) ) ) + self.assertEqual( camera.blindData()["maya"]["aperture"].value, imath.V2f( maya.cmds.getAttr( "perspShape.horizontalFilmAperture" ), maya.cmds.getAttr( "perspShape.verticalFilmAperture" ) ) ) sel = maya.OpenMaya.MSelectionList() sel.add( "perspShape" ) @@ -92,12 +93,12 @@ def testOrthographic( self ) : camera = IECoreMaya.FromMayaCameraConverter( "topShape" ).convert() self.assertEqual( camera.getName(), "topShape" ) - self.assertEqual( camera.getTransform().transform(), IECore.M44f( maya.cmds.getAttr( "top.worldMatrix[0]" ) ) ) - self.assertEqual( camera.parameters()["resolution"].value, IECore.V2i( maya.cmds.getAttr( "defaultResolution.width" ), maya.cmds.getAttr( "defaultResolution.height" ) ) ) - self.assertEqual( camera.parameters()["clippingPlanes"].value, IECore.V2f( maya.cmds.getAttr( "topShape.nearClipPlane" ), maya.cmds.getAttr( "topShape.farClipPlane" ) ) ) + self.assertEqual( camera.getTransform().transform(), imath.M44f( *maya.cmds.getAttr( "top.worldMatrix[0]" ) ) ) + self.assertEqual( camera.parameters()["resolution"].value, imath.V2i( maya.cmds.getAttr( "defaultResolution.width" ), maya.cmds.getAttr( "defaultResolution.height" ) ) ) + self.assertEqual( camera.parameters()["clippingPlanes"].value, imath.V2f( maya.cmds.getAttr( "topShape.nearClipPlane" ), maya.cmds.getAttr( "topShape.farClipPlane" ) ) ) self.assertEqual( camera.parameters()["projection"].value, "orthographic" ) - self.assertEqual( camera.parameters()["screenWindow"].value.max.x - camera.parameters()["screenWindow"].value.min.x, maya.cmds.getAttr( "topShape.orthographicWidth" ) ) - self.assertEqual( camera.blindData()["maya"]["aperture"].value, IECore.V2f( maya.cmds.getAttr( "topShape.horizontalFilmAperture" ), maya.cmds.getAttr( "topShape.verticalFilmAperture" ) ) ) + self.assertEqual( camera.parameters()["screenWindow"].value.max().x - camera.parameters()["screenWindow"].value.min().x, maya.cmds.getAttr( "topShape.orthographicWidth" ) ) + self.assertEqual( camera.blindData()["maya"]["aperture"].value, imath.V2f( maya.cmds.getAttr( "topShape.horizontalFilmAperture" ), maya.cmds.getAttr( "topShape.verticalFilmAperture" ) ) ) def testCustomResolution( self ) : @@ -107,11 +108,11 @@ def testCustomResolution( self ) : camera = converter.convert() self.assertEqual( camera.getName(), "perspShape" ) - self.assertEqual( camera.getTransform().transform(), IECore.M44f( maya.cmds.getAttr( "persp.worldMatrix[0]" ) ) ) - self.assertEqual( camera.parameters()["resolution"].value, IECore.V2i( 1024, 778 ) ) - self.assertEqual( camera.parameters()["clippingPlanes"].value, IECore.V2f( maya.cmds.getAttr( "perspShape.nearClipPlane" ), maya.cmds.getAttr( "perspShape.farClipPlane" ) ) ) + self.assertEqual( camera.getTransform().transform(), imath.M44f( *maya.cmds.getAttr( "persp.worldMatrix[0]" ) ) ) + self.assertEqual( camera.parameters()["resolution"].value, imath.V2i( 1024, 778 ) ) + self.assertEqual( camera.parameters()["clippingPlanes"].value, imath.V2f( maya.cmds.getAttr( "perspShape.nearClipPlane" ), maya.cmds.getAttr( "perspShape.farClipPlane" ) ) ) self.assertEqual( camera.parameters()["projection"].value, "perspective" ) - self.assertEqual( camera.blindData()["maya"]["aperture"].value, IECore.V2f( maya.cmds.getAttr( "perspShape.horizontalFilmAperture" ), maya.cmds.getAttr( "perspShape.verticalFilmAperture" ) ) ) + self.assertEqual( camera.blindData()["maya"]["aperture"].value, imath.V2f( maya.cmds.getAttr( "perspShape.horizontalFilmAperture" ), maya.cmds.getAttr( "perspShape.verticalFilmAperture" ) ) ) sel = maya.OpenMaya.MSelectionList() sel.add( "perspShape" ) @@ -125,13 +126,13 @@ def testPixelAspectRatio( self ) : def verify( camera, resolution, pixelAspectRatio, expectedScreenWindow ) : self.assertEqual( camera.getName(), "perspShape" ) - self.assertEqual( camera.getTransform().transform(), IECore.M44f( maya.cmds.getAttr( "persp.worldMatrix[0]" ) ) ) + self.assertEqual( camera.getTransform().transform(), imath.M44f( *maya.cmds.getAttr( "persp.worldMatrix[0]" ) ) ) self.assertEqual( camera.parameters()["resolution"].value, resolution ) - self.assertEqual( camera.parameters()["clippingPlanes"].value, IECore.V2f( maya.cmds.getAttr( "perspShape.nearClipPlane" ), maya.cmds.getAttr( "perspShape.farClipPlane" ) ) ) + self.assertEqual( camera.parameters()["clippingPlanes"].value, imath.V2f( maya.cmds.getAttr( "perspShape.nearClipPlane" ), maya.cmds.getAttr( "perspShape.farClipPlane" ) ) ) self.assertEqual( camera.parameters()["projection"].value, "perspective" ) - self.assertTrue( camera.parameters()["screenWindow"].value.min.equalWithAbsError( expectedScreenWindow.min, 1e-6 ) ) - self.assertTrue( camera.parameters()["screenWindow"].value.max.equalWithAbsError( expectedScreenWindow.max, 1e-6 ) ) - self.assertEqual( camera.blindData()["maya"]["aperture"].value, IECore.V2f( maya.cmds.getAttr( "perspShape.horizontalFilmAperture" ), maya.cmds.getAttr( "perspShape.verticalFilmAperture" ) ) ) + self.assertTrue( camera.parameters()["screenWindow"].value.min().equalWithAbsError( expectedScreenWindow.min(), 1e-6 ) ) + self.assertTrue( camera.parameters()["screenWindow"].value.max().equalWithAbsError( expectedScreenWindow.max(), 1e-6 ) ) + self.assertEqual( camera.blindData()["maya"]["aperture"].value, imath.V2f( maya.cmds.getAttr( "perspShape.horizontalFilmAperture" ), maya.cmds.getAttr( "perspShape.verticalFilmAperture" ) ) ) sel = maya.OpenMaya.MSelectionList() sel.add( "perspShape" ) @@ -154,27 +155,27 @@ def setGlobalPixelAspectRatio( pixelAspectRatio ) : maya.cmds.setAttr( "defaultResolution.lockDeviceAspectRatio", 0 ) maya.cmds.setAttr( "defaultResolution.pixelAspect", pixelAspectRatio ) - globalRes = IECore.V2i( maya.cmds.getAttr( "defaultResolution.width" ), maya.cmds.getAttr( "defaultResolution.height" ) ) - self.assertEqual( globalRes, IECore.V2i( 960, 540 ) ) - globalScreenWindow = IECore.Box2f( IECore.V2f( -1, -0.5625 ), IECore.V2f( 1, 0.5625 ) ) + globalRes = imath.V2i( maya.cmds.getAttr( "defaultResolution.width" ), maya.cmds.getAttr( "defaultResolution.height" ) ) + self.assertEqual( globalRes, imath.V2i( 960, 540 ) ) + globalScreenWindow = imath.Box2f( imath.V2f( -1, -0.5625 ), imath.V2f( 1, 0.5625 ) ) setGlobalPixelAspectRatio( 1 ) verify( converter.convert(), resolution = globalRes, pixelAspectRatio = 1, expectedScreenWindow = globalScreenWindow ) setGlobalPixelAspectRatio( 2 ) - verify( converter.convert(), resolution = globalRes, pixelAspectRatio = 2, expectedScreenWindow = IECore.Box2f( globalScreenWindow.min / IECore.V2f( 1, 2 ), globalScreenWindow.max / IECore.V2f( 1, 2 ) ) ) + verify( converter.convert(), resolution = globalRes, pixelAspectRatio = 2, expectedScreenWindow = imath.Box2f( globalScreenWindow.min() / imath.V2f( 1, 2 ), globalScreenWindow.max() / imath.V2f( 1, 2 ) ) ) setGlobalPixelAspectRatio( 3 ) - verify( converter.convert(), resolution = globalRes, pixelAspectRatio = 3, expectedScreenWindow = IECore.Box2f( globalScreenWindow.min / IECore.V2f( 1, 3 ), globalScreenWindow.max / IECore.V2f( 1, 3 ) ) ) + verify( converter.convert(), resolution = globalRes, pixelAspectRatio = 3, expectedScreenWindow = imath.Box2f( globalScreenWindow.min() / imath.V2f( 1, 3 ), globalScreenWindow.max() / imath.V2f( 1, 3 ) ) ) # from the parameters - customRes = IECore.V2i( 1024, 778 ) - customScreenWindow = IECore.Box2f( IECore.V2f( -1, -0.759765 ), IECore.V2f( 1, 0.759765 ) ) + customRes = imath.V2i( 1024, 778 ) + customScreenWindow = imath.Box2f( imath.V2f( -1, -0.759765 ), imath.V2f( 1, 0.759765 ) ) converter.parameters()["resolutionMode"].setValue( "specified" ) converter.parameters()["resolution"].setTypedValue( customRes ) converter.parameters()["pixelAspectRatio"].setTypedValue( 1 ) verify( converter.convert(), resolution = customRes, pixelAspectRatio = 1, expectedScreenWindow = customScreenWindow ) converter.parameters()["pixelAspectRatio"].setTypedValue( 2 ) - verify( converter.convert(), resolution = customRes, pixelAspectRatio = 2, expectedScreenWindow = IECore.Box2f( customScreenWindow.min / IECore.V2f( 1, 2 ), customScreenWindow.max / IECore.V2f( 1, 2 ) ) ) + verify( converter.convert(), resolution = customRes, pixelAspectRatio = 2, expectedScreenWindow = imath.Box2f( customScreenWindow.min() / imath.V2f( 1, 2 ), customScreenWindow.max() / imath.V2f( 1, 2 ) ) ) converter.parameters()["pixelAspectRatio"].setTypedValue( 3 ) - verify( converter.convert(), resolution = customRes, pixelAspectRatio = 3, expectedScreenWindow = IECore.Box2f( customScreenWindow.min / IECore.V2f( 1, 3 ), customScreenWindow.max / IECore.V2f( 1, 3 ) ) ) + verify( converter.convert(), resolution = customRes, pixelAspectRatio = 3, expectedScreenWindow = imath.Box2f( customScreenWindow.min() / imath.V2f( 1, 3 ), customScreenWindow.max() / imath.V2f( 1, 3 ) ) ) def testFilmOffset( self ) : @@ -187,11 +188,11 @@ def testFilmOffset( self ) : camera = IECoreMaya.FromMayaCameraConverter( "perspShape" ).convert() self.assertEqual( camera.getName(), "perspShape" ) - self.assertEqual( camera.getTransform().transform(), IECore.M44f( maya.cmds.getAttr( "persp.worldMatrix[0]" ) ) ) - self.assertEqual( camera.parameters()["resolution"].value, IECore.V2i( maya.cmds.getAttr( "defaultResolution.width" ), maya.cmds.getAttr( "defaultResolution.height" ) ) ) - self.assertEqual( camera.parameters()["clippingPlanes"].value, IECore.V2f( maya.cmds.getAttr( "perspShape.nearClipPlane" ), maya.cmds.getAttr( "perspShape.farClipPlane" ) ) ) + self.assertEqual( camera.getTransform().transform(), imath.M44f( *maya.cmds.getAttr( "persp.worldMatrix[0]" ) ) ) + self.assertEqual( camera.parameters()["resolution"].value, imath.V2i( maya.cmds.getAttr( "defaultResolution.width" ), maya.cmds.getAttr( "defaultResolution.height" ) ) ) + self.assertEqual( camera.parameters()["clippingPlanes"].value, imath.V2f( maya.cmds.getAttr( "perspShape.nearClipPlane" ), maya.cmds.getAttr( "perspShape.farClipPlane" ) ) ) self.assertEqual( camera.parameters()["projection"].value, "perspective" ) - self.assertEqual( camera.blindData()["maya"]["aperture"].value, IECore.V2f( maya.cmds.getAttr( "perspShape.horizontalFilmAperture" ), maya.cmds.getAttr( "perspShape.verticalFilmAperture" ) ) ) + self.assertEqual( camera.blindData()["maya"]["aperture"].value, imath.V2f( maya.cmds.getAttr( "perspShape.horizontalFilmAperture" ), maya.cmds.getAttr( "perspShape.verticalFilmAperture" ) ) ) sel = maya.OpenMaya.MSelectionList() sel.add( "perspShape" ) diff --git a/test/IECoreMaya/FromMayaConverterTest.py b/test/IECoreMaya/FromMayaConverterTest.py index bdf1791033..617d4b4e64 100644 --- a/test/IECoreMaya/FromMayaConverterTest.py +++ b/test/IECoreMaya/FromMayaConverterTest.py @@ -33,6 +33,7 @@ ########################################################################## import maya.cmds +import imath import IECore import IECoreScene @@ -86,7 +87,7 @@ def testTransformationMatrixConverter( self ): self.assert_( converter ) transform = converter.convert() self.assert_( transform.isInstanceOf( IECore.TransformationMatrixfData.staticTypeId() ) ) - self.assertAlmostEqual( (transform.value.rotate - IECore.Eulerf( -1000, 30, 100 )).length(), 0, 2 ) + self.assertAlmostEqual( (transform.value.rotate - imath.Eulerf( -1000, 30, 100 )).length(), 0, 2 ) if __name__ == "__main__": IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/FromMayaCurveConverterTest.py b/test/IECoreMaya/FromMayaCurveConverterTest.py index f61eb6bfb8..9e01dc8265 100644 --- a/test/IECoreMaya/FromMayaCurveConverterTest.py +++ b/test/IECoreMaya/FromMayaCurveConverterTest.py @@ -33,6 +33,7 @@ ########################################################################## import maya.cmds +import imath import IECore import IECoreScene @@ -169,11 +170,21 @@ def testSpaces( self ) : self.assertEqual( converter["space"].getNumericValue(), IECoreMaya.FromMayaCurveConverter.Space.Object ) c = converter.convert() - self.assert_( IECore.Box3f( IECore.V3f( -1.1, -1.01, -0.01 ), IECore.V3f( 0.01, 1.01, 0.01 ) ).contains( c.bound() ) ) + self.assertTrue( + IECore.BoxAlgo.contains( + imath.Box3f( imath.V3f( -1.1, -1.01, -0.01 ), imath.V3f( 0.01, 1.01, 0.01 ) ), + c.bound() + ) + ) converter["space"].setNumericValue( IECoreMaya.FromMayaCurveConverter.Space.World ) c = converter.convert() - self.assert_( IECore.Box3f( IECore.V3f( -0.1, 0.99, 2.99 ), IECore.V3f( 1.01, 3.01, 3.01 ) ).contains( c.bound() ) ) + self.assertTrue( + IECore.BoxAlgo.contains( + imath.Box3f( imath.V3f( -0.1, 0.99, 2.99 ), imath.V3f( 1.01, 3.01, 3.01 ) ), + c.bound() + ) + ) def testCubicCircleAsLinear( self ) : @@ -244,7 +255,12 @@ def testConvertFromPlug( self ) : converter["space"].setNumericValue( IECoreMaya.FromMayaShapeConverter.Space.World ) curve = converter.convert() self.assertEqual( curve["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) - self.assert_( IECore.Box3f( IECore.V3f( -1.11 ) + IECore.V3f( 1, 2, 3 ), IECore.V3f( 1.11 ) + IECore.V3f( 1, 2, 3 ) ).contains( curve.bound() ) ) + self.assertTrue( + IECore.BoxAlgo.contains( + imath.Box3f( imath.V3f( -1.11 ) + imath.V3f( 1, 2, 3 ), imath.V3f( 1.11 ) + imath.V3f( 1, 2, 3 ) ), + curve.bound() + ) + ) if __name__ == "__main__": IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/FromMayaGroupConverterTest.py b/test/IECoreMaya/FromMayaGroupConverterTest.py index a1c30b4e2d..875e08d9ad 100644 --- a/test/IECoreMaya/FromMayaGroupConverterTest.py +++ b/test/IECoreMaya/FromMayaGroupConverterTest.py @@ -33,6 +33,7 @@ ########################################################################## import maya.cmds +import imath import IECore import IECoreScene @@ -57,7 +58,7 @@ def testConversion( self ) : converted = converter.convert() self.assert_( converted.isInstanceOf( IECoreScene.Group.staticTypeId() ) ) - self.assertEqual( converted.getTransform().transform(), IECore.M44f.createTranslated( IECore.V3f( 1, 2, 3 ) ) ) + self.assertEqual( converted.getTransform().transform(), imath.M44f().translate( imath.V3f( 1, 2, 3 ) ) ) self.assertEqual( len( converted.children() ), 1 ) convertedCube = converted.children()[0] diff --git a/test/IECoreMaya/FromMayaLocatorConverterTest.py b/test/IECoreMaya/FromMayaLocatorConverterTest.py index 49630da410..5f59fecc15 100644 --- a/test/IECoreMaya/FromMayaLocatorConverterTest.py +++ b/test/IECoreMaya/FromMayaLocatorConverterTest.py @@ -34,6 +34,7 @@ import maya.cmds import maya.OpenMaya +import imath import IECore import IECoreScene @@ -75,11 +76,12 @@ def test( self ) : self.assertEqual( locator.getName(), "myLocator" ) m = locator.getTransform().transform() - (s,h,r,t) = m.extractSHRT() - self.assertEqual( s, IECore.V3f(1,2,3) ) - self.assertEqual( t, IECore.V3f(10,20,30) ) - self.assertEqual( r, IECore.V3f(0,0,0) ) - self.assertEqual( h, IECore.V3f(0,0,0) ) + s, h, r, t = imath.V3f(), imath.V3f(), imath.V3f(), imath.V3f() + m.extractSHRT( s, h, r, t ) + self.assertEqual( s, imath.V3f(1,2,3) ) + self.assertEqual( t, imath.V3f(10,20,30) ) + self.assertEqual( r, imath.V3f(0,0,0) ) + self.assertEqual( h, imath.V3f(0,0,0) ) def testConstructor( self ) : diff --git a/test/IECoreMaya/FromMayaMeshConverterTest.py b/test/IECoreMaya/FromMayaMeshConverterTest.py index bf0cad0a4f..70124ceef0 100644 --- a/test/IECoreMaya/FromMayaMeshConverterTest.py +++ b/test/IECoreMaya/FromMayaMeshConverterTest.py @@ -35,6 +35,7 @@ import os.path import maya.cmds import maya.OpenMaya as OpenMaya +import imath import IECore import IECoreScene @@ -140,8 +141,8 @@ def testSphere( self ) : self.assertEqual( m["N"].data.getInterpretation(), IECore.GeometricData.Interpretation.Normal ) self.assertEqual( m["uv"].data.getInterpretation(), IECore.GeometricData.Interpretation.UV ) - self.assert_( IECore.Box3f( IECore.V3f( -1.0001 ), IECore.V3f( 1.0001 ) ).contains( m.bound() ) ) - self.assert_( m.bound().contains( IECore.Box3f( IECore.V3f( -0.90 ), IECore.V3f( 0.90 ) ) ) ) + self.assertTrue( IECore.BoxAlgo.contains( imath.Box3f( imath.V3f( -1.0001 ), imath.V3f( 1.0001 ) ), m.bound() ) ) + self.assertTrue( IECore.BoxAlgo.contains( m.bound(), imath.Box3f( imath.V3f( -0.90 ), imath.V3f( 0.90 ) ) ) ) def testSpaces( self ) : @@ -153,11 +154,11 @@ def testSpaces( self ) : self.assertEqual( converter["space"].getNumericValue(), IECoreMaya.FromMayaCurveConverter.Space.Object ) m = converter.convert() - self.assert_( IECore.Box3f( IECore.V3f( -1.0001 ), IECore.V3f( 1.0001 ) ).contains( m.bound() ) ) + self.assertTrue( IECore.BoxAlgo.contains( imath.Box3f( imath.V3f( -1.0001 ), imath.V3f( 1.0001 ) ), m.bound() ) ) converter["space"].setNumericValue( IECoreMaya.FromMayaShapeConverter.Space.World ) m = converter.convert() - self.assert_( IECore.Box3f( IECore.V3f( -1.0001 ) + IECore.V3f( 1, 2, 3 ), IECore.V3f( 1.0001 ) + IECore.V3f( 1, 2, 3 ) ).contains( m.bound() ) ) + self.assertTrue( imath.Box3f( imath.V3f( -1.0001 ) + imath.V3f( 1, 2, 3 ), imath.V3f( 1.0001 ) + imath.V3f( 1, 2, 3 ) ), m.bound() ) def testNormalsOnlyWhenLinear( self ) : @@ -191,7 +192,7 @@ def testWindingOrder( self ) : self.assertEqual( vertexIds.size(), 4 ) loop = IECore.V3fVectorData( [ p[vertexIds[0]], p[vertexIds[1]], p[vertexIds[2]], p[vertexIds[3]] ] ) - self.assert_( IECore.polygonNormal( loop ).equalWithAbsError( IECore.V3f( 0, 1, 0 ), 0.0001 ) ) + self.assert_( IECore.polygonNormal( loop ).equalWithAbsError( imath.V3f( 0, 1, 0 ), 0.0001 ) ) def testBlindData( self ) : @@ -223,7 +224,7 @@ def testPrimVars( self ) : self.assertEqual( set( m.keys() ), set( [ "P", "N", "uv", "Double", "DoubleArray" ] ) ) self.assertEqual( m["uv"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.FaceVarying ) - self.assertEqual( m["uv"].data, IECore.V2fVectorData( [ IECore.V2f( 0, 0 ), IECore.V2f( 1, 0 ), IECore.V2f( 0, 1 ), IECore.V2f( 1, 1 ) ], IECore.GeometricData.Interpretation.UV ) ) + self.assertEqual( m["uv"].data, IECore.V2fVectorData( [ imath.V2f( 0, 0 ), imath.V2f( 1, 0 ), imath.V2f( 0, 1 ), imath.V2f( 1, 1 ) ], IECore.GeometricData.Interpretation.UV ) ) self.assertEqual( m["uv"].indices, IECore.IntVectorData( [ 0, 1, 3, 2 ] ) ) self.assertEqual( m["Double"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant ) self.assertEqual( m["Double"].data, IECore.FloatData( 1 ) ) @@ -242,7 +243,7 @@ def testConvertFromPlug( self ) : m = converter.convert() self.assertEqual( m["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) self.assertEqual( m["N"].data.getInterpretation(), IECore.GeometricData.Interpretation.Normal ) - self.assert_( IECore.Box3f( IECore.V3f( -1.0001 ) + IECore.V3f( 1, 2, 3 ), IECore.V3f( 1.0001 ) + IECore.V3f( 1, 2, 3 ) ).contains( m.bound() ) ) + self.assertTrue( IECore.BoxAlgo.contains( imath.Box3f( imath.V3f( -1.0001 ) + imath.V3f( 1, 2, 3 ), imath.V3f( 1.0001 ) + imath.V3f( 1, 2, 3 ) ), m.bound() ) ) def testSharedUVIndices( self ) : @@ -341,7 +342,7 @@ def testColors( self ): converter = IECoreMaya.FromMayaShapeConverter.create( mesh, IECoreScene.MeshPrimitive.staticTypeId() ) converter['colors'] = True m = converter.convert() - self.assertEqual( m['Cs'].data, IECore.Color3fVectorData( [ IECore.Color3f(0), IECore.Color3f(1), IECore.Color3f(0.8), IECore.Color3f(0.5) ] ) ) + self.assertEqual( m['Cs'].data, IECore.Color3fVectorData( [ imath.Color3f(0), imath.Color3f(1), imath.Color3f(0.8), imath.Color3f(0.5) ] ) ) # test rgba to rgb conversion maya.cmds.file( os.path.dirname( __file__ ) + "/scenes/colouredPlane.ma", force = True, open = True ) @@ -354,7 +355,7 @@ def testColors( self ): converter = IECoreMaya.FromMayaShapeConverter.create( mesh, IECoreScene.MeshPrimitive.staticTypeId() ) converter['colors'] = True m = converter.convert() - self.assertEqual( m['Cs'].data, IECore.Color3fVectorData( [ IECore.Color3f( 1, 1, 0 ), IECore.Color3f( 1, 1, 1 ), IECore.Color3f( 0, 1, 1 ), IECore.Color3f( 0, 1, 0 ) ] ) ) + self.assertEqual( m['Cs'].data, IECore.Color3fVectorData( [ imath.Color3f( 1, 1, 0 ), imath.Color3f( 1, 1, 1 ), imath.Color3f( 0, 1, 1 ), imath.Color3f( 0, 1, 0 ) ] ) ) def testExtraColors( self ): @@ -365,8 +366,8 @@ def testExtraColors( self ): converter['extraColors'] = True m = converter.convert() self.assertEqual( m['cAlpha_Cs'].data, IECore.FloatVectorData( [ 0, 1, 0.8, 0.5 ] ) ) - self.assertEqual( m['cRGB_Cs'].data, IECore.Color3fVectorData( [ IECore.Color3f(1,0,0), IECore.Color3f(0), IECore.Color3f(0,0,1), IECore.Color3f(0,1,0) ] ) ) - self.assertEqual( m['cRGBA_Cs'].data, IECore.Color4fVectorData( [ IECore.Color4f( 1, 1, 0, 0.5 ), IECore.Color4f( 1, 1, 1, 1 ), IECore.Color4f( 0, 1, 1, 1 ), IECore.Color4f( 0, 1, 0, 0.5 ) ] ) ) + self.assertEqual( m['cRGB_Cs'].data, IECore.Color3fVectorData( [ imath.Color3f(1,0,0), imath.Color3f(0), imath.Color3f(0,0,1), imath.Color3f(0,1,0) ] ) ) + self.assertEqual( m['cRGBA_Cs'].data, IECore.Color4fVectorData( [ imath.Color4f( 1, 1, 0, 0.5 ), imath.Color4f( 1, 1, 1, 1 ), imath.Color4f( 0, 1, 1, 1 ), imath.Color4f( 0, 1, 0, 0.5 ) ] ) ) if __name__ == "__main__": IECoreMaya.TestProgram( plugins = [ "ieCore" ] ) diff --git a/test/IECoreMaya/FromMayaTransformConverterTest.py b/test/IECoreMaya/FromMayaTransformConverterTest.py index e93684f5c9..696ff5c0d4 100644 --- a/test/IECoreMaya/FromMayaTransformConverterTest.py +++ b/test/IECoreMaya/FromMayaTransformConverterTest.py @@ -33,6 +33,7 @@ ########################################################################## import maya.cmds +import imath import IECore import IECoreMaya @@ -50,43 +51,43 @@ def test( self ) : t = c.convert() self.assert_( t.isInstanceOf( IECore.TransformationMatrixdData.staticTypeId() ) ) - self.assertEqual( t.value.transform, IECore.M44d() ) + self.assertEqual( t.value.transform, imath.M44d() ) maya.cmds.xform( locatorTransform, translation=( 1, 2, 3 ) ) t = c.convert() self.assert_( t.isInstanceOf( IECore.TransformationMatrixdData.staticTypeId() ) ) - self.assertEqual( t.value.transform, IECore.M44d.createTranslated( IECore.V3d( 1, 2, 3 ) ) ) + self.assertEqual( t.value.transform, imath.M44d().translate( imath.V3d( 1, 2, 3 ) ) ) group = maya.cmds.group( locatorTransform ) t = c.convert() self.assert_( t.isInstanceOf( IECore.TransformationMatrixdData.staticTypeId() ) ) - self.assertEqual( t.value.transform, IECore.M44d.createTranslated( IECore.V3d( 1, 2, 3 ) ) ) + self.assertEqual( t.value.transform, imath.M44d().translate( imath.V3d( 1, 2, 3 ) ) ) maya.cmds.xform( group, translation=( 1, 0, 10 ) ) t = c.convert() self.assert_( t.isInstanceOf( IECore.TransformationMatrixdData.staticTypeId() ) ) - self.assertEqual( t.value.transform, IECore.M44d.createTranslated( IECore.V3d( 2, 2, 13 ) ) ) + self.assertEqual( t.value.transform, imath.M44d().translate( imath.V3d( 2, 2, 13 ) ) ) c["space"].setValue( "Local" ) t = c.convert() self.assert_( t.isInstanceOf( IECore.TransformationMatrixdData.staticTypeId() ) ) - self.assertEqual( t.value.transform, IECore.M44d.createTranslated( IECore.V3d( 1, 2, 3 ) ) ) + self.assertEqual( t.value.transform, imath.M44d().translate( imath.V3d( 1, 2, 3 ) ) ) # test custom space - customSpace = IECore.M44f() - customSpace.setScale( IECore.V3f( 0.5, 0.5, 0.5 ) ) + customSpace = imath.M44f() + customSpace.setScale( imath.V3f( 0.5, 0.5, 0.5 ) ) c["space"].setValue( "Custom" ) c["customSpace"].setValue( IECore.M44fData( customSpace ) ) t = c.convert() self.assert_( t.isInstanceOf( IECore.TransformationMatrixdData.staticTypeId() ) ) - expectedResult = IECore.M44d( 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 4, 4, 26, 1 ) + expectedResult = imath.M44d( 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 4, 4, 26, 1 ) self.assertEqual( t.value.transform, expectedResult ) # sanity check: if we apply the custom space to the result we should get the world space result - self.assertEqual( t.value.transform * IECore.M44d.createScaled( IECore.V3d( 0.5, 0.5, 0.5 ) ), IECore.M44d.createTranslated( IECore.V3d( 2, 2, 13 ) ) ) + self.assertEqual( t.value.transform * imath.M44d().scale( imath.V3d( 0.5, 0.5, 0.5 ) ), imath.M44d().translate( imath.V3d( 2, 2, 13 ) ) ) locatorShape = maya.cmds.listRelatives( locatorTransform, children=True )[0] @@ -94,13 +95,13 @@ def test( self ) : t = c.convert() self.assert_( t.isInstanceOf( IECore.TransformationMatrixdData.staticTypeId() ) ) - self.assertEqual( t.value.transform, IECore.M44d.createTranslated( IECore.V3d( 2, 2, 13 ) ) ) + self.assertEqual( t.value.transform, imath.M44d().translate( imath.V3d( 2, 2, 13 ) ) ) c["space"].setValue( "Local" ) t = c.convert() self.assert_( t.isInstanceOf( IECore.TransformationMatrixdData.staticTypeId() ) ) - self.assertEqual( t.value.transform, IECore.M44d() ) + self.assertEqual( t.value.transform, imath.M44d() ) if __name__ == "__main__": IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/GeometryCombinerTest.py b/test/IECoreMaya/GeometryCombinerTest.py index 9310d1411b..cbf4b55262 100644 --- a/test/IECoreMaya/GeometryCombinerTest.py +++ b/test/IECoreMaya/GeometryCombinerTest.py @@ -34,6 +34,7 @@ import os import maya.cmds +import imath import IECore import IECoreScene @@ -125,13 +126,22 @@ def testSpaces( self ) : self.assertEqual( maya.cmds.getAttr( combiner + ".conversionSpace" ), IECoreMaya.FromMayaShapeConverter.Space.World.real ) combined = IECoreMaya.FromMayaPlugConverter.create( combiner + ".outputGroup" ).convert() - self.assert_( IECore.Box3f( IECore.V3f( -1.0001 ) + IECore.V3f( 1, 2, 3 ), IECore.V3f( 1.0001 ) + IECore.V3f( 1, 2, 3 ) ).contains( combined.bound() ) ) + self.assertTrue( + IECore.BoxAlgo.contains( + imath.Box3f( imath.V3f( -1.0001 ) + imath.V3f( 1, 2, 3 ), imath.V3f( 1.0001 ) + imath.V3f( 1, 2, 3 ) ), + combined.bound() + ) + ) maya.cmds.setAttr( combiner + ".conversionSpace", IECoreMaya.FromMayaShapeConverter.Space.Object.real ) combined = IECoreMaya.FromMayaPlugConverter.create( combiner + ".outputGroup" ).convert() - self.assert_( IECore.Box3f( IECore.V3f( -1.0001 ), IECore.V3f( 1.0001 ) ).contains( combined.bound() ) ) - + self.assertTrue( + IECore.BoxAlgo.contains( + imath.Box3f( imath.V3f( -1.0001 ), imath.V3f( 1.0001 ) ), + combined.bound() + ) + ) if __name__ == "__main__": IECoreMaya.TestProgram() diff --git a/test/IECoreMaya/LiveSceneTest.py b/test/IECoreMaya/LiveSceneTest.py index b662b7f1e0..36c9f74a04 100644 --- a/test/IECoreMaya/LiveSceneTest.py +++ b/test/IECoreMaya/LiveSceneTest.py @@ -34,6 +34,7 @@ import maya.cmds import maya.OpenMaya as OpenMaya +import imath import IECore import IECoreScene @@ -275,13 +276,13 @@ def testAnimatedTransform( self ) : maya.cmds.currentTime( "1sec" ) transform1 = transformChild.readTransform( 1 ).value - self.assertEqual( transform0.translate, IECore.V3d( 1, 2, 3 ) ) + self.assertEqual( transform0.translate, imath.V3d( 1, 2, 3 ) ) self.assertAlmostEqual( transform0_5.translate.x, 2.5, 5 ) self.assertAlmostEqual( transform0_5.translate.y, 3.5, 5 ) self.assertAlmostEqual( transform0_5.translate.z, 4.5, 5 ) - self.assertEqual( transform1.translate, IECore.V3d( 4, 5, 6 ) ) + self.assertEqual( transform1.translate, imath.V3d( 4, 5, 6 ) ) def testDeletedDagPath( self ) : @@ -337,14 +338,14 @@ def testReadMesh( self ) : self.assertEqual( len( vertList ), 8 ) # check it's got the right verts: - self.assertEqual( vertList.count( IECore.V3f( -0.5, -0.5, 0.5 ) ), 1 ) - self.assertEqual( vertList.count( IECore.V3f( 0.5, -0.5, 0.5 ) ), 1 ) - self.assertEqual( vertList.count( IECore.V3f( -0.5, 0.5, 0.5 ) ), 1 ) - self.assertEqual( vertList.count( IECore.V3f( 0.5, 0.5, 0.5 ) ), 1 ) - self.assertEqual( vertList.count( IECore.V3f( -0.5, 0.5, -0.5 ) ), 1 ) - self.assertEqual( vertList.count( IECore.V3f( 0.5, 0.5, -0.5 ) ), 1 ) - self.assertEqual( vertList.count( IECore.V3f( -0.5, -0.5, -0.5 ) ), 1 ) - self.assertEqual( vertList.count( IECore.V3f( 0.5, -0.5, -0.5 ) ), 1 ) + self.assertEqual( vertList.count( imath.V3f( -0.5, -0.5, 0.5 ) ), 1 ) + self.assertEqual( vertList.count( imath.V3f( 0.5, -0.5, 0.5 ) ), 1 ) + self.assertEqual( vertList.count( imath.V3f( -0.5, 0.5, 0.5 ) ), 1 ) + self.assertEqual( vertList.count( imath.V3f( 0.5, 0.5, 0.5 ) ), 1 ) + self.assertEqual( vertList.count( imath.V3f( -0.5, 0.5, -0.5 ) ), 1 ) + self.assertEqual( vertList.count( imath.V3f( 0.5, 0.5, -0.5 ) ), 1 ) + self.assertEqual( vertList.count( imath.V3f( -0.5, -0.5, -0.5 ) ), 1 ) + self.assertEqual( vertList.count( imath.V3f( 0.5, -0.5, -0.5 ) ), 1 ) # check read primvars self.assertEqual( mesh["P"], cube.readObjectPrimitiveVariables( [ "P" ], 0 )["P"] ) @@ -405,25 +406,25 @@ def testReadBound( self ) : cube1Transform = scene.child( "pCube1" ) maya.cmds.currentTime( "0.0sec" ) - self.assertEqual( scene.readBound( 0.0 ), IECore.Box3d( IECore.V3d( -1.5, -1.5, -1.5 ), IECore.V3d( 3.5, 3.5, 3.5 ) ) ) + self.assertEqual( scene.readBound( 0.0 ), imath.Box3d( imath.V3d( -1.5, -1.5, -1.5 ), imath.V3d( 3.5, 3.5, 3.5 ) ) ) - self.assertEqual( cube4Transform.readBound( 0.0 ), IECore.Box3d( IECore.V3d( -0.5, -0.5, -0.5 ), IECore.V3d( 0.5, 0.5, 0.5 ) ) ) + self.assertEqual( cube4Transform.readBound( 0.0 ), imath.Box3d( imath.V3d( -0.5, -0.5, -0.5 ), imath.V3d( 0.5, 0.5, 0.5 ) ) ) # check it's including its children: - self.assertEqual( cube1Transform.readBound( 0.0 ), IECore.Box3d( IECore.V3d( -1.5, -1.5, -1.5 ), IECore.V3d( 1.5, 1.5, 1.5 ) ) ) + self.assertEqual( cube1Transform.readBound( 0.0 ), imath.Box3d( imath.V3d( -1.5, -1.5, -1.5 ), imath.V3d( 1.5, 1.5, 1.5 ) ) ) maya.cmds.setAttr( "pCube1.tx", 1 ) maya.cmds.setAttr( "pCube1.ty", 1 ) maya.cmds.setAttr( "pCube1.tz", 1 ) # should be in object space!!! - self.assertEqual( cube1Transform.readBound( 0.0 ), IECore.Box3d( IECore.V3d( -1.5, -1.5, -1.5 ), IECore.V3d( 1.5, 1.5, 1.5 ) ) ) + self.assertEqual( cube1Transform.readBound( 0.0 ), imath.Box3d( imath.V3d( -1.5, -1.5, -1.5 ), imath.V3d( 1.5, 1.5, 1.5 ) ) ) cube2Transform = cube1Transform.child( "pCube2" ) - self.assertEqual( cube2Transform.readBound( 0.0 ), IECore.Box3d( IECore.V3d( -0.5, -0.5, -0.5 ), IECore.V3d( 0.5, 0.5, 0.5 ) ) ) + self.assertEqual( cube2Transform.readBound( 0.0 ), imath.Box3d( imath.V3d( -0.5, -0.5, -0.5 ), imath.V3d( 0.5, 0.5, 0.5 ) ) ) cube3Transform = cube1Transform.child( "pCube3" ) - self.assertEqual( cube3Transform.readBound( 0.0 ), IECore.Box3d( IECore.V3d( -0.5, -0.5, -0.5 ), IECore.V3d( 0.5, 0.5, 0.5 ) ) ) + self.assertEqual( cube3Transform.readBound( 0.0 ), imath.Box3d( imath.V3d( -0.5, -0.5, -0.5 ), imath.V3d( 0.5, 0.5, 0.5 ) ) ) def testAnimatedMeshBound( self ) : @@ -444,11 +445,11 @@ def testAnimatedMeshBound( self ) : transformChild = scene.child( "pCube2" ) maya.cmds.currentTime( "0.0sec" ) - self.assertEqual( transformChild.readBound( 0.0 ), IECore.Box3d( IECore.V3d( -0.5, -0.5, -0.5 ), IECore.V3d( 0.5, 0.5, 0.5 ) ) ) + self.assertEqual( transformChild.readBound( 0.0 ), imath.Box3d( imath.V3d( -0.5, -0.5, -0.5 ), imath.V3d( 0.5, 0.5, 0.5 ) ) ) maya.cmds.currentTime( "0.5sec" ) - self.assertEqual( transformChild.readBound( 0.5 ), IECore.Box3d( IECore.V3d( -1.0, -0.5, -0.5 ), IECore.V3d( 0.5, 0.5, 0.5 ) ) ) + self.assertEqual( transformChild.readBound( 0.5 ), imath.Box3d( imath.V3d( -1.0, -0.5, -0.5 ), imath.V3d( 0.5, 0.5, 0.5 ) ) ) maya.cmds.currentTime( "1.0sec" ) - self.assertEqual( transformChild.readBound( 1.0 ), IECore.Box3d( IECore.V3d( -1.5, -0.5, -0.5 ), IECore.V3d( 0.5, 0.5, 0.5 ) ) ) + self.assertEqual( transformChild.readBound( 1.0 ), imath.Box3d( imath.V3d( -1.5, -0.5, -0.5 ), imath.V3d( 0.5, 0.5, 0.5 ) ) ) def testAnimatedBound( self ) : @@ -467,11 +468,11 @@ def testAnimatedBound( self ) : transformChild = scene.child( "pCube1Parent" ) maya.cmds.currentTime( "0.0sec" ) - self.assertEqual( transformChild.readBound( 0.0 ), IECore.Box3d( IECore.V3d( -0.5, -0.5, -0.5 ), IECore.V3d( 0.5, 0.5, 0.5 ) ) ) + self.assertEqual( transformChild.readBound( 0.0 ), imath.Box3d( imath.V3d( -0.5, -0.5, -0.5 ), imath.V3d( 0.5, 0.5, 0.5 ) ) ) maya.cmds.currentTime( "0.5sec" ) - self.assertEqual( transformChild.readBound( 0.5 ), IECore.Box3d( IECore.V3d( -1.0, -0.5, -0.5 ), IECore.V3d( 0.0, 0.5, 0.5 ) ) ) + self.assertEqual( transformChild.readBound( 0.5 ), imath.Box3d( imath.V3d( -1.0, -0.5, -0.5 ), imath.V3d( 0.0, 0.5, 0.5 ) ) ) maya.cmds.currentTime( "1.0sec" ) - self.assertEqual( transformChild.readBound( 1.0 ), IECore.Box3d( IECore.V3d( -1.5, -0.5, -0.5 ), IECore.V3d( -0.5, 0.5, 0.5 ) ) ) + self.assertEqual( transformChild.readBound( 1.0 ), imath.Box3d( imath.V3d( -1.5, -0.5, -0.5 ), imath.V3d( -0.5, 0.5, 0.5 ) ) ) def testCameraTransform( self ) : @@ -484,10 +485,10 @@ def testCameraTransform( self ) : camera = cameraTransform.readObject( 0 ) # sanity check: camera transform is not identity? - self.assertNotEqual( cameraTransform.readTransformAsMatrix( 0 ), IECore.M44f() ) + self.assertNotEqual( cameraTransform.readTransformAsMatrix( 0 ), imath.M44f() ) # this transform must be identity... - self.assertEqual( camera.getTransform().transform(), IECore.M44f() ) + self.assertEqual( camera.getTransform().transform(), imath.M44f() ) def testMeshChange( self ) : @@ -514,8 +515,8 @@ def testWriteExceptions( self ) : scene = IECoreMaya.LiveScene() - self.assertRaises( RuntimeError, IECore.curry( scene.writeBound, IECore.Box3d(), 0.0 ) ) - self.assertRaises( RuntimeError, IECore.curry( scene.writeTransform, IECore.M44dData( IECore.M44d() ), 0.0 ) ) + self.assertRaises( RuntimeError, IECore.curry( scene.writeBound, imath.Box3d(), 0.0 ) ) + self.assertRaises( RuntimeError, IECore.curry( scene.writeTransform, IECore.M44dData( imath.M44d() ), 0.0 ) ) self.assertRaises( RuntimeError, IECore.curry( scene.writeAttribute, "asdfs", IECore.BoolData( False ), 0.0 ) ) self.assertRaises( RuntimeError, IECore.curry( scene.writeObject, IECoreScene.SpherePrimitive(), 0.0 ) ) diff --git a/test/IECoreMaya/ParameterisedHolder.py b/test/IECoreMaya/ParameterisedHolder.py index 1062442675..b49c1f8894 100644 --- a/test/IECoreMaya/ParameterisedHolder.py +++ b/test/IECoreMaya/ParameterisedHolder.py @@ -38,6 +38,7 @@ import maya.cmds as cmds import maya.OpenMaya as OpenMaya +import imath import IECore import IECoreScene @@ -151,12 +152,12 @@ def __init__( self ) : h = IECoreMaya.FnParameterisedHolder( str(n) ) self.assert_( h ) - p = makeOp( IECore.Color3f( 0, 0, 0 ) ) + p = makeOp( imath.Color3f( 0, 0, 0 ) ) h.setParameterised( p ) dv = cmds.attributeQuery ( "parm_c", node = n, listDefault = True ) self.assertEqual( dv, [ 0, 0, 0 ] ) - p = makeOp( IECore.Color3f( 1, 1, 1 ) ) + p = makeOp( imath.Color3f( 1, 1, 1 ) ) h.setParameterised( p ) dv = cmds.attributeQuery ( "parm_c", node = n, listDefault = True ) self.assertEqual( dv, [ 1, 1, 1 ] ) @@ -283,7 +284,7 @@ def testMeshParameterIOProblem( self ) : fnOP = IECoreMaya.FnOpHolder.create( "merge", "meshMerge", 1 ) op = fnOP.getOp() - mesh = IECoreScene.MeshPrimitive.createBox( IECore.Box3f( IECore.V3f( -2, -2, -2 ), IECore.V3f( 2, 3, 4 ) ) ) + mesh = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( -2, -2, -2 ), imath.V3f( 2, 3, 4 ) ) ) op.parameters()["input"].setValue( mesh ) fnOP.setNodeValues() @@ -1814,7 +1815,7 @@ def testRemoveLockedChildAttributes( self ) : IECore.V3fParameter( "v", "d", - IECore.V3f( 0 ), + imath.V3f( 0 ), ) ) diff --git a/test/IECoreMaya/SceneShapeTest.py b/test/IECoreMaya/SceneShapeTest.py index 6d9ded5362..aa66d6841e 100644 --- a/test/IECoreMaya/SceneShapeTest.py +++ b/test/IECoreMaya/SceneShapeTest.py @@ -34,6 +34,7 @@ import os +import imath import IECore import IECoreScene import IECoreMaya @@ -51,27 +52,27 @@ def setUp( self ) : maya.cmds.file( new=True, f=True ) - def writeSCC( self, file, rotation=IECore.V3d( 0, 0, 0 ), time=0 ) : + def writeSCC( self, file, rotation=imath.V3d( 0, 0, 0 ), time=0 ) : scene = IECoreScene.SceneCache( file, IECore.IndexedIO.OpenMode.Write ) sc = scene.createChild( str( 1 ) ) - mesh = IECoreScene.MeshPrimitive.createBox(IECore.Box3f(IECore.V3f(0),IECore.V3f(1))) + mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) sc.writeObject( mesh, time ) - matrix = IECore.M44d.createTranslated( IECore.V3d( 1, 0, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 1, 0, 0 ) ) matrix = matrix.rotate( rotation ) sc.writeTransform( IECore.M44dData( matrix ), time ) sc = sc.createChild( str( 2 ) ) - mesh = IECoreScene.MeshPrimitive.createBox(IECore.Box3f(IECore.V3f(0),IECore.V3f(1))) + mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) sc.writeObject( mesh, time ) - matrix = IECore.M44d.createTranslated( IECore.V3d( 2, 0, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 2, 0, 0 ) ) matrix = matrix.rotate( rotation ) sc.writeTransform( IECore.M44dData( matrix ), time ) sc = sc.createChild( str( 3 ) ) - mesh = IECoreScene.MeshPrimitive.createBox(IECore.Box3f(IECore.V3f(0),IECore.V3f(1))) + mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) sc.writeObject( mesh, time ) - matrix = IECore.M44d.createTranslated( IECore.V3d( 3, 0, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 3, 0, 0 ) ) matrix = matrix.rotate( rotation ) sc.writeTransform( IECore.M44dData( matrix ), time ) @@ -83,18 +84,18 @@ def writeAnimSCC( self, file ) : sc1 = scene.child( str( 1 ) ) sc2 = sc1.child( str( 2 ) ) sc3 = sc2.child( str( 3 ) ) - mesh = IECoreScene.MeshPrimitive.createBox(IECore.Box3f(IECore.V3f(0),IECore.V3f(1))) + mesh = IECoreScene.MeshPrimitive.createBox(imath.Box3f(imath.V3f(0),imath.V3f(1))) for time in [ 0.5, 1, 1.5, 2, 5, 10 ] : - matrix = IECore.M44d.createTranslated( IECore.V3d( 1, time, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 1, time, 0 ) ) sc1.writeTransform( IECore.M44dData( matrix ), time ) sc2.writeObject( mesh, time ) - matrix = IECore.M44d.createTranslated( IECore.V3d( 2, time, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 2, time, 0 ) ) sc2.writeTransform( IECore.M44dData( matrix ), time ) - matrix = IECore.M44d.createTranslated( IECore.V3d( 3, time, 0 ) ) + matrix = imath.M44d().translate( imath.V3d( 3, time, 0 ) ) sc3.writeTransform( IECore.M44dData( matrix ), time ) return scene @@ -181,7 +182,7 @@ def testComputePlugs( self ) : def testPlugValues( self ) : - self.writeSCC( file=SceneShapeTest.__testPlugFile, rotation = IECore.V3d( 0, 0, IECore.degreesToRadians( -30 ) ) ) + self.writeSCC( file=SceneShapeTest.__testPlugFile, rotation = imath.V3d( 0, 0, IECore.degreesToRadians( -30 ) ) ) maya.cmds.file( new=True, f=True ) node = maya.cmds.createNode( 'ieSceneShape' ) diff --git a/test/IECoreMaya/SplineParameterHandlerTest.py b/test/IECoreMaya/SplineParameterHandlerTest.py index 64d9f40ddb..e9aa57c319 100644 --- a/test/IECoreMaya/SplineParameterHandlerTest.py +++ b/test/IECoreMaya/SplineParameterHandlerTest.py @@ -37,6 +37,7 @@ import unittest import maya.cmds +import imath import IECore import IECoreMaya @@ -81,10 +82,10 @@ def __init__( self ) : IECore.SplinefColor3f( IECore.CubicBasisf.catmullRom(), ( - ( 0, IECore.Color3f( 1, 1, 1 ) ), - ( 0, IECore.Color3f( 1, 1, 1 ) ), - ( 1, IECore.Color3f( 0, 0, 0 ) ), - ( 1, IECore.Color3f( 0, 0, 0 ) ), + ( 0, imath.Color3f( 1, 1, 1 ) ), + ( 0, imath.Color3f( 1, 1, 1 ) ), + ( 1, imath.Color3f( 0, 0, 0 ) ), + ( 1, imath.Color3f( 0, 0, 0 ) ), ), ), ), @@ -162,7 +163,7 @@ def testRoundTripColor( self ) : for j in range( 0, numPoints ) : - splinePoints.append( ( random.random(), IECore.Color3f( random.random(), random.random(), random.random() ) ) ) + splinePoints.append( ( random.random(), imath.Color3f( random.random(), random.random(), random.random() ) ) ) splinePoints.sort() @@ -197,8 +198,8 @@ def testRoundTripColor( self ) : c1 = data.value.values()[i] c2 = splineData.value.values()[i] - v1 = IECore.V3f( c1[0], c1[1], c1[2] ) - v2 = IECore.V3f( c2[0], c2[1], c2[2] ) + v1 = imath.V3f( c1[0], c1[1], c1[2] ) + v2 = imath.V3f( c2[0], c2[1], c2[2] ) self.assert_( ( v1 - v2 ).length() < 1.e-4 ) @@ -320,10 +321,10 @@ def testAddColorSplineToReferencedNode( self ) : IECore.SplinefColor3f( IECore.CubicBasisf.catmullRom(), ( - ( 0, IECore.Color3f( 1 ) ), - ( 0, IECore.Color3f( 1 ) ), - ( 1, IECore.Color3f( 0 ) ), - ( 1, IECore.Color3f( 0 ) ), + ( 0, imath.Color3f( 1 ) ), + ( 0, imath.Color3f( 1 ) ), + ( 1, imath.Color3f( 0 ) ), + ( 1, imath.Color3f( 0 ) ), ), ) ) @@ -347,10 +348,10 @@ def testAddColorSplineToReferencedNode( self ) : IECore.SplinefColor3f( IECore.CubicBasisf.catmullRom(), ( - ( 0, IECore.Color3f( 1 ) ), - ( 0, IECore.Color3f( 1 ) ), - ( 1, IECore.Color3f( 0 ) ), - ( 1, IECore.Color3f( 0 ) ), + ( 0, imath.Color3f( 1 ) ), + ( 0, imath.Color3f( 1 ) ), + ( 1, imath.Color3f( 0 ) ), + ( 1, imath.Color3f( 0 ) ), ), ) ) diff --git a/test/IECoreMaya/TemporaryAttributeValuesTest.py b/test/IECoreMaya/TemporaryAttributeValuesTest.py index 68d10ccc11..1cd3be64e8 100644 --- a/test/IECoreMaya/TemporaryAttributeValuesTest.py +++ b/test/IECoreMaya/TemporaryAttributeValuesTest.py @@ -37,6 +37,7 @@ import os import maya.cmds +import imath import IECore import IECoreMaya @@ -99,7 +100,7 @@ def test( self ) : s + ".floatTest" : 10, s + ".intTest" : 20, s + ".float2Test" : ( 1, 2 ), - s + ".int2Test" : IECore.V2i( 3, 4 ), + s + ".int2Test" : imath.V2i( 3, 4 ), s + ".float3Test" : ( 9, 6, 1 ), s + ".short3Test" : ( 500, 2, -1 ), s + ".stringTest" : "bye", diff --git a/test/IECoreMaya/ToMayaCameraConverterTest.py b/test/IECoreMaya/ToMayaCameraConverterTest.py index af23970e1d..90d027179e 100644 --- a/test/IECoreMaya/ToMayaCameraConverterTest.py +++ b/test/IECoreMaya/ToMayaCameraConverterTest.py @@ -33,6 +33,7 @@ ########################################################################## import maya.cmds +import imath import IECore import IECoreScene @@ -85,10 +86,10 @@ def assertIECoreCamsNotEqual( self, camA, camB ) : def assertIECoreCamAndMayaCamEqual( self, coreCam, mayaCam ) : - self.assertEqual( coreCam.getTransform().transform(), IECore.M44f( maya.cmds.getAttr( mayaCam+".worldMatrix[0]" ) ) ) - self.assertEqual( coreCam.parameters()["clippingPlanes"].value, IECore.V2f( maya.cmds.getAttr( mayaCam+".nearClipPlane" ), maya.cmds.getAttr( mayaCam+".farClipPlane" ) ) ) - self.assertEqual( coreCam.blindData()["maya"]["aperture"].value, IECore.V2f( maya.cmds.getAttr( mayaCam+".horizontalFilmAperture" ), maya.cmds.getAttr( mayaCam+".verticalFilmAperture" ) ) ) - self.assertEqual( coreCam.blindData()["maya"]["filmOffset"].value, IECore.V2f( maya.cmds.getAttr( mayaCam+".horizontalFilmOffset" ), maya.cmds.getAttr( mayaCam+".verticalFilmOffset" ) ) ) + self.assertEqual( coreCam.getTransform().transform(), imath.M44f( *maya.cmds.getAttr( mayaCam+".worldMatrix[0]" ) ) ) + self.assertEqual( coreCam.parameters()["clippingPlanes"].value, imath.V2f( maya.cmds.getAttr( mayaCam+".nearClipPlane" ), maya.cmds.getAttr( mayaCam+".farClipPlane" ) ) ) + self.assertEqual( coreCam.blindData()["maya"]["aperture"].value, imath.V2f( maya.cmds.getAttr( mayaCam+".horizontalFilmAperture" ), maya.cmds.getAttr( mayaCam+".verticalFilmAperture" ) ) ) + self.assertEqual( coreCam.blindData()["maya"]["filmOffset"].value, imath.V2f( maya.cmds.getAttr( mayaCam+".horizontalFilmOffset" ), maya.cmds.getAttr( mayaCam+".verticalFilmOffset" ) ) ) if coreCam.parameters()["projection"].value == "perspective" : self.assertFalse( maya.cmds.getAttr( mayaCam+".orthographic" ) ) @@ -100,7 +101,7 @@ def assertIECoreCamAndMayaCamEqual( self, coreCam, mayaCam ) : self.assertAlmostEqual( coreCam.parameters()["projection:fov"].value, IECore.radiansToDegrees( fn.horizontalFieldOfView() ), 5 ) else : self.assertTrue( maya.cmds.getAttr( mayaCam+".orthographic" ) ) - self.assertEqual( coreCam.parameters()["screenWindow"].value.max.x - coreCam.parameters()["screenWindow"].value.min.x, maya.cmds.getAttr( mayaCam+".orthographicWidth" ) ) + self.assertEqual( coreCam.parameters()["screenWindow"].value.max().x - coreCam.parameters()["screenWindow"].value.min().x, maya.cmds.getAttr( mayaCam+".orthographicWidth" ) ) def testExistingCam( self ) : diff --git a/test/IECoreMaya/ToMayaCurveConverterTest.py b/test/IECoreMaya/ToMayaCurveConverterTest.py index f99a936b9b..ac326d9ce4 100644 --- a/test/IECoreMaya/ToMayaCurveConverterTest.py +++ b/test/IECoreMaya/ToMayaCurveConverterTest.py @@ -34,6 +34,7 @@ import maya.cmds import maya.OpenMaya as OpenMaya +import imath import IECore import IECoreScene @@ -44,7 +45,7 @@ class ToMayaCurveConverterTest( IECoreMaya.TestCase ) : def testConstructor( self ) : i = IECore.IntVectorData( [ 8 ] ) - p = IECore.V3fVectorData( [ IECore.V3f( 0 ), IECore.V3f( 0 ), IECore.V3f( 0 ), IECore.V3f( 1 ), IECore.V3f( 2 ), IECore.V3f( 3 ), IECore.V3f( 3 ), IECore.V3f( 3 ) ] ) + p = IECore.V3fVectorData( [ imath.V3f( 0 ), imath.V3f( 0 ), imath.V3f( 0 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ), imath.V3f( 3 ), imath.V3f( 3 ) ] ) coreCurves = IECoreScene.CurvesPrimitive( i, IECore.CubicBasisf.bSpline(), False, p ) converter = IECoreMaya.ToMayaCurveConverter( coreCurves ) @@ -56,7 +57,7 @@ def testConversion( self ) : # open, cubic curve: i = IECore.IntVectorData( [ 8 ] ) - p = IECore.V3fVectorData( [ IECore.V3f( 0 ), IECore.V3f( 0 ), IECore.V3f( 0 ), IECore.V3f( 1 ), IECore.V3f( 2 ), IECore.V3f( 3 ), IECore.V3f( 3 ), IECore.V3f( 3 ) ] ) + p = IECore.V3fVectorData( [ imath.V3f( 0 ), imath.V3f( 0 ), imath.V3f( 0 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ), imath.V3f( 3 ), imath.V3f( 3 ) ] ) coreCurves = IECoreScene.CurvesPrimitive( i, IECore.CubicBasisf.bSpline(), False, p ) converter = IECoreMaya.ToMayaObjectConverter.create( coreCurves ) @@ -80,7 +81,7 @@ def testConversion( self ) : def testPeriodic( self ) : i = IECore.IntVectorData( [ 4 ] ) - p = IECore.V3fVectorData( [ IECore.V3f( 0, 0, 0 ), IECore.V3f( 0, 1, 0 ), IECore.V3f( 1, 1, 0 ), IECore.V3f( 1, 0, 0 ) ] ) + p = IECore.V3fVectorData( [ imath.V3f( 0, 0, 0 ), imath.V3f( 0, 1, 0 ), imath.V3f( 1, 1, 0 ), imath.V3f( 1, 0, 0 ) ] ) coreCurves = IECoreScene.CurvesPrimitive( i, IECore.CubicBasisf.bSpline(), True, p ) converter = IECoreMaya.ToMayaObjectConverter.create( coreCurves ) @@ -100,7 +101,7 @@ def testOpenLinear( self ) : # open, cubic curve: i = IECore.IntVectorData( [ 4 ] ) - p = IECore.V3fVectorData( [ IECore.V3f( 0 ), IECore.V3f( 1 ), IECore.V3f( 2 ), IECore.V3f( 3 ) ] ) + p = IECore.V3fVectorData( [ imath.V3f( 0 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ) ] ) coreCurves = IECoreScene.CurvesPrimitive( i, IECore.CubicBasisf.linear(), False, p ) converter = IECoreMaya.ToMayaObjectConverter.create( coreCurves ) @@ -120,7 +121,7 @@ def testOpenLinear( self ) : def testPeriodicLinear( self ) : i = IECore.IntVectorData( [ 4 ] ) - p = IECore.V3fVectorData( [ IECore.V3f( 0, 0, 0 ), IECore.V3f( 0, 1, 0 ), IECore.V3f( 1, 1, 0 ), IECore.V3f( 1, 0, 0 ) ] ) + p = IECore.V3fVectorData( [ imath.V3f( 0, 0, 0 ), imath.V3f( 0, 1, 0 ), imath.V3f( 1, 1, 0 ), imath.V3f( 1, 0, 0 ) ] ) coreCurves = IECoreScene.CurvesPrimitive( i, IECore.CubicBasisf.linear(), True, p ) converter = IECoreMaya.ToMayaObjectConverter.create( coreCurves ) @@ -139,10 +140,10 @@ def testPeriodicLinear( self ) : def testCurveIndex( self ): i = IECore.IntVectorData( [ 8, 9, 10, 11] ) - cvs = [ IECore.V3f( 0 ), IECore.V3f( 0 ), IECore.V3f( 0 ), IECore.V3f( 1 ), IECore.V3f( 2 ), IECore.V3f( 3 ), IECore.V3f( 3 ), IECore.V3f( 3 ) ] - cvs.extend([ IECore.V3f( 4 ), IECore.V3f( 4 ), IECore.V3f( 4 ), IECore.V3f( 5 ), IECore.V3f( 6 ), IECore.V3f( 7 ), IECore.V3f( 8 ), IECore.V3f( 8 ), IECore.V3f( 8 ) ]) - cvs.extend([ IECore.V3f( 9 ), IECore.V3f( 9 ), IECore.V3f( 9 ), IECore.V3f( 10 ), IECore.V3f( 11 ), IECore.V3f( 12 ), IECore.V3f( 13 ), IECore.V3f( 14 ), IECore.V3f( 14 ), IECore.V3f( 14 ) ]) - cvs.extend([ IECore.V3f( 15 ), IECore.V3f( 15 ), IECore.V3f( 15 ), IECore.V3f( 16 ), IECore.V3f( 17 ), IECore.V3f( 18 ), IECore.V3f( 19 ), IECore.V3f( 20 ), IECore.V3f( 21 ), IECore.V3f( 21 ), IECore.V3f( 21 ) ]) + cvs = [ imath.V3f( 0 ), imath.V3f( 0 ), imath.V3f( 0 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ), imath.V3f( 3 ), imath.V3f( 3 ) ] + cvs.extend([ imath.V3f( 4 ), imath.V3f( 4 ), imath.V3f( 4 ), imath.V3f( 5 ), imath.V3f( 6 ), imath.V3f( 7 ), imath.V3f( 8 ), imath.V3f( 8 ), imath.V3f( 8 ) ]) + cvs.extend([ imath.V3f( 9 ), imath.V3f( 9 ), imath.V3f( 9 ), imath.V3f( 10 ), imath.V3f( 11 ), imath.V3f( 12 ), imath.V3f( 13 ), imath.V3f( 14 ), imath.V3f( 14 ), imath.V3f( 14 ) ]) + cvs.extend([ imath.V3f( 15 ), imath.V3f( 15 ), imath.V3f( 15 ), imath.V3f( 16 ), imath.V3f( 17 ), imath.V3f( 18 ), imath.V3f( 19 ), imath.V3f( 20 ), imath.V3f( 21 ), imath.V3f( 21 ), imath.V3f( 21 ) ]) p = IECore.V3fVectorData( cvs ) coreCurves = IECoreScene.CurvesPrimitive( i, IECore.CubicBasisf.bSpline(), False, p ) @@ -183,7 +184,7 @@ def testCurveIndex( self ): def testWrongCubicCurve( self ): i = IECore.IntVectorData( [ 4 ] ) - p = IECore.V3fVectorData( [ IECore.V3f( 0 ), IECore.V3f( 1 ), IECore.V3f( 2 ), IECore.V3f( 3 ) ] ) + p = IECore.V3fVectorData( [ imath.V3f( 0 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ) ] ) coreCurves = IECoreScene.CurvesPrimitive( i, IECore.CubicBasisf.bSpline(), False, p ) converter = IECoreMaya.ToMayaObjectConverter.create( coreCurves ) @@ -194,7 +195,7 @@ def testToMayaAndBack( self ): # open, cubic curve: i = IECore.IntVectorData( [ 8 ] ) - p = IECore.V3fVectorData( [ IECore.V3f( 0 ), IECore.V3f( 0 ), IECore.V3f( 0 ), IECore.V3f( 1 ), IECore.V3f( 2 ), IECore.V3f( 3 ), IECore.V3f( 3 ), IECore.V3f( 3 ) ] ) + p = IECore.V3fVectorData( [ imath.V3f( 0 ), imath.V3f( 0 ), imath.V3f( 0 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ), imath.V3f( 3 ), imath.V3f( 3 ) ] ) coreCurves = IECoreScene.CurvesPrimitive( i, IECore.CubicBasisf.bSpline(), False, p ) converter = IECoreMaya.ToMayaObjectConverter.create( coreCurves ) diff --git a/test/IECoreMaya/ToMayaGroupConverterTest.py b/test/IECoreMaya/ToMayaGroupConverterTest.py index 0835ec05b5..0d219b1e5d 100644 --- a/test/IECoreMaya/ToMayaGroupConverterTest.py +++ b/test/IECoreMaya/ToMayaGroupConverterTest.py @@ -33,6 +33,7 @@ ########################################################################## import maya.cmds +import imath import IECore import IECoreScene @@ -43,16 +44,16 @@ class ToMayaGroupConverterTest( IECoreMaya.TestCase ) : def testConversion( self ) : g = IECoreScene.Group() - g.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createScaled( IECore.V3f( 2 ) ) ) ) + g.setTransform( IECoreScene.MatrixTransform( imath.M44f().scale( imath.V3f( 2 ) ) ) ) c1 = IECoreScene.Group() - c1.addChild( IECoreScene.MeshPrimitive.createBox( IECore.Box3f( IECore.V3f( -1 ), IECore.V3f( 1 ) ) ) ) - c1.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( 2, 0, 0 ) ) ) ) + c1.addChild( IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ) ) ) + c1.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 2, 0, 0 ) ) ) ) g.addChild( c1 ) c2 = IECoreScene.Group() - c2.addChild( IECoreScene.MeshPrimitive.createBox( IECore.Box3f( IECore.V3f( -1 ), IECore.V3f( 1 ) ) ) ) - c2.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( -2, 0, 0 ) ) ) ) + c2.addChild( IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ) ) ) + c2.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( -2, 0, 0 ) ) ) ) g.addChild( c2 ) p = maya.cmds.createNode( "transform" ) diff --git a/test/IECoreMaya/ToMayaLocatorConverterTest.py b/test/IECoreMaya/ToMayaLocatorConverterTest.py index fb6ec0bdaa..9328d48101 100644 --- a/test/IECoreMaya/ToMayaLocatorConverterTest.py +++ b/test/IECoreMaya/ToMayaLocatorConverterTest.py @@ -33,6 +33,7 @@ ########################################################################## import maya.cmds +import imath import IECore import IECoreScene @@ -52,7 +53,7 @@ def testFactory( self ) : def testNewLocator( self ) : - m = IECore.M44f.createScaled(IECore.V3f(1,2,3)) * IECore.M44f.createTranslated(IECore.V3f(10,20,30)) + m = imath.M44f().scale( imath.V3f(1,2,3) ) * imath.M44f().translate( imath.V3f(10,20,30) ) coordSys = IECoreScene.CoordinateSystem( "myNamedCoordSys", IECoreScene.MatrixTransform( m ) ) parent = maya.cmds.createNode( "transform" ) @@ -84,7 +85,7 @@ def testWrongIECoreObject( self ) : def testWrongMayaNode( self ) : maya.cmds.polySphere( name="pSphere" ) - coordSys = IECoreScene.CoordinateSystem( "myNamedCoordSys", IECoreScene.MatrixTransform( IECore.M44f() ) ) + coordSys = IECoreScene.CoordinateSystem( "myNamedCoordSys", IECoreScene.MatrixTransform( imath.M44f() ) ) converter = IECoreMaya.ToMayaLocatorConverter( coordSys ) messageHandler = IECore.CapturingMessageHandler() diff --git a/test/IECoreMaya/ToMayaMeshConverterTest.py b/test/IECoreMaya/ToMayaMeshConverterTest.py index b83ab411c0..402baf2564 100644 --- a/test/IECoreMaya/ToMayaMeshConverterTest.py +++ b/test/IECoreMaya/ToMayaMeshConverterTest.py @@ -36,6 +36,7 @@ import maya.cmds import maya.OpenMaya as OpenMaya +import imath import IECore import IECoreScene @@ -45,7 +46,7 @@ class ToMayaMeshConverterTest( IECoreMaya.TestCase ) : def testConversion( self ) : - coreMesh = IECoreScene.MeshPrimitive.createBox( IECore.Box3f( IECore.V3f( -10 ), IECore.V3f( 10 ) ) ) + coreMesh = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( -10 ), imath.V3f( 10 ) ) ) converter = IECoreMaya.ToMayaObjectConverter.create( coreMesh ) self.assert_( converter.isInstanceOf( IECoreMaya.ToMayaObjectConverter.staticTypeId() ) ) @@ -256,7 +257,7 @@ def testUVConversionFromMayaMesh( self ) : def testShadingGroup( self ) : - coreMesh = IECoreScene.MeshPrimitive.createBox( IECore.Box3f( IECore.V3f( -10 ), IECore.V3f( 10 ) ) ) + coreMesh = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( -10 ), imath.V3f( 10 ) ) ) converter = IECoreMaya.ToMayaObjectConverter.create( coreMesh ) transform = maya.cmds.createNode( "transform" ) converter.convert( transform ) @@ -266,7 +267,7 @@ def testShadingGroup( self ) : def testConstructor( self ) : - coreMesh = IECoreScene.MeshPrimitive.createBox( IECore.Box3f( IECore.V3f( -10 ), IECore.V3f( 10 ) ) ) + coreMesh = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( -10 ), imath.V3f( 10 ) ) ) converter = IECoreMaya.ToMayaMeshConverter( coreMesh ) transform = maya.cmds.createNode( "transform" ) @@ -317,7 +318,7 @@ def testSetMeshInterpolation( self ) : IECoreMaya.ToMayaMeshConverter.setMeshInterpolationAttribute( sphere ) self.assertEqual( maya.cmds.getAttr( sphere + ".ieMeshInterpolation" ), 0 ) - coreMesh = IECoreScene.MeshPrimitive.createBox( IECore.Box3f( IECore.V3f( -10 ), IECore.V3f( 10 ) ) ) + coreMesh = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( -10 ), imath.V3f( 10 ) ) ) coreMesh.interpolation = "catmullClark" converter = IECoreMaya.ToMayaObjectConverter.create( coreMesh ) transform = maya.cmds.createNode( "transform" ) diff --git a/test/IECoreMaya/ToMayaParticleConverterTest.py b/test/IECoreMaya/ToMayaParticleConverterTest.py index 6c9cb3b74d..a5c1910ce0 100644 --- a/test/IECoreMaya/ToMayaParticleConverterTest.py +++ b/test/IECoreMaya/ToMayaParticleConverterTest.py @@ -33,6 +33,7 @@ ########################################################################## import maya.cmds +import imath import IECore import IECoreScene @@ -42,13 +43,13 @@ class ToMayaParticleConverterTest( IECoreMaya.TestCase ) : def testFactory( self ) : - points = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ IECore.V3f( x ) for x in range( 0, 10 ) ] ) ) + points = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ imath.V3f( x ) for x in range( 0, 10 ) ] ) ) converter = IECoreMaya.ToMayaObjectConverter.create( points ) self.failUnless( isinstance( converter, IECoreMaya.ToMayaParticleConverter ) ) def testConversion( self ) : - points = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ IECore.V3f( x ) for x in range( 0, 10 ) ] ) ) + points = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ imath.V3f( x ) for x in range( 0, 10 ) ] ) ) parent = maya.cmds.createNode( "transform" ) IECoreMaya.ToMayaParticleConverter( points ).convert( parent ) @@ -69,8 +70,8 @@ def testConversion( self ) : def testConversionFromDoubles( self ) : points = IECoreScene.PointsPrimitive( 10 ) - points["P"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3dVectorData( [ IECore.V3d( x ) for x in range( 0, 10 ) ] ) ) - points["rgbPP"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3dVectorData( [ IECore.V3d( x ) for x in range( 10, 20 ) ] ) ) + points["P"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3dVectorData( [ imath.V3d( x ) for x in range( 0, 10 ) ] ) ) + points["rgbPP"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3dVectorData( [ imath.V3d( x ) for x in range( 10, 20 ) ] ) ) parent = maya.cmds.createNode( "transform" ) IECoreMaya.ToMayaParticleConverter( points ).convert( parent ) @@ -90,8 +91,8 @@ def testConversionFromDoubles( self ) : def testRGBPPConversion( self ) : - points = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ IECore.V3f( x ) for x in range( 0, 10 ) ] ) ) - points["rgbPP"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.Color3fVectorData( [ IECore.Color3f( x ) for x in range( 10, 20 ) ] ) ) + points = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ imath.V3f( x ) for x in range( 0, 10 ) ] ) ) + points["rgbPP"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.Color3fVectorData( [ imath.Color3f( x ) for x in range( 10, 20 ) ] ) ) parent = maya.cmds.createNode( "transform" ) IECoreMaya.ToMayaParticleConverter( points ).convert( parent ) @@ -108,8 +109,8 @@ def testRGBPPConversion( self ) : def testCsConversion( self ) : - points = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ IECore.V3f( x ) for x in range( 0, 10 ) ] ) ) - points["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.Color3fVectorData( [ IECore.Color3f( x ) for x in range( 10, 20 ) ] ) ) + points = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ imath.V3f( x ) for x in range( 0, 10 ) ] ) ) + points["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.Color3fVectorData( [ imath.Color3f( x ) for x in range( 10, 20 ) ] ) ) parent = maya.cmds.createNode( "transform" ) IECoreMaya.ToMayaParticleConverter( points ).convert( parent ) diff --git a/test/IECoreMaya/ToMayaSkinClusterConverterTest.py b/test/IECoreMaya/ToMayaSkinClusterConverterTest.py index 1833e2e167..82854de6be 100644 --- a/test/IECoreMaya/ToMayaSkinClusterConverterTest.py +++ b/test/IECoreMaya/ToMayaSkinClusterConverterTest.py @@ -36,6 +36,7 @@ ########################################################################## import maya.cmds +import imath import IECore import IECoreScene @@ -67,9 +68,9 @@ def buildTestSetup( self ) : sc2 = maya.cmds.skinCluster( j4, geo2, dr=4.5 )[0] # change the weights on sc2 - r = IECore.Rand32() + r = imath.Rand32() for i in range( 0, 15 ) : - val = r.barycentricf() + val = IECore.RandomAlgo.barycentricRandf( r ) maya.cmds.skinPercent( sc2, '%s.vtx[%d]' % ( geo2, i ), transformValue=[(j4, val[0]), (j5, val[1]), (j6, val[2]) ]) return ( sc, sc2 ) @@ -140,7 +141,7 @@ def testSSDInfluenceNotInScene( self ) : maya.cmds.parent( 'joint3', 'joint1' ) maya.cmds.delete( 'joint2' ) - newPose = IECore.M44fVectorData( [ IECore.M44f( maya.cmds.getAttr( 'skinCluster1.bindPreMatrix[0]' ) ), IECore.M44f( maya.cmds.getAttr( 'skinCluster1.bindPreMatrix[2]' ) ) ] ) + newPose = IECore.M44fVectorData( [ imath.M44f( *maya.cmds.getAttr( 'skinCluster1.bindPreMatrix[0]' ) ), imath.M44f( *maya.cmds.getAttr( 'skinCluster1.bindPreMatrix[2]' ) ) ] ) toConverter = IECoreMaya.ToMayaSkinClusterConverter.create( ssd ) self.assertRaises( RuntimeError, IECore.curry( toConverter.convert, sc ) ) @@ -169,7 +170,7 @@ def testSSDInfluenceInSceneButNotAJoint( self ) : maya.cmds.parent( 'joint3', 'joint1' ) maya.cmds.delete( 'joint2' ) maya.cmds.polyCube( n = "joint2", w = 1, h = 4, d = 1, sx = 1, sy = 3, sz = 1, ax = [ 0, 1, 0 ],cuv = 4, ch = 0 ) - newPose = IECore.M44fVectorData( [ IECore.M44f( maya.cmds.getAttr( 'skinCluster1.bindPreMatrix[0]' ) ), IECore.M44f( maya.cmds.getAttr( 'skinCluster1.bindPreMatrix[2]' ) ) ] ) + newPose = IECore.M44fVectorData( [ imath.M44f( *maya.cmds.getAttr( 'skinCluster1.bindPreMatrix[0]' ) ), imath.M44f( *maya.cmds.getAttr( 'skinCluster1.bindPreMatrix[2]' ) ) ] ) toConverter = IECoreMaya.ToMayaSkinClusterConverter.create( ssd ) self.assertRaises( RuntimeError, IECore.curry( toConverter.convert, sc ) ) @@ -196,7 +197,7 @@ def testSkinClusterInfluencesWereRenamed( self ) : ssd.validate() maya.cmds.rename( 'joint2', 'fakeJoint' ) - newPose = IECore.M44fVectorData( [ IECore.M44f( maya.cmds.getAttr( 'skinCluster1.bindPreMatrix[0]' ) ), IECore.M44f( maya.cmds.getAttr( 'skinCluster1.bindPreMatrix[2]' ) ), IECore.M44f( maya.cmds.getAttr( 'skinCluster1.bindPreMatrix[1]' ) ) ] ) + newPose = IECore.M44fVectorData( [ imath.M44f( *maya.cmds.getAttr( 'skinCluster1.bindPreMatrix[0]' ) ), imath.M44f( *maya.cmds.getAttr( 'skinCluster1.bindPreMatrix[2]' ) ), imath.M44f( *maya.cmds.getAttr( 'skinCluster1.bindPreMatrix[1]' ) ) ] ) toConverter = IECoreMaya.ToMayaSkinClusterConverter.create( ssd ) toConverter.parameters()["ignoreMissingInfluences"].setTypedValue( True ) @@ -224,7 +225,7 @@ def testSkinClusterInfluencesWereRenamedAndOldNamesStillExist( self ) : maya.cmds.rename( 'joint2', 'fakeJoint' ) maya.cmds.rename( 'joint5', 'joint2' ) newPose = ssd.influencePose() - newPose.append( IECore.M44f( maya.cmds.getAttr( 'skinCluster1.bindPreMatrix[1]' ) ) ) + newPose.append( imath.M44f( *maya.cmds.getAttr( 'skinCluster1.bindPreMatrix[1]' ) ) ) toConverter = IECoreMaya.ToMayaSkinClusterConverter.create( ssd ) toConverter.parameters()["ignoreMissingInfluences"].setTypedValue( True ) diff --git a/test/IECoreNuke/FnAxisTest.py b/test/IECoreNuke/FnAxisTest.py index 8fc4b3a8c3..72af0df8a7 100644 --- a/test/IECoreNuke/FnAxisTest.py +++ b/test/IECoreNuke/FnAxisTest.py @@ -35,6 +35,7 @@ import math import unittest import IECoreNuke +import imath import IECore import nuke @@ -45,10 +46,10 @@ def test( self ) : n = nuke.nodes.Axis() f = IECoreNuke.FnAxis( n ) - self.assertEqual( f.getLocalMatrix(), IECore.M44f() ) + self.assertEqual( f.getLocalMatrix(), imath.M44f() ) - IECoreNuke.setKnobValue( n.knob( "translate" ), IECore.V3f( 1, 2, 3 ) ) - self.assertEqual( f.getLocalMatrix(), IECore.M44f.createTranslated( IECore.V3f( 1, 2, 3 ) ) ) + IECoreNuke.setKnobValue( n.knob( "translate" ), imath.V3f( 1, 2, 3 ) ) + self.assertEqual( f.getLocalMatrix(), imath.M44f().translate( imath.V3f( 1, 2, 3 ) ) ) if __name__ == "__main__": diff --git a/test/IECoreNuke/KnobAccessorsTest.py b/test/IECoreNuke/KnobAccessorsTest.py index 2da71a1b41..8a511d799c 100644 --- a/test/IECoreNuke/KnobAccessorsTest.py +++ b/test/IECoreNuke/KnobAccessorsTest.py @@ -35,6 +35,7 @@ import math import unittest import IECoreNuke +import imath import IECore import nuke @@ -45,8 +46,8 @@ def test( self ) : n = nuke.nodes.RadialDistort() k = n.knob( "scale" ) - self.assertEqual( IECoreNuke.getKnobValue( k ), IECore.V3f( 1 ) ) - self.assertEqual( IECoreNuke.getKnobValue( k, resultType=IECore.V3d ), IECore.V3d( 1 ) ) + self.assertEqual( IECoreNuke.getKnobValue( k ), imath.V3f( 1 ) ) + self.assertEqual( IECoreNuke.getKnobValue( k, resultType=imath.V3d ), imath.V3d( 1 ) ) if __name__ == "__main__": unittest.main() diff --git a/test/IECoreNuke/KnobConvertersTest.py b/test/IECoreNuke/KnobConvertersTest.py index cfeec3b7b3..a42d4497b7 100644 --- a/test/IECoreNuke/KnobConvertersTest.py +++ b/test/IECoreNuke/KnobConvertersTest.py @@ -35,6 +35,7 @@ import math import unittest import IECoreNuke +import imath import IECore import nuke @@ -121,12 +122,12 @@ def __parameters() : IECore.TransformationMatrixfParameter( name = "O", description = "", - defaultValue = IECore.TransformationMatrixfData( IECore.TransformationMatrixf( IECore.V3f(1), IECore.Eulerf(), IECore.V3f(1) ) ), + defaultValue = IECore.TransformationMatrixfData( IECore.TransformationMatrixf( imath.V3f(1), imath.Eulerf(), imath.V3f(1) ) ), presets = ( - ( "preset0", IECore.TransformationMatrixfData(IECore.TransformationMatrixf(IECore.V3f(1), IECore.Eulerf(), IECore.V3f(1))) ), - ( "preset1", IECore.TransformationMatrixfData(IECore.TransformationMatrixf(IECore.V3f(1), IECore.Eulerf(), IECore.V3f(2))) ), - ( "preset2", IECore.TransformationMatrixfData(IECore.TransformationMatrixf(IECore.V3f(1), IECore.Eulerf(), IECore.V3f(3))) ), - ( "preset3", IECore.TransformationMatrixfData(IECore.TransformationMatrixf(IECore.V3f(1), IECore.Eulerf(), IECore.V3f(4))) ), + ( "preset0", IECore.TransformationMatrixfData(IECore.TransformationMatrixf(imath.V3f(1), imath.Eulerf(), imath.V3f(1))) ), + ( "preset1", IECore.TransformationMatrixfData(IECore.TransformationMatrixf(imath.V3f(1), imath.Eulerf(), imath.V3f(2))) ), + ( "preset2", IECore.TransformationMatrixfData(IECore.TransformationMatrixf(imath.V3f(1), imath.Eulerf(), imath.V3f(3))) ), + ( "preset3", IECore.TransformationMatrixfData(IECore.TransformationMatrixf(imath.V3f(1), imath.Eulerf(), imath.V3f(4))) ), ), presetsOnly = True ) @@ -175,7 +176,7 @@ def testSettingKnobValues( self ) : params[ 'F' ][ 'I' ] = IECore.DoubleVectorData( [ 9 ] ) params[ 'M' ] = "/tmp/anotherTest.%d.dpx" params[ 'N' ] = False - params[ 'O' ] = IECore.TransformationMatrixfData(IECore.TransformationMatrixf(IECore.V3f(1), IECore.Eulerf(), IECore.V3f(3))) + params[ 'O' ] = IECore.TransformationMatrixfData(IECore.TransformationMatrixf(imath.V3f(1), imath.Eulerf(), imath.V3f(3))) IECoreNuke.setKnobsFromParameter( knobHolder, params ) knobs = knobHolder.knobs() self.assertEqual( knobs["parm_A"].getValue(), 2 ) @@ -223,7 +224,7 @@ def testGettingKnobValues( self ) : self.assertEqual( params["L"].getTypedValue(), "/tmp2" ) self.assertEqual( params["M"].getTypedValue(), "/tmp2/test.##.dpx" ) self.assertEqual( params["N"].getTypedValue(), False ) - self.assertEqual( params["O"].getValue(), IECore.TransformationMatrixfData(IECore.TransformationMatrixf(IECore.V3f(1), IECore.Eulerf(), IECore.V3f(4))) ) + self.assertEqual( params["O"].getValue(), IECore.TransformationMatrixfData(IECore.TransformationMatrixf(imath.V3f(1), imath.Eulerf(), imath.V3f(4))) ) # raises exception when trying to convert an invalid file sequence syntax knobs["parm_M"].setValue( "/tmp2/test.%2d.dpx" ) self.assertRaises( RuntimeError, IECoreNuke.setParameterFromKnobs, knobHolder, params ) diff --git a/test/IECoreNuke/LensDistortTest.py b/test/IECoreNuke/LensDistortTest.py index 8bd3a928a7..97362cc893 100644 --- a/test/IECoreNuke/LensDistortTest.py +++ b/test/IECoreNuke/LensDistortTest.py @@ -37,6 +37,7 @@ import unittest import nuke +import imath import IECore import IECoreImage @@ -99,12 +100,12 @@ def setUp( self ) : # Finally, read back the images and offset their display windows to make the # tests even more interesting... offsetImg = IECore.Reader.create( paths['path'] ).read() - offsetDisplayWindow = IECore.Box2i( offsetImg.displayWindow.min + IECore.V2i( -261, 172 ), offsetImg.displayWindow.max + IECore.V2i( -261, 172 ) ) + offsetDisplayWindow = imath.Box2i( offsetImg.displayWindow.min() + imath.V2i( -261, 172 ), offsetImg.displayWindow.max() + imath.V2i( -261, 172 ) ) offsetImg.displayWindow = offsetDisplayWindow IECore.Writer.create( offsetImg, paths['offsetPath'] ).write() croppedOffsetImg = IECore.Reader.create( paths['croppedPath'] ).read() - offsetDisplayWindow = IECore.Box2i( croppedOffsetImg.displayWindow.min + IECore.V2i( 120, -100 ), croppedOffsetImg.displayWindow.max + IECore.V2i( 120, -100 ) ) + offsetDisplayWindow = imath.Box2i( croppedOffsetImg.displayWindow.min() + imath.V2i( 120, -100 ), croppedOffsetImg.displayWindow.max() + imath.V2i( 120, -100 ) ) croppedOffsetImg.displayWindow = offsetDisplayWindow IECore.Writer.create( croppedOffsetImg, paths['croppedOffsetPath'] ).write() diff --git a/test/IECoreNuke/ParameterisedHolderTest.py b/test/IECoreNuke/ParameterisedHolderTest.py index f1f2017115..e3365e1994 100644 --- a/test/IECoreNuke/ParameterisedHolderTest.py +++ b/test/IECoreNuke/ParameterisedHolderTest.py @@ -38,6 +38,7 @@ import os import nuke +import imath import IECore import IECoreScene @@ -75,9 +76,9 @@ def __checkParameterKnobs( self, parameter, node, knobName=None, parameterPath=N knobValue = IECoreNuke.getKnobValue( knob ) if isinstance( parameter, IECore.V2dParameter ) : # getKnobValue defaults to V2f - knobValue = IECore.V2d( knobValue[0], knobValue[1] ) + knobValue = imath.V2d( knobValue[0], knobValue[1] ) elif isinstance( parameter, IECore.V3dParameter ) : - knobValue = IECore.V3d( knobValue[0], knobValue[1], knobValue[2] ) + 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 @@ -276,7 +277,7 @@ def testParameterTypes( self ) : with fnOH.parameterModificationContext() as parameterised : parameterised.parameters()["d"].setTypedValue( "lalal" ) - parameterised.parameters()["p2"].setTypedValue( IECore.LineSegment3f( IECore.V3f( 10, 11, 12 ), IECore.V3f( 12, 10, 9 ) ) ) + parameterised.parameters()["p2"].setTypedValue( IECore.LineSegment3f( imath.V3f( 10, 11, 12 ), imath.V3f( 12, 10, 9 ) ) ) self.__checkParameterKnobs( parameterised.parameters(), fnOH.node(), ignore=unsupported | notEasy ) self.__checkParameterKnobs( fnOH.getParameterised()[0].parameters(), fnOH.node(), ignore=unsupported | notEasy ) diff --git a/test/IECoreScene/AddAndRemoveSmoothSkinningInfluencesOpTest.py b/test/IECoreScene/AddAndRemoveSmoothSkinningInfluencesOpTest.py index 021180293a..b44e747795 100644 --- a/test/IECoreScene/AddAndRemoveSmoothSkinningInfluencesOpTest.py +++ b/test/IECoreScene/AddAndRemoveSmoothSkinningInfluencesOpTest.py @@ -35,6 +35,7 @@ import math import unittest import random +import imath import IECore import IECoreScene @@ -54,7 +55,7 @@ def createSSD( self, names, poses, indices ) : def original( self ) : names = IECore.StringVectorData( [ 'jointA', 'jointB', 'jointC' ] ) - poses = IECore.M44fVectorData( [IECore.M44f(1),IECore.M44f(2),IECore.M44f(3)] ) + poses = IECore.M44fVectorData( [imath.M44f(1),imath.M44f(2),imath.M44f(3)] ) indices = IECore.IntVectorData( [0, 1, 0, 1, 2, 1, 1, 2, 0, 1, 2] ) return self.createSSD( names, poses, indices ) @@ -62,7 +63,7 @@ def original( self ) : def added( self ) : names = IECore.StringVectorData( [ 'newA', 'jointA', 'newC', 'newB', 'jointB', 'jointC', 'newD' ] ) - poses = IECore.M44fVectorData( [ IECore.M44f(4), IECore.M44f(1), IECore.M44f(6), IECore.M44f(5), IECore.M44f(2), IECore.M44f(3), IECore.M44f(7) ] ) + poses = IECore.M44fVectorData( [ imath.M44f(4), imath.M44f(1), imath.M44f(6), imath.M44f(5), imath.M44f(2), imath.M44f(3), imath.M44f(7) ] ) indices = IECore.IntVectorData( [1, 4, 1, 4, 5, 4, 4, 5, 1, 4, 5] ) return self.createSSD( names, poses, indices ) @@ -70,7 +71,7 @@ def added( self ) : def removed( self ) : names = IECore.StringVectorData( [ 'jointA', 'newC', 'newB', 'jointC' ] ) - poses = IECore.M44fVectorData( [ IECore.M44f(1), IECore.M44f(6), IECore.M44f(5), IECore.M44f(3) ] ) + poses = IECore.M44fVectorData( [ imath.M44f(1), imath.M44f(6), imath.M44f(5), imath.M44f(3) ] ) offsets = IECore.IntVectorData( [0, 1, 3, 3, 4] ) counts = IECore.IntVectorData( [1, 2, 0, 1, 2] ) indices = IECore.IntVectorData( [0, 0, 3, 3, 0, 3] ) @@ -122,7 +123,7 @@ def testAdding( self ) : op = IECoreScene.AddSmoothSkinningInfluencesOp() op.parameters()['input'].setValue( ssd ) op.parameters()['influenceNames'].setValue( IECore.StringVectorData( [ "newA", "newB", "newC", "newD" ] ) ) - op.parameters()['influencePose'].setValue( IECore.M44fVectorData( [ IECore.M44f(4), IECore.M44f(5), IECore.M44f(6), IECore.M44f(7) ] ) ) + op.parameters()['influencePose'].setValue( IECore.M44fVectorData( [ imath.M44f(4), imath.M44f(5), imath.M44f(6), imath.M44f(7) ] ) ) op.parameters()['indices'].setValue( IECore.IntVectorData( [ 0, 2, 2, 6 ] ) ) result = op.operate() @@ -251,14 +252,14 @@ def testAddOpErrorStates( self ) : op = IECoreScene.AddSmoothSkinningInfluencesOp() op.parameters()['input'].setValue( ssd ) op.parameters()['influenceNames'].setValue( IECore.StringVectorData( [ "newA", "newB", "newC" ] ) ) - op.parameters()['influencePose'].setValue( IECore.M44fVectorData( [ IECore.M44f(1), IECore.M44f(2) ] ) ) + op.parameters()['influencePose'].setValue( IECore.M44fVectorData( [ imath.M44f(1), imath.M44f(2) ] ) ) op.parameters()['indices'].setValue( IECore.IntVectorData( [ 1, 3 ] ) ) # wrong number of pose matrices self.assertRaises( RuntimeError, op.operate ) # wrong number of indices - op.parameters()['influencePose'].setValue( IECore.M44fVectorData( [ IECore.M44f(1), IECore.M44f(2), IECore.M44f(3) ] ) ) + op.parameters()['influencePose'].setValue( IECore.M44fVectorData( [ imath.M44f(1), imath.M44f(2), imath.M44f(3) ] ) ) self.assertRaises( RuntimeError, op.operate ) # index validity diff --git a/test/IECoreScene/All.py b/test/IECoreScene/All.py index 36e96334da..0eb68d68c3 100644 --- a/test/IECoreScene/All.py +++ b/test/IECoreScene/All.py @@ -52,7 +52,6 @@ from MotionPrimitive import * from Transform import * from Group import * -from PointsExpressionOp import * from Camera import * from NURBS import * from PointBoundsOp import * diff --git a/test/IECoreScene/Camera.py b/test/IECoreScene/Camera.py index 8da2582071..807376ecb3 100644 --- a/test/IECoreScene/Camera.py +++ b/test/IECoreScene/Camera.py @@ -34,6 +34,7 @@ import unittest import os.path +import imath import IECore import IECoreScene @@ -61,8 +62,8 @@ def test( self ) : c.setName( "n" ) self.assertEqual( c.getName(), "n" ) - c.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createScaled( IECore.V3f( 2 ) ) ) ) - self.assertEqual( c.getTransform(), IECoreScene.MatrixTransform( IECore.M44f.createScaled( IECore.V3f( 2 ) ) ) ) + c.setTransform( IECoreScene.MatrixTransform( imath.M44f().scale( imath.V3f( 2 ) ) ) ) + self.assertEqual( c.getTransform(), IECoreScene.MatrixTransform( imath.M44f().scale( imath.V3f( 2 ) ) ) ) c.parameters()["fov"] = IECore.FloatData( 45 ) self.assertEqual( c.parameters()["fov"], IECore.FloatData( 45 ) ) @@ -80,36 +81,36 @@ def testAddStandardParameters( self ) : c = IECoreScene.Camera() c.addStandardParameters() - self.assertEqual( c.parameters()["resolution"].value, IECore.V2i( 640, 480 ) ) + self.assertEqual( c.parameters()["resolution"].value, imath.V2i( 640, 480 ) ) self.assertEqual( c.parameters()["pixelAspectRatio"].value, 1.0 ) aspectRatio = 640.0/480.0 - self.assertEqual( c.parameters()["screenWindow"].value, IECore.Box2f( IECore.V2f( -aspectRatio, -1 ), IECore.V2f( aspectRatio, 1 ) ) ) + self.assertEqual( c.parameters()["screenWindow"].value, imath.Box2f( imath.V2f( -aspectRatio, -1 ), imath.V2f( aspectRatio, 1 ) ) ) - self.assertEqual( c.parameters()["cropWindow"].value, IECore.Box2f( IECore.V2f( 0, 0 ), IECore.V2f( 1, 1 ) ) ) + self.assertEqual( c.parameters()["cropWindow"].value, imath.Box2f( imath.V2f( 0, 0 ), imath.V2f( 1, 1 ) ) ) self.assertEqual( c.parameters()["projection"].value, "orthographic" ) - self.assertEqual( c.parameters()["clippingPlanes"].value, IECore.V2f( 0.01, 100000 ) ) - self.assertEqual( c.parameters()["shutter"].value, IECore.V2f( 0 ) ) + self.assertEqual( c.parameters()["clippingPlanes"].value, imath.V2f( 0.01, 100000 ) ) + self.assertEqual( c.parameters()["shutter"].value, imath.V2f( 0 ) ) c = IECoreScene.Camera() c.parameters()["projection"] = IECore.StringData( "perspective" ) - c.parameters()["resolution"] = IECore.V2iData( IECore.V2i( 500, 1000 ) ) - c.parameters()["cropWindow"] = IECore.Box2fData( IECore.Box2f( IECore.V2f( 0.1 ), IECore.V2f( 0.9 ) ) ) - c.parameters()["clippingPlanes"] = IECore.V2fData( IECore.V2f( 1, 1000 ) ) - c.parameters()["shutter"] = IECore.V2fData( IECore.V2f( 1, 2 ) ) + c.parameters()["resolution"] = IECore.V2iData( imath.V2i( 500, 1000 ) ) + c.parameters()["cropWindow"] = IECore.Box2fData( imath.Box2f( imath.V2f( 0.1 ), imath.V2f( 0.9 ) ) ) + c.parameters()["clippingPlanes"] = IECore.V2fData( imath.V2f( 1, 1000 ) ) + c.parameters()["shutter"] = IECore.V2fData( imath.V2f( 1, 2 ) ) c.addStandardParameters() - self.assertEqual( c.parameters()["resolution"].value, IECore.V2i( 500, 1000 ) ) - self.assertEqual( c.parameters()["screenWindow"].value, IECore.Box2f( IECore.V2f( -1, -2 ), IECore.V2f( 1, 2 ) ) ) - self.assertEqual( c.parameters()["cropWindow"].value, IECore.Box2f( IECore.V2f( 0.1 ), IECore.V2f( 0.9 ) ) ) + self.assertEqual( c.parameters()["resolution"].value, imath.V2i( 500, 1000 ) ) + self.assertEqual( c.parameters()["screenWindow"].value, imath.Box2f( imath.V2f( -1, -2 ), imath.V2f( 1, 2 ) ) ) + self.assertEqual( c.parameters()["cropWindow"].value, imath.Box2f( imath.V2f( 0.1 ), imath.V2f( 0.9 ) ) ) self.assertEqual( c.parameters()["projection"].value, "perspective" ) self.assertEqual( c.parameters()["projection:fov"].value, 90 ) - self.assertEqual( c.parameters()["clippingPlanes"].value, IECore.V2f( 1, 1000 ) ) - self.assertEqual( c.parameters()["shutter"].value, IECore.V2f( 1, 2 ) ) + self.assertEqual( c.parameters()["clippingPlanes"].value, imath.V2f( 1, 1000 ) ) + self.assertEqual( c.parameters()["shutter"].value, imath.V2f( 1, 2 ) ) # Negative clip planes on ortho cameras should be supported c = IECoreScene.Camera() - c.parameters()["clippingPlanes"] = IECore.V2fData( IECore.V2f( -1000, 1000 ) ) + c.parameters()["clippingPlanes"] = IECore.V2fData( imath.V2f( -1000, 1000 ) ) c.addStandardParameters() - self.assertEqual( c.parameters()["clippingPlanes"].value, IECore.V2f( -1000, 1000 ) ) + self.assertEqual( c.parameters()["clippingPlanes"].value, imath.V2f( -1000, 1000 ) ) def testHash( self ) : @@ -120,7 +121,7 @@ def testHash( self ) : self.assertNotEqual( c.hash(), h ) h = c.hash() - c.setTransform( IECoreScene.MatrixTransform( IECore.M44f() ) ) + c.setTransform( IECoreScene.MatrixTransform( imath.M44f() ) ) self.assertNotEqual( c.hash(), h ) h = c.hash() @@ -130,11 +131,11 @@ def testHash( self ) : def testAddStandardParametersWithNonSquarePixels( self ) : c = IECoreScene.Camera() - c.parameters()["resolution"] = IECore.V2i( 100, 200 ) + c.parameters()["resolution"] = imath.V2i( 100, 200 ) c.parameters()["pixelAspectRatio"] = 2.0 c.addStandardParameters() - self.assertEqual( c.parameters()["screenWindow"].value, IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + self.assertEqual( c.parameters()["screenWindow"].value, imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) def tearDown( self ) : diff --git a/test/IECoreScene/CapturingRendererTest.py b/test/IECoreScene/CapturingRendererTest.py index f19c0d28bc..cd78b9acae 100644 --- a/test/IECoreScene/CapturingRendererTest.py +++ b/test/IECoreScene/CapturingRendererTest.py @@ -38,6 +38,7 @@ import unittest import sys import os +import imath import IECore import IECoreScene @@ -245,23 +246,23 @@ def testTransformStack( self ) : with IECoreScene.WorldBlock( r ) : - self.assertEqual( r.getTransform(), IECore.M44f() ) + self.assertEqual( r.getTransform(), imath.M44f() ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 1, 0 ) ) ) - self.assertEqual( r.getTransform(), IECore.M44f.createTranslated( IECore.V3f( 0, 1, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 0, 1, 0 ) ) ) + self.assertEqual( r.getTransform(), imath.M44f().translate( imath.V3f( 0, 1, 0 ) ) ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 1, 0, 0 ) ) ) - self.assertEqual( r.getTransform(), IECore.M44f.createTranslated( IECore.V3f( 1, 1, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 1, 0, 0 ) ) ) + self.assertEqual( r.getTransform(), imath.M44f().translate( imath.V3f( 1, 1, 0 ) ) ) - r.setTransform( IECore.M44f.createTranslated( IECore.V3f( 0, 0, 1 ) ) ) - self.assertEqual( r.getTransform(), IECore.M44f.createTranslated( IECore.V3f( 0, 0, 1 ) ) ) + r.setTransform( imath.M44f().translate( imath.V3f( 0, 0, 1 ) ) ) + self.assertEqual( r.getTransform(), imath.M44f().translate( imath.V3f( 0, 0, 1 ) ) ) with IECoreScene.TransformBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 1, 1, 0 ) ) ) - self.assertEqual( r.getTransform(), IECore.M44f.createTranslated( IECore.V3f( 1, 1, 1 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 1, 1, 0 ) ) ) + self.assertEqual( r.getTransform(), imath.M44f().translate( imath.V3f( 1, 1, 1 ) ) ) - self.assertEqual( r.getTransform(), IECore.M44f.createTranslated( IECore.V3f( 0, 0, 1 ) ) ) + self.assertEqual( r.getTransform(), imath.M44f().translate( imath.V3f( 0, 0, 1 ) ) ) def testTransforms( self ) : @@ -269,13 +270,13 @@ def testTransforms( self ) : with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 1, 0, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 1, 0, 0 ) ) ) r.sphere( 1, -1, 1, 360, {} ) w = r.world() - self.assertEqual( w.getTransform().matrix, IECore.M44f.createTranslated( IECore.V3f( 1, 0, 0 ) ) ) + self.assertEqual( w.getTransform().matrix, imath.M44f().translate( imath.V3f( 1, 0, 0 ) ) ) self.failUnless( isinstance( w.children()[0], IECoreScene.SpherePrimitive ) ) def testInterleavedTransformsAndPrimitives( self ) : @@ -284,11 +285,11 @@ def testInterleavedTransformsAndPrimitives( self ) : with IECoreScene.WorldBlock( r ) : - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 1, 0, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 1, 0, 0 ) ) ) r.sphere( 1, -1, 1, 360, {} ) - r.concatTransform( IECore.M44f.createTranslated( IECore.V3f( 1, 0, 0 ) ) ) + r.concatTransform( imath.M44f().translate( imath.V3f( 1, 0, 0 ) ) ) r.sphere( 1, -1, 1, 360, {} ) @@ -300,8 +301,8 @@ def testInterleavedTransformsAndPrimitives( self ) : self.assertEqual( len( c ), 2 ) self.failUnless( isinstance( c[0], IECoreScene.Group ) ) self.failUnless( isinstance( c[1], IECoreScene.Group ) ) - self.assertEqual( c[0].getTransform().matrix, IECore.M44f.createTranslated( IECore.V3f( 1, 0, 0 ) ) ) - self.assertEqual( c[1].getTransform().matrix, IECore.M44f.createTranslated( IECore.V3f( 2, 0, 0 ) ) ) + self.assertEqual( c[0].getTransform().matrix, imath.M44f().translate( imath.V3f( 1, 0, 0 ) ) ) + self.assertEqual( c[1].getTransform().matrix, imath.M44f().translate( imath.V3f( 2, 0, 0 ) ) ) self.failUnless( isinstance( c[0].children()[0], IECoreScene.SpherePrimitive ) ) self.failUnless( isinstance( c[1].children()[0], IECoreScene.SpherePrimitive ) ) @@ -318,7 +319,7 @@ def __init__( self, maxLevel = 3, level = 0 ) : def bound( self ) : - return IECore.Box3f( IECore.V3f( -1 ), IECore.V3f( 1 ) ) + return imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ) def render( self, renderer ) : @@ -331,18 +332,18 @@ def emit( offset ) : with IECoreScene.AttributeBlock( renderer ) : - renderer.concatTransform( IECore.M44f.createTranslated( offset ) ) - renderer.concatTransform( IECore.M44f.createScaled( IECore.V3f( 0.5 ) ) ) + renderer.concatTransform( imath.M44f().translate( offset ) ) + renderer.concatTransform( imath.M44f().scale( imath.V3f( 0.5 ) ) ) renderer.procedural( CapturingRendererTest.SnowflakeProcedural( self.__maxLevel, self.__level + 1 ) ) if self.__level < self.__maxLevel : - emit( IECore.V3f( 0, 1, 0 ) ) - emit( IECore.V3f( -1, 0, 0 ) ) - emit( IECore.V3f( 0, 0, 0 ) ) - emit( IECore.V3f( 1, 0, 0 ) ) - emit( IECore.V3f( 0, -1, 0 ) ) + emit( imath.V3f( 0, 1, 0 ) ) + emit( imath.V3f( -1, 0, 0 ) ) + emit( imath.V3f( 0, 0, 0 ) ) + emit( imath.V3f( 1, 0, 0 ) ) + emit( imath.V3f( 0, -1, 0 ) ) else : @@ -465,7 +466,7 @@ def __init__( self ) : def bound( self ) : - return IECore.Box3f( IECore.V3f( -1 ), IECore.V3f( 1 ) ) + return imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ) def render( self, renderer ) : @@ -530,7 +531,7 @@ def __init__( self, maxLevel = 4, level = 0 ) : def bound( self ) : - return IECore.Box3f( IECore.V3f( -1 ), IECore.V3f( 1 ) ) + return imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ) def render( self, renderer ) : @@ -581,7 +582,7 @@ def __init__( self, maxLevel = 3, level = 0, name="snowflake" ) : def bound( self ) : - return IECore.Box3f( IECore.V3f( -1 ), IECore.V3f( 1 ) ) + return imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ) def render( self, renderer ) : @@ -589,8 +590,8 @@ def emit( offset, childname, recurse ) : with IECoreScene.AttributeBlock( renderer ) : - renderer.concatTransform( IECore.M44f.createTranslated( offset ) ) - renderer.concatTransform( IECore.M44f.createScaled( IECore.V3f( 0.5 ) ) ) + renderer.concatTransform( imath.M44f().translate( offset ) ) + renderer.concatTransform( imath.M44f().scale( imath.V3f( 0.5 ) ) ) newName = self.__name + "/" + childname @@ -607,11 +608,11 @@ def emit( offset, childname, recurse ) : recurse = self.__level < self.__maxLevel - emit( IECore.V3f( 0, 1, 0 ), "one", recurse ) - emit( IECore.V3f( -1, 0, 0 ), "two", recurse ) - emit( IECore.V3f( 0, 0, 0 ), "three", recurse ) - emit( IECore.V3f( 1, 0, 0 ), "four", recurse ) - emit( IECore.V3f( 0, -1, 0 ), "five", recurse ) + emit( imath.V3f( 0, 1, 0 ), "one", recurse ) + emit( imath.V3f( -1, 0, 0 ), "two", recurse ) + emit( imath.V3f( 0, 0, 0 ), "three", recurse ) + emit( imath.V3f( 1, 0, 0 ), "four", recurse ) + emit( imath.V3f( 0, -1, 0 ), "five", recurse ) def hash( self ): @@ -886,7 +887,7 @@ def __init__( self, maxLevel = 3, level = 0, withAttributeBlock = True ) : def bound( self ) : - return IECore.Box3f( IECore.V3f( -1 ), IECore.V3f( 1 ) ) + return imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ) def render( self, renderer ) : diff --git a/test/IECoreScene/CompressAndDecompressSmoothSkinningDataOpsTest.py b/test/IECoreScene/CompressAndDecompressSmoothSkinningDataOpsTest.py index 20c3d08cf6..6311763143 100644 --- a/test/IECoreScene/CompressAndDecompressSmoothSkinningDataOpsTest.py +++ b/test/IECoreScene/CompressAndDecompressSmoothSkinningDataOpsTest.py @@ -35,6 +35,7 @@ import math import unittest import random +import imath import IECore import IECoreScene @@ -44,7 +45,7 @@ class CompressAndDecompressSmoothSkinningDataOpsTest( unittest.TestCase ) : def compressed( self ) : names = IECore.StringVectorData( [ 'jointA', 'jointB', 'jointC' ] ) - poses = IECore.M44fVectorData( [IECore.M44f(),IECore.M44f(),IECore.M44f()] ) + poses = IECore.M44fVectorData( [imath.M44f(),imath.M44f(),imath.M44f()] ) offsets = IECore.IntVectorData( [0, 2, 4] ) counts = IECore.IntVectorData( [2, 2, 1] ) indices = IECore.IntVectorData( [0, 1, 0, 1, 1] ) @@ -57,7 +58,7 @@ def compressed( self ) : def noncompressed( self ) : names = IECore.StringVectorData( [ 'jointA', 'jointB', 'jointC' ] ) - poses = IECore.M44fVectorData( [IECore.M44f(),IECore.M44f(),IECore.M44f()] ) + poses = IECore.M44fVectorData( [imath.M44f(),imath.M44f(),imath.M44f()] ) offsets = IECore.IntVectorData( [0, 2, 5] ) counts = IECore.IntVectorData( [2, 3, 1] ) indices = IECore.IntVectorData( [0, 1, 0, 1, 2, 1] ) @@ -70,7 +71,7 @@ def noncompressed( self ) : def decompressed( self ) : names = IECore.StringVectorData( [ 'jointA', 'jointB', 'jointC' ] ) - poses = IECore.M44fVectorData( [IECore.M44f(),IECore.M44f(),IECore.M44f()] ) + poses = IECore.M44fVectorData( [imath.M44f(),imath.M44f(),imath.M44f()] ) offsets = IECore.IntVectorData( [0, 3, 6] ) counts = IECore.IntVectorData( [3, 3, 3] ) indices = IECore.IntVectorData( [0, 1, 2, 0, 1, 2, 0, 1, 2] ) diff --git a/test/IECoreScene/ContrastSmoothSkinningWeightsOpTest.py b/test/IECoreScene/ContrastSmoothSkinningWeightsOpTest.py index 6d21bfc74a..08eecc5b51 100644 --- a/test/IECoreScene/ContrastSmoothSkinningWeightsOpTest.py +++ b/test/IECoreScene/ContrastSmoothSkinningWeightsOpTest.py @@ -35,6 +35,7 @@ import math import unittest import random +import imath import IECore import IECoreScene @@ -57,9 +58,9 @@ def createSSD( self, offsets, counts, indices, weights ) : names = IECore.StringVectorData( [ "|joint1", "|joint1|joint2", "|joint1|joint2|joint3" ] ) poses = IECore.M44fVectorData( [ - IECore.M44f( 1, -0, 0, -0, -0, 1, -0, 0, 0, -0, 1, -0, -0, 2, -0, 1 ), - IECore.M44f( 1, -0, 0, -0, -0, 1, -0, 0, 0, -0, 1, -0, -0, 0, -0, 1 ), - IECore.M44f( 1, -0, 0, -0, -0, 1, -0, 0, 0, -0, 1, -0, -0, -2, -0, 1 ) + imath.M44f( 1, -0, 0, -0, -0, 1, -0, 0, 0, -0, 1, -0, -0, 2, -0, 1 ), + imath.M44f( 1, -0, 0, -0, -0, 1, -0, 0, 0, -0, 1, -0, -0, 0, -0, 1 ), + imath.M44f( 1, -0, 0, -0, -0, 1, -0, 0, 0, -0, 1, -0, -0, -2, -0, 1 ) ] ) return IECoreScene.SmoothSkinningData( names, poses, offsets, counts, indices, weights ) diff --git a/test/IECoreScene/CoordinateSystemTest.py b/test/IECoreScene/CoordinateSystemTest.py index e9682e4b82..7db78cfbfc 100644 --- a/test/IECoreScene/CoordinateSystemTest.py +++ b/test/IECoreScene/CoordinateSystemTest.py @@ -34,6 +34,7 @@ import os import unittest +import imath import IECore import IECoreScene @@ -69,7 +70,7 @@ def testHash( self ) : b.setName( "a" ) self.assertEqual( a.hash(), b.hash() ) - b.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( 1 ) ) ) ) + b.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 1 ) ) ) ) self.assertNotEqual( a.hash(), b.hash() ) def testTransform( self ) : @@ -82,17 +83,17 @@ def testTransform( self ) : self.assertEqual( c.getTransform(), None ) self.assertEqual( c, c.copy() ) - c = IECoreScene.CoordinateSystem( "test", IECoreScene.MatrixTransform( IECore.M44f() ) ) + c = IECoreScene.CoordinateSystem( "test", IECoreScene.MatrixTransform( imath.M44f() ) ) self.assertEqual( c.getName(), "test" ) - self.assertEqual( c.getTransform(), IECoreScene.MatrixTransform( IECore.M44f() ) ) + self.assertEqual( c.getTransform(), IECoreScene.MatrixTransform( imath.M44f() ) ) self.assertEqual( c, c.copy() ) cc = c.copy() - self.assertEqual( cc.getTransform(), IECoreScene.MatrixTransform( IECore.M44f() ) ) + self.assertEqual( cc.getTransform(), IECoreScene.MatrixTransform( imath.M44f() ) ) self.failIf( c.getTransform().isSame( cc.getTransform() ) ) - c.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( 1 ) ) ) ) - self.assertEqual( c.getTransform(), IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( 1 ) ) ) ) + c.setTransform( IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 1 ) ) ) ) + self.assertEqual( c.getTransform(), IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 1 ) ) ) ) c.setTransform( None ) self.assertEqual( c.getTransform(), None ) @@ -109,11 +110,11 @@ def testLoadCobFromBeforeTransforms( self ) : def testLoadCobWithTransform( self ) : - c = IECoreScene.CoordinateSystem( "test", IECoreScene.MatrixTransform( IECore.M44f() ) ) + c = IECoreScene.CoordinateSystem( "test", IECoreScene.MatrixTransform( imath.M44f() ) ) IECore.ObjectWriter( c, "test/IECore/data/coordSys.cob" ).write() c = IECore.ObjectReader( "test/IECore/data/coordSys.cob" ).read() - self.assertEqual( c.getTransform(), IECoreScene.MatrixTransform( IECore.M44f() ) ) + self.assertEqual( c.getTransform(), IECoreScene.MatrixTransform( imath.M44f() ) ) c = IECoreScene.CoordinateSystem( "test", None ) IECore.ObjectWriter( c, "test/IECore/data/coordSys.cob" ).write() @@ -133,11 +134,11 @@ def testEquality( self ) : self.assertNotEqual( c2, c1 ) c1.setName( "test" ) - c1.setTransform( IECoreScene.MatrixTransform( IECore.M44f() ) ) + c1.setTransform( IECoreScene.MatrixTransform( imath.M44f() ) ) self.assertNotEqual( c1, c2 ) self.assertNotEqual( c2, c1 ) - c2.setTransform( IECoreScene.MatrixTransform( IECore.M44f() ) ) + c2.setTransform( IECoreScene.MatrixTransform( imath.M44f() ) ) self.assertEqual( c1, c2 ) self.assertEqual( c2, c1 ) @@ -145,7 +146,7 @@ def testMemoryUsage( self ) : c = IECoreScene.CoordinateSystem( "test" ) m = c.memoryUsage() - c.setTransform( IECoreScene.MatrixTransform( IECore.M44f() ) ) + c.setTransform( IECoreScene.MatrixTransform( imath.M44f() ) ) self.failUnless( c.memoryUsage() > m ) def tearDown( self ) : diff --git a/test/IECoreScene/CurveExtrudeOp.py b/test/IECoreScene/CurveExtrudeOp.py index 3813be20d4..2f9b5c18f7 100644 --- a/test/IECoreScene/CurveExtrudeOp.py +++ b/test/IECoreScene/CurveExtrudeOp.py @@ -36,6 +36,7 @@ import os.path import math import unittest +import imath import IECore import IECoreScene @@ -50,7 +51,7 @@ def testIt( self ) : patchGroup = op( curves = c, - resolution = IECore.V2i( 6, 30 ) + resolution = imath.V2i( 6, 30 ) ) self.assertEqual( len( patchGroup.children() ), 193 ) diff --git a/test/IECoreScene/CurveLineariserTest.py b/test/IECoreScene/CurveLineariserTest.py index 79307904ce..f49f318dd6 100644 --- a/test/IECoreScene/CurveLineariserTest.py +++ b/test/IECoreScene/CurveLineariserTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene @@ -79,14 +80,14 @@ def runTest( self, curves ) : if isinstance( pv, ( float, int ) ) : self.assertAlmostEqual( pv, pv2 ) - elif isinstance( pv, ( IECore.V3f, IECore.Color3f ) ) : + elif isinstance( pv, ( imath.V3f, imath.Color3f ) ) : self.assert_( pv.equalWithAbsError( pv2, 0.005 ) ) else : self.assertEqual( pv, pv2 ) def test3SegmentBSpline( self ) : - v = IECore.V3f + v = imath.V3f c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 6 ] ), @@ -108,7 +109,7 @@ def test3SegmentBSpline( self ) : def test3SegmentBSplineDoubledEndpoints( self ) : - v = IECore.V3f + v = imath.V3f c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 8 ] ), @@ -132,7 +133,7 @@ def test3SegmentBSplineDoubledEndpoints( self ) : def test2Curve3SegmentBSpline( self ) : - v = IECore.V3f + v = imath.V3f c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 6, 6 ] ), @@ -160,7 +161,7 @@ def test2Curve3SegmentBSpline( self ) : def testPeriodicBSpline( self ) : - v = IECore.V3f + v = imath.V3f c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 4 ] ), @@ -180,7 +181,7 @@ def testPeriodicBSpline( self ) : def test2CurvePeriodicBSpline( self ) : - v = IECore.V3f + v = imath.V3f c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 4, 4 ] ), @@ -204,7 +205,7 @@ def test2CurvePeriodicBSpline( self ) : def test3SegmentLinear( self ) : - v = IECore.V3f + v = imath.V3f c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 6 ] ), @@ -226,7 +227,7 @@ def test3SegmentLinear( self ) : def test3SegmentLinearDoubledEndpoints( self ) : - v = IECore.V3f + v = imath.V3f c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 8 ] ), @@ -250,7 +251,7 @@ def test3SegmentLinearDoubledEndpoints( self ) : def test2Curve3SegmentLinear( self ) : - v = IECore.V3f + v = imath.V3f c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 6, 6 ] ), @@ -278,7 +279,7 @@ def test2Curve3SegmentLinear( self ) : def test3SegmentPeriodicLinear( self ) : - v = IECore.V3f + v = imath.V3f c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 6 ] ), @@ -300,7 +301,7 @@ def test3SegmentPeriodicLinear( self ) : def test2Curve3SegmentPeriodicLinear( self ) : - v = IECore.V3f + v = imath.V3f c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 6, 6 ] ), diff --git a/test/IECoreScene/CurveTangentsOpTest.py b/test/IECoreScene/CurveTangentsOpTest.py index 878f7a28f5..e0850a061b 100644 --- a/test/IECoreScene/CurveTangentsOpTest.py +++ b/test/IECoreScene/CurveTangentsOpTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene import math @@ -42,7 +43,7 @@ class CurveTangentsOpTest( unittest.TestCase ) : def testTangentsGeneration( self ) : i = IECore.IntVectorData( [ 4 ] ) - p = IECore.V3fVectorData( [ IECore.V3f( 0.0 ), IECore.V3f( 1.0, 0.0, 0.0 ), IECore.V3f( 2.0, 0.0, 0.0 ), IECore.V3f( 3.0, 0.0, 0.0 ) ] ) + p = IECore.V3fVectorData( [ imath.V3f( 0.0 ), imath.V3f( 1.0, 0.0, 0.0 ), imath.V3f( 2.0, 0.0, 0.0 ), imath.V3f( 3.0, 0.0, 0.0 ) ] ) c = IECoreScene.CurvesPrimitive( i, IECore.CubicBasisf.bSpline(), False, p ) self.assert_( "myTangent" not in c ) @@ -58,7 +59,7 @@ def testTangentsGeneration( self ) : self.assertEqual( curves["myTangent"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) for v in curves["myTangent"].data : - self.failUnless( v.equalWithAbsError( IECore.V3f( 1, 0, 0 ), 0.000001 ) ) + self.failUnless( v.equalWithAbsError( imath.V3f( 1, 0, 0 ), 0.000001 ) ) if __name__ == "__main__": unittest.main() diff --git a/test/IECoreScene/CurvesAlgoTest.py b/test/IECoreScene/CurvesAlgoTest.py index b34e11b1b6..f62052b6be 100644 --- a/test/IECoreScene/CurvesAlgoTest.py +++ b/test/IECoreScene/CurvesAlgoTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene @@ -56,22 +57,22 @@ def curvesBSpline( self ) : False, IECore.V3fVectorData( [ - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 0, 0.75, 0 ), - IECore.V3f( 0.25, 1, 0 ), - IECore.V3f( 1, 1, 0 ), - IECore.V3f( 1, 1, 0 ), - IECore.V3f( 1, 1, 0 ), - IECore.V3f( 0, 0, 1 ), - IECore.V3f( 0, 0, 1 ), - IECore.V3f( 0, 0, 1 ), - IECore.V3f( 0, 0.75, 1 ), - IECore.V3f( 0.25, 1, 1 ), - IECore.V3f( 1, 1, 1 ), - IECore.V3f( 1, 1, 1 ), - IECore.V3f( 1, 1, 1 ) + imath.V3f( 0, 0, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 0, 0.75, 0 ), + imath.V3f( 0.25, 1, 0 ), + imath.V3f( 1, 1, 0 ), + imath.V3f( 1, 1, 0 ), + imath.V3f( 1, 1, 0 ), + imath.V3f( 0, 0, 1 ), + imath.V3f( 0, 0, 1 ), + imath.V3f( 0, 0, 1 ), + imath.V3f( 0, 0.75, 1 ), + imath.V3f( 0.25, 1, 1 ), + imath.V3f( 1, 1, 1 ), + imath.V3f( 1, 1, 1 ), + imath.V3f( 1, 1, 1 ) ] ) ) @@ -370,22 +371,22 @@ def curvesCatmullRom( self ) : False, IECore.V3fVectorData( [ - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 0, 0.75, 0 ), - IECore.V3f( 0.25, 1, 0 ), - IECore.V3f( 1, 1, 0 ), - IECore.V3f( 1, 1, 0 ), - IECore.V3f( 1, 1, 0 ), - IECore.V3f( 0, 0, 1 ), - IECore.V3f( 0, 0, 1 ), - IECore.V3f( 0, 0, 1 ), - IECore.V3f( 0, 0.75, 1 ), - IECore.V3f( 0.25, 1, 1 ), - IECore.V3f( 1, 1, 1 ), - IECore.V3f( 1, 1, 1 ), - IECore.V3f( 1, 1, 1 ) + imath.V3f( 0, 0, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 0, 0.75, 0 ), + imath.V3f( 0.25, 1, 0 ), + imath.V3f( 1, 1, 0 ), + imath.V3f( 1, 1, 0 ), + imath.V3f( 1, 1, 0 ), + imath.V3f( 0, 0, 1 ), + imath.V3f( 0, 0, 1 ), + imath.V3f( 0, 0, 1 ), + imath.V3f( 0, 0.75, 1 ), + imath.V3f( 0.25, 1, 1 ), + imath.V3f( 1, 1, 1 ), + imath.V3f( 1, 1, 1 ), + imath.V3f( 1, 1, 1 ) ] ) ) @@ -581,10 +582,10 @@ def curvesLinear( self ) : False, IECore.V3fVectorData( [ - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 0, 1, 0 ), - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 1, 0, 0 ) + imath.V3f( 0, 0, 0 ), + imath.V3f( 0, 1, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 1, 0, 0 ) ] ) ) @@ -779,21 +780,21 @@ def curvesBezier( self ) : False, IECore.V3fVectorData( [ - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 0, 1, 0 ), - IECore.V3f( 1, 1, 0 ), - IECore.V3f( 1, 0, 0 ), - IECore.V3f( 1, -1, 0 ), - IECore.V3f( 2, -1, 0 ), - IECore.V3f( 2, 0, 0 ), - - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 0, 0, 1 ), - IECore.V3f( 1, 0, 1 ), - IECore.V3f( 1, 0, 0 ), - IECore.V3f( 1, 0, -1 ), - IECore.V3f( 2, 0, -1 ), - IECore.V3f( 2, 0, 0 ) + imath.V3f( 0, 0, 0 ), + imath.V3f( 0, 1, 0 ), + imath.V3f( 1, 1, 0 ), + imath.V3f( 1, 0, 0 ), + imath.V3f( 1, -1, 0 ), + imath.V3f( 2, -1, 0 ), + imath.V3f( 2, 0, 0 ), + + imath.V3f( 0, 0, 0 ), + imath.V3f( 0, 0, 1 ), + imath.V3f( 1, 0, 1 ), + imath.V3f( 1, 0, 0 ), + imath.V3f( 1, 0, -1 ), + imath.V3f( 2, 0, -1 ), + imath.V3f( 2, 0, 0 ) ] ) ) @@ -977,10 +978,10 @@ def createLinearCurves(self): False, IECore.V3fVectorData( [ - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 0, 1, 0 ), - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 1, 0, 0 ) + imath.V3f( 0, 0, 0 ), + imath.V3f( 0, 1, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 1, 0, 0 ) ] ) ) @@ -1059,7 +1060,7 @@ def testOneArrayDeletesNoCurvesIfInverted(self): actualCurves = IECoreScene.CurvesAlgo.deleteCurves(curves, deletePrimVar, invert=True) self.assertEqual(actualCurves.numCurves(), 2) - self.assertEqual(actualCurves["P"].data, IECore.V3fVectorData( [ IECore.V3f( 0, 0, 0 ), IECore.V3f( 0, 1, 0 ), IECore.V3f( 0, 0, 0 ), IECore.V3f( 1, 0, 0 ) ] ) ) + self.assertEqual(actualCurves["P"].data, IECore.V3fVectorData( [ imath.V3f( 0, 0, 0 ), imath.V3f( 0, 1, 0 ), imath.V3f( 0, 0, 0 ), imath.V3f( 1, 0, 0 ) ] ) ) def testCanUseBoolArrayToDeleteAllCurves(self): deletePrimVar = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.BoolVectorData( [True, True] ) ) ) @@ -1075,7 +1076,7 @@ def testBoolArrayTrueDeletesNoCurvesIfInverted(self): actualCurves = IECoreScene.CurvesAlgo.deleteCurves(curves, deletePrimVar, invert=True) self.assertEqual(actualCurves.numCurves(), 2) - self.assertEqual(actualCurves["P"].data, IECore.V3fVectorData( [ IECore.V3f( 0, 0, 0 ), IECore.V3f( 0, 1, 0 ), IECore.V3f( 0, 0, 0 ), IECore.V3f( 1, 0, 0 ) ] ) ) + self.assertEqual(actualCurves["P"].data, IECore.V3fVectorData( [ imath.V3f( 0, 0, 0 ), imath.V3f( 0, 1, 0 ), imath.V3f( 0, 0, 0 ), imath.V3f( 1, 0, 0 ) ] ) ) def testCanUseFloatArrayToDeleteAllCurves(self): deletePrimVar = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.FloatVectorData( [0.1, 1.0] ) ) ) @@ -1091,7 +1092,7 @@ def testFloatArrayNonZeroDeletesNoCurvesIfInverted(self): actualCurves = IECoreScene.CurvesAlgo.deleteCurves(curves, deletePrimVar, invert=True) self.assertEqual(actualCurves.numCurves(), 2) - self.assertEqual(actualCurves["P"].data, IECore.V3fVectorData( [ IECore.V3f( 0, 0, 0 ), IECore.V3f( 0, 1, 0 ), IECore.V3f( 0, 0, 0 ), IECore.V3f( 1, 0, 0 ) ] ) ) + self.assertEqual(actualCurves["P"].data, IECore.V3fVectorData( [ imath.V3f( 0, 0, 0 ), imath.V3f( 0, 1, 0 ), imath.V3f( 0, 0, 0 ), imath.V3f( 1, 0, 0 ) ] ) ) def testPrimvarsAreDeleted(self): deletePrimVar = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.IntVectorData( [1, 0] ) ) ) @@ -1099,7 +1100,7 @@ def testPrimvarsAreDeleted(self): actualCurves = IECoreScene.CurvesAlgo.deleteCurves(curves, deletePrimVar) self.assertEqual(actualCurves.numCurves(), 1) - self.assertEqual( actualCurves["P"].data, IECore.V3fVectorData( [IECore.V3f( 0, 0, 0 ), IECore.V3f( 1, 0, 0 )] ) ) + self.assertEqual( actualCurves["P"].data, IECore.V3fVectorData( [imath.V3f( 0, 0, 0 ), imath.V3f( 1, 0, 0 )] ) ) self.assertEqual( actualCurves["a"].data, IECore.FloatData( 0.5 ) ) self.assertEqual( actualCurves["a"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant) @@ -1121,7 +1122,7 @@ def testPrimvarsAreDeletedIfInverted(self): actualCurves = IECoreScene.CurvesAlgo.deleteCurves(curves, deletePrimVar, invert=True) self.assertEqual(actualCurves.numCurves(), 1) - self.assertEqual( actualCurves["P"].data, IECore.V3fVectorData( [IECore.V3f( 0, 0, 0 ), IECore.V3f( 0, 1, 0 )] ) ) + self.assertEqual( actualCurves["P"].data, IECore.V3fVectorData( [imath.V3f( 0, 0, 0 ), imath.V3f( 0, 1, 0 )] ) ) self.assertEqual( actualCurves["a"].data, IECore.FloatData( 0.5 ) ) self.assertEqual( actualCurves["a"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Constant) diff --git a/test/IECoreScene/CurvesMergeOpTest.py b/test/IECoreScene/CurvesMergeOpTest.py index 6c8a86ecf2..075ae8ec36 100644 --- a/test/IECoreScene/CurvesMergeOpTest.py +++ b/test/IECoreScene/CurvesMergeOpTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene @@ -40,7 +41,7 @@ class CurvesMergeOpTest( unittest.TestCase ) : def test( self ) : - v = IECore.V3f + v = imath.V3f p1 = IECore.V3fVectorData( [ v( 0 ), v( 1 ), v( 2 ), v( 3 ) ], IECore.GeometricData.Interpretation.Point ) p2 = IECore.V3fVectorData( [ v( 4 ), v( 5 ), v( 6 ), v( 7 ), v( 8 ), v( 9 ), v( 10 ), v( 11 ) ] ) diff --git a/test/IECoreScene/CurvesPrimitiveEvaluatorTest.py b/test/IECoreScene/CurvesPrimitiveEvaluatorTest.py index af9ddadecc..09fc44e4ae 100644 --- a/test/IECoreScene/CurvesPrimitiveEvaluatorTest.py +++ b/test/IECoreScene/CurvesPrimitiveEvaluatorTest.py @@ -38,6 +38,7 @@ import threading import math import unittest +import imath import IECore import IECoreScene @@ -111,11 +112,11 @@ def runPointAtVTest( self, curvesPrimitive, expectedPositions=None, expectedLeng def testLinearSubsetLength( self ) : pts = IECore.V3fVectorData() - pts.append( IECore.V3f( 0,0,0 ) ) - pts.append( IECore.V3f( 1,0,0 ) ) - pts.append( IECore.V3f( 1,1,0 ) ) - pts.append( IECore.V3f( 2,1,0 ) ) - pts.append( IECore.V3f( 2,1,1 ) ) + pts.append( imath.V3f( 0,0,0 ) ) + pts.append( imath.V3f( 1,0,0 ) ) + pts.append( imath.V3f( 1,1,0 ) ) + pts.append( imath.V3f( 2,1,0 ) ) + pts.append( imath.V3f( 2,1,1 ) ) c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [len( pts )] ), IECore.CubicBasisf.linear(), False, pts ) e = IECoreScene.CurvesPrimitiveEvaluator( c ) @@ -126,12 +127,12 @@ def testLinearSubsetLength( self ) : def testCurveLengthAccuracy( self ) : pts = IECore.V3fVectorData() - pts.append( IECore.V3f( 0,0,0 ) ) - pts.append( IECore.V3f( 0,0,0 ) ) - pts.append( IECore.V3f( 0,0,0 ) ) - pts.append( IECore.V3f( 1000,0,0 ) ) - pts.append( IECore.V3f( 1000,0,0 ) ) - pts.append( IECore.V3f( 1000,0,0 ) ) + pts.append( imath.V3f( 0,0,0 ) ) + pts.append( imath.V3f( 0,0,0 ) ) + pts.append( imath.V3f( 0,0,0 ) ) + pts.append( imath.V3f( 1000,0,0 ) ) + pts.append( imath.V3f( 1000,0,0 ) ) + pts.append( imath.V3f( 1000,0,0 ) ) c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [len( pts )] ), IECore.CubicBasisf.bSpline(), False, pts ) e = IECoreScene.CurvesPrimitiveEvaluator( c ) @@ -140,15 +141,15 @@ def testCurveLengthAccuracy( self ) : # measure the length of a semicircle: pts = IECore.V3fVectorData() - pts.append( IECore.V3f( 1,0,0 ) ) - pts.append( IECore.V3f( 1,0,0 ) ) + pts.append( imath.V3f( 1,0,0 ) ) + pts.append( imath.V3f( 1,0,0 ) ) for i in range( 0,201 ): angle = math.pi * float(i) / 200 - pts.append( IECore.V3f( math.cos( angle ), math.sin( angle ), 0 ) ) + pts.append( imath.V3f( math.cos( angle ), math.sin( angle ), 0 ) ) - pts.append( IECore.V3f( -1,0,0 ) ) - pts.append( IECore.V3f( -1,0,0 ) ) + pts.append( imath.V3f( -1,0,0 ) ) + pts.append( imath.V3f( -1,0,0 ) ) c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [len( pts )] ), IECore.CubicBasisf.bSpline(), False, pts ) e = IECoreScene.CurvesPrimitiveEvaluator( c ) @@ -160,7 +161,7 @@ def testCurveLengthAccuracy( self ) : for i in range( 0,401 ): angle = 2 * math.pi * float(i) / 400 - pts.append( IECore.V3f( math.cos( angle ), math.sin( angle ), 0 ) ) + pts.append( imath.V3f( math.cos( angle ), math.sin( angle ), 0 ) ) c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [len( pts )] ), IECore.CubicBasisf.bSpline(), True, pts ) e = IECoreScene.CurvesPrimitiveEvaluator( c ) @@ -174,7 +175,7 @@ def testCurveLengthFreeze( self ) : pts = IECore.V3fVectorData() for i in range( 0,1008 ): - pts.append( IECore.V3f( i,0,0 ) ) + pts.append( imath.V3f( i,0,0 ) ) c = IECoreScene.CurvesPrimitive( @@ -190,7 +191,7 @@ def testCurveLengthFreeze( self ) : def test3SegmentBSpline( self ) : - v = IECore.V3f + v = imath.V3f c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 6 ] ), @@ -209,56 +210,56 @@ def test3SegmentBSpline( self ) : ) expected = IECore.V3fVectorData( [ - IECore.V3f( 0.166667, 0.166667, 0 ), - IECore.V3f( 0.199077, 0.137929, 0 ), - IECore.V3f( 0.234776, 0.112939, 0 ), - IECore.V3f( 0.273306, 0.0916979, 0 ), - IECore.V3f( 0.314207, 0.0742052, 0 ), - IECore.V3f( 0.357021, 0.0604609, 0 ), - IECore.V3f( 0.401288, 0.0504651, 0 ), - IECore.V3f( 0.44655, 0.0442177, 0 ), - IECore.V3f( 0.492347, 0.0417187, 0 ), - IECore.V3f( 0.538221, 0.0429682, 0 ), - IECore.V3f( 0.583712, 0.0479661, 0 ), - IECore.V3f( 0.628362, 0.0567125, 0 ), - IECore.V3f( 0.671711, 0.0692073, 0 ), - IECore.V3f( 0.713301, 0.0854505, 0 ), - IECore.V3f( 0.752673, 0.105442, 0 ), - IECore.V3f( 0.789366, 0.129182, 0 ), - IECore.V3f( 0.822924, 0.156671, 0 ), - IECore.V3f( 0.852931, 0.187885, 0 ), - IECore.V3f( 0.879502, 0.222539, 0 ), - IECore.V3f( 0.903089, 0.260176, 0 ), - IECore.V3f( 0.924152, 0.300338, 0 ), - IECore.V3f( 0.943149, 0.342566, 0 ), - IECore.V3f( 0.960539, 0.386399, 0 ), - IECore.V3f( 0.976783, 0.431381, 0 ), - IECore.V3f( 0.992337, 0.47705, 0 ), - IECore.V3f( 1.00766, 0.52295, 0 ), - IECore.V3f( 1.02322, 0.568619, 0 ), - IECore.V3f( 1.03946, 0.613601, 0 ), - IECore.V3f( 1.05685, 0.657435, 0 ), - IECore.V3f( 1.07585, 0.699662, 0 ), - IECore.V3f( 1.09691, 0.739824, 0 ), - IECore.V3f( 1.1205, 0.777461, 0 ), - IECore.V3f( 1.14707, 0.812115, 0 ), - IECore.V3f( 1.17708, 0.843329, 0 ), - IECore.V3f( 1.21063, 0.870818, 0 ), - IECore.V3f( 1.24733, 0.894558, 0 ), - IECore.V3f( 1.2867, 0.914549, 0 ), - IECore.V3f( 1.32829, 0.930793, 0 ), - IECore.V3f( 1.37164, 0.943287, 0 ), - IECore.V3f( 1.41629, 0.952034, 0 ), - IECore.V3f( 1.46178, 0.957032, 0 ), - IECore.V3f( 1.50765, 0.958281, 0 ), - IECore.V3f( 1.55345, 0.955782, 0 ), - IECore.V3f( 1.59871, 0.949535, 0 ), - IECore.V3f( 1.64298, 0.939539, 0 ), - IECore.V3f( 1.68579, 0.925795, 0 ), - IECore.V3f( 1.72669, 0.908302, 0 ), - IECore.V3f( 1.76522, 0.887061, 0 ), - IECore.V3f( 1.80092, 0.862071, 0 ), - IECore.V3f( 1.83333, 0.833333, 0 ) + imath.V3f( 0.166667, 0.166667, 0 ), + imath.V3f( 0.199077, 0.137929, 0 ), + imath.V3f( 0.234776, 0.112939, 0 ), + imath.V3f( 0.273306, 0.0916979, 0 ), + imath.V3f( 0.314207, 0.0742052, 0 ), + imath.V3f( 0.357021, 0.0604609, 0 ), + imath.V3f( 0.401288, 0.0504651, 0 ), + imath.V3f( 0.44655, 0.0442177, 0 ), + imath.V3f( 0.492347, 0.0417187, 0 ), + imath.V3f( 0.538221, 0.0429682, 0 ), + imath.V3f( 0.583712, 0.0479661, 0 ), + imath.V3f( 0.628362, 0.0567125, 0 ), + imath.V3f( 0.671711, 0.0692073, 0 ), + imath.V3f( 0.713301, 0.0854505, 0 ), + imath.V3f( 0.752673, 0.105442, 0 ), + imath.V3f( 0.789366, 0.129182, 0 ), + imath.V3f( 0.822924, 0.156671, 0 ), + imath.V3f( 0.852931, 0.187885, 0 ), + imath.V3f( 0.879502, 0.222539, 0 ), + imath.V3f( 0.903089, 0.260176, 0 ), + imath.V3f( 0.924152, 0.300338, 0 ), + imath.V3f( 0.943149, 0.342566, 0 ), + imath.V3f( 0.960539, 0.386399, 0 ), + imath.V3f( 0.976783, 0.431381, 0 ), + imath.V3f( 0.992337, 0.47705, 0 ), + imath.V3f( 1.00766, 0.52295, 0 ), + imath.V3f( 1.02322, 0.568619, 0 ), + imath.V3f( 1.03946, 0.613601, 0 ), + imath.V3f( 1.05685, 0.657435, 0 ), + imath.V3f( 1.07585, 0.699662, 0 ), + imath.V3f( 1.09691, 0.739824, 0 ), + imath.V3f( 1.1205, 0.777461, 0 ), + imath.V3f( 1.14707, 0.812115, 0 ), + imath.V3f( 1.17708, 0.843329, 0 ), + imath.V3f( 1.21063, 0.870818, 0 ), + imath.V3f( 1.24733, 0.894558, 0 ), + imath.V3f( 1.2867, 0.914549, 0 ), + imath.V3f( 1.32829, 0.930793, 0 ), + imath.V3f( 1.37164, 0.943287, 0 ), + imath.V3f( 1.41629, 0.952034, 0 ), + imath.V3f( 1.46178, 0.957032, 0 ), + imath.V3f( 1.50765, 0.958281, 0 ), + imath.V3f( 1.55345, 0.955782, 0 ), + imath.V3f( 1.59871, 0.949535, 0 ), + imath.V3f( 1.64298, 0.939539, 0 ), + imath.V3f( 1.68579, 0.925795, 0 ), + imath.V3f( 1.72669, 0.908302, 0 ), + imath.V3f( 1.76522, 0.887061, 0 ), + imath.V3f( 1.80092, 0.862071, 0 ), + imath.V3f( 1.83333, 0.833333, 0 ) ] ) lengths = IECore.FloatVectorData( [ 2.2106194496154785 ] ) @@ -267,7 +268,7 @@ def test3SegmentBSpline( self ) : def test3SegmentBSplineDoubledEndpoints( self ) : - v = IECore.V3f + v = imath.V3f c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 8 ] ), @@ -288,56 +289,56 @@ def test3SegmentBSplineDoubledEndpoints( self ) : ) expected = IECore.V3fVectorData( [ - IECore.V3f( 0, 0.833333, 0 ), - IECore.V3f( 0.00017708, 0.777461, 0 ), - IECore.V3f( 0.00141664, 0.713301, 0 ), - IECore.V3f( 0.00478117, 0.642979, 0 ), - IECore.V3f( 0.0113331, 0.568619, 0 ), - IECore.V3f( 0.0221351, 0.492347, 0 ), - IECore.V3f( 0.0382494, 0.416288, 0 ), - IECore.V3f( 0.0607386, 0.342566, 0 ), - IECore.V3f( 0.0906652, 0.273306, 0 ), - IECore.V3f( 0.129092, 0.210634, 0 ), - IECore.V3f( 0.177076, 0.156671, 0 ), - IECore.V3f( 0.234776, 0.112939, 0 ), - IECore.V3f( 0.300338, 0.0796196, 0 ), - IECore.V3f( 0.371638, 0.0567125, 0 ), - IECore.V3f( 0.44655, 0.0442177, 0 ), - IECore.V3f( 0.52295, 0.0421352, 0 ), - IECore.V3f( 0.598712, 0.0504651, 0 ), - IECore.V3f( 0.671711, 0.0692073, 0 ), - IECore.V3f( 0.739824, 0.0983618, 0 ), - IECore.V3f( 0.800923, 0.137929, 0 ), - IECore.V3f( 0.852931, 0.187885, 0 ), - IECore.V3f( 0.89553, 0.247327, 0 ), - IECore.V3f( 0.930691, 0.314207, 0 ), - IECore.V3f( 0.960539, 0.386399, 0 ), - IECore.V3f( 0.987201, 0.461779, 0 ), - IECore.V3f( 1.0128, 0.538221, 0 ), - IECore.V3f( 1.03946, 0.613601, 0 ), - IECore.V3f( 1.06931, 0.685793, 0 ), - IECore.V3f( 1.10447, 0.752673, 0 ), - IECore.V3f( 1.14707, 0.812115, 0 ), - IECore.V3f( 1.19908, 0.862071, 0 ), - IECore.V3f( 1.26018, 0.901638, 0 ), - IECore.V3f( 1.32829, 0.930793, 0 ), - IECore.V3f( 1.40129, 0.949535, 0 ), - IECore.V3f( 1.47705, 0.957865, 0 ), - IECore.V3f( 1.55345, 0.955782, 0 ), - IECore.V3f( 1.62836, 0.943288, 0 ), - IECore.V3f( 1.69966, 0.92038, 0 ), - IECore.V3f( 1.76522, 0.887061, 0 ), - IECore.V3f( 1.82292, 0.843329, 0 ), - IECore.V3f( 1.87091, 0.789366, 0 ), - IECore.V3f( 1.90933, 0.726694, 0 ), - IECore.V3f( 1.93926, 0.657435, 0 ), - IECore.V3f( 1.96175, 0.583712, 0 ), - IECore.V3f( 1.97786, 0.507653, 0 ), - IECore.V3f( 1.98867, 0.431381, 0 ), - IECore.V3f( 1.99522, 0.357021, 0 ), - IECore.V3f( 1.99858, 0.286699, 0 ), - IECore.V3f( 1.99982, 0.222539, 0 ), - IECore.V3f( 2, 0.166667, 0 ) ] ) + imath.V3f( 0, 0.833333, 0 ), + imath.V3f( 0.00017708, 0.777461, 0 ), + imath.V3f( 0.00141664, 0.713301, 0 ), + imath.V3f( 0.00478117, 0.642979, 0 ), + imath.V3f( 0.0113331, 0.568619, 0 ), + imath.V3f( 0.0221351, 0.492347, 0 ), + imath.V3f( 0.0382494, 0.416288, 0 ), + imath.V3f( 0.0607386, 0.342566, 0 ), + imath.V3f( 0.0906652, 0.273306, 0 ), + imath.V3f( 0.129092, 0.210634, 0 ), + imath.V3f( 0.177076, 0.156671, 0 ), + imath.V3f( 0.234776, 0.112939, 0 ), + imath.V3f( 0.300338, 0.0796196, 0 ), + imath.V3f( 0.371638, 0.0567125, 0 ), + imath.V3f( 0.44655, 0.0442177, 0 ), + imath.V3f( 0.52295, 0.0421352, 0 ), + imath.V3f( 0.598712, 0.0504651, 0 ), + imath.V3f( 0.671711, 0.0692073, 0 ), + imath.V3f( 0.739824, 0.0983618, 0 ), + imath.V3f( 0.800923, 0.137929, 0 ), + imath.V3f( 0.852931, 0.187885, 0 ), + imath.V3f( 0.89553, 0.247327, 0 ), + imath.V3f( 0.930691, 0.314207, 0 ), + imath.V3f( 0.960539, 0.386399, 0 ), + imath.V3f( 0.987201, 0.461779, 0 ), + imath.V3f( 1.0128, 0.538221, 0 ), + imath.V3f( 1.03946, 0.613601, 0 ), + imath.V3f( 1.06931, 0.685793, 0 ), + imath.V3f( 1.10447, 0.752673, 0 ), + imath.V3f( 1.14707, 0.812115, 0 ), + imath.V3f( 1.19908, 0.862071, 0 ), + imath.V3f( 1.26018, 0.901638, 0 ), + imath.V3f( 1.32829, 0.930793, 0 ), + imath.V3f( 1.40129, 0.949535, 0 ), + imath.V3f( 1.47705, 0.957865, 0 ), + imath.V3f( 1.55345, 0.955782, 0 ), + imath.V3f( 1.62836, 0.943288, 0 ), + imath.V3f( 1.69966, 0.92038, 0 ), + imath.V3f( 1.76522, 0.887061, 0 ), + imath.V3f( 1.82292, 0.843329, 0 ), + imath.V3f( 1.87091, 0.789366, 0 ), + imath.V3f( 1.90933, 0.726694, 0 ), + imath.V3f( 1.93926, 0.657435, 0 ), + imath.V3f( 1.96175, 0.583712, 0 ), + imath.V3f( 1.97786, 0.507653, 0 ), + imath.V3f( 1.98867, 0.431381, 0 ), + imath.V3f( 1.99522, 0.357021, 0 ), + imath.V3f( 1.99858, 0.286699, 0 ), + imath.V3f( 1.99982, 0.222539, 0 ), + imath.V3f( 2, 0.166667, 0 ) ] ) lengths = IECore.FloatVectorData( [ 3.61808 ] ) @@ -345,7 +346,7 @@ def test3SegmentBSplineDoubledEndpoints( self ) : def test2Curve3SegmentBSpline( self ) : - v = IECore.V3f + v = imath.V3f c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 6, 6 ] ), @@ -370,106 +371,106 @@ def test2Curve3SegmentBSpline( self ) : ) expected = IECore.V3fVectorData( [ - IECore.V3f( 0.166667, 0.166667, 0 ), - IECore.V3f( 0.199077, 0.137929, 0 ), - IECore.V3f( 0.234776, 0.112939, 0 ), - IECore.V3f( 0.273306, 0.0916979, 0 ), - IECore.V3f( 0.314207, 0.0742052, 0 ), - IECore.V3f( 0.357021, 0.0604609, 0 ), - IECore.V3f( 0.401288, 0.0504651, 0 ), - IECore.V3f( 0.44655, 0.0442177, 0 ), - IECore.V3f( 0.492347, 0.0417187, 0 ), - IECore.V3f( 0.538221, 0.0429682, 0 ), - IECore.V3f( 0.583712, 0.0479661, 0 ), - IECore.V3f( 0.628362, 0.0567125, 0 ), - IECore.V3f( 0.671711, 0.0692073, 0 ), - IECore.V3f( 0.713301, 0.0854505, 0 ), - IECore.V3f( 0.752673, 0.105442, 0 ), - IECore.V3f( 0.789366, 0.129182, 0 ), - IECore.V3f( 0.822924, 0.156671, 0 ), - IECore.V3f( 0.852931, 0.187885, 0 ), - IECore.V3f( 0.879502, 0.222539, 0 ), - IECore.V3f( 0.903089, 0.260176, 0 ), - IECore.V3f( 0.924152, 0.300338, 0 ), - IECore.V3f( 0.943149, 0.342566, 0 ), - IECore.V3f( 0.960539, 0.386399, 0 ), - IECore.V3f( 0.976783, 0.431381, 0 ), - IECore.V3f( 0.992337, 0.47705, 0 ), - IECore.V3f( 1.00766, 0.52295, 0 ), - IECore.V3f( 1.02322, 0.568619, 0 ), - IECore.V3f( 1.03946, 0.613601, 0 ), - IECore.V3f( 1.05685, 0.657435, 0 ), - IECore.V3f( 1.07585, 0.699662, 0 ), - IECore.V3f( 1.09691, 0.739824, 0 ), - IECore.V3f( 1.1205, 0.777461, 0 ), - IECore.V3f( 1.14707, 0.812115, 0 ), - IECore.V3f( 1.17708, 0.843329, 0 ), - IECore.V3f( 1.21063, 0.870818, 0 ), - IECore.V3f( 1.24733, 0.894558, 0 ), - IECore.V3f( 1.2867, 0.914549, 0 ), - IECore.V3f( 1.32829, 0.930793, 0 ), - IECore.V3f( 1.37164, 0.943287, 0 ), - IECore.V3f( 1.41629, 0.952034, 0 ), - IECore.V3f( 1.46178, 0.957032, 0 ), - IECore.V3f( 1.50765, 0.958281, 0 ), - IECore.V3f( 1.55345, 0.955782, 0 ), - IECore.V3f( 1.59871, 0.949535, 0 ), - IECore.V3f( 1.64298, 0.939539, 0 ), - IECore.V3f( 1.68579, 0.925795, 0 ), - IECore.V3f( 1.72669, 0.908302, 0 ), - IECore.V3f( 1.76522, 0.887061, 0 ), - IECore.V3f( 1.80092, 0.862071, 0 ), - IECore.V3f( 1.83333, 0.833333, 0 ), - IECore.V3f( 0.166667, 1.16667, 0 ), - IECore.V3f( 0.199077, 1.13793, 0 ), - IECore.V3f( 0.234776, 1.11294, 0 ), - IECore.V3f( 0.273306, 1.0917, 0 ), - IECore.V3f( 0.314207, 1.07421, 0 ), - IECore.V3f( 0.357021, 1.06046, 0 ), - IECore.V3f( 0.401288, 1.05047, 0 ), - IECore.V3f( 0.44655, 1.04422, 0 ), - IECore.V3f( 0.492347, 1.04172, 0 ), - IECore.V3f( 0.538221, 1.04297, 0 ), - IECore.V3f( 0.583712, 1.04797, 0 ), - IECore.V3f( 0.628362, 1.05671, 0 ), - IECore.V3f( 0.671711, 1.06921, 0 ), - IECore.V3f( 0.713301, 1.08545, 0 ), - IECore.V3f( 0.752673, 1.10544, 0 ), - IECore.V3f( 0.789366, 1.12918, 0 ), - IECore.V3f( 0.822924, 1.15667, 0 ), - IECore.V3f( 0.852931, 1.18789, 0 ), - IECore.V3f( 0.879502, 1.22254, 0 ), - IECore.V3f( 0.903089, 1.26018, 0 ), - IECore.V3f( 0.924152, 1.30034, 0 ), - IECore.V3f( 0.943149, 1.34257, 0 ), - IECore.V3f( 0.960539, 1.3864, 0 ), - IECore.V3f( 0.976783, 1.43138, 0 ), - IECore.V3f( 0.992337, 1.47705, 0 ), - IECore.V3f( 1.00766, 1.52295, 0 ), - IECore.V3f( 1.02322, 1.56862, 0 ), - IECore.V3f( 1.03946, 1.6136, 0 ), - IECore.V3f( 1.05685, 1.65743, 0 ), - IECore.V3f( 1.07585, 1.69966, 0 ), - IECore.V3f( 1.09691, 1.73982, 0 ), - IECore.V3f( 1.1205, 1.77746, 0 ), - IECore.V3f( 1.14707, 1.81211, 0 ), - IECore.V3f( 1.17708, 1.84333, 0 ), - IECore.V3f( 1.21063, 1.87082, 0 ), - IECore.V3f( 1.24733, 1.89456, 0 ), - IECore.V3f( 1.2867, 1.91455, 0 ), - IECore.V3f( 1.32829, 1.93079, 0 ), - IECore.V3f( 1.37164, 1.94329, 0 ), - IECore.V3f( 1.41629, 1.95203, 0 ), - IECore.V3f( 1.46178, 1.95703, 0 ), - IECore.V3f( 1.50765, 1.95828, 0 ), - IECore.V3f( 1.55345, 1.95578, 0 ), - IECore.V3f( 1.59871, 1.94954, 0 ), - IECore.V3f( 1.64298, 1.93954, 0 ), - IECore.V3f( 1.68579, 1.92579, 0 ), - IECore.V3f( 1.72669, 1.9083, 0 ), - IECore.V3f( 1.76522, 1.88706, 0 ), - IECore.V3f( 1.80092, 1.86207, 0 ), - IECore.V3f( 1.83333, 1.83333, 0 ) + imath.V3f( 0.166667, 0.166667, 0 ), + imath.V3f( 0.199077, 0.137929, 0 ), + imath.V3f( 0.234776, 0.112939, 0 ), + imath.V3f( 0.273306, 0.0916979, 0 ), + imath.V3f( 0.314207, 0.0742052, 0 ), + imath.V3f( 0.357021, 0.0604609, 0 ), + imath.V3f( 0.401288, 0.0504651, 0 ), + imath.V3f( 0.44655, 0.0442177, 0 ), + imath.V3f( 0.492347, 0.0417187, 0 ), + imath.V3f( 0.538221, 0.0429682, 0 ), + imath.V3f( 0.583712, 0.0479661, 0 ), + imath.V3f( 0.628362, 0.0567125, 0 ), + imath.V3f( 0.671711, 0.0692073, 0 ), + imath.V3f( 0.713301, 0.0854505, 0 ), + imath.V3f( 0.752673, 0.105442, 0 ), + imath.V3f( 0.789366, 0.129182, 0 ), + imath.V3f( 0.822924, 0.156671, 0 ), + imath.V3f( 0.852931, 0.187885, 0 ), + imath.V3f( 0.879502, 0.222539, 0 ), + imath.V3f( 0.903089, 0.260176, 0 ), + imath.V3f( 0.924152, 0.300338, 0 ), + imath.V3f( 0.943149, 0.342566, 0 ), + imath.V3f( 0.960539, 0.386399, 0 ), + imath.V3f( 0.976783, 0.431381, 0 ), + imath.V3f( 0.992337, 0.47705, 0 ), + imath.V3f( 1.00766, 0.52295, 0 ), + imath.V3f( 1.02322, 0.568619, 0 ), + imath.V3f( 1.03946, 0.613601, 0 ), + imath.V3f( 1.05685, 0.657435, 0 ), + imath.V3f( 1.07585, 0.699662, 0 ), + imath.V3f( 1.09691, 0.739824, 0 ), + imath.V3f( 1.1205, 0.777461, 0 ), + imath.V3f( 1.14707, 0.812115, 0 ), + imath.V3f( 1.17708, 0.843329, 0 ), + imath.V3f( 1.21063, 0.870818, 0 ), + imath.V3f( 1.24733, 0.894558, 0 ), + imath.V3f( 1.2867, 0.914549, 0 ), + imath.V3f( 1.32829, 0.930793, 0 ), + imath.V3f( 1.37164, 0.943287, 0 ), + imath.V3f( 1.41629, 0.952034, 0 ), + imath.V3f( 1.46178, 0.957032, 0 ), + imath.V3f( 1.50765, 0.958281, 0 ), + imath.V3f( 1.55345, 0.955782, 0 ), + imath.V3f( 1.59871, 0.949535, 0 ), + imath.V3f( 1.64298, 0.939539, 0 ), + imath.V3f( 1.68579, 0.925795, 0 ), + imath.V3f( 1.72669, 0.908302, 0 ), + imath.V3f( 1.76522, 0.887061, 0 ), + imath.V3f( 1.80092, 0.862071, 0 ), + imath.V3f( 1.83333, 0.833333, 0 ), + imath.V3f( 0.166667, 1.16667, 0 ), + imath.V3f( 0.199077, 1.13793, 0 ), + imath.V3f( 0.234776, 1.11294, 0 ), + imath.V3f( 0.273306, 1.0917, 0 ), + imath.V3f( 0.314207, 1.07421, 0 ), + imath.V3f( 0.357021, 1.06046, 0 ), + imath.V3f( 0.401288, 1.05047, 0 ), + imath.V3f( 0.44655, 1.04422, 0 ), + imath.V3f( 0.492347, 1.04172, 0 ), + imath.V3f( 0.538221, 1.04297, 0 ), + imath.V3f( 0.583712, 1.04797, 0 ), + imath.V3f( 0.628362, 1.05671, 0 ), + imath.V3f( 0.671711, 1.06921, 0 ), + imath.V3f( 0.713301, 1.08545, 0 ), + imath.V3f( 0.752673, 1.10544, 0 ), + imath.V3f( 0.789366, 1.12918, 0 ), + imath.V3f( 0.822924, 1.15667, 0 ), + imath.V3f( 0.852931, 1.18789, 0 ), + imath.V3f( 0.879502, 1.22254, 0 ), + imath.V3f( 0.903089, 1.26018, 0 ), + imath.V3f( 0.924152, 1.30034, 0 ), + imath.V3f( 0.943149, 1.34257, 0 ), + imath.V3f( 0.960539, 1.3864, 0 ), + imath.V3f( 0.976783, 1.43138, 0 ), + imath.V3f( 0.992337, 1.47705, 0 ), + imath.V3f( 1.00766, 1.52295, 0 ), + imath.V3f( 1.02322, 1.56862, 0 ), + imath.V3f( 1.03946, 1.6136, 0 ), + imath.V3f( 1.05685, 1.65743, 0 ), + imath.V3f( 1.07585, 1.69966, 0 ), + imath.V3f( 1.09691, 1.73982, 0 ), + imath.V3f( 1.1205, 1.77746, 0 ), + imath.V3f( 1.14707, 1.81211, 0 ), + imath.V3f( 1.17708, 1.84333, 0 ), + imath.V3f( 1.21063, 1.87082, 0 ), + imath.V3f( 1.24733, 1.89456, 0 ), + imath.V3f( 1.2867, 1.91455, 0 ), + imath.V3f( 1.32829, 1.93079, 0 ), + imath.V3f( 1.37164, 1.94329, 0 ), + imath.V3f( 1.41629, 1.95203, 0 ), + imath.V3f( 1.46178, 1.95703, 0 ), + imath.V3f( 1.50765, 1.95828, 0 ), + imath.V3f( 1.55345, 1.95578, 0 ), + imath.V3f( 1.59871, 1.94954, 0 ), + imath.V3f( 1.64298, 1.93954, 0 ), + imath.V3f( 1.68579, 1.92579, 0 ), + imath.V3f( 1.72669, 1.9083, 0 ), + imath.V3f( 1.76522, 1.88706, 0 ), + imath.V3f( 1.80092, 1.86207, 0 ), + imath.V3f( 1.83333, 1.83333, 0 ) ] ) lengths = IECore.FloatVectorData( [ 2.2106194496154785, 2.2106194496154785 ] ) @@ -478,7 +479,7 @@ def test2Curve3SegmentBSpline( self ) : def testPeriodicBSpline( self ) : - v = IECore.V3f + v = imath.V3f c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 4 ] ), @@ -495,56 +496,56 @@ def testPeriodicBSpline( self ) : ) expected = IECore.V3fVectorData( [ - IECore.V3f( 0.166667, 0.166667, 0 ), - IECore.V3f( 0.210634, 0.129182, 0 ), - IECore.V3f( 0.260176, 0.0983618, 0 ), - IECore.V3f( 0.314207, 0.0742052, 0 ), - IECore.V3f( 0.371638, 0.0567125, 0 ), - IECore.V3f( 0.431381, 0.0458837, 0 ), - IECore.V3f( 0.492347, 0.0417187, 0 ), - IECore.V3f( 0.55345, 0.0442177, 0 ), - IECore.V3f( 0.613601, 0.0533805, 0 ), - IECore.V3f( 0.671711, 0.0692073, 0 ), - IECore.V3f( 0.726694, 0.0916979, 0 ), - IECore.V3f( 0.777461, 0.120852, 0 ), - IECore.V3f( 0.822924, 0.156671, 0 ), - IECore.V3f( 0.862071, 0.199077, 0 ), - IECore.V3f( 0.894558, 0.247328, 0 ), - IECore.V3f( 0.92038, 0.300338, 0 ), - IECore.V3f( 0.939539, 0.357021, 0 ), - IECore.V3f( 0.952034, 0.416288, 0 ), - IECore.V3f( 0.957865, 0.47705, 0 ), - IECore.V3f( 0.957032, 0.538221, 0 ), - IECore.V3f( 0.949535, 0.598712, 0 ), - IECore.V3f( 0.935374, 0.657434, 0 ), - IECore.V3f( 0.914549, 0.713301, 0 ), - IECore.V3f( 0.887061, 0.765224, 0 ), - IECore.V3f( 0.852909, 0.812115, 0 ), - IECore.V3f( 0.812115, 0.852908, 0 ), - IECore.V3f( 0.765224, 0.887061, 0 ), - IECore.V3f( 0.713301, 0.914549, 0 ), - IECore.V3f( 0.657434, 0.935374, 0 ), - IECore.V3f( 0.598712, 0.949535, 0 ), - IECore.V3f( 0.538221, 0.957032, 0 ), - IECore.V3f( 0.47705, 0.957865, 0 ), - IECore.V3f( 0.416288, 0.952034, 0 ), - IECore.V3f( 0.357021, 0.939539, 0 ), - IECore.V3f( 0.300338, 0.92038, 0 ), - IECore.V3f( 0.247327, 0.894558, 0 ), - IECore.V3f( 0.199077, 0.862071, 0 ), - IECore.V3f( 0.156671, 0.822924, 0 ), - IECore.V3f( 0.120852, 0.777461, 0 ), - IECore.V3f( 0.0916979, 0.726694, 0 ), - IECore.V3f( 0.0692073, 0.671711, 0 ), - IECore.V3f( 0.0533805, 0.613601, 0 ), - IECore.V3f( 0.0442177, 0.55345, 0 ), - IECore.V3f( 0.0417187, 0.492347, 0 ), - IECore.V3f( 0.0458837, 0.431381, 0 ), - IECore.V3f( 0.0567125, 0.371638, 0 ), - IECore.V3f( 0.0742052, 0.314207, 0 ), - IECore.V3f( 0.0983618, 0.260176, 0 ), - IECore.V3f( 0.129182, 0.210634, 0 ), - IECore.V3f( 0.166667, 0.166667, 0 ) + imath.V3f( 0.166667, 0.166667, 0 ), + imath.V3f( 0.210634, 0.129182, 0 ), + imath.V3f( 0.260176, 0.0983618, 0 ), + imath.V3f( 0.314207, 0.0742052, 0 ), + imath.V3f( 0.371638, 0.0567125, 0 ), + imath.V3f( 0.431381, 0.0458837, 0 ), + imath.V3f( 0.492347, 0.0417187, 0 ), + imath.V3f( 0.55345, 0.0442177, 0 ), + imath.V3f( 0.613601, 0.0533805, 0 ), + imath.V3f( 0.671711, 0.0692073, 0 ), + imath.V3f( 0.726694, 0.0916979, 0 ), + imath.V3f( 0.777461, 0.120852, 0 ), + imath.V3f( 0.822924, 0.156671, 0 ), + imath.V3f( 0.862071, 0.199077, 0 ), + imath.V3f( 0.894558, 0.247328, 0 ), + imath.V3f( 0.92038, 0.300338, 0 ), + imath.V3f( 0.939539, 0.357021, 0 ), + imath.V3f( 0.952034, 0.416288, 0 ), + imath.V3f( 0.957865, 0.47705, 0 ), + imath.V3f( 0.957032, 0.538221, 0 ), + imath.V3f( 0.949535, 0.598712, 0 ), + imath.V3f( 0.935374, 0.657434, 0 ), + imath.V3f( 0.914549, 0.713301, 0 ), + imath.V3f( 0.887061, 0.765224, 0 ), + imath.V3f( 0.852909, 0.812115, 0 ), + imath.V3f( 0.812115, 0.852908, 0 ), + imath.V3f( 0.765224, 0.887061, 0 ), + imath.V3f( 0.713301, 0.914549, 0 ), + imath.V3f( 0.657434, 0.935374, 0 ), + imath.V3f( 0.598712, 0.949535, 0 ), + imath.V3f( 0.538221, 0.957032, 0 ), + imath.V3f( 0.47705, 0.957865, 0 ), + imath.V3f( 0.416288, 0.952034, 0 ), + imath.V3f( 0.357021, 0.939539, 0 ), + imath.V3f( 0.300338, 0.92038, 0 ), + imath.V3f( 0.247327, 0.894558, 0 ), + imath.V3f( 0.199077, 0.862071, 0 ), + imath.V3f( 0.156671, 0.822924, 0 ), + imath.V3f( 0.120852, 0.777461, 0 ), + imath.V3f( 0.0916979, 0.726694, 0 ), + imath.V3f( 0.0692073, 0.671711, 0 ), + imath.V3f( 0.0533805, 0.613601, 0 ), + imath.V3f( 0.0442177, 0.55345, 0 ), + imath.V3f( 0.0417187, 0.492347, 0 ), + imath.V3f( 0.0458837, 0.431381, 0 ), + imath.V3f( 0.0567125, 0.371638, 0 ), + imath.V3f( 0.0742052, 0.314207, 0 ), + imath.V3f( 0.0983618, 0.260176, 0 ), + imath.V3f( 0.129182, 0.210634, 0 ), + imath.V3f( 0.166667, 0.166667, 0 ) ] ) lengths = IECore.FloatVectorData( [ 2.917539119 ] ) @@ -553,7 +554,7 @@ def testPeriodicBSpline( self ) : def test2CurvePeriodicBSpline( self ) : - v = IECore.V3f + v = imath.V3f c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 4, 4 ] ), @@ -574,106 +575,106 @@ def test2CurvePeriodicBSpline( self ) : ) expected = IECore.V3fVectorData( [ - IECore.V3f( 0.166667, 0.166667, 0 ), - IECore.V3f( 0.210634, 0.129182, 0 ), - IECore.V3f( 0.260176, 0.0983618, 0 ), - IECore.V3f( 0.314207, 0.0742052, 0 ), - IECore.V3f( 0.371638, 0.0567125, 0 ), - IECore.V3f( 0.431381, 0.0458837, 0 ), - IECore.V3f( 0.492347, 0.0417187, 0 ), - IECore.V3f( 0.55345, 0.0442177, 0 ), - IECore.V3f( 0.613601, 0.0533805, 0 ), - IECore.V3f( 0.671711, 0.0692073, 0 ), - IECore.V3f( 0.726694, 0.0916979, 0 ), - IECore.V3f( 0.777461, 0.120852, 0 ), - IECore.V3f( 0.822924, 0.156671, 0 ), - IECore.V3f( 0.862071, 0.199077, 0 ), - IECore.V3f( 0.894558, 0.247328, 0 ), - IECore.V3f( 0.92038, 0.300338, 0 ), - IECore.V3f( 0.939539, 0.357021, 0 ), - IECore.V3f( 0.952034, 0.416288, 0 ), - IECore.V3f( 0.957865, 0.47705, 0 ), - IECore.V3f( 0.957032, 0.538221, 0 ), - IECore.V3f( 0.949535, 0.598712, 0 ), - IECore.V3f( 0.935374, 0.657434, 0 ), - IECore.V3f( 0.914549, 0.713301, 0 ), - IECore.V3f( 0.887061, 0.765224, 0 ), - IECore.V3f( 0.852909, 0.812115, 0 ), - IECore.V3f( 0.812115, 0.852908, 0 ), - IECore.V3f( 0.765224, 0.887061, 0 ), - IECore.V3f( 0.713301, 0.914549, 0 ), - IECore.V3f( 0.657434, 0.935374, 0 ), - IECore.V3f( 0.598712, 0.949535, 0 ), - IECore.V3f( 0.538221, 0.957032, 0 ), - IECore.V3f( 0.47705, 0.957865, 0 ), - IECore.V3f( 0.416288, 0.952034, 0 ), - IECore.V3f( 0.357021, 0.939539, 0 ), - IECore.V3f( 0.300338, 0.92038, 0 ), - IECore.V3f( 0.247327, 0.894558, 0 ), - IECore.V3f( 0.199077, 0.862071, 0 ), - IECore.V3f( 0.156671, 0.822924, 0 ), - IECore.V3f( 0.120852, 0.777461, 0 ), - IECore.V3f( 0.0916979, 0.726694, 0 ), - IECore.V3f( 0.0692073, 0.671711, 0 ), - IECore.V3f( 0.0533805, 0.613601, 0 ), - IECore.V3f( 0.0442177, 0.55345, 0 ), - IECore.V3f( 0.0417187, 0.492347, 0 ), - IECore.V3f( 0.0458837, 0.431381, 0 ), - IECore.V3f( 0.0567125, 0.371638, 0 ), - IECore.V3f( 0.0742052, 0.314207, 0 ), - IECore.V3f( 0.0983618, 0.260176, 0 ), - IECore.V3f( 0.129182, 0.210634, 0 ), - IECore.V3f( 0.166667, 0.166667, 0 ), - IECore.V3f( 0.166667, 1.16667, 0 ), - IECore.V3f( 0.210634, 1.12918, 0 ), - IECore.V3f( 0.260176, 1.09836, 0 ), - IECore.V3f( 0.314207, 1.07421, 0 ), - IECore.V3f( 0.371638, 1.05671, 0 ), - IECore.V3f( 0.431381, 1.04588, 0 ), - IECore.V3f( 0.492347, 1.04172, 0 ), - IECore.V3f( 0.55345, 1.04422, 0 ), - IECore.V3f( 0.613601, 1.05338, 0 ), - IECore.V3f( 0.671711, 1.06921, 0 ), - IECore.V3f( 0.726694, 1.0917, 0 ), - IECore.V3f( 0.777461, 1.12085, 0 ), - IECore.V3f( 0.822924, 1.15667, 0 ), - IECore.V3f( 0.862071, 1.19908, 0 ), - IECore.V3f( 0.894558, 1.24733, 0 ), - IECore.V3f( 0.92038, 1.30034, 0 ), - IECore.V3f( 0.939539, 1.35702, 0 ), - IECore.V3f( 0.952034, 1.41629, 0 ), - IECore.V3f( 0.957865, 1.47705, 0 ), - IECore.V3f( 0.957032, 1.53822, 0 ), - IECore.V3f( 0.949535, 1.59871, 0 ), - IECore.V3f( 0.935374, 1.65743, 0 ), - IECore.V3f( 0.914549, 1.7133, 0 ), - IECore.V3f( 0.887061, 1.76522, 0 ), - IECore.V3f( 0.852909, 1.81211, 0 ), - IECore.V3f( 0.812115, 1.85291, 0 ), - IECore.V3f( 0.765224, 1.88706, 0 ), - IECore.V3f( 0.713301, 1.91455, 0 ), - IECore.V3f( 0.657434, 1.93537, 0 ), - IECore.V3f( 0.598712, 1.94954, 0 ), - IECore.V3f( 0.538221, 1.95703, 0 ), - IECore.V3f( 0.47705, 1.95786, 0 ), - IECore.V3f( 0.416288, 1.95203, 0 ), - IECore.V3f( 0.357021, 1.93954, 0 ), - IECore.V3f( 0.300338, 1.92038, 0 ), - IECore.V3f( 0.247327, 1.89456, 0 ), - IECore.V3f( 0.199077, 1.86207, 0 ), - IECore.V3f( 0.156671, 1.82292, 0 ), - IECore.V3f( 0.120852, 1.77746, 0 ), - IECore.V3f( 0.0916979, 1.72669, 0 ), - IECore.V3f( 0.0692073, 1.67171, 0 ), - IECore.V3f( 0.0533805, 1.6136, 0 ), - IECore.V3f( 0.0442177, 1.55345, 0 ), - IECore.V3f( 0.0417187, 1.49235, 0 ), - IECore.V3f( 0.0458837, 1.43138, 0 ), - IECore.V3f( 0.0567125, 1.37164, 0 ), - IECore.V3f( 0.0742052, 1.31421, 0 ), - IECore.V3f( 0.0983618, 1.26018, 0 ), - IECore.V3f( 0.129182, 1.21063, 0 ), - IECore.V3f( 0.166667, 1.16667, 0 ) + imath.V3f( 0.166667, 0.166667, 0 ), + imath.V3f( 0.210634, 0.129182, 0 ), + imath.V3f( 0.260176, 0.0983618, 0 ), + imath.V3f( 0.314207, 0.0742052, 0 ), + imath.V3f( 0.371638, 0.0567125, 0 ), + imath.V3f( 0.431381, 0.0458837, 0 ), + imath.V3f( 0.492347, 0.0417187, 0 ), + imath.V3f( 0.55345, 0.0442177, 0 ), + imath.V3f( 0.613601, 0.0533805, 0 ), + imath.V3f( 0.671711, 0.0692073, 0 ), + imath.V3f( 0.726694, 0.0916979, 0 ), + imath.V3f( 0.777461, 0.120852, 0 ), + imath.V3f( 0.822924, 0.156671, 0 ), + imath.V3f( 0.862071, 0.199077, 0 ), + imath.V3f( 0.894558, 0.247328, 0 ), + imath.V3f( 0.92038, 0.300338, 0 ), + imath.V3f( 0.939539, 0.357021, 0 ), + imath.V3f( 0.952034, 0.416288, 0 ), + imath.V3f( 0.957865, 0.47705, 0 ), + imath.V3f( 0.957032, 0.538221, 0 ), + imath.V3f( 0.949535, 0.598712, 0 ), + imath.V3f( 0.935374, 0.657434, 0 ), + imath.V3f( 0.914549, 0.713301, 0 ), + imath.V3f( 0.887061, 0.765224, 0 ), + imath.V3f( 0.852909, 0.812115, 0 ), + imath.V3f( 0.812115, 0.852908, 0 ), + imath.V3f( 0.765224, 0.887061, 0 ), + imath.V3f( 0.713301, 0.914549, 0 ), + imath.V3f( 0.657434, 0.935374, 0 ), + imath.V3f( 0.598712, 0.949535, 0 ), + imath.V3f( 0.538221, 0.957032, 0 ), + imath.V3f( 0.47705, 0.957865, 0 ), + imath.V3f( 0.416288, 0.952034, 0 ), + imath.V3f( 0.357021, 0.939539, 0 ), + imath.V3f( 0.300338, 0.92038, 0 ), + imath.V3f( 0.247327, 0.894558, 0 ), + imath.V3f( 0.199077, 0.862071, 0 ), + imath.V3f( 0.156671, 0.822924, 0 ), + imath.V3f( 0.120852, 0.777461, 0 ), + imath.V3f( 0.0916979, 0.726694, 0 ), + imath.V3f( 0.0692073, 0.671711, 0 ), + imath.V3f( 0.0533805, 0.613601, 0 ), + imath.V3f( 0.0442177, 0.55345, 0 ), + imath.V3f( 0.0417187, 0.492347, 0 ), + imath.V3f( 0.0458837, 0.431381, 0 ), + imath.V3f( 0.0567125, 0.371638, 0 ), + imath.V3f( 0.0742052, 0.314207, 0 ), + imath.V3f( 0.0983618, 0.260176, 0 ), + imath.V3f( 0.129182, 0.210634, 0 ), + imath.V3f( 0.166667, 0.166667, 0 ), + imath.V3f( 0.166667, 1.16667, 0 ), + imath.V3f( 0.210634, 1.12918, 0 ), + imath.V3f( 0.260176, 1.09836, 0 ), + imath.V3f( 0.314207, 1.07421, 0 ), + imath.V3f( 0.371638, 1.05671, 0 ), + imath.V3f( 0.431381, 1.04588, 0 ), + imath.V3f( 0.492347, 1.04172, 0 ), + imath.V3f( 0.55345, 1.04422, 0 ), + imath.V3f( 0.613601, 1.05338, 0 ), + imath.V3f( 0.671711, 1.06921, 0 ), + imath.V3f( 0.726694, 1.0917, 0 ), + imath.V3f( 0.777461, 1.12085, 0 ), + imath.V3f( 0.822924, 1.15667, 0 ), + imath.V3f( 0.862071, 1.19908, 0 ), + imath.V3f( 0.894558, 1.24733, 0 ), + imath.V3f( 0.92038, 1.30034, 0 ), + imath.V3f( 0.939539, 1.35702, 0 ), + imath.V3f( 0.952034, 1.41629, 0 ), + imath.V3f( 0.957865, 1.47705, 0 ), + imath.V3f( 0.957032, 1.53822, 0 ), + imath.V3f( 0.949535, 1.59871, 0 ), + imath.V3f( 0.935374, 1.65743, 0 ), + imath.V3f( 0.914549, 1.7133, 0 ), + imath.V3f( 0.887061, 1.76522, 0 ), + imath.V3f( 0.852909, 1.81211, 0 ), + imath.V3f( 0.812115, 1.85291, 0 ), + imath.V3f( 0.765224, 1.88706, 0 ), + imath.V3f( 0.713301, 1.91455, 0 ), + imath.V3f( 0.657434, 1.93537, 0 ), + imath.V3f( 0.598712, 1.94954, 0 ), + imath.V3f( 0.538221, 1.95703, 0 ), + imath.V3f( 0.47705, 1.95786, 0 ), + imath.V3f( 0.416288, 1.95203, 0 ), + imath.V3f( 0.357021, 1.93954, 0 ), + imath.V3f( 0.300338, 1.92038, 0 ), + imath.V3f( 0.247327, 1.89456, 0 ), + imath.V3f( 0.199077, 1.86207, 0 ), + imath.V3f( 0.156671, 1.82292, 0 ), + imath.V3f( 0.120852, 1.77746, 0 ), + imath.V3f( 0.0916979, 1.72669, 0 ), + imath.V3f( 0.0692073, 1.67171, 0 ), + imath.V3f( 0.0533805, 1.6136, 0 ), + imath.V3f( 0.0442177, 1.55345, 0 ), + imath.V3f( 0.0417187, 1.49235, 0 ), + imath.V3f( 0.0458837, 1.43138, 0 ), + imath.V3f( 0.0567125, 1.37164, 0 ), + imath.V3f( 0.0742052, 1.31421, 0 ), + imath.V3f( 0.0983618, 1.26018, 0 ), + imath.V3f( 0.129182, 1.21063, 0 ), + imath.V3f( 0.166667, 1.16667, 0 ) ] ) lengths = IECore.FloatVectorData( [ 2.917539119, 2.917539119 ] ) @@ -682,7 +683,7 @@ def test2CurvePeriodicBSpline( self ) : def test3SegmentLinear( self ) : - v = IECore.V3f + v = imath.V3f c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 6 ] ), @@ -700,56 +701,56 @@ def test3SegmentLinear( self ) : ) ) - expected = IECore.V3fVectorData( [ IECore.V3f( 0, 1, 0 ), - IECore.V3f( 0, 0.897959, 0 ), - IECore.V3f( 0, 0.795918, 0 ), - IECore.V3f( 0, 0.693878, 0 ), - IECore.V3f( 0, 0.591837, 0 ), - IECore.V3f( 0, 0.489796, 0 ), - IECore.V3f( 0, 0.387755, 0 ), - IECore.V3f( 0, 0.285714, 0 ), - IECore.V3f( 0, 0.183674, 0 ), - IECore.V3f( 0, 0.0816326, 0 ), - IECore.V3f( 0.0204082, 0, 0 ), - IECore.V3f( 0.122449, 0, 0 ), - IECore.V3f( 0.22449, 0, 0 ), - IECore.V3f( 0.326531, 0, 0 ), - IECore.V3f( 0.428571, 0, 0 ), - IECore.V3f( 0.530612, 0, 0 ), - IECore.V3f( 0.632653, 0, 0 ), - IECore.V3f( 0.734694, 0, 0 ), - IECore.V3f( 0.836735, 0, 0 ), - IECore.V3f( 0.938776, 0, 0 ), - IECore.V3f( 1, 0.0408163, 0 ), - IECore.V3f( 1, 0.142857, 0 ), - IECore.V3f( 1, 0.244898, 0 ), - IECore.V3f( 1, 0.346939, 0 ), - IECore.V3f( 1, 0.44898, 0 ), - IECore.V3f( 1, 0.55102, 0 ), - IECore.V3f( 1, 0.653061, 0 ), - IECore.V3f( 1, 0.755102, 0 ), - IECore.V3f( 1, 0.857143, 0 ), - IECore.V3f( 1, 0.959184, 0 ), - IECore.V3f( 1.06122, 1, 0 ), - IECore.V3f( 1.16327, 1, 0 ), - IECore.V3f( 1.26531, 1, 0 ), - IECore.V3f( 1.36735, 1, 0 ), - IECore.V3f( 1.46939, 1, 0 ), - IECore.V3f( 1.57143, 1, 0 ), - IECore.V3f( 1.67347, 1, 0 ), - IECore.V3f( 1.77551, 1, 0 ), - IECore.V3f( 1.87755, 1, 0 ), - IECore.V3f( 1.97959, 1, 0 ), - IECore.V3f( 2, 0.918367, 0 ), - IECore.V3f( 2, 0.816327, 0 ), - IECore.V3f( 2, 0.714286, 0 ), - IECore.V3f( 2, 0.612245, 0 ), - IECore.V3f( 2, 0.510204, 0 ), - IECore.V3f( 2, 0.408164, 0 ), - IECore.V3f( 2, 0.306122, 0 ), - IECore.V3f( 2, 0.204082, 0 ), - IECore.V3f( 2, 0.102041, 0 ), - IECore.V3f( 2, 0, 0 ) ] ) + expected = IECore.V3fVectorData( [ imath.V3f( 0, 1, 0 ), + imath.V3f( 0, 0.897959, 0 ), + imath.V3f( 0, 0.795918, 0 ), + imath.V3f( 0, 0.693878, 0 ), + imath.V3f( 0, 0.591837, 0 ), + imath.V3f( 0, 0.489796, 0 ), + imath.V3f( 0, 0.387755, 0 ), + imath.V3f( 0, 0.285714, 0 ), + imath.V3f( 0, 0.183674, 0 ), + imath.V3f( 0, 0.0816326, 0 ), + imath.V3f( 0.0204082, 0, 0 ), + imath.V3f( 0.122449, 0, 0 ), + imath.V3f( 0.22449, 0, 0 ), + imath.V3f( 0.326531, 0, 0 ), + imath.V3f( 0.428571, 0, 0 ), + imath.V3f( 0.530612, 0, 0 ), + imath.V3f( 0.632653, 0, 0 ), + imath.V3f( 0.734694, 0, 0 ), + imath.V3f( 0.836735, 0, 0 ), + imath.V3f( 0.938776, 0, 0 ), + imath.V3f( 1, 0.0408163, 0 ), + imath.V3f( 1, 0.142857, 0 ), + imath.V3f( 1, 0.244898, 0 ), + imath.V3f( 1, 0.346939, 0 ), + imath.V3f( 1, 0.44898, 0 ), + imath.V3f( 1, 0.55102, 0 ), + imath.V3f( 1, 0.653061, 0 ), + imath.V3f( 1, 0.755102, 0 ), + imath.V3f( 1, 0.857143, 0 ), + imath.V3f( 1, 0.959184, 0 ), + imath.V3f( 1.06122, 1, 0 ), + imath.V3f( 1.16327, 1, 0 ), + imath.V3f( 1.26531, 1, 0 ), + imath.V3f( 1.36735, 1, 0 ), + imath.V3f( 1.46939, 1, 0 ), + imath.V3f( 1.57143, 1, 0 ), + imath.V3f( 1.67347, 1, 0 ), + imath.V3f( 1.77551, 1, 0 ), + imath.V3f( 1.87755, 1, 0 ), + imath.V3f( 1.97959, 1, 0 ), + imath.V3f( 2, 0.918367, 0 ), + imath.V3f( 2, 0.816327, 0 ), + imath.V3f( 2, 0.714286, 0 ), + imath.V3f( 2, 0.612245, 0 ), + imath.V3f( 2, 0.510204, 0 ), + imath.V3f( 2, 0.408164, 0 ), + imath.V3f( 2, 0.306122, 0 ), + imath.V3f( 2, 0.204082, 0 ), + imath.V3f( 2, 0.102041, 0 ), + imath.V3f( 2, 0, 0 ) ] ) lengths = IECore.FloatVectorData( [ 5.0 ] ) @@ -757,7 +758,7 @@ def test3SegmentLinear( self ) : def test3SegmentLinearDoubledEndpoints( self ) : - v = IECore.V3f + v = imath.V3f c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 8 ] ), @@ -778,56 +779,56 @@ def test3SegmentLinearDoubledEndpoints( self ) : ) expected = IECore.V3fVectorData( [ - IECore.V3f( 0, 1, 0 ), - IECore.V3f( 0, 1, 0 ), - IECore.V3f( 0, 1, 0 ), - IECore.V3f( 0, 1, 0 ), - IECore.V3f( 0, 1, 0 ), - IECore.V3f( 0, 1, 0 ), - IECore.V3f( 0, 1, 0 ), - IECore.V3f( 0, 1, 0 ), - IECore.V3f( 0, 0.857143, 0 ), - IECore.V3f( 0, 0.714286, 0 ), - IECore.V3f( 0, 0.571429, 0 ), - IECore.V3f( 0, 0.428571, 0 ), - IECore.V3f( 0, 0.285714, 0 ), - IECore.V3f( 0, 0.142857, 0 ), - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 0.142857, 0, 0 ), - IECore.V3f( 0.285714, 0, 0 ), - IECore.V3f( 0.428571, 0, 0 ), - IECore.V3f( 0.571429, 0, 0 ), - IECore.V3f( 0.714286, 0, 0 ), - IECore.V3f( 0.857143, 0, 0 ), - IECore.V3f( 1, 0, 0 ), - IECore.V3f( 1, 0.142857, 0 ), - IECore.V3f( 1, 0.285714, 0 ), - IECore.V3f( 1, 0.428571, 0 ), - IECore.V3f( 1, 0.571429, 0 ), - IECore.V3f( 1, 0.714286, 0 ), - IECore.V3f( 1, 0.857143, 0 ), - IECore.V3f( 1, 1, 0 ), - IECore.V3f( 1.14286, 1, 0 ), - IECore.V3f( 1.28571, 1, 0 ), - IECore.V3f( 1.42857, 1, 0 ), - IECore.V3f( 1.57143, 1, 0 ), - IECore.V3f( 1.71429, 1, 0 ), - IECore.V3f( 1.85714, 1, 0 ), - IECore.V3f( 2, 1, 0 ), - IECore.V3f( 2, 0.857143, 0 ), - IECore.V3f( 2, 0.714286, 0 ), - IECore.V3f( 2, 0.571429, 0 ), - IECore.V3f( 2, 0.428572, 0 ), - IECore.V3f( 2, 0.285714, 0 ), - IECore.V3f( 2, 0.142857, 0 ), - IECore.V3f( 2, 0, 0 ), - IECore.V3f( 2, 0, 0 ), - IECore.V3f( 2, 0, 0 ), - IECore.V3f( 2, 0, 0 ), - IECore.V3f( 2, 0, 0 ), - IECore.V3f( 2, 0, 0 ), - IECore.V3f( 2, 0, 0 ), - IECore.V3f( 2, 0, 0 ) ] ) + imath.V3f( 0, 1, 0 ), + imath.V3f( 0, 1, 0 ), + imath.V3f( 0, 1, 0 ), + imath.V3f( 0, 1, 0 ), + imath.V3f( 0, 1, 0 ), + imath.V3f( 0, 1, 0 ), + imath.V3f( 0, 1, 0 ), + imath.V3f( 0, 1, 0 ), + imath.V3f( 0, 0.857143, 0 ), + imath.V3f( 0, 0.714286, 0 ), + imath.V3f( 0, 0.571429, 0 ), + imath.V3f( 0, 0.428571, 0 ), + imath.V3f( 0, 0.285714, 0 ), + imath.V3f( 0, 0.142857, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 0.142857, 0, 0 ), + imath.V3f( 0.285714, 0, 0 ), + imath.V3f( 0.428571, 0, 0 ), + imath.V3f( 0.571429, 0, 0 ), + imath.V3f( 0.714286, 0, 0 ), + imath.V3f( 0.857143, 0, 0 ), + imath.V3f( 1, 0, 0 ), + imath.V3f( 1, 0.142857, 0 ), + imath.V3f( 1, 0.285714, 0 ), + imath.V3f( 1, 0.428571, 0 ), + imath.V3f( 1, 0.571429, 0 ), + imath.V3f( 1, 0.714286, 0 ), + imath.V3f( 1, 0.857143, 0 ), + imath.V3f( 1, 1, 0 ), + imath.V3f( 1.14286, 1, 0 ), + imath.V3f( 1.28571, 1, 0 ), + imath.V3f( 1.42857, 1, 0 ), + imath.V3f( 1.57143, 1, 0 ), + imath.V3f( 1.71429, 1, 0 ), + imath.V3f( 1.85714, 1, 0 ), + imath.V3f( 2, 1, 0 ), + imath.V3f( 2, 0.857143, 0 ), + imath.V3f( 2, 0.714286, 0 ), + imath.V3f( 2, 0.571429, 0 ), + imath.V3f( 2, 0.428572, 0 ), + imath.V3f( 2, 0.285714, 0 ), + imath.V3f( 2, 0.142857, 0 ), + imath.V3f( 2, 0, 0 ), + imath.V3f( 2, 0, 0 ), + imath.V3f( 2, 0, 0 ), + imath.V3f( 2, 0, 0 ), + imath.V3f( 2, 0, 0 ), + imath.V3f( 2, 0, 0 ), + imath.V3f( 2, 0, 0 ), + imath.V3f( 2, 0, 0 ) ] ) lengths = IECore.FloatVectorData( [ 5.0 ] ) @@ -835,7 +836,7 @@ def test3SegmentLinearDoubledEndpoints( self ) : def test2Curve3SegmentLinear( self ) : - v = IECore.V3f + v = imath.V3f c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 6, 6 ] ), @@ -860,106 +861,106 @@ def test2Curve3SegmentLinear( self ) : ) ) - expected = IECore.V3fVectorData( [ IECore.V3f( 0, 1, 0 ), - IECore.V3f( 0, 0.897959, 0 ), - IECore.V3f( 0, 0.795918, 0 ), - IECore.V3f( 0, 0.693878, 0 ), - IECore.V3f( 0, 0.591837, 0 ), - IECore.V3f( 0, 0.489796, 0 ), - IECore.V3f( 0, 0.387755, 0 ), - IECore.V3f( 0, 0.285714, 0 ), - IECore.V3f( 0, 0.183674, 0 ), - IECore.V3f( 0, 0.0816326, 0 ), - IECore.V3f( 0.0204082, 0, 0 ), - IECore.V3f( 0.122449, 0, 0 ), - IECore.V3f( 0.22449, 0, 0 ), - IECore.V3f( 0.326531, 0, 0 ), - IECore.V3f( 0.428571, 0, 0 ), - IECore.V3f( 0.530612, 0, 0 ), - IECore.V3f( 0.632653, 0, 0 ), - IECore.V3f( 0.734694, 0, 0 ), - IECore.V3f( 0.836735, 0, 0 ), - IECore.V3f( 0.938776, 0, 0 ), - IECore.V3f( 1, 0.0408163, 0 ), - IECore.V3f( 1, 0.142857, 0 ), - IECore.V3f( 1, 0.244898, 0 ), - IECore.V3f( 1, 0.346939, 0 ), - IECore.V3f( 1, 0.44898, 0 ), - IECore.V3f( 1, 0.55102, 0 ), - IECore.V3f( 1, 0.653061, 0 ), - IECore.V3f( 1, 0.755102, 0 ), - IECore.V3f( 1, 0.857143, 0 ), - IECore.V3f( 1, 0.959184, 0 ), - IECore.V3f( 1.06122, 1, 0 ), - IECore.V3f( 1.16327, 1, 0 ), - IECore.V3f( 1.26531, 1, 0 ), - IECore.V3f( 1.36735, 1, 0 ), - IECore.V3f( 1.46939, 1, 0 ), - IECore.V3f( 1.57143, 1, 0 ), - IECore.V3f( 1.67347, 1, 0 ), - IECore.V3f( 1.77551, 1, 0 ), - IECore.V3f( 1.87755, 1, 0 ), - IECore.V3f( 1.97959, 1, 0 ), - IECore.V3f( 2, 0.918367, 0 ), - IECore.V3f( 2, 0.816327, 0 ), - IECore.V3f( 2, 0.714286, 0 ), - IECore.V3f( 2, 0.612245, 0 ), - IECore.V3f( 2, 0.510204, 0 ), - IECore.V3f( 2, 0.408164, 0 ), - IECore.V3f( 2, 0.306122, 0 ), - IECore.V3f( 2, 0.204082, 0 ), - IECore.V3f( 2, 0.102041, 0 ), - IECore.V3f( 2, 0, 0 ), - IECore.V3f( 0, 2, 0 ), - IECore.V3f( 0, 1.89796, 0 ), - IECore.V3f( 0, 1.79592, 0 ), - IECore.V3f( 0, 1.69388, 0 ), - IECore.V3f( 0, 1.59184, 0 ), - IECore.V3f( 0, 1.4898, 0 ), - IECore.V3f( 0, 1.38776, 0 ), - IECore.V3f( 0, 1.28571, 0 ), - IECore.V3f( 0, 1.18367, 0 ), - IECore.V3f( 0, 1.08163, 0 ), - IECore.V3f( 0.0204082, 1, 0 ), - IECore.V3f( 0.122449, 1, 0 ), - IECore.V3f( 0.22449, 1, 0 ), - IECore.V3f( 0.326531, 1, 0 ), - IECore.V3f( 0.428571, 1, 0 ), - IECore.V3f( 0.530612, 1, 0 ), - IECore.V3f( 0.632653, 1, 0 ), - IECore.V3f( 0.734694, 1, 0 ), - IECore.V3f( 0.836735, 1, 0 ), - IECore.V3f( 0.938776, 1, 0 ), - IECore.V3f( 1, 1.04082, 0 ), - IECore.V3f( 1, 1.14286, 0 ), - IECore.V3f( 1, 1.2449, 0 ), - IECore.V3f( 1, 1.34694, 0 ), - IECore.V3f( 1, 1.44898, 0 ), - IECore.V3f( 1, 1.55102, 0 ), - IECore.V3f( 1, 1.65306, 0 ), - IECore.V3f( 1, 1.7551, 0 ), - IECore.V3f( 1, 1.85714, 0 ), - IECore.V3f( 1, 1.95918, 0 ), - IECore.V3f( 1.06122, 2, 0 ), - IECore.V3f( 1.16327, 2, 0 ), - IECore.V3f( 1.26531, 2, 0 ), - IECore.V3f( 1.36735, 2, 0 ), - IECore.V3f( 1.46939, 2, 0 ), - IECore.V3f( 1.57143, 2, 0 ), - IECore.V3f( 1.67347, 2, 0 ), - IECore.V3f( 1.77551, 2, 0 ), - IECore.V3f( 1.87755, 2, 0 ), - IECore.V3f( 1.97959, 2, 0 ), - IECore.V3f( 2, 1.91837, 0 ), - IECore.V3f( 2, 1.81633, 0 ), - IECore.V3f( 2, 1.71429, 0 ), - IECore.V3f( 2, 1.61225, 0 ), - IECore.V3f( 2, 1.5102, 0 ), - IECore.V3f( 2, 1.40816, 0 ), - IECore.V3f( 2, 1.30612, 0 ), - IECore.V3f( 2, 1.20408, 0 ), - IECore.V3f( 2, 1.10204, 0 ), - IECore.V3f( 2, 1, 0 ) ] ) + expected = IECore.V3fVectorData( [ imath.V3f( 0, 1, 0 ), + imath.V3f( 0, 0.897959, 0 ), + imath.V3f( 0, 0.795918, 0 ), + imath.V3f( 0, 0.693878, 0 ), + imath.V3f( 0, 0.591837, 0 ), + imath.V3f( 0, 0.489796, 0 ), + imath.V3f( 0, 0.387755, 0 ), + imath.V3f( 0, 0.285714, 0 ), + imath.V3f( 0, 0.183674, 0 ), + imath.V3f( 0, 0.0816326, 0 ), + imath.V3f( 0.0204082, 0, 0 ), + imath.V3f( 0.122449, 0, 0 ), + imath.V3f( 0.22449, 0, 0 ), + imath.V3f( 0.326531, 0, 0 ), + imath.V3f( 0.428571, 0, 0 ), + imath.V3f( 0.530612, 0, 0 ), + imath.V3f( 0.632653, 0, 0 ), + imath.V3f( 0.734694, 0, 0 ), + imath.V3f( 0.836735, 0, 0 ), + imath.V3f( 0.938776, 0, 0 ), + imath.V3f( 1, 0.0408163, 0 ), + imath.V3f( 1, 0.142857, 0 ), + imath.V3f( 1, 0.244898, 0 ), + imath.V3f( 1, 0.346939, 0 ), + imath.V3f( 1, 0.44898, 0 ), + imath.V3f( 1, 0.55102, 0 ), + imath.V3f( 1, 0.653061, 0 ), + imath.V3f( 1, 0.755102, 0 ), + imath.V3f( 1, 0.857143, 0 ), + imath.V3f( 1, 0.959184, 0 ), + imath.V3f( 1.06122, 1, 0 ), + imath.V3f( 1.16327, 1, 0 ), + imath.V3f( 1.26531, 1, 0 ), + imath.V3f( 1.36735, 1, 0 ), + imath.V3f( 1.46939, 1, 0 ), + imath.V3f( 1.57143, 1, 0 ), + imath.V3f( 1.67347, 1, 0 ), + imath.V3f( 1.77551, 1, 0 ), + imath.V3f( 1.87755, 1, 0 ), + imath.V3f( 1.97959, 1, 0 ), + imath.V3f( 2, 0.918367, 0 ), + imath.V3f( 2, 0.816327, 0 ), + imath.V3f( 2, 0.714286, 0 ), + imath.V3f( 2, 0.612245, 0 ), + imath.V3f( 2, 0.510204, 0 ), + imath.V3f( 2, 0.408164, 0 ), + imath.V3f( 2, 0.306122, 0 ), + imath.V3f( 2, 0.204082, 0 ), + imath.V3f( 2, 0.102041, 0 ), + imath.V3f( 2, 0, 0 ), + imath.V3f( 0, 2, 0 ), + imath.V3f( 0, 1.89796, 0 ), + imath.V3f( 0, 1.79592, 0 ), + imath.V3f( 0, 1.69388, 0 ), + imath.V3f( 0, 1.59184, 0 ), + imath.V3f( 0, 1.4898, 0 ), + imath.V3f( 0, 1.38776, 0 ), + imath.V3f( 0, 1.28571, 0 ), + imath.V3f( 0, 1.18367, 0 ), + imath.V3f( 0, 1.08163, 0 ), + imath.V3f( 0.0204082, 1, 0 ), + imath.V3f( 0.122449, 1, 0 ), + imath.V3f( 0.22449, 1, 0 ), + imath.V3f( 0.326531, 1, 0 ), + imath.V3f( 0.428571, 1, 0 ), + imath.V3f( 0.530612, 1, 0 ), + imath.V3f( 0.632653, 1, 0 ), + imath.V3f( 0.734694, 1, 0 ), + imath.V3f( 0.836735, 1, 0 ), + imath.V3f( 0.938776, 1, 0 ), + imath.V3f( 1, 1.04082, 0 ), + imath.V3f( 1, 1.14286, 0 ), + imath.V3f( 1, 1.2449, 0 ), + imath.V3f( 1, 1.34694, 0 ), + imath.V3f( 1, 1.44898, 0 ), + imath.V3f( 1, 1.55102, 0 ), + imath.V3f( 1, 1.65306, 0 ), + imath.V3f( 1, 1.7551, 0 ), + imath.V3f( 1, 1.85714, 0 ), + imath.V3f( 1, 1.95918, 0 ), + imath.V3f( 1.06122, 2, 0 ), + imath.V3f( 1.16327, 2, 0 ), + imath.V3f( 1.26531, 2, 0 ), + imath.V3f( 1.36735, 2, 0 ), + imath.V3f( 1.46939, 2, 0 ), + imath.V3f( 1.57143, 2, 0 ), + imath.V3f( 1.67347, 2, 0 ), + imath.V3f( 1.77551, 2, 0 ), + imath.V3f( 1.87755, 2, 0 ), + imath.V3f( 1.97959, 2, 0 ), + imath.V3f( 2, 1.91837, 0 ), + imath.V3f( 2, 1.81633, 0 ), + imath.V3f( 2, 1.71429, 0 ), + imath.V3f( 2, 1.61225, 0 ), + imath.V3f( 2, 1.5102, 0 ), + imath.V3f( 2, 1.40816, 0 ), + imath.V3f( 2, 1.30612, 0 ), + imath.V3f( 2, 1.20408, 0 ), + imath.V3f( 2, 1.10204, 0 ), + imath.V3f( 2, 1, 0 ) ] ) lengths = IECore.FloatVectorData( [ 5.0, 5.0 ] ) @@ -967,7 +968,7 @@ def test2Curve3SegmentLinear( self ) : def test3SegmentPeriodicLinear( self ) : - v = IECore.V3f + v = imath.V3f c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 6 ] ), @@ -985,56 +986,56 @@ def test3SegmentPeriodicLinear( self ) : ) ) - expected = IECore.V3fVectorData( [ IECore.V3f( 0, 1, 0 ), - IECore.V3f( 0, 0.877551, 0 ), - IECore.V3f( 0, 0.755102, 0 ), - IECore.V3f( 0, 0.632653, 0 ), - IECore.V3f( 0, 0.510204, 0 ), - IECore.V3f( 0, 0.387755, 0 ), - IECore.V3f( 0, 0.265306, 0 ), - IECore.V3f( 0, 0.142857, 0 ), - IECore.V3f( 0, 0.0204082, 0 ), - IECore.V3f( 0.102041, 0, 0 ), - IECore.V3f( 0.22449, 0, 0 ), - IECore.V3f( 0.346939, 0, 0 ), - IECore.V3f( 0.469388, 0, 0 ), - IECore.V3f( 0.591837, 0, 0 ), - IECore.V3f( 0.714286, 0, 0 ), - IECore.V3f( 0.836735, 0, 0 ), - IECore.V3f( 0.959184, 0, 0 ), - IECore.V3f( 1, 0.0816326, 0 ), - IECore.V3f( 1, 0.204082, 0 ), - IECore.V3f( 1, 0.32653, 0 ), - IECore.V3f( 1, 0.44898, 0 ), - IECore.V3f( 1, 0.571429, 0 ), - IECore.V3f( 1, 0.693877, 0 ), - IECore.V3f( 1, 0.816327, 0 ), - IECore.V3f( 1, 0.938776, 0 ), - IECore.V3f( 1.06122, 1, 0 ), - IECore.V3f( 1.18367, 1, 0 ), - IECore.V3f( 1.30612, 1, 0 ), - IECore.V3f( 1.42857, 1, 0 ), - IECore.V3f( 1.55102, 1, 0 ), - IECore.V3f( 1.67347, 1, 0 ), - IECore.V3f( 1.79592, 1, 0 ), - IECore.V3f( 1.91837, 1, 0 ), - IECore.V3f( 2, 0.959184, 0 ), - IECore.V3f( 2, 0.836735, 0 ), - IECore.V3f( 2, 0.714286, 0 ), - IECore.V3f( 2, 0.591837, 0 ), - IECore.V3f( 2, 0.469388, 0 ), - IECore.V3f( 2, 0.346939, 0 ), - IECore.V3f( 2, 0.22449, 0 ), - IECore.V3f( 2, 0.102041, 0 ), - IECore.V3f( 1.95918, 0.0204082, 0 ), - IECore.V3f( 1.71429, 0.142857, 0 ), - IECore.V3f( 1.46939, 0.265306, 0 ), - IECore.V3f( 1.22449, 0.387755, 0 ), - IECore.V3f( 0.979592, 0.510204, 0 ), - IECore.V3f( 0.734694, 0.632653, 0 ), - IECore.V3f( 0.489796, 0.755102, 0 ), - IECore.V3f( 0.244898, 0.877551, 0 ), - IECore.V3f( 0, 1, 0 ) ] ) + expected = IECore.V3fVectorData( [ imath.V3f( 0, 1, 0 ), + imath.V3f( 0, 0.877551, 0 ), + imath.V3f( 0, 0.755102, 0 ), + imath.V3f( 0, 0.632653, 0 ), + imath.V3f( 0, 0.510204, 0 ), + imath.V3f( 0, 0.387755, 0 ), + imath.V3f( 0, 0.265306, 0 ), + imath.V3f( 0, 0.142857, 0 ), + imath.V3f( 0, 0.0204082, 0 ), + imath.V3f( 0.102041, 0, 0 ), + imath.V3f( 0.22449, 0, 0 ), + imath.V3f( 0.346939, 0, 0 ), + imath.V3f( 0.469388, 0, 0 ), + imath.V3f( 0.591837, 0, 0 ), + imath.V3f( 0.714286, 0, 0 ), + imath.V3f( 0.836735, 0, 0 ), + imath.V3f( 0.959184, 0, 0 ), + imath.V3f( 1, 0.0816326, 0 ), + imath.V3f( 1, 0.204082, 0 ), + imath.V3f( 1, 0.32653, 0 ), + imath.V3f( 1, 0.44898, 0 ), + imath.V3f( 1, 0.571429, 0 ), + imath.V3f( 1, 0.693877, 0 ), + imath.V3f( 1, 0.816327, 0 ), + imath.V3f( 1, 0.938776, 0 ), + imath.V3f( 1.06122, 1, 0 ), + imath.V3f( 1.18367, 1, 0 ), + imath.V3f( 1.30612, 1, 0 ), + imath.V3f( 1.42857, 1, 0 ), + imath.V3f( 1.55102, 1, 0 ), + imath.V3f( 1.67347, 1, 0 ), + imath.V3f( 1.79592, 1, 0 ), + imath.V3f( 1.91837, 1, 0 ), + imath.V3f( 2, 0.959184, 0 ), + imath.V3f( 2, 0.836735, 0 ), + imath.V3f( 2, 0.714286, 0 ), + imath.V3f( 2, 0.591837, 0 ), + imath.V3f( 2, 0.469388, 0 ), + imath.V3f( 2, 0.346939, 0 ), + imath.V3f( 2, 0.22449, 0 ), + imath.V3f( 2, 0.102041, 0 ), + imath.V3f( 1.95918, 0.0204082, 0 ), + imath.V3f( 1.71429, 0.142857, 0 ), + imath.V3f( 1.46939, 0.265306, 0 ), + imath.V3f( 1.22449, 0.387755, 0 ), + imath.V3f( 0.979592, 0.510204, 0 ), + imath.V3f( 0.734694, 0.632653, 0 ), + imath.V3f( 0.489796, 0.755102, 0 ), + imath.V3f( 0.244898, 0.877551, 0 ), + imath.V3f( 0, 1, 0 ) ] ) lengths = IECore.FloatVectorData( [ 7.23606777 ] ) @@ -1042,7 +1043,7 @@ def test3SegmentPeriodicLinear( self ) : def test2Curve3SegmentPeriodicLinear( self ) : - v = IECore.V3f + v = imath.V3f c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 6, 6 ] ), @@ -1066,106 +1067,106 @@ def test2Curve3SegmentPeriodicLinear( self ) : ) ) - expected = IECore.V3fVectorData( [ IECore.V3f( 0, 1, 0 ), - IECore.V3f( 0, 0.877551, 0 ), - IECore.V3f( 0, 0.755102, 0 ), - IECore.V3f( 0, 0.632653, 0 ), - IECore.V3f( 0, 0.510204, 0 ), - IECore.V3f( 0, 0.387755, 0 ), - IECore.V3f( 0, 0.265306, 0 ), - IECore.V3f( 0, 0.142857, 0 ), - IECore.V3f( 0, 0.0204082, 0 ), - IECore.V3f( 0.102041, 0, 0 ), - IECore.V3f( 0.22449, 0, 0 ), - IECore.V3f( 0.346939, 0, 0 ), - IECore.V3f( 0.469388, 0, 0 ), - IECore.V3f( 0.591837, 0, 0 ), - IECore.V3f( 0.714286, 0, 0 ), - IECore.V3f( 0.836735, 0, 0 ), - IECore.V3f( 0.959184, 0, 0 ), - IECore.V3f( 1, 0.0816326, 0 ), - IECore.V3f( 1, 0.204082, 0 ), - IECore.V3f( 1, 0.32653, 0 ), - IECore.V3f( 1, 0.44898, 0 ), - IECore.V3f( 1, 0.571429, 0 ), - IECore.V3f( 1, 0.693877, 0 ), - IECore.V3f( 1, 0.816327, 0 ), - IECore.V3f( 1, 0.938776, 0 ), - IECore.V3f( 1.06122, 1, 0 ), - IECore.V3f( 1.18367, 1, 0 ), - IECore.V3f( 1.30612, 1, 0 ), - IECore.V3f( 1.42857, 1, 0 ), - IECore.V3f( 1.55102, 1, 0 ), - IECore.V3f( 1.67347, 1, 0 ), - IECore.V3f( 1.79592, 1, 0 ), - IECore.V3f( 1.91837, 1, 0 ), - IECore.V3f( 2, 0.959184, 0 ), - IECore.V3f( 2, 0.836735, 0 ), - IECore.V3f( 2, 0.714286, 0 ), - IECore.V3f( 2, 0.591837, 0 ), - IECore.V3f( 2, 0.469388, 0 ), - IECore.V3f( 2, 0.346939, 0 ), - IECore.V3f( 2, 0.22449, 0 ), - IECore.V3f( 2, 0.102041, 0 ), - IECore.V3f( 1.95918, 0.0204082, 0 ), - IECore.V3f( 1.71429, 0.142857, 0 ), - IECore.V3f( 1.46939, 0.265306, 0 ), - IECore.V3f( 1.22449, 0.387755, 0 ), - IECore.V3f( 0.979592, 0.510204, 0 ), - IECore.V3f( 0.734694, 0.632653, 0 ), - IECore.V3f( 0.489796, 0.755102, 0 ), - IECore.V3f( 0.244898, 0.877551, 0 ), - IECore.V3f( 0, 1, 0 ), - IECore.V3f( 0, 2, 0 ), - IECore.V3f( 0, 1.87755, 0 ), - IECore.V3f( 0, 1.7551, 0 ), - IECore.V3f( 0, 1.63265, 0 ), - IECore.V3f( 0, 1.5102, 0 ), - IECore.V3f( 0, 1.38776, 0 ), - IECore.V3f( 0, 1.26531, 0 ), - IECore.V3f( 0, 1.14286, 0 ), - IECore.V3f( 0, 1.02041, 0 ), - IECore.V3f( 0.102041, 1, 0 ), - IECore.V3f( 0.22449, 1, 0 ), - IECore.V3f( 0.346939, 1, 0 ), - IECore.V3f( 0.469388, 1, 0 ), - IECore.V3f( 0.591837, 1, 0 ), - IECore.V3f( 0.714286, 1, 0 ), - IECore.V3f( 0.836735, 1, 0 ), - IECore.V3f( 0.959184, 1, 0 ), - IECore.V3f( 1, 1.08163, 0 ), - IECore.V3f( 1, 1.20408, 0 ), - IECore.V3f( 1, 1.32653, 0 ), - IECore.V3f( 1, 1.44898, 0 ), - IECore.V3f( 1, 1.57143, 0 ), - IECore.V3f( 1, 1.69388, 0 ), - IECore.V3f( 1, 1.81633, 0 ), - IECore.V3f( 1, 1.93878, 0 ), - IECore.V3f( 1.06122, 2, 0 ), - IECore.V3f( 1.18367, 2, 0 ), - IECore.V3f( 1.30612, 2, 0 ), - IECore.V3f( 1.42857, 2, 0 ), - IECore.V3f( 1.55102, 2, 0 ), - IECore.V3f( 1.67347, 2, 0 ), - IECore.V3f( 1.79592, 2, 0 ), - IECore.V3f( 1.91837, 2, 0 ), - IECore.V3f( 2, 1.95918, 0 ), - IECore.V3f( 2, 1.83673, 0 ), - IECore.V3f( 2, 1.71429, 0 ), - IECore.V3f( 2, 1.59184, 0 ), - IECore.V3f( 2, 1.46939, 0 ), - IECore.V3f( 2, 1.34694, 0 ), - IECore.V3f( 2, 1.22449, 0 ), - IECore.V3f( 2, 1.10204, 0 ), - IECore.V3f( 1.95918, 1.02041, 0 ), - IECore.V3f( 1.71429, 1.14286, 0 ), - IECore.V3f( 1.46939, 1.26531, 0 ), - IECore.V3f( 1.22449, 1.38775, 0 ), - IECore.V3f( 0.979592, 1.5102, 0 ), - IECore.V3f( 0.734694, 1.63265, 0 ), - IECore.V3f( 0.489796, 1.7551, 0 ), - IECore.V3f( 0.244898, 1.87755, 0 ), - IECore.V3f( 0, 2, 0 ) ] ) + expected = IECore.V3fVectorData( [ imath.V3f( 0, 1, 0 ), + imath.V3f( 0, 0.877551, 0 ), + imath.V3f( 0, 0.755102, 0 ), + imath.V3f( 0, 0.632653, 0 ), + imath.V3f( 0, 0.510204, 0 ), + imath.V3f( 0, 0.387755, 0 ), + imath.V3f( 0, 0.265306, 0 ), + imath.V3f( 0, 0.142857, 0 ), + imath.V3f( 0, 0.0204082, 0 ), + imath.V3f( 0.102041, 0, 0 ), + imath.V3f( 0.22449, 0, 0 ), + imath.V3f( 0.346939, 0, 0 ), + imath.V3f( 0.469388, 0, 0 ), + imath.V3f( 0.591837, 0, 0 ), + imath.V3f( 0.714286, 0, 0 ), + imath.V3f( 0.836735, 0, 0 ), + imath.V3f( 0.959184, 0, 0 ), + imath.V3f( 1, 0.0816326, 0 ), + imath.V3f( 1, 0.204082, 0 ), + imath.V3f( 1, 0.32653, 0 ), + imath.V3f( 1, 0.44898, 0 ), + imath.V3f( 1, 0.571429, 0 ), + imath.V3f( 1, 0.693877, 0 ), + imath.V3f( 1, 0.816327, 0 ), + imath.V3f( 1, 0.938776, 0 ), + imath.V3f( 1.06122, 1, 0 ), + imath.V3f( 1.18367, 1, 0 ), + imath.V3f( 1.30612, 1, 0 ), + imath.V3f( 1.42857, 1, 0 ), + imath.V3f( 1.55102, 1, 0 ), + imath.V3f( 1.67347, 1, 0 ), + imath.V3f( 1.79592, 1, 0 ), + imath.V3f( 1.91837, 1, 0 ), + imath.V3f( 2, 0.959184, 0 ), + imath.V3f( 2, 0.836735, 0 ), + imath.V3f( 2, 0.714286, 0 ), + imath.V3f( 2, 0.591837, 0 ), + imath.V3f( 2, 0.469388, 0 ), + imath.V3f( 2, 0.346939, 0 ), + imath.V3f( 2, 0.22449, 0 ), + imath.V3f( 2, 0.102041, 0 ), + imath.V3f( 1.95918, 0.0204082, 0 ), + imath.V3f( 1.71429, 0.142857, 0 ), + imath.V3f( 1.46939, 0.265306, 0 ), + imath.V3f( 1.22449, 0.387755, 0 ), + imath.V3f( 0.979592, 0.510204, 0 ), + imath.V3f( 0.734694, 0.632653, 0 ), + imath.V3f( 0.489796, 0.755102, 0 ), + imath.V3f( 0.244898, 0.877551, 0 ), + imath.V3f( 0, 1, 0 ), + imath.V3f( 0, 2, 0 ), + imath.V3f( 0, 1.87755, 0 ), + imath.V3f( 0, 1.7551, 0 ), + imath.V3f( 0, 1.63265, 0 ), + imath.V3f( 0, 1.5102, 0 ), + imath.V3f( 0, 1.38776, 0 ), + imath.V3f( 0, 1.26531, 0 ), + imath.V3f( 0, 1.14286, 0 ), + imath.V3f( 0, 1.02041, 0 ), + imath.V3f( 0.102041, 1, 0 ), + imath.V3f( 0.22449, 1, 0 ), + imath.V3f( 0.346939, 1, 0 ), + imath.V3f( 0.469388, 1, 0 ), + imath.V3f( 0.591837, 1, 0 ), + imath.V3f( 0.714286, 1, 0 ), + imath.V3f( 0.836735, 1, 0 ), + imath.V3f( 0.959184, 1, 0 ), + imath.V3f( 1, 1.08163, 0 ), + imath.V3f( 1, 1.20408, 0 ), + imath.V3f( 1, 1.32653, 0 ), + imath.V3f( 1, 1.44898, 0 ), + imath.V3f( 1, 1.57143, 0 ), + imath.V3f( 1, 1.69388, 0 ), + imath.V3f( 1, 1.81633, 0 ), + imath.V3f( 1, 1.93878, 0 ), + imath.V3f( 1.06122, 2, 0 ), + imath.V3f( 1.18367, 2, 0 ), + imath.V3f( 1.30612, 2, 0 ), + imath.V3f( 1.42857, 2, 0 ), + imath.V3f( 1.55102, 2, 0 ), + imath.V3f( 1.67347, 2, 0 ), + imath.V3f( 1.79592, 2, 0 ), + imath.V3f( 1.91837, 2, 0 ), + imath.V3f( 2, 1.95918, 0 ), + imath.V3f( 2, 1.83673, 0 ), + imath.V3f( 2, 1.71429, 0 ), + imath.V3f( 2, 1.59184, 0 ), + imath.V3f( 2, 1.46939, 0 ), + imath.V3f( 2, 1.34694, 0 ), + imath.V3f( 2, 1.22449, 0 ), + imath.V3f( 2, 1.10204, 0 ), + imath.V3f( 1.95918, 1.02041, 0 ), + imath.V3f( 1.71429, 1.14286, 0 ), + imath.V3f( 1.46939, 1.26531, 0 ), + imath.V3f( 1.22449, 1.38775, 0 ), + imath.V3f( 0.979592, 1.5102, 0 ), + imath.V3f( 0.734694, 1.63265, 0 ), + imath.V3f( 0.489796, 1.7551, 0 ), + imath.V3f( 0.244898, 1.87755, 0 ), + imath.V3f( 0, 2, 0 ) ] ) lengths = IECore.FloatVectorData( [ 7.23606777, 7.23606777 ] ) @@ -1173,7 +1174,7 @@ def test2Curve3SegmentPeriodicLinear( self ) : def testClosestPoint( self ) : - rand = IECore.Rand32() + rand = imath.Rand32() for basis in ( IECore.CubicBasisf.linear(), IECore.CubicBasisf.bezier(), IECore.CubicBasisf.bSpline(), IECore.CubicBasisf.catmullRom() ) : @@ -1192,7 +1193,7 @@ def testClosestPoint( self ) : for i in range( 0, numVerts ) : - p.append( rand.nextV3f() + IECore.V3f( c * 2 ) ) + p.append( imath.V3f( rand.nextf(), rand.nextf(), rand.nextf() ) + imath.V3f( c * 2 ) ) curves = IECoreScene.CurvesPrimitive( vertsPerCurve, basis, False, p ) @@ -1224,7 +1225,7 @@ def testClosestPoint( self ) : def testTopologyMethods( self ) : - c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 6, 6 ] ), IECore.CubicBasisf.linear(), False, IECore.V3fVectorData( [ IECore.V3f( 0 ) ] * 12 ) ) + c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 6, 6 ] ), IECore.CubicBasisf.linear(), False, IECore.V3fVectorData( [ imath.V3f( 0 ) ] * 12 ) ) e = IECoreScene.CurvesPrimitiveEvaluator( c ) self.assertEqual( e.verticesPerCurve(), IECore.IntVectorData( [ 6, 6 ] ) ) self.assertEqual( e.vertexDataOffsets(), IECore.IntVectorData( [ 0, 6 ] ) ) @@ -1232,7 +1233,7 @@ def testTopologyMethods( self ) : def testCreate( self ) : - c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 6, 6 ] ), IECore.CubicBasisf.linear(), False, IECore.V3fVectorData( [ IECore.V3f( 0 ) ] * 12 ) ) + c = IECoreScene.CurvesPrimitive( IECore.IntVectorData( [ 6, 6 ] ), IECore.CubicBasisf.linear(), False, IECore.V3fVectorData( [ imath.V3f( 0 ) ] * 12 ) ) e = IECoreScene.PrimitiveEvaluator.create( c ) self.failUnless( isinstance( e, IECoreScene.CurvesPrimitiveEvaluator ) ) diff --git a/test/IECoreScene/CurvesPrimitiveTest.py b/test/IECoreScene/CurvesPrimitiveTest.py index 31ab93c81f..d56bc02e84 100644 --- a/test/IECoreScene/CurvesPrimitiveTest.py +++ b/test/IECoreScene/CurvesPrimitiveTest.py @@ -36,6 +36,7 @@ import os.path import math import unittest +import imath import IECore import IECoreScene @@ -72,7 +73,7 @@ def testConstructors( self ) : self.assertEqual( c.numCurves(), 1 ) i = IECore.IntVectorData( [ 4 ] ) - p = IECore.V3fVectorData( [ IECore.V3f( 0 ), IECore.V3f( 1 ), IECore.V3f( 2 ), IECore.V3f( 3 ) ] ) + p = IECore.V3fVectorData( [ imath.V3f( 0 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ) ] ) c = IECoreScene.CurvesPrimitive( i, IECore.CubicBasisf.bSpline(), True, p ) self.assertEqual( c.verticesPerCurve(), IECore.IntVectorData( [ 4 ] ) ) self.assertEqual( c.basis(), IECore.CubicBasisf.bSpline() ) @@ -96,7 +97,7 @@ def testConstructorValidation( self ) : def testCopy( self ) : i = IECore.IntVectorData( [ 4 ] ) - p = IECore.V3fVectorData( [ IECore.V3f( 0 ), IECore.V3f( 1 ), IECore.V3f( 2 ), IECore.V3f( 3 ) ] ) + p = IECore.V3fVectorData( [ imath.V3f( 0 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ) ] ) c = IECoreScene.CurvesPrimitive( i, IECore.CubicBasisf.bSpline(), True, p ) cc = c.copy() @@ -105,7 +106,7 @@ def testCopy( self ) : def testIO( self ) : i = IECore.IntVectorData( [ 4 ] ) - p = IECore.V3fVectorData( [ IECore.V3f( 0 ), IECore.V3f( 1 ), IECore.V3f( 2 ), IECore.V3f( 3 ) ] ) + p = IECore.V3fVectorData( [ imath.V3f( 0 ), imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ) ] ) c = IECoreScene.CurvesPrimitive( i, IECore.CubicBasisf.bSpline(), True, p ) IECore.Writer.create( c, "test/IECore/data/curves.cob" ).write() diff --git a/test/IECoreScene/ExternalProceduralTest.py b/test/IECoreScene/ExternalProceduralTest.py index 1a7b1431d8..8561e09fd9 100644 --- a/test/IECoreScene/ExternalProceduralTest.py +++ b/test/IECoreScene/ExternalProceduralTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene @@ -43,7 +44,7 @@ def test( self ) : p = IECoreScene.ExternalProcedural( "yeti.so", - IECore.Box3f( IECore.V3f( 1, 2, 3 ), IECore.V3f( 4, 5, 6 ) ), + imath.Box3f( imath.V3f( 1, 2, 3 ), imath.V3f( 4, 5, 6 ) ), IECore.CompoundData( { "one" : 1, "two" : 2, @@ -51,7 +52,7 @@ def test( self ) : ) self.assertEqual( p.getFileName(), "yeti.so" ) - self.assertEqual( p.getBound(), IECore.Box3f( IECore.V3f( 1, 2, 3 ), IECore.V3f( 4, 5, 6 ) ) ) + self.assertEqual( p.getBound(), imath.Box3f( imath.V3f( 1, 2, 3 ), imath.V3f( 4, 5, 6 ) ) ) self.assertEqual( p.parameters(), IECore.CompoundData( { @@ -63,7 +64,7 @@ def test( self ) : p2 = p.copy() self.assertEqual( p2.getFileName(), "yeti.so" ) - self.assertEqual( p2.getBound(), IECore.Box3f( IECore.V3f( 1, 2, 3 ), IECore.V3f( 4, 5, 6 ) ) ) + self.assertEqual( p2.getBound(), imath.Box3f( imath.V3f( 1, 2, 3 ), imath.V3f( 4, 5, 6 ) ) ) self.assertEqual( p2.parameters(), IECore.CompoundData( { diff --git a/test/IECoreScene/FaceVaryingPromotionOpTest.py b/test/IECoreScene/FaceVaryingPromotionOpTest.py index 67eb20d727..79abdcfb30 100644 --- a/test/IECoreScene/FaceVaryingPromotionOpTest.py +++ b/test/IECoreScene/FaceVaryingPromotionOpTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene @@ -65,7 +66,7 @@ class FaceVaryingPromotionOpTest( unittest.TestCase ) : def __plane( self, indices = False ) : - p = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + p = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) IECoreScene.TriangulateOp()( input=p, copyInput=False ) for n in self.__inputValues.keys() : diff --git a/test/IECoreScene/FontTest.py b/test/IECoreScene/FontTest.py index 7eb7754ca6..e8d3c14d55 100644 --- a/test/IECoreScene/FontTest.py +++ b/test/IECoreScene/FontTest.py @@ -76,7 +76,7 @@ def testCharBound( self ) : for c in range( 0, 128 ) : bb = f.bound( chr( c ) ) - self.assert_( b.contains( bb ) ) + self.assertTrue( IECore.BoxAlgo.contains( b, bb ) ) def testThreading( self ) : diff --git a/test/IECoreScene/Group.py b/test/IECoreScene/Group.py index 93fa27faf1..b2c2eb45c1 100644 --- a/test/IECoreScene/Group.py +++ b/test/IECoreScene/Group.py @@ -35,6 +35,7 @@ import os import sys import unittest +import imath import IECore import IECoreScene @@ -44,11 +45,11 @@ def test( self ) : g = IECoreScene.Group() self.assertEqual( g.getTransform(), None ) - self.assertEqual( g.transformMatrix(), IECore.M44f() ) + self.assertEqual( g.transformMatrix(), imath.M44f() ) - g.setTransform( IECoreScene.MatrixTransform( IECore.M44f.createScaled( IECore.V3f( 2 ) ) ) ) - self.assertEqual( g.getTransform(), IECoreScene.MatrixTransform( IECore.M44f.createScaled( IECore.V3f( 2 ) ) ) ) - self.assertEqual( g.transformMatrix(), IECore.M44f.createScaled( IECore.V3f( 2 ) ) ) + g.setTransform( IECoreScene.MatrixTransform( imath.M44f().scale( imath.V3f( 2 ) ) ) ) + self.assertEqual( g.getTransform(), IECoreScene.MatrixTransform( imath.M44f().scale( imath.V3f( 2 ) ) ) ) + self.assertEqual( g.transformMatrix(), imath.M44f().scale( imath.V3f( 2 ) ) ) self.assertEqual( g.children(), [] ) self.assertEqual( g.state(), [] ) @@ -210,7 +211,7 @@ def testExceptions( self ) : def testTransformsNotState( self ) : g = IECoreScene.Group() - self.assertRaises( Exception, g.addState, IECoreScene.MatrixTransform( IECore.M44f() ) ) + self.assertRaises( Exception, g.addState, IECoreScene.MatrixTransform( imath.M44f() ) ) def testChildOrdering( self ) : @@ -284,7 +285,7 @@ def testHash( self ) : self.assertNotEqual( g.hash(), h ) h = g.hash() - g.setTransform( IECoreScene.MatrixTransform( IECore.M44f() ) ) + g.setTransform( IECoreScene.MatrixTransform( imath.M44f() ) ) self.assertNotEqual( g.hash(), h ) def testGlobalTransform( self ) : @@ -295,16 +296,20 @@ def testGlobalTransform( self ) : g.addChild( childGroup ) parentTransform = IECore.TransformationMatrixf() - parentTransform.rotate = IECore.Eulerf( 0,3.1415926/2,0 ) + parentTransform.rotate = imath.Eulerf( 0,3.1415926/2,0 ) childTransform = IECore.TransformationMatrixf() - childTransform.translate = IECore.V3f( 1, 0, 2 ) + childTransform.translate = imath.V3f( 1, 0, 2 ) childGroup.setTransform( IECoreScene.MatrixTransform( childTransform.transform ) ) g.setTransform( IECoreScene.MatrixTransform( parentTransform.transform ) ) # child group's translation should have been rotated 90 degrees about the y axis: - childGroupGlobalTranslation = childGroup.globalTransformMatrix().extractSHRT()[3] + s = imath.V3f() + h = imath.V3f() + r = imath.V3f() + childGroupGlobalTranslation = imath.V3f() + childGroup.globalTransformMatrix().extractSHRT( s, h, r, childGroupGlobalTranslation ) self.assertAlmostEqual( childGroupGlobalTranslation.x, 2, 4 ) self.assertAlmostEqual( childGroupGlobalTranslation.y, 0, 4 ) self.assertAlmostEqual( childGroupGlobalTranslation.z, -1, 4 ) diff --git a/test/IECoreScene/IDXReaderTest.py b/test/IECoreScene/IDXReaderTest.py index 7be5a0bf92..ec35b9ea4e 100644 --- a/test/IECoreScene/IDXReaderTest.py +++ b/test/IECoreScene/IDXReaderTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene @@ -66,12 +67,12 @@ def testReading( self ) : self.failUnless( k in c["PointID"].data ) for p in [ - IECore.V3f( 63.204863, 0.831837, -33.969296 ), - IECore.V3f( 62.345470, 0.707662, -34.099882 ), - IECore.V3f( 63.104346, 0.708060, -34.025762 ), - IECore.V3f( 63.096101, -0.973316, -34.031914 ), - IECore.V3f( 62.338136, -0.974567, -34.112893 ), - IECore.V3f( 54.252821, 0.716216, -34.849839 ), + imath.V3f( 63.204863, 0.831837, -33.969296 ), + imath.V3f( 62.345470, 0.707662, -34.099882 ), + imath.V3f( 63.104346, 0.708060, -34.025762 ), + imath.V3f( 63.096101, -0.973316, -34.031914 ), + imath.V3f( 62.338136, -0.974567, -34.112893 ), + imath.V3f( 54.252821, 0.716216, -34.849839 ), ]: self.failUnless( p in c["P"].data ) diff --git a/test/IECoreScene/LimitSmoothSkinningInfluencesOpTest.py b/test/IECoreScene/LimitSmoothSkinningInfluencesOpTest.py index 4984c80aaf..ab295a59e0 100644 --- a/test/IECoreScene/LimitSmoothSkinningInfluencesOpTest.py +++ b/test/IECoreScene/LimitSmoothSkinningInfluencesOpTest.py @@ -35,6 +35,7 @@ import math import unittest import random +import imath import IECore import IECoreScene @@ -44,7 +45,7 @@ class LimitSmoothSkinningInfluencesOpTest( unittest.TestCase ) : def createSSD( self, weights ) : names = IECore.StringVectorData( [ 'jointA', 'jointB', 'jointC' ] ) - poses = IECore.M44fVectorData( [IECore.M44f(1),IECore.M44f(2),IECore.M44f(3)] ) + poses = IECore.M44fVectorData( [imath.M44f(1),imath.M44f(2),imath.M44f(3)] ) offsets = IECore.IntVectorData( [0, 2, 5, 6, 8] ) counts = IECore.IntVectorData( [2, 3, 1, 2, 3] ) indices = IECore.IntVectorData( [0, 1, 0, 1, 2, 1, 1, 2, 0, 1, 2] ) @@ -92,7 +93,7 @@ def indexed( self ) : def compressedAfterIndexed( self ) : names = IECore.StringVectorData( [ 'jointA', 'jointB', 'jointC' ] ) - poses = IECore.M44fVectorData( [IECore.M44f(1),IECore.M44f(2),IECore.M44f(3)] ) + poses = IECore.M44fVectorData( [imath.M44f(1),imath.M44f(2),imath.M44f(3)] ) offsets = IECore.IntVectorData( [0, 1, 2, 2, 3] ) counts = IECore.IntVectorData( [1, 1, 0, 1, 2] ) indices = IECore.IntVectorData( [0, 0, 2, 0, 2] ) diff --git a/test/IECoreScene/LinkedSceneTest.py b/test/IECoreScene/LinkedSceneTest.py index e46c778746..2f33d1e57a 100644 --- a/test/IECoreScene/LinkedSceneTest.py +++ b/test/IECoreScene/LinkedSceneTest.py @@ -37,6 +37,7 @@ import os import math import unittest +import imath import IECore import IECoreScene @@ -45,12 +46,12 @@ class LinkedSceneTest( unittest.TestCase ) : @staticmethod def compareBBox( box1, box2 ): - errorTolerance = IECore.V3d(1e-5, 1e-5, 1e-5) - boxTmp = IECore.Box3d( box1.min - errorTolerance, box1.max + errorTolerance ) - if not boxTmp.contains( box2 ): + errorTolerance = imath.V3d(1e-5, 1e-5, 1e-5) + boxTmp = imath.Box3d( box1.min() - errorTolerance, box1.max() + errorTolerance ) + if not IECore.BoxAlgo.contains( boxTmp, box2 ): return False - boxTmp = IECore.Box3d( box2.min - errorTolerance, box2.max + errorTolerance ) - if not boxTmp.contains( box1 ): + boxTmp = imath.Box3d( box2.min() - errorTolerance, box2.max() + errorTolerance ) + if not IECore.BoxAlgo.contains( boxTmp, box1 ): return False return True @@ -145,10 +146,10 @@ def testWriting( self ): i1 = l.createChild("instance1") i1.writeLink( m ) i1.writeAttribute( "testAttr", IECore.StringData("test"), 0 ) - i1.writeTransform( IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 1, 0, 0 ) ) ), 0.0 ) + i1.writeTransform( IECore.M44dData( imath.M44d().translate( imath.V3d( 1, 0, 0 ) ) ), 0.0 ) i2 = l.createChild("instance2") i2.writeLink( A ) - i2.writeTransform( IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 2, 0, 0 ) ) ), 0.0 ) + i2.writeTransform( IECore.M44dData( imath.M44d().translate( imath.V3d( 2, 0, 0 ) ) ), 0.0 ) l.createChild("canHaveChildrenAtLinks") i2.writeTags( ["canHaveTagsAtLinks"] ) self.assertRaises( RuntimeError, i2.writeObject, IECoreScene.SpherePrimitive( 1 ), 0.0 ) # cannot save objects at link locations. @@ -166,33 +167,33 @@ def testWriting( self ): self.assertEqual( set(l.childNames()), set(["canHaveChildrenAtLinks",'instance0','instance1','instance2','branch1','branch2']) ) i0 = l.child("instance0") self.assertEqual( i0.numBoundSamples(), 4 ) - self.failUnless( LinkedSceneTest.compareBBox( i0.readBoundAtSample(0), IECore.Box3d( IECore.V3d( -1,-1,-1 ), IECore.V3d( 2,2,1 ) ) ) ) - self.failUnless( LinkedSceneTest.compareBBox( i0.readBoundAtSample(1), IECore.Box3d( IECore.V3d( -1,-1,-1 ), IECore.V3d( 3,3,1 ) ) ) ) - self.failUnless( LinkedSceneTest.compareBBox( i0.readBoundAtSample(2), IECore.Box3d( IECore.V3d( -2,-1,-2 ), IECore.V3d( 4,5,2 ) ) ) ) - self.failUnless( LinkedSceneTest.compareBBox( i0.readBoundAtSample(3), IECore.Box3d( IECore.V3d( -3,-1,-3 ), IECore.V3d( 4,6,3 ) ) ) ) - self.failUnless( LinkedSceneTest.compareBBox( i0.readBound(0), IECore.Box3d( IECore.V3d( -1,-1,-1 ), IECore.V3d( 2,2,1 ) ) ) ) + self.failUnless( LinkedSceneTest.compareBBox( i0.readBoundAtSample(0), imath.Box3d( imath.V3d( -1,-1,-1 ), imath.V3d( 2,2,1 ) ) ) ) + self.failUnless( LinkedSceneTest.compareBBox( i0.readBoundAtSample(1), imath.Box3d( imath.V3d( -1,-1,-1 ), imath.V3d( 3,3,1 ) ) ) ) + self.failUnless( LinkedSceneTest.compareBBox( i0.readBoundAtSample(2), imath.Box3d( imath.V3d( -2,-1,-2 ), imath.V3d( 4,5,2 ) ) ) ) + self.failUnless( LinkedSceneTest.compareBBox( i0.readBoundAtSample(3), imath.Box3d( imath.V3d( -3,-1,-3 ), imath.V3d( 4,6,3 ) ) ) ) + self.failUnless( LinkedSceneTest.compareBBox( i0.readBound(0), imath.Box3d( imath.V3d( -1,-1,-1 ), imath.V3d( 2,2,1 ) ) ) ) A = i0.child("A") - self.failUnless( LinkedSceneTest.compareBBox( A.readBoundAtSample(0), IECore.Box3d(IECore.V3d( -1,-1,-1 ), IECore.V3d( 1,1,1 ) ) ) ) - self.failUnless( LinkedSceneTest.compareBBox( A.readBoundAtSample(1), IECore.Box3d(IECore.V3d( -1,-1,-1 ), IECore.V3d( 1,1,1 ) ) ) ) - self.failUnless( LinkedSceneTest.compareBBox( A.readBoundAtSample(2), IECore.Box3d(IECore.V3d( 0,-1,-1 ), IECore.V3d( 2,1,1 ) ) ) ) - self.assertEqual( i0.readTransform( 0 ), IECore.M44dData( IECore.M44d() ) ) + self.failUnless( LinkedSceneTest.compareBBox( A.readBoundAtSample(0), imath.Box3d(imath.V3d( -1,-1,-1 ), imath.V3d( 1,1,1 ) ) ) ) + self.failUnless( LinkedSceneTest.compareBBox( A.readBoundAtSample(1), imath.Box3d(imath.V3d( -1,-1,-1 ), imath.V3d( 1,1,1 ) ) ) ) + self.failUnless( LinkedSceneTest.compareBBox( A.readBoundAtSample(2), imath.Box3d(imath.V3d( 0,-1,-1 ), imath.V3d( 2,1,1 ) ) ) ) + self.assertEqual( i0.readTransform( 0 ), IECore.M44dData( imath.M44d() ) ) i1 = l.child("instance1") self.assertEqual( i1.numBoundSamples(), 4 ) - self.failUnless( LinkedSceneTest.compareBBox( i1.readBoundAtSample(0), IECore.Box3d( IECore.V3d( -1,-1,-1 ), IECore.V3d( 2,2,1 ) ) ) ) - self.failUnless( LinkedSceneTest.compareBBox( i1.readBoundAtSample(2), IECore.Box3d( IECore.V3d( -2,-1,-2 ), IECore.V3d( 4,5,2 ) ) ) ) - self.failUnless( LinkedSceneTest.compareBBox( i1.readBoundAtSample(3), IECore.Box3d( IECore.V3d( -3,-1,-3 ), IECore.V3d( 4,6,3 ) ) ) ) - self.failUnless( LinkedSceneTest.compareBBox( i1.readBound(0), IECore.Box3d( IECore.V3d( -1,-1,-1 ), IECore.V3d( 2,2,1 ) ) ) ) - self.assertEqual( i1.readTransform( 0 ), IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 1, 0, 0 ) ) ) ) + self.failUnless( LinkedSceneTest.compareBBox( i1.readBoundAtSample(0), imath.Box3d( imath.V3d( -1,-1,-1 ), imath.V3d( 2,2,1 ) ) ) ) + self.failUnless( LinkedSceneTest.compareBBox( i1.readBoundAtSample(2), imath.Box3d( imath.V3d( -2,-1,-2 ), imath.V3d( 4,5,2 ) ) ) ) + self.failUnless( LinkedSceneTest.compareBBox( i1.readBoundAtSample(3), imath.Box3d( imath.V3d( -3,-1,-3 ), imath.V3d( 4,6,3 ) ) ) ) + self.failUnless( LinkedSceneTest.compareBBox( i1.readBound(0), imath.Box3d( imath.V3d( -1,-1,-1 ), imath.V3d( 2,2,1 ) ) ) ) + self.assertEqual( i1.readTransform( 0 ), IECore.M44dData( imath.M44d().translate( imath.V3d( 1, 0, 0 ) ) ) ) self.assertEqual( i1.readAttribute( "testAttr", 0 ), IECore.StringData("test") ) i2 = l.child("instance2") self.assertEqual( i2.numBoundSamples(), 3 ) - self.failUnless( LinkedSceneTest.compareBBox( i2.readBoundAtSample(0), IECore.Box3d(IECore.V3d( -1,-1,-1 ), IECore.V3d( 1,1,1 ) ) ) ) - self.failUnless( LinkedSceneTest.compareBBox( i2.readBoundAtSample(1), IECore.Box3d(IECore.V3d( -1,-1,-1 ), IECore.V3d( 1,1,1 ) ) ) ) - self.failUnless( LinkedSceneTest.compareBBox( i2.readBoundAtSample(2), IECore.Box3d(IECore.V3d( 0,-1,-1 ), IECore.V3d( 2,1,1 ) ) ) ) - self.assertEqual( i2.readTransform( 0 ), IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 2, 0, 0 ) ) ) ) + self.failUnless( LinkedSceneTest.compareBBox( i2.readBoundAtSample(0), imath.Box3d(imath.V3d( -1,-1,-1 ), imath.V3d( 1,1,1 ) ) ) ) + self.failUnless( LinkedSceneTest.compareBBox( i2.readBoundAtSample(1), imath.Box3d(imath.V3d( -1,-1,-1 ), imath.V3d( 1,1,1 ) ) ) ) + self.failUnless( LinkedSceneTest.compareBBox( i2.readBoundAtSample(2), imath.Box3d(imath.V3d( 0,-1,-1 ), imath.V3d( 2,1,1 ) ) ) ) + self.assertEqual( i2.readTransform( 0 ), IECore.M44dData( imath.M44d().translate( imath.V3d( 2, 0, 0 ) ) ) ) self.assertTrue( i2.hasTag( "canHaveTagsAtLinks", IECoreScene.SceneInterface.TagFilter.EveryTag ) ) self.assertTrue( l.hasTag( "canHaveTagsAtLinks", IECoreScene.SceneInterface.TagFilter.EveryTag ) ) # tags propagate up self.assertTrue( i2.child("a").hasTag( "canHaveTagsAtLinks", IECoreScene.SceneInterface.TagFilter.EveryTag ) ) # tags at link locations propagate down as well @@ -229,8 +230,8 @@ def testWriteLinkAnimatedTransform( self ): # this was causing a problem upon deleting l, as the first transform sample doesn't coincide with the # first bound sample in the link - i0.writeTransform( IECore.M44dData( IECore.M44d() ), 5.0 ) - i0.writeTransform( IECore.M44dData( IECore.M44d() ), 6.0 ) + i0.writeTransform( IECore.M44dData( imath.M44d() ), 5.0 ) + i0.writeTransform( IECore.M44dData( imath.M44d() ), 6.0 ) del i0, l, m @@ -278,10 +279,10 @@ def testTimeRemapping( self ): self.assertEqual( A0.numBoundSamples(), 2 ) self.assertEqual( A0.numTransformSamples(), 2 ) - self.failUnless( LinkedSceneTest.compareBBox( A0.readBoundAtSample(0), IECore.Box3d(IECore.V3d( -1,-1,-1 ), IECore.V3d( 1,1,1 ) ) ) ) - self.failUnless( LinkedSceneTest.compareBBox( A0.readBoundAtSample(1), IECore.Box3d(IECore.V3d( 0,-1,-1 ), IECore.V3d( 2,1,1 ) ) ) ) - self.assertEqual( A0.readTransformAtSample(0), IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 1, 0, 0 ) ) ) ) - self.assertEqual( A0.readTransformAtSample(1), IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 2, 0, 0 ) ) ) ) + self.failUnless( LinkedSceneTest.compareBBox( A0.readBoundAtSample(0), imath.Box3d(imath.V3d( -1,-1,-1 ), imath.V3d( 1,1,1 ) ) ) ) + self.failUnless( LinkedSceneTest.compareBBox( A0.readBoundAtSample(1), imath.Box3d(imath.V3d( 0,-1,-1 ), imath.V3d( 2,1,1 ) ) ) ) + self.assertEqual( A0.readTransformAtSample(0), IECore.M44dData( imath.M44d().translate( imath.V3d( 1, 0, 0 ) ) ) ) + self.assertEqual( A0.readTransformAtSample(1), IECore.M44dData( imath.M44d().translate( imath.V3d( 2, 0, 0 ) ) ) ) i1 = l.child("instance1") self.assertEqual( i1.hasAttribute( "sceneInterface:link.time" ), True ) @@ -294,10 +295,10 @@ def testTimeRemapping( self ): self.assertEqual( i1.numTransformSamples(), 1 ) A1 = i1.child("A") self.assertEqual( A1.numTransformSamples(), 4 ) - self.assertEqual( A1.readTransformAtSample(0), IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 1, 0, 0 ) ) ) ) - self.assertEqual( A1.readTransformAtSample(1), IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 2, 0, 0 ) ) ) ) - self.assertEqual( A1.readTransformAtSample(2), IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 2, 0, 0 ) ) ) ) - self.assertEqual( A1.readTransformAtSample(3), IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 2, 0, 0 ) ) ) ) + self.assertEqual( A1.readTransformAtSample(0), IECore.M44dData( imath.M44d().translate( imath.V3d( 1, 0, 0 ) ) ) ) + self.assertEqual( A1.readTransformAtSample(1), IECore.M44dData( imath.M44d().translate( imath.V3d( 2, 0, 0 ) ) ) ) + self.assertEqual( A1.readTransformAtSample(2), IECore.M44dData( imath.M44d().translate( imath.V3d( 2, 0, 0 ) ) ) ) + self.assertEqual( A1.readTransformAtSample(3), IECore.M44dData( imath.M44d().translate( imath.V3d( 2, 0, 0 ) ) ) ) self.assertEqual( A1.hasAttribute( "sceneInterface:link.time" ), False ) @@ -313,10 +314,10 @@ def testTimeRemapping( self ): A2 = i2.child("A") self.assertEqual( A2.numBoundSamples(), 3 ) self.assertEqual( A2.numTransformSamples(), 3 ) - self.assertEqual( A2.readTransform(1.0), IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 1.5, 0, 0 ) ) ) ) - self.assertEqual( A2.readTransformAtSample(0), IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 1, 0, 0 ) ) ) ) - self.assertEqual( A2.readTransformAtSample(1), IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 1.5, 0, 0 ) ) ) ) - self.assertEqual( A2.readTransformAtSample(2), IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 2, 0, 0 ) ) ) ) + self.assertEqual( A2.readTransform(1.0), IECore.M44dData( imath.M44d().translate( imath.V3d( 1.5, 0, 0 ) ) ) ) + self.assertEqual( A2.readTransformAtSample(0), IECore.M44dData( imath.M44d().translate( imath.V3d( 1, 0, 0 ) ) ) ) + self.assertEqual( A2.readTransformAtSample(1), IECore.M44dData( imath.M44d().translate( imath.V3d( 1.5, 0, 0 ) ) ) ) + self.assertEqual( A2.readTransformAtSample(2), IECore.M44dData( imath.M44d().translate( imath.V3d( 2, 0, 0 ) ) ) ) self.assertEqual( A2.hasAttribute( "sceneInterface:link.time" ), False ) @@ -665,10 +666,10 @@ def testMissingLinkedScene( self ) : i0.writeLink( m ) i1 = l.createChild("instance1") i1.writeLink( m ) - i1.writeTransform( IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 1, 0, 0 ) ) ), 0.0 ) + i1.writeTransform( IECore.M44dData( imath.M44d().translate( imath.V3d( 1, 0, 0 ) ) ), 0.0 ) i2 = l.createChild("instance2") i2.writeLink( A ) - i2.writeTransform( IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 2, 0, 0 ) ) ), 0.0 ) + i2.writeTransform( IECore.M44dData( imath.M44d().translate( imath.V3d( 2, 0, 0 ) ) ), 0.0 ) del i0, i1, i2, l, m, A l = IECoreScene.LinkedScene( "/tmp/test.lscc", IECore.IndexedIO.OpenMode.Read ) @@ -697,7 +698,7 @@ def testLinkBoundTransformMismatch( self ) : scene = IECoreScene.SceneCache( "/tmp/test.scc", IECore.IndexedIO.OpenMode.Write ) child = scene.createChild( "child" ) - mesh = IECoreScene.MeshPrimitive.createBox( IECore.Box3f( IECore.V3f( 0 ), IECore.V3f( 1 ) ) ) + mesh = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( 0 ), imath.V3f( 1 ) ) ) child.writeObject( mesh, 0 ) del scene, child @@ -706,7 +707,7 @@ def testLinkBoundTransformMismatch( self ) : linked = IECoreScene.LinkedScene( "/tmp/test.lscc", IECore.IndexedIO.OpenMode.Write ) parent = linked.createChild( "parent" ) - transform = IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 1, 0, 0 ) ) ) + transform = IECore.M44dData( imath.M44d().translate( imath.V3d( 1, 0, 0 ) ) ) parent.writeTransform( transform, 1.0 ) parent.writeObject( mesh, 1.0 ) childLink = parent.createChild( "childLink" ) @@ -729,16 +730,16 @@ def testLinkBoundTransformMismatch( self ) : self.assertEqual( childLink.numTransformSamples(), 1 ) # object at the origin - self.failUnless( LinkedSceneTest.compareBBox( childLink.readBoundAtSample( 0 ), IECore.Box3d( IECore.V3d( 0 ), IECore.V3d( 1 ) ) ) ) + self.failUnless( LinkedSceneTest.compareBBox( childLink.readBoundAtSample( 0 ), imath.Box3d( imath.V3d( 0 ), imath.V3d( 1 ) ) ) ) # transformed the childLink by ( 1, 0, 0 ) and added an object at the origin self.assertEqual( childLink.readTransformAtSample( 0 ), transform ) - self.failUnless( LinkedSceneTest.compareBBox( parent.readBoundAtSample( 0 ), IECore.Box3d( IECore.V3d( 0 ), IECore.V3d( 2, 1, 1 ) ) ) ) + self.failUnless( LinkedSceneTest.compareBBox( parent.readBoundAtSample( 0 ), imath.Box3d( imath.V3d( 0 ), imath.V3d( 2, 1, 1 ) ) ) ) self.failUnless( LinkedSceneTest.compareBBox( parent.readBoundAtSample( 0 ), parent.readBoundAtSample( 1 ) ) ) # transformed the parent by ( 1, 0, 0 ) self.assertEqual( parent.readTransformAtSample( 0 ), transform ) - self.failUnless( LinkedSceneTest.compareBBox( linked.readBoundAtSample( 0 ), IECore.Box3d( IECore.V3d( 1, 0, 0 ), IECore.V3d( 3, 1, 1 ) ) ) ) + self.failUnless( LinkedSceneTest.compareBBox( linked.readBoundAtSample( 0 ), imath.Box3d( imath.V3d( 1, 0, 0 ), imath.V3d( 3, 1, 1 ) ) ) ) self.failUnless( LinkedSceneTest.compareBBox( linked.readBoundAtSample( 0 ), linked.readBoundAtSample( 1 ) ) ) def testMemoryIndexedIOReadWrite( self ) : @@ -789,7 +790,7 @@ def testHashes( self ): i2 = l.createChild("instance2") i2.writeLink( m ) c = i2.createChild("c") - c.writeBound( IECore.Box3d( IECore.V3d(-100), IECore.V3d(100) ), 0 ) + c.writeBound( imath.Box3d( imath.V3d(-100), imath.V3d(100) ), 0 ) del i0, i1, i2, l, m, c l = IECoreScene.LinkedScene( sceneFile, IECore.IndexedIO.OpenMode.Read ) @@ -943,7 +944,7 @@ def testWriteExtraChildrenAtLink( self ) : # give it an extra child: C = link.createChild( "C" ) C.writeTags( ["stuff"] ) - C.writeTransform( IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 10, 0, 0 ) ) ), 0.0 ) + C.writeTransform( IECore.M44dData( imath.M44d().translate( imath.V3d( 10, 0, 0 ) ) ), 0.0 ) C.writeObject( IECoreScene.SpherePrimitive( 1 ), 0.0 ) del C, l, link @@ -953,17 +954,17 @@ def testWriteExtraChildrenAtLink( self ) : C = link.child("C") # check the bounding box has been dilated at the link: - expectedBox = IECore.Box3f( IECore.V3f( -1.0000002384185791, -1, -1.0000004768371582 ), IECore.V3f( 2, 2, 1.0000001192092896 ) ) - expectedBox.extendBy( IECore.Box3f( IECore.V3f(9,-1,-1), IECore.V3f(11,-1,-1) ) ) + expectedBox = imath.Box3f( imath.V3f( -1.0000002384185791, -1, -1.0000004768371582 ), imath.V3f( 2, 2, 1.0000001192092896 ) ) + expectedBox.extendBy( imath.Box3f( imath.V3f(9,-1,-1), imath.V3f(11,-1,-1) ) ) bbox = link.readBound( 0 ) - self.assertAlmostEqual( bbox.min.x, expectedBox.min.x, 5 ) - self.assertAlmostEqual( bbox.min.y, expectedBox.min.y, 5 ) - self.assertAlmostEqual( bbox.min.z, expectedBox.min.z, 5 ) + self.assertAlmostEqual( bbox.min().x, expectedBox.min().x, 5 ) + self.assertAlmostEqual( bbox.min().y, expectedBox.min().y, 5 ) + self.assertAlmostEqual( bbox.min().z, expectedBox.min().z, 5 ) - self.assertAlmostEqual( bbox.max.x, expectedBox.max.x, 5 ) - self.assertAlmostEqual( bbox.max.y, expectedBox.max.y, 5 ) - self.assertAlmostEqual( bbox.max.z, expectedBox.max.z, 5 ) + self.assertAlmostEqual( bbox.max().x, expectedBox.max().x, 5 ) + self.assertAlmostEqual( bbox.max().y, expectedBox.max().y, 5 ) + self.assertAlmostEqual( bbox.max().z, expectedBox.max().z, 5 ) # bounding box should have propagated up: self.assertEqual( l.readBound( 0 ), bbox ) diff --git a/test/IECoreScene/MeshAlgoDeleteFacesTest.py b/test/IECoreScene/MeshAlgoDeleteFacesTest.py index c4cdd4d576..78c7b4df08 100644 --- a/test/IECoreScene/MeshAlgoDeleteFacesTest.py +++ b/test/IECoreScene/MeshAlgoDeleteFacesTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene @@ -43,8 +44,8 @@ def makeQuadTriangleMesh( self ): verticesPerFace = IECore.IntVectorData( [ 3, 3 ] ) vertexIds = IECore.IntVectorData( [ 0, 1, 2, 0, 2, 3 ] ) - p = IECore.V3fVectorData( [ IECore.V3f( 0, 0, 0 ), IECore.V3f( 1, 0, 0 ), IECore.V3f( 1, 1, 0 ), IECore.V3f( 0, 1, 0 ) ] ) - uv = IECore.V2fVectorData( [ IECore.V2f( 0, 0 ), IECore.V2f( 1, 0 ), IECore.V2f( 1, 1 ), IECore.V2f( 0, 0 ), IECore.V2f( 1, 1 ), IECore.V2f( 0, 1 ) ] ) + p = IECore.V3fVectorData( [ imath.V3f( 0, 0, 0 ), imath.V3f( 1, 0, 0 ), imath.V3f( 1, 1, 0 ), imath.V3f( 0, 1, 0 ) ] ) + uv = IECore.V2fVectorData( [ imath.V2f( 0, 0 ), imath.V2f( 1, 0 ), imath.V2f( 1, 1 ), imath.V2f( 0, 0 ), imath.V2f( 1, 1 ), imath.V2f( 0, 1 ) ] ) mesh = IECoreScene.MeshPrimitive( verticesPerFace, vertexIds, "linear", p ) mesh["uv"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, uv ) @@ -52,7 +53,7 @@ def makeQuadTriangleMesh( self ): return mesh def testHandlesInvalidPrimvarType( self ) : - deleteAttributeData = IECore.V3fVectorData( [ IECore.V3f( 0, 0, 0 ), IECore.V3f( 1, 0, 0 ), IECore.V3f( 1, 1, 0 ), IECore.V3f( 0, 1, 0 ) ] ) + deleteAttributeData = IECore.V3fVectorData( [ imath.V3f( 0, 0, 0 ), imath.V3f( 1, 0, 0 ), imath.V3f( 1, 1, 0 ), imath.V3f( 0, 1, 0 ) ] ) mesh = self.makeQuadTriangleMesh() mesh["delete"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, deleteAttributeData ) @@ -94,8 +95,8 @@ def testNoFacesRemovedIfFlagIsTrueButIfInverted( self ) : self.assertEqual( facesDeletedMesh.verticesPerFace, IECore.IntVectorData( [ 3, 3 ] ) ) self.assertEqual( facesDeletedMesh.vertexIds, IECore.IntVectorData( [ 0, 1, 2, 0, 2, 3 ] ) ) - self.assertEqual( facesDeletedMesh["uv"].data, IECore.V2fVectorData( [ IECore.V2f( 0, 0 ), IECore.V2f( 1, 0 ), IECore.V2f( 1, 1 ), IECore.V2f( 0, 0 ), IECore.V2f( 1, 1 ), IECore.V2f( 0, 1 ) ] ) ) - self.assertEqual( facesDeletedMesh["P"].data, IECore.V3fVectorData( [ IECore.V3f( 0, 0, 0 ), IECore.V3f( 1, 0, 0 ), IECore.V3f( 1, 1, 0 ), IECore.V3f( 0, 1, 0 ) ] ) ) + self.assertEqual( facesDeletedMesh["uv"].data, IECore.V2fVectorData( [ imath.V2f( 0, 0 ), imath.V2f( 1, 0 ), imath.V2f( 1, 1 ), imath.V2f( 0, 0 ), imath.V2f( 1, 1 ), imath.V2f( 0, 1 ) ] ) ) + self.assertEqual( facesDeletedMesh["P"].data, IECore.V3fVectorData( [ imath.V3f( 0, 0, 0 ), imath.V3f( 1, 0, 0 ), imath.V3f( 1, 1, 0 ), imath.V3f( 0, 1, 0 ) ] ) ) self.assertEqual( facesDeletedMesh["delete"].data, IECore.IntVectorData( [1, 1] ) ) @@ -111,9 +112,9 @@ def testCanRemoveFirstFace( self ) : self.assertEqual( facesDeletedMesh.verticesPerFace, IECore.IntVectorData( [3] ) ) self.assertEqual( facesDeletedMesh.vertexIds, IECore.IntVectorData( [0, 1, 2] ) ) - self.assertEqual( facesDeletedMesh["uv"].data, IECore.V2fVectorData( [ IECore.V2f( 0, 0 ), IECore.V2f( 1, 1 ), IECore.V2f( 0, 1 ) ] ) ) + self.assertEqual( facesDeletedMesh["uv"].data, IECore.V2fVectorData( [ imath.V2f( 0, 0 ), imath.V2f( 1, 1 ), imath.V2f( 0, 1 ) ] ) ) - self.assertEqual( facesDeletedMesh["P"].data, IECore.V3fVectorData( [ IECore.V3f( 0, 0, 0 ), IECore.V3f( 1, 1, 0 ), IECore.V3f( 0, 1, 0 ) ] ) ) + self.assertEqual( facesDeletedMesh["P"].data, IECore.V3fVectorData( [ imath.V3f( 0, 0, 0 ), imath.V3f( 1, 1, 0 ), imath.V3f( 0, 1, 0 ) ] ) ) self.assertEqual( facesDeletedMesh["delete"].data, IECore.IntVectorData( [0] ) ) def testRemovesAllButFirstIfInverted( self ) : @@ -128,8 +129,8 @@ def testRemovesAllButFirstIfInverted( self ) : self.assertEqual( facesDeletedMesh.verticesPerFace, IECore.IntVectorData( [ 3 ] ) ) self.assertEqual( facesDeletedMesh.vertexIds, IECore.IntVectorData( [ 0, 1, 2 ] ) ) - self.assertEqual( facesDeletedMesh["uv"].data, IECore.V2fVectorData( [ IECore.V2f( 0, 0 ), IECore.V2f( 1, 0 ), IECore.V2f( 1, 1 ) ] ) ) - self.assertEqual( facesDeletedMesh["P"].data, IECore.V3fVectorData( [ IECore.V3f( 0, 0, 0 ), IECore.V3f( 1, 0, 0 ), IECore.V3f( 1, 1, 0 ) ] ) ) + self.assertEqual( facesDeletedMesh["uv"].data, IECore.V2fVectorData( [ imath.V2f( 0, 0 ), imath.V2f( 1, 0 ), imath.V2f( 1, 1 ) ] ) ) + self.assertEqual( facesDeletedMesh["P"].data, IECore.V3fVectorData( [ imath.V3f( 0, 0, 0 ), imath.V3f( 1, 0, 0 ), imath.V3f( 1, 1, 0 ) ] ) ) self.assertEqual( facesDeletedMesh["delete"].data, IECore.IntVectorData( [1] ) ) def testCanRemoveFirstFaceBool( self ) : @@ -144,9 +145,9 @@ def testCanRemoveFirstFaceBool( self ) : self.assertEqual( facesDeletedMesh.verticesPerFace, IECore.IntVectorData( [ 3 ] ) ) self.assertEqual( facesDeletedMesh.vertexIds, IECore.IntVectorData( [0, 1, 2] ) ) - self.assertEqual( facesDeletedMesh["uv"].data, IECore.V2fVectorData( [ IECore.V2f( 0, 0 ), IECore.V2f( 1, 1 ), IECore.V2f( 0, 1 ) ] ) ) + self.assertEqual( facesDeletedMesh["uv"].data, IECore.V2fVectorData( [ imath.V2f( 0, 0 ), imath.V2f( 1, 1 ), imath.V2f( 0, 1 ) ] ) ) - self.assertEqual( facesDeletedMesh["P"].data, IECore.V3fVectorData( [ IECore.V3f( 0, 0, 0 ), IECore.V3f( 1, 1, 0 ), IECore.V3f( 0, 1, 0 ) ] ) ) + self.assertEqual( facesDeletedMesh["P"].data, IECore.V3fVectorData( [ imath.V3f( 0, 0, 0 ), imath.V3f( 1, 1, 0 ), imath.V3f( 0, 1, 0 ) ] ) ) self.assertEqual( facesDeletedMesh["delete"].data, IECore.BoolVectorData( [False] ) ) def testRemovesAllButFirstIfInvertedBool( self ) : @@ -161,8 +162,8 @@ def testRemovesAllButFirstIfInvertedBool( self ) : self.assertEqual( facesDeletedMesh.verticesPerFace, IECore.IntVectorData( [ 3 ] ) ) self.assertEqual( facesDeletedMesh.vertexIds, IECore.IntVectorData( [ 0, 1, 2 ] ) ) - self.assertEqual( facesDeletedMesh["uv"].data, IECore.V2fVectorData( [ IECore.V2f( 0, 0 ), IECore.V2f( 1, 0 ), IECore.V2f( 1, 1 ) ] ) ) - self.assertEqual( facesDeletedMesh["P"].data, IECore.V3fVectorData( [ IECore.V3f( 0, 0, 0 ), IECore.V3f( 1, 0, 0 ), IECore.V3f( 1, 1, 0 ) ] ) ) + self.assertEqual( facesDeletedMesh["uv"].data, IECore.V2fVectorData( [ imath.V2f( 0, 0 ), imath.V2f( 1, 0 ), imath.V2f( 1, 1 ) ] ) ) + self.assertEqual( facesDeletedMesh["P"].data, IECore.V3fVectorData( [ imath.V3f( 0, 0, 0 ), imath.V3f( 1, 0, 0 ), imath.V3f( 1, 1, 0 ) ] ) ) self.assertEqual( facesDeletedMesh["delete"].data, IECore.BoolVectorData( [True] ) ) def testCanRemoveFirstFaceFloat( self ) : @@ -177,9 +178,9 @@ def testCanRemoveFirstFaceFloat( self ) : self.assertEqual( facesDeletedMesh.verticesPerFace, IECore.IntVectorData( [3] ) ) self.assertEqual( facesDeletedMesh.vertexIds, IECore.IntVectorData( [0, 1, 2] ) ) - self.assertEqual( facesDeletedMesh["uv"].data, IECore.V2fVectorData( [ IECore.V2f( 0, 0 ), IECore.V2f( 1, 1 ), IECore.V2f( 0, 1 ) ] ) ) + self.assertEqual( facesDeletedMesh["uv"].data, IECore.V2fVectorData( [ imath.V2f( 0, 0 ), imath.V2f( 1, 1 ), imath.V2f( 0, 1 ) ] ) ) - self.assertEqual( facesDeletedMesh["P"].data, IECore.V3fVectorData( [ IECore.V3f( 0, 0, 0 ), IECore.V3f( 1, 1, 0 ), IECore.V3f( 0, 1, 0 ) ] ) ) + self.assertEqual( facesDeletedMesh["P"].data, IECore.V3fVectorData( [ imath.V3f( 0, 0, 0 ), imath.V3f( 1, 1, 0 ), imath.V3f( 0, 1, 0 ) ] ) ) self.assertEqual( facesDeletedMesh["delete"].data, IECore.FloatVectorData( [0.0] ) ) @@ -195,8 +196,8 @@ def testRemovesAllButFirstIfInvertedFloat( self ) : self.assertEqual( facesDeletedMesh.verticesPerFace, IECore.IntVectorData( [ 3 ] ) ) self.assertEqual( facesDeletedMesh.vertexIds, IECore.IntVectorData( [ 0, 1, 2 ] ) ) - self.assertEqual( facesDeletedMesh["uv"].data, IECore.V2fVectorData( [ IECore.V2f( 0, 0 ), IECore.V2f( 1, 0 ), IECore.V2f( 1, 1 ) ] ) ) - self.assertEqual( facesDeletedMesh["P"].data, IECore.V3fVectorData( [ IECore.V3f( 0, 0, 0 ), IECore.V3f( 1, 0, 0 ), IECore.V3f( 1, 1, 0 ) ] ) ) + self.assertEqual( facesDeletedMesh["uv"].data, IECore.V2fVectorData( [ imath.V2f( 0, 0 ), imath.V2f( 1, 0 ), imath.V2f( 1, 1 ) ] ) ) + self.assertEqual( facesDeletedMesh["P"].data, IECore.V3fVectorData( [ imath.V3f( 0, 0, 0 ), imath.V3f( 1, 0, 0 ), imath.V3f( 1, 1, 0 ) ] ) ) self.assertEqual( facesDeletedMesh["delete"].data, IECore.FloatVectorData( [1.0] ) ) if __name__ == "__main__": diff --git a/test/IECoreScene/MeshAlgoDistortionsTest.py b/test/IECoreScene/MeshAlgoDistortionsTest.py index e08ee51661..ceca608b20 100644 --- a/test/IECoreScene/MeshAlgoDistortionsTest.py +++ b/test/IECoreScene/MeshAlgoDistortionsTest.py @@ -35,6 +35,7 @@ import math import unittest import random +import imath import IECore import IECoreScene @@ -53,18 +54,18 @@ def testSimple( self ) : 6,7,11,10 ] ) pRef = IECore.V3fVectorData( [ - IECore.V3f( -1,-1, 0 ), IECore.V3f( 0,-1, 0 ), IECore.V3f( 1,-1, 0 ), IECore.V3f( 2,-1, 0 ), - IECore.V3f( -1, 0, 0 ), IECore.V3f( 0, 0, 0 ), IECore.V3f( 1, 0, 0 ), IECore.V3f( 2, 0, 0 ), - IECore.V3f( -1, 1, 0 ), IECore.V3f( 0, 1, 0 ), IECore.V3f( 1, 1, 0 ), IECore.V3f( 2, 1, 0 ), + imath.V3f( -1,-1, 0 ), imath.V3f( 0,-1, 0 ), imath.V3f( 1,-1, 0 ), imath.V3f( 2,-1, 0 ), + imath.V3f( -1, 0, 0 ), imath.V3f( 0, 0, 0 ), imath.V3f( 1, 0, 0 ), imath.V3f( 2, 0, 0 ), + imath.V3f( -1, 1, 0 ), imath.V3f( 0, 1, 0 ), imath.V3f( 1, 1, 0 ), imath.V3f( 2, 1, 0 ), ] ) # p moves vertex from (0,0,0) to (0.5,0.5,0) p = pRef.copy() - p[5] = IECore.V3f( 0.5, 0.5, 0 ) + p[5] = imath.V3f( 0.5, 0.5, 0 ) uvs = IECore.V2fVectorData() for v in vertexIds : - uvs.append( IECore.V2f( p[v][0], p[v][1] ) ) + uvs.append( imath.V2f( p[v][0], p[v][1] ) ) m = IECoreScene.MeshPrimitive( verticesPerFace, vertexIds, "linear", p ) m['Pref'] = IECoreScene.PrimitiveVariable( m['P'].interpolation, pRef ) @@ -87,30 +88,30 @@ def vec2Err( vec ): return acc uvExpected = IECore.V2fVectorData( [ - IECore.V2f( 0, 0 ), - IECore.V2f( 0.0918861, 0.275658 ), - IECore.V2f( 0.0373256, 0.0373256 ), - IECore.V2f( 0.275658, 0.0918861 ), - IECore.V2f( 0.0918861, 0.275658 ), - IECore.V2f( 0, 0 ), - IECore.V2f( -0.0732233, -0.0732233 ), - IECore.V2f( 0.0373256, 0.0373256 ), - IECore.V2f( 0, 0 ), - IECore.V2f( 0, 0 ), - IECore.V2f( 0, 0 ), - IECore.V2f( -0.0732233, -0.0732233 ), - IECore.V2f( 0.275658, 0.091886 ), - IECore.V2f( 0.0373256, 0.0373256 ), - IECore.V2f( -0.146447, -0.146447 ), - IECore.V2f( 0, 0 ), - IECore.V2f( 0.0373256, 0.0373256 ), - IECore.V2f( -0.0732233,-0.0732233 ), - IECore.V2f( 0, 0 ), - IECore.V2f( -0.146447, -0.146447 ), - IECore.V2f( -0.0732233, -0.0732233 ), - IECore.V2f( 0, 0 ), - IECore.V2f( 0, 0 ), - IECore.V2f( 0, 0 ), + imath.V2f( 0, 0 ), + imath.V2f( 0.0918861, 0.275658 ), + imath.V2f( 0.0373256, 0.0373256 ), + imath.V2f( 0.275658, 0.0918861 ), + imath.V2f( 0.0918861, 0.275658 ), + imath.V2f( 0, 0 ), + imath.V2f( -0.0732233, -0.0732233 ), + imath.V2f( 0.0373256, 0.0373256 ), + imath.V2f( 0, 0 ), + imath.V2f( 0, 0 ), + imath.V2f( 0, 0 ), + imath.V2f( -0.0732233, -0.0732233 ), + imath.V2f( 0.275658, 0.091886 ), + imath.V2f( 0.0373256, 0.0373256 ), + imath.V2f( -0.146447, -0.146447 ), + imath.V2f( 0, 0 ), + imath.V2f( 0.0373256, 0.0373256 ), + imath.V2f( -0.0732233,-0.0732233 ), + imath.V2f( 0, 0 ), + imath.V2f( -0.146447, -0.146447 ), + imath.V2f( -0.0732233, -0.0732233 ), + imath.V2f( 0, 0 ), + imath.V2f( 0, 0 ), + imath.V2f( 0, 0 ), ] ) for i in range( 0, len(expected) ) : diff --git a/test/IECoreScene/MeshAlgoDistributePointsTest.py b/test/IECoreScene/MeshAlgoDistributePointsTest.py index e57ba9b33c..10416222ff 100644 --- a/test/IECoreScene/MeshAlgoDistributePointsTest.py +++ b/test/IECoreScene/MeshAlgoDistributePointsTest.py @@ -34,6 +34,7 @@ import os import unittest +import imath import IECore import IECoreScene @@ -74,7 +75,7 @@ def testSimple( self ) : def testHighDensity( self ) : m = IECore.Reader.create( "test/IECore/data/cobFiles/pCubeShape1.cob" ).read() - p = IECoreScene.MeshAlgo.distributePoints( mesh = m, density = 50000, offset = IECore.V2f( 0.0001, 0.0001 ) ) + p = IECoreScene.MeshAlgo.distributePoints( mesh = m, density = 50000, offset = imath.V2f( 0.0001, 0.0001 ) ) self.pointTest( m, p, 50000 ) @@ -93,8 +94,8 @@ def testOffsetParameter( self ) : m = IECore.Reader.create( "test/IECore/data/cobFiles/pCubeShape1.cob" ).read() density = 500 - p = IECoreScene.MeshAlgo.distributePoints( mesh = m, density = density, offset = IECore.V2f( 0, 0 ) ) - pOffset = IECoreScene.MeshAlgo.distributePoints( mesh = m, density = density, offset = IECore.V2f( 0.5, 0.75 ) ) + p = IECoreScene.MeshAlgo.distributePoints( mesh = m, density = density, offset = imath.V2f( 0, 0 ) ) + pOffset = IECoreScene.MeshAlgo.distributePoints( mesh = m, density = density, offset = imath.V2f( 0.5, 0.75 ) ) self.pointTest( m, p, density ) self.pointTest( m, pOffset, density ) self.assertNotEqual( p.numPoints, pOffset.numPoints ) @@ -124,7 +125,7 @@ def testPointOrder( self ) : m = IECore.Reader.create( "test/IECore/data/cobFiles/pCubeShape1.cob" ).read() m2 = m.copy() - m2['P'].data += IECore.V3f( 0, 5, 0 ) + m2['P'].data += imath.V3f( 0, 5, 0 ) pos = m["P"].data pos2 = m2["P"].data for i in range( 0, pos.size() ) : @@ -140,7 +141,7 @@ def testPointOrder( self ) : pos = p["P"].data pos2 = p2["P"].data for i in range( 0, p.numPoints ) : - self.failUnless( pos2[i].equalWithRelError( pos[i] + IECore.V3f( 0, 5, 0 ), 1e-6 ) ) + self.failUnless( pos2[i].equalWithRelError( pos[i] + imath.V3f( 0, 5, 0 ), 1e-6 ) ) def testDensityRange( self ) : diff --git a/test/IECoreScene/MeshAlgoFaceAreaTest.py b/test/IECoreScene/MeshAlgoFaceAreaTest.py index 052baea9e9..86c44624ad 100644 --- a/test/IECoreScene/MeshAlgoFaceAreaTest.py +++ b/test/IECoreScene/MeshAlgoFaceAreaTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene import math @@ -41,7 +42,7 @@ class MeshAlgoFaceAreaTest( unittest.TestCase ) : def test( self ) : - p = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -2, -1 ), IECore.V2f( 2, 1 ) ) ) + p = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -2, -1 ), imath.V2f( 2, 1 ) ) ) faceArea = IECoreScene.MeshAlgo.calculateFaceArea( p ) @@ -52,24 +53,28 @@ def test( self ) : def testRandomTriangles( self ) : - r = IECore.Rand32() + r = imath.Rand32() for i in range( 0, 1000 ) : - p = IECore.V3fVectorData( [ r.nextV3f(), r.nextV3f(), r.nextV3f() ] ) + p = IECore.V3fVectorData( [ + imath.V3f( r.nextf(), r.nextf(), r.nextf() ), + imath.V3f( r.nextf(), r.nextf(), r.nextf() ), + imath.V3f( r.nextf(), r.nextf(), r.nextf() ), + ] ) m = IECoreScene.MeshPrimitive( IECore.IntVectorData( [ 3 ] ), IECore.IntVectorData( [ 0, 1, 2 ] ), "linear", p ) - uv = IECore.V2fVectorData( [ IECore.V2f( r.nextf(), r.nextf() ), IECore.V2f( r.nextf(), r.nextf() ), IECore.V2f( r.nextf(), r.nextf() ) ] ) + uv = IECore.V2fVectorData( [ imath.V2f( r.nextf(), r.nextf() ), imath.V2f( r.nextf(), r.nextf() ), imath.V2f( r.nextf(), r.nextf() ) ] ) m["uv"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, uv ) faceArea = IECoreScene.MeshAlgo.calculateFaceArea( m ) textureArea = IECoreScene.MeshAlgo.calculateFaceTextureArea( m, "uv" ) self.assertAlmostEqual( faceArea.data[0], IECore.triangleArea( p[0], p[1], p[2] ), 4 ) - self.assertAlmostEqual( textureArea.data[0], IECore.triangleArea( IECore.V3f( uv[0][0], uv[0][1], 0 ), IECore.V3f( uv[1][0], uv[1][1], 0 ), IECore.V3f( uv[2][0], uv[2][1], 0 ) ), 4 ) + self.assertAlmostEqual( textureArea.data[0], IECore.triangleArea( imath.V3f( uv[0][0], uv[0][1], 0 ), imath.V3f( uv[1][0], uv[1][1], 0 ), imath.V3f( uv[2][0], uv[2][1], 0 ) ), 4 ) def testTwoFaces( self ) : - v = IECore.V3f + v = imath.V3f # P # _ _ @@ -95,13 +100,13 @@ def testTwoFaces( self ) : uvs = IECore.V2fVectorData( [ - IECore.V2f( 0, 0 ), - IECore.V2f( 3, 0 ), - IECore.V2f( 3, 2 ), - IECore.V2f( 0, 2 ), - IECore.V2f( 5, 0 ), - IECore.V2f( 6, 0 ), - IECore.V2f( 5, 2 ), + imath.V2f( 0, 0 ), + imath.V2f( 3, 0 ), + imath.V2f( 3, 2 ), + imath.V2f( 0, 2 ), + imath.V2f( 5, 0 ), + imath.V2f( 6, 0 ), + imath.V2f( 5, 2 ), ] ) diff --git a/test/IECoreScene/MeshAlgoResampleTest.py b/test/IECoreScene/MeshAlgoResampleTest.py index 33955d08da..6f8a8280ab 100644 --- a/test/IECoreScene/MeshAlgoResampleTest.py +++ b/test/IECoreScene/MeshAlgoResampleTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene @@ -41,7 +42,7 @@ class MeshAlgoResampleTest( unittest.TestCase ) : @classmethod def makeMesh( cls ) : - testObject = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 10 ) ), IECore.V2i( 2 ) ) + testObject = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( 0 ), imath.V2f( 10 ) ), imath.V2i( 2 ) ) testObject["a"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.FloatData( 0.5 ) ) testObject["b"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.FloatVectorData( range( 0, 9 ) ) ) @@ -278,7 +279,7 @@ def testInitialisationOfVectorData( self ) : # This exercises a bug whereby the resampling methods that use averaging # were not initialising the results to zero before accumulating. - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ), IECore.V2i( 100 ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ), imath.V2i( 100 ) ) for i in range( 0, 10 ) : @@ -286,13 +287,13 @@ def testInitialisationOfVectorData( self ) : pv = IECoreScene.PrimitiveVariable( interpolation, - IECore.V2fVectorData( [ IECore.V2f( 0 ) ] * m.variableSize( interpolation ) ) + IECore.V2fVectorData( [ imath.V2f( 0 ) ] * m.variableSize( interpolation ) ) ) IECoreScene.MeshAlgo.resamplePrimitiveVariable( m, pv, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) self.assertEqual( len( pv.data ), m.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ) ) for v in pv.data : - self.assertEqual( v, IECore.V2f( 0 ) ) + self.assertEqual( v, imath.V2f( 0 ) ) if __name__ == "__main__": unittest.main() diff --git a/test/IECoreScene/MeshAlgoTangentsTest.py b/test/IECoreScene/MeshAlgoTangentsTest.py index a1a50daf27..5c31376a29 100644 --- a/test/IECoreScene/MeshAlgoTangentsTest.py +++ b/test/IECoreScene/MeshAlgoTangentsTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene @@ -43,15 +44,15 @@ def makeSingleTriangleMesh( self ): verticesPerFace = IECore.IntVectorData( [ 3 ] ) vertexIds = IECore.IntVectorData( [ 0, 1, 2 ] ) - p = IECore.V3fVectorData( [ IECore.V3f( 0, 0, 0 ), IECore.V3f( 1, 0, 0 ), IECore.V3f( 0, 1, 0 ) ] ) - uv = IECore.V2fVectorData( [ IECore.V2f( 0, 0 ), IECore.V2f( 1, 0 ), IECore.V2f( 0, 1 ) ] ) + p = IECore.V3fVectorData( [ imath.V3f( 0, 0, 0 ), imath.V3f( 1, 0, 0 ), imath.V3f( 0, 1, 0 ) ] ) + uv = IECore.V2fVectorData( [ imath.V2f( 0, 0 ), imath.V2f( 1, 0 ), imath.V2f( 0, 1 ) ] ) mesh = IECoreScene.MeshPrimitive( verticesPerFace, vertexIds, "linear", p ) mesh["uv"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, uv ) - mesh["foo"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, IECore.V2fVectorData( [ IECore.V2f( 0, 0 ), IECore.V2f( 0, 1 ), IECore.V2f( 1, 0 ) ] ) ) + mesh["foo"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, IECore.V2fVectorData( [ imath.V2f( 0, 0 ), imath.V2f( 0, 1 ), imath.V2f( 1, 0 ) ] ) ) - prefData = IECore.V3fVectorData( [ IECore.V3f( 0, 0, 0 ), IECore.V3f( 0, -1, 0 ), IECore.V3f( 1, 0, 0 ) ] ) + prefData = IECore.V3fVectorData( [ imath.V3f( 0, 0, 0 ), imath.V3f( 0, -1, 0 ), imath.V3f( 1, 0, 0 ) ] ) mesh["Pref"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, prefData ) return mesh @@ -60,8 +61,8 @@ def makeSingleBadUVTriangleMesh( self ) : verticesPerFace = IECore.IntVectorData( [3] ) vertexIds = IECore.IntVectorData( [0, 1, 2] ) - p = IECore.V3fVectorData( [ IECore.V3f( 0, 0, 0 ), IECore.V3f( 1, 0, 0 ), IECore.V3f( 0, 1, 0 )] ) - uv = IECore.V2fVectorData( [ IECore.V2f( 0 ) ] ) + p = IECore.V3fVectorData( [ imath.V3f( 0, 0, 0 ), imath.V3f( 1, 0, 0 ), imath.V3f( 0, 1, 0 )] ) + uv = IECore.V2fVectorData( [ imath.V2f( 0 ) ] ) mesh = IECoreScene.MeshPrimitive( verticesPerFace, vertexIds, "linear", p ) mesh["uv"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, uv ) @@ -103,9 +104,9 @@ def testJoinedUVEdges( self ) : self.assertEqual( bitangentPrimVar.interpolation, IECoreScene.PrimitiveVariable.Interpolation.FaceVarying ) for v in tangentPrimVar.data : - self.failUnless( v.equalWithAbsError( IECore.V3f( 1, 0, 0 ), 0.000001 ) ) + self.failUnless( v.equalWithAbsError( imath.V3f( 1, 0, 0 ), 0.000001 ) ) for v in bitangentPrimVar.data : - self.failUnless( v.equalWithAbsError( IECore.V3f( 0, 0, -1 ), 0.000001 ) ) + self.failUnless( v.equalWithAbsError( imath.V3f( 0, 0, -1 ), 0.000001 ) ) def testSplitAndOpposedUVEdges( self ) : @@ -117,17 +118,17 @@ def testSplitAndOpposedUVEdges( self ) : self.assertEqual( bitangentPrimVar.interpolation, IECoreScene.PrimitiveVariable.Interpolation.FaceVarying ) for v in tangentPrimVar.data[:3] : - self.failUnless( v.equalWithAbsError( IECore.V3f( -1, 0, 0 ), 0.000001 ) ) + self.failUnless( v.equalWithAbsError( imath.V3f( -1, 0, 0 ), 0.000001 ) ) for v in tangentPrimVar.data[3:] : - self.failUnless( v.equalWithAbsError( IECore.V3f( 1, 0, 0 ), 0.000001 ) ) + self.failUnless( v.equalWithAbsError( imath.V3f( 1, 0, 0 ), 0.000001 ) ) for v in bitangentPrimVar.data[:3] : - self.failUnless( v.equalWithAbsError( IECore.V3f( 0, 0, 1 ), 0.000001 ) ) + self.failUnless( v.equalWithAbsError( imath.V3f( 0, 0, 1 ), 0.000001 ) ) for v in bitangentPrimVar.data[3:] : - self.failUnless( v.equalWithAbsError( IECore.V3f( 0, 0, -1 ), 0.000001 ) ) + self.failUnless( v.equalWithAbsError( imath.V3f( 0, 0, -1 ), 0.000001 ) ) def testNonTriangulatedMeshRaisesException( self ): - plane = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -0.1 ), IECore.V2f( 0.1 ) ) ) + plane = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -0.1 ), imath.V2f( 0.1 ) ) ) self.assertRaises( RuntimeError, lambda : IECoreScene.MeshAlgo.calculateTangents( plane ) ) def testInvalidPositionPrimVarRaisesException( self ) : @@ -151,12 +152,12 @@ def testCanUseSecondUVSet( self ) : self.assertEqual( len( vTangent.data ), 3 ) for v in uTangent.data : - self.failUnless( v.equalWithAbsError( IECore.V3f( 0, 1, 0 ), 0.000001 ) ) + self.failUnless( v.equalWithAbsError( imath.V3f( 0, 1, 0 ), 0.000001 ) ) # really I'd expect the naive answer to the vTangent to be V3f( 1, 0, 0 ) # but the code forces the triple of n, uT, vT to flip the direction of vT if we don't have a correctly handed set of basis vectors for v in vTangent.data : - self.failUnless( v.equalWithAbsError( IECore.V3f( -1, 0, 0 ), 0.000001 ) ) + self.failUnless( v.equalWithAbsError( imath.V3f( -1, 0, 0 ), 0.000001 ) ) def testCanUsePref( self ) : @@ -167,10 +168,10 @@ def testCanUsePref( self ) : self.assertEqual( len( vTangent.data ), 3 ) for v in uTangent.data : - self.failUnless( v.equalWithAbsError( IECore.V3f( 0, -1, 0 ), 0.000001 ) ) + self.failUnless( v.equalWithAbsError( imath.V3f( 0, -1, 0 ), 0.000001 ) ) for v in vTangent.data : - self.failUnless( v.equalWithAbsError( IECore.V3f( 1, 0, 0 ), 0.000001 ) ) + self.failUnless( v.equalWithAbsError( imath.V3f( 1, 0, 0 ), 0.000001 ) ) if __name__ == "__main__": unittest.main() diff --git a/test/IECoreScene/MeshAlgoWindingTest.py b/test/IECoreScene/MeshAlgoWindingTest.py index 4313611ca4..7910348e4e 100644 --- a/test/IECoreScene/MeshAlgoWindingTest.py +++ b/test/IECoreScene/MeshAlgoWindingTest.py @@ -34,6 +34,7 @@ import random import unittest +import imath import IECore import IECoreScene @@ -44,15 +45,15 @@ def makeSingleTriangleMesh( self ): verticesPerFace = IECore.IntVectorData( [ 3 ] ) vertexIds = IECore.IntVectorData( [ 0, 1, 2 ] ) - p = IECore.V3fVectorData( [ IECore.V3f( 0, 0, 0 ), IECore.V3f( 1, 0, 0 ), IECore.V3f( 0, 1, 0 ) ] ) - uv = IECore.V2fVectorData( [ IECore.V2f( 0, 0 ), IECore.V2f( 1, 0 ), IECore.V2f( 0, 1 ) ] ) + p = IECore.V3fVectorData( [ imath.V3f( 0, 0, 0 ), imath.V3f( 1, 0, 0 ), imath.V3f( 0, 1, 0 ) ] ) + uv = IECore.V2fVectorData( [ imath.V2f( 0, 0 ), imath.V2f( 1, 0 ), imath.V2f( 0, 1 ) ] ) mesh = IECoreScene.MeshPrimitive( verticesPerFace, vertexIds, "linear", p ) mesh["uv"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, uv ) - mesh["foo"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, IECore.V2fVectorData( [ IECore.V2f( 0, 0 ), IECore.V2f( 0, 1 ), IECore.V2f( 1, 0 ) ] ) ) + mesh["foo"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, IECore.V2fVectorData( [ imath.V2f( 0, 0 ), imath.V2f( 0, 1 ), imath.V2f( 1, 0 ) ] ) ) - prefData = IECore.V3fVectorData( [ IECore.V3f( 0, 0, 0 ), IECore.V3f( 0, -1, 0 ), IECore.V3f( 1, 0, 0 ) ] ) + prefData = IECore.V3fVectorData( [ imath.V3f( 0, 0, 0 ), imath.V3f( 0, -1, 0 ), imath.V3f( 1, 0, 0 ) ] ) mesh["Pref"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, prefData ) return mesh @@ -82,7 +83,7 @@ def testSingleTriangle( self ) : def testPlane( self ) : - mesh = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ), IECore.V2i( 10 ) ) + mesh = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ), imath.V2i( 10 ) ) IECoreScene.TriangulateOp()( input = mesh, copyInput = False ) meshReversed = mesh.copy() @@ -96,7 +97,7 @@ def testPlane( self ) : for i in range( 0, 1000 ) : - p = IECore.V3f( random.uniform( -1.0, 1.0 ), random.uniform( -1.0, 1.0 ), 0 ) + p = imath.V3f( random.uniform( -1.0, 1.0 ), random.uniform( -1.0, 1.0 ), 0 ) evaluator.closestPoint( p, result ) evaluatorReversed.closestPoint( p, resultReversed ) @@ -109,7 +110,7 @@ def testPlane( self ) : def testRoundTrip( self ) : - mesh = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ), IECore.V2i( 10 ) ) + mesh = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ), imath.V2i( 10 ) ) meshReversed = mesh.copy() IECoreScene.MeshAlgo.reverseWinding( meshReversed ) meshReversedAgain = meshReversed.copy() @@ -121,8 +122,8 @@ def testUVIndices( self ) : verticesPerFace = IECore.IntVectorData( [ 3 ] ) vertexIds = IECore.IntVectorData( [ 0, 1, 2 ] ) - p = IECore.V3fVectorData( [ IECore.V3f( 0, 0, 0 ), IECore.V3f( 1, 0, 0 ), IECore.V3f( 0, 1, 0 ) ] ) - uv = IECore.V2fVectorData( [ IECore.V2f( 0, 0 ), IECore.V2f( 1, 0 ), IECore.V2f( 0, 1 ) ] ) + p = IECore.V3fVectorData( [ imath.V3f( 0, 0, 0 ), imath.V3f( 1, 0, 0 ), imath.V3f( 0, 1, 0 ) ] ) + uv = IECore.V2fVectorData( [ imath.V2f( 0, 0 ), imath.V2f( 1, 0 ), imath.V2f( 0, 1 ) ] ) uvIndices = IECore.IntVectorData( [ 0, 1, 2 ] ) mesh = IECoreScene.MeshPrimitive( verticesPerFace, vertexIds, "linear", p ) mesh["uv"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, uv, uvIndices ) diff --git a/test/IECoreScene/MeshMergeOpTest.py b/test/IECoreScene/MeshMergeOpTest.py index 33803f6928..bb42e54944 100644 --- a/test/IECoreScene/MeshMergeOpTest.py +++ b/test/IECoreScene/MeshMergeOpTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene import math @@ -118,16 +119,16 @@ def verifyData( self, meshA, meshB, merged, flipped=False ) : def testPlanes( self ) : - p1 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 0 ) ) ) - p2 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) ) + p1 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 0 ) ) ) + p2 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) merged = IECoreScene.MeshMergeOp()( input=p1, mesh=p2 ) self.verifyMerge( p1, p2, merged ) def testDifferentPrimVars( self ) : - p1 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 0 ) ) ) + p1 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 0 ) ) ) IECoreScene.MeshNormalsOp()( input=p1, copyInput=False ) - p2 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) ) + p2 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) self.assertNotEqual( p1.keys(), p2.keys() ) merged = IECoreScene.MeshMergeOp()( input=p1, mesh=p2 ) self.verifyMerge( p1, p2, merged ) @@ -143,10 +144,10 @@ def testDifferentPrimVars( self ) : def testSamePrimVarNamesWithDifferentInterpolation( self ) : - plane = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 0 ) ) ) + plane = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 0 ) ) ) del plane["uv"] IECoreScene.MeshNormalsOp()( input=plane, copyInput=False ) - box = IECoreScene.MeshPrimitive.createBox( IECore.Box3f( IECore.V3f( 0 ), IECore.V3f( 1 ) ) ) + box = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( 0 ), imath.V3f( 1 ) ) ) IECoreScene.MeshNormalsOp()( input=box, copyInput=False ) IECoreScene.FaceVaryingPromotionOp()( input=box, copyInput=False, primVarNames=IECore.StringVectorData( [ "N" ] ) ) self.assertEqual( plane.keys(), box.keys() ) @@ -156,9 +157,9 @@ def testSamePrimVarNamesWithDifferentInterpolation( self ) : def testRemovePrimVars( self ) : - p1 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 0 ) ) ) + p1 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 0 ) ) ) IECoreScene.MeshNormalsOp()( input=p1, copyInput=False ) - p2 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) ) + p2 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) self.assertNotEqual( p1.keys(), p2.keys() ) merged = IECoreScene.MeshMergeOp()( input=p1, mesh=p2, removeNonMatchingPrimVars=False ) self.failUnless( "N" in merged ) @@ -188,9 +189,9 @@ def testRemovePrimVars( self ) : def testReferencedData( self ) : - p1 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 0 ) ) ) + p1 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 0 ) ) ) p1["Pref"] = p1["P"] - p2 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) ) + p2 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) merged = IECoreScene.MeshMergeOp()( input=p1, mesh=p2 ) self.failUnless( "Pref" in merged ) self.verifyMerge( p1, p2, merged ) @@ -203,8 +204,8 @@ def testReferencedData( self ) : def testIndexedPrimVars( self ) : - p1 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 0 ) ) ) - p2 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) ) + p1 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 0 ) ) ) + p2 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) # both meshes have indexed UVs p1["uv"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, p1["uv"].data, IECore.IntVectorData( [ 0, 3, 1, 2 ] ) ) @@ -235,7 +236,7 @@ def testIndexedPrimVars( self ) : # meshA has no UVs, meshB has indexed UVs del p1["uv"] - p2 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) ) + p2 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) p2["uv"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, p2["uv"].data, IECore.IntVectorData( [ 2, 1, 0, 3 ] ) ) merged = IECoreScene.MeshMergeOp()( input=p1, mesh=p2 ) self.verifyMerge( p1, p2, merged ) diff --git a/test/IECoreScene/MeshNormalsOpTest.py b/test/IECoreScene/MeshNormalsOpTest.py index 82d6f60c63..0e97bd95c0 100644 --- a/test/IECoreScene/MeshNormalsOpTest.py +++ b/test/IECoreScene/MeshNormalsOpTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene import math @@ -41,7 +42,7 @@ class MeshNormalsOpTest( unittest.TestCase ) : def testPlane( self ) : - p = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + p = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) if "N" in p : del p["N"] self.assert_( not "N" in p ) @@ -58,11 +59,11 @@ def testPlane( self ) : for n in normals : - self.assertEqual( n, IECore.V3f( 0, 0, 1 ) ) + self.assertEqual( n, imath.V3f( 0, 0, 1 ) ) def testOnlyNAdded( self ) : - p = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + p = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) pp = IECoreScene.MeshNormalsOp()( input=p ) del pp["N"] @@ -95,7 +96,7 @@ def testSphere( self ) : def testUniformInterpolation( self ) : - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ), IECore.V2i( 10 ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ), imath.V2i( 10 ) ) self.assertTrue( "N" not in m ) m2 = IECoreScene.MeshNormalsOp()( input = m, interpolation = IECoreScene.PrimitiveVariable.Interpolation.Uniform ) @@ -103,7 +104,7 @@ def testUniformInterpolation( self ) : self.assertEqual( len( m2["N"].data ), m2.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) ) for n in m2["N"].data : - self.assertEqual( n, IECore.V3f( 0, 0, 1 ) ) + self.assertEqual( n, imath.V3f( 0, 0, 1 ) ) if __name__ == "__main__": unittest.main() diff --git a/test/IECoreScene/MeshPrimitive.py b/test/IECoreScene/MeshPrimitive.py index 0346aaeff1..9b4912f590 100644 --- a/test/IECoreScene/MeshPrimitive.py +++ b/test/IECoreScene/MeshPrimitive.py @@ -34,6 +34,7 @@ import os import unittest +import imath import IECore import IECoreScene @@ -236,7 +237,7 @@ def testHash( self ) : def testBox( self ) : - m = IECoreScene.MeshPrimitive.createBox( IECore.Box3f( IECore.V3f( 0 ), IECore.V3f( 1 ) ) ) + m = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( 0 ), imath.V3f( 1 ) ) ) self.assertEqual( m.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Constant ), 1 ) self.assertEqual( m.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ), 6 ) self.assertEqual( m.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ), 8 ) @@ -244,12 +245,12 @@ def testBox( self ) : self.assertEqual( m.variableSize( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying ), 24 ) self.assertEqual( m.numFaces(), 6 ) self.assertEqual( m.verticesPerFace, IECore.IntVectorData( [ 4 ] * 6 ) ) - self.assertEqual( m.bound(), IECore.Box3f( IECore.V3f( 0 ), IECore.V3f( 1 ) ) ) + self.assertEqual( m.bound(), imath.Box3f( imath.V3f( 0 ), imath.V3f( 1 ) ) ) self.assertTrue( m.arePrimitiveVariablesValid() ) def testPlane( self ) : - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) self.assertEqual( m.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Constant ), 1 ) self.assertEqual( m.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ), 1 ) self.assertEqual( m.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ), 4 ) @@ -258,27 +259,27 @@ def testPlane( self ) : self.assertEqual( m.numFaces(), 1 ) self.assertEqual( m.verticesPerFace, IECore.IntVectorData( [ 4 ] ) ) self.assertEqual( m.vertexIds, IECore.IntVectorData( [ 0, 1, 3, 2 ] ) ) - self.assertEqual( m.bound(), IECore.Box3f( IECore.V3f( 0 ), IECore.V3f( 1, 1, 0 ) ) ) + self.assertEqual( m.bound(), imath.Box3f( imath.V3f( 0 ), imath.V3f( 1, 1, 0 ) ) ) self.assertTrue( m.arePrimitiveVariablesValid() ) # verify uvs e = IECoreScene.MeshPrimitiveEvaluator( IECoreScene.TriangulateOp()( input = m ) ) r = e.createResult() - self.assertTrue( e.pointAtUV( IECore.V2f( 0, 0 ), r ) ) + self.assertTrue( e.pointAtUV( imath.V2f( 0, 0 ), r ) ) self.assertEqual( r.point(), m["P"].data[0] ) - self.assertEqual( r.point(), IECore.V3f( 0, 0, 0 ) ) - self.assertTrue( e.pointAtUV( IECore.V2f( 1, 0 ), r ) ) + self.assertEqual( r.point(), imath.V3f( 0, 0, 0 ) ) + self.assertTrue( e.pointAtUV( imath.V2f( 1, 0 ), r ) ) self.assertEqual( r.point(), m["P"].data[1] ) - self.assertEqual( r.point(), IECore.V3f( 1, 0, 0 ) ) - self.assertTrue( e.pointAtUV( IECore.V2f( 1, 1 ), r ) ) + self.assertEqual( r.point(), imath.V3f( 1, 0, 0 ) ) + self.assertTrue( e.pointAtUV( imath.V2f( 1, 1 ), r ) ) self.assertEqual( r.point(), m["P"].data[3] ) - self.assertEqual( r.point(), IECore.V3f( 1, 1, 0 ) ) - self.assertTrue( e.pointAtUV( IECore.V2f( 0, 1 ), r ) ) + self.assertEqual( r.point(), imath.V3f( 1, 1, 0 ) ) + self.assertTrue( e.pointAtUV( imath.V2f( 0, 1 ), r ) ) self.assertEqual( r.point(), m["P"].data[2] ) - self.assertEqual( r.point(), IECore.V3f( 0, 1, 0 ) ) + self.assertEqual( r.point(), imath.V3f( 0, 1, 0 ) ) # test divisions - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ), divisions = IECore.V2i( 2, 3 ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ), divisions = imath.V2i( 2, 3 ) ) self.assertEqual( m.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Constant ), 1 ) self.assertEqual( m.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ), 6 ) self.assertEqual( m.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ), 12 ) @@ -287,29 +288,29 @@ def testPlane( self ) : self.assertEqual( m.numFaces(), 6 ) self.assertEqual( m.verticesPerFace, IECore.IntVectorData( [ 4 ] * 6 ) ) self.assertEqual( m.vertexIds, IECore.IntVectorData( [ 0, 1, 4, 3, 1, 2, 5, 4, 3, 4, 7, 6, 4, 5, 8, 7, 6, 7, 10, 9, 7, 8, 11, 10 ] ) ) - self.assertEqual( m.bound(), IECore.Box3f( IECore.V3f( 0 ), IECore.V3f( 1, 1, 0 ) ) ) + self.assertEqual( m.bound(), imath.Box3f( imath.V3f( 0 ), imath.V3f( 1, 1, 0 ) ) ) self.assertTrue( m.arePrimitiveVariablesValid() ) # corners still have correct uvs e = IECoreScene.MeshPrimitiveEvaluator( IECoreScene.TriangulateOp()( input = m ) ) r = e.createResult() - self.assertTrue( e.pointAtUV( IECore.V2f( 0, 0 ), r ) ) + self.assertTrue( e.pointAtUV( imath.V2f( 0, 0 ), r ) ) self.assertEqual( r.point(), m["P"].data[0] ) - self.assertEqual( r.point(), IECore.V3f( 0, 0, 0 ) ) - self.assertTrue( e.pointAtUV( IECore.V2f( 1, 0 ), r ) ) + self.assertEqual( r.point(), imath.V3f( 0, 0, 0 ) ) + self.assertTrue( e.pointAtUV( imath.V2f( 1, 0 ), r ) ) self.assertEqual( r.point(), m["P"].data[2] ) - self.assertEqual( r.point(), IECore.V3f( 1, 0, 0 ) ) - self.assertTrue( e.pointAtUV( IECore.V2f( 1, 1 ), r ) ) + self.assertEqual( r.point(), imath.V3f( 1, 0, 0 ) ) + self.assertTrue( e.pointAtUV( imath.V2f( 1, 1 ), r ) ) self.assertEqual( r.point(), m["P"].data[11] ) - self.assertEqual( r.point(), IECore.V3f( 1, 1, 0 ) ) - self.assertTrue( e.pointAtUV( IECore.V2f( 0, 1 ), r ) ) + self.assertEqual( r.point(), imath.V3f( 1, 1, 0 ) ) + self.assertTrue( e.pointAtUV( imath.V2f( 0, 1 ), r ) ) self.assertEqual( r.point(), m["P"].data[9] ) - self.assertEqual( r.point(), IECore.V3f( 0, 1, 0 ) ) + self.assertEqual( r.point(), imath.V3f( 0, 1, 0 ) ) def testSphere( self ) : - m = IECoreScene.MeshPrimitive.createSphere( radius = 1, divisions = IECore.V2i( 30, 40 ) ) - self.assertTrue( IECore.Box3f( IECore.V3f( -1 ), IECore.V3f( 1 ) ).contains( m.bound() ) ) + m = IECoreScene.MeshPrimitive.createSphere( radius = 1, divisions = imath.V2i( 30, 40 ) ) + self.assertTrue( IECore.BoxAlgo.contains( imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ), m.bound() ) ) self.assertTrue( m.arePrimitiveVariablesValid() ) me = IECoreScene.PrimitiveEvaluator.create( m ) mer = me.createResult() @@ -318,27 +319,27 @@ def testSphere( self ) : ser = se.createResult() for s in range( 0, 100 ) : for t in range( 0, 100 ) : - me.pointAtUV( IECore.V2f( s/100., t/100. ), mer ) - se.pointAtUV( IECore.V2f( s/100., t/100. ), ser ) + me.pointAtUV( imath.V2f( s/100., t/100. ), mer ) + se.pointAtUV( imath.V2f( s/100., t/100. ), ser ) self.assertTrue( mer.point().equalWithAbsError( ser.point(), 1e-2 ) ) # test divisions - m = IECoreScene.MeshPrimitive.createSphere( radius = 1, divisions = IECore.V2i( 300, 300 ) ) - self.assertTrue( IECore.Box3f( IECore.V3f( -1 ), IECore.V3f( 1 ) ).contains( m.bound() ) ) + m = IECoreScene.MeshPrimitive.createSphere( radius = 1, divisions = imath.V2i( 300, 300 ) ) + self.assertTrue( IECore.BoxAlgo.contains( imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ), m.bound() ) ) self.assertTrue( m.arePrimitiveVariablesValid() ) me = IECoreScene.PrimitiveEvaluator.create( m ) mer = me.createResult() for s in range( 0, 100 ) : for t in range( 0, 100 ) : - me.pointAtUV( IECore.V2f( s/100., t/100. ), mer ) - se.pointAtUV( IECore.V2f( s/100., t/100. ), ser ) + me.pointAtUV( imath.V2f( s/100., t/100. ), mer ) + se.pointAtUV( imath.V2f( s/100., t/100. ), ser ) # more divisions means points are closer to ground truth self.assertTrue( mer.point().equalWithAbsError( ser.point(), 1e-4 ) ) # test radius - m = IECoreScene.MeshPrimitive.createSphere( radius = 2, divisions = IECore.V2i( 30, 40 ) ) - self.assertFalse( IECore.Box3f( IECore.V3f( -1 ), IECore.V3f( 1 ) ).contains( m.bound() ) ) - self.assertTrue( IECore.Box3f( IECore.V3f( -2 ), IECore.V3f( 2 ) ).contains( m.bound() ) ) + m = IECoreScene.MeshPrimitive.createSphere( radius = 2, divisions = imath.V2i( 30, 40 ) ) + self.assertFalse( IECore.BoxAlgo.contains( imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ), m.bound() ) ) + self.assertTrue( IECore.BoxAlgo.contains( imath.Box3f( imath.V3f( -2 ), imath.V3f( 2 ) ), m.bound() ) ) self.assertTrue( m.arePrimitiveVariablesValid() ) me = IECoreScene.PrimitiveEvaluator.create( m ) mer = me.createResult() @@ -347,18 +348,18 @@ def testSphere( self ) : ser = se.createResult() for s in range( 0, 100 ) : for t in range( 0, 100 ) : - me.pointAtUV( IECore.V2f( s/100., t/100. ), mer ) - se.pointAtUV( IECore.V2f( s/100., t/100. ), ser ) + me.pointAtUV( imath.V2f( s/100., t/100. ), mer ) + se.pointAtUV( imath.V2f( s/100., t/100. ), ser ) self.assertTrue( mer.point().equalWithAbsError( ser.point(), 1e-2 ) ) # test zMin/zMax m = IECoreScene.MeshPrimitive.createSphere( radius = 1, zMin = -0.75, zMax = 0.75 ) - self.assertTrue( IECore.Box3f( IECore.V3f( -1, -1, -0.75 ), IECore.V3f( 1, 1, 0.75 ) ).contains( m.bound() ) ) + self.assertTrue( IECore.BoxAlgo.contains( imath.Box3f( imath.V3f( -1, -1, -0.75 ), imath.V3f( 1, 1, 0.75 ) ), m.bound() ) ) self.assertTrue( m.arePrimitiveVariablesValid() ) # test thetaMax m = IECoreScene.MeshPrimitive.createSphere( radius = 1, thetaMax = 300 ) - self.assertTrue( IECore.Box3f( IECore.V3f( -1 ), IECore.V3f( 1 ) ).contains( m.bound() ) ) + self.assertTrue( IECore.BoxAlgo.contains( imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ), m.bound() ) ) self.assertTrue( m.arePrimitiveVariablesValid() ) m2 = IECoreScene.MeshPrimitive.createSphere( radius = 1 ) self.assertTrue( m.numFaces() < m2.numFaces() ) diff --git a/test/IECoreScene/MeshPrimitiveEvaluator.py b/test/IECoreScene/MeshPrimitiveEvaluator.py index 895c44d326..348f97e044 100644 --- a/test/IECoreScene/MeshPrimitiveEvaluator.py +++ b/test/IECoreScene/MeshPrimitiveEvaluator.py @@ -35,6 +35,7 @@ import math import unittest import random +import imath import IECore import IECoreScene @@ -54,7 +55,7 @@ def testResultTypeValidation( self ) : wrongResultType = IECoreScene.PrimitiveEvaluator.create( IECoreScene.SpherePrimitive() ).createResult() - self.assertRaises( Exception, e.closestPoint, IECore.V3f( 0 ), wrongResultType ) + self.assertRaises( Exception, e.closestPoint, imath.V3f( 0 ), wrongResultType ) def testEmptyMesh( self ) : """ Testing MeshPrimitiveEvaluator with empty mesh""" @@ -68,7 +69,7 @@ def testEmptyMesh( self ) : r = mpe.createResult() - foundClosest = mpe.closestPoint( IECore.V3f( 0, 10, 0 ), r ) + foundClosest = mpe.closestPoint( imath.V3f( 0, 10, 0 ), r ) self.failIf( foundClosest ) @@ -100,19 +101,19 @@ def testSimpleMesh( self ) : vertexIds.append( 1 ) vertexIds.append( 2 ) - translation = IECore.V3f( 3, 3, 3 ) + translation = imath.V3f( 3, 3, 3 ) P = IECore.V3fVectorData() - P.append( IECore.V3f( -1, 0, 0 ) + translation ) - P.append( IECore.V3f( 0, 0, -1 ) + translation ) - P.append( IECore.V3f( -1, 0, -1 ) + translation ) + P.append( imath.V3f( -1, 0, 0 ) + translation ) + P.append( imath.V3f( 0, 0, -1 ) + translation ) + P.append( imath.V3f( -1, 0, -1 ) + translation ) uOffset = 7 uv = IECore.V2fVectorData() vOffset = 12 for p in P : - uv.append( IECore.V2f( p.x + uOffset, p.z + vOffset ) ) + uv.append( imath.V2f( p.x + uOffset, p.z + vOffset ) ) self.assertEqual( len( P ), len( uv ) ) @@ -132,18 +133,18 @@ def testSimpleMesh( self ) : self.assertAlmostEqual( ( p - r.point() ).length(), 0 ) - foundClosest = mpe.closestPoint( IECore.V3f( 0, 10, 0 ) + translation , r ) + foundClosest = mpe.closestPoint( imath.V3f( 0, 10, 0 ) + translation , r ) self.assert_( foundClosest ) - self.assertAlmostEqual( ( IECore.V3f( -0.5, 0, -0.5 ) + translation - r.point()).length(), 0 ) - self.assertAlmostEqual( math.fabs( r.normal().dot( IECore.V3f(0, 1, 0 ) ) ) , 1, places = 3 ) + self.assertAlmostEqual( ( imath.V3f( -0.5, 0, -0.5 ) + translation - r.point()).length(), 0 ) + self.assertAlmostEqual( math.fabs( r.normal().dot( imath.V3f(0, 1, 0 ) ) ) , 1, places = 3 ) # For each point verify that the UV data is exactly what we specified at those vertices for p in P: foundClosest = mpe.closestPoint( p , r ) self.assert_( foundClosest ) - testUV = IECore.V2f( p.x + uOffset, p.z + vOffset ) + testUV = imath.V2f( p.x + uOffset, p.z + vOffset ) self.assertAlmostEqual( ( testUV - r.uv() ).length(), 0 ) # Now when we looking up that UV in reverse we should get back the point again! @@ -153,7 +154,7 @@ def testSimpleMesh( self ) : self.assertAlmostEqual( ( p - r.point()).length(), 0 ) # test the uvBound method - uvb = IECore.Box2f() + uvb = imath.Box2f() for i in range( 0, len( uv ) ) : uvb.extendBy( uv[i] ) @@ -193,7 +194,7 @@ def testSphereMesh( self ) : # Pick a random point outside the sphere testPt = None while not testPt or testPt.length() < 1.5: - testPt = 3 * IECore.V3f( random.uniform(-1, 1), random.uniform(-1, 1), random.uniform(-1, 1) ) + testPt = 3 * imath.V3f( random.uniform(-1, 1), random.uniform(-1, 1), random.uniform(-1, 1) ) foundClosest = mpe.closestPoint( testPt, r ) @@ -226,13 +227,13 @@ def testSphereMesh( self ) : # Vector from closest point to test point should be roughly the same direction as the normal self.assert_( shadingNormal.dot( ( testPt - r.point() ).normalized() ) > 0.5 ) - rand = IECore.Rand48() + rand = imath.Rand48() # Perform 100 ray intersection queries from inside the sphere, in random directions for i in range(0, 100): - origin = IECore.Rand48.solidSpheref(rand) * 0.5 - direction = IECore.Rand48.hollowSpheref(rand) + origin = rand.nextSolidSphere( imath.V3f() ) * 0.5 + direction = rand.nextHollowSphere( imath.V3f() ) hit = mpe.intersectionPoint( origin, direction, r ) self.assert_( hit ) self.assert_( math.fabs( r.point().length() -1 ) < 0.1 ) @@ -246,7 +247,7 @@ def testSphereMesh( self ) : # Perform 100 nearest ray intersection queries from outside the sphere, going outwards for i in range(0, 100): - direction = IECore.Rand48.hollowSpheref(rand) + direction = rand.nextHollowSphere( imath.V3f() ) origin = direction * 2 hit = mpe.intersectionPoint( origin, direction, r ) @@ -258,7 +259,7 @@ def testSphereMesh( self ) : # Perform 100 nearest ray intersection queries from outside the sphere, going inwards for i in range(0, 100): - direction = -IECore.Rand48.hollowSpheref(rand) + direction = -rand.nextHollowSphere( imath.V3f() ) origin = -direction * 2 hit = mpe.intersectionPoint( origin, direction, r ) @@ -282,18 +283,18 @@ def testCylinderMesh( self ) : m = IECore.Reader.create( "test/IECore/data/cobFiles/cylinder3Mesh.cob" ) () e = IECoreScene.MeshPrimitiveEvaluator( m ) res = e.createResult() - self.failIf( e.intersectionPoint( IECore.V3f(0.5,0,0.5), IECore.V3f(1,0,0), res ) ) - self.assert_( e.intersectionPoint( IECore.V3f(0.5,0,0.5), IECore.V3f(-1,0,0), res ) ) + self.failIf( e.intersectionPoint( imath.V3f(0.5,0,0.5), imath.V3f(1,0,0), res ) ) + self.assert_( e.intersectionPoint( imath.V3f(0.5,0,0.5), imath.V3f(-1,0,0), res ) ) - self.failIf( e.intersectionPoints( IECore.V3f(0.5,0,0.5), IECore.V3f(1,0,0) ) ) - self.assert_( e.intersectionPoints( IECore.V3f(0.5,0,0.5), IECore.V3f(-1,0,0) ) ) + self.failIf( e.intersectionPoints( imath.V3f(0.5,0,0.5), imath.V3f(1,0,0) ) ) + self.assert_( e.intersectionPoints( imath.V3f(0.5,0,0.5), imath.V3f(-1,0,0) ) ) def testRandomTriangles( self ) : """ Testing MeshPrimitiveEvaluator with random triangles""" random.seed( 100 ) - rand = IECore.Rand48( 100 ) + rand = imath.Rand48( 100 ) numConfigurations = 100 numTests = 50 @@ -311,9 +312,9 @@ def testRandomTriangles( self ) : verticesPerFace.append( 3 ) - P.append( IECore.V3f( random.uniform(-10, 10), random.uniform(-10, 10), random.uniform(-10, 10) ) ) - P.append( IECore.V3f( random.uniform(-10, 10), random.uniform(-10, 10), random.uniform(-10, 10) ) ) - P.append( IECore.V3f( random.uniform(-10, 10), random.uniform(-10, 10), random.uniform(-10, 10) ) ) + P.append( imath.V3f( random.uniform(-10, 10), random.uniform(-10, 10), random.uniform(-10, 10) ) ) + P.append( imath.V3f( random.uniform(-10, 10), random.uniform(-10, 10), random.uniform(-10, 10) ) ) + P.append( imath.V3f( random.uniform(-10, 10), random.uniform(-10, 10), random.uniform(-10, 10) ) ) vertexIds.append( vertexId + 0 ) vertexIds.append( vertexId + 1 ) @@ -331,8 +332,8 @@ def testRandomTriangles( self ) : # comparing long-hand with the list of all intersections. for test in range( 0, numTests ) : - origin = IECore.V3f( 0, 0, 0 ) - direction = IECore.Rand48.hollowSpheref(rand) + origin = imath.V3f( 0, 0, 0 ) + direction = rand.nextHollowSphere( imath.V3f() ) hit = mpe.intersectionPoint( origin, direction, r ) diff --git a/test/IECoreScene/MeshPrimitiveShrinkWrapOp.py b/test/IECoreScene/MeshPrimitiveShrinkWrapOp.py index d2bc1ca495..811283c4ca 100644 --- a/test/IECoreScene/MeshPrimitiveShrinkWrapOp.py +++ b/test/IECoreScene/MeshPrimitiveShrinkWrapOp.py @@ -35,6 +35,7 @@ import math import unittest import random +import imath import IECore import IECoreScene @@ -59,7 +60,7 @@ def testSimple( self ) : target["P"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData() ) for p in pData: - target["P"].data.append( p * targetRadius + 0.01 * IECore.V3f( random.random(), random.random(), random.random() ) ) + target["P"].data.append( p * targetRadius + 0.01 * imath.V3f( random.random(), random.random(), random.random() ) ) self.assertEqual( len( target["P"].data ), len( m["P"].data ) ) diff --git a/test/IECoreScene/MeshVertexReorderOpTest.py b/test/IECoreScene/MeshVertexReorderOpTest.py index bc364b64a3..4b4088e9e6 100755 --- a/test/IECoreScene/MeshVertexReorderOpTest.py +++ b/test/IECoreScene/MeshVertexReorderOpTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene @@ -57,10 +58,10 @@ def testPlane( self ) : m = IECoreScene.MeshPrimitive( verticesPerFace, vertexIds ) p = IECore.V3fVectorData() - p.append( IECore.V3f( -1, -1, 0 ) ) - p.append( IECore.V3f( 1, -1, 0 ) ) - p.append( IECore.V3f( -1, 1, 0 ) ) - p.append( IECore.V3f( 1, 1, 0 ) ) + p.append( imath.V3f( -1, -1, 0 ) ) + p.append( imath.V3f( 1, -1, 0 ) ) + p.append( imath.V3f( -1, 1, 0 ) ) + p.append( imath.V3f( 1, 1, 0 ) ) s = IECore.FloatVectorData() s.append( 0 ) @@ -96,7 +97,7 @@ def testPlane( self ) : result = op( input = m, - startingVertices = IECore.V3i( 2, 3, 1 ) + startingVertices = imath.V3i( 2, 3, 1 ) ) expectedVerticesPerFace = IECore.IntVectorData() @@ -116,10 +117,10 @@ def testPlane( self ) : self.assertEqual( result.vertexIds, expectedVertexIds ) expectedP = IECore.V3fVectorData() - expectedP.append( IECore.V3f( -1, 1, 0 ) ) - expectedP.append( IECore.V3f( 1, 1, 0 ) ) - expectedP.append( IECore.V3f( 1, -1, 0 ) ) - expectedP.append( IECore.V3f( -1, -1, 0 ) ) + expectedP.append( imath.V3f( -1, 1, 0 ) ) + expectedP.append( imath.V3f( 1, 1, 0 ) ) + expectedP.append( imath.V3f( 1, -1, 0 ) ) + expectedP.append( imath.V3f( -1, -1, 0 ) ) self.assertEqual( result["P"].data, expectedP ) @@ -172,10 +173,10 @@ def testPlaneOppositeWinding( self ) : m = IECoreScene.MeshPrimitive( verticesPerFace, vertexIds ) p = IECore.V3fVectorData() - p.append( IECore.V3f( -1, -1, 0 ) ) - p.append( IECore.V3f( 1, -1, 0 ) ) - p.append( IECore.V3f( -1, 1, 0 ) ) - p.append( IECore.V3f( 1, 1, 0 ) ) + p.append( imath.V3f( -1, -1, 0 ) ) + p.append( imath.V3f( 1, -1, 0 ) ) + p.append( imath.V3f( -1, 1, 0 ) ) + p.append( imath.V3f( 1, 1, 0 ) ) s = IECore.FloatVectorData() s.append( 0 ) @@ -211,7 +212,7 @@ def testPlaneOppositeWinding( self ) : result = op( input = m, - startingVertices = IECore.V3i( 2, 3, 1 ) + startingVertices = imath.V3i( 2, 3, 1 ) ) expectedVerticesPerFace = IECore.IntVectorData() @@ -231,10 +232,10 @@ def testPlaneOppositeWinding( self ) : self.assertEqual( result.vertexIds, expectedVertexIds ) expectedP = IECore.V3fVectorData() - expectedP.append( IECore.V3f( -1, 1, 0 ) ) - expectedP.append( IECore.V3f( 1, 1, 0 ) ) - expectedP.append( IECore.V3f( 1, -1, 0 ) ) - expectedP.append( IECore.V3f( -1, -1, 0 ) ) + expectedP.append( imath.V3f( -1, 1, 0 ) ) + expectedP.append( imath.V3f( 1, 1, 0 ) ) + expectedP.append( imath.V3f( 1, -1, 0 ) ) + expectedP.append( imath.V3f( -1, -1, 0 ) ) self.assertEqual( result["P"].data, expectedP ) @@ -276,7 +277,7 @@ def testQuadSphere( self ) : result = op( input = m, - startingVertices = IECore.V3i( 0, 1, 21 ) + startingVertices = imath.V3i( 0, 1, 21 ) ) self.assert_( result.arePrimitiveVariablesValid() ) @@ -293,7 +294,7 @@ def testSphere( self ) : result = op( input = m, - startingVertices = IECore.V3i( 20, 1, 21 ) + startingVertices = imath.V3i( 20, 1, 21 ) ) self.assert_( result.arePrimitiveVariablesValid() ) @@ -310,7 +311,7 @@ def testCube( self ) : result = op( input = m, - startingVertices = IECore.V3i( 0, 1, 3 ) + startingVertices = imath.V3i( 0, 1, 3 ) ) self.assert_( result.arePrimitiveVariablesValid() ) diff --git a/test/IECoreScene/MixSmoothSkinningWeightsOpTest.py b/test/IECoreScene/MixSmoothSkinningWeightsOpTest.py index 21a1dd6251..cd609493d2 100644 --- a/test/IECoreScene/MixSmoothSkinningWeightsOpTest.py +++ b/test/IECoreScene/MixSmoothSkinningWeightsOpTest.py @@ -35,6 +35,7 @@ import math import unittest import random +import imath import IECore import IECoreScene @@ -44,7 +45,7 @@ class MixSmoothSkinningWeightsOpTest( unittest.TestCase ) : def createSSD( self, weights ) : names = IECore.StringVectorData( [ 'jointA', 'jointB', 'jointC' ] ) - poses = IECore.M44fVectorData( [IECore.M44f(1),IECore.M44f(2),IECore.M44f(3)] ) + poses = IECore.M44fVectorData( [imath.M44f(1),imath.M44f(2),imath.M44f(3)] ) offsets = IECore.IntVectorData( [0, 2, 5, 6] ) counts = IECore.IntVectorData( [2, 3, 1, 2] ) indices = IECore.IntVectorData( [0, 1, 0, 1, 2, 1, 1, 2] ) diff --git a/test/IECoreScene/NormalizeSmoothSkinningWeightsOpTest.py b/test/IECoreScene/NormalizeSmoothSkinningWeightsOpTest.py index 3ca82d09fe..2991747d1b 100644 --- a/test/IECoreScene/NormalizeSmoothSkinningWeightsOpTest.py +++ b/test/IECoreScene/NormalizeSmoothSkinningWeightsOpTest.py @@ -35,6 +35,7 @@ import math import unittest import random +import imath import IECore import IECoreScene @@ -44,7 +45,7 @@ class NormalizeSmoothSkinningWeightsOpTest( unittest.TestCase ) : def createSSD( self, weights ) : names = IECore.StringVectorData( [ 'jointA', 'jointB', 'jointC' ] ) - poses = IECore.M44fVectorData( [IECore.M44f(1),IECore.M44f(2),IECore.M44f(3)] ) + poses = IECore.M44fVectorData( [imath.M44f(1),imath.M44f(2),imath.M44f(3)] ) offsets = IECore.IntVectorData( [0, 2, 5, 6] ) counts = IECore.IntVectorData( [2, 3, 1, 2] ) indices = IECore.IntVectorData( [0, 1, 0, 1, 2, 1, 1, 2] ) diff --git a/test/IECoreScene/ObjectInterpolationTest.py b/test/IECoreScene/ObjectInterpolationTest.py index 5093169ad3..510d2b0f04 100644 --- a/test/IECoreScene/ObjectInterpolationTest.py +++ b/test/IECoreScene/ObjectInterpolationTest.py @@ -34,6 +34,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene @@ -42,15 +43,15 @@ class ObjectInterpolationTest( unittest.TestCase ) : def testPrimitiveInterpolation( self ) : - m1 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) - m2 = IECoreScene.TransformOp()( input=m1, matrix = IECore.M44fData( IECore.M44f.createScaled( IECore.V3f( 2 ) ) ) ) + m1 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) + m2 = IECoreScene.TransformOp()( input=m1, matrix = IECore.M44fData( imath.M44f().scale( imath.V3f( 2 ) ) ) ) m3 = IECore.linearObjectInterpolation( m1, m2, 0.5 ) - self.assertEqual( m3, IECoreScene.TransformOp()( input=m1, matrix = IECore.M44fData( IECore.M44f.createScaled( IECore.V3f( 1.5 ) ) ) ) ) + self.assertEqual( m3, IECoreScene.TransformOp()( input=m1, matrix = IECore.M44fData( imath.M44f().scale( imath.V3f( 1.5 ) ) ) ) ) def testPrimitiveInterpolationMaintainsUninterpolableValuesFromFirstPrimitive( self ) : - m1 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m1 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) m1["c"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.StringData( "hi" ) ) m2 = m1.copy() @@ -64,8 +65,8 @@ def testPrimitiveInterpolationMaintainsUninterpolableValuesFromFirstPrimitive( s def testPrimitiveInterpolationMaintainsValuesMissingFromSecondPrimitive( self ) : - m1 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) - m2 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m1 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) + m2 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) m1["v"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.FloatVectorData( [ 1, 2, 3, 4 ] ) ) @@ -74,7 +75,7 @@ def testPrimitiveInterpolationMaintainsValuesMissingFromSecondPrimitive( self ) def testPrimitiveInterpolationWithBlindData( self ) : - m1 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m1 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) m2 = m1.copy() m1.blindData()["a"] = IECore.FloatData( 10 ) @@ -85,7 +86,7 @@ def testPrimitiveInterpolationWithBlindData( self ) : def testPrimitiveInterpolationWithBlindDataMaintainsValuesMissingFromSecondPrimitive( self ) : - m1 = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m1 = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) m2 = m1.copy() m1.blindData()["a"] = IECore.FloatData( 10 ) diff --git a/test/IECoreScene/PDCWriter.py b/test/IECoreScene/PDCWriter.py index 74fa4af8bf..07f173c610 100644 --- a/test/IECoreScene/PDCWriter.py +++ b/test/IECoreScene/PDCWriter.py @@ -35,6 +35,7 @@ import os import unittest import sys +import imath import IECore import IECoreScene @@ -80,7 +81,7 @@ def testWriteConstantData( self ) : p = IECoreScene.PointsPrimitive( 1 ) p["d"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.DoubleData( 1 ) ) - p["v3d"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.V3dData( IECore.V3d( 1, 2, 3 ) ) ) + p["v3d"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.V3dData( imath.V3d( 1, 2, 3 ) ) ) p["i"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.IntData( 10 ) ) w = IECore.Writer.create( p, "test/particleShape1.250.pdc" ) @@ -96,9 +97,9 @@ def testWriteFloatData( self ) : p = IECoreScene.PointsPrimitive( 3 ) p["f"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.FloatData( 1 ) ) - p["v3f"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.V3fData( IECore.V3f( 1, 2, 3 ) ) ) + p["v3f"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.V3fData( imath.V3f( 1, 2, 3 ) ) ) p["fVector"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.FloatVectorData( [ 1, 2, 3 ] ) ) - p["v3fVector"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f( 1, 2, 3 ), IECore.V3f( 4, 5, 6 ), IECore.V3f( 7, 8, 9 ) ] ) ) + p["v3fVector"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f( 1, 2, 3 ), imath.V3f( 4, 5, 6 ), imath.V3f( 7, 8, 9 ) ] ) ) w = IECore.Writer.create( p, "test/particleShape1.250.pdc" ) w.write() @@ -109,15 +110,15 @@ def testWriteFloatData( self ) : self.assertEqual( p.keys(), p2.keys() ) self.assertEqual( p2["f"].data, IECore.DoubleData( 1 ) ) - self.assertEqual( p2["v3f"].data, IECore.V3dData( IECore.V3d( 1, 2, 3 ) ) ) + self.assertEqual( p2["v3f"].data, IECore.V3dData( imath.V3d( 1, 2, 3 ) ) ) self.assertEqual( p2["fVector"].data, IECore.DoubleVectorData( [ 1, 2, 3 ] ) ) - self.assertEqual( p2["v3fVector"].data, IECore.V3dVectorData( [ IECore.V3d( 1, 2, 3 ), IECore.V3d( 4, 5, 6 ), IECore.V3d( 7, 8, 9 ) ] ) ) + self.assertEqual( p2["v3fVector"].data, IECore.V3dVectorData( [ imath.V3d( 1, 2, 3 ), imath.V3d( 4, 5, 6 ), imath.V3d( 7, 8, 9 ) ] ) ) def testWriteColorData( self ) : p = IECoreScene.PointsPrimitive( 3 ) - p["color3f"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.Color3fData( IECore.Color3f( 1 ) ) ) - p["color3fVector"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.Color3fVectorData( [ IECore.Color3f( 1 ), IECore.Color3f( 2 ), IECore.Color3f( 3 ) ] ) ) + p["color3f"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.Color3fData( imath.Color3f( 1 ) ) ) + p["color3fVector"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.Color3fVectorData( [ imath.Color3f( 1 ), imath.Color3f( 2 ), imath.Color3f( 3 ) ] ) ) IECore.Writer.create( p, "test/particleShape1.250.pdc" ).write() @@ -126,8 +127,8 @@ def testWriteColorData( self ) : self.assertEqual( p.keys(), p2.keys() ) # we can't expect them to come back as colours, because there's not support for that in pdcs - they should therefore come back as float vectors - self.assertEqual( p2["color3f"].data, IECore.V3fData( IECore.V3f( 1 ) ) ) - self.assertEqual( p2["color3fVector"].data, IECore.V3fVectorData( [ IECore.V3f( 1 ), IECore.V3f( 2 ), IECore.V3f( 3 ) ] ) ) + self.assertEqual( p2["color3f"].data, IECore.V3fData( imath.V3f( 1 ) ) ) + self.assertEqual( p2["color3fVector"].data, IECore.V3fVectorData( [ imath.V3f( 1 ), imath.V3f( 2 ), imath.V3f( 3 ) ] ) ) def tearDown( self ) : diff --git a/test/IECoreScene/PatchMeshPrimitiveTest.py b/test/IECoreScene/PatchMeshPrimitiveTest.py index 779515d4d7..1f07ab28b3 100644 --- a/test/IECoreScene/PatchMeshPrimitiveTest.py +++ b/test/IECoreScene/PatchMeshPrimitiveTest.py @@ -36,6 +36,7 @@ import os.path import math import unittest +import imath import IECore import IECoreScene @@ -45,7 +46,7 @@ def testConstructors( self ) : self.assertRaises( Exception, IECoreScene.PatchMeshPrimitive ) - p = IECoreScene.PatchMeshPrimitive( 10, 7, IECore.CubicBasisf.bezier(), IECore.CubicBasisf.bezier(), False, False, IECore.V3fVectorData( [ IECore.V3f() ] * 70 ) ) + p = IECoreScene.PatchMeshPrimitive( 10, 7, IECore.CubicBasisf.bezier(), IECore.CubicBasisf.bezier(), False, False, IECore.V3fVectorData( [ imath.V3f() ] * 70 ) ) self.assertEqual( p.uBasis(), IECore.CubicBasisf.bezier() ) self.assertEqual( p.vBasis(), IECore.CubicBasisf.bezier() ) @@ -67,7 +68,7 @@ def testConstructorValidation( self ) : def testCopy( self ) : - p = IECoreScene.PatchMeshPrimitive( 10, 7, IECore.CubicBasisf.bezier(), IECore.CubicBasisf.bezier(), False, False, IECore.V3fVectorData( [ IECore.V3f() ] * 70 ) ) + p = IECoreScene.PatchMeshPrimitive( 10, 7, IECore.CubicBasisf.bezier(), IECore.CubicBasisf.bezier(), False, False, IECore.V3fVectorData( [ imath.V3f() ] * 70 ) ) pp = p.copy() self.assertEqual( p, pp ) @@ -84,7 +85,7 @@ def testIO( self ) : def testVariableSize( self ) : - p = IECoreScene.PatchMeshPrimitive( 10, 7, IECore.CubicBasisf.bezier(), IECore.CubicBasisf.bezier(), False, False, IECore.V3fVectorData( [ IECore.V3f() ] * 70 ) ) + p = IECoreScene.PatchMeshPrimitive( 10, 7, IECore.CubicBasisf.bezier(), IECore.CubicBasisf.bezier(), False, False, IECore.V3fVectorData( [ imath.V3f() ] * 70 ) ) self.assertEqual( p.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Constant ), 1 ) self.assertEqual( p.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ), 6 ) @@ -92,7 +93,7 @@ def testVariableSize( self ) : self.assertEqual( p.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Varying ), 12 ) self.assertEqual( p.variableSize( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying ), 12 ) - p = IECoreScene.PatchMeshPrimitive( 9, 5, IECore.CubicBasisf.catmullRom(), IECore.CubicBasisf.catmullRom(), True, False, IECore.V3fVectorData( [ IECore.V3f() ] * 45 ) ) + p = IECoreScene.PatchMeshPrimitive( 9, 5, IECore.CubicBasisf.catmullRom(), IECore.CubicBasisf.catmullRom(), True, False, IECore.V3fVectorData( [ imath.V3f() ] * 45 ) ) self.assertEqual( p.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Constant ), 1 ) self.assertEqual( p.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ), 18 ) diff --git a/test/IECoreScene/PointBoundsOp.py b/test/IECoreScene/PointBoundsOp.py index 2888b5e0e4..a5a53412b4 100644 --- a/test/IECoreScene/PointBoundsOp.py +++ b/test/IECoreScene/PointBoundsOp.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene @@ -41,49 +42,49 @@ class TestPointBoundsOp( unittest.TestCase ) : def test( self ) : o = IECoreScene.PointBoundsOp() - b = o( points = IECore.V3fVectorData( [ IECore.V3f( 0 ) ] ) ) + b = o( points = IECore.V3fVectorData( [ imath.V3f( 0 ) ] ) ) self.assert_( b.isInstanceOf( IECore.Box3fData.staticTypeId() ) ) - self.assertEqual( b.value, IECore.Box3f( IECore.V3f( 0 ), IECore.V3f( 0 ) ) ) + self.assertEqual( b.value, imath.Box3f( imath.V3f( 0 ), imath.V3f( 0 ) ) ) o = IECoreScene.PointBoundsOp() b = o( - points = IECore.V3fVectorData( [ IECore.V3f( 0 ) ] ), - velocities = IECore.V3fVectorData( [ IECore.V3f( 1 ) ] ) + points = IECore.V3fVectorData( [ imath.V3f( 0 ) ] ), + velocities = IECore.V3fVectorData( [ imath.V3f( 1 ) ] ) ) - self.assertEqual( b.value, IECore.Box3f( IECore.V3f( 0 ), IECore.V3f( 1 ) ) ) + self.assertEqual( b.value, imath.Box3f( imath.V3f( 0 ), imath.V3f( 1 ) ) ) o = IECoreScene.PointBoundsOp() b = o( - points = IECore.V3fVectorData( [ IECore.V3f( 0 ) ] ), - velocities = IECore.V3fVectorData( [ IECore.V3f( 1 ) ] ), + points = IECore.V3fVectorData( [ imath.V3f( 0 ) ] ), + velocities = IECore.V3fVectorData( [ imath.V3f( 1 ) ] ), velocityMultiplier = 0.5 ) - self.assertEqual( b.value, IECore.Box3f( IECore.V3f( 0 ), IECore.V3f( 0.5 ) ) ) + self.assertEqual( b.value, imath.Box3f( imath.V3f( 0 ), imath.V3f( 0.5 ) ) ) o = IECoreScene.PointBoundsOp() b = o( - points = IECore.V3fVectorData( [ IECore.V3f( 0 ) ] ), - velocities = IECore.V3fVectorData( [ IECore.V3f( 1 ) ] ), + points = IECore.V3fVectorData( [ imath.V3f( 0 ) ] ), + velocities = IECore.V3fVectorData( [ imath.V3f( 1 ) ] ), velocityMultiplier = 0.5, radii = IECore.FloatVectorData( [ 1 ] ), ) - self.assertEqual( b.value, IECore.Box3f( IECore.V3f( -1 ), IECore.V3f( 1.5 ) ) ) + self.assertEqual( b.value, imath.Box3f( imath.V3f( -1 ), imath.V3f( 1.5 ) ) ) o = IECoreScene.PointBoundsOp() b = o( - points = IECore.V3fVectorData( [ IECore.V3f( 0 ) ] ), - velocities = IECore.V3fVectorData( [ IECore.V3f( 1 ) ] ), + points = IECore.V3fVectorData( [ imath.V3f( 0 ) ] ), + velocities = IECore.V3fVectorData( [ imath.V3f( 1 ) ] ), velocityMultiplier = 0.5, radii = IECore.FloatVectorData( [ 1 ] ), radiusMultiplier = 0.5, ) - self.assertEqual( b.value, IECore.Box3f( IECore.V3f( -0.5 ), IECore.V3f( 1 ) ) ) + self.assertEqual( b.value, imath.Box3f( imath.V3f( -0.5 ), imath.V3f( 1 ) ) ) o = IECoreScene.PointBoundsOp() b = o( - points = IECore.V3fVectorData( [ IECore.V3f( 0, 1, 2 ), IECore.V3f( 4, 5, 6 ) ] ), + points = IECore.V3fVectorData( [ imath.V3f( 0, 1, 2 ), imath.V3f( 4, 5, 6 ) ] ), ) - self.assertEqual( b.value, IECore.Box3f( IECore.V3f( 0, 1, 2 ), IECore.V3f( 4, 5, 6 ) ) ) + self.assertEqual( b.value, imath.Box3f( imath.V3f( 0, 1, 2 ), imath.V3f( 4, 5, 6 ) ) ) if __name__ == "__main__": unittest.main() diff --git a/test/IECoreScene/PointSmoothSkinningOpTest.py b/test/IECoreScene/PointSmoothSkinningOpTest.py index 3570e52bbc..06e9fee79a 100644 --- a/test/IECoreScene/PointSmoothSkinningOpTest.py +++ b/test/IECoreScene/PointSmoothSkinningOpTest.py @@ -34,6 +34,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene @@ -43,7 +44,7 @@ class PointSmoothSkinningOpTest( unittest.TestCase ) : def mySSD (self): # return an ssd for testing ok_jn = IECore.StringVectorData( [ 'joint1', 'joint2', 'joint3' ] ) - ok_ip = IECore.M44fVectorData( [IECore.M44f().translate(IECore.V3f(0,2,0)), IECore.M44f(), IECore.M44f().translate(IECore.V3f(0,-2,0))] ) + ok_ip = IECore.M44fVectorData( [imath.M44f().translate(imath.V3f(0,2,0)), imath.M44f(), imath.M44f().translate(imath.V3f(0,-2,0))] ) ok_pio = IECore.IntVectorData( [0, 2, 4, 6, 8, 10, 12, 14] ) ok_pic = IECore.IntVectorData( [2, 2, 2, 2, 2, 2, 2, 2] ) ok_pii = IECore.IntVectorData( [0, 1, 0, 1, 1, 2, 1, 2, 1, 2, 1, 2, 0, 1, 0, 1] ) @@ -54,14 +55,14 @@ def mySSD (self): def myN (self): # return an n for testing - n = IECore.V3fVectorData( [ IECore.V3f(0, -1, 0), IECore.V3f(0, -1, 0 ), IECore.V3f(0, 1, 0 ), IECore.V3f(0, 1, 0 ), - IECore.V3f(0, 1, 0 ), IECore.V3f(0, 1, 0 ), IECore.V3f(0, -1, 0), IECore.V3f(0, -1, 0)] ) + n = IECore.V3fVectorData( [ imath.V3f(0, -1, 0), imath.V3f(0, -1, 0 ), imath.V3f(0, 1, 0 ), imath.V3f(0, 1, 0 ), + imath.V3f(0, 1, 0 ), imath.V3f(0, 1, 0 ), imath.V3f(0, -1, 0), imath.V3f(0, -1, 0)] ) return n def myP (self): # return an p for testing - p = IECore.V3fVectorData( [ IECore.V3f(-0.5, -2, 0.5), IECore.V3f(0.5, -2, 0.5 ), IECore.V3f(-0.5, 2, 0.5 ), IECore.V3f(0.5, 2, 0.5 ), - IECore.V3f(-0.5, 2, -0.5), IECore.V3f(0.5, 2, -0.5 ), IECore.V3f(-0.5, -2, -0.5), IECore.V3f(0.5, -2, -0.5)] ) + p = IECore.V3fVectorData( [ imath.V3f(-0.5, -2, 0.5), imath.V3f(0.5, -2, 0.5 ), imath.V3f(-0.5, 2, 0.5 ), imath.V3f(0.5, 2, 0.5 ), + imath.V3f(-0.5, 2, -0.5), imath.V3f(0.5, 2, -0.5 ), imath.V3f(-0.5, -2, -0.5), imath.V3f(0.5, -2, -0.5)] ) return p def myPP (self): @@ -74,12 +75,12 @@ def myPP (self): def myMN (self): # face varying n - n = IECore.V3fVectorData( [ IECore.V3f( 0, 0, 1 ), IECore.V3f( 0, 0, 1 ), IECore.V3f( 0, 0, 1 ), IECore.V3f( 0, 0, 1 ), - IECore.V3f( 0, 1, 0 ), IECore.V3f( 0, 1, 0 ), IECore.V3f( 0, 1, 0 ), IECore.V3f( 0, 1, 0 ), - IECore.V3f( 0, 0, -1 ), IECore.V3f( 0, 0, -1 ), IECore.V3f( 0, 0, -1 ), IECore.V3f( 0, 0, -1 ), - IECore.V3f( 0, -1, 0 ), IECore.V3f( 0, -1, 0 ), IECore.V3f( 0, -1, 0 ), IECore.V3f( 0, -1, 0 ), - IECore.V3f( 1, 0, 0 ), IECore.V3f( 1, 0, 0 ), IECore.V3f( 1, 0, 0 ), IECore.V3f( 1, 0, 0 ), - IECore.V3f( -1, 0, 0 ), IECore.V3f( -1, 0, 0 ), IECore.V3f( -1, 0, 0 ), IECore.V3f( -1, 0, 0 ) ] ) + n = IECore.V3fVectorData( [ imath.V3f( 0, 0, 1 ), imath.V3f( 0, 0, 1 ), imath.V3f( 0, 0, 1 ), imath.V3f( 0, 0, 1 ), + imath.V3f( 0, 1, 0 ), imath.V3f( 0, 1, 0 ), imath.V3f( 0, 1, 0 ), imath.V3f( 0, 1, 0 ), + imath.V3f( 0, 0, -1 ), imath.V3f( 0, 0, -1 ), imath.V3f( 0, 0, -1 ), imath.V3f( 0, 0, -1 ), + imath.V3f( 0, -1, 0 ), imath.V3f( 0, -1, 0 ), imath.V3f( 0, -1, 0 ), imath.V3f( 0, -1, 0 ), + imath.V3f( 1, 0, 0 ), imath.V3f( 1, 0, 0 ), imath.V3f( 1, 0, 0 ), imath.V3f( 1, 0, 0 ), + imath.V3f( -1, 0, 0 ), imath.V3f( -1, 0, 0 ), imath.V3f( -1, 0, 0 ), imath.V3f( -1, 0, 0 ) ] ) return n def myMP (self): @@ -93,9 +94,9 @@ def myMP (self): def myDP (self): # return a deformation pose for testing (2nd joint roated by 90deg in z) - dp = IECore.M44fVectorData( [ IECore.M44f( 1, 0, 0, 0, -0, 1, -0, 0, 0, -0, 1, -0, -0, -2, -0, 1 ), - IECore.M44f( 0, 1, 0, -0, -1, 0, -0, 0, 0, -0, 1, -0, -0, 0, -0, 1 ), - IECore.M44f( 0, 1, 0, 0, -1, 0, -0, 0, 0, -0, 1, -0, -0, -2, -0, 1 ) ] ) + dp = IECore.M44fVectorData( [ imath.M44f( 1, 0, 0, 0, -0, 1, -0, 0, 0, -0, 1, -0, -0, -2, -0, 1 ), + imath.M44f( 0, 1, 0, -0, -1, 0, -0, 0, 0, -0, 1, -0, -0, 0, -0, 1 ), + imath.M44f( 0, 1, 0, 0, -1, 0, -0, 0, 0, -0, 1, -0, -0, -2, -0, 1 ) ] ) return dp @@ -156,7 +157,7 @@ def testBadSSD( self ) : # test if the ssd is not matching the deformationPose ssd = self.mySSD() a = ssd.influencePose() - a.append(IECore.M44f()) + a.append(imath.M44f()) self.assertRaises( RuntimeError, o, input=pts, copyInput=True, smoothSkinningData = ssd, deformationPose = self.myDP()) @@ -180,7 +181,7 @@ def testBadDeformationPose( self ) : # test if the ssd is not matching the deformationPose dp = self.myDP() - dp.append(IECore.M44f()) + dp.append(imath.M44f()) self.assertRaises( RuntimeError, o, input=pts, copyInput=True, smoothSkinningData = self.mySSD(), deformationPose = dp) @@ -190,7 +191,7 @@ def testPrimVarLengthMismatch( self ) : pts = IECoreScene.PointsPrimitive(0) vertex = IECoreScene.PrimitiveVariable.Interpolation.Vertex pts["P"] = IECoreScene.PrimitiveVariable( vertex, self.myP() ) - pts["N"] = IECoreScene.PrimitiveVariable( vertex, IECore.V3fVectorData( [ IECore.V3f(0, -1, 0)] ) ) + pts["N"] = IECoreScene.PrimitiveVariable( vertex, IECore.V3fVectorData( [ imath.V3f(0, -1, 0)] ) ) o = IECoreScene.PointSmoothSkinningOp() self.assertRaises( RuntimeError, o, input=pts, copyInput=True, deformationPose = self.myDP(), smoothSkinningData = self.mySSD(), deformNormals = True ) diff --git a/test/IECoreScene/PointVelocityDisplaceOp.py b/test/IECoreScene/PointVelocityDisplaceOp.py index 81c49d300e..25bbc05353 100644 --- a/test/IECoreScene/PointVelocityDisplaceOp.py +++ b/test/IECoreScene/PointVelocityDisplaceOp.py @@ -34,6 +34,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene @@ -50,46 +51,46 @@ def test( self ) : # check not passing v is a passthru o = IECoreScene.PointVelocityDisplaceOp() - pts["P"] = IECoreScene.PrimitiveVariable( vertex, IECore.V3fVectorData( [ IECore.V3f(0) ] ) ) + pts["P"] = IECoreScene.PrimitiveVariable( vertex, IECore.V3fVectorData( [ imath.V3f(0) ] ) ) self.assertRaises( RuntimeError, o, input=pts, copyInput=True ) # check it works o = IECoreScene.PointVelocityDisplaceOp() - pts["P"] = IECoreScene.PrimitiveVariable( vertex, IECore.V3fVectorData( [ IECore.V3f(0) ] ) ) - pts["v"] = IECoreScene.PrimitiveVariable( vertex, IECore.V3fVectorData( [ IECore.V3f(1) ] ) ) + pts["P"] = IECoreScene.PrimitiveVariable( vertex, IECore.V3fVectorData( [ imath.V3f(0) ] ) ) + pts["v"] = IECoreScene.PrimitiveVariable( vertex, IECore.V3fVectorData( [ imath.V3f(1) ] ) ) p = o(input=pts) self.assertNotEqual( pts["P"].data, p["P"].data ) - self.assertEqual( p["P"].data[0], IECore.V3f(1) ) + self.assertEqual( p["P"].data[0], imath.V3f(1) ) p = o(input=pts, copyInput=False) self.assertEqual( pts["P"].data, p["P"].data ) - self.assertEqual( pts["P"].data[0], IECore.V3f(1) ) + self.assertEqual( pts["P"].data[0], imath.V3f(1) ) # slightly more interesting example o = IECoreScene.PointVelocityDisplaceOp() - pts["P"] = IECoreScene.PrimitiveVariable( vertex, IECore.V3fVectorData( [ IECore.V3f( 1,2,3 ), IECore.V3f( 4,5,6 ) ] ) ) - pts["v"] = IECoreScene.PrimitiveVariable( vertex, IECore.V3fVectorData( [ IECore.V3f( 1 ), IECore.V3f( 2, 1, 3 ) ] ) ) + pts["P"] = IECoreScene.PrimitiveVariable( vertex, IECore.V3fVectorData( [ imath.V3f( 1,2,3 ), imath.V3f( 4,5,6 ) ] ) ) + pts["v"] = IECoreScene.PrimitiveVariable( vertex, IECore.V3fVectorData( [ imath.V3f( 1 ), imath.V3f( 2, 1, 3 ) ] ) ) p = o(input=pts) - self.assertEqual( p["P"].data, IECore.V3fVectorData([ IECore.V3f(2,3,4), IECore.V3f(6,6,9) ] ) ) + self.assertEqual( p["P"].data, IECore.V3fVectorData([ imath.V3f(2,3,4), imath.V3f(6,6,9) ] ) ) # check samplelength works o = IECoreScene.PointVelocityDisplaceOp() - pts["P"] = IECoreScene.PrimitiveVariable( vertex, IECore.V3fVectorData( [ IECore.V3f( 1,2,3 ), IECore.V3f( 4,5,6 ) ] ) ) - pts["v"] = IECoreScene.PrimitiveVariable( vertex, IECore.V3fVectorData( [ IECore.V3f( 1 ), IECore.V3f( 2, 1, 3 ) ] ) ) + pts["P"] = IECoreScene.PrimitiveVariable( vertex, IECore.V3fVectorData( [ imath.V3f( 1,2,3 ), imath.V3f( 4,5,6 ) ] ) ) + pts["v"] = IECoreScene.PrimitiveVariable( vertex, IECore.V3fVectorData( [ imath.V3f( 1 ), imath.V3f( 2, 1, 3 ) ] ) ) p = o(input=pts, sampleLength=0.5) - self.assertEqual( p["P"].data, IECore.V3fVectorData([ IECore.V3f(1.5,2.5,3.5), IECore.V3f(5,5.5,7.5) ] ) ) + self.assertEqual( p["P"].data, IECore.V3fVectorData([ imath.V3f(1.5,2.5,3.5), imath.V3f(5,5.5,7.5) ] ) ) # check that len(p)!=len(v) raises exception o = IECoreScene.PointVelocityDisplaceOp() - pts["P"] = IECoreScene.PrimitiveVariable( vertex, IECore.V3fVectorData( [ IECore.V3f(0), IECore.V3f(1), IECore.V3f(2) ] ) ) - pts["v"] = IECoreScene.PrimitiveVariable( vertex, IECore.V3fVectorData( [ IECore.V3f( 1 ) ] ) ) + pts["P"] = IECoreScene.PrimitiveVariable( vertex, IECore.V3fVectorData( [ imath.V3f(0), imath.V3f(1), imath.V3f(2) ] ) ) + pts["v"] = IECoreScene.PrimitiveVariable( vertex, IECore.V3fVectorData( [ imath.V3f( 1 ) ] ) ) self.assertRaises( RuntimeError, o, input=pts ) # check that it works with other primitives o = IECoreScene.PointVelocityDisplaceOp() - c = IECoreScene.MeshPrimitive.createBox( IECore.Box3f( IECore.V3f(0), IECore.V3f(1) ) ) + c = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f(0), imath.V3f(1) ) ) self.assertEqual( len(c['P'].data), 8 ) v = IECore.V3fVectorData( [] ) - v.resize( 8, IECore.V3f(1) ) + v.resize( 8, imath.V3f(1) ) c['v'] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, v ) c2 = o(input=c) for i in range(8): @@ -115,7 +116,7 @@ def test( self ) : # check that it works with different var names o = IECoreScene.PointVelocityDisplaceOp() - c = IECoreScene.MeshPrimitive.createBox( IECore.Box3f( IECore.V3f(0), IECore.V3f(1) ) ) + c = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f(0), imath.V3f(1) ) ) IECoreScene.MeshNormalsOp()( input=c, copyInput=False ) self.assertTrue( "N" in c ) c['bob'] = c['P'] diff --git a/test/IECoreScene/PointsAlgoTest.py b/test/IECoreScene/PointsAlgoTest.py index de97fa790f..f91830cf74 100644 --- a/test/IECoreScene/PointsAlgoTest.py +++ b/test/IECoreScene/PointsAlgoTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene @@ -40,7 +41,7 @@ class PointsAlgoTest( unittest.TestCase ) : def points( self ) : - testObject = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ IECore.V3f( x ) for x in range( 0, 10 ) ] ) ) + testObject = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ imath.V3f( x ) for x in range( 0, 10 ) ] ) ) testObject["a"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.FloatData( 0.5 ) ) testObject["b"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.FloatVectorData( range( 0, 10 ) ) ) @@ -293,7 +294,7 @@ def testPointsIndexedFaceVaryingToUniform( self ) : class DeletePointsTest( unittest.TestCase ) : def points( self ) : - testObject = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ IECore.V3f( x ) for x in range( 0, 10 ) ] ) ) + testObject = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ imath.V3f( x ) for x in range( 0, 10 ) ] ) ) testObject["a"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.FloatData( 0.5 ) ) testObject["b"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.FloatVectorData( range( 0, 10 ) ) ) @@ -307,7 +308,7 @@ def points( self ) : def testRaisesExceptionIfPrimitiveVariableTypeIsInvalid(self): points = self.points() - points["delete"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f( x ) for x in range( 0, 10 ) ] ) ) + points["delete"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f( x ) for x in range( 0, 10 ) ] ) ) self.assertTrue( points.arePrimitiveVariablesValid() ) @@ -412,25 +413,25 @@ def testPrimitiveVariablesCorrectlyFilteredIfDeleteInverterd(self): class MergePointsTest( unittest.TestCase ) : def testCanMergeTwoPointsPrimitivesWithNoPrimvars( self ) : - pointsA = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [IECore.V3f( x ) for x in range( 0, 3 )] ) ) - pointsB = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [IECore.V3f( x ) for x in range( 5, 9 )] ) ) + pointsA = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [imath.V3f( x ) for x in range( 0, 3 )] ) ) + pointsB = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [imath.V3f( x ) for x in range( 5, 9 )] ) ) mergedPoints = IECoreScene.PointsAlgo.mergePoints( [pointsA, pointsB] ) self.assertEqual( mergedPoints.numPoints, 3 + 4 ) - self.assertEqual( mergedPoints["P"].data[0], IECore.V3f( 0 ) ) - self.assertEqual( mergedPoints["P"].data[1], IECore.V3f( 1 ) ) - self.assertEqual( mergedPoints["P"].data[2], IECore.V3f( 2 ) ) + self.assertEqual( mergedPoints["P"].data[0], imath.V3f( 0 ) ) + self.assertEqual( mergedPoints["P"].data[1], imath.V3f( 1 ) ) + self.assertEqual( mergedPoints["P"].data[2], imath.V3f( 2 ) ) - self.assertEqual( mergedPoints["P"].data[3], IECore.V3f( 5 ) ) - self.assertEqual( mergedPoints["P"].data[4], IECore.V3f( 6 ) ) - self.assertEqual( mergedPoints["P"].data[5], IECore.V3f( 7 ) ) - self.assertEqual( mergedPoints["P"].data[6], IECore.V3f( 8 ) ) + self.assertEqual( mergedPoints["P"].data[3], imath.V3f( 5 ) ) + self.assertEqual( mergedPoints["P"].data[4], imath.V3f( 6 ) ) + self.assertEqual( mergedPoints["P"].data[5], imath.V3f( 7 ) ) + self.assertEqual( mergedPoints["P"].data[6], imath.V3f( 8 ) ) def testCanMergeTwoPointsPrimitivesWithConstantPrimvars( self ) : - pointsA = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [IECore.V3f( x ) for x in range( 2 )] ) ) - pointsB = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [IECore.V3f( x ) for x in range( 2 )] ) ) + pointsA = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [imath.V3f( x ) for x in range( 2 )] ) ) + pointsB = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [imath.V3f( x ) for x in range( 2 )] ) ) pointsA["foo"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.FloatData( 0.1 ) ) pointsB["bar"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.FloatData( 0.2 ) ) @@ -441,8 +442,8 @@ def testCanMergeTwoPointsPrimitivesWithConstantPrimvars( self ) : self.assertEqual( mergedPoints["bar"], IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.FloatData( 0.2 ) ) ) def testFirstConstantPrimvarIsTaken( self ) : - pointsA = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [IECore.V3f( x ) for x in range( 2 )] ) ) - pointsB = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [IECore.V3f( x ) for x in range( 2 )] ) ) + pointsA = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [imath.V3f( x ) for x in range( 2 )] ) ) + pointsB = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [imath.V3f( x ) for x in range( 2 )] ) ) pointsA["foo"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.FloatData( 0.5 ) ) pointsB["foo"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.FloatData( 0.6 ) ) @@ -452,8 +453,8 @@ def testFirstConstantPrimvarIsTaken( self ) : self.assertEqual( mergedPoints["foo"], IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.FloatData( 0.5 ) ) ) def testRaisesExceptionIfSamePrimvarHasDifferentInterpolation( self ) : - pointsA = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [IECore.V3f( x ) for x in range( 2 )] ) ) - pointsB = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [IECore.V3f( x ) for x in range( 2 )] ) ) + pointsA = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [imath.V3f( x ) for x in range( 2 )] ) ) + pointsB = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [imath.V3f( x ) for x in range( 2 )] ) ) # constant then vertex) pointsA["foo"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.FloatData( 0.5 ) ) @@ -468,8 +469,8 @@ def testRaisesExceptionIfSamePrimvarHasDifferentInterpolation( self ) : self.assertRaises( RuntimeError, lambda : IECoreScene.PointsAlgo.mergePoints( [pointsA, pointsB] ) ) def testMissingPrimvarIsExpanedToDefaultValue( self ) : - pointsA = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [IECore.V3f( x ) for x in range( 0, 4 )] ) ) - pointsB = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [IECore.V3f( x ) for x in range( 0, 4 )] ) ) + pointsA = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [imath.V3f( x ) for x in range( 0, 4 )] ) ) + pointsB = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [imath.V3f( x ) for x in range( 0, 4 )] ) ) pointsA["foo"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.IntVectorData( [0, 1, 2, 3] ) ) @@ -488,8 +489,8 @@ def testMissingPrimvarIsExpanedToDefaultValue( self ) : self.assertEqual( mergedPoints["foo"].data[7], 0 ) def testConvertsTypesIfPossible( self ) : - pointsA = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [IECore.V3f( x ) for x in range( 0, 4 )] ) ) - pointsB = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [IECore.V3f( x ) for x in range( 0, 4 )] ) ) + pointsA = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [imath.V3f( x ) for x in range( 0, 4 )] ) ) + pointsB = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [imath.V3f( x ) for x in range( 0, 4 )] ) ) pointsA["foo"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.IntVectorData( [4, 5, 6, 7] ) ) pointsB["foo"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.FloatVectorData( [0, 1, 2, 3] ) ) @@ -512,8 +513,8 @@ def testConvertsTypesIfPossible( self ) : self.assertEqual( mergedPoints["foo"].data[7], 3 ) def testRaisesExceptionIfTypesAreIncompatible( self ) : - pointsA = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [IECore.V3f( x ) for x in range( 0, 4 )] ) ) - pointsB = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [IECore.V3f( x ) for x in range( 0, 4 )] ) ) + pointsA = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [imath.V3f( x ) for x in range( 0, 4 )] ) ) + pointsB = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [imath.V3f( x ) for x in range( 0, 4 )] ) ) pointsA["foo"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.IntVectorData( [4, 5, 6, 7] ) ) pointsB["foo"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.StringVectorData( ["a", "b", "c", "d"] ) ) diff --git a/test/IECoreScene/PointsMotionOpTest.py b/test/IECoreScene/PointsMotionOpTest.py index dafd89a21a..85e3d24b4e 100644 --- a/test/IECoreScene/PointsMotionOpTest.py +++ b/test/IECoreScene/PointsMotionOpTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene @@ -41,14 +42,14 @@ class PointsMotionOpTest( unittest.TestCase ) : def _buildPoints( self, time ): p = IECoreScene.PointsPrimitive( 5 ) - p[ "P" ] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f(time*1), IECore.V3f(time*2), IECore.V3f(time*3), IECore.V3f(time*4), IECore.V3f(time*5) ] ) ) + p[ "P" ] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f(time*1), imath.V3f(time*2), imath.V3f(time*3), imath.V3f(time*4), imath.V3f(time*5) ] ) ) p[ "id" ] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.IntVectorData( [ 1, 2, 3, 4, 5 ] ) ) p[ "float" ] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Varying, IECore.FloatVectorData( [ time*1, time*2, time*3, time*4, time*5 ] ) ) - p[ "vec3" ] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f(time*2), IECore.V3f(time*3), IECore.V3f(time*4), IECore.V3f(time*5), IECore.V3f(time*6) ] ) ) - p[ "vec2" ] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V2fVectorData( [ IECore.V2f(time*2), IECore.V2f(time*3), IECore.V2f(time*4), IECore.V2f(time*5), IECore.V2f(time*6) ] ) ) - p[ "C" ] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.Color3fVectorData( [ IECore.Color3f(1), IECore.Color3f(2), IECore.Color3f(4), IECore.Color3f(5), IECore.Color3f(6) ] ) ) - p[ "C2" ] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.Color4fVectorData( [ IECore.Color4f(1), IECore.Color4f(2), IECore.Color4f(4), IECore.Color4f(5), IECore.Color4f(6) ] ) ) - p[ "G" ] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ IECore.V3f(time) ] ) ) + p[ "vec3" ] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f(time*2), imath.V3f(time*3), imath.V3f(time*4), imath.V3f(time*5), imath.V3f(time*6) ] ) ) + p[ "vec2" ] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V2fVectorData( [ imath.V2f(time*2), imath.V2f(time*3), imath.V2f(time*4), imath.V2f(time*5), imath.V2f(time*6) ] ) ) + p[ "C" ] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.Color3fVectorData( [ imath.Color3f(1), imath.Color3f(2), imath.Color3f(4), imath.Color3f(5), imath.Color3f(6) ] ) ) + p[ "C2" ] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.Color4fVectorData( [ imath.Color4f(1), imath.Color4f(2), imath.Color4f(4), imath.Color4f(5), imath.Color4f(6) ] ) ) + p[ "G" ] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.V3fVectorData( [ imath.V3f(time) ] ) ) p[ "c" ] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, IECore.FloatData( time ) ) return p @@ -72,10 +73,10 @@ def testPrimvarCopy( self ) : self.assertEqual( result[2], p2 ) self.assertNotEqual( result[1], p2 ) - p1[ "P" ].data[3] = IECore.V3f(1,2,3) - self.assertEqual( p1["P"].data[3], IECore.V3f(1,2,3) ) + p1[ "P" ].data[3] = imath.V3f(1,2,3) + self.assertEqual( p1["P"].data[3], imath.V3f(1,2,3) ) # proves that destroying the original input value, keeps the output untouched. - self.assertEqual( result[1]["P"].data[3], IECore.V3f(4) ) + self.assertEqual( result[1]["P"].data[3], imath.V3f(4) ) def testInvalidInputParams( self ): @@ -184,11 +185,11 @@ def testMissingSnapshots( self ): self.assertEqual( result[1]["id"].data, result[4]["id"].data ) self.assertEqual( result[1]["id"].data, result[5]["id"].data ) # checking if unmasked prim var was filled with closest available value - self.assertEqual( result[1]["P"].data, IECore.V3fVectorData( [ IECore.V3f(1*1), IECore.V3f(1*2), IECore.V3f(1*3), IECore.V3f(1*4), IECore.V3f(1*5), IECore.V3f(2*1), IECore.V3f(3*2), IECore.V3f(4*4), IECore.V3f(5*5) ] ) ) - self.assertEqual( result[3]["P"].data, IECore.V3fVectorData( [ IECore.V3f(1*1), IECore.V3f(2*2), IECore.V3f(3*3), IECore.V3f(3*4), IECore.V3f(3*5), IECore.V3f(3*1), IECore.V3f(3*2), IECore.V3f(4*4), IECore.V3f(5*5) ] ) ) - self.assertEqual( result[5]["P"].data, IECore.V3fVectorData( [ IECore.V3f(1*1), IECore.V3f(2*2), IECore.V3f(5*3), IECore.V3f(3*4), IECore.V3f(4*5), IECore.V3f(5*1), IECore.V3f(5*2), IECore.V3f(5*4), IECore.V3f(5*5) ] ) ) + self.assertEqual( result[1]["P"].data, IECore.V3fVectorData( [ imath.V3f(1*1), imath.V3f(1*2), imath.V3f(1*3), imath.V3f(1*4), imath.V3f(1*5), imath.V3f(2*1), imath.V3f(3*2), imath.V3f(4*4), imath.V3f(5*5) ] ) ) + self.assertEqual( result[3]["P"].data, IECore.V3fVectorData( [ imath.V3f(1*1), imath.V3f(2*2), imath.V3f(3*3), imath.V3f(3*4), imath.V3f(3*5), imath.V3f(3*1), imath.V3f(3*2), imath.V3f(4*4), imath.V3f(5*5) ] ) ) + self.assertEqual( result[5]["P"].data, IECore.V3fVectorData( [ imath.V3f(1*1), imath.V3f(2*2), imath.V3f(5*3), imath.V3f(3*4), imath.V3f(4*5), imath.V3f(5*1), imath.V3f(5*2), imath.V3f(5*4), imath.V3f(5*5) ] ) ) # checkin if masked prim var was filled with zero - self.assertEqual( result[3]["vec3"].data, IECore.V3fVectorData( [ IECore.V3f(0), IECore.V3f(0), IECore.V3f(3*4), IECore.V3f(3*5), IECore.V3f(3*6), IECore.V3f(3*2), IECore.V3f(3*3), IECore.V3f(0), IECore.V3f(0) ] ) ) + self.assertEqual( result[3]["vec3"].data, IECore.V3fVectorData( [ imath.V3f(0), imath.V3f(0), imath.V3f(3*4), imath.V3f(3*5), imath.V3f(3*6), imath.V3f(3*2), imath.V3f(3*3), imath.V3f(0), imath.V3f(0) ] ) ) if __name__ == "__main__": unittest.main() diff --git a/test/IECoreScene/PointsPrimitive.py b/test/IECoreScene/PointsPrimitive.py index 6325ae14a9..f0a17595bd 100644 --- a/test/IECoreScene/PointsPrimitive.py +++ b/test/IECoreScene/PointsPrimitive.py @@ -34,6 +34,7 @@ import math import unittest +import imath import IECore import IECoreScene @@ -107,7 +108,7 @@ def testConstructors( self ) : self.assertEqual( p.variableSize( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying ), 20 ) self.assertEqual( len( p ), 0 ) - p = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ IECore.V3f( 1 ) ] ) ) + p = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ imath.V3f( 1 ) ] ) ) self.assertEqual( p.numPoints, 1 ) self.assertEqual( p.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Constant ), 1 ) self.assertEqual( p.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ), 1 ) @@ -116,10 +117,10 @@ def testConstructors( self ) : self.assertEqual( p.variableSize( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying ), 1 ) self.assertEqual( len( p ), 1 ) self.assert_( "P" in p ) - self.assertEqual( p["P"].data, IECore.V3fVectorData( [ IECore.V3f( 1 ) ], IECore.GeometricData.Interpretation.Point ) ) + self.assertEqual( p["P"].data, IECore.V3fVectorData( [ imath.V3f( 1 ) ], IECore.GeometricData.Interpretation.Point ) ) self.assertEqual( p["P"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) - p = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ IECore.V3f( 1 ) ] ), IECore.FloatVectorData( [ 1 ] ) ) + p = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ imath.V3f( 1 ) ] ), IECore.FloatVectorData( [ 1 ] ) ) self.assertEqual( p.numPoints, 1 ) self.assertEqual( p.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Constant ), 1 ) self.assertEqual( p.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ), 1 ) @@ -129,7 +130,7 @@ def testConstructors( self ) : self.assertEqual( len( p ), 2 ) self.assert_( "P" in p ) self.assert_( "r" in p ) - self.assertEqual( p["P"].data, IECore.V3fVectorData( [ IECore.V3f( 1 ) ], IECore.GeometricData.Interpretation.Point ) ) + self.assertEqual( p["P"].data, IECore.V3fVectorData( [ imath.V3f( 1 ) ], IECore.GeometricData.Interpretation.Point ) ) self.assertEqual( p["P"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) self.assertEqual( p["r"].data, IECore.FloatVectorData( [ 1 ] ) ) self.assertEqual( p["r"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex ) @@ -159,19 +160,19 @@ def testHash( self ) : def testBound( self ) : p = IECoreScene.PointsPrimitive( 2 ) - self.assertEqual( p.bound(), IECore.Box3f() ) + self.assertEqual( p.bound(), imath.Box3f() ) p["P"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, - IECore.V3fVectorData( [ IECore.V3f( 1, 2, 3 ), IECore.V3f( 12, 13, 14 ) ] ) + IECore.V3fVectorData( [ imath.V3f( 1, 2, 3 ), imath.V3f( 12, 13, 14 ) ] ) ) # when no width is specified, it defaults to 1 self.assertEqual( p.bound(), - IECore.Box3f( - IECore.V3f( 1, 2, 3 ) - IECore.V3f( 1 ) / 2.0, - IECore.V3f( 12, 13, 14 ) + IECore.V3f( 1 ) / 2.0 + imath.Box3f( + imath.V3f( 1, 2, 3 ) - imath.V3f( 1 ) / 2.0, + imath.V3f( 12, 13, 14 ) + imath.V3f( 1 ) / 2.0 ) ) @@ -180,9 +181,9 @@ def testBound( self ) : self.assertEqual( p.bound(), - IECore.Box3f( - IECore.V3f( 1, 2, 3 ) - IECore.V3f( 2 ) / 2.0, - IECore.V3f( 12, 13, 14 ) + IECore.V3f( 2 ) / 2.0 + imath.Box3f( + imath.V3f( 1, 2, 3 ) - imath.V3f( 2 ) / 2.0, + imath.V3f( 12, 13, 14 ) + imath.V3f( 2 ) / 2.0 ) ) @@ -192,9 +193,9 @@ def testBound( self ) : self.assertEqual( p.bound(), - IECore.Box3f( - IECore.V3f( 1, 2, 3 ) - IECore.V3f( 2 * 2 ) / 2.0, - IECore.V3f( 12, 13, 14 ) + IECore.V3f( 2 * 4 ) / 2.0 + imath.Box3f( + imath.V3f( 1, 2, 3 ) - imath.V3f( 2 * 2 ) / 2.0, + imath.V3f( 12, 13, 14 ) + imath.V3f( 2 * 4 ) / 2.0 ) ) @@ -206,9 +207,9 @@ def testBound( self ) : self.assertEqual( p.bound(), - IECore.Box3f( - IECore.V3f( 1, 2, 3 ) - IECore.V3f( 1 ) / 2.0, - IECore.V3f( 12, 13, 14 ) + IECore.V3f( 1 ) / 2.0 + imath.Box3f( + imath.V3f( 1, 2, 3 ) - imath.V3f( 1 ) / 2.0, + imath.V3f( 12, 13, 14 ) + imath.V3f( 1 ) / 2.0 ) ) @@ -220,9 +221,9 @@ def testBound( self ) : self.assertEqual( p.bound(), - IECore.Box3f( - IECore.V3f( 1, 2, 3 ) - IECore.V3f( diagonal ) / 2.0, - IECore.V3f( 12, 13, 14 ) + IECore.V3f( diagonal ) / 2.0 + imath.Box3f( + imath.V3f( 1, 2, 3 ) - imath.V3f( diagonal ) / 2.0, + imath.V3f( 12, 13, 14 ) + imath.V3f( diagonal ) / 2.0 ) ) @@ -232,9 +233,9 @@ def testBound( self ) : self.assertEqual( p.bound(), - IECore.Box3f( - IECore.V3f( 1, 2, 3 ) - IECore.V3f( 2 * diagonal ) / 2.0, - IECore.V3f( 12, 13, 14 ) + IECore.V3f( 2 * diagonal ) / 2.0 + imath.Box3f( + imath.V3f( 1, 2, 3 ) - imath.V3f( 2 * diagonal ) / 2.0, + imath.V3f( 12, 13, 14 ) + imath.V3f( 2 * diagonal ) / 2.0 ) ) @@ -244,9 +245,9 @@ def testBound( self ) : self.assertEqual( p.bound(), - IECore.Box3f( - IECore.V3f( 1, 2, 3 ) - IECore.V3f( 2 * 2 * diagonal ) / 2.0, - IECore.V3f( 12, 13, 14 ) + IECore.V3f( 2 * 4 * diagonal ) / 2.0 + imath.Box3f( + imath.V3f( 1, 2, 3 ) - imath.V3f( 2 * 2 * diagonal ) / 2.0, + imath.V3f( 12, 13, 14 ) + imath.V3f( 2 * 4 * diagonal ) / 2.0 ) ) diff --git a/test/IECoreScene/PointsPrimitiveEvaluatorTest.py b/test/IECoreScene/PointsPrimitiveEvaluatorTest.py index 5936c331c7..0134258847 100644 --- a/test/IECoreScene/PointsPrimitiveEvaluatorTest.py +++ b/test/IECoreScene/PointsPrimitiveEvaluatorTest.py @@ -35,6 +35,7 @@ from __future__ import with_statement import unittest +import imath import IECore import IECoreScene @@ -44,7 +45,7 @@ class PointsPrimitiveEvaluatorTest( unittest.TestCase ) : def testCreate( self ) : p = IECoreScene.PointsPrimitive( 5 ) - p["P"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f( x ) for x in range( 0, 5 ) ] ) ) + p["P"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f( x ) for x in range( 0, 5 ) ] ) ) e = IECoreScene.PrimitiveEvaluator.create( p ) self.failUnless( isinstance( e, IECoreScene.PointsPrimitiveEvaluator ) ) @@ -53,7 +54,7 @@ def testCreate( self ) : def testConstruct( self ) : p = IECoreScene.PointsPrimitive( 5 ) - p["P"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f( x ) for x in range( 0, 5 ) ] ) ) + p["P"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f( x ) for x in range( 0, 5 ) ] ) ) e = IECoreScene.PointsPrimitiveEvaluator( p ) self.failUnless( isinstance( e, IECoreScene.PointsPrimitiveEvaluator ) ) @@ -62,18 +63,18 @@ def testConstruct( self ) : def testClosestPoint( self ) : p = IECoreScene.PointsPrimitive( 5 ) - p["P"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f( x, 0, 0 ) for x in range( 0, 5 ) ] ) ) - p["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.Color3fVectorData( [ IECore.Color3f( r, 0, 0 ) for r in range( 5, 10 ) ] ) ) + p["P"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f( x, 0, 0 ) for x in range( 0, 5 ) ] ) ) + p["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.Color3fVectorData( [ imath.Color3f( r, 0, 0 ) for r in range( 5, 10 ) ] ) ) p["names"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.StringVectorData( [ "a", "b", "c", "d", "e" ] ) ) e = IECoreScene.PointsPrimitiveEvaluator( p ) r = e.createResult() - s = e.closestPoint( IECore.V3f( -1, -1, 0 ), r ) + s = e.closestPoint( imath.V3f( -1, -1, 0 ), r ) self.assertEqual( s, True ) self.assertEqual( r.pointIndex(), 0 ) - self.assertEqual( r.point(), IECore.V3f( 0 ) ) - self.assertEqual( r.colorPrimVar( p["Cs"] ), IECore.Color3f( 5, 0, 0 ) ) + self.assertEqual( r.point(), imath.V3f( 0 ) ) + self.assertEqual( r.colorPrimVar( p["Cs"] ), imath.Color3f( 5, 0, 0 ) ) self.assertEqual( r.stringPrimVar( p["names"] ), "a" ) if __name__ == "__main__": diff --git a/test/IECoreScene/PrimitiveTest.py b/test/IECoreScene/PrimitiveTest.py index d8cdfd2107..440d89e138 100644 --- a/test/IECoreScene/PrimitiveTest.py +++ b/test/IECoreScene/PrimitiveTest.py @@ -34,6 +34,7 @@ import os import unittest +import imath import IECore import IECoreScene @@ -52,7 +53,7 @@ def test( self ) : self.assertEqual( m.inferInterpolation( 10 ), IECoreScene.PrimitiveVariable.Interpolation.Invalid ) self.assertEqual( m.inferInterpolation( IECore.FloatData( 1 ) ), IECoreScene.PrimitiveVariable.Interpolation.Constant ) - self.assertEqual( m.inferInterpolation( IECore.V3fVectorData( [ IECore.V3f( 1 ) ] ) ), IECoreScene.PrimitiveVariable.Interpolation.Constant ) + self.assertEqual( m.inferInterpolation( IECore.V3fVectorData( [ imath.V3f( 1 ) ] ) ), IECoreScene.PrimitiveVariable.Interpolation.Constant ) self.assertEqual( m.inferInterpolation( IECore.FloatVectorData( [ 2, 3 ] ) ), IECoreScene.PrimitiveVariable.Interpolation.Uniform ) self.assertEqual( m.inferInterpolation( IECore.IntVectorData( [ 1, 2, 3, 4 ] ) ), IECoreScene.PrimitiveVariable.Interpolation.Vertex ) self.assertEqual( m.inferInterpolation( IECore.IntVectorData( [ 1, 2, 3, 4, 5, 6 ] ) ), IECoreScene.PrimitiveVariable.Interpolation.FaceVarying ) @@ -72,7 +73,7 @@ def testCopyFrom( self ) : def testLoad( self ) : m = IECoreScene.MeshPrimitive( IECore.IntVectorData( [ 3, 3 ] ), IECore.IntVectorData( [ 0, 1, 2, 2, 1, 3 ] ) ) - m["P"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f(1), IECore.V3f(2), IECore.V3f(3), IECore.V3f(4) ] ) ) + m["P"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f(1), imath.V3f(2), imath.V3f(3), imath.V3f(4) ] ) ) m["a"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, IECore.FloatVectorData( [ 1, 2 ] ), IECore.IntVectorData( [ 1, 0, 1, 0, 1, 0 ] ) ) self.assertTrue( m.arePrimitiveVariablesValid() ) @@ -130,8 +131,8 @@ def testPrimitiveVariableDataValidity( self ) : self.assert_( not m.isPrimitiveVariableValid( IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.FloatVectorData( [ 1, 2, 3, 4 ] ) ) ) ) # data size (not base size) matches interpolation - self.assert_( m.isPrimitiveVariableValid( IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f(1), IECore.V3f(2), IECore.V3f(3) ] ) ) ) ) - self.assert_( not m.isPrimitiveVariableValid( IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f(1), IECore.V3f(2), IECore.V3f(3), IECore.V3f(4) ] ) ) ) ) + self.assert_( m.isPrimitiveVariableValid( IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f(1), imath.V3f(2), imath.V3f(3) ] ) ) ) ) + self.assert_( not m.isPrimitiveVariableValid( IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f(1), imath.V3f(2), imath.V3f(3), imath.V3f(4) ] ) ) ) ) def testPrimitiveVariableIndicesValidity( self ) : diff --git a/test/IECoreScene/ReorderSmoothSkinningInfluencesOpTest.py b/test/IECoreScene/ReorderSmoothSkinningInfluencesOpTest.py index b49b0c78b9..ca8b9905fc 100644 --- a/test/IECoreScene/ReorderSmoothSkinningInfluencesOpTest.py +++ b/test/IECoreScene/ReorderSmoothSkinningInfluencesOpTest.py @@ -35,6 +35,7 @@ import math import unittest import random +import imath import IECore import IECoreScene @@ -54,7 +55,7 @@ def createSSD( self, names, poses, indices ) : def original( self ) : names = IECore.StringVectorData( [ 'jointA', 'jointB', 'jointC' ] ) - poses = IECore.M44fVectorData( [IECore.M44f(1),IECore.M44f(2),IECore.M44f(3)] ) + poses = IECore.M44fVectorData( [imath.M44f(1),imath.M44f(2),imath.M44f(3)] ) indices = IECore.IntVectorData( [0, 1, 0, 1, 2, 1] ) return self.createSSD( names, poses, indices ) @@ -62,7 +63,7 @@ def original( self ) : def reordered( self ) : names = IECore.StringVectorData( [ 'jointB', 'jointC', 'jointA' ] ) - poses = IECore.M44fVectorData( [IECore.M44f(2),IECore.M44f(3),IECore.M44f(1)] ) + poses = IECore.M44fVectorData( [imath.M44f(2),imath.M44f(3),imath.M44f(1)] ) indices = IECore.IntVectorData( [2, 0, 2, 0, 1, 0] ) return self.createSSD( names, poses, indices ) diff --git a/test/IECoreScene/SWAReaderTest.py b/test/IECoreScene/SWAReaderTest.py index 72cb0bc653..f390a9b23b 100644 --- a/test/IECoreScene/SWAReaderTest.py +++ b/test/IECoreScene/SWAReaderTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene @@ -83,9 +84,9 @@ def testReading( self ) : self.failUnless( isinstance( o["treeName"].data, IECore.StringVectorData ) ) self.assertEqual( o["treeName"].data, IECore.StringVectorData( [ "Acacia_RT", "BroadLeaf_HighDetail" ] ) ) - self.assertEqual( o["P"].data[0], IECore.V3f( 3750.05, 1556.86, -2149.22 ) ) - self.assertEqual( o["yAxis"].data[0], IECore.V3f( 0.0176831, 0.998519, 0.0514542 ) ) - self.assertEqual( o["xAxis"].data[0], IECore.V3f( 0.0179192, -0.0517705, 0.998498 ) ) + self.assertEqual( o["P"].data[0], imath.V3f( 3750.05, 1556.86, -2149.22 ) ) + self.assertEqual( o["yAxis"].data[0], imath.V3f( 0.0176831, 0.998519, 0.0514542 ) ) + self.assertEqual( o["xAxis"].data[0], imath.V3f( 0.0179192, -0.0517705, 0.998498 ) ) self.assertEqual( o["zAxis"].data[0], o["xAxis"].data[0].cross( o["yAxis"].data[0] ) ) self.assertAlmostEqual( o["scale"].data[0], 6.4516, 6 ) self.assertAlmostEqual( o["scale"].data[1], 6.7, 6 ) diff --git a/test/IECoreScene/SceneCacheTest.py b/test/IECoreScene/SceneCacheTest.py index ad310196d5..b6f5aacbd8 100644 --- a/test/IECoreScene/SceneCacheTest.py +++ b/test/IECoreScene/SceneCacheTest.py @@ -36,6 +36,7 @@ import sys import math import unittest +import imath import IECore import IECoreScene @@ -86,7 +87,7 @@ def testKnownStaticHierarchy( self ) : self.assertEqual( t.hasObject(), False ) self.assertEqual( m.childNames(), [ "t" ] ) - t.writeTransform( IECore.M44dData(IECore.M44d.createTranslated(IECore.V3d( 1, 0, 0 ))), 1.0 ) + t.writeTransform( IECore.M44dData(imath.M44d().translate(imath.V3d( 1, 0, 0 ))), 1.0 ) self.assertEqual( t.hasObject(), False ) t.writeAttribute( "wuh", IECore.BoolData( True ), 1.0 ) @@ -115,11 +116,11 @@ def testKnownStaticHierarchy( self ) : self.assertEqual( m.hasChild("t"), True ) self.assertEqual( m.childNames(), [ "t" ] ) self.assertEqual( m.numBoundSamples(), 1 ) - self.assertEqual( m.readBoundAtSample(0), IECore.Box3d( IECore.V3d( 0, -1, -1 ), IECore.V3d( 2, 1, 1 ) ) ) - self.assertEqual( m.readBound(0.0), IECore.Box3d( IECore.V3d( 0, -1, -1 ), IECore.V3d( 2, 1, 1 ) ) ) + self.assertEqual( m.readBoundAtSample(0), imath.Box3d( imath.V3d( 0, -1, -1 ), imath.V3d( 2, 1, 1 ) ) ) + self.assertEqual( m.readBound(0.0), imath.Box3d( imath.V3d( 0, -1, -1 ), imath.V3d( 2, 1, 1 ) ) ) self.assertEqual( m.numTransformSamples(), 1 ) - self.assertEqual( m.readTransformAtSample(0), IECore.M44dData(IECore.M44d()) ) - self.assertEqual( m.readTransform(0.0), IECore.M44dData(IECore.M44d()) ) + self.assertEqual( m.readTransformAtSample(0), IECore.M44dData(imath.M44d()) ) + self.assertEqual( m.readTransform(0.0), IECore.M44dData(imath.M44d()) ) self.assertEqual( m.hasObject(), False ) self.assertEqual( m.readAttribute( "w", 0 ), IECore.BoolData( True ) ) @@ -132,8 +133,8 @@ def testKnownStaticHierarchy( self ) : self.assertEqual( t.hasChild("t"), False ) self.assertEqual( t.hasChild("s"), True ) self.assertEqual( t.childNames(), [ "s" ] ) - self.assertEqual( t.readBound(0.0), IECore.Box3d( IECore.V3d( -1, -1, -1 ), IECore.V3d( 1, 1, 1 ) ) ) - self.assertEqual( t.readTransform(0.0), IECore.M44dData(IECore.M44d.createTranslated( IECore.V3d( 1, 0, 0 ) )) ) + self.assertEqual( t.readBound(0.0), imath.Box3d( imath.V3d( -1, -1, -1 ), imath.V3d( 1, 1, 1 ) ) ) + self.assertEqual( t.readTransform(0.0), IECore.M44dData(imath.M44d().translate( imath.V3d( 1, 0, 0 ) )) ) self.assertEqual( t.hasObject(), False ) self.assertEqual( t.readAttribute( "wuh", 0 ), IECore.BoolData( True ) ) @@ -144,8 +145,8 @@ def testKnownStaticHierarchy( self ) : self.assertEqual( s.name(), "s" ) self.assertEqual( s.hasObject(), True ) self.assertEqual( s.childNames(), [] ) - self.assertEqual( s.readBound(0.0), IECore.Box3d( IECore.V3d( -1, -1, -1 ), IECore.V3d( 1, 1, 1 ) ) ) - self.assertEqual( s.readTransform(0.0), IECore.M44dData(IECore.M44d.createTranslated( IECore.V3d( 0, 0, 0 ) )) ) + self.assertEqual( s.readBound(0.0), imath.Box3d( imath.V3d( -1, -1, -1 ), imath.V3d( 1, 1, 1 ) ) ) + self.assertEqual( s.readTransform(0.0), IECore.M44dData(imath.M44d().translate( imath.V3d( 0, 0, 0 ) )) ) self.assertEqual( s.hasObject(), True ) self.assertEqual( s.readObject(0.0), IECoreScene.SpherePrimitive( 1 ) ) @@ -166,18 +167,18 @@ def testAnimatedAttributes( self ) : @staticmethod def compareBBox( box1, box2 ): - errorTolerance = IECore.V3d(1e-5, 1e-5, 1e-5) - boxTmp = IECore.Box3d( box1.min - errorTolerance, box1.max + errorTolerance ) - if not boxTmp.contains( box2 ): + errorTolerance = imath.V3d(1e-5, 1e-5, 1e-5) + boxTmp = imath.Box3d( box1.min() - errorTolerance, box1.max() + errorTolerance ) + if not IECore.BoxAlgo.contains( boxTmp, box2 ): return False - boxTmp = IECore.Box3d( box2.min - errorTolerance, box2.max + errorTolerance ) - if not boxTmp.contains( box1 ): + boxTmp = imath.Box3d( box2.min() - errorTolerance, box2.max() + errorTolerance ) + if not IECore.BoxAlgo.contains( boxTmp, box1 ): return False return True def testRandomStaticHierarchy( self ) : - r = IECore.Rand48() + r = imath.Rand48() def writeWalk( m ) : @@ -186,7 +187,8 @@ def writeWalk( m ) : m.writeObject( IECoreScene.SpherePrimitive( r.nextf( 1.0, 4.0 ) ), 0.0 ) if r.nextf( 0.0, 1.0 ) < 0.5 : - m.writeTransform( IECore.M44dData(IECore.M44d.createTranslated( r.nextV3d() )), 0.0 ) + t = imath.V3d( r.nextf(), r.nextf(), r.nextf() ) + m.writeTransform( IECore.M44dData( imath.M44d().translate( t ) ), 0.0 ) thisDepth = int( r.nextf( 1, 4 ) ) if thisDepth > len(m.path()) : @@ -201,14 +203,14 @@ def writeWalk( m ) : def readWalk( m, parentSpaceBound ) : - localSpaceBound = IECore.Box3d() + localSpaceBound = imath.Box3d() for childName in m.childNames() : readWalk( m.child( childName ), localSpaceBound ) if m.hasObject() : o = m.readObject(0.0) ob = o.bound() - ob = IECore.Box3d( IECore.V3d( *ob.min ), IECore.V3d( *ob.max ) ) + ob = imath.Box3d( imath.V3d( *ob.min() ), imath.V3d( *ob.max() ) ) localSpaceBound.extendBy( ob ) fileBound = m.readBound(0.0) @@ -216,11 +218,11 @@ def readWalk( m, parentSpaceBound ) : # the two bounding boxes should be pretty tightly close! self.failUnless( SceneCacheTest.compareBBox( localSpaceBound, fileBound ) ) - transformedBound = localSpaceBound.transform( m.readTransformAsMatrix(0.0) ) + transformedBound = localSpaceBound * m.readTransformAsMatrix(0.0) parentSpaceBound.extendBy( transformedBound ) m = IECoreScene.SceneCache( "/tmp/test.scc", IECore.IndexedIO.OpenMode.Read ) - readWalk( m, IECore.Box3d() ) + readWalk( m, imath.Box3d() ) def testMissingReadableChild( self ) : @@ -255,8 +257,8 @@ def testExplicitBoundDilatesImplicitBound( self ) : m = IECoreScene.SceneCache( "/tmp/test.scc", IECore.IndexedIO.OpenMode.Write ) a = m.createChild( "a" ) - a.writeBound( IECore.Box3d( IECore.V3d( -200 ), IECore.V3d( 10 ) ), 0.0 ) - a.writeBound( IECore.Box3d( IECore.V3d( -300 ), IECore.V3d( 10 ) ), 1.0 ) + a.writeBound( imath.Box3d( imath.V3d( -200 ), imath.V3d( 10 ) ), 0.0 ) + a.writeBound( imath.Box3d( imath.V3d( -300 ), imath.V3d( 10 ) ), 1.0 ) a.writeObject( IECoreScene.SpherePrimitive( 0.1 ), 0.0 ) b = a.createChild( "b" ) @@ -268,16 +270,16 @@ def testExplicitBoundDilatesImplicitBound( self ) : m = IECoreScene.SceneCache( "/tmp/test.scc", IECore.IndexedIO.OpenMode.Read ) a = m.child( "a" ) - self.assertEqual( a.readBound(0.0), IECore.Box3d( IECore.V3d( -200 ), IECore.V3d( 100 ) ) ) + self.assertEqual( a.readBound(0.0), imath.Box3d( imath.V3d( -200 ), imath.V3d( 100 ) ) ) # this one should be the union of ( -250, -250, -250 ) ( 10, 10, 10 ) and (-50 -50 -50) (50 50 50) - self.assertEqual( a.readBound(0.5), IECore.Box3d( IECore.V3d( -250 ), IECore.V3d( 50 ) ) ) + self.assertEqual( a.readBound(0.5), imath.Box3d( imath.V3d( -250 ), imath.V3d( 50 ) ) ) - self.assertEqual( a.readBound(1.0), IECore.Box3d( IECore.V3d( -300 ), IECore.V3d( 50 ) ) ) + self.assertEqual( a.readBound(1.0), imath.Box3d( imath.V3d( -300 ), imath.V3d( 50 ) ) ) b = a.child( "b" ) - self.assertEqual( b.readBound(0.0), IECore.Box3d( IECore.V3d( -100 ), IECore.V3d( 100 ) ) ) - self.assertEqual( b.readBound(0.5), IECore.Box3d( IECore.V3d( -50 ), IECore.V3d( 50 ) ) ) + self.assertEqual( b.readBound(0.0), imath.Box3d( imath.V3d( -100 ), imath.V3d( 100 ) ) ) + self.assertEqual( b.readBound(0.5), imath.Box3d( imath.V3d( -50 ), imath.V3d( 50 ) ) ) def testAnimatedBoundPropagation( self ) : @@ -288,43 +290,43 @@ def testAnimatedBoundPropagation( self ) : p1 = m.createChild( "p1" ) a = p1.createChild( "a" ) - a.writeBound( IECore.Box3d( IECore.V3d( -4 ), IECore.V3d( 0 ) ), -2.5 ) - a.writeBound( IECore.Box3d( IECore.V3d( -3 ), IECore.V3d( 0 ) ), -1.5 ) - a.writeBound( IECore.Box3d( IECore.V3d( -2 ), IECore.V3d( 0 ) ), -0.5 ) - a.writeBound( IECore.Box3d( IECore.V3d( -1 ), IECore.V3d( 0 ) ), 0.5 ) + a.writeBound( imath.Box3d( imath.V3d( -4 ), imath.V3d( 0 ) ), -2.5 ) + a.writeBound( imath.Box3d( imath.V3d( -3 ), imath.V3d( 0 ) ), -1.5 ) + a.writeBound( imath.Box3d( imath.V3d( -2 ), imath.V3d( 0 ) ), -0.5 ) + a.writeBound( imath.Box3d( imath.V3d( -1 ), imath.V3d( 0 ) ), 0.5 ) b = a.createChild( "b" ) - b.writeBound( IECore.Box3d( IECore.V3d( 0 ), IECore.V3d( 1 ) ), -1.0 ) - b.writeBound( IECore.Box3d( IECore.V3d( 0 ), IECore.V3d( 2 ) ), 0.0 ) - b.writeBound( IECore.Box3d( IECore.V3d( 0 ), IECore.V3d( 3 ) ), 1.0 ) - b.writeBound( IECore.Box3d( IECore.V3d( 0 ), IECore.V3d( 4 ) ), 2.0 ) + b.writeBound( imath.Box3d( imath.V3d( 0 ), imath.V3d( 1 ) ), -1.0 ) + b.writeBound( imath.Box3d( imath.V3d( 0 ), imath.V3d( 2 ) ), 0.0 ) + b.writeBound( imath.Box3d( imath.V3d( 0 ), imath.V3d( 3 ) ), 1.0 ) + b.writeBound( imath.Box3d( imath.V3d( 0 ), imath.V3d( 4 ) ), 2.0 ) p2 = m.createChild( "p2" ) a = p2.createChild( "a" ) - a.writeBound( IECore.Box3d( IECore.V3d( 0 ), IECore.V3d( 1 ) ), -1.0 ) - a.writeBound( IECore.Box3d( IECore.V3d( 0 ), IECore.V3d( 2 ) ), 0.0 ) - a.writeBound( IECore.Box3d( IECore.V3d( 0 ), IECore.V3d( 3 ) ), 1.0 ) - a.writeBound( IECore.Box3d( IECore.V3d( 0 ), IECore.V3d( 4 ) ), 2.0 ) + a.writeBound( imath.Box3d( imath.V3d( 0 ), imath.V3d( 1 ) ), -1.0 ) + a.writeBound( imath.Box3d( imath.V3d( 0 ), imath.V3d( 2 ) ), 0.0 ) + a.writeBound( imath.Box3d( imath.V3d( 0 ), imath.V3d( 3 ) ), 1.0 ) + a.writeBound( imath.Box3d( imath.V3d( 0 ), imath.V3d( 4 ) ), 2.0 ) b = a.createChild( "b" ) - b.writeBound( IECore.Box3d( IECore.V3d( -4 ), IECore.V3d( 0 ) ), -2.5 ) - b.writeBound( IECore.Box3d( IECore.V3d( -3 ), IECore.V3d( 0 ) ), -1.5 ) - b.writeBound( IECore.Box3d( IECore.V3d( -2 ), IECore.V3d( 0 ) ), -0.5 ) - b.writeBound( IECore.Box3d( IECore.V3d( -1 ), IECore.V3d( 0 ) ), 0.5 ) + b.writeBound( imath.Box3d( imath.V3d( -4 ), imath.V3d( 0 ) ), -2.5 ) + b.writeBound( imath.Box3d( imath.V3d( -3 ), imath.V3d( 0 ) ), -1.5 ) + b.writeBound( imath.Box3d( imath.V3d( -2 ), imath.V3d( 0 ) ), -0.5 ) + b.writeBound( imath.Box3d( imath.V3d( -1 ), imath.V3d( 0 ) ), 0.5 ) # non interleaved with a coincident sample: p3 = m.createChild( "p3" ) a = p3.createChild( "a" ) - a.writeBound( IECore.Box3d( IECore.V3d( -4 ), IECore.V3d( 0 ) ), -2.5 ) - a.writeBound( IECore.Box3d( IECore.V3d( -3 ), IECore.V3d( 0 ) ), -1.5 ) - a.writeBound( IECore.Box3d( IECore.V3d( -2 ), IECore.V3d( 0 ) ), 0 ) + a.writeBound( imath.Box3d( imath.V3d( -4 ), imath.V3d( 0 ) ), -2.5 ) + a.writeBound( imath.Box3d( imath.V3d( -3 ), imath.V3d( 0 ) ), -1.5 ) + a.writeBound( imath.Box3d( imath.V3d( -2 ), imath.V3d( 0 ) ), 0 ) b = p3.createChild( "b" ) - b.writeBound( IECore.Box3d( IECore.V3d( 0 ), IECore.V3d( 1 ) ), 0 ) - b.writeBound( IECore.Box3d( IECore.V3d( 0 ), IECore.V3d( 2 ) ), 1.5 ) - b.writeBound( IECore.Box3d( IECore.V3d( 0 ), IECore.V3d( 3 ) ), 2.5 ) + b.writeBound( imath.Box3d( imath.V3d( 0 ), imath.V3d( 1 ) ), 0 ) + b.writeBound( imath.Box3d( imath.V3d( 0 ), imath.V3d( 2 ) ), 1.5 ) + b.writeBound( imath.Box3d( imath.V3d( 0 ), imath.V3d( 3 ) ), 2.5 ) del m, a, b, p1, p2, p3 @@ -336,21 +338,21 @@ def testAnimatedBoundPropagation( self ) : for t in [-2.5, -1.5, -1, -0.5, 0, 0.5, 1, 2]: self.assertEqual( p1.readBound( t ), p2.readBound( t ) ) - self.assertEqual( p1.readBound( -2.5 ), IECore.Box3d( IECore.V3d( -4 ), IECore.V3d( 1 ) ) ) - self.assertEqual( p1.readBound( -1.5 ), IECore.Box3d( IECore.V3d( -3 ), IECore.V3d( 1 ) ) ) - self.assertEqual( p1.readBound( -1.0 ), IECore.Box3d( IECore.V3d( -2.5 ), IECore.V3d( 1 ) ) ) - self.assertEqual( p1.readBound( -0.5 ), IECore.Box3d( IECore.V3d( -2 ), IECore.V3d( 1.5 ) ) ) - self.assertEqual( p1.readBound( 0.0 ), IECore.Box3d( IECore.V3d( -1.5 ), IECore.V3d( 2 ) ) ) - self.assertEqual( p1.readBound( 0.5 ), IECore.Box3d( IECore.V3d( -1 ), IECore.V3d( 2.5 ) ) ) - self.assertEqual( p1.readBound( 1.0 ), IECore.Box3d( IECore.V3d( -1 ), IECore.V3d( 3 ) ) ) - self.assertEqual( p1.readBound( 2.0 ), IECore.Box3d( IECore.V3d( -1 ), IECore.V3d( 4 ) ) ) + self.assertEqual( p1.readBound( -2.5 ), imath.Box3d( imath.V3d( -4 ), imath.V3d( 1 ) ) ) + self.assertEqual( p1.readBound( -1.5 ), imath.Box3d( imath.V3d( -3 ), imath.V3d( 1 ) ) ) + self.assertEqual( p1.readBound( -1.0 ), imath.Box3d( imath.V3d( -2.5 ), imath.V3d( 1 ) ) ) + self.assertEqual( p1.readBound( -0.5 ), imath.Box3d( imath.V3d( -2 ), imath.V3d( 1.5 ) ) ) + self.assertEqual( p1.readBound( 0.0 ), imath.Box3d( imath.V3d( -1.5 ), imath.V3d( 2 ) ) ) + self.assertEqual( p1.readBound( 0.5 ), imath.Box3d( imath.V3d( -1 ), imath.V3d( 2.5 ) ) ) + self.assertEqual( p1.readBound( 1.0 ), imath.Box3d( imath.V3d( -1 ), imath.V3d( 3 ) ) ) + self.assertEqual( p1.readBound( 2.0 ), imath.Box3d( imath.V3d( -1 ), imath.V3d( 4 ) ) ) - self.assertEqual( p3.readBound( -2.5 ), IECore.Box3d( IECore.V3d( -4 ), IECore.V3d( 1 ) ) ) - self.assertEqual( p3.readBound( -1.5 ), IECore.Box3d( IECore.V3d( -3 ), IECore.V3d( 1 ) ) ) - self.assertEqual( p3.readBound( 0 ), IECore.Box3d( IECore.V3d( -2 ), IECore.V3d( 1 ) ) ) - self.assertEqual( p3.readBound( 1.5 ), IECore.Box3d( IECore.V3d( -2 ), IECore.V3d( 2 ) ) ) - self.assertEqual( p3.readBound( 2.5 ), IECore.Box3d( IECore.V3d( -2 ), IECore.V3d( 3 ) ) ) + self.assertEqual( p3.readBound( -2.5 ), imath.Box3d( imath.V3d( -4 ), imath.V3d( 1 ) ) ) + self.assertEqual( p3.readBound( -1.5 ), imath.Box3d( imath.V3d( -3 ), imath.V3d( 1 ) ) ) + self.assertEqual( p3.readBound( 0 ), imath.Box3d( imath.V3d( -2 ), imath.V3d( 1 ) ) ) + self.assertEqual( p3.readBound( 1.5 ), imath.Box3d( imath.V3d( -2 ), imath.V3d( 2 ) ) ) + self.assertEqual( p3.readBound( 2.5 ), imath.Box3d( imath.V3d( -2 ), imath.V3d( 3 ) ) ) def testExplicitBoundPropagatesToImplicitBound( self ) : @@ -362,36 +364,36 @@ def testExplicitBoundPropagatesToImplicitBound( self ) : a = m.createChild( "a" ) b = a.createChild( "b" ) - b.writeBound( IECore.Box3d( IECore.V3d( -1 ), IECore.V3d( 1 ) ), 0.0 ) + b.writeBound( imath.Box3d( imath.V3d( -1 ), imath.V3d( 1 ) ), 0.0 ) b.writeObject( IECoreScene.SpherePrimitive( 0.1 ), 0.0 ) # This hierarchy has a leaf with a large primitive and a smaller explicit bound. # The primitive's bound should win in this case : c = m.createChild( "c" ) - c.writeBound( IECore.Box3d( IECore.V3d( -1 ), IECore.V3d( 1 ) ), 0.0 ) + c.writeBound( imath.Box3d( imath.V3d( -1 ), imath.V3d( 1 ) ), 0.0 ) d = c.createChild( "d" ) - d.writeBound( IECore.Box3d( IECore.V3d( -2 ), IECore.V3d( 2 ) ), 0.0 ) + d.writeBound( imath.Box3d( imath.V3d( -2 ), imath.V3d( 2 ) ), 0.0 ) d.writeObject( IECoreScene.SpherePrimitive( 100 ), 0.0 ) # destroys reference to the write SceneCache handles to close the file del m, a, b, c, d m = IECoreScene.SceneCache( "/tmp/test.scc", IECore.IndexedIO.OpenMode.Read ) - self.assertEqual( m.readBound(0.0), IECore.Box3d( IECore.V3d( -100 ), IECore.V3d( 100 ) ) ) + self.assertEqual( m.readBound(0.0), imath.Box3d( imath.V3d( -100 ), imath.V3d( 100 ) ) ) a = m.child( "a" ) - self.assertEqual( a.readBound(0.0), IECore.Box3d( IECore.V3d( -1 ), IECore.V3d( 1 ) ) ) + self.assertEqual( a.readBound(0.0), imath.Box3d( imath.V3d( -1 ), imath.V3d( 1 ) ) ) b = a.child( "b" ) - self.assertEqual( b.readBound(0.0), IECore.Box3d( IECore.V3d( -1 ), IECore.V3d( 1 ) ) ) + self.assertEqual( b.readBound(0.0), imath.Box3d( imath.V3d( -1 ), imath.V3d( 1 ) ) ) c = m.child( "c" ) - self.assertEqual( c.readBound(0.0), IECore.Box3d( IECore.V3d( -100 ), IECore.V3d( 100 ) ) ) + self.assertEqual( c.readBound(0.0), imath.Box3d( imath.V3d( -100 ), imath.V3d( 100 ) ) ) d = c.child( "d" ) - self.assertEqual( d.readBound(0.0), IECore.Box3d( IECore.V3d( -100 ), IECore.V3d( 100 ) ) ) + self.assertEqual( d.readBound(0.0), imath.Box3d( imath.V3d( -100 ), imath.V3d( 100 ) ) ) @@ -400,7 +402,7 @@ def testWriteMultiObjects( self ) : sc = IECoreScene.SceneCache( "/tmp/test.scc", IECore.IndexedIO.OpenMode.Write ) t = sc.createChild( "transform" ) - t.writeTransform( IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 1, 0, 0 ) ) ), 0.0 ) + t.writeTransform( IECore.M44dData( imath.M44d().translate( imath.V3d( 1, 0, 0 ) ) ), 0.0 ) s = t.createChild( "shape" ) s.writeObject( IECoreScene.SpherePrimitive( 10 ), 0.0 ) @@ -429,7 +431,7 @@ def testWritingOnFlushedFiles( self ) : # after this, no modification on children should be allowed. self.assertRaises( RuntimeError, b.writeObject, IECoreScene.SpherePrimitive( 100 ), 0.0 ) self.assertRaises( RuntimeError, b.writeAttribute, "test", IECore.IntData( 100 ), 0.0 ) - self.assertRaises( RuntimeError, b.writeBound, IECore.Box3d( IECore.V3d( -1 ), IECore.V3d( 1 ) ), 0.0 ) + self.assertRaises( RuntimeError, b.writeBound, imath.Box3d( imath.V3d( -1 ), imath.V3d( 1 ) ), 0.0 ) self.assertRaises( RuntimeError, b.createChild, "c" ) self.assertRaises( RuntimeError, b.child, "c", IECoreScene.SceneInterface.MissingBehaviour.CreateIfMissing ) @@ -442,13 +444,13 @@ def testStoredScene( self ): self.assertEqual( m.boundSampleTime(2), 2.0 ) self.assertEqual( m.boundSampleTime(3), 3.0 ) self.assertTrue( m.hasBound() ) - self.failUnless( SceneCacheTest.compareBBox( m.readBoundAtSample(0), IECore.Box3d( IECore.V3d( -1,-1,-1 ), IECore.V3d( 2,2,1 ) ) ) ) - self.failUnless( SceneCacheTest.compareBBox( m.readBound(0), IECore.Box3d( IECore.V3d( -1,-1,-1 ), IECore.V3d( 2,2,1 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( m.readBoundAtSample(0), imath.Box3d( imath.V3d( -1,-1,-1 ), imath.V3d( 2,2,1 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( m.readBound(0), imath.Box3d( imath.V3d( -1,-1,-1 ), imath.V3d( 2,2,1 ) ) ) ) self.assertEqual( m.boundSampleInterval(0), (0,0,0) ) - self.failUnless( SceneCacheTest.compareBBox( m.readBoundAtSample(1), IECore.Box3d( IECore.V3d( -1,-1,-1 ), IECore.V3d( 3,3,1 ) ) ) ) - self.failUnless( SceneCacheTest.compareBBox( m.readBoundAtSample(2), IECore.Box3d( IECore.V3d( -2,-1,-2 ), IECore.V3d( 4,5,2 ) ) ) ) - self.failUnless( SceneCacheTest.compareBBox( m.readBoundAtSample(3), IECore.Box3d( IECore.V3d( -3,-1,-3 ), IECore.V3d( 4,6,3 ) ) ) ) - self.failUnless( SceneCacheTest.compareBBox( m.readBound(3), IECore.Box3d( IECore.V3d( -3,-1,-3 ), IECore.V3d( 4,6,3 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( m.readBoundAtSample(1), imath.Box3d( imath.V3d( -1,-1,-1 ), imath.V3d( 3,3,1 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( m.readBoundAtSample(2), imath.Box3d( imath.V3d( -2,-1,-2 ), imath.V3d( 4,5,2 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( m.readBoundAtSample(3), imath.Box3d( imath.V3d( -3,-1,-3 ), imath.V3d( 4,6,3 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( m.readBound(3), imath.Box3d( imath.V3d( -3,-1,-3 ), imath.V3d( 4,6,3 ) ) ) ) self.assertEqual( m.boundSampleInterval(3), (1.0,2,3) ) self.assertEqual( m.boundSampleInterval(4), (0,3,3) ) @@ -458,12 +460,12 @@ def testStoredScene( self ): self.assertEqual( A.boundSampleTime(0), 0.0 ) self.assertEqual( A.boundSampleTime(1), 1.0 ) self.assertEqual( A.boundSampleTime(2), 2.0 ) - self.failUnless( SceneCacheTest.compareBBox( A.readBoundAtSample(0), IECore.Box3d(IECore.V3d( -1,-1,-1 ), IECore.V3d( 1,1,1 ) ) ) ) - self.failUnless( SceneCacheTest.compareBBox( A.readBoundAtSample(1), IECore.Box3d(IECore.V3d( -1,-1,-1 ), IECore.V3d( 1,1,1 ) ) ) ) - self.failUnless( SceneCacheTest.compareBBox( A.readBoundAtSample(2), IECore.Box3d(IECore.V3d( 0,-1,-1 ), IECore.V3d( 2,1,1 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( A.readBoundAtSample(0), imath.Box3d(imath.V3d( -1,-1,-1 ), imath.V3d( 1,1,1 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( A.readBoundAtSample(1), imath.Box3d(imath.V3d( -1,-1,-1 ), imath.V3d( 1,1,1 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( A.readBoundAtSample(2), imath.Box3d(imath.V3d( 0,-1,-1 ), imath.V3d( 2,1,1 ) ) ) ) a = A.child("a") self.assertEqual( a.numBoundSamples(), 1 ) - self.failUnless( SceneCacheTest.compareBBox( a.readBoundAtSample(0), IECore.Box3d(IECore.V3d( -1 ), IECore.V3d( 1 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( a.readBoundAtSample(0), imath.Box3d(imath.V3d( -1 ), imath.V3d( 1 ) ) ) ) B = m.child("B") self.assertTrue( B.hasBound() ) self.assertEqual( B.numBoundSamples(), 4 ) @@ -471,10 +473,10 @@ def testStoredScene( self ): self.assertEqual( B.boundSampleTime(1), 1.0 ) self.assertEqual( B.boundSampleTime(2), 2.0 ) self.assertEqual( B.boundSampleTime(3), 3.0 ) - self.failUnless( SceneCacheTest.compareBBox( B.readBoundAtSample(0), IECore.Box3d(IECore.V3d( -1,-1,-1 ), IECore.V3d( 1,1,1 ) ) ) ) - self.failUnless( SceneCacheTest.compareBBox( B.readBoundAtSample(1), IECore.Box3d(IECore.V3d( -1,-1,-1 ), IECore.V3d( 1,1,1 ) ) ) ) - self.failUnless( SceneCacheTest.compareBBox( B.readBoundAtSample(2), IECore.Box3d(IECore.V3d( -2,-1,-2 ), IECore.V3d( 2,3,2 ) ) ) ) - self.failUnless( SceneCacheTest.compareBBox( B.readBoundAtSample(3), IECore.Box3d(IECore.V3d( -3,-2,-3 ), IECore.V3d( 3,4,3 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( B.readBoundAtSample(0), imath.Box3d(imath.V3d( -1,-1,-1 ), imath.V3d( 1,1,1 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( B.readBoundAtSample(1), imath.Box3d(imath.V3d( -1,-1,-1 ), imath.V3d( 1,1,1 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( B.readBoundAtSample(2), imath.Box3d(imath.V3d( -2,-1,-2 ), imath.V3d( 2,3,2 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( B.readBoundAtSample(3), imath.Box3d(imath.V3d( -3,-2,-3 ), imath.V3d( 3,4,3 ) ) ) ) b = B.child("b") self.assertTrue( b.hasBound() ) self.assertEqual( b.numBoundSamples(), 4 ) @@ -482,10 +484,10 @@ def testStoredScene( self ): self.assertEqual( b.boundSampleTime(1), 1.0 ) self.assertEqual( b.boundSampleTime(2), 2.0 ) self.assertEqual( b.boundSampleTime(3), 3.0 ) - self.failUnless( SceneCacheTest.compareBBox( b.readBoundAtSample(0), IECore.Box3d(IECore.V3d( -1 ), IECore.V3d( 1 ) ) ) ) - self.failUnless( SceneCacheTest.compareBBox( b.readBoundAtSample(1), IECore.Box3d(IECore.V3d( -1 ), IECore.V3d( 1 ) ) ) ) - self.failUnless( SceneCacheTest.compareBBox( b.readBoundAtSample(2), IECore.Box3d(IECore.V3d( -2 ), IECore.V3d( 2 ) ) ) ) - self.failUnless( SceneCacheTest.compareBBox( b.readBoundAtSample(3), IECore.Box3d(IECore.V3d( -3 ), IECore.V3d( 3 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( b.readBoundAtSample(0), imath.Box3d(imath.V3d( -1 ), imath.V3d( 1 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( b.readBoundAtSample(1), imath.Box3d(imath.V3d( -1 ), imath.V3d( 1 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( b.readBoundAtSample(2), imath.Box3d(imath.V3d( -2 ), imath.V3d( 2 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( b.readBoundAtSample(3), imath.Box3d(imath.V3d( -3 ), imath.V3d( 3 ) ) ) ) def testUnionBoundsForAnimation( self ): @@ -495,21 +497,21 @@ def testUnionBoundsForAnimation( self ): B = m.createChild( "B" ) b = B.createChild( "b" ) # time 0.0 - A.writeTransform( IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 1, 0, 0 ) ) ), 0.0 ) - a.writeTransform( IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 0, 0, 0 ) ) ), 0.0 ) + A.writeTransform( IECore.M44dData( imath.M44d().translate( imath.V3d( 1, 0, 0 ) ) ), 0.0 ) + a.writeTransform( IECore.M44dData( imath.M44d().translate( imath.V3d( 0, 0, 0 ) ) ), 0.0 ) a.writeObject( IECoreScene.SpherePrimitive( 1 ), 0.0 ) - B.writeTransform( IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 0, 1, 0 ) ) ), 0.0 ) - b.writeTransform( IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 0, 0, 0 ) ) ), 0.0 ) + B.writeTransform( IECore.M44dData( imath.M44d().translate( imath.V3d( 0, 1, 0 ) ) ), 0.0 ) + b.writeTransform( IECore.M44dData( imath.M44d().translate( imath.V3d( 0, 0, 0 ) ) ), 0.0 ) b.writeObject( IECoreScene.SpherePrimitive( 1 ), 0.0 ) # time 1.0 - A.writeTransform( IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 2, 0, 0 ) ) ), 1.0 ) - a.writeTransform( IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 0, 0, 0 ) ) ), 1.0 ) - B.writeTransform( IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 0, 2, 0 ) ) ), 1.0 ) - b.writeTransform( IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 0, 0, 0 ) ) ), 1.0 ) + A.writeTransform( IECore.M44dData( imath.M44d().translate( imath.V3d( 2, 0, 0 ) ) ), 1.0 ) + a.writeTransform( IECore.M44dData( imath.M44d().translate( imath.V3d( 0, 0, 0 ) ) ), 1.0 ) + B.writeTransform( IECore.M44dData( imath.M44d().translate( imath.V3d( 0, 2, 0 ) ) ), 1.0 ) + b.writeTransform( IECore.M44dData( imath.M44d().translate( imath.V3d( 0, 0, 0 ) ) ), 1.0 ) b.writeObject( IECoreScene.SpherePrimitive( 1 ), 1.0 ) # time 2.0 - a.writeTransform( IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 1, 0, 0 ) ) ), 2.0 ) - b.writeTransform( IECore.M44dData( IECore.M44d.createTranslated( IECore.V3d( 0, 1, 0 ) ) ), 2.0 ) + a.writeTransform( IECore.M44dData( imath.M44d().translate( imath.V3d( 1, 0, 0 ) ) ), 2.0 ) + b.writeTransform( IECore.M44dData( imath.M44d().translate( imath.V3d( 0, 1, 0 ) ) ), 2.0 ) b.writeObject( IECoreScene.SpherePrimitive( 2 ), 2.0 ) # time 3.0 b.writeObject( IECoreScene.SpherePrimitive( 3 ), 3.0 ) @@ -521,13 +523,13 @@ def testUnionBoundsForAnimation( self ): self.assertEqual( m.boundSampleTime(1), 1.0 ) self.assertEqual( m.boundSampleTime(2), 2.0 ) self.assertEqual( m.boundSampleTime(3), 3.0 ) - self.failUnless( SceneCacheTest.compareBBox( m.readBoundAtSample(0), IECore.Box3d( IECore.V3d( -1,-1,-1 ), IECore.V3d( 2,2,1 ) ) ) ) - self.failUnless( SceneCacheTest.compareBBox( m.readBound(0), IECore.Box3d( IECore.V3d( -1,-1,-1 ), IECore.V3d( 2,2,1 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( m.readBoundAtSample(0), imath.Box3d( imath.V3d( -1,-1,-1 ), imath.V3d( 2,2,1 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( m.readBound(0), imath.Box3d( imath.V3d( -1,-1,-1 ), imath.V3d( 2,2,1 ) ) ) ) self.assertEqual( m.boundSampleInterval(0), (0,0,0) ) - self.failUnless( SceneCacheTest.compareBBox( m.readBoundAtSample(1), IECore.Box3d( IECore.V3d( -1,-1,-1 ), IECore.V3d( 3,3,1 ) ) ) ) - self.assertEqual( m.readBoundAtSample(2), IECore.Box3d( IECore.V3d( -2,-1,-2 ), IECore.V3d( 4,5,2 ) ) ) - self.assertEqual( m.readBoundAtSample(3), IECore.Box3d( IECore.V3d( -3,-1,-3 ), IECore.V3d( 4,6,3 ) ) ) - self.assertEqual( m.readBound(3), IECore.Box3d( IECore.V3d( -3,-1,-3 ), IECore.V3d( 4,6,3 ) ) ) + self.failUnless( SceneCacheTest.compareBBox( m.readBoundAtSample(1), imath.Box3d( imath.V3d( -1,-1,-1 ), imath.V3d( 3,3,1 ) ) ) ) + self.assertEqual( m.readBoundAtSample(2), imath.Box3d( imath.V3d( -2,-1,-2 ), imath.V3d( 4,5,2 ) ) ) + self.assertEqual( m.readBoundAtSample(3), imath.Box3d( imath.V3d( -3,-1,-3 ), imath.V3d( 4,6,3 ) ) ) + self.assertEqual( m.readBound(3), imath.Box3d( imath.V3d( -3,-1,-3 ), imath.V3d( 4,6,3 ) ) ) self.assertEqual( m.boundSampleInterval(3), (1.0,2,3) ) self.assertEqual( m.boundSampleInterval(4), (0,3,3) ) @@ -536,32 +538,32 @@ def testUnionBoundsForAnimation( self ): self.assertEqual( A.boundSampleTime(0), 0.0 ) self.assertEqual( A.boundSampleTime(1), 1.0 ) self.assertEqual( A.boundSampleTime(2), 2.0 ) - self.failUnless( SceneCacheTest.compareBBox( A.readBoundAtSample(0), IECore.Box3d(IECore.V3d( -1,-1,-1 ), IECore.V3d( 1,1,1 ) ) ) ) - self.failUnless( SceneCacheTest.compareBBox( A.readBoundAtSample(1), IECore.Box3d(IECore.V3d( -1,-1,-1 ), IECore.V3d( 1,1,1 ) ) ) ) - self.failUnless( SceneCacheTest.compareBBox( A.readBoundAtSample(2), IECore.Box3d(IECore.V3d( 0,-1,-1 ), IECore.V3d( 2,1,1 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( A.readBoundAtSample(0), imath.Box3d(imath.V3d( -1,-1,-1 ), imath.V3d( 1,1,1 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( A.readBoundAtSample(1), imath.Box3d(imath.V3d( -1,-1,-1 ), imath.V3d( 1,1,1 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( A.readBoundAtSample(2), imath.Box3d(imath.V3d( 0,-1,-1 ), imath.V3d( 2,1,1 ) ) ) ) a = A.child("a") self.assertEqual( a.numBoundSamples(), 1 ) - self.assertEqual( a.readBoundAtSample(0), IECore.Box3d(IECore.V3d( -1 ), IECore.V3d( 1 ) ) ) + self.assertEqual( a.readBoundAtSample(0), imath.Box3d(imath.V3d( -1 ), imath.V3d( 1 ) ) ) B = m.child("B") self.assertEqual( B.numBoundSamples(), 4 ) self.assertEqual( B.boundSampleTime(0), 0.0 ) self.assertEqual( B.boundSampleTime(1), 1.0 ) self.assertEqual( B.boundSampleTime(2), 2.0 ) self.assertEqual( B.boundSampleTime(3), 3.0 ) - self.failUnless( SceneCacheTest.compareBBox( B.readBoundAtSample(0), IECore.Box3d(IECore.V3d( -1,-1,-1 ), IECore.V3d( 1,1,1 ) ) ) ) - self.failUnless( SceneCacheTest.compareBBox( B.readBoundAtSample(1), IECore.Box3d(IECore.V3d( -1,-1,-1 ), IECore.V3d( 1,1,1 ) ) ) ) - self.failUnless( SceneCacheTest.compareBBox( B.readBoundAtSample(2), IECore.Box3d(IECore.V3d( -2,-1,-2 ), IECore.V3d( 2,3,2 ) ) ) ) - self.failUnless( SceneCacheTest.compareBBox( B.readBoundAtSample(3), IECore.Box3d(IECore.V3d( -3,-2,-3 ), IECore.V3d( 3,4,3 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( B.readBoundAtSample(0), imath.Box3d(imath.V3d( -1,-1,-1 ), imath.V3d( 1,1,1 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( B.readBoundAtSample(1), imath.Box3d(imath.V3d( -1,-1,-1 ), imath.V3d( 1,1,1 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( B.readBoundAtSample(2), imath.Box3d(imath.V3d( -2,-1,-2 ), imath.V3d( 2,3,2 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( B.readBoundAtSample(3), imath.Box3d(imath.V3d( -3,-2,-3 ), imath.V3d( 3,4,3 ) ) ) ) b = B.child("b") self.assertEqual( b.numBoundSamples(), 4 ) self.assertEqual( b.boundSampleTime(0), 0.0 ) self.assertEqual( b.boundSampleTime(1), 1.0 ) self.assertEqual( b.boundSampleTime(2), 2.0 ) self.assertEqual( b.boundSampleTime(3), 3.0 ) - self.failUnless( SceneCacheTest.compareBBox( b.readBoundAtSample(0), IECore.Box3d(IECore.V3d( -1 ), IECore.V3d( 1 ) ) ) ) - self.failUnless( SceneCacheTest.compareBBox( b.readBoundAtSample(1), IECore.Box3d(IECore.V3d( -1 ), IECore.V3d( 1 ) ) ) ) - self.failUnless( SceneCacheTest.compareBBox( b.readBoundAtSample(2), IECore.Box3d(IECore.V3d( -2 ), IECore.V3d( 2 ) ) ) ) - self.failUnless( SceneCacheTest.compareBBox( b.readBoundAtSample(3), IECore.Box3d(IECore.V3d( -3 ), IECore.V3d( 3 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( b.readBoundAtSample(0), imath.Box3d(imath.V3d( -1 ), imath.V3d( 1 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( b.readBoundAtSample(1), imath.Box3d(imath.V3d( -1 ), imath.V3d( 1 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( b.readBoundAtSample(2), imath.Box3d(imath.V3d( -2 ), imath.V3d( 2 ) ) ) ) + self.failUnless( SceneCacheTest.compareBBox( b.readBoundAtSample(3), imath.Box3d(imath.V3d( -3 ), imath.V3d( 3 ) ) ) ) def testExpandedBoundsForAnimation( self ): @@ -571,15 +573,15 @@ def testExpandedBoundsForAnimation( self ): a = m.createChild( "a" ) a.writeObject( cube, 0.0 ) - a.writeTransform( IECore.M44dData( IECore.M44d.createRotated( IECore.V3d( 0, math.radians(0), 0 ) ) ), 0.0 ) - a.writeTransform( IECore.M44dData( IECore.M44d.createRotated( IECore.V3d( 0, math.radians(90), 0 ) ) ), 1.0 ) - a.writeTransform( IECore.M44dData( IECore.M44d.createRotated( IECore.V3d( 0, math.radians(180), 0 ) ) ), 2.0 ) - a.writeTransform( IECore.M44dData( IECore.M44d.createRotated( IECore.V3d( 0, math.radians(270), 0 ) ) ), 3.0 ) + a.writeTransform( IECore.M44dData( imath.M44d().rotate( imath.V3d( 0, math.radians(0), 0 ) ) ), 0.0 ) + a.writeTransform( IECore.M44dData( imath.M44d().rotate( imath.V3d( 0, math.radians(90), 0 ) ) ), 1.0 ) + a.writeTransform( IECore.M44dData( imath.M44d().rotate( imath.V3d( 0, math.radians(180), 0 ) ) ), 2.0 ) + a.writeTransform( IECore.M44dData( imath.M44d().rotate( imath.V3d( 0, math.radians(270), 0 ) ) ), 3.0 ) del m,a - cubeBound = IECore.Box3d( IECore.V3d( cube.bound().min ), IECore.V3d( cube.bound().max ) ) - errorTolerance = IECore.V3d(1e-5, 1e-5, 1e-5) + cubeBound = imath.Box3d( imath.V3d( cube.bound().min() ), imath.V3d( cube.bound().max() ) ) + errorTolerance = imath.V3d(1e-5, 1e-5, 1e-5) m = IECoreScene.SceneCache( "/tmp/test.scc", IECore.IndexedIO.OpenMode.Read ) a = m.child("a") @@ -593,18 +595,18 @@ def testExpandedBoundsForAnimation( self ): for t in xrange( 0, 30, 2 ): time = t / 10.0 angle = time * math.radians(90) - transformedBound = cubeBound.transform( IECore.M44d.createRotated( IECore.V3d( 0, angle, 0 ) ) ) + transformedBound = cubeBound * imath.M44d().rotate( imath.V3d( 0, angle, 0 ) ) tmpBounds = m.readBound( time ) - tmpBounds.extendBy( IECore.Box3d( tmpBounds.min - errorTolerance, tmpBounds.max + errorTolerance ) ) - self.failUnless( tmpBounds.contains( transformedBound ) ) # interpolated bounding box must contain bounding box of interpolated rotation. + tmpBounds.extendBy( imath.Box3d( tmpBounds.min() - errorTolerance, tmpBounds.max() + errorTolerance ) ) + self.failUnless( IECore.BoxAlgo.contains( tmpBounds, transformedBound ) ) # interpolated bounding box must contain bounding box of interpolated rotation. def testAnimatedObjectAttributes( self ) : - plane = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( 0 ), IECore.V2f( 1 ) ) ) - box = IECoreScene.MeshPrimitive.createBox( IECore.Box3f( IECore.V3f( 0 ), IECore.V3f( 1 ) ) ) - box["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.Color3fVectorData( [ IECore.Color3f( 1, 0, 0 ) ] * box.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) ) ) + plane = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( 0 ), imath.V2f( 1 ) ) ) + box = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( 0 ), imath.V3f( 1 ) ) ) + box["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.Color3fVectorData( [ imath.Color3f( 1, 0, 0 ) ] * box.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) ) ) box2 = box.copy() - box2["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.Color3fVectorData( [ IECore.Color3f( 0, 1, 0 ) ] * box.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) ) ) + box2["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.Color3fVectorData( [ imath.Color3f( 0, 1, 0 ) ] * box.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) ) ) s = IECoreScene.SceneCache( "/tmp/test.scc", IECore.IndexedIO.OpenMode.Write ) a = s.createChild( "a" ) @@ -650,10 +652,10 @@ def testAnimatedObjectAttributes( self ) : def testObjectPrimitiveVariablesRead( self ) : - box = IECoreScene.MeshPrimitive.createBox( IECore.Box3f( IECore.V3f( 0 ), IECore.V3f( 1 ) ) ) - box["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.Color3fVectorData( [ IECore.Color3f( 1, 0, 0 ) ] * box.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) ) ) + box = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( 0 ), imath.V3f( 1 ) ) ) + box["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.Color3fVectorData( [ imath.Color3f( 1, 0, 0 ) ] * box.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) ) ) box2 = box.copy() - box2["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.Color3fVectorData( [ IECore.Color3f( 0, 1, 0 ) ] * box.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) ) ) + box2["Cs"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.Color3fVectorData( [ imath.Color3f( 0, 1, 0 ) ] * box.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Uniform ) ) ) s = IECoreScene.SceneCache( "/tmp/test.scc", IECore.IndexedIO.OpenMode.Write ) b = s.createChild( "b" ) @@ -675,7 +677,7 @@ def testObjectPrimitiveVariablesRead( self ) : def testTags( self ) : sphere = IECoreScene.SpherePrimitive( 1 ) - box = IECoreScene.MeshPrimitive.createBox( IECore.Box3f( IECore.V3f( 0 ), IECore.V3f( 1 ) ) ) + box = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( 0 ), imath.V3f( 1 ) ) ) def testSet( values ): return set( map( lambda s: IECore.InternedString(s), values ) ) @@ -810,11 +812,10 @@ def testTransformInterpolation( self ): t = s.createChild( "t" ) - m = IECore.M44d() - m.setEulerAngles( IECore.V3d( 0, math.pi/2, 0 ) ) - m[(3,0)] = 10 + m = imath.Eulerd( 0, math.pi/2, 0 ).toMatrix44() + m[3][0] = 10 - t.writeTransform( IECore.M44dData( IECore.M44d.createTranslated(IECore.V3d( 5, 0, 0 ) ) ), 0.0 ) + t.writeTransform( IECore.M44dData( imath.M44d().translate(imath.V3d( 5, 0, 0 ) ) ), 0.0 ) t.writeTransform( IECore.M44dData(m), 1.0 ) del m, t, s @@ -824,7 +825,11 @@ def testTransformInterpolation( self ): for i in range(0,11): interpolatedTransform = tchild.readTransformAsMatrix(float(i)/10) - ( s, h, r, t ) = interpolatedTransform.extractSHRT() + s = imath.V3d() + h = imath.V3d() + r = imath.V3d() + t = imath.V3d() + interpolatedTransform.extractSHRT( s, h, r, t ) self.assertAlmostEqual( r[1], 0.1 * i * math.pi * 0.5, 9 ) self.assertAlmostEqual( t[0], 5 + 0.5 * i, 9 ) diff --git a/test/IECoreScene/SceneInterfaceTest.py b/test/IECoreScene/SceneInterfaceTest.py index 94d1a7ab77..aa982d8799 100644 --- a/test/IECoreScene/SceneInterfaceTest.py +++ b/test/IECoreScene/SceneInterfaceTest.py @@ -36,6 +36,7 @@ import sys import math import unittest +import imath import IECore import IECoreScene @@ -50,7 +51,7 @@ def writeSCC( self ) : m.writeAttribute( "w", IECore.BoolData( True ), 1.0 ) t = m.createChild( "t" ) - t.writeTransform( IECore.M44dData(IECore.M44d.createTranslated(IECore.V3d( 1, 0, 0 ))), 1.0 ) + t.writeTransform( IECore.M44dData(imath.M44d().translate(imath.V3d( 1, 0, 0 ))), 1.0 ) t.writeAttribute( "wuh", IECore.BoolData( True ), 1.0 ) s = t.createChild( "s" ) diff --git a/test/IECoreScene/SmoothSkinningDataTest.py b/test/IECoreScene/SmoothSkinningDataTest.py index 38773ad2e2..1c2f5c3293 100644 --- a/test/IECoreScene/SmoothSkinningDataTest.py +++ b/test/IECoreScene/SmoothSkinningDataTest.py @@ -36,6 +36,7 @@ ########################################################################## """Unit test for SmoothSkinningData binding""" +import imath import IECore import IECoreScene @@ -62,7 +63,7 @@ def testData( self ) : def testIO( self ) : # test fileIndexedIO, read and write ok_jn = IECore.StringVectorData( [ 'jointA', 'jointB' ] ) - ok_ip = IECore.M44fVectorData( [IECore.M44f(),IECore.M44f()] ) + ok_ip = IECore.M44fVectorData( [imath.M44f(),imath.M44f()] ) ok_pio = IECore.IntVectorData( [0, 2, 4] ) ok_pic = IECore.IntVectorData( [2, 2, 1] ) ok_pii = IECore.IntVectorData( [0, 1, 0, 1, 1] ) @@ -78,7 +79,7 @@ def testIO( self ) : def testDataStorage(self ): #test the object can store data ok_jn = IECore.StringVectorData( [ 'jointA', 'jointB' ] ) - ok_ip = IECore.M44fVectorData( [IECore.M44f(),IECore.M44f()] ) + ok_ip = IECore.M44fVectorData( [imath.M44f(),imath.M44f()] ) ok_pio = IECore.IntVectorData( [0, 2, 4] ) ok_pic = IECore.IntVectorData( [2, 2, 1] ) ok_pii = IECore.IntVectorData( [0, 1, 0, 1, 1] ) @@ -105,7 +106,7 @@ def testValidate(self): # good data ok_jn = IECore.StringVectorData( [ 'jointA', 'jointB' ] ) - ok_ip = IECore.M44fVectorData( [IECore.M44f(),IECore.M44f()] ) + ok_ip = IECore.M44fVectorData( [imath.M44f(),imath.M44f()] ) ok_pio = IECore.IntVectorData( [0, 2, 4] ) ok_pic = IECore.IntVectorData( [2, 2, 1] ) ok_pii = IECore.IntVectorData( [0, 1, 0, 1, 1] ) @@ -113,7 +114,7 @@ def testValidate(self): # data with invalid nr of elements iv_jn = IECore.StringVectorData( [ 'jointA', 'jointB', 'jointC' ] ) - iv_ip = IECore.M44fVectorData( [IECore.M44f()] ) + iv_ip = IECore.M44fVectorData( [imath.M44f()] ) iv_pio1 = IECore.IntVectorData( [0, 2, 4, 666] ) iv_pic1 = IECore.IntVectorData( [2, 2 ] ) iv_pii1 = IECore.IntVectorData( [0, 1, 0, 1, 1, 666] ) diff --git a/test/IECoreScene/SmoothSmoothSkinningWeightsOpTest.py b/test/IECoreScene/SmoothSmoothSkinningWeightsOpTest.py index 4bd28c9523..c7820566ac 100644 --- a/test/IECoreScene/SmoothSmoothSkinningWeightsOpTest.py +++ b/test/IECoreScene/SmoothSmoothSkinningWeightsOpTest.py @@ -35,6 +35,7 @@ import math import unittest import random +import imath import IECore import IECoreScene @@ -57,9 +58,9 @@ def createSSD( self, offsets, counts, indices, weights ) : names = IECore.StringVectorData( [ "|joint1", "|joint1|joint2", "|joint1|joint2|joint3" ] ) poses = IECore.M44fVectorData( [ - IECore.M44f( 1, -0, 0, -0, -0, 1, -0, 0, 0, -0, 1, -0, -0, 2, -0, 1 ), - IECore.M44f( 1, -0, 0, -0, -0, 1, -0, 0, 0, -0, 1, -0, -0, 0, -0, 1 ), - IECore.M44f( 1, -0, 0, -0, -0, 1, -0, 0, 0, -0, 1, -0, -0, -2, -0, 1 ) + imath.M44f( 1, -0, 0, -0, -0, 1, -0, 0, 0, -0, 1, -0, -0, 2, -0, 1 ), + imath.M44f( 1, -0, 0, -0, -0, 1, -0, 0, 0, -0, 1, -0, -0, 0, -0, 1 ), + imath.M44f( 1, -0, 0, -0, -0, 1, -0, 0, 0, -0, 1, -0, -0, -2, -0, 1 ) ] ) return IECoreScene.SmoothSkinningData( names, poses, offsets, counts, indices, weights ) diff --git a/test/IECoreScene/SpherePrimitiveEvaluator.py b/test/IECoreScene/SpherePrimitiveEvaluator.py index 5eaca4edef..3af8b84086 100644 --- a/test/IECoreScene/SpherePrimitiveEvaluator.py +++ b/test/IECoreScene/SpherePrimitiveEvaluator.py @@ -35,6 +35,7 @@ import math import unittest import random +import imath import IECore import IECoreScene @@ -49,22 +50,22 @@ def testSimple( self ) : random.seed( 1 ) - rand = IECore.Rand48( 1 ) + rand = imath.Rand48( 1 ) numTests = 50 for i in range(0, numTests) : - center = IECore.V3f( 0, 0, 0 ) + center = imath.V3f( 0, 0, 0 ) radius = random.uniform( 0.1, 5 ) sphere = IECoreScene.SpherePrimitive( radius ) # Add some UV data in "bowtie" order - when we read it back it should then match the geometric UVs # if we're doing everything correctly. testData = IECore.V3fVectorData() - testData.append( IECore.V3f( 0, 0, 0 ) ) - testData.append( IECore.V3f( 1, 0, 0 ) ) - testData.append( IECore.V3f( 0, 1, 0 ) ) - testData.append( IECore.V3f( 1, 1, 0 ) ) + testData.append( imath.V3f( 0, 0, 0 ) ) + testData.append( imath.V3f( 1, 0, 0 ) ) + testData.append( imath.V3f( 0, 1, 0 ) ) + testData.append( imath.V3f( 1, 1, 0 ) ) testPrimVar = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Varying, testData ) sphere["testPrimVar"] = testPrimVar @@ -72,7 +73,7 @@ def testSimple( self ) : result = se.createResult() - testPoint = IECore.V3f( random.uniform( -10, 10 ), random.uniform( -10, 10 ), random.uniform( -10, 10 ) ) + testPoint = imath.V3f( random.uniform( -10, 10 ), random.uniform( -10, 10 ), random.uniform( -10, 10 ) ) found = se.closestPoint( testPoint, result ) @@ -101,11 +102,11 @@ def testSimple( self ) : self.assertAlmostEqual( result.uv()[1], uv[1], 3 ) # Pick a random point inside the sphere... - origin = center + IECore.Rand48.solidSpheref(rand) * radius * 0.9 + origin = center + rand.nextSolidSphere( imath.V3f() ) * radius * 0.9 self.assert_( ( origin - center ).length() < radius ) # And a random (unnormalized!) direction - direction = IECore.Rand48.hollowSpheref(rand) * random.uniform( 0.5, 10 ) + direction = rand.nextHollowSphere( imath.V3f() ) * random.uniform( 0.5, 10 ) found = se.intersectionPoint( origin, direction, result ) if found: @@ -122,7 +123,7 @@ def testSimple( self ) : self.assert_( math.fabs( ( result.point() - center ).length() - radius ) < 0.001 ) # Pick a random point outside the sphere... - origin = center + IECore.Rand48.hollowSpheref(rand) * radius * 2 + origin = center + rand.nextHollowSphere( imath.V3f() ) * radius * 2 self.assert_( ( origin - center ).length() > radius ) found = se.intersectionPoint( origin, direction, result ) diff --git a/test/IECoreScene/TransferSmoothSkinningWeightsOpTest.py b/test/IECoreScene/TransferSmoothSkinningWeightsOpTest.py index 36b77e1f25..225a3c06b6 100644 --- a/test/IECoreScene/TransferSmoothSkinningWeightsOpTest.py +++ b/test/IECoreScene/TransferSmoothSkinningWeightsOpTest.py @@ -35,6 +35,7 @@ import math import unittest import random +import imath import IECore import IECoreScene @@ -44,7 +45,7 @@ class TransferSmoothSkinningWeightsOpTest( unittest.TestCase ) : def createSSD( self, weights, indices, offsets, counts ) : names = IECore.StringVectorData( [ 'jointA', 'jointB', 'jointC' ] ) - poses = IECore.M44fVectorData( [IECore.M44f(1),IECore.M44f(2),IECore.M44f(3)] ) + poses = IECore.M44fVectorData( [imath.M44f(1),imath.M44f(2),imath.M44f(3)] ) ssd = IECoreScene.SmoothSkinningData( names, poses, offsets, counts, indices, weights ) @@ -84,7 +85,7 @@ def testTypes( self ) : op = IECoreScene.TransferSmoothSkinningWeightsOp() self.assertEqual( type(op), IECoreScene.TransferSmoothSkinningWeightsOp ) - self.assertEqual( op.typeId(), IECore.TypeId.TransferSmoothSkinningWeightsOp ) + self.assertEqual( op.typeId(), IECoreScene.TypeId.TransferSmoothSkinningWeightsOp ) op.parameters()['input'].setValue( IECore.IntData(1) ) self.assertRaises( RuntimeError, op.operate ) diff --git a/test/IECoreScene/Transform.py b/test/IECoreScene/Transform.py index 3df4afdf85..d5e8b0089c 100644 --- a/test/IECoreScene/Transform.py +++ b/test/IECoreScene/Transform.py @@ -34,6 +34,7 @@ import os import unittest +import imath import IECore import IECoreScene @@ -41,15 +42,15 @@ class TestTransform( unittest.TestCase ) : def test( self ) : - m = IECoreScene.MatrixTransform( IECore.M44f() ) - self.assertEqual( m.transform(), IECore.M44f() ) - self.assertEqual( m.transform( 1 ), IECore.M44f() ) - self.assertEqual( m.matrix, IECore.M44f() ) + m = IECoreScene.MatrixTransform( imath.M44f() ) + self.assertEqual( m.transform(), imath.M44f() ) + self.assertEqual( m.transform( 1 ), imath.M44f() ) + self.assertEqual( m.matrix, imath.M44f() ) - m = IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( 1, 2, 3 ) ) ) - self.assertEqual( m.transform(), IECore.M44f.createTranslated( IECore.V3f( 1, 2, 3 ) ) ) - self.assertEqual( m.transform( 1 ), IECore.M44f.createTranslated( IECore.V3f( 1, 2, 3 ) ) ) - self.assertEqual( m.matrix, IECore.M44f.createTranslated( IECore.V3f( 1, 2, 3 ) ) ) + m = IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 1, 2, 3 ) ) ) + self.assertEqual( m.transform(), imath.M44f().translate( imath.V3f( 1, 2, 3 ) ) ) + self.assertEqual( m.transform( 1 ), imath.M44f().translate( imath.V3f( 1, 2, 3 ) ) ) + self.assertEqual( m.matrix, imath.M44f().translate( imath.V3f( 1, 2, 3 ) ) ) mm = m.copy() @@ -63,15 +64,15 @@ def test( self ) : def testMotionTransform( self ) : m = IECoreScene.MatrixMotionTransform() - self.assertEqual( m.transform(), IECore.M44f() ) - self.assertEqual( m.transform( 2 ), IECore.M44f() ) + self.assertEqual( m.transform(), imath.M44f() ) + self.assertEqual( m.transform( 2 ), imath.M44f() ) self.assertEqual( m.keys(), [] ) self.assertEqual( m.values(), [] ) self.assertEqual( len( m ), 0 ) - t1 = IECore.M44f.createTranslated( IECore.V3f( 0, 1, 0 ) ) - t2 = IECore.M44f.createTranslated( IECore.V3f( 0, 5, 0 ) ) - tMid = IECore.M44f.createTranslated( IECore.V3f( 0, 3, 0 ) ) + t1 = imath.M44f().translate( imath.V3f( 0, 1, 0 ) ) + t2 = imath.M44f().translate( imath.V3f( 0, 5, 0 ) ) + tMid = imath.M44f().translate( imath.V3f( 0, 3, 0 ) ) m[0] = t1 self.assertEqual( len( m ), 1 ) @@ -103,10 +104,10 @@ def testMotionTransform( self ) : def testHash( self ) : - t = IECoreScene.MatrixTransform( IECore.M44f() ) - self.assertEqual( t.hash(), IECoreScene.MatrixTransform( IECore.M44f() ).hash() ) + t = IECoreScene.MatrixTransform( imath.M44f() ) + self.assertEqual( t.hash(), IECoreScene.MatrixTransform( imath.M44f() ).hash() ) - t2 = IECoreScene.MatrixTransform( IECore.M44f.createTranslated( IECore.V3f( 1 ) ) ) + t2 = IECoreScene.MatrixTransform( imath.M44f().translate( imath.V3f( 1 ) ) ) self.assertNotEqual( t.hash(), t2.hash() ) def tearDown( self ) : diff --git a/test/IECoreScene/TransformOpTest.py b/test/IECoreScene/TransformOpTest.py index 4835b199a3..6384f7d927 100644 --- a/test/IECoreScene/TransformOpTest.py +++ b/test/IECoreScene/TransformOpTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene @@ -46,26 +47,26 @@ def testParameterDefaults( self ) : def testTranformation( self ) : - m = IECoreScene.MeshPrimitive.createBox( IECore.Box3f( IECore.V3f( -1 ), IECore.V3f( 1 ) ) ) + m = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ) ) IECoreScene.MeshNormalsOp()( input = m, copyInput = False ) - m["vel"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f( 0.5 ) ] * 8, IECore.GeometricData.Interpretation.Vector ) ) - m["notVel"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f( 0.5 ) ] * 8 ) ) + m["vel"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f( 0.5 ) ] * 8, IECore.GeometricData.Interpretation.Vector ) ) + m["notVel"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f( 0.5 ) ] * 8 ) ) - mt = IECoreScene.TransformOp()( input=m, primVarsToModify = IECore.StringVectorData( m.keys() ), matrix = IECore.M44fData( IECore.M44f.createTranslated( IECore.V3f( 1 ) ) ) ) + mt = IECoreScene.TransformOp()( input=m, primVarsToModify = IECore.StringVectorData( m.keys() ), matrix = IECore.M44fData( imath.M44f().translate( imath.V3f( 1 ) ) ) ) - self.assertEqual( mt.bound(), IECore.Box3f( IECore.V3f( 0 ), IECore.V3f( 2 ) ) ) - self.assertEqual( mt["P"].data, IECore.V3fVectorData( [ x + IECore.V3f( 1 ) for x in m["P"].data ], IECore.GeometricData.Interpretation.Point ) ) + self.assertEqual( mt.bound(), imath.Box3f( imath.V3f( 0 ), imath.V3f( 2 ) ) ) + self.assertEqual( mt["P"].data, IECore.V3fVectorData( [ x + imath.V3f( 1 ) for x in m["P"].data ], IECore.GeometricData.Interpretation.Point ) ) self.assertEqual( mt["N"].data, m["N"].data ) self.assertEqual( mt["vel"].data, m["vel"].data ) self.assertEqual( mt["notVel"].data, m["notVel"].data ) - ms = IECoreScene.TransformOp()( input=m, primVarsToModify = IECore.StringVectorData( m.keys() ), matrix = IECore.M44fData( IECore.M44f.createScaled( IECore.V3f( 1, 2, 3 ) ) ) ) + ms = IECoreScene.TransformOp()( input=m, primVarsToModify = IECore.StringVectorData( m.keys() ), matrix = IECore.M44fData( imath.M44f().scale( imath.V3f( 1, 2, 3 ) ) ) ) - self.assertEqual( ms.bound(), IECore.Box3f( IECore.V3f( -1, -2, -3 ), IECore.V3f( 1, 2, 3 ) ) ) - self.assertEqual( ms["P"].data, IECore.V3fVectorData( [ x * IECore.V3f( 1, 2, 3 ) for x in m["P"].data ], IECore.GeometricData.Interpretation.Point ) ) + self.assertEqual( ms.bound(), imath.Box3f( imath.V3f( -1, -2, -3 ), imath.V3f( 1, 2, 3 ) ) ) + self.assertEqual( ms["P"].data, IECore.V3fVectorData( [ x * imath.V3f( 1, 2, 3 ) for x in m["P"].data ], IECore.GeometricData.Interpretation.Point ) ) self.assertNotEqual( ms["N"].data, m["N"].data ) - self.assertNotEqual( ms["N"].data, IECore.V3fVectorData( [ x * IECore.V3f( 1, 2, 3 ) for x in m["N"].data ], IECore.GeometricData.Interpretation.Normal ) ) - self.assertEqual( ms["vel"].data, IECore.V3fVectorData( [ x * IECore.V3f( 1, 2, 3 ) for x in m["vel"].data ], IECore.GeometricData.Interpretation.Vector ) ) + self.assertNotEqual( ms["N"].data, IECore.V3fVectorData( [ x * imath.V3f( 1, 2, 3 ) for x in m["N"].data ], IECore.GeometricData.Interpretation.Normal ) ) + self.assertEqual( ms["vel"].data, IECore.V3fVectorData( [ x * imath.V3f( 1, 2, 3 ) for x in m["vel"].data ], IECore.GeometricData.Interpretation.Vector ) ) self.assertEqual( ms["notVel"].data, m["notVel"].data ) self.assertEqual( ms["P"].data.getInterpretation(), IECore.GeometricData.Interpretation.Point ) @@ -75,49 +76,49 @@ def testTranformation( self ) : def testPrimVarParameter( self ) : - m = IECoreScene.MeshPrimitive.createBox( IECore.Box3f( IECore.V3f( -1 ), IECore.V3f( 1 ) ) ) + m = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ) ) IECoreScene.MeshNormalsOp()( input = m, copyInput = False ) - m["vel"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f( 0.5 ) ] * 8, IECore.GeometricData.Interpretation.Vector ) ) - m["notVel"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f( 0.5 ) ] * 8 ) ) + m["vel"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f( 0.5 ) ] * 8, IECore.GeometricData.Interpretation.Vector ) ) + m["notVel"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f( 0.5 ) ] * 8 ) ) - ms = IECoreScene.TransformOp()( input=m, primVarsToModify = IECore.StringVectorData( [ "P", "vel" ] ), matrix = IECore.M44fData( IECore.M44f.createScaled( IECore.V3f( 1, 2, 3 ) ) ) ) + ms = IECoreScene.TransformOp()( input=m, primVarsToModify = IECore.StringVectorData( [ "P", "vel" ] ), matrix = IECore.M44fData( imath.M44f().scale( imath.V3f( 1, 2, 3 ) ) ) ) - self.assertEqual( ms.bound(), IECore.Box3f( IECore.V3f( -1, -2, -3 ), IECore.V3f( 1, 2, 3 ) ) ) - self.assertEqual( ms["P"].data, IECore.V3fVectorData( [ x * IECore.V3f( 1, 2, 3 ) for x in m["P"].data ], IECore.GeometricData.Interpretation.Point ) ) + self.assertEqual( ms.bound(), imath.Box3f( imath.V3f( -1, -2, -3 ), imath.V3f( 1, 2, 3 ) ) ) + self.assertEqual( ms["P"].data, IECore.V3fVectorData( [ x * imath.V3f( 1, 2, 3 ) for x in m["P"].data ], IECore.GeometricData.Interpretation.Point ) ) self.assertEqual( ms["N"].data, m["N"].data ) - self.assertEqual( ms["vel"].data, IECore.V3fVectorData( [ x * IECore.V3f( 1, 2, 3 ) for x in m["vel"].data ], IECore.GeometricData.Interpretation.Vector ) ) + self.assertEqual( ms["vel"].data, IECore.V3fVectorData( [ x * imath.V3f( 1, 2, 3 ) for x in m["vel"].data ], IECore.GeometricData.Interpretation.Vector ) ) self.assertEqual( ms["notVel"].data, m["notVel"].data ) - ms = IECoreScene.TransformOp()( input=m, primVarsToModify = IECore.StringVectorData( [ "P" ] ), matrix = IECore.M44fData( IECore.M44f.createScaled( IECore.V3f( 1, 2, 3 ) ) ) ) + ms = IECoreScene.TransformOp()( input=m, primVarsToModify = IECore.StringVectorData( [ "P" ] ), matrix = IECore.M44fData( imath.M44f().scale( imath.V3f( 1, 2, 3 ) ) ) ) - self.assertEqual( ms.bound(), IECore.Box3f( IECore.V3f( -1, -2, -3 ), IECore.V3f( 1, 2, 3 ) ) ) - self.assertEqual( ms["P"].data, IECore.V3fVectorData( [ x * IECore.V3f( 1, 2, 3 ) for x in m["P"].data ], IECore.GeometricData.Interpretation.Point ) ) + self.assertEqual( ms.bound(), imath.Box3f( imath.V3f( -1, -2, -3 ), imath.V3f( 1, 2, 3 ) ) ) + self.assertEqual( ms["P"].data, IECore.V3fVectorData( [ x * imath.V3f( 1, 2, 3 ) for x in m["P"].data ], IECore.GeometricData.Interpretation.Point ) ) self.assertEqual( ms["N"].data, m["N"].data ) self.assertEqual( ms["N"].data, m["N"].data ) self.assertEqual( ms["notVel"].data, m["notVel"].data ) def testSamePrimVars( self ) : - m = IECoreScene.MeshPrimitive.createBox( IECore.Box3f( IECore.V3f( -1 ), IECore.V3f( 1 ) ) ) + m = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ) ) IECoreScene.MeshNormalsOp()( input = m, copyInput = False ) - m["vel"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f( 0.5 ) ] * 8, IECore.GeometricData.Interpretation.Vector ) ) + m["vel"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f( 0.5 ) ] * 8, IECore.GeometricData.Interpretation.Vector ) ) m["sameVel"] = m["vel"] - ms = IECoreScene.TransformOp()( input=m, primVarsToModify = IECore.StringVectorData( [ "vel", "sameVel" ] ), matrix = IECore.M44fData( IECore.M44f.createScaled( IECore.V3f( 1, 2, 3 ) ) ) ) + ms = IECoreScene.TransformOp()( input=m, primVarsToModify = IECore.StringVectorData( [ "vel", "sameVel" ] ), matrix = IECore.M44fData( imath.M44f().scale( imath.V3f( 1, 2, 3 ) ) ) ) - self.assertEqual( ms["vel"].data, IECore.V3fVectorData( [ x * IECore.V3f( 1, 2, 3 ) for x in m["vel"].data ], IECore.GeometricData.Interpretation.Vector ) ) + self.assertEqual( ms["vel"].data, IECore.V3fVectorData( [ x * imath.V3f( 1, 2, 3 ) for x in m["vel"].data ], IECore.GeometricData.Interpretation.Vector ) ) self.assertEqual( ms["vel"].data, ms["sameVel"].data ) def testIdenticalPrimVarsCanBeExcluded( self ) : - m = IECoreScene.MeshPrimitive.createBox( IECore.Box3f( IECore.V3f( -1 ), IECore.V3f( 1 ) ) ) + m = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( -1 ), imath.V3f( 1 ) ) ) IECoreScene.MeshNormalsOp()( input = m, copyInput = False ) - m["vel"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ IECore.V3f( 0.5 ) ] * 8, IECore.GeometricData.Interpretation.Vector ) ) + m["vel"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.V3fVectorData( [ imath.V3f( 0.5 ) ] * 8, IECore.GeometricData.Interpretation.Vector ) ) m["otherVel"] = m["vel"] - ms = IECoreScene.TransformOp()( input=m, primVarsToModify = IECore.StringVectorData( [ "vel" ] ), matrix = IECore.M44fData( IECore.M44f.createScaled( IECore.V3f( 1, 2, 3 ) ) ) ) + ms = IECoreScene.TransformOp()( input=m, primVarsToModify = IECore.StringVectorData( [ "vel" ] ), matrix = IECore.M44fData( imath.M44f().scale( imath.V3f( 1, 2, 3 ) ) ) ) - self.assertEqual( ms["vel"].data, IECore.V3fVectorData( [ x * IECore.V3f( 1, 2, 3 ) for x in m["vel"].data ], IECore.GeometricData.Interpretation.Vector ) ) + self.assertEqual( ms["vel"].data, IECore.V3fVectorData( [ x * imath.V3f( 1, 2, 3 ) for x in m["vel"].data ], IECore.GeometricData.Interpretation.Vector ) ) self.assertNotEqual( ms["vel"].data, ms["otherVel"].data ) self.assertEqual( ms["otherVel"].data, m["otherVel"].data ) diff --git a/test/IECoreScene/TriangulateOp.py b/test/IECoreScene/TriangulateOp.py index 03cb025962..7816560b74 100644 --- a/test/IECoreScene/TriangulateOp.py +++ b/test/IECoreScene/TriangulateOp.py @@ -34,6 +34,7 @@ import math import unittest +import imath import IECore import IECoreScene @@ -54,10 +55,10 @@ def testSimple( self ) : vertexIds.append( 3 ) P = IECore.V3fVectorData() - P.append( IECore.V3f( -1, 0, -1 ) ) - P.append( IECore.V3f( -1, 0, 1 ) ) - P.append( IECore.V3f( 1, 0, 1 ) ) - P.append( IECore.V3f( 1, 0, -1 ) ) + P.append( imath.V3f( -1, 0, -1 ) ) + P.append( imath.V3f( -1, 0, 1 ) ) + P.append( imath.V3f( 1, 0, 1 ) ) + P.append( imath.V3f( 1, 0, -1 ) ) m = IECoreScene.MeshPrimitive( verticesPerFace, vertexIds ) m["P"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, P ) @@ -168,10 +169,10 @@ def testNonPlanar( self ) : vertexIds.append( 3 ) P = IECore.V3dVectorData() - P.append( IECore.V3d( -1, 0, -1 ) ) - P.append( IECore.V3d( -1, 0, 1 ) ) - P.append( IECore.V3d( 1, 0, 1 ) ) - P.append( IECore.V3d( 1, 1, -1 ) ) + P.append( imath.V3d( -1, 0, -1 ) ) + P.append( imath.V3d( -1, 0, 1 ) ) + P.append( imath.V3d( 1, 0, 1 ) ) + P.append( imath.V3d( 1, 1, -1 ) ) m = IECoreScene.MeshPrimitive( verticesPerFace, vertexIds ) m["P"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, P ) @@ -200,10 +201,10 @@ def testConcave( self ) : vertexIds.append( 3 ) P = IECore.V3dVectorData() - P.append( IECore.V3d( -1, 0, -1 ) ) - P.append( IECore.V3d( -1, 0, 1 ) ) - P.append( IECore.V3d( 1, 0, 1 ) ) - P.append( IECore.V3d( -0.9, 0, -0.9 ) ) + P.append( imath.V3d( -1, 0, -1 ) ) + P.append( imath.V3d( -1, 0, 1 ) ) + P.append( imath.V3d( 1, 0, 1 ) ) + P.append( imath.V3d( -0.9, 0, -0.9 ) ) m = IECoreScene.MeshPrimitive( verticesPerFace, vertexIds ) m["P"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, P ) @@ -258,7 +259,7 @@ def testConstantPrimVars( self ) : def testInterpolationShouldntChange( self ) : - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) m.setTopology( m.verticesPerFace, m.vertexIds, "catmullClark" ) IECoreScene.TriangulateOp()( input = m, copyInput = False ) @@ -267,7 +268,7 @@ def testInterpolationShouldntChange( self ) : def testFaceVaryingIndices( self ) : - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -1 ), IECore.V2f( 1 ) ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ) ) m["uv"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.FaceVarying, m["uv"].data, IECore.IntVectorData( [ 0, 3, 1, 2 ] ) ) m2 = IECoreScene.TriangulateOp()( input = m, copyInput = True ) @@ -279,7 +280,7 @@ def testFaceVaryingIndices( self ) : def testUniformIndices( self ) : - m = IECoreScene.MeshPrimitive.createPlane( IECore.Box2f( IECore.V2f( -4 ), IECore.V2f( 4 ) ), divisions = IECore.V2i( 2, 2 ) ) + m = IECoreScene.MeshPrimitive.createPlane( imath.Box2f( imath.V2f( -4 ), imath.V2f( 4 ) ), divisions = imath.V2i( 2, 2 ) ) m["myString"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Uniform, IECore.StringVectorData( [ "a", "b" ] ), IECore.IntVectorData( [ 1, 0, 0, 1 ] ) ) m2 = IECoreScene.TriangulateOp()( input = m, copyInput = True ) diff --git a/test/IECoreScene/TriangulatorTest.py b/test/IECoreScene/TriangulatorTest.py index 6ecc5fb7d5..ed59e20d55 100644 --- a/test/IECoreScene/TriangulatorTest.py +++ b/test/IECoreScene/TriangulatorTest.py @@ -33,6 +33,7 @@ ########################################################################## import unittest +import imath import IECore import IECoreScene import math @@ -49,18 +50,18 @@ def testV3f( self ) : p = IECore.V3fVectorData( [ - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 3, 0, 0 ), - IECore.V3f( 3, 4, 0 ), - IECore.V3f( 2, 4, 0 ), - IECore.V3f( 2, 3, 0 ), - IECore.V3f( 1, 3, 0 ), - IECore.V3f( 1, 4, 0 ), - IECore.V3f( 0, 4, 0 ), - IECore.V3f( 0, 2, 0 ), - IECore.V3f( 1, 2, 0 ), - IECore.V3f( 1, 1, 0 ), - IECore.V3f( 0, 1, 0 ) + imath.V3f( 0, 0, 0 ), + imath.V3f( 3, 0, 0 ), + imath.V3f( 3, 4, 0 ), + imath.V3f( 2, 4, 0 ), + imath.V3f( 2, 3, 0 ), + imath.V3f( 1, 3, 0 ), + imath.V3f( 1, 4, 0 ), + imath.V3f( 0, 4, 0 ), + imath.V3f( 0, 2, 0 ), + imath.V3f( 1, 2, 0 ), + imath.V3f( 1, 1, 0 ), + imath.V3f( 0, 1, 0 ) ] ) @@ -95,19 +96,19 @@ def testOneHole( self ) : outer = IECore.V3fVectorData( [ - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 3, 0, 0 ), - IECore.V3f( 3, 3, 0 ), - IECore.V3f( 0, 3, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 3, 0, 0 ), + imath.V3f( 3, 3, 0 ), + imath.V3f( 0, 3, 0 ), ] ) inner = IECore.V3fVectorData( [ - IECore.V3f( 1, 1, 0 ), - IECore.V3f( 1, 2, 0 ), - IECore.V3f( 2, 2, 0 ), - IECore.V3f( 2, 1, 0 ), + imath.V3f( 1, 1, 0 ), + imath.V3f( 1, 2, 0 ), + imath.V3f( 2, 2, 0 ), + imath.V3f( 2, 1, 0 ), ] ) @@ -131,28 +132,28 @@ def testTwoHoles( self ) : outer = IECore.V3fVectorData( [ - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 5, 0, 0 ), - IECore.V3f( 5, 3, 0 ), - IECore.V3f( 0, 3, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 5, 0, 0 ), + imath.V3f( 5, 3, 0 ), + imath.V3f( 0, 3, 0 ), ] ) inner1 = IECore.V3fVectorData( [ - IECore.V3f( 1, 1, 0 ), - IECore.V3f( 1, 2, 0 ), - IECore.V3f( 2, 2, 0 ), - IECore.V3f( 2, 1, 0 ), + imath.V3f( 1, 1, 0 ), + imath.V3f( 1, 2, 0 ), + imath.V3f( 2, 2, 0 ), + imath.V3f( 2, 1, 0 ), ] ) inner2 = IECore.V3fVectorData( [ - IECore.V3f( 3, 1, 0 ), - IECore.V3f( 3, 2, 0 ), - IECore.V3f( 4, 2, 0 ), - IECore.V3f( 4, 1, 0 ), + imath.V3f( 3, 1, 0 ), + imath.V3f( 3, 2, 0 ), + imath.V3f( 4, 2, 0 ), + imath.V3f( 4, 1, 0 ), ] ) @@ -174,7 +175,7 @@ def testBigCircle( self ) : for i in range( 0, numPoints ) : t = i * math.pi * 2 / numPoints - loop[i] = IECore.V3f( math.cos( t ), math.sin( t ), 0 ) + loop[i] = imath.V3f( math.cos( t ), math.sin( t ), 0 ) builder = IECoreScene.MeshPrimitiveBuilder() triangulator = IECoreScene.V3fTriangulator( builder ) @@ -189,19 +190,19 @@ def testMultipleCalls( self ) : outline1 = IECore.V3fVectorData( [ - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 1, 0, 0 ), - IECore.V3f( 1, 1, 0 ), - IECore.V3f( 0, 1, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 1, 0, 0 ), + imath.V3f( 1, 1, 0 ), + imath.V3f( 0, 1, 0 ), ] ) outline2 = IECore.V3fVectorData( [ - IECore.V3f( 3, 0, 0 ), - IECore.V3f( 4, 0, 0 ), - IECore.V3f( 4, 1, 0 ), - IECore.V3f( 3, 1, 0 ), + imath.V3f( 3, 0, 0 ), + imath.V3f( 4, 0, 0 ), + imath.V3f( 4, 1, 0 ), + imath.V3f( 3, 1, 0 ), ] ) @@ -216,7 +217,7 @@ def testMultipleCalls( self ) : self.assertEqual( outMesh["P"].data.size(), 8 ) self.assertEqual( outMesh.verticesPerFace, IECore.IntVectorData( [ 3, 3, 3, 3 ] ) ) self.assertEqual( outMesh.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ), 8 ) - self.assertEqual( outMesh.bound(), IECore.Box3f( IECore.V3f( 0 ), IECore.V3f( 4, 1, 0 ) ) ) + self.assertEqual( outMesh.bound(), imath.Box3f( imath.V3f( 0 ), imath.V3f( 4, 1, 0 ) ) ) e = IECoreScene.PrimitiveEvaluator.create( outMesh ) self.assertEqual( e.surfaceArea(), 2 ) @@ -231,37 +232,37 @@ def testMultipleCallsWithHoles( self ) : outer1 = IECore.V3fVectorData( [ - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 3, 0, 0 ), - IECore.V3f( 3, 3, 0 ), - IECore.V3f( 0, 3, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 3, 0, 0 ), + imath.V3f( 3, 3, 0 ), + imath.V3f( 0, 3, 0 ), ] ) inner1 = IECore.V3fVectorData( [ - IECore.V3f( 1, 1, 0 ), - IECore.V3f( 1, 2, 0 ), - IECore.V3f( 2, 2, 0 ), - IECore.V3f( 2, 1, 0 ), + imath.V3f( 1, 1, 0 ), + imath.V3f( 1, 2, 0 ), + imath.V3f( 2, 2, 0 ), + imath.V3f( 2, 1, 0 ), ] ) outer2 = IECore.V3fVectorData( [ - IECore.V3f( 4, 0, 0 ), - IECore.V3f( 7, 0, 0 ), - IECore.V3f( 7, 3, 0 ), - IECore.V3f( 4, 3, 0 ), + imath.V3f( 4, 0, 0 ), + imath.V3f( 7, 0, 0 ), + imath.V3f( 7, 3, 0 ), + imath.V3f( 4, 3, 0 ), ] ) inner2 = IECore.V3fVectorData( [ - IECore.V3f( 5, 1, 0 ), - IECore.V3f( 5, 2, 0 ), - IECore.V3f( 6, 2, 0 ), - IECore.V3f( 6, 1, 0 ), + imath.V3f( 5, 1, 0 ), + imath.V3f( 5, 2, 0 ), + imath.V3f( 6, 2, 0 ), + imath.V3f( 6, 1, 0 ), ] ) @@ -275,7 +276,7 @@ def testMultipleCallsWithHoles( self ) : self.assertEqual( outMesh["P"].data.size(), 16 ) self.assertEqual( outMesh.variableSize( IECoreScene.PrimitiveVariable.Interpolation.Vertex ), 16 ) - self.assertEqual( outMesh.bound(), IECore.Box3f( IECore.V3f( 0 ), IECore.V3f( 7, 3, 0 ) ) ) + self.assertEqual( outMesh.bound(), imath.Box3f( imath.V3f( 0 ), imath.V3f( 7, 3, 0 ) ) ) e = IECoreScene.PrimitiveEvaluator.create( outMesh ) self.assertEqual( e.surfaceArea(), 16 ) @@ -291,28 +292,28 @@ def testRightAlignedHoles( self ) : outer = IECore.V3fVectorData( [ - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 3, 0, 0 ), - IECore.V3f( 3, 5, 0 ), - IECore.V3f( 0, 5, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 3, 0, 0 ), + imath.V3f( 3, 5, 0 ), + imath.V3f( 0, 5, 0 ), ] ) inner1 = IECore.V3fVectorData( [ - IECore.V3f( 1, 1, 0 ), - IECore.V3f( 1, 2, 0 ), - IECore.V3f( 2, 2, 0 ), - IECore.V3f( 2, 1, 0 ), + imath.V3f( 1, 1, 0 ), + imath.V3f( 1, 2, 0 ), + imath.V3f( 2, 2, 0 ), + imath.V3f( 2, 1, 0 ), ] ) inner2 = IECore.V3fVectorData( [ - IECore.V3f( 1, 3, 0 ), - IECore.V3f( 1, 4, 0 ), - IECore.V3f( 2, 4, 0 ), - IECore.V3f( 2, 3, 0 ), + imath.V3f( 1, 3, 0 ), + imath.V3f( 1, 4, 0 ), + imath.V3f( 2, 4, 0 ), + imath.V3f( 2, 3, 0 ), ] ) @@ -338,16 +339,16 @@ def testColinearities( self ) : outer = IECore.V3fVectorData( [ - IECore.V3f( 1, 1, 0 ), - IECore.V3f( 1, 2, 0 ), - IECore.V3f( 1, 3, 0 ), - IECore.V3f( 0.5, 3, 0 ), - IECore.V3f( 0, 3, 0 ), - IECore.V3f( 0, 2, 0 ), - IECore.V3f( 0, 1, 0 ), - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 0.5, 0, 0 ), - IECore.V3f( 1, 0, 0 ), + imath.V3f( 1, 1, 0 ), + imath.V3f( 1, 2, 0 ), + imath.V3f( 1, 3, 0 ), + imath.V3f( 0.5, 3, 0 ), + imath.V3f( 0, 3, 0 ), + imath.V3f( 0, 2, 0 ), + imath.V3f( 0, 1, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 0.5, 0, 0 ), + imath.V3f( 1, 0, 0 ), ] ) @@ -391,21 +392,21 @@ def testHoleAlignedWithVertex( self ) : outer = IECore.V3fVectorData( [ - IECore.V3f( 0, 0, 0 ), - IECore.V3f( 2, 0, 0 ), - IECore.V3f( 2, -1, 0 ), - IECore.V3f( 3, -1, 0 ), - IECore.V3f( 3, 3, 0 ), - IECore.V3f( 0, 3, 0 ), + imath.V3f( 0, 0, 0 ), + imath.V3f( 2, 0, 0 ), + imath.V3f( 2, -1, 0 ), + imath.V3f( 3, -1, 0 ), + imath.V3f( 3, 3, 0 ), + imath.V3f( 0, 3, 0 ), ] ) inner = IECore.V3fVectorData( [ - IECore.V3f( 1, 1, 0 ), - IECore.V3f( 1, 2, 0 ), - IECore.V3f( 2, 2, 0 ), - IECore.V3f( 2, 1, 0 ), + imath.V3f( 1, 1, 0 ), + imath.V3f( 1, 2, 0 ), + imath.V3f( 2, 2, 0 ), + imath.V3f( 2, 1, 0 ), ] ) diff --git a/test/IECoreScene/TypedPrimitiveOp.py b/test/IECoreScene/TypedPrimitiveOp.py index 9ee95ec352..8981b58d15 100644 --- a/test/IECoreScene/TypedPrimitiveOp.py +++ b/test/IECoreScene/TypedPrimitiveOp.py @@ -61,7 +61,7 @@ def testMeshPrimitiveOp( self ) : outputMesh = op( input = inputMesh ) - self.assert_( outputMesh.isInstanceOf( IECore.TypeId.MeshPrimitive ) ) + self.assert_( outputMesh.isInstanceOf( IECoreScene.TypeId.MeshPrimitive ) ) self.failIf( inputMesh is outputMesh ) self.assertEqual( inputMesh, outputMesh )