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

Comparing ray/src/common/objset.c (file contents):
Revision 2.3 by greg, Mon Jul 13 14:23:21 1992 UTC vs.
Revision 2.4 by greg, Fri Mar 7 15:45:28 1997 UTC

# Line 16 | Line 16 | static char SCCSid[] = "$SunId$ LBL";
16  
17   #include  "object.h"
18  
19 #include  "otypes.h"
20
19   #ifndef  OSTSIZ
20   #ifdef  BIGMEM
21   #define  OSTSIZ         56437           /* object table size (a prime!) */
# Line 72 | Line 70 | OBJECT  obj;
70  
71          lower = 1;
72          upper = cm = os[0] + 1;
73 <
73 >                                        /* binary search algorithm */
74          while ((i = (lower + upper) >> 1) != cm) {
75                  cm = obj - os[i];
76                  if (cm > 0)
# Line 109 | Line 107 | register OBJECT  *os1, *os2;
107   }
108  
109  
110 + OBJECT *
111 + setsave(os)                     /* allocate space and save set */
112 + register OBJECT  *os;
113 + {
114 +        OBJECT  *osnew;
115 +        register OBJECT  *oset;
116 +        register int  i;
117 +
118 +        if ((osnew = oset = (OBJECT *)malloc((*os+1)*sizeof(OBJECT))) == NULL)
119 +                error(SYSTEM, "out of memory in setsave\n");
120 +        for (i = *os; i-- >= 0; )       /* inline setcopy */
121 +                *oset++ = *os++;
122 +        return(osnew);
123 + }
124 +
125 +
126 + setunion(osr, os1, os2)         /* osr = os1 Union os2 */
127 + register OBJECT  *osr, *os1, *os2;
128 + {
129 +        register int    i1, i2;
130 +
131 +        osr[0] = 0;
132 +        for (i1 = i2 = 1; i1 <= os1[0] || i2 <= os2[0]; ) {
133 +                while (i1 <= os1[0] && (i2 > os2[0] || os1[i1] <= os2[i2])) {
134 +                        osr[++osr[0]] = os1[i1];
135 +                        if (i2 <= os2[0] && os2[i2] == os1[i1])
136 +                                i2++;
137 +                        i1++;
138 +                }
139 +                while (i2 <= os2[0] && (i1 > os1[0] || os2[i2] < os1[i1]))
140 +                        osr[++osr[0]] = os2[i2++];
141 +        }
142 + }
143 +
144 +
145 + setintersect(osr, os1, os2)     /* osr = os1 Intersect os2 */
146 + register OBJECT  *osr, *os1, *os2;
147 + {
148 +        register int    i1, i2;
149 +
150 +        osr[0] = 0;
151 +        if (os1[0] <= 0)
152 +                return;
153 +        for (i1 = i2 = 1; i2 <= os2[0]; ) {
154 +                while (os1[i1] < os2[i2])
155 +                        if (++i1 > os1[0])
156 +                                return;
157 +                while (os2[i2] < os1[i1])
158 +                        if (++i2 > os2[0])
159 +                                return;
160 +                if (os1[i1] == os2[i2])
161 +                        osr[++osr[0]] = os2[i2++];
162 +        }
163 + }
164 +
165 +
166   OCTREE
167   fullnode(oset)                  /* return octree for object set */
168   OBJECT  *oset;
# Line 188 | Line 242 | noderr:
242   }
243  
244  
245 < nonsurfinset(orig, nobjs)               /* check sets for non-surfaces */
246 < int  orig, nobjs;
245 > int
246 > dosets(f)                               /* loop through all sets */
247 > int     (*f)();
248   {
249 +        int  res = 0;
250          int  n;
251          register OBJECT  *os;
196        register OBJECT  i, s;
252  
253          for (n = 0; n < OSTSIZ; n++) {
254                  if ((os = ostable[n]) == NULL)
255                          continue;
256 <                while ((i = *os++) > 0)
257 <                        do
258 <                                if ((s = *os++) >= orig && s < orig+nobjs &&
259 <                                                ismodifier(objptr(s)->otype))
205 <                                        return(1);
206 <                        while (--i);
256 >                while (*os > 0) {
257 >                        res += (*f)(os);
258 >                        os += *os + 1;
259 >                }
260          }
261 <        return(0);
261 >        return(res);
262 > }
263 >
264 >
265 > donesets()                      /* free ALL SETS in our table */
266 > {
267 >        register int  n;
268 >
269 >        for (n = 0; n < OSTSIZ; n++)
270 >                if (ostable[n] != NULL) {
271 >                        free((char *)ostable[n]);
272 >                        ostable[n] = NULL;
273 >                }
274   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines