修复:同心圆布尔错误

pull/1485/head
ChenX 3 years ago
parent 6c1fcf5a92
commit fc15b7ee67

@ -1,5 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`同心圆 1`] = `"101735.59416"`;
exports[`同心圆 2`] = `"322593.41488"`;
exports[`同心圆 3`] = `"220857.82072"`;
exports[`造型里面有重复的圆造型 1`] = `2782`; exports[`造型里面有重复的圆造型 1`] = `2782`;
exports[`造型里面有重复的圆造型 2`] = `0`; exports[`造型里面有重复的圆造型 2`] = `0`;

@ -1,5 +1,8 @@
import { BoolOpeartionType } from "../../src/api";
import { Board } from "../../src/DatabaseServices/Entity/Board"; import { Board } from "../../src/DatabaseServices/Entity/Board";
import { LoadEntityFromFileData } from "../Utils/LoadEntity.util"; import { Region } from "../../src/DatabaseServices/Entity/Region";
import "../Utils/jest.util";
import { LoadEntityFromFileData, LoadRegionsFromFileData } from "../Utils/LoadEntity.util";
test('造型里面有重复的圆造型', () => test('造型里面有重复的圆造型', () =>
{ {
@ -13,3 +16,20 @@ test('造型里面有重复的圆造型', () =>
expect(br.Grooves.length).toMatchSnapshot(); expect(br.Grooves.length).toMatchSnapshot();
expect(split.length).toMatchSnapshot(); expect(split.length).toMatchSnapshot();
}); });
test('同心圆', () =>
{
let f = { "file": [2, "Region", 8, 2, 506, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1944.2723126080546, 1489.6275867898448, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1944.2723126080546, 1489.6275867898448, 0, 1], 0, 1, 1, 1, 1, "Circle", 8, 2, 0, false, 0, 1, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1944.2723126080546, 1489.6275867898448, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 1, 320.4444931257359, 0, "Region", 8, 2, 507, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1944.2723126080546, 1489.6275867898448, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1944.2723126080546, 1489.6275867898448, 0, 1], 0, 1, 1, 1, 1, "Circle", 8, 2, 0, false, 0, 2, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1944.2723126080546, 1489.6275867898448, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 1, 179.954009116518, 0], "basePt": { "x": 1623.8278194823188, "y": 1169.183093664109, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let regs = LoadRegionsFromFileData(f) as Region[];
let regs2 = regs.map(r => r.Clone());
let regs3 = regs.map(r => r.Clone());
regs[0].BooleanOper(regs[1], BoolOpeartionType.Intersection);
expect(regs[0].Area).toMatchNumberSnapshot();
regs2[0].BooleanOper(regs2[1], BoolOpeartionType.Union);
expect(regs2[0].Area).toMatchNumberSnapshot();
regs3[0].BooleanOper(regs3[1], BoolOpeartionType.Subtract);
expect(regs3[0].Area).toMatchNumberSnapshot();
});

@ -44,7 +44,7 @@ export function LoadBoardsFromFileData(data)
return LoadEntityFromFileData(data) as Board[]; return LoadEntityFromFileData(data) as Board[];
} }
export function LoadRegionsFromFileData(data) export function LoadRegionsFromFileData(data): Region[]
{ {
return LoadEntityFromFileData(data) as Region[]; return LoadEntityFromFileData(data) as Region[];
} }

@ -218,9 +218,9 @@ export class Contour
if (this._Curve instanceof Circle && target._Curve instanceof Circle && equalv2(this._Curve.Center, target._Curve.Center, 1e-3)) if (this._Curve instanceof Circle && target._Curve instanceof Circle && equalv2(this._Curve.Center, target._Curve.Center, 1e-3))
{ {
if (this._Curve.Radius > target._Curve.Radius) if (this._Curve.Radius > target._Curve.Radius)
return { intersectionList: [this._Curve], unionList: [target._Curve] };
else
return { intersectionList: [target._Curve], unionList: [this._Curve] }; return { intersectionList: [target._Curve], unionList: [this._Curve] };
else
return { intersectionList: [this._Curve], unionList: [target._Curve] };
} }
let intersectionList: Curve[] = []; let intersectionList: Curve[] = [];

@ -373,6 +373,8 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
app.Viewer.ZoomAll(); app.Viewer.ZoomAll();
}, "提取三维刀路"); }, "提取三维刀路");
}; };
//应用异形+造型
private ChangeModeling = async () => private ChangeModeling = async () =>
{ {
await app.Editor.ModalManage.EndExecingCmd(); await app.Editor.ModalManage.EndExecingCmd();

Loading…
Cancel
Save