clan::RectPacker Class Reference - ClanLib SDK
Description: clan::RectPacker Class Reference

Classes | Public Types | Public Member Functions | List of all members
clan::RectPacker Class Reference
clanCore Math

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

## Detailed Description

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

## Member Enumeration Documentation

## ◆ AllocationPolicy

enum clan::RectPacker::AllocationPolicy

Allocation policy.

Enumerator
create_new_group |
search_previous_groups |
fail_if_full |

## Constructor & Destructor Documentation

## ◆ RectPacker() [1/2]

clan::RectPacker::RectPacker | ( |  | ) |

Constructs a null instance.

## ◆ RectPacker() [2/2]

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

Constructs a rect group.

## ◆ ~RectPacker()

clan::RectPacker::~RectPacker | ( |  | ) |

## Member Function Documentation

## ◆ add()

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

Allocate space for another rect.

## ◆ get_allocation_policy()

AllocationPolicy clan::RectPacker::get_allocation_policy | ( |  | ) | const

Returns the allocation policy.

## ◆ get_group_count()

int clan::RectPacker::get_group_count | ( |  | ) | const

Returns the amount of rects used by group.

## ◆ get_max_group_size()

Size clan::RectPacker::get_max_group_size | ( |  | ) | const

Returns the max group size.

## ◆ get_rect_count()

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

Returns the amount of rects in a group.

## ◆ get_total_rect_count()

int clan::RectPacker::get_total_rect_count | ( |  | ) | const

Returns the total amount of rects.

## ◆ is_null()

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

Returns true if this object is invalid.

## ◆ set_allocation_policy()

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

Set the allocation policy.

## ◆ throw_if_null()

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:

- rect_packer.h