mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-20 23:43:27 +01:00
36 lines
No EOL
860 B
TypeScript
36 lines
No EOL
860 B
TypeScript
|
|
import {Shell} from "brep/topo/shell";
|
|
|
|
export function assignEntityIdentity(created: Shell[], consumed: Shell[]) {
|
|
|
|
let refIndex = indexFacesByRef(consumed);
|
|
|
|
let shell = readBrep(data);
|
|
for (let face of shell.faces) {
|
|
let ref = getRef(face);
|
|
if (ref !== undefined) {
|
|
let consumedFace = refIndex.get(ref);
|
|
if (consumedFace) {
|
|
face.data.id = consumedFace.id;
|
|
}
|
|
}
|
|
}
|
|
return new MBrepShell(shell, csys);
|
|
}
|
|
|
|
function indexFacesByRef(shells: Shell[]) {
|
|
let index = new Map();
|
|
if (shells) {
|
|
for (let shell of shells) {
|
|
for (let face of shell.faces) {
|
|
let ref = getRef(face.brepFace);
|
|
if (ref !== undefined) {
|
|
index.set(ref, face);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return index;
|
|
}
|
|
|
|
const getRef = brepFace => brepFace && brepFace.data.externals && brepFace.data.externals.ref; |