checkpoint belt support work. fixes for danish

This commit is contained in:
Stewart Allen 2021-01-21 21:39:51 -05:00
commit 8229dc4888
8 changed files with 98 additions and 15 deletions

View file

@ -35,7 +35,7 @@
restoreSupports(api.widgets.all());
});
api.event.on("settings.saved", (settings) => {
api.ui.fdmSupport.style.display = lastMode !== 'FDM' || settings.device.bedBelt ? 'none' : 'flex';
// api.ui.fdmSupport.style.display = lastMode !== 'FDM' || settings.device.bedBelt ? 'none' : 'flex';
});
api.event.on("button.click", target => {
switch (target) {

View file

@ -216,6 +216,8 @@
let swidget = KIRI.newWidget();
swidget.slices = sslices;
swidget.support = true;
swidget.rotinfo = widget.rotinfo;
swidget.belt = widget.belt;
swidget.mesh = { widget: swidget, position: widget.mesh.position };
settings.widget[swidget.id] = { extruder: process.sliceSupportNozzle };
widgets.push(swidget);
@ -288,7 +290,7 @@
// establish offsets
for (let widget of widgets) {
let { rotinfo, belt } = widget;
// console.log({rotinfo, belt});
console.log({rotinfo, belt, widget});
let offset = widget.mesh ? Object.clone(widget.mesh.position) : {x:0, y:0, z:0};
if (isBelt) {
offset.x = rotinfo.xpos;

View file

@ -23,7 +23,8 @@
infill: { check: 0x3322bb, face: 0x3322bb, line: 0x3322bb, opacity: 1 },
support: { check: 0xaa5533, face: 0xaa5533, line: 0xaa5533, opacity: 1 }
},
PROTO = Object.clone(COLOR);
PROTO = Object.clone(COLOR),
bwcomp = (1 / Math.cos(Math.PI/4));
let isThin = false; // force line rendering
let isFlat = false; // force flat rendering
@ -210,6 +211,11 @@
// slices[0].output()
// .setLayer('shadow', { line: 0xff0000, check: 0xff0000 })
// .addPolys(shadow);
if (isBelt) {
for (let col of fixed) {
col.z += widget.belt.zmov;
}
}
}
// create shells and diff inner fillable areas
@ -271,7 +277,7 @@
}, "infill");
}
// calculations only relevant when supports are enabled
// belt supports are their own thing
if (!isBelt) {
let auto = spro.sliceSupportEnable && spro.sliceSupportDensity > 0.0,
minArea = spro.sliceSupportArea;
@ -282,6 +288,8 @@
forSlices(0.8, 0.9, slice => {
doSupportFill(slice, lineWidth, spro.sliceSupportDensity, minArea);
}, "support");
} else if (false) {
doSupportBelt(slices, spro, fixed, shadow, doupdate);
}
// render if not explicitly disabled
@ -864,6 +872,77 @@
return true;
};
function doSupportBelt(slices, proc, fixed, shadow, doupdate) {
if (!fixed || fixed.length === 0) {
return;
}
let minArea = proc.supportMinArea,
offset = proc.sliceSupportOffset,
min = minArea || 0.01;
// find slice closest to z
function findSlice(z) {
let mind = Infinity,
mins = null;
for (let slice of slices) {
let d = Math.abs(slice.z - z);
if (d < mind) {
mind = d;
mins = slice;
}
}
return mins;
}
// add support pillar to a slice
function addPillar(slice, sup) {
// ensure slice has offsets
if (!slice.offsets) {
// create inner clip offset from tops
POLY.expand(slice.topPolys(), offset, slice.z, slice.offsets = []);
}
// ensure slice has supports array
if (!slice.supports) {
slice.supports = [];
}
// calculate support rect
let dz = sup.z - slice.z;
let dy = dz;
let dw = bwcomp;
let center = BASE.newPoint(sup.x, sup.y + dy, slice.z);
let poly = [ BASE.newPolygon().centerRectangle(center, sup.dw, sup.dw * dw) ];
let trim = [];
// poly = POLY.trimTo(poly, shadow);
POLY.subtract(poly, slice.offsets, trim, null, slice.z, min);
// if support is entirely culled, terminate projection
if (trim.length === 0) {
return false;
}
slice.supports.appendAll(trim);
return true;
}
for (let sup of fixed) {
let slice = findSlice(sup.z);
let rem = addPillar(slice, sup);
let zmin = sup.z - sup.dh / 2;
let zmax = sup.z + sup.dh / 2;
while (slice.up && slice.up.z <= zmax) {
slice = slice.up;
if (!addPillar(slice, sup)) {
break;
}
}
while (slice.down && slice.down.z >= zmin) {
slice = slice.down;
if (!addPillar(slice, sup)) {
break;
}
}
}
}
/**
* calculate external overhangs requiring support.
* this is done bottom-up except for fixed supports (manual)
@ -961,6 +1040,7 @@
let zmin = sup.z - sup.dh / 2;
let zmax = sup.z + sup.dh / 2;
if (slice.z >= zmin && slice.z <= zmax) {
let dz = sup.z - slice.z;
let center = BASE.newPoint(sup.x, sup.y, slice.z);
supports.push(BASE.newPolygon().centerRectangle(center, sup.dw, sup.dw));
}
@ -984,7 +1064,7 @@
// set depth hint on support polys for infill density
trimmed.forEach(function(trim) {
if (trim.area() < 0.1) return;
// if (trim.area() < 0.1) return;
culled.push(trim.setZ(down.z));
});