okgeometry-api 1.10.0 → 1.11.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.
@@ -474,11 +474,21 @@ export function mesh_evaluate(vertex_count: number, buffer: Float64Array, u: num
474
474
 
475
475
  /**
476
476
  * Export a mesh to OBJ format
477
- * Takes mesh buffers as input (same format as mesh_to_buffers output)
478
- * Returns OBJ string
477
+ * Takes the standard mesh buffer (`[vertexCount, ...positions, ...indices]`,
478
+ * same format as `mesh_to_buffers` / `Mesh.rawBuffer`) and returns OBJ text.
479
479
  */
480
480
  export function mesh_export_obj(vertex_count: number, buffer: Float64Array): string;
481
481
 
482
+ /**
483
+ * Export a mesh (standard buffer format) to ASCII STL text.
484
+ */
485
+ export function mesh_export_stl_ascii(vertex_count: number, buffer: Float64Array, name: string): string;
486
+
487
+ /**
488
+ * Export a mesh (standard buffer format) to binary STL bytes.
489
+ */
490
+ export function mesh_export_stl_binary(vertex_count: number, buffer: Float64Array): Uint8Array;
491
+
482
492
  /**
483
493
  * Push/pull a planar face set by moving its coplanar connected region.
484
494
  */
@@ -564,6 +574,17 @@ export function mesh_get_stats(vertex_count: number, buffer: Float64Array): Floa
564
574
  */
565
575
  export function mesh_import_obj(obj_data: string): Float64Array;
566
576
 
577
+ /**
578
+ * Import STL data (binary or ASCII, auto-detected) and return the standard
579
+ * mesh buffer (`[vertexCount, ...positions, ...indices]`). STL stores an
580
+ * unindexed triangle soup, so coincident vertices are welded.
581
+ *
582
+ * `weld_tolerance`: absolute distance under which vertices merge; `<= 0`
583
+ * selects an automatic tolerance from the bounding box. Returns an empty
584
+ * buffer on parse failure.
585
+ */
586
+ export function mesh_import_stl(data: Uint8Array, weld_tolerance: number): Float64Array;
587
+
567
588
  /**
568
589
  * Check if triangulated mesh is a closed volume (no welded boundary edges).
569
590
  */
@@ -1027,6 +1048,8 @@ export interface InitOutput {
1027
1048
  readonly mesh_create_sphere: (a: number, b: number, c: number) => [number, number];
1028
1049
  readonly mesh_evaluate: (a: number, b: number, c: number, d: number, e: number) => [number, number];
1029
1050
  readonly mesh_export_obj: (a: number, b: number, c: number) => [number, number];
1051
+ readonly mesh_export_stl_ascii: (a: number, b: number, c: number, d: number, e: number) => [number, number];
1052
+ readonly mesh_export_stl_binary: (a: number, b: number, c: number) => [number, number];
1030
1053
  readonly mesh_extrude_face: (a: number, b: number, c: number, d: number, e: number) => [number, number];
1031
1054
  readonly mesh_extrude_planar_curve: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
1032
1055
  readonly mesh_find_face_group_by_normal: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number];
@@ -1042,6 +1065,7 @@ export interface InitOutput {
1042
1065
  readonly mesh_get_smooth_face_group: (a: number, b: number, c: number, d: number, e: number) => [number, number];
1043
1066
  readonly mesh_get_stats: (a: number, b: number, c: number) => [number, number];
1044
1067
  readonly mesh_import_obj: (a: number, b: number) => [number, number];
1068
+ readonly mesh_import_stl: (a: number, b: number, c: number) => [number, number];
1045
1069
  readonly mesh_is_closed_volume: (a: number, b: number, c: number) => number;
1046
1070
  readonly mesh_manifold_port_import_roundtrip_debug: (a: number, b: number, c: number, d: number) => [number, number];
1047
1071
  readonly mesh_manifold_port_import_stage_hashes_debug: (a: number, b: number, c: number, d: number) => [number, number];
@@ -1688,8 +1688,8 @@ export function mesh_evaluate(vertex_count, buffer, u, v) {
1688
1688
 
1689
1689
  /**
1690
1690
  * Export a mesh to OBJ format
1691
- * Takes mesh buffers as input (same format as mesh_to_buffers output)
1692
- * Returns OBJ string
1691
+ * Takes the standard mesh buffer (`[vertexCount, ...positions, ...indices]`,
1692
+ * same format as `mesh_to_buffers` / `Mesh.rawBuffer`) and returns OBJ text.
1693
1693
  * @param {number} vertex_count
1694
1694
  * @param {Float64Array} buffer
1695
1695
  * @returns {string}
@@ -1709,6 +1709,45 @@ export function mesh_export_obj(vertex_count, buffer) {
1709
1709
  }
1710
1710
  }
1711
1711
 
1712
+ /**
1713
+ * Export a mesh (standard buffer format) to ASCII STL text.
1714
+ * @param {number} vertex_count
1715
+ * @param {Float64Array} buffer
1716
+ * @param {string} name
1717
+ * @returns {string}
1718
+ */
1719
+ export function mesh_export_stl_ascii(vertex_count, buffer, name) {
1720
+ let deferred3_0;
1721
+ let deferred3_1;
1722
+ try {
1723
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
1724
+ const len0 = WASM_VECTOR_LEN;
1725
+ const ptr1 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1726
+ const len1 = WASM_VECTOR_LEN;
1727
+ const ret = wasm.mesh_export_stl_ascii(vertex_count, ptr0, len0, ptr1, len1);
1728
+ deferred3_0 = ret[0];
1729
+ deferred3_1 = ret[1];
1730
+ return getStringFromWasm0(ret[0], ret[1]);
1731
+ } finally {
1732
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1733
+ }
1734
+ }
1735
+
1736
+ /**
1737
+ * Export a mesh (standard buffer format) to binary STL bytes.
1738
+ * @param {number} vertex_count
1739
+ * @param {Float64Array} buffer
1740
+ * @returns {Uint8Array}
1741
+ */
1742
+ export function mesh_export_stl_binary(vertex_count, buffer) {
1743
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
1744
+ const len0 = WASM_VECTOR_LEN;
1745
+ const ret = wasm.mesh_export_stl_binary(vertex_count, ptr0, len0);
1746
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1747
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1748
+ return v2;
1749
+ }
1750
+
1712
1751
  /**
1713
1752
  * Push/pull a planar face set by moving its coplanar connected region.
1714
1753
  * @param {number} vertex_count
@@ -1974,6 +2013,27 @@ export function mesh_import_obj(obj_data) {
1974
2013
  return v2;
1975
2014
  }
1976
2015
 
2016
+ /**
2017
+ * Import STL data (binary or ASCII, auto-detected) and return the standard
2018
+ * mesh buffer (`[vertexCount, ...positions, ...indices]`). STL stores an
2019
+ * unindexed triangle soup, so coincident vertices are welded.
2020
+ *
2021
+ * `weld_tolerance`: absolute distance under which vertices merge; `<= 0`
2022
+ * selects an automatic tolerance from the bounding box. Returns an empty
2023
+ * buffer on parse failure.
2024
+ * @param {Uint8Array} data
2025
+ * @param {number} weld_tolerance
2026
+ * @returns {Float64Array}
2027
+ */
2028
+ export function mesh_import_stl(data, weld_tolerance) {
2029
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
2030
+ const len0 = WASM_VECTOR_LEN;
2031
+ const ret = wasm.mesh_import_stl(ptr0, len0, weld_tolerance);
2032
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
2033
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2034
+ return v2;
2035
+ }
2036
+
1977
2037
  /**
1978
2038
  * Check if triangulated mesh is a closed volume (no welded boundary edges).
1979
2039
  * @param {number} vertex_count
@@ -3176,6 +3236,11 @@ function getArrayF64FromWasm0(ptr, len) {
3176
3236
  return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
3177
3237
  }
3178
3238
 
3239
+ function getArrayU8FromWasm0(ptr, len) {
3240
+ ptr = ptr >>> 0;
3241
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
3242
+ }
3243
+
3179
3244
  let cachedFloat32ArrayMemory0 = null;
3180
3245
  function getFloat32ArrayMemory0() {
3181
3246
  if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
@@ -3205,6 +3270,13 @@ function getUint8ArrayMemory0() {
3205
3270
  return cachedUint8ArrayMemory0;
3206
3271
  }
3207
3272
 
3273
+ function passArray8ToWasm0(arg, malloc) {
3274
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
3275
+ getUint8ArrayMemory0().set(arg, ptr / 1);
3276
+ WASM_VECTOR_LEN = arg.length;
3277
+ return ptr;
3278
+ }
3279
+
3208
3280
  function passArrayF64ToWasm0(arg, malloc) {
3209
3281
  const ptr = malloc(arg.length * 8, 8) >>> 0;
3210
3282
  getFloat64ArrayMemory0().set(arg, ptr / 8);