From a5e70aab01cea64950ec2292057d78115bcd6994 Mon Sep 17 00:00:00 2001 From: ChenX Date: Sat, 21 Jul 2018 17:20:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B2=E7=BA=BF=E5=90=88=E5=B9=B6=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E7=9A=84=E5=A4=9A=E6=AE=B5=E7=BA=BF=E5=90=88=E5=B9=B6?= =?UTF-8?q?=E9=94=99=E8=AF=AF.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __test__/Polyline/__snapshots__/offset.test.ts.snap | 4 ++++ __test__/Polyline/offset.test.ts | 9 +++++++++ src/GraphicsSystem/OffsetPolyline.ts | 4 +++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/__test__/Polyline/__snapshots__/offset.test.ts.snap b/__test__/Polyline/__snapshots__/offset.test.ts.snap index 0f505651d..63d1e6c6f 100644 --- a/__test__/Polyline/__snapshots__/offset.test.ts.snap +++ b/__test__/Polyline/__snapshots__/offset.test.ts.snap @@ -64,6 +64,10 @@ exports[`复杂圆盘选点 9`] = `1`; exports[`复杂圆盘选点 10`] = `206.82332282556683`; +exports[`多段线因为合并问题造成的错误 1`] = `1`; + +exports[`多段线因为合并问题造成的错误 2`] = `2210.3833040297095`; + exports[`多段线存在0长度线段导致偏移错误 1`] = `1`; exports[`多段线存在0长度线段导致偏移错误 2`] = `81933.70549460054`; diff --git a/__test__/Polyline/offset.test.ts b/__test__/Polyline/offset.test.ts index 7760390e7..0a344c1aa 100644 --- a/__test__/Polyline/offset.test.ts +++ b/__test__/Polyline/offset.test.ts @@ -900,3 +900,12 @@ test('纯圆生成的多段线偏移', () => testOffset(pl, 100); testOffset(pl, -100); }); + +test('多段线因为合并问题造成的错误', () => +{ + let pl = loadFile( + [1, ["Polyline", 1, 1, 38, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 10, [560.4622946261899, 280.3468208092485], 0, [273.1213872832369, 280.3468208092485], 0, [273.1213872832369, 70.80924855491334], 0, [273.1213872832369, 70.80924855491334], 0, [520.5860801571987, 70.80924855491334], 0.45552774411272906, [773.2934581245079, 9.947706891888771], 1.0105662598284268, [843.111615774608, 120.72879526430421], 0.42745194242823337, [695.3090834219281, 321.1478937918483], 3.4733857741050023, [602.1148370593586, 307.0986147536708], 0.07222028753966563, [560.4622946261899, 280.3468208092485], 0, false]] + )[0]; + + testOffset(pl, 37.8831); +}); diff --git a/src/GraphicsSystem/OffsetPolyline.ts b/src/GraphicsSystem/OffsetPolyline.ts index 27a54f0c3..a3637d143 100644 --- a/src/GraphicsSystem/OffsetPolyline.ts +++ b/src/GraphicsSystem/OffsetPolyline.ts @@ -128,7 +128,9 @@ export class PolyOffsetUtil //有共线部分才允许合并. if (c2.PtOnCurve2(c1.StartPoint) || c2.PtOnCurve2(c1.EndPoint) - || c1.PtOnCurve2(c2.StartPoint) || c1.PtOnCurve2(c2.EndPoint)) + || c1.PtOnCurve2(c2.StartPoint) || c1.PtOnCurve2(c2.EndPoint) + || (c1.PtOnCurve(c2.StartPoint) && c1.PtOnCurve(c2.EndPoint)) + ) if (c1.Join(c2) === Status.True) { this.m_RetCurves.splice(j, 1);