Changeset 5717 for trunk/pois/src/poisReadStamps.c
- Timestamp:
- Dec 6, 2005, 6:43:52 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/pois/src/poisReadStamps.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pois/src/poisReadStamps.c
r4644 r5717 3 3 #include "pois.h" 4 4 5 #define MAXLINE 128 // Maximum length of a line in the stamps file5 #define MAXLINE 128 // Maximum length of a line in the stamps file 6 6 7 7 8 8 psArray *poisReadStamps(psArray *stamps,// Stamps 9 FILE **stampFP, // File pointer for stamps file10 const psImage *image, // Image for which to find stamps11 const psImage *mask, // Mask image12 const poisConfig *config // Configuration9 FILE **stampFP, // File pointer for stamps file 10 const psImage *image, // Image for which to find stamps 11 const psImage *mask, // Mask image 12 const poisConfig *config // Configuration 13 13 ) 14 14 { 15 FILE *fp = *stampFP; // File pointer 16 17 int num = 0; // Number of stamps 15 FILE *fp = *stampFP; // File pointer 18 16 19 17 if (stamps == NULL) { 20 stamps = psArrayAlloc(config->nsx);21 // Initialise22 for (int i = 0; i < config->nsx; i++) {23 stamps->data[i] = poisStampAlloc();24 }18 stamps = psArrayAlloc(config->nsx); 19 // Initialise 20 for (int i = 0; i < config->nsx; i++) { 21 stamps->data[i] = poisStampAlloc(); 22 } 25 23 } 26 24 27 25 for (int i = 0; i < stamps->n; i++) { 28 poisStamp *stamp = stamps->data[i];26 poisStamp *stamp = stamps->data[i]; 29 27 30 if (stamp->status == POIS_STAMP_RESET) { 31 if (fp) { 32 float x, y; // Position of stamp 33 int xPixel, yPixel; // Integer position 34 int result = 0; // Result of fscanf 35 bool badPixels = false; // Result of check on stamp footprint 36 char line[MAXLINE]; // The line from the stamps file 37 char *lineBack; // The line back from fgets 38 do { 39 lineBack = fgets(line, MAXLINE, fp); 40 result = sscanf(line, "%f %f", &x, &y); 28 if (stamp->status == POIS_STAMP_RESET) { 29 if (fp) { 30 float x, y; // Position of stamp 31 int xPixel, yPixel; // Integer position 32 int result = 0; // Result of fscanf 33 char line[MAXLINE]; // The line from the stamps file 34 char *lineBack; // The line back from fgets 35 do { 36 lineBack = fgets(line, MAXLINE, fp); 37 result = sscanf(line, "%f %f", &x, &y); 41 38 42 // Add 0.5 for rounding, and subtract 1.0 for unit-offset to zero-offset43 xPixel = (int)(x - 0.5);44 yPixel = (int)(y - 0.5);45 } while (result == 2 && lineBack && ! poisCheckStamp(image, mask, xPixel, yPixel, config));46 if (result == 2 && lineBack) {47 stamp->x = xPixel;48 stamp->y = yPixel;49 stamp->status = POIS_STAMP_RECALC;50 psTrace("pois.readStamps", 7, "Stamp %d: %d,%d\n", i, stamp->x, stamp->y);51 } else {52 // We've run out of stamps in the file --- probably got EOF53 stamp->status = POIS_STAMP_BAD;54 }55 } else {56 // Stamp file isn't open!57 stamp->status = POIS_STAMP_BAD;58 }59 }39 // Add 0.5 for rounding, and subtract 1.0 for unit-offset to zero-offset 40 xPixel = (int)(x - 0.5); 41 yPixel = (int)(y - 0.5); 42 } while (result == 2 && lineBack && ! poisCheckStamp(image, mask, xPixel, yPixel, config)); 43 if (result == 2 && lineBack) { 44 stamp->x = xPixel; 45 stamp->y = yPixel; 46 stamp->status = POIS_STAMP_RECALC; 47 psTrace("pois.readStamps", 7, "Stamp %d: %d,%d\n", i, stamp->x, stamp->y); 48 } else { 49 // We've run out of stamps in the file --- probably got EOF 50 stamp->status = POIS_STAMP_BAD; 51 } 52 } else { 53 // Stamp file isn't open! 54 stamp->status = POIS_STAMP_BAD; 55 } 56 } 60 57 } 61 58
Note:
See TracChangeset
for help on using the changeset viewer.
