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.11 by greg, Fri Jan 24 01:26:44 2014 UTC vs.
Revision 2.14 by greg, Wed Jun 11 00:08:30 2014 UTC

# Line 32 | Line 32 | static char    group[256];     /* current group name */
32   static int      lineno;         /* current line number */
33   static int      faceno;         /* current face number */
34  
35 < static int getstmt(char *av[MAXARG], FILE       *fp);
36 < static int cvtndx(VNDX  vi, char        *vs);
37 < static int putface(int  ac, char        **av);
35 > static int getstmt(char *av[MAXARG], FILE *fp);
36 > static int cvtndx(VNDX vi, char *vs);
37 > static int putface(int ac, char **av);
38   static OBJECT getmod(void);
39 < static int puttri(char  *v1, char       *v2, char       *v3);
39 > static int puttri(char  *v1, char *v2, char *v3);
40   static void freeverts(void);
41 < static int newv(double  x, double       y, double       z);
42 < static int newvn(double x, double       y, double       z);
43 < static int newvt(double x, double       y);
41 > static int newv(double  x, double y, double z);
42 > static int newvn(double x, double y, double z);
43 > static int newvt(double x, double y);
44   static void syntax(char *er);
45  
46  
# Line 249 | Line 249 | cvtndx(                                /* convert vertex string to index */
249   static int
250   dominant_axis(char *v1, char *v2, char *v3)
251   {
252 <        int     v1i = atoi(v1), v2i = atoi(v2), v3i = atoi(v3);
252 >        VNDX    v1i, v2i, v3i;
253          FVECT   e1, e2, vn;
254          int     i, imax;
255  
256 <        VSUB(e1, vlist[v2i], vlist[v1i]);
257 <        VSUB(e2, vlist[v3i], vlist[v2i]);
256 >        if (!cvtndx(v1i, v1) || !cvtndx(v2i, v2) || !cvtndx(v3i, v3))
257 >                return(-1);
258 >        VSUB(e1, vlist[v2i[0]], vlist[v1i[0]]);
259 >        VSUB(e2, vlist[v3i[0]], vlist[v2i[0]]);
260          VCROSS(vn, e1, e2);
261          for (i = imax = 2; i--; )
262                  if (vn[i]*vn[i] > vn[imax]*vn[imax])
263                          imax = i;
264 <        return(vn[imax]*vn[imax] > FTINY ? imax : -1);
264 >        return(vn[imax]*vn[imax] > FTINY*FTINY ? imax : -1);
265   }
266  
267   /* callback for triangle output from polygon */
# Line 287 | Line 289 | putface(                               /* put out an N-sided polygon */
289                  if ((ax = dominant_axis(av[i], av[i+1], av[i+2])) >= 0)
290                          break;
291          if (ax < 0)
292 <                return(0);
292 >                return(1);              /* ignore degenerate face */
293          if (++ax >= 3) ax = 0;
294          ay = ax;
295          if (++ay >= 3) ay = 0;
# Line 302 | Line 304 | putface(                               /* put out an N-sided polygon */
304                  poly->v[i].mY = vlist[vi[0]][ay];
305          }
306                                          /* break into triangles & output */
307 <        if (!polyTriangulate(poly, &tri_out))
308 <                return(0);
307 >        if (!polyTriangulate(poly, &tri_out)) {
308 >                sprintf(errmsg, "self-intersecting face with %d vertices", ac);
309 >                error(WARNING, errmsg);
310 >        }
311          polyFree(poly);
312          return(1);
313   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines