pull/68/head
Zoe 6 years ago
parent f54c968ae2
commit 919dbdf3db

@ -194,4 +194,11 @@ test('点在圆弧的弦中心上', () =>
let pt = new Vector3().fromArray([4.999999999999999, 2.5, 0]); let pt = new Vector3().fromArray([4.999999999999999, 2.5, 0]);
let isR = GetPointAtCurveDir(pl, pt); let isR = GetPointAtCurveDir(pl, pt);
expect(isR).toBeFalsy(); expect(isR).toBeFalsy();
pt = new Vector3().fromArray([5, 9.5, 0]);
isR = GetPointAtCurveDir(pl, pt);
expect(isR).toBeTruthy();
pt = new Vector3().fromArray([5, 5.5, 0]);
isR = GetPointAtCurveDir(pl, pt);
expect(isR).toBeTruthy();
}); });

@ -32,6 +32,7 @@ test('IKKGK圆与直线补圆弧', () =>
expect(f.Data).toMatchSnapshot(); expect(f.Data).toMatchSnapshot();
//圆丢失的问题 //圆丢失的问题
cus = pl.GetOffsetCurves(-1.926388985025112); cus = pl.GetOffsetCurves(-1.926388985025112);
expect(cus.length).toBe(2); expect(cus.length).toBe(2);

@ -37,7 +37,7 @@ export class Test implements Command
} }
//将多段线转换为cad图形 //将多段线转换为cad图形
async exec() async exec4()
{ {
// let d = [["Polyline", 1, 1, 12839, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 24, [256.5228611988947, -38.705370748164505], 0, [372.1955588024039, 31.844231195771492], 0, [372.1955588024039, -31.54297461172431], 0, [450.9819163032461, 37.57414810492366], 0, [423.0485713711294, -54.10452244151095], 0, [589.216161736542, 52.97329979827009], 0, [611.0614699526845, -2.177150452319474], 0, [672.6580767260702, 61.21005535517633], 0, [678.0298738284004, 13.938240854670997], 0, [735.329042919922, 21.100636991111184], 0, [684.1179105443746, -21.515620020708024], 0, [730.6734854312358, -32.61733403219032], 0, [815.1897598412304, 38.29038771856768], 0, [835.6025888300849, -8.981426781937659], 0, [862.1034545349137, 74.4604882075907], 0, [943.4539498526012, 74.46048820759069], 0, [986.972668777612, -29.064785548515978], 0, [924.5022496755805, -66.26627108118637], 0, [1001.0109652050348, -106.27541589934134], 0, [965.9152241364777, -128.73669018321777], 0, [1006.6262837760039, -176.46689803645526], 0, [904.1467198558175, -189.8032796425069], 0, [981.3573502066429, -242.44689124534239], 0, [1004.5205393118904, -256.48518767276516], 0, false]] // let d = [["Polyline", 1, 1, 12839, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 24, [256.5228611988947, -38.705370748164505], 0, [372.1955588024039, 31.844231195771492], 0, [372.1955588024039, -31.54297461172431], 0, [450.9819163032461, 37.57414810492366], 0, [423.0485713711294, -54.10452244151095], 0, [589.216161736542, 52.97329979827009], 0, [611.0614699526845, -2.177150452319474], 0, [672.6580767260702, 61.21005535517633], 0, [678.0298738284004, 13.938240854670997], 0, [735.329042919922, 21.100636991111184], 0, [684.1179105443746, -21.515620020708024], 0, [730.6734854312358, -32.61733403219032], 0, [815.1897598412304, 38.29038771856768], 0, [835.6025888300849, -8.981426781937659], 0, [862.1034545349137, 74.4604882075907], 0, [943.4539498526012, 74.46048820759069], 0, [986.972668777612, -29.064785548515978], 0, [924.5022496755805, -66.26627108118637], 0, [1001.0109652050348, -106.27541589934134], 0, [965.9152241364777, -128.73669018321777], 0, [1006.6262837760039, -176.46689803645526], 0, [904.1467198558175, -189.8032796425069], 0, [981.3573502066429, -242.44689124534239], 0, [1004.5205393118904, -256.48518767276516], 0, false]]
@ -127,7 +127,7 @@ export class Test implements Command
r2.ShapeManager.ShapeList.forEach(s => s.Explode().forEach(c => app.m_Database.ModelSpace.Append(c))); r2.ShapeManager.ShapeList.forEach(s => s.Explode().forEach(c => app.m_Database.ModelSpace.Append(c)));
} }
async exec4() async exec()
{ {
let e = await app.m_Editor.GetEntity(); let e = await app.m_Editor.GetEntity();
if (e.Status === PromptStatus.OK) if (e.Status === PromptStatus.OK)
@ -136,10 +136,7 @@ export class Test implements Command
if (e.Entity instanceof Polyline) if (e.Entity instanceof Polyline)
{ {
console.log(GetPointAtCurveDir(e.Entity, new Vector3(2.5, 3.1699))); console.log(GetPointAtCurveDir(e.Entity, new Vector3(5, 5.5)));
console.log(GetPointAtCurveDir(e.Entity, new Vector3(5, 2.5)));
console.log(GetPointAtCurveDir(e.Entity, new Vector3(4.99999999999, 2.5)));
console.log(GetPointAtCurveDir(e.Entity, new Vector3(2.5, 2.5)));
this.drawPtDirTestCir(e.Entity); this.drawPtDirTestCir(e.Entity);
} }
return; return;
@ -161,7 +158,7 @@ export class Test implements Command
{ {
p.y += size.y; p.y += size.y;
let c = new Circle(p, 0.1); let c = new Circle(p, 0.1);
c.ColorIndex = GetPointAtCurveDir(pl, p) ? 1 : 2; c.ColorIndex = GetPointAtCurveDir(pl, p) ? 3 : 1;
app.m_Database.ModelSpace.Append(c); app.m_Database.ModelSpace.Append(c);
} }
} }

@ -90,8 +90,11 @@ export class PolyOffestUtil
//与源线段自交 //与源线段自交
if (c.IntersectWith(this.m_Polyline, IntersectOption.OnBothOperands).length !== 0) if (c.IntersectWith(this.m_Polyline, IntersectOption.OnBothOperands).length !== 0)
return false; return false;
return (this.CheckPointDist(c.StartPoint) && this.CheckPointDist(c.EndPoint)) //删除在反方向的无效线段
&& (this.CheckPointDir(c.StartPoint) || this.CheckPointDir(c.EndPoint)); return this.CheckPointDir(c.StartPoint);
// return this.CheckPointDist(c.StartPoint) && this.CheckPointDist(c.EndPoint)
// return (this.CheckPointDist(c.StartPoint) && this.CheckPointDist(c.EndPoint))
// && this.CheckPointDir(c.StartPoint);
}); });
//处理自交的线段 //处理自交的线段
@ -235,8 +238,10 @@ export class PolyOffestUtil
laterLine = offResList[FixIndex(i + 1, offResList)].curve; laterLine = offResList[FixIndex(i + 1, offResList)].curve;
//#region 1.中间丢失线段的情况下补圆弧. //#region 1.中间丢失线段的情况下且没循环到尾部,补圆弧.
if (FixIndex(startIndex + 1, this.m_Polyline.EndParam) !== endIndex) let isFillArc = FixIndex(startIndex + 1, this.m_Polyline.EndParam) !== endIndex;
if (isFillArc && startIndex > endIndex)
{ {
this.fillArc(startIndex, endIndex, nextStartPt, frontLine, laterLine); this.fillArc(startIndex, endIndex, nextStartPt, frontLine, laterLine);
continue; continue;
@ -270,7 +275,7 @@ export class PolyOffestUtil
let iPt = this.selectFitInterPt(tPts, frontLine.EndPoint); let iPt = this.selectFitInterPt(tPts, frontLine.EndPoint);
this.appendNewCuAndContour(frontLine, nextStartPt, iPt, startIndex); this.appendNewCuAndContour(frontLine, nextStartPt, iPt, startIndex);
} }
else if (iPts.length === 0)//连交点都没,补圆弧 else if (isFillArc || iPts.length === 0)//连交点都没或者圆弧丢失补圆弧
{ {
this.fillArc(startIndex, endIndex, nextStartPt, frontLine, laterLine); this.fillArc(startIndex, endIndex, nextStartPt, frontLine, laterLine);
} }

Loading…
Cancel
Save