#include <voxeltable.h>
Classes | |
struct | hashNode |
the hash tabel entry More... | |
Public Types | |
enum | { PAR_MIRROR = 1, PAR_COLOUR = 2 } |
Some parameter flags for the get and set function. More... | |
Public Member Functions | |
voxelTable_c (void) | |
virtual | ~voxelTable_c (void) |
bool | getSpace (const voxel_c *v, unsigned int *index=0, unsigned char *trans=0, unsigned int params=0) const |
Returns true, if the given shape is inside the table. | |
void | addSpace (unsigned int index, unsigned int params=0) |
Add a voxel space to the table. | |
Protected Member Functions | |
virtual const voxel_c * | findSpace (unsigned int index) const =0 |
you must provide this function and return a pointer to the actual voxel space: | |
Private Types | |
typedef struct voxelTable_c::hashNode | hashNode |
the hash tabel entry | |
Private Member Functions | |
voxelTable_c (const voxelTable_c &) | |
void | operator= (const voxelTable_c &) |
Private Attributes | |
hashNode ** | hashTable |
unsigned long | tableSize |
unsigned long | tableEntries |
This table can be used to quickly find dublicates of voxel spaces. The table is a hash-table saving only the hash of the shape to add and then using a user supplied function to actually get the space and do the comparison
The idea is to add all possible orientations of the shape to add so that it becomes easy to actually find something.
Additionally it is possible to calculate the hash including or disregarding the colours attatched to the shape.
It is up to the user to specify which transformations/colour variations to add to the table, only those will be found at the end
To use this class you must derive it and provide a means to return the shape to this table. The table itself only saves an index and with this index the provided function must return the shape
typedef struct voxelTable_c::hashNode voxelTable_c::hashNode [private] |
the hash tabel entry
anonymous enum |
voxelTable_c::voxelTable_c | ( | void | ) |
References hashTable, tableEntries, and tableSize.
voxelTable_c::~voxelTable_c | ( | void | ) | [virtual] |
References hashTable, voxelTable_c::voxelTable_c::hashNode::next, and tableSize.
voxelTable_c::voxelTable_c | ( | const voxelTable_c & | ) | [private] |
void voxelTable_c::addSpace | ( | unsigned int | index, | |
unsigned int | params = 0 | |||
) |
Add a voxel space to the table.
The index is the number returned by getSpace and also given to findSpace
The params parameter works as follows:
If you want to be able to search for all combinations you must call the function twice, once with PAR_MIRROR and then again with PAR_MIRROR | PAR_COLOUR. When PAR_MIRROR is set you can search with and without PAR_MIRROR.
References calcColourHashValue(), calcHashValue(), findSpace(), voxel_c::getGridType(), symmetries_c::getNumTransformations(), symmetries_c::getNumTransformationsMirror(), gridType_c::getSymmetries(), gridType_c::getVoxel(), voxelTable_c::voxelTable_c::hashNode::hash, hashTable, voxelTable_c::voxelTable_c::hashNode::index, symmetries_c::isTransformationUnique(), voxelTable_c::voxelTable_c::hashNode::next, PAR_COLOUR, PAR_MIRROR, voxel_c::selfSymmetries(), tableEntries, tableSize, voxel_c::transform(), and voxelTable_c::voxelTable_c::hashNode::transformation.
virtual const voxel_c* voxelTable_c::findSpace | ( | unsigned int | index | ) | const [protected, pure virtual] |
you must provide this function and return a pointer to the actual voxel space:
For an actual example loot at the class voxelTablePuzzle_c
Implemented in voxelTablePuzzle_c.
Referenced by addSpace(), and getSpace().
bool voxelTable_c::getSpace | ( | const voxel_c * | v, | |
unsigned int * | index = 0 , |
|||
unsigned char * | trans = 0 , |
|||
unsigned int | params = 0 | |||
) | const |
Returns true, if the given shape is inside the table.
The function also returns the index for the shape and the orientation that this shape has relative to the one found at the returned index
The parameter work as follows:
you can provide NULL pointer to index and trans when you only want to know if the space is inside the table
References calcColourHashValue(), calcHashValue(), findSpace(), voxel_c::getGridType(), symmetries_c::getNumTransformations(), gridType_c::getSymmetries(), gridType_c::getVoxel(), voxelTable_c::voxelTable_c::hashNode::hash, hashTable, voxel_c::identicalInBB(), voxelTable_c::voxelTable_c::hashNode::index, voxelTable_c::voxelTable_c::hashNode::next, PAR_COLOUR, PAR_MIRROR, tableSize, voxel_c::transform(), and voxelTable_c::voxelTable_c::hashNode::transformation.
void voxelTable_c::operator= | ( | const voxelTable_c & | ) | [private] |
hashNode** voxelTable_c::hashTable [private] |
Referenced by addSpace(), getSpace(), voxelTable_c(), and ~voxelTable_c().
unsigned long voxelTable_c::tableEntries [private] |
Referenced by addSpace(), and voxelTable_c().
unsigned long voxelTable_c::tableSize [private] |
Referenced by addSpace(), getSpace(), voxelTable_c(), and ~voxelTable_c().