Esempio n. 1
0
/*******************************************************************************
*
* Name: CreateEngineAndConnectToViewer
*
* Purpose: Intialize the engine and connect to the viewer.
*
* Author: Jeremy Meredith, B Division, Lawrence Livermore National Laboratory
*
* Modifications:
*
*******************************************************************************/
static int CreateEngineAndConnectToViewer(void)
{
    /* get the engine */
    engine = v_getengine();
    if (!engine)
    {
        return FALSE;
    }

    if (!v_initialize(engine, engine_argc, engine_argv))
    {
        VisItDisconnect();
        return FALSE;
    }

    if (!v_connectviewer(engine, engine_argc, engine_argv))
    {
        VisItDisconnect();
        return FALSE;
    }

    return TRUE;
}
Esempio n. 2
0
int main (int argc, char ** argv)
{
	struct world *world;
	FILE *f;
	int c, ret;
	int head_steps, tail_steps, skip_steps, next_step;
	int ants_count, resolution;
	int step;
	int performance_test;
	int window_width;
	int window_height;
	int hex_size;

	dump_format = 0;
	step = 0;
	head_steps = 0; 
	tail_steps = 0; 
	skip_steps = 1;
	performance_test = 0;

	window_width = 800;
	window_height = 614;
	hex_size = 3;

/* These are used for dump format, since it is difficult to figure them out. */
	resolution = 10;
	ants_count = 32;

	world = NULL;

	while ((c=getopt (argc, argv, "wdh:t:s:a:p:W:H:c:")) != EOF) {
		switch (c) {
		case 'd': dump_format = 1; break;
		case 't': 
			if (!optarg) usage_and_exit (argv[0]);
			tail_steps = atoi (optarg); break;
		case 's': 
			if (!optarg) usage_and_exit (argv[0]);
			skip_steps = atoi (optarg); break;
                case 'r':
                        if (!optarg) usage_and_exit (argv[0]);
                        resolution = atoi (optarg); break;
                case 'a':
                        if (!optarg) usage_and_exit (argv[0]);
                        ants_count = atoi (optarg); break;
		case 'h': 
			if (!optarg) usage_and_exit (argv[0]);
			head_steps = atoi (optarg); break;
		case 'w': warnings = 1; break;
		case 'p': 
			if (!optarg) usage_and_exit (argv[0]);
			performance_test = atoi (optarg); 
			break;
		case 'W': 
			if (!optarg) usage_and_exit (argv[0]);
			window_width = atoi (optarg); break;
		case 'H': 
			if (!optarg) usage_and_exit (argv[0]);
			window_height = atoi (optarg); break;
		case 'c': 
			if (!optarg) usage_and_exit (argv[0]);
			hex_size = atoi (optarg); break;
		
		case '?': 
		default: usage_and_exit (argv[0]);
		}
	}

	if (skip_steps < 1 || tail_steps < head_steps) {
		fprintf (stderr, "Illegal step setting.\n");
		exit (-1);
	}

	if (dump_format) {
		next_step = head_steps;
		f = open_next_file_from_argv (argv);

		v_set_geometry (window_width, window_height, hex_size);
		v_initialize ();
		while (!feof (f)) {
			if (read_world_as_icfp_dump (&world, f, resolution, resolution, ants_count) == 0) {
				if (step <= head_steps ||
                                    step >= tail_steps ||
                                    step == next_step) {
					printf ("Step %d ...\n", step);
					display_world (world);
		    	    	    	v_refit_view ();
					if ((ret = v_poll_event (0))) {
					    if (ret == -1) {
						break;
					    }
					}

					next_step = skip_steps+step;
				}
			}
			step++;
		}
		fclose (f);
	} else {
		f = open_next_file_from_argv (argv);
		if (read_world (&world, f) != 0) {
			fprintf (stderr, "Error in reading world map.\n");
			exit (-1);
		}
		fclose (f);

		f = open_next_file_from_argv (argv);
		if (parse_world_trace (world, f) != 0) {
			fprintf (stderr, "Error in reading world trace.\n");
			exit (-1);
		}
		fclose (f);

		v_set_geometry (window_width, window_height, hex_size);
		v_initialize ();
		display_world (world);
		// v_refit_view ();
	}

	if (performance_test) {
		return run_performance_test (world, performance_test);
	} else {
		return run_main_loop (world);
	}
}