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.10 by gwlarson, Mon Nov 9 17:11:40 1998 UTC vs.
Revision 3.13 by gwlarson, Mon Feb 1 10:22:46 1999 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1998 Silicon Graphics, Inc. */
1 > /* Copyright (c) 1999 Silicon Graphics, Inc. */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ SGI";
# Line 175 | Line 175 | COLR   cv;
175                  bi = hdbindex(hp, gc);          /* check for duplicates */
176                  if (checkrepeats && (bp = hdgetbeam(hp, bi)) != NULL) {
177                          for (n = bp->nrm, rv = hdbray(bp); n--; rv++)
178 <                                if (rv->d == dc &&
178 >                                if ((hp->priv != NULL || rv->d == dc) &&
179                                                  rv->r[0][0] == rr[0][0] &&
180                                                  rv->r[0][1] == rr[0][1] &&
181                                                  rv->r[1][0] == rr[1][0] &&
# Line 193 | Line 193 | COLR   cv;
193   }
194  
195  
196 < addbeam(bp, hb)                 /* add a beam to our output holodeck */
197 < register BEAM   *bp;
198 < register HDBEAMI        *hb;
196 > static BEAMI    *beamdir;
197 >
198 > static int
199 > bpcmp(b1p, b2p)                 /* compare beam positions on disk */
200 > int     *b1p, *b2p;
201   {
202 +        register long   pdif = beamdir[*b1p].fo - beamdir[*b2p].fo;
203 +
204 +        if (pdif > 0L) return(1);
205 +        if (pdif < 0L) return(-1);
206 +        return(0);
207 + }
208 +
209 + static int
210 + addclump(hp, bq, nb)            /* transfer the given clump and free */
211 + HOLO    *hp;
212 + int     *bq, nb;
213 + {
214          GCOORD  gc[2];
215          FVECT   ro, rd;
216          double  d;
217 +        int     i;
218          register int    k;
219 <                                        /* get beam coordinates */
220 <        hdbcoord(gc, hb->h, hb->b);
221 <                                        /* add each ray to output */
222 <        for (k = bp->nrm; k--; ) {
223 <                d = hdray(ro, rd, hb->h, gc, hdbray(bp)[k].r);
224 <                if (hb->h->priv == &unobstr)
225 <                        VSUM(ro, ro, rd, d);
226 <                else
227 <                        d = 0.;
228 <                d = hddepth(hb->h, hdbray(bp)[k].d) - d;
229 <                addray(ro, rd, d, hdbray(bp)[k].v);
219 >        register BEAM   *bp;
220 >                                        /* sort based on file position */
221 >        beamdir = hp->bi;
222 >        qsort((char *)bq, nb, sizeof(*bq), bpcmp);
223 >                                        /* transfer each beam */
224 >        for (i = 0; i < nb; i++) {
225 >                bp = hdgetbeam(hp, bq[i]);
226 >                hdbcoord(gc, hp, bq[i]);
227 >                                                /* add each ray to output */
228 >                for (k = bp->nrm; k--; ) {
229 >                        d = hdray(ro, rd, hp, gc, hdbray(bp)[k].r);
230 >                        if (hp->priv == &unobstr)
231 >                                VSUM(ro, ro, rd, d);
232 >                        else
233 >                                d = 0.;
234 >                        d = hddepth(hp, hdbray(bp)[k].d) - d;
235 >                        addray(ro, rd, d, hdbray(bp)[k].v);
236 >                }
237 >                hdfreebeam(hp, bq[i]);          /* free the beam */
238          }
239 <        hdfreebeam(hb->h, hb->b);       /* free the beam */
239 >        hdfreebeam(NULL, 0);                    /* write & free clump */
240 >        return(0);
241   }
242  
219
243   addholo(hdf)                    /* add a holodeck file */
244   char    *hdf;
245   {
# Line 226 | Line 249 | char   *hdf;
249          fd = hdlist[noutsects]->fd;     /* remember the file handle */
250          while (hdlist[noutsects] != NULL) {     /* load each section */
251                                                          /* clump the beams */
252 <                clumpbeams(hdlist[noutsects], 0, BKBSIZE*1024, addbeam);
252 >                clumpbeams(hdlist[noutsects], 0, BKBSIZE*1024, addclump);
253                  hddone(hdlist[noutsects]);              /* free the section */
254          }
255          close(fd);                      /* close input file */
256 +        hdflush(NULL);                  /* flush output */
257   }
258  
259  
# Line 364 | Line 388 | char   *pcf, *zbf;
388                          addray(ro, rd, (double)zscn[i], cscn[i]);
389                  }
390          }
391 <                                /* write output */
392 <        hdsync(NULL, 1);
391 >                                /* write output and free beams */
392 >        hdflush(NULL);
393                                  /* clean up */
394          free((char *)cscn);
395          free((char *)zscn);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines