ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/ot/oconv.c
(Generate patch)

Comparing ray/src/ot/oconv.c (file contents):
Revision 2.4 by greg, Mon Sep 21 12:11:39 1992 UTC vs.
Revision 2.15 by schorsch, Thu Jun 5 19:29:34 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1992 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  oconv.c - main program for object to octree conversion.
6   *
# Line 22 | Line 19 | static char SCCSid[] = "$SunId$ LBL";
19  
20   #define  OMARGIN        (10*FTINY)      /* margin around global cube */
21  
22 < #define  MAXOBJFIL      63              /* maximum number of scene files */
22 > #define  MAXOBJFIL      127             /* maximum number of scene files */
23  
24   char  *progname;                        /* argv[0] */
25  
29 char  *libpath;                         /* library search path */
30
26   int  nowarn = 0;                        /* supress warnings? */
27  
28 < int  objlim = 5;                        /* # of objects before split */
28 > int  objlim = 6;                        /* # of objects before split */
29  
30 < int  resolu = 1024;                     /* octree resolution limit */
30 > int  resolu = 16384;                    /* octree resolution limit */
31  
32   CUBE  thescene = {EMPTY, {0.0, 0.0, 0.0}, 0.0};         /* our scene */
33  
# Line 41 | Line 36 | int  nfiles = 0;                       /* number of object files */
36  
37   double  mincusize;                      /* minimum cube size from resolu */
38  
39 < int  (*addobjnotify[])() = {NULL};      /* new object notifier functions */
39 > void  (*addobjnotify[])() = {NULL};     /* new object notifier functions */
40  
41  
42   main(argc, argv)                /* convert object files to an octree */
43   int  argc;
44 < char  **argv;
44 > char  *argv[];
45   {
51        extern char  *getenv();
46          FVECT  bbmin, bbmax;
47          char  *infile = NULL;
48 +        int  inpfrozen = 0;
49          int  outflags = IO_ALL;
50          OBJECT  startobj;
51          int  i;
57        
58        progname = argv[0];
52  
53 <        if ((libpath = getenv(ULIBVAR)) == NULL)
61 <                libpath = DEFPATH;
53 >        progname = argv[0] = fixargv0(argv[0]);
54  
55          initotypes();
56  
# Line 93 | Line 85 | char  **argv;
85                          break;
86                  }
87   breakopt:
88 < #ifdef MSDOS
97 <        setmode(fileno(stdout), O_BINARY);
98 < #endif
88 >        SET_FILE_BINARY(stdout);
89          if (infile != NULL) {           /* get old octree & objects */
90                  if (thescene.cusize > FTINY)
91                          error(USER, "only one of '-b' or '-i'");
92                  nfiles = readoct(infile, IO_ALL, &thescene, ofname);
93 <                if (nfiles == 0 && outflags & IO_FILES) {
94 <                        error(WARNING, "frozen octree");
95 <                        outflags &= ~IO_FILES;
96 <                }
97 <        }
108 <
109 <        printargs(argc, argv, stdout);  /* info. header */
93 >                if (nfiles == 0)
94 >                        inpfrozen++;
95 >        } else
96 >                newheader("RADIANCE", stdout);  /* new binary file header */
97 >        printargs(argc, argv, stdout);
98          fputformat(OCTFMT, stdout);
99          printf("\n");
100  
101          startobj = nobjects;            /* previous objects already converted */
102 <        
102 >
103          for ( ; i < argc; i++)          /* read new scene descriptions */
104                  if (!strcmp(argv[i], "-")) {    /* from stdin */
105                          readobj(NULL);
# Line 123 | Line 111 | breakopt:
111                  }
112  
113          ofname[nfiles] = NULL;
114 +
115 +        if (inpfrozen && outflags & IO_FILES) {
116 +                error(WARNING, "frozen octree");
117 +                outflags &= ~IO_FILES;
118 +        }
119                                                  /* find bounding box */
120          bbmin[0] = bbmin[1] = bbmin[2] = FHUGE;
121          bbmax[0] = bbmax[1] = bbmax[2] = -FHUGE;
# Line 150 | Line 143 | breakopt:
143          }
144  
145          mincusize = thescene.cusize / resolu - FTINY;
146 <                
146 >
147          for (i = startobj; i < nobjects; i++)           /* add new objects */
148                  addobject(&thescene, i);
149 <        
149 >
150          thescene.cutree = combine(thescene.cutree);     /* optimize */
151  
152          writeoct(outflags, &thescene, ofname);  /* write structures to stdout */
# Line 162 | Line 155 | breakopt:
155   }
156  
157  
158 + void
159   quit(code)                              /* exit program */
160   int  code;
161   {
# Line 169 | Line 163 | int  code;
163   }
164  
165  
166 + void
167   cputs()                                 /* interactive error */
168   {
169          /* referenced, but not used */
170   }
171  
172  
173 + void
174   wputs(s)                                /* warning message */
175   char  *s;
176   {
# Line 183 | Line 179 | char  *s;
179   }
180  
181  
182 + void
183   eputs(s)                                /* put string to stderr */
184   register char  *s;
185   {
# Line 209 | Line 206 | addobject(cu, obj)                     /* add an object to a cube */
206   register CUBE  *cu;
207   OBJECT  obj;
208   {
209 <        CUBE  cukid;
213 <        OCTREE  ot;
214 <        OBJECT  oset[MAXSET+1];
215 <        unsigned char  inflg[(MAXSET+7)/8], volflg[(MAXSET+7)/8];
216 <        int  in;
217 <        register int  i, j;
209 >        int  inc;
210  
211 <        in = (*ofun[objptr(obj)->otype].funp)(objptr(obj), cu);
211 >        inc = (*ofun[objptr(obj)->otype].funp)(objptr(obj), cu);
212  
213 <        if (in == O_MISS)
213 >        if (inc == O_MISS)
214                  return;                         /* no intersection */
215 <        
215 >
216          if (istree(cu->cutree)) {
217 <                                                /* do children */
217 >                CUBE  cukid;                    /* do children */
218 >                int  i, j;
219                  cukid.cusize = cu->cusize * 0.5;
220                  for (i = 0; i < 8; i++) {
221                          cukid.cutree = octkid(cu->cutree, i);
# Line 237 | Line 230 | OBJECT obj;
230                  return;
231          }
232          if (isempty(cu->cutree)) {
233 <                                                /* singular set */
233 >                OBJECT  oset[2];                /* singular set */
234                  oset[0] = 1; oset[1] = obj;
235                  cu->cutree = fullnode(oset);
236                  return;
237          }
238                                          /* add to full node */
239 +        add2full(cu, obj, inc);
240 + }
241 +
242 +
243 + add2full(cu, obj, inc)                  /* add object to full node */
244 + register CUBE  *cu;
245 + OBJECT  obj;
246 + int  inc;
247 + {
248 +        OCTREE  ot;
249 +        OBJECT  oset[MAXSET+1];
250 +        CUBE  cukid;
251 +        unsigned char  inflg[(MAXSET+7)/8], volflg[(MAXSET+7)/8];
252 +        register int  i, j;
253 +
254          objset(oset, cu->cutree);
255          cukid.cusize = cu->cusize * 0.5;
256 <        
257 <        if (in==O_IN || oset[0] < objlim || cukid.cusize < mincusize) {
256 >
257 >        if (inc==O_IN || oset[0] < objlim || cukid.cusize < mincusize) {
258                                                  /* add to set */
259                  if (oset[0] >= MAXSET) {
260                          sprintf(errmsg, "set overflow in addobject (%s)",

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines