mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-09 18:02:50 +01:00
keep sketches of consumed shells
This commit is contained in:
parent
fe9d7c1a81
commit
2f34f9390e
3 changed files with 40 additions and 5 deletions
|
|
@ -21,7 +21,12 @@ export function readBrep(data) {
|
|||
format: 'verbose',
|
||||
data: normalizeTesselationData(faceData.tess, inverted, faceData.surface.normal)
|
||||
};
|
||||
|
||||
if (faceData.ref !== undefined) {
|
||||
bb._face.data.externals = {
|
||||
ref: faceData.ref
|
||||
}
|
||||
}
|
||||
|
||||
for (let loop of faceData.loops) {
|
||||
bb.loop();
|
||||
for (let edgeData of loop) {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ export class MBrepShell extends MShell {
|
|||
let vertexCounter = 0;
|
||||
|
||||
for (let brepFace of this.brepShell.faces) {
|
||||
const mFace = new MBrepFace(this.id + '/F:' + faceCounter++, this, brepFace);
|
||||
const mFace = new MBrepFace(brepFace.data.id || (this.id + '/F:' + faceCounter++), this, brepFace);
|
||||
this.faces.push(mFace);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,36 @@
|
|||
import {readBrep} from '../../../brep/io/brepIO';
|
||||
import {MBrepShell} from '../../model/mshell';
|
||||
|
||||
export function readShellEntityFromJson(data) {
|
||||
return new MBrepShell(readBrep(data));
|
||||
}
|
||||
export function readShellEntityFromJson(data, consumed) {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
function indexFacesByRef(shells) {
|
||||
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;
|
||||
Loading…
Reference in a new issue