forked from juj/RectangleBinPack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
boost_binpacker.cpp
99 lines (85 loc) · 4.19 KB
/
boost_binpacker.cpp
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include <boost/python.hpp>
#include <vector>
#include "./MaxRectsBinPack.h"
#include "./GuillotineBinPack.h"
#include "./ShelfBinPack.h"
#include "./SkylineBinPack.h"
#include <cstdio>
using namespace boost::python;
BOOST_PYTHON_MODULE(boost_binpacker_ext)
{
using namespace rbp;
class_<Rect>("Rect")
.add_property("x", &Rect::x)
.add_property("y", &Rect::y)
.add_property("width", &Rect::width)
.add_property("height", &Rect::height)
;
// MaxRectBinpack
enum_<MaxRectsBinPack::FreeRectChoiceHeuristic>("MaxRectsFreeRectChoiceHeuristic")
.value("RectBestShortSideFit", MaxRectsBinPack::RectBestShortSideFit)
.value("RectBestLongSideFit", MaxRectsBinPack::RectBestLongSideFit)
.value("RectBestAreaFit", MaxRectsBinPack::RectBestAreaFit)
.value("RectBottomLeftRule", MaxRectsBinPack::RectBottomLeftRule)
.value("RectContactPointRule", MaxRectsBinPack::RectContactPointRule)
;
Rect (MaxRectsBinPack::*MaxRectsInsert)(int, int, MaxRectsBinPack::FreeRectChoiceHeuristic) = &MaxRectsBinPack::Insert;
class_<MaxRectsBinPack>("MaxRectsBinPack", init<int, int>())
.def(init<>())
.def("init", &MaxRectsBinPack::Init)
.def("insert", MaxRectsInsert)
.def("occupancy", &MaxRectsBinPack::Occupancy)
;
// GuillotineBinPack
enum_<GuillotineBinPack::FreeRectChoiceHeuristic>("GuillotineFreeRectChoiceHeuristic")
.value("RectBestAreaFit", GuillotineBinPack::RectBestAreaFit)
.value("RectBestShortSideFit", GuillotineBinPack::RectBestShortSideFit)
.value("RectBestLongSideFit", GuillotineBinPack::RectBestLongSideFit)
.value("RectWorstAreaFit", GuillotineBinPack::RectWorstAreaFit)
.value("RectWorstShortSideFit", GuillotineBinPack::RectWorstShortSideFit)
.value("RectWorstLongSideFit", GuillotineBinPack::RectWorstLongSideFit)
;
enum_<GuillotineBinPack::GuillotineSplitHeuristic>("GuillotineSplitHeuristic")
.value("SplitShorterLeftoverAxis", GuillotineBinPack::SplitShorterLeftoverAxis)
.value("SplitLongerLeftoverAxis", GuillotineBinPack::SplitLongerLeftoverAxis)
.value("SplitMinimizeArea", GuillotineBinPack::SplitMinimizeArea)
.value("SplitMaximizeArea", GuillotineBinPack::SplitMaximizeArea)
.value("SplitShorterAxis", GuillotineBinPack::SplitShorterAxis)
.value("SplitLongerAxis", GuillotineBinPack::SplitLongerAxis)
;
Rect (GuillotineBinPack::*GuillotineInsert)(int, int, bool, GuillotineBinPack::FreeRectChoiceHeuristic, GuillotineBinPack::GuillotineSplitHeuristic) = &GuillotineBinPack::Insert;
class_<GuillotineBinPack>("GuillotineBinPack", init<int, int>())
.def(init<>())
.def("init", &GuillotineBinPack::Init)
.def("insert", GuillotineInsert)
.def("occupancy", &GuillotineBinPack::Occupancy)
;
// ShelfBinPack
enum_<ShelfBinPack::ShelfChoiceHeuristic>("ShelfChoiceHeuristic")
.value("ShelfNextFit", ShelfBinPack::ShelfNextFit)
.value("ShelfFirstFit", ShelfBinPack::ShelfFirstFit)
.value("ShelfBestAreaFit", ShelfBinPack::ShelfBestAreaFit)
.value("ShelfWorstAreaFit", ShelfBinPack::ShelfWorstAreaFit)
.value("ShelfBestHeightFit", ShelfBinPack::ShelfBestHeightFit)
.value("ShelfBestWidthFit", ShelfBinPack::ShelfBestWidthFit)
.value("ShelfWorstWidthFit", ShelfBinPack::ShelfWorstWidthFit)
;
class_<ShelfBinPack>("ShelfBinPack", init<int, int, bool>())
.def(init<>())
.def("init", &ShelfBinPack::Init)
.def("insert", &ShelfBinPack::Insert)
.def("occupancy", &ShelfBinPack::Occupancy)
;
// SkylineBinPack
enum_<SkylineBinPack::LevelChoiceHeuristic>("SkylineLevelChoiceHeuristic")
.value("LevelBottomLeft", SkylineBinPack::LevelBottomLeft)
.value("LevelMinWasteFit", SkylineBinPack::LevelMinWasteFit)
;
Rect (SkylineBinPack::*SkylineInsert)(int, int, SkylineBinPack::LevelChoiceHeuristic) = &SkylineBinPack::Insert;
class_<SkylineBinPack>("SkylineBinPack", init<int, int, bool>())
.def(init<>())
.def("init", &SkylineBinPack::Init)
.def("insert", SkylineInsert)
.def("occupancy", &SkylineBinPack::Occupancy)
;
}