# To unbundle, sh this file echo A.scene 1>&2 cat >A.scene <<'End of A.scene' End of A.scene echo Makefile 1>&2 cat >Makefile <<'End of Makefile' O_FILES = extrude.o CFLAGS = CC = cc extrude: $(O_FILES) $(CC) $(CFLAGS) -o extrude $(O_FILES) -lm End of Makefile echo Test 1>&2 cat >Test <<'End of Test' # # ~abs/swdev/X/lineDraw/lineDraw -v -z 500 > testv.vect ~abs/swdev/vect/vect_to_geom < testv.vect > testv.geom # extrude -z -1000 < testv.vect > testp.polyh /usr/avs/bin/polyh_to_geom < testp.polyh > testp.geom # extrude -z -1000 -c -s < testv.vect > testc.polyhc ~abs/swdev/polyhc/polyhc_to_geom < testc.polyhc > testc.geom # avs -data $cwd -geometry -scene A.scr End of Test echo Test2 1>&2 cat >Test2 <<'End of Test2' End of Test2 echo extrude.c 1>&2 cat >extrude.c <<'End of extrude.c' /** ** extrude - etrude a vect file into a polyh file ** ** CREATED: 92.04.01 ABS copied from xf ** **/ #include "extrude.h" main(argc, argv) int argc; char** argv; { /* declare functions */ double atof(); /* declare local variables */ char input_line[MAX_LINE]; int v, i; int numVects; float vertsOld[2][3]; float vertsNew[2][3]; float colorsOld[2][3]; float colorsNew[2][3]; /* initialize global variables (including parameters) */ defaultParms(); parseArgs(argc, argv); /* initialize local variables */ colorsOld[0][0] = 1.0; /* old = red */ colorsOld[0][1] = 0.0; colorsOld[0][2] = 0.0; colorsOld[1][0] = 1.0; /* old = red */ colorsOld[1][1] = 0.0; colorsOld[1][2] = 0.0; colorsNew[0][0] = 0.0; /* new = green */ colorsNew[0][1] = 1.0; colorsNew[0][2] = 0.0; colorsNew[1][0] = 0.0; /* new = green */ colorsNew[1][1] = 1.0; colorsNew[1][2] = 0.0; /* read number of vectors from vect file */ fscanf(stdin, "%d", &numVects); /* write number of vertices to polyh file */ if (Smooth != FALSE) { fprintf(stdout, "smooth\n"); } else { fprintf(stdout, "facet\n"); } fprintf(stdout, "%d\n", numVects*4); /* read & write */ for (v = 0; v < numVects; v++) { /* read vecor vertices */ fscanf(stdin, "%f%f%f%f%f%f", &vertsOld[0][0], &vertsOld[0][1], &vertsOld[0][2], &vertsOld[1][0], &vertsOld[1][1], &vertsOld[1][2]); /* extrude */ for (i = 0; i < 2; i++) { vertsNew[i][0] = vertsOld[i][0]; vertsNew[i][1] = vertsOld[i][1]; vertsNew[i][2] = vertsOld[i][2] + ZDistance; } if (Debug != FALSE) { fprintf(stderr, "%s: DEBUG: old: (x,y,z) (x,y,z) = (%f, %f, %f) (%f, %f, %f)\n", argv[0], vertsOld[0][0], vertsOld[0][1], vertsOld[0][2], vertsOld[1][0], vertsOld[1][1], vertsOld[1][2]); fprintf(stderr, "%s: DEBUG: new: (x,y,z) (x,y,z) = (%f, %f, %f) (%f, %f, %f)\n", argv[0], vertsNew[0][0], vertsNew[0][1], vertsNew[0][2], vertsNew[1][0], vertsNew[1][1], vertsNew[1][2]); } /* write polygon vertices */ if (Colors != FALSE) { fprintf(stdout, "%f %f %f %f %f %f\n", vertsOld[0][0], vertsOld[0][1], vertsOld[0][2], colorsOld[0][0], colorsOld[0][1], colorsOld[0][2]); fprintf(stdout, "%f %f %f %f %f %f\n", vertsOld[1][0], vertsOld[1][1], vertsOld[1][2], colorsOld[1][0], colorsOld[1][1], colorsOld[1][2]); fprintf(stdout, "%f %f %f %f %f %f\n", vertsNew[0][0], vertsNew[0][1], vertsNew[0][2], colorsNew[0][0], colorsNew[0][1], colorsNew[0][2]); fprintf(stdout, "%f %f %f %f %f %f\n", vertsNew[1][0], vertsNew[1][1], vertsNew[1][2], colorsNew[1][0], colorsNew[1][1], colorsNew[1][2]); } else { fprintf(stdout, "%f %f %f\n%f %f %f\n", vertsOld[0][0], vertsOld[0][1], vertsOld[0][2], vertsOld[1][0], vertsOld[1][1], vertsOld[1][2]); fprintf(stdout, "%f %f %f\n%f %f %f\n", vertsNew[0][0], vertsNew[0][1], vertsNew[0][2], vertsNew[1][0], vertsNew[1][1], vertsNew[1][2]); } } /* polygon connectivity */ for (v = 0; v < numVects; v++) { fprintf(stdout, "4\n"); fprintf(stdout, "%d %d %d %d\n", v*4 + 1, v*4 + 3, v*4 + 4, v*4 + 2); } } /* end main */ /* * defaultParms - initialize global variables */ defaultParms() { Debug = FALSE; Colors = FALSE; Smooth = FALSE; ZDistance = 100.0; } /* end defaultParms() */ /* * parseArgs - parse arguments into global variables */ parseArgs(arg_c, arg_v) int arg_c; char** arg_v; { int i; for (i = 0; i < arg_c; i++) { if (arg_v[i][0] == '-') { switch (arg_v[i][1]) { case 'D' : Debug = TRUE; break; case 'c' : Colors = TRUE; break; case 'h' : help(arg_v); exit(0); break; case 's' : Smooth = TRUE; break; case 'u' : usage(arg_v); exit(0); break; case 'z' : ZDistance = atof(&arg_v[++i][0]); break; default: fprintf(stderr, "%s: ERROR: illegal flag: %s\n", arg_v[0], arg_v[i]); usage(arg_v); exit(0); break; } /* end switch */ } /* end if */ } /* end for(i) */ } /* end parseArgs() */ /* * getline - from Kernighan & Ritchie */ int getline(s, lim) /* get line into s, return length */ char s[]; int lim; { int c, i; i = 0; while (--lim > 0 && (c = getchar()) != EOF && c != '\n') s[i++] = c; if (c == '\n') s[i++] = c; s[i] = '\0'; return(i); } /* end getline() */ /* * getl - modified from Kernighan & Ritchie to take stream */ int getl(stream, s, lim) /* get line into s, return length */ FILE *stream; char s[]; int lim; { int c, i; i = 0; while (--lim > 0 && (c = getc(stream)) != EOF && c != '\n') s[i++] = c; if (c == '\n') s[i++] = c; s[i] = '\0'; return(i); } /* end getl() */ /* * help - give program help */ help(arg_v) char** arg_v; { fprintf(stderr, "%s: HELP:\n", arg_v[0]); fprintf(stderr, "\n"); fprintf(stderr, " extrude - extrude a .vect file into a .polyh or .polych file\n"); fprintf(stderr, "\n"); fprintf(stderr, " This program reads a .vect file from standard in\n"); fprintf(stderr, " and writes a .polyh (or .polyhc if -c used) file\n"); fprintf(stderr, " to standard out, representing the extrusion of \n"); fprintf(stderr, " the vectors in the Z dimension. \n"); fprintf(stderr, "\n"); } /* end of help */ /* * usage - give program usage */ usage(arg_v) char** arg_v; { fprintf(stderr, "%s: USAGE: %s []\n", arg_v[0], arg_v[0]); fprintf(stderr, "\n"); fprintf(stderr, " flag meaning default\n"); fprintf(stderr, " ------------- ---------------------- -------\n"); fprintf(stderr, " -D debug FALSE \n"); fprintf(stderr, " -c colors too (polyhc) FALSE \n"); fprintf(stderr, " -h help on this program \n"); fprintf(stderr, " -s smooth shade polygons facet \n"); fprintf(stderr, " -u usage (this message) \n"); fprintf(stderr, " -z Z distance to extrude 100.0 \n"); fprintf(stderr, "\n"); } /* end of usage */ End of extrude.c echo extrude.h 1>&2 cat >extrude.h <<'End of extrude.h' /* * xf.h -- include file for xf.c */ /* includes */ #include #include #include /* constants */ #define TRUE (1) #define FALSE (0) #define MAX_LINE (255) #define MAX_VERTS (255) /* global variables */ /* flag-settable parameters (global variables) */ int Debug; /* Boolean: TRUE = debug writes */ int Colors; /* Boolean: TRUE = colors too (polyhc) */ int Smooth; /* Boolean: TRUE = smooth shade (else facet) */ float ZDistance; /* float: distance in Z */ End of extrude.h