@@ -1108,6 +1108,25 @@ describe('#Flatten.Polygon', function() {
11081108 console . error ( 'Cut fail.' )
11091109 }
11101110 } )
1111+ it ( 'Self-intersecting output when cutting a multipolygon with a multiline #205' , ( ) => {
1112+ const input = new Polygon ( [ [
1113+ { "ps" :{ "x" :0 , "y" :0 , "name" :"point" } , "pe" :{ "x" :0 , "y" :50 , "name" :"point" } , "name" :"segment" } ,
1114+ { "ps" :{ "x" :0 , "y" :50 , "name" :"point" } , "pe" :{ "x" :100 , "y" :50 , "name" :"point" } , "name" :"segment" } ,
1115+ { "ps" :{ "x" :100 , "y" :50 , "name" :"point" } , "pe" :{ "x" :100 , "y" :0 , "name" :"point" } , "name" :"segment" } ,
1116+ { "ps" :{ "x" :100 , "y" :0 , "name" :"point" } , "pe" :{ "x" :0 , "y" :0 , "name" :"point" } , "name" :"segment" }
1117+ ] , [
1118+ { "ps" :{ "x" :0 , "y" :50 , "name" :"point" } , "pe" :{ "x" :0 , "y" :100 , "name" :"point" } , "name" :"segment" } ,
1119+ { "ps" :{ "x" :0 , "y" :100 , "name" :"point" } , "pe" :{ "x" :100 , "y" :100 , "name" :"point" } , "name" :"segment" } ,
1120+ { "ps" :{ "x" :100 , "y" :100 , "name" :"point" } , "pe" :{ "x" :100 , "y" :50 , "name" :"point" } , "name" :"segment" } ,
1121+ { "ps" :{ "x" :100 , "y" :50 , "name" :"point" } , "pe" :{ "x" :0 , "y" :50 , "name" :"point" } , "name" :"segment" }
1122+ ] ] )
1123+ const cutline = new Multiline ( [
1124+ new Segment ( point ( 50 , 110 ) , point ( 50 , - 10 ) )
1125+ ] )
1126+ const result = input . cut ( cutline )
1127+ expect ( result . faces . size ) . to . equal ( 4 )
1128+ expect ( result . edges . size ) . to . equal ( 16 )
1129+ } )
11111130 describe ( '#Intersections' , function ( ) {
11121131 it ( 'Can perform intersection between polygons' , function ( ) {
11131132 const poly1 = new Polygon (
0 commit comments