From 45aabd75770728f716228fd5211f0fc293f1af94 Mon Sep 17 00:00:00 2001 From: ChenX Date: Tue, 11 Jul 2023 15:27:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D:=E5=B0=81=E8=BE=B9=E5=AF=B9?= =?UTF-8?q?=E5=BA=94=E9=94=99=E8=AF=AF,=E5=88=9D=E5=A7=8B=E5=8C=96testm?= =?UTF-8?q?=E9=97=B4=E8=B7=9D200,=E5=A4=9A=E6=AE=B5=E7=BA=BF=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E6=97=B6=E5=B0=BE=E9=83=A8=E4=BC=98=E5=85=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Board2CADViewer.test.ts.snap | 80 +++++++++---------- .../__snapshots__/SmoothEdge.test.ts.snap | 4 +- .../__snapshots__/offset.test.ts.snap | 4 +- .../__snapshots__/offsetbug.test.ts.snap | 2 +- .../__snapshots__/SweepSegs.test.ts.snap | 42 +++++----- src/DatabaseServices/Entity/Polyline.ts | 29 ++++--- src/Editor/UserConfig.ts | 2 +- src/GraphicsSystem/CalcEdgeSealing.ts | 18 ++++- 8 files changed, 99 insertions(+), 82 deletions(-) diff --git a/__test__/DTO/__snapshots__/Board2CADViewer.test.ts.snap b/__test__/DTO/__snapshots__/Board2CADViewer.test.ts.snap index 778e6ae47..3f0ded079 100644 --- a/__test__/DTO/__snapshots__/Board2CADViewer.test.ts.snap +++ b/__test__/DTO/__snapshots__/Board2CADViewer.test.ts.snap @@ -162,10 +162,6 @@ CADDbBoard { "H": 10, "L": 179.17946854625225, "Pts": Array [ - Vector2 { - "x": -1.4210854715202004e-14, - "y": 89.58973427312614, - }, Vector2 { "x": 179.17946854625222, "y": 89.58973427312613, @@ -174,6 +170,10 @@ CADDbBoard { "x": -1.4210854715202004e-14, "y": 89.58973427312614, }, + Vector2 { + "x": 179.17946854625222, + "y": 89.58973427312613, + }, ], "SubBoardAssoc": null, "SubBoardLocal": Array [ @@ -195,10 +195,6 @@ CADDbBoard { "H": 10, "L": 139.17946854625225, "Pts": Array [ - Vector2 { - "x": -1.4210854715202004e-14, - "y": 69.58973427312614, - }, Vector2 { "x": 139.17946854625222, "y": 69.58973427312613, @@ -207,6 +203,10 @@ CADDbBoard { "x": -1.4210854715202004e-14, "y": 69.58973427312614, }, + Vector2 { + "x": 139.17946854625222, + "y": 69.58973427312613, + }, ], "SubBoardAssoc": null, "SubBoardLocal": Array [], @@ -323,10 +323,6 @@ CADDbBoard { "H": 10, "L": 116.79966683283226, "Pts": Array [ - Vector2 { - "x": 7.105427357601002e-15, - "y": 58.39983341641608, - }, Vector2 { "x": 116.79966683283226, "y": 58.39983341641607, @@ -335,6 +331,10 @@ CADDbBoard { "x": 7.105427357601002e-15, "y": 58.39983341641608, }, + Vector2 { + "x": 116.79966683283226, + "y": 58.39983341641607, + }, ], "SubBoardAssoc": null, "SubBoardLocal": Array [], @@ -394,10 +394,6 @@ CADDbBoard { "H": 18, "L": 4408.678960586129, "Pts": Array [ - Vector2 { - "x": 0, - "y": 2204.3394802930648, - }, Vector2 { "x": 4408.678960586129, "y": 2204.3394802930643, @@ -406,6 +402,10 @@ CADDbBoard { "x": 0, "y": 2204.3394802930648, }, + Vector2 { + "x": 4408.678960586129, + "y": 2204.3394802930643, + }, ], "SubBoardAssoc": null, "SubBoardLocal": Array [ @@ -427,10 +427,6 @@ CADDbBoard { "H": 5, "L": 633.2307692307686, "Pts": Array [ - Vector2 { - "x": 0, - "y": 316.61538461538436, - }, Vector2 { "x": 633.2307692307686, "y": 316.6153846153843, @@ -439,6 +435,10 @@ CADDbBoard { "x": 0, "y": 316.61538461538436, }, + Vector2 { + "x": 633.2307692307686, + "y": 316.6153846153843, + }, ], "SubBoardAssoc": null, "SubBoardLocal": Array [], @@ -477,10 +477,6 @@ CADDbBoard { "H": 5, "L": 557.8461538461524, "Pts": Array [ - Vector2 { - "x": 0, - "y": 278.9230769230763, - }, Vector2 { "x": 557.8461538461524, "y": 278.9230769230762, @@ -489,6 +485,10 @@ CADDbBoard { "x": 0, "y": 278.9230769230763, }, + Vector2 { + "x": 557.8461538461524, + "y": 278.9230769230762, + }, ], "SubBoardAssoc": null, "SubBoardLocal": Array [], @@ -771,10 +771,6 @@ CADDbBoard { "H": 18, "L": 189.0974955047293, "Pts": Array [ - Vector2 { - "x": -1.4210854715202004e-14, - "y": 94.54874775236478, - }, Vector2 { "x": 189.0974955047293, "y": 94.54874775236476, @@ -783,6 +779,10 @@ CADDbBoard { "x": -1.4210854715202004e-14, "y": 94.54874775236478, }, + Vector2 { + "x": 189.0974955047293, + "y": 94.54874775236476, + }, ], "SubBoardAssoc": null, "SubBoardLocal": Array [], @@ -985,10 +985,6 @@ CADDbBoard { "H": 10, "L": 179.17946854625225, "Pts": Array [ - Vector2 { - "x": -1.4210854715202004e-14, - "y": 89.58973427312614, - }, Vector2 { "x": 179.17946854625222, "y": 89.58973427312613, @@ -997,6 +993,10 @@ CADDbBoard { "x": -1.4210854715202004e-14, "y": 89.58973427312614, }, + Vector2 { + "x": 179.17946854625222, + "y": 89.58973427312613, + }, ], "SubBoardAssoc": null, "SubBoardLocal": Array [ @@ -1018,10 +1018,6 @@ CADDbBoard { "H": 10, "L": 139.17946854625225, "Pts": Array [ - Vector2 { - "x": -1.4210854715202004e-14, - "y": 69.58973427312614, - }, Vector2 { "x": 139.17946854625222, "y": 69.58973427312613, @@ -1030,6 +1026,10 @@ CADDbBoard { "x": -1.4210854715202004e-14, "y": 69.58973427312614, }, + Vector2 { + "x": 139.17946854625222, + "y": 69.58973427312613, + }, ], "SubBoardAssoc": null, "SubBoardLocal": Array [], @@ -1146,10 +1146,6 @@ CADDbBoard { "H": 10, "L": 116.79966683283226, "Pts": Array [ - Vector2 { - "x": 7.105427357601002e-15, - "y": 58.39983341641608, - }, Vector2 { "x": 116.79966683283226, "y": 58.39983341641607, @@ -1158,6 +1154,10 @@ CADDbBoard { "x": 7.105427357601002e-15, "y": 58.39983341641608, }, + Vector2 { + "x": 116.79966683283226, + "y": 58.39983341641607, + }, ], "SubBoardAssoc": null, "SubBoardLocal": Array [], diff --git a/__test__/EdgeSealing/__snapshots__/SmoothEdge.test.ts.snap b/__test__/EdgeSealing/__snapshots__/SmoothEdge.test.ts.snap index 642fa5c54..d2987ea54 100644 --- a/__test__/EdgeSealing/__snapshots__/SmoothEdge.test.ts.snap +++ b/__test__/EdgeSealing/__snapshots__/SmoothEdge.test.ts.snap @@ -9,10 +9,10 @@ Array [ "size": 1, }, Object { - "size": 0, + "size": 1, }, Object { - "size": 1, + "size": 0, }, Object { "size": 1, diff --git a/__test__/Polyline/__snapshots__/offset.test.ts.snap b/__test__/Polyline/__snapshots__/offset.test.ts.snap index bddda90f9..2f1e270db 100644 --- a/__test__/Polyline/__snapshots__/offset.test.ts.snap +++ b/__test__/Polyline/__snapshots__/offset.test.ts.snap @@ -176,7 +176,7 @@ exports[`点在多段线内 1`] = `1`; exports[`点在多段线内 2`] = `"1589.94630"`; -exports[`简单图形因为点在线内算法错误导致的丢失 1`] = `8.675189454805244`; +exports[`简单图形因为点在线内算法错误导致的丢失 1`] = `8.675189454805246`; exports[`简单图形因为点在线内算法错误导致的丢失 2`] = `8.252841733482933`; @@ -196,7 +196,7 @@ exports[`精度过高导致的曲线丢失 4`] = `"97661.61008"`; exports[`精度过高导致直连失败 1`] = `1`; -exports[`精度过高导致直连失败 2`] = `"32040.01390"`; +exports[`精度过高导致直连失败 2`] = `"32040.01391"`; exports[`精度过高导致直连失败 3`] = `1`; diff --git a/__test__/Polyline/__snapshots__/offsetbug.test.ts.snap b/__test__/Polyline/__snapshots__/offsetbug.test.ts.snap index edd0b7426..8583ebd0c 100644 --- a/__test__/Polyline/__snapshots__/offsetbug.test.ts.snap +++ b/__test__/Polyline/__snapshots__/offsetbug.test.ts.snap @@ -20,6 +20,6 @@ exports[`补充bug测试#IKWGF 9`] = `2.168984971098264`; exports[`补充bug测试#IKWGF 10`] = `0.39474593983901435`; -exports[`补充bug测试#IKWGF 11`] = `10.69886845125427`; +exports[`补充bug测试#IKWGF 11`] = `10.698868451254269`; exports[`补充bug测试#IKWGF 12`] = `1.0803374679586235`; diff --git a/__test__/Sweep/__snapshots__/SweepSegs.test.ts.snap b/__test__/Sweep/__snapshots__/SweepSegs.test.ts.snap index b0b794363..d20a5fa48 100644 --- a/__test__/Sweep/__snapshots__/SweepSegs.test.ts.snap +++ b/__test__/Sweep/__snapshots__/SweepSegs.test.ts.snap @@ -80,44 +80,44 @@ exports[`顶线分段测试 闭合圆弧 8`] = `11360.440190078047`; exports[`顶线分段测试 闭合圆弧 9`] = `4713.85413305274`; -exports[`顶线分段测试 闭合直线 1`] = `2152.655017660556`; +exports[`顶线分段测试 闭合直线 1`] = `1411.8807330899142`; -exports[`顶线分段测试 闭合直线 2`] = `1157.9339062625943`; +exports[`顶线分段测试 闭合直线 2`] = `2152.655017660556`; -exports[`顶线分段测试 闭合直线 3`] = `1049.373745402737`; +exports[`顶线分段测试 闭合直线 3`] = `1157.9339062625943`; -exports[`顶线分段测试 闭合直线 4`] = `1007.7933435525692`; +exports[`顶线分段测试 闭合直线 4`] = `1049.373745402737`; -exports[`顶线分段测试 闭合直线 5`] = `1867.3971281882991`; +exports[`顶线分段测试 闭合直线 5`] = `1007.7933435525692`; -exports[`顶线分段测试 闭合直线 6`] = `711.6950394345639`; +exports[`顶线分段测试 闭合直线 6`] = `1867.3971281882991`; -exports[`顶线分段测试 闭合直线 7`] = `1109.7095976240196`; +exports[`顶线分段测试 闭合直线 7`] = `711.6950394345639`; -exports[`顶线分段测试 闭合直线 8`] = `1099.4488714706863`; +exports[`顶线分段测试 闭合直线 8`] = `1109.7095976240196`; -exports[`顶线分段测试 闭合直线 9`] = `1411.8807330899142`; +exports[`顶线分段测试 闭合直线 9`] = `1099.4488714706863`; -exports[`顶线分段测试 闭合直线2 1`] = `1773.6483926638098`; +exports[`顶线分段测试 闭合直线2 1`] = `2378.824808973823`; -exports[`顶线分段测试 闭合直线2 2`] = `1327.0314994557618`; +exports[`顶线分段测试 闭合直线2 2`] = `1773.6483926638098`; -exports[`顶线分段测试 闭合直线2 3`] = `1593.058941817248`; +exports[`顶线分段测试 闭合直线2 3`] = `1327.0314994557618`; -exports[`顶线分段测试 闭合直线2 4`] = `1234.7942063629366`; +exports[`顶线分段测试 闭合直线2 4`] = `1593.058941817248`; -exports[`顶线分段测试 闭合直线2 5`] = `1657.0432133817048`; +exports[`顶线分段测试 闭合直线2 5`] = `1234.7942063629366`; -exports[`顶线分段测试 闭合直线2 6`] = `1812.9802996395224`; +exports[`顶线分段测试 闭合直线2 6`] = `1657.0432133817048`; -exports[`顶线分段测试 闭合直线2 7`] = `1366.7470210563024`; +exports[`顶线分段测试 闭合直线2 7`] = `1812.9802996395224`; -exports[`顶线分段测试 闭合直线2 8`] = `2149.6670549035985`; +exports[`顶线分段测试 闭合直线2 8`] = `1366.7470210563024`; -exports[`顶线分段测试 闭合直线2 9`] = `1980.1205315844518`; +exports[`顶线分段测试 闭合直线2 9`] = `2149.6670549035985`; -exports[`顶线分段测试 闭合直线2 10`] = `1613.0589418172485`; +exports[`顶线分段测试 闭合直线2 10`] = `1980.1205315844518`; -exports[`顶线分段测试 闭合直线2 11`] = `1665.8400676945942`; +exports[`顶线分段测试 闭合直线2 11`] = `1613.0589418172485`; -exports[`顶线分段测试 闭合直线2 12`] = `2378.824808973823`; +exports[`顶线分段测试 闭合直线2 12`] = `1665.8400676945942`; diff --git a/src/DatabaseServices/Entity/Polyline.ts b/src/DatabaseServices/Entity/Polyline.ts index 64a4dcd87..d12ab1aa8 100644 --- a/src/DatabaseServices/Entity/Polyline.ts +++ b/src/DatabaseServices/Entity/Polyline.ts @@ -7,7 +7,7 @@ import { FixIndex } from '../../Common/Utils'; import { ObjectSnapMode } from '../../Editor/ObjectSnapMode'; import { Box3Ext } from '../../Geometry/Box'; import { CreatePolylinePath } from '../../Geometry/CreatePolylinePath'; -import { AsVector2, AsVector3, equaln, equalv2, equalv3, MatrixIsIdentityCS } from '../../Geometry/GeUtils'; +import { AsVector2, AsVector3, MatrixIsIdentityCS, equaln, equalv2, equalv3 } from '../../Geometry/GeUtils'; import { IntersectOption, IntersectPolylineAndCurve } from '../../GraphicsSystem/IntersectWith'; import { OffsetPolyline } from '../../GraphicsSystem/OffsetPolyline'; import { Factory } from '../CADFactory'; @@ -897,6 +897,18 @@ export class Polyline extends Curve let linkType = LinkType.None; + if (epspDisSq < minDis) + { + linkType = LinkType.EpSp; + minDis = epspDisSq; + } + + if (epepDisSq < minDis) + { + linkType = LinkType.EpEp; + minDis = epepDisSq; + } + if (spspDisSq < minDis) { linkType = LinkType.SpSp; @@ -909,15 +921,6 @@ export class Polyline extends Curve minDis = spepDisSq; } - if (epspDisSq < minDis) - { - linkType = LinkType.EpSp; - minDis = epspDisSq; - } - - if (epepDisSq < minDis) - linkType = LinkType.EpEp; - if (linkType === LinkType.None) return Status.False; @@ -1050,13 +1053,15 @@ export class Polyline extends Curve return pl; } + /**首尾相连的曲线直接连接 */ - static FastCombine(curves: Curve[], tolerance = 1e-5): Polyline | undefined + static FastCombine(curves: Curve[], tolerance = 1e-5, computOCS = true): Polyline | undefined { if (!curves || curves.length === 0) return; let pl = new Polyline; - pl.OCS = ComputerCurvesNormalOCS(curves); + if (computOCS) + pl.OCS = ComputerCurvesNormalOCS(curves); let ocsInv = pl.OCSInv; let normal = pl.Normal; diff --git a/src/Editor/UserConfig.ts b/src/Editor/UserConfig.ts index 16aa1d96b..afa03ff6c 100644 --- a/src/Editor/UserConfig.ts +++ b/src/Editor/UserConfig.ts @@ -95,7 +95,7 @@ export class UserConfig implements IConfigStore @observable isModifyMaterial: boolean = true;//右侧工具栏应用时覆盖新的材质 @observable isHighlightMaterial: boolean = true;//亮显材质球 @observable cabinetSpacing: number = 1000; //柜子移动到0点配置 柜子间距 - @observable testModeSpacing = 50; //模拟走刀图形间距 + @observable testModeSpacing = 200; //模拟走刀图形间距 @observable ConceptualEdgeColor = 7;//概念线框的颜色 ConceptualOpacity = 1;//概念透明的透明度 diff --git a/src/GraphicsSystem/CalcEdgeSealing.ts b/src/GraphicsSystem/CalcEdgeSealing.ts index d3181fb03..f0f44f94f 100644 --- a/src/GraphicsSystem/CalcEdgeSealing.ts +++ b/src/GraphicsSystem/CalcEdgeSealing.ts @@ -286,6 +286,7 @@ class OffsetPolyline2 extends OffsetPolyline /** * 获取板件的轮廓(没有扣封边)(拆单时表现) * 在拆单的时候 我们用这个轮廓(为了数据对应准确性) + * 修改时 请注意函数 GetSealedBoardContour */ export function GetBoardContour(br: Board): ExtrudeContourCurve | undefined { @@ -297,13 +298,20 @@ export function GetBoardContour(br: Board): ExtrudeContourCurve | undefined if (curves.length === 1 && curves[0] instanceof Circle) return curves[0]; - let brContour = Polyline.Combine(curves, 1e-3); + let allCurvs: Curve[] = []; + for (let c of curves) + if (c instanceof Polyline) + allCurvs.push(...c.Explode()); + else + allCurvs.push(c); + let brContour = Polyline.FastCombine(allCurvs, 1e-4, false); return brContour; } /** * 获取板件(扣封边后的)轮廓(拆单时) + * 修改时 请注意函数 GetBoardContour */ export function GetSealedBoardContour(br: Board): BrSealedData | undefined { @@ -324,9 +332,13 @@ export function GetSealedBoardContour(br: Board): BrSealedData | undefined return res; } - let brContour = new Polyline; + let allCurvs: Curve[] = []; for (let c of curves) - brContour.Join(c); + if (c instanceof Polyline) + allCurvs.push(...c.Explode()); + else + allCurvs.push(c); + let brContour = Polyline.FastCombine(allCurvs, 1e-4, false); let dir = Math.sign(brContour.Area2);