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

Comparing ray/src/hd/clumpbeams.c (file contents):
Revision 3.1 by gwlarson, Mon Nov 9 17:11:04 1998 UTC vs.
Revision 3.6 by schorsch, Sun Jul 27 22:12:02 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1998 Silicon Graphics, Inc. */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ SGI";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Bundle holodeck beams together into clumps.
6   */
# Line 20 | Line 17 | static int     bneighrem;
17  
18   #define nextneigh()     (bneighrem<=0 ? 0 : bneighlist[--bneighrem])
19  
23 static BEAMI    *beamdir;
20  
25
21   gcshifti(gc, ia, di, hp)        /* shift cell row or column */
22   register GCOORD *gc;
23   int     ia, di;
# Line 57 | Line 52 | GCOORD *gc;
52          register int    i, j;
53  
54          for (i = 3; i--; ) {
55 <                copystruct(&gci0, gc);
55 >                gci0 = *gc;
56                  gcshifti(&gci0, 0, i-1, hp);
57                  for (j = 3; j--; ) {
58 <                        copystruct(ng+(3*i+j), &gci0);
58 >                        *(ng+(3*i+j)) = gci0;
59                          gcshifti(ng+(3*i+j), gci0.w==gc->w, j-1, hp);
60                  }
61          }
# Line 81 | Line 76 | int    b;
76          bneighrem = 0;
77          for (i = 9; i--; )
78                  for (j = 9; j--; ) {
79 <                        if (i == 4 & j == 4)    /* don't copy starting beam */
79 >                        if ((i == 4) & (j == 4))        /* don't copy starting beam */
80                                  continue;
81                          if (wg0[i].w == wg1[j].w)
82                                  continue;
83 <                        copystruct(bgc, wg0+i);
84 <                        copystruct(bgc+1, wg1+j);
83 >                        *bgc = *(wg0+i);
84 >                        *(bgc+1) = *(wg1+j);
85                          bneighlist[bneighrem++] = hdbindex(hp, bgc);
86   #ifdef DEBUG
87                          if (bneighlist[bneighrem-1] <= 0)
# Line 97 | Line 92 | int    b;
92   }
93  
94  
95 < static int
101 < bpcmp(b1p, b2p)                 /* compare beam positions on disk */
102 < int     *b1p, *b2p;
103 < {
104 <        register long   pdif = beamdir[*b1p].fo - beamdir[*b2p].fo;
105 <
106 <        if (pdif > 0L) return(1);
107 <        if (pdif < 0L) return(-1);
108 <        return(0);
109 < }
110 <
111 <
112 < clumpbeams(hp, maxcnt, maxsiz, bf)      /* clump beams from hinp */
95 > clumpbeams(hp, maxcnt, maxsiz, cf)      /* clump beams from hinp */
96   register HOLO   *hp;
97   int     maxcnt, maxsiz;
98 < int     (*bf)();
98 > int     (*cf)();
99   {
100          static short    primes[] = {9431,6803,4177,2659,1609,887,587,251,47,1};
101 <        HDBEAMI bis;
119 <        BEAM    *bp;
120 <        unsigned int4   *bflags;
101 >        uint32  *bflags;
102          int     *bqueue;
103          int     bqlen;
104 <        int4    bqtotal;
104 >        int32   bqtotal;
105          int     bc, bci, bqc, myprime;
106          register int    i;
107                                          /* get clump size */
# Line 129 | Line 110 | int    (*bf)();
110          maxsiz /= sizeof(RAYVAL);
111                                          /* allocate beam queue */
112          bqueue = (int *)malloc(maxcnt*sizeof(int));
113 <        bflags = (unsigned int4 *)calloc((nbeams(hp)>>5)+1,
114 <                        sizeof(unsigned int4));
115 <        if (bqueue == NULL | bflags == NULL)
113 >        bflags = (uint32 *)calloc((nbeams(hp)>>5)+1,
114 >                        sizeof(uint32));
115 >        if ((bqueue == NULL) | (bflags == NULL))
116                  error(SYSTEM, "out of memory in clumpbeams");
117                                          /* mark empty beams as done */
118          for (i = nbeams(hp); i > 0; i--)
# Line 169 | Line 150 | int    (*bf)();
150                          if (i > 0)
151                                  break;
152                  }
153 <                beamdir = hp->bi;               /* sort queue */
173 <                qsort((char *)bqueue, bqlen, sizeof(*bqueue), bpcmp);
174 <                                                /* transfer each beam */
175 <                for (i = 0; i < bqlen; i++) {
176 <                        bp = hdgetbeam(bis.h=hp, bis.b=bqueue[i]);
177 <                        (*bf)(bp, &bis);
178 <                }
179 <                hdfreebeam(NULL, 0);            /* write & free clump */
153 >                (*cf)(hp, bqueue, bqlen);       /* transfer clump */
154          }
155 <        hdsync(NULL, 0);                /* we're done -- clean up */
156 <        free((char *)bqueue);
157 <        free((char *)bflags);
155 >                                        /* all done; clean up */
156 >        free((void *)bqueue);
157 >        free((void *)bflags);
158   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines