--- ray/src/ot/oconv.c 1989/02/02 10:33:04 1.1 +++ ray/src/ot/oconv.c 1989/10/14 11:19:34 1.6 @@ -18,6 +18,8 @@ static char SCCSid[] = "$SunId$ LBL"; #include "otypes.h" +#define OMARGIN (10*FTINY) /* margin around global cube */ + #define MAXOBJFIL 63 /* maximum number of scene files */ char *progname; /* argv[0] */ @@ -57,14 +59,16 @@ char **argv; for (i = 1; i < argc && argv[i][0] == '-'; i++) switch (argv[i][1]) { + case '\0': /* scene from stdin */ + goto breakopt; case 'i': /* input octree */ infile = argv[++i]; break; case 'b': /* bounding cube */ - thescene.cuorg[0] = atof(argv[++i]) - FTINY; - thescene.cuorg[1] = atof(argv[++i]) - FTINY; - thescene.cuorg[2] = atof(argv[++i]) - FTINY; - thescene.cusize = atof(argv[++i]) + 2*FTINY; + thescene.cuorg[0] = atof(argv[++i]) - OMARGIN; + thescene.cuorg[1] = atof(argv[++i]) - OMARGIN; + thescene.cuorg[2] = atof(argv[++i]) - OMARGIN; + thescene.cusize = atof(argv[++i]) + 2*OMARGIN; break; case 'n': /* set limit */ objlim = atoi(argv[++i]); @@ -83,7 +87,7 @@ char **argv; error(USER, errmsg); break; } - +breakopt: if (infile != NULL) { /* get old octree & objects */ if (thescene.cusize > FTINY) error(USER, "only one of '-b' or '-i'"); @@ -99,11 +103,16 @@ char **argv; startobj = nobjects; /* previous objects already converted */ - for ( ; i < argc; i++) { /* read new files */ - if (nfiles >= MAXOBJFIL) - error(INTERNAL, "too many scene files"); - readobj(ofname[nfiles++] = argv[i]); - } + for ( ; i < argc; i++) /* read new scene descriptions */ + if (!strcmp(argv[i], "-")) { /* from stdin */ + readobj(NULL); + outflags &= ~IO_FILES; + } else { /* from file */ + if (nfiles >= MAXOBJFIL) + error(INTERNAL, "too many scene files"); + readobj(ofname[nfiles++] = argv[i]); + } + ofname[nfiles] = NULL; /* find bounding box */ bbmin[0] = bbmin[1] = bbmin[2] = FHUGE; @@ -114,13 +123,15 @@ char **argv; if (thescene.cusize == 0.0) { if (bbmin[0] <= bbmax[0]) { for (i = 0; i < 3; i++) { - bbmin[i] -= FTINY; - bbmax[i] += FTINY; + bbmin[i] -= OMARGIN; + bbmax[i] += OMARGIN; } - VCOPY(thescene.cuorg, bbmin); for (i = 0; i < 3; i++) if (bbmax[i] - bbmin[i] > thescene.cusize) thescene.cusize = bbmax[i] - bbmin[i]; + for (i = 0; i < 3; i++) + thescene.cuorg[i] = + (bbmax[i]+bbmin[i]-thescene.cusize)*.5; } } else { for (i = 0; i < 3; i++) @@ -190,7 +201,7 @@ OBJECT obj; in = (*ofun[objptr(obj)->otype].funp)(objptr(obj), cu); - if (!in) + if (in == O_MISS) return; /* no intersection */ if (istree(cu->cutree)) { @@ -217,7 +228,7 @@ OBJECT obj; objset(oset, cu->cutree); cukid.cusize = cu->cusize * 0.5; - if (in == 2 || oset[0] < objlim || cukid.cusize < mincusize) { + if (in==O_IN || oset[0] < objlim || cukid.cusize < mincusize) { /* add to set */ if (oset[0] >= MAXSET) { sprintf(errmsg, @@ -239,9 +250,9 @@ OBJECT obj; if ((1<cutree = ot;