edf@ROCKEFELLER.ARPA (David MacKenzie) (07/16/88)
Posting-number: Volume 3, Issue 87 Submitted-by: "David MacKenzie" <edf@ROCKEFELLER.ARPA> Archive-name: hpglplot/Part3 #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 3 (of 3)." # Contents: charset.0 hatch.c main.c # Wrapped by dave@zedfdc on Fri Jul 8 20:51:05 1988 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'charset.0' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'charset.0'\" else echo shar: Extracting \"'charset.0'\" \(11475 characters\) sed "s/^X//" >'charset.0' <<'END_OF_FILE' X 2,0, 100, 0,0, -100, 0,2, 100, 0,6, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* ! */ X 1,6, 100, 1,2, -100, 1,-2, 100, 1,2, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* " */ X 1,1, 100, 0,6, -100, 2,0, 100, 0,-6, -100, 1,2, 100, -4,0, -100, 0,2, 100, 4,0, -200,-200,-200,-200,-200 /* # */ X 0,2, 100, 1,-1, 2,0, 1,1, 0,1, -4,2, 0,1, 1,1, 2,0, 1,-1, -100, -2,2, 100, 0,-8, -200 /* $ */ X 0,2, 100, 3,4, -100, -2,0, 100, -1,-1, 0,1, 1,0, -100, 2,-3, 100, 0,-1, -1,0, 1,1, -200,-200,-200 /* % */ X 4,0, 100, -3,5, 0,2, 1,1, 1,-1, 0,-2, -3,-2, 0,-2, 1,-1, 2,0, 1,2, -200,-200,-200,-200,-200 /* & */ X 1,6, 100, 1,2, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* ' */ X 3,0, 100, -1,2, 0,4, 1,2, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* ( */ X 1,0, 100, 1,2, 0,4, -1,2, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* ) */ X 0,2, 100, 4,4, -100, -4,0, 100, 4,-4, -100, -2,0, 100, 0,4, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* * */ X 2,2, 100, 0,4, -100, -2,-2, 100, 4,0, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* + */ X 2,0, 100, -1,0, 0,1, 1,0, 0,-1, -1,-1, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* , */ X 0,4, 100, 4,0, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* - */ X 1,0, 100, 0,1, 1,0, 0,-1, -1,0, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* . */ X 0,1, 100, 3,6, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* / */ X 1,0, 100, -1,3, 0,2, 1,3, 2,0, 1,-3, 0,-2, -1,-3, -2,0, -200,-200,-200,-200,-200,-200,-200,-200,-200 /* 0 */ X 1,0, 100, 2,0, -1,0, 0,8, -1,-1, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* 1 */ X 4,0, 100, -4,0, 0,1, 1,2, 2,1, 1,1, 0,2, -1,1, -2,0, -1,-1, 0,-1, -200,-200,-200,-200,-200 /* 2 */ X 0,1, 100, 1,-1, 2,0, 1,1, 0,2, -1,1, -2,0, 2,0, 1,1, 0,2, -1,1, -2,0, -1,-1, -200 /* 3 */ X 4,0, 100, 0,8, 0,-4, -4,0, 1,4, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* 4 */ X 0,1, 100, 1,-1, 2,0, 1,1, 0,2, -1,1, -3,0, 0,4, 4,0, -200,-200,-200,-200,-200,-200,-200,-200,-200 /* 5 */ X 0,4, 100, 3,0, 1,-1, 0,-2, -1,-1, -2,0, -1,1, 0,6, 1,1, 2,0, 1,-1, -200,-200,-200,-200,-200 /* 6 */ X 1,0, 100, 3,8, -4,0, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* 7 */ X 0,1, 100, 0,2, 4,2, 0,2, -1,1, -2,0, -1,-1, 0,-2, 4,-2, 0,-2, -1,-1, -2,0, -1,1, -200 /* 8 */ X 4,0, 100, 0,8, -3,0, -1,-1, 0,-2, 1,-1, 2,0, 1,1, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* 9 */ X 1,0, 100, 0,1, 1,0, 0,-1, -1,0, -100, 0,4, 100, 0,1, 1,0, 0,-1, -1,0, -200,-200,-200,-200,-200 /* : */ X 2,0, 100, -1,0, 0,1, 1,0, 0,-1, -1,-1, -100, 0,5, 100, 0,1, 1,0, 0,-1, -1,0, -200,-200,-200 /* ; */ X 4,1, 100, -3,3, 3,3, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* < */ X 0,3, 100, 4,0, -100, 0,2, 100, -4,0, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* = */ X 0,1, 100, 3,3, -3,3, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* > */ X 2,0, 100, 0,0, -100, 0,2, 100, 0,1, 2,2, 0,2, -1,1, -2,0, -1-1, -200,-200,-200,-200,-200,-200,-200 /* ? */ X 4,1, 100, -3,0, -1,1, 0,4, 1,1, 2,0, 1,-1, 0,-2, -1,-1, -1,0, 0,2, 2,1, -200, -200, -200 /* @ */ X 100, 0,5, 2,3, 2,-3, 0,-5, -100, 0,4, 100, -4,0, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* A */ X 0,4, 100, 3,0, 1,-1, 0,-2, -1,-1, -3,0, 0,8, 3,0, 1,-1, 0,-2, -1,-1, -200,-200,-200,-200,-200 /* B */ X 4,1, 100, -1,-1, -2,0, -1,1, 0,6, 1,1, 2,0, 1,-1, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* C */ X 100, 0,8, 3,0, 1,-1, 0,-6, -1,-1, -3,0, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* D */ X 4,0, 100, -4,0, 0,4, 3,0, -3,0, 0,4, 4,0, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* E */ X 100, 0,4, 3,0, -3,0, 0,4, 4,0, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* F */ X 2,3, 100, 2,0, 0,-2, -1,-1, -2,0, -1,1, 0,6, 1,1, 2,0, 1,-1, -200,-200,-200,-200,-200,-200,-200 /* G */ X 100, 0,8, 0,-4, 4,0, 0,4, 0,-8, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* H */ X 1,0, 100, 2,0, -1,0, 0,8, 1,0, -2,0, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* I */ X 0,2, 100, 0,-1, 1,-1, 2,0, 1,1, 0,7, -1,0, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* J */ X 100, 0,8, 0,-4, 4,4, -4,-4, 4,-4, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* K */ X 4,0, 100, -4,0, 0,8, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* L */ X 100, 0,8, 2,-3, 2,3, 0,-8, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* M */ X 100, 0,8, 4,-8, 0,8, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* N */ X 0,1, 100, 0,6, 1,1, 2,0, 1,-1, 0,-6, -1,-1, -2,0, -1,1, -200,-200,-200,-200,-200,-200,-200,-200,-200 /* O */ X 100, 0,8, 3,0, 1,-1, 0,-2, -1,-1, -3,0, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* P */ X 0,1, 100, 0,6, 1,1, 2,0, 1,-1, 0,-6, -1,-1, -2,0, -1,1, -100, 2,1, 100, 2,-2, -200,-200,-200 /* Q */ X 100, 0,8, 3,0, 1,-1, 0,-2, -1,-1, -3,0, 2,0, 2,-4, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* R */ X 0,1, 100, 1,-1, 2,0, 1,1, 0,2, -1,1, -2,0, -1,1, 0,2, 1,1, 2,0, 1,-1, -200,-200,-200 /* S */ X 2,0, 100, 0,8, -2,0, 4,0, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* T */ X 0,8, 100, 0,-7, 1,-1, 2,0, 1,1, 0,-1, 0,8, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* U */ X 0,8, 100, 1,-5, 1,-3, 1,3, 1,5, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* V */ X 0,8, 100, 0,-6, 1,-2, 1,3, 0,1, 0,-1, 1,-3, 1,2, 0,6, -200,-200,-200,-200,-200,-200,-200,-200,-200 /* W */ X 100, 4,8, -100, -4,0, 100, 4,-8, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* X */ X 2,0, 100, 0,5, -2,3, 2,-3, 2,3, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* Y */ X 0,8, 100, 4,0, -4,-8, 4,0, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* Z */ X 3,0, 100, -1,0, 0,8, 1,0, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* [ */ X 0,7, 100, 3,-6, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* \ */ X 1,0, 100, 1,0, 0,8, -1,0, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* ] */ X 0,6, 100, 2,2, 2,-2, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* ^ */ X 100, 4,0, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* _ */ X 2,8, 100, 1,-2, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* ` */ X 4,1, 100, -1,-1, -2,0, -1,1, 0,2, 1,2, 3,0, 0,-5, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* a */ X 0,8, 100, 0,-8, 0,1, 1,-1, 2,0, 1,1, 0,3, -1,1, -3,0, -200,-200,-200,-200,-200,-200,-200,-200,-200 /* b */ X 4,1, 100, -1,-1, -2,0, -1,1, 0,3, 1,1, 2,0, 1,-1, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* c */ X 4,8, 100, 0,-8, 0,1, -1,-1, -2,0, -1,1, 0,3, 1,1, 3,0, -200,-200,-200,-200,-200,-200,-200,-200,-200 /* d */ X 4,1, 100, -1,-1, -2,0, -1,1, 0,3, 1,1, 2,0, 1,-1, 0,-1, -4,0, -200,-200,-200,-200,-200,-200,-200 /* e */ X 1,0, 100, 0,7, 1,1, 1,0, 1,-1, -100, -2,-3, 100, -2,0, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* f */ X 4,1, 100, -1,-1, -2,0, -1,1, 0,3, 1,1, 3,0, 0,-7, -1,-1, -2,0, -1,1, -200,-200,-200,-200,-200 /* g */ X 100, 0,8, 0,-4, 1,1, 2,0, 1,-1, 0,-4, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* h */ X 1,0, 100, 2,0, -1,0, 0,5, -100, 0,2, 100, 0,0, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* i */ X 0,-2, 100, 1,-1, 1,0, 1,1, 0,7, -100, 0,2, 100, 0,0, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* j */ X 100, 0,8, 0,-5, 4,2, -2,-1, 2,-4, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* k */ X 1,0, 100, 2,0, -1,0, 0,8, -1,0, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* l */ X 100, 0,5, 0,-1, 1,1, 1,0, 0,-5, 0,4, 1,1, 1,0, 0,-5, -200,-200,-200,-200,-200,-200,-200,-200,-200 /* m */ X 100, 0,5, 0,-1, 1,1, 2,0, 1,-1, 0,-4, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* n */ X 1,0, 100, -1,1, 0,3, 1,1, 2,0, 1,-1, 0,-3, -1,-1, -2,0, -200,-200,-200,-200,-200,-200,-200,-200,-200 /* o */ X 0,-3, 100, 0,8, 3,0, 1,-1, 0,-3, -1,-1, -2,0, -1,1, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* p */ X 4,1, 100, -1,-1, -2,0, -1,1, 0,3, 1,1, 3,0, 0,-8, -1,0, 2,0, -200,-200,-200,-200,-200,-200,-200 /* q */ X 100, 0,5, 0,-2, 2,2, 2,0, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* r */ X 0,1, 100, 1,-1, 2,0, 1,1, 0,1, -4,1, 0,1, 1,1, 2,0, 1,-1, -200,-200,-200,-200,-200,-200,-200 /* s */ X 2,0, 100, 0,8, -100, -2,-3, 100, 4,0, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* t */ X 0,5, 100, 0,-4, 1,-1, 2,0, 1,1, 0,-1, 0,5, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* u */ X 0,5, 100, 2,-5, 2,5, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* v */ X 0,5, 100, 0,-3, 1,-2, 1,3, 0,2, 0,-2, 1,-3, 1,2, 0,3, -200,-200,-200,-200,-200,-200,-200,-200,-200 /* w */ X 100, 4,5, -100, -4,0, 100, 4,-5, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* x */ X 0,5, 100, 2,-5, -2,-3, 2,3, 2,5, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* y */ X 4,0, 100, -4,0, 4,5, -4,0, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* z */ X 3,0, 100, -1,1, 0,2, -1,1, 1,1, 0,2, 1,1, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* { */ X 2,0, 100, 0,8, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* | */ X 1,0, 100, 1,1, 0,2, 1,1, -1,1, 0,2, -1,1, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* } */ X 1,6, 100, 1,1, 1,-1, 1,1, -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200 /* ~ */ END_OF_FILE if test 11475 -ne `wc -c <'charset.0'`; then echo shar: \"'charset.0'\" unpacked with wrong size! fi # end of 'charset.0' fi if test -f 'hatch.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'hatch.c'\" else echo shar: Extracting \"'hatch.c'\" \(10686 characters\) sed "s/^X//" >'hatch.c' <<'END_OF_FILE' X/* X * hatch.c X * X * Copyright (c) 1988 Environmental Defense Fund, Inc. X */ X X#include <stdio.h> X#include <math.h> X#include "const.h" X#include "vars.h" X#include "fillcnst.h" X#ifdef TESTVER X#include "dbgvars.h" X#endif X X/* global vars -- extern-referenced in fillvars.h */ Xint hatch_degs; /* hatch angle in degrees */ Xdouble hatch_rads; /* hatch angle in radians */ Xdouble x_shift; Xdouble chg_x_CA, X chg_y_CA, X chg_x_CB, X chg_y_CB, X chg_x_AB, X chg_y_AB; Xint C_A, X C_B, X A_B; Xint fill, /* these are used in fix_fill() */ X fixed_fill, X pen_number, X spacing; Xint no_fill; /* flag to disable fill routines */ X X/* =========================== hatch() ===================================== */ X/* X * since the hatch algorithm cannot plot horizontal hatch lines, X * the angle of inclination of most lines has been altered. X * fill type nominal plotted X * PARLL_0 0 deg 25 deg X * PARLL_45 45 75 X * PARLL_90 90 90 X * PARLL_135 135 115 X * CROSS_0 0/90 25/155 X * CROSS_90 45/135 75/115 X * X * fixed_fill is the fill type returned from fix_fill() in file filltype.c X * see also the hand-written documentation, page F1, and the documentation in X * file filltype.c for more details on fill type patterns. X */ X Xhatch(pts, num_pts) X POINT pts[362]; Xint num_pts; X X{ X if (no_fill) X return (0); /* no_fill=T ==> don't do fill routines */ X X switch (fixed_fill) { X case SOLIDFILL: X#ifdef TRUESOLID X hatch_degs = 90; X fill_figure(hatch_degs, pts, num_pts); X#else X /* for tri-hatch implementation of solidfill */ X hatch_degs = 30; X fill_figure(hatch_degs, pts, num_pts); X hatch_degs = 90; X fill_figure(hatch_degs, pts, num_pts); X hatch_degs = 150; X fill_figure(hatch_degs, pts, num_pts); X#endif X break; X case PARLL_0: X case PARLL_45: X case PARLL_90: X case PARLL_135: X case OTHER: /* <<<<<<<<< for testing */ X switch (fixed_fill) { X case PARLL_0: X hatch_degs = 25; X break; X case PARLL_45: X hatch_degs = 65; X break; X case PARLL_90: X hatch_degs = 90; X break; X case PARLL_135: X hatch_degs = 115; X break; X case OTHER: X hatch_degs = fill_angle; X break; X } X fill_figure(hatch_degs, pts, num_pts); X break; X case CROSS_0: X hatch_degs = 20; X fill_figure(hatch_degs, pts, num_pts); X hatch_degs = 160; X fill_figure(hatch_degs, pts, num_pts); X break; X case CROSS_45: X hatch_degs = 70; X fill_figure(hatch_degs, pts, num_pts); X hatch_degs = 110; X fill_figure(hatch_degs, pts, num_pts); X break; X } X} X X X/* =========================== fill_figure() =============================== */ X/* X * fill a rectangle or pie sector with parallel hatch lines X * at an angle of hatch_degs. X * hatch_degx is a formal param, to which X * the value of the global var hatch_degs is passed X * Repeated twice on the same figure for cross-hatching, X * thrice for "solid fill". X */ X Xfill_figure(hatch_degx, pts, num_pts) X int hatch_degx; X POINT pts[362]; Xint num_pts; X X{ X POINT P[3]; X int i; X X#ifdef TESTVER X int n; X X if (debug1c) { X fprintf(stderr, "\nIn: fill_figure();\n"); X } X if (debug1f) { X fprintf(errfp, "\nIn: fill_figure();\n"); X } X#endif X X hatch_rads = (double) hatch_degx *DEG_TO_RAD; X X#ifdef TESTVER X if (debug4) { X for (n = 0; n < num_pts; n++) { X fprintf(errfp, "pts[%d]: ( %d, %d )\n", n, pts[n].x, pts[n].y); X } X fprintf(errfp, "hatch_degs: %d; hatch_rads: %5.1f\n", X hatch_degx, hatch_rads); X fflush(errfp); X } X#endif X X /* find spacing of x-intercepts of adjacent hatch lines */ X x_shift = spacing / sin(hatch_rads); X X#ifdef TESTVER X if (debug4) { X fprintf(errfp, X "spacing: %d; sin(hatch_angle): %6.4f; x_shift: %5.1f\n", X spacing, sin(hatch_rads), x_shift); X fflush(errfp); X } X#endif X X P[0] = pts[0]; X for (i = 1; i < num_pts - 2; i++) { X P[1] = pts[i]; X P[2] = pts[i + 1]; X X#ifdef TESTVER X /* if ( debug1c ) { fprintf( stderr, "\nTo: fill_triangle();\n" ); } */ X if (debug1f) { X fprintf(errfp, "\nTo: fill_triangle();\n"); X fflush(errfp); X } X#endif X fill_triangle(hatch_degx, P); X } X} X X X/* =========================== fill_triangle() ============================= */ X/* X * hatch_degx is a formal param, to which X * the value of the global var hatch_degs is passed X */ X Xfill_triangle(hatch_degx, P) X int hatch_degx; X POINT P[3]; X X{ X double ic[3]; /* x-intercept of a hatch line passing thru X * the given pt */ X int i; X double x_offset; X POINT A, X B, X C; X X#ifdef TESTVER X int n; X static char *stat_type[] = {"GENERIC", X "PARALLEL", X "VERTICAL", X "HORIZONTAL"}; X X if (debug4) { X for (n = 0; n < 3; n++) { X fprintf(errfp, "P[%d]: ( %d, %d )\n", n, P[n].x, P[n].y); X } X fflush(errfp); X } X#endif X X for (i = 0; i < 3; i++) { X /* find the x-intercept of the hatch line containing P[i] */ X if (hatch_degx == 90) { /* tan(90) is not defined */ X ic[i] = (double) P[i].x; X } else { X x_offset = ((double) P[i].y / tan(hatch_rads)); X ic[i] = (double) P[i].x - x_offset; X } X#ifdef TESTVER X if (debug4) { X if (i == 0) X putc('\n', errfp); X fprintf(errfp, "hatch_intercept[%d]: %f\n", i, ic[i]); X fflush(errfp); X } X#endif X } X X X/* X * The x-intercepts of the three vertices are used to determine the relative X * position of the vertices C (the common reference point for hatching) and X * A and B. Due to binary storage error, intercepts which are close enough X * to be considered equal must be actually set equal before performing the X * tests for in/equality which determine the relative positioning of the X * intercepts, and thence the points themselves. get_3_chgs is called here X * because the results that it returns provide the exact criteria for X * determining which intercepts are close enough to be considered equal. In X * calling get_3_chgs, it is assumed that vertices A and B are in order X * from 'left' to 'right'; so A = P[1], B = P[2]. P[0] is known to be the X * common (reference) point, so it will be named C in any case. Depending X * on the results of the tests on the intercepts, the naming of P[1] and X * P[2] may be swapped so that ultimately P[1] is named B, etc. In that X * case, line segments become renamed, and their attributes must be X * similarly swapped. This is so that end_ref() and mid_ref() can then be X * called with parameters A, B, and C naming points that are in the standard X * positions expected by end_ref() and mid_ref(). X */ X X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: get_3_chgs()\n"); X } X if (debug1f) { X fprintf(errfp, "\nTo: get_3_chgs()\n"); X fflush(errfp); X } X#endif X get_3_chgs(P[1], P[2], P[0]); X if (C_A == PARL) { X ic[1] = ic[0]; X } X if (C_B == PARL) { X ic[2] = ic[0]; X } X#ifdef TESTVER X if (debug4) { X putc('\n', errfp); X for (n = 0; n < 3; n++) X fprintf(errfp, "ic[%d]: %f\n", n, ic[n]); X } X#endif X X /* assign points, reassigning order if necessary */ X C = P[0]; X if (ic[1] < ic[2]) { X A = P[1]; X B = P[2]; X } else { X A = P[2]; X B = P[1]; X iswap(&C_A, &C_B); X fswap(&chg_x_CA, &chg_x_CB); X fswap(&chg_y_CA, &chg_y_CB); X } X /* X * if reference point (C) is at 'right' end of triangle, negate the X * changes, and reverse A and B X */ X if (ic[0] >= ic[1] && ic[0] >= ic[2]) { X iswap(&A.x, &B.x); X iswap(&A.y, &B.y); X iswap(&C_A, &C_B); X fswap(&chg_x_CA, &chg_x_CB); X fswap(&chg_y_CA, &chg_y_CB); X chg_x_CA = -chg_x_CA; X chg_y_CA = -chg_y_CA; X chg_x_CB = -chg_x_CB; X chg_y_CB = -chg_y_CB; X chg_x_AB = -chg_x_AB; X chg_y_AB = -chg_y_AB; X } X#ifdef TESTVER X /* debug output */ X if (debug4) { X fprintf(errfp, "\nA: ( %d, %d ); B: ( %d, %d ); C: ( %d, %d )\n", X A.x, A.y, B.x, B.y, C.x, C.y); X fprintf(errfp, "chg_x_CA: %6.1f; chg_y_CA: %6.1f; C_A: %s\n", X chg_x_CA, chg_y_CA, stat_type[C_A]); X fprintf(errfp, "chg_x_CB: %6.1f; chg_y_CB: %6.1f; C_B: %s\n", X chg_x_CB, chg_y_CB, stat_type[C_B]); X fprintf(errfp, "chg_x_AB: %6.1f; chg_y_AB: %6.1f; A_B: %s\n", X chg_x_AB, chg_y_AB, stat_type[A_B]); X fflush(errfp); X } X#endif X X /* select and call proper processing function */ X /* reference point (C) is at 'left' end of triangle ----------------- */ X if (ic[0] <= ic[1] && ic[0] <= ic[2]) { X X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: end_ref() -- LEFT\n"); X } X if (debug1f) { X fprintf(errfp, "\nTo: end_ref() -- LEFT\n"); X fflush(errfp); X } X#endif X end_ref(C, A, B); X } X /* reference point (C) is at 'right' end of triangle ----------------- */ X else if (ic[0] >= ic[1] && ic[0] >= ic[2]) { X X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: end_ref() -- RIGHT\n"); X } X if (debug1f) { X fprintf(errfp, "\nTo: end_ref() -- RIGHT\n"); X fflush(errfp); X } X#endif X end_ref(C, A, B); X } X /* reference point (C) is in 'middle' of triangle ----------------- */ X else if ((ic[1] < ic[0] && ic[0] < ic[2]) || X (ic[2] < ic[0] && ic[0] < ic[1])) { X X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: mid_ref() -- MID\n"); X } X if (debug1f) { X fprintf(errfp, "\nTo: mid_ref() -- MID\n"); X fflush(stderr); X } X#endif X mid_ref(A, C, B); X } else { X fprintf(stderr, "Disposition error -- fill_triangle()\n"); X#ifdef TESTVER X fprintf(errfp, "Disposition error -- fill_triangle()\n"); X fprintf(errfp, "ic[0]: %f; ic[1]: %f; ic[2]: %f\n", X ic[0], ic[1], ic[2]); X#endif X exit(1); X } X X} X X X/* =========================== get_3_chgs() ================================ */ Xget_3_chgs(A, B, C) X POINT A, X B, X C; X{ X /* X * find the x- and y- increments for successive hatch line intersections X * along segment C-A X */ X C_A = get_chgs(&chg_x_CA, &chg_y_CA, C, A); X X /* X * find the x- and y- increments for successive hatch line intersections X * along segment C-B X */ X C_B = get_chgs(&chg_x_CB, &chg_y_CB, C, B); X X /* X * find the x- and y- increments for successive hatch line intersections X * along segment A-B X */ X A_B = get_chgs(&chg_x_AB, &chg_y_AB, A, B); X} X X X/* =========================== iswap() ===================================== */ Xiswap(i1p, i2p) X int *i1p, X *i2p; X{ X int itemp; X X itemp = *i1p; X *i1p = *i2p; X *i2p = itemp; X} X X X/* =========================== fswap() ===================================== */ Xfswap(f1p, f2p) X double *f1p, X *f2p; X{ X double ftemp; X X ftemp = *f1p; X *f1p = *f2p; X *f2p = ftemp; X} END_OF_FILE if test 10686 -ne `wc -c <'hatch.c'`; then echo shar: \"'hatch.c'\" unpacked with wrong size! fi # end of 'hatch.c' fi if test -f 'main.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'main.c'\" else echo shar: Extracting \"'main.c'\" \(11906 characters\) sed "s/^X//" >'main.c' <<'END_OF_FILE' X/* X * main.c X * X * Copyright (c) 1988 Environmental Defense Fund, Inc. X * X * hpglplot v2.1 X * X * Filter to read HPGL commands (Hewlett-Packard Graphics Language, X * used by HP7475A 6-pen plotter, among others) and produce bit map X * graphics commands for various printers. X * X * Usage: hpglplot -eiln X * Options: X * -e produce output for Epson LQ-1500 X * -i produce output for IBM Proprinter X * -l produce output for HP LaserJet+ X * -n disable area fill routines (bug-prone) X * X * Authors: X * Mel Brooks X * Initial program design, command interpreter, Epson bit-map. X * Al Chase X * Fill routines, LaserJet and Proprinter bit-maps. X * David MacKenzie X * Rewrote option parser and makefile, cleaned up. X */ X X#include <stdio.h> X#include <string.h> X#include "const.h" X#include "fillvars.h" X#include "vars.h" X X#ifdef TESTVER X#include "dbgvars.h" X#endif X Xmain(argc, argv) X int argc; X char **argv; X{ X extern int no_fill; X int to_printer; X int c; /* option letter */ X X no_fill = FALSE; X /* Determine bit image output */ X#ifdef TESTVER X fprintf(stderr, "Test version of plot program.\n"); X /* use defaults if no options specified */ X printer = EPSON; X to_printer = FALSE; X while ((c = getopt(argc, argv, "ein")) != EOF) X switch (c) { X case 'e': X printer = EPSON; X to_printer = TRUE; X break; X case 'i': X printer = IBM_PRO; X to_printer = TRUE; X break; X case 'n': X no_fill = TRUE; X break; X default: X usage(); X } X#else X printer = 0; X to_printer = TRUE; X while ((c = getopt(argc, argv, "eiln")) != EOF) X switch (c) { X case 'e': X printer = EPSON; X break; X case 'i': X printer = IBM_PRO; X break; X case 'l': X printer = LASER; X break; X case 'n': X no_fill = TRUE; X break; X default: X usage(); X } X if (printer == 0) X usage(); X#endif X X#ifdef TESTVER X set_debugs(); X#endif X X first_fill = TRUE; X while ((c = getchar()) != EOF) { /* Read from standard input until EOF */ X switch (c) { X case '\n': X break; X case ' ': /* non-standard: for readability */ X break; X case '{': /* non-standard: allows nested */ X skip_comments(); /* comments in the HPGL file */ X break; X case '!': /* for debugging */ X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: test routine\n"); X } X if (debug1f) { X fprintf(errfp, "\nTo: test routine\n"); X } X#endif X#if 0 X test(); X#endif X break; X case ESC: X c = getchar(); /* Throw away '.' */ X c = getchar(); X switch (c) { X case '(': X case 'Y': X case 'B': X case 'E': X case 'K': X case 'L': X case 'J': X case 'O': X break; X case 'R': X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: init_map();\n"); X } X if (debug1f) { X fprintf(errfp, "To: init_map();\n"); X } X#endif X init_map(); X break; X#ifdef TESTVER X case '!': /* for debugging -- exit before dump_map() */ X exit(0); X break; X#endif X case ')': X case 'Z': X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: dump_map();\n"); X } X if (debug1f) { X fprintf(errfp, "To: dump_map();\n"); X } X#endif X dump_map(to_printer); X exit(0); X break; X case '@': X case 'I': X case 'M': X case 'N': X while ((c = getchar()) != ':'); X break; X default: X fprintf(stderr, "Bad ESC sequence, ESC.%c\n", c); X exit(3); X } X break; X case 'A': X switch ((c = getchar())) { X case 'A': X unimpl('A', 'A'); X break; X case 'R': X unimpl('A', 'R'); X break; X default: X fprintf(stderr, "Bad instruction A%c\n", c); X exit(3); X } X break; X case 'C': X switch ((c = getchar())) { X case 'A': X /* do_CA(); */ X fprintf(stderr, "Alternate character set not available. "); X fprintf(stderr, "Default set will be used.\n"); X break; X case 'S': X do_CS(); X break; X case 'I': X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: do_CI();\n"); X } X if (debug1f) { X fprintf(errfp, "To: do_CI();\n"); X } X#endif X do_CI(); X break; X case 'P': X unimpl('C', c); X break; X default: X fprintf(stderr, "Bad instruction C%c\n", c); X exit(3); X } X break; X case 'D': X switch ((c = getchar())) { X case 'C': X case 'P': X unimpl('D', c); X break; X case 'F': X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: do_DF();\n"); X } X if (debug1f) { X fprintf(errfp, "To: do_DF();\n"); X } X#endif X do_DF(); X break; X case 'I': X case 'R': X unimpl('D', c); X break; X default: X fprintf(stderr, "Bad instruction D%c\n", c); X exit(3); X } X break; X case 'E': X switch ((c = getchar())) { X case 'A': X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: do_Ex(TRUE);\n"); X } X if (debug1f) { X fprintf(errfp, "To: do_Ex(TRUE);\n"); X } X#endif X do_Ex(TRUE); X break; X case 'P': X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: do_EP();\n"); X } X if (debug1f) { X fprintf(errfp, "To: do_EP();\n"); X } X#endif X do_EP(); X break; X case 'R': X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: do_Ex(FALSE);\n"); X } X if (debug1f) { X fprintf(errfp, "To: do_Ex(FALSE);\n"); X } X#endif X do_Ex(FALSE); X break; X case 'W': X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: do_EW();\n"); X } X if (debug1f) { X fprintf(errfp, "To: do_EW();\n"); X } X#endif X do_EW(); X break; X default: X fprintf(stderr, "Bad instruction E%c\n", c); X exit(3); X } X break; X case 'F': X switch ((c = getchar())) { X case 'T': X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: do_FT();\n"); X } X if (debug1f) { X fprintf(errfp, "To: do_FT();\n"); X } X#endif X do_FT(); X break; X default: X fprintf(stderr, "Bad instruction F%c\n", c); X exit(3); X } X break; X case 'I': X switch ((c = getchar())) { X case 'M': X unimpl('I', c); X break; X case 'N': X unimpl('I', c); X break; X case 'P': X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: do_IP();\n"); X } X if (debug1f) { X fprintf(errfp, "To: do_IP();\n"); X } X#endif X do_IP(); X break; X case 'W': X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: do_IW();\n"); X } X if (debug1f) { X fprintf(errfp, "To: do_IW();\n"); X } X#endif X do_IW(); X break; X default: X fprintf(stderr, "Bad instruction I%c\n", c); X exit(3); X } X break; X case 'L': X switch ((c = getchar())) { X case 'B': X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: do_LB();\n"); X } X if (debug1f) { X fprintf(errfp, "To: do_LB();\n"); X } X#endif X do_LB(); X break; X case 'T': X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: do_LT();\n"); X } X if (debug1f) { X fprintf(errfp, "To: do_LT();\n"); X } X#endif X do_LT(); X break; X default: X fprintf(stderr, "Bad instruction L%c\n", c); X exit(3); X } X break; X case 'O': X switch ((c = getchar())) { X case 'A': X case 'C': X case 'D': X case 'E': X case 'F': X case 'H': X case 'I': X case 'O': X case 'P': X case 'S': X case 'W': X unimpl('O', c); X break; X default: X fprintf(stderr, "Bad instruction O%c\n", c); X exit(3); X } X break; X case 'P': X switch ((c = getchar())) { X case 'A': X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: do_Px(PA);\n"); X } X if (debug1f) { X fprintf(errfp, "To: do_Px(PA);\n"); X } X#endif X do_Px(PA); X break; X case 'G': X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: do_PG();\n"); X } X if (debug1f) { X fprintf(errfp, "To: do_PG();\n"); X } X#endif X do_PG(); X break; X case 'R': X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: do_Px(PR);\n"); X } X if (debug1f) { X fprintf(errfp, "To: do_Px(PR);\n"); X } X#endif X do_Px(PR); X break; X case 'U': X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: do_Px(PU);\n"); X } X if (debug1f) { X fprintf(errfp, "To: do_Px(PU);\n"); X } X#endif X do_Px(PU); X break; X case 'D': X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: do_Px(PD);\n"); X } X if (debug1f) { X fprintf(errfp, "To: do_Px(PD);\n"); X } X#endif X do_Px(PD); X break; X case 'S': X unimpl('P', 'S'); X break; X case 'T': X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: do_PT();\n"); X } X if (debug1f) { X fprintf(errfp, "To: do_PT();\n"); X } X#endif X do_PT(); X break; X default: X fprintf(stderr, "Bad instruction P%c\n", c); X exit(3); X } X break; X case 'R': X switch ((c = getchar())) { X case 'A': X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: do_Rx (RA)\n"); X } X if (debug1f) { X fprintf(errfp, "To: do_Rx (RA)\n"); X } X#endif X do_Rx(TRUE); X break; X case 'O': X unimpl('R', c); X break; X case 'R': X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: do_Rx (RR)\n"); X } X if (debug1f) { X fprintf(errfp, "To: do_Rx (RR)\n"); X } X#endif X do_Rx(FALSE); X break; X default: X fprintf(stderr, "Bad instruction R%c\n", c); X exit(3); X } X break; X case 'S': X switch ((c = getchar())) { X case 'A': X case 'C': X unimpl('S', c); X break; X case 'I': X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: do_SI();\n"); X } X if (debug1f) { X fprintf(errfp, "To: do_SI();\n"); X } X#endif X do_SI(); X break; X case 'L': X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: do_SL();\n"); X } X if (debug1f) { X fprintf(errfp, "To: do_SL();\n"); X } X#endif X do_SL(); X break; X case 'M': X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: do_SM();\n"); X } X if (debug1f) { X fprintf(errfp, "To: do_SM();\n"); X } X#endif X do_SM(); X break; X case 'P': X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: do_SP();\n"); X } X if (debug1f) { X fprintf(errfp, "To: do_SP();\n"); X } X#endif X do_SP(); X break; X case 'R': X case 'S': X unimpl('S', c); X break; X default: X fprintf(stderr, "Bad instruction S%c\n", c); X exit(3); X } X break; X case 'T': X if ((c = getchar()) == 'L') X unimpl('T', c); X else { X fprintf(stderr, "Bad instruction T%c\n", c); X exit(3); X } X break; X case 'U': X if ((c = getchar()) == 'C') X unimpl('U', c); X else { X fprintf(stderr, "Bad instruction U%c\n", c); X exit(3); X } X break; X case 'V': X if ((c = getchar()) == 'S') X while ((c = getchar()) != ';'); X else { X fprintf(stderr, "Bad instruction V%c\n", c); X exit(3); X } X break; X case 'W': X if ((c = getchar()) == 'G') { X#ifdef TESTVER X if (debug1c) { X fprintf(stderr, "To: do_WG();\n"); X } X if (debug1f) { X fprintf(errfp, "To: do_WG();\n"); X } X#endif X do_WG(); X } else { X fprintf(stderr, "Bad instruction W%c\n", c); X exit(3); X } X break; X case 'X': X if ((c = getchar()) == 'T') X unimpl('X', c); X else { X fprintf(stderr, "Bad instruction X%c\n", c); X exit(3); X } X case 'Y': X if ((c = getchar()) == 'T') X unimpl('Y', c); X else { X fprintf(stderr, "Bad instruction Y%c\n", c); X exit(3); X } X break; X default: X#ifdef TESTVER X fprintf(stderr, "Unimplemented instruction %cx\n", c); X fprintf(errfp, "Unimplemented instruction %cx\n", c); X#endif X break; X } X } X} X X Xskip_comments() X{ X int end_of_comment = FALSE; X int nested = 0; X X while (!end_of_comment) { X c = getchar(); X /* skip label */ X if (c == 'L') { X if ((c = getchar()) == 'B') { X while (getchar() != label_terminator); X } X } X if (c == '{') { X nested++; X } X if (c == '}') { X if (nested) { X nested--; X } else { X end_of_comment = TRUE; X } X } X } X X} X Xusage() X{ X#ifdef TESTVER X fprintf(stderr, X "Test version can only output to Epson LQ 1500, IBM Proprinter, "); X fprintf(stderr, X "or the screen.\n"); X fprintf(stderr, X "Use flag e or i for printer output, no flag for screen output.\n"); X#else X fprintf(stderr, "Usage: hpglplot -eiln\n"); X#endif X exit(1); X} END_OF_FILE if test 11906 -ne `wc -c <'main.c'`; then echo shar: \"'main.c'\" unpacked with wrong size! fi # end of 'main.c' fi echo shar: End of archive 3 \(of 3\). cp /dev/null ark3isdone MISSING="" for I in 1 2 3 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 3 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0