packme

package module
v0.0.0-...-5f3dbfd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

README

packme-wasm.go

go binding for packme-wasm A 3D bin packing library in Rust/WebAssembly.

Usage example
func TestPacking(t *testing.T) {
	packme := New()
	input := PackmeInput{
		Containers: []ItemInput{
			{Id: "container 1", Qty: 1, Dim: [3]int{20, 20, 30}},
		},
		Items: []ItemInput{
			{Id: "item 1", Qty: 5, Dim: [3]int{10, 10, 30}},
		},
	}
	packed := packme.Pack(input)
	assert.Equal(t, len(packed.UnpackedItems), 1)
	assert.Equal(t, len(packed.Containers[0].Items), 4)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContainerOutput

type ContainerOutput struct {
	Id    string       `json:"id"`
	Dim   Vector3      `json:"dim"`
	Items []ItemResult `json:"items"`
}

type ItemInput

type ItemInput struct {
	Id  string `json:"id"`
	Qty int    `json:"qty"`
	Dim [3]int `json:"dim"`
}

type ItemResult

type ItemResult struct {
	Id  string   `json:"id"`
	Dim Vector3  `json:"dim"`
	Pos Vector3  `json:"pos"`
	Rot Rotation `json:"rot"`
}

type Packme

type Packme struct {
	// contains filtered or unexported fields
}

func New

func New() Packme

func (Packme) FromPath

func (p Packme) FromPath(file_path string) Packme

func (*Packme) Pack

func (p *Packme) Pack(input PackmeInput) PackmeOutput

func (*Packme) Version

func (p *Packme) Version() string

type PackmeInput

type PackmeInput struct {
	Containers []ItemInput `json:"containers"`
	Items      []ItemInput `json:"items"`
}

type PackmeOutput

type PackmeOutput struct {
	Containers    []ContainerOutput `json:"containers"`
	UnpackedItems []ItemResult      `json:"unpacked_items"`
}

type Rotation

type Rotation string // "LWH" | "WLH" | "WHL" | "HLW" | "HWL" | "LHW"

type Vector3

type Vector3 struct {
	Length float64 `json:"length"`
	Width  float64 `json:"width"`
	Height float64 `json:"height"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL