@@ -170,16 +170,29 @@ def accumulateInPython2( iterable ):
170170 newVerticesPerFace = []
171171 newVertIndices = []
172172 mapFaceVert = []
173- reverseIndices = []
173+
174+ usedIndices = set ()
174175 for i in r :
175176 vpf = mesh .verticesPerFace [i ]
176177 newVerticesPerFace .append ( vpf )
177178 for j in range ( vpf ):
178179 origFaceVert = faceIndices [i ] + j
179180 origVert = mesh .vertexIds [ origFaceVert ]
180- newIndex = reindex .setdefault ( origVert , len ( reindex ) )
181- if len ( reindex ) > len ( reverseIndices ):
182- reverseIndices .append ( origVert )
181+
182+ usedIndices .add ( origVert )
183+
184+ usedIndices = sorted ( usedIndices )
185+
186+ for i in range ( len ( usedIndices ) ):
187+ reindex [ usedIndices [i ] ] = i
188+
189+ for i in r :
190+ vpf = mesh .verticesPerFace [i ]
191+ for j in range ( vpf ):
192+ origFaceVert = faceIndices [i ] + j
193+ origVert = mesh .vertexIds [ origFaceVert ]
194+
195+ newIndex = usedIndices .index ( origVert )
183196 newVertIndices .append ( newIndex )
184197 mapFaceVert .append ( origFaceVert )
185198
@@ -226,7 +239,7 @@ def accumulateInPython2( iterable ):
226239 if p .interpolation == interp .Constant :
227240 d = p .data .copy ()
228241 elif p .interpolation in [ interp .Vertex , interp .Varying ]:
229- d = type ( p .data )( [ pd [i ] for i in reverseIndices ] )
242+ d = type ( p .data )( [ pd [i ] for i in usedIndices ] )
230243 elif p .interpolation == interp .FaceVarying :
231244 d = type ( p .data )( [ pd [i ] for i in mapFaceVert ] )
232245 elif p .interpolation == interp .Uniform :
@@ -269,8 +282,8 @@ def testCanSplitUsingIntegerPrimvar( self ) :
269282 p12 = imath .V3f ( 1 , 2 , 0 )
270283 p22 = imath .V3f ( 2 , 2 , 0 )
271284
272- self .assertEqual ( s0 ["P" ].data , IECore .V3fVectorData ( [p00 , p10 , p11 , p01 , p20 , p21 ], IECore .GeometricData .Interpretation .Point ) )
273- self .assertEqual ( s1 ["P" ].data , IECore .V3fVectorData ( [p01 , p11 , p12 , p02 , p21 , p22 ], IECore .GeometricData .Interpretation .Point ) )
285+ self .assertEqual ( s0 ["P" ].data , IECore .V3fVectorData ( [p00 , p10 , p20 , p01 , p11 , p21 ], IECore .GeometricData .Interpretation .Point ) )
286+ self .assertEqual ( s1 ["P" ].data , IECore .V3fVectorData ( [p01 , p11 , p21 , p02 , p12 , p22 ], IECore .GeometricData .Interpretation .Point ) )
274287
275288 def testSplitsFully ( self ) :
276289 mesh = IECoreScene .MeshPrimitive .createPlane ( imath .Box2f ( imath .V2f ( 0 ), imath .V2f ( 2 ) ), imath .V2i ( 2 ) )
@@ -303,8 +316,8 @@ def testSplitsFully( self ) :
303316 if s0 ["s" ].data [0 ] != 'a' :
304317 s0 ,s1 = s1 ,s0
305318
306- self .assertEqual ( s0 ["P" ].data , IECore .V3fVectorData ( [p00 , p10 , p11 , p01 , p21 , p22 , p12 ], IECore .GeometricData .Interpretation .Point ) )
307- self .assertEqual ( s1 ["P" ].data , IECore .V3fVectorData ( [p10 , p20 , p21 , p11 , p01 , p12 , p02 ], IECore .GeometricData .Interpretation .Point ) )
319+ self .assertEqual ( s0 ["P" ].data , IECore .V3fVectorData ( [p00 , p10 , p01 , p11 , p21 , p12 , p22 ], IECore .GeometricData .Interpretation .Point ) )
320+ self .assertEqual ( s1 ["P" ].data , IECore .V3fVectorData ( [p10 , p20 , p01 , p11 , p21 , p02 , p12 ], IECore .GeometricData .Interpretation .Point ) )
308321
309322 def testSplitUsingIndexedPrimitiveVariable ( self ) :
310323
0 commit comments