Doxygen Source Code Documentation
afni_suma.h File Reference
#include "vecmat.h"Go to the source code of this file.
Define Documentation
|
|
Value: do{ if( vv != NULL ){ \ if( vv->voxijk != NULL ) free(vv->voxijk) ; \ if( vv->voxval != NULL ) free(vv->voxval) ; \ free(vv) ; \ }} while(0) Definition at line 87 of file afni_suma.h. Referenced by process_NIML_Node_ROI(), and SUMA_destroy_surface(). |
|
|
NIML rowtype definition for SUMA_ijk struct Definition at line 42 of file afni_suma.h. |
|
|
NIML rowtype definition for SUMA_irgba struct Definition at line 53 of file afni_suma.h. |
|
|
NIML rowtype definition for SUMA_ixyz struct Definition at line 32 of file afni_suma.h. |
|
|
Max number nodes allowed in a surface (67.1 million) [higher order bits are reserved for other purposes]. Definition at line 146 of file afni_suma.h. Referenced by SUMA_add_nodes_ixyz(). |
|
|
Macro for node count in a SUMA_surface struct Definition at line 137 of file afni_suma.h. |
|
|
Type code for SUMA_surface structs Definition at line 69 of file afni_suma.h. |
|
|
For the SUMA_surfacegroup typedef below. Definition at line 161 of file afni_suma.h. |
|
|
Port number for talking to AFNI Definition at line 16 of file afni_suma.h. |
|
|
Macro for triangle count in a SUMA_surface struct Definition at line 141 of file afni_suma.h. |
|
|
Definition at line 154 of file afni_suma.h. |
|
|
These macros are used in SUMA_map_dset_to_surf() to create an easily searched map between dataset voxel indexes and surface nodes (currently disabled) * Definition at line 152 of file afni_suma.h. |
|
|
Definition at line 155 of file afni_suma.h. |
|
|
Definition at line 157 of file afni_suma.h. |
|
|
Definition at line 153 of file afni_suma.h. |
|
|
A large number Definition at line 74 of file afni_suma.h. |
Function Documentation
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
Find node in surface closest to given DICOM vector, with limitation that node's x is in range xbot..xtop, etc. Return value is node index into ixyz array (not necessarily node ID), -1 if none is found. ------------------------------------------------------------------------- Definition at line 409 of file afni_sumafunc.c. References ENTRY, RETURN, SUMA_ixyz::x, SUMA_ixyz::y, and SUMA_ixyz::z. Referenced by AFNI_get_xhair_node().
00414 {
00415 int ii , ibest=-1 ;
00416 float x,y,z , dbest, d ;
00417
00418 ENTRY("AFNI_find_closest_node") ;
00419
00420 if( num_ixyz <= 0 || ixyz == NULL ) RETURN(-1) ; /* bad inputs */
00421
00422 /* if search ranges are incoherent, make them very wide */
00423
00424 if( xbot >= xtop ){ xbot = -WAY_BIG; xtop = WAY_BIG; }
00425 if( ybot >= ytop ){ ybot = -WAY_BIG; ytop = WAY_BIG; }
00426 if( zbot >= ztop ){ zbot = -WAY_BIG; ztop = WAY_BIG; }
00427
00428 for( ii=0 ; ii < num_ixyz ; ii++ ){
00429 x = ixyz[ii].x; y = ixyz[ii].y; z = ixyz[ii].z;
00430 if( x < xbot || x > xtop ||
00431 y < ybot || y > ytop ||
00432 z < zbot || z > ztop ) continue ; /* outside box */
00433
00434 d = (xtarg-x)*(xtarg-x) + (ytarg-y)*(ytarg-y) + (ztarg-z)*(ztarg-z) ;
00435 if( ibest < 0 || d < dbest ){ ibest = ii; dbest = d; }
00436 }
00437
00438 RETURN(ibest) ;
00439 }
|
|
||||||||||||||||
|
Definition at line 1164 of file afni_niml.c. References AFNI_find_closest_node(), Three_D_View::anat_now, AXIAL, CORONAL, DSET_DX, DSET_DY, DSET_DZ, SUMA_ixyz::id, IM3D_OPEN, SUMA_surface::ixyz, LOAD_FVEC3, SUMA_surface::num_ixyz, SAGITTAL, Three_D_View::ss_now, THD_session::su_num, THD_session::su_surf, THD_3dmm_to_dicomm(), AFNI_view_info::view_setter, Three_D_View::vinfo, AFNI_view_info::xi, THD_fvec3::xyz, AFNI_view_info::yj, and AFNI_view_info::zk. Referenced by AFNI_brick_to_mri(), and AFNI_niml_viewpoint_CB().
01165 {
01166 Three_D_View *im3d = (Three_D_View *)qq3d ;
01167 int ks , kbest=-1,ibest=-1 ,ii , nnod ;
01168 float xyz[3] , dbest=WAY_BIG,dd , xbot,xtop,ybot,ytop,zbot,ztop ;
01169 SUMA_surface *ag ;
01170 SUMA_ixyz *nod ;
01171
01172 if( !IM3D_OPEN(im3d) || (kkbest==NULL && iibest==NULL) ) return ;
01173 if( im3d->ss_now->su_num == 0 ||
01174 im3d->ss_now->su_surf[0] == NULL ) return ;
01175
01176 xyz[0] = im3d->vinfo->xi ; /* current RAI coordinates */
01177 xyz[1] = im3d->vinfo->yj ;
01178 xyz[2] = im3d->vinfo->zk ;
01179
01180 /* 20 Feb 2003: find closest node */
01181
01182 xbot = ybot = zbot = xtop = ytop = ztop = 0.0 ; /* unrestricted */
01183
01184 if( im3d->vinfo->view_setter > 0 ){ /* restrict to a thick plane */
01185 THD_fvec3 fv ;
01186 LOAD_FVEC3(fv,DSET_DX(im3d->anat_now),
01187 DSET_DY(im3d->anat_now),DSET_DZ(im3d->anat_now)) ;
01188 fv = THD_3dmm_to_dicomm(im3d->anat_now,fv) ;
01189 switch( im3d->vinfo->view_setter ){
01190 case AXIAL:
01191 dd = 0.499*fabs(fv.xyz[2]) ; zbot = xyz[2]-dd ; ztop = xyz[2]+dd ;
01192 break ;
01193 case SAGITTAL:
01194 dd = 0.499*fabs(fv.xyz[0]) ; xbot = xyz[0]-dd ; xtop = xyz[0]+dd ;
01195 break ;
01196 case CORONAL:
01197 dd = 0.499*fabs(fv.xyz[1]) ; ybot = xyz[1]-dd ; ytop = xyz[1]+dd ;
01198 break ;
01199 }
01200 #if 0
01201 fprintf(stderr,"view_setter=%d box=%f,%f %f,%f %f,%f\n",
01202 im3d->vinfo->view_setter , xbot,xtop,ybot,ytop,zbot,ztop ) ;
01203 #endif
01204 }
01205
01206 /* search all surfaces */
01207
01208 for( ks=0 ; ks < im3d->ss_now->su_num ; ks++ ){
01209 ag = im3d->ss_now->su_surf[ks]; if( ag == NULL ) continue;
01210 nod = ag->ixyz ; nnod = ag->num_ixyz ;
01211 ii = AFNI_find_closest_node( nnod,nod , xyz[0],xyz[1],xyz[2] ,
01212 xbot,xtop,ybot,ytop,zbot,ztop ) ;
01213 if( ii >= 0 ){
01214 dd = sqrt( (xyz[0]-nod[ii].x)*(xyz[0]-nod[ii].x)
01215 +(xyz[1]-nod[ii].y)*(xyz[1]-nod[ii].y)
01216 +(xyz[2]-nod[ii].z)*(xyz[2]-nod[ii].z) ) ;
01217 if( kbest < 0 || dd < dbest ){
01218 kbest = ks ; ibest = ii ; dbest = dd ;
01219 }
01220 }
01221 }
01222
01223 /* if didn't find anything, try again unrestricted */
01224 if( kbest < 0 && im3d->vinfo->view_setter > 0 ){
01225 xbot = ybot = zbot = xtop = ytop = ztop = 0.0 ;
01226 for( ks=0 ; ks < im3d->ss_now->su_num ; ks++ ){
01227 ag = im3d->ss_now->su_surf[ks]; if( ag == NULL ) continue;
01228 nod = ag->ixyz ; nnod = ag->num_ixyz ;
01229 ii = AFNI_find_closest_node( nnod,nod , xyz[0],xyz[1],xyz[2] ,
01230 xbot,xtop,ybot,ytop,zbot,ztop ) ;
01231 if( ii >= 0 ){
01232 dd = sqrt( (xyz[0]-nod[ii].x)*(xyz[0]-nod[ii].x)
01233 +(xyz[1]-nod[ii].y)*(xyz[1]-nod[ii].y)
01234 +(xyz[2]-nod[ii].z)*(xyz[2]-nod[ii].z) ) ;
01235 if( kbest < 0 || dd < dbest ){
01236 kbest = ks ; ibest = ii ; dbest = dd ;
01237 }
01238 }
01239 }
01240 }
01241
01242 if( kbest >= 0 ){
01243 ag = im3d->ss_now->su_surf[kbest] ; nod = ag->ixyz ;
01244 ibest = nod[ibest].id ;
01245 }
01246
01247 if( kkbest != NULL ) *kkbest = kbest ;
01248 if( iibest != NULL ) *iibest = ibest ;
01249 return ;
01250 }
|
|
||||||||||||||||||||||||
|
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 }
|
|
|
|
|
||||||||||||
|
Referenced by AFNI_vnlist_func_overlay(). |
|
||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||
|
|
|
|
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 }
|
|
|
|
|
||||||||||||
|
Referenced by main(). |
|
||||||||||||
|
Referenced by main(). |