--- ray/src/ot/oconv.c 1992/09/21 12:11:39 2.4 +++ ray/src/ot/oconv.c 2003/02/22 02:07:26 2.12 @@ -1,9 +1,6 @@ -/* Copyright (c) 1992 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: oconv.c,v 2.12 2003/02/22 02:07:26 greg Exp $"; #endif - /* * oconv.c - main program for object to octree conversion. * @@ -22,17 +19,15 @@ static char SCCSid[] = "$SunId$ LBL"; #define OMARGIN (10*FTINY) /* margin around global cube */ -#define MAXOBJFIL 63 /* maximum number of scene files */ +#define MAXOBJFIL 127 /* maximum number of scene files */ char *progname; /* argv[0] */ -char *libpath; /* library search path */ - int nowarn = 0; /* supress warnings? */ int objlim = 5; /* # of objects before split */ -int resolu = 1024; /* octree resolution limit */ +int resolu = 8192; /* octree resolution limit */ CUBE thescene = {EMPTY, {0.0, 0.0, 0.0}, 0.0}; /* our scene */ @@ -41,24 +36,21 @@ int nfiles = 0; /* number of object files */ double mincusize; /* minimum cube size from resolu */ -int (*addobjnotify[])() = {NULL}; /* new object notifier functions */ +void (*addobjnotify[])() = {NULL}; /* new object notifier functions */ main(argc, argv) /* convert object files to an octree */ int argc; -char **argv; +char *argv[]; { - extern char *getenv(); FVECT bbmin, bbmax; char *infile = NULL; + int inpfrozen = 0; int outflags = IO_ALL; OBJECT startobj; int i; - - progname = argv[0]; - if ((libpath = getenv(ULIBVAR)) == NULL) - libpath = DEFPATH; + progname = argv[0] = fixargv0(argv[0]); initotypes(); @@ -100,18 +92,16 @@ breakopt: if (thescene.cusize > FTINY) error(USER, "only one of '-b' or '-i'"); nfiles = readoct(infile, IO_ALL, &thescene, ofname); - if (nfiles == 0 && outflags & IO_FILES) { - error(WARNING, "frozen octree"); - outflags &= ~IO_FILES; - } - } - - printargs(argc, argv, stdout); /* info. header */ + if (nfiles == 0) + inpfrozen++; + } else + newheader("RADIANCE", stdout); /* new binary file header */ + printargs(argc, argv, stdout); fputformat(OCTFMT, stdout); printf("\n"); startobj = nobjects; /* previous objects already converted */ - + for ( ; i < argc; i++) /* read new scene descriptions */ if (!strcmp(argv[i], "-")) { /* from stdin */ readobj(NULL); @@ -123,6 +113,11 @@ breakopt: } ofname[nfiles] = NULL; + + if (inpfrozen && outflags & IO_FILES) { + error(WARNING, "frozen octree"); + outflags &= ~IO_FILES; + } /* find bounding box */ bbmin[0] = bbmin[1] = bbmin[2] = FHUGE; bbmax[0] = bbmax[1] = bbmax[2] = -FHUGE; @@ -150,10 +145,10 @@ breakopt: } mincusize = thescene.cusize / resolu - FTINY; - + for (i = startobj; i < nobjects; i++) /* add new objects */ addobject(&thescene, i); - + thescene.cutree = combine(thescene.cutree); /* optimize */ writeoct(outflags, &thescene, ofname); /* write structures to stdout */ @@ -162,6 +157,7 @@ breakopt: } +void quit(code) /* exit program */ int code; { @@ -169,12 +165,14 @@ int code; } +void cputs() /* interactive error */ { /* referenced, but not used */ } +void wputs(s) /* warning message */ char *s; { @@ -183,6 +181,7 @@ char *s; } +void eputs(s) /* put string to stderr */ register char *s; { @@ -220,7 +219,7 @@ OBJECT obj; if (in == O_MISS) return; /* no intersection */ - + if (istree(cu->cutree)) { /* do children */ cukid.cusize = cu->cusize * 0.5; @@ -245,7 +244,7 @@ OBJECT obj; /* add to full node */ objset(oset, cu->cutree); cukid.cusize = cu->cusize * 0.5; - + if (in==O_IN || oset[0] < objlim || cukid.cusize < mincusize) { /* add to set */ if (oset[0] >= MAXSET) {