@mlightcad/libredwg-converter 3.5.12 → 3.5.14
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.
- package/dist/libredwg-converter.js +304 -283
- package/dist/libredwg-converter.umd.cjs +1 -1
- package/dist/libredwg-parser-worker.js +1 -1
- package/lib/AcDbEntitiyConverter.d.ts.map +1 -1
- package/lib/AcDbEntitiyConverter.js +74 -22
- package/lib/AcDbEntitiyConverter.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AcDbFace as
|
|
1
|
+
import { AcDbFace as v, AcDbArc as O, AcGeVector3d as D, AcDbCircle as m, AcDbEllipse as k, AcDbLine as F, AcGePoint3d as w, AcDbSpline as T, AcDbPoint as R, AcDbTrace as V, AcDbPolyline as N, AcGePoint2d as b, AcDbPolygonMesh as B, AcDbPolyFaceMesh as z, AcDbPoly2dType as A, AcDb2dPolyline as j, AcDbPoly3dType as y, AcDb3dPolyline as W, AcDbHatch as H, AcGePolyline2d as X, AcGeLine2d as U, AcGeCircArc2d as G, AcGeVector2d as Y, AcGeEllipseArc2d as _, AcGeSpline3d as P, AcGeLoop2d as E, AcDbTable as Z, AcDbText as K, AcDbMText as q, AcDbLeader as J, AcDbAlignedDimension as Q, AcDb3PointAngularDimension as $, AcDbOrdinateDimension as ee, AcDbRadialDimension as ne, AcDbDiametricDimension as oe, AcDbRasterImage as te, AcDbWipeout as se, AcDbViewport as re, AcDbRay as ie, AcDbXline as ce, AcDbAttributeFlags as I, AcDbAttributeMTextFlag as M, AcDbAttribute as le, AcDbAttributeDefinition as ae, AcDbBlockReference as de, AcCmTransparency as pe, AcDbDatabaseConverter as ue, createWorkerApi as fe, AcDbLinetypeTableRecord as he, AcDbTextStyleTableRecord as ge, DEFAULT_TEXT_STYLE as L, AcDbDimStyleTableRecord as De, AcCmColor as Ae, AcDbLayerTableRecord as Ie, AcDbViewportTableRecord as ye, AcDbBlockTableRecord as we, AcDbBatchProcessing as Te, AcDbLayout as be, AcDbRasterImageDef as Pe } from "@mlightcad/data-model";
|
|
2
2
|
class S {
|
|
3
3
|
convert(e) {
|
|
4
4
|
const n = this.createEntity(e);
|
|
@@ -13,7 +13,7 @@ class S {
|
|
|
13
13
|
return e.type == "3DFACE" ? this.convertFace(e) : e.type == "ARC" ? this.convertArc(e) : e.type == "ATTDEF" ? this.convertAttributeDefinition(e) : e.type == "CIRCLE" ? this.convertCirle(e) : e.type == "DIMENSION" ? this.convertDimension(e) : e.type == "ELLIPSE" ? this.convertEllipse(e) : e.type == "HATCH" ? this.convertHatch(e) : e.type == "IMAGE" ? this.convertImage(e) : e.type == "LEADER" ? this.convertLeader(e) : e.type == "LINE" ? this.convertLine(e) : e.type == "LWPOLYLINE" ? this.convertLWPolyline(e) : e.type == "MTEXT" ? this.convertMText(e) : e.type == "POINT" ? this.convertPoint(e) : e.type == "POLYLINE2D" ? this.convertPolyline2d(e) : e.type == "POLYLINE3D" ? this.convertPolyline3d(e) : e.type == "RAY" ? this.convertRay(e) : e.type == "SPLINE" ? this.convertSpline(e) : e.type == "ACAD_TABLE" ? this.convertTable(e) : e.type == "TEXT" ? this.convertText(e) : e.type == "SOLID" ? this.convertSolid(e) : e.type == "VIEWPORT" ? this.convertViewport(e) : e.type == "WIPEOUT" ? this.convertWipeout(e) : e.type == "XLINE" ? this.convertXline(e) : e.type == "INSERT" ? this.convertBlockReference(e) : null;
|
|
14
14
|
}
|
|
15
15
|
convertFace(e) {
|
|
16
|
-
const n = new
|
|
16
|
+
const n = new v();
|
|
17
17
|
return e.corner1 && n.setVertexAt(0, e.corner1), e.corner2 && n.setVertexAt(1, e.corner2), e.corner3 && n.setVertexAt(2, e.corner3), e.corner4 && n.setVertexAt(3, e.corner4), n.setEdgeInvisibilities(e.flag), n;
|
|
18
18
|
}
|
|
19
19
|
convertArc(e) {
|
|
@@ -33,22 +33,22 @@ class S {
|
|
|
33
33
|
);
|
|
34
34
|
}
|
|
35
35
|
convertEllipse(e) {
|
|
36
|
-
const n = new D(e.majorAxisEndPoint),
|
|
36
|
+
const n = new D(e.majorAxisEndPoint), t = n.length();
|
|
37
37
|
return new k(
|
|
38
38
|
e.center,
|
|
39
39
|
e.extrusionDirection ?? D.Z_AXIS,
|
|
40
40
|
n,
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
t,
|
|
42
|
+
t * e.axisRatio,
|
|
43
43
|
e.startAngle,
|
|
44
44
|
e.endAngle
|
|
45
45
|
);
|
|
46
46
|
}
|
|
47
47
|
convertLine(e) {
|
|
48
|
-
const n = e.startPoint,
|
|
48
|
+
const n = e.startPoint, t = e.endPoint;
|
|
49
49
|
return new F(
|
|
50
|
-
new
|
|
51
|
-
new
|
|
50
|
+
new w(n.x, n.y, n.z),
|
|
51
|
+
new w(t.x, t.y, t.z)
|
|
52
52
|
);
|
|
53
53
|
}
|
|
54
54
|
convertSpline(e) {
|
|
@@ -86,52 +86,73 @@ class S {
|
|
|
86
86
|
}
|
|
87
87
|
convertLWPolyline(e) {
|
|
88
88
|
const n = new N();
|
|
89
|
-
return n.closed = !!(e.flag & 512), e.vertices.forEach((
|
|
89
|
+
return n.closed = !!(e.flag & 512), e.vertices.forEach((t, o) => {
|
|
90
90
|
n.addVertexAt(
|
|
91
|
-
|
|
92
|
-
new b(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
o,
|
|
92
|
+
new b(t.x, t.y),
|
|
93
|
+
t.bulge,
|
|
94
|
+
t.startWidth,
|
|
95
|
+
t.endWidth
|
|
96
96
|
);
|
|
97
97
|
}), n;
|
|
98
98
|
}
|
|
99
99
|
convertPolyline2d(e) {
|
|
100
|
-
const n = !!(e.flag & 1), o = [],
|
|
101
|
-
e.vertices.map((
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
100
|
+
const n = !!(e.flag & 1), t = !!(e.flag & 16), o = !!(e.flag & 64), s = !!(e.flag & 32), r = [], a = [], c = [];
|
|
101
|
+
if (e.vertices.map((i) => {
|
|
102
|
+
if (!(i.flag & 16))
|
|
103
|
+
if (o && i.flag & 128)
|
|
104
|
+
if (i.flag & 64)
|
|
105
|
+
r.push({
|
|
106
|
+
x: i.x,
|
|
107
|
+
y: i.y,
|
|
108
|
+
z: i.z
|
|
109
|
+
}), a.push(i.bulge ?? 0);
|
|
110
|
+
else {
|
|
111
|
+
const d = [];
|
|
112
|
+
i.polyfaceIndex0 != null && i.polyfaceIndex0 != 0 && d.push(Math.abs(i.polyfaceIndex0) - 1), i.polyfaceIndex1 != null && i.polyfaceIndex1 != 0 && d.push(Math.abs(i.polyfaceIndex1) - 1), i.polyfaceIndex2 != null && i.polyfaceIndex2 != 0 && d.push(Math.abs(i.polyfaceIndex2) - 1), i.polyfaceIndex3 != null && i.polyfaceIndex3 != 0 && d.push(Math.abs(i.polyfaceIndex3) - 1), d.length >= 3 && c.push(d);
|
|
113
|
+
}
|
|
114
|
+
else
|
|
115
|
+
r.push({
|
|
116
|
+
x: i.x,
|
|
117
|
+
y: i.y,
|
|
118
|
+
z: i.z
|
|
119
|
+
}), a.push(i.bulge ?? 0);
|
|
120
|
+
}), t) {
|
|
121
|
+
const i = e.meshMVertexCount ?? 2, d = e.meshNVertexCount ?? 2;
|
|
122
|
+
return new B(i, d, r, n, s);
|
|
123
|
+
} else {
|
|
124
|
+
if (o)
|
|
125
|
+
return new z(r, c);
|
|
126
|
+
{
|
|
127
|
+
let i = A.SimplePoly;
|
|
128
|
+
return e.flag & 2 ? i = A.FitCurvePoly : e.flag & 4 && (e.smoothType == 6 ? i = A.CubicSplinePoly : e.smoothType == 5 && (i = A.QuadSplinePoly)), new j(
|
|
129
|
+
i,
|
|
130
|
+
r,
|
|
131
|
+
0,
|
|
132
|
+
n,
|
|
133
|
+
e.startWidth,
|
|
134
|
+
e.endWidth,
|
|
135
|
+
a
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
118
139
|
}
|
|
119
140
|
convertPolyline3d(e) {
|
|
120
|
-
const n = !!(e.flag & 1),
|
|
141
|
+
const n = !!(e.flag & 1), t = [];
|
|
121
142
|
e.vertices.map((s) => {
|
|
122
|
-
s.flag & 16 ||
|
|
143
|
+
s.flag & 16 || t.push({
|
|
123
144
|
x: s.x,
|
|
124
145
|
y: s.y,
|
|
125
146
|
z: s.z
|
|
126
147
|
});
|
|
127
148
|
});
|
|
128
|
-
let
|
|
129
|
-
return e.flag & 4 && (e.smoothType == 6 ?
|
|
149
|
+
let o = y.SimplePoly;
|
|
150
|
+
return e.flag & 4 && (e.smoothType == 6 ? o = y.CubicSplinePoly : e.smoothType == 5 && (o = y.QuadSplinePoly)), new W(o, t, n);
|
|
130
151
|
}
|
|
131
152
|
convertHatch(e) {
|
|
132
|
-
var
|
|
133
|
-
const n = new
|
|
134
|
-
return (
|
|
153
|
+
var o;
|
|
154
|
+
const n = new H();
|
|
155
|
+
return (o = e.definitionLines) == null || o.forEach((s) => {
|
|
135
156
|
n.definitionLines.push({
|
|
136
157
|
angle: s.angle,
|
|
137
158
|
base: s.base,
|
|
@@ -140,55 +161,55 @@ class S {
|
|
|
140
161
|
});
|
|
141
162
|
}), n.isSolidFill = e.solidFill == 1, n.hatchStyle = e.hatchStyle, n.patternName = e.patternName, n.patternType = e.patternType, n.patternAngle = e.patternAngle == null ? 0 : e.patternAngle, n.patternScale = e.patternScale == null ? 0 : e.patternScale, e.boundaryPaths.forEach((s) => {
|
|
142
163
|
if (s.boundaryPathTypeFlag & 2) {
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
x:
|
|
147
|
-
y:
|
|
148
|
-
bulge:
|
|
164
|
+
const a = s, c = new X();
|
|
165
|
+
c.closed = a.isClosed, a.vertices.forEach((i, d) => {
|
|
166
|
+
c.addVertexAt(d, {
|
|
167
|
+
x: i.x,
|
|
168
|
+
y: i.y,
|
|
169
|
+
bulge: i.bulge
|
|
149
170
|
});
|
|
150
|
-
}), n.add(
|
|
171
|
+
}), n.add(c);
|
|
151
172
|
} else {
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
if (
|
|
155
|
-
if (
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
} else if (
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
new
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
!
|
|
173
|
+
const a = s, c = [];
|
|
174
|
+
a.edges.forEach((d) => {
|
|
175
|
+
if (d != null) {
|
|
176
|
+
if (d.type == 1) {
|
|
177
|
+
const l = d;
|
|
178
|
+
c.push(new U(l.start, l.end));
|
|
179
|
+
} else if (d.type == 2) {
|
|
180
|
+
const l = d;
|
|
181
|
+
c.push(
|
|
182
|
+
new G(
|
|
183
|
+
l.center,
|
|
184
|
+
l.radius,
|
|
185
|
+
l.startAngle,
|
|
186
|
+
l.endAngle,
|
|
187
|
+
!l.isCCW
|
|
167
188
|
)
|
|
168
189
|
);
|
|
169
|
-
} else if (
|
|
170
|
-
const
|
|
171
|
-
new
|
|
190
|
+
} else if (d.type == 3) {
|
|
191
|
+
const l = d;
|
|
192
|
+
new Y().subVectors(l.end, l.center);
|
|
172
193
|
const p = Math.sqrt(
|
|
173
|
-
Math.pow(
|
|
174
|
-
), u = p *
|
|
175
|
-
let f =
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
new
|
|
179
|
-
{ ...
|
|
194
|
+
Math.pow(l.end.x, 2) + Math.pow(l.end.y, 2)
|
|
195
|
+
), u = p * l.lengthOfMinorAxis;
|
|
196
|
+
let f = l.startAngle, g = l.endAngle;
|
|
197
|
+
const x = Math.atan2(l.end.y, l.end.x);
|
|
198
|
+
l.isCCW || (f = Math.PI * 2 - f, g = Math.PI * 2 - g), c.push(
|
|
199
|
+
new _(
|
|
200
|
+
{ ...l.center, z: 0 },
|
|
180
201
|
p,
|
|
181
202
|
u,
|
|
182
203
|
f,
|
|
183
204
|
g,
|
|
184
|
-
!
|
|
185
|
-
|
|
205
|
+
!l.isCCW,
|
|
206
|
+
x
|
|
186
207
|
)
|
|
187
208
|
);
|
|
188
|
-
} else if (
|
|
189
|
-
const
|
|
190
|
-
if (
|
|
191
|
-
const h =
|
|
209
|
+
} else if (d.type == 4) {
|
|
210
|
+
const l = d;
|
|
211
|
+
if (l.numberOfControlPoints > 0 && l.numberOfKnots > 0) {
|
|
212
|
+
const h = l.controlPoints.map(
|
|
192
213
|
(f) => ({
|
|
193
214
|
x: f.x,
|
|
194
215
|
y: f.y,
|
|
@@ -196,104 +217,104 @@ class S {
|
|
|
196
217
|
})
|
|
197
218
|
);
|
|
198
219
|
let p = !0;
|
|
199
|
-
const u =
|
|
200
|
-
|
|
201
|
-
new
|
|
220
|
+
const u = l.controlPoints.map((f) => (f.weight == null && (p = !1), f.weight || 1));
|
|
221
|
+
c.push(
|
|
222
|
+
new P(
|
|
202
223
|
h,
|
|
203
|
-
|
|
224
|
+
l.knots,
|
|
204
225
|
p ? u : void 0
|
|
205
226
|
)
|
|
206
227
|
);
|
|
207
|
-
} else if (
|
|
208
|
-
const h =
|
|
228
|
+
} else if (l.numberOfFitData > 0) {
|
|
229
|
+
const h = l.fitDatum.map((p) => ({
|
|
209
230
|
x: p.x,
|
|
210
231
|
y: p.y,
|
|
211
232
|
z: 0
|
|
212
233
|
}));
|
|
213
|
-
|
|
234
|
+
c.push(new P(h, "Uniform"));
|
|
214
235
|
}
|
|
215
236
|
}
|
|
216
237
|
}
|
|
217
238
|
});
|
|
218
|
-
const
|
|
219
|
-
|
|
239
|
+
const i = E.buildFromEdges(c);
|
|
240
|
+
i.length == 0 && c.length > 0 ? n.add(new E(c)) : i.forEach((d) => n.add(d));
|
|
220
241
|
}
|
|
221
242
|
}), n;
|
|
222
243
|
}
|
|
223
244
|
convertTable(e) {
|
|
224
|
-
const n = new
|
|
245
|
+
const n = new Z(
|
|
225
246
|
e.name,
|
|
226
247
|
e.rowCount,
|
|
227
248
|
e.columnCount
|
|
228
249
|
);
|
|
229
250
|
return n.tableStyleId = e.tableStyleId, n.owningBlockRecordId = e.blockRecordHandle, e.directionVector && (n.horizontalDirection = new D(e.directionVector)), n.attachmentPoint = e.attachmentPoint, n.position.copy(e.startPoint), n.tableValueFlag = e.tableValue, n.tableOverrideFlag = e.overrideFlag, n.borderColorOverrideFlag = e.borderColorOverrideFlag, n.borderLineweightOverrideFlag = e.borderLineWeightOverrideFlag, n.borderVisibilityOverrideFlag = e.borderVisibilityOverrideFlag, e.columnWidthArr.forEach(
|
|
230
|
-
(
|
|
251
|
+
(t, o) => n.setColumnWidth(o, t)
|
|
231
252
|
), e.rowHeightArr.forEach(
|
|
232
|
-
(
|
|
233
|
-
), e.cells.forEach((
|
|
234
|
-
n.setCell(
|
|
253
|
+
(t, o) => n.setRowHeight(o, t)
|
|
254
|
+
), e.cells.forEach((t, o) => {
|
|
255
|
+
n.setCell(o, t);
|
|
235
256
|
}), n;
|
|
236
257
|
}
|
|
237
258
|
convertText(e) {
|
|
238
|
-
const n = new
|
|
259
|
+
const n = new K();
|
|
239
260
|
return n.textString = e.text, n.styleName = e.styleName, n.height = e.textHeight, n.position.copy(e.startPoint), n.rotation = e.rotation, n.oblique = e.obliqueAngle ?? 0, n.thickness = e.thickness, n.horizontalMode = e.halign, n.verticalMode = e.valign, n.widthFactor = e.xScale ?? 1, n;
|
|
240
261
|
}
|
|
241
262
|
convertMText(e) {
|
|
242
|
-
const n = new
|
|
263
|
+
const n = new q();
|
|
243
264
|
return n.contents = e.text, e.styleName != null && (n.styleName = e.styleName), n.height = e.textHeight, n.width = e.rectWidth, n.rotation = e.rotation || 0, n.location = e.insertionPoint, n.attachmentPoint = e.attachmentPoint, e.direction && (n.direction = new D(e.direction)), n.drawingDirection = e.drawingDirection, n;
|
|
244
265
|
}
|
|
245
266
|
convertLeader(e) {
|
|
246
|
-
const n = new
|
|
247
|
-
return e.vertices.forEach((
|
|
248
|
-
n.appendVertex(
|
|
267
|
+
const n = new J();
|
|
268
|
+
return e.vertices.forEach((t) => {
|
|
269
|
+
n.appendVertex(t);
|
|
249
270
|
}), n.hasArrowHead = e.isArrowheadEnabled, n.hasHookLine = e.isHooklineExists, n.isSplined = e.isSpline, n.dimensionStyle = e.styleName, n.annoType = e.leaderCreationFlag, n;
|
|
250
271
|
}
|
|
251
272
|
convertDimension(e) {
|
|
252
273
|
if (e.subclassMarker == "AcDbAlignedDimension" || e.subclassMarker == "AcDbRotatedDimension") {
|
|
253
|
-
const n = e,
|
|
274
|
+
const n = e, t = new Q(
|
|
254
275
|
n.subDefinitionPoint1,
|
|
255
276
|
n.subDefinitionPoint2,
|
|
256
277
|
n.definitionPoint
|
|
257
278
|
);
|
|
258
|
-
return n.insertionPoint && (
|
|
279
|
+
return n.insertionPoint && (t.dimBlockPosition = {
|
|
259
280
|
x: n.insertionPoint.x,
|
|
260
281
|
y: n.insertionPoint.y,
|
|
261
282
|
z: 0
|
|
262
|
-
}),
|
|
283
|
+
}), t.rotation = n.rotationAngle, this.processDimensionCommonAttrs(e, t), t;
|
|
263
284
|
} else if (e.subclassMarker == "AcDb3PointAngularDimension") {
|
|
264
|
-
const n = e,
|
|
285
|
+
const n = e, t = new $(
|
|
265
286
|
n.centerPoint,
|
|
266
287
|
n.subDefinitionPoint1,
|
|
267
288
|
n.subDefinitionPoint2,
|
|
268
289
|
n.definitionPoint
|
|
269
290
|
);
|
|
270
|
-
return this.processDimensionCommonAttrs(e,
|
|
291
|
+
return this.processDimensionCommonAttrs(e, t), t;
|
|
271
292
|
} else if (e.subclassMarker == "AcDbOrdinateDimension") {
|
|
272
|
-
const n = e,
|
|
293
|
+
const n = e, t = new ee(
|
|
273
294
|
n.subDefinitionPoint1,
|
|
274
295
|
n.subDefinitionPoint2
|
|
275
296
|
);
|
|
276
|
-
return this.processDimensionCommonAttrs(e,
|
|
297
|
+
return this.processDimensionCommonAttrs(e, t), t;
|
|
277
298
|
} else if (e.subclassMarker == "AcDbRadialDimension") {
|
|
278
|
-
const n = e,
|
|
299
|
+
const n = e, t = new ne(
|
|
279
300
|
n.definitionPoint,
|
|
280
301
|
n.centerPoint,
|
|
281
302
|
n.leaderLength
|
|
282
303
|
);
|
|
283
|
-
return this.processDimensionCommonAttrs(e,
|
|
304
|
+
return this.processDimensionCommonAttrs(e, t), t;
|
|
284
305
|
} else if (e.subclassMarker == "AcDbDiametricDimension") {
|
|
285
|
-
const n = e,
|
|
306
|
+
const n = e, t = new oe(
|
|
286
307
|
n.definitionPoint,
|
|
287
308
|
n.centerPoint,
|
|
288
309
|
n.leaderLength
|
|
289
310
|
);
|
|
290
|
-
return this.processDimensionCommonAttrs(e,
|
|
311
|
+
return this.processDimensionCommonAttrs(e, t), t;
|
|
291
312
|
}
|
|
292
313
|
return null;
|
|
293
314
|
}
|
|
294
315
|
processImage(e, n) {
|
|
295
|
-
n.position.copy(e.position), n.brightness = e.brightness, n.contrast = e.contrast, n.fade = e.fade, n.imageSize.copy(e.imageSize), n.imageDefId = e.imageDefHandle, n.isClipped = e.clipping > 0, n.isShownClipped = (e.flags | 4) > 0, n.isImageShown = (e.flags | 3) > 0, n.isImageTransparent = (e.flags | 8) > 0, e.clippingBoundaryPath.forEach((
|
|
296
|
-
n.clipBoundary.push(new b(
|
|
316
|
+
n.position.copy(e.position), n.brightness = e.brightness, n.contrast = e.contrast, n.fade = e.fade, n.imageSize.copy(e.imageSize), n.imageDefId = e.imageDefHandle, n.isClipped = e.clipping > 0, n.isShownClipped = (e.flags | 4) > 0, n.isImageShown = (e.flags | 3) > 0, n.isImageTransparent = (e.flags | 8) > 0, e.clippingBoundaryPath.forEach((t) => {
|
|
317
|
+
n.clipBoundary.push(new b(t));
|
|
297
318
|
}), n.clipBoundaryType = e.clippingBoundaryType, n.width = Math.sqrt(
|
|
298
319
|
e.uPixel.x ** 2 + e.uPixel.y ** 2 + e.uPixel.z ** 2
|
|
299
320
|
) * e.imageSize.x, n.height = Math.sqrt(
|
|
@@ -301,42 +322,42 @@ class S {
|
|
|
301
322
|
) * e.imageSize.y, n.rotation = Math.atan2(e.uPixel.y, e.uPixel.x);
|
|
302
323
|
}
|
|
303
324
|
convertImage(e) {
|
|
304
|
-
const n = new
|
|
325
|
+
const n = new te();
|
|
305
326
|
return this.processImage(e, n), n;
|
|
306
327
|
}
|
|
307
328
|
convertWipeout(e) {
|
|
308
|
-
const n = new
|
|
329
|
+
const n = new se();
|
|
309
330
|
return this.processImage(e, n), n;
|
|
310
331
|
}
|
|
311
332
|
convertViewport(e) {
|
|
312
|
-
const n = new
|
|
333
|
+
const n = new re();
|
|
313
334
|
return n.number = e.viewportId, n.centerPoint.copy(e.viewportCenter), n.height = e.height, n.width = e.width, n.viewCenter.copy(e.displayCenter), n.viewHeight = e.viewHeight, n;
|
|
314
335
|
}
|
|
315
336
|
convertRay(e) {
|
|
316
|
-
const n = new
|
|
337
|
+
const n = new ie();
|
|
317
338
|
return n.basePoint.copy(e.firstPoint), n.unitDir.copy(e.unitDirection), n;
|
|
318
339
|
}
|
|
319
340
|
convertXline(e) {
|
|
320
|
-
const n = new
|
|
341
|
+
const n = new ce();
|
|
321
342
|
return n.basePoint.copy(e.firstPoint), n.unitDir.copy(e.unitDirection), n;
|
|
322
343
|
}
|
|
323
344
|
convertAttributeCommon(e, n) {
|
|
324
|
-
const
|
|
325
|
-
n.textString =
|
|
345
|
+
const t = e.text;
|
|
346
|
+
n.textString = t.text, n.styleName = t.styleName, n.height = t.textHeight, n.position.copy(t.startPoint), n.rotation = t.rotation, n.oblique = t.obliqueAngle ?? 0, n.thickness = t.thickness, n.horizontalMode = t.halign, n.verticalMode = t.valign, n.widthFactor = t.xScale ?? 1, n.tag = e.tag, n.fieldLength = e.fieldLength, n.isInvisible = (e.flags & I.Invisible) !== 0, n.isConst = (e.flags & I.Const) !== 0, n.isVerifiable = (e.flags & I.Verifiable) !== 0, n.isPreset = (e.flags & I.Preset) !== 0, n.lockPositionInBlock = e.lockPositionFlag, n.isReallyLocked = e.isReallyLocked, n.isMTextAttribute = (e.mtextFlag & M.MultiLine) !== 0, n.isConstMTextAttribute = (e.mtextFlag & M.ConstMultiLine) !== 0;
|
|
326
347
|
}
|
|
327
348
|
convertAttribute(e) {
|
|
328
|
-
const n = new
|
|
349
|
+
const n = new le();
|
|
329
350
|
return this.convertAttributeCommon(e, n), n;
|
|
330
351
|
}
|
|
331
352
|
convertAttributeDefinition(e) {
|
|
332
|
-
const n = new
|
|
353
|
+
const n = new ae();
|
|
333
354
|
return this.convertAttributeCommon(e, n), n.prompt = e.prompt, n;
|
|
334
355
|
}
|
|
335
356
|
convertBlockReference(e) {
|
|
336
|
-
const n = new
|
|
337
|
-
return e.insertionPoint && n.position.copy(e.insertionPoint), n.scaleFactors.x = e.xScale, n.scaleFactors.y = e.yScale, n.scaleFactors.z = e.zScale, n.rotation = e.rotation, n.normal.copy(e.extrusionDirection), e.attribs && e.attribs.forEach((
|
|
338
|
-
const
|
|
339
|
-
n.appendAttributes(
|
|
357
|
+
const n = new de(e.name);
|
|
358
|
+
return e.insertionPoint && n.position.copy(e.insertionPoint), n.scaleFactors.x = e.xScale, n.scaleFactors.y = e.yScale, n.scaleFactors.z = e.zScale, n.rotation = e.rotation, n.normal.copy(e.extrusionDirection), e.attribs && e.attribs.forEach((t) => {
|
|
359
|
+
const o = this.convertAttribute(t);
|
|
360
|
+
n.appendAttributes(o);
|
|
340
361
|
}), n;
|
|
341
362
|
}
|
|
342
363
|
processDimensionCommonAttrs(e, n) {
|
|
@@ -344,22 +365,22 @@ class S {
|
|
|
344
365
|
}
|
|
345
366
|
processCommonAttrs(e, n) {
|
|
346
367
|
if (n.layer = e.layer || "0", n.objectId = e.handle, n.ownerId = e.ownerBlockRecordSoftId, e.lineType != null && (n.lineType = e.lineType), e.lineweight != null && (n.lineWeight = e.lineweight), e.lineTypeScale != null && (n.linetypeScale = e.lineTypeScale), e.color != null && n.color.setRGBValue(e.color), e.colorIndex != null && (n.color.colorIndex = e.colorIndex), e.colorName && (n.color.colorName = e.colorName), e.isVisible != null && (n.visibility = e.isVisible), e.transparency != null) {
|
|
347
|
-
const
|
|
348
|
-
|
|
368
|
+
const t = new pe();
|
|
369
|
+
t.method = e.transparencyType, (t.isByBlock || t.isByBlock) && (t.alpha = e.transparency), n.transparency = t;
|
|
349
370
|
}
|
|
350
371
|
}
|
|
351
372
|
}
|
|
352
|
-
const
|
|
353
|
-
class
|
|
373
|
+
const Ee = "*MODEL_SPACE";
|
|
374
|
+
class Le extends ue {
|
|
354
375
|
constructor(e = {}) {
|
|
355
376
|
super(e), e.useWorker = !0, e.parserWorkerUrl || (e.parserWorkerUrl = "/assets/libredwg-parser-worker.js");
|
|
356
377
|
}
|
|
357
378
|
async parse(e, n) {
|
|
358
|
-
const
|
|
359
|
-
if (
|
|
360
|
-
const s =
|
|
361
|
-
workerUrl:
|
|
362
|
-
timeout:
|
|
379
|
+
const t = this.config, o = this.getParserWorkerTimeout(e, n);
|
|
380
|
+
if (t.useWorker && t.parserWorkerUrl) {
|
|
381
|
+
const s = fe({
|
|
382
|
+
workerUrl: t.parserWorkerUrl,
|
|
383
|
+
timeout: o,
|
|
363
384
|
// One concurrent worker needed for parser
|
|
364
385
|
maxConcurrentWorkers: 1
|
|
365
386
|
}), r = await s.execute(e);
|
|
@@ -381,175 +402,175 @@ class Pe extends de {
|
|
|
381
402
|
e.tables.BLOCK_RECORD.entries.forEach((r) => {
|
|
382
403
|
n.set(r.name, r);
|
|
383
404
|
});
|
|
384
|
-
const
|
|
405
|
+
const t = /* @__PURE__ */ new Map(), o = (r) => {
|
|
385
406
|
if (r) {
|
|
386
|
-
const
|
|
387
|
-
return
|
|
407
|
+
const a = r.lastIndexOf(".");
|
|
408
|
+
return a >= 0 ? r.substring(0, a).toLowerCase() : r.toLowerCase();
|
|
388
409
|
}
|
|
389
410
|
};
|
|
390
411
|
e.tables.STYLE.entries.forEach((r) => {
|
|
391
|
-
const
|
|
392
|
-
let
|
|
393
|
-
|
|
412
|
+
const a = [];
|
|
413
|
+
let c = o(r.font);
|
|
414
|
+
c && a.push(c), c = o(r.bigFont), c && a.push(c), t.set(r.name, a);
|
|
394
415
|
});
|
|
395
416
|
const s = /* @__PURE__ */ new Set();
|
|
396
|
-
return this.getFontsInBlock(e.entities, n,
|
|
417
|
+
return this.getFontsInBlock(e.entities, n, t, s), Array.from(s);
|
|
397
418
|
}
|
|
398
419
|
/**
|
|
399
420
|
* Iterate entities in model space to get fonts used by text, mtext and insert entities
|
|
400
421
|
*/
|
|
401
|
-
getFontsInBlock(e, n,
|
|
422
|
+
getFontsInBlock(e, n, t, o) {
|
|
402
423
|
const s = /\\f(.*?)\|/g;
|
|
403
424
|
e.forEach((r) => {
|
|
404
425
|
if (r.type == "MTEXT") {
|
|
405
|
-
const
|
|
406
|
-
[...
|
|
407
|
-
|
|
426
|
+
const a = r;
|
|
427
|
+
[...a.text.matchAll(s)].forEach((i) => {
|
|
428
|
+
o.add(i[1].toLowerCase());
|
|
408
429
|
});
|
|
409
|
-
const
|
|
410
|
-
|
|
430
|
+
const c = t.get(a.styleName);
|
|
431
|
+
c == null || c.forEach((i) => o.add(i));
|
|
411
432
|
} else if (r.type == "TEXT") {
|
|
412
|
-
const
|
|
413
|
-
|
|
433
|
+
const a = r, c = t.get(a.styleName);
|
|
434
|
+
c == null || c.forEach((i) => o.add(i));
|
|
414
435
|
} else if (r.type == "INSERT") {
|
|
415
|
-
const
|
|
416
|
-
|
|
436
|
+
const a = r, c = n.get(a.name);
|
|
437
|
+
c && this.getFontsInBlock(c.entities, n, t, o);
|
|
417
438
|
}
|
|
418
439
|
});
|
|
419
440
|
}
|
|
420
441
|
processLineTypes(e, n) {
|
|
421
|
-
e.tables.LTYPE.entries.forEach((
|
|
442
|
+
e.tables.LTYPE.entries.forEach((o) => {
|
|
422
443
|
const s = {
|
|
423
|
-
name:
|
|
424
|
-
description:
|
|
425
|
-
standardFlag:
|
|
426
|
-
totalPatternLength:
|
|
427
|
-
pattern:
|
|
428
|
-
}, r = new
|
|
429
|
-
this.processCommonTableEntryAttrs(
|
|
444
|
+
name: o.name,
|
|
445
|
+
description: o.description,
|
|
446
|
+
standardFlag: o.standardFlag,
|
|
447
|
+
totalPatternLength: o.totalPatternLength,
|
|
448
|
+
pattern: o.pattern
|
|
449
|
+
}, r = new he(s);
|
|
450
|
+
this.processCommonTableEntryAttrs(o, r), r.name = o.name, n.tables.linetypeTable.add(r);
|
|
430
451
|
});
|
|
431
452
|
}
|
|
432
453
|
processTextStyles(e, n) {
|
|
433
|
-
e.tables.STYLE.entries.forEach((
|
|
434
|
-
const s = new
|
|
435
|
-
this.processCommonTableEntryAttrs(
|
|
454
|
+
e.tables.STYLE.entries.forEach((o) => {
|
|
455
|
+
const s = new ge(o);
|
|
456
|
+
this.processCommonTableEntryAttrs(o, s), n.tables.textStyleTable.add(s);
|
|
436
457
|
});
|
|
437
458
|
}
|
|
438
459
|
processDimStyles(e, n) {
|
|
439
|
-
e.tables.DIMSTYLE.entries.forEach((
|
|
460
|
+
e.tables.DIMSTYLE.entries.forEach((o) => {
|
|
440
461
|
const s = {
|
|
441
|
-
name:
|
|
442
|
-
ownerId:
|
|
443
|
-
dimpost:
|
|
444
|
-
dimapost:
|
|
445
|
-
dimscale:
|
|
446
|
-
dimasz:
|
|
447
|
-
dimexo:
|
|
448
|
-
dimdli:
|
|
449
|
-
dimexe:
|
|
450
|
-
dimrnd:
|
|
451
|
-
dimdle:
|
|
452
|
-
dimtp:
|
|
453
|
-
dimtm:
|
|
454
|
-
dimtxt:
|
|
455
|
-
dimcen:
|
|
456
|
-
dimtsz:
|
|
457
|
-
dimaltf:
|
|
458
|
-
dimlfac:
|
|
459
|
-
dimtvp:
|
|
460
|
-
dimtfac:
|
|
461
|
-
dimgap:
|
|
462
|
-
dimaltrnd:
|
|
463
|
-
dimtol:
|
|
464
|
-
dimlim:
|
|
465
|
-
dimtih:
|
|
466
|
-
dimtoh:
|
|
467
|
-
dimse1:
|
|
468
|
-
dimse2:
|
|
469
|
-
dimtad:
|
|
470
|
-
dimzin:
|
|
471
|
-
dimazin:
|
|
472
|
-
dimalt:
|
|
473
|
-
dimaltd:
|
|
474
|
-
dimtofl:
|
|
475
|
-
dimsah:
|
|
476
|
-
dimtix:
|
|
477
|
-
dimsoxd:
|
|
478
|
-
dimclrd:
|
|
479
|
-
dimclre:
|
|
480
|
-
dimclrt:
|
|
481
|
-
dimadec:
|
|
482
|
-
dimunit:
|
|
483
|
-
dimdec:
|
|
484
|
-
dimtdec:
|
|
485
|
-
dimaltu:
|
|
486
|
-
dimalttd:
|
|
487
|
-
dimaunit:
|
|
488
|
-
dimfrac:
|
|
489
|
-
dimlunit:
|
|
490
|
-
dimdsep:
|
|
491
|
-
dimtmove:
|
|
492
|
-
dimjust:
|
|
493
|
-
dimsd1:
|
|
494
|
-
dimsd2:
|
|
495
|
-
dimtolj:
|
|
496
|
-
dimtzin:
|
|
497
|
-
dimaltz:
|
|
498
|
-
dimalttz:
|
|
499
|
-
dimfit:
|
|
500
|
-
dimupt:
|
|
501
|
-
dimatfit:
|
|
502
|
-
dimtxsty:
|
|
462
|
+
name: o.name,
|
|
463
|
+
ownerId: o.ownerHandle,
|
|
464
|
+
dimpost: o.DIMPOST || "",
|
|
465
|
+
dimapost: o.DIMAPOST || "",
|
|
466
|
+
dimscale: o.DIMSCALE,
|
|
467
|
+
dimasz: o.DIMASZ,
|
|
468
|
+
dimexo: o.DIMEXO,
|
|
469
|
+
dimdli: o.DIMDLI,
|
|
470
|
+
dimexe: o.DIMEXE,
|
|
471
|
+
dimrnd: o.DIMRND,
|
|
472
|
+
dimdle: o.DIMDLE,
|
|
473
|
+
dimtp: o.DIMTP,
|
|
474
|
+
dimtm: o.DIMTM,
|
|
475
|
+
dimtxt: o.DIMTXT,
|
|
476
|
+
dimcen: o.DIMCEN,
|
|
477
|
+
dimtsz: o.DIMTSZ,
|
|
478
|
+
dimaltf: o.DIMALTF,
|
|
479
|
+
dimlfac: o.DIMLFAC,
|
|
480
|
+
dimtvp: o.DIMTVP,
|
|
481
|
+
dimtfac: o.DIMTFAC,
|
|
482
|
+
dimgap: o.DIMGAP,
|
|
483
|
+
dimaltrnd: o.DIMALTRND,
|
|
484
|
+
dimtol: o.DIMTOL == null || o.DIMTOL == 0 ? 0 : 1,
|
|
485
|
+
dimlim: o.DIMLIM == null || o.DIMLIM == 0 ? 0 : 1,
|
|
486
|
+
dimtih: o.DIMTIH == null || o.DIMTIH == 0 ? 0 : 1,
|
|
487
|
+
dimtoh: o.DIMTOH == null || o.DIMTOH == 0 ? 0 : 1,
|
|
488
|
+
dimse1: o.DIMSE1 == null || o.DIMSE1 == 0 ? 0 : 1,
|
|
489
|
+
dimse2: o.DIMSE2 == null || o.DIMSE2 == 0 ? 0 : 1,
|
|
490
|
+
dimtad: o.DIMTAD,
|
|
491
|
+
dimzin: o.DIMZIN,
|
|
492
|
+
dimazin: o.DIMAZIN,
|
|
493
|
+
dimalt: o.DIMALT,
|
|
494
|
+
dimaltd: o.DIMALTD,
|
|
495
|
+
dimtofl: o.DIMTOFL,
|
|
496
|
+
dimsah: o.DIMSAH,
|
|
497
|
+
dimtix: o.DIMTIX,
|
|
498
|
+
dimsoxd: o.DIMSOXD,
|
|
499
|
+
dimclrd: o.DIMCLRD,
|
|
500
|
+
dimclre: o.DIMCLRE,
|
|
501
|
+
dimclrt: o.DIMCLRT,
|
|
502
|
+
dimadec: o.DIMADEC || 0,
|
|
503
|
+
dimunit: o.DIMUNIT || 2,
|
|
504
|
+
dimdec: o.DIMDEC,
|
|
505
|
+
dimtdec: o.DIMTDEC,
|
|
506
|
+
dimaltu: o.DIMALTU,
|
|
507
|
+
dimalttd: o.DIMALTTD,
|
|
508
|
+
dimaunit: o.DIMAUNIT,
|
|
509
|
+
dimfrac: o.DIMFRAC,
|
|
510
|
+
dimlunit: o.DIMLUNIT,
|
|
511
|
+
dimdsep: o.DIMDSEP || ".",
|
|
512
|
+
dimtmove: o.DIMTMOVE || 0,
|
|
513
|
+
dimjust: o.DIMJUST,
|
|
514
|
+
dimsd1: o.DIMSD1,
|
|
515
|
+
dimsd2: o.DIMSD2,
|
|
516
|
+
dimtolj: o.DIMTOLJ,
|
|
517
|
+
dimtzin: o.DIMTZIN,
|
|
518
|
+
dimaltz: o.DIMALTZ,
|
|
519
|
+
dimalttz: o.DIMALTTZ,
|
|
520
|
+
dimfit: o.DIMFIT || 0,
|
|
521
|
+
dimupt: o.DIMUPT,
|
|
522
|
+
dimatfit: o.DIMATFIT,
|
|
523
|
+
dimtxsty: L,
|
|
503
524
|
// TODO: Set correct value
|
|
504
525
|
dimldrblk: "",
|
|
505
526
|
// TODO: Set correct value
|
|
506
|
-
dimblk:
|
|
527
|
+
dimblk: o.DIMBLK || "",
|
|
507
528
|
// TODO: Set correct value
|
|
508
|
-
dimblk1:
|
|
529
|
+
dimblk1: o.DIMBLK1 || "",
|
|
509
530
|
// TODO: Set correct value
|
|
510
|
-
dimblk2:
|
|
531
|
+
dimblk2: o.DIMBLK2 || "",
|
|
511
532
|
// TODO: Set correct value
|
|
512
|
-
dimlwd:
|
|
513
|
-
dimlwe:
|
|
514
|
-
}, r = new
|
|
515
|
-
this.processCommonTableEntryAttrs(
|
|
533
|
+
dimlwd: o.DIMLWD,
|
|
534
|
+
dimlwe: o.DIMLWE
|
|
535
|
+
}, r = new De(s);
|
|
536
|
+
this.processCommonTableEntryAttrs(o, r), n.tables.dimStyleTable.add(r);
|
|
516
537
|
});
|
|
517
538
|
}
|
|
518
539
|
processLayers(e, n) {
|
|
519
|
-
e.tables.LAYER.entries.forEach((
|
|
520
|
-
const s = new
|
|
521
|
-
s.colorIndex =
|
|
522
|
-
const r = new
|
|
523
|
-
name:
|
|
524
|
-
standardFlags:
|
|
525
|
-
linetype:
|
|
526
|
-
lineWeight:
|
|
527
|
-
isOff:
|
|
540
|
+
e.tables.LAYER.entries.forEach((o) => {
|
|
541
|
+
const s = new Ae();
|
|
542
|
+
s.colorIndex = o.colorIndex;
|
|
543
|
+
const r = new Ie({
|
|
544
|
+
name: o.name,
|
|
545
|
+
standardFlags: o.standardFlag,
|
|
546
|
+
linetype: o.lineType,
|
|
547
|
+
lineWeight: o.lineweight,
|
|
548
|
+
isOff: o.off,
|
|
528
549
|
color: s,
|
|
529
|
-
isPlottable:
|
|
550
|
+
isPlottable: o.plotFlag != 0
|
|
530
551
|
});
|
|
531
|
-
this.processCommonTableEntryAttrs(
|
|
552
|
+
this.processCommonTableEntryAttrs(o, r), n.tables.layerTable.add(r);
|
|
532
553
|
});
|
|
533
554
|
}
|
|
534
555
|
processViewports(e, n) {
|
|
535
|
-
e.tables.VPORT.entries.forEach((
|
|
536
|
-
const s = new
|
|
537
|
-
this.processCommonTableEntryAttrs(
|
|
556
|
+
e.tables.VPORT.entries.forEach((o) => {
|
|
557
|
+
const s = new ye();
|
|
558
|
+
this.processCommonTableEntryAttrs(o, s), o.circleSides && (s.circleSides = o.circleSides), s.standardFlag = o.standardFlag, s.center.copy(o.center), s.lowerLeftCorner.copy(o.lowerLeftCorner), s.upperRightCorner.copy(o.upperRightCorner), o.snapBasePoint && s.snapBase.copy(o.snapBasePoint), o.snapRotationAngle && (s.snapAngle = o.snapRotationAngle), o.snapSpacing && s.snapIncrements.copy(o.snapSpacing), o.majorGridLines && (s.gridMajor = o.majorGridLines), o.gridSpacing && s.gridIncrements.copy(o.gridSpacing), o.backgroundObjectId && (s.backgroundObjectId = o.backgroundObjectId), s.gsView.center.copy(o.center), s.gsView.viewDirectionFromTarget.copy(o.viewDirectionFromTarget), s.gsView.viewTarget.copy(o.viewTarget), o.lensLength && (s.gsView.lensLength = o.lensLength), o.frontClippingPlane && (s.gsView.frontClippingPlane = o.frontClippingPlane), o.backClippingPlane && (s.gsView.backClippingPlane = o.backClippingPlane), o.viewHeight && (s.gsView.viewHeight = o.viewHeight), o.viewTwistAngle && (s.gsView.viewTwistAngle = o.viewTwistAngle), o.frozenLayers && (s.gsView.frozenLayers = o.frozenLayers), o.styleSheet && (s.gsView.styleSheet = o.styleSheet), o.renderMode && (s.gsView.renderMode = o.renderMode), o.viewMode && (s.gsView.viewMode = o.viewMode), o.ucsIconSetting && (s.gsView.ucsIconSetting = o.ucsIconSetting), o.ucsOrigin && s.gsView.ucsOrigin.copy(o.ucsOrigin), o.ucsXAxis && s.gsView.ucsXAxis.copy(o.ucsXAxis), o.ucsYAxis && s.gsView.ucsYAxis.copy(o.ucsYAxis), o.orthographicType && (s.gsView.orthographicType = o.orthographicType), o.shadePlotSetting && (s.gsView.shadePlotSetting = o.shadePlotSetting), o.shadePlotObjectId && (s.gsView.shadePlotObjectId = o.shadePlotObjectId), o.visualStyleObjectId && (s.gsView.visualStyleObjectId = o.visualStyleObjectId), o.isDefaultLightingOn && (s.gsView.isDefaultLightingOn = o.isDefaultLightingOn), o.defaultLightingType && (s.gsView.defaultLightingType = o.defaultLightingType), o.brightness && (s.gsView.brightness = o.brightness), o.contrast && (s.gsView.contrast = o.contrast), o.ambientColor && (s.gsView.ambientColor = o.ambientColor), n.tables.viewportTable.add(s);
|
|
538
559
|
});
|
|
539
560
|
}
|
|
540
561
|
processBlockTables(e, n) {
|
|
541
|
-
e.tables.BLOCK_RECORD.entries.forEach((
|
|
542
|
-
let s = n.tables.blockTable.getAt(
|
|
543
|
-
s || (s = new
|
|
562
|
+
e.tables.BLOCK_RECORD.entries.forEach((o) => {
|
|
563
|
+
let s = n.tables.blockTable.getAt(o.name);
|
|
564
|
+
s || (s = new we(), s.objectId = o.handle, s.name = o.name, s.ownerId = o.ownerHandle, s.origin.copy(o.basePoint), s.layoutId = o.layout, s.blockInsertUnits = o.insertionUnits, s.explodability = o.explodability, s.blockScaling = o.scalability, o.bmpPreview && (s.bmpPreview = o.bmpPreview), n.tables.blockTable.add(s)), !s.isModelSapce && o.entities && o.entities.length > 0 && this.processEntitiesInBlock(o.entities, s);
|
|
544
565
|
});
|
|
545
566
|
}
|
|
546
567
|
processBlocks(e, n) {
|
|
547
568
|
}
|
|
548
569
|
async processEntitiesInBlock(e, n) {
|
|
549
|
-
const
|
|
550
|
-
for (let r = 0; r <
|
|
551
|
-
const
|
|
552
|
-
|
|
570
|
+
const t = new S(), o = e.length, s = [];
|
|
571
|
+
for (let r = 0; r < o; r++) {
|
|
572
|
+
const a = e[r], c = t.convert(a);
|
|
573
|
+
c && s.push(c);
|
|
553
574
|
}
|
|
554
575
|
n.appendEntity(s);
|
|
555
576
|
}
|
|
@@ -558,34 +579,34 @@ class Pe extends de {
|
|
|
558
579
|
* as "batch processing" or "cooperative multitasking," where the time-consuming task is broken into
|
|
559
580
|
* smaller pieces and executed in small intervals to allow the UI to remain responsive.
|
|
560
581
|
*/
|
|
561
|
-
async processEntities(e, n,
|
|
582
|
+
async processEntities(e, n, t, o, s) {
|
|
562
583
|
const r = new S();
|
|
563
|
-
let
|
|
564
|
-
e.tables.BLOCK_RECORD.entries.forEach((
|
|
565
|
-
this.isModelSpace(
|
|
584
|
+
let a = [];
|
|
585
|
+
e.tables.BLOCK_RECORD.entries.forEach((l) => {
|
|
586
|
+
this.isModelSpace(l.name) && (a = l.entities);
|
|
566
587
|
});
|
|
567
|
-
const
|
|
568
|
-
|
|
569
|
-
100 -
|
|
570
|
-
|
|
588
|
+
const c = a.length, i = new Te(
|
|
589
|
+
c,
|
|
590
|
+
100 - o.value,
|
|
591
|
+
t
|
|
571
592
|
);
|
|
572
|
-
this.config.convertByEntityType && (
|
|
573
|
-
const
|
|
574
|
-
await
|
|
593
|
+
this.config.convertByEntityType && (a = this.groupAndFlattenByType(a));
|
|
594
|
+
const d = n.tables.blockTable.modelSpace;
|
|
595
|
+
await i.processChunk(async (l, h) => {
|
|
575
596
|
const p = [];
|
|
576
|
-
for (let u =
|
|
577
|
-
const f =
|
|
597
|
+
for (let u = l; u < h; u++) {
|
|
598
|
+
const f = a[u], g = r.convert(f);
|
|
578
599
|
g && p.push(g);
|
|
579
600
|
}
|
|
580
|
-
if (
|
|
581
|
-
let u =
|
|
601
|
+
if (d.appendEntity(p), s) {
|
|
602
|
+
let u = o.value + h / c * (100 - o.value);
|
|
582
603
|
u > 100 && (u = 100), await s(u, "ENTITY", "IN-PROGRESS");
|
|
583
604
|
}
|
|
584
605
|
});
|
|
585
606
|
}
|
|
586
607
|
processHeader(e, n) {
|
|
587
|
-
const
|
|
588
|
-
|
|
608
|
+
const t = e.header;
|
|
609
|
+
t.CECOLOR && (t.CECOLOR.index >= 0 && t.CECOLOR.index <= 256 ? n.cecolor.colorIndex = t.CECOLOR.index : n.cecolor.setRGBValue(t.CECOLOR.rgb)), n.angBase = t.ANGBASE ?? 0, n.angDir = t.ANGDIR ?? 0, n.aunits = t.AUNITS ?? 0, n.celtscale = t.CELTSCALE ?? 1, n.ltscale = t.LTSCALE ?? 1, t.EXTMAX && (n.extmax = t.EXTMAX), t.EXTMIN && (n.extmin = t.EXTMIN), n.insunits = t.INSUNITS ?? 1, n.pdmode = t.PDMODE ?? 0, n.pdsize = t.PDSIZE ?? 0, n.textstyle = t.TEXTSTYLE ?? L;
|
|
589
610
|
}
|
|
590
611
|
processCommonTableEntryAttrs(e, n) {
|
|
591
612
|
n.name = e.name, n.objectId = e.handle, n.ownerId = e.ownerHandle;
|
|
@@ -594,25 +615,25 @@ class Pe extends de {
|
|
|
594
615
|
this.processLayouts(e, n), this.processImageDefs(e, n);
|
|
595
616
|
}
|
|
596
617
|
processLayouts(e, n) {
|
|
597
|
-
const
|
|
618
|
+
const t = n.objects.layout;
|
|
598
619
|
e.objects.LAYOUT.forEach((s) => {
|
|
599
|
-
const r = new
|
|
620
|
+
const r = new be();
|
|
600
621
|
r.layoutName = s.layoutName, r.tabOrder = s.tabOrder;
|
|
601
|
-
const
|
|
622
|
+
const a = n.tables.blockTable.newIterator();
|
|
602
623
|
r.objectId = s.handle;
|
|
603
|
-
for (const
|
|
604
|
-
if (
|
|
605
|
-
r.blockTableRecordId =
|
|
624
|
+
for (const c of a)
|
|
625
|
+
if (c.layoutId === r.objectId) {
|
|
626
|
+
r.blockTableRecordId = c.objectId;
|
|
606
627
|
break;
|
|
607
628
|
}
|
|
608
|
-
r.blockTableRecordId || s.layoutName === "Model" && (r.blockTableRecordId = n.tables.blockTable.modelSpace.objectId), r.limits.min.copy(s.minLimit), r.limits.max.copy(s.maxLimit), r.extents.min.copy(s.minExtent), r.extents.max.copy(s.maxExtent), s.viewportId && r.viewportArray.push(s.viewportId), this.processCommonObjectAttrs(s, r),
|
|
629
|
+
r.blockTableRecordId || s.layoutName === "Model" && (r.blockTableRecordId = n.tables.blockTable.modelSpace.objectId), r.limits.min.copy(s.minLimit), r.limits.max.copy(s.maxLimit), r.extents.min.copy(s.minExtent), r.extents.max.copy(s.maxExtent), s.viewportId && r.viewportArray.push(s.viewportId), this.processCommonObjectAttrs(s, r), t.setAt(r.layoutName, r);
|
|
609
630
|
});
|
|
610
631
|
}
|
|
611
632
|
processImageDefs(e, n) {
|
|
612
|
-
const
|
|
633
|
+
const t = n.objects.imageDefinition;
|
|
613
634
|
e.objects.IMAGEDEF.forEach((s) => {
|
|
614
|
-
const r = new
|
|
615
|
-
r.sourceFileName = s.fileName, this.processCommonObjectAttrs(s, r),
|
|
635
|
+
const r = new Pe();
|
|
636
|
+
r.sourceFileName = s.fileName, this.processCommonObjectAttrs(s, r), t.setAt(r.objectId, r);
|
|
616
637
|
});
|
|
617
638
|
}
|
|
618
639
|
processCommonObjectAttrs(e, n) {
|
|
@@ -632,15 +653,15 @@ class Pe extends de {
|
|
|
632
653
|
* @returns A new array of entities grouped by their `type` property.
|
|
633
654
|
*/
|
|
634
655
|
groupAndFlattenByType(e) {
|
|
635
|
-
const n = {},
|
|
636
|
-
for (const
|
|
637
|
-
n[
|
|
638
|
-
return
|
|
656
|
+
const n = {}, t = [];
|
|
657
|
+
for (const o of e)
|
|
658
|
+
n[o.type] || (n[o.type] = [], t.push(o.type)), n[o.type].push(o);
|
|
659
|
+
return t.flatMap((o) => n[o]);
|
|
639
660
|
}
|
|
640
661
|
isModelSpace(e) {
|
|
641
|
-
return e && e.toUpperCase() ==
|
|
662
|
+
return e && e.toUpperCase() == Ee;
|
|
642
663
|
}
|
|
643
664
|
}
|
|
644
665
|
export {
|
|
645
|
-
|
|
666
|
+
Le as AcDbLibreDwgConverter
|
|
646
667
|
};
|