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

Comparing ray/src/cv/mgflib/parser.c (file contents):
Revision 1.23 by greg, Wed Jun 19 22:34:59 1996 UTC vs.
Revision 1.26 by gregl, Mon Dec 15 09:41:37 1997 UTC

# Line 10 | Line 10 | static char SCCSid[] = "$SunId$ LBL";
10  
11   #include <stdio.h>
12   #include <math.h>
13 + #include <stdlib.h>
14   #include <ctype.h>
15   #include <string.h>
16   #include "parser.h"
# Line 67 | Line 68 | static int     e_any_toss(),           /* discard unneeded entity *
68                  e_cmix(),               /* color mixtures */
69                  e_cspec();              /* color spectra */
70  
70 int             e_include(),            /* include file */
71                e_sph(),                /* sphere */
72                e_cyl(),                /* cylinder */
73                e_cone(),               /* cone */
74                e_prism(),              /* prism */
75                e_ring(),               /* ring */
76                e_torus();              /* torus */
77
71                                  /* alternate handler support functions */
72  
73   static int      (*e_supp[MG_NENTITIES])();
# Line 124 | Line 117 | mg_init()                      /* initialize alternate entity handlers */
117                  ineed |= 1L<<MG_E_POINT|1L<<MG_E_NORMAL|1L<<MG_E_VERTEX;
118          } else
119                  uneed |= 1L<<MG_E_POINT|1L<<MG_E_NORMAL|1L<<MG_E_VERTEX|1L<<MG_E_XF;
120 +        if (mg_ehand[MG_E_FACE] == NULL)
121 +                mg_ehand[MG_E_FACE] = mg_ehand[MG_E_FACEH];
122 +        else if (mg_ehand[MG_E_FACEH] == NULL)
123 +                mg_ehand[MG_E_FACEH] = e_faceh;
124          if (mg_ehand[MG_E_COLOR] != NULL) {
125                  if (mg_ehand[MG_E_CMIX] == NULL) {
126                          mg_ehand[MG_E_CMIX] = e_cmix;
# Line 270 | Line 267 | void
267   mg_fgetpos(pos)                 /* get current position in input file */
268   register MG_FPOS        *pos;
269   {
273        extern long     ftell();
274
270          pos->fid = mg_file->fid;
271          pos->lineno = mg_file->lineno;
272          pos->offset = ftell(mg_file->fp);
# Line 319 | Line 314 | mg_parse()                     /* parse current input line */
314   {
315          char    abuf[MG_MAXLINE];
316          char    *argv[MG_MAXARGC];
322        int     en;
317          register char   *cp, *cp2, **ap;
318                                          /* copy line, removing escape chars */
319          cp = abuf; cp2 = mg_file->inpline;
# Line 464 | Line 458 | char   **av;
458   }
459  
460  
461 + int
462 + e_faceh(ac, av)                 /* replace face+holes with single contour */
463 + int     ac;
464 + char    **av;
465 + {
466 +        char    *newav[MG_MAXARGC];
467 +        int     lastp = 0;
468 +        register int    i, j;
469 +
470 +        newav[0] = mg_ename[MG_E_FACE];
471 +        for (i = 1; i < ac; i++)
472 +                if (av[i][0] == '-') {
473 +                        if (i < 4)
474 +                                return(MG_EARGC);
475 +                        if (i >= ac-1)
476 +                                break;
477 +                        if (!lastp)
478 +                                lastp = i-1;
479 +                        for (j = i+1; j < ac-1 && av[j+1][0] != '-'; j++)
480 +                                ;
481 +                        if (j - i < 3)
482 +                                return(MG_EARGC);
483 +                        newav[i] = av[j];       /* connect hole loop */
484 +                } else
485 +                        newav[i] = av[i];       /* hole or perimeter vertex */
486 +        if (lastp)
487 +                newav[i++] = av[lastp];         /* finish seam to outside */
488 +        newav[i] = NULL;
489 +        return(mg_handle(MG_E_FACE, i, newav));
490 + }
491 +
492 +
493   static void
494   make_axes(u, v, w)              /* compute u and v given w (normalized) */
495   FVECT   u, v, w;
# Line 782 | Line 808 | char   **av;
808                  if (rad2 == 0.)
809                          return(MG_EILL);
810          } else if (rad2 != 0.) {
811 <                if (rad1 < 0. ^ rad2 < 0.)
811 >                if ((rad1 < 0.) ^ (rad2 < 0.))
812                          return(MG_EILL);
813          } else {                        /* swap */
814                  C_VERTEX        *cv;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines