add prusa ini conversion mapping of gcode vars

speed up surface selection
This commit is contained in:
Stewart Allen 2022-04-14 12:46:31 -04:00
commit 0d58db27ed
5 changed files with 51 additions and 14 deletions

View file

@ -424,7 +424,7 @@ const tool = {
models = fallback(models);
api.log.emit('mapping faces').pin();
let promises = [];
// let mark = Date.now();
let mark = Date.now();
for (let m of models) {
let p = worker.model_mapFaces({ id: m.id, opt }).then(data => {
// console.log({map_info: data});
@ -433,7 +433,7 @@ const tool = {
}
Promise.all(promises).then(() => {
api.log.emit('mapping complete').unpin();
// api.log.emit(`... time = ${Date.now() - mark}`);
api.log.emit(`... map time = ${Date.now() - mark}`);
});
},

View file

@ -529,14 +529,32 @@ mesh.model = class MeshModel extends mesh.object {
selectFaces(list = [], action = {}) {
let faces = this.sel.faces;
for (let t of list) {
if (action.toggle) {
faces.remove(t) || faces.addOnce(t);
} else if (action.clear) {
faces.remove(t);
} else if (action.select) {
faces.addOnce(t);
let map = {};
for (let f of list) {
map[f] = f;
}
if (action.toggle) {
faces = faces.filter(f => {
if (map[f] !== undefined) {
map[f] = undefined;
return false;
} else {
return true;
}
});
faces.appendAll(Object.entries(map).filter(kv => {
return kv[1] !== undefined;
}).map(kv => {
return kv[1];
}));
this.sel.faces = faces;
} else if (action.clear) {
this.sel.faces = faces.filter(f => map[f] === undefined);
} else if (action.select) {
for (let f of faces) {
map[f] = undefined;
}
faces.appendAll(Object.values(map).filter(f => f !== undefined));
}
}
@ -576,9 +594,11 @@ mesh.model = class MeshModel extends mesh.object {
timer = undefined;
mesh.api.log.emit("matching surface").pin();
}, 150);
// let mark = Date.now();
worker.model_select({
id: this.id, x, y:-z, z:y, a, b, c, matrix: this.matrix, surface
}).then(data => {
// mesh.api.log.emit(`... data time = ${Date.now() - mark}`); mark = Date.now();
if (timer) {
clearTimeout(timer);
}
@ -586,11 +606,13 @@ mesh.model = class MeshModel extends mesh.object {
// console.log({data});
// this.toggleSelectedVertices(verts);
this.selectFaces(faces, action);
// mesh.api.log.emit(`... select time = ${Date.now() - mark}`); mark = Date.now();
this.updateSelections();
if (!timer) {
mesh.api.log.emit("surface match complete").unpin();
moto.space.refresh();
}
// mesh.api.log.emit(`... paint time = ${Date.now() - mark}`);
});
}

View file

@ -200,7 +200,7 @@ mesh.tool = class MeshTool {
const s2 = (v2 < v0 ? v2 + "," + v0 : v0 + "," +v2);
// for storing raw vertex offset in side record
const [ vr0, vr1, vr2 ] = viraw;
const vv = [ vr0, vr1, vr1, vr2, vr2, vr0 ];
// const vv = [ vr0, vr1, vr1, vr2, vr2, vr0 ];
// store face indexes into sdrec array for each side
const smap = [ s0, s1, s2 ].map((key,ki) => {
let sid = simap[key], sdoff, sdcnt;
@ -208,8 +208,10 @@ mesh.tool = class MeshTool {
sid = simap[key] = sn++;
sdcnt = srecs[sid] = 1;
sdoff = sid * 4;
sides[sdoff] = vv[ki * 2];
sides[sdoff + 1] = vv[ki * 2 + 1];
// sides[sdoff] = vv[ki * 2];
// sides[sdoff + 1] = vv[ki * 2 + 1];
sides[sdoff] = viraw[ki];
sides[sdoff + 1] = viraw[(ki + 1) % 3];
} else {
sdoff = sid * 4;
sdcnt = ++srecs[sid];
@ -236,7 +238,7 @@ mesh.tool = class MeshTool {
this.indexed = {
faces, sides, sideExt
};
// console.log(this.indexed);
console.log(this.indexed);
}
getAdjacentFaces(face) {