!1511 优化:干涉检查返回的数据结构

pull/1511/MERGE
ChenX 3 years ago
parent ee5c6b917d
commit 777357ce92

@ -8,7 +8,7 @@ async function Check(data: any, count: number)
for (let i = 0; i < boards.length; i++) for (let i = 0; i < boards.length; i++)
boards[i].objectId = new ObjectId(i); boards[i].objectId = new ObjectId(i);
await CheckInterfereTool.GetInstance().Check(boards as any[]); await CheckInterfereTool.GetInstance().Check(boards as any[]);
expect(CheckInterfereTool.GetInstance().objMap.size).toBe(count); expect(CheckInterfereTool.GetInstance().objMap.length).toBe(count);
} }

@ -183,10 +183,10 @@ async function ExecChaiDan(chaiDanRoute: ErpRoutes)
originEns.add(b.__OriginalEnt__ ?? b); originEns.add(b.__OriginalEnt__ ?? b);
CheckInterfereTool.GetInstance().Check([...originEns, ...selction.metalsList]).then(objMap => CheckInterfereTool.GetInstance().Check([...originEns, ...selction.metalsList]).then(objMap =>
{ {
if (objMap.size > 0) if (objMap.length > 0)
{ {
AppToaster.show({ AppToaster.show({
message: `${objMap.size}组实体干涉了,请退出检查确认`, message: `${objMap.length}组实体干涉了,请退出检查确认`,
timeout: 5000, timeout: 5000,
intent: Intent.DANGER, intent: Intent.DANGER,
}); });

@ -61,7 +61,7 @@ export class Interfere implements Command
let objMap = this.checkInterfereTool.objMap; let objMap = this.checkInterfereTool.objMap;
if (objMap.size === 0) if (objMap.length === 0)
{ {
AppToaster.show({ AppToaster.show({
message: "未找到干涉对象", message: "未找到干涉对象",

@ -35,7 +35,7 @@ export class CheckInterfereTool
} }
entitySet: Set<Solid3D> = new Set(); entitySet: Set<Solid3D> = new Set();
objMap: Map<Mesh, [Solid3D, Solid3D]> = new Map(); objMap: [Mesh, [Solid3D, Solid3D]][] = [];
GetEntitys(selectEnts: (HardwareCompositeEntity | ExtrudeSolid | SweepSolid)[]) GetEntitys(selectEnts: (HardwareCompositeEntity | ExtrudeSolid | SweepSolid)[])
{ {
let ens: Solid3D[] = []; let ens: Solid3D[] = [];
@ -68,7 +68,7 @@ export class CheckInterfereTool
let entitySet = this.entitySet; let entitySet = this.entitySet;
let objMap = this.objMap; let objMap = this.objMap;
entitySet.clear(); entitySet.clear();
objMap.clear(); objMap.length = 0;
for (let i = 0; i < ens.length; i++) for (let i = 0; i < ens.length; i++)
{ {
@ -170,7 +170,7 @@ export class CheckInterfereTool
{ {
let geo = CSG2Geometry(interCsg).applyMatrix4(e1.OCSNoClone); let geo = CSG2Geometry(interCsg).applyMatrix4(e1.OCSNoClone);
let mesh = new Mesh(geo, this._MeshMaterial); 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() Clear()
{ {
this.entitySet.clear(); this.entitySet.clear();
this.objMap.clear(); this.objMap.length = 0;
} }
csgCache: Map<Entity, CSG> = new Map(); csgCache: Map<Entity, CSG> = new Map();

@ -2,7 +2,7 @@ import { Button, Card, Classes, Intent } from '@blueprintjs/core';
import { observable } from 'mobx'; import { observable } from 'mobx';
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Box3, Mesh, Vector3 } from 'three'; import { Mesh } from 'three';
import { app } from '../../../ApplicationServices/Application'; import { app } from '../../../ApplicationServices/Application';
import { Solid3D } from '../../../Common/InterfereUtil'; import { Solid3D } from '../../../Common/InterfereUtil';
import { ColorMaterial } from './../../../Common/ColorPalette'; import { ColorMaterial } from './../../../Common/ColorPalette';
@ -12,7 +12,7 @@ import { CommonModal } from './ModalContainer';
interface IInterfereProps interface IInterfereProps
{ {
count: number, count: number,
data: Map<Mesh, [Solid3D, Solid3D]>; data: [Mesh, [Solid3D, Solid3D]][];
} }
@observer @observer
@ -42,7 +42,7 @@ export class InterfereModal extends Component<IInterfereProps, {}> {
<h5>{count}</h5> <h5>{count}</h5>
<div className="flex-between"> <div className="flex-between">
<span></span> <span></span>
<span>{data.size}</span> <span>{data.length}</span>
</div> </div>
</div> </div>
<div className="flex-col" style={{ width: "40%" }}> <div className="flex-col" style={{ width: "40%" }}>
@ -57,7 +57,7 @@ export class InterfereModal extends Component<IInterfereProps, {}> {
intent={Intent.SUCCESS} intent={Intent.SUCCESS}
onClick={this.next} onClick={this.next}
/>{ />{
this.currentIndex >= 0 && <span>{this.currentIndex + 1}{data.size}</span> this.currentIndex >= 0 && <span>{this.currentIndex + 1}{data.length}</span>
} }
</div> </div>
</Card> </Card>
@ -67,40 +67,35 @@ export class InterfereModal extends Component<IInterfereProps, {}> {
private close = () => private close = () =>
{ {
app.Editor.ModalManage.Destory(); app.Editor.ModalManage.Destory();
app.Viewer.OutlinePass.selectedObjects = []; app.Editor.SetSelection([]);
}; };
private restore = (os: Mesh[]) => private restore = () =>
{ {
for (let o of os) for (let lst of this.props.data)
o.material = ColorMaterial.GetConceptualMaterial(1); {
app.Viewer.OutlinePass.selectedObjects = []; let mesh = lst[0];
mesh.material = ColorMaterial.GetConceptualMaterial(1);
}
}; };
private next = () => private next = () =>
{ {
let os = [...this.props.data.keys()]; this.restore();
this.restore(os); this.currentIndex = FixIndex(this.currentIndex + 1, this.props.data);
this.currentIndex = FixIndex(this.currentIndex + 1, os.length); this.update(this.props.data[this.currentIndex]);
this.update(os[this.currentIndex]);
}; };
private previos = () => private previos = () =>
{ {
let os = [...this.props.data.keys()]; this.restore();
this.restore(os); this.currentIndex = FixIndex(this.currentIndex - 1, this.props.data);
if (this.currentIndex < 0) if (this.currentIndex < 0) this.currentIndex = 0;
this.currentIndex = 0; this.update(this.props.data[this.currentIndex]);
this.currentIndex = FixIndex(this.currentIndex - 1, os.length);
this.update(os[this.currentIndex]);
}; };
private update = (o: Mesh) => private update = (group: [Mesh, [Solid3D, Solid3D]]) =>
{ {
o.material = ColorMaterial.GetConceptualMaterial(5); if (!group) return;
let box = new Box3(); let [mesh, ens] = group;
app.Viewer.OutlinePass.selectedObjects = this.props.data.get(o).map(e => mesh.material = ColorMaterial.GetConceptualMaterial(5);
{ app.Editor.SetSelection(ens);
box.union(e.BoundingBox); app.Viewer.ZoomtoEntitys(ens);
return e.DrawObject;
});
app.Viewer.CameraCtrl.ZoomExtensBox3(box);
app.Viewer.Zoom(1, box.getCenter(new Vector3));
}; };
} }

Loading…
Cancel
Save