Skip to content

Commit f7e050e

Browse files
Merge pull request #1554 from johnhaddon/alembicDoubles
Alembic PrimitiveReader : Support double vectors
2 parents fc59149 + 200d9af commit f7e050e

2 files changed

Lines changed: 59 additions & 12 deletions

File tree

contrib/IECoreAlembic/src/IECoreAlembic/PrimitiveReader.cpp

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,6 @@ void PrimitiveReader::readArbGeomParams( const Alembic::Abc::ICompoundProperty &
6767
IDoubleGeomParam p( params, header.getName() );
6868
readGeomParam( p, sampleSelector, primitive );
6969
}
70-
else if( IV3dGeomParam::matches( header ) )
71-
{
72-
IV3dGeomParam p( params, header.getName() );
73-
readGeomParam( p, sampleSelector, primitive );
74-
}
7570
else if( IUcharGeomParam::matches( header ) )
7671
{
7772
IUcharGeomParam p( params, header.getName() );
@@ -107,11 +102,6 @@ void PrimitiveReader::readArbGeomParams( const Alembic::Abc::ICompoundProperty &
107102
IV2fGeomParam p( params, header.getName() );
108103
readGeomParam( p, sampleSelector, primitive );
109104
}
110-
else if( IV3fGeomParam::matches( header ) )
111-
{
112-
IV3fGeomParam p( params, header.getName() );
113-
readGeomParam( p, sampleSelector, primitive );
114-
}
115105
else if( IC3fGeomParam::matches( header ) )
116106
{
117107
IC3fGeomParam p( params, header.getName() );
@@ -122,14 +112,34 @@ void PrimitiveReader::readArbGeomParams( const Alembic::Abc::ICompoundProperty &
122112
IC4fGeomParam p( params, header.getName() );
123113
readGeomParam( p, sampleSelector, primitive );
124114
}
115+
else if( IP3fGeomParam::matches( header ) )
116+
{
117+
IP3fGeomParam p( params, header.getName() );
118+
readGeomParam( p, sampleSelector, primitive );
119+
}
120+
else if( IV3fGeomParam::matches( header ) )
121+
{
122+
IV3fGeomParam p( params, header.getName() );
123+
readGeomParam( p, sampleSelector, primitive );
124+
}
125125
else if( IN3fGeomParam::matches( header ) )
126126
{
127127
IN3fGeomParam p( params, header.getName() );
128128
readGeomParam( p, sampleSelector, primitive );
129129
}
130-
else if( IP3fGeomParam::matches( header ) )
130+
else if( IP3dGeomParam::matches( header ) )
131131
{
132-
IP3fGeomParam p( params, header.getName() );
132+
IP3dGeomParam p( params, header.getName() );
133+
readGeomParam( p, sampleSelector, primitive );
134+
}
135+
else if( IV3dGeomParam::matches( header ) )
136+
{
137+
IV3dGeomParam p( params, header.getName() );
138+
readGeomParam( p, sampleSelector, primitive );
139+
}
140+
else if( IN3dGeomParam::matches( header ) )
141+
{
142+
IN3dGeomParam p( params, header.getName() );
133143
readGeomParam( p, sampleSelector, primitive );
134144
}
135145
else if( IM44fGeomParam::matches( header ) )

contrib/IECoreAlembic/test/IECoreAlembic/AlembicSceneTest.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,5 +2039,42 @@ def testArbGeomParamTypes( self ) :
20392039
for name in points.keys() :
20402040
self.assertEqual( points2[name], points[name] )
20412041

2042+
def testV3dVectorDataPrimitiveVariable( self ) :
2043+
2044+
points = IECoreScene.PointsPrimitive( IECore.V3fVectorData( [ imath.V3f( i ) for i in range( 0, 2 ) ] ) )
2045+
2046+
points["point"] = IECoreScene.PrimitiveVariable(
2047+
IECoreScene.PrimitiveVariable.Interpolation.Vertex,
2048+
IECore.V3dVectorData(
2049+
[ imath.V3d( i, i + 1, i + 2 ) for i in range( 0, 2 ) ],
2050+
IECore.GeometricData.Interpretation.Point
2051+
)
2052+
)
2053+
points["vector"] = IECoreScene.PrimitiveVariable(
2054+
IECoreScene.PrimitiveVariable.Interpolation.Vertex,
2055+
IECore.V3dVectorData(
2056+
[ imath.V3d( i, i * 2, i * 3 ) for i in range( 0, 2 ) ],
2057+
IECore.GeometricData.Interpretation.Vector
2058+
)
2059+
)
2060+
points["normal"] = IECoreScene.PrimitiveVariable(
2061+
IECoreScene.PrimitiveVariable.Interpolation.Vertex,
2062+
IECore.V3dVectorData(
2063+
[ imath.V3d( i, i - 1, i - 2 ) for i in range( 0, 2 ) ],
2064+
IECore.GeometricData.Interpretation.Normal
2065+
)
2066+
)
2067+
2068+
fileName = os.path.join( self.temporaryDirectory(), "doubleVector.abc" )
2069+
root = IECoreScene.SceneInterface.create( fileName, IECore.IndexedIO.OpenMode.Write )
2070+
root.createChild( "object" ).writeObject( points, 0 )
2071+
del root
2072+
2073+
root = IECoreScene.SceneInterface.create( fileName, IECore.IndexedIO.OpenMode.Read )
2074+
points2 = root.child( "object" ).readObject( 0 )
2075+
self.assertEqual( points2["point"], points["point"] )
2076+
self.assertEqual( points2["vector"], points["vector"] )
2077+
self.assertEqual( points2["normal"], points["normal"] )
2078+
20422079
if __name__ == "__main__":
20432080
unittest.main()

0 commit comments

Comments
 (0)