1 |
- !function(i,M,J){"use strict";var Y="ht",U=i[Y],h=U.Default,P=h.getInternal();P.addMethod(h,{cadToShape:function(Z,p){var j=new U.DxfViewer(p);return j.toShape(Z)}}),function(I){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=I();else if("function"==typeof define&&define.amd)define([],I);else{var b;b="undefined"!=typeof i?i:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.DxfParser=I()}}(function(){var y;return function d(U,t,c){function e(v,O){if(!t[v]){if(!U[v]){var p="function"==typeof require&&require;if(!O&&p)return p(v,!0);if(E)return E(v,!0);var I=new Error("Cannot find module '"+v+"'");throw I.code="MODULE_NOT_FOUND",I}var P=t[v]={exports:{}};U[v][0].call(P.exports,function(E){var w=U[v][1][E];return e(w?w:E)},P,P.exports,d,U,t,c)}return t[v].exports}for(var E="function"==typeof require&&require,k=0;k<c.length;k++)e(c[k]);return e}({1:[function(E,i){i.exports=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215]},{}],2:[function(b,B){function m(x){this._pointer=0,this._data=x,this._eof=!1}function s(c,m){return 9>=c?m:c>=10&&59>=c?parseFloat(m):c>=60&&99>=c?parseInt(m):c>=100&&109>=c?m:c>=110&&149>=c?parseFloat(m):c>=160&&179>=c?parseInt(m):c>=210&&239>=c?parseFloat(m):c>=270&&289>=c?parseInt(m):c>=290&&299>=c?r(m):c>=300&&369>=c?m:c>=370&&389>=c?parseInt(m):c>=390&&399>=c?m:c>=400&&409>=c?parseInt(m):c>=410&&419>=c?m:c>=420&&429>=c?parseInt(m):c>=430&&439>=c?m:c>=440&&459>=c?parseInt(m):c>=460&&469>=c?parseFloat(m):c>=470&&481>=c?m:999===c?m:c>=1e3&&1009>=c?m:c>=1010&&1059>=c?parseFloat(m):c>=1060&&1071>=c?parseInt(m):(console.log("WARNING: Group code does not have a defined type: %j",{code:c,value:m}),m)}function r(H){if("0"===H)return!1;if("1"===H)return!0;throw TypeError("String '"+H+"' cannot be cast to Boolean type")}m.prototype.next=function(){var O;if(!this.hasNext())throw this._eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);return O={code:parseInt(this._data[this._pointer])},this._pointer++,O.value=s(O.code,this._data[this._pointer].trim()),this._pointer++,0===O.code&&"EOF"===O.value&&(this._eof=!0),O},m.prototype.hasNext=function(){return this._eof?!1:this._pointer>this._data.length-2?!1:!0},m.prototype.isEOF=function(){return this._eof},B.exports=m},{}],3:[function(Z,I){function g(){}function k(E){D.debug("unhandled group "+m(E))}function m(R){return R.code+":"+R.value}function n(d){return y[d]}var X=Z("./DxfArrayScanner.js"),y=Z("./AutoCadColorIndex"),D=Z("loglevel");D.setLevel("error"),g.prototype.parse=function(){throw new Error("read() not implemented. Use readSync()")},g.prototype.parseSync=function(y){return"string"==typeof y?this._parse(y):(console.error("Cannot read dxf source of type `"+typeof y),null)},g.prototype.parseStream=function(n,I){function z(l){p+=l}function i(){try{var o=J._parse(p)}catch(X){return I(X)}I(null,o)}function A(V){I(V)}var p="",J=this;n.on("data",z),n.on("end",i),n.on("error",A)},g.prototype._parse=function(F){var V,j,p={},T=0,v=F.split(/\r\n|\r|\n/g);if(V=new X(v),!V.hasNext())throw Error("Empty file");var f=function(){for(j=V.next();!V.isEOF();)if(0===j.code&&"SECTION"===j.value){if(j=V.next(),2!==j.code){console.error("Unexpected code %s after 0:SECTION",m(j)),j=V.next();continue}"HEADER"===j.value?(D.debug("> HEADER"),p.header=Z(),D.debug("<")):"BLOCKS"===j.value?(D.debug("> BLOCKS"),p.blocks=c(),D.debug("<")):"ENTITIES"===j.value?(D.debug("> ENTITIES"),p.entities=L(!1),D.debug("<")):"TABLES"===j.value?(D.debug("> TABLES"),p.tables=g(),D.debug("<")):"EOF"===j.value?D.debug("EOF"):D.warn("Skipping section '%s'",j.value)}else j=V.next()},h=function(c,s){return j.code===c&&j.value===s},Z=function(){var $=null,I=null,W={};for(j=V.next();;){if(h(0,"ENDSEC")){$&&(W[$]=I);break}9===j.code?($&&(W[$]=I),$=j.value):10===j.code?I={x:j.value}:20===j.code?I.y=j.value:30===j.code?I.z=j.value:I=j.value,j=V.next()}return j=V.next(),W},c=function(){var G,R={};for(j=V.next();"EOF"!==j.value&&!h(0,"ENDSEC");)h(0,"BLOCK")?(D.debug("block {"),G=$(),D.debug("}"),P(G),G.name?R[G.name]=G:D.error('block with handle "'+G.handle+'" is missing a name.')):(k(j),j=V.next());return R},$=function(){var B={};for(j=V.next();"EOF"!==j.value;){switch(j.code){case 1:B.xrefPath=j.value,j=V.next();break;case 2:B.name=j.value,j=V.next();break;case 3:B.name2=j.value,j=V.next();break;case 5:B.handle=j.value,j=V.next();break;case 8:B.layer=j.value,j=V.next();break;case 10:B.position=w();break;case 67:B.paperSpace=j.value&&1==j.value?!0:!1,j=V.next();break;case 70:0!=j.value&&(B.type=j.value),j=V.next();break;case 100:j=V.next();break;case 330:B.ownerHandle=j.value,j=V.next();break;case 0:if("ENDBLK"==j.value)break;V._pointer-=2,B.entities=L(!0);break;default:k(j),j=V.next()}if(h(0,"ENDBLK")){j=V.next();break}}return B},g=function(){var p={};for(j=V.next();"EOF"!==j.value&&!h(0,"ENDSEC");)if(h(0,"TABLE")){j=V.next();var _=o[j.value];_?(D.debug(j.value+" Table {"),p[o[j.value].tableName]=E(),D.debug("}")):D.debug("Unhandled Table "+j.value)}else j=V.next();return j=V.next(),p},e="ENDTAB",E=function(){var U,W=o[j.value],Z={},t=0;for(j=V.next();!h(0,e);)switch(j.code){case 5:Z.handle=j.value,j=V.next();break;case 330:Z.ownerHandle=j.value,j=V.next();break;case 100:"AcDbSymbolTable"===j.value?j=V.next():(k(j),j=V.next());break;case 70:t=j.value,j=V.next();break;case 0:j.value===W.dxfSymbolName?Z[W.tableRecordsProperty]=W.parseTableRecords():(k(j),j=V.next());break;default:k(j),j=V.next()}var b=Z[W.tableRecordsProperty];return b&&(b.constructor===Array?U=b.length:"object"==typeof b&&(U=M.keys(b).length),t!==U&&D.warn("Parsed "+U+" "+W.dxfSymbolName+"'s but expected "+t)),j=V.next(),Z},U=function(){var Y=[],f={};for(D.debug("ViewPort {"),j=V.next();!h(0,e);)switch(j.code){case 2:f.name=j.value,j=V.next();break;case 10:f.lowerLeftCorner=w();break;case 11:f.upperRightCorner=w();break;case 12:f.center=w();break;case 13:f.snapBasePoint=w();break;case 14:f.snapSpacing=w();break;case 15:f.gridSpacing=w();break;case 16:f.viewDirectionFromTarget=w();break;case 17:f.viewTarget=w();break;case 40:f.viewHeight=j.value,f.aspectRatio!==J&&(f.viewWidth=j.value*f.aspectRatio),j=V.next();break;case 41:f.aspectRatio=j.value,f.viewHeight!==J&&(f.viewWidth=j.value*f.viewHeight),j=V.next();break;case 42:f.lensLength=j.value,j=V.next();break;case 43:f.frontClippingPlane=j.value,j=V.next();break;case 44:f.backClippingPlane=j.value,j=V.next();break;case 45:f.viewHeight=j.value,j=V.next();break;case 50:f.snapRotationAngle=j.value,j=V.next();break;case 51:f.viewTwistAngle=j.value,j=V.next();break;case 79:f.orthographicType=j.value,j=V.next();break;case 110:f.ucsOrigin=w();break;case 111:f.ucsXAxis=w();break;case 112:f.ucsYAxis=w();break;case 110:f.ucsOrigin=w();break;case 281:f.renderMode=j.value,j=V.next();break;case 281:f.defaultLightingType=j.value,j=V.next();break;case 292:f.defaultLightingOn=j.value,j=V.next();break;case 330:f.ownerHandle=j.value,j=V.next();break;case 63:case 421:case 431:f.ambientColor=j.value,j=V.next();break;case 0:"VPORT"===j.value&&(D.debug("}"),Y.push(f),D.debug("ViewPort {"),f={},j=V.next());break;default:k(j),j=V.next()}return D.debug("}"),Y.push(f),Y},O=function(){var d,p,C={},v={};for(D.debug("LType {"),j=V.next();!h(0,"ENDTAB");)switch(j.code){case 2:v.name=j.value,d=j.value,j=V.next();break;case 3:v.description=j.value,j=V.next();break;case 73:p=j.value,p>0&&(v.pattern=[]),j=V.next();break;case 40:v.patternLength=j.value,j=V.next();break;case 49:v.pattern.push(j.value),j=V.next();break;case 0:D.debug("}"),p>0&&p!==v.pattern.length&&D.warn("lengths do not match on LTYPE pattern"),C[d]=v,v={},D.debug("LType {"),j=V.next();break;default:j=V.next()}return D.debug("}"),C[d]=v,C},u=function(){var f,O={},M={};for(D.debug("Layer {"),j=V.next();!h(0,"ENDTAB");)switch(j.code){case 2:M.name=j.value,f=j.value,j=V.next();break;case 62:M.visible=j.value>0,M.color=n(Math.abs(j.value)),j=V.next();break;case 6:M.lineType=j.value,j=V.next();break;case 0:"LAYER"===j.value&&(D.debug("}"),O[f]=M,D.debug("Layer {"),M={},f=J,j=V.next());break;default:k(j),j=V.next()}return D.debug("}"),O[f]=M,O},o={VPORT:{tableRecordsProperty:"viewPorts",tableName:"viewPort",dxfSymbolName:"VPORT",parseTableRecords:U},LTYPE:{tableRecordsProperty:"lineTypes",tableName:"lineType",dxfSymbolName:"LTYPE",parseTableRecords:O},LAYER:{tableRecordsProperty:"layers",tableName:"layer",dxfSymbolName:"LAYER",parseTableRecords:u}},L=function(E){var a=[],w=E?"ENDBLK":"ENDSEC";for(j=V.next();;)if(0===j.code){if(j.value===w)break;var I;if("LWPOLYLINE"===j.value)D.debug("LWPOLYLINE {"),I=N(),D.debug("}");else if("POLYLINE"===j.value)D.debug("POLYLINE {"),I=Q(),D.debug("}");else if("LINE"===j.value)D.debug("LINE {"),I=t(),D.debug("}");else if("CIRCLE"===j.value)D.debug("CIRCLE {"),I=S(),D.debug("}");else if("ARC"===j.value)D.debug("ARC {"),I=S(),D.debug("}");else if("ELLIPSE"===j.value)D.debug("ELLIPSE {"),I=l(),D.debug("}");else if("SPLINE"===j.value)D.debug("SPLINE {"),I=s(),D.debug("}");else if("TEXT"===j.value)D.debug("TEXT {"),I=H(),D.debug("}");else if("DIMENSION"===j.value)D.debug("DIMENSION {"),I=b(),D.debug("}");else if("INSERT"===j.value)D.debug("INSERT {"),I=C(),D.debug("}");else if("HATCH"===j.value)D.debug("HATCH {"),I=i(),D.debug("}");else if("SOLID"===j.value)D.debug("SOLID {"),I=G(),D.debug("}");else if("POINT"===j.value)D.debug("POINT {"),I=q(),D.debug("}");else if("MTEXT"===j.value)D.debug("MTEXT {"),I=K(),D.debug("}");else{if("ATTDEF"!==j.value){D.warn("Unhandled entity "+j.value),j=V.next();continue}D.debug("ATTDEF {"),I=_(),D.debug("}")}P(I),a.push(I)}else j=V.next();return"ENDSEC"==w&&(j=V.next()),a},d=function(G){switch(j.code){case 0:G.type=j.value,j=V.next();break;case 5:G.handle=j.value,j=V.next();break;case 6:G.lineType=j.value,j=V.next();break;case 8:G.layer=j.value,j=V.next();break;case 48:G.lineTypeScale=j.value,j=V.next();break;case 60:G.visible=0===j.value,j=V.next();break;case 62:G.colorIndex=j.value,G.color=n(Math.abs(j.value)),j=V.next();break;case 67:G.inPaperSpace=0!==j.value,j=V.next();break;case 210:G.extrusionDirection=w();break;case 230:G.extrusionDirection={x:0,y:0,z:j.value},j=V.next();break;case 330:G.ownerHandle=j.value,j=V.next();break;case 347:G.materialObjectHandle=j.value,j=V.next();break;case 370:G.lineweight=j.value,j=V.next();break;case 420:G.color=j.value,j=V.next();break;case 100:if("AcDbEntity"==j.value){j=V.next();break}default:k(j),j=V.next()}},Y=function(){var Z={type:j.value};for(j=V.next();"EOF"!==j&&0!==j.code;)switch(j.code){case 10:Z.x=j.value,j=V.next();break;case 20:Z.y=j.value,j=V.next();break;case 30:Z.z=j.value,j=V.next();break;case 40:case 41:case 42:j=V.next();break;case 70:Z.curveFittingVertex=0!==(1|j.value),Z.curveFitTangent=0!==(2|j.value),Z.splineVertex=0!==(8|j.value),Z.splineControlPoint=0!==(16|j.value),Z.ThreeDPolylineVertex=0!==(32|j.value),Z.ThreeDPolylineMesh=0!==(64|j.value),Z.polyfaceMeshVertex=0!==(128|j.value),j=V.next();break;case 50:case 71:case 72:case 73:case 74:j=V.next();break;default:d(Z)}return Z},x=function(){var c={type:j.value};for(j=V.next();"EOF"!=j&&0!=j.code;)d(c);return c},w=function(){var s={},g=j.code;if(s.x=j.value,g+=10,j=V.next(),j.code!=g)throw new Error("Expected code for point value to be "+g+" but got "+j.code+".");return s.y=j.value,g+=10,j=V.next(),j.code!=g?s:(s.z=j.value,j=V.next(),s)},r=function(){var k={},O=j.code;return k.x=j.value,O+=1,j=V.next(),j.code!=O?(V._pointer-=2,k.y=1):k.y=j.value,O+=1,j=V.next(),j.code!=O?(V._pointer-=2,k):(k.z=j.value,j=V.next(),k)},y=function(u){if(!u||0>=u)throw Error("n must be greater than 0 verticies");var A,X=[],H=!1,N=!1;for(A=0;u>A;A++){for(var w={};"EOF"!==j&&0!==j.code&&!N;){switch(j.code){case 10:if(H){N=!0;continue}w.x=j.value,H=!0;break;case 20:w.y=j.value;break;case 30:w.z=j.value;break;case 40:w.startWidth=j.value;break;case 41:w.endWidth=j.value;break;case 42:0!=j.value&&(w.bulge=j.value);break;default:if(H){N=!0;continue}continue}j=V.next()}X.push(w),H=!1,N=!1}return X},R=function(){for(var e=[];"EOF"!==j;)if(0===j.code)if("VERTEX"===j.value)e.push(Y());else if("SEQEND"===j.value){x();break}return e},K=function(){var G={type:j.value};for(j=V.next();"EOF"!==j&&0!==j.code;)switch(j.code){case 1:G.text=j.value,j=V.next();break;case 3:G.text+=j.value,j=V.next();break;case 10:G.position=w();break;case 40:G.height=j.value,j=V.next();break;case 41:G.width=j.value,j=V.next();break;case 71:G.attachmentPoint=j.value,j=V.next();break;case 72:G.drawingDirection=j.value,j=V.next();break;case 50:G.angle=2*j.value*Math.PI/360,j=V.next();break;case 11:G.directionX=j.value,j=V.next();break;case 21:G.directionY=j.value,j=V.next();break;default:d(G)}return G},_=function(){var T={type:j.value,scale:1,textStyle:"STANDARD"};for(j=V.next();"EOF"!==j&&0!==j.code;)switch(j.code){case 1:T.text=j.value,j=V.next();break;case 2:T.tag=j.value,j=V.next();break;case 3:T.prompt=j.value,j=V.next();break;case 7:T.textStyle=j.value,j=V.next();break;case 10:T.x=j.value,j=V.next();break;case 20:T.y=j.value,j=V.next();break;case 30:T.z=j.value,j=V.next();break;case 39:T.thickness=j.value,j=V.next();break;case 40:T.textHeight=j.value,j=V.next();break;case 41:T.scale=j.value,j=V.next();break;case 50:T.rotation=j.value,j=V.next();break;case 51:T.obliqueAngle=j.value,j=V.next();break;case 70:T.invisible=!!(1&j.value),T.constant=!!(2&j.value),T.verificationRequired=!!(4&j.value),T.preset=!!(8&j.value),j=V.next();break;case 71:T.backwards=!!(2&j.value),T.mirrored=!!(4&j.value),j=V.next();break;case 72:T.horizontalJustification=j.value,j=V.next();break;case 73:T.fieldLength=j.value,j=V.next();break;case 74:T.verticalJustification=j.value,j=V.next();break;case 100:j=V.next();break;case 210:T.extrusionDirectionX=j.value,j=V.next();break;case 220:T.extrusionDirectionY=j.value,j=V.next();break;case 230:T.extrusionDirectionZ=j.value,j=V.next();break;default:d(T)}return T},N=function(){var Q={type:j.value,vertices:[]},v=0;for(j=V.next();"EOF"!==j&&0!==j.code;)switch(j.code){case 38:Q.elevation=j.value,j=V.next();break;case 39:Q.depth=j.value,j=V.next();break;case 70:Q.shape=1===j.value,j=V.next();break;case 90:v=j.value,j=V.next();break;case 10:Q.vertices=y(v);break;case 43:0!==j.value&&(Q.width=j.value),j=V.next();break;default:d(Q)}return Q},Q=function(){var N={type:j.value,vertices:[]};for(j=V.next();"EOF"!==j&&0!==j.code;)switch(j.code){case 10:case 20:case 30:case 39:case 40:case 41:j=V.next();break;case 70:N.shape=0!==(1|j.value),j=V.next();break;case 71:case 72:case 73:case 74:case 75:j=V.next();break;case 100:j=V.next();break;default:d(N)}return N.vertices=R(),N},t=function(){var J={type:j.value,vertices:[]};for(j=V.next();"EOF"!==j&&0!==j.code;)switch(j.code){case 10:J.vertices.unshift(w());break;case 11:J.vertices.push(w());break;case 100:if("AcDbLine"==j.value){j=V.next();break}default:d(J)}return J},S=function(){var B,E;for(B={type:j.value},j=V.next();"EOF"!==j&&0!==j.code;)switch(j.code){case 10:B.center=w();break;case 40:B.radius=j.value,j=V.next();break;case 50:B.startAngle=Math.PI/180*j.value,j=V.next();break;case 51:E=Math.PI/180*j.value,B.angleLength=E<B.startAngle?E+2*Math.PI-B.startAngle:E-B.startAngle,B.endAngle=E,j=V.next();break;default:d(B)}return B},l=function(){var Y,F;for(Y={type:j.value},j=V.next();"EOF"!==j&&0!==j.code;)switch(j.code){case 10:Y.center=w();break;case 11:Y.major=w();break;case 40:Y.ratio=j.value,j=V.next();break;case 41:Y.startAngle=j.value,j=V.next();break;case 42:F=j.value,Y.angleLength=F<Y.startAngle?F+2*Math.PI-Y.startAngle:F-Y.startAngle,Y.endAngle=F,j=V.next();break;default:d(Y)}return Y},C=function(){var i;for(i={type:j.value},j=V.next();"EOF"!==j&&0!==j.code;)switch(j.code){case 2:i.block=j.value,j=V.next();break;case 10:i.center=w();break;case 41:i.scale=r();break;case 50:i.deg=j.value,j=V.next();break;default:d(i)}return i},i=function(){var Z;for(Z={type:j.value},j=V.next();"EOF"!==j&&0!==j.code;)switch(j.code){case 2:Z.block=j.value,j=V.next();break;case 10:Z.center=w();break;case 41:Z.scale=r();break;case 50:Z.deg=j.value,j=V.next();break;default:d(Z)}return Z},s=function(){var t,R;for(t={type:j.value},j=V.next();"EOF"!==j&&0!==j.code;)switch(j.code){case 10:t.center=w();break;case 11:t.major=w();break;case 40:t.ratio=j.value,j=V.next();break;case 41:t.startAngle=j.value,j=V.next();break;case 42:R=j.value,t.angleLength=R<t.startAngle?R+2*Math.PI-t.startAngle:R-t.startAngle,t.endAngle=R,j=V.next();break;default:d(t)}return t},H=function(){var b;for(b={type:j.value},j=V.next();"EOF"!==j&&0!==j.code;)switch(j.code){case 10:b.startPoint=w();break;case 11:b.endPoint=w();break;case 40:b.textHeight=j.value,j=V.next();break;case 41:b.xScale=j.value,j=V.next();break;case 1:b.text=j.value,j=V.next();break;case 71:b.generationFlags=j.value,j=V.next();break;case 72:b.halign=j.value,j=V.next();break;case 73:b.valign=j.value,j=V.next();break;case 50:b.rotation=2*j.value*Math.PI/360,j=V.next();break;default:d(b)}return b},b=function(){var A;for(A={type:j.value},j=V.next();"EOF"!==j&&0!==j.code;)switch(j.code){case 2:A.block=j.value,j=V.next();break;case 10:A.anchorPoint=w();break;case 11:A.middleOfText=w();break;case 71:A.attachmentPoint=j.value,j=V.next();break;case 42:A.actualMeasurement=j.value,j=V.next();break;case 1:A.text=j.value,j=V.next();break;case 50:A.angle=j.value,j=V.next();break;default:d(A)}return A},G=function(){var X;for(X={type:j.value},X.points=[],j=V.next();"EOF"!==j&&0!==j.code;)switch(j.code){case 10:X.points[0]=w();break;case 11:X.points[1]=w();break;case 12:X.points[2]=w();break;case 13:X.points[3]=w();break;default:d(X)}return X},q=function(){var n;for(n={type:j.value},j=V.next();"EOF"!==j&&0!==j.code;)switch(j.code){case 10:n.position=w();break;case 39:n.thickness=j.value,j=V.next();break;case 100:if("AcDbPoint"==j.value){j=V.next();break}default:d(n)}return n},P=function(W){if(!W)throw new TypeError("entity cannot be undefined or null");W.handle||(W.handle=T++)};return f(),p},I.exports=g},{"./AutoCadColorIndex":1,"./DxfArrayScanner.js":2,loglevel:4}],4:[function(h,V){!function(u,e){"object"==typeof V&&V.exports&&"function"==typeof h?V.exports=e():"function"==typeof y&&"object"==typeof y.amd?y(e):u.log=e()}(this,function(){function j(z){return typeof console===t?!1:console[z]!==J?T(console,z):console.log!==J?T(console,"log"):e}function T(m,M){var E=m[M];if("function"==typeof E.bind)return E.bind(m);try{return Function.prototype.bind.call(E,m)}catch(H){return function(){return Function.prototype.apply.apply(E,[m,arguments])}}}function v(y,W){return function(){typeof console!==t&&(q(W),O[y].apply(O,arguments))}}function q($){for(var q=0;q<n.length;q++){var S=n[q];O[S]=$>q?e:O.methodFactory(S,$)}}function z(G){var Q=(n[G]||"silent").toUpperCase();try{return i.localStorage.loglevel=Q,void 0}catch(f){}try{i.document.cookie="loglevel="+Q+";"}catch(f){}}function H(){var j;try{j=i.localStorage.loglevel}catch(q){}if(typeof j===t)try{j=/loglevel=([^;]+)/.exec(i.document.cookie)[1]}catch(q){}O.levels[j]===J&&(j="WARN"),O.setLevel(O.levels[j],!1)}var O={},e=function(){},t="undefined",n=["trace","debug","info","warn","error"];O.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},O.methodFactory=function(G,B){return j(G)||v(G,B)},O.setLevel=function(s,T){if("string"==typeof s&&O.levels[s.toUpperCase()]!==J&&(s=O.levels[s.toUpperCase()]),!("number"==typeof s&&s>=0&&s<=O.levels.SILENT))throw"log.setLevel() called with invalid level: "+s;return T!==!1&&z(s),q(s),typeof console===t&&s<O.levels.SILENT?"No console available for logging":void 0},O.enableAll=function(V){O.setLevel(O.levels.TRACE,V)},O.disableAll=function($){O.setLevel(O.levels.SILENT,$)};var s=typeof i!==t?i.log:J;return O.noConflict=function(){return typeof i!==t&&i.log===O&&(i.log=s),O},H(),O})},{}]},{},[3])(3)});var X=U.DxfViewer=function(r){var p=this;p.$16w(r)};X.prototype={},X.prototype.constructor=X;var s={LINE:["LINE","POLYLINE","LWPOLYLINE"],CIRCLE:["CIRCLE","ARC"],ELLIPSE:["ELLIPSE"],TEXT:["TEXT","MTEXT"],SOLID:["SOLID"],POINT:["POINT"]};M.defineProperties(X.prototype,{dxf:{get:function(){return this._dxf}}}),X.prototype.$16w=function(J){var E=this,$=E.options={};J=J||{},$.font=J.font||"Courier",$.textScaleRatio=J.textScaleRatio||1,$.size=J.size||512,$.filter=J.filter,$.defaultColor=J.defaultColor||0},X.prototype.toShape=function(g){var y=this;y._bound={xMin:1/0,yMin:1/0,xMax:-1/0,yMax:-1/0},y.parseFile(g),y._shiftX=y._bound.xMin,y._shiftY=y._bound.yMax;var o=y._bound.xMax-y._bound.xMin,$=y._bound.yMax-y._bound.yMin,e=y.options.size/o,_=y.options.size/$;return y._scale=Math.min(e,_),y.shapeComps=[],y.$12w(),y.$11w(),y.$9w(),y.$7w(),y.$8w(),{width:Math.ceil(o*y._scale),height:Math.ceil($*y._scale),comps:y.shapeComps}},X.prototype.$12w=function(){var r,o,S,C,W,e,l,A,J,K,E,F,p,d,w,R,H,u=this,y=u._models;for(r=s.LINE,C=0,W=r.length;W>C;C++){o=r[C],S=y[o];for(A in S)for(J=S[A],e=0,l=J.length;l>e;e++)if(K=J[e],E=K.vertices,E&&E.length){for(w=u.$3w(E[0].x,1),R=u.$3w(E[0].y,2),H={type:"shape",borderColor:A,points:[w,R],segments:[1]},H.borderWidth=Math.max(1,u.$3w(K.width||0)),p=1,d=E.length;d>p;p++)F=E[p],H.points.push(u.$3w(F.x,1),u.$3w(F.y,2)),H.segments.push(2);K.shape&&H.segments.push(5),u.shapeComps.push(H)}}},X.prototype.$11w=function(){var u,P,o,G,S,r,z,Y,b,h,c,H=this,C=H._models;for(u=s.SOLID,G=0,S=u.length;S>G;G++){P=u[G],o=C[P];for(Y in o)for(b=o[Y],r=0,z=b.length;z>r;r++)h=b[r],c=h.points,H.shapeComps.push({type:"shape",background:Y,points:[H.$3w(c[0].x,1),H.$3w(c[0].y,2),H.$3w(c[1].x,1),H.$3w(c[1].y,2),H.$3w(c[3].x,1),H.$3w(c[3].y,2),H.$3w(c[2].x,1),H.$3w(c[2].y,2)],segments:[1,2,2,2,5]})}},X.prototype.extrusionZNagative=function(x){var _=x.extrusionDirection;return _?Math.abs(_.z+1)<1e-5:!1},X.prototype.$9w=function(){var F,d,U,W,j,G,N,T,q,y,D,I,V,w,k,_,f,J,g,L,a=this,S=a._models;for(F=s.CIRCLE,W=0,j=F.length;j>W;W++){d=F[W],U=S[d];for(T in U)for(q=U[T],G=0,N=q.length;N>G;G++){if(y=q[G],D=y.startAngle||0,I=y.angleLength||2*Math.PI,V=D+I,w=a.$3w(y.radius),k=y.addonAngle||0,_=a.$3w(y.center.x,1),f=a.$3w(y.center.y,2),L=y.xInvert^a.extrusionZNagative(y),g=y.yInvert,g||L?L&&g?(D=Math.PI+D,V=Math.PI+V,J=!1):(D=Math.PI*(L?1:2)-D,V=Math.PI*(L?1:2)-V,J=!0):J=!1,J=!J,D=2*Math.PI-D-k,V=2*Math.PI-V-k,J){var t=D;D=V,V=t}a.shapeComps.push({type:"arc",borderColor:T,borderWidth:1,rect:[_-w,f-w,2*w,2*w],arcFrom:D,arcTo:V,arcClose:!1})}}},X.prototype.$8w=function(){var S,C,T,q,Y,I,b,W,y,x,n,L,g,d,p,j,U,z,N,J,R,a,t,w,G,D=this,O=D._models;for(S=s.TEXT,w=D.options.textScaleRatio,q=0,Y=S.length;Y>q;q++){C=S[q],T=O[C];for(W in T)for(y=T[W],I=0,b=y.length;b>I;I++)if(x=y[I],n=x.text,n&&n.length)if("MTEXT"===C?(L=D.$3w(x.height||12),g=D.$3w(x.position.x,1),d=D.$3w(x.position.y,2),J=x.angle?x.angle:x.directionX?Math.atan2(x.directionY,x.directionX):0,J+=x.addonAngle||0,t=1,N=x.attachmentPoint||1,U=N%3,z=Math.floor(N/3)):(L=D.$3w(x.textHeight||12),g=x.startPoint.x,d=x.startPoint.y,J=x.rotation||0,t=x.xScale||1,2===x.generationFlags?J=2*Math.PI-J:4===x.generationFlags?J=Math.PI-J:6===x.generationFlags&&(J=Math.PI+J),g=D.$3w(g,1),d=D.$3w(d,2),U=(x.halign||0)+1,3===x.valign?z=0:2===x.valign?(z=1,x.endPoint&&(g=(g+D.$3w(x.endPoint.x,1))/2)):z=2),D._isAc2015&&(d-=L),J=2*Math.PI-J,z=1===z?"middle":0===z?"top":"bottom",j=0===U?"right":2===U?"center":"left",p=L*w+"px "+D.options.font,"MTEXT"===C)for(n=n.replace(/\\{/g,"#@#"),n=n.replace(/\\}/g,"#@@"),n=n.replace(/({|})/g,""),n=n.replace(/#@#/g,"{"),n=n.replace(/#@@/g,"}"),n=n.replace(/\\[ACT]\d+;/g,""),(G=n.match(/\\f[^;]*;/))&&(n=n.replace(G[0],""),G=G[0].match(/\|p(\d+)/),G&&(p=G[0]/10*L*w+"px "+p)),R=n.split("\\P"),a=0;a<R.length;a++)D.shapeComps.push({type:"text",color:W,text:R[a],rotation:J,rect:[g,d+1.2*a*L,0,0],align:j,vAlign:z,font:p});else D.shapeComps.push({type:"text",color:W,text:n,rotation:J,rect:[g,d,0,0],align:j,vAlign:z,font:p})}},X.prototype.$7w=function(){var r,D,p,i,U,b,k,G,l,u,E,m,I,g,C,j,J,F,K,h,B,V,f=this,y=f._models;for(r=s.ELLIPSE,i=0,U=r.length;U>i;i++){D=r[i],p=y[D];for(G in p)for(l=p[G],b=0,k=l.length;k>b;b++){if(u=l[b],E=u.major,m=Math.atan2(E.y,E.x),I=f.$3w(Math.sqrt(E.x*E.x+E.y*E.y)),g=I*u.ratio,C=u.startAngle||0,j=u.angleLength||2*Math.PI,J=C+j,F=f.$3w(u.center.x,1),K=f.$3w(u.center.y,2),h=u.xInvert,B=u.yInvert^f.extrusionZNagative(u),B^=1,B||h?h&&B?(C=Math.PI+C,J=Math.PI+J,V=!1):(C=Math.PI*(h?1:2)-C,J=Math.PI*(h?1:2)-J,V=!0):V=!1,V){var n=C;C=J,J=n}m=2*Math.PI-m,f.shapeComps.push({type:"arc",borderColor:G,borderWidth:1,rotation:m,rect:[F-I,K-g,2*I,2*g],arcFrom:C,arcTo:J,arcClose:!1,arcOval:!0})}}},X.prototype.$4w=function(m,a,J,H){var F=this,q=F.$2w(a,J);if(q&&(!F.options.filter||!F.options.filter(a))){var n,z,S,g=a.type;if("DIMENSION"!==g&&"INSERT"!==g){(n=m[g])||(n=m[g]={}),(z=n[q])||(z=n[q]=[]);var B=F.extrusionZNagative(a)&&["POINT","LINE","ELLIPSE"].indexOf(g)<0;if(H||B){H||(H={a:1,b:0,c:0,d:1,tx:0,ty:0});var D={};for(var N in a)D[N]=a[N];D.radius&&(D.radius*=Math.sqrt(H.a*H.a+H.b*H.b)),D.textHeight&&(D.textHeight*=Math.sqrt(H.a*H.a+H.b*H.b));var f=B?-1:1,Q=function(R,M){if(R){var u=R.x,e=R.y;return{x:u*f*M.a+e*M.c+M.tx,y:u*f*M.b+e*M.d+M.ty}}};if(D.position=Q(D.position,H),D.startPoint=Q(D.startPoint,H),D.center=Q(D.center,H),"ELLIPSE"===g){var i;i=Q({x:a.major.x+a.center.x,y:a.major.y+a.center.y},H),D.major={x:i.x-D.center.x,y:i.y-D.center.y},F.extrusionZNagative(a)&&(D.major.x*=-1)}var O;D.vertices&&(O=[],D.vertices.forEach(function(u){O.push(Q(u,H))}),D.vertices=O),D.points&&(O=[],D.points.forEach(function(U){O.push(Q(U,H))}),D.points=O);var o=Math.atan2(H.b,H.a),e=Math.cos(o);D.yInvert=H.d*e<0,D.xInvert=H.a*e<0,0!==o&&(D.addonAngle=o),a=D}F.$8dw(a),z.push(a)}else{if(!a.block)return;if(F.extrusionZNagative(a))return;var T=J.blocks[a.block];if(!T||!T.entities)return;var c=H;if("INSERT"===g){var r=a.scale?a.scale.x:1,j=a.scale?a.scale.y:1,l=0,R=1,V=0;if(a.deg&&(l=a.deg*Math.PI/180,R=Math.cos(l),V=Math.sin(l)),H){var L=r*R,E=r*V,A=-j*V,y=j*R,P=a.center.x,Y=a.center.y;c={a:H.a*L+H.c*E,b:H.b*L+H.d*E,c:H.a*A+H.c*y,d:H.b*A+H.d*y,tx:H.a*P+H.c*Y+H.tx,ty:H.b*P+H.d*Y+H.ty}}else c={a:r*R,b:r*V,c:-j*V,d:j*R,tx:a.center.x,ty:a.center.y}}for(S=0;S<T.entities.length;S++)F.$4w(m,T.entities[S],J,c)}}},X.prototype.$8cw=function(s){for(var g=1/0,o=1/0,x=-1/0,w=-1/0,r=0,N=s.length;N>r;r++){var m=s[r];g=Math.min(g,m.x),o=Math.min(o,m.y),x=Math.max(x,m.x),w=Math.max(w,m.y)}return{xMin:g,yMin:o,xMax:x,yMax:w}},X.prototype.$8dw=function(Z){var f,m,l=this;m=Z.type;for(f in s)if(s[f].indexOf(m)>=0)break;var F,A,B,M,x,W,o,K,C,D,Y,O,h,y,P,G,u=l.$8cw;switch(f){case"LINE":F=u(Z.vertices);break;case"SOLID":F=u(Z.points);break;case"POINT":if(!Z.position)return;A=Z.position.x,B=Z.position.y,F={xMin:A,yMin:B,xMax:A,yMax:B};break;case"CIRCLE":for(A=Z.center.x,B=Z.center.y,M=Z.radius,x=[],W=Z.startAngle||0,o=W+(Z.angleLength||2*Math.PI),K=Z.xInvert^l.extrusionZNagative(Z),C=Z.yInvert,D=K?-1:1,Y=C?-1:1,O=W;O<o+Math.PI/30;O+=Math.PI/30)O=Math.min(O,o),x.push({x:A+D*M*Math.cos(O),y:B+Y*M*Math.sin(O)});F=u(x);break;case"ELLIPSE":for(A=Z.center.x,B=Z.center.y,x=[],h=Math.sqrt(Z.major.x*Z.major.x+Z.major.y*Z.major.y),y=h*Z.ratio,M=Math.atan2(Z.major.y,Z.major.x),P=Math.sin(M),G=Math.cos(M),W=Z.startAngle||0,o=W+(Z.angleLength||2*Math.PI),K=Z.xInvert,C=Z.yInvert^l.extrusionZNagative(Z),D=K?-1:1,Y=C?-1:1,O=W;O<o+Math.PI/30;O+=Math.PI/30){O=Math.min(O,o);var g=D*h*Math.cos(O),T=Y*y*Math.sin(O);x.push({x:A+(G*g-P*T),y:B+(P*g+G*T)})}F=u(x);break;default:return}var p=l._bound;p.xMin=Math.min(p.xMin,F.xMin),p.yMin=Math.min(p.yMin,F.yMin),p.xMax=Math.max(p.xMax,F.xMax),p.yMax=Math.max(p.yMax,F.yMax)},X.prototype.parseFile=function(p){var t=this,f=new DxfParser,K=f.parseSync(p);t._dxf=K,t._isAc2015="AC1015"===K.header.$ACADVER;var b,v,J,q=t._models={};for(b=0,v=K.entities.length;v>b;b++)J=K.entities[b],t.$4w(q,J,K)},X.prototype.$3w=function(a,R){var c,J=this;return c=2===R?-(a-J._shiftY):1===R?a-J._shiftX:a,c*J._scale},X.prototype.$2w=function(L,b){var l,Z=this;if(b.tables&&b.tables.layer&&(l=b.tables.layer.layers[L.layer]),!l||l.visible){var x;return L.color!==J?(x=L.color,0===x&&(x=Z.options.defaultColor)):l&&(x=l.color),x&&16777215!==x||(x=Z.options.defaultColor),"#"+((1<<24)+x).toString(16).slice(1)}}}("undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:this,Object);
|