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

Comparing ray/src/hd/rhcopy.c (file contents):
Revision 3.22 by schorsch, Thu Jan 1 11:21:55 2004 UTC vs.
Revision 3.32 by greg, Mon Oct 21 18:19:32 2019 UTC

# Line 31 | Line 31 | struct phead {
31   };
32   static int openholo(char *fname, int append);
33   static void addray(FVECT ro, FVECT rd, double d, COLR cv);
34 < static int holheadline(char *s, int *hf);
34 > static gethfunc holheadline;
35   static int bpcmp(const void *b1p, const void *b2p);
36   static int addclump(HOLO *hp, int *bq, int nb);
37   static void addholo(char *hdf);
38 < static int picheadline(char *s, struct phead *ph);
38 > static gethfunc picheadline;
39   static void addpicz(char *pcf, char *zbf);
40  
41  
# Line 85 | Line 85 | main(
85   userr:
86          fprintf(stderr, "Usage: %s output.hdk [-u][-d] -h inp1.hdk ..\n",
87                          progname);
88 <        fprintf(stderr, "   Or: %s output.hdk [-u][-d] -p inp1.pic inp1.zbf ..\n",
88 >        fprintf(stderr, "   Or: %s output.hdk [-u][-d] -p inp1.hdr inp1.zbf ..\n",
89                          progname);
90          exit(1);
91   }
# Line 95 | Line 95 | userr:
95   #define H_OBST  02
96   #define H_OBSF  04
97  
98 < int
98 > static int
99   holheadline(            /* check holodeck header line */
100 <        register char   *s,
101 <        int     *hf
100 >        char    *s,
101 >        void    *vhf
102   )
103   {
104 <        char    fmt[32];
104 >        char    fmt[MAXFMTLEN];
105 >        int     *hf = vhf;
106  
107          if (formatval(fmt, s)) {
108                  if (strcmp(fmt, HOLOFMT))
# Line 133 | Line 134 | openholo(              /* open existing holodeck file for i/o */
134          FILE    *fp;
135          int     fd;
136          int     hflags = 0;
137 <        long    nextloc;
137 >        off_t   nextloc;
138          int     n;
139                                          /* open holodeck file */
140 <        if ((fp = fopen(fname, append ? "r+" : "r")) == NULL) {
140 >        if ((fp = fopen(fname, append ? "rb+" : "rb")) == NULL) {
141                  sprintf(errmsg, "cannot open \"%s\" for %s", fname,
142                                  append ? "appending" : "reading");
143                  error(SYSTEM, errmsg);
144          }
145                                          /* check header and magic number */
146 <        if (getheader(fp, holheadline, (char *)&hflags) < 0 ||
146 >        if (getheader(fp, holheadline, &hflags) < 0 ||
147                          hflags&H_BADF || getw(fp) != HOLOMAGIC) {
148                  sprintf(errmsg, "file \"%s\" not in holodeck format", fname);
149                  error(USER, errmsg);
# Line 151 | Line 152 | openholo(              /* open existing holodeck file for i/o */
152          nextloc = ftell(fp);                    /* get stdio position */
153          fclose(fp);                             /* done with stdio */
154          for (n = 0; nextloc > 0L; n++) {        /* initialize each section */
155 <                lseek(fd, (off_t)nextloc, SEEK_SET);
155 >                lseek(fd, nextloc, SEEK_SET);
156                  read(fd, (char *)&nextloc, sizeof(nextloc));
157                  hdinit(fd, NULL)->priv = hflags&H_OBST ? &obstr :
158                                  hflags&H_OBSF ? &unobstr : (char *)NULL;
# Line 173 | Line 174 | addray(                /* add a ray to our output holodeck */
174   )
175   {
176          int     sn, bi, n;
177 <        register HOLO   *hp;
177 >        HOLO    *hp;
178          GCOORD  gc[2];
179 <        BYTE    rr[2][2];
179 >        uby8    rr[2][2];
180          BEAM    *bp;
181          double  d0, d1;
182          unsigned        dc;
183 <        register RAYVAL *rv;
183 >        RAYVAL  *rv;
184                                  /* check each output section */
185          for (sn = noutsects; sn--; ) {
186                  hp = hdlist[sn];
# Line 222 | Line 223 | bpcmp(                 /* compare beam positions on disk */
223          const void      *b2p
224   )
225   {
226 <        register off_t  pdif = beamdir[*(int*)b1p].fo - beamdir[*(int*)b2p].fo;
226 >        off_t   pdif = beamdir[*(int*)b1p].fo - beamdir[*(int*)b2p].fo;
227  
228          if (pdif > 0L) return(1);
229          if (pdif < 0L) return(-1);
# Line 240 | Line 241 | addclump(              /* transfer the given clump and free */
241          FVECT   ro, rd;
242          double  d;
243          int     i;
244 <        register int    k;
245 <        register BEAM   *bp;
244 >        int     k;
245 >        BEAM    *bp;
246                                          /* sort based on file position */
247          beamdir = hp->bi;
248          qsort((char *)bq, nb, sizeof(*bq), bpcmp);
# Line 285 | Line 286 | addholo(                       /* add a holodeck file */
286  
287  
288  
289 < int
289 > static int
290   picheadline(            /* process picture header line */
291          char    *s,
292 <        struct phead    *ph
292 >        void    *vph
293   )
294   {
295          char    fmt[32];
296 +        struct phead *ph = vph;
297  
298          if (formatval(fmt, s)) {
299                  ph->badfmt = strcmp(fmt, COLRFMT);
# Line 332 | Line 334 | addpicz(               /* add a picture + depth-buffer */
334          double  aftd;
335          COLOR   ctmp;
336          int     j;
337 <        register int    i;
337 >        int     i;
338                                  /* open files */
339 <        if ((pfp = fopen(pcf, "r")) == NULL) {
339 >        if ((pfp = fopen(pcf, "rb")) == NULL) {
340                  sprintf(errmsg, "cannot open picture file \"%s\"", pcf);
341                  error(SYSTEM, pcf);
342          }
# Line 342 | Line 344 | addpicz(               /* add a picture + depth-buffer */
344                  sprintf(errmsg, "cannot open depth file \"%s\"", zbf);
345                  error(SYSTEM, pcf);
346          }
347 +        SET_FD_BINARY(zfd);
348                                  /* load picture header */
349          phd.vw = stdview;
350          phd.expos = 1.0;
351          phd.badfmt = phd.gotview = phd.altprims = 0;
352 <        if (getheader(pfp, picheadline, (char *)&phd) < 0 ||
352 >        if (getheader(pfp, picheadline, &phd) < 0 ||
353                          phd.badfmt || !fgetsresolu(&prs, pfp)) {
354                  sprintf(errmsg, "bad format for picture file \"%s\"", pcf);
355                  error(USER, errmsg);
# Line 357 | Line 360 | addpicz(               /* add a picture + depth-buffer */
360                  error(USER, errmsg);
361          }
362          if (phd.altprims) {
363 <                sprintf(errmsg, "ignoring primary values in picture \"%s\"",
363 >                sprintf(errmsg, "ignoring color primaries in picture \"%s\"",
364                                  pcf);
365                  error(WARNING, errmsg);
366          }
# Line 390 | Line 393 | addpicz(               /* add a picture + depth-buffer */
393                  }
394                  if (eshft)                              /* shift exposure */
395                          shiftcolrs(cscn, i, eshft);
396 <                i *= sizeof(float);                     /* read depth */
397 <                if (read(zfd, (char *)zscn, i) != i) {
396 >                                                        /* read depth */
397 >                if (read(zfd, zscn, i*sizeof(float)) != i*sizeof(float)) {
398                          sprintf(errmsg, "error reading depth file \"%s\"", zbf);
399                          error(USER, errmsg);
400                  }
401 <                for (i = scanlen(&prs); i--; ) {        /* do each pixel */
401 >                while (i--) {                           /* process each pixel */
402 >                        if (zscn[i] <= 0.0)
403 >                                continue;               /* illegal depth */
404                          pix2loc(vl, &prs, i, j);
405                          aftd = viewray(ro, rd, &phd.vw, vl[0], vl[1]);
406                          if (aftd < -FTINY)
# Line 423 | Line 428 | addpicz(               /* add a picture + depth-buffer */
428  
429   void
430   eputs(                  /* put error message to stderr */
431 <        register char  *s
431 >        char  *s
432   )
433   {
434          static int  midline = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines