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.35 by greg, Tue Oct 11 16:54:26 2005 UTC vs.
Revision 1.39 by greg, Fri Oct 21 01:12:59 2005 UTC

# Line 325 | Line 325 | main(int argc, char *argv[])
325                                  rtargv[rtargc++] = argv[++i];
326                                  addmodfile(argv[i], curout, binval, bincnt);
327                                  continue;
328 +                        case 'P':               /* persist file */
329 +                                error(USER, "persist file is automatic");
330 +                                break;
331                          }
332                  rtargv[rtargc++] = argv[i];     /* assume rtrace option */
333          }
# Line 760 | Line 763 | getostream(const char *ospec, const char *mname, int b
763   int
764   getinp(char *buf, FILE *fp)
765   {
766 +        double  dv[3];
767 +        float   fv[3];
768          char    *cp;
769          int     i;
770  
# Line 768 | Line 773 | getinp(char *buf, FILE *fp)
773                  cp = buf;               /* make sure we get 6 floats */
774                  for (i = 0; i < 6; i++) {
775                          if (fgetword(cp, buf+127-cp, fp) == NULL)
776 <                                return 0;
776 >                                return -1;
777 >                        if (i >= 3)
778 >                                dv[i-3] = atof(cp);
779                          if ((cp = fskip(cp)) == NULL || *cp)
780 <                                return 0;
780 >                                return -1;
781                          *cp++ = ' ';
782                  }
783                  getc(fp);               /* get/put eol */
784                  *cp-- = '\0'; *cp = '\n';
785 +                if (DOT(dv,dv) <= FTINY*FTINY)
786 +                        return 0;       /* dummy ray */
787                  return strlen(buf);
788          case 'f':
789                  if (fread(buf, sizeof(float), 6, fp) < 6)
790 <                        return 0;
790 >                        return -1;
791 >                memcpy(fv, buf+3*sizeof(float), 3*sizeof(float));
792 >                if (DOT(fv,fv) <= FTINY*FTINY)
793 >                        return 0;       /* dummy ray */
794                  return sizeof(float)*6;
795          case 'd':
796                  if (fread(buf, sizeof(double), 6, fp) < 6)
797 <                        return 0;
797 >                        return -1;
798 >                memcpy(dv, buf+3*sizeof(double), 3*sizeof(double));
799 >                if (DOT(dv,dv) <= FTINY*FTINY)
800 >                        return 0;       /* dummy ray */
801                  return sizeof(double)*6;
802          }
803          error(INTERNAL, "botched input format");
804 <        return 0;       /* pro forma return */
804 >        return -1;      /* pro forma return */
805   }
806  
807   static float    rparams[9];             /* traced ray parameters */
# Line 960 | Line 975 | process_queue(void)
975                  }
976                  done_contrib();         /* sum up contributions & output */
977                  lastdone = rtp->raynum;
978 <                free(rtp->buf);         /* free up buffer space */
978 >                if (rtp->buf != NULL)   /* free up buffer space */
979 >                        free(rtp->buf);
980                  rt_unproc = rtp->next;
981                  free(rtp);              /* done with this ray tree */
982          }
# Line 1048 | Line 1064 | trace_contribs(FILE *fin)
1064          int             iblen;
1065          struct rtproc   *rtp;
1066                                                  /* loop over input */
1067 <        while ((iblen = getinp(inpbuf, fin)) > 0) {
1068 <                if (lastray+1 < lastray ||      /* need reset? */
1069 <                                queue_length() > 10*nrtprocs()) {
1067 >        while ((iblen = getinp(inpbuf, fin)) >= 0) {
1068 >                if (!iblen ||                   /* need reset? */
1069 >                                queue_length() > 10*nrtprocs() ||
1070 >                                lastray+1 < lastray) {
1071                          while (wait_rproc() != NULL)
1072                                  process_queue();
1073                          if (lastray+1 < lastray)
1074                                  lastdone = lastray = 0;
1075                  }
1076                  rtp = get_rproc();              /* get avail. rtrace process */
1077 <                rtp->raynum = ++lastray;        /* assign ray to it */
1078 <                writebuf(rtp->pd.w, inpbuf, iblen);
1079 <                if (raysleft && !--raysleft)
1080 <                        break;
1077 >                rtp->raynum = ++lastray;        /* assign ray */
1078 >                if (iblen) {                    /* trace ray if valid */
1079 >                        writebuf(rtp->pd.w, inpbuf, iblen);
1080 >                } else {                        /* else bypass dummy ray */
1081 >                        queue_raytree(rtp);     /* empty tree */
1082 >                        if ((yres <= 0) | (waitflush > 1))
1083 >                                waitflush = 1;  /* flush after this */
1084 >                }
1085                  process_queue();                /* catch up with results */
1086 +                if (raysleft && !--raysleft)
1087 +                        break;                  /* preemptive EOI */
1088          }
1089          while (wait_rproc() != NULL)            /* process outstanding rays */
1090                  process_queue();
# Line 1219 | Line 1242 | recover_output(FILE *fin)
1242          lu_doall(&ofiletab, myseeko, &nvals);
1243                                                  /* skip repeated input */
1244          for (nvals = 0; nvals < lastout; nvals++)
1245 <                if (getinp(oname, fin) <= 0)
1245 >                if (getinp(oname, fin) < 0)
1246                          error(USER, "unexpected EOF on input");
1247          lastray = lastdone = (unsigned long)lastout;
1248          if (raysleft)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines