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.57 by greg, Tue Aug 21 17:46:09 2018 UTC vs.
Revision 2.66 by greg, Thu Sep 12 23:14:32 2024 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 155 | Line 153 | main(
153                                          ++i;
154                                          continue;
155                                  }
156 +                                if (argv[i][2] == 'X') {
157 +                                        fprintf(stderr, "%s: -pXYZ unsupported\n",
158 +                                                argv[0]);
159 +                                        ++i;
160 +                                        continue;
161 +                                }
162 +                                if (argv[i][2] == 'c') {
163 +                                        fprintf(stderr, "%s: -pc unsupported\n",
164 +                                                argv[0]);
165 +                                        i += 9;
166 +                                        continue;
167 +                                }
168                                  if (argv[i][2] != 'a' || argv[i][3])
169                                          break;
170                                  pixaspect = atof(argv[++i]);
171                                  continue;
172 +                        case 'S':
173 +                                fprintf(stderr, "%s: -S unsupported\n", argv[0]);
174 +                                i++;
175 +                                continue;
176                          case 'T':               /* time limit (hours) */
177                                  if (argv[i][2])
178                                          break;
# Line 286 | Line 300 | init(                  /* set up output file and start rpict */
300          sprintf(vrbuf, "%d", vres);
301          rpargv[rpargc++] = "-y"; rpargv[rpargc++] = vrbuf;
302          rpargv[rpargc++] = "-pa"; rpargv[rpargc++] = "0";
303 +        rpargv[rpargc++] = "-pm"; rpargv[rpargc++] = "0";
304          rpargv[rpargc++] = av[ac-1];
305          rpargv[rpargc] = NULL;
306                                          /* open output file */
# Line 296 | Line 311 | init(                  /* set up output file and start rpict */
311                  newheader("RADIANCE", fp);      /* create header */
312                  printargs(ac, av, fp);
313                  fprintf(fp, "SOFTWARE= %s\n", VersionID);
314 +                fprintf(fp, "TILED= %d %d\n", hmult, vmult);
315                  fputs(VIEWSTR, fp);
316                  fprintview(&ourview, fp);
317 <                putc('\n', fp);
317 >                fputc('\n', fp);
318                  fputnow(fp);
319                  if (pixaspect < .99 || pixaspect > 1.01)
320                          fputaspect(pixaspect, fp);
321 +                fputprims(stdprims, fp);
322                  fputformat(COLRFMT, fp);
323 <                putc('\n', fp);
323 >                fputc('\n', fp);
324                  fprtresolu(hres*hmult, vres*vmult, fp);
325          } else if ((outfd = open(outfile, O_RDWR)) >= 0) {
326                  dolock(outfd, F_RDLCK);
# Line 326 | Line 343 | init(                  /* set up output file and start rpict */
343                  goto filerr;
344          dolock(outfd, F_UNLCK);
345                                          /* start rpict process */
346 +        rpd = sp_inactive;
347          if (open_process(&rpd, rpargv) <= 0) {
348                  fprintf(stderr, "%s: cannot start %s\n", progname, rpargv[0]);
349                  exit(1);
# Line 460 | Line 478 | cleanup(                       /* close rpict process and clean up */
478   static void
479   rpiece(void)                    /* render picture piece by piece */
480   {
481 +        char  *err;
482          VIEW  pview;
483          int  xorg, yorg;
465                                        /* compute view parameters */
466        pview = ourview;
467        switch (ourview.type) {
468        case VT_PER:
469                pview.horiz = (2.*180./PI)*atan(
470                                tan((PI/180./2.)*ourview.horiz)/hmult );
471                pview.vert = (2.*180./PI)*atan(
472                                tan((PI/180./2.)*ourview.vert)/vmult );
473                break;
474        case VT_PAR:
475        case VT_ANG:
476                pview.horiz = ourview.horiz / hmult;
477                pview.vert = ourview.vert / vmult;
478                break;
479        case VT_CYL:
480                pview.horiz = ourview.horiz / hmult;
481                pview.vert = (2.*180./PI)*atan(
482                                tan((PI/180./2.)*ourview.vert)/vmult );
483                break;
484        case VT_HEM:
485                pview.horiz = (2.*180./PI)*asin(
486                                sin((PI/180./2.)*ourview.horiz)/hmult );
487                pview.vert = (2.*180./PI)*asin(
488                                sin((PI/180./2.)*ourview.vert)/vmult );
489                break;
490        case VT_PLS:
491                pview.horiz = sin((PI/180./2.)*ourview.horiz) /
492                                (1.0 + cos((PI/180./2.)*ourview.horiz)) / hmult;
493                pview.horiz *= pview.horiz;
494                pview.horiz = (2.*180./PI)*acos((1. - pview.horiz) /
495                                                (1. + pview.horiz));
496                pview.vert = sin((PI/180./2.)*ourview.vert) /
497                                (1.0 + cos((PI/180./2.)*ourview.vert)) / vmult;
498                pview.vert *= pview.vert;
499                pview.vert = (2.*180./PI)*acos((1. - pview.vert) /
500                                                (1. + pview.vert));
501                break;
502        default:
503                fprintf(stderr, "%s: unknown view type '-vt%c'\n",
504                                progname, ourview.type);
505                exit(cleanup(1));
506        }
484                                          /* render each piece */
485          while (nextpiece(&xorg, &yorg)) {
486 <                pview.hoff = ourview.hoff*hmult + xorg - 0.5*(hmult-1);
487 <                pview.voff = ourview.voff*vmult + yorg - 0.5*(vmult-1);
486 >                pview = ourview;
487 >                err = cropview(&pview, (double)xorg/hmult, (double)yorg/vmult,
488 >                                        (xorg+1.)/hmult, (yorg+1.)/vmult);
489 >                if (err != NULL) {
490 >                        fprintf(stderr, "%s: %s\n", progname, err);
491 >                        exit(cleanup(1));
492 >                }
493                  fputs(VIEWSTR, torp);
494                  fprintview(&pview, torp);
495 <                putc('\n', torp);
495 >                fputc('\n', torp);
496                  fflush(torp);                   /* assigns piece to rpict */
497                  putpiece(xorg, yorg);           /* place piece in output */
498          }
# Line 588 | Line 570 | int    ypos
570          if (lseek(outfd, (off_t)fls.l_start, SEEK_SET) < 0)
571                  filerr("seek");
572          if (hmult == 1) {
573 <                if (writebuf(outfd, (char *)pbuf,
573 >                if (writebuf(outfd, pbuf,
574                                  vr*hr*sizeof(COLR)) != vr*hr*sizeof(COLR))
575                          filerr("write");
576          } else
577                  for (y = 0; y < vr; y++) {
578 <                        if (writebuf(outfd, (char *)(pbuf+y*hr),
578 >                        if (writebuf(outfd, pbuf+y*hr,
579                                          hr*sizeof(COLR)) != hr*sizeof(COLR))
580                                  filerr("write");
581                          if (y < vr-1 && lseek(outfd,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines