diff --git a/__test__/Booloperate/more_sub.test.ts b/__test__/Booloperate/more_sub.test.ts new file mode 100644 index 000000000..fe8588f68 --- /dev/null +++ b/__test__/Booloperate/more_sub.test.ts @@ -0,0 +1,18 @@ +import { Polyline } from "../../src/api"; +import { Contour } from "../../src/DatabaseServices/Contour"; +import { LoadEntityFromFileData } from "../Utils/LoadEntity.util"; + +test('多个布尔错误', () => +{ + let d = + [2, "Polyline", 8, 2, 0, false, 0, 1, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 142, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 8, [942, -142], 0, [942, 202], 0, [430, 202], 0, [430.0000000000002, 18], 0, [430.0000000000002, 18], 0, [430.0000000000002, 0], 0, [0, 0], 0, [0, -142], 0, true, "Polyline", 8, 2, 0, false, 0, 2, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 142, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 142, 0, 1], 0, 2, 4, [0, 0], 0, [698, 0], 0, [698, 18], 0, [0, 18], 0, true]; + + let pls = LoadEntityFromFileData(d) as Polyline[]; + + let cons = pls.map(pl => Contour.CreateContour(pl)); + + let res = cons[0].GetSubtractListByMoreTargets(cons.slice(1)); + + expect(res.outlines.length).toBe(1); + expect(res.holes.length).toBe(0); +}); diff --git a/src/DatabaseServices/Contour.ts b/src/DatabaseServices/Contour.ts index eccebf47a..3b76d0d56 100644 --- a/src/DatabaseServices/Contour.ts +++ b/src/DatabaseServices/Contour.ts @@ -603,12 +603,12 @@ function fastEqualCurve(c1: Curve, c2: Curve, tolerance = 1e-3) //也许有一天这个中点算法需要改一下, 使用.MidPoint比较稳妥 function fastCurveInCurve(sourceCu: Polyline | Circle, targetCu: Curve) { - return sourceCu.PtInCurve(targetCu.GetPointAtParam(targetCu.EndParam * 0.5)); + return sourceCu.PtInCurve(targetCu.Midpoint); } //当交点小于等于1时 export function fastCurveInCurve2(sourceCu: Polyline | Circle, targetCu: Curve) { return sourceCu.PtInCurve(targetCu.StartPoint) || - sourceCu.PtInCurve(targetCu.GetPointAtParam(targetCu.EndParam * 0.5)); + sourceCu.PtInCurve(targetCu.Midpoint); }