assembly_c Class Reference

this class contains the assembly for a puzzle. More...

#include <assembly.h>

Collaboration diagram for assembly_c:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 assembly_c (const gridType_c *gt)
 assembly_c (const assembly_c *orig)
 copy constructor
 assembly_c (xmlParser_c &pars, unsigned int pieces, const gridType_c *gt)
 load the assembly from xml file
void save (xmlWriter_c &xml) const
 used to save to XML
void addPlacement (unsigned char tran, int x, int y, int z)
 add placement for the next piece.
void addNonPlacement (void)
 add a non placed piece.
unsigned int placementCount (void) const
 how many pieces are in this assembly
bool isPlaced (unsigned int num) const
 check if a piece is placed in this assembly
unsigned char getTransformation (unsigned int num) const
 get the transformation of a piece
int getX (unsigned int num) const
 get the x-position of a piece
int getY (unsigned int num) const
 get the y-position of a piece
int getZ (unsigned int num) const
 get the z-position of a piece
bool transform (unsigned char trans, const problem_c *puz, const mirrorInfo_c *mir)
 transform the assembly.
bool smallerRotationExists (const problem_c *puz, unsigned int pivot, const mirrorInfo_c *mir, bool complete) const
 return true, if this is a non-normal assembly.
void exchangeShape (unsigned int s1, unsigned int s2)
 exchange 2 shapes.
int comparePieces (const assembly_c *b) const
 compare 2 assemblies according to their used pieces.
void sort (const problem_c *puz)
 sort the pieces within the assembly so that multipieces are ordered by ascending placement order.
voxel_ccreateSpace (const problem_c *puz) const
 calculate a voxelspace that is identical to the assembly with all pieces put into the space
void removePieces (unsigned int from, unsigned int cnt)
void addNonPlacedPieces (unsigned int from, unsigned int cnt)

Private Member Functions

bool operator== (const assembly_c &b) const
 the equality operation.
bool compare (const assembly_c &b, unsigned int pivot) const
 returns true, if assembly b is smaller than this assembly.
bool containsMirroredPieces (void) const
 returns true, if one of the pieces within this assembly is a mirror orientation.
bool validSolution (const problem_c *puz) const
 returns true, if all shapes are at least the minimum required times inside the assembly
 assembly_c (const assembly_c &)
void operator= (const assembly_c &)

Private Attributes

std::vector< placement_cplacements
 the placements of all pieces of the puzzle.
const symmetries_csym
 pointer to the symmetry class for this puzzle


Detailed Description

this class contains the assembly for a puzzle.

an assembly is a list of transformations and positions for each piece in the final assembly

the transformations are the same as defined in the voxel space class


Constructor & Destructor Documentation

assembly_c::assembly_c ( const gridType_c gt  )  [inline]

assembly_c::assembly_c ( const assembly_c orig  ) 

copy constructor

assembly_c::assembly_c ( xmlParser_c pars,
unsigned int  pieces,
const gridType_c gt 
)

assembly_c::assembly_c ( const assembly_c  )  [private]


Member Function Documentation

void assembly_c::addNonPlacedPieces ( unsigned int  from,
unsigned int  cnt 
)

void assembly_c::addNonPlacement ( void   )  [inline]

add a non placed piece.

as all pieces of a puzzle must be inside the assembly this function needs to be called when a piece is not used in the assembly.

References placements, and UNPLACED_TRANS.

Referenced by assembler_1_c::getAssembly(), and assembler_0_c::getAssembly().

void assembly_c::addPlacement ( unsigned char  tran,
int  x,
int  y,
int  z 
) [inline]

add placement for the next piece.

Pieces are added one after another with this function

References bt_assert, placements, and UNPLACED_TRANS.

Referenced by assembler_1_c::getAssembly(), and assembler_0_c::getAssembly().

bool assembly_c::compare ( const assembly_c b,
unsigned int  pivot 
) const [private]

returns true, if assembly b is smaller than this assembly.

This function is used in the smallerRotationExists function to compare different orientations of one and the same assembly. For normalisation purposes.

References bt_assert, and placements.

Referenced by smallerRotationExists().

int assembly_c::comparePieces ( const assembly_c b  )  const

compare 2 assemblies according to their used pieces.

used to sort assemblies by the pieces they use. Assemblies wich use pieces with smaller indices are smaller than assemblies that use pieces with bigger indices.

References bt_assert, placements, and UNPLACED_TRANS.

Referenced by comp_3_pieces().

bool assembly_c::containsMirroredPieces ( void   )  const [private]

returns true, if one of the pieces within this assembly is a mirror orientation.

this is used by the smaller rotation exists check, to see, if the mirrored orientation can be achieved with the given pieces

References symmetries_c::getNumTransformations(), isPlaced(), placements, and sym.

Referenced by smallerRotationExists().

voxel_c * assembly_c::createSpace ( const problem_c puz  )  const

void assembly_c::exchangeShape ( unsigned int  s1,
unsigned int  s2 
)

exchange 2 shapes.

this is used when editing a problem and exchanging the order of 2 pieces in a problem

References bt_assert, and placements.

Referenced by solution_c::exchangeShape().

unsigned char assembly_c::getTransformation ( unsigned int  num  )  const [inline]

get the transformation of a piece

References bt_assert, placements, and UNPLACED_TRANS.

Referenced by disassemblerNode_c::disassemblerNode_c(), getX(), getY(), getZ(), print(), and save().

int assembly_c::getX ( unsigned int  num  )  const [inline]

get the x-position of a piece

References bt_assert, getTransformation(), placements, and UNPLACED_TRANS.

Referenced by disassemblerNode_c::disassemblerNode_c(), and print().

int assembly_c::getY ( unsigned int  num  )  const [inline]

get the y-position of a piece

References bt_assert, getTransformation(), placements, and UNPLACED_TRANS.

Referenced by disassemblerNode_c::disassemblerNode_c(), and print().

int assembly_c::getZ ( unsigned int  num  )  const [inline]

get the z-position of a piece

References bt_assert, getTransformation(), placements, and UNPLACED_TRANS.

Referenced by disassemblerNode_c::disassemblerNode_c(), and print().

bool assembly_c::isPlaced ( unsigned int  num  )  const [inline]

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

bool assembly_c::operator== ( const assembly_c b  )  const [inline, private]

the equality operation.

2 assemblies are equal, if all placements are equal

References bt_assert, and placements.

unsigned int assembly_c::placementCount ( void   )  const [inline]

void assembly_c::removePieces ( unsigned int  from,
unsigned int  cnt 
)

References bt_assert, isPlaced(), and placements.

Referenced by solution_c::removePieces().

void assembly_c::save ( xmlWriter_c xml  )  const

bool assembly_c::smallerRotationExists ( const problem_c puz,
unsigned int  pivot,
const mirrorInfo_c mir,
bool  complete 
) const

void assembly_c::sort ( const problem_c puz  ) 

sort the pieces within the assembly so that multipieces are ordered by ascending placement order.

References problem_c::getShapeMax(), isPlaced(), problem_c::partNumber(), and placements.

Referenced by assembler_1_c::getAssembly(), and transform().

bool assembly_c::transform ( unsigned char  trans,
const problem_c puz,
const mirrorInfo_c mir 
)

transform the assembly.

the problem is that to rotate the placements we need to know the sizes of the shapes because the given position is always the corner with the lowest coordinates

The function returns true, when the transformation has been done successfully and false if not.

when complete is true, then the symmetry of the solution shape is NOT used to find out which symmetries to check for instead all possible orientations are checked, also all possible translations are checked

When the function returns false it will leave the assembly in an undefined state maybe some pieces have already been replaced while other are still in their initial position, so you have to throw away the assembly when that happens

References bt_assert, bt_assert2, voxel_c::getBoundingBox(), voxel_c::getHotspot(), voxel_c::getHx(), voxel_c::getHy(), voxel_c::getHz(), symmetries_c::getNumTransformations(), mirrorInfo_c::getPieceInfo(), problem_c::getResultShape(), problem_c::getShapeMax(), problem_c::getShapeShape(), isPlaced(), voxel_c::normalizeTransformation(), problem_c::partNumber(), placements, sort(), sym, TND, symmetries_c::transAdd(), voxel_c::transformPoint(), and UNPLACED_TRANS.

Referenced by smallerRotationExists(), and assembler_1_c::solution().

bool assembly_c::validSolution ( const problem_c puz  )  const [private]

returns true, if all shapes are at least the minimum required times inside the assembly

References problem_c::getShapeMax(), isPlaced(), and problem_c::partNumber().

Referenced by smallerRotationExists().


Member Data Documentation

std::vector<placement_c> assembly_c::placements [private]

const symmetries_c* assembly_c::sym [private]

pointer to the symmetry class for this puzzle

Referenced by assembly_c(), containsMirroredPieces(), smallerRotationExists(), and transform().


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

Generated on Sun Oct 10 10:02:43 2010 for BurrTools by  doxygen 1.5.8