| 26 |
|
|
| 27 |
|
char *progname; /* argv[0] */ |
| 28 |
|
|
| 29 |
– |
char *libpath; /* library search path */ |
| 30 |
– |
|
| 29 |
|
int nowarn = 0; /* supress warnings? */ |
| 30 |
|
|
| 31 |
|
int objlim = 5; /* # of objects before split */ |
| 49 |
|
extern char *getenv(); |
| 50 |
|
FVECT bbmin, bbmax; |
| 51 |
|
char *infile = NULL; |
| 52 |
+ |
int inpfrozen = 0; |
| 53 |
|
int outflags = IO_ALL; |
| 54 |
|
OBJECT startobj; |
| 55 |
|
int i; |
| 57 |
– |
|
| 58 |
– |
progname = argv[0]; |
| 56 |
|
|
| 57 |
< |
if ((libpath = getenv(ULIBVAR)) == NULL) |
| 61 |
< |
libpath = DEFPATH; |
| 57 |
> |
progname = argv[0] = fixargv0(argv[0]); |
| 58 |
|
|
| 59 |
|
initotypes(); |
| 60 |
|
|
| 61 |
|
for (i = 1; i < argc && argv[i][0] == '-'; i++) |
| 62 |
|
switch (argv[i][1]) { |
| 63 |
|
case '\0': /* scene from stdin */ |
| 64 |
+ |
outflags &= ~IO_FILES; |
| 65 |
|
goto breakopt; |
| 66 |
|
case 'i': /* input octree */ |
| 67 |
|
infile = argv[++i]; |
| 97 |
|
if (thescene.cusize > FTINY) |
| 98 |
|
error(USER, "only one of '-b' or '-i'"); |
| 99 |
|
nfiles = readoct(infile, IO_ALL, &thescene, ofname); |
| 100 |
< |
if (nfiles == 0 && outflags & IO_FILES) { |
| 101 |
< |
error(WARNING, "frozen octree"); |
| 102 |
< |
outflags &= ~IO_FILES; |
| 103 |
< |
} |
| 104 |
< |
} |
| 108 |
< |
|
| 109 |
< |
printargs(argc, argv, stdout); /* info. header */ |
| 100 |
> |
if (nfiles == 0) |
| 101 |
> |
inpfrozen++; |
| 102 |
> |
} else |
| 103 |
> |
newheader("RADIANCE", stdout); /* new binary file header */ |
| 104 |
> |
printargs(argc, argv, stdout); |
| 105 |
|
fputformat(OCTFMT, stdout); |
| 106 |
|
printf("\n"); |
| 107 |
|
|
| 108 |
|
startobj = nobjects; /* previous objects already converted */ |
| 109 |
< |
|
| 109 |
> |
|
| 110 |
|
for ( ; i < argc; i++) /* read new scene descriptions */ |
| 111 |
|
if (!strcmp(argv[i], "-")) { /* from stdin */ |
| 112 |
|
readobj(NULL); |
| 118 |
|
} |
| 119 |
|
|
| 120 |
|
ofname[nfiles] = NULL; |
| 121 |
+ |
|
| 122 |
+ |
if (inpfrozen && outflags & IO_FILES) { |
| 123 |
+ |
error(WARNING, "frozen octree"); |
| 124 |
+ |
outflags &= ~IO_FILES; |
| 125 |
+ |
} |
| 126 |
|
/* find bounding box */ |
| 127 |
|
bbmin[0] = bbmin[1] = bbmin[2] = FHUGE; |
| 128 |
|
bbmax[0] = bbmax[1] = bbmax[2] = -FHUGE; |
| 150 |
|
} |
| 151 |
|
|
| 152 |
|
mincusize = thescene.cusize / resolu - FTINY; |
| 153 |
< |
|
| 153 |
> |
|
| 154 |
|
for (i = startobj; i < nobjects; i++) /* add new objects */ |
| 155 |
|
addobject(&thescene, i); |
| 156 |
< |
|
| 156 |
> |
|
| 157 |
|
thescene.cutree = combine(thescene.cutree); /* optimize */ |
| 158 |
|
|
| 159 |
|
writeoct(outflags, &thescene, ofname); /* write structures to stdout */ |
| 220 |
|
|
| 221 |
|
if (in == O_MISS) |
| 222 |
|
return; /* no intersection */ |
| 223 |
< |
|
| 223 |
> |
|
| 224 |
|
if (istree(cu->cutree)) { |
| 225 |
|
/* do children */ |
| 226 |
|
cukid.cusize = cu->cusize * 0.5; |
| 245 |
|
/* add to full node */ |
| 246 |
|
objset(oset, cu->cutree); |
| 247 |
|
cukid.cusize = cu->cusize * 0.5; |
| 248 |
< |
|
| 248 |
> |
|
| 249 |
|
if (in==O_IN || oset[0] < objlim || cukid.cusize < mincusize) { |
| 250 |
|
/* add to set */ |
| 251 |
|
if (oset[0] >= MAXSET) { |