Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site ubc-vision.UUCP Path: utzoo!utcsri!ubc-vision!majka From: majka@ubc-vision.UUCP (Marc Majka) Newsgroups: net.sources Subject: Super Plot (3 of 8) Message-ID: <120@ubc-vision.UUCP> Date: Sun, 27-Apr-86 18:48:42 EDT Article-I.D.: ubc-visi.120 Posted: Sun Apr 27 18:48:42 1986 Date-Received: Mon, 28-Apr-86 04:01:36 EDT Organization: UBC Computational Vision Lab, Vancouver, B.C., Canada Lines: 665 - - - CUT - - - CUT - - - CUT - - - CUT - - - CUT - - - CUT - - - CUT - - - #!/bin/sh # # shell archive - extract with /bin/sh # echo Plot archive part 3 of 8 echo echo extracting file hform.man sed 's/^X//' > hform.man <<'!FUNKY!STUFF!' XHFORM(1) UNIX Programmer's Manual HFORM(1) X XNAME X hform - reformat the public distribution of the Hershey fonts X XSYNOPSIS X hform X XDESCRIPTION X hform reads in a concatination of the Hershey fonts they X come out of the public distribution in mod.sources. The X program produces two files, vfont/hf.table and X vfont/hf.clist. The table file contains a glyph-number X offset list. The offset is a character offset into the X clist file. This file contains, for each glyph, a list X of relative moves and draws for rendering that glyph. X Lists are terminated by a single null (0) character. X X These two files are used by the programs hcat and hfont. X XAUTHOR X Marc Majka X !FUNKY!STUFF! echo extracting file labels.c sed 's/^X//' > labels.c <<'!FUNKY!STUFF!' X/*************************************************************/ X/* */ X/* Copyright (c) 1986 */ X/* Marc S. Majka - UBC Laboratory for Computational Vision */ X/* */ X/* Permission is hereby granted to copy all or any part of */ X/* this program for free distribution. The author's name */ X/* and this copyright notice must be included in any copy. */ X/* */ X/*************************************************************/ X X/*************************************************************/ X/* */ X/* This file contains a common set of label drawing and */ X/* font manipulation routines. They depend on there being */ X/* three routines compiled in with them: */ X/* */ X/* dblmoverel(x,y) To do a relative move, but */ X/* double x,y; take doubles as input. */ X/* */ X/* dblcontrel(x,y) To do a relative draw, but */ X/* double x,y; take doubles as input. */ X/* */ X/* donelabel() Doesn't need to do anything, but a */ X/* device filter may want to know. */ X/* */ X/*************************************************************/ X X#include X#include X X#define MAXF 32000 X X/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ X/* THIS IS WHERE THE FONTS ARE KEPT: MODIFY FOR LOCAL CONFIGURATION */ X/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ X#define FONTS "vfont/" X Xextern int errno; X Xstruct fontstruct { X char name[256], clist[256], draw[MAXF]; X int nchars, cstart[256]; X double wscale, hscale, theta; X double sinth, costh; X}; X Xstatic struct fontstruct fontst; X Xfont(fname) Xchar *fname; X{ X FILE *fin, *fopen(); X int spt, i; X char c, fontfile[256]; X X fontst.nchars = 0; X spt = 0; X X /* open the font file */ X X if (fname[0] == '/') X strcpy(fontfile,fname); X else { X strcpy(fontfile,FONTS); X strcat(fontfile,fname); X } X X errno = 0; X X fin = fopen(fontfile,"r"); X if (fin == NULL) { X fprintf(stderr,"\ncan't open font file: \"%s\"\n",fontfile); X if (errno == 0) fprintf(stderr,"Too many open files\n"); X else perror(0); X exit(1); X } X strcpy(fontst.name,fname); X X /* read the character index */ X fread(&c,1,1,fin); X while (c != '\0') { X fread(&spt,4,1,fin); X fontst.clist[fontst.nchars] = c; X fontst.cstart[fontst.nchars++] = spt; X fread(&c,1,1,fin); X } X fontst.clist[fontst.nchars] = '\0'; X X /* read the plot list */ X i = 0; X while (fread(&fontst.draw[i++],1,1,fin)); X fclose(fin); X} X Xfspec(w,h,t) Xdouble w, h, t; X{ X double sin(), cos(); X fontst.wscale = w; X fontst.hscale = h; X fontst.theta = t; X fontst.costh = cos(t); X fontst.sinth = sin(t); X} X Xlabel(str) Xchar *str; X{ X int i; X for (i = 0; str[i] != '\0'; imchar(str[i++])); X donelabel(); X} X Ximlabelsize(str,x,y) Xchar *str; Xdouble *x,*y; X{ X /* This code is krufty. It runs through the input string X and collects the "size" of the label. There are too many X coordinate systems in here to imagine. Bleech! */ X X int cpt, spt, i; X double csxc, csyc, x1, y1, x2, y2, csdx, csdy; X char c; X X csxc = 0.0; csyc = 0.0; X x1 = 0.0; y1 = 0.0; X x2 = 0.0; y2 = 0.0; X X for (i = 0; str[i] != '\0'; i++) { X c = str[i]; X cpt = 0; X while ((c != fontst.clist[cpt]) && (cpt < fontst.nchars)) cpt++; X X if (cpt < fontst.nchars) { X spt = fontst.cstart[cpt]; X while (fontst.draw[spt++] != '\0') { X csdx = fontst.wscale * (double)(fontst.draw[spt++]); X csdy = fontst.hscale * (double)(fontst.draw[spt++]); X csxc += csdx; csyc += csdy; X if (csxc < x1) x1 = csxc; X if (csyc < y1) y1 = csyc; X if (csxc > x2) x2 = csxc; X if (csyc > y2) y2 = csyc; X } X } X } X X *x = x2 - x1; X *y = y2 - y1; X} X Xclabel(str) Xchar *str; X{ X double dx,dy,odx,ody; X X imlabelsize(str,&dx,&dy); X dx /= -2.0; dy /= 2.0; X odx = (dx * fontst.costh) - (dy * fontst.sinth); X ody = (dx * fontst.sinth) + (dy * fontst.costh); X dblmoverel(odx,ody); X X label(str); X} X Xblabel(lx,ly,str) Xshort lx,ly; Xchar *str; X{ X double dx,dy,d0; X double ow, oh, t; X X ow = fontst.wscale; X oh = fontst.hscale; X X fontst.wscale = 1.0; X fontst.hscale = 1.0; X if (ow < 0) fontst.wscale *= -1.0; X if (oh < 0) fontst.hscale *= -1.0; X X imlabelsize(str,&dx,&dy); X X if (dx == 0.0) dx = 1.0; X if (dy == 0.0) dy = 1.0; X X fontst.wscale = (double)lx / dx; X fontst.hscale = (double)ly / dy; X X label(str); X X fontst.wscale = ow; X fontst.hscale = oh; X} X Xllabel(lx,ly,str) Xshort lx,ly; Xchar *str; X{ X double dx,dy,d0; X double ow, oh, t; X X ow = fontst.wscale; X oh = fontst.hscale; X X fontst.wscale = 1.0; X fontst.hscale = 1.0; X if (ow < 0) fontst.wscale *= -1.0; X if (oh < 0) fontst.hscale *= -1.0; X X imlabelsize(str,&dx,&d0); X imlabelsize(fontst.clist,&d0,&dy); X X if (dx == 0.0) dx = 1.0; X if (dy == 0.0) dy = 1.0; X X fontst.wscale = (double)lx / dx; X fontst.hscale = (double)ly / dy; X X label(str); X X fontst.wscale = ow; X fontst.hscale = oh; X} X Ximchar(c) Xchar c; X{ X int cpt, spt, contf; X double csdx, csdy, odx, ody; X X cpt = 0; X while ((c != fontst.clist[cpt]) && (cpt < fontst.nchars)) cpt++; X X if (cpt < fontst.nchars) { X spt = fontst.cstart[cpt]; X while (fontst.draw[spt] != '\0') { X if (fontst.draw[spt++] == 'N') contf = 1; X else contf = 0; X X csdx = fontst.wscale * (double)(fontst.draw[spt++]); X csdy = fontst.hscale * (double)(fontst.draw[spt++]); X X odx = (csdx * fontst.costh) - (csdy * fontst.sinth); X ody = (csdx * fontst.sinth) + (csdy * fontst.costh); X X if (contf) dblcontrel(odx,ody); X else dblmoverel(odx,ody); X } X } X if (c == ' ') donelabel(); X} !FUNKY!STUFF! echo extracting file mkfont.c sed 's/^X//' > mkfont.c <<'!FUNKY!STUFF!' X/*************************************************************/ X/* */ X/* Copyright (c) 1986 */ X/* Marc S. Majka - UBC Laboratory for Computational Vision */ X/* */ X/* Permission is hereby granted to copy all or any part of */ X/* this program for free distribution. The author's name */ X/* and this copyright notice must be included in any copy. */ X/* */ X/*************************************************************/ X X#include X#define MAXF 32768 Xmain(argc,argv) Xint argc; Xchar *argv[]; X{ X FILE *fin, *fout, *fopen(); X short x, y; X int cstart[256], cpt, spt, i; X char comm[32], fstr[MAXF], clist[256], xc, yc; X X cpt = 0; spt = 0; X if (argc < 2) { X fin = stdin; X fout = stdout; X } X else if (argc < 3) { X fin = fopen(argv[1],"r"); X fout = stdout; X } X else { X fin = fopen(argv[1],"r"); X fout = fopen(argv[2],"w"); X } X X if (fin == NULL) { X fprintf(stderr,"mkfont: can't open input file!\n"); X exit(1); X } X X if (fout == NULL) { X fprintf(stderr,"mkfont: can't open output file!\n"); X exit(1); X } X X fscanf(fin,"%c%c",&comm[0],&comm[1]); X X while (comm[1] == ':') { X clist[cpt] = comm[0]; X cstart[cpt++] = spt; X fscanf(fin,"%s",comm); X while (comm[0] != 'E') { X if (comm[0] == 'N') { X fscanf(fin,"%hd %hd",&x,&y); X xc = x; yc = y; X fstr[spt++] = 'N'; X fstr[spt++] = xc; fstr[spt++] = yc; X } X else if (comm[0] == 'M') { X fscanf(fin,"%hd %hd",&x,&y); X xc = x; yc = y; X fstr[spt++] = 'M'; X fstr[spt++] = xc; fstr[spt++] = yc; X } X fscanf(fin,"%s",comm); X } X fstr[spt++] = '\0'; X X while (getc(fin) != '\n'); X X fscanf(fin,"%c%c",&comm[0],&comm[1]); X } X for (i = 0; i < cpt; i++) { X fwrite(&clist[i],1,1,fout); X fwrite(&cstart[i],4,1,fout); X } X xc = '\0'; X fwrite(&xc,1,1,fout); X for (i = 0; i < spt; i++) fwrite(&fstr[i],1,1,fout); X fclose(fin); X fclose(fout); X} !FUNKY!STUFF! echo extracting file pl5pl.c sed 's/^X//' > pl5pl.c <<'!FUNKY!STUFF!' X/*************************************************************/ X/* */ X/* Copyright (c) 1986 */ X/* Marc S. Majka - UBC Laboratory for Computational Vision */ X/* */ X/* Permission is hereby granted to copy all or any part of */ X/* this program for free distribution. The author's name */ X/* and this copyright notice must be included in any copy. */ X/* */ X/*************************************************************/ X X#include X Xmain (argc, argv) Xint argc; Xchar *argv[]; X{ X char str[1024], comm, nl, c; X int i, patn; X short x1, y1, x2, y2, x3, y3, r, gray, red, green, blue, hv, pn, n, k; X FILE *tfp, *pfp, *fopen(); X double ws, hs, theta; X X hv = 0; X X if (argc > 1) tfp = fopen(argv[1],"r"); X else tfp = stdin; X X if (tfp == NULL) { X fprintf(stderr,"stpl: can't open input plot file\n"); X exit(1); X } X X if (argc > 2) pfp = fopen(argv[2],"w"); X else pfp = stdout; X X if (pfp == NULL) { X fprintf(stderr,"stpl: can't open output plot file\n"); X exit(1); X } X X fprintf(pfp,"Xsr\n"); X ws = 5.0; hs = 5.0; theta = 0.0; X fprintf(pfp,"S"); X fwrite(&ws,4,1,pfp); X fwrite(&hs,4,1,pfp); X fwrite(&theta,4,1,pfp); X fflush(pfp); X X while (fscanf(tfp, "%c", &comm) != EOF) { X switch (comm) { X case 'm': /* MOVE */ X fread(&x1,2,1,tfp); X fread(&y1,2,1,tfp); X fprintf(pfp,"m"); X fwrite(&x1,2,1,pfp); X fwrite(&y1,2,1,pfp); X fflush(pfp); X break; X case 'n': /* CONT */ X fread(&x1,2,1,tfp); X fread(&y1,2,1,tfp); X fprintf(pfp,"n"); X fwrite(&x1,2,1,pfp); X fwrite(&y1,2,1,pfp); X fflush(pfp); X break; X case 'p': /* POINT */ X fread(&x1,2,1,tfp); X fread(&y1,2,1,tfp); X fprintf(pfp,"p"); X fwrite(&x1,2,1,pfp); X fwrite(&y1,2,1,pfp); X fflush(pfp); X break; X case 'l': /* LINE */ X fread(&x1,2,1,tfp); X fread(&y1,2,1,tfp); X fread(&x2,2,1,tfp); X fread(&y2,2,1,tfp); X fprintf(pfp,"l"); X fwrite(&x1,2,1,pfp); X fwrite(&y1,2,1,pfp); X fwrite(&x2,2,1,pfp); X fwrite(&y2,2,1,pfp); X fflush(pfp); X break; X case 't': /* LABEL */ X fscanf(tfp,"%1s",&c); X i = 0; X while (c != '\n') { X str[i++] = c; X fscanf(tfp,"%c",&c); X } X str[i] = '\0'; X fprintf(pfp,"t%s\n",str); X fflush(pfp); X break; X case 'a': /* ARC */ X fread(&x1,2,1,tfp); X fread(&y1,2,1,tfp); X fread(&x2,2,1,tfp); X fread(&y2,2,1,tfp); X fread(&x3,2,1,tfp); X fread(&y3,2,1,tfp); X fprintf(pfp,"a"); X fwrite(&x1,2,1,pfp); X fwrite(&y1,2,1,pfp); X fwrite(&x2,2,1,pfp); X fwrite(&y2,2,1,pfp); X fwrite(&x3,2,1,pfp); X fwrite(&y3,2,1,pfp); X fflush(pfp); X break; X case 'c': /* CIRCLE */ X fread(&x1,2,1,tfp); X fread(&y1,2,1,tfp); X fread(&r,2,1,tfp); X fprintf(pfp,"c"); X fwrite(&x1,2,1,pfp); X fwrite(&y1,2,1,pfp); X fwrite(&r,2,1,pfp); X fflush(pfp); X break; X case 'e': /* ERASE */ X gray = 0; X fprintf(pfp,"g"); X fwrite(&gray,2,1,pfp); X fprintf(pfp,"e"); X gray = 255; X fprintf(pfp,"g"); X fwrite(&gray,2,1,pfp); X fflush(pfp); X break; X case 'f': /* LINEMOD */ X fscanf(tfp,"%s",str); X fscanf(tfp,"%c",&c); X if (!strcmp(str,"dotted")) X strcpy(str,"11000000"); X else if (!strcmp(str,"solid")) X strcpy(str,"1"); X else if (!strcmp(str,"longdashed")) X strcpy(str,"11111100"); X else if (!strcmp(str,"shortdashed")) X strcpy(str,"11110000"); X else if (!strcmp(str,"dotdashed")) X strcpy(str,"1100001111110000"); X else strcpy(str,"1"); X fprintf(pfp,"f%s\n",str); X fflush(pfp); X break; X case 's': /* SPACE */ X fread(&x1,2,1,tfp); X fread(&y1,2,1,tfp); X fread(&x2,2,1,tfp); X fread(&y2,2,1,tfp); X fprintf(pfp,"s"); X fwrite(&x1,2,1,pfp); X fwrite(&y1,2,1,pfp); X fwrite(&x2,2,1,pfp); X fwrite(&y2,2,1,pfp); X fwrite(&hv,2,1,pfp); X fflush(pfp); X break; X default: X fprintf(stderr,"stpl: unknown command %s\n", comm); X break; X } X } X X fclose(pfp); X fclose(tfp); X exit(0); X} X !FUNKY!STUFF! echo extracting file pl5pl.man sed 's/^X//' > pl5pl.man <<'!FUNKY!STUFF!' XPL5PL(1) UNIX Programmer's Manual PL5PL(1) X XNAME X pl5pl - converts standard UNIX plot(5) files to plot file X format. X XSYNOPSIS X pl5pl [in [out]] X XDESCRIPTION X pl5pl reads a plot file in the format specified by plot(5), X and writes it in the local format. The space command has a X 0 hv flag attached. Linemods are translated into something X sensible. and erase is interpreted as clear to black. X X See the manual page for fplot(3) for a specification of plot X files. X XAUTHOR X Marc Majka X XSEE ALSO X plot(5) !FUNKY!STUFF! echo extracting file plps.c sed 's/^X//' > plps.c <<'!FUNKY!STUFF!' X/*************************************************************/ X/* */ X/* Copyright (c) 1986 */ X/* Marc S. Majka - UBC Laboratory for Computational Vision */ X/* */ X/* Permission is hereby granted to copy all or any part of */ X/* this program for free distribution. The author's name */ X/* and this copyright notice must be included in any copy. */ X/* */ X/*************************************************************/ X X#include X Xmain (argc, argv) Xint argc; Xchar *argv[]; X{ X FILE *pfp, *fopen(); X int argn, sqr, plt, bin, win, man, leg; X int x1, y1, x2, y2, r1, c1, r2, c2; X X man = 0; X leg = 0; X sqr = 0; X win = 0; X bin = 0; X plt = 0; X X for (argn = 1; argn < argc; argn++) { X if (argv[argn][0] == '-') { X switch (argv[argn][1]) { X case 's': sqr = 1; break; X case 'm': man = 1; break; X case 'l': leg = 1; break; X case 'b': bin = 1; break; X case 'w': X win = argn; X r1 = atoi(argv[++win]); X c1 = atoi(argv[++win]); X r2 = atoi(argv[++win]); X c2 = atoi(argv[++win]); X x1 = c1; X y1 = 3300 - r1; X x2 = c2; X y2 = 3300 - r2; X win = 1; X argn += 4; X break; X default: X printf("plps [file] [-w r1 c1 r2 c2] [-s][-b][-m][-l]\n"); X exit(0); X } X } X else { X if (plt) { X printf("plps [file] [-w r1 c1 r2 c2] [-s][-b][-m][-l]\n"); X exit(0); X } X plt = 1; X pfp = fopen(argv[argn],"r"); X if (pfp == NULL) { X printf("can't open plt file %s\n",argv[argn]); X exit(1); X } X } X } X X if (!plt) pfp = stdin; X X plotopen(""); X if (man) manfeed(); X if (leg) legal(); X if (sqr) frame(100,3200,2400,800,1); X if (win) frame(x1,y1,x2,y2,1); X if (bin) bppout(0); X else bppout(1); X plotdriver(pfp); X plotclose(); X exit(0); X} !FUNKY!STUFF! echo echo finished part 3 of 8