IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 6, 2005, 6:43:52 PM (21 years ago)
Author:
Paul Price
Message:

Importing current working PAP version (many bug fixes since this branch) straight on top of this version, and tidying up a bit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pois/src/poisReadStamps.c

    r4644 r5717  
    33#include "pois.h"
    44
    5 #define MAXLINE 128                     // Maximum length of a line in the stamps file
     5#define MAXLINE 128                     // Maximum length of a line in the stamps file
    66
    77
    88psArray *poisReadStamps(psArray *stamps,// Stamps
    9                         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
     9                        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
    1313    )
    1414{
    15     FILE *fp = *stampFP;                // File pointer
    16 
    17     int num = 0;                        // Number of stamps
     15    FILE *fp = *stampFP;                // File pointer
    1816
    1917    if (stamps == NULL) {
    20         stamps = psArrayAlloc(config->nsx);
    21         // Initialise
    22         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        }
    2523    }
    2624
    2725    for (int i = 0; i < stamps->n; i++) {
    28         poisStamp *stamp = stamps->data[i];
     26        poisStamp *stamp = stamps->data[i];
    2927
    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);
    4138
    42                     // Add 0.5 for rounding, and subtract 1.0 for unit-offset to zero-offset
    43                     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 EOF
    53                     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        }
    6057    }
    6158
Note: See TracChangeset for help on using the changeset viewer.