| 33 |
|
|
| 34 |
|
#define hasmult (unit_mult < .999 || unit_mult > 1.001) |
| 35 |
|
|
| 36 |
+ |
/* |
| 37 |
+ |
* Stuff for tracking and reusing vertices: |
| 38 |
+ |
*/ |
| 39 |
|
|
| 40 |
+ |
char VKFMT[] = "%+1.9e %+1.9e %+1.9e"; |
| 41 |
+ |
#define VKLEN 64 |
| 42 |
+ |
|
| 43 |
+ |
#define mkvkey(k,v) sprintf(k, VKFMT, (v)[0], (v)[1], (v)[2]) |
| 44 |
+ |
|
| 45 |
+ |
#define NVERTS 256 |
| 46 |
+ |
|
| 47 |
+ |
long clock; /* incremented at each vertex request */ |
| 48 |
+ |
|
| 49 |
+ |
struct vert { |
| 50 |
+ |
long lused; /* when last used (0 if unassigned) */ |
| 51 |
+ |
FVECT p; /* track point position only */ |
| 52 |
+ |
} vert[NVERTS]; /* our vertex cache */ |
| 53 |
+ |
|
| 54 |
+ |
LUTAB vertab = LU_SINIT(free,NULL); /* our vertex lookup table */ |
| 55 |
+ |
|
| 56 |
+ |
|
| 57 |
|
main(argc, argv) |
| 58 |
|
int argc; |
| 59 |
|
char **argv; |
| 80 |
|
goto unkopt; |
| 81 |
|
} |
| 82 |
|
break; |
| 83 |
+ |
default: |
| 84 |
+ |
goto unkopt; |
| 85 |
|
} |
| 86 |
|
init(); |
| 87 |
|
if (i >= argc) |
| 266 |
|
|
| 267 |
|
init() /* initialize dispatch table and output */ |
| 268 |
|
{ |
| 269 |
+ |
lu_init(&vertab, NVERTS); |
| 270 |
|
lu_init(&rdispatch, 22); |
| 271 |
|
add2dispatch("polygon", o_face); |
| 272 |
|
add2dispatch("cone", o_cone); |
| 304 |
|
puts("# End of data converted from Radiance scene input"); |
| 305 |
|
lu_done(&rdispatch); |
| 306 |
|
lu_done(&rmats); |
| 307 |
+ |
lu_done(&vertab); |
| 308 |
|
} |
| 309 |
|
|
| 310 |
|
|
| 311 |
+ |
clrverts() /* clear vertex table */ |
| 312 |
+ |
{ |
| 313 |
+ |
register int i; |
| 314 |
+ |
|
| 315 |
+ |
lu_done(&vertab); |
| 316 |
+ |
for (i = 0; i < NVERTS; i++) |
| 317 |
+ |
vert[i].lused = 0; |
| 318 |
+ |
lu_init(&vertab, NVERTS); |
| 319 |
+ |
} |
| 320 |
+ |
|
| 321 |
+ |
|
| 322 |
|
add2dispatch(name, func) /* add function to dispatch table */ |
| 323 |
|
char *name; |
| 324 |
|
int (*func)(); |
| 336 |
|
} |
| 337 |
|
|
| 338 |
|
|
| 304 |
– |
/* |
| 305 |
– |
* Stuff for tracking and reusing vertices: |
| 306 |
– |
*/ |
| 307 |
– |
|
| 308 |
– |
char VKFMT[] = "%+1.9e %+1.9e %+1.9e"; |
| 309 |
– |
#define VKLEN 64 |
| 310 |
– |
|
| 311 |
– |
#define mkvkey(k,v) sprintf(k, VKFMT, (v)[0], (v)[1], (v)[2]) |
| 312 |
– |
|
| 313 |
– |
#define NVERTS 256 |
| 314 |
– |
|
| 315 |
– |
long clock; /* incremented at each vertex request */ |
| 316 |
– |
|
| 317 |
– |
struct vert { |
| 318 |
– |
long lused; /* when last used (0 if unassigned) */ |
| 319 |
– |
FVECT p; /* track point position only */ |
| 320 |
– |
} vert[NVERTS]; |
| 321 |
– |
|
| 322 |
– |
LUTAB vertab = LU_SINIT(free,NULL); /* our vertex lookup table */ |
| 323 |
– |
|
| 324 |
– |
|
| 339 |
|
char * |
| 340 |
|
getvertid(vname, vp) /* get/set vertex ID for this point */ |
| 341 |
|
char *vname; |
| 345 |
|
register LUENT *lp; |
| 346 |
|
register int i, vndx; |
| 347 |
|
|
| 334 |
– |
if (!vertab.tsiz && !lu_init(&vertab, NVERTS)) |
| 335 |
– |
goto memerr; |
| 348 |
|
clock++; /* increment counter */ |
| 349 |
|
mkvkey(vkey, vp); |
| 350 |
|
if ((lp = lu_find(&vertab, vkey)) == NULL) |
| 524 |
|
fputs(fa->sarg[i], stdout); |
| 525 |
|
} |
| 526 |
|
putchar('\n'); |
| 527 |
+ |
clrverts(); /* vertex id's no longer reliable */ |
| 528 |
|
return(0); |
| 529 |
|
} |
| 530 |
|
|