Skip to content
Shapemetry

@huukhanhnguyen/model / nodeMethods/solid/mesh

nodeMethods/solid/mesh

connectedFaceGroups()

connectedFaceGroups(faces): BrepData[][]

Partition faces into connected components (union-find over shared welded vertices). Each returned group is the face-set of one connected solid. A pre-wrapped multi-face document is already one component (its own points).

Parameters

faces

BrepData[]

Returns

BrepData[][]


curvedFaceData()

curvedFaceData(surface, reversed): BrepData | null

A NURBS surface → ONE natural-bounds curved scene face, built in the kernel (brep_face_from_surface, which answers a one-face SHELL handle). Null when the kernel refuses the surface, so callers can fall back to tessellating rather than drop geometry.

reversed is the construction flag, not a flip applied afterwards: an OPEN natural-bounds face (every wall this module builds) takes it verbatim, and only a CLOSED one — sphere, torus, full revolve — would additionally be re-oriented outward by the kernel's divergence integral.

Parameters

surface

NurbsSurface

reversed

boolean

Returns

BrepData | null


emitPlanarOrSplit()

emitPlanarOrSplit(loops3d, out): void

Emit one face's loops as Face region(s). An exactly-planar face maps to one region. A NON-planar single loop splits into planar triangles — but HOW it splits matters:

  • ≤4 points (the tessellated quad of a curved bevel/fillet surface — the case this branch exists for): fan from vertex 0, vertex-faithful.
  • 4 points (e.g. a boolean/merge output ring that drifted slightly off plane — irrational-coordinate models hit this): CDT on the ring's best-fit plane via the kernel. A vertex-0 fan on a CONCAVE ring produces overlapping garbage triangles ("fans" sweeping across the notches).

Parameters

loops3d

Point[][]

out

BrepData[]

Returns

void


explodeWraps()

explodeWraps(faces): BrepData[]

Expand solid/shell wraps to independent one-face documents for mesh topology ops (bevel, extrude-face) that still run on the welded half-edge MeshData waist. Re-weld with weldToWrap after the mesh op.

Parameters

faces

BrepData[]

Returns

BrepData[]


facesToMesh()

facesToMesh(faces): { tessellate: TriangleMesh; volume: number; }

The welded mesh's READS, each opening and releasing its own arena handle.

ponytail: this exists so the consumers outside this module keep their one spelling (facesToMesh(faces).tessellate()) while the live TypeScript class under it is gone — no object owns kernel memory across a call, which is the whole point. A caller that wants to mutate the topology takes facesToMeshHandle and frees it.

Parameters

faces

BrepData[]

Returns

{ tessellate: TriangleMesh; volume: number; }

tessellate()

tessellate(): TriangleMesh

Returns

TriangleMesh

volume()

volume(): number

Returns

number


facesToMeshHandle()

facesToMeshHandle(faces): number

A solid's faces as a welded half-edge mesh in the wasm ARENA (1e-6 vertex weld + T-junction stitch + half-edge build) — the operand every topology op below mutates. The caller releases it with freeMeshHandle; both ends are counted so the leak gate sees mesh handles exactly as it sees shells and tessellations.

Parameters

faces

BrepData[]

Returns

number


facesToTriangleMesh()

facesToTriangleMesh(faces): TriangleMesh

A solid's faces → the welded mesh's TRIANGLE SOUP. The display substrate nodeMethods/dataCollection.ts, solidify.ts, triangulate.ts and unfold.ts all read, and the reason none of them needs a handle: they want positions and indices, not a topology to mutate.

Parameters

faces

BrepData[]

Returns

TriangleMesh


freeMeshHandle()

freeMeshHandle(handle): void

Parameters

handle

number

Returns

void


meshToFaces()

meshToFaces(mesh): BrepData[]

A welded half-edge mesh HANDLE → its faces as Face[]. Exactly-planar n-gon faces (box sides, cut faces) map to one region each; non-planar faces split to planar triangles (see emitPlanarOrSplit) so the decompose → re-weld round-trip stays vertex-faithful.

Parameters

mesh

number

Returns

BrepData[]


nurbsToFaces()

nurbsToFaces(nurbs): BrepData[]

A kernel NURBS surface → one natural-bounds curved scene face when the boundary is honest (kernel ≥ 0.17.0); falls back to one planar triangle face per tessellation triangle only when the natural-bounds path refuses.

Parameters

nurbs

NurbsSurface

Returns

BrepData[]


tessellateFaces()

tessellateFaces(faces, curveTolerance?): BakedTriangleMesh

Parameters

faces

BrepData[]

curveTolerance?

number = DEFAULT_CURVE_TOLERANCE

Returns

BakedTriangleMesh


weldToWrap()

weldToWrap(faces): BrepData[]

Weld loose one-face documents into shell/solid wraps (producer construction). One wrap PER connected component — never fuse disjoint bodies by contact.

Parameters

faces

BrepData[]

Returns

BrepData[]

Last updated: 📖 4 min readEdit on GitHub