00001 #ifndef SUMA_MACROSm_INCLUDED
00002 #define SUMA_MACROSm_INCLUDED
00003
00004
00005
00006
00007
00008
00009 #define SUMA_NEW_ID(newcode, strn) { \
00010 if ((newcode)) { SUMA_SL_Err("newcode pointer must be null"); } \
00011 else if (!(strn)) { (newcode) = (char*)SUMA_calloc(SUMA_IDCODE_LENGTH, sizeof(char)); UNIQ_idcode_fill((newcode)); } \
00012 else { char *m_tmp; m_tmp = UNIQ_hashcode((strn)); (newcode) = SUMA_copy_string(m_tmp); free(m_tmp); m_tmp = NULL; } \
00013 }
00014
00015
00016 #define SUMA_WHAT_ENDIAN(End){ \
00017 int m_one = 1; \
00018 \
00019 End = (*(char *)&m_one == 1) ? LSB_FIRST : MSB_FIRST; \
00020 }
00021
00022 #define SUMA_OTHER_ENDIAN(End){ \
00023 End = (End == LSB_FIRST) ? MSB_FIRST : LSB_FIRST; \
00024 }
00025
00026 #define SUMA_SWAP_THIS(nip,chnk){ \
00027 if (chnk == 4) SUMA_swap_4( nip ) ; \
00028 else if (chnk == 8) SUMA_swap_8( nip ) ; \
00029 else if (chnk == 2) SUMA_swap_2( nip ) ; \
00030 else { SUMA_SL_Err ("No swapping performed.") } \
00031 }
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #define SUMA_READ_NUM(nip, fp, ex, chnk) \
00042 { \
00043 ex = fread (nip, chnk, 1, fp); \
00044 }
00045
00046
00047
00048 #define SUMA_READ_NUM_BS(nip, fp, ex, chnk) \
00049 { \
00050 SUMA_READ_NUM(nip, fp, ex, chnk); \
00051 if (chnk == 4) SUMA_swap_4( nip ) ; \
00052 else if (chnk == 8) SUMA_swap_8( nip ) ; \
00053 else if (chnk == 2) SUMA_swap_2( nip ) ; \
00054 else { SUMA_SL_Err ("No swapping performed.") } \
00055 }
00056
00057
00058
00059
00060
00061
00062
00063
00064 #define SUMA_READ_INT(nip, bs, fp, ex) \
00065 { static int m_chnk = sizeof(int);\
00066 ex = fread (nip, m_chnk, 1, fp); \
00067 if (bs) { \
00068 if (m_chnk == 4) SUMA_swap_4( nip ) ; \
00069 else if (m_chnk == 8) SUMA_swap_8( nip ) ; \
00070 else if (m_chnk == 2) SUMA_swap_2( nip ) ; \
00071 else { SUMA_SL_Err ("No swapping performed.") } \
00072 } \
00073 }
00074 #define SUMA_READ_FLOAT(nip, bs, fp, ex) \
00075 { static int m_chnk = sizeof(float);\
00076 ex = fread (nip, m_chnk, 1, fp); \
00077 if (bs) { \
00078 if (m_chnk == 4) SUMA_swap_4( nip ) ; \
00079 else if (m_chnk == 8) SUMA_swap_8( nip ) ; \
00080 else { SUMA_SL_Err ("No swapping performed.") } \
00081 } \
00082 }
00083
00084 #define SUMA_SWAP_VEC(vec,N_alloc,chnk) {\
00085 int m_i; \
00086 if (chnk == 4) { for (m_i=0; m_i<N_alloc; ++m_i) SUMA_swap_4(&(vec[m_i])); } \
00087 else if (chnk == 2) { for (m_i=0; m_i<N_alloc; ++m_i) SUMA_swap_2(&(vec[m_i])); } \
00088 else if (chnk == 8) { for (m_i=0; m_i<N_alloc; ++m_i) SUMA_swap_8(&(vec[m_i])); } \
00089 else { SUMA_SL_Err("Bad chnk"); } \
00090 }
00091
00092 #define SUMA_IS_STRICT_POS(a) ( ((a) > 0) ? 1 : 0 )
00093
00094 #define SUMA_IS_POS(a) ( ((a) >= 0) ? 1 : 0 )
00095
00096 #define SUMA_IS_STRICT_NEG(a) ( ((a) < 0) ? 1 : 0 )
00097
00098 #define SUMA_IS_NEG(a) ( ((a) <= 0) ? 1 : 0 )
00099
00100 #define SUMA_SIGN(a) ( ((a) < 0) ? -1 : 1 )
00101
00102 #define SUMA_MIN_PAIR(a,b) ( ((a) <= (b)) ? a : b )
00103
00104 #define SUMA_MAX_PAIR(a,b) ( ((a) <= (b)) ? b : a )
00105
00106 #define SUMA_ABS(a) ( ((a) < 0 ) ? -(a) : a )
00107
00108 #define SUMA_ROUND(a) ( ( ((a) - (int)(a)) < 0.5 ) ? (int)(a) : ((int)(a)+1) )
00109
00110 #define SUMA_CEIL(a) ( ( ((a) - (int)(a)) == 0.0 ) ? (int)(a) : ((int)(a)+1) )
00111
00112 #define SUMA_3D_2_1D_index(i, j, k, ni, nij) ( (int)(i) + (int)(j) * (ni) + (int)(k) * (nij) )
00113
00114 #define SUMA_1D_2_3D_index(ijk, i, j, k, ni, nij){ \
00115 k = ((ijk) / (nij)); \
00116 j = ((ijk) % (nij)); \
00117 i = ((j) % (ni)); \
00118 j = ((j) / (ni)); \
00119 }
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148 #define SUMA_POINT_AT_DISTANCE(U, P1, d, P2){ \
00149 float m_n, m_Un[3]; \
00150 SUMA_NORM_VEC(U, 3, m_n); \
00151 if (m_n) { \
00152 if (m_n != 1) { \
00153 m_Un[0] = (U[0]) / (m_n); m_Un[1] = (U[1]) / (m_n); m_Un[2] = (U[2]) / (m_n); \
00154 SUMA_POINT_AT_DISTANCE_NORM(m_Un, P1, d, P2); \
00155 } else { SUMA_POINT_AT_DISTANCE_NORM(U, P1, d, P2); } \
00156 } \
00157 }
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185 #define SUMA_POINT_AT_DISTANCE_NORM(U, P1, d, P2){ \
00186 P2[0][0] = (d) * U[0]; P2[1][0] = -(d) * U[0]; P2[0][0] += P1[0]; P2[1][0] += P1[0]; \
00187 P2[0][1] = (d) * U[1]; P2[1][1] = -(d) * U[1]; P2[0][1] += P1[1]; P2[1][1] += P1[1]; \
00188 P2[0][2] = (d) * U[2]; P2[1][2] = -(d) * U[2]; P2[0][2] += P1[2]; P2[1][2] += P1[2]; \
00189 }
00190
00191
00192
00193
00194
00195 #define SUMA_FROM_BARYCENTRIC(u, v, p1, p2, p3, p){ \
00196 (p)[0] = (p1)[0] + u * ((p2)[0] - (p1)[0] ) + v * ((p3)[0] - (p1)[0]); \
00197 (p)[1] = (p1)[1] + u * ((p2)[1] - (p1)[1] ) + v * ((p3)[1] - (p1)[1]); \
00198 (p)[2] = (p1)[2] + u * ((p2)[2] - (p1)[2] ) + v * ((p3)[2] - (p1)[2]); \
00199 }
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209 #define SUMA_CART_2_SPH(c,s){\
00210 SUMA_NORM_VEC(c, 3, s[0]); \
00211 s[1] = atan2(c[1], c[0]); \
00212 s[2] = atan2(c[2],sqrt(c[0]*c[0]+c[1]*c[1])); \
00213 }
00214
00215
00216
00217
00218
00219
00220
00221
00222 #define SUMA_SPH_2_CART(s,c){\
00223 c[0] = s[0] * cos(s[2]) * cos(s[1]) ; \
00224 c[1] = s[0] * cos(s[2]) * sin(s[1]) ; \
00225 c[2] = s[0] * sin(s[2]); \
00226 }
00227
00228 #define SUMA_LARG_ABS(a, b) ( ( fabs((double)(a)) > fabs((double)(b)) ) ? fabs((double)(a)) : fabs((double)(b)) )
00229
00230
00231
00232
00233 #define SRM(r,c,nc) ((nc)*(r)+(c))
00234
00235
00236
00237 #define SCM(r,c,nr) ((r)+(nr)*(c))
00238
00239
00240 #define SUMA_WRAP_VALUE(v, min, max) \
00241 { \
00242 if (v > max) v = min; \
00243 else if (v < min) v = max; \
00244 }
00245
00246 #define SUMA_CLIP_VALUE(v, min, max) \
00247 { \
00248 if (v > max) v = max; \
00249 else if (v < min) v = min; \
00250 }
00251
00252 #define SUMA_CLIP_UB(v, max) \
00253 { \
00254 if (v > max) v = max; \
00255 }
00256
00257 #define SUMA_CLIP_LB(v, min) \
00258 { \
00259 if (v < min) v = min; \
00260 }
00261
00262
00263
00264
00265
00266 #define SUMA_DIST_FROM_PLANE(P1, P2, P3, P, Dist){ \
00267 static float m_Eq[4]; \
00268 SUMA_Plane_Equation ( P1, P2, P3, m_Eq); \
00269 Dist = m_Eq[0] * P[0] + m_Eq[1] * P[1] + m_Eq[2] * P[2] + m_Eq[3] ; \
00270 }
00271
00272
00273
00274
00275 #define SUMA_TRIANGLE_BOUNDING_BOX(n1, n2, n3, min_v, max_v){ \
00276 min_v[0] = SUMA_MIN_PAIR( (n1)[0], (n2)[0]); min_v[0] = SUMA_MIN_PAIR( (n3)[0], min_v[0]); \
00277 min_v[1] = SUMA_MIN_PAIR( (n1)[1], (n2)[1]); min_v[1] = SUMA_MIN_PAIR( (n3)[1], min_v[1]); \
00278 min_v[2] = SUMA_MIN_PAIR( (n1)[2], (n2)[2]); min_v[2] = SUMA_MIN_PAIR( (n3)[2], min_v[2]); \
00279 max_v[0] = SUMA_MAX_PAIR( (n1)[0], (n2)[0]); max_v[0] = SUMA_MAX_PAIR( (n3)[0], max_v[0]); \
00280 max_v[1] = SUMA_MAX_PAIR( (n1)[1], (n2)[1]); max_v[1] = SUMA_MAX_PAIR( (n3)[1], max_v[1]); \
00281 max_v[2] = SUMA_MAX_PAIR( (n1)[2], (n2)[2]); max_v[2] = SUMA_MAX_PAIR( (n3)[2], max_v[2]); \
00282 }
00283
00284 #define SUMA_SET_GL_RENDER_MODE(m_PolyMode) \
00285 { \
00286 switch (m_PolyMode) { \
00287 case SRM_Fill: \
00288 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); \
00289 break; \
00290 case SRM_Line: \
00291 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); \
00292 break; \
00293 case SRM_Points: \
00294 glPolygonMode(GL_FRONT_AND_BACK, GL_POINT); \
00295 break; \
00296 case SRM_ViewerDefault: \
00297 break; \
00298 default: \
00299 fprintf (SUMA_STDERR, "Error %s: Wrong Rendering Mode.\n", FuncName); \
00300 break; \
00301 } \
00302 }
00303
00304
00305
00306
00307
00308 #define SUMA_SO_RADIUS(SO, r){ \
00309 int m_i, m_i3; \
00310 float m_dx, m_dy, m_dz; \
00311 r = 0.0; \
00312 for (m_i=0; m_i<SO->N_Node; ++m_i) { \
00313 m_i3 = 3 * m_i; \
00314 m_dx = SO->NodeList[m_i3 ] - SO->Center[0]; \
00315 m_dy = SO->NodeList[m_i3+1] - SO->Center[1]; \
00316 m_dz = SO->NodeList[m_i3+2] - SO->Center[2]; \
00317 r += sqrt( (m_dx * m_dx) + (m_dy * m_dy) + (m_dz * m_dz)); \
00318 } \
00319 r /= (float)SO->N_Node; \
00320 }
00321
00322
00323
00324
00325 #define SUMA_RECOMPUTE_NORMALS(SO){ \
00326 SUMA_SURF_NORM m_SN; \
00327 if (SO->NodeNormList) SUMA_free(SO->NodeNormList); SO->NodeNormList = NULL; \
00328 if (SO->FaceNormList) SUMA_free(SO->FaceNormList); SO->FaceNormList = NULL; \
00329 m_SN = SUMA_SurfNorm(SO->NodeList, SO->N_Node, SO->FaceSetList, SO->N_FaceSet ); \
00330 SO->NodeNormList = m_SN.NodeNormList; \
00331 SO->FaceNormList = m_SN.FaceNormList; \
00332 SO->glar_NodeNormList = (GLfloat *) SO->NodeNormList; \
00333 SO->glar_FaceNormList = (GLfloat *) SO->FaceNormList; \
00334 }
00335
00336
00337
00338
00339 #define SUMA_PAUSE_PROMPT(s) { int m_jnk; fprintf(SUMA_STDOUT,"Pausing: %s ...", s); fflush(SUMA_STDOUT); m_jnk = getchar(); fprintf(SUMA_STDOUT,"\n"); fflush(SUMA_STDOUT);}
00340
00341
00342
00343
00344 #define SUMA_DIM_CENTER(SO){ \
00345 SUMA_MIN_MAX_SUM_VECMAT_COL (SO->NodeList, SO->N_Node, SO->NodeDim, SO->MinDims, SO->MaxDims, SO->Center); \
00346 SO->Center[0] /= SO->N_Node; \
00347 SO->Center[1] /= SO->N_Node; \
00348 SO->Center[2] /= SO->N_Node; \
00349 SUMA_MIN_VEC (SO->MinDims, 3, SO->aMinDims ); \
00350 SUMA_MAX_VEC (SO->MaxDims, 3, SO->aMaxDims); \
00351 }
00352
00353
00354 #define SUMA_FACE_CENTROID(SO, ifc, c){ \
00355 static int m_n1, m_n2, m_n3; \
00356 m_n1 = SO->FaceSetList[3*ifc]; m_n2 = SO->FaceSetList[3*ifc+1]; m_n3 = SO->FaceSetList[3*ifc+2]; \
00357 c[0] = (SO->NodeList[3*m_n1] + SO->NodeList[3*m_n2] + SO->NodeList[3*m_n3] )/3; \
00358 c[1] = (SO->NodeList[3*m_n1+1] + SO->NodeList[3*m_n2+1] + SO->NodeList[3*m_n3+1])/3; \
00359 c[2] = (SO->NodeList[3*m_n1+2] + SO->NodeList[3*m_n2+2] + SO->NodeList[3*m_n3+2])/3; \
00360 }
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372 #define SUMA_FIND_EDGE(m_EL, m_n1, m_n2, m_iseg) \
00373 { int m_eloc ; \
00374 m_eloc = m_EL->ELloc[m_n1]; \
00375 do { \
00376 if (m_EL->EL[m_eloc][1] == m_n2) m_iseg = m_eloc; \
00377 ++m_eloc; \
00378 } while (m_EL->EL[m_eloc][0] == m_n1 && m_eloc < m_EL->N_EL); \
00379 }
00380
00381
00382
00383
00384
00385 #define SUMA_DRAWN_ROI_TAIL_NODE(D_ROI, Ntail) \
00386 {\
00387 DListElmt *m_Tail=NULL; \
00388 SUMA_ROI_DATUM *m_ROId=NULL; \
00389 Ntail = -1; \
00390 m_Tail = dlist_tail(D_ROI->ROIstrokelist); \
00391 if (m_Tail) { \
00392 m_ROId = (SUMA_ROI_DATUM *)m_Tail->data; \
00393 if (m_ROId->N_n) Ntail = m_ROId->nPath[m_ROId->N_n-1]; \
00394 } \
00395 }
00396
00397
00398
00399
00400
00401 #define SUMA_DRAWN_ROI_HEAD_NODE(D_ROI, Nhead) \
00402 {\
00403 DListElmt *m_Head=NULL; \
00404 SUMA_ROI_DATUM *m_ROId=NULL; \
00405 Nhead = -1; \
00406 m_Head = dlist_head(D_ROI->ROIstrokelist); \
00407 if (m_Head) { \
00408 m_ROId = (SUMA_ROI_DATUM *)m_Head->data; \
00409 if (m_ROId->N_n) Nhead = m_ROId->nPath[0]; \
00410 } \
00411 }
00412
00413
00414
00415
00416
00417 #define SUMA_MT_CROSS(m_MTCR_dest,m_MTCR_v1,m_MTCR_v2) \
00418 m_MTCR_dest[0]=m_MTCR_v1[1]*m_MTCR_v2[2]-m_MTCR_v1[2]*m_MTCR_v2[1]; \
00419 m_MTCR_dest[1]=m_MTCR_v1[2]*m_MTCR_v2[0]-m_MTCR_v1[0]*m_MTCR_v2[2]; \
00420 m_MTCR_dest[2]=m_MTCR_v1[0]*m_MTCR_v2[1]-m_MTCR_v1[1]*m_MTCR_v2[0];
00421 #define SUMA_MT_DOT(m_MTDOT_v1,m_MTDOT_v2) (m_MTDOT_v1[0]*m_MTDOT_v2[0]+m_MTDOT_v1[1]*m_MTDOT_v2[1]+m_MTDOT_v1[2]*m_MTDOT_v2[2])
00422 #define SUMA_MT_SUB(m_MTSUB_dest,m_MTSUB_v1,m_MTSUB_v2) \
00423 m_MTSUB_dest[0]=m_MTSUB_v1[0]-m_MTSUB_v2[0]; \
00424 m_MTSUB_dest[1]=m_MTSUB_v1[1]-m_MTSUB_v2[1]; \
00425 m_MTSUB_dest[2]=m_MTSUB_v1[2]-m_MTSUB_v2[2];
00426 #define SUMA_NORM(m_NORM_dest, m_NORM_v1) \
00427 m_NORM_dest= sqrt(m_NORM_v1[0]*m_NORM_v1[0]+m_NORM_v1[1]*m_NORM_v1[1]+m_NORM_v1[2]*m_NORM_v1[2]);
00428 #define SUMA_TRI_AREA(m_TRIAREA_n0,m_TRIAREA_n1,m_TRIAREA_n2, m_TRIAREA_A) {\
00429 float m_TRIAREA_dv[3], m_TRIAREA_dw[3], m_TRIAREA_cross[3]; \
00430 SUMA_MT_SUB (m_TRIAREA_dv, m_TRIAREA_n1, m_TRIAREA_n0); \
00431 SUMA_MT_SUB (m_TRIAREA_dw, m_TRIAREA_n2, m_TRIAREA_n0); \
00432 SUMA_MT_CROSS(m_TRIAREA_cross,m_TRIAREA_dv,m_TRIAREA_dw); \
00433 SUMA_NORM(m_TRIAREA_A, m_TRIAREA_cross); \
00434 m_TRIAREA_A *= 0.5; \
00435 }
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447 #define SUMA_EULER_SO(SO, eu) { \
00448 if (!SO) { eu = -1000; } \
00449 else if (!SO->EL) { eu = -1001; } \
00450 else eu = SO->N_Node - SO->EL->N_Distinct_Edges + SO->N_FaceSet; \
00451 }
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461 #define SUMA_IS_IN_VEC(m_vec, m_nel, m_val, m_loc) { \
00462 int m_i=0;\
00463 m_loc = -1;\
00464 while (m_i < m_nel) { \
00465 if (m_vec[m_i] == m_val) { \
00466 m_loc = m_i; \
00467 m_i = m_nel; \
00468 } else { \
00469 ++ m_i; \
00470 } \
00471 } \
00472 }
00473
00474 #define SUMA_DBG_IN_NOTIFY(m_fname) { \
00475 int m_i;\
00476 ++SUMAg_CF->InOut_Level; \
00477 for (m_i=0; m_i < SUMAg_CF->InOut_Level; ++m_i) fprintf (SUMA_STDERR," ");\
00478 fprintf (SUMA_STDERR,"--dbg: Entered %s (lvl %d).\n", m_fname, SUMAg_CF->InOut_Level); \
00479 }
00480
00481 #define SUMA_DBG_OUT_NOTIFY(m_fname) { \
00482 int m_i;\
00483 for (m_i=0; m_i < SUMAg_CF->InOut_Level; ++m_i) fprintf (SUMA_STDERR," ");\
00484 fprintf (SUMA_STDERR,"--dbg: Left %s (lvl %d).\n", m_fname, SUMAg_CF->InOut_Level); \
00485 --SUMAg_CF->InOut_Level; \
00486 }
00487
00488
00489
00490
00491
00492 #define SUMA_REPORT_WICH_WIDGET_SV(m_w) {\
00493 int m_i = 0; \
00494 SUMA_SurfaceViewer *m_sv = NULL; \
00495 int m_svi = -1; \
00496 while (m_i < SUMA_MAX_SURF_VIEWERS) { \
00497 \
00498 if (SUMAg_SVv[m_i].X->GLXAREA == m_w) { \
00499 fprintf (SUMA_STDERR,"SUMA_REPORT_WICH_WIDGET_SV: %p is GLXAREA widget in Surface Viewer %d.\n", m_w, m_i); \
00500 m_svi = m_i; \
00501 } \
00502 if (SUMAg_SVv[m_i].X->TOPLEVEL == m_w) { \
00503 fprintf (SUMA_STDERR,"SUMA_REPORT_WICH_WIDGET_SV: %p is TOPLEVEL widget in Surface Viewer %d.\n", m_w, m_i); \
00504 m_svi = m_i; \
00505 } \
00506 if (SUMAg_SVv[m_i].X->FORM == m_w) { \
00507 fprintf (SUMA_STDERR,"SUMA_REPORT_WICH_WIDGET_SV: %p is FORM widget in Surface Viewer %d.\n", m_w, m_i); \
00508 m_svi = m_i; \
00509 } \
00510 if (SUMAg_SVv[m_i].X->FRAME == m_w) { \
00511 fprintf (SUMA_STDERR,"SUMA_REPORT_WICH_WIDGET_SV: %p is FRAME widget in Surface Viewer %d.\n", m_w, m_i); \
00512 m_svi = m_i; \
00513 } \
00514 ++m_i; \
00515 } \
00516 }
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527 #define SUMA_ANY_WIDGET2SV(m_w, m_sv, m_svi) {\
00528 int m_i = 0; \
00529 m_sv = NULL; \
00530 m_svi = -1; \
00531 while (m_i < SUMA_MAX_SURF_VIEWERS) { \
00532 if (SUMAg_SVv[m_i].X->GLXAREA == m_w || SUMAg_SVv[m_i].X->TOPLEVEL == m_w || SUMAg_SVv[m_i].X->FORM == m_w || SUMAg_SVv[m_i].X->FRAME == m_w) { \
00533 m_svi = m_i; \
00534 m_sv = &(SUMAg_SVv[m_i]); \
00535 m_i = SUMA_MAX_SURF_VIEWERS; \
00536 } else { \
00537 ++m_i; \
00538 } \
00539 } \
00540 }
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550 #define SUMA_GLXAREA_WIDGET2SV(m_w, m_sv, m_svi) {\
00551 int m_i = 0; \
00552 m_sv = NULL; \
00553 m_svi = -1; \
00554 while (m_i < SUMA_MAX_SURF_VIEWERS) { \
00555 if (SUMAg_SVv[m_i].X->GLXAREA == m_w) { \
00556 m_svi = m_i; \
00557 m_sv = &(SUMAg_SVv[m_i]); \
00558 m_i = SUMA_MAX_SURF_VIEWERS; \
00559 } else { \
00560 ++m_i; \
00561 } \
00562 } \
00563 }
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581 #define SUMA_SEG_LENGTH(m_a, m_b, m_dist) { \
00582 m_dist = sqrt( (m_b[0] - m_a[0]) * (m_b[0] - m_a[0]) \
00583 +(m_b[1] - m_a[1]) * (m_b[1] - m_a[1]) \
00584 +(m_b[2] - m_a[2]) * (m_b[2] - m_a[2]) ); \
00585 }
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595 #define SUMA_SEG_LENGTH_SQ(m_a, m_b, m_dist) { \
00596 m_dist = (m_b[0] - m_a[0]) * (m_b[0] - m_a[0]) \
00597 +(m_b[1] - m_a[1]) * (m_b[1] - m_a[1]) \
00598 +(m_b[2] - m_a[2]) * (m_b[2] - m_a[2]) ; \
00599 }
00600
00601
00602
00603
00604
00605
00606
00607 #define SUMA_NORM_VEC(a,nel,norm) { \
00608 int m_I; \
00609 norm = 0.0; \
00610 for (m_I = 0; m_I < nel; m_I++) { \
00611 norm += a[m_I]*a[m_I]; \
00612 } \
00613 norm = sqrt(norm); \
00614 }
00615
00616
00617
00618
00619
00620
00621
00622
00623 #define SUMA_MIN_VEC(a,nel,amin) { \
00624 int m_I; \
00625 amin = a[0]; \
00626 for (m_I = 1; m_I < nel; m_I++) { \
00627 if (a[m_I] < amin) amin = a[m_I]; \
00628 } \
00629 }
00630
00631
00632
00633
00634
00635
00636
00637
00638 #define SUMA_MIN_LOC_VEC(a,nel,amin, minloc) { \
00639 int m_I; \
00640 amin = a[0]; \
00641 minloc = 0; \
00642 for (m_I = 1; m_I < nel; m_I++) { \
00643 if (a[m_I] < amin) { \
00644 amin = a[m_I]; \
00645 minloc = m_I; \
00646 } \
00647 } \
00648 }
00649
00650
00651
00652
00653
00654
00655
00656 #define SUMA_MAX_VEC(a,nel,amax) { \
00657 int m_I; \
00658 amax = a[0]; \
00659 for (m_I = 1; m_I < nel; m_I++) { \
00660 if (a[m_I] > amax) amax = a[m_I]; \
00661 } \
00662 }
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673 #define SUMA_MIN_MAX_VEC(a,nel, amin, amax, aminloc, amaxloc) { \
00674 int m_I; \
00675 amaxloc = 0; \
00676 amax = a[0]; \
00677 aminloc = 0; \
00678 amin = a[0];\
00679 for (m_I = 1; m_I < nel; m_I++) { \
00680 if (a[m_I] > amax) { amax = a[m_I]; amaxloc = m_I; } \
00681 else { if (a[m_I] < amin) { amin = a[m_I]; aminloc = m_I; } } \
00682 } \
00683 }
00684
00685 #define SUMA_MIN_MAX_VEC_STRIDE(a,nel, amin, amax, aminloc, amaxloc, stride) { \
00686 int m_I; \
00687 amaxloc = 0; \
00688 amax = a[0]; \
00689 aminloc = 0; \
00690 amin = a[0];\
00691 for (m_I = stride; m_I < nel; m_I = m_I+stride) { \
00692 if (a[m_I] > amax) { amax = a[m_I]; amaxloc = m_I; } \
00693 else { if (a[m_I] < amin) { amin = a[m_I]; aminloc = m_I; } } \
00694 } \
00695 }
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714 #ifndef SUMA_ADD_VEC
00715 #define SUMA_ADD_VEC(a,b,c,len,typea,typeb,typec) { \
00716 typea *_PTA = a; \
00717 typeb *_PTB = b; \
00718 typec *_PTC = c; \
00719 int m_IX; \
00720 for(m_IX = 0 ; m_IX < (len) ; m_IX++) \
00721 *_PTC++ = (typec)((*_PTA++) + (*_PTB++)); \
00722 }
00723
00724 #endif
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744 #ifndef SUMA_SUB_VEC
00745 #define SUMA_SUB_VEC(a,b,c,len,typea,typeb,typec) { \
00746 typea *_PTA = a; \
00747 typeb *_PTB = b; \
00748 typec *_PTC = c; \
00749 int m_IX; \
00750 for(m_IX = 0 ; m_IX < (len) ; m_IX++) \
00751 *_PTC++ = (typec)((*_PTA++) - (*_PTB++)); \
00752 }
00753 #endif
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777 #ifndef SUMA_MULT_VEC
00778 #define SUMA_MULT_VEC(a,b,c,len,typea,typeb,typec) { \
00779 typea *_PTA = a; \
00780 typeb *_PTB = b; \
00781 typec *_PTC = c; \
00782 int m_IX; \
00783 for(m_IX = 0 ; m_IX < (len) ; m_IX++) \
00784 *_PTC++ = (typec)((*_PTA++) * (*_PTB++)); \
00785 }
00786 #endif
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803 #ifndef SUMA_SUM_VEC
00804 #define SUMA_SUM_VEC(a,s,len,typea) { \
00805 typea *_PTA = a; \
00806 int m_IX; \
00807 s = (*_PTA++); \
00808 for(m_IX = 1 ; m_IX < (len) ; m_IX++) \
00809 s += (*_PTA++); \
00810 }
00811 #endif
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831 #ifndef SUMA_SCALE_VEC
00832 #define SUMA_SCALE_VEC(a,b,s,len,typea,typeb) { \
00833 typea *_PTA = (typea *)a; \
00834 typeb *_PTB = (typeb *)b; \
00835 int m_IX; \
00836 for(m_IX = 0 ; m_IX < (len) ; m_IX++) \
00837 *(_PTB)++ = (typeb)(s * (*(_PTA)++)); \
00838 }
00839 #endif
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856 #define SUMA_EXTRACT_VEC(a,b,ind,len,typea,typeb) { \
00857 typea *_PTA = (typea *)a; \
00858 typeb *_PTB = (typeb *)b; \
00859 int m_IX; \
00860 for(m_IX = 0 ; m_IX < (len) ; m_IX++) \
00861 _PTB[m_IX] = _PTA[ind[m_IX]]; \
00862 }
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882 #define SUMA_CAT_VEC(a,b, catata, lenb,typea,typeb) { \
00883 typea *_PTA = (typea *)a; \
00884 typeb *_PTB = (typeb *)b; \
00885 int m_IX; \
00886 _PTA = _PTA + catata; \
00887 for(m_IX = 0 ; m_IX < (lenb) ; m_IX++) \
00888 *(_PTA)++ = (typea)(*(_PTB)++); \
00889 }
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905 #define SUMA_GET_MAT_ROW(a,b,row,cols,typea,typeb) { \
00906 typea **_AMX = (typea **)a; \
00907 typeb *_PTB = (typeb *)b; \
00908 typea *_PTA; \
00909 int _JX; \
00910 _PTA = _AMX[row]; \
00911 for(_JX = 0 ; _JX < cols ; _JX++) \
00912 *_PTB++ = (typeb) (*_PTA++); \
00913 }
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929 #define SUMA_GET_MAT_COL(a,b,col , rows, typea,typeb) { \
00930 typea **_AMX = (typea **)a; \
00931 typeb *_PTB = (typeb *)b; \
00932 typea *_PTA; \
00933 int m_IX,_JX; \
00934 for(m_IX = 0 ; m_IX < rows ; m_IX++) { \
00935 _PTA = _AMX[m_IX ] ; \
00936 for(_JX = 0 ; _JX < col ; _JX++) \
00937 _PTA++; \
00938 *_PTB++ = (typeb)(*_PTA++); \
00939 } \
00940 }
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950 #define SUMA_MIN_MAT_COL(a, rows, cols, amin) { \
00951 int m_IX, _JX; \
00952 for (m_IX = 0; m_IX < cols ; m_IX++) { \
00953 amin[m_IX]=a[0][m_IX]; \
00954 for (_JX = 1 ; _JX < rows ; _JX++) \
00955 if (a[_JX][m_IX] < amin[m_IX]) amin[m_IX] = a[_JX][m_IX];\
00956 }\
00957 }
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967 #define SUMA_MAX_MAT_COL(a, rows, cols, amax) { \
00968 int m_IX, _JX; \
00969 for (m_IX = 0; m_IX < cols ; m_IX++) { \
00970 amax[m_IX]=a[0][m_IX]; \
00971 for (_JX = 1 ; _JX < rows ; _JX++) \
00972 if (a[_JX][m_IX] > amax[m_IX]) amax[m_IX] = a[_JX][m_IX];\
00973 }\
00974 }
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986 #define SUMA_MIN_MAX_SUM_MAT_COL(a, rows, cols, amin, amax, asum) { \
00987 int m_IX, _JX; \
00988 for (m_IX = 0; m_IX < cols ; m_IX++) { \
00989 amax[m_IX]=a[0][m_IX]; \
00990 amin[m_IX]=a[0][m_IX]; \
00991 asum[m_IX]=a[0][m_IX]; \
00992 for (_JX = 1 ; _JX < rows ; _JX++) { \
00993 if (a[_JX][m_IX] > amax[m_IX]) amax[m_IX] = a[_JX][m_IX];\
00994 if (a[_JX][m_IX] < amin[m_IX]) amin[m_IX] = a[_JX][m_IX];\
00995 asum[m_IX] += a[_JX][m_IX]; \
00996 } \
00997 }\
00998 }
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015 #define SUMA_MIN_MAX_SUM_VECMAT_COL(a, rows, cols, amin, amax, asum) { \
01016 int m_IX, m_JX, m_id; \
01017 for (m_IX = 0; m_IX < cols ; m_IX++) { \
01018 amax[m_IX]=a[m_IX]; \
01019 amin[m_IX]=a[m_IX]; \
01020 asum[m_IX]=a[m_IX]; \
01021 for (m_JX = 1 ; m_JX < rows ; m_JX++) { \
01022 m_id = cols * m_JX + m_IX; \
01023 if (a[m_id] > amax[m_IX]) amax[m_IX] = a[m_id];\
01024 if (a[m_id] < amin[m_IX]) amin[m_IX] = a[m_id];\
01025 asum[m_IX] += a[m_id]; \
01026 } \
01027 } \
01028 }
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042
01043
01044
01045
01046 #define SUMA_MIN_MAX_SUM_VECMAT_MASK_COL(a, rows, cols, rowmask, amin, amax, asum) { \
01047 int m_IX, m_JX, m_id, m_start_row=0; \
01048 m_JX = 0; \
01049 while (!m_start_row && m_JX < rows) { \
01050 if (rowmask[m_JX]) m_start_row = m_JX+1; \
01051 ++m_JX; \
01052 } \
01053 --m_start_row; \
01054 for (m_IX = 0; m_IX < cols ; m_IX++) { \
01055 amax[m_IX]=a[cols * m_start_row + m_IX]; \
01056 amin[m_IX]=a[cols * m_start_row + m_IX]; \
01057 asum[m_IX]=a[cols * m_start_row + m_IX]; \
01058 ++m_start_row; \
01059 for (m_JX = m_start_row ; m_JX < rows ; m_JX++) { \
01060 if (rowmask[m_JX]) { \
01061 m_id = cols * m_JX + m_IX; \
01062 if (a[m_id] > amax[m_IX]) amax[m_IX] = a[m_id];\
01063 if (a[m_id] < amin[m_IX]) amin[m_IX] = a[m_id];\
01064 asum[m_IX] += a[m_id]; \
01065 } \
01066 } \
01067 } \
01068 }
01069
01070
01071
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084 #define SUMA_MAT_TO_VEC(a,b,rows,cols,typea,typeb) { \
01085 typea **_AMX = (typea **)a; \
01086 typeb *_PTB = (typeb *)b; \
01087 typea *_PTA; \
01088 int m_IX,_JX; \
01089 for(m_IX = 0 ; m_IX < rows ; m_IX++) { \
01090 _PTA = _AMX[m_IX ]; \
01091 for(_JX = 0 ; _JX < cols ; _JX++) \
01092 *_PTB++ = (typeb) (*_PTA++); \
01093 } \
01094 }
01095
01096
01097
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108
01109
01110 #define SUMA_COPY_VEC(a,b,len,typea,typeb) { \
01111 typea *_PTA = (typea *)a; \
01112 typeb *_PTB = (typeb *)b; \
01113 int m_IX; \
01114 for(m_IX = 0 ; m_IX < (len) ; m_IX++) \
01115 *(_PTB)++ = (typeb)(*(_PTA)++); \
01116 }
01117
01118
01119
01120
01121
01122 #define SUMA_INIT_VEC(a,len,val,typea) { \
01123 int m_i; \
01124 for (m_i = 0; m_i < (len) ; m_i ++) \
01125 a[m_i] = (typea)val; \
01126 }
01127
01128 #define SUMA_COPY_VALUE_IN_VEC(a, b, ia, ib, typea, typeb) { \
01129 typea *_PTA = (typea *)a; \
01130 typeb *_PTB = (typeb *)b; \
01131 _PTB[ib] = (typeb)_PTA[ia]; \
01132 }
01133
01134 #define SUMA_ASSIGN_VALUE_IN_VEC(a, ia, typea, val) { \
01135 typea *_PTA = (typea *)a; \
01136 _PTA[ia] = (typea)val; \
01137 }
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158
01159
01160
01161 #define SUMA_DOTP_VEC(a,b,s,len,typea,typeb) { \
01162 typea *_PTA = a; \
01163 typeb *_PTB = b; \
01164 int m_IX; \
01165 s = (*_PTA++) * (*_PTB++); \
01166 for(m_IX = 1 ; m_IX < (len) ; m_IX++) \
01167 s += (*_PTA++) * (*_PTB++); \
01168 }
01169
01170
01171
01172
01173
01174
01175
01176
01177
01178 #define SUMA_UNIT_VEC(P1, P2, U, Un){ \
01179 \
01180 U[0] = P2[0] - P1[0]; \
01181 U[1] = P2[1] - P1[1]; \
01182 U[2] = P2[2] - P1[2]; \
01183 Un = sqrt(U[0]*U[0] + U[1]*U[1] + U[2]*U[2]); \
01184 if (Un) { \
01185 U[0] /= Un; U[1] /= Un; U[2] /= Un; \
01186 }else { \
01187 U[0] = U[1] = U[2] = 0; \
01188 } \
01189 } \
01190
01191
01192
01193
01194
01195
01196 #define SUMA_SEG_NORM(P1, P2, Un){ \
01197 static double m_dx, m_dy,m_dz; \
01198 \
01199 m_dx = P2[0] - P1[0]; \
01200 m_dy = P2[1] - P1[1]; \
01201 m_dz = P2[2] - P1[2]; \
01202 Un = sqrt(m_dx*m_dx + m_dy*m_dy + m_dz*m_dz); \
01203 } \
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222 #define SUMA_MULT_MAT(a,b,c,rowsa,colsa,colsb,typea,typeb,typec) { \
01223 typea **_AMX = (typea **)a; \
01224 typeb **_BMX = (typeb **)b; \
01225 typec **_CMX = (typec **)c; \
01226 typea *_PTA; \
01227 typeb *_PTB; \
01228 typec *_PTC; \
01229 int m_IX,_JX,_KX; \
01230 for(m_IX = 0 ; m_IX < rowsa ; m_IX++) { \
01231 _PTC = _CMX[m_IX]; \
01232 _PTB = _BMX[0]; \
01233 for(_JX = 0 ; _JX < colsb ; _JX++) { \
01234 _PTA = _AMX[m_IX]; \
01235 *_PTC = (*_PTA++) * (*_PTB++); \
01236 for(_KX = 1 ; _KX < colsa ; _KX++) \
01237 *_PTC += (*_PTA++)* _BMX[_KX][_JX]; \
01238 _PTC++; \
01239 } \
01240 } \
01241 }
01242
01243
01244
01245
01246
01247
01248
01249
01250
01251
01252
01253
01254
01255
01256
01257
01258
01259
01260 #define SUMA_ADD_MAT(a,b,c,rowsa,colsa,typea,typeb,typec) { \
01261 typea **_AMX = (typea **)a; \
01262 typeb **_BMX = (typeb **)b; \
01263 typec **_CMX = (typec **)c; \
01264 int m_IX,_JX; \
01265 for(m_IX = 0 ; m_IX < rowsa ; m_IX++) { \
01266 for(_JX = 0 ; _JX < colsa ; _JX++) { \
01267 _CMX[m_IX][_JX] = _AMX[m_IX][_JX] + _BMX[m_IX][_JX]; \
01268 } \
01269 } \
01270 }
01271
01272
01273
01274
01275
01276
01277
01278
01279
01280
01281
01282
01283
01284
01285
01286
01287
01288 #define SUMA_SUB_MAT(a,b,c,rowsa,colsa,typea,typeb,typec) { \
01289 typea **_AMX = (typea **)a; \
01290 typeb **_BMX = (typeb **)b; \
01291 typec **_CMX = (typec **)c; \
01292 int m_IX,_JX; \
01293 for(m_IX = 0 ; m_IX < rowsa ; m_IX++) { \
01294 for(_JX = 0 ; _JX < colsa ; _JX++) { \
01295 _CMX[m_IX][_JX] = _AMX[m_IX][_JX] - _BMX[m_IX][_JX]; \
01296 } \
01297 } \
01298 }
01299
01300
01301
01302
01303
01304
01305
01306
01307
01308
01309
01310
01311
01312
01313
01314
01315 #define SUMA_TRANSP_MAT(a,b,rowsa,colsa,typea,typeb) { \
01316 typea **_AMX = (typea **)a; \
01317 typeb **_BMX = (typeb **)b; \
01318 int m_IX,_JX; \
01319 for(m_IX = 0 ; m_IX < rowsa ; m_IX++) { \
01320 for(_JX = 0 ; _JX < colsa ; _JX++) { \
01321 _BMX[_JX][m_IX] = _AMX[m_IX][_JX]; \
01322 } \
01323 } \
01324 }
01325
01326
01327
01328
01329
01330
01331
01332
01333
01334
01335 #define SUMA_RGBmat_2_GLCOLAR4(RGBmat, glcolar, nrgb) {\
01336 int m_I, m_I4 = 0; \
01337 for (m_I=0; m_I < nrgb; ++m_I) {\
01338 glcolar[m_I4] = RGBmat[m_I][0]; ++m_I4;\
01339 glcolar[m_I4] = RGBmat[m_I][1]; ++m_I4;\
01340 glcolar[m_I4] = RGBmat[m_I][2]; ++m_I4;\
01341 ++m_I4;\
01342 }\
01343 }
01344 #define SUMA_RGBvec_2_GLCOLAR4(RGBvec, glcolar, nrgb) {\
01345 int m_I, m_I4 = 0, m_I3=0; \
01346 for (m_I=0; m_I < nrgb; ++m_I) {\
01347 glcolar[m_I4] = RGBvec[m_I3]; ++m_I4; ++m_I3;\
01348 glcolar[m_I4] = RGBvec[m_I3]; ++m_I4; ++m_I3;\
01349 glcolar[m_I4] = RGBvec[m_I3]; ++m_I4; ++m_I3;\
01350 ++m_I4;\
01351 }\
01352 }
01353
01354
01355
01356
01357
01358
01359
01360
01361
01362
01363
01364 #define SUMA_GLCOLAR4_2_RGBmat(glcolar, RGBmat, nrgb) {\
01365 int m_I, m_I4 = 0; \
01366 for (m_I=0; m_I < nrgb; ++m_I) {\
01367 RGBmat[m_I][0] = glcolar[m_I4]; ++m_I4;\
01368 RGBmat[m_I][1] = glcolar[m_I4]; ++m_I4;\
01369 RGBmat[m_I][2] = glcolar[m_I4]; ++m_I4;\
01370 ++m_I4;\
01371 }\
01372 }
01373 #define SUMA_GLCOLAR4_2_RGBvec(glcolar, RGBvec, nrgb) {\
01374 int m_I, m_I4 = 0, m_I3=0; \
01375 for (m_I=0; m_I < nrgb; ++m_I) {\
01376 RGBvec[m_I3] = glcolar[m_I4]; ++m_I4; ++m_I3;\
01377 RGBvec[m_I3] = glcolar[m_I4]; ++m_I4; ++m_I3;\
01378 RGBvec[m_I3] = glcolar[m_I4]; ++m_I4; ++m_I3;\
01379 ++m_I4;\
01380 }\
01381 }
01382
01383
01384
01385
01386
01387
01388
01389
01390
01391
01392
01393
01394 #define SUMA_FillBlanks_GLCOLAR4(isColored, N_Nodes, R, G, B, glcolar) {\
01395 int m_I, m_I4; \
01396 for (m_I=0; m_I < N_Nodes; ++m_I) {\
01397 if (!isColored[m_I]) {\
01398 m_I4 = 4*m_I; \
01399 glcolar[m_I4] = R; ++m_I4;\
01400 glcolar[m_I4] = G; ++m_I4;\
01401 glcolar[m_I4] = B; ++m_I4;\
01402 }\
01403 }\
01404 }
01405
01406
01407
01408
01409
01410
01411
01412
01413
01414
01415
01416
01417
01418
01419
01420
01421
01422
01423 #define SUMA_RGB_FnGnL_AR4op(RGBmat, glcolar, nrgb, isColored) {\
01424 int m_I, m_I4 = 0; \
01425 for (m_I=0; m_I < nrgb; ++m_I) {\
01426 isColored[m_I] = YUP;\
01427 glcolar[m_I4] = RGBmat[m_I][0]; ++m_I4;\
01428 glcolar[m_I4] = RGBmat[m_I][1]; ++m_I4;\
01429 glcolar[m_I4] = RGBmat[m_I][2]; ++m_I4;\
01430 ++m_I4;\
01431 }\
01432 }
01433
01434 #define SUMA_RGBv_FnGnL_AR4op(RGBvec, glcolar, nrgb, isColored) {\
01435 int m_I, m_I4 = 0, m_I3=0; \
01436 for (m_I=0; m_I < nrgb; ++m_I) {\
01437 isColored[m_I] = YUP;\
01438 glcolar[m_I4] = RGBvec[m_I3]; ++m_I4; ++m_I3;\
01439 glcolar[m_I4] = RGBvec[m_I3]; ++m_I4; ++m_I3;\
01440 glcolar[m_I4] = RGBvec[m_I3]; ++m_I4; ++m_I3;\
01441 ++m_I4;\
01442 }\
01443 }
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455
01456
01457
01458
01459
01460
01461
01462
01463
01464
01465
01466 #define SUMA_RGB_FGnL_AR4op(RGBmat, glcolar, nrgb, opacity, isColored) {\
01467 int m_I, m_I4 = 0; \
01468 float m_of;\
01469 m_of = 1-opacity;\
01470 for (m_I=0; m_I < nrgb; ++m_I) {\
01471 if (isColored[m_I]) { \
01472 glcolar[m_I4] = m_of * glcolar[m_I4] + opacity * RGBmat[m_I][0]; ++m_I4;\
01473 glcolar[m_I4] = m_of * glcolar[m_I4] + opacity * RGBmat[m_I][1]; ++m_I4;\
01474 glcolar[m_I4] = m_of * glcolar[m_I4] + opacity * RGBmat[m_I][2]; ++m_I4;\
01475 } else { \
01476 glcolar[m_I4] = RGBmat[m_I][0]; ++m_I4;\
01477 glcolar[m_I4] = RGBmat[m_I][1]; ++m_I4;\
01478 glcolar[m_I4] = RGBmat[m_I][2]; ++m_I4;\
01479 isColored[m_I] = YUP;\
01480 } \
01481 ++m_I4;\
01482 }\
01483 }
01484 #define SUMA_RGBv_FGnL_AR4op(RGBvec, glcolar, nrgb, opacity, isColored) {\
01485 int m_I, m_I4 = 0, m_I3 = 0; \
01486 float m_of;\
01487 m_of = 1-opacity;\
01488 for (m_I=0; m_I < nrgb; ++m_I) {\
01489 if (isColored[m_I]) { \
01490 glcolar[m_I4] = m_of * glcolar[m_I4] + opacity * RGBvec[m_I3]; ++m_I4; ++m_I3;\
01491 glcolar[m_I4] = m_of * glcolar[m_I4] + opacity * RGBvec[m_I3]; ++m_I4; ++m_I3;\
01492 glcolar[m_I4] = m_of * glcolar[m_I4] + opacity * RGBvec[m_I3]; ++m_I4; ++m_I3;\
01493 } else { \
01494 glcolar[m_I4] = RGBvec[m_I3]; ++m_I4; ++m_I3;\
01495 glcolar[m_I4] = RGBvec[m_I3]; ++m_I4; ++m_I3;\
01496 glcolar[m_I4] = RGBvec[m_I3]; ++m_I4; ++m_I3;\
01497 isColored[m_I] = YUP;\
01498 } \
01499 ++m_I4;\
01500 }\
01501 }
01502 #define SUMA_RGB_FGnL_AR4op2(RGBmat, glcolar, nrgb, opacity, isColored) {\
01503 int m_I, m_I4 = 0; \
01504 float m_of;\
01505 m_of = 1-opacity;\
01506 for (m_I=0; m_I < nrgb; ++m_I) {\
01507 if (isColored[m_I]) { \
01508 glcolar[m_I4] = m_of * glcolar[m_I4] + RGBmat[m_I][0]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4;\
01509 glcolar[m_I4] = m_of * glcolar[m_I4] + RGBmat[m_I][1]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4;\
01510 glcolar[m_I4] = m_of * glcolar[m_I4] + RGBmat[m_I][2]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4;\
01511 } else { \
01512 glcolar[m_I4] = RGBmat[m_I][0]; ++m_I4;\
01513 glcolar[m_I4] = RGBmat[m_I][1]; ++m_I4;\
01514 glcolar[m_I4] = RGBmat[m_I][2]; ++m_I4;\
01515 isColored[m_I] = YUP;\
01516 } \
01517 ++m_I4;\
01518 }\
01519 }
01520 #define SUMA_RGBv_FGnL_AR4op2(RGBvec, glcolar, nrgb, opacity, isColored) {\
01521 int m_I, m_I4 = 0, m_I3 = 0; \
01522 float m_of;\
01523 m_of = 1-opacity;\
01524 for (m_I=0; m_I < nrgb; ++m_I) {\
01525 if (isColored[m_I]) { \
01526 glcolar[m_I4] = m_of * glcolar[m_I4] + RGBvec[m_I3]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4; ++m_I3;\
01527 glcolar[m_I4] = m_of * glcolar[m_I4] + RGBvec[m_I3]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4; ++m_I3;\
01528 glcolar[m_I4] = m_of * glcolar[m_I4] + RGBvec[m_I3]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4; ++m_I3;\
01529 } else { \
01530 glcolar[m_I4] = RGBvec[m_I3]; ++m_I4; ++m_I3;\
01531 glcolar[m_I4] = RGBvec[m_I3]; ++m_I4; ++m_I3;\
01532 glcolar[m_I4] = RGBvec[m_I3]; ++m_I4; ++m_I3;\
01533 isColored[m_I] = YUP;\
01534 } \
01535 ++m_I4;\
01536 }\
01537 }
01538
01539
01540
01541
01542
01543
01544
01545
01546
01547
01548
01549
01550
01551
01552
01553
01554
01555
01556
01557
01558
01559
01560
01561
01562
01563 #define SUMA_RGB_FGL_AR4op(RGBmat, glcolar, nrgb, opacity, locgain, isColored) {\
01564 int m_I, m_I4 = 0; \
01565 float m_of, m_of2;\
01566 for (m_I=0; m_I < nrgb; ++m_I) {\
01567 if (isColored[m_I]) { \
01568 m_of = locgain[m_I] * opacity; \
01569 m_of2 = (1-opacity);\
01570 glcolar[m_I4] = m_of2 * glcolar[m_I4] + m_of * RGBmat[m_I][0]; ++m_I4;\
01571 glcolar[m_I4] = m_of2 * glcolar[m_I4] + m_of * RGBmat[m_I][1]; ++m_I4;\
01572 glcolar[m_I4] = m_of2 * glcolar[m_I4] + m_of * RGBmat[m_I][2]; ++m_I4;\
01573 } else { \
01574 glcolar[m_I4] = locgain[m_I] * RGBmat[m_I][0]; ++m_I4;\
01575 glcolar[m_I4] = locgain[m_I] * RGBmat[m_I][1]; ++m_I4;\
01576 glcolar[m_I4] = locgain[m_I] * RGBmat[m_I][2]; ++m_I4;\
01577 isColored[m_I] = YUP;\
01578 } \
01579 ++m_I4;\
01580 }\
01581 }
01582 #define SUMA_RGBv_FGL_AR4op(RGBvec, glcolar, nrgb, opacity, locgain, isColored) {\
01583 int m_I, m_I4 = 0, m_I3 = 0; \
01584 float m_of, m_of2;\
01585 for (m_I=0; m_I < nrgb; ++m_I) {\
01586 if (isColored[m_I]) { \
01587 m_of = locgain[m_I] * opacity; \
01588 m_of2 = (1-opacity);\
01589 glcolar[m_I4] = m_of2 * glcolar[m_I4] + m_of * RGBvec[m_I3]; ++m_I4; ++m_I3;\
01590 glcolar[m_I4] = m_of2 * glcolar[m_I4] + m_of * RGBvec[m_I3]; ++m_I4; ++m_I3;\
01591 glcolar[m_I4] = m_of2 * glcolar[m_I4] + m_of * RGBvec[m_I3]; ++m_I4; ++m_I3;\
01592 } else { \
01593 glcolar[m_I4] = locgain[m_I] * RGBvec[m_I3]; ++m_I4; ++m_I3;\
01594 glcolar[m_I4] = locgain[m_I] * RGBvec[m_I3]; ++m_I4; ++m_I3;\
01595 glcolar[m_I4] = locgain[m_I] * RGBvec[m_I3]; ++m_I4; ++m_I3;\
01596 isColored[m_I] = YUP;\
01597 } \
01598 ++m_I4;\
01599 }\
01600 }
01601 #define SUMA_RGB_FGL_AR4op2(RGBmat, glcolar, nrgb, opacity, locgain, isColored) {\
01602 int m_I, m_I4 = 0; \
01603 float m_of, m_of2;\
01604 for (m_I=0; m_I < nrgb; ++m_I) {\
01605 if (isColored[m_I]) { \
01606 m_of = locgain[m_I]; \
01607 m_of2 = (1-opacity);\
01608 glcolar[m_I4] = m_of2 * glcolar[m_I4] + m_of * RGBmat[m_I][0]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4;\
01609 glcolar[m_I4] = m_of2 * glcolar[m_I4] + m_of * RGBmat[m_I][1]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4;\
01610 glcolar[m_I4] = m_of2 * glcolar[m_I4] + m_of * RGBmat[m_I][2]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4;\
01611 } else { \
01612 glcolar[m_I4] = locgain[m_I] * RGBmat[m_I][0]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4;\
01613 glcolar[m_I4] = locgain[m_I] * RGBmat[m_I][1]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4;\
01614 glcolar[m_I4] = locgain[m_I] * RGBmat[m_I][2]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4;\
01615 isColored[m_I] = YUP;\
01616 } \
01617 ++m_I4;\
01618 }\
01619 }
01620 #define SUMA_RGBv_FGL_AR4op2(RGBvec, glcolar, nrgb, opacity, locgain, isColored) {\
01621 int m_I, m_I4 = 0, m_I3=0; \
01622 float m_of, m_of2;\
01623 for (m_I=0; m_I < nrgb; ++m_I) {\
01624 if (isColored[m_I]) { \
01625 m_of = locgain[m_I]; \
01626 m_of2 = (1-opacity);\
01627 glcolar[m_I4] = m_of2 * glcolar[m_I4] + m_of * RGBvec[m_I3]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4; ++m_I3;\
01628 glcolar[m_I4] = m_of2 * glcolar[m_I4] + m_of * RGBvec[m_I3]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4; ++m_I3;\
01629 glcolar[m_I4] = m_of2 * glcolar[m_I4] + m_of * RGBvec[m_I3]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4; ++m_I3;\
01630 } else { \
01631 glcolar[m_I4] = locgain[m_I] * RGBvec[m_I3]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4; ++m_I3;\
01632 glcolar[m_I4] = locgain[m_I] * RGBvec[m_I3]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4; ++m_I3;\
01633 glcolar[m_I4] = locgain[m_I] * RGBvec[m_I3]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4; ++m_I3;\
01634 isColored[m_I] = YUP;\
01635 } \
01636 ++m_I4;\
01637 }\
01638 }
01639
01640
01641
01642
01643
01644
01645
01646
01647
01648
01649
01650
01651
01652
01653
01654
01655
01656
01657 #define SUMA_RGB_FnGL_AR4op(RGBmat, glcolar, nrgb, locgain, isColored) {\
01658 int m_I, m_I4 = 0; \
01659 float m_of;\
01660 for (m_I=0; m_I < nrgb; ++m_I) {\
01661 glcolar[m_I4] = locgain[m_I] * RGBmat[m_I][0]; ++m_I4;\
01662 glcolar[m_I4] = locgain[m_I] * RGBmat[m_I][1]; ++m_I4;\
01663 glcolar[m_I4] = locgain[m_I] * RGBmat[m_I][2]; ++m_I4;\
01664 isColored[m_I] = YUP;\
01665 ++m_I4;\
01666 }\
01667 }
01668 #define SUMA_RGBv_FnGL_AR4op(RGBvec, glcolar, nrgb, locgain, isColored) {\
01669 int m_I, m_I4 = 0, m_I3=0; \
01670 float m_of;\
01671 for (m_I=0; m_I < nrgb; ++m_I) {\
01672 glcolar[m_I4] = locgain[m_I] * RGBvec[m_I3]; ++m_I4; ++m_I3;\
01673 glcolar[m_I4] = locgain[m_I] * RGBvec[m_I3]; ++m_I4; ++m_I3;\
01674 glcolar[m_I4] = locgain[m_I] * RGBvec[m_I3]; ++m_I4; ++m_I3;\
01675 isColored[m_I] = YUP;\
01676 ++m_I4;\
01677 }\
01678 }
01679
01680
01681
01682
01683
01684
01685
01686
01687
01688
01689
01690
01691
01692
01693
01694
01695
01696
01697 #define SUMA_RGB_PnGnL_AR4op(RGBmat, NodeId, glcolar, nrgb, isColored, N_Node) {\
01698 int m_I, m_I4 = 0; \
01699 for (m_I=0; m_I < nrgb; ++m_I) {\
01700 if (NodeId[m_I] < N_Node) {\
01701 m_I4 = 4*NodeId[m_I]; \
01702 glcolar[m_I4] = RGBmat[m_I][0]; ++m_I4;\
01703 glcolar[m_I4] = RGBmat[m_I][1]; ++m_I4;\
01704 glcolar[m_I4] = RGBmat[m_I][2]; ++m_I4;\
01705 isColored[NodeId[m_I]] = YUP;\
01706 }\
01707 }\
01708 }
01709
01710 #define SUMA_RGBv_PnGnL_AR4op(RGBvec, NodeId, glcolar, nrgb, isColored, N_Node) {\
01711 int m_I, m_I4 = 0, m_I3=0; \
01712 for (m_I=0; m_I < nrgb; ++m_I) {\
01713 if (NodeId[m_I] < N_Node) {\
01714 m_I4 = 4*NodeId[m_I]; \
01715 m_I3 = 3*m_I; \
01716 glcolar[m_I4] = RGBvec[m_I3]; ++m_I4; ++m_I3;\
01717 glcolar[m_I4] = RGBvec[m_I3]; ++m_I4; ++m_I3;\
01718 glcolar[m_I4] = RGBvec[m_I3]; ++m_I4; ++m_I3;\
01719 isColored[NodeId[m_I]] = YUP;\
01720 }\
01721 }\
01722 }
01723
01724
01725
01726
01727
01728
01729
01730
01731
01732
01733
01734
01735
01736
01737
01738
01739
01740
01741
01742
01743
01744
01745
01746
01747
01748
01749 #define SUMA_RGB_PGnL_AR4op(RGBmat, NodeId, glcolar, nrgb, isColored, opacity, N_Node) {\
01750 int m_I, m_I4 = 0, m_II; \
01751 float m_of;\
01752 m_of = (1 - opacity); \
01753 for (m_I=0; m_I < nrgb; ++m_I) {\
01754 if (!isColored[NodeId[m_I]]) { \
01755 if (NodeId[m_I] < N_Node) {\
01756 m_I4 = 4*NodeId[m_I]; \
01757 glcolar[m_I4] = RGBmat[m_I][0]; ++m_I4;\
01758 glcolar[m_I4] = RGBmat[m_I][1]; ++m_I4;\
01759 glcolar[m_I4] = RGBmat[m_I][2]; ++m_I4;\
01760 isColored[NodeId[m_I]] = YUP;\
01761 }\
01762 }else {\
01763 if (NodeId[m_I] < N_Node) {\
01764 m_I4 = 4*NodeId[m_I]; \
01765 glcolar[m_I4] = m_of * glcolar[m_I4] + opacity * RGBmat[m_I][0]; ++m_I4;\
01766 glcolar[m_I4] = m_of * glcolar[m_I4] + opacity * RGBmat[m_I][1]; ++m_I4;\
01767 glcolar[m_I4] = m_of * glcolar[m_I4] + opacity * RGBmat[m_I][2]; ++m_I4;\
01768 }\
01769 }\
01770 }\
01771 }
01772 #define SUMA_RGBv_PGnL_AR4op(RGBvec, NodeId, glcolar, nrgb, isColored, opacity, N_Node) {\
01773 int m_I, m_I4 = 0, m_II, m_I3=0; \
01774 float m_of;\
01775 m_of = (1 - opacity); \
01776 for (m_I=0; m_I < nrgb; ++m_I) {\
01777 if (!isColored[NodeId[m_I]]) { \
01778 if (NodeId[m_I] < N_Node) {\
01779 m_I4 = 4*NodeId[m_I]; \
01780 m_I3 = 3*m_I; \
01781 glcolar[m_I4] = RGBvec[m_I3]; ++m_I4; ++m_I3;\
01782 glcolar[m_I4] = RGBvec[m_I3]; ++m_I4; ++m_I3;\
01783 glcolar[m_I4] = RGBvec[m_I3]; ++m_I4; ++m_I3;\
01784 isColored[NodeId[m_I]] = YUP;\
01785 }\
01786 }else {\
01787 if (NodeId[m_I] < N_Node) {\
01788 m_I4 = 4*NodeId[m_I]; \
01789 m_I3 = 3*m_I; \
01790 glcolar[m_I4] = m_of * glcolar[m_I4] + opacity * RGBvec[m_I3]; ++m_I4; ++m_I3;\
01791 glcolar[m_I4] = m_of * glcolar[m_I4] + opacity * RGBvec[m_I3]; ++m_I4; ++m_I3;\
01792 glcolar[m_I4] = m_of * glcolar[m_I4] + opacity * RGBvec[m_I3]; ++m_I4; ++m_I3;\
01793 }\
01794 }\
01795 }\
01796 }
01797
01798 #define SUMA_RGB_PGnL_AR4op2(RGBmat, NodeId, glcolar, nrgb, isColored, opacity, N_Node) {\
01799 int m_I, m_I4 = 0, m_II; \
01800 float m_of;\
01801 m_of = (1 - opacity); \
01802 for (m_I=0; m_I < nrgb; ++m_I) {\
01803 if (!isColored[NodeId[m_I]]) { \
01804 if (NodeId[m_I] < N_Node) {\
01805 m_I4 = 4*NodeId[m_I]; \
01806 glcolar[m_I4] = RGBmat[m_I][0]; ++m_I4;\
01807 glcolar[m_I4] = RGBmat[m_I][1]; ++m_I4;\
01808 glcolar[m_I4] = RGBmat[m_I][2]; ++m_I4;\
01809 isColored[NodeId[m_I]] = YUP;\
01810 }\
01811 }else {\
01812 if (NodeId[m_I] < N_Node) {\
01813 m_I4 = 4*NodeId[m_I]; \
01814 glcolar[m_I4] = m_of * glcolar[m_I4] + RGBmat[m_I][0]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4;\
01815 glcolar[m_I4] = m_of * glcolar[m_I4] + RGBmat[m_I][1]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4;\
01816 glcolar[m_I4] = m_of * glcolar[m_I4] + RGBmat[m_I][2]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4;\
01817 }\
01818 }\
01819 }\
01820 }
01821 #define SUMA_RGBv_PGnL_AR4op2(RGBvec, NodeId, glcolar, nrgb, isColored, opacity, N_Node) {\
01822 int m_I, m_I4 = 0, m_II, m_I3=0; \
01823 float m_of;\
01824 m_of = (1 - opacity); \
01825 for (m_I=0; m_I < nrgb; ++m_I) {\
01826 if (!isColored[NodeId[m_I]]) { \
01827 if (NodeId[m_I] < N_Node) {\
01828 m_I4 = 4*NodeId[m_I]; \
01829 m_I3 = 3*m_I; \
01830 glcolar[m_I4] = RGBvec[m_I3]; ++m_I4; ++m_I3;\
01831 glcolar[m_I4] = RGBvec[m_I3]; ++m_I4; ++m_I3;\
01832 glcolar[m_I4] = RGBvec[m_I3]; ++m_I4; ++m_I3;\
01833 isColored[NodeId[m_I]] = YUP;\
01834 }\
01835 }else {\
01836 if (NodeId[m_I] < N_Node) {\
01837 m_I4 = 4*NodeId[m_I]; \
01838 m_I3 = 3*m_I; \
01839 glcolar[m_I4] = m_of * glcolar[m_I4] + RGBvec[m_I3]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4; ++m_I3;\
01840 glcolar[m_I4] = m_of * glcolar[m_I4] + RGBvec[m_I3]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4; ++m_I3;\
01841 glcolar[m_I4] = m_of * glcolar[m_I4] + RGBvec[m_I3]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4; ++m_I3;\
01842 }\
01843 }\
01844 }\
01845 }
01846
01847
01848
01849
01850
01851
01852
01853
01854
01855
01856
01857
01858
01859
01860
01861
01862
01863
01864
01865
01866
01867
01868
01869
01870
01871
01872
01873
01874 #define SUMA_RGB_PGL_AR4op(RGBmat, NodeId, glcolar, nrgb, isColored, opacity, locgain, N_Node) {\
01875 int m_I, m_I4 = 0; \
01876 float m_of, m_of2;\
01877 for (m_I=0; m_I < nrgb; ++m_I) {\
01878 if (!isColored[NodeId[m_I]]) { \
01879 if (NodeId[m_I] < N_Node) {\
01880 m_I4 = 4*NodeId[m_I]; \
01881 glcolar[m_I4] = locgain[m_I] * RGBmat[m_I][0]; ++m_I4;\
01882 glcolar[m_I4] = locgain[m_I] * RGBmat[m_I][1]; ++m_I4;\
01883 glcolar[m_I4] = locgain[m_I] * RGBmat[m_I][2]; ++m_I4;\
01884 isColored[NodeId[m_I]] = YUP;\
01885 }\
01886 }else { \
01887 if (NodeId[m_I] < N_Node) {\
01888 m_I4 = 4*NodeId[m_I]; \
01889 m_of = (locgain[m_I] * opacity); \
01890 m_of2 = (1 - opacity);\
01891 glcolar[m_I4] = m_of2 * glcolar[m_I4] + m_of * RGBmat[m_I][0]; ++m_I4;\
01892 glcolar[m_I4] = m_of2 * glcolar[m_I4] + m_of * RGBmat[m_I][1]; ++m_I4;\
01893 glcolar[m_I4] = m_of2 * glcolar[m_I4] + m_of * RGBmat[m_I][2]; ++m_I4;\
01894 }\
01895 }\
01896 }\
01897 }
01898 #define SUMA_RGBv_PGL_AR4op(RGBvec, NodeId, glcolar, nrgb, isColored, opacity, locgain, N_Node) {\
01899 int m_I, m_I4 = 0, m_I3=0; \
01900 float m_of, m_of2;\
01901 for (m_I=0; m_I < nrgb; ++m_I) {\
01902 if (!isColored[NodeId[m_I]]) { \
01903 if (NodeId[m_I] < N_Node) {\
01904 m_I4 = 4*NodeId[m_I]; \
01905 m_I3 = 3*m_I; \
01906 glcolar[m_I4] = locgain[m_I] * RGBvec[m_I3]; ++m_I4; ++m_I3;\
01907 glcolar[m_I4] = locgain[m_I] * RGBvec[m_I3]; ++m_I4; ++m_I3;\
01908 glcolar[m_I4] = locgain[m_I] * RGBvec[m_I3]; ++m_I4; ++m_I3;\
01909 isColored[NodeId[m_I]] = YUP;\
01910 }\
01911 }else { \
01912 if (NodeId[m_I] < N_Node) {\
01913 m_I4 = 4*NodeId[m_I]; \
01914 m_I3 = 3*m_I; \
01915 m_of = (locgain[m_I] * opacity); \
01916 m_of2 = (1 - opacity);\
01917 glcolar[m_I4] = m_of2 * glcolar[m_I4] + m_of * RGBvec[m_I3]; ++m_I4; ++m_I3;\
01918 glcolar[m_I4] = m_of2 * glcolar[m_I4] + m_of * RGBvec[m_I3]; ++m_I4; ++m_I3;\
01919 glcolar[m_I4] = m_of2 * glcolar[m_I4] + m_of * RGBvec[m_I3]; ++m_I4; ++m_I3;\
01920 }\
01921 }\
01922 }\
01923 }
01924
01925 #define SUMA_RGB_PGL_AR4op2(RGBmat, NodeId, glcolar, nrgb, isColored, opacity, locgain, N_Node) {\
01926 int m_I, m_I4 = 0; \
01927 float m_of, m_of2;\
01928 for (m_I=0; m_I < nrgb; ++m_I) {\
01929 if (!isColored[NodeId[m_I]]) { \
01930 if (NodeId[m_I] < N_Node) {\
01931 m_I4 = 4*NodeId[m_I]; \
01932 glcolar[m_I4] = locgain[m_I] * RGBmat[m_I][0]; ++m_I4;\
01933 glcolar[m_I4] = locgain[m_I] * RGBmat[m_I][1]; ++m_I4;\
01934 glcolar[m_I4] = locgain[m_I] * RGBmat[m_I][2]; ++m_I4;\
01935 isColored[NodeId[m_I]] = YUP;\
01936 }\
01937 }else { \
01938 if (NodeId[m_I] < N_Node) {\
01939 m_I4 = 4*NodeId[m_I]; \
01940 m_of = (locgain[m_I]); \
01941 m_of2 = (1 - opacity);\
01942 glcolar[m_I4] = m_of2 * glcolar[m_I4] + m_of * RGBmat[m_I][0]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4;\
01943 glcolar[m_I4] = m_of2 * glcolar[m_I4] + m_of * RGBmat[m_I][1]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4;\
01944 glcolar[m_I4] = m_of2 * glcolar[m_I4] + m_of * RGBmat[m_I][2]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4;\
01945 }\
01946 }\
01947 }\
01948 }
01949 #define SUMA_RGBv_PGL_AR4op2(RGBvec, NodeId, glcolar, nrgb, isColored, opacity, locgain, N_Node) {\
01950 int m_I, m_I4 = 0, m_I3=0; \
01951 float m_of, m_of2;\
01952 for (m_I=0; m_I < nrgb; ++m_I) {\
01953 if (!isColored[NodeId[m_I]]) { \
01954 if (NodeId[m_I] < N_Node) {\
01955 m_I4 = 4*NodeId[m_I]; \
01956 m_I3 = 3*m_I; \
01957 glcolar[m_I4] = locgain[m_I] * RGBvec[m_I3]; ++m_I4; ++m_I3;\
01958 glcolar[m_I4] = locgain[m_I] * RGBvec[m_I3]; ++m_I4; ++m_I3;\
01959 glcolar[m_I4] = locgain[m_I] * RGBvec[m_I3]; ++m_I4; ++m_I3;\
01960 isColored[NodeId[m_I]] = YUP;\
01961 }\
01962 }else { \
01963 if (NodeId[m_I] < N_Node) {\
01964 m_I4 = 4*NodeId[m_I]; \
01965 m_I3 = 3*m_I; \
01966 m_of = (locgain[m_I]); \
01967 m_of2 = (1 - opacity);\
01968 glcolar[m_I4] = m_of2 * glcolar[m_I4] + m_of * RGBvec[m_I3]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4; ++m_I3;\
01969 glcolar[m_I4] = m_of2 * glcolar[m_I4] + m_of * RGBvec[m_I3]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4; ++m_I3;\
01970 glcolar[m_I4] = m_of2 * glcolar[m_I4] + m_of * RGBvec[m_I3]; SUMA_CLIP_UB(glcolar[m_I4], 1.0); ++m_I4; ++m_I3;\
01971 }\
01972 }\
01973 }\
01974 }
01975
01976
01977
01978
01979
01980
01981
01982
01983
01984
01985
01986
01987
01988
01989
01990
01991
01992
01993
01994
01995 #define SUMA_RGB_PnGL_AR4op(RGBmat, NodeId, glcolar, nrgb, isColored, locgain, N_Node) {\
01996 int m_I, m_I4 = 0; \
01997 float m_of;\
01998 for (m_I=0; m_I < nrgb; ++m_I) {\
01999 if (NodeId[m_I] < N_Node) {\
02000 m_I4 = 4*NodeId[m_I]; \
02001 glcolar[m_I4] = locgain[m_I] * RGBmat[m_I][0]; ++m_I4;\
02002 glcolar[m_I4] = locgain[m_I] * RGBmat[m_I][1]; ++m_I4;\
02003 glcolar[m_I4] = locgain[m_I] * RGBmat[m_I][2]; ++m_I4;\
02004 isColored[NodeId[m_I]] = YUP;\
02005 }\
02006 }\
02007 }
02008 #define SUMA_RGBv_PnGL_AR4op(RGBvec, NodeId, glcolar, nrgb, isColored, locgain, N_Node) {\
02009 int m_I, m_I4 = 0, m_I3=0; \
02010 float m_of;\
02011 for (m_I=0; m_I < nrgb; ++m_I) {\
02012 if (NodeId[m_I] < N_Node) {\
02013 m_I4 = 4*NodeId[m_I]; \
02014 m_I3 = 3*m_I; \
02015 glcolar[m_I4] = locgain[m_I] * RGBvec[m_I3]; ++m_I4; ++m_I3;\
02016 glcolar[m_I4] = locgain[m_I] * RGBvec[m_I3]; ++m_I4; ++m_I3;\
02017 glcolar[m_I4] = locgain[m_I] * RGBvec[m_I3]; ++m_I4; ++m_I3;\
02018 isColored[NodeId[m_I]] = YUP;\
02019 }\
02020 }\
02021 }
02022 #endif
02023