!1191 修复:椭圆弧封边,异型轮廓错误

pull/1191/MERGE
ZoeLeeFZ 4 years ago committed by ChenX
parent 98de6de3ec
commit 7a67d17e0f

@ -1,7 +1,7 @@
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 } from "../../src/GraphicsSystem/CalcEdgeSealing"; import { CalcEdgeSealing, ParagraphCulist, GetSealedBoardContour } from "../../src/GraphicsSystem/CalcEdgeSealing";
import { LoadBoardsFromFileData } from "../Utils/LoadEntity.util"; import { LoadBoardsFromFileData } from "../Utils/LoadEntity.util";
function testBrSealing(br: Board, sealingSize: number[]) function testBrSealing(br: Board, sealingSize: number[])
@ -115,3 +115,33 @@ test("丢失线段板件", () =>
sealingSize.push(1); sealingSize.push(1);
testBrSealing(br, sealingSize); testBrSealing(br, sealingSize);
}); });
test("椭圆弧封边", () =>
{
let data = { "file": [1, "Board", 8, 2, 100, false, 1, 11, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -82.13690829474945, 114.75723174517043, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -82.13690829474945, 104.75723174517043, 18, 1], 0, 3, 200, 180, 18, false, "Polyline", 8, 2, 0, false, 0, 1, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -258.46153846153857, -12964.69992987938, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -258.46153846153857, -12964.69992987938, 0, 1], 0, 2, 51, [288.46153846153857, 12964.69992987938], 0, [288.5704463785399, 12971.92684875419], 0, [288.9140739605454, 12979.410398465114], 0, [290.27885575504905, 12995.063291147017], 0, [292.9586758298214, 13009.891833820202], 0, [296.39553752213186, 13024.889048477557], 0, [300.282315654163, 13036.173202739328], 0, [303.66793686306085, 13044.361681942244], 0, [306.10873354854533, 13049.87315832882], 0, [308.8644717418342, 13054.990957830643], 0, [312.95871134329207, 13061.368523363684], 0, [316.1868617982876, 13065.93517522685], 0, [319.7188580568129, 13070.055638857499], 0, [327.18971912910087, 13076.905272038977], 0, [333.9023216122879, 13081.209838355366], 0, [342.54746600152004, 13084.32775928263], 0, [348.46153846153857, 13084.69992987938], 0, [352.02720538643393, 13084.69992987938], 0, [357.5386817730118, 13083.225464005316], 0, [361.9478628822741, 13081.682250617074], 0, [365.80589635287856, 13079.477660062443], 0, [367.4684750921103, 13078.507534398059], 0, [368.4284772766677, 13077.8389614481], 0, [369.3027649804613, 13077.206388580058], 0, [370.25076713771176, 13076.510386996253], 0, [372.8398519874499, 13074.326962635703], 0, [373.75992035441425, 13073.406894268739], 0, [374.5127035637492, 13072.654111059404], 0, [375.1330526899602, 13072.033761933193], 0, [376.9243979195813, 13070.242416703572], 0, [378.0326620888804, 13069.134152534272], 0, [379.05728367936507, 13067.886484066948], 0, [380.5349692384301, 13066.046347333018], 0, [381.3853354563827, 13064.98687466803], 0, [384.58640519997704, 13060.471908040156], 0, [387.6003992826533, 13055.568544532518], 0, [390.56940837902096, 13050.215331161793], 0, [393.08856761230254, 13044.817132804761], 0, [397.19119836364706, 13034.848459838773], 0, [399.5943477683716, 13027.63130423622], 0, [402.1233363096843, 13018.562546884497], 0, [403.70663926312574, 13011.517825493022], 0, [406.260171603461, 12997.187029301213], 0, [407.2678352967737, 12988.495929946394], 0, [408.0235830667582, 12979.23801976408], 0, [408.4163190634927, 12969.357947900617], 0, [408.46153846153857, 12964.69992987938], 0, [438.46153846153857, 12964.69992987938], 0, [438.46153846153857, 13164.69992987938], 0, [258.46153846153857, 13164.69992987938], 0, [258.46153846153857, 12964.69992987938], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 1, "右侧板", "", "标准柜", "", "", "", 0, 1, "三合一", 2, 0, "0.6", "0.6", "1.5", "0.6", "", "", "", 51, "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true], "basePt": { "x": -82.13690829474945, "y": 114.75723174517043, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let br = LoadBoardsFromFileData(data)[0];
let con = GetSealedBoardContour(br, false);
expect(con.IsClose).toBeTruthy();
expect(con.Area).toMatchSnapshot();
});
test("封边错误板件", () =>
{
let data = { "file": [1, "Board", 8, 2, 105, false, 1, 1, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1579.3258628151088, -574.3939551283838, 1.2729687070241198, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1579.3258628151088, -604.3939551283838, 1.2729687070241198, 1], 0, 3, 332, 520, 18, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1117581.920290453, -307708.965755141, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1117581.920290453, -307708.965755141, 0, 1], 0, 2, 20, [1118030.85530438, 307708.9658], -0.435046896, [1118000.930043029, 307741.0821], 0, [1118000.340575397, 307769.2703], 0, [1117993.237938485, 307791.7833], 0, [1117976.799157559, 307806.2037], 0, [1117952.328366119, 307813.7577], 0, [1117921.347416826, 307815.8636], 0, [1117885.378162336, 307813.9399], 0, [1117804.5621484, 307803.677], 0, [1117722.055145579, 307794.3162], 0, [1117683.972154982, 307793.5201], 0, [1117650.031975138, 307797.2046], 0, [1117621.756458705, 307806.7882], 0, [1117600.667458342, 307823.6893], 0, [1117588.150725121, 307849.1923], 0, [1117581.920290453, 307880.9658], 0, [1117581.920290453, 308040.965755141], 0, [1118101.920290453, 308040.965755141], 0, [1118101.920290453, 307708.965755141], 0, [1118030.85530438, 307708.965755141], 0, true, 0, 3, 0, 0, 0, 0, 0, 9, 1, "左侧板", "次卧一书桌柜", "书桌", "蕙质兰心", "多层实木", "蕙质兰心", 0, 0, "三合一", 2, 0, "1", "1", "1", "1", "", "", "", 20, "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true], "basePt": { "x": 1579.3258628151088, "y": -574.3939551283838, "z": 1.2729687070241198 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let br = LoadBoardsFromFileData(data)[0];
let con = GetSealedBoardContour(br, false);
expect(con.IsClose).toBeTruthy();
expect(con.Area).toMatchSnapshot();
});
test("封边错误板件2", () =>
{
let data = { "file": [1, "Board", 8, 2, 321, false, 1, 3, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 8511.883548299666, -144.54126186296344, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 8536.883548299666, -144.54126186296344, 0, 1], 0, 3, 400.2476503569924, 2300, 25, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 406.2643066383516, 310.58952284495217, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, -9115.641761047009, -1933.6524071638414, 0, 1], 0, 2, 16, [-67.06912303135869, 78.84805159804773], 0, [0, 0], 0.2202439982667024, [22.874295099078154, -10.58952284995803], 0, [742.3473665786241, -10.589522844952171], 0.22024399852882928, [765.2216616957576, 5.275069270282984e-9], 0, [832.5014391616369, 79.0957019560442], -0.21993334211278368, [855.3527126344816, 89.6581275100466], 0, [1318.9838435386573, 89.65812751204021], -0.21993334237487636, [1341.8351170292226, 79.09570194591333], 0, [1409.1148944956167, 1.0472831490915269e-9], 0.18676524414106982, [1428.1424129374664, -10.341872493370829], 0, [1893.7356933616484, -10.34187248795979], 0, [1893.7356933616484, -310.58952284495217], 0, [-406.2643066383516, -310.58952284495217], 0, [-406.2643066383516, 89.41047715504783], 0, [-89.92039651338382, 89.41047715504783], -0.21993334237487636, true, 1, 3, 80.00000000199361, 243.63113088517912, 25, false, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 203.6311308697916, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, -10487.258780340819, -2173.90005751884, 0, 1], 0, 2, 4, [-163.63113088158752, 1.9936123862862587e-9], 0, [0, 0], 1.0000000002948966, [7.183189154602587e-9, 80], 0, [-163.63113088158752, 80.00000000199361], 0.9999999997051033, true, 0, 3, 0, 0, 0, 0, 0, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 9883.500567593475, -144.54126186296344, 240.24765035499877, 1], 3, 0, 0, 0, 0, 0, 9, 2, "背板", "小孩房", "小孩房床", "25进口暖白无光麻LZ9202", "多层板", "进口暖白无光麻LZ9202", 1, 1, "三合一", 2, 0, "1", "1", "1", "1", "", "", "", 16, "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", "三合一", false, true, 0, 0, 0, 0, 0, 0, 0, 0, true], "basePt": { "x": 8511.883548299666, "y": -169.54126186296344, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let br = LoadBoardsFromFileData(data)[0];
let con = GetSealedBoardContour(br, false);
expect(con.IsClose).toBeTruthy();
expect(con.Area).toMatchSnapshot();
});

@ -4,6 +4,10 @@ exports[`丢失线段板件 1`] = `554052.5007766777`;
exports[`丢失线段板件 2`] = `398758.8789695821`; exports[`丢失线段板件 2`] = `398758.8789695821`;
exports[`封边错误板件 1`] = `130118.40949065729`;
exports[`封边错误板件2 1`] = `779770.9650700318`;
exports[`常规板件,常规坐标系 1`] = `716404`; exports[`常规板件,常规坐标系 1`] = `716404`;
exports[`常规板件,常规坐标系 2`] = `711624`; exports[`常规板件,常规坐标系 2`] = `711624`;
@ -29,3 +33,5 @@ exports[`异型板件,非常规坐标系 3`] = `75694680.60847883`;
exports[`异型板件,非相切圆弧 1`] = `635612.2751433642`; exports[`异型板件,非相切圆弧 1`] = `635612.2751433642`;
exports[`异型板件,非相切圆弧 2`] = `626242.2196800549`; exports[`异型板件,非相切圆弧 2`] = `626242.2196800549`;
exports[`椭圆弧封边 1`] = `23838.801571523727`;

@ -99,7 +99,21 @@ export async function SelectExtrudeContour(selectInside = false, useExtrude = fa
{ {
if (selectInside || !en.IsClose) if (selectInside || !en.IsClose)
{ {
let cus = app.Viewer.VisibleEntitys.filter(e => e instanceof Curve) as Curve[]; let cus: Curve[] = [];
for (let c of app.Viewer.VisibleEntitys)
{
if (c instanceof Curve)
{
if (c instanceof Ellipse || c instanceof Spline)
{
let temp = c.Convert2Polyline();
temp.__CachePolyline__ = c;
cus.push(temp);
}
else
cus.push(c);
}
}
let cuGroups = curveLinkGroup(cus); let cuGroups = curveLinkGroup(cus);

@ -71,7 +71,10 @@ export class DrawSpecialShapedBoard implements Command
//删除被应用的轮廓 //删除被应用的轮廓
if (useCurves) if (useCurves)
for (let c of useCurves) for (let c of useCurves)
{
c = c.__CachePolyline__ ?? c;
c.Erase(); c.Erase();
}
}); });
} }
else else

@ -36,6 +36,9 @@ export class DrawSpecialShapedBoardByContour implements Command
//删除被应用的轮廓 //删除被应用的轮廓
if (useCurves) if (useCurves)
for (let c of useCurves) for (let c of useCurves)
{
c = c.__CachePolyline__ ?? c;
c.Erase(); c.Erase();
}
} }
} }

@ -115,6 +115,9 @@ export function ParagraphCulist(cus: Curve[])
} }
} }
/**扣除封边是否相连和连接共用精度 */
export const LINK_FUZZ = 1e-3;
/** /**
* *
*/ */
@ -134,8 +137,11 @@ export function CalcEdgeSealing(cus: Curve[])
alert("获取封边错误,请提供图纸给相关人员"); alert("获取封边错误,请提供图纸给相关人员");
return; return;
} }
if (equalv3(frontLine.EndPoint, laterLine.StartPoint, 1e-2))
let dist = frontLine.EndPoint.distanceToSquared(laterLine.StartPoint);
if (dist < LINK_FUZZ ** 2)
continue; continue;
let refLine = oldLine ?? frontLine; let refLine = oldLine ?? frontLine;
let refLine2 = i === cus.length - 1 ? firstLine : laterLine; let refLine2 = i === cus.length - 1 ? firstLine : laterLine;
let iPts = refLine.IntersectWith(refLine2, IntersectOption.ExtendBoth); let iPts = refLine.IntersectWith(refLine2, IntersectOption.ExtendBoth);
@ -203,6 +209,16 @@ export function GetBoardHighSeal(br: Board, sealcus: Curve[])
return highSeals; return highSeals;
} }
/**偏移前后曲线起点没改变 */
export function OffsetOutlineSpNotChange(oldcu: Curve, newCu: Curve)
{
let sDerv = oldcu.GetFistDeriv(0).normalize();
let eDerv = oldcu.GetFistDeriv(oldcu.EndParam).normalize().negate();
sDerv.add(eDerv).normalize();
let mDerv = newCu.StartPoint.sub(oldcu.StartPoint).normalize();
return oldcu.EndParam === newCu?.EndParam && isParallelTo(mDerv, sDerv);
}
/** /**
* 线 * 线
* 线, * 线,
@ -220,7 +236,7 @@ export function GetBoardSealingCurves(br: Board, isOffset = false): Curve[]
{ {
let dir = Math.sign(cu.Area2); let dir = Math.sign(cu.Area2);
let newCu = cu.GetOffsetCurves(-1 * dir)[0] as ExtureContourCurve; let newCu = cu.GetOffsetCurves(-1 * dir)[0] as ExtureContourCurve;
if (cu.EndParam === newCu?.EndParam && equaln(newCu.StartPoint.distanceTo(cu.StartPoint), 1)) if (OffsetOutlineSpNotChange(cu, newCu))
cu = newCu; cu = newCu;
} }
if (cu instanceof Circle) if (cu instanceof Circle)
@ -287,7 +303,7 @@ export function GetSealedBoardContour(br: Board, hasSealing: boolean): Polyline
return offsetCus[0] as Circle; return offsetCus[0] as Circle;
CalcEdgeSealing(offsetCus); CalcEdgeSealing(offsetCus);
let pl = Polyline.Combine(offsetCus); let pl = Polyline.Combine(offsetCus, LINK_FUZZ);
if (dir < 0) if (dir < 0)
pl.Reverse(); pl.Reverse();
return pl; return pl;

@ -278,7 +278,10 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
//删除应用的轮廓 //删除应用的轮廓
if (useCurves) if (useCurves)
for (let c of useCurves) for (let c of useCurves)
{
c = c.__CachePolyline__ ?? c;
c.Erase(); c.Erase();
}
if (cuGourp) if (cuGourp)
{ {

@ -7,7 +7,7 @@ import { DrillType } from "../BoardInterface";
import { BoardEdgesEditor } from "./BoardEdgesEditor"; import { BoardEdgesEditor } from "./BoardEdgesEditor";
import { Board } from "../../../DatabaseServices/Entity/Board"; import { Board } from "../../../DatabaseServices/Entity/Board";
import { log } from "util"; import { log } from "util";
import { equaln } from "../../../Geometry/GeUtils"; import { OffsetOutlineSpNotChange } from "../../../GraphicsSystem/CalcEdgeSealing";
export class DrillingStore extends BoardEdgesEditor export class DrillingStore extends BoardEdgesEditor
{ {
@ -28,7 +28,7 @@ export class DrillingStore extends BoardEdgesEditor
{ {
let dir = Math.sign(br.ContourCurve.Area2); let dir = Math.sign(br.ContourCurve.Area2);
let newCu = br.ContourCurve.GetOffsetCurves(-1 * dir)[0]; let newCu = br.ContourCurve.GetOffsetCurves(-1 * dir)[0];
let cus = (newCu.EndParam === br.ContourCurve.EndParam && equaln(newCu.StartPoint.distanceTo(br.ContourCurve.StartPoint), 1) ? let cus = (OffsetOutlineSpNotChange(br.ContourCurve, newCu) ?
newCu : br.ContourCurve).Explode() as Curve[]; newCu : br.ContourCurve).Explode() as Curve[];
let highDrillData = br.BoardProcessOption.highDrill; let highDrillData = br.BoardProcessOption.highDrill;

Loading…
Cancel
Save