|
|
@ -7,6 +7,8 @@ import { BoolOpeartionType } from "../../GraphicsSystem/BoolOperateUtils";
|
|
|
|
import { equaln, isParallelTo, isPerpendicularityTo } from "../GeUtils";
|
|
|
|
import { equaln, isParallelTo, isPerpendicularityTo } from "../GeUtils";
|
|
|
|
import { ISpaceParse } from "./ISpaceParse";
|
|
|
|
import { ISpaceParse } from "./ISpaceParse";
|
|
|
|
import { Board } from "../../DatabaseServices/Entity/Board";
|
|
|
|
import { Board } from "../../DatabaseServices/Entity/Board";
|
|
|
|
|
|
|
|
import { getRectFrom4Pts } from "../../Common/CurveUtils";
|
|
|
|
|
|
|
|
import { arrayLast } from "../../Common/ArrayExt";
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 板件周围轮廓分析
|
|
|
|
* 板件周围轮廓分析
|
|
|
@ -27,13 +29,20 @@ export class SurroundOutlineParse extends ISpaceParse
|
|
|
|
for (let br of brs)
|
|
|
|
for (let br of brs)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let brNormal = br.Normal;
|
|
|
|
let brNormal = br.Normal;
|
|
|
|
|
|
|
|
|
|
|
|
let box = br.BoundingBoxInOCS;
|
|
|
|
let box = br.BoundingBoxInOCS;
|
|
|
|
|
|
|
|
let min = box.min;
|
|
|
|
|
|
|
|
let max = box.max;
|
|
|
|
|
|
|
|
//盒子8个点,避免盒子旋转后被破坏
|
|
|
|
|
|
|
|
let pts = [
|
|
|
|
|
|
|
|
min, new Vector3(max.x, min.y, min.z),
|
|
|
|
|
|
|
|
new Vector3(min.x, min.y, max.z), new Vector3(max.x, min.y, max.z),
|
|
|
|
|
|
|
|
new Vector3(min.x, max.y, min.z), new Vector3(max.x, max.y, min.z),
|
|
|
|
|
|
|
|
new Vector3(min.x, max.y, max.z), max
|
|
|
|
|
|
|
|
];
|
|
|
|
//br->ucs
|
|
|
|
//br->ucs
|
|
|
|
let mtx = new Matrix4().multiplyMatrices(ucsInv, br.OCS);
|
|
|
|
let mtx = new Matrix4().multiplyMatrices(ucsInv, br.OCS);
|
|
|
|
box.applyMatrix4(mtx);
|
|
|
|
pts.forEach(p => p.applyMatrix4(mtx));
|
|
|
|
|
|
|
|
pts.sort((p1, p2) => p1.z - p2.z);
|
|
|
|
if (isParallelTo(brNormal, ucsNormal))
|
|
|
|
if (isParallelTo(brNormal, ucsNormal))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let cu = br.ContourCurve;
|
|
|
|
let cu = br.ContourCurve;
|
|
|
@ -45,11 +54,11 @@ export class SurroundOutlineParse extends ISpaceParse
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (isPerpendicularityTo(brNormal, ucsNormal))
|
|
|
|
else if (isPerpendicularityTo(brNormal, ucsNormal))
|
|
|
|
pls.push(new Polyline().Create2Pt(box.min, box.max));
|
|
|
|
pls.push(getRectFrom4Pts(pts.slice(0, 4)));
|
|
|
|
else
|
|
|
|
else
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
maxZ = Math.max(maxZ, box.max.z);
|
|
|
|
maxZ = Math.max(maxZ, arrayLast(pts).z);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let retCus = this.GetOutline(pls);
|
|
|
|
let retCus = this.GetOutline(pls);
|
|
|
|
|
|
|
|
|
|
|
@ -93,44 +102,32 @@ export class SurroundOutlineParse extends ISpaceParse
|
|
|
|
boxes.push(box);
|
|
|
|
boxes.push(box);
|
|
|
|
boxMap.set(box, br);
|
|
|
|
boxMap.set(box, br);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
boxes.sort((b1, b2) =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let min1 = b1.min;
|
|
|
|
|
|
|
|
let min2 = b2.min;
|
|
|
|
|
|
|
|
if (!equaln(min1.x, min2.x))
|
|
|
|
|
|
|
|
return min1.x - min2.x;
|
|
|
|
|
|
|
|
else if (equaln(min1.y, min2.y))
|
|
|
|
|
|
|
|
return min1.y - min2.y;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
return min1.z - min2.z;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let originBox: Box3;
|
|
|
|
|
|
|
|
let boardList: Board[][] = [];
|
|
|
|
let boardList: Board[][] = [];
|
|
|
|
let usedBox = new WeakSet();
|
|
|
|
|
|
|
|
while (boxes.length > 0)
|
|
|
|
while (boxes.length > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
originBox = boxes.shift();
|
|
|
|
let originBox = boxes.shift();
|
|
|
|
let brs = [];
|
|
|
|
let brs = [boxMap.get(originBox)];
|
|
|
|
if (!usedBox.has(originBox))
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
usedBox.add(originBox);
|
|
|
|
let remBoxes = boxes.filter(b =>
|
|
|
|
brs.push(boxMap.get(originBox));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (let b of boxes)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (usedBox.has(b)) continue;
|
|
|
|
|
|
|
|
if (originBox.intersectsBox(b))
|
|
|
|
if (originBox.intersectsBox(b))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
originBox.union(b);
|
|
|
|
originBox.union(b);
|
|
|
|
brs.push(boxMap.get(b));
|
|
|
|
brs.push(boxMap.get(b));
|
|
|
|
usedBox.add(b);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (remBoxes.length === boxes.length)
|
|
|
|
|
|
|
|
{
|
|
|
|
boardList.push(brs);
|
|
|
|
boardList.push(brs);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
boxes = remBoxes;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return boardList;
|
|
|
|
return boardList;
|
|
|
|
}
|
|
|
|
}
|
|
|
|