add surface output
This commit is contained in:
parent
7c99dfc5fc
commit
8c4f4198be
1 changed files with 28 additions and 5 deletions
|
|
@ -40,6 +40,7 @@ class OpArea extends CamOp {
|
||||||
// selected area polygons: surfaces and edges
|
// selected area polygons: surfaces and edges
|
||||||
let { devel, edgeangle } = settings.controller;
|
let { devel, edgeangle } = settings.controller;
|
||||||
let stack = [];
|
let stack = [];
|
||||||
|
let surfaces = this.surfaces = [];
|
||||||
let areas = this.areas = [ stack ];
|
let areas = this.areas = [ stack ];
|
||||||
let polys = [];
|
let polys = [];
|
||||||
|
|
||||||
|
|
@ -199,6 +200,7 @@ class OpArea extends CamOp {
|
||||||
|
|
||||||
let resolution = tolerance || 0.05;
|
let resolution = tolerance || 0.05;
|
||||||
let raster = await self.get_raster_gpu({ mode: "tracing", resolution });
|
let raster = await self.get_raster_gpu({ mode: "tracing", resolution });
|
||||||
|
let surface = [];
|
||||||
let paths = [];
|
let paths = [];
|
||||||
|
|
||||||
// prepare paths
|
// prepare paths
|
||||||
|
|
@ -260,10 +262,14 @@ class OpArea extends CamOp {
|
||||||
// convert terrain raster output back to open polylines
|
// convert terrain raster output back to open polylines
|
||||||
for (let path of output.paths) {
|
for (let path of output.paths) {
|
||||||
path = newPolygon().fromArray([1, ...path]);
|
path = newPolygon().fromArray([1, ...path]);
|
||||||
|
surface.push(path);
|
||||||
newLayer().output()
|
newLayer().output()
|
||||||
.setLayer("linear", { line: 0x00ff00 }, false)
|
.setLayer("linear", { line: 0x00ff00 }, false)
|
||||||
.addPolys([ path ]);
|
.addPolys([ path ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// output this surface
|
||||||
|
surfaces.push(surface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -271,16 +277,35 @@ class OpArea extends CamOp {
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare(ops, progress) {
|
prepare(ops, progress) {
|
||||||
let { op, state, areas } = this;
|
let { op, state, areas, surfaces } = this;
|
||||||
let { getPrintPoint , pocket, setTool, setSpindle } = ops;
|
let { getPrintPoint, newLayer, pocket, polyEmit, setTool, setSpindle, tip2tipEmit } = ops;
|
||||||
let { process } = state.settings;
|
let { process } = state.settings;
|
||||||
|
|
||||||
setTool(op.tool, op.rate);
|
setTool(op.tool, op.rate);
|
||||||
setSpindle(op.spindle);
|
setSpindle(op.spindle);
|
||||||
|
|
||||||
|
let printPoint = getPrintPoint();
|
||||||
|
|
||||||
|
// process surface paths
|
||||||
|
for (let surface of surfaces) {
|
||||||
|
let array = surface.map(poly => { return {
|
||||||
|
el: poly,
|
||||||
|
first: poly.first(),
|
||||||
|
last: poly.last()
|
||||||
|
} });
|
||||||
|
tip2tipEmit(array, printPoint, (next, first, count) => {
|
||||||
|
printPoint = polyEmit(next.el, 0, 1, printPoint, {});
|
||||||
|
newLayer();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// skip areas when processing surfaces
|
||||||
|
if (surfaces.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// process areas as pockets
|
// process areas as pockets
|
||||||
while (areas?.length) {
|
while (areas?.length) {
|
||||||
let printPoint = getPrintPoint();
|
|
||||||
let min = {
|
let min = {
|
||||||
dist: Infinity,
|
dist: Infinity,
|
||||||
area: undefined
|
area: undefined
|
||||||
|
|
@ -302,7 +327,6 @@ class OpArea extends CamOp {
|
||||||
// if we have a next-closest top poly, pocket that
|
// if we have a next-closest top poly, pocket that
|
||||||
if (min.area) {
|
if (min.area) {
|
||||||
min.area.used = true;
|
min.area.used = true;
|
||||||
console.log({ area: min.area });
|
|
||||||
pocket({
|
pocket({
|
||||||
cutdir: op.ov_conv,
|
cutdir: op.ov_conv,
|
||||||
depthFirst: process.camDepthFirst,
|
depthFirst: process.camDepthFirst,
|
||||||
|
|
@ -314,7 +338,6 @@ class OpArea extends CamOp {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue