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.58 by greg, Fri Feb 28 05:18:49 2020 UTC vs.
Revision 2.67 by greg, Tue Jun 3 21:31:51 2025 UTC

# Line 59 | Line 59 | main(
59   #define unguard()      
60   #endif
61  
62 extern char  *strerror();
63
62                                  /* rpict command */
63   char  *rpargv[128] = {"rpict", "-S", "1"};
64   int  rpargc = 3;
# Line 80 | Line 78 | int  nforked = 0;
78  
79   #define  sflock(t)      if ((t)!=synclst) dolock(fileno(syncfp),synclst=t)
80  
83 char  *progname;
81   int  verbose = 0;
82   int  nowarn = 0;
83   unsigned  timelim = 0;
# Line 107 | Line 104 | main(
104   {
105          int  i, rval;
106          
107 <        progname = argv[0];
107 >        fixargv0(argv[0]);                      /* assigns global progname */
108          for (i = 1; i < argc; i++) {
109                                                  /* expand arguments */
110                  while ((rval = expandarg(&argc, &argv, i)) > 0)
# Line 155 | Line 152 | main(
152                                          ++i;
153                                          continue;
154                                  }
155 +                                if (argv[i][2] == 'X') {
156 +                                        fprintf(stderr, "%s: -pXYZ unsupported\n",
157 +                                                argv[0]);
158 +                                        ++i;
159 +                                        continue;
160 +                                }
161 +                                if (argv[i][2] == 'c') {
162 +                                        fprintf(stderr, "%s: -pc unsupported\n",
163 +                                                argv[0]);
164 +                                        i += 9;
165 +                                        continue;
166 +                                }
167                                  if (argv[i][2] != 'a' || argv[i][3])
168                                          break;
169                                  pixaspect = atof(argv[++i]);
170                                  continue;
171 +                        case 'S':
172 +                                fprintf(stderr, "%s: -S unsupported\n", argv[0]);
173 +                                i++;
174 +                                continue;
175                          case 'T':               /* time limit (hours) */
176                                  if (argv[i][2])
177                                          break;
# Line 286 | Line 299 | init(                  /* set up output file and start rpict */
299          sprintf(vrbuf, "%d", vres);
300          rpargv[rpargc++] = "-y"; rpargv[rpargc++] = vrbuf;
301          rpargv[rpargc++] = "-pa"; rpargv[rpargc++] = "0";
302 +        rpargv[rpargc++] = "-pm"; rpargv[rpargc++] = "0";
303          rpargv[rpargc++] = av[ac-1];
304          rpargv[rpargc] = NULL;
305                                          /* open output file */
# Line 296 | Line 310 | init(                  /* set up output file and start rpict */
310                  newheader("RADIANCE", fp);      /* create header */
311                  printargs(ac, av, fp);
312                  fprintf(fp, "SOFTWARE= %s\n", VersionID);
313 +                fprintf(fp, "TILED= %d %d\n", hmult, vmult);
314                  fputs(VIEWSTR, fp);
315                  fprintview(&ourview, fp);
316 <                putc('\n', fp);
316 >                fputc('\n', fp);
317                  fputnow(fp);
318                  if (pixaspect < .99 || pixaspect > 1.01)
319                          fputaspect(pixaspect, fp);
320 +                fputprims(stdprims, fp);
321                  fputformat(COLRFMT, fp);
322 <                putc('\n', fp);
322 >                fputc('\n', fp);
323                  fprtresolu(hres*hmult, vres*vmult, fp);
324          } else if ((outfd = open(outfile, O_RDWR)) >= 0) {
325                  dolock(outfd, F_RDLCK);
# Line 461 | Line 477 | cleanup(                       /* close rpict process and clean up */
477   static void
478   rpiece(void)                    /* render picture piece by piece */
479   {
480 +        char  *err;
481          VIEW  pview;
482          int  xorg, yorg;
466                                        /* compute view parameters */
467        pview = ourview;
468        switch (ourview.type) {
469        case VT_PER:
470                pview.horiz = (2.*180./PI)*atan(
471                                tan((PI/180./2.)*ourview.horiz)/hmult );
472                pview.vert = (2.*180./PI)*atan(
473                                tan((PI/180./2.)*ourview.vert)/vmult );
474                break;
475        case VT_PAR:
476        case VT_ANG:
477                pview.horiz = ourview.horiz / hmult;
478                pview.vert = ourview.vert / vmult;
479                break;
480        case VT_CYL:
481                pview.horiz = ourview.horiz / hmult;
482                pview.vert = (2.*180./PI)*atan(
483                                tan((PI/180./2.)*ourview.vert)/vmult );
484                break;
485        case VT_HEM:
486                pview.horiz = (2.*180./PI)*asin(
487                                sin((PI/180./2.)*ourview.horiz)/hmult );
488                pview.vert = (2.*180./PI)*asin(
489                                sin((PI/180./2.)*ourview.vert)/vmult );
490                break;
491        case VT_PLS:
492                pview.horiz = sin((PI/180./2.)*ourview.horiz) /
493                                (1.0 + cos((PI/180./2.)*ourview.horiz)) / hmult;
494                pview.horiz *= pview.horiz;
495                pview.horiz = (2.*180./PI)*acos((1. - pview.horiz) /
496                                                (1. + pview.horiz));
497                pview.vert = sin((PI/180./2.)*ourview.vert) /
498                                (1.0 + cos((PI/180./2.)*ourview.vert)) / vmult;
499                pview.vert *= pview.vert;
500                pview.vert = (2.*180./PI)*acos((1. - pview.vert) /
501                                                (1. + pview.vert));
502                break;
503        default:
504                fprintf(stderr, "%s: unknown view type '-vt%c'\n",
505                                progname, ourview.type);
506                exit(cleanup(1));
507        }
483                                          /* render each piece */
484          while (nextpiece(&xorg, &yorg)) {
485 <                pview.hoff = ourview.hoff*hmult + xorg - 0.5*(hmult-1);
486 <                pview.voff = ourview.voff*vmult + yorg - 0.5*(vmult-1);
485 >                pview = ourview;
486 >                err = cropview(&pview, (double)xorg/hmult, (double)yorg/vmult,
487 >                                        (xorg+1.)/hmult, (yorg+1.)/vmult);
488 >                if (err != NULL) {
489 >                        fprintf(stderr, "%s: %s\n", progname, err);
490 >                        exit(cleanup(1));
491 >                }
492                  fputs(VIEWSTR, torp);
493                  fprintview(&pview, torp);
494 <                putc('\n', torp);
494 >                fputc('\n', torp);
495                  fflush(torp);                   /* assigns piece to rpict */
496                  putpiece(xorg, yorg);           /* place piece in output */
497          }
# Line 589 | Line 569 | int    ypos
569          if (lseek(outfd, (off_t)fls.l_start, SEEK_SET) < 0)
570                  filerr("seek");
571          if (hmult == 1) {
572 <                if (writebuf(outfd, (char *)pbuf,
572 >                if (writebuf(outfd, pbuf,
573                                  vr*hr*sizeof(COLR)) != vr*hr*sizeof(COLR))
574                          filerr("write");
575          } else
576                  for (y = 0; y < vr; y++) {
577 <                        if (writebuf(outfd, (char *)(pbuf+y*hr),
577 >                        if (writebuf(outfd, pbuf+y*hr,
578                                          hr*sizeof(COLR)) != hr*sizeof(COLR))
579                                  filerr("write");
580                          if (y < vr-1 && lseek(outfd,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines