-
Notifications
You must be signed in to change notification settings - Fork 0
/
SmallBinPacking.h
61 lines (49 loc) · 1.72 KB
/
SmallBinPacking.h
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
50
51
52
53
54
55
56
57
58
59
60
61
//
// Copyright 2010 Bastian Holst <[email protected]>
//
#ifndef SMALLBINPACKING_H
#define SMALLBINPACKING_H
#include <QtCore/QVector>
#include <QtCore/QMultiMap>
class FloatItem;
class SmallBinPacking
{
public:
SmallBinPacking();
~SmallBinPacking();
QVector<FloatItem> items() const;
void setItems(const QVector<FloatItem>& items);
int maximumNumberOfBins() const;
/**
* Returns the number of bins that are needed to pack the items into.
* Returns -1 if there is no assignment for maximumNumberOfBins.
*/
int minimumNumberOfBins();
int *assignment();
private:
virtual void recalculateValues();
bool handlePreassignment(int *preassignment, int numberOfBins,
QVector<float> normalItemSizes,
QVector<int> normalItemNumbers,
QMultiMap<float, int> grouping,
QMap<float, int> extraItems,
QSet<int> smallItems,
int *resultingAssignment,
float *resultingRemainingCapacities);
bool packExtraItems(QMap<float, int> extraItems,
QMultiMap<float, int> grouping,
int *assignment,
float *remainingCapacities,
int numberOfBins);
bool packSmallItems(QSet<int> smallItems,
int *assignment,
float *remainingCapacities,
int numberOfBins);
float m_delta;
int m_K;
QVector<FloatItem> m_items;
bool m_dirty;
int m_minimumNumberOfBins;
int *m_assignment;
};
#endif // SMALLBINPACKING_H