Exemple #1
0
int main(int argc, char **argv) {
	unsigned short width, height;
	unsigned char wfactor;

	calc_window window;

	// Set defaults
	window.width = XRES;
	window.height = YRES;
	window.xmax = XMAX;
	window.xmin = XMIN;
	window.ymax = YMAX;
	window.ymin = YMIN;
	window.tstep = TSTEP;
	window.steps = TSTEP*STEPSS;
	window.tmax = TMAX;
	window.offset = 0;
	
	parse_opts(argc, argv, &window);

	printf("Producing image of %dx%d...\n\n", window.width, window.height);
	printf("View window:\n");
	printf("  x = [%f, %f]\n", window.xmin, window.xmax);
	printf("  y = [%f, %f]\n\n", window.ymin, window.ymax);

	char imagedata[window.width*window.height];

        if (window.xmin == -window.xmax) {
                wfactor = 2;
		printf("Image symmetric, only calculating half.\n");
		window.xmin = 0.;
		window.width = window.width/wfactor;
        } else {
                wfactor = 1;
        }
	
	double buffer[window.width*window.height];

	printf("Allocating memory... ");
	calc_params*** data;
	
	data = allocate_data(window.width, window.height);
	
	printf("done.\n");
		
	char basename[255];
	char tiffile[255];
	char bmpfile[255];
	char command[255];

	double t=0.;

	char endless;
	if (window.tmax < 0) {
		endless = 1;
		printf("\nStarted calculating until the end of time\n");
	} else {
		endless = 0;
		printf("\nStarted calculating until time is %f\n", window.tmax);
	}

	while (endless || t<window.tmax) {
		t = window.tstep*(window.offset+1);
		
		printf("\nFrame: %d Range: %f-%f\n", window.offset+1, window.tstep*window.offset, t);
		calc_image(buffer, data, &window);

		doubletochar(window.width * window.height, buffer, imagedata);
		
		if (wfactor == 2) duplicate_data(window.width*wfactor, window.height, imagedata);

		snprintf(basename, 255, "imgs/%.5d", window.offset);
		snprintf(tiffile, 255, "%s.tif", basename);
		snprintf(bmpfile, 255, "%s.bmp", basename);

		writetiff(tiffile, window.width*wfactor, window.height, imagedata);

#ifdef FINISH
		// This requires ImageMagick
		printf("Converting and scaling...\n");
		snprintf(command, 255, "convert -contrast -depth 24 -type truecolor -resize 50%% %s %s", tiffile, bmpfile);
		execute(command);

                snprintf(command, 255, "rm %s", tiffile);
		execute(command);
#endif
		window.offset++;
	}

	printf("\n%d frames written.\n", window.offset);
	printf("Done enough, dozing off for bed...\n");
							
			
	return EXIT_SUCCESS;
}
 int duplicate_sender_manager::direct_send(int area, const data_entry* key, const data_entry* value, int expire_time,
           int bucket_number, const vector<uint64_t>& des_server_ids, uint32_t max_packet_id)
 {
    return duplicate_data(area,key,value,expire_time,bucket_number,des_server_ids,NULL,0);
 }