|
|
@ -18,7 +18,7 @@ interface offestRes
|
|
|
|
interface offestRes1
|
|
|
|
interface offestRes1
|
|
|
|
{
|
|
|
|
{
|
|
|
|
index: number,
|
|
|
|
index: number,
|
|
|
|
pl: Curve
|
|
|
|
curve: Curve
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -1065,13 +1065,14 @@ export class PolyOffestUtil3
|
|
|
|
//偏移
|
|
|
|
//偏移
|
|
|
|
GetOffsetCurves(): Curve[]
|
|
|
|
GetOffsetCurves(): Curve[]
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let plList1: offestRes1[] = this.offestCurve(this.m_Polyline.Explode());
|
|
|
|
let expCus = this.m_Polyline.Explode();
|
|
|
|
let plList2: offestRes1[] = this.offestCurve(this.m_Polyline.Explode(), true);
|
|
|
|
let plList1 = this.offestCurve(expCus, this.m_OffestDist);
|
|
|
|
|
|
|
|
let plList2 = this.offestCurve(expCus, -this.m_OffestDist);
|
|
|
|
|
|
|
|
|
|
|
|
let contours: Contour[] = [];
|
|
|
|
let contours: Contour[] = [];
|
|
|
|
for (let i = 0; i < plList1.length; i++)
|
|
|
|
for (let i = 0; i < plList1.length; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let con = this.buildContourByTwoSideOfest(plList1[i].pl, plList2[i].pl);
|
|
|
|
let con = this.buildContourByTwoSideOfest(plList1[i].curve, plList2[i].curve);
|
|
|
|
con && contours.push(con);
|
|
|
|
con && contours.push(con);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1126,17 +1127,15 @@ export class PolyOffestUtil3
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//偏移曲线
|
|
|
|
//偏移曲线
|
|
|
|
private offestCurve(pls: Curve[], isContrary: boolean = false): offestRes1[]
|
|
|
|
private offestCurve(pls: Curve[], dis: number): offestRes1[]
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let plList: offestRes1[] = [];
|
|
|
|
return pls.map((cu, index) =>
|
|
|
|
pls.forEach((cu, index) =>
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let pl = cu.GetOffsetCurves(isContrary ? -this.m_OffestDist : this.m_OffestDist)[0];
|
|
|
|
let curve = cu.GetOffsetCurves(dis)[0];
|
|
|
|
plList.push({ pl, index });
|
|
|
|
return { curve, index };
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return plList;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//通过2侧偏移曲线构建封闭轮廓
|
|
|
|
//通过2侧偏移曲线构建封闭轮廓,由于是双向偏移,所以不可能出现2个曲线都为空的情况
|
|
|
|
private buildContourByTwoSideOfest(pl1: Curve, pl2: Curve)
|
|
|
|
private buildContourByTwoSideOfest(pl1: Curve, pl2: Curve)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (pl1 && pl2)
|
|
|
|
if (pl1 && pl2)
|
|
|
@ -1162,20 +1161,21 @@ export class PolyOffestUtil3
|
|
|
|
// 修剪连接相邻曲线
|
|
|
|
// 修剪连接相邻曲线
|
|
|
|
private trimAndJointOffestPolyline(offResList: offestRes1[], originLine: Polyline)
|
|
|
|
private trimAndJointOffestPolyline(offResList: offestRes1[], originLine: Polyline)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
offResList = offResList.filter(r => r.pl)
|
|
|
|
offResList = offResList.filter(r => r.curve);
|
|
|
|
if (offResList.length === 0) return [];
|
|
|
|
if (offResList.length <= 1)
|
|
|
|
if (offResList.length === 1) return [offResList[0].pl];
|
|
|
|
return offResList.map(r => r.curve);
|
|
|
|
|
|
|
|
|
|
|
|
let newPlList: Array<Curve> = [];
|
|
|
|
let newPlList: Array<Curve> = [];
|
|
|
|
|
|
|
|
|
|
|
|
let nextPt: Vector3 = offResList[0].pl.StartPoint.clone();
|
|
|
|
let nextPt: Vector3 = offResList[0].curve.StartPoint;
|
|
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < offResList.length; i++)
|
|
|
|
for (let i = 0; i < offResList.length; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//前面线
|
|
|
|
//前面线
|
|
|
|
let frontLine = offResList[i].pl;
|
|
|
|
let frontLine = offResList[i].curve;
|
|
|
|
|
|
|
|
|
|
|
|
//后面线
|
|
|
|
//后面线
|
|
|
|
let laterLine = i === offResList.length - 1 ? undefined : offResList[i + 1].pl;
|
|
|
|
let laterLine = i === offResList.length - 1 ? undefined : offResList[i + 1].curve;
|
|
|
|
//如果是闭合的,继续循环,否则直接添加到新数组列表
|
|
|
|
//如果是闭合的,继续循环,否则直接添加到新数组列表
|
|
|
|
if (i === offResList.length - 1)
|
|
|
|
if (i === offResList.length - 1)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1183,7 +1183,6 @@ export class PolyOffestUtil3
|
|
|
|
laterLine = newPlList[0];
|
|
|
|
laterLine = newPlList[0];
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let frontLine = offResList[offResList.length - 1].pl;
|
|
|
|
|
|
|
|
this.appendNewPllist(frontLine, nextPt, frontLine.EndPoint, newPlList);
|
|
|
|
this.appendNewPllist(frontLine, nextPt, frontLine.EndPoint, newPlList);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|