ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/rtcontrib.c
(Generate patch)

Comparing ray/src/util/rtcontrib.c (file contents):
Revision 1.3 by greg, Thu May 26 15:14:42 2005 UTC vs.
Revision 1.6 by greg, Sat May 28 22:27:54 2005 UTC

# Line 5 | Line 5 | static const char RCSid[] = "$Id$";
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"
# Line 64 | Line 63 | struct rtproc {
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",
69 > char            *rtargv[256] = { "rtrace", "-dj", ".5", "-dr", "3",
70                                  "-ab", "1", "-ad", "128", };
71 < int  rtargc = 11;
71 > int  rtargc = 9;
72                                          /* overriding rtrace options */
73 < char            *myrtopts[] = { "-o~~TmWdp", "-h-",
74 <                                "-x", "1", "-y", "0",
76 <                                "-as", "0", "-aa", "0", NULL };
73 > char            *myrtopts[] = { "-o~~TmWdp", "-h-", "-x", "1", "-y", "0",
74 >                                "-dt", "0", "-as", "0", "-aa", "0", NULL };
75  
76   struct rtproc   rt0;                    /* head of rtrace process list */
77  
78   struct rtproc   *rt_unproc = NULL;      /* unprocessed ray trees */
79  
80   char    persistfn[] = "pfXXXXXX";       /* persist file name */
83 char    fmt[8];                         /* rtrace i/o format */
81  
82   int             gargc;                  /* global argc */
83   char            **gargv;                /* global argv */
# Line 108 | Line 105 | int            nmods = 0;              /* number of modifiers */
105  
106   MODCONT *addmodifier(char *modn, char *outf, char *binv);
107  
111 int done_rprocs(struct rtproc *rtp);
108   void init(int np);
109 < void tracecontribs(FILE *fp);
109 > int done_rprocs(struct rtproc *rtp);
110 > void trace_contribs(FILE *fp);
111   struct rtproc *wait_rproc(void);
112   struct rtproc *get_rproc(void);
113   void queue_raytree(struct rtproc *rtp);
# Line 160 | Line 157 | main(int argc, char *argv[])
157          int     nprocs = 1;
158          char    *curout = NULL;
159          char    *binval = NULL;
160 +        char    fmt[8];
161          int     i, j;
162                                  /* global program name */
163          gargv = argv;
# Line 270 | Line 268 | main(int argc, char *argv[])
268                  execv(rtpath, rtargv);
269                  perror(rtpath); /* execv() should not return */
270                  exit(1);
271 <        } else if (nprocs > 1) {        /* add persist file if parallel */
271 >        }
272 >        if (nprocs > 1) {       /* add persist file if parallel */
273                  rtargv[rtargc++] = "-PP";
274                  rtargv[rtargc++] = mktemp(persistfn);
275          }
# Line 284 | Line 283 | main(int argc, char *argv[])
283          rtargv[rtargc] = NULL;
284                                  /* start rtrace & compute contributions */
285          init(nprocs);
286 <        tracecontribs(stdin);
286 >        trace_contribs(stdin);
287          quit(0);
288   }
289  
# Line 336 | Line 335 | quit(int status)
335          exit(status);                   /* flushes all output streams */
336   }
337  
338 < /* start rtrace and initialize buffers */
338 > /* start rtrace processes and initialize */
339   void
340   init(int np)
341   {
# Line 562 | Line 561 | badspec:
561   int
562   getinp(char *buf, FILE *fp)
563   {
564 +        char    *cp;
565 +        int     i;
566 +
567          switch (inpfmt) {
568          case 'a':
569 <                if (fgets(buf, 128, fp) == NULL)
570 <                        return 0;
569 >                cp = buf;               /* make sure we get 6 floats */
570 >                for (i = 0; i < 6; i++) {
571 >                        if (fgetword(cp, buf+127-cp, fp) == NULL)
572 >                                return 0;
573 >                        if ((cp = fskip(cp)) == NULL || *cp)
574 >                                return 0;
575 >                        *cp++ = ' ';
576 >                }
577 >                getc(fp);               /* get/put eol */
578 >                *cp-- = '\0'; *cp = '\n';
579                  return strlen(buf);
580          case 'f':
581                  if (fread(buf, sizeof(float), 6, fp) < 6)
# Line 832 | Line 842 | get_rproc(void)
842  
843   /* trace ray contributions (main loop) */
844   void
845 < tracecontribs(FILE *fin)
845 > trace_contribs(FILE *fin)
846   {
847          char            inpbuf[128];
848          int             iblen;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines