From 2ecd1e1b6402d5dc3803c23725ea11b783d40454 Mon Sep 17 00:00:00 2001 From: ChenX Date: Thu, 10 Oct 2019 22:18:06 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=A4=9A=E6=AE=B5=E7=BA=BF=E8=87=AA?= =?UTF-8?q?=E6=88=91trim=E6=97=B6,=E8=BF=9E=E6=8E=A5=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E5=87=BA=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Add-on/Trim.ts | 6 +++--- src/DatabaseServices/Entity/Polyline.ts | 28 ++++++++++++------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/Add-on/Trim.ts b/src/Add-on/Trim.ts index 939442526..7daaa3f28 100644 --- a/src/Add-on/Trim.ts +++ b/src/Add-on/Trim.ts @@ -128,7 +128,7 @@ export class Command_Trim implements Command kniefCus = app.Database.ModelSpace.Entitys.filter(cu => cu instanceof Curve && !cu.IsErase) as Curve[]; for (let icu of kniefCus) - if (icu != thisCurve) + if (icu !== thisCurve) inPts.push(...cu.IntersectWith(icu, IntersectOption.OnBothOperands)); return inPts; } @@ -162,7 +162,7 @@ export class Command_Trim implements Command //正向遍历 for (; i < notSelCus.length; i++) { - if (cuStart.Join(notSelCus[i]) != Status.True) + if (cuStart.Join(notSelCus[i]) !== Status.True) break; } notSelCus.splice(0, i);//移除0->(i-1)的元素 @@ -209,7 +209,7 @@ export class Command_Trim implements Command //合并多段线 for (let c of notSelCus) { - if (pl.Join(c) != Status.True) + if (pl.Join(c) !== Status.True) { retPolylineCol.push(pl); pl = new Polyline(); diff --git a/src/DatabaseServices/Entity/Polyline.ts b/src/DatabaseServices/Entity/Polyline.ts index 6cd5c27a6..33d5d9f86 100644 --- a/src/DatabaseServices/Entity/Polyline.ts +++ b/src/DatabaseServices/Entity/Polyline.ts @@ -709,27 +709,27 @@ export class Polyline extends Curve this.Update(); } - MatrixAlignTo(toMatrix: Matrix4) + //const this + MatrixAlignTo2(toMatrix: Matrix4) { if (!matrixIsCoplane(this._Matrix, toMatrix, 1e-4)) - return; + return this.PtsBuls; - this.WriteAllObjectRecord(); let m = matrixAlignCoordSys(this._Matrix, toMatrix); let z1 = this.Normal; let z2 = new Vector3().setFromMatrixColumn(toMatrix, 2); let isMirror = equalv3(z1, z2.negate()); + let pts: Vector2[] = []; + let buls: number[] = []; for (let d of this.m_LineData) { - let p = AsVector3(d.pt).applyMatrix4(m); - d.pt.x = p.x; - d.pt.y = p.y; - - if (isMirror) - d.bul = -d.bul; + let p = AsVector2(AsVector3(d.pt).applyMatrix4(m)); + pts.push(p); + buls.push(isMirror ? -d.bul : d.bul); } + return { pts, buls }; } Join(cu: Curve, allowGap = false, tolerance = 1e-4) @@ -819,14 +819,12 @@ export class Polyline extends Curve { if (cu.CloseMark) return Status.False; - cu.MatrixAlignTo(this.OCS); - let { pts, buls } = this.PtsBuls; if (equalv3(cuSp, sp, tolerance)) { cu.Reverse(); - let cuPtsBul = cu.PtsBuls; + let cuPtsBul = cu.MatrixAlignTo2(this.OCS); cuPtsBul.pts.pop(); cuPtsBul.buls.pop(); pts = cuPtsBul.pts.concat(pts); @@ -837,13 +835,13 @@ export class Polyline extends Curve pts.pop(); buls.pop(); - let cuPtsBul = cu.PtsBuls; + let cuPtsBul = cu.MatrixAlignTo2(this.OCS); pts = pts.concat(cuPtsBul.pts); buls = buls.concat(cuPtsBul.buls); } else if (equalv3(cuEp, sp, tolerance)) { - let cuPtsBul = cu.PtsBuls; + let cuPtsBul = cu.MatrixAlignTo2(this.OCS); cuPtsBul.pts.pop(); cuPtsBul.buls.pop(); pts = cuPtsBul.pts.concat(pts); @@ -855,7 +853,7 @@ export class Polyline extends Curve buls.pop(); cu.Reverse(); - let cuPtsBul = cu.PtsBuls; + let cuPtsBul = cu.MatrixAlignTo2(this.OCS); pts = pts.concat(cuPtsBul.pts); buls = buls.concat(cuPtsBul.buls); }