diff --git a/notes.md b/notes.md index 5ee0100e..278cd928 100644 --- a/notes.md +++ b/notes.md @@ -2,11 +2,11 @@ ## `C` cosmetic, `F` functional, `P` performance, `B` bug fix +* `F` gcode color to speed visualization bar * `F` detect and report slow framerates * `F` implement an in-app bug reporting system. add workspace to export option. * `F` extend mesh object to store raw + annotations (rot,scale,pos) * share raw data w/ dups, encode/decode -* `F` gcode color to speed visualization bar * `F` X,Y,Z colored axes visualizations * `F` 2D image import * `P` improve decimation speed by avoiding in/out of Point? diff --git a/src/kiri/client.js b/src/kiri/client.js index 1d878240..e5391f7f 100644 --- a/src/kiri/client.js +++ b/src/kiri/client.js @@ -183,6 +183,28 @@ KIRI.work = { }, parse : function(args, progress, done) { + // have to do this client side because DOMParser is not in workers + if (args.type === 'svg') { + const { settings, code, type } = args; + const origin = settings.origin; + const offset = { + x: origin.x, + y: -origin.y, + z: origin.z + }; + const output = KIRI.newPrint().parseSVG(code, offset); + send("parse_svg", output, function(reply) { + if (reply.parsed) { + done(KIRI.codec.decode(reply.parsed)); + } + }); + return; + // const layers = KIRI.driver.FDM.prepareRender(output, progress => { + // send.data({ progress: 0.5 + progress * 0.5 }); + // }, { thin: true }); + // send.done({parsed: layers}); + // return; + } send("parse", args, function(reply) { if (reply.progress) { progress(reply); diff --git a/src/kiri/codec.js b/src/kiri/codec.js index 713368b0..80c01106 100644 --- a/src/kiri/codec.js +++ b/src/kiri/codec.js @@ -212,7 +212,6 @@ open: this.isOpen(), inner: encode(this.inner, state), parent: encode(this.parent, state), - // fills: encodePointArray(this.fills, state), depth: this.depth, color: this.color }; @@ -232,13 +231,11 @@ poly.id = v.id; poly.open = v.open; - // if (v.open) poly.setOpen(); else poly.setClosed(); state.poly[v.id] = poly; poly.inner = decode(v.inner, state); poly.parent = decode(v.parent, state); - // poly.fills = decodePointArray(v.fills); poly.depth = v.depth; poly.color = v.color; diff --git a/src/kiri/print.js b/src/kiri/print.js index bd273a41..9e84e637 100644 --- a/src/kiri/print.js +++ b/src/kiri/print.js @@ -38,24 +38,11 @@ */ function Print(settings, widgets, id) { this.id = id || new Date().getTime().toString(36); - this.settings = settings; this.widgets = widgets; - // this.group = new THREE.Group(); - this.printView = []; - this.movesView = []; - - this.time = 0; - this.lines = 0; - this.bytes = 0; - this.output = null; - this.distance = 0; - this.bounds = null; - this.imported = null; } PRO.addOutput = addOutput; - PRO.tip2tipEmit = tip2tipEmit; PRO.extrudePerMM = extrudePerMM; PRO.constReplace = constReplace; PRO.poly2polyEmit = poly2polyEmit; @@ -84,13 +71,15 @@ if (point.y) bounds.max.y = Math.max(bounds.max.y, point.y); if (point.z) bounds.min.z = Math.min(bounds.min.z, point.z); if (point.z) bounds.max.z = Math.max(bounds.max.z, point.z); - addOutput(seq, point, seq.length > 0); + const { x, y, z } = point; // SVGPoint is not serializable + addOutput(seq, { x, y, z }, seq.length > 0); }); output.push(seq); }); scope.imported = code; scope.lines = lines.length; scope.bytes = code.length; + return scope.output; }; PRO.parseGCode = function(gcode, offset, progress, done, options) { diff --git a/src/kiri/worker.js b/src/kiri/worker.js index 4c66ab79..dc38f231 100644 --- a/src/kiri/worker.js +++ b/src/kiri/worker.js @@ -155,7 +155,6 @@ KIRI.worker = { parse: function(args, send) { const { settings, code, type } = args; - const center = settings.process.outputOriginCenter; const origin = settings.origin; const offset = { x: origin.x, @@ -177,6 +176,19 @@ KIRI.worker = { }, { fdm : mode === 'FDM' }); }, + parse_svg: function(parsed, send) { + parsed.forEach(layer => { + layer.forEach(out => { + const { x, y, z } = out.point; + out.point = BASE.newPoint(x,y,z || 0); + }); + }); + const layers = KIRI.driver.FDM.prepareRender(parsed, progress => { + send.data({ progress }); + }, { thin: true }); + send.done({parsed: KIRI.codec.encode(layers)}); + }, + clear: function(data, send) { current.snap = null; current.print = null; diff --git a/src/mode/cam/prepare.js b/src/mode/cam/prepare.js index 827531e4..0e10f124 100644 --- a/src/mode/cam/prepare.js +++ b/src/mode/cam/prepare.js @@ -224,7 +224,7 @@ isMove = !cut; // drop points too close together if (deltaXY < 0.001 && point.z === lastPoint.z) { - console.log(["drop dup",lastPoint,point]); + // console.trace(["drop dup",lastPoint,point]); return; } if (isMove && deltaXY <= toolDiamMove) {