/
check.go
46 lines (34 loc) · 939 Bytes
/
check.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
//
// Copyright (c) 2020 Jason S. McMullan <jason.mcmullan@gmail.com>
//
package main
import (
"fmt"
"github.com/ezrec/uv3dp"
)
type checkModifier struct {
uv3dp.Printable
}
func (mod *checkModifier) LayerZ(index int) (z float32) {
z = mod.Printable.LayerZ(index)
if z < 0.001 {
panic(fmt.Sprintf("Layer %d: Z value of %.02fmm is too close to the screen", index, z))
}
if index > 0 {
prev_z := mod.Printable.LayerZ(index - 1)
if z < prev_z {
panic(fmt.Sprintf("Layer %d: Z value of %.02fmm is below the previous layer at %.02fmm", index, z, prev_z))
}
nominal_dz := mod.Printable.Size().LayerHeight
if (z - prev_z) > nominal_dz*1.5 {
panic(fmt.Sprintf("Layer %d: Layer height of %.02fmm is too far from nominal of %.02fmm", index, z-prev_z, nominal_dz))
}
}
return
}
func CheckFilter(input uv3dp.Printable) (mod uv3dp.Printable, err error) {
mod = &checkModifier{
Printable: input,
}
return
}