| 5 |
|
* Gather rtrace output to compute contributions from particular sources |
| 6 |
|
*/ |
| 7 |
|
|
| 8 |
+ |
#include "standard.h" |
| 9 |
|
#include <ctype.h> |
| 9 |
– |
#include "rtio.h" |
| 10 |
– |
#include "rterror.h" |
| 10 |
|
#include "platform.h" |
| 11 |
|
#include "rtprocess.h" |
| 12 |
|
#include "selcall.h" |
| 63 |
|
int bsiz; /* ray tree buffer length */ |
| 64 |
|
char *buf; /* ray tree buffer */ |
| 65 |
|
int nbr; /* number of bytes from rtrace */ |
| 66 |
< |
}; /* rtrace process */ |
| 66 |
> |
}; /* rtrace process buffer */ |
| 67 |
|
|
| 68 |
|
/* rtrace command and defaults */ |
| 69 |
|
char *rtargv[256] = { "rtrace", "-dt", "0", "-dj", ".5", "-dr", "3", |
| 79 |
|
struct rtproc *rt_unproc = NULL; /* unprocessed ray trees */ |
| 80 |
|
|
| 81 |
|
char persistfn[] = "pfXXXXXX"; /* persist file name */ |
| 83 |
– |
char fmt[8]; /* rtrace i/o format */ |
| 82 |
|
|
| 83 |
|
int gargc; /* global argc */ |
| 84 |
|
char **gargv; /* global argv */ |
| 106 |
|
|
| 107 |
|
MODCONT *addmodifier(char *modn, char *outf, char *binv); |
| 108 |
|
|
| 111 |
– |
int done_rprocs(struct rtproc *rtp); |
| 109 |
|
void init(int np); |
| 110 |
< |
void tracecontribs(FILE *fp); |
| 110 |
> |
int done_rprocs(struct rtproc *rtp); |
| 111 |
> |
void trace_contribs(FILE *fp); |
| 112 |
|
struct rtproc *wait_rproc(void); |
| 113 |
|
struct rtproc *get_rproc(void); |
| 114 |
|
void queue_raytree(struct rtproc *rtp); |
| 158 |
|
int nprocs = 1; |
| 159 |
|
char *curout = NULL; |
| 160 |
|
char *binval = NULL; |
| 161 |
+ |
char fmt[8]; |
| 162 |
|
int i, j; |
| 163 |
|
/* global program name */ |
| 164 |
|
gargv = argv; |
| 269 |
|
execv(rtpath, rtargv); |
| 270 |
|
perror(rtpath); /* execv() should not return */ |
| 271 |
|
exit(1); |
| 272 |
< |
} else if (nprocs > 1) { /* add persist file if parallel */ |
| 272 |
> |
} |
| 273 |
> |
if (nprocs > 1) { /* add persist file if parallel */ |
| 274 |
|
rtargv[rtargc++] = "-PP"; |
| 275 |
|
rtargv[rtargc++] = mktemp(persistfn); |
| 276 |
|
} |
| 284 |
|
rtargv[rtargc] = NULL; |
| 285 |
|
/* start rtrace & compute contributions */ |
| 286 |
|
init(nprocs); |
| 287 |
< |
tracecontribs(stdin); |
| 287 |
> |
trace_contribs(stdin); |
| 288 |
|
quit(0); |
| 289 |
|
} |
| 290 |
|
|
| 336 |
|
exit(status); /* flushes all output streams */ |
| 337 |
|
} |
| 338 |
|
|
| 339 |
< |
/* start rtrace and initialize buffers */ |
| 339 |
> |
/* start rtrace processes and initialize */ |
| 340 |
|
void |
| 341 |
|
init(int np) |
| 342 |
|
{ |
| 562 |
|
int |
| 563 |
|
getinp(char *buf, FILE *fp) |
| 564 |
|
{ |
| 565 |
+ |
char *cp; |
| 566 |
+ |
int i; |
| 567 |
+ |
|
| 568 |
|
switch (inpfmt) { |
| 569 |
|
case 'a': |
| 570 |
< |
if (fgets(buf, 128, fp) == NULL) |
| 571 |
< |
return 0; |
| 570 |
> |
cp = buf; /* make sure we get 6 floats */ |
| 571 |
> |
for (i = 0; i < 6; i++) { |
| 572 |
> |
if (fgetword(cp, buf+127-cp, fp) == NULL) |
| 573 |
> |
return 0; |
| 574 |
> |
if ((cp = fskip(cp)) == NULL || *cp) |
| 575 |
> |
return 0; |
| 576 |
> |
*cp++ = ' '; |
| 577 |
> |
} |
| 578 |
> |
getc(fp); /* get/put eol */ |
| 579 |
> |
*cp-- = '\0'; *cp = '\n'; |
| 580 |
|
return strlen(buf); |
| 581 |
|
case 'f': |
| 582 |
|
if (fread(buf, sizeof(float), 6, fp) < 6) |
| 843 |
|
|
| 844 |
|
/* trace ray contributions (main loop) */ |
| 845 |
|
void |
| 846 |
< |
tracecontribs(FILE *fin) |
| 846 |
> |
trace_contribs(FILE *fin) |
| 847 |
|
{ |
| 848 |
|
char inpbuf[128]; |
| 849 |
|
int iblen; |