Exemple #1
0
void tex::make_accent ()
	{
	fnt	f;
	qcell	i;
	ptr	p, q, r;
	scal	a, h, w, x;
	float	s, t;
	scal	delta;

	scan_char_num();
	f = cur_font;
	p = new_character(f, cur_val);
	if (p != null) {
		x = x_height(f);
		s = (float) slant(f) / 65536.0;
		a = char_width(f, char_info(f, character(p)));
		do_assignments();
		q = null;
		f = cur_font;
		if (cur_cmd == LETTER
		|| cur_cmd == OTHER_CHAR
		|| cur_cmd ==  CHAR_GIVEN) {
			q = new_character(f, cur_chr);
		} else if (cur_cmd ==  CHAR_NUM) {
			scan_char_num();
			q = new_character(f, cur_val);
		} else {
			back_input();
		}
		if (q != null) {
			t = (float) slant(f) / 65536.0;
			i = char_info(f, character(q));
			w = char_width(f, i); 
			h = char_height(f, height_depth(i));
			if (h != x) {
				p = hpack(p, 0, ADDITIONAL);
				shift_amount(p) = x - h;
			}
			delta = round((float) (w - a) / 2.0 + h * t - x * s);
			r = new_kern(delta);
			subtype(r) = ACC_KERN;
			link(tail) = r;
			link(r) = p;
			tail = new_kern(-a - delta);
			subtype(tail) = ACC_KERN;
			link(p) = tail;
			p = q;
		}
		tail_append(p);
		space_factor = 1000;
		}
	}
Exemple #2
0
int main(void)
{
	/* Setup */
	struct _challenge j_chal[5];
	struct _challenge s_chal[5];
	FILE *fp;

	char *output_filename;

	int num_j_chal, num_s_chal=0, i, j, x, y;
	int ichal;

	j_chal[0].name = "J1";
	j_chal[0].num_tables = 2;
	j_chal[0].rounds_per_team = 2;
	j_chal[0].timeslot_length = 5;
	j_chal[0].teams_per_timeslot = 1;
	j_chal[0].num_minutes = num_minutes - 30;
	j_chal[0].lunch_length = 45;
	j_chal[0].start_minute = 10;

	j_chal[1].name = "J2";
	j_chal[1].num_tables = 2;
	j_chal[1].rounds_per_team = 2;
	j_chal[1].timeslot_length = 6;
	j_chal[1].teams_per_timeslot = 1;
	j_chal[1].num_minutes = num_minutes - 10;
	j_chal[1].lunch_length = 45;
	j_chal[1].start_minute = 0;

	j_chal[2].name = "J3-White";
	j_chal[2].num_tables = 3;
	j_chal[2].rounds_per_team = 3;
	j_chal[2].timeslot_length = 5;
	j_chal[2].teams_per_timeslot = 2;
	j_chal[2].num_minutes = num_minutes - 80;
	j_chal[2].lunch_length = 30;
	j_chal[2].start_minute = 0;

	j_chal[3].name = "J3-Black";
	j_chal[3].num_tables = 1;
	j_chal[3].rounds_per_team = 3;
	j_chal[3].timeslot_length = 5;
	j_chal[3].teams_per_timeslot = 2;
	j_chal[3].num_minutes = num_minutes - 85;
	j_chal[3].lunch_length = 30;
	j_chal[3].start_minute = 0;

	j_chal[4].name = "J4";
	j_chal[4].num_tables = 1;
	j_chal[4].rounds_per_team = 3;
	j_chal[4].timeslot_length = 4;
	j_chal[4].teams_per_timeslot = 1;
	j_chal[4].num_minutes = num_minutes - 30;
	j_chal[4].lunch_length = 30;
	j_chal[4].start_minute = 40;

	num_j_chal = 5;

	s_chal[0].name = "S1";
	s_chal[0].num_tables = 2;
	s_chal[0].rounds_per_team = 2;
	s_chal[0].timeslot_length = 7;
	s_chal[0].teams_per_timeslot = 1;
	s_chal[0].num_minutes = num_minutes- 10;
	s_chal[0].lunch_length = 30;
	s_chal[0].start_minute = 0;

	s_chal[1].name = "S2";
	s_chal[1].num_tables = 2;
	s_chal[1].rounds_per_team = 2;
	s_chal[1].timeslot_length = 8;
	s_chal[1].teams_per_timeslot = 1;
	s_chal[1].num_minutes = num_minutes -10;
	s_chal[1].lunch_length = 30;
	s_chal[1].start_minute = 0;

	s_chal[2].name = "S3";
	s_chal[2].num_tables = 2;
	s_chal[2].rounds_per_team = 3;
	s_chal[2].timeslot_length = 6;
	s_chal[2].teams_per_timeslot = 2;
	s_chal[2].num_minutes = num_minutes - 60;
	s_chal[2].lunch_length = 30;
	s_chal[2].start_minute = 0;

	s_chal[3].name = "S4";
	s_chal[3].num_tables = 1;
	s_chal[3].rounds_per_team = 3;
	s_chal[3].timeslot_length = 5;
	s_chal[3].teams_per_timeslot = 1;
	s_chal[3].num_minutes = num_minutes - 30;
	s_chal[3].lunch_length = 45;
	s_chal[3].start_minute = 40;

	s_chal[4].name = "S5";
	s_chal[4].num_tables = 1;
	s_chal[4].rounds_per_team = 3;
	s_chal[4].timeslot_length = 5;
	s_chal[4].teams_per_timeslot = 1;
	s_chal[4].num_minutes = num_minutes- 30;
	s_chal[4].lunch_length = 45;
	s_chal[4].start_minute = 40;

	num_s_chal = 5;

	/* Build timeslots */

	for(i=0;i<2;i++) {

		int h, m;

		if(i==0) {
			challenges = &j_chal[0];
			num_challenges = num_j_chal;
			output_filename = "j.csv";
			junior = 1;
		} else {
			challenges = &s_chal[0];
			num_challenges = num_s_chal;
			output_filename = "s.csv";
			junior = 0;
		}
		
		num_tables = 0;
		for(ichal=0;ichal<num_challenges; ichal++) {
			struct _challenge *c = &challenges[ichal];
			int len = num_minutes;
			int num_timeslots = len / c->timeslot_length;
			int offset = c->timeslot_length/2;

			printf("%s: %d tables, %dx each team, %d timeslots * %d minutes\n", 
					c->name, c->num_tables, c->rounds_per_team, num_timeslots, c->timeslot_length);

			c->tables = malloc(sizeof(struct _table) * c->num_tables);
			for(j=0;j<c->num_tables;j++) {
				struct _table *t = &c->tables[j];
				t->num_timeslots = num_timeslots;
				t->timeslots = malloc(sizeof(struct _timeslot) * num_timeslots);
				t->offset = j % 2 == 0 ? 0 : offset;
				t->x_index = num_tables;
				for(x=0;x<num_timeslots;x++) {
					struct _timeslot *ts = &t->timeslots[x];
					ts->start_time = c->start_time + t->offset + x * c->timeslot_length;
					ts->num_teams = c->teams_per_timeslot;
					ts->teams = malloc(ts->num_teams * sizeof(int));
				}
				num_tables += 1;
			}
		}

		schedule = (int **)malloc(sizeof(int *) * num_tables);
		partner_schedule = (int **)malloc(sizeof(int *) * num_tables);

		
		if(i==0) {
			load_teams("j.txt");
		} else {
			load_teams("s.txt");
		}
		

		team_schedule = (int **)malloc(sizeof(int *) * num_teams);

		/* Clean out the schedule */
		for(x=0;x<num_tables;x++) {
			schedule[x] = malloc(sizeof(int) * num_minutes);
			partner_schedule[x] = malloc(sizeof(int) * num_minutes);
			for(y=0;y<num_minutes;y++) {
				schedule[x][y] = -1;
				partner_schedule[x][y] = -1;
			}
		}
		/* Clean out the team schedule */
		for(x=0;x<num_teams;x++) {
			team_schedule[x] = malloc(sizeof(int) * num_minutes);
			for(y=0;y<num_minutes;y++) {
				team_schedule[x][y] = -1;
			}
		}

		/* Mark breaks and lunches */
		for(x=0;x<num_challenges; x++) {
			struct _challenge *c = &challenges[x];
			for(j=0;j<c->num_tables;j++) {
				mark_breaks(x, j);
			}
		}

		do_assignments();


		/* Print schedule and build a team schedule map */
		printf("Time    ");
		for(j=0;j<num_challenges;j++) {
			for(y=0;y<challenges[j].num_tables;y++) {
				printf("%8s-%d ", challenges[j].name, y);
			}
		}
		printf("\n");
		for(x=0;x<num_minutes;x++) {
			printf("%6d  ", x);
			for(j=0;j<num_challenges;j++) {
				for(y=0;y<challenges[j].num_tables;y++) {
					struct _table *t = &challenges[j].tables[y];
					int iteam = schedule[t->x_index][x];
					int ipartner_team = partner_schedule[t->x_index][x];
					if(ipartner_team >= 0) {
						printf("%3d,%3d    ", iteam, ipartner_team);
						team_schedule[iteam][x] = t->x_index;
						team_schedule[ipartner_team][x] = t->x_index;
					} else {
						printf("%6d     ", iteam);
						if(iteam >= 0) {
							team_schedule[iteam][x]= t->x_index;
						}
					}
				}
			}
			printf("\n");
		}

		/* Write .CSV files */

		fp = fopen(output_filename, "wt");
		fprintf(fp, "By Area:\nTime,");
		for(j=0;j<num_challenges;j++) {
			for(y=0;y<challenges[j].num_tables;y++) {
				if(challenges[j].teams_per_timeslot != 2) {
					fprintf(fp,"%s-%d,", challenges[j].name, y+1);
				} else  {
					fprintf(fp,"%s-%dL,", challenges[j].name, y+1);
					fprintf(fp,"%s-%dR,", challenges[j].name, y+1);
				}
			}
		}
		fprintf(fp, "\n");
		h=10;
		m=20;
		for(x=0;x<num_minutes;x++) {
			fprintf(fp, "%02d:%02d, ", h,m);
			for(j=0;j<num_challenges;j++) {
				for(y=0;y<challenges[j].num_tables;y++) {
					struct _table *t = &challenges[j].tables[y];
					if(schedule[t->x_index][x] == -3) {
						fprintf(fp, ", ");
					} else if(schedule[t->x_index][x] == -2) {
						fprintf(fp, "Lunch, ");
					} else if(schedule[t->x_index][x] == -1) {
						fprintf(fp, ", ");
					} else {
						fprintf(fp, "%6d, ", teams[schedule[t->x_index][x]].id);	
					}

					if(challenges[j].teams_per_timeslot != 2) {
						; /* DO ntohing */

					} else 	if(schedule[t->x_index][x] == -3) {
						fprintf(fp, ", ");
					} else if(schedule[t->x_index][x] == -2) {
						fprintf(fp, "Lunch, ");
					} else if(schedule[t->x_index][x] == -1) {
						fprintf(fp, ", ");
					} else {
						fprintf(fp, "%6d, ", teams[partner_schedule[t->x_index][x]].id);
					}
				}
			}
			fprintf(fp, "\n");
			m++;
			if(m==60) {
				m=0;
				h++;
			}
		}
		fprintf(fp, "By Team:\n");
		fprintf(fp, "Time, ");
		for(j=0;j<num_teams;j++) {
			fprintf(fp, "%d,", teams[j].id);
		}
		fprintf(fp, "\n");
		h=10;
		m=2;
		for(x=0;x<num_minutes;x++) {
			fprintf(fp, "%02d:%02d, ", h,m);
			for(j=0;j<num_teams;j++) {
				int x_index = team_schedule[j][x];
				int ichal, itable;

				if(x_index >= 0 ) {
					/* Find the chal/area for this x_index */
					get_challenge_and_table_for_index(x_index, &ichal, &itable);
					fprintf(fp, "%s-%d,", challenges[ichal].name, itable+1);
				} else {
					fprintf(fp, " ,");
				}
			}
			fprintf(fp, "\n");
			m++;
			if(m==60) {
				m=0;
				h++;
			}
		}
		fprintf(fp, "By Team:\n");
		fclose(fp);
		
	}

	/* Do initial assignments */

	printf("All done!\n");

	return 0;
}