-
Notifications
You must be signed in to change notification settings - Fork 1
/
end.go
439 lines (342 loc) · 10.7 KB
/
end.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
package gen
import (
"bufio"
"strconv"
"strings"
)
type End struct {
LeftOrigin float64
LeftClosestPoint float64
LeftFarthestPoint float64
LeftV0 float64
LeftClosestPointWeb float64
LeftFarthestPointWeb float64
BurnEcut int
Stoss int
FabricationExcess float64
EndcutType int
EndcutMask string
EndcutCode int
A float64
B float64
C float64
R1 float64
R2 float64
V1 float64
V2 float64
V3 float64
V4 float64
Ks float64
Excess float64
BevelDefined int
BevelCode int
BevelName string
BevelType int
BevelVariant int
E float64
Gap float64
Chamfer float64
ChamferTs float64
ChamferOs float64
Alpha float64
Beta float64
Nose float64
H float64
HFact float64
HFactAdjust float64
AngleTs float64
AngleOs float64
DepthTs float64
DepthOs float64
ChamferWidthTs float64
ChamferWidthOs float64
ChamferHeightTs float64
ChamferHeightOs float64
ConnectionAngle float64
WebSeg float64
BevelDefinedFlange float64
BevelCodeFlange float64
BevelNameFlange string
BevelTypeFlange float64
BevelVariantFlange float64
EFlange float64
GapFlange float64
ChamferFlange float64
ChamferTsFlange float64
ChamferOsFlange float64
AlphaFlange float64
BetaFlange float64
NoseFlange float64
HFlange float64
HFactFlange float64
HFactAdjustFlange float64
AngleTsFlange float64
AngleOsFlange float64
DepthTsFlange float64
DepthOsFlange float64
ChamferWidthTsFlange float64
ChamferWidthOsFlange float64
ChamferHeightTsFlange float64
ChamferHeightOsFlange float64
ConnectionAngleFlange float64
FlaSeg float64
BevelDefinedFlange2 float64
BevelCodeFlange2 float64
BevelNameFlange2 string
BevelTypeFlange2 float64
BevelVariantFlange2 float64
EFlange2 float64
GapFlange2 float64
ChamferFlange2 float64
ChamferTsFlange2 float64
ChamferOsFlange2 float64
AlphaFlange2 float64
BetaFlange2 float64
NoseFlange2 float64
HFlange2 float64
HFactFlange2 float64
HFactAdjustFlange2 float64
AngleTsFlange2 float64
AngleOsFlange2 float64
DepthTsFlange2 float64
DepthOsFlange2 float64
ChamferWidthTsFlange2 float64
ChamferWidthOsFlange2 float64
ChamferHeightTsFlange2 float64
ChamferHeightOsFlange2 float64
Fla2Seg float64
Gsd float64
GsdDist float64
Contour *Contour
FContour *Contour
}
func readEnd(s *bufio.Scanner) *End {
e := new(End)
bevelNamesFound := 0
next:
for s.Scan() {
k, v, ok := strings.Cut(s.Text(), "=")
switch k {
case "START_OF_CONTOUR":
e.Contour = readContour(s)
continue next
case "START_OF_FCONTOUR":
e.FContour = readContour(s)
continue next
}
if !ok {
break
}
switch k {
case "LEFT_ORIGIN":
e.LeftOrigin, _ = strconv.ParseFloat(v, 64)
case "LEFT_CLOSEST_POINT":
e.LeftClosestPoint, _ = strconv.ParseFloat(v, 64)
case "LEFT_FARTHEST_POINT":
e.LeftFarthestPoint, _ = strconv.ParseFloat(v, 64)
case "LEFT_V0":
e.LeftV0, _ = strconv.ParseFloat(v, 64)
case "LEFT_CLOSEST_POINT_WEB":
e.LeftClosestPointWeb, _ = strconv.ParseFloat(v, 64)
case "LEFT_FARTHEST_POINT_WEB":
e.LeftFarthestPointWeb, _ = strconv.ParseFloat(v, 64)
case "BURN_ECUT":
e.BurnEcut, _ = strconv.Atoi(v)
case "STOSS":
e.Stoss, _ = strconv.Atoi(v)
case "FABRICATION_EXCESS":
e.FabricationExcess, _ = strconv.ParseFloat(v, 64)
case "ENDCUT_TYPE":
e.EndcutType, _ = strconv.Atoi(v)
case "ENDCUT_MASK":
e.EndcutMask = v
case "ENDCUT_CODE":
e.EndcutCode, _ = strconv.Atoi(v)
case "A":
e.A, _ = strconv.ParseFloat(v, 64)
case "B":
e.B, _ = strconv.ParseFloat(v, 64)
case "C":
e.C, _ = strconv.ParseFloat(v, 64)
case "R1":
e.R1, _ = strconv.ParseFloat(v, 64)
case "R2":
e.R2, _ = strconv.ParseFloat(v, 64)
case "V1":
e.V1, _ = strconv.ParseFloat(v, 64)
case "V2":
e.V2, _ = strconv.ParseFloat(v, 64)
case "V3":
e.V3, _ = strconv.ParseFloat(v, 64)
case "V4":
e.V4, _ = strconv.ParseFloat(v, 64)
case "KS":
e.Ks, _ = strconv.ParseFloat(v, 64)
case "EXCESS":
e.Excess, _ = strconv.ParseFloat(v, 64)
case "BEVEL_DEFINED":
e.BevelDefined, _ = strconv.Atoi(v)
case "BEVEL_CODE":
e.BevelCode, _ = strconv.Atoi(v)
case "BEVEL_TYPE":
e.BevelType, _ = strconv.Atoi(v)
case "BEVEL_VARIANT":
e.BevelVariant, _ = strconv.Atoi(v)
case "E":
e.E, _ = strconv.ParseFloat(v, 64)
case "GAP":
e.Gap, _ = strconv.ParseFloat(v, 64)
case "CHAMFER":
e.Chamfer, _ = strconv.ParseFloat(v, 64)
case "CHAMFER_TS":
e.ChamferTs, _ = strconv.ParseFloat(v, 64)
case "CHAMFER_OS":
e.ChamferOs, _ = strconv.ParseFloat(v, 64)
case "ALPHA":
e.Alpha, _ = strconv.ParseFloat(v, 64)
case "BETA":
e.Beta, _ = strconv.ParseFloat(v, 64)
case "NOSE":
e.Nose, _ = strconv.ParseFloat(v, 64)
case "H":
e.H, _ = strconv.ParseFloat(v, 64)
case "H_FACT":
e.HFact, _ = strconv.ParseFloat(v, 64)
case "H_FACT_ADJUST":
e.HFactAdjust, _ = strconv.ParseFloat(v, 64)
case "ANGLE_TS":
e.AngleTs, _ = strconv.ParseFloat(v, 64)
case "ANGLE_OS":
e.AngleOs, _ = strconv.ParseFloat(v, 64)
case "DEPTH_TS":
e.DepthTs, _ = strconv.ParseFloat(v, 64)
case "DEPTH_OS":
e.DepthOs, _ = strconv.ParseFloat(v, 64)
case "CHAMFER_WIDTH_TS":
e.ChamferWidthTs, _ = strconv.ParseFloat(v, 64)
case "CHAMFER_WIDTH_OS":
e.ChamferWidthOs, _ = strconv.ParseFloat(v, 64)
case "CHAMFER_HEIGHT_TS":
e.ChamferHeightTs, _ = strconv.ParseFloat(v, 64)
case "CHAMFER_HEIGHT_OS":
e.ChamferHeightOs, _ = strconv.ParseFloat(v, 64)
case "CONNECTION_ANGLE":
e.ConnectionAngle, _ = strconv.ParseFloat(v, 64)
case "WEB_SEG":
e.WebSeg, _ = strconv.ParseFloat(v, 64)
case "BEVEL_DEFINED_FLANGE":
e.BevelDefinedFlange, _ = strconv.ParseFloat(v, 64)
case "BEVEL_CODE_FLANGE":
e.BevelCodeFlange, _ = strconv.ParseFloat(v, 64)
case "BEVEL_NAME":
switch bevelNamesFound {
case 0:
e.BevelName = v
case 1:
e.BevelNameFlange = v
case 2:
e.BevelNameFlange2 = v
}
bevelNamesFound++
case "BEVEL_TYPE_FLANGE":
e.BevelTypeFlange, _ = strconv.ParseFloat(v, 64)
case "BEVEL_VARIANT_FLANGE":
e.BevelVariantFlange, _ = strconv.ParseFloat(v, 64)
case "E_FLANGE":
e.EFlange, _ = strconv.ParseFloat(v, 64)
case "GAP_FLANGE":
e.GapFlange, _ = strconv.ParseFloat(v, 64)
case "CHAMFER_FLANGE":
e.ChamferFlange, _ = strconv.ParseFloat(v, 64)
case "CHAMFER_TS_FLANGE":
e.ChamferTsFlange, _ = strconv.ParseFloat(v, 64)
case "CHAMFER_OS_FLANGE":
e.ChamferOsFlange, _ = strconv.ParseFloat(v, 64)
case "ALPHA_FLANGE":
e.AlphaFlange, _ = strconv.ParseFloat(v, 64)
case "BETA_FLANGE":
e.BetaFlange, _ = strconv.ParseFloat(v, 64)
case "NOSE_FLANGE":
e.NoseFlange, _ = strconv.ParseFloat(v, 64)
case "H_FLANGE":
e.HFlange, _ = strconv.ParseFloat(v, 64)
case "H_FACT_FLANGE":
e.HFactFlange, _ = strconv.ParseFloat(v, 64)
case "H_FACT_ADJUST_FLANGE":
e.HFactAdjustFlange, _ = strconv.ParseFloat(v, 64)
case "ANGLE_TS_FLANGE":
e.AngleTsFlange, _ = strconv.ParseFloat(v, 64)
case "ANGLE_OS_FLANGE":
e.AngleOsFlange, _ = strconv.ParseFloat(v, 64)
case "DEPTH_TS_FLANGE":
e.DepthTsFlange, _ = strconv.ParseFloat(v, 64)
case "DEPTH_OS_FLANGE":
e.DepthOsFlange, _ = strconv.ParseFloat(v, 64)
case "CHAMFER_WIDTH_TS_FLANGE":
e.ChamferWidthTsFlange, _ = strconv.ParseFloat(v, 64)
case "CHAMFER_WIDTH_OS_FLANGE":
e.ChamferWidthOsFlange, _ = strconv.ParseFloat(v, 64)
case "CHAMFER_HEIGHT_TS_FLANGE":
e.ChamferHeightTsFlange, _ = strconv.ParseFloat(v, 64)
case "CHAMFER_HEIGHT_OS_FLANGE":
e.ChamferHeightOsFlange, _ = strconv.ParseFloat(v, 64)
case "CONNECTION_ANGLE_FLANGE":
e.ConnectionAngleFlange, _ = strconv.ParseFloat(v, 64)
case "FLA_SEG":
e.FlaSeg, _ = strconv.ParseFloat(v, 64)
case "BEVEL_DEFINED_FLANGE2":
e.BevelDefinedFlange2, _ = strconv.ParseFloat(v, 64)
case "BEVEL_CODE_FLANGE2":
e.BevelCodeFlange2, _ = strconv.ParseFloat(v, 64)
case "BEVEL_TYPE_FLANGE2":
e.BevelTypeFlange2, _ = strconv.ParseFloat(v, 64)
case "BEVEL_VARIANT_FLANGE2":
e.BevelVariantFlange2, _ = strconv.ParseFloat(v, 64)
case "E_FLANGE2":
e.EFlange2, _ = strconv.ParseFloat(v, 64)
case "GAP_FLANGE2":
e.GapFlange2, _ = strconv.ParseFloat(v, 64)
case "CHAMFER_FLANGE2":
e.ChamferFlange2, _ = strconv.ParseFloat(v, 64)
case "CHAMFER_TS_FLANGE2":
e.ChamferTsFlange2, _ = strconv.ParseFloat(v, 64)
case "CHAMFER_OS_FLANGE2":
e.ChamferOsFlange2, _ = strconv.ParseFloat(v, 64)
case "ALPHA_FLANGE2":
e.AlphaFlange2, _ = strconv.ParseFloat(v, 64)
case "BETA_FLANGE2":
e.BetaFlange2, _ = strconv.ParseFloat(v, 64)
case "NOSE_FLANGE2":
e.NoseFlange2, _ = strconv.ParseFloat(v, 64)
case "H_FLANGE2":
e.HFlange2, _ = strconv.ParseFloat(v, 64)
case "H_FACT_FLANGE2":
e.HFactFlange2, _ = strconv.ParseFloat(v, 64)
case "H_FACT_ADJUST_FLANGE2":
e.HFactAdjustFlange2, _ = strconv.ParseFloat(v, 64)
case "ANGLE_TS_FLANGE2":
e.AngleTsFlange2, _ = strconv.ParseFloat(v, 64)
case "ANGLE_OS_FLANGE2":
e.AngleOsFlange2, _ = strconv.ParseFloat(v, 64)
case "DEPTH_TS_FLANGE2":
e.DepthTsFlange2, _ = strconv.ParseFloat(v, 64)
case "DEPTH_OS_FLANGE2":
e.DepthOsFlange2, _ = strconv.ParseFloat(v, 64)
case "CHAMFER_WIDTH_TS_FLANGE2":
e.ChamferWidthTsFlange2, _ = strconv.ParseFloat(v, 64)
case "CHAMFER_WIDTH_OS_FLANGE2":
e.ChamferWidthOsFlange2, _ = strconv.ParseFloat(v, 64)
case "CHAMFER_HEIGHT_TS_FLANGE2":
e.ChamferHeightTsFlange2, _ = strconv.ParseFloat(v, 64)
case "CHAMFER_HEIGHT_OS_FLANGE2":
e.ChamferHeightOsFlange2, _ = strconv.ParseFloat(v, 64)
case "FLA2_SEG":
e.Fla2Seg, _ = strconv.ParseFloat(v, 64)
case "GSD":
e.Gsd, _ = strconv.ParseFloat(v, 64)
case "GSD_DIST":
e.GsdDist, _ = strconv.ParseFloat(v, 64)
}
}
return e
}