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.14 by greg, Wed Mar 12 17:26:58 2003 UTC vs.
Revision 2.25 by greg, Sat Jun 7 05:09:46 2025 UTC

# Line 7 | Line 7 | static const char RCSid[] = "$Id$";
7   *     7/29/85
8   */
9  
10 + #include  "platform.h"
11   #include  "standard.h"
11
12   #include  "octree.h"
13
13   #include  "object.h"
15
14   #include  "otypes.h"
15 + #include  "resolu.h"
16 + #include  "oconv.h"
17  
18 #include  "paths.h"
19
18   #define  OMARGIN        (10*FTINY)      /* margin around global cube */
19  
20 < #define  MAXOBJFIL      127             /* maximum number of scene files */
20 > #define  MAXOBJFIL      255             /* maximum number of scene files */
21  
24 char  *progname;                        /* argv[0] */
25
22   int  nowarn = 0;                        /* supress warnings? */
23  
24   int  objlim = 6;                        /* # of objects before split */
25  
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 */
# Line 38 | Line 34 | double mincusize;                      /* minimum cube size from resolu *
34  
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   {
47          FVECT  bbmin, bbmax;
48          char  *infile = NULL;
# Line 50 | 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 <        initotypes();
56 >        ot_initotypes();
57  
58          for (i = 1; i < argc && argv[i][0] == '-'; i++)
59                  switch (argv[i][1]) {
# Line 85 | Line 86 | char  *argv[];
86                          break;
87                  }
88   breakopt:
89 < #ifdef MSDOS
89 <        setmode(fileno(stdout), O_BINARY);
90 < #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 154 | 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   void
161 < quit(code)                              /* exit program */
162 < int  code;
161 > quit(                           /* exit program */
162 >        int  code
163 > )
164   {
165          exit(code);
166   }
167  
168  
169   void
170 < cputs()                                 /* interactive error */
170 > cputs(void)                                     /* interactive error */
171   {
172          /* referenced, but not used */
173   }
174  
175  
176   void
177 < wputs(s)                                /* warning message */
178 < char  *s;
177 > wputs(                          /* warning message */
178 >        const char  *s
179 > )
180   {
181          if (!nowarn)
182                  eputs(s);
# Line 182 | Line 184 | char  *s;
184  
185  
186   void
187 < eputs(s)                                /* put string to stderr */
188 < register char  *s;
187 > eputs(                          /* put string to stderr */
188 >        const char  *s
189 > )
190   {
191          static int  inln = 0;
192  
# Line 196 | 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 204 | 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          int  inc;
222  
# Line 242 | Line 252 | OBJECT obj;
252   }
253  
254  
255 < add2full(cu, obj, inc)                  /* add object to full node */
256 < register CUBE  *cu;
257 < OBJECT  obj;
258 < int  inc;
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 <        register int  i, j;
266 >        int  i, j;
267  
268          objset(oset, cu->cutree);
269          cukid.cusize = cu->cusize * 0.5;
270  
271 <        if (inc==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