disable wasm. move clip offset to slicePost
This commit is contained in:
parent
5947dda899
commit
ef9e8fb11a
8 changed files with 26 additions and 39 deletions
2
app.js
2
app.js
|
|
@ -288,7 +288,7 @@ const script = {
|
||||||
"add/three",
|
"add/three",
|
||||||
"add/class",
|
"add/class",
|
||||||
"geo/base",
|
"geo/base",
|
||||||
"geo/wasm",
|
// "geo/wasm",
|
||||||
"geo/debug",
|
"geo/debug",
|
||||||
"geo/point",
|
"geo/point",
|
||||||
"geo/points",
|
"geo/points",
|
||||||
|
|
|
||||||
|
|
@ -314,7 +314,7 @@
|
||||||
opt.prof.call = (opt.prof.call || 0) + 1;
|
opt.prof.call = (opt.prof.call || 0) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opt.wasm) {
|
if (false && opt.wasm) {
|
||||||
let oA = outA ? [] : undefined;
|
let oA = outA ? [] : undefined;
|
||||||
let oB = outB ? [] : undefined;
|
let oB = outB ? [] : undefined;
|
||||||
geo.wasm.js.diff(setA, setB, z, oA, oB);
|
geo.wasm.js.diff(setA, setB, z, oA, oB);
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ if (!self.window) (function() {
|
||||||
|
|
||||||
function polyUnion(polys, z) {
|
function polyUnion(polys, z) {
|
||||||
let wasm = geo.wasm,
|
let wasm = geo.wasm,
|
||||||
buffer = geo.wasm.shared,
|
buffer = geo.wasm.shared,
|
||||||
pcount = writePolys(new DataWriter(wasm.heap, buffer), polys),
|
pcount = writePolys(new DataWriter(wasm.heap, buffer), polys),
|
||||||
resat = wasm.fn.union(buffer, pcount),
|
resat = wasm.fn.union(buffer, pcount),
|
||||||
out = readPolys(new DataReader(wasm.heap, resat), z);
|
out = readPolys(new DataReader(wasm.heap, resat), z);
|
||||||
|
|
@ -88,7 +88,7 @@ if (!self.window) (function() {
|
||||||
|
|
||||||
function polyDiff(polysA, polysB, z, AB, BA) {
|
function polyDiff(polysA, polysB, z, AB, BA) {
|
||||||
let wasm = geo.wasm,
|
let wasm = geo.wasm,
|
||||||
buffer = geo.wasm.shared,
|
buffer = geo.wasm.shared,
|
||||||
writer = new DataWriter(wasm.heap, buffer),
|
writer = new DataWriter(wasm.heap, buffer),
|
||||||
pcountA = writePolys(writer, polysA),
|
pcountA = writePolys(writer, polysA),
|
||||||
pcountB = writePolys(writer, polysB),
|
pcountB = writePolys(writer, polysB),
|
||||||
|
|
@ -132,7 +132,8 @@ if (!self.window) (function() {
|
||||||
|
|
||||||
function runTests() {
|
function runTests() {
|
||||||
let newPolygon = self.base.newPolygon;
|
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 p2 = p1.clone().setZ(0).move({x:2, y:2});
|
||||||
let d1 = [];
|
let d1 = [];
|
||||||
let d2 = [];
|
let d2 = [];
|
||||||
|
|
@ -184,7 +185,9 @@ if (!self.window) (function() {
|
||||||
};
|
};
|
||||||
if (debug) {
|
if (debug) {
|
||||||
wasm.set_debug(1);
|
wasm.set_debug(1);
|
||||||
runTests();
|
for (let i=0; i<100; i++) {
|
||||||
|
runTests();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -93,9 +93,10 @@ const funcs = {
|
||||||
}
|
}
|
||||||
let output = [];
|
let output = [];
|
||||||
for (let params of slices) {
|
for (let params of slices) {
|
||||||
|
let rec = KIRI.slicer.sliceZ(params.z, realp, options, params);
|
||||||
output.push({
|
output.push({
|
||||||
params,
|
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) });
|
reply({ seq, output: CODEC.encode(output) });
|
||||||
|
|
|
||||||
|
|
@ -339,11 +339,12 @@
|
||||||
|
|
||||||
function createSlice(params, data, options = {}) {
|
function createSlice(params, data, options = {}) {
|
||||||
let { index, z, height, thick } = params;
|
let { index, z, height, thick } = params;
|
||||||
let { lines, groups, tops } = data;
|
let { lines, groups, tops, clip } = data;
|
||||||
let slice = newSlice(z).addTops(tops);
|
let slice = newSlice(z).addTops(tops);
|
||||||
slice.height = height;
|
slice.height = height;
|
||||||
slice.index = index;
|
slice.index = index;
|
||||||
slice.thick = thick;
|
slice.thick = thick;
|
||||||
|
slice.clips = clip;
|
||||||
// debugging (non-threaded mode only)
|
// debugging (non-threaded mode only)
|
||||||
let { debug, xray, view } = options;
|
let { debug, xray, view } = options;
|
||||||
if (view && (debug || xray)) {
|
if (view && (debug || xray)) {
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@
|
||||||
FDM.slicePost = function(data, options, params) {
|
FDM.slicePost = function(data, options, params) {
|
||||||
let { lines, groups, tops } = data;
|
let { lines, groups, tops } = data;
|
||||||
let { z, index, total, height, thick } = params;
|
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) {
|
if (isSynth) {
|
||||||
// do not shell synth widgets because
|
// do not shell synth widgets because
|
||||||
// they will be clipped against peers later
|
// they will be clipped against peers later
|
||||||
|
|
@ -98,11 +98,7 @@
|
||||||
danger: isDanger
|
danger: isDanger
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
// // add simple (low rez poly) where less accuracy is OK
|
data.clip = POLY.offset(nutops.map(t => t.simple), clipOffset);
|
||||||
// for (let top of nutops) {
|
|
||||||
// // top.simple = top.poly.clean(true, undefined, CONF.clipper / 10);
|
|
||||||
// top.simple = top.poly.simple();
|
|
||||||
// }
|
|
||||||
data.tops = nutops;
|
data.tops = nutops;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -140,6 +136,7 @@
|
||||||
shellOffset = lineWidth,
|
shellOffset = lineWidth,
|
||||||
fillSpacing = lineWidth,
|
fillSpacing = lineWidth,
|
||||||
fillOffset = lineWidth * fillOffsetMult,
|
fillOffset = lineWidth * fillOffsetMult,
|
||||||
|
clipOffset = process.sliceSupportOffset,
|
||||||
sliceFillAngle = process.sliceFillAngle,
|
sliceFillAngle = process.sliceFillAngle,
|
||||||
supportDensity = process.sliceSupportDensity,
|
supportDensity = process.sliceSupportDensity,
|
||||||
beltfact = Math.cos(Math.PI/4);
|
beltfact = Math.cos(Math.PI/4);
|
||||||
|
|
@ -193,6 +190,7 @@
|
||||||
post: {
|
post: {
|
||||||
shellOffset,
|
shellOffset,
|
||||||
fillOffset,
|
fillOffset,
|
||||||
|
clipOffset,
|
||||||
lineWidth,
|
lineWidth,
|
||||||
vaseMode,
|
vaseMode,
|
||||||
isSynth,
|
isSynth,
|
||||||
|
|
@ -279,13 +277,8 @@
|
||||||
if (Math.abs(Math.abs(pslice.z - slice.z) - gap) > 0.1) {
|
if (Math.abs(Math.abs(pslice.z - slice.z) - gap) > 0.1) {
|
||||||
continue;
|
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 = [];
|
let ntops = [];
|
||||||
POLY.subtract(tops, ptops, ntops, null, slice.z, 0);
|
POLY.subtract(tops, pslice.clips, ntops, null, slice.z, 0);
|
||||||
tops = ntops;
|
tops = ntops;
|
||||||
}
|
}
|
||||||
// trim to group's shadow if not in belt mode
|
// trim to group's shadow if not in belt mode
|
||||||
|
|
@ -303,7 +296,6 @@
|
||||||
|
|
||||||
// calculate % complete and call onupdate()
|
// calculate % complete and call onupdate()
|
||||||
function doupdate(index, from, to, msg) {
|
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);
|
trackupdate(index / slices.length, from, to, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1181,12 +1173,6 @@
|
||||||
tops = slice.topPolys(),
|
tops = slice.topPolys(),
|
||||||
trimTo = tops;
|
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)),
|
let traces = POLY.flatten(slice.topShells().clone(true)),
|
||||||
fill = slice.topFill(),
|
fill = slice.topFill(),
|
||||||
points = [],
|
points = [],
|
||||||
|
|
@ -1311,12 +1297,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {number} linewidth
|
|
||||||
* @param {number} angle
|
|
||||||
* @param {number} density
|
|
||||||
* @param {number} offset
|
|
||||||
*/
|
|
||||||
function doSupportFill(promises, slice, linewidth, density, minArea) {
|
function doSupportFill(promises, slice, linewidth, density, minArea) {
|
||||||
let supports = slice.supports,
|
let supports = slice.supports,
|
||||||
nsB = [],
|
nsB = [],
|
||||||
|
|
@ -1329,14 +1309,14 @@
|
||||||
supports = POLY.union(supports, undefined, true);
|
supports = POLY.union(supports, undefined, true);
|
||||||
|
|
||||||
// trim to clip offsets
|
// trim to clip offsets
|
||||||
if (slice.offsets) {
|
if (slice.clips) {
|
||||||
POLY.subtract(supports, slice.offsets, nsB, null, slice.z, min);
|
POLY.subtract(supports, slice.clips, nsB, null, slice.z, min);
|
||||||
}
|
}
|
||||||
supports = nsB;
|
supports = nsB;
|
||||||
|
|
||||||
// also trim to lower offsets, if they exist
|
// also trim to lower offsets, if they exist
|
||||||
if (slice.down && slice.down.offsets) {
|
if (slice.down && slice.down.clips) {
|
||||||
POLY.subtract(nsB, slice.down.offsets, nsC, null, slice.z, min);
|
POLY.subtract(nsB, slice.down.clips, nsC, null, slice.z, min);
|
||||||
supports = nsC;
|
supports = nsC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,11 +43,12 @@ Uint32 readPoly(Path &path, Uint32 pos) {
|
||||||
Uint16 points = ls->length;
|
Uint16 points = ls->length;
|
||||||
// if (debug) polygon(points, 0);
|
// if (debug) polygon(points, 0);
|
||||||
pos += 2;
|
pos += 2;
|
||||||
while (points-- > 0) {
|
while (points > 0) {
|
||||||
struct point32 *ip = (struct point32 *)(mem + pos);
|
struct point32 *ip = (struct point32 *)(mem + pos);
|
||||||
pos += 8;
|
pos += 8;
|
||||||
path << IntPoint(ip->x, ip->y);
|
path << IntPoint(ip->x, ip->y);
|
||||||
// if (debug) point(ip->x, ip->y);
|
// if (debug) point(ip->x, ip->y);
|
||||||
|
points--;
|
||||||
}
|
}
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
@ -55,8 +56,9 @@ Uint32 readPoly(Path &path, Uint32 pos) {
|
||||||
Uint32 readPolys(Paths &paths, Uint32 pos, Uint32 count) {
|
Uint32 readPolys(Paths &paths, Uint32 pos, Uint32 count) {
|
||||||
Uint32 poly = 0;
|
Uint32 poly = 0;
|
||||||
// if (debug) abc(poly, count, pos);
|
// if (debug) abc(poly, count, pos);
|
||||||
while (count-- > 0) {
|
while (count > 0) {
|
||||||
pos = readPoly(paths[poly++], pos);
|
pos = readPoly(paths[poly++], pos);
|
||||||
|
count--;
|
||||||
}
|
}
|
||||||
// if (debug) abc(poly, count, pos);
|
// if (debug) abc(poly, count, pos);
|
||||||
return pos;
|
return pos;
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Reference in a new issue