Skip to content
Snippets Groups Projects
BarnesHutTree.cpp 434 B
Newer Older
#include "BarnesHutTree.hpp"

namespace nbody {
	BarnesHutTree::BarnesHutTree() {
		this->root = NULL;
	}

	BarnesHutTree::~BarnesHutTree() {
		delete this->root;
		this->root = NULL;
	}

	void BarnesHutTree::build(vector<Body> bodies) {
		delete this->root;
		this->root = new TreeNode();
Paul Heinzlreiter's avatar
Paul Heinzlreiter committed
		std::copy(bodies.begin(), bodies.end(), this->root->bodies.begin());
		this->root->extendBBforBodies();
		this->root->extendBBtoCube();