#include <assembly.h>

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
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_c * | createSpace (const problem_c *puz) const |
| calculate a voxelspace that is identical to the assembly with all pieces put into the space | |
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_c > | placements |
| the placements of all pieces of the puzzle. | |
| const symmetries_c * | sym |
| pointer to the symmetry class for this puzzle | |
| 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 | |||
| ) |
load the assembly from xml file
| assembly_c::assembly_c | ( | 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
| 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.
| 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
| 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
| void assembly_c::save | ( | xmlWriter_c & | xml | ) | const |
used to save to XML
| 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
| 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.
| unsigned int assembly_c::placementCount | ( | void | ) | const [inline] |
how many pieces are in this assembly
| bool assembly_c::isPlaced | ( | unsigned int | num | ) | const [inline] |
check if a piece is placed in this assembly
| unsigned char assembly_c::getTransformation | ( | unsigned int | num | ) | const [inline] |
get the transformation of a piece
| int assembly_c::getX | ( | unsigned int | num | ) | const [inline] |
get the x-position of a piece
| int assembly_c::getY | ( | unsigned int | num | ) | const [inline] |
get the y-position of a piece
| int assembly_c::getZ | ( | unsigned int | num | ) | const [inline] |
get the z-position of a piece
| 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
| bool assembly_c::smallerRotationExists | ( | const problem_c * | puz, | |
| unsigned int | pivot, | |||
| const mirrorInfo_c * | mir, | |||
| bool | complete | |||
| ) | const |
return true, if this is a non-normal assembly.
This is used to drop rotated assemblies
| 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
| 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.
| void assembly_c::sort | ( | const problem_c * | puz | ) |
sort the pieces within the assembly so that multipieces are ordered by ascending placement order.
calculate a voxelspace that is identical to the assembly with all pieces put into the space
| void assembly_c::operator= | ( | const assembly_c & | ) | [private] |
std::vector<placement_c> assembly_c::placements [private] |
the placements of all pieces of the puzzle.
the order here is the same as the order of problem definition
const symmetries_c* assembly_c::sym [private] |
pointer to the symmetry class for this puzzle
1.5.4