flatten-js
Version:
Javascript library for 2d geometry
1 lines • 7.06 kB
JSON
{"dependencies":[{"name":"C:\\Users\\alexbol\\WebstormProjects\\flatten-js\\package.json","includedInParent":true,"mtime":1520238055570}],"generated":{"js":"\"use strict\";var t=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,\"value\"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}();function e(t,e){if(!(t instanceof e))throw new TypeError(\"Cannot call a class as a function\")}module.exports=function(r){var i=r.Point,n=r.Segment,s=r.Arc,a=(r.Box,r.Edge);r.Face=function(){function o(t){if(e(this,o),this.first,this.last,this._box=void 0,this._orientation=void 0,0!=(arguments.length<=1?0:arguments.length-1)){if(1==(arguments.length<=1?0:arguments.length-1))if((arguments.length<=1?void 0:arguments[1])instanceof Array){var r=arguments.length<=1?void 0:arguments[1];if(0==r.length)return;if(r.every(function(t){return t instanceof i})){var l=o.points2segments(r);this.shapes2face(t.edges,l)}else if(r.every(function(t){return t instanceof n||t instanceof s}))this.shapes2face(t.edges,r);else if(r.every(function(t){return\"Segment\"===t.name||\"Arc\"===t.name})){var h=[],v=!0,f=!1,u=void 0;try{for(var c,y=r[Symbol.iterator]();!(v=(c=y.next()).done);v=!0){var d=c.value,g=void 0;g=\"Segment\"===d.name?new n(d.ps.x,d.ps.y,d.pe.x,d.pe.y):new s(new i(d.pc.x,d.pc.y),d.r,d.startAngle,d.endAngle,d.counterClockwise),h.push(g)}}catch(t){f=!0,u=t}finally{try{!v&&y.return&&y.return()}finally{if(f)throw u}}this.shapes2face(t.edges,h)}}else if((arguments.length<=1?void 0:arguments[1])instanceof o){var p=arguments.length<=1?void 0:arguments[1];this.first=p.first,this.last=p.last;var x=!0,b=!1,m=void 0;try{for(var S,_=p[Symbol.iterator]();!(x=(S=_.next()).done);x=!0){var w=S.value;t.edges.add(w)}}catch(t){b=!0,m=t}finally{try{!x&&_.return&&_.return()}finally{if(b)throw m}}}2==(arguments.length<=1?0:arguments.length-1)&&(arguments.length<=1?void 0:arguments[1])instanceof a&&(arguments.length<=2?void 0:arguments[2])instanceof a&&(this.first=arguments.length<=1?void 0:arguments[1],this.last=arguments.length<=2?void 0:arguments[2],this.last.next=this.first,this.first.prev=this.last,this.setArcLength())}}return t(o,[{key:Symbol.iterator,value:function(){var t=this,e=void 0;return{next:function(){var r=e||t.first,i=!t.first||!!e&&e===t.first;return e=r?r.next:void 0,{value:r,done:i}}}}},{key:\"shapes2face\",value:function(t,e){var r=!0,i=!1,n=void 0;try{for(var s,o=e[Symbol.iterator]();!(r=(s=o.next()).done);r=!0){var l=s.value,h=new a(l);this.append(t,h)}}catch(t){i=!0,n=t}finally{try{!r&&o.return&&o.return()}finally{if(i)throw n}}}},{key:\"isEmpty\",value:function(){return void 0===this.first&&void 0===this.last}},{key:\"append\",value:function(t,e){void 0===this.first?(e.prev=e,e.next=e,this.first=e,this.last=e,e.arc_length=0):(e.prev=this.last,this.last.next=e,this.last=e,this.last.next=this.first,this.first.prev=this.last,e.arc_length=e.prev.arc_length+e.prev.length),e.face=this,t.add(e)}},{key:\"insert\",value:function(t,e,r){if(void 0===this.first)edge.prev=e,edge.next=e,this.first=e,this.last=e;else{var i=r.next;r.next=e,i.prev=e,e.prev=r,e.next=i,this.last===r&&(this.first=e)}e.face=this,t.add(e)}},{key:\"remove\",value:function(t,e){e===this.first&&e===this.last?(this.first=void 0,this.last=void 0):(e.prev.next=e.next,e.next.prev=e.prev,e===this.first&&(this.first=e.next),e===this.last&&(this.last=e.prev)),t.delete(e)}},{key:\"reverse\",value:function(){var t=[],e=this.last;do{e.shape=e.shape.reverse(),t.push(e),e=e.prev}while(e!==this.last);this.first=void 0,this.last=void 0;var r=!0,i=!1,n=void 0;try{for(var s,a=t[Symbol.iterator]();!(r=(s=a.next()).done);r=!0){var o=s.value;void 0===this.first?(o.prev=o,o.next=o,this.first=o,this.last=o,o.arc_length=0):(o.prev=this.last,this.last.next=o,this.last=o,this.last.next=this.first,this.first.prev=this.last,o.arc_length=o.prev.arc_length+o.prev.length)}}catch(t){i=!0,n=t}finally{try{!r&&a.return&&a.return()}finally{if(i)throw n}}void 0!==this._orientation&&(this._orientation=void 0,this._orientation=this.orientation())}},{key:\"setArcLength\",value:function(){var t=!0,e=!1,r=void 0;try{for(var i,n=this[Symbol.iterator]();!(t=(i=n.next()).done);t=!0){var s=i.value;s===this.first?s.arc_length=0:s.arc_length=s.prev.arc_length+s.prev.length,s.face=this}}catch(t){e=!0,r=t}finally{try{!t&&n.return&&n.return()}finally{if(e)throw r}}}},{key:\"area\",value:function(){return Math.abs(this.signedArea())}},{key:\"signedArea\",value:function(){var t=0,e=!0,r=!1,i=void 0;try{for(var n,s=this[Symbol.iterator]();!(e=(n=s.next()).done);e=!0){t+=n.value.shape.definiteIntegral(this.box.ymin)}}catch(t){r=!0,i=t}finally{try{!e&&s.return&&s.return()}finally{if(r)throw i}}return t}},{key:\"orientation\",value:function(){if(void 0===this._orientation){var t=this.signedArea();r.Utils.EQ_0(t)?this._orientation=r.ORIENTATION.NOT_ORIENTABLE:r.Utils.LT(t,0)?this._orientation=r.ORIENTATION.CCW:this._orientation=r.ORIENTATION.CW}return this._orientation}},{key:\"getRelation\",value:function(t){this.first.bv=this.first.bvStart=this.first.bvEnd=void 0;var e=this.first.setInclusion(t),i=t.faces.search(this.box);if(0===i.length)return e;var n=new r.Polygon;n.addFace(this);var s=0,a=!0,o=!1,l=void 0;try{for(var h,v=i[Symbol.iterator]();!(a=(h=v.next()).done);a=!0){var f=h.value;f.first.bv=f.first.bvStart=f.first.bvEnd=void 0,f.first.setInclusion(n)===r.INSIDE&&s++}}catch(t){o=!0,l=t}finally{try{!a&&v.return&&v.return()}finally{if(o)throw l}}return e===r.OUTSIDE?0===s?r.OUTSIDE:s===i.length&&i.length===t.faces.size?r.CONTAINS:r.INTERLACE:e===r.INSIDE?0===s?r.INSIDE:r.INTERLACE:void 0}},{key:\"toJSON\",value:function(){return this.edges.map(function(t){return t.toJSON()})}},{key:\"svg\",value:function(){var t=\"\\nM\"+this.first.start.x+\",\"+this.first.start.y,e=!0,r=!1,i=void 0;try{for(var n,s=this[Symbol.iterator]();!(e=(n=s.next()).done);e=!0){t+=n.value.svg()}}catch(t){r=!0,i=t}finally{try{!e&&s.return&&s.return()}finally{if(r)throw i}}return t+=\" z\"}},{key:\"edges\",get:function(){var t=[],e=!0,r=!1,i=void 0;try{for(var n,s=this[Symbol.iterator]();!(e=(n=s.next()).done);e=!0){var a=n.value;t.push(a)}}catch(t){r=!0,i=t}finally{try{!e&&s.return&&s.return()}finally{if(r)throw i}}return t}},{key:\"size\",get:function(){var t=0,e=!0,r=!1,i=void 0;try{for(var n,s=this[Symbol.iterator]();!(e=(n=s.next()).done);e=!0){n.value;t++}}catch(t){r=!0,i=t}finally{try{!e&&s.return&&s.return()}finally{if(r)throw i}}return t}},{key:\"box\",get:function(){if(void 0===this._box){var t=new r.Box,e=!0,i=!1,n=void 0;try{for(var s,a=this[Symbol.iterator]();!(e=(s=a.next()).done);e=!0){var o=s.value;t=t.merge(o.box)}}catch(t){i=!0,n=t}finally{try{!e&&a.return&&a.return()}finally{if(i)throw n}}this._box=t}return this._box}}],[{key:\"points2segments\",value:function(t){for(var e=[],r=0;r<t.length;r++)e.push(new n(t[r],t[(r+1)%t.length]));return e}}]),o}()};"},"hash":"9e7f72fc0c331fb09f6c2aa6707e4d15","cacheData":{"env":{}}}