Giter Club home page Giter Club logo

guillotine-packer's Introduction

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.

๐Ÿป

guillotine-packer's People

Contributors

naogify avatar tyschroed avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.