restore svg import render

This commit is contained in:
Stewart Allen 2020-11-09 23:01:41 -05:00
commit eb53f5334d
6 changed files with 40 additions and 20 deletions

View file

@ -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?

View file

@ -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);

View file

@ -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;

View file

@ -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) {

View file

@ -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;

View file

@ -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) {