You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
WebCAD/__test__/Polyline/RemoveRepPos.test.ts

34 lines
2.1 KiB

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);
});