MCPcopy Create free account
hub / github.com/CNCKitchen/stlTexturizer / getShellAssignments

Function getShellAssignments

js/meshValidation.js:472–497  ·  view source on GitHub ↗
(adjacency, triCount)

Source from the content-addressed store, hash-verified

470/**
471 * Return per-triangle shell ID (0-based) via BFS on the adjacency graph.
472 *
473 * @param {Array<Array<{neighbor:number}>>} adjacency
474 * @param {number} triCount
475 * @returns {Uint32Array} shellId[t] = 0-based shell index for triangle t
476 */
477export function getShellAssignments(adjacency, triCount) {
478 const shellId = new Uint32Array(triCount); // default 0
479 const visited = new Uint8Array(triCount);
480 let nextShell = 0;
481 for (let seed = 0; seed < triCount; seed++) {
482 if (visited[seed]) continue;
483 const id = nextShell++;
484 const queue = [seed];
485 visited[seed] = 1;
486 shellId[seed] = id;
487 let head = 0;
488 while (head < queue.length) {
489 const cur = queue[head++];
490 const neighbors = adjacency[cur];
491 if (!neighbors) continue;
492 for (const { neighbor } of neighbors) {
493 if (!visited[neighbor]) {
494 visited[neighbor] = 1;
495 shellId[neighbor] = id;
496 queue.push(neighbor);
497 }
498 }
499 }
500 }

Callers 1

toggleDiagHighlightFunction · 0.90

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected