--- ray/src/hd/clumpbeams.c 1998/11/09 17:11:04 3.1 +++ ray/src/hd/clumpbeams.c 2003/07/21 22:30:18 3.5 @@ -1,9 +1,6 @@ -/* Copyright (c) 1998 Silicon Graphics, Inc. */ - #ifndef lint -static char SCCSid[] = "$SunId$ SGI"; +static const char RCSid[] = "$Id: clumpbeams.c,v 3.5 2003/07/21 22:30:18 schorsch Exp $"; #endif - /* * Bundle holodeck beams together into clumps. */ @@ -20,9 +17,7 @@ static int bneighrem; #define nextneigh() (bneighrem<=0 ? 0 : bneighlist[--bneighrem]) -static BEAMI *beamdir; - gcshifti(gc, ia, di, hp) /* shift cell row or column */ register GCOORD *gc; int ia, di; @@ -57,10 +52,10 @@ GCOORD *gc; register int i, j; for (i = 3; i--; ) { - copystruct(&gci0, gc); + gci0 = *gc; gcshifti(&gci0, 0, i-1, hp); for (j = 3; j--; ) { - copystruct(ng+(3*i+j), &gci0); + *(ng+(3*i+j)) = gci0; gcshifti(ng+(3*i+j), gci0.w==gc->w, j-1, hp); } } @@ -85,8 +80,8 @@ int b; continue; if (wg0[i].w == wg1[j].w) continue; - copystruct(bgc, wg0+i); - copystruct(bgc+1, wg1+j); + *bgc = *(wg0+i); + *(bgc+1) = *(wg1+j); bneighlist[bneighrem++] = hdbindex(hp, bgc); #ifdef DEBUG if (bneighlist[bneighrem-1] <= 0) @@ -97,30 +92,16 @@ int b; } -static int -bpcmp(b1p, b2p) /* compare beam positions on disk */ -int *b1p, *b2p; -{ - register long pdif = beamdir[*b1p].fo - beamdir[*b2p].fo; - - if (pdif > 0L) return(1); - if (pdif < 0L) return(-1); - return(0); -} - - -clumpbeams(hp, maxcnt, maxsiz, bf) /* clump beams from hinp */ +clumpbeams(hp, maxcnt, maxsiz, cf) /* clump beams from hinp */ register HOLO *hp; int maxcnt, maxsiz; -int (*bf)(); +int (*cf)(); { static short primes[] = {9431,6803,4177,2659,1609,887,587,251,47,1}; - HDBEAMI bis; - BEAM *bp; - unsigned int4 *bflags; + uint32 *bflags; int *bqueue; int bqlen; - int4 bqtotal; + int32 bqtotal; int bc, bci, bqc, myprime; register int i; /* get clump size */ @@ -129,8 +110,8 @@ int (*bf)(); maxsiz /= sizeof(RAYVAL); /* allocate beam queue */ bqueue = (int *)malloc(maxcnt*sizeof(int)); - bflags = (unsigned int4 *)calloc((nbeams(hp)>>5)+1, - sizeof(unsigned int4)); + bflags = (uint32 *)calloc((nbeams(hp)>>5)+1, + sizeof(uint32)); if (bqueue == NULL | bflags == NULL) error(SYSTEM, "out of memory in clumpbeams"); /* mark empty beams as done */ @@ -169,16 +150,9 @@ int (*bf)(); if (i > 0) break; } - beamdir = hp->bi; /* sort queue */ - qsort((char *)bqueue, bqlen, sizeof(*bqueue), bpcmp); - /* transfer each beam */ - for (i = 0; i < bqlen; i++) { - bp = hdgetbeam(bis.h=hp, bis.b=bqueue[i]); - (*bf)(bp, &bis); - } - hdfreebeam(NULL, 0); /* write & free clump */ + (*cf)(hp, bqueue, bqlen); /* transfer clump */ } - hdsync(NULL, 0); /* we're done -- clean up */ - free((char *)bqueue); - free((char *)bflags); + /* all done; clean up */ + free((void *)bqueue); + free((void *)bflags); }