Merge pull request #417 from GridSpace/rough-cut-buxfix-4.3

Rough cut buxfix 4.3
This commit is contained in:
Josiah Hamm 2025-08-19 16:24:51 -06:00 • committed by GitHub
commit 736559acff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 4 deletions

View file

@ -302,7 +302,7 @@ class OpRough extends CamOp {
// set winding specified in output // set winding specified in output
POLY.setWinding(level, cutdir, false); POLY.setWinding(level, cutdir, false);
poly2polyEmit(level, printPoint, (poly, index, count) => { poly2polyEmit(level, printPoint, (poly, index, count) => {
printPoint = polyEmit(poly, index, count, printPoint); printPoint = polyEmit(poly, index, count, printPoint, {cutFromLast: true});
}); });
newLayer(); newLayer();
} }

View file

@ -740,10 +740,15 @@ export function prepEach(widget, settings, print, firstPoint, update) {
* @param {number} index - unused * @param {number} index - unused
* @param {number} count - 1 to set engage factor * @param {number} count - 1 to set engage factor
* @param {Point} fromPoint - the point to rapid move from * @param {Point} fromPoint - the point to rapid move from
* @param {Object} camOutOpts - optional parameters to pass to camOut * @param {boolean} ops.cutFromLast - whether to emit a 1 when moving from last point. Defaults to false
* @returns {Point} - the last point of the polygon * @returns {Point} - the last point of the polygon
*/ */
function polyEmit(poly, index, count, fromPoint) { function polyEmit(poly, index, count, fromPoint,ops) {
let {
cutFromLast,
} = ops ?? {
cutFromLast: false
};
let arcQ = [], let arcQ = [],
arcMax = Infinity, // no max arc radius arcMax = Infinity, // no max arc radius
lineTolerance = 0.001, // do not consider points under 0.001mm for arcs lineTolerance = 0.001, // do not consider points under 0.001mm for arcs
@ -779,7 +784,8 @@ export function prepEach(widget, settings, print, firstPoint, update) {
// if(offset == 0) console.log("forEachPoint",point,pidx,points) // if(offset == 0) console.log("forEachPoint",point,pidx,points)
// console.log({pointA, pointB, indexA, indexB,startIndex}) // console.log({pointA, pointB, indexA, indexB,startIndex})
if (indexA == startIndex) { if (indexA == startIndex) {
camOut(pointA.clone(), 0, { factor: engageFactor }); //if cutFromLast is true, emit a 1 for a cutting move
camOut(pointA.clone(), cutFromLast ? 1 : 0, { factor: engageFactor });
// if first point, move to and call export function // if first point, move to and call export function
if (arcEnabled) arcQ.push(pointA); if (arcEnabled) arcQ.push(pointA);
} }