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

Comparing ray/src/util/rpiece.c (file contents):
Revision 2.47 by greg, Wed Aug 22 18:46:36 2007 UTC vs.
Revision 2.53 by greg, Sat Jan 21 22:04:02 2012 UTC

# Line 9 | Line 9 | static const char      RCSid[] = "$Id$";
9   #include <stdio.h>
10   #include <signal.h>
11   #include <sys/types.h>
12 +
13 + #include "platform.h"
14   #ifndef NON_POSIX /* XXX need abstraction for process management */
15   #include <sys/wait.h>
16   #endif
17  
16 #include "platform.h"
18   #include "standard.h"
19   #include "color.h"
20   #include "view.h"
# Line 77 | Line 78 | int  nforked = 0;
78  
79   char  *progname;
80   int  verbose = 0;
81 + int  nowarn = 0;
82   unsigned  timelim = 0;
83   int  rvrlim = -1;
84  
# Line 107 | Line 109 | main(
109                  while ((rval = expandarg(&argc, &argv, i)) > 0)
110                          ;
111                  if (rval < 0) {
112 <                        fprintf(stderr, "%s: cannot expand '%s'",
112 >                        fprintf(stderr, "%s: cannot expand '%s'\n",
113                                          argv[0], argv[i]);
114                          exit(1);
115                  }
116                  if (argv[i][0] == '-')
117                          switch (argv[i][1]) {
118 +                        case 'w':
119 +                                if (!argv[i][2])
120 +                                        nowarn = !nowarn;
121 +                                else if (argv[i][2] == '+')
122 +                                        nowarn = 0;
123 +                                else if (argv[i][2] == '-')
124 +                                        nowarn = 1;
125 +                                break;
126                          case 'v':
127                                  switch (argv[i][2]) {
128                                  case '\0':      /* verbose option */
# Line 135 | Line 145 | main(
145                                  }
146                                  break;
147                          case 'p':               /* pixel aspect ratio? */
148 +                                if (argv[i][2] == 'm') {
149 +                                        fprintf(stderr, "%s: -pm unsupported\n",
150 +                                                argv[0]);
151 +                                        ++i;
152 +                                        continue;
153 +                                }
154                                  if (argv[i][2] != 'a' || argv[i][3])
155                                          break;
156                                  pixaspect = atof(argv[++i]);
# Line 143 | Line 159 | main(
159                                  if (argv[i][2])
160                                          break;
161                                  timelim = atof(argv[++i])*3600. + .5;
162 <                                break;
162 >                                continue;
163                          case 'x':               /* overall x resolution */
164                                  if (argv[i][2])
165                                          break;
# Line 188 | Line 204 | main(
204                                          break;
205                                  outfile = argv[++i];
206                                  continue;
207 <                        } else if (i >= argc-1)
208 <                                break;
207 >                        }
208 >                else if (i >= argc-1)
209 >                        break;
210                  rpargv[rpargc++] = argv[i];
211          }
212          if (i >= argc) {
# Line 246 | Line 263 | init(                  /* set up output file and start rpict */
263                  sflock(F_UNLCK);
264          }
265                                          /* compute piece size */
266 +        hr = hres; vr = vres;
267 +        if (pixaspect > FTINY)
268 +                normaspect(viewaspect(&ourview), &pixaspect, &hr, &vr);
269          hres /= hmult;
270          vres /= vmult;
271          if (hres <= 0 || vres <= 0) {
# Line 253 | Line 273 | init(                  /* set up output file and start rpict */
273                  exit(1);
274          }
275          normaspect(viewaspect(&ourview)*hmult/vmult, &pixaspect, &hres, &vres);
276 +        if (!nowarn && (hr != hres*hmult) | (vr != vres*vmult))
277 +                fprintf(stderr,
278 +                "%s: warning - resolution changed from %dx%d to %dx%d\n",
279 +                                progname, hr, vr, hres*hmult, vres*vmult);
280          sprintf(hrbuf, "%d", hres);
281          rpargv[rpargc++] = "-x"; rpargv[rpargc++] = hrbuf;
282          sprintf(vrbuf, "%d", vres);
# Line 271 | Line 295 | init(                  /* set up output file and start rpict */
295                  fputs(VIEWSTR, fp);
296                  fprintview(&ourview, fp);
297                  putc('\n', fp);
298 +                fputnow(fp);
299                  if (pixaspect < .99 || pixaspect > 1.01)
300                          fputaspect(pixaspect, fp);
301                  fputformat(COLRFMT, fp);
# Line 437 | Line 462 | rpiece(void)                   /* render picture piece by piece */
462          pview = ourview;
463          switch (ourview.type) {
464          case VT_PER:
465 <                pview.horiz = 2.*180./PI*atan(
466 <                                tan(PI/180./2.*ourview.horiz)/hmult );
467 <                pview.vert = 2.*180./PI*atan(
468 <                                tan(PI/180./2.*ourview.vert)/vmult );
465 >                pview.horiz = (2.*180./PI)*atan(
466 >                                tan((PI/180./2.)*ourview.horiz)/hmult );
467 >                pview.vert = (2.*180./PI)*atan(
468 >                                tan((PI/180./2.)*ourview.vert)/vmult );
469                  break;
470          case VT_PAR:
471          case VT_ANG:
# Line 449 | Line 474 | rpiece(void)                   /* render picture piece by piece */
474                  break;
475          case VT_CYL:
476                  pview.horiz = ourview.horiz / hmult;
477 <                pview.vert = 2.*180./PI*atan(
478 <                                tan(PI/180./2.*ourview.vert)/vmult );
477 >                pview.vert = (2.*180./PI)*atan(
478 >                                tan((PI/180./2.)*ourview.vert)/vmult );
479                  break;
480          case VT_HEM:
481 <                pview.horiz = 2.*180./PI*asin(
482 <                                sin(PI/180./2.*ourview.horiz)/hmult );
483 <                pview.vert = 2.*180./PI*asin(
484 <                                sin(PI/180./2.*ourview.vert)/vmult );
481 >                pview.horiz = (2.*180./PI)*asin(
482 >                                sin((PI/180./2.)*ourview.horiz)/hmult );
483 >                pview.vert = (2.*180./PI)*asin(
484 >                                sin((PI/180./2.)*ourview.vert)/vmult );
485 >                break;
486 >        case VT_PLS:
487 >                pview.horiz = sin((PI/180./2.)*ourview.horiz) /
488 >                                (1.0 + cos((PI/180./2.)*ourview.horiz)) / hmult;
489 >                pview.horiz *= pview.horiz;
490 >                pview.horiz = (2.*180./PI)*acos((1. - pview.horiz) /
491 >                                                (1. + pview.horiz));
492 >                pview.vert = sin((PI/180./2.)*ourview.vert) /
493 >                                (1.0 + cos((PI/180./2.)*ourview.vert)) / vmult;
494 >                pview.vert *= pview.vert;
495 >                pview.vert = (2.*180./PI)*acos((1. - pview.vert) /
496 >                                                (1. + pview.vert));
497                  break;
498          default:
499                  fprintf(stderr, "%s: unknown view type '-vt%c'\n",

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines