fl-web-component 2.0.19 → 2.1.1-beta.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.
- package/dist/fl-web-component.common.1.js.map +1 -1
- package/dist/fl-web-component.common.2.js.map +1 -1
- package/dist/fl-web-component.common.js +5871 -1872
- package/dist/fl-web-component.common.js.map +1 -1
- package/dist/fl-web-component.css +1 -1
- package/package.json +4 -3
- package/packages/components/com-flcanvas/components/entityFormatting.js +134 -1
- package/packages/components/com-flcanvas/index.vue +335 -239
- package/packages/components/com-graphics/index.vue +433 -35
- package/packages/components/com-graphics/mock.json +115 -0
- package/packages/utils/StreamLoader.js +250 -107
- package/packages/utils/StreamLoaderParser.worker.js +180 -72
- package/src/utils/dxf-parser/AutoCadColorIndex.js +265 -0
- package/src/utils/dxf-parser/DimStyleCodes.js +33 -0
- package/src/utils/dxf-parser/DxfArrayScanner.js +151 -0
- package/src/utils/dxf-parser/DxfParser.js +918 -0
- package/src/utils/dxf-parser/ExtendedDataParser.js +117 -0
- package/src/utils/dxf-parser/LICENSE +21 -0
- package/src/utils/dxf-parser/ParseHelpers.js +140 -0
- package/src/utils/dxf-parser/README.md +8 -0
- package/src/utils/dxf-parser/entities/3dface.js +83 -0
- package/src/utils/dxf-parser/entities/arc.js +38 -0
- package/src/utils/dxf-parser/entities/attdef.js +89 -0
- package/src/utils/dxf-parser/entities/attribute.js +109 -0
- package/src/utils/dxf-parser/entities/circle.js +43 -0
- package/src/utils/dxf-parser/entities/dimension.js +71 -0
- package/src/utils/dxf-parser/entities/ellipse.js +48 -0
- package/src/utils/dxf-parser/entities/hatch.js +348 -0
- package/src/utils/dxf-parser/entities/insert.js +57 -0
- package/src/utils/dxf-parser/entities/line.js +34 -0
- package/src/utils/dxf-parser/entities/lwpolyline.js +103 -0
- package/src/utils/dxf-parser/entities/mtext.js +57 -0
- package/src/utils/dxf-parser/entities/point.js +35 -0
- package/src/utils/dxf-parser/entities/polyline.js +92 -0
- package/src/utils/dxf-parser/entities/solid.js +40 -0
- package/src/utils/dxf-parser/entities/spline.js +70 -0
- package/src/utils/dxf-parser/entities/text.js +50 -0
- package/src/utils/dxf-parser/entities/vertex.js +62 -0
- package/src/utils/flgltf-parser.js +21 -9
- package/src/utils/instance-parser.js +59 -59
- package/src/utils/threejs/measure-clear-distance.js +149 -123
- package/packages/components/com-graphics/box.json +0 -77
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
|
|
2
|
+
import * as helpers from "../ParseHelpers.js"
|
|
3
|
+
|
|
4
|
+
export default function EntityParser() {}
|
|
5
|
+
|
|
6
|
+
EntityParser.ForEntityName = 'DIMENSION';
|
|
7
|
+
|
|
8
|
+
EntityParser.prototype.parseEntity = function(scanner, curr) {
|
|
9
|
+
var entity;
|
|
10
|
+
entity = { type: curr.value };
|
|
11
|
+
curr = scanner.next();
|
|
12
|
+
while(curr !== 'EOF') {
|
|
13
|
+
if(curr.code === 0) break;
|
|
14
|
+
|
|
15
|
+
switch(curr.code) {
|
|
16
|
+
case 2: // Referenced block name
|
|
17
|
+
entity.block = curr.value;
|
|
18
|
+
break;
|
|
19
|
+
case 3: // Dimension style name
|
|
20
|
+
entity.styleName = curr.value;
|
|
21
|
+
break;
|
|
22
|
+
case 10: // X coordinate of 'first alignment point'
|
|
23
|
+
entity.anchorPoint = helpers.parsePoint(scanner);
|
|
24
|
+
break;
|
|
25
|
+
case 11:
|
|
26
|
+
entity.middleOfText = helpers.parsePoint(scanner);
|
|
27
|
+
break;
|
|
28
|
+
case 12: // Insertion point for clones of a dimension
|
|
29
|
+
entity.insertionPoint = helpers.parsePoint(scanner);
|
|
30
|
+
break;
|
|
31
|
+
case 13: // Definition point for linear and angular dimensions
|
|
32
|
+
entity.linearOrAngularPoint1 = helpers.parsePoint(scanner);
|
|
33
|
+
break;
|
|
34
|
+
case 14: // Definition point for linear and angular dimensions
|
|
35
|
+
entity.linearOrAngularPoint2 = helpers.parsePoint(scanner);
|
|
36
|
+
break;
|
|
37
|
+
case 15: // Definition point for diameter, radius, and angular dimensions
|
|
38
|
+
entity.diameterOrRadiusPoint = helpers.parsePoint(scanner);
|
|
39
|
+
break;
|
|
40
|
+
case 16: // Point defining dimension arc for angular dimensions
|
|
41
|
+
entity.arcPoint = helpers.parsePoint(scanner);
|
|
42
|
+
break;
|
|
43
|
+
case 70: // Dimension type
|
|
44
|
+
entity.dimensionType = curr.value;
|
|
45
|
+
break;
|
|
46
|
+
case 71: // 5 = Middle center
|
|
47
|
+
entity.attachmentPoint = curr.value;
|
|
48
|
+
break;
|
|
49
|
+
case 42: // Actual measurement
|
|
50
|
+
entity.actualMeasurement = curr.value;
|
|
51
|
+
break;
|
|
52
|
+
case 1: // Text entered by user explicitly
|
|
53
|
+
entity.text = curr.value;
|
|
54
|
+
break;
|
|
55
|
+
case 50: // Angle of rotated, horizontal, or vertical dimensions
|
|
56
|
+
entity.angle = curr.value;
|
|
57
|
+
break;
|
|
58
|
+
case 53: // Rotation angle of the dimension text away from its default orientation (the
|
|
59
|
+
//direction of the dimension line)
|
|
60
|
+
entity.textRotation = curr.value;
|
|
61
|
+
break;
|
|
62
|
+
|
|
63
|
+
default: // check common entity attributes
|
|
64
|
+
helpers.checkCommonEntityProperties(entity, curr, scanner);
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
curr = scanner.next();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return entity;
|
|
71
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
|
|
2
|
+
import * as helpers from "../ParseHelpers.js"
|
|
3
|
+
|
|
4
|
+
export default function EntityParser() {}
|
|
5
|
+
|
|
6
|
+
EntityParser.ForEntityName = 'ELLIPSE';
|
|
7
|
+
|
|
8
|
+
EntityParser.prototype.parseEntity = function(scanner, curr) {
|
|
9
|
+
var entity;
|
|
10
|
+
entity = { type: curr.value };
|
|
11
|
+
curr = scanner.next();
|
|
12
|
+
while(curr !== 'EOF') {
|
|
13
|
+
if(curr.code === 0) break;
|
|
14
|
+
|
|
15
|
+
switch(curr.code) {
|
|
16
|
+
case 10:
|
|
17
|
+
entity.center = helpers.parsePoint(scanner);
|
|
18
|
+
break;
|
|
19
|
+
case 11:
|
|
20
|
+
entity.majorAxisEndPoint = helpers.parsePoint(scanner);
|
|
21
|
+
break;
|
|
22
|
+
case 40:
|
|
23
|
+
entity.axisRatio = curr.value;
|
|
24
|
+
break;
|
|
25
|
+
case 41:
|
|
26
|
+
/* Already in radians. */
|
|
27
|
+
entity.startAngle = curr.value;
|
|
28
|
+
break;
|
|
29
|
+
case 42:
|
|
30
|
+
/* Already in radians. */
|
|
31
|
+
entity.endAngle = curr.value;
|
|
32
|
+
break;
|
|
33
|
+
case 2:
|
|
34
|
+
entity.name = curr.value;
|
|
35
|
+
break;
|
|
36
|
+
case 210:
|
|
37
|
+
entity.extrusionDirection = helpers.parsePoint(scanner);
|
|
38
|
+
break;
|
|
39
|
+
default: // check common entity attributes
|
|
40
|
+
helpers.checkCommonEntityProperties(entity, curr, scanner);
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
curr = scanner.next();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return entity;
|
|
48
|
+
};
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import * as helpers from "../ParseHelpers.js"
|
|
2
|
+
|
|
3
|
+
export default function EntityParser() {}
|
|
4
|
+
|
|
5
|
+
EntityParser.ForEntityName = 'HATCH';
|
|
6
|
+
|
|
7
|
+
EntityParser.prototype.parseEntity = function(scanner, curr) {
|
|
8
|
+
var entity;
|
|
9
|
+
entity = { type: curr.value };
|
|
10
|
+
|
|
11
|
+
let numBoundaryLoops = 0;
|
|
12
|
+
let numDefinitionLines = 0;
|
|
13
|
+
let numSeedPoints = 0;
|
|
14
|
+
|
|
15
|
+
curr = scanner.next();
|
|
16
|
+
while(curr !== 'EOF') {
|
|
17
|
+
if (curr.code === 0) break;
|
|
18
|
+
|
|
19
|
+
while (numBoundaryLoops > 0) {
|
|
20
|
+
const loop = ParseBoundaryLoop(curr, scanner)
|
|
21
|
+
if (loop) {
|
|
22
|
+
entity.boundaryLoops.push(loop);
|
|
23
|
+
numBoundaryLoops--;
|
|
24
|
+
curr = scanner.next();
|
|
25
|
+
} else {
|
|
26
|
+
numBoundaryLoops = 0
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
while (numDefinitionLines > 0) {
|
|
31
|
+
const line = ParseDefinitionLine(curr, scanner)
|
|
32
|
+
if (line) {
|
|
33
|
+
entity.definitionLines.push(line);
|
|
34
|
+
numDefinitionLines--;
|
|
35
|
+
curr = scanner.next();
|
|
36
|
+
} else {
|
|
37
|
+
numDefinitionLines = 0
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
while (numSeedPoints > 0) {
|
|
42
|
+
const pt = ParseSeedPoint(curr, scanner);
|
|
43
|
+
if (pt) {
|
|
44
|
+
entity.seedPoints.push(pt);
|
|
45
|
+
numSeedPoints--;
|
|
46
|
+
curr = scanner.next();
|
|
47
|
+
} else {
|
|
48
|
+
numSeedPoints = 0
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (curr.code === 0) break;
|
|
53
|
+
|
|
54
|
+
switch(curr.code) {
|
|
55
|
+
|
|
56
|
+
case 2: // Hatch pattern name
|
|
57
|
+
entity.patternName = curr.value;
|
|
58
|
+
break;
|
|
59
|
+
|
|
60
|
+
case 70: //Solid fill flag (solid fill = 1; pattern fill = 0)
|
|
61
|
+
entity.isSolid = curr.value != 0;
|
|
62
|
+
break;
|
|
63
|
+
|
|
64
|
+
case 91: // Number of boundary paths (loops)
|
|
65
|
+
numBoundaryLoops = curr.value;
|
|
66
|
+
if (numBoundaryLoops > 0) {
|
|
67
|
+
entity.boundaryLoops = []
|
|
68
|
+
}
|
|
69
|
+
break;
|
|
70
|
+
|
|
71
|
+
// Hatch style:
|
|
72
|
+
// 0 = Hatch “odd parity” area (Normal style)
|
|
73
|
+
// 1 = Hatch outermost area only (Outer style)
|
|
74
|
+
// 2 = Hatch through entire area (Ignore style)
|
|
75
|
+
case 75:
|
|
76
|
+
entity.hatchStyle = curr.value;
|
|
77
|
+
break;
|
|
78
|
+
|
|
79
|
+
//Hatch pattern type:
|
|
80
|
+
// 0 = User-defined; 1 = Predefined; 2 = Custom
|
|
81
|
+
case 76:
|
|
82
|
+
entity.patternType = curr.value;
|
|
83
|
+
break;
|
|
84
|
+
|
|
85
|
+
case 52: // Hatch pattern angle (pattern fill only)
|
|
86
|
+
entity.patternAngle = curr.value * Math.PI / 180;
|
|
87
|
+
break;
|
|
88
|
+
|
|
89
|
+
case 41: // Hatch pattern scale or spacing (pattern fill only)
|
|
90
|
+
entity.patternScale = curr.value;
|
|
91
|
+
break;
|
|
92
|
+
|
|
93
|
+
case 78: // Number of pattern definition lines
|
|
94
|
+
numDefinitionLines = curr.value;
|
|
95
|
+
if (numDefinitionLines > 0) {
|
|
96
|
+
entity.definitionLines = []
|
|
97
|
+
}
|
|
98
|
+
break;
|
|
99
|
+
|
|
100
|
+
case 98: // Number of seed points
|
|
101
|
+
numSeedPoints = curr.value;
|
|
102
|
+
if (numSeedPoints > 0) {
|
|
103
|
+
entity.seedPoints = []
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
|
|
107
|
+
default: // check common entity attributes
|
|
108
|
+
helpers.checkCommonEntityProperties(entity, curr, scanner);
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
curr = scanner.next();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return entity;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
function ParseBoundaryLoop(curr, scanner) {
|
|
118
|
+
let entity = null
|
|
119
|
+
|
|
120
|
+
const ParsePolyline = () => {
|
|
121
|
+
const pl = {vertices: [], isClosed: false};
|
|
122
|
+
let hasBulge = false;
|
|
123
|
+
let numVertices = 0;
|
|
124
|
+
while (true) {
|
|
125
|
+
if (numVertices > 0) {
|
|
126
|
+
for (let i = 0; i < numVertices; i++) {
|
|
127
|
+
if (curr.code != 10) {
|
|
128
|
+
break
|
|
129
|
+
}
|
|
130
|
+
const p = helpers.parsePoint(scanner)
|
|
131
|
+
curr = scanner.next();
|
|
132
|
+
if (curr.code == 42) {
|
|
133
|
+
p.bulge = curr.value
|
|
134
|
+
curr = scanner.next();
|
|
135
|
+
}
|
|
136
|
+
pl.vertices.push(p)
|
|
137
|
+
}
|
|
138
|
+
return pl
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
switch (curr.code) {
|
|
142
|
+
case 72:
|
|
143
|
+
hasBulge = curr.value;
|
|
144
|
+
break;
|
|
145
|
+
case 73:
|
|
146
|
+
pl.isClosed = curr.value;
|
|
147
|
+
break;
|
|
148
|
+
case 93:
|
|
149
|
+
numVertices = curr.value;
|
|
150
|
+
break;
|
|
151
|
+
default:
|
|
152
|
+
return pl;
|
|
153
|
+
}
|
|
154
|
+
curr = scanner.next();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const ParseEdge = () => {
|
|
159
|
+
if (curr.code != 72) {
|
|
160
|
+
return null
|
|
161
|
+
}
|
|
162
|
+
const e = {type: curr.value}
|
|
163
|
+
curr = scanner.next();
|
|
164
|
+
const isSpline = e.type == 4
|
|
165
|
+
|
|
166
|
+
while (true) {
|
|
167
|
+
switch (curr.code) {
|
|
168
|
+
case 10:
|
|
169
|
+
if (isSpline) {
|
|
170
|
+
if (!e.controlPoints) {
|
|
171
|
+
e.controlPoints = [];
|
|
172
|
+
}
|
|
173
|
+
e.controlPoints.push(helpers.parsePoint(scanner));
|
|
174
|
+
} else {
|
|
175
|
+
e.start = helpers.parsePoint(scanner);
|
|
176
|
+
}
|
|
177
|
+
break;
|
|
178
|
+
case 11:
|
|
179
|
+
if (isSpline) {
|
|
180
|
+
if (!e.fitPoints) {
|
|
181
|
+
e.fitPoints = [];
|
|
182
|
+
}
|
|
183
|
+
e.fitPoints.push(helpers.parsePoint(scanner));
|
|
184
|
+
} else {
|
|
185
|
+
e.end = helpers.parsePoint(scanner);
|
|
186
|
+
}
|
|
187
|
+
break;
|
|
188
|
+
case 40:
|
|
189
|
+
if (isSpline) {
|
|
190
|
+
if (!e.knotValues) {
|
|
191
|
+
e.knotValues = [];
|
|
192
|
+
}
|
|
193
|
+
e.knotValues.push(curr.value);
|
|
194
|
+
} else {
|
|
195
|
+
e.radius = curr.value;
|
|
196
|
+
}
|
|
197
|
+
break;
|
|
198
|
+
case 50:
|
|
199
|
+
e.startAngle = curr.value * Math.PI / 180;
|
|
200
|
+
break;
|
|
201
|
+
case 51:
|
|
202
|
+
e.endAngle = curr.value * Math.PI / 180;
|
|
203
|
+
break;
|
|
204
|
+
case 73:
|
|
205
|
+
if (isSpline) {
|
|
206
|
+
e.rational = curr.value;
|
|
207
|
+
} else {
|
|
208
|
+
e.isCcw = curr.value;
|
|
209
|
+
}
|
|
210
|
+
break;
|
|
211
|
+
case 74:
|
|
212
|
+
e.periodic = curr.value;
|
|
213
|
+
break;
|
|
214
|
+
case 94:
|
|
215
|
+
e.degreeOfSplineCurve = curr.value;
|
|
216
|
+
break;
|
|
217
|
+
|
|
218
|
+
//XXX ignore some groups for now, mostly spline
|
|
219
|
+
case 95:
|
|
220
|
+
case 96:
|
|
221
|
+
case 40:
|
|
222
|
+
case 42:
|
|
223
|
+
case 97:
|
|
224
|
+
break;
|
|
225
|
+
default:
|
|
226
|
+
return e
|
|
227
|
+
}
|
|
228
|
+
curr = scanner.next();
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
let polylineParsed = false;
|
|
233
|
+
let numEdges = 0;
|
|
234
|
+
let numSourceRefs = 0;
|
|
235
|
+
|
|
236
|
+
while (true) {
|
|
237
|
+
|
|
238
|
+
if (!entity) {
|
|
239
|
+
if (curr.code != 92) {
|
|
240
|
+
return null
|
|
241
|
+
}
|
|
242
|
+
entity = {
|
|
243
|
+
type: curr.value,
|
|
244
|
+
isExternal: (curr.value & 1) != 0,
|
|
245
|
+
isOutermost: (curr.value & 16) != 0
|
|
246
|
+
}
|
|
247
|
+
curr = scanner.next()
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if ((entity.type & 2) && !polylineParsed) {
|
|
251
|
+
entity.polyline = ParsePolyline()
|
|
252
|
+
polylineParsed = true
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
while (numEdges) {
|
|
256
|
+
const edge = ParseEdge()
|
|
257
|
+
if (edge) {
|
|
258
|
+
entity.edges.push(edge)
|
|
259
|
+
numEdges--
|
|
260
|
+
} else {
|
|
261
|
+
numEdges = 0;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
while (numSourceRefs) {
|
|
266
|
+
if (curr.code == 330) {
|
|
267
|
+
entity.sourceRefs.push(curr.value)
|
|
268
|
+
numSourceRefs--
|
|
269
|
+
curr = scanner.next()
|
|
270
|
+
} else {
|
|
271
|
+
numSourceRefs = 0
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
switch (curr.code) {
|
|
276
|
+
case 93:
|
|
277
|
+
numEdges = curr.value
|
|
278
|
+
if (numEdges > 0) {
|
|
279
|
+
entity.edges = []
|
|
280
|
+
}
|
|
281
|
+
break;
|
|
282
|
+
case 97:
|
|
283
|
+
numSourceRefs = curr.value
|
|
284
|
+
if (numSourceRefs > 0) {
|
|
285
|
+
entity.sourceRefs = []
|
|
286
|
+
}
|
|
287
|
+
break;
|
|
288
|
+
default:
|
|
289
|
+
scanner.rewind()
|
|
290
|
+
return entity
|
|
291
|
+
}
|
|
292
|
+
curr = scanner.next()
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function ParseDefinitionLine(curr, scanner) {
|
|
297
|
+
/* Assuming always starts from group 53. */
|
|
298
|
+
if (curr.code != 53) {
|
|
299
|
+
return null
|
|
300
|
+
}
|
|
301
|
+
const entity = {
|
|
302
|
+
angle: curr.value * Math.PI / 180,
|
|
303
|
+
base: {x: 0, y: 0},
|
|
304
|
+
offset: {x: 0, y: 0}
|
|
305
|
+
};
|
|
306
|
+
curr = scanner.next();
|
|
307
|
+
|
|
308
|
+
let numDashes = 0;
|
|
309
|
+
while (true) {
|
|
310
|
+
switch (curr.code) {
|
|
311
|
+
case 43:
|
|
312
|
+
entity.base.x = curr.value;
|
|
313
|
+
break;
|
|
314
|
+
case 44:
|
|
315
|
+
entity.base.y = curr.value;
|
|
316
|
+
break;
|
|
317
|
+
case 45:
|
|
318
|
+
entity.offset.x = curr.value;
|
|
319
|
+
break;
|
|
320
|
+
case 46:
|
|
321
|
+
entity.offset.y = curr.value;
|
|
322
|
+
break;
|
|
323
|
+
case 49:
|
|
324
|
+
if (numDashes > 0) {
|
|
325
|
+
entity.dashes.push(curr.value);
|
|
326
|
+
numDashes--;
|
|
327
|
+
}
|
|
328
|
+
break;
|
|
329
|
+
case 79:
|
|
330
|
+
numDashes = curr.value;
|
|
331
|
+
if (curr.value) {
|
|
332
|
+
entity.dashes = []
|
|
333
|
+
}
|
|
334
|
+
break;
|
|
335
|
+
default:
|
|
336
|
+
scanner.rewind();
|
|
337
|
+
return entity;
|
|
338
|
+
}
|
|
339
|
+
curr = scanner.next();
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function ParseSeedPoint(curr, scanner) {
|
|
344
|
+
if (curr.code != 10) {
|
|
345
|
+
return null
|
|
346
|
+
}
|
|
347
|
+
return helpers.parsePoint(scanner);
|
|
348
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
|
|
2
|
+
import * as helpers from "../ParseHelpers.js"
|
|
3
|
+
|
|
4
|
+
export default function EntityParser() {}
|
|
5
|
+
|
|
6
|
+
EntityParser.ForEntityName = 'INSERT';
|
|
7
|
+
|
|
8
|
+
EntityParser.prototype.parseEntity = function(scanner, curr) {
|
|
9
|
+
var entity;
|
|
10
|
+
entity = { type: curr.value };
|
|
11
|
+
curr = scanner.next();
|
|
12
|
+
while(curr !== 'EOF') {
|
|
13
|
+
if(curr.code === 0) break;
|
|
14
|
+
|
|
15
|
+
switch(curr.code) {
|
|
16
|
+
case 2:
|
|
17
|
+
entity.name = curr.value;
|
|
18
|
+
break;
|
|
19
|
+
case 41:
|
|
20
|
+
entity.xScale = curr.value;
|
|
21
|
+
break;
|
|
22
|
+
case 42:
|
|
23
|
+
entity.yScale = curr.value;
|
|
24
|
+
break;
|
|
25
|
+
case 43:
|
|
26
|
+
entity.zScale = curr.value;
|
|
27
|
+
break;
|
|
28
|
+
case 10:
|
|
29
|
+
entity.position = helpers.parsePoint(scanner);
|
|
30
|
+
break;
|
|
31
|
+
case 50:
|
|
32
|
+
entity.rotation = curr.value;
|
|
33
|
+
break;
|
|
34
|
+
case 70:
|
|
35
|
+
entity.columnCount = curr.value;
|
|
36
|
+
break;
|
|
37
|
+
case 71:
|
|
38
|
+
entity.rowCount = curr.value;
|
|
39
|
+
break;
|
|
40
|
+
case 44:
|
|
41
|
+
entity.columnSpacing = curr.value;
|
|
42
|
+
break;
|
|
43
|
+
case 45:
|
|
44
|
+
entity.rowSpacing = curr.value;
|
|
45
|
+
break;
|
|
46
|
+
case 210:
|
|
47
|
+
entity.extrusionDirection = helpers.parsePoint(scanner);
|
|
48
|
+
break;
|
|
49
|
+
default: // check common entity attributes
|
|
50
|
+
helpers.checkCommonEntityProperties(entity, curr, scanner);
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
curr = scanner.next();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return entity;
|
|
57
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
import * as helpers from "../ParseHelpers.js"
|
|
3
|
+
|
|
4
|
+
export default function EntityParser() {}
|
|
5
|
+
|
|
6
|
+
EntityParser.ForEntityName = 'LINE';
|
|
7
|
+
|
|
8
|
+
EntityParser.prototype.parseEntity = function(scanner, curr) {
|
|
9
|
+
var entity = { type: curr.value, vertices: [] };
|
|
10
|
+
curr = scanner.next();
|
|
11
|
+
while(curr !== 'EOF') {
|
|
12
|
+
if(curr.code === 0) break;
|
|
13
|
+
|
|
14
|
+
switch(curr.code) {
|
|
15
|
+
case 10: // X coordinate of point
|
|
16
|
+
entity.vertices.unshift(helpers.parsePoint(scanner));
|
|
17
|
+
break;
|
|
18
|
+
case 11:
|
|
19
|
+
entity.vertices.push(helpers.parsePoint(scanner));
|
|
20
|
+
break;
|
|
21
|
+
case 210:
|
|
22
|
+
entity.extrusionDirection = helpers.parsePoint(scanner);
|
|
23
|
+
break;
|
|
24
|
+
case 100:
|
|
25
|
+
break;
|
|
26
|
+
default:
|
|
27
|
+
helpers.checkCommonEntityProperties(entity, curr, scanner);
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
curr = scanner.next();
|
|
32
|
+
}
|
|
33
|
+
return entity;
|
|
34
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
|
|
2
|
+
import * as helpers from "../ParseHelpers.js"
|
|
3
|
+
|
|
4
|
+
export default function EntityParser() {}
|
|
5
|
+
|
|
6
|
+
EntityParser.ForEntityName = 'LWPOLYLINE';
|
|
7
|
+
|
|
8
|
+
EntityParser.prototype.parseEntity = function(scanner, curr) {
|
|
9
|
+
var entity = { type: curr.value, vertices: [] },
|
|
10
|
+
numberOfVertices = 0;
|
|
11
|
+
curr = scanner.next();
|
|
12
|
+
while(curr !== 'EOF') {
|
|
13
|
+
if(curr.code === 0) break;
|
|
14
|
+
|
|
15
|
+
switch(curr.code) {
|
|
16
|
+
case 38:
|
|
17
|
+
entity.elevation = curr.value;
|
|
18
|
+
break;
|
|
19
|
+
case 39:
|
|
20
|
+
entity.depth = curr.value;
|
|
21
|
+
break;
|
|
22
|
+
case 70: // 1 = Closed shape, 128 = plinegen?, 0 = default
|
|
23
|
+
entity.shape = ((curr.value & 1) === 1);
|
|
24
|
+
entity.hasContinuousLinetypePattern = ((curr.value & 128) === 128);
|
|
25
|
+
break;
|
|
26
|
+
case 90:
|
|
27
|
+
numberOfVertices = curr.value;
|
|
28
|
+
break;
|
|
29
|
+
case 10: // X coordinate of point
|
|
30
|
+
entity.vertices = parseLWPolylineVertices(numberOfVertices, scanner);
|
|
31
|
+
break;
|
|
32
|
+
case 43:
|
|
33
|
+
if(curr.value !== 0) entity.width = curr.value;
|
|
34
|
+
break;
|
|
35
|
+
case 210:
|
|
36
|
+
entity.extrusionDirection = helpers.parsePoint(scanner);
|
|
37
|
+
break;
|
|
38
|
+
default:
|
|
39
|
+
helpers.checkCommonEntityProperties(entity, curr, scanner);
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
curr = scanner.next();
|
|
43
|
+
}
|
|
44
|
+
return entity;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
function parseLWPolylineVertices(n, scanner) {
|
|
48
|
+
if(!n || n <= 0) throw Error('n must be greater than 0 vertices');
|
|
49
|
+
var vertices = [], i;
|
|
50
|
+
var vertexIsStarted = false;
|
|
51
|
+
var vertexIsFinished = false;
|
|
52
|
+
var curr = scanner.lastReadGroup;
|
|
53
|
+
|
|
54
|
+
for(i = 0; i < n; i++) {
|
|
55
|
+
var vertex = {};
|
|
56
|
+
while(curr !== 'EOF') {
|
|
57
|
+
if(curr.code === 0 || vertexIsFinished) break;
|
|
58
|
+
|
|
59
|
+
switch(curr.code) {
|
|
60
|
+
case 10: // X
|
|
61
|
+
if(vertexIsStarted) {
|
|
62
|
+
vertexIsFinished = true;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
vertex.x = curr.value;
|
|
66
|
+
vertexIsStarted = true;
|
|
67
|
+
break;
|
|
68
|
+
case 20: // Y
|
|
69
|
+
vertex.y = curr.value;
|
|
70
|
+
break;
|
|
71
|
+
case 30: // Z
|
|
72
|
+
vertex.z = curr.value;
|
|
73
|
+
break;
|
|
74
|
+
case 40: // start width
|
|
75
|
+
vertex.startWidth = curr.value;
|
|
76
|
+
break;
|
|
77
|
+
case 41: // end width
|
|
78
|
+
vertex.endWidth = curr.value;
|
|
79
|
+
break;
|
|
80
|
+
case 42: // bulge
|
|
81
|
+
if(curr.value != 0) vertex.bulge = curr.value;
|
|
82
|
+
break;
|
|
83
|
+
case 91: // vertex identifier
|
|
84
|
+
vertex.id = curr.value;
|
|
85
|
+
break;
|
|
86
|
+
default:
|
|
87
|
+
// if we do not hit known code return vertices. Code might belong to entity
|
|
88
|
+
if (vertexIsStarted) {
|
|
89
|
+
vertices.push(vertex);
|
|
90
|
+
}
|
|
91
|
+
scanner.rewind();
|
|
92
|
+
return vertices;
|
|
93
|
+
}
|
|
94
|
+
curr = scanner.next();
|
|
95
|
+
}
|
|
96
|
+
// See https://groups.google.com/forum/#!topic/comp.cad.autocad/9gn8s5O_w6E
|
|
97
|
+
vertices.push(vertex);
|
|
98
|
+
vertexIsStarted = false;
|
|
99
|
+
vertexIsFinished = false;
|
|
100
|
+
}
|
|
101
|
+
scanner.rewind();
|
|
102
|
+
return vertices;
|
|
103
|
+
};
|