!440 fix #IZXMP 柜体旋转后,柜体轮廓错误

pull/440/MERGE
ZoeLeeFZ 5 years ago committed by ChenX
parent e6b3a5493b
commit bc58ca3b9e

@ -582,3 +582,22 @@ export function IsRect(cu: Curve): { isRect: boolean, size?: Vector3, box?: Box3
} }
return { isRect: false }; return { isRect: false };
} }
/**用4个矩形点构造矩形 */
export function getRectFrom4Pts(pts: Vector3[])
{
if (pts.length !== 4) return;
let p = pts.shift();
pts.sort((p1, p2) => p.distanceTo(p1) - p.distanceTo(p2));
pts.splice(1, 0, p);
let lineData = pts.map(p =>
{
return {
pt: new Vector2(p.x, p.y),
bul: 0
}
});
let l = new Polyline(lineData);
l.CloseMark = true;
return l;
}

@ -28,8 +28,6 @@ export class UserConfig
let type = sessionStorage.getItem(StoreageKeys.RenderType); let type = sessionStorage.getItem(StoreageKeys.RenderType);
if (type) if (type)
this._renderType = parseFloat(type); this._renderType = parseFloat(type);
this.openExactDrill = localStorage.getItem(StoreageKeys.ExactDrill) === "true";
} }
set RenderType(t: RenderType) set RenderType(t: RenderType)
{ {

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

@ -3,7 +3,6 @@ import { observer } from 'mobx-react';
import * as React from 'react'; import * as React from 'react';
import { app } from '../../../../ApplicationServices/Application'; import { app } from '../../../../ApplicationServices/Application';
import { UserConfig } from '../../../../Editor/UserConfig'; import { UserConfig } from '../../../../Editor/UserConfig';
import { StoreageKeys } from '../../../../Common/KeyEnum';
interface IConfigProps interface IConfigProps
{ {
@ -36,15 +35,6 @@ export class DrawConfigPanel extends React.Component<IConfigProps, {}> {
checked={userConfig.openDrillingReactor} checked={userConfig.openDrillingReactor}
onChange={this.toggleDrillingReactor} onChange={this.toggleDrillingReactor}
/> />
<Checkbox
label="精确排钻"
checked={userConfig.openExactDrill}
onChange={() =>
{
userConfig.openExactDrill = !userConfig.openExactDrill;
localStorage.setItem(StoreageKeys.ExactDrill, String(userConfig.openExactDrill))
}}
/>
<H5></H5> <H5></H5>
<Checkbox <Checkbox
label="自动切割" label="自动切割"

Loading…
Cancel
Save