!1234 修复:切割错误

pull/1234/MERGE
ZoeLeeFZ 4 years ago committed by ChenX
parent 38629063d5
commit a661b57c2e

@ -2,6 +2,8 @@
exports[`差集共线(圆) 1`] = `442426.78778792813`; exports[`差集共线(圆) 1`] = `442426.78778792813`;
exports[`差集错误 1`] = `1216051.1666666665`;
exports[`差集问题 1`] = `546438.8158863322`; exports[`差集问题 1`] = `546438.8158863322`;
exports[`弧形板差集 1`] = `165548.3611026407`; exports[`弧形板差集 1`] = `165548.3611026407`;

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

@ -44,3 +44,16 @@ test("弧形板差集2", () =>
for (let s of regs[0].ShapeManager.ShapeList) for (let s of regs[0].ShapeManager.ShapeList)
expect(s.Area).toMatchSnapshot(); expect(s.Area).toMatchSnapshot();
}); });
test("差集错误", () =>
{
let d = { "file": [2, "Region", 8, 2, 104, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2485.841337666032, 3556.345601907233, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2485.841337666032, 3556.345601907233, 0, 1], 0, 1, 1, 1, 1, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2485.841337666032, 3556.345601907233, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2485.841337666032, 1254.3456019072328, 0, 1], 0, 2, 6, [482, -2302], 0, [481.9999999999991, -1476], 0, [564, -1476.0000000000002], 0, [564, 0], 0, [0, 0], 0, [0, -2302], 0, true, 0, "Region", 8, 2, 105, false, 1, 7, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 2967.841337666032, 1254.3489352405668, 0, 1], 0, 0, true, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 2967.841337666032, 1254.3489352405668, 0, 1], 0, 1, 1, 1, 1, "Polyline", 8, 2, 0, false, 0, 3, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 2967.841337666032, 1254.3489352405668, 0, 1], 0, 0, true, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 2967.841337666032, 1254.3489352405668, 0, 1], 0, 2, 4, [0, 0], 0, [808, 0], 0, [808, 18], 0, [0, 18], 0, true, 0], "basePt": { "x": 2485.841337666032, "y": 1254.3456019072328, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let regs = LoadRegionsFromFileData(d);
regs[0].BooleanOper(regs[1], BoolOpeartionType.Subtract);
expect(regs[0].ShapeManager.ShapeList.length).toBe(1);
for (let s of regs[0].ShapeManager.ShapeList)
expect(s.Area).toMatchSnapshot();
});

@ -16,6 +16,8 @@ import { IntersectBox2 } from "../Geometry/Box";
let cache = new WeakMap(); let cache = new WeakMap();
const COMBINE_FUZZ = 1e-2;
export class Contour export class Contour
{ {
private _Curve: Polyline | Circle; private _Curve: Polyline | Circle;
@ -43,7 +45,7 @@ export class Contour
return; return;
} }
let closeCurve = Contour.Combine(cus, needLink, 1e-2) as Polyline | Circle; let closeCurve = Contour.Combine(cus, needLink, COMBINE_FUZZ) as Polyline | Circle;
if (closeCurve && closeCurve.IsClose) if (closeCurve && closeCurve.IsClose)
{ {
if (closeCurve instanceof Polyline && closeCurve.CloseMark === false) if (closeCurve instanceof Polyline && closeCurve.CloseMark === false)
@ -218,7 +220,7 @@ export class Contour
let targetOutline = target.Curve; let targetOutline = target.Curve;
let isEqualNormal = equalv3(sourceOutline.Normal, targetOutline.Normal, 1e-3); let isEqualNormal = equalv3(sourceOutline.Normal, targetOutline.Normal, 1e-3);
let interPts = sourceOutline.IntersectWith2(targetOutline, IntersectOption.OnBothOperands); let interPts = sourceOutline.IntersectWith2(targetOutline, IntersectOption.OnBothOperands, COMBINE_FUZZ);
let sourceContainerTarget = this.CuInOutline(targetOutline); let sourceContainerTarget = this.CuInOutline(targetOutline);
let targetContainerSource = target.CuInOutline(sourceOutline); let targetContainerSource = target.CuInOutline(sourceOutline);
@ -301,7 +303,7 @@ export class Contour
let isEqualNormal = equalv3(sourceOutline.Normal, targetOutline.Normal, 1e-3); let isEqualNormal = equalv3(sourceOutline.Normal, targetOutline.Normal, 1e-3);
let interPts = sourceOutline.IntersectWith2(targetOutline, IntersectOption.OnBothOperands, 1e-3); let interPts = sourceOutline.IntersectWith2(targetOutline, IntersectOption.OnBothOperands, COMBINE_FUZZ);
if (interPts.length <= 1) if (interPts.length <= 1)
{ {
@ -409,7 +411,7 @@ export class Contour
if (!IntersectBox2(outBox, targetOutline.BoundingBox)) if (!IntersectBox2(outBox, targetOutline.BoundingBox))
continue; continue;
let pts = sourceOutline.IntersectWith2(con.Curve, IntersectOption.OnBothOperands, 1e-3); let pts = sourceOutline.IntersectWith2(con.Curve, IntersectOption.OnBothOperands, COMBINE_FUZZ);
if (pts.length <= 1) if (pts.length <= 1)
{ {
//反包含 //反包含

Loading…
Cancel
Save