-
Notifications
You must be signed in to change notification settings - Fork 1
/
hole.go
68 lines (53 loc) · 1.12 KB
/
hole.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
package gen
import (
"bufio"
"strconv"
"strings"
)
type Hole struct {
Open int
DistOrigin float64
DistOriginToZeroP float64
DistOriginV float64
Type int
Rotation float64
Mirror int
Name string
DistLeft float64
Contour *Contour
}
func readHolesNotchesCutouts(s *bufio.Scanner) *Hole {
h := new(Hole)
next:
for s.Scan() {
k, v, ok := strings.Cut(s.Text(), "=")
if k == "START_OF_CONTOUR" {
h.Contour = readContour(s)
continue next
}
if !ok {
break
}
switch k {
case "OPEN":
h.Open, _ = strconv.Atoi(v)
case "DIST_ORIGIN":
h.DistOrigin, _ = strconv.ParseFloat(v, 64)
case "DIST_ORIGIN_TO_ZEROP":
h.DistOriginToZeroP, _ = strconv.ParseFloat(v, 64)
case "DIST_ORIGIN_V":
h.DistOriginV, _ = strconv.ParseFloat(v, 64)
case "TYPE":
h.Type, _ = strconv.Atoi(v)
case "ROTATION":
h.Rotation, _ = strconv.ParseFloat(v, 64)
case "MIRROR":
h.Mirror, _ = strconv.Atoi(v)
case "NAME":
h.Name = v
case "DIST_LEFT":
h.DistLeft, _ = strconv.ParseFloat(v, 64)
}
}
return h
}