diff --git a/__test__/Polyline/PointInPolyline.test.ts b/__test__/Polyline/PointInPolyline.test.ts index a31786ee5..a20f06791 100644 --- a/__test__/Polyline/PointInPolyline.test.ts +++ b/__test__/Polyline/PointInPolyline.test.ts @@ -164,4 +164,19 @@ describe("", () => expect(pl.PtInCurve(p)).toBeFalsy(); }); + + test('精度过低导致的错误', () => + { + let f = new CADFile(); + f.Data = + [1, ["Polyline", 1, 1, 18237, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.7938671363300003, 0.39666461398798525, 0, 1], 2, 5, [12.414545456418505, 8.796498405316765], 0, [12.015990240675425, 8.743859037199755], 0, [12.23362472371057, 8.552710046188702], 0, [12.233990240675425, 8.552758322014249], 0, [12.414545456418505, 8.796498405316765], 0, false]] + + let p = new Vector3().fromArray([13.027857377005425, 8.947146562082409, 0]); + + f.Read(); + let pl = f.ReadObject() as Polyline; + + pl.PtInCurve(p);//? + }); + }) diff --git a/src/DatabaseServices/PointInPolyline.ts b/src/DatabaseServices/PointInPolyline.ts index b407e663a..06f7ab7cf 100644 --- a/src/DatabaseServices/PointInPolyline.ts +++ b/src/DatabaseServices/PointInPolyline.ts @@ -84,13 +84,13 @@ export function IsPointInPolyLine(pl: Polyline, pt: Vector3): boolean if (equal(pti, cu.StartPoint)) { let der = cu.GetFistDeriv(0); - if (der.x < -1e-3) //左边+ 右边0 + if (der.x < -1e-4) //左边+ 右边0 crossings++; } else if (equal(pti, cu.EndPoint)) { let der = cu.GetFistDeriv(1); - if (der.x > 1e-3) //左边+ 右边0 + if (der.x > 1e-4) //左边+ 右边0 crossings++; } else