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.7 by greg, Tue May 31 03:48:59 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>
10 < #include  "rtio.h"
10 < #include  "rterror.h"
10 > #include  <signal.h>
11   #include  "platform.h"
12   #include  "rtprocess.h"
13   #include  "selcall.h"
# Line 64 | Line 64 | struct rtproc {
64          int             bsiz;           /* ray tree buffer length */
65          char            *buf;           /* ray tree buffer */
66          int             nbr;            /* number of bytes from rtrace */
67 < };                              /* rtrace process */
67 > };                              /* rtrace process buffer */
68  
69                                          /* rtrace command and defaults */
70 < char            *rtargv[256] = { "rtrace", "-dt", "0", "-dj", ".5", "-dr", "3",
70 > char            *rtargv[256] = { "rtrace", "-dj", ".5", "-dr", "3",
71                                  "-ab", "1", "-ad", "128", };
72 < int  rtargc = 11;
72 > int  rtargc = 9;
73                                          /* overriding rtrace options */
74 < char            *myrtopts[] = { "-o~~TmWdp", "-h-",
75 <                                "-x", "1", "-y", "0",
76 <                                "-as", "0", "-aa", "0", NULL };
74 > char            *myrtopts[] = { "-o~~TmWdp", "-h-", "-x", "1", "-y", "0",
75 >                                "-dt", "0", "-as", "0", "-aa", "0", NULL };
76  
77   struct rtproc   rt0;                    /* head of rtrace process list */
78  
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 */
# Line 108 | Line 106 | int            nmods = 0;              /* number of modifiers */
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);
# Line 160 | Line 158 | main(int argc, char *argv[])
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;
# Line 270 | Line 269 | main(int argc, char *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          }
# Line 284 | Line 284 | main(int argc, char *argv[])
284          rtargv[rtargc] = NULL;
285                                  /* start rtrace & compute contributions */
286          init(nprocs);
287 <        tracecontribs(stdin);
287 >        trace_contribs(stdin);
288          quit(0);
289   }
290  
# Line 336 | Line 336 | quit(int status)
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   {
# Line 562 | Line 562 | badspec:
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)
# Line 832 | Line 843 | get_rproc(void)
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;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines