Changeset 2375
- Timestamp:
- Nov 16, 2004, 10:00:21 AM (22 years ago)
- Location:
- trunk/psLib
- Files:
-
- 7 added
- 22 edited
-
psLib.kdevelop.filelist (modified) (1 diff)
-
psLib.kdevelop.pcs (modified) ( previous)
-
psLib.kdevses (modified) (1 diff)
-
src/astronomy/psAstronomyErrors.h (modified) (1 diff)
-
src/collections/psList.c (modified) (12 diffs)
-
src/collections/psList.h (modified) (2 diffs)
-
src/dataIO/Makefile (modified) (1 diff)
-
src/dataIO/psFileUtilsErrors.dat (modified) (1 diff)
-
src/dataIO/psFileUtilsErrors.h (modified) (3 diffs)
-
src/dataIO/psFits.c (added)
-
src/dataIO/psFits.h (added)
-
src/fileUtils/Makefile (modified) (1 diff)
-
src/fileUtils/psFileUtilsErrors.dat (modified) (1 diff)
-
src/fileUtils/psFileUtilsErrors.h (modified) (3 diffs)
-
src/fileUtils/psFits.c (added)
-
src/fileUtils/psFits.h (added)
-
src/fits (added)
-
src/fits/psFits.c (added)
-
src/fits/psFits.h (added)
-
src/image/psImage.c (modified) (3 diffs)
-
src/image/psImage.h (modified) (4 diffs)
-
src/image/psImageConvolve.c (modified) (4 diffs)
-
src/image/psImageErrors.h (modified) (1 diff)
-
src/image/psImageManip.h (modified) (5 diffs)
-
src/imageops/psImageConvolve.c (modified) (4 diffs)
-
src/mathtypes/psImage.c (modified) (3 diffs)
-
src/mathtypes/psImage.h (modified) (4 diffs)
-
src/types/psList.c (modified) (12 diffs)
-
src/types/psList.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/psLib.kdevelop.filelist
r2285 r2375 1 1 # KDevelop Custom Project File List 2 2 tags 3 src/fileUtils/psFits.c 4 src/fileUtils/psFits.h -
trunk/psLib/psLib.kdevses
r2273 r2375 2 2 <!DOCTYPE KDevPrjSession> 3 3 <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> 5 30 <pluginList> 6 31 <kdevbookmarks> 7 32 <bookmarks/> 8 33 </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> 9 37 <kdevvalgrind> 10 38 <executable path="" params="" /> 11 39 <valgrind path="" params="" /> 40 <calltree path="" params="" /> 41 <kcachegrind path="" /> 12 42 </kdevvalgrind> 13 43 <kdevdebugger> -
trunk/psLib/src/astronomy/psAstronomyErrors.h
r2301 r2375 7 7 * @author Robert DeSonia, MHPCC 8 8 * 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 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 13 13 */ 14 14 15 #ifndef PS_ SYSUTILS_ERRORS_H16 #define PS_ SYSUTILS_ERRORS_H15 #ifndef PS_ASTRONOMY_ERRORS_H 16 #define PS_ASTRONOMY_ERRORS_H 17 17 18 18 /* N.B., lines between '//~Start' and '//~End' are automatic generated from -
trunk/psLib/src/collections/psList.c
r2273 r2375 6 6 * @author Robert Daniel DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.2 1$ $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 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 42 42 list->size = 0; 43 43 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; 46 46 47 47 pthread_mutex_init(&(list->lock), NULL) … … 127 127 128 128 list->size++; 129 list-> iter = elem;130 list-> iterIndex = list->size - 1;129 list->p_iter = elem; 130 list->p_iterIndex = list->size - 1; 131 131 } else { 132 132 // move ourselves to the given position … … 152 152 153 153 list->size++; 154 list-> iter = elem;155 list-> iterIndex = cursorIndex;154 list->p_iter = elem; 155 list->p_iterIndex = cursorIndex; 156 156 } 157 157 … … 227 227 // removed tail, so iter should be the last element of list to keep it valid 228 228 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; 231 231 } else { 232 list-> iter = ITER_INIT_TAIL;232 list->p_iter = ITER_INIT_TAIL; 233 233 } 234 234 } else { 235 235 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; 238 238 } 239 239 … … 275 275 276 276 if (where >= (psS32)list->size) { 277 list-> iter = NULL;277 list->p_iter = NULL; 278 278 if (lockList) { 279 279 pthread_mutex_unlock(&list->lock) … … 285 285 switch (where) { 286 286 case PS_LIST_HEAD: 287 list-> iter = ITER_INIT_HEAD;287 list->p_iter = ITER_INIT_HEAD; 288 288 break; 289 289 290 290 case PS_LIST_TAIL: 291 list-> iter = ITER_INIT_TAIL;291 list->p_iter = ITER_INIT_TAIL; 292 292 break; 293 293 … … 297 297 298 298 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; 301 301 } 302 302 break; … … 307 307 308 308 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; 311 311 } 312 312 break; … … 322 322 cursor = listGetIterator(list); 323 323 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; 326 326 } 327 327 … … 357 357 } 358 358 359 if (list-> iter == ITER_INIT_HEAD) {359 if (list->p_iter == ITER_INIT_HEAD) { 360 360 return list->head; 361 } else if (list-> iter == ITER_INIT_TAIL) {361 } else if (list->p_iter == ITER_INIT_TAIL) { 362 362 return list->tail; 363 363 } else { 364 return list-> iter;364 return list->p_iter; 365 365 } 366 366 } … … 368 368 psS32 listGetIteratorIndex(psList* list) 369 369 { 370 if (list-> iter == ITER_INIT_HEAD) {370 if (list->p_iter == ITER_INIT_HEAD) { 371 371 return 0; 372 } else if (list-> iter == ITER_INIT_TAIL) {372 } else if (list->p_iter == ITER_INIT_TAIL) { 373 373 return list->size - 1; 374 374 } else { 375 return list-> iterIndex;375 return list->p_iterIndex; 376 376 } 377 377 } -
trunk/psLib/src/collections/psList.h
r2204 r2375 10 10 * @ingroup LinkedList 11 11 * 12 * @version $Revision: 1.1 6$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-1 0-27 00:57:31$12 * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-11-16 20:00:20 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 52 52 * directly; rather the psListAlloc should be used. 53 53 * 54 * @see psListAlloc , psListFree54 * @see psListAlloc 55 55 */ 56 56 typedef struct 57 57 { 58 psU32 size; ///< number of elements on list58 psU32 size; ///< number of elements on list 59 59 psListElem* head; ///< first element on list (may be NULL) 60 60 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 63 62 pthread_mutex_t lock; ///< mutex to lock a node during changes 63 psListElem* p_iter; ///< internal cursor for increased performance index accessing 64 int p_iterIndex; ///< index position of the iter. 64 65 } 65 66 psList; 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 */ 76 typedef struct 77 { 78 psList* list; ///< List iterator to works on 79 psU32 number; ///< List iterator number 80 psListElem* cursor; ///< current cursor position 81 bool offEnd; ///< Iterator off the end? 82 } 83 psListIterator; 84 66 85 67 86 /** Creates a psList linked list object. -
trunk/psLib/src/dataIO/Makefile
r2302 r2375 16 16 all: $(TARGET_STATIC) 17 17 18 #psAstronomyErrors.h: psAstronomyErrors.dat19 #perl ../parseErrorCodes.pl --data=$? $@18 psFileUtilsErrors.h: psFileUtilsErrors.dat 19 perl ../parseErrorCodes.pl --data=$? $@ 20 20 21 21 -
trunk/psLib/src/dataIO/psFileUtilsErrors.dat
r2302 r2375 15 15 psLookupTable_DIVIDE_BY_ZERO Divide by zero error during interpolation. 16 16 psLookupTable_INVALID_TYPE Invalid psLookupType, %d; 17 # 18 psFits_NULL The input psFits object can not NULL. 19 psFits_FILENAME_INVALID Could not open file,'%s'.\nCFITSIO Error: %s 20 psFits_FILENAME_NULL Specified filename can not be NULL. 21 psFits_EXTNAME_INVALID Could not find HDU '%s' in file %s.\nCFITSIO Error: %s 22 psFits_EXTNUM_INVALID Could not find HDU #%d in file %s.\nCFITSIO Error: %s 23 psFits_GET_EXTNUM_FAILED Failed to determine the current HDU number in file %s.\nCFITSIO Error: %s 24 psFits_GETNUMHDUS_FAILED Failed to determine the number of HDUs in file %s.\nCFITSIO Error: %s 25 psFits_GETHDUTYPE_FAILED Failed to determine an HDU type in file %s.\nCFITSIO Error: %s 26 psFits_GETNUMKEYS_FAILED Failed to determine the number of header keys in file %s.\nCFITSIO Error: %s 27 psFits_FILENAME_CREATE_FAILED Could not create file,'%s'.\nCFITSIO Error: %s 28 psFits_TYPE_UNSUPPORTED Specified type, %s, is not supported. 29 psFits_CREATE_HDU_FAILED Could not create new image HDU in file,'%s'.\nCFITSIO Error: %s 30 psFits_NOT_IMAGE_TYPE Current FITS HDU type must be an IMAGE. 31 psFits_TABLE_FIRSTROW_NULL Can't create a table without the first row, where table column information is derived. 32 psFits_CFITSIO_ERROR CFITSIO error: %s 33 psFits_METATYPE_INVALID Specified FITS metadata type, %c, is not supported. 34 psFits_METADATA_ADD_FAILED Failed to add metadata item, %s. 35 psFits_WRITE_FAILED Could not write psImage data to file,'%s'.\nCFITSIO Error: %s 36 psFits_IMAGE_NULL The input psImage was NULL. Need a non-NULL psImage for operation. -
trunk/psLib/src/dataIO/psFileUtilsErrors.h
r2302 r2375 1 /** @file ps AstronomyErrors.h1 /** @file psFileUtilsErrors.h 2 2 * 3 * @brief Contains the error text for the astronomyfunctions3 * @brief Contains the error text for the fileUtils functions 4 4 * 5 5 * @ingroup ErrorHandling … … 7 7 * @author Robert DeSonia, MHPCC 8 8 * 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 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 13 13 */ 14 14 15 #ifndef PS_ SYSUTILS_ERRORS_H16 #define PS_ SYSUTILS_ERRORS_H15 #ifndef PS_FILEUTIL_ERRORS_H 16 #define PS_FILEUTIL_ERRORS_H 17 17 18 18 /* N.B., lines between '//~Start' and '//~End' are automatic generated from … … 38 38 #define PS_ERRORTEXT_psLookupTable_DIVIDE_BY_ZERO "Divide by zero error during interpolation." 39 39 #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." 40 59 //~End 41 60 -
trunk/psLib/src/fileUtils/Makefile
r2302 r2375 16 16 all: $(TARGET_STATIC) 17 17 18 #psAstronomyErrors.h: psAstronomyErrors.dat19 #perl ../parseErrorCodes.pl --data=$? $@18 psFileUtilsErrors.h: psFileUtilsErrors.dat 19 perl ../parseErrorCodes.pl --data=$? $@ 20 20 21 21 -
trunk/psLib/src/fileUtils/psFileUtilsErrors.dat
r2302 r2375 15 15 psLookupTable_DIVIDE_BY_ZERO Divide by zero error during interpolation. 16 16 psLookupTable_INVALID_TYPE Invalid psLookupType, %d; 17 # 18 psFits_NULL The input psFits object can not NULL. 19 psFits_FILENAME_INVALID Could not open file,'%s'.\nCFITSIO Error: %s 20 psFits_FILENAME_NULL Specified filename can not be NULL. 21 psFits_EXTNAME_INVALID Could not find HDU '%s' in file %s.\nCFITSIO Error: %s 22 psFits_EXTNUM_INVALID Could not find HDU #%d in file %s.\nCFITSIO Error: %s 23 psFits_GET_EXTNUM_FAILED Failed to determine the current HDU number in file %s.\nCFITSIO Error: %s 24 psFits_GETNUMHDUS_FAILED Failed to determine the number of HDUs in file %s.\nCFITSIO Error: %s 25 psFits_GETHDUTYPE_FAILED Failed to determine an HDU type in file %s.\nCFITSIO Error: %s 26 psFits_GETNUMKEYS_FAILED Failed to determine the number of header keys in file %s.\nCFITSIO Error: %s 27 psFits_FILENAME_CREATE_FAILED Could not create file,'%s'.\nCFITSIO Error: %s 28 psFits_TYPE_UNSUPPORTED Specified type, %s, is not supported. 29 psFits_CREATE_HDU_FAILED Could not create new image HDU in file,'%s'.\nCFITSIO Error: %s 30 psFits_NOT_IMAGE_TYPE Current FITS HDU type must be an IMAGE. 31 psFits_TABLE_FIRSTROW_NULL Can't create a table without the first row, where table column information is derived. 32 psFits_CFITSIO_ERROR CFITSIO error: %s 33 psFits_METATYPE_INVALID Specified FITS metadata type, %c, is not supported. 34 psFits_METADATA_ADD_FAILED Failed to add metadata item, %s. 35 psFits_WRITE_FAILED Could not write psImage data to file,'%s'.\nCFITSIO Error: %s 36 psFits_IMAGE_NULL The input psImage was NULL. Need a non-NULL psImage for operation. -
trunk/psLib/src/fileUtils/psFileUtilsErrors.h
r2302 r2375 1 /** @file ps AstronomyErrors.h1 /** @file psFileUtilsErrors.h 2 2 * 3 * @brief Contains the error text for the astronomyfunctions3 * @brief Contains the error text for the fileUtils functions 4 4 * 5 5 * @ingroup ErrorHandling … … 7 7 * @author Robert DeSonia, MHPCC 8 8 * 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 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 13 13 */ 14 14 15 #ifndef PS_ SYSUTILS_ERRORS_H16 #define PS_ SYSUTILS_ERRORS_H15 #ifndef PS_FILEUTIL_ERRORS_H 16 #define PS_FILEUTIL_ERRORS_H 17 17 18 18 /* N.B., lines between '//~Start' and '//~End' are automatic generated from … … 38 38 #define PS_ERRORTEXT_psLookupTable_DIVIDE_BY_ZERO "Divide by zero error during interpolation." 39 39 #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." 40 59 //~End 41 60 -
trunk/psLib/src/image/psImage.c
r2291 r2375 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.5 3$ $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 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 26 26 #include "psImageErrors.h" 27 27 28 static void imageFree(psImage* image); 28 static 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 } 29 58 30 59 psImage* psImageAlloc(psU32 numCols, … … 71 100 } 72 101 73 static void imageFree(psImage* image) 102 psRegion* psRegionAlloc(double x0, 103 double x1, 104 double y0, 105 double y1) 74 106 { 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 119 psRegion* 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 103 150 104 151 psImage* psImageRecycle(psImage* old, -
trunk/psLib/src/image/psImage.h
r2204 r2375 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.4 2$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-1 0-27 00:57:31 $13 * @version $Revision: 1.43 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-11-16 20:00:21 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 75 75 psImage; 76 76 77 /** Basic image region structure. 78 * 79 * Struct for specifying a rectangular area in an image. 80 * 81 */ 82 typedef 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 } 89 psRegion; 90 77 91 /** Create an image of the specified size and type. 78 92 * … … 84 98 */ 85 99 psImage* 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. 88 102 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 */ 113 psRegion* 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 120 psRegion* psRegionFromString( 121 char* region ///< image rectangular region in the form '[x0:x1,y0:y1]' 89 122 ); 90 123 … … 96 129 psImage* psImageRecycle( 97 130 psImage* old, ///< the psImage to recycle by resizing image buffer 98 psU32 numCols, ///< the desired number of columns in image99 psU32 numRows, ///< the desired number of rows in image131 psU32 numCols, ///< the desired number of columns in image 132 psU32 numRows, ///< the desired number of rows in image 100 133 const psElemType type ///< the desired datatype of the image 101 134 ); -
trunk/psLib/src/image/psImageConvolve.c
r2273 r2375 5 5 * @author Robert DeSonia, MHPCC 6 6 * 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 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 93 93 psBool relative) 94 94 { 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; 99 101 psS32 oldX; 100 102 psS32 oldY; … … 148 150 ps##TYPE *xShiftData = xShifts->data.TYPE; \ 149 151 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 \ 163 159 if (x < xMin) { \ 164 160 xMin = x; \ … … 172 168 } \ 173 169 } \ 170 \ 171 normalizeTime = 1.0 / (psKernelType)(lastT - tShiftData[0]); \ 174 172 result = psKernelAlloc(xMin,xMax,yMin,yMax); \ 175 173 kernel = result->kernel; \ 176 174 \ 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) \ 188 case 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 \ 178 193 x = 0; \ 179 194 y = 0; \ 180 195 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; \ 193 204 } \ 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]; \ 195 212 \ 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 \ 197 225 } \ 198 226 break; \ 199 227 } 200 228 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 } 221 274 } 222 275 } -
trunk/psLib/src/image/psImageErrors.h
r2093 r2375 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-1 0-13 23:34:57$9 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-11-16 20:00:21 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii -
trunk/psLib/src/image/psImageManip.h
r2204 r2375 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.1 4$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-1 0-27 00:57:31 $13 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-11-16 20:00:21 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 83 83 psImage* image, ///< target image 84 84 const psImage* overlay, ///< the overlay image 85 psS32 col0, ///< the column to start overlay86 psS32 row0, ///< the row to start overlay85 psS32 col0, ///< the column to start overlay 86 psS32 row0, ///< the row to start overlay 87 87 const char *op ///< the operation to perform for overlay 88 88 ); … … 103 103 const psImage* restrict mask, ///< mask for input image. If NULL, no masking is done. 104 104 psMaskType maskVal, ///< the bits to check in mask. 105 psU32 scale, ///< the scale to rebin for each dimension105 psU32 scale, ///< the scale to rebin for each dimension 106 106 const psStats* stats 107 107 ///< the statistic to perform when rebinning. Only one method should be set. … … 121 121 psImage* out, ///< an psImage to recycle. If NULL, a new image is created 122 122 const psImage* in, ///< input image 123 psS32 scale, ///< resample scaling factor123 psS32 scale, ///< resample scaling factor 124 124 psImageInterpolateMode mode ///< the interpolation mode used in resampling 125 125 ); … … 176 176 psImage* out, ///< an psImage to recycle. If NULL, a new image is created 177 177 const psImage* in, ///< input image 178 psS32 dx, ///< number of pixels to roll in the x-dimension179 psS32 dy ///< number of pixels to roll in the y-dimension178 psS32 dx, ///< number of pixels to roll in the x-dimension 179 psS32 dy ///< number of pixels to roll in the y-dimension 180 180 ); 181 181 -
trunk/psLib/src/imageops/psImageConvolve.c
r2273 r2375 5 5 * @author Robert DeSonia, MHPCC 6 6 * 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 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 93 93 psBool relative) 94 94 { 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; 99 101 psS32 oldX; 100 102 psS32 oldY; … … 148 150 ps##TYPE *xShiftData = xShifts->data.TYPE; \ 149 151 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 \ 163 159 if (x < xMin) { \ 164 160 xMin = x; \ … … 172 168 } \ 173 169 } \ 170 \ 171 normalizeTime = 1.0 / (psKernelType)(lastT - tShiftData[0]); \ 174 172 result = psKernelAlloc(xMin,xMax,yMin,yMax); \ 175 173 kernel = result->kernel; \ 176 174 \ 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) \ 188 case 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 \ 178 193 x = 0; \ 179 194 y = 0; \ 180 195 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; \ 193 204 } \ 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]; \ 195 212 \ 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 \ 197 225 } \ 198 226 break; \ 199 227 } 200 228 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 } 221 274 } 222 275 } -
trunk/psLib/src/mathtypes/psImage.c
r2291 r2375 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.5 3$ $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 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 26 26 #include "psImageErrors.h" 27 27 28 static void imageFree(psImage* image); 28 static 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 } 29 58 30 59 psImage* psImageAlloc(psU32 numCols, … … 71 100 } 72 101 73 static void imageFree(psImage* image) 102 psRegion* psRegionAlloc(double x0, 103 double x1, 104 double y0, 105 double y1) 74 106 { 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 119 psRegion* 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 103 150 104 151 psImage* psImageRecycle(psImage* old, -
trunk/psLib/src/mathtypes/psImage.h
r2204 r2375 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.4 2$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-1 0-27 00:57:31 $13 * @version $Revision: 1.43 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-11-16 20:00:21 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 75 75 psImage; 76 76 77 /** Basic image region structure. 78 * 79 * Struct for specifying a rectangular area in an image. 80 * 81 */ 82 typedef 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 } 89 psRegion; 90 77 91 /** Create an image of the specified size and type. 78 92 * … … 84 98 */ 85 99 psImage* 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. 88 102 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 */ 113 psRegion* 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 120 psRegion* psRegionFromString( 121 char* region ///< image rectangular region in the form '[x0:x1,y0:y1]' 89 122 ); 90 123 … … 96 129 psImage* psImageRecycle( 97 130 psImage* old, ///< the psImage to recycle by resizing image buffer 98 psU32 numCols, ///< the desired number of columns in image99 psU32 numRows, ///< the desired number of rows in image131 psU32 numCols, ///< the desired number of columns in image 132 psU32 numRows, ///< the desired number of rows in image 100 133 const psElemType type ///< the desired datatype of the image 101 134 ); -
trunk/psLib/src/types/psList.c
r2273 r2375 6 6 * @author Robert Daniel DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.2 1$ $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 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 42 42 list->size = 0; 43 43 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; 46 46 47 47 pthread_mutex_init(&(list->lock), NULL) … … 127 127 128 128 list->size++; 129 list-> iter = elem;130 list-> iterIndex = list->size - 1;129 list->p_iter = elem; 130 list->p_iterIndex = list->size - 1; 131 131 } else { 132 132 // move ourselves to the given position … … 152 152 153 153 list->size++; 154 list-> iter = elem;155 list-> iterIndex = cursorIndex;154 list->p_iter = elem; 155 list->p_iterIndex = cursorIndex; 156 156 } 157 157 … … 227 227 // removed tail, so iter should be the last element of list to keep it valid 228 228 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; 231 231 } else { 232 list-> iter = ITER_INIT_TAIL;232 list->p_iter = ITER_INIT_TAIL; 233 233 } 234 234 } else { 235 235 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; 238 238 } 239 239 … … 275 275 276 276 if (where >= (psS32)list->size) { 277 list-> iter = NULL;277 list->p_iter = NULL; 278 278 if (lockList) { 279 279 pthread_mutex_unlock(&list->lock) … … 285 285 switch (where) { 286 286 case PS_LIST_HEAD: 287 list-> iter = ITER_INIT_HEAD;287 list->p_iter = ITER_INIT_HEAD; 288 288 break; 289 289 290 290 case PS_LIST_TAIL: 291 list-> iter = ITER_INIT_TAIL;291 list->p_iter = ITER_INIT_TAIL; 292 292 break; 293 293 … … 297 297 298 298 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; 301 301 } 302 302 break; … … 307 307 308 308 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; 311 311 } 312 312 break; … … 322 322 cursor = listGetIterator(list); 323 323 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; 326 326 } 327 327 … … 357 357 } 358 358 359 if (list-> iter == ITER_INIT_HEAD) {359 if (list->p_iter == ITER_INIT_HEAD) { 360 360 return list->head; 361 } else if (list-> iter == ITER_INIT_TAIL) {361 } else if (list->p_iter == ITER_INIT_TAIL) { 362 362 return list->tail; 363 363 } else { 364 return list-> iter;364 return list->p_iter; 365 365 } 366 366 } … … 368 368 psS32 listGetIteratorIndex(psList* list) 369 369 { 370 if (list-> iter == ITER_INIT_HEAD) {370 if (list->p_iter == ITER_INIT_HEAD) { 371 371 return 0; 372 } else if (list-> iter == ITER_INIT_TAIL) {372 } else if (list->p_iter == ITER_INIT_TAIL) { 373 373 return list->size - 1; 374 374 } else { 375 return list-> iterIndex;375 return list->p_iterIndex; 376 376 } 377 377 } -
trunk/psLib/src/types/psList.h
r2204 r2375 10 10 * @ingroup LinkedList 11 11 * 12 * @version $Revision: 1.1 6$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-1 0-27 00:57:31$12 * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-11-16 20:00:20 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 52 52 * directly; rather the psListAlloc should be used. 53 53 * 54 * @see psListAlloc , psListFree54 * @see psListAlloc 55 55 */ 56 56 typedef struct 57 57 { 58 psU32 size; ///< number of elements on list58 psU32 size; ///< number of elements on list 59 59 psListElem* head; ///< first element on list (may be NULL) 60 60 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 63 62 pthread_mutex_t lock; ///< mutex to lock a node during changes 63 psListElem* p_iter; ///< internal cursor for increased performance index accessing 64 int p_iterIndex; ///< index position of the iter. 64 65 } 65 66 psList; 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 */ 76 typedef struct 77 { 78 psList* list; ///< List iterator to works on 79 psU32 number; ///< List iterator number 80 psListElem* cursor; ///< current cursor position 81 bool offEnd; ///< Iterator off the end? 82 } 83 psListIterator; 84 66 85 67 86 /** Creates a psList linked list object.
Note:
See TracChangeset
for help on using the changeset viewer.
