Skip to content

Use Imath bindings from PyIlmBase #672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Dec 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6925133
BoxAlgo : Add BoxAlgo namespace
johnhaddon Dec 12, 2017
c7cab50
BoxAlgo : Add split and contains functions
johnhaddon Dec 12, 2017
e77adad
IECore : Move Random.h to RandomAlgo.h and add namespace
johnhaddon Dec 13, 2017
0c54814
IECore : Remove import *
johnhaddon Dec 1, 2017
061ffa1
Remove Color3d/Color4d data types
johnhaddon Dec 8, 2017
877c24c
SConstruct : Add PYTHONPATH argument
johnhaddon Dec 10, 2017
947405b
Remove Imath bindings
johnhaddon Nov 29, 2017
4f30dc8
DataTraits : Remove isMatrixTypeData
johnhaddon Dec 10, 2017
b1bbf81
9to10 : Add fixes for IECore->imath transition
johnhaddon Dec 1, 2017
ae40e2b
IECore module : Use imath
johnhaddon Dec 1, 2017
dbaac40
IECore tests : Use Imath
johnhaddon Dec 1, 2017
e09456f
IECoreImage tests : Use imath
johnhaddon Dec 11, 2017
0606ec8
IECoreScene : Remove PointsExpressionOp
johnhaddon Dec 11, 2017
04467e1
IECoreScene : Use imath
johnhaddon Dec 11, 2017
0327cdf
IECoreScene tests : Use imath
johnhaddon Dec 11, 2017
cf5e0fd
IECoreMaya tests : Update for imath
johnhaddon Dec 12, 2017
a419fa4
IECoreAlembic tests : Update to use imath module
johnhaddon Dec 12, 2017
0e0745c
IECoreGL tests : Use imath
johnhaddon Dec 11, 2017
f09122b
SimpleTypedDataBinding : Reorder bindings to fix Color3fData extraction
johnhaddon Dec 12, 2017
fa25927
IECoreUSD tests : Update for imath module
johnhaddon Dec 14, 2017
3b844cc
IECoreArnold tests : Update to use imath module
johnhaddon Dec 14, 2017
562052f
IECoreAppleseed tests : Update to use imath module
johnhaddon Dec 14, 2017
a640305
IECoreHoudini : Update to use imath module
johnhaddon Dec 14, 2017
4f4813c
IECoreNuke : Update to use imath module
johnhaddon Dec 15, 2017
446b648
IE config : Add path to imath module
johnhaddon Dec 11, 2017
f2a4112
Travis : Use prepackaged dependencies from GafferHQ
johnhaddon Dec 19, 2017
2e74d51
IECore module : Bind `repr()`
johnhaddon Dec 21, 2017
15730b0
IECoreBinding : Simplify repr() for empty boxes
johnhaddon Dec 21, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 6 additions & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ o.Add(
"/usr/lib",
)

o.Add(
"PYTHONPATH",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit funny that it's named generically but only used for tests. Don't we add TEST_ to other variables like that. Are you thinking of using it outside the tests as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure which way to go, but it seemed plausible that we'd use it for other things, and I thought having a matching set of CPPPATH, LIBPATH and PYTHONPATH made sense. Not particularly attached to it though if you feel strongly about it.

"A colon separated list of paths to search for python modules on.",
"",
)

# Python options

Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion config/ie/options
Original file line number Diff line number Diff line change
Expand Up @@ -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( "~" ) )
Expand Down
72 changes: 72 additions & 0 deletions config/travis/installDependencies.py
Original file line number Diff line number Diff line change
@@ -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 )
59 changes: 30 additions & 29 deletions contrib/IECoreAlembic/test/IECoreAlembic/AlembicInputTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import os
import math
import unittest
import imath

import IECore
import IECoreScene
Expand Down Expand Up @@ -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 ) :

Expand Down Expand Up @@ -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 ),
] )
)

Expand Down Expand Up @@ -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 ) :

Expand All @@ -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 ) :
Expand All @@ -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 ) :
Expand All @@ -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 ) :
Expand All @@ -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 ) :

Expand All @@ -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
Expand All @@ -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 ) :

Expand Down Expand Up @@ -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
)
)
Expand Down
Loading