@@ -470,6 +470,41 @@ def testBSplineCurvesIndexedFaceVaryingToVarying( self ) :
470
470
self .assertEqual ( p .interpolation , IECoreScene .PrimitiveVariable .Interpolation .Varying )
471
471
self .assertEqual ( p .data , IECore .FloatVectorData ( range ( 0 , 3 ) ) )
472
472
self .assertEqual ( p .indices , IECore .IntVectorData ( [ 0 , 1 , 2 , 0 , 1 , 2 , 0 , 1 , 2 , 0 , 1 , 2 ] ) )
473
+
474
+ def testBSplineCurvesPeriodic ( self ) :
475
+ # Periodic curves are a corner case that we don't test much, but we should at least make sure that
476
+ # we produce valid primvars
477
+
478
+ curves = self .curvesBSpline ()
479
+ for q in [ "d" , "e" , "h" , "i" , "varying_Color_V3f" , "facevarying_Normal_V3f" ]:
480
+ del curves [q ]
481
+
482
+ curves .setTopology ( curves .verticesPerCurve (), curves .basis (), True )
483
+
484
+ p = IECoreScene .PrimitiveVariable ( IECoreScene .PrimitiveVariable .Interpolation .Uniform , curves ["c" ].data )
485
+ IECoreScene .CurvesAlgo .resamplePrimitiveVariable (curves , p , IECoreScene .PrimitiveVariable .Interpolation .Varying )
486
+
487
+ self .assertTrue ( curves .isPrimitiveVariableValid ( p ) )
488
+
489
+ IECoreScene .CurvesAlgo .resamplePrimitiveVariable (curves , p , IECoreScene .PrimitiveVariable .Interpolation .Uniform )
490
+ self .assertEqual ( curves ["c" ], p )
491
+
492
+ p = IECoreScene .PrimitiveVariable ( IECoreScene .PrimitiveVariable .Interpolation .Vertex , IECore .FloatVectorData ( [ i for i in range ( curves .variableSize ( IECoreScene .PrimitiveVariable .Interpolation .Vertex ) ) ] ) )
493
+
494
+ # Work around weird limitation that for resampling Varying -> Vertex the primvar must be stored on curves.
495
+ # Note that there may no longer be any reason for this limitation ( CurvesPrimitiveEvaluator looks like
496
+ # it should work fine with arbitrary prim vars ), but we're still doing something weird in
497
+ # CurvesVaryingToVertex in CurvesAlgo.cpp line 366
498
+ curves ["dummy" ] = p
499
+ IECoreScene .CurvesAlgo .resamplePrimitiveVariable (curves , p , IECoreScene .PrimitiveVariable .Interpolation .Varying )
500
+
501
+ self .assertTrue ( curves .isPrimitiveVariableValid ( p ) )
502
+
503
+ curves ["dummy" ] = p
504
+
505
+ IECoreScene .CurvesAlgo .resamplePrimitiveVariable (curves , p , IECoreScene .PrimitiveVariable .Interpolation .Vertex )
506
+ self .assertTrue ( curves .isPrimitiveVariableValid ( p ) )
507
+
473
508
# endregion
474
509
475
510
# region catmullrom
@@ -930,6 +965,56 @@ def testLinearCurvesFaceVaryingToVarying( self ) :
930
965
self .assertEqual ( p .interpolation , IECoreScene .PrimitiveVariable .Interpolation .Varying )
931
966
self .assertEqual ( p .data , IECore .FloatVectorData ( range ( 0 , 4 ) ) )
932
967
968
+ def testLinearCurvesPeriodic ( self ) :
969
+ # Periodic curves are a corner case that we don't test much, but we should at least make sure that
970
+ # we produce valid primvars
971
+
972
+ curves = IECoreScene .CurvesPrimitive (
973
+
974
+ IECore .IntVectorData ( [ 3 , 3 ] ),
975
+ IECore .CubicBasisf .linear (),
976
+ True ,
977
+ IECore .V3fVectorData (
978
+ [
979
+ imath .V3f ( 0 , 0 , 0 ),
980
+ imath .V3f ( 0 , 1 , 0 ),
981
+ imath .V3f ( 0 , 0 , 1 ),
982
+ imath .V3f ( 0 , 0 , 0 ),
983
+ imath .V3f ( 1 , 0 , 0 ),
984
+ imath .V3f ( 0 , 0 , 1 )
985
+ ]
986
+ )
987
+ )
988
+
989
+ curves ["c" ] = IECoreScene .PrimitiveVariable ( IECoreScene .PrimitiveVariable .Interpolation .Uniform , IECore .FloatVectorData ( range ( 0 , 2 ) ) )
990
+
991
+ p = IECoreScene .PrimitiveVariable ( IECoreScene .PrimitiveVariable .Interpolation .Uniform , curves ["c" ].data )
992
+ IECoreScene .CurvesAlgo .resamplePrimitiveVariable (curves , p , IECoreScene .PrimitiveVariable .Interpolation .Varying )
993
+
994
+ self .assertTrue ( curves .isPrimitiveVariableValid ( p ) )
995
+
996
+ IECoreScene .CurvesAlgo .resamplePrimitiveVariable (curves , p , IECoreScene .PrimitiveVariable .Interpolation .Uniform )
997
+ self .assertEqual ( curves ["c" ], p )
998
+
999
+ origP = IECoreScene .PrimitiveVariable ( IECoreScene .PrimitiveVariable .Interpolation .Vertex , IECore .FloatVectorData ( [ i for i in range ( curves .variableSize ( IECoreScene .PrimitiveVariable .Interpolation .Vertex ) ) ] ) )
1000
+ p = IECoreScene .PrimitiveVariable ( IECoreScene .PrimitiveVariable .Interpolation .Vertex , origP .data )
1001
+
1002
+ # Work around weird limitation that for resampling Varying -> Vertex the primvar must be stored on curves
1003
+ curves ["dummy" ] = p
1004
+ IECoreScene .CurvesAlgo .resamplePrimitiveVariable (curves , p , IECoreScene .PrimitiveVariable .Interpolation .Varying )
1005
+
1006
+ self .assertTrue ( curves .isPrimitiveVariableValid ( p ) )
1007
+
1008
+ # Linear curves are a special case where the data shouldn't actually change when resampling from Vertex
1009
+ # to Varying
1010
+ self .assertEqual ( p .data , origP .data )
1011
+
1012
+ curves ["dummy" ] = p
1013
+
1014
+ IECoreScene .CurvesAlgo .resamplePrimitiveVariable (curves , p , IECoreScene .PrimitiveVariable .Interpolation .Vertex )
1015
+ self .assertTrue ( curves .isPrimitiveVariableValid ( p ) )
1016
+ self .assertEqual ( p .data , origP .data )
1017
+
933
1018
def testCanSegmentUsingIntegerPrimvar ( self ) :
934
1019
curves = self .curvesLinear ()
935
1020
0 commit comments