Skip to content
Snippets Groups Projects
Tree.cpp 672 B
Newer Older
#include <string>
#include <sstream>
#include <iostream>
#include <fstream>
#include "Tree.hpp"
#include "TreeNode.hpp"

namespace nbody {
	Tree::Tree() {
	}

	Tree::~Tree() {
		this->clean();
	}

	void Tree::clean() {
		while (!this->nodes.empty()) {
			delete this->nodes.back();
			this->nodes.pop_back();
		}

	vector<Body> Tree::dubinskiParse(string filename) {
		vector<Body> result;
		string line;
		ifstream infile(filename.c_str(), ifstream::in);
		double mass, px, py, pz, vx, vy, vz;

		while (infile >> mass >> px >> py >> pz >> vx >> vy >> vz) {
			Body b(px, py, pz, vx, vy, vz, mass);

			result.push_back(b);
		}
		infile.close();