!2737 修复:切割错误

pull/2733/MERGE
ChenX 5 months ago
parent 20177da8e0
commit 01bc6f4733

@ -8,4 +8,4 @@ exports[`同心圆 3`] = `"220857.82072"`;
exports[`造型里面有重复的圆造型 1`] = `2782`;
exports[`造型里面有重复的圆造型 2`] = `30`;
exports[`造型里面有重复的圆造型 2`] = `20`;

@ -1,5 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`同深度造型槽并集错误 1`] = `"6362640.00000"`;
exports[`并集错误 1`] = `"580529.02133"`;
exports[`并集错误 2`] = `1`;

@ -1,7 +1,8 @@
import { CuttingBoard } from "../../src/Add-on/BoardCutting/CuttingUtils";
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 { LoadBoardsFromFileData, LoadEntityFromFileData, LoadRegionsFromFileData } from "../Utils/LoadEntity.util";
import "../Utils/jest.util";
test('无法求到交集', () =>
@ -43,3 +44,13 @@ test('并集错误', () =>
expect(regs[0].ShapeManager.ShapeList.length).toMatchSnapshot();
});
test('同深度造型槽并集错误', () =>
{
let d = { "file": [2, "Board", 10, 2, 100, 0, 1, 3, 71, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 78, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 78, 0, 1], 0, 0, 1, 3, 600, 600.0000000000001, 18, true, "Polyline", 10, 2, 0, 0, 0, 7, 71, [1, 0, 0, 0, 0, 1, -2.1316282072803007e-16, 0, 0, 2.1316282072803007e-16, 1, 0, 0, 600, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, -930.925507900677, 2.257336342893268, 78.00000000000013, 1], 0, 0, 1, 2, 4, [0, -600], 0, [600.0000000000001, -600], 0, [600.0000000000001, 0], 0, [0, 0], 0, true, 1, 3, 220, 120, 10, true, "Polyline", 10, 2, 0, 0, 0, 7, 71, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 220, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, -1102.8668171557558, -172.16704288961245, 78, 1], 0, 0, 1, 2, 4, [0, -220], 0, [120, -220], 0, [120, 0], 0, [0, 0], 0, true, 1, 3, 200, 100, 10, true, "Polyline", 10, 2, 0, 0, 0, 7, 71, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 200, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, -1112.8668171557558, -182.16704288961245, 78, 1], 0, 0, 1, 2, 4, [0, -200], 0, [100, -200], 0, [100, 0], 0, [0, 0], 0, true, 0, 3, 0, 0, 0, 0, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 181.94130925507886, 69.99999999999987, 184.42437923250571, 1], 3, 0, 0, 0, 0, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 171.94130925507886, 69.99999999999987, 174.42437923250571, 1], 3, 0, 0, 0, 0, 0, 19, 2, "18背板", "", "", "", "", "", 0, 1, "三合一", 2, 0, "0.8", "0.8", "0.8", "0.8", "", "", "", 4, "三合一", "三合一", "三合一", "三合一", false, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, null, 0, 0, "", "", "", "", 0, false, 0, "", "Board", 10, 2, 101, 0, 1, 11, 71, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 227.65808219178084, 4.999999999999872, 20.290716803898704, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1643.7419178082207, 4.999999999999872, -3034.849283196101, 1], 0, 0, 1, 3, 300, 65, 18.4, true, "Polyline", 10, 2, 0, 0, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 321.05999999999995, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, -3055.14, 0, 1], 0, 0, 1, 2, 4, [65, -321.05999999999995], 0, [65, -21.059999999999945], 0, [0, -21.059999999999945], 0, [0, -321.05999999999995], 0, true, 0, 3, 0, 0, 0, 0, 0, 19, 1, "格栅条", "", "", "", "", "", 0, 0, "三合一", 2, 0, "0.8", "0.8", "0.8", "0.8", "", "", "", 4, "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, null, 0, 0, "", "", "", "", 0, false, 0, ""], "basePt": { "x": 0, "y": 4.999999999999872, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1] };
let brs = LoadBoardsFromFileData(d);
let br = brs.shift();
CuttingBoard(br, brs);
expect(br.Volume).toMatchNumberSnapshot();
});

@ -609,10 +609,13 @@ export class ExtrudeSolid extends Entity
let thisShape = this.Shape;
let targetShape = target.Shape.ApplyMatrix(matrixToLocal).Z0();
let unionShapes = thisShape.UnionBoolOperation(targetShape, true);
if (unionShapes.length === 1)
{
this.WriteAllObjectRecord();
//防止重复添加
this.grooves = this.grooves.filter((g) => !equaln(g.thickness, target.thickness, 1e-3));//过滤掉一样的 因为已经在shape里
// [ + ] 产生网洞.
for (let hole of unionShapes[0].Holes)
{
@ -626,7 +629,10 @@ export class ExtrudeSolid extends Entity
this.ContourCurve = unionShapes[0].Outline.Curve;
this.grooves.push(...target.grooves.map(g => g.Clone()));
for (let tg of target.grooves)
if (!equaln(tg.thickness, target.thickness, 1e-3))//过滤掉一样的 因为已经在shape里
this.grooves.push(tg.Clone());
MergeRelevance();
this.GrooveCheckMerge();
this.Update();

Loading…
Cancel
Save