Doxygen Source Code Documentation
afni_suma.c File Reference
#include "mrilib.h"
#include "cs_sort_template.h"
Go to the source code of this file.
Define Documentation
|
Definition at line 234 of file afni_suma.c. Referenced by ISORT_NAME(), and QSREC_NAME(). |
|
Definition at line 235 of file afni_suma.c. |
|
Definition at line 233 of file afni_suma.c. Referenced by ISORT_NAME(), QSORT_NAME(), and QSREC_NAME(). |
|
Definition at line 8 of file afni_suma.c. Referenced by SUMA_add_nodes_ixyz(), and SUMA_add_triangles(). |
|
Definition at line 7 of file afni_suma.c. Referenced by SUMA_add_nodes_ixyz(), and SUMA_add_triangles(). |
Function Documentation
|
Add 1 pitiful node to a surface. -------------------------------------------------------------------- Definition at line 156 of file afni_suma.c. References i, and SUMA_add_nodes_ixyz().
00157 { 00158 SUMA_add_nodes_ixyz( ag , 1 , &i,&x,&y,&z ) ; 00159 } |
|
Definition at line 71 of file afni_suma.c. References ENTRY, EXIT, SUMA_ixyz::id, SUMA_surface::ixyz, SUMA_surface::nall_ixyz, SUMA_surface::num_ixyz, realloc, SUMA_surface::seq, SUMA_surface::sorted, SUMA_EXTEND_FAC, SUMA_EXTEND_NUM, SUMA_MAX_NODES, SUMA_ixyz::x, SUMA_ixyz::y, SUMA_ixyz::z, and zadd. Referenced by process_NIML_SUMA_ixyz(), and SUMA_add_node_ixyz().
00073 { 00074 int ii , nup ; 00075 00076 ENTRY("SUMA_add_nodes_ixyz") ; 00077 00078 if( ag == NULL || nadd < 1 ) EXRETURN ; 00079 if( xadd == NULL || yadd == NULL || zadd == NULL || iadd == NULL ) EXRETURN ; 00080 00081 nup = ag->num_ixyz + nadd ; 00082 00083 if( nup >= SUMA_MAX_NODES ){ /* 07 Sep 2001 */ 00084 fprintf(stderr, 00085 "** SUMA surface can't have more than %d nodes!\n", 00086 SUMA_MAX_NODES-1 ) ; 00087 EXRETURN ; 00088 } 00089 00090 if( nup > ag->nall_ixyz ){ /* extend length of array */ 00091 ag->nall_ixyz = nup = nup*SUMA_EXTEND_FAC + SUMA_EXTEND_NUM ; 00092 ag->ixyz = (SUMA_ixyz *) realloc( (void *)ag->ixyz, sizeof(SUMA_ixyz)*nup ); 00093 if( ag->ixyz == NULL ){ 00094 fprintf(stderr,"SUMA_add_nodes_ixyz: can't malloc!\n"); EXIT(1); 00095 } 00096 } 00097 00098 nup = ag->num_ixyz ; 00099 00100 for( ii=0 ; ii < nadd ; ii++ ){ 00101 ag->ixyz[ii+nup].x = xadd[ii] ; 00102 ag->ixyz[ii+nup].y = yadd[ii] ; 00103 ag->ixyz[ii+nup].z = zadd[ii] ; 00104 ag->ixyz[ii+nup].id = iadd[ii] ; 00105 } 00106 00107 ag->num_ixyz += nadd ; 00108 00109 ag->seq = ag->sorted = 0 ; EXRETURN ; 00110 } |
|
Definition at line 119 of file afni_suma.c. References calloc, ENTRY, EXIT, SUMA_surface::norm, SUMA_surface::num_ixyz, RETURN, THD_fvec3::xyz, and zadd. Referenced by process_NIML_SUMA_node_normals().
00121 { 00122 int ii ; 00123 00124 ENTRY("SUMA_add_norms_xyz") ; 00125 00126 if( ag == NULL || nadd < 1 ) RETURN(-1) ; 00127 if( xadd == NULL || yadd == NULL || zadd == NULL ) RETURN(-1) ; 00128 00129 if( nadd != ag->num_ixyz ){ 00130 fprintf(stderr, "** SUMA surface has %d nodes but %d normals!\n", 00131 ag->num_ixyz, nadd ) ; 00132 RETURN(-1) ; 00133 } 00134 00135 /* if norm is NULL, memory is needed */ 00136 if( ag->norm == NULL ){ 00137 ag->norm = (THD_fvec3 *)calloc(nadd, sizeof(THD_fvec3)); 00138 if( ag->norm == NULL ){ 00139 fprintf(stderr,"SUMA_add_norms_xyz: can't malloc!\n"); EXIT(1); 00140 } 00141 } 00142 00143 for( ii=0 ; ii < nadd ; ii++ ){ 00144 ag->norm[ii].xyz[0] = xadd[ii] ; 00145 ag->norm[ii].xyz[1] = yadd[ii] ; 00146 ag->norm[ii].xyz[2] = zadd[ii] ; 00147 } 00148 00149 RETURN(0) ; 00150 } |
|
Add 1 pitiful triangle to a surface. -------------------------------------------------------------------- Definition at line 197 of file afni_suma.c. References SUMA_add_triangles().
00198 { 00199 SUMA_add_triangles( ag , 1 , &it,&jt,&kt ) ; 00200 } |
|
Add a bunch of triangles (node id triples) to a surface. -------------------------------------------------------------------- Definition at line 165 of file afni_suma.c. References ENTRY, EXIT, SUMA_ijk::id, SUMA_surface::ijk, SUMA_ijk::jd, SUMA_ijk::kd, SUMA_surface::nall_ijk, SUMA_surface::num_ijk, realloc, SUMA_EXTEND_FAC, and SUMA_EXTEND_NUM. Referenced by process_NIML_SUMA_ijk(), and SUMA_add_triangle().
00166 { 00167 int ii , nup ; 00168 00169 ENTRY("SUMA_add_triangles") ; 00170 00171 if( ag == NULL || nadd < 1 ) EXRETURN ; 00172 if( it == NULL || jt == NULL || kt == NULL ) EXRETURN ; 00173 00174 nup = ag->num_ijk + nadd ; 00175 if( nup > ag->nall_ijk ){ /* extend length of array */ 00176 ag->nall_ijk = nup = nup*SUMA_EXTEND_FAC + SUMA_EXTEND_NUM ; 00177 ag->ijk = (SUMA_ijk *) realloc( (void *)ag->ijk , sizeof(SUMA_ijk)*nup ) ; 00178 if( ag->ijk == NULL ){ 00179 fprintf(stderr,"SUMA_add_triangles: can't malloc!\n"); EXIT(1); 00180 } 00181 } 00182 00183 nup = ag->num_ijk ; 00184 for( ii=0 ; ii < nadd ; ii++ ){ 00185 ag->ijk[ii+nup].id = it[ii] ; 00186 ag->ijk[ii+nup].jd = jt[ii] ; 00187 ag->ijk[ii+nup].kd = kt[ii] ; 00188 } 00189 00190 ag->num_ijk += nadd ; EXRETURN ; 00191 } |
|
Create an empty surface description. -------------------------------------------------------------------- Definition at line 14 of file afni_suma.c. References calloc, ENTRY, EXIT, SUMA_surface::idcode, SUMA_surface::idcode_dset, SUMA_surface::idcode_ldp, SUMA_surface::ijk, SUMA_surface::ixyz, SUMA_surface::label, SUMA_surface::label_ldp, malloc, SUMA_surface::nall_ijk, SUMA_surface::nall_ixyz, SUMA_surface::norm, SUMA_surface::num_ijk, SUMA_surface::num_ixyz, RETURN, SUMA_surface::seq, SUMA_surface::seqbase, SUMA_surface::sorted, SUMA_surface::type, SUMA_surface::vn, SUMA_surface::vv, SUMA_surface::xbot, SUMA_surface::xcen, SUMA_surface::xtop, SUMA_surface::ybot, SUMA_surface::ycen, SUMA_surface::ytop, SUMA_surface::zbot, SUMA_surface::zcen, and SUMA_surface::ztop. Referenced by process_NIML_SUMA_ixyz().
00015 { 00016 SUMA_surface *ag ; 00017 00018 ENTRY("SUMA_create_empty_surface") ; 00019 00020 ag = (SUMA_surface *) calloc(1,sizeof(SUMA_surface)) ; 00021 ag->type = SUMA_SURFACE_TYPE ; 00022 00023 ag->num_ixyz = ag->num_ijk = 0 ; 00024 ag->nall_ixyz = ag->nall_ijk = 1 ; 00025 ag->ixyz = (SUMA_ixyz *) malloc(sizeof(SUMA_ixyz)) ; /* space for */ 00026 ag->ijk = (SUMA_ijk *) malloc(sizeof(SUMA_ijk) ) ; /* 1 of each */ 00027 ag->norm = NULL ; ; /* none of this */ 00028 00029 if( ag->ixyz == NULL || ag->ijk == NULL ){ 00030 fprintf(stderr,"SUMA_create_empty_surface: can't malloc!\n"); EXIT(1); 00031 } 00032 00033 ag->idcode[0] = ag->idcode_dset[0] = ag->idcode_ldp[0] = 00034 ag->label[0] = ag->label_ldp[0] = '\0' ; 00035 00036 ag->xbot = ag->ybot = ag->zbot = WAY_BIG ; 00037 ag->xtop = ag->ytop = ag->ztop = -WAY_BIG ; 00038 ag->xcen = ag->ycen = ag->zcen = 0.0 ; 00039 00040 ag->seq = ag->seqbase = ag->sorted = 0 ; /* not sequential; not sorted */ 00041 00042 ag->vv = NULL ; /* 16 Jun 2003 */ 00043 ag->vn = NULL ; /* 22 Jan 2004 */ 00044 00045 RETURN( ag ) ; 00046 } |
|
Throw out some trash (i.e., free the contents of a surface). -------------------------------------------------------------------- Definition at line 52 of file afni_suma.c. References DESTROY_VVLIST, ENTRY, free, SUMA_surface::ijk, SUMA_surface::ixyz, SUMA_surface::norm, SUMA_destroy_vnlist(), SUMA_surface::vn, and SUMA_surface::vv. Referenced by process_NIML_SUMA_ixyz().
00053 { 00054 ENTRY("SUMA_destroy_surface") ; 00055 00056 if( ag == NULL ) EXRETURN ; 00057 if( ag->ixyz != NULL ) free((void *)ag->ixyz) ; 00058 if( ag->ijk != NULL ) free((void *)ag->ijk) ; 00059 if( ag->norm != NULL ) free((void *)ag->norm) ; 00060 00061 if( ag->vv != NULL ) DESTROY_VVLIST(ag->vv) ; 00062 if( ag->vn != NULL ) SUMA_destroy_vnlist(ag->vn) ; 00063 00064 free((void *)ag) ; EXRETURN ; 00065 } |
|
Destroy a SUMA_vnlist struct. --------------------------------------------------------------------------- Definition at line 476 of file afni_suma.c. References free, SUMA_vnlist::nlist, SUMA_vnlist::numnod, SUMA_vnlist::nvox, and SUMA_vnlist::voxijk. Referenced by AFNI_vnlist_func_overlay(), AFNI_vol2surf_func_overlay(), and SUMA_destroy_surface().
00477 { 00478 int ii ; 00479 if( vnlist == NULL ) return ; 00480 if( vnlist->voxijk != NULL ) free( vnlist->voxijk ) ; 00481 if( vnlist->numnod != NULL ) free( vnlist->numnod ) ; 00482 if( vnlist->nlist != NULL ){ 00483 for( ii=0 ; ii < vnlist->nvox ; ii++ ) 00484 if( vnlist->nlist[ii] != NULL ) free( vnlist->nlist[ii] ) ; 00485 free( vnlist->nlist ) ; 00486 } 00487 free( vnlist ) ; 00488 } |
|
Find a node id in a surface, and return its index into the node array; return -1 if not found. ---------------------------------------------------------------------- Definition at line 328 of file afni_suma.c. References SUMA_ixyz::id, SUMA_surface::ixyz, SUMA_surface::num_ixyz, SUMA_surface::seq, SUMA_surface::seqbase, SUMA_surface::sorted, and SUMA_ixyzsort_surface(). Referenced by AFNI_brick_to_mri(), AFNI_process_plugout(), AFNI_sumato_CB(), and process_NIML_Node_ROI().
00329 { 00330 int nn , ii,jj,kk ; 00331 00332 if( ag == NULL || ag->num_ixyz < 1 || target < 0 ) return( -1 ); 00333 00334 if( !ag->sorted ) SUMA_ixyzsort_surface( ag ) ; 00335 00336 if( ag->seq ){ /* node id-s are sequential (the easy case) */ 00337 kk = target - ag->seqbase ; 00338 if( kk >= 0 && kk < ag->num_ixyz ) return( kk ); 00339 return( -1 ); 00340 } 00341 00342 /* node id-s are in increasing order, but not sequential; 00343 so, use binary search to find the node id (if present) */ 00344 00345 ii = 0 ; jj = ag->num_ixyz - 1 ; /* search bounds */ 00346 00347 if( target < ag->ixyz[0].id ) return( -1 ); /* not present */ 00348 else if( target == ag->ixyz[0].id ) return( ii ); /* at start! */ 00349 00350 if( target > ag->ixyz[jj].id ) return( -1 ); /* not present */ 00351 else if( target == ag->ixyz[jj].id ) return( jj ); /* at end! */ 00352 00353 while( jj - ii > 1 ){ /* while search bounds not too close */ 00354 00355 kk = (ii+jj) / 2 ; /* midway between search bounds */ 00356 00357 nn = ag->ixyz[kk].id - target ; 00358 if( nn == 0 ) return( kk ); /* AHA! */ 00359 00360 if( nn < 0 ) ii = kk ; /* kk before target => bottom = kk */ 00361 else jj = kk ; /* kk after target => top = kk */ 00362 } 00363 00364 return( -1 ); 00365 } |
|
Sort the nodes by id-s, and mark if the id-s are sequential. -------------------------------------------------------------------- Definition at line 245 of file afni_suma.c. References ENTRY, SUMA_ixyz::id, SUMA_surface::ixyz, SUMA_surface::num_ixyz, SUMA_surface::seq, SUMA_surface::seqbase, SUMA_surface::sorted, SUMA_truncate_memory(), SUMA_ixyz::x, SUMA_surface::xbot, xc, SUMA_surface::xcen, SUMA_surface::xtop, SUMA_ixyz::y, SUMA_surface::ybot, yc, SUMA_surface::ycen, SUMA_surface::ytop, SUMA_ixyz::z, SUMA_surface::zbot, SUMA_surface::zcen, and SUMA_surface::ztop. Referenced by process_NIML_SUMA_ixyz(), SUMA_find_node_id(), and SUMA_make_vnlist().
00246 { 00247 int nn , ii , ndup ; 00248 float xb,yb,zb , xt,yt,zt , xc,yc,zc ; 00249 00250 ENTRY("SUMA_ixyzsort_surface") ; 00251 00252 if( ag == NULL || ag->num_ixyz < 1 ) EXRETURN ; 00253 00254 SUMA_truncate_memory( ag ) ; 00255 00256 nn = ag->num_ixyz ; 00257 00258 /* check if nodes are already sorted [26 Oct 2001] */ 00259 00260 for( ii=1 ; ii < nn ; ii++ ) 00261 if( ag->ixyz[ii].id <= ag->ixyz[ii-1].id ) break ; 00262 00263 /* if not in increasing order, 00264 sort them using the function generated above */ 00265 00266 if( ii < nn ){ 00267 qsort_SUMA_ixyz( nn , ag->ixyz ) ; 00268 } 00269 00270 ag->sorted = 1 ; /* mark as sorted */ 00271 00272 /* check if node id-s are sequential */ 00273 00274 for( ii=1 ; ii < nn ; ii++ ) 00275 if( ag->ixyz[ii].id != ag->ixyz[ii-1].id+1 ) break ; 00276 00277 /* if we finished that loop all the way, 00278 mark the nodes as being sequential, and 00279 store the base of the sequence (id of node #0) */ 00280 00281 if( ii == nn ){ 00282 ag->seq = 1 ; ag->seqbase = ag->ixyz[0].id ; 00283 } 00284 00285 /* 07 Sep 2001: check for duplicate node id-s */ 00286 00287 for( ndup=0,ii=1 ; ii < nn ; ii++ ) 00288 if( ag->ixyz[ii].id == ag->ixyz[ii-1].id ) ndup++ ; 00289 00290 if( ndup > 0 ) 00291 fprintf(stderr,"** SUMA WARNING: %d duplicate surface node id's found!\n",ndup); 00292 00293 /* find bounding box of all nodes (it's useful on occasion) */ 00294 00295 xb = xt = ag->ixyz[0].x ; 00296 yb = yt = ag->ixyz[0].y ; 00297 zb = zt = ag->ixyz[0].z ; 00298 xc = yc = zc = 0.0 ; 00299 for( ii=1 ; ii < nn ; ii++ ){ 00300 xc += ag->ixyz[ii].x ; 00301 yc += ag->ixyz[ii].y ; 00302 zc += ag->ixyz[ii].z ; 00303 00304 if( ag->ixyz[ii].x < xb ) xb = ag->ixyz[ii].x ; 00305 else if( ag->ixyz[ii].x > xt ) xt = ag->ixyz[ii].x ; 00306 00307 if( ag->ixyz[ii].y < yb ) yb = ag->ixyz[ii].y ; 00308 else if( ag->ixyz[ii].y > yt ) yt = ag->ixyz[ii].y ; 00309 00310 if( ag->ixyz[ii].z < zb ) zb = ag->ixyz[ii].z ; 00311 else if( ag->ixyz[ii].z > zt ) zt = ag->ixyz[ii].z ; 00312 } 00313 00314 ag->xbot = xb ; ag->xtop = xt ; 00315 ag->ybot = yb ; ag->ytop = yt ; 00316 ag->zbot = zb ; ag->ztop = zt ; 00317 00318 ag->xcen = xc/nn ; ag->ycen = yc/nn ; ag->zcen = zc/nn ; 00319 00320 EXRETURN ; 00321 } |
|
Create the voxel-to-node list for this surface/dataset combo. --------------------------------------------------------------------------- Definition at line 371 of file afni_suma.c. References calloc, SUMA_vnlist::dset, DSET_NX, DSET_NY, DSET_NZ, DSET_XXMAX, DSET_XXMIN, DSET_YYMAX, DSET_YYMIN, DSET_ZZMAX, DSET_ZZMIN, ENTRY, EXIT, free, ISVALID_DSET, SUMA_surface::ixyz, LOAD_FVEC3, malloc, SUMA_vnlist::nlist, SUMA_surface::num_ixyz, SUMA_vnlist::numnod, SUMA_vnlist::nvox, nz, qsort_intint(), RETURN, SUMA_surface::sorted, SUMA_ixyzsort_surface(), THD_3dmm_to_3dind(), THD_dicomm_to_3dmm(), UNLOAD_IVEC3, SUMA_vnlist::voxijk, THD_3dim_dataset::wod_flag, SUMA_ixyz::x, THD_fvec3::xyz, SUMA_ixyz::y, and SUMA_ixyz::z.
00372 { 00373 int ii,jj,kk , nx,ny,nz , nxy,nxyz , nnode , pp,qq,nn,nvox ; 00374 THD_fvec3 fv ; 00375 THD_ivec3 iv ; 00376 int *vlist , *nlist , wodsave ; 00377 SUMA_vnlist *vnlist ; 00378 float xbot,xtop , ybot,ytop , zbot,ztop ; 00379 00380 ENTRY("SUMA_make_vnlist") ; 00381 00382 if( ag == NULL || ag->num_ixyz < 1 || !ISVALID_DSET(dset) ) RETURN(NULL) ; 00383 00384 if( !ag->sorted ) SUMA_ixyzsort_surface( ag ) ; 00385 00386 /* setup: create arrays for voxel list and node list */ 00387 00388 nx = DSET_NX(dset) ; ny = DSET_NY(dset) ; nz = DSET_NZ(dset) ; 00389 nxy = nx*ny ; nxyz = nxy*nz ; nnode = ag->num_ixyz ; 00390 vlist = (int *) malloc(sizeof(int)*nnode) ; 00391 nlist = (int *) malloc(sizeof(int)*nnode) ; 00392 if( vlist == NULL || nlist == NULL ){ 00393 fprintf(stderr,"SUMA_make_vnlist: can't malloc!\n"); EXIT(1); 00394 } 00395 00396 /* for each node, find which voxel it is in */ 00397 00398 wodsave = dset->wod_flag ; dset->wod_flag = 0 ; 00399 00400 xbot = DSET_XXMIN(dset) ; xtop = DSET_XXMAX(dset) ; 00401 ybot = DSET_YYMIN(dset) ; ytop = DSET_YYMAX(dset) ; 00402 zbot = DSET_ZZMIN(dset) ; ztop = DSET_ZZMAX(dset) ; 00403 00404 for( nn=pp=0 ; pp < nnode ; pp++ ){ 00405 LOAD_FVEC3( fv , ag->ixyz[pp].x, ag->ixyz[pp].y, ag->ixyz[pp].z ) ; 00406 fv = THD_dicomm_to_3dmm( dset , fv ) ; /* convert Dicom coords */ 00407 00408 if( fv.xyz[0] < xbot || fv.xyz[0] > xtop ) continue ; 00409 if( fv.xyz[1] < ybot || fv.xyz[1] > ytop ) continue ; 00410 if( fv.xyz[2] < zbot || fv.xyz[2] > ztop ) continue ; 00411 00412 iv = THD_3dmm_to_3dind( dset , fv ) ; /* in surface to */ 00413 UNLOAD_IVEC3( iv , ii,jj,kk ) ; /* dataset indexes */ 00414 00415 nlist[nn] = pp ; /* list of nodes */ 00416 vlist[nn] = ii + jj*nx + kk*nxy ; /* list of voxels */ 00417 nn++ ; 00418 } 00419 00420 nnode = nn ; /* number of nodes inside dataset volume */ 00421 if( nnode == 0 ){ free(nlist); free(vlist); RETURN(NULL); } 00422 00423 dset->wod_flag = wodsave ; 00424 00425 /* now sort the 2 lists so that vlist is increasing 00426 (and each nlist still corresponds to its original vlist) */ 00427 00428 qsort_intint( nnode , vlist , nlist ) ; 00429 00430 /* count how many distinct voxels we found */ 00431 00432 nvox = 1 ; ii = vlist[0] ; 00433 for( pp=1 ; pp < nnode ; pp++ ){ 00434 if( vlist[pp] != ii ){ nvox++; ii = vlist[pp]; } 00435 } 00436 00437 /* now create the output vnlist */ 00438 00439 vnlist = (SUMA_vnlist *) malloc( sizeof(SUMA_vnlist) ) ; 00440 vnlist->nvox = nvox ; 00441 vnlist->voxijk = (int *) malloc(sizeof(int) *nvox) ; 00442 vnlist->numnod = (int *) calloc(sizeof(int) ,nvox) ; 00443 vnlist->nlist = (int **)malloc(sizeof(int*)*nvox); 00444 vnlist->dset = dset ; 00445 00446 if( vnlist->voxijk==NULL || vnlist->numnod==NULL || vnlist->nlist==NULL ){ 00447 fprintf(stderr,"SUMA_make_vnlist: can't malloc!\n"); EXIT(1); 00448 } 00449 00450 /* now count how many nodes are at each voxel in the list */ 00451 00452 ii = vlist[0] ; qq = nn = 0 ; 00453 for( pp=1 ; pp < nnode ; pp++ ){ 00454 if( vlist[pp] != ii ){ /* qq..pp-1 are the same */ 00455 vnlist->voxijk[nn] = ii ; 00456 vnlist->numnod[nn] = jj = pp-qq ; 00457 vnlist->nlist[nn] = (int *) malloc(sizeof(int)*jj) ; 00458 memcpy( vnlist->nlist[nn] , nlist+qq , sizeof(int)*jj ) ; 00459 ii = vlist[pp] ; nn++ ; qq = pp ; 00460 } 00461 } 00462 vnlist->voxijk[nn] = ii ; 00463 vnlist->numnod[nn] = jj = pp-qq ; 00464 vnlist->nlist[nn] = (int *) malloc(sizeof(int)*jj) ; 00465 memcpy( vnlist->nlist[nn] , nlist+qq , sizeof(int)*jj ) ; 00466 00467 /* and we're done! */ 00468 00469 free(nlist) ; free(vlist) ; RETURN( vnlist ) ; 00470 } |
|
Truncate the memory used by the node and triangle arrays back to the minimum they need. -------------------------------------------------------------------- Definition at line 207 of file afni_suma.c. References ENTRY, SUMA_surface::ijk, SUMA_surface::ixyz, SUMA_surface::nall_ijk, SUMA_surface::nall_ixyz, SUMA_surface::num_ijk, SUMA_surface::num_ixyz, and realloc. Referenced by SUMA_ixyzsort_surface().
00208 { 00209 int nn ; 00210 00211 ENTRY("SUMA_truncate_memory") ; 00212 00213 if( ag == NULL ) EXRETURN ; 00214 00215 if( ag->num_ixyz < ag->nall_ixyz && ag->num_ixyz > 0 ){ 00216 ag->nall_ixyz = nn = ag->num_ixyz ; 00217 ag->ixyz = (SUMA_ixyz *) realloc( (void *)ag->ixyz, sizeof(SUMA_ixyz)*nn ); 00218 } 00219 00220 if( ag->num_ijk < ag->nall_ijk && ag->num_ijk > 0 ){ 00221 ag->nall_ijk = nn = ag->num_ijk ; 00222 ag->ijk = (SUMA_ijk *) realloc( (void *)ag->ijk , sizeof(SUMA_ijk)*nn ) ; 00223 } 00224 00225 EXRETURN ; 00226 } |
|
Definition at line 495 of file afni_suma.c. References DSET_DX, DSET_DY, DSET_DZ, DSET_NX, DSET_NY, DSET_NZ, DSET_XORG, DSET_YORG, DSET_ZORG, LOAD_FVEC3, MAX, MIN, THD_3dmm_to_dicomm(), v1, and THD_fvec3::xyz.
00496 { 00497 float xx,yy,zz , xbase,ybase,zbase ; 00498 THD_fvec3 vout ; 00499 00500 xx = -fv.xyz[0] ; yy = -fv.xyz[1] ; zz = fv.xyz[2] ; /* xyz now LPI */ 00501 00502 if( dset != NULL ){ 00503 THD_fvec3 v1 , v2 ; 00504 LOAD_FVEC3(v1, DSET_XORG(dset),DSET_YORG(dset),DSET_ZORG(dset)) ; 00505 v1 = THD_3dmm_to_dicomm( dset , v1 ) ; 00506 LOAD_FVEC3(v2, DSET_XORG(dset)+(DSET_NX(dset)-1)*DSET_DX(dset) , 00507 DSET_YORG(dset)+(DSET_NY(dset)-1)*DSET_DY(dset) , 00508 DSET_ZORG(dset)+(DSET_NZ(dset)-1)*DSET_DZ(dset) ) ; 00509 v2 = THD_3dmm_to_dicomm( dset , v2 ) ; 00510 xbase = MAX( v1.xyz[0] , v2.xyz[0] ) ; xbase = -xbase ; /* Left-most */ 00511 ybase = MAX( v1.xyz[1] , v2.xyz[1] ) ; ybase = -ybase ; /* Posterior */ 00512 zbase = MIN( v1.xyz[2] , v2.xyz[2] ) ; /* Inferior */ 00513 } else { 00514 xbase = ybase = zbase = 0.0 ; 00515 } 00516 00517 vout.xyz[0] = xx - xbase ; 00518 vout.xyz[1] = yy - ybase ; 00519 vout.xyz[2] = zz - zbase ; return vout ; 00520 } |
|
Definition at line 524 of file afni_suma.c. References DSET_DX, DSET_DY, DSET_DZ, DSET_NX, DSET_NY, DSET_NZ, DSET_XORG, DSET_YORG, DSET_ZORG, LOAD_FVEC3, MAX, MIN, THD_3dmm_to_dicomm(), v1, and THD_fvec3::xyz.
00525 { 00526 float xx,yy,zz , xbase,ybase,zbase ; 00527 THD_fvec3 vout ; 00528 00529 xx = -fv.xyz[0] ; yy = -fv.xyz[1] ; zz = fv.xyz[2] ; /* xyz now RAI */ 00530 00531 if( dset != NULL ){ 00532 THD_fvec3 v1 , v2 ; 00533 LOAD_FVEC3(v1, DSET_XORG(dset),DSET_YORG(dset),DSET_ZORG(dset)) ; 00534 v1 = THD_3dmm_to_dicomm( dset , v1 ) ; 00535 LOAD_FVEC3(v2, DSET_XORG(dset)+(DSET_NX(dset)-1)*DSET_DX(dset) , 00536 DSET_YORG(dset)+(DSET_NY(dset)-1)*DSET_DY(dset) , 00537 DSET_ZORG(dset)+(DSET_NZ(dset)-1)*DSET_DZ(dset) ) ; 00538 v2 = THD_3dmm_to_dicomm( dset , v2 ) ; 00539 xbase = MAX( v1.xyz[0] , v2.xyz[0] ) ; xbase = -xbase ; 00540 ybase = MAX( v1.xyz[1] , v2.xyz[1] ) ; ybase = -ybase ; 00541 zbase = MIN( v1.xyz[2] , v2.xyz[2] ) ; 00542 } else { 00543 xbase = ybase = zbase = 0.0 ; 00544 } 00545 00546 vout.xyz[0] = xx - xbase ; 00547 vout.xyz[1] = yy - ybase ; 00548 vout.xyz[2] = zz + zbase ; return vout ; 00549 } |