finish slice, add prepare skeleton
This commit is contained in:
parent
13ce7ac0fe
commit
c13d6eaba4
1 changed files with 70 additions and 25 deletions
|
|
@ -1,9 +1,10 @@
|
|||
|
||||
import { arcToPath } from "../../../geo/paths.js";
|
||||
import { newPolygon } from "../../../geo/polygon.js";
|
||||
import { CAM } from "./driver-be.js"
|
||||
import { CamOp } from "./op.js";
|
||||
|
||||
import { Tool } from "./tool.js";
|
||||
import { cylinder_poly_find } from "./slice.js";
|
||||
import { newPoint } from "../../../geo/point.js";
|
||||
import { newSlice } from "../../core/slice.js";
|
||||
|
||||
export class OpHelical extends CamOp {
|
||||
constructor(state, op) {
|
||||
|
|
@ -24,31 +25,30 @@ export class OpHelical extends CamOp {
|
|||
down,
|
||||
thru,
|
||||
} = op;
|
||||
let {stock} = settings
|
||||
|
||||
let tool = new CAM.Tool(settings, op.tool),
|
||||
|
||||
|
||||
let tool = new Tool(settings, op.tool),
|
||||
toolDiam = tool.fluteDiameter(),
|
||||
sliceOut = (this.sliceOut = []),
|
||||
startAngle = forceStartAng ? startAng : 0;
|
||||
|
||||
updateToolDiams(toolDiam);
|
||||
|
||||
console.log(cylinders, cylinders[widget.id]);
|
||||
let faces = cylinders[widget.id];
|
||||
|
||||
if (faces.faces) faces = faces.faces;
|
||||
console.log(faces);
|
||||
|
||||
let polys = [];
|
||||
|
||||
//iterate over selected faces
|
||||
for (let face of faces) {
|
||||
//get poly info for the cylinder
|
||||
let { zmin, zmax, diam, center, interior, faces } =
|
||||
CAM.cylinder_poly_find(widget, face);
|
||||
|
||||
console.log({ zmin, zmax, diam, center, interior });
|
||||
|
||||
let { zmin, zmax, diam, center, interior, faces } = cylinder_poly_find(
|
||||
widget,
|
||||
face
|
||||
);
|
||||
// console.log({ zmin, zmax, diam, center, interior });
|
||||
let radius = diam >> 1;
|
||||
zmax = fromTop ? stock.z: zmax;
|
||||
|
||||
let radAdd,
|
||||
zBottom = zmin - thru,
|
||||
|
|
@ -59,20 +59,20 @@ export class OpHelical extends CamOp {
|
|||
if (offOver) {
|
||||
//apply offset override
|
||||
if (offset == "auto") {
|
||||
radAdd = (interior ? -offOver : offOver) * 2;
|
||||
radAdd = interior ? -offOver : offOver;
|
||||
} else if (offset == "inside") {
|
||||
radAdd = -offOver * 2;
|
||||
radAdd = -offOver;
|
||||
} else if (offset == "outside") {
|
||||
radAdd = offOver * 2;
|
||||
radAdd = offOver;
|
||||
}
|
||||
} else {
|
||||
//otherwise, calculate based on offset type
|
||||
if (offset == "auto") {
|
||||
radAdd = (interior ? -toolDiam : toolDiam) * 2;
|
||||
radAdd = (interior ? -toolDiam : toolDiam) / 2;
|
||||
} else if (offset == "inside") {
|
||||
radAdd = -toolDiam * 2;
|
||||
radAdd = -toolDiam / 2;
|
||||
} else if (offset == "outside") {
|
||||
radAdd = toolDiam * 2;
|
||||
radAdd = toolDiam / 2;
|
||||
}
|
||||
}
|
||||
console.log({ radius, radAdd });
|
||||
|
|
@ -94,17 +94,15 @@ export class OpHelical extends CamOp {
|
|||
let bottom = currentZ - down;
|
||||
if (bottom > zBottom) {
|
||||
//if not at the bottom, do a whole helix
|
||||
|
||||
let start = startPoint.setZ(currentZ),
|
||||
end = startPoint.clone().setZ(bottom);
|
||||
console.log(currentZ, bottom, [start.z, end.z]);
|
||||
|
||||
// console.log(currentZ, bottom, [start.z, end.z]);
|
||||
let path = arcToPath(start, end, numSegs, {
|
||||
clockwise,
|
||||
radius,
|
||||
center,
|
||||
});
|
||||
console.log({ path, start, end, radius, center });
|
||||
// console.log({ path, start, end, radius, center });
|
||||
poly.addPoints(path);
|
||||
} else {
|
||||
//if at the bottom, do a partial helix
|
||||
|
|
@ -163,5 +161,52 @@ export class OpHelical extends CamOp {
|
|||
sliceOut.push(slice);
|
||||
}
|
||||
|
||||
async prepare(ops, progress) {}
|
||||
async prepare(ops, progress) {
|
||||
let { op, state } = this;
|
||||
let { settings, widget, addSlices, updateToolDiams } = state;
|
||||
let {
|
||||
setTool,
|
||||
setSpindle,
|
||||
polyEmit,
|
||||
camOut,
|
||||
setPrintPoint,
|
||||
getPrintPoint,
|
||||
} = ops;
|
||||
let { tool, spindle, rate, feed } = op;
|
||||
setTool(tool, feed, rate);
|
||||
setSpindle(spindle);
|
||||
|
||||
let [polys] = this.sliceOut.map((s) => s.camLines);
|
||||
|
||||
let pp = getPrintPoint();
|
||||
|
||||
console.log(polys)
|
||||
|
||||
polys = polys.slice();
|
||||
for (;;) {
|
||||
let closestDist = Infinity,
|
||||
closestI,
|
||||
closest = null,
|
||||
dist,
|
||||
poly;
|
||||
|
||||
for (let i = 0; i < polys.length; i++) {
|
||||
if (!polys[i]) continue;
|
||||
if ((dist = polys[i].first().distTo2D(pp)) < closestDist) {
|
||||
closestDist = dist;
|
||||
closest = polys[i];
|
||||
closestI = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (!closest) break;
|
||||
poly = polys[closestI]
|
||||
polys[closestI] = null;
|
||||
//emit
|
||||
|
||||
pp = polyEmit(poly,0,1,poly.points[0])
|
||||
}
|
||||
|
||||
setPrintPoint(pp);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue