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__/Sweep/SweepSegs.test.ts

80 lines
16 KiB

import { HardwareTopline } from "../../src/DatabaseServices/Hardware/HardwareTopline";
import { LoadEntityFromFileData } from "../Utils/LoadEntity.util";
describe("顶线分段测试", () =>
{
test("不闭合直线", () =>
{
let data = { "file": [1, "HardwareTopline", 8, 2, 101, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 1, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -287.8749030927833, -1610.1774753266122, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -259.0799031476998, 7.263922518159916, 0, 1], 0, 2, 12, [327.8749030927833, 1710.1774753266122], 0, [305.5142233177854, 1710.1774753266122], 0, [265.5142233177854, 1630.1774753266122], 0, [227.8749030927833, 1630.1774753266122], 0, [227.8749030927833, 1610.1774753266122], 0, [287.8749030927833, 1610.1774753266122], 0, [287.8749030927833, 1630.1774753266122], 0, [293.72274470531937, 1641.8731585516844], -0.4817330338808767, [307.8749030927833, 1670.1774753266122], 0, [315.06369878080005, 1684.5550667026457], -1.000000000000003, [322.30959178698555, 1699.0468527150167], 0, [327.8749030927833, 1710.1774753266122], 0, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 8, [665.0653753026636, 3.786924939467383], 0, [665.0653753026636, 1051.6513317191284], 0, [2248.2518159806295, 1051.6513317191284], 0, [2248.2518159806295, 274.2953995157385], 0, [3372.9975786924942, 274.2953995157385], 0, [3372.9975786924942, 934.9055690072639], 0, [4594.556900726393, 934.9055690072639], 0, [4594.556900726393, -132.89104116222757], 0, false, 1, 0, "0", "2", "", "", "", "", "", "", "", "", "", 0], "basePt": { "x": 605.0653753026636, "y": -132.89104116222757, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let en = LoadEntityFromFileData(data)[0] as HardwareTopline;
let sgs = en.Segmentations;
for (let sg of sgs)
expect(sg.Length).toMatchSnapshot();
});
test("闭合直线", () =>
{
let data = { "file": [1, "HardwareTopline", 8, 2, 103, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 1, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -287.8749030927833, -1610.1774753266122, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -259.0799031476998, 7.263922518159916, 0, 1], 0, 2, 12, [327.8749030927833, 1710.1774753266122], 0, [305.5142233177854, 1710.1774753266122], 0, [265.5142233177854, 1630.1774753266122], 0, [227.8749030927833, 1630.1774753266122], 0, [227.8749030927833, 1610.1774753266122], 0, [287.8749030927833, 1610.1774753266122], 0, [287.8749030927833, 1630.1774753266122], 0, [293.72274470531937, 1641.8731585516844], -0.4817330338808767, [307.8749030927833, 1670.1774753266122], 0, [315.06369878080005, 1684.5550667026457], -1.000000000000003, [322.30959178698555, 1699.0468527150167], 0, [327.8749030927833, 1710.1774753266122], 0, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 10, [6596.172000387409, 1362.5581683292971], 0, [8676.730470895884, 1362.5581683292971], 0, [9168.976165811138, 364.9402266343825], 0, [9359.311167845035, -639.2409909927355], 0, [8958.95133598063, -1512.156689975786], 0, [7199.993386150121, -1978.1492811622265], 0, [6569.918896658596, -1735.308071670701], 0, [5920.15457937046, -882.082200484261], 0, [5920.15457937046, 181.1685005326874], 0, [6596.172000387409, 1362.5581683292971], 0, false, 1, 0, "0", "2", "", "", "", "", "", "", "", "", "", 0], "basePt": { "x": 5860.15457937046, "y": -2041.1284915962528, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let en = LoadEntityFromFileData(data)[0] as HardwareTopline;
let sgs = en.Segmentations;
for (let sg of sgs)
expect(sg.Length).toMatchSnapshot();
});
test("闭合直线2", () =>
{
let data = { "file": [1, "HardwareTopline", 8, 2, 125, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 1, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -287.8749030927833, -1610.1774753266122, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -259.0799031476998, 7.263922518159916, 0, 1], 0, 2, 12, [327.8749030927833, 1710.1774753266122], 0, [305.5142233177854, 1710.1774753266122], 0, [265.5142233177854, 1630.1774753266122], 0, [227.8749030927833, 1630.1774753266122], 0, [227.8749030927833, 1610.1774753266122], 0, [287.8749030927833, 1610.1774753266122], 0, [287.8749030927833, 1630.1774753266122], 0, [293.72274470531937, 1641.8731585516844], -0.4817330338808767, [307.8749030927833, 1670.1774753266122], 0, [315.06369878080005, 1684.5550667026457], -1.000000000000003, [322.30959178698555, 1699.0468527150167], 0, [327.8749030927833, 1710.1774753266122], 0, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 13, [1015.8635290455081, -2009.9663326486714], 0, [1130.2226351130905, -3672.571797785067], 0, [-92.5401143787551, -3672.571797785067], 0, [-92.5401143787551, -5185.630739602315], 0, [1042.2540919841813, -5185.630739602315], 0, [1042.2540919841813, -6742.67395298402], 0, [2775.2343916237037, -6742.67395298402], 0, [2775.2343916237037, -5475.926931927717], 0, [4824.901446527302, -5475.926931927717], 0, [4824.901446527302, -3575.8064003432655], 0, [3311.8425047100536, -3575.8064003432655], 0, [3311.8425047100536, -2009.9663326486714], 0, [1015.8635290455081, -2009.9663326486714], 0, false, 1, 0, "0", "2", "", "", "", "", "", "", "", "", "", 0], "basePt": { "x": -132.5401143787559, "y": -6782.67395298402, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let en = LoadEntityFromFileData(data)[0] as HardwareTopline;
let sgs = en.Segmentations;
for (let sg of sgs)
expect(sg.Length).toMatchSnapshot();
});
test("不闭合直线圆弧", () =>
{
let data = { "file": [1, "HardwareTopline", 8, 2, 138, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 1, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -287.8749030927833, -1610.1774753266122, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -259.0799031476998, 7.263922518159916, 0, 1], 0, 2, 12, [327.8749030927833, 1710.1774753266122], 0, [305.5142233177854, 1710.1774753266122], 0, [265.5142233177854, 1630.1774753266122], 0, [227.8749030927833, 1630.1774753266122], 0, [227.8749030927833, 1610.1774753266122], 0, [287.8749030927833, 1610.1774753266122], 0, [287.8749030927833, 1630.1774753266122], 0, [293.72274470531937, 1641.8731585516844], -0.4817330338808767, [307.8749030927833, 1670.1774753266122], 0, [315.06369878080005, 1684.5550667026457], -1.000000000000003, [322.30959178698555, 1699.0468527150167], 0, [327.8749030927833, 1710.1774753266122], 0, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 7, [8161.170129063812, -4825.736011624398], 0, [10274.422826954877, -4535.8983420362665], -0.3209968703598907, [13631.804665466512, -3515.33299725931], 0.6961040990362499, [16433.95143649677, -4968.781221551193], 0, [18722.67479532548, -6256.188110892344], 0, [17900.164838246415, -8366.104957312566], 0, [13847.2172236539, -8938.285797019744], 0, false, 1, 0, "0", "2", "", "", "", "", "", "", "", "", "", 0], "basePt": { "x": 8153.017308542492, "y": -8997.696665063295, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let en = LoadEntityFromFileData(data)[0] as HardwareTopline;
let sgs = en.Segmentations;
for (let sg of sgs)
expect(sg.Length).toMatchSnapshot();
});
test("不闭合直线圆弧2", () =>
{
let data = { "file": [1, "HardwareTopline", 8, 2, 176, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 1, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -287.8749030927833, -1610.1774753266122, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -259.0799031476998, 7.263922518159916, 0, 1], 0, 2, 12, [327.8749030927833, 1710.1774753266122], 0, [305.5142233177854, 1710.1774753266122], 0, [265.5142233177854, 1630.1774753266122], 0, [227.8749030927833, 1630.1774753266122], 0, [227.8749030927833, 1610.1774753266122], 0, [287.8749030927833, 1610.1774753266122], 0, [287.8749030927833, 1630.1774753266122], 0, [293.72274470531937, 1641.8731585516844], -0.4817330338808767, [307.8749030927833, 1670.1774753266122], 0, [315.06369878080005, 1684.5550667026457], -1.000000000000003, [322.30959178698555, 1699.0468527150167], 0, [327.8749030927833, 1710.1774753266122], 0, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 6, [4897.356760796507, -13021.199375936494], 0, [9215.002456548624, -12210.606888994527], -1.5675361689042855, [8896.50860624945, -15932.715247401524], 0.6586041364016083, [13810.3273614602, -19298.493791077715], 0.5762572382754851, [19488.91928472054, -20035.357142623532], 1.0469568095664106, [24641.13993498401, -15563.349756617026], 0, false, 1, 0, "0", "2", "", "", "", "", "", "", "", "", "", 0], "basePt": { "x": 4886.285807460384, "y": -20100.459726764348, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let en = LoadEntityFromFileData(data)[0] as HardwareTopline;
let sgs = en.Segmentations;
for (let sg of sgs)
expect(sg.Length).toMatchSnapshot();
});
test("闭合圆弧", () =>
{
let data = { "file": [1, "HardwareTopline", 8, 2, 212, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 1, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -287.8749030927833, -1610.1774753266122, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -259.0799031476998, 7.263922518159916, 0, 1], 0, 2, 12, [327.8749030927833, 1710.1774753266122], 0, [305.5142233177854, 1710.1774753266122], 0, [265.5142233177854, 1630.1774753266122], 0, [227.8749030927833, 1630.1774753266122], 0, [227.8749030927833, 1610.1774753266122], 0, [287.8749030927833, 1610.1774753266122], 0, [287.8749030927833, 1630.1774753266122], 0, [293.72274470531937, 1641.8731585516844], -0.4817330338808767, [307.8749030927833, 1670.1774753266122], 0, [315.06369878080005, 1684.5550667026457], -1.000000000000003, [322.30959178698555, 1699.0468527150167], 0, [327.8749030927833, 1710.1774753266122], 0, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 9, [26918.40309536543, -6762.519351691368], 0, [30726.6994741038, -2358.141800628734], -0.5886269825401041, [35793.38943886006, -3417.8416625385407], 1.9631692691925628, [37945.904783364356, -536.7826629712545], -0.9869745189351885, [37945.904783364356, 2675.4325434428465], -0.15411492859354337, [45198.2257133096, 489.8015782538714], -0.7492501709688599, [41952.894886210815, -9511.115868519928], -0.13168435817007573, [31223.433784374025, -6298.900662105827], 0.3425423322181609, [26918.40309536543, -6762.519351691368], 0, false, 1, 0, "0", "2", "", "", "", "", "", "", "", "", "", 0], "basePt": { "x": 26006.740732473027, "y": -9571.090590925047, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let en = LoadEntityFromFileData(data)[0] as HardwareTopline;
let sgs = en.Segmentations;
for (let sg of sgs)
expect(sg.Length).toMatchSnapshot();
});
test("不闭合多补圆弧", () =>
{
let data =
{ "file": [1, "HardwareTopline", 8, 2, 461, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 1, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -287.8749030927833, -1610.1774753266122, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -259.0799031476998, 7.263922518159916, 0, 1], 0, 2, 12, [327.8749030927833, 1710.1774753266122], 0, [305.5142233177854, 1710.1774753266122], 0, [265.5142233177854, 1630.1774753266122], 0, [227.8749030927833, 1630.1774753266122], 0, [227.8749030927833, 1610.1774753266122], 0, [287.8749030927833, 1610.1774753266122], 0, [287.8749030927833, 1630.1774753266122], 0, [293.72274470531937, 1641.8731585516844], -0.4817330338808767, [307.8749030927833, 1670.1774753266122], 0, [315.06369878080005, 1684.5550667026457], -1.000000000000003, [322.30959178698555, 1699.0468527150167], 0, [327.8749030927833, 1710.1774753266122], 0, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 9, [45751.96592203299, 3086.036062563707], 0.22239155538431857, [52423.0828344913, 5938.5569393828955], 1.1461811427928006, [56463.47934476306, 3849.018445843789], 1.043480940008842, [62001.088374224215, 3387.691765452039], 0.8769933217842865, [68693.87601580269, 3758.4758746386747], 0.798237664392203, [75267.09679427171, 4091.702169937928], -0.8843311793277688, [80944.03676807143, 3824.3355122590892], -1.0886924073122075, [88681.92945847644, 2000.566713469759], -0.803057870546459, [94187.65216324253, -492.2642729771228], 0, false, 1, 0, "0", "2", "", "", "", "", "", "", "", "", "", 0], "basePt": { "x": 45750.62233582299, "y": -504.6289351196049, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let en = LoadEntityFromFileData(data)[0] as HardwareTopline;
let sgs = en.Segmentations;
for (let sg of sgs)
expect(sg.Length).toMatchSnapshot();
});
test("三维顶线", () =>
{
let data =
{ "file": [1, "HardwareTopline", 10, 2, 289, 0, 1, 7, 71, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 4796.814917280106, -649.6766791599803, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 4796.814917280106, -649.6766791599803, 0, 1], 0, 0, 1, 2, "Polyline", 10, 2, 0, 0, 0, 7, 71, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1794.6800494579688, -752.3551866479207, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1794.6800494579688, -752.3551866479207, 0, 1], 0, 0, 1, 2, 12, [1691.4177159478995, 702.8822712717154], 0, [1714.7698425753852, 679.5301446442261], 0, [1714.7698425753852, 679.5301446442261], 0, [1714.7698425753852, 679.5301446442261], 0, [1746.210156625953, 710.970458694799], 0, [1775.6109646391687, 681.5696506815787], 0, [1811.5243923180442, 717.4830783604598], 0, [1851.9100343613813, 677.0974363171161], 0, [1851.9100343613813, 677.0974363171161], 0, [1900.5427993008007, 725.7302012565432], 0, [1799.7364779468508, 826.5365226105092], 0, [1691.4177159478995, 702.8822712717154], 0, false, 2, "Polyline", 10, 2, 239, 1, 1, 7, 71, [0, -1, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 1756.7709279402495, 0, 0, 1], 0, 0, 1, [0, -1, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 1756.7709279402495, 0, 0, 1], 0, 0, 1, 2, 4, [0, -1759.3364756864237], 0, [2540.6486638849437, -1754.5919838318846], 0, [2540.6486638849437, 2676.716809211834], 0, [0, 2676.716809211834], 0, false, "Polyline", 10, 2, 242, 1, 1, 7, 71, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1], 0, 0, 1, 2, 4, [1756.7709279402495, 2676.716809211834], 0, [-1452.394394942868, 2676.716809211834], 0, [-1452.394394942868, -1759.3364756864237], 0, [1756.7709279402495, -1759.3364756864237], 0, false, 1, 0, "0", "2", "", "", "", "23", "", "", "", "", "", 0], "basePt": { "x": 3238.557772494406, "y": -3296.1880928879395, "z": -1865.1992255292557 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let en = LoadEntityFromFileData(data)[0] as HardwareTopline;
let sgs = en.Segmentations;
for (let sg of sgs)
expect(sg.Length).toMatchSnapshot();
});
});