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

Comparing ray/src/hd/rhoptimize.c (file contents):
Revision 3.4 by gwlarson, Mon Nov 9 17:11:40 1998 UTC vs.
Revision 3.5 by gwlarson, Thu Nov 12 15:07:49 1998 UTC

# Line 133 | Line 133 | char   *infn, *outfn;
133   }
134  
135  
136 < static HOLO     *hout;          /* output holodeck section */
136 > static BEAMI    *beamdir;
137  
138   static int
139 < xferbeam(bp, hb)                /* transfer the given beam to hout and free */
140 < register BEAM   *bp;
141 < HDBEAMI *hb;
139 > bpcmp(b1p, b2p)                 /* compare beam positions on disk */
140 > int     *b1p, *b2p;
141   {
142 <        bcopy((char *)hdbray(bp), (char *)hdnewrays(hout,hb->b,bp->nrm),
143 <                        bp->nrm*sizeof(RAYVAL));
144 <        hdfreebeam(hb->h, hb->b);
142 >        register long   pdif = beamdir[*b1p].fo - beamdir[*b2p].fo;
143 >
144 >        if (pdif > 0L) return(1);
145 >        if (pdif < 0L) return(-1);
146          return(0);
147   }
148  
149 + static HOLO     *hout;
150 +
151 + static int
152 + xferclump(hp, bq, nb)           /* transfer the given clump to hout and free */
153 + HOLO    *hp;
154 + int     *bq, nb;
155 + {
156 +        register int    i;
157 +        register BEAM   *bp;
158 +
159 +        beamdir = hp->bi;               /* sort based on file position */
160 +        qsort((char *)bq, nb, sizeof(*bq), bpcmp);
161 +                                        /* transfer and free each beam */
162 +        for (i = 0; i < nb; i++) {
163 +                bp = hdgetbeam(hp, bq[i]);
164 +                bcopy((char *)hdbray(bp), (char *)hdnewrays(hout,bq[i],bp->nrm),
165 +                                bp->nrm*sizeof(RAYVAL));
166 +                hdfreebeam(hp, bq[i]);
167 +        }
168 +        hdflush(hout);                  /* write & free clump */
169 +        return(0);
170 + }
171 +
172   copysect(ifd, ofd)              /* copy holodeck section from ifd to ofd */
173   int     ifd, ofd;
174   {
# Line 155 | Line 178 | int    ifd, ofd;
178                                          /* create output section directory */
179          hout = hdinit(ofd, (HDGRID *)hinp);
180                                          /* clump the beams */
181 <        clumpbeams(hinp, 0, BKBSIZE*1024, xferbeam);
181 >        clumpbeams(hinp, 0, BKBSIZE*1024, xferclump);
182                                          /* clean up */
183          hddone(hinp);
184          hddone(hout);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines