UNPKG

@avdl/martinez

Version:

TypeScript library for polygon boolean operations

3 lines (2 loc) 21 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(){function t(t,e){this.beginPoint=t,this.endPoint=e}var e=t.prototype;return e.begin=function(){return this.beginPoint},e.end=function(){return this.endPoint},t}(),e=function(){function e(t){void 0===t&&(t=[]),this.points=[],this.holeOf=null,this.holeIds=[],this.depth=0,this.points=[].concat(t)}var n=e.prototype;return n.nvertices=function(){return this.points.length},n.segment=function(e){return new t(this.points[e],this.points[(e+1)%this.points.length])},n.addPoint=function(t){this.points.push(t)},n.getPoints=function(){return[].concat(this.points)},n.setPoints=function(t){this.points=[].concat(t)},n.setHoleOf=function(t){this.holeOf=t},n.getHoleOf=function(){return this.holeOf},n.addHole=function(t){this.holeIds.push(t)},n.getHoles=function(){return[].concat(this.holeIds)},n.setDepth=function(t){this.depth=t},n.getDepth=function(){return this.depth},n.isHole=function(){return null!==this.holeOf},e}();function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function i(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,r(i.key),i)}}function o(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t,e){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(i)return(i=i.call(t)).next.bind(i);if(Array.isArray(t)||(i=function(t,e){if(t){if("string"==typeof t)return n(t,e);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?n(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var o=0;return function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function r(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}var p,h,u,a=function(){function t(t){void 0===t&&(t=[]),this.contours=[],this.contours=[].concat(t)}var n=t.prototype;return n.contourCount=function(){return this.contours.length},n.contour=function(t){return this.contours[t]},n.boundingbox=function(t,e){if(0!==this.contours.length){for(var n,i=Infinity,o=Infinity,r=-Infinity,p=-Infinity,h=s(this.contours);!(n=h()).done;)for(var u=n.value,a=0;a<u.nvertices();a++){var l=u.segment(a),y=l.begin(),g=l.end();i=Math.min(i,y.x,g.x),o=Math.min(o,y.y,g.y),r=Math.max(r,y.x,g.x),p=Math.max(p,y.y,g.y)}t.x=i,t.y=o,e.x=r,e.y=p}},n.pushbackContour=function(){var t=new e;return this.contours.push(t),t},n.addContour=function(t){var n=new e(t);return this.contours.push(n),n},n.addContours=function(t){var n=this;return t.map((function(t){var i=new e(structuredClone(t));return n.contours.push(i),i}))},n.getContours=function(){return this.contours.map((function(t){return t.getPoints()}))},t}();(p=exports.BooleanOperationType||(exports.BooleanOperationType={}))[p.INTERSECTION=0]="INTERSECTION",p[p.UNION=1]="UNION",p[p.DIFFERENCE=2]="DIFFERENCE",p[p.XOR=3]="XOR",(h=exports.EdgeType||(exports.EdgeType={}))[h.NORMAL=0]="NORMAL",h[h.NON_CONTRIBUTING=1]="NON_CONTRIBUTING",h[h.SAME_TRANSITION=2]="SAME_TRANSITION",h[h.DIFFERENT_TRANSITION=3]="DIFFERENT_TRANSITION",(u=exports.PolygonType||(exports.PolygonType={}))[u.SUBJECT=0]="SUBJECT",u[u.CLIPPING=1]="CLIPPING";var l=function(){function t(t){this.items=[],this.compareFn=t}var e=t.prototype;return e.push=function(t){this.items.push(t),this.bubbleUp(this.items.length-1)},e.pop=function(){if(0!==this.items.length){if(1===this.items.length)return this.items.pop();var t=this.items[0];return this.items[0]=this.items.pop(),this.bubbleDown(0),t}},e.size=function(){return this.items.length},e.isEmpty=function(){return 0===this.items.length},e.bubbleUp=function(t){for(;t>0;){var e=Math.floor((t-1)/2);if(!this.compareFn(this.items[e],this.items[t]))break;this.swap(e,t),t=e}},e.bubbleDown=function(t){for(;;){var e=t,n=2*t+1,i=2*t+2;if(n<this.items.length&&this.compareFn(this.items[e],this.items[n])&&(e=n),i<this.items.length&&this.compareFn(this.items[e],this.items[i])&&(e=i),e===t)break;this.swap(t,e),t=e}},e.swap=function(t,e){var n=[this.items[e],this.items[t]];this.items[t]=n[0],this.items[e]=n[1]},t}(),y=function(){function t(t){this.items=[],this.compareFn=t}var e=t.prototype;return e.insert=function(t){for(var e=0,n=this.items.length;e<n;){var i=Math.floor((e+n)/2);this.compareFn(this.items[i],t)?e=i+1:n=i}return this.items.splice(e,0,t),e},e.delete=function(t){var e=this.items.indexOf(t);return-1!==e&&(this.items.splice(e,1),!0)},e.indexOf=function(t){return this.items.indexOf(t)},e.at=function(t){return this.items[t]},e.size=function(){return this.items.length},e.isEmpty=function(){return 0===this.items.length},e.clear=function(){this.items=[]},t}();function g(t,e,n){return(t.x-n.x)*(e.y-n.y)-(e.x-n.x)*(t.y-n.y)}function d(t,e,n,i){var o=t.begin(),s=t.end(),r=e.begin(),p=e.end(),h=s.x-o.x,u=s.y-o.y,a=p.x-r.x,l=p.y-r.y,y=r.x-o.x,g=r.y-o.y,d=h*l-u*a,c=h*h+u*u;if(d*d>1e-7*c*(a*a+l*l)){var f=(y*l-g*a)/d;if(f<0||f>1)return 0;var v=(y*u-g*h)/d;return v<0||v>1?0:(n.x=o.x+f*h,n.y=o.y+f*u,Math.abs(n.x-o.x)<1e-8&&Math.abs(n.y-o.y)<1e-8?(n.x=o.x,n.y=o.y):Math.abs(n.x-s.x)<1e-8&&Math.abs(n.y-s.y)<1e-8?(n.x=s.x,n.y=s.y):Math.abs(n.x-r.x)<1e-8&&Math.abs(n.y-r.y)<1e-8?(n.x=r.x,n.y=r.y):Math.abs(n.x-p.x)<1e-8&&Math.abs(n.y-p.y)<1e-8&&(n.x=p.x,n.y=p.y),1)}var x=y*u-g*h;if(x*x>1e-7*c*(y*y+g*g))return 0;var E=(h*y+u*g)/c,T=E+(h*a+u*l)/c,I=Math.min(E,T),m=Math.max(E,T),O=Math.max(0,I),L=Math.min(1,m);return O>L?0:O===L?(n.x=o.x+O*h,n.y=o.y+O*u,1):(n.x=o.x+O*h,n.y=o.y+O*u,i.x=o.x+L*h,i.y=o.y+L*u,2)}var c=function(){function e(t,e,n,i,o){void 0===o&&(o=exports.EdgeType.NORMAL),this._point=t,this._isLeftEndpoint=e,this._polygonLabel=n,this._otherEvent=i,this._edgeType=o,this._positionInSweepLine=null,this._isInsideOutsideTransition=!1,this._isInsideOtherPolygon=!1}var n=e.prototype;return n.getSegment=function(){return new t(this.point,this._otherEvent.point)},n.isSegmentBelowPoint=function(t){return this._isLeftEndpoint?g(this.point,this._otherEvent.point,t)>0:g(this._otherEvent.point,this.point,t)>0},n.isSegmentAbovePoint=function(t){return!this.isSegmentBelowPoint(t)},n.segment=function(){return this.getSegment()},n.below=function(t){return this.isSegmentBelowPoint(t)},n.above=function(t){return this.isSegmentAbovePoint(t)},o(e,[{key:"point",get:function(){return this._point},set:function(t){this._point=t}},{key:"isLeftEndpoint",get:function(){return this._isLeftEndpoint},set:function(t){this._isLeftEndpoint=t}},{key:"polygonLabel",get:function(){return this._polygonLabel},set:function(t){this._polygonLabel=t}},{key:"otherEvent",get:function(){return this._otherEvent},set:function(t){this._otherEvent=t}},{key:"isInsideOutsideTransition",get:function(){return this._isInsideOutsideTransition},set:function(t){this._isInsideOutsideTransition=t}},{key:"edgeType",get:function(){return this._edgeType},set:function(t){this._edgeType=t}},{key:"isInsideOtherPolygon",get:function(){return this._isInsideOtherPolygon},set:function(t){this._isInsideOtherPolygon=t}},{key:"positionInSweepLine",get:function(){return this._positionInSweepLine},set:function(t){this._positionInSweepLine=t}}])}(),f=function(){function t(){}return t.compare=function(t,e){return t.point.x>e.point.x||!(e.point.x>t.point.x)&&(t.point.x!==e.point.x||t.point.y!==e.point.y?t.point.y>e.point.y:t.isLeftEndpoint!==e.isLeftEndpoint?t.isLeftEndpoint:t.isSegmentAbovePoint(e.otherEvent.point))},t}(),v=function(){function t(){}return t.compare=function(t,e){return t!==e&&(0!==g(t.point,t.otherEvent.point,e.point)||0!==g(t.point,t.otherEvent.point,e.otherEvent.point)?t.point.x===e.point.x&&t.point.y===e.point.y?t.isSegmentBelowPoint(e.otherEvent.point):f.compare(t,e)?e.isSegmentAbovePoint(t.point):t.isSegmentBelowPoint(e.point):t.point.x===e.point.x&&t.point.y===e.point.y?t<e:f.compare(t,e))},t}(),x=function(){function t(){this.init=this.initializeWithSegment,this.closed=this.isClosed,this.begin=this.getPoints,this.end=this.getPoints,this.clear=this.clearChain,this.size=this.getSize,this.pointList=[],this.isChainClosed=!1,this.prevInResult=null,this.resultTransition=!1}var e=t.prototype;return e.initializeWithSegment=function(t){this.pointList.push(t.begin()),this.pointList.push(t.end())},e.linkSegment=function(t){var e=t.begin(),n=t.end();return e.x===this.pointList[0].x&&e.y===this.pointList[0].y?(n.x===this.pointList[this.pointList.length-1].x&&n.y===this.pointList[this.pointList.length-1].y?this.isChainClosed=!0:this.pointList.unshift(n),!0):n.x===this.pointList[this.pointList.length-1].x&&n.y===this.pointList[this.pointList.length-1].y?(e.x===this.pointList[0].x&&e.y===this.pointList[0].y?this.isChainClosed=!0:this.pointList.push(e),!0):n.x===this.pointList[0].x&&n.y===this.pointList[0].y?(e.x===this.pointList[this.pointList.length-1].x&&e.y===this.pointList[this.pointList.length-1].y?this.isChainClosed=!0:this.pointList.unshift(e),!0):e.x===this.pointList[this.pointList.length-1].x&&e.y===this.pointList[this.pointList.length-1].y&&(n.x===this.pointList[0].x&&n.y===this.pointList[0].y?this.isChainClosed=!0:this.pointList.push(n),!0)},e.linkPointChain=function(t){var e,n,i,o;return t.pointList[0].x===this.pointList[this.pointList.length-1].x&&t.pointList[0].y===this.pointList[this.pointList.length-1].y?(t.pointList.shift(),(e=this.pointList).splice.apply(e,[this.pointList.length,0].concat(t.pointList)),!0):t.pointList[t.pointList.length-1].x===this.pointList[0].x&&t.pointList[t.pointList.length-1].y===this.pointList[0].y?(this.pointList.shift(),(n=this.pointList).splice.apply(n,[0,0].concat(t.pointList)),!0):t.pointList[0].x===this.pointList[0].x&&t.pointList[0].y===this.pointList[0].y?(this.pointList.shift(),t.pointList.reverse(),(i=this.pointList).splice.apply(i,[0,0].concat(t.pointList)),!0):t.pointList[t.pointList.length-1].x===this.pointList[this.pointList.length-1].x&&t.pointList[t.pointList.length-1].y===this.pointList[this.pointList.length-1].y&&(this.pointList.pop(),t.pointList.reverse(),(o=this.pointList).splice.apply(o,[this.pointList.length,0].concat(t.pointList)),!0)},e.isClosed=function(){return this.isChainClosed},e.getPoints=function(){return this.pointList},e.clearChain=function(){this.pointList=[]},e.getSize=function(){return this.pointList.length},e.setSpatialContext=function(t,e){this.prevInResult=t,this.resultTransition=e},e.getSpatialContext=function(){return{prevInResult:this.prevInResult,resultTransition:this.resultTransition}},o(t,[{key:"list",get:function(){return this.pointList}},{key:"_closed",get:function(){return this.isChainClosed},set:function(t){this.isChainClosed=t}}])}(),E=function(){function t(){this.add=this.addSegment,this.begin=this.getClosedChains,this.end=this.getClosedChains,this.clear=this.clearAll,this.size=this.getClosedChainCount,this.openPolygonChains=[],this.closedPolygonChains=[],this.prevInResult=null}var e=t.prototype;return e.addSegment=function(t,e){for(var n=0;n<this.openPolygonChains.length;){if(this.openPolygonChains[n].linkSegment(t)){if(this.openPolygonChains[n].isClosed()){var i=this.openPolygonChains.splice(n,1)[0];void 0!==e&&i.setSpatialContext(this.prevInResult,e),this.closedPolygonChains.push(i),this.prevInResult=this.closedPolygonChains.length-1}else for(var o=n+1;o<this.openPolygonChains.length;){if(this.openPolygonChains[n].linkPointChain(this.openPolygonChains[o])){this.openPolygonChains.splice(o,1);break}o++}return}n++}var s=new x;s.initializeWithSegment(t),this.openPolygonChains.push(s)},e.getClosedChains=function(){return this.closedPolygonChains},e.clearAll=function(){this.closedPolygonChains=[],this.openPolygonChains=[]},e.getClosedChainCount=function(){return this.closedPolygonChains.length},e.toPolygon=function(t){for(var e,n=s(this.closedPolygonChains);!(e=n()).done;)for(var i,o=e.value,r=t.pushbackContour(),p=s(o.getPoints());!(i=p()).done;)r.addPoint(i.value);for(var h=0;h<this.closedPolygonChains.length;h++){var u=this.closedPolygonChains[h],a=(t.contour(h),u.getSpatialContext());null!==a.prevInResult&&this.classifyContourHierarchy(h,a,t)}},e.classifyContourHierarchy=function(t,e,n){var i=e.prevInResult,o=e.resultTransition;if(null!==i){var s=n.contour(t),r=n.contour(i);if(o)if(r.isHole()){var p=r.getHoleOf();null!==p&&(s.setHoleOf(p),n.contour(p).addHole(t),s.setDepth(r.getDepth()))}else s.setHoleOf(i),r.addHole(t),s.setDepth(r.getDepth()+1);else s.setDepth(r.getDepth())}},t}(),T=function(){function t(t,e){this.eventQueue=new l(f.compare),this.eventStorage=[],this.subjectPolygon=t,this.clippingPolygon=e,this.intersectionCount=0}var e=t.prototype;return e.getIntersectionCount=function(){return this.intersectionCount},e.computeBooleanOperation=function(t){var e=new a;if(this.subjectPolygon.contourCount()*this.clippingPolygon.contourCount()==0){if(t===exports.BooleanOperationType.DIFFERENCE&&e.addContours(this.subjectPolygon.getContours()),t===exports.BooleanOperationType.UNION){var n=0===this.subjectPolygon.contourCount()?this.clippingPolygon:this.subjectPolygon;e.addContours(n.getContours())}return e}var i={x:0,y:0},o={x:0,y:0},s={x:0,y:0},r={x:0,y:0};if(this.subjectPolygon.boundingbox(i,o),this.clippingPolygon.boundingbox(s,r),i.x>r.x||s.x>o.x||i.y>r.y||s.y>o.y)return t===exports.BooleanOperationType.DIFFERENCE&&e.addContours(this.subjectPolygon.getContours()),t===exports.BooleanOperationType.UNION&&(e.addContours(this.subjectPolygon.getContours()),e.addContours(this.clippingPolygon.getContours())),e;for(var p=0;p<this.subjectPolygon.contourCount();p++)for(var h=0;h<this.subjectPolygon.contour(p).nvertices();h++)this.processSegment(this.subjectPolygon.contour(p).segment(h),exports.PolygonType.SUBJECT);for(var u=0;u<this.clippingPolygon.contourCount();u++)for(var l=0;l<this.clippingPolygon.contour(u).nvertices();l++)this.processSegment(this.clippingPolygon.contour(u).segment(l),exports.PolygonType.CLIPPING);for(var g=new E,d=new y(v.compare),c=Math.min(o.x,r.x);!this.eventQueue.isEmpty();){var f=this.eventQueue.pop();if(t===exports.BooleanOperationType.INTERSECTION&&f.point.x>c||t===exports.BooleanOperationType.DIFFERENCE&&f.point.x>o.x)return g.toPolygon(e),e;if(t===exports.BooleanOperationType.UNION&&f.point.x>c){for(f.isLeftEndpoint||g.add(f.segment(),f.otherEvent.isInsideOutsideTransition);!this.eventQueue.isEmpty();){var x=this.eventQueue.pop();x.isLeftEndpoint||g.add(x.segment(),x.otherEvent.isInsideOutsideTransition)}return g.toPolygon(e),e}if(f.isLeftEndpoint){var T=d.insert(f);f.positionInSweepLine=T;for(var I=T+1;I<d.size();I++){var m=d.at(I);m&&null!==m.positionInSweepLine&&(m.positionInSweepLine=I)}var O=T>0?d.at(T-1):null,L=T<d.size()-1?d.at(T+1):null;if(null==O)f.isInsideOtherPolygon=f.isInsideOutsideTransition=!1;else if(O.edgeType!==exports.EdgeType.NORMAL)if(T<=1)f.isInsideOtherPolygon=!0,f.isInsideOutsideTransition=!1;else{var C=d.at(T-2);C&&O.polygonLabel===f.polygonLabel?(f.isInsideOutsideTransition=!O.isInsideOutsideTransition,f.isInsideOtherPolygon=!C.isInsideOutsideTransition):C&&(f.isInsideOutsideTransition=!C.isInsideOutsideTransition,f.isInsideOtherPolygon=!O.isInsideOutsideTransition)}else f.polygonLabel===O.polygonLabel?(f.isInsideOtherPolygon=O.isInsideOtherPolygon,f.isInsideOutsideTransition=!O.isInsideOutsideTransition):(f.isInsideOtherPolygon=!O.isInsideOutsideTransition,f.isInsideOutsideTransition=O.isInsideOtherPolygon);null!=L&&this.possibleIntersection(f,L),null!=O&&this.possibleIntersection(O,f)}else{var P=f.otherEvent,b=P.positionInSweepLine,N=b>0?d.at(b-1):null,S=b<d.size()-1?d.at(b+1):null;switch(f.edgeType){case exports.EdgeType.NORMAL:switch(t){case exports.BooleanOperationType.INTERSECTION:f.otherEvent.isInsideOtherPolygon&&g.add(f.segment(),f.otherEvent.isInsideOutsideTransition);break;case exports.BooleanOperationType.UNION:f.otherEvent.isInsideOtherPolygon||g.add(f.segment(),f.otherEvent.isInsideOutsideTransition);break;case exports.BooleanOperationType.DIFFERENCE:(f.polygonLabel===exports.PolygonType.SUBJECT&&!f.otherEvent.isInsideOtherPolygon||f.polygonLabel===exports.PolygonType.CLIPPING&&f.otherEvent.isInsideOtherPolygon)&&g.add(f.segment(),f.otherEvent.isInsideOutsideTransition);break;case exports.BooleanOperationType.XOR:g.add(f.segment(),f.otherEvent.isInsideOutsideTransition)}break;case exports.EdgeType.SAME_TRANSITION:t!==exports.BooleanOperationType.INTERSECTION&&t!==exports.BooleanOperationType.UNION||g.add(f.segment(),f.otherEvent.isInsideOutsideTransition);break;case exports.EdgeType.DIFFERENT_TRANSITION:t===exports.BooleanOperationType.DIFFERENCE&&g.add(f.segment(),f.otherEvent.isInsideOutsideTransition)}d.delete(P);for(var R=b;R<d.size();R++){var _=d.at(R);_&&null!==_.positionInSweepLine&&(_.positionInSweepLine=R)}null!==S&&null!==N&&void 0!==S&&void 0!==N&&this.possibleIntersection(N,S)}}return g.toPolygon(e),e},e.processSegment=function(t,e){var n=t.begin(),i=t.end();if(n.x!==i.x||n.y!==i.y){var o=this.storeSweepEvent(new c(n,!0,e,null)),s=this.storeSweepEvent(new c(i,!0,e,o));o.otherEvent=s,o.point.x<s.point.x?s.isLeftEndpoint=!1:o.point.x>s.point.x?o.isLeftEndpoint=!1:o.point.y<s.point.y?s.isLeftEndpoint=!1:o.isLeftEndpoint=!1,this.eventQueue.push(o),this.eventQueue.push(s)}},e.possibleIntersection=function(t,e){var n={x:0,y:0},i=d(t.segment(),e.segment(),n,{x:0,y:0});if(0!==i&&!(1===i&&(t.point.x===e.point.x&&t.point.y===e.point.y||t.otherEvent.point.x===e.otherEvent.point.x&&t.otherEvent.point.y===e.otherEvent.point.y)||2===i&&t.polygonLabel===e.polygonLabel)){if(this.intersectionCount+=i,1===i)return t.point.x===n.x&&t.point.y===n.y||t.otherEvent.point.x===n.x&&t.otherEvent.point.y===n.y||this.divideSegment(t,n),void(e.point.x===n.x&&e.point.y===n.y||e.otherEvent.point.x===n.x&&e.otherEvent.point.y===n.y||this.divideSegment(e,n));var o=[];if(t.point.x===e.point.x&&t.point.y===e.point.y?o.push(null):f.compare(t,e)?(o.push(e),o.push(t)):(o.push(t),o.push(e)),t.otherEvent.point.x===e.otherEvent.point.x&&t.otherEvent.point.y===e.otherEvent.point.y?o.push(null):f.compare(t.otherEvent,e.otherEvent)?(o.push(e.otherEvent),o.push(t.otherEvent)):(o.push(t.otherEvent),o.push(e.otherEvent)),2===o.length)return t.edgeType=t.otherEvent.edgeType=exports.EdgeType.NON_CONTRIBUTING,void(e.edgeType=e.otherEvent.edgeType=t.isInsideOutsideTransition===e.isInsideOutsideTransition?exports.EdgeType.SAME_TRANSITION:exports.EdgeType.DIFFERENT_TRANSITION);if(3===o.length)return o[1].edgeType=o[1].otherEvent.edgeType=exports.EdgeType.NON_CONTRIBUTING,o[0]?o[0].otherEvent.edgeType=t.isInsideOutsideTransition===e.isInsideOutsideTransition?exports.EdgeType.SAME_TRANSITION:exports.EdgeType.DIFFERENT_TRANSITION:o[2].otherEvent.edgeType=t.isInsideOutsideTransition===e.isInsideOutsideTransition?exports.EdgeType.SAME_TRANSITION:exports.EdgeType.DIFFERENT_TRANSITION,void this.divideSegment(o[0]?o[0]:o[2].otherEvent,o[1].point);if(o[0]!==o[3].otherEvent)return o[1].edgeType=exports.EdgeType.NON_CONTRIBUTING,o[2].edgeType=t.isInsideOutsideTransition===e.isInsideOutsideTransition?exports.EdgeType.SAME_TRANSITION:exports.EdgeType.DIFFERENT_TRANSITION,this.divideSegment(o[0],o[1].point),void this.divideSegment(o[1],o[2].point);o[1].edgeType=o[1].otherEvent.edgeType=exports.EdgeType.NON_CONTRIBUTING,this.divideSegment(o[0],o[1].point),o[3].otherEvent.edgeType=t.isInsideOutsideTransition===e.isInsideOutsideTransition?exports.EdgeType.SAME_TRANSITION:exports.EdgeType.DIFFERENT_TRANSITION,this.divideSegment(o[3].otherEvent,o[2].point)}},e.divideSegment=function(t,e){var n=this.storeSweepEvent(new c(e,!1,t.polygonLabel,t,t.edgeType)),i=this.storeSweepEvent(new c(e,!0,t.polygonLabel,t.otherEvent,t.otherEvent.edgeType));f.compare(i,t.otherEvent)&&(console.log("Oops"),t.otherEvent.isLeftEndpoint=!0,i.isLeftEndpoint=!1),f.compare(t,n)&&console.log("Oops2"),t.otherEvent.otherEvent=i,t.otherEvent=n,this.eventQueue.push(i),this.eventQueue.push(n)},e.storeSweepEvent=function(t){return this.eventStorage.push(t),this.eventStorage[this.eventStorage.length-1]},t}();exports.Connector=E,exports.Contour=e,exports.Martinez=T,exports.OrderedSet=y,exports.PointChain=x,exports.Polygon=a,exports.PriorityQueue=l,exports.Segment=t,exports.SegmentComparator=v,exports.SweepEvent=c,exports.SweepEventComparator=f,exports.calculateSignedArea=g,exports.findSegmentIntersection=d,exports.isPointOnSegment=function(t,e,n){return n.x<=Math.max(t.x,e.x)&&n.x>=Math.min(t.x,e.x)&&n.y<=Math.max(t.y,e.y)&&n.y>=Math.min(t.y,e.y)}; //# sourceMappingURL=martinez.cjs.production.min.js.map