/* * Header Begins--Do not remove################################################ * * Driver that gets points interactively from the user's mouse and * plots a spline through them until the user depresses the right-hand * button. * * (c) Eugene Fiume, University of Toronto, 1995. * * You are permitted to use this code for noncommercial, educational * purposes only. This header must not be removed from this file. * * Header Ends--Do not remove################################################## */ #include #include "X.h" #include "Spline.h" main(argc, argv) int argc; char *argv[]; { int done = FALSE; int s,eval; RealPoint2D pt; printf("Interpolation Demonstration.\n\n"); printf("Choose a cubic spline.\n"); printf(" %d = Catmull-Rom\n",CubicCatmullRom); printf(" %d = B-Spline\n",CubicBSpline); printf(" %d = Bezier\n",CubicBezier); printf(" %d = Lagrange\n",CubicLagrange); done = FALSE; while (!done) { if (scanf("%d", &s) == EOF) exit(1); if ((s <= 0) || (s >= NumberOfSplines)) fprintf(stderr, "Enter something reasonable, eh?\n"); else done = TRUE; } SetUpSpline(s, 16, 0); printf("\nChoose an evaluation method.\n"); printf(" %d = Direct matrix multiplication\n", DirectTM); printf(" %d = Premultiply to get coefficients\n",DirectMP); printf(" %d = Horner's rule (which implies 2)\n",Horner); printf(" %d = Forward differencing\n",ForwardDiff); printf(" %d = Table Lookup\n",TableLookup); done = FALSE; while (!done) { if (scanf("%d", &eval) == EOF) exit(1); if ((eval < 0) || (eval > Evaluations)) fprintf(stderr, "Enter something reasonable, eh?\n"); else done = TRUE; } SetEvaluation(eval); printf("\nDepress left mouse button at desired points.\n"); printf("Stop execution by depressing right-hand button.\n\n"); XOpen(500,500, argc, argv); done = FALSE; do { pt = GetMouseButtonPush(); if (pt.x < 0.0) done = TRUE; else AddControlPoint(pt); } while (!done); }