package main import ( "fmt" "os" "testing" ) func TestShapeExtraction(t *testing.T) { files := []string{ "temp/3efe010e39240608501455e800058a3f_EIS4-F_Cu.gbr", "temp/3efe010e39240608501455e800058a3f_EIS4-F_Silkscreen.gbr", "temp/3efe010e39240608501455e800058a3f_EIS4-F_Paste.gbr", "temp/3efe010e39240608501455e800058a3f_EIS4-F_Fab.gbr", "temp/3efe010e39240608501455e800058a3f_EIS4-User_Drawings.gbr", } for _, f := range files { if _, err := os.Stat(f); err != nil { continue } gf, err := ParseGerber(f) if err != nil { fmt.Printf("%s: parse error: %v\n", f, err) continue } bounds := gf.CalculateBounds() elems := ExtractElementBBoxes(gf, 508, &bounds) shapes := map[string]int{} types := map[string]int{} for _, e := range elems { shapes[e.Shape]++ types[e.Type]++ } fmt.Printf("%s: %d elements, shapes=%v types=%v\n", f, len(elems), shapes, types) count := 0 for _, e := range elems { if e.Type == "pad" && count < 5 { fmt.Printf(" pad id=%d shape=%s footprint=%s w=%.1f h=%.1f\n", e.ID, e.Shape, e.Footprint, e.MaxX-e.MinX, e.MaxY-e.MinY) count++ } } } }