IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 15, 2009, 4:03:13 PM (17 years ago)
Author:
eugene
Message:

updates from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20090715/psModules/src/imcombine/pmSubtractionStamps.c

    r24066 r25407  
    225225}
    226226
     227pmSubtractionStampList *pmSubtractionStampListCopy(const pmSubtractionStampList *in)
     228{
     229    PM_ASSERT_SUBTRACTION_STAMP_LIST_NON_NULL(in, NULL);
     230
     231    pmSubtractionStampList *out = psAlloc(sizeof(pmSubtractionStampList)); // Copied stamp list to return
     232    psMemSetDeallocator(out, (psFreeFunc)subtractionStampListFree);
     233
     234    int num = out->num = in->num;       // Number of stamps
     235    out->stamps = psArrayAlloc(num);
     236    out->regions = psArrayAlloc(num);
     237    out->x = NULL;
     238    out->y = NULL;
     239    out->flux = NULL;
     240    out->footprint = in->footprint;
     241
     242    for (int i = 0; i < num; i++) {
     243        psRegion *inRegion = in->regions->data[i]; // Input region
     244        out->regions->data[i] = psRegionAlloc(inRegion->x0, inRegion->x1, inRegion->y0, inRegion->y1);
     245
     246        pmSubtractionStamp *inStamp = in->stamps->data[i]; // Input stamp
     247        pmSubtractionStamp *outStamp = psAlloc(sizeof(pmSubtractionStamp));
     248        psMemSetDeallocator(outStamp, (psFreeFunc)subtractionStampFree);
     249        outStamp->x = inStamp->x;
     250        outStamp->y = inStamp->y;
     251        outStamp->flux = inStamp->flux;
     252        outStamp->xNorm = inStamp->xNorm;
     253        outStamp->yNorm = inStamp->yNorm;
     254        outStamp->status = inStamp->status;
     255
     256        outStamp->image1 = inStamp->image1 ? psKernelCopy(inStamp->image1) : NULL;
     257        outStamp->image2 = inStamp->image2 ? psKernelCopy(inStamp->image2) : NULL;
     258        outStamp->variance = inStamp->variance ? psKernelCopy(inStamp->variance) : NULL;
     259
     260        if (inStamp->convolutions1) {
     261            int size = inStamp->convolutions1->n; // Size of array
     262            outStamp->convolutions1 = psArrayAlloc(size);
     263            for (int j = 0; j < size; j++) {
     264                psKernel *conv = inStamp->convolutions1->data[j]; // Convolution
     265                outStamp->convolutions1->data[j] = conv ? psKernelCopy(conv) : NULL;
     266            }
     267        } else {
     268            outStamp->convolutions1 = NULL;
     269        }
     270        if (inStamp->convolutions2) {
     271            int size = inStamp->convolutions2->n; // Size of array
     272            outStamp->convolutions2 = psArrayAlloc(size);
     273            for (int j = 0; j < size; j++) {
     274                psKernel *conv = inStamp->convolutions2->data[j]; // Convolution
     275                outStamp->convolutions2->data[j] = conv ? psKernelCopy(conv) : NULL;
     276            }
     277        } else {
     278            outStamp->convolutions2 = NULL;
     279        }
     280
     281        outStamp->matrix1 = inStamp->matrix1 ? psImageCopy(NULL, inStamp->matrix1, PS_TYPE_F64) : NULL;
     282        outStamp->matrix2 = inStamp->matrix2 ? psImageCopy(NULL, inStamp->matrix2, PS_TYPE_F64) : NULL;
     283        outStamp->matrixX = inStamp->matrixX ? psImageCopy(NULL, inStamp->matrixX, PS_TYPE_F64) : NULL;
     284        outStamp->vector1 = inStamp->vector1 ? psVectorCopy(NULL, inStamp->vector1, PS_TYPE_F64) : NULL;
     285        outStamp->vector2 = inStamp->vector2 ? psVectorCopy(NULL, inStamp->vector2, PS_TYPE_F64) : NULL;
     286
     287        out->stamps->data[i] = outStamp;
     288    }
     289
     290    return out;
     291}
     292
    227293pmSubtractionStamp *pmSubtractionStampAlloc(void)
    228294{
Note: See TracChangeset for help on using the changeset viewer.