-
Notifications
You must be signed in to change notification settings - Fork 12
/
main.go
33 lines (28 loc) · 816 Bytes
/
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
package main
import (
"log"
"os"
"path/filepath"
"github.com/unixpickle/essentials"
"github.com/unixpickle/model3d/model3d"
)
const OutputDir = "models"
func main() {
CreateMeshFile("propeller.stl", PropellerMesh)
CreateMeshFile("spine.stl", SpineMesh)
CreateMeshFile("small_gear.stl", SmallGearMesh)
CreateMeshFile("crank_gear.stl", CrankGearMesh)
CreateMeshFile("crank_bolt.stl", CrankBoltMesh)
}
func CreateMeshFile(name string, f func() *model3d.Mesh) {
if _, err := os.Stat(OutputDir); os.IsNotExist(err) {
essentials.Must(os.Mkdir(OutputDir, 0755))
}
outPath := filepath.Join(OutputDir, name)
if _, err := os.Stat(outPath); os.IsNotExist(err) {
log.Println("Creating mesh for", name, "...")
mesh := f()
log.Println("Saving mesh for", name, "...")
mesh.SaveGroupedSTL(outPath)
}
}