--- ray/src/px/xshowtrace.c 2003/06/27 06:53:22 2.8 +++ ray/src/px/xshowtrace.c 2014/04/11 20:27:23 2.13 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: xshowtrace.c,v 2.8 2003/06/27 06:53:22 greg Exp $"; +static const char RCSid[] = "$Id: xshowtrace.c,v 2.13 2014/04/11 20:27:23 greg Exp $"; #endif /* * Display an image and watch the rays get traced. @@ -7,19 +7,17 @@ static const char RCSid[] = "$Id: xshowtrace.c,v 2.8 2 * 9/21/90 Greg Ward */ +#include + #include "standard.h" +#include "paths.h" #include "view.h" -#include #define MAXDEPTH 32 /* ridiculous ray tree depth */ -#ifdef SMLFLT -#define sscanvec(s,v) (sscanf(s,"%f %f %f",v,v+1,v+2)==3) -#else -#define sscanvec(s,v) (sscanf(s,"%lf %lf %lf",v,v+1,v+2)==3) -#endif +#define sscanvec(s,v) (sscanf(s,FVFORMAT,v,v+1,v+2)==3) -char rtcom[] = "rtrace -h- -otp -fa -x 1"; +char rtcom[64] = "rtrace -h- -otp -fa -x 1"; char xicom[] = "ximage -c 256"; VIEW ourview = STDVIEW; /* view for picture */ @@ -43,22 +41,33 @@ struct node { /* ray tree node */ int slow = 0; /* slow trace? */ +void mainloop(void); +static void freetree(struct node *tp); +static void tracerays(struct node *tp); +static int strtoipt(int ipt[2], char *str); +static void setvec(int ipt[2]); +static void vector(int ip1[2], int ip2[2]); -main(argc, argv) /* takes both the octree and the image */ -int argc; -char *argv[]; + +int +main( /* takes both the octree and the image */ + int argc, + char *argv[] +) { int i; - char combuf[256]; + char combuf[PATH_MAX]; progname = argv[0]; for (i = 1; i < argc-2; i++) if (!strcmp(argv[i], "-s")) slow++; + else if (!strcmp(argv[i], "-T")) + strcat(rtcom, " -oTp"); else break; if (i > argc-2) { - fprintf(stderr, "Usage: %s [-s] [rtrace args] octree picture\n", + fprintf(stderr, "Usage: %s [-s][-T] [rtrace args] octree picture\n", progname); exit(1); } @@ -78,7 +87,7 @@ char *argv[]; exit(1); } /* build input command */ - sprintf(combuf, "%s %s | %s", xicom, picture, rtcom); + sprintf(combuf, "%s \"%s\" | %s", xicom, picture, rtcom); for ( ; i < argc-1; i++) { strcat(combuf, " "); strcat(combuf, argv[i]); @@ -94,7 +103,8 @@ char *argv[]; } -mainloop() /* get and process input */ +void +mainloop(void) /* get and process input */ { static struct node *sis[MAXDEPTH]; register struct node *newp; @@ -133,8 +143,10 @@ mainloop() /* get and process input */ } -freetree(tp) /* free a trace tree */ -struct node *tp; +static void +freetree( /* free a trace tree */ + struct node *tp +) { register struct node *kid, *k2; @@ -146,8 +158,10 @@ struct node *tp; } -tracerays(tp) /* trace a ray tree */ -struct node *tp; +static void +tracerays( /* trace a ray tree */ + struct node *tp +) { register struct node *kid; @@ -158,9 +172,11 @@ struct node *tp; } -strtoipt(ipt, str) /* convert string x y z to image point */ -int ipt[2]; -char *str; +static int +strtoipt( /* convert string x y z to image point */ + int ipt[2], + char *str +) { FVECT im_pt, pt; @@ -184,8 +200,10 @@ Window gwind = 0; int xoff, yoff; -setvec(ipt) /* set up vector drawing for pick */ -int ipt[2]; +static void +setvec( /* set up vector drawing for pick */ + int ipt[2] +) { extern Window xfindwind(); XWindowAttributes wa; @@ -224,8 +242,11 @@ int ipt[2]; } -vector(ip1, ip2) /* draw a vector */ -int ip1[2], ip2[2]; +static void +vector( /* draw a vector */ + int ip1[2], + int ip2[2] +) { if (ip2[0] == -1 && ip2[1] == -1) return; /* null vector */