diff --git a/__test__/FeedingToolPath/FeedingToolPath.test.ts b/__test__/FeedingToolPath/FeedingToolPath.test.ts index 82333c44e..50beec60e 100644 --- a/__test__/FeedingToolPath/FeedingToolPath.test.ts +++ b/__test__/FeedingToolPath/FeedingToolPath.test.ts @@ -150,3 +150,11 @@ test("超级复杂造型01", () => let brs = LoadBoardsFromFileData(data); testPathCount(brs[0]); }); + +test("#I1MUQD", () => +{ + let data = + { "file": [1, "Board", 8, 2, 100, false, 1, 7, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, -467.31234866828163, 18, -238.49878934602498, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -467.31234866828163, 18, -238.49878934602498, 1], 0, 3, 2430, 831, 18, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 836, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, -5680.316507397597, -177.89800995069288, 0, 1], 0, 2, 4, [-5, 0], 0, [-5, 2430], 0, [-836, 2430], 0, [-836, 0], 0, true, 1, 3, 2210, 631, 5, true, "Polyline", 8, 2, 0, false, 0, 1, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -5780.316507397597, -297.8980099506929, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -5780.316507397597, -297.8980099506929, 0, 1], 0, 2, 4, [5780.316507397597, 297.8980099506929], 0, [6411.316507397597, 297.8980099506929], 0, [6411.316507397597, 2507.898009950693], 0, [5780.316507397597, 2507.898009950693], 0, true, 3, 3, 2204, 625.0000000000009, 5, false, "Polyline", 8, 2, 0, false, 0, 1, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -5783.316507397596, -300.8980099506929, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -5783.316507397596, -300.8980099506929, 0, 1], 0, 2, 12, [5783.316507397596, 2204.5970149255954], 0, [5926.316507397597, 2204.5970149255954], 0, [5926.316507397597, 606.5970149255957], 0, [5783.316507397597, 606.5970149255954], 0, [5783.316507397597, 300.8980099506929], 0, [6408.316507397597, 300.898009950693], 0, [6408.316507397597, 606.5970149255954], 0, [6265.316507397597, 606.5970149255953], 0, [6265.316507397597, 2204.5970149255954], 0, [6408.316507397597, 2204.5970149255954], 0, [6408.316507397597, 2504.898009950693], 0, [5783.316507397597, 2504.898009950693], 0, true, 0, 3, 0, 0, 0, 0, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, -364.31234866828163, 5, -115.49878934602498, 1], 3, 1592, 140.0000000000009, 5, true, "Polyline", 8, 2, 0, false, 0, 1, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -5783.316507397596, -609.5970149255954, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -5783.316507397596, -609.5970149255954, 0, 1], 0, 2, 4, [5783.316507397596, 2201.5970149255954], 0, [5783.316507397597, 609.5970149255954], 0, [5923.316507397597, 609.5970149255957], 0, [5923.316507397597, 2201.5970149255954], 0, true, 0, 3, 0, 0, 0, 0, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, -364.31234866828163, 5, 193.20021562887757, 1], 3, 1592, 140, 5, true, "Polyline", 8, 2, 0, false, 0, 1, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -6273.316507397597, -609.5970149255954, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, -6273.316507397597, -609.5970149255954, 0, 1], 0, 2, 4, [6413.316507397597, 609.5970149255954], 0, [6413.316507397597, 2201.5970149255954], 0, [6273.316507397597, 2201.5970149255954], 0, [6273.316507397597, 609.5970149255954], 0, true, 0, 3, 0, 0, 0, 0, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 120.68765133171837, 5, 193.20021562887757, 1], 1.5, 0, 0, 0, 0, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, -367.31234866828163, 5, -118.49878934602498, 1], 3, 0, 0, 0, 0, 0, 9, 2, "背板", "", "", "18厘SL天使白", "多层", "天使白", 0, 0, "三合一", 0, 0, "1", "1", "1", "1", "", "", "", 4, "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true], "basePt": { "x": -467.31234866828163, "y": 0, "z": -238.49878934602498 }, "ucs": [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1] }; + let brs = LoadBoardsFromFileData(data); + testPathCount(brs[0], 8); +}); diff --git a/__test__/FeedingToolPath/__snapshots__/FeedingToolPath.test.ts.snap b/__test__/FeedingToolPath/__snapshots__/FeedingToolPath.test.ts.snap index 71dfe134b..11c5e450d 100644 --- a/__test__/FeedingToolPath/__snapshots__/FeedingToolPath.test.ts.snap +++ b/__test__/FeedingToolPath/__snapshots__/FeedingToolPath.test.ts.snap @@ -1,5 +1,23 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`#I1MUQD 1`] = `"6522.00000"`; + +exports[`#I1MUQD 2`] = `"6242.00000"`; + +exports[`#I1MUQD 3`] = `"3476.00000"`; + +exports[`#I1MUQD 4`] = `"3476.00000"`; + +exports[`#I1MUQD 5`] = `"5682.00000"`; + +exports[`#I1MUQD 6`] = `"6230.00000"`; + +exports[`#I1MUQD 7`] = `"3464.00000"`; + +exports[`#I1MUQD 8`] = `"3464.00000"`; + +exports[`#I1MUQD: 走刀数量 1`] = `3`; + exports[`#IYX1P 1`] = `"3600.00000"`; exports[`#IYX1P 2`] = `"1356.19421"`; diff --git a/src/GraphicsSystem/ToolPath/FeedingToolPath.ts b/src/GraphicsSystem/ToolPath/FeedingToolPath.ts index bd93aed04..952ae1d5d 100644 --- a/src/GraphicsSystem/ToolPath/FeedingToolPath.ts +++ b/src/GraphicsSystem/ToolPath/FeedingToolPath.ts @@ -13,7 +13,7 @@ import { Shape } from "../../DatabaseServices/Shape"; import { ShapeManager } from "../../DatabaseServices/ShapeManager"; import { Route } from "../../Geometry/CurveMap"; import { GetSideFaceMtx } from "../../Geometry/DrillParse/BoardGetFace"; -import { angleTo, isParallelTo, MoveMatrix, XAxis } from "../../Geometry/GeUtils"; +import { angleTo, isParallelTo, MoveMatrix, XAxis, equaln } from "../../Geometry/GeUtils"; import { RegionParse } from "../../Geometry/RegionParse"; import { FixIndex } from "../../Nest/Common/Util"; import { FaceDirection } from "../../UI/Store/BoardInterface"; @@ -147,7 +147,15 @@ export class FeedingToolPath extends Singleton vailHoles.push(h); } if (isOut) + { + //#I1MUQD 走好擦边的孔不合并 + let oldHoles = vailHoles.map(c => c.Clone()); + let oldArea = vailHoles.reduce((area, c) => area += c.Area, 0); vailHoles = Shape.mergeContours(vailHoles); + let newArea = vailHoles.reduce((area, c) => area += c.Area, 0); + if (equaln(oldArea, newArea, 0.1)) + vailHoles = oldHoles; + } offsetCus.push(...vailHoles.map(h => h.Curve)); return offsetCus;