#include <assembly.h>
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 | |
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_c > | placements |
the placements of all pieces of the puzzle. | |
const symmetries_c * | sym |
pointer to the symmetry class for this 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
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
References xmlParser_c::END_TAG, xmlParser_c::exception(), symmetries_c::getNumTransformations(), xmlParser_c::getText(), xmlParser_c::next(), placements, xmlParser_c::require(), xmlParser_c::START_TAG, sym, xmlParser_c::TEXT, and UNPLACED_TRANS.
assembly_c::assembly_c | ( | const assembly_c & | ) | [private] |
void assembly_c::addNonPlacedPieces | ( | unsigned int | from, | |
unsigned int | cnt | |||
) |
References bt_assert, placements, and UNPLACED_TRANS.
Referenced by solution_c::addNonPlacedPieces().
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().
calculate a voxelspace that is identical to the assembly with all pieces put into the space
References bt_assert, voxel_c::get(), problem_c::getGridType(), voxel_c::getHx(), voxel_c::getHy(), voxel_c::getHz(), problem_c::getShapeShape(), voxel_c::getState(), gridType_c::getVoxel(), voxel_c::getX(), voxel_c::getY(), voxel_c::getZ(), voxel_c::initHotspot(), problem_c::pieceToShape(), placements, voxel_c::resize(), voxel_c::set(), voxel_c::skipRecalcBoundingBox(), voxel_c::transform(), UNPLACED_TRANS, and voxel_c::VX_EMPTY.
Referenced by smallerRotationExists().
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] |
check if a piece is placed in this assembly
References placements, and UNPLACED_TRANS.
Referenced by containsMirroredPieces(), disassembler_a_c::disassemble(), disassemblerNode_c::disassemblerNode_c(), print(), removePieces(), solution_c::solution_c(), sort(), transform(), and validSolution().
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] |
how many pieces are in this assembly
References placements.
Referenced by solveThread_c::assembly(), disassembler_a_c::disassemble(), disassemblerNode_c::disassemblerNode_c(), print(), and solution_c::solution_c().
void assembly_c::removePieces | ( | unsigned int | from, | |
unsigned int | cnt | |||
) |
void assembly_c::save | ( | xmlWriter_c & | xml | ) | const |
used to save to XML
References xmlWriter_c::addContent(), xmlWriter_c::endTag(), getTransformation(), xmlWriter_c::newTag(), placements, and UNPLACED_TRANS.
Referenced by solution_c::save().
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
References voxel_c::boundX1(), voxel_c::boundX2(), voxel_c::boundY1(), voxel_c::boundY2(), voxel_c::boundZ1(), voxel_c::boundZ2(), bt_assert2, compare(), containsMirroredPieces(), createSpace(), voxel_c::getColor(), voxel_c::getColor2(), symmetries_c::getNumTransformations(), symmetries_c::getNumTransformationsMirror(), problem_c::getResultShape(), voxel_c::getState(), voxel_c::getState2(), voxel_c::onGrid(), problem_c::placementAllowed(), placements, voxel_c::selfSymmetries(), sym, symmetries_c::symmetrieContainsTransformation(), transform(), validSolution(), voxel_c::VX_EMPTY, and voxel_c::VX_FILLED.
Referenced by assembler_1_c::solution(), and assembler_0_c::solution().
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().
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
Referenced by addNonPlacedPieces(), addNonPlacement(), addPlacement(), assembly_c(), compare(), comparePieces(), containsMirroredPieces(), createSpace(), exchangeShape(), getTransformation(), getX(), getY(), getZ(), isPlaced(), operator==(), placementCount(), removePieces(), save(), smallerRotationExists(), sort(), and transform().
const symmetries_c* assembly_c::sym [private] |
pointer to the symmetry class for this puzzle
Referenced by assembly_c(), containsMirroredPieces(), smallerRotationExists(), and transform().