修复:轮廓偏移失败 fix #I7CTIO

pull/2249/MERGE
ChenX 1 year ago
parent 4b9ff0712d
commit 719dbbf6df

@ -1,5 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`因为错误的点在多段线内部导致的偏移错误 1`] = `"2029.61915"`;
exports[`圆裁剪精度 1`] = `1`;
exports[`圆裁剪精度 2`] = `"8360.62214"`;

@ -1,9 +1,9 @@
import { Factory } from "../../src/DatabaseServices/CADFactory";
import { Curve } from "../../src/DatabaseServices/Entity/Curve";
import { Polyline } from "../../src/DatabaseServices/Entity/Polyline";
import { LoadEntityFromFileData } from "../Utils/LoadEntity.util";
import "../Utils/jest.util";
import { OffsetPolyline } from "../../src/GraphicsSystem/OffsetPolyline";
import "../Utils/jest.util";
import { LoadEntityFromFileData } from "../Utils/LoadEntity.util";
Factory(Polyline);
@ -1089,3 +1089,10 @@ test('精度问题导致的连接错误', () =>
)[0];
testOffset(pl, 2.4254);
});
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] };
});

@ -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();
});

@ -128,13 +128,13 @@ export function IsPointInPolyLine(pl: Polyline, pt: Vector3): boolean
}
if (equaln(sp.x, pt.x) && sp.y > pt.y)
{
let der = arc.GetFistDeriv(0);
let der = arc.GetFistDeriv(0).normalize();
if (der.x < -1e-5)
crossings++;
}
if (equaln(ep.x, pt.x) && ep.y > pt.y)
{
let der = arc.GetFistDeriv(1);
let der = arc.GetFistDeriv(1).normalize();
if (der.x > 1e-5)
crossings++;
}
@ -144,8 +144,8 @@ export function IsPointInPolyLine(pl: Polyline, pt: Vector3): boolean
if (pti.y < pt.y || equalv3(sp, pti, 1e-5) || equalv3(ep, pti, 1e-5))
continue;
let der = arc.GetFistDeriv(pti);
if (!equaln(der.x, 0)) //相切.
let der = arc.GetFistDeriv(pti).normalize();
if (!equaln(der.y, 0, 1e-5)) //相切.
crossings++;
}
}

Loading…
Cancel
Save