From 200d9af299797763135939b42045063a68ed9e7e Mon Sep 17 00:00:00 2001 From: John Haddon Date: Tue, 25 Aug 2026 16:57:05 +0100 Subject: [PATCH] Alembic PrimitiveReader : Support double vectors --- .../src/IECoreAlembic/PrimitiveReader.cpp | 34 +++++++++++------ .../test/IECoreAlembic/AlembicSceneTest.py | 37 +++++++++++++++++++ 2 files changed, 59 insertions(+), 12 deletions(-) diff --git a/contrib/IECoreAlembic/src/IECoreAlembic/PrimitiveReader.cpp b/contrib/IECoreAlembic/src/IECoreAlembic/PrimitiveReader.cpp index 69b3bf8f7d..a2573adb97 100644 --- a/contrib/IECoreAlembic/src/IECoreAlembic/PrimitiveReader.cpp +++ b/contrib/IECoreAlembic/src/IECoreAlembic/PrimitiveReader.cpp @@ -67,11 +67,6 @@ void PrimitiveReader::readArbGeomParams( const Alembic::Abc::ICompoundProperty & IDoubleGeomParam p( params, header.getName() ); readGeomParam( p, sampleSelector, primitive ); } - else if( IV3dGeomParam::matches( header ) ) - { - IV3dGeomParam p( params, header.getName() ); - readGeomParam( p, sampleSelector, primitive ); - } else if( IUcharGeomParam::matches( header ) ) { IUcharGeomParam p( params, header.getName() ); @@ -107,11 +102,6 @@ void PrimitiveReader::readArbGeomParams( const Alembic::Abc::ICompoundProperty & IV2fGeomParam p( params, header.getName() ); readGeomParam( p, sampleSelector, primitive ); } - else if( IV3fGeomParam::matches( header ) ) - { - IV3fGeomParam p( params, header.getName() ); - readGeomParam( p, sampleSelector, primitive ); - } else if( IC3fGeomParam::matches( header ) ) { IC3fGeomParam p( params, header.getName() ); @@ -122,14 +112,34 @@ void PrimitiveReader::readArbGeomParams( const Alembic::Abc::ICompoundProperty & IC4fGeomParam p( params, header.getName() ); readGeomParam( p, sampleSelector, primitive ); } + else if( IP3fGeomParam::matches( header ) ) + { + IP3fGeomParam p( params, header.getName() ); + readGeomParam( p, sampleSelector, primitive ); + } + else if( IV3fGeomParam::matches( header ) ) + { + IV3fGeomParam p( params, header.getName() ); + readGeomParam( p, sampleSelector, primitive ); + } else if( IN3fGeomParam::matches( header ) ) { IN3fGeomParam p( params, header.getName() ); readGeomParam( p, sampleSelector, primitive ); } - else if( IP3fGeomParam::matches( header ) ) + else if( IP3dGeomParam::matches( header ) ) { - IP3fGeomParam p( params, header.getName() ); + IP3dGeomParam p( params, header.getName() ); + readGeomParam( p, sampleSelector, primitive ); + } + else if( IV3dGeomParam::matches( header ) ) + { + IV3dGeomParam p( params, header.getName() ); + readGeomParam( p, sampleSelector, primitive ); + } + else if( IN3dGeomParam::matches( header ) ) + { + IN3dGeomParam p( params, header.getName() ); readGeomParam( p, sampleSelector, primitive ); } else if( IM44fGeomParam::matches( header ) ) diff --git a/contrib/IECoreAlembic/test/IECoreAlembic/AlembicSceneTest.py b/contrib/IECoreAlembic/test/IECoreAlembic/AlembicSceneTest.py index 8f34b9f16e..3cc171db12 100644 --- a/contrib/IECoreAlembic/test/IECoreAlembic/AlembicSceneTest.py +++ b/contrib/IECoreAlembic/test/IECoreAlembic/AlembicSceneTest.py @@ -2039,5 +2039,42 @@ def testArbGeomParamTypes( self ) : for name in points.keys() : self.assertEqual( points2[name], points[name] ) + def testV3dVectorDataPrimitiveVariable( self ) : + + points = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ imath.V3f( i ) for i in range( 0, 2 ) ] ) ) + + points["point"] = IECoreScene.PrimitiveVariable( + IECoreScene.PrimitiveVariable.Interpolation.Vertex, + IECore.V3dVectorData( + [ imath.V3d( i, i + 1, i + 2 ) for i in range( 0, 2 ) ], + IECore.GeometricData.Interpretation.Point + ) + ) + points["vector"] = IECoreScene.PrimitiveVariable( + IECoreScene.PrimitiveVariable.Interpolation.Vertex, + IECore.V3dVectorData( + [ imath.V3d( i, i * 2, i * 3 ) for i in range( 0, 2 ) ], + IECore.GeometricData.Interpretation.Vector + ) + ) + points["normal"] = IECoreScene.PrimitiveVariable( + IECoreScene.PrimitiveVariable.Interpolation.Vertex, + IECore.V3dVectorData( + [ imath.V3d( i, i - 1, i - 2 ) for i in range( 0, 2 ) ], + IECore.GeometricData.Interpretation.Normal + ) + ) + + fileName = os.path.join( self.temporaryDirectory(), "doubleVector.abc" ) + root = IECoreScene.SceneInterface.create( fileName, IECore.IndexedIO.OpenMode.Write ) + root.createChild( "object" ).writeObject( points, 0 ) + del root + + root = IECoreScene.SceneInterface.create( fileName, IECore.IndexedIO.OpenMode.Read ) + points2 = root.child( "object" ).readObject( 0 ) + self.assertEqual( points2["point"], points["point"] ) + self.assertEqual( points2["vector"], points["vector"] ) + self.assertEqual( points2["normal"], points["normal"] ) + if __name__ == "__main__": unittest.main()