/* * pleat - * laser score and cut a folded pleated surface * * To compile: cc pleat.c -o pleat -lgl -lm To run pleat pleat.dxf * * Paul Haeberli - 1996 */ #include "stdio.h" #include "math.h" #include "gl.h" #include "device.h" #define SCORE 0 #define CUT1 1 #define CUT2 2 #define PAGEXSIZE (36.0) #define PAGEYSIZE (24.0) FILE *outf; float geom[2000][2]; int nvert; float xmin, xmax, ymin, ymax; main(argc,argv) int argc; char **argv; { int xsize, ysize; if(argc<2) { fprintf(stderr,"usage: pleat pleat.dxf\n"); exit(1); } xsize = 900; ysize = (PAGEYSIZE*xsize)/PAGEXSIZE; prefsize(xsize,ysize); winopen("laser"); RGBmode(); gconfig(); ortho2(-0.1,PAGEXSIZE+0.1,-0.1,PAGEYSIZE); scale(1.0,1.0,1.0); dxf_begin(argv[1]); project_pleat(); dxf_end(); sleep(5); /* can be deleted */ } #define XSPACE (1.4) #define YSIZE (8.5) #define NSECTIONS (24) project_pleat() { putzigzag(XSPACE,YSIZE,NSECTIONS); putdiag(XSPACE, 1.9, 3.4,NSECTIONS); putdiag(XSPACE, 2.5, 4.0,NSECTIONS); putdiag(XSPACE,YSIZE-2.5,YSIZE-4.0,NSECTIONS); putdiag(XSPACE,YSIZE-1.9,YSIZE-3.4,NSECTIONS); cutrect(0.0,XSPACE*NSECTIONS,0.0,YSIZE); } putzigzag(xspace,ysize,n) float xspace, ysize; int n; { int i; for(i=1; ix) xmin = x; if(xmaxy) ymin = y; if(ymax2 && (coords[0][0] == coords[n-1][0]) && (coords[0][1] == coords[n-1][1]) ) { closed = 1; n--; } else closed = 0; fprintf(outf," 0\n"); fprintf(outf,"POLYLINE\n"); printlayer(layer); fprintf(outf," 66\n"); fprintf(outf," 1\n"); fprintf(outf," 10\n"); fprintf(outf,"0.0\n"); fprintf(outf," 20\n"); fprintf(outf,"0.0\n"); fprintf(outf," 70\n"); if(closed) fprintf(outf," 1\n"); else fprintf(outf," 0\n"); for(i=0; i(str+1)) { if((eptr[0] == '0') && (eptr[-1] != '.')) { eptr[0] = 0; eptr--; } else break; } fprintf(f,"%s\n",str); }