-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
59 lines (40 loc) · 1.06 KB
/
main.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
package main
import (
"fmt"
"main/geom"
"main/io"
"main/repair"
)
func main() {
//m := io.ReadBinarySTL("stls/teapot_hole.stl")
//io.WriteToOBJ(m, "objs/teapot_hole.obj")
m, _ := io.ReadObj("objs/teapot_hole.obj")
//repair.WriteToOBJ(m, "teapot_deleted.obj")
m = repair.RemoveSelfIntersections(m, false, true)
io.WriteToOBJ(m, "results/removed_self_intersections.obj")
vertices := m.V
faces := []geom.Face{}
face := geom.Face{}
for i, idx := range m.T {
face = append(face, int(idx))
if (i+1)%3 == 0 {
faces = append(faces, face)
face = geom.Face{}
}
}
loops := repair.FindBorders(m)
fmt.Println("number of loops: ", len(loops))
newTriangles := []uint32{}
for _, loop := range loops {
holeTriangles := repair.FillHoleLiepa(vertices, faces, loop, "angle")
faces = append(faces, holeTriangles...)
for i := range faces {
for j := range faces[i] {
newTriangles = append(newTriangles, uint32(faces[i][j]))
}
}
}
m.T = newTriangles
io.WriteToOBJ(m, "results/hole_filled.obj")
fmt.Println("succesfully filled hole")
}