7 |
|
* 9/21/90 Greg Ward |
8 |
|
*/ |
9 |
|
|
10 |
+ |
#include <X11/Xlib.h> |
11 |
+ |
|
12 |
|
#include "standard.h" |
13 |
+ |
#include "paths.h" |
14 |
|
#include "view.h" |
12 |
– |
#include <X11/Xlib.h> |
15 |
|
|
16 |
|
#define MAXDEPTH 32 /* ridiculous ray tree depth */ |
17 |
|
|
18 |
< |
#ifdef SMLFLT |
17 |
< |
#define sscanvec(s,v) (sscanf(s,"%f %f %f",v,v+1,v+2)==3) |
18 |
< |
#else |
19 |
< |
#define sscanvec(s,v) (sscanf(s,"%lf %lf %lf",v,v+1,v+2)==3) |
20 |
< |
#endif |
18 |
> |
#define sscanvec(s,v) (sscanf(s,FVFORMAT,v,v+1,v+2)==3) |
19 |
|
|
20 |
< |
char rtcom[] = "rtrace -h- -otp -fa -x 1"; |
20 |
> |
char rtcom[64] = "rtrace -h- -otp -fa -x 1"; |
21 |
|
char xicom[] = "ximage -c 256"; |
22 |
|
|
23 |
|
VIEW ourview = STDVIEW; /* view for picture */ |
24 |
|
RESOLU ourres; /* picture resolution */ |
25 |
|
|
28 |
– |
char *progname; /* program name */ |
29 |
– |
|
26 |
|
char *picture; /* picture name */ |
27 |
|
|
28 |
|
FILE *pin; /* input stream */ |
39 |
|
|
40 |
|
int slow = 0; /* slow trace? */ |
41 |
|
|
42 |
+ |
void mainloop(void); |
43 |
+ |
static void freetree(struct node *tp); |
44 |
+ |
static void tracerays(struct node *tp); |
45 |
+ |
static int strtoipt(int ipt[2], char *str); |
46 |
+ |
static void setvec(int ipt[2]); |
47 |
+ |
static void vector(int ip1[2], int ip2[2]); |
48 |
|
|
49 |
< |
main(argc, argv) /* takes both the octree and the image */ |
50 |
< |
int argc; |
51 |
< |
char *argv[]; |
49 |
> |
|
50 |
> |
int |
51 |
> |
main( /* takes both the octree and the image */ |
52 |
> |
int argc, |
53 |
> |
char *argv[] |
54 |
> |
) |
55 |
|
{ |
56 |
|
int i; |
57 |
< |
char combuf[256]; |
57 |
> |
char combuf[PATH_MAX]; |
58 |
|
|
59 |
< |
progname = argv[0]; |
59 |
> |
fixargv0(argv[0]); /* sets global progname */ |
60 |
|
for (i = 1; i < argc-2; i++) |
61 |
|
if (!strcmp(argv[i], "-s")) |
62 |
|
slow++; |
63 |
+ |
else if (!strcmp(argv[i], "-T")) |
64 |
+ |
strcat(rtcom, " -oTp"); |
65 |
|
else |
66 |
|
break; |
67 |
|
if (i > argc-2) { |
68 |
< |
fprintf(stderr, "Usage: %s [-s] [rtrace args] octree picture\n", |
68 |
> |
fprintf(stderr, "Usage: %s [-s][-T] [rtrace args] octree picture\n", |
69 |
|
progname); |
70 |
|
exit(1); |
71 |
|
} |
85 |
|
exit(1); |
86 |
|
} |
87 |
|
/* build input command */ |
88 |
< |
sprintf(combuf, "%s %s | %s", xicom, picture, rtcom); |
88 |
> |
sprintf(combuf, "%s \"%s\" | %s", xicom, picture, rtcom); |
89 |
|
for ( ; i < argc-1; i++) { |
90 |
|
strcat(combuf, " "); |
91 |
|
strcat(combuf, argv[i]); |
101 |
|
} |
102 |
|
|
103 |
|
|
104 |
< |
mainloop() /* get and process input */ |
104 |
> |
void |
105 |
> |
mainloop(void) /* get and process input */ |
106 |
|
{ |
107 |
|
static struct node *sis[MAXDEPTH]; |
108 |
|
register struct node *newp; |
141 |
|
} |
142 |
|
|
143 |
|
|
144 |
< |
freetree(tp) /* free a trace tree */ |
145 |
< |
struct node *tp; |
144 |
> |
static void |
145 |
> |
freetree( /* free a trace tree */ |
146 |
> |
struct node *tp |
147 |
> |
) |
148 |
|
{ |
149 |
< |
register struct node *kid; |
149 |
> |
register struct node *kid, *k2; |
150 |
|
|
151 |
< |
for (kid = tp->daughter; kid != NULL; kid = kid->sister) |
151 |
> |
for (kid = tp->daughter; kid != NULL; kid = k2) { |
152 |
> |
k2 = kid->sister; |
153 |
|
freetree(kid); |
154 |
+ |
} |
155 |
|
free((void *)tp); |
156 |
|
} |
157 |
|
|
158 |
|
|
159 |
< |
tracerays(tp) /* trace a ray tree */ |
160 |
< |
struct node *tp; |
159 |
> |
static void |
160 |
> |
tracerays( /* trace a ray tree */ |
161 |
> |
struct node *tp |
162 |
> |
) |
163 |
|
{ |
164 |
|
register struct node *kid; |
165 |
|
|
170 |
|
} |
171 |
|
|
172 |
|
|
173 |
< |
strtoipt(ipt, str) /* convert string x y z to image point */ |
174 |
< |
int ipt[2]; |
175 |
< |
char *str; |
173 |
> |
static int |
174 |
> |
strtoipt( /* convert string x y z to image point */ |
175 |
> |
int ipt[2], |
176 |
> |
char *str |
177 |
> |
) |
178 |
|
{ |
179 |
|
FVECT im_pt, pt; |
180 |
|
|
198 |
|
int xoff, yoff; |
199 |
|
|
200 |
|
|
201 |
< |
setvec(ipt) /* set up vector drawing for pick */ |
202 |
< |
int ipt[2]; |
201 |
> |
static void |
202 |
> |
setvec( /* set up vector drawing for pick */ |
203 |
> |
int ipt[2] |
204 |
> |
) |
205 |
|
{ |
206 |
|
extern Window xfindwind(); |
207 |
|
XWindowAttributes wa; |
240 |
|
} |
241 |
|
|
242 |
|
|
243 |
< |
vector(ip1, ip2) /* draw a vector */ |
244 |
< |
int ip1[2], ip2[2]; |
243 |
> |
static void |
244 |
> |
vector( /* draw a vector */ |
245 |
> |
int ip1[2], |
246 |
> |
int ip2[2] |
247 |
> |
) |
248 |
|
{ |
249 |
|
if (ip2[0] == -1 && ip2[1] == -1) |
250 |
|
return; /* null vector */ |