|
|
|
@ -55,17 +55,17 @@ export class PolyOffestUtil
|
|
|
|
|
// testContours(this.m_Contours);
|
|
|
|
|
//裁剪
|
|
|
|
|
let { boxCurves, outputCus } = this.trimByContours(this.m_RetCurves);
|
|
|
|
|
// // 优化裁剪后的曲线
|
|
|
|
|
// this.m_RetCurves = this.optimizeCus(boxCurves, outputCus);
|
|
|
|
|
// this.m_RetCurves.push(...this.unNeedCutCus);
|
|
|
|
|
// 优化裁剪后的曲线
|
|
|
|
|
this.m_RetCurves = this.optimizeCus(boxCurves, outputCus);
|
|
|
|
|
this.m_RetCurves.push(...this.unNeedCutCus);
|
|
|
|
|
|
|
|
|
|
// this.m_RetCurves = this.linkCurves(this.m_RetCurves);
|
|
|
|
|
// // 如果源线段闭合只保留闭合的部分
|
|
|
|
|
// if (this.m_Polyline.IsClose)
|
|
|
|
|
// return this.m_RetCurves.filter(c => c.IsClose);
|
|
|
|
|
this.m_RetCurves = this.linkCurves(this.m_RetCurves);
|
|
|
|
|
// 如果源线段闭合只保留闭合的部分
|
|
|
|
|
if (this.m_Polyline.IsClose)
|
|
|
|
|
return this.m_RetCurves.filter(c => c.IsClose);
|
|
|
|
|
|
|
|
|
|
this.m_Contours.forEach(c => { c.Outline.ColorIndex = 2 });
|
|
|
|
|
this.m_RetCurves.push(...this.m_Contours.map(c => c.Outline))
|
|
|
|
|
// this.m_Contours.forEach(c => { c.Outline.ColorIndex = 2 });
|
|
|
|
|
// this.m_RetCurves.push(...this.m_Contours.map(c => c.Outline))
|
|
|
|
|
return this.m_RetCurves;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -192,6 +192,12 @@ export class PolyOffestUtil
|
|
|
|
|
this.unNeedCutCus.push(splitCus[1])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//防止轮廓自交
|
|
|
|
|
if (l1.IntersectWith(l2, 0).length > 0)
|
|
|
|
|
{
|
|
|
|
|
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,
|
|
|
|
@ -541,15 +547,20 @@ export class PolyOffestUtil
|
|
|
|
|
|
|
|
|
|
//需要计算的点列表
|
|
|
|
|
let needCaclPts: Vector3[] = [];
|
|
|
|
|
for (let i = 0; i < iParams.length - 1; i++)
|
|
|
|
|
if (iParams.length === 0)
|
|
|
|
|
needCaclPts = [l.StartPoint]
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
needCaclPts.push(l.GetPointAtParam((iParams[i] + iParams[i + 1]) / 2));
|
|
|
|
|
for (let i = 0; i < iParams.length - 1; i++)
|
|
|
|
|
{
|
|
|
|
|
needCaclPts.push(l.GetPointAtParam((iParams[i] + iParams[i + 1]) / 2));
|
|
|
|
|
}
|
|
|
|
|
//如果交点不是首尾点,就加入首尾点
|
|
|
|
|
if (!equaln(iParams[0], 0, 1e-6))
|
|
|
|
|
needCaclPts.unshift(l.StartPoint);
|
|
|
|
|
if (!equaln(arrayLast(iParams), 1, 1e-6))
|
|
|
|
|
needCaclPts.push(l.EndPoint);
|
|
|
|
|
}
|
|
|
|
|
//如果交点不是首尾点,就加入首尾点
|
|
|
|
|
if (!equaln(iParams[0], 0, 1e-6))
|
|
|
|
|
needCaclPts.unshift(l.StartPoint);
|
|
|
|
|
if (!equaln(arrayLast(iParams), 1, 1e-6))
|
|
|
|
|
needCaclPts.push(l.EndPoint);
|
|
|
|
|
|
|
|
|
|
//切割曲线,缓存切割后曲线包围盒
|
|
|
|
|
if (IsPtsAllOutOrOnReg(outline, needCaclPts))
|
|
|
|
|