/*
 * Filename: bedlam.h
 * Revision: 19981008
 */

#ifndef _BEDLAM_H
#define _BEDLAM_H

#include "container.h"
#include "shape.h"
#include "wireframe.h"

#include "config.h"

class bedlam  
{
public:
	bedlam ();
	bedlam (struct wire_frame *);
	~bedlam ();

	// Setup the shape/orientation lookup table
	void init_shapes (struct wire_frame *);

	// Remove duplicate orientations from the lookup table
	void remove_dupes (void);

	// Load and save functions
	void load (fstream &);
	void save (fstream &);

	// Start solving the cube
	void solve (int, int);

	// Dump everything in the bedlam cube solver - so manual inspection of everything can be made
	void status (void);

	// Find which shape is used at a particular level of recursion
	int find_used_shape (int);

	// Mail the MAIL_TO person
	void do_mail (void (*)(void));

private:
	// next_shape() tries the next shape
	void next_shape (void);

	// do_orientations() tries all unique orientations with the given shape
	void do_orientations (int);

	// do_coords() tries all possible combinations with the given shape in
	// the set orientation
	void do_coords (int, int);

public:
	shape **all_shapes;		// An array of pointers to all of the shapes in all
							// orientations. A NULL in the array means its a
							// duplicate orientation
	shape **used_shapes;	// A pointer to the used shape array
	container **boxes;		// A pointer to an array of containers at each
							// level of recursion
	int first_shape;		// The shape to start with
	int last_shape;			// The shape to finish with
	int level;				// The recursion level we are at
};

#endif
