FreeCalypso > hg > ueda-linux
comparison pads2gpcb/decals.c @ 54:a930e05cf908
pads2gpcb/decals.c: silk circle extraction implemented
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Sun, 31 Jan 2016 01:57:38 +0000 |
parents | 0e18818206e5 |
children | e93375570f91 |
comparison
equal
deleted
inserted
replaced
53:0e18818206e5 | 54:a930e05cf908 |
---|---|
116 } | 116 } |
117 | 117 |
118 static | 118 static |
119 try_silk_circle() | 119 try_silk_circle() |
120 { | 120 { |
121 return(0); | 121 int i, bad; |
122 long x[2], y[2]; | |
123 long centre_x, centre_y, diameter, thickness; | |
124 | |
125 if (strcmp(input_line_fields[0], "CIRCLE")) | |
126 return(0); | |
127 if (input_line_nfields != 5) | |
128 return(0); | |
129 if (strcmp(input_line_fields[4], "0")) | |
130 return(0); | |
131 if (strcmp(input_line_fields[1], "2")) { | |
132 printf("line %d: silk CIRCLE piece ncoord != 2\n", | |
133 input_lineno); | |
134 return(0); | |
135 } | |
136 thickness = convert_input_dim(input_line_fields[2]); | |
137 | |
138 bad = 0; | |
139 for (i = 0; i < 2; i++) { | |
140 get_line_internal(); | |
141 parse_input_line_fields(); | |
142 if (input_line_nfields != 2) { | |
143 printf("line %d: silk CIRCLE coord not 2 numbers\n", | |
144 input_lineno); | |
145 bad = 1; | |
146 continue; | |
147 } | |
148 x[i] = convert_input_dim(input_line_fields[0]); | |
149 y[i] = -convert_input_dim(input_line_fields[1]); | |
150 } | |
151 if (bad) | |
152 return(1); | |
153 | |
154 /* find the centre and diameter */ | |
155 if (x[0] == x[1]) { | |
156 centre_x = x[0]; | |
157 if (y[0] < y[1]) { | |
158 diameter = y[1] - y[0]; | |
159 centre_y = y[0] + diameter / 2; | |
160 } else if (y[1] < y[0]) { | |
161 diameter = y[0] - y[1]; | |
162 centre_y = y[1] + diameter / 2; | |
163 } else | |
164 goto centre_diam_fail; | |
165 } else if (y[0] == y[1]) { | |
166 centre_y = y[0]; | |
167 if (x[0] < x[1]) { | |
168 diameter = x[1] - x[0]; | |
169 centre_x = x[0] + diameter / 2; | |
170 } else if (x[1] < x[0]) { | |
171 diameter = x[0] - x[1]; | |
172 centre_x = x[1] + diameter / 2; | |
173 } else | |
174 goto centre_diam_fail; | |
175 } else { | |
176 centre_diam_fail: | |
177 printf("line %d: unable to find circle centre and diameter\n", | |
178 input_lineno); | |
179 return(1); | |
180 } | |
181 if (diameter % 2) | |
182 printf("warning: line %d: circle diameter in nm is odd!\n", | |
183 input_lineno); | |
184 | |
185 if (num_silk_arcs >= MAX_SILK_LINES) { | |
186 printf("Too many silk arcs!\n"); | |
187 return(1); | |
188 } | |
189 silk_arcs[num_silk_arcs].centre_x = centre_x; | |
190 silk_arcs[num_silk_arcs].centre_y = centre_y; | |
191 silk_arcs[num_silk_arcs].width = diameter; | |
192 silk_arcs[num_silk_arcs].height = diameter; | |
193 silk_arcs[num_silk_arcs].start_angle = 0; | |
194 silk_arcs[num_silk_arcs].delta_angle = 360; | |
195 silk_arcs[num_silk_arcs].thickness = thickness; | |
196 return(1); | |
122 } | 197 } |
123 | 198 |
124 static void | 199 static void |
125 one_drawing_piece() | 200 one_drawing_piece() |
126 { | 201 { |