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.64 by greg, Wed Jul 3 17:18:17 2024 UTC

# Line 155 | Line 155 | main(
155                                          ++i;
156                                          continue;
157                                  }
158 +                                if (argv[i][2] == 'X') {
159 +                                        fprintf(stderr, "%s: -pXYZ unsupported\n",
160 +                                                argv[0]);
161 +                                        ++i;
162 +                                        continue;
163 +                                }
164 +                                if (argv[i][2] == 'c') {
165 +                                        fprintf(stderr, "%s: -pc unsupported\n",
166 +                                                argv[0]);
167 +                                        i += 9;
168 +                                        continue;
169 +                                }
170                                  if (argv[i][2] != 'a' || argv[i][3])
171                                          break;
172                                  pixaspect = atof(argv[++i]);
173                                  continue;
174 +                        case 'S':
175 +                                fprintf(stderr, "%s: -S unsupported\n", argv[0]);
176 +                                i++;
177 +                                continue;
178                          case 'T':               /* time limit (hours) */
179                                  if (argv[i][2])
180                                          break;
# Line 286 | Line 302 | init(                  /* set up output file and start rpict */
302          sprintf(vrbuf, "%d", vres);
303          rpargv[rpargc++] = "-y"; rpargv[rpargc++] = vrbuf;
304          rpargv[rpargc++] = "-pa"; rpargv[rpargc++] = "0";
305 +        rpargv[rpargc++] = "-pm"; rpargv[rpargc++] = "0";
306          rpargv[rpargc++] = av[ac-1];
307          rpargv[rpargc] = NULL;
308                                          /* open output file */
# Line 298 | Line 315 | init(                  /* set up output file and start rpict */
315                  fprintf(fp, "SOFTWARE= %s\n", VersionID);
316                  fputs(VIEWSTR, fp);
317                  fprintview(&ourview, fp);
318 <                putc('\n', fp);
318 >                fputc('\n', fp);
319                  fputnow(fp);
320                  if (pixaspect < .99 || pixaspect > 1.01)
321                          fputaspect(pixaspect, fp);
322 +                fputprims(stdprims, fp);
323                  fputformat(COLRFMT, fp);
324 <                putc('\n', fp);
324 >                fputc('\n', fp);
325                  fprtresolu(hres*hmult, vres*vmult, fp);
326          } else if ((outfd = open(outfile, O_RDWR)) >= 0) {
327                  dolock(outfd, F_RDLCK);
# Line 461 | Line 479 | cleanup(                       /* close rpict process and clean up */
479   static void
480   rpiece(void)                    /* render picture piece by piece */
481   {
482 +        char  *err;
483          VIEW  pview;
484          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        }
485                                          /* render each piece */
486          while (nextpiece(&xorg, &yorg)) {
487 <                pview.hoff = ourview.hoff*hmult + xorg - 0.5*(hmult-1);
488 <                pview.voff = ourview.voff*vmult + yorg - 0.5*(vmult-1);
487 >                pview = ourview;
488 >                err = cropview(&pview, (double)xorg/hmult, (double)yorg/vmult,
489 >                                        (xorg+1.)/hmult, (yorg+1.)/vmult);
490 >                if (err != NULL) {
491 >                        fprintf(stderr, "%s: %s\n", progname, err);
492 >                        exit(cleanup(1));
493 >                }
494                  fputs(VIEWSTR, torp);
495                  fprintview(&pview, torp);
496 <                putc('\n', torp);
496 >                fputc('\n', torp);
497                  fflush(torp);                   /* assigns piece to rpict */
498                  putpiece(xorg, yorg);           /* place piece in output */
499          }
# Line 589 | Line 571 | int    ypos
571          if (lseek(outfd, (off_t)fls.l_start, SEEK_SET) < 0)
572                  filerr("seek");
573          if (hmult == 1) {
574 <                if (writebuf(outfd, (char *)pbuf,
574 >                if (writebuf(outfd, pbuf,
575                                  vr*hr*sizeof(COLR)) != vr*hr*sizeof(COLR))
576                          filerr("write");
577          } else
578                  for (y = 0; y < vr; y++) {
579 <                        if (writebuf(outfd, (char *)(pbuf+y*hr),
579 >                        if (writebuf(outfd, pbuf+y*hr,
580                                          hr*sizeof(COLR)) != hr*sizeof(COLR))
581                                  filerr("write");
582                          if (y < vr-1 && lseek(outfd,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines