Ion
|
This class implements generic 2D bin-packing using a modified version of the Skyline Bottom-Left algorithm available at: http://clb.demon.fi/files/RectangleBinPack. More...
#include "binpacker.h"
Classes | |
struct | Rectangle |
Structure representing a rectangle to pack into the bin. More... | |
Public Member Functions | |
BinPacker () | |
BinPacker functions. More... | |
~BinPacker () | |
BinPacker (const BinPacker &from) | |
Allow BinPacker to be copied. More... | |
BinPacker & | operator= (const BinPacker &from) |
void | AddRectangle (uint64 id, const math::Vector2ui &size) |
Adds a rectangle of the given size to pack into the bin. More... | |
bool | Pack (const math::Vector2ui &bin_size) |
Tries to pack all of the rectangles into a bin of the given size. More... | |
const std::vector< Rectangle > & | GetRectangles () const |
Returns the vector of rectangles (including positions) resulting from the last call to Pack(). More... | |
This class implements generic 2D bin-packing using a modified version of the Skyline Bottom-Left algorithm available at: http://clb.demon.fi/files/RectangleBinPack.
Modifications include:
Definition at line 36 of file binpacker.h.
ion::text::BinPacker::BinPacker | ( | ) |
BinPacker functions.
Definition at line 201 of file binpacker.cc.
ion::text::BinPacker::~BinPacker | ( | ) |
Definition at line 205 of file binpacker.cc.
|
explicit |
Allow BinPacker to be copied.
Definition at line 203 of file binpacker.cc.
|
inline |
Adds a rectangle of the given size to pack into the bin.
It is up to the client to manage IDs responsibly; duplicates are not detected here.
Definition at line 60 of file binpacker.h.
|
inline |
Returns the vector of rectangles (including positions) resulting from the last call to Pack().
If Pack() returned false, this vector will not be useful.
Definition at line 72 of file binpacker.h.
Definition at line 207 of file binpacker.cc.
bool ion::text::BinPacker::Pack | ( | const math::Vector2ui & | bin_size | ) |
Tries to pack all of the rectangles into a bin of the given size.
Returns true if they were able to fit. This can be called incrementally; only the rectangles added since the last call to Pack() will be processed.
Definition at line 215 of file binpacker.cc.