@mlightcad/data-model 1.8.4 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/README.md +41 -20
  2. package/dist/data-model.cjs +7 -7
  3. package/lib/base/AcDbDxfFiler.d.ts +1 -1
  4. package/lib/base/AcDbDxfFiler.d.ts.map +1 -1
  5. package/lib/base/AcDbObject.d.ts +1 -0
  6. package/lib/base/AcDbObject.d.ts.map +1 -1
  7. package/lib/base/AcDbObject.js +6 -0
  8. package/lib/base/AcDbObject.js.map +1 -1
  9. package/lib/converter/AcDbRegenerator.d.ts +1 -1
  10. package/lib/converter/AcDbRegenerator.d.ts.map +1 -1
  11. package/lib/converter/AcDbRegenerator.js.map +1 -1
  12. package/lib/converter/index.d.ts +0 -1
  13. package/lib/converter/index.d.ts.map +1 -1
  14. package/lib/converter/index.js +0 -1
  15. package/lib/converter/index.js.map +1 -1
  16. package/lib/database/AcDbBlockTable.d.ts +1 -1
  17. package/lib/database/AcDbBlockTable.d.ts.map +1 -1
  18. package/lib/database/AcDbBlockTableRecord.d.ts +1 -1
  19. package/lib/database/AcDbBlockTableRecord.d.ts.map +1 -1
  20. package/lib/database/AcDbDatabase.d.ts +2 -2
  21. package/lib/database/AcDbDatabase.d.ts.map +1 -1
  22. package/lib/database/AcDbDatabase.js +7 -2
  23. package/lib/database/AcDbDatabase.js.map +1 -1
  24. package/lib/database/AcDbDatabaseConverter.d.ts +9 -9
  25. package/lib/database/AcDbDatabaseConverter.d.ts.map +1 -1
  26. package/lib/database/AcDbDatabaseConverter.js +14 -2
  27. package/lib/database/AcDbDatabaseConverter.js.map +1 -1
  28. package/lib/database/AcDbDatabaseConverterManager.d.ts +0 -2
  29. package/lib/database/AcDbDatabaseConverterManager.d.ts.map +1 -1
  30. package/lib/database/AcDbDatabaseConverterManager.js +0 -4
  31. package/lib/database/AcDbDatabaseConverterManager.js.map +1 -1
  32. package/lib/database/AcDbDimStyleTableRecord.d.ts +1 -1
  33. package/lib/database/AcDbDimStyleTableRecord.d.ts.map +1 -1
  34. package/lib/database/AcDbDimStyleTableRecord.js +1 -1
  35. package/lib/database/AcDbDimStyleTableRecord.js.map +1 -1
  36. package/lib/database/AcDbLayerTableRecord.d.ts +1 -1
  37. package/lib/database/AcDbLayerTableRecord.d.ts.map +1 -1
  38. package/lib/database/AcDbLinetypeTableRecord.d.ts +1 -1
  39. package/lib/database/AcDbLinetypeTableRecord.d.ts.map +1 -1
  40. package/lib/database/AcDbRegAppTableRecord.d.ts +1 -1
  41. package/lib/database/AcDbRegAppTableRecord.d.ts.map +1 -1
  42. package/lib/database/AcDbSymbolTableRecord.d.ts +1 -1
  43. package/lib/database/AcDbSymbolTableRecord.d.ts.map +1 -1
  44. package/lib/database/AcDbSysVarManager.js +4 -1
  45. package/lib/database/AcDbSysVarManager.js.map +1 -1
  46. package/lib/database/AcDbTextStyleTable.js +1 -1
  47. package/lib/database/AcDbTextStyleTable.js.map +1 -1
  48. package/lib/database/AcDbTextStyleTableRecord.d.ts +1 -1
  49. package/lib/database/AcDbTextStyleTableRecord.d.ts.map +1 -1
  50. package/lib/database/AcDbViewTableRecord.d.ts +1 -1
  51. package/lib/database/AcDbViewTableRecord.d.ts.map +1 -1
  52. package/lib/database/AcDbViewportTableRecord.d.ts +1 -1
  53. package/lib/database/AcDbViewportTableRecord.d.ts.map +1 -1
  54. package/lib/entity/AcDb2dPolyline.d.ts +4 -2
  55. package/lib/entity/AcDb2dPolyline.d.ts.map +1 -1
  56. package/lib/entity/AcDb2dPolyline.js +9 -1
  57. package/lib/entity/AcDb2dPolyline.js.map +1 -1
  58. package/lib/entity/AcDb2dVertex.d.ts +2 -2
  59. package/lib/entity/AcDb2dVertex.d.ts.map +1 -1
  60. package/lib/entity/AcDb2dVertex.js +1 -1
  61. package/lib/entity/AcDb2dVertex.js.map +1 -1
  62. package/lib/entity/AcDb3dPolyline.d.ts +4 -2
  63. package/lib/entity/AcDb3dPolyline.d.ts.map +1 -1
  64. package/lib/entity/AcDb3dPolyline.js +9 -1
  65. package/lib/entity/AcDb3dPolyline.js.map +1 -1
  66. package/lib/entity/AcDb3dVertex.d.ts +2 -2
  67. package/lib/entity/AcDb3dVertex.d.ts.map +1 -1
  68. package/lib/entity/AcDb3dVertex.js +1 -1
  69. package/lib/entity/AcDb3dVertex.js.map +1 -1
  70. package/lib/entity/AcDbArc.d.ts +4 -2
  71. package/lib/entity/AcDbArc.d.ts.map +1 -1
  72. package/lib/entity/AcDbArc.js +10 -2
  73. package/lib/entity/AcDbArc.js.map +1 -1
  74. package/lib/entity/AcDbAttribute.d.ts +1 -1
  75. package/lib/entity/AcDbAttribute.d.ts.map +1 -1
  76. package/lib/entity/AcDbAttributeDefinition.d.ts +1 -1
  77. package/lib/entity/AcDbAttributeDefinition.d.ts.map +1 -1
  78. package/lib/entity/AcDbBlockReference.d.ts +4 -2
  79. package/lib/entity/AcDbBlockReference.d.ts.map +1 -1
  80. package/lib/entity/AcDbBlockReference.js +3 -1
  81. package/lib/entity/AcDbBlockReference.js.map +1 -1
  82. package/lib/entity/AcDbCircle.d.ts +4 -2
  83. package/lib/entity/AcDbCircle.d.ts.map +1 -1
  84. package/lib/entity/AcDbCircle.js +10 -2
  85. package/lib/entity/AcDbCircle.js.map +1 -1
  86. package/lib/entity/AcDbCurve.d.ts +5 -0
  87. package/lib/entity/AcDbCurve.d.ts.map +1 -1
  88. package/lib/entity/AcDbCurve.js.map +1 -1
  89. package/lib/entity/AcDbEllipse.d.ts +4 -2
  90. package/lib/entity/AcDbEllipse.d.ts.map +1 -1
  91. package/lib/entity/AcDbEllipse.js +10 -2
  92. package/lib/entity/AcDbEllipse.js.map +1 -1
  93. package/lib/entity/AcDbEntity.d.ts +2 -2
  94. package/lib/entity/AcDbEntity.d.ts.map +1 -1
  95. package/lib/entity/AcDbEntity.js +1 -1
  96. package/lib/entity/AcDbEntity.js.map +1 -1
  97. package/lib/entity/AcDbFace.d.ts +6 -2
  98. package/lib/entity/AcDbFace.d.ts.map +1 -1
  99. package/lib/entity/AcDbFace.js +22 -1
  100. package/lib/entity/AcDbFace.js.map +1 -1
  101. package/lib/entity/AcDbHatch.d.ts +6 -2
  102. package/lib/entity/AcDbHatch.d.ts.map +1 -1
  103. package/lib/entity/AcDbHatch.js +12 -2
  104. package/lib/entity/AcDbHatch.js.map +1 -1
  105. package/lib/entity/AcDbLeader.d.ts +4 -2
  106. package/lib/entity/AcDbLeader.d.ts.map +1 -1
  107. package/lib/entity/AcDbLeader.js +9 -1
  108. package/lib/entity/AcDbLeader.js.map +1 -1
  109. package/lib/entity/AcDbLine.d.ts +3 -1
  110. package/lib/entity/AcDbLine.d.ts.map +1 -1
  111. package/lib/entity/AcDbLine.js +8 -0
  112. package/lib/entity/AcDbLine.js.map +1 -1
  113. package/lib/entity/AcDbMLeader.d.ts +2 -2
  114. package/lib/entity/AcDbMLeader.d.ts.map +1 -1
  115. package/lib/entity/AcDbMLeader.js +4 -2
  116. package/lib/entity/AcDbMLeader.js.map +1 -1
  117. package/lib/entity/AcDbMLine.d.ts +2 -2
  118. package/lib/entity/AcDbMLine.d.ts.map +1 -1
  119. package/lib/entity/AcDbMLine.js +2 -2
  120. package/lib/entity/AcDbMLine.js.map +1 -1
  121. package/lib/entity/AcDbMText.d.ts +2 -2
  122. package/lib/entity/AcDbMText.d.ts.map +1 -1
  123. package/lib/entity/AcDbMText.js +1 -1
  124. package/lib/entity/AcDbMText.js.map +1 -1
  125. package/lib/entity/AcDbOsnapHelpers.d.ts +1 -1
  126. package/lib/entity/AcDbOsnapHelpers.d.ts.map +1 -1
  127. package/lib/entity/AcDbOsnapHelpers.js +1 -1
  128. package/lib/entity/AcDbOsnapHelpers.js.map +1 -1
  129. package/lib/entity/AcDbPoint.d.ts +2 -2
  130. package/lib/entity/AcDbPoint.d.ts.map +1 -1
  131. package/lib/entity/AcDbPoint.js +1 -1
  132. package/lib/entity/AcDbPoint.js.map +1 -1
  133. package/lib/entity/AcDbPolyFaceMesh.d.ts +4 -2
  134. package/lib/entity/AcDbPolyFaceMesh.d.ts.map +1 -1
  135. package/lib/entity/AcDbPolyFaceMesh.js +9 -1
  136. package/lib/entity/AcDbPolyFaceMesh.js.map +1 -1
  137. package/lib/entity/AcDbPolygonMesh.d.ts +4 -2
  138. package/lib/entity/AcDbPolygonMesh.d.ts.map +1 -1
  139. package/lib/entity/AcDbPolygonMesh.js +9 -1
  140. package/lib/entity/AcDbPolygonMesh.js.map +1 -1
  141. package/lib/entity/AcDbPolyline.d.ts +4 -2
  142. package/lib/entity/AcDbPolyline.d.ts.map +1 -1
  143. package/lib/entity/AcDbPolyline.js +9 -1
  144. package/lib/entity/AcDbPolyline.js.map +1 -1
  145. package/lib/entity/AcDbRasterImage.d.ts +3 -2
  146. package/lib/entity/AcDbRasterImage.d.ts.map +1 -1
  147. package/lib/entity/AcDbRasterImage.js +1 -1
  148. package/lib/entity/AcDbRasterImage.js.map +1 -1
  149. package/lib/entity/AcDbRay.d.ts +4 -2
  150. package/lib/entity/AcDbRay.d.ts.map +1 -1
  151. package/lib/entity/AcDbRay.js +9 -1
  152. package/lib/entity/AcDbRay.js.map +1 -1
  153. package/lib/entity/AcDbShape.d.ts +2 -2
  154. package/lib/entity/AcDbShape.d.ts.map +1 -1
  155. package/lib/entity/AcDbShape.js +1 -1
  156. package/lib/entity/AcDbShape.js.map +1 -1
  157. package/lib/entity/AcDbSpline.d.ts +4 -2
  158. package/lib/entity/AcDbSpline.d.ts.map +1 -1
  159. package/lib/entity/AcDbSpline.js +9 -1
  160. package/lib/entity/AcDbSpline.js.map +1 -1
  161. package/lib/entity/AcDbTable.d.ts +1 -1
  162. package/lib/entity/AcDbTable.d.ts.map +1 -1
  163. package/lib/entity/AcDbText.d.ts +2 -2
  164. package/lib/entity/AcDbText.d.ts.map +1 -1
  165. package/lib/entity/AcDbText.js +1 -1
  166. package/lib/entity/AcDbText.js.map +1 -1
  167. package/lib/entity/AcDbTrace.d.ts +4 -2
  168. package/lib/entity/AcDbTrace.d.ts.map +1 -1
  169. package/lib/entity/AcDbTrace.js +9 -0
  170. package/lib/entity/AcDbTrace.js.map +1 -1
  171. package/lib/entity/AcDbViewport.d.ts +1 -1
  172. package/lib/entity/AcDbViewport.d.ts.map +1 -1
  173. package/lib/entity/AcDbWipeout.d.ts +1 -1
  174. package/lib/entity/AcDbWipeout.d.ts.map +1 -1
  175. package/lib/entity/AcDbXline.d.ts +4 -2
  176. package/lib/entity/AcDbXline.d.ts.map +1 -1
  177. package/lib/entity/AcDbXline.js +9 -1
  178. package/lib/entity/AcDbXline.js.map +1 -1
  179. package/lib/index.d.ts +1 -1
  180. package/lib/index.d.ts.map +1 -1
  181. package/lib/index.js +1 -1
  182. package/lib/index.js.map +1 -1
  183. package/lib/misc/AcDbDataGenerator.d.ts +1 -1
  184. package/lib/misc/AcDbDataGenerator.d.ts.map +1 -1
  185. package/lib/misc/AcDbDataGenerator.js +7 -3
  186. package/lib/misc/AcDbDataGenerator.js.map +1 -1
  187. package/lib/misc/AcDbRenderingCache.d.ts +1 -1
  188. package/lib/misc/AcDbRenderingCache.d.ts.map +1 -1
  189. package/lib/misc/AcDbRenderingCache.js +1 -1
  190. package/lib/misc/AcDbRenderingCache.js.map +1 -1
  191. package/lib/object/AcDbMLeaderStyle.js +1 -1
  192. package/lib/object/AcDbMLeaderStyle.js.map +1 -1
  193. package/lib/object/layout/AcDbLayoutManager.d.ts.map +1 -1
  194. package/lib/object/layout/AcDbLayoutManager.js +2 -2
  195. package/lib/object/layout/AcDbLayoutManager.js.map +1 -1
  196. package/package.json +6 -9
  197. package/dist/dxf-parser-worker.js +0 -1794
  198. package/lib/converter/AcDbDxfConverter.d.ts +0 -277
  199. package/lib/converter/AcDbDxfConverter.d.ts.map +0 -1
  200. package/lib/converter/AcDbDxfConverter.js +0 -1076
  201. package/lib/converter/AcDbDxfConverter.js.map +0 -1
  202. package/lib/converter/AcDbDxfParser.d.ts +0 -23
  203. package/lib/converter/AcDbDxfParser.d.ts.map +0 -1
  204. package/lib/converter/AcDbDxfParser.js +0 -85
  205. package/lib/converter/AcDbDxfParser.js.map +0 -1
  206. package/lib/converter/AcDbEntitiyConverter.d.ts +0 -156
  207. package/lib/converter/AcDbEntitiyConverter.d.ts.map +0 -1
  208. package/lib/converter/AcDbEntitiyConverter.js +0 -1426
  209. package/lib/converter/AcDbEntitiyConverter.js.map +0 -1
  210. package/lib/converter/AcDbObjectConverter.d.ts +0 -68
  211. package/lib/converter/AcDbObjectConverter.d.ts.map +0 -1
  212. package/lib/converter/AcDbObjectConverter.js +0 -376
  213. package/lib/converter/AcDbObjectConverter.js.map +0 -1
  214. package/lib/converter/worker/AcDbDxfParserWorker.d.ts +0 -11
  215. package/lib/converter/worker/AcDbDxfParserWorker.d.ts.map +0 -1
  216. package/lib/converter/worker/AcDbDxfParserWorker.js +0 -75
  217. package/lib/converter/worker/AcDbDxfParserWorker.js.map +0 -1
@@ -1,1076 +0,0 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
- return new (P || (P = Promise))(function (resolve, reject) {
19
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
- step((generator = generator.apply(thisArg, _arguments || [])).next());
23
- });
24
- };
25
- var __generator = (this && this.__generator) || function (thisArg, body) {
26
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
27
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
28
- function verb(n) { return function (v) { return step([n, v]); }; }
29
- function step(op) {
30
- if (f) throw new TypeError("Generator is already executing.");
31
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
32
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
33
- if (y = 0, t) op = [op[0] & 2, t.value];
34
- switch (op[0]) {
35
- case 0: case 1: t = op; break;
36
- case 4: _.label++; return { value: op[1], done: false };
37
- case 5: _.label++; y = op[1]; op = [0]; continue;
38
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
39
- default:
40
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
41
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
42
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
43
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
44
- if (t[2]) _.ops.pop();
45
- _.trys.pop(); continue;
46
- }
47
- op = body.call(thisArg, _);
48
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
49
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
50
- }
51
- };
52
- var __read = (this && this.__read) || function (o, n) {
53
- var m = typeof Symbol === "function" && o[Symbol.iterator];
54
- if (!m) return o;
55
- var i = m.call(o), r, ar = [], e;
56
- try {
57
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
58
- }
59
- catch (error) { e = { error: error }; }
60
- finally {
61
- try {
62
- if (r && !r.done && (m = i["return"])) m.call(i);
63
- }
64
- finally { if (e) throw e.error; }
65
- }
66
- return ar;
67
- };
68
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
69
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
70
- if (ar || !(i in from)) {
71
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
72
- ar[i] = from[i];
73
- }
74
- }
75
- return to.concat(ar || Array.prototype.slice.call(from));
76
- };
77
- var __values = (this && this.__values) || function(o) {
78
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
79
- if (m) return m.call(o);
80
- if (o && typeof o.length === "number") return {
81
- next: function () {
82
- if (o && i >= o.length) o = void 0;
83
- return { value: o && o[i++], done: !o };
84
- }
85
- };
86
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
87
- };
88
- import { AcCmColor } from '@mlightcad/common';
89
- import { AcDbBlockTableRecord, AcDbDimStyleTableRecord, AcDbLayerTableRecord, AcDbLinetypeTableRecord, AcDbSystemVariables, AcDbSysVarManager, AcDbTextStyleTableRecord, AcDbViewportTableRecord } from '../database';
90
- import { AcDbDatabaseConverter } from '../database/AcDbDatabaseConverter';
91
- import { ByLayer, DEFAULT_MLEADER_STYLE, DEFAULT_MLINE_STYLE, DEFAULT_TEXT_STYLE, VPORT_FALLBACK_CENTER_2D, VPORT_FALLBACK_LLC, VPORT_FALLBACK_URC, VPORT_FALLBACK_VIEW_DIR, VPORT_FALLBACK_VIEW_TARGET } from '../misc';
92
- import { AcDbBatchProcessing } from './AcDbBatchProcessing';
93
- import { AcDbDxfParser } from './AcDbDxfParser';
94
- import { AcDbEntityConverter } from './AcDbEntitiyConverter';
95
- import { AcDbObjectConverter } from './AcDbObjectConverter';
96
- import { createWorkerApi } from './worker';
97
- /**
98
- * Default database converter for DXF files.
99
- *
100
- * This class extends AcDbDatabaseConverter to provide specialized functionality
101
- * for converting DXF (Drawing Exchange Format) files into AcDbDatabase objects.
102
- * It handles parsing DXF data, processing entities, blocks, tables, and other
103
- * DXF-specific structures.
104
- *
105
- * @example
106
- * ```typescript
107
- * const converter = new AcDbDxfConverter();
108
- * const database = await converter.convert(dxfData);
109
- * ```
110
- */
111
- var AcDbDxfConverter = /** @class */ (function (_super) {
112
- __extends(AcDbDxfConverter, _super);
113
- function AcDbDxfConverter(config) {
114
- if (config === void 0) { config = {}; }
115
- var _this = _super.call(this, config) || this;
116
- if (!config.parserWorkerUrl) {
117
- config.parserWorkerUrl = '/assets/dxf-parser-worker.js';
118
- }
119
- return _this;
120
- }
121
- /**
122
- * Parses DXF data into a ParsedDxf object.
123
- *
124
- * @param data - The DXF data
125
- * @returns Parsed DXF object containing all the parsed data
126
- *
127
- */
128
- AcDbDxfConverter.prototype.parse = function (data, timeout) {
129
- return __awaiter(this, void 0, void 0, function () {
130
- var effectiveConfig, resolvedTimeout, api, result, parser, result;
131
- return __generator(this, function (_a) {
132
- switch (_a.label) {
133
- case 0:
134
- effectiveConfig = this.config;
135
- resolvedTimeout = this.getParserWorkerTimeout(data, timeout);
136
- if (!(effectiveConfig.useWorker && effectiveConfig.parserWorkerUrl)) return [3 /*break*/, 2];
137
- api = createWorkerApi({
138
- workerUrl: effectiveConfig.parserWorkerUrl,
139
- timeout: resolvedTimeout,
140
- // One concurrent worker needed for parser
141
- maxConcurrentWorkers: 1
142
- });
143
- return [4 /*yield*/, api.execute(data)
144
- // Release worker
145
- ];
146
- case 1:
147
- result = _a.sent();
148
- // Release worker
149
- api.destroy();
150
- if (result.success) {
151
- return [2 /*return*/, {
152
- model: result.data,
153
- data: {
154
- unknownEntityCount: 0
155
- }
156
- }];
157
- }
158
- else {
159
- throw new Error("Failed to parse drawing due to error: '".concat(result.error, "'"));
160
- }
161
- return [3 /*break*/, 3];
162
- case 2:
163
- parser = new AcDbDxfParser();
164
- result = parser.parse(data);
165
- return [2 /*return*/, {
166
- model: result,
167
- data: {
168
- unknownEntityCount: 0
169
- }
170
- }];
171
- case 3: return [2 /*return*/];
172
- }
173
- });
174
- });
175
- };
176
- /**
177
- * Gets all fonts used by entities in model space and paper space.
178
- *
179
- * This method analyzes the DXF data to extract all font names used by
180
- * text entities, MText entities, and insert entities throughout the drawing.
181
- *
182
- * @param dxf - Input parsed DXF model
183
- * @returns Array of font names used in the drawing
184
- *
185
- * @example
186
- * ```typescript
187
- * const fonts = converter.getFonts(parsedDxf);
188
- * console.log('Used fonts:', fonts);
189
- * ```
190
- */
191
- AcDbDxfConverter.prototype.getFonts = function (dxf) {
192
- var _a;
193
- // Build text style map. The key is text style name, and the value is font name list.
194
- var styleMap = new Map();
195
- var getFontName = function (fontFileName) {
196
- if (fontFileName) {
197
- var lastDotIndex = fontFileName.lastIndexOf('.');
198
- if (lastDotIndex >= 0) {
199
- return fontFileName.substring(0, lastDotIndex).toLowerCase();
200
- }
201
- else {
202
- return fontFileName.toLowerCase();
203
- }
204
- }
205
- };
206
- (_a = dxf.tables.STYLE) === null || _a === void 0 ? void 0 : _a.entries.forEach(function (style) {
207
- var fontNames = [];
208
- if (style.font) {
209
- var fontName = getFontName(style.font);
210
- if (fontName)
211
- fontNames.push(fontName);
212
- }
213
- if (style.bigFont) {
214
- var fontName = getFontName(style.bigFont);
215
- if (fontName)
216
- fontNames.push(fontName);
217
- }
218
- if (style.extendedFont) {
219
- var fontName = getFontName(style.extendedFont);
220
- if (fontName)
221
- fontNames.push(fontName);
222
- }
223
- styleMap.set(style.name, fontNames);
224
- });
225
- var fonts = new Set();
226
- this.getFontsInBlock(dxf.entities, dxf.blocks, styleMap, fonts);
227
- return Array.from(fonts);
228
- };
229
- /**
230
- * Iterates through entities in a block to get fonts used by text, MText, and insert entities.
231
- *
232
- * This is a helper method that recursively processes entities to extract font information
233
- * from text-based entities and block references.
234
- *
235
- * @param entities - Array of DXF entities to process
236
- * @param blockMap - Map of block definitions
237
- * @param styleMap - Map of text styles to font names
238
- * @param fonts - Set to collect font names
239
- *
240
- * @example
241
- * ```typescript
242
- * const fonts = new Set<string>();
243
- * converter.getFontsInBlock(entities, blocks, styleMap, fonts);
244
- * ```
245
- */
246
- AcDbDxfConverter.prototype.getFontsInBlock = function (entities, blockMap, styleMap, fonts) {
247
- var _this = this;
248
- var regex = /\\f(.*?)\|/g;
249
- entities.forEach(function (entity) {
250
- if (entity.type == 'MTEXT') {
251
- var mtext = entity;
252
- var text = mtext.text;
253
- __spreadArray([], __read(text.matchAll(regex)), false).forEach(function (match) {
254
- fonts.add(match[1].toLowerCase());
255
- });
256
- var fontNames = styleMap.get(mtext.styleName);
257
- fontNames === null || fontNames === void 0 ? void 0 : fontNames.forEach(function (name) { return fonts.add(name); });
258
- }
259
- else if (entity.type == 'TEXT') {
260
- var text = entity;
261
- var fontNames = styleMap.get(text.styleName);
262
- fontNames === null || fontNames === void 0 ? void 0 : fontNames.forEach(function (name) { return fonts.add(name); });
263
- }
264
- else if (entity.type == 'MULTILEADER' || entity.type == 'MLEADER') {
265
- var mleader = entity;
266
- var text = typeof mleader.textContent === 'string' ? mleader.textContent : '';
267
- __spreadArray([], __read(text.matchAll(regex)), false).forEach(function (match) {
268
- fonts.add(match[1].toLowerCase());
269
- });
270
- var styleName = typeof mleader.textStyleName === 'string'
271
- ? mleader.textStyleName
272
- : typeof mleader.styleName === 'string'
273
- ? mleader.styleName
274
- : undefined;
275
- var fontNames = styleName ? styleMap.get(styleName) : undefined;
276
- fontNames === null || fontNames === void 0 ? void 0 : fontNames.forEach(function (name) { return fonts.add(name); });
277
- }
278
- else if (entity.type == 'INSERT') {
279
- var insert = entity;
280
- var block = blockMap[insert.name];
281
- if (block && block.entities)
282
- _this.getFontsInBlock(block.entities, blockMap, styleMap, fonts);
283
- }
284
- });
285
- };
286
- /**
287
- * Processes entities in batches to maintain UI responsiveness.
288
- *
289
- * This method breaks up the entity processing work into smaller chunks that are
290
- * executed asynchronously. This is often referred to as "batch processing" or
291
- * "cooperative multitasking," where the time-consuming task is broken into
292
- * smaller pieces and executed in small intervals to allow the UI to remain responsive.
293
- *
294
- * @param dxf - Parsed DXF data
295
- * @param db - Target database to add entities to
296
- * @param minimumChunkSize - Minimum number of entities to process in each chunk
297
- * @param startPercentage - Object containing the starting percentage for progress tracking
298
- * @param progress - Optional callback for progress updates
299
- *
300
- * @example
301
- * ```typescript
302
- * await converter.processEntities(dxf, database, 100, { value: 0 }, progressCallback);
303
- * ```
304
- */
305
- AcDbDxfConverter.prototype.processEntities = function (dxf, db, minimumChunkSize, startPercentage, progress) {
306
- return __awaiter(this, void 0, void 0, function () {
307
- var converter, entities, entityCount, batchProcessor, attributeMap, i, entity, dbEntity, attributes, modelSpaceBlockTableRecord;
308
- var _this = this;
309
- return __generator(this, function (_a) {
310
- switch (_a.label) {
311
- case 0:
312
- converter = new AcDbEntityConverter();
313
- entities = dxf.entities;
314
- entityCount = entities.length;
315
- batchProcessor = new AcDbBatchProcessing(entityCount, 100 - startPercentage.value, minimumChunkSize);
316
- // Groups entities by their `type` property and flattens the result into a single array.
317
- if (this.config.convertByEntityType) {
318
- entities = this.groupAndFlattenByType(entities);
319
- }
320
- attributeMap = new Map();
321
- for (i = 0; i < entityCount; i++) {
322
- entity = entities[i];
323
- if (entity.type === 'ATTRIB') {
324
- dbEntity = converter.convert(entity);
325
- if (dbEntity && dbEntity.ownerId && dbEntity.ownerId !== '0') {
326
- attributes = attributeMap.get(dbEntity === null || dbEntity === void 0 ? void 0 : dbEntity.ownerId);
327
- if (attributes == null) {
328
- attributes = [];
329
- attributeMap.set(dbEntity.ownerId, attributes);
330
- }
331
- attributes.push(dbEntity);
332
- }
333
- }
334
- }
335
- modelSpaceBlockTableRecord = db.tables.blockTable.modelSpace;
336
- return [4 /*yield*/, batchProcessor.processChunk(function (start, end) { return __awaiter(_this, void 0, void 0, function () {
337
- var dbEntities, entityType, _loop_1, this_1, i, percentage;
338
- return __generator(this, function (_a) {
339
- switch (_a.label) {
340
- case 0:
341
- dbEntities = [];
342
- entityType = start < end ? entities[start].type : '';
343
- _loop_1 = function (i) {
344
- var entity = entities[i];
345
- if (entity.ownerBlockRecordSoftId &&
346
- entity.ownerBlockRecordSoftId !== modelSpaceBlockTableRecord.objectId) {
347
- return "continue";
348
- }
349
- if (entity.type !== 'ATTRIB') {
350
- var dbEntity_1 = converter.convert(entity);
351
- if (dbEntity_1) {
352
- if (this_1.config.convertByEntityType && entity.type !== entityType) {
353
- modelSpaceBlockTableRecord.appendEntity(dbEntities);
354
- dbEntities = [];
355
- entityType = entity.type;
356
- }
357
- if (entity.type === 'INSERT') {
358
- var attributes = attributeMap.get(dbEntity_1.objectId);
359
- if (attributes && attributes.length > 0) {
360
- attributes.forEach(function (attribute) {
361
- ;
362
- dbEntity_1.appendAttributes(attribute);
363
- });
364
- }
365
- }
366
- dbEntities.push(dbEntity_1);
367
- }
368
- }
369
- };
370
- this_1 = this;
371
- for (i = start; i < end; i++) {
372
- _loop_1(i);
373
- }
374
- // Use batch append to improve performance
375
- modelSpaceBlockTableRecord.appendEntity(dbEntities);
376
- percentage = startPercentage.value +
377
- (end / entityCount) * (100 - startPercentage.value);
378
- if (percentage > 100)
379
- percentage = 100;
380
- if (!progress) return [3 /*break*/, 2];
381
- return [4 /*yield*/, progress(percentage, 'ENTITY', 'IN-PROGRESS')];
382
- case 1:
383
- _a.sent();
384
- _a.label = 2;
385
- case 2: return [2 /*return*/];
386
- }
387
- });
388
- }); })];
389
- case 1:
390
- _a.sent();
391
- return [2 /*return*/];
392
- }
393
- });
394
- });
395
- };
396
- /**
397
- * Processes entities within a specific block.
398
- *
399
- * This method handles the conversion and addition of entities to a specific
400
- * block table record.
401
- *
402
- * @param entities - Array of DXF entities to process
403
- * @param blockTableRecord - The block table record to use
404
- * @param checkOwner - The flag whether to check the owner of entity is the passed
405
- * blockTableRecord. If yes, convert it and append it to the block table record.
406
- * Otherwise, ignore the entity.
407
- *
408
- * @example
409
- * ```typescript
410
- * await converter.processEntitiesInBlock(entities, blockRecord);
411
- * ```
412
- */
413
- AcDbDxfConverter.prototype.processEntitiesInBlock = function (entities_1, blockTableRecord_1) {
414
- return __awaiter(this, arguments, void 0, function (entities, blockTableRecord, checkOwner) {
415
- var converter, entityCount, dbEntities, btrId, attributes, i, entity, dbEntity;
416
- if (checkOwner === void 0) { checkOwner = false; }
417
- return __generator(this, function (_a) {
418
- converter = new AcDbEntityConverter();
419
- entityCount = entities.length;
420
- dbEntities = [];
421
- btrId = blockTableRecord.objectId;
422
- attributes = [];
423
- for (i = 0; i < entityCount; i++) {
424
- entity = entities[i];
425
- dbEntity = converter.convert(entity);
426
- if (dbEntity) {
427
- if (entity.type === 'ATTRIB') {
428
- attributes.push(dbEntity);
429
- }
430
- else if (!checkOwner || entity.ownerBlockRecordSoftId === btrId) {
431
- dbEntities.push(dbEntity);
432
- }
433
- }
434
- }
435
- // Use batch append to improve performance
436
- blockTableRecord.appendEntity(dbEntities);
437
- attributes.forEach(function (attribute) {
438
- var owner = blockTableRecord.getIdAt(attribute.ownerId);
439
- if (owner) {
440
- owner.appendAttributes(attribute);
441
- }
442
- });
443
- return [2 /*return*/];
444
- });
445
- });
446
- };
447
- /**
448
- * Processes blocks defined in the DXF file.
449
- *
450
- * This method iterates through all blocks in the DXF data and creates
451
- * corresponding AcDbBlockTableRecord objects in the database.
452
- *
453
- * @param model - Parsed DXF model containing block definitions
454
- * @param db - Target database to add blocks to
455
- *
456
- * @example
457
- * ```typescript
458
- * converter.processBlocks(parsedDxf, database);
459
- * ```
460
- */
461
- AcDbDxfConverter.prototype.processBlocks = function (model, db) {
462
- var e_1, _a;
463
- var blocks = model.blocks;
464
- try {
465
- for (var _b = __values(Object.entries(blocks)), _c = _b.next(); !_c.done; _c = _b.next()) {
466
- var _d = __read(_c.value, 2), name_1 = _d[0], block = _d[1];
467
- var dbBlock = db.tables.blockTable.getAt(block.name);
468
- if (!dbBlock) {
469
- dbBlock = new AcDbBlockTableRecord();
470
- if (block.handle != null) {
471
- dbBlock.objectId = String(block.handle);
472
- }
473
- // dbBlock.ownerId = block.ownerHandle
474
- dbBlock.name = name_1;
475
- dbBlock.origin.copy(block.position);
476
- db.tables.blockTable.add(dbBlock);
477
- }
478
- if (block.entities) {
479
- // Process entities in user-defined blocks
480
- this.processEntitiesInBlock(block.entities, dbBlock);
481
- }
482
- else {
483
- // Process paper space block definiton. Entities in model space are
484
- // handled in method processEntities
485
- if (dbBlock.isPaperSapce) {
486
- this.processEntitiesInBlock(model.entities, dbBlock, true);
487
- }
488
- }
489
- }
490
- }
491
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
492
- finally {
493
- try {
494
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
495
- }
496
- finally { if (e_1) throw e_1.error; }
497
- }
498
- };
499
- /**
500
- * Processes header variables from the DXF file.
501
- *
502
- * This method extracts and sets various header variables such as color settings,
503
- * angle base, angle direction, units, and point display settings.
504
- *
505
- * @param model - Parsed DXF model containing header information
506
- * @param db - Target database to set header variables on
507
- *
508
- * @example
509
- * ```typescript
510
- * converter.processHeader(parsedDxf, database);
511
- * ```
512
- */
513
- AcDbDxfConverter.prototype.processHeader = function (model, db) {
514
- var _a;
515
- var header = model.header;
516
- if (header['$ACADVER']) {
517
- db.version = header['$ACADVER'];
518
- }
519
- // Color index 256 is 'ByLayer'
520
- db.cecolor.colorIndex = header['$CECOLOR'] || 256;
521
- db.angbase = header['$ANGBASE'] || 0;
522
- db.angdir = header['$ANGDIR'] || 0;
523
- if (header['$AUNITS'] != null)
524
- db.aunits = header['$AUNITS'];
525
- if (header['$AUPREC'] != null)
526
- db.auprec = header['$AUPREC'];
527
- if (header['$LUNITS'] != null)
528
- db.lunits = header['$LUNITS'];
529
- if (header['$LUPREC'] != null)
530
- db.luprec = header['$LUPREC'];
531
- if (header['$UNITMODE'] != null)
532
- db.unitmode = header['$UNITMODE'];
533
- if (header['$MEASUREMENT'] != null)
534
- db.measurement = header['$MEASUREMENT'];
535
- db.celtype = header['$CELTYPE'] || ByLayer;
536
- AcDbSysVarManager.instance().setVar(AcDbSystemVariables.CETRANSPARENCY, header['$CETRANSPARENCY'] || 'ByLayer', db);
537
- db.celtscale = header['$CELTSCALE'] || 1;
538
- var cmlStyle = this.normalizeHeaderStringValue(header['$CMLSTYLE']) ||
539
- this.normalizeHeaderStringValue(header['CMLSTYLE']) ||
540
- DEFAULT_MLINE_STYLE;
541
- db.cmlstyle = cmlStyle;
542
- var cmlScale = (_a = header['$CMLSCALE']) !== null && _a !== void 0 ? _a : header['CMLSCALE'];
543
- if (typeof cmlScale === 'number' && Number.isFinite(cmlScale)) {
544
- db.cmlscale = cmlScale;
545
- }
546
- var cmleaderStyle = this.normalizeHeaderStringValue(header['$CMLEADERSTYLE']) ||
547
- this.normalizeHeaderStringValue(header['CMLEADERSTYLE']) ||
548
- DEFAULT_MLEADER_STYLE;
549
- db.cmleaderstyle = cmleaderStyle;
550
- // db.hpcolor = this.parseHpColor(
551
- // this.normalizeHeaderStringValue(header['$HPCOLOR']) ||
552
- // this.normalizeHeaderStringValue(header['HPCOLOR']),
553
- // db.cecolor
554
- // )
555
- // db.hpbackgroundcolor = this.parseHpBackgroundColor(
556
- // this.normalizeHeaderStringValue(header['$HPBACKGROUNDCOLOR']) ||
557
- // this.normalizeHeaderStringValue(header['HPBACKGROUNDCOLOR'])
558
- // )
559
- db.hplayer =
560
- this.normalizeHeaderStringValue(header['$HPLAYER']) ||
561
- this.normalizeHeaderStringValue(header['HPLAYER']) ||
562
- '.';
563
- // db.hptransparency = this.parseHpTransparency(
564
- // this.normalizeHeaderStringValue(header['$HPTRANSPARENCY']) ||
565
- // this.normalizeHeaderStringValue(header['HPTRANSPARENCY'])
566
- // )
567
- db.ltscale = header['$LTSCALE'] || 1;
568
- if (header['$EXTMAX'])
569
- db.extmax = header['$EXTMAX'];
570
- if (header['$EXTMIN'])
571
- db.extmin = header['$EXTMIN'];
572
- if (header['$INSUNITS'] != null)
573
- db.insunits = header['$INSUNITS'];
574
- db.osmode = header['$OSMODE'] || 0;
575
- db.orthomode = header['$ORTHOMODE'] || 0;
576
- db.pdmode = header['$PDMODE'] || 0;
577
- db.pdsize = header['$PDSIZE'] || 0.0;
578
- db.textstyle = header['$TEXTSTYLE'] || DEFAULT_TEXT_STYLE;
579
- };
580
- /**
581
- * Processes block table records from the DXF file.
582
- *
583
- * This method creates AcDbBlockTableRecord objects for each block record
584
- * defined in the DXF tables section.
585
- *
586
- * @param dxf - Parsed DXF data
587
- * @param db - Target database to add block table records to
588
- *
589
- * @example
590
- * ```typescript
591
- * converter.processBlockTables(parsedDxf, database);
592
- * ```
593
- */
594
- AcDbDxfConverter.prototype.processBlockTables = function (dxf, db) {
595
- var _a;
596
- var btrs = (_a = dxf.tables.BLOCK_RECORD) === null || _a === void 0 ? void 0 : _a.entries;
597
- if (btrs && btrs.length > 0) {
598
- db.tables.blockTable.removeAll();
599
- btrs.forEach(function (btr) {
600
- var dbBlock = new AcDbBlockTableRecord();
601
- dbBlock.objectId = btr.handle;
602
- dbBlock.name = btr.name;
603
- dbBlock.layoutId = btr.layoutObjects;
604
- dbBlock.blockInsertUnits = btr.insertionUnits;
605
- dbBlock.explodability = btr.explodability;
606
- dbBlock.blockScaling = btr.scalability;
607
- if (btr.bmpPreview) {
608
- dbBlock.bmpPreview = btr.bmpPreview;
609
- }
610
- db.tables.blockTable.add(dbBlock);
611
- });
612
- }
613
- };
614
- /**
615
- * Processes objects defined in the DXF file.
616
- *
617
- * This method handles the conversion of DXF objects such as layouts and
618
- * image definitions into their corresponding AcDb objects.
619
- *
620
- * @param model - Parsed DXF model containing object definitions
621
- * @param db - Target database to add objects to
622
- *
623
- * @example
624
- * ```typescript
625
- * converter.processObjects(parsedDxf, database);
626
- * ```
627
- */
628
- AcDbDxfConverter.prototype.processObjects = function (model, db) {
629
- var objects = model.objects.byName;
630
- var objectConverter = new AcDbObjectConverter();
631
- if ('LAYOUT' in objects) {
632
- var layoutDict_1 = db.objects.layout;
633
- objects['LAYOUT'].forEach(function (layout) {
634
- var dbLayout = objectConverter.convertLayout(layout, model);
635
- layoutDict_1.setAt(dbLayout.layoutName, dbLayout);
636
- });
637
- }
638
- if ('IMAGEDEF' in objects) {
639
- var imageDefDict_1 = db.objects.imageDefinition;
640
- objects['IMAGEDEF'].forEach(function (imageDef) {
641
- var dbImageDef = objectConverter.convertImageDef(imageDef);
642
- imageDefDict_1.setAt(dbImageDef.objectId, dbImageDef);
643
- });
644
- }
645
- if ('MLEADERSTYLE' in objects) {
646
- var mleaderStyleDict_1 = db.objects.mleaderStyle;
647
- objects['MLEADERSTYLE'].forEach(function (style) {
648
- var dbStyle = objectConverter.convertMLeaderStyle(style);
649
- mleaderStyleDict_1.setAt(dbStyle.objectId, dbStyle);
650
- });
651
- }
652
- if ('MLINESTYLE' in objects) {
653
- var mlineStyleDict_1 = db.objects.mlineStyle;
654
- objects['MLINESTYLE'].forEach(function (style) {
655
- var dbStyle = objectConverter.convertMLineStyle(style);
656
- mlineStyleDict_1.setAt(dbStyle.styleName || dbStyle.objectId, dbStyle);
657
- });
658
- }
659
- };
660
- /**
661
- * Processes viewport table records from the DXF file.
662
- *
663
- * This method creates AcDbViewportTableRecord objects for each viewport
664
- * defined in the DXF tables section, including their properties like
665
- * center, corners, snap settings, and grid settings.
666
- *
667
- * @param model - Parsed DXF model containing viewport definitions
668
- * @param db - Target database to add viewport table records to
669
- *
670
- * @example
671
- * ```typescript
672
- * converter.processViewports(parsedDxf, database);
673
- * ```
674
- */
675
- AcDbDxfConverter.prototype.processViewports = function (model, db) {
676
- var _this = this;
677
- var _a;
678
- var viewportTable = (_a = model.tables) === null || _a === void 0 ? void 0 : _a.VPORT;
679
- if (viewportTable) {
680
- this.processCommonTableAttrs(viewportTable, db.tables.viewportTable);
681
- var viewports = viewportTable.entries;
682
- if (viewports && viewports.length > 0) {
683
- viewports.forEach(function (item) {
684
- var _a, _b, _c, _d, _e, _f;
685
- var record = new AcDbViewportTableRecord();
686
- _this.processCommonTableEntryAttrs(item, record);
687
- if (item.circleSides) {
688
- record.circleSides = item.circleSides;
689
- }
690
- record.standardFlag = item.standardFlag;
691
- record.center.copy((_a = item.center) !== null && _a !== void 0 ? _a : VPORT_FALLBACK_CENTER_2D);
692
- record.lowerLeftCorner.copy((_b = item.lowerLeftCorner) !== null && _b !== void 0 ? _b : VPORT_FALLBACK_LLC);
693
- record.upperRightCorner.copy((_c = item.upperRightCorner) !== null && _c !== void 0 ? _c : VPORT_FALLBACK_URC);
694
- if (item.snapBasePoint) {
695
- record.snapBase.copy(item.snapBasePoint);
696
- }
697
- if (item.snapRotationAngle) {
698
- record.snapAngle = item.snapRotationAngle;
699
- }
700
- if (item.snapSpacing) {
701
- record.snapIncrements.copy(item.snapSpacing);
702
- }
703
- if (item.majorGridLines) {
704
- record.gridMajor = item.majorGridLines;
705
- }
706
- if (item.gridSpacing) {
707
- record.gridIncrements.copy(item.gridSpacing);
708
- }
709
- if (item.backgroundObjectId) {
710
- record.backgroundObjectId = item.backgroundObjectId;
711
- }
712
- record.gsView.center.copy((_d = item.center) !== null && _d !== void 0 ? _d : VPORT_FALLBACK_CENTER_2D);
713
- record.gsView.viewDirectionFromTarget.copy((_e = item.viewDirectionFromTarget) !== null && _e !== void 0 ? _e : VPORT_FALLBACK_VIEW_DIR);
714
- record.gsView.viewTarget.copy((_f = item.viewTarget) !== null && _f !== void 0 ? _f : VPORT_FALLBACK_VIEW_TARGET);
715
- if (item.lensLength) {
716
- record.gsView.lensLength = item.lensLength;
717
- }
718
- if (item.frontClippingPlane) {
719
- record.gsView.frontClippingPlane = item.frontClippingPlane;
720
- }
721
- if (item.backClippingPlane) {
722
- record.gsView.backClippingPlane = item.backClippingPlane;
723
- }
724
- if (item.viewHeight) {
725
- record.gsView.viewHeight = item.viewHeight;
726
- }
727
- if (item.aspectRatio != null &&
728
- Number.isFinite(item.aspectRatio) &&
729
- item.aspectRatio > 0) {
730
- record.gsView.aspectRatio = item.aspectRatio;
731
- }
732
- if (item.viewTwistAngle) {
733
- record.gsView.viewTwistAngle = item.viewTwistAngle;
734
- }
735
- if (item.frozenLayers) {
736
- record.gsView.frozenLayers = item.frozenLayers;
737
- }
738
- if (item.styleSheet) {
739
- record.gsView.styleSheet = item.styleSheet;
740
- }
741
- if (item.renderMode) {
742
- record.gsView.renderMode =
743
- item.renderMode;
744
- }
745
- if (item.viewMode) {
746
- record.gsView.viewMode = item.viewMode;
747
- }
748
- if (item.ucsIconSetting) {
749
- record.gsView.ucsIconSetting = item.ucsIconSetting;
750
- }
751
- if (item.ucsOrigin) {
752
- record.gsView.ucsOrigin.copy(item.ucsOrigin);
753
- }
754
- if (item.ucsXAxis) {
755
- record.gsView.ucsXAxis.copy(item.ucsXAxis);
756
- }
757
- if (item.ucsYAxis) {
758
- record.gsView.ucsYAxis.copy(item.ucsYAxis);
759
- }
760
- if (item.orthographicType) {
761
- record.gsView.orthographicType =
762
- item.orthographicType;
763
- }
764
- if (item.shadePlotSetting) {
765
- record.gsView.shadePlotSetting = item.shadePlotSetting;
766
- }
767
- if (item.shadePlotObjectId) {
768
- record.gsView.shadePlotObjectId = item.shadePlotObjectId;
769
- }
770
- if (item.visualStyleObjectId) {
771
- record.gsView.visualStyleObjectId = item.visualStyleObjectId;
772
- }
773
- if (item.isDefaultLightingOn) {
774
- record.gsView.isDefaultLightingOn = item.isDefaultLightingOn;
775
- }
776
- if (item.defaultLightingType) {
777
- record.gsView.defaultLightingType =
778
- item.defaultLightingType;
779
- }
780
- if (item.brightness) {
781
- record.gsView.brightness = item.brightness;
782
- }
783
- if (item.contrast) {
784
- record.gsView.contrast = item.contrast;
785
- }
786
- if (item.ambientColor) {
787
- record.gsView.ambientColor = item.ambientColor;
788
- }
789
- db.tables.viewportTable.add(record);
790
- });
791
- }
792
- }
793
- };
794
- /**
795
- * Processes layer table records from the DXF file.
796
- *
797
- * This method creates AcDbLayerTableRecord objects for each layer
798
- * defined in the DXF tables section, including their properties like
799
- * color, linetype, lineweight, and visibility settings.
800
- *
801
- * @param model - Parsed DXF model containing layer definitions
802
- * @param db - Target database to add layer table records to
803
- *
804
- * @example
805
- * ```typescript
806
- * converter.processLayers(parsedDxf, database);
807
- * ```
808
- */
809
- AcDbDxfConverter.prototype.processLayers = function (model, db) {
810
- var _this = this;
811
- var _a;
812
- var layerTable = (_a = model.tables) === null || _a === void 0 ? void 0 : _a.LAYER;
813
- if (layerTable) {
814
- this.processCommonTableAttrs(layerTable, db.tables.layerTable);
815
- var layers = layerTable.entries;
816
- if (layers && layers.length > 0) {
817
- layers.forEach(function (item) {
818
- var color = new AcCmColor();
819
- color.colorIndex = item.colorIndex;
820
- var record = new AcDbLayerTableRecord({
821
- name: item.name,
822
- standardFlags: item.standardFlag,
823
- linetype: item.lineType,
824
- lineWeight: item.lineweight,
825
- isOff: item.colorIndex < 0,
826
- color: color,
827
- isPlottable: item.isPlotting
828
- });
829
- _this.processCommonTableEntryAttrs(item, record);
830
- db.tables.layerTable.add(record);
831
- });
832
- }
833
- }
834
- };
835
- /**
836
- * Processes linetype table records from the DXF file.
837
- *
838
- * This method creates AcDbLinetypeTableRecord objects for each linetype
839
- * defined in the DXF tables section.
840
- *
841
- * @param model - Parsed DXF model containing linetype definitions
842
- * @param db - Target database to add linetype table records to
843
- *
844
- * @example
845
- * ```typescript
846
- * converter.processLineTypes(parsedDxf, database);
847
- * ```
848
- */
849
- AcDbDxfConverter.prototype.processLineTypes = function (model, db) {
850
- var _this = this;
851
- var _a;
852
- var lineTypeTable = (_a = model.tables) === null || _a === void 0 ? void 0 : _a.LTYPE;
853
- if (lineTypeTable) {
854
- this.processCommonTableAttrs(lineTypeTable, db.tables.linetypeTable);
855
- var lineTypes = lineTypeTable.entries;
856
- if (lineTypes && lineTypes.length > 0) {
857
- lineTypes.forEach(function (item) {
858
- var record = new AcDbLinetypeTableRecord(item);
859
- _this.processCommonTableEntryAttrs(item, record);
860
- record.name = item.name;
861
- db.tables.linetypeTable.add(record);
862
- });
863
- }
864
- }
865
- };
866
- /**
867
- * Processes text style table records from the DXF file.
868
- *
869
- * This method creates AcDbTextStyleTableRecord objects for each text style
870
- * defined in the DXF tables section.
871
- *
872
- * @param model - Parsed DXF model containing text style definitions
873
- * @param db - Target database to add text style table records to
874
- *
875
- * @example
876
- * ```typescript
877
- * converter.processTextStyles(parsedDxf, database);
878
- * ```
879
- */
880
- AcDbDxfConverter.prototype.processTextStyles = function (model, db) {
881
- var _this = this;
882
- var _a;
883
- var textStyleTable = (_a = model.tables) === null || _a === void 0 ? void 0 : _a.STYLE;
884
- if (textStyleTable) {
885
- this.processCommonTableAttrs(textStyleTable, db.tables.textStyleTable);
886
- var textStyles = textStyleTable.entries;
887
- if (textStyles && textStyles.length > 0) {
888
- textStyles.forEach(function (item) {
889
- var record = new AcDbTextStyleTableRecord(item);
890
- _this.processCommonTableEntryAttrs(item, record);
891
- db.tables.textStyleTable.add(record);
892
- });
893
- }
894
- }
895
- db.ensureTextStyleDefaults();
896
- };
897
- /**
898
- * Processes dimension style table records from the DXF file.
899
- *
900
- * This method creates AcDbDimStyleTableRecord objects for each dimension style
901
- * defined in the DXF tables section, including all dimension-related properties
902
- * like text positioning, arrow settings, and tolerance settings.
903
- *
904
- * @param model - Parsed DXF model containing dimension style definitions
905
- * @param db - Target database to add dimension style table records to
906
- *
907
- * @example
908
- * ```typescript
909
- * converter.processDimStyles(parsedDxf, database);
910
- * ```
911
- */
912
- AcDbDxfConverter.prototype.processDimStyles = function (model, db) {
913
- var _this = this;
914
- var _a;
915
- var dimStyleTable = (_a = model.tables) === null || _a === void 0 ? void 0 : _a.DIMSTYLE;
916
- if (dimStyleTable) {
917
- this.processCommonTableAttrs(dimStyleTable, db.tables.dimStyleTable);
918
- var dimStyles = dimStyleTable.entries;
919
- if (dimStyles && dimStyles.length > 0) {
920
- dimStyles.forEach(function (item) {
921
- var attrs = {
922
- name: item.name,
923
- ownerId: item.ownerObjectId,
924
- dimpost: item.DIMPOST || '',
925
- dimapost: item.DIMAPOST || '',
926
- dimscale: item.DIMSCALE,
927
- dimasz: item.DIMASZ,
928
- dimexo: item.DIMEXO,
929
- dimdli: item.DIMDLI,
930
- dimexe: item.DIMEXE,
931
- dimrnd: item.DIMRND,
932
- dimdle: item.DIMDLE,
933
- dimtp: item.DIMTP,
934
- dimtm: item.DIMTM,
935
- dimtxt: item.DIMTXT,
936
- dimcen: item.DIMCEN,
937
- dimtsz: item.DIMTSZ,
938
- dimaltf: item.DIMALTF,
939
- dimlfac: item.DIMLFAC,
940
- dimtvp: item.DIMTVP,
941
- dimtfac: item.DIMTFAC,
942
- dimgap: item.DIMGAP,
943
- dimaltrnd: item.DIMALTRND,
944
- dimtol: item.DIMTOL == null || item.DIMTOL == 0 ? 0 : 1,
945
- dimlim: item.DIMLIM == null || item.DIMLIM == 0 ? 0 : 1,
946
- dimtih: item.DIMTIH == null || item.DIMTIH == 0 ? 0 : 1,
947
- dimtoh: item.DIMTOH == null || item.DIMTOH == 0 ? 0 : 1,
948
- dimse1: item.DIMSE1 == null || item.DIMSE1 == 0 ? 0 : 1,
949
- dimse2: item.DIMSE2 == null || item.DIMSE2 == 0 ? 0 : 1,
950
- dimtad: item.DIMTAD,
951
- dimzin: item.DIMZIN,
952
- dimazin: item.DIMAZIN,
953
- dimalt: item.DIMALT,
954
- dimaltd: item.DIMALTD,
955
- dimtofl: item.DIMTOFL,
956
- dimsah: item.DIMSAH,
957
- dimtix: item.DIMTIX,
958
- dimsoxd: item.DIMSOXD,
959
- dimclrd: item.DIMCLRD,
960
- dimclre: item.DIMCLRE,
961
- dimclrt: item.DIMCLRT,
962
- dimadec: item.DIMADEC || 0,
963
- dimunit: item.DIMUNIT || 2,
964
- dimdec: item.DIMDEC,
965
- dimtdec: item.DIMTDEC,
966
- dimaltu: item.DIMALTU,
967
- dimalttd: item.DIMALTTD,
968
- dimaunit: item.DIMAUNIT,
969
- dimfrac: item.DIMFRAC,
970
- dimlunit: item.DIMLUNIT,
971
- dimdsep: item.DIMDSEP ? item.DIMDSEP.toString() : '.',
972
- dimtmove: item.DIMTMOVE || 0,
973
- dimjust: item.DIMJUST,
974
- dimsd1: item.DIMSD1,
975
- dimsd2: item.DIMSD2,
976
- dimtolj: item.DIMTOLJ,
977
- dimtzin: item.DIMTZIN,
978
- dimaltz: item.DIMALTZ,
979
- dimalttz: item.DIMALTTZ,
980
- dimfit: item.DIMFIT || 0,
981
- dimupt: item.DIMUPT,
982
- dimatfit: item.DIMATFIT,
983
- dimtxsty: item.DIMTXSTY || DEFAULT_TEXT_STYLE,
984
- dimldrblk: item.DIMLDRBLK || '',
985
- dimblk: item.DIMBLK || '',
986
- dimblk1: item.DIMBLK1 || '',
987
- dimblk2: item.DIMBLK2 || '',
988
- dimlwd: item.DIMLWD,
989
- dimlwe: item.DIMLWE
990
- };
991
- var record = new AcDbDimStyleTableRecord(attrs);
992
- _this.processCommonTableEntryAttrs(item, record);
993
- db.tables.dimStyleTable.add(record);
994
- });
995
- }
996
- }
997
- };
998
- AcDbDxfConverter.prototype.processCommonTableAttrs = function (table, dbTable) {
999
- if (table.handle != null) {
1000
- dbTable.objectId = table.handle;
1001
- }
1002
- if (table.ownerObjectId != null) {
1003
- dbTable.ownerId = table.ownerObjectId;
1004
- }
1005
- };
1006
- /**
1007
- * Processes common table entry attributes from DXF data.
1008
- *
1009
- * This helper method sets the common attributes (name, objectId, ownerId)
1010
- * that are shared across all table entries.
1011
- *
1012
- * @param entry - DXF table entry containing the source data
1013
- * @param dbEntry - AcDbSymbolTableRecord to populate with the data
1014
- *
1015
- * @example
1016
- * ```typescript
1017
- * converter.processCommonTableEntryAttrs(dxfEntry, dbRecord);
1018
- * ```
1019
- */
1020
- AcDbDxfConverter.prototype.processCommonTableEntryAttrs = function (entry, dbEntry) {
1021
- dbEntry.name = 'name' in entry ? entry.name : '';
1022
- // All of objects in drawing database should have handle. However, some VPORT objects in DXF file
1023
- // don't have handle. In this time, just use objectId created in constructor of AcDbObject.
1024
- // https://github.com/mlightcad/cad-viewer/issues/101
1025
- if (entry.handle != null)
1026
- dbEntry.objectId = entry.handle;
1027
- if (entry.ownerObjectId != null) {
1028
- dbEntry.ownerId = entry.ownerObjectId;
1029
- }
1030
- };
1031
- /**
1032
- * Groups entities by their `type` property and flattens the result into a single array.
1033
- *
1034
- * The order of `type` groups follows the order in which they first appear in the input array.
1035
- * Items within each group preserve their original order.
1036
- *
1037
- * This runs in O(n) time, which is generally faster than sorting when you
1038
- * don't care about alphabetical order of types.
1039
- *
1040
- * @param entities - The array of entities to group and flatten.
1041
- *
1042
- * @returns A new array of entities grouped by their `type` property.
1043
- */
1044
- AcDbDxfConverter.prototype.groupAndFlattenByType = function (entities) {
1045
- var e_2, _a;
1046
- var groups = {};
1047
- var order = [];
1048
- try {
1049
- for (var entities_1 = __values(entities), entities_1_1 = entities_1.next(); !entities_1_1.done; entities_1_1 = entities_1.next()) {
1050
- var entity = entities_1_1.value;
1051
- if (!groups[entity.type]) {
1052
- groups[entity.type] = [];
1053
- order.push(entity.type);
1054
- }
1055
- groups[entity.type].push(entity);
1056
- }
1057
- }
1058
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1059
- finally {
1060
- try {
1061
- if (entities_1_1 && !entities_1_1.done && (_a = entities_1.return)) _a.call(entities_1);
1062
- }
1063
- finally { if (e_2) throw e_2.error; }
1064
- }
1065
- return order.flatMap(function (type) { return groups[type]; });
1066
- };
1067
- AcDbDxfConverter.prototype.normalizeHeaderStringValue = function (value) {
1068
- if (typeof value !== 'string')
1069
- return undefined;
1070
- var trimmed = value.trim();
1071
- return trimmed.length > 0 ? trimmed : undefined;
1072
- };
1073
- return AcDbDxfConverter;
1074
- }(AcDbDatabaseConverter));
1075
- export { AcDbDxfConverter };
1076
- //# sourceMappingURL=AcDbDxfConverter.js.map