IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 16963


Ignore:
Timestamp:
Mar 12, 2008, 3:03:08 PM (18 years ago)
Author:
Paul Price
Message:

Cleaning up --- was getting SEGVs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/types/psPixels.c

    r16873 r16963  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2008-03-07 22:16:38 $
     9 *  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2008-03-13 01:03:08 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    246246}
    247247
    248 psPixels* psPixelsConcatenate(psPixels *out,
    249                               const psPixels *pixels)
     248psPixels* psPixelsConcatenate(psPixels *out, const psPixels *pixels)
    250249{
    251250    PS_ASSERT_PIXELS_NON_NULL(pixels, NULL);
    252 
    253     long pixelsN = pixels->n;           // Size of input
    254     psPixelCoord* pixelsData = pixels->data; // Dereference input
    255 
    256251    if (!out) {
    257         // Simply copy pixels
    258         out = psPixelsCopy(out, pixels);
    259         return out;
    260     }
    261 
    262     long outN = out->n;                 // Size of output
    263     psPixelCoord* outData = out->data;  // Dereference output
     252        return psPixelsCopy(NULL, pixels);
     253    }
    264254
    265255    // sort the OUT array to help in searching for duplicates later
    266     qsort(outData, outN, sizeof(psPixelCoord), (qsortCompareFunc)comparePixelCoord);
    267 
    268     // add non-duplicate values in pixels to out
    269     for (long n = 0; n < pixelsN; n++) {
    270         psPixelCoord pCoord = pixelsData[n]; // Coordinate of interest
    271         if (!bsearch(&pCoord, outData, outN, sizeof(psPixelCoord), (qsortCompareFunc)comparePixelCoord)) {
    272             // no match in OUT array of this value
    273             psPixelsAdd(out, 0, pCoord.x, pCoord.y);
     256    qsort(out->data, out->n, sizeof(psPixelCoord), (qsortCompareFunc)comparePixelCoord);
     257
     258    // add non-duplicate values in pixels to the end of the output list (unsorted!)
     259    long numInPix = pixels->n;          // Number of input pixels
     260    long numOutPix = out->n;            // (Original) number of output pixels
     261    for (long i = 0; i < numInPix; i++) {
     262        psPixelCoord pix = pixels->data[i]; // Coordinate of interest
     263        if (!bsearch(&pix, out->data, numOutPix, sizeof(psPixelCoord), (qsortCompareFunc)comparePixelCoord)) {
     264            psPixelsAdd(out, 0, pix.x, pix.y);
    274265        }
    275266    }
Note: See TracChangeset for help on using the changeset viewer.