Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
Nz::GuillotineBinPack Class Reference

Core class that represents the "Guillotine problem", combination of the "Bin packing problem" and the "cutting stock". More...

Public Types

enum  FreeRectChoiceHeuristic : int {
  RectBestAreaFit, RectBestLongSideFit, RectBestShortSideFit, RectWorstAreaFit,
  RectWorstLongSideFit, RectWorstShortSideFit
}
 
enum  GuillotineSplitHeuristic : int {
  SplitLongerAxis, SplitLongerLeftoverAxis, SplitMaximizeArea, SplitMinimizeArea,
  SplitShorterAxis, SplitShorterLeftoverAxis
}
 

Public Member Functions

enum FreeRectChoiceHeuristic int enum GuillotineSplitHeuristic int GuillotineBinPack ()
 Constructs a GuillotineBinPack object by default.
 
 GuillotineBinPack (unsigned int width, unsigned int height)
 Constructs a GuillotineBinPack object with width and height. More...
 
 GuillotineBinPack (const Vector2ui &size)
 Constructs a GuillotineBinPack object with area. More...
 
 GuillotineBinPack (const GuillotineBinPack &)=default
 
 GuillotineBinPack (GuillotineBinPack &&)=default
 
void Clear ()
 Clears the content.
 
void Expand (unsigned int newWidth, unsigned newHeight)
 Expands the content. More...
 
void Expand (const Vector2ui &newSize)
 Expands the content. More...
 
void FreeRectangle (const Rectui &rect)
 Frees the rectangle. More...
 
unsigned int GetHeight () const
 Gets the height. More...
 
float GetOccupancy () const
 Gets percentage of occupation. More...
 
Vector2ui GetSize () const
 Gets the size of the area. More...
 
unsigned int GetWidth () const
 Gets the width. More...
 
bool Insert (Rectui *rects, unsigned int count, bool merge, FreeRectChoiceHeuristic rectChoice, GuillotineSplitHeuristic splitMethod)
 Inserts rectangles in the area. More...
 
bool Insert (Rectui *rects, bool *flipped, unsigned int count, bool merge, FreeRectChoiceHeuristic rectChoice, GuillotineSplitHeuristic splitMethod)
 Inserts rectangles in the area. More...
 
bool Insert (Rectui *rects, bool *flipped, bool *inserted, unsigned int count, bool merge, FreeRectChoiceHeuristic rectChoice, GuillotineSplitHeuristic splitMethod)
 Inserts rectangles in the area. More...
 
bool MergeFreeRectangles ()
 Merges free rectangles together. More...
 
void Reset ()
 Resets the area.
 
void Reset (unsigned int width, unsigned int height)
 Resets the area. More...
 
void Reset (const Vector2ui &size)
 Resets the area. More...
 
GuillotineBinPackoperator= (const GuillotineBinPack &)=default
 
GuillotineBinPackoperator= (GuillotineBinPack &&)=default
 

Detailed Description

Core class that represents the "Guillotine problem", combination of the "Bin packing problem" and the "cutting stock".

Constructor & Destructor Documentation

◆ GuillotineBinPack() [1/2]

Nz::GuillotineBinPack::GuillotineBinPack ( unsigned int  width,
unsigned int  height 
)

Constructs a GuillotineBinPack object with width and height.

Parameters
widthWidth
heightHeight

◆ GuillotineBinPack() [2/2]

Nz::GuillotineBinPack::GuillotineBinPack ( const Vector2ui size)

Constructs a GuillotineBinPack object with area.

Parameters
sizeVector2 representing the area (width, height)

Member Function Documentation

◆ Expand() [1/2]

void Nz::GuillotineBinPack::Expand ( unsigned int  newWidth,
unsigned  newHeight 
)

Expands the content.

Parameters
newWidthNew width for the expansion
newHeightNew height for the expansion
See also
Expand

◆ Expand() [2/2]

void Nz::GuillotineBinPack::Expand ( const Vector2ui newSize)

Expands the content.

Parameters
newSizeNew area for the expansion
See also
Expand

◆ FreeRectangle()

void Nz::GuillotineBinPack::FreeRectangle ( const Rectui rect)

Frees the rectangle.

Parameters
rectArea to free
Remarks
This method should only be called with computed rectangles by the method Insert and can produce fragmentation

◆ GetHeight()

unsigned int Nz::GuillotineBinPack::GetHeight ( ) const

Gets the height.

Returns
Height of the area

◆ GetOccupancy()

float Nz::GuillotineBinPack::GetOccupancy ( ) const

Gets percentage of occupation.

Returns
Percentage of the already occupied area

◆ GetSize()

Vector2ui Nz::GuillotineBinPack::GetSize ( ) const

Gets the size of the area.

Returns
Size of the area

◆ GetWidth()

unsigned int Nz::GuillotineBinPack::GetWidth ( ) const

Gets the width.

Returns
Width of the area

◆ Insert() [1/3]

bool Nz::GuillotineBinPack::Insert ( Rectui rects,
unsigned int  count,
bool  merge,
FreeRectChoiceHeuristic  rectChoice,
GuillotineSplitHeuristic  splitMethod 
)

Inserts rectangles in the area.

Returns
true if each rectangle could be inserted
Parameters
rectsList of rectangles
countCount of rectangles
mergeMerge possible
rectChoiceHeuristic to use to free
splitMethodHeuristic to use to split

◆ Insert() [2/3]

bool Nz::GuillotineBinPack::Insert ( Rectui rects,
bool *  flipped,
unsigned int  count,
bool  merge,
FreeRectChoiceHeuristic  rectChoice,
GuillotineSplitHeuristic  splitMethod 
)

Inserts rectangles in the area.

Returns
true if each rectangle could be inserted
Parameters
rectsList of rectangles
flippedList of flipped rectangles
countCount of rectangles
mergeMerge possible
rectChoiceHeuristic to use to free
splitMethodHeuristic to use to split

◆ Insert() [3/3]

bool Nz::GuillotineBinPack::Insert ( Rectui rects,
bool *  flipped,
bool *  inserted,
unsigned int  count,
bool  merge,
FreeRectChoiceHeuristic  rectChoice,
GuillotineSplitHeuristic  splitMethod 
)

Inserts rectangles in the area.

Returns
true if each rectangle could be inserted
Parameters
rectsList of rectangles
flippedList of flipped rectangles
flippedList of inserted rectangles
countCount of rectangles
mergeMerge possible
rectChoiceHeuristic to use to free
splitMethodHeuristic to use to split

◆ MergeFreeRectangles()

bool Nz::GuillotineBinPack::MergeFreeRectangles ( )

Merges free rectangles together.

Returns
true if there was a merge (and thus if a merge is still possible)

◆ Reset() [1/2]

void Nz::GuillotineBinPack::Reset ( unsigned int  width,
unsigned int  height 
)

Resets the area.

Parameters
widthWidth
heightHeight

◆ Reset() [2/2]

void Nz::GuillotineBinPack::Reset ( const Vector2ui size)

Resets the area.

Parameters
sizeSize of the area

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