-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdebug.go
31 lines (23 loc) · 994 Bytes
/
debug.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
package martinez_rueda
import "fmt"
func gatherSweepEventData(event SweepEvent) string {
return fmt.Sprintf("index:%v is_left:%v x:%v y:%v other[x:%v y:%v]", event.id, event.isLeft, event.p.X(), event.p.Y(), event.other.p.X(), event.other.p.Y())
}
func gatherConnectorData(connector Connector) string {
open_polygons := []string{}
closed_polygons := []string{}
for _, open := range connector.openPolygons {
open_polygons = append(open_polygons, gatherPointChainData(*open))
}
for _, clo := range connector.closedPolygons {
closed_polygons = append(closed_polygons, gatherPointChainData(*clo))
}
return fmt.Sprintf("closed:%v open_polygons:%v closed_polygons:%v", connector.isClosed(), open_polygons, closed_polygons)
}
func gatherPointChainData(chain PointChain) string {
points := []string{}
for _, seg := range chain.segments {
points = append(points, fmt.Sprintf("x:%v y:%v", seg.X(), seg.Y()))
}
return fmt.Sprintf("closed:%v elements:%v", chain.closed, points)
}