| 14 |
|
|
| 15 |
void do_byteswap_f32( float arr[], int nel ), global(), local( int, int, int ); |
void do_byteswap_f32( float arr[], int nel ), global(), local( int, int, int ); |
| 16 |
void readnames( char[] ), readarray( float[], char[], int ), readjet(), readxz( float[], char[] ); |
void readnames( char[] ), readarray( float[], char[], int ), readjet(), readxz( float[], char[] ); |
| 17 |
|
void readyz( float[], char[] ); |
| 18 |
void TimerFunction( int ), bitmap( char[], int, int ); |
void TimerFunction( int ), bitmap( char[], int, int ); |
| 19 |
|
|
| 20 |
float data[MAX][MAX*MAX], mxval, mnval, jet[64][3]; |
float data[MAX][MAX*MAX], mxval, mnval, jet[64][3]; |
| 21 |
float globalmx=0, globalmn=100; |
float globalmx=0, globalmn=100; |
| 22 |
int win[MAX], ilev=1, howmany, sets, count=0, glo=0, usr=0, anim=0, logscale=0, xz=0, nonegs=1, endian=0; |
int win[MAX], ilev=1, howmany, sets, count=0, glo=0, usr=0, anim=0, logscale=0, xz=0, nonegs=1, endian=0; |
| 23 |
int xmax, ymax, offset=0; |
int xmax, ymax, yoffset=0, xoffset=0, yz=0; |
| 24 |
char initfns[MAX][MAX], fns[MAX][MAX][MAX]; |
char initfns[MAX][MAX], fns[MAX][MAX][MAX]; |
| 25 |
|
|
| 26 |
void menu(int value){ // called when menu is opened on right click |
void menu(int value){ // called when menu is opened on right click |
| 61 |
for( q=0; q<sets; q++ ){ // runs display func for each subwindow |
for( q=0; q<sets; q++ ){ // runs display func for each subwindow |
| 62 |
glutSetWindow( win[q] ); // sets which subwindow to display to |
glutSetWindow( win[q] ); // sets which subwindow to display to |
| 63 |
glClear( GL_COLOR_BUFFER_BIT ); // background to black |
glClear( GL_COLOR_BUFFER_BIT ); // background to black |
| 64 |
if( xz ) ymax=NZ; |
if( xz ) { xmax=NX; ymax=NZ; } |
| 65 |
else ymax=NY; |
else{ |
| 66 |
|
if( yz ){ xmax=NY; ymax=NZ; } |
| 67 |
|
else { xmax=NX; ymax=NY; } |
| 68 |
|
} |
| 69 |
|
|
| 70 |
if( glo || usr ){ // if global or user-set max/min |
if( glo || usr ){ // if global or user-set max/min |
| 71 |
if( xz ) |
if( xz ) |
| 72 |
readxz( data[q], fns[q][count] ); |
readxz( data[q], fns[q][count] ); |
| 73 |
else |
else{ |
| 74 |
readarray( data[q], fns[q][count], ilev ); // read new array w/o calculating local max/min |
if( yz ) |
| 75 |
|
readyz( data[q], fns[q][count] ); |
| 76 |
|
else |
| 77 |
|
readarray( data[q], fns[q][count], ilev ); // read new array w/o calculating local max/min |
| 78 |
|
} |
| 79 |
} |
} |
| 80 |
else // if local max/min is set |
else // if local max/min is set |
| 81 |
local( q, count, ilev ); // read new array and calculate local max/min |
local( q, count, ilev ); // read new array and calculate local max/min |
| 149 |
bitmap( str, xmax+2, 1 ); |
bitmap( str, xmax+2, 1 ); |
| 150 |
|
|
| 151 |
if( xz ) |
if( xz ) |
| 152 |
sprintf( str, "Y-coordinate=%d", offset+1); |
sprintf( str, "Y-coordinate=%d", yoffset+1); |
| 153 |
else |
else{ |
| 154 |
sprintf( str, "Level %d", ilev ); // labels current level |
if( yz ) |
| 155 |
|
sprintf( str, "X-coordinate=%d", xoffset+1); |
| 156 |
|
else |
| 157 |
|
sprintf( str, "Level %d", ilev ); // labels current level |
| 158 |
|
} |
| 159 |
bitmap( str, 1, ymax+3 ); |
bitmap( str, 1, ymax+3 ); |
| 160 |
|
|
| 161 |
sprintf( str, "Time %d", count+1 ); // labels current time |
sprintf( str, "Time %d", count+1 ); // labels current time |
| 208 |
glutPostRedisplay(); |
glutPostRedisplay(); |
| 209 |
break; |
break; |
| 210 |
case 'x': xz=(xz+1)%2; |
case 'x': xz=(xz+1)%2; |
| 211 |
|
yz=0; |
| 212 |
glutPostRedisplay(); |
glutPostRedisplay(); |
| 213 |
break; |
break; |
| 214 |
|
case 'y': yz=(yz+1)%2; |
| 215 |
|
xz=0; |
| 216 |
|
glutPostRedisplay(); |
| 217 |
} |
} |
| 218 |
} |
} |
| 219 |
|
|
| 221 |
int i; |
int i; |
| 222 |
|
|
| 223 |
switch(value){ // increments in the correct direction |
switch(value){ // increments in the correct direction |
| 224 |
case DOWN : if( xz ){ |
case DOWN : if( xz && yoffset>0 ) |
| 225 |
if( offset>0 ) |
yoffset--; |
|
offset--; |
|
|
} |
|
| 226 |
else{ |
else{ |
| 227 |
if( ilev<NZ ) |
if( yz && xoffset<NX-1 ) |
| 228 |
ilev++; // if down arrow pressed, move down a level |
xoffset++; |
| 229 |
|
else |
| 230 |
|
if( ilev<NZ && !xz && !yz ) |
| 231 |
|
ilev++; // if down arrow pressed, move down a level |
| 232 |
} |
} |
| 233 |
break; |
break; |
| 234 |
case UP : if( xz ){ |
case UP : if( xz && yoffset<NY-1 ) |
| 235 |
if( offset<NY-1 ) |
yoffset++; |
|
offset++; |
|
|
} |
|
| 236 |
else{ |
else{ |
| 237 |
if( ilev>1 ) |
if( yz && xoffset>0 ) |
| 238 |
ilev--; // if up arrow is pressed, move up a level |
xoffset--; |
| 239 |
|
else |
| 240 |
|
if( ilev>1 && !xz && !yz ) |
| 241 |
|
ilev--; // if up arrow is pressed, move up a level |
| 242 |
} |
} |
| 243 |
break; |
break; |
| 244 |
case LEFT : if( count>0 ) |
case LEFT : if( count>0 ) |
| 251 |
|
|
| 252 |
glutPostRedisplay(); |
glutPostRedisplay(); |
| 253 |
|
|
| 254 |
if (anim ) |
if ( anim ) |
| 255 |
switch( value ){ |
switch( value ){ |
| 256 |
case DOWN : if( xz ){ |
case DOWN : if( xz && yoffset==0 ) |
| 257 |
if( offset==0 ) offset=NY-1; |
yoffset=NY-1; |
|
} |
|
| 258 |
else{ |
else{ |
| 259 |
if( ilev==NZ ) ilev=1; // if end reached, restart |
if( yz && xoffset==NX-1 ) |
| 260 |
|
xoffset=0; |
| 261 |
|
else |
| 262 |
|
if( ilev==NZ && !xz && !yz ) |
| 263 |
|
ilev=1; // if end reached, restart |
| 264 |
} |
} |
| 265 |
glutTimerFunc( 100, TimerFunction, value ); // recalls itself |
glutTimerFunc( 100, TimerFunction, value ); // recalls itself |
| 266 |
break; |
break; |
| 267 |
case UP : if( xz ){ |
case UP : if( xz && yoffset==NY-1 ) |
| 268 |
if( offset==NY-1) offset=0; |
yoffset=0; |
|
} |
|
| 269 |
else{ |
else{ |
| 270 |
if( ilev==1 ) ilev=NZ; // if end reached, restart |
if( yz && xoffset==0 ) |
| 271 |
|
xoffset=NX-1; |
| 272 |
|
else |
| 273 |
|
if( ilev==1 ) |
| 274 |
|
ilev=NZ; // if end reached, restart |
| 275 |
} |
} |
| 276 |
glutTimerFunc( 100, TimerFunction, value ); // recalls itself |
glutTimerFunc( 100, TimerFunction, value ); // recalls itself |
| 277 |
break; |
break; |
| 291 |
glutTimerFunc( 100, TimerFunction, key); // to scroll automatically |
glutTimerFunc( 100, TimerFunction, key); // to scroll automatically |
| 292 |
|
|
| 293 |
switch(key){ |
switch(key){ |
| 294 |
case DOWN : if( xz ){ |
case DOWN : if( xz && yoffset>0 ) |
| 295 |
if( offset>0 ) |
yoffset--; |
|
offset--; |
|
|
} |
|
| 296 |
else{ |
else{ |
| 297 |
if( ilev<NZ ) // if you haven't reached the bottom |
if( yz && xoffset<NY-1 ) |
| 298 |
ilev++; // keep going down |
xoffset++; |
| 299 |
|
else |
| 300 |
|
if( ilev<NZ && !xz && !yz ) // if you haven't reached the bottom |
| 301 |
|
ilev++; // keep going down |
| 302 |
} |
} |
| 303 |
break; |
break; |
| 304 |
case UP : if( xz ){ |
case UP : if( xz && yoffset<NY-1 ) |
| 305 |
if( offset<NY-1 ) |
yoffset++; |
|
offset++; |
|
|
} |
|
| 306 |
else{ |
else{ |
| 307 |
if( ilev>1 ) // if you haven't reached the top |
if( yz && xoffset>0 ) |
| 308 |
ilev--; // keep going up |
xoffset--; |
| 309 |
|
else |
| 310 |
|
if( ilev>1 ) // if you haven't reached the top |
| 311 |
|
ilev--; // keep going up |
| 312 |
} |
} |
| 313 |
break; |
break; |
| 314 |
case RIGHT : if( count<howmany-1 ) // if you haven't reached the last file |
case RIGHT : if( count<howmany-1 ) // if you haven't reached the last file |
| 340 |
mnval=100; |
mnval=100; |
| 341 |
if( xz ) |
if( xz ) |
| 342 |
readxz( data[i], fns[i][time]); |
readxz( data[i], fns[i][time]); |
| 343 |
else |
else{ |
| 344 |
readarray( data[i], fns[i][time], lev ); // read new array of data |
if( yz ) |
| 345 |
|
readyz( data[i], fns[i][time]); |
| 346 |
|
else |
| 347 |
|
readarray( data[i], fns[i][time], lev ); // read new array of data |
| 348 |
|
} |
| 349 |
for( j=0; j<xmax*ymax; j++ ){ |
for( j=0; j<xmax*ymax; j++ ){ |
| 350 |
if( data[i][j] > mxval ) |
if( data[i][j] > mxval ) |
| 351 |
mxval=data[i][j]; // set largest val to mxval |
mxval=data[i][j]; // set largest val to mxval |
| 390 |
} |
} |
| 391 |
|
|
| 392 |
void readxz( float arr[], char filename[] ){ |
void readxz( float arr[], char filename[] ){ |
| 393 |
int i; |
int i, j; |
| 394 |
float tmp[MAX*MAX]; |
float tmp[MAX][MAX], tmp2[MAX*MAX]; |
| 395 |
FILE* fp; |
FILE* fp; |
| 396 |
|
|
| 397 |
fp=fopen( filename, "rb" ); |
fp=fopen( filename, "rb" ); |
| 398 |
for( i=0; i<NZ; i++){ |
for( i=0; i<NZ; i++){ |
| 399 |
fseek( fp, (NX*offset*4)+(i*NX*NY*4), SEEK_SET ); |
fseek( fp, (NX*yoffset*4)+(i*NX*NY*4), SEEK_SET ); |
| 400 |
fread( &arr[NX*i], sizeof( arr[0] ), NX, fp ); // reads in data to fill one level |
fread( &arr[NX*i], sizeof( arr[0] ), NX, fp ); // reads in data to fill one level |
| 401 |
} |
} |
| 402 |
fclose( fp ); |
fclose( fp ); |
| 403 |
for( i=1; i<NX*NZ+1; i++ ) |
|
| 404 |
tmp[NX*NZ-i]=arr[i-1]; |
for( i=0; i<NZ; i++ ) |
| 405 |
for( i=0; i<NX*NZ; i++ ) |
for( j=0; j<NX; j++) |
| 406 |
arr[i]=tmp[i]; |
tmp[i][j]=arr[i*NX+j]; |
| 407 |
|
|
| 408 |
|
for( i=0; i<NZ; i++ ) |
| 409 |
|
for( j=0; j<NX; j++) |
| 410 |
|
tmp2[i*NX+j]=tmp[NZ-i-1][j]; |
| 411 |
|
|
| 412 |
|
for( i=0; i<NX*NZ; i++) |
| 413 |
|
arr[i]=tmp2[i]; |
| 414 |
|
} |
| 415 |
|
|
| 416 |
|
void readyz( float arr[], char filename[] ){ |
| 417 |
|
int i, j; |
| 418 |
|
float tmp[MAX][MAX], tmp2[MAX*MAX]; |
| 419 |
|
FILE* fp; |
| 420 |
|
|
| 421 |
|
fp=fopen( filename, "rb" ); |
| 422 |
|
for( i=0; i<NY*NZ; i++ ){ |
| 423 |
|
fseek( fp, (xoffset*4)+(i*NX*4), SEEK_SET ); |
| 424 |
|
fread( &arr[i], sizeof( arr[0] ), 1, fp ); |
| 425 |
|
} |
| 426 |
|
fclose(fp); |
| 427 |
|
|
| 428 |
|
for( i=0; i<NZ; i++ ) |
| 429 |
|
for( j=0; j<NY; j++) |
| 430 |
|
tmp[i][j]=arr[i*NY+j]; |
| 431 |
|
|
| 432 |
|
for( i=0; i<NZ; i++ ) |
| 433 |
|
for( j=0; j<NY; j++) |
| 434 |
|
tmp2[i*NY+j]=tmp[NZ-i-1][j]; |
| 435 |
|
|
| 436 |
|
for( i=0; i<NY*NZ; i++) |
| 437 |
|
arr[i]=tmp2[i]; |
| 438 |
} |
} |
| 439 |
|
|
| 440 |
void readarray( float arr[], char filename[], int il ){ // reads new data |
void readarray( float arr[], char filename[], int il ){ // reads new data |
| 441 |
FILE* fp; |
FILE* fp; |
| 442 |
int i; |
int i; |
| 443 |
|
|
| 444 |
fp=fopen( filename, "rb" ); // opens the file containing data |
fp=fopen( filename, "rb" ); // opens the file containing data |
| 445 |
fseek( fp, (il-1)*NX*NY*4, SEEK_SET ); // seeks to the correct place using ilev |
fseek( fp, (il-1)*NX*NY*4, SEEK_SET ); // seeks to the correct place using ilev |
| 446 |
fread( arr, sizeof( arr[0] ), NX*NY, fp ); // reads in data to fill one level |
fread( arr, sizeof( arr[0] ), NX*NY, fp ); // reads in data to fill one level |
| 447 |
fclose( fp ); // close file |
fclose( fp ); // close file |