refactor / rename laser fields to ct for 'cut tool' as a generic class for waterjet/wireedm/dragknite/laser
This commit is contained in:
parent
1d50d42b46
commit
dfe42c0e4e
26 changed files with 261 additions and 171 deletions
|
|
@ -288,8 +288,8 @@ kiri.load(() => {
|
|||
const stepsY = Math.floor(stock.y / step);
|
||||
const { pos, ind, sab } = createGrid(stepsX, stepsY, stock, step);
|
||||
const offset = {
|
||||
x: process.outputOriginCenter ? 0 : stock.x / 2,
|
||||
y: process.outputOriginCenter ? 0 : stock.y / 2,
|
||||
x: process.camOriginCenter ? 0 : stock.x / 2,
|
||||
y: process.camOriginCenter ? 0 : stock.y / 2,
|
||||
z: process.camOriginTop ? -stock.z : 0
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -188,7 +188,6 @@ FDM.init = function(kiri, api) {
|
|||
api.event.on("range.updates", updateRanges);
|
||||
api.event.on("settings.load", (settings) => {
|
||||
if (settings.mode !== 'FDM') return;
|
||||
settings.process.outputOriginCenter = (settings.device.originCenter || false);
|
||||
restoreSupports(api.widgets.all());
|
||||
updateRanges(settings.process.ranges);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ FDM.export = function(print, online, ondone, ondebug) {
|
|||
arcRes = 20,
|
||||
arcDev = 0.5,
|
||||
arcMax = 40,
|
||||
originCenter = process.outputOriginCenter || bedRound,
|
||||
originCenter = device.originCenter || bedRound,
|
||||
offset = originCenter ? {
|
||||
x: 0,
|
||||
y: 0,
|
||||
|
|
|
|||
|
|
@ -785,14 +785,14 @@ function slicePrintPath(print, slice, startPoint, offset, output, opt = {}) {
|
|||
|
||||
let preout = [],
|
||||
process = opt.params || settings.process,
|
||||
originCenter = process.outputOriginCenter || bedRound,
|
||||
originCenter = device.originCenter || bedRound,
|
||||
extruder = slice.extruder || 0,
|
||||
nozzleSize = process.sliceLineWidth || device.extruders[extruder].extNozzle,
|
||||
firstLayer = (opt.first || false) && !opt.support,
|
||||
thinWall = nozzleSize * (opt.thinWall || 1.75),
|
||||
retractDist = opt.retractOver || 2,
|
||||
fillMult = opt.mult || process.outputFillMult,
|
||||
shellMult = opt.mult || process.outputShellMult || (process.laserSliceHeight >= 0 ? 1 : 0),
|
||||
shellMult = opt.mult || process.outputShellMult || (process.ctSliceHeight >= 0 ? 1 : 0),
|
||||
shellOrder = {"out-in":-1,"in-out":1}[process.sliceShellOrder] || -1,
|
||||
sparseMult = process.outputSparseMult,
|
||||
coastDist = process.outputCoastDist || 0,
|
||||
|
|
|
|||
|
|
@ -40,14 +40,14 @@ function init(kiri, api) {
|
|||
*/
|
||||
function slice(settings, widget, onupdate, ondone) {
|
||||
let proc = settings.process;
|
||||
let offset = proc.laserOffset || 0;
|
||||
let offset = proc.ctSliceKerf || 0;
|
||||
let color = settings.controller.dark ? 0xbbbbbb : 0;
|
||||
|
||||
if (proc.laserSliceHeight < 0) {
|
||||
if (proc.ctSliceHeight < 0) {
|
||||
return ondone("invalid slice height");
|
||||
}
|
||||
|
||||
let { laserSliceSingle, laserSliceHeight, laserSliceHeightMin } = proc;
|
||||
let { ctSliceSingle, ctSliceHeight, ctSliceHeightMin } = proc;
|
||||
let bounds = widget.getBoundingBox();
|
||||
let points = widget.getPoints();
|
||||
let indices = [];
|
||||
|
|
@ -57,10 +57,10 @@ function slice(settings, widget, onupdate, ondone) {
|
|||
zMax: bounds.max.z,
|
||||
zGen(zopt) {
|
||||
let { zMin, zMax, zIndexes } = zopt;
|
||||
if (laserSliceSingle) {
|
||||
indices = [ laserSliceHeight ];
|
||||
} else if (laserSliceHeight) {
|
||||
for (let z = zMin + laserSliceHeight / 2; z < zMax; z += laserSliceHeight) {
|
||||
if (ctSliceSingle) {
|
||||
indices = [ ctSliceHeight ];
|
||||
} else if (ctSliceHeight) {
|
||||
for (let z = zMin + ctSliceHeight / 2; z < zMax; z += ctSliceHeight) {
|
||||
indices.push(z);
|
||||
}
|
||||
indices;
|
||||
|
|
@ -69,11 +69,11 @@ function slice(settings, widget, onupdate, ondone) {
|
|||
indices.push((zIndexes[i-1] + zIndexes[i]) / 2);
|
||||
}
|
||||
// discard layers too
|
||||
if (laserSliceHeightMin) {
|
||||
if (ctSliceHeightMin) {
|
||||
let last;
|
||||
indices = indices.filter(v => {
|
||||
let ok = true;
|
||||
if (last !== undefined && Math.abs(v - last) < laserSliceHeightMin) {
|
||||
if (last !== undefined && Math.abs(v - last) < ctSliceHeightMin) {
|
||||
ok = false;
|
||||
} else {
|
||||
last = v;
|
||||
|
|
@ -110,13 +110,13 @@ function polyLabel(poly, label) {
|
|||
function sliceEmitObjects(print, slice, groups, opt = { }) {
|
||||
let start = newPoint(0,0,0);
|
||||
let process = print.settings.process;
|
||||
let stacked = process.outputLaserStack;
|
||||
let grouped = stacked || process.outputLaserGroup;
|
||||
let stacked = process.ctOutStack;
|
||||
let grouped = stacked || process.ctOutGroup;
|
||||
let label = false && process.outputLaserLabel;
|
||||
let simple = opt.simple || false;
|
||||
let emit = { in: [], out: [], mark: [] };
|
||||
let lastEmit = opt.lastEmit;
|
||||
let zcolor = print.settings.process.outputLaserZColor;
|
||||
let zcolor = print.settings.process.ctOutZColor;
|
||||
|
||||
function laserOut(poly, group, type, indexed) {
|
||||
if (!poly) {
|
||||
|
|
@ -182,7 +182,7 @@ async function prepare(widgets, settings, update) {
|
|||
process = settings.process,
|
||||
print = self.worker.print = kiri.newPrint(settings, widgets),
|
||||
knifeOn = self.worker.mode === 'DRAG',
|
||||
knifeTipOff = process.outputKnifeTip,
|
||||
knifeTipOff = process.ctOutKnifeTip,
|
||||
output = print.output = [],
|
||||
totalSlices = 0,
|
||||
slices = 0;
|
||||
|
|
@ -262,7 +262,7 @@ async function prepare(widgets, settings, update) {
|
|||
// emit objects from each slice into output array
|
||||
widgets.forEach(widget => {
|
||||
// slice stack merging
|
||||
if (process.outputLaserMerged) {
|
||||
if (process.ctOutMerged) {
|
||||
let merged = [];
|
||||
widget.slices.forEach(slice => {
|
||||
let polys = [];
|
||||
|
|
@ -343,16 +343,16 @@ async function prepare(widgets, settings, update) {
|
|||
let i, m, e,
|
||||
dw = device.bedWidth / 2,
|
||||
dh = device.bedDepth / 2,
|
||||
sort = !process.outputLaserLayer,
|
||||
sort = !process.ctOutLayer,
|
||||
// sort objects by size when not using laser layer ordering
|
||||
c = sort ? output.sort(kiri.Sort) : output,
|
||||
p = new kiri.Pack(dw, dh, process.outputTileSpacing).fit(c, !sort);
|
||||
p = new kiri.Pack(dw, dh, process.ctOutTileSpacing).fit(c, !sort);
|
||||
|
||||
// test different ratios until packed
|
||||
while (!p.packed) {
|
||||
dw *= 1.1;
|
||||
dh *= 1.1;
|
||||
p = new kiri.Pack(dw, dh, process.outputTileSpacing).fit(c ,!sort);
|
||||
p = new kiri.Pack(dw, dh, process.ctOutTileSpacing).fit(c ,!sort);
|
||||
}
|
||||
|
||||
if (pack)
|
||||
|
|
@ -383,7 +383,7 @@ function exportLaser(print, online, ondone) {
|
|||
*/
|
||||
function exportElements(settings, output, onpre, onpoly, onpost, onpoint, onlayer) {
|
||||
let process = settings.process,
|
||||
zcolor = process.outputLaserZColor,
|
||||
zcolor = process.ctOutZColor,
|
||||
last,
|
||||
point,
|
||||
poly = [],
|
||||
|
|
@ -402,7 +402,7 @@ function exportElements(settings, output, onpre, onpoly, onpost, onpoint, onlaye
|
|||
});
|
||||
});
|
||||
|
||||
if (!process.outputOriginCenter) {
|
||||
if (!process.ctOriginCenter) {
|
||||
// normalize against origin lower left
|
||||
output.forEach(function(layer) {
|
||||
layer.forEach(function(out) {
|
||||
|
|
@ -432,7 +432,7 @@ function exportElements(settings, output, onpre, onpoly, onpost, onpoint, onlaye
|
|||
min.y = 0;
|
||||
}
|
||||
|
||||
onpre(min, max, process.outputLaserPower, process.outputLaserSpeed);
|
||||
onpre(min, max, process.ctOutPower, process.ctOutSpeed);
|
||||
|
||||
output.forEach(function(layer, index) {
|
||||
let thick = 0;
|
||||
|
|
@ -476,8 +476,8 @@ function exportGCode(settings, data) {
|
|||
let laser_on = dev.gcodeLaserOn || [];
|
||||
let laser_off = dev.gcodeLaserOff || [];
|
||||
let knifeOn = proc.knifeOn;
|
||||
let knifeDepth = proc.outputKnifeDepth;
|
||||
let passes = knifeOn ? proc.outputKnifePasses : 1;
|
||||
let knifeDepth = proc.ctOutKnifeDepth;
|
||||
let passes = knifeOn ? proc.ctOutKnifePasses : 1;
|
||||
|
||||
exportElements(
|
||||
settings,
|
||||
|
|
@ -554,8 +554,8 @@ function exportGCode(settings, data) {
|
|||
*/
|
||||
function exportSVG(settings, data, cut_color) {
|
||||
let { process } = settings;
|
||||
let zcolor = process.outputLaserZColor ? 1 : 0;
|
||||
let zstack = process.outputLaserStack;
|
||||
let zcolor = process.ctOutZColor ? 1 : 0;
|
||||
let zstack = process.ctOutStack;
|
||||
let lines = [], dx = 0, dy = 0, my, z = 0;
|
||||
let colors = [
|
||||
"black",
|
||||
|
|
|
|||
Loading…
Reference in a new issue