优化:在布尔运算结果为空时删除面域

pull/1996/head
ChenX 2 years ago
parent 844be4b87f
commit f1ef48dd80

@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`并集错误,错误的曲线包含 1`] = `"20000.00500"`;
exports[`并集错误,错误的曲线包含 1`] = `"20000.01000"`;

@ -182,7 +182,7 @@ exports[`精度不一致导致的错误: 走刀数量 1`] = `4`;
exports[`超级复杂造型01 1`] = `"23338.03269"`;
exports[`超级复杂造型01 2`] = `"11855.39980"`;
exports[`超级复杂造型01 2`] = `"11855.39981"`;
exports[`超级复杂造型01 3`] = `"9.89484"`;

@ -2,10 +2,8 @@
exports[`求交集错误 1`] = `2`;
exports[`求交集错误 2`] = `1`;
exports[`求交集错误 2`] = `0`;
exports[`求交集错误 3`] = `"7704.00000"`;
exports[`求交集错误 4`] = `"5771.53229"`;
exports[`求交集错误 5`] = `"0.00000"`;

@ -5,7 +5,8 @@ import { LoadEntityFromFileData } from "../Utils/LoadEntity.util";
test('求交集错误', () =>
{
let d = [2, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [9.094947017729282e-12, -1411.0000000000002], 0, [9.094947017729282e-12, 2423], 0, [-17.999999999990905, 2423], 0, [-17.999999999990905, -1411.0000000000002], 0, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.5140442132778844, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.5140442132778844, 0, 0, 1], 0, 2, 8, [540, 0], 0, [540, 102], 0, [552, 102], 0, [561, 2329], 0, [-0.5140442132778844, 2329], 0, [-0.5140442132778844, 2329], 0, [-0.5140442132778844, 2329], 0, [0, 0], 0, true];
let d =
[2, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [9.094947017729282e-12, -1411.0000000000002], 0, [9.094947017729282e-12, 2423], 0, [-17.999999999990905, 2423], 0, [-17.999999999990905, -1411.0000000000002], 0, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.5140442132778844, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.5140442132778844, 0, 0, 1], 0, 2, 8, [540, 0], 0, [540, 102], 0, [552, 102], 0, [561, 2329], 0, [-0.5140442132778844, 2329], 0, [-0.5140442132778844, 2329], 0, [-0.5140442132778844, 2329], 0, [0, 0], 0, true];
let pls = LoadEntityFromFileData(d) as Polyline[];

@ -184,7 +184,7 @@ exports[`简单图形因为点在线内算法错误导致的丢失 3`] = `7.1494
exports[`简单图形因为点在线内算法错误导致的丢失 4`] = `6.693604273021893`;
exports[`精度过高导致无法连接 1`] = `"6723.54630"`;
exports[`精度过高导致无法连接 1`] = `"6723.54634"`;
exports[`精度过高导致的曲线丢失 1`] = `1`;

@ -13,6 +13,10 @@ function RegionsBoolOperate(regs: Region[], boolType: BoolOpeartionType): Region
firstReg.BooleanOper(regs[i], boolType);
regs[i].Erase();
}
if (firstReg.ShapeManager.ShapeCount === 0)
firstReg.Erase();
return firstReg;
}

@ -6,7 +6,7 @@ import { FixIndex } from "../Common/Utils";
import { IntersectBox2 } from "../Geometry/Box";
import { CreateContour2 } from "../Geometry/CreateContour2";
import { Route } from "../Geometry/CurveMap";
import { ComparePointFnGenerate, equaln, equalv2, equalv3 } from "../Geometry/GeUtils";
import { equaln, equalv2, equalv3 } from "../Geometry/GeUtils";
import { RegionParse } from "../Geometry/RegionParse";
import { isTargetCurInOrOnSourceCur } from "../GraphicsSystem/BoolOperateUtils";
import { IntersectOption } from "../GraphicsSystem/IntersectWith";
@ -451,9 +451,6 @@ export class Contour
}
else
{
let fn = ComparePointFnGenerate("xyz", 1e-4);
pts.sort((p1, p2) => fn(p1.pt, p2.pt));
arrayRemoveDuplicateBySort(pts, (p1, p2) => equalv2(p1.pt, p2.pt, 1e-4));
intPars.push(...pts.map(r => r.thisParam));
curveIntParamsMap.set(targetOutline, pts.map(r => r.argParam));
}

@ -337,8 +337,9 @@ const comparePointCache: Map<string, compareVectorFn> = new Map();
*/
export function ComparePointFnGenerate(sortKey: string, fuzz = 1e-8): compareVectorFn
{
if (comparePointCache.has(sortKey))
return comparePointCache.get(sortKey);
let cacheKey = `${sortKey}${fuzz}`;
if (comparePointCache.has(cacheKey))
return comparePointCache.get(cacheKey);
let sortIndex = [];

@ -6,7 +6,7 @@ import { Curve } from '../DatabaseServices/Entity/Curve';
import { Ellipse } from '../DatabaseServices/Entity/Ellipse';
import { Line } from '../DatabaseServices/Entity/Line';
import { Polyline } from '../DatabaseServices/Entity/Polyline';
import { ComparePointFnGenerate, equaln, equalv3 } from '../Geometry/GeUtils';
import { ComparePointFnGenerate, equaln, equalv2, equalv3 } from '../Geometry/GeUtils';
/**
* .
@ -456,6 +456,11 @@ export function IntersectPolylineAndCurve(pl: Polyline, cu: Curve, extType: Inte
}));
}
}
let fn = ComparePointFnGenerate("xyz", tolerance);
intRes.sort((p1, p2) => fn(p1.pt, p2.pt));
arrayRemoveDuplicateBySort(intRes, (p1, p2) => equalv2(p1.pt, p2.pt, tolerance));
return intRes;
}

Loading…
Cancel
Save