From 3bed092594b2ed740b8106625b9f1dc3d84bd2a0 Mon Sep 17 00:00:00 2001 From: ChenX Date: Wed, 15 Apr 2020 09:57:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D:=E5=81=8F=E7=A7=BB=E7=AE=97?= =?UTF-8?q?=E6=B3=95=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __test__/Polyline/offsetbug.test.ts | 9 +++++++++ src/GraphicsSystem/OffsetPolyline.ts | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/__test__/Polyline/offsetbug.test.ts b/__test__/Polyline/offsetbug.test.ts index 2c6c34c39..706d17edf 100644 --- a/__test__/Polyline/offsetbug.test.ts +++ b/__test__/Polyline/offsetbug.test.ts @@ -100,3 +100,12 @@ test("补圆弧错误02", () => }); +test('方向判断错误', () => +{ + let plD = { "file": [1, "Polyline", 8, 2, 100, false, 1, 1, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 905.8692798363977, -201.17289418446444, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 46.0379459990736, -2.9086509590968035, 0, 1], 0, 2, 4, [339.450877196156, 791.6288697108841], 1.00000000428954, [336.55690134418086, 796.884809566722], 0.5932441531761995, [337.21656343856364, 602.2844235796431], 0.9999999957104566, [340.0748399325664, 607.5598624698049], -0.5932441531761995, true], "basePt": { "x": 108.6124401913877, "y": 77.99043062200967, "z": 0 } }; + let f = new CADFiler(plD.file); + f.Read(); + let pl = f.ReadObject() as Polyline; + let cus = pl.GetOffsetCurves(-6); + expect(cus.length).toBe(0); +}); diff --git a/src/GraphicsSystem/OffsetPolyline.ts b/src/GraphicsSystem/OffsetPolyline.ts index e0e01b279..5e69a88a8 100644 --- a/src/GraphicsSystem/OffsetPolyline.ts +++ b/src/GraphicsSystem/OffsetPolyline.ts @@ -681,7 +681,7 @@ export class OffsetPolyline { let c = this._SubCurves[i]; let cp = c.GetClosestPointTo(pt, false); - if (equalv3(cp, pt)) return 0; + if (equalv3(cp, pt, 1e-5)) return 0; let dist = cp.distanceToSquared(pt); if (dist < minDist)