00001 /* BurrTools 00002 * 00003 * BurrTools is the legal property of its developers, whose 00004 * names are listed in the COPYRIGHT file, which is included 00005 * within the source distribution. 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation; either version 2 00010 * of the License, or (at your option) any later version. 00011 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00020 */ 00021 #ifndef __VOXEL_TABLE_H__ 00022 #define __VOXEL_TABLE_H__ 00023 00024 class puzzle_c; 00025 class voxel_c; 00026 00048 class voxelTable_c { 00049 00050 private: 00051 00053 typedef struct hashNode { 00054 unsigned int index; //< the shape index, which is given to the user to get the shape 00055 unsigned char transformation; //< which transformation of the shape is saved in here 00056 unsigned long hash; //< the hash value of this transformation of the shape 00057 struct hashNode * next; //< next entry 00058 } hashNode; 00059 00060 hashNode ** hashTable; //< the hash table 00061 unsigned long tableSize; //< size of the hash table 00062 unsigned long tableEntries; //< number of entries in hash table 00063 00064 public: 00065 00066 voxelTable_c(void); 00067 virtual ~voxelTable_c(void); 00068 00072 enum { 00073 PAR_MIRROR = 1, 00074 PAR_COLOUR = 2 00075 }; 00076 00092 bool getSpace(const voxel_c *v, unsigned int *index = 0, unsigned char * trans = 0, unsigned int params = 0) const; 00093 00109 void addSpace(unsigned int index, unsigned int params = 0); 00110 00111 protected: 00112 00118 virtual const voxel_c * findSpace(unsigned int index) const = 0; 00119 00120 private: 00121 00122 // no copying and assigning 00123 voxelTable_c(const voxelTable_c&); 00124 void operator=(const voxelTable_c&); 00125 }; 00126 00128 class voxelTablePuzzle_c : public voxelTable_c { 00129 00130 private: 00131 00132 const puzzle_c * puzzle; 00133 00134 public: 00135 00136 voxelTablePuzzle_c(const puzzle_c * puz) : puzzle(puz) {} 00137 00138 protected: 00139 00140 const voxel_c * findSpace(unsigned int index) const; 00141 00142 private: 00143 00144 // no copying and assigning 00145 voxelTablePuzzle_c(const voxelTable_c&); 00146 void operator=(const voxelTablePuzzle_c&); 00147 00148 }; 00149 00150 #endif