diff --git a/release.md b/release.md index cfa6a7e7..1d68e3bb 100644 --- a/release.md +++ b/release.md @@ -9,6 +9,7 @@ Full docs @ https://docs.grid.space/projects/kiri-moto ## Kiri:moto * `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 * `I` add CAM pocket operation using surface selection * `-` refactor cnc to use new core slicer engine @@ -16,6 +17,7 @@ Full docs @ https://docs.grid.space/projects/kiri-moto ## Mesh:Tool +* `C` significant speed-up for large surface selections * `C` multi-body identification and isolation * `-` parameterize svg and image import diff --git a/src/kiri/settings.js b/src/kiri/settings.js index 331ad950..d5165ce1 100644 --- a/src/kiri/settings.js +++ b/src/kiri/settings.js @@ -618,6 +618,11 @@ function settingsImportZip(data, ask) { function settingsPrusaConvert(data) { const { uc } = api; const map = {}; + const vsub = { + '[first_layer_bed_temperature]': '{bed_temp}', + '[first_layer_temperature]': '{temp}', + '[layer_z]': '{z}' + }; try { data.split('\n') .filter(l => l.charAt(0) !== '#') @@ -625,7 +630,13 @@ function settingsPrusaConvert(data) { .map(l => { // convert gcode string into a string array 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; }) diff --git a/src/mesh/api.js b/src/mesh/api.js index 428a4170..b38aa588 100644 --- a/src/mesh/api.js +++ b/src/mesh/api.js @@ -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}`); }); }, diff --git a/src/mesh/model.js b/src/mesh/model.js index 5cb8cd31..33c68024 100644 --- a/src/mesh/model.js +++ b/src/mesh/model.js @@ -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}`); }); } diff --git a/src/mesh/tool.js b/src/mesh/tool.js index c846cd6e..ff9fbc77 100644 --- a/src/mesh/tool.js +++ b/src/mesh/tool.js @@ -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) {