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

47 lines
5.2 KiB

import { Factory } from "../../src/DatabaseServices/CADFactory";
import { Curve } from "../../src/DatabaseServices/Entity/Curve";
import { Polyline } from "../../src/DatabaseServices/Entity/Polyline";
import "../Utils/jest.util";
import { LoadEntityFromFileData } from "../Utils/LoadEntity.util";
Factory(Polyline);
function loadFile(data)
{
return LoadEntityFromFileData(data) as Curve[];
}
function EntityToMatchSnapshot(ens: Curve[])
{
expect(ens.length).toMatchSnapshot();
for (let c of ens)
{
expect(c.Length).toMatchNumberSnapshot();
}
}
function testOffset(pl: Curve, dis: number)
{
let cus = pl.GetOffsetCurves(dis);
EntityToMatchSnapshot(cus);
}
test('圆弧被压扁时', () =>
{
let pl = loadFile(
{ "file": [1, "Polyline", 8, 2, 154, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 377.4539113436276, 1247.0593462341237, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 6, [0, 0], 0, [19.763395114298646, 0], 0, [19.763395114298646, -77.16333081989751], 0, [620.8495708336222, 2], 0, [12.422828246409608, 2], 0.07998201834820468, [0, 0], 0, false], "basePt": { "x": 377.4539113436276, "y": 1169.8960154142262, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] }
)[0] as Polyline;
testOffset(pl, -1);
});
//会产生一个全圆,和上面的结果差不多
test('圆弧被压扁时2', () =>
{
let pl = loadFile(
{ "file": [1, "Polyline", 8, 2, 119, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1154.2238497367207, 104.14208322448218, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1154.2238497367207, 104.14208322448218, 0, 1], 0, 2, 60, [612.3014131291516, 516.3528702447977], 0.015806718902080345, [620.7943305625928, 607.0727250842237], 0.015085580217079377, [623.5388275982333, 693.9909315240145], 0.018559911555977058, [619.7184915236674, 800.899678859206], 0.014694123780868687, [611.0748359644397, 885.1634608721657], 0, [610.5937664221115, 885.5638696907919], 0.048351140222397095, [591.8736546167333, 974.856452029918], 0, [589.108411721164, 976.3352094794792], 0.12312867730767327, [549.49737942662, 1070.8379195719986], 0.17558566194791864, [493.1989814833556, 1105.1070499123898], 0, [493.1989814768517, 1106.8145087542505], 0.016687098951025527, [486.7752303851114, 1106.1799845700543], 0.016686934361763963, [480.3515429184599, 1106.814499939058], 0, [480.3515429184599, 1105.1070579994375], 0.1738513267498107, [424.462475564043, 1071.3443793295373], 0.14452030487651513, [385.51999664149616, 987.8692829759501], 0, [381.82742116645204, 985.894619916155], 0.05688790122446251, [362.1606942638914, 899.9341132066843], 0.06913430034215114, [358.36535846878064, 891.585241437522], 0.011951758276873363, [349.5455822495776, 813.8344631655293], 0.016079714858141424, [343.5599042095864, 708.741352103413], 0.012454880979067107, [343.57381445093506, 627.19890258108], 0.0353850507118894, [348.29886924626226, 547.5274109585339], 0, [347.91466794653746, 547.093379771549], 0.07426058357128477, [361.42189294407046, 461.28835523391433], 0, [360.0426715873188, 459.9156011573379], -0.06548790279458117, [360.2851152549719, 357.8786506661694], -0.04227753631212227, [346.33055464305374, 293.3324195844309], -0.056172333674162495, [311.43200724979914, 212.96070379493364], 0, [310.93871631800266, 212.88779827664194], -0.00793399669319285, [307.68508259066056, 206.58515476883855], -0.005919522217160536, [302.8230350758758, 198.70136235145944], 0, [303.28820964677647, 198.77011229634067], -0.07174730482095937, [263.3699447771607, 148.97924018587022], 0, [262.7596522831348, 149.10538038282925], -0.14255049355605404, [182.21024773410883, 113.61003285764781], -0.14077658798903714, [87.93677094888172, 136.03287484008467], 0, [88.19488827221956, 135.1956938030656], -0.04513801259751311, [45.780586931621485, 162.3898499135038], 0.39782128974410047, [-2.044548087593359, 147.4569370104155], 0, [-0.7859749528631816, 146.03276259253875], 0.2472291990501607, [-14.776371068260916, 124.25265858503285], 0.20695219839929455, [1.4915436378485722, 75.92120642684569], 0.013652847267144727, [12.194646194062642, 64.9005592146319], 0.11991101226154251, [126.7108106504181, -2.8175183289565666], 0.06970856590582382, [203.83456674596607, -14.959526923127044], 0.08482062762366688, [297.5168107124458, -0.5828301821931063], 0.08326244171921664, [379.7311114468818, 43.0216754773393], 0, [379.91321780220164, 40.48338437162393], 0.02592982720348706, [445.5507141763875, 108.87936972502882], 0, [445.5627415862375, 108.83630788084449], 0.0027506827909016085, [450.4676088733669, 114.61323114391712], 0.0021728799018758123, [455.5907752184968, 120.69112944801714], 0, [455.5706646369793, 120.76313155754232], 0.032323516875440585, [507.4200586291239, 193.05207203810642], 0.03636742975664602, [554.0598955470364, 281.58061383017815], 0.022695347458021323, [576.4724738949936, 339.9187895342726], 0, [577.3097360534697, 338.5946377731411], 0.02676041600254321, [600.1759496398608, 437.5240861303753], 0.01676422580319205, [614.3076343013773, 533.1181808392147], 0, false], "basePt": { "x": 1139.2238497367207, "y": 89.14208311646485, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] }
)[0] as Polyline;
testOffset(pl, -15);
});