IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 12330


Ignore:
Timestamp:
Mar 8, 2007, 12:12:56 PM (19 years ago)
Author:
Paul Price
Message:

Making psPixels APIs to look more like the psArray, psVector APIs (psPixelsAdd, psPixelsAllocEmpty, etc).

Location:
trunk/psLib/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/astro/psCoord.c

    r11686 r12330  
    1010*  @author GLG, MHPCC
    1111*
    12 *  @version $Revision: 1.134 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2007-02-07 23:52:53 $
     12*  @version $Revision: 1.135 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2007-03-08 22:12:56 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    6767simply inverts the supplied psPlaneTransform transform.  It assumes that
    6868"transform" is linear.
    69  
     69
    7070XXX: This code no longer makes sense.  The merge must be reviewed.
    71  
     71
    7272XXX: below is the code using the standard matrix representation.  note that
    7373this inversion requires x->nX == 1, y->nY == 1 and x->nY <= 1, y->nX <= 1
     
    144144if the supplied psPlaneTransform transform is linear: if any of the
    145145cooefficients of order 2 are higher are non-zero, then it is not linear.
    146  
     146
    147147Returns:
    148148    true: if linear
    149149    false: otherwise
    150  
     150
    151151Why isn't this called p_psIsPlaneTransformLinear()?
    152152 *****************************************************************************/
     
    882882/*****************************************************************************
    883883psPlaneTransformFit(trans, source, dest, nRejIter, sigmaClip)
    884  
     884
    885885XXX: This code ignores nRejIter and sigmaClip.  We must call the ClipFit
    886886routines instead.
     
    931931/*****************************************************************************
    932932psPlaneTransformInvert(out, in, region, nSamples)
    933  
     933
    934934 *****************************************************************************/
    935935psPlaneTransform *psPlaneTransformInvert(
     
    11291129                    //                    out->data[m].y = fxnVal->y + y;
    11301130                    //                    m++;
    1131                     out = p_psPixelsAppend(out, 1, (float)(fxnVal->x+j),
    1132                                            (float)(fxnVal->y+k) );
     1131                    out = psPixelsAdd(out, 1, (float)(fxnVal->x+j),
     1132                                      (float)(fxnVal->y+k) );
    11331133                }
    11341134            }
  • trunk/psLib/src/imageops/psImageGeomManip.c

    r12248 r12330  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2007-03-06 02:14:55 $
     12 *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2007-03-08 22:12:56 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    907907    if (isnan(value)) { \
    908908        if (blankPixels != NULL) { \
    909             p_psPixelsAppend(*blankPixels, (*blankPixels)->nalloc, outPosition.x, outPosition.y); \
     909            psPixelsAdd(*blankPixels, (*blankPixels)->nalloc, outPosition.x, outPosition.y); \
    910910        } \
    911911        value = exposedValue; \
  • trunk/psLib/src/types/psPixels.c

    r12289 r12330  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2007-03-07 02:50:15 $
     9 *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2007-03-08 22:12:56 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    6060}
    6161
     62
     63static psPixels *pixelsAlloc(const char *file,
     64                          unsigned int lineno,
     65                          const char *func,
     66                          long nalloc)
     67{
     68    psPixels* out = p_psAlloc(file, lineno, func, sizeof(psPixels));
     69    psMemSetDeallocator(out, (psFreeFunc)pixelsFree);
     70
     71    out->data = p_psAlloc(file, lineno, func, sizeof(psPixelCoord)*nalloc);
     72    P_PSPIXELS_SET_NALLOC(out,nalloc);
     73
     74    return out;
     75}
     76
    6277psPixels* p_psPixelsAlloc(const char *file,
    6378                          unsigned int lineno,
     
    6580                          long nalloc)
    6681{
    67     psPixels* out = p_psAlloc(file, lineno, func, sizeof(psPixels));
    68 
    69     if (nalloc > 0) {
    70         out->data = p_psAlloc(file, lineno, func, sizeof(psPixelCoord)*nalloc);
    71     } else {
    72         out->data = NULL;
    73     }
     82    psPixels *out = pixelsAlloc(file, lineno, func, nalloc);
     83    out->n = nalloc;
     84    return out;
     85}
     86
     87psPixels* p_psPixelsAllocEmpty(const char *file,
     88                             unsigned int lineno,
     89                             const char *func,
     90                             long nalloc)
     91{
     92    psPixels *out = pixelsAlloc(file, lineno, func, nalloc);
    7493    out->n = 0;
    75     P_PSPIXELS_SET_NALLOC(out,nalloc);
    76 
    77     psMemSetDeallocator(out, (psFreeFunc)pixelsFree);
    78 
    7994    return out;
    8095}
     
    94109                            long nalloc)
    95110{
    96     if (pixels == NULL) {
     111    if (!pixels) {
    97112        return p_psPixelsAlloc(file, lineno, func, nalloc);
    98113    }
    99 
    100     if (nalloc > 0) {
    101         pixels->data = p_psRealloc(file, lineno, func, pixels->data, sizeof(psPixelCoord)*nalloc);
    102     } else {
    103         psFree(pixels->data);
    104         pixels->data = NULL;
    105     }
    106 
     114    if (nalloc < 0) {
     115        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     116                "Can't reallocate a psPixels to negative size.");
     117        return pixels;
     118    }
     119
     120    if (pixels->n == nalloc) {
     121        return pixels;
     122    }
     123    if (nalloc < pixels->n) {
     124        pixels->n = nalloc;
     125    }
     126    pixels->data = p_psRealloc(file, lineno, func, pixels->data, sizeof(psPixelCoord)*nalloc);
    107127    P_PSPIXELS_SET_NALLOC(pixels,nalloc);
    108128
    109     if (pixels->n > pixels->nalloc) {
    110         pixels->n = pixels->nalloc;
    111     }
    112 
    113129    return pixels;
    114130}
    115131
    116 psPixels* p_psPixelsAppend(psPixels* pixels,
    117                            long growth,
    118                            float x,
    119                            float y)
    120 {
    121     if (growth < 1) {
     132psPixels* psPixelsAdd(psPixels* pixels,
     133                      long growth,
     134                      float x,
     135                      float y)
     136{
     137    PS_ASSERT_PIXELS_NON_NULL(pixels, NULL);
     138
     139    if (growth <= 0) {
    122140        growth = PIXELS_DEFAULT_ADD;
    123141    }
    124142
    125     if ( (pixels == NULL) || (pixels->n >= pixels->nalloc) ) {
    126         pixels=psPixelsRealloc(pixels, pixels->nalloc+growth);
     143    if (pixels->n >= pixels->nalloc) {
     144        pixels = psPixelsRealloc(pixels, pixels->nalloc + growth);
    127145    }
    128146
     
    354372        position += pixels->n;
    355373    }
    356     if (position < 0 || position > pixels->n) {
     374    if (position < 0 || position >= pixels->n) {
    357375        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position: %ld\n", position);
    358376        return false;
  • trunk/psLib/src/types/psPixels.h

    r12289 r12330  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-03-07 02:50:15 $
     8 *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-03-08 22:12:56 $
    1010 *
    1111 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    7979#endif // ifdef DOXYGEN
    8080
     81/** Allocates a new empty psPixels structure
     82 *
     83 *  @return psPixels*   new psPixels
     84 */
     85#ifdef DOXYGEN
     86psPixels* psPixelsAllocEmpty(
     87    long nalloc                         ///< the size of the coordinate vectors
     88);
     89#else // ifdef DOXYGEN
     90psPixels* p_psPixelsAllocEmpty(
     91    const char *file,                   ///< File of caller
     92    unsigned int lineno,                ///< Line number of caller
     93    const char *func,                   ///< Function name of caller
     94    long nalloc                         ///< the size of the coordinate vectors
     95);
     96#define psPixelsAllocEmpty(nalloc) \
     97      p_psPixelsAllocEmpty(__FILE__, __LINE__, __func__, nalloc)
     98#endif // ifdef DOXYGEN
     99
    81100
    82101/** Checks the type of a particular pointer.
     
    121140 *  @return psPixels*       psPixels with the value appended.
    122141 */
    123 psPixels* p_psPixelsAppend(
     142psPixels* psPixelsAdd(
    124143    psPixels* pixels,                  ///< psPixels to append new coordinate to.
    125144    long growth,                       ///< Number of elements to grow the pixels list if necessary.
Note: See TracChangeset for help on using the changeset viewer.