Doxygen Source Code Documentation
SUMA_ParseCommands.c File Reference
#include "SUMA_suma.h"Go to the source code of this file.
Defines | |
| #define | DEBUG_3 |
Functions | |
| SUMA_ENGINE_CODE | SUMA_GetListNextCommand (DList *list) |
| Returns the code for the next command (at the tail of the list). CommandCode = SUMA_GetListNextCommand (list);. | |
| int | SUMA_GetNextCommand (char *S, char d, char term, char *Scom) |
| int | SUMA_CommandCode (char *Scom) |
| const char * | SUMA_ColMixModeString (SUMA_COL_MIX_MODE mode) |
| const char * | SUMA_DomainKinships_String (SUMA_DOMAIN_KINSHIPS code) |
| const char * | SUMA_CommandString (SUMA_ENGINE_CODE code) |
| Transforms a command code into a string for human consumption const char *SUMA_CommandString (SUMA_ENGINE_CODE code);. | |
| const char * | SUMA_SurfaceTypeString (SUMA_SO_File_Type tp) |
| Returns the name (string) of a surface type. | |
| SUMA_SO_File_Type | SUMA_SurfaceTypeCode (char *cd) |
| Returns the code for a surface's file type. | |
| SUMA_Boolean | SUMA_RegisterCommand (char *S, char d, char term, char *Scom, SUMA_Boolean Prepend) |
| const char * | SUMA_EngineFieldString (SUMA_ENGINE_FIELD_CODE i) |
| translates SUMA_ENGINE_FIELD_CODE to string | |
| SUMA_ENGINE_FIELD_CODE | SUMA_EngineFieldCode (char *Scom) |
| int | SUMA_EngineSourceCode (char *Scom) |
| void | SUMA_EngineSourceString (char *Scom, int i) |
| SUMA_Boolean | SUMA_RegisterMessage (DList *list, char *Message, char *Source, SUMA_MESSAGE_TYPES Type, SUMA_MESSAGE_ACTION Action) |
| Appends a new message to the list of SUMA messages, making sure the number of messages does not exceed SUMA_MAX_MESSAGES Ans = SUMA_RegisterMessage ( list, Message, Source, Type, Action );. | |
| char * | SUMA_BuildMessageLog (DList *ML) |
| forms a string out of all the messages in the Message list | |
| DListElmt * | SUMA_RegisterEngineListCommand (DList *list, SUMA_EngineData *EngineData, SUMA_ENGINE_FIELD_CODE Fld, void *FldValp, SUMA_ENGINE_SOURCE Src, void *Srcp, SUMA_Boolean PassByPointer, SUMA_ENGINE_INSERT_LOCATION InsertAt, DListElmt *Element) |
| Adds a new element to the list of commands for SUMA_Engine. NewElement = SUMA_RegisterEngineListCommand ( list, EngineData, FldCode, FldValp, SourceCode, SourcePointer, PassByPointer, InsertAt, Element);. | |
| SUMA_Boolean | SUMA_RegisterEngineData (SUMA_EngineData *ED, char *Fldname, void *FldValp, char *DestName, char *SourceName, SUMA_Boolean PassByPointer) |
| SUMA_EngineData * | SUMA_InitializeEngineListData (SUMA_ENGINE_CODE CommandCode) |
| allocate and initialize the data structure for EngineData SUMA_EngineData *SUMA_InitializeEngineListData (SUMA_ENGINE_CODE CommandCode); | |
| void | SUMA_FreeActionStackData (void *asdata) |
| void | SUMA_ReleaseActionStackData (void *asdata) |
| void | SUMA_FreeMessageListData (void *Hv) |
| free a message structure and any allocated space in its fields | |
| void | SUMA_FreeEngineListData (void *EDv) |
| free an engine data structure and any allocated space in its fields SUMA_FreeEngineListData (EDv); | |
| SUMA_Boolean | SUMA_FreeEngineData (SUMA_EngineData *ED) |
| SUMA_Boolean | SUMA_ReleaseEngineListElement (DList *list, DListElmt *element) |
| removes an element from the list, frees the data structure associated with the removed element ans = SUMA_ReleaseEngineListElement (list, element) | |
| SUMA_Boolean | SUMA_ReleaseMessageListElement (DList *list, DListElmt *element) |
| removes an element from the list, frees the data structure associated with the removed element ans = SUMA_ReleaseMessageListElement (list, element) | |
| DList * | SUMA_DestroyList (DList *list) |
| destroys a list IF IT IS EMPTY ! list = SUMA_DestroyList (list); | |
| DList * | SUMA_EmptyDestroyList (DList *list) |
| destroys a list even if it is not empty list = SUMA_DestroyList (list); | |
| DList * | SUMA_CreateActionStack (void) |
| creates a list for the Action Stack list = SUMA_CreateActionStack (); | |
| DList * | SUMA_EmptyDestroyActionStack (DList *AS) |
| destroys the Action Stack ans = SUMA_DestroyActionStack (DList *AS); | |
| DList * | SUMA_CreateMessageList (void) |
| creates a list for the message list list = SUMA_CreateMessageList (); | |
| DList * | SUMA_CreateList (void) |
| creates a list for SUMA_Engine list = SUMA_CreateList (); | |
| SUMA_Boolean | SUMA_ReleaseEngineData (SUMA_EngineData *ED, char *Location) |
| void | SUMA_ShowList (DList *list, FILE *Out) |
| Writes the commands to be executed in list SUMA_ShowList (list, Out);. | |
| SUMA_SO_File_Type | SUMA_guess_surftype_argv (char *str) |
| looks for words in str to guess what surface type is being mentioned | |
| void * | SUMA_AdvancePastNumbers (char *op, char **opend, SUMA_VARTYPE tp) |
| Reads in a sequence of numbers of an undetermined length Not for reading in large numbers of numbers! | |
| void * | SUMA_strtol_vec (char *op, int nvals, int *nread, SUMA_VARTYPE vtp) |
| change a character string of numbers to a vector of values. op must be NULL terminated! | |
| SUMA_GENERIC_PROG_OPTIONS_STRUCT * | SUMA_Alloc_Generic_Prog_Options_Struct (void) |
| a function to allocate and initialize the option structure that is to be used by most programs. | |
| SUMA_GENERIC_PROG_OPTIONS_STRUCT * | SUMA_Free_Generic_Prog_Options_Struct (SUMA_GENERIC_PROG_OPTIONS_STRUCT *Opt) |
| SUMA_GENERIC_ARGV_PARSE * | SUMA_CreateGenericArgParse (char *optflags) |
| SUMA_GENERIC_ARGV_PARSE * | SUMA_FreeGenericArgParse (SUMA_GENERIC_ARGV_PARSE *ps) |
| char * | SUMA_help_IO_Args (SUMA_GENERIC_ARGV_PARSE *opt) |
| SUMA_GENERIC_ARGV_PARSE * | SUMA_Parse_IO_Args (int argc, char *argv[], char *optflags) |
Variables | |
| SUMA_CommonFields * | SUMAg_CF |
Define Documentation
|
|
Definition at line 2 of file SUMA_ParseCommands.c. |
Function Documentation
|
||||||||||||||||
|
Reads in a sequence of numbers of an undetermined length Not for reading in large numbers of numbers!
Definition at line 2478 of file SUMA_ParseCommands.c. References i, LocalHead, SUMA_IVEC::n, SUMA_FVEC::n, SUMA_DVEC::n, SUMA_ADVANCE_PAST_NUM, SUMA_Boolean, SUMA_calloc, SUMA_double, SUMA_ENTRY, SUMA_float, SUMA_free, SUMA_int, SUMA_malloc, SUMA_notypeset, SUMA_realloc, SUMA_RETURN, SUMA_SL_Crit, SUMA_SL_Err, SUMA_SL_Warn, SUMA_VARTYPE, SUMA_IVEC::v, SUMA_FVEC::v, and SUMA_DVEC::v. Referenced by SUMA_OpenDx_Object_Header_Field().
02479 {
02480 static char FuncName[]={"SUMA_AdvancePastNumbers"};
02481 double *d=NULL, db;
02482 int nrealloc = 0, Chunk = 100, nalloc = 0;
02483 int Found = 0, i, nread;
02484 void *ans;
02485 SUMA_Boolean LocalHead = NOPE;
02486
02487 SUMA_ENTRY;
02488
02489 nread = 0;
02490 Found = 1;
02491 while (Found) {
02492 SUMA_ADVANCE_PAST_NUM(op, db, Found);
02493 if (Found) {
02494 if (nread == nalloc) {
02495 nalloc += Chunk; ++nrealloc;
02496 d = (double*)SUMA_realloc(d, nalloc*sizeof(double));
02497 if (!d) { SUMA_SL_Crit("Failed to allocate"); if (d) SUMA_free(d); d = NULL; SUMA_RETURN(NULL); }
02498 if (!(nrealloc % 10)) { SUMA_SL_Warn("Too much reallocation, improper use of function?"); }
02499 }
02500 d[nread] = db;
02501 ++(nread);
02502 }
02503 }
02504
02505 if (LocalHead) {
02506 fprintf(SUMA_STDERR,"%s: Found %d numbers:\n", FuncName, nread);
02507 for (i=0; i<nread; ++i) fprintf(SUMA_STDERR,"%f\t", d[i]);
02508 fprintf(SUMA_STDERR,"\n");
02509 }
02510
02511 if (opend) *opend = op;
02512
02513 ans = NULL;
02514 switch (tp) {
02515 case SUMA_int:
02516 {
02517 SUMA_IVEC *ivec= (SUMA_IVEC *)SUMA_malloc(sizeof(SUMA_IVEC));
02518 ivec->v = (int *)SUMA_calloc(nread,sizeof(int));
02519 ivec->n = nread;
02520 for (i=0; i<nread; ++i) ivec->v[i] = (int)d[i];
02521 ans = (void *)ivec;
02522 }
02523 break;
02524 case SUMA_float:
02525 {
02526 SUMA_FVEC *fvec= (SUMA_FVEC *)SUMA_malloc(sizeof(SUMA_FVEC));
02527 fvec->v = (float *)SUMA_calloc(nread,sizeof(float));
02528 fvec->n = nread;
02529 for (i=0; i<nread; ++i) fvec->v[i] = (float)d[i];
02530 ans = (void *)fvec;
02531 }
02532 break;
02533 case SUMA_double:
02534 {
02535 SUMA_DVEC *dvec= (SUMA_DVEC *)SUMA_malloc(sizeof(SUMA_DVEC));
02536 dvec->v = (double *)SUMA_calloc(nread,sizeof(double));
02537 dvec->n = nread;
02538 for (i=0; i<nread; ++i) dvec->v[i] = (double)d[i];
02539 ans = (void *)dvec;
02540 }
02541 break;
02542 case SUMA_notypeset:
02543 SUMA_SL_Err("Type not set");
02544 ans = NULL;
02545 break;
02546 default:
02547 SUMA_SL_Err("Type not supported by this function");
02548 ans = NULL;
02549 break;
02550
02551 }
02552 if (d) SUMA_free(d); d = NULL;
02553
02554 SUMA_RETURN(ans);
02555
02556 }
|
|
|
|
forms a string out of all the messages in the Message list
Definition at line 790 of file SUMA_ParseCommands.c. References DListElmt_::data, dlist_head, dlist_next, SUMA_STRING::s, DList_::size, SMT_Text, SUMA_ENTRY, SUMA_free, SUMA_RETURN, SUMA_StringAppend(), and SUMA_MessageData::Type. Referenced by SUMA_Engine().
00791 {
00792 static char FuncName[]={"SUMA_BuildMessageLog"};
00793 char *s=NULL;
00794 SUMA_STRING *SS = NULL;
00795 SUMA_MessageData *MD=NULL;
00796 DListElmt *CurElmt=NULL;
00797
00798 SUMA_ENTRY;
00799
00800
00801 if (!ML->size) { /* Nothing */
00802 SUMA_RETURN (NULL);
00803 }
00804
00805 SS = SUMA_StringAppend (NULL, NULL);
00806
00807 if (!(CurElmt = dlist_head(ML))) {
00808 SUMA_RETURN (NULL);
00809 }
00810 do {
00811 MD = (SUMA_MessageData *)CurElmt->data;
00812 SS = SUMA_StringAppend (SS, SUMA_FormatMessage (MD));
00813 if (MD->Type != SMT_Text)SS = SUMA_StringAppend (SS, "---------------------\n");
00814 } while ((CurElmt = dlist_next(CurElmt)));
00815
00816 /* clean SS */
00817 SS = SUMA_StringAppend (SS, NULL);
00818 /* copy s pointer and free SS */
00819 s = SS->s;
00820 SUMA_free(SS);
00821
00822 SUMA_RETURN (s);
00823
00824 }
|
|
|
Definition at line 204 of file SUMA_ParseCommands.c. References SUMA_4AML, SUMA_BAD_MODE, SUMA_COL_MIX_MODE, SUMA_ENTRY, SUMA_ORIG_MIX_MODE, and SUMA_RETURN. Referenced by SUMA_input().
00205 {
00206 static char FuncName[]={"SUMA_ColMixModeString"};
00207
00208 SUMA_ENTRY;
00209
00210 switch (mode) {
00211 case SUMA_BAD_MODE:
00212 SUMA_RETURN("BadMode");
00213 case SUMA_ORIG_MIX_MODE:
00214 SUMA_RETURN("ORIG");
00215 case SUMA_4AML:
00216 SUMA_RETURN("MOD1");
00217 default:
00218 SUMA_RETURN("VeryBadMode");
00219 }
00220
00221 }
|
|
|
Definition at line 129 of file SUMA_ParseCommands.c. References SE_BadCode, SE_BindCrossHair, SE_CloseStream4All, SE_Empty, SE_FlipLight0Pos, SE_FOVreset, SE_GetNearestNode, SE_Help, SE_Help_Cmap, SE_HighlightNodes, SE_Home, SE_Home_AllVisible, SE_Load_Group, SE_LoadSegDO, SE_LoadViewFileSelection, SE_LockCrossHair, SE_Log, SE_OpenCmapFileSelection, SE_OpenColFileSelection, SE_OpenDrawnROIFileSelection, SE_OpenDrawROI, SE_OpenDsetFileSelection, SE_Redisplay, SE_Redisplay_AllVisible, SE_RedisplayNow, SE_RedisplayNow_AllOtherVisible, SE_RedisplayNow_AllVisible, SE_ResetOpenGLState, SE_SaveDrawnROIFileSelection, SE_SaveSOFileSelection, SE_SaveViewFileSelection, SE_SendColorMapToAfni, SE_SetAfniCrossHair, SE_SetAfniSurf, SE_SetAfniSurfList, SE_SetAfniThisSurf, SE_SetCrossHair, SE_SetForceAfniSurf, SE_SetLight0Pos, SE_SetLockAllCrossHair, SE_SetLookAt, SE_SetLookAtNode, SE_SetLookFrom, SE_SetNodeColor, SE_SetRenderMode, SE_SetRotMatrix, SE_SetSelectedFaceSet, SE_SetSelectedNode, SE_SetSOinFocus, SE_StartListening, SE_ToggleBackground, SE_ToggleConnected, SE_ToggleCrossHair, SE_ToggleForeground, SE_ToggleLockAllCrossHair, SE_ToggleLockAllViews, SE_ToggleLockView, SE_ToggleShowSelectedFaceSet, SE_ToggleShowSelectedNode, SE_UpdateLog, SUMA_ENTRY, and SUMA_RETURN. Referenced by SUMA_GetNextCommand(), SUMA_RegisterEngineData(), and SUMA_ReleaseEngineData().
00130 {
00131 static char FuncName[]={"SUMA_CommandCode"};
00132
00133 SUMA_ENTRY;
00134
00135 if (!strlen(Scom)) SUMA_RETURN (SE_Empty);
00136 if (strcmp(Scom,"~") == 0) SUMA_RETURN (SE_Empty);
00137
00138 /*fprintf(stdout,"Looking for %s\n", Scom);*/
00139 if (!strcmp(Scom,"SetLookAt")) SUMA_RETURN(SE_SetLookAt);
00140 if (!strcmp(Scom,"SetLookFrom")) SUMA_RETURN(SE_SetLookFrom);
00141 if (!strcmp(Scom,"Redisplay")) SUMA_RETURN(SE_Redisplay);
00142 if (!strcmp(Scom,"RedisplayNow")) SUMA_RETURN(SE_RedisplayNow);
00143 if (!strcmp(Scom,"Redisplay_AllVisible")) SUMA_RETURN(SE_Redisplay_AllVisible);
00144 if (!strcmp(Scom,"SetNodeColor")) SUMA_RETURN (SE_SetNodeColor);
00145 if (!strcmp(Scom,"FlipLight0Pos")) SUMA_RETURN(SE_FlipLight0Pos);
00146 if (!strcmp(Scom,"GetNearestNode")) SUMA_RETURN (SE_GetNearestNode);
00147 if (!strcmp(Scom,"SetLookAtNode")) SUMA_RETURN (SE_SetLookAtNode);
00148 if (!strcmp(Scom,"SetRotMatrix")) SUMA_RETURN (SE_SetRotMatrix);
00149 if (!strcmp(Scom,"SetCrossHair")) SUMA_RETURN (SE_SetCrossHair);
00150 if (!strcmp(Scom,"ToggleCrossHair")) SUMA_RETURN (SE_ToggleCrossHair);
00151 if (!strcmp(Scom,"HighlightNodes")) SUMA_RETURN (SE_HighlightNodes);
00152 if (!strcmp(Scom,"ToggleShowSelectedNode")) SUMA_RETURN (SE_ToggleShowSelectedNode);
00153 if (!strcmp(Scom,"SetSelectedNode")) SUMA_RETURN (SE_SetSelectedNode);
00154 if (!strcmp(Scom,"SetSelectedFaceSet")) SUMA_RETURN (SE_SetSelectedFaceSet);
00155 if (!strcmp(Scom,"ToggleShowSelectedFaceSet")) SUMA_RETURN (SE_ToggleShowSelectedFaceSet);
00156 if (!strcmp(Scom,"ToggleConnected")) SUMA_RETURN (SE_ToggleConnected);
00157 if (!strcmp(Scom,"StartListening")) SUMA_RETURN(SE_StartListening);
00158 if (!strcmp(Scom,"SetAfniCrossHair")) SUMA_RETURN (SE_SetAfniCrossHair);
00159 if (!strcmp(Scom,"SetForceAfniSurf")) SUMA_RETURN (SE_SetForceAfniSurf);
00160 if (!strcmp(Scom,"CloseStream4All")) SUMA_RETURN (SE_CloseStream4All);
00161 if (!strcmp(Scom,"SetAfniSurf")) SUMA_RETURN (SE_SetAfniSurf);
00162 if (!strcmp(Scom,"SetAfniThisSurf")) SUMA_RETURN (SE_SetAfniThisSurf);
00163 if (!strcmp(Scom,"SetAfniSurfList")) SUMA_RETURN (SE_SetAfniSurfList);
00164 if (!strcmp(Scom,"BindCrossHair")) SUMA_RETURN(SE_BindCrossHair);
00165 if (!strcmp(Scom,"ToggleForeground")) SUMA_RETURN (SE_ToggleForeground);
00166 if (!strcmp(Scom,"ToggleBackground")) SUMA_RETURN (SE_ToggleBackground);
00167 if (!strcmp(Scom,"FOVreset")) SUMA_RETURN (SE_FOVreset);
00168 if (!strcmp(Scom,"ResetOpenGLState")) SUMA_RETURN (SE_ResetOpenGLState);
00169 if (!strcmp(Scom,"LockCrossHair")) SUMA_RETURN(SE_LockCrossHair);
00170 if (!strcmp(Scom,"Home")) SUMA_RETURN (SE_Home);
00171 if (!strcmp(Scom,"Home_AllVisible")) SUMA_RETURN (SE_Home_AllVisible);
00172 if (!strcmp(Scom,"ToggleLockAllCrossHair")) SUMA_RETURN(SE_ToggleLockAllCrossHair);
00173 if (!strcmp(Scom,"SetLockAllCrossHair")) SUMA_RETURN(SE_SetLockAllCrossHair);
00174 if (!strcmp(Scom,"ToggleLockView")) SUMA_RETURN(SE_ToggleLockView);
00175 if (!strcmp(Scom,"ToggleLockAllViews")) SUMA_RETURN(SE_ToggleLockAllViews);
00176 if (!strcmp(Scom,"Load_Group")) SUMA_RETURN(SE_Load_Group);
00177 if (!strcmp(Scom,"Help")) SUMA_RETURN(SE_Help);
00178 if (!strcmp(Scom,"Help_Cmap")) SUMA_RETURN(SE_Help_Cmap);
00179 if (!strcmp(Scom,"UpdateLog")) SUMA_RETURN(SE_UpdateLog);
00180 if (!strcmp(Scom,"Log")) SUMA_RETURN(SE_Log);
00181 if (!strcmp(Scom,"SetRenderMode")) SUMA_RETURN(SE_SetRenderMode);
00182 if (!strcmp(Scom,"OpenDrawROI")) SUMA_RETURN(SE_OpenDrawROI);
00183 if (!strcmp(Scom,"RedisplayNow_AllVisible")) SUMA_RETURN(SE_RedisplayNow_AllVisible);
00184 if (!strcmp(Scom,"RedisplayNow_AllOtherVisible")) SUMA_RETURN(SE_RedisplayNow_AllOtherVisible);
00185 if (!strcmp(Scom,"SetLight0Pos")) SUMA_RETURN(SE_SetLight0Pos);
00186 if (!strcmp(Scom,"OpenColFileSelection")) SUMA_RETURN(SE_OpenColFileSelection);
00187 if (!strcmp(Scom,"OpenDsetFileSelection")) SUMA_RETURN(SE_OpenDsetFileSelection);
00188 if (!strcmp(Scom,"OpenCmapFileSelection")) SUMA_RETURN(SE_OpenCmapFileSelection);
00189 if (!strcmp(Scom,"SaveDrawnROIFileSelection")) SUMA_RETURN(SE_SaveDrawnROIFileSelection);
00190 if (!strcmp(Scom,"OpenDrawnROIFileSelection")) SUMA_RETURN(SE_OpenDrawnROIFileSelection);
00191 if (!strcmp(Scom,"SendColorMapToAfni")) SUMA_RETURN(SE_SendColorMapToAfni);
00192 if (!strcmp(Scom,"SaveSOFileSelection")) SUMA_RETURN(SE_SaveSOFileSelection);
00193 if (!strcmp(Scom,"SetSOinFocus")) SUMA_RETURN(SE_SetSOinFocus);
00194 if (!strcmp(Scom,"LoadViewFileSelection")) SUMA_RETURN(SE_LoadViewFileSelection);
00195 if (!strcmp(Scom,"SaveViewFileSelection")) SUMA_RETURN(SE_SaveViewFileSelection);
00196 if (!strcmp(Scom,"LoadSegDO")) SUMA_RETURN(SE_LoadSegDO);
00197 /*if (!strcmp(Scom,"")) SUMA_RETURN(SE_);*/
00198
00199 /* Last one is Bad Code */
00200 SUMA_RETURN (SE_BadCode);
00201
00202 }
|
|
|
|
creates a list for the Action Stack list = SUMA_CreateActionStack ();
Definition at line 2063 of file SUMA_ParseCommands.c. References dlist_init(), malloc, SUMA_ENTRY, SUMA_ReleaseActionStackData(), and SUMA_RETURN. Referenced by SUMA_AllocateDrawnROI(), and SUMA_NIMLDrawnROI_to_DrawnROI().
02064 {
02065 static char FuncName[]={"SUMA_CreateActionStack"};
02066 DList *list=NULL;
02067
02068 SUMA_ENTRY;
02069
02070 list = (DList *)malloc (sizeof(DList));
02071 if (!list) {
02072 fprintf (SUMA_STDERR, "Error %s: Failed to allocate for list.\n", FuncName);
02073 SUMA_RETURN(NULL);
02074 }
02075
02076 /*
02077 Do not use: dlist_init(list, SUMA_FreeActionStackData);
02078 You do not want to destroy data stored inside the ActionStack because
02079 the data is used elsewhere. Destruction of ActionStackData should
02080 only be done when a stack element is above the new Do element and will
02081 therefore never be used again. */
02082
02083 dlist_init(list, SUMA_ReleaseActionStackData);
02084
02085 SUMA_RETURN (list);
02086 }
|
|
|
|
|
creates a list for the message list list = SUMA_CreateMessageList ();
Definition at line 2114 of file SUMA_ParseCommands.c. References dlist_init(), malloc, and SUMA_FreeMessageListData(). Referenced by SUMA_Create_CommonFields().
02115 {
02116 static char FuncName[]={"SUMA_CreateMessageList"};
02117 DList *list=NULL;
02118
02119
02120 list = (DList *)malloc (sizeof(DList));
02121 if (!list) {
02122 fprintf (SUMA_STDERR, "Error %s: Failed to allocate for list.\n", FuncName);
02123 return (NULL);
02124 }
02125
02126 dlist_init(list, SUMA_FreeMessageListData);
02127
02128 return (list);
02129 }
|
|
|
destroys a list IF IT IS EMPTY ! list = SUMA_DestroyList (list);
Definition at line 2020 of file SUMA_ParseCommands.c. References dlist_destroy(), DList_::size, SUMA_ENTRY, SUMA_free, and SUMA_RETURN. Referenced by SUMA_Engine().
02021 {
02022 static char FuncName[]={"SUMA_DestroyList"};
02023
02024 SUMA_ENTRY;
02025
02026 if (list->size) {
02027 fprintf (SUMA_STDERR, "Error %s: list still contains elements.\n", FuncName);
02028 SUMA_RETURN (list);
02029 }
02030
02031 dlist_destroy(list);
02032 if (list) SUMA_free(list);
02033 SUMA_RETURN (NULL);
02034 }
|
|
|
Definition at line 223 of file SUMA_ParseCommands.c. References SUMA_DOMAIN_KINSHIPS, SUMA_DOMAINS_ERROR, SUMA_DOMAINS_NOT_RELATED, SUMA_ENTRY, SUMA_LDPSO1_is_LDPSO2, SUMA_NUCELAR_FAMILY, SUMA_RETURN, SUMA_SO1_is_GPSO2, SUMA_SO1_is_LDPSO2, SUMA_SO1_is_SO2, SUMA_SO2_is_GPSO1, and SUMA_SO2_is_LDPSO1.
00224 {
00225 static char FuncName[]={"SUMA_DomainKinships_String"};
00226
00227 SUMA_ENTRY;
00228
00229 switch (code) {
00230 case SUMA_DOMAINS_ERROR:
00231 SUMA_RETURN("Code Error");
00232 case SUMA_DOMAINS_NOT_RELATED:
00233 SUMA_RETURN("Surfaces domains not related");
00234 case SUMA_SO1_is_SO2:
00235 SUMA_RETURN("Surfaces are the same (identical idcodes)");
00236 case SUMA_SO1_is_LDPSO2:
00237 SUMA_RETURN("Surface 1 is the local domain parent of Surface 2");
00238 case SUMA_SO2_is_LDPSO1:
00239 SUMA_RETURN("Surface 2 is the local domain parent of Surface 1");
00240 case SUMA_NUCELAR_FAMILY:
00241 SUMA_RETURN("Flag for nuclear family flag limit");
00242 case SUMA_LDPSO1_is_LDPSO2:
00243 SUMA_RETURN("Surfaces have same domain grandparent");
00244 case SUMA_SO1_is_GPSO2:
00245 SUMA_RETURN("Surface 1 is the domain grandparent of Surface 2");
00246 case SUMA_SO2_is_GPSO1:
00247 SUMA_RETURN("Surface 2 is the domain grandparent of Surface 1");
00248 default:
00249 SUMA_RETURN("Should not see this");
00250 }
00251
00252 SUMA_RETURN("Should not see this either");
00253 }
|
|
|
destroys the Action Stack ans = SUMA_DestroyActionStack (DList *AS);
Definition at line 2095 of file SUMA_ParseCommands.c. References dlist_destroy(), SUMA_ENTRY, and SUMA_RETURN. Referenced by SUMA_freeDrawnROI().
02096 {
02097 static char FuncName[]={"SUMA_DestroyActionStack"};
02098
02099 SUMA_ENTRY;
02100
02101 dlist_destroy(AS);
02102
02103 SUMA_RETURN (NULL);
02104 }
|
|
|
destroys a list even if it is not empty list = SUMA_DestroyList (list);
Definition at line 2045 of file SUMA_ParseCommands.c. References dlist_destroy(), SUMA_ENTRY, SUMA_free, and SUMA_RETURN. Referenced by SUMA_ClearBrushStroke(), SUMA_Free_CommonFields(), SUMA_Free_SurfaceViewer_Struct(), and SUMA_freeDrawnROI().
02046 {
02047 static char FuncName[]={"SUMA_EmptyDestroyList"};
02048
02049 SUMA_ENTRY;
02050
02051 dlist_destroy(list);
02052 if (list) SUMA_free(list);
02053 SUMA_RETURN (NULL);
02054 }
|
|
|
Definition at line 606 of file SUMA_ParseCommands.c. References SEF_BadCode, SEF_cp, SEF_Empty, SEF_f, SEF_fm, SEF_fp, SEF_fv15, SEF_fv200, SEF_fv3, SEF_fvec, SEF_i, SEF_im, SEF_ip, SEF_iv15, SEF_iv200, SEF_iv3, SEF_ivec, SEF_s, SEF_vp, SUMA_ENGINE_FIELD_CODE, SUMA_ENTRY, and SUMA_RETURN. Referenced by SUMA_RegisterEngineData().
00607 {
00608 static char FuncName[]={"SUMA_EngineFieldCode"};
00609
00610 SUMA_ENTRY;
00611
00612 if (!strlen(Scom)) SUMA_RETURN (SEF_Empty);
00613
00614 /*fprintf(stdout,"Looking for %s\n", Scom);*/
00615 if (!strcmp(Scom,"fm")) SUMA_RETURN(SEF_fm);
00616 if (!strcmp(Scom,"im")) SUMA_RETURN(SEF_im);
00617 if (!strcmp(Scom,"fvec")) SUMA_RETURN(SEF_fvec);
00618 if (!strcmp(Scom,"ivec")) SUMA_RETURN(SEF_ivec);
00619 if (!strcmp(Scom,"fv3")) SUMA_RETURN(SEF_fv3);
00620 if (!strcmp(Scom,"iv3")) SUMA_RETURN(SEF_iv3);
00621 if (!strcmp(Scom,"fv15")) SUMA_RETURN(SEF_fv15);
00622 if (!strcmp(Scom,"iv15")) SUMA_RETURN(SEF_iv15);
00623 if (!strcmp(Scom,"fv200")) SUMA_RETURN(SEF_fv200);
00624 if (!strcmp(Scom,"iv200")) SUMA_RETURN(SEF_iv200);
00625 if (!strcmp(Scom,"i")) SUMA_RETURN(SEF_i);
00626 if (!strcmp(Scom,"f")) SUMA_RETURN (SEF_f);
00627 if (!strcmp(Scom,"s")) SUMA_RETURN (SEF_s);
00628 if (!strcmp(Scom,"vp")) SUMA_RETURN (SEF_vp); /* void pointer */
00629 if (!strcmp(Scom,"fp")) SUMA_RETURN(SEF_fp);
00630 if (!strcmp(Scom,"cp")) SUMA_RETURN(SEF_cp);
00631 if (!strcmp(Scom,"ip")) SUMA_RETURN(SEF_ip);
00632 /*if (!strcmp(Scom,"")) SUMA_RETURN(SEF_);*/
00633
00634 /* Last one is Bad Code */
00635 SUMA_RETURN (SEF_BadCode);
00636
00637 }
|
|
|
translates SUMA_ENGINE_FIELD_CODE to string
Definition at line 540 of file SUMA_ParseCommands.c. References i, SUMA_ENGINE_FIELD_CODE, SUMA_ENTRY, and SUMA_RETURN. Referenced by SUMA_RegisterEngineListCommand().
00541 {
00542 static char FuncName[]={"SUMA_EngineFieldString"};
00543
00544 SUMA_ENTRY;
00545
00546 switch (i) {
00547 case (SEF_fm):
00548 SUMA_RETURN ("fm");
00549 break;
00550 case (SEF_im):
00551 SUMA_RETURN ("im");
00552 break;
00553 case (SEF_ivec):
00554 SUMA_RETURN ("ivec");
00555 break;
00556 case (SEF_fvec):
00557 SUMA_RETURN ("fvec");
00558 break;
00559 case (SEF_fv3):
00560 SUMA_RETURN ("fv3");
00561 break;
00562 case (SEF_iv3):
00563 SUMA_RETURN ("iv3");
00564 break;
00565 case (SEF_fv15):
00566 SUMA_RETURN ("fv15");
00567 break;
00568 case (SEF_iv15):
00569 SUMA_RETURN ("iv15");
00570 break;
00571 case (SEF_iv200):
00572 SUMA_RETURN ("iv200");
00573 break;
00574 case (SEF_fv200):
00575 SUMA_RETURN ("fv200");
00576 break;
00577 case (SEF_i):
00578 SUMA_RETURN ("i");
00579 break;
00580 case (SEF_f):
00581 SUMA_RETURN ("f");
00582 break;
00583 case (SEF_s):
00584 SUMA_RETURN ("s");
00585 break;
00586 case (SEF_vp):
00587 SUMA_RETURN ("vp");
00588 break;
00589 case (SEF_cp):
00590 SUMA_RETURN ("cp");
00591 break;
00592 case (SEF_fp):
00593 SUMA_RETURN ("fp");
00594 break;
00595 case (SEF_ip):
00596 SUMA_RETURN ("ip");
00597 break;
00598 default:
00599 SUMA_RETURN ("Unknown");
00600 break;
00601
00602 }
00603
00604 }
|
|
|
Definition at line 639 of file SUMA_ParseCommands.c. References SES_Afni, SES_Empty, SES_Suma, SES_SumaFromAfni, SES_SumaFromAny, SES_SumaWidget, SES_Unknown, SUMA_ENTRY, and SUMA_RETURN. Referenced by SUMA_RegisterEngineData().
00640 {
00641 static char FuncName[]={"SUMA_EngineSourceCode"};
00642
00643 SUMA_ENTRY;
00644
00645 if (!strlen(Scom)) SUMA_RETURN (SES_Empty);
00646 if (!strcmp(Scom,"suma")) SUMA_RETURN(SES_Suma);
00647 if (!strcmp(Scom,"afni")) SUMA_RETURN(SES_Afni);
00648 if (!strcmp(Scom,"suma_widget")) SUMA_RETURN(SES_SumaWidget);
00649 if (!strcmp(Scom,"suma_from_afni")) SUMA_RETURN(SES_SumaFromAfni);
00650 if (!strcmp(Scom,"suma_from_any")) SUMA_RETURN(SES_SumaFromAny);
00651 if (!strcmp(Scom,"unknown")) SUMA_RETURN(SES_Unknown);
00652
00653 /* got here? Unknown */
00654 SUMA_RETURN (SES_Unknown);
00655 }
|
|
||||||||||||
|
Definition at line 657 of file SUMA_ParseCommands.c. References i, SES_Afni, SES_Empty, SES_Suma, SES_SumaFromAfni, SES_SumaFromAny, SES_SumaWidget, SES_Unknown, SUMA_ENTRY, and SUMA_RETURNe.
00658 {
00659 static char FuncName[]={"SUMA_EngineSourceString"};
00660
00661 SUMA_ENTRY;
00662
00663 switch (i) {
00664 case SES_Empty:
00665 Scom[0]='\0';
00666 break;
00667 case SES_Suma:
00668 sprintf(Scom,"suma");
00669 break;
00670 case SES_Afni:
00671 sprintf(Scom, "afni");
00672 break;
00673 case SES_SumaWidget:
00674 sprintf(Scom, "suma_widget");
00675 break;
00676 case SES_SumaFromAfni:
00677 sprintf(Scom, "suma_from_afni");
00678 break;
00679 case SES_SumaFromAny:
00680 sprintf(Scom, "suma_from_any");
00681 break;
00682 case SES_Unknown:
00683 sprintf(Scom, "unknown");
00684 break;
00685 default:
00686 sprintf(Scom, "Undetermined flag");
00687 break;
00688 }
00689 SUMA_RETURNe;
00690 }
|
|
|
|
Free an action stack data structure -frees AS_data->ActionData by calling destructor function -frees AS_data Definition at line 1754 of file SUMA_ParseCommands.c. References SUMA_ACTION_STACK_DATA::ActionData, SUMA_ACTION_STACK_DATA::ActionDataDestructor, LocalHead, SUMA_Boolean, SUMA_ENTRY, SUMA_free, and SUMA_RETURNe. Referenced by SUMA_PushActionStack().
01755 {
01756 static char FuncName[]={"SUMA_FreeActionStackData"};
01757 SUMA_ACTION_STACK_DATA *AS_data=NULL;
01758 SUMA_Boolean LocalHead = NOPE;
01759
01760 SUMA_ENTRY;
01761
01762 AS_data=(SUMA_ACTION_STACK_DATA *)asdata;
01763 if (AS_data) {
01764 if (LocalHead) fprintf (SUMA_STDERR, "%s: Destroying Action Stack Data \n", FuncName);
01765 /* first you want to free the Action Data */
01766 AS_data->ActionDataDestructor(AS_data->ActionData);
01767
01768 /* Now you can free the Action Stucture Data */
01769 SUMA_free(AS_data);
01770 }
01771
01772 SUMA_RETURNe;
01773 }
|
|
|
SUMA_Boolean SUMA_FreeEngineData (SUMA_EngineData *ED) free memory allocated for ED in SUMA_InitializeEngineData
if space for im or fm has been dynamically allocated in SUMA_RegisterEngineData it is released. ED itself is not freed OBSOLETE: Use SUMA_FreeEngineListData Definition at line 1905 of file SUMA_ParseCommands.c. References SUMA_EngineData::fm, SUMA_EngineData::fm_LocalAlloc, SUMA_EngineData::im, SUMA_EngineData::im_LocalAlloc, SUMA_EngineData::N_cols, SUMA_EngineData::N_rows, SUMA_Boolean, SUMA_ENTRY, SUMA_free2D(), and SUMA_RETURN.
01906 {
01907 static char FuncName[]={"SUMA_FreeEngineData"};
01908
01909 SUMA_ENTRY;
01910
01911 fprintf (SUMA_STDERR, "Error %s: This function is now obsolete. Must use SUMA_FreeEngineListData instead.\n", FuncName);
01912 SUMA_RETURN (NOPE);
01913
01914 if (ED == NULL) {
01915 fprintf(SUMA_STDERR,"Error %s: ED is null, nothing to do!\n", FuncName);
01916 SUMA_RETURN (NOPE);
01917 }
01918
01919 /* check on Dynamic Memory Allocations needs */
01920 if (ED->fm_LocalAlloc) {
01921 if (!ED->N_rows || !ED->N_cols) {
01922 fprintf(SUMA_STDERR,"Error %s: N_rows or N_cols are 0.\n", FuncName);
01923 SUMA_RETURN (NOPE);
01924 }
01925 if (ED->fm == NULL) {
01926 fprintf(SUMA_STDERR,"Error %s: ED->fm is NULL, not good here.\n", FuncName);
01927 SUMA_RETURN (NOPE);
01928 }
01929 /* OK, free ED->fm */
01930 SUMA_free2D((char **)ED->fm, ED->N_rows);
01931 }
01932
01933 if (ED->im_LocalAlloc) {
01934 if (!ED->N_rows || !ED->N_cols) {
01935 fprintf(SUMA_STDERR,"Error %s: N_rows or N_cols are 0.\n", FuncName);
01936 SUMA_RETURN (NOPE);
01937 }
01938 if (ED->im == NULL) {
01939 fprintf(SUMA_STDERR,"Error %s: ED->im is NULL, not good here.\n", FuncName);
01940 SUMA_RETURN (NOPE);
01941 }
01942 /* OK, free ED->im */
01943 SUMA_free2D((char **)ED->im, ED->N_rows);
01944 }
01945
01946 /* good deal, DO NOT flush ED in case it was not dynamically allocated*/
01947 SUMA_RETURN (YUP);
01948 }
|
|
|
free an engine data structure and any allocated space in its fields SUMA_FreeEngineListData (EDv);
Definition at line 1844 of file SUMA_ParseCommands.c. References SUMA_EngineData::fm, SUMA_EngineData::fm_LocalAlloc, SUMA_EngineData::im, SUMA_EngineData::im_LocalAlloc, SUMA_EngineData::N_cols, SUMA_EngineData::N_rows, SUMA_ENTRY, SUMA_free, SUMA_free2D(), and SUMA_RETURNe. Referenced by SUMA_CreateList(), and SUMA_ReleaseEngineListElement().
01845 {
01846 static char FuncName[]={"SUMA_FreeEngineListData"};
01847 SUMA_EngineData *ED = NULL;
01848
01849 SUMA_ENTRY;
01850
01851 ED = (SUMA_EngineData *)EDv;
01852
01853 if (ED == NULL) {
01854 fprintf(SUMA_STDERR,"Warning %s: ED is null, nothing to do!\n", FuncName);
01855 SUMA_RETURNe;
01856 }
01857
01858 /* check on Dynamic Memory Allocations needs */
01859 if (ED->fm_LocalAlloc) {
01860 if (!ED->N_rows || !ED->N_cols) {
01861 fprintf(SUMA_STDERR,"Error %s: N_rows or N_cols are 0.\n\a", FuncName);
01862 SUMA_RETURNe;
01863 }
01864 if (ED->fm == NULL) {
01865 fprintf(SUMA_STDERR,"Error %s: ED->fm is NULL, not good here.\n\a", FuncName);
01866 SUMA_RETURNe;
01867 }
01868 /* OK, free ED->fm */
01869 SUMA_free2D((char **)ED->fm, ED->N_rows);
01870 }
01871
01872 if (ED->im_LocalAlloc) {
01873 if (!ED->N_rows || !ED->N_cols) {
01874 fprintf(SUMA_STDERR,"Error %s: N_rows or N_cols are 0.\n\a", FuncName);
01875 SUMA_RETURNe;
01876 }
01877 if (ED->im == NULL) {
01878 fprintf(SUMA_STDERR,"Error %s: ED->im is NULL, not good here.\n\a", FuncName);
01879 SUMA_RETURNe;
01880 }
01881 /* OK, free ED->im */
01882 SUMA_free2D((char **)ED->im, ED->N_rows);
01883 }
01884
01885 /* good deal, flush ED */
01886 SUMA_free(ED);
01887 SUMA_RETURNe;
01888 }
|
|
|
|
free a message structure and any allocated space in its fields
Definition at line 1806 of file SUMA_ParseCommands.c. References SUMA_MessageData::Message, SUMA_MessageData::Source, SUMA_ENTRY, SUMA_free, and SUMA_RETURNe. Referenced by SUMA_CreateMessageList(), and SUMA_ReleaseMessageListElement().
01807 {
01808 static char FuncName[]={"SUMA_FreeMessageListData"};
01809 SUMA_MessageData *H = NULL;
01810
01811 SUMA_ENTRY;
01812
01813 H = (SUMA_MessageData *)Hv;
01814
01815 if (!H) {
01816 fprintf(SUMA_STDERR,"Warning %s: H is null, nothing to do!\n", FuncName);
01817 SUMA_RETURNe;
01818 }
01819
01820 #if 1 /* Message and Source are never allocated and should not be freed. */
01821 /* 2003 June 19 [rickr] */
01822 /* Message and Source are now allocated */
01823 /* 2003 June 23 [zsaad] */
01824 if (H->Message) SUMA_free(H->Message);
01825 if (H->Source) SUMA_free(H->Source);
01826 #endif
01827
01828 if (H) SUMA_free(H);
01829
01830 SUMA_RETURNe;
01831 }
|
|
|
Returns the code for the next command (at the tail of the list). CommandCode = SUMA_GetListNextCommand (list);.
This function replaces the obsolete SUMA_GetNextCommand Definition at line 31 of file SUMA_ParseCommands.c. References SUMA_EngineData::CommandCode, DListElmt_::data, dlist_head, dlist_size, SE_Empty, SUMA_ENGINE_CODE, SUMA_ENTRY, and SUMA_RETURN.
00032 {
00033 static char FuncName[]={"SUMA_GetListNextCommand"};
00034 DListElmt *next;
00035 SUMA_EngineData *ED = NULL;
00036
00037 SUMA_ENTRY;
00038
00039 if (!dlist_size(list)) {
00040 SUMA_RETURN (SE_Empty);
00041 }
00042
00043 next = (DListElmt *)dlist_head(list);
00044 ED = (SUMA_EngineData *)(next->data);
00045 SUMA_RETURN (ED->CommandCode);
00046
00047 }
|
|
||||||||||||||||||||
|
** File : SUMA_ParseCommands.c
Usage : Ret = SUMA_GetNextCommand (char *S, char d, char term, char *Scom); Input paramters :
Definition at line 77 of file SUMA_ParseCommands.c. References i, S, SUMA_CommandCode(), SUMA_ENTRY, and SUMA_RETURN.
00078 {/*SUMA_GetNextCommand*/
00079 static char FuncName[]={"SUMA_GetNextCommand"};
00080 int i=0, iBegin, iStop;
00081
00082 SUMA_ENTRY;
00083
00084 fprintf (SUMA_STDERR, "Error %s: This function is now obsolete. Must use SUMA_GetListNextCommand instead.\n", FuncName);
00085 SUMA_RETURN (NOPE);
00086
00087 iStop = strlen(S)-1;
00088
00089 /*fprintf(stdout,"%s %c %c\n", S, S[iStop], term); */
00090 if (S[iStop] != term) {
00091 fprintf (stderr, "%s Error: Command poorly terminated!\n\a", FuncName);
00092 SUMA_RETURN (0);
00093 }
00094 /* Make sure character just before term is not d */
00095 if (S[iStop-1] == d) {
00096 S[iStop] = '\0';
00097 iStop -= 1;
00098 S[iStop] = term;
00099 }
00100
00101 /* search for command delimiter */
00102 iBegin = iStop -1;
00103 while (iBegin > -1 && S[iBegin]!= d) --iBegin;
00104 ++iBegin;
00105
00106 /* copy command to Scom*/
00107 for (i=0; i< iStop - iBegin; ++i) {
00108 /*fprintf(stdout,"%d %c\n", iBegin+i, S[iBegin+i]);*/
00109 Scom[i] = S[iBegin+i];
00110 S[iBegin+i] = '\0'; /*for esthetics */}
00111
00112 /* seal strings with terminators */
00113 Scom[iStop-iBegin] = '\0';
00114 if (iBegin > 0) {
00115 S[iBegin-1] = term;
00116 iStop = iBegin-1;
00117 }
00118 else {
00119 S[iBegin] = term;
00120 iStop = iBegin;
00121
00122 }
00123
00124 /*get the code of the command*/
00125 SUMA_RETURN (SUMA_CommandCode(Scom));
00126
00127 }/*SUMA_GetNextCommand*/
|
|
|
looks for words in str to guess what surface type is being mentioned
Definition at line 2442 of file SUMA_ParseCommands.c. References SUMA_BRAIN_VOYAGER, SUMA_CMAP_SO, SUMA_ENTRY, SUMA_FREE_SURFER, SUMA_FT_NOT_SPECIFIED, SUMA_INVENTOR_GENERIC, SUMA_iswordin_ci(), SUMA_OPENDX_MESH, SUMA_PLY, SUMA_RETURN, SUMA_SO_File_Type, SUMA_SUREFIT, and SUMA_VEC.
02443 {
02444 static char FuncName[]={"SUMA_guess_surftype_argv"};
02445 SUMA_SO_File_Type tp=SUMA_FT_NOT_SPECIFIED;
02446
02447 SUMA_ENTRY;
02448
02449 if (SUMA_iswordin_ci(str, "FreeSurfer") == 1 || SUMA_iswordin_ci(str, "fs") == 1 ) {
02450 SUMA_RETURN( SUMA_FREE_SURFER );
02451 }
02452 if (SUMA_iswordin_ci(str, "SureFit") == 1 || SUMA_iswordin_ci(str, "sf") == 1 || SUMA_iswordin_ci(str, "caret") == 1 ) SUMA_RETURN( SUMA_SUREFIT );
02453 if (SUMA_iswordin_ci(str, "Inventor") == 1 || SUMA_iswordin_ci(str, "iv") == 1 || SUMA_iswordin_ci(str, "inv") == 1 ) SUMA_RETURN( SUMA_INVENTOR_GENERIC );
02454 if (SUMA_iswordin_ci(str, "dx") == 1 ) SUMA_RETURN( SUMA_OPENDX_MESH );
02455 if (SUMA_iswordin_ci(str, "ply") == 1 ) SUMA_RETURN( SUMA_PLY );
02456 if (SUMA_iswordin_ci(str, "vec") == 1 || SUMA_iswordin_ci(str, "1d") == 1 ) SUMA_RETURN( SUMA_VEC );
02457 if (SUMA_iswordin_ci(str, "BrainVoyager") == 1 || SUMA_iswordin_ci(str, "bv") == 1 ) SUMA_RETURN( SUMA_BRAIN_VOYAGER );
02458 if (SUMA_iswordin_ci(str, "cmap") == 1 ) SUMA_RETURN( SUMA_CMAP_SO );
02459
02460 SUMA_RETURN(tp);
02461 }
|
|
|
Definition at line 2876 of file SUMA_ParseCommands.c. References SUMA_GENERIC_ARGV_PARSE::accept_i, SUMA_GENERIC_ARGV_PARSE::accept_ipar, SUMA_GENERIC_ARGV_PARSE::accept_o, SUMA_GENERIC_ARGV_PARSE::accept_s, SUMA_GENERIC_ARGV_PARSE::accept_spec, SUMA_GENERIC_ARGV_PARSE::accept_sv, SUMA_GENERIC_ARGV_PARSE::accept_t, SUMA_GENERIC_ARGV_PARSE::accept_talk_suma, SUMA_ENTRY, SUMA_free, SUMA_help_talk(), SUMA_RETURN, SUMA_SS2S, SUMA_StringAppend(), and SUMA_StringAppend_va(). Referenced by SUMA_usage(), usage_3dBRAIN_VOYAGERtoAFNI(), usage_3dCRUISEtoAFNI(), usage_3dSurfMask(), usage_PROGRAM_NAME(), usage_SUMA_coarsen(), and usage_SurfToSurf().
02877 {
02878 static char FuncName[]={"SUMA_help_IO_Args"};
02879 char *s=NULL, *st = NULL;
02880 SUMA_STRING *SS = NULL;
02881
02882 SUMA_ENTRY;
02883 SS = SUMA_StringAppend (NULL, NULL);
02884
02885 if (opt->accept_i) {
02886 SS = SUMA_StringAppend (SS,
02887 " Specifying input surfaces using -i_TYPE options: \n"
02888 " -i_TYPE inSurf specifies the input surface,\n"
02889 " TYPE is one of the following:\n"
02890 " fs: FreeSurfer surface. \n"
02891 " If surface name has .asc it is assumed to be\n"
02892 " in ASCII format. Otherwise it is assumed to be\n"
02893 " in BINARY_BE (Big Endian) format.\n"
02894 " Patches in Binary format cannot be read at the moment.\n"
02895 " sf: SureFit surface. \n"
02896 " You must specify the .coord followed by the .topo file.\n"
02897 " vec (or 1D): Simple ascii matrix format. \n"
02898 " You must specify the coord (NodeList) file followed by \n"
02899 " the topo (FaceSetList) file.\n"
02900 " coord contains 3 floats per line, representing \n"
02901 " X Y Z vertex coordinates.\n"
02902 " topo contains 3 ints per line, representing \n"
02903 " v1 v2 v3 triangle vertices.\n"
02904 " ply: PLY format, ascii or binary.\n"
02905 " Only vertex and triangulation info is preserved.\n"
02906 " bv: BrainVoyager format. \n"
02907 " Only vertex and triangulation info is preserved.\n"
02908 " dx: OpenDX ascii mesh format.\n"
02909 " Only vertex and triangulation info is preserved.\n"
02910 " Requires presence of 3 objects, the one of class \n"
02911 " 'field' should contain 2 components 'positions'\n"
02912 " and 'connections' that point to the two objects\n"
02913 " containing node coordinates and topology, respectively.\n"
02914 );
02915 }
02916 if (opt->accept_ipar) {
02917 SS = SUMA_StringAppend (SS,
02918 " -ipar_TYPE ParentSurf specifies the parent surface. Only used\n"
02919 " when -o_fsp is used, see -o_TYPE options.\n"
02920 );
02921 }
02922
02923 if (opt->accept_t) {
02924 SS = SUMA_StringAppend (SS,
02925 " Specifying surfaces using -t* options: \n"
02926 " -tn TYPE NAME: specify surface type and name.\n"
02927 " See below for help on the parameters.\n"
02928 " -tsn TYPE STATE NAME: specify surface type state and name.\n"
02929 " TYPE: Choose from the following (case sensitive):\n"
02930 " 1D: 1D format\n"
02931 " FS: FreeSurfer ascii format\n"
02932 " PLY: ply format\n"
02933 " SF: Caret/SureFit format\n"
02934 " BV: BrainVoyager format\n"
02935 " NAME: Name of surface file. \n"
02936 " For SF and 1D formats, NAME is composed of two names\n"
02937 " the coord file followed by the topo file\n"
02938 " STATE: State of the surface.\n"
02939 " Default is S1, S2.... for each surface.\n"
02940 );
02941 }
02942
02943
02944 if (opt->accept_sv) {
02945 SS = SUMA_StringAppend (SS,
02946 " Specifying a Surface Volume:\n"
02947 " -sv SurfaceVolume [VolParam for sf surfaces]\n"
02948 " If you supply a surface volume, the coordinates of the input surface.\n"
02949 " are modified to SUMA's convention and aligned with SurfaceVolume.\n"
02950 " You must also specify a VolParam file for SureFit surfaces.\n"
02951 );
02952 }
02953
02954 if (opt->accept_spec) {
02955 SS = SUMA_StringAppend (SS,
02956 " Specifying a surface specification (spec) file:\n"
02957 " -spec SPEC: specify the name of the SPEC file.\n"
02958 );
02959 }
02960
02961 if (opt->accept_s) {
02962 SS = SUMA_StringAppend (SS,
02963 " Specifying a surface using -surf_? method:\n"
02964 " -surf_A SURFACE: specify the name of the first\n"
02965 " surface to load. If the program requires\n"
02966 " or allows multiple surfaces, use -surf_B\n"
02967 " ... -surf_Z .\n"
02968 " You need not use _A if only one surface is\n"
02969 " expected.\n"
02970 " SURFACE is the name of the surface as specified\n"
02971 " in the SPEC file. The use of -surf_ option \n"
02972 " requires the use of -spec option.\n"
02973
02974 );
02975 }
02976
02977 if (opt->accept_o) {
02978 SS = SUMA_StringAppend (SS,
02979 " Specifying output surfaces using -o_TYPE options: \n"
02980 " -o_TYPE outSurf specifies the output surface, \n"
02981 " TYPE is one of the following:\n"
02982 " fs: FreeSurfer ascii surface. \n"
02983 " fsp: FeeSurfer ascii patch surface. \n"
02984 " In addition to outSurf, you need to specify\n"
02985 " the name of the parent surface for the patch.\n"
02986 " using the -ipar_TYPE option.\n"
02987 " This option is only for ConvertSurface \n"
02988 " sf: SureFit surface. \n"
02989 " For most programs, you are expected to specify prefix:\n"
02990 " i.e. -o_sf brain. In some programs, you are allowed to \n"
02991 " specify both .coord and .topo file names: \n"
02992 " i.e. -o_sf XYZ.coord TRI.topo\n"
02993 " The program will determine your choice by examining \n"
02994 " the first character of the second parameter following\n"
02995 " -o_sf. If that character is a '-' then you have supplied\n"
02996 " a prefix and the program will generate the coord and topo names.\n"
02997 " vec (or 1D): Simple ascii matrix format. \n"
02998 " For most programs, you are expected to specify prefix:\n"
02999 " i.e. -o_1D brain. In some programs, you are allowed to \n"
03000 " specify both coord and topo file names: \n"
03001 " i.e. -o_1D brain.1D.coord brain.1D.topo\n"
03002 " coord contains 3 floats per line, representing \n"
03003 " X Y Z vertex coordinates.\n"
03004 " topo contains 3 ints per line, representing \n"
03005 " v1 v2 v3 triangle vertices.\n"
03006 " ply: PLY format, ascii or binary.\n"
03007 );
03008 }
03009
03010 if (opt->accept_talk_suma) {
03011 st = SUMA_help_talk();
03012 SS = SUMA_StringAppend_va (SS,
03013 "\n"
03014 "%s"
03015 "\n",
03016 st
03017 );
03018 SUMA_free(st); st = NULL;
03019 }
03020
03021 SUMA_SS2S(SS, s);
03022
03023 SUMA_RETURN(s);
03024
03025 }
|
|
|
||||||||||||||||
|
A function to parse command line arguments and return a convenient structure that can be used by various programs for surface specifications I hope and pray that this will not be a can of worms. Definition at line 3032 of file SUMA_ParseCommands.c. References SUMA_GENERIC_ARGV_PARSE::accept_i, SUMA_GENERIC_ARGV_PARSE::accept_ipar, SUMA_GENERIC_ARGV_PARSE::accept_o, SUMA_GENERIC_ARGV_PARSE::accept_s, SUMA_GENERIC_ARGV_PARSE::accept_spec, SUMA_GENERIC_ARGV_PARSE::accept_sv, SUMA_GENERIC_ARGV_PARSE::accept_t, SUMA_GENERIC_ARGV_PARSE::accept_talk_suma, SUMA_COMM_STRUCT::afni_host_name, SUMA_GENERIC_ARGV_PARSE::arg_checked, argc, SUMA_COMM_STRUCT::comm_NI_mode, SUMA_GENERIC_ARGV_PARSE::cs, SUMA_COMM_STRUCT::Feed2Afni, i, SUMA_GENERIC_ARGV_PARSE::i_FF, SUMA_GENERIC_ARGV_PARSE::i_FT, SUMA_GENERIC_ARGV_PARSE::i_N_surfnames, SUMA_GENERIC_ARGV_PARSE::i_surfnames, SUMA_GENERIC_ARGV_PARSE::i_surftopo, ind, SUMA_GENERIC_ARGV_PARSE::ipar_FF, SUMA_GENERIC_ARGV_PARSE::ipar_FT, SUMA_GENERIC_ARGV_PARSE::ipar_N_surfnames, SUMA_GENERIC_ARGV_PARSE::ipar_surfnames, SUMA_GENERIC_ARGV_PARSE::ipar_surftopo, SUMA_COMM_STRUCT::kth, SUMA_GENERIC_ARGV_PARSE::N_args, SUMA_GENERIC_ARGV_PARSE::N_spec_names, SUMA_GENERIC_ARGV_PARSE::N_sv, SUMA_GENERIC_ARGV_PARSE::N_vp, SUMA_COMM_STRUCT::nelps, NI_BINARY_MODE, NI_TEXT_MODE, SUMA_GENERIC_ARGV_PARSE::o_FF, SUMA_GENERIC_ARGV_PARSE::o_FT, SUMA_GENERIC_ARGV_PARSE::o_N_surfnames, SUMA_GENERIC_ARGV_PARSE::o_surfnames, SUMA_GENERIC_ARGV_PARSE::o_surftopo, SUMA_COMM_STRUCT::rps, SUMA_GENERIC_ARGV_PARSE::s_N_surfnames, SUMA_GENERIC_ARGV_PARSE::s_surfnames, SUMA_GENERIC_ARGV_PARSE::spec_names, SUMA_ASCII, SUMA_BINARY, SUMA_BINARY_BE, SUMA_Boolean, SUMA_BRAIN_VOYAGER, SUMA_copy_string(), SUMA_Create_CommSrtuct(), SUMA_CreateGenericArgParse(), SUMA_ENTRY, SUMA_FF_NOT_SPECIFIED, SUMA_FREE_SURFER, SUMA_FREE_SURFER_PATCH, SUMA_FT_ERROR, SUMA_FT_NOT_SPECIFIED, SUMA_COMM_STRUCT::suma_host_name, SUMA_INVENTOR_GENERIC, SUMA_isExtension(), SUMA_MAX_SURF_ON_COMMAND, SUMA_N_ARGS_MAX, SUMA_OPENDX_MESH, SUMA_PLY, SUMA_RemoveSurfNameExtension(), SUMA_RETURN, SUMA_S_Err, SUMA_SL_Err, SUMA_SUREFIT, SUMA_SurfaceTypeCode(), SUMA_VEC, SUMA_GENERIC_ARGV_PARSE::sv, SUMA_GENERIC_ARGV_PARSE::t_FF, SUMA_GENERIC_ARGV_PARSE::t_FT, SUMA_GENERIC_ARGV_PARSE::t_N_surfnames, SUMA_GENERIC_ARGV_PARSE::t_state, SUMA_GENERIC_ARGV_PARSE::t_surfnames, SUMA_GENERIC_ARGV_PARSE::t_surftopo, SUMA_COMM_STRUCT::talk_suma, and SUMA_GENERIC_ARGV_PARSE::vp. Referenced by main().
03033 {
03034 static char FuncName[]={"SUMA_Parse_IO_Args"};
03035 int i, kar, ind, N_name;
03036 SUMA_Boolean brk = NOPE;
03037 SUMA_GENERIC_ARGV_PARSE *ps=NULL;
03038
03039 SUMA_ENTRY;
03040
03041 if (argc >= SUMA_N_ARGS_MAX) {
03042 SUMA_S_Err("Number of arguments exceeds SUMA's parsing limit.");
03043 SUMA_RETURN(NULL);
03044 }
03045
03046 ps = SUMA_CreateGenericArgParse(optflags);
03047 if (!ps) {
03048 SUMA_S_Err("Failed to create parse structure.");
03049 SUMA_RETURN(NULL);
03050 }
03051 ps->N_args = argc;
03052 ps->cs = SUMA_Create_CommSrtuct();
03053 kar = 1;
03054 brk = NOPE;
03055 while (kar < argc) { /* loop accross command ine options */
03056 if (ps->accept_talk_suma) {
03057 if (!brk && (strcmp(argv[kar], "-talk_suma") == 0)) {
03058 ps->arg_checked[kar]=1;
03059 ps->cs->talk_suma = 1;
03060 brk = YUP;
03061 }
03062
03063 if (!brk && (strcmp(argv[kar], "-feed_afni") == 0)) {
03064 ps->arg_checked[kar]=1;
03065 ps->cs->Feed2Afni = 1;
03066 brk = YUP;
03067 }
03068
03069 if (!brk && strcmp(argv[kar], "-send_kth") == 0)
03070 {
03071 ps->arg_checked[kar]=1;
03072 kar ++; ps->arg_checked[kar]=1;
03073 if (kar >= argc) {
03074 SUMA_S_Err("need argument after -send_kth \n");
03075 exit (1);
03076 }
03077 ps->cs->kth = atoi(argv[kar]);
03078 if (ps->cs->kth <= 0) {
03079 fprintf (SUMA_STDERR, "Bad value (%d) for send_kth\n", ps->cs->kth);
03080 exit (1);
03081 }
03082
03083 brk = YUP;
03084 }
03085
03086 if (!brk && strcmp(argv[kar], "-ni_text") == 0)
03087 {
03088 ps->arg_checked[kar]=1;
03089 ps->cs->comm_NI_mode = NI_TEXT_MODE;
03090 brk = YUP;
03091 }
03092
03093 if (!brk && strcmp(argv[kar], "-ni_binary") == 0)
03094 {
03095 ps->arg_checked[kar]=1;
03096 ps->cs->comm_NI_mode = NI_BINARY_MODE;
03097 brk = YUP;
03098 }
03099
03100 if (!brk && strcmp(argv[kar], "-sh") == 0)
03101 {
03102 ps->arg_checked[kar]=1;
03103 kar ++; ps->arg_checked[kar]=1;
03104 if (kar >= argc) {
03105 SUMA_S_Err("need argument after -sh \n");
03106 exit (1);
03107 }
03108 if (strcmp(argv[kar],"localhost") != 0) {
03109 ps->cs->suma_host_name = SUMA_copy_string(argv[kar]);
03110 }else {
03111 fprintf (SUMA_STDERR, "localhost is the default for -sh\nNo need to specify it.\n");
03112 }
03113
03114 brk = YUP;
03115 }
03116
03117 if (!brk && strcmp(argv[kar], "-ah") == 0)
03118 {
03119 ps->arg_checked[kar]=1;
03120 kar ++; ps->arg_checked[kar]=1;
03121 if (kar >= argc) {
03122 SUMA_S_Err("need argument after -ah \n");
03123 exit (1);
03124 }
03125 if (strcmp(argv[kar],"localhost") != 0) {
03126 ps->cs->afni_host_name = SUMA_copy_string(argv[kar]);
03127 }else {
03128 fprintf (SUMA_STDERR, "localhost is the default for -ah\nNo need to specify it.\n");
03129 }
03130
03131 brk = YUP;
03132 }
03133
03134 if (!brk && strcmp(argv[kar], "-refresh_rate") == 0)
03135 {
03136 ps->arg_checked[kar]=1;
03137 kar ++; ps->arg_checked[kar]=1;
03138 if (kar >= argc) {
03139 SUMA_S_Err("need argument after -refresh_rate \n");
03140 exit (1);
03141 }
03142 ps->cs->rps = atof(argv[kar]);
03143 if (ps->cs->rps <= 0) {
03144 fprintf (SUMA_STDERR, "Bad value (%f) for refresh_rate\n", ps->cs->rps);
03145 exit (1);
03146 }
03147
03148 brk = YUP;
03149 }
03150
03151 }
03152
03153 if (ps->accept_sv) {
03154 if (!brk && (strcmp(argv[kar], "-sv") == 0)) {
03155 ps->arg_checked[kar]=1;
03156 kar ++; ps->arg_checked[kar]=1;
03157 if (kar >= argc) {
03158 SUMA_S_Err("need 1 or 2 arguments after -sv ");
03159 exit (1);
03160 }
03161 if (ps->N_sv >= SUMA_MAX_SURF_ON_COMMAND) {
03162 SUMA_S_Err("Exceeding maximum number of allowed sv files...");
03163 exit(1);
03164 }
03165 ps->sv[ps->N_sv] = SUMA_copy_string(argv[kar]);
03166 /* is there a volparam option ?*/
03167 if (kar+1 < argc) {
03168 /* maybe a volparam file */
03169 if (argv[kar+1][0] == '-') { /* NOPE*/
03170 } else {
03171 kar ++; ps->arg_checked[kar]=1;
03172 ps->vp[ps->N_vp] = SUMA_copy_string(argv[kar]);
03173 ++ps->N_vp;
03174 }
03175 }
03176 ++ps->N_sv;
03177 brk = YUP;
03178 }
03179 }
03180 if (ps->accept_spec || ps->accept_s) {
03181 if (!brk && (strcmp(argv[kar], "-spec") == 0)) {
03182 ps->arg_checked[kar]=1;
03183 kar ++; ps->arg_checked[kar]=1;
03184 if (kar >= argc) {
03185 SUMA_S_Err( "need argument after -spec ");
03186 exit (1);
03187 }
03188 if (ps->N_spec_names >= SUMA_MAX_SURF_ON_COMMAND) {
03189 SUMA_SL_Err("Exceeding maximum number of allowed spec files...");
03190 exit(1);
03191 }
03192 ps->spec_names[ps->N_spec_names] = SUMA_copy_string(argv[kar]);
03193 ++ps->N_spec_names;
03194 brk = YUP;
03195 }
03196 }
03197 if (ps->accept_s) {
03198 if (!brk && (strncmp(argv[kar], "-surf_", 6) == 0)) {
03199 ps->arg_checked[kar]=1;
03200 if (kar + 1>= argc) {
03201 SUMA_S_Err( "need argument after -surf_X SURF_NAME \n");
03202 exit (1);
03203 }
03204 ind = argv[kar][6] - 'A';
03205 if (ind < 0 || ind >= 'Z') {
03206 fprintf (SUMA_STDERR, "Error %s:\n -surf_X SURF_NAME option is out of range.\n"
03207 "Only %d surfaces are allowed. \n"
03208 "Must start with surf_A for first surface.\n", FuncName, 'Z');
03209 exit (1);
03210 }
03211 kar ++;
03212 ps->arg_checked[kar]=1;
03213 if (ps->s_N_surfnames >= SUMA_MAX_SURF_ON_COMMAND) {
03214 SUMA_SL_Err("Exceeding maximum number of allowed surfaces...");
03215 exit(1);
03216 }
03217 ps->s_surfnames[ps->s_N_surfnames+ind] = SUMA_copy_string(argv[kar]);
03218 ++ps->s_N_surfnames;
03219 brk = YUP;
03220 }
03221 if (!brk && (strncmp(argv[kar], "-surf", 5) == 0)) {
03222 ps->arg_checked[kar]=1;
03223 if (kar + 1>= argc) {
03224 SUMA_S_Err( "need argument after -surf SURF_NAME \n");
03225 exit (1);
03226 }
03227 ind = 0;
03228
03229 kar ++;
03230 ps->arg_checked[kar]=1;
03231 if (ps->s_N_surfnames >= SUMA_MAX_SURF_ON_COMMAND) {
03232 SUMA_SL_Err("Exceeding maximum number of allowed surfaces...");
03233 exit(1);
03234 }
03235 if (ps->s_surfnames[ps->s_N_surfnames+ind]) {
03236 SUMA_SL_Err("surface (A) already specified.");
03237 exit(1);
03238 }
03239 ps->s_surfnames[ps->s_N_surfnames+ind] = SUMA_copy_string(argv[kar]);
03240 ++ps->s_N_surfnames;
03241 brk = YUP;
03242 }
03243 }
03244 if (ps->accept_i) {
03245 if (!brk && ( (strcmp(argv[kar], "-i_bv") == 0) || (strcmp(argv[kar], "-i_BV") == 0) ) ) {
03246 ps->arg_checked[kar]=1;
03247 kar ++; ps->arg_checked[kar]=1;
03248 if (kar >= argc) {
03249 SUMA_S_Err( "need argument after -i_bv ");
03250 exit (1);
03251 }
03252 if (ps->i_N_surfnames >= SUMA_MAX_SURF_ON_COMMAND) {
03253 SUMA_SL_Err("Exceeding maximum number of allowed surfaces...");
03254 exit(1);
03255 }
03256 ps->i_surfnames[ps->i_N_surfnames] = SUMA_copy_string(argv[kar]);
03257 ps->i_FT[ps->i_N_surfnames] = SUMA_BRAIN_VOYAGER;
03258 ps->i_FF[ps->i_N_surfnames] = SUMA_BINARY;
03259 ++ps->i_N_surfnames;
03260 brk = YUP;
03261 }
03262
03263 if (!brk && ( (strcmp(argv[kar], "-i_fs") == 0) || (strcmp(argv[kar], "-i_FS") == 0)) ) {
03264 ps->arg_checked[kar]=1;
03265 kar ++; ps->arg_checked[kar]=1;
03266 if (kar >= argc) {
03267 SUMA_S_Err( "need argument after -i_fs ");
03268 exit (1);
03269 }
03270 if (ps->i_N_surfnames >= SUMA_MAX_SURF_ON_COMMAND) {
03271 SUMA_SL_Err("Exceeding maximum number of allowed surfaces...");
03272 exit(1);
03273 }
03274 ps->i_surfnames[ps->i_N_surfnames] = SUMA_copy_string(argv[kar]);
03275 ps->i_FT[ps->i_N_surfnames] = SUMA_FREE_SURFER;
03276 if (SUMA_isExtension(ps->i_surfnames[ps->i_N_surfnames], ".asc"))
03277 ps->i_FF[ps->i_N_surfnames] = SUMA_ASCII;
03278 else
03279 ps->i_FF[ps->i_N_surfnames] = SUMA_BINARY_BE;
03280 ++ps->i_N_surfnames;
03281 brk = YUP;
03282 }
03283
03284 if (!brk && ( (strcmp(argv[kar], "-i_sf") == 0) || (strcmp(argv[kar], "-i_SF") == 0)) ){
03285 ps->arg_checked[kar]=1;
03286 kar ++; ps->arg_checked[kar]=1;
03287 if (kar+1 >= argc) {
03288 SUMA_S_Err( "need 2 arguments after -i_sf");
03289 exit (1);
03290 }
03291 if (ps->i_N_surfnames >= SUMA_MAX_SURF_ON_COMMAND) {
03292 SUMA_S_Err("Exceeding maximum number of allowed surfaces...");
03293 exit(1);
03294 }
03295 ps->i_surfnames[ps->i_N_surfnames] = SUMA_copy_string(argv[kar]);
03296 kar ++; ps->arg_checked[kar]=1;
03297 ps->i_surftopo[ps->i_N_surfnames] = SUMA_copy_string(argv[kar]);
03298 ps->i_FT[ps->i_N_surfnames] = SUMA_SUREFIT;
03299 ps->i_FF[ps->i_N_surfnames] = SUMA_ASCII;
03300 ++ps->i_N_surfnames;
03301 brk = YUP;
03302 }
03303
03304 if (!brk && ( (strcmp(argv[kar], "-i_vec") == 0) || (strcmp(argv[kar], "-i_1d") == 0) ||
03305 (strcmp(argv[kar], "-i_VEC") == 0) || (strcmp(argv[kar], "-i_1D") == 0) ) ) {
03306 ps->arg_checked[kar]=1;
03307 kar ++; ps->arg_checked[kar]=1;
03308 if (kar+1 >= argc) {
03309 SUMA_S_Err( "need 2 argument after -i_vec or -i_1d");
03310 exit (1);
03311 }
03312 if (ps->i_N_surfnames >= SUMA_MAX_SURF_ON_COMMAND) {
03313 SUMA_S_Err("Exceeding maximum number of allowed surfaces...");
03314 exit(1);
03315 }
03316 ps->i_surfnames[ps->i_N_surfnames] = SUMA_copy_string(argv[kar]);
03317 kar ++; ps->arg_checked[kar]=1;
03318 ps->i_surftopo[ps->i_N_surfnames] = SUMA_copy_string(argv[kar]);
03319 ps->i_FT[ps->i_N_surfnames] = SUMA_VEC;
03320 ps->i_FF[ps->i_N_surfnames] = SUMA_ASCII;
03321 ++ps->i_N_surfnames;
03322 brk = YUP;
03323 }
03324
03325 if (!brk && ( (strcmp(argv[kar], "-i_ply") == 0) || (strcmp(argv[kar], "-i_Ply") == 0) || (strcmp(argv[kar], "-i_PLY") == 0))) {
03326 ps->arg_checked[kar]=1;
03327 kar ++; ps->arg_checked[kar]=1;
03328 if (kar >= argc) {
03329 SUMA_S_Err( "need argument after -i_ply ");
03330 exit (1);
03331 }
03332 if (ps->i_N_surfnames >= SUMA_MAX_SURF_ON_COMMAND) {
03333 SUMA_S_Err("Exceeding maximum number of allowed surfaces...");
03334 exit(1);
03335 }
03336 ps->i_surfnames[ps->i_N_surfnames] = SUMA_copy_string(argv[kar]);
03337 ps->i_FT[ps->i_N_surfnames] = SUMA_PLY;
03338 ps->i_FF[ps->i_N_surfnames] = SUMA_FF_NOT_SPECIFIED;
03339 ++ps->i_N_surfnames;
03340 brk = YUP;
03341 }
03342 if (!brk && ( (strcmp(argv[kar], "-i_DX") == 0) || (strcmp(argv[kar], "-i_dx") == 0) || (strcmp(argv[kar], "-i_Dx") == 0))) {
03343 ps->arg_checked[kar]=1;
03344 kar ++; ps->arg_checked[kar]=1;
03345 if (kar >= argc) {
03346 SUMA_S_Err( "need argument after -i_dx ");
03347 exit (1);
03348 }
03349 if (ps->i_N_surfnames >= SUMA_MAX_SURF_ON_COMMAND) {
03350 SUMA_S_Err("Exceeding maximum number of allowed surfaces...");
03351 exit(1);
03352 }
03353 ps->i_surfnames[ps->i_N_surfnames] = SUMA_copy_string(argv[kar]);
03354 ps->i_FT[ps->i_N_surfnames] = SUMA_OPENDX_MESH;
03355 ps->i_FF[ps->i_N_surfnames] = SUMA_ASCII;
03356 ++ps->i_N_surfnames;
03357 brk = YUP;
03358 }
03359 if (!brk && ( (strcmp(argv[kar], "-i_iv") == 0) || (strcmp(argv[kar], "-i_IV") == 0) )) {
03360 ps->arg_checked[kar]=1;
03361 kar ++; ps->arg_checked[kar]=1;
03362 if (kar >= argc) {
03363 SUMA_S_Err( "need argument after -i_iv ");
03364 exit (1);
03365 }
03366 if (ps->i_N_surfnames >= SUMA_MAX_SURF_ON_COMMAND) {
03367 SUMA_S_Err("Exceeding maximum number of allowed surfaces...");
03368 exit(1);
03369 }
03370 ps->i_surfnames[ps->i_N_surfnames] = SUMA_copy_string(argv[kar]);
03371 ps->i_FT[ps->i_N_surfnames] = SUMA_INVENTOR_GENERIC;
03372 ps->i_FF[ps->i_N_surfnames] = SUMA_ASCII;
03373 ++ps->i_N_surfnames;
03374 brk = YUP;
03375 }
03376
03377 }
03378
03379 if (ps->accept_ipar) {
03380 if (!brk && ( (strcmp(argv[kar], "-ipar_bv") == 0) || (strcmp(argv[kar], "-ipar_BV") == 0) ) ) {
03381 ps->arg_checked[kar]=1;
03382 kar ++; ps->arg_checked[kar]=1;
03383 if (kar >= argc) {
03384 SUMA_S_Err( "need argument after -ipar_bv ");
03385 exit (1);
03386 }
03387 if (ps->ipar_N_surfnames >= SUMA_MAX_SURF_ON_COMMAND) {
03388 SUMA_SL_Err("Exceeding maximum number of allowed surfaces...");
03389 exit(1);
03390 }
03391 ps->ipar_surfnames[ps->ipar_N_surfnames] = SUMA_copy_string(argv[kar]);
03392 ps->ipar_FT[ps->ipar_N_surfnames] = SUMA_BRAIN_VOYAGER;
03393 ps->ipar_FF[ps->ipar_N_surfnames] = SUMA_BINARY;
03394 ++ps->ipar_N_surfnames;
03395 brk = YUP;
03396 }
03397
03398 if (!brk && ( (strcmp(argv[kar], "-ipar_fs") == 0) || (strcmp(argv[kar], "-ipar_FS") == 0)) ) {
03399 ps->arg_checked[kar]=1;
03400 kar ++; ps->arg_checked[kar]=1;
03401 if (kar >= argc) {
03402 SUMA_S_Err( "need argument after -ipar_fs ");
03403 exit (1);
03404 }
03405 if (ps->ipar_N_surfnames >= SUMA_MAX_SURF_ON_COMMAND) {
03406 SUMA_SL_Err("Exceeding maximum number of allowed surfaces...");
03407 exit(1);
03408 }
03409 ps->ipar_surfnames[ps->ipar_N_surfnames] = SUMA_copy_string(argv[kar]);
03410 ps->ipar_FT[ps->ipar_N_surfnames] = SUMA_FREE_SURFER;
03411 if (SUMA_isExtension(ps->ipar_surfnames[ps->ipar_N_surfnames], ".asc"))
03412 ps->ipar_FF[ps->ipar_N_surfnames] = SUMA_ASCII;
03413 else
03414 ps->ipar_FF[ps->ipar_N_surfnames] = SUMA_BINARY_BE;
03415 ++ps->ipar_N_surfnames;
03416 brk = YUP;
03417 }
03418
03419 if (!brk && ( (strcmp(argv[kar], "-ipar_sf") == 0) || (strcmp(argv[kar], "-ipar_SF") == 0)) ){
03420 ps->arg_checked[kar]=1;
03421 kar ++; ps->arg_checked[kar]=1;
03422 if (kar+1 >= argc) {
03423 SUMA_S_Err( "need 2 arguments after -ipar_sf");
03424 exit (1);
03425 }
03426 if (ps->ipar_N_surfnames >= SUMA_MAX_SURF_ON_COMMAND) {
03427 SUMA_S_Err("Exceeding maximum number of allowed surfaces...");
03428 exit(1);
03429 }
03430 ps->ipar_surfnames[ps->ipar_N_surfnames] = SUMA_copy_string(argv[kar]);
03431 kar ++; ps->arg_checked[kar]=1;
03432 ps->ipar_surftopo[ps->ipar_N_surfnames] = SUMA_copy_string(argv[kar]);
03433 ps->ipar_FT[ps->ipar_N_surfnames] = SUMA_SUREFIT;
03434 ps->ipar_FF[ps->ipar_N_surfnames] = SUMA_ASCII;
03435 ++ps->ipar_N_surfnames;
03436 brk = YUP;
03437 }
03438
03439 if (!brk && ( (strcmp(argv[kar], "-ipar_vec") == 0) || (strcmp(argv[kar], "-ipar_1d") == 0) ||
03440 (strcmp(argv[kar], "-ipar_VEC") == 0) || (strcmp(argv[kar], "-ipar_1D") == 0) ) ) {
03441 ps->arg_checked[kar]=1;
03442 kar ++; ps->arg_checked[kar]=1;
03443 if (kar+1 >= argc) {
03444 SUMA_S_Err( "need 2 argument after -ipar_vec or -ipar_1d");
03445 exit (1);
03446 }
03447 if (ps->ipar_N_surfnames >= SUMA_MAX_SURF_ON_COMMAND) {
03448 SUMA_S_Err("Exceeding maximum number of allowed surfaces...");
03449 exit(1);
03450 }
03451 ps->ipar_surfnames[ps->ipar_N_surfnames] = SUMA_copy_string(argv[kar]);
03452 kar ++; ps->arg_checked[kar]=1;
03453 ps->ipar_surftopo[ps->ipar_N_surfnames] = SUMA_copy_string(argv[kar]);
03454 ps->ipar_FT[ps->ipar_N_surfnames] = SUMA_VEC;
03455 ps->ipar_FF[ps->ipar_N_surfnames] = SUMA_ASCII;
03456 ++ps->ipar_N_surfnames;
03457 brk = YUP;
03458 }
03459
03460 if (!brk && ( (strcmp(argv[kar], "-ipar_ply") == 0) || (strcmp(argv[kar], "-ipar_Ply") == 0) || (strcmp(argv[kar], "-ipar_PLY") == 0))) {
03461 ps->arg_checked[kar]=1;
03462 kar ++; ps->arg_checked[kar]=1;
03463 if (kar >= argc) {
03464 SUMA_S_Err( "need argument after -ipar_ply ");
03465 exit (1);
03466 }
03467 if (ps->ipar_N_surfnames >= SUMA_MAX_SURF_ON_COMMAND) {
03468 SUMA_S_Err("Exceeding maximum number of allowed surfaces...");
03469 exit(1);
03470 }
03471 ps->ipar_surfnames[ps->ipar_N_surfnames] = SUMA_copy_string(argv[kar]);
03472 ps->ipar_FT[ps->ipar_N_surfnames] = SUMA_PLY;
03473 ps->ipar_FF[ps->ipar_N_surfnames] = SUMA_FF_NOT_SPECIFIED;
03474 ++ps->ipar_N_surfnames;
03475 brk = YUP;
03476 }
03477 if (!brk && ( (strcmp(argv[kar], "-ipar_DX") == 0) || (strcmp(argv[kar], "-ipar_dx") == 0) || (strcmp(argv[kar], "-ipar_Dx") == 0))) {
03478 ps->arg_checked[kar]=1;
03479 kar ++; ps->arg_checked[kar]=1;
03480 if (kar >= argc) {
03481 SUMA_S_Err( "need argument after -ipar_dx ");
03482 exit (1);
03483 }
03484 if (ps->ipar_N_surfnames >= SUMA_MAX_SURF_ON_COMMAND) {
03485 SUMA_S_Err("Exceeding maximum number of allowed surfaces...");
03486 exit(1);
03487 }
03488 ps->ipar_surfnames[ps->ipar_N_surfnames] = SUMA_copy_string(argv[kar]);
03489 ps->ipar_FT[ps->ipar_N_surfnames] = SUMA_OPENDX_MESH;
03490 ps->ipar_FF[ps->ipar_N_surfnames] = SUMA_ASCII;
03491 ++ps->ipar_N_surfnames;
03492 brk = YUP;
03493 }
03494 if (!brk && ( (strcmp(argv[kar], "-ipar_iv") == 0) || (strcmp(argv[kar], "-ipar_IV") == 0) )) {
03495 ps->arg_checked[kar]=1;
03496 kar ++; ps->arg_checked[kar]=1;
03497 if (kar >= argc) {
03498 SUMA_S_Err( "need argument after -ipar_iv ");
03499 exit (1);
03500 }
03501 if (ps->ipar_N_surfnames >= SUMA_MAX_SURF_ON_COMMAND) {
03502 SUMA_S_Err("Exceeding maximum number of allowed surfaces...");
03503 exit(1);
03504 }
03505 ps->ipar_surfnames[ps->ipar_N_surfnames] = SUMA_copy_string(argv[kar]);
03506 ps->ipar_FT[ps->ipar_N_surfnames] = SUMA_INVENTOR_GENERIC;
03507 ps->ipar_FF[ps->ipar_N_surfnames] = SUMA_ASCII;
03508 ++ps->ipar_N_surfnames;
03509 brk = YUP;
03510 }
03511 }
03512
03513 if (ps->accept_t) {
03514 if (!brk && (strcmp(argv[kar], "-tn") == 0)) {
03515 ps->arg_checked[kar]=1;
03516 kar ++; ps->arg_checked[kar]=1;
03517 if (kar >= argc) {
03518 SUMA_S_Err( "Type argument must follow -tn ");
03519 exit (1);
03520 }
03521 if (ps->t_N_surfnames >= SUMA_MAX_SURF_ON_COMMAND) {
03522 SUMA_SL_Err("Exceeding maximum number of allowed surfaces...");
03523 exit(1);
03524 }
03525 /* get the type */
03526 ps->t_FT[ps->t_N_surfnames] = SUMA_SurfaceTypeCode(argv[kar]);
03527 if (ps->t_FT[ps->t_N_surfnames] == SUMA_FT_ERROR || ps->t_FT[ps->t_N_surfnames] == SUMA_FT_NOT_SPECIFIED) {
03528 fprintf (SUMA_STDERR, "%s is a bad file type.\n", argv[kar]);
03529 exit(1);
03530 }
03531 /* get the name */
03532 if (ps->t_FT[ps->t_N_surfnames] == SUMA_SUREFIT || ps->t_FT[ps->t_N_surfnames] == SUMA_VEC) N_name = 2;
03533 else N_name = 1;
03534 if (kar+N_name >= argc) {
03535 fprintf (SUMA_STDERR, "need %d elements for NAME \n", N_name);
03536 exit (1);
03537 }
03538 kar ++; ps->arg_checked[kar]=1;
03539 ps->t_surfnames[ps->t_N_surfnames] = SUMA_copy_string(argv[kar]);
03540 if (N_name == 2) {
03541 kar ++; ps->arg_checked[kar]=1;
03542 ps->t_surftopo[ps->t_N_surfnames] = SUMA_copy_string(argv[kar]);
03543 }
03544
03545 ++ps->t_N_surfnames;
03546 brk = YUP;
03547 }
03548
03549 if (!brk && (strcmp(argv[kar], "-tsn") == 0)) {
03550 ps->arg_checked[kar]=1;
03551 kar ++; ps->arg_checked[kar]=1;
03552 if (kar >= argc) {
03553 fprintf (SUMA_STDERR, "Type argument must follow -tn \n");
03554 exit (1);
03555 }
03556 if (ps->t_N_surfnames >= SUMA_MAX_SURF_ON_COMMAND) {
03557 SUMA_SL_Err("Exceeding maximum number of allowed surfaces...");
03558 exit(1);
03559 }
03560 /* get the type */
03561 ps->t_FT[ps->t_N_surfnames] = SUMA_SurfaceTypeCode(argv[kar]);
03562 if (ps->t_FT[ps->t_N_surfnames] == SUMA_FT_ERROR || ps->t_FT[ps->t_N_surfnames] == SUMA_FT_NOT_SPECIFIED) {
03563 fprintf (SUMA_STDERR, "%s is a bad file type.\n", argv[kar]);
03564 exit(1);
03565 }
03566 /* get the state */
03567 kar ++; ps->arg_checked[kar]=1;
03568 if (kar >= argc) {
03569 SUMA_S_Err( "STATE argument must follow TYPE with -tsn ");
03570 exit (1);
03571 }
03572 ps->t_state[ps->t_N_surfnames] = SUMA_copy_string(argv[kar]);
03573
03574 /* get the name */
03575 if (ps->t_FT[ps->t_N_surfnames] == SUMA_SUREFIT || ps->t_FT[ps->t_N_surfnames] == SUMA_VEC) N_name = 2;
03576 else N_name = 1;
03577 if (kar+N_name >= argc) {
03578 fprintf (SUMA_STDERR, "Error %s:\nneed %d elements for NAME \n", FuncName, N_name);
03579 exit (1);
03580 }
03581 kar ++; ps->arg_checked[kar]=1;
03582 ps->t_surfnames[ps->t_N_surfnames] = SUMA_copy_string(argv[kar]);
03583 if (N_name == 2) {
03584 kar ++; ps->arg_checked[kar]=1;
03585 ps->t_surftopo[ps->t_N_surfnames] = SUMA_copy_string(argv[kar]);
03586 }
03587 /* get the format */
03588 if ( ps->t_FT[ps->t_N_surfnames] == SUMA_SUREFIT || ps->t_FT[ps->t_N_surfnames] == SUMA_VEC ||
03589 ps->t_FT[ps->t_N_surfnames] == SUMA_INVENTOR_GENERIC || ps->t_FT[ps->t_N_surfnames] == SUMA_OPENDX_MESH)
03590 ps->t_FF[ps->t_N_surfnames] = SUMA_ASCII;
03591 else if (ps->t_FT[ps->t_N_surfnames] == SUMA_PLY) ps->t_FF[ps->t_N_surfnames] = SUMA_FF_NOT_SPECIFIED;
03592 else if (ps->t_FT[ps->t_N_surfnames] == SUMA_BRAIN_VOYAGER) ps->t_FF[ps->t_N_surfnames] = SUMA_BINARY;
03593 else if (ps->t_FT[ps->t_N_surfnames] == SUMA_FREE_SURFER) {
03594 if (SUMA_isExtension(ps->t_surfnames[ps->t_N_surfnames], ".asc"))
03595 ps->t_FF[ps->t_N_surfnames] = SUMA_ASCII;
03596 else
03597 ps->t_FF[ps->t_N_surfnames] = SUMA_BINARY_BE;
03598 }
03599
03600 ++ps->t_N_surfnames;
03601 brk = YUP;
03602 }
03603
03604 }
03605 if (ps->accept_o) {
03606 if (!brk && ( (strcmp(argv[kar], "-o_fs") == 0) || (strcmp(argv[kar], "-o_FS") == 0) ) ) {
03607 ps->arg_checked[kar]=1;
03608 kar ++; ps->arg_checked[kar]=1;
03609 if (kar >= argc) {
03610 SUMA_S_Err( "need argument after -o_fs ");
03611 exit (1);
03612 }
03613 if (ps->o_N_surfnames >= SUMA_MAX_SURF_ON_COMMAND) {
03614 SUMA_S_Err("Exceeding maximum number of allowed surfaces...");
03615 exit(1);
03616 }
03617 ps->o_surfnames[ps->o_N_surfnames] = SUMA_RemoveSurfNameExtension(argv[kar], SUMA_FREE_SURFER);
03618 ps->o_FT[ps->o_N_surfnames] = SUMA_FREE_SURFER;
03619 ps->o_FF[ps->o_N_surfnames] = SUMA_ASCII;
03620 ++ps->o_N_surfnames;
03621 brk = YUP;
03622 }
03623
03624 if (!brk && ( (strcmp(argv[kar], "-o_fsp") == 0) || (strcmp(argv[kar], "-o_FSP") == 0) ) ) {
03625 ps->arg_checked[kar]=1;
03626 kar ++; ps->arg_checked[kar]=1;
03627 if (kar >= argc) {
03628 SUMA_S_Err( "need argument after -o_fsp ");
03629 exit (1);
03630 }
03631 if (ps->o_N_surfnames >= SUMA_MAX_SURF_ON_COMMAND) {
03632 SUMA_SL_Err("Exceeding maximum number of allowed surfaces...");
03633 exit(1);
03634 }
03635
03636 ps->o_surfnames[ps->o_N_surfnames] = SUMA_RemoveSurfNameExtension(argv[kar], SUMA_FREE_SURFER_PATCH);
03637 ps->o_FT[ps->o_N_surfnames] = SUMA_FREE_SURFER_PATCH;
03638 ps->o_FF[ps->o_N_surfnames] = SUMA_BINARY;
03639 ++ps->o_N_surfnames;
03640 brk = YUP;
03641 }
03642
03643 if (!brk && ( (strcmp(argv[kar], "-o_sf") == 0) || (strcmp(argv[kar], "-o_SF") == 0)) ) {
03644 ps->arg_checked[kar]=1;
03645 kar ++; ps->arg_checked[kar]=1;
03646 if (kar >= argc) {
03647 SUMA_S_Err( "need 1 or 2 argument after -o_sf ");
03648 exit (1);
03649 }
03650 if (ps->o_N_surfnames >= SUMA_MAX_SURF_ON_COMMAND) {
03651 SUMA_S_Err("Exceeding maximum number of allowed surfaces...");
03652 exit(1);
03653 }
03654 ps->o_surfnames[ps->o_N_surfnames] = SUMA_RemoveSurfNameExtension(argv[kar], SUMA_SUREFIT);
03655 ps->o_FT[ps->o_N_surfnames] = SUMA_SUREFIT;
03656 ps->o_FF[ps->o_N_surfnames] = SUMA_ASCII;
03657 /* is there another argument ?*/
03658 if (kar+1 < argc) {
03659 if (argv[kar+1][0] == '-') {
03660 /* that is an option flag */
03661 ps->o_surftopo[ps->o_N_surfnames] = SUMA_copy_string(ps->o_surfnames[ps->o_N_surfnames]);
03662 } else {
03663 kar ++; ps->arg_checked[kar]=1;
03664 ps->o_surftopo[ps->o_N_surfnames] = SUMA_RemoveSurfNameExtension(argv[kar], SUMA_SUREFIT);
03665 }
03666 }
03667 ++ps->o_N_surfnames;
03668 brk = YUP;
03669 }
03670
03671
03672 if (!brk && ( (strcmp(argv[kar], "-o_vec") == 0) || (strcmp(argv[kar], "-o_1d") == 0) ||
03673 (strcmp(argv[kar], "-o_VEC") == 0) || (strcmp(argv[kar], "-o_1D") == 0) ) ) {
03674 ps->arg_checked[kar]=1;
03675 kar ++; ps->arg_checked[kar]=1;
03676 if (kar >= argc) {
03677 SUMA_S_Err( "need 1 or 2 argument after -o_sf ");
03678 exit (1);
03679 }
03680 if (ps->o_N_surfnames >= SUMA_MAX_SURF_ON_COMMAND) {
03681 SUMA_S_Err("Exceeding maximum number of allowed surfaces...");
03682 exit(1);
03683 }
03684 ps->o_surfnames[ps->o_N_surfnames] = SUMA_RemoveSurfNameExtension(argv[kar], SUMA_VEC);
03685 ps->o_FT[ps->o_N_surfnames] = SUMA_VEC;
03686 ps->o_FF[ps->o_N_surfnames] = SUMA_ASCII;
03687 /* is there another argument ?*/
03688 if (kar+1 < argc) {
03689 if (argv[kar+1][0] == '-') {
03690 /* that is an option flag */
03691 ps->o_surftopo[ps->o_N_surfnames] = SUMA_copy_string(ps->o_surfnames[ps->o_N_surfnames]);
03692 } else {
03693 kar ++; ps->arg_checked[kar]=1;
03694 ps->o_surftopo[ps->o_N_surfnames] = SUMA_RemoveSurfNameExtension(argv[kar], SUMA_VEC);
03695 }
03696 }
03697 ++ps->o_N_surfnames;
03698 brk = YUP;
03699 }
03700
03701 if (!brk && ( (strcmp(argv[kar], "-o_dx") == 0) || (strcmp(argv[kar], "-o_DX") == 0) || (strcmp(argv[kar], "-o_Dx") == 0)) ) {
03702 ps->arg_checked[kar]=1;
03703 kar ++; ps->arg_checked[kar]=1;
03704 if (kar >= argc) {
03705 SUMA_S_Err( "need argument after -o_dx \n");
03706 exit (1);
03707 }
03708 if (ps->o_N_surfnames >= SUMA_MAX_SURF_ON_COMMAND) {
03709 SUMA_S_Err("Exceeding maximum number of allowed surfaces...");
03710 exit(1);
03711 }
03712 ps->o_surfnames[ps->o_N_surfnames] = SUMA_RemoveSurfNameExtension(argv[kar], SUMA_OPENDX_MESH);
03713 ps->o_FT[ps->o_N_surfnames] = SUMA_OPENDX_MESH;
03714 ps->o_FF[ps->o_N_surfnames] = SUMA_ASCII;
03715 ++ps->o_N_surfnames;
03716 brk = YUP;
03717 }
03718 if (!brk && ( (strcmp(argv[kar], "-o_ply") == 0) || (strcmp(argv[kar], "-o_PLY") == 0) || (strcmp(argv[kar], "-o_Ply") == 0)) ) {
03719 ps->arg_checked[kar]=1;
03720 kar ++; ps->arg_checked[kar]=1;
03721 if (kar >= argc) {
03722 SUMA_S_Err( "need argument after -o_ply \n");
03723 exit (1);
03724 }
03725 if (ps->o_N_surfnames >= SUMA_MAX_SURF_ON_COMMAND) {
03726 SUMA_S_Err("Exceeding maximum number of allowed surfaces...");
03727 exit(1);
03728 }
03729 ps->o_surfnames[ps->o_N_surfnames] = SUMA_RemoveSurfNameExtension(argv[kar], SUMA_PLY);
03730 ps->o_FT[ps->o_N_surfnames] = SUMA_PLY;
03731 ps->o_FF[ps->o_N_surfnames] = SUMA_ASCII;
03732 ++ps->o_N_surfnames;
03733 brk = YUP;
03734 }
03735 }
03736
03737 brk = NOPE;
03738 kar ++;
03739 }
03740
03741 if (ps->cs->rps > 0) { ps->cs->nelps = (float)ps->cs->talk_suma * ps->cs->rps; }
03742 else { ps->cs->nelps = (float) ps->cs->talk_suma * -1.0; }
03743
03744
03745 SUMA_RETURN(ps);
03746 }
|
|
||||||||||||||||||||||||
|
** Purpose : Append or prepend command Scom to S Usage : Ret = SUMA_RegisterCommand(char *S, char d, char term, char *Scom, SUMA_Boolean Prepend); Input paramters :
Definition at line 482 of file SUMA_ParseCommands.c. References i, S, SUMA_Boolean, SUMA_ENTRY, SUMA_MAX_COMMAND_LENGTH, and SUMA_RETURN.
00483 { int i, iStop, iorig, iStopNew, nCom;
00484 static char FuncName[]={"SUMA_RegisterCommand"};
00485
00486 SUMA_ENTRY;
00487
00488 fprintf (SUMA_STDERR, "Error %s: This function is now obsolete. Must use SUMA_RegisterCommand instead.\n", FuncName);
00489 SUMA_RETURN (NOPE);
00490
00491 iStop = strlen(S)-1;
00492
00493 nCom = strlen(Scom);
00494 /*fprintf (stdout,"Scom->%s<-, length %d\n", Scom, nCom);*/
00495 if (strlen(Scom) + iStop + 2 > SUMA_MAX_COMMAND_LENGTH ) {
00496 fprintf (stderr, "%s Error: Resultant command longer than SUMA_MAX_COMMAND_LENGTH!\n\a", FuncName);
00497 SUMA_RETURN (NOPE);
00498 }
00499 if (S[iStop] != term) {
00500 fprintf (stderr, "%s Error: S improperly terminated!\n\a", FuncName);
00501 SUMA_RETURN (NOPE);
00502 }
00503 if (!Prepend) {
00504 /* add a delimiter */
00505 if (S[iStop-1] != d) {
00506 S[iStop] = d;
00507 iStop += 1;
00508 }
00509 /*append the command */
00510 for (i=0; i <nCom; ++i) {
00511 S[iStop+i] = Scom[i];
00512 }
00513 iStop += nCom;
00514 S[iStop] = term;
00515 S[iStop+1] = '\0';
00516 SUMA_RETURN (YUP);
00517 } else {
00518 /* move old string forward*/
00519 iStopNew = iStop+nCom+1;
00520 S[iStopNew+1] = '\0';
00521 iorig = 0;
00522 while (iorig <= iStop) {
00523 S[iStopNew-iorig] = S[iStop-iorig];
00524 ++iorig;
00525 }
00526 S[iStopNew-iorig] = d;
00527
00528 /*add new one */
00529 for (i=0; i < nCom; ++i) {
00530 S[i] = Scom[i];
00531 }
00532 iStop = iStopNew;
00533 SUMA_RETURN (YUP);
00534 }
00535 }
|
|
||||||||||||||||||||||||||||
|
SUMA_Boolean SUMA_RegisterEngineData (SUMA_EngineData *ED, char *Fldname, void *FldValp, char *DestName, char *SourceName, SUMA_Boolean PassByPointer)
+PassByPointer option is only useful when dealing with fields that are/can be dynamically allocated like fm and fi. For fields like fv3 or iv15 then assignments are done by value and not pointers. +You cannot set the value of a field unless the destination for the pre-existing data in that field has been reached +When passing by value for fields requiring allocation, like fm or fi, you must be sure that ED->N_cols and ED->N_rows are set correctly before you call the function.
Definition at line 1372 of file SUMA_ParseCommands.c. References SUMA_EngineData::cp, SUMA_EngineData::cp_Dest, SUMA_EngineData::f, SUMA_EngineData::f_Dest, SUMA_EngineData::f_Source, SUMA_EngineData::fm, SUMA_EngineData::fm_Dest, SUMA_EngineData::fm_LocalAlloc, SUMA_EngineData::fm_Source, SUMA_EngineData::fp, SUMA_EngineData::fp_Dest, ft, SUMA_EngineData::fv15, SUMA_EngineData::fv15_Dest, SUMA_EngineData::fv15_Source, SUMA_EngineData::fv200, SUMA_EngineData::fv200_Dest, SUMA_EngineData::fv200_Source, SUMA_EngineData::fv3, SUMA_EngineData::fv3_Dest, SUMA_EngineData::fv3_Source, i, SUMA_EngineData::i, SUMA_EngineData::i_Dest, SUMA_EngineData::i_Source, SUMA_EngineData::im, SUMA_EngineData::im_Dest, SUMA_EngineData::im_LocalAlloc, SUMA_EngineData::im_Source, SUMA_EngineData::ip, SUMA_EngineData::ip_Dest, SUMA_EngineData::iv15, SUMA_EngineData::iv15_Dest, SUMA_EngineData::iv15_Source, SUMA_EngineData::iv200, SUMA_EngineData::iv200_Dest, SUMA_EngineData::iv200_Source, SUMA_EngineData::iv3, SUMA_EngineData::iv3_Dest, SUMA_EngineData::iv3_Source, SUMA_EngineData::N_cols, SUMA_EngineData::N_rows, SUMA_EngineData::s, SUMA_EngineData::s_Dest, SUMA_EngineData::s_Source, SE_BadCode, SE_Empty, SEF_cp, SEF_Empty, SEF_f, SEF_fm, SEF_fp, SEF_fv15, SEF_fv200, SEF_fv3, SEF_i, SEF_im, SEF_ip, SEF_iv15, SEF_iv200, SEF_iv3, SEF_s, SEF_vp, SUMA_allocate2D(), SUMA_Boolean, SUMA_CommandCode(), SUMA_EngineFieldCode(), SUMA_EngineSourceCode(), SUMA_ENTRY, SUMA_MAX_STRING_LENGTH, SUMA_RETURN, SUMA_EngineData::vp, SUMA_EngineData::vp_Dest, and SUMA_EngineData::vp_Source.
01373 { /* SUMA_RegisterEngineData*/
01374 int Dest, Fld, Src;
01375 static char FuncName[]={"SUMA_RegisterEngineData"};
01376
01377 SUMA_ENTRY;
01378
01379 fprintf (SUMA_STDERR, "Error %s: This function is now obsolete. Must use SUMA_RegisterEngineListCommand instead.\n", FuncName);
01380 SUMA_RETURN (NOPE);
01381
01382 Dest = SUMA_CommandCode((char *)DestName);
01383 Fld = SUMA_EngineFieldCode((char *)Fldname);
01384 Src = SUMA_EngineSourceCode ((char *)SourceName);
01385
01386 /* make sure Destination is good and wholesome*/
01387 switch (Dest) {
01388 case SE_BadCode:
01389 fprintf (SUMA_STDERR, "Error in %s: Bad code string.\n", FuncName);
01390 SUMA_RETURN (NOPE);
01391 break;
01392 case SE_Empty:
01393 fprintf (SUMA_STDERR, "Error in %s: Empty code string.\n", FuncName);
01394 SUMA_RETURN (NOPE);
01395 break;
01396 default:
01397 break;
01398 }
01399
01400 /*fprintf(SUMA_STDOUT, "%s: Registering %s for %s\n", FuncName, Fldname, DestName);*/
01401
01402 switch (Fld) { /* switch Fld */
01403 case SEF_fm:
01404 if (ED->fm_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01405 fprintf(SUMA_STDERR, "Error %s: field %s has a preset destination (%d).\n", FuncName, Fldname, ED->fm_Dest);
01406 SUMA_RETURN (NOPE);
01407 }
01408 /* space available*/
01409 if (PassByPointer) {
01410 /* pass the pointer */
01411 ED->fm = (float **)FldValp;
01412 ED->fm_LocalAlloc = NOPE; /* allocation not done by Engine functions */
01413 }
01414 else { /* pass by value */
01415 if (ED->fm != NULL) {
01416 fprintf(SUMA_STDERR, "Error %s: Passing by value and ED->fm is not NULL. Clean up your act.\n", FuncName);
01417 SUMA_RETURN(NOPE);
01418 }
01419 if (!ED->N_rows || !ED->N_cols) {
01420 fprintf(SUMA_STDERR, "Error %s: ED->N_rows or ED->N_cols is 0.\n", FuncName);
01421 SUMA_RETURN(NOPE);
01422 }
01423 ED->fm = (float **)SUMA_allocate2D(ED->N_rows, ED->N_cols, sizeof(float));
01424 if (ED->fm == NULL) {
01425 fprintf(SUMA_STDERR, "Error %s: Failed to allocate fm.\n", FuncName);
01426 SUMA_RETURN(NOPE);
01427 }
01428 ED->fm_LocalAlloc = YUP; /* allocation done by Engine functions, this can be freed*/
01429 {/* copy the data */
01430 float **fm;
01431 int i, j;
01432 fm = (float **)FldValp;
01433 for (i=0; i < ED->N_rows; ++i) {
01434 for (j=0; j < ED->N_cols; ++j)
01435 ED->fm[i][j] = fm[i][j];
01436 }
01437 }/* copy the data */
01438 }/* pass by value */
01439 /* set the new destination*/
01440 ED->fm_Dest = Dest;
01441 ED->fm_Source = Src;
01442 SUMA_RETURN (YUP);
01443 break;
01444 case SEF_im:
01445 if (ED->im_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01446 fprintf(SUMA_STDERR, "Error %s: field %s has a preset destination (%d).\n", FuncName, Fldname, ED->im_Dest);
01447 SUMA_RETURN (NOPE);
01448 }
01449 /* space available*/
01450 if (PassByPointer) {
01451 /* pass the pointer */
01452 ED->im = (int **)FldValp;
01453 ED->im_LocalAlloc = NOPE; /* allocation not done by Engine functions */
01454 } else { /* pass by value */
01455 if (ED->im != NULL) {
01456 fprintf(SUMA_STDERR, "Error %s: Passing by value and ED->im is not NULL. Clean up your act.\n", FuncName);
01457 SUMA_RETURN(NOPE);
01458 }
01459 if (!ED->N_rows || !ED->N_cols) {
01460 fprintf(SUMA_STDERR, "Error %s: ED->N_rows or ED->N_cols is 0.\n", FuncName);
01461 SUMA_RETURN(NOPE);
01462 }
01463 ED->im = (int **)SUMA_allocate2D(ED->N_rows, ED->N_cols, sizeof(int));
01464 if (ED->im == NULL) {
01465 fprintf(SUMA_STDERR, "Error %s: Failed to allocate im.\n", FuncName);
01466 SUMA_RETURN(NOPE);
01467 }
01468 ED->im_LocalAlloc = YUP; /* allocation done by Engine functions, this can be freed*/
01469 {/* copy the data */
01470 int **im;
01471 int i, j;
01472 im = (int **)FldValp;
01473 for (i=0; i < ED->N_rows; ++i) {
01474 for (j=0; j < ED->N_cols; ++j)
01475 ED->im[i][j] = im[i][j];
01476 }
01477 }/* copy the data */
01478 }/* pass by value */
01479 /* set the new destination*/
01480 ED->im_Dest = Dest;
01481 ED->im_Source = Src;
01482 SUMA_RETURN (YUP);
01483 break;
01484
01485 case SEF_i:
01486 if (ED->i_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01487 fprintf(SUMA_STDERR, "Error %s: field %s has a preset destination (%d).\n", FuncName, Fldname, ED->i_Dest);
01488 SUMA_RETURN (NOPE);
01489 }
01490 { /* assign by value */
01491 int *it;
01492 it = (int*)FldValp;
01493 ED->i = *it;
01494 }
01495 ED->i_Dest = Dest;
01496 ED->i_Source = Src;
01497 SUMA_RETURN (YUP);
01498 break;
01499
01500 case SEF_f:
01501 if (ED->f_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01502 fprintf(SUMA_STDERR, "Error %s: field %s has a preset destination (%d).\n", FuncName, Fldname, ED->f_Dest);
01503 SUMA_RETURN (NOPE);
01504 }
01505 { /* assign by value */
01506 float *ft;
01507 ft = (float*)FldValp;
01508 ED->f = *ft;
01509 }
01510 ED->f_Dest = Dest;
01511 ED->f_Source = Src;
01512 SUMA_RETURN (YUP);
01513 break;
01514
01515 case SEF_fv3:
01516 if (ED->fv3_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01517 fprintf(SUMA_STDERR, "Error %s: field %s has a preset destination (%d).\n", FuncName, Fldname, ED->fv3_Dest);
01518 SUMA_RETURN (NOPE);
01519 }
01520 { /* assign by value */
01521 float *fvt;
01522 int kt;
01523 fvt = (float*)FldValp;
01524 for (kt=0; kt < 3; ++kt) ED->fv3[kt] = fvt[kt];
01525 }
01526 ED->fv3_Dest = Dest;
01527 ED->fv3_Source = Src;
01528 SUMA_RETURN (YUP);
01529 break;
01530
01531 case SEF_fv15:
01532 if (ED->fv15_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01533 fprintf(SUMA_STDERR, "Error %s: field %s has a preset destination (%d).\n", FuncName, Fldname, ED->fv15_Dest);
01534 SUMA_RETURN (NOPE);
01535 }
01536 { /* assign by value */
01537 float *fvt;
01538 int kt;
01539 fvt = (float*)FldValp;
01540 for (kt=0; kt < 15; ++kt) ED->fv15[kt] = fvt[kt];
01541 }
01542 ED->fv15_Dest = Dest;
01543 ED->fv15_Source = Src;
01544 SUMA_RETURN (YUP);
01545 break;
01546
01547 case SEF_fv200:
01548 if (ED->fv200_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01549 fprintf(SUMA_STDERR, "Error %s: field %s has a preset destination (%d).\n", FuncName, Fldname, ED->fv200_Dest);
01550 SUMA_RETURN (NOPE);
01551 }
01552 { /* assign by value */
01553 float *fvt;
01554 int kt;
01555 fvt = (float*)FldValp;
01556 for (kt=0; kt < 200; ++kt) ED->fv200[kt] = fvt[kt];
01557 }
01558 ED->fv200_Dest = Dest;
01559 ED->fv200_Source = Src;
01560 SUMA_RETURN (YUP);
01561 break;
01562
01563 case SEF_iv3:
01564 if (ED->iv3_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01565 fprintf(SUMA_STDERR, "Error %s: field %s has a preset destination (%d).\n", FuncName, Fldname, ED->iv3_Dest);
01566 SUMA_RETURN (NOPE);
01567 }
01568 { /* assign by value */
01569 int *ivt;
01570 int kt;
01571 ivt = (int*)FldValp;
01572 for (kt=0; kt < 3; ++kt) ED->iv3[kt] = ivt[kt];
01573 }
01574 ED->iv3_Dest = Dest;
01575 ED->iv3_Source = Src;
01576 SUMA_RETURN (YUP);
01577 break;
01578
01579 case SEF_iv15:
01580 if (ED->iv15_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01581 fprintf(SUMA_STDERR, "Error %s: field %s has a preset destination (%d).\n", FuncName, Fldname, ED->iv15_Dest);
01582 SUMA_RETURN (NOPE);
01583 }
01584 { /* assign by value */
01585 int *ivt;
01586 int kt;
01587 ivt = (int*)FldValp;
01588 for (kt=0; kt < 15; ++kt) ED->iv15[kt] = ivt[kt];
01589 }
01590 ED->iv15_Dest = Dest;
01591 ED->iv15_Source = Src;
01592 SUMA_RETURN (YUP);
01593 break;
01594
01595 case SEF_iv200:
01596 if (ED->iv200_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01597 fprintf(SUMA_STDERR, "Error %s: field %s has a preset destination (%d).\n", FuncName, Fldname, ED->iv200_Dest);
01598 SUMA_RETURN (NOPE);
01599 }
01600 { /* assign by value */
01601 int *ivt;
01602 int kt;
01603 ivt = (int*)FldValp;
01604 for (kt=0; kt < 200; ++kt) ED->iv200[kt] = ivt[kt];
01605 }
01606 ED->iv200_Dest = Dest;
01607 ED->iv200_Source = Src;
01608 SUMA_RETURN (YUP);
01609 break;
01610
01611 case SEF_s:
01612 if (ED->s_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01613 fprintf(SUMA_STDERR, "Error %s: field %s has a preset destination (%d).\n", FuncName, Fldname, ED->s_Dest);
01614 SUMA_RETURN (NOPE);
01615 }
01616 { /* assign by value */
01617 char *st;
01618 st = (char*)FldValp;
01619 if (strlen(st) < SUMA_MAX_STRING_LENGTH) {
01620 sprintf(ED->s,"%s", st);
01621 } else {
01622 fprintf(SUMA_STDERR, "Error %s: string in FldValp is longer than SUMA_MAX_STRING_LENGTH.\n", FuncName);
01623 SUMA_RETURN (NOPE);
01624 }
01625 }
01626 ED->s_Dest = Dest;
01627 ED->s_Source = Src;
01628 SUMA_RETURN (YUP);
01629 break;
01630
01631 case SEF_vp:
01632 if (ED->vp_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01633 fprintf(SUMA_STDERR, "Error %s: field %s has a preset destination (%d).\n", FuncName, Fldname, ED->vp_Dest);
01634 SUMA_RETURN (NOPE);
01635 }
01636 ED->vp = (void *)FldValp;
01637 ED->vp_Dest = Dest;
01638 ED->vp_Source = Src;
01639 SUMA_RETURN (YUP);
01640 break;
01641
01642 case SEF_ip:
01643 if (ED->ip_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01644 fprintf(SUMA_STDERR, "Error %s: field %s has a preset destination (%d).\n", FuncName, Fldname, ED->ip_Dest);
01645 SUMA_RETURN (NOPE);
01646 }
01647 ED->ip = (int *)FldValp;
01648 ED->ip_Dest = Dest;
01649 SUMA_RETURN (YUP);
01650 break;
01651
01652 case SEF_fp:
01653 if (ED->fp_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01654 fprintf(SUMA_STDERR, "Error %s: field %s has a preset destination (%d).\n", FuncName, Fldname, ED->fp_Dest);
01655 SUMA_RETURN (NOPE);
01656 }
01657 ED->fp = (float *)FldValp;
01658 ED->fp_Dest = Dest;
01659 SUMA_RETURN (YUP);
01660 break;
01661
01662 case SEF_cp:
01663 if (ED->cp_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01664 fprintf(SUMA_STDERR, "Error %s: field %s has a preset destination (%d).\n", FuncName, Fldname, ED->cp_Dest);
01665 SUMA_RETURN (NOPE);
01666 }
01667 ED->cp = (char *)FldValp;
01668 ED->cp_Dest = Dest;
01669 SUMA_RETURN (YUP);
01670 break;
01671
01672 default:
01673 fprintf(SUMA_STDERR, "Error %s: Not setup for field %s yet.\n", FuncName, Fldname);
01674 SUMA_RETURN (NOPE);
01675 break;
01676 }/* switch Fld */
01677
01678
01679 }/* SUMA_RegisterEngineData*/
|
|
||||||||||||||||||||||||||||||||||||||||
|
Adds a new element to the list of commands for SUMA_Engine. NewElement = SUMA_RegisterEngineListCommand ( list, EngineData, FldCode, FldValp, SourceCode, SourcePointer, PassByPointer, InsertAt, Element);.
-NOTE: If a Command requires that mutliple fields be filled, you can call this function repeatedly with the same fields except FldCode, FldValp, SourcePointer and InsertAt should be SEI_In and Element should be the pointer returned in the previous call for SUMA_RegisterEngineListCommand. Definition at line 868 of file SUMA_ParseCommands.c. References SUMA_EngineData::CommandCode, SUMA_EngineData::cp, SUMA_EngineData::cp_Dest, DListElmt_::data, dlist_head, dlist_ins_next(), dlist_ins_prev(), dlist_size, dlist_tail, SUMA_EngineData::f, SUMA_EngineData::f_Dest, SUMA_EngineData::f_Source, SUMA_EngineData::fm, SUMA_EngineData::fm_Dest, SUMA_EngineData::fm_LocalAlloc, SUMA_EngineData::fm_Source, SUMA_EngineData::fp, SUMA_EngineData::fp_Dest, ft, SUMA_EngineData::fv15, SUMA_EngineData::fv15_Dest, SUMA_EngineData::fv15_Source, SUMA_EngineData::fv200, SUMA_EngineData::fv200_Dest, SUMA_EngineData::fv200_Source, SUMA_EngineData::fv3, SUMA_EngineData::fv3_Dest, SUMA_EngineData::fv3_Source, SUMA_EngineData::fvec, SUMA_EngineData::fvec_Dest, SUMA_EngineData::fvec_LocalAlloc, SUMA_EngineData::fvec_Source, i, SUMA_EngineData::i, SUMA_EngineData::i_Dest, SUMA_EngineData::i_Source, SUMA_EngineData::im, SUMA_EngineData::im_Dest, SUMA_EngineData::im_LocalAlloc, SUMA_EngineData::im_Source, SUMA_EngineData::ip, SUMA_EngineData::ip_Dest, SUMA_EngineData::iv15, SUMA_EngineData::iv15_Dest, SUMA_EngineData::iv15_Source, SUMA_EngineData::iv200, SUMA_EngineData::iv200_Dest, SUMA_EngineData::iv200_Source, SUMA_EngineData::iv3, SUMA_EngineData::iv3_Dest, SUMA_EngineData::iv3_Source, SUMA_EngineData::ivec, SUMA_EngineData::ivec_Dest, SUMA_EngineData::ivec_LocalAlloc, SUMA_EngineData::ivec_Source, LocalHead, SUMA_IVEC::n, SUMA_FVEC::n, SUMA_EngineData::N_cols, SUMA_EngineData::N_rows, DListElmt_::next, DListElmt_::prev, SUMA_EngineData::s, SUMA_EngineData::s_Dest, SUMA_EngineData::s_Source, SE_BadCode, SE_Empty, SEF_cp, SEF_Empty, SEF_f, SEF_fm, SEF_fp, SEF_fv15, SEF_fv200, SEF_fv3, SEF_fvec, SEF_i, SEF_im, SEF_ip, SEF_iv15, SEF_iv200, SEF_iv3, SEF_ivec, SEF_s, SEF_vp, SEI_After, SEI_BadLoc, SEI_Before, SEI_Head, SEI_In, SEI_Tail, SEI_WTSDS, SES_Empty, SUMA_EngineData::Src, SUMA_EngineData::Srcp, SUMA_allocate2D(), SUMA_Boolean, SUMA_CommandString(), SUMA_COPY_VEC, SUMA_ENGINE_CODE, SUMA_ENGINE_FIELD_CODE, SUMA_ENGINE_INSERT_LOCATION, SUMA_ENGINE_SOURCE, SUMA_EngineFieldString(), SUMA_ENTRY, SUMA_malloc, SUMA_MAX_STRING_LENGTH, SUMA_RETURN, SUMA_SL_Crit, SUMA_SL_Err, SUMA_IVEC::v, SUMA_FVEC::v, SUMA_EngineData::vp, SUMA_EngineData::vp_Dest, and SUMA_EngineData::vp_Source. Referenced by main(), SUMA_cb_AfniLink_toggled(), SUMA_cb_Cmap_Load(), SUMA_cb_ColPlane_Load(), SUMA_cb_DrawROI_Load(), SUMA_cb_DrawROI_Save(), SUMA_cb_Dset_Load(), SUMA_cb_FileLoadView(), SUMA_cb_FileSaveView(), SUMA_cb_SetRenderMode(), SUMA_cb_XHalock_toggled(), SUMA_cb_XHaviewlock_toggled(), SUMA_cb_XHviewlock_toggled(), SUMA_cmap_wid_input(), SUMA_Engine(), SUMA_HighlightBox(), SUMA_input(), SUMA_JumpFocusFace(), SUMA_JumpFocusNode(), SUMA_JumpIndex(), SUMA_JumpXYZ(), SUMA_LookAtCoordinates(), SUMA_MarkLineSurfaceIntersect(), SUMA_niml_workproc(), SUMA_Paint_SO_ROIplanes(), SUMA_process_NIML_data(), and SUMA_SetLight0().
00872 {
00873 SUMA_ENGINE_CODE Dest=SES_Empty;
00874 static char FuncName[]={"SUMA_RegisterEngineListCommand"};
00875 SUMA_Boolean Refill = NOPE;
00876 DListElmt *tail=NULL, *head=NULL, *NewElement=NULL;
00877 SUMA_EngineData * Old_ED=NULL;
00878 SUMA_IVEC *ivec=NULL;
00879 SUMA_FVEC *fvec=NULL;
00880 SUMA_Boolean LocalHead = NOPE;
00881
00882 SUMA_ENTRY;
00883
00884 if (PassByPointer) {
00885 if (Fld != SEF_im && Fld != SEF_fm && Fld != SEF_ivec && Fld != SEF_fvec) {
00886 SUMA_SL_Err("Cannot use PassByPointer except with SEF_im || SEF_fm || SEF_ivec || SEF_fvec");
00887 SUMA_RETURN (NULL);
00888 }
00889 }
00890
00891 if (!list) {
00892 fprintf (SUMA_STDERR, "Error %s: list has not been initialized.\n", FuncName);
00893 SUMA_RETURN (NULL);
00894 }
00895
00896 if (InsertAt == SEI_In) {
00897 /* adding fields to EngineData, check for errors */
00898 Refill = YUP;
00899 /* Src and Srcp should be the same as before */
00900 if (!Element) {
00901 SUMA_SL_Err("NULL element with SEI_In");
00902 SUMA_RETURN(NULL);
00903 }
00904 Old_ED = (SUMA_EngineData *)Element->data;
00905 if (Old_ED != EngineData) {
00906 fprintf (SUMA_STDERR, "Error %s: EngineData is different from initializing call for Element.\n", FuncName);
00907 SUMA_RETURN (NULL);
00908 }
00909 if (Old_ED->Src != Src) {
00910 fprintf (SUMA_STDERR, "Error %s: Src is different from initializing call for Element.\n", FuncName);
00911 SUMA_RETURN (NULL);
00912 }
00913 if (Old_ED->Srcp != Srcp) {
00914 fprintf (SUMA_STDERR, "Error %s: Srcp is different from initializing call for Element.\n", FuncName);
00915 SUMA_RETURN (NULL);
00916 }
00917 if (Old_ED->CommandCode != EngineData->CommandCode) {
00918 fprintf (SUMA_STDERR, "Error %s: CommandCode is different in EngineData from the one initializing call for Element.\n", FuncName);
00919 SUMA_RETURN (NULL);
00920 }
00921
00922 } else Refill = NOPE;
00923
00924 Dest = EngineData->CommandCode;
00925
00926 if (!Refill) {
00927 /* make sure Destination is good and wholesome*/
00928 switch (Dest) {
00929 case SE_BadCode:
00930 fprintf (SUMA_STDERR, "Error in %s: Bad code string.\n", FuncName);
00931 SUMA_RETURN (NULL);
00932 break;
00933 case SE_Empty:
00934 fprintf (SUMA_STDERR, "Error in %s: Empty code string.\n", FuncName);
00935 SUMA_RETURN (NULL);
00936 break;
00937 default:
00938 break;
00939 }
00940
00941 /* make sure that Srcp is empty or the same as in EngineData */
00942 if (EngineData->Srcp != NULL) {
00943 if (EngineData->Srcp != Srcp) {
00944 fprintf (SUMA_STDERR, "Error %s: Attempting to assign a Srcp to a structure that has a different Srcp.\n", FuncName);
00945 SUMA_RETURN (NULL);
00946 }
00947 }
00948
00949 EngineData->Srcp = Srcp;
00950 EngineData->Src = Src;
00951 }
00952
00953 if (LocalHead) fprintf(SUMA_STDOUT, "%s: Registering %s for %s\n", FuncName, SUMA_EngineFieldString(Fld), SUMA_CommandString (Dest));
00954
00955 switch (Fld) { /* switch Fld */
00956 case SEF_Empty:
00957 break;
00958 case SEF_fm:
00959 if (EngineData->fm_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
00960 fprintf(SUMA_STDERR, "Error %s: field %d has a preset destination (%d).\n", FuncName, Fld, EngineData->fm_Dest);
00961 SUMA_RETURN (NULL);
00962 }
00963 /* space available*/
00964 if (PassByPointer) {
00965 /* pass the pointer */
00966 EngineData->fm = (float **)FldValp;
00967 EngineData->fm_LocalAlloc = NOPE; /* allocation not done by Engine functions */
00968 }
00969 else { /* pass by value */
00970 if (EngineData->fm != NULL) {
00971 fprintf(SUMA_STDERR, "Error %s: Passing by value and EngineData->fm is not NULL. Clean up your act.\n", FuncName);
00972 SUMA_RETURN(NULL);
00973 }
00974 if (!EngineData->N_rows || !EngineData->N_cols) {
00975 fprintf(SUMA_STDERR, "Error %s: EngineData->N_rows or EngineData->N_cols is 0.\n", FuncName);
00976 SUMA_RETURN(NULL);
00977 }
00978 EngineData->fm = (float **)SUMA_allocate2D(EngineData->N_rows, EngineData->N_cols, sizeof(float));
00979 if (EngineData->fm == NULL) {
00980 fprintf(SUMA_STDERR, "Error %s: Failed to allocate fm.\n", FuncName);
00981 SUMA_RETURN(NULL);
00982 }
00983 EngineData->fm_LocalAlloc = YUP; /* allocation done by Engine functions, this can be freed*/
00984 {/* copy the data */
00985 float **fm;
00986 int i, j;
00987 fm = (float **)FldValp;
00988 for (i=0; i < EngineData->N_rows; ++i) {
00989 for (j=0; j < EngineData->N_cols; ++j)
00990 EngineData->fm[i][j] = fm[i][j];
00991 }
00992 }/* copy the data */
00993 }/* pass by value */
00994 /* set the new destination*/
00995 EngineData->fm_Dest = Dest;
00996 EngineData->fm_Source = Src;
00997 break;
00998 case SEF_im:
00999 if (EngineData->im_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01000 fprintf(SUMA_STDERR, "Error %s: field %d has a preset destination (%d).\n", FuncName, Fld, EngineData->im_Dest);
01001 SUMA_RETURN (NULL);
01002 }
01003 /* space available*/
01004 if (PassByPointer) {
01005 /* pass the pointer */
01006 EngineData->im = (int **)FldValp;
01007 EngineData->im_LocalAlloc = NOPE; /* allocation not done by Engine functions */
01008 } else { /* pass by value */
01009 if (EngineData->im != NULL) {
01010 fprintf(SUMA_STDERR, "Error %s: Passing by value and EngineData->im is not NULL. Clean up your act.\n", FuncName);
01011 SUMA_RETURN(NULL);
01012 }
01013 if (!EngineData->N_rows || !EngineData->N_cols) {
01014 fprintf(SUMA_STDERR, "Error %s: EngineData->N_rows or EngineData->N_cols is 0.\n", FuncName);
01015 SUMA_RETURN(NULL);
01016 }
01017 EngineData->im = (int **)SUMA_allocate2D(EngineData->N_rows, EngineData->N_cols, sizeof(int));
01018 if (EngineData->im == NULL) {
01019 fprintf(SUMA_STDERR, "Error %s: Failed to allocate im.\n", FuncName);
01020 SUMA_RETURN(NULL);
01021 }
01022 EngineData->im_LocalAlloc = YUP; /* allocation done by Engine functions, this can be freed*/
01023 {/* copy the data */
01024 int **im;
01025 int i, j;
01026 im = (int **)FldValp;
01027 for (i=0; i < EngineData->N_rows; ++i) {
01028 for (j=0; j < EngineData->N_cols; ++j)
01029 EngineData->im[i][j] = im[i][j];
01030 }
01031 }/* copy the data */
01032 }/* pass by value */
01033 /* set the new destination*/
01034 EngineData->im_Dest = Dest;
01035 EngineData->im_Source = Src;
01036 break;
01037
01038 case SEF_ivec:
01039 if (EngineData->ivec_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01040 fprintf(SUMA_STDERR, "Error %s: field %d has a preset destination (%d).\n", FuncName, Fld, EngineData->ivec_Dest);
01041 SUMA_RETURN (NULL);
01042 }
01043 ivec = (SUMA_IVEC *)FldValp;
01044 /* space available*/
01045 if (PassByPointer) {
01046 EngineData->ivec = ivec;
01047 EngineData->ivec_LocalAlloc = NOPE;
01048 } else {
01049 if (EngineData->fvec != NULL) {
01050 fprintf(SUMA_STDERR, "Error %s: Passing by value and EngineData->fvec is not NULL. Clean up your act.\n", FuncName);
01051 SUMA_RETURN(NULL);
01052 }
01053 if (ivec->n <= 0 && ivec->v) {
01054 fprintf(SUMA_STDERR, "Error %s: ivec->n <= 0 while ivec->v is not NULL. Clean up your act.\n", FuncName);
01055 SUMA_RETURN(NULL);
01056 }
01057 EngineData->ivec_LocalAlloc = YUP;
01058 EngineData->ivec = (SUMA_IVEC*)SUMA_malloc(sizeof(SUMA_IVEC));
01059 EngineData->ivec->v = (int *)SUMA_malloc(ivec->n * sizeof(int));
01060 if (!EngineData->ivec->v) {
01061 SUMA_SL_Crit("Failed to allocate");
01062 SUMA_RETURN(NULL);
01063 }
01064 SUMA_COPY_VEC(ivec->v, EngineData->ivec->v, ivec->n, int, int);
01065 EngineData->ivec->n = ivec->n;
01066 }
01067 /* set the new destination*/
01068 EngineData->ivec_Dest = Dest;
01069 EngineData->ivec_Source = Src;
01070 break;
01071
01072 case SEF_fvec:
01073 if (EngineData->fvec_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01074 fprintf(SUMA_STDERR, "Error %s: field %d has a preset destination (%d).\n", FuncName, Fld, EngineData->fvec_Dest);
01075 SUMA_RETURN (NULL);
01076 }
01077 fvec = (SUMA_FVEC *)FldValp;
01078 /* space available*/
01079 if (PassByPointer) {
01080 EngineData->fvec = fvec;
01081 EngineData->fvec_LocalAlloc = NOPE;
01082 } else {
01083 if (EngineData->fvec != NULL) {
01084 fprintf(SUMA_STDERR, "Error %s: Passing by value and EngineData->fvec is not NULL. Clean up your act.\n", FuncName);
01085 SUMA_RETURN(NULL);
01086 }
01087 if (fvec->n <= 0 && fvec->v) {
01088 fprintf(SUMA_STDERR, "Error %s: fvec->n <= 0 while fvec->v is not NULL. Clean up your act.\n", FuncName);
01089 SUMA_RETURN(NULL);
01090 }
01091 EngineData->fvec_LocalAlloc = YUP;
01092 EngineData->fvec = (SUMA_FVEC*)SUMA_malloc(sizeof(SUMA_FVEC));
01093 EngineData->fvec->v = (float *)SUMA_malloc(fvec->n * sizeof(float));
01094 if (!EngineData->fvec->v) {
01095 SUMA_SL_Crit("Failed to allocate");
01096 SUMA_RETURN(NULL);
01097 }
01098 SUMA_COPY_VEC(fvec->v, EngineData->fvec->v, fvec->n, float, float);
01099 EngineData->fvec->n = fvec->n;
01100 }
01101 /* set the new destination*/
01102 EngineData->fvec_Dest = Dest;
01103 EngineData->fvec_Source = Src;
01104 break;
01105
01106 case SEF_i:
01107 if (EngineData->i_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01108 fprintf(SUMA_STDERR, "Error %s: field %d has a preset destination (%d).\n", FuncName, Fld, EngineData->i_Dest);
01109 SUMA_RETURN (NULL);
01110 }
01111 { /* assign by value */
01112 int *it;
01113 it = (int*)FldValp;
01114 EngineData->i = *it;
01115 }
01116 EngineData->i_Dest = Dest;
01117 EngineData->i_Source = Src;
01118 break;
01119
01120 case SEF_f:
01121 if (EngineData->f_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01122 fprintf(SUMA_STDERR, "Error %s: field %d has a preset destination (%d).\n", FuncName, Fld, EngineData->f_Dest);
01123 SUMA_RETURN (NULL);
01124 }
01125 { /* assign by value */
01126 float *ft;
01127 ft = (float*)FldValp;
01128 EngineData->f = *ft;
01129 }
01130 EngineData->f_Dest = Dest;
01131 EngineData->f_Source = Src;
01132 break;
01133
01134 case SEF_fv3:
01135 if (EngineData->fv3_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01136 fprintf(SUMA_STDERR, "Error %s: field %d has a preset destination (%d).\n", FuncName, Fld, EngineData->fv3_Dest);
01137 SUMA_RETURN (NULL);
01138 }
01139 { /* assign by value */
01140 float *fvt;
01141 int kt;
01142 fvt = (float*)FldValp;
01143 for (kt=0; kt < 3; ++kt) EngineData->fv3[kt] = fvt[kt];
01144 }
01145 EngineData->fv3_Dest = Dest;
01146 EngineData->fv3_Source = Src;
01147 break;
01148
01149 case SEF_fv15:
01150 if (EngineData->fv15_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01151 fprintf(SUMA_STDERR, "Error %s: field %d has a preset destination (%d).\n", FuncName, Fld, EngineData->fv15_Dest);
01152 SUMA_RETURN (NULL);
01153 }
01154 { /* assign by value */
01155 float *fvt;
01156 int kt;
01157 fvt = (float*)FldValp;
01158 for (kt=0; kt < 15; ++kt) EngineData->fv15[kt] = fvt[kt];
01159 }
01160 EngineData->fv15_Dest = Dest;
01161 EngineData->fv15_Source = Src;
01162 break;
01163
01164 case SEF_fv200:
01165 if (EngineData->fv200_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01166 fprintf(SUMA_STDERR, "Error %s: field %d has a preset destination (%d).\n", FuncName, Fld, EngineData->fv200_Dest);
01167 SUMA_RETURN (NULL);
01168 }
01169 { /* assign by value */
01170 float *fvt;
01171 int kt;
01172 fvt = (float*)FldValp;
01173 for (kt=0; kt < 200; ++kt) EngineData->fv200[kt] = fvt[kt];
01174 }
01175 EngineData->fv200_Dest = Dest;
01176 EngineData->fv200_Source = Src;
01177 break;
01178
01179 case SEF_iv3:
01180 if (EngineData->iv3_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01181 fprintf(SUMA_STDERR, "Error %s: field %d has a preset destination (%d).\n", FuncName, Fld, EngineData->iv3_Dest);
01182 SUMA_RETURN (NULL);
01183 }
01184 { /* assign by value */
01185 int *ivt;
01186 int kt;
01187 ivt = (int*)FldValp;
01188 for (kt=0; kt < 3; ++kt) EngineData->iv3[kt] = ivt[kt];
01189 }
01190 EngineData->iv3_Dest = Dest;
01191 EngineData->iv3_Source = Src;
01192 break;
01193
01194 case SEF_iv15:
01195 if (EngineData->iv15_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01196 fprintf(SUMA_STDERR, "Error %s: field %d has a preset destination (%d).\n", FuncName, Fld, EngineData->iv15_Dest);
01197 SUMA_RETURN (NULL);
01198 }
01199 { /* assign by value */
01200 int *ivt;
01201 int kt;
01202 ivt = (int*)FldValp;
01203 for (kt=0; kt < 15; ++kt) EngineData->iv15[kt] = ivt[kt];
01204 }
01205 EngineData->iv15_Dest = Dest;
01206 EngineData->iv15_Source = Src;
01207 break;
01208
01209 case SEF_iv200:
01210 if (EngineData->iv200_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01211 fprintf(SUMA_STDERR, "Error %s: field %d has a preset destination (%d).\n", FuncName, Fld, EngineData->iv200_Dest);
01212 SUMA_RETURN (NULL);
01213 }
01214 { /* assign by value */
01215 int *ivt;
01216 int kt;
01217 ivt = (int*)FldValp;
01218 for (kt=0; kt < 200; ++kt) EngineData->iv200[kt] = ivt[kt];
01219 }
01220 EngineData->iv200_Dest = Dest;
01221 EngineData->iv200_Source = Src;
01222 break;
01223
01224 case SEF_s:
01225 if (EngineData->s_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01226 fprintf(SUMA_STDERR, "Error %s: field %d has a preset destination (%d).\n", FuncName, Fld, EngineData->s_Dest);
01227 SUMA_RETURN (NULL);
01228 }
01229 { /* assign by value */
01230 char *st;
01231 st = (char*)FldValp;
01232 if (strlen(st) < SUMA_MAX_STRING_LENGTH) {
01233 sprintf(EngineData->s,"%s", st);
01234 } else {
01235 fprintf(SUMA_STDERR, "Error %s: string in FldValp is longer than SUMA_MAX_STRING_LENGTH.\n", FuncName);
01236 SUMA_RETURN (NULL);
01237 }
01238 }
01239 EngineData->s_Dest = Dest;
01240 EngineData->s_Source = Src;
01241 break;
01242
01243 case SEF_vp:
01244 if (EngineData->vp_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01245 fprintf(SUMA_STDERR, "Error %s: field %d has a preset destination (%d).\n", FuncName, Fld, EngineData->vp_Dest);
01246 SUMA_RETURN (NULL);
01247 }
01248 EngineData->vp = (void *)FldValp;
01249 EngineData->vp_Dest = Dest;
01250 EngineData->vp_Source = Src;
01251 break;
01252
01253 case SEF_ip:
01254 if (EngineData->ip_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01255 fprintf(SUMA_STDERR, "Error %s: field %d has a preset destination (%d).\n", FuncName, Fld, EngineData->ip_Dest);
01256 SUMA_RETURN (NULL);
01257 }
01258 EngineData->ip = (int *)FldValp;
01259 EngineData->ip_Dest = Dest;
01260 break;
01261
01262 case SEF_fp:
01263 if (EngineData->fp_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01264 fprintf(SUMA_STDERR, "Error %s: field %d has a preset destination (%d).\n", FuncName, Fld, EngineData->fp_Dest);
01265 SUMA_RETURN (NULL);
01266 }
01267 EngineData->fp = (float *)FldValp;
01268 EngineData->fp_Dest = Dest;
01269 break;
01270
01271 case SEF_cp:
01272 if (EngineData->cp_Dest != SEF_Empty) { /* Make sure the data in this field in not predestined */
01273 fprintf(SUMA_STDERR, "Error %s: field %d has a preset destination (%d).\n", FuncName, Fld, EngineData->cp_Dest);
01274 SUMA_RETURN (NULL);
01275 }
01276 EngineData->cp = (char *)FldValp;
01277 EngineData->cp_Dest = Dest;
01278 break;
01279
01280 default:
01281 fprintf(SUMA_STDERR, "Error %s: Not setup for field %d yet.\n", FuncName, Fld);
01282 SUMA_RETURN (NULL);
01283 break;
01284 }/* switch Fld */
01285
01286 /* Now EngineData is filled up, add an element (if not present already) to the list with EngineData */
01287 switch (InsertAt) {
01288 case SEI_In:
01289 if (LocalHead) fprintf (SUMA_STDERR, "%s: Element already in list.\n", FuncName);
01290 NewElement = Element;
01291 break;
01292 case SEI_Tail:
01293 if (LocalHead) fprintf (SUMA_STDERR, "%s: Inserting new element at end of list \n", FuncName);
01294 if (dlist_ins_next (list, dlist_tail(list), (void *)EngineData) < 0) {
01295 fprintf (SUMA_STDERR, "Error %s: Failed to insert element in list.\n", FuncName);
01296 SUMA_RETURN(NULL);
01297 }
01298 NewElement = dlist_tail(list);
01299 break;
01300 case SEI_Head:
01301 if (LocalHead) fprintf (SUMA_STDERR, "%s: Inserting new element at beginning of list \n", FuncName);
01302 if (dlist_ins_prev (list, dlist_head(list), (void *)EngineData) < 0) {
01303 fprintf (SUMA_STDERR, "Error %s: Failed to insert element in list.\n", FuncName);
01304 SUMA_RETURN(NULL);
01305 }
01306 NewElement = dlist_head(list);
01307 break;
01308 case SEI_Before:
01309 if (LocalHead) fprintf (SUMA_STDERR, "%s: Inserting new element before specified element.\n", FuncName);
01310 if (!Element) fprintf (SUMA_STDERR, "Error %s: NULL Element!\n", FuncName);
01311 if (dlist_ins_prev (list, Element, (void *)EngineData) < 0) {
01312 fprintf (SUMA_STDERR, "Error %s: Failed to insert element in list.\n", FuncName);
01313 SUMA_RETURN(NULL);
01314 }
01315 NewElement = Element->prev;
01316 if (!NewElement) {
01317 fprintf (SUMA_STDERR, "Error %s: No previous element. List size %d", FuncName, dlist_size(list));
01318 SUMA_RETURN(NULL);
01319 }
01320 break;
01321 case SEI_After:
01322 if (LocalHead) fprintf (SUMA_STDERR, "%s: Inserting new element after specified element.\n", FuncName);
01323 if (!Element) fprintf (SUMA_STDERR, "Error %s: NULL Element!\n", FuncName);
01324 if (dlist_ins_next (list, Element, (void *)EngineData) < 0) {
01325 fprintf (SUMA_STDERR, "Error %s: Failed to insert element in list.\n", FuncName);
01326 SUMA_RETURN(NULL);
01327 }
01328 NewElement = Element->next;
01329 if (!NewElement) {
01330 fprintf (SUMA_STDERR, "Error %s: No next element. List size %d", FuncName, dlist_size(list));
01331 SUMA_RETURN(NULL);
01332 }
01333 break;
01334 case SEI_WTSDS:
01335 case SEI_BadLoc:
01336 default:
01337 fprintf (SUMA_STDERR, "Error %s: Bad insertion location!\n", FuncName);
01338 SUMA_RETURN(NULL);
01339 break;
01340
01341 }
01342
01343 SUMA_RETURN (NewElement);
01344 }
|
|
||||||||||||||||||||||||
|
Appends a new message to the list of SUMA messages, making sure the number of messages does not exceed SUMA_MAX_MESSAGES Ans = SUMA_RegisterMessage ( list, Message, Source, Type, Action );.
Definition at line 705 of file SUMA_ParseCommands.c. References SUMA_MessageData::Action, dlist_head, dlist_ins_next(), dlist_tail, i, SUMA_MessageData::Message, SE_UpdateLog, SES_Suma, DList_::size, SMA_Log, SMA_LogAndPopup, SMA_Nothing, SUMA_MessageData::Source, SUMA_Boolean, SUMA_copy_string(), SUMA_CreateList(), SUMA_Engine(), SUMA_ENTRY, SUMA_malloc, SUMA_MAX_MESSAGES, SUMA_MESSAGE_ACTION, SUMA_MESSAGE_TYPES, SUMA_PopUpMessage(), SUMA_REGISTER_HEAD_COMMAND_NO_DATA, SUMA_ReleaseMessageListElement(), SUMA_RETURN, and SUMA_MessageData::Type. Referenced by SUMA_ATF_SetValue(), SUMA_cb_ToolsDrawROI(), SUMA_CreateArrowField(), SUMA_CreateBrushStroke(), SUMA_CreateBSDatum(), SUMA_Engine(), SUMA_input(), SUMA_NodeStrokeToConnectedNodes(), SUMA_ProcessBrushStroke(), SUMA_Surf_Plane_Intersect_ROI(), and SUMA_TableF_cb_label_change().
00708 {
00709 static char FuncName[]={"SUMA_RegisterMessage"};
00710 SUMA_MessageData *MD = NULL;
00711 SUMA_Boolean TryLogWindow = NOPE;
00712 int i=0, TrimTheFat=0;
00713
00714 SUMA_ENTRY;
00715
00716 if (!list) {
00717 fprintf (SUMA_STDERR, "Warning %s: list has not been initialized.\n"
00718 "Nothing done.\n", FuncName);
00719 SUMA_RETURN (YUP);
00720 }
00721
00722 /* allocate and initialize element */
00723 MD = (SUMA_MessageData *) SUMA_malloc(sizeof(SUMA_MessageData));
00724 if (!MD) {
00725 fprintf (SUMA_STDERR, "Error %s: Failed to allocate.\n", FuncName);
00726 SUMA_RETURN (NOPE);
00727 }
00728
00729 MD->Message = SUMA_copy_string(Message);
00730 MD->Source = SUMA_copy_string(Source);
00731 MD->Type = Type;
00732 MD->Action = Action;
00733
00734 /* add element at end */
00735 if (dlist_ins_next (list, dlist_tail(list), (void *)MD) < 0) {
00736 fprintf (SUMA_STDERR, "Error %s: Failed to insert message:\n%s from %s in list.\n",
00737 FuncName, MD->Message, MD->Source);
00738 SUMA_RETURN(NOPE);
00739 }
00740
00741 /* make sure size of list is < SUMA_MAX_MESSAGES */
00742 TrimTheFat = list->size - SUMA_MAX_MESSAGES;
00743 if ( TrimTheFat > 0) {
00744 for (i=0; i < TrimTheFat; ++i) {
00745 /* remove the head */
00746 if (!SUMA_ReleaseMessageListElement (list, dlist_head(list))) {
00747 fprintf (SUMA_STDERR, "Error %s: Failed in SUMA_ReleaseMessageListElement.\n", FuncName);
00748 SUMA_RETURN (NOPE);
00749 }
00750 }
00751 }
00752
00753 /* Decide on what to do with new element */
00754 switch (MD->Action) {
00755 case SMA_Nothing:
00756 break;
00757 case SMA_Log:
00758 TryLogWindow = YUP;
00759 break;
00760 case SMA_LogAndPopup:
00761 TryLogWindow = YUP;
00762 SUMA_PopUpMessage (MD);
00763 break;
00764 default:
00765 break;
00766
00767 }
00768
00769 if (TryLogWindow) {
00770 DList *Elist=NULL;
00771 SUMA_EngineData *ED=NULL;
00772
00773 Elist = SUMA_CreateList();
00774 SUMA_REGISTER_HEAD_COMMAND_NO_DATA(Elist, SE_UpdateLog, SES_Suma, NULL);
00775
00776 if (!SUMA_Engine (&Elist)) {
00777 fprintf(SUMA_STDERR, "Error %s: SUMA_Engine call failed.\n", FuncName);
00778 SUMA_RETURN (NOPE);
00779 }
00780 }
00781
00782
00783 SUMA_RETURN (YUP);
00784 }
|
|
|
Releases an action stack data structure -frees AS_data->ActionData WITHOUT calling destructor function -frees AS_data Definition at line 1780 of file SUMA_ParseCommands.c. References SUMA_ACTION_STACK_DATA::ActionData, LocalHead, SUMA_Boolean, SUMA_ENTRY, SUMA_free, and SUMA_RETURNe. Referenced by SUMA_CreateActionStack().
01781 {
01782 static char FuncName[]={"SUMA_ReleaseActionStackData"};
01783 SUMA_ACTION_STACK_DATA *AS_data=NULL;
01784 SUMA_Boolean LocalHead = NOPE;
01785
01786 SUMA_ENTRY;
01787
01788 AS_data=(SUMA_ACTION_STACK_DATA *)asdata;
01789 if (AS_data) {
01790 if (LocalHead) fprintf (SUMA_STDERR, "%s: Releasing Action Stack Data structure\n", FuncName);
01791 /* first you want to free the Action Data */
01792 if (AS_data->ActionData) SUMA_free(AS_data->ActionData);
01793
01794 /* Now you can free the Action Stucture Data */
01795 SUMA_free(AS_data);
01796 }
01797
01798 SUMA_RETURNe;
01799 }
|
|
||||||||||||
|
SUMA_Boolean SUMA_ReleaseEngineData (SUMA_EngineData *ED, char *Location) This function releases data fields that were destined to Location
Memory is freed for fm and im only if their assignment in SUMA_RegisterEngineData was done by value
Definition at line 2177 of file SUMA_ParseCommands.c. References SUMA_EngineData::cp_Dest, SUMA_EngineData::f_Dest, SUMA_EngineData::f_Source, SUMA_EngineData::fm, SUMA_EngineData::fm_Dest, SUMA_EngineData::fm_LocalAlloc, SUMA_EngineData::fm_Source, SUMA_EngineData::fp_Dest, SUMA_EngineData::fv15_Dest, SUMA_EngineData::fv15_Source, SUMA_EngineData::fv200_Dest, SUMA_EngineData::fv200_Source, SUMA_EngineData::fv3_Dest, SUMA_EngineData::fv3_Source, SUMA_EngineData::fvec, SUMA_EngineData::fvec_Dest, SUMA_EngineData::fvec_LocalAlloc, SUMA_EngineData::fvec_Source, SUMA_EngineData::i_Dest, SUMA_EngineData::i_Source, SUMA_EngineData::im, SUMA_EngineData::im_Dest, SUMA_EngineData::im_LocalAlloc, SUMA_EngineData::im_Source, SUMA_EngineData::ip_Dest, SUMA_EngineData::iv15_Dest, SUMA_EngineData::iv15_Source, SUMA_EngineData::iv200_Dest, SUMA_EngineData::iv200_Source, SUMA_EngineData::iv3_Dest, SUMA_EngineData::iv3_Source, SUMA_EngineData::ivec, SUMA_EngineData::ivec_Dest, SUMA_EngineData::ivec_LocalAlloc, SUMA_EngineData::ivec_Source, SUMA_IVEC::n, SUMA_FVEC::n, SUMA_EngineData::N_cols, SUMA_EngineData::N_rows, SUMA_EngineData::s_Dest, SUMA_EngineData::s_Source, SE_BadCode, SE_Empty, SES_Empty, SUMA_Boolean, SUMA_CommandCode(), SUMA_ENTRY, SUMA_free, SUMA_free2D(), SUMA_RETURN, SUMA_IVEC::v, SUMA_FVEC::v, SUMA_EngineData::vp_Dest, and SUMA_EngineData::vp_Source.
02178 {/* SUMA_ReleaseEngineData*/
02179 static char FuncName[]={"SUMA_ReleaseEngineData"};
02180 int Loc;
02181
02182 SUMA_ENTRY;
02183
02184 fprintf (SUMA_STDERR, "Error %s: This function is now obsolete. Must use SUMA_ReleaseEngineListElement instead.\n", FuncName);
02185 SUMA_RETURN (NOPE);
02186
02187 /* search through all fields and clear (or release) all those who should be */
02188 Loc = SUMA_CommandCode((char *)Location);
02189
02190 /* make sure Destination is good and wholesome*/
02191 switch (Loc) {
02192 case SE_BadCode:
02193 fprintf (SUMA_STDERR, "Error in %s: Bad code string.\n", FuncName);
02194 SUMA_RETURN (NOPE);
02195 break;
02196 case SE_Empty:
02197 fprintf (SUMA_STDERR, "Error in %s: Empty code string.\n", FuncName);
02198 SUMA_RETURN (NOPE);
02199 break;
02200 default:
02201 break;
02202 }
02203
02204 /*fprintf(SUMA_STDOUT,"%s : Releasing location %s\n", FuncName, Location);*/
02205 /* go through all the fields*/
02206 /* fm */
02207 if (ED->fm_Dest == Loc) {
02208 /* needs to be released */
02209 if (ED->fm_LocalAlloc) { /* locally allocated */
02210 /* must be freed */
02211 if (!ED->N_rows || !ED->N_cols) {
02212 fprintf (SUMA_STDERR, "Error in %s: ED->N_rows or ED->N_cols is 0 .\n", FuncName);
02213 SUMA_RETURN (NOPE);
02214 }
02215 if (ED->fm == NULL) {
02216 fprintf (SUMA_STDERR, "Error in %s: fm is null already. This should not be .\n", FuncName);
02217 SUMA_RETURN (NOPE);
02218 }
02219 SUMA_free2D((char **)ED->fm, ED->N_rows);
02220 ED->N_rows = ED->N_cols = 0;
02221 ED->fm = NULL;
02222 ED->fm_Dest = SE_Empty;
02223 ED->fm_Source = SES_Empty;
02224 } /* locally allocated */ else { /* passed by pointer */
02225 ED->fm = NULL;
02226 ED->N_rows = ED->N_cols = 0;
02227 ED->fm_Dest = SE_Empty;
02228 ED->fm_Source = SES_Empty;
02229 }/* passed by pointer */
02230 }
02231
02232 /*im*/
02233 if (ED->im_Dest == Loc) {
02234 /* needs to be released */
02235 if (ED->im_LocalAlloc) { /* locally allocated */
02236 /* must be freed */
02237 if (!ED->N_rows || !ED->N_cols) {
02238 fprintf (SUMA_STDERR, "Error in %s: ED->N_rows or ED->N_cols is 0 .\n", FuncName);
02239 SUMA_RETURN (NOPE);
02240 }
02241 if (ED->im == NULL) {
02242 fprintf (SUMA_STDERR, "Error in %s: im is null already. This should not be .\n", FuncName);
02243 SUMA_RETURN (NOPE);
02244 }
02245 SUMA_free2D((char **)ED->im, ED->N_rows);
02246 ED->N_rows = ED->N_cols = 0;
02247 ED->im = NULL;
02248 ED->im_Dest = SE_Empty;
02249 ED->im_Source = SES_Empty;
02250 } /* locally allocated */ else { /* passed by pointer */
02251 ED->im = NULL;
02252 ED->N_rows = ED->N_cols = 0;
02253 ED->im_Dest = SE_Empty;
02254 ED->im_Source = SES_Empty;
02255 }/* passed by pointer */
02256 }
02257
02258 /* ivec */
02259 if (ED->ivec_Dest == Loc) {
02260 /* needs to be released */
02261 if (ED->ivec_LocalAlloc) { /* locally allocated */
02262 /* must be freed */
02263 if (!ED->ivec) {
02264 fprintf (SUMA_STDERR, "Error %s: NULL ivec, why?\n", FuncName);
02265 SUMA_RETURN (NOPE);
02266 }
02267 if (ED->ivec->n > 0 && !ED->ivec->v) {
02268 fprintf (SUMA_STDERR, "Error %s: ED->ivec->n >= 0 && ED->ivec->v = NULL.\n", FuncName);
02269 SUMA_RETURN (NOPE);
02270 }
02271 if (ED->ivec->v == NULL) {
02272 fprintf (SUMA_STDERR, "Error in %s: v is null already. This should not be .\n", FuncName);
02273 SUMA_RETURN (NOPE);
02274 }
02275 if (ED->ivec->v) SUMA_free(ED->ivec->v);
02276 if (ED->ivec) SUMA_free(ED->ivec);
02277 ED->ivec = NULL;
02278 ED->ivec_Dest = SE_Empty;
02279 ED->ivec_Source = SES_Empty;
02280 } /* locally allocated */ else { /* passed by pointer */
02281 ED->ivec = NULL;
02282 ED->ivec_Dest = SE_Empty;
02283 ED->ivec_Source = SES_Empty;
02284 }/* passed by pointer */
02285 }
02286
02287 /* fvec */
02288 if (ED->fvec_Dest == Loc) {
02289 /* needs to be released */
02290 if (ED->fvec_LocalAlloc) { /* locally allocated */
02291 /* must be freed */
02292 if (!ED->fvec) {
02293 fprintf (SUMA_STDERR, "Error %s: NULL fvec, why?\n", FuncName);
02294 SUMA_RETURN (NOPE);
02295 }
02296 if (ED->fvec->n > 0 && !ED->fvec->v) {
02297 fprintf (SUMA_STDERR, "Error %s: ED->fvec->n >= 0 && ED->fvec->v = NULL.\n", FuncName);
02298 SUMA_RETURN (NOPE);
02299 }
02300 if (ED->fvec->v == NULL) {
02301 fprintf (SUMA_STDERR, "Error in %s: v is null already. This should not be .\n", FuncName);
02302 SUMA_RETURN (NOPE);
02303 }
02304 if (ED->fvec->v) SUMA_free(ED->fvec->v);
02305 if (ED->fvec) SUMA_free(ED->fvec);
02306 ED->fvec = NULL;
02307 ED->fvec_Dest = SE_Empty;
02308 ED->fvec_Source = SES_Empty;
02309 } /* locally allocated */ else { /* passed by pointer */
02310 ED->fvec = NULL;
02311 ED->fvec_Dest = SE_Empty;
02312 ED->fvec_Source = SES_Empty;
02313 }/* passed by pointer */
02314 }
02315
02316 /* i */
02317 if (ED->i_Dest == Loc) {
02318 ED->i_Dest = SE_Empty;
02319 ED->i_Source = SES_Empty;
02320 }
02321
02322 /* iv3 */
02323 if (ED->iv3_Dest == Loc) {
02324 ED->iv3_Dest = SE_Empty;
02325 ED->iv3_Source = SES_Empty;
02326 }
02327
02328 /* iv15 */
02329 if (ED->iv15_Dest == Loc) {
02330 ED->iv15_Dest = SE_Empty;
02331 ED->iv15_Source = SES_Empty;
02332 }
02333
02334 /* iv200 */
02335 if (ED->iv200_Dest == Loc) {
02336 ED->iv200_Dest = SE_Empty;
02337 ED->iv200_Source = SES_Empty;
02338 }
02339
02340 /* f */
02341 if (ED->f_Dest == Loc) {
02342 ED->f_Dest = SE_Empty;
02343 ED->f_Source = SES_Empty;
02344 }
02345
02346 /* fv3 */
02347 if (ED->fv3_Dest == Loc) {
02348 ED->fv3_Dest = SE_Empty;
02349 ED->fv3_Source = SES_Empty;
02350 }
02351
02352 /* fv15 */
02353 if (ED->fv15_Dest == Loc) {
02354 ED->fv15_Dest = SE_Empty;
02355 ED->fv15_Source = SES_Empty;
02356 }
02357
02358 /* fv200 */
02359 if (ED->fv200_Dest == Loc) {
02360 ED->fv200_Dest = SE_Empty;
02361 ED->fv200_Source = SES_Empty;
02362 }
02363
02364 /*s*/
02365 if (ED->s_Dest == Loc) {
02366 ED->s_Dest = SE_Empty;
02367 ED->s_Source = SES_Empty;
02368 }
02369
02370 /* vp */
02371 if (ED->vp_Dest == Loc) {
02372 ED->vp_Dest = SE_Empty;
02373 ED->vp_Source = SES_Empty;
02374 }
02375
02376 /* cp */
02377 if (ED->cp_Dest == Loc) {
02378 ED->cp_Dest = SE_Empty;
02379 }
02380
02381 /* ip */
02382 if (ED->ip_Dest == Loc) {
02383 ED->ip_Dest = SE_Empty;
02384 }
02385
02386 /* fp */
02387 if (ED->fp_Dest == Loc) {
02388 ED->fp_Dest = SE_Empty;
02389 }
02390 /* SUMA_RETURN, tout va bien */
02391 SUMA_RETURN (YUP);
02392 }
|
|
||||||||||||
|
removes an element from the list, frees the data structure associated with the removed element ans = SUMA_ReleaseEngineListElement (list, element)
Definition at line 1960 of file SUMA_ParseCommands.c. References dlist_remove(), SUMA_Boolean, SUMA_ENTRY, SUMA_FreeEngineListData(), SUMA_RETURN, and SUMA_SL_Err. Referenced by SUMA_Engine().
01961 {
01962 static char FuncName[]={"SUMA_ReleaseEngineListElement"};
01963 void *ED=NULL;
01964
01965 SUMA_ENTRY;
01966 if (!element) {
01967 SUMA_SL_Err("Null element");
01968 SUMA_RETURN (NOPE);
01969 }
01970 if (dlist_remove (list, element, &ED) < 0) {
01971 fprintf (SUMA_STDERR, "Error %s: Failed to remove element from list.\n", FuncName);
01972 SUMA_RETURN (NOPE);
01973 }
01974 if (ED) { /* had an if (!ED) here..... */
01975 SUMA_FreeEngineListData((SUMA_EngineData *)ED);
01976 }
01977
01978 SUMA_RETURN (YUP);
01979 }
|
|
||||||||||||
|
removes an element from the list, frees the data structure associated with the removed element ans = SUMA_ReleaseMessageListElement (list, element)
Definition at line 1991 of file SUMA_ParseCommands.c. References dlist_remove(), SUMA_Boolean, SUMA_ENTRY, SUMA_FreeMessageListData(), and SUMA_RETURN. Referenced by SUMA_RegisterMessage().
01992 {
01993 static char FuncName[]={"SUMA_ReleaseMessageListElement"};
01994 void *H=NULL;
01995
01996 SUMA_ENTRY;
01997
01998 if (dlist_remove (list, element, &H) < 0) {
01999 fprintf (SUMA_STDERR, "Error %s: Failed to remove element from list.\n", FuncName);
02000 SUMA_RETURN (NOPE);
02001 }
02002 if (H) {/* had an if (!H) here..... */
02003 SUMA_FreeMessageListData((SUMA_MessageData *)H);
02004 }
02005
02006 SUMA_RETURN (YUP);
02007 }
|
|
||||||||||||
|
Writes the commands to be executed in list SUMA_ShowList (list, Out);.
Definition at line 2402 of file SUMA_ParseCommands.c. References SUMA_EngineData::CommandCode, DListElmt_::data, dlist_head, dlist_is_tail, DList_::size, SUMA_CommandString(), SUMA_ENTRY, and SUMA_RETURNe.
02403 {
02404 static char FuncName[]={"SUMA_ShowList"};
02405 DListElmt *NE;
02406 SUMA_EngineData *ED;
02407
02408 SUMA_ENTRY;
02409
02410 if (!Out) Out = stdout;
02411
02412 if (!list) {
02413 fprintf (Out,"%s: NULL List.\n", FuncName);
02414 SUMA_RETURNe;
02415 }
02416
02417 if (!list->size) {
02418 fprintf (Out,"%s: Empty List.\n", FuncName);
02419 SUMA_RETURNe;
02420 }
02421
02422 fprintf (Out,"%s: List of %d elements.\n\t", FuncName, list->size);
02423 do{
02424 NE = dlist_head(list);
02425 ED = (SUMA_EngineData *) NE->data;
02426 if (!ED) {
02427 fprintf (Out, "NULL-This should not be | ");
02428 } else {
02429 fprintf (Out, "%s | ", SUMA_CommandString (ED->CommandCode));
02430 }
02431 } while (!dlist_is_tail(NE));
02432
02433 fprintf (Out,"\n");
02434
02435 SUMA_RETURNe;
02436 }
|
|
||||||||||||||||||||
|
change a character string of numbers to a vector of values. op must be NULL terminated!
Definition at line 2565 of file SUMA_ParseCommands.c. References LocalHead, strtod(), SUMA_Boolean, SUMA_byte, SUMA_calloc, SUMA_double, SUMA_ENTRY, SUMA_float, SUMA_int, SUMA_notypeset, SUMA_OK_OPENDX_DATA_TYPE, SUMA_RETURN, SUMA_SL_Err, and SUMA_VARTYPE. Referenced by SUMA_OpenDx_Object_Data().
02566 {
02567 static char FuncName[]={"SUMA_strtol_vec"};
02568 void *ans = NULL;
02569 long lv;
02570 double dv;
02571 char *endptr=NULL;
02572 SUMA_Boolean LocalHead = NOPE;
02573
02574 SUMA_ENTRY;
02575 *nread = 0;
02576 if (!SUMA_OK_OPENDX_DATA_TYPE(vtp)) {
02577 SUMA_SL_Err("Bad type");
02578 SUMA_RETURN(ans);
02579 }
02580
02581 ans = NULL;
02582 switch (vtp) {
02583 case SUMA_byte:
02584 {
02585 byte *bvec=NULL;
02586 bvec = (byte *)SUMA_calloc(nvals,sizeof(byte));
02587 lv = strtol(op, &endptr, 10);
02588 while (endptr && endptr != op && *nread < nvals) {
02589 bvec[*nread] = (byte)lv;
02590 /* if (LocalHead) fprintf(SUMA_STDERR,">>>%d<<<\t", bvec[*nread]); */
02591 ++(*nread);
02592 op = endptr;
02593 lv = strtol(op, &endptr, 10);
02594 }
02595 ans = (void *)bvec;
02596 }
02597 break;
02598 case SUMA_int:
02599 {
02600 int *ivec=NULL;
02601 ivec = (int *)SUMA_calloc(nvals,sizeof(int));
02602 lv = strtol(op, &endptr, 10);
02603 while (endptr && endptr != op && *nread < nvals) {
02604 ivec[*nread] = (int)lv;
02605 /* if (LocalHead) fprintf(SUMA_STDERR,">>>%d<<<\t", ivec[*nread]); */
02606 ++(*nread);
02607 op = endptr;
02608 lv = strtol(op, &endptr, 10);
02609 }
02610 ans = (void *)ivec;
02611 }
02612 break;
02613 case SUMA_float:
02614 {
02615 float *fvec=NULL;
02616 fvec = (float *)SUMA_calloc(nvals,sizeof(float));
02617 dv = strtod(op, &endptr);
02618 while (endptr && endptr != op && *nread < nvals) {
02619 fvec[*nread] = (float)dv;
02620 /* if (LocalHead) fprintf(SUMA_STDERR,">>>%f<<<\t", fvec[*nread]); */
02621 ++(*nread);
02622 op = endptr;
02623 dv = strtod(op, &endptr);
02624 }
02625 ans = (void *)fvec;
02626 }
02627 break;
02628 case SUMA_double:
02629 {
02630 double *dvec=NULL;
02631 dvec = (double *)SUMA_calloc(nvals,sizeof(double));
02632 dv = strtod(op, &endptr);
02633 while (endptr && endptr != op && *nread < nvals) {
02634 dvec[*nread] = (double)dv;
02635 /* if (LocalHead) fprintf(SUMA_STDERR,">>>%f<<<\t", dvec[*nread]); */
02636 ++(*nread);
02637 op = endptr;
02638 dv = strtod(op, &endptr);
02639 }
02640 ans = (void *)dvec;
02641 }
02642 break;
02643 case SUMA_notypeset:
02644 SUMA_SL_Err("Type not set");
02645 ans = NULL;
02646 break;
02647 default:
02648 SUMA_SL_Err("Type not supported by this function");
02649 ans = NULL;
02650 break;
02651
02652 }
02653
02654 SUMA_RETURN(ans);
02655 }
|
|
|
Returns the code for a surface's file type.
Definition at line 435 of file SUMA_ParseCommands.c. References SUMA_BRAIN_VOYAGER, SUMA_ENTRY, SUMA_FREE_SURFER, SUMA_FT_ERROR, SUMA_FT_NOT_SPECIFIED, SUMA_INVENTOR_GENERIC, SUMA_OPENDX_MESH, SUMA_PLY, SUMA_RETURN, SUMA_SO_File_Type, SUMA_SUREFIT, and SUMA_VEC. Referenced by SUMA_nimlSO2SO(), and SUMA_Parse_IO_Args().
00436 {
00437 static char FuncName[]={"SUMA_SurfaceTypeCode"};
00438
00439 SUMA_ENTRY;
00440
00441 if (!cd) { SUMA_RETURN(SUMA_FT_ERROR); }
00442
00443 if (!strcmp(cd, "NotSpecified")) { SUMA_RETURN(SUMA_FT_NOT_SPECIFIED ); }
00444 if (!strcmp(cd, "FreeSurfer") || !strcmp(cd, "FS")) { SUMA_RETURN( SUMA_FREE_SURFER); }
00445 if (!strcmp(cd, "SureFit") || !strcmp(cd, "SF")) { SUMA_RETURN( SUMA_SUREFIT); }
00446 if (!strcmp(cd, "GenericInventor") || !strcmp(cd, "INV")) { SUMA_RETURN(SUMA_INVENTOR_GENERIC ); }
00447 if (!strcmp(cd, "Ply") || !strcmp(cd, "PLY")) { SUMA_RETURN( SUMA_PLY); }
00448 if (!strcmp(cd, "DX") || !strcmp(cd, "dx") || !strcmp(cd, "OpenDX") || !strcmp(cd, "opendx")) { SUMA_RETURN( SUMA_OPENDX_MESH); }
00449 if (!strcmp(cd, "BrainVoyager") || !strcmp(cd, "BV") || !strcmp(cd, "bv")) { SUMA_RETURN( SUMA_BRAIN_VOYAGER); }
00450 if (!strcmp(cd, "1D") || !strcmp(cd, "VEC") || !strcmp(cd, "1d")) { SUMA_RETURN(SUMA_VEC ); }
00451 if (!strcmp(cd, "Error")) { SUMA_RETURN(SUMA_FT_ERROR ); }
00452 /* if (!strcmp(cd, "")) { SUMA_RETURN( ); } */
00453 SUMA_RETURN(SUMA_FT_ERROR);
00454
00455 }
|
|
|
Returns the name (string) of a surface type.
Definition at line 394 of file SUMA_ParseCommands.c. References SUMA_BRAIN_VOYAGER, SUMA_ENTRY, SUMA_FREE_SURFER, SUMA_FREE_SURFER_PATCH, SUMA_FT_ERROR, SUMA_FT_NOT_SPECIFIED, SUMA_INVENTOR_GENERIC, SUMA_OPENDX_MESH, SUMA_PLY, SUMA_RETURN, SUMA_SO_File_Type, SUMA_SUREFIT, and SUMA_VEC. Referenced by SUMA_SO2nimlSO().
00395 {
00396 static char FuncName[]={"SUMA_SurfaceTypeString"};
00397
00398 SUMA_ENTRY;
00399 switch (tp) {
00400 case SUMA_FT_NOT_SPECIFIED:
00401 SUMA_RETURN("NotSpecified");
00402 break;
00403 case SUMA_FREE_SURFER:
00404 case SUMA_FREE_SURFER_PATCH:
00405 SUMA_RETURN("FreeSurfer");
00406 break;
00407 case SUMA_SUREFIT:
00408 SUMA_RETURN("SureFit");
00409 break;
00410 case SUMA_INVENTOR_GENERIC:
00411 SUMA_RETURN("GenericInventor");
00412 break;
00413 case SUMA_PLY:
00414 SUMA_RETURN("Ply");
00415 break;
00416 case SUMA_BRAIN_VOYAGER:
00417 SUMA_RETURN("BrainVoyager");
00418 break;
00419 case SUMA_VEC:
00420 SUMA_RETURN("1D");
00421 break;
00422 case SUMA_OPENDX_MESH:
00423 SUMA_RETURN("OpenDX");
00424 break;
00425 case SUMA_FT_ERROR:
00426 SUMA_RETURN("Error");
00427 default:
00428 SUMA_RETURN ("Error");
00429 }
00430 }
|
Variable Documentation
|
|
Global pointer to structure containing info common to all viewers Definition at line 15 of file SUMA_ParseCommands.c. |