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.4 by greg, Fri Apr 18 21:47:45 2003 UTC vs.
Revision 2.11 by greg, Fri Apr 23 00:56:27 2004 UTC

# Line 6 | Line 6 | static const char RCSid[] = "$Id$";
6   */
7  
8   #include "copyright.h"
9 + #include "platform.h"
10   #include "standard.h"
11 + #include "resolu.h"
12   #include "cvmesh.h"
13   #include "otypes.h"
14  
15 < extern int      o_face();
15 > extern int      o_face(); /* XXX should go to a header file */
16  
17   int     o_default() { return(O_MISS); }
18  
# Line 26 | Line 28 | int  resolu = 16384;                   /* octree resolution limit */
28  
29   double  mincusize;                      /* minimum cube size from resolu */
30  
31 + static void addface(CUBE  *cu, OBJECT   obj);
32 + static void add2full(CUBE  *cu, OBJECT  obj);
33  
34 < main(argc, argv)                /* compile a .OBJ file into a mesh */
35 < int  argc;
36 < char  *argv[];
34 >
35 > int
36 > main(           /* compile a .OBJ file into a mesh */
37 >        int  argc,
38 >        char  *argv[]
39 > )
40   {
41          int  nmatf = 0;
42 <        char  *matinp[32];
42 >        char  pathnames[12800];
43 >        char  *pns = pathnames;
44 >        char  *matinp[128];
45 >        char  *cp;
46          int  i, j;
47  
48          progname = argv[0];
# Line 49 | Line 59 | char  *argv[];
59                  case 'a':                               /* material file */
60                          matinp[nmatf++] = argv[++i];
61                          break;
62 +                case 'l':                               /* library material */
63 +                        cp = getpath(argv[++i], getrlibpath(), R_OK);
64 +                        if (cp == NULL) {
65 +                                sprintf(errmsg,
66 +                                        "cannot find library material: '%s'",
67 +                                                argv[i]);
68 +                                error(USER, errmsg);
69 +                        }
70 +                        matinp[nmatf++] = strcpy(pns, cp);
71 +                        while (*pns++)
72 +                                ;
73 +                        break;
74                  case 'w':                               /* supress warnings */
75                          nowarn = 1;
76                          break;
# Line 57 | Line 79 | char  *argv[];
79                          error(USER, errmsg);
80                          break;
81                  }
82 +
83 +        if (i < argc-2)
84 +                error(USER, "too many file arguments");
85                                          /* initialize mesh */
86          cvinit(i==argc-2 ? argv[i+1] : "<stdout>");
87                                          /* load material input */
# Line 73 | Line 98 | char  *argv[];
98          if (i == argc-2)                /* open output file */
99                  if (freopen(argv[i+1], "w", stdout) == NULL)
100                          error(SYSTEM, "cannot open output file");
101 < #ifdef MSDOS
77 <        setmode(fileno(stdout), O_BINARY);
78 < #endif
101 >        SET_FILE_BINARY(stdout);
102          newheader("RADIANCE", stdout);  /* new binary file header */
103          printargs(i<argc ? i+1 : argc, argv, stdout);
104          fputformat(MESHFMT, stdout);
# Line 100 | Line 123 | char  *argv[];
123          /* printmeshstats(ourmesh, stderr); */
124  
125          quit(0);
126 +        return 0; /* pro forma return */
127   }
128  
129  
130   void
131 < quit(code)                              /* exit program */
132 < int  code;
131 > quit(                           /* exit program */
132 >        int  code
133 > )
134   {
135          exit(code);
136   }
137  
138  
139   void
140 < cputs()                                 /* interactive error */
140 > cputs(void)                                     /* interactive error */
141   {
142          /* referenced, but not used */
143   }
144  
145  
146   void
147 < wputs(s)                                /* warning message */
148 < char  *s;
147 > wputs(                          /* warning message */
148 >        char  *s
149 > )
150   {
151          if (!nowarn)
152                  eputs(s);
# Line 128 | Line 154 | char  *s;
154  
155  
156   void
157 < eputs(s)                                /* put string to stderr */
158 < register char  *s;
157 > eputs(                          /* put string to stderr */
158 >        register char  *s
159 > )
160   {
161          static int  inln = 0;
162  
# Line 143 | Line 170 | register char  *s;
170   }
171  
172  
173 < addface(cu, obj)                        /* add a face to a cube */
174 < register CUBE  *cu;
175 < OBJECT  obj;
173 > static void
174 > addface(                        /* add a face to a cube */
175 >        register CUBE  *cu,
176 >        OBJECT  obj
177 > )
178   {
179  
180          if (o_face(objptr(obj), cu) == O_MISS)
# Line 178 | Line 207 | OBJECT obj;
207   }
208  
209  
210 < add2full(cu, obj)                       /* add object to full node */
211 < register CUBE  *cu;
212 < OBJECT  obj;
210 > static void
211 > add2full(                       /* add object to full node */
212 >        register CUBE  *cu,
213 >        OBJECT  obj
214 > )
215   {
216          OCTREE  ot;
217          OBJECT  oset[MAXSET+1];
# Line 190 | Line 221 | OBJECT obj;
221          objset(oset, cu->cutree);
222          cukid.cusize = cu->cusize * 0.5;
223  
224 <        if (oset[0] < objlim || cukid.cusize < mincusize) {
224 >        if (oset[0] < objlim || cukid.cusize <
225 >                        (oset[0] < MAXSET ? mincusize : mincusize/256.0)) {
226                                                  /* add to set */
227                  if (oset[0] >= MAXSET) {
228                          sprintf(errmsg, "set overflow in addobject (%s)",

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines