IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 2375


Ignore:
Timestamp:
Nov 16, 2004, 10:00:21 AM (22 years ago)
Author:
desonia
Message:

Added some psfits and pslist changes. More work needs to be done to make it match the current SDRS.

Location:
trunk/psLib
Files:
7 added
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/psLib.kdevelop.filelist

    r2285 r2375  
    11# KDevelop Custom Project File List
    22tags
     3src/fileUtils/psFits.c
     4src/fileUtils/psFits.h
  • trunk/psLib/psLib.kdevses

    r2273 r2375  
    22<!DOCTYPE KDevPrjSession>
    33<KDevPrjSession>
    4  <DocsAndViews NumberOfDocuments="0" />
     4 <DocsAndViews NumberOfDocuments="8" >
     5  <Doc0 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImageConvolve.c" >
     6   <View0 Type="Source" />
     7  </Doc0>
     8  <Doc1 NumberOfViews="1" URL="file:/home/desonia/psLib/src/fileUtils/psFits.c" >
     9   <View0 Type="Source" />
     10  </Doc1>
     11  <Doc2 NumberOfViews="1" URL="file:/home/desonia/psLib/src/fileUtils/psFits.h" >
     12   <View0 Type="Source" />
     13  </Doc2>
     14  <Doc3 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImageIO.c" >
     15   <View0 Type="Source" />
     16  </Doc3>
     17  <Doc4 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImageIO.h" >
     18   <View0 Type="Source" />
     19  </Doc4>
     20  <Doc5 NumberOfViews="1" URL="file:/home/desonia/psLib/src/fileUtils/psFileUtilsErrors.dat" >
     21   <View0 Type="Source" />
     22  </Doc5>
     23  <Doc6 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImageErrors.dat" >
     24   <View0 Type="Source" />
     25  </Doc6>
     26  <Doc7 NumberOfViews="1" URL="file:/home/desonia/psLib/src/psErrorCodes.dat" >
     27   <View0 line="9" Type="Source" />
     28  </Doc7>
     29 </DocsAndViews>
    530 <pluginList>
    631  <kdevbookmarks>
    732   <bookmarks/>
    833  </kdevbookmarks>
     34  <kdevsubversion>
     35   <subversion recurseresolve="1" recurserelocate="1" recursemerge="1" recursecommit="1" base="" recursepropget="1" recurseswitch="1" recurseupdate="1" recursepropset="1" recursediff="1" recurserevert="1" forcemove="1" recursecheckout="1" forceremove="1" recurseadd="1" recurseproplist="1" forcemerge="1" />
     36  </kdevsubversion>
    937  <kdevvalgrind>
    1038   <executable path="" params="" />
    1139   <valgrind path="" params="" />
     40   <calltree path="" params="" />
     41   <kcachegrind path="" />
    1242  </kdevvalgrind>
    1343  <kdevdebugger>
  • trunk/psLib/src/astronomy/psAstronomyErrors.h

    r2301 r2375  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-11-09 00:36:13 $
     9 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-11-16 20:00:20 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    1313 */
    1414
    15 #ifndef PS_SYSUTILS_ERRORS_H
    16 #define PS_SYSUTILS_ERRORS_H
     15#ifndef PS_ASTRONOMY_ERRORS_H
     16#define PS_ASTRONOMY_ERRORS_H
    1717
    1818/* N.B., lines between '//~Start' and '//~End' are automatic generated from
  • trunk/psLib/src/collections/psList.c

    r2273 r2375  
    66 *  @author Robert Daniel DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-11-04 01:04:57 $
     8 *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-11-16 20:00:20 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4242    list->size = 0;
    4343    list->head = list->tail = NULL;
    44     list->iter = ITER_INIT_HEAD;
    45     list->iterIndex = PS_LIST_HEAD;
     44    list->p_iter = ITER_INIT_HEAD;
     45    list->p_iterIndex = PS_LIST_HEAD;
    4646
    4747    pthread_mutex_init(&(list->lock), NULL)
     
    127127
    128128        list->size++;
    129         list->iter = elem;
    130         list->iterIndex = list->size - 1;
     129        list->p_iter = elem;
     130        list->p_iterIndex = list->size - 1;
    131131    } else {
    132132        // move ourselves to the given position
     
    152152
    153153        list->size++;
    154         list->iter = elem;
    155         list->iterIndex = cursorIndex;
     154        list->p_iter = elem;
     155        list->p_iterIndex = cursorIndex;
    156156    }
    157157
     
    227227        // removed tail, so iter should be the last element of list to keep it valid
    228228        if (list->size > 0) {
    229             list->iter = list->tail;
    230             list->iterIndex = list->size - 1;
     229            list->p_iter = list->tail;
     230            list->p_iterIndex = list->size - 1;
    231231        } else {
    232             list->iter = ITER_INIT_TAIL;
     232            list->p_iter = ITER_INIT_TAIL;
    233233        }
    234234    } else {
    235235        elem->next->prev = elem->prev;
    236         list->iter = elem->next;
    237         list->iterIndex = cursorIndex;
     236        list->p_iter = elem->next;
     237        list->p_iterIndex = cursorIndex;
    238238    }
    239239
     
    275275
    276276    if (where >= (psS32)list->size) {
    277         list->iter = NULL;
     277        list->p_iter = NULL;
    278278        if (lockList) {
    279279            pthread_mutex_unlock(&list->lock)
     
    285285    switch (where) {
    286286    case PS_LIST_HEAD:
    287         list->iter = ITER_INIT_HEAD;
     287        list->p_iter = ITER_INIT_HEAD;
    288288        break;
    289289
    290290    case PS_LIST_TAIL:
    291         list->iter = ITER_INIT_TAIL;
     291        list->p_iter = ITER_INIT_TAIL;
    292292        break;
    293293
     
    297297
    298298        if (cursor != NULL) {
    299             list->iter = cursor->prev;
    300             list->iterIndex = position - 1;
     299            list->p_iter = cursor->prev;
     300            list->p_iterIndex = position - 1;
    301301        }
    302302        break;
     
    307307
    308308        if (cursor != NULL) {
    309             list->iter = cursor->next;
    310             list->iterIndex = position + 1;
     309            list->p_iter = cursor->next;
     310            list->p_iterIndex = position + 1;
    311311        }
    312312        break;
     
    322322            cursor = listGetIterator(list);
    323323            if (cursor == NULL) {      // reset the iterator if it is invalid
    324                 list->iter = ITER_INIT_HEAD;
    325                 list->iterIndex = 0;
     324                list->p_iter = ITER_INIT_HEAD;
     325                list->p_iterIndex = 0;
    326326            }
    327327
     
    357357    }
    358358
    359     if (list->iter == ITER_INIT_HEAD) {
     359    if (list->p_iter == ITER_INIT_HEAD) {
    360360        return list->head;
    361     } else if (list->iter == ITER_INIT_TAIL) {
     361    } else if (list->p_iter == ITER_INIT_TAIL) {
    362362        return list->tail;
    363363    } else {
    364         return list->iter;
     364        return list->p_iter;
    365365    }
    366366}
     
    368368psS32 listGetIteratorIndex(psList* list)
    369369{
    370     if (list->iter == ITER_INIT_HEAD) {
     370    if (list->p_iter == ITER_INIT_HEAD) {
    371371        return 0;
    372     } else if (list->iter == ITER_INIT_TAIL) {
     372    } else if (list->p_iter == ITER_INIT_TAIL) {
    373373        return list->size - 1;
    374374    } else {
    375         return list->iterIndex;
     375        return list->p_iterIndex;
    376376    }
    377377}
  • trunk/psLib/src/collections/psList.h

    r2204 r2375  
    1010 *  @ingroup LinkedList
    1111 *
    12  *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-10-27 00:57:31 $
     12 *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-11-16 20:00:20 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5252 *  directly; rather the psListAlloc should be used.
    5353 *
    54  *  @see psListAlloc, psListFree
     54 *  @see psListAlloc
    5555 */
    5656typedef struct
    5757{
    58     psU32 size;                 ///< number of elements on list
     58    psU32 size;                        ///< number of elements on list
    5959    psListElem* head;                  ///< first element on list (may be NULL)
    6060    psListElem* tail;                  ///< last element on list (may be NULL)
    61     psListElem* iter;                  ///< iteration cursor
    62     psU32 iterIndex;            ///< the numeric position of the iteration cursor in the list
     61    psArray* iterators;                ///< iterators
    6362    pthread_mutex_t lock;              ///< mutex to lock a node during changes
     63psListElem* p_iter;                ///< internal cursor for increased performance index accessing
     64int p_iterIndex;                   ///< index position of the iter.
    6465}
    6566psList;
     67
     68/** The psList iterator structure.  This should be allocated via
     69 *  psListIteratorAlloc and not directly.
     70 *
     71 *  The life span of a psListIterator object is ended by either a psFree
     72 *  of this structure OR psFree of the psList in which it operates on.
     73 *
     74 *  @see psListIteratorAlloc, psListIteratorSet, psListGetNext, psListGetPrevious
     75 */
     76typedef struct
     77{
     78psList* list;                      ///< List iterator to works on
     79psU32 number;                      ///< List iterator number
     80psListElem* cursor;                ///< current cursor position
     81bool offEnd;                       ///< Iterator off the end?
     82}
     83psListIterator;
     84
    6685
    6786/** Creates a psList linked list object.
  • trunk/psLib/src/dataIO/Makefile

    r2302 r2375  
    1616all: $(TARGET_STATIC)
    1717
    18 #psAstronomyErrors.h: psAstronomyErrors.dat
    19 #       perl ../parseErrorCodes.pl --data=$? $@
     18psFileUtilsErrors.h: psFileUtilsErrors.dat
     19        perl ../parseErrorCodes.pl --data=$? $@
    2020
    2121
  • trunk/psLib/src/dataIO/psFileUtilsErrors.dat

    r2302 r2375  
    1515psLookupTable_DIVIDE_BY_ZERO           Divide by zero error during interpolation.
    1616psLookupTable_INVALID_TYPE             Invalid psLookupType, %d;
     17#
     18psFits_NULL                            The input psFits object can not NULL.
     19psFits_FILENAME_INVALID                Could not open file,'%s'.\nCFITSIO Error: %s
     20psFits_FILENAME_NULL                   Specified filename can not be NULL.
     21psFits_EXTNAME_INVALID                 Could not find HDU '%s' in file %s.\nCFITSIO Error: %s
     22psFits_EXTNUM_INVALID                  Could not find HDU #%d in file %s.\nCFITSIO Error: %s
     23psFits_GET_EXTNUM_FAILED               Failed to determine the current HDU number in file %s.\nCFITSIO Error: %s
     24psFits_GETNUMHDUS_FAILED               Failed to determine the number of HDUs in file %s.\nCFITSIO Error: %s
     25psFits_GETHDUTYPE_FAILED               Failed to determine an HDU type in file %s.\nCFITSIO Error: %s
     26psFits_GETNUMKEYS_FAILED               Failed to determine the number of header keys in file %s.\nCFITSIO Error: %s
     27psFits_FILENAME_CREATE_FAILED          Could not create file,'%s'.\nCFITSIO Error: %s
     28psFits_TYPE_UNSUPPORTED                Specified type, %s, is not supported.
     29psFits_CREATE_HDU_FAILED               Could not create new image HDU in file,'%s'.\nCFITSIO Error: %s
     30psFits_NOT_IMAGE_TYPE                  Current FITS HDU type must be an IMAGE.
     31psFits_TABLE_FIRSTROW_NULL             Can't create a table without the first row, where table column information is derived.
     32psFits_CFITSIO_ERROR                   CFITSIO error: %s
     33psFits_METATYPE_INVALID                Specified FITS metadata type, %c, is not supported.
     34psFits_METADATA_ADD_FAILED             Failed to add metadata item, %s.
     35psFits_WRITE_FAILED                    Could not write psImage data to file,'%s'.\nCFITSIO Error: %s
     36psFits_IMAGE_NULL                      The input psImage was NULL.  Need a non-NULL psImage for operation.
  • trunk/psLib/src/dataIO/psFileUtilsErrors.h

    r2302 r2375  
    1 /** @file  psAstronomyErrors.h
     1/** @file  psFileUtilsErrors.h
    22 *
    3  *  @brief Contains the error text for the astronomy functions
     3 *  @brief Contains the error text for the fileUtils functions
    44 *
    55 *  @ingroup ErrorHandling
     
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-11-09 00:38:14 $
     9 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-11-16 20:00:21 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    1313 */
    1414
    15 #ifndef PS_SYSUTILS_ERRORS_H
    16 #define PS_SYSUTILS_ERRORS_H
     15#ifndef PS_FILEUTIL_ERRORS_H
     16#define PS_FILEUTIL_ERRORS_H
    1717
    1818/* N.B., lines between '//~Start' and '//~End' are automatic generated from
     
    3838#define PS_ERRORTEXT_psLookupTable_DIVIDE_BY_ZERO "Divide by zero error during interpolation."
    3939#define PS_ERRORTEXT_psLookupTable_INVALID_TYPE "Invalid psLookupType, %d;"
     40#define PS_ERRORTEXT_psFits_NULL "The input psFits object can not NULL."
     41#define PS_ERRORTEXT_psFits_FILENAME_INVALID "Could not open file,'%s'.\nCFITSIO Error: %s"
     42#define PS_ERRORTEXT_psFits_FILENAME_NULL "Specified filename can not be NULL."
     43#define PS_ERRORTEXT_psFits_EXTNAME_INVALID "Could not find HDU '%s' in file %s.\nCFITSIO Error: %s"
     44#define PS_ERRORTEXT_psFits_EXTNUM_INVALID "Could not find HDU #%d in file %s.\nCFITSIO Error: %s"
     45#define PS_ERRORTEXT_psFits_GET_EXTNUM_FAILED "Failed to determine the current HDU number in file %s.\nCFITSIO Error: %s"
     46#define PS_ERRORTEXT_psFits_GETNUMHDUS_FAILED "Failed to determine the number of HDUs in file %s.\nCFITSIO Error: %s"
     47#define PS_ERRORTEXT_psFits_GETHDUTYPE_FAILED "Failed to determine an HDU type in file %s.\nCFITSIO Error: %s"
     48#define PS_ERRORTEXT_psFits_GETNUMKEYS_FAILED "Failed to determine the number of header keys in file %s.\nCFITSIO Error: %s"
     49#define PS_ERRORTEXT_psFits_FILENAME_CREATE_FAILED "Could not create file,'%s'.\nCFITSIO Error: %s"
     50#define PS_ERRORTEXT_psFits_TYPE_UNSUPPORTED "Specified type, %s, is not supported."
     51#define PS_ERRORTEXT_psFits_CREATE_HDU_FAILED "Could not create new image HDU in file,'%s'.\nCFITSIO Error: %s"
     52#define PS_ERRORTEXT_psFits_NOT_IMAGE_TYPE "Current FITS HDU type must be an IMAGE."
     53#define PS_ERRORTEXT_psFits_TABLE_FIRSTROW_NULL "Can't create a table without the first row, where table column information is derived."
     54#define PS_ERRORTEXT_psFits_CFITSIO_ERROR "CFITSIO error: %s"
     55#define PS_ERRORTEXT_psFits_METATYPE_INVALID "Specified FITS metadata type, %c, is not supported."
     56#define PS_ERRORTEXT_psFits_METADATA_ADD_FAILED "Failed to add metadata item, %s."
     57#define PS_ERRORTEXT_psFits_WRITE_FAILED "Could not write psImage data to file,'%s'.\nCFITSIO Error: %s"
     58#define PS_ERRORTEXT_psFits_IMAGE_NULL "The input psImage was NULL.  Need a non-NULL psImage for operation."
    4059//~End
    4160
  • trunk/psLib/src/fileUtils/Makefile

    r2302 r2375  
    1616all: $(TARGET_STATIC)
    1717
    18 #psAstronomyErrors.h: psAstronomyErrors.dat
    19 #       perl ../parseErrorCodes.pl --data=$? $@
     18psFileUtilsErrors.h: psFileUtilsErrors.dat
     19        perl ../parseErrorCodes.pl --data=$? $@
    2020
    2121
  • trunk/psLib/src/fileUtils/psFileUtilsErrors.dat

    r2302 r2375  
    1515psLookupTable_DIVIDE_BY_ZERO           Divide by zero error during interpolation.
    1616psLookupTable_INVALID_TYPE             Invalid psLookupType, %d;
     17#
     18psFits_NULL                            The input psFits object can not NULL.
     19psFits_FILENAME_INVALID                Could not open file,'%s'.\nCFITSIO Error: %s
     20psFits_FILENAME_NULL                   Specified filename can not be NULL.
     21psFits_EXTNAME_INVALID                 Could not find HDU '%s' in file %s.\nCFITSIO Error: %s
     22psFits_EXTNUM_INVALID                  Could not find HDU #%d in file %s.\nCFITSIO Error: %s
     23psFits_GET_EXTNUM_FAILED               Failed to determine the current HDU number in file %s.\nCFITSIO Error: %s
     24psFits_GETNUMHDUS_FAILED               Failed to determine the number of HDUs in file %s.\nCFITSIO Error: %s
     25psFits_GETHDUTYPE_FAILED               Failed to determine an HDU type in file %s.\nCFITSIO Error: %s
     26psFits_GETNUMKEYS_FAILED               Failed to determine the number of header keys in file %s.\nCFITSIO Error: %s
     27psFits_FILENAME_CREATE_FAILED          Could not create file,'%s'.\nCFITSIO Error: %s
     28psFits_TYPE_UNSUPPORTED                Specified type, %s, is not supported.
     29psFits_CREATE_HDU_FAILED               Could not create new image HDU in file,'%s'.\nCFITSIO Error: %s
     30psFits_NOT_IMAGE_TYPE                  Current FITS HDU type must be an IMAGE.
     31psFits_TABLE_FIRSTROW_NULL             Can't create a table without the first row, where table column information is derived.
     32psFits_CFITSIO_ERROR                   CFITSIO error: %s
     33psFits_METATYPE_INVALID                Specified FITS metadata type, %c, is not supported.
     34psFits_METADATA_ADD_FAILED             Failed to add metadata item, %s.
     35psFits_WRITE_FAILED                    Could not write psImage data to file,'%s'.\nCFITSIO Error: %s
     36psFits_IMAGE_NULL                      The input psImage was NULL.  Need a non-NULL psImage for operation.
  • trunk/psLib/src/fileUtils/psFileUtilsErrors.h

    r2302 r2375  
    1 /** @file  psAstronomyErrors.h
     1/** @file  psFileUtilsErrors.h
    22 *
    3  *  @brief Contains the error text for the astronomy functions
     3 *  @brief Contains the error text for the fileUtils functions
    44 *
    55 *  @ingroup ErrorHandling
     
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-11-09 00:38:14 $
     9 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-11-16 20:00:21 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    1313 */
    1414
    15 #ifndef PS_SYSUTILS_ERRORS_H
    16 #define PS_SYSUTILS_ERRORS_H
     15#ifndef PS_FILEUTIL_ERRORS_H
     16#define PS_FILEUTIL_ERRORS_H
    1717
    1818/* N.B., lines between '//~Start' and '//~End' are automatic generated from
     
    3838#define PS_ERRORTEXT_psLookupTable_DIVIDE_BY_ZERO "Divide by zero error during interpolation."
    3939#define PS_ERRORTEXT_psLookupTable_INVALID_TYPE "Invalid psLookupType, %d;"
     40#define PS_ERRORTEXT_psFits_NULL "The input psFits object can not NULL."
     41#define PS_ERRORTEXT_psFits_FILENAME_INVALID "Could not open file,'%s'.\nCFITSIO Error: %s"
     42#define PS_ERRORTEXT_psFits_FILENAME_NULL "Specified filename can not be NULL."
     43#define PS_ERRORTEXT_psFits_EXTNAME_INVALID "Could not find HDU '%s' in file %s.\nCFITSIO Error: %s"
     44#define PS_ERRORTEXT_psFits_EXTNUM_INVALID "Could not find HDU #%d in file %s.\nCFITSIO Error: %s"
     45#define PS_ERRORTEXT_psFits_GET_EXTNUM_FAILED "Failed to determine the current HDU number in file %s.\nCFITSIO Error: %s"
     46#define PS_ERRORTEXT_psFits_GETNUMHDUS_FAILED "Failed to determine the number of HDUs in file %s.\nCFITSIO Error: %s"
     47#define PS_ERRORTEXT_psFits_GETHDUTYPE_FAILED "Failed to determine an HDU type in file %s.\nCFITSIO Error: %s"
     48#define PS_ERRORTEXT_psFits_GETNUMKEYS_FAILED "Failed to determine the number of header keys in file %s.\nCFITSIO Error: %s"
     49#define PS_ERRORTEXT_psFits_FILENAME_CREATE_FAILED "Could not create file,'%s'.\nCFITSIO Error: %s"
     50#define PS_ERRORTEXT_psFits_TYPE_UNSUPPORTED "Specified type, %s, is not supported."
     51#define PS_ERRORTEXT_psFits_CREATE_HDU_FAILED "Could not create new image HDU in file,'%s'.\nCFITSIO Error: %s"
     52#define PS_ERRORTEXT_psFits_NOT_IMAGE_TYPE "Current FITS HDU type must be an IMAGE."
     53#define PS_ERRORTEXT_psFits_TABLE_FIRSTROW_NULL "Can't create a table without the first row, where table column information is derived."
     54#define PS_ERRORTEXT_psFits_CFITSIO_ERROR "CFITSIO error: %s"
     55#define PS_ERRORTEXT_psFits_METATYPE_INVALID "Specified FITS metadata type, %c, is not supported."
     56#define PS_ERRORTEXT_psFits_METADATA_ADD_FAILED "Failed to add metadata item, %s."
     57#define PS_ERRORTEXT_psFits_WRITE_FAILED "Could not write psImage data to file,'%s'.\nCFITSIO Error: %s"
     58#define PS_ERRORTEXT_psFits_IMAGE_NULL "The input psImage was NULL.  Need a non-NULL psImage for operation."
    4059//~End
    4160
  • trunk/psLib/src/image/psImage.c

    r2291 r2375  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.53 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-11-06 00:44:56 $
     11 *  @version $Revision: 1.54 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-11-16 20:00:21 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2626#include "psImageErrors.h"
    2727
    28 static void imageFree(psImage* image);
     28static void imageFree(psImage* image)
     29{
     30    if (image == NULL) {
     31        return;
     32    }
     33
     34    if (image->type.type == PS_TYPE_PTR) {
     35        // 2-D array of pointers -- must dereference elements
     36        psU32 oldNumRows = image->numRows;
     37        psU32 oldNumCols = image->numCols;
     38        psPtr* rowPtr;
     39
     40        for (psU32 row = 0; row < oldNumRows; row++) {
     41            rowPtr = image->data.PTR[row];
     42            for (psU32 col = 0; col < oldNumCols; col++) {
     43                psMemDecrRefCounter(rowPtr[col]);
     44            }
     45        }
     46    }
     47
     48    if (image->parent != NULL) {
     49        psArrayRemove(image->parent->children,image);
     50        image->parent = NULL;
     51    }
     52
     53    psImageFreeChildren(image);
     54
     55    psFree(image->rawDataBuffer);
     56    psFree(image->data.V);
     57}
    2958
    3059psImage* psImageAlloc(psU32 numCols,
     
    71100}
    72101
    73 static void imageFree(psImage* image)
     102psRegion* psRegionAlloc(double x0,
     103                        double x1,
     104                        double y0,
     105                        double y1)
    74106{
    75     if (image == NULL) {
    76         return;
    77     }
    78 
    79     if (image->type.type == PS_TYPE_PTR) {
    80         // 2-D array of pointers -- must dereference elements
    81         psU32 oldNumRows = image->numRows;
    82         psU32 oldNumCols = image->numCols;
    83         psPtr* rowPtr;
    84 
    85         for (psU32 row = 0; row < oldNumRows; row++) {
    86             rowPtr = image->data.PTR[row];
    87             for (psU32 col = 0; col < oldNumCols; col++) {
    88                 psMemDecrRefCounter(rowPtr[col]);
    89             }
    90         }
    91     }
    92 
    93     if (image->parent != NULL) {
    94         psArrayRemove(image->parent->children,image);
    95         image->parent = NULL;
    96     }
    97 
    98     psImageFreeChildren(image);
    99 
    100     psFree(image->rawDataBuffer);
    101     psFree(image->data.V);
    102 }
     107    psRegion* out = psAlloc(sizeof(psRegion));
     108
     109    out->x0 = x0;
     110    out->y0 = y0;
     111    out->x1 = x1;
     112    out->y1 = y1;
     113
     114    return out;
     115}
     116
     117
     118
     119psRegion* psRegionFromString(char* region)
     120{
     121    psS32 col0;
     122    psS32 col1;
     123    psS32 row0;
     124    psS32 row1;
     125
     126    // section should be of the form '[col0:col1,row0:row1]'
     127    if (region == NULL) {
     128        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     129                PS_ERRORTEXT_psImage_SUBSECTION_NULL);
     130        return NULL;
     131    }
     132
     133    if (sscanf(region,"[%d:%d,%d:%d]",&col0,&col1,&row0,&row1) < 4) {
     134        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     135                PS_ERRORTEXT_psImage_SUBSECTION_INVALID,
     136                region);
     137        return NULL;
     138    }
     139
     140    if (col0 > col1 || row0 > row1) {
     141        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     142                PS_ERRORTEXT_psImage_SUBSET_RANGE_MALFORMED,
     143                col0,col1,row0,row1);
     144        return NULL;
     145    }
     146
     147    return psRegionAlloc(col0,col1,row0,row1);
     148}
     149
    103150
    104151psImage* psImageRecycle(psImage* old,
  • trunk/psLib/src/image/psImage.h

    r2204 r2375  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-10-27 00:57:31 $
     13 *  @version $Revision: 1.43 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2004-11-16 20:00:21 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7575psImage;
    7676
     77/** Basic image region structure.
     78 *
     79 * Struct for specifying a rectangular area in an image.
     80 *
     81 */
     82typedef struct
     83{
     84    double x0;                         ///< the first column of the region.
     85    double x1;                         ///< the last column of the region.
     86    double y0;                         ///< the first row of the region.
     87    double y1;                         ///< the last row of the region.
     88}
     89psRegion;
     90
    7791/** Create an image of the specified size and type.
    7892 *
     
    8498 */
    8599psImage* psImageAlloc(
    86     psU32 numCols,              ///< Number of rows in image.
    87     psU32 numRows,              ///< Number of columns in image.
     100    psU32 numCols,                     ///< Number of rows in image.
     101    psU32 numRows,                     ///< Number of columns in image.
    88102    const psElemType type              ///< Type of data for image.
     103);
     104
     105/** Create an image of the specified size and type.
     106 *
     107 * Uses psLib memory allocation functions to create an image struct of the
     108 * specified size and type.
     109 *
     110 * @return psImage* : Pointer to psImage.
     111 *
     112 */
     113psRegion* psRegionAlloc(
     114    double x0,                         ///< the first column of the region.
     115    double x1,                         ///< the last column of the region.
     116    double y0,                         ///< the first row of the region.
     117    double y1                          ///< the last row of the region.
     118);
     119
     120psRegion* psRegionFromString(
     121    char* region                       ///< image rectangular region in the form '[x0:x1,y0:y1]'
    89122);
    90123
     
    96129psImage* psImageRecycle(
    97130    psImage* old,                      ///< the psImage to recycle by resizing image buffer
    98     psU32 numCols,              ///< the desired number of columns in image
    99     psU32 numRows,              ///< the desired number of rows in image
     131    psU32 numCols,                     ///< the desired number of columns in image
     132    psU32 numRows,                     ///< the desired number of rows in image
    100133    const psElemType type              ///< the desired datatype of the image
    101134);
  • trunk/psLib/src/image/psImageConvolve.c

    r2273 r2375  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-11-04 01:05:00 $
     7 *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-11-16 20:00:21 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    9393                           psBool relative)
    9494{
    95     psS32 x = 0;
    96     psS32 y = 0;
    97     psS32 t = 0;
    98     psS32 deltaT;
     95    psS32 lastX;
     96    psS32 lastY;
     97    psS32 lastT;
     98    psS32 x;
     99    psS32 y;
     100    psS32 t;
    99101    psS32 oldX;
    100102    psS32 oldY;
     
    148150        ps##TYPE *xShiftData = xShifts->data.TYPE; \
    149151        ps##TYPE *yShiftData = yShifts->data.TYPE; \
    150         x = 0; \
    151         y = 0; \
    152         t = 0; \
    153         for (psS32 lcv = 0; lcv < length; lcv++) { \
    154             if (relative) { \
    155                 x += xShiftData[lcv]; \
    156                 y += yShiftData[lcv]; \
    157                 t += tShiftData[lcv]; \
    158             } else { \
    159                 x = xShiftData[lcv]; \
    160                 y = yShiftData[lcv]; \
    161                 t = tShiftData[lcv]; \
    162             } \
     152        lastX =  xShiftData[length-1]; \
     153        lastY =  yShiftData[length-1]; \
     154        \
     155        for (int lcv = 0; lcv < length; lcv++) { \
     156            x = lastX - xShiftData[lcv]; \
     157            y = lastY - yShiftData[lcv]; \
     158            \
    163159            if (x < xMin) { \
    164160                xMin = x; \
     
    172168            } \
    173169        } \
     170        \
     171        normalizeTime = 1.0 / (psKernelType)(lastT - tShiftData[0]); \
    174172        result = psKernelAlloc(xMin,xMax,yMin,yMax); \
    175173        kernel = result->kernel; \
    176174        \
    177         normalizeTime = 1.0 / (psKernelType)(t); \
     175        lastT = 0; \
     176        for (int i = 0; i < length; i++) { \
     177            t = tShiftData[i] - lastT; \
     178            x = lastX - xShiftData[i]; \
     179            y = lastY - yShiftData[i]; \
     180            \
     181            kernel[y][x] += (psKernelType)t * normalizeTime; \
     182            lastT = t; \
     183        } \
     184        break; \
     185    }
     186
     187    #define RELATIVE_KERNEL_GENERATE_CASE(TYPE) \
     188case PS_TYPE_##TYPE: { \
     189        ps##TYPE *tShiftData = tShifts->data.TYPE; \
     190        ps##TYPE *xShiftData = xShifts->data.TYPE; \
     191        ps##TYPE *yShiftData = yShifts->data.TYPE; \
     192        \
    178193        x = 0; \
    179194        y = 0; \
    180195        t = 0; \
    181         for (psS32 i = 0; i < length; i++) { \
    182             deltaT = t; \
    183             oldX = x; \
    184             oldY = y; \
    185             if (relative) { \
    186                 t += tShiftData[i]; \
    187                 x += xShiftData[i]; \
    188                 y += yShiftData[i]; \
    189             } else { \
    190                 t = tShiftData[i]; \
    191                 x = xShiftData[i]; \
    192                 y = yShiftData[i]; \
     196        \
     197        for (int lcv = length-1; lcv >= 0; lcv--) { \
     198            t += tShiftData[lcv]; \
     199            \
     200            if (x < xMin) { \
     201                xMin = x; \
     202            } else if (x > xMax) { \
     203                xMax = x; \
    193204            } \
    194             deltaT = t - deltaT; \
     205            if (y < yMin) { \
     206                yMin = y; \
     207            } else if (y > yMax) { \
     208                yMax = y; \
     209            } \
     210            x += xShiftData[lcv]; \
     211            y += yShiftData[lcv]; \
    195212            \
    196             kernel[oldY][oldX] += deltaT * normalizeTime; \
     213        } \
     214        result = psKernelAlloc(xMin,xMax,yMin,yMax); \
     215        kernel = result->kernel; \
     216        \
     217        normalizeTime = 1.0 / (psKernelType)t; \
     218        x = 0; \
     219        y = 0; \
     220        for (psS32 i = length-1; i >= 0; i--) { \
     221            kernel[y][x] += (psKernelType)(tShiftData[i]) * normalizeTime; \
     222            x += xShiftData[i]; \
     223            y += yShiftData[i]; \
     224            \
    197225        } \
    198226        break; \
    199227    }
    200228
    201     switch (xShifts->type.type) {
    202         KERNEL_GENERATE_CASE(U8);
    203         KERNEL_GENERATE_CASE(U16);
    204         KERNEL_GENERATE_CASE(U32);
    205         KERNEL_GENERATE_CASE(U64);
    206         KERNEL_GENERATE_CASE(S8);
    207         KERNEL_GENERATE_CASE(S16);
    208         KERNEL_GENERATE_CASE(S32);
    209         KERNEL_GENERATE_CASE(S64);
    210         KERNEL_GENERATE_CASE(F32);
    211         KERNEL_GENERATE_CASE(F64);
    212         KERNEL_GENERATE_CASE(C32);
    213         KERNEL_GENERATE_CASE(C64);
    214 
    215     default: {
    216             char* typeStr;
    217             PS_TYPE_NAME(typeStr,xShifts->type.type);
    218             psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    219                     PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
    220                     typeStr);
     229    if (relative) {
     230        switch (xShifts->type.type) {
     231            RELATIVE_KERNEL_GENERATE_CASE(U8);
     232            RELATIVE_KERNEL_GENERATE_CASE(U16);
     233            RELATIVE_KERNEL_GENERATE_CASE(U32);
     234            RELATIVE_KERNEL_GENERATE_CASE(U64);
     235            RELATIVE_KERNEL_GENERATE_CASE(S8);
     236            RELATIVE_KERNEL_GENERATE_CASE(S16);
     237            RELATIVE_KERNEL_GENERATE_CASE(S32);
     238            RELATIVE_KERNEL_GENERATE_CASE(S64);
     239            RELATIVE_KERNEL_GENERATE_CASE(F32);
     240            RELATIVE_KERNEL_GENERATE_CASE(F64);
     241            RELATIVE_KERNEL_GENERATE_CASE(C32);
     242            RELATIVE_KERNEL_GENERATE_CASE(C64);
     243
     244        default: {
     245                char* typeStr;
     246                PS_TYPE_NAME(typeStr,xShifts->type.type);
     247                psError(PS_ERR_BAD_PARAMETER_TYPE, true,
     248                        PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
     249                        typeStr);
     250            }
     251        }
     252    } else {
     253        switch (xShifts->type.type) {
     254            KERNEL_GENERATE_CASE(U8);
     255            KERNEL_GENERATE_CASE(U16);
     256            KERNEL_GENERATE_CASE(U32);
     257            KERNEL_GENERATE_CASE(U64);
     258            KERNEL_GENERATE_CASE(S8);
     259            KERNEL_GENERATE_CASE(S16);
     260            KERNEL_GENERATE_CASE(S32);
     261            KERNEL_GENERATE_CASE(S64);
     262            KERNEL_GENERATE_CASE(F32);
     263            KERNEL_GENERATE_CASE(F64);
     264            KERNEL_GENERATE_CASE(C32);
     265            KERNEL_GENERATE_CASE(C64);
     266
     267        default: {
     268                char* typeStr;
     269                PS_TYPE_NAME(typeStr,xShifts->type.type);
     270                psError(PS_ERR_BAD_PARAMETER_TYPE, true,
     271                        PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
     272                        typeStr);
     273            }
    221274        }
    222275    }
  • trunk/psLib/src/image/psImageErrors.h

    r2093 r2375  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-10-13 23:34:57 $
     9 *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-11-16 20:00:21 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  • trunk/psLib/src/image/psImageManip.h

    r2204 r2375  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-10-27 00:57:31 $
     13 *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2004-11-16 20:00:21 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    8383    psImage* image,                    ///< target image
    8484    const psImage* overlay,            ///< the overlay image
    85     psS32 col0,                          ///< the column to start overlay
    86     psS32 row0,                          ///< the row to start overlay
     85    psS32 col0,                        ///< the column to start overlay
     86    psS32 row0,                        ///< the row to start overlay
    8787    const char *op                     ///< the operation to perform for overlay
    8888);
     
    103103    const psImage* restrict mask,      ///< mask for input image.  If NULL, no masking is done.
    104104    psMaskType maskVal,                ///< the bits to check in mask.
    105     psU32 scale,                ///< the scale to rebin for each dimension
     105    psU32 scale,                       ///< the scale to rebin for each dimension
    106106    const psStats* stats
    107107    ///< the statistic to perform when rebinning.  Only one method should be set.
     
    121121    psImage* out,                      ///< an psImage to recycle.  If NULL, a new image is created
    122122    const psImage* in,                 ///< input image
    123     psS32 scale,                         ///< resample scaling factor
     123    psS32 scale,                       ///< resample scaling factor
    124124    psImageInterpolateMode mode        ///< the interpolation mode used in resampling
    125125);
     
    176176    psImage* out,                      ///< an psImage to recycle.  If NULL, a new image is created
    177177    const psImage* in,                 ///< input image
    178     psS32 dx,                            ///< number of pixels to roll in the x-dimension
    179     psS32 dy                             ///< number of pixels to roll in the y-dimension
     178    psS32 dx,                          ///< number of pixels to roll in the x-dimension
     179    psS32 dy                           ///< number of pixels to roll in the y-dimension
    180180);
    181181
  • trunk/psLib/src/imageops/psImageConvolve.c

    r2273 r2375  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-11-04 01:05:00 $
     7 *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-11-16 20:00:21 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    9393                           psBool relative)
    9494{
    95     psS32 x = 0;
    96     psS32 y = 0;
    97     psS32 t = 0;
    98     psS32 deltaT;
     95    psS32 lastX;
     96    psS32 lastY;
     97    psS32 lastT;
     98    psS32 x;
     99    psS32 y;
     100    psS32 t;
    99101    psS32 oldX;
    100102    psS32 oldY;
     
    148150        ps##TYPE *xShiftData = xShifts->data.TYPE; \
    149151        ps##TYPE *yShiftData = yShifts->data.TYPE; \
    150         x = 0; \
    151         y = 0; \
    152         t = 0; \
    153         for (psS32 lcv = 0; lcv < length; lcv++) { \
    154             if (relative) { \
    155                 x += xShiftData[lcv]; \
    156                 y += yShiftData[lcv]; \
    157                 t += tShiftData[lcv]; \
    158             } else { \
    159                 x = xShiftData[lcv]; \
    160                 y = yShiftData[lcv]; \
    161                 t = tShiftData[lcv]; \
    162             } \
     152        lastX =  xShiftData[length-1]; \
     153        lastY =  yShiftData[length-1]; \
     154        \
     155        for (int lcv = 0; lcv < length; lcv++) { \
     156            x = lastX - xShiftData[lcv]; \
     157            y = lastY - yShiftData[lcv]; \
     158            \
    163159            if (x < xMin) { \
    164160                xMin = x; \
     
    172168            } \
    173169        } \
     170        \
     171        normalizeTime = 1.0 / (psKernelType)(lastT - tShiftData[0]); \
    174172        result = psKernelAlloc(xMin,xMax,yMin,yMax); \
    175173        kernel = result->kernel; \
    176174        \
    177         normalizeTime = 1.0 / (psKernelType)(t); \
     175        lastT = 0; \
     176        for (int i = 0; i < length; i++) { \
     177            t = tShiftData[i] - lastT; \
     178            x = lastX - xShiftData[i]; \
     179            y = lastY - yShiftData[i]; \
     180            \
     181            kernel[y][x] += (psKernelType)t * normalizeTime; \
     182            lastT = t; \
     183        } \
     184        break; \
     185    }
     186
     187    #define RELATIVE_KERNEL_GENERATE_CASE(TYPE) \
     188case PS_TYPE_##TYPE: { \
     189        ps##TYPE *tShiftData = tShifts->data.TYPE; \
     190        ps##TYPE *xShiftData = xShifts->data.TYPE; \
     191        ps##TYPE *yShiftData = yShifts->data.TYPE; \
     192        \
    178193        x = 0; \
    179194        y = 0; \
    180195        t = 0; \
    181         for (psS32 i = 0; i < length; i++) { \
    182             deltaT = t; \
    183             oldX = x; \
    184             oldY = y; \
    185             if (relative) { \
    186                 t += tShiftData[i]; \
    187                 x += xShiftData[i]; \
    188                 y += yShiftData[i]; \
    189             } else { \
    190                 t = tShiftData[i]; \
    191                 x = xShiftData[i]; \
    192                 y = yShiftData[i]; \
     196        \
     197        for (int lcv = length-1; lcv >= 0; lcv--) { \
     198            t += tShiftData[lcv]; \
     199            \
     200            if (x < xMin) { \
     201                xMin = x; \
     202            } else if (x > xMax) { \
     203                xMax = x; \
    193204            } \
    194             deltaT = t - deltaT; \
     205            if (y < yMin) { \
     206                yMin = y; \
     207            } else if (y > yMax) { \
     208                yMax = y; \
     209            } \
     210            x += xShiftData[lcv]; \
     211            y += yShiftData[lcv]; \
    195212            \
    196             kernel[oldY][oldX] += deltaT * normalizeTime; \
     213        } \
     214        result = psKernelAlloc(xMin,xMax,yMin,yMax); \
     215        kernel = result->kernel; \
     216        \
     217        normalizeTime = 1.0 / (psKernelType)t; \
     218        x = 0; \
     219        y = 0; \
     220        for (psS32 i = length-1; i >= 0; i--) { \
     221            kernel[y][x] += (psKernelType)(tShiftData[i]) * normalizeTime; \
     222            x += xShiftData[i]; \
     223            y += yShiftData[i]; \
     224            \
    197225        } \
    198226        break; \
    199227    }
    200228
    201     switch (xShifts->type.type) {
    202         KERNEL_GENERATE_CASE(U8);
    203         KERNEL_GENERATE_CASE(U16);
    204         KERNEL_GENERATE_CASE(U32);
    205         KERNEL_GENERATE_CASE(U64);
    206         KERNEL_GENERATE_CASE(S8);
    207         KERNEL_GENERATE_CASE(S16);
    208         KERNEL_GENERATE_CASE(S32);
    209         KERNEL_GENERATE_CASE(S64);
    210         KERNEL_GENERATE_CASE(F32);
    211         KERNEL_GENERATE_CASE(F64);
    212         KERNEL_GENERATE_CASE(C32);
    213         KERNEL_GENERATE_CASE(C64);
    214 
    215     default: {
    216             char* typeStr;
    217             PS_TYPE_NAME(typeStr,xShifts->type.type);
    218             psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    219                     PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
    220                     typeStr);
     229    if (relative) {
     230        switch (xShifts->type.type) {
     231            RELATIVE_KERNEL_GENERATE_CASE(U8);
     232            RELATIVE_KERNEL_GENERATE_CASE(U16);
     233            RELATIVE_KERNEL_GENERATE_CASE(U32);
     234            RELATIVE_KERNEL_GENERATE_CASE(U64);
     235            RELATIVE_KERNEL_GENERATE_CASE(S8);
     236            RELATIVE_KERNEL_GENERATE_CASE(S16);
     237            RELATIVE_KERNEL_GENERATE_CASE(S32);
     238            RELATIVE_KERNEL_GENERATE_CASE(S64);
     239            RELATIVE_KERNEL_GENERATE_CASE(F32);
     240            RELATIVE_KERNEL_GENERATE_CASE(F64);
     241            RELATIVE_KERNEL_GENERATE_CASE(C32);
     242            RELATIVE_KERNEL_GENERATE_CASE(C64);
     243
     244        default: {
     245                char* typeStr;
     246                PS_TYPE_NAME(typeStr,xShifts->type.type);
     247                psError(PS_ERR_BAD_PARAMETER_TYPE, true,
     248                        PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
     249                        typeStr);
     250            }
     251        }
     252    } else {
     253        switch (xShifts->type.type) {
     254            KERNEL_GENERATE_CASE(U8);
     255            KERNEL_GENERATE_CASE(U16);
     256            KERNEL_GENERATE_CASE(U32);
     257            KERNEL_GENERATE_CASE(U64);
     258            KERNEL_GENERATE_CASE(S8);
     259            KERNEL_GENERATE_CASE(S16);
     260            KERNEL_GENERATE_CASE(S32);
     261            KERNEL_GENERATE_CASE(S64);
     262            KERNEL_GENERATE_CASE(F32);
     263            KERNEL_GENERATE_CASE(F64);
     264            KERNEL_GENERATE_CASE(C32);
     265            KERNEL_GENERATE_CASE(C64);
     266
     267        default: {
     268                char* typeStr;
     269                PS_TYPE_NAME(typeStr,xShifts->type.type);
     270                psError(PS_ERR_BAD_PARAMETER_TYPE, true,
     271                        PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
     272                        typeStr);
     273            }
    221274        }
    222275    }
  • trunk/psLib/src/mathtypes/psImage.c

    r2291 r2375  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.53 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-11-06 00:44:56 $
     11 *  @version $Revision: 1.54 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-11-16 20:00:21 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2626#include "psImageErrors.h"
    2727
    28 static void imageFree(psImage* image);
     28static void imageFree(psImage* image)
     29{
     30    if (image == NULL) {
     31        return;
     32    }
     33
     34    if (image->type.type == PS_TYPE_PTR) {
     35        // 2-D array of pointers -- must dereference elements
     36        psU32 oldNumRows = image->numRows;
     37        psU32 oldNumCols = image->numCols;
     38        psPtr* rowPtr;
     39
     40        for (psU32 row = 0; row < oldNumRows; row++) {
     41            rowPtr = image->data.PTR[row];
     42            for (psU32 col = 0; col < oldNumCols; col++) {
     43                psMemDecrRefCounter(rowPtr[col]);
     44            }
     45        }
     46    }
     47
     48    if (image->parent != NULL) {
     49        psArrayRemove(image->parent->children,image);
     50        image->parent = NULL;
     51    }
     52
     53    psImageFreeChildren(image);
     54
     55    psFree(image->rawDataBuffer);
     56    psFree(image->data.V);
     57}
    2958
    3059psImage* psImageAlloc(psU32 numCols,
     
    71100}
    72101
    73 static void imageFree(psImage* image)
     102psRegion* psRegionAlloc(double x0,
     103                        double x1,
     104                        double y0,
     105                        double y1)
    74106{
    75     if (image == NULL) {
    76         return;
    77     }
    78 
    79     if (image->type.type == PS_TYPE_PTR) {
    80         // 2-D array of pointers -- must dereference elements
    81         psU32 oldNumRows = image->numRows;
    82         psU32 oldNumCols = image->numCols;
    83         psPtr* rowPtr;
    84 
    85         for (psU32 row = 0; row < oldNumRows; row++) {
    86             rowPtr = image->data.PTR[row];
    87             for (psU32 col = 0; col < oldNumCols; col++) {
    88                 psMemDecrRefCounter(rowPtr[col]);
    89             }
    90         }
    91     }
    92 
    93     if (image->parent != NULL) {
    94         psArrayRemove(image->parent->children,image);
    95         image->parent = NULL;
    96     }
    97 
    98     psImageFreeChildren(image);
    99 
    100     psFree(image->rawDataBuffer);
    101     psFree(image->data.V);
    102 }
     107    psRegion* out = psAlloc(sizeof(psRegion));
     108
     109    out->x0 = x0;
     110    out->y0 = y0;
     111    out->x1 = x1;
     112    out->y1 = y1;
     113
     114    return out;
     115}
     116
     117
     118
     119psRegion* psRegionFromString(char* region)
     120{
     121    psS32 col0;
     122    psS32 col1;
     123    psS32 row0;
     124    psS32 row1;
     125
     126    // section should be of the form '[col0:col1,row0:row1]'
     127    if (region == NULL) {
     128        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     129                PS_ERRORTEXT_psImage_SUBSECTION_NULL);
     130        return NULL;
     131    }
     132
     133    if (sscanf(region,"[%d:%d,%d:%d]",&col0,&col1,&row0,&row1) < 4) {
     134        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     135                PS_ERRORTEXT_psImage_SUBSECTION_INVALID,
     136                region);
     137        return NULL;
     138    }
     139
     140    if (col0 > col1 || row0 > row1) {
     141        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     142                PS_ERRORTEXT_psImage_SUBSET_RANGE_MALFORMED,
     143                col0,col1,row0,row1);
     144        return NULL;
     145    }
     146
     147    return psRegionAlloc(col0,col1,row0,row1);
     148}
     149
    103150
    104151psImage* psImageRecycle(psImage* old,
  • trunk/psLib/src/mathtypes/psImage.h

    r2204 r2375  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-10-27 00:57:31 $
     13 *  @version $Revision: 1.43 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2004-11-16 20:00:21 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7575psImage;
    7676
     77/** Basic image region structure.
     78 *
     79 * Struct for specifying a rectangular area in an image.
     80 *
     81 */
     82typedef struct
     83{
     84    double x0;                         ///< the first column of the region.
     85    double x1;                         ///< the last column of the region.
     86    double y0;                         ///< the first row of the region.
     87    double y1;                         ///< the last row of the region.
     88}
     89psRegion;
     90
    7791/** Create an image of the specified size and type.
    7892 *
     
    8498 */
    8599psImage* psImageAlloc(
    86     psU32 numCols,              ///< Number of rows in image.
    87     psU32 numRows,              ///< Number of columns in image.
     100    psU32 numCols,                     ///< Number of rows in image.
     101    psU32 numRows,                     ///< Number of columns in image.
    88102    const psElemType type              ///< Type of data for image.
     103);
     104
     105/** Create an image of the specified size and type.
     106 *
     107 * Uses psLib memory allocation functions to create an image struct of the
     108 * specified size and type.
     109 *
     110 * @return psImage* : Pointer to psImage.
     111 *
     112 */
     113psRegion* psRegionAlloc(
     114    double x0,                         ///< the first column of the region.
     115    double x1,                         ///< the last column of the region.
     116    double y0,                         ///< the first row of the region.
     117    double y1                          ///< the last row of the region.
     118);
     119
     120psRegion* psRegionFromString(
     121    char* region                       ///< image rectangular region in the form '[x0:x1,y0:y1]'
    89122);
    90123
     
    96129psImage* psImageRecycle(
    97130    psImage* old,                      ///< the psImage to recycle by resizing image buffer
    98     psU32 numCols,              ///< the desired number of columns in image
    99     psU32 numRows,              ///< the desired number of rows in image
     131    psU32 numCols,                     ///< the desired number of columns in image
     132    psU32 numRows,                     ///< the desired number of rows in image
    100133    const psElemType type              ///< the desired datatype of the image
    101134);
  • trunk/psLib/src/types/psList.c

    r2273 r2375  
    66 *  @author Robert Daniel DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-11-04 01:04:57 $
     8 *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-11-16 20:00:20 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4242    list->size = 0;
    4343    list->head = list->tail = NULL;
    44     list->iter = ITER_INIT_HEAD;
    45     list->iterIndex = PS_LIST_HEAD;
     44    list->p_iter = ITER_INIT_HEAD;
     45    list->p_iterIndex = PS_LIST_HEAD;
    4646
    4747    pthread_mutex_init(&(list->lock), NULL)
     
    127127
    128128        list->size++;
    129         list->iter = elem;
    130         list->iterIndex = list->size - 1;
     129        list->p_iter = elem;
     130        list->p_iterIndex = list->size - 1;
    131131    } else {
    132132        // move ourselves to the given position
     
    152152
    153153        list->size++;
    154         list->iter = elem;
    155         list->iterIndex = cursorIndex;
     154        list->p_iter = elem;
     155        list->p_iterIndex = cursorIndex;
    156156    }
    157157
     
    227227        // removed tail, so iter should be the last element of list to keep it valid
    228228        if (list->size > 0) {
    229             list->iter = list->tail;
    230             list->iterIndex = list->size - 1;
     229            list->p_iter = list->tail;
     230            list->p_iterIndex = list->size - 1;
    231231        } else {
    232             list->iter = ITER_INIT_TAIL;
     232            list->p_iter = ITER_INIT_TAIL;
    233233        }
    234234    } else {
    235235        elem->next->prev = elem->prev;
    236         list->iter = elem->next;
    237         list->iterIndex = cursorIndex;
     236        list->p_iter = elem->next;
     237        list->p_iterIndex = cursorIndex;
    238238    }
    239239
     
    275275
    276276    if (where >= (psS32)list->size) {
    277         list->iter = NULL;
     277        list->p_iter = NULL;
    278278        if (lockList) {
    279279            pthread_mutex_unlock(&list->lock)
     
    285285    switch (where) {
    286286    case PS_LIST_HEAD:
    287         list->iter = ITER_INIT_HEAD;
     287        list->p_iter = ITER_INIT_HEAD;
    288288        break;
    289289
    290290    case PS_LIST_TAIL:
    291         list->iter = ITER_INIT_TAIL;
     291        list->p_iter = ITER_INIT_TAIL;
    292292        break;
    293293
     
    297297
    298298        if (cursor != NULL) {
    299             list->iter = cursor->prev;
    300             list->iterIndex = position - 1;
     299            list->p_iter = cursor->prev;
     300            list->p_iterIndex = position - 1;
    301301        }
    302302        break;
     
    307307
    308308        if (cursor != NULL) {
    309             list->iter = cursor->next;
    310             list->iterIndex = position + 1;
     309            list->p_iter = cursor->next;
     310            list->p_iterIndex = position + 1;
    311311        }
    312312        break;
     
    322322            cursor = listGetIterator(list);
    323323            if (cursor == NULL) {      // reset the iterator if it is invalid
    324                 list->iter = ITER_INIT_HEAD;
    325                 list->iterIndex = 0;
     324                list->p_iter = ITER_INIT_HEAD;
     325                list->p_iterIndex = 0;
    326326            }
    327327
     
    357357    }
    358358
    359     if (list->iter == ITER_INIT_HEAD) {
     359    if (list->p_iter == ITER_INIT_HEAD) {
    360360        return list->head;
    361     } else if (list->iter == ITER_INIT_TAIL) {
     361    } else if (list->p_iter == ITER_INIT_TAIL) {
    362362        return list->tail;
    363363    } else {
    364         return list->iter;
     364        return list->p_iter;
    365365    }
    366366}
     
    368368psS32 listGetIteratorIndex(psList* list)
    369369{
    370     if (list->iter == ITER_INIT_HEAD) {
     370    if (list->p_iter == ITER_INIT_HEAD) {
    371371        return 0;
    372     } else if (list->iter == ITER_INIT_TAIL) {
     372    } else if (list->p_iter == ITER_INIT_TAIL) {
    373373        return list->size - 1;
    374374    } else {
    375         return list->iterIndex;
     375        return list->p_iterIndex;
    376376    }
    377377}
  • trunk/psLib/src/types/psList.h

    r2204 r2375  
    1010 *  @ingroup LinkedList
    1111 *
    12  *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-10-27 00:57:31 $
     12 *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-11-16 20:00:20 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5252 *  directly; rather the psListAlloc should be used.
    5353 *
    54  *  @see psListAlloc, psListFree
     54 *  @see psListAlloc
    5555 */
    5656typedef struct
    5757{
    58     psU32 size;                 ///< number of elements on list
     58    psU32 size;                        ///< number of elements on list
    5959    psListElem* head;                  ///< first element on list (may be NULL)
    6060    psListElem* tail;                  ///< last element on list (may be NULL)
    61     psListElem* iter;                  ///< iteration cursor
    62     psU32 iterIndex;            ///< the numeric position of the iteration cursor in the list
     61    psArray* iterators;                ///< iterators
    6362    pthread_mutex_t lock;              ///< mutex to lock a node during changes
     63psListElem* p_iter;                ///< internal cursor for increased performance index accessing
     64int p_iterIndex;                   ///< index position of the iter.
    6465}
    6566psList;
     67
     68/** The psList iterator structure.  This should be allocated via
     69 *  psListIteratorAlloc and not directly.
     70 *
     71 *  The life span of a psListIterator object is ended by either a psFree
     72 *  of this structure OR psFree of the psList in which it operates on.
     73 *
     74 *  @see psListIteratorAlloc, psListIteratorSet, psListGetNext, psListGetPrevious
     75 */
     76typedef struct
     77{
     78psList* list;                      ///< List iterator to works on
     79psU32 number;                      ///< List iterator number
     80psListElem* cursor;                ///< current cursor position
     81bool offEnd;                       ///< Iterator off the end?
     82}
     83psListIterator;
     84
    6685
    6786/** Creates a psList linked list object.
Note: See TracChangeset for help on using the changeset viewer.