修复:并集计算错误

pull/2437/MERGE
ChenX 10 months ago
parent e360f2855c
commit 91201a5eec

@ -1,5 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`并集错误 1`] = `"580529.02133"`;
exports[`并集错误 2`] = `1`;
exports[`无法求到交集 1`] = `6966`;
exports[`精度不一致导致的板件显示错误 1`] = `"84"`;

@ -1,4 +1,5 @@
import { Board } from "../../src/DatabaseServices/Entity/Board";
import { Region } from "../../src/DatabaseServices/Entity/Region";
import { BoolOpeartionType } from "../../src/GraphicsSystem/BoolOperateUtils";
import { LoadEntityFromFileData, LoadRegionsFromFileData } from "../Utils/LoadEntity.util";
import "../Utils/jest.util";
@ -25,3 +26,20 @@ test('精度不一致导致的板件显示错误', () =>
expect(br.MeshGeometry.getAttribute("position").count).toMatchNumberSnapshot(0);
});
test('并集错误', () =>
{
//原因: 两条线 已经相似(fastEqualCurve) 在判断方向相同时,因为精度问题,我们错误的认为它不同向,将判断同向的精度改成0.01后解决
let d = { "file": [2, "Region", 10, 2, 106, 0, 1, 7, 71, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 863.9694986599663, 458.07124371859294, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 863.9694986599663, 458.07124371859294, 0, 1], 0, 0, 1, 1, 1, 1, 1, "Polyline", 10, 2, 0, 0, 0, 7, 71, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 863.9694986599663, 458.07124371859294, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 863.9694986599663, 458.07124371859294, 0, 1], 0, 0, 1, 2, 11, [487.3242, 322.0844], 0, [498.26980000000003, 538.7396], 0, [499.17220000000003, 755.6124], 0, [490.02970000000005, 972.3511000000001], 0, [455.53470000000004, 1303.1193], 0, [-2.5761000000000003, 1238.6734000000001], 0, [30.600900000000003, 881.4381000000001], 0, [36.0287, 647.2415000000001], 0, [28.446, 413.1016], 0, [-8.023100000000001, 56.1227], 0, [450.08520000000004, -8.3225], 0, true, 0, "Region", 10, 2, 107, 0, 1, 7, 71, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 863.9694986599663, 458.07124371859294, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 863.9694986599663, 458.07124371859294, 0, 1], 0, 0, 1, 1, 1, 1, 1, "Polyline", 10, 2, 0, 0, 0, 7, 71, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 863.9694986599663, 458.07124371859294, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 863.9694986599663, 458.07124371859294, 0, 1], 0, 0, 1, 2, 14, [431.2735, 107.0175], 0, [452.0221, 322.5664], 0, [462.70520000000005, 538.8478], 0, [463.2995, 755.3922], 0, [453.80260000000004, 971.7552000000001], 0, [419.08840000000004, 1297.9876000000002], 0, [405.99760000000003, 1296.1904], 0, [439.3514, 970.7397000000001], 0, [448.81690000000003, 755.0946], 0, [448.2244, 539.224], 0, [437.57460000000003, 323.6175], 0, [416.8883, 108.7181], 0, [402.36, -1.6169], 0, [415.41150000000005, -3.4817], 0, true, 0], "basePt": { "x": 855.9463986599663, "y": 449.74874371859295, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let regs = LoadEntityFromFileData(d) as Region[];
let ok = regs[0].BooleanOper(regs[1], BoolOpeartionType.Union);
expect(ok).toBeTruthy();
expect(regs[0].Area).toMatchNumberSnapshot();
expect(regs[0].ShapeManager.ShapeList.length).toMatchSnapshot();
});

@ -283,7 +283,7 @@ export class Contour
{
//方向相同
if (
equalv3(cu.GetFirstDeriv(cu.MidParam).normalize(), pl.GetFirstDeriv(pl.MidParam).normalize(), 1e-3)
equalv3(cu.GetFirstDeriv(cu.MidParam).normalize(), pl.GetFirstDeriv(pl.MidParam).normalize(), 1e-2)
=== isEqualNormal
)
{

Loading…
Cancel
Save