#include <iostream.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fstream.h>
#include <iomanip.h>
#include <time.h>
#include <math.h>





const int max_file_name = 100;
const double pi = atan(1.0)*4;
const int max_line_length = 100;

#include "read_file.cpp"
using namespace std;

int main(int argc, char *argv[])
{

	char input_file_name[max_file_name];
	strcpy(input_file_name, "input.txt");


	ifstream in(input_file_name, ios::in);


	if (!in)
	{
		cerr << "File could not be opened" << endl;
		exit(1);
	}

	long get_pointer_start;
	get_pointer_start = in.tellg();

	//First get the first line which has an input_comment in it
	char input_comment[max_line_length];
	strcpy(input_comment, get_line(in));
	cout << input_comment << endl;

	// first set up a temp variable for the current position of the get pointer
	long temp;

	in.seekg(get_pointer_start);
	temp = find_string(in, "##number_of_particles##");
	double number_of_particles;
	number_of_particles = get_double(in);
	printf("The number of particles = %e \n", number_of_particles);

	in.seekg(get_pointer_start);
	temp = find_string(in, "##slab_x_in_cm##");
	double slab_x_in_cm=get_double(in);
	printf("The slab length x = %.2f \n", slab_x_in_cm);

	in.seekg(get_pointer_start);
	temp = find_string(in, "##slab_y_in_cm##");
	double slab_y_in_cm = get_double(in);
	printf("The slab_y_in_cm = %.2f \n", slab_y_in_cm);

	in.seekg(get_pointer_start);
	temp = find_string(in, "##macro_cross_section_1_over_cm##");
	double macro_cross_section_1_over_cm = get_double(in);
	printf("The macro_cross_section_1_over_cm = %f \n", macro_cross_section_1_over_cm);

	in.seekg(get_pointer_start);
	temp = find_string(in, "##scattering_probability##");
	char scatt_prob_dist[max_line_length];
	char temp2[max_line_length];
	strcpy(temp2, get_line(in));
	strcpy(scatt_prob_dist, get_line(in));
	cout << "The scattering_probability_dist is " << scatt_prob_dist << endl;
	if(strcmp("uniform", scatt_prob_dist) == 0)
	{
		double scatt_x_start = get_double(in);
		double scatt_x_end = get_double(in);
		double scatt_y_start = get_double(in);
		cout << endl << scatt_x_start << "  " << scatt_x_end << "   " << scatt_y_start << endl;
	}
	else
	{
		if(strcmp("linear", scatt_prob_dist) == 0)
		{
			double scatt_x_start = get_double(in);
			double scatt_x_end = get_double(in);
			double scatt_y_start = get_double(in);
			double scatt_y_end = get_double(in);
			cout << endl << scatt_x_start << "  " << scatt_x_end << "   " << scatt_y_start << scatt_y_end << endl;
		}
		else
		{
			if(strcmp("hat", scatt_prob_dist) == 0)
			{
				double scatt_x_start = get_double(in);
				double scatt_x_end = get_double(in);
				double scatt_y_midpoint = get_double(in);
				cout << endl << scatt_x_start << "  " << scatt_x_end << "   " << scatt_y_midpoint << endl;
			}
		}

	}
			
	

	//printf("The scattering_probability_dist is %s\n", scatt_prob_dist);
	
	double scattering_probability = get_double(in);
	printf("The scattering_probability = %f \n", scattering_probability);






    in.seekg(get_pointer_start);
	temp = find_string(in, "##source_energy_distribution##");
	char source_energy_dist[max_line_length];
	strcpy(temp2, get_line(in));
	strcpy(source_energy_dist, get_line(in));
	
	double source_energy_distribution1 = get_double(in);
	double source_energy_distribution2 = get_double(in);
	double source_energy_distribution3 = get_double(in);


	printf("The source_energy_distribution1 = %f \n", source_energy_distribution1);
	printf("The source_energy_distribution2 = %f \n", source_energy_distribution2);
	printf("The source_energy_distribution3 = %f \n", source_energy_distribution3);




	return 0;
}
	
		
	
	

