|
|
|
@ -1,7 +1,6 @@
|
|
|
|
|
import { Box3, Matrix4, Vector3 } from "three";
|
|
|
|
|
import { app } from "../../ApplicationServices/Application";
|
|
|
|
|
import { arrayRemoveIf } from "../../Common/ArrayExt";
|
|
|
|
|
import { IsDev } from "../../Common/Deving";
|
|
|
|
|
import { safeEval } from "../../Common/eval";
|
|
|
|
|
import { matrixSetVector } from "../../Common/Matrix4Utils";
|
|
|
|
|
import { Board } from "../../DatabaseServices/Entity/Board";
|
|
|
|
@ -9,7 +8,7 @@ import { Polyline } from "../../DatabaseServices/Entity/Polyline";
|
|
|
|
|
import { TemplateRecord } from "../../DatabaseServices/Template/TemplateRecord";
|
|
|
|
|
import { Command } from "../../Editor/CommandMachine";
|
|
|
|
|
import { PromptStatus } from "../../Editor/PromptResult";
|
|
|
|
|
import { equaln } from "../../Geometry/GeUtils";
|
|
|
|
|
import { equaln, isParallelTo, XAxis, YAxis, ZAxis } from "../../Geometry/GeUtils";
|
|
|
|
|
import { IntersectOption } from "../../GraphicsSystem/IntersectWith";
|
|
|
|
|
import { HotCMD } from "../../Hot/HotCommand";
|
|
|
|
|
import { BoardType } from "../../UI/Store/BoardInterface";
|
|
|
|
@ -24,6 +23,7 @@ import { userConfigStore } from "../../UI/Store/UserConfigStore";
|
|
|
|
|
import { BoardModalType } from "../../UI/Components/Board/BoardModal";
|
|
|
|
|
import { UpdateBoardInfos } from "../BoardEditor/UpdateBoardInfos";
|
|
|
|
|
import { FixDigits } from "../../Common/Utils";
|
|
|
|
|
import { GetRectData } from "../../Common/CurveUtils";
|
|
|
|
|
|
|
|
|
|
const MaxBoardDistance = 200;//左右侧板,顶底板距离边缘的最大距离
|
|
|
|
|
|
|
|
|
@ -146,10 +146,8 @@ export class Polyline2Board implements Command
|
|
|
|
|
for (let pl of pls)
|
|
|
|
|
{
|
|
|
|
|
pl.ApplyMatrix(ucsinv);
|
|
|
|
|
let box = pl.BoundingBox;
|
|
|
|
|
let size = box.getSize(new Vector3);
|
|
|
|
|
pl.__CacheSize__ = size;
|
|
|
|
|
pl.__CacheBox__ = box;
|
|
|
|
|
this.ParsePolyline(pl);
|
|
|
|
|
let size = pl.__CacheSize__;
|
|
|
|
|
if (this.IsBackBoard(size))
|
|
|
|
|
backPls.push(pl);
|
|
|
|
|
else if (this.IsFaceBoard(size))
|
|
|
|
@ -590,10 +588,23 @@ export class Polyline2Board implements Command
|
|
|
|
|
}
|
|
|
|
|
let box = pl.__CacheBox__;
|
|
|
|
|
let minp = box.min.clone();
|
|
|
|
|
|
|
|
|
|
let ocs: Matrix4;
|
|
|
|
|
if (pl.TempData)
|
|
|
|
|
{
|
|
|
|
|
ocs = pl.TempData.OCS.clone();
|
|
|
|
|
minp.applyMatrix4(pl.TempData.OCS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let br: Board;
|
|
|
|
|
|
|
|
|
|
let mtx = new Matrix4().makeBasis(XAxis, ZAxis.clone().negate(), YAxis);
|
|
|
|
|
|
|
|
|
|
if (x > y && y <= this.maxThickness) //层板
|
|
|
|
|
{
|
|
|
|
|
br = Board.CreateBoard(x, depth, y, BoardType.Layer);
|
|
|
|
|
mtx.setPosition(new Vector3(x));
|
|
|
|
|
|
|
|
|
|
[minp.x, minp.y, minp.z] = [minp.x + x, minp.z, minp.y];
|
|
|
|
|
}
|
|
|
|
|
else if (x < y && x <= this.maxThickness)//立板
|
|
|
|
@ -604,6 +615,9 @@ export class Polyline2Board implements Command
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[minp.x, minp.y, minp.z] = [minp.x, minp.z + this.backBoardThick, minp.y];
|
|
|
|
|
|
|
|
|
|
mtx.setPosition(new Vector3(0, this.backBoardThick));
|
|
|
|
|
|
|
|
|
|
if (isBack)
|
|
|
|
|
{
|
|
|
|
|
minp.y += this.boardDepth - this.backBoardThick - this.backBoardMoveDis;//移动到后面
|
|
|
|
@ -613,10 +627,25 @@ export class Polyline2Board implements Command
|
|
|
|
|
|
|
|
|
|
x += this.backLeftExtend + this.backRightExtend;
|
|
|
|
|
y += this.backTopExtend + this.backDownExtend;
|
|
|
|
|
|
|
|
|
|
mtx.setPosition(new Vector3(-this.backLeftExtend, -this.backDownExtend, this.boardDepth - this.backBoardMoveDis));
|
|
|
|
|
}
|
|
|
|
|
br = Board.CreateBoard(y, x, this.backBoardThick, BoardType.Behind);
|
|
|
|
|
br.Name = this.backBrName;
|
|
|
|
|
if (!pl.TempData && !GetRectData(pl).isRect)
|
|
|
|
|
{
|
|
|
|
|
pl.Position = pl.Position.sub(box.min);
|
|
|
|
|
let con = pl.Clone();
|
|
|
|
|
con.Erase(false);
|
|
|
|
|
br.ContourCurve = con;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//被旋转的矩形
|
|
|
|
|
let mtxInv = new Matrix4().getInverse(mtx);
|
|
|
|
|
if (ocs)
|
|
|
|
|
br.ApplyMatrix(mtx).ApplyMatrix(ocs).ApplyMatrix(mtxInv);
|
|
|
|
|
|
|
|
|
|
let m = new Matrix4().setPosition(minp);
|
|
|
|
|
br.ApplyMatrix(m);
|
|
|
|
|
br.ApplyMatrix(this.SpaceOCS);
|
|
|
|
@ -634,8 +663,13 @@ export class Polyline2Board implements Command
|
|
|
|
|
//pl1是否包含pl2
|
|
|
|
|
IsPolyLineContain(pl1: Polyline, pl2: Polyline)
|
|
|
|
|
{
|
|
|
|
|
let box1 = pl1.__CacheBox__;
|
|
|
|
|
let box2 = pl2.__CacheBox__;
|
|
|
|
|
let box1 = pl1.__CacheBox__.clone();
|
|
|
|
|
let box2 = pl2.__CacheBox__.clone();
|
|
|
|
|
if (pl1.TempData)
|
|
|
|
|
box1.applyMatrix4(pl1.TempData.OCS);
|
|
|
|
|
if (pl2.TempData)
|
|
|
|
|
box2.applyMatrix4(pl2.TempData.OCS);
|
|
|
|
|
|
|
|
|
|
let box = box1.clone().intersect(box2);
|
|
|
|
|
let s = box.getSize(new Vector3);
|
|
|
|
|
if (s.x < 1 || s.y < 1) return false;
|
|
|
|
@ -651,6 +685,34 @@ export class Polyline2Board implements Command
|
|
|
|
|
|
|
|
|
|
private IsFaceBoard(size: Vector3): boolean
|
|
|
|
|
{
|
|
|
|
|
return size.x > this.maxThickness && size.y > this.maxThickness;
|
|
|
|
|
return size.x > this.maxThickness + 1e-3 && size.y > this.maxThickness + 1e-3;
|
|
|
|
|
}
|
|
|
|
|
private ParsePolyline(pl: Polyline)
|
|
|
|
|
{
|
|
|
|
|
let firstDev = pl.GetFistDeriv(0);
|
|
|
|
|
let size: Vector3;
|
|
|
|
|
let box: Box3;
|
|
|
|
|
if (isParallelTo(firstDev, XAxis) || isParallelTo(firstDev, YAxis))
|
|
|
|
|
{
|
|
|
|
|
box = pl.BoundingBox;
|
|
|
|
|
size = box.getSize(new Vector3);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
let rd = GetRectData(pl);
|
|
|
|
|
if (rd.isRect)
|
|
|
|
|
{
|
|
|
|
|
pl.TempData = rd;
|
|
|
|
|
box = rd.box;
|
|
|
|
|
size = rd.size;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
box = pl.BoundingBox;
|
|
|
|
|
size = box.getSize(new Vector3);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
pl.__CacheSize__ = size;
|
|
|
|
|
pl.__CacheBox__ = box;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|