Skip to content
Shapemetry

@huukhanhnguyen/model / schema/nesting

schema/nesting

NestConfig

NestConfig = { clipperScale: number; curveTolerance: number; exploreConcave: boolean; mutationRate: number; populationSize: number; rotations: number; spacing: number; useHoles: boolean; }

Engine configuration — the kernel's own NestConfig. Defaults live in the wasm config parsing, so a caller passes only the fields it overrides. There is no rng field: the kernel takes an explicit integer seed instead, which is nest's fourth argument.

clipperScale

clipperScale: number

curveTolerance

curveTolerance: number

exploreConcave

exploreConcave: boolean

mutationRate

mutationRate: number

populationSize

populationSize: number

rotations

rotations: number

spacing

spacing: number

useHoles

useHoles: boolean


NestInput

NestInput = { bin: NestPath; parts: NestPath[]; }

bin

bin: NestPath

The Group / sheet to place parts into.

parts

parts: NestPath[]

The parts to nest. Each Curve2d may contain an outer ring plus holes.


NestPath

NestPath = string

The wasm kernel's 2D region form: a Curve2d string, the argument every Curve2d.* export in @huukhanhnguyen/geometry takes and returns. Kept as a named alias so call sites read as geometry, not as text.


NestResult

NestResult = { bins: PlacedPart[][]; fitness: number; placedCount: number; totalCount: number; unplaced: number[]; utilization: number; }

bins

bins: PlacedPart[][]

One inner array per opened bin/sheet.

fitness

fitness: number

Lower is better (number of bins opened + packing penalty).

placedCount

placedCount: number

totalCount

totalCount: number

unplaced

unplaced: number[]

Ids of parts that could not be placed in any bin (empty when everything fit).

utilization

utilization: number

placedArea / totalBinArea of the best result.


NestResultJson

NestResultJson = Omit<NestResult, "bins"> & { bins: Omit<PlacedPart, "path2d"> & { path2d: unknown; }[][]; }

The kernel's NestResultJSON: the same shape, with path2d as an embedded object (the whole result is one JSON document, so nothing rides as a nested string). transformation is already the canonical Transformation2d — the kernel serializes its Matrix3x2 = [f64; 6] as-is.


PlacedPart

PlacedPart = { id: number; path2d: NestPath; rotation: number; source: number; transformation: Transformation2d; x: number; y: number; }

A single placed part in the final result.

id

id: number

Internal tree id of the placed part.

path2d

path2d: NestPath

The original input part transformed into its placement (outer ring + holes).

rotation

rotation: number

Rotation in degrees, applied about the part's local origin before translation.

source

source: number

Index into the input parts array.

transformation

transformation: Transformation2d

The full placement transform (rotate-about-origin then translate) — the canonical 6-number affine declared in @huukhanhnguyen/types.

x

x: number

Translation in bin-local coordinates (bin min corner at origin).

y

y: number

Last updated: 📖 3 min readEdit on GitHub