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) {