IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 6, 2008, 6:23:02 PM (18 years ago)
Author:
eugene
Message:

set mask bits based on recipe and input mask image headers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20080706/psModules/src/config/pmConfigMask.c

    r18425 r18430  
    4040}
    4141
    42 // replace the named masks in the recipe with values in the header
     42// replace the named masks in the recipe with values in the header:
     43// replace only the names in the header in the recipe
    4344void pmConfigMasksReadHeader (pmConfig *config, psMetadata *header) {
    4445
     
    4950    }
    5051
    51     int nMask = 0;
     52    int nMask = psMetadataLookupS32 (&status, header, "MSKNUM");
     53    if (!status) {
     54        psError(PS_ERR_UNKNOWN, true, "Unable to find MSKNUM in header.");
     55        return false;
     56    }
    5257
    53     psMetadataIterator *iter = psMetadataIteratorAlloc(recipe, PS_LIST_HEAD, NULL); // Iterator
     58    for (int i = 0; i < nMask; i++) {
    5459
    55     psMetadataItem *item;               // Item from iteration
    56     while ((item = psMetadataGetAndIncrement(iter))) {
     60        snprintf (namekey,  64, "MSKNAM%02d", i);
     61        snprintf (valuekey, 64, "MSKVAL%02d", i);
    5762
    58         if (item->type != PS_DATA_U8) {
    59             psWarning("mask recipe entry %s is not a bit value\n", item->name);
    60             continue;
     63        char *name = psMetadataLookupStr (&status, header, namekey);
     64        psU8 bit = psMetadataLookupU8 (&status, header, valuekey);
     65
     66        // XXX validate that bit is a 2^n value?
     67
     68        psMetadataItem *item = psMetadataLookup (header, name);
     69        if (!item) {
     70          psWarning("mask recipe entry %s not in recipe\n", name);
     71          psMetadataAddU8 (recipe, PS_LIST_TAIL, name, 0, "Bitmask bit value", bit);
     72        } else {
     73          item->data.U8 = bit;
    6174        }
    62 
    63         snprintf (namekey,  64, "MSKNAM%02d", nMask);
    64         snprintf (valuekey, 64, "MSKVAL%02d", nMask);
    65 
    66         psMetadataAddStr (header, PS_LIST_TAIL, namekey, 0, "Bitmask bit name", item->name);
    67         psMetadataAddU8 (header, PS_LIST_TAIL, valuekey, 0, "Bitmask bit value", item->data.U8);
    68         nMask ++;
    6975    }
    7076   
    71     psMetadataAddU8 (header, PS_LIST_TAIL, "MSKNUM", 0, "Bitmask bit count", nMask);
    7277    return true;
    7378}
     
    102107    }
    103108   
    104     psMetadataAddU8 (header, PS_LIST_TAIL, "MSKNUM", 0, "Bitmask bit count", nMask);
     109    psMetadataAddS32 (header, PS_LIST_TAIL, "MSKNUM", 0, "Bitmask bit count", nMask);
    105110    return true;
    106111}
Note: See TracChangeset for help on using the changeset viewer.