/***************************************************************************
                           corner.h
                           -------------------
    copyright            : (C) 2004 by Jos van den Oever
    email                : jos@vandenoever.info
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
#ifndef CORNER_H
#define CORNER_H
#include "rotenums.h"
/*
	 /\
	|\/|
         \/
	 /^\
	|\ /|
         \|/
	    5
	   /^\
	1/  2  \4
	|\     /|
	|  \0/  |
	| 0 | 1 |
	2\  |  /7
	   \|/
	    3
*/

/* global function that returns an integer random number from [0, max>. */
extern short rand(short);
class Corner {
public:
	Symmetry sym[3];
	short type[3];
	short cor[3];
	void reduceCorner();
	short mapcor(short i, short j) const;
	bool operator==(const Corner &c) const;
	short count(short, Symmetry) const;
	bool isBlank() const;
	bool is2_3Blank() const;
};
class CubeDecoration;
class Question;
class Corners {
private:
	Corner orig[8];
	void setCorners(Corner o[8], const CubeDecoration &c, bool) const;
	bool checkCorner(const Corner &, const Question &) const;
public:
	Corners(const CubeDecoration &);
	short chooseOrientation(const CubeDecoration&c, const Question&,
		Corner &visc) const;
	const Corner &operator[](short i) const { return orig[i];}
};
#endif
