..
This commit is contained in:
parent
9689bfcc18
commit
62a385e4c9
1 changed files with 2649 additions and 809 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { buildGeometry, normalizeAngle, signedArea } from './geometry';
|
||||
import { isSkirtingCut } from './cut-list';
|
||||
import { cutLength } from './format';
|
||||
import type {
|
||||
Issue,
|
||||
Point,
|
||||
|
|
@ -86,14 +87,19 @@ function endCuts(piece: SkirtingPiece) {
|
|||
return Number(Math.abs(piece.leftMitre) > EPS) + Number(Math.abs(piece.rightMitre) > EPS);
|
||||
}
|
||||
|
||||
function blankLength(piece: SkirtingPiece, available: number) {
|
||||
return Math.abs(available - piece.length) <= EPS ? available : cutLength(piece.length);
|
||||
}
|
||||
|
||||
function requiredCuts(piece: SkirtingPiece, available: number) {
|
||||
return endCuts(piece) + Number(Math.abs(available - piece.length) > EPS);
|
||||
return endCuts(piece) + Number(Math.abs(available - blankLength(piece, available)) > EPS);
|
||||
}
|
||||
|
||||
function consumedLength(piece: SkirtingPiece, available: number, kerf: number) {
|
||||
// Cut a square blank, then bevel within its longest-point envelope. This leaves
|
||||
// a square reusable offcut. Bevel kerfs remove material inside the blank.
|
||||
return Math.min(available, piece.length + (Math.abs(available - piece.length) <= EPS ? 0 : kerf));
|
||||
const length = blankLength(piece, available);
|
||||
return Math.min(available, length + (Math.abs(available - length) <= EPS ? 0 : kerf));
|
||||
}
|
||||
|
||||
function makePiece(
|
||||
|
|
@ -141,7 +147,7 @@ function shortestEdge(piece: SkirtingPiece) {
|
|||
|
||||
function fits(piece: SkirtingPiece, available: number) {
|
||||
// The final saw pass may extend beyond the stock's tail.
|
||||
return piece.length <= available + EPS;
|
||||
return blankLength(piece, available) <= available + EPS;
|
||||
}
|
||||
|
||||
/** Zero means that no number of pieces can satisfy the end allowances. */
|
||||
|
|
|
|||
Loading…
Reference in a new issue