dxf-parser.js 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617
  1. !function(e, a) {
  2. "object" == typeof exports && "object" == typeof module ? module.exports = a() : "function" == typeof define && define.amd ? define([], a) : "object" == typeof exports ? exports.DxfParser = a() : e.DxfParser = a()
  3. }("undefined" != typeof self ? self : this, function() {
  4. return function(e) {
  5. var a = {};
  6. function t(r) {
  7. if (a[r])
  8. return a[r].exports;
  9. var n = a[r] = {
  10. i: r,
  11. l: !1,
  12. exports: {}
  13. };
  14. return e[r].call(n.exports, n, n.exports, t),
  15. n.l = !0,
  16. n.exports
  17. }
  18. return t.m = e,
  19. t.c = a,
  20. t.d = function(e, a, r) {
  21. t.o(e, a) || Object.defineProperty(e, a, {
  22. enumerable: !0,
  23. get: r
  24. })
  25. }
  26. ,
  27. t.r = function(e) {
  28. "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, {
  29. value: "Module"
  30. }),
  31. Object.defineProperty(e, "__esModule", {
  32. value: !0
  33. })
  34. }
  35. ,
  36. t.t = function(e, a) {
  37. if (1 & a && (e = t(e)),
  38. 8 & a)
  39. return e;
  40. if (4 & a && "object" == typeof e && e && e.__esModule)
  41. return e;
  42. var r = Object.create(null);
  43. if (t.r(r),
  44. Object.defineProperty(r, "default", {
  45. enumerable: !0,
  46. value: e
  47. }),
  48. 2 & a && "string" != typeof e)
  49. for (var n in e)
  50. t.d(r, n, function(a) {
  51. return e[a]
  52. }
  53. .bind(null, n));
  54. return r
  55. }
  56. ,
  57. t.n = function(e) {
  58. var a = e && e.__esModule ? function() {
  59. return e.default
  60. }
  61. : function() {
  62. return e
  63. }
  64. ;
  65. return t.d(a, "a", a),
  66. a
  67. }
  68. ,
  69. t.o = function(e, a) {
  70. return Object.prototype.hasOwnProperty.call(e, a)
  71. }
  72. ,
  73. t.p = "",
  74. t(t.s = 1)
  75. }([function(e, a, t) {
  76. var r, n;
  77. !function(o, c) {
  78. "use strict";
  79. void 0 === (n = "function" == typeof (r = function() {
  80. var e = function() {}
  81. , a = "undefined"
  82. , t = ["trace", "debug", "info", "warn", "error"];
  83. function r(e, a) {
  84. var t = e[a];
  85. if ("function" == typeof t.bind)
  86. return t.bind(e);
  87. try {
  88. return Function.prototype.bind.call(t, e)
  89. } catch (a) {
  90. return function() {
  91. return Function.prototype.apply.apply(t, [e, arguments])
  92. }
  93. }
  94. }
  95. function n(a, r) {
  96. for (var n = 0; n < t.length; n++) {
  97. var o = t[n];
  98. this[o] = n < a ? e : this.methodFactory(o, a, r)
  99. }
  100. this.log = this.debug
  101. }
  102. function o(t, o, c) {
  103. return function(t) {
  104. "debug" === t && (t = "log");
  105. return typeof console !== a && (void 0 !== console[t] ? r(console, t) : void 0 !== console.log ? r(console, "log") : e)
  106. }(t) || function(e, t, r) {
  107. return function() {
  108. typeof console !== a && (n.call(this, t, r),
  109. this[e].apply(this, arguments))
  110. }
  111. }
  112. .apply(this, arguments)
  113. }
  114. function c(e, r, c) {
  115. var i, u = this, s = "loglevel";
  116. function l() {
  117. var e;
  118. if (typeof window !== a) {
  119. try {
  120. e = window.localStorage[s]
  121. } catch (e) {}
  122. if (typeof e === a)
  123. try {
  124. var t = window.document.cookie
  125. , r = t.indexOf(encodeURIComponent(s) + "=");
  126. -1 !== r && (e = /^([^;]+)/.exec(t.slice(r))[1])
  127. } catch (e) {}
  128. return void 0 === u.levels[e] && (e = void 0),
  129. e
  130. }
  131. }
  132. e && (s += ":" + e),
  133. u.name = e,
  134. u.levels = {
  135. TRACE: 0,
  136. DEBUG: 1,
  137. INFO: 2,
  138. WARN: 3,
  139. ERROR: 4,
  140. SILENT: 5
  141. },
  142. u.methodFactory = c || o,
  143. u.getLevel = function() {
  144. return i
  145. }
  146. ,
  147. u.setLevel = function(r, o) {
  148. if ("string" == typeof r && void 0 !== u.levels[r.toUpperCase()] && (r = u.levels[r.toUpperCase()]),
  149. !("number" == typeof r && r >= 0 && r <= u.levels.SILENT))
  150. throw "log.setLevel() called with invalid level: " + r;
  151. if (i = r,
  152. !1 !== o && function(e) {
  153. var r = (t[e] || "silent").toUpperCase();
  154. if (typeof window === a)
  155. return;
  156. try {
  157. return void (window.localStorage[s] = r)
  158. } catch (e) {}
  159. try {
  160. window.document.cookie = encodeURIComponent(s) + "=" + r + ";"
  161. } catch (e) {}
  162. }(r),
  163. n.call(u, r, e),
  164. typeof console === a && r < u.levels.SILENT)
  165. return "No console available for logging"
  166. }
  167. ,
  168. u.setDefaultLevel = function(e) {
  169. l() || u.setLevel(e, !1)
  170. }
  171. ,
  172. u.enableAll = function(e) {
  173. u.setLevel(u.levels.TRACE, e)
  174. }
  175. ,
  176. u.disableAll = function(e) {
  177. u.setLevel(u.levels.SILENT, e)
  178. }
  179. ;
  180. var v = l();
  181. null == v && (v = null == r ? "WARN" : r),
  182. u.setLevel(v, !1)
  183. }
  184. var i = new c
  185. , u = {};
  186. i.getLogger = function(e) {
  187. if ("string" != typeof e || "" === e)
  188. throw new TypeError("You must supply a name when creating a logger.");
  189. var a = u[e];
  190. return a || (a = u[e] = new c(e,i.getLevel(),i.methodFactory)),
  191. a
  192. }
  193. ;
  194. var s = typeof window !== a ? window.log : void 0;
  195. return i.noConflict = function() {
  196. return typeof window !== a && window.log === i && (window.log = s),
  197. i
  198. }
  199. ,
  200. i.getLoggers = function() {
  201. return u
  202. }
  203. ,
  204. i
  205. }
  206. ) ? r.call(a, t, a, e) : r) || (e.exports = n)
  207. }()
  208. }
  209. , function(e, a, t) {
  210. "use strict";
  211. function r(e) {
  212. this._pointer = 0,
  213. this._data = e,
  214. this._eof = !1
  215. }
  216. function n(e, a) {
  217. return e <= 9 ? a : e >= 10 && e <= 59 ? parseFloat(a) : e >= 60 && e <= 99 ? parseInt(a) : e >= 100 && e <= 109 ? a : e >= 110 && e <= 149 ? parseFloat(a) : e >= 160 && e <= 179 ? parseInt(a) : e >= 210 && e <= 239 ? parseFloat(a) : e >= 270 && e <= 289 ? parseInt(a) : e >= 290 && e <= 299 ? function(e) {
  218. if ("0" === e)
  219. return !1;
  220. if ("1" === e)
  221. return !0;
  222. throw TypeError("String '" + e + "' cannot be cast to Boolean type")
  223. }(a) : e >= 300 && e <= 369 ? a : e >= 370 && e <= 389 ? parseInt(a) : e >= 390 && e <= 399 ? a : e >= 400 && e <= 409 ? parseInt(a) : e >= 410 && e <= 419 ? a : e >= 420 && e <= 429 ? parseInt(a) : e >= 430 && e <= 439 ? a : e >= 440 && e <= 459 ? parseInt(a) : e >= 460 && e <= 469 ? parseFloat(a) : e >= 470 && e <= 481 ? a : 999 === e ? a : e >= 1e3 && e <= 1009 ? a : e >= 1010 && e <= 1059 ? parseFloat(a) : e >= 1060 && e <= 1071 ? parseInt(a) : (console.log("WARNING: Group code does not have a defined type: %j", {
  224. code: e,
  225. value: a
  226. }),
  227. a)
  228. }
  229. t.r(a),
  230. r.prototype.next = function() {
  231. var e;
  232. if (!this.hasNext())
  233. 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]);
  234. return e = {
  235. code: parseInt(this._data[this._pointer])
  236. },
  237. this._pointer++,
  238. e.value = n(e.code, this._data[this._pointer].trim()),
  239. this._pointer++,
  240. 0 === e.code && "EOF" === e.value && (this._eof = !0),
  241. this.lastReadGroup = e,
  242. e
  243. }
  244. ,
  245. r.prototype.peek = function() {
  246. if (!this.hasNext())
  247. 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]);
  248. var e = {
  249. code: parseInt(this._data[this._pointer])
  250. };
  251. return e.value = n(e.code, this._data[this._pointer + 1].trim()),
  252. e
  253. }
  254. ,
  255. r.prototype.rewind = function(e) {
  256. e = e || 1,
  257. this._pointer = this._pointer - 2 * e
  258. }
  259. ,
  260. r.prototype.hasNext = function() {
  261. return !this._eof && !(this._pointer > this._data.length - 2)
  262. }
  263. ,
  264. r.prototype.isEOF = function() {
  265. return this._eof
  266. }
  267. ;
  268. var o = [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];
  269. function c(e) {
  270. var a = {};
  271. e.rewind();
  272. var t = e.next()
  273. , r = t.code;
  274. if (a.x = t.value,
  275. r += 10,
  276. (t = e.next()).code != r)
  277. throw new Error("Expected code for point value to be " + r + " but got " + t.code + ".");
  278. return a.y = t.value,
  279. r += 10,
  280. (t = e.next()).code != r ? (e.rewind(),
  281. a) : (a.z = t.value,
  282. a)
  283. }
  284. function i(e, a) {
  285. switch (a.code) {
  286. case 0:
  287. e.type = a.value;
  288. break;
  289. case 5:
  290. e.handle = a.value;
  291. /* if(e.handle == "2FDDB"){
  292. console.log(1)
  293. } */
  294. break;
  295. case 6:
  296. e.lineType = a.value;
  297. break;
  298. case 8:
  299. e.layer = a.value;
  300. break;
  301. case 48:
  302. e.lineTypeScale = a.value;
  303. break;
  304. case 60:
  305. e.visible = 0 === a.value;
  306. break;
  307. case 62:
  308. e.colorIndex = a.value,
  309. e.color = (t = Math.abs(a.value),
  310. o[t]);
  311. break;
  312. case 67:
  313. e.inPaperSpace = 0 !== a.value;
  314. break;
  315. case 100:
  316. break;
  317. case 330:
  318. e.ownerHandle = a.value;
  319. break;
  320. case 347:
  321. e.materialObjectHandle = a.value;
  322. break;
  323. case 370:
  324. e.lineweight = a.value;
  325. break;
  326. case 420:
  327. e.color = a.value;
  328. break;
  329. case 1e3:
  330. e.extendedData = e.extendedData || {},
  331. e.extendedData.customStrings = e.extendedData.customStrings || [],
  332. e.extendedData.customStrings.push(a.value);
  333. break;
  334. case 1001:
  335. e.extendedData = e.extendedData || {},
  336. e.extendedData.applicationName = a.value;
  337. break;
  338. default:
  339. return !1
  340. }
  341. var t;
  342. return !0
  343. }
  344. function u() {}
  345. function s(e, a) {
  346. var t, r = [], n = !1, o = !1;
  347. for (t = 0; t <= 4; t++) {
  348. for (var c = {}; "EOF" !== a && 0 !== a.code && !o; ) {
  349. switch (a.code) {
  350. case 10:
  351. case 11:
  352. case 12:
  353. case 13:
  354. if (n) {
  355. o = !0;
  356. continue
  357. }
  358. c.x = a.value,
  359. n = !0;
  360. break;
  361. case 20:
  362. case 21:
  363. case 22:
  364. case 23:
  365. c.y = a.value;
  366. break;
  367. case 30:
  368. case 31:
  369. case 32:
  370. case 33:
  371. c.z = a.value;
  372. break;
  373. default:
  374. return r
  375. }
  376. a = e.next()
  377. }
  378. r.push(c),
  379. n = !1,
  380. o = !1
  381. }
  382. return e.rewind(),
  383. r
  384. }
  385. function l() {}
  386. function v() {}
  387. function d() {}
  388. function b() {}
  389. function p() {}
  390. function f() {}
  391. function k() {}
  392. function y() {}
  393. function x(e, a) {
  394. if (!e || e <= 0)
  395. throw Error("n must be greater than 0 verticies");
  396. var t, r = [], n = !1, o = !1, c = a.lastReadGroup;
  397. for (t = 0; t < e; t++) {
  398. for (var i = {}; "EOF" !== c && 0 !== c.code && !o; ) {
  399. switch (c.code) {
  400. case 10:
  401. if (n) {
  402. o = !0;
  403. continue
  404. }
  405. i.x = c.value,
  406. n = !0;
  407. break;
  408. case 20:
  409. i.y = c.value;
  410. break;
  411. case 30:
  412. i.z = c.value;
  413. break;
  414. case 40:
  415. i.startWidth = c.value;
  416. break;
  417. case 41:
  418. i.endWidth = c.value;
  419. break;
  420. case 42:
  421. 0 != c.value && (i.bulge = c.value);
  422. break;
  423. default:
  424. return n && r.push(i),
  425. r
  426. }
  427. c = a.next()
  428. }
  429. r.push(i),
  430. n = !1,
  431. o = !1
  432. }
  433. return a.rewind(),
  434. r
  435. }
  436. function h() {}
  437. function g() {}
  438. function E() {}
  439. function w() {}
  440. function m(e, a) {
  441. var t = {
  442. type: a.value
  443. };
  444. for (a = e.next(); "EOF" != a && 0 != a.code; )
  445. i(t, a),
  446. a = e.next();
  447. return t
  448. }
  449. function P() {}
  450. function F() {}
  451. function O() {}
  452. u.ForEntityName = "3DFACE",
  453. u.prototype.parseEntity = function(e, a) {
  454. var t = {
  455. type: a.value,
  456. vertices: []
  457. };
  458. for (a = e.next(); "EOF" !== a && 0 !== a.code; ) {
  459. switch (a.code) {
  460. case 70:
  461. t.shape = 1 == (1 & a.value),
  462. t.hasContinuousLinetypePattern = 128 == (128 & a.value);
  463. break;
  464. case 10:
  465. t.vertices = s(e, a),
  466. a = e.lastReadGroup;
  467. break;
  468. default:
  469. i(t, a)
  470. }
  471. a = e.next()
  472. }
  473. return t
  474. }
  475. ,
  476. l.ForEntityName = "ARC",
  477. l.prototype.parseEntity = function(e, a) {
  478. var t;
  479. for (t = {
  480. type: a.value
  481. },
  482. a = e.next(); "EOF" !== a && 0 !== a.code; ) {
  483. switch (a.code) {
  484. case 10:
  485. t.center = c(e);
  486. break;
  487. case 40:
  488. t.radius = a.value;
  489. break;
  490. case 50:
  491. t.startAngle = Math.PI / 180 * a.value;
  492. break;
  493. case 51:
  494. t.endAngle = Math.PI / 180 * a.value,
  495. t.angleLength = t.endAngle - t.startAngle;
  496. break;
  497. default:
  498. i(t, a)
  499. }
  500. a = e.next()
  501. }
  502. return t
  503. }
  504. ,
  505. v.ForEntityName = "ATTDEF",
  506. v.prototype.parseEntity = function(e, a) {
  507. var t = {
  508. type: a.value,
  509. scale: 1,
  510. textStyle: "STANDARD"
  511. };
  512. for (a = e.next(); "EOF" !== a && 0 !== a.code; ) {
  513. switch (a.code) {
  514. case 1:
  515. t.text = a.value;
  516. break;
  517. case 2:
  518. t.tag = a.value;
  519. break;
  520. case 3:
  521. t.prompt = a.value;
  522. break;
  523. case 7:
  524. t.textStyle = a.value;
  525. break;
  526. case 10:
  527. t.startPoint = c(e);
  528. break;
  529. case 11:
  530. t.endPoint = c(e);
  531. break;
  532. case 39:
  533. t.thickness = a.value;
  534. break;
  535. case 40:
  536. t.textHeight = a.value;
  537. break;
  538. case 41:
  539. t.scale = a.value;
  540. break;
  541. case 50:
  542. t.rotation = a.value;
  543. break;
  544. case 51:
  545. t.obliqueAngle = a.value;
  546. break;
  547. case 70:
  548. t.invisible = !!(1 & a.value),
  549. t.constant = !!(2 & a.value),
  550. t.verificationRequired = !!(4 & a.value),
  551. t.preset = !!(8 & a.value);
  552. break;
  553. case 71:
  554. t.backwards = !!(2 & a.value),
  555. t.mirrored = !!(4 & a.value);
  556. break;
  557. case 72:
  558. t.horizontalJustification = a.value;
  559. break;
  560. case 73:
  561. t.fieldLength = a.value;
  562. break;
  563. case 74:
  564. t.verticalJustification = a.value;
  565. break;
  566. case 100:
  567. break;
  568. case 210:
  569. t.extrusionDirectionX = a.value;
  570. break;
  571. case 220:
  572. t.extrusionDirectionY = a.value;
  573. break;
  574. case 230:
  575. t.extrusionDirectionZ = a.value;
  576. break;
  577. default:
  578. i(t, a)
  579. }
  580. a = e.next()
  581. }
  582. return t
  583. }
  584. ,
  585. d.ForEntityName = "CIRCLE",
  586. d.prototype.parseEntity = function(e, a) {
  587. var t, r;
  588. for (t = {
  589. type: a.value
  590. },
  591. a = e.next(); "EOF" !== a && 0 !== a.code; ) {
  592. switch (a.code) {
  593. case 10:
  594. t.center = c(e);
  595. break;
  596. case 40:
  597. t.radius = a.value;
  598. break;
  599. case 50:
  600. t.startAngle = Math.PI / 180 * a.value;
  601. break;
  602. case 51:
  603. (r = Math.PI / 180 * a.value) < t.startAngle ? t.angleLength = r + 2 * Math.PI - t.startAngle : t.angleLength = r - t.startAngle,
  604. t.endAngle = r;
  605. break;
  606. default:
  607. i(t, a)
  608. }
  609. a = e.next()
  610. }
  611. return t
  612. }
  613. ,
  614. b.ForEntityName = "DIMENSION",
  615. b.prototype.parseEntity = function(e, a) {
  616. var t;
  617. for (t = {
  618. type: a.value
  619. },
  620. a = e.next(); "EOF" !== a && 0 !== a.code; ) {
  621. switch (a.code) {
  622. case 2:
  623. t.block = a.value;
  624. break;
  625. case 10:
  626. t.anchorPoint = c(e);
  627. break;
  628. case 11:
  629. t.middleOfText = c(e);
  630. break;
  631. case 12:
  632. t.insertionPoint = c(e);
  633. break;
  634. case 13:
  635. t.linearOrAngularPoint1 = c(e);
  636. break;
  637. case 14:
  638. t.linearOrAngularPoint2 = c(e);
  639. break;
  640. case 15:
  641. t.diameterOrRadiusPoint = c(e);
  642. break;
  643. case 16:
  644. t.arcPoint = c(e);
  645. break;
  646. case 70:
  647. t.dimensionType = a.value;
  648. break;
  649. case 71:
  650. t.attachmentPoint = a.value;
  651. break;
  652. case 42:
  653. t.actualMeasurement = a.value;
  654. break;
  655. case 1:
  656. t.text = a.value;
  657. break;
  658. case 50:
  659. t.angle = a.value;
  660. break;
  661. default:
  662. i(t, a)
  663. }
  664. a = e.next()
  665. }
  666. return t
  667. }
  668. ,
  669. p.ForEntityName = "ELLIPSE",
  670. p.prototype.parseEntity = function(e, a) {
  671. var t;
  672. for (t = {
  673. type: a.value
  674. },
  675. a = e.next(); "EOF" !== a && 0 !== a.code; ) {
  676. switch (a.code) {
  677. case 10:
  678. t.center = c(e);
  679. break;
  680. case 11:
  681. t.majorAxisEndPoint = c(e);
  682. break;
  683. case 40:
  684. t.axisRatio = a.value;
  685. break;
  686. case 41:
  687. t.startAngle = a.value;
  688. break;
  689. case 42:
  690. t.endAngle = a.value;
  691. break;
  692. case 2:
  693. t.name = a.value;
  694. break;
  695. default:
  696. i(t, a)
  697. }
  698. a = e.next()
  699. }
  700. return t
  701. }
  702. ,
  703. f.ForEntityName = "INSERT",
  704. f.prototype.parseEntity = function(e, a) {
  705. var t;
  706. for (t = {
  707. type: a.value
  708. },
  709. a = e.next(); "EOF" !== a && 0 !== a.code; ) {
  710. switch (a.code) {
  711. case 2:
  712. t.name = a.value;
  713. break;
  714. case 41:
  715. t.xScale = a.value;
  716. break;
  717. case 42:
  718. t.yScale = a.value;
  719. break;
  720. case 43:
  721. t.zScale = a.value;
  722. break;
  723. case 10:
  724. t.position = c(e);
  725. break;
  726. case 50:
  727. t.rotation = a.value;
  728. break;
  729. case 70:
  730. t.columnCount = a.value;
  731. break;
  732. case 71:
  733. t.rowCount = a.value;
  734. break;
  735. case 44:
  736. t.columnSpacing = a.value;
  737. break;
  738. case 45:
  739. t.rowSpacing = a.value;
  740. break;
  741. case 210:
  742. t.extrusionDirection = c(e);
  743. break;
  744. default:
  745. i(t, a)
  746. }
  747. a = e.next()
  748. }
  749. return t
  750. }
  751. ,
  752. k.ForEntityName = "LINE",
  753. k.prototype.parseEntity = function(e, a) {
  754. var t = {
  755. type: a.value,
  756. vertices: []
  757. };
  758. for (a = e.next(); "EOF" !== a && 0 !== a.code; ) {
  759. switch (a.code) {
  760. case 10:
  761. t.vertices.unshift(c(e));
  762. break;
  763. case 11:
  764. t.vertices.push(c(e));
  765. break;
  766. case 210:
  767. t.extrusionDirection = c(e);
  768. break;
  769. case 100:
  770. break;
  771. default:
  772. i(t, a)
  773. }
  774. a = e.next()
  775. }
  776. return t
  777. }
  778. ,
  779. y.ForEntityName = "LWPOLYLINE",
  780. y.prototype.parseEntity = function(e, a) {
  781. var t = {
  782. type: a.value,
  783. vertices: []
  784. }
  785. , r = 0;
  786. for (a = e.next(); "EOF" !== a && 0 !== a.code; ) {
  787. switch (a.code) {
  788. case 38:
  789. t.elevation = a.value;
  790. break;
  791. case 39:
  792. t.depth = a.value;
  793. break;
  794. case 70:
  795. t.shape = 1 == (1 & a.value),
  796. t.hasContinuousLinetypePattern = 128 == (128 & a.value);
  797. break;
  798. case 90:
  799. r = a.value;
  800. break;
  801. case 10:
  802. //t.vertices = x(r, e);
  803. //改,因有的文件有点问题,可能版本原因
  804. t.vertices.push(...x(r, e))//有的文件同一个entity需要多次执行到这里,所以不能直接覆盖,要push
  805. t.vertices = t.vertices.filter(e=>e.x!=void 0)//而且会出现空的vertix:{},所以排除下
  806. break;
  807. case 43:
  808. 0 !== a.value && (t.width = a.value);
  809. break;
  810. case 210:
  811. t.extrusionDirectionX = a.value;
  812. break;
  813. case 220:
  814. t.extrusionDirectionY = a.value;
  815. break;
  816. case 230:
  817. t.extrusionDirectionZ = a.value;
  818. break;
  819. default:
  820. i(t, a)
  821. }
  822. a = e.next()
  823. }
  824. return t
  825. }
  826. ,
  827. h.ForEntityName = "MTEXT",
  828. h.prototype.parseEntity = function(e, a) {
  829. var t = {
  830. type: a.value
  831. };
  832. for (a = e.next(); "EOF" !== a && 0 !== a.code; ) {
  833. switch (a.code) {
  834. case 3:
  835. case 1:
  836. t.text ? t.text += a.value : t.text = a.value;
  837. break;
  838. case 10:
  839. t.position = c(e);
  840. break;
  841. case 40:
  842. t.height = a.value;
  843. break;
  844. case 41:
  845. t.width = a.value;
  846. break;
  847. case 50:
  848. t.rotation = a.value;
  849. break;
  850. case 71:
  851. t.attachmentPoint = a.value;
  852. break;
  853. case 72:
  854. t.drawingDirection = a.value;
  855. break;
  856. default:
  857. i(t, a)
  858. }
  859. a = e.next()
  860. }
  861. return t
  862. }
  863. ,
  864. g.ForEntityName = "POINT",
  865. g.prototype.parseEntity = function(e, a) {
  866. var t;
  867. for (t = {
  868. type: a.value
  869. },
  870. a = e.next(); "EOF" !== a && 0 !== a.code; ) {
  871. switch (a.code) {
  872. case 10:
  873. t.position = c(e);
  874. break;
  875. case 39:
  876. t.thickness = a.value;
  877. break;
  878. case 210:
  879. t.extrusionDirection = c(e);
  880. break;
  881. case 100:
  882. break;
  883. default:
  884. i(t, a)
  885. }
  886. a = e.next()
  887. }
  888. return t
  889. }
  890. ,
  891. E.ForEntityName = "VERTEX",
  892. E.prototype.parseEntity = function(e, a) {
  893. var t = {
  894. type: a.value
  895. };
  896. for (a = e.next(); "EOF" !== a && 0 !== a.code; ) {
  897. switch (a.code) {
  898. case 10:
  899. t.x = a.value;
  900. break;
  901. case 20:
  902. t.y = a.value;
  903. break;
  904. case 30:
  905. t.z = a.value;
  906. break;
  907. case 40:
  908. case 41:
  909. case 42:
  910. 0 != a.value && (t.bulge = a.value);
  911. break;
  912. case 70:
  913. t.curveFittingVertex = 0 != (1 & a.value),
  914. t.curveFitTangent = 0 != (2 & a.value),
  915. t.splineVertex = 0 != (8 & a.value),
  916. t.splineControlPoint = 0 != (16 & a.value),
  917. t.threeDPolylineVertex = 0 != (32 & a.value),
  918. t.threeDPolylineMesh = 0 != (64 & a.value),
  919. t.polyfaceMeshVertex = 0 != (128 & a.value);
  920. break;
  921. case 50:
  922. case 71:
  923. t.faceA = a.value;
  924. break;
  925. case 72:
  926. t.faceB = a.value;
  927. break;
  928. case 73:
  929. t.faceC = a.value;
  930. break;
  931. case 74:
  932. t.faceD = a.value;
  933. break;
  934. default:
  935. i(t, a)
  936. }
  937. a = e.next()
  938. }
  939. return t
  940. }
  941. ,
  942. w.ForEntityName = "POLYLINE",
  943. w.prototype.parseEntity = function(e, a) {
  944. var t = {
  945. type: a.value,
  946. vertices: []
  947. };
  948. for (a = e.next(); "EOF" !== a && 0 !== a.code; ) {
  949. switch (a.code) {
  950. case 10:
  951. case 20:
  952. case 30:
  953. case 39:
  954. t.thickness = a.value;
  955. break;
  956. case 40:
  957. case 41:
  958. break;
  959. case 70:
  960. t.shape = 0 != (1 & a.value),
  961. t.includesCurveFitVertices = 0 != (2 & a.value),
  962. t.includesSplineFitVertices = 0 != (4 & a.value),
  963. t.is3dPolyline = 0 != (8 & a.value),
  964. t.is3dPolygonMesh = 0 != (16 & a.value),
  965. t.is3dPolygonMeshClosed = 0 != (32 & a.value),
  966. t.isPolyfaceMesh = 0 != (64 & a.value),
  967. t.hasContinuousLinetypePattern = 0 != (128 & a.value);
  968. break;
  969. case 71:
  970. case 72:
  971. case 73:
  972. case 74:
  973. case 75:
  974. break;
  975. case 210:
  976. t.extrusionDirection = c(e);
  977. break;
  978. default:
  979. i(t, a)
  980. }
  981. a = e.next()
  982. }
  983. return t.vertices = function(e, a) {
  984. var t = new E
  985. , r = [];
  986. for (; !e.isEOF(); )
  987. if (0 === a.code)
  988. if ("VERTEX" === a.value)
  989. r.push(t.parseEntity(e, a)),
  990. a = e.lastReadGroup;
  991. else if ("SEQEND" === a.value) {
  992. m(e, a);
  993. break
  994. }
  995. return r
  996. }(e, a),
  997. t
  998. }
  999. ,
  1000. P.ForEntityName = "SOLID",
  1001. P.prototype.parseEntity = function(e, a) {
  1002. var t;
  1003. for ((t = {
  1004. type: a.value
  1005. }).points = [],
  1006. a = e.next(); "EOF" !== a && 0 !== a.code; ) {
  1007. switch (a.code) {
  1008. case 10:
  1009. t.points[0] = c(e);
  1010. break;
  1011. case 11:
  1012. t.points[1] = c(e);
  1013. break;
  1014. case 12:
  1015. t.points[2] = c(e);
  1016. break;
  1017. case 13:
  1018. t.points[3] = c(e);
  1019. break;
  1020. case 210:
  1021. t.extrusionDirection = c(e);
  1022. break;
  1023. default:
  1024. i(t, a)
  1025. }
  1026. a = e.next()
  1027. }
  1028. return t
  1029. }
  1030. ,
  1031. F.ForEntityName = "SPLINE",
  1032. F.prototype.parseEntity = function(e, a) {
  1033. var t;
  1034. for (t = {
  1035. type: a.value
  1036. },
  1037. a = e.next(); "EOF" !== a && 0 !== a.code; ) {
  1038. switch (a.code) {
  1039. case 10:
  1040. t.controlPoints || (t.controlPoints = []),
  1041. t.controlPoints.push(c(e));
  1042. break;
  1043. case 11:
  1044. t.fitPoints || (t.fitPoints = []),
  1045. t.fitPoints.push(c(e));
  1046. break;
  1047. case 12:
  1048. t.startTangent = c(e);
  1049. break;
  1050. case 13:
  1051. t.endTangent = c(e);
  1052. break;
  1053. case 40:
  1054. t.knotValues || (t.knotValues = []),
  1055. t.knotValues.push(a.value);
  1056. break;
  1057. case 70:
  1058. 0 != (1 & a.value) && (t.closed = !0),
  1059. 0 != (2 & a.value) && (t.periodic = !0),
  1060. 0 != (4 & a.value) && (t.rational = !0),
  1061. 0 != (8 & a.value) && (t.planar = !0),
  1062. 0 != (16 & a.value) && (t.planar = !0,
  1063. t.linear = !0);
  1064. break;
  1065. case 71:
  1066. t.degreeOfSplineCurve = a.value;
  1067. break;
  1068. case 72:
  1069. t.numberOfKnots = a.value;
  1070. break;
  1071. case 73:
  1072. t.numberOfControlPoints = a.value;
  1073. break;
  1074. case 74:
  1075. t.numberOfFitPoints = a.value;
  1076. break;
  1077. case 210:
  1078. t.normalVector = c(e);
  1079. break;
  1080. default:
  1081. i(t, a)
  1082. }
  1083. a = e.next()
  1084. }
  1085. return t
  1086. }
  1087. ,
  1088. O.ForEntityName = "TEXT",
  1089. O.prototype.parseEntity = function(e, a) {
  1090. var t;
  1091. for (t = {
  1092. type: a.value
  1093. },
  1094. a = e.next(); "EOF" !== a && 0 !== a.code; ) {
  1095. switch (a.code) {
  1096. case 10:
  1097. t.startPoint = c(e);
  1098. break;
  1099. case 11:
  1100. t.endPoint = c(e);
  1101. break;
  1102. case 40:
  1103. t.textHeight = a.value;
  1104. break;
  1105. case 41:
  1106. t.xScale = a.value;
  1107. break;
  1108. case 50:
  1109. t.rotation = a.value;
  1110. break;
  1111. case 1:
  1112. t.text = a.value;
  1113. break;
  1114. case 72:
  1115. t.halign = a.value;
  1116. break;
  1117. case 73:
  1118. t.valign = a.value;
  1119. break;
  1120. default:
  1121. i(t, a)
  1122. }
  1123. a = e.next()
  1124. }
  1125. return t
  1126. }
  1127. ;
  1128. var N = t(0);
  1129. function T() {
  1130. var e;
  1131. this._entityHandlers = {},
  1132. (e = this).registerEntityHandler(u),
  1133. e.registerEntityHandler(l),
  1134. e.registerEntityHandler(v),
  1135. e.registerEntityHandler(d),
  1136. e.registerEntityHandler(b),
  1137. e.registerEntityHandler(p),
  1138. e.registerEntityHandler(f),
  1139. e.registerEntityHandler(k),
  1140. e.registerEntityHandler(y),
  1141. e.registerEntityHandler(h),
  1142. e.registerEntityHandler(g),
  1143. e.registerEntityHandler(w),
  1144. e.registerEntityHandler(P),
  1145. e.registerEntityHandler(F),
  1146. e.registerEntityHandler(O)
  1147. }
  1148. function S(e) {
  1149. N.debug("unhandled group " + L(e))
  1150. }
  1151. function L(e) {
  1152. return e.code + ":" + e.value
  1153. }
  1154. N.setLevel("error"),
  1155. T.prototype.parse = function(e, a) {
  1156. throw new Error("read() not implemented. Use readSync()")
  1157. }
  1158. ,
  1159. T.prototype.registerEntityHandler = function(e) {
  1160. var a = new e;
  1161. this._entityHandlers[e.ForEntityName] = a
  1162. }
  1163. ,
  1164. T.prototype.parseSync = function(e) {
  1165. return "string" == typeof e ? this._parse(e) : (console.error("Cannot read dxf source of type `" + typeof e),
  1166. null)
  1167. }
  1168. ,
  1169. T.prototype.parseStream = function(e, a) {
  1170. var t = ""
  1171. , r = this;
  1172. e.on("data", function(e) {
  1173. t += e
  1174. }),
  1175. e.on("end", function() {
  1176. try {
  1177. var e = r._parse(t)
  1178. } catch (e) {
  1179. return a(e)
  1180. }
  1181. a(null, e)
  1182. }),
  1183. e.on("error", function(e) {
  1184. a(e)
  1185. })
  1186. }
  1187. ,
  1188. T.prototype._parse = function(e) {
  1189. var a, t, n = {}, c = 0, i = e.split(/\r\n|\r|\n/g);
  1190. if (!(a = new r(i)).hasNext())
  1191. throw Error("Empty file");
  1192. var u = this
  1193. , s = function(e, a) {
  1194. return t.code === e && t.value === a
  1195. }
  1196. , l = function() {
  1197. var e = null
  1198. , r = null
  1199. , n = {};
  1200. for (t = a.next(); ; ) {
  1201. if (s(0, "ENDSEC")) {
  1202. e && (n[e] = r);
  1203. break
  1204. }
  1205. 9 === t.code ? (e && (n[e] = r),
  1206. e = t.value) : 10 === t.code ? r = {
  1207. x: t.value
  1208. } : 20 === t.code ? r.y = t.value : 30 === t.code ? r.z = t.value : r = t.value,
  1209. t = a.next()
  1210. }
  1211. return t = a.next(),
  1212. n
  1213. }
  1214. , v = function() {
  1215. var e, r = {};
  1216. for (t = a.next(); "EOF" !== t.value && !s(0, "ENDSEC"); )
  1217. s(0, "BLOCK") ? (N.debug("block {"),
  1218. e = d(),
  1219. N.debug("}"),
  1220. x(e),
  1221. e.name ? r[e.name] = e : N.error('block with handle "' + e.handle + '" is missing a name.')) : (S(t),
  1222. t = a.next());
  1223. return r
  1224. }
  1225. , d = function() {
  1226. var e = {};
  1227. for (t = a.next(); "EOF" !== t.value; ) {
  1228. switch (t.code) {
  1229. case 1:
  1230. e.xrefPath = t.value,
  1231. t = a.next();
  1232. break;
  1233. case 2:
  1234. e.name = t.value,
  1235. t = a.next();
  1236. break;
  1237. case 3:
  1238. e.name2 = t.value,
  1239. t = a.next();
  1240. break;
  1241. case 5:
  1242. e.handle = t.value,
  1243. t = a.next();
  1244. break;
  1245. case 8:
  1246. e.layer = t.value,
  1247. t = a.next();
  1248. break;
  1249. case 10:
  1250. e.position = y(),
  1251. t = a.next();
  1252. break;
  1253. case 67:
  1254. e.paperSpace = !(!t.value || 1 != t.value),
  1255. t = a.next();
  1256. break;
  1257. case 70:
  1258. 0 != t.value && (e.type = t.value),
  1259. t = a.next();
  1260. break;
  1261. case 100:
  1262. t = a.next();
  1263. break;
  1264. case 330:
  1265. e.ownerHandle = t.value,
  1266. t = a.next();
  1267. break;
  1268. case 0:
  1269. if ("ENDBLK" == t.value)
  1270. break;
  1271. e.entities = k(!0);
  1272. break;
  1273. default:
  1274. S(t),
  1275. t = a.next()
  1276. }
  1277. if (s(0, "ENDBLK")) {
  1278. t = a.next();
  1279. break
  1280. }
  1281. }
  1282. return e
  1283. }
  1284. , b = function() {
  1285. var e = {};
  1286. for (t = a.next(); "EOF" !== t.value && !s(0, "ENDSEC"); ) {
  1287. s(0, "TABLE") ? (t = a.next(),
  1288. f[t.value] ? (N.debug(t.value + " Table {"),
  1289. e[f[t.value].tableName] = p(),
  1290. N.debug("}")) : N.debug("Unhandled Table " + t.value)) : t = a.next()
  1291. }
  1292. return t = a.next(),
  1293. e
  1294. };
  1295. var p = function() {
  1296. var e, r = f[t.value], n = {}, o = 0;
  1297. for (t = a.next(); !s(0, "ENDTAB"); )
  1298. switch (t.code) {
  1299. case 5:
  1300. n.handle = t.value,
  1301. t = a.next();
  1302. break;
  1303. case 330:
  1304. n.ownerHandle = t.value,
  1305. t = a.next();
  1306. break;
  1307. case 100:
  1308. "AcDbSymbolTable" === t.value ? t = a.next() : (S(t),
  1309. t = a.next());
  1310. break;
  1311. case 70:
  1312. o = t.value,
  1313. t = a.next();
  1314. break;
  1315. case 0:
  1316. t.value === r.dxfSymbolName ? n[r.tableRecordsProperty] = r.parseTableRecords() : (S(t),
  1317. t = a.next());
  1318. break;
  1319. default:
  1320. S(t),
  1321. t = a.next()
  1322. }
  1323. var c = n[r.tableRecordsProperty];
  1324. return c && (c.constructor === Array ? e = c.length : "object" == typeof c && (e = Object.keys(c).length),
  1325. o !== e && N.warn("Parsed " + e + " " + r.dxfSymbolName + "'s but expected " + o)),
  1326. t = a.next(),
  1327. n
  1328. }
  1329. , f = {
  1330. VPORT: {
  1331. tableRecordsProperty: "viewPorts",
  1332. tableName: "viewPort",
  1333. dxfSymbolName: "VPORT",
  1334. parseTableRecords: function() {
  1335. var e = []
  1336. , r = {};
  1337. for (N.debug("ViewPort {"),
  1338. t = a.next(); !s(0, "ENDTAB"); )
  1339. switch (t.code) {
  1340. case 2:
  1341. r.name = t.value,
  1342. t = a.next();
  1343. break;
  1344. case 10:
  1345. r.lowerLeftCorner = y(),
  1346. t = a.next();
  1347. break;
  1348. case 11:
  1349. r.upperRightCorner = y(),
  1350. t = a.next();
  1351. break;
  1352. case 12:
  1353. r.center = y(),
  1354. t = a.next();
  1355. break;
  1356. case 13:
  1357. r.snapBasePoint = y(),
  1358. t = a.next();
  1359. break;
  1360. case 14:
  1361. r.snapSpacing = y(),
  1362. t = a.next();
  1363. break;
  1364. case 15:
  1365. r.gridSpacing = y(),
  1366. t = a.next();
  1367. break;
  1368. case 16:
  1369. r.viewDirectionFromTarget = y(),
  1370. t = a.next();
  1371. break;
  1372. case 17:
  1373. r.viewTarget = y(),
  1374. t = a.next();
  1375. break;
  1376. case 42:
  1377. r.lensLength = t.value,
  1378. t = a.next();
  1379. break;
  1380. case 43:
  1381. r.frontClippingPlane = t.value,
  1382. t = a.next();
  1383. break;
  1384. case 44:
  1385. r.backClippingPlane = t.value,
  1386. t = a.next();
  1387. break;
  1388. case 45:
  1389. r.viewHeight = t.value,
  1390. t = a.next();
  1391. break;
  1392. case 50:
  1393. r.snapRotationAngle = t.value,
  1394. t = a.next();
  1395. break;
  1396. case 51:
  1397. r.viewTwistAngle = t.value,
  1398. t = a.next();
  1399. break;
  1400. case 79:
  1401. r.orthographicType = t.value,
  1402. t = a.next();
  1403. break;
  1404. case 110:
  1405. r.ucsOrigin = y(),
  1406. t = a.next();
  1407. break;
  1408. case 111:
  1409. r.ucsXAxis = y(),
  1410. t = a.next();
  1411. break;
  1412. case 112:
  1413. r.ucsYAxis = y(),
  1414. t = a.next();
  1415. break;
  1416. case 110:
  1417. r.ucsOrigin = y(),
  1418. t = a.next();
  1419. break;
  1420. case 281:
  1421. r.renderMode = t.value,
  1422. t = a.next();
  1423. break;
  1424. case 281:
  1425. r.defaultLightingType = t.value,
  1426. t = a.next();
  1427. break;
  1428. case 292:
  1429. r.defaultLightingOn = t.value,
  1430. t = a.next();
  1431. break;
  1432. case 330:
  1433. r.ownerHandle = t.value,
  1434. t = a.next();
  1435. break;
  1436. case 63:
  1437. case 421:
  1438. case 431:
  1439. r.ambientColor = t.value,
  1440. t = a.next();
  1441. break;
  1442. case 0:
  1443. "VPORT" === t.value && (N.debug("}"),
  1444. e.push(r),
  1445. N.debug("ViewPort {"),
  1446. r = {},
  1447. t = a.next());
  1448. break;
  1449. default:
  1450. S(t),
  1451. t = a.next()
  1452. }
  1453. return N.debug("}"),
  1454. e.push(r),
  1455. e
  1456. }
  1457. },
  1458. LTYPE: {
  1459. tableRecordsProperty: "lineTypes",
  1460. tableName: "lineType",
  1461. dxfSymbolName: "LTYPE",
  1462. parseTableRecords: function() {
  1463. var e, r, n = {}, o = {};
  1464. for (N.debug("LType {"),
  1465. t = a.next(); !s(0, "ENDTAB"); )
  1466. switch (t.code) {
  1467. case 2:
  1468. o.name = t.value,
  1469. e = t.value,
  1470. t = a.next();
  1471. break;
  1472. case 3:
  1473. o.description = t.value,
  1474. t = a.next();
  1475. break;
  1476. case 73:
  1477. (r = t.value) > 0 && (o.pattern = []),
  1478. t = a.next();
  1479. break;
  1480. case 40:
  1481. o.patternLength = t.value,
  1482. t = a.next();
  1483. break;
  1484. case 49:
  1485. o.pattern.push(t.value),
  1486. t = a.next();
  1487. break;
  1488. case 0:
  1489. N.debug("}"),
  1490. r > 0 && r !== o.pattern.length && N.warn("lengths do not match on LTYPE pattern"),
  1491. n[e] = o,
  1492. o = {},
  1493. N.debug("LType {"),
  1494. t = a.next();
  1495. break;
  1496. default:
  1497. t = a.next()
  1498. }
  1499. return N.debug("}"),
  1500. n[e] = o,
  1501. n
  1502. }
  1503. },
  1504. LAYER: {
  1505. tableRecordsProperty: "layers",
  1506. tableName: "layer",
  1507. dxfSymbolName: "LAYER",
  1508. parseTableRecords: function() {
  1509. var e, r, n = {}, c = {};
  1510. for (N.debug("Layer {"),
  1511. t = a.next(); !s(0, "ENDTAB"); )
  1512. switch (t.code) {
  1513. case 2:
  1514. c.name = t.value,
  1515. e = t.value,
  1516. t = a.next();
  1517. break;
  1518. case 62:
  1519. c.visible = t.value >= 0,
  1520. c.colorIndex = Math.abs(t.value),
  1521. c.color = (r = c.colorIndex,
  1522. o[r]),
  1523. t = a.next();
  1524. break;
  1525. case 70:
  1526. c.frozen = 0 != (1 & t.value) || 0 != (2 & t.value),
  1527. t = a.next();
  1528. break;
  1529. case 0:
  1530. "LAYER" === t.value && (N.debug("}"),
  1531. n[e] = c,
  1532. N.debug("Layer {"),
  1533. c = {},
  1534. e = void 0,
  1535. t = a.next());
  1536. break;
  1537. default:
  1538. S(t),
  1539. t = a.next()
  1540. }
  1541. return N.debug("}"),
  1542. n[e] = c,
  1543. n
  1544. }
  1545. }
  1546. }
  1547. , k = function(e) {
  1548. var r = []
  1549. , n = e ? "ENDBLK" : "ENDSEC";
  1550. for (e || (t = a.next()); ; )
  1551. if (0 === t.code) {
  1552. if (t.value === n)
  1553. break;
  1554. var o, c = u._entityHandlers[t.value];
  1555. if (null == c) {
  1556. N.warn("Unhandled entity " + t.value),
  1557. t = a.next();
  1558. continue
  1559. }
  1560. N.debug(t.value + " {"),
  1561. o = c.parseEntity(a, t),
  1562. t = a.lastReadGroup,
  1563. N.debug("}"),
  1564. x(o),
  1565. r.push(o)
  1566. } else
  1567. t = a.next();
  1568. return "ENDSEC" == n && (t = a.next()),
  1569. r
  1570. }
  1571. , y = function() {
  1572. var e = {}
  1573. , r = t.code;
  1574. if (e.x = t.value,
  1575. r += 10,
  1576. (t = a.next()).code != r)
  1577. throw new Error("Expected code for point value to be " + r + " but got " + t.code + ".");
  1578. return e.y = t.value,
  1579. r += 10,
  1580. (t = a.next()).code != r ? (a.rewind(),
  1581. e) : (e.z = t.value,
  1582. e)
  1583. }
  1584. , x = function(e) {
  1585. if (!e)
  1586. throw new TypeError("entity cannot be undefined or null");
  1587. e.handle || (e.handle = c++)
  1588. };
  1589. return function() {
  1590. for (t = a.next(); !a.isEOF(); )
  1591. if (0 === t.code && "SECTION" === t.value) {
  1592. if (2 !== (t = a.next()).code) {
  1593. console.error("Unexpected code %s after 0:SECTION", L(t)),
  1594. t = a.next();
  1595. continue
  1596. }
  1597. "HEADER" === t.value ? (N.debug("> HEADER"),
  1598. n.header = l(),
  1599. N.debug("<")) : "BLOCKS" === t.value ? (N.debug("> BLOCKS"),
  1600. n.blocks = v(),
  1601. N.debug("<")) : "ENTITIES" === t.value ? (N.debug("> ENTITIES"),
  1602. n.entities = k(!1),
  1603. N.debug("<")) : "TABLES" === t.value ? (N.debug("> TABLES"),
  1604. n.tables = b(),
  1605. N.debug("<")) : "EOF" === t.value ? N.debug("EOF") : N.warn("Skipping section '%s'", t.value)
  1606. } else
  1607. t = a.next()
  1608. }(),
  1609. n
  1610. }
  1611. ;
  1612. a.default = T
  1613. }
  1614. ]).default
  1615. });