51 |
|
extern char *getenv(); |
52 |
|
FVECT bbmin, bbmax; |
53 |
|
char *infile = NULL; |
54 |
+ |
int inpfrozen = 0; |
55 |
|
int outflags = IO_ALL; |
56 |
|
OBJECT startobj; |
57 |
|
int i; |
57 |
– |
|
58 |
– |
progname = argv[0]; |
58 |
|
|
59 |
+ |
progname = argv[0] = fixargv0(argv[0]); |
60 |
+ |
|
61 |
|
if ((libpath = getenv(ULIBVAR)) == NULL) |
62 |
|
libpath = DEFPATH; |
63 |
|
|
66 |
|
for (i = 1; i < argc && argv[i][0] == '-'; i++) |
67 |
|
switch (argv[i][1]) { |
68 |
|
case '\0': /* scene from stdin */ |
69 |
+ |
outflags &= ~IO_FILES; |
70 |
|
goto breakopt; |
71 |
|
case 'i': /* input octree */ |
72 |
|
infile = argv[++i]; |
102 |
|
if (thescene.cusize > FTINY) |
103 |
|
error(USER, "only one of '-b' or '-i'"); |
104 |
|
nfiles = readoct(infile, IO_ALL, &thescene, ofname); |
105 |
< |
if (nfiles == 0 && outflags & IO_FILES) { |
106 |
< |
error(WARNING, "frozen octree"); |
105 |
< |
outflags &= ~IO_FILES; |
106 |
< |
} |
105 |
> |
if (nfiles == 0) |
106 |
> |
inpfrozen++; |
107 |
|
} |
108 |
|
|
109 |
< |
printargs(argc, argv, stdout); /* info. header */ |
109 |
> |
newheader("RADIANCE", stdout); /* new binary file header */ |
110 |
> |
printargs(argc, argv, stdout); |
111 |
|
fputformat(OCTFMT, stdout); |
112 |
|
printf("\n"); |
113 |
|
|
114 |
|
startobj = nobjects; /* previous objects already converted */ |
115 |
< |
|
115 |
> |
|
116 |
|
for ( ; i < argc; i++) /* read new scene descriptions */ |
117 |
|
if (!strcmp(argv[i], "-")) { /* from stdin */ |
118 |
|
readobj(NULL); |
124 |
|
} |
125 |
|
|
126 |
|
ofname[nfiles] = NULL; |
127 |
+ |
|
128 |
+ |
if (inpfrozen && outflags & IO_FILES) { |
129 |
+ |
error(WARNING, "frozen octree"); |
130 |
+ |
outflags &= ~IO_FILES; |
131 |
+ |
} |
132 |
|
/* find bounding box */ |
133 |
|
bbmin[0] = bbmin[1] = bbmin[2] = FHUGE; |
134 |
|
bbmax[0] = bbmax[1] = bbmax[2] = -FHUGE; |
156 |
|
} |
157 |
|
|
158 |
|
mincusize = thescene.cusize / resolu - FTINY; |
159 |
< |
|
159 |
> |
|
160 |
|
for (i = startobj; i < nobjects; i++) /* add new objects */ |
161 |
|
addobject(&thescene, i); |
162 |
< |
|
162 |
> |
|
163 |
|
thescene.cutree = combine(thescene.cutree); /* optimize */ |
164 |
|
|
165 |
|
writeoct(outflags, &thescene, ofname); /* write structures to stdout */ |
226 |
|
|
227 |
|
if (in == O_MISS) |
228 |
|
return; /* no intersection */ |
229 |
< |
|
229 |
> |
|
230 |
|
if (istree(cu->cutree)) { |
231 |
|
/* do children */ |
232 |
|
cukid.cusize = cu->cusize * 0.5; |
251 |
|
/* add to full node */ |
252 |
|
objset(oset, cu->cutree); |
253 |
|
cukid.cusize = cu->cusize * 0.5; |
254 |
< |
|
254 |
> |
|
255 |
|
if (in==O_IN || oset[0] < objlim || cukid.cusize < mincusize) { |
256 |
|
/* add to set */ |
257 |
|
if (oset[0] >= MAXSET) { |