#ifndef lint
static char *sccsid = "@(#)main.c	1.2 (UKC) 9/12/87";
#endif  lint
/*
 *	Main program for hidden line removal package
 */
#include <stdio.h>
#include "types.h"

#define TILT 21				/* default tilt */
#define ROTATE 0			/* default rotation */

linelist_t *linelist = NULLLINE;	/* list of edges to clip and plot */
trilist_t *trilist = NULLTRI;		/* list of obscuring triangles */

static char *progname;			/* argv[0] for error reporting */

main(argc, argv)
char **argv;
{
	linelist_t *lp;
	int tilt = TILT;
	int rotate = ROTATE;

	progname = argv[0];

	inittrans(tilt, rotate);

	genpoly(argc, argv);

	compute_abch();
	remove_backfaces();
	
	openpl();
	space(0, 0, 4096, 4096);	/* suitable for digs format */

	for (lp = linelist; lp != NULLLINE; lp = lp->link) {
		/* linesegment calls outputline to do its dirty work */
		linesegment(lp->P.x, lp->P.y, lp->P.z,
			    lp->Q.x, lp->Q.y, lp->Q.z,
			    trilist);
	}
	closepl();
	exit(0);
}

error(message)
char *message;
{
	/* may be run with stty -graph for tek, so output CRs */
	fprintf(stderr, "\r%s: %s.\r\n", progname, message);
}
