mirror of https://gitee.com/cf-fz/WebCAD.git
parent
ab8ddb35c7
commit
aaca87d42a
@ -0,0 +1,33 @@
|
||||
import { Polyline } from "../../src/DatabaseServices/Entity/Polyline";
|
||||
import { LoadEntityFromFileData } from "../Utils/LoadEntity.util";
|
||||
import "../Utils/jest.util";
|
||||
|
||||
test('精简多段线', () =>
|
||||
{
|
||||
let d =
|
||||
{ "file": [1, "Polyline", 10, 2, 182, 0, 1, 3, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1493.5460401813875, 698.3323670493448, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1493.5460401813875, 698.3323670493448, 0, 1], 0, 0, 1, 2, 7, [-529, -397.9970410676705], 0, [-2.9849800837673115, -1], 0, [-250, -1], -0.0006310150531804717, [-250.00252405719763, -0.999996814562558], 0.41569289652442754, [-529.0000031854374, -279.99747594280234], -0.000631015053187468, [-529, -280], 0, [-529, -397.9970410676705], 0, false], "basePt": { "x": 964.5451505016724, "y": 300.3353259816743, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
|
||||
let pl = LoadEntityFromFileData(d)[0] as Polyline;
|
||||
|
||||
pl.RemoveRepeatPos();
|
||||
|
||||
expect(pl.EndParam).toMatchNumberSnapshot(0);
|
||||
expect(pl.Length).toMatchNumberSnapshot(3);
|
||||
});
|
||||
|
||||
//保留最后一个点?
|
||||
test('精简多段线2', () =>
|
||||
{
|
||||
let d =
|
||||
{ "file": [1, "Polyline", 10, 2, 183, 0, 1, 7, 71, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, 2, 7, [323.78480965026665, 1043.5675363800462], 0, [218.75605375536884, 744.9733873895931], 0, [400.1693593920104, 714.5931687423086], 0, [559.8825088520202, 935.9347617439527], 0, [757.7879331829016, 843.9260995550339], 0, [708.3115771001814, 1097.383923698093], 0, [323.7848611540741, 1043.5676220967764], 0, true], "basePt": { "x": 218.75605375536884, "y": 714.5931687423086, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
|
||||
let pl = LoadEntityFromFileData(d)[0] as Polyline;
|
||||
pl.CloseMark = false;
|
||||
pl.RemoveRepeatPos();
|
||||
expect(pl.EndParam).toMatchNumberSnapshot(0);
|
||||
expect(pl.Length).toMatchNumberSnapshot(3);
|
||||
|
||||
pl = LoadEntityFromFileData(d)[0] as Polyline;
|
||||
pl.CloseMark = true;
|
||||
pl.RemoveRepeatPos();
|
||||
expect(pl.EndParam).toMatchNumberSnapshot(0);
|
||||
expect(pl.Length).toMatchNumberSnapshot(3);
|
||||
});
|
@ -0,0 +1,13 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`精简多段线 1`] = `"4"`;
|
||||
|
||||
exports[`精简多段线 2`] = `"1462.581"`;
|
||||
|
||||
exports[`精简多段线2 1`] = `"6"`;
|
||||
|
||||
exports[`精简多段线2 2`] = `"1638.178"`;
|
||||
|
||||
exports[`精简多段线2 3`] = `"6"`;
|
||||
|
||||
exports[`精简多段线2 4`] = `"1638.178"`;
|
@ -0,0 +1,20 @@
|
||||
import { app } from "../ApplicationServices/Application";
|
||||
import { Polyline } from "../DatabaseServices/Entity/Polyline";
|
||||
import { Command } from "../Editor/CommandMachine";
|
||||
import { PromptStatus } from "../Editor/PromptResult";
|
||||
|
||||
export class Command_RemovePolylineRepeatPos implements Command
|
||||
{
|
||||
async exec()
|
||||
{
|
||||
let ssRes = await app.Editor.GetSelection({
|
||||
Msg: "选择多段线移除重复点:",
|
||||
Filter: { filterTypes: [Polyline] }
|
||||
});
|
||||
if (ssRes.Status !== PromptStatus.OK) return;
|
||||
let ents = ssRes.SelectSet.SelectEntityList as Polyline[];
|
||||
|
||||
for (let en of ents)
|
||||
en.RemoveRepeatPos();
|
||||
}
|
||||
}
|
Loading…
Reference in new issue