RectanglePacking Class Reference#include <RectanglePacking.h>
Collaboration diagram for RectanglePacking:
[legend]List of all members.
Detailed Description
This class is used for the implementation of the greedy algorithm.
Public Member Functions
- RectanglePacking (int numberRects)
- ~RectanglePacking ()
- void defaultPositionRestOfRectangles (vector< Rectangle< float > >::iterator itlim, vector< Rectangle< float > >::iterator itend)
- void optimalPositionOfNewRectangle (vector< Rectangle< float > >::iterator itNewRect)
- list< RectangleRelativePosition
>::iterator testOfPositionOfNewRectangle (int positionInFirstSequence, int positionInSecondSequence)
- list< RectangleRelativePosition
>::iterator positionOfNewRectangle (int positionInFirstSequence, int positionInSecondSequence)
- void coordinatesOfNewRectangle (list< RectangleRelativePosition >::iterator itRectLeftOrBelowOfNewRect, int positionInFirstSequence, int positionInSecondSequence)
- void dimensionsBoundingBoxOfRectanglesLeftOrBelowNewRectangle (list< RectangleRelativePosition >::iterator itRectLeftOrBelowOfNewRect)
- void dimensionsBoundingBoxOfNewRectangleAndRectanglesLeftOrBelow ()
- void repositionOfRectanglesRightOrAboveNewRectangle (list< RectangleRelativePosition >::iterator itFirstRectangleRightOrAboveOfNewRectangle, int positionInFirstSequence, int positionInSecondSequence)
- void modificationCoordinatesRectanglesRightOrAboveNewRectangleInFonctionNewRectangle (list< RectangleRelativePosition >::iterator itRectOfSequenceToReposition, int positionInSecondSequence)
- void modificationCoordinatesRectanglesRightOrAboveNewRectangleInFonctionAlreadyRepositionnedRectangles (list< RectangleRelativePosition >::iterator itFirstRectangleRightOrAboveOfNewRectangle, list< RectangleRelativePosition >::iterator itRectOfSequenceToReposition)
- void dimensionsBoundingBoxOfAllOptimalPositionnedRectangles (list< RectangleRelativePosition >::iterator itRectOfSequenceToReposition)
- void modificationOfSequencePair (vector< Rectangle< float > >::iterator itNewRect, list< RectangleRelativePosition >::iterator itBestPositionInFirstSequence)
- int calculOfNumberOptimalRepositionnedRectangles (const char *quality)
- float calculateRatio ()
- void lineOrColumnToStart (bool &boolWidth, bool &boolHeight)
- void endOfLine (float &heightTemp, float &widthTemp, bool &boolWidth, bool &boolHeight)
- void endOfColumn (float &widthTemp, float &heightTemp, bool &boolWidth, bool &boolHeight)
- void continueLine (vector< Rectangle< float > >::iterator itr, float &widthTemp, float &heightTemp, bool &boolWidth, bool &boolHeight)
- void continueColumn (vector< Rectangle< float > >::iterator itr, float &widthTemp, float &heightTemp, bool &boolWidth, bool &boolHeight)
- void optimalPositionOfNewRectangleLimPos (vector< Rectangle< float > >::iterator itNewRect, int numberTestedPositions)
- int calculNumberOfTestedPositions (const char *quality)
Public Attributes
Constructor & Destructor Documentation
RectanglePacking::RectanglePacking |
( |
int |
numberRects |
) |
|
|
|
constructor of the RectanglePacking class. - Parameters:
-
| numberRects | number of rectangles to pack. |
|
RectanglePacking::~RectanglePacking |
( |
|
) |
|
|
Member Function Documentation
float RectanglePacking::calculateRatio |
( |
|
) |
|
|
|
Calculate the ratio width/height or height/width so that the return >=1. |
int RectanglePacking::calculNumberOfTestedPositions |
( |
const char * |
quality |
) |
|
|
|
Calculate the number of rectangles we can pack without go beyond the complexity desired. |
int RectanglePacking::calculOfNumberOptimalRepositionnedRectangles |
( |
const char * |
quality |
) |
|
|
|
Calculate the number of rectangles we can pack in an optimal way without going beyond the complexity desired. - Parameters:
-
| quality | give the complexity desired. |
- Returns:
- an integer equal to the number of rectangles we want to pack in an optimal way.
|
void RectanglePacking::continueColumn |
( |
vector< Rectangle< float > >::iterator |
itr, |
|
|
float & |
widthTemp, |
|
|
float & |
heightTemp, |
|
|
bool & |
boolWidth, |
|
|
bool & |
boolHeight |
|
) |
|
|
|
We start or continue a new column if the height of the new rectangle to pack, added to the height of the current column, is strictly lower to the height of the including rectangle. |
void RectanglePacking::continueLine |
( |
vector< Rectangle< float > >::iterator |
itr, |
|
|
float & |
widthTemp, |
|
|
float & |
heightTemp, |
|
|
bool & |
boolWidth, |
|
|
bool & |
boolHeight |
|
) |
|
|
|
We start or continue a new line if the width of the new rectangle to pack, added to the width of the current line, is strictly lower to the width of the including rectangle. |
void RectanglePacking::coordinatesOfNewRectangle |
( |
list< RectangleRelativePosition >::iterator |
itRectLeftOrBelowOfNewRect, |
|
|
int |
positionInFirstSequence, |
|
|
int |
positionInSecondSequence |
|
) |
|
|
|
Determine if the rectangle pointed by itRectLeftOrBelowOfNewRect has a right abscissa or a high ordonate higher than those of rectangles yet visited. - Parameters:
-
| itRectLeftOrBelowOfNewRect | pointer on one of the structures of RectangleRelativePosition corresponding to a rectangle places on the left or below the tested position of the new rectangle. |
| positionInFirstSequence | position tested in the first sequence. |
| positionInSecondSequence | position tested in the second sequence. |
|
void RectanglePacking::defaultPositionRestOfRectangles |
( |
vector< Rectangle< float > >::iterator |
itlim, |
|
|
vector< Rectangle< float > >::iterator |
itend |
|
) |
|
|
|
Place the rectangles not packed in an optimal way around the rectangle including the rectangles packed in an optimal way. |
void RectanglePacking::dimensionsBoundingBoxOfAllOptimalPositionnedRectangles |
( |
list< RectangleRelativePosition >::iterator |
itRectOfSequenceToReposition |
) |
|
|
|
Search the dimensions of the rectangle including the rectangles on the left and below the considered rectangle. |
void RectanglePacking::dimensionsBoundingBoxOfNewRectangleAndRectanglesLeftOrBelow |
( |
|
) |
|
|
|
Search the dimensions of the rectangle including the new rectangle and the rectangles on the left and below it. |
void RectanglePacking::dimensionsBoundingBoxOfRectanglesLeftOrBelowNewRectangle |
( |
list< RectangleRelativePosition >::iterator |
itRectLeftOrBelowOfNewRect |
) |
|
|
|
Stock in the fields maxWidthOfBoundingBox and maxHeightOfBoundingBox the dimensions of the rectangle including the rectangles on the left and below the considered rectangle. |
void RectanglePacking::endOfColumn |
( |
float & |
widthTemp, |
|
|
float & |
heightTemp, |
|
|
bool & |
boolWidth, |
|
|
bool & |
boolHeight |
|
) |
|
|
|
End a column and decide if the rectangle pointed is going to start a line or a column. |
void RectanglePacking::endOfLine |
( |
float & |
heightTemp, |
|
|
float & |
widthTemp, |
|
|
bool & |
boolWidth, |
|
|
bool & |
boolHeight |
|
) |
|
|
|
End a line and decide if the rectangle pointed is going to start a line or a column. |
void RectanglePacking::lineOrColumnToStart |
( |
bool & |
boolWidth, |
|
|
bool & |
boolHeight |
|
) |
|
|
|
decide if a new rectangle is going to be placed in line or in column. |
void RectanglePacking::modificationCoordinatesRectanglesRightOrAboveNewRectangleInFonctionAlreadyRepositionnedRectangles |
( |
list< RectangleRelativePosition >::iterator |
itFirstRectangleRightOrAboveOfNewRectangle, |
|
|
list< RectangleRelativePosition >::iterator |
itRectOfSequenceToReposition |
|
) |
|
|
|
Compare the left abscissa and the low ordonate of the rectangle pointed by itRectOfSequenceToReposition with the right abscissa and the high ordonate of all the rectangles placed in the first sequence between the first rectangle on the right of the tested position and the rectangle pointed by itRectOfSequenceToReposition. - Parameters:
-
| itFirstRectangleRightOrAboveOfNewRectangle | pointer on the first rectangle on the right or above the new rectangle. |
| itRectOfSequenceToReposition | pointer on the rectangles places on the right or above the new rectangle. |
|
void RectanglePacking::modificationCoordinatesRectanglesRightOrAboveNewRectangleInFonctionNewRectangle |
( |
list< RectangleRelativePosition >::iterator |
itRectOfSequenceToReposition, |
|
|
int |
positionInSecondSequence |
|
) |
|
|
|
Compare the right abscissa and the high ordonate of the new rectangle, with the left abscissa and the low ordonate of the rectangle pointed by itRectOfSequenceToReposition. - Parameters:
-
| itRectOfSequenceToReposition | pointer on one rectangle placed on the right or above the new rectangle. |
| positionInSecondSequence | position tested in the second sequence. |
|
void RectanglePacking::modificationOfSequencePair |
( |
vector< Rectangle< float > >::iterator |
itNewRect, |
|
|
list< RectangleRelativePosition >::iterator |
itBestPositionInFirstSequence |
|
) |
|
|
|
Modify the even sequence when all the position tests, for a new rectangle to pack, have been made. |
void RectanglePacking::optimalPositionOfNewRectangle |
( |
vector< Rectangle< float > >::iterator |
itNewRect |
) |
|
|
|
Search the best co-ordinates of a rectangle in order to pack it in the best way. Test the results obtained with all the possible positions in the even sequence. |
void RectanglePacking::optimalPositionOfNewRectangleLimPos |
( |
vector< Rectangle< float > >::iterator |
itNewRect, |
|
|
int |
numberTestedPositions |
|
) |
|
|
list< RectangleRelativePosition >::iterator RectanglePacking::positionOfNewRectangle |
( |
int |
positionInFirstSequence, |
|
|
int |
positionInSecondSequence |
|
) |
|
|
|
Search the co-ordinates of a rectangle for the positions tested in the first and in the second sequence of the even sequence. Search the dimensions of the rectangle including the rectangles placed on the left and below the new rectangle. - Parameters:
-
| positionInFirstSequence | position tested in the first sequence. |
| positionInSecondSequence | position tested in the second sequence. |
|
void RectanglePacking::repositionOfRectanglesRightOrAboveNewRectangle |
( |
list< RectangleRelativePosition >::iterator |
itFirstRectangleRightOrAboveOfNewRectangle, |
|
|
int |
positionInFirstSequence, |
|
|
int |
positionInSecondSequence |
|
) |
|
|
|
Calculate again the co-ordinates of the rectangles places on the right and above the new rectangle. Calculate the dimensions of the rectangle including all the packed rectangles. - Parameters:
-
| positionInFirstSequence | position tested in the first sequence. |
| positionInSecondSequence | position tested in the second sequence. |
|
list< RectangleRelativePosition >::iterator RectanglePacking::testOfPositionOfNewRectangle |
( |
int |
positionInFirstSequence, |
|
|
int |
positionInSecondSequence |
|
) |
|
|
|
Search the co-ordinates of a rectangle for the positions tested in the first and in the second sequence of the even sequence. Search the dimensions of the rectangle including all the packed rectangles. - Parameters:
-
| positionInFirstSequence | position tested in the first sequence. |
| positionInSecondSequence | position tested in the second sequence. |
|
Member Data Documentation
|
Best height of the rectangle including all the packed rectangles and a new rectangle to pack since the beginning of the position tests. |
|
Current best position of a new rectangle to pack, in the first sequence, since the beginning of the position tests. |
|
Current best position of a new rectangle to pack, in the second sequence, since the beginning of the position tests. |
|
Best left abscissa of a new rectangle to pack since the beginning of the position tests. |
|
Best low ordinate of a new rectangle to pack since the beginning of the position tests. |
|
Best width of the rectangle including all the packed rectangles and a new rectangle to pack since the beginning of the position tests. |
|
List which is useful for the stocking of the first sequence of the even sequence. |
|
Width of the rectangle including all the packed rectangles and a new rectangle to pack, for a tested position. |
|
Width of the rectangle including all the packed rectangles and a new rectangle to pack, for a tested position. |
|
Height of a new rectangle to pack. |
|
Left abscissa of a new rectangle to pack, for a tested position. |
|
Low ordinate of a new rectangle to pack, for a tested position. |
|
Width of a new rectangle to pack. |
|
Current value of the number of packed rectangles. |
|
Value of the number of rectangles to pack. |
|
Array which is used for the stocking of the positions of the rectangles in the second sequence. |
|