fix 多段线自我trim时,连接结果出错的问题

pull/528/MERGE
ChenX 5 years ago
parent cef011a3ae
commit 2ecd1e1b64

@ -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();

@ -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);
}

Loading…
Cancel
Save