|
|
@ -3,15 +3,14 @@ import { app } from "../ApplicationServices/Application";
|
|
|
|
import { Board } from "../DatabaseServices/Entity/Board";
|
|
|
|
import { Board } from "../DatabaseServices/Entity/Board";
|
|
|
|
import { Command } from "../Editor/CommandMachine";
|
|
|
|
import { Command } from "../Editor/CommandMachine";
|
|
|
|
import { PromptStatus } from "../Editor/PromptResult";
|
|
|
|
import { PromptStatus } from "../Editor/PromptResult";
|
|
|
|
import { ZeroVec, equalv3, isParallelTo, MoveMatrix } from "../Geometry/GeUtils";
|
|
|
|
import { ZeroVec, equalv3, isParallelTo } from "../Geometry/GeUtils";
|
|
|
|
import { BoardBatchCurtailModal, BoardBatchCurtailStore } from "../UI/Components/BoardBatchCurtailModal";
|
|
|
|
import { BoardBatchCurtailModal, BoardBatchCurtailStore, CurtailType } from "../UI/Components/BoardBatchCurtailModal";
|
|
|
|
import { ModalPosition, ModalState } from "../UI/Components/Modal/ModalsManage";
|
|
|
|
import { ModalPosition, ModalState } from "../UI/Components/Modal/ModalsManage";
|
|
|
|
import { HotCMD } from "../Hot/HotCommand";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface CurtailDataItem
|
|
|
|
interface CurtailDataItem
|
|
|
|
{
|
|
|
|
{
|
|
|
|
vec: Vector3;
|
|
|
|
vec: Vector3;
|
|
|
|
box: Box3;
|
|
|
|
indexs: number[];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
interface CurtailData
|
|
|
|
interface CurtailData
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -20,7 +19,13 @@ interface CurtailData
|
|
|
|
left: CurtailDataItem;
|
|
|
|
left: CurtailDataItem;
|
|
|
|
right: CurtailDataItem;
|
|
|
|
right: CurtailDataItem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
interface CurtailBox
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
front: Box3;
|
|
|
|
|
|
|
|
back: Box3;
|
|
|
|
|
|
|
|
left: Box3;
|
|
|
|
|
|
|
|
right: Box3;
|
|
|
|
|
|
|
|
}
|
|
|
|
export class BoardBatchCurtail implements Command
|
|
|
|
export class BoardBatchCurtail implements Command
|
|
|
|
{
|
|
|
|
{
|
|
|
|
async exec()
|
|
|
|
async exec()
|
|
|
@ -49,21 +54,27 @@ export class BoardBatchCurtail implements Command
|
|
|
|
sizeBox.union(box);
|
|
|
|
sizeBox.union(box);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let size = sizeBox.getSize(new Vector3);
|
|
|
|
|
|
|
|
let v = new Vector3(1, 1, 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//构造内缩盒子
|
|
|
|
//构造内缩盒子
|
|
|
|
let frontBox = new Box3(sizeBox.min.clone().sub(v), sizeBox.max.clone().sub(new Vector3(-1, size.y / 2, -1)));
|
|
|
|
const GenCurtailBox = (sizeBox: Box3): CurtailBox =>
|
|
|
|
let rightBox = new Box3(sizeBox.min.clone().add(new Vector3(size.x / 2, -1, -1)), sizeBox.max.clone().add(v));
|
|
|
|
{
|
|
|
|
let backBox = new Box3(sizeBox.min.clone().add(new Vector3(-1, size.y / 2, -1)), sizeBox.max.clone().add(v));
|
|
|
|
let size = sizeBox.getSize(new Vector3);
|
|
|
|
let leftBox = new Box3(sizeBox.min.clone().sub(v), sizeBox.max.sub(new Vector3(size.x / 2, -1, -1)));
|
|
|
|
let v = new Vector3(1, 1, 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let frontBox = new Box3(sizeBox.min.clone().sub(v), sizeBox.max.clone().sub(new Vector3(-1, size.y / 2, -1)));
|
|
|
|
|
|
|
|
let rightBox = new Box3(sizeBox.min.clone().add(new Vector3(size.x / 2, -1, -1)), sizeBox.max.clone().add(v));
|
|
|
|
|
|
|
|
let backBox = new Box3(sizeBox.min.clone().add(new Vector3(-1, size.y / 2, -1)), sizeBox.max.clone().add(v));
|
|
|
|
|
|
|
|
let leftBox = new Box3(sizeBox.min.clone().sub(v), sizeBox.max.clone().sub(new Vector3(size.x / 2, -1, -1)));
|
|
|
|
|
|
|
|
return { front: frontBox, right: rightBox, left: leftBox, back: backBox }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let curBox = GenCurtailBox(sizeBox);
|
|
|
|
|
|
|
|
|
|
|
|
//解析前后左右能够拉伸的范围.
|
|
|
|
//解析前后左右能够拉伸的范围.
|
|
|
|
let dx = {
|
|
|
|
let dx = {
|
|
|
|
front: { box: frontBox, index: 1 },
|
|
|
|
front: { box: curBox.front, index: 1 },
|
|
|
|
back: { box: backBox, index: 1 },
|
|
|
|
back: { box: curBox.back, index: 1 },
|
|
|
|
left: { box: leftBox, index: 0 },
|
|
|
|
left: { box: curBox.left, index: 0 },
|
|
|
|
right: { box: rightBox, index: 0 },
|
|
|
|
right: { box: curBox.right, index: 0 },
|
|
|
|
};
|
|
|
|
};
|
|
|
|
for (let key in dx)
|
|
|
|
for (let key in dx)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -91,40 +102,76 @@ export class BoardBatchCurtail implements Command
|
|
|
|
|
|
|
|
|
|
|
|
if (res.Status === ModalState.Ok)
|
|
|
|
if (res.Status === ModalState.Ok)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// 各方向拉伸所需数据: 拉伸向量, 拉伸盒子
|
|
|
|
// 各方向拉伸所需数据: 拉伸向量, 拉伸索引
|
|
|
|
let curtailData: CurtailData = {
|
|
|
|
let curtailData: CurtailData = {
|
|
|
|
front: { vec: new Vector3(0, store.m_Option.front), box: frontBox },
|
|
|
|
front: { vec: new Vector3(0, store.m_Option.front), indexs: [] },
|
|
|
|
back: { vec: new Vector3(0, -store.m_Option.back), box: backBox },
|
|
|
|
back: { vec: new Vector3(0, -store.m_Option.back), indexs: [] },
|
|
|
|
left: { vec: new Vector3(store.m_Option.left), box: leftBox },
|
|
|
|
left: { vec: new Vector3(store.m_Option.left), indexs: [] },
|
|
|
|
right: { vec: new Vector3(-store.m_Option.right), box: rightBox }
|
|
|
|
right: { vec: new Vector3(-store.m_Option.right), indexs: [] }
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
for (let key in curtailData)
|
|
|
|
//逐板内缩
|
|
|
|
|
|
|
|
if (store.m_Option.type === CurtailType.PerBr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let d = curtailData[key] as CurtailDataItem;
|
|
|
|
|
|
|
|
if (equalv3(d.vec, ZeroVec))
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (let br of brs)
|
|
|
|
for (let br of brs)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//获取索引
|
|
|
|
//逐板计算拉伸盒子
|
|
|
|
let spts = br.GetStretchPoints();
|
|
|
|
let box = br.BoundingBox;
|
|
|
|
let indexs: number[] = [];
|
|
|
|
let curBox2 = GenCurtailBox(box);
|
|
|
|
for (let i = 0; i < spts.length; i++)
|
|
|
|
let pts = br.GetStretchPoints();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (let key in curtailData)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let p = spts[i];
|
|
|
|
let d = curtailData[key] as CurtailDataItem;
|
|
|
|
p.applyMatrix4(spaceOcsInv);
|
|
|
|
d.indexs = [];
|
|
|
|
if (d.box.containsPoint(p))
|
|
|
|
//获取索引
|
|
|
|
indexs.push(i);
|
|
|
|
for (let i = 0, length = pts.length; i < length; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (curBox2[key].containsPoint(pts[i]))
|
|
|
|
|
|
|
|
d.indexs.push(i);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isParallelTo(d.vec, br.Normal))
|
|
|
|
|
|
|
|
br.MoveStretchPoints(d.indexs, d.vec);
|
|
|
|
|
|
|
|
else if (store.m_Option.moveBrs)
|
|
|
|
|
|
|
|
br.MoveStretchPoints(br.GetStretchPoints().map((v, i) => { return i }), d.vec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (indexs.length === 0) continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
//禁止拉伸厚度
|
|
|
|
//整体内缩
|
|
|
|
if (br.IsStretchThickness(indexs))
|
|
|
|
else
|
|
|
|
continue;
|
|
|
|
{
|
|
|
|
// br.ApplyMatrix(MoveMatrix(d.vec.clone().multiplyScalar(0.5)));
|
|
|
|
for (let br of brs)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//先获取索引
|
|
|
|
|
|
|
|
for (let key in curtailData)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let box = curBox[key] as Box3;
|
|
|
|
|
|
|
|
let d = curtailData[key] as CurtailDataItem;
|
|
|
|
|
|
|
|
d.indexs = [];
|
|
|
|
|
|
|
|
if (equalv3(d.vec, ZeroVec))
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let spts = br.GetStretchPoints();
|
|
|
|
|
|
|
|
for (let i = 0; i < spts.length; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let p = spts[i];
|
|
|
|
|
|
|
|
p.applyMatrix4(spaceOcsInv);
|
|
|
|
|
|
|
|
if (box.containsPoint(p))
|
|
|
|
|
|
|
|
d.indexs.push(i);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
//进行内缩
|
|
|
|
//进行内缩
|
|
|
|
br.MoveStretchPoints(indexs, d.vec);
|
|
|
|
for (let key in curtailData)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let d = curtailData[key] as CurtailDataItem;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (d.indexs.length === 0) continue;
|
|
|
|
|
|
|
|
//禁止拉伸厚度
|
|
|
|
|
|
|
|
if (br.IsStretchThickness(d.indexs))
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// br.ApplyMatrix(MoveMatrix(d.vec.clone().multiplyScalar(0.5)));
|
|
|
|
|
|
|
|
br.MoveStretchPoints(d.indexs, d.vec);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|