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 */ |
111 |
|
printf("\n"); |
112 |
|
|
113 |
|
startobj = nobjects; /* previous objects already converted */ |
114 |
< |
|
114 |
> |
|
115 |
|
for ( ; i < argc; i++) /* read new scene descriptions */ |
116 |
|
if (!strcmp(argv[i], "-")) { /* from stdin */ |
117 |
|
readobj(NULL); |
123 |
|
} |
124 |
|
|
125 |
|
ofname[nfiles] = NULL; |
126 |
+ |
|
127 |
+ |
if (inpfrozen && outflags & IO_FILES) { |
128 |
+ |
error(WARNING, "frozen octree"); |
129 |
+ |
outflags &= ~IO_FILES; |
130 |
+ |
} |
131 |
|
/* find bounding box */ |
132 |
|
bbmin[0] = bbmin[1] = bbmin[2] = FHUGE; |
133 |
|
bbmax[0] = bbmax[1] = bbmax[2] = -FHUGE; |
155 |
|
} |
156 |
|
|
157 |
|
mincusize = thescene.cusize / resolu - FTINY; |
158 |
< |
|
158 |
> |
|
159 |
|
for (i = startobj; i < nobjects; i++) /* add new objects */ |
160 |
|
addobject(&thescene, i); |
161 |
< |
|
161 |
> |
|
162 |
|
thescene.cutree = combine(thescene.cutree); /* optimize */ |
163 |
|
|
164 |
|
writeoct(outflags, &thescene, ofname); /* write structures to stdout */ |
225 |
|
|
226 |
|
if (in == O_MISS) |
227 |
|
return; /* no intersection */ |
228 |
< |
|
228 |
> |
|
229 |
|
if (istree(cu->cutree)) { |
230 |
|
/* do children */ |
231 |
|
cukid.cusize = cu->cusize * 0.5; |
250 |
|
/* add to full node */ |
251 |
|
objset(oset, cu->cutree); |
252 |
|
cukid.cusize = cu->cusize * 0.5; |
253 |
< |
|
253 |
> |
|
254 |
|
if (in==O_IN || oset[0] < objlim || cukid.cusize < mincusize) { |
255 |
|
/* add to set */ |
256 |
|
if (oset[0] >= MAXSET) { |