|
|
|
@ -7,27 +7,52 @@ import { Intent } from "../../Common/Toaster";
|
|
|
|
|
import { GetEntity } from "../../Common/Utils";
|
|
|
|
|
import { Board } from "../../DatabaseServices/Entity/Board";
|
|
|
|
|
import { PointPick, Raycast } from "../../Editor/PointPick";
|
|
|
|
|
import { PromptStatus } from "../../Editor/PromptResult";
|
|
|
|
|
import { PromptRectResult, PromptStatus } from "../../Editor/PromptResult";
|
|
|
|
|
import { Filter } from "../../Editor/SelectFilter";
|
|
|
|
|
import { userConfig } from "../../Editor/UserConfig";
|
|
|
|
|
import { RenderType } from "../../GraphicsSystem/RenderType";
|
|
|
|
|
import { BoardModalType } from "../../UI/Components/Board/BoardModalType";
|
|
|
|
|
import { DialogUserConfig } from "../../UI/Components/Board/UserConfigComponent";
|
|
|
|
|
import { AppToaster } from "../../UI/Components/Toaster";
|
|
|
|
|
import { userConfigStore } from "../../UI/Store/UserConfigStore";
|
|
|
|
|
import { Box3Ext } from "../Box";
|
|
|
|
|
import { isParallelTo, isPerpendicularityTo } from "../GeUtils";
|
|
|
|
|
import { ClampSpaceParseRay } from "./ClampSpaceParseRay";
|
|
|
|
|
import { ISpaceParse } from "./ISpaceParse";
|
|
|
|
|
import { PointSelectBoards } from "./PointSelectBoards";
|
|
|
|
|
import { spaceParseStore } from "./SpaceParseStore";
|
|
|
|
|
|
|
|
|
|
let lastDepth = 600;
|
|
|
|
|
export class Point2SpaceParse extends ISpaceParse
|
|
|
|
|
{
|
|
|
|
|
async Parse()
|
|
|
|
|
{
|
|
|
|
|
let rectRes = await app.Editor.GetRectPoint();
|
|
|
|
|
let store = spaceParseStore;
|
|
|
|
|
let config = new DialogUserConfig(store, BoardModalType.SpaceParse);
|
|
|
|
|
await config.LoadAndInitConfig();//载入或者初始化
|
|
|
|
|
|
|
|
|
|
if (rectRes.Status !== PromptStatus.OK) return;
|
|
|
|
|
let rectRes: PromptRectResult;
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
rectRes = await app.Editor.GetRectPoint({
|
|
|
|
|
Msg: `请输入一个点${store.m_Option.autoParseDepth ? ",(当前为自动分析深度)" : ""}`,
|
|
|
|
|
KeyWordList: [{ key: "A", msg: `${store.m_Option.autoParseDepth ? "关闭自动分析深度" : "开启自动分析深度"}` }]
|
|
|
|
|
});
|
|
|
|
|
if (rectRes.Status === PromptStatus.Keyword)
|
|
|
|
|
{
|
|
|
|
|
if (rectRes.StringResult === "A")
|
|
|
|
|
{
|
|
|
|
|
store.m_Option.autoParseDepth = !store.m_Option.autoParseDepth;
|
|
|
|
|
userConfigStore.SaveConfig(BoardModalType.SpaceParse, store, { toaster: false });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (rectRes.Status === PromptStatus.OK)
|
|
|
|
|
break;
|
|
|
|
|
else
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let depth = await GetSpaceDepth(rectRes.Point1UCS, rectRes.Point2UCS, rectRes.UCS, lastDepth);
|
|
|
|
|
let depth = await GetSpaceDepth(rectRes.Point1UCS, rectRes.Point2UCS, rectRes.UCS, lastDepth, store.m_Option.autoParseDepth);
|
|
|
|
|
if (!depth) return;
|
|
|
|
|
lastDepth = depth;
|
|
|
|
|
|
|
|
|
@ -94,72 +119,78 @@ const RayVec = [
|
|
|
|
|
* @param p2UCS
|
|
|
|
|
* @param UCSMatrix
|
|
|
|
|
* @param lastDepth
|
|
|
|
|
* @param autoParseDepth //是否解析深度
|
|
|
|
|
*/
|
|
|
|
|
export async function GetSpaceDepth(p1UCS: Vector3, p2UCS: Vector3, UCSMatrix: Matrix4, lastDepth: number)
|
|
|
|
|
export async function GetSpaceDepth(p1UCS: Vector3, p2UCS: Vector3, UCSMatrix: Matrix4, lastDepth: number, autoParseDepth: boolean)
|
|
|
|
|
{
|
|
|
|
|
let autoDepth = 0;
|
|
|
|
|
let size = p2UCS.clone().sub(p1UCS);
|
|
|
|
|
let ray = new Vector3().setFromMatrixColumn(UCSMatrix, 2).negate();
|
|
|
|
|
let boardObjects: Object3D[] = [];
|
|
|
|
|
for (let obj of app.Viewer.VisibleObjects)//获取真实视图的绘制对象
|
|
|
|
|
if (autoParseDepth)
|
|
|
|
|
{
|
|
|
|
|
let en = GetEntity(obj);
|
|
|
|
|
if (en && !en.IsErase && en.Id && en instanceof Board)
|
|
|
|
|
let size = p2UCS.clone().sub(p1UCS);
|
|
|
|
|
let ray = new Vector3().setFromMatrixColumn(UCSMatrix, 2).negate();
|
|
|
|
|
let boardObjects: Object3D[] = [];
|
|
|
|
|
for (let obj of app.Viewer.VisibleObjects)//获取真实视图的绘制对象
|
|
|
|
|
{
|
|
|
|
|
let normal = en.Normal;
|
|
|
|
|
if (isParallelTo(normal, ray) || isPerpendicularityTo(normal, ray))
|
|
|
|
|
boardObjects.push(en.GetDrawObjectFromRenderType(RenderType.Physical));
|
|
|
|
|
let en = GetEntity(obj);
|
|
|
|
|
if (en && !en.IsErase && en.Id && en instanceof Board)
|
|
|
|
|
{
|
|
|
|
|
let normal = en.Normal;
|
|
|
|
|
if (isParallelTo(normal, ray) || isPerpendicularityTo(normal, ray))
|
|
|
|
|
boardObjects.push(en.GetDrawObjectFromRenderType(RenderType.Physical));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let pts: Vector3[] = [];
|
|
|
|
|
for (let v of RayVec)//使用射线投射
|
|
|
|
|
{
|
|
|
|
|
let p = p1UCS.clone().add(size.multiply(v));
|
|
|
|
|
p.applyMatrix4(UCSMatrix);
|
|
|
|
|
|
|
|
|
|
let rayCast = new Raycaster(p, ray);
|
|
|
|
|
let f: Filter = { filterErase: true, filterTypes: [Board] };
|
|
|
|
|
let i = Raycast(rayCast, boardObjects, f);
|
|
|
|
|
pts.push(p);
|
|
|
|
|
if (i && i.distance < 1200 && i.distance > 0.1)//深度太大是没有意义的
|
|
|
|
|
let pts: Vector3[] = [];
|
|
|
|
|
for (let v of RayVec)//使用射线投射
|
|
|
|
|
{
|
|
|
|
|
autoDepth = i.distance;
|
|
|
|
|
break;
|
|
|
|
|
let p = p1UCS.clone().add(size.multiply(v));
|
|
|
|
|
p.applyMatrix4(UCSMatrix);
|
|
|
|
|
|
|
|
|
|
let rayCast = new Raycaster(p, ray);
|
|
|
|
|
let f: Filter = { filterErase: true, filterTypes: [Board] };
|
|
|
|
|
let i = Raycast(rayCast, boardObjects, f);
|
|
|
|
|
pts.push(p);
|
|
|
|
|
if (i && i.distance < 1200 && i.distance > 0.1)//深度太大是没有意义的
|
|
|
|
|
{
|
|
|
|
|
autoDepth = i.distance;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (autoDepth < 0.1)
|
|
|
|
|
{
|
|
|
|
|
let dcsMtx = app.Viewer.DCS;
|
|
|
|
|
let ucsInv = new Matrix4().getInverse(UCSMatrix);
|
|
|
|
|
for (let p of pts)//使用点选空间
|
|
|
|
|
if (autoDepth < 0.1)
|
|
|
|
|
{
|
|
|
|
|
let dcsPoint = p.applyMatrix4(dcsMtx);
|
|
|
|
|
let ptSelect = new PointSelectBoards(dcsPoint, app.Viewer, boardObjects);
|
|
|
|
|
let spaceParse = new ClampSpaceParseRay(ptSelect.SelectBoards).SetRay(ptSelect.Ray);
|
|
|
|
|
spaceParse.IsDynamic = true;
|
|
|
|
|
await spaceParse.Parse();
|
|
|
|
|
if (spaceParse.ParseOK)
|
|
|
|
|
let dcsMtx = app.Viewer.DCS;
|
|
|
|
|
let ucsInv = new Matrix4().getInverse(UCSMatrix);
|
|
|
|
|
for (let p of pts)//使用点选空间
|
|
|
|
|
{
|
|
|
|
|
let mtx = new Matrix4().multiplyMatrices(ucsInv, spaceParse.SpaceOCS);
|
|
|
|
|
spaceParse.SpaceBox.applyMatrix4(mtx);
|
|
|
|
|
autoDepth = p1UCS.z - spaceParse.SpaceBox.min.z;
|
|
|
|
|
break;
|
|
|
|
|
let dcsPoint = p.applyMatrix4(dcsMtx);
|
|
|
|
|
let ptSelect = new PointSelectBoards(dcsPoint, app.Viewer, boardObjects);
|
|
|
|
|
let spaceParse = new ClampSpaceParseRay(ptSelect.SelectBoards).SetRay(ptSelect.Ray);
|
|
|
|
|
spaceParse.IsDynamic = true;
|
|
|
|
|
await spaceParse.Parse();
|
|
|
|
|
if (spaceParse.ParseOK)
|
|
|
|
|
{
|
|
|
|
|
let mtx = new Matrix4().multiplyMatrices(ucsInv, spaceParse.SpaceOCS);
|
|
|
|
|
spaceParse.SpaceBox.applyMatrix4(mtx);
|
|
|
|
|
autoDepth = p1UCS.z - spaceParse.SpaceBox.min.z;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//保留两位有效数字
|
|
|
|
|
autoDepth = parseFloat(autoDepth.toFixed(2));
|
|
|
|
|
|
|
|
|
|
if (autoDepth > 0.1)
|
|
|
|
|
{
|
|
|
|
|
Log(`自动分析深度为:${autoDepth}`);
|
|
|
|
|
AppToaster.show({
|
|
|
|
|
message: `自动分析深度为:${autoDepth}`,
|
|
|
|
|
timeout: 5000,
|
|
|
|
|
intent: Intent.SUCCESS,
|
|
|
|
|
});
|
|
|
|
|
if (autoDepth > 0.1)
|
|
|
|
|
{
|
|
|
|
|
Log(`自动分析深度为:${autoDepth}`);
|
|
|
|
|
AppToaster.show({
|
|
|
|
|
message: `自动分析深度为:${autoDepth}`,
|
|
|
|
|
timeout: 5000,
|
|
|
|
|
intent: Intent.SUCCESS,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
autoDepth = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
autoDepth = 0;
|
|
|
|
|
|
|
|
|
|
let keyword: KeyWord[] = [];
|
|
|
|
|
if (autoDepth)
|
|
|
|
|