grouping_c Class Reference

Solves the grouping problem. More...

#include <grouping.h>

Collaboration diagram for grouping_c:

Collaboration graph
[legend]

List of all members.

Classes

struct  piece
struct  set

Public Member Functions

 grouping_c (void)
void addPieces (unsigned int pc, unsigned int group, unsigned int count)
 Initialisation.
void reSet (void)
 remove all sets and start fresh
void newSet (void)
 start a new set of pieces.
bool addPieceToSet (unsigned int pc)
 Add the pieces you need to the current set.

Private Member Functions

unsigned int findPiece (unsigned int pc, unsigned int gp)
 grouping_c (const grouping_c &)
void operator= (const grouping_c &)

Private Attributes

std::vector< setsets
std::vector< piecepieces
unsigned int numGroups
bool failed


Detailed Description

Solves the grouping problem.

Problem: when trying to disassemble a puzzle with groups there comes up the problem when identical pieces belong to different groups. Because you don't know, to which group the current piece belongs to you don't know what to do.

But the groups assigned to a piece might change the disassembability of the whole puzzle

Example a puzzle made out of 8 identical pieces, 4 belong to group A and the other 4 to group B. The pieces are assembled into such a shape that always 4 do interlock and can not be disassembled. Depending on how the pieces from the 2 groups are distributed between the 2 subassemblies the puzzle is or isn't disassembable.

The functionality in here is supposed to help solve this problem when the disassembler goes along it's way and tries to disassemble a (sub)problem it only stops premature when there is a clear group assignment available, meaning all pieces have a unique group assigned.

Otherwise it tries to disassemble. If this is not possible it checks with the functions in here, if it is possible to assign groups to the pieces in such a way that all the involved pieces are in the same group. The class will allocate the groups to the involved pieces and use this knowledge later on when more groups get added.


Constructor & Destructor Documentation

grouping_c::grouping_c ( void   )  [inline]

grouping_c::grouping_c ( const grouping_c  )  [private]


Member Function Documentation

void grouping_c::addPieces ( unsigned int  pc,
unsigned int  group,
unsigned int  count 
)

Initialisation.

the following functions tell the class what pieces can be in what groups and how many of them are available

References grouping_c::grouping_c::piece::count, findPiece(), grouping_c::grouping_c::piece::group, numGroups, grouping_c::grouping_c::piece::piece, and pieces.

Referenced by disassembler_a_c::disassembler_a_c().

bool grouping_c::addPieceToSet ( unsigned int  pc  ) 

Add the pieces you need to the current set.

Each time you add a new piece you get a return value saying if it can still be done, as soon as you get false from that function you must stop, it can not be true later any way and the function will return unexpected results after the first false

References failed, findPiece(), numGroups, pieces, and sets.

Referenced by disassembler_a_c::subProbGrouping().

unsigned int grouping_c::findPiece ( unsigned int  pc,
unsigned int  gp 
) [inline, private]

References pieces.

Referenced by addPieces(), and addPieceToSet().

void grouping_c::newSet ( void   ) 

start a new set of pieces.

References grouping_c::grouping_c::set::currentGroup, failed, and sets.

Referenced by disassembler_a_c::subProbGrouping().

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

void grouping_c::reSet ( void   ) 

remove all sets and start fresh

References failed, and sets.

Referenced by disassembler_a_c::disassemble().


Member Data Documentation

bool grouping_c::failed [private]

Referenced by addPieceToSet(), newSet(), and reSet().

unsigned int grouping_c::numGroups [private]

Referenced by addPieces(), and addPieceToSet().

std::vector<piece> grouping_c::pieces [private]

Referenced by addPieces(), addPieceToSet(), and findPiece().

std::vector<set> grouping_c::sets [private]

Referenced by addPieceToSet(), newSet(), and reSet().


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

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