disable wasm. move clip offset to slicePost

This commit is contained in:
Stewart Allen 2021-06-25 21:43:47 -04:00
commit ef9e8fb11a
8 changed files with 26 additions and 39 deletions

2
app.js
View file

@ -288,7 +288,7 @@ const script = {
"add/three",
"add/class",
"geo/base",
"geo/wasm",
// "geo/wasm",
"geo/debug",
"geo/point",
"geo/points",

View file

@ -314,7 +314,7 @@
opt.prof.call = (opt.prof.call || 0) + 1;
}
if (opt.wasm) {
if (false && opt.wasm) {
let oA = outA ? [] : undefined;
let oB = outB ? [] : undefined;
geo.wasm.js.diff(setA, setB, z, oA, oB);

View file

@ -132,7 +132,8 @@ if (!self.window) (function() {
function runTests() {
let newPolygon = self.base.newPolygon;
let p1 = newPolygon().add(0,0).add(4,0).add(4,4).add(0,4);
let p1 = newPolygon().centerCircle({x:2,y:2,z:0}, 2, 50);
// let p1 = newPolygon().add(0,0).add(4,0).add(4,4).add(0,4);
let p2 = p1.clone().setZ(0).move({x:2, y:2});
let d1 = [];
let d2 = [];
@ -184,8 +185,10 @@ if (!self.window) (function() {
};
if (debug) {
wasm.set_debug(1);
for (let i=0; i<100; i++) {
runTests();
}
}
});
})();

View file

@ -93,9 +93,10 @@ const funcs = {
}
let output = [];
for (let params of slices) {
let rec = KIRI.slicer.sliceZ(params.z, realp, options, params);
output.push({
params,
data: { tops: KIRI.slicer.sliceZ(params.z, realp, options, params).tops }
data: { tops: rec.tops, clip: rec.clip }
});
}
reply({ seq, output: CODEC.encode(output) });

View file

@ -339,11 +339,12 @@
function createSlice(params, data, options = {}) {
let { index, z, height, thick } = params;
let { lines, groups, tops } = data;
let { lines, groups, tops, clip } = data;
let slice = newSlice(z).addTops(tops);
slice.height = height;
slice.index = index;
slice.thick = thick;
slice.clips = clip;
// debugging (non-threaded mode only)
let { debug, xray, view } = options;
if (view && (debug || xray)) {

View file

@ -66,7 +66,7 @@
FDM.slicePost = function(data, options, params) {
let { lines, groups, tops } = data;
let { z, index, total, height, thick } = params;
let { process, isSynth, isDanger, vaseMode, shellOffset, fillOffset } = options.post;
let { process, isSynth, isDanger, vaseMode, shellOffset, fillOffset, clipOffset } = options.post;
if (isSynth) {
// do not shell synth widgets because
// they will be clipped against peers later
@ -98,11 +98,7 @@
danger: isDanger
}));
}
// // add simple (low rez poly) where less accuracy is OK
// for (let top of nutops) {
// // top.simple = top.poly.clean(true, undefined, CONF.clipper / 10);
// top.simple = top.poly.simple();
// }
data.clip = POLY.offset(nutops.map(t => t.simple), clipOffset);
data.tops = nutops;
};
@ -140,6 +136,7 @@
shellOffset = lineWidth,
fillSpacing = lineWidth,
fillOffset = lineWidth * fillOffsetMult,
clipOffset = process.sliceSupportOffset,
sliceFillAngle = process.sliceFillAngle,
supportDensity = process.sliceSupportDensity,
beltfact = Math.cos(Math.PI/4);
@ -193,6 +190,7 @@
post: {
shellOffset,
fillOffset,
clipOffset,
lineWidth,
vaseMode,
isSynth,
@ -279,13 +277,8 @@
if (Math.abs(Math.abs(pslice.z - slice.z) - gap) > 0.1) {
continue;
}
// offset pslice tops by process.sliceSupportOffset
if (!pslice.synth_off) {
pslice.synth_off = POLY.offset(pslice.topPolys(), process.sliceSupportOffset);
}
let ptops = pslice.synth_off;
let ntops = [];
POLY.subtract(tops, ptops, ntops, null, slice.z, 0);
POLY.subtract(tops, pslice.clips, ntops, null, slice.z, 0);
tops = ntops;
}
// trim to group's shadow if not in belt mode
@ -303,7 +296,6 @@
// calculate % complete and call onupdate()
function doupdate(index, from, to, msg) {
// onupdate(0.5 + (from + ((index/slices.length) * (to-from))) * 0.5, msg);
trackupdate(index / slices.length, from, to, msg);
}
@ -1181,12 +1173,6 @@
tops = slice.topPolys(),
trimTo = tops;
// create inner clip offset from tops (unless pre-computed)
if (!slice.offsets) {
// POLY.expand(tops, offset, slice.z, slice.offsets = []);
slice.offsets = geo.wasm.js.offset(tops, offset, slice.z);
}
let traces = POLY.flatten(slice.topShells().clone(true)),
fill = slice.topFill(),
points = [],
@ -1311,12 +1297,6 @@
}
}
/**
* @param {number} linewidth
* @param {number} angle
* @param {number} density
* @param {number} offset
*/
function doSupportFill(promises, slice, linewidth, density, minArea) {
let supports = slice.supports,
nsB = [],
@ -1329,14 +1309,14 @@
supports = POLY.union(supports, undefined, true);
// trim to clip offsets
if (slice.offsets) {
POLY.subtract(supports, slice.offsets, nsB, null, slice.z, min);
if (slice.clips) {
POLY.subtract(supports, slice.clips, nsB, null, slice.z, min);
}
supports = nsB;
// also trim to lower offsets, if they exist
if (slice.down && slice.down.offsets) {
POLY.subtract(nsB, slice.down.offsets, nsC, null, slice.z, min);
if (slice.down && slice.down.clips) {
POLY.subtract(nsB, slice.down.clips, nsC, null, slice.z, min);
supports = nsC;
}

View file

@ -43,11 +43,12 @@ Uint32 readPoly(Path &path, Uint32 pos) {
Uint16 points = ls->length;
// if (debug) polygon(points, 0);
pos += 2;
while (points-- > 0) {
while (points > 0) {
struct point32 *ip = (struct point32 *)(mem + pos);
pos += 8;
path << IntPoint(ip->x, ip->y);
// if (debug) point(ip->x, ip->y);
points--;
}
return pos;
}
@ -55,8 +56,9 @@ Uint32 readPoly(Path &path, Uint32 pos) {
Uint32 readPolys(Paths &paths, Uint32 pos, Uint32 count) {
Uint32 poly = 0;
// if (debug) abc(poly, count, pos);
while (count-- > 0) {
while (count > 0) {
pos = readPoly(paths[poly++], pos);
count--;
}
// if (debug) abc(poly, count, pos);
return pos;

Binary file not shown.