From 13e3433f2d7a3164d18c3e034a28b8ff081a740f Mon Sep 17 00:00:00 2001 From: ZoeLeeFZ Date: Tue, 19 Nov 2019 15:41:11 +0800 Subject: [PATCH] =?UTF-8?q?!607=20=E4=BC=98=E5=8C=96=E5=B0=81=E8=BE=B9?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__snapshots__/EdgeSealing.test.ts.snap | 6 +++--- src/GraphicsSystem/CalcEdgeSealing.ts | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/__test__/EdgeSealing/__snapshots__/EdgeSealing.test.ts.snap b/__test__/EdgeSealing/__snapshots__/EdgeSealing.test.ts.snap index ff007119f..6384a67c2 100644 --- a/__test__/EdgeSealing/__snapshots__/EdgeSealing.test.ts.snap +++ b/__test__/EdgeSealing/__snapshots__/EdgeSealing.test.ts.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`丢失线段板件 1`] = `538651.2759963807`; +exports[`丢失线段板件 1`] = `538651.2759963808`; exports[`丢失线段板件 2`] = `398758.87896958226`; @@ -24,8 +24,8 @@ exports[`异型板件,非常规坐标系 1`] = `75939516.39226122`; exports[`异型板件,非常规坐标系 2`] = `75863286.03232267`; -exports[`异型板件,非常规坐标系 3`] = `75694680.60847881`; +exports[`异型板件,非常规坐标系 3`] = `75694680.60847883`; exports[`异型板件,非相切圆弧 1`] = `635612.2751433643`; -exports[`异型板件,非相切圆弧 2`] = `626242.2196800548`; +exports[`异型板件,非相切圆弧 2`] = `626242.2196800549`; diff --git a/src/GraphicsSystem/CalcEdgeSealing.ts b/src/GraphicsSystem/CalcEdgeSealing.ts index 366fb3488..4613989ac 100644 --- a/src/GraphicsSystem/CalcEdgeSealing.ts +++ b/src/GraphicsSystem/CalcEdgeSealing.ts @@ -1,4 +1,3 @@ -import { Vector3 } from "three"; import { EBoardKeyList } from "../Common/BoardKeyList"; import { FixIndex } from "../Common/Utils"; import { Board } from "../DatabaseServices/Entity/Board"; @@ -120,21 +119,31 @@ export function CalcEdgeSealing(cus: Curve[]) { if (cus.length <= 1) return; + let oldLine: Curve; + let firstLine = cus[0].Clone(); for (let i = 0; i < cus.length; i++) { let frontLine = cus[i]; let laterLine = cus[FixIndex(i + 1, cus)]; if (equalv3(frontLine.EndPoint, laterLine.StartPoint)) continue; - let iPts = frontLine.IntersectWith(laterLine, IntersectOption.ExtendBoth); + let refLine = oldLine ?? frontLine; + let refLine2 = i === cus.length - 1 ? firstLine : laterLine; + let iPts = refLine.IntersectWith(refLine2, IntersectOption.ExtendBoth); let tPts = iPts.filter(p => - frontLine.PtOnCurve(p) - && laterLine.PtOnCurve(p) + refLine.PtOnCurve(p) + && refLine2.PtOnCurve(p) ); let iPt = SelectNearP(tPts.length > 0 ? tPts : iPts, frontLine.EndPoint); + if (!iPt) + { + alert("获取封边错误,请提供图纸给相关人员"); + return; + } frontLine.EndPoint = iPt; + oldLine = equalv3(iPt, laterLine.EndPoint) ? laterLine.Clone() : null; laterLine.StartPoint = iPt; } }