|
|
|
@ -1,3 +1,5 @@
|
|
|
|
|
import { Vector3 } from "three";
|
|
|
|
|
import { CADFiler } from "../../src/DatabaseServices/CADFiler";
|
|
|
|
|
import { Polyline } from "../../src/DatabaseServices/Entity/Polyline";
|
|
|
|
|
import "../Utils/jest.util";
|
|
|
|
|
import { LoadCurvesFromFileData } from "../Utils/LoadEntity.util";
|
|
|
|
@ -18,3 +20,37 @@ test('圆裁剪精度', () =>
|
|
|
|
|
expect(c.Length).toMatchNumberSnapshot();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("错误的点在多段线内部", () =>
|
|
|
|
|
{
|
|
|
|
|
let d = ["Polyline", 10, 2, 0, 0, 0, 7, 0, [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, 5, [-903.9879626621178, 75.79030586302474], -0.1548304020399718, [-68.32112723448535, 75.79030866386893], 0, [-68.01871597353619, 76.74348620727369], 0.1548304020399718, [-904.2903739294563, 76.74348340440224], 0, [-903.9879626621178, 75.79030586302474], 0, false, -486.15450978803466, 140.48362331381213, 0];
|
|
|
|
|
let f = new CADFiler(d);
|
|
|
|
|
let pl = f.ReadObject() as Polyline;
|
|
|
|
|
let p = new Vector3(f.Read(), f.Read(), f.Read());
|
|
|
|
|
expect(pl.PtInCurve(p)).toBeFalsy();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('错误的点在多段线内部2', () =>
|
|
|
|
|
{
|
|
|
|
|
let d =
|
|
|
|
|
["Polyline", 10, 2, 108, 0, 1, 7, 71, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -438.1577281907905, 358.23373269662113, 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, 3, [0, 0], 0.9999999999999999, [-58.58109281699865, 0], -0.7547474747474747, [0, 0], 0, false, -467.44827459928985, 380.3406986324097, 0];
|
|
|
|
|
let f = new CADFiler(d);
|
|
|
|
|
let pl = f.ReadObject() as Polyline;
|
|
|
|
|
let p = new Vector3(f.Read(), f.Read(), f.Read());
|
|
|
|
|
expect(pl.PtInCurve(p)).toBeFalsy();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('因为错误的点在多段线内部导致的偏移错误', () =>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
let d =
|
|
|
|
|
{ "file": [1, "Polyline", 10, 2, 111, 0, 1, 7, 0, [1, 0, 0, 0, 0, 2.220446049250313e-16, 1, 0, 0, -1, 2.220446049250313e-16, 0, 3448.9478393627373, 588.8818635607608, 2277.4901004968165, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, 2, 5, [0, 0], 0.27588288158564067, [-68.01871597353602, 76.74348620727369], 0.1548304020399718, [-904.2903739294561, 76.74348340440201], 0.27588268439117536, [-972.3091079030273, -0.00014195760331858764], 0, [-9.094947017729282e-13, 4.547473508864641e-13], 0, false], "basePt": { "x": 2476.63873145971, "y": 588.8818635607608, "z": 2277.489958539213 }, "ucs": [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 610.4825291181364, 588.8818635607321, 0, 1] };
|
|
|
|
|
let f = new CADFiler(d.file);
|
|
|
|
|
|
|
|
|
|
f.Read();
|
|
|
|
|
let el1 = f.ReadObject() as Polyline;
|
|
|
|
|
|
|
|
|
|
let pls = el1.GetOffsetCurves(-1);
|
|
|
|
|
for (let pl of pls)
|
|
|
|
|
expect(pl.Length).toMatchNumberSnapshot();
|
|
|
|
|
});
|
|
|
|
|