Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

SUMA_DOmanip.h File Reference

Go to the source code of this file.


Defines

#define SUMA_IS_DRAW_ROI_SWITCH_ROI_SHADED(Shaded)
 SUMA_IS_DRAW_ROI_SWITCH_ROI_SHADED(Shaded) Shaded is YUP unless the Switch ROI window is currently open.

#define SUMA_IS_SWITCH_COL_PLANE_SHADED(SO, Shaded)
 SUMA_IS_SWITCH_COL_PLANE_SHADED(SO, Shaded) Shaded is YUP unless the Switch Col plane window is currently open.


Functions

float * SUMA_IV_XYZextract (char *IV_filename, int *N_NodeList, int IncludeIndex)
int * SUMA_IV_FaceSetsextract (char *IV_filename, int *N_FaceSetList)
SUMA_SURF_NORM SUMA_SurfNorm (float *NodeList, int N_NodeList, int *FaceSetList, int N_FaceSetList)
SUMA_Boolean SUMA_Free_Displayable_Object (SUMA_DO *dov)
SUMA_DOSUMA_Alloc_DisplayObject_Struct (int N)
SUMA_Boolean SUMA_AddDO (SUMA_DO *dov, int *N_dov, void *op, SUMA_DO_Types DO_Type, SUMA_DO_CoordType DO_CoordType)
SUMA_Boolean SUMA_RemoveDO (SUMA_DO *dov, int *N_dov, void *op, SUMA_Boolean Free_op)
 Remove a displayable object from dov success = SUMA_RemoveDO(dov, N_dov, op, Free_op);.

SUMA_Boolean SUMA_UnRegisterDO (int dov_id, SUMA_SurfaceViewer *cSV)
SUMA_Boolean SUMA_RegisterDO (int dov_id, SUMA_SurfaceViewer *cSV)
void SUMA_Show_DOv (SUMA_DO *dov, int N_dov, FILE *Out)
int * SUMA_GetDO_Type (SUMA_DO *dov, int N_dov, SUMA_DO_Types DO_Type, int *N)
SUMA_Boolean SUMA_Free_Displayable_Object_Vect (SUMA_DO *dov, int N)
SUMA_MEMBER_FACE_SETSSUMA_MemberFaceSets (int Nind, int *FaceSetList, int nFr, int FaceDim, char *ownerid)
SUMA_Boolean SUMA_Free_MemberFaceSets (SUMA_MEMBER_FACE_SETS *MF)
SUMA_VOLPARSUMA_VolPar_Attr (char *volparent_name)
SUMA_VOLPARSUMA_VolParFromDset (THD_3dim_dataset *dset)
SUMA_Boolean SUMA_Free_VolPar (SUMA_VOLPAR *VP)
SUMA_VOLPARSUMA_Alloc_VolPar (void)
int SUMA_THD_handedness (THD_3dim_dataset *dset)
SUMA_Boolean SUMA_AfniExists (char *prefix, char *c2view)
SUMA_Boolean SUMA_AfniView (char *nameorig, char *cview)
SUMA_Boolean SUMA_AfniExistsView (int exists, char *view)
char * SUMA_AfniPrefix (char *name, char *view, char *path, int *exists)
 Return AFNI's prefix, from a file name also checks for its validity.

byteSUMA_isSkin (THD_3dim_dataset *dset, double *dvec, double thresh, int *N_skin)
 A function to find the skin of a volume.

void SUMA_Show_VolPar (SUMA_VOLPAR *VP, FILE *Out)
char * SUMA_VolPar_Info (SUMA_VOLPAR *VP)
 Form a string containing the info of the volume parent.

SUMA_Boolean SUMA_Align_to_VolPar (SUMA_SurfaceObject *SO, void *S_struct)
 Transform the coordinates of a surface object to AFNI-DICOM convention and transform the coordinates by SO->VolPar ans = SUMA_Align_to_VolPar (SO, SF_Struct);.

SUMA_Boolean SUMA_Apply_VolReg_Trans (SUMA_SurfaceObject *SO)
 applies the transform in SO->VolPar to SO->NodeList. This only makes sense if SO->NodeList is in DICOM to begin with...

SUMA_Boolean SUMA_Read_SureFit_Param (char *f_name, SUMA_SureFit_struct *SF)
int SUMA_ReleaseLink (SUMA_INODE *IN)
int SUMA_AddLink (SUMA_INODE *IN)
SUMA_INODESUMA_CreateInode (void *data, char *ID)
SUMA_INODESUMA_CreateInodeLink (SUMA_INODE *FromIN, SUMA_INODE *ToIN)
SUMA_Boolean SUMA_isInodeLink (SUMA_INODE *IN, const char *HolderIDcode)
SUMA_INODESUMA_BreakInodeLink (SUMA_INODE *IN, const char *HolderIDcode)
SUMA_Boolean SUMA_existSO (char *idcode, SUMA_DO *dov, int N_dov)
SUMA_Boolean SUMA_existDO (char *idcode, SUMA_DO *dov, int N_dov)
int SUMA_whichDO (char *idcode, SUMA_DO *dov, int N_dov)
int SUMA_findSO_inDOv (char *idcode, SUMA_DO *dov, int N_dov)
SUMA_SurfaceObjectSUMA_findSOp_inDOv (char *idcode, SUMA_DO *dov, int N_dov)
SUMA_SurfaceObjectSUMA_find_named_SOp_inDOv (char *coordname, SUMA_DO *dov, int N_dov)
SUMA_Boolean SUMA_ismappable (SUMA_SurfaceObject *SO)
SUMA_Boolean SUMA_isINHmappable (SUMA_SurfaceObject *SO)
SUMA_Boolean SUMA_isLocalDomainParent (SUMA_SurfaceObject *SO)
SUMA_Boolean SUMA_isSO (SUMA_DO DO)
 SUMA_Boolean SUMA_isSO (SUMA_DO DO) returns YUP if DO is of SO_type ans = SUMA_isSO (DO) ;.

SUMA_Boolean SUMA_isSO_G (SUMA_DO DO, char *Group)
 SUMA_Boolean SUMA_isSO_G (SUMA_DO DO, char *Group) returns YUP if DO is a surface object and is a part of the group Group.

SUMA_DOMAIN_KINSHIPS SUMA_WhatAreYouToMe (SUMA_SurfaceObject *SO1, SUMA_SurfaceObject *SO2)
 ans = SUMA_WhatAreYouToMe (SUMA_SurfaceObject *SO1, SUMA_SurfaceObject *SO2); returns a code for the kinship between two surfaces:

SUMA_Boolean SUMA_isRelated (SUMA_SurfaceObject *SO1, SUMA_SurfaceObject *SO2, int level)
 ans = SUMA_isRelated (SUMA_SurfaceObject *SO1, SUMA_SurfaceObject *SO2, int level);

SUMA_Boolean SUMA_isdROIrelated (SUMA_DRAWN_ROI *ROI, SUMA_SurfaceObject *SO)
 Returns YUP if the surface: dROI->Parent_idcode_str is related to SO->idcode_str or SO->LocalDomainParentID. NOPE otherwise.

SUMA_Boolean SUMA_isROIrelated (SUMA_ROI *ROI, SUMA_SurfaceObject *SO)
 Returns YUP if if the surface: ROI->Parent_idcode_str is related to SO->idcode_str or SO->LocalDomainParentID. NOPE otherwise.

SUMA_DRAWN_ROISUMA_FetchROI_InCreation (SUMA_SurfaceObject *SO, SUMA_DO *dov, int N_dov)
 Returns an ROI that is related to SO and is in InCreation (being actively drawn) DrawStatus There should only be one ROI in creation at any one time for a group of related surfaces.

SUMA_Boolean SUMA_AFNI_forward_warp_xyz (THD_warp *warp, float *XYZv, int N)
 transforms XYZ coordinates by transfrom in warp. ans = SUMA_AFNI_forward_warp_xyz( warp , XYZv, N);

SUMA_Boolean SUMA_AFNItlrc_toMNI (float *NodeList, int N_Node, char *Coord)
 transforms XYZ coordinates from AFNI'S RAI talairach space to MNI space in in RAI or (LPI) http://www.mrc-cbu.cam.ac.uk/Imaging/mnispace.html. see Bob's THD_tta_to_mni in thd_mnicoords.c

int SUMA_Build_Mask_DrawnROI (SUMA_DRAWN_ROI *D_ROI, int *Mask)
 Return a mask of the nodes belonging to a drawn ROI of a certain surface N_added = SUMA_Build_Mask_DrawnROI (dROI, Mask);.

int * SUMA_Build_Mask_AllROI (SUMA_DO *dov, int N_dov, SUMA_SurfaceObject *SO, int *Mask, int *N_added)
 Return a mask of the nodes belonging to any ROI of a certain surface Mask = SUMA_Build_Mask_AllROI (dov, N_dov, SO, Mask, N_added);.

SUMA_ASSEMBLE_LIST_STRUCTSUMA_AssembleAllROIList (SUMA_DO *dov, int N_dov, SUMA_Boolean SortByLabel)
 Returns a list of the ROIs loaded into dov.

SUMA_ASSEMBLE_LIST_STRUCTSUMA_FreeAssembleListStruct (SUMA_ASSEMBLE_LIST_STRUCT *str)
 frees SUMA_ASSEMBLE_LIST_STRUCT *

SUMA_ASSEMBLE_LIST_STRUCTSUMA_CreateAssembleListStruct (void)
 Creates an SUMA_ASSEMBLE_LIST_STRUCT *structure.

SUMA_Boolean SUMA_DeleteROI (SUMA_DRAWN_ROI *ROI)
 deletes an ROI from the list of drawn objects

int SUMA_isTypicalSOforVolSurf (SUMA_SurfaceObject *SO)
 return +1 if surface is typically the outer layer surface used in Vol2Surf -1 if surface is typically the inner layer surface used in Vol2Surf 0 if no comment


Define Documentation

#define SUMA_IS_DRAW_ROI_SWITCH_ROI_SHADED Shaded   
 

Value:

{  \
   Shaded = YUP;  \
   if (SUMAg_CF->X) {   \
      if (SUMAg_CF->X->DrawROI) {\
         if (SUMAg_CF->X->DrawROI->SwitchROIlst) {\
            if (!SUMAg_CF->X->DrawROI->SwitchROIlst->isShaded) {\
               Shaded = NOPE;  \
            }  \
         }  \
      }  \
   }  \
}
SUMA_IS_DRAW_ROI_SWITCH_ROI_SHADED(Shaded) Shaded is YUP unless the Switch ROI window is currently open.

Definition at line 69 of file SUMA_DOmanip.h.

Referenced by SUMA_cb_CloseDrawROIWindow(), SUMA_DeleteROI(), SUMA_DrawROI_NewLabel(), and SUMA_ProcessBrushStroke().

#define SUMA_IS_SWITCH_COL_PLANE_SHADED SO,
Shaded   
 

Value:

{  \
   Shaded = YUP;  \
   if (SO) {   \
      if (SO->SurfCont) {\
         if (SO->SurfCont->SwitchDsetlst) {\
            if (!SO->SurfCont->SwitchDsetlst->isShaded) {\
               Shaded = NOPE;  \
            }  \
         }  \
      }  \
   }  \
}
SUMA_IS_SWITCH_COL_PLANE_SHADED(SO, Shaded) Shaded is YUP unless the Switch Col plane window is currently open.

Definition at line 87 of file SUMA_DOmanip.h.

Referenced by SUMA_ColPlane_NewOrder().


Function Documentation

SUMA_Boolean SUMA_AddDO SUMA_DO   dov,
int *    N_dov,
void *    op,
SUMA_DO_Types    DO_Type,
SUMA_DO_CoordType    DO_CoordType
 

Add a displayable object to dov

Definition at line 289 of file SUMA_DOmanip.c.

References SUMA_DO::CoordType, SUMA_DO::ObjectType, SUMA_DO::OP, SUMA_Boolean, SUMA_DO_CoordType, SUMA_DO_Types, SUMA_ENTRY, SUMA_error_message(), SUMA_MAX_DISPLAYABLE_OBJECTS, and SUMA_RETURN.

Referenced by main(), SUMA_LoadSegDO(), SUMA_LoadSpec_eng(), SUMA_OpenDrawnROI(), SUMA_PrepAddmappableSO(), SUMA_process_NIML_data(), SUMA_ProcessBrushStroke(), and SUMA_Surf_Plane_Intersect_ROI().

00290 {
00291    static char FuncName[] = {"SUMA_AddDO"};
00292    
00293    SUMA_ENTRY;
00294 
00295    /* make sure you did not exceed allocated space */
00296    if (*N_dov >= SUMA_MAX_DISPLAYABLE_OBJECTS) {
00297       SUMA_error_message (FuncName, "Reached limit of DOv storage",0);
00298       SUMA_RETURN(NOPE);
00299    }
00300    dov[*N_dov].OP = op;
00301    dov[*N_dov].ObjectType = DO_Type;
00302    dov[*N_dov].CoordType = DO_CoordType;
00303    *N_dov = *N_dov+1;
00304    
00305    
00306    SUMA_RETURN(YUP);
00307 }

int SUMA_AddLink SUMA_INODE   IN
 

This function increments the N_link field in IN by 1 and returns the resultant N_link value a zero is returned in case of an error

ans = SUMA_AddLink (IN);

Parameters:
IN  (SUMA_INODE *) pointer to SUMA_INODE structure \ret ans (int) value of IN->N_link
See also:
SUMA_ReleaseLink

Definition at line 164 of file SUMA_DOmanip.c.

References SUMA_INODE::N_link, SUMA_ENTRY, and SUMA_RETURN.

Referenced by SUMA_CreateInodeLink().

00165 {
00166    static char FuncName[]={"SUMA_AddLink"};
00167 
00168    SUMA_ENTRY;
00169 
00170    if (!IN) {
00171       fprintf (SUMA_STDERR,"Error %s: Inode is null.\n", FuncName);
00172       
00173       SUMA_RETURN(0);
00174    } else {
00175       IN->N_link++;
00176       SUMA_RETURN(IN->N_link);
00177    }
00178 }

SUMA_Boolean SUMA_AFNI_forward_warp_xyz THD_warp   warp,
float *    xyzv,
int    N
 

transforms XYZ coordinates by transfrom in warp. ans = SUMA_AFNI_forward_warp_xyz( warp , XYZv, N);

Parameters:
warp  (THD_warp *) afni warp structure
XYZv  (float *) pointer to coordinates vector.
N  (int) number of XYZ triplets in XYZv. The ith X,Y, Z coordinates would be XYZv[3i], XYZv[3i+1],XYZv[3i+2]
Returns:
ans (YUP/NOPE) NOPE: NULL warp or bad warp->type

Definition at line 1854 of file SUMA_VolData.c.

References THD_linear_mapping::bot, THD_linear_mapping::bvec, i, MATVEC_SUB, THD_linear_mapping::mfor, THD_warp::rig_bod, SUMA_Boolean, SUMA_ENTRY, SUMA_RETURN, THD_warp::tal_12, THD_linear_mapping::top, THD_warp::type, THD_talairach_12_warp::warp, THD_affine_warp::warp, WARP_AFFINE_TYPE, WARP_TALAIRACH_12_TYPE, and THD_fvec3::xyz.

01855 {
01856    static char FuncName[]={"SUMA_AFNI_forward_warp_xyz"};
01857    THD_fvec3 new_fv, old_fv;
01858    int i, i3;
01859    
01860    SUMA_ENTRY;
01861    
01862    if( warp == NULL ) {
01863       fprintf (SUMA_STDERR, "Error %s: NULL warp.\n", FuncName);
01864       SUMA_RETURN (NOPE) ;
01865    }
01866 
01867    switch( warp->type ){
01868 
01869       default: 
01870          fprintf (SUMA_STDERR, "Error %s: bad warp->type\n", FuncName);
01871          SUMA_RETURN (NOPE); 
01872          break ;
01873 
01874       case WARP_TALAIRACH_12_TYPE:{
01875          THD_linear_mapping map ;
01876          int iw ;
01877 
01878          /* forward transform each possible case,
01879             and test if result is in bot..top of defined map */
01880 
01881          for (i=0; i < N; ++i) {
01882             i3 = 3*i;
01883             old_fv.xyz[0] = xyzv[i3];
01884             old_fv.xyz[1] = xyzv[i3+1];
01885             old_fv.xyz[2] = xyzv[i3+2];
01886             
01887             for( iw=0 ; iw < 12 ; iw++ ){
01888                map    = warp->tal_12.warp[iw] ;
01889                new_fv = MATVEC_SUB(map.mfor,old_fv,map.bvec) ;
01890 
01891                if( new_fv.xyz[0] >= map.bot.xyz[0] &&
01892                    new_fv.xyz[1] >= map.bot.xyz[1] &&
01893                    new_fv.xyz[2] >= map.bot.xyz[2] &&
01894                    new_fv.xyz[0] <= map.top.xyz[0] &&
01895                    new_fv.xyz[1] <= map.top.xyz[1] &&
01896                    new_fv.xyz[2] <= map.top.xyz[2]   ) break ;  /* leave loop */
01897             }
01898             xyzv[i3] = new_fv.xyz[0];
01899             xyzv[i3+1] = new_fv.xyz[1];
01900             xyzv[i3+2] = new_fv.xyz[2];
01901             
01902          }
01903       }
01904       break ;
01905 
01906       case WARP_AFFINE_TYPE:{
01907          THD_linear_mapping map = warp->rig_bod.warp ;
01908          for (i=0; i < N; ++i) {
01909             i3 = 3*i;
01910             old_fv.xyz[0] = xyzv[i3];
01911             old_fv.xyz[1] = xyzv[i3+1];
01912             old_fv.xyz[2] = xyzv[i3+2];
01913             new_fv = MATVEC_SUB(map.mfor,old_fv,map.bvec) ;
01914             xyzv[i3] = new_fv.xyz[0];
01915             xyzv[i3+1] = new_fv.xyz[1];
01916             xyzv[i3+2] = new_fv.xyz[2];
01917          }
01918       }
01919       break ;
01920 
01921    }
01922    SUMA_RETURN(YUP);
01923 }

SUMA_Boolean SUMA_AfniExists char *    prefix,
char *    c2view
 

Definition at line 111 of file SUMA_VolData.c.

References LocalHead, SUMA_append_replace_string(), SUMA_Boolean, SUMA_filexists(), SUMA_free, and SUMA_RETURN.

00112 {
00113    static char FuncName[]={"SUMA_AfniExists"};
00114    char *head=NULL;
00115    SUMA_Boolean ans = NOPE;
00116    SUMA_Boolean LocalHead = NOPE;
00117    
00118    ans = NOPE;
00119 
00120    head = SUMA_append_replace_string(prefix,".HEAD", c2view,0);
00121    if (LocalHead) fprintf(SUMA_STDERR,"%s: Checking existence of %s\n", FuncName, head);
00122    if (SUMA_filexists(head)) { ans = YUP; }
00123    SUMA_free(head); head = NULL; 
00124    
00125    SUMA_RETURN(ans);
00126 }

SUMA_Boolean SUMA_AfniExistsView int    exists,
char *    view
 

see help for SUMA_AfniPrefix below

Definition at line 59 of file SUMA_VolData.c.

References SUMA_Boolean, and SUMA_RETURN.

Referenced by main(), SUMA_3dSurfMask_ParseInput(), and SUMA_AfniPrefix().

00060 {
00061    static char FuncName[]={"SUMA_AfniExistsView"};
00062    SUMA_Boolean ans = NOPE;
00063    
00064    if (!exists) SUMA_RETURN(ans);
00065    
00066    if (strcmp(view,"+orig") == 0) {
00067       if (exists == 1 || exists == 3 || exists == 5 || exists == 7) ans = YUP; 
00068    } else if (strcmp(view,"+acpc") == 0) {
00069       if (exists == 2 || exists == 3 || exists == 6 || exists == 7) ans = YUP; 
00070    } else if (strcmp(view,"+tlrc") == 0) {
00071       if (exists == 4 || exists == 5 || exists == 6 || exists == 7) ans = YUP; 
00072    } 
00073    
00074    SUMA_RETURN(ans);
00075 
00076 }

char* SUMA_AfniPrefix char *    nameorig,
char *    view,
char *    path,
int *    exists
 

Return AFNI's prefix, from a file name also checks for its validity.

Parameters:
name  (char *) dset name (can contain path)
view  (char[4]) array to return view in it
path  (char *) if any, make sure it is not duplicated in name!
exists  (int *) function checks for all three possible views 0: No afni dset with name/prefix 1: +orig 2: +acpc 3: +orig and +acpc 4: +tlrc 5: +orig and +tlrc 6: +acpc and +tlrc 7: +orig and +acpc and +tlrc
See also:
SUMA_AfniExistsView
Returns:
prefix (char *) dset prefix, free it with SUMA_free
See also:
SUMA_AfniView

Definition at line 147 of file SUMA_VolData.c.

References LocalHead, name, SUMA_AfniExistsView(), SUMA_append_replace_string(), SUMA_append_string(), SUMA_Boolean, SUMA_copy_string(), SUMA_ENTRY, SUMA_Extension(), SUMA_filexists(), SUMA_free, SUMA_isExtension(), SUMA_RETURN, SUMA_SL_Err, and THD_filename_ok().

Referenced by main(), SUMA_3dSurfMask_ParseInput(), SUMA_BrainVoyager_Read_vmr(), and SUMA_OpenDX_Read_CruiseVolHead().

00148 {
00149    static char FuncName[]={"SUMA_AfniPrefix"};
00150    char *tmp1 = NULL, *tmp2 = NULL, *prfx = NULL, *name=NULL;
00151    char cview[10];
00152    int iview;
00153    SUMA_Boolean LocalHead = NOPE;
00154    
00155    SUMA_ENTRY;
00156    
00157    if (!nameorig) SUMA_RETURN(prfx);
00158    if (exists) *exists = 0;
00159    
00160    if (LocalHead) fprintf(SUMA_STDERR,"%s: Working with %s\n", FuncName, nameorig);
00161    
00162    if (!path) name = SUMA_copy_string(nameorig);
00163    else {
00164       if (path[strlen(path)-1] == '/') {
00165          name = SUMA_append_replace_string(path, nameorig, "", 0);
00166       } else {
00167          name = SUMA_append_replace_string(path, nameorig, "/", 0);
00168       }
00169    }
00170    
00171    if (LocalHead) fprintf(SUMA_STDERR,"%s: name now %s\n", FuncName, name);
00172    
00173    tmp1 = SUMA_Extension(name, ".HEAD", YUP);
00174    tmp2 = SUMA_Extension(tmp1, ".BRIK", YUP); SUMA_free(tmp1); tmp1 = NULL;
00175    /* is there a dot ?*/
00176    if (tmp2[strlen(tmp2)-1] == '.') tmp2[strlen(tmp2)-1] = '\0';
00177    
00178    if (LocalHead) fprintf(SUMA_STDERR,"%s: Searching for view of %s\n", FuncName, tmp2);
00179    
00180    /* view */
00181    iview = -1;
00182    if (SUMA_isExtension(tmp2, "+orig")) { 
00183       iview = 0; sprintf(cview, "+orig"); 
00184       prfx = SUMA_Extension(tmp2, "+orig", YUP);
00185    } else if (SUMA_isExtension(tmp2, "+acpc")) { 
00186       iview = 1; sprintf(cview, "+acpc"); 
00187       prfx = SUMA_Extension(tmp2, "+acpc", YUP);
00188    } else if (SUMA_isExtension(tmp2, "+tlrc")) { 
00189       iview = 2; sprintf(cview, "+tlrc"); 
00190       prfx = SUMA_Extension(tmp2, "+tlrc", YUP);
00191    } else {
00192       prfx = SUMA_copy_string(tmp2);
00193       cview[0]='\0';
00194    }
00195    SUMA_free(tmp2); tmp2 = NULL;
00196    
00197    if (LocalHead) fprintf(SUMA_STDERR,"%s: Prefix %s\n", FuncName, prfx);
00198    
00199    /* can't tell what view is, so can't test properly quite yet */
00200    {   
00201       /* is name ok ? all I have to do is test with +orig */
00202       char *bname=SUMA_append_string(prfx,"+orig");
00203       if (LocalHead) fprintf(SUMA_STDERR,"%s: Checking name validity using +orig for view %s\n", FuncName, bname);
00204       if( !THD_filename_ok(bname) ){
00205          SUMA_SL_Err("not a proper dset name!\n") ;
00206          SUMA_free(name); name = NULL;
00207          SUMA_free(prfx); prfx = NULL;
00208          SUMA_free(bname); bname = NULL;
00209          SUMA_RETURN(prfx);
00210       }
00211    }
00212    
00213    if (exists) {
00214       { /* look for any */
00215          char *head=NULL, c2view[10];
00216          iview = 0; *exists = 0;
00217          while (iview < 3) {
00218             if (iview == 0) sprintf(c2view, "+orig"); 
00219             else if (iview == 1) sprintf(c2view, "+acpc"); 
00220             else if (iview == 2) sprintf(c2view, "+tlrc");
00221             head = SUMA_append_replace_string(prfx,".HEAD", c2view,0);
00222             if (LocalHead) fprintf(SUMA_STDERR,"%s: Checking existence of %s\n", FuncName, head);
00223             if (SUMA_filexists(head)) { *exists += (int)pow(2,iview); }
00224             SUMA_free(head); head = NULL; 
00225             ++iview;
00226          }
00227       }
00228       if (LocalHead) fprintf(SUMA_STDERR,"%s: exist number is %d\n", FuncName, *exists);
00229    }
00230    
00231    
00232    if (cview[0] != '\0') {
00233       if (LocalHead) {
00234          if (SUMA_AfniExistsView(*exists, cview)) {
00235             fprintf(SUMA_STDERR,"%s: dset with view %s does exist.\n", FuncName, cview); 
00236          } else {
00237             fprintf(SUMA_STDERR,"%s: dset with view %s does not exist.\n", FuncName, cview); 
00238          }
00239       }
00240    }
00241    
00242    if (view) {
00243       sprintf(view,"%s", cview);
00244    }
00245    if (name) SUMA_free(name); name = NULL;
00246    
00247    SUMA_RETURN(prfx);
00248 }

SUMA_Boolean SUMA_AFNItlrc_toMNI float *    NodeList,
int    N_Node,
char *    Coord
 

transforms XYZ coordinates from AFNI'S RAI talairach space to MNI space in in RAI or (LPI) http://www.mrc-cbu.cam.ac.uk/Imaging/mnispace.html. see Bob's THD_tta_to_mni in thd_mnicoords.c

Parameters:
NodeList  (float *) vector of coordinates, 3 * N_Node long
N_Node  (int) number of nodes in vector above
Coord  (char *) one of two options "RAI" meaning the MNI coordinates are to be in RAI "LPI" meaning the MNI coordinates are to be in LPI
Returns:
flag (SUMA_Boolean) NOPE = failed

  • This function should be rewritten to call THD_tta_to_mni (although you'll have to deal with the flipping option

Definition at line 1802 of file SUMA_VolData.c.

References i, LocalHead, SUMA_Boolean, SUMA_LH, SUMA_RETURN, and SUMA_S_Err.

01803 {
01804    static char FuncName[]={"SUMA_AFNItlrc_toMNI"};
01805    SUMA_Boolean DoFlip = NOPE;
01806    int i, i3;
01807    float mx = 0.0,my = 0.0,mz  = 0.0, tx = 0.0,ty = 0.0,tz = 0.0 ;
01808    SUMA_Boolean LocalHead = NOPE;
01809    
01810    if (strcmp(Coord,"RAI") == 0) DoFlip = NOPE;
01811    else if (strcmp(Coord,"LPI") == 0) DoFlip = YUP;
01812    else {
01813       SUMA_S_Err("Can't do. Either RAI or LPI");
01814       SUMA_RETURN(NOPE);
01815    }   
01816 
01817    
01818    for (i=0; i< N_Node; ++i) {
01819       i3 = 3*i;
01820       if (DoFlip) {
01821          if (!i) SUMA_LH("Flipping to LPI");
01822          tx = - NodeList[i3]; ty = -NodeList[i3+1] ;  /* flip xy from RAI to LPI */
01823          tz = NodeList[i3+2] ;
01824       } else {
01825          if (!i) SUMA_LH("No Flipping, RAI maintained");
01826          tx =  NodeList[i3]; ty = NodeList[i3+1] ;  /* flip xy from RAI to LPI */
01827          tz =  NodeList[i3+2] ;
01828       }
01829       mx = 1.01010 * tx ;
01830       my = 1.02962 * ty - 0.05154 * tz ;
01831       mz = 0.05434 * ty + 1.08554 * tz ;
01832       if( mz < 0.0 ) mz *= 1.09523 ;
01833       NodeList[i3] = mx;
01834       NodeList[i3+1] = my;
01835       NodeList[i3+2] = mz;
01836    }
01837    
01838    
01839    SUMA_RETURN(YUP);
01840 }

SUMA_Boolean SUMA_AfniView char *    nameorig,
char *    cview
 

Definition at line 78 of file SUMA_VolData.c.

References LocalHead, SUMA_Boolean, SUMA_ENTRY, SUMA_Extension(), SUMA_free, SUMA_isExtension(), and SUMA_RETURN.

Referenced by main().

00079 {
00080    static char FuncName[]={"SUMA_AfniView"};
00081    char *tmp1 = NULL, *tmp2 = NULL;
00082    SUMA_Boolean LocalHead = NOPE;
00083    
00084    SUMA_ENTRY;
00085    
00086    if (!nameorig) SUMA_RETURN(NOPE);
00087    if (!cview) SUMA_RETURN(NOPE);
00088 
00089    tmp1 = SUMA_Extension(nameorig, ".HEAD", YUP);
00090    tmp2 = SUMA_Extension(tmp1, ".BRIK", YUP); SUMA_free(tmp1); tmp1 = NULL;
00091    /* is there a dot ?*/
00092    if (tmp2[strlen(tmp2)-1] == '.') tmp2[strlen(tmp2)-1] = '\0';
00093    
00094    if (LocalHead) fprintf(SUMA_STDERR,"%s: Searching for view of %s\n", FuncName, tmp2);
00095    
00096    /* view */
00097    if (SUMA_isExtension(tmp2, "+orig")) { 
00098       sprintf(cview, "+orig"); 
00099    } else if (SUMA_isExtension(tmp2, "+acpc")) { 
00100       sprintf(cview, "+acpc"); 
00101    } else if (SUMA_isExtension(tmp2, "+tlrc")) { 
00102       sprintf(cview, "+tlrc"); 
00103    } else {
00104       cview[0]='\0';
00105    }
00106    SUMA_free(tmp2); tmp2 = NULL;
00107 
00108    SUMA_RETURN(YUP);
00109 }

SUMA_Boolean SUMA_Align_to_VolPar SUMA_SurfaceObject   SO,
void *    S_Struct
 

Transform the coordinates of a surface object to AFNI-DICOM convention and transform the coordinates by SO->VolPar ans = SUMA_Align_to_VolPar (SO, SF_Struct);.

Parameters:
SO  (SUMA_SurfaceObject *)
S_Struct  (void *) That is only needed for SureFit surfaces and is nothing but a type cast of a SUMA_SureFit_struct containing information on cropping. send NULL for all other surfaces.
Returns:
YUP/NOPE For SureFit and FreeSurfer surfaces, the coordinates are first set in RAI (DICOM) coordinate system before applying SO->VolPar. For other surface formats, SO->VolPar is applied to whatever coordinates are in SO->NodeList

Definition at line 794 of file SUMA_VolData.c.

References SUMA_SureFit_struct::AC, SUMA_SureFit_struct::AC_WholeVolume, SUMA_SurfaceObject::FileType, i, SUMA_SurfaceObject::N_Node, SUMA_SurfaceObject::NodeDim, SUMA_SurfaceObject::NodeList, SUMA_Apply_VolReg_Trans(), SUMA_Boolean, SUMA_BRAIN_VOYAGER, SUMA_ENTRY, SUMA_FREE_SURFER, SUMA_FREE_SURFER_PATCH, SUMA_INVENTOR_GENERIC, SUMA_malloc, SUMA_OPENDX_MESH, SUMA_PLY, SUMA_RETURN, SUMA_SUREFIT, SUMA_THD_3dfind_to_3dmm(), SUMA_THD_3dmm_to_dicomm(), SUMA_VEC, THD_coorder_fill(), THD_coorder_to_dicom(), SUMA_SurfaceObject::VolPar, SUMA_VOLPAR::xxorient, THD_fvec3::xyz, SUMA_VOLPAR::yyorient, and SUMA_VOLPAR::zzorient.

Referenced by SUMA_Load_Surface_Object_eng().

00795 {
00796    static char FuncName[]={"SUMA_Align_to_VolPar"};
00797    char  orcode[3];
00798    float xx, yy, zz;
00799    THD_coorder * cord_surf, *cord_RAI;
00800    int i, ND, id;
00801    SUMA_SureFit_struct *SF;
00802    SUMA_FreeSurfer_struct *FS;
00803    
00804    SUMA_ENTRY;
00805 
00806    /* allocate for cord structure */
00807    cord_surf = (THD_coorder *)SUMA_malloc(sizeof(THD_coorder));
00808    cord_RAI = (THD_coorder *)SUMA_malloc(sizeof(THD_coorder));
00809    if (cord_surf == NULL || cord_RAI == NULL) {
00810       fprintf(SUMA_STDERR,"Error %s: failed to allocate for cord\n", FuncName);
00811       SUMA_RETURN (NOPE);
00812    }
00813    
00814    /* do the dance to get cord for RAI */
00815    THD_coorder_fill( NULL, cord_RAI);
00816    ND = SO->NodeDim;
00817    switch (SO->FileType) {
00818       case SUMA_INVENTOR_GENERIC:
00819       case SUMA_OPENDX_MESH:
00820       case SUMA_PLY:
00821       case SUMA_VEC:
00822          /* Do nothing */
00823          break;
00824       case SUMA_FREE_SURFER:
00825       case SUMA_FREE_SURFER_PATCH:
00826          /* For free surfer, all you need to do is 
00827           go from LPI to RAI (DICOM)*/
00828          sprintf(orcode,"LPI");
00829          THD_coorder_fill(orcode , cord_surf); 
00830          /*loop over XYZs and change them to dicom*/
00831          for (i=0; i < SO->N_Node; ++i) {
00832             id = i * ND;
00833             THD_coorder_to_dicom (cord_surf, &(SO->NodeList[id]), &(SO->NodeList[id+1]), &(SO->NodeList[id+2])); 
00834          }
00835          break;
00836       case SUMA_SUREFIT:
00837          /* For SureFit, coordinates are actually a float version of the indices */
00838          SF = (SUMA_SureFit_struct *)S_Struct;
00839          {   THD_fvec3 fv, iv;
00840             float D[3];
00841             /* Calcluate Delta caused by cropping */
00842             for (i=0; i < 3; ++i) D[i] = SF->AC_WholeVolume[i] - SF->AC[i];
00843             /* fprintf (SUMA_STDERR,"%s: Shift Values: [%f, %f, %f]\n", FuncName, D[0], D[1], D[2]); */
00844             for (i=0; i < SO->N_Node; ++i) {
00845                id = i * ND;
00846                /* change float indices to mm coords */
00847                iv.xyz[0] = SO->NodeList[id] + D[0];
00848                iv.xyz[1] = SO->NodeList[id+1] + D[1];
00849                iv.xyz[2] = SO->NodeList[id+2] + D[2];
00850                fv = SUMA_THD_3dfind_to_3dmm( SO, iv );
00851                
00852                /* change mm to RAI coords */
00853                iv = SUMA_THD_3dmm_to_dicomm( SO->VolPar->xxorient, SO->VolPar->yyorient, SO->VolPar->zzorient,  fv );
00854                SO->NodeList[id] = iv.xyz[0];
00855                SO->NodeList[id+1] = iv.xyz[1];
00856                SO->NodeList[id+2] = iv.xyz[2];
00857             }
00858          }
00859          break;
00860       case SUMA_BRAIN_VOYAGER:
00861          /* For Brain Voyager, all you need to do is 
00862           go from AIR to RAI (DICOM)
00863           Note: The center of the volume is at the 1st voxel's center and that huge
00864           center shift, relative to standard AFNI dsets (centered about middle of volume)
00865           might throw off 3dVolreg. If you want to shift volume's center to be in
00866           the middle voxel, you'll need to shift the surface coordinates before transforming
00867           them to ASR*/
00868          sprintf(orcode,"ASR");
00869          THD_coorder_fill(orcode , cord_surf); 
00870          /*loop over XYZs and change them to dicom*/
00871          for (i=0; i < SO->N_Node; ++i) {
00872             id = i * ND;
00873             THD_coorder_to_dicom (cord_surf, &(SO->NodeList[id]), &(SO->NodeList[id+1]), &(SO->NodeList[id+2])); 
00874          }
00875          break;
00876       default:
00877          fprintf(SUMA_STDERR,"Warning %s: Unknown SO->FileType. Assuming coordinates are in DICOM already.\n", FuncName);
00878          break;
00879    }
00880    
00881    if (!SUMA_Apply_VolReg_Trans (SO)) {
00882       fprintf(SUMA_STDERR,"Error %s: Failed in SUMA_Apply_VolReg_Trans.\n", FuncName);
00883       SUMA_RETURN (NOPE);
00884    }
00885 
00886    SUMA_RETURN (YUP);
00887 }

SUMA_DO* SUMA_Alloc_DisplayObject_Struct int    N
 

Create a Displayable Object data structure

Definition at line 213 of file SUMA_DOmanip.c.

References SUMA_alloc_problem(), SUMA_ENTRY, SUMA_malloc, and SUMA_RETURN.

Referenced by fill_SUMA_structs(), main(), read_surf_files(), and spec2SUMA().

00214 {
00215    static char FuncName[]={"SUMA_Alloc_DisplayObject_Struct"};
00216    SUMA_DO *dov;
00217    
00218    SUMA_ENTRY;
00219 
00220    dov = (SUMA_DO *)SUMA_malloc(sizeof(SUMA_DO)*N);
00221    if (dov == NULL) {
00222       SUMA_alloc_problem("SUMA_Alloc_DisplayObject_Struct: could not allocate memory for SO");
00223    }
00224    SUMA_RETURN(dov);
00225 }/*SUMA_Alloc_DisplayObject_Struct*/

SUMA_VOLPAR* SUMA_Alloc_VolPar void   
 

Returns the attributes of the surface's volume parent A volume parent is defined as: The volume data set used to generate the surface. aka the master SPGR \ret NULL for troubles

Definition at line 342 of file SUMA_VolData.c.

References SUMA_VOLPAR::dirname, SUMA_VOLPAR::dx, SUMA_VOLPAR::dy, SUMA_VOLPAR::dz, SUMA_VOLPAR::filecode, SUMA_VOLPAR::Hand, SUMA_VOLPAR::idcode_str, SUMA_VOLPAR::isanat, SUMA_VOLPAR::nx, SUMA_VOLPAR::ny, SUMA_VOLPAR::nz, SUMA_VOLPAR::prefix, SUMA_VOLPAR::ROTATE_CENTER_BASE, SUMA_VOLPAR::ROTATE_CENTER_OLD, SUMA_VOLPAR::ROTATE_MATVEC, SUMA_ENTRY, SUMA_malloc, SUMA_RETURN, SUMA_VOLPAR::TAGALIGN_MATVEC, SUMA_VOLPAR::vol_idcode_date, SUMA_VOLPAR::vol_idcode_str, SUMA_VOLPAR::VOLREG_CENTER_BASE, SUMA_VOLPAR::VOLREG_CENTER_OLD, SUMA_VOLPAR::VOLREG_MATVEC, SUMA_VOLPAR::xorg, SUMA_VOLPAR::xxorient, SUMA_VOLPAR::yorg, SUMA_VOLPAR::yyorient, SUMA_VOLPAR::zorg, and SUMA_VOLPAR::zzorient.

Referenced by SUMA_VolPar_nel2SOVolPar(), and SUMA_VolParFromDset().

00343 {
00344    static char FuncName[]={"SUMA_Alloc_VolPar"};
00345    SUMA_VOLPAR *VP;
00346 
00347    SUMA_ENTRY;
00348 
00349    VP = (SUMA_VOLPAR *)SUMA_malloc(sizeof(SUMA_VOLPAR));
00350    if (VP == NULL) {
00351       fprintf(SUMA_STDERR,"Error SUMA_Alloc_VolPar: Failed to allocate for VolPar\n");
00352       SUMA_RETURN (NULL);
00353    }
00354    VP->idcode_str = NULL;
00355    VP->isanat = 1;
00356    VP->nx = VP->ny = VP->nz = 0; /*!< number of voxels in the three dimensions */
00357    VP->dx = VP->dy = VP->dz = 0.0; /*!< delta x, y, z in mm */
00358    VP->xorg = VP->yorg = VP->zorg = 0.0; /*!< voxel origin in three dimensions */
00359    VP->prefix = NULL; /*!< parent volume prefix */
00360    VP->filecode = NULL; /*!< parent volume prefix + view */
00361    VP->dirname = NULL; /*!< parent volume directory name */
00362    VP->vol_idcode_str = NULL; /*!< idcode string OF parent volume*/
00363    VP->vol_idcode_date = NULL; /*!< idcode date */
00364    VP->xxorient = VP->yyorient = VP->zzorient = 0; /*!< orientation of three dimensions*/ 
00365    VP->VOLREG_CENTER_OLD = NULL; /*!< pointer to the named attribute (3x1) in the .HEAD file of the experiment-aligned Parent Volume */
00366    VP->VOLREG_CENTER_BASE = NULL; /*!< pointer to the named attribute (3x1) in the .HEAD file of the experiment-aligned Parent Volume */
00367    VP->VOLREG_MATVEC = NULL; /*!< pointer to the named attribute (12x1) in the .HEAD file of the experiment-aligned Parent Volume */
00368    VP->TAGALIGN_MATVEC = NULL; /*!< pointer to the named attribute (12x1) in the .HEAD file of the tag aligned Parent Volume */
00369    VP->ROTATE_MATVEC = NULL; /*!< pointer to the named attribute (12x1) in the .HEAD file of the 3drotated Parent Volume */
00370    VP->ROTATE_CENTER_OLD = NULL;
00371    VP->ROTATE_CENTER_BASE = NULL;
00372    VP->Hand = 1; /*!< Handedness of axis 1 RH, -1 LH*/
00373    
00374    SUMA_RETURN(VP);
00375 }

SUMA_Boolean SUMA_Apply_VolReg_Trans SUMA_SurfaceObject   SO
 

applies the transform in SO->VolPar to SO->NodeList. This only makes sense if SO->NodeList is in DICOM to begin with...

Parameters:
SO  (SUMA_SurfaceObject *) You better have NodeList and VolPar in there...
Returns:
YUP/NOPE
See also:
SUMA_Align_to_VolPar NOTE: The field SO->VOLREG_APPLIED is set to NOPE if this function fails, YUP otherwise

Definition at line 897 of file SUMA_VolData.c.

References i, SUMA_CommonFields::IgnoreVolreg, SUMA_SurfaceObject::N_Node, SUMA_SurfaceObject::NodeDim, SUMA_SurfaceObject::NodeList, SUMA_SurfaceObject::ROTATE_APPLIED, SUMA_VOLPAR::ROTATE_CENTER_BASE, SUMA_VOLPAR::ROTATE_CENTER_OLD, SUMA_VOLPAR::ROTATE_MATVEC, SUMA_Boolean, SUMA_ENTRY, SUMA_RETURN, SUMA_SL_Note, SUMA_SurfaceObject::TAGALIGN_APPLIED, SUMA_VOLPAR::TAGALIGN_MATVEC, SUMA_SurfaceObject::VolPar, SUMA_SurfaceObject::VOLREG_APPLIED, SUMA_VOLPAR::VOLREG_CENTER_BASE, SUMA_VOLPAR::VOLREG_CENTER_OLD, and SUMA_VOLPAR::VOLREG_MATVEC.

Referenced by SUMA_Align_to_VolPar().

00898 {
00899    static char FuncName[]={"SUMA_Apply_VolReg_Trans"};
00900    int i, ND, id;
00901    SUMA_Boolean UseVolreg, UseTagAlign, UseRotate, Bad=YUP;
00902    
00903    SUMA_ENTRY;
00904 
00905    if (SUMAg_CF->IgnoreVolreg) {
00906       SUMA_SL_Note("Ignoring any Volreg or TagAlign transforms present in Surface Volume.\n");
00907       SO->VOLREG_APPLIED = NOPE;
00908       SUMA_RETURN (YUP);
00909    }
00910    
00911    if (SO->VOLREG_APPLIED || SO->TAGALIGN_APPLIED || SO->ROTATE_APPLIED) {
00912       fprintf (SUMA_STDERR,"Error %s: Volreg (or Tagalign or rotate) already applied. Nothing done.\n", FuncName);
00913       SUMA_RETURN (NOPE);
00914    }
00915 
00916    ND = SO->NodeDim;
00917    
00918    
00919    UseVolreg = NOPE;
00920    UseTagAlign = NOPE;
00921    UseRotate = NOPE;
00922    /* perform the rotation needed to align the surface with the current experiment's data */
00923    if (SO->VolPar->VOLREG_MATVEC != NULL || SO->VolPar->VOLREG_CENTER_OLD != NULL || SO->VolPar->VOLREG_CENTER_BASE != NULL) {
00924       Bad = NOPE;
00925       if (SO->VolPar->VOLREG_MATVEC == NULL) {
00926          fprintf(SUMA_STDERR,"Error %s: SO->VolPar->VOLREG_MATVEC = NULL. Cannot perform alignment.\n", FuncName);
00927          Bad = YUP;
00928       }
00929       if (SO->VolPar->VOLREG_CENTER_OLD == NULL) {
00930          fprintf(SUMA_STDERR,"Error %s: SO->VolPar->VOLREG_CENTER_OLD = NULL. Cannot perform alignment.\n", FuncName);
00931          Bad = YUP;
00932       }
00933       if (SO->VolPar->VOLREG_CENTER_BASE == NULL) {
00934          fprintf(SUMA_STDERR,"Error %s: SO->VolPar->VOLREG_CENTER_BASE = NULL. Cannot perform alignment.\n", FuncName);
00935          Bad = YUP;
00936       }
00937       if (!Bad) UseVolreg = YUP;
00938    }
00939    
00940    /* Check for Tagalign and Rotate field */
00941    if (SO->VolPar->TAGALIGN_MATVEC) UseTagAlign = YUP;
00942    if (SO->VolPar->ROTATE_MATVEC || SO->VolPar->ROTATE_CENTER_OLD || SO->VolPar->ROTATE_CENTER_BASE) {
00943       Bad = NOPE;
00944       if (SO->VolPar->ROTATE_MATVEC == NULL) {
00945          fprintf(SUMA_STDERR,"Error %s: SO->VolPar->ROTATE_MATVEC = NULL. Cannot perform alignment.\n", FuncName);
00946          Bad = YUP;
00947       }
00948       if (SO->VolPar->ROTATE_CENTER_OLD == NULL) {
00949          fprintf(SUMA_STDERR,"Error %s: SO->VolPar->ROTATE_CENTER_OLD = NULL. Cannot perform alignment.\n", FuncName);
00950          Bad = YUP;
00951       }
00952       if (SO->VolPar->ROTATE_CENTER_BASE == NULL) {
00953          fprintf(SUMA_STDERR,"Error %s: SO->VolPar->ROTATE_CENTER_BASE = NULL. Cannot perform alignment.\n", FuncName);
00954          Bad = YUP;
00955       }
00956       if (!Bad) UseRotate = YUP;
00957    }
00958    
00959    if (UseTagAlign && UseVolreg) {
00960       SUMA_SL_Note("Found both Volreg and TagAlign fields.\n"
00961                    "Using Volreg fields for alignment.");
00962       UseTagAlign = NOPE;
00963    }
00964    if (UseRotate && UseVolreg) {
00965       SUMA_SL_Note("Found both Volreg and Rotate fields.\n"
00966                    "Using Volreg fields for alignment.");
00967       UseRotate = NOPE;
00968    }
00969    if (UseRotate && UseTagAlign) {
00970       SUMA_SL_Note("Found both Rotate and TagAlign fields.\n"
00971                    "Using Tagalign fields for alignment.");
00972       UseRotate = NOPE;
00973    }
00974    
00975    if (UseTagAlign) {
00976       float Mrot[3][3], Delta[3], x, y, z, NetShift[3];
00977       
00978       /* fillerup*/
00979       Mrot[0][0] = SO->VolPar->TAGALIGN_MATVEC[0];
00980       Mrot[0][1] = SO->VolPar->TAGALIGN_MATVEC[1];
00981       Mrot[0][2] = SO->VolPar->TAGALIGN_MATVEC[2];
00982       Delta[0]   = SO->VolPar->TAGALIGN_MATVEC[3];
00983       Mrot[1][0] = SO->VolPar->TAGALIGN_MATVEC[4];
00984       Mrot[1][1] = SO->VolPar->TAGALIGN_MATVEC[5];
00985       Mrot[1][2] = SO->VolPar->TAGALIGN_MATVEC[6];
00986       Delta[1]   = SO->VolPar->TAGALIGN_MATVEC[7];   
00987       Mrot[2][0] = SO->VolPar->TAGALIGN_MATVEC[8];
00988       Mrot[2][1] = SO->VolPar->TAGALIGN_MATVEC[9];
00989       Mrot[2][2] = SO->VolPar->TAGALIGN_MATVEC[10];
00990       Delta[2]   = SO->VolPar->TAGALIGN_MATVEC[11];
00991       
00992       NetShift[0] = Delta[0];
00993       NetShift[1] = Delta[1];
00994       NetShift[2] = Delta[2];
00995       
00996       /*
00997       fprintf (SUMA_STDERR,"%s: Applying Rotation.\nMrot[\t%f\t%f\t%f\n%f\t%f\t%f\n%f\t%f\t%f]\nDelta = [%f %f %f]\n", FuncName,\
00998                Mrot[0][0], Mrot[0][1], Mrot[0][2], Mrot[1][0], Mrot[1][1], Mrot[1][2], Mrot[2][0], Mrot[2][1], Mrot[2][2], \
00999                Delta[0], Delta[1], Delta[2]);
01000       
01001       */
01002       
01003       for (i=0; i < SO->N_Node; ++i) {
01004          id = ND * i;
01005          /* zero the center */ 
01006          x = SO->NodeList[id] ;
01007          y = SO->NodeList[id+1] ;
01008          z = SO->NodeList[id+2] ;
01009          
01010          /* Apply the rotation matrix XYZn = Mrot x XYZ*/
01011          SO->NodeList[id] = Mrot[0][0] * x + Mrot[0][1] * y + Mrot[0][2] * z;
01012          SO->NodeList[id+1] = Mrot[1][0] * x + Mrot[1][1] * y + Mrot[1][2] * z;
01013          SO->NodeList[id+2] = Mrot[2][0] * x + Mrot[2][1] * y + Mrot[2][2] * z;
01014          
01015          /*apply netshift*/
01016          SO->NodeList[id] += NetShift[0];
01017          SO->NodeList[id+1] += NetShift[1];
01018          SO->NodeList[id+2] += NetShift[2];
01019       }
01020       SO->TAGALIGN_APPLIED = YUP;   
01021    } else
01022       SO->TAGALIGN_APPLIED = NOPE;
01023          
01024    if (UseVolreg) {
01025       float Mrot[3][3], Delta[3], x, y, z, NetShift[3];
01026       
01027       /* fillerup*/
01028       Mrot[0][0] = SO->VolPar->VOLREG_MATVEC[0];
01029       Mrot[0][1] = SO->VolPar->VOLREG_MATVEC[1];
01030       Mrot[0][2] = SO->VolPar->VOLREG_MATVEC[2];
01031       Delta[0]   = SO->VolPar->VOLREG_MATVEC[3];
01032       Mrot[1][0] = SO->VolPar->VOLREG_MATVEC[4];
01033       Mrot[1][1] = SO->VolPar->VOLREG_MATVEC[5];
01034       Mrot[1][2] = SO->VolPar->VOLREG_MATVEC[6];
01035       Delta[1]   = SO->VolPar->VOLREG_MATVEC[7];   
01036       Mrot[2][0] = SO->VolPar->VOLREG_MATVEC[8];
01037       Mrot[2][1] = SO->VolPar->VOLREG_MATVEC[9];
01038       Mrot[2][2] = SO->VolPar->VOLREG_MATVEC[10];
01039       Delta[2]   = SO->VolPar->VOLREG_MATVEC[11];
01040       
01041       NetShift[0] = SO->VolPar->VOLREG_CENTER_BASE[0] + Delta[0];
01042       NetShift[1] = SO->VolPar->VOLREG_CENTER_BASE[1] + Delta[1];
01043       NetShift[2] = SO->VolPar->VOLREG_CENTER_BASE[2] + Delta[2];
01044       
01045       /*
01046       fprintf (SUMA_STDERR,"%s: Applying Rotation.\nMrot[\t%f\t%f\t%f\n%f\t%f\t%f\n%f\t%f\t%f]\nDelta = [%f %f %f]\n", FuncName,\
01047                Mrot[0][0], Mrot[0][1], Mrot[0][2], Mrot[1][0], Mrot[1][1], Mrot[1][2], Mrot[2][0], Mrot[2][1], Mrot[2][2], \
01048                Delta[0], Delta[1], Delta[2]);
01049       fprintf (SUMA_STDERR,"VOLREG_CENTER_BASE = [%f %f %f]. VOLREG_CENTER_OLD = [%f %f %f]\n", \
01050          SO->VolPar->VOLREG_CENTER_BASE[0], SO->VolPar->VOLREG_CENTER_BASE[1], SO->VolPar->VOLREG_CENTER_BASE[2], \
01051          SO->VolPar->VOLREG_CENTER_OLD[0], SO->VolPar->VOLREG_CENTER_OLD[1], SO->VolPar->VOLREG_CENTER_OLD[2]);
01052       */
01053       
01054       for (i=0; i < SO->N_Node; ++i) {
01055          id = ND * i;
01056          /* zero the center */ 
01057          x = SO->NodeList[id  ] - SO->VolPar->VOLREG_CENTER_OLD[0];
01058          y = SO->NodeList[id+1] - SO->VolPar->VOLREG_CENTER_OLD[1];
01059          z = SO->NodeList[id+2] - SO->VolPar->VOLREG_CENTER_OLD[2];
01060          
01061          /* Apply the rotation matrix XYZn = Mrot x XYZ*/
01062          SO->NodeList[id  ] = Mrot[0][0] * x + Mrot[0][1] * y + Mrot[0][2] * z;
01063          SO->NodeList[id+1] = Mrot[1][0] * x + Mrot[1][1] * y + Mrot[1][2] * z;
01064          SO->NodeList[id+2] = Mrot[2][0] * x + Mrot[2][1] * y + Mrot[2][2] * z;
01065          
01066          /*apply netshift*/
01067          SO->NodeList[id  ] += NetShift[0];
01068          SO->NodeList[id+1] += NetShift[1];
01069          SO->NodeList[id+2] += NetShift[2];
01070       }
01071       SO->VOLREG_APPLIED = YUP;   
01072    } else
01073       SO->VOLREG_APPLIED = NOPE;
01074    
01075    if (UseRotate) {
01076       float Mrot[3][3], Delta[3], x, y, z, NetShift[3];
01077       
01078       /* fillerup*/
01079       Mrot[0][0] = SO->VolPar->ROTATE_MATVEC[0];
01080       Mrot[0][1] = SO->VolPar->ROTATE_MATVEC[1];
01081       Mrot[0][2] = SO->VolPar->ROTATE_MATVEC[2];
01082       Delta[0]   = SO->VolPar->ROTATE_MATVEC[3];
01083       Mrot[1][0] = SO->VolPar->ROTATE_MATVEC[4];
01084       Mrot[1][1] = SO->VolPar->ROTATE_MATVEC[5];
01085       Mrot[1][2] = SO->VolPar->ROTATE_MATVEC[6];
01086       Delta[1]   = SO->VolPar->ROTATE_MATVEC[7];   
01087       Mrot[2][0] = SO->VolPar->ROTATE_MATVEC[8];
01088       Mrot[2][1] = SO->VolPar->ROTATE_MATVEC[9];
01089       Mrot[2][2] = SO->VolPar->ROTATE_MATVEC[10];
01090       Delta[2]   = SO->VolPar->ROTATE_MATVEC[11];
01091       
01092       NetShift[0] = SO->VolPar->ROTATE_CENTER_BASE[0] + Delta[0];
01093       NetShift[1] = SO->VolPar->ROTATE_CENTER_BASE[0] + Delta[1];
01094       NetShift[2] = SO->VolPar->ROTATE_CENTER_BASE[0] + Delta[2];
01095       
01096       /*
01097       fprintf (SUMA_STDERR,"%s: Applying Rotation.\nMrot[\t%f\t%f\t%f\n%f\t%f\t%f\n%f\t%f\t%f]\nDelta = [%f %f %f]\n", FuncName,\
01098                Mrot[0][0], Mrot[0][1], Mrot[0][2], Mrot[1][0], Mrot[1][1], Mrot[1][2], Mrot[2][0], Mrot[2][1], Mrot[2][2], \
01099                Delta[0], Delta[1], Delta[2]);
01100       fprintf (SUMA_STDERR,"ROTATE_CENTER_BASE = [%f %f %f]. ROTATE_CENTER_OLD = [%f %f %f]\n", \
01101          SO->VolPar->ROTATE_CENTER_BASE[0], SO->VolPar->ROTATE_CENTER_BASE[1], SO->VolPar->ROTATE_CENTER_BASE[2], \
01102          SO->VolPar->ROTATE_CENTER_OLD[0], SO->VolPar->ROTATE_CENTER_OLD[1], SO->VolPar->ROTATE_CENTER_OLD[2]);
01103       */
01104       
01105       for (i=0; i < SO->N_Node; ++i) {
01106          id = ND * i;
01107          /* zero the center */ 
01108          x = SO->NodeList[id  ] - SO->VolPar->ROTATE_CENTER_OLD[0];
01109          y = SO->NodeList[id+1] - SO->VolPar->ROTATE_CENTER_OLD[1];
01110          z = SO->NodeList[id+2] - SO->VolPar->ROTATE_CENTER_OLD[1];
01111          
01112          /* Apply the rotation matrix XYZn = Mrot x XYZ*/
01113          SO->NodeList[id  ] = Mrot[0][0] * x + Mrot[0][1] * y + Mrot[0][2] * z;
01114          SO->NodeList[id+1] = Mrot[1][0] * x + Mrot[1][1] * y + Mrot[1][2] * z;
01115          SO->NodeList[id+2] = Mrot[2][0] * x + Mrot[2][1] * y + Mrot[2][2] * z;
01116          
01117          /*apply netshift*/
01118          SO->NodeList[id  ] += NetShift[0];
01119          SO->NodeList[id+1] += NetShift[1];
01120          SO->NodeList[id+2] += NetShift[2];
01121       }
01122       SO->ROTATE_APPLIED = YUP;   
01123    } else
01124       SO->ROTATE_APPLIED = NOPE;
01125    
01126    SUMA_RETURN (YUP);
01127 }

SUMA_ASSEMBLE_LIST_STRUCT* SUMA_AssembleAllROIList SUMA_DO   dov,
int    N_dov,
SUMA_Boolean    SortByLabel
 

Returns a list of the ROIs loaded into dov.

Parameters:
dov  (SUMA_DO *) pointer to vector of DOs
N_dov  (int) number of DOs in dov
SortByLabel  (SUMA_Boolean) if YUP then returned strings are sorted by their ROI's labels (The parents must be part of dov). If Nope then strings are sorted by the labels of the ROI's parent.
Returns:
clist (SUMA_ASSEMBLE_LIST_STRUCT *) pointer to structure containing results
See also:
SUMA_FreeAssembleListStruct , SUMA_CreateAssembleListStruct

Definition at line 1134 of file SUMA_DOmanip.c.

References SUMA_ASSEMBLE_LIST_STRUCT::clist, DListElmt_::data, dlist_destroy(), dlist_head, dlist_init(), dlist_ins_next(), dlist_ins_prev(), dlist_next, dlist_tail, i, SUMA_SurfaceObject::Label, SUMA_DRAWN_ROI::Label, LocalHead, SUMA_ASSEMBLE_LIST_STRUCT::N_clist, SUMA_ASSEMBLE_LIST_STRUCT::oplist, SUMA_DRAWN_ROI::Parent_idcode_str, ROIdO_type, DList_::size, SUMA_Boolean, SUMA_calloc, SUMA_CreateAssembleListStruct(), SUMA_ENTRY, SUMA_findSOp_inDOv(), SUMA_free, SUMA_malloc, SUMA_MAX_NAME_LENGTH, and SUMA_RETURN.

Referenced by SUMA_cb_DrawROI_SwitchROI(), and SUMA_DeleteROI().

01135 {
01136    static char FuncName[]={"SUMA_AssembleAllROIList"};
01137    int i=-1, N_clist=-1; 
01138    DList *list=NULL, *listop = NULL;
01139    DListElmt *Elm = NULL, *Elmop = NULL;
01140    char Label[SUMA_MAX_NAME_LENGTH], Parent_Label[SUMA_MAX_NAME_LENGTH], *store=NULL;
01141    SUMA_SurfaceObject *SO = NULL;
01142    char **clist=NULL;
01143    void **oplist=NULL;
01144    SUMA_DRAWN_ROI *ROI=NULL;
01145    SUMA_ASSEMBLE_LIST_STRUCT *clist_str = NULL;
01146    SUMA_Boolean Found = NOPE;
01147    SUMA_Boolean LocalHead = NOPE;
01148 
01149    SUMA_ENTRY;
01150    
01151    list = (DList *)SUMA_malloc(sizeof(DList));
01152    listop = (DList *)SUMA_malloc(sizeof(DList));
01153    
01154    clist = NULL;
01155    N_clist = -1;
01156    
01157    dlist_init(list, NULL);
01158    dlist_init(listop, NULL);
01159    for (i=0; i < N_dov; ++i) {
01160       if (dov[i].ObjectType == ROIdO_type) {
01161          ROI = (SUMA_DRAWN_ROI *)dov[i].OP;
01162          if (LocalHead) fprintf (SUMA_STDERR, "%s: Found an ROI %s\n", FuncName, ROI->Label);
01163          if (!ROI->Label) sprintf (Label,"NULL");
01164          else sprintf (Label,"%s", ROI->Label);
01165          if (!ROI->Parent_idcode_str) sprintf (Parent_Label,"NULL");
01166          else {
01167             SO = SUMA_findSOp_inDOv(ROI->Parent_idcode_str, dov, N_dov);
01168             if (!SO) sprintf (Parent_Label,"Unknown");
01169             else if (!SO->Label) sprintf (Parent_Label,"Empty");
01170             else sprintf (Parent_Label,"%s", SO->Label);
01171          }
01172          /* Now allocate space for that label */
01173          store = (char *)SUMA_calloc(strlen(Label)+strlen(Parent_Label)+5, sizeof(char));
01174          if (SortByLabel) {
01175             sprintf(store,"%s:%s", Label, Parent_Label);
01176          } else  {
01177             sprintf(store,"%s:%s", Parent_Label, Label);
01178          }
01179          
01180          /* now place it in the list by aplhpabetical order */
01181          if (!list->size) {
01182             dlist_ins_next(list, dlist_tail(list), (void*)store);
01183             dlist_ins_next(listop, dlist_tail(listop), (void*)ROI);
01184          }else { /* must sort first */
01185             Elm = NULL;
01186             Elmop = NULL;
01187             do {
01188                Found = NOPE;
01189                if (!Elm) {
01190                   Elm = dlist_head(list);
01191                   Elmop = dlist_head(listop);
01192                } else {
01193                   Elm = dlist_next(Elm);
01194                   Elmop = dlist_next(Elmop);
01195                }
01196                
01197                if (strcmp(store, (char*)Elm->data) <= 0) {
01198                   dlist_ins_prev(list, Elm, (void *)store);
01199                   dlist_ins_prev(listop, Elmop, (void *)ROI);
01200                   Found = YUP;
01201                } else if (Elm == dlist_tail(list)) {
01202                   /* reached the end, append */
01203                   dlist_ins_next(list, Elm, (void *)store);
01204                   dlist_ins_next(listop, Elmop, (void *)ROI);
01205                   Found = YUP;
01206                }
01207             } while (!Found);
01208          }
01209          
01210       }
01211    }
01212 
01213    if (!list->size) { /* Nothing found */
01214       N_clist = 0;
01215       
01216    }else {
01217    
01218       Elm = NULL;
01219       Elmop = NULL;
01220       clist = (char **)SUMA_calloc(list->size, sizeof(char *));
01221       oplist = (void **)SUMA_calloc(list->size, sizeof(void*));
01222       for (i=0; i< list->size; ++i) {
01223          if (!Elm) {
01224             Elm = dlist_head(list);
01225             Elmop = dlist_head(listop);
01226          } else {
01227             Elm = dlist_next(Elm);
01228             Elmop = dlist_next(Elmop);
01229          }
01230          clist[i] = (char*)Elm->data;
01231          oplist[i] = Elmop->data;
01232       }
01233 
01234       N_clist = list->size;
01235       /* destroy list */
01236       dlist_destroy(list);
01237       dlist_destroy(listop);
01238       SUMA_free(list);
01239       SUMA_free(listop);
01240    }
01241    
01242    clist_str = SUMA_CreateAssembleListStruct();
01243    clist_str->clist = clist;
01244    clist_str->oplist = oplist;
01245    clist_str->N_clist = N_clist;
01246    
01247    /* return */
01248    SUMA_RETURN (clist_str);  
01249 }

SUMA_INODE* SUMA_BreakInodeLink SUMA_INODE   IN,
const char *    HolderIDcode
 

function to remove the link of one IDnode to the next SUMA_INODE * SUMA_BreakInodeLink (SUMA_INODE *IN, const char *HolderIDcode);

Parameters:
IN  (SUMA_INODE *) the linked inode
HolderIDcode  (const char *) the ID code that holds/contains IN \ret NULL if the link was broken or IN == NULL IN if IN is not a link but an actuak Inode (meaning IN->ParentIDcode == HolderIDcode

Definition at line 90 of file SUMA_DOmanip.c.

References SUMA_ENTRY, SUMA_isInodeLink(), SUMA_ReleaseLink(), and SUMA_RETURN.

00091 {
00092    static char FuncName[] = {"SUMA_BreakInodeLink"};
00093 
00094    SUMA_ENTRY;
00095 
00096    if (!IN) {
00097       fprintf (SUMA_STDERR, "Warning %s: IN is null, nothing to do.\n", FuncName); 
00098       SUMA_RETURN(NULL);
00099    }
00100    if (!SUMA_isInodeLink (IN, HolderIDcode)) {
00101       fprintf (SUMA_STDERR, "Error %s: Inode IN is not a link. Nothing done.\n", FuncName);
00102       SUMA_RETURN(IN);
00103    } 
00104    
00105    /* release the link */
00106    if (SUMA_ReleaseLink (IN) < 0) {
00107       fprintf (SUMA_STDERR, "Error %s: IN has no links. Nothing done.\n", FuncName);
00108       SUMA_RETURN(IN);
00109    }
00110    
00111    /* OK, link released, not return NULL */
00112    SUMA_RETURN(NULL);
00113 }

int* SUMA_Build_Mask_AllROI SUMA_DO   dov,
int    N_do,
SUMA_SurfaceObject   SO,
int *    Mask,
int *    N_added
 

Return a mask of the nodes belonging to any ROI of a certain surface Mask = SUMA_Build_Mask_AllROI (dov, N_dov, SO, Mask, N_added);.

Parameters:
dov  (SUMA_DO*) pointer to vector of displayable objects to consider
N_dov  (int) number of elements in dov
SO  (SUMA_SurfaceObject *)
Mask  (int *) pointer to mask vector. 0 if node belongs to no ROI n if node belongs to n ROIs Pass NULL if you're calling this function for the first time.
N_added  (int *)integer containing the total number of nodes added to Mask. That would be the sum of the number of nodes found in all ROIs. Duplicate nodes are counted twice. If you want the number of nodes without the duplicates, you need to count non-zero values in Mask.
Returns:
Mask (int *) pointer to modified mask vector.

Definition at line 1423 of file SUMA_DOmanip.c.

References i, LocalHead, SUMA_SurfaceObject::N_Node, ROIdO_type, ROIO_type, SUMA_Boolean, SUMA_Build_Mask_DrawnROI(), SUMA_calloc, SUMA_ENTRY, SUMA_free, SUMA_isdROIrelated(), SUMA_isROIrelated(), SUMA_RETURN, and SUMA_S_Err.

Referenced by SUMA_ProcessBrushStroke().

01424 {
01425    static char FuncName[]={"SUMA_Build_Mask_AllROI"};
01426    int Npart = 0,i;
01427    SUMA_DRAWN_ROI *D_ROI=NULL;
01428    SUMA_ROI *ROI = NULL;
01429    SUMA_Boolean LocalHead = NOPE;
01430     
01431    SUMA_ENTRY;
01432    
01433    *N_added = -1;
01434    
01435    if (!Mask) { /* allocate for it */
01436       Mask = (int *)SUMA_calloc(SO->N_Node, sizeof(int));
01437       if (!Mask) {
01438          SUMA_S_Err ("Failed to allocate for Mask.");
01439          SUMA_RETURN(NULL);
01440       }
01441    }
01442    
01443    for (i=0; i < N_do; ++i) {
01444       switch (dov[i].ObjectType) { /* case Object Type */
01445          case ROIdO_type:
01446             D_ROI = (SUMA_DRAWN_ROI *)dov[i].OP;
01447             if (SUMA_isdROIrelated (D_ROI, SO)) {
01448                if (LocalHead) fprintf (SUMA_STDERR, "%s: Found a drawn ROI, building mask...\n", FuncName);
01449 
01450                Npart = SUMA_Build_Mask_DrawnROI (D_ROI, Mask);
01451                if (Npart < 0) {
01452                   SUMA_S_Err ("Badness in SUMA_Build_Mask_DrawnROI");
01453                   if (Mask) SUMA_free(Mask);
01454                   *N_added = -1;
01455                   SUMA_RETURN(NULL);
01456                }else {
01457                   *N_added = *N_added + Npart;
01458                   if (LocalHead) fprintf (SUMA_STDERR, "%s: %d nodes found in that ROI.\n", FuncName, Npart);
01459                }
01460             }
01461             break;
01462          case ROIO_type:
01463             ROI = (SUMA_ROI *)dov[i].OP;
01464             if (SUMA_isROIrelated (ROI, SO)) {
01465                SUMA_S_Err ("Not dealing with regular ROIs yet");
01466             }
01467             break;
01468          default:
01469             /* not an ROI */
01470             break;   
01471       }
01472    }
01473    
01474    SUMA_RETURN(Mask);
01475 }

int SUMA_Build_Mask_DrawnROI SUMA_DRAWN_ROI   D_ROI,
int *    Mask
 

Return a mask of the nodes belonging to a drawn ROI of a certain surface N_added = SUMA_Build_Mask_DrawnROI (dROI, Mask);.

Parameters:
dROI  (SUMA_DRAWN_ROI *) the pointer to the ROI structure
Mask  (int *) pointer to mask vector. 0 if node belongs to no ROI n if node belongs to n ROIs It is the calling function's responsability to make sure enough space is allocated for Mask and that cleanup is properly handled.
Returns:
N_added (int *)integer containing the number of nodes found in dROI. This variable is set to -1 when trouble occurs.

Definition at line 1490 of file SUMA_DOmanip.c.

References DListElmt_::data, dlist_head, dlist_next, dlist_size, dlist_tail, SUMA_ROI_DATUM::N_n, SUMA_ROI_DATUM::nPath, SUMA_DRAWN_ROI::ROIstrokelist, SUMA_ENTRY, SUMA_RETURN, and SUMA_S_Err.

Referenced by SUMA_Build_Mask_AllROI(), and SUMA_ProcessBrushStroke().

01491 {
01492    static char FuncName[]={"SUMA_Build_Mask_DrawnROI"};
01493    DListElmt *NextElm=NULL;
01494    int ii, N_added;
01495    SUMA_ROI_DATUM *ROId=NULL;
01496    
01497    SUMA_ENTRY;
01498    
01499    N_added = -1;
01500    
01501    if (!Mask) { 
01502       SUMA_S_Err ("Mask is NULL");
01503       SUMA_RETURN(N_added);
01504    }
01505    
01506    if (!D_ROI->ROIstrokelist) {
01507      N_added = 0;
01508      SUMA_RETURN(N_added); 
01509    }
01510    
01511    if (!dlist_size(D_ROI->ROIstrokelist)) {
01512      N_added = 0;
01513      SUMA_RETURN(N_added); 
01514    }
01515    
01516    /* start with the first element */
01517    NextElm = NULL;
01518    do {
01519       if (!NextElm) {
01520          NextElm = dlist_head(D_ROI->ROIstrokelist);
01521       }else {
01522          NextElm = dlist_next(NextElm);
01523       }
01524       ROId = (SUMA_ROI_DATUM *)NextElm->data;
01525       if (ROId->N_n) {
01526          for (ii = 0; ii < ROId->N_n; ++ii) {
01527             ++Mask[ROId->nPath[ii]];
01528             ++N_added;
01529          }
01530       }
01531    } while (NextElm != dlist_tail(D_ROI->ROIstrokelist));
01532                
01533    SUMA_RETURN (N_added);
01534 }

SUMA_ASSEMBLE_LIST_STRUCT* SUMA_CreateAssembleListStruct void   
 

Creates an SUMA_ASSEMBLE_LIST_STRUCT *structure.

See also:
SUMA_FreeAssembleListStruct

Definition at line 1255 of file SUMA_DOmanip.c.

References SUMA_ASSEMBLE_LIST_STRUCT::clist, SUMA_ASSEMBLE_LIST_STRUCT::N_clist, SUMA_ASSEMBLE_LIST_STRUCT::oplist, SUMA_ENTRY, SUMA_malloc, and SUMA_RETURN.

Referenced by SUMA_AssembleAllROIList(), SUMA_AssembleCmapList(), SUMA_AssembleColorPlaneList(), and SUMA_AssembleGroupList().

01256 {
01257    static char FuncName[]={"SUMA_CreateAssembleListStruct"};
01258    SUMA_ASSEMBLE_LIST_STRUCT *str=NULL;
01259    
01260    SUMA_ENTRY;
01261    
01262    str = (SUMA_ASSEMBLE_LIST_STRUCT *)SUMA_malloc(sizeof(SUMA_ASSEMBLE_LIST_STRUCT));
01263    str->clist = NULL;
01264    str->N_clist = -1;
01265    str->oplist = NULL;
01266    
01267    SUMA_RETURN(str);
01268 }

SUMA_INODE* SUMA_CreateInode void *    data,
char *    ID
 

Function to create a SUMA_INODE structure ans = SUMA_CreateInode (data, ParentIDcode);

Parameters:
data  (void *) pointer to data location
ParentIDcode  (char[SUMA_IDCODE_LENGTH]) containing the IDcode of the creator of the data \ret ans (SUMA_INODE *) pointer to SUMA_INODE for data NULL if error is encountered

Definition at line 190 of file SUMA_DOmanip.c.

References SUMA_INODE::data, SUMA_INODE::N_link, SUMA_INODE::ParentIDcode, SUMA_ENTRY, SUMA_malloc, and SUMA_RETURN.

00191 {
00192    static char FuncName[]={"SUMA_CreateInode"};
00193    SUMA_INODE *IN;
00194    
00195    SUMA_ENTRY;
00196 
00197    IN = (SUMA_INODE *)SUMA_malloc (sizeof(SUMA_INODE));
00198    if (IN == NULL) {
00199       fprintf (SUMA_STDERR,"Error %s: failed to allocate for Inode.\n", FuncName);
00200       SUMA_RETURN(NULL);
00201    }
00202    
00203    IN->data = data;
00204    strcpy (IN->ParentIDcode, ID);
00205    IN->N_link = 0;
00206    
00207    SUMA_RETURN(IN);
00208 }

SUMA_INODE* SUMA_CreateInodeLink SUMA_INODE   FromIN,
SUMA_INODE   ToIN
 

This function Links one Inode to another. This is different from CreateInode in that no new node is being allocated for, only a link is created. SUMA_CreateInodeLink (SUMA_INODE * FromIN, SUMA_INODE *ToIN)

FromIN = SUMA_CreateInodeLink (FromIN, ToIN);

Parameters:
FromIN  (SUMA_INODE *) this is the pointer to the IDnode wich will be linked to ToIN. As silly as this sounds, this should be a pointer to NULL otherwise the link will not be established. The use of this function will help reduce the risk of linking pointers that are pointing to allocated space.
ToIN  (SUMA_INODE *) pointer where the link is going \ret FromIN (SUMA_INODE *) if all is well, FromIN = ToIN otherwise, NULL is returned
All this function does is check the FromIN is NULL and ToIN isn't and then it calls SUMA_AddLink (ToIN)
See also:
SUMA_BreakInodeLink , SUMA_isInodeLink

Definition at line 30 of file SUMA_DOmanip.c.

References SUMA_AddLink(), SUMA_ENTRY, and SUMA_RETURN.

00031 {
00032    static char FuncName[] = {"SUMA_CreateInodeLink"};
00033    
00034    SUMA_ENTRY;
00035 
00036    if (FromIN) {
00037       fprintf (SUMA_STDERR,"Error %s: FromIN Inode is not NULL. \n\tFromIN pointer is left undisturbed.\n", FuncName);
00038       SUMA_RETURN(FromIN);
00039    }
00040    if (!ToIN) {
00041       fprintf (SUMA_STDERR,"Error %s: ToIN is NULL.\n\t Can't link to NULL, returning NULL.\n", FuncName);
00042       SUMA_RETURN(NULL); 
00043    }
00044    
00045    /* add a link to ToIN */
00046    if (!SUMA_AddLink (ToIN)) {
00047       fprintf (SUMA_STDERR,"Error %s: Failed in SUMA_AddLink.\n", FuncName);
00048       SUMA_RETURN(NULL);
00049    }
00050    
00051    /* now return the pointer to be linked to */
00052    SUMA_RETURN(ToIN);
00053 
00054 }

SUMA_Boolean SUMA_DeleteROI SUMA_DRAWN_ROI   ROI
 

deletes an ROI from the list of drawn objects

Definition at line 1539 of file SUMA_DOmanip.c.

References SUMA_X_DrawROI::curDrawnROI, SUMA_X_AllView::DrawROI, i, LocalHead, SUMA_ASSEMBLE_LIST_STRUCT::N_clist, SUMA_ASSEMBLE_LIST_STRUCT::oplist, SUMA_AssembleAllROIList(), SUMA_Boolean, SUMA_cb_CloseSwitchROI(), SUMA_ENTRY, SUMA_FreeAssembleListStruct(), SUMA_InitializeDrawROIWindow(), SUMA_IS_DRAW_ROI_SWITCH_ROI_SHADED, SUMA_LH, SUMA_RemoveDO(), SUMA_RETURN, SUMA_SLP_Err, SUMAg_N_DOv, SUMA_X_DrawROI::SwitchROIlst, and SUMA_CommonFields::X.

Referenced by SUMA_cb_DrawROI_Delete(), and SUMA_OpenDrawnROI_NIML().

01540 {
01541    static char FuncName[]={"SUMA_DeleteROI"};
01542    SUMA_ASSEMBLE_LIST_STRUCT *ALS = NULL;
01543    SUMA_DRAWN_ROI *NextROI=NULL;
01544    int i;
01545    SUMA_Boolean WasCurrent = NOPE, Shaded = NOPE;
01546    SUMA_Boolean LocalHead = NOPE;
01547 
01548    SUMA_ENTRY;
01549 
01550    if (!ROI) {
01551       SUMA_LH("Null ROI");
01552       SUMA_RETURN(YUP);
01553    }
01554    
01555    /* form a list of the current ROI available for editing */
01556 
01557    /* assemble the ROI list */
01558    ALS = SUMA_AssembleAllROIList (SUMAg_DOv, SUMAg_N_DOv, YUP);
01559 
01560    NextROI = NULL;
01561    if (ALS) {
01562       if (ALS->N_clist)  {
01563          i=0;
01564          while (!NextROI && i<ALS->N_clist) {
01565             if (ALS->oplist[i] != (void*)ROI) 
01566                NextROI = (SUMA_DRAWN_ROI *)ALS->oplist[i];
01567             ++i;
01568          }  
01569       }
01570       SUMA_FreeAssembleListStruct(ALS);
01571    }
01572 
01573    /* check to see if ROI being deleted is current one */
01574    if (ROI == SUMAg_CF->X->DrawROI->curDrawnROI) {
01575       WasCurrent = YUP;
01576    }else {
01577       WasCurrent = NOPE;
01578    }
01579    
01580    /* Close the ROIlist window if it is open */
01581    SUMA_IS_DRAW_ROI_SWITCH_ROI_SHADED(Shaded);
01582    if (!Shaded) {
01583       if (LocalHead) fprintf (SUMA_STDERR, "%s: Closing switch ROI window ...\n", FuncName);
01584       SUMA_cb_CloseSwitchROI(NULL, (XtPointer) SUMAg_CF->X->DrawROI->SwitchROIlst, NULL);
01585    }
01586 
01587    /* remove ROI for SUMAg_DO and clear the ROI structure*/
01588    if (!SUMA_RemoveDO(SUMAg_DOv, &SUMAg_N_DOv, (void *)ROI, YUP)) {
01589       SUMA_SLP_Err("Failed to remove DO from list.");
01590       SUMA_RETURN(NOPE);
01591    }
01592 
01593    if (WasCurrent) {
01594       SUMAg_CF->X->DrawROI->curDrawnROI = NextROI;
01595 
01596       /* reinitialize the draw ROI window */
01597       SUMA_InitializeDrawROIWindow(SUMAg_CF->X->DrawROI->curDrawnROI);
01598    }
01599    
01600    SUMA_RETURN(YUP);
01601 }

SUMA_Boolean SUMA_existDO char *    idcode,
SUMA_DO   dov,
int    N_dov
 

searches all DO objects with an idcode_str for idcode

YUP if found, NOPE if not

Definition at line 618 of file SUMA_DOmanip.c.

References i, SUMA_SegmentDO::idcode_str, SUMA_Axis::idcode_str, SUMA_ROI::idcode_str, SUMA_DRAWN_ROI::idcode_str, SUMA_SurfaceObject::idcode_str, SUMA_Boolean, SUMA_ENTRY, and SUMA_RETURN.

Referenced by SUMA_OpenDrawnROI_NIML().

00619 {
00620    static char FuncName[]={"SUMA_existDO"};
00621    int i;
00622    SUMA_SurfaceObject *SO = NULL;
00623    SUMA_DRAWN_ROI *dROI = NULL;
00624    SUMA_ROI *ROI = NULL;
00625    SUMA_SegmentDO *sdo = NULL;
00626    SUMA_Axis *sax = NULL;
00627    
00628    SUMA_ENTRY;
00629 
00630    if (idcode == NULL) {
00631       fprintf(SUMA_STDERR,"Warning %s: NULL idcode.\n", FuncName);
00632       SUMA_RETURN (NOPE);
00633    }
00634    for (i=0; i< N_dov; ++i) {
00635       switch (dov[i].ObjectType) {
00636          case (SO_type):
00637             SO = (SUMA_SurfaceObject *)dov[i].OP;
00638             if (strcmp(idcode, SO->idcode_str)== 0) {
00639                SUMA_RETURN (YUP);
00640             }
00641             break;
00642          case (ROIdO_type):
00643             dROI = (SUMA_DRAWN_ROI *)dov[i].OP;
00644             if (strcmp(idcode, dROI->idcode_str)== 0) {
00645                SUMA_RETURN (YUP);
00646             }
00647             break;
00648          case (ROIO_type):
00649             ROI = (SUMA_ROI *)dov[i].OP;
00650             if (strcmp(idcode, ROI->idcode_str)== 0) {
00651                SUMA_RETURN (YUP);
00652             }
00653             break;
00654          case (AO_type):
00655             sax = (SUMA_Axis *)dov[i].OP;
00656             if (strcmp(idcode, sax->idcode_str)== 0) {
00657                SUMA_RETURN (YUP);
00658             }
00659             break;
00660          case (LS_type):
00661             sdo = (SUMA_SegmentDO *)dov[i].OP;
00662             if (strcmp(idcode, sdo->idcode_str)== 0) {
00663                SUMA_RETURN (YUP);
00664             }
00665             break;
00666          default:
00667             fprintf(SUMA_STDERR,"Warning %s: Object type %d not checked.\n", FuncName, dov[i].ObjectType);
00668             break;
00669       }
00670    }
00671    SUMA_RETURN(NOPE);
00672 }

SUMA_Boolean SUMA_existSO char *    idcode,
SUMA_DO   dov,
int    N_dov
 

searches all SO_type DO objects for idcode YUP if found, NOPE if not

Definition at line 590 of file SUMA_DOmanip.c.

References i, SUMA_SurfaceObject::idcode_str, SO_type, SUMA_Boolean, SUMA_ENTRY, and SUMA_RETURN.

Referenced by SUMA_LoadSpec_eng().

00591 {
00592    static char FuncName[]={"SUMA_existSO"};
00593    SUMA_SurfaceObject *SO;
00594    int i;
00595    
00596    SUMA_ENTRY;
00597 
00598    if (idcode == NULL) {
00599       fprintf(SUMA_STDERR,"Warning SUMA_existSO: NULL idcode.\n");
00600       SUMA_RETURN (NOPE);
00601    }
00602    for (i=0; i< N_dov; ++i) {
00603       if (dov[i].ObjectType == SO_type) {
00604          SO = (SUMA_SurfaceObject *)dov[i].OP;
00605          if (strcmp(idcode, SO->idcode_str)== 0) {
00606             SUMA_RETURN (YUP);
00607          }
00608       }
00609    }
00610    SUMA_RETURN(NOPE);
00611 }

SUMA_DRAWN_ROI* SUMA_FetchROI_InCreation SUMA_SurfaceObject   SO,
SUMA_DO   dov,
int    N_dov
 

Returns an ROI that is related to SO and is in InCreation (being actively drawn) DrawStatus There should only be one ROI in creation at any one time for a group of related surfaces.

ROI = SUMA_ ROI_InCreation (SO, dov, N_dov);

Parameters:
SO  (SUMA_SurfaceObject *) pointer to surface object
dov  (SUMA_DO *) pointer to vector of DOs (typically SUMAg_DOv)
N_dov  (int) number of elements in dov
Returns:
ROI (SUMA_DRAWN_ROI *) pointer to ROI object, NULL if no such object is found.

Definition at line 1311 of file SUMA_DOmanip.c.

References SUMA_DRAWN_ROI::DrawStatus, i, ROIdO_type, SUMA_ENTRY, SUMA_isdROIrelated(), SUMA_RETURN, and SUMA_ROI_InCreation.

Referenced by SUMA_Engine(), and SUMA_ProcessBrushStroke().

01312 {
01313    int i;
01314    SUMA_DRAWN_ROI *ROI = NULL;
01315    static char FuncName[]={"SUMA_FetchROI_InCreation"};
01316    
01317    SUMA_ENTRY;
01318    
01319    for (i=0; i < N_dov; ++i) {
01320       if (dov[i].ObjectType == ROIdO_type) {
01321          ROI = (SUMA_DRAWN_ROI *)dov[i].OP;
01322          if (ROI->DrawStatus == SUMA_ROI_InCreation) {
01323             if (SUMA_isdROIrelated (ROI, SO)) {
01324                /* found an ROI, should be the only one, return */
01325                SUMA_RETURN (ROI);
01326             }
01327          }
01328       }
01329    }
01330    SUMA_RETURN (NULL);
01331 }

SUMA_SurfaceObject* SUMA_find_named_SOp_inDOv char *    coordname,
SUMA_DO   dov,
int    N_dov
 

SO = SUMA_find_named_SOp_inDOv(char *idcode, SUMA_DO *dov, int N_dov) searches all SO_type DO objects for idcode

Parameters:
coordname  (char *) filename of SO (without path) that you are searching for. If surface is specified by 2 files, then use the coord file name.
dov  (SUMA_DO*) pointer to vector of Displayable Objects, typically SUMAg_DOv
N_dov  (int) number of DOs in dov
Returns:
SO (SUMA_SurfaceObject *) pointer of SO with matching idcode NULL if not found
See also:
SUMA_findSO_inDOv , SUMA_findSOp_inDOv

Definition at line 815 of file SUMA_DOmanip.c.

References SUMA_FileName::FileName, SUMA_SurfaceObject::FileType, i, SUMA_SurfaceObject::Name, SUMA_SurfaceObject::Name_coord, SO_type, SUMA_ENTRY, SUMA_free, SUMA_FREE_SURFER, SUMA_FREE_SURFER_PATCH, SUMA_INVENTOR_GENERIC, SUMA_OPENDX_MESH, SUMA_PLY, SUMA_RETURN, SUMA_SL_Err, SUMA_SS2S, SUMA_StringAppend_va(), SUMA_SUREFIT, and SUMA_VEC.

00816 {
00817    static char FuncName[]={"SUMA_find_named_SOp_inDOv"};
00818    SUMA_SurfaceObject *SO = NULL, *SOf = NULL;
00819    SUMA_STRING *SS=NULL;
00820    char *stmp=NULL;
00821    int i;
00822    
00823    SUMA_ENTRY;
00824    
00825    i=0;
00826    SOf = NULL;
00827    while (i<N_dov) {
00828       if (dov[i].ObjectType == SO_type) {
00829          SO = (SUMA_SurfaceObject *)dov[i].OP;
00830          switch(SO->FileType) {
00831             case SUMA_SUREFIT:
00832             case SUMA_VEC:
00833                if (strstr(SO->Name_coord.FileName, coordname)) {
00834                   if (SOf) {
00835                      SS = SUMA_StringAppend_va(NULL, NULL);
00836                      SS = SUMA_StringAppend_va(SS, 
00837                                     "Error %s:\n"
00838                                     "Surface name %s\n"
00839                                     "is not a unique identifier.\n"
00840                                     "Found %s and %s so far.\n"
00841                                     "Be more specific.\n", FuncName, 
00842                                     coordname, SOf->Name_coord.FileName,
00843                                     SO->Name_coord.FileName);
00844                      SUMA_SS2S(SS, stmp);
00845                      SUMA_SL_Err(stmp); if (stmp) SUMA_free(stmp); stmp = NULL;
00846                      SUMA_RETURN(NULL);
00847                   }
00848                   SOf = SO;
00849                }
00850                break;
00851             case SUMA_FREE_SURFER:
00852             case SUMA_FREE_SURFER_PATCH:
00853             case SUMA_INVENTOR_GENERIC:
00854             case SUMA_OPENDX_MESH:
00855             case SUMA_PLY: 
00856                if (strstr(SO->Name.FileName, coordname)) {
00857                   if (SOf) {
00858                      SS = SUMA_StringAppend_va(NULL, NULL);
00859                      SS = SUMA_StringAppend_va(SS, 
00860                                     "Error %s:\n"
00861                                     "Surface name %s\n"
00862                                     "is not a unique identifier.\n"
00863                                     "Found %s and %s so far.\n"
00864                                     "Be more specific.\n", FuncName, 
00865                                     coordname, SOf->Name_coord.FileName,
00866                                     SO->Name_coord.FileName);
00867                      SUMA_SS2S(SS, stmp);
00868                      SUMA_SL_Err(stmp); if (stmp) SUMA_free(stmp); stmp = NULL;
00869                      SUMA_RETURN(NULL);
00870                   }
00871                   SOf = SO;
00872                }
00873                break;
00874             default: 
00875                SUMA_SL_Err("Type not supported.");
00876                SUMA_RETURN(NULL);
00877          }
00878       }
00879       ++i;
00880    }
00881    
00882    SUMA_RETURN(SOf);
00883 }

int SUMA_findSO_inDOv char *    idcode,
SUMA_DO   dov,
int    N_dov
 

ans = SUMA_findSO_inDOv(idcode, dov, N_dov); searches all SO_type DO objects for idcode

Parameters:
idcode  (char *) idcode of SO you are searching for
dov  (SUMA_DO*) pointer to vector of Displayable Objects, typically SUMAg_DOv
N_dov  (int) number of DOs in dov
Returns:
ans (int) index into dov of object with matching idcode -1 if not found
See also:
SUMA_findSOp_inDOv

Definition at line 747 of file SUMA_DOmanip.c.

References i, SUMA_SurfaceObject::idcode_str, LocalHead, SO_type, SUMA_Boolean, SUMA_ENTRY, and SUMA_RETURN.

Referenced by SUMA_Engine(), SUMA_input(), SUMA_JumpIndex(), SUMA_LoadSpec_eng(), SUMA_MarkLineSurfaceIntersect(), SUMA_MixColors(), SUMA_NewSurfaceGeometry(), SUMA_NextSO(), SUMA_process_NIML_data(), SUMA_RedisplayAllShowing(), SUMA_SetLocalRemixFlag(), SUMA_SetRemixFlag(), SUMA_SwitchState(), SUMA_XYZ_XYZmap(), and SUMA_XYZmap_XYZ().

00748 {
00749    static char FuncName[]={"SUMA_findSO_inDOv"};
00750    SUMA_SurfaceObject *SO;
00751    int i;
00752    SUMA_Boolean LocalHead = NOPE;
00753       
00754    SUMA_ENTRY;
00755 
00756    for (i=0; i<N_dov; ++i) {
00757       if (dov[i].ObjectType == SO_type) {
00758          SO = (SUMA_SurfaceObject *)dov[i].OP;
00759          if (LocalHead) fprintf (SUMA_STDERR, "%s: Comparing \n\t:%s:to\n\t:%s:\n", \
00760                   FuncName, idcode, SO->idcode_str);
00761          if (strcmp(idcode, SO->idcode_str)== 0) {
00762             SUMA_RETURN (i);
00763          }
00764       }
00765    }
00766    SUMA_RETURN(-1);
00767 }

SUMA_SurfaceObject* SUMA_findSOp_inDOv char *    idcode,
SUMA_DO   dov,
int    N_dov
 

SO = SUMA_findSOp_inDOv(char *idcode, SUMA_DO *dov, int N_dov) searches all SO_type DO objects for idcode

Parameters:
idcode  (char *) idcode of SO you are searching for
dov  (SUMA_DO*) pointer to vector of Displayable Objects, typically SUMAg_DOv
N_dov  (int) number of DOs in dov
Returns:
SO (SUMA_SurfaceObject *) pointer of SO with matching idcode NULL if not found
See also:
SUMA_findSO_inDOv

Definition at line 781 of file SUMA_DOmanip.c.

References i, SUMA_SurfaceObject::idcode_str, SO_type, SUMA_ENTRY, and SUMA_RETURN.

Referenced by SUMA_1DROI_to_DrawnROI(), SUMA_AssembleAllROIList(), SUMA_cb_createSurfaceCont(), SUMA_cb_DrawROI_Delete(), SUMA_cb_DrawROI_Finish(), SUMA_cb_DrawROI_Join(), SUMA_cb_DrawROI_Redo(), SUMA_cb_DrawROI_Undo(), SUMA_DrawROI_NewValue(), SUMA_FinishedROI(), SUMA_InitializeDrawROIWindow(), SUMA_isdROIrelated(), SUMA_isROIrelated(), SUMA_OpenDrawnROI(), SUMA_process_NIML_data(), and SUMA_SaveDrawnROI().

00782 {
00783    static char FuncName[]={"SUMA_findSOp_inDOv"};
00784    SUMA_SurfaceObject *SO;
00785    int i;
00786    
00787    SUMA_ENTRY;
00788 
00789    for (i=0; i<N_dov; ++i) {
00790       if (dov[i].ObjectType == SO_type) {
00791          SO = (SUMA_SurfaceObject *)dov[i].OP;
00792          if (strcmp(idcode, SO->idcode_str)== 0) {
00793             SUMA_RETURN (SO);
00794          }
00795       }
00796    }
00797    SUMA_RETURN(NULL);
00798 }

SUMA_Boolean SUMA_Free_Displayable_Object SUMA_DO   dov
 

Free a Displayable Object data structure

Definition at line 231 of file SUMA_DOmanip.c.

References AO_type, GO_type, LS_type, SUMA_DO::ObjectType, SUMA_DO::OP, ROIdO_type, ROIO_type, SO_type, SUMA_Boolean, SUMA_ENTRY, SUMA_Free_Axis(), SUMA_free_SegmentDO(), SUMA_Free_Surface_Object(), SUMA_freeDrawnROI(), SUMA_freeROI(), and SUMA_RETURN.

Referenced by SUMA_Free_Displayable_Object_Vect(), and SUMA_RemoveDO().

00232 {
00233    static char FuncName[]={"SUMA_Free_Displayable_Object"};
00234 
00235    SUMA_ENTRY;
00236 
00237    switch (dov->ObjectType) {
00238       case SO_type:
00239          if (!SUMA_Free_Surface_Object ((SUMA_SurfaceObject *)dov->OP)) {
00240             fprintf(SUMA_STDERR,"Error SUMA_Free_Displayable_Object, could not free surface\n");
00241          }
00242          break;
00243       case ROIdO_type:
00244          if (!SUMA_freeDrawnROI ((SUMA_DRAWN_ROI *)dov->OP)) {
00245             fprintf(SUMA_STDERR,"Error SUMA_freeDrawnROI, could not free  ROI.\n");
00246          }
00247          break;
00248       case ROIO_type:
00249          if (!SUMA_freeROI ((SUMA_ROI *)dov->OP)) {
00250             fprintf(SUMA_STDERR,"Error SUMA_freeROI, could not free  ROI.\n");
00251          }
00252          break;
00253       case LS_type:
00254          SUMA_free_SegmentDO ((SUMA_SegmentDO *)dov->OP);
00255          break;
00256       case AO_type:
00257          SUMA_Free_Axis((SUMA_Axis*)dov->OP);
00258          break;
00259       case GO_type:
00260          fprintf(SUMA_STDERR,"Error SUMA_Free_Displayable_Object, Not trained to free GO objects\n");
00261          break;
00262          
00263    }   
00264 
00265    SUMA_RETURN(YUP);
00266 }

SUMA_Boolean SUMA_Free_Displayable_Object_Vect SUMA_DO   dov,
int    N
 

Definition at line 268 of file SUMA_DOmanip.c.

References i, SUMA_Boolean, SUMA_ENTRY, SUMA_free, SUMA_Free_Displayable_Object(), and SUMA_RETURN.

Referenced by final_clean_up(), final_cleanup(), and main().

00269 {
00270    static char FuncName[] = {"SUMA_Free_Displayable_Object_Vect"};
00271    int i;
00272    SUMA_Boolean Ret = YUP;
00273    
00274    SUMA_ENTRY;
00275 
00276    for (i=0; i < N; ++i) {
00277       if (&dov[i] != NULL) {
00278          Ret = Ret * SUMA_Free_Displayable_Object (&dov[i]);
00279       }
00280    }
00281 
00282    if (dov) SUMA_free(dov);
00283    SUMA_RETURN(Ret);
00284 
00285 }   

SUMA_Boolean SUMA_Free_MemberFaceSets SUMA_MEMBER_FACE_SETS   MF
 

Free a SUMA_MEMBER_FACE_SETS structure

Definition at line 386 of file SUMA_SurfNorm.c.

References SUMA_MEMBER_FACE_SETS::idcode_str, LocalHead, SUMA_MEMBER_FACE_SETS::N_links, SUMA_MEMBER_FACE_SETS::N_Memb, SUMA_MEMBER_FACE_SETS::Nnode, SUMA_MEMBER_FACE_SETS::NodeMemberOfFaceSet, SUMA_Boolean, SUMA_ENTRY, SUMA_free, SUMA_free2D(), SUMA_LH, SUMA_RETURN, and SUMA_UnlinkFromPointer().

Referenced by SUMA_Free_Surface_Object().

00387 {
00388    static char FuncName[]={"SUMA_Free_MemberFaceSets"};
00389    SUMA_Boolean LocalHead = NOPE;
00390    
00391    SUMA_ENTRY;
00392    if (!MF) { SUMA_RETURN (YUP); }
00393    if (MF->N_links) {
00394       SUMA_LH("Just a link release");
00395       MF = (SUMA_MEMBER_FACE_SETS *)SUMA_UnlinkFromPointer((void *)MF);
00396       SUMA_RETURN (YUP);
00397    }
00398    
00399    SUMA_LH("No more links, here we go");
00400    if (MF->idcode_str) SUMA_free(MF->idcode_str);
00401    if (MF->NodeMemberOfFaceSet) SUMA_free2D((char **)MF->NodeMemberOfFaceSet, MF->Nnode);
00402    if (MF->N_Memb) SUMA_free(MF->N_Memb);
00403    if (MF) SUMA_free(MF);
00404    SUMA_RETURN (YUP);
00405 }   

SUMA_Boolean SUMA_Free_VolPar SUMA_VOLPAR   VP
 

< Handedness of axis 1 RH, -1 LH

Definition at line 376 of file SUMA_VolData.c.

References SUMA_VOLPAR::dirname, SUMA_VOLPAR::filecode, SUMA_VOLPAR::idcode_str, SUMA_VOLPAR::prefix, SUMA_VOLPAR::ROTATE_CENTER_BASE, SUMA_VOLPAR::ROTATE_CENTER_OLD, SUMA_VOLPAR::ROTATE_MATVEC, SUMA_Boolean, SUMA_ENTRY, SUMA_free, SUMA_RETURN, SUMA_VOLPAR::TAGALIGN_MATVEC, SUMA_VOLPAR::vol_idcode_date, SUMA_VOLPAR::vol_idcode_str, SUMA_VOLPAR::VOLREG_CENTER_BASE, SUMA_VOLPAR::VOLREG_CENTER_OLD, and SUMA_VOLPAR::VOLREG_MATVEC.

Referenced by main(), SUMA_Free_Surface_Object(), SUMA_process_NIML_data(), and SUMA_VolParFromDset().

00377 {
00378    static char FuncName[]={"SUMA_Free_VolPar"};
00379    
00380    SUMA_ENTRY;
00381 
00382    if (VP->prefix != NULL) SUMA_free(VP->prefix);
00383    if (VP->idcode_str != NULL) SUMA_free(VP->idcode_str);
00384    if (VP->filecode != NULL) SUMA_free(VP->filecode);
00385    if (VP->dirname != NULL) SUMA_free(VP->dirname);
00386    if (VP->vol_idcode_str != NULL) SUMA_free(VP->vol_idcode_str);
00387    if (VP->vol_idcode_date != NULL) SUMA_free(VP->vol_idcode_date);
00388    if (VP->VOLREG_CENTER_OLD != NULL) SUMA_free(VP->VOLREG_CENTER_OLD);
00389    if (VP->VOLREG_CENTER_BASE != NULL) SUMA_free(VP->VOLREG_CENTER_BASE);
00390    if (VP->VOLREG_MATVEC != NULL) SUMA_free(VP->VOLREG_MATVEC);
00391    if (VP->TAGALIGN_MATVEC != NULL) SUMA_free(VP->TAGALIGN_MATVEC);
00392    if (VP->ROTATE_MATVEC != NULL) SUMA_free(VP->ROTATE_MATVEC);
00393    if (VP->ROTATE_CENTER_OLD != NULL) SUMA_free(VP->ROTATE_CENTER_OLD);
00394    if (VP->ROTATE_CENTER_BASE != NULL) SUMA_free(VP->ROTATE_CENTER_BASE);
00395    if (VP != NULL) SUMA_free(VP);
00396    SUMA_RETURN (YUP);
00397 }

SUMA_ASSEMBLE_LIST_STRUCT* SUMA_FreeAssembleListStruct SUMA_ASSEMBLE_LIST_STRUCT   str
 

frees SUMA_ASSEMBLE_LIST_STRUCT *

Parameters:
SUMA_ASSEMBLE_LIST_STRUCT  *str
Returns:
NULL always
-This function frees each string in clist. BUT NOT pointers in oplist (for obvious reasons)

Definition at line 1277 of file SUMA_DOmanip.c.

References SUMA_ASSEMBLE_LIST_STRUCT::clist, i, SUMA_ASSEMBLE_LIST_STRUCT::N_clist, SUMA_ASSEMBLE_LIST_STRUCT::oplist, SUMA_ENTRY, SUMA_free, and SUMA_RETURN.

Referenced by SUMA_cb_DrawROI_SwitchROI(), SUMA_cb_ViewerCont_SwitchGroup(), SUMA_CmapSelectList(), SUMA_DeleteROI(), SUMA_FreeScrolledList(), and SUMA_RefreshDsetList().

01278 {
01279    static char FuncName[]={"SUMA_FreeAssembleListStruct"};
01280    int i;
01281    
01282    SUMA_ENTRY;
01283    
01284    if (!str) SUMA_RETURN(NULL);
01285    
01286    if (str->clist) {
01287       for (i=0; i < str->N_clist; ++i)
01288          if (str->clist[i]) SUMA_free(str->clist[i]);
01289       SUMA_free(str->clist);
01290    }
01291    if (str->oplist) SUMA_free(str->oplist);
01292    SUMA_free(str);
01293    
01294    SUMA_RETURN(NULL);
01295 }

int* SUMA_GetDO_Type SUMA_DO   dov,
int    N_dov,
SUMA_DO_Types    DO_Type,
int *    N
 

returns a vector of indices into dov for DO that meet DO_Type You should free the returned pointer once you're done with it N contains the number of elements found

Definition at line 559 of file SUMA_DOmanip.c.

References i, LocalHead, SUMA_Boolean, SUMA_calloc, SUMA_DO_Types, SUMA_ENTRY, SUMA_MAX_DISPLAYABLE_OBJECTS, and SUMA_RETURN.

Referenced by SUMA_input().

00560 {
00561    static char FuncName[]={"SUMA_GetDO_Type"};
00562    int *do_id, i;
00563    SUMA_Boolean LocalHead = NOPE;
00564       
00565    SUMA_ENTRY;
00566 
00567    *N = 0;
00568 
00569    do_id = (int *)SUMA_calloc (SUMA_MAX_DISPLAYABLE_OBJECTS, sizeof(int));
00570 
00571    if (do_id == NULL) {
00572       fprintf(stderr,"Error SUMA_GetDO_Type: Could not allocate for do_id\n");
00573       SUMA_RETURN(NULL);
00574    }
00575       i = 0;
00576       while (i < N_dov) {
00577          if (dov[i].ObjectType == DO_Type) {
00578             do_id[*N] = i;
00579             *N = *N + 1;
00580          }
00581       ++i;
00582       }
00583       SUMA_RETURN(do_id);
00584 }

SUMA_Boolean SUMA_isdROIrelated SUMA_DRAWN_ROI   ROI,
SUMA_SurfaceObject   SO
 

Returns YUP if the surface: dROI->Parent_idcode_str is related to SO->idcode_str or SO->LocalDomainParentID. NOPE otherwise.

ans = SUMA_isdROIrelated (dROI, SO);

Parameters:
ROI  (SUMA_DRAWN_ROI *) pointer to drawn ROI
SO  (SUMA_SurfaceObject *) pointer to surface object
Returns:
ans (SUMA_Boolean) YUP/NOPE

Definition at line 1344 of file SUMA_DOmanip.c.

References SUMA_SurfaceObject::idcode_str, SUMA_SurfaceObject::LocalDomainParentID, LocalHead, SUMA_DRAWN_ROI::Parent_idcode_str, SUMA_Boolean, SUMA_ENTRY, SUMA_findSOp_inDOv(), SUMA_isRelated(), SUMA_RETURN, SUMA_SL_Err, and SUMAg_N_DOv.

Referenced by SUMA_Build_Mask_AllROI(), SUMA_Draw_SO_ROI(), SUMA_FetchROI_InCreation(), SUMA_Find_ROIrelatedtoSO(), SUMA_FlushPlaneNotInUse(), SUMA_Paint_SO_ROIplanes(), and SUMA_ProcessBrushStroke().

01345 {
01346    static char FuncName[]={"SUMA_isdROIrelated"};
01347    SUMA_SurfaceObject *SO_ROI = NULL;
01348    SUMA_Boolean LocalHead = NOPE;
01349    
01350    SUMA_ENTRY;
01351    
01352    if (LocalHead) {
01353       fprintf (SUMA_STDERR, "%s: %s SO->LocalDomainParentID\n", FuncName, SO->LocalDomainParentID);
01354       fprintf (SUMA_STDERR, "%s: %s ROI->Parent_idcode_str\n", FuncName, ROI->Parent_idcode_str);
01355       fprintf (SUMA_STDERR, "%s: %s SO->idcode_str\n", FuncName, SO->idcode_str);
01356    }
01357    
01358    /* find the pointer to the surface having for an idcode_str: ROI->Parent_idcode_str */
01359    SO_ROI = SUMA_findSOp_inDOv(ROI->Parent_idcode_str, SUMAg_DOv, SUMAg_N_DOv);
01360    
01361    if (!SO_ROI) {
01362       SUMA_SL_Err("Could not find surface of ROI->Parent_idcode_str");
01363       SUMA_RETURN (NOPE);
01364    }
01365    
01366    if (SUMA_isRelated (SO, SO_ROI, 1)) { /* relationship of the 1st order only */ 
01367       SUMA_RETURN (YUP);
01368    }
01369 
01370    SUMA_RETURN (NOPE);
01371 }

SUMA_Boolean SUMA_isINHmappable SUMA_SurfaceObject   SO
 

Left here temporarily for backward compatibility

use the more appropriately named SUMA_isLocalDomainParent

Definition at line 911 of file SUMA_DOmanip.c.

References SUMA_Boolean, SUMA_ENTRY, SUMA_isLocalDomainParent(), and SUMA_RETURN.

00912 {
00913    static char FuncName[]={"SUMA_isINHmappable"};
00914    
00915    SUMA_ENTRY;
00916    
00917    SUMA_RETURN(SUMA_isLocalDomainParent(SO));
00918 }

SUMA_Boolean SUMA_isInodeLink SUMA_INODE   IN,
const char *    HolderIDcode
 

This function determines if an Inode in a SO is a link or not. an Inode is a link if IN->ParentIDcode and HolderIDcode are different. The function is nothing more than a strcmp.

SUMA_Boolean SUMA_isInodeLink (SUMA_INODE *IN, const char *HolderIDcode)

returns NOPE if IN == NULL or IN->ParentIDcode != HolderIDcode

Definition at line 65 of file SUMA_DOmanip.c.

References SUMA_INODE::ParentIDcode, SUMA_Boolean, SUMA_ENTRY, and SUMA_RETURN.

Referenced by SUMA_BreakInodeLink().

00066 {
00067    static char FuncName[] = {"SUMA_isInodeLink"};
00068    
00069    SUMA_ENTRY;
00070 
00071    if (!IN) {
00072       fprintf (SUMA_STDERR, "Warning %s: IN is null.\n", FuncName); 
00073       SUMA_RETURN(NOPE);
00074    } 
00075    if (!strcmp(IN->ParentIDcode, HolderIDcode)) SUMA_RETURN(YUP);
00076       
00077    SUMA_RETURN(NOPE);
00078 }

SUMA_Boolean SUMA_isLocalDomainParent SUMA_SurfaceObject   SO
 

determines if a Surface Object is a local domain parent (ie LocalDomainParentID == idcode_str) (used to be called inherently mappable) ans = SUMA_isLocalDomainParent (SUMA_SurfaceObject *SO)

Parameters:
SO  (SUMA_SurfaceObject *) \ret YUP/NOPE
-- Used to be called SUMA_isINHmappable

Definition at line 929 of file SUMA_DOmanip.c.

References SUMA_SurfaceObject::idcode_str, SUMA_SurfaceObject::LocalDomainParentID, SUMA_Boolean, SUMA_ENTRY, and SUMA_RETURN.

Referenced by SUMA_FormSOListToSendToAFNI(), SUMA_input(), SUMA_iRGB_to_OverlayPointer(), SUMA_isINHmappable(), SUMA_SurfaceObject_Info(), SUMA_XYZ_XYZmap(), and SUMA_XYZmap_XYZ().

00930 {
00931    static char FuncName[]={"SUMA_isLocalDomainParent"};
00932    
00933    SUMA_ENTRY;
00934 
00935    if (SO->LocalDomainParentID == NULL) {
00936       SUMA_RETURN (NOPE);
00937    }
00938    if (strcmp(SO->LocalDomainParentID, SO->idcode_str) == 0) {
00939       /* SO is the local domain parent */
00940       SUMA_RETURN (YUP);
00941    } 
00942    SUMA_RETURN (NOPE);
00943 }

SUMA_Boolean SUMA_ismappable SUMA_SurfaceObject   SO
 

determines if a Surface Object is mappable (ie LocalDomainParentID != NULL) ans = SUMA_ismappable (SUMA_SurfaceObject *SO)

Parameters:
SO  (SUMA_SurfaceObject *) \ret YUP/NOPE

Definition at line 891 of file SUMA_DOmanip.c.

References SUMA_SurfaceObject::LocalDomainParentID, SUMA_Boolean, SUMA_ENTRY, and SUMA_RETURN.

Referenced by SUMA_MapRefRelative(), SUMA_SurfaceObject_Info(), SUMA_XYZ_XYZmap(), and SUMA_XYZmap_XYZ().

00892 {
00893    static char FuncName[]={"SUMA_ismappable"};
00894    
00895    SUMA_ENTRY;
00896 
00897    if (SO->LocalDomainParentID != NULL) {
00898       /* SO is mappable */
00899       SUMA_RETURN (YUP);
00900    }
00901     
00902    SUMA_RETURN (NOPE);
00903 
00904 }

SUMA_Boolean SUMA_isRelated SUMA_SurfaceObject   SO1,
SUMA_SurfaceObject   SO2,
int    level
 

ans = SUMA_isRelated (SUMA_SurfaceObject *SO1, SUMA_SurfaceObject *SO2, int level);

returns YUP if SO1 and SO2 are related at level 1 or 2 level 1 means nuclear family (share the same parent) level 2 means extended family (share a grandparent, ultimately this could be the grand icosahedron duc Surfaces must be the of the same hemi side since both hemispheres can have the same grandparent, use level 3 if you want to go across hemis.) level 3 is like level 2 with no care for what side of the brain we're working with For more definitions on relationships:

See also:
SUMA_WhatAreYouToMe

Definition at line 959 of file SUMA_DOmanip.c.

References LocalHead, SUMA_SurfaceObject::Side, SUMA_Boolean, SUMA_DOMAIN_KINSHIPS, SUMA_DOMAINS_NOT_RELATED, SUMA_ENTRY, SUMA_NUCELAR_FAMILY, SUMA_RETURN, SUMA_SL_Err, and SUMA_WhatAreYouToMe().

Referenced by SUMA_AddNewPlane(), SUMA_Engine(), SUMA_GetOverlaysFromParent(), SUMA_isdROIrelated(), SUMA_isROIrelated(), SUMA_MapRefRelative(), SUMA_SetLocalRemixFlag(), SUMA_SetRemixFlag(), and SUMA_UpdateColPlaneShellAsNeeded().

00960 {
00961    static char FuncName[]={"SUMA_isRelated"};
00962    SUMA_DOMAIN_KINSHIPS kin;
00963    SUMA_Boolean LocalHead = NOPE;
00964    
00965    SUMA_ENTRY;
00966    
00967    kin =  SUMA_WhatAreYouToMe (SO1, SO2);
00968    switch (level) {
00969       case 3: /* anything goes */
00970          if (  (kin > SUMA_DOMAINS_NOT_RELATED) ) SUMA_RETURN(YUP);
00971          break;
00972       case 2: /* share an ancestor, but same side */
00973          if (  (kin > SUMA_DOMAINS_NOT_RELATED) &&
00974                (SO1->Side == SO2->Side) ) SUMA_RETURN(YUP);
00975          break;
00976       case 1: /* nuclear family only */
00977          if (  (kin > SUMA_DOMAINS_NOT_RELATED) && 
00978                (kin < SUMA_NUCELAR_FAMILY ) &&
00979                (SO1->Side == SO2->Side) ) SUMA_RETURN(YUP); /* last condition is not really necessary but it don't hoyt...*/
00980          break;
00981       default:
00982          SUMA_SL_Err("Bad value for level.");   
00983          break;
00984    }
00985    SUMA_RETURN(NOPE);
00986 }

SUMA_Boolean SUMA_isROIrelated SUMA_ROI   ROI,
SUMA_SurfaceObject   SO
 

Returns YUP if if the surface: ROI->Parent_idcode_str is related to SO->idcode_str or SO->LocalDomainParentID. NOPE otherwise.

ans = SUMA_isROIrelated (ROI, SO);

Parameters:
ROI  (SUMA_ROI *) pointer to ROI
SO  (SUMA_SurfaceObject *) pointer to surface object
Returns:
ans (SUMA_Boolean) YUP/NOPE

Definition at line 1384 of file SUMA_DOmanip.c.

References SUMA_ROI::Parent_idcode_str, SUMA_Boolean, SUMA_ENTRY, SUMA_findSOp_inDOv(), SUMA_isRelated(), SUMA_RETURN, SUMA_SL_Err, and SUMAg_N_DOv.

Referenced by SUMA_Build_Mask_AllROI(), and SUMA_Draw_SO_ROI().

01385 {
01386    static char FuncName[]={"SUMA_isROIrelated"};
01387    SUMA_SurfaceObject *SO_ROI = NULL;
01388    
01389    SUMA_ENTRY;
01390    
01391    /* find the pointer to the surface having for an idcode_str: ROI->Parent_idcode_str */
01392    SO_ROI = SUMA_findSOp_inDOv(ROI->Parent_idcode_str, SUMAg_DOv, SUMAg_N_DOv);
01393    
01394    if (!SO_ROI) {
01395       SUMA_SL_Err("Could not find surface of ROI->Parent_idcode_str");
01396       SUMA_RETURN (NOPE);
01397    }
01398    
01399    if (SUMA_isRelated (SO, SO_ROI, 1)) { /* relationship of the 1st order only */
01400       SUMA_RETURN (YUP);
01401    }
01402 
01403    SUMA_RETURN (NOPE);
01404 }

byte* SUMA_isSkin THD_3dim_dataset   dset,
double *    dvec,
double    thresh,
int *    N_skin
 

A function to find the skin of a volume.

Parameters:
dset  (THD_3dim_dataset *) an AFNI volume
dvec  (double *) (nx * ny * nz) data vector
thresh  (double) consider only values in dvec > thresh
N_skin  (int *) number of voxels that are skin
Returns:
skin (byte *) (nx * ny * nz) vector containing 1 for skin voxels, 0 elsewhere.

Definition at line 258 of file SUMA_VolData.c.

References DSET_NX, DSET_NY, DSET_NZ, nz, SUMA_3D_2_1D_index, SUMA_calloc, SUMA_ENTRY, SUMA_RETURN, SUMA_SL_Crit, and SUMA_SL_Err.

Referenced by SUMA_LoadPrepInVol().

00259 {
00260    static char FuncName[]={"SUMA_isSkin"};
00261    byte *isskin=NULL;
00262    int x, y, z, nx, ny, nz, i1D,  nxy;
00263   
00264    SUMA_ENTRY;
00265    
00266    if (!dset || !dvec) {
00267       SUMA_SL_Err("NULL input dset or dvec");
00268       SUMA_RETURN(isskin);
00269    }
00270    
00271    nx = DSET_NX(dset);
00272    ny = DSET_NY(dset);
00273    nz = DSET_NZ(dset);
00274    nxy = nx * ny;
00275    
00276    isskin = (byte *) SUMA_calloc(nxy * nz, sizeof(byte));
00277    if (!isskin) {
00278       SUMA_SL_Crit("Failed to allocate");
00279       SUMA_RETURN(NULL);
00280    }
00281    
00282    *N_skin = 0;
00283    for (z=0; z<nz; ++z) {
00284       for (y=0; y<ny; ++y) {
00285          x = 0;
00286          do { /* the upstroke */
00287             i1D = SUMA_3D_2_1D_index(x, y, z, nx, nxy);
00288             if (dvec[i1D] > thresh) { isskin[i1D] = 1; ++ *N_skin; }
00289             ++x; 
00290          } while (x < nx && !isskin[i1D]);
00291          x = nx - 1;
00292          do { /* the downstroke */
00293             i1D = SUMA_3D_2_1D_index(x, y, z, nx, nxy);
00294             if (dvec[i1D] > thresh) { isskin[i1D] = 1; ++ *N_skin; }
00295             --x; 
00296          } while (x >=0 && !isskin[i1D]);
00297       } /* y */
00298    } /* z */
00299    
00300    for (z=0; z<nz; ++z) {
00301       for (x=0; x<nx; ++x) {
00302          y = 0;
00303          do { /* the upstroke */
00304             i1D = SUMA_3D_2_1D_index(x, y, z, nx, nxy);
00305             if (dvec[i1D] > thresh) { isskin[i1D] = 1; ++ *N_skin; }
00306             ++y; 
00307          } while (y < ny && !isskin[i1D]);
00308          y = ny - 1;
00309          do { /* the downstroke */
00310             i1D = SUMA_3D_2_1D_index(x, y, z, nx, nxy);
00311             if (dvec[i1D] > thresh) { isskin[i1D] = 1; ++ *N_skin; }
00312             --y; 
00313          } while (y >=0 && !isskin[i1D]);
00314       } /* x */
00315    } /* z */
00316    
00317    for (x=0; x<nx; ++x) {
00318       for (y=0; y<ny; ++y) {
00319          z = 0;
00320          do { /* the upstroke */
00321             i1D = SUMA_3D_2_1D_index(x, y, z, nx, nxy);
00322             if (dvec[i1D] > thresh) { isskin[i1D] = 1; ++ *N_skin; }
00323             ++z; 
00324          } while (z < nz && !isskin[i1D]);
00325          z = nz - 1;
00326          do { /* the downstroke */
00327             i1D = SUMA_3D_2_1D_index(x, y, z, nx, nxy);
00328             if (dvec[i1D] > thresh) { isskin[i1D] = 1; ++ *N_skin; }
00329             --z; 
00330          } while (z >=0 && !isskin[i1D]);
00331       } /* y */
00332    } /* x */
00333       
00334    SUMA_RETURN(isskin);
00335 }

SUMA_Boolean SUMA_isSO SUMA_DO    DO
 

SUMA_Boolean SUMA_isSO (SUMA_DO DO) returns YUP if DO is of SO_type ans = SUMA_isSO (DO) ;.

See also:
SUMA_isSO_G (SUMA_DO DO, char *Group)

Definition at line 1108 of file SUMA_DOmanip.c.

References SUMA_DO::ObjectType, SO_type, SUMA_Boolean, SUMA_ENTRY, and SUMA_RETURN.

Referenced by all_mappable_surfs(), get_mappable_surfs(), SUMA_AddNewPlane(), SUMA_CanTalkToAfni(), SUMA_Engine(), SUMA_FormSOListToSendToAFNI(), SUMA_input(), SUMA_isSO_G(), SUMA_NextSO(), SUMA_RedisplayAllShowing(), SUMA_RegisterDO(), SUMA_RegisterSpecSO(), SUMA_RemoveCoordBias(), SUMA_SetCoordBias(), SUMA_SetRemixFlag(), SUMA_SetupSVforDOs(), SUMA_TransferCoordBias(), SUMA_UnRegisterDO(), and SUMA_UpdateColPlaneShellAsNeeded().

01109 {
01110    static char FuncName[]={"SUMA_isSO"};
01111    
01112    SUMA_ENTRY;
01113 
01114    if (DO.ObjectType == SO_type) {
01115       SUMA_RETURN (YUP);
01116    }
01117    SUMA_RETURN (NOPE);
01118 }

SUMA_Boolean SUMA_isSO_G SUMA_DO    DO,
char *    Group
 

SUMA_Boolean SUMA_isSO_G (SUMA_DO DO, char *Group) returns YUP if DO is a surface object and is a part of the group Group.

See also:
SUMA_isSO

Definition at line 1081 of file SUMA_DOmanip.c.

References SUMA_SurfaceObject::Group, SUMA_DO::OP, SUMA_Boolean, SUMA_ENTRY, SUMA_isSO(), SUMA_RETURN, and SUMA_SL_Err.

Referenced by SUMA_input(), SUMA_isVisibleSO(), SUMA_NewSurfaceGeometry(), SUMA_RegisteredSOs(), SUMA_RegisterSpecSO(), SUMA_SwitchGroups(), and SUMA_VisibleSOs().

01082 {
01083    static char FuncName[]={"SUMA_isSO_G"};
01084    SUMA_SurfaceObject *SO = NULL;
01085    
01086    SUMA_ENTRY;
01087    
01088    if (!Group) {
01089       SUMA_SL_Err("Null Group");
01090       SUMA_RETURN(NOPE);
01091    }
01092    
01093    if (SUMA_isSO(DO)) {
01094       SO = (SUMA_SurfaceObject *)DO.OP;
01095       if (strcmp(SO->Group, Group)) { SUMA_RETURN(NOPE); }
01096       else { SUMA_RETURN(YUP); }
01097    }
01098    
01099    SUMA_RETURN(NOPE);
01100 }

int SUMA_isTypicalSOforVolSurf SUMA_SurfaceObject   SO
 

return +1 if surface is typically the outer layer surface used in Vol2Surf -1 if surface is typically the inner layer surface used in Vol2Surf 0 if no comment

Definition at line 1608 of file SUMA_DOmanip.c.

References SUMA_FileName::FileName, SUMA_SurfaceObject::FileType, SUMA_SurfaceObject::Name, SUMA_ENTRY, SUMA_FREE_SURFER, SUMA_iswordin(), and SUMA_RETURN.

Referenced by SUMA_FormSOListToSendToAFNI().

01609 {
01610    static char FuncName[]={"SUMA_isTypicalSOforVolSurf"};
01611    SUMA_ENTRY;
01612    
01613    switch (SO->FileType) {
01614       case SUMA_FREE_SURFER: 
01615          if (SUMA_iswordin (SO->Name.FileName, "smoothwm")) SUMA_RETURN(-1);
01616          else if (SUMA_iswordin (SO->Name.FileName, "pial")) SUMA_RETURN(1);
01617          else SUMA_RETURN(0);
01618          break;
01619       default:
01620          SUMA_RETURN(0);
01621          break;
01622    }
01623    
01624    SUMA_RETURN(0);
01625 }

int* SUMA_IV_FaceSetsextract char *    IV_filename,
int *    N_FaceSetList
 

File : Taken from IV_FaceSetsextract.c Author : Ziad Saad Date : Tue Nov 17 19:02:16 CST 1998

Purpose :

Extracts the FaceSets coordinates of the nodes in an IV file so that we can manipulate the data to our liking. The program looks for a sequence of characters that seem to indicate the start of the FaceSets list. Once the sequence is found, the series of triplets is read and written out either to a file or to the screen. The sequence of triplets must be terminated by an ending sequence. The starting and ending sequences are hard coded into the program.

The program outputs an error message if : If the starting or ending sequences are not found If the number of points read is not a multiple of three If the first number of the first FaceSets triplet and the last character in the starting sequence are not spearated by a space (or tab). You can fix this by manually adding a space.

Input paramters :

IV_filename (char *) a string specifying the name of the inventor file N_FaceSetList (int *) will give the number of rows in FaceSetList

Usage : FaceSetList = SUMA_IV_FaceSetsextract (char *IV_filename, int *N_FaceSetList)

Returns :

FaceSetList (int *) the facesetlist in the inventor file, an Mx3 integer vector (used to be a matrix before SUMA 1.2)

Support :

Side effects :

Definition at line 59 of file SUMA_IV_FaceSetsextract.c.

References i, SUMA_alloc_problem(), SUMA_calloc, SUMA_error_message(), SUMA_free, SUMA_iswordin(), SUMA_malloc, and SUMA_realloc.

Referenced by SUMA_Load_Surface_Object_eng().

00060 {/* SUMA_IV_FaceSetsextract */
00061         char s[500],serr[500];
00062         char seq_strt[5][30], seq_end[5][30];
00063         int i, f, ex, si, si_exit, evl, se, se_exit;
00064         int ip, NP, cnt, nospacing, MaxAlloc = 100, *linv, *FaceSetList;
00065         div_t cnt4;
00066         FILE*iv_file;
00067    static char FuncName[]={"SUMA_IV_FaceSetsextract"};
00068    
00069 
00070         /* intialize the number of points read to 0 */
00071         *N_FaceSetList = 0;
00072         
00073         linv = (int *)SUMA_malloc (MaxAlloc*sizeof(int));
00074         if (!linv)
00075                 {
00076                                 SUMA_alloc_problem ("Allocation error in IV-FaceSetExtract");
00077                                 return (NULL);
00078                 }
00079                 
00080         /*This is the sequence to trigger reading the numbers*/
00081         sprintf (seq_strt[0],"IndexedFaceSet");
00082         sprintf (seq_strt[1],"{");
00083         sprintf (seq_strt[2],"coordIndex");     
00084         sprintf (seq_strt[3],"[");
00085 
00086         si_exit = 4; /* set equal to the number of strings to be matched */
00087 
00088         /*This is a sequence to mark the end of the number list*/
00089         sprintf (seq_end[0],"]");
00090         sprintf (seq_end[1],"}");  /* you do not need that one, it is possible to have other objects following coordIndex */
00091 
00092         se_exit = 1; /* set equal to the number of strings to be matched */
00093 
00094         iv_file = fopen (IV_filename,"r");
00095         if (iv_file == NULL)
00096                 {
00097                         SUMA_error_message ("SUMA_IV_FaceSetsextract","Could not open input file ",1);
00098                         return (NULL);
00099                 }
00100 
00101 
00102         si = 0;
00103         ex = 1;
00104         cnt = 0;
00105 
00106         nospacing = 0; /* this flag is used to when the last number is read and it has the first seq_end*/
00107                                                         /* character attached to it, ie no space ! in between*/
00108         while (ex != EOF && si < si_exit)
00109         {
00110                 ex = fscanf (iv_file,"%s",s);
00111 
00112                 /*evl = equal_strings (s,seq_strt[si]);*/
00113 
00114                 if (strlen (seq_strt[si]) >= strlen (s)) 
00115                         {
00116                                 evl = SUMA_iswordin (seq_strt[si],s);
00117                                 if (evl == 1)
00118                                         nospacing = 0; /* There is a space between character in starting sequence and first number*/ 
00119                         }
00120                 else
00121                         {
00122                                 evl = SUMA_iswordin (s,seq_strt[si]);
00123                                 if (evl == 1)
00124                                                 nospacing = 1;
00125                         }
00126 
00127                 switch (evl)
00128                         {
00129                                 case 0:
00130                                         si = 0;         /* No match, reset the sequence counter */
00131                                         break;
00132                                 case 1:
00133                                         if (nospacing == 1 && si == si_exit-1) /* it has to be the last character in the sequence*/
00134                                                 {
00135                                                         sprintf (serr,"Must have a space character between first number and last character in start sequence ( %s )",s);
00136                                                         SUMA_error_message ("SUMA_IV_FaceSetsextract",serr,1);
00137                                                         exit (1);
00138 
00139                                                 }
00140                                         si = si +1;     /* increment the start sequence counter */
00141                                         #ifdef DEBUG_3
00142                                                 printf ("found %s  ---  si = %d\n",s,si);
00143                                         #endif
00144                                         break;
00145                                 default:
00146                                         break;
00147                         }
00148         }
00149 
00150         /* Now, read the series of numbers until you encounter the first string of the ending sequence*/
00151         se = 0;
00152         nospacing = 0; 
00153 
00154         while (ex != EOF && se < se_exit )
00155                 {
00156                         ex = fscanf (iv_file,"%s",s);
00157                         /*evl = equal_strings (s,seq_end[se]);*/
00158 
00159                         if (strlen (seq_end[se]) >= strlen (s)) 
00160                                 {
00161                                         evl = SUMA_iswordin (seq_end[se],s);
00162                                         if (evl == 1)
00163                                                 nospacing = 0; /* There is a space between last number and fisrt character in ending sequence */ 
00164                                 }
00165                         else
00166                                 { 
00167                                         evl = SUMA_iswordin (s,seq_end[se]);
00168                                         if (evl == 1)
00169                                                 nospacing = 1;
00170                                 }
00171 
00172                         switch (evl)
00173                                 {
00174                                         case 0:
00175                                                 f = atoi (s);
00176                                                 linv[cnt] = f;
00177                                                         #ifdef DEBUG_3
00178                                                                 printf ("\nNumber (%d): %d is appended to end sequence !\n",cnt,linv[cnt]);     
00179                                                         #endif
00180                 
00181                                                 ++cnt;
00182                                                 if (cnt >= MaxAlloc - 1)
00183                                                         {
00184                                                                 MaxAlloc = MaxAlloc + 100;
00185                                                                 linv = (int *)SUMA_realloc ((void*) linv, MaxAlloc * sizeof(int));
00186                                                                 if (!linv)
00187                                                                         {
00188                                                                                 SUMA_alloc_problem ("Re-Allocation error in IV-FaceSetExtract");
00189                                                                                 return (NULL);
00190                                                                         }
00191                                                                 
00192                                                         }  
00193                                                 se = 0;  /* no match for ending sequence, reset the counter */
00194                                                 break;
00195                                         case 1:         /* found the first character in the end sequence */
00196                                                 if (nospacing == 1 && se == 0) /* it has to be the first character in the sequence*/
00197                                                 {
00198                                                         f = atoi (s);
00199                                                         linv[cnt] = f;
00200                                                         
00201                                                         ++cnt;
00202                                                         #ifdef DEBUG_3
00203                                                                 printf ("\nLast number (%d): %f is appended to end sequence !\n",cnt,f);        
00204                                                         #endif
00205                                                 }
00206                                                 #ifdef DEBUG_3
00207                                                         printf ("\nfound %s  ---  se = %d\n",s,se);
00208                                                 #endif
00209                                                 se = se + 1;
00210                                                 break;
00211                                         default:
00212                                                 break;
00213                                 }
00214 
00215                 }
00216         if (si < si_exit)
00217                 {
00218                         SUMA_error_message ("IV_FaceSetextract","Could not find specified starting sequence",0);
00219                         for (i=0;i<si_exit;++i)
00220                                         printf ("%s \t",seq_strt[i]);
00221                 }
00222         else
00223                 { 
00224                         if (se < se_exit)
00225                                 {
00226                                         SUMA_error_message ("IV_FaceSetextract","Could not find specified ending sequence",0);
00227                                         for (i=0;i<se_exit;++i)
00228                                                         printf ("%s \t",seq_end[i]);
00229                                 }
00230                         else
00231                                 {
00232                                         /* check that the number of points read is multiple of 4 */
00233                                         cnt4 = div (cnt,4);
00234                                         if (cnt4.rem != 0)
00235                                                 {
00236                                                         SUMA_error_message ("IV_FaceSetextract","number of points read is not multiple of 4 !",0);
00237                                                         #ifdef DEBUG_3
00238                                                                 printf ("%f FaceSets sets read !!!\n",(float)cnt/4);
00239                                                         #endif
00240                                                 }
00241                                         
00242                                 }
00243                 }
00244 
00245         *N_FaceSetList = cnt4.quot ;
00246         
00247         /* Now allocate space for SUMA_IV_FaceSetsextract and fill it up */
00248         NP = 3;
00249         FaceSetList = (int *) SUMA_calloc (*N_FaceSetList * NP, sizeof(int));
00250         if (!FaceSetList)
00251                 {
00252                         SUMA_alloc_problem("IV_FaceSetextract : Could not allocate");
00253                         return(NULL);
00254                 }
00255         
00256         i = 0;
00257         ip = 0;
00258         while (i < cnt) {
00259                 FaceSetList[ip] = linv[i]; ++ip; ++i;
00260                 FaceSetList[ip] = linv[i]; ++ip; ++i;
00261                 FaceSetList[ip] = linv[i]; ++ip; ++i;
00262                 ++i; /* skip the 4th value */
00263         }
00264         
00265         fclose (iv_file);
00266         
00267         SUMA_free(linv);
00268         
00269         return (FaceSetList);
00270 
00271 }/* SUMA_IV_FaceSetsextract */

float* SUMA_IV_XYZextract char *    IV_filename,
int *    N_NodeList,
int    IncludeIndex
 

File :Taken from IV_XYZextract.c Author : Ziad Saad Date : Tue Nov 17 19:02:16 CST 1998

Purpose :

Extracts the XYZ coordinates of the nodes in an IV file so that we can manipulate the data to our liking. The program looks for a sequence of characters that seem to indicate the start of the XYZ list. Once the sequence is found, the series of triplets is read and written out either to a file or to the screen. The sequence of triplets must be terminated by an ending sequence. The starting and ending sequences are hard coded into the program.

The program outputs an error message if : If the starting or ending sequences are not found If the number of points read is not a multiple of three If the first number of the first XYZ triplet and the last character in the starting sequence are not spearated by a space (or tab). You can fix this by manually adding a space.

Input paramters :

IV_filename (char *) a string specifying the name of the inventor file N_NodeList (int *) will give the number of nodes in NodeList / 3 or /4 Include_Index (int) (0/1) controls the output of the function, see ahead for info

Usage : NodeList = SUMA_IV_XYZextract (char *IV_filename, int *N_NodeList, int Include_Index)

Returns : NodeList (float *) an Mx3 (or Mx4) vector containing the

X Y Z coordinates of each node (with Include_Index = 0) or NodeIndex X Y Z coordinates of each node (with Include_Index = 1)

entries on one line are separated by a tab.

Support :

Side effects :

Definition at line 70 of file SUMA_IV_XYZextract.c.

References free, i, SUMA_alloc_problem(), SUMA_calloc, SUMA_ENTRY, SUMA_error_message(), SUMA_iswordin(), SUMA_malloc, SUMA_realloc, and SUMA_RETURN.

Referenced by SUMA_Load_Surface_Object_eng().

00071 {/* SUMA_IV_XYZextract */
00072         static char FuncName[]={"SUMA_IV_XYZextract"};
00073         char s[500],serr[500];
00074         char seq_strt[5][30], seq_end[5][30];
00075         float f, *linv, *NodeList;
00076         int i, ex, si, si_exit, evl, se, se_exit, cnt, cntlim,i3, i4;
00077         int nospacing, MaxAlloc = 100;
00078         div_t cnt3;
00079         FILE*iv_file;
00080         
00081         SUMA_ENTRY;
00082 
00083         /* intialize the number of points read to 0 */
00084         *N_NodeList = 0;
00085         
00086         linv = (float *)SUMA_malloc (MaxAlloc*sizeof(float));
00087         if (!linv)
00088                 {
00089                                 SUMA_alloc_problem ("Allocation error in SUMA_IV-XYZExtract");
00090                                 SUMA_RETURN (NULL);
00091                 }
00092         
00093         /*This is the sequence to trigger reading the numbers*/
00094         sprintf (seq_strt[0],"Coordinate3");
00095         sprintf (seq_strt[1],"{");
00096         sprintf (seq_strt[2],"point");  
00097         sprintf (seq_strt[3],"[");
00098 
00099         si_exit = 4; /* set equal to the number of strings to be matched */
00100 
00101         /*This is a sequence to mark the end of the number list*/
00102         sprintf (seq_end[0],"]");
00103         sprintf (seq_end[1],"}");  /* no need to find closing Coordinate element, perhaps other properties are defined.*/
00104 
00105         se_exit = 1; /* set equal to the number of strings to be matched */
00106 
00107         iv_file = fopen (IV_filename,"r");
00108         if (iv_file == NULL)
00109                 {
00110                         SUMA_error_message ("SUMA_IV_XYZextract","Could not open input file ",1);
00111                         exit (1);
00112                 }
00113 
00114 
00115         si = 0;
00116         ex = 1;
00117         cnt = 0;
00118 
00119         nospacing = 0; /* this flag is used to when the last number is read and it has the first seq_end*/
00120                                                         /* character attached to it, ie no space ! in between*/
00121         while (ex != EOF && si < si_exit)
00122         {
00123                 ex = fscanf (iv_file,"%s",s);
00124 
00125                 /*evl = equal_strings (s,seq_strt[si]);*/
00126 
00127                 if (strlen (seq_strt[si]) >= strlen (s)) 
00128                         {
00129                                 evl = SUMA_iswordin (seq_strt[si],s);
00130                                 if (evl == 1)
00131                                         nospacing = 0; /* There is a space between character in starting sequence and first number*/ 
00132                         }
00133                 else
00134                         {
00135                                 evl = SUMA_iswordin (s,seq_strt[si]);
00136                                 if (evl == 1)
00137                                                 nospacing = 1;
00138                         }
00139 
00140                 switch (evl)
00141                         {
00142                                 case 0:
00143                                         si = 0;         /* No match, reset the sequence counter */
00144                                         break;
00145                                 case 1:
00146                                         if (nospacing == 1 && si == si_exit-1) /* it has to be the last character in the sequence*/
00147                                                 {
00148                                                         sprintf (serr,"Must have a space character between first number and last character in start sequence ( %s )",s);
00149                                                         SUMA_error_message ("SUMA_IV_XYZextract",serr,1);
00150                                                         exit (1);
00151 
00152                                                 }
00153                                         si = si +1;     /* increment the start sequence counter */
00154                                         #ifdef DEBUG_3
00155                                                 printf ("found %s  ---  si = %d\n",s,si);
00156                                         #endif
00157                                         break;
00158                                 default:
00159                                         break;
00160                         }
00161         }
00162 
00163         /* Now, read the series of numbers until you encounter the first string of the ending sequence*/
00164         se = 0;
00165         nospacing = 0; 
00166 
00167         while (ex != EOF && se < se_exit )
00168                 {
00169                         ex = fscanf (iv_file,"%s",s);
00170                         /*evl = equal_strings (s,seq_end[se]);*/
00171 
00172                         if (strlen (seq_end[se]) >= strlen (s)) 
00173                                 {
00174                                         evl = SUMA_iswordin (seq_end[se],s);
00175                                         if (evl == 1)
00176                                                 nospacing = 0; /* There is a space between last number and fisrt character in ending sequence */ 
00177                                 }
00178                         else
00179                                 { 
00180                                         evl = SUMA_iswordin (s,seq_end[se]);
00181                                         if (evl == 1)
00182                                                 nospacing = 1;
00183                                 }
00184 
00185                         switch (evl)
00186                                 {
00187                                         case 0:
00188                                                 f = atof (s);
00189                                                 linv[cnt] = f;
00190                                                         #ifdef DEBUG_3
00191                                                                 printf ("\nNumber (%d): %d is appended to end sequence !\n",cnt,linv[cnt]);     
00192                                                         #endif
00193                                                 
00194                                                 
00195                                                 ++cnt;
00196                                                 
00197                                                 if (cnt >= MaxAlloc - 1)
00198                                                         {
00199                                                                 MaxAlloc = MaxAlloc + 100;
00200                                                                 linv = (float *)SUMA_realloc ((void*) linv, MaxAlloc * sizeof(float));
00201                                                                 if (!linv)
00202                                                                         {
00203                                                                                 SUMA_alloc_problem ("Re-Allocation error in IV-FaceSetExtract");
00204                                                                                 SUMA_RETURN (NULL);
00205                                                                         }
00206                                                                 
00207                                                         }  
00208                                                 se = 0;  /* no match for ending sequence, reset the counter */
00209                                                 break;
00210                                         case 1:         /* found the first character in the end sequence */
00211                                                 if (nospacing == 1 && se == 0) /* it has to be the first character in the sequence*/
00212                                                 {
00213                                                         f = atof (s);
00214                                                         linv[cnt] = f;
00215                                                         
00216                                                         ++cnt;
00217                                                         #ifdef DEBUG_3
00218                                                                 printf ("\nLast number (%d): %f is appended to end sequence !\n",cnt,f);        
00219                                                         #endif
00220                                                 }
00221                                                 #ifdef DEBUG_3
00222                                                         printf ("\nfound %s  ---  se = %d\n",s,se);
00223                                                 #endif
00224                                                 se = se + 1;
00225                                                 break;
00226                                         default:
00227                                                 break;
00228                                 }
00229 
00230                 }
00231         if (si < si_exit)
00232                 {
00233                         SUMA_error_message ("SUMA_IV_XYZextract","Could not find specified starting sequence",0);
00234                         for (i=0;i<si_exit;++i)
00235                                         printf ("%s \t",seq_strt[i]);
00236                 }
00237         else
00238                 { 
00239                         if (se < se_exit)
00240                                 {
00241                                         SUMA_error_message ("SUMA_IV_XYZextract","Could not find specified ending sequence",0);
00242                                         for (i=0;i<se_exit;++i)
00243                                                         printf ("%s \t",seq_end[i]);
00244                                 }
00245                         else
00246                                 {
00247                                         /* check that the number of points read is multiple of 3 */
00248                                         cnt3 = div (cnt,3);
00249                                         if (cnt3.rem != 0)
00250                                                 {
00251                                                         SUMA_error_message ("SUMA_IV_XYZextract","number of points read is not multiple of 3 !",0);
00252                                                         #ifdef DEBUG_3
00253                                                                 printf ("%f XYZ sets read !!!\n",(float)cnt/3);
00254                                                         #endif
00255                                                 }
00256                                 }
00257                 }
00258 
00259         *N_NodeList = cnt3.quot;
00260         
00261         /* Now allocate space for IV_FaceSetsextract and fill it up */
00262         if (!IncludeIndex)
00263                 NodeList = (float *) SUMA_calloc (*N_NodeList * 3, sizeof(float));
00264         else
00265                 NodeList = (float *) SUMA_calloc (*N_NodeList * 4, sizeof(float));
00266         
00267         if (!NodeList)
00268                 {
00269                         SUMA_alloc_problem("SUMA_IV_XYZextract : Could not allocate");
00270                         SUMA_RETURN (NULL);
00271                 }
00272         
00273         if (!IncludeIndex)
00274                 {       
00275                         for (i=0; i< cnt; ++i)
00276                                 {
00277                                         NodeList[i] = linv[i];
00278                                 }
00279                 }
00280         else
00281                 {
00282                         cntlim = cnt/3;
00283                         for (i=0; i < cntlim; ++i)
00284                                 {
00285                                         
00286                                         i4 = 4*i;
00287                                         i3 = 3*i;
00288                                         NodeList[i4] = i;
00289                                         
00290                                         NodeList[i4+1] = linv[i3];
00291                                         NodeList[i4+2] = linv[i3+1];
00292                                         NodeList[i4+3] = linv[i3+2];
00293                                         
00294                                 }
00295                         
00296                 }
00297                 
00298         fclose (iv_file);
00299         free (linv);
00300         
00301         SUMA_RETURN (NodeList);
00302         
00303         
00304 }/* SUMA_IV_XYZextract */

SUMA_MEMBER_FACE_SETS* SUMA_MemberFaceSets int    Nind,
int *    FaceSetList,
int    nFr,
int    FaceDim,
char *    ownerid
 

** File : SUMA_MemberFaceSets.c

Author:
Ziad Saad Date : Thu Jan 3 12:01:49 EST 2002
Purpose : Determines for each Node Index, from 0 to Nind-1 the indices of the FaceSets to which the node belongs.

Usage : RetStruct = SUMA_MemberFaceSets (int Nind, int * FaceSetList, int nFace, int FaceSetDim);

Input paramters :

Parameters:
Nind  (int) : Total number of nodes in Index. ( No value (node index) in FaceSetList can be > Nind-1 )
FaceSetList  (int *) : The FaceSetList vector (used to be matrix, prior to SUMA 1.2), [nFace x FaceSetDim]
nFace  (int) : number of FaceSets in FaceSetList
FaceSetDim  (int): column (2nd) dimension of FaceSetList (usually 3 or 4)
Returns :
Returns:
RetStruct : a SUMA_MEMBER_FACE_SETS type structure with the following fields NodeMemberOfFaceSet (int **) a matrix containing the indices of the FaceSets containing the nodes. Each row i in NodeMemberOfFaceSet lists all FaceSets containing the node i. The list is delimited by a -1 entry for all but the node that has a max of N_Memb_max members. the size of NodeMemberOfFaceSet is [Nind x N_Memb_max]; N_Memb (int *) the number of 1st order neighbors for each node in Index N_Memb_max (int) the second dimension of NodeMemberOfFaceSet, also represents the maximum number of FaceSets that any node belongs to. Nnode (int) : it's equal to Nind but it is kept here so that the structure can contain enough info to free memory that is allocated to it.
if (RetStruct.NodeMemberOfFaceSet == NULL) then an error occurred in the function

Support :

See also:
MemberFaceSets.c and .m for methods that work when the search is required for a few nodes only
Example: FaceSetList is: 1 4 6 6 4 2 6 1 3

and Nind is: 7

Then RetStruct.NodeMemberOfFaceSet is: -1 0 0 ( Node 0 is not used in FaceSetList ) 0 2 -1 (Node 1 is used in Facesets 0 & 2 ) 1 -1 0 (Node 2 is used in Faceset 1) 2 -1 0 (Node 3 is used in Faceset 2) 0 1 -1 (Node 4 is used in Facesets 0 & 1) -1 0 0 (Node 5 in not used in FaceSetList) 0 1 2 (Node 6 is used in all Facesets)

and RetStruct.N_Memb is: 0 2 1 1 2 0 3

Side effects : To free RetStruct, use: if (RetStruct.NodeMemberOfFaceSet) SUMA_free2D((char **)RetStruct.NodeMemberOfFaceSet, Nind); if (RetStruct.N_Memb) SUMA_free(RetStruct.N_Memb); if (RetStruct) SUMA_free(RetStrct);

Definition at line 303 of file SUMA_SurfNorm.c.

References i, SUMA_MEMBER_FACE_SETS::idcode_str, SUMA_MEMBER_FACE_SETS::LinkedPtrType, SUMA_MEMBER_FACE_SETS::N_links, SUMA_MEMBER_FACE_SETS::N_Memb, SUMA_MEMBER_FACE_SETS::N_Memb_max, SUMA_MEMBER_FACE_SETS::Nnode, SUMA_MEMBER_FACE_SETS::NodeMemberOfFaceSet, SUMA_MEMBER_FACE_SETS::owner_id, SUMA_allocate2D(), SUMA_calloc, SUMA_ENTRY, SUMA_free2D(), SUMA_LINKED_MEMB_FACE_TYPE, SUMA_malloc, SUMA_MAX_MEMBER_FACE_SETS, SUMA_NEW_ID, and SUMA_RETURN.

Referenced by main(), SUMA_CreateIcosahedron(), and SUMA_SurfaceMetrics_eng().

00304 {/*SUMA_MemberFaceSets*/
00305    static char FuncName[]={"SUMA_MemberFaceSets"}; 
00306    SUMA_MEMBER_FACE_SETS *RetStrct;
00307    int **tmpMember;
00308    int i, inode, iface, ip , NP;
00309    
00310    SUMA_ENTRY;
00311 
00312    NP = FaceDim;
00313    RetStrct = (SUMA_MEMBER_FACE_SETS *)SUMA_malloc(sizeof(SUMA_MEMBER_FACE_SETS));
00314    RetStrct->idcode_str = NULL;
00315    SUMA_NEW_ID(RetStrct->idcode_str, NULL);
00316    RetStrct->N_links = 0;
00317    if (ownerid) sprintf(RetStrct->owner_id, "%s", ownerid);
00318    else RetStrct->owner_id[0] = '\0';
00319    RetStrct->LinkedPtrType = SUMA_LINKED_MEMB_FACE_TYPE;
00320    
00321    RetStrct->N_Memb_max = RetStrct->Nnode = 0;
00322    RetStrct->N_Memb = NULL;
00323    RetStrct->NodeMemberOfFaceSet = NULL;
00324    
00325    /* Allocate return variables */
00326    tmpMember = (int **) SUMA_allocate2D (Nind, SUMA_MAX_MEMBER_FACE_SETS ,sizeof(int));
00327    RetStrct->N_Memb = (int *) SUMA_calloc (Nind, sizeof(int));
00328    
00329    if (!tmpMember || !RetStrct->N_Memb)
00330       {
00331          fprintf (SUMA_STDERR,"Error %s: Failed to allocate for tmpMember or RetStrct->N_Memb\n", FuncName);
00332          SUMA_RETURN (RetStrct);
00333       }
00334    
00335    /* loop through all facesets and tag nodes that make up FaceSets*/
00336    for (iface=0; iface<nFr; ++iface) {/*iface*/
00337       i = 0;
00338       ip = NP * iface;
00339       do {
00340          inode = FaceSetList[ip + i];
00341          if (inode > Nind) {
00342             fprintf (SUMA_STDERR,"Error %s: FaceSetList contains node indices >= Nind\n", FuncName);
00343             SUMA_RETURN (RetStrct);
00344          }
00345          tmpMember[inode][RetStrct->N_Memb[inode]] = iface; 
00346          ++RetStrct->N_Memb[inode];
00347          if (RetStrct->N_Memb[inode] >= SUMA_MAX_MEMBER_FACE_SETS) {
00348             fprintf (SUMA_STDERR,"Error %s: Node %d is member of (%d FaceSets) more than SUMA_MAX_MEMBER_FACE_SETS (%d)\n",\
00349                 FuncName, inode, RetStrct->N_Memb[inode], SUMA_MAX_MEMBER_FACE_SETS);
00350             SUMA_RETURN (RetStrct);
00351          }
00352          if (RetStrct->N_Memb[inode] > RetStrct->N_Memb_max) RetStrct->N_Memb_max = RetStrct->N_Memb[inode];
00353          ++i;
00354       } while (i < FaceDim);
00355    }
00356    
00357    /*allocate just enough for returning variables */
00358    RetStrct->NodeMemberOfFaceSet = (int **) SUMA_allocate2D (Nind, RetStrct->N_Memb_max ,sizeof(int));
00359    if (!RetStrct->NodeMemberOfFaceSet)
00360       {
00361          fprintf(SUMA_STDERR,"Error %s: Failed to allocate for RetStrct->NodeMemberOfFaceSet\n", FuncName);
00362          SUMA_RETURN (RetStrct);
00363       }
00364 
00365    /* loop through all nodes, cp results into RetStrct->NodeMemberOfFaceSet and seal with -1 */
00366    for (inode = 0; inode < Nind; ++inode) {
00367       i = 0;
00368       while (i < RetStrct->N_Memb[inode]) {
00369          RetStrct->NodeMemberOfFaceSet[inode][i] = tmpMember[inode][i];
00370          ++i;
00371       }
00372       /*seal with -1 */
00373       if (RetStrct->N_Memb[inode] < RetStrct->N_Memb_max) RetStrct->NodeMemberOfFaceSet[inode][i] = -1;
00374    }
00375 
00376    /* Clean up time */
00377    if (tmpMember) SUMA_free2D((char **)tmpMember, Nind);
00378    
00379    RetStrct->Nnode = Nind;
00380    SUMA_RETURN (RetStrct);
00381 
00382 }/*SUMA_MemberFaceSets*/

SUMA_Boolean SUMA_Read_SureFit_Param char *    f_name,
SUMA_SureFit_struct   SF
 

Read in some parameters from a .param file

Definition at line 839 of file SUMA_Surface_IO.c.

References SUMA_SureFit_struct::AC, SUMA_SureFit_struct::AC_WholeVolume, SUMA_SureFit_struct::name_param, SUMA_Boolean, SUMA_ENTRY, SUMA_filexists(), SUMA_iswordin(), SUMA_RETURN, and SUMA_SL_Warn.

Referenced by SUMA_Load_Surface_Object_eng().

00840 {
00841         static char FuncName[]={"SUMA_Read_SureFit_Param"};
00842         int ex, evl; 
00843    FILE *sf_file;
00844         SUMA_Boolean Done;
00845         char delimstr[] = {' ', '\0'}, stmp[100], s[1000], *st;
00846 
00847         SUMA_ENTRY;
00848 
00849         /* check for existence */
00850         if (!SUMA_filexists(f_name)) {
00851                 fprintf(SUMA_STDERR,"File %s does not exist or cannot be read.\n", f_name);
00852                 SUMA_RETURN (NOPE);
00853         }
00854 
00855         sprintf(SF->name_param, "%s", f_name);
00856 
00857         /* start reading */
00858         sf_file = fopen (f_name,"r");
00859         if (sf_file == NULL)
00860                 {
00861                         fprintf (SUMA_STDERR,"Error %s: Could not open input file ",FuncName);
00862                         SUMA_RETURN (NOPE);
00863                 }
00864 
00865         /* read until you reach something you like */
00866         ex = 1;
00867         Done = NOPE;                    
00868         sprintf(delimstr,"=");
00869         while (ex != EOF && !Done)
00870         {
00871                 ex = fscanf (sf_file,"%s",s);
00872                 
00873                 sprintf(stmp,"ACx_WholeVolume");
00874                 evl = SUMA_iswordin (s,stmp);
00875                 if (evl == 1) {
00876                         /* found ACx_WholeVolume */
00877                         /*fprintf(SUMA_STDOUT, "Found ACx_WholeVolume:");*/
00878                         /* go past the = sign and grab the value */
00879                         st = strtok(s, delimstr);
00880                         st = strtok(NULL, delimstr);
00881                         SF->AC_WholeVolume[0] = atof(st);
00882                         /*fprintf(SUMA_STDOUT, " %f\n", SF->AC_WholeVolume[0]);*/
00883                         continue;
00884                 }
00885                 sprintf(stmp,"ACy_WholeVolume");
00886                 evl = SUMA_iswordin (s,stmp);
00887                 if (evl == 1) {
00888                         /* found ACy_WholeVolume */
00889                         /*fprintf(SUMA_STDOUT, "Found ACy_WholeVolume:");*/
00890                         /* go past the = sign and grab the value */
00891                         st = strtok(s, delimstr);
00892                         st = strtok(NULL, delimstr);
00893                         SF->AC_WholeVolume[1] = atof(st);
00894                         /*fprintf(SUMA_STDOUT, " %f\n", SF->AC_WholeVolume[1]);*/
00895                         continue;
00896                 }
00897                 sprintf(stmp,"ACz_WholeVolume");
00898                 evl = SUMA_iswordin (s,stmp);
00899                 if (evl == 1) {
00900                         /* found ACz_WholeVolume */
00901                         /*fprintf(SUMA_STDOUT, "Found ACz_WholeVolume:");*/
00902                         /* go past the = sign and grab the value */
00903                         st = strtok(s, delimstr);
00904                         st = strtok(NULL, delimstr);
00905                         SF->AC_WholeVolume[2] = atof(st);
00906                         /*fprintf(SUMA_STDOUT, " %f\n", SF->AC_WholeVolume[2]);*/
00907                         continue;
00908                 }
00909                  
00910                 sprintf(stmp,"ACx");
00911                 evl = SUMA_iswordin (s,stmp);
00912                 if (evl == 1) {
00913                         /* found ACx */
00914                         /*fprintf(SUMA_STDOUT, "Found ACx:");*/
00915                         /* go past the = sign and grab the value */
00916                         st = strtok(s, delimstr);
00917                         st = strtok(NULL, delimstr);
00918                         SF->AC[0] = atof(st);
00919                         /*fprintf(SUMA_STDOUT, " %f\n", SF->AC[0]);*/
00920                         continue;
00921                 }
00922                 sprintf(stmp,"ACy");
00923                 evl = SUMA_iswordin (s,stmp);
00924                 if (evl == 1) {
00925                         /* found ACy */
00926                         /*fprintf(SUMA_STDOUT, "Found ACy:");*/
00927                         /* go past the = sign and grab the value */
00928                         st = strtok(s, delimstr);
00929                         st = strtok(NULL, delimstr);
00930                         SF->AC[1] = atof(st);
00931                         /*fprintf(SUMA_STDOUT, " %f\n", SF->AC[1]);*/
00932                         continue;
00933                 }
00934                 sprintf(stmp,"ACz");
00935                 evl = SUMA_iswordin (s,stmp);
00936                 if (evl == 1) {
00937                         /* found ACz */
00938                         /*fprintf(SUMA_STDOUT, "Found ACz:");*/
00939                         /* go past the = sign and grab the value */
00940                         st = strtok(s, delimstr);
00941                         st = strtok(NULL, delimstr);
00942                         SF->AC[2] = atof(st);
00943                         /*fprintf(SUMA_STDOUT, " %f\n", SF->AC[2]);*/
00944                         continue;
00945                 }
00946                 
00947         }
00948         
00949         fclose(sf_file);
00950         
00951         /* Sanity Checks */
00952         if (SF->AC[0] == 0.0 && SF->AC[1] == 0.0 && SF->AC[2] == 0.0) {
00953                 fprintf (SUMA_STDERR,"Error %s: All values for AC are 0.0. Check your params file.\n", FuncName);
00954                 SUMA_RETURN (NOPE);
00955         }
00956         
00957         if (SF->AC_WholeVolume[0] == 0.0 && SF->AC_WholeVolume[1] == 0.0 && SF->AC_WholeVolume[2] == 0.0) {
00958                 fprintf (SUMA_STDERR,"Error %s: All values for AC_WholeVolume are 0.0. Check your params file.\n", FuncName);
00959                 SUMA_RETURN (NOPE);
00960         }
00961         
00962         if (SF->AC[0] == SF->AC_WholeVolume[0] && SF->AC[1] == SF->AC_WholeVolume[1] && SF->AC[2] == SF->AC_WholeVolume[2])
00963         {
00964                 SUMA_SL_Warn("Idetincal values for AC and AC_WholeVolume.\nCheck your params file if not using Talairach-ed surfaces.\n");
00965       /* looks like that's OK for TLRC surfaces ...*/
00966       /*
00967       fprintf (SUMA_STDERR,"Error %s: Idetincal values for AC and AC_WholeVolume. Check your params file.\n", FuncName);
00968                 SUMA_RETURN (NOPE);
00969       */
00970         }
00971         if (SF->AC[0] < 0 || SF->AC[1] < 0 || SF->AC[2] < 0 || SF->AC_WholeVolume[0] < 0 || SF->AC_WholeVolume[1] < 0 || SF->AC_WholeVolume[2] < 0) 
00972         {
00973                 fprintf (SUMA_STDERR,"Error %s: Negative values in AC or AC_WholeVolume. Check you params file.\n", FuncName);
00974                 SUMA_RETURN (NOPE);
00975         }
00976         
00977         SUMA_RETURN (YUP);
00978 }

SUMA_Boolean SUMA_RegisterDO int    dov_id,
SUMA_SurfaceViewer   cSV
 

Register a DO with surface viewer RegisteredDO vector if dov_id is present in cSV, nothing is done if not found then dov_id is registered at the end of cSV->RegisteredDO

When a DO is registered, a ColorList is created if the DO is a surface object. and N_DO is updated

Definition at line 364 of file SUMA_DOmanip.c.

References SUMA_SurfaceViewer::ColList, i, SUMA_COLORLIST_STRUCT::idcode_str, LocalHead, SUMA_SurfaceViewer::N_ColList, SUMA_SurfaceViewer::N_DO, SUMA_SurfaceViewer::RegisteredDO, SUMA_Boolean, SUMA_ENTRY, SUMA_FillColorList(), SUMA_isSO(), SUMA_MAX_SURF_VIEWERS, SUMA_RETURN, SUMA_UpdateViewerTitle(), and SUMA_WhichSV().

Referenced by SUMA_LoadSegDO(), SUMA_SetupSVforDOs(), SUMA_SwitchSO(), and SUMA_SwitchState().

00365 {
00366    int i;
00367    static char FuncName[]={"SUMA_RegisterDO"};
00368    SUMA_Boolean LocalHead = NOPE;
00369    
00370    SUMA_ENTRY;
00371    
00372    if (LocalHead && SUMA_WhichSV(cSV, SUMAg_SVv, SUMA_MAX_SURF_VIEWERS) != 0) {
00373       fprintf(SUMA_STDERR,"%s: Muted for viewer[%c]\n", FuncName, 65+SUMA_WhichSV(cSV, SUMAg_SVv, SUMA_MAX_SURF_VIEWERS) );
00374       /* turn off the LocalHead, too much output*/
00375       LocalHead = NOPE;
00376    }  
00377     
00378    /* check to see if dov_id exists */
00379    i = 0;
00380    while (i < cSV->N_DO) {
00381       if (cSV->RegisteredDO[i] == dov_id) {
00382          /* found do nothing, return */
00383          SUMA_RETURN(YUP);
00384       }
00385       ++i;
00386    }
00387    cSV->RegisteredDO[cSV->N_DO] = dov_id;
00388    cSV->N_DO += 1;
00389    
00390    /* Now add the ColorList, if DO is a surface object */
00391    if (SUMA_isSO(SUMAg_DOv[dov_id])) {
00392       if (LocalHead) fprintf (SUMA_STDERR,"%s: Adding color list...\n", FuncName);
00393       /* add the ColorList */
00394       if (!SUMA_FillColorList (cSV, (SUMA_SurfaceObject *)SUMAg_DOv[dov_id].OP)) {
00395          fprintf(SUMA_STDERR,"Error %s: Failed in SUMA_FillColorList.\n", FuncName);
00396          SUMA_RETURN (NOPE);
00397       }
00398    }
00399    
00400    if (LocalHead) fprintf (SUMA_STDERR, "%s: Back from SUMA_FillColorList. (%s/%d).\n", \
00401          FuncName, cSV->ColList[0].idcode_str, cSV->N_ColList);
00402    
00403    if (LocalHead) {
00404       fprintf (SUMA_STDERR,"%s: RegisteredDO is now:\n", FuncName);
00405       for (i=0; i< cSV->N_DO; ++i) {
00406          fprintf(SUMA_STDERR,"RegisteredDO[%d] = %d\t", i, cSV->RegisteredDO[i]);
00407       }
00408       fprintf(SUMA_STDERR,"\n");
00409    }
00410 
00411    /* update the title bar */
00412    SUMA_UpdateViewerTitle(cSV);   
00413 
00414    SUMA_RETURN(YUP); 
00415 }

int SUMA_ReleaseLink SUMA_INODE   IN
 

This function decrements the N_link field in IN by 1 and returns the resultant N_link value a -1 is returned if IN->N_link = 0 or IN == NULL

ans = SUMA_ReleaseLink (IN);

Parameters:
IN  (SUMA_INODE *) pointer to SUMA_INODE structure \ret ans (int) value of IN->N_link
See also:
SUMA_AddLink

Definition at line 127 of file SUMA_DOmanip.c.

References LocalHead, SUMA_INODE::N_link, SUMA_Boolean, SUMA_ENTRY, and SUMA_RETURN.

Referenced by SUMA_BreakInodeLink(), SUMA_Free_Surface_Object(), and SUMA_ReleaseOverlay().

00128 {
00129    static char FuncName[]={"SUMA_ReleaseLink"};
00130    SUMA_Boolean LocalHead = NOPE;
00131    
00132    SUMA_ENTRY;
00133 
00134    if (!IN) {
00135       /* This typically happens when A link was never created in the first place.
00136       It used to be an error message but now it is just a warning because some
00137       programs compute things like SO->Cx without creating an inode with it ...*/
00138       fprintf (SUMA_STDERR,"Warning %s: Inode is null. Returning -1.\n", FuncName);
00139       SUMA_RETURN(-1);
00140    }
00141    if (!IN->N_link) {
00142       if (LocalHead) fprintf (SUMA_STDERR,"%s: No links. Returning -1.\n", FuncName);
00143       /* You do not want to return a 0 because freeing is done when no links remain 
00144       THIS STUPID SYSTEM SHOULD BE ELIMINATED IN FAVOR OF THE METHOD USED FOR OVERLAYS*/
00145       SUMA_RETURN(-1);
00146    }
00147    else {
00148       IN->N_link--;
00149       SUMA_RETURN(IN->N_link);
00150    }
00151 }

SUMA_Boolean SUMA_RemoveDO SUMA_DO   dov,
int *    N_dov,
void *    op,
SUMA_Boolean    Free_op
 

Remove a displayable object from dov success = SUMA_RemoveDO(dov, N_dov, op, Free_op);.

Parameters:
dov  (SUMA_DO*) vector containing displayable objects
N_dov  (int *) number of elements in dov
op  (void *) pointer to object sought
Free_op  (SUMA_Boolean) Flag for freeing space allocated for op's data. Freeing is done via SUMA_Free_Displayable_Object()
Returns:
success (SUMA_Boolean) flag.

Definition at line 320 of file SUMA_DOmanip.c.

References SUMA_DO::CoordType, i, LocalHead, SUMA_DO::ObjectType, SUMA_DO::OP, SUMA_Boolean, SUMA_ENTRY, SUMA_Free_Displayable_Object(), SUMA_LH, SUMA_RETURN, and SUMA_SLP_Crit.

Referenced by SUMA_DeleteROI().

00321 {
00322    static char FuncName[] = {"SUMA_RemoveDO"};
00323    int i;
00324    SUMA_Boolean LocalHead = NOPE, Found=NOPE;
00325    
00326    SUMA_ENTRY;
00327    
00328    SUMA_LH("Called");
00329    
00330    for (i=0; i<*N_dov; ++i) {
00331       if (dov[i].OP == op) {
00332          Found = YUP;
00333          if (LocalHead) fprintf (SUMA_STDERR,"%s: found object. Removing it from dov.\n", FuncName);
00334          if (Free_op) {
00335             if (LocalHead) fprintf (SUMA_STDERR,"%s: Freeing object.\n", FuncName);
00336             if (!SUMA_Free_Displayable_Object (&dov[i])) {
00337                SUMA_SLP_Crit("Failed to free displayable object.");
00338                SUMA_RETURN(NOPE);
00339             }
00340          }
00341          *N_dov = *N_dov-1;
00342          dov[i].OP = dov[*N_dov].OP;
00343          dov[i].ObjectType = dov[*N_dov].ObjectType;
00344          dov[i].CoordType = dov[*N_dov].CoordType;
00345       }
00346    }
00347 
00348    
00349    if (Found) {
00350       SUMA_RETURN(YUP);
00351    } else {
00352       SUMA_RETURN(NOPE);
00353    }
00354 }

void SUMA_Show_DOv SUMA_DO   dov,
int    N_dov,
FILE *    Out
 

print out the data contained in dov

Definition at line 482 of file SUMA_DOmanip.c.

References AO_type, SUMA_FileName::FileName, SUMA_SurfaceObject::FileType, GO_type, i, SUMA_ROI::idcode_str, SUMA_DRAWN_ROI::idcode_str, SUMA_SegmentDO::idcode_str, SUMA_Axis::idcode_str, SUMA_ROI::Label, SUMA_DRAWN_ROI::Label, SUMA_SegmentDO::Label, LS_type, SUMA_Axis::Name, SUMA_SurfaceObject::Name, SUMA_SurfaceObject::Name_coord, SUMA_SurfaceObject::Name_topo, SUMA_FileName::Path, ROIdO_type, ROIO_type, SO_type, SUMA_ENTRY, SUMA_RETURNe, and SUMA_SUREFIT.

Referenced by SUMA_input().

00483 {
00484    int i;
00485    SUMA_SurfaceObject *so_op;
00486    static char FuncName[]={"SUMA_Show_DOv"};
00487    
00488    SUMA_ENTRY;
00489 
00490    if (Out == NULL) Out = stdout;
00491    fprintf(Out,"\nDOv contents (%d elements):\n", N_dov);
00492    for (i=0; i < N_dov; ++i) {
00493       switch (dov[i].ObjectType) {
00494          case SO_type:
00495             so_op = (SUMA_SurfaceObject *)dov[i].OP;
00496             if (so_op->FileType != SUMA_SUREFIT) {
00497                fprintf(Out,"DOv ID: %d\n\tName: %s/%s\n\tType: %d, Axis Attachment %d\n",\
00498                   i, so_op->Name.Path, so_op->Name.FileName,\
00499                   dov[i].ObjectType, dov[i].CoordType);
00500             } else {
00501                fprintf(Out,"DOv ID: %d\n\tNameCoord: %s/%s\n\tNameTopo: %s/%s\n\tType: %d, Axis Attachment %d\n",\
00502                   i, so_op->Name_coord.Path, so_op->Name_coord.FileName,\
00503                   so_op->Name_topo.Path, so_op->Name_topo.FileName,\
00504                   dov[i].ObjectType, dov[i].CoordType);
00505             }   
00506             break;
00507          case AO_type:
00508             {
00509                SUMA_Axis* ao;
00510                ao = (SUMA_Axis*) dov[i].OP;
00511                fprintf(Out,"DOv ID: %d\n\tAxis Object\n\tType: %d, Axis Attachment %d\n", i,dov[i].ObjectType, dov[i].CoordType);
00512                fprintf(Out,"\tName: %s\tidcode: %s\n", ao->Name, ao->idcode_str);
00513             }
00514             break;
00515          case LS_type:
00516             {
00517                SUMA_SegmentDO *sdo=NULL;
00518                
00519                sdo = (SUMA_SegmentDO *)dov[i].OP;
00520                fprintf(Out,"DOv ID: %d\n\tLine Segment Object\n\tType: %d, Axis Attachment %d\n", i,dov[i].ObjectType, dov[i].CoordType);
00521                fprintf(Out,"\tLabel: %s\tidcode: %s\n", sdo->Label, sdo->idcode_str);
00522             
00523             }
00524             break;
00525          case ROIdO_type:
00526             {
00527                SUMA_DRAWN_ROI *dROI = NULL;
00528                
00529                dROI = (SUMA_DRAWN_ROI *)dov[i].OP;
00530                fprintf(Out,"DOv ID: %d\n\tLine Segment Object\n\tType: %d, Axis Attachment %d\n", i,dov[i].ObjectType, dov[i].CoordType);
00531                fprintf(Out,"\tLabel: %s\tidcode: %s\n", dROI->Label, dROI->idcode_str);
00532             }  
00533             break;
00534          case ROIO_type:
00535             {
00536                SUMA_ROI *ROI = NULL;
00537                
00538                ROI = (SUMA_ROI *)dov[i].OP;
00539                fprintf(Out,"DOv ID: %d\n\tLine Segment Object\n\tType: %d, Axis Attachment %d\n", i,dov[i].ObjectType, dov[i].CoordType);
00540                fprintf(Out,"\tLabel: %s\tidcode: %s\n", ROI->Label, ROI->idcode_str);
00541             }  
00542             break;
00543          case GO_type:
00544             fprintf(Out,"DOv ID: %d\n\tGrid Object\n", i);
00545             break;
00546          default:
00547             fprintf(Out,"DOv ID: %d\n\tUnknown Type!\n", i);
00548             break;
00549       }
00550    }
00551    SUMA_RETURNe;
00552 }

void SUMA_Show_VolPar SUMA_VOLPAR   VP,
FILE *    Out
 

Show the contents of SUMA_VOLPAR structure

See also:
SUMA_VolPar_Info

Definition at line 762 of file SUMA_VolData.c.

References SUMA_ENTRY, SUMA_free, SUMA_RETURNe, and SUMA_VolPar_Info().

00763 {
00764    static char FuncName[]={"SUMA_Show_VolPar"};
00765    char *s;
00766    
00767    SUMA_ENTRY;
00768 
00769    if (Out == NULL) Out = SUMA_STDOUT;
00770    
00771    s =  SUMA_VolPar_Info(VP);
00772    
00773    if (s) {
00774       fprintf (Out, "%s", s);
00775       SUMA_free(s);
00776    }else {
00777       fprintf (SUMA_STDERR, "Error %s: Failed in SUMA_VolPar_Info.\n", FuncName);
00778    }   
00779    
00780    SUMA_RETURNe;
00781       
00782 }

SUMA_SURF_NORM SUMA_SurfNorm float *    NodeList,
int    N_NodeList,
int *    FaceSetList,
int    N_FaceSetList
 

** File : SUMA_SurfNorm.c

Author:
Ziad Saad Date : Thu Jan 3 14:46:55 EST 2002
Purpose : Calculate the polygon and node normals making up a surface It is assumed that FaceSetList does NOT contain an index >= N_NodeList

Usage : RetStrct = SUMA_SurfNorm (NodeList, N_NodeList, FaceSetList, N_FaceSetList );

Input paramters :

Parameters:
NodeList  (float *): N_NodeList x 3 vector containing the XYZ coordinates of each node
N_NodeList  (int): number of nodes in NodeList
FaceSetList  (int *): [N_FaceSetList x 3] vector (matrix prior to SUMA 1.2) of node indices forming each triangular facet (FaceSets). The indices must be relative to NodeList
N_FaceSetList  (int): 1st dimension of FaceSetList
Returns :
Returns:
RetStrct, a structure of the type SUMA_SURF_NORM with the following fields N_Node (int) Number of nodes, 1st dim of NodeNormList N_Face (int) Number of facesets, 1st dim of FaceNormList FaceNormList (float *) N_Face x 3 vector (was matrix prior to SUMA 1.2) containing normalized normal vectors for each triangular faceset NodeNormList (float *) N_Node x 3 vector (was matrix prior to SUMA 1.2) containing normalized normal vectors for each node
Support :
See also:
SUMA_MemberFaceSets , Side effects : to free memory from RetStrct if (RetStrct.FaceNormList) SUMA_free(RetStrct.FaceNormList); if (RetStrct.NodeNormList) SUMA_free(RetStrct.NodeNormList);
The node normals are obtained by averaging the normals of the surrounding facesets (ie facesets containing the node). This is an approximation and in special cases like a cube with a particular tesselation, the normals could be biased in direction if the node is a member of more triangles on one side of the object than the other sides. See Lab-book NIH-2, page 142 for an illustration or this miserable ascii rendition.

------------------- ## * Here, Node I will have its normal biased towards the direction of N2 and N3 ## * | because node I is part of two triangles from one side and one triangle in ## N1 * | each of the other 2 sides. ## * | ## I * N3 | ------------------ * | |## |######| | ## N4 | * | ## | N2 * | ## | * | ## | * | ## | * ------------------

Definition at line 87 of file SUMA_SurfNorm.c.

References SUMA_SURF_NORM::FaceNormList, i, LocalHead, SUMA_SURF_NORM::N_Face, SUMA_SURF_NORM::N_Node, SUMA_SURF_NORM::NodeNormList, SUMA_alloc_problem(), SUMA_Boolean, SUMA_calloc, SUMA_ENTRY, SUMA_error_message(), SUMA_free, SUMA_LH, SUMA_RETURN, SUMA_SL_Warn, and SUMA_TriNorm().

Referenced by main(), SUMA_Cmap_To_SO(), SUMA_Cmap_To_SO_old(), SUMA_CreateIcosahedron(), SUMA_Pattie_Volume(), and SUMA_PrepSO_GeomProp_GL().

00088 {/*SUMA_SurfNorm*/
00089    static char stmp[200], FuncName[]={"SUMA_SurfNorm"}; 
00090    float d1[3], d2[3], d, nrm;
00091    SUMA_SURF_NORM RetStrct;
00092    int *Index, *N_Memb, i, j, maxind, NotMember, id, id2, ND, ip, NP;
00093    SUMA_Boolean LocalHead = NOPE;
00094    
00095    SUMA_ENTRY;
00096    
00097    ND = 3;
00098    NP = 3;
00099    RetStrct.N_Node = N_NodeList; /* redundant, but practical for clean up outside the function */
00100    RetStrct.N_Face = N_FaceSetList;
00101 
00102    /* allocate space */
00103    if (LocalHead) fprintf(SUMA_STDERR,"%s: %d %d\n", FuncName, N_NodeList, N_FaceSetList);
00104    RetStrct.FaceNormList = (float *)SUMA_calloc (N_FaceSetList * NP, sizeof(float));
00105    RetStrct.NodeNormList = (float *)SUMA_calloc (N_NodeList * ND, sizeof(float));
00106    Index = (int *)SUMA_calloc (N_NodeList, sizeof(int));
00107    N_Memb = (int *)SUMA_calloc (N_NodeList, sizeof(int));
00108    if (!RetStrct.FaceNormList || !RetStrct.NodeNormList || !Index || !N_Memb)
00109       {
00110          SUMA_alloc_problem (FuncName);
00111          SUMA_RETURN (RetStrct);
00112       }
00113 
00114    /* calculate and normalize triangle normals */
00115    maxind = N_NodeList -1;
00116    for (i=0; i < N_FaceSetList; i++) {
00117       ip = NP * i;
00118       for (j=0; j < 3; j++) {
00119          d1[j] = NodeList[(ND*FaceSetList[ip])+j] - NodeList[(ND*FaceSetList[ip+1])+j];
00120          d2[j] = NodeList[(ND*FaceSetList[ip+1])+j] - NodeList[(ND*FaceSetList[ip+2])+j];
00121       }
00122       RetStrct.FaceNormList[ip] = d1[1]*d2[2] - d1[2]*d2[1];
00123       RetStrct.FaceNormList[ip+1] = d1[2]*d2[0] - d1[0]*d2[2];
00124       RetStrct.FaceNormList[ip+2] = d1[0]*d2[1] - d1[1]*d2[0];
00125       d = sqrt(RetStrct.FaceNormList[ip]*RetStrct.FaceNormList[ip]+RetStrct.FaceNormList[ip+1]*RetStrct.FaceNormList[ip+1]+RetStrct.FaceNormList[ip+2]*RetStrct.FaceNormList[ip+2]);
00126       if (d == 0.0) {
00127          /* I used to return here with a nasty message, but it seems that FreeSurfer surfaces contain such conditions 
00128          So, now I just set the normal to 1.0 in that case */
00129          /*SUMA_error_message (FuncName,"Zero length vector, returning",1);
00130          if (RetStrct.FaceNormList) SUMA_free(RetStrct.FaceNormList);
00131          if (RetStrct.NodeNormList) SUMA_free(RetStrct.NodeNormList);
00132          if (Index) SUMA_free(Index);
00133          if (N_Memb) SUMA_free(N_Memb);
00134          SUMA_RETURN (RetStrct);*/
00135          RetStrct.FaceNormList[ip] = 1.0;
00136          RetStrct.FaceNormList[ip+1] = 1.0;
00137          RetStrct.FaceNormList[ip+2] = 1.0;
00138          
00139       } else {
00140          RetStrct.FaceNormList[ip] /= d;
00141          RetStrct.FaceNormList[ip+1] /= d;
00142          RetStrct.FaceNormList[ip+2] /= d;
00143       }
00144       
00145       #if 0
00146          /* a test for the function SUMA_TriNorm */
00147          {
00148             float test_norm[3];
00149             SUMA_TriNorm (&(NodeList[(ND*FaceSetList[ip])]), &(NodeList[(ND*FaceSetList[ip+1])]), &(NodeList[(ND*FaceSetList[ip+2])]), test_norm);
00150             if (test_norm[0] != RetStrct.FaceNormList[ip] || test_norm[1] != RetStrct.FaceNormList[ip+1] || test_norm[2] != RetStrct.FaceNormList[ip+2]) {
00151                fprintf (SUMA_STDERR, "Error %s: Test of SUMA_TriNorm failed, difference in norms. Exiting.\n", FuncName);
00152                exit(1);
00153             } 
00154             fprintf (SUMA_STDERR,".");
00155          }
00156          
00157       #endif
00158       
00159          /*each node making up the FaceSet will get its normal vector updated*/
00160          if (FaceSetList[ip] > maxind || FaceSetList[ip+1] > maxind || FaceSetList[ip+2] > maxind) {
00161             SUMA_error_message (FuncName,"FaceSetList contains indices >= N_NodeList",1);
00162             if (RetStrct.FaceNormList) SUMA_free(RetStrct.FaceNormList);
00163             if (RetStrct.NodeNormList) SUMA_free(RetStrct.NodeNormList);
00164             if (Index) SUMA_free(Index);
00165             if (N_Memb) SUMA_free(N_Memb);
00166             SUMA_RETURN (RetStrct);
00167          }
00168 
00169          
00170          id2 = ND * FaceSetList[ip];
00171          RetStrct.NodeNormList[id2] += RetStrct.FaceNormList[ip];
00172          RetStrct.NodeNormList[id2+1] += RetStrct.FaceNormList[ip+1];
00173          RetStrct.NodeNormList[id2+2] += RetStrct.FaceNormList[ip+2];
00174          ++N_Memb[FaceSetList[ip]];
00175          id2 = ND * FaceSetList[ip+1];
00176          RetStrct.NodeNormList[id2] += RetStrct.FaceNormList[ip];
00177          RetStrct.NodeNormList[id2+1] += RetStrct.FaceNormList[ip+1];
00178          RetStrct.NodeNormList[id2+2] += RetStrct.FaceNormList[ip+2];
00179          ++N_Memb[FaceSetList[ip+1]];
00180          id2 = ND * FaceSetList[ip+2];
00181          RetStrct.NodeNormList[id2] += RetStrct.FaceNormList[ip];
00182          RetStrct.NodeNormList[id2+1] += RetStrct.FaceNormList[ip+1];
00183          RetStrct.NodeNormList[id2+2] += RetStrct.FaceNormList[ip+2];
00184          ++N_Memb[FaceSetList[ip+2]];
00185    }
00186       SUMA_LH("Normalizing");
00187       /*Now normalize NodeNormList*/
00188       NotMember = 0;
00189       for (i=0; i<N_NodeList; ++i)
00190          {
00191             id = ND * i;
00192             if (N_Memb[i])
00193             {
00194                /* fprintf(SUMA_STDERR,"%s: Node %d, Normal (pre scale) %f %f %f\n", FuncName, i, RetStrct.NodeNormList[id], RetStrct.NodeNormList[id+1], RetStrct.NodeNormList[id+2]); */
00195                RetStrct.NodeNormList[id] /= N_Memb[i];
00196                RetStrct.NodeNormList[id+1] /= N_Memb[i];
00197                RetStrct.NodeNormList[id+2] /= N_Memb[i];
00198                /* normalize */
00199                nrm = sqrt(RetStrct.NodeNormList[id]*RetStrct.NodeNormList[id] + RetStrct.NodeNormList[id+1]*RetStrct.NodeNormList[id+1] + RetStrct.NodeNormList[id+2]*RetStrct.NodeNormList[id+2]); 
00200                if (nrm) { /* at times nrm is 0. This happened once on a flat surface that was not consistently wound. Nodes that were 
00201                               members of two triangles of opposed normals ended up with a normal (and nrm) of 0 */ 
00202                   RetStrct.NodeNormList[id] /= nrm;
00203                   RetStrct.NodeNormList[id+1] /= nrm;
00204                   RetStrct.NodeNormList[id+2] /= nrm;
00205                } 
00206                
00207                /* fprintf(SUMA_STDERR,"%s: Node %d, N_Memb[i] = %d, nrm = %f\n", FuncName, i, N_Memb[i], nrm); */
00208             }
00209             else
00210             {
00211                ++NotMember;
00212                /*
00213                For some patches (Free Surfer's) such conditions are frequent, spitting out that message becomes old too quick */
00214                /*
00215                fprintf(stdout,"\n%s Warning: Node %d is not a member of any FaceSets, returning unit vector as normal.\n", FuncName, i); 
00216                */
00217                RetStrct.NodeNormList[id] = RetStrct.NodeNormList[id+1] = RetStrct.NodeNormList[id+2] = 1.0;
00218             }
00219          }
00220       if (NotMember) {
00221          sprintf (stmp, "(IGNORE for surface patches\n"
00222                         "%d nodes (%f%% of total) are\n"
00223                         "not members of any FaceSets.\n"
00224                         "Their normals are set to the\n"
00225                         "unit vector.\n", NotMember, (float)NotMember/(float)N_NodeList*100.0);
00226          SUMA_SL_Warn(stmp);
00227       }
00228       
00229    if (N_Memb) SUMA_free(N_Memb);
00230    if (Index) SUMA_free(Index);
00231    SUMA_RETURN (RetStrct);
00232 }/*SUMA_SurfNorm*/

int SUMA_THD_handedness THD_3dim_dataset   dset
 

a copy of THD_handedness from ../thd_rotangles.c Dunno why the original was giving me pain linking ...

Definition at line 8 of file SUMA_VolData.c.

References THD_3dim_dataset::daxes, ISVALID_DSET, LOAD_ZERO_MAT, THD_mat33::mat, MAT_DET, q, SUMA_RETURN, THD_dataxes::xxorient, THD_dataxes::yyorient, and THD_dataxes::zzorient.

Referenced by SUMA_VolParFromDset().

00009 {
00010    THD_dataxes * dax ;
00011    THD_mat33 q ;
00012    int col ;
00013    float val ;
00014 
00015 
00016    if( !ISVALID_DSET(dset) ) SUMA_RETURN(1) ;
00017 
00018    LOAD_ZERO_MAT(q) ;
00019    dax = dset->daxes ;
00020 
00021    col = 0 ;
00022    switch( dax->xxorient ){
00023       case 0: q.mat[0][col] =  1.0 ; break ;
00024       case 1: q.mat[0][col] = -1.0 ; break ;
00025       case 2: q.mat[1][col] = -1.0 ; break ;
00026       case 3: q.mat[1][col] =  1.0 ; break ;
00027       case 4: q.mat[2][col] =  1.0 ; break ;
00028       case 5: q.mat[2][col] = -1.0 ; break ;
00029    }
00030 
00031    col = 1 ;
00032    switch( dax->yyorient ){
00033       case 0: q.mat[0][col] =  1.0 ; break ;
00034       case 1: q.mat[0][col] = -1.0 ; break ;
00035       case 2: q.mat[1][col] = -1.0 ; break ;
00036       case 3: q.mat[1][col] =  1.0 ; break ;
00037       case 4: q.mat[2][col] =  1.0 ; break ;
00038       case 5: q.mat[2][col] = -1.0 ; break ;
00039    }
00040 
00041    col = 2 ;
00042    switch( dax->zzorient ){
00043       case 0: q.mat[0][col] =  1.0 ; break ;
00044       case 1: q.mat[0][col] = -1.0 ; break ;
00045       case 2: q.mat[1][col] = -1.0 ; break ;
00046       case 3: q.mat[1][col] =  1.0 ; break ;
00047       case 4: q.mat[2][col] =  1.0 ; break ;
00048       case 5: q.mat[2][col] = -1.0 ; break ;
00049    }
00050 
00051    val = MAT_DET(q) ;
00052    if( val > 0.0 ) SUMA_RETURN( 1) ;  /* right handed */
00053    else            SUMA_RETURN(-1) ;  /* left handed */
00054 }

SUMA_Boolean SUMA_UnRegisterDO int    dov_id,
SUMA_SurfaceViewer   cSV
 

remove DO with I.D. dov_id from RegisteredDO list of that current viewer removal of dov_id element is done by replacing it with the last entry in RegisteredDO list. If not found, nothing happens.

Definition at line 421 of file SUMA_DOmanip.c.

References i, SUMA_SurfaceObject::idcode_str, LocalHead, SUMA_SurfaceViewer::N_DO, SUMA_DO::OP, SUMA_SurfaceViewer::RegisteredDO, SUMA_Boolean, SUMA_EmptyColorList(), SUMA_ENTRY, SUMA_isSO(), SUMA_RETURN, and SUMA_UpdateViewerTitle().

Referenced by SUMA_SwitchSO(), and SUMA_SwitchState().

00422 {
00423    int i;
00424    static char FuncName[]={"SUMA_UnRegisterDO"};
00425    SUMA_Boolean LocalHead = NOPE;
00426    
00427    SUMA_ENTRY;
00428 
00429    /* check to see if dov_id exists */
00430    i = 0;
00431    while (i < cSV->N_DO) {
00432       if (cSV->RegisteredDO[i] == dov_id) {
00433          /* found, replace it by the last in the list */
00434          cSV->RegisteredDO[i] = cSV->RegisteredDO[cSV->N_DO-1];
00435          /*remove the last element of the list */
00436          cSV->RegisteredDO[cSV->N_DO-1] = 0;
00437          cSV->N_DO -= 1; 
00438          
00439          /* empty the ColorList for this surface */
00440          if (SUMA_isSO(SUMAg_DOv[dov_id])) {
00441             SUMA_SurfaceObject *SO = NULL;
00442             if (LocalHead) fprintf (SUMA_STDERR,"%s: Emptying ColorList ...\n", FuncName);
00443             SO = (SUMA_SurfaceObject *)SUMAg_DOv[dov_id].OP;
00444             if (!SUMA_EmptyColorList (cSV, SO->idcode_str)) {
00445                fprintf (SUMA_STDERR,"Error %s: Failed in SUMA_EmptyColorList\n", FuncName);
00446                SUMA_RETURN(NOPE);
00447             }
00448          }
00449          
00450          if (LocalHead) {
00451             fprintf (SUMA_STDERR,"%s: RegisteredDO is now:\n", FuncName);
00452             for (i=0; i< cSV->N_DO; ++i) {
00453                fprintf(SUMA_STDERR,"RegisteredDO[%d] = %d\t", i, cSV->RegisteredDO[i]);
00454             }
00455             fprintf(SUMA_STDERR,"\n");
00456          }
00457 
00458          /* update the title bar */
00459          SUMA_UpdateViewerTitle(cSV);   
00460 
00461 
00462          SUMA_RETURN(YUP);
00463       }
00464       ++i;
00465    }
00466    /* Not found, nothing happens */
00467    
00468    if (LocalHead) {
00469       fprintf (SUMA_STDERR,"%s: RegisteredDO is now:\n", FuncName);
00470       for (i=0; i< cSV->N_DO; ++i) {
00471          fprintf(SUMA_STDERR,"RegisteredDO[%d] = %d\t", i, cSV->RegisteredDO[i]);
00472       }
00473       fprintf(SUMA_STDERR,"\n");
00474    }
00475    
00476    SUMA_RETURN(YUP); 
00477 }

SUMA_VOLPAR* SUMA_VolPar_Attr char *    volparent_name
 

Definition at line 584 of file SUMA_VolData.c.

References LocalHead, SUMA_Boolean, SUMA_ENTRY, SUMA_RETURN, SUMA_SL_Err, SUMA_VolParFromDset(), THD_delete_3dim_dataset(), and THD_open_dataset().

Referenced by main(), SUMA_Load_Surface_Object_eng(), and SUMA_process_NIML_data().

00585 {
00586    ATR_float *atr;
00587    static char FuncName[]={"SUMA_VolPar_Attr"};
00588    SUMA_VOLPAR *VP;
00589    THD_3dim_dataset *dset;
00590    int ii;
00591    MCW_idcode idcode;
00592    SUMA_Boolean LocalHead = NOPE;
00593       
00594    SUMA_ENTRY;
00595 
00596    /* read the header of the parent volume */
00597    dset = THD_open_dataset(volparent_name);
00598    if (dset == NULL) {
00599       fprintf (SUMA_STDERR,"Error %s: Could not read %s\n", FuncName, volparent_name);
00600       SUMA_RETURN (NULL);
00601    }
00602    
00603    VP = SUMA_VolParFromDset(dset);
00604    if (!VP) {
00605       SUMA_SL_Err("Failed in SUMA_VolParFromDset");
00606    }
00607 
00608    /* now free the dset pointer */
00609    THD_delete_3dim_dataset( dset , False ) ;
00610    
00611    SUMA_RETURN (VP);
00612 }

char* SUMA_VolPar_Info SUMA_VOLPAR   VP
 

Form a string containing the info of the volume parent.

Parameters:
VP  (SUMA_VOLPAR *) Volume parent structure.
Returns:
s (char *) pointer to NULL terminated string containing surface info. It is your responsability to free it.
See also:
SUMA_Show_VolPar

Definition at line 624 of file SUMA_VolData.c.

References SUMA_VOLPAR::dirname, SUMA_VOLPAR::dx, SUMA_VOLPAR::dy, SUMA_VOLPAR::dz, SUMA_VOLPAR::filecode, SUMA_VOLPAR::Hand, SUMA_VOLPAR::idcode_str, SUMA_VOLPAR::isanat, SUMA_VOLPAR::nx, SUMA_VOLPAR::ny, SUMA_VOLPAR::nz, SUMA_VOLPAR::prefix, SUMA_VOLPAR::ROTATE_CENTER_BASE, SUMA_VOLPAR::ROTATE_CENTER_OLD, SUMA_VOLPAR::ROTATE_MATVEC, SUMA_STRING::s, SUMA_ENTRY, SUMA_free, SUMA_RETURN, SUMA_StringAppend(), SUMA_StringAppend_va(), SUMA_VOLPAR::TAGALIGN_MATVEC, SUMA_VOLPAR::vol_idcode_date, SUMA_VOLPAR::vol_idcode_str, SUMA_VOLPAR::VOLREG_CENTER_BASE, SUMA_VOLPAR::VOLREG_CENTER_OLD, SUMA_VOLPAR::VOLREG_MATVEC, SUMA_VOLPAR::xorg, SUMA_VOLPAR::xxorient, SUMA_VOLPAR::yorg, SUMA_VOLPAR::yyorient, SUMA_VOLPAR::zorg, and SUMA_VOLPAR::zzorient.

Referenced by SUMA_Show_VolPar(), and SUMA_SurfaceObject_Info().

00625 {
00626    static char FuncName[]={"SUMA_VolPar_Info"};
00627    char stmp[1000], *s=NULL;
00628    SUMA_STRING *SS = NULL;
00629    
00630    SUMA_ENTRY;
00631 
00632    SS = SUMA_StringAppend (NULL, NULL);
00633    
00634    if (VP) { 
00635       sprintf (stmp,"\nVP contents:\n");
00636       SS = SUMA_StringAppend (SS, stmp);
00637       sprintf (stmp,"prefix: %s\tfilecode: %s\tdirname: %s\nId code str:%s\tID code date: %s\n", \
00638          VP->prefix, VP->filecode, VP->dirname, VP->vol_idcode_str, VP->vol_idcode_date);
00639       SS = SUMA_StringAppend (SS, stmp);
00640       if (VP->idcode_str) SS = SUMA_StringAppend (SS, "IDcode is NULL\n");
00641       else SS = SUMA_StringAppend_va (SS, "IDcode: %s\n", VP->idcode_str);
00642       
00643       sprintf (stmp,"isanat: %d\n", VP->isanat);
00644       SS = SUMA_StringAppend (SS, stmp);
00645       sprintf (stmp,"Orientation: %d %d %d\n", \
00646          VP->xxorient, VP->yyorient, VP->zzorient);
00647       if (VP->Hand == 1) SS = SUMA_StringAppend (SS, "Right Hand Coordinate System.\n");
00648       else if (VP->Hand == -1) SS = SUMA_StringAppend (SS, "Left Hand Coordinate System.\n");
00649       else SS = SUMA_StringAppend (SS, "No hand coordinate system!\n");
00650       
00651       SS = SUMA_StringAppend (SS, stmp);
00652       sprintf (stmp,"Origin: %f %f %f\n", \
00653          VP->xorg, VP->yorg, VP->zorg);
00654       SS = SUMA_StringAppend (SS, stmp);
00655       sprintf (stmp,"Delta: %f %f %f\n", \
00656          VP->dx, VP->dy, VP->dz);
00657       SS = SUMA_StringAppend (SS, stmp);
00658       sprintf (stmp,"N: %d %d %d\n",\
00659          VP->nx, VP->ny, VP->nz);
00660       SS = SUMA_StringAppend (SS, stmp);
00661 
00662       if (VP->ROTATE_MATVEC != NULL) {
00663          sprintf (stmp,"VP->ROTATE_MATVEC = \n\tMrot\tDelta\n");
00664          SS = SUMA_StringAppend (SS, stmp);
00665          sprintf (stmp,"|%f\t%f\t%f|\t|%f|\n", \
00666          VP->ROTATE_MATVEC[0], VP->ROTATE_MATVEC[1], VP->ROTATE_MATVEC[2], VP->ROTATE_MATVEC[3]); 
00667          SS = SUMA_StringAppend (SS, stmp);
00668          sprintf (stmp,"|%f\t%f\t%f|\t|%f|\n", \
00669          VP->ROTATE_MATVEC[4], VP->ROTATE_MATVEC[5], VP->ROTATE_MATVEC[6], VP->ROTATE_MATVEC[7]);
00670          SS = SUMA_StringAppend (SS, stmp);
00671          sprintf (stmp,"|%f\t%f\t%f|\t|%f|\n", \
00672          VP->ROTATE_MATVEC[8], VP->ROTATE_MATVEC[9], VP->ROTATE_MATVEC[10], VP->ROTATE_MATVEC[11]);
00673          SS = SUMA_StringAppend (SS, stmp);
00674       } else {
00675          sprintf (stmp,"VP->ROTATE_MATVEC = NULL\n");
00676          SS = SUMA_StringAppend (SS, stmp);
00677       }      
00678       if (VP->ROTATE_CENTER_OLD != NULL) {
00679          sprintf (stmp,"VP->ROTATE_CENTER_OLD = %f, %f, %f\n", \
00680            VP->ROTATE_CENTER_OLD[0], VP->ROTATE_CENTER_OLD[1], VP->ROTATE_CENTER_OLD[2]); 
00681          SS = SUMA_StringAppend (SS, stmp);
00682       }else {
00683          sprintf (stmp,"VP->ROTATE_CENTER_OLD = NULL\n");
00684          SS = SUMA_StringAppend (SS, stmp);
00685       }
00686       if (VP->ROTATE_CENTER_BASE != NULL) {
00687          sprintf (stmp,"VP->ROTATE_CENTER_BASE = %f, %f, %f\n", \
00688             VP->ROTATE_CENTER_BASE[0], VP->ROTATE_CENTER_BASE[1], VP->ROTATE_CENTER_BASE[2]); 
00689          SS = SUMA_StringAppend (SS, stmp);
00690       } else {
00691          sprintf (stmp,"VP->ROTATE_CENTER_BASE = NULL\n");
00692          SS = SUMA_StringAppend (SS, stmp);
00693       }      
00694       if (VP->TAGALIGN_MATVEC != NULL) {
00695          sprintf (stmp,"VP->TAGALIGN_MATVEC = \n\tMrot\tDelta\n");
00696          SS = SUMA_StringAppend (SS, stmp);
00697          sprintf (stmp,"|%f\t%f\t%f|\t|%f|\n", \
00698          VP->TAGALIGN_MATVEC[0], VP->TAGALIGN_MATVEC[1], VP->TAGALIGN_MATVEC[2], VP->TAGALIGN_MATVEC[3]); 
00699          SS = SUMA_StringAppend (SS, stmp);
00700          sprintf (stmp,"|%f\t%f\t%f|\t|%f|\n", \
00701          VP->TAGALIGN_MATVEC[4], VP->TAGALIGN_MATVEC[5], VP->TAGALIGN_MATVEC[6], VP->TAGALIGN_MATVEC[7]);
00702          SS = SUMA_StringAppend (SS, stmp);
00703          sprintf (stmp,"|%f\t%f\t%f|\t|%f|\n", \
00704          VP->TAGALIGN_MATVEC[8], VP->TAGALIGN_MATVEC[9], VP->TAGALIGN_MATVEC[10], VP->TAGALIGN_MATVEC[11]);
00705          SS = SUMA_StringAppend (SS, stmp);
00706       } else {
00707          sprintf (stmp,"VP->TAGALIGN_MATVEC = NULL\n");
00708          SS = SUMA_StringAppend (SS, stmp);
00709       }      
00710       
00711       if (VP->VOLREG_MATVEC != NULL) {
00712          sprintf (stmp,"VP->VOLREG_MATVEC = \n\tMrot\tDelta\n");
00713          SS = SUMA_StringAppend (SS, stmp);
00714          sprintf (stmp,"|%f\t%f\t%f|\t|%f|\n", \
00715          VP->VOLREG_MATVEC[0], VP->VOLREG_MATVEC[1], VP->VOLREG_MATVEC[2], VP->VOLREG_MATVEC[3]); 
00716          SS = SUMA_StringAppend (SS, stmp);
00717          sprintf (stmp,"|%f\t%f\t%f|\t|%f|\n", \
00718          VP->VOLREG_MATVEC[4], VP->VOLREG_MATVEC[5], VP->VOLREG_MATVEC[6], VP->VOLREG_MATVEC[7]);
00719          SS = SUMA_StringAppend (SS, stmp);
00720          sprintf (stmp,"|%f\t%f\t%f|\t|%f|\n", \
00721          VP->VOLREG_MATVEC[8], VP->VOLREG_MATVEC[9], VP->VOLREG_MATVEC[10], VP->VOLREG_MATVEC[11]);
00722          SS = SUMA_StringAppend (SS, stmp);
00723       } else {
00724          sprintf (stmp,"VP->VOLREG_MATVEC = NULL\n");
00725          SS = SUMA_StringAppend (SS, stmp);
00726       }
00727 
00728       if (VP->VOLREG_CENTER_OLD != NULL) {
00729          sprintf (stmp,"VP->VOLREG_CENTER_OLD = %f, %f, %f\n", \
00730            VP->VOLREG_CENTER_OLD[0], VP->VOLREG_CENTER_OLD[1], VP->VOLREG_CENTER_OLD[2]); 
00731          SS = SUMA_StringAppend (SS, stmp);
00732       }else {
00733          sprintf (stmp,"VP->VOLREG_CENTER_OLD = NULL\n");
00734          SS = SUMA_StringAppend (SS, stmp);
00735       }
00736 
00737       if (VP->VOLREG_CENTER_BASE != NULL) {
00738          sprintf (stmp,"VP->VOLREG_CENTER_BASE = %f, %f, %f\n", \
00739             VP->VOLREG_CENTER_BASE[0], VP->VOLREG_CENTER_BASE[1], VP->VOLREG_CENTER_BASE[2]); 
00740          SS = SUMA_StringAppend (SS, stmp);
00741       } else {
00742          sprintf (stmp,"VP->VOLREG_CENTER_BASE = NULL\n");
00743          SS = SUMA_StringAppend (SS, stmp);
00744       }
00745    }else{
00746       sprintf (stmp, "NULL Volume Parent Pointer.\n");
00747       SS = SUMA_StringAppend (SS, stmp);
00748    }
00749    
00750    /* clean SS */
00751    SS = SUMA_StringAppend (SS, NULL);
00752    /* copy s pointer and free SS */
00753    s = SS->s;
00754    SUMA_free(SS); 
00755    
00756    SUMA_RETURN (s);
00757 }

SUMA_VOLPAR* SUMA_VolParFromDset THD_3dim_dataset   dset
 

Definition at line 399 of file SUMA_VolData.c.

References MCW_idcode::date, THD_3dim_dataset::daxes, THD_3dim_dataset::dblk, SUMA_VOLPAR::dirname, DSET_DIRNAME, DSET_DX, DSET_DY, DSET_DZ, DSET_FILECODE, DSET_NX, DSET_NY, DSET_NZ, DSET_PREFIX, DSET_XORG, DSET_YORG, DSET_ZORG, SUMA_VOLPAR::dx, SUMA_VOLPAR::dy, SUMA_VOLPAR::dz, SUMA_VOLPAR::filecode, ATR_float::fl, SUMA_VOLPAR::Hand, THD_3dim_dataset::idcode, SUMA_VOLPAR::isanat, ISANAT, LocalHead, ATR_float::nfl, SUMA_VOLPAR::nx, SUMA_VOLPAR::ny, SUMA_VOLPAR::nz, SUMA_VOLPAR::prefix, SUMA_VOLPAR::ROTATE_CENTER_BASE, SUMA_VOLPAR::ROTATE_CENTER_OLD, SUMA_VOLPAR::ROTATE_MATVEC, MCW_idcode::str, SUMA_Alloc_VolPar(), SUMA_Boolean, SUMA_calloc, SUMA_ENTRY, SUMA_Free_VolPar(), SUMA_malloc, SUMA_RETURN, SUMA_THD_handedness(), SUMA_VOLPAR::TAGALIGN_MATVEC, THD_find_float_atr(), SUMA_VOLPAR::vol_idcode_date, SUMA_VOLPAR::vol_idcode_str, SUMA_VOLPAR::VOLREG_CENTER_BASE, SUMA_VOLPAR::VOLREG_CENTER_OLD, SUMA_VOLPAR::VOLREG_MATVEC, SUMA_VOLPAR::xorg, SUMA_VOLPAR::xxorient, THD_dataxes::xxorient, SUMA_VOLPAR::yorg, SUMA_VOLPAR::yyorient, THD_dataxes::yyorient, SUMA_VOLPAR::zorg, SUMA_VOLPAR::zzorient, and THD_dataxes::zzorient.

Referenced by SUMA_VolPar_Attr().

00400 {
00401    ATR_float *atr;
00402    static char FuncName[]={"SUMA_VolParFromDset"};
00403    SUMA_VOLPAR *VP;
00404    int ii;
00405    MCW_idcode idcode;
00406    SUMA_Boolean LocalHead = NOPE;
00407       
00408    SUMA_ENTRY;
00409 
00410    /* read the header of the parent volume */
00411    if (dset == NULL) {
00412       fprintf (SUMA_STDERR,"Error %s:\nNULL dset\n", FuncName);
00413       SUMA_RETURN (NULL);
00414    }
00415    
00416    /* allocate for VP */
00417    VP = SUMA_Alloc_VolPar();
00418    if (VP == NULL) {
00419       fprintf(SUMA_STDERR,"Error %s: Failed in SUMA_Alloc_VolPar\n", FuncName);
00420       SUMA_RETURN (NULL);
00421    }
00422    
00423    /* retain pertinent info */
00424    VP->isanat = ISANAT(dset);
00425    VP->nx = DSET_NX(dset);
00426    VP->ny = DSET_NY(dset);
00427    VP->nz = DSET_NZ(dset);
00428    VP->dx = DSET_DX(dset);
00429    VP->dy = DSET_DY(dset);
00430    VP->dz = DSET_DZ(dset);
00431    VP->xorg = DSET_XORG(dset);
00432    VP->yorg = DSET_YORG(dset);
00433    VP->zorg = DSET_ZORG(dset);
00434    ii = strlen(DSET_PREFIX(dset));
00435    VP->prefix = (char *)SUMA_malloc(ii+1);
00436    ii = strlen(DSET_FILECODE(dset));
00437    VP->filecode = (char *)SUMA_malloc(ii+1);
00438    ii = strlen(DSET_DIRNAME(dset));
00439    VP->dirname = (char *)SUMA_malloc(ii+1);
00440    ii = strlen(dset->idcode.str);
00441    VP->vol_idcode_str = (char *)SUMA_malloc(ii+1);
00442    ii = strlen(dset->idcode.date);
00443    VP->vol_idcode_date = (char *)SUMA_malloc(ii+1);
00444    if (VP->prefix == NULL || VP->filecode == NULL || VP->vol_idcode_date == NULL || VP->dirname == NULL || VP->vol_idcode_str == NULL) {
00445       fprintf(SUMA_STDERR,"Error %s: Failed to allocate for strings. Kill me, please.\n", FuncName);
00446       SUMA_Free_VolPar(VP);
00447       SUMA_RETURN (NULL);
00448    }
00449    VP->prefix = strcpy(VP->prefix, DSET_PREFIX(dset));
00450    VP->filecode = strcpy(VP->filecode, DSET_FILECODE(dset));
00451    VP->dirname = strcpy(VP->dirname, DSET_DIRNAME(dset));
00452    VP->vol_idcode_str = strcpy(VP->vol_idcode_str, dset->idcode.str);
00453    VP->vol_idcode_date = strcpy(VP->vol_idcode_date, dset->idcode.date);
00454    VP->xxorient = dset->daxes->xxorient;
00455    VP->yyorient = dset->daxes->yyorient;
00456    VP->zzorient = dset->daxes->zzorient;
00457 
00458    if (LocalHead) {      
00459       fprintf (SUMA_STDERR,"%s: dset->idcode_str = %s\n", FuncName, dset->idcode.str);
00460       fprintf (SUMA_STDERR,"%s: VP->vol_idcode_str = %s\n", FuncName, VP->vol_idcode_str);
00461    }
00462    /* Get the 3drotate matrix if possible*/
00463    atr = THD_find_float_atr( dset->dblk , "ROTATE_MATVEC_000000" ) ;
00464    if (atr == NULL) {
00465       VP->ROTATE_MATVEC = NULL;
00466    }else {
00467       VP->ROTATE_MATVEC = (float *)SUMA_calloc(12, sizeof(float));
00468       if (VP->ROTATE_MATVEC != NULL) {
00469          if (atr->nfl == 12) {
00470             for (ii=0; ii<12; ++ii) VP->ROTATE_MATVEC[ii] = atr->fl[ii];
00471          } else {   
00472             fprintf(SUMA_STDERR,"Error %s: ROTATE_MATVEC does not have 12 elements.\n", FuncName);
00473          }
00474       } else {
00475          fprintf(SUMA_STDERR,"Error %s: Failed to allocate for VP->ROTATE_MATVEC\n", FuncName);
00476       }
00477    }
00478    
00479    /* Get the tagalign matrix if possible*/
00480    atr = THD_find_float_atr( dset->dblk , "TAGALIGN_MATVEC" ) ;
00481    if (atr == NULL) {
00482       VP->TAGALIGN_MATVEC = NULL;
00483    }else {
00484       VP->TAGALIGN_MATVEC = (float *)SUMA_calloc(12, sizeof(float));
00485       if (VP->TAGALIGN_MATVEC != NULL) {
00486          if (atr->nfl == 12) {
00487             for (ii=0; ii<12; ++ii) VP->TAGALIGN_MATVEC[ii] = atr->fl[ii];
00488          } else {   
00489             fprintf(SUMA_STDERR,"Error %s: TAGALIGN_MATVEC does not have 12 elements.\n", FuncName);
00490          }
00491       } else {
00492          fprintf(SUMA_STDERR,"Error %s: Failed to allocate for VP->TAGALIGN_MATVEC\n", FuncName);
00493       }
00494    }
00495    
00496    /* Get the volreg matrix if possible*/
00497    atr = THD_find_float_atr( dset->dblk , "VOLREG_MATVEC_000000" ) ;
00498    if (atr == NULL) {
00499       VP->VOLREG_MATVEC = NULL;
00500    }else {
00501       VP->VOLREG_MATVEC = (float *)SUMA_calloc(12, sizeof(float));
00502       if (VP->VOLREG_MATVEC != NULL) {
00503          if (atr->nfl == 12) {
00504             for (ii=0; ii<12; ++ii) VP->VOLREG_MATVEC[ii] = atr->fl[ii];
00505          } else {   
00506             fprintf(SUMA_STDERR,"Error %s: VOLREG_MATVEC_000000 does not have 12 elements.\n", FuncName);
00507          }
00508       } else {
00509          fprintf(SUMA_STDERR,"Error %s: Failed to allocate for VP->VOLREG_MATVEC\n", FuncName);
00510       }
00511    }
00512    /* Get the center base coordinates */
00513    atr = THD_find_float_atr( dset->dblk , "VOLREG_CENTER_BASE");
00514    if (atr == NULL) {
00515       VP->VOLREG_CENTER_BASE = NULL;
00516    } else {
00517       VP->VOLREG_CENTER_BASE = (float *)SUMA_calloc(3, sizeof(float));
00518       if (VP->VOLREG_CENTER_BASE != NULL) {
00519          if (atr->nfl == 3) {
00520             for (ii=0; ii<3; ++ii) VP->VOLREG_CENTER_BASE[ii] = atr->fl[ii];
00521          } else {   
00522             fprintf(SUMA_STDERR,"Error %s: VOLREG_CENTER_BASE does not have 12 elements.\n", FuncName);
00523          }
00524       } else {
00525          fprintf(SUMA_STDERR,"Error %s: Failed to allocate for VP->VOLREG_CENTER_BASE\n", FuncName);
00526       }
00527    }
00528    /* VOLREG_CENTER_OLD  */
00529    atr = THD_find_float_atr( dset->dblk , "VOLREG_CENTER_OLD");
00530    if (atr == NULL) {
00531       VP->VOLREG_CENTER_OLD = NULL;
00532    } else {
00533       VP->VOLREG_CENTER_OLD = (float *)SUMA_calloc(3, sizeof(float));
00534       if (VP->VOLREG_CENTER_OLD != NULL) {
00535          if (atr->nfl == 3) {
00536             for (ii=0; ii<3; ++ii) VP->VOLREG_CENTER_OLD[ii] = atr->fl[ii];
00537          } else {   
00538             fprintf(SUMA_STDERR,"Error %s: VOLREG_CENTER_OLD does not have 12 elements.\n", FuncName);
00539          }
00540       } else {
00541          fprintf(SUMA_STDERR,"Error %s: Failed to allocate for VP->VOLREG_CENTER_OLD\n", FuncName);
00542       }
00543    }
00544    
00545    /* Get the center base coordinates */
00546    atr = THD_find_float_atr( dset->dblk , "ROTATE_CENTER_BASE");
00547    if (atr == NULL) {
00548       VP->ROTATE_CENTER_BASE = NULL;
00549    } else {
00550       VP->ROTATE_CENTER_BASE = (float *)SUMA_calloc(3, sizeof(float));
00551       if (VP->ROTATE_CENTER_BASE != NULL) {
00552          if (atr->nfl == 3) {
00553             for (ii=0; ii<3; ++ii) VP->ROTATE_CENTER_BASE[ii] = atr->fl[ii];
00554          } else {   
00555             fprintf(SUMA_STDERR,"Error %s: ROTATE_CENTER_BASE does not have 12 elements.\n", FuncName);
00556          }
00557       } else {
00558          fprintf(SUMA_STDERR,"Error %s: Failed to allocate for VP->ROTATE_CENTER_BASE\n", FuncName);
00559       }
00560    }
00561    /* ROTATE_CENTER_OLD */
00562    atr = THD_find_float_atr( dset->dblk , "ROTATE_CENTER_OLD");
00563    if (atr == NULL) {
00564       VP->ROTATE_CENTER_OLD = NULL;
00565    } else {
00566       VP->ROTATE_CENTER_OLD = (float *)SUMA_calloc(3, sizeof(float));
00567       if (VP->ROTATE_CENTER_OLD != NULL) {
00568          if (atr->nfl == 3) {
00569             for (ii=0; ii<3; ++ii) VP->ROTATE_CENTER_OLD[ii] = atr->fl[ii];
00570          } else {   
00571             fprintf(SUMA_STDERR,"Error %s: ROTATE_CENTER_OLD does not have 12 elements.\n", FuncName);
00572          }
00573       } else {
00574          fprintf(SUMA_STDERR,"Error %s: Failed to allocate for VP->ROTATE_CENTER_OLD\n", FuncName);
00575       }
00576    }
00577 
00578    /* handedness */
00579    VP->Hand = SUMA_THD_handedness( dset );
00580    
00581    SUMA_RETURN (VP);
00582 }

SUMA_DOMAIN_KINSHIPS SUMA_WhatAreYouToMe SUMA_SurfaceObject   SO1,
SUMA_SurfaceObject   SO2
 

ans = SUMA_WhatAreYouToMe (SUMA_SurfaceObject *SO1, SUMA_SurfaceObject *SO2); returns a code for the kinship between two surfaces:

SO1->idcode_str = SO2->idcode_str (in this case SO1 = SO2) or SO1->LocalDomainParentID = SO2->idcode_str (SO2 is the mapping reference of SO1) or SO1->idcode_str = SO2->LocalDomainParentID (SO1 is the mapping reference of SO2) SO1->LocalDomainParentID = SO2->LocalDomainParentID (SO1 and SO2 have the same mapping reference) or SO1->DomainGrandParentID = SO2->idcode_str (SO2 is the granddaddy of SO1) or SO1->idcode_str = SO2->DomainGrandParentID (SO1 is the granddaddy of SO2) or SO1->DomainGrandParentID = SO2->DomainGrandParentID (SO1 and SO2 have the same granddaddy)

See also:
definition of SUMA_DOMAIN_KINSHIPS and , SUMA_DomainKinships_String

Definition at line 1003 of file SUMA_DOmanip.c.

References SUMA_SurfaceObject::DomainGrandParentID, SUMA_SurfaceObject::idcode_str, SUMA_SurfaceObject::LocalDomainParentID, LocalHead, SUMA_Boolean, SUMA_DOMAIN_KINSHIPS, SUMA_DOMAINS_NOT_RELATED, SUMA_ENTRY, SUMA_GPSO1_is_GPSO2, SUMA_LDPSO1_is_LDPSO2, SUMA_LH, SUMA_RETURN, SUMA_SO1_is_GPSO2, SUMA_SO1_is_LDPSO2, SUMA_SO1_is_SO2, SUMA_SO2_is_GPSO1, and SUMA_SO2_is_LDPSO1.

Referenced by SUMA_isRelated(), and SUMA_RedisplayAllShowing().

01004 {
01005    static char FuncName[]={"SUMA_WhatAreYouToMe"};
01006    SUMA_Boolean LocalHead = NOPE;
01007    
01008    SUMA_ENTRY;
01009    
01010    if (!SO1->idcode_str || !SO2->idcode_str) {
01011       fprintf (SUMA_STDERR, "Error %s: NULL idcode_str.\n", FuncName);
01012       SUMA_RETURN (SUMA_DOMAINS_NOT_RELATED);
01013    }
01014    
01015    if (strcmp (SO1->idcode_str, SO2->idcode_str) == 0) {
01016       /* SO1 = SO2 */
01017       SUMA_LH(SUMA_DomainKinships_String (SUMA_SO1_is_SO2));
01018       SUMA_RETURN (SUMA_SO1_is_SO2);
01019    }
01020    
01021    if (SO1->LocalDomainParentID) {
01022       if (strcmp (SO1->LocalDomainParentID, SO2->idcode_str) == 0) {
01023          /* SO2 is the local domain parent of SO1 */
01024          SUMA_LH(SUMA_DomainKinships_String (SUMA_SO2_is_LDPSO1));
01025          SUMA_RETURN (SUMA_SO2_is_LDPSO1);
01026       }
01027    }
01028    
01029    if (SO2->LocalDomainParentID) {
01030       if (strcmp (SO1->idcode_str, SO2->LocalDomainParentID) == 0) {
01031           /* SO1 is the local domain parent of SO2 */
01032           SUMA_LH(SUMA_DomainKinships_String (SUMA_SO1_is_LDPSO2));
01033           SUMA_RETURN (SUMA_SO1_is_LDPSO2);
01034       }
01035    }
01036    
01037    if (SO1->LocalDomainParentID && SO2->LocalDomainParentID) {
01038       if (strcmp (SO1->LocalDomainParentID, SO2->LocalDomainParentID) == 0) {
01039          /* SO1 and SO2 have the same local domain parent */
01040          SUMA_LH(SUMA_DomainKinships_String (SUMA_LDPSO1_is_LDPSO2));
01041          SUMA_RETURN (SUMA_LDPSO1_is_LDPSO2);
01042       }
01043    }
01044    
01045    if (SO1->DomainGrandParentID && SO2->idcode_str) {
01046       if (strcmp (SO1->DomainGrandParentID, SO2->idcode_str) == 0) {
01047          /* SO2 is the grand daddy of SO1 */
01048          SUMA_LH(SUMA_DomainKinships_String (SUMA_SO2_is_GPSO1));
01049          SUMA_RETURN (SUMA_SO2_is_GPSO1);
01050       }
01051    }
01052    
01053    if (SO1->idcode_str && SO2->DomainGrandParentID) {
01054       if (strcmp (SO1->idcode_str, SO2->DomainGrandParentID) == 0) {
01055          /* SO1 is the grand daddy of SO2 */
01056          SUMA_LH(SUMA_DomainKinships_String (SUMA_SO1_is_GPSO2));
01057          SUMA_RETURN (SUMA_SO1_is_GPSO2);
01058       }
01059    }
01060    
01061    if (SO1->DomainGrandParentID && SO2->DomainGrandParentID) {
01062       if (strcmp (SO1->DomainGrandParentID, SO2->DomainGrandParentID) == 0) {
01063          /* SO1 and SO2 have the same grand daddy */
01064          SUMA_LH(SUMA_DomainKinships_String (SUMA_GPSO1_is_GPSO2));
01065          SUMA_RETURN (SUMA_GPSO1_is_GPSO2);
01066       }
01067    }
01068    
01069    SUMA_LH(SUMA_DomainKinships_String (SUMA_DOMAINS_NOT_RELATED));
01070    SUMA_RETURN (SUMA_DOMAINS_NOT_RELATED);
01071    
01072 }

int SUMA_whichDO char *    idcode,
SUMA_DO   dov,
int    N_dov
 

searches for DO object with an idcode_str equal to idcode It returns the DO's index into dov -1 if nothing was found

Definition at line 680 of file SUMA_DOmanip.c.

References i, SUMA_SegmentDO::idcode_str, SUMA_Axis::idcode_str, SUMA_ROI::idcode_str, SUMA_DRAWN_ROI::idcode_str, SUMA_SurfaceObject::idcode_str, SUMA_ENTRY, SUMA_IS_EMPTY_STR_ATTR, and SUMA_RETURN.

Referenced by SUMA_OpenDrawnROI_NIML(), and SUMA_PrepAddmappableSO().

00681 {
00682    static char FuncName[]={"SUMA_whichDO"};
00683    int i;
00684    SUMA_SurfaceObject *SO = NULL;
00685    SUMA_DRAWN_ROI *dROI = NULL;
00686    SUMA_ROI *ROI = NULL;
00687    SUMA_SegmentDO *sdo = NULL;
00688    SUMA_Axis *sax = NULL;
00689    
00690    SUMA_ENTRY;
00691 
00692    if (SUMA_IS_EMPTY_STR_ATTR(idcode)) { /* might come in as ~ at times */
00693       fprintf(SUMA_STDERR,"Warning %s: NULL idcode.\n", FuncName);
00694       SUMA_RETURN (-1);
00695    }
00696    for (i=0; i< N_dov; ++i) {
00697       switch (dov[i].ObjectType) {
00698          case (SO_type):
00699             SO = (SUMA_SurfaceObject *)dov[i].OP;
00700             if (strcmp(idcode, SO->idcode_str)== 0) {
00701                SUMA_RETURN (i);
00702             }
00703             break;
00704          case (ROIdO_type):
00705             dROI = (SUMA_DRAWN_ROI *)dov[i].OP;
00706             if (strcmp(idcode, dROI->idcode_str)== 0) {
00707                SUMA_RETURN (i);
00708             }
00709             break;
00710          case (ROIO_type):
00711             ROI = (SUMA_ROI *)dov[i].OP;
00712             if (strcmp(idcode, ROI->idcode_str)== 0) {
00713                SUMA_RETURN (i);
00714             }
00715             break;
00716          case (AO_type):
00717             sax = (SUMA_Axis *)dov[i].OP;
00718             if (strcmp(idcode, sax->idcode_str)== 0) {
00719                SUMA_RETURN (i);
00720             }
00721             break;
00722          case (LS_type):
00723             sdo = (SUMA_SegmentDO *)dov[i].OP;
00724             if (strcmp(idcode, sdo->idcode_str)== 0) {
00725                SUMA_RETURN (i);
00726             }
00727             break;
00728          default:
00729             fprintf(SUMA_STDERR,"Warning %s: Object type %d not checked.\n", FuncName, dov[i].ObjectType);
00730             break;
00731       }
00732    }
00733    SUMA_RETURN(-1);
00734 }
 

Powered by Plone

This site conforms to the following standards: