@@ -28,12 +28,6 @@ You should have received a copy of the GNU Lesser General Public
2828using System . Collections . Generic ;
2929using System . Linq ;
3030using System . Numerics ;
31- using System . Runtime . InteropServices ;
32- #if NETCOREAPP3_0_OR_GREATER
33- using System . Runtime . Intrinsics ;
34- using System . Runtime . Intrinsics . X86 ;
35- #endif
36- using System . Transactions ;
3731using static OpenVectorFormat . SIMDVectorOperations ;
3832
3933namespace OpenVectorFormat
@@ -442,67 +436,21 @@ public static RepeatedField<float> RawCoordinates(this VectorBlock vectorBlock)
442436 }
443437 }
444438
445- #if NETCOREAPP3_0_OR_GREATER
446- [ StructLayout ( LayoutKind . Sequential , Pack = 4 ) ]
447- private struct Vec256FromVec3
448- {
449- public Vector256 < float > vec256 ;
450- private float unused ;
451- }
452- #endif
453-
454439 private static void RotateVector2 ( RepeatedField < float > coordinates , float angleRad , int dims )
455440 {
456- if ( coordinates . Count % dims != 0 ) throw new ArgumentException ( $ "coordinates count is { coordinates . Count } but must be a multiple of { dims } ") ;
457-
458- #if NETCOREAPP3_0_OR_GREATER
459- if ( Avx2 . IsSupported & coordinates . Count > 80 * dims )
460- {
461- var coordSpan = ProtoUtils . AsSpan < float > ( coordinates ) ;
462- RotateAsVector2 ( coordSpan , angleRad , dims ) ;
463- return ;
464- }
465- #endif
466-
467- var sin = ( float ) Math . Sin ( angleRad ) ;
468- var cos = ( float ) Math . Cos ( angleRad ) ;
469- var nsin = - sin ;
470-
471- for ( int i = 0 ; i < coordinates . Count - 1 ; i += dims )
472- {
473- float xNew = coordinates [ i ] * cos + coordinates [ i + 1 ] * nsin ;
474- float yNew = coordinates [ i ] * sin + coordinates [ i + 1 ] * cos ;
475- coordinates [ i ] = xNew ; coordinates [ i + 1 ] = yNew ;
476- }
441+ var coordSpan = coordinates . AsSpan ( ) ;
442+ RotateAsVector2 ( coordSpan , angleRad , dims ) ;
477443 }
478444
479445 private static AxisAlignedBox2D Bounds2DFromCoordinates ( RepeatedField < float > coordinates , int dims )
480446 {
481447 if ( coordinates . Count == 0 )
482448 return AxisAlignedBox2DExtensions . EmptyAAB2D ( ) ;
483- else if ( coordinates . Count > 100 * dims )
449+ else
484450 {
485451 var coordSpan = coordinates . AsSpan ( ) ;
486452 return SIMDVectorOperations . Bounds2D ( coordSpan , dims ) ;
487453 }
488- else
489- {
490- var bounds = new AxisAlignedBox2D ( )
491- {
492- XMin = coordinates [ 0 ] ,
493- YMin = coordinates [ 1 ] ,
494- XMax = coordinates [ 0 ] ,
495- YMax = coordinates [ 1 ] ,
496- } ;
497- for ( int i = dims ; i < coordinates . Count - 1 ; i += dims )
498- {
499- if ( coordinates [ i ] < bounds . XMin ) bounds . XMin = coordinates [ i ] ;
500- if ( coordinates [ i + 1 ] < bounds . YMin ) bounds . YMin = coordinates [ i + 1 ] ;
501- if ( coordinates [ i ] > bounds . XMax ) bounds . XMax = coordinates [ i ] ;
502- if ( coordinates [ i + 1 ] > bounds . YMax ) bounds . YMax = coordinates [ i + 1 ] ;
503- }
504- return bounds ;
505- }
506454 }
507455
508456 /// <summary>
@@ -514,7 +462,6 @@ private static AxisAlignedBox2D Bounds2DFromCoordinates(RepeatedField<float> coo
514462 /// <returns></returns>
515463 public static List < Vector2 > ToVector2 ( this VectorBlock vectorBlock )
516464 {
517- var list = new List < Vector2 > ( ) ;
518465 switch ( vectorBlock . VectorDataCase )
519466 {
520467 case VectorBlock . VectorDataOneofCase . LineSequence :
@@ -556,7 +503,6 @@ public static List<Vector2> ToVector2(this VectorBlock vectorBlock)
556503 /// <returns></returns>
557504 public static List < Vector3 > ToVector3 ( this VectorBlock vectorBlock )
558505 {
559- var list = new List < Vector2 > ( ) ;
560506 switch ( vectorBlock . VectorDataCase )
561507 {
562508 case VectorBlock . VectorDataOneofCase . LineSequence :
0 commit comments