@@ -751,5 +751,90 @@ public void TestPointNormalization()
751751 }
752752
753753 #endregion
754+
755+ #region Contour Generation Tests
756+
757+ [ Test ]
758+ public void TestMakeContour_10UnitEdge_VerifyAdaptiveRadiusFix ( )
759+ {
760+ // Arrange: Create the exact polygon from the problem statement
761+ var original_path = new Clipper2Lib . PathD ( )
762+ {
763+ new Clipper2Lib . PointD ( 0 , 0 ) ,
764+ new Clipper2Lib . PointD ( 0 , 60 ) ,
765+ new Clipper2Lib . PointD ( 20 , 60 ) ,
766+ new Clipper2Lib . PointD ( 20 , 10 ) ,
767+ new Clipper2Lib . PointD ( 60 , 10 ) ,
768+ new Clipper2Lib . PointD ( 60 , 0 ) ,
769+ new Clipper2Lib . PointD ( 0 , 0 ) // Close the path
770+ } ;
771+
772+ double concaveRadius = 30 ;
773+ double convexRadius = 30 ;
774+ double edgeResolution = 1 ;
775+ double angularResolution = 1 ;
776+ double shortEdgeLength = 0.01 ;
777+ double maxShortEdgeLength = 0.01 ;
778+
779+ // Act
780+ var result = shapeEngine . contourGen . makeContour ( original_path , concaveRadius , convexRadius ,
781+ edgeResolution , angularResolution , shortEdgeLength , maxShortEdgeLength ) ;
782+
783+ // Assert: The result should have smooth curves applied
784+ Assert . That ( result . Count , Is . GreaterThan ( 7 ) , "Result should have more points than input due to curve sampling" ) ;
785+
786+ // The fix ensures that normal 10-unit edges get appropriate treatment
787+ // The edge from (60,10) to (60,0) is 10 units, much longer than shortEdgeLength=0.01
788+ // With the adaptive radius fix, this should receive proper Bezier curve treatment
789+
790+ // Verify the result has a reasonable number of points (not too few, not too many)
791+ Console . WriteLine ( $ "Result points: { result . Count } ") ;
792+ Assert . That ( result . Count , Is . InRange ( 30 , 150 ) ,
793+ "Result should have a reasonable number of curve points indicating proper radius application" ) ;
794+ }
795+
796+ [ Test ]
797+ public void TestMakeContour_18UnitEdge_ShouldWorkCorrectly ( )
798+ {
799+ // Arrange: Create a polygon where the problematic edge is 18 units (reported to work)
800+ var original_path = new Clipper2Lib . PathD ( )
801+ {
802+ new Clipper2Lib . PointD ( 0 , 0 ) ,
803+ new Clipper2Lib . PointD ( 0 , 60 ) ,
804+ new Clipper2Lib . PointD ( 20 , 60 ) ,
805+ new Clipper2Lib . PointD ( 20 , 18 ) , // Changed from 10 to 18
806+ new Clipper2Lib . PointD ( 60 , 18 ) , // Changed from 10 to 18
807+ new Clipper2Lib . PointD ( 60 , 0 ) ,
808+ new Clipper2Lib . PointD ( 0 , 0 )
809+ } ;
810+
811+ double concaveRadius = 30 ;
812+ double convexRadius = 30 ;
813+ double edgeResolution = 1 ;
814+ double angularResolution = 1 ;
815+ double shortEdgeLength = 0.01 ;
816+ double maxShortEdgeLength = 0.01 ;
817+
818+ // Act
819+ var result = shapeEngine . contourGen . makeContour ( original_path , concaveRadius , convexRadius ,
820+ edgeResolution , angularResolution , shortEdgeLength , maxShortEdgeLength ) ;
821+
822+ // Assert: This should work correctly according to the problem statement
823+ Assert . That ( result . Count , Is . GreaterThan ( 7 ) , "Result should have curved points" ) ;
824+
825+ // The 18-unit edge should get proper rounding
826+ var pointsNearCorner = new List < Clipper2Lib . PointD > ( ) ;
827+ foreach ( var point in result )
828+ {
829+ if ( Math . Abs ( point . x - 60 ) < 35 && Math . Abs ( point . y - 0 ) < 35 )
830+ {
831+ pointsNearCorner . Add ( point ) ;
832+ }
833+ }
834+
835+ Assert . That ( pointsNearCorner . Count , Is . GreaterThan ( 0 ) , "Should have points near the corner" ) ;
836+ }
837+
838+ #endregion
754839 }
755840}
0 commit comments