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

Comparing ray/src/rt/colortab.c (file contents):
Revision 1.6 by greg, Wed Oct 4 09:23:38 1989 UTC vs.
Revision 1.7 by greg, Thu Oct 12 11:12:48 1989 UTC

# Line 37 | Line 37 | static char SCCSid[] = "$SunId$ LBL";
37   #define CNODE           short
38   #define set_branch(p,c) ((c)<<2|(p))
39   #define set_pval(pv)    ((pv)<<2|3)
40 + #define is_branch(cn)   (((cn)&3)!=3)
41   #define is_pval(cn)     (((cn)&3)==3)
42   #define part(cn)        ((cn)>>2)
43   #define prim(cn)        ((cn)&3)
# Line 68 | Line 69 | int    ncolors;
69                                  /* clear color table */
70          bzero(clrtab, sizeof(clrtab));
71                                  /* partition color space */
72 <        cut(ctree, FBDEPTH, CLRCUBE, 0, ncolors);
72 >        cut(ctree, 0, CLRCUBE, 0, ncolors);
73                                  /* clear histogram */
74          bzero(histo, sizeof(histo));
75                                  /* return number of colors used */
# Line 96 | Line 97 | int    (*set_pixel)();
97                                                  /* add to histogram */
98          histo[cv[RED]][cv[GRN]][cv[BLU]]++;
99                                                  /* find pixel in tree */
100 <        p.t = ctree;
100 <        for (h = FBDEPTH; h > 0; h--) {
101 <                if (is_pval(*p.t))
102 <                        break;
100 >        for (p.t = ctree, h = 0; is_branch(*p.t); h++)
101                  if (cv[prim(*p.t)] < part(*p.t))
102 <                        p.t++;          /* left branch */
102 >                        p.t += 1<<h;            /* left branch */
103                  else
104 <                        p.t += 1<<h;    /* right branch */
107 <        }
104 >                        p.t += 1<<(h+1);        /* right branch */
105          h = pval(*p.t);
106                                                  /* add to color table */
107          p.e = clrtab + h;
# Line 158 | Line 155 | BYTE   *rmap, *gmap, *bmap;
155  
156  
157   static
158 < cut(tree, height, box, c0, c1)          /* partition color space */
158 > cut(tree, level, box, c0, c1)           /* partition color space */
159   register CNODE  *tree;
160 < int     height;
160 > int     level;
161   register int    box[3][2];
162   int     c0, c1;
163   {
# Line 175 | Line 172 | int    c0, c1;
172          bcopy(box, kb, sizeof(kb));
173                                                  /* do left (lesser) branch */
174          kb[prim(*tree)][1] = part(*tree);
175 <        cut(tree+1, height-1, kb, c0, (c0+c1)>>1);
175 >        cut(tree+(1<<level), level+1, kb, c0, (c0+c1)>>1);
176                                                  /* do right branch */
177          kb[prim(*tree)][0] = part(*tree);
178          kb[prim(*tree)][1] = box[prim(*tree)][1];
179 <        cut(tree+(1<<height), height-1, kb, (c0+c1)>>1, c1);
179 >        cut(tree+(1<<(level+1)), level+1, kb, (c0+c1)>>1, c1);
180   }
181  
182  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines