/**********************************************************************/ /* */ /* (c) Copyright, 1997 by Professor Gabriel Robins */ /* */ /* Department of Computer Science, University of Virginia */ /* Charlottesville, VA 22903-2442 (804) 982-2207 */ /* robins@cs.virginia.edu http://www.cs.virginia.edu/~robins/ */ /* */ /* This code may be freely used for all non-commercial purposes. */ /* All copies/portions of this code must contain this header. */ /* */ /**********************************************************************/ /**********************************************************************/ /* main.c */ /**********************************************************************/ #include "geometry.h" int choice; /**********************************************************************/ main(int argc, char *argv[] ) { int h1, h2,run_count=0; init_vars(); /* randomize_seed(); */ #ifdef MAC InitMacintosh(); SetUpMenus(); SetUpWindow( argc, argv); erase_window(); generate_random_points(); draw_points(); for (;;) HandleEvent(CGWindow); #endif #ifdef SUN SetUpWindow( argc, argv); interactive(); #else interactive(); #endif } /**********************************************************************/ void interactive(void) { int get_seed, old_noi, old_nop; printf("Choose: 1) Random pointsets, 2) Read in pointset, or 3) Automatic runs: "); scanf("%d", &choice); if(choice==1) { printf("Enter the number of points: "); scanf("%d", &number_of_points); printf("Enter the number of iterations: "); scanf("%d", &number_of_iterations); printf("Enter the gridsize: "); scanf("%d", &grid_size); printf("Enter the initial random seed (0 for random): "); scanf("%d", &get_seed); if(get_seed==0) { printf("randomizing seed!\n"); randomize_seed(); } else next = (unsigned long int) get_seed; loop_stats(); } else if(choice==2) { printf("Enter the number of points: "); scanf("%d", &number_of_points); printf("Enter the gridsize: "); scanf("%d", &grid_size); old_noi = number_of_iterations; old_nop = number_of_points; read_in_pointset(); number_of_iterations = 1; loop_stats(); number_of_iterations = old_noi; number_of_points = old_nop; } else if(choice==3) { printf("Enter the number of iterations: "); scanf("%d", &number_of_iterations); printf("Enter the initial random seed (0 for random): "); scanf("%d", &get_seed); if(get_seed==0) { printf("randomizing seed!\n"); randomize_seed(); } else next = (unsigned long int) get_seed; multi_loop_stats(); } } /********************************************************************* This function reads in a pointset. *********************************************************************/ void read_in_pointset(void) { int x, y, i = 0; printf("Enter the pairs of integer coordinates of each point : \n"); /* printf("end with -1, -1 if want to print out #SP and their coordinates\n"); printf("otherwise end with (-0, -0) \n"); while(YES) { if(scanf("%d %d", &x, &y) < 0) break; if(x < 0) break; pointset[i].X = x; pointset[i].Y = y; pointset[i].flag = NO; pointset[i].id = generate_unique_identifier(); i++; } number_of_points = i; */ for (i=0; i< number_of_points; i++) { scanf("%d %d", &x, &y); pointset[i].X = x; pointset[i].Y = y; /* pointset[i].flag = NO; pointset[i].id = generate_unique_identifier(); */ } } /**********************************************************************/