!2295 新增:空间绘制层立板自动按缺口尺寸绘制出异形板件

pull/2359/MERGE
林三 7 months ago committed by ChenX
parent 60d3829c7c
commit e954fff373

@ -0,0 +1,46 @@
import { Matrix4 } from "three";
import { app } from "../../ApplicationServices/Application";
import { ExtrudeHole } from "../../DatabaseServices/3DSolid/ExtrudeHole";
import { Board } from "../../DatabaseServices/Entity/Board";
import { ExtrudeSolid } from "../../DatabaseServices/Entity/Extrude";
import { HardwareCompositeEntity } from "../../DatabaseServices/Hardware/HardwareCompositeEntity";
import { Box3Ext } from "../../Geometry/Box";
/**
* ()
*
*
* @param {Box3Ext} spaceBox
* @param {Matrix4} spaceOCS
* @param {Board[]} brs
*/
export function CuttingProtrudingPart(spaceBox: Box3Ext, spaceOCS: Matrix4, brs: Board[])
{
// 获取解析空间包围框
let box = spaceBox.clone().applyMatrix4(spaceOCS);
// 获取包围框里的实体
let intersectsEnt = app.Database.ModelSpace.Entitys.filter((ent) =>
{
return !ent.IsErase && (ent instanceof Board || ent instanceof HardwareCompositeEntity) && box.intersectsBox(ent.BoundingBox);
});
// 获取包围框里的实体与需要绘制实体碰撞的实体
let brKfs = intersectsEnt.filter((ent) => ent instanceof Board) as Board[];
// 处理碰撞的复合实体
let hardwareEnt = intersectsEnt.filter((ent) => ent instanceof HardwareCompositeEntity) as HardwareCompositeEntity[];
let hardwareKfs: ExtrudeSolid[] = [];
for (let h of hardwareEnt)
{
let ens = h.GetAllEntity(true, e => e instanceof ExtrudeSolid || e instanceof ExtrudeHole) as (ExtrudeSolid | ExtrudeHole)[];
for (let e of ens)
{
if (e instanceof ExtrudeHole)
hardwareKfs.push(e.Convert2ExtrudeSolid());
else
hardwareKfs.push(e);
}
}
//直接切掉
for (let br of brs)
br.Subtract([...hardwareKfs, ...brKfs]);
}

@ -4,6 +4,7 @@ import { BoardType } from '../../DatabaseServices/Entity/BoardInterface';
import { Command } from '../../Editor/CommandMachine';
import { PromptStatus } from '../../Editor/PromptResult';
import { ISpaceParse } from '../../Geometry/SpaceParse/ISpaceParse';
import { EnableSelectType } from '../../Geometry/SpaceParse/PointSelectSpace';
import { PointSelectSpaceClamp } from '../../Geometry/SpaceParse/PointSelectSpaceClamp';
import { BoardModal } from '../../UI/Components/Board/BoardModal';
import { BoardModalType } from "../../UI/Components/Board/BoardModalType";
@ -53,9 +54,13 @@ export abstract class DrawBoardTool implements Command
private async SelectAndBuildBoard()
{
let selectSpace = new PointSelectSpaceClamp();
if (this.modalType !== BoardModalType.Be)
selectSpace.Enable = EnableSelectType.AutoCutting;
await selectSpace.Select(() =>
{
this.space = selectSpace.SpaceParse;
this.store.m_Option.cuttingProtrudingPart = selectSpace.AutoCutting;
if (selectSpace.ParseOK)
this.buildBoard(false);
});
@ -77,6 +82,7 @@ export abstract class DrawBoardTool implements Command
if (!selectSpace.ParseOK)
return;
this.space = selectSpace.SpaceParse;
this.store.m_Option.cuttingProtrudingPart = selectSpace.AutoCutting;
//用周围板件加工数据
if (this.store.BoardProcessOption.useBoardProcessOption && this.space.Boards.length > 0)
this.store.GetBoardProcessOption(this.space.Boards[0]);

@ -5,6 +5,7 @@ import { JigUtils } from '../../Editor/JigUtils';
import { LayerBoardStore } from '../../UI/Store/BoardStore';
import { LayerBoardOption } from "../../UI/Store/OptionInterface/IOptionInterface";
import { BuildLayerBoards } from './BuildBoardTool';
import { CuttingProtrudingPart } from './CuttingProtrudingPart';
import { DrawBoardTool } from './DrawBoardTool';
export class DrawLayerBoard extends DrawBoardTool
@ -26,6 +27,10 @@ export class DrawLayerBoard extends DrawBoardTool
else
{
let brs = BuildLayerBoards(this.store.m_Option as LayerBoardOption, this.space);
if (this.store.m_Option.cuttingProtrudingPart)
CuttingProtrudingPart(this.space.SpaceBox, this.space.SpaceOCS, brs);
brs.forEach(b => JigUtils.Draw(b));
}
}

@ -5,6 +5,7 @@ import { SetTemplatePositionAndSetParent } from '../../DatabaseServices/Template
import { JigUtils } from '../../Editor/JigUtils';
import { VerticalBoardOption } from "../../UI/Store/OptionInterface/IOptionInterface";
import { BuildVerticalBoards } from './BuildBoardTool';
import { CuttingProtrudingPart } from './CuttingProtrudingPart';
import { DrawBoardTool } from './DrawBoardTool';
export class DrawVerticalBoard extends DrawBoardTool
@ -25,6 +26,10 @@ export class DrawVerticalBoard extends DrawBoardTool
else
{
let brs = BuildVerticalBoards(this.store.m_Option as VerticalBoardOption, this.space);
if (this.store.m_Option.cuttingProtrudingPart)
CuttingProtrudingPart(this.space.SpaceBox, this.space.SpaceOCS, brs);
brs.forEach(b => JigUtils.Draw(b));
}
}

@ -1,4 +1,5 @@
import { ExtendsBoardThickness } from "../../../Add-on/DrawBoard/BuildBoardTool";
import { CuttingProtrudingPart } from "../../../Add-on/DrawBoard/CuttingProtrudingPart";
import { EBoardKeyList } from "../../../Common/BoardKeyList";
import { ISpaceParse } from "../../../Geometry/SpaceParse/ISpaceParse";
import { BoardProcessOption } from "../../../UI/Store/OptionInterface/BoardProcessOption";
@ -60,6 +61,9 @@ export class TemplateBoardRecord extends TemplateRecord
this._option.thickness = thickness;
let nbrs = this.GeneralBoardList(this.SpaceParse);
if (this._option.cuttingProtrudingPart)
CuttingProtrudingPart(this.SpaceParse.SpaceBox, this.SpaceParse.SpaceOCS, nbrs);
let sbrs = this.PositioningSupportBoards;
if (this.BoardProcessOption)

@ -21,6 +21,7 @@ export enum EnableSelectType
Stretch = 1,
Two = 2,
Three = 4,
AutoCutting = 5,
All = ~(~0 << 3)
}
@ -28,6 +29,7 @@ const StretchKeyWord = { msg: "框选", key: "S" };
const TwoKeyWord = { msg: "2点", key: "2" };
const ThreeKeyWord = { msg: "3点", key: "3" };
const UCSKeyword = { msg: "ucs", key: "T" };
const AutoCutting = { msg: "缺口绘制异形板", key: "C" };
const AllKeyWordList = [StretchKeyWord, TwoKeyWord, ThreeKeyWord, UCSKeyword, { msg: "放弃", key: "U" }];
@ -35,16 +37,21 @@ export class PointSelectSpace
{
SpaceParse: ISpaceParse;
GetPointRes: PromptPointResult;
Enable = EnableSelectType.All;
UseUCSSpace = false;
AutoCutting = false;
async Select(callback?: Function)
{
let KeyWordList: KeyWord[];
UCSKeyword.msg = this.UseUCSSpace ? "使用实际空间" : "尝试使用UCS空间";
if (this.Enable === EnableSelectType.All)
KeyWordList = AllKeyWordList;
else if (this.Enable === EnableSelectType.AutoCutting)
{
AutoCutting.msg = this.AutoCutting ? "缺口正常绘制" : "缺口绘制异形板";
KeyWordList = [AutoCutting];
KeyWordList.push(...AllKeyWordList);
}
else
{
KeyWordList = [];
@ -134,6 +141,11 @@ export class PointSelectSpace
this.UseUCSSpace = !this.UseUCSSpace;
return await this.Select(callback);
}
else if (this.GetPointRes.StringResult === "C")
{
this.AutoCutting = !this.AutoCutting;
return await this.Select(callback);
}
}
else
{

@ -19,6 +19,7 @@ export interface BoardConfigOption extends IBaseOption
height?: number;
width?: number;
openDir?: BoardOpenDir;
cuttingProtrudingPart?: boolean; //自动按缺口尺寸绘制出异形板件
}
export interface RightPlaneLightOption

Loading…
Cancel
Save