fix restore from .km preserving widget annotations. fix trace ordering for tops that split down. fix support z span
This commit is contained in:
parent
b88c47f6af
commit
125f9cb16b
4 changed files with 72 additions and 30 deletions
1
notes.md
1
notes.md
|
|
@ -54,6 +54,7 @@
|
||||||
|
|
||||||
# FDM - BELT
|
# FDM - BELT
|
||||||
|
|
||||||
|
* `B` auto bed resizing leaves the origin in the wrong place at first
|
||||||
* `B` ranges don't work with anchors
|
* `B` ranges don't work with anchors
|
||||||
* `B` multiple parts with one angled against origin "floats" in preview
|
* `B` multiple parts with one angled against origin "floats" in preview
|
||||||
* `B` re-add progress calls for all work units
|
* `B` re-add progress calls for all work units
|
||||||
|
|
|
||||||
|
|
@ -2271,10 +2271,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isSettings) {
|
if (isSettings) {
|
||||||
|
clearWorkspace();
|
||||||
settings = CONF.normalize(data.settings);
|
settings = CONF.normalize(data.settings);
|
||||||
SDB.setItem('ws-settings', JSON.stringify(settings));
|
SDB.setItem('ws-settings', JSON.stringify(settings));
|
||||||
if (LOCAL) console.log('settings',Object.clone(settings));
|
|
||||||
restoreSettings();
|
restoreSettings();
|
||||||
|
if (LOCAL) console.log('settings',Object.clone(settings));
|
||||||
if (isWork) {
|
if (isWork) {
|
||||||
API.platform.clear();
|
API.platform.clear();
|
||||||
KIRI.codec.decode(data.work).forEach(widget => {
|
KIRI.codec.decode(data.work).forEach(widget => {
|
||||||
|
|
@ -2416,7 +2417,6 @@
|
||||||
|
|
||||||
function restoreSettings(save) {
|
function restoreSettings(save) {
|
||||||
let newset = ls2o('ws-settings') || settings;
|
let newset = ls2o('ws-settings') || settings;
|
||||||
|
|
||||||
settings = CONF.normalize(newset);
|
settings = CONF.normalize(newset);
|
||||||
// override camera from settings
|
// override camera from settings
|
||||||
if (settings.controller.view) {
|
if (settings.controller.view) {
|
||||||
|
|
|
||||||
|
|
@ -566,12 +566,48 @@
|
||||||
return int;
|
return int;
|
||||||
}
|
}
|
||||||
|
|
||||||
function outputTraces(poly, extrude) {
|
function outputTraces(poly, opt = {}) {
|
||||||
if (!poly) return;
|
if (!poly) return;
|
||||||
if (Array.isArray(poly)) {
|
if (Array.isArray(poly)) {
|
||||||
outputOrderClosest(poly, function(next) {
|
if (opt.sort) {
|
||||||
outputTraces(next, extrude);
|
let polys = poly.slice().sort(function(a,b) {
|
||||||
}, null);
|
return (a.perimeter() - b.perimeter()) * opt.sort;
|
||||||
|
});
|
||||||
|
let debug = polys.length > 3;
|
||||||
|
let last;
|
||||||
|
while (polys.length) {
|
||||||
|
let next;
|
||||||
|
for (let p of polys) {
|
||||||
|
if (!last) {
|
||||||
|
next = p;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (opt.sort > 0) {
|
||||||
|
// in-out
|
||||||
|
if (last.isInside(p)) {
|
||||||
|
next = p;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// out-in
|
||||||
|
if (p.isInside(last)) {
|
||||||
|
next = p;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (next) {
|
||||||
|
last = next;
|
||||||
|
polys.remove(next);
|
||||||
|
outputTraces(next, opt);
|
||||||
|
} else {
|
||||||
|
last = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// outputOrderClosest(poly, function(next) {
|
||||||
|
// outputTraces(next, opt);
|
||||||
|
// }, null);
|
||||||
} else {
|
} else {
|
||||||
let finishShell = poly.depth === 0 && !firstLayer;
|
let finishShell = poly.depth === 0 && !firstLayer;
|
||||||
startPoint = scope.polyPrintPath(poly, startPoint, preout, {
|
startPoint = scope.polyPrintPath(poly, startPoint, preout, {
|
||||||
|
|
@ -580,7 +616,7 @@
|
||||||
accel: finishShell,
|
accel: finishShell,
|
||||||
wipe: process.outputWipeDistance || 0,
|
wipe: process.outputWipeDistance || 0,
|
||||||
coast: firstLayer ? 0 : coastDist,
|
coast: firstLayer ? 0 : coastDist,
|
||||||
extrude: pref(extrude, shellMult),
|
extrude: pref(opt.extrude, shellMult),
|
||||||
onfirst: function(firstPoint) {
|
onfirst: function(firstPoint) {
|
||||||
if (startPoint.distTo2D(firstPoint) > retractDist) {
|
if (startPoint.distTo2D(firstPoint) > retractDist) {
|
||||||
retract();
|
retract();
|
||||||
|
|
@ -776,11 +812,11 @@
|
||||||
* the special exception that depth is considered into distance
|
* the special exception that depth is considered into distance
|
||||||
* so that inner polygons are emitted first.
|
* so that inner polygons are emitted first.
|
||||||
*
|
*
|
||||||
* @param {Array} array of Polygon or Polygon wrappers
|
* @param {Array} array of Polygons or Polygon wrappers (tops)
|
||||||
* @param {Function} fn
|
* @param {Function} fn call to emit next candidate
|
||||||
* @param {Function} fnp convert 'next' object into a Polygon
|
* @param {Function} fnp convert 'next' object into a Polygon for closeness
|
||||||
*/
|
*/
|
||||||
function outputOrderClosest(array, fn, fnp, newTop) {
|
function outputOrderClosest(array, fn, fnp) {
|
||||||
if (array.length === 1) {
|
if (array.length === 1) {
|
||||||
return fn(array[0]);
|
return fn(array[0]);
|
||||||
}
|
}
|
||||||
|
|
@ -800,7 +836,6 @@
|
||||||
d: find.distance - (poly.depth * thinWall),
|
d: find.distance - (poly.depth * thinWall),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
newTop = false;
|
|
||||||
if (order.length === 0) {
|
if (order.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -848,23 +883,24 @@
|
||||||
shellOrder = -1;
|
shellOrder = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// top object
|
// innermost shells
|
||||||
let bounds = POLY.flatten(next.shellsAtDepth(0).clone(true));
|
let inner = next.innerShells() || [];
|
||||||
|
|
||||||
// output inner polygons
|
// output inner polygons
|
||||||
if (shellOrder === 1)
|
if (shellOrder === 1) outputTraces(inner);
|
||||||
outputTraces([].appendAll(next.innerShells() || []));
|
|
||||||
|
outputTraces(next.shells, { sort: shellOrder });
|
||||||
|
|
||||||
// sort perimeter polygon by length to go out-to-in or in-to-out
|
// sort perimeter polygon by length to go out-to-in or in-to-out
|
||||||
(next.shells || []).sort(function(a,b) {
|
// this causes too much seeking when nesting splits into disconnected areas
|
||||||
return a.perimeter() > b.perimeter() ? shellOrder : -shellOrder;
|
// (next.shells || []).sort(function(a,b) {
|
||||||
}).forEach(function(poly, index) {
|
// return a.perimeter() > b.perimeter() ? shellOrder : -shellOrder;
|
||||||
outputTraces(poly);
|
// }).forEach(function(poly, index) {
|
||||||
});
|
// outputTraces(poly);
|
||||||
|
// });
|
||||||
|
|
||||||
// output outer polygons
|
// output outer polygons
|
||||||
if (shellOrder === -1)
|
if (shellOrder === -1) outputTraces(inner);
|
||||||
outputTraces([].appendAll(next.innerShells() || []));
|
|
||||||
|
|
||||||
// output thin fill
|
// output thin fill
|
||||||
outputFills(next.thin_fill, {near: true});
|
outputFills(next.thin_fill, {near: true});
|
||||||
|
|
@ -876,6 +912,7 @@
|
||||||
lastTop = next;
|
lastTop = next;
|
||||||
}
|
}
|
||||||
}, function(obj) {
|
}, function(obj) {
|
||||||
|
// for tops
|
||||||
return obj instanceof Polygon ? obj : obj.poly;
|
return obj instanceof Polygon ? obj : obj.poly;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,11 @@
|
||||||
UTIL = BASE.util,
|
UTIL = BASE.util,
|
||||||
FDM = KIRI.driver.FDM,
|
FDM = KIRI.driver.FDM,
|
||||||
SPACE, API, VIEWS, LANG, PROC, UI, UC,
|
SPACE, API, VIEWS, LANG, PROC, UI, UC,
|
||||||
|
nextID = Date.now(),
|
||||||
p1, p2, iw,
|
p1, p2, iw,
|
||||||
lastMode, lastView, lastPillar, fromPillar,
|
lastBox,
|
||||||
|
lastMode, lastView,
|
||||||
|
lastPillar, fromPillar,
|
||||||
isFdmMode = false,
|
isFdmMode = false,
|
||||||
addingSupports = false,
|
addingSupports = false,
|
||||||
alert = [],
|
alert = [],
|
||||||
|
|
@ -291,16 +294,16 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!iw) return;
|
if (!iw) return;
|
||||||
|
let { point, dim } = lastBox;
|
||||||
p1.y = Math.max(0, p1.y);
|
p1.y = Math.max(0, p1.y);
|
||||||
p2.y = Math.max(0, p2.y);
|
p2.y = Math.max(0, p2.y);
|
||||||
let hy = (p1.y + p2.y) / 2;
|
let dh = dim.z;
|
||||||
let dh = Math.abs(p1.y - p2.y);
|
|
||||||
let dw = api.conf.get().process.sliceSupportSize / 2;
|
let dw = api.conf.get().process.sliceSupportSize / 2;
|
||||||
let ip = iw.track.pos;
|
let ip = iw.track.pos;
|
||||||
let wa = api.widgets.annotate(iw.id);
|
let wa = api.widgets.annotate(iw.id);
|
||||||
let ws = (wa.support = wa.support || []);
|
let ws = (wa.support = wa.support || []);
|
||||||
let x = p1.x - ip.x, y = -p1.z - ip.y, z = hy, id = Date.now();
|
let id = ++nextID;
|
||||||
let rec = {x, y, z, dw, dh, id};
|
let rec = {x: point.x - ip.x, y: -point.z - ip.y, z: point.y, dw, dh, id};
|
||||||
if (fromPillar && event && event.shiftKey) {
|
if (fromPillar && event && event.shiftKey) {
|
||||||
let targets = api.widgets.meshes().append(SPACE.internals().platform);
|
let targets = api.widgets.meshes().append(SPACE.internals().platform);
|
||||||
let from = fromPillar,
|
let from = fromPillar,
|
||||||
|
|
@ -350,7 +353,7 @@
|
||||||
let mp = (phi.y + plo.y) / 2;
|
let mp = (phi.y + plo.y) / 2;
|
||||||
let dy = Math.abs(phi.y - plo.y);
|
let dy = Math.abs(phi.y - plo.y);
|
||||||
let dw = api.conf.get().process.sliceSupportSize / 2;
|
let dw = api.conf.get().process.sliceSupportSize / 2;
|
||||||
let rec = { rz:angle, x:point.x, y:point.z, z:mp, dw, dh:dy, id: id * 0xffffffffff };
|
let rec = { rz:angle, x:point.x, y:point.z, z:mp, dw, dh:dy, id };
|
||||||
ws.push(Object.clone(rec));
|
ws.push(Object.clone(rec));
|
||||||
fromPillar = addWidgetSupport(iw, rec);
|
fromPillar = addWidgetSupport(iw, rec);
|
||||||
}
|
}
|
||||||
|
|
@ -416,7 +419,6 @@
|
||||||
Object.values(widget.sups || {}).forEach(support => {
|
Object.values(widget.sups || {}).forEach(support => {
|
||||||
active.push(support.box);
|
active.push(support.box);
|
||||||
support.box.support = true;
|
support.box.support = true;
|
||||||
// console.log({support});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return active;
|
return active;
|
||||||
|
|
@ -495,6 +497,8 @@
|
||||||
box.position.y = point.y;
|
box.position.y = point.y;
|
||||||
box.position.z = point.z;
|
box.position.z = point.z;
|
||||||
|
|
||||||
|
lastBox = {point, dim};
|
||||||
|
|
||||||
const group = opt.group || SPACE.scene
|
const group = opt.group || SPACE.scene
|
||||||
group.add(box);
|
group.add(box);
|
||||||
box.groupTo = group;
|
box.groupTo = group;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue