jsketcher/web/app/cad/occ/entityIdentity.ts
2022-06-25 14:32:14 -07:00

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;