
#ifndef _JL_Bounds4d_H_
#define _JL_Bounds4d_H_


#include <stdlib.h>
#include <iostream.h>

#include "vec4.h"

class Ray;
class Bounds3d;


class Bounds4d {

	private:
		real	_a1, _a2;		// min/max a
		real	_b1, _b2;		// min/max b
		real	_c1, _c2;		// min/max c
		real	_d1, _d2;		// min/max d

	public: 
		Bounds4d()
			{ _a1 = _b1 = _c1 = _d1 = -1.0f; _a2 = _b2 = _c2 = _d2 = 2.0f; }

/*  Shouldn't ever have to use this
		Bounds4d(real a1, real a2, real b1, real b2,
				 real c1, real c2, real d1, real d2) {
				_a1 = a1; _a2 = a2;
				_b1 = b1; _b2 = b2;
				_c1 = c1; _c2 = c2;
				_d1 = d1; _d2 = d2;
			}
*/

		Bounds4d(const Bounds4d &B) { CopyFrom(B); }
		~Bounds4d() { }

		Bounds4d& CopyFrom(const Bounds4d &B) {
				_a1 = B._a1; _a2 = B._a2;
				_b1 = B._b1; _b2 = B._b2;
				_c1 = B._c1; _c2 = B._c2;
				_d1 = B._d1; _d2 = B._d2;
				return *this;
			}

		Bounds4d& operator=(const Bounds4d &B) { return CopyFrom(B); }

		friend ostream& operator<<(ostream&, const Bounds4d&);

		void Set(real a1, real a2, real b1, real b2,
				 real c1, real c2, real d1, real d2) {
				_a1 = a1; _a2 = a2;
				_b1 = b1; _b2 = b2;
				_c1 = c1; _c2 = c2;
				_d1 = d1; _d2 = d2;
			}

		real a1() const { return _a1; }
		real a2() const { return _a2; }
		real b1() const { return _b1; }
		real b2() const { return _b2; }
		real c1() const { return _c1; }
		real c2() const { return _c2; }
		real d1() const { return _d1; }
		real d2() const { return _d2; }

		void Half_a_min() { _a2 = (_a1 + _a2) * 0.5f; }
		void Half_a_max() { _a1 = (_a1 + _a2) * 0.5f; }
		void Half_b_min() { _b2 = (_b1 + _b2) * 0.5f; }
		void Half_b_max() { _b1 = (_b1 + _b2) * 0.5f; }
		void Half_c_min() { _c2 = (_c1 + _c2) * 0.5f; }
		void Half_c_max() { _c1 = (_c1 + _c2) * 0.5f; }
		void Half_d_min() { _d2 = (_d1 + _d2) * 0.5f; }
		void Half_d_max() { _d1 = (_d1 + _d2) * 0.5f; }

		void Draw(int major_plane, const Bounds3d &relative_to);
};

#endif
