From a448b0a68338924503b88ca2dc282c32273cf8d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E4=B8=89?= <940119273@qq.com> Date: Wed, 8 May 2024 02:20:48 +0000 Subject: [PATCH] =?UTF-8?q?!2704=20=E4=BF=AE=E5=A4=8D:=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=A7=81=E5=85=89=E9=9D=A2=E5=B0=81=E8=BE=B9=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=BC=A7=E5=BD=A2=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Add-on/SetSmoothEdge/SetSmoothEdgeFace.ts | 48 +++++++++++++++++-- src/Geometry/DrillParse/BoardGetFace.ts | 29 +++++++++-- src/Geometry/DrillParse/Face.ts | 17 ++++++- 3 files changed, 83 insertions(+), 11 deletions(-) diff --git a/src/Add-on/SetSmoothEdge/SetSmoothEdgeFace.ts b/src/Add-on/SetSmoothEdge/SetSmoothEdgeFace.ts index 5e163ac62..f79997160 100644 --- a/src/Add-on/SetSmoothEdge/SetSmoothEdgeFace.ts +++ b/src/Add-on/SetSmoothEdge/SetSmoothEdgeFace.ts @@ -70,6 +70,13 @@ class SetSmoothEdgeFaces extends BoardGetFace } } } + override GetArcBoardFaces() + { + this.FaceSealingDataMap = new Map(); + this.highSealingData = []; + this.sealCus = []; + super.GetArcBoardFaces(this.FaceSealingDataMap, this.highSealingData, this.sealCus); + } GetSmoothFaces(bg: this, scale = 0) { for (let f1 of this.Faces) @@ -86,6 +93,10 @@ class SetSmoothEdgeFaces extends BoardGetFace let localBoard = (f1.type !== f2.type && f1.type === BoardFaceType.NoSide) ? f1.LocalBoard : f2.LocalBoard; + let scaleCopy = scale; + if (f1.LocalBoard.IsArcBoard && f1.type === BoardFaceType.Side || f2.LocalBoard.IsArcBoard && f2.type === BoardFaceType.Side) + scaleCopy = 0; + let nor1 = new Vector3().setFromMatrixColumn(mtx, 2); let nor2 = new Vector3().setFromMatrixColumn(mtx2, 2); @@ -107,7 +118,7 @@ class SetSmoothEdgeFaces extends BoardGetFace let f2CoverBoxes = bg._CoveredWidthFaceMap.get(f2) ?? []; if (f1.type === f2.type) { - let intRes = f1.IsIntersect(f2, scale, f1CoverBoxes); + let intRes = f1.IsIntersect(f2, scaleCopy, f1CoverBoxes); if (intRes.isInt) { this.SmoothFace.add(f1); @@ -116,7 +127,7 @@ class SetSmoothEdgeFaces extends BoardGetFace else this._CoveredWidthFaceMap.set(f1, intRes.coverBoxesList); - intRes = f2.IsIntersect(f1, scale, f2CoverBoxes); + intRes = f2.IsIntersect(f1, scaleCopy, f2CoverBoxes); if (intRes.isInt) { bg.SmoothFace.add(f2); @@ -127,7 +138,7 @@ class SetSmoothEdgeFaces extends BoardGetFace } else { - let intRes = f1.IsIntersect(f2, scale, f1.type === BoardFaceType.Side ? f1CoverBoxes : f2CoverBoxes); + let intRes = f1.IsIntersect(f2, scaleCopy, f1.type === BoardFaceType.Side ? f1CoverBoxes : f2CoverBoxes); if (intRes.isInt) { if (f1.type === BoardFaceType.Side) @@ -183,6 +194,32 @@ class SetSmoothEdgeFaces extends BoardGetFace SetBoardTopDownLeftRightSealData(this.Board, this.highSealingData, this.sealCus); this.Board.BoardProcessOption.highSealed = this.highSealingData; } + + WriteArcBoardSealingData(option: ISmoothEdgeOption) + { + let useIndex = new Set(); + + for (let f of this.Faces) + { + if (f.type === BoardFaceType.Side && this.SmoothFace.has(f)) + { + let index = this.FaceSealingDataMap.get(f); + if (index !== undefined) + { + this.highSealingData[index].size = option.edge; + useIndex.add(index); + } + } + } + for (let i = 0; i < this.highSealingData.length; i++) + { + if (!useIndex.has(i)) + this.highSealingData[i].size = option.smoothEdge; + } + + SetBoardTopDownLeftRightSealData(this.Board, this.highSealingData, this.sealCus); + this.Board.BoardProcessOption.highSealed = this.highSealingData; + } } export function SetSmoothEdges(brs: Board[], option: ISmoothEdgeOption) @@ -220,6 +257,9 @@ export function SetSmoothEdges(brs: Board[], option: ISmoothEdgeOption) for (let brGe of BoardGeList) { - brGe.WriteSealingData(option); + if (brGe.Board.IsArcBoard) + brGe.WriteArcBoardSealingData(option); + else + brGe.WriteSealingData(option); } } diff --git a/src/Geometry/DrillParse/BoardGetFace.ts b/src/Geometry/DrillParse/BoardGetFace.ts index f56f57a9d..ff968b1d8 100644 --- a/src/Geometry/DrillParse/BoardGetFace.ts +++ b/src/Geometry/DrillParse/BoardGetFace.ts @@ -9,6 +9,8 @@ import { Board } from "../../DatabaseServices/Entity/Board"; import { Curve } from "../../DatabaseServices/Entity/Curve"; import { Polyline } from "../../DatabaseServices/Entity/Polyline"; import { Region } from "../../DatabaseServices/Entity/Region"; +import { GetBoardHighSeal } from "../../GraphicsSystem/CalcEdgeSealing"; +import { IHighSealedItem } from "../../UI/Store/OptionInterface/IHighSealedItem"; import { AsVector2, ZAxis, angle, equaln, equalv3 } from "../GeUtils"; import { CanDrawHoleFuzz } from "./CanDrawHoleFuzz"; import { Face } from "./Face"; @@ -30,7 +32,7 @@ export class BoardGetFace { if (this.Board.IsArcBoard) { - this.GetCurveBoardSideFaces(); + this.GetArcBoardFaces(); return; } //正反面 @@ -103,7 +105,7 @@ export class BoardGetFace } //获取曲线板的正反 侧面 - GetCurveBoardSideFaces() + GetArcBoardFaces(faceSealingDataMap?: Map, highSealingData?: IHighSealedItem[], sealCu?: Curve[]) { let br = this.Board; const opt = br.BoardProcessOption; @@ -135,9 +137,17 @@ export class BoardGetFace const FaceDir = br.SweepVisibleFace === FaceDirection.Front ? -1 : 1; - let ContourCurve = br.ContourCurve.Clone() as Polyline; + const ContourCurve = br.ContourCurve.Clone() as Polyline; + //弧形板旋转角度 ContourCurve.ApplyMatrix(sweepArcBoardBuild.OCS2RotateMtx); + if (highSealingData) + { + let cus = (br.ContourCurve.Clone() as Polyline).Explode(); + highSealingData.push(...GetBoardHighSeal(br, cus)); + sealCu.push(...cus); + } + let contourLength = br.ParseBoardLengthInArcSweep(); for (let i = 0; i < conCus.length; i++) @@ -238,14 +248,23 @@ export class BoardGetFace ocs = new Matrix4().multiplyMatrices((new Matrix4().makeRotationAxis(ZNormal, ro)), ocs).setPosition(conCu.StartPoint); ocs.multiply(new Matrix4().getInverse(RX)).multiply(mtx); - this.Faces.push(new Face({ + let f = new Face({ type: BoardFaceType.Side, localBoard: br, matrix4: ocs, length: cu.Length, width: br.Thickness * FaceDir, drillType: HighDrill.length > 0 && HighDrill[j] - })); + }); + + if (faceSealingDataMap) + { + let pt = cu.GetPointAtParam(0.5).add(new Vector3(currentLength)); + let index = Math.floor(ContourCurve.GetParamAtPoint(pt)); + if (!isNaN(index)) + faceSealingDataMap.set(f, index); + } + this.Faces.push(f); } } } diff --git a/src/Geometry/DrillParse/Face.ts b/src/Geometry/DrillParse/Face.ts index ba214ccd2..5cce7d6cf 100644 --- a/src/Geometry/DrillParse/Face.ts +++ b/src/Geometry/DrillParse/Face.ts @@ -253,7 +253,20 @@ export class Face } else { - let retBox = new Box3Ext(new Vector3(), new Vector3(sideFace.Length, sideFace.Width)); + let minV: Vector3; + let maxV: Vector3; + if (sideFace.Width > 0) + { + minV = new Vector3(); + maxV = new Vector3(sideFace.Length, sideFace.Width); + } + else + { + minV = new Vector3(0, sideFace.Width); + maxV = new Vector3(sideFace.Length, 0); + } + + let retBox = new Box3Ext(minV, maxV); let p1 = new Vector3().setFromMatrixPosition(diffMtx); let p2 = new Vector3(noSideFace.Length, noSideFace.Width).applyMatrix4(diffMtx); @@ -263,7 +276,7 @@ export class Face { retBox.intersect(box3); let size = retBox.getSize(new Vector3()); - if (equaln(size.x * size.y, 0) || size.y / sideFace.Width <= fuzz) + if (equaln(size.x * size.y, 0) || Math.abs(size.y / sideFace.Width) <= fuzz) return { isInt: false, coverBoxesList: currentCoverBoxes }; if (size.x / sideFace.Length > fuzz)