guillotine-packer
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

guillotine-packer

styled with prettier Travis Coverage Status semantic-release

What is this?

This is a bin packing implementation based off of this fantastic paper. Originally developed as part of Part Placer for the woodworking community, however it can be used for all sorts of bin packing applications! Guillotine based algorithms translate well for many real-world material use cases, as they nicely balance outputs that can easily performed on machinery with efficient material use.

Getting Started

Install

npm install guillotine-packer

Usage

import { packer } from 'guillotine-packer'
 
  const result = packer({
    binHeight: 30,
    binWidth: 30,
    items: [
      {
        name: 'test2',
        width: 20,
        height: 20
      } as Item,
      {
        name: 'test',
        width: 20,
        height: 20
      } as Item
    ]
  })
 
  /* OUTPUT:
 
  Array [
  Array [
    Object {
      "bin": 1,
      "height": 20,
      "item": Object {
        "name": "test2",
      },
      "width": 20,
      "x": 0,
      "y": 0,
    },
    Object {
      "bin": 1,
      "height": 20,
      "item": Object {
        "name": "test",
      },
      "width": 20,
      "x": 20,
      "y": 0,
    },
  ],
]
 
  */

Parameters

Inputs
Property Default Description
binHeight undefined required Height of the bin we will be packing the items into
binWidth undefined required Width of the bin we will be packing the items into
items undefined required Array of items. Each item should have a width and height property. Additional properties will be included in the item property of the results
Options
Option Default Description
kerfSize 0 The size of the blade kerf to account for when splitting rectanges
sortStrategy undefined SortStrategy to use. Undefined will try all strategies and pick which performs the best.
splitStrategy undefined SplitStrategy to use. Undefined will try all strategies and pick which performs the best.
selectionStrategy undefined SelectionStrategy to use. Undefined will try all strategies and pick which performs the best.
allowRotation true Whether items may be rotated. If true, items will be rotated if doing so maximizes the offcut size.

🍻

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.2
    5
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.2
    5
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i guillotine-packer

Weekly Downloads

5

Version

1.0.2

License

MIT

Unpacked Size

313 kB

Total Files

28

Last publish

Collaborators

  • tyschroed