static int read_peaks(FILE *fh, struct image *image) { char *rval = NULL; int first = 1; image->features = image_feature_list_new(); do { char line[1024]; float x, y, d, intensity; int r; struct panel *p = NULL; float add_x, add_y; rval = fgets(line, 1023, fh); if ( rval == NULL ) continue; chomp(line); if ( strcmp(line, PEAK_LIST_END_MARKER) == 0 ) return 0; r = sscanf(line, "%f %f %f %f", &x, &y, &d, &intensity); if ( (r != 4) && (!first) ) { ERROR("Failed to parse peak list line.\n"); ERROR("The failed line was: '%s'\n", line); return 1; } first = 0; if ( r == 4 ) { if ( image->det != NULL ) { p = find_orig_panel(image->det, x, y); if ( p == NULL ) { ERROR("Panel not found\n"); return 1; } add_x = x-p->orig_min_fs+p->min_fs; add_y = y-p->orig_min_ss+p->min_ss; image_add_feature(image->features, add_x, add_y, image, intensity, NULL); } else { image_add_feature(image->features, x, y, image, intensity, NULL); } } } while ( rval != NULL ); /* Got read error of some kind before finding PEAK_LIST_END_MARKER */ return 1; }
static int read_peaks(FILE *fh, struct image *image) { char *rval = NULL; int first = 1; image->features = image_feature_list_new(); do { char line[1024]; float x, y, d, intensity; int r; rval = fgets(line, 1023, fh); if ( rval == NULL ) continue; chomp(line); if ( strcmp(line, PEAK_LIST_END_MARKER) == 0 ) return 0; r = sscanf(line, "%f %f %f %f", &x, &y, &d, &intensity); if ( (r != 4) && (!first) ) { ERROR("Failed to parse peak list line.\n"); ERROR("The failed line was: '%s'\n", line); return 1; } first = 0; if ( r == 4 ) { image_add_feature(image->features, x, y, image, intensity, NULL); } } while ( rval != NULL ); /* Got read error of some kind before finding PEAK_LIST_END_MARKER */ return 1; }