forked from juj/RectangleBinPack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShelfNextFitBinPack.h
More file actions
49 lines (35 loc) · 856 Bytes
/
ShelfNextFitBinPack.h
File metadata and controls
49 lines (35 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/** @file ShelfNextFitBinPack.h
@author Jukka Jylänki
@brief Implements the naive Shelf Next Fit bin packer algorithm.
This algorithm is not recommended for real use at all - its only advantage is that it
consumes only a constant amount of memory, whereas the other packers in this library
use at least a linear amount of memory.
This work is released to Public Domain, do whatever you want with it.
*/
#pragma once
#include <vector>
namespace rbp {
class ShelfNextFitBinPack
{
public:
struct Node
{
int x;
int y;
int width;
int height;
bool flipped;
};
void Init(int width, int height);
Node Insert(int width, int height);
/// Computes the ratio of used surface area.
float Occupancy() const;
private:
int binWidth;
int binHeight;
int currentX;
int currentY;
int shelfHeight;
unsigned long usedSurfaceArea;
};
}