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__/Fillet/ParalleLine.test.ts

64 lines
7.3 KiB

import { FilletRes, FilletUtils } from "../../src/Add-on/FilletUtils";
import { CADFiler } from "../../src/DatabaseServices/CADFiler";
import { Entity } from "../../src/DatabaseServices/Entity/Entity";
import { Line } from "../../src/DatabaseServices/Entity/Line";
import { PromptEntityResult } from "../../src/Editor/PromptResult";
import { LoadEntityFromFileData } from "../Utils/LoadEntity.util";
function expectEntity(e: Entity)
{
let f = new CADFiler();
e.WriteFile(f);
expect(f.Data).toMatchSnapshot();
}
function expectxSnapshot(fres: FilletRes)
{
let l1 = fres.cu1 as Line;
let l2 = fres.cu2 as Line;
let arc = fres.arc;
expect(l1.StartPoint).toMatchSnapshot();
expect(l1.EndPoint).toMatchSnapshot();
expect(l2.StartPoint).toMatchSnapshot();
expect(l2.EndPoint).toMatchSnapshot();
expectEntity(arc);
}
test('平行线倒角', () =>
{
let filletUtil = new FilletUtils();
let d =
{ "file": [26, "Line", 5, 2, 165, false, 1, 7, 0, [0, -0.9195768791852731, 0.3929101211064353, 0, 0, -0.3929101211064353, -0.9195768791852731, 0, 1, 0, 0, 0, 0, 14623.719240410923, 2429.6470638527735, 1], 0, 0, 1, [1692.670818240843, 343.04557415800707, 0], [3372.3693514346232, 2642.1329414669926, 0], "Line", 5, 2, 166, false, 1, 7, 0, [0, -0.9195768791852731, 0.3929101211064353, 0, 0, -0.3929101211064353, -0.9195768791852731, 0, 1, 0, 0, 0, 0, 14568.429154096713, 2567.433469429394, 1], 0, 0, 1, [1692.670818240843, 343.04557415800707, 0], [3372.3693514346232, 2642.1329414669926, 0], "Line", 5, 2, 163, false, 1, 7, 0, [0, 0.39291012110643525, 0.9195768791852731, 0, 0, -0.9195768791852731, 0.39291012110643525, 0, 1, 0, 0, 0, 0, 6203.497215967531, -2471.1785825859374, 1], 0, 0, 1, [1692.670818240843, 343.04557415800707, 0], [3372.3693514346232, 2642.1329414669926, 0], "Line", 5, 2, 164, false, 1, 7, 0, [0, 0.39291012110643525, 0.9195768791852731, 0, 0, -0.9195768791852731, 0.39291012110643525, 0, 1, 0, 0, 0, 0, 6341.283621544151, -2415.888496271727, 1], 0, 0, 1, [1692.670818240843, 343.04557415800707, 0], [3372.3693514346232, 2642.1329414669926, 0], "Line", 5, 2, 161, false, 1, 7, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1], 0, 0, 1, [1692.670818240843, 343.04557415800707, 0], [3372.3693514346232, 2642.1329414669926, 0], "Line", 5, 2, 162, false, 1, 7, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 104.98115832463645, -104.98115832460257, 1], 0, 0, 1, [1692.670818240843, 343.04557415800707, 0], [3372.3693514346232, 2642.1329414669926, 0], "Line", 5, 2, 101, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, [145.9330143540669, -28.708133971291886, 0], [145.9330143540669, 325.3588516746412, 0], "Line", 5, 2, 102, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, [184.21052631578942, -27.511961722488138, 0], [184.21052631578942, 316.98564593301444, 0], "Line", 5, 2, 103, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, [510.76555023923447, -57.41626794258377, 0], [510.76555023923447, 355.2631578947369, 0], "Line", 5, 2, 104, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, [562.200956937799, 361.244019138756, 0], [562.200956937799, -130.38277511961724, 0], "Line", 5, 2, 110, false, 0, 7, 0, [0.8214737453237212, -0.5702463377732627, 0, 0, 0.5702463377732627, 0.8214737453237212, 0, 0, 0, 0, 1, 0, 1192.7055566180743, 222.97759104658724, 0, 1], 0, 0, 1, [145.93301435406704, -27.511961722488195, 0], [145.9330143540669, 325.3588516746412, 0], "Line", 5, 2, 111, false, 0, 7, 0, [0.8214737453237212, -0.5702463377732627, 0, 0, 0.5702463377732627, 0.8214737453237212, 0, 0, 0, 0, 1, 0, 1192.7055566180743, 222.97759104658724, 0, 1], 0, 0, 1, [184.21052631578942, -27.511961722488138, 0], [184.21052631578948, 325.3588516746413, 0], "Line", 5, 2, 112, false, 0, 7, 0, [0.8214737453237212, -0.5702463377732627, 0, 0, 0.5702463377732627, 0.8214737453237212, 0, 0, 0, 0, 1, 0, 1192.7055566180743, 222.97759104658724, 0, 1], 0, 0, 1, [510.7655502392346, -130.38277511961724, 0], [510.76555023923447, 355.2631578947369, 0], "Line", 5, 2, 113, false, 0, 7, 0, [0.8214737453237212, -0.5702463377732627, 0, 0, 0.5702463377732627, 0.8214737453237212, 0, 0, 0, 0, 1, 0, 1192.7055566180743, 222.97759104658724, 0, 1], 0, 0, 1, [562.2009569377991, 355.2631578947369, 0], [562.200956937799, -130.38277511961724, 0], "Line", 5, 2, 134, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, [2647.8208243286344, 317.92433298415114, 0], [3169.8822406013596, 317.92433298415114, 0], "Line", 5, 2, 135, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, [2722.4010266533096, 227.5240877421207, 0], [3337.122694299116, 227.5240877421207, 0], "Line", 5, 2, 149, false, 1, 7, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1], 0, 0, 1, [2907.9548191037384, 493.8714486099474, 0], [2907.9548191037384, 1488.0701817589372, 0], "Line", 5, 2, 150, false, 1, 7, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1], 0, 0, 1, [3024.1598658354383, 1494.526017688476, 0], [3024.1598658354383, 355.0709761248611, 0], "Line", 5, 2, 153, false, 1, 7, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1], 0, 0, 1, [3705.2505564017906, 280.8288629351637, 0], [3705.2505564017906, 1568.7681308781732, 0], "Line", 5, 2, 154, false, 1, 7, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1], 0, 0, 1, [3869.8743726050325, 287.28469886470253, 0], [3869.8743726050325, 1546.1727051247872, 0], "Line", 5, 2, 157, false, 1, 7, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1], 0, 0, 1, [5086.799445323114, 468.04810489179147, 0], [5086.799445323114, 1820.5457321301901, 0], "Line", 5, 2, 158, false, 1, 7, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1], 0, 0, 1, [5190.092820195736, 1865.7365836369625, 0], [5190.092820195736, 225.95425753408313, 0], "Line", 5, 2, 136, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, [4345.085428747755, 295.3242716736435, 0], [4776.746599778449, 295.3242716736435, 0], "Line", 5, 2, 137, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, [5095.4074642566065, 191.36398964530858, 0], [4220.785091539963, 191.36398964530858, 0], "Line", 5, 2, 167, false, 1, 7, 0, [0, -1, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, 0, 0, 1], 0, 0, 1, [8996.91886327466, -984.963632541074, 0], [12643.991371767113, 5415.060382361811, 0], "Line", 5, 2, 168, false, 1, 7, 0, [0, -1, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, -447.06050104057067, -447.06050104171936, 1], 0, 0, 1, [8996.91886327466, -984.963632541074, 0], [12643.991371767113, 5415.060382361811, 0]], "basePt": { "x": 0, "y": -13091.051872807684, "z": -1432.0241335827934 } };
let lines = LoadEntityFromFileData(d) as Line[];
for (let i = 0; i < lines.length / 2; i++)
{
let l1 = lines[i * 2];
let l2 = lines[i * 2 + 1];
let e1 = new PromptEntityResult(l1, l1.StartPoint);
let e2 = new PromptEntityResult(l2, l2.StartPoint);
let fres = filletUtil.Fillet(e1, e2);
expectxSnapshot(fres);
e1.Point = l1.EndPoint;
fres = filletUtil.Fillet(e1, e2);
expectxSnapshot(fres);
e1 = new PromptEntityResult(l2, l2.StartPoint);
e2 = new PromptEntityResult(l1, l1.StartPoint);
fres = filletUtil.Fillet(e1, e2);
expectxSnapshot(fres);
e1.Point = l2.EndPoint;
fres = filletUtil.Fillet(e1, e2);
expectxSnapshot(fres);
}
});