work on fdm slicing
This commit is contained in:
parent
5bf4142355
commit
6e172fe40f
12 changed files with 231 additions and 252 deletions
|
|
@ -31,20 +31,6 @@
|
||||||
/******/ })();
|
/******/ })();
|
||||||
/******/
|
/******/
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
var __webpack_exports__ = {};
|
|
||||||
|
|
||||||
// EXPORTS
|
|
||||||
__webpack_require__.d(__webpack_exports__, {
|
|
||||||
wT: () => (/* reexport */ BufferGeometryUtils_namespaceObject),
|
|
||||||
Xk: () => (/* reexport */ Line2),
|
|
||||||
vK: () => (/* reexport */ LineGeometry),
|
|
||||||
GV: () => (/* reexport */ LineMaterial),
|
|
||||||
bF: () => (/* reexport */ LineSegments2),
|
|
||||||
n3: () => (/* reexport */ LineSegmentsGeometry),
|
|
||||||
Z5: () => (/* reexport */ index_module_namespaceObject),
|
|
||||||
cK: () => (/* reexport */ SVGLoader_namespaceObject),
|
|
||||||
ZH: () => (/* reexport */ three_module_namespaceObject)
|
|
||||||
});
|
|
||||||
|
|
||||||
// NAMESPACE OBJECT: ./node_modules/three/build/three.module.js
|
// NAMESPACE OBJECT: ./node_modules/three/build/three.module.js
|
||||||
var three_module_namespaceObject = {};
|
var three_module_namespaceObject = {};
|
||||||
|
|
@ -80704,13 +80690,4 @@ const shaderIntersectFunction = `
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var __webpack_exports__BufferGeometryUtils = __webpack_exports__.wT;
|
export { BufferGeometryUtils_namespaceObject as BufferGeometryUtils, Line2, LineGeometry, LineMaterial, LineSegments2, LineSegmentsGeometry, index_module_namespaceObject as MeshBVHLib, SVGLoader_namespaceObject as SVGLoader, three_module_namespaceObject as THREE };
|
||||||
var __webpack_exports__Line2 = __webpack_exports__.Xk;
|
|
||||||
var __webpack_exports__LineGeometry = __webpack_exports__.vK;
|
|
||||||
var __webpack_exports__LineMaterial = __webpack_exports__.GV;
|
|
||||||
var __webpack_exports__LineSegments2 = __webpack_exports__.bF;
|
|
||||||
var __webpack_exports__LineSegmentsGeometry = __webpack_exports__.n3;
|
|
||||||
var __webpack_exports__MeshBVHLib = __webpack_exports__.Z5;
|
|
||||||
var __webpack_exports__SVGLoader = __webpack_exports__.cK;
|
|
||||||
var __webpack_exports__THREE = __webpack_exports__.ZH;
|
|
||||||
export { __webpack_exports__BufferGeometryUtils as BufferGeometryUtils, __webpack_exports__Line2 as Line2, __webpack_exports__LineGeometry as LineGeometry, __webpack_exports__LineMaterial as LineMaterial, __webpack_exports__LineSegments2 as LineSegments2, __webpack_exports__LineSegmentsGeometry as LineSegmentsGeometry, __webpack_exports__MeshBVHLib as MeshBVHLib, __webpack_exports__SVGLoader as SVGLoader, __webpack_exports__THREE as THREE };
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
* basic slice and line connection. In future, replace kiri's fdm and cam slicers
|
* basic slice and line connection. In future, replace kiri's fdm and cam slicers
|
||||||
* with wrappers on this one.
|
* with wrappers on this one.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { base } from './base.js';
|
||||||
import { newOrderedLine } from './line.js';
|
import { newOrderedLine } from './line.js';
|
||||||
import { newPolygon } from '../geo/polygon.js';
|
import { newPolygon } from '../geo/polygon.js';
|
||||||
import { polygons } from '../geo/polygons.js';
|
import { polygons } from '../geo/polygons.js';
|
||||||
|
|
@ -64,7 +66,6 @@ export async function slice(points, options = {}) {
|
||||||
for (i = 0; i < points.length; i++) {
|
for (i = 0; i < points.length; i++) {
|
||||||
points[i] = points[i].round(3);
|
points[i] = points[i].round(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// gather z-index stats
|
// gather z-index stats
|
||||||
|
|
@ -78,7 +79,7 @@ export async function slice(points, options = {}) {
|
||||||
if (p1.z === p2.z && p2.z === p3.z && p1.z >= zMin) {
|
if (p1.z === p2.z && p2.z === p3.z && p1.z >= zMin) {
|
||||||
// detect faces co-planar with Z and sum the enclosed area
|
// detect faces co-planar with Z and sum the enclosed area
|
||||||
let zkey = p1.z,
|
let zkey = p1.z,
|
||||||
area = Math.abs(util.area2(p1,p2,p3)) / 2;
|
area = Math.abs(base.util.area2(p1,p2,p3)) / 2;
|
||||||
if (!zFlat[zkey]) {
|
if (!zFlat[zkey]) {
|
||||||
zFlat[zkey] = area;
|
zFlat[zkey] = area;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -408,7 +409,8 @@ export async function sliceZ(z, points, options = {}) {
|
||||||
|
|
||||||
// look for driver-specific slice post-processor
|
// look for driver-specific slice post-processor
|
||||||
if (options.post) {
|
if (options.post) {
|
||||||
let fn = base.slicePost[options.post];
|
console.log({ options });
|
||||||
|
let fn = slicer.slicePost[options.post];
|
||||||
if (fn) fn(rval, options);
|
if (fn) fn(rval, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
import { $ } from '../../moto/webui.js';
|
import { $ } from '../../moto/webui.js';
|
||||||
import { api } from '../../kiri/api.js';
|
import { api } from '../../kiri/api.js';
|
||||||
import { conf } from '../../kiri/conf.js';
|
import { conf } from '../../kiri/conf.js';
|
||||||
|
import { client } from '../../kiri/client.js';
|
||||||
import { addbox, delbox } from '../../kiri/boxes.js';
|
import { addbox, delbox } from '../../kiri/boxes.js';
|
||||||
import { Layers } from '../../kiri/layers.js';
|
import { Layers } from '../../kiri/layers.js';
|
||||||
import { Stack } from '../../kiri/stack.js';
|
import { Stack } from '../../kiri/stack.js';
|
||||||
|
|
@ -201,7 +202,7 @@ export function init() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
alerts.push(api.show.alert("analyzing part(s)...", 1000));
|
alerts.push(api.show.alert("analyzing part(s)...", 1000));
|
||||||
FDM.support_generate(array => {
|
support_generate(array => {
|
||||||
func.sclear();
|
func.sclear();
|
||||||
api.hide.alert(undefined,alerts);
|
api.hide.alert(undefined,alerts);
|
||||||
for (let rec of array) {
|
for (let rec of array) {
|
||||||
|
|
@ -538,6 +539,23 @@ let xpdebug;
|
||||||
let supsave = {};
|
let supsave = {};
|
||||||
let suptimer;
|
let suptimer;
|
||||||
|
|
||||||
|
function support_generate(ondone) {
|
||||||
|
client.clear();
|
||||||
|
client.sync();
|
||||||
|
const settings = api.conf.get();
|
||||||
|
const widgets = api.widgets.map();
|
||||||
|
client.send("fdm_support_generate", { settings }, (gen) => {
|
||||||
|
if (gen && gen.error) {
|
||||||
|
api.show.alert('support generation canceled');
|
||||||
|
return ondone([]);
|
||||||
|
}
|
||||||
|
for (let g of gen) {
|
||||||
|
g.widget = widgets[g.id];
|
||||||
|
}
|
||||||
|
ondone(gen);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
function scheduleSupportSave(widget) {
|
function scheduleSupportSave(widget) {
|
||||||
clearTimeout(suptimer);
|
clearTimeout(suptimer);
|
||||||
supsave[widget.id] = widget;
|
supsave[widget.id] = widget;
|
||||||
|
|
|
||||||
44
src2/kiri-mode/fdm/driver-be.js
Normal file
44
src2/kiri-mode/fdm/driver-be.js
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
||||||
|
|
||||||
|
import { util } from '../../geo/base.js';
|
||||||
|
import { fdm_slice } from './slice.js';
|
||||||
|
import { fdm_prepare } from './prepare.js';
|
||||||
|
import { fdm_export } from './export.js';
|
||||||
|
|
||||||
|
// 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
|
||||||
|
function init(worker) {
|
||||||
|
|
||||||
|
worker.fdm_support_generate = function(data, send) {
|
||||||
|
const { settings } = data;
|
||||||
|
const widgets = Object.values(worker.cache);
|
||||||
|
const fresh = widgets.filter(widget => FDM.supports(settings, widget));
|
||||||
|
send.done(kiri.codec.encode(fresh.map(widget => { return {
|
||||||
|
id: widget.id,
|
||||||
|
supports: widget.supports,
|
||||||
|
} } )));
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export const FDM = {
|
||||||
|
init,
|
||||||
|
extrudePerMM,
|
||||||
|
extrudeMM,
|
||||||
|
slice: fdm_slice,
|
||||||
|
prepare: fdm_prepare,
|
||||||
|
export: fdm_export
|
||||||
|
};
|
||||||
|
|
@ -1,16 +1,7 @@
|
||||||
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
||||||
import { base } from '../../../geo/base.js';
|
|
||||||
import { kiri } from '../../kiri.js';
|
|
||||||
import { driver } from '../../kiri.js';
|
|
||||||
import { util } from '../../../geo/base.js';
|
|
||||||
|
|
||||||
const { base, kiri } = root;
|
|
||||||
const { driver } = kiri;
|
|
||||||
const { util } = base;
|
|
||||||
const FDM = driver.FDM = { getRangeParameters, extrudePerMM, extrudeMM };
|
|
||||||
|
|
||||||
// shared by client and worker contexts
|
// shared by client and worker contexts
|
||||||
function getRangeParameters(process, index) {
|
export function getRangeParameters(process, index) {
|
||||||
if (index === undefined || index === null || index < 0) {
|
if (index === undefined || index === null || index < 0) {
|
||||||
return process;
|
return process;
|
||||||
}
|
}
|
||||||
|
|
@ -29,55 +20,3 @@ function getRangeParameters(process, index) {
|
||||||
}
|
}
|
||||||
return params;
|
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 => {
|
|
||||||
|
|
||||||
const { client, worker } = kiri;
|
|
||||||
|
|
||||||
if (client) {
|
|
||||||
FDM.support_generate = function(ondone) {
|
|
||||||
client.clear();
|
|
||||||
client.sync();
|
|
||||||
const settings = api.conf.get();
|
|
||||||
const widgets = api.widgets.map();
|
|
||||||
client.send("fdm_support_generate", { settings }, (gen) => {
|
|
||||||
if (gen && gen.error) {
|
|
||||||
api.show.alert('support generation canceled');
|
|
||||||
return ondone([]);
|
|
||||||
}
|
|
||||||
for (let g of gen) {
|
|
||||||
g.widget = widgets[g.id];
|
|
||||||
}
|
|
||||||
ondone(gen);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (worker) {
|
|
||||||
worker.fdm_support_generate = function(data, send) {
|
|
||||||
const { settings } = data;
|
|
||||||
const widgets = Object.values(worker.cache);
|
|
||||||
const fresh = widgets.filter(widget => FDM.supports(settings, widget));
|
|
||||||
send.done(kiri.codec.encode(fresh.map(widget => { return {
|
|
||||||
id: widget.id,
|
|
||||||
supports: widget.supports,
|
|
||||||
} } )));
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,19 @@
|
||||||
import { base } from '../geo/base.js';
|
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
||||||
import { utils } from '../kiri/utils.js';
|
|
||||||
import { driver } from '../kiri-mode/fdm/driver.js';
|
|
||||||
|
|
||||||
|
import { base, util } from '../../geo/base.js';
|
||||||
|
import { getRangeParameters } from './driver.js';
|
||||||
|
|
||||||
const const { base, kiri } = root;;const const { util, config } = base;;const const { FDM } = kiri.driver;;const const { getRangeParameters } = FDM;;const debug = false;
|
const { config } = base;
|
||||||
|
const debug = false;
|
||||||
|
|
||||||
FDM.export = function(print, online, ondone, ondebug) const { const { widgets, settings, belty, tools, firstTool } = print;;const const { bounds, controller, device, process, filter, mode } = settings;;const const { extruders, fwRetract } = device;;const const { bedWidth, bedDepth, bedRound, bedBelt, maxHeight } = device;;const const { gcodeFan, gcodeLayer, gcodeTrack, gcodePause, gcodeFeature, gcodeChange } = device;;let model_labels = [];
|
export function fdm_export(print, online, ondone, ondebug) {
|
||||||
|
const { widgets, settings, belty, tools, firstTool } = print;
|
||||||
|
const { bounds, controller, device, process, filter, mode } = settings;
|
||||||
|
const { extruders, fwRetract } = device;
|
||||||
|
const { bedWidth, bedDepth, bedRound, bedBelt, maxHeight } = device;
|
||||||
|
const { gcodeFan, gcodeLayer, gcodeTrack, gcodePause, gcodeFeature, gcodeChange } = device;
|
||||||
|
|
||||||
|
let model_labels = [];
|
||||||
for (let widget of widgets) {
|
for (let widget of widgets) {
|
||||||
model_labels.push(widget.track.grid_id);
|
model_labels.push(widget.track.grid_id);
|
||||||
}
|
}
|
||||||
|
|
@ -13,7 +21,9 @@ FDM.export = function(print, online, ondone, ondebug) const { const { widgets, s
|
||||||
let layers = print.output,
|
let layers = print.output,
|
||||||
extras = device.extras || {},
|
extras = device.extras || {},
|
||||||
isBambu = extras.bbl,
|
isBambu = extras.bbl,
|
||||||
const { extrudeAbs } = device;const { exportThumb } = controller;extused = Object.keys(print.extruders).map(v => parseInt(v)),
|
{ extrudeAbs } = device,
|
||||||
|
{ exportThumb } = controller,
|
||||||
|
extused = Object.keys(print.extruders).map(v => parseInt(v)),
|
||||||
timeFactor = (device.gcodeTime || 1) * 1.5,
|
timeFactor = (device.gcodeTime || 1) * 1.5,
|
||||||
decimals = config.gcode_decimals || 4,
|
decimals = config.gcode_decimals || 4,
|
||||||
zMoveMax = device.deviceZMax || 0,
|
zMoveMax = device.deviceZMax || 0,
|
||||||
|
|
@ -281,7 +291,9 @@ FDM.export = function(print, online, ondone, ondebug) const { const { widgets, s
|
||||||
append(`; Bed type: ${bedType}`);
|
append(`; Bed type: ${bedType}`);
|
||||||
append(`; Target: ${filter[mode]}`);
|
append(`; Target: ${filter[mode]}`);
|
||||||
// inject thumbnail preview
|
// inject thumbnail preview
|
||||||
if (exportThumb && worker.snap) const { let { width, height, url } = worker.snap;;let data = url.substring(url.indexOf(',') + 1);
|
if (exportThumb && worker.snap) {
|
||||||
|
let { width, height, url } = worker.snap;
|
||||||
|
let data = url.substring(url.indexOf(',') + 1);
|
||||||
append(`; thumbnail begin ${width} ${height} ${data.length}`);
|
append(`; thumbnail begin ${width} ${height} ${data.length}`);
|
||||||
for (let i=0; i<data.length; i += 78) {
|
for (let i=0; i<data.length; i += 78) {
|
||||||
append(`; ${data.substring(i, i + 78)}`);
|
append(`; ${data.substring(i, i + 78)}`);
|
||||||
|
|
@ -819,7 +831,9 @@ FDM.export = function(print, online, ondone, ondebug) const { const { widgets, s
|
||||||
drainQ();
|
drainQ();
|
||||||
}
|
}
|
||||||
|
|
||||||
function emitQrec(rec) const { let {e, x, y, dist, emitPerMM, speedMMM } = rec;;// emitMM = emitPerMM * e * dist;
|
function emitQrec(rec) {
|
||||||
|
let {e, x, y, dist, emitPerMM, speedMMM} = rec;
|
||||||
|
// emitMM = emitPerMM * e * dist;
|
||||||
emitMM = extrudeMM(dist, emitPerMM, e);
|
emitMM = extrudeMM(dist, emitPerMM, e);
|
||||||
moveTo({x:x, y:y, e:emitMM}, speedMMM);
|
moveTo({x:x, y:y, e:emitMM}, speedMMM);
|
||||||
emitted += emitMM;
|
emitted += emitMM;
|
||||||
|
|
@ -974,6 +988,3 @@ FDM.export = function(print, online, ondone, ondebug) const { const { widgets, s
|
||||||
console.log('minz', minz);
|
console.log('minz', minz);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export { encodeBitOffset, setTempFanSpeed, updateParams, append, appendSubPad, appendSub, appendAll, appendAllSub, appendTok, preamble, dwell, retract, unretract, pushPos, popPos, moveTo, emitQrec, drainQ, arcValid, debug, model_labels, layers, tools_used, bytes, byteIndex, bitPosition, rloops, loops, subon, ifhit, evil, arg, data, i, pre, gcpre, axmap, t0, t1, wait, taxis, tcent, angle, savePos, o, emit, epos, zheight, line, allout, totaldistance, endloop, off, b64, x, rec, deem, depm, desp, el, e1, e2, e3, e4, e5, cc, lr, dc, radFault, avg, dx, dy, tc, defer, moveSpeed, vec1, vec2, gc, from, to, cl, dist, add, globalCenters, ac, rad };
|
|
||||||
|
|
@ -1,26 +1,24 @@
|
||||||
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
||||||
import { base } from '../geo/base.js';
|
|
||||||
import { gyroid } from '../geo/gyroid.js';
|
|
||||||
import { driver } from '../kiri-mode/fdm/driver.js';
|
|
||||||
|
|
||||||
|
import { base, util } from '../../geo/base.js';
|
||||||
|
import { slice as gyroid_slice } from '../../geo/gyroid.js';
|
||||||
|
|
||||||
const { base, kiri } = root;
|
export const fill_fixed = {
|
||||||
const { util } = base;
|
hex: fillHexFull,
|
||||||
|
grid: fillGrid,
|
||||||
|
triangle: fillTriangle
|
||||||
|
};
|
||||||
|
|
||||||
const DEG2RAD = Math.PI / 180,
|
export const fill = {
|
||||||
FILL = kiri.fill = {
|
hex: fillHexFull,
|
||||||
hex: fillHexFull,
|
grid: fillGrid,
|
||||||
grid: fillGrid,
|
gyroid: fillGyroid,
|
||||||
gyroid: fillGyroid,
|
triangle: fillTriangle,
|
||||||
triangle: fillTriangle,
|
linear: fillLinear,
|
||||||
linear: fillLinear,
|
cubic: fillCubic
|
||||||
cubic: fillCubic
|
};
|
||||||
},
|
|
||||||
CACHE = kiri.fill_fixed = {
|
const DEG2RAD = Math.PI / 180;
|
||||||
hex: fillHexFull,
|
|
||||||
grid: fillGrid,
|
|
||||||
triangle: fillTriangle
|
|
||||||
};
|
|
||||||
|
|
||||||
function fillHexFull(target) {
|
function fillHexFull(target) {
|
||||||
fillHex(target, true);
|
fillHex(target, true);
|
||||||
|
|
@ -106,13 +104,13 @@ function fillGyroid(target) {
|
||||||
let tile_x = span_x / tile;
|
let tile_x = span_x / tile;
|
||||||
let tile_y = span_y / tile;
|
let tile_y = span_y / tile;
|
||||||
let tile_z = 1 / tile;
|
let tile_z = 1 / tile;
|
||||||
let gyroid = base.gyroid.slice(target.zValue() * tile_z, (1 - density) * 500);
|
let gen = gyroid_slice(target.zValue() * tile_z, (1 - density) * 500);
|
||||||
|
|
||||||
let polys = [];
|
let polys = [];
|
||||||
if (gyroid.dir == 'lr') {
|
if (gen.dir == 'lr') {
|
||||||
for (let ty=0; ty<=tile_y; ty++) {
|
for (let ty=0; ty<=tile_y; ty++) {
|
||||||
for (let tx=0; tx<=tile_x; tx++) {
|
for (let tx=0; tx<=tile_x; tx++) {
|
||||||
for (let poly of gyroid.polys) {
|
for (let poly of gen.polys) {
|
||||||
target.newline();
|
target.newline();
|
||||||
let points = poly.map(el => {
|
let points = poly.map(el => {
|
||||||
return {
|
return {
|
||||||
|
|
@ -129,7 +127,7 @@ function fillGyroid(target) {
|
||||||
} else {
|
} else {
|
||||||
for (let tx=0; tx<=tile_x; tx++) {
|
for (let tx=0; tx<=tile_x; tx++) {
|
||||||
for (let ty=0; ty<=tile_y; ty++) {
|
for (let ty=0; ty<=tile_y; ty++) {
|
||||||
for (let poly of gyroid.polys) {
|
for (let poly of gen.polys) {
|
||||||
target.newline();
|
target.newline();
|
||||||
let points = poly.map(el => {
|
let points = poly.map(el => {
|
||||||
return {
|
return {
|
||||||
|
|
@ -320,6 +318,3 @@ function fillTriangle(target) {
|
||||||
target.emit(xp, bounds.max.y);
|
target.emit(xp, bounds.max.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export { fillHexFull, fillHex, fillGyroid, connectOpenPolys, fillGrid, fillCubic, fillLinear, fillTriangle, DEG2RAD, spacing, vhlen, anxlen, anylen, bounds, even, evenZ, maxy, height, span_x, span_y, density, tile, tile_x, tile_y, tile_z, gyroid, polys, ty, tx, points, heal, ntmp, i, s1, j, s2, offset, tile_xc, tile_yc, bx, by, span, steps, step, ztype, line_w, xp };
|
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,15 @@
|
||||||
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
||||||
import { base } from '../geo/base.js';
|
|
||||||
import { polygons } from '../geo/polygons.js';
|
|
||||||
import { driver } from '../kiri-mode/fdm/driver.js';
|
|
||||||
|
|
||||||
|
import { base } from '../../geo/base.js';
|
||||||
const { base, kiri } = root;
|
import { polygons as POLY, fillArea } from '../../geo/polygons.js';
|
||||||
const { driver } = kiri;
|
import { getRangeParameters } from './driver.js';
|
||||||
const { polygons } = base;
|
|
||||||
const { fillArea } = polygons;
|
|
||||||
const { FDM } = driver;
|
|
||||||
|
|
||||||
const POLY = polygons;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* may run in minion or worker context. do not create objects
|
* may run in minion or worker context. do not create objects
|
||||||
* that will not quickly encode in threaded mode. add to existing
|
* that will not quickly encode in threaded mode. add to existing
|
||||||
* data object. return is ignored.
|
* data object. return is ignored.
|
||||||
*/
|
*/
|
||||||
base.slicePost.FDM = function(data, options) {
|
export function slicePost(data, options) {
|
||||||
const { z, lines, groups } = data;
|
const { z, lines, groups } = data;
|
||||||
const { useAssembly, post_args, zIndexes } = options;
|
const { useAssembly, post_args, zIndexes } = options;
|
||||||
const { process, isSynth, vaseMode } = post_args;
|
const { process, isSynth, vaseMode } = post_args;
|
||||||
|
|
@ -37,7 +29,7 @@ base.slicePost.FDM = function(data, options) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const index = zIndexes.indexOf(z);
|
const index = zIndexes.indexOf(z);
|
||||||
const range = FDM.getRangeParameters(process, index);
|
const range = getRangeParameters(process, index);
|
||||||
// calculate fractional shells
|
// calculate fractional shells
|
||||||
let shellFrac = (range.sliceShells - (range.sliceShells | 0));
|
let shellFrac = (range.sliceShells - (range.sliceShells | 0));
|
||||||
let sliceShells = range.sliceShells | 0;
|
let sliceShells = range.sliceShells | 0;
|
||||||
|
|
@ -59,7 +51,7 @@ base.slicePost.FDM = function(data, options) {
|
||||||
const nutops = [];
|
const nutops = [];
|
||||||
// co-locate shell processing with top generation in slicer
|
// co-locate shell processing with top generation in slicer
|
||||||
for (let top of data.tops) {
|
for (let top of data.tops) {
|
||||||
nutops.push(FDM.doTopShells(z, top, count, offset/2, offset, fillOff, {
|
nutops.push(doTopShells(z, top, count, offset/2, offset, fillOff, {
|
||||||
thinType,
|
thinType,
|
||||||
vaseMode,
|
vaseMode,
|
||||||
useAssembly
|
useAssembly
|
||||||
|
|
@ -190,7 +182,7 @@ function thin_type_3(params) {
|
||||||
* may run in minion or worker context. performs shell offsetting
|
* may run in minion or worker context. performs shell offsetting
|
||||||
* including thin wall detection when enabled
|
* including thin wall detection when enabled
|
||||||
*/
|
*/
|
||||||
FDM.doTopShells = function(z, top, count, offset1, offsetN, fillOffset, opt = {}) {
|
export function doTopShells(z, top, count, offset1, offsetN, fillOffset, opt = {}) {
|
||||||
// pretend we're a top object in minions
|
// pretend we're a top object in minions
|
||||||
if (!top.poly) {
|
if (!top.poly) {
|
||||||
top = { poly: top };
|
top = { poly: top };
|
||||||
|
|
@ -316,6 +308,3 @@ function cullIntersections() {
|
||||||
}
|
}
|
||||||
return good.length > 2 ? good : [];
|
return good.length > 2 ? good : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export { offset_default, thin_type_1, thin_type_2, thin_type_3, cullIntersections, toLines, POLY, process, index, range, shellFrac, sliceShells, v1, v2, parts, rem, trg, isFirst, height, spaceMult, count, offset, fillOff, thinType, nutops, layers, off, min, max, centers, oso, wasm, top_poly, last, dist, ret, nulast, lns, i, aOa, aa, bb, al, j, bl, good };
|
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,15 @@
|
||||||
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
||||||
import { base } from '../geo/base.js';
|
|
||||||
import { paths } from '../geo/paths.js';
|
|
||||||
import { point } from '../geo/point.js';
|
|
||||||
import { polygons } from '../geo/polygons.js';
|
|
||||||
import { utils } from '../kiri/utils.js';
|
|
||||||
import { slice } from '../kiri/slice.js';
|
|
||||||
import { consts } from '../kiri/consts.js';
|
|
||||||
import { render } from '../kiri/render.js';
|
|
||||||
import { driver } from '../kiri-mode/fdm/driver.js';
|
|
||||||
|
|
||||||
|
import { base, util } from '../../geo/base.js';
|
||||||
|
import { poly2polyEmit, tip2tipEmit } from '../../geo/paths.js';
|
||||||
|
import { newPoint } from '../../geo/point.js';
|
||||||
|
import { newPolygon } from '../../geo/polygon.js';
|
||||||
|
import { polygons as POLY, fillArea } from '../../geo/polygons.js';
|
||||||
|
import { newSlice } from '../../kiri/slice.js';
|
||||||
|
import { render } from '../../kiri/render.js';
|
||||||
|
import { getRangeParameters } from './driver.js';
|
||||||
|
|
||||||
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 { numOrDefault } = util;
|
||||||
const { fillArea } = polygons;
|
|
||||||
const { beltfact } = consts;
|
|
||||||
const { FDM } = driver;
|
|
||||||
const { getRangeParameters } = FDM;
|
|
||||||
const POLY = polygons;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DRIVER PRINT CONTRACT
|
* DRIVER PRINT CONTRACT
|
||||||
|
|
@ -27,7 +17,7 @@ const POLY = polygons;
|
||||||
* @param {Function} update progress callback
|
* @param {Function} update progress callback
|
||||||
* @returns {Object[]} returns array of render objects
|
* @returns {Object[]} returns array of render objects
|
||||||
*/
|
*/
|
||||||
FDM.prepare = async function(widgets, settings, update) {
|
export async function fdm_prepare(widgets, settings, update) {
|
||||||
// filter ignored widgets
|
// filter ignored widgets
|
||||||
widgets = widgets.filter(w => !w.track.ignore && !w.meta.disabled);
|
widgets = widgets.filter(w => !w.track.ignore && !w.meta.disabled);
|
||||||
|
|
||||||
|
|
@ -1509,6 +1499,3 @@ function slicePrintPath(print, slice, startPoint, offset, output, opt = {}) {
|
||||||
|
|
||||||
return startPoint.add(offset);
|
return startPoint.add(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export { raft, mkblok, mkrec, linesToPoly, purge, slicePrintPath, retract, intersectsTop, routeAround, outputTraces, outputSparse, outputThin, outputFills, outputOrderClosest, POLY, lastLayerStart, wp, wb, brims, tops, slices, off, extra, zheight, offset, slice, t, polys, brimStart, bbounds, sslices, sslice, swidget, extruders, extcount, extruder, blokw, blokh, count, gap, step, mp, sp, ts, ty, tx, exi, towers, poly, ping, i, p1, p2, purgedFirst, rec, thin, tool, first, rate, wipe, purgeOn, scale, box, pause, fill, bmove, bo, cake, zrec, z, track, order, find, ext, lex, dst, forceRetract, params, wtb, beltStart, lastOut, center, maxDist, useDist, endpoint, preout, belt, thresh, point, brimHalf, firstLayerBrim, firstLayerBrimIn, firstLayerBrimTrig, firstLayerBrimGap, minz, mins, miny, pads, overate, brate, bmult, belty, lowrate, tmpout, trigmet, brimax, y, g, b, bi, lastLayerOut, beltPoint, gaps, lpad, x0, x1, array, last, int, dbug, ints, ip, i1, i2, isCW, points, p1p, p2p, r1s, r1e, r1, r1d, r2s, r2e, r2, r2d, route, debug, finishShell, from, proxy, lp, dist, rdst, itop, emit, d1, d2, idiff, min, restart, out, lastTop, top, isRaft, bounds, radius, angle, x, inner, shells };
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,19 @@
|
||||||
import { base } from '../geo/base.js';
|
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
||||||
import { slicer } from '../geo/slicer.js';
|
|
||||||
import { polygons } from '../geo/polygons.js';
|
|
||||||
import { utils } from '../kiri/utils.js';
|
|
||||||
import { consts } from '../kiri/consts.js';
|
|
||||||
import { driver } from '../kiri-mode/fdm/driver.js';
|
|
||||||
import { post } from '../kiri-mode/fdm/post.js';
|
|
||||||
import { fill } from '../kiri-mode/fdm/fill.js';
|
|
||||||
import { clip2 } from '../ext/clip2.js';
|
|
||||||
import { three } from '../add/three.js';
|
|
||||||
|
|
||||||
|
import { base, util } from '../../geo/base.js';
|
||||||
|
import { newBounds } from '../../geo/bounds.js';
|
||||||
|
import { newPolygon } from '../../geo/polygon.js';
|
||||||
|
import { polygons as POLY } from '../../geo/polygons.js';
|
||||||
|
import { newPoint } from '../../geo/point.js';
|
||||||
|
import { slice, sliceZ } from '../../geo/slicer.js';
|
||||||
|
import { newSlice } from '../../kiri/slice.js';
|
||||||
|
import { fill, fill_fixed } from './fill.js';
|
||||||
|
import { getRangeParameters } from './driver.js';
|
||||||
|
import { doTopShells } from './post.js';
|
||||||
|
|
||||||
const const { base, kiri, noop } = root;;const const { consts, driver, fill, fill_fixed, newSlice, utils } = kiri;;const const { config, polygons, util, newPoint } = base;;const const { fillArea } = polygons;;const const { FDM } = driver;;const const { doTopShells, getRangeParameters } = FDM;;const POLY = polygons,
|
const { config } = base;
|
||||||
tracker = util.pwait,
|
|
||||||
|
let tracker = util.pwait,
|
||||||
lopacity = 0.6,
|
lopacity = 0.6,
|
||||||
opacity = 1,
|
opacity = 1,
|
||||||
fat = 1.5,
|
fat = 1.5,
|
||||||
|
|
@ -33,6 +35,7 @@ const const { base, kiri, noop } = root;;const const { consts, driver, fill, fil
|
||||||
part: { line: 0x777777, check: 0x777777, face: 0 },
|
part: { line: 0x777777, check: 0x777777, face: 0 },
|
||||||
thin: { check: 0xbb8800, face: 0xbb8800, line: 0xbb8800, opacity, lopacity, fat },
|
thin: { check: 0xbb8800, face: 0xbb8800, line: 0xbb8800, opacity, lopacity, fat },
|
||||||
}),
|
}),
|
||||||
|
noop = () => {},
|
||||||
PROTO = Object.clone(COLOR),
|
PROTO = Object.clone(COLOR),
|
||||||
profile = false,
|
profile = false,
|
||||||
profileStart = profile ? console.profile : noop,
|
profileStart = profile ? console.profile : noop,
|
||||||
|
|
@ -55,16 +58,19 @@ function vopt(opt) {
|
||||||
return opt;
|
return opt;
|
||||||
}
|
}
|
||||||
|
|
||||||
FDM.sliceAll = function(settings, onupdate) {
|
export function sliceAll(settings, onupdate) {
|
||||||
// future home of brim and anchor generation
|
// future home of brim and anchor generation
|
||||||
let widgets = Object.values(kiri.worker.cache)
|
let widgets = Object.values(self.kiri_worker.cache)
|
||||||
.filter(w => !w.meta.disabled)
|
.filter(w => !w.meta.disabled)
|
||||||
.sort((a,b) => {
|
.sort((a,b) => {
|
||||||
return a.slices[0].z - b.slices[0].z
|
return a.slices[0].z - b.slices[0].z
|
||||||
});
|
});
|
||||||
// assign grid_id which can be embedded in gcode and
|
// assign grid_id which can be embedded in gcode and
|
||||||
// used by the controller to cancel objects during print
|
// used by the controller to cancel objects during print
|
||||||
let const { bounds } = settings;;for (let widget of widgets) const { let { pos, box } = widget.track;;// calculate top/left coordinate for widget
|
let { bounds } = settings;
|
||||||
|
for (let widget of widgets) {
|
||||||
|
let { pos, box } = widget.track;
|
||||||
|
// calculate top/left coordinate for widget
|
||||||
// relative to bounding box for all widgets
|
// relative to bounding box for all widgets
|
||||||
let tl = {
|
let tl = {
|
||||||
x: Math.round((pos.x - box.w/2 - bounds.min.x) / 10) + 1,
|
x: Math.round((pos.x - box.w/2 - bounds.min.x) / 10) + 1,
|
||||||
|
|
@ -109,12 +115,16 @@ FDM.sliceAll = function(settings, onupdate) {
|
||||||
* @param {Function} onupdate (called with % complete and optional message)
|
* @param {Function} onupdate (called with % complete and optional message)
|
||||||
* @param {Function} ondone (called when complete with an array of Slice objects)
|
* @param {Function} ondone (called when complete with an array of Slice objects)
|
||||||
*/
|
*/
|
||||||
FDM.slice = function(settings, widget, onupdate, ondone) const { let render = settings.render !== false, { process, device, controller } = settings;isBelt = device.bedBelt,
|
export function fdm_slice(settings, widget, onupdate, ondone) {
|
||||||
|
let render = settings.render !== false,
|
||||||
|
{ minions } = self.kiri_worker,
|
||||||
|
{ process, device, controller } = settings,
|
||||||
|
isBelt = device.bedBelt,
|
||||||
isBrick = controller.devel && process.sliceZInterleave,
|
isBrick = controller.devel && process.sliceZInterleave,
|
||||||
isSynth = widget.track.synth,
|
isSynth = widget.track.synth,
|
||||||
isSupport = widget.track.support,
|
isSupport = widget.track.support,
|
||||||
useAssembly = controller.assembly,
|
useAssembly = controller.assembly,
|
||||||
isConcurrent = controller.threaded && kiri.minions.concurrent,
|
isConcurrent = controller.threaded && minions.concurrent,
|
||||||
topLayers = process.sliceTopLayers || 0,
|
topLayers = process.sliceTopLayers || 0,
|
||||||
bottomLayers = process.sliceBottomLayers || 0,
|
bottomLayers = process.sliceBottomLayers || 0,
|
||||||
vaseMode = process.sliceFillType === 'vase' && !isSynth,
|
vaseMode = process.sliceFillType === 'vase' && !isSynth,
|
||||||
|
|
@ -186,7 +196,8 @@ FDM.slice = function(settings, widget, onupdate, ondone) const { let render = se
|
||||||
// handle z cutting (floor method) and base flattening
|
// handle z cutting (floor method) and base flattening
|
||||||
let zPress = isBelt ? process.firstLayerFlatten || 0 : 0;
|
let zPress = isBelt ? process.firstLayerFlatten || 0 : 0;
|
||||||
let zCut = widget.track.zcut || 0;
|
let zCut = widget.track.zcut || 0;
|
||||||
let const { belt } = widget;;if (zCut || zPress) {
|
let { belt } = widget;
|
||||||
|
if (zCut || zPress) {
|
||||||
for (let p of points) {
|
for (let p of points) {
|
||||||
if (!p._z) {
|
if (!p._z) {
|
||||||
p._z = p.z;
|
p._z = p.z;
|
||||||
|
|
@ -208,7 +219,7 @@ FDM.slice = function(settings, widget, onupdate, ondone) const { let render = se
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
base.slice(points, {
|
slice(points, {
|
||||||
debug: process.xray,
|
debug: process.xray,
|
||||||
xray: process.xray,
|
xray: process.xray,
|
||||||
zMin: bounds.min.z,
|
zMin: bounds.min.z,
|
||||||
|
|
@ -232,7 +243,8 @@ FDM.slice = function(settings, widget, onupdate, ondone) const { let render = se
|
||||||
if (process.xray) {
|
if (process.xray) {
|
||||||
return zopt.zIndexes;
|
return zopt.zIndexes;
|
||||||
}
|
}
|
||||||
let const { zMin, zMax } = zopt;;let h1 = sliceHeight;
|
let { zMin, zMax } = zopt;
|
||||||
|
let h1 = sliceHeight;
|
||||||
let h0 = sliceHeightBase || h1;
|
let h0 = sliceHeightBase || h1;
|
||||||
let hm = sliceMinHeight || 0;
|
let hm = sliceMinHeight || 0;
|
||||||
let h = h0;
|
let h = h0;
|
||||||
|
|
@ -310,14 +322,16 @@ FDM.slice = function(settings, widget, onupdate, ondone) const { let render = se
|
||||||
// slicer function (worker local or minion distributed)
|
// slicer function (worker local or minion distributed)
|
||||||
slicer(z, points, opts) {
|
slicer(z, points, opts) {
|
||||||
// opts.debug = opts.debug || isSynth;
|
// opts.debug = opts.debug || isSynth;
|
||||||
return (isConcurrent ? kiri.minions.sliceZ : base.sliceZ)(z, points, opts);
|
return (isConcurrent ? minions.sliceZ : sliceZ)(z, points, opts);
|
||||||
},
|
},
|
||||||
onupdate(update) {
|
onupdate(update) {
|
||||||
return onupdate(0.0 + update * 0.5)
|
return onupdate(0.0 + update * 0.5)
|
||||||
}
|
}
|
||||||
}).then((output) => const { // post process slices and re-incorporate missing meta-data
|
}).then((output) => {
|
||||||
|
// post process slices and re-incorporate missing meta-data
|
||||||
return output.slices.map(data => {
|
return output.slices.map(data => {
|
||||||
let { z, clip, lines, groups, changes } = data;;if (!data.tops) return null;
|
let { z, clip, lines, groups, changes } = data;
|
||||||
|
if (!data.tops) return null;
|
||||||
let slice = newSlice(z).addTops(data.tops);
|
let slice = newSlice(z).addTops(data.tops);
|
||||||
slice.index = indices.indexOf(z);
|
slice.index = indices.indexOf(z);
|
||||||
slice.height = heights[slice.index];
|
slice.height = heights[slice.index];
|
||||||
|
|
@ -359,7 +373,7 @@ FDM.slice = function(settings, widget, onupdate, ondone) const { let render = se
|
||||||
.map(w => w.slices).flat()
|
.map(w => w.slices).flat()
|
||||||
.map(s => s.tops).flat().map(t => t.simple);
|
.map(s => s.tops).flat().map(t => t.simple);
|
||||||
let shadow = isConcurrent ?
|
let shadow = isConcurrent ?
|
||||||
await kiri.minions.union(alltops, 0.1) :
|
await minions.union(alltops, 0.1) :
|
||||||
POLY.union(alltops, 0.1, true);
|
POLY.union(alltops, 0.1, true);
|
||||||
// expand shadow when requested (support clipping)
|
// expand shadow when requested (support clipping)
|
||||||
if (process.sliceSupportExtra) {
|
if (process.sliceSupportExtra) {
|
||||||
|
|
@ -495,7 +509,9 @@ FDM.slice = function(settings, widget, onupdate, ondone) const { let render = se
|
||||||
}, "solid layers");
|
}, "solid layers");
|
||||||
|
|
||||||
// add lead in anchor when specified in belt mode (but not for synths)
|
// add lead in anchor when specified in belt mode (but not for synths)
|
||||||
if (isBelt && !isSynth) const { let { cosf, slope } = widget.belt;;// find adjusted zero point from slices
|
if (isBelt && !isSynth) {
|
||||||
|
let { cosf, slope } = widget.belt;
|
||||||
|
// find adjusted zero point from slices
|
||||||
let smin = Infinity;
|
let smin = Infinity;
|
||||||
for (let slice of slices) {
|
for (let slice of slices) {
|
||||||
let miny = Infinity;
|
let miny = Infinity;
|
||||||
|
|
@ -561,7 +577,7 @@ FDM.slice = function(settings, widget, onupdate, ondone) const { let render = se
|
||||||
addto.belt.touch = false;
|
addto.belt.touch = false;
|
||||||
let z = addto.z;
|
let z = addto.z;
|
||||||
let y = (slope * 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 splat = newPolygon().add(minx, y, z).add(maxx, y, z).setOpen();
|
||||||
let snew = addto.addTop(splat).fill_sparse = [ splat ];
|
let snew = addto.addTop(splat).fill_sparse = [ splat ];
|
||||||
adds.push(snew);
|
adds.push(snew);
|
||||||
start = addto;
|
start = addto;
|
||||||
|
|
@ -594,16 +610,20 @@ FDM.slice = function(settings, widget, onupdate, ondone) const { let render = se
|
||||||
let fz = first.z;
|
let fz = first.z;
|
||||||
let n2 = lineWidth / 2;
|
let n2 = lineWidth / 2;
|
||||||
for (let x = mp - dx; x <= mp + dx ; x += 3) {
|
for (let x = mp - dx; x <= mp + dx ; x += 3) {
|
||||||
add.push( base.newPolygon().add(x, fy - n2, fz).add(x, fy + y + n2, fz).setOpen() );
|
add.push(newPolygon().add(x, fy - n2, fz).add(x, fy + y + n2, fz).setOpen() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// experimental emboss text on a flat underside of an object
|
// experimental emboss text on a flat underside of an object
|
||||||
// in belt mode only
|
// in belt mode only
|
||||||
if (process.pooch && self.OffscreenCanvas) const { const { length, width, height, text } = process.pooch;;let firstZ, firstI, lastZ, lastI, minX = 0, maxX = 0, maxY = 0;
|
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
|
// locate suitable flat spot
|
||||||
for (let slice of slices) const { let { belt } = slice;;if (!belt.touch) {
|
for (let slice of slices) {
|
||||||
|
let { belt } = slice;
|
||||||
|
if (!belt.touch) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let index = slice.index;
|
let index = slice.index;
|
||||||
|
|
@ -684,7 +704,7 @@ FDM.slice = function(settings, widget, onupdate, ondone) const { let render = se
|
||||||
let z = slice.z;
|
let z = slice.z;
|
||||||
let y = z - smin - (lineWidth / 2);
|
let y = z - smin - (lineWidth / 2);
|
||||||
for (let line of lines) {
|
for (let line of lines) {
|
||||||
supps.push(base.newPolygon()
|
supps.push(newPolygon()
|
||||||
.add(minX + line.start / 2, y, z)
|
.add(minX + line.start / 2, y, z)
|
||||||
.add(minX + line.end / 2, y, z)
|
.add(minX + line.end / 2, y, z)
|
||||||
.setOpen()
|
.setOpen()
|
||||||
|
|
@ -811,7 +831,9 @@ FDM.slice = function(settings, widget, onupdate, ondone) const { let render = se
|
||||||
trackupdate(i / t, 0.6, 0.7);
|
trackupdate(i / t, 0.6, 0.7);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
for (let rec of resolve) const { let { slice, polys } = rec;;rec.supports = polys;
|
for (let rec of resolve) {
|
||||||
|
let { slice, polys } = rec;
|
||||||
|
rec.supports = polys;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -910,7 +932,7 @@ FDM.slice = function(settings, widget, onupdate, ondone) const { let render = se
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isBelt) {
|
if (isBelt) {
|
||||||
let bounds = base.newBounds();
|
let bounds = newBounds();
|
||||||
let slice = slices[0];
|
let slice = slices[0];
|
||||||
if (slice.tops) {
|
if (slice.tops) {
|
||||||
for (let top of slice.tops) {
|
for (let top of slice.tops) {
|
||||||
|
|
@ -962,7 +984,9 @@ function bound(v,min,max) {
|
||||||
return Math.max(min,Math.min(max,v));
|
return Math.max(min,Math.min(max,v));
|
||||||
}
|
}
|
||||||
|
|
||||||
function doRender(slice, isSynth, params, opt = {}) const { const { dark, devel } = opt;;const Color = dark ? COLOR_DARK : COLOR;
|
function doRender(slice, isSynth, params, opt = {}) {
|
||||||
|
const { dark, devel } = opt;
|
||||||
|
const Color = dark ? COLOR_DARK : COLOR;
|
||||||
const output = slice.output();
|
const output = slice.output();
|
||||||
const height = slice.height / 2;
|
const height = slice.height / 2;
|
||||||
const solidWidth = params.sliceFillWidth || 1;
|
const solidWidth = params.sliceFillWidth || 1;
|
||||||
|
|
@ -1050,15 +1074,6 @@ function doRender(slice, isSynth, params, opt = {}) const { const { dark, devel
|
||||||
// console.log(slice.index, slice.render.stats);
|
// console.log(slice.index, slice.render.stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
// shared with SLA driver and minions
|
|
||||||
FDM.share = {
|
|
||||||
doShells,
|
|
||||||
doTopShells,
|
|
||||||
doDiff,
|
|
||||||
projectFlats,
|
|
||||||
projectBridges
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute offset shell polygons. For FDM, the first offset is usually half
|
* Compute offset shell polygons. For FDM, the first offset is usually half
|
||||||
* of the nozzle width. Each subsequent offset is a full nozzle width. User
|
* of the nozzle width. Each subsequent offset is a full nozzle width. User
|
||||||
|
|
@ -1073,7 +1088,7 @@ FDM.share = {
|
||||||
* @param {number} fillOffset
|
* @param {number} fillOffset
|
||||||
* @param {Obejct} options
|
* @param {Obejct} options
|
||||||
*/
|
*/
|
||||||
function doShells(slice, count, offset1, offsetN, fillOffset, opt = {}) {
|
export function doShells(slice, count, offset1, offsetN, fillOffset, opt = {}) {
|
||||||
for (let top of slice.tops) {
|
for (let top of slice.tops) {
|
||||||
doTopShells(slice.z, top, count, offset1, offsetN, fillOffset, opt);
|
doTopShells(slice.z, top, count, offset1, offsetN, fillOffset, opt);
|
||||||
}
|
}
|
||||||
|
|
@ -1099,7 +1114,7 @@ function doShells(slice, count, offset1, offsetN, fillOffset, opt = {}) {
|
||||||
|
|
||||||
slice.tops.forEach(function(top) {
|
slice.tops.forEach(function(top) {
|
||||||
if (!top.fill_off) return; // missing for inner brick layers
|
if (!top.fill_off) return; // missing for inner brick layers
|
||||||
let lines = fillArea(top.fill_off, angle, spacing, null);
|
let lines = POLY.fillArea(top.fill_off, angle, spacing, null);
|
||||||
top.fill_lines.appendAll(lines);
|
top.fill_lines.appendAll(lines);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -1259,7 +1274,7 @@ function doSparseLayerFill(slice, options = {}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.promises) {
|
if (options.promises) {
|
||||||
options.promises.push(kiri.minions.clip(slice, polys, lines));
|
options.promises.push(self.kiri_worker.minions.clip(slice, polys, lines));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1285,7 +1300,9 @@ function doSparseLayerFill(slice, options = {}) {
|
||||||
* Used to calculate bridges, flats and then solid projections.
|
* Used to calculate bridges, flats and then solid projections.
|
||||||
* 'expand' is used for top offsets in SLA mode
|
* 'expand' is used for top offsets in SLA mode
|
||||||
*/
|
*/
|
||||||
function doDiff(slice, options = {}) const { const { sla, fakedown, grow, min } = options;;if ((slice.index <= 0 && !fakedown) || slice.xray) {
|
export function doDiff(slice, options = {}) {
|
||||||
|
const { sla, fakedown, grow, min } = options;
|
||||||
|
if ((slice.index <= 0 && !fakedown) || slice.xray) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const top = slice,
|
const top = slice,
|
||||||
|
|
@ -1339,7 +1356,7 @@ function addSolidFills(slice, polys) {
|
||||||
/**
|
/**
|
||||||
* project bottom flats down
|
* project bottom flats down
|
||||||
*/
|
*/
|
||||||
function projectFlats(slice, count, expand) {
|
export function projectFlats(slice, count, expand) {
|
||||||
if (!slice.down || !slice.flats) return;
|
if (!slice.down || !slice.flats) return;
|
||||||
// these flats are marked for finishing print speed
|
// these flats are marked for finishing print speed
|
||||||
if (slice.flats.length) slice.finishSolids = true;
|
if (slice.flats.length) slice.finishSolids = true;
|
||||||
|
|
@ -1352,7 +1369,7 @@ function projectFlats(slice, count, expand) {
|
||||||
/**
|
/**
|
||||||
* project top bridges up
|
* project top bridges up
|
||||||
*/
|
*/
|
||||||
function projectBridges(slice, count) {
|
export function projectBridges(slice, count) {
|
||||||
if (!slice.up || !slice.bridges) return;
|
if (!slice.up || !slice.bridges) return;
|
||||||
// these flats are marked for finishing print speed
|
// these flats are marked for finishing print speed
|
||||||
if (slice.bridges.length) slice.finishSolids = true;
|
if (slice.bridges.length) slice.finishSolids = true;
|
||||||
|
|
@ -1483,7 +1500,7 @@ function doSolidsFill(slice, spacing, angle, minArea, fillQ) {
|
||||||
|
|
||||||
function doFillArea(fillQ, polys, angle, spacing, output, minLen, maxLen) {
|
function doFillArea(fillQ, polys, angle, spacing, output, minLen, maxLen) {
|
||||||
if (fillQ) {
|
if (fillQ) {
|
||||||
fillQ.push(kiri.minions.fill(polys, angle, spacing, output, minLen, maxLen));
|
fillQ.push(self.kiri_worker.minions.fill(polys, angle, spacing, output, minLen, maxLen));
|
||||||
} else {
|
} else {
|
||||||
POLY.fillArea(polys, angle, spacing, output, minLen, maxLen);
|
POLY.fillArea(polys, angle, spacing, output, minLen, maxLen);
|
||||||
}
|
}
|
||||||
|
|
@ -1582,26 +1599,26 @@ async function doSupport(slice, proc, shadow, opt = {}) {
|
||||||
|
|
||||||
// for each point, create a bounding rectangle
|
// for each point, create a bounding rectangle
|
||||||
points.forEach(function(point) {
|
points.forEach(function(point) {
|
||||||
pillars.push(base.newPolygon().centerRectangle(point, size/2, size/2));
|
pillars.push(newPolygon().centerRectangle(point, size/2, size/2));
|
||||||
});
|
});
|
||||||
|
|
||||||
supports.appendAll(POLY.union(pillars, null, true, { wasm: false }));
|
supports.appendAll(POLY.union(pillars, null, true, { wasm: false }));
|
||||||
// merge pillars and replace with convex hull of outer points (aka smoothing)
|
// merge pillars and replace with convex hull of outer points (aka smoothing)
|
||||||
pillars = POLY.union(pillars, null, true, { wasm: false }).forEach(function(pillar) {
|
pillars = POLY.union(pillars, null, true, { wasm: false }).forEach(function(pillar) {
|
||||||
supports.push(base.newPolygon().createConvexHull(pillar.points));
|
supports.push(newPolygon().createConvexHull(pillar.points));
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
// DEBUG code
|
// DEBUG code
|
||||||
if (SDBG && down_traces) slice.output()
|
if (SDBG && down_traces) slice.output()
|
||||||
.setLayer('cks', { line: 0xee5533, check: 0xee5533 })
|
.setLayer('cks', { line: 0xee5533, check: 0xee5533 })
|
||||||
.addPolys(cks.map(p => base.newPolygon().centerRectangle(p, 0.25, 0.25)))
|
.addPolys(cks.map(p => newPolygon().centerRectangle(p, 0.25, 0.25)))
|
||||||
.setLayer('pip', { line: 0xdd4422, check: 0xdd4422 })
|
.setLayer('pip', { line: 0xdd4422, check: 0xdd4422 })
|
||||||
.addPolys(pip.map(p => base.newPolygon().centerRectangle(p, 0.4, 0.4)))
|
.addPolys(pip.map(p => newPolygon().centerRectangle(p, 0.4, 0.4)))
|
||||||
.setLayer('pcl', { line: 0xcc3311, check: 0xcc3311 })
|
.setLayer('pcl', { line: 0xcc3311, check: 0xcc3311 })
|
||||||
.addPolys(pcl.map(p => base.newPolygon().centerRectangle(p, 0.3, 0.3)))
|
.addPolys(pcl.map(p => newPolygon().centerRectangle(p, 0.3, 0.3)))
|
||||||
.setLayer('pts', { line: 0xdd33dd, check: 0xdd33dd })
|
.setLayer('pts', { line: 0xdd33dd, check: 0xdd33dd })
|
||||||
.addPolys(points.map(p => base.newPolygon().centerRectangle(p, 0.8, 0.8)))
|
.addPolys(points.map(p => newPolygon().centerRectangle(p, 0.8, 0.8)))
|
||||||
.setLayer('dtr', { line: 0x0, check: 0x0 })
|
.setLayer('dtr', { line: 0x0, check: 0x0 })
|
||||||
.addPolys(POLY.setZ(down_traces.clone(true),slice.z));
|
.addPolys(POLY.setZ(down_traces.clone(true),slice.z));
|
||||||
;
|
;
|
||||||
|
|
@ -1612,7 +1629,7 @@ async function doSupport(slice, proc, shadow, opt = {}) {
|
||||||
|
|
||||||
// then union supports
|
// then union supports
|
||||||
if (supports.length > 10) {
|
if (supports.length > 10) {
|
||||||
supports = await kiri.minions.union(supports);
|
supports = await minions.union(supports);
|
||||||
} else {
|
} else {
|
||||||
supports = POLY.union(supports, null, true, { wasm: false });
|
supports = POLY.union(supports, null, true, { wasm: false });
|
||||||
}
|
}
|
||||||
|
|
@ -1651,7 +1668,9 @@ async function doSupport(slice, proc, shadow, opt = {}) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function doSupportFill(args) const { const { promises, slice, lineWidth, density, minArea, isBelt, angle, outline } = args;;let supports = slice.supports,
|
function doSupportFill(args) {
|
||||||
|
const { promises, slice, lineWidth, density, minArea, isBelt, angle, outline } = args;
|
||||||
|
let supports = slice.supports,
|
||||||
nsB = [],
|
nsB = [],
|
||||||
nsC = [],
|
nsC = [],
|
||||||
min = minArea || 0.1;
|
min = minArea || 0.1;
|
||||||
|
|
@ -1682,7 +1701,9 @@ function doSupportFill(args) const { const { promises, slice, lineWidth, density
|
||||||
slice.supports = supports;
|
slice.supports = supports;
|
||||||
};
|
};
|
||||||
|
|
||||||
function fillSupportPolys(args) const { const { promises, polys, lineWidth, density, z, isBelt, angle, outline } = args;;// calculate fill density
|
function fillSupportPolys(args) {
|
||||||
|
const { promises, polys, lineWidth, density, z, isBelt, angle, outline } = args;
|
||||||
|
// calculate fill density
|
||||||
let spacing = lineWidth * (1 / density);
|
let spacing = lineWidth * (1 / density);
|
||||||
polys.forEach(function (poly) {
|
polys.forEach(function (poly) {
|
||||||
// calculate angle based on width/height ratio
|
// calculate angle based on width/height ratio
|
||||||
|
|
@ -1726,7 +1747,7 @@ function projectSolid(slice, polys, count, up, first) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FDM.supports = function(settings, widget) {
|
export function supports(settings, widget) {
|
||||||
let isBelt = settings.device.bedBelt;
|
let isBelt = settings.device.bedBelt;
|
||||||
let process = settings.process;
|
let process = settings.process;
|
||||||
let size = process.sliceSupportSize;
|
let size = process.sliceSupportSize;
|
||||||
|
|
@ -1802,7 +1823,9 @@ FDM.supports = function(settings, widget) {
|
||||||
} : (norm) => {
|
} : (norm) => {
|
||||||
return norm.z < thresh;
|
return norm.z < thresh;
|
||||||
};
|
};
|
||||||
let const { position } = geo.attributes;;let const { itemSize, count, array } = position;;for (let i = 0; i<count; i += 3) {
|
let { position } = geo.attributes;
|
||||||
|
let { itemSize, count, array } = position;
|
||||||
|
for (let i = 0; i<count; i += 3) {
|
||||||
let ip = i * itemSize;
|
let ip = i * itemSize;
|
||||||
let a = new THREE.Vector3(array[ip++], array[ip++], array[ip++]);
|
let a = new THREE.Vector3(array[ip++], array[ip++], array[ip++]);
|
||||||
let b = new THREE.Vector3(array[ip++], array[ip++], array[ip++]);
|
let b = new THREE.Vector3(array[ip++], array[ip++], array[ip++]);
|
||||||
|
|
@ -1885,7 +1908,7 @@ class Coplanars {
|
||||||
// convert groups of faces to contiguous polygon groups
|
// convert groups of faces to contiguous polygon groups
|
||||||
groups = groups.map(group => {
|
groups = groups.map(group => {
|
||||||
let parr = group.map(arr => {
|
let parr = group.map(arr => {
|
||||||
return base.newPolygon()
|
return newPolygon()
|
||||||
.add(arr[0].x, arr[0].y, arr[0].z)
|
.add(arr[0].x, arr[0].y, arr[0].z)
|
||||||
.add(arr[1].x, arr[1].y, arr[1].z)
|
.add(arr[1].x, arr[1].y, arr[1].z)
|
||||||
.add(arr[2].x, arr[2].y, arr[2].z);
|
.add(arr[2].x, arr[2].y, arr[2].z);
|
||||||
|
|
@ -1903,6 +1926,3 @@ class Coplanars {
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export { vopt, doShadow, onSliceDone, doupdate, trackupdate, forSlices, connect_lines, bound, doRender, doShells, doSolidLayerFill, doSparseLayerFill, doDiff, addSolidFills, projectFlats, projectBridges, doSolidsFill, doFillArea, doSupport, checkPointSupport, checkLineSupport, doSupportFill, fillSupportPolys, projectSolid, tp, tf, POLY, isThin, widgets, tl, ext, e, render, color, proto, sliceMinHeight, bounds, points, indices, heights, healed, zPress, zCut, zd, h1, h0, hm, h, z, zi, zh, zIncFirst, zInc, zIncMin, zHeights, zIndexes, zOrdered, zPos, realz, slice, alltops, shadow, found, i, gap, tops, clipto, ntops, range, spaceMult, isBottom, isTop, isDense, isSolid, solidWidth, fillSpace, smin, miny, y, by, minx, peek, brim, adds, step, anchorlen, addto, splat, snew, bump, count, poly, first, mp, dx, fy, fz, n2, x, index, p0, p1, p0y, p1y, i_ok, y_ok, x_ok, dy, dz, span, tall, can, ctx, img, rgb, str, maxp, lines, pix, supps, params, solidMinArea, sliceFillGrow, promises, newType, down, outline, resolve, density, supports, polys, last, nu, nuSlice, ti, nuTop, cap, newlines, eo, p2, t, op1, idx, Color, output, height, group, process, skippable, miss, sparse_clip, masks, angl, inter, p, top, newBridges, newFlats, flats, minarea, unioned, trims, make_solid_layer, tops_area, stop, top_area, stop_area, tofill, angfill, newfill, maxBridge, traces, SDBG, cks, pip, pcl, supported, dist, slope, pillars, depth, trimmed, spacing, auto, inset, clones, isBelt, size, s9, s4, s2, min, geo, rad, deg, angle, thresh, dir, add, mat, mesh, platform, now, pm, ray, int, mid, dab, dbc, dca, max, filter, ip, a, b, c, norm, key, arr, out, groups, match, parr, union };
|
|
||||||
|
|
@ -1,12 +1,5 @@
|
||||||
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
// Future imports for src/kiri-run/minion.js when unwrapped from gapp.register()
|
|
||||||
|
|
||||||
// Core dependencies from root
|
|
||||||
import { base, kiri } from '../../main/gapp.js';
|
|
||||||
|
|
||||||
// Base dependencies
|
// Base dependencies
|
||||||
import { polygons } from '../../geo/base.js';
|
import { polygons } from '../../geo/base.js';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
||||||
|
|
||||||
console.log('TOP OF WORKER');
|
|
||||||
|
|
||||||
import "../ext/clip2.js";
|
import "../ext/clip2.js";
|
||||||
import "../ext/earcut.js";
|
import "../ext/earcut.js";
|
||||||
import '../add/array.js';
|
import '../add/array.js';
|
||||||
|
|
@ -21,6 +19,7 @@ import { version } from '../moto/license.js';
|
||||||
import { Widget, newWidget } from '../kiri/widget.js';
|
import { Widget, newWidget } from '../kiri/widget.js';
|
||||||
|
|
||||||
import { CAM } from '../kiri-mode/cam/driver-be.js';
|
import { CAM } from '../kiri-mode/cam/driver-be.js';
|
||||||
|
import { FDM } from '../kiri-mode/fdm/driver-be.js';
|
||||||
|
|
||||||
// const CAM = {};
|
// const CAM = {};
|
||||||
const { time } = util;
|
const { time } = util;
|
||||||
|
|
@ -28,7 +27,8 @@ const POLY = polygons;
|
||||||
|
|
||||||
let debug = (self.debug === true),
|
let debug = (self.debug === true),
|
||||||
drivers = {
|
drivers = {
|
||||||
CAM
|
CAM,
|
||||||
|
FDM
|
||||||
},
|
},
|
||||||
ccvalue = self.navigator ? self.navigator.hardwareConcurrency || 0 : 0,
|
ccvalue = self.navigator ? self.navigator.hardwareConcurrency || 0 : 0,
|
||||||
concurrent = Math.min(4, self.Worker && ccvalue > 3 ? ccvalue - 1 : 0),
|
concurrent = Math.min(4, self.Worker && ccvalue > 3 ? ccvalue - 1 : 0),
|
||||||
|
|
@ -45,12 +45,6 @@ let debug = (self.debug === true),
|
||||||
minifns = {},
|
minifns = {},
|
||||||
miniseq = 0;
|
miniseq = 0;
|
||||||
|
|
||||||
const worker = self.kiri_worker = {
|
|
||||||
current,
|
|
||||||
drivers,
|
|
||||||
version
|
|
||||||
};
|
|
||||||
|
|
||||||
// catch clipper alerts and convert to console messages
|
// catch clipper alerts and convert to console messages
|
||||||
self.alert = function(o) {
|
self.alert = function(o) {
|
||||||
console.log(o);
|
console.log(o);
|
||||||
|
|
@ -70,7 +64,7 @@ function minhandler(msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// for concurrent operations
|
// for concurrent operations
|
||||||
const minwork = worker.minions = {
|
const minwork = {
|
||||||
get concurrent() {
|
get concurrent() {
|
||||||
return concurrent
|
return concurrent
|
||||||
},
|
},
|
||||||
|
|
@ -198,6 +192,7 @@ const minwork = worker.minions = {
|
||||||
points: floatP,
|
points: floatP,
|
||||||
options
|
options
|
||||||
}, data => {
|
}, data => {
|
||||||
|
console.log({ data });
|
||||||
for (let rec of data.output) {
|
for (let rec of data.output) {
|
||||||
each(rec);
|
each(rec);
|
||||||
}
|
}
|
||||||
|
|
@ -744,7 +739,16 @@ dispatch.onmessage = self.onmessage = async function(e) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self.kiri_worker = {
|
||||||
|
cache: wcache,
|
||||||
|
current,
|
||||||
|
drivers,
|
||||||
|
version,
|
||||||
|
minions: minwork
|
||||||
|
};
|
||||||
|
|
||||||
// initilize driver mode handlers
|
// initilize driver mode handlers
|
||||||
CAM.init(dispatch);
|
CAM.init(dispatch);
|
||||||
|
FDM.init(dispatch);
|
||||||
|
|
||||||
broker.publish("worker.started", { dispatch, minions: minwork });
|
broker.publish("worker.started", { dispatch, minions: minwork });
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue