Model - Surface divide
API reference for src/nodeMethods/surfaceDivide on @huukhanhnguyen/model, reachable from ./compute.
See the Guide for the ModelJSON / evaluate pipeline.
API reference
Signatures are generated from the live package .d.ts - not hand-written.
surfaceDivide
function
surfaceDivide — Revit-style "Divide Surface": UV-divide a NURBS surface into a countU x countV grid of cells, each drawn either as isocurve grid lines (default) or filled with an adaptive pattern sub-model resolved through the owner hook resolvePatternComponent (see nodesRegistry/ wiring.ts's "surfaceDivide" hand-wire branch).
Cell (i, j)'s UV rect is [i/countU, (i+1)/countU] x [j/countV, (j+1)/countV]. trim (optional) is closed planar loops already expressed in the surface's own normalized UV space (u, v, 0). A cell's visible footprint is found by treating the cell's UV rect as the clip WINDOW and each trim loop as the polygon being clipped (projection.ts's clipPolygonToWindow, reused backwards from its usual "clip geometry to a viewport" role — exact for the convex cell window regardless of the trim loop's own convexity). An empty footprint (no overlap, incl. a boundary-only touch — filtered by a shoelace-area floor, not just vertex count) drops the cell outright, with nothing emitted for it. Grid-curve edges of a border cell are trimmed separately with clipSegmentToLoops against the trim's own loops.
A cell's PHYSICAL mm size (the pattern path) is measured once via Surface.point at its 4 UV corners. CEILING: this assumes the surface's parameterization is locally close to uniform-speed within one cell — a strongly non-uniform surface (very unequal knot spacing, a pole near the cell) will distort a pattern's geometry inside that cell; nothing here reparameterizes by arc length. Raise countU/countV as the workaround.
The surface crosses to the kernel as its own JSON, and every multi-point evaluation goes through the BATCH Surface.points — the per-point export re-parses that JSON on every call, and a divide walks 4 corners plus 9 stations per cell edge.
surfaceDivide(surfaceInput: unknown, countU?: number, countV?: number, trimInput?: unknown, pattern?: string, resolveTexture?: (key: string, cellMmLoops: Point$1[][]) => unknown[] | undefined): Entity[]