IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3746


Ignore:
Timestamp:
Apr 21, 2005, 2:06:41 PM (21 years ago)
Author:
desonia
Message:

* empty log message *

Location:
trunk/psLib/src/image
Files:
2 edited

Legend:

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

    r3741 r3746  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-04-21 23:28:39 $
     9 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-04-22 00:06:41 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    1919#include "psMemory.h"
    2020
     21typedef struct
     22{
     23    psS32 x;
     24    psS32 y;
     25}
     26p_psPixelCoord;
     27
    2128typedef int(*qsortCompareFcn)(const void *, const void *);
    2229
     
    2431{
    2532    if (pixels != NULL) {
    26         psFree(pixels->data);
     33        psFree(pixels->x);
     34        psFree(pixels->y);
    2735    }
    2836}
    2937
    3038// for use by qsort, etc.
    31 static int comparePixelCoord(psPixelCoord* coord1, psPixelCoord* coord2)
     39static int comparePixelCoord(p_psPixelCoord* coord1, p_psPixelCoord* coord2)
    3240{
    3341    // check row first
     
    5765
    5866    if (size > 0) {
    59         out->data = psAlloc(sizeof(psPixelCoord)*size);
     67        out->x = psVectorAlloc(size, PS_TYPE_S32);
     68        out->y = psVectorAlloc(size, PS_TYPE_S32);
    6069    } else {
    61         out->data = NULL;
     70        out->x = NULL;
     71        out->y = NULL;
    6272    }
    6373
     
    7383    }
    7484
    75     pixels->data = psRealloc(pixels->data, sizeof(psPixelCoord)*size);
     85    pixels->x = psVectorRealloc(pixels->x, size);
     86    pixels->y = psVectorRealloc(pixels->y, size);
    7687
    7788    return pixels;
     
    8697        return NULL;
    8798    }
    88     psPixelCoord* data = pixels->data;
    89     if (data == NULL) {
     99    psVector* xVec = pixels->x;
     100    psVector* yVec = pixels->y;
     101    if (xVec == NULL || yVec == NULL) {
     102        // XXX: Error message
     103        psFree(out);
     104        return NULL;
     105    }
     106    if (xVec->type.type != PS_TYPE_S32) {
     107        // XXX: Error message
     108        psFree(out);
     109        return NULL;
     110    }
     111    if (yVec->type.type != PS_TYPE_S32) {
    90112        // XXX: Error message
    91113        psFree(out);
     
    129151
    130152    // determine the length of the pixel vector
    131     int length = pixels->n;
     153    int length = pixels->x->n;
     154    if (pixels->y->n != length) {
     155        // XXX: warning message
     156        if (pixels->y->n < length) {
     157            length = pixels->y->n;
     158        }
     159    }
    132160
    133161    // cycle through the vector of pixels and insert pixels into image
    134162    psMaskType** outData = out->data.PS_TYPE_MASK_DATA;
    135163    for (int p = 0; p < length; p++) {
    136         psS32 x = data[p].x;
    137         psS32 y = data[p].y;
     164        psS32 x = xVec->data.S32[p];
     165        psS32 y = yVec->data.S32[p];
    138166        // pixel in region?
    139167        if (x >= x0 && x < x1 && y >= y0 && y < y1) {
     
    170198        out = psPixelsAlloc(minPixels);
    171199    }
    172     psPixelCoord* data = out->data;
     200    psVector* xVec = out->x;
     201    psVector* yVec = out->y;
    173202
    174203    // check the x and y vector validity (type/minimum size)
  • trunk/psLib/src/image/psPixels.h

    r3741 r3746  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-04-21 23:28:39 $
     9 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-04-22 00:06:41 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2020/// @addtogroup Image
    2121/// @{
    22 
    23 typedef struct
    24 {
    25     psS32 x;
    26     psS32 y;
    27 }
    28 psPixelCoord;
    2922
    3023/** list of pixel coordinates
     
    4033typedef struct
    4134{
    42     int n;
    43     int nalloc;
    44     psPixelCoord* data;
     35    psVector *x;                       ///< x coordinate
     36    psVector *y;                       ///< y coordinate
    4537}
    4638psPixels;
Note: See TracChangeset for help on using the changeset viewer.