示例#1
0
文件: road.cpp 项目: Khedesh/Traffic
void Road::append_to_file()
{
	/*std::ofstream fout(file, ios::out | ios::app);

	fout << "------------------------------------------" << endl;
	fout << "frame " << bounds[0]->get_clock()->get_time() << endl;

	for(unsigned i = 0 ; i < bounds.size() ; i ++)
	{
		fout << "road " << i << endl;
		Bound* b = bounds[i];
		for(int j = 0 ; j < b->get_car_count() ; j ++)
		{
			fout << "car " << b->get_car(j)->get_local_pos() << " " << b->get_car(j)->getCurrentSpeed() << endl;
		}
		fout << "endroad" << endl;
	}

	fout << "end" << endl;*/

	fprintf(fptr, "------------------------------------------\n");
	fprintf(fptr, "frame %f\n", bounds[0]->get_clock()->get_time());

	for(unsigned i = 0 ; i < bounds.size() ; i ++)
	{
		fprintf(fptr, "road %d\n", i);
		Bound* b = bounds[i];
		for(int j = 0 ; j < b->get_car_count() ; j ++)
		{
			fprintf(fptr, "car %f %f\n", b->get_car(j)->get_local_pos(), b->get_car(j)->getCurrentSpeed());
		}
		fprintf(fptr, "endroad\n");
	}

	fprintf(fptr, "end\n");
}