!2712 修复:绘制缺口立板时模块撤销重做失败问题

pull/2713/head
林三 5 months ago committed by ChenX
parent c720029680
commit 164e85d356

@ -3,6 +3,7 @@ import { Board } from "../../DatabaseServices/Entity/Board";
import { Entity } from "../../DatabaseServices/Entity/Entity";
import { ExtrudeSolid } from "../../DatabaseServices/Entity/Extrude";
import { HardwareCompositeEntity } from "../../DatabaseServices/Hardware/HardwareCompositeEntity";
import { ObjectId } from "../../DatabaseServices/ObjectId";
/**
* ()0
@ -11,10 +12,17 @@ import { HardwareCompositeEntity } from "../../DatabaseServices/Hardware/Hardwar
* @param {Entity} knifeBrs
* @param {Board[]} brs
*/
export function CuttingProtrudingPart(knifeBrs: Set<Entity>, brs: Board[]): Board[]
export function CuttingProtrudingPart(knifeBrs: Set<ObjectId>, brs: Board[]): Board[]
{
// 获取包围框里的实体
let intersectsEnt = Array.from(knifeBrs) || [];
let intersectsEnt: Entity[] = [];
for (let entId of knifeBrs)
{
let ent = entId?.Object as Entity;
if (ent && !ent.IsErase)
intersectsEnt.push(ent);
}
// 获取包围框里的实体与需要绘制实体碰撞的实体
let brKfs = intersectsEnt.filter((ent) => ent instanceof Board) as Board[];
// 处理碰撞的复合实体

@ -2,8 +2,8 @@ import { app } from '../../ApplicationServices/Application';
import { CommandNames } from '../../Common/CommandNames';
import { Board } from '../../DatabaseServices/Entity/Board';
import { BoardType } from '../../DatabaseServices/Entity/BoardInterface';
import { Entity } from '../../DatabaseServices/Entity/Entity';
import { HardwareCompositeEntity } from '../../DatabaseServices/Hardware/HardwareCompositeEntity';
import { ObjectId } from '../../DatabaseServices/ObjectId';
import { Command } from '../../Editor/CommandMachine';
import { PromptStatus } from '../../Editor/PromptResult';
import { ISpaceParse } from '../../Geometry/SpaceParse/ISpaceParse';
@ -23,8 +23,12 @@ export abstract class DrawBoardTool implements Command
protected modalType: BoardModalType;
protected store: LayerBoardStore | VerticalBoardStore | BehindBoardStore;
protected space: ISpaceParse;
protected IntersectSpaceEntitys: Set<Entity>;
CacheSpaceEntitysMap: Map<string, Set<Entity>> = new Map();
protected IntersectSpaceEntitys: Set<ObjectId>;
/**
* min/max
*/
CacheSpaceEntitysMap: Map<string, Set<ObjectId>> = new Map();
async exec()
{
@ -117,17 +121,22 @@ export abstract class DrawBoardTool implements Command
{
let box = spaceParse.SpaceBox.clone().applyMatrix4(spaceParse.SpaceOCS);
let key = `${PointToString(box.min)}${PointToString(box.max)}`;
let ents = this.CacheSpaceEntitysMap.get(key);
let objectIds = this.CacheSpaceEntitysMap.get(key);
if (!ents)
if (!objectIds)
{
ents = new Set(app.Database.ModelSpace.Entitys.filter((ent) =>
let ents = app.Database.ModelSpace.Entitys.filter((ent) =>
{
return !ent.IsErase && (ent instanceof Board || ent instanceof HardwareCompositeEntity) && box.intersectsBox(ent.BoundingBox);
}));
this.CacheSpaceEntitysMap.set(key, ents);
});
objectIds = new Set();
for (let ent of ents)
objectIds.add(ent.objectId);
this.CacheSpaceEntitysMap.set(key, objectIds);
}
return ents;
return objectIds;
}
//构建板件

@ -9,6 +9,7 @@ import { Factory } from "../../CADFactory";
import { CADFiler } from "../../CADFiler";
import { Board } from "../../Entity/Board";
import { Entity } from "../../Entity/Entity";
import { ObjectId } from "../../ObjectId";
import { TemplateRecord } from "../TemplateRecord";
/**
@ -24,7 +25,7 @@ export class TemplateBoardRecord extends TemplateRecord
@AutoRecord DrawBoardCount = 1;
//空间分析缺口切割需要的板件
protected IntersectSpaceEntitys: Set<Entity>;
protected IntersectSpaceEntitys: Set<ObjectId>;
//空间分析缺口切割需要原板件排钻信息
protected IntersectHighDrill: string[];
@ -87,11 +88,11 @@ export class TemplateBoardRecord extends TemplateRecord
}
//记录按缺口切割前的板轮廓
const OldContour = nbrs[0].ContourCurve.Clone();
const OldContour = nbrs[0]?.ContourCurve?.Clone();
//是否是被缺口切割
const IsIntersectSpaceEntitys = !!this.IntersectSpaceEntitys?.size;
if (IsIntersectSpaceEntitys)
if (IsIntersectSpaceEntitys && nbrs?.length)
{
if (!this.IntersectHighDrill?.length)
this.IntersectHighDrill = nbrs[0].BoardProcessOption.highDrill;

@ -6,7 +6,7 @@ import { IGrooveOption, LayerBoardOption, LayerNailOption } from "../../../UI/St
import { Factory } from "../../CADFactory";
import { CADFiler } from "../../CADFiler";
import { Board } from "../../Entity/Board";
import { Entity } from "../../Entity/Entity";
import { ObjectId } from "../../ObjectId";
import { TemplateBoardRecord } from "./TemplateBoard";
/**
@ -30,7 +30,7 @@ export class TemplateLayerBoard extends TemplateBoardRecord
};
//空间分析缺口切割需要的板件
IntersectSpaceEntitys: Set<Entity> = new Set();
IntersectSpaceEntitys: Set<ObjectId> = new Set();
IntersectHighDrill: string[] = [];
set GrooveOption(option: IGrooveOption)
{
@ -136,9 +136,9 @@ export class TemplateLayerBoard extends TemplateBoardRecord
let size = file.Read();
for (let i = 0; i < size; i++)
{
let ent = file.ReadObjectId().Object as Entity;
if (ent && !ent.IsErase)
this.IntersectSpaceEntitys.add(ent);
let entId = file.ReadObjectId();
if (entId)
this.IntersectSpaceEntitys.add(entId);
}
size = file.Read();
@ -190,7 +190,7 @@ export class TemplateLayerBoard extends TemplateBoardRecord
//ver5
file.Write(this.IntersectSpaceEntitys.size);
for (let ent of this.IntersectSpaceEntitys)
file.WriteObjectId(ent?.objectId);
file.WriteObjectId(ent);
file.Write(this.IntersectHighDrill.length);
for (let type of this.IntersectHighDrill)

@ -4,7 +4,8 @@ import { ISpaceParse } from "../../../Geometry/SpaceParse/ISpaceParse";
import { IGrooveOption, VerticalBoardOption } from "../../../UI/Store/OptionInterface/IOptionInterface";
import { Factory } from "../../CADFactory";
import { CADFiler } from "../../CADFiler";
import { Entity } from "../../Entity/Entity";
import { Database } from "../../Database";
import { ObjectId } from "../../ObjectId";
import { TemplateBoardRecord } from "./TemplateBoard";
/**
@ -32,7 +33,7 @@ export class TemplateVerticalBoard extends TemplateBoardRecord
}
//空间分析缺口切割需要的板件
IntersectSpaceEntitys: Set<Entity> = new Set();
IntersectSpaceEntitys: Set<ObjectId> = new Set();
IntersectHighDrill: string[] = [];
GeneralBoardList(space: ISpaceParse)
@ -85,19 +86,43 @@ export class TemplateVerticalBoard extends TemplateBoardRecord
}
this.IntersectSpaceEntitys.clear();
if (ver > 3)
//版本4弃用ReadObject
if (ver === 4)
{
let size = file.Read();
let bakDb = file.database;
file.database = new Database;
for (let i = 0; i < size; i++)
this.IntersectSpaceEntitys.add(file.ReadObject());
{
let ent = file.ReadObject();
let id = bakDb.GetObjectId(ent.Id.Index, true);
this.IntersectSpaceEntitys.add(id);
}
file.database = bakDb;
}
size = file.Read();
if (ver > 3)
{
let size = file.Read();
this.IntersectHighDrill = file.ReadArray(size);
}
if (ver > 4)
{
//版本5 采用读取ID
let size = file.Read();
for (let i = 0; i < size; i++)
{
let entId = file.ReadObjectId();
if (entId)
this.IntersectSpaceEntitys.add(entId);
}
}
}
WriteFile(file: CADFiler)
{
file.Write(4);
file.Write(5);
super.WriteFile(file);
file.Write(this._option.type);
file.Write(this._option.name);
@ -121,14 +146,14 @@ export class TemplateVerticalBoard extends TemplateBoardRecord
file.Write(this.grooveOption.grooveAddDepth);
file.Write(this.grooveOption.knifeRadius);
//ver4
file.Write(this.IntersectSpaceEntitys.size);
for (let ent of this.IntersectSpaceEntitys)
file.WriteObject(ent);
file.Write(this.IntersectHighDrill.length);
for (let type of this.IntersectHighDrill)
file.Write(type);
//ver5
file.Write(this.IntersectSpaceEntitys.size);
for (let ent of this.IntersectSpaceEntitys)
file.WriteObjectId(ent);
}
}

Loading…
Cancel
Save