mirror of https://gitee.com/cf-fz/WebCAD.git
parent
9140f10c9e
commit
d2a455ec93
@ -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…
Reference in new issue