#ifndef BOX_HPP
#define BOX_HPP

#include <vector>
#include <array>
#include <Body.hpp>

namespace nbody {
	struct Box {
		std::array<double, 3> min;
		std::array<double, 3> max;

		Box();
		void extendToCube();
		void extendForBodies(const std::vector<Body>& bodies);
		std::vector<Body> extractBodies(std::vector<Body>& bodies) const;
		std::vector<Body> copyBodies(const std::vector<Body>& bodies) const;
		double volume() const;
		double maxSidelength() const;
		bool isCorrectBox() const;
		bool isValid() const;
		void printBB(int parallelId) const;
		bool overlapsSphere(const double* sphereCenter, double sphereRadius) const; //TODO(steinret): double* srsly?
		double distanceToPosition(const double* position) const;
		double distanceToBox(const Box& box2) const;
		std::vector<Box> octreeSplit() const;
		std::vector<Box> splitLongestSide() const;
		bool contained(const std::array<double, 3>& position) const;
		void extend(const Box& extender);
		void extend(const Body& extender);
	};
	bool isContained(const Body& body, const Box& box);
	bool isContained(const Box& inner, const Box& outer);

}

#endif
