顶底板使用夹层空间分析,完善旋转板件空间分析的支持

pull/457/MERGE
ChenX 5 years ago
parent 8603e83fb5
commit e25f20baad

@ -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);

@ -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;

@ -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();

@ -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

@ -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);
}

@ -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));

@ -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
}

@ -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);

@ -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());

@ -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);

@ -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);
}
}

@ -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);
}
}

@ -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);
}
}

@ -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")

@ -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)

@ -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);

@ -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;
}

@ -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) =>
{

@ -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);

@ -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));
}
}

@ -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<SplitType, Box3Ext>();
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<SplitType, Box3Ext>)
{
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;
}
}

@ -8,6 +8,13 @@ export class ClampSpaceParseDist extends ClampSpaceParse
//virtual (请重载) 指定用户选择单块板的延伸空间
async GetSignalDist(): Promise<PromptDistendResult>
{
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;

@ -16,6 +16,9 @@ export class ClampSpaceParseKey extends ClampSpaceParseDist
*/
async SelectBox(splitBoxs: Box3Ext[], splitType: SplitType): Promise<Box3Ext>
{
if (this.IsDynamic)
return splitBoxs[0];
let keywords = [
[{ key: "1", msg: "靠左" }, { key: "2", msg: "靠右" }],
[{ key: "1", msg: "靠前" }, { key: "2", msg: "靠后" }],

@ -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;
}

@ -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<BoardType, Board[]> = new Map();
BoardMap: Map<BoardType, Board[]> = new Map();
/**
*
*/
m_Boards: Board[];
Boards: Board[];
m_LeftBoard: Board;
m_RightBoard: Board;
LeftBoard: Board;
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);
let fuzzNormal = new FuzzDirection();
this.BoardMap.clear();
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) =>

@ -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;
}
}

@ -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;
}
}

@ -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();
}
}
else
{
if (ptSelect.SelectBoards.length === 0)
if (ptSelect.SelectBoards.length === 0 && !isDynamic)
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);
});
}

@ -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();
}
}

@ -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[])

@ -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<Box3, Board> = 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);
}

@ -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;
}
}
}

@ -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;
}
}
}

@ -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);

@ -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;

Loading…
Cancel
Save