allow fdm driver override of extrusion calcs
This commit is contained in:
parent
9cd7f52f5c
commit
e96670bb05
3 changed files with 26 additions and 11 deletions
|
|
@ -4,9 +4,10 @@
|
|||
|
||||
gapp.register("kiri-mode.fdm.driver", [], (root, exports) => {
|
||||
|
||||
const { kiri } = root;
|
||||
const { base, kiri } = root;
|
||||
const { driver } = kiri;
|
||||
const FDM = driver.FDM = { getRangeParameters };
|
||||
const { util } = base;
|
||||
const FDM = driver.FDM = { getRangeParameters, extrudePerMM, extrudeMM };
|
||||
|
||||
// shared by client and worker contexts
|
||||
function getRangeParameters(process, index) {
|
||||
|
|
@ -29,6 +30,20 @@ function getRangeParameters(process, index) {
|
|||
return params;
|
||||
}
|
||||
|
||||
// noz = nozzle diameter
|
||||
// fil = filament diameter
|
||||
// slice = slice height
|
||||
function extrudePerMM(noz, fil, slice) {
|
||||
return ((Math.PI * util.sqr(noz / 2)) / (Math.PI * util.sqr(fil / 2))) * (slice / noz);
|
||||
};
|
||||
|
||||
// dist = distance between extrusion points
|
||||
// perMM = amount extruded per MM (from extrudePerMM)
|
||||
// factor = scaling factor (usually 1.0)
|
||||
function extrudeMM(dist, perMM, factor) {
|
||||
return dist * perMM * factor;
|
||||
}
|
||||
|
||||
// defer loading until client and worker exist
|
||||
kiri.load(api => {
|
||||
|
||||
|
|
|
|||
|
|
@ -128,7 +128,9 @@ FDM.export = function(print, online, ondone, ondebug) {
|
|||
// track purges for palette3 pings
|
||||
purgePos,
|
||||
purgeOn = 0,
|
||||
purgeOff = 0;
|
||||
purgeOff = 0,
|
||||
extrudeMM = FDM.extrudeMM,
|
||||
extrudePerMM = FDM.extrudePerMM;
|
||||
|
||||
let tools_used = Object.keys(tools);
|
||||
for (let tool of tools_used) {
|
||||
|
|
@ -537,7 +539,7 @@ FDM.export = function(print, online, ondone, ondebug) {
|
|||
updateParams(path.layer, path.params);
|
||||
}
|
||||
|
||||
emitPerMM = print.extrudePerMM(
|
||||
emitPerMM = extrudePerMM(
|
||||
lineWidth || extruder.extNozzle,
|
||||
extruder.extFilament,
|
||||
path.layer === 0 ?
|
||||
|
|
@ -665,7 +667,7 @@ FDM.export = function(print, online, ondone, ondebug) {
|
|||
extruder = extruders[tool];
|
||||
offset_x = extruder.extOffsetX;
|
||||
offset_y = extruder.extOffsetY;
|
||||
emitPerMM = print.extrudePerMM(
|
||||
emitPerMM = extrudePerMM(
|
||||
lineWidth || extruder.extNozzle,
|
||||
extruder.extFilament,
|
||||
path.layer === 0 ?
|
||||
|
|
@ -802,7 +804,8 @@ FDM.export = function(print, online, ondone, ondebug) {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
emitMM = emitPerMM * out.emit * dist;
|
||||
// emitMM = emitPerMM * out.emit * dist;
|
||||
emitMM = extrudeMM(dist, emitPerMM, out.emit);
|
||||
moveTo({x:x, y:y, e:emitMM}, speedMMM);
|
||||
emitted += emitMM;
|
||||
}
|
||||
|
|
@ -847,7 +850,8 @@ FDM.export = function(print, online, ondone, ondebug) {
|
|||
|
||||
function emitQrec(rec) {
|
||||
let {e, x, y, dist, emitPerMM, speedMMM} = rec;
|
||||
emitMM = emitPerMM * e * dist;
|
||||
// emitMM = emitPerMM * e * dist;
|
||||
emitMM = extrudeMM(dist, emitPerMM, e);
|
||||
moveTo({x:x, y:y, e:emitMM}, speedMMM);
|
||||
emitted += emitMM;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,10 +128,6 @@ class Print {
|
|||
return output.last().point;
|
||||
}
|
||||
|
||||
extrudePerMM(noz, fil, slice) {
|
||||
return ((Math.PI * util.sqr(noz / 2)) / (Math.PI * util.sqr(fil / 2))) * (slice / noz);
|
||||
}
|
||||
|
||||
constReplace(str, consts, start, pad, short) {
|
||||
let cs = str.indexOf("{", start || 0),
|
||||
ce = str.indexOf("}", cs),
|
||||
|
|
|
|||
Loading…
Reference in a new issue