diff --git a/__test__/Winerack/winerack.test.ts b/__test__/Winerack/winerack.test.ts index 485a5a69a..c837af544 100644 --- a/__test__/Winerack/winerack.test.ts +++ b/__test__/Winerack/winerack.test.ts @@ -46,8 +46,8 @@ describe("酒格功能测试", () => [2, "Board", 5, 2, 102, false, 1, 11, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 580.3050847457629, -214.2857142857143, 0, 1], 0, 0, 2, 2000, 600, 18, true, "Polyline", 5, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 2, 4, [0, 0], 0, [600, 0], 0, [600, 2000], 0, [0, 2000], 0, true, 0, 3, 0, 0, 0, 4, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 580.3050847457629, -214.2857142857143, 0, 1], 1, "右侧板", "主卧", "下柜", "", "", "", 0, 0, "三合一", 2, 0, "1", "1", "1", "1", "", "", "", 4, "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, "Board", 5, 2, 101, false, 1, 11, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -601.6949152542372, -214.2857142857143, 0, 1], 0, 0, 2, 2000, 600, 18, true, "Polyline", 5, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 2, 4, [0, 0], 0, [600, 0], 0, [600, 2000], 0, [0, 2000], 0, true, 0, 3, 0, 0, 0, 4, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -601.6949152542372, -214.2857142857143, 0, 1], 1, "左侧板", "主卧", "下柜", "", "", "", 0, 0, "三合一", 2, 0, "1", "1", "1", "1", "", "", "", 4, "三合一", "三合一", "三合一", "三合一", true, true, 0, 0] let spaceParse = new ISpaceParse(); - spaceParse.m_Boards = LoadEntityFromFileData(data) as Board[]; - spaceParse.m_SpaceBox = new Box3Ext(new Vector3(), new Vector3(1200, 600, 2000)); + spaceParse.Boards = LoadEntityFromFileData(data) as Board[]; + spaceParse.SpaceBox = new Box3Ext(new Vector3(), new Vector3(1200, 600, 2000)); spaceParse.Parse(); UprightTool.Parse(spaceParse, option); blisTool.Parse(spaceParse, option); diff --git a/src/Add-on/DrawBoard/DrawBehindBoard.ts b/src/Add-on/DrawBoard/DrawBehindBoard.ts index c3dfb9e5d..391ad38be 100644 --- a/src/Add-on/DrawBoard/DrawBehindBoard.ts +++ b/src/Add-on/DrawBoard/DrawBehindBoard.ts @@ -13,8 +13,8 @@ export class DrawBehindBoard extends DrawBoardTool protected drawType = BoardType.Behind; protected buildBoard(isAppendSpace = true) { - let newBox = this.space.m_SpaceBox.clone(); - let spaceOcs = this.space.m_SpaceOCS; + let newBox = this.space.SpaceBox.clone(); + let spaceOcs = this.space.SpaceOCS; const opt = this.store.m_Option as BehindBoardOption; //判断延伸 let leftExt = opt.leftExt; diff --git a/src/Add-on/DrawBoard/DrawBoardTool.ts b/src/Add-on/DrawBoard/DrawBoardTool.ts index adbc21257..227e52006 100644 --- a/src/Add-on/DrawBoard/DrawBoardTool.ts +++ b/src/Add-on/DrawBoard/DrawBoardTool.ts @@ -70,8 +70,8 @@ export abstract class DrawBoardTool implements Command break; this.space = selectSpace.SpaceParse; //用周围板件加工数据 - if (this.store.UseBoardProcessOption && this.space.m_Boards.length > 0) - this.store.GetBoardProcessOption(this.space.m_Boards[0]); + if (this.store.UseBoardProcessOption && this.space.Boards.length > 0) + this.store.GetBoardProcessOption(this.space.Boards[0]); this.buildBoard(); diff --git a/src/Add-on/DrawBoard/DrawClosingStrip.ts b/src/Add-on/DrawBoard/DrawClosingStrip.ts index 38e8f814d..585ae510d 100644 --- a/src/Add-on/DrawBoard/DrawClosingStrip.ts +++ b/src/Add-on/DrawBoard/DrawClosingStrip.ts @@ -58,7 +58,7 @@ export class DrawClosingStrip implements Command await spaceParse.Parse(); while (true) { - this.buildClosingStrip(spaceParse.m_SpaceBox, spaceParse.m_SpaceOCS); + this.buildClosingStrip(spaceParse.SpaceBox, spaceParse.SpaceOCS); AppToaster.show({ message: "收口条已绘制", timeout: 1000 diff --git a/src/Add-on/DrawBoard/DrawDoor.ts b/src/Add-on/DrawBoard/DrawDoor.ts index 43b421b7c..9ccac345a 100644 --- a/src/Add-on/DrawBoard/DrawDoor.ts +++ b/src/Add-on/DrawBoard/DrawDoor.ts @@ -28,7 +28,7 @@ export class DrawDoor implements Command let size = spaceParse.Size; let store = DoorStore.GetInstance() as DoorStore; - const surroundOption = spaceParse.m_Boards[0].BoardProcessOption; + const surroundOption = spaceParse.Boards[0].BoardProcessOption; store.m_Option.boardName = surroundOption.cabinetName; store.totalHeight = safeEval(ToFixed(size.z, 2)); store.totalWidth = safeEval(ToFixed(size.x, 2)); @@ -40,7 +40,7 @@ export class DrawDoor implements Command if (res.Status === ModalState.Ok) { - let min = spaceParse.m_SpaceBox.min; + let min = spaceParse.SpaceBox.min; store.doorPosition.copy(min); store.CalcDoorsInfo(true); @@ -132,7 +132,7 @@ export class DrawDoor implements Command } for (let br of [...doors, ...verBrs, ...layerBrs]) { - br.ApplyMatrix(spaceParse.m_SpaceOCS); + br.ApplyMatrix(spaceParse.SpaceOCS); app.Database.ModelSpace.Append(br); } diff --git a/src/Add-on/DrawBoard/DrawDrawer.ts b/src/Add-on/DrawBoard/DrawDrawer.ts index 191068d26..b58649751 100644 --- a/src/Add-on/DrawBoard/DrawDrawer.ts +++ b/src/Add-on/DrawBoard/DrawDrawer.ts @@ -20,7 +20,7 @@ export class DrawDrawrer implements Command let size = spaceParse.Size; let store = DrawerStore.GetInstance() as DrawerStore; - store.m_Option.boardName = spaceParse.m_Boards[0].BoardProcessOption.cabinetName; + store.m_Option.boardName = spaceParse.Boards[0].BoardProcessOption.cabinetName; store.totalHeight = safeEval(FixedNotZero(size.z, 2)); store.totalWidth = safeEval(FixedNotZero(size.x, 2)); store.totalDepth = safeEval(FixedNotZero(size.y, 2)); diff --git a/src/Add-on/DrawBoard/DrawLayerBoard.ts b/src/Add-on/DrawBoard/DrawLayerBoard.ts index 2fe55e7e7..98da3c233 100644 --- a/src/Add-on/DrawBoard/DrawLayerBoard.ts +++ b/src/Add-on/DrawBoard/DrawLayerBoard.ts @@ -32,8 +32,8 @@ export class DrawLayerBoard extends DrawBoardTool protected buildBoard(isAppendSpace = true) { const opt = this.store.m_Option as LayerBoardOption; - let spaceBox = this.space.m_SpaceBox; - let spaceOCS = this.space.m_SpaceOCS; + let spaceBox = this.space.SpaceBox; + let spaceOCS = this.space.SpaceOCS; let size = spaceBox.getSize(new Vector3()); let width: number; @@ -154,19 +154,19 @@ export class DrawLayerBoard extends DrawBoardTool } parseHasLRBoard() { - let minX = this.space.m_SpaceBox.min.x; - let maxX = this.space.m_SpaceBox.max.x; + let minX = this.space.SpaceBox.min.x; + let maxX = this.space.SpaceBox.max.x; const nailOpt = (this.store as LayerBoardStore).layerNailOption; //如果层板和左右板得距离大于这个值,则这边不绘制层板钉 let refDist = nailOpt.length - nailOpt.depth; - let vertBrs: Board[] = this.space.m_BoardMap.get(BoardType.Vertical); + let vertBrs: Board[] = this.space.BoardMap.get(BoardType.Vertical); if (vertBrs && vertBrs.length > 0) { if (vertBrs.length === 1) { - let center = this.space.m_SpaceBox.getCenter(new Vector3); - let pos = vertBrs[0].Position.applyMatrix4(this.space.m_SpaceOCSInv); + let center = this.space.SpaceBox.getCenter(new Vector3); + let pos = vertBrs[0].Position.applyMatrix4(this.space.SpaceOCSInv); if (pos.x < center.x) this.leftBoard = vertBrs[0]; else @@ -176,13 +176,13 @@ export class DrawLayerBoard extends DrawBoardTool { vertBrs.sort((br1, br2) => { - return br1.MinPoint.applyMatrix4(this.space.m_SpaceOCSInv).x - br2.MinPoint.applyMatrix4(this.space.m_SpaceOCSInv).x; + return br1.MinPoint.applyMatrix4(this.space.SpaceOCSInv).x - br2.MinPoint.applyMatrix4(this.space.SpaceOCSInv).x; }); let lBr = vertBrs[0]; let rBr = arrayLast(vertBrs); - let pos1 = lBr.Position.applyMatrix4(this.space.m_SpaceOCSInv); - let pos2 = rBr.Position.applyMatrix4(this.space.m_SpaceOCSInv); + let pos1 = lBr.Position.applyMatrix4(this.space.SpaceOCSInv); + let pos2 = rBr.Position.applyMatrix4(this.space.SpaceOCSInv); if (Math.abs(pos1.x - minX + lBr.Thickness) < refDist) this.leftBoard = lBr; @@ -194,13 +194,13 @@ export class DrawLayerBoard extends DrawBoardTool //允许在背板绘制层板钉 if (nailOpt.isInBack) { - let backBrs = this.space.m_BoardMap.get(BoardType.Behind); - let maxY = this.space.m_SpaceBox.max.y; + let backBrs = this.space.BoardMap.get(BoardType.Behind); + let maxY = this.space.SpaceBox.max.y; if (backBrs && backBrs.length === 1) { let backBr = backBrs[0]; - let backPos = backBr.Position.applyMatrix4(this.space.m_SpaceOCSInv); + let backPos = backBr.Position.applyMatrix4(this.space.SpaceOCSInv); if (Math.abs(backPos.y - maxY - backBr.Thickness) < refDist) this.backBoard = backBr } diff --git a/src/Add-on/DrawBoard/DrawTopBottomBoard.ts b/src/Add-on/DrawBoard/DrawTopBottomBoard.ts index d0444ab80..8c417ac24 100644 --- a/src/Add-on/DrawBoard/DrawTopBottomBoard.ts +++ b/src/Add-on/DrawBoard/DrawTopBottomBoard.ts @@ -1,17 +1,17 @@ -import { Vector3 } from 'three'; -import { app } from '../../ApplicationServices/Application'; -import { log } from '../../Common/Utils'; -import { Board, BoardType } from '../../DatabaseServices/Entity/Board'; -import { Command } from '../../Editor/CommandMachine'; -import { MoveMatrix } from '../../Geometry/GeUtils'; -import { ISpaceParse } from '../../Geometry/SpaceParse/ISpaceParse'; -import { PointSelectSpaceSurround } from '../../Geometry/SpaceParse/PointSelectSpaceSurround'; -import { BoardModal, BoardModalType } from '../../UI/Components/Board/BoardModal'; -import { ModalPosition, ModalState } from '../../UI/Components/Modal/ModalsManage'; -import { BoardData, ComposingType, FaceDirection, TBBoardOption, LinesType } from '../../UI/Store/BoardInterface'; -import { TopBottomBoardStore } from '../../UI/Store/BoardStore'; -import { EBoardKeyList } from '../../Common/BoardKeyList'; -import { JigUtils } from '../../Editor/JigUtils'; +import { Vector3 } from "three"; +import { app } from "../../ApplicationServices/Application"; +import { EBoardKeyList } from "../../Common/BoardKeyList"; +import { log } from "../../Common/Utils"; +import { Board, BoardType } from "../../DatabaseServices/Entity/Board"; +import { Command } from "../../Editor/CommandMachine"; +import { JigUtils } from "../../Editor/JigUtils"; +import { MoveMatrix } from "../../Geometry/GeUtils"; +import { ISpaceParse } from "../../Geometry/SpaceParse/ISpaceParse"; +import { PointSelectSpaceClamp } from "../../Geometry/SpaceParse/PointSelectSpaceClamp"; +import { BoardModal, BoardModalType } from "../../UI/Components/Board/BoardModal"; +import { ModalPosition, ModalState } from "../../UI/Components/Modal/ModalsManage"; +import { BoardData, ComposingType, FaceDirection, LinesType, TBBoardOption } from "../../UI/Store/BoardInterface"; +import { TopBottomBoardStore } from "../../UI/Store/BoardStore"; export class DrawTopBottomBoard implements Command { @@ -25,10 +25,10 @@ export class DrawTopBottomBoard implements Command if (res.Status === ModalState.Ok) { - let selectSpace = new PointSelectSpaceSurround(); + let selectSpace = new PointSelectSpaceClamp(); await selectSpace.Select(() => { - if (selectSpace.SpaceParse && selectSpace.SpaceParse.m_SpaceBox) + if (selectSpace.SpaceParse && selectSpace.SpaceParse.ParseOK) this.Draw(selectSpace.SpaceParse, false); }); if (!selectSpace.ParseOK) @@ -42,49 +42,35 @@ export class DrawTopBottomBoard implements Command private GetTopBoardBasePt(opt: TBBoardOption, spc: ISpaceParse) { - let box = spc.m_SpaceBox; + let box = spc.SpaceBox; let min = box.min; let max = box.max; let basePoint = new Vector3(); if (opt.isWrapSide) { - basePoint.set( - max.x + spc.m_RightBoard.Thickness, - min.y, - max.z - ) + let rightBoardThickness = spc.RightBoard ? spc.RightBoard.Thickness : opt.thickness; + basePoint.set(max.x + rightBoardThickness, min.y, max.z); } else { - basePoint.set( - max.x, - min.y, - max.z - (opt.thickness + opt.offset) - ) + basePoint.set(max.x, min.y, max.z - (opt.thickness + opt.offset)); } return basePoint; } private GetBottomBoardBasePt(opt: TBBoardOption, spc: ISpaceParse) { - let box = spc.m_SpaceBox; + let box = spc.SpaceBox; let min = box.min; let max = box.max; let basePoint = new Vector3(); if (opt.isWrapSide) { - basePoint.set( - max.x + spc.m_RightBoard.Thickness, - min.y, - min.z - opt.thickness - ); + let rightBoardThickness = spc.RightBoard ? spc.RightBoard.Thickness : opt.thickness; + basePoint.set(max.x + rightBoardThickness, min.y, min.z - opt.thickness); } else { - basePoint.set( - max.x, - min.y, - min.z + opt.offset - ); + basePoint.set(max.x, min.y, min.z + opt.offset); } return basePoint; } @@ -92,7 +78,7 @@ export class DrawTopBottomBoard implements Command { const opt = data.boardConfig as TBBoardOption; if (this.store.UseBoardProcessOption) - this.store.GetBoardProcessOption(spaceParse.m_LeftBoard); + this.store.GetBoardProcessOption(spaceParse.Boards[0]); //前 let frontDist = opt.frontDist; @@ -107,8 +93,9 @@ export class DrawTopBottomBoard implements Command let thickness = opt.thickness; if (opt.isWrapSide) { - length += - (spaceParse.m_LeftBoard.Thickness + spaceParse.m_RightBoard.Thickness + leftExt + rightExt); + let leftBoardThickness = spaceParse.LeftBoard ? spaceParse.LeftBoard.Thickness : opt.thickness; + let rightBoardThickness = spaceParse.RightBoard ? spaceParse.RightBoard.Thickness : opt.thickness; + length += leftBoardThickness + rightBoardThickness + leftExt + rightExt; } else { @@ -128,7 +115,7 @@ export class DrawTopBottomBoard implements Command //移动右缩和前距的距离 basePt.add(new Vector3(rightExt, -frontDist)); board.ApplyMatrix(MoveMatrix(basePt)); - board.ApplyMatrix(spaceParse.m_SpaceOCS); + board.ApplyMatrix(spaceParse.SpaceOCS); if (isAppendSpace) app.Database.ModelSpace.Append(board); else @@ -147,9 +134,9 @@ export class DrawTopBottomBoard implements Command footBoard.BoardProcessOption.composingFace = ComposingType.Reverse; footBoard.BoardProcessOption.bigHoleDir = FaceDirection.Back; footBoard.BoardProcessOption.lines = LinesType.Reverse; - let moveDist = isBack ? spaceParse.Size.y - opt.footerOffset : thickness + opt.footBehindShrink - footBoard.ApplyMatrix(MoveMatrix(spaceParse.m_SpaceBox.min.clone().add(new Vector3(0, moveDist)))) - .ApplyMatrix(spaceParse.m_SpaceOCS); + let moveDist = isBack ? spaceParse.Size.y - opt.footerOffset : thickness + opt.footBehindShrink; + footBoard.ApplyMatrix(MoveMatrix(spaceParse.SpaceBox.min.clone().add(new Vector3(0, moveDist)))) + .ApplyMatrix(spaceParse.SpaceOCS); if (isAppendSpace) app.Database.ModelSpace.Append(footBoard); else @@ -173,8 +160,8 @@ export class DrawTopBottomBoard implements Command { let b = br.Clone(); b.Name = "加强条" + i; - b.ApplyMatrix(MoveMatrix(spaceParse.m_SpaceBox.min.clone().add(new Vector3(spaceSize * i + (i - 1) * thickness, thickness + opt.footBehindShrink)))) - .ApplyMatrix(spaceParse.m_SpaceOCS); + b.ApplyMatrix(MoveMatrix(spaceParse.SpaceBox.min.clone().add(new Vector3(spaceSize * i + (i - 1) * thickness, thickness + opt.footBehindShrink)))) + .ApplyMatrix(spaceParse.SpaceOCS); if (isAppendSpace) app.Database.ModelSpace.Append(b); else @@ -222,14 +209,14 @@ export class DrawTopBottomBoard implements Command if (bottomOpt.isDrawFooter && !bottomOpt.isWrapSide) { this.DrawFootBoard(bottomOpt, space, false, isAppendSpace); - refSize -= (thickness + bottomOpt.footBehindShrink); + refSize -= thickness + bottomOpt.footBehindShrink; } //绘制后地脚 if (bottomOpt.isDrawBackFooter && !bottomOpt.isWrapSide) { this.DrawFootBoard(bottomOpt, space, true, isAppendSpace); - refSize -= (thickness + bottomOpt.footerOffset); + refSize -= thickness + bottomOpt.footerOffset; } //绘制加强条 this.DrawStrengthenStrip(bottomOpt, space, refSize, isAppendSpace); diff --git a/src/Add-on/DrawBoard/DrawVerticalBoard.ts b/src/Add-on/DrawBoard/DrawVerticalBoard.ts index e03b43a77..0123f8311 100644 --- a/src/Add-on/DrawBoard/DrawVerticalBoard.ts +++ b/src/Add-on/DrawBoard/DrawVerticalBoard.ts @@ -12,8 +12,8 @@ export class DrawVerticalBoard extends DrawBoardTool protected drawType = BoardType.Vertical; protected buildBoard(isAppendSpace = true) { - const spaceBox = this.space.m_SpaceBox; - const spaceOCS = this.space.m_SpaceOCS; + const spaceBox = this.space.SpaceBox; + const spaceOCS = this.space.SpaceOCS; const opt = this.store.m_Option as VerticalBoardOption; let size = spaceBox.getSize(new Vector3()); diff --git a/src/Add-on/DrawTopline.ts b/src/Add-on/DrawTopline.ts index 11268e632..5c017d361 100644 --- a/src/Add-on/DrawTopline.ts +++ b/src/Add-on/DrawTopline.ts @@ -47,7 +47,7 @@ async function handleBoard(outline: Polyline, brs: Board[]) let spaceParse = new SurroundOutlineParse(brs); await spaceParse.Parse(); - let cus = spaceParse.m_Outlines; + let cus = spaceParse.Outlines; for (let cu of cus) JigUtils.Draw(cu); diff --git a/src/Add-on/DrawWineRack/DrawBlisWineRackTool.ts b/src/Add-on/DrawWineRack/DrawBlisWineRackTool.ts index 54ac1a623..c7e069f55 100644 --- a/src/Add-on/DrawWineRack/DrawBlisWineRackTool.ts +++ b/src/Add-on/DrawWineRack/DrawBlisWineRackTool.ts @@ -631,14 +631,14 @@ export class DrawBlisWineRackTool extends DrawWineRackTool br.ContourCurve = pl; this.ParseHighSealing(br, config.leftEdge, config.rightEdge, config.topEdge, config.bottomEdge, d.isLeft); br.RotateBoard(0, Math.PI / 4 * (d.isLeft ? -1 : 1), 0); - br.ApplyMatrix(MoveMatrix(this.space.m_SpaceBox.min)); + br.ApplyMatrix(MoveMatrix(this.space.SpaceBox.min)); br.ApplyMatrix(MoveMatrix(d.basePt)); if ((config.fullType === EFullType.ByHeight || config.arrayType === EWRackArrayType.Fixed) && config.fullDir === EFullDir.Right) { br.ApplyMatrix(MoveMatrix(new Vector3(this.space.Size.x - actualWidth))); } - br.ApplyMatrix(this.space.m_SpaceOCS); + br.ApplyMatrix(this.space.SpaceOCS); this.boardlist.push(br); } } diff --git a/src/Add-on/DrawWineRack/DrawUprightWineRackTool.ts b/src/Add-on/DrawWineRack/DrawUprightWineRackTool.ts index c3bccc36a..e4348f0c6 100644 --- a/src/Add-on/DrawWineRack/DrawUprightWineRackTool.ts +++ b/src/Add-on/DrawWineRack/DrawUprightWineRackTool.ts @@ -85,7 +85,7 @@ export class DrawUprightWineRackTool extends DrawWineRackTool BuildBoard(gripHeight: number, spaceWidth: number, spaceHeight: number, space: ISpaceParse) { const config = this.Config; - let min = space.m_SpaceBox.min; + let min = space.SpaceBox.min; let size = space.Size; let brThick = config.boardThick; @@ -95,7 +95,7 @@ export class DrawUprightWineRackTool extends DrawWineRackTool { let br = verBr.Clone(); br.Name = "右板" + i; - br.ApplyMatrix(MoveMatrix(min.clone().add(new Vector3(config.gripWidth * i + (i - 1) * brThick)))).ApplyMatrix(space.m_SpaceOCS); + br.ApplyMatrix(MoveMatrix(min.clone().add(new Vector3(config.gripWidth * i + (i - 1) * brThick)))).ApplyMatrix(space.SpaceOCS); this.boardlist.push(br); } @@ -107,7 +107,7 @@ export class DrawUprightWineRackTool extends DrawWineRackTool br.Name = "左板" + i; br.ApplyMatrix(MoveMatrix( min.clone().add(new Vector3(spaceWidth, 0, gripHeight * i + (i - 1) * brThick)))) - .ApplyMatrix(space.m_SpaceOCS); + .ApplyMatrix(space.SpaceOCS); this.boardlist.push(br); } } diff --git a/src/Add-on/DrawWineRack/DrawWinRackTool.ts b/src/Add-on/DrawWineRack/DrawWinRackTool.ts index 9d96143ac..c87b31e9a 100644 --- a/src/Add-on/DrawWineRack/DrawWinRackTool.ts +++ b/src/Add-on/DrawWineRack/DrawWinRackTool.ts @@ -28,22 +28,22 @@ export class DrawWineRackTool extends Singleton let depth = safeEval(config.calcDepth, { L: space.Size.x, W: space.Size.y, H: space.Size.z });; if (!isNaN(depth)) { - space.m_SpaceBox.max.setY(space.m_SpaceBox.min.y + depth); + space.SpaceBox.max.setY(space.SpaceBox.min.y + depth); } } //处理前缩 - space.m_SpaceBox.min.add(new Vector3(0, config.frontCut)); + space.SpaceBox.min.add(new Vector3(0, config.frontCut)); //左右缩 - space.m_SpaceBox.min.add(new Vector3(config.leftCut)); - space.m_SpaceBox.max.add(new Vector3(-config.rightCut)); + space.SpaceBox.min.add(new Vector3(config.leftCut)); + space.SpaceBox.max.add(new Vector3(-config.rightCut)); //上缩 - space.m_SpaceBox.max.add(new Vector3(0, 0, -config.topCut)); + space.SpaceBox.max.add(new Vector3(0, 0, -config.topCut)); } /** 拾取空间周围的板件柜名房名等信息*/ protected GetBoardProcessOption(br: Board) { //获取空间周围的板件数据 - let refProcessData = this.space.m_Boards[0].BoardProcessOption; + let refProcessData = this.space.Boards[0].BoardProcessOption; br.BoardProcessOption.roomName = refProcessData.roomName; br.BoardProcessOption.boardName = refProcessData.boardName; br.BoardProcessOption.material = refProcessData.material; @@ -104,7 +104,7 @@ export class DrawWineRackTool extends Singleton let length = actWidth; let width = size.y + config.frontCut; - let position = this.space.m_SpaceBox.min.clone(); + let position = this.space.SpaceBox.min.clone(); if (config.arrayType === EWRackArrayType.Fixed) { @@ -128,7 +128,7 @@ export class DrawWineRackTool extends Singleton this.GetBoardProcessOption(br); br.BoardProcessOption.bigHoleDir = FaceDirection.Back; br.Position = position; - br.ApplyMatrix(this.space.m_SpaceOCS); + br.ApplyMatrix(this.space.SpaceOCS); this.boardlist.push(br); } if (config.isDrawVer && (config.arrayType === EWRackArrayType.Fixed || config.fullType === EFullType.ByHeight)) @@ -139,7 +139,7 @@ export class DrawWineRackTool extends Singleton let br = Board.CreateBoard(len, size.y + config.frontCut, config.brThick2, BoardType.Vertical); - let position = this.space.m_SpaceBox.min.clone(); + let position = this.space.SpaceBox.min.clone(); if (config.fullDir === EFullDir.Right) position.add(new Vector3(size.x - actWidth - config.brThick2)); @@ -150,7 +150,7 @@ export class DrawWineRackTool extends Singleton } this.GetBoardProcessOption(br); br.Position = position; - br.ApplyMatrix(this.space.m_SpaceOCS); + br.ApplyMatrix(this.space.SpaceOCS); this.boardlist.push(br); } } diff --git a/src/Add-on/Gesture/Gesture_DrawLayerBoard.ts b/src/Add-on/Gesture/Gesture_DrawLayerBoard.ts index cd7bd6328..6982d2d8f 100644 --- a/src/Add-on/Gesture/Gesture_DrawLayerBoard.ts +++ b/src/Add-on/Gesture/Gesture_DrawLayerBoard.ts @@ -29,10 +29,10 @@ export async function Gesture_DrawLayerBoard(dirs: GestureDir[], path: Vector2[] let spaceParse = new ClampSpaceParseRay(ptSelect.SelectBoards).SetRay(ptSelect.Ray); await spaceParse.Parse(); - if (!spaceParse.m_ParseOK) + if (!spaceParse.ParseOK) return; - let box = spaceParse.m_SpaceBox; + let box = spaceParse.SpaceBox; let size = box.getSize(new Vector3()); let br: Board; @@ -47,7 +47,7 @@ export async function Gesture_DrawLayerBoard(dirs: GestureDir[], path: Vector2[] br.ApplyMatrix(MoveMatrix(new Vector3(size.x / 2, 0, 0).sub(br.MinPoint).add(box.min))); } - br.ApplyMatrix(spaceParse.m_SpaceOCS); + br.ApplyMatrix(spaceParse.SpaceOCS); commandMachine.CommandStart("gs") diff --git a/src/Add-on/LatticeDrawer/LatticeDrawerTool.ts b/src/Add-on/LatticeDrawer/LatticeDrawerTool.ts index 7c4c51b9c..7b8334580 100644 --- a/src/Add-on/LatticeDrawer/LatticeDrawerTool.ts +++ b/src/Add-on/LatticeDrawer/LatticeDrawerTool.ts @@ -51,7 +51,7 @@ export class DrawLatticeDrawerTool extends Singleton config.gripWidth = gripWidth; config.gripDepth = gripDepth; - let position = space.m_SpaceBox.min.clone(); + let position = space.SpaceBox.min.clone(); let verBr = Board.CreateBoard(size.z, size.y, config.thickness, BoardType.Vertical); this.WriteBoardProcessOption(verBr); @@ -69,7 +69,7 @@ export class DrawLatticeDrawerTool extends Singleton let pos = position.clone(); pos.add(new Vector3(gripWidth * i + (i - 1) * config.thickness)); br.Position = pos; - br.ApplyMatrix(space.m_SpaceOCS); + br.ApplyMatrix(space.SpaceOCS); app.Database.ModelSpace.Append(br); } @@ -85,7 +85,7 @@ export class DrawLatticeDrawerTool extends Singleton let pos = position.clone(); pos.add(new Vector3(0, (gripDepth + config.thickness) * i)); br.Position = pos; - br.ApplyMatrix(space.m_SpaceOCS); + br.ApplyMatrix(space.SpaceOCS); app.Database.ModelSpace.Append(br); } @@ -94,7 +94,7 @@ export class DrawLatticeDrawerTool extends Singleton private HandleSpace() { const config = this.Config; - let box = this.space.m_SpaceBox; + let box = this.space.SpaceBox; box.max.add(new Vector3(0, 0, -this.Config.downDist)); //处理间隙 box.min.add(new Vector3(config.space, config.space)); @@ -107,7 +107,7 @@ export class DrawLatticeDrawerTool extends Singleton let addH = backPos.y + this.backBr.Height - this.frontBr.Height; if (addH > 0) { - this.space.m_SpaceBox.max.add(new Vector3(0, 0, addH)); + this.space.SpaceBox.max.add(new Vector3(0, 0, addH)); if (config.isAuto) config.arcLen = addH; } @@ -194,31 +194,31 @@ export class DrawLatticeDrawerTool extends Singleton } private ParseSpaceBrs() { - let vertBrs: Board[] = this.space.m_BoardMap.get(BoardType.Vertical); + let vertBrs: Board[] = this.space.BoardMap.get(BoardType.Vertical); if (vertBrs && vertBrs.length > 1) { vertBrs.sort((br1, br2) => { - return br1.Position.applyMatrix4(this.space.m_SpaceOCSInv).x - br2.Position.applyMatrix4(this.space.m_SpaceOCSInv).x; + return br1.Position.applyMatrix4(this.space.SpaceOCSInv).x - br2.Position.applyMatrix4(this.space.SpaceOCSInv).x; }); this.leftBr = vertBrs[0]; this.rightBr = arrayLast(vertBrs); } - let behindBrs = this.space.m_BoardMap.get(BoardType.Behind); + let behindBrs = this.space.BoardMap.get(BoardType.Behind); if (behindBrs && behindBrs.length > 1) { behindBrs.sort((br1, br2) => { - return br1.Position.applyMatrix4(this.space.m_SpaceOCSInv).y - br2.Position.applyMatrix4(this.space.m_SpaceOCSInv).y; + return br1.Position.applyMatrix4(this.space.SpaceOCSInv).y - br2.Position.applyMatrix4(this.space.SpaceOCSInv).y; }); this.backBr = arrayLast(behindBrs); this.frontBr = behindBrs[0]; } - let lyBrs = this.space.m_BoardMap.get(BoardType.Layer); + let lyBrs = this.space.BoardMap.get(BoardType.Layer); this.haveTopBr = lyBrs && lyBrs.length > 1; } private ParseArcLenOrObliuqeAng(br: Board) diff --git a/src/DatabaseServices/Entity/Board.ts b/src/DatabaseServices/Entity/Board.ts index 33a315086..a59f08be5 100644 --- a/src/DatabaseServices/Entity/Board.ts +++ b/src/DatabaseServices/Entity/Board.ts @@ -544,11 +544,17 @@ export class Board extends ExtrudeSolid this.m_BoardProcessOption.highDrill = Array(cu.EndParam).fill(defaultType); super.ContourCurve = cu; } - GetBoardBoxInMat(mtx: Matrix4): Box3Ext + + GetBoardBoxInMtx(mtx: Matrix4): Box3Ext { - let mtxC = mtx.clone().multiply(this.OCS); - return this.BoundingBoxInOCS.applyMatrix4(mtxC); + return this.BoundingBoxInOCS.applyMatrix4(this.OCS.premultiply(mtx)); } + + get BoundingBoxInSpaceCS(): Box3Ext + { + return this.GetBoardBoxInMtx(this.SpaceOCSInv); + } + Explode() { return Board2Regions(this); diff --git a/src/DatabaseServices/Template/Positioning/PositioningClampSpace.ts b/src/DatabaseServices/Template/Positioning/PositioningClampSpace.ts index 6d3343b08..3c3476dd8 100644 --- a/src/DatabaseServices/Template/Positioning/PositioningClampSpace.ts +++ b/src/DatabaseServices/Template/Positioning/PositioningClampSpace.ts @@ -20,7 +20,7 @@ export class PositioningClampSpace extends Positioning FromSpaceParse(parse: ClampSpaceParse) { this.SignalDist = parse.SignalDist || 100; - this.Objects = parse.m_Boards.map(br => br.Id); + this.Objects = parse.Boards.map(br => br.Id); for (let [splitType, index] of parse.SelectBoxRecord) this.SelectBoxIndex[splitType] = index; } @@ -38,10 +38,10 @@ export class PositioningClampSpace extends Positioning parse.SignalDist = this.SignalDist; await parse.Parse(); - if (parse.m_ParseOK) + if (parse.ParseOK) { - this.SpaceCS = parse.m_SpaceOCS; - let p = parse.m_SpaceBox.min.clone().applyMatrix4(this.SpaceCS); + this.SpaceCS = parse.SpaceOCS; + let p = parse.SpaceBox.min.clone().applyMatrix4(this.SpaceCS); this.SpaceCS.setPosition(p); this.SpaceSize = parse.Size; } diff --git a/src/DatabaseServices/Template/TemplateTest.ts b/src/DatabaseServices/Template/TemplateTest.ts index d7ef3ea40..90cafa308 100644 --- a/src/DatabaseServices/Template/TemplateTest.ts +++ b/src/DatabaseServices/Template/TemplateTest.ts @@ -471,7 +471,7 @@ export class TemplateAttach } let parse = selectSpace.SpaceParse as ClampSpaceParse; - let brs = parse.m_Boards; + let brs = parse.Boards; let positioning = new PositioningClampSpace(); positioning.FromSpaceParse(parse); @@ -531,7 +531,7 @@ export class TemplateAttach2 } let parse = selectSpace.SpaceParse as ClampSpaceParse; - let brs = parse.m_Boards; + let brs = parse.Boards; let positioning = new PositioningClampSpace(); positioning.FromSpaceParse(parse); @@ -613,7 +613,7 @@ export class TemplateAttach3 } let parse = selectSpace.SpaceParse as ClampSpaceParse; - let brs = parse.m_Boards; + let brs = parse.Boards; let positioning = new PositioningClampSpace(); positioning.FromSpaceParse(parse); @@ -764,7 +764,7 @@ export class Command_TemplateWineRack app.Editor.Prompt("未能分析出有效空间!"); return; } - let brs = selectSpace.SpaceParse.m_Boards; + let brs = selectSpace.SpaceParse.Boards; let tbrs = brs.filter(br => br.Template !== undefined); tbrs.sort((b1, b2) => { diff --git a/src/DatabaseServices/Template/TemplateWineRackRecord.ts b/src/DatabaseServices/Template/TemplateWineRackRecord.ts index 73f3fb87e..0aab3ca93 100644 --- a/src/DatabaseServices/Template/TemplateWineRackRecord.ts +++ b/src/DatabaseServices/Template/TemplateWineRackRecord.ts @@ -67,8 +67,8 @@ export class TemplateWineRackRecord extends TemplateRecord } let space = new ISpaceParse(brs, this._CacheSpaceCS); - space.m_ParseOK = true; - space.m_SpaceBox = new Box3Ext(new Vector3(), this._CacheSpaceSize); + space.ParseOK = true; + space.SpaceBox = new Box3Ext(new Vector3(), this._CacheSpaceSize); wineRack.Parse(space, this.option); diff --git a/src/Geometry/DrillParse/CollisionDetection.ts b/src/Geometry/DrillParse/CollisionDetection.ts index 2e39f2b75..22cace475 100644 --- a/src/Geometry/DrillParse/CollisionDetection.ts +++ b/src/Geometry/DrillParse/CollisionDetection.ts @@ -24,7 +24,7 @@ export class CollisionDetection if (b.BoardProcessOption.drillType !== DrillType.None) { this.m_BoardGeList.push(new BoardGetFace(b)); - boxCache.set(b, b.GetBoardBoxInMat(ocsInv)); + boxCache.set(b, b.GetBoardBoxInMtx(ocsInv)); } } diff --git a/src/Geometry/SpaceParse/ClampSpaceParse.ts b/src/Geometry/SpaceParse/ClampSpaceParse.ts index ceab4df5a..1c1c1a0d3 100644 --- a/src/Geometry/SpaceParse/ClampSpaceParse.ts +++ b/src/Geometry/SpaceParse/ClampSpaceParse.ts @@ -12,7 +12,7 @@ export class ClampSpaceParse extends ISpaceParse { async Parse() { - if (this.m_Boards.length === 1) + if (this.Boards.length === 1) { await this.ParseSignalBoard(); return; @@ -22,13 +22,13 @@ export class ClampSpaceParse extends ISpaceParse let clampBoxs: Box3Ext[] = []; //单层空间(用于切割) let spliteBoxs = new Map(); - for (let [boardType, boards] of this.m_BoardMap) + for (let [boardType, boards] of this.BoardMap) { let splitType: SplitType = ConverBoardTypeToSpaceType(boardType); let boardBoxCol = this.ParseBoardBox(boards, splitType); //#IWFYY - if (boardType === BoardType.Behind && this.m_BoardMap.size > 1 && boardBoxCol.length > 1) + if (boardType === BoardType.Behind && this.BoardMap.size > 1 && boardBoxCol.length > 1) { let clampBox = boardBoxCol[0].clampSpace(boardBoxCol[1], splitType); let size = clampBox.getSize(new Vector3()); @@ -64,14 +64,14 @@ export class ClampSpaceParse extends ISpaceParse //切割并选择合适的空间 await this.SpliteBoxsAndSelect(allSpaceBox, spliteBoxs); - if (this.m_SpaceBox && this.m_SpaceBox.isSolid()) + if (this.SpaceBox && this.SpaceBox.isSolid()) { //空间延伸到背板 let behindBox = spliteBoxs.get(SplitType.Y); - if (behindBox && behindBox.min.y > this.m_SpaceBox.min.y) - this.m_SpaceBox.max.setY(behindBox.min.y); + if (behindBox && behindBox.min.y > this.SpaceBox.min.y) + this.SpaceBox.max.setY(behindBox.min.y); - this.m_ParseOK = true; + this.ParseOK = true; } } @@ -92,9 +92,9 @@ export class ClampSpaceParse extends ISpaceParse let dist = res.Distance; this._signalDist = dist; - let br = this.m_Boards[0]; + let br = this.Boards[0]; - let mtx = this.m_SpaceOCSInv.clone().multiply(br.OCS); + let mtx = this.SpaceOCSInv.clone().multiply(br.OCS); let p1 = new Vector3(0, 0, 0).applyMatrix4(mtx); let p2 = new Vector3(br.Width, br.Height, -dist).applyMatrix4(mtx); let p3 = new Vector3(0, 0, br.Thickness).applyMatrix4(mtx); @@ -102,13 +102,13 @@ export class ClampSpaceParse extends ISpaceParse let boxs = [new Box3Ext().setFromPoints([p1, p2]), new Box3Ext().setFromPoints([p3, p4])]; - this.m_SpaceBox = await this.WrapSelectBox(boxs, ConverBoardTypeToSpaceType(br.BoardType)); + this.SpaceBox = await this.WrapSelectBox(boxs, ConverBoardTypeToSpaceType(br.BoardType)); - if (this.m_SpaceBox) - this.m_ParseOK = true; + if (this.SpaceBox) + this.ParseOK = true; } else - this.m_ParseOK = false; + this.ParseOK = false; } //virtual (请重载) 指定用户选择单块板的延伸空间 @@ -148,10 +148,10 @@ export class ClampSpaceParse extends ISpaceParse */ private async SpliteBoxsAndSelect(orgBox: Box3Ext, spliteBoxes: Map) { - this.m_SpaceBox = undefined; + this.SpaceBox = undefined; if (spliteBoxes.size === 0) { - this.m_SpaceBox = orgBox; + this.SpaceBox = orgBox; return; } @@ -169,7 +169,16 @@ export class ClampSpaceParse extends ISpaceParse } else orgBox = await this.WrapSelectBox(remBoxs, splitType); + + //Left Or Right Board + if (splitType === SplitType.X) + { + if (spBox.min.x < orgBox.min.x) + this.LeftBoard = this.BoardMap.get(BoardType.Vertical)[0]; + else + this.RightBoard = this.BoardMap.get(BoardType.Vertical)[0]; + } } - this.m_SpaceBox = orgBox; + this.SpaceBox = orgBox; } } diff --git a/src/Geometry/SpaceParse/ClampSpaceParseDist.ts b/src/Geometry/SpaceParse/ClampSpaceParseDist.ts index 82a1d7392..ba4d3b363 100644 --- a/src/Geometry/SpaceParse/ClampSpaceParseDist.ts +++ b/src/Geometry/SpaceParse/ClampSpaceParseDist.ts @@ -8,6 +8,13 @@ export class ClampSpaceParseDist extends ClampSpaceParse //virtual (请重载) 指定用户选择单块板的延伸空间 async GetSignalDist(): Promise { + if (this.IsDynamic) + { + let res = new PromptDistendResult(); + res.Status = PromptStatus.OK; + res.Distance = Default; + return res; + } let res = await app.Editor.GetDistance({ Default }); if (res.Status === PromptStatus.OK) Default = res.Distance; diff --git a/src/Geometry/SpaceParse/ClampSpaceParseKey.ts b/src/Geometry/SpaceParse/ClampSpaceParseKey.ts index 4f61e60e1..3516f1917 100644 --- a/src/Geometry/SpaceParse/ClampSpaceParseKey.ts +++ b/src/Geometry/SpaceParse/ClampSpaceParseKey.ts @@ -16,6 +16,9 @@ export class ClampSpaceParseKey extends ClampSpaceParseDist */ async SelectBox(splitBoxs: Box3Ext[], splitType: SplitType): Promise { + if (this.IsDynamic) + return splitBoxs[0]; + let keywords = [ [{ key: "1", msg: "靠左" }, { key: "2", msg: "靠右" }], [{ key: "1", msg: "靠前" }, { key: "2", msg: "靠后" }], diff --git a/src/Geometry/SpaceParse/ClampSpaceParseRay.ts b/src/Geometry/SpaceParse/ClampSpaceParseRay.ts index eb10bf820..864a9e7ea 100644 --- a/src/Geometry/SpaceParse/ClampSpaceParseRay.ts +++ b/src/Geometry/SpaceParse/ClampSpaceParseRay.ts @@ -10,7 +10,7 @@ export class ClampSpaceParseRay extends ClampSpaceParseDist SetRay(ray: Ray) { this.selectRay = ray; - this.selectRay.applyMatrix4(this.m_SpaceOCSInv); + this.selectRay.applyMatrix4(this.SpaceOCSInv); return this; } diff --git a/src/Geometry/SpaceParse/ISpaceParse.ts b/src/Geometry/SpaceParse/ISpaceParse.ts index ad4976483..d2310b371 100644 --- a/src/Geometry/SpaceParse/ISpaceParse.ts +++ b/src/Geometry/SpaceParse/ISpaceParse.ts @@ -2,40 +2,43 @@ import { Matrix4, Vector3 } from "three"; import { arrayRemoveDuplicateBySort2 } from "../../Common/ArrayExt"; import { Board, BoardType } from "../../DatabaseServices/Entity/Board"; import { Box3Ext, SplitType } from "../Box"; -import { XAxis, YAxis, ZAxis, ZeroVec, equaln, equalv3 } from "../GeUtils"; -import { FuzzDirection } from "../FuzzVector"; - +import { equaln, isParallelTo, XAxis, YAxis, ZAxis } from "../GeUtils"; export class ISpaceParse { /** - * 解析空间成功 - */ - m_ParseOK = false; + * 解析空间成功 + */ + ParseOK = false; /** * 空间占地盒子 */ - m_SpaceBox: Box3Ext; + SpaceBox: Box3Ext; /** * 空间盒子所在的位置矩阵 */ - m_SpaceOCS: Matrix4; - m_SpaceOCSInv: Matrix4; + SpaceOCS: Matrix4; + SpaceOCSInv: Matrix4; /** * 板件映射表 */ - m_BoardMap: Map = new Map(); + BoardMap: Map = new Map(); /** * 解析空间所用的板件列表 */ - m_Boards: Board[]; + Boards: Board[]; + + LeftBoard: Board; + RightBoard: Board; - m_LeftBoard: Board; - m_RightBoard: Board; + /** + * 动态中,禁止执行二次操作 + */ + IsDynamic: Boolean = false; /** * # 构造后请手动调用Parse()方法. @@ -44,15 +47,15 @@ export class ISpaceParse */ constructor(boards?: Board[], spaceOCS?: Matrix4) { - this.m_Boards = boards; + this.Boards = boards; if (spaceOCS) - this.m_SpaceOCS = spaceOCS; + this.SpaceOCS = spaceOCS; else if (boards && boards.length > 0) - this.m_SpaceOCS = boards[0].SpaceOCS; + this.SpaceOCS = boards[0].SpaceOCS; else - this.m_SpaceOCS = new Matrix4(); + this.SpaceOCS = new Matrix4(); - this.m_SpaceOCSInv = new Matrix4().getInverse(this.m_SpaceOCS); + this.SpaceOCSInv = new Matrix4().getInverse(this.SpaceOCS); this.GeneralBoardMap(); } @@ -63,8 +66,8 @@ export class ISpaceParse get Size() { - if (this.m_SpaceBox) - return this.m_SpaceBox.getSize(new Vector3()); + if (this.SpaceBox) + return this.SpaceBox.getSize(new Vector3()); return new Vector3(); } @@ -73,31 +76,27 @@ export class ISpaceParse */ protected GeneralBoardMap() { - if (this.m_Boards && this.m_Boards.length > 0) + if (this.Boards && this.Boards.length > 0) { - this.m_BoardMap.clear(); - let spaceOCSInv = this.m_SpaceOCSInv.clone().setPosition(ZeroVec); + this.BoardMap.clear(); - let fuzzNormal = new FuzzDirection(); - - for (let br of this.m_Boards) + for (let br of this.Boards) { //使用板件向量判断类型,而不是板件类型 - let normal = br.Normal.applyMatrix4(spaceOCSInv); - fuzzNormal.GetKey(normal, true); + let normal = br.Normal.transformDirection(this.SpaceOCSInv); let type: BoardType; - if (equalv3(XAxis, normal)) + if (isParallelTo(XAxis, normal)) type = BoardType.Vertical; - else if (equalv3(YAxis, normal)) + else if (isParallelTo(YAxis, normal)) type = BoardType.Behind; - else if (equalv3(ZAxis, normal)) + else if (isParallelTo(ZAxis, normal)) type = BoardType.Layer; - let brs = this.m_BoardMap.get(type); + let brs = this.BoardMap.get(type); if (brs) brs.push(br); else - this.m_BoardMap.set(br.BoardType, [br]); + this.BoardMap.set(br.BoardType, [br]); } } } @@ -108,7 +107,35 @@ export class ISpaceParse */ protected ParseBoardBox(boardCol: Board[], splitType: SplitType): Box3Ext[] { - let boxCol = boardCol.map(b => { return b.GetBoardBoxInMat(this.m_SpaceOCSInv) }); + let boxCol = boardCol.map(b => b.GetBoardBoxInMtx(this.SpaceOCSInv)); + + //查找最左的板和最右的板 + if (splitType === SplitType.X) + { + let minX = Infinity; + let leftIndex = 0; + let maxX = -Infinity; + let rightIndex = 0; + + for (let i = 0; i < boxCol.length; i++) + { + let box = boxCol[i]; + if (box.min.x < minX) + { + minX = box.min.x; + leftIndex = i; + } + + if (box.max.x > maxX) + { + maxX = box.max.x; + rightIndex = i; + } + } + + this.LeftBoard = boardCol[leftIndex]; + this.RightBoard = boardCol[rightIndex]; + } //根据分割类型排序 boxCol.sort((b1, b2) => diff --git a/src/Geometry/SpaceParse/Point2SpaceParse.ts b/src/Geometry/SpaceParse/Point2SpaceParse.ts index aafae5d74..28065c6af 100644 --- a/src/Geometry/SpaceParse/Point2SpaceParse.ts +++ b/src/Geometry/SpaceParse/Point2SpaceParse.ts @@ -27,41 +27,41 @@ export class Point2SpaceParse extends ISpaceParse lastDepth = distRes.Distance; - this.m_SpaceOCS = app.Editor.UCSMatrix; - this.m_SpaceOCS.setPosition(rectRes.Point1WCS); - this.m_SpaceOCSInv = new Matrix4().getInverse(this.m_SpaceOCS); - let p1 = rectRes.Point1WCS.clone().applyMatrix4(this.m_SpaceOCSInv); - let p2 = rectRes.Point2WCS.clone().applyMatrix4(this.m_SpaceOCSInv).setZ(0); + this.SpaceOCS = app.Editor.UCSMatrix; + this.SpaceOCS.setPosition(rectRes.Point1WCS); + this.SpaceOCSInv = new Matrix4().getInverse(this.SpaceOCS); + let p1 = rectRes.Point1WCS.clone().applyMatrix4(this.SpaceOCSInv); + let p2 = rectRes.Point2WCS.clone().applyMatrix4(this.SpaceOCSInv).setZ(0); - this.m_SpaceBox = new Box3Ext().setFromPoints([p1, p2]); - this.m_SpaceBox.max.setZ(lastDepth); + this.SpaceBox = new Box3Ext().setFromPoints([p1, p2]); + this.SpaceBox.max.setZ(lastDepth); - let y = new Vector3().setFromMatrixColumn(this.m_SpaceOCS, 1); + let y = new Vector3().setFromMatrixColumn(this.SpaceOCS, 1); if (equalv3(y, ZAxis))//侧视图 { - let z = new Vector3().setFromMatrixColumn(this.m_SpaceOCS, 2); - matrixSetVector(this.m_SpaceOCS, 1, z.negate()); - matrixSetVector(this.m_SpaceOCS, 2, y); + let z = new Vector3().setFromMatrixColumn(this.SpaceOCS, 2); + matrixSetVector(this.SpaceOCS, 1, z.negate()); + matrixSetVector(this.SpaceOCS, 2, y); - [this.m_SpaceBox.min.y, this.m_SpaceBox.min.z] = [this.m_SpaceBox.min.z, this.m_SpaceBox.min.y]; - [this.m_SpaceBox.max.y, this.m_SpaceBox.max.z] = [this.m_SpaceBox.max.z, this.m_SpaceBox.max.y]; + [this.SpaceBox.min.y, this.SpaceBox.min.z] = [this.SpaceBox.min.z, this.SpaceBox.min.y]; + [this.SpaceBox.max.y, this.SpaceBox.max.z] = [this.SpaceBox.max.z, this.SpaceBox.max.y]; - this.m_SpaceOCSInv = new Matrix4().getInverse(this.m_SpaceOCS); + this.SpaceOCSInv = new Matrix4().getInverse(this.SpaceOCS); } //选择周围的板件 - this.m_Boards = []; + this.Boards = []; let dcs = app.Viewer.DCS; for (let p of [rectRes.Point1WCS, rectRes.Point2WCS]) { let vp = p.applyMatrix4(dcs); let boardSel = PointPick(vp, app.Viewer, { filterTypes: [Board] }).map(GetEntity) as Board[]; - this.m_Boards.push(...boardSel); + this.Boards.push(...boardSel); } - if (this.m_Boards.length === 0) - this.m_Boards.push(new Board); + if (this.Boards.length === 0) + this.Boards.push(new Board); - this.m_ParseOK = true; + this.ParseOK = true; } } diff --git a/src/Geometry/SpaceParse/Point3SpaceParse,.ts b/src/Geometry/SpaceParse/Point3SpaceParse,.ts index 6b20bbde7..c314970ea 100644 --- a/src/Geometry/SpaceParse/Point3SpaceParse,.ts +++ b/src/Geometry/SpaceParse/Point3SpaceParse,.ts @@ -8,7 +8,7 @@ import { isPerpendicularityTo } from "../GeUtils"; import { ISpaceParse } from "./ISpaceParse"; import { PointSelectBoards } from "./PointSelectBoards"; -let lastDepth = 10; +let lastDepth = 600; export class Point3SpaceParse extends ISpaceParse { @@ -64,32 +64,32 @@ export class Point3SpaceParse extends ISpaceParse let spaceOcs = new Matrix4().makeBasis(xVec, yVec, zVec); spaceOcs.setPosition(basePt); - this.m_SpaceOCS = spaceOcs; + this.SpaceOCS = spaceOcs; - this.m_SpaceOCSInv = new Matrix4().getInverse(spaceOcs); + this.SpaceOCSInv = new Matrix4().getInverse(spaceOcs); let ptsWCS = [basePt, xRes.Point, zRes.Point]; - let ptsSCS = ptsWCS.map(p => p.clone().applyMatrix4(this.m_SpaceOCSInv)); + let ptsSCS = ptsWCS.map(p => p.clone().applyMatrix4(this.SpaceOCSInv)); let box = new Box3Ext().setFromPoints(ptsSCS); box.max.sub(box.min).setY(lastDepth); box.min.set(0, 0, 0); - this.m_SpaceBox = box; + this.SpaceBox = box; //选择周围的板件 - this.m_Boards = []; + this.Boards = []; let dcs = app.Viewer.DCS; for (let p of ptsWCS) { let vp = p.applyMatrix4(dcs); let boardSel = new PointSelectBoards(vp, app.Viewer, app.Viewer.Scene.children); - this.m_Boards.push(...boardSel.SelectBoards); + this.Boards.push(...boardSel.SelectBoards); } - if (this.m_Boards.length === 0) - this.m_Boards.push(new Board); + if (this.Boards.length === 0) + this.Boards.push(new Board); - this.m_ParseOK = true; + this.ParseOK = true; } } diff --git a/src/Geometry/SpaceParse/PointSelectSpace.ts b/src/Geometry/SpaceParse/PointSelectSpace.ts index dd766fb4d..ffb72010a 100644 --- a/src/Geometry/SpaceParse/PointSelectSpace.ts +++ b/src/Geometry/SpaceParse/PointSelectSpace.ts @@ -62,7 +62,10 @@ export class PointSelectSpace timeId = setTimeout(async () => { JigUtils.Destroy(); - await this.PointParseSpace(true, callback); + await this.PointParseSpace(true); + this.ShowSpaceBox(); + if (callback) + await callback(); }, 30); } }); @@ -98,13 +101,13 @@ export class PointSelectSpace else { if (this.SpaceParse) - this.SpaceParse.m_ParseOK = false; + this.SpaceParse.ParseOK = false; } } get ParseOK(): boolean { - return this.SpaceParse !== undefined && this.SpaceParse.m_ParseOK; + return this.SpaceParse !== undefined && this.SpaceParse.ParseOK; } /** @@ -119,7 +122,7 @@ export class PointSelectSpace * Virtual * @param ptSelect */ - protected async ParseByPointSelect(ptSelect: PointSelectBoards) + protected async ParseByPointSelect(ptSelect: PointSelectBoards, isDynamic = false) { } protected async ParseBy2Point() @@ -129,35 +132,22 @@ export class PointSelectSpace { } - private async PointParseSpace(isDynamic = false, callback?: Function) + private async PointParseSpace(isDynamic = false) { let view = app.Viewer; let vcs = app.Editor.MouseCtrl.m_CurMousePointVCS; let ptSelect = new PointSelectBoards(vcs, view, view.VisibleObjects); - if (isDynamic) - { - if (ptSelect.SelectBoards.length >= 2) - { - await this.ParseByPointSelect(ptSelect); - this.ShowSpaceBox(); - if (callback) - callback(); - } - } + if (ptSelect.SelectBoards.length === 0 && !isDynamic) + app.Editor.Prompt("请选择有效的板件,或者周围没有效板件"); else - { - if (ptSelect.SelectBoards.length === 0) - app.Editor.Prompt("请选择有效的板件,或者周围没有效板件"); - else - await this.ParseByPointSelect(ptSelect); - } + await this.ParseByPointSelect(ptSelect, isDynamic); } private ShowSpaceBox() { if (this.ParseOK) { - let box = this.SpaceParse.m_SpaceBox; + let box = this.SpaceParse.SpaceBox; let size = box.getSize(new Vector3); let min = box.min.clone(); let max = box.max.clone(); @@ -173,7 +163,7 @@ export class PointSelectSpace [alignDim, alignDim2, alignDim3, boxSolid].forEach(l => { - l.ApplyMatrix(this.SpaceParse.m_SpaceOCS); + l.ApplyMatrix(this.SpaceParse.SpaceOCS); JigUtils.Draw(l); }); } diff --git a/src/Geometry/SpaceParse/PointSelectSpaceClamp.ts b/src/Geometry/SpaceParse/PointSelectSpaceClamp.ts index c4c59cb22..8c1dad36d 100644 --- a/src/Geometry/SpaceParse/PointSelectSpaceClamp.ts +++ b/src/Geometry/SpaceParse/PointSelectSpaceClamp.ts @@ -8,25 +8,29 @@ import { Point3SpaceParse } from "./Point3SpaceParse,"; export class PointSelectSpaceClamp extends PointSelectSpace { - protected async ParseBySelect(brs: Board[]) + protected async ParseBySelect(brs: Board[], isDynamic = false) { this.SpaceParse = new ClampSpaceParseKey(brs); + this.SpaceParse.IsDynamic = isDynamic; await this.SpaceParse.Parse(); } - protected async ParseByPointSelect(ptSelect: PointSelectBoards) + protected async ParseByPointSelect(ptSelect: PointSelectBoards, isDynamic = false) { this.SpaceParse = new ClampSpaceParseRay(ptSelect.SelectBoards).SetRay(ptSelect.Ray); + this.SpaceParse.IsDynamic = isDynamic; await this.SpaceParse.Parse(); } - protected async ParseBy2Point() + protected async ParseBy2Point(isDynamic = false) { this.SpaceParse = new Point2SpaceParse(); + this.SpaceParse.IsDynamic = isDynamic; await this.SpaceParse.Parse(); } - protected async ParseBy3Point() + protected async ParseBy3Point(isDynamic = false) { this.SpaceParse = new Point3SpaceParse(); + this.SpaceParse.IsDynamic = isDynamic; await this.SpaceParse.Parse(); } } diff --git a/src/Geometry/SpaceParse/PointSelectSpaceSurround.ts b/src/Geometry/SpaceParse/PointSelectSpaceSurround.ts index e7a89bc37..8ff2afe67 100644 --- a/src/Geometry/SpaceParse/PointSelectSpaceSurround.ts +++ b/src/Geometry/SpaceParse/PointSelectSpaceSurround.ts @@ -3,6 +3,9 @@ import { PointSelectBoards } from "./PointSelectBoards"; import { PointSelectSpace } from "./PointSelectSpace"; import { SurroundSpaceParse } from "./SurroundSpaceParse"; +/** + * (弃用) 原顶底板空间分析 + */ export class PointSelectSpaceSurround extends PointSelectSpace { protected async ParseBySelect(brs: Board[]) diff --git a/src/Geometry/SpaceParse/SurroundOutlineParse.ts b/src/Geometry/SpaceParse/SurroundOutlineParse.ts index d25c56563..3f7ce12f3 100644 --- a/src/Geometry/SpaceParse/SurroundOutlineParse.ts +++ b/src/Geometry/SpaceParse/SurroundOutlineParse.ts @@ -16,7 +16,7 @@ import { arrayLast } from "../../Common/ArrayExt"; export class SurroundOutlineParse extends ISpaceParse { Polylines: Polyline[] = []; - m_Outlines: Curve[] = []; + Outlines: Curve[] = []; async Parse() { let ucsNormal = new Vector3().setFromMatrixColumn(app.Editor.UCSMatrix, 2); @@ -70,7 +70,7 @@ export class SurroundOutlineParse extends ISpaceParse for (let cu of retCus) cu.ApplyMatrix(ucs); - this.m_Outlines.push(...retCus); + this.Outlines.push(...retCus); } } private GetOutline(cus: Curve[]) @@ -96,9 +96,9 @@ export class SurroundOutlineParse extends ISpaceParse { let boxMap: Map = new Map(); let boxes: Box3[] = []; - for (let br of this.m_Boards) + for (let br of this.Boards) { - let box = br.GetBoardBoxInMat(this.m_SpaceOCSInv); + let box = br.GetBoardBoxInMtx(this.SpaceOCSInv); boxes.push(box); boxMap.set(box, br); } diff --git a/src/Geometry/SpaceParse/SurroundSpaceParse.ts b/src/Geometry/SpaceParse/SurroundSpaceParse.ts index b8ef9d5a4..301672bf1 100644 --- a/src/Geometry/SpaceParse/SurroundSpaceParse.ts +++ b/src/Geometry/SpaceParse/SurroundSpaceParse.ts @@ -7,49 +7,49 @@ import { ClampSpaceParseKey } from "./ClampSpaceParseKey"; import { ISpaceParse } from "./ISpaceParse"; /** - * 绘制顶底板所需要的空间 + * (弃用)绘制顶底板所需要的空间 */ export class SurroundSpaceParse extends ISpaceParse { async Parse() { - let vertBrs: Board[] = this.m_BoardMap.get(BoardType.Vertical); + let vertBrs: Board[] = this.BoardMap.get(BoardType.Vertical); if (!vertBrs || vertBrs.length < 2) return;//出错 - this.m_SpaceOCS = vertBrs[0].SpaceOCS; - this.m_SpaceOCSInv = new Matrix4().getInverse(this.m_SpaceOCS); + this.SpaceOCS = vertBrs[0].SpaceOCS; + this.SpaceOCSInv = new Matrix4().getInverse(this.SpaceOCS); vertBrs.sort((br1, br2) => { - return br1.MinPoint.applyMatrix4(this.m_SpaceOCSInv).x - br2.MinPoint.applyMatrix4(this.m_SpaceOCSInv).x; + return br1.MinPoint.applyMatrix4(this.SpaceOCSInv).x - br2.MinPoint.applyMatrix4(this.SpaceOCSInv).x; }); - this.m_LeftBoard = vertBrs[0]; - this.m_RightBoard = vertBrs[1]; + this.LeftBoard = vertBrs[0]; + this.RightBoard = vertBrs[1]; //必须平行 - if (isParallelTo(this.m_LeftBoard.Normal, this.m_RightBoard.Normal)) + if (isParallelTo(this.LeftBoard.Normal, this.RightBoard.Normal)) { - let brs = [this.m_LeftBoard, this.m_RightBoard]; + let brs = [this.LeftBoard, this.RightBoard]; - let beBrs = this.m_BoardMap.get(BoardType.Behind); + let beBrs = this.BoardMap.get(BoardType.Behind); if (beBrs && beBrs.length > 0) { beBrs.sort((br1, br2) => { - return br2.Position.applyMatrix4(this.m_SpaceOCSInv).y - br1.Position.applyMatrix4(this.m_SpaceOCSInv).y; + return br2.Position.applyMatrix4(this.SpaceOCSInv).y - br1.Position.applyMatrix4(this.SpaceOCSInv).y; }); brs.push(beBrs[0]); } - let clampSpace = new ClampSpaceParseKey(brs, this.m_SpaceOCS); + let clampSpace = new ClampSpaceParseKey(brs, this.SpaceOCS); await clampSpace.Parse(); - if (clampSpace.m_ParseOK) + if (clampSpace.ParseOK) { - this.m_SpaceBox = clampSpace.m_SpaceBox; + this.SpaceBox = clampSpace.SpaceBox; - this.m_ParseOK = true; + this.ParseOK = true; if (brs.length <= 2) await this.ParseStandBoard(); } @@ -60,33 +60,33 @@ export class SurroundSpaceParse extends ISpaceParse */ async ParseStandBoard() { - let size = this.m_SpaceBox.getSize(new Vector3()); + let size = this.SpaceBox.getSize(new Vector3()); - if (!equaln(size.y, this.m_LeftBoard.Width) || !equaln(size.y, this.m_RightBoard.Width)) + if (!equaln(size.y, this.LeftBoard.Width) || !equaln(size.y, this.RightBoard.Width)) { let enRes = await app.Editor.GetEntity({ Msg: "宽度不一致,请选择基准板:", Filter: { filterFunction: (o, br) => { - return br === this.m_LeftBoard || br === this.m_RightBoard; + return br === this.LeftBoard || br === this.RightBoard; } } }); if (enRes.Status !== PromptStatus.OK) { - this.m_ParseOK = false; + this.ParseOK = false; return; } let br = enRes.Entity as Board; let mp = br.MinPoint; - mp.applyMatrix4(this.m_SpaceOCSInv); + mp.applyMatrix4(this.SpaceOCSInv); - this.m_SpaceBox.min.y = mp.y; - this.m_SpaceBox.max.y = mp.y + br.Width; + this.SpaceBox.min.y = mp.y; + this.SpaceBox.max.y = mp.y + br.Width; } } } diff --git a/src/Geometry/SpaceParse/TotalSpaceParse.ts b/src/Geometry/SpaceParse/TotalSpaceParse.ts index 200ca03b8..12e6685a1 100644 --- a/src/Geometry/SpaceParse/TotalSpaceParse.ts +++ b/src/Geometry/SpaceParse/TotalSpaceParse.ts @@ -8,14 +8,14 @@ export class TotalSpaceParse extends ISpaceParse { async Parse() { - if (this.m_Boards.length > 0) + if (this.Boards.length > 0) { - this.m_SpaceBox = new Box3Ext(); + this.SpaceBox = new Box3Ext(); - for (let br of this.m_Boards) - this.m_SpaceBox.union(br.GetBoardBoxInMat(this.m_SpaceOCSInv)); + for (let br of this.Boards) + this.SpaceBox.union(br.GetBoardBoxInMtx(this.SpaceOCSInv)); - this.m_ParseOK = true; + this.ParseOK = true; } } } diff --git a/src/UI/Components/Template/TemplateComponent.tsx b/src/UI/Components/Template/TemplateComponent.tsx index 4ab3e054a..c60fef18e 100644 --- a/src/UI/Components/Template/TemplateComponent.tsx +++ b/src/UI/Components/Template/TemplateComponent.tsx @@ -269,11 +269,11 @@ export class TemplateManage extends React.Component<{}, {}> { template = br.Template.Object as TemplateRecord; template = template.Root; - let seleteBrs = parse.m_Boards.filter(b => b.Template !== undefined); + let seleteBrs = parse.Boards.filter(b => b.Template !== undefined); - if (parse.m_Boards.length > 0) + if (parse.Boards.length > 0) { - let process = parse.m_Boards[0].BoardProcessOption; + let process = parse.Boards[0].BoardProcessOption; for (let b of nents) { b.BoardProcessOption[EBoardKeyList.RoomName] = process[EBoardKeyList.RoomName]; @@ -307,7 +307,7 @@ export class TemplateManage extends React.Component<{}, {}> { if (ens.length > 0) { - let parseOCS = parse.m_SpaceOCS.clone().setPosition(parse.m_SpaceBox.min.clone().applyMatrix4(parse.m_SpaceOCS)); + let parseOCS = parse.SpaceOCS.clone().setPosition(parse.SpaceBox.min.clone().applyMatrix4(parse.SpaceOCS)); let mtx = ens[0].SpaceOCSInv.premultiply(parseOCS); for (let e of ens) e.ApplyMatrix(mtx); diff --git a/src/UI/Store/BoardInterface.ts b/src/UI/Store/BoardInterface.ts index 48cd0fcc9..c050a7895 100644 --- a/src/UI/Store/BoardInterface.ts +++ b/src/UI/Store/BoardInterface.ts @@ -211,7 +211,7 @@ export interface TBBoardOption extends BoardConfigOption isDraw: boolean; frontDist: number; //前距 behindDistance: number; //后距 - isWrapSide: boolean; + isWrapSide: boolean; //顶包侧 useLFData: boolean; leftExt: number; rightExt: number;