优化:对封边一致的板进行统一偏移,而非单独偏移 fix #I39T1I

pull/1559/MERGE
ChenX 3 years ago
parent 76111bc38e
commit bc5faff5b4

@ -1,7 +1,8 @@
import { Board } from "../../src/DatabaseServices/Entity/Board"; import { Board } from "../../src/DatabaseServices/Entity/Board";
import { Curve } from "../../src/DatabaseServices/Entity/Curve"; import { Curve } from "../../src/DatabaseServices/Entity/Curve";
import { Polyline } from "../../src/DatabaseServices/Entity/Polyline"; import { Polyline } from "../../src/DatabaseServices/Entity/Polyline";
import { CalcEdgeSealing, ParagraphCulist, GetSealedBoardContour } from "../../src/GraphicsSystem/CalcEdgeSealing"; import { CalcEdgeSealing, GetSealedBoardContour, ParagraphCulist } from "../../src/GraphicsSystem/CalcEdgeSealing";
import "../Utils/jest.util";
import { LoadBoardsFromFileData } from "../Utils/LoadEntity.util"; import { LoadBoardsFromFileData } from "../Utils/LoadEntity.util";
function testBrSealing(br: Board, sealingSize: number[]) function testBrSealing(br: Board, sealingSize: number[])
@ -123,7 +124,7 @@ test("椭圆弧封边", () =>
let con = GetSealedBoardContour(br, false); let con = GetSealedBoardContour(br, false);
expect(con.IsClose).toBeTruthy(); expect(con.IsClose).toBeTruthy();
expect(con.Area).toMatchSnapshot(); expect(con.Area2).toMatchNumberSnapshot();
}); });
test("封边错误板件", () => test("封边错误板件", () =>
{ {
@ -133,7 +134,7 @@ test("封边错误板件", () =>
let con = GetSealedBoardContour(br, false); let con = GetSealedBoardContour(br, false);
expect(con.IsClose).toBeTruthy(); expect(con.IsClose).toBeTruthy();
expect(con.Area).toMatchSnapshot(); expect(con.Area2).toMatchNumberSnapshot();
}); });
test("封边错误板件2", () => test("封边错误板件2", () =>
{ {
@ -143,7 +144,7 @@ test("封边错误板件2", () =>
let con = GetSealedBoardContour(br, false); let con = GetSealedBoardContour(br, false);
expect(con.IsClose).toBeTruthy(); expect(con.IsClose).toBeTruthy();
expect(con.Area).toMatchSnapshot(); expect(con.Area2).toMatchNumberSnapshot();
}); });
test("封边错误板件3", () => test("封边错误板件3", () =>
{ {
@ -153,7 +154,7 @@ test("封边错误板件3", () =>
let con = GetSealedBoardContour(br, false); let con = GetSealedBoardContour(br, false);
expect(con.IsClose).toBeTruthy(); expect(con.IsClose).toBeTruthy();
expect(con.Area).toMatchSnapshot(); expect(con.Area2).toMatchNumberSnapshot();
}); });
test("封边错误板件4", () => test("封边错误板件4", () =>
{ {
@ -163,7 +164,7 @@ test("封边错误板件4", () =>
let con = GetSealedBoardContour(br, false); let con = GetSealedBoardContour(br, false);
expect(con.IsClose).toBeTruthy(); expect(con.IsClose).toBeTruthy();
expect(con.Area).toMatchSnapshot(); expect(con.Area2).toMatchNumberSnapshot();
}); });
test("切割残留一个封边厚度的凸角的板件封边", () => test("切割残留一个封边厚度的凸角的板件封边", () =>
@ -173,13 +174,13 @@ test("切割残留一个封边厚度的凸角的板件封边", () =>
let con = GetSealedBoardContour(brs[0], false); let con = GetSealedBoardContour(brs[0], false);
expect(con.IsClose).toBeTruthy(); expect(con.IsClose).toBeTruthy();
expect(con.Area).toMatchSnapshot(); expect(con.Area2).toMatchNumberSnapshot();
expect(con.Length).toMatchSnapshot(); expect(con.Length).toMatchNumberSnapshot();
con = GetSealedBoardContour(brs[1], false); con = GetSealedBoardContour(brs[1], false);
expect(con.IsClose).toBeTruthy(); expect(con.IsClose).toBeTruthy();
expect(con.Area).toMatchSnapshot(); expect(con.Area2).toMatchNumberSnapshot();
expect(con.Length).toMatchSnapshot(); expect(con.Length).toMatchNumberSnapshot();
}); });
test("切割残留2个封边厚度的凸角的板件封边", () => test("切割残留2个封边厚度的凸角的板件封边", () =>
@ -191,8 +192,8 @@ test("切割残留2个封边厚度的凸角的板件封边", () =>
{ {
let con = GetSealedBoardContour(b, false); let con = GetSealedBoardContour(b, false);
expect(con.IsClose).toBeTruthy(); expect(con.IsClose).toBeTruthy();
expect(con.Area).toMatchSnapshot(); expect(con.Area2).toMatchNumberSnapshot();
expect(con.Length).toMatchSnapshot(); expect(con.Length).toMatchNumberSnapshot();
} }
}); });
test("切割残留一个小于封边厚度的凸角的板件封边", () => test("切割残留一个小于封边厚度的凸角的板件封边", () =>
@ -204,8 +205,8 @@ test("切割残留一个小于封边厚度的凸角的板件封边", () =>
{ {
let con = GetSealedBoardContour(b, false); let con = GetSealedBoardContour(b, false);
expect(con.IsClose).toBeTruthy(); expect(con.IsClose).toBeTruthy();
expect(con.Area).toMatchSnapshot(); expect(con.Area2).toMatchNumberSnapshot();
expect(con.Length).toMatchSnapshot(); expect(con.Length).toMatchNumberSnapshot();
} }
}); });
test("获取封边错误案例", () => test("获取封边错误案例", () =>
@ -217,7 +218,7 @@ test("获取封边错误案例", () =>
{ {
let con = GetSealedBoardContour(b, false); let con = GetSealedBoardContour(b, false);
expect(con.IsClose).toBeTruthy(); expect(con.IsClose).toBeTruthy();
expect(con.Area).toMatchSnapshot(); expect(con.Area2).toMatchNumberSnapshot();
expect(con.Length).toMatchSnapshot(); expect(con.Length).toMatchNumberSnapshot();
} }
}); });

@ -0,0 +1,19 @@
import { GetSealedBoardContour } from "../../src/GraphicsSystem/CalcEdgeSealing";
import "../Utils/jest.util";
import { LoadBoardsFromFileData } from "../Utils/LoadEntity.util";
test('只有一个封边,并且失败的案例', () =>
{
let d =
{ "file": [4, "Board", 8, 2, 121, false, 1, 1, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 5156.78604262264, 155.71155098138843, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5156.78604262264, 155.71155098138843, -517.2053991103303, 1], 0, 3, 1332.7946008896697, 60, 18, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1332.7946008896697, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 6, [0.9999999999995453, -1332.7946008896697], 0, [0.9999999999995453, -1332], 0, [60, -1332], 0, [60, 0], 0, [0, 0], 0, [0, -1332.7946008896697], 0, true, 0, 3, 0, 0, 0, 0, 0, 10, 1, "右收口条", "榻米衣柜及书桌", "柜体4右收口", "固峰希腊白", "多层板", "希腊白", 0, 0, "不排", 2, 0, "1", "1", "1", "1", "", "", "", 6, "不排", "不排", "不排", "不排", "不排", "不排", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, "Board", 8, 2, 125, false, 1, 2, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5019.321452985634, 377.9382754993276, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 4283.636154264983, 377.9382754993276, 0, 1], 0, 3, 116.0936470770996, 492.7358454018065, 18, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -410.58187625625226, -2.2737367544323206e-13, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -410.58187625625226, -2.2737367544323206e-13, 0, 1], 0, 2, 8, [903.0128456459614, 0.042011759224124035], 0.00006257940248264371, [903.3177216580588, 0.044582197205727425], 0, [903.1637146020545, 18.0439233470006], -0.00006250723639880799, [902.8636905320473, 18.041393772886522], -0.002076508735090201, [892.896577535593, 17.999999999999773], -0.10213911426261756, [417.70988855098807, 116.09364707709983], 0, [410.5818762562526, 99.56514318901282], 0.10213916213559157, [892.8965775355929, 4.547473508864641e-13], 0.0020764365686957082, true, 0, 3, 0, 0, 0, 0, 0, 10, 2, "背板", "", "", "", "", "", 1, 0, "三合一", 2, 0, "1", "1", "1", "1", "", "", "", 8, "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, "Board", 8, 2, 126, false, 1, 3, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 4947.116633075755, 488.82041104941163, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 4211.431334355104, 488.82041104941163, 0, 1], 0, 3, 116.09364707712712, 492.73584540181275, 18, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 4.547473508864641e-13, 99.56514318901509, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -69.12869845001791, -1926.3342224071403, 0, 1], 0, 2, 6, [492.73584540181236, -99.52056099181004], 0, [492.5818383458083, -81.52121984201517], -0.00006250723639903003, [492.2818142757997, -81.52374941612948], -0.10423773106609027, [7.128012294613768, 16.528503888112027], 0, [0, 0], 0.10423770600938752, [492.4309693897147, -99.52313142979142], 0.00006257940248264371, true, 0, 3, 0, 0, 0, 0, 0, 10, 2, "背板", "", "", "", "", "", 1, 0, "三合一", 2, 4, 1, 1, 1, 1, "1", "1", "1", "1", "", "", "", 6, "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, "Board", 8, 2, 127, false, 1, 4, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 5078.087564233807, 657.0134638837771, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5078.087564233807, 657.0134638837771, 0, 1], 0, 3, 2111.999999999998, 350, 18, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 2031, 0, 1], 0, 0, true, [0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, -1207.750629722921, -11265.46679826914, 0, 1], 0, 2, 8, [350, -2031], 0, [350, 80.99999999999818], 0, [147, 80.99999999999818], 0, [147, 80], -0.41421356237309503, [107, 40], 0, [40, 40], 0.41421356237309503, [0, 0], 0, [0, -2031], 0, true, 0, 3, 0, 0, 0, 0, 0, 10, 1, "右侧板", "大厅", "鞋柜", "格绿", "生态板", "和风细雨", 0, 0, "三合一", 2, 0, "1", "1", "1", "1", "", "", "", 8, "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0], "basePt": { "x": 4947.116633075755, "y": 155.71155098138843, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let brs = LoadBoardsFromFileData(d);
for (let br of brs)
{
let con = GetSealedBoardContour(br, false);
expect(con.IsClose).toBeTruthy();
expect(con.Area2).toMatchNumberSnapshot();
expect(con.Length).toMatchNumberSnapshot();
}
});

@ -4,33 +4,33 @@ exports[`丢失线段板件 1`] = `554052.5007766777`;
exports[`丢失线段板件 2`] = `398758.8789695821`; exports[`丢失线段板件 2`] = `398758.8789695821`;
exports[`切割残留2个封边厚度的凸角的板件封边 1`] = `30420`; exports[`切割残留2个封边厚度的凸角的板件封边 1`] = `"30127.50000"`;
exports[`切割残留2个封边厚度的凸角的板件封边 2`] = `1274`; exports[`切割残留2个封边厚度的凸角的板件封边 2`] = `"1273.00000"`;
exports[`切割残留一个封边厚度的凸角的板件封边 1`] = `30420`; exports[`切割残留一个封边厚度的凸角的板件封边 1`] = `"30420.00000"`;
exports[`切割残留一个封边厚度的凸角的板件封边 2`] = `1274`; exports[`切割残留一个封边厚度的凸角的板件封边 2`] = `"1274.00000"`;
exports[`切割残留一个封边厚度的凸角的板件封边 3`] = `30420`; exports[`切割残留一个封边厚度的凸角的板件封边 3`] = `"30420.00000"`;
exports[`切割残留一个封边厚度的凸角的板件封边 4`] = `1274`; exports[`切割残留一个封边厚度的凸角的板件封边 4`] = `"1274.00000"`;
exports[`切割残留一个小于封边厚度的凸角的板件封边 1`] = `30127.5`; exports[`切割残留一个小于封边厚度的凸角的板件封边 1`] = `"30127.50000"`;
exports[`切割残留一个小于封边厚度的凸角的板件封边 2`] = `1273`; exports[`切割残留一个小于封边厚度的凸角的板件封边 2`] = `"1273.00000"`;
exports[`切割残留一个小于封边厚度的凸角的板件封边 3`] = `30127.5`; exports[`切割残留一个小于封边厚度的凸角的板件封边 3`] = `"30127.50000"`;
exports[`切割残留一个小于封边厚度的凸角的板件封边 4`] = `1273`; exports[`切割残留一个小于封边厚度的凸角的板件封边 4`] = `"1273.00000"`;
exports[`封边错误板件 1`] = `130118.40946854133`; exports[`封边错误板件 1`] = `"130118.40950"`;
exports[`封边错误板件2 1`] = `779770.9650700318`; exports[`封边错误板件2 1`] = `"779770.96110"`;
exports[`封边错误板件3 1`] = `359947.9362569036`; exports[`封边错误板件3 1`] = `"359947.95128"`;
exports[`封边错误板件4 1`] = `30748.998495139338`; exports[`封边错误板件4 1`] = `"30748.99860"`;
exports[`常规板件,常规坐标系 1`] = `716404`; exports[`常规板件,常规坐标系 1`] = `716404`;
@ -58,16 +58,16 @@ exports[`异型板件,非相切圆弧 1`] = `635612.2751433642`;
exports[`异型板件,非相切圆弧 2`] = `626242.2196800549`; exports[`异型板件,非相切圆弧 2`] = `626242.2196800549`;
exports[`椭圆弧封边 1`] = `23816.280001593965`; exports[`椭圆弧封边 1`] = `"23816.28000"`;
exports[`获取封边错误案例 1`] = `153800.9412630349`; exports[`获取封边错误案例 1`] = `"153800.94126"`;
exports[`获取封边错误案例 2`] = `1812.3606355214206`; exports[`获取封边错误案例 2`] = `"1812.36064"`;
exports[`获取封边错误案例 3`] = `163941`; exports[`获取封边错误案例 3`] = `"163941.00000"`;
exports[`获取封边错误案例 4`] = `1876`; exports[`获取封边错误案例 4`] = `"1876.00000"`;
exports[`获取封边错误案例 5`] = `165821`; exports[`获取封边错误案例 5`] = `"165821.00000"`;
exports[`获取封边错误案例 6`] = `1884`; exports[`获取封边错误案例 6`] = `"1884.00000"`;

@ -0,0 +1,17 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`只有一个封边,并且失败的案例 1`] = `"77140.00000"`;
exports[`只有一个封边,并且失败的案例 2`] = `"2776.00000"`;
exports[`只有一个封边,并且失败的案例 3`] = `"8009.31415"`;
exports[`只有一个封边,并且失败的案例 4`] = `"1033.16428"`;
exports[`只有一个封边,并且失败的案例 5`] = `"8009.31415"`;
exports[`只有一个封边,并且失败的案例 6`] = `"1033.16428"`;
exports[`只有一个封边,并且失败的案例 7`] = `"728287.33629"`;
exports[`只有一个封边,并且失败的案例 8`] = `"4881.66371"`;

@ -8,6 +8,7 @@ import { Curve } from "../DatabaseServices/Entity/Curve";
import { ExtureContourCurve } from "../DatabaseServices/Entity/Extrude"; import { ExtureContourCurve } from "../DatabaseServices/Entity/Extrude";
import { Line } from "../DatabaseServices/Entity/Line"; import { Line } from "../DatabaseServices/Entity/Line";
import { Polyline } from "../DatabaseServices/Entity/Polyline"; import { Polyline } from "../DatabaseServices/Entity/Polyline";
import { CreateContour2 } from "../Geometry/CreateContour2";
import { angle, equaln, equalv3, isParallelTo, SelectNearP, XAxis } from "../Geometry/GeUtils"; import { angle, equaln, equalv3, isParallelTo, SelectNearP, XAxis } from "../Geometry/GeUtils";
import { Production } from "../Production/Product"; import { Production } from "../Production/Product";
import { IHighSealedItem } from "../UI/Store/BoardInterface"; import { IHighSealedItem } from "../UI/Store/BoardInterface";
@ -323,13 +324,14 @@ export function GetBoardSealingCurves(br: Board, isOffset = false): Curve[]
*/ */
export function GetSealedBoardContour(br: Board, hasSealing: boolean): Polyline | Circle | undefined export function GetSealedBoardContour(br: Board, hasSealing: boolean): Polyline | Circle | undefined
{ {
if (equaln(br.ContourCurve.Area, 0)) let area2 = br.ContourCurve.Area2;
if (Math.abs(area2) < 10)
return; return;
let offsetCus: Curve[] = []; let offsetCus: Curve[] = [];
let cus = GetBoardSealingCurves(br); let cus = GetBoardSealingCurves(br);
let highSeals = GetBoardHighSeal(br, cus); let highSeals = GetBoardHighSeal(br, cus);
let dir = Math.sign(br.ContourCurve.Area2); let dir = Math.sign(area2);
if (hasSealing) if (hasSealing)
{ {
@ -346,6 +348,36 @@ export function GetSealedBoardContour(br: Board, hasSealing: boolean): Polyline
if (cus[0] instanceof Circle) if (cus[0] instanceof Circle)
dir = 1; dir = 1;
//所有的封边都一样时
if (highSeals.every(s => equaln(s.size, highSeals[0].size), 1e-3))
{
let brContour = br.ContourCurve;
let retPl: ExtureContourCurve;
if (!highSeals[0].size || equaln(highSeals[0].size, 0, 1e-3))
{
retPl = brContour.Clone();
if (dir < 0)
retPl.Reverse();
}
else
{
retPl = brContour.GetOffsetCurves(-highSeals[0].size * dir)[0] as ExtureContourCurve;
if (retPl && !retPl.IsClose)
{
//某些情况下,这里会出现非闭合轮廓
retPl = CreateContour2([retPl]).Curve;
}
if (retPl && retPl.Area2 < 0)
retPl.Reverse();
}
return retPl;
}
for (let i = 0; i < cus.length; i++) for (let i = 0; i < cus.length; i++)
{ {
let cs: Curve[]; let cs: Curve[];

Loading…
Cancel
Save