-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathuse_xyz.go
60 lines (51 loc) · 1.23 KB
/
use_xyz.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
// +build use_xyz
package clipper
import "fmt"
type IntPoint struct {
X CInt
Y CInt
Z CInt
}
func (p *IntPoint) String() string {
return fmt.Sprintf("{%v, %v}", p.X, p.Y)
}
func NewIntPoint(X, Y, Z CInt) *IntPoint {
ip := new(IntPoint)
ip.X, ip.Y, ip.Z = X, Y, Z
return ip
}
func NewIntPointFromFloat(x, y, z float64) *IntPoint {
ip := new(IntPoint)
ip.X, ip.Y = CInt(x), CInt(y), CInt(z)
return ip
}
func (ip *IntPoint) Copy() IntPoint {
return IntPoint{
X: ip.X,
Y: ip.Y,
Z: ip.Z,
}
}
func (c *ClipperBase) ReverseHorizontal(e *TEdge) {
//swap horizontal edges' top and bottom x's so they follow the natural
//progression of the bounds - ie so their xbots will align with the
//adjoining lower edge. [Helpful in the ProcessHorizontal() method.]
Swap(&e.Top.X, &e.Bot.X)
Swap(&e.Top.Z, &e.Bot.Z)
}
func (c *Clipper) SetZ(pt *IntPoint, e1, e2 *TEdge) {
if pt.Z != 0 || ZFillFunction == nil {
return
} else if pt == e1.Bot {
pt.Z = e1.Bot.Z
} else if pt == e1.Top {
pt.Z = e1.Top.Z
} else if pt == e2.Bot {
pt.Z = e2.Bot.Z
} else if pt == e2.Top {
pt.Z = e2.Top.Z
} else {
c.ZFillFunction(e1.Bot, e1.Top, e2.Bot, e2.Top, &pt)
}
}
//------------------------------------------------------------------------------