--- ray/src/cv/tmesh2rad.c 2003/03/04 01:42:29 2.11 +++ ray/src/cv/tmesh2rad.c 2003/11/15 17:54:06 2.15 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: tmesh2rad.c,v 2.11 2003/03/04 01:42:29 greg Exp $"; +static const char RCSid[] = "$Id: tmesh2rad.c,v 2.15 2003/11/15 17:54:06 schorsch Exp $"; #endif /* * Convert a trianglular mesh into a Radiance description. @@ -29,8 +29,11 @@ static const char RCSid[] = "$Id: tmesh2rad.c,v 2.11 2 * It is not necessary for the normal vectors to have unit length. */ -#include "standard.h" +#include +#include +#include "rtmath.h" + #include "tmesh.h" #define VOIDID "void" /* this is defined in object.h */ @@ -52,7 +55,7 @@ typedef struct { VERTEX *vlist = NULL; /* our vertex list */ int nverts = 0; /* number of vertices in our list */ -#define novert(i) ((i)<0|(i)>=nverts || !(vlist[i].flags&V_DEFINED)) +#define novert(i) (((i)<0)|((i)>=nverts) || !(vlist[i].flags&V_DEFINED)) #define CHUNKSIZ 128 /* vertex allocation chunk size */ @@ -62,10 +65,17 @@ char *defmat = VOIDID; /* default (starting) material char *defpat = ""; /* default (starting) picture name */ char *defobj = "T"; /* default (starting) object name */ +void convert(char *fname, FILE *fp); +void triangle(char *pn,char *mod,char *obj, VERTEX *v1,VERTEX *v2,VERTEX *v3); +VERTEX *vnew(int id, double x, double y, double z); +void syntax(char *fn, FILE *fp, char *er); -main(argc, argv) /* read in T-mesh files and convert */ -int argc; -char *argv[]; + +int +main( /* read in T-mesh files and convert */ + int argc, + char *argv[] +) { FILE *fp; int i; @@ -102,9 +112,11 @@ char *argv[]; } -convert(fname, fp) /* convert a T-mesh */ -char *fname; -FILE *fp; +void +convert( /* convert a T-mesh */ + char *fname, + FILE *fp +) { char typ[4]; int id[3]; @@ -195,15 +207,21 @@ FILE *fp; } -triangle(pn, mod, obj, v1, v2, v3) /* put out a triangle */ -char *pn, *mod, *obj; -register VERTEX *v1, *v2, *v3; +void +triangle( /* put out a triangle */ + char *pn, + char *mod, + char *obj, + register VERTEX *v1, + register VERTEX *v2, + register VERTEX *v3 +) { static char vfmt[] = "%18.12g %18.12g %18.12g\n"; static int ntri = 0; int flatness = ISFLAT; BARYCCM bvecs; - FLOAT bvm[3][3]; + RREAL bvm[3][3]; register int i; /* compute barycentric coordinates */ if (v1->flags & v2->flags & v3->flags & (V_HASINDX|V_HASNORM)) @@ -258,9 +276,12 @@ register VERTEX *v1, *v2, *v3; VERTEX * -vnew(id, x, y, z) /* create a new vertex */ -register int id; -double x, y, z; +vnew( /* create a new vertex */ + register int id, + double x, + double y, + double z +) { register int i; @@ -270,7 +291,7 @@ double x, y, z; if (vlist == NULL) vlist = (VERTEX *)malloc(nverts*sizeof(VERTEX)); else - vlist = (VERTEX *)realloc((char *)vlist, + vlist = (VERTEX *)realloc((void *)vlist, nverts*sizeof(VERTEX)); if (vlist == NULL) { fprintf(stderr, @@ -290,10 +311,12 @@ double x, y, z; } -syntax(fn, fp, er) /* report syntax error and exit */ -char *fn; -register FILE *fp; -char *er; +void +syntax( /* report syntax error and exit */ + char *fn, + register FILE *fp, + char *er +) { extern long ftell(); register long cpos;