39 #define DPRINTF(...) do { if (DEBUG) printf(__VA_ARGS__); } while (0)
49 gerbv_aperture_list_t *aperture_list;
50 gerbv_aperture_list_t *D_code_list;
60 GERB_FATAL_ERROR(
"malloc error_list failed in %s()", __FUNCTION__);
64 aperture_list = gerbv_stats_new_aperture_list();
65 if (aperture_list == NULL)
66 GERB_FATAL_ERROR(
"malloc aperture_list failed in %s()", __FUNCTION__);
67 stats->aperture_list = (gerbv_aperture_list_t *) aperture_list;
70 D_code_list = gerbv_stats_new_aperture_list();
71 if (D_code_list == NULL)
72 GERB_FATAL_ERROR(
"malloc D_code_list failed in %s()", __FUNCTION__);
73 stats->D_code_list = (gerbv_aperture_list_t *) D_code_list;
83 tempError = nextError->next;
84 g_free (nextError->error_text);
86 nextError = tempError;
91 gerbv_destroy_aperture_list (gerbv_aperture_list_t *apertureList) {
92 gerbv_aperture_list_t *nextAperture=apertureList,*tempAperture;
94 while (nextAperture) {
95 tempAperture = nextAperture->next;
96 g_free (nextAperture);
97 nextAperture = tempAperture;
106 gerbv_destroy_error_list (stats->error_list);
107 gerbv_destroy_aperture_list (stats->aperture_list);
108 gerbv_destroy_aperture_list (stats->D_code_list);
125 DPRINTF(
"---> Entering gerbv_stats_add_layer ... \n");
128 gerbv_aperture_list_t *aperture;
129 gerbv_aperture_list_t *D_code;
131 accum_stats->layer_count++;
132 accum_stats->G0 += input_stats->G0;
133 accum_stats->G1 += input_stats->G1;
134 accum_stats->G2 += input_stats->G2;
135 accum_stats->G3 += input_stats->G3;
136 accum_stats->G4 += input_stats->G4;
137 accum_stats->G10 += input_stats->G10;
138 accum_stats->G11 += input_stats->G11;
139 accum_stats->G12 += input_stats->G12;
140 accum_stats->G36 += input_stats->G36;
141 accum_stats->G37 += input_stats->G37;
142 accum_stats->G54 += input_stats->G54;
143 accum_stats->G55 += input_stats->G55;
144 accum_stats->G70 += input_stats->G70;
145 accum_stats->G71 += input_stats->G71;
146 accum_stats->G74 += input_stats->G74;
147 accum_stats->G75 += input_stats->G75;
148 accum_stats->G90 += input_stats->G90;
149 accum_stats->G91 += input_stats->G91;
150 accum_stats->G_unknown += input_stats->G_unknown;
152 accum_stats->D1 += input_stats->D1;
153 accum_stats->D2 += input_stats->D2;
154 accum_stats->D3 += input_stats->D3;
156 for (D_code = input_stats->D_code_list;
158 D_code = D_code->next) {
159 if (D_code->number != -1) {
160 DPRINTF(
" .... In gerbv_stats_add_layer, D code section, adding number = %d to accum_stats D list ...\n",
162 gerbv_stats_add_to_D_list(accum_stats->D_code_list,
164 DPRINTF(
" .... In gerbv_stats_add_layer, D code section, calling increment_D_count with count %d ...\n",
166 gerbv_stats_increment_D_list_count(accum_stats->D_code_list,
169 accum_stats->error_list);
172 accum_stats->D_unknown += input_stats->D_unknown;
173 accum_stats->D_error += input_stats->D_error;
175 accum_stats->M0 += input_stats->M0;
176 accum_stats->M1 += input_stats->M1;
177 accum_stats->M2 += input_stats->M2;
178 accum_stats->M_unknown += input_stats->M_unknown;
180 accum_stats->X += input_stats->X;
181 accum_stats->Y += input_stats->Y;
182 accum_stats->I += input_stats->I;
183 accum_stats->J += input_stats->J;
185 accum_stats->star += input_stats->star;
186 accum_stats->unknown += input_stats->unknown;
189 for (error = input_stats->error_list;
191 error = error->next) {
192 if (error->error_text != NULL) {
193 gerbv_stats_add_error(accum_stats->error_list,
201 for (aperture = input_stats->aperture_list;
203 aperture = aperture->next) {
204 if (aperture->number != -1) {
205 gerbv_stats_add_aperture(accum_stats->aperture_list,
209 aperture->parameter);
213 DPRINTF(
"<---- .... Leaving gerbv_stats_add_layer. \n");
220 gerbv_stats_new_error_list() {
237 int layer,
const char *text, ...)
242 va_start(args, text);
243 str = g_strdup_vprintf(text, args);
245 gerbv_stats_add_error(list, layer, str, type);
258 char *ec = (
char *)&i;
303 int layer,
const char *error_text,
313 GERB_FATAL_ERROR(
"%s",error_text);
316 GERB_COMPILE_ERROR(
"%s",error_text);
319 GERB_COMPILE_WARNING(
"%s",error_text);
322 GERB_NOTE(
"%s", error_text);
327 if (error_list_in->error_text == NULL) {
328 error_list_in->layer = layer;
329 error_list_in->error_text = g_strdup_printf(
"%s", error_text);
330 error_list_in->type = type;
331 error_list_in->next = NULL;
336 for(error = error_list_in; error != NULL; error = error->next) {
337 if ((strcmp(error->error_text, error_text) == 0) &&
338 (error->layer == layer) ) {
347 GERB_FATAL_ERROR(
"malloc error_list failed in %s()", __FUNCTION__);
351 error_list_new->layer = layer;
352 error_list_new->error_text = g_strdup_printf(
"%s", error_text);
353 error_list_new->type = type;
354 error_list_new->next = NULL;
355 error_last->next = error_list_new;
361 gerbv_aperture_list_t *
362 gerbv_stats_new_aperture_list() {
363 gerbv_aperture_list_t *aperture_list;
366 DPRINTF(
"Mallocing new gerb aperture list\n");
368 if (NULL == (aperture_list = g_new(gerbv_aperture_list_t, 1))) {
369 DPRINTF(
"malloc new gerb aperture list failed in %s()\n", __FUNCTION__);
373 DPRINTF(
" Placing values in certain structs.\n");
374 aperture_list->number = -1;
375 aperture_list->count = 0;
376 aperture_list->type = 0;
377 for (i = 0; i<5; i++) {
378 aperture_list->parameter[i] = 0.0;
380 aperture_list->next = NULL;
381 return aperture_list;
387 gerbv_stats_add_aperture(gerbv_aperture_list_t *aperture_list_in,
389 double parameter[5]) {
391 gerbv_aperture_list_t *aperture_list_new;
392 gerbv_aperture_list_t *aperture_last = NULL;
393 gerbv_aperture_list_t *aperture;
396 DPRINTF(
" ---> Entering gerbv_stats_add_aperture ....\n");
399 if (aperture_list_in->number == -1) {
400 DPRINTF(
" .... Adding first aperture to aperture list ... \n");
401 DPRINTF(
" .... Aperture type = %d ... \n", type);
402 aperture_list_in->number = number;
403 aperture_list_in->type = type;
404 aperture_list_in->layer = layer;
406 aperture_list_in->parameter[i] = parameter[i];
408 aperture_list_in->next = NULL;
409 DPRINTF(
" <--- .... Leaving gerbv_stats_add_aperture.\n");
414 for(aperture = aperture_list_in;
416 aperture = aperture->next) {
417 if ((aperture->number == number) &&
418 (aperture->layer == layer) ) {
419 DPRINTF(
" .... This aperture is already in the list ... \n");
420 DPRINTF(
" <--- .... Leaving gerbv_stats_add_aperture.\n");
423 aperture_last = aperture;
426 DPRINTF(
" .... Adding another aperture to list ... \n");
427 DPRINTF(
" .... Aperture type = %d ... \n", type);
430 if (NULL == (aperture_list_new = g_new(gerbv_aperture_list_t, 1))) {
431 GERB_FATAL_ERROR(
"malloc aperture_list failed in %s()", __FUNCTION__);
435 aperture_list_new->layer = layer;
436 aperture_list_new->number = number;
437 aperture_list_new->type = type;
438 aperture_list_new->next = NULL;
440 aperture_list_new->parameter[i] = parameter[i];
442 aperture_last->next = aperture_list_new;
444 DPRINTF(
" <--- .... Leaving gerbv_stats_add_aperture.\n");
451 gerbv_stats_add_to_D_list(gerbv_aperture_list_t *D_list_in,
454 gerbv_aperture_list_t *D_list;
455 gerbv_aperture_list_t *D_list_last=NULL;
456 gerbv_aperture_list_t *D_list_new;
458 DPRINTF(
" ----> Entering add_to_D_list, numbr = %d\n", number);
461 if (D_list_in->number == -1) {
462 DPRINTF(
" .... Adding first D code to D code list ... \n");
463 DPRINTF(
" .... Aperture number = %d ... \n", number);
464 D_list_in->number = number;
465 D_list_in->count = 0;
466 D_list_in->next = NULL;
467 DPRINTF(
" <--- .... Leaving add_to_D_list.\n");
472 for(D_list = D_list_in;
474 D_list = D_list->next) {
475 if (D_list->number == number) {
476 DPRINTF(
" .... Found in D list .... \n");
477 DPRINTF(
" <--- .... Leaving add_to_D_list.\n");
480 D_list_last = D_list;
484 DPRINTF(
" .... Adding another D code to D code list ... \n");
487 if (NULL == (D_list_new = g_new(gerbv_aperture_list_t, 1))) {
488 GERB_FATAL_ERROR(
"malloc D_list failed in %s()", __FUNCTION__);
492 D_list_new->number = number;
493 D_list_new->count = 0;
494 D_list_new->next = NULL;
495 D_list_last->next = D_list_new;
497 DPRINTF(
" <--- .... Leaving add_to_D_list.\n");
504 gerbv_stats_increment_D_list_count(gerbv_aperture_list_t *D_list_in,
509 gerbv_aperture_list_t *D_list;
511 DPRINTF(
" Entering inc_D_list_count, code = D%d, input count to add = %d\n", number, count);
514 for(D_list = D_list_in;
516 D_list = D_list->next) {
517 if (D_list->number == number) {
518 DPRINTF(
" old count = %d\n", D_list->count);
519 D_list->count += count;
520 DPRINTF(
" updated count = %d\n", D_list->count);
526 DPRINTF(
" .... Didn't find this D code in defined list .... \n");
527 DPRINTF(
" <--- .... Leaving inc_D_list_count.\n");
530 _(
"Undefined aperture number called out in D code"));
int gerbv_escape_char_return_int(char c)
Escape special ASCII char (' ', '\0').
gerbv_stats_t * gerbv_stats_new(void)
Allocates a new gerbv_stats structure.
void gerbv_stats_add_layer(gerbv_stats_t *accum_stats, gerbv_stats_t *input_stats, int this_layer)
void gerbv_stats_destroy(gerbv_stats_t *stats)
Header info for the statistics generating functions for RS274X files.
The main header file for the libgerbv library.