IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 7, 2014, 5:38:26 AM (12 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20140423/psphot/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20140423/psphot/src

  • branches/eam_branches/ipp-20140423/psphot/src/psphotFullForceSummary.c

    r36666 r36828  
    186186    psFitsClose(fits);
    187187
    188     // Convert to an array indexed by ID
    189     psArray *sortedTable = psArrayAlloc(4*inTable->n);
     188    // Convert to a set of arrays indexed by model type + 1
     189    // which contain pointers to arrays indexed by ID
     190#define MAX_MODEL_TYPE 10
     191    psArray *sortedTables = psArrayAlloc(MAX_MODEL_TYPE+1);
    190192    for (int i=0; i<inTable->n; i++) {
    191193        psMetadata *row = inTable->data[i];
    192194        psS32 ID = psMetadataLookupS32(&status, row, "ID");
     195        psS32 modelType = psMetadataLookupS32(&status, row, "MODEL_TYPE");
     196        // XXX: need to use the lookup table functions to be ready for changes in the model type numbers
     197        if (modelType+1 >= MAX_MODEL_TYPE) {
     198            psError(PSPHOT_ERR_CONFIG, false, "found modelType %d max allowed is %d", modelType, MAX_MODEL_TYPE);
     199            return false;
     200        }
     201        psArray *sortedTable = sortedTables->data[modelType+1];
     202        if (!sortedTable) {
     203            sortedTable = psArrayAlloc(4*inTable->n);
     204            sortedTables->data[modelType+1] = sortedTable;
     205            // dont' free sortedTable the array of tables gets our reference
     206        }
    193207        if (ID >= sortedTable->n) {
    194208            sortedTable = psArrayRealloc(sortedTable, 2*ID);
    195209            // Why doesn't psArrayRealloc do this?????
    196             sortedTable->n = sortedTable->nalloc;
     210                sortedTable->n = sortedTable->nalloc;
    197211        }
    198212        if (sortedTable->data[ID]) {
     
    202216        sortedTable->data[ID] = psMemIncrRefCounter(row);
    203217    }
    204     psMetadataAddArray(config->arguments, PS_LIST_TAIL, "CFF_TABLE", PS_META_REPLACE, "cff table", sortedTable);
     218    psMetadataAddArray(config->arguments, PS_LIST_TAIL, "CFF_TABLES", PS_META_REPLACE, "cff tables", sortedTables);
    205219    psFree(inTable);
    206     psFree(sortedTable);
     220    psFree(sortedTables);
    207221
    208222    return true;
Note: See TracChangeset for help on using the changeset viewer.