!1605 修复:封边和排钻的方向算法改成直接对比判断

pull/1825/MERGE
ChenX 2 years ago
parent 618d5e3a30
commit 8eb4f7bbbf

@ -34,6 +34,20 @@ test('只有一个封边,并且失败的案例(展示这个改进的缺陷的地
} }
}); });
test('矩形板解析封边错误', () =>
{
let d = { "file": [1, "Board", 8, 2, 100, false, 1, 2, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, -152.34375, 18, -167.96874999976717, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -152.34375, 18, -167.96874999976717, 1], 0, 3, 1515.0003295573406, 406, 18, true, "Polyline", 8, 2, 0, false, 0, 1, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, -899.9973051166162, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, -899.9973051166162, 0, 1], 0, 2, 4, [406, 2414.9973051175475], 0, [0, 2414.997634673957], 0, [0, 899.9976346730255], 0, [406, 899.9973051166162], 0, true, 0, 3, 0, 0, 0, 0, 0, 10, 2, "假门", "4-5装饰柜2", "1号柜", "南亚柚木", "夹板", "南亚柚木", 0, 1, "不排", 2, 4, 0, 1.5, 1.5, 1.5, "0", "0", "1.5", "1.5", "", "", "", 4, "不排", "不排", "不排", "不排", false, false, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0], "basePt": { "x": -152.34375, "y": 0, "z": -167.96874999976717 }, "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();
}
});
test('偏移后曲线不闭合的问题', () => test('偏移后曲线不闭合的问题', () =>
{ {
let d = let d =

@ -23,3 +23,7 @@ exports[`只有一个封边,并且失败的案例 8`] = `"4881.66371"`;
exports[`只有一个封边,并且失败的案例(展示这个改进的缺陷的地方) 1`] = `"368500.00000"`; exports[`只有一个封边,并且失败的案例(展示这个改进的缺陷的地方) 1`] = `"368500.00000"`;
exports[`只有一个封边,并且失败的案例(展示这个改进的缺陷的地方) 2`] = `"2440.00000"`; exports[`只有一个封边,并且失败的案例(展示这个改进的缺陷的地方) 2`] = `"2440.00000"`;
exports[`矩形板解析封边错误 1`] = `"610545.00000"`;
exports[`矩形板解析封边错误 2`] = `"3836.00000"`;

@ -9,7 +9,7 @@ import { Circle } from "../../DatabaseServices/Entity/Circle";
import { Curve } from "../../DatabaseServices/Entity/Curve"; import { Curve } from "../../DatabaseServices/Entity/Curve";
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 { angle, clampRad, isParallelTo, rotatePoint, ZAxis } from "../../Geometry/GeUtils"; import { isParallelTo, rotatePoint, ZAxis } from "../../Geometry/GeUtils";
import { DrillType } from "../../UI/Store/BoardInterface"; import { DrillType } from "../../UI/Store/BoardInterface";
export const SCALAR = 0.1; export const SCALAR = 0.1;
@ -165,17 +165,21 @@ export function InitRectBoardHoleOption(br: Board, option: IRectHoleOption)
{ {
let c = cus[i]; let c = cus[i];
let derv = c.GetFistDeriv(0).multiplyScalar(dir); let derv = c.GetFistDeriv(0).multiplyScalar(dir);
let an = angle(derv);
an = clampRad(an); if (Math.abs(derv.x) > Math.abs(derv.y))
{
if (an < Math.PI / 4 + 1e-8 || an > Math.PI * 7 / 4) if (derv.x > 0)
option.down = hightDrill[i]; option.down = hightDrill[i];
else if (an > Math.PI / 4 && an < Math.PI * 3 / 4 + 1e-8) else
option.right = hightDrill[i]; option.up = hightDrill[i];
else if (an > Math.PI * 3 / 4 && an < Math.PI * 5 / 4 + 1e-8) }
option.up = hightDrill[i];
else else
option.left = hightDrill[i]; {
if (derv.y > 0)
option.right = hightDrill[i];
else
option.left = hightDrill[i];
}
} }
} }
export function ExtureHoleInBoard(holes: ExtrudeHole[], board: Board, ocs: Matrix4) export function ExtureHoleInBoard(holes: ExtrudeHole[], board: Board, ocs: Matrix4)
@ -208,17 +212,21 @@ export function SetRectHighHole(br: Board, option: IRectHoleOption)
{ {
let c = cus[i]; let c = cus[i];
let derv = c.GetFistDeriv(0).multiplyScalar(dir); let derv = c.GetFistDeriv(0).multiplyScalar(dir);
let an = angle(derv);
an = clampRad(an); if (Math.abs(derv.x) > Math.abs(derv.y))
{
if (an < Math.PI / 4 + 1e-8 || an > Math.PI * 7 / 4) if (derv.x > 0)
highDrill.push(option.down); highDrill.push(option.down);
else if (an > Math.PI / 4 && an < Math.PI * 3 / 4 + 1e-8) else
highDrill.push(option.right); highDrill.push(option.up);
else if (an > Math.PI * 3 / 4 && an < Math.PI * 5 / 4 + 1e-8) }
highDrill.push(option.up);
else else
highDrill.push(option.left); {
if (derv.y > 0)
highDrill.push(option.right);
else
highDrill.push(option.left);
}
} }
let types = new Set(highDrill); let types = new Set(highDrill);
if (types.size === 1 && highDrill[0] !== DrillType.None) if (types.size === 1 && highDrill[0] !== DrillType.None)

@ -10,7 +10,7 @@ import { ExtrudeContourCurve } 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 { CreateContour2 } from "../Geometry/CreateContour2";
import { angle, clampRad, equaln, equalv3, isParallelTo, SelectNearP, XAxis } from "../Geometry/GeUtils"; import { equaln, equalv3, isParallelTo, SelectNearP, XAxis } from "../Geometry/GeUtils";
import { Production } from "../Production/Product"; import { Production } from "../Production/Product";
import { IHighSealedItem, ISealingData } from "../UI/Store/BoardInterface"; import { IHighSealedItem, ISealingData } from "../UI/Store/BoardInterface";
import { IntersectOption } from "./IntersectWith"; import { IntersectOption } from "./IntersectWith";
@ -269,18 +269,21 @@ export function GetBoardHighSeal(br: Board, sealcus: Curve[]): IHighSealedItem[]
for (let c of sealcus) for (let c of sealcus)
{ {
let derv = c.GetFistDeriv(0).multiplyScalar(dir); let derv = c.GetFistDeriv(0).multiplyScalar(dir);
let an = angle(derv);
an = clampRad(an); if (Math.abs(derv.x) > Math.abs(derv.y))
{
if ((an < Math.PI / 4 + 1e-8) || (an > Math.PI * 7 / 4)) if (derv.x > 0)
highSeals.push({ size: sealDown }); highSeals.push({ size: sealDown });
else if (an > Math.PI / 4 && an < Math.PI * 3 / 4 + 1e-8) else
highSeals.push({ size: sealRight }); highSeals.push({ size: sealUp });
else if (an > Math.PI * 3 / 4 && an < Math.PI * 5 / 4 + 1e-8) }
highSeals.push({ size: sealUp });
else else
highSeals.push({ size: sealLeft }); {
if (derv.y > 0)
highSeals.push({ size: sealRight });
else
highSeals.push({ size: sealLeft });
}
} }
} }

Loading…
Cancel
Save