mirror of https://gitee.com/cf-fz/WebCAD.git
parent
b48039d332
commit
940ed79762
@ -1,30 +1,102 @@
|
||||
import { Command } from "../Editor/CommandMachine";
|
||||
import { Vector3 } from "three";
|
||||
import { app } from "../ApplicationServices/Application";
|
||||
import { PromptStatus } from "../Editor/PromptResult";
|
||||
import { Polyline } from "../DatabaseServices/Entity/Polyline";
|
||||
import { RevolveSolid } from "../DatabaseServices/3DSolid/RevolveSolid";
|
||||
import { TestDraw } from "./test/TestUtil";
|
||||
import { Line } from "../DatabaseServices/Entity/Line";
|
||||
import { Polyline } from "../DatabaseServices/Entity/Polyline";
|
||||
import { Command } from "../Editor/CommandMachine";
|
||||
import { PromptStatus } from "../Editor/PromptResult";
|
||||
import { equalv3, ZeroVec } from "../Geometry/GeUtils";
|
||||
import { HotCMD } from "../Hot/HotCommand";
|
||||
import { TestDraw } from "./test/TestUtil";
|
||||
|
||||
@HotCMD
|
||||
export class Command_DrawRevolve implements Command
|
||||
{
|
||||
async exec()
|
||||
{
|
||||
let enRes = await app.Editor.GetEntity({ Msg: "选择轴", Filter: { filterTypes: [Line] } });
|
||||
if (enRes.Status !== PromptStatus.OK) return;
|
||||
let axis = enRes.Entity as Line;
|
||||
|
||||
let enRes2 = await app.Editor.GetEntity({ Msg: "选择轮廓", Filter: { filterTypes: [Polyline] } });
|
||||
if (enRes2.Status !== PromptStatus.OK) return;
|
||||
let pl = enRes2.Entity as Polyline;
|
||||
|
||||
let rs = new RevolveSolid(
|
||||
axis.GetFistDeriv(0).normalize(),
|
||||
axis.StartPoint,
|
||||
pl,
|
||||
0, 0
|
||||
);
|
||||
let p0 = await app.Editor.GetPoint({
|
||||
Msg: "指定轴起点或者根据以下选项之一定义轴:",
|
||||
KeyWordList: [
|
||||
{ key: "O", msg: "对象" },
|
||||
{ key: "X", msg: "" },
|
||||
{ key: "Y", msg: "" },
|
||||
{ key: "Z", msg: "" },
|
||||
]
|
||||
});
|
||||
|
||||
if (p0.Status === PromptStatus.Keyword)
|
||||
{
|
||||
if (p0.StringResult === "O")
|
||||
{
|
||||
let enRes = await app.Editor.GetEntity({ Msg: "选择轴", Filter: { filterTypes: [Line] } });
|
||||
if (enRes.Status !== PromptStatus.OK) return;
|
||||
let axis = enRes.Entity as Line;
|
||||
let rs = new RevolveSolid(
|
||||
axis.GetFistDeriv(0).normalize(),
|
||||
axis.StartPoint,
|
||||
pl,
|
||||
0, 0
|
||||
);
|
||||
TestDraw(rs);
|
||||
}
|
||||
else if (p0.StringResult === "X")
|
||||
{
|
||||
let rs = new RevolveSolid(
|
||||
new Vector3(1),
|
||||
new Vector3,
|
||||
pl,
|
||||
0, 0
|
||||
);
|
||||
TestDraw(rs);
|
||||
}
|
||||
else if (p0.StringResult === "Y")
|
||||
{
|
||||
let rs = new RevolveSolid(
|
||||
new Vector3(0, 1),
|
||||
new Vector3,
|
||||
pl,
|
||||
0, 0
|
||||
);
|
||||
TestDraw(rs);
|
||||
}
|
||||
else if (p0.StringResult === "Z")
|
||||
{
|
||||
let rs = new RevolveSolid(
|
||||
new Vector3(0, 0, 1),
|
||||
new Vector3,
|
||||
pl,
|
||||
0, 0
|
||||
);
|
||||
TestDraw(rs);
|
||||
}
|
||||
}
|
||||
else if (p0.Status === PromptStatus.OK)
|
||||
{
|
||||
let p1Res = await app.Editor.GetPoint({ Msg: "指定轴端点:", BasePoint: p0.Point, AllowDrawRubberBand: true });
|
||||
if (p1Res.Status === PromptStatus.OK)
|
||||
{
|
||||
let p1 = p1Res.Point;
|
||||
let n = p1.sub(p0.Point);
|
||||
if (equalv3(n, ZeroVec))
|
||||
{
|
||||
app.Editor.Prompt("重合!");
|
||||
return;
|
||||
}
|
||||
|
||||
let rs = new RevolveSolid(
|
||||
n,
|
||||
p0.Point,
|
||||
pl,
|
||||
0, 0
|
||||
);
|
||||
TestDraw(rs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TestDraw(rs);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in new issue