构建扇形清理剩余无效线段

pull/68/head
Zoe 6 years ago
parent 2a273fce5f
commit 53f92a3f95

@ -504,8 +504,7 @@ describe("补圆弧测试", () =>
{
expect(cus[0].GetOffsetCurves(-i).length).toBe(1);
}
//FIXME:没清理干净
// expect(cus[0].GetOffsetCurves(27.3).length).toBe(1);
expect(cus[0].GetOffsetCurves(27.3).length).toBe(1);
})
test("补圆弧测试3", () =>
{

@ -179,7 +179,7 @@ export class PolyOffestUtil
}
/**
* 线
* 2线
*
* @private
* @param {Curve} cu1
@ -187,37 +187,51 @@ export class PolyOffestUtil
* @returns
* @memberof PolyOffestUtil
*/
private BuildContour(cu1: Curve, cu2: Curve): Contour
private BuildContour(cu1: Curve, cu2: Curve | Vector3): Contour
{
let l1 = new Line(cu1.StartPoint, cu2.StartPoint);
let l2 = new Line(cu1.EndPoint, cu2.EndPoint);
if (cu1 instanceof Arc && cu2 instanceof Arc)
if (cu2 instanceof Curve)
{
let pts1 = l1.IntersectWith(cu2, 0);
if (pts1.length === 2)
let l1 = new Line(cu1.StartPoint, cu2.StartPoint);
let l2 = new Line(cu1.EndPoint, cu2.EndPoint);
if (cu1 instanceof Arc && cu2 instanceof Arc)
{
let splitCus = cu2.GetSplitCurvesByPts(pts1);
this.unNeedCutCus.push(splitCus[0])
let pts1 = l1.IntersectWith(cu2, 0);
if (pts1.length === 2)
{
let splitCus = cu2.GetSplitCurvesByPts(pts1);
this.unNeedCutCus.push(splitCus[0])
}
let pts2 = l2.IntersectWith(cu2, 0);
if (pts2.length === 2)
{
let splitCus = cu2.GetSplitCurvesByPts(pts2);
this.unNeedCutCus.push(splitCus[1])
}
}
let pts2 = l2.IntersectWith(cu2, 0);
if (pts2.length === 2)
//防止轮廓自交
if (l1.IntersectWith(l2, 0).length > 0)
{
let splitCus = cu2.GetSplitCurvesByPts(pts2);
this.unNeedCutCus.push(splitCus[1])
l1 = new Line(cu1.StartPoint, cu2.EndPoint);
l2 = new Line(cu1.EndPoint, cu2.StartPoint);
}
return Contour.CreateContour([
cu1.Clone() as Curve,
cu2.Clone() as Curve,
l1,
l2
]);
}
//防止轮廓自交
if (l1.IntersectWith(l2, 0).length > 0)
else
{
l1 = new Line(cu1.StartPoint, cu2.EndPoint);
l2 = new Line(cu1.EndPoint, cu2.StartPoint);
let l1 = new Line(cu1.StartPoint, cu2);
let l2 = new Line(cu1.EndPoint, cu2);
return Contour.CreateContour([
cu1,
l1,
l2
]);
}
return Contour.CreateContour([
cu1.Clone() as Curve,
cu2.Clone() as Curve,
l1,
l2
]);
}
private BuildCircleContour(i: number | Vector3, cons: Contour[])
{
@ -324,6 +338,18 @@ export class PolyOffestUtil
if (tPts.length > 0)//存在真交点情况下直接修剪
{
let iPt = this.selectFitInterPt(tPts, frontLine.EndPoint);
if (isFillArc)
{
//用丢失圆弧和交点构建扇形轮廓
for (let i = startIndex + 1; ; i++)
{
let index = FixIndex(i, this.m_PtCount);
let cu = this.m_Polyline.GetCurveAtParam(index);
cirContours.push(this.BuildContour(cu, iPt));
if (index === endIndex - 1) break;
}
}
this.appendNewCuAndContour(frontLine, nextStartPt, iPt, startIndex);
}
else if (isFillArc || iPts.length === 0)//连交点都没或者圆弧丢失补圆弧

Loading…
Cancel
Save