add prusa ini conversion mapping of gcode vars
speed up surface selection
This commit is contained in:
parent
a1c274341e
commit
0d58db27ed
5 changed files with 51 additions and 14 deletions
|
|
@ -9,6 +9,7 @@ Full docs @ https://docs.grid.space/projects/kiri-moto
|
||||||
## Kiri:moto
|
## Kiri:moto
|
||||||
|
|
||||||
* `C` added batch processing to object adds/removes to speedup complex workspace restore
|
* `C` added batch processing to object adds/removes to speedup complex workspace restore
|
||||||
|
* `C` substitute some prusa slicer [variables] with KM {variables} on import
|
||||||
* `C` fix CAM output order for tool changes an spindle speed updates
|
* `C` fix CAM output order for tool changes an spindle speed updates
|
||||||
* `I` add CAM pocket operation using surface selection
|
* `I` add CAM pocket operation using surface selection
|
||||||
* `-` refactor cnc to use new core slicer engine
|
* `-` refactor cnc to use new core slicer engine
|
||||||
|
|
@ -16,6 +17,7 @@ Full docs @ https://docs.grid.space/projects/kiri-moto
|
||||||
|
|
||||||
## Mesh:Tool
|
## Mesh:Tool
|
||||||
|
|
||||||
|
* `C` significant speed-up for large surface selections
|
||||||
* `C` multi-body identification and isolation
|
* `C` multi-body identification and isolation
|
||||||
* `-` parameterize svg and image import
|
* `-` parameterize svg and image import
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -618,6 +618,11 @@ function settingsImportZip(data, ask) {
|
||||||
function settingsPrusaConvert(data) {
|
function settingsPrusaConvert(data) {
|
||||||
const { uc } = api;
|
const { uc } = api;
|
||||||
const map = {};
|
const map = {};
|
||||||
|
const vsub = {
|
||||||
|
'[first_layer_bed_temperature]': '{bed_temp}',
|
||||||
|
'[first_layer_temperature]': '{temp}',
|
||||||
|
'[layer_z]': '{z}'
|
||||||
|
};
|
||||||
try {
|
try {
|
||||||
data.split('\n')
|
data.split('\n')
|
||||||
.filter(l => l.charAt(0) !== '#')
|
.filter(l => l.charAt(0) !== '#')
|
||||||
|
|
@ -625,7 +630,13 @@ function settingsPrusaConvert(data) {
|
||||||
.map(l => {
|
.map(l => {
|
||||||
// convert gcode string into a string array
|
// convert gcode string into a string array
|
||||||
if (l[0].indexOf('_gcode') > 0) {
|
if (l[0].indexOf('_gcode') > 0) {
|
||||||
l[1] = l[1].replaceAll('\\n','\n').split('\n');
|
l[1] = l[1].replaceAll('\\n','\n').split('\n')
|
||||||
|
.map(line => {
|
||||||
|
for (let [k,v] of Object.entries(vsub)) {
|
||||||
|
line = line.replace(k,v);
|
||||||
|
}
|
||||||
|
return line;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return l;
|
return l;
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -424,7 +424,7 @@ const tool = {
|
||||||
models = fallback(models);
|
models = fallback(models);
|
||||||
api.log.emit('mapping faces').pin();
|
api.log.emit('mapping faces').pin();
|
||||||
let promises = [];
|
let promises = [];
|
||||||
// let mark = Date.now();
|
let mark = Date.now();
|
||||||
for (let m of models) {
|
for (let m of models) {
|
||||||
let p = worker.model_mapFaces({ id: m.id, opt }).then(data => {
|
let p = worker.model_mapFaces({ id: m.id, opt }).then(data => {
|
||||||
// console.log({map_info: data});
|
// console.log({map_info: data});
|
||||||
|
|
@ -433,7 +433,7 @@ const tool = {
|
||||||
}
|
}
|
||||||
Promise.all(promises).then(() => {
|
Promise.all(promises).then(() => {
|
||||||
api.log.emit('mapping complete').unpin();
|
api.log.emit('mapping complete').unpin();
|
||||||
// api.log.emit(`... time = ${Date.now() - mark}`);
|
api.log.emit(`... map time = ${Date.now() - mark}`);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -529,14 +529,32 @@ mesh.model = class MeshModel extends mesh.object {
|
||||||
|
|
||||||
selectFaces(list = [], action = {}) {
|
selectFaces(list = [], action = {}) {
|
||||||
let faces = this.sel.faces;
|
let faces = this.sel.faces;
|
||||||
for (let t of list) {
|
let map = {};
|
||||||
if (action.toggle) {
|
for (let f of list) {
|
||||||
faces.remove(t) || faces.addOnce(t);
|
map[f] = f;
|
||||||
} else if (action.clear) {
|
|
||||||
faces.remove(t);
|
|
||||||
} else if (action.select) {
|
|
||||||
faces.addOnce(t);
|
|
||||||
}
|
}
|
||||||
|
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;
|
timer = undefined;
|
||||||
mesh.api.log.emit("matching surface").pin();
|
mesh.api.log.emit("matching surface").pin();
|
||||||
}, 150);
|
}, 150);
|
||||||
|
// let mark = Date.now();
|
||||||
worker.model_select({
|
worker.model_select({
|
||||||
id: this.id, x, y:-z, z:y, a, b, c, matrix: this.matrix, surface
|
id: this.id, x, y:-z, z:y, a, b, c, matrix: this.matrix, surface
|
||||||
}).then(data => {
|
}).then(data => {
|
||||||
|
// mesh.api.log.emit(`... data time = ${Date.now() - mark}`); mark = Date.now();
|
||||||
if (timer) {
|
if (timer) {
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
}
|
}
|
||||||
|
|
@ -586,11 +606,13 @@ mesh.model = class MeshModel extends mesh.object {
|
||||||
// console.log({data});
|
// console.log({data});
|
||||||
// this.toggleSelectedVertices(verts);
|
// this.toggleSelectedVertices(verts);
|
||||||
this.selectFaces(faces, action);
|
this.selectFaces(faces, action);
|
||||||
|
// mesh.api.log.emit(`... select time = ${Date.now() - mark}`); mark = Date.now();
|
||||||
this.updateSelections();
|
this.updateSelections();
|
||||||
if (!timer) {
|
if (!timer) {
|
||||||
mesh.api.log.emit("surface match complete").unpin();
|
mesh.api.log.emit("surface match complete").unpin();
|
||||||
moto.space.refresh();
|
moto.space.refresh();
|
||||||
}
|
}
|
||||||
|
// mesh.api.log.emit(`... paint time = ${Date.now() - mark}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,7 @@ mesh.tool = class MeshTool {
|
||||||
const s2 = (v2 < v0 ? v2 + "," + v0 : v0 + "," +v2);
|
const s2 = (v2 < v0 ? v2 + "," + v0 : v0 + "," +v2);
|
||||||
// for storing raw vertex offset in side record
|
// for storing raw vertex offset in side record
|
||||||
const [ vr0, vr1, vr2 ] = viraw;
|
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
|
// store face indexes into sdrec array for each side
|
||||||
const smap = [ s0, s1, s2 ].map((key,ki) => {
|
const smap = [ s0, s1, s2 ].map((key,ki) => {
|
||||||
let sid = simap[key], sdoff, sdcnt;
|
let sid = simap[key], sdoff, sdcnt;
|
||||||
|
|
@ -208,8 +208,10 @@ mesh.tool = class MeshTool {
|
||||||
sid = simap[key] = sn++;
|
sid = simap[key] = sn++;
|
||||||
sdcnt = srecs[sid] = 1;
|
sdcnt = srecs[sid] = 1;
|
||||||
sdoff = sid * 4;
|
sdoff = sid * 4;
|
||||||
sides[sdoff] = vv[ki * 2];
|
// sides[sdoff] = vv[ki * 2];
|
||||||
sides[sdoff + 1] = vv[ki * 2 + 1];
|
// sides[sdoff + 1] = vv[ki * 2 + 1];
|
||||||
|
sides[sdoff] = viraw[ki];
|
||||||
|
sides[sdoff + 1] = viraw[(ki + 1) % 3];
|
||||||
} else {
|
} else {
|
||||||
sdoff = sid * 4;
|
sdoff = sid * 4;
|
||||||
sdcnt = ++srecs[sid];
|
sdcnt = ++srecs[sid];
|
||||||
|
|
@ -236,7 +238,7 @@ mesh.tool = class MeshTool {
|
||||||
this.indexed = {
|
this.indexed = {
|
||||||
faces, sides, sideExt
|
faces, sides, sideExt
|
||||||
};
|
};
|
||||||
// console.log(this.indexed);
|
console.log(this.indexed);
|
||||||
}
|
}
|
||||||
|
|
||||||
getAdjacentFaces(face) {
|
getAdjacentFaces(face) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue