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

Comparing ray/src/ot/wfconv.c (file contents):
Revision 2.4 by greg, Wed Apr 23 00:52:34 2003 UTC vs.
Revision 2.8 by schorsch, Sat Mar 27 12:41:45 2004 UTC

# Line 21 | Line 21 | static FVECT   *vlist;         /* our vertex list */
21   static int      nvs;            /* number of vertices in our list */
22   static FVECT    *vnlist;        /* vertex normal list */
23   static int      nvns;
24 < static FLOAT    (*vtlist)[2];   /* map vertex list */
24 > static RREAL    (*vtlist)[2];   /* map vertex list */
25   static int      nvts;
26  
27   static char     *inpfile;       /* input file name */
# Line 31 | Line 31 | static char    group[64];      /* current group name */
31   static int      lineno;         /* current line number */
32   static int      faceno;         /* current face number */
33  
34 < static int      getstmt();
35 < static int      cvtndx();
36 < static OBJECT   getmod();
37 < static int      putface();
38 < static int      puttri();
39 < static void     freeverts();
40 < static int      newv();
41 < static int      newvn();
42 < static int      newvt();
43 < static void     syntax();
34 > static int getstmt(char *av[MAXARG], FILE       *fp);
35 > static int cvtndx(VNDX  vi, char        *vs);
36 > static int putface(int  ac, char        **av);
37 > static OBJECT getmod(void);
38 > static int puttri(char  *v1, char       *v2, char       *v3);
39 > static void freeverts(void);
40 > static int newv(double  x, double       y, double       z);
41 > static int newvn(double x, double       y, double       z);
42 > static int newvt(double x, double       y);
43 > static void syntax(char *er);
44  
45  
46   void
47 < wfreadobj(objfn)                /* read in .OBJ file and convert */
48 < char    *objfn;
47 > wfreadobj(              /* read in .OBJ file and convert */
48 >        char    *objfn
49 > )
50   {
51          FILE    *fp;
52          char    *argv[MAXARG];
53          int     argc;
54          int     nstats, nunknown;
54        int     i;
55  
56          if (objfn == NULL) {
57                  inpfile = "<stdin>";
# Line 66 | Line 66 | char   *objfn;
66          group[0] = '\0';
67          lineno = 0; faceno = 0;
68                                          /* scan until EOF */
69 <        while (argc = getstmt(argv, fp)) {
69 >        while ( (argc = getstmt(argv, fp)) ) {
70                  switch (argv[0][0]) {
71                  case 'v':               /* vertex */
72                          switch (argv[0][1]) {
# Line 157 | Line 157 | char   *objfn;
157  
158  
159   static int
160 < getstmt(av, fp)                         /* read the next statement from fp */
161 < register char   *av[MAXARG];
162 < FILE    *fp;
160 > getstmt(                                /* read the next statement from fp */
161 >        register char   *av[MAXARG],
162 >        FILE    *fp
163 > )
164   {
165          static char     sbuf[MAXARG*16];
166          register char   *cp;
# Line 190 | Line 191 | FILE   *fp;
191  
192  
193   static int
194 < cvtndx(vi, vs)                          /* convert vertex string to index */
195 < register VNDX   vi;
196 < register char   *vs;
194 > cvtndx(                         /* convert vertex string to index */
195 >        register VNDX   vi,
196 >        register char   *vs
197 > )
198   {
199                                          /* get point */
200          vi[0] = atoi(vs);
# Line 238 | Line 240 | register char  *vs;
240  
241  
242   static int
243 < putface(ac, av)                         /* put out an N-sided polygon */
244 < int     ac;
245 < register char   **av;
243 > putface(                                /* put out an N-sided polygon */
244 >        int     ac,
245 >        register char   **av
246 > )
247   {
248          char            *cp;
249          register int    i;
# Line 259 | Line 262 | register char  **av;
262  
263  
264   static OBJECT
265 < getmod()                                /* get current modifier ID */
265 > getmod(void)                            /* get current modifier ID */
266   {
267          char    *mnam;
268          OBJECT  mod;
# Line 285 | Line 288 | getmod()                               /* get current modifier ID */
288  
289  
290   static int
291 < puttri(v1, v2, v3)                      /* convert a triangle */
292 < char    *v1, *v2, *v3;
291 > puttri(                 /* convert a triangle */
292 >        char    *v1,
293 >        char    *v2,
294 >        char    *v3
295 > )
296   {
297          VNDX    v1i, v2i, v3i;
298 <        FLOAT   *v1c, *v2c, *v3c;
299 <        FLOAT   *v1n, *v2n, *v3n;
298 >        RREAL   *v1c, *v2c, *v3c;
299 >        RREAL   *v1n, *v2n, *v3n;
300          
301 <        if (!cvtndx(v1i, v1) || !cvtndx(v2i, v2) || !cvtndx(v3i, v3))
301 >        if (!cvtndx(v1i, v1) || !cvtndx(v2i, v2) || !cvtndx(v3i, v3)) {
302 >                error(WARNING, "bad vertex reference");
303                  return(0);
304 <
304 >        }
305          if (v1i[1]>=0 && v2i[1]>=0 && v3i[1]>=0) {
306                  v1c = vtlist[v1i[1]];
307                  v2c = vtlist[v2i[1]];
# Line 315 | Line 322 | char   *v1, *v2, *v3;
322  
323  
324   static void
325 < freeverts()                     /* free all vertices */
325 > freeverts(void)                 /* free all vertices */
326   {
327          if (nvs) {
328                  free((void *)vlist);
# Line 333 | Line 340 | freeverts()                    /* free all vertices */
340  
341  
342   static int
343 < newv(x, y, z)                   /* create a new vertex */
344 < double  x, y, z;
343 > newv(                   /* create a new vertex */
344 >        double  x,
345 >        double  y,
346 >        double  z
347 > )
348   {
349          if (!(nvs%CHUNKSIZ)) {          /* allocate next block */
350                  if (nvs == 0)
# Line 354 | Line 364 | double x, y, z;
364  
365  
366   static int
367 < newvn(x, y, z)                  /* create a new vertex normal */
368 < double  x, y, z;
367 > newvn(                  /* create a new vertex normal */
368 >        double  x,
369 >        double  y,
370 >        double  z
371 > )
372   {
373          if (!(nvns%CHUNKSIZ)) {         /* allocate next block */
374                  if (nvns == 0)
# Line 377 | Line 390 | double x, y, z;
390  
391  
392   static int
393 < newvt(x, y)                     /* create a new texture map vertex */
394 < double  x, y;
393 > newvt(                  /* create a new texture map vertex */
394 >        double  x,
395 >        double  y
396 > )
397   {
398          if (!(nvts%CHUNKSIZ)) {         /* allocate next block */
399                  if (nvts == 0)
400 <                        vtlist = (FLOAT (*)[2])malloc(CHUNKSIZ*2*sizeof(FLOAT));
400 >                        vtlist = (RREAL (*)[2])malloc(CHUNKSIZ*2*sizeof(RREAL));
401                  else
402 <                        vtlist = (FLOAT (*)[2])realloc((void *)vtlist,
403 <                                        (nvts+CHUNKSIZ)*2*sizeof(FLOAT));
402 >                        vtlist = (RREAL (*)[2])realloc((void *)vtlist,
403 >                                        (nvts+CHUNKSIZ)*2*sizeof(RREAL));
404                  if (vtlist == NULL)
405                          error(SYSTEM, "out of memory in newvt");
406          }
# Line 397 | Line 412 | double x, y;
412  
413  
414   static void
415 < syntax(er)                      /* report syntax error and exit */
416 < char    *er;
415 > syntax(                 /* report syntax error and exit */
416 >        char    *er
417 > )
418   {
419          sprintf(errmsg, "%s: Wavefront syntax error near line %d: %s\n",
420                          inpfile, lineno, er);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines