From df1960f17ec1d9bffa543f51adf4290ada8bbdf1 Mon Sep 17 00:00:00 2001 From: Zoe Date: Wed, 20 Jun 2018 14:43:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9B=B4=E7=BA=BF=E5=9C=86?= =?UTF-8?q?=E5=BC=A7=E8=BF=9E=E6=8E=A5=E6=96=B9=E5=BC=8F,=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E7=9B=B4=E7=BA=BF=E5=92=8C=E5=9C=86=E5=BC=A7=E9=83=BD?= =?UTF-8?q?=E6=98=AF=E6=AD=A3=E5=81=87=E4=BA=A4=E7=82=B9,=E8=A1=A5?= =?UTF-8?q?=E5=9C=86=E5=BC=A7,?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __test__/Polyline/offset.test.ts | 23 +++++++++++++++++++++++ src/GraphicsSystem/OffestPolyline.ts | 14 +++++++++----- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/__test__/Polyline/offset.test.ts b/__test__/Polyline/offset.test.ts index bb47d3e69..0bf9e8d04 100644 --- a/__test__/Polyline/offset.test.ts +++ b/__test__/Polyline/offset.test.ts @@ -248,5 +248,28 @@ test('闭合多段线偏移测试8', () => expect(cus[0].GetOffsetCurves(15).length).toBe(1); expect(cus[0].GetOffsetCurves(17.8).length).toBe(2); expect(cus[0].GetOffsetCurves(19).length).toBe(3); + for (let i = 20; i <= 40; i++) + { + expect(cus[0].GetOffsetCurves(i).length).toBe(3); + } + for (let i = 41; i <= 44.3; i += 0.1) + { + expect(cus[0].GetOffsetCurves(i).length).toBe(2); + } + expect(cus[0].GetOffsetCurves(45).length).toBe(1); + for (let i = 48; i <= 200; i += 10) + { + expect(cus[0].GetOffsetCurves(i).length).toBe(0); + } +}) +test('闭合多段线偏移测试9', () => +{ + let data = + [1, ["Polyline", 1, 1, 12283, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -2494.1602062139054, -154.37421492307953, 0, 1], 2, 4, [-835.9056689963722, -81.71614968554674], -1.404257507243489, [-2.5205246091134654, -224.3682931983378], -0.7704346688180675, [-677.9527382520764, -55.635630094036955], 0, [-835.9056689963722, -81.71614968554674], 0, false]]; + let cus = loadFile(data); + //外偏移 - + + + //内偏移+ }) diff --git a/src/GraphicsSystem/OffestPolyline.ts b/src/GraphicsSystem/OffestPolyline.ts index d86eb879a..27971c7b8 100644 --- a/src/GraphicsSystem/OffestPolyline.ts +++ b/src/GraphicsSystem/OffestPolyline.ts @@ -100,10 +100,7 @@ export class PolyOffestUtil if (c.IntersectWith(this.m_Polyline, IntersectOption.OnBothOperands).length !== 0) return false; //删除在反方向的无效线段 - return this.CheckPointDir(c.StartPoint) || this.CheckPointDir(c.EndPoint); - // return this.CheckPointDist(c.StartPoint) && this.CheckPointDist(c.EndPoint) - // return (this.CheckPointDist(c.StartPoint) && this.CheckPointDist(c.EndPoint)) - // && this.CheckPointDir(c.StartPoint); + return this.CheckPointDir(c.GetPointAtParam(0.5)); }); //处理自交的线段 @@ -378,7 +375,14 @@ export class PolyOffestUtil let par2 = laterLine.GetParamAtPoint(intPt); if (par1 > 1) { - this.appendNewCuAndContour(frontLine, nextPt, intPt, startIndex); + if (par2 > 1 && laterLine instanceof Arc) + { + this.fillArc(endIndex - 1, endIndex, nextPt, frontLine, laterLine); + } + else + { + this.appendNewCuAndContour(frontLine, nextPt, intPt, startIndex); + } } else if (frontLine instanceof Arc && par1 < 0 && par2 < 0) {