alter belt calculations for abitrary slice angle
This commit is contained in:
parent
58c33da9e8
commit
4aa9b7ed49
4 changed files with 36 additions and 30 deletions
|
|
@ -440,11 +440,10 @@ FDM.prepare = async function(widgets, settings, update) {
|
|||
let { belt } = widget;
|
||||
let offset = Object.clone(widget.track.pos);
|
||||
if (isBelt) {
|
||||
let o = belt.ypos * beltfact;
|
||||
offset = {
|
||||
x: belt.xpos,
|
||||
y: o,
|
||||
z: o
|
||||
y: belt.ypos * belt.cosf,
|
||||
z: belt.ypos * belt.sinf
|
||||
};
|
||||
} else {
|
||||
// when rafts used this is non-zero
|
||||
|
|
@ -648,12 +647,14 @@ FDM.prepare = async function(widgets, settings, update) {
|
|||
|
||||
// post-process for base extrusions (touching the bed)
|
||||
if (isBelt) {
|
||||
// all widgets should have the same belt scaling constants
|
||||
let belt = widgets[0].belt;
|
||||
// tune base threshold
|
||||
let thresh = Infinity;
|
||||
for (let layer of output) {
|
||||
for (let rec of layer) {
|
||||
let point = rec.point;
|
||||
thresh = Math.min(thresh, point.z - point.y);
|
||||
thresh = Math.min(thresh, (belt.slope * point.z) - point.y);
|
||||
}
|
||||
}
|
||||
// store this offset to be removed from Y values in export
|
||||
|
|
@ -680,7 +681,7 @@ FDM.prepare = async function(widgets, settings, update) {
|
|||
let brate = params.firstLayerRate || firstLayerRate;
|
||||
let bmult = params.firstLayerPrintMult || params.firstLayerPrintMult;
|
||||
let point = rec.point;
|
||||
let belty = rec.belty = -point.y + point.z;
|
||||
let belty = rec.belty = -point.y + (point.z * belt.slope);
|
||||
let lowrate = belty <= thresh ? brate : overate || brate;
|
||||
miny = Math.min(miny, belty);
|
||||
if (layer.anchor) {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ const { base, kiri, noop } = root;
|
|||
const { consts, driver, fill, fill_fixed, newSlice, utils } = kiri;
|
||||
const { config, polygons, util, newPoint } = base;
|
||||
const { fillArea } = polygons;
|
||||
const { beltfact } = consts;
|
||||
const { FDM } = driver;
|
||||
const { doTopShells, getRangeParameters } = FDM;
|
||||
|
||||
|
|
@ -179,16 +178,17 @@ FDM.slice = function(settings, widget, onupdate, ondone) {
|
|||
// handle z cutting (floor method) and base flattening
|
||||
let zPress = isBelt ? process.firstLayerFlatten || 0 : 0;
|
||||
let zCut = widget.track.zcut || 0;
|
||||
let { belt } = widget;
|
||||
if (zCut || zPress) {
|
||||
for (let p of points) {
|
||||
if (!p._z) {
|
||||
p._z = p.z;
|
||||
if (zPress) {
|
||||
if (isBelt) {
|
||||
let zb = (p.z - p.y) * beltfact;
|
||||
if (zb > 0 && zb <= zPress) {
|
||||
p.y += zb * beltfact;
|
||||
p.z -= zb * beltfact;
|
||||
let zd = (belt.slope * p.z) - p.y;
|
||||
if (zd > 0 && zd <= zPress) {
|
||||
p.y += zd * belt.cosf;
|
||||
p.z -= zd * belt.sinf;
|
||||
}
|
||||
} else {
|
||||
if (p.z <= zPress) p.z = 0;
|
||||
|
|
@ -492,10 +492,7 @@ FDM.slice = function(settings, widget, onupdate, ondone) {
|
|||
|
||||
// add lead in anchor when specified in belt mode (but not for synths)
|
||||
if (isBelt && !isSynth) {
|
||||
let mrad = Math.cos(Math.PI/4);
|
||||
let arad = Math.cos((Math.PI/180) * process.sliceAngle);
|
||||
let ymlt = arad / mrad;
|
||||
console.log({ arad, ymlt });
|
||||
let { cosf, slope } = widget.belt;
|
||||
// find adjusted zero point from slices
|
||||
let smin = Infinity;
|
||||
for (let slice of slices) {
|
||||
|
|
@ -505,14 +502,14 @@ FDM.slice = function(settings, widget, onupdate, ondone) {
|
|||
let z = slice.z;
|
||||
// at 45 degrees, 1mm in Z is 1mm in Y
|
||||
// find formula for other angles
|
||||
let by = z - (y * ymlt);
|
||||
let by = (slope * z) - y;
|
||||
if (by < miny) miny = by;
|
||||
if (by < smin) smin = by;
|
||||
}
|
||||
slice.belt = { miny, touch: false };
|
||||
console.log({ miny, z:slice.z });
|
||||
slice.belt = { miny, touch: miny.round(3) == 0 };
|
||||
// console.log({ miny: miny.round(3), z:slice.z, touch: slice.belt.touch });
|
||||
}
|
||||
console.log({ smin });
|
||||
console.log({ smin: smin.round(5) });
|
||||
// mark slices with tops touching belt
|
||||
// also find max width of first 5 layers
|
||||
let start;
|
||||
|
|
@ -527,10 +524,11 @@ FDM.slice = function(settings, widget, onupdate, ondone) {
|
|||
}
|
||||
// mark slice as touching belt if near miny
|
||||
// if (Math.abs(slice.belt.miny - smin) < 0.01) {
|
||||
if (Math.abs(slice.belt.miny) < 0.01) {
|
||||
slice.belt.touch = true;
|
||||
if (!start) start = slice;
|
||||
}
|
||||
if (!start && slice.belt.touch) start = slice;
|
||||
// if (Math.abs(slice.belt.miny) < 0.01) {
|
||||
// slice.belt.touch = true;
|
||||
// if (!start) start = slice;
|
||||
// }
|
||||
}
|
||||
// ensure we start against a layer with shells
|
||||
while (start && start.up && start.topShells().length === 0) {
|
||||
|
|
@ -544,11 +542,12 @@ FDM.slice = function(settings, widget, onupdate, ondone) {
|
|||
}
|
||||
// array of added top.fill_sparse arrays
|
||||
let adds = [];
|
||||
let anchorlen = (process.beltAnchor || process.firstLayerBeltLead) * beltfact;
|
||||
let step = sliceHeight;
|
||||
let anchorlen = (process.beltAnchor || process.firstLayerBeltLead) * cosf;
|
||||
while (anchorlen && start && anchorlen >= sliceHeight) {
|
||||
let addto = start.down;
|
||||
if (!addto) {
|
||||
addto = newSlice(start.z - sliceHeight);
|
||||
addto = newSlice(start.z - step);
|
||||
addto.extruder = extruder;
|
||||
addto.belt = { };
|
||||
addto.height = start.height;
|
||||
|
|
@ -565,12 +564,13 @@ FDM.slice = function(settings, widget, onupdate, ondone) {
|
|||
// by removing the forced start-point in print.js
|
||||
addto.belt.touch = false;
|
||||
let z = addto.z;
|
||||
let y = z - smin - (lineWidth / 2);
|
||||
let y = (slope * z) - smin - (lineWidth / 2);
|
||||
let splat = base.newPolygon().add(minx, y, z).add(maxx, y, z).setOpen();
|
||||
let snew = addto.addTop(splat).fill_sparse = [ splat ];
|
||||
adds.push(snew);
|
||||
start = addto;
|
||||
anchorlen -= sliceHeight;
|
||||
// console.log({ z: z.round(3), anchorlen: anchorlen.round(3) });
|
||||
anchorlen -= (step * slope);
|
||||
}
|
||||
// add anchor bump
|
||||
let bump = process.firstLayerBeltBump;
|
||||
|
|
|
|||
|
|
@ -363,7 +363,8 @@ kiri.worker = {
|
|||
let xpos = track.pos.x;
|
||||
let yoff = proc.beltAnchor || proc.firstLayerBeltLead || 0;
|
||||
let ypos = settings.device.bedDepth / 2 + track.pos.y + miny + yoff;
|
||||
let rotation = (Math.PI / 180) * angle;
|
||||
let radians = Math.PI / 180;
|
||||
let rotation = radians * angle;
|
||||
for (let w of group) {
|
||||
w.moveMesh(0, miny, 0);
|
||||
}
|
||||
|
|
@ -376,7 +377,12 @@ kiri.worker = {
|
|||
ypos,
|
||||
// used during slice
|
||||
dy: - miny - yoff,
|
||||
dz: 0
|
||||
dz: 0,
|
||||
// ratio for anchor lengths, path offsets
|
||||
cosf: Math.cos(radians * angle), // Y comp
|
||||
sinf: Math.sin(radians * angle), // Z comp
|
||||
// slope for calculating z = 0 from angle bias
|
||||
slope: Math.tan(radians * (90 - angle))
|
||||
};
|
||||
for (let others of group.slice(1)) {
|
||||
others.belt = widget.belt;
|
||||
|
|
|
|||
|
|
@ -10,8 +10,7 @@
|
|||
gapp.register("kiri.print", [], (root, evets) => {
|
||||
|
||||
const { base, kiri } = self;
|
||||
const { paths, util, newPoint, Polygon } = base;
|
||||
const { tip2tipEmit } = paths;
|
||||
const { paths, util, newPoint } = base;
|
||||
const { numOrDefault } = util;
|
||||
const { beltfact } = kiri.consts;
|
||||
const XAXIS = new THREE.Vector3(1,0,0);
|
||||
|
|
|
|||
Loading…
Reference in a new issue