!1499 功能:分堆打包移动到0点,命令PM0

pull/1499/MERGE
ChenX 3 years ago
parent 7c9c02eac7
commit 52de121a08

@ -2,10 +2,10 @@ import { app } from "../../ApplicationServices/Application";
import { Board } from "../../DatabaseServices/Entity/Board";
import { Command } from "../../Editor/CommandMachine";
import { PromptStatus } from "../../Editor/PromptResult";
import { IHardwareType } from "../../Production/Product";
import { LookOverBoardInfosModal } from "../../UI/Components/BBS/LookOverBoardInfos";
import { HardwareCompositeEntity } from './../../DatabaseServices/Hardware/HardwareCompositeEntity';
import { HardwareTopline } from './../../DatabaseServices/Hardware/HardwareTopline';
import { IHardwareType, Production } from "../../Production/Product";
export class LookOverBoardInfos implements Command
{
async exec()

@ -1,8 +1,11 @@
import { Box3, Matrix4 } from "three";
import Flatbush from 'flatbush';
import { Box3, Matrix4, Vector3 } from "three";
import { app } from "../ApplicationServices/Application";
import { Entity } from "../DatabaseServices/Entity/Entity";
import { Command } from "../Editor/CommandMachine";
import { PromptStatus } from "../Editor/PromptResult";
import { comparePoint } from '../Geometry/GeUtils';
import { HotCMD } from '../Hot/HotCommand';
export class Command_M0 implements Command
@ -26,3 +29,80 @@ export class Command_M0 implements Command
e.ApplyMatrix(m);
}
}
@HotCMD
export class Command_PackageMove implements Command
{
async exec()
{
let ents = app.Database.ModelSpace.Entitys.filter(e => !e.IsErase);
if (ents.length === 0) return;
let oents = ents.concat();
this.PackageMove(ents, oents, 0, 1);
this.PackageMove(oents.concat(), oents, 1, 2, 5000, 1e10);
this.PackageMove(oents.concat(), oents, 2, 0, 5000, 1e10);
app.Viewer.ZoomAll();
}
PackageMove(ents: Entity[], oents: Entity[], i1: number, i2: number, i1d = 1000, i2d = 1000)
{
for (let i = 0; i < ents.length; i++)
{
let en = ents[i];
en.TempData = { i, b: en.BoundingBox, u: false };
}
let fb = new Flatbush(ents.length);
for (let en of ents)
{
let box = en.TempData.b as Box3;
fb.add(box.min.getComponent(i1) - 10, box.min.getComponent(i2) - 10, box.max.getComponent(i1) + 10, box.max.getComponent(i2) + 10);
}
fb.finish();
let groups: { ens: Entity[], box: Box3; }[] = [];
while (ents.length)
{
let arr = [ents.pop()];
arr[0].TempData.u = true;
let b = new Box3;
for (let i = 0; i < arr.length; i++)
{
let e = arr[i];
b.union(e.TempData.b);
let ids = fb.search(b.min.getComponent(i1) - i1d, b.min.getComponent(i2) - i2d, b.max.getComponent(i1) + i1d, b.max.getComponent(i2) + i2d, id => oents[id].TempData.u === false);
for (let id of ids)
{
let e = oents[id];
e.TempData.u = true;
arr.push(e);
b.union(e.TempData.b);
}
if (ids.length)
ents = ents.filter(e => e.TempData.u === false);
}
groups.push({ ens: arr, box: b });
}
groups.sort((g1, g2) => g1.box.min.getComponent(i1) - g2.box.min.getComponent(i1));
let movex = new Vector3;
let size = new Vector3;
let mmtz = new Matrix4;
for (let g of groups)
{
let b = g.box;
mmtz.setPosition(b.min.clone().negate().add(movex));
movex.setComponent(i1, movex.getComponent(i1) + b.getSize(size).getComponent(i1) + 1000);
for (let e of g.ens)
e.ApplyMatrix(mmtz);
}
}
}

@ -224,5 +224,6 @@ export enum CommandNames
UploadConfig = "UPLOADCONFIG",
TestM = "TESTM",
M0 = "M0",
PackageGroupMove0 = "PACKAGEGROUPMOVE0",
ApplyMtl = "APPLYMTL",//应用材质
}

@ -127,7 +127,10 @@ export class ExtrudeSolid extends Entity
}
get BoundingBoxInOCS(): Box3Ext
{
return new Box3Ext(new Vector3(), new Vector3(this.width, this.height, this.thickness));
if (this.width > 0 && this.height > 0 && this.thickness > 0)
return new Box3Ext(new Vector3, new Vector3(this.width, this.height, this.thickness));
else
return new Box3Ext().setFromPoints([new Vector3, new Vector3(this.width, this.height, this.thickness)]);
}
get OBB(): OBB

@ -136,7 +136,7 @@ import { Fbx } from "../Add-on/loadfbx";
import { LookOverBoardInfos } from "../Add-on/LookOverBoardInfos/LookOverBoardInfos";
import { MirrorCommand } from "../Add-on/Mirror";
import { Command_Move } from "../Add-on/Move";
import { Command_M0 } from "../Add-on/MoveToWCS0";
import { Command_M0, Command_PackageMove } from "../Add-on/MoveToWCS0";
import { Command_DynOffset, Command_DynOffsetToolPath, Command_Offset } from "../Add-on/Offset";
import { OffsetX } from "../Add-on/OffsetX";
import { Open } from "../Add-on/Open";
@ -277,6 +277,7 @@ export function registerCommand()
commandMachine.RegisterCommand(CommandNames.Move, new Command_Move());
commandMachine.RegisterCommand("z0", new Command_EntitytMoveToZ0());
commandMachine.RegisterCommand(CommandNames.M0, new Command_M0());
commandMachine.RegisterCommand(CommandNames.PackageGroupMove0, new Command_PackageMove());
commandMachine.RegisterCommand(CommandNames.Rotate, new Command_Rotate());
commandMachine.RegisterCommand(CommandNames.RotateRefer, new Command_RotateRefer());
commandMachine.RegisterCommand(CommandNames.Revolve, new Command_DrawRevolve());

@ -23,6 +23,9 @@ import { PromptPointResult, PromptStatus } from './PromptResult';
import { SnapMenuKW, SNAPMODE } from './ShowSnapMenu';
import { SnapServices } from './SnapServices';
const MinP = new Vector3(-2e6, -2e6, -2e6);
const MaxP = new Vector3(2e6, 2e6, 2e6);
/**
* ,Editor.
*/
@ -467,6 +470,8 @@ export class GetPointServices implements EditorService
{
if (!this.promisResolve) return;
this.RestState();
if (retValue.Status === PromptStatus.OK)
retValue.Point.clamp(MinP, MaxP);
this.promisResolve(retValue);
this.promisResolve = undefined;
}

@ -1570,6 +1570,15 @@ export const CommandList: ICommand[] = [
chName: "移动到0点",
chDes: "移动到0点",
},
{
typeId: "util",
link: "#",
defaultCustom: "PM0",
command: CommandNames.PackageGroupMove0,
type: "工具",
chName: "按柜子移动到0点",
chDes: "按柜子移动到0点",
},
{
icon: IconEnum.ExportView,
typeId: "util",

Loading…
Cancel
Save