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

Comparing ray/src/ot/obj2mesh.c (file contents):
Revision 2.5 by schorsch, Thu Jun 5 19:29:34 2003 UTC vs.
Revision 2.15 by greg, Fri Mar 3 01:25:27 2017 UTC

# Line 6 | Line 6 | static const char RCSid[] = "$Id$";
6   */
7  
8   #include "copyright.h"
9 + #include "paths.h"
10 + #include "platform.h"
11   #include "standard.h"
12 + #include "resolu.h"
13   #include "cvmesh.h"
14   #include "otypes.h"
15  
16 < extern int      o_face();
16 > extern int      o_face(); /* XXX should go to a header file */
17  
18   int     o_default() { return(O_MISS); }
19  
# Line 20 | Line 23 | char  *progname;                       /* argv[0] */
23  
24   int  nowarn = 0;                        /* supress warnings? */
25  
26 < int  objlim = 15;                       /* # of objects before split */
26 > int  objlim = 9;                        /* # of objects before split */
27  
28   int  resolu = 16384;                    /* octree resolution limit */
29  
30   double  mincusize;                      /* minimum cube size from resolu */
31  
32 + static void addface(CUBE  *cu, OBJECT   obj);
33 + static void add2full(CUBE  *cu, OBJECT  obj);
34  
35 < main(argc, argv)                /* compile a .OBJ file into a mesh */
36 < int  argc;
37 < char  *argv[];
35 >
36 > int
37 > main(           /* compile a .OBJ file into a mesh */
38 >        int  argc,
39 >        char  *argv[]
40 > )
41   {
42          int  nmatf = 0;
43 <        char  *matinp[32];
43 >        int  verbose = 0;
44 >        char  pathnames[12800];
45 >        char  *pns = pathnames;
46 >        char  *matinp[128];
47 >        char  *cp;
48          int  i, j;
49  
50          progname = argv[0];
# Line 49 | Line 61 | char  *argv[];
61                  case 'a':                               /* material file */
62                          matinp[nmatf++] = argv[++i];
63                          break;
64 +                case 'l':                               /* library material */
65 +                        cp = getpath(argv[++i], getrlibpath(), R_OK);
66 +                        if (cp == NULL) {
67 +                                sprintf(errmsg,
68 +                                        "cannot find library material: '%s'",
69 +                                                argv[i]);
70 +                                error(SYSTEM, errmsg);
71 +                        }
72 +                        matinp[nmatf++] = strcpy(pns, cp);
73 +                        while (*pns++)
74 +                                ;
75 +                        break;
76                  case 'w':                               /* supress warnings */
77                          nowarn = 1;
78                          break;
79 +                case 'v':                               /* print mesh stats */
80 +                        verbose = 1;
81 +                        break;
82                  default:
83                          sprintf(errmsg, "unknown option: '%s'", argv[i]);
84                          error(USER, errmsg);
85                          break;
86                  }
87 +
88 +        if (i < argc-2)
89 +                error(USER, "too many file arguments");
90                                          /* initialize mesh */
91          cvinit(i==argc-2 ? argv[i+1] : "<stdout>");
92                                          /* load material input */
# Line 95 | Line 125 | char  *argv[];
125  
126          writemesh(ourmesh, stdout);     /* write mesh to output */
127          
128 <        /* printmeshstats(ourmesh, stderr); */
128 >        if (verbose)
129 >                printmeshstats(ourmesh, stderr);
130  
131          quit(0);
132 +        return 0; /* pro forma return */
133   }
134  
135  
136   void
137 < quit(code)                              /* exit program */
138 < int  code;
137 > quit(                           /* exit program */
138 >        int  code
139 > )
140   {
141          exit(code);
142   }
143  
144  
145   void
146 < cputs()                                 /* interactive error */
146 > cputs(void)                                     /* interactive error */
147   {
148          /* referenced, but not used */
149   }
150  
151  
152   void
153 < wputs(s)                                /* warning message */
154 < char  *s;
153 > wputs(                          /* warning message */
154 >        char  *s
155 > )
156   {
157          if (!nowarn)
158                  eputs(s);
# Line 126 | Line 160 | char  *s;
160  
161  
162   void
163 < eputs(s)                                /* put string to stderr */
164 < register char  *s;
163 > eputs(                          /* put string to stderr */
164 >        register char  *s
165 > )
166   {
167          static int  inln = 0;
168  
# Line 141 | Line 176 | register char  *s;
176   }
177  
178  
179 < addface(cu, obj)                        /* add a face to a cube */
180 < register CUBE  *cu;
181 < OBJECT  obj;
179 > static void
180 > addface(                        /* add a face to a cube */
181 >        register CUBE  *cu,
182 >        OBJECT  obj
183 > )
184   {
185  
186          if (o_face(objptr(obj), cu) == O_MISS)
# Line 176 | Line 213 | OBJECT obj;
213   }
214  
215  
216 < add2full(cu, obj)                       /* add object to full node */
217 < register CUBE  *cu;
218 < OBJECT  obj;
216 > static void
217 > add2full(                       /* add object to full node */
218 >        register CUBE  *cu,
219 >        OBJECT  obj
220 > )
221   {
222          OCTREE  ot;
223          OBJECT  oset[MAXSET+1];
# Line 188 | Line 227 | OBJECT obj;
227          objset(oset, cu->cutree);
228          cukid.cusize = cu->cusize * 0.5;
229  
230 <        if (oset[0] < objlim || cukid.cusize < mincusize) {
230 >        if (oset[0] < objlim || cukid.cusize <
231 >                        (oset[0] < MAXSET ? mincusize : mincusize/256.0)) {
232                                                  /* add to set */
233                  if (oset[0] >= MAXSET) {
234                          sprintf(errmsg, "set overflow in addobject (%s)",

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines