Generic rect packer class. Implements an algorithm to pack rects into groups efficiently. More...

#include <rect_packer.h>

Classes

struct  AllocatedRect
 

Public Types

enum  AllocationPolicy { create_new_group, search_previous_groups, fail_if_full }
 Allocation policy. More...
 

Public Member Functions

 RectPacker ()
 Constructs a null instance. More...
 
 RectPacker (const Size &max_group_size, AllocationPolicy policy=create_new_group)
 Constructs a rect group. More...
 
 ~RectPacker ()
 
AllocatedRect add (const Size &size)
 Allocate space for another rect. More...
 
AllocationPolicy get_allocation_policy () const
 Returns the allocation policy. More...
 
int get_group_count () const
 Returns the amount of rects used by group. More...
 
Size get_max_group_size () const
 Returns the max group size. More...
 
int get_rect_count (unsigned int group_index=0) const
 Returns the amount of rects in a group. More...
 
int get_total_rect_count () const
 Returns the total amount of rects. More...
 
bool is_null () const
 Returns true if this object is invalid. More...
 
void set_allocation_policy (AllocationPolicy policy)
 Set the allocation policy. More...
 
void throw_if_null () const
 Throw an exception if this object is invalid. More...
 

Detailed Description

Generic rect packer class. Implements an algorithm to pack rects into groups efficiently.

Constructor & Destructor Documentation

clan::RectPacker::RectPacker ( )

Constructs a null instance.

clan::RectPacker::RectPacker ( const Size max_group_size,
AllocationPolicy  policy = create_new_group 
)

Constructs a rect group.

clan::RectPacker::~RectPacker ( )

Member Function Documentation

AllocatedRect clan::RectPacker::add ( const Size size)

Allocate space for another rect.

AllocationPolicy clan::RectPacker::get_allocation_policy ( ) const

Returns the allocation policy.

int clan::RectPacker::get_group_count ( ) const

Returns the amount of rects used by group.

Size clan::RectPacker::get_max_group_size ( ) const

Returns the max group size.

int clan::RectPacker::get_rect_count ( unsigned int  group_index = 0) const

Returns the amount of rects in a group.

int clan::RectPacker::get_total_rect_count ( ) const

Returns the total amount of rects.

bool clan::RectPacker::is_null ( ) const
inline

Returns true if this object is invalid.

void clan::RectPacker::set_allocation_policy ( AllocationPolicy  policy)

Set the allocation policy.

void clan::RectPacker::throw_if_null ( ) const

Throw an exception if this object is invalid.


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