opengeometry 2.0.10 → 2.0.11

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/index.d.ts CHANGED
@@ -97,6 +97,6 @@ export * from "./src/freeform/index.js";
97
97
  */
98
98
  export * from "./src/editor/index.js";
99
99
  /**
100
- * Kernel-backed modeling operations.
100
+ * Kernel-backed modeling operations (incl. analytic polyline offset → regions).
101
101
  */
102
102
  export * from "./src/operations/index.js";
package/index.js CHANGED
@@ -209,16 +209,42 @@ function getStringFromWasm0(ptr, len) {
209
209
  ptr = ptr >>> 0;
210
210
  return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
211
211
  }
212
- function _assertClass(instance, klass) {
213
- if (!(instance instanceof klass)) {
214
- throw new Error(`expected instance of ${klass.name}`);
215
- }
216
- }
217
212
  function takeFromExternrefTable0(idx) {
218
213
  const value = wasm.__wbindgen_export_2.get(idx);
219
214
  wasm.__externref_table_dealloc(idx);
220
215
  return value;
221
216
  }
217
+ /**
218
+ * @param {string} local_brep_serialized
219
+ * @param {number} height
220
+ * @returns {string}
221
+ */
222
+ function extrudeBrepFace$1(local_brep_serialized, height) {
223
+ let deferred3_0;
224
+ let deferred3_1;
225
+ try {
226
+ const ptr0 = passStringToWasm0(local_brep_serialized, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
227
+ const len0 = WASM_VECTOR_LEN;
228
+ const ret = wasm.extrudeBrepFace(ptr0, len0, height);
229
+ var ptr2 = ret[0];
230
+ var len2 = ret[1];
231
+ if (ret[3]) {
232
+ ptr2 = 0;
233
+ len2 = 0;
234
+ throw takeFromExternrefTable0(ret[2]);
235
+ }
236
+ deferred3_0 = ptr2;
237
+ deferred3_1 = len2;
238
+ return getStringFromWasm0(ptr2, len2);
239
+ } finally {
240
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
241
+ }
242
+ }
243
+ function _assertClass(instance, klass) {
244
+ if (!(instance instanceof klass)) {
245
+ throw new Error(`expected instance of ${klass.name}`);
246
+ }
247
+ }
222
248
  let cachedFloat64ArrayMemory0 = null;
223
249
  function getFloat64ArrayMemory0() {
224
250
  if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
@@ -239,9 +265,63 @@ function passArrayJsValueToWasm0(array, malloc) {
239
265
  WASM_VECTOR_LEN = array.length;
240
266
  return ptr;
241
267
  }
268
+ function getArrayJsValueFromWasm0(ptr, len) {
269
+ ptr = ptr >>> 0;
270
+ const mem = getDataViewMemory0();
271
+ const result = [];
272
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
273
+ result.push(wasm.__wbindgen_export_2.get(mem.getUint32(i, true)));
274
+ }
275
+ wasm.__externref_drop_slice(ptr, len);
276
+ return result;
277
+ }
242
278
  function isLikeNone(x) {
243
279
  return x === undefined || x === null;
244
280
  }
281
+ function passArrayF64ToWasm0(arg, malloc) {
282
+ const ptr = malloc(arg.length * 8, 8) >>> 0;
283
+ getFloat64ArrayMemory0().set(arg, ptr / 8);
284
+ WASM_VECTOR_LEN = arg.length;
285
+ return ptr;
286
+ }
287
+ /**
288
+ * Wasm entry point: offset a centreline by `width` into stroked regions via the
289
+ * deterministic analytic offset. `centreline_flat` is `[x0,y0,z0, …]`. Returns
290
+ * CW-outer / CCW-hole regions, canonicalised; empty (does NOT throw) when degenerate.
291
+ * @param {Float64Array} centreline_flat
292
+ * @param {number} width
293
+ * @param {boolean} closed
294
+ * @param {number} miter_limit
295
+ * @returns {OGOffsetRegionsResult}
296
+ */
297
+ function offsetPolylineRegions$1(centreline_flat, width, closed, miter_limit) {
298
+ const ptr0 = passArrayF64ToWasm0(centreline_flat, wasm.__wbindgen_malloc);
299
+ const len0 = WASM_VECTOR_LEN;
300
+ const ret = wasm.offsetPolylineRegions(ptr0, len0, width, closed, miter_limit);
301
+ if (ret[2]) {
302
+ throw takeFromExternrefTable0(ret[1]);
303
+ }
304
+ return OGOffsetRegionsResult.__wrap(ret[0]);
305
+ }
306
+
307
+ /**
308
+ * Wasm entry point: merge a GROUP of separate polylines (a crossing T / X / L
309
+ * overlap) into one clean stroked region by nonzero-winding union of their mitered
310
+ * bands. `polylines_json` is `[{centreline:[x,y,z,…], width, closed}, …]`. Returns
311
+ * CW-outer / CCW-hole regions (one or more); empty when nothing is buildable.
312
+ * @param {string} polylines_json
313
+ * @returns {OGOffsetRegionsResult}
314
+ */
315
+ function offsetPolylineGroupRegions$1(polylines_json) {
316
+ const ptr0 = passStringToWasm0(polylines_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
317
+ const len0 = WASM_VECTOR_LEN;
318
+ const ret = wasm.offsetPolylineGroupRegions(ptr0, len0);
319
+ if (ret[2]) {
320
+ throw takeFromExternrefTable0(ret[1]);
321
+ }
322
+ return OGOffsetRegionsResult.__wrap(ret[0]);
323
+ }
324
+
245
325
  /**
246
326
  * Wasm entry point for union.
247
327
  * @param {string} lhs_brep_serialized
@@ -327,40 +407,22 @@ function booleanSubtractionMany(lhs_brep_serialized, cutters_brep_serialized, op
327
407
  }
328
408
 
329
409
  /**
330
- * @param {string} local_brep_serialized
331
- * @param {number} height
332
- * @returns {string}
410
+ * Wasm entry point for array-backed batched union. Accepts a JSON array of
411
+ * serialized BReps and folds them with `batch_union` in one boundary crossing.
412
+ * @param {string} operands_brep_serialized
413
+ * @param {string | null} [options_json]
414
+ * @returns {OGBooleanResult}
333
415
  */
334
- function extrudeBrepFace$1(local_brep_serialized, height) {
335
- let deferred3_0;
336
- let deferred3_1;
337
- try {
338
- const ptr0 = passStringToWasm0(local_brep_serialized, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
339
- const len0 = WASM_VECTOR_LEN;
340
- const ret = wasm.extrudeBrepFace(ptr0, len0, height);
341
- var ptr2 = ret[0];
342
- var len2 = ret[1];
343
- if (ret[3]) {
344
- ptr2 = 0;
345
- len2 = 0;
346
- throw takeFromExternrefTable0(ret[2]);
347
- }
348
- deferred3_0 = ptr2;
349
- deferred3_1 = len2;
350
- return getStringFromWasm0(ptr2, len2);
351
- } finally {
352
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
353
- }
354
- }
355
- function getArrayJsValueFromWasm0(ptr, len) {
356
- ptr = ptr >>> 0;
357
- const mem = getDataViewMemory0();
358
- const result = [];
359
- for (let i = ptr; i < ptr + 4 * len; i += 4) {
360
- result.push(wasm.__wbindgen_export_2.get(mem.getUint32(i, true)));
416
+ function batchUnion(operands_brep_serialized, options_json) {
417
+ const ptr0 = passStringToWasm0(operands_brep_serialized, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
418
+ const len0 = WASM_VECTOR_LEN;
419
+ var ptr1 = isLikeNone(options_json) ? 0 : passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
420
+ var len1 = WASM_VECTOR_LEN;
421
+ const ret = wasm.batchUnion(ptr0, len0, ptr1, len1);
422
+ if (ret[2]) {
423
+ throw takeFromExternrefTable0(ret[1]);
361
424
  }
362
- wasm.__externref_drop_slice(ptr, len);
363
- return result;
425
+ return OGBooleanResult.__wrap(ret[0]);
364
426
  }
365
427
  const Matrix3Finalization = typeof FinalizationRegistry === 'undefined' ? {
366
428
  register: () => {},
@@ -2818,7 +2880,7 @@ class OGLine {
2818
2880
  * @returns {Vector3}
2819
2881
  */
2820
2882
  get_anchor() {
2821
- const ret = wasm.ogcurve_get_anchor(this.__wbg_ptr);
2883
+ const ret = wasm.ogline_get_anchor(this.__wbg_ptr);
2822
2884
  return Vector3.__wrap(ret);
2823
2885
  }
2824
2886
  /**
@@ -2872,6 +2934,50 @@ class OGLine {
2872
2934
  }
2873
2935
  }
2874
2936
  }
2937
+ const OGOffsetRegionsResultFinalization = typeof FinalizationRegistry === 'undefined' ? {
2938
+ register: () => {},
2939
+ unregister: () => {}
2940
+ } : new FinalizationRegistry(ptr => wasm.__wbg_ogoffsetregionsresult_free(ptr >>> 0, 1));
2941
+ /**
2942
+ * Result payload for a polyline offset: a list of regions (each an outer ring +
2943
+ * inner-void holes). Normally one region; a self-crossing closed centreline (e.g.
2944
+ * a figure-8) yields one per simple sub-loop. The deterministic analytic offset —
2945
+ * no extrude/solid. Used to build the plan polygons + extruded base solids in JS.
2946
+ */
2947
+ class OGOffsetRegionsResult {
2948
+ static __wrap(ptr) {
2949
+ ptr = ptr >>> 0;
2950
+ const obj = Object.create(OGOffsetRegionsResult.prototype);
2951
+ obj.__wbg_ptr = ptr;
2952
+ OGOffsetRegionsResultFinalization.register(obj, obj.__wbg_ptr, obj);
2953
+ return obj;
2954
+ }
2955
+ __destroy_into_raw() {
2956
+ const ptr = this.__wbg_ptr;
2957
+ this.__wbg_ptr = 0;
2958
+ OGOffsetRegionsResultFinalization.unregister(this);
2959
+ return ptr;
2960
+ }
2961
+ free() {
2962
+ const ptr = this.__destroy_into_raw();
2963
+ wasm.__wbg_ogoffsetregionsresult_free(ptr, 0);
2964
+ }
2965
+ /**
2966
+ * @returns {string}
2967
+ */
2968
+ get regionsSerialized() {
2969
+ let deferred1_0;
2970
+ let deferred1_1;
2971
+ try {
2972
+ const ret = wasm.ogoffsetregionsresult_regionsSerialized(this.__wbg_ptr);
2973
+ deferred1_0 = ret[0];
2974
+ deferred1_1 = ret[1];
2975
+ return getStringFromWasm0(ret[0], ret[1]);
2976
+ } finally {
2977
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2978
+ }
2979
+ }
2980
+ }
2875
2981
  const OGPolygonFinalization = typeof FinalizationRegistry === 'undefined' ? {
2876
2982
  register: () => {},
2877
2983
  unregister: () => {}
@@ -3444,7 +3550,7 @@ class OGPolyline {
3444
3550
  * @returns {Vector3}
3445
3551
  */
3446
3552
  get_anchor() {
3447
- const ret = wasm.ogcurve_get_anchor(this.__wbg_ptr);
3553
+ const ret = wasm.ogpolyline_get_anchor(this.__wbg_ptr);
3448
3554
  return Vector3.__wrap(ret);
3449
3555
  }
3450
3556
  /**
@@ -5435,7 +5541,7 @@ class OGWedge {
5435
5541
  * @returns {Vector3}
5436
5542
  */
5437
5543
  get_anchor() {
5438
- const ret = wasm.ogwedge_get_anchor(this.__wbg_ptr);
5544
+ const ret = wasm.ogarc_get_anchor(this.__wbg_ptr);
5439
5545
  return Vector3.__wrap(ret);
5440
5546
  }
5441
5547
  }
@@ -5862,6 +5968,7 @@ var OGKernel = /*#__PURE__*/Object.freeze({
5862
5968
  OGFreeformGeometry: OGFreeformGeometry,
5863
5969
  OGIfcExportResult: OGIfcExportResult,
5864
5970
  OGLine: OGLine,
5971
+ OGOffsetRegionsResult: OGOffsetRegionsResult,
5865
5972
  OGPolygon: OGPolygon,
5866
5973
  OGPolyline: OGPolyline,
5867
5974
  OGRectangle: OGRectangle,
@@ -5872,13 +5979,16 @@ var OGKernel = /*#__PURE__*/Object.freeze({
5872
5979
  OGSweep: OGSweep,
5873
5980
  OGWedge: OGWedge,
5874
5981
  Vector3: Vector3,
5982
+ batchUnion: batchUnion,
5875
5983
  booleanIntersection: booleanIntersection$1,
5876
5984
  booleanSubtraction: booleanSubtraction$1,
5877
5985
  booleanSubtractionMany: booleanSubtractionMany,
5878
5986
  booleanUnion: booleanUnion$1,
5879
5987
  default: __wbg_init,
5880
5988
  extrudeBrepFace: extrudeBrepFace$1,
5881
- initSync: initSync
5989
+ initSync: initSync,
5990
+ offsetPolylineGroupRegions: offsetPolylineGroupRegions$1,
5991
+ offsetPolylineRegions: offsetPolylineRegions$1
5882
5992
  });
5883
5993
 
5884
5994
  function spotLabelElement() {
@@ -11145,6 +11255,44 @@ function createEditorModesExample(scene) {
11145
11255
  };
11146
11256
  }
11147
11257
 
11258
+ /**
11259
+ * Offset a centreline by ±half-width into one or more filled REGIONS, via the
11260
+ * deterministic analytic offset — miters / flat bevels at `miterLimit`, concave
11261
+ * trims, and nonzero-winding resolution of reflex / closed loops. NO boolean union
11262
+ * (so it is deterministic, unlike the 3D-mesh CSG path). A simple centreline returns
11263
+ * one region; a self-crossing closed centreline (e.g. a figure-8) returns one per
11264
+ * simple sub-loop. Returns an EMPTY array for a genuinely unbuildable input (does
11265
+ * not throw, so it never looks like a kernel crash). Rings are CW-outer / CCW-holes.
11266
+ *
11267
+ * @param centrelineFlat centreline points as `[x,y,z, …]`.
11268
+ * @param width full stroke width (offset ±width/2 on each side).
11269
+ * @param miterLimit SVG stroke-miterlimit; corners sharper than this bevel. Default 4.
11270
+ */
11271
+ function offsetPolylineRegions(centrelineFlat, width, closed, miterLimit = 4) {
11272
+ const buildExport = offsetPolylineRegions$1;
11273
+ if (typeof buildExport !== "function") {
11274
+ throw new Error("offsetPolylineRegions is not available in the loaded wasm package. Rebuild opengeometry wasm bindings.");
11275
+ }
11276
+ const flat = centrelineFlat instanceof Float64Array ? centrelineFlat : new Float64Array(centrelineFlat);
11277
+ const result = buildExport(flat, width, closed, miterLimit);
11278
+ return JSON.parse(result.regionsSerialized);
11279
+ }
11280
+ /**
11281
+ * Merge a GROUP of separate polylines (a crossing T / X / L overlap) into one clean
11282
+ * region by nonzero-winding union of their mitered bands — the overlapping strokes
11283
+ * merge into a single region with mitered/bevelled corners, no internal edges.
11284
+ * Returns CW-outer / CCW-hole regions (one or more); empty if nothing is buildable.
11285
+ * No CSG. Used to render/extrude an overlapping crossing as one joined mass.
11286
+ */
11287
+ function offsetPolylineGroupRegions(polylines) {
11288
+ const buildExport = offsetPolylineGroupRegions$1;
11289
+ if (typeof buildExport !== "function") {
11290
+ throw new Error("offsetPolylineGroupRegions is not available in the loaded wasm package. Rebuild opengeometry wasm bindings.");
11291
+ }
11292
+ const result = buildExport(JSON.stringify(polylines));
11293
+ return JSON.parse(result.regionsSerialized);
11294
+ }
11295
+
11148
11296
  /**
11149
11297
  * Shared runtime entrypoint used to initialize the OpenGeometry wasm module.
11150
11298
  */
@@ -11209,5 +11357,5 @@ class OpenGeometry {
11209
11357
  OpenGeometry.version = OPEN_GEOMETRY_THREE_VERSION;
11210
11358
  OpenGeometry.instance = null;
11211
11359
 
11212
- export { Arc, BooleanError, BooleanResult, CoincidentFacesError, Cuboid, Curve, CutterExceedsHostError, Cylinder, FreeformEditor, FreeformGeometry, Line, NonManifoldOutputError, OGSceneManager, OpenGeometry, Opening, OverlappingCuttersError, Polygon, Polyline, Rectangle, Solid, Sphere, SpotLabel, Sweep, Vector3, Wedge, booleanIntersection, booleanSubtraction, booleanUnion, clonePlacement, createBooleanExample, createEditorModesExample, createFreeformEditor, createFreeformGeometry, createOffsetExample, createParametricEditCapabilities, createPrimitivesExample, createShapesExample, createSweepExample, createWallFromOffsetsExample, describeWallSubtractError, executeBooleanSubtractionMany, extrudeBrepFace, parseBooleanError, toObjectTransformation$1 as toObjectTransformation };
11360
+ export { Arc, BooleanError, BooleanResult, CoincidentFacesError, Cuboid, Curve, CutterExceedsHostError, Cylinder, FreeformEditor, FreeformGeometry, Line, NonManifoldOutputError, OGSceneManager, OpenGeometry, Opening, OverlappingCuttersError, Polygon, Polyline, Rectangle, Solid, Sphere, SpotLabel, Sweep, Vector3, Wedge, booleanIntersection, booleanSubtraction, booleanUnion, clonePlacement, createBooleanExample, createEditorModesExample, createFreeformEditor, createFreeformGeometry, createOffsetExample, createParametricEditCapabilities, createPrimitivesExample, createShapesExample, createSweepExample, createWallFromOffsetsExample, describeWallSubtractError, executeBooleanSubtractionMany, extrudeBrepFace, offsetPolylineGroupRegions, offsetPolylineRegions, parseBooleanError, toObjectTransformation$1 as toObjectTransformation };
11213
11361
  //# sourceMappingURL=index.js.map