-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplacement.m
More file actions
54 lines (53 loc) · 1.41 KB
/
placement.m
File metadata and controls
54 lines (53 loc) · 1.41 KB
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
% place the boxes into the bins
function [bins]=placement(bps,vbo,bin,boxes,varargin)
mindim=varargin{1};
minvol=varargin{2};
% initiate the variables
bins=[bin];
nb=1;
n=length(boxes);
% place all the boxes
for i=1:n
binnoselected=0;
emsselected='';
boxnotopack=bps(i);
box=boxes(boxnotopack);
% iterate each bin for packing
for j=1:nb
[emsselected,orientationsfeasible]=dftrc2(box,bins(j));
if ~isempty(emsselected)
binnoselected=j;
break;
end
end
% open a new bin
if binnoselected==0
binnoselected=nb+1;
bins=[bins bin];
nb=nb+1;
[emsselected,orientationsfeasible]=dftrc2(box,bin);
if isempty(emsselected)
error('there is a box not feasible for a empty bin!');
end
end
% select the orientation
boselected=orientationsfeasible;
nbos=length(boselected);
boo=boselected(ceil(vbo(boxnotopack)*nbos));
% pack box
origin.x=emsselected.minx;
origin.y=emsselected.miny;
origin.z=emsselected.minz;
bins(binnoselected)=packbox(boxes(boxnotopack),boo,origin,bins(binnoselected),mindim,minvol);
if box.mindim<=mindim
for j=i+1:n
mindim=min([mindim,boxes(j).mindim]);
end
end
if box.vol<=minvol
for j=i+1:n
minvol=min([minvol,boxes(j).vol]);
end
end
end
end