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.8 by greg, Mon Mar 28 11:13:58 1994 UTC vs.
Revision 2.25 by greg, Sat Jun 7 05:09:46 2025 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   *
7   *     7/29/85
8   */
9  
10 + #include  "platform.h"
11   #include  "standard.h"
14
12   #include  "octree.h"
16
13   #include  "object.h"
18
14   #include  "otypes.h"
15 + #include  "resolu.h"
16 + #include  "oconv.h"
17  
21 #include  "paths.h"
22
18   #define  OMARGIN        (10*FTINY)      /* margin around global cube */
19  
20 < #define  MAXOBJFIL      63              /* maximum number of scene files */
20 > #define  MAXOBJFIL      255             /* maximum number of scene files */
21  
27 char  *progname;                        /* argv[0] */
28
29 char  *libpath;                         /* library search path */
30
22   int  nowarn = 0;                        /* supress warnings? */
23  
24 < int  objlim = 5;                        /* # of objects before split */
24 > int  objlim = 6;                        /* # of objects before split */
25  
26 < int  resolu = 1024;                     /* octree resolution limit */
26 > int  resolu = 16384;                    /* octree resolution limit */
27  
28 < CUBE  thescene = {EMPTY, {0.0, 0.0, 0.0}, 0.0};         /* our scene */
28 > CUBE  thescene = {{0.0, 0.0, 0.0}, 0.0, EMPTY};         /* our scene */
29  
30   char  *ofname[MAXOBJFIL+1];             /* object file names */
31   int  nfiles = 0;                        /* number of object files */
32  
33   double  mincusize;                      /* minimum cube size from resolu */
34  
35 < int  (*addobjnotify[])() = {NULL};      /* new object notifier functions */
35 > void  (*addobjnotify[])() = {NULL};     /* new object notifier functions */
36  
37 + static void addobject(CUBE  *cu, OBJECT obj);
38 + static void add2full(CUBE  *cu, OBJECT  obj, int  inc);
39  
40 < main(argc, argv)                /* convert object files to an octree */
41 < int  argc;
42 < char  **argv;
40 >
41 > int
42 > main(           /* convert object files to an octree */
43 >        int  argc,
44 >        char  *argv[]
45 > )
46   {
51        extern char  *getenv();
47          FVECT  bbmin, bbmax;
48          char  *infile = NULL;
49          int  inpfrozen = 0;
# Line 56 | Line 51 | char  **argv;
51          OBJECT  startobj;
52          int  i;
53  
54 <        progname = argv[0] = fixargv0(argv[0]);
54 >        fixargv0(argv[0]);              /* sets global progname */
55  
56 <        if ((libpath = getenv(ULIBVAR)) == NULL)
62 <                libpath = DEFPATH;
56 >        ot_initotypes();
57  
64        initotypes();
65
58          for (i = 1; i < argc && argv[i][0] == '-'; i++)
59                  switch (argv[i][1]) {
60                  case '\0':                              /* scene from stdin */
69                        outflags &= ~IO_FILES;
61                          goto breakopt;
62                  case 'i':                               /* input octree */
63                          infile = argv[++i];
# Line 95 | Line 86 | char  **argv;
86                          break;
87                  }
88   breakopt:
89 < #ifdef MSDOS
99 <        setmode(fileno(stdout), O_BINARY);
100 < #endif
89 >        SET_FILE_BINARY(stdout);
90          if (infile != NULL) {           /* get old octree & objects */
91                  if (thescene.cusize > FTINY)
92                          error(USER, "only one of '-b' or '-i'");
# Line 164 | Line 153 | breakopt:
153          writeoct(outflags, &thescene, ofname);  /* write structures to stdout */
154  
155          quit(0);
156 +        return 0; /* pro forma return */
157   }
158  
159  
160 < quit(code)                              /* exit program */
161 < int  code;
160 > void
161 > quit(                           /* exit program */
162 >        int  code
163 > )
164   {
165          exit(code);
166   }
167  
168  
169 < cputs()                                 /* interactive error */
169 > void
170 > cputs(void)                                     /* interactive error */
171   {
172          /* referenced, but not used */
173   }
174  
175  
176 < wputs(s)                                /* warning message */
177 < char  *s;
176 > void
177 > wputs(                          /* warning message */
178 >        const char  *s
179 > )
180   {
181          if (!nowarn)
182                  eputs(s);
183   }
184  
185  
186 < eputs(s)                                /* put string to stderr */
187 < register char  *s;
186 > void
187 > eputs(                          /* put string to stderr */
188 >        const char  *s
189 > )
190   {
191          static int  inln = 0;
192  
# Line 202 | Line 199 | register char  *s;
199                  inln = 0;
200   }
201  
202 +                                /* conflicting def's in param.h */
203 + #undef  tstbit
204 + #undef  setbit
205 + #undef  clrbit
206 + #undef  tglbit
207  
208   #define  bitop(f,i,op)          (f[((i)>>3)] op (1<<((i)&7)))
209   #define  tstbit(f,i)            bitop(f,i,&)
# Line 210 | Line 212 | register char  *s;
212   #define  tglbit(f,i)            bitop(f,i,^=)
213  
214  
215 < addobject(cu, obj)                      /* add an object to a cube */
216 < register CUBE  *cu;
217 < OBJECT  obj;
215 > static void
216 > addobject(                      /* add an object to a cube */
217 >        CUBE  *cu,
218 >        OBJECT  obj
219 > )
220   {
221 <        CUBE  cukid;
218 <        OCTREE  ot;
219 <        OBJECT  oset[MAXSET+1];
220 <        unsigned char  inflg[(MAXSET+7)/8], volflg[(MAXSET+7)/8];
221 <        int  in;
222 <        register int  i, j;
221 >        int  inc;
222  
223 <        in = (*ofun[objptr(obj)->otype].funp)(objptr(obj), cu);
223 >        inc = (*ofun[objptr(obj)->otype].funp)(objptr(obj), cu);
224  
225 <        if (in == O_MISS)
225 >        if (inc == O_MISS)
226                  return;                         /* no intersection */
227  
228          if (istree(cu->cutree)) {
229 <                                                /* do children */
229 >                CUBE  cukid;                    /* do children */
230 >                int  i, j;
231                  cukid.cusize = cu->cusize * 0.5;
232                  for (i = 0; i < 8; i++) {
233                          cukid.cutree = octkid(cu->cutree, i);
# Line 242 | Line 242 | OBJECT obj;
242                  return;
243          }
244          if (isempty(cu->cutree)) {
245 <                                                /* singular set */
245 >                OBJECT  oset[2];                /* singular set */
246                  oset[0] = 1; oset[1] = obj;
247                  cu->cutree = fullnode(oset);
248                  return;
249          }
250                                          /* add to full node */
251 +        add2full(cu, obj, inc);
252 + }
253 +
254 +
255 + static void
256 + add2full(                       /* add object to full node */
257 +        CUBE  *cu,
258 +        OBJECT  obj,
259 +        int  inc
260 + )
261 + {
262 +        OCTREE  ot;
263 +        OBJECT  oset[MAXSET+1];
264 +        CUBE  cukid;
265 +        unsigned char  inflg[(MAXSET+7)/8], volflg[(MAXSET+7)/8];
266 +        int  i, j;
267 +
268          objset(oset, cu->cutree);
269          cukid.cusize = cu->cusize * 0.5;
270  
271 <        if (in==O_IN || oset[0] < objlim || cukid.cusize < mincusize) {
271 >        if (inc==O_IN || oset[0] < objlim || cukid.cusize <
272 >                        (oset[0] < MAXSET ? mincusize : mincusize/256.0)) {
273                                                  /* add to set */
274                  if (oset[0] >= MAXSET) {
275                          sprintf(errmsg, "set overflow in addobject (%s)",

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines