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.9 by greg, Wed Jun 1 16:11:01 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",
71 <                                "-ab", "1", "-ad", "128", };
70 > char            *rtargv[256] = { "rtrace", "-dj", ".5", "-dr", "3",
71 >                                "-ab", "1", "-ad", "128", "-lr", "-10", };
72   int  rtargc = 11;
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 203 | Line 202 | main(int argc, char *argv[])
202                                  break;
203                          case 'f':               /* file or i/o format */
204                                  if (!argv[i][2]) {
205 +                                        char    *fpath;
206                                          if (i >= argc-1) break;
207 <                                        fcompile(argv[++i]);
207 >                                        fpath = getpath(argv[++i],
208 >                                                        getrlibpath(), R_OK);
209 >                                        if (fpath == NULL) {
210 >                                                sprintf(errmsg,
211 >                                                        "cannot find file '%s'",
212 >                                                                argv[i]);
213 >                                                error(USER, errmsg);
214 >                                        }
215 >                                        fcompile(fpath);
216                                          continue;
217                                  }
218                                  setformat(argv[i]+2);
# Line 270 | Line 278 | main(int argc, char *argv[])
278                  execv(rtpath, rtargv);
279                  perror(rtpath); /* execv() should not return */
280                  exit(1);
281 <        } else if (nprocs > 1) {        /* add persist file if parallel */
281 >        }
282 >        if (nprocs > 1) {       /* add persist file if parallel */
283                  rtargv[rtargc++] = "-PP";
284                  rtargv[rtargc++] = mktemp(persistfn);
285          }
# Line 284 | Line 293 | main(int argc, char *argv[])
293          rtargv[rtargc] = NULL;
294                                  /* start rtrace & compute contributions */
295          init(nprocs);
296 <        tracecontribs(stdin);
296 >        trace_contribs(stdin);
297          quit(0);
298   }
299  
# Line 336 | Line 345 | quit(int status)
345          exit(status);                   /* flushes all output streams */
346   }
347  
348 < /* start rtrace and initialize buffers */
348 > /* start rtrace processes and initialize */
349   void
350   init(int np)
351   {
# Line 562 | Line 571 | badspec:
571   int
572   getinp(char *buf, FILE *fp)
573   {
574 +        char    *cp;
575 +        int     i;
576 +
577          switch (inpfmt) {
578          case 'a':
579 <                if (fgets(buf, 128, fp) == NULL)
580 <                        return 0;
579 >                cp = buf;               /* make sure we get 6 floats */
580 >                for (i = 0; i < 6; i++) {
581 >                        if (fgetword(cp, buf+127-cp, fp) == NULL)
582 >                                return 0;
583 >                        if ((cp = fskip(cp)) == NULL || *cp)
584 >                                return 0;
585 >                        *cp++ = ' ';
586 >                }
587 >                getc(fp);               /* get/put eol */
588 >                *cp-- = '\0'; *cp = '\n';
589                  return strlen(buf);
590          case 'f':
591                  if (fread(buf, sizeof(float), 6, fp) < 6)
# Line 832 | Line 852 | get_rproc(void)
852  
853   /* trace ray contributions (main loop) */
854   void
855 < tracecontribs(FILE *fin)
855 > trace_contribs(FILE *fin)
856   {
857          char            inpbuf[128];
858          int             iblen;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines