From 777357ce927f3598aafdd085c25a2cb206f010bc Mon Sep 17 00:00:00 2001 From: ChenX Date: Mon, 31 May 2021 16:19:14 +0800 Subject: [PATCH] =?UTF-8?q?!1511=20=E4=BC=98=E5=8C=96:=E5=B9=B2=E6=B6=89?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E8=BF=94=E5=9B=9E=E7=9A=84=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __test__/Interfere/interfere.test.ts | 2 +- src/Add-on/Erp/ErpCommands.ts | 4 +- src/Add-on/interfere.ts | 2 +- src/Common/InterfereUtil.ts | 8 ++-- src/UI/Components/Modal/InterfereModal.tsx | 53 ++++++++++------------ 5 files changed, 32 insertions(+), 37 deletions(-) diff --git a/__test__/Interfere/interfere.test.ts b/__test__/Interfere/interfere.test.ts index 8de09162a..6f5ff3b44 100644 --- a/__test__/Interfere/interfere.test.ts +++ b/__test__/Interfere/interfere.test.ts @@ -8,7 +8,7 @@ async function Check(data: any, count: number) for (let i = 0; i < boards.length; i++) boards[i].objectId = new ObjectId(i); await CheckInterfereTool.GetInstance().Check(boards as any[]); - expect(CheckInterfereTool.GetInstance().objMap.size).toBe(count); + expect(CheckInterfereTool.GetInstance().objMap.length).toBe(count); } diff --git a/src/Add-on/Erp/ErpCommands.ts b/src/Add-on/Erp/ErpCommands.ts index f64934ad2..a340b4d1b 100644 --- a/src/Add-on/Erp/ErpCommands.ts +++ b/src/Add-on/Erp/ErpCommands.ts @@ -183,10 +183,10 @@ async function ExecChaiDan(chaiDanRoute: ErpRoutes) originEns.add(b.__OriginalEnt__ ?? b); CheckInterfereTool.GetInstance().Check([...originEns, ...selction.metalsList]).then(objMap => { - if (objMap.size > 0) + if (objMap.length > 0) { AppToaster.show({ - message: `有${objMap.size}组实体干涉了,请退出检查确认`, + message: `有${objMap.length}组实体干涉了,请退出检查确认`, timeout: 5000, intent: Intent.DANGER, }); diff --git a/src/Add-on/interfere.ts b/src/Add-on/interfere.ts index e16f3bd15..b250d788b 100644 --- a/src/Add-on/interfere.ts +++ b/src/Add-on/interfere.ts @@ -61,7 +61,7 @@ export class Interfere implements Command let objMap = this.checkInterfereTool.objMap; - if (objMap.size === 0) + if (objMap.length === 0) { AppToaster.show({ message: "未找到干涉对象", diff --git a/src/Common/InterfereUtil.ts b/src/Common/InterfereUtil.ts index 161b24370..905398bc2 100644 --- a/src/Common/InterfereUtil.ts +++ b/src/Common/InterfereUtil.ts @@ -35,7 +35,7 @@ export class CheckInterfereTool } entitySet: Set = new Set(); - objMap: Map = new Map(); + objMap: [Mesh, [Solid3D, Solid3D]][] = []; GetEntitys(selectEnts: (HardwareCompositeEntity | ExtrudeSolid | SweepSolid)[]) { let ens: Solid3D[] = []; @@ -68,7 +68,7 @@ export class CheckInterfereTool let entitySet = this.entitySet; let objMap = this.objMap; entitySet.clear(); - objMap.clear(); + objMap.length = 0; for (let i = 0; i < ens.length; i++) { @@ -170,7 +170,7 @@ export class CheckInterfereTool { let geo = CSG2Geometry(interCsg).applyMatrix4(e1.OCSNoClone); let mesh = new Mesh(geo, this._MeshMaterial); - objMap.set(mesh, [e1, e2]); + objMap.push([mesh, [e1, e2]]); } } } @@ -183,7 +183,7 @@ export class CheckInterfereTool Clear() { this.entitySet.clear(); - this.objMap.clear(); + this.objMap.length = 0; } csgCache: Map = new Map(); diff --git a/src/UI/Components/Modal/InterfereModal.tsx b/src/UI/Components/Modal/InterfereModal.tsx index 158f99b24..0aa6a155f 100644 --- a/src/UI/Components/Modal/InterfereModal.tsx +++ b/src/UI/Components/Modal/InterfereModal.tsx @@ -2,7 +2,7 @@ import { Button, Card, Classes, Intent } from '@blueprintjs/core'; import { observable } from 'mobx'; import { observer } from 'mobx-react'; import React, { Component } from 'react'; -import { Box3, Mesh, Vector3 } from 'three'; +import { Mesh } from 'three'; import { app } from '../../../ApplicationServices/Application'; import { Solid3D } from '../../../Common/InterfereUtil'; import { ColorMaterial } from './../../../Common/ColorPalette'; @@ -12,7 +12,7 @@ import { CommonModal } from './ModalContainer'; interface IInterfereProps { count: number, - data: Map; + data: [Mesh, [Solid3D, Solid3D]][]; } @observer @@ -42,7 +42,7 @@ export class InterfereModal extends Component {
共{count}个干涉对象
找到干涉点对 - {data.size} + {data.length}
@@ -57,7 +57,7 @@ export class InterfereModal extends Component { intent={Intent.SUCCESS} onClick={this.next} />{ - this.currentIndex >= 0 && 第{this.currentIndex + 1}个,共{data.size}个 + this.currentIndex >= 0 && 第{this.currentIndex + 1}个,共{data.length}个 }
@@ -67,40 +67,35 @@ export class InterfereModal extends Component { private close = () => { app.Editor.ModalManage.Destory(); - app.Viewer.OutlinePass.selectedObjects = []; + app.Editor.SetSelection([]); }; - private restore = (os: Mesh[]) => + private restore = () => { - for (let o of os) - o.material = ColorMaterial.GetConceptualMaterial(1); - app.Viewer.OutlinePass.selectedObjects = []; + for (let lst of this.props.data) + { + let mesh = lst[0]; + mesh.material = ColorMaterial.GetConceptualMaterial(1); + } }; private next = () => { - let os = [...this.props.data.keys()]; - this.restore(os); - this.currentIndex = FixIndex(this.currentIndex + 1, os.length); - this.update(os[this.currentIndex]); + this.restore(); + this.currentIndex = FixIndex(this.currentIndex + 1, this.props.data); + this.update(this.props.data[this.currentIndex]); }; private previos = () => { - let os = [...this.props.data.keys()]; - this.restore(os); - if (this.currentIndex < 0) - this.currentIndex = 0; - this.currentIndex = FixIndex(this.currentIndex - 1, os.length); - this.update(os[this.currentIndex]); + this.restore(); + this.currentIndex = FixIndex(this.currentIndex - 1, this.props.data); + if (this.currentIndex < 0) this.currentIndex = 0; + this.update(this.props.data[this.currentIndex]); }; - private update = (o: Mesh) => + private update = (group: [Mesh, [Solid3D, Solid3D]]) => { - o.material = ColorMaterial.GetConceptualMaterial(5); - let box = new Box3(); - app.Viewer.OutlinePass.selectedObjects = this.props.data.get(o).map(e => - { - box.union(e.BoundingBox); - return e.DrawObject; - }); - app.Viewer.CameraCtrl.ZoomExtensBox3(box); - app.Viewer.Zoom(1, box.getCenter(new Vector3)); + if (!group) return; + let [mesh, ens] = group; + mesh.material = ColorMaterial.GetConceptualMaterial(5); + app.Editor.SetSelection(ens); + app.Viewer.ZoomtoEntitys(ens); }; }