voxelTable_c Class Reference

This class is a table containing references to voxelspaces. More...

#include <voxeltable.h>

Inheritance diagram for voxelTable_c:

Inheritance graph
Collaboration diagram for voxelTable_c:

Collaboration graph

List of all members.


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_cfindSpace (unsigned int index) const =0
 you must provide this function and return a pointer to the actual voxel space:

Private Types

typedef struct
 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

Detailed Description

This class is a table containing references to voxelspaces.

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

Member Typedef Documentation

the hash tabel entry

Member Enumeration Documentation

anonymous enum

Some parameter flags for the get and set function.

You can or them together when required

PAR_MIRROR  include mirrors of this shape
PAR_COLOUR  differenly coloured shapes are different

Constructor & Destructor Documentation

voxelTable_c::voxelTable_c ( void   ) 

References hashTable, tableEntries, and tableSize.

voxelTable_c::~voxelTable_c ( void   )  [virtual]

voxelTable_c::voxelTable_c ( const voxelTable_c  )  [private]

Member Function Documentation

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:

  • when PAR_MIRROR is set, the shape will be added in all possible orientations including mirror orientations, when not set only normal orientations will be used
  • PAR_COLOUR: when set the hash will be calculated in a way that differently colourized shapes will have a differen hash, when not set, only the shape will go into the hash

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:

  • PAR_MIRROR: when set mirror orientations of the shape may be returned, otherwise the function either finds a non mirror orientation or nothing. Will only work when the shape is added using PAR_MIRROR
  • PAR_COLOUR: when set, shapes with different colouring will be different

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]

Member Data Documentation

unsigned long voxelTable_c::tableEntries [private]

Referenced by addSpace(), and voxelTable_c().

unsigned long voxelTable_c::tableSize [private]

The documentation for this class was generated from the following files:

Generated on Sun Oct 10 10:03:18 2010 for BurrTools by  doxygen 1.5.8