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.11 by gwlarson, Thu Nov 12 15:06:00 1998 UTC

# 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 >        hdflush(NULL);                  /* 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 */
# Line 364 | Line 387 | char   *pcf, *zbf;
387                          addray(ro, rd, (double)zscn[i], cscn[i]);
388                  }
389          }
390 <                                /* write output */
391 <        hdsync(NULL, 1);
390 >                                /* write output and free beams */
391 >        hdflush(NULL);
392                                  /* clean up */
393          free((char *)cscn);
394          free((char *)zscn);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines