IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 16481


Ignore:
Timestamp:
Feb 14, 2008, 4:26:09 PM (18 years ago)
Author:
Paul Price
Message:

Gene needs the concepts copied over in pmFPAfileDefineChipMosaic, so to avoid the error due to differing number of cells, I've made new functions that provide optional recursion.

Location:
trunk/psModules/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPAfileDefine.c

    r16340 r16481  
    12001200
    12011201    file->src = psMemIncrRefCounter(src); // inherit output elements from this source pmFPA
     1202    if (src) {
     1203        if (!pmConceptsCopyFPA(file->fpa, src, true, false)) {
     1204            psError(PS_ERR_UNKNOWN, false, "Unable to copy concepts from source to new FPA");
     1205            psFree(file);
     1206            return NULL;
     1207        }
     1208    }
    12021209
    12031210    file->mosaicLevel = PM_FPA_LEVEL_CHIP; // don't do any I/O on this at a lower level
     
    12451252
    12461253    file->src = psMemIncrRefCounter(src); // inherit output elements from this source pmFPA
     1254    if (src) {
     1255        if (!pmConceptsCopyFPA(file->fpa, src, false, false)) {
     1256            psError(PS_ERR_UNKNOWN, false, "Unable to copy concepts from source to new FPA");
     1257            psFree(file);
     1258            return NULL;
     1259        }
     1260    }
    12471261
    12481262    file->mosaicLevel = PM_FPA_LEVEL_FPA; // don't do any I/O on this at a lower level
  • trunk/psModules/src/concepts/pmConcepts.c

    r16218 r16481  
    11201120    return true;
    11211121}
     1122
     1123
     1124bool pmConceptsCopyFPA(pmFPA *target, const pmFPA *source, bool chips, bool cells)
     1125{
     1126    PS_ASSERT_PTR_NON_NULL(target, false);
     1127    PS_ASSERT_PTR_NON_NULL(source, false);
     1128
     1129    // Copy FPA concepts
     1130    copyConcepts(target->concepts, source->concepts, dontCopyConceptsFPA);
     1131
     1132    // Copy chip concepts
     1133    bool status = true;                 // Status of chips
     1134    if (chips) {
     1135        psArray *targetChips = target->chips; // Chips in target
     1136        psArray *sourceChips = source->chips; // Chips in source
     1137        if (targetChips->n != sourceChips->n) {
     1138            psError(PS_ERR_IO, true,
     1139                    "Number of chips in target (%ld) and source (%ld) differ --- unable to copy concepts.",
     1140                    targetChips->n, sourceChips->n);
     1141            return false;
     1142        }
     1143        for (int i = 0; i < targetChips->n; i++) {
     1144            pmChip *targetChip = targetChips->data[i]; // Target chip of interest
     1145            pmChip *sourceChip = sourceChips->data[i]; // Source chip of interest
     1146            if (! targetChip || ! sourceChip) {
     1147                continue;
     1148            }
     1149
     1150            status &= pmConceptsCopyChip(targetChip, sourceChip, cells);
     1151        }
     1152    }
     1153
     1154    return status;
     1155}
     1156
     1157bool pmConceptsCopyChip(pmChip *target, const pmChip *source, bool cells)
     1158{
     1159    PS_ASSERT_PTR_NON_NULL(target, false);
     1160    PS_ASSERT_PTR_NON_NULL(source, false);
     1161
     1162    // Copy chip concepts
     1163    copyConcepts(target->concepts, source->concepts, dontCopyConceptsChip);
     1164
     1165    // Copy cell concepts
     1166    bool status = true;                 // Status of cells
     1167    if (cells) {
     1168        psArray *targetCells = target->cells; // Cells in target
     1169        psArray *sourceCells = source->cells; // Cells in source
     1170        if (targetCells->n != sourceCells->n) {
     1171            psError(PS_ERR_IO, true,
     1172                    "Number of cells in target (%ld) and source (%ld) differ --- unable to copy concepts.",
     1173                    targetCells->n, sourceCells->n);
     1174            return false;
     1175        }
     1176        for (int j = 0; j < targetCells->n; j++) {
     1177            pmCell *targetCell = targetCells->data[j]; // Target chip of interest
     1178            pmCell *sourceCell = sourceCells->data[j]; // Source chip of interest
     1179            if (! targetCell || ! sourceCell) {
     1180                continue;
     1181            }
     1182
     1183            status &= pmConceptsCopyCell(targetCell, sourceCell);
     1184        }
     1185    }
     1186
     1187    return status;
     1188}
     1189
     1190
     1191bool pmConceptsCopyCell(pmCell *target, const pmCell *source)
     1192{
     1193    PS_ASSERT_PTR_NON_NULL(target, false);
     1194    PS_ASSERT_PTR_NON_NULL(source, false);
     1195
     1196    copyConcepts(target->concepts, source->concepts, dontCopyConceptsCell);
     1197
     1198    return true;
     1199}
  • trunk/psModules/src/concepts/pmConcepts.h

    r12696 r16481  
    44 * @author Paul Price, IfA
    55 *
    6  * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2007-03-30 21:12:56 $
     6 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2008-02-15 02:26:09 $
    88 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii
    99 */
     
    203203                       const pmFPA *source    ///< The source FPA
    204204                      );
     205
     206/// Copy the concepts within an FPA to another FPA; optionally recurse to lower levels
     207bool pmConceptsCopyFPA(pmFPA *target,   ///< Target FPA
     208                       const pmFPA *source, ///< Source FPA
     209                       bool chips,      ///< Recurse to chips level?
     210                       bool cells       ///< Recurse to cells level?
     211    );
     212
     213/// Copy the concepts within a chip to another chip; optionally recurse to lower level
     214bool pmConceptsCopyChip(pmChip *target, ///< Target chip
     215                        const pmChip *source, ///< Source chip
     216                        bool cells      ///< Recurse to cells level?
     217    );
     218
     219/// Copy the concepts within a cell to another cell
     220bool pmConceptsCopyCell(pmCell *target, ///< Target cell
     221                        const pmCell *source ///< Source cell
     222    );
     223
     224
    205225/// @}
    206226#endif
Note: See TracChangeset for help on using the changeset viewer.