17 |
|
|
18 |
|
#include "standard.h" |
19 |
|
|
20 |
+ |
#include "paths.h" |
21 |
+ |
#include "resolu.h" |
22 |
+ |
#include "rterror.h" |
23 |
+ |
#include "calcomp.h" |
24 |
+ |
|
25 |
|
char XNAME[] = "X`SYS"; /* x function name */ |
26 |
|
char YNAME[] = "Y`SYS"; /* y function name */ |
27 |
|
char ZNAME[] = "Z`SYS"; /* z function name */ |
34 |
|
|
35 |
|
#define pvect(p) printf(vformat, (p)[0], (p)[1], (p)[2]) |
36 |
|
|
37 |
< |
char vformat[] = "%15.9g %15.9g %15.9g\n"; |
38 |
< |
char tsargs[] = "4 surf_dx surf_dy surf_dz surf.cal\n"; |
37 |
> |
char vformat[] = "%18.12g %18.12g %18.12g\n"; |
38 |
> |
char tsargs[] = "4 surf_dx surf_dy surf_dz surf.cal"; |
39 |
|
char texname[] = "Phong"; |
40 |
|
|
41 |
|
int smooth = 0; /* apply smoothing? */ |
53 |
|
RREAL *data; /* the data itself, s major sort */ |
54 |
|
} datarec; /* our recorded data */ |
55 |
|
|
56 |
+ |
/* XXX this is redundant with rt/noise3.c, should go to a library */ |
57 |
|
double l_hermite(), l_bezier(), l_bspline(), l_dataval(); |
52 |
– |
extern double funvalue(), argument(); |
58 |
|
|
59 |
|
typedef struct { |
60 |
|
int valid; /* point is valid (vertex number) */ |
64 |
|
} POINT; |
65 |
|
|
66 |
|
|
67 |
+ |
void loaddata(char *file, int m, int n, int pointsize); |
68 |
+ |
double l_dataval(char *nam); |
69 |
+ |
void putobjrow(POINT *rp, int n); |
70 |
+ |
void putsquare(POINT *p0, POINT *p1, POINT *p2, POINT *p3); |
71 |
+ |
void comprow(double s, POINT *row, int siz); |
72 |
+ |
void compnorms(POINT *r0, POINT *r1, POINT *r2, int siz); |
73 |
+ |
int norminterp(FVECT resmat[4], POINT *p0, POINT *p1, POINT *p2, POINT *p3); |
74 |
+ |
|
75 |
+ |
|
76 |
+ |
int |
77 |
|
main(argc, argv) |
78 |
|
int argc; |
79 |
|
char *argv[]; |
80 |
|
{ |
66 |
– |
extern long eclock; |
81 |
|
POINT *row0, *row1, *row2, *rp; |
82 |
|
int i, j, m, n; |
83 |
|
char stmp[256]; |
138 |
|
} |
139 |
|
row0++; row1++; row2++; |
140 |
|
/* print header */ |
141 |
< |
printhead(argc, argv); |
141 |
> |
fputs("# ", stdout); |
142 |
> |
printargs(argc, argv, stdout); |
143 |
|
eclock = 0; |
144 |
|
/* initialize */ |
145 |
|
comprow(-1.0/m, row0, n); |
178 |
|
} |
179 |
|
} |
180 |
|
|
181 |
< |
quit(0); |
181 |
> |
return 0; |
182 |
|
|
183 |
|
userror: |
184 |
|
fprintf(stderr, "Usage: %s material name ", argv[0]); |
185 |
< |
fprintf(stderr, "x(s,t) y(s,t) z(s,t) m n [-s][-e expr][-f file]\n"); |
186 |
< |
quit(1); |
185 |
> |
fprintf(stderr, "x(s,t) y(s,t) z(s,t) m n [-s][-o][-e expr][-f file]\n"); |
186 |
> |
return 1; |
187 |
|
} |
188 |
|
|
189 |
|
|
190 |
< |
loaddata(file, m, n, pointsize) /* load point data from file */ |
191 |
< |
char *file; |
192 |
< |
int m, n; |
193 |
< |
int pointsize; |
190 |
> |
void |
191 |
> |
loaddata( /* load point data from file */ |
192 |
> |
char *file, |
193 |
> |
int m, |
194 |
> |
int n, |
195 |
> |
int pointsize |
196 |
> |
) |
197 |
|
{ |
198 |
|
FILE *fp; |
199 |
|
char word[64]; |
229 |
|
size--; |
230 |
|
} |
231 |
|
if (size == (m+n+1)*pointsize) { /* no border after all */ |
232 |
< |
dp = (RREAL *)realloc((void *)datarec.data, |
232 |
> |
dp = (RREAL *)realloc(datarec.data, |
233 |
|
m*n*pointsize*sizeof(RREAL)); |
234 |
|
if (dp != NULL) |
235 |
|
datarec.data = dp; |
249 |
|
|
250 |
|
|
251 |
|
double |
252 |
< |
l_dataval(nam) /* return recorded data value */ |
253 |
< |
char *nam; |
252 |
> |
l_dataval( /* return recorded data value */ |
253 |
> |
char *nam |
254 |
> |
) |
255 |
|
{ |
256 |
|
double u, v; |
257 |
|
register int i, j; |
291 |
|
} |
292 |
|
|
293 |
|
|
294 |
< |
putobjrow(rp, n) /* output vertex row to .OBJ */ |
295 |
< |
register POINT *rp; |
296 |
< |
int n; |
294 |
> |
void |
295 |
> |
putobjrow( /* output vertex row to .OBJ */ |
296 |
> |
register POINT *rp, |
297 |
> |
int n |
298 |
> |
) |
299 |
|
{ |
300 |
|
static int nverts = 0; |
301 |
|
|
313 |
|
} |
314 |
|
|
315 |
|
|
316 |
< |
putsquare(p0, p1, p2, p3) /* put out a square */ |
317 |
< |
POINT *p0, *p1, *p2, *p3; |
316 |
> |
void |
317 |
> |
putsquare( /* put out a square */ |
318 |
> |
POINT *p0, |
319 |
> |
POINT *p1, |
320 |
> |
POINT *p2, |
321 |
> |
POINT *p3 |
322 |
> |
) |
323 |
|
{ |
324 |
|
static int nout = 0; |
325 |
|
FVECT norm[4]; |
382 |
|
if (ok1 & ok2 && fdot(vc1,vc2) >= 1.0-FTINY*FTINY) { |
383 |
|
printf("\n%s ", modname); |
384 |
|
if (axis != -1) { |
385 |
< |
printf("texfunc %s\n", texname); |
360 |
< |
printf(tsargs); |
385 |
> |
printf("texfunc %s\n%s\n", texname, tsargs); |
386 |
|
printf("0\n13\t%d\n", axis); |
387 |
|
pvect(norm[0]); |
388 |
|
pvect(norm[1]); |
404 |
|
if (ok1) { |
405 |
|
printf("\n%s ", modname); |
406 |
|
if (axis != -1) { |
407 |
< |
printf("texfunc %s\n", texname); |
383 |
< |
printf(tsargs); |
407 |
> |
printf("texfunc %s\n%s\n", texname, tsargs); |
408 |
|
printf("0\n13\t%d\n", axis); |
409 |
|
pvect(norm[0]); |
410 |
|
pvect(norm[1]); |
422 |
|
if (ok2) { |
423 |
|
printf("\n%s ", modname); |
424 |
|
if (axis != -1) { |
425 |
< |
printf("texfunc %s\n", texname); |
402 |
< |
printf(tsargs); |
425 |
> |
printf("texfunc %s\n%s\n", texname, tsargs); |
426 |
|
printf("0\n13\t%d\n", axis); |
427 |
|
pvect(norm[0]); |
428 |
|
pvect(norm[1]); |
440 |
|
} |
441 |
|
|
442 |
|
|
443 |
< |
comprow(s, row, siz) /* compute row of values */ |
444 |
< |
double s; |
445 |
< |
register POINT *row; |
446 |
< |
int siz; |
443 |
> |
void |
444 |
> |
comprow( /* compute row of values */ |
445 |
> |
double s, |
446 |
> |
register POINT *row, |
447 |
> |
int siz |
448 |
> |
) |
449 |
|
{ |
450 |
|
double st[2]; |
451 |
|
int end; |
482 |
|
} |
483 |
|
|
484 |
|
|
485 |
< |
compnorms(r0, r1, r2, siz) /* compute row of averaged normals */ |
486 |
< |
register POINT *r0, *r1, *r2; |
487 |
< |
int siz; |
485 |
> |
void |
486 |
> |
compnorms( /* compute row of averaged normals */ |
487 |
> |
register POINT *r0, |
488 |
> |
register POINT *r1, |
489 |
> |
register POINT *r2, |
490 |
> |
int siz |
491 |
> |
) |
492 |
|
{ |
493 |
|
FVECT v1, v2; |
494 |
|
|
526 |
|
|
527 |
|
|
528 |
|
int |
529 |
< |
norminterp(resmat, p0, p1, p2, p3) /* compute normal interpolation */ |
530 |
< |
register FVECT resmat[4]; |
531 |
< |
POINT *p0, *p1, *p2, *p3; |
529 |
> |
norminterp( /* compute normal interpolation */ |
530 |
> |
register FVECT resmat[4], |
531 |
> |
POINT *p0, |
532 |
> |
POINT *p1, |
533 |
> |
POINT *p2, |
534 |
> |
POINT *p3 |
535 |
> |
) |
536 |
|
{ |
537 |
|
#define u ((ax+1)%3) |
538 |
|
#define v ((ax+2)%3) |
582 |
|
|
583 |
|
#undef u |
584 |
|
#undef v |
552 |
– |
} |
553 |
– |
|
554 |
– |
|
555 |
– |
void |
556 |
– |
eputs(msg) |
557 |
– |
char *msg; |
558 |
– |
{ |
559 |
– |
fputs(msg, stderr); |
560 |
– |
} |
561 |
– |
|
562 |
– |
|
563 |
– |
void |
564 |
– |
wputs(msg) |
565 |
– |
char *msg; |
566 |
– |
{ |
567 |
– |
eputs(msg); |
568 |
– |
} |
569 |
– |
|
570 |
– |
|
571 |
– |
void |
572 |
– |
quit(code) |
573 |
– |
int code; |
574 |
– |
{ |
575 |
– |
exit(code); |
576 |
– |
} |
577 |
– |
|
578 |
– |
|
579 |
– |
printhead(ac, av) /* print command header */ |
580 |
– |
register int ac; |
581 |
– |
register char **av; |
582 |
– |
{ |
583 |
– |
putchar('#'); |
584 |
– |
while (ac--) { |
585 |
– |
putchar(' '); |
586 |
– |
fputs(*av++, stdout); |
587 |
– |
} |
588 |
– |
putchar('\n'); |
585 |
|
} |
586 |
|
|
587 |
|
|