@meshioplusplus/wasm 17.8.0 → 17.10.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/index.d.ts CHANGED
@@ -1144,8 +1144,9 @@ export type InterpolateOnConflict = 'error' | 'overwrite' | 'suffix';
1144
1144
  * exists on the target: throw, replace, or write to `name + '_interp'`. */
1145
1145
  export type ConservativeInterpolateOnConflict = 'error' | 'overwrite' | 'suffix';
1146
1146
 
1147
- /** Partitioning backend: SFC is always available; KaHIP is never compiled
1148
- * into the WASM build, so `'kahip'` always throws and `'auto'` = `'sfc'`. */
1147
+ /** Partitioning backend: SFC is always available; KaHIP is linked only in
1148
+ * the full artifact, so `'kahip'` throws there outside it and `'auto'`
1149
+ * resolves to SFC. */
1149
1150
  export type PartitionMethod = 'sfc' | 'kahip' | 'auto';
1150
1151
 
1151
1152
  /** KaHIP preconfiguration (ignored by the SFC method). */
@@ -1743,10 +1744,18 @@ export interface MeshioPlusPlusModule {
1743
1744
 
1744
1745
  /**
1745
1746
  * Whether OpenCASCADE is linked in, so `step` and `iges` read and `fitCad`
1746
- * runs: true in the full artifact (`{full: true}`), false in the lean one.
1747
+ * has its OpenCASCADE backend: true in the full artifact (`{full: true}`),
1748
+ * false in the lean one (where `fitCad` runs the native backend).
1747
1749
  */
1748
1750
  hasOcct(): boolean;
1749
1751
 
1752
+ /**
1753
+ * Whether the KaHIP kaffpa partitioner is linked in, so `partition` with
1754
+ * `method: 'kahip'` runs: true in the full artifact (`{full: true}`),
1755
+ * false in the lean one.
1756
+ */
1757
+ hasKahip(): boolean;
1758
+
1750
1759
  /** Whether the VTK XML zstd block codec is linked in (the full artifact). */
1751
1760
  hasZstd(): boolean;
1752
1761
 
@@ -2058,6 +2067,47 @@ export interface MeshioPlusPlusModule {
2058
2067
  grid(dims: number[], origin?: number[] | null, spacing?: number[] | null,
2059
2068
  maxCells?: number): Mesh;
2060
2069
 
2070
+ /**
2071
+ * A regular 2-D grid of quads or triangles at `z = origin[2]`, points x
2072
+ * fastest. `split` (`'zigzag'`, `'up'`, `'down'`, `'center'`) lays out the
2073
+ * triangles; `order: 2` gives `quad8` / `triangle6` cells on the exact
2074
+ * geometry. Side regions `xmin`, `xmax`, `ymin`, `ymax`.
2075
+ * @throws {Error} on a bad count, size, cell type, split or order, or a mesh
2076
+ * above `maxCells`.
2077
+ */
2078
+ rectangle(dims?: number[] | null, size?: number[] | null, origin?: number[] | null,
2079
+ cellType?: string, split?: string, order?: number, maxCells?: number): Mesh;
2080
+
2081
+ /** A regular 3-D grid of `'hexahedron'`, `'tetra'` (six Kuhn tetrahedra per
2082
+ * cell) or `'wedge'` cells. Side regions `xmin` ... `zmax`. */
2083
+ box(dims?: number[] | null, size?: number[] | null, origin?: number[] | null,
2084
+ cellType?: string, order?: number, maxCells?: number): Mesh;
2085
+
2086
+ /** A disk of `n x n` quads (squircle map) or `n` rings of triangles. Side
2087
+ * region `rim`. */
2088
+ disk(radius?: number, n?: number, center?: number[] | null, cellType?: string,
2089
+ order?: number, maxCells?: number): Mesh;
2090
+
2091
+ /** A latitude / longitude sphere surface, oriented outward; `cellType: 'quad'`
2092
+ * gives quads between the rings and triangle caps. */
2093
+ uvSphere(radius?: number, nu?: number, nv?: number, center?: number[] | null,
2094
+ cellType?: string, order?: number, maxCells?: number): Mesh;
2095
+
2096
+ /** A sphere surface of `20 * 4^subdivisions` triangles, oriented outward. */
2097
+ icosaSphere(radius?: number, subdivisions?: number, center?: number[] | null,
2098
+ order?: number, maxCells?: number): Mesh;
2099
+
2100
+ /** A solid cylinder along z, `'hexahedron'` or `'wedge'` cells. Side regions
2101
+ * `side`, `top`, `bottom`. */
2102
+ cylinder(radius?: number, height?: number, nxy?: number, nz?: number,
2103
+ center?: number[] | null, cellType?: string, order?: number,
2104
+ maxCells?: number): Mesh;
2105
+
2106
+ /** One cell of each requested meshio type in its reference coordinates, side
2107
+ * by side (every supported type when `types` is omitted); `pairs` gives two
2108
+ * cells sharing a facet, for linear types. */
2109
+ referenceCells(types?: string[] | null, pairs?: boolean): Mesh;
2110
+
2061
2111
  /**
2062
2112
  * Build a regular grid around a mesh. Give exactly one of `resolution` and
2063
2113
  * `cellSize`; `fill` selects the whole bounding box, only the cells a triangle
@@ -2583,7 +2633,10 @@ export interface MeshioPlusPlusModule {
2583
2633
  * feature edges. The mesh comes back unchanged plus cell data
2584
2634
  * `segment:patch` (-1 off the surface), field data `segment:adjacency`
2585
2635
  * (rows `[a, b, sharedEdges]`) and one cell region per patch,
2586
- * `<prefix>:<k>`. See doc/segment.md.
2636
+ * `<prefix>:<k>`. `method: 'primitive'` (v17.9.0) ends a patch where the
2637
+ * surface its facets lie on changes, at `tolerance` (relative to the
2638
+ * diagonal), so a fillet comes apart from its tangent planes. See
2639
+ * doc/segment.md.
2587
2640
  * @throws {Error} on an option out of range, an unknown region or a volume block.
2588
2641
  */
2589
2642
  segment(
@@ -2594,6 +2647,8 @@ export interface MeshioPlusPlusModule {
2594
2647
  minPatchCells?: number,
2595
2648
  region?: string,
2596
2649
  prefix?: string,
2650
+ method?: 'angle' | 'primitive',
2651
+ tolerance?: number,
2597
2652
  ): {
2598
2653
  mesh: Mesh;
2599
2654
  numPatches: number;
@@ -2635,10 +2690,12 @@ export interface MeshioPlusPlusModule {
2635
2690
  * output of `segment` then `fitPrimitives`): planes, spheres, cylinders,
2636
2691
  * cones and tori, fillets and blends, threads and freeform B-spline faces,
2637
2692
  * sewn and checked by OpenCASCADE, optionally written as STEP to
2638
- * `stepPath` on the virtual FS. Needs OpenCASCADE: the full artifact only.
2639
- * See doc/fit_cad.md.
2640
- * @throws {Error} in the lean artifact (naming `{full: true}`), on a bad
2641
- * option, or on a skin that is not closed.
2693
+ * `stepPath` on the virtual FS. The lean artifact (and `backend: 'native'`)
2694
+ * runs the kernel-free backend instead (v17.9.0): the fitted patches become
2695
+ * analytic STEP faces, the rest coplanar polygons, and `mesh` is the skin
2696
+ * itself. See doc/fit_cad.md.
2697
+ * @throws {Error} with `backend: 'occt'` in the lean artifact (naming
2698
+ * `{full: true}`), on a bad option, or on a skin that is not closed.
2642
2699
  */
2643
2700
  fitCad(mesh: Mesh, options?: FitCadOptions): FitCadResult;
2644
2701
 
@@ -3129,9 +3186,9 @@ export interface MeshioPlusPlusModule {
3129
3186
  * scalar `cell_data` array of per-cell weights. `ghostLayers > 0` grows
3130
3187
  * each piece by that many shared-node BFS layers of other parts' cells (a
3131
3188
  * halo), tagged `partition:ghost`.
3132
- * @throws {Error} on `method: 'kahip'` (KaHIP is never part of the WASM
3133
- * build; the message names `MESHIOPLUSPLUS_WITH_KAHIP`), `nparts < 1`,
3134
- * `ghostLayers < 0`, or a bad weights array.
3189
+ * @throws {Error} on `method: 'kahip'` outside the full artifact (KaHIP
3190
+ * is linked only there; the message names `MESHIOPLUSPLUS_WITH_KAHIP`),
3191
+ * `nparts < 1`, `ghostLayers < 0`, or a bad weights array.
3135
3192
  */
3136
3193
  partition(
3137
3194
  mesh: Mesh,
@@ -3374,6 +3431,10 @@ export interface FitCadOptions {
3374
3431
  fillets?: boolean;
3375
3432
  /** Try thread faces, tapered and of varying pitch included (default true). */
3376
3433
  threads?: boolean;
3434
+ /** Merge faces on one surface once the solid is built (default true; v17.9.0). */
3435
+ mergeFaces?: boolean;
3436
+ /** The engine: OpenCASCADE when linked in (`'auto'`, the default), or none (v17.9.0). */
3437
+ backend?: 'auto' | 'occt' | 'native';
3377
3438
  }
3378
3439
 
3379
3440
  /** What {@link MeshioPlusPlusModule.fitCad} built. */
@@ -3417,6 +3478,8 @@ export interface FitCadResult {
3417
3478
  numTaperedThread: number;
3418
3479
  /** Thread flanks whose pitch varies along the axis. */
3419
3480
  numVariablePitchThread: number;
3481
+ /** The engine that built the solid (v17.9.0). */
3482
+ backend: 'occt' | 'native';
3420
3483
  /** The solid's B-rep, for `writeMesh(path, mesh, 'cad_json', {info})`. */
3421
3484
  info: CadJsonInfo;
3422
3485
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshioplusplus/wasm",
3
- "version": "17.8.0",
3
+ "version": "17.10.0",
4
4
  "description": "meshio++ mesh I/O compiled to WebAssembly: read 80 and write 75 mesh formats (incl. MED, CGNS, Exodus; STEP and IGES in the full build) in the browser or Node.js",
5
5
  "type": "module",
6
6
  "main": "./src/index.mjs",
package/src/index.mjs CHANGED
@@ -32,7 +32,7 @@
32
32
  //
33
33
  // Beside that lean pair the package ships the FULL pair (roadmap 6.2),
34
34
  // meshioplusplus_wasm_full and meshioplusplus_wasm_full_mt: the same API, with
35
- // OpenCASCADE (STEP/IGES reading, fitCad), zstd, lz4 and bzip2 linked in, and
35
+ // OpenCASCADE (STEP/IGES reading, fitCad's OpenCASCADE backend), zstd, lz4 and bzip2 linked in, and
36
36
  // a mixed licence (OpenCASCADE is LGPL-2.1 with its exception; see
37
37
  // THIRD_PARTY_NOTICES.md). `{ full: true }` loads it, with the same variant
38
38
  // choice. Its import() is deliberately NOT literal: a bundler that saw it would
@@ -249,6 +249,7 @@ export class MeshioPlusPlusLoadError extends Error {
249
249
  * parallelBackend: () => string,
250
250
  * hasCgnslib: () => boolean,
251
251
  * hasOcct: () => boolean,
252
+ * hasKahip: () => boolean,
252
253
  * hasZstd: () => boolean,
253
254
  * hasLz4: () => boolean,
254
255
  * hasBzip2: () => boolean,
@@ -275,6 +276,13 @@ export class MeshioPlusPlusLoadError extends Error {
275
276
  * slice: (mesh: Mesh, origin: number[], normal: number[], recordParentIds?: boolean) => Mesh,
276
277
  * isosurface: (mesh: Mesh, array: string, isovalues: number|number[], component?: number, recordParentIds?: boolean) => Mesh,
277
278
  * grid: (dims: number[], origin?: number[], spacing?: number[], maxCells?: number) => Mesh,
279
+ * rectangle: (dims?: number[], size?: number[], origin?: number[], cellType?: string, split?: string, order?: number, maxCells?: number) => Mesh,
280
+ * box: (dims?: number[], size?: number[], origin?: number[], cellType?: string, order?: number, maxCells?: number) => Mesh,
281
+ * disk: (radius?: number, n?: number, center?: number[], cellType?: string, order?: number, maxCells?: number) => Mesh,
282
+ * uvSphere: (radius?: number, nu?: number, nv?: number, center?: number[], cellType?: string, order?: number, maxCells?: number) => Mesh,
283
+ * icosaSphere: (radius?: number, subdivisions?: number, center?: number[], order?: number, maxCells?: number) => Mesh,
284
+ * cylinder: (radius?: number, height?: number, nxy?: number, nz?: number, center?: number[], cellType?: string, order?: number, maxCells?: number) => Mesh,
285
+ * referenceCells: (types?: string[], pairs?: boolean) => Mesh,
278
286
  * voxelize: (mesh: Mesh, resolution?: number[], cellSize?: number, bounds?: number[], padding?: number, paddingRelative?: number, fill?: string, sign?: string, attachOccupancy?: boolean, maxCells?: number, watertightCheck?: string) => {mesh: Mesh, dims: number[], origin: number[], spacing: number[], numOccupied: number},
279
287
  * octree: (mesh: Mesh, rootCells?: number[], minLevel?: number, maxLevel?: number, bounds?: number[], padding?: number, paddingRelative?: number, dimension?: number, sampleDistance?: number, balance?: string, fill?: string, sign?: string, attachDistance?: boolean, evenOdd?: boolean, maxCells?: number, watertightCheck?: string, transition?: string, snap?: boolean, surfaceLevel?: number, curvatureThreshold?: number, featureAngle?: number, sizeArray?: string, plane?: string) => {mesh: Mesh, dimension: number, numLeaves: number, numHanging: number, finestLevel: number, origin: number[], rootSize: number, numSnapped: number, numRefused: number},
280
288
  * surfaceWatertightCheck: (mesh: Mesh) => {boundaryEdges: number, nonManifoldEdges: number, inconsistentPairs: number, degenerateTriangles: number, watertight: boolean},
@@ -291,12 +299,12 @@ export class MeshioPlusPlusLoadError extends Error {
291
299
  * computeNormals: (mesh: Mesh, pointNormals?: boolean, cellNormals?: boolean, weight?: string, splitAngle?: number, recordParentIds?: boolean, region?: string) => {mesh: Mesh, numIsolated: number, numUndefined: number, numDegenerate: number, numSplitPoints: number, numAddedPoints: number, quality: {boundaryEdges: number, nonManifoldEdges: number, inconsistentPairs: number, degenerateTriangles: number, watertight: boolean}},
292
300
  * checkQuality: (mesh: Mesh, require?: string, maxInverted?: number, maxDegenerate?: number) => {passed: boolean, numCells: number, numInverted: number, numDegenerate: number, checks: Array<object>, summary: string},
293
301
  * featureEdges: (mesh: Mesh, featureAngle?: number, feature?: boolean, boundary?: boolean, nonManifold?: boolean, inconsistent?: boolean, region?: string) => {mesh: Mesh, numFeature: number, numBoundary: number, numNonManifold: number, numInconsistent: number},
294
- * segment: (mesh: Mesh, featureAngle?: number, normalTolerance?: number, curvatureTolerance?: number, minPatchCells?: number, region?: string, prefix?: string) => {mesh: Mesh, numPatches: number, numMerged: number, numFeatureEdges: number, numBoundaryEdges: number, numNonManifoldEdges: number},
302
+ * segment: (mesh: Mesh, featureAngle?: number, normalTolerance?: number, curvatureTolerance?: number, minPatchCells?: number, region?: string, prefix?: string, method?: 'angle' | 'primitive', tolerance?: number) => {mesh: Mesh, numPatches: number, numMerged: number, numFeatureEdges: number, numBoundaryEdges: number, numNonManifoldEdges: number},
295
303
  * igaRefine: (info: object, options?: {subdivisions?: number | number[], elevate?: number | number[], sampleSubdivisions?: number, trimSamples?: number, edges?: boolean, trim?: boolean}) => {mesh: Mesh, info: object},
296
304
  * igaSample: (info: object, options?: {sampleSubdivisions?: number, trimSamples?: number, edges?: boolean, trim?: boolean}) => {mesh: Mesh, info: object},
297
305
  * igaEvaluate: (info: object, patch: number, params: ArrayLike<number>, options?: {derivatives?: 0 | 1, trimSamples?: number}) => object,
298
306
  * fitPrimitives: (mesh: Mesh, patchData?: string, tolerance?: number, relative?: boolean, minInlierFraction?: number, types?: string[], maxIterations?: number) => {mesh: Mesh, numPatches: number, numPlane: number, numSphere: number, numCylinder: number, numCone: number, numTorus: number, numUnfitted: number},
299
- * fitCad: (mesh: Mesh, options?: {stepPath?: string, tolerance?: number, exactEdges?: boolean, types?: string[], meshDeflection?: number, maxDemotionRounds?: number, freeform?: boolean, freeformDegree?: number, freeformMaxControl?: number, freeformSplit?: boolean, fillets?: boolean, threads?: boolean}) => object,
307
+ * fitCad: (mesh: Mesh, options?: {stepPath?: string, tolerance?: number, exactEdges?: boolean, types?: string[], meshDeflection?: number, maxDemotionRounds?: number, freeform?: boolean, freeformDegree?: number, freeformMaxControl?: number, freeformSplit?: boolean, fillets?: boolean, threads?: boolean, mergeFaces?: boolean, backend?: 'auto' | 'occt' | 'native'}) => object,
300
308
  * tessellate: (mesh: Mesh, levels?: number, curved?: boolean, fields?: boolean, recordStencil?: boolean) => {mesh: Mesh, numSourcePoints: number, numSourceCells: number, numCurvedSourceCells: number, numPassThroughSourceCells: number, numPoints: number, numCells: number, numBoundaryFacets: number, numInteriorFacets: number, numFacetsWithBadCount: number},
301
309
  * render: (mesh: Mesh, options?: RenderOptions) => RenderedFrame,
302
310
  * renderText: (mesh: Mesh, options?: RenderOptions, text?: RenderTextOptions) => string,
@@ -601,9 +609,10 @@ export async function loadMeshioPlusPlus(
601
609
  // meshioplusplus_wasm_mt one -- which of the two this instance loaded.
602
610
  parallelBackend: () => Module.parallelBackend(),
603
611
  hasCgnslib: () => Module.hasCgnslib(),
604
- // The full artifact's libraries (roadmap 6.2): all four are true there
612
+ // The full artifact's libraries (roadmap 6.2): all five are true there
605
613
  // and false in the lean one. buildFlavour() names which loaded.
606
614
  hasOcct: () => Module.hasOcct(),
615
+ hasKahip: () => Module.hasKahip(),
607
616
  hasZstd: () => Module.hasZstd(),
608
617
  hasLz4: () => Module.hasLz4(),
609
618
  hasBzip2: () => Module.hasBzip2(),
@@ -741,6 +750,28 @@ export async function loadMeshioPlusPlus(
741
750
  Module.slice(mesh, origin, normal, recordParentIds),
742
751
  grid: (dims, origin = null, spacing = null, maxCells = 20000000) =>
743
752
  Module.grid(dims, origin, spacing, maxCells),
753
+ rectangle: (
754
+ dims = null, size = null, origin = null, cellType = 'quad', split = 'zigzag',
755
+ order = 1, maxCells = 20000000,
756
+ ) => Module.rectangle(dims, size, origin, cellType, split, order, maxCells),
757
+ box: (
758
+ dims = null, size = null, origin = null, cellType = 'hexahedron', order = 1,
759
+ maxCells = 20000000,
760
+ ) => Module.box(dims, size, origin, cellType, order, maxCells),
761
+ disk: (
762
+ radius = 1, n = 8, center = null, cellType = 'quad', order = 1, maxCells = 20000000,
763
+ ) => Module.disk(radius, n, center, cellType, order, maxCells),
764
+ uvSphere: (
765
+ radius = 1, nu = 16, nv = 8, center = null, cellType = 'triangle', order = 1,
766
+ maxCells = 20000000,
767
+ ) => Module.uvSphere(radius, nu, nv, center, cellType, order, maxCells),
768
+ icosaSphere: (radius = 1, subdivisions = 2, center = null, order = 1, maxCells = 20000000) =>
769
+ Module.icosaSphere(radius, subdivisions, center, order, maxCells),
770
+ cylinder: (
771
+ radius = 1, height = 1, nxy = 8, nz = 8, center = null, cellType = 'hexahedron',
772
+ order = 1, maxCells = 20000000,
773
+ ) => Module.cylinder(radius, height, nxy, nz, center, cellType, order, maxCells),
774
+ referenceCells: (types = null, pairs = false) => Module.referenceCells(types, pairs),
744
775
  voxelize: (
745
776
  mesh,
746
777
  resolution = null,
@@ -962,9 +993,11 @@ export async function loadMeshioPlusPlus(
962
993
  minPatchCells = 1,
963
994
  region = '',
964
995
  prefix = 'patch',
996
+ method = 'angle',
997
+ tolerance = 1e-3,
965
998
  ) =>
966
999
  Module.segment(mesh, featureAngle, normalTolerance, curvatureTolerance,
967
- minPatchCells, region, prefix),
1000
+ minPatchCells, region, prefix, method, tolerance),
968
1001
  fitPrimitives: (
969
1002
  mesh,
970
1003
  patchData = 'segment:patch',