Skip to content

Commit 384be38

Browse files
author
dcmox
committed
missing rotations
1 parent 7d12da2 commit 384be38

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

binpack.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,24 @@ export const pack = (matrix: TBin, item: any): IBinItemResult => {
133133
solutions.push({pos: or, item: ri, desc: 'Orientation: Rotate L -> W', rotation: true})
134134
}
135135

136+
if (item.height !== item.width || item.length !== item.height || item.width !== item.length) {
137+
const ri: IBinItem = Object.assign({}, item)
138+
ri.height = item.width
139+
ri.length = item.height
140+
ri.width = item.length
141+
const or: IBinItemPosition = getPosition(matrix, ri)
142+
solutions.push({pos: or, item: ri, desc: 'Orientation: Rotate W -> L, H -> W, L -> H', rotation: true})
143+
}
144+
145+
if (item.height !== item.width || item.length !== item.height || item.width !== item.length) {
146+
const ri: IBinItem = Object.assign({}, item)
147+
ri.length = item.width
148+
ri.width = item.height
149+
ri.height = item.length
150+
const or: IBinItemPosition = getPosition(matrix, ri)
151+
solutions.push({pos: or, item: ri, desc: 'Orientation: Rotate L -> W, W -> H, H -> L', rotation: true})
152+
}
153+
136154
const fit = bestFit(matrix, solutions)
137155

138156
if (fit.x !== false) {

0 commit comments

Comments
 (0)