开发:测试绘制Container移动到主干

pull/1469/head
ChenX 4 years ago
parent 9140f10c9e
commit d2a455ec93

@ -206,6 +206,7 @@ import { IsTest } from "../Common/Deving";
import { CommandServer, UpgradeData } from '../DatabaseServices/CommandServer';
import { Command_ExportObj2 } from "../Geometry/ExportObj2";
import { RenderType } from "../GraphicsSystem/RenderType";
import { Command_TestContainer } from "../Nest/Test/TestContainer";
import { Command_TestDrawYHData } from "../Nest/Test/TestDrawYHData";
import { Command_TestNFP } from "../Nest/Test/TestNFP";
import { Command_TestPlace } from "../Nest/Test/TestPlace";
@ -525,6 +526,7 @@ export function registerCommand()
commandMachine.RegisterCommand("testSum", new Command_TestSum());
commandMachine.RegisterCommand("TestSimplyOddments", new Command_TestSimplyOddments());
commandMachine.RegisterCommand("TestParseOddments", new Command_TestParseOddments());//分析余料
commandMachine.RegisterCommand("TestContainer", new Command_TestContainer());//绘制Container
}
commandMachine.RegisterCommand("editorlattice", new EditorLattice());

@ -0,0 +1,44 @@
import { TestDraw } from "../../Add-on/test/TestUtil";
import { FileSystem } from "../../Common/FileSystem";
import { Polyline } from "../../DatabaseServices/Entity/Polyline";
import { Command } from "../../Editor/CommandMachine";
import { AsVector3 } from "../../Geometry/GeUtils";
import { HotCMD } from "../../Hot/HotCommand";
import { NestFiler } from "../../Nest/Common/Filer";
import { Point } from "../../Nest/Common/Point";
import { Path2Polyline } from "../../Nest/Converter/Path2Polyline";
import { Container } from "../../Nest/Core/Container";
import { Part } from "../../Nest/Core/Part";
import { PathScale } from "../../Nest/Core/Path";
@HotCMD
export class Command_TestContainer implements Command
{
async exec()
{
FileSystem.ChooseFile({
filter: ".container", multiple: false, callback: async (files) =>
{
let fileItem = files.item(0);
let fstr = await FileSystem.ReadFileAsText(fileItem);
let f = new NestFiler(JSON.parse(fstr));
let count = f.Read() as number;
let pls: Polyline[] = [];
for (let i = 0; i < count; i++)
{
let pl = Path2Polyline(PathScale(f.Read() as Point[], 1e-4));
pls.push(pl);
}
let c = new Container;
c.ReadFile(f, pls.map(p => new Part));
for (let i = 0; i < count; i++)
{
pls[i].Position = AsVector3(c.PlacedParts[i].PlacePosition).multiplyScalar(1e-4);
TestDraw(pls[i]);
}
}
});
}
}
Loading…
Cancel
Save