14 |
|
|
15 |
|
#include "platform.h" |
16 |
|
#include "rtio.h" |
17 |
– |
#include "rtprocess.h" |
17 |
|
#include "fvect.h" |
18 |
|
|
19 |
|
#ifdef M_PI |
22 |
|
#define PI 3.14159265358979323846 |
23 |
|
#endif |
24 |
|
|
26 |
– |
#define FEQ(a,b) ((a)-(b) <= 1e-7 && (b)-(a) <= 1e-7) |
27 |
– |
|
25 |
|
#define MAXVERT 6 /* maximum number of vertices for markers */ |
26 |
|
#define MAXMARK 128 /* maximum number of markers */ |
27 |
|
|
45 |
|
|
46 |
|
int expand; /* expand commands? */ |
47 |
|
|
51 |
– |
char *progname; |
52 |
– |
|
48 |
|
static void convert(char *name, FILE *fin); |
49 |
|
static void cvcomm(char *fname, FILE *fin); |
50 |
|
static void cvobject(char *fname, FILE *fin); |
63 |
|
FILE *fp; |
64 |
|
int i, j; |
65 |
|
|
66 |
< |
progname = argv[0]; |
66 |
> |
fixargv0(argv[0]); /* sets global progname */ |
67 |
|
i = 1; |
68 |
|
while (i < argc && argv[i][0] == '-') { |
69 |
|
do { |
136 |
|
void |
137 |
|
convert( /* replace marks in a stream */ |
138 |
|
char *name, |
139 |
< |
register FILE *fin |
139 |
> |
FILE *fin |
140 |
|
) |
141 |
|
{ |
142 |
< |
register int c; |
142 |
> |
int c; |
143 |
|
|
144 |
|
while ((c = getc(fin)) != EOF) { |
145 |
|
if (isspace(c)) /* blank */ |
169 |
|
) |
170 |
|
{ |
171 |
|
FILE *pin; |
172 |
< |
char buf[512], *fgetline(); |
172 |
> |
char buf[512]; |
173 |
|
|
174 |
|
fgetline(buf, sizeof(buf), fin); |
175 |
|
if (expand) { |
180 |
|
exit(1); |
181 |
|
} |
182 |
|
convert(buf, pin); |
183 |
< |
pclose(pin); |
183 |
> |
if (pclose(pin) != 0) |
184 |
> |
fprintf(stderr, |
185 |
> |
"%s: (%s): warning - bad status from \"%s\"\n", |
186 |
> |
progname, fname, buf); |
187 |
|
} else |
188 |
|
printf("\n%s\n", buf); |
189 |
|
} |
195 |
|
FILE *fin |
196 |
|
) |
197 |
|
{ |
200 |
– |
extern char *fgetword(); |
198 |
|
char buf[128], typ[16], nam[128]; |
199 |
|
int i, n; |
200 |
< |
register int j; |
200 |
> |
int j; |
201 |
|
|
202 |
|
if (fgetword(buf, sizeof(buf), fin) == NULL || |
203 |
|
fgetword(typ, sizeof(typ), fin) == NULL || |
242 |
|
void |
243 |
|
replace( /* replace marker */ |
244 |
|
char *fname, |
245 |
< |
register struct mrkr *m, |
245 |
> |
struct mrkr *m, |
246 |
|
char *mark, |
247 |
|
FILE *fin |
248 |
|
) |
296 |
|
|
297 |
|
int |
298 |
|
buildxf( /* build transform for marker */ |
299 |
< |
register char *xf, |
299 |
> |
char *xf, |
300 |
|
double markscale, |
301 |
|
FILE *fin |
302 |
|
) |
306 |
|
FVECT xvec, yvec, zvec; |
307 |
|
double xlen; |
308 |
|
int n; |
309 |
< |
register int i; |
309 |
> |
int i; |
310 |
|
/* |
311 |
|
* Read and sort vectors: longest is hypotenuse, |
312 |
|
* second longest is x' axis, |
379 |
|
|
380 |
|
int |
381 |
|
addrot( /* compute rotation (x,y,z) => (xp,yp,zp) */ |
382 |
< |
register char *xf, |
382 |
> |
char *xf, |
383 |
|
FVECT xp, |
384 |
|
FVECT yp, |
385 |
|
FVECT zp |
398 |
|
} |
399 |
|
n = 0; |
400 |
|
theta = atan2(yp[2], zp[2]); |
401 |
< |
if (!FEQ(theta,0.0)) { |
401 |
> |
if (!FABSEQ(theta,0.0)) { |
402 |
|
sprintf(xf, " -rx %f", theta*(180./PI)); |
403 |
|
while (*xf) ++xf; |
404 |
|
n += 2; |
405 |
|
} |
406 |
|
theta = Asin(-xp[2]); |
407 |
< |
if (!FEQ(theta,0.0)) { |
407 |
> |
if (!FABSEQ(theta,0.0)) { |
408 |
|
sprintf(xf, " -ry %f", theta*(180./PI)); |
409 |
|
while (*xf) ++xf; |
410 |
|
n += 2; |
411 |
|
} |
412 |
|
theta = atan2(xp[1], xp[0]); |
413 |
< |
if (!FEQ(theta,0.0)) { |
413 |
> |
if (!FABSEQ(theta,0.0)) { |
414 |
|
sprintf(xf, " -rz %f", theta*(180./PI)); |
415 |
|
/* while (*xf) ++xf; */ |
416 |
|
n += 2; |