reviewed
This commit is contained in:
parent
62a385e4c9
commit
7959fe85cc
29 changed files with 1679 additions and 498 deletions
|
|
@ -6,7 +6,7 @@ import { planSkirting } from '../src/lib/skirting';
|
|||
import { skirtingPolygon } from '../src/lib/skirting-polygon';
|
||||
import type { Point, Room } from '../src/lib/types';
|
||||
|
||||
const settings = { stockLengths: [2400], thickness: 18, minLength: 200, kerf: 3 };
|
||||
const settings = { stockLength: 2400, thickness: 18, minLength: 200, kerf: 3 };
|
||||
|
||||
function overlap(a: Point[], b: Point[]): number {
|
||||
const clipper = new ClipperLib.Clipper();
|
||||
|
|
@ -56,10 +56,14 @@ function expectCompleteSkirting(room: Room) {
|
|||
const next = polygon[(index + 1) % polygon.length];
|
||||
return sum + Math.hypot(next.x - point.x, next.y - point.y) / 1000;
|
||||
}, 0);
|
||||
expect(polygon[0].x).toBeCloseTo(plan.pieces[i].start.x);
|
||||
expect(polygon[0].y).toBeCloseTo(plan.pieces[i].start.y);
|
||||
expect(polygon[1].x).toBeCloseTo(plan.pieces[i].end.x);
|
||||
expect(polygon[1].y).toBeCloseTo(plan.pieces[i].end.y);
|
||||
const piece = plan.pieces[i];
|
||||
const installed = piece.installedTemplate!;
|
||||
expect(Math.hypot(polygon[0].x - piece.start.x, polygon[0].y - piece.start.y)).toBeCloseTo(
|
||||
Math.abs(installed[0].x - piece.template![0].x),
|
||||
);
|
||||
expect(Math.hypot(polygon[1].x - piece.end.x, polygon[1].y - piece.end.y)).toBeCloseTo(
|
||||
Math.abs(installed[1].x - piece.template![1].x),
|
||||
);
|
||||
expect(
|
||||
Math.abs(overlap(polygon, geometry.vertices) - Math.abs(signedArea(polygon))),
|
||||
).toBeLessThan(clippingTolerance);
|
||||
|
|
@ -73,7 +77,7 @@ function expectCompleteSkirting(room: Room) {
|
|||
|
||||
describe('installed skirting polygons', () => {
|
||||
it.each([1, -1])(
|
||||
'covers a rectangle including uncut stock without overlapping butt joints (orientation %i)',
|
||||
'covers a rectangle including uncut stock without overlapping coped bodies (orientation %i)',
|
||||
(orientation) => {
|
||||
const room = rectangle();
|
||||
room.walls.forEach((wall) => {
|
||||
|
|
@ -93,19 +97,29 @@ describe('installed skirting polygons', () => {
|
|||
});
|
||||
const plan = expectCompleteSkirting(room);
|
||||
expect(
|
||||
plan.pieces.some(
|
||||
(piece) => piece.leftType === 'external' && piece.rightType === 'external',
|
||||
plan.pieces.reduce(
|
||||
(sum, piece) =>
|
||||
sum + Number(piece.leftType === 'external') + Number(piece.rightType === 'external'),
|
||||
0,
|
||||
),
|
||||
).toBe(true);
|
||||
).toBe(4);
|
||||
},
|
||||
);
|
||||
|
||||
it('matches the room boundary at angled internal butt joints', () => {
|
||||
expectCompleteSkirting({
|
||||
id: 'triangle',
|
||||
name: 'Triangle',
|
||||
direction: 0,
|
||||
walls: [0, 1, 2].map((index) => ({ id: `w${index}`, length: 3000, turn: 120, doors: [] })),
|
||||
});
|
||||
});
|
||||
it.each([60, -60, 120, -120])(
|
||||
'matches the room boundary at angled coped internal joints (%i degrees)',
|
||||
(turn) => {
|
||||
expectCompleteSkirting({
|
||||
id: 'triangle',
|
||||
name: 'Triangle',
|
||||
direction: 0,
|
||||
walls: Array.from({ length: 360 / Math.abs(turn) }, (_, index) => ({
|
||||
id: `w${index}`,
|
||||
length: 3000,
|
||||
turn,
|
||||
doors: [],
|
||||
})),
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue