Skip to content

Commit

Permalink
IECoreUSD : Alembic referenced in a USD stage places the indices of a…
Browse files Browse the repository at this point in the history
…n indexed primitive variable into an attribute
  • Loading branch information
boberfly committed Apr 20, 2024
1 parent 5dedde4 commit 16a16d9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
24 changes: 24 additions & 0 deletions contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4001,5 +4001,29 @@ def testRoundTripArnoldLight( self ) :
self.assertIn( "__lights", root.setNames() )
self.assertEqual( root.readSet( "__lights" ), IECore.PathMatcher( [ "/light" ] ) )

def testAlembicIndices( self ) :

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

cube = root.child( "cube" )
self.assertEqual( cube.attributeNames(), [] )
self.assertFalse( cube.hasAttribute( "primvars:custom:indices" ) )

primitive = cube.readObject( 1.0 )
self.assertEqual(
set( primitive.keys() ),
{ "P", "N", "uv", "custom" }
)
comparison = IECoreScene.PrimitiveVariable(
IECoreScene.PrimitiveVariable.Interpolation.FaceVarying,
IECore.Color3fVectorData(
[ imath.Color3f( 1, 0, 0 ), imath.Color3f( 0, 1, 0 ), imath.Color3f( 0, 0, 1 ),
imath.Color3f( 1, 1, 0 ), imath.Color3f( 0, 1, 1 ), imath.Color3f( 1, 1, 1 ) ]
),
IECore.IntVectorData( [ 1, 1, 1, 1, 4, 4, 4, 4, 0, 0, 0, 0, 5, 5, 5, 5, 2, 2, 2, 2, 3, 3, 3, 3 ] )
)
self.assertEqual( primitive["custom"], comparison )
self.assertEqual( primitive["custom"].indices(), comparison.indices() )

if __name__ == "__main__":
unittest.main()
Binary file not shown.
8 changes: 8 additions & 0 deletions contrib/IECoreUSD/test/IECoreUSD/data/alembicIndices.usda
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#usda 1.0

def Mesh "cube" (
references = @./alembicIndices.abc@
)
{
}

0 comments on commit 16a16d9

Please sign in to comment.