comments and tweaks on belt slicing

This commit is contained in:
Stewart Allen 2024-07-06 15:40:58 -04:00
commit 9aae90880c
6 changed files with 53 additions and 52 deletions

View file

@ -258,6 +258,7 @@ FDM.init = function(kiri, api) {
updateVisiblity();
// synth support widget for each widget group
// iow, create support meshes based on support widget annotation
let synth = [];
for (let group of kiri.Widget.Groups.list()) {
let merge = group.filter(w => w.sups).map(w => Object.values(w.sups)).flat();
@ -290,10 +291,9 @@ FDM.init = function(kiri, api) {
}
});
api.event.on("key.esc", () => {
if (!isFdmMode) {
return;
if (isFdmMode) {
func.sdone()
}
func.sdone()
});
api.event.on("selection.scale", () => {
if (isFdmMode) {
@ -304,7 +304,6 @@ FDM.init = function(kiri, api) {
api.event.on("widget.delete", widget => {
if (isFdmMode) {
clearRanges();
return;
}
});
api.event.on("widget.duplicate", (widget, oldwidget) => {

View file

@ -13,9 +13,9 @@
// dep: kiri-mode.fdm.driver
gapp.register("kiri-mode.fdm.prepare", [], (root, exports) => {
const { base, kiri, noop } = root;
const { consts, driver, newSlice, utils, render } = kiri;
const { config, polygons, paths, util, newPoint, newPolygon, Polygon } = base;
const { base, kiri } = root;
const { consts, driver, newSlice, render } = kiri;
const { polygons, paths, util, newPoint, newPolygon, Polygon } = base;
const { poly2polyEmit, tip2tipEmit } = paths;
const { numOrDefault } = util;
const { fillArea } = polygons;
@ -34,10 +34,10 @@ FDM.prepare = async function(widgets, settings, update) {
// filter ignored widgets
widgets = widgets.filter(w => !w.track.ignore && !w.meta.disabled);
let { device, process, controller, bounds, mode } = settings,
{ sliceHeight, firstSliceHeight, firstLayerRate, sliceSupportOutline } = process,
let { device, process, controller, bounds } = settings,
{ sliceHeight, firstSliceHeight, firstLayerRate } = process,
{ outputSeekrate, outputDraftShield, outputPurgeTower } = process,
{ bedWidth, bedDepth, filamentSource } = device,
{ bedWidth, bedDepth } = device,
{ lineType } = controller,
printPoint = newPoint(0,0,0),
print = self.worker.print = kiri.newPrint(settings, widgets),
@ -45,7 +45,6 @@ FDM.prepare = async function(widgets, settings, update) {
isBelt = device.bedBelt,
isThin = lineType === "line",
isFlat = lineType === "flat",
isPalette = filamentSource === 'palette3',
useRaft = process.outputRaft || false,
firstLayerHeight = isBelt ? sliceHeight : firstSliceHeight || sliceHeight,
layerno = 0,
@ -135,14 +134,14 @@ FDM.prepare = async function(widgets, settings, update) {
POLY.expand(brims, nozzle * 4, 0, null, 1) : brims;
function raft(height, angle, spacing, speed, extrude, outline) {
let slice = kiri.newSlice(zoff + height / 2);
let slice = newSlice(zoff + height / 2);
for (let brim of rafts) {
// use first point of first brim as start point
if (printPoint === null) printPoint = brim.first();
let t = slice.addTop(brim);
if (outline) t.traces = [ brim ];
t.inner = POLY.expand([ brim ], nozzle * -0.8, 0, null, 1);
t.fill_lines = POLY.fillArea(t.inner, angle, spacing, []);
t.fill_lines = fillArea(t.inner, angle, spacing, []);
t.isRaft = true;
}
offset.z = slice.z;
@ -238,7 +237,7 @@ FDM.prepare = async function(widgets, settings, update) {
if (!slice.supports) {
continue;
}
let sslice = kiri.newSlice(slice.z);
let sslice = newSlice(slice.z);
sslice.extruder = process.sliceSupportNozzle;
sslice.supports = slice.supports.slice();
sslice.height = slice.height;
@ -315,10 +314,10 @@ FDM.prepare = async function(widgets, settings, update) {
noz = exi.extNozzle,
pos = {x:blokpos.x + walkpos.x * i, y:blokpos.y + walkpos.y * i, z:0},
rect = newPolygon().centerRectangle(pos, blok.x, blok.y),
full = linesToPoly(POLY.fillArea([
full = linesToPoly(fillArea([
newPolygon().centerRectangle(pos, blok.x - noz, blok.y - noz)
], angle, noz)),
sparse = rect.area() > 10 ? linesToPoly(POLY.fillArea([
sparse = rect.area() > 10 ? linesToPoly(fillArea([
newPolygon().centerRectangle(pos, blok.x - noz, blok.y - noz)
], angle + 90, noz * thin)) : newPolygon(),
rec = {

View file

@ -596,9 +596,12 @@ FDM.slice = function(settings, widget, onupdate, ondone) {
}
}
}
// experimental emboss text on a flat underside of an object
// in belt mode only
if (process.pooch && self.OffscreenCanvas) {
const { length, width, height, text } = process.pooch;
let firstZ, firstI, lastZ, lastI, minX = 0, maxX = 0, maxY = 0;
// locate suitable flat spot
for (let slice of slices) {
let { belt } = slice;
if (!belt.touch) {