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

Comparing ray/src/util/rsensor.c (file contents):
Revision 2.2 by greg, Thu Feb 21 20:18:25 2008 UTC vs.
Revision 2.5 by greg, Fri Apr 11 22:06:04 2008 UTC

# Line 22 | Line 22 | extern char    *progname;      /* global argv[0] */
22   extern int      nowarn;         /* don't report warnings? */
23  
24                                  /* current sensor's perspective */
25 < VIEW            ourview = STDVIEW;
25 > VIEW            ourview =  {VT_ANG,{0.,0.,0.},{0.,0.,1.},{1.,0.,0.},
26 >                                1.,180.,180.,0.,0.,0.,0.,
27 >                                {0.,0.,0.},{0.,0.,0.},0.,0.};
28  
29   unsigned long   nsamps = 10000; /* desired number of initial samples */
30   unsigned long   nssamps = 9000; /* number of super-samples */
# Line 45 | Line 47 | double         gscale = 1.;    /* global scaling value */
47   static void     comp_sensor(char *sfile);
48  
49   static void
50 < print_defaults()
50 > over_options()                  /* overriding options */
51   {
52 +        directvis = (ndsamps <= 0);
53 +        do_irrad = 0;
54 + }
55 +
56 + static void
57 + print_defaults()                /* print out default parameters */
58 + {
59 +        over_options();
60          printf("-n %-9d\t\t\t# number of processes\n", nprocs);
61          printf("-rd %-9ld\t\t\t# ray directions\n", nsamps);
62          /* printf("-rs %-9ld\t\t\t# ray super-samples\n", nssamps); */
# Line 68 | Line 78 | main(
78   )
79   {
80          int     doheader = 1;
81 +        int     optwarn = 0;
82          int     i, rval;
83  
84          progname = argv[0];
# Line 78 | Line 89 | main(
89          directrelay = 3;
90          ambounce = 1;
91          maxdepth = -10;
81                                /* just asking defaults? */
82        if (argc == 2 && !strcmp(argv[1], "-defaults")) {
83                print_defaults();
84                return(0);
85        }
86                                /* check octree */
87        if (argc < 2 || argv[argc-1][0] == '-')
88                error(USER, "missing octree argument");
92                                  /* get options from command line */
93 <        for (i = 1; i < argc-1; i++) {
93 >        for (i = 1; i < argc; i++) {
94                  while ((rval = expandarg(&argc, &argv, i)) > 0)
95                          ;
96                  if (rval < 0) {
97                          sprintf(errmsg, "cannot expand '%s'", argv[i]);
98                          error(SYSTEM, errmsg);
99                  }
100 <                if (argv[i][0] != '-') {        /* process a sensor file */
100 >                if (argv[i][0] != '-') {
101 >                        if (i >= argc-1)
102 >                                break;          /* final octree argument */
103                          if (!ray_pnprocs) {
104 <                                                /* overriding options */
100 <                                directvis = (ndsamps <= 0);
101 <                                do_irrad = 0;
104 >                                over_options();
105                                  if (doheader) { /* print header */
106                                          printargs(argc, argv, stdout);
107                                          fputformat("ascii", stdout);
# Line 107 | Line 110 | main(
110                                                  /* start process(es) */
111                                  ray_pinit(argv[argc-1], nprocs);
112                          }
113 <                        comp_sensor(argv[i]);
113 >                        comp_sensor(argv[i]);   /* process a sensor file */
114                          continue;
115                  }
116                  if (argv[i][1] == 'r') {        /* sampling options */
# Line 150 | Line 153 | main(
153                          sprintf(errmsg, "bad view option at '%s'", argv[i]);
154                          error(USER, errmsg);
155                  }
156 <                if (!strcmp(argv[i], "-w")) {   /* turn off warnings */
157 <                        nowarn = 1;
156 >                if (!strcmp(argv[i], "-w")) {   /* toggle warnings */
157 >                        nowarn = !nowarn;
158                          continue;
159                  }
160                  if (ray_pnprocs) {
161 <                        error(WARNING,
161 >                        if (!optwarn++)
162 >                                error(WARNING,
163                          "rendering options should appear before first sensor");
164                  } else if (!strcmp(argv[i], "-defaults")) {
165                          print_defaults();
# Line 178 | Line 182 | main(
182                  }
183                  i += rval;
184          }
185 +        if (!ray_pnprocs)
186 +                error(USER, i<argc ? "missing sensor file" : "missing octree");
187          quit(0);
188   }
189  
# Line 370 | Line 376 | init_ptable(
376                                              "code error 2 in init_ptable()");
377                                  frac1 = 1. + prob/((1.-frac)*rowp[p]/rowsum[t]
378                                                  + frac*rowp1[p]/rowsum[t+1]);
373                                if (p <= 0 || frac1 > 0.5)
374                                        frac1 -= 0.5;
375                                else if (p >= sntp[1]-1 || frac1 < 0.5) {
376                                        frac1 += 0.5;
377                                        --p;
378                                }
379                                  pvals[i*(nphi+1) + j] = (1.-frac1)*phdiv[p] +
380                                                          frac1*phdiv[p+1];
381                          }
# Line 475 | Line 475 | comp_sensor(
475          setcolor(vsum, .0f, .0f, .0f);
476          nt = (int)(sqrt((double)nsamps*ntheta/nphi) + .5);
477          np = nsamps/nt;
478        VCOPY(rr.rorg, ourview.vp);
479        rr.rmax = .0;
478          for (i = 0; i < nt; i++)
479                  for (j = 0; j < np; j++) {
480 +                        VCOPY(rr.rorg, ourview.vp);
481                          get_direc(rr.rdir, (i+frandom())/nt, (j+frandom())/np);
482 +                        if (ourview.vfore > FTINY)
483 +                                VSUM(rr.rorg, rr.rorg, rr.rdir, ourview.vfore);
484 +                        rr.rmax = .0;
485                          rayorigin(&rr, PRIMARY, NULL, NULL);
486                          if (ray_pqueue(&rr) == 1)
487                                  addcolor(vsum, rr.rcol);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines