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/CreateContours.test.ts

22 lines
4.3 KiB

import { Curve } from "../../src/DatabaseServices/Entity/Curve";
import { Polyline } from "../../src/DatabaseServices/Entity/Polyline";
import { CreateContour2 } from "../../src/Geometry/CreateContour2";
import { LoadCurvesFromFileData } from "../Utils/LoadEntity.util";
test('创建外部轮廓', () =>
{
let d = { "file": [5, "Line", 11, 2, 104, 0, 1, 7, 0, [-1, 0, 1.2246467991473532e-16, 0, 0, 1, 0, 0, -1.2246467991473532e-16, 0, -1, 0, 1164.6744409023404, 335.0778781038374, 94.62259909393966, 1], 0, 0, 1, [-1, 0, 1.2246467991473532e-16, 0, 0, 1, 0, 0, -1.2246467991473532e-16, 0, -1, 0, 1164.6744409023404, 335.0778781038374, 94.62259909393966, 1], 0, 0, 1, 61, 1, [0, -205.02934537246045, 0], [529.6591422121895, -205.02934537246045, 0], "Line", 11, 2, 105, 0, 1, 7, 0, [-1, 0, 1.2246467991473532e-16, 0, 0, 1, 0, 0, -1.2246467991473532e-16, 0, -1, 0, 1164.6744409023404, 335.0778781038374, 94.62259909393966, 1], 0, 0, 1, [-1, 0, 1.2246467991473532e-16, 0, 0, 1, 0, 0, -1.2246467991473532e-16, 0, -1, 0, 1164.6744409023404, 335.0778781038374, 94.62259909393966, 1], 0, 0, 1, 61, 1, [529.6591422121895, -205.02934537246045, 0], [529.6591422121895, -100.00000000000003, 0], "Arc", 11, 2, 106, 0, 1, 7, 0, [-1, 0, 1.2246467991473532e-16, 0, 0, 1, 0, 0, -1.2246467991473532e-16, 0, -1, 0, 735.015298690151, 235.0778781038374, 94.6225990939397, 1], 0, 0, 1, [-1, 0, 1.2246467991473532e-16, 0, 0, 1, 0, 0, -1.2246467991473532e-16, 0, -1, 0, 735.015298690151, 235.0778781038374, 94.6225990939397, 1], 0, 0, 1, 61, 2, 100.00000000000003, 0, 1.5707963267948966, 0, "Line", 11, 2, 107, 0, 1, 7, 0, [-1, 0, 1.2246467991473532e-16, 0, 0, 1, 0, 0, -1.2246467991473532e-16, 0, -1, 0, 1164.6744409023404, 335.0778781038374, 94.62259909393966, 1], 0, 0, 1, [-1, 0, 1.2246467991473532e-16, 0, 0, 1, 0, 0, -1.2246467991473532e-16, 0, -1, 0, 1164.6744409023404, 335.0778781038374, 94.62259909393966, 1], 0, 0, 1, 61, 1, [429.6591422121895, 0, 0], [0, 0, 0], "Line", 11, 2, 108, 0, 1, 7, 0, [-1, 0, 1.2246467991473532e-16, 0, 0, 1, 0, 0, -1.2246467991473532e-16, 0, -1, 0, 1164.6744409023404, 335.0778781038374, 94.62259909393966, 1], 0, 0, 1, [-1, 0, 1.2246467991473532e-16, 0, 0, 1, 0, 0, -1.2246467991473532e-16, 0, -1, 0, 1164.6744409023404, 335.0778781038374, 94.62259909393966, 1], 0, 0, 1, 61, 1, [0, 0, 0], [0, -205.02934537246045, 0]], "basePt": { "x": 635.0152986901509, "y": 130.04853273137695, "z": 94.62259909393966 }, "ucs": [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1] };
let con = LoadCurvesFromFileData(d);
let cu = CreateContour2(con).Curve as Polyline;
expect(cu.LineData).toMatchSnapshot();
});
test('创建外部轮廓2', () =>
{
let d = { "file": [1, "Polyline", 11, 2, 5032, 0, 1, 7, 71, [-1, 1.1102230246251565e-16, 0, 0, 2.465190328815662e-32, 2.220446049250313e-16, 1, 0, 1.1102230246251565e-16, 1, -2.220446049250313e-16, 0, 35241.53353479059, -17.999999999999616, -3674.8458462047706, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, 61, 2, 21, [0, 0], 0, [-609.4731159461226, 9.968061931431293e-10], 0.1405408347059597, [-646.567464445041, -10.63663326907681], 0, [-685.2446315693451, -34.80480962448382], -0.14054083470579037, [-738.2365579603502, -50.000000000000455], 0, [-1197.7365579789184, -50.000000000325144], 0, [-1597.2770077495006, -127.66279613715642], 0.3590366866002194, [-1637.7365579789184, -176.74415531099976], 0, [-1637.736557977907, -190.00000000105547], 0.4142135623718738, [-1627.7365579789184, -200.00000000000045], 0, [-1197.7365579789184, -200.00000000000045], 0, [588.2634420200775, -199.9999999999991], 0, [1018.2634420149698, -199.99999999900047], 0.4142135625138464, [1028.2634420200775, -189.99999999721513], 0, [1028.2634420190734, -176.7441553192566], 0.3590366865886623, [987.8038917822851, -127.66279613787356], 0, [588.2634420210816, -50], 0, [128.7634420037357, -49.999999999001375], -0.1405408347049536, [75.7715156149352, -34.8048096241273], 0, [37.094348498707404, -10.636633273863481], 0.14054083475470996, [-3.637978807091713e-11, 0], 0, false], "basePt": { "x": 34213.270092770515, "y": -17.999999999999847, "z": -3874.845846204771 }, "ucs": [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1] };
let con = LoadCurvesFromFileData(d)[0] as Polyline;
let cus = con.Explode() as Curve[];
let pl = CreateContour2(cus).Curve as Polyline;
expect(pl.LineData).toMatchSnapshot();
});