@iyulab/u-nesting 0.3.5 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -139,10 +139,32 @@ interface Request2D {
139
139
  mutation_rate?: number; // Mutation rate (default: 0.1)
140
140
  time_limit_ms?: number; // Time limit in ms
141
141
  target_utilization?: number; // Stop early if reached
142
+ multi_sheet?: boolean; // Spill overflow onto extra sheets (default: false)
142
143
  };
143
144
  }
144
145
  ```
145
146
 
147
+ ### Multi-Sheet Nesting
148
+
149
+ By default `solve_2d` packs into a **single** sheet; parts that do not fit become
150
+ `unplaced`. Set `config.multi_sheet: true` to spill overflow onto **additional
151
+ sheets**. Then:
152
+
153
+ - `sheets_used` reports how many sheets were needed.
154
+ - each placement's `sheet_index` selects its sheet.
155
+ - placement `x`/`y` are **sheet-local** — relative to that sheet's own origin —
156
+ so you can render one panel per sheet without subtracting any offset.
157
+
158
+ ```javascript
159
+ const res = JSON.parse(solve_2d(JSON.stringify({
160
+ geometries: [{ id: "part", polygon: [[0,0],[100,0],[100,100],[0,100]], quantity: 20 }],
161
+ boundary: { width: 300, height: 300 },
162
+ config: { strategy: "blf", multi_sheet: true }
163
+ })));
164
+ // res.sheets_used === 3, res.placements.length === 20, res.unplaced === []
165
+ // group placements by sheet_index to draw each sheet
166
+ ```
167
+
146
168
  ### Available 2D Strategies
147
169
 
148
170
  | Strategy | Description |
@@ -180,12 +202,15 @@ interface SolveResponse {
180
202
  x: number;
181
203
  y: number;
182
204
  rotation: number; // degrees
183
- sheet_index: number; // 0-based sheet/bin index
205
+ sheet_index: number; // 0-based sheet/bin index (see config.multi_sheet)
184
206
  flipped: boolean; // mirrored
185
207
  }[];
186
- sheets_used: number;
208
+ sheets_used: number; // >1 only when config.multi_sheet is true
187
209
  utilization: number;
188
- unplaced: string[];
210
+ total_requested: number; // Σ of every geometry's quantity (instance-level).
211
+ // unplaced instances = total_requested - placements.length
212
+ unplaced: string[]; // deduplicated geometry ids (NOT per-instance), so
213
+ // unplaced.length under-reports the failed-instance count
189
214
  elapsed_ms: number;
190
215
  }
191
216
  ```
@@ -208,7 +233,10 @@ interface Pack3DResponse {
208
233
  }[];
209
234
  bins_used: number;
210
235
  utilization: number;
211
- unplaced: string[];
236
+ total_requested: number; // Σ of every geometry's quantity (instance-level).
237
+ // unplaced instances = total_requested - placements.length
238
+ unplaced: string[]; // deduplicated geometry ids (NOT per-instance), so
239
+ // unplaced.length under-reports the failed-instance count
212
240
  elapsed_ms: number;
213
241
  }
214
242
  ```
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "iyulab"
6
6
  ],
7
7
  "description": "WebAssembly bindings for U-Nesting spatial optimization engine",
8
- "version": "0.3.5",
8
+ "version": "0.5.0",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",
@@ -123,11 +123,11 @@ export function version() {
123
123
  wasm.__wbindgen_export2(deferred1_0, deferred1_1, 1);
124
124
  }
125
125
  }
126
- export function __wbg___wbindgen_is_undefined_67b456be8673d3d7(arg0) {
126
+ export function __wbg___wbindgen_is_undefined_721f8decd50c87a3(arg0) {
127
127
  const ret = getObject(arg0) === undefined;
128
128
  return ret;
129
129
  }
130
- export function __wbg___wbindgen_throw_1506f2235d1bdba0(arg0, arg1) {
130
+ export function __wbg___wbindgen_throw_ea4887a5f8f9a9db(arg0, arg1) {
131
131
  throw new Error(getStringFromWasm0(arg0, arg1));
132
132
  }
133
133
  export function __wbg_getRandomValues_3f44b700395062e5() { return handleError(function (arg0, arg1) {
@@ -141,19 +141,19 @@ export function __wbg_performance_3fcf6e32a7e1ed0a(arg0) {
141
141
  const ret = getObject(arg0).performance;
142
142
  return addHeapObject(ret);
143
143
  }
144
- export function __wbg_static_accessor_GLOBAL_9d53f2689e622ca1() {
145
- const ret = typeof global === 'undefined' ? null : global;
144
+ export function __wbg_static_accessor_GLOBAL_THIS_2fee5048bcca5938() {
145
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
146
146
  return isLikeNone(ret) ? 0 : addHeapObject(ret);
147
147
  }
148
- export function __wbg_static_accessor_GLOBAL_THIS_a1a35cec07001a8a() {
149
- const ret = typeof globalThis === 'undefined' ? null : globalThis;
148
+ export function __wbg_static_accessor_GLOBAL_ce44e66a4935da8c() {
149
+ const ret = typeof global === 'undefined' ? null : global;
150
150
  return isLikeNone(ret) ? 0 : addHeapObject(ret);
151
151
  }
152
- export function __wbg_static_accessor_SELF_4c59f6c7ea29a144() {
152
+ export function __wbg_static_accessor_SELF_44f6e0cb5e67cdad() {
153
153
  const ret = typeof self === 'undefined' ? null : self;
154
154
  return isLikeNone(ret) ? 0 : addHeapObject(ret);
155
155
  }
156
- export function __wbg_static_accessor_WINDOW_e70ae9f2eb052253() {
156
+ export function __wbg_static_accessor_WINDOW_168f178805d978fe() {
157
157
  const ret = typeof window === 'undefined' ? null : window;
158
158
  return isLikeNone(ret) ? 0 : addHeapObject(ret);
159
159
  }
Binary file