diff --git a/__test__/Booloperate/BoardCutting.test.ts b/__test__/Booloperate/BoardCutting.test.ts index 63d0f9071..e08589561 100644 --- a/__test__/Booloperate/BoardCutting.test.ts +++ b/__test__/Booloperate/BoardCutting.test.ts @@ -147,3 +147,17 @@ test("板件分裂后槽需要在正确的位置", () => expect(b.Volume).toMatchNumberSnapshot(); } }); + +test('布尔运算导致的切割错误', () => +{ + let d = + { "file": [2, "Board", 8, 2, 101, false, 1, 11, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 145.70588235294053, 55.24369747899152, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 145.70588235294053, 55.24369747899152, 0, 1], 0, 3, 2000, 600, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [0, 0], 0, [600, 0], 0, [600, 2000], 0, [0, 2000], 0, true, 2, 3, 2000, 9, 5, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [0, 0], 0, [9, 0], 0, [9, 2000], 0, [0, 2000], 0, true, 0, 3, 6, 1, 1, 0, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 158.70588235294053, 628.2436974789915, 0, 1], 3, 18, 588.3901659112175, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [0, 0], 0, [588.3901659112175, 0], 0, [588.3901659112175, 18], 0, [0, 18], 0, true, 0, 3, 0, 0, 0, 0, 0, [0, 0.9659258262890683, -0.25881904510252074, 0, 0, 0.25881904510252074, 0.9659258262890683, 0, 1, 0, 0, 0, 145.7058823529403, 55.24369747899152, 990.9999999999998, 1], 3, 0, 0, 0, 0, 0, 10, 1, "左侧板", "主卧", "下柜", "", "", "", 0, 0, "测试", 2, 0, "1", "1", "1", "1", "", "", "", 4, "测试", "测试", "测试", "测试", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, "Board", 8, 2, 100, false, 1, 2, 0, [0, 0.9659258262890683, -0.25881904510252074, 0, -1, 0, 0, 0, 0, 0.25881904510252074, 0.9659258262890683, 0, 1327.7058823529405, 55.24369747899152, 990.9999999999998, 1], 0, 0, true, [1, 0, 0, 0, 0, 0.9659258262890683, -0.25881904510252074, 0, 0, 0.25881904510252074, 0.9659258262890683, 0, 163.70588235294053, -201.24597621760648, 33.76750614753291, 1], 0, 3, 1364, 588.3901659112173, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [0, 0], 0, [588.3901659112173, 0], 0, [588.3901659112173, 1364], 0, [0, 1364], 0, true, 0, 3, 0, 0, 0, 0, 0, 10, 0, "层板", "主卧", "下柜", "", "", "", 0, 1, "测试", 2, 0, "1", "1", "1", "1", "", "", "", 4, "测试", "测试", "测试", "测试", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0], "basePt": { "x": -36.294117647059466, "y": 55.24369747899152, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] }; + + let [br0, br1] = LoadBoardsFromFileData(d) as Board[]; + let splitBrs = CuttingBoard(br0, [br1]); + splitBrs.push(br0); + for (let b of splitBrs) + { + expect(b.Volume).toMatchNumberSnapshot(); + } +}); diff --git a/__test__/Booloperate/__snapshots__/BoardCutting.test.ts.snap b/__test__/Booloperate/__snapshots__/BoardCutting.test.ts.snap index 58001a939..cfbe03204 100644 --- a/__test__/Booloperate/__snapshots__/BoardCutting.test.ts.snap +++ b/__test__/Booloperate/__snapshots__/BoardCutting.test.ts.snap @@ -12,6 +12,8 @@ exports[`切圆环 2`] = `"6547348.76281"`; exports[`切圆环 3`] = `"15351393.37905"`; +exports[`布尔运算导致的切割错误 1`] = `"21319361.58624"`; + exports[`斜切割 1`] = `"7492938.32873"`; exports[`斜切割 2`] = `"5198741.81897"`; diff --git a/src/DatabaseServices/Contour.ts b/src/DatabaseServices/Contour.ts index 06663456f..1ed720e75 100644 --- a/src/DatabaseServices/Contour.ts +++ b/src/DatabaseServices/Contour.ts @@ -606,8 +606,9 @@ function fastCurveInCurve(sourceCu: Polyline | Circle, targetCu: Curve) return sourceCu.PtInCurve(targetCu.GetPointAtParam(targetCu.EndParam * 0.5)); } +//当交点小于等于1时 function fastCurveInCurve2(sourceCu: Polyline | Circle, targetCu: Curve) { - return sourceCu.PtInCurve(targetCu.StartPoint) && + return sourceCu.PtInCurve(targetCu.StartPoint) || sourceCu.PtInCurve(targetCu.GetPointAtParam(targetCu.EndParam * 0.5)); }