fix #IOX2D IOX26

pull/198/MERGE
ChenX 6 years ago
parent cea77709d5
commit 5be79e78ad

@ -364,35 +364,47 @@ export class CommandFillet implements Command
if (res && res.arc) if (res && res.arc)
{ {
let pln = pl.Clone(); let pln = pl.Clone();
//修正凸度
if (res.cu1 instanceof Arc) if (res.cu1 instanceof Arc)
pln.SetBulgeAt(parF1, res.cu1.Bul); pln.SetBulgeAt(parF1, res.cu1.Bul);
if (res.cu2 instanceof Arc) if (res.cu2 instanceof Arc)
pln.SetBulgeAt(parF2, res.cu2.Bul); pln.SetBulgeAt(parF2, res.cu2.Bul);
let sp = res.arc.StartPoint.applyMatrix4(pln.OCSInv); let sp2d = Vec3DTo2D(res.arc.StartPoint.applyMatrix4(pln.OCSInv));
let ep = res.arc.EndPoint.applyMatrix4(pln.OCSInv); let ep2d = Vec3DTo2D(res.arc.EndPoint.applyMatrix4(pln.OCSInv));
if (rem === 1)
let isNeighbor = rem === 1;
//#IOX26
if (isNeighbor && res.cu1 instanceof Arc && res.cu2 instanceof Arc)
{ {
pln.SetPointAt(parF2, Vec3DTo2D(ep)); let ins = res.cu1.IntersectWith(res.cu2, IntersectOption.OnBothOperands);
pln.AddVertexAt(parF2, Vec3DTo2D(sp)); if (ins.length === 1 && !equalv3(pln.StartPoint, ins[0]))
isNeighbor = false;
}
if (isNeighbor)
{
pln.SetPointAt(parF2, ep2d);
pln.AddVertexAt(parF2, sp2d);
pln.SetBulgeAt(parF2, res.arc.Bul); pln.SetBulgeAt(parF2, res.arc.Bul);
} }
else//首尾 else//首尾
{ {
let oldBul = pln.GetBuilgeAt(0); pln.SetPointAt(0, sp2d);
pln.StartPoint = sp;
pln.SetBulgeAt(0, oldBul);
let plPtCount = pln.NumberOfVertices; let plPtCount = pln.NumberOfVertices;
if (pln.EndParam === plPtCount)//CloseMark if (pln.EndParam === plPtCount)//CloseMark
{ {
pln.AddVertexAt(plPtCount, Vec3DTo2D(ep)); pln.AddVertexAt(plPtCount, ep2d);
pln.SetBulgeAt(plPtCount, -res.arc.Bul); pln.SetBulgeAt(plPtCount, -res.arc.Bul);
} }
else else
{ {
pln.EndPoint = ep; pln.SetPointAt(plPtCount - 1, ep2d);
pln.SetBulgeAt(plPtCount - 1, -res.arc.Bul); pln.SetBulgeAt(plPtCount - 1, -res.arc.Bul);
pln.AddVertexAt(plPtCount, Vec3DTo2D(sp)); pln.AddVertexAt(plPtCount, sp2d);
} }
} }

@ -235,17 +235,26 @@ export class Polyline extends Curve
return Vec2DTo3D(this.m_LineData[0].pt).applyMatrix4(this.OCS); return Vec2DTo3D(this.m_LineData[0].pt).applyMatrix4(this.OCS);
return new Vector3(); return new Vector3();
} }
set StartPoint(v: Vector3) set StartPoint(p: Vector3)
{ {
this.WriteAllObjectRecord(); this.WriteAllObjectRecord();
this.SetPointAt(0, Vec3DTo2D(v)); p = p.clone().applyMatrix4(this.OCSInv);
let bul = this.GetBuilgeAt(0)
if (bul !== 0) if (this.m_LineData.length === 0)
this.AddVertexAt(0, Vec3DTo2D(p));
else if (this.m_LineData.length === 1)
this.SetPointAt(0, Vec3DTo2D(p));
else
{ {
let arc = this.GetCurveAtParam(0) as Arc; let bul = this.GetBuilgeAt(0)
arc.StartPoint = v; if (bul !== 0)
//前面线的凸度调整 {
this.SetBulgeAt(0, Math.tan(arc.AllAngle / 4) * Math.sign(bul)); let arc = this.GetCurveAtParam(0) as Arc;
arc.StartPoint = p;
//前面线的凸度调整
this.SetBulgeAt(0, Math.tan(arc.AllAngle / 4) * Math.sign(bul));
}
this.SetPointAt(0, Vec3DTo2D(p));
} }
} }
get EndPoint() get EndPoint()
@ -255,21 +264,24 @@ export class Polyline extends Curve
return Vec2DTo3D(this.m_LineData[this.EndParam].pt).applyMatrix4(this.OCS); return Vec2DTo3D(this.m_LineData[this.EndParam].pt).applyMatrix4(this.OCS);
return new Vector3(); return new Vector3();
} }
set EndPoint(v: Vector3) set EndPoint(p: Vector3)
{ {
this.WriteAllObjectRecord(); if (this.m_LineData.length < 2 || this.CloseMark)
this.SetPointAt(this.EndParam, Vec3DTo2D(v));
if (this.EndParam === 0)
return; return;
this.WriteAllObjectRecord();
p = p.clone().applyMatrix4(this.OCSInv);
let bul = this.GetBuilgeAt(this.EndParam - 1) let bul = this.GetBuilgeAt(this.EndParam - 1)
if (bul !== 0) if (bul !== 0)
{ {
let arc = this.GetCurveAtParam(0) as Arc; let arc = this.GetCurveAtParam(this.EndParam - 1) as Arc;
arc.EndPoint = v; arc.ApplyMatrix(this.OCSInv);
arc.EndPoint = p;
//前面线的凸度调整 //前面线的凸度调整
this.SetBulgeAt(this.EndParam - 1, Math.tan(arc.AllAngle / 4) * Math.sign(bul)); this.SetBulgeAt(this.EndParam - 1, Math.tan(arc.AllAngle / 4) * Math.sign(bul));
} }
this.SetPointAt(this.EndParam, Vec3DTo2D(p));
} }
get StartParam() get StartParam()
{ {

Loading…
Cancel
Save