@@ -925,158 +925,6 @@ private static OutPt DisposeOutPt(OutPt op)
925925 return result ;
926926 }
927927
928- [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
929- private static BoundsF GetBounds ( OutPt op )
930- {
931- BoundsF result = new ( op . Point . X , op . Point . Y , op . Point . X , op . Point . Y ) ;
932- OutPt op2 = op . Next ;
933- while ( op2 != op )
934- {
935- if ( op2 . Point . X < result . Left )
936- {
937- result . Left = op2 . Point . X ;
938- }
939- else if ( op2 . Point . X > result . Right )
940- {
941- result . Right = op2 . Point . X ;
942- }
943-
944- if ( op2 . Point . Y < result . Top )
945- {
946- result . Top = op2 . Point . Y ;
947- }
948- else if ( op2 . Point . Y > result . Bottom )
949- {
950- result . Bottom = op2 . Point . Y ;
951- }
952-
953- op2 = op2 . Next ;
954- }
955-
956- return result ;
957- }
958-
959- private static PointInPolygonResult PointInOpPolygon ( Vector2 pt , OutPt op )
960- {
961- if ( op == op . Next || op . Prev == op . Next )
962- {
963- return PointInPolygonResult . IsOutside ;
964- }
965-
966- OutPt op2 = op ;
967- do
968- {
969- if ( op . Point . Y != pt . Y )
970- {
971- break ;
972- }
973-
974- op = op . Next ;
975- }
976- while ( op != op2 ) ;
977-
978- // not a proper polygon
979- if ( op . Point . Y == pt . Y )
980- {
981- return PointInPolygonResult . IsOutside ;
982- }
983-
984- // must be above or below to get here
985- bool isAbove = op . Point . Y < pt . Y , startingAbove = isAbove ;
986- int val = 0 ;
987-
988- op2 = op . Next ;
989- while ( op2 != op )
990- {
991- if ( isAbove )
992- {
993- while ( op2 != op && op2 . Point . Y < pt . Y )
994- {
995- op2 = op2 . Next ;
996- }
997- }
998- else
999- {
1000- while ( op2 != op && op2 . Point . Y > pt . Y )
1001- {
1002- op2 = op2 . Next ;
1003- }
1004- }
1005-
1006- if ( op2 == op )
1007- {
1008- break ;
1009- }
1010-
1011- // must have touched or crossed the pt.Y horizonal
1012- // and this must happen an even number of times
1013- // touching the horizontal
1014- if ( op2 . Point . Y == pt . Y )
1015- {
1016- if ( op2 . Point . X == pt . X || ( op2 . Point . Y == op2 . Prev . Point . Y
1017- && ( pt . X < op2 . Prev . Point . X ) != ( pt . X < op2 . Point . X ) ) )
1018- {
1019- return PointInPolygonResult . IsOn ;
1020- }
1021-
1022- op2 = op2 . Next ;
1023- if ( op2 == op )
1024- {
1025- break ;
1026- }
1027-
1028- continue ;
1029- }
1030-
1031- if ( op2 . Point . X <= pt . X || op2 . Prev . Point . X <= pt . X )
1032- {
1033- if ( op2 . Prev . Point . X < pt . X && op2 . Point . X < pt . X )
1034- {
1035- val = 1 - val ; // toggle val
1036- }
1037- else
1038- {
1039- float d = ClipperUtils . CrossProduct ( op2 . Prev . Point , op2 . Point , pt ) ;
1040- if ( d == 0 )
1041- {
1042- return PointInPolygonResult . IsOn ;
1043- }
1044-
1045- if ( ( d < 0 ) == isAbove )
1046- {
1047- val = 1 - val ;
1048- }
1049- }
1050- }
1051-
1052- isAbove = ! isAbove ;
1053- op2 = op2 . Next ;
1054- }
1055-
1056- if ( isAbove != startingAbove )
1057- {
1058- float d = ClipperUtils . CrossProduct ( op2 . Prev . Point , op2 . Point , pt ) ;
1059- if ( d == 0 )
1060- {
1061- return PointInPolygonResult . IsOn ;
1062- }
1063-
1064- if ( ( d < 0 ) == isAbove )
1065- {
1066- val = 1 - val ;
1067- }
1068- }
1069-
1070- if ( val == 0 )
1071- {
1072- return PointInPolygonResult . IsOutside ;
1073- }
1074- else
1075- {
1076- return PointInPolygonResult . IsInside ;
1077- }
1078- }
1079-
1080928 private void ProcessHorzJoins ( )
1081929 {
1082930 foreach ( HorzJoin j in this . horzJoinList )
@@ -1091,6 +939,7 @@ private void ProcessHorzJoins()
1091939 op1b . Prev = op2b ;
1092940 op2b . Next = op1b ;
1093941
942+ // 'join' is really a split
1094943 if ( or1 == or2 )
1095944 {
1096945 or2 = new OutRec
@@ -1179,7 +1028,6 @@ private void DoSplitOp(OutRec outrec, OutPt splitOp)
11791028 OutPt prevOp = splitOp . Prev ;
11801029 OutPt nextNextOp = splitOp . Next . Next ;
11811030 outrec . Pts = prevOp ;
1182- OutPt result = prevOp ;
11831031
11841032 ClipperUtils . GetIntersectPoint (
11851033 prevOp . Point , splitOp . Point , splitOp . Next . Point , nextNextOp . Point , out Vector2 ip ) ;
@@ -1193,11 +1041,6 @@ private void DoSplitOp(OutRec outrec, OutPt splitOp)
11931041 return ;
11941042 }
11951043
1196- // nb: area1 is the path's area *before* splitting, whereas area2 is
1197- // the area of the triangle containing splitOp & splitOp.next.
1198- // So the only way for these areas to have the same sign is if
1199- // the split triangle is larger than the path containing prevOp or
1200- // if there's more than one self=intersection.
12011044 float area2 = AreaTriangle ( ip , splitOp . Point , splitOp . Next . Point ) ;
12021045 float absArea2 = Math . Abs ( area2 ) ;
12031046
@@ -1220,6 +1063,11 @@ private void DoSplitOp(OutRec outrec, OutPt splitOp)
12201063 prevOp . Next = newOp2 ;
12211064 }
12221065
1066+ // nb: area1 is the path's area *before* splitting, whereas area2 is
1067+ // the area of the triangle containing splitOp & splitOp.next.
1068+ // So the only way for these areas to have the same sign is if
1069+ // the split triangle is larger than the path containing prevOp or
1070+ // if there's more than one self=intersection.
12231071 if ( absArea2 > 1 && ( absArea2 > absArea1 || ( ( area2 > 0 ) == ( area1 > 0 ) ) ) )
12241072 {
12251073 OutRec newOutRec = this . NewOutRec ( ) ;
0 commit comments