From 129871b3e78fd305b92f4e6ce274fef59f79ef59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E4=B8=89?= <940119273@qq.com> Date: Tue, 16 Apr 2024 01:11:46 +0000 Subject: [PATCH] =?UTF-8?q?!2682=20=E4=BC=98=E5=8C=96:=E5=BC=A7=E5=BD=A2?= =?UTF-8?q?=E6=9D=BF=E6=A8=A1=E6=8B=9F=E8=B5=B0=E5=88=80=E6=8E=92=E9=92=BB?= =?UTF-8?q?=E5=AD=94=E4=BD=8D=E5=88=86=E6=9E=90=20Merge=20pull=20request?= =?UTF-8?q?=20!2682=20from=20=E6=9E=97=E4=B8=89/fix=5Fparse=5Fhole?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Geometry/DrillParse/BoardGetFace.ts | 2 + src/Production/Product.ts | 97 ++++++++++++++++++++----- 2 files changed, 81 insertions(+), 18 deletions(-) diff --git a/src/Geometry/DrillParse/BoardGetFace.ts b/src/Geometry/DrillParse/BoardGetFace.ts index eeb0ff4a6..d7614589e 100644 --- a/src/Geometry/DrillParse/BoardGetFace.ts +++ b/src/Geometry/DrillParse/BoardGetFace.ts @@ -225,6 +225,8 @@ export class BoardGetFace let cus = faceRegion.Explode(); for (let j = 0; j < cus.length; j++) { + if (HighDrill.length > 0 && HighDrill[j] === DrillType.None) continue; + let cu = cus[j]; let mtx = GetSideFaceMtx(cu, faceRegion.IsClockWise); let ocs = PathOCS.clone().setPosition(0, 0, 0); diff --git a/src/Production/Product.ts b/src/Production/Product.ts index af8ded0ba..dcd03aa97 100644 --- a/src/Production/Product.ts +++ b/src/Production/Product.ts @@ -1,4 +1,5 @@ import { Box3, Matrix4, Vector2, Vector3 } from "three"; +import { SplitPolyline } from "../Add-on/BoardCutting/SplitPolyline"; import { FaceDirection } from "../Add-on/DrawDrilling/DrillType"; import { SCALAR } from "../Add-on/DrawDrilling/HoleUtils"; import { lookOverBoardInfosTool } from "../Add-on/LookOverBoardInfos/LookOverBoardInfosTool"; @@ -24,7 +25,7 @@ import { HardwareCompositeEntity } from "../DatabaseServices/Hardware/HardwareCo import { HardwareTopline } from "../DatabaseServices/Hardware/HardwareTopline"; import { Shape } from "../DatabaseServices/Shape"; import { CanDrawHoleFuzz } from "../Geometry/DrillParse/CanDrawHoleFuzz"; -import { IsBetweenA2B, MoveMatrix, XAxis, angle, angleTo, equaln, equalv2, equalv3, isIntersect2, isParallelTo, isPerpendicularityTo } from "../Geometry/GeUtils"; +import { AsVector2, IsBetweenA2B, MoveMatrix, XAxis, angle, angleTo, equaln, equalv2, equalv3, isIntersect2, isParallelTo, isPerpendicularityTo } from "../Geometry/GeUtils"; import { BrSealedData, GetSealedBoardContour } from "../GraphicsSystem/CalcEdgeSealing"; import { FeedingToolPath, GetModelingFromCustomDrill } from "../GraphicsSystem/ToolPath/FeedingToolPath"; import { EMetalsType, IHardwareOption, IToplineOption } from "../UI/Components/RightPanel/RightPanelInterface"; @@ -501,15 +502,10 @@ export namespace Production { const ArcBoardBuild = br.ArcBuild; ArcBoardBuild.ParseSweepCurves(); - let cus = br.SweepVisibleFace === FaceDirection.Front ? ArcBoardBuild.SweepCurves2 : ArcBoardBuild.SweepCurves1; - - let brBoxSize = br.Shape.Outline.Curve.Clone().ApplyMatrix(ArcBoardBuild.Rotate2OCSMtx).BoundingBox.getSize(new Vector3); - if (br.SweepAngle) - { - let extrude = Board.CreateBoard(brBoxSize.y, brBoxSize.x, 1); - sealedContour = extrude.ContourCurve; - } + let cus = ArcBoardBuild.SweepCurves1; + let ContourCurve = br.Shape.Outline.Curve.Clone().ApplyMatrix(ArcBoardBuild.OCS2RotateMtx) as Polyline; + let brBoxSize = ContourCurve.BoundingBox.getSize(new Vector3); let currentLength = 0; for (let cu of cus) { @@ -532,6 +528,34 @@ export namespace Production ocs.multiply(m.setPosition(cu.StartPoint.clone().applyMatrix4(new Matrix4().makeRotationX(Math.PI / 2)))); + //正面时翻转Z向量 + if (br.SweepVisibleFace === FaceDirection.Front) + ocs.setPosition(new Vector3(0, 0, -br.Thickness).applyMatrix4(ocs)); + + // 测试代码 + // let pt = new Vector3().applyMatrix4(ocs); + // let l1 = new Line(pt, pt.clone().add(new Vector3().setFromMatrixColumn(ocs, 0).normalize().multiplyScalar(100))); + // let l2 = new Line(pt, pt.clone().add(new Vector3().setFromMatrixColumn(ocs, 1).normalize().multiplyScalar(100))); + // let l3 = new Line(pt, pt.clone().add(new Vector3().setFromMatrixColumn(ocs, 2).normalize().multiplyScalar(100))); + + // TestDraw(new Point(pt)); + // TestDraw(l1, 1); + // TestDraw(l2, 3); + // TestDraw(l3, 5); + + //裁剪 计算每个分段轮廓 + let length = currentLength + cu.Length; + let starKnifePls = new Polyline([{ pt: AsVector2({ x: currentLength, y: -1 }), bul: 0 }, { pt: AsVector2({ x: currentLength, y: 10000 }), bul: 0 }]); + let endKnifePls = new Polyline([{ pt: AsVector2({ x: length, y: -1 }), bul: 0 }, { pt: AsVector2({ x: length, y: 10000 }), bul: 0 }]); + + //裁剪结果 + let faceRegions = SplitPolyline(ContourCurve, [starKnifePls, endKnifePls]); + faceRegions = faceRegions.filter((faceRegion) => + { + let x = faceRegion.BoundingBox.getCenter(new Vector3).x; + return x > currentLength && x < length; + }); + for (let [, driss] of br.DrillList) { for (let dris of driss) @@ -549,11 +573,12 @@ export namespace Production d["__CacheBrOCS__"] = ocs; //记录分段路径的起点与原点差值 d["__CacheAddPos__"] = new Vector3(currentLength); + d["__CacheContour__"] = faceRegions; } } } } - currentLength = currentLength + cu.Length; + currentLength = length; } } @@ -685,28 +710,37 @@ export namespace Production let brNormal = br.Normal; let outlineWidth = br.Width; let outlineHeight = br.Height; + let faceRegions: Polyline[]; + let faceRegionsBox: Box3; let addPos: Vector3; if (br.IsArcBoard) { addPos = cyHole["__CacheAddPos__"]; + faceRegions = cyHole["__CacheContour__"]; let ocs = cyHole["__CacheBrOCS__"]; cyHole["__CacheAddPos__"] = undefined; cyHole["__CacheBrOCS__"] = undefined; + cyHole["__CacheContour__"] = undefined; - if (!ocs || !addPos) + if (!ocs || !addPos || !faceRegions?.length) return; else { brInv = new Matrix4().getInverse(ocs); brNormal = new Vector3().setFromMatrixColumn(ocs, 2); - if (br.SweepAngle) - { - let boxSize = outline.BoundingBox.getSize(new Vector3); - outlineWidth = boxSize.x; - outlineHeight = boxSize.y; - } + + faceRegionsBox = new Box3(); + for (let pl of faceRegions) + faceRegionsBox.union(pl.BoundingBox); + + let boxSize = faceRegionsBox.getSize(new Vector3); + outlineWidth = boxSize.x; + outlineHeight = boxSize.y; + + let extrude = Board.CreateBoard(boxSize.y, boxSize.x, 1); + outline = extrude.ContourCurve; } } @@ -763,12 +797,39 @@ export namespace Production let sp = position.clone().setZ(0); //真实数据 let ep = position.clone().add(cyHole.Normal.multiplyScalar(cyHole.Height).applyMatrix4(brInvRo)).setZ(0); //真实数据 let testLine = new Line(sp, ep); - let iPt = outline.IntersectWith(testLine, 0, CanDrawHoleFuzz)[0]; + let iPt: Vector3; + + if (br.IsArcBoard) + { + if (faceRegions?.length) + { + for (let pl of faceRegions) + { + pl.UpdateOCSTo(new Matrix4().setPosition(faceRegionsBox.min)); + let newPl = new Polyline(pl.LineData); + iPt = newPl.IntersectWith(testLine, 0, CanDrawHoleFuzz)[0]; + if (iPt) + { + outline = newPl; + break; + } + } + } + else + { + InteractionLog([{ msg: "警告:" }, { msg: `板件${br.Name}`, entity: [br, cyHole] }, { msg: "侧孔与板无交点,无法加工该侧孔!" }], LogType.Warning); + return; + } + } + else + iPt = outline.IntersectWith(testLine, 0, CanDrawHoleFuzz)[0]; + if (!iPt) { InteractionLog([{ msg: "警告:" }, { msg: `板件${br.Name}`, entity: [br, cyHole] }, { msg: "侧孔与板无交点,无法加工该侧孔!" }], LogType.Warning); return; } + position = iPt.clone().setZ(z);//排钻开始的位置 for (let p of [sp, ep]) {