1
2 /*
3
4 Reads in a gds2cds.map file and produces a first cut layers.config
5 file.
6
7 gds2cds.map file format:
8
9 layername layerfeaturename layernumber layerfeaturenumber
10
11 Optional whitespace everywhere
12
13 By default, I am now making all layers hidden.
14
15
16 -----------------
17
18
19 */
20
21 #include <stdio.h>
22
23
24
25
26
27
convfile(FILE * infile,FILE * outfile)28 int convfile(FILE *infile, FILE *outfile)
29 {
30 char lna[100],lfna[100];
31 int layn,layfn,rc,i,red,green,blue;
32 int layermap[256];
33 for(i=0;i<256;i++) layermap[i]=0;
34 while (!feof(infile)) {
35 if ((rc=fscanf(infile," %s %s %d %d ",lna,lfna,&layn,&layfn))!=4) {
36 fprintf(stderr,"ERROR: incomplete read.");
37 exit(1);
38 }
39 if (layermap[layn]==0) {
40 /* Assume a 64 color space, 4^3, so 4 reds 4 blues 4 greens */
41 /* Reserve black and white. That gives 1/5th */
42 red = layn / 16 ; /* 0..3 */
43 green = (layn - ( red * 16 )) / 4 ; /* 0..3 */
44 blue = layn - red*16 - green*4 ;
45 fprintf(outfile,
46 "newlayer\n"
47 " gdsno %d\n"
48 " hidden %s\n"
49 " name %s\n"
50 " red %1.1f\n"
51 " green %2.1f\n"
52 " blue %.1f\n",layn,"yes",lna,0.2+0.2*(float)red ,
53 0.2+0.2*(float)green,0.2+0.2*(float)blue);
54 fprintf(outfile,
55 " fill %s\n"
56 /* ,"no"); */
57
58 " hatch %s\n"
59 " angle %.1f\n"
60 " step %.1f\n"
61 " thickness %f\n"
62 " depth %f\n"
63 ,"no","cross",45.0,3.0,0.1,0.1*(float)layn);
64
65 fprintf(outfile,"endlayer\n\n");
66
67 layermap[layn]=1;
68 }
69 }
70
71
72
73 return(0);
74 }
75
76
77
78
79
80
81
82
main(int argc,char * argv[])83 int main(int argc,char *argv[])
84 {
85
86
87 convfile(stdin,stdout);
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108 return(0);
109 }
110