movementCache_c Class Reference

Calculates and stores the information required for movement analysis. More...

#include <movementcache.h>

Inheritance diagram for movementCache_c:

Inheritance graph
[legend]
Collaboration diagram for movementCache_c:

Collaboration graph
[legend]

List of all members.

Classes

struct  moEntry
 values are saved within a hash table, this is the entry for the table for the movement data More...

Public Member Functions

 movementCache_c (const problem_c *puz)
 create the cache.
virtual ~movementCache_c (void)
void getMoValue (int dx, int dy, int dz, unsigned char t1, unsigned char t2, unsigned int p1, unsigned int p2, unsigned int *movements)
 return the values, that are: how far can the 2nd piece be moved in positive x, y and z direction, when the 2nd piece is offset by dx, dy and dz relative to the first, the 2 pieces are the pieces p1 and p2 from the puzzle and problem defined in the constructor and the 2 pieces are transformed by t1 and t2
virtual unsigned int numDirections (void)=0
 return the number of different directions of movement that are possible within the space grid that that movement cache is for
virtual void getDirection (unsigned int dir, int *x, int *y, int *z)=0
 return the movement vector of the given direction

Private Types

typedef struct
movementCache_c::moEntry 
moEntry
 values are saved within a hash table, this is the entry for the table for the movement data

Private Member Functions

void moRehash (void)
 this function resizes the hash table to roughly twice the size
virtual unsigned int * moCalcValues (const voxel_c *sh1, const voxel_c *sh2, int dx, int dy, int dz)=0
 when the entry is not inside the table, this function calculates the values for the movement info
const voxel_cgetTransformedShape (unsigned int s, unsigned char t)
 get the transformed shape from the shapes array, calculating missing ones
 movementCache_c (const movementCache_c &)
void operator= (const movementCache_c &)

Private Attributes

moEntry ** moHash
 the hash table
unsigned int moTableSize
 size of the hash table
unsigned int moEntries
 number of entries in the table
const voxel_c *** shapes
 Saves the shapes in all orientations.
unsigned int * pieces
 the mapping of piece numbers to shape ids
unsigned int num_shapes
 number of shapes
unsigned int num_transformations
 number of possible transformations for each shape
const gridType_cgt
 the gridtype used. We need this to make copies and transformations of the shapes


Detailed Description

Calculates and stores the information required for movement analysis.

The movement cache calculates the following value:

Because calculating this information is expensive all the values gained are stored in a table for later retrieval. That is why it is called cache

Internally this class holds a hash table for the stored values and calls abstract functions for the calculation of the values, when they are not inside the table.

So only the derived classes do actually calculate something.


Member Typedef Documentation

values are saved within a hash table, this is the entry for the table for the movement data


Constructor & Destructor Documentation

movementCache_c::movementCache_c ( const problem_c puz  ) 

create the cache.

The cache is then fixed to the puzzle and the problem, it can and should be reused to analyse all assemblies found but can not be used for another puzzle

References problem_c::getGridType(), symmetries_c::getNumTransformations(), problem_c::getShapeMax(), problem_c::getShapeShape(), gridType_c::getSymmetries(), moEntries, moHash, moTableSize, num_shapes, num_transformations, problem_c::partNumber(), problem_c::pieceNumber(), pieces, and shapes.

movementCache_c::~movementCache_c ( void   )  [virtual]

movementCache_c::movementCache_c ( const movementCache_c  )  [private]


Member Function Documentation

virtual void movementCache_c::getDirection ( unsigned int  dir,
int *  x,
int *  y,
int *  z 
) [pure virtual]

return the movement vector of the given direction

Implemented in movementCache_0_c, and movementCache_1_c.

Referenced by movementAnalysator_c::findMatching(), and movementAnalysator_c::newNode().

void movementCache_c::getMoValue ( int  dx,
int  dy,
int  dz,
unsigned char  t1,
unsigned char  t2,
unsigned int  p1,
unsigned int  p2,
unsigned int *  movements 
)

return the values, that are: how far can the 2nd piece be moved in positive x, y and z direction, when the 2nd piece is offset by dx, dy and dz relative to the first, the 2 pieces are the pieces p1 and p2 from the puzzle and problem defined in the constructor and the 2 pieces are transformed by t1 and t2

References movementCache_c::movementCache_c::moEntry::dx, movementCache_c::movementCache_c::moEntry::dy, movementCache_c::movementCache_c::moEntry::dz, getTransformedShape(), moCalcValues(), moEntries, moHash, moHashValue(), moRehash(), moTableSize, movementCache_c::movementCache_c::moEntry::move, movementCache_c::movementCache_c::moEntry::next, numDirections(), pieces, movementCache_c::movementCache_c::moEntry::s1, movementCache_c::movementCache_c::moEntry::s2, movementCache_c::movementCache_c::moEntry::t1, and movementCache_c::movementCache_c::moEntry::t2.

Referenced by movementAnalysator_c::prepare().

const voxel_c * movementCache_c::getTransformedShape ( unsigned int  s,
unsigned char  t 
) [private]

get the transformed shape from the shapes array, calculating missing ones

References bt_assert2, gridType_c::getVoxel(), gt, shapes, and voxel_c::transform().

Referenced by getMoValue().

virtual unsigned int* movementCache_c::moCalcValues ( const voxel_c sh1,
const voxel_c sh2,
int  dx,
int  dy,
int  dz 
) [private, pure virtual]

when the entry is not inside the table, this function calculates the values for the movement info

Implemented in movementCache_0_c, and movementCache_1_c.

Referenced by getMoValue().

void movementCache_c::moRehash ( void   )  [private]

virtual unsigned int movementCache_c::numDirections ( void   )  [pure virtual]

return the number of different directions of movement that are possible within the space grid that that movement cache is for

Implemented in movementCache_0_c, and movementCache_1_c.

Referenced by movementAnalysator_c::checkmovement(), movementAnalysator_c::find(), movementAnalysator_c::findMatching(), getMoValue(), movementAnalysator_c::movementAnalysator_c(), and movementAnalysator_c::prepare().

void movementCache_c::operator= ( const movementCache_c  )  [private]


Member Data Documentation

const gridType_c* movementCache_c::gt [private]

the gridtype used. We need this to make copies and transformations of the shapes

Referenced by getTransformedShape().

unsigned int movementCache_c::moEntries [private]

number of entries in the table

Referenced by getMoValue(), and movementCache_c().

the hash table

Referenced by getMoValue(), moRehash(), movementCache_c(), and ~movementCache_c().

unsigned int movementCache_c::moTableSize [private]

size of the hash table

Referenced by getMoValue(), moRehash(), movementCache_c(), and ~movementCache_c().

unsigned int movementCache_c::num_shapes [private]

number of shapes

Referenced by movementCache_c(), and ~movementCache_c().

unsigned int movementCache_c::num_transformations [private]

number of possible transformations for each shape

Referenced by movementCache_c(), and ~movementCache_c().

unsigned int* movementCache_c::pieces [private]

the mapping of piece numbers to shape ids

Referenced by getMoValue(), movementCache_c(), and ~movementCache_c().

const voxel_c*** movementCache_c::shapes [private]

Saves the shapes in all orientations.

The voxel spaces are calculated on demand. The entry at the zero-th position are pointers into the puzzle, so we must not free them

Referenced by getTransformedShape(), movementCache_c(), and ~movementCache_c().


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

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