From b98352c97bb89c52aa2ae7cbf0a1fe2672dcfcec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E4=B8=89?= <940119273@qq.com> Date: Wed, 26 Jun 2024 06:17:46 +0000 Subject: [PATCH] =?UTF-8?q?!2836=20=E6=96=B0=E5=A2=9E:=E6=8B=86=E5=8D=95?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=A2=9E=E5=8A=A0=E9=80=A0=E5=9E=8B=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E5=92=8C=E6=8B=86=E5=8D=95=E5=90=8D=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=20Merge=20pull=20request=20!2836=20from=20=E6=9E=97=E4=B8=89/c?= =?UTF-8?q?haidan=5Fprop?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Add-on/DrawDrilling/DrawDrillingTool.ts | 11 +++++++++++ src/Add-on/Erp/Models/CadBlockInfo.ts | 11 ++++++++--- src/Add-on/Erp/ParseData.ts | 7 +++++-- src/DatabaseServices/3DSolid/Hole.ts | 9 ++++++++- .../ExtrudeMeshGeomBuilder/ExtrudeEdgeGeometry2.ts | 6 +++++- src/GraphicsSystem/ToolPath/FeedingToolPath.ts | 4 ++++ src/Production/Product.ts | 5 +++-- src/UI/Components/Board/SideModelingEditor.tsx | 2 +- 8 files changed, 45 insertions(+), 10 deletions(-) diff --git a/src/Add-on/DrawDrilling/DrawDrillingTool.ts b/src/Add-on/DrawDrilling/DrawDrillingTool.ts index f45fa0ee3..c32e493b5 100644 --- a/src/Add-on/DrawDrilling/DrawDrillingTool.ts +++ b/src/Add-on/DrawDrilling/DrawDrillingTool.ts @@ -869,8 +869,19 @@ export class DrawDrillingTool extends Singleton let g = new GroupRecord(); g.Name = this.m_Option.name; app.Database.GroupTable.Append(g); + + // 记录排钻的拆单组 + let onlyRecordNameGroup = new GroupRecord(); + onlyRecordNameGroup.Name = this.m_Option.name; + app.Database.GroupTable.Append(onlyRecordNameGroup); + for (let id of ids) + { + //后添加到 g组,防止Entity.GroupId使用onlyRecordNameGroup + onlyRecordNameGroup.Entitys.push(id); g.Entitys.push(id); + (id.Object as Hole).DrillGroupId = onlyRecordNameGroup.Id; + } } //分析结束,排钻存入板件或者原始板件 diff --git a/src/Add-on/Erp/Models/CadBlockInfo.ts b/src/Add-on/Erp/Models/CadBlockInfo.ts index d29d53aae..c08f450bc 100644 --- a/src/Add-on/Erp/Models/CadBlockInfo.ts +++ b/src/Add-on/Erp/Models/CadBlockInfo.ts @@ -1,4 +1,4 @@ -import { IOriginModelingData } from '../../../Production/Product'; +import { IOriginModelingData, ModelType } from '../../../Production/Product'; import { GetArray, GetOrgModelingArray } from './ArrayHelper'; export abstract class BaseModel @@ -68,18 +68,23 @@ export class CadBlockModel extends BaseModel PointList: CadBlockModelPoint[]; OffSetList: ModelOffSetData[]; OriginModeling: IOriginModelingData; + ModelType: ModelType; + ChaiDanName: string; + protected get props() { - return ['ModelID', 'LineID', 'Face', 'KnifeName', 'KnifeRadius', 'Depth']; + return ['ModelID', 'LineID', 'Face', 'KnifeName', 'KnifeRadius', 'Depth', 'ModelType', 'ChaiDanName']; } ToArray() { return [this.ModelID, this.LineID, this.Face, this.KnifeName, this.KnifeRadius, this.Depth, GetArray(CadBlockModelPoint, this.PointList), GetArray(ModelOffSetData, this.OffSetList), - GetOrgModelingArray(this.OriginModeling)]; + GetOrgModelingArray(this.OriginModeling), + this.ModelType, this.ChaiDanName]; } } + export class ModelOffSetData extends BaseModel { Name: string; diff --git a/src/Add-on/Erp/ParseData.ts b/src/Add-on/Erp/ParseData.ts index a7895c7f7..3faa0cb6c 100644 --- a/src/Add-on/Erp/ParseData.ts +++ b/src/Add-on/Erp/ParseData.ts @@ -13,7 +13,7 @@ import { TemplateRecord } from "../../DatabaseServices/Template/TemplateRecord"; import { CoordinateSystem } from "../../Geometry/CoordinateSystem"; import { GetBoxArr, IdentityMtx4, equalv2 } from "../../Geometry/GeUtils"; import { IContourData } from "../../Production/Convert2PtsBul"; -import { I2DModeling, I3DContourData, I3DModeling, IDrillingOption, IHardwareType, IModelingData, IOriginModelingData, ISpliteHardwareData, ISpliteOrderData, Production } from '../../Production/Product'; +import { I2DModeling, I3DContourData, I3DModeling, IDrillingOption, IHardwareType, IModelingData, IOriginSideModelingData, ISpliteHardwareData, ISpliteOrderData, ModelType, Production } from '../../Production/Product'; import { EMetalsType } from "../../UI/Components/RightPanel/RightPanelInterface"; import { ISealingData } from "../../UI/Store/OptionInterface/IHighSealedItem"; import { FaceDirection } from "../DrawDrilling/DrillType"; @@ -420,6 +420,7 @@ export class ErpParseData newModel.Depth = depth; newModel.PointList = this.GetModelPointDetail(f, modelID, depth); newModel.OriginModeling = DataArray[i].origin; + newModel.ModelType = ModelType.frontBackModel; modelList.push(newModel); lineID++; } @@ -430,7 +431,7 @@ export class ErpParseData } //获取侧面造型数据 - GetSideModelDetail(DataArray: IOriginModelingData[]): CadBlockModel[] + GetSideModelDetail(DataArray: IOriginSideModelingData[]): CadBlockModel[] { if (DataArray == null) return []; let sideModelList: CadBlockModel[] = []; @@ -444,8 +445,10 @@ export class ErpParseData newModel.LineID = 1; newModel.Face = DataArray[i].dir; newModel.KnifeName = ""; + newModel.ChaiDanName = DataArray[i].chaiDanName; newModel.KnifeRadius = DataArray[i].knifeRadius; newModel.Depth = DataArray[i].thickness; + newModel.ModelType = DataArray[i].modelType; newModel.OriginModeling = DataArray[i]; sideModelList.push(newModel); diff --git a/src/DatabaseServices/3DSolid/Hole.ts b/src/DatabaseServices/3DSolid/Hole.ts index e6a5ae03d..ae1ab7bc2 100644 --- a/src/DatabaseServices/3DSolid/Hole.ts +++ b/src/DatabaseServices/3DSolid/Hole.ts @@ -14,6 +14,8 @@ export abstract class Hole extends Entity @AutoRecord OtherHalfTongKong: ObjectId; protected allowHoleAtBoardEdge: boolean = false; //允许大孔面在板边缘 protected type: GangDrillType = GangDrillType.Pxl; + @AutoRecord DrillGroupId: ObjectId; //用于获取拆单名 区别GroupId 因为解组后GroupId会丢失 + get Height() { return this._Height; @@ -87,15 +89,20 @@ export abstract class Hole extends Entity { this.allowHoleAtBoardEdge = false; } + + if (ver > 7) + this.DrillGroupId = file.ReadObjectId(); } WriteFile(file: CADFiler) { super.WriteFile(file); - file.Write(7);//ver + file.Write(8);//ver file.Write(this._Height); file.WriteSoftObjectId(this.FId); file.WriteSoftObjectId(this.MId); file.WriteSoftObjectId(this.OtherHalfTongKong); file.WriteBool(this.allowHoleAtBoardEdge); + + file.WriteObjectId(this.DrillGroupId); } } diff --git a/src/Geometry/ExtrudeMeshGeomBuilder/ExtrudeEdgeGeometry2.ts b/src/Geometry/ExtrudeMeshGeomBuilder/ExtrudeEdgeGeometry2.ts index d8a156528..ffda5c60e 100644 --- a/src/Geometry/ExtrudeMeshGeomBuilder/ExtrudeEdgeGeometry2.ts +++ b/src/Geometry/ExtrudeMeshGeomBuilder/ExtrudeEdgeGeometry2.ts @@ -285,7 +285,7 @@ export class ContourTreeNode } } - static ParseContourTree(contourNodes: ContourTreeNode[], ignoreInCurve = false): void + static ParseContourTree(contourNodes: ContourTreeNode[], ignoreInCurve = false, checkIntersect = false): void { if (contourNodes.length < 2) return; @@ -312,6 +312,10 @@ export class ContourTreeNode let node2 = contourNodes[id]; if (node2.parent === node1 || node2.area < node1.area) continue;//避免自己的儿子成为自己的父亲 + //检查是否有交集 + if (checkIntersect && node1.contour.Curve.IntersectWith(node2.contour.Curve, IntersectOption.ExtendNone)) + continue; + if (node2.contour.Curve.PtInCurve(p) || ignoreInCurve) { node1.SetParent(node2); diff --git a/src/GraphicsSystem/ToolPath/FeedingToolPath.ts b/src/GraphicsSystem/ToolPath/FeedingToolPath.ts index b9cd96e2f..94c3e5ddb 100644 --- a/src/GraphicsSystem/ToolPath/FeedingToolPath.ts +++ b/src/GraphicsSystem/ToolPath/FeedingToolPath.ts @@ -14,6 +14,7 @@ import { Curve } from "../../DatabaseServices/Entity/Curve"; import { ExtrudeContourCurve, ExtrudeSolid } from "../../DatabaseServices/Entity/Extrude"; import { Line } from "../../DatabaseServices/Entity/Line"; import { Polyline } from "../../DatabaseServices/Entity/Polyline"; +import { GroupRecord } from "../../DatabaseServices/GroupTableRecord"; import { Shape } from "../../DatabaseServices/Shape"; import { ShapeManager } from "../../DatabaseServices/ShapeManager"; import { GetSideCuFaceMtx } from "../../Geometry/Board2DModelCSG/BoardSideModelCSGBuilder"; @@ -823,6 +824,8 @@ export function GetModelingFromCustomDrill(br: Board) shape.ApplyMatrix(new Matrix4().getInverse(GetSideCuFaceMtx(cu))); } + let chaiDanName = (hole.DrillGroupId?.Object as GroupRecord)?.Name ?? ""; + sideModeling.push({ outline: ConverToPtsBul(shape.Outline.Curve, false), holes: shape.Holes.map((cu) => ConverToPtsBul(cu.Curve, false)), @@ -832,6 +835,7 @@ export function GetModelingFromCustomDrill(br: Board) addLen: 0, addDepth: 0, addWidth: 0, + chaiDanName, modelType: ModelType.drill }); } diff --git a/src/Production/Product.ts b/src/Production/Product.ts index 45e22c034..0648f8ab6 100644 --- a/src/Production/Product.ts +++ b/src/Production/Product.ts @@ -154,7 +154,7 @@ export interface IOriginModelingData export interface IOriginSideModelingData extends IOriginModelingData { - chaiDanName?: string; + chaiDanName: string; modelType: ModelType; } @@ -530,7 +530,8 @@ export namespace Production addLen: solid.GroovesAddLength, addWidth: solid.GroovesAddWidth, addDepth: solid.GroovesAddDepth, - modelType + chaiDanName: "", + modelType, }); } else if (toaster) diff --git a/src/UI/Components/Board/SideModelingEditor.tsx b/src/UI/Components/Board/SideModelingEditor.tsx index d596c5b70..8669a4fcf 100644 --- a/src/UI/Components/Board/SideModelingEditor.tsx +++ b/src/UI/Components/Board/SideModelingEditor.tsx @@ -295,7 +295,7 @@ export class SideModelingEditor //分析包含关系 let contourNodes = contours.map(contour => new ContourTreeNode(contour)); - ContourTreeNode.ParseContourTree(contourNodes); + ContourTreeNode.ParseContourTree(contourNodes, false, true); for (let contourNode of contourNodes) {