-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathburning_data.go
65 lines (58 loc) · 1.19 KB
/
burning_data.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
package gen
import (
"bufio"
"strconv"
"strings"
)
type BurningData struct {
Shape string
StartEndInGap string
BevelDefined string
Direction int
Designation string
PartID int
NumberOfHeads int
GeometryValidFor int
DistanceY1Y2 float64
GeometryData *GeometryData
Contour *Contour
}
func readBurningData(s *bufio.Scanner) *BurningData {
b := new(BurningData)
next:
for s.Scan() {
k, v, ok := strings.Cut(s.Text(), "=")
switch k {
case "GEOMETRY_DATA":
b.GeometryData = readGeometryData(s)
continue next
case "START_OF_CONTOUR":
b.Contour = readContour(s)
continue next
}
if !ok {
break
}
switch k {
case "SHAPE":
b.Shape = v
case "START_END_IN_GAP":
b.StartEndInGap = v
case "BEVEL_DEFINED":
b.BevelDefined = v
case "DIRECTION":
b.Direction, _ = strconv.Atoi(v)
case "DESIGNATION":
b.Designation = v
case "PART_ID":
b.PartID, _ = strconv.Atoi(v)
case "NUMBER_OF_HEADS":
b.NumberOfHeads, _ = strconv.Atoi(v)
case "GEOMETRY_VALID_FOR":
b.GeometryValidFor, _ = strconv.Atoi(v)
case "DISTANCE_Y1_Y2":
b.DistanceY1Y2, _ = strconv.ParseFloat(v, 64)
}
}
return b
}